@openwarelabs/ui 0.4.0 → 0.5.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.
- package/README.md +3 -2
- package/dist/components/ChainOfThought/ChainOfThought.d.cts +44 -0
- package/dist/components/ChainOfThought/ChainOfThought.d.ts +44 -0
- package/dist/components/Chat/ChatConversation.d.cts +48 -0
- package/dist/components/Chat/ChatConversation.d.ts +48 -0
- package/dist/components/Chat/ChatLoader.d.cts +21 -0
- package/dist/components/Chat/ChatLoader.d.ts +21 -0
- package/dist/components/Chat/ChatMessage.d.cts +93 -0
- package/dist/components/Chat/ChatMessage.d.ts +93 -0
- package/dist/components/ChatSource/ChatSource.d.cts +58 -0
- package/dist/components/ChatSource/ChatSource.d.ts +58 -0
- package/dist/components/ChatTool/ChatTool.d.cts +89 -0
- package/dist/components/ChatTool/ChatTool.d.ts +89 -0
- package/dist/components/PromptInput/PromptInput.d.cts +95 -0
- package/dist/components/PromptInput/PromptInput.d.ts +95 -0
- package/dist/components/PromptInput/PromptSuggestion.d.cts +36 -0
- package/dist/components/PromptInput/PromptSuggestion.d.ts +36 -0
- package/dist/components/Prose/Prose.d.cts +22 -0
- package/dist/components/Prose/Prose.d.ts +22 -0
- package/dist/components/TextShimmer/TextShimmer.d.cts +20 -0
- package/dist/components/TextShimmer/TextShimmer.d.ts +20 -0
- package/dist/components.css +2524 -0
- package/dist/index.cjs +1548 -73
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.cts +20 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +1573 -72
- package/dist/index.js.map +4 -4
- package/dist/openware-ui.iife.js +7 -6
- package/dist/styles.css +2524 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -31,6 +31,15 @@ __export(index_exports, {
|
|
|
31
31
|
ButtonGroup: () => ButtonGroup,
|
|
32
32
|
Calendar: () => Calendar,
|
|
33
33
|
Card: () => Card,
|
|
34
|
+
ChainOfThought: () => ChainOfThought,
|
|
35
|
+
ChatAgentAvatar: () => ChatAgentAvatar,
|
|
36
|
+
ChatConversation: () => ChatConversation,
|
|
37
|
+
ChatLoader: () => ChatLoader,
|
|
38
|
+
ChatMessage: () => ChatMessage,
|
|
39
|
+
ChatMessageActions: () => ChatMessageActions,
|
|
40
|
+
ChatSource: () => ChatSource,
|
|
41
|
+
ChatSources: () => ChatSources,
|
|
42
|
+
ChatTool: () => ChatTool,
|
|
34
43
|
Checkbox: () => Checkbox,
|
|
35
44
|
CheckboxGroup: () => CheckboxGroup,
|
|
36
45
|
Chip: () => Chip,
|
|
@@ -79,6 +88,10 @@ __export(index_exports, {
|
|
|
79
88
|
Popover: () => Popover,
|
|
80
89
|
ProgressBar: () => ProgressBar,
|
|
81
90
|
ProgressCircle: () => ProgressCircle,
|
|
91
|
+
PromptInput: () => PromptInput,
|
|
92
|
+
PromptSuggestion: () => PromptSuggestion,
|
|
93
|
+
PromptSuggestions: () => PromptSuggestions,
|
|
94
|
+
Prose: () => Prose,
|
|
82
95
|
Radio: () => Radio,
|
|
83
96
|
RadioGroup: () => RadioGroup,
|
|
84
97
|
RangeCalendar: () => RangeCalendar,
|
|
@@ -107,6 +120,7 @@ __export(index_exports, {
|
|
|
107
120
|
Tag: () => Tag,
|
|
108
121
|
TagGroup: () => TagGroup,
|
|
109
122
|
Text: () => Text,
|
|
123
|
+
TextShimmer: () => TextShimmer,
|
|
110
124
|
Textarea: () => Textarea,
|
|
111
125
|
TimeField: () => TimeField,
|
|
112
126
|
Toaster: () => Toaster,
|
|
@@ -3931,7 +3945,7 @@ function FileDropZone({
|
|
|
3931
3945
|
}
|
|
3932
3946
|
keep(kept.current);
|
|
3933
3947
|
}
|
|
3934
|
-
const
|
|
3948
|
+
const hasFiles2 = (event) => event.dataTransfer.types.includes("Files");
|
|
3935
3949
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
3936
3950
|
"label",
|
|
3937
3951
|
{
|
|
@@ -3943,13 +3957,13 @@ function FileDropZone({
|
|
|
3943
3957
|
className
|
|
3944
3958
|
),
|
|
3945
3959
|
onDragEnter: (event) => {
|
|
3946
|
-
if (!
|
|
3960
|
+
if (!hasFiles2(event) || disabled) return;
|
|
3947
3961
|
event.preventDefault();
|
|
3948
3962
|
depth.current += 1;
|
|
3949
3963
|
setIsDragging(true);
|
|
3950
3964
|
},
|
|
3951
3965
|
onDragOver: (event) => {
|
|
3952
|
-
if (!
|
|
3966
|
+
if (!hasFiles2(event) || disabled) return;
|
|
3953
3967
|
event.preventDefault();
|
|
3954
3968
|
event.dataTransfer.dropEffect = "copy";
|
|
3955
3969
|
},
|
|
@@ -3958,7 +3972,7 @@ function FileDropZone({
|
|
|
3958
3972
|
if (depth.current === 0) setIsDragging(false);
|
|
3959
3973
|
},
|
|
3960
3974
|
onDrop: (event) => {
|
|
3961
|
-
if (!
|
|
3975
|
+
if (!hasFiles2(event)) return;
|
|
3962
3976
|
event.preventDefault();
|
|
3963
3977
|
depth.current = 0;
|
|
3964
3978
|
setIsDragging(false);
|
|
@@ -6474,10 +6488,1471 @@ function DotGrid({ fade = false, interactive = false, className, children, onPoi
|
|
|
6474
6488
|
);
|
|
6475
6489
|
}
|
|
6476
6490
|
|
|
6477
|
-
// src/components/
|
|
6491
|
+
// src/components/Prose/Prose.tsx
|
|
6478
6492
|
var import_react57 = require("react");
|
|
6479
|
-
var import_react_colorful = require("react-colorful");
|
|
6480
6493
|
var import_jsx_runtime62 = require("react/jsx-runtime");
|
|
6494
|
+
var Prose = (0, import_react57.forwardRef)(function Prose2({ size: size2 = "md", fullWidth = false, as = "div", className, children, ...props }, ref) {
|
|
6495
|
+
const Element2 = as;
|
|
6496
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
|
|
6497
|
+
Element2,
|
|
6498
|
+
{
|
|
6499
|
+
ref,
|
|
6500
|
+
className: cx("ow-prose", `ow-prose--${size2}`, size2 === "md" ? "ow-type-prose" : "ow-type-copy", fullWidth && "ow-prose--full", className),
|
|
6501
|
+
...props,
|
|
6502
|
+
children
|
|
6503
|
+
}
|
|
6504
|
+
);
|
|
6505
|
+
});
|
|
6506
|
+
|
|
6507
|
+
// src/components/TextShimmer/TextShimmer.tsx
|
|
6508
|
+
var import_jsx_runtime63 = require("react/jsx-runtime");
|
|
6509
|
+
function TextShimmer({ children, as = "span", duration = 2, active = true, className }) {
|
|
6510
|
+
const Element2 = as;
|
|
6511
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
6512
|
+
Element2,
|
|
6513
|
+
{
|
|
6514
|
+
className: cx("ow-shimmer", active && "ow-shimmer--active", className),
|
|
6515
|
+
style: active ? { "--ow-shimmer-duration": `${duration}s` } : void 0,
|
|
6516
|
+
children
|
|
6517
|
+
}
|
|
6518
|
+
);
|
|
6519
|
+
}
|
|
6520
|
+
|
|
6521
|
+
// src/components/PromptInput/PromptInput.tsx
|
|
6522
|
+
var import_react58 = require("react");
|
|
6523
|
+
var import_jsx_runtime64 = require("react/jsx-runtime");
|
|
6524
|
+
var noAttachments = [];
|
|
6525
|
+
var counterFrom = 0.8;
|
|
6526
|
+
var announceDelay = 1e3;
|
|
6527
|
+
function Glyph({ children }) {
|
|
6528
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
6529
|
+
"svg",
|
|
6530
|
+
{
|
|
6531
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
6532
|
+
width: 16,
|
|
6533
|
+
height: 16,
|
|
6534
|
+
viewBox: "0 0 24 24",
|
|
6535
|
+
fill: "none",
|
|
6536
|
+
stroke: "currentColor",
|
|
6537
|
+
strokeWidth: 2,
|
|
6538
|
+
strokeLinecap: "round",
|
|
6539
|
+
strokeLinejoin: "round",
|
|
6540
|
+
"aria-hidden": "true",
|
|
6541
|
+
focusable: "false",
|
|
6542
|
+
children
|
|
6543
|
+
}
|
|
6544
|
+
);
|
|
6545
|
+
}
|
|
6546
|
+
var sheet = "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z";
|
|
6547
|
+
var fold = "M14 2v5a1 1 0 0 0 1 1h5";
|
|
6548
|
+
var PaperclipIcon = () => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Glyph, { children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("path", { d: "m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551" }) });
|
|
6549
|
+
var StopIcon = () => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Glyph, { children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("rect", { x: "6", y: "6", width: "12", height: "12", rx: "2", fill: "currentColor", stroke: "none" }) });
|
|
6550
|
+
var fileIcons = {
|
|
6551
|
+
image: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(Glyph, { children: [
|
|
6552
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("path", { d: sheet }),
|
|
6553
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("path", { d: fold }),
|
|
6554
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("circle", { cx: "10", cy: "12", r: "2" }),
|
|
6555
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("path", { d: "m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22" })
|
|
6556
|
+
] }),
|
|
6557
|
+
code: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(Glyph, { children: [
|
|
6558
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("path", { d: sheet }),
|
|
6559
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("path", { d: fold }),
|
|
6560
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("path", { d: "M10 12.5 8 15l2 2.5" }),
|
|
6561
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("path", { d: "m14 12.5 2 2.5-2 2.5" })
|
|
6562
|
+
] }),
|
|
6563
|
+
text: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(Glyph, { children: [
|
|
6564
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("path", { d: sheet }),
|
|
6565
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("path", { d: fold }),
|
|
6566
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("path", { d: "M10 9H8" }),
|
|
6567
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("path", { d: "M16 13H8" }),
|
|
6568
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("path", { d: "M16 17H8" })
|
|
6569
|
+
] }),
|
|
6570
|
+
file: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(FileIcon, { size: 16 })
|
|
6571
|
+
};
|
|
6572
|
+
function kindOf({ name, type = "" }) {
|
|
6573
|
+
const lower = name.toLowerCase();
|
|
6574
|
+
if (type.startsWith("image/") || /\.(png|jpe?g|gif|webp|avif|heic|svg)$/.test(lower)) return "image";
|
|
6575
|
+
if (/\.(tsx?|jsx?|mjs|cjs|py|go|rs|rb|java|kt|swift|c|cc|cpp|h|cs|php|css|scss|html|json|ya?ml|toml|sql|sh)$/.test(lower)) return "code";
|
|
6576
|
+
if (type.startsWith("text/") || type === "application/pdf" || /\.(txt|md|log|csv|pdf|docx?|rtf)$/.test(lower)) return "text";
|
|
6577
|
+
return "file";
|
|
6578
|
+
}
|
|
6579
|
+
function splitName(name) {
|
|
6580
|
+
const dot = name.lastIndexOf(".");
|
|
6581
|
+
if (dot <= 0 || name.length - dot > 8) return [name, ""];
|
|
6582
|
+
return [name.slice(0, dot), name.slice(dot)];
|
|
6583
|
+
}
|
|
6584
|
+
function formatBytes(bytes, locale) {
|
|
6585
|
+
const units = ["byte", "kilobyte", "megabyte", "gigabyte"];
|
|
6586
|
+
let value = bytes;
|
|
6587
|
+
let unit = 0;
|
|
6588
|
+
while (value >= 1e3 && unit < units.length - 1) {
|
|
6589
|
+
value /= 1e3;
|
|
6590
|
+
unit += 1;
|
|
6591
|
+
}
|
|
6592
|
+
return new Intl.NumberFormat(locale, {
|
|
6593
|
+
style: "unit",
|
|
6594
|
+
unit: units[unit],
|
|
6595
|
+
unitDisplay: unit === 0 ? "long" : "short",
|
|
6596
|
+
maximumFractionDigits: unit > 0 && value < 10 ? 1 : 0
|
|
6597
|
+
}).format(value);
|
|
6598
|
+
}
|
|
6599
|
+
function accepts(file, accept) {
|
|
6600
|
+
if (!accept) return true;
|
|
6601
|
+
return accept.split(",").some((rule) => {
|
|
6602
|
+
const pattern = rule.trim().toLowerCase();
|
|
6603
|
+
if (!pattern) return false;
|
|
6604
|
+
if (pattern.startsWith(".")) return file.name.toLowerCase().endsWith(pattern);
|
|
6605
|
+
if (pattern.endsWith("/*")) return file.type.toLowerCase().startsWith(pattern.slice(0, -1));
|
|
6606
|
+
return file.type.toLowerCase() === pattern;
|
|
6607
|
+
});
|
|
6608
|
+
}
|
|
6609
|
+
var hasFiles = (event) => Array.from(event.dataTransfer.types).includes("Files");
|
|
6610
|
+
var PromptInput = (0, import_react58.forwardRef)(function PromptInput2({
|
|
6611
|
+
value,
|
|
6612
|
+
defaultValue = "",
|
|
6613
|
+
onChange,
|
|
6614
|
+
onSubmit,
|
|
6615
|
+
isStreaming = false,
|
|
6616
|
+
onStop,
|
|
6617
|
+
attachments = noAttachments,
|
|
6618
|
+
onAttach,
|
|
6619
|
+
onRemoveAttachment,
|
|
6620
|
+
accept,
|
|
6621
|
+
multiple = true,
|
|
6622
|
+
startActions,
|
|
6623
|
+
endActions,
|
|
6624
|
+
hint,
|
|
6625
|
+
placeholder = "Message the agent\u2026",
|
|
6626
|
+
"aria-label": ariaLabel,
|
|
6627
|
+
"aria-labelledby": ariaLabelledBy,
|
|
6628
|
+
"aria-describedby": ariaDescribedBy,
|
|
6629
|
+
id,
|
|
6630
|
+
isInvalid = false,
|
|
6631
|
+
disabled = false,
|
|
6632
|
+
autoFocus = false,
|
|
6633
|
+
maxLength,
|
|
6634
|
+
minRows = 1,
|
|
6635
|
+
maxRows = 8,
|
|
6636
|
+
size: size2 = "md",
|
|
6637
|
+
locale,
|
|
6638
|
+
onKeyDown,
|
|
6639
|
+
className
|
|
6640
|
+
}, ref) {
|
|
6641
|
+
const [text, setText] = useControllableState(value, defaultValue, onChange);
|
|
6642
|
+
const textAreaRef = (0, import_react58.useRef)(null);
|
|
6643
|
+
const actionRef = (0, import_react58.useRef)(null);
|
|
6644
|
+
const pickerRef = (0, import_react58.useRef)(null);
|
|
6645
|
+
const listRef = (0, import_react58.useRef)(null);
|
|
6646
|
+
const composing = (0, import_react58.useRef)(false);
|
|
6647
|
+
const dragDepth = (0, import_react58.useRef)(0);
|
|
6648
|
+
const pendingFocus = (0, import_react58.useRef)(null);
|
|
6649
|
+
const [isDragging, setIsDragging] = (0, import_react58.useState)(false);
|
|
6650
|
+
const [notice, setNotice] = (0, import_react58.useState)();
|
|
6651
|
+
const [announcement, setAnnouncement] = (0, import_react58.useState)("");
|
|
6652
|
+
const hintId = (0, import_react58.useId)();
|
|
6653
|
+
const rows = Math.max(1, Math.round(minRows));
|
|
6654
|
+
const maxRowCount = Math.max(rows, Math.round(maxRows));
|
|
6655
|
+
const canAttach = Boolean(onAttach) && !disabled;
|
|
6656
|
+
const hasContent = text.trim().length > 0 || attachments.length > 0;
|
|
6657
|
+
const canSend = hasContent && !disabled && !isStreaming;
|
|
6658
|
+
const toolbarStart = Boolean(onAttach || startActions);
|
|
6659
|
+
const inline = !toolbarStart && !endActions;
|
|
6660
|
+
const showCounter = maxLength !== void 0 && maxLength > 0 && text.length >= maxLength * counterFrom;
|
|
6661
|
+
const remaining = maxLength === void 0 ? 0 : Math.max(0, maxLength - text.length);
|
|
6662
|
+
const number = (count) => new Intl.NumberFormat(locale).format(count);
|
|
6663
|
+
const shownHint = notice ?? hint;
|
|
6664
|
+
const describedBy = [ariaDescribedBy, hint && !notice ? hintId : void 0].filter(Boolean).join(" ") || void 0;
|
|
6665
|
+
const name = ariaLabel ?? (ariaLabelledBy || id ? void 0 : "Message");
|
|
6666
|
+
function setTextAreaRef(element) {
|
|
6667
|
+
textAreaRef.current = element;
|
|
6668
|
+
if (typeof ref === "function") ref(element);
|
|
6669
|
+
else if (ref) ref.current = element;
|
|
6670
|
+
}
|
|
6671
|
+
(0, import_react58.useEffect)(() => {
|
|
6672
|
+
const textArea = textAreaRef.current;
|
|
6673
|
+
if (!textArea || typeof ResizeObserver === "undefined") return;
|
|
6674
|
+
let width = textArea.clientWidth;
|
|
6675
|
+
const observer = new ResizeObserver(() => {
|
|
6676
|
+
if (textArea.clientWidth === width) return;
|
|
6677
|
+
width = textArea.clientWidth;
|
|
6678
|
+
resizeTextArea(textArea);
|
|
6679
|
+
});
|
|
6680
|
+
observer.observe(textArea);
|
|
6681
|
+
return () => observer.disconnect();
|
|
6682
|
+
}, []);
|
|
6683
|
+
(0, import_react58.useLayoutEffect)(() => {
|
|
6684
|
+
if (textAreaRef.current) resizeTextArea(textAreaRef.current);
|
|
6685
|
+
}, [size2, rows]);
|
|
6686
|
+
const wasStreaming = (0, import_react58.useRef)(isStreaming);
|
|
6687
|
+
const actionHadFocus = (0, import_react58.useRef)(false);
|
|
6688
|
+
if (wasStreaming.current !== isStreaming) {
|
|
6689
|
+
actionHadFocus.current = typeof document !== "undefined" && document.activeElement === actionRef.current;
|
|
6690
|
+
}
|
|
6691
|
+
(0, import_react58.useLayoutEffect)(() => {
|
|
6692
|
+
if (wasStreaming.current && !isStreaming && actionHadFocus.current && !hasContent) textAreaRef.current?.focus();
|
|
6693
|
+
wasStreaming.current = isStreaming;
|
|
6694
|
+
actionHadFocus.current = false;
|
|
6695
|
+
}, [isStreaming, hasContent]);
|
|
6696
|
+
(0, import_react58.useLayoutEffect)(() => {
|
|
6697
|
+
const pending = pendingFocus.current;
|
|
6698
|
+
if (!pending) return;
|
|
6699
|
+
pendingFocus.current = null;
|
|
6700
|
+
if (attachments.some((attachment) => attachment.id === pending.id)) return;
|
|
6701
|
+
const buttons = listRef.current?.querySelectorAll(".ow-prompt-input__remove");
|
|
6702
|
+
const next = buttons?.length ? buttons[Math.min(pending.index, buttons.length - 1)] : void 0;
|
|
6703
|
+
(next ?? textAreaRef.current)?.focus();
|
|
6704
|
+
}, [attachments]);
|
|
6705
|
+
(0, import_react58.useEffect)(() => {
|
|
6706
|
+
if (!showCounter || document.activeElement !== textAreaRef.current) return;
|
|
6707
|
+
const timer = window.setTimeout(() => {
|
|
6708
|
+
setAnnouncement(`${number(remaining)} ${remaining === 1 ? "character" : "characters"} left`);
|
|
6709
|
+
}, announceDelay);
|
|
6710
|
+
return () => window.clearTimeout(timer);
|
|
6711
|
+
}, [showCounter, remaining, locale]);
|
|
6712
|
+
function submit() {
|
|
6713
|
+
if (!canSend) return;
|
|
6714
|
+
onSubmit?.(text.trim(), attachments);
|
|
6715
|
+
setNotice(void 0);
|
|
6716
|
+
if (value === void 0) setText("");
|
|
6717
|
+
}
|
|
6718
|
+
function stop() {
|
|
6719
|
+
if (isStreaming && !disabled) onStop?.();
|
|
6720
|
+
}
|
|
6721
|
+
function take(list) {
|
|
6722
|
+
if (!canAttach || !list.length) return;
|
|
6723
|
+
const files = multiple ? list : list.slice(0, 1);
|
|
6724
|
+
const refused = files.find((file) => !accepts(file, accept));
|
|
6725
|
+
const taken = files.filter((file) => accepts(file, accept));
|
|
6726
|
+
let message;
|
|
6727
|
+
if (refused) message = `\u201C${refused.name}\u201D isn't a file this accepts.`;
|
|
6728
|
+
else if (!multiple && list.length > 1) message = "Attach one file at a time.";
|
|
6729
|
+
setNotice(message);
|
|
6730
|
+
if (message) setAnnouncement(message);
|
|
6731
|
+
if (taken.length) onAttach?.(taken);
|
|
6732
|
+
}
|
|
6733
|
+
function remove(attachment, index) {
|
|
6734
|
+
if (listRef.current?.contains(document.activeElement)) pendingFocus.current = { id: attachment.id, index };
|
|
6735
|
+
onRemoveAttachment?.(attachment.id);
|
|
6736
|
+
}
|
|
6737
|
+
function handleKeyDown(event) {
|
|
6738
|
+
onKeyDown?.(event);
|
|
6739
|
+
if (event.defaultPrevented) return;
|
|
6740
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
6741
|
+
if (composing.current || event.nativeEvent.isComposing || event.keyCode === 229) return;
|
|
6742
|
+
event.preventDefault();
|
|
6743
|
+
submit();
|
|
6744
|
+
} else if (event.key === "Escape" && isStreaming && onStop) {
|
|
6745
|
+
event.preventDefault();
|
|
6746
|
+
event.stopPropagation();
|
|
6747
|
+
stop();
|
|
6748
|
+
}
|
|
6749
|
+
}
|
|
6750
|
+
function handlePaste(event) {
|
|
6751
|
+
if (!canAttach) return;
|
|
6752
|
+
const files = Array.from(event.clipboardData.files);
|
|
6753
|
+
if (!files.length || event.clipboardData.getData("text/plain")) return;
|
|
6754
|
+
event.preventDefault();
|
|
6755
|
+
take(files);
|
|
6756
|
+
}
|
|
6757
|
+
function handleMouseDown(event) {
|
|
6758
|
+
const target = event.target;
|
|
6759
|
+
if (disabled || target !== event.currentTarget && !target.hasAttribute("data-prompt-blank")) return;
|
|
6760
|
+
event.preventDefault();
|
|
6761
|
+
textAreaRef.current?.focus();
|
|
6762
|
+
}
|
|
6763
|
+
const attachButton = onAttach ? /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Tooltip, { label: "Attach files", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
6764
|
+
Button,
|
|
6765
|
+
{
|
|
6766
|
+
className: "ow-prompt-input__attach",
|
|
6767
|
+
variant: "ghost",
|
|
6768
|
+
size: "sm",
|
|
6769
|
+
iconOnly: true,
|
|
6770
|
+
"aria-label": multiple ? "Attach files" : "Attach a file",
|
|
6771
|
+
disabled,
|
|
6772
|
+
onClick: () => pickerRef.current?.click(),
|
|
6773
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(PaperclipIcon, {})
|
|
6774
|
+
}
|
|
6775
|
+
) }) : null;
|
|
6776
|
+
const actionLabel = isStreaming ? "Stop" : "Send";
|
|
6777
|
+
const actionButton = /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Tooltip, { label: actionLabel, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
6778
|
+
Button,
|
|
6779
|
+
{
|
|
6780
|
+
ref: actionRef,
|
|
6781
|
+
className: "ow-prompt-input__action",
|
|
6782
|
+
variant: "primary",
|
|
6783
|
+
size: "sm",
|
|
6784
|
+
iconOnly: true,
|
|
6785
|
+
"aria-label": actionLabel,
|
|
6786
|
+
disabled: disabled || (isStreaming ? !onStop : !hasContent),
|
|
6787
|
+
onClick: () => {
|
|
6788
|
+
if (isStreaming) stop();
|
|
6789
|
+
else submit();
|
|
6790
|
+
textAreaRef.current?.focus();
|
|
6791
|
+
},
|
|
6792
|
+
children: isStreaming ? /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(StopIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ArrowUpIcon, { size: 16 })
|
|
6793
|
+
}
|
|
6794
|
+
) });
|
|
6795
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
|
|
6796
|
+
"div",
|
|
6797
|
+
{
|
|
6798
|
+
className: cx(
|
|
6799
|
+
"ow-prompt-input",
|
|
6800
|
+
`ow-prompt-input--${size2}`,
|
|
6801
|
+
inline && "ow-prompt-input--inline",
|
|
6802
|
+
isInvalid && "ow-prompt-input--invalid",
|
|
6803
|
+
disabled && "ow-prompt-input--disabled",
|
|
6804
|
+
isDragging && "ow-prompt-input--dragging",
|
|
6805
|
+
className
|
|
6806
|
+
),
|
|
6807
|
+
style: { "--ow-prompt-min-rows": rows, "--ow-prompt-max-rows": maxRowCount },
|
|
6808
|
+
children: [
|
|
6809
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
|
|
6810
|
+
"fieldset",
|
|
6811
|
+
{
|
|
6812
|
+
role: "presentation",
|
|
6813
|
+
className: "ow-prompt-input__box",
|
|
6814
|
+
disabled,
|
|
6815
|
+
onMouseDown: handleMouseDown,
|
|
6816
|
+
onDragEnter: (event) => {
|
|
6817
|
+
if (!canAttach || !hasFiles(event)) return;
|
|
6818
|
+
event.preventDefault();
|
|
6819
|
+
dragDepth.current += 1;
|
|
6820
|
+
setIsDragging(true);
|
|
6821
|
+
},
|
|
6822
|
+
onDragOver: (event) => {
|
|
6823
|
+
if (!canAttach || !hasFiles(event)) return;
|
|
6824
|
+
event.preventDefault();
|
|
6825
|
+
event.dataTransfer.dropEffect = "copy";
|
|
6826
|
+
},
|
|
6827
|
+
onDragLeave: () => {
|
|
6828
|
+
dragDepth.current = Math.max(0, dragDepth.current - 1);
|
|
6829
|
+
if (dragDepth.current === 0) setIsDragging(false);
|
|
6830
|
+
},
|
|
6831
|
+
onDrop: (event) => {
|
|
6832
|
+
if (!canAttach || !hasFiles(event)) return;
|
|
6833
|
+
event.preventDefault();
|
|
6834
|
+
dragDepth.current = 0;
|
|
6835
|
+
setIsDragging(false);
|
|
6836
|
+
take(Array.from(event.dataTransfer.files));
|
|
6837
|
+
},
|
|
6838
|
+
children: [
|
|
6839
|
+
attachments.length ? /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("ul", { ref: listRef, className: "ow-prompt-input__attachments", "aria-label": "Attachments", children: attachments.map((attachment, index) => {
|
|
6840
|
+
const [base, extension] = splitName(attachment.name);
|
|
6841
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("li", { className: "ow-prompt-input__attachment", children: [
|
|
6842
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("span", { className: "ow-prompt-input__thumb", "aria-hidden": "true", children: [
|
|
6843
|
+
fileIcons[kindOf(attachment)],
|
|
6844
|
+
attachment.previewUrl ? /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
6845
|
+
"img",
|
|
6846
|
+
{
|
|
6847
|
+
src: attachment.previewUrl,
|
|
6848
|
+
alt: "",
|
|
6849
|
+
onError: (event) => {
|
|
6850
|
+
event.currentTarget.hidden = true;
|
|
6851
|
+
}
|
|
6852
|
+
}
|
|
6853
|
+
) : null
|
|
6854
|
+
] }),
|
|
6855
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("span", { className: "ow-prompt-input__file", children: [
|
|
6856
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("span", { className: "ow-prompt-input__file-name", title: attachment.name, children: [
|
|
6857
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "ow-prompt-input__file-base", children: base }),
|
|
6858
|
+
extension
|
|
6859
|
+
] }),
|
|
6860
|
+
attachment.size !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "ow-prompt-input__file-size", children: formatBytes(attachment.size, locale) }) : null
|
|
6861
|
+
] }),
|
|
6862
|
+
onRemoveAttachment ? /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
6863
|
+
"button",
|
|
6864
|
+
{
|
|
6865
|
+
type: "button",
|
|
6866
|
+
className: "ow-prompt-input__remove",
|
|
6867
|
+
"aria-label": `Remove ${attachment.name}`,
|
|
6868
|
+
onClick: () => remove(attachment, index),
|
|
6869
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(XIcon, { size: 14 })
|
|
6870
|
+
}
|
|
6871
|
+
) : null
|
|
6872
|
+
] }, attachment.id);
|
|
6873
|
+
}) }) : null,
|
|
6874
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
6875
|
+
Textarea,
|
|
6876
|
+
{
|
|
6877
|
+
ref: setTextAreaRef,
|
|
6878
|
+
className: "ow-prompt-input__textarea",
|
|
6879
|
+
bare: true,
|
|
6880
|
+
autoGrow: true,
|
|
6881
|
+
autoGrowMaxHeight: `calc(var(--ow-prompt-line) * ${maxRowCount} + 2 * var(--ow-prompt-pad))`,
|
|
6882
|
+
rows,
|
|
6883
|
+
id,
|
|
6884
|
+
value: text,
|
|
6885
|
+
placeholder,
|
|
6886
|
+
"aria-label": name,
|
|
6887
|
+
"aria-labelledby": ariaLabelledBy,
|
|
6888
|
+
"aria-describedby": describedBy,
|
|
6889
|
+
isInvalid,
|
|
6890
|
+
disabled,
|
|
6891
|
+
autoFocus,
|
|
6892
|
+
maxLength,
|
|
6893
|
+
enterKeyHint: "send",
|
|
6894
|
+
onChange: (event) => setText(event.target.value),
|
|
6895
|
+
onKeyDown: handleKeyDown,
|
|
6896
|
+
onPaste: handlePaste,
|
|
6897
|
+
onCompositionStart: () => {
|
|
6898
|
+
composing.current = true;
|
|
6899
|
+
},
|
|
6900
|
+
onCompositionEnd: () => {
|
|
6901
|
+
composing.current = false;
|
|
6902
|
+
}
|
|
6903
|
+
}
|
|
6904
|
+
),
|
|
6905
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "ow-prompt-input__toolbar", "data-prompt-blank": "", children: [
|
|
6906
|
+
toolbarStart ? /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "ow-prompt-input__start", "data-prompt-blank": "", children: [
|
|
6907
|
+
attachButton,
|
|
6908
|
+
startActions
|
|
6909
|
+
] }) : null,
|
|
6910
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "ow-prompt-input__end", "data-prompt-blank": "", children: [
|
|
6911
|
+
showCounter ? /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("span", { className: cx("ow-prompt-input__counter", remaining === 0 && "ow-prompt-input__counter--full"), "aria-hidden": "true", children: [
|
|
6912
|
+
number(text.length),
|
|
6913
|
+
" / ",
|
|
6914
|
+
number(maxLength)
|
|
6915
|
+
] }) : null,
|
|
6916
|
+
endActions,
|
|
6917
|
+
actionButton
|
|
6918
|
+
] })
|
|
6919
|
+
] }),
|
|
6920
|
+
onAttach ? /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
6921
|
+
"input",
|
|
6922
|
+
{
|
|
6923
|
+
ref: pickerRef,
|
|
6924
|
+
type: "file",
|
|
6925
|
+
hidden: true,
|
|
6926
|
+
tabIndex: -1,
|
|
6927
|
+
accept,
|
|
6928
|
+
multiple,
|
|
6929
|
+
onChange: (event) => {
|
|
6930
|
+
take(Array.from(event.target.files ?? []));
|
|
6931
|
+
event.target.value = "";
|
|
6932
|
+
textAreaRef.current?.focus();
|
|
6933
|
+
}
|
|
6934
|
+
}
|
|
6935
|
+
) : null,
|
|
6936
|
+
isDragging ? /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "ow-prompt-input__drop", "aria-hidden": "true", children: [
|
|
6937
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(UploadIcon, { size: 16 }),
|
|
6938
|
+
"Drop to attach"
|
|
6939
|
+
] }) : null
|
|
6940
|
+
]
|
|
6941
|
+
}
|
|
6942
|
+
),
|
|
6943
|
+
shownHint ? /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
6944
|
+
"div",
|
|
6945
|
+
{
|
|
6946
|
+
className: cx("ow-prompt-input__hint", notice && "ow-prompt-input__hint--notice"),
|
|
6947
|
+
id: notice ? void 0 : hintId,
|
|
6948
|
+
"aria-hidden": notice ? true : void 0,
|
|
6949
|
+
children: shownHint
|
|
6950
|
+
}
|
|
6951
|
+
) : null,
|
|
6952
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "ow-visually-hidden", role: "status", children: announcement })
|
|
6953
|
+
]
|
|
6954
|
+
}
|
|
6955
|
+
);
|
|
6956
|
+
});
|
|
6957
|
+
|
|
6958
|
+
// src/components/PromptInput/PromptSuggestion.tsx
|
|
6959
|
+
var import_react59 = require("react");
|
|
6960
|
+
var import_jsx_runtime65 = require("react/jsx-runtime");
|
|
6961
|
+
var PromptSuggestion = (0, import_react59.forwardRef)(function PromptSuggestion2({ children, icon: icon2, description, variant = description ? "card" : "pill", type = "button", className, ...buttonProps }, ref) {
|
|
6962
|
+
if (variant === "card") {
|
|
6963
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("button", { ref, type, className: cx("ow-prompt-suggestion", "ow-prompt-suggestion--card", className), ...buttonProps, children: [
|
|
6964
|
+
icon2 ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { className: "ow-prompt-suggestion__icon", children: icon2 }) : null,
|
|
6965
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("span", { className: "ow-prompt-suggestion__text", children: [
|
|
6966
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { className: "ow-prompt-suggestion__title", children }),
|
|
6967
|
+
description ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { className: "ow-prompt-suggestion__description", children: description }) : null
|
|
6968
|
+
] })
|
|
6969
|
+
] });
|
|
6970
|
+
}
|
|
6971
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
|
|
6972
|
+
"button",
|
|
6973
|
+
{
|
|
6974
|
+
ref,
|
|
6975
|
+
type,
|
|
6976
|
+
className: cx(
|
|
6977
|
+
buttonClassName({ variant: "secondary", size: "sm", shape: "pill" }),
|
|
6978
|
+
"ow-prompt-suggestion",
|
|
6979
|
+
"ow-prompt-suggestion--pill",
|
|
6980
|
+
className
|
|
6981
|
+
),
|
|
6982
|
+
...buttonProps,
|
|
6983
|
+
children: [
|
|
6984
|
+
icon2 ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { className: "ow-prompt-suggestion__icon", children: icon2 }) : null,
|
|
6985
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { className: "ow-prompt-suggestion__label", children })
|
|
6986
|
+
]
|
|
6987
|
+
}
|
|
6988
|
+
);
|
|
6989
|
+
});
|
|
6990
|
+
function PromptSuggestions({
|
|
6991
|
+
children,
|
|
6992
|
+
layout = "wrap",
|
|
6993
|
+
columns = 2,
|
|
6994
|
+
align = "start",
|
|
6995
|
+
"aria-label": ariaLabel = "Suggested prompts",
|
|
6996
|
+
className,
|
|
6997
|
+
style,
|
|
6998
|
+
...props
|
|
6999
|
+
}) {
|
|
7000
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
7001
|
+
"div",
|
|
7002
|
+
{
|
|
7003
|
+
role: "group",
|
|
7004
|
+
"aria-label": ariaLabel,
|
|
7005
|
+
className: cx("ow-prompt-suggestions", `ow-prompt-suggestions--${layout}`, align === "center" && "ow-prompt-suggestions--center", className),
|
|
7006
|
+
style: layout === "grid" ? { "--ow-suggestion-columns": Math.max(1, Math.round(columns)), ...style } : style,
|
|
7007
|
+
...props,
|
|
7008
|
+
children
|
|
7009
|
+
}
|
|
7010
|
+
);
|
|
7011
|
+
}
|
|
7012
|
+
|
|
7013
|
+
// src/components/Chat/ChatConversation.tsx
|
|
7014
|
+
var import_react60 = require("react");
|
|
7015
|
+
var import_jsx_runtime66 = require("react/jsx-runtime");
|
|
7016
|
+
var ChatConversationContext = (0, import_react60.createContext)(null);
|
|
7017
|
+
var stickyDistance = 32;
|
|
7018
|
+
var defaultCount = (count) => `${count} new`;
|
|
7019
|
+
var prefersReducedMotion = () => typeof window !== "undefined" && Boolean(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches);
|
|
7020
|
+
var ChatConversation = (0, import_react60.forwardRef)(function ChatConversation2({
|
|
7021
|
+
children,
|
|
7022
|
+
empty,
|
|
7023
|
+
footer,
|
|
7024
|
+
"aria-label": ariaLabel = "Conversation",
|
|
7025
|
+
"aria-labelledby": ariaLabelledBy,
|
|
7026
|
+
width = "comfortable",
|
|
7027
|
+
jumpLabel = "Jump to latest",
|
|
7028
|
+
formatNewCount = defaultCount,
|
|
7029
|
+
className,
|
|
7030
|
+
...props
|
|
7031
|
+
}, ref) {
|
|
7032
|
+
const scrollerRef = (0, import_react60.useRef)(null);
|
|
7033
|
+
const contentRef = (0, import_react60.useRef)(null);
|
|
7034
|
+
const jumpRef = (0, import_react60.useRef)(null);
|
|
7035
|
+
const following = (0, import_react60.useRef)(true);
|
|
7036
|
+
const lastTop = (0, import_react60.useRef)(0);
|
|
7037
|
+
const ready = (0, import_react60.useRef)(false);
|
|
7038
|
+
const unseen = (0, import_react60.useRef)(/* @__PURE__ */ new Set());
|
|
7039
|
+
const [isFollowing, setIsFollowing] = (0, import_react60.useState)(true);
|
|
7040
|
+
const [newCount, setNewCount] = (0, import_react60.useState)(0);
|
|
7041
|
+
const isEmpty = import_react60.Children.toArray(children).length === 0;
|
|
7042
|
+
const follow = (0, import_react60.useCallback)((next) => {
|
|
7043
|
+
following.current = next;
|
|
7044
|
+
setIsFollowing(next);
|
|
7045
|
+
if (next && unseen.current.size > 0) {
|
|
7046
|
+
unseen.current.clear();
|
|
7047
|
+
setNewCount(0);
|
|
7048
|
+
}
|
|
7049
|
+
}, []);
|
|
7050
|
+
const stick = (0, import_react60.useCallback)(() => {
|
|
7051
|
+
const scroller = scrollerRef.current;
|
|
7052
|
+
if (!scroller) return;
|
|
7053
|
+
scroller.scrollTop = scroller.scrollHeight;
|
|
7054
|
+
lastTop.current = scroller.scrollTop;
|
|
7055
|
+
}, []);
|
|
7056
|
+
const scrollToBottom = (0, import_react60.useCallback)(
|
|
7057
|
+
(options) => {
|
|
7058
|
+
const scroller = scrollerRef.current;
|
|
7059
|
+
if (!scroller) return;
|
|
7060
|
+
follow(true);
|
|
7061
|
+
scroller.scrollTo({ top: scroller.scrollHeight, behavior: options?.behavior ?? (prefersReducedMotion() ? "auto" : "smooth") });
|
|
7062
|
+
},
|
|
7063
|
+
[follow]
|
|
7064
|
+
);
|
|
7065
|
+
(0, import_react60.useImperativeHandle)(ref, () => ({ scrollToBottom }), [scrollToBottom]);
|
|
7066
|
+
(0, import_react60.useLayoutEffect)(stick, [stick]);
|
|
7067
|
+
(0, import_react60.useEffect)(() => {
|
|
7068
|
+
ready.current = true;
|
|
7069
|
+
}, []);
|
|
7070
|
+
(0, import_react60.useEffect)(() => {
|
|
7071
|
+
const scroller = scrollerRef.current;
|
|
7072
|
+
const content = contentRef.current;
|
|
7073
|
+
if (!scroller || !content || typeof ResizeObserver === "undefined") return void 0;
|
|
7074
|
+
const observer = new ResizeObserver(() => {
|
|
7075
|
+
if (following.current) stick();
|
|
7076
|
+
});
|
|
7077
|
+
observer.observe(content);
|
|
7078
|
+
observer.observe(scroller);
|
|
7079
|
+
return () => observer.disconnect();
|
|
7080
|
+
}, [stick]);
|
|
7081
|
+
function onScroll() {
|
|
7082
|
+
const scroller = scrollerRef.current;
|
|
7083
|
+
if (!scroller) return;
|
|
7084
|
+
const top = scroller.scrollTop;
|
|
7085
|
+
const distance = scroller.scrollHeight - top - scroller.clientHeight;
|
|
7086
|
+
if (top < lastTop.current && distance > 1) {
|
|
7087
|
+
if (following.current) follow(false);
|
|
7088
|
+
} else if (distance <= stickyDistance && !following.current) {
|
|
7089
|
+
follow(true);
|
|
7090
|
+
}
|
|
7091
|
+
lastTop.current = top;
|
|
7092
|
+
}
|
|
7093
|
+
const context = (0, import_react60.useMemo)(
|
|
7094
|
+
() => ({
|
|
7095
|
+
ready,
|
|
7096
|
+
register(id) {
|
|
7097
|
+
if (ready.current && !following.current) {
|
|
7098
|
+
unseen.current.add(id);
|
|
7099
|
+
setNewCount(unseen.current.size);
|
|
7100
|
+
}
|
|
7101
|
+
return () => {
|
|
7102
|
+
if (unseen.current.delete(id)) setNewCount(unseen.current.size);
|
|
7103
|
+
};
|
|
7104
|
+
}
|
|
7105
|
+
}),
|
|
7106
|
+
[]
|
|
7107
|
+
);
|
|
7108
|
+
const showJump = !isFollowing && !isEmpty;
|
|
7109
|
+
const jump = usePresence(showJump);
|
|
7110
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: cx("ow-chat-conversation", width === "full" && "ow-chat-conversation--full", className), ...props, children: [
|
|
7111
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "ow-chat-conversation__viewport", children: [
|
|
7112
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
7113
|
+
"div",
|
|
7114
|
+
{
|
|
7115
|
+
ref: scrollerRef,
|
|
7116
|
+
className: "ow-chat-conversation__scroll",
|
|
7117
|
+
role: "log",
|
|
7118
|
+
"aria-live": "polite",
|
|
7119
|
+
"aria-relevant": "additions",
|
|
7120
|
+
"aria-label": ariaLabelledBy ? void 0 : ariaLabel,
|
|
7121
|
+
"aria-labelledby": ariaLabelledBy,
|
|
7122
|
+
tabIndex: isEmpty ? void 0 : 0,
|
|
7123
|
+
onScroll,
|
|
7124
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { ref: contentRef, className: "ow-chat-conversation__content", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(ChatConversationContext.Provider, { value: context, children }) })
|
|
7125
|
+
}
|
|
7126
|
+
),
|
|
7127
|
+
isEmpty && empty ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "ow-chat-conversation__empty", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "ow-chat-conversation__empty-inner", children: empty }) }) : null,
|
|
7128
|
+
jump.mounted ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "ow-chat-conversation__jump", "data-state": jump.state, children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
|
|
7129
|
+
Button,
|
|
7130
|
+
{
|
|
7131
|
+
ref: jumpRef,
|
|
7132
|
+
size: "sm",
|
|
7133
|
+
shape: "pill",
|
|
7134
|
+
startIcon: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(ArrowDownIcon, { size: 16 }),
|
|
7135
|
+
"aria-label": newCount > 0 ? `${jumpLabel}, ${formatNewCount(newCount)}` : jumpLabel,
|
|
7136
|
+
tabIndex: showJump ? void 0 : -1,
|
|
7137
|
+
onClick: () => {
|
|
7138
|
+
if (document.activeElement === jumpRef.current) scrollerRef.current?.focus({ preventScroll: true });
|
|
7139
|
+
scrollToBottom();
|
|
7140
|
+
},
|
|
7141
|
+
children: [
|
|
7142
|
+
jumpLabel,
|
|
7143
|
+
newCount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("span", { className: "ow-chat-conversation__count", children: formatNewCount(newCount) }) : null
|
|
7144
|
+
]
|
|
7145
|
+
}
|
|
7146
|
+
) }) : null
|
|
7147
|
+
] }),
|
|
7148
|
+
footer != null && footer !== false ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "ow-chat-conversation__footer", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "ow-chat-conversation__footer-inner", children: footer }) }) : null
|
|
7149
|
+
] });
|
|
7150
|
+
});
|
|
7151
|
+
|
|
7152
|
+
// src/components/Chat/ChatMessage.tsx
|
|
7153
|
+
var import_react61 = require("react");
|
|
7154
|
+
var import_jsx_runtime67 = require("react/jsx-runtime");
|
|
7155
|
+
function lucide(paths) {
|
|
7156
|
+
return function Icon({ size: size2 = 16, strokeWidth = 2, ...props }) {
|
|
7157
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
7158
|
+
"svg",
|
|
7159
|
+
{
|
|
7160
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
7161
|
+
width: size2,
|
|
7162
|
+
height: size2,
|
|
7163
|
+
viewBox: "0 0 24 24",
|
|
7164
|
+
fill: "none",
|
|
7165
|
+
stroke: "currentColor",
|
|
7166
|
+
strokeWidth,
|
|
7167
|
+
strokeLinecap: "round",
|
|
7168
|
+
strokeLinejoin: "round",
|
|
7169
|
+
"aria-hidden": "true",
|
|
7170
|
+
focusable: "false",
|
|
7171
|
+
...props,
|
|
7172
|
+
children: paths
|
|
7173
|
+
}
|
|
7174
|
+
);
|
|
7175
|
+
};
|
|
7176
|
+
}
|
|
7177
|
+
var BotIcon = lucide(
|
|
7178
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
|
|
7179
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("path", { d: "M12 8V4H8" }),
|
|
7180
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("rect", { width: "16", height: "12", x: "4", y: "8", rx: "2" }),
|
|
7181
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("path", { d: "M2 14h2" }),
|
|
7182
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("path", { d: "M20 14h2" }),
|
|
7183
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("path", { d: "M15 13v2" }),
|
|
7184
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("path", { d: "M9 13v2" })
|
|
7185
|
+
] })
|
|
7186
|
+
);
|
|
7187
|
+
var RotateCcwIcon = lucide(
|
|
7188
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
|
|
7189
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" }),
|
|
7190
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("path", { d: "M3 3v5h5" })
|
|
7191
|
+
] })
|
|
7192
|
+
);
|
|
7193
|
+
var ThumbsUpIcon = lucide(
|
|
7194
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
|
|
7195
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("path", { d: "M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z" }),
|
|
7196
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("path", { d: "M7 10v12" })
|
|
7197
|
+
] })
|
|
7198
|
+
);
|
|
7199
|
+
var ThumbsDownIcon = lucide(
|
|
7200
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
|
|
7201
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("path", { d: "M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z" }),
|
|
7202
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("path", { d: "M17 14V2" })
|
|
7203
|
+
] })
|
|
7204
|
+
);
|
|
7205
|
+
var PencilIcon = lucide(
|
|
7206
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
|
|
7207
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("path", { d: "M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" }),
|
|
7208
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("path", { d: "m15 5 4 4" })
|
|
7209
|
+
] })
|
|
7210
|
+
);
|
|
7211
|
+
var botSizes = { sm: 14, md: 16, lg: 18 };
|
|
7212
|
+
function ChatAgentAvatar({ size: size2 = "md", label, className }) {
|
|
7213
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
7214
|
+
"span",
|
|
7215
|
+
{
|
|
7216
|
+
className: cx("ow-chat-avatar", size2 !== "md" && `ow-chat-avatar--${size2}`, className),
|
|
7217
|
+
role: label ? "img" : void 0,
|
|
7218
|
+
"aria-label": label,
|
|
7219
|
+
"aria-hidden": label ? void 0 : true,
|
|
7220
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(BotIcon, { size: botSizes[size2] })
|
|
7221
|
+
}
|
|
7222
|
+
);
|
|
7223
|
+
}
|
|
7224
|
+
function useChatEntrance() {
|
|
7225
|
+
const conversation = (0, import_react61.useContext)(ChatConversationContext);
|
|
7226
|
+
const [entering] = (0, import_react61.useState)(() => conversation?.ready.current ?? false);
|
|
7227
|
+
return entering;
|
|
7228
|
+
}
|
|
7229
|
+
var formatters = /* @__PURE__ */ new Map();
|
|
7230
|
+
function formattersFor(locale) {
|
|
7231
|
+
const key = locale ?? "";
|
|
7232
|
+
let entry = formatters.get(key);
|
|
7233
|
+
if (!entry) {
|
|
7234
|
+
entry = {
|
|
7235
|
+
short: new Intl.DateTimeFormat(locale, { timeStyle: "short" }),
|
|
7236
|
+
full: new Intl.DateTimeFormat(locale, { dateStyle: "full", timeStyle: "short" })
|
|
7237
|
+
};
|
|
7238
|
+
formatters.set(key, entry);
|
|
7239
|
+
}
|
|
7240
|
+
return entry;
|
|
7241
|
+
}
|
|
7242
|
+
function MessageTime({ time, locale }) {
|
|
7243
|
+
const date = typeof time === "string" ? new Date(time) : time;
|
|
7244
|
+
if (Number.isNaN(date.getTime())) {
|
|
7245
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("time", { className: "ow-chat-message__time", children: String(time) });
|
|
7246
|
+
}
|
|
7247
|
+
const { short, full } = formattersFor(locale);
|
|
7248
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("time", { className: "ow-chat-message__time", dateTime: date.toISOString(), title: full.format(date), children: short.format(date) });
|
|
7249
|
+
}
|
|
7250
|
+
var skipCaret = '[aria-hidden="true"], .ow-visually-hidden';
|
|
7251
|
+
function useStreamingCaret(bodyRef, contentRef, caretRef, active) {
|
|
7252
|
+
(0, import_react61.useLayoutEffect)(() => {
|
|
7253
|
+
const body = bodyRef.current;
|
|
7254
|
+
const content = contentRef.current;
|
|
7255
|
+
const caret = caretRef.current;
|
|
7256
|
+
if (!active || !body || !content || !caret) return void 0;
|
|
7257
|
+
const place = () => {
|
|
7258
|
+
const walker = document.createTreeWalker(content, NodeFilter.SHOW_TEXT, {
|
|
7259
|
+
acceptNode: (node) => node.nodeValue?.trim() && !node.parentElement?.closest(skipCaret) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT
|
|
7260
|
+
});
|
|
7261
|
+
const last = walker.lastChild();
|
|
7262
|
+
const box = body.getBoundingClientRect();
|
|
7263
|
+
if (!last) {
|
|
7264
|
+
caret.style.transform = "";
|
|
7265
|
+
caret.style.removeProperty("height");
|
|
7266
|
+
caret.style.removeProperty("color");
|
|
7267
|
+
caret.hidden = false;
|
|
7268
|
+
return;
|
|
7269
|
+
}
|
|
7270
|
+
const end = last.data.trimEnd().length;
|
|
7271
|
+
const range = document.createRange();
|
|
7272
|
+
range.setStart(last, end - 1);
|
|
7273
|
+
range.setEnd(last, end);
|
|
7274
|
+
const rects = range.getClientRects();
|
|
7275
|
+
const rect = rects[rects.length - 1];
|
|
7276
|
+
if (!rect) {
|
|
7277
|
+
caret.hidden = true;
|
|
7278
|
+
return;
|
|
7279
|
+
}
|
|
7280
|
+
const x = Math.min(rect.right - box.left + 2, box.width - 2);
|
|
7281
|
+
caret.hidden = false;
|
|
7282
|
+
caret.style.transform = `translate(${Math.round(x)}px, ${Math.round(rect.top - box.top)}px)`;
|
|
7283
|
+
caret.style.height = `${Math.round(rect.height)}px`;
|
|
7284
|
+
caret.style.color = getComputedStyle(last.parentElement ?? content).color;
|
|
7285
|
+
};
|
|
7286
|
+
place();
|
|
7287
|
+
const mutations = new MutationObserver(place);
|
|
7288
|
+
mutations.observe(content, { subtree: true, childList: true, characterData: true });
|
|
7289
|
+
const resizes = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(place);
|
|
7290
|
+
resizes?.observe(body);
|
|
7291
|
+
return () => {
|
|
7292
|
+
mutations.disconnect();
|
|
7293
|
+
resizes?.disconnect();
|
|
7294
|
+
};
|
|
7295
|
+
}, [active, bodyRef, contentRef, caretRef]);
|
|
7296
|
+
}
|
|
7297
|
+
var ChatMessage = (0, import_react61.forwardRef)(function ChatMessage2({ from, children, name, avatar, time, locale, status = "done", error, onRetry, retryLabel = "Retry", actions, showActions = "hover", className, ...props }, ref) {
|
|
7298
|
+
const conversation = (0, import_react61.useContext)(ChatConversationContext);
|
|
7299
|
+
const entering = useChatEntrance();
|
|
7300
|
+
const id = (0, import_react61.useId)();
|
|
7301
|
+
const bodyRef = (0, import_react61.useRef)(null);
|
|
7302
|
+
const contentRef = (0, import_react61.useRef)(null);
|
|
7303
|
+
const caretRef = (0, import_react61.useRef)(null);
|
|
7304
|
+
const streaming = status === "streaming";
|
|
7305
|
+
(0, import_react61.useEffect)(() => conversation?.register(id), [conversation, id]);
|
|
7306
|
+
useStreamingCaret(bodyRef, contentRef, caretRef, streaming && from !== "system");
|
|
7307
|
+
if (from === "system") {
|
|
7308
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
7309
|
+
"div",
|
|
7310
|
+
{
|
|
7311
|
+
ref,
|
|
7312
|
+
className: cx("ow-chat-message", "ow-chat-message--system", entering && "ow-chat-message--enter", className),
|
|
7313
|
+
...props,
|
|
7314
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("span", { className: "ow-chat-message__system-text", children: [
|
|
7315
|
+
children,
|
|
7316
|
+
time !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
|
|
7317
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { "aria-hidden": "true", children: " \xB7 " }),
|
|
7318
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(MessageTime, { time, locale })
|
|
7319
|
+
] }) : null
|
|
7320
|
+
] })
|
|
7321
|
+
}
|
|
7322
|
+
);
|
|
7323
|
+
}
|
|
7324
|
+
const isUser = from === "user";
|
|
7325
|
+
const avatarNode = avatar !== void 0 ? avatar : isUser ? null : /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ChatAgentAvatar, {});
|
|
7326
|
+
const hasHeader = name != null || time !== void 0;
|
|
7327
|
+
const errorText = error ?? (isUser ? "Couldn't send this message." : "The answer didn't finish.");
|
|
7328
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
|
|
7329
|
+
"article",
|
|
7330
|
+
{
|
|
7331
|
+
ref,
|
|
7332
|
+
className: cx(
|
|
7333
|
+
"ow-chat-message",
|
|
7334
|
+
`ow-chat-message--${from}`,
|
|
7335
|
+
entering && "ow-chat-message--enter",
|
|
7336
|
+
streaming && "ow-chat-message--streaming",
|
|
7337
|
+
status === "error" && "ow-chat-message--error",
|
|
7338
|
+
showActions === "always" && "ow-chat-message--actions-always",
|
|
7339
|
+
className
|
|
7340
|
+
),
|
|
7341
|
+
"aria-busy": streaming || void 0,
|
|
7342
|
+
...props,
|
|
7343
|
+
children: [
|
|
7344
|
+
avatarNode != null && avatarNode !== false ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "ow-chat-message__avatar", children: avatarNode }) : null,
|
|
7345
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "ow-chat-message__main", children: [
|
|
7346
|
+
hasHeader ? /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "ow-chat-message__header", children: [
|
|
7347
|
+
name != null ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { className: "ow-chat-message__name", children: name }) : /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { className: "ow-visually-hidden", children: isUser ? "You" : "Agent" }),
|
|
7348
|
+
time !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(MessageTime, { time, locale }) : null
|
|
7349
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { className: "ow-visually-hidden", children: isUser ? "You" : "Agent" }),
|
|
7350
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { ref: bodyRef, className: "ow-chat-message__body", children: [
|
|
7351
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { ref: contentRef, className: "ow-chat-message__content", children }),
|
|
7352
|
+
streaming ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { ref: caretRef, className: "ow-chat-message__caret", "aria-hidden": "true" }) : null
|
|
7353
|
+
] }),
|
|
7354
|
+
status === "error" ? /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: cx("ow-chat-message__error", onRetry && "ow-chat-message__error--retry"), children: [
|
|
7355
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(CircleAlertIcon, { size: 16, className: "ow-chat-message__error-icon" }),
|
|
7356
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { className: "ow-chat-message__error-text", children: errorText }),
|
|
7357
|
+
onRetry ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Button, { size: "sm", startIcon: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(RotateCcwIcon, { size: 16 }), onClick: onRetry, children: retryLabel }) : null
|
|
7358
|
+
] }) : null,
|
|
7359
|
+
actions && !streaming ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "ow-chat-message__actions", children: actions }) : null
|
|
7360
|
+
] })
|
|
7361
|
+
]
|
|
7362
|
+
}
|
|
7363
|
+
);
|
|
7364
|
+
});
|
|
7365
|
+
var defaultLabels = { copy: "Copy", copied: "Copied", edit: "Edit", retry: "Retry", good: "Good response", bad: "Bad response" };
|
|
7366
|
+
function CopyAction({ text, label, copiedLabel }) {
|
|
7367
|
+
const [copied, setCopied] = (0, import_react61.useState)(false);
|
|
7368
|
+
const timer = (0, import_react61.useRef)(0);
|
|
7369
|
+
(0, import_react61.useEffect)(() => () => window.clearTimeout(timer.current), []);
|
|
7370
|
+
const current = copied ? copiedLabel : label;
|
|
7371
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
|
|
7372
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Tooltip, { label: current, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
7373
|
+
Button,
|
|
7374
|
+
{
|
|
7375
|
+
variant: "ghost",
|
|
7376
|
+
size: "sm",
|
|
7377
|
+
iconOnly: true,
|
|
7378
|
+
"aria-label": current,
|
|
7379
|
+
className: cx("ow-chat-actions__copy", copied && "ow-chat-actions__copy--copied"),
|
|
7380
|
+
onClick: async () => {
|
|
7381
|
+
if (await copyText(text)) {
|
|
7382
|
+
setCopied(true);
|
|
7383
|
+
window.clearTimeout(timer.current);
|
|
7384
|
+
timer.current = window.setTimeout(() => setCopied(false), 2e3);
|
|
7385
|
+
}
|
|
7386
|
+
},
|
|
7387
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("span", { className: "ow-chat-actions__copy-icon", children: [
|
|
7388
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(CopyIcon, { size: 16 }),
|
|
7389
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(CheckIcon, { size: 16 })
|
|
7390
|
+
] })
|
|
7391
|
+
}
|
|
7392
|
+
) }),
|
|
7393
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { className: "ow-visually-hidden", "aria-live": "polite", children: copied ? copiedLabel : "" })
|
|
7394
|
+
] });
|
|
7395
|
+
}
|
|
7396
|
+
function ChatMessageActions({
|
|
7397
|
+
copyText: text,
|
|
7398
|
+
onEdit,
|
|
7399
|
+
onRetry,
|
|
7400
|
+
onRate,
|
|
7401
|
+
rating,
|
|
7402
|
+
defaultRating = null,
|
|
7403
|
+
children,
|
|
7404
|
+
labels,
|
|
7405
|
+
"aria-label": ariaLabel = "Message actions",
|
|
7406
|
+
className
|
|
7407
|
+
}) {
|
|
7408
|
+
const words = { ...defaultLabels, ...labels };
|
|
7409
|
+
const [current, setCurrent] = useControllableState(rating, defaultRating, onRate);
|
|
7410
|
+
const rate = (value, label, Icon) => {
|
|
7411
|
+
const pressed = current === value;
|
|
7412
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Tooltip, { label, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
7413
|
+
ToggleButton,
|
|
7414
|
+
{
|
|
7415
|
+
variant: "ghost",
|
|
7416
|
+
size: "sm",
|
|
7417
|
+
iconOnly: true,
|
|
7418
|
+
"aria-label": label,
|
|
7419
|
+
pressed,
|
|
7420
|
+
className: "ow-chat-actions__rate",
|
|
7421
|
+
onPressedChange: () => setCurrent(pressed ? null : value),
|
|
7422
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Icon, { size: 16 })
|
|
7423
|
+
}
|
|
7424
|
+
) });
|
|
7425
|
+
};
|
|
7426
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(Toolbar, { variant: "plain", size: "sm", "aria-label": ariaLabel, className: cx("ow-chat-actions", className), children: [
|
|
7427
|
+
text !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(CopyAction, { text, label: words.copy, copiedLabel: words.copied }) : null,
|
|
7428
|
+
onEdit ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Tooltip, { label: words.edit, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Button, { variant: "ghost", size: "sm", iconOnly: true, "aria-label": words.edit, onClick: onEdit, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(PencilIcon, { size: 16 }) }) }) : null,
|
|
7429
|
+
onRetry ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Tooltip, { label: words.retry, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Button, { variant: "ghost", size: "sm", iconOnly: true, "aria-label": words.retry, onClick: onRetry, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(RotateCcwIcon, { size: 16 }) }) }) : null,
|
|
7430
|
+
onRate ? /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
|
|
7431
|
+
rate("up", words.good, ThumbsUpIcon),
|
|
7432
|
+
rate("down", words.bad, ThumbsDownIcon)
|
|
7433
|
+
] }) : null,
|
|
7434
|
+
children
|
|
7435
|
+
] });
|
|
7436
|
+
}
|
|
7437
|
+
|
|
7438
|
+
// src/components/Chat/ChatLoader.tsx
|
|
7439
|
+
var import_jsx_runtime68 = require("react/jsx-runtime");
|
|
7440
|
+
function ChatLoader({ label, inline = false, name, avatar, srLabel = "Working\u2026", className }) {
|
|
7441
|
+
const entering = useChatEntrance();
|
|
7442
|
+
const indicator = label != null ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(TextShimmer, { className: "ow-chat-loader__label", children: label }) : /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("span", { className: "ow-chat-loader__dots", children: [
|
|
7443
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", { className: "ow-chat-loader__dot", "aria-hidden": "true" }),
|
|
7444
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", { className: "ow-chat-loader__dot", "aria-hidden": "true" }),
|
|
7445
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", { className: "ow-chat-loader__dot", "aria-hidden": "true" }),
|
|
7446
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", { className: "ow-visually-hidden", children: srLabel })
|
|
7447
|
+
] });
|
|
7448
|
+
if (inline) {
|
|
7449
|
+
return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", { role: "status", className: cx("ow-chat-loader", "ow-chat-loader--inline", className), children: indicator });
|
|
7450
|
+
}
|
|
7451
|
+
const avatarNode = avatar === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(ChatAgentAvatar, {}) : avatar;
|
|
7452
|
+
return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { role: "status", className: cx("ow-chat-message", "ow-chat-message--assistant", "ow-chat-loader", entering && "ow-chat-loader--enter", className), children: [
|
|
7453
|
+
avatarNode != null && avatarNode !== false ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "ow-chat-message__avatar", children: avatarNode }) : null,
|
|
7454
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: "ow-chat-message__main", children: [
|
|
7455
|
+
name != null ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "ow-chat-message__header", children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", { className: "ow-chat-message__name", children: name }) }) : null,
|
|
7456
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "ow-chat-loader__line", children: indicator })
|
|
7457
|
+
] })
|
|
7458
|
+
] });
|
|
7459
|
+
}
|
|
7460
|
+
|
|
7461
|
+
// src/components/ChatTool/ChatTool.tsx
|
|
7462
|
+
var import_react62 = require("react");
|
|
7463
|
+
var import_jsx_runtime69 = require("react/jsx-runtime");
|
|
7464
|
+
var statusWords = {
|
|
7465
|
+
pending: "Not started",
|
|
7466
|
+
running: "Running",
|
|
7467
|
+
success: "Done",
|
|
7468
|
+
error: "Failed",
|
|
7469
|
+
approval: "Needs approval",
|
|
7470
|
+
cancelled: "Cancelled"
|
|
7471
|
+
};
|
|
7472
|
+
function SlashIcon() {
|
|
7473
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
7474
|
+
"svg",
|
|
7475
|
+
{
|
|
7476
|
+
width: 12,
|
|
7477
|
+
height: 12,
|
|
7478
|
+
viewBox: "0 0 24 24",
|
|
7479
|
+
fill: "none",
|
|
7480
|
+
stroke: "currentColor",
|
|
7481
|
+
strokeWidth: 3,
|
|
7482
|
+
strokeLinecap: "round",
|
|
7483
|
+
"aria-hidden": "true",
|
|
7484
|
+
focusable: "false",
|
|
7485
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("path", { d: "M7 17 17 7" })
|
|
7486
|
+
}
|
|
7487
|
+
);
|
|
7488
|
+
}
|
|
7489
|
+
function ExclamationIcon() {
|
|
7490
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(
|
|
7491
|
+
"svg",
|
|
7492
|
+
{
|
|
7493
|
+
width: 12,
|
|
7494
|
+
height: 12,
|
|
7495
|
+
viewBox: "0 0 24 24",
|
|
7496
|
+
fill: "none",
|
|
7497
|
+
stroke: "currentColor",
|
|
7498
|
+
strokeWidth: 3,
|
|
7499
|
+
strokeLinecap: "round",
|
|
7500
|
+
"aria-hidden": "true",
|
|
7501
|
+
focusable: "false",
|
|
7502
|
+
children: [
|
|
7503
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("path", { d: "M12 5v9" }),
|
|
7504
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("path", { d: "M12 19h.01" })
|
|
7505
|
+
]
|
|
7506
|
+
}
|
|
7507
|
+
);
|
|
7508
|
+
}
|
|
7509
|
+
function ChatStatusMarker({ status, icon: icon2 }) {
|
|
7510
|
+
const showsIcon = Boolean(icon2) && (status === "success" || status === "pending");
|
|
7511
|
+
const glyph = status === "running" ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Spinner, { size: "sm", label: "" }) : status === "error" ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(XIcon, { size: 12, strokeWidth: 3 }) : status === "approval" ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(ExclamationIcon, {}) : status === "cancelled" ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(SlashIcon, {}) : showsIcon ? icon2 : status === "success" ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(CheckIcon, { size: 12, strokeWidth: 3 }) : null;
|
|
7512
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("span", { className: cx("ow-chat-status", `ow-chat-status--${status}`, showsIcon && "ow-chat-status--icon"), children: [
|
|
7513
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { className: "ow-chat-status__glyph", "aria-hidden": "true", children: glyph }),
|
|
7514
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("span", { className: "ow-visually-hidden", children: [
|
|
7515
|
+
statusWords[status],
|
|
7516
|
+
": "
|
|
7517
|
+
] })
|
|
7518
|
+
] });
|
|
7519
|
+
}
|
|
7520
|
+
function formatDuration(ms, locale) {
|
|
7521
|
+
const number = (value, digits = 0) => new Intl.NumberFormat(locale, { maximumFractionDigits: digits }).format(value);
|
|
7522
|
+
const safe = Math.max(0, ms);
|
|
7523
|
+
if (safe < 1e3) return `${number(Math.round(safe))} ms`;
|
|
7524
|
+
const seconds = safe / 1e3;
|
|
7525
|
+
if (seconds < 10) return `${number(Math.floor(seconds * 10) / 10, 1)} s`;
|
|
7526
|
+
if (seconds < 60) return `${number(Math.floor(seconds))} s`;
|
|
7527
|
+
const minutes = Math.floor(seconds / 60);
|
|
7528
|
+
if (minutes < 60) {
|
|
7529
|
+
const rest2 = Math.floor(seconds % 60);
|
|
7530
|
+
return rest2 ? `${number(minutes)} min ${number(rest2)} s` : `${number(minutes)} min`;
|
|
7531
|
+
}
|
|
7532
|
+
const hours = Math.floor(minutes / 60);
|
|
7533
|
+
const rest = minutes % 60;
|
|
7534
|
+
return rest ? `${number(hours)} h ${number(rest)} min` : `${number(hours)} h`;
|
|
7535
|
+
}
|
|
7536
|
+
function ChatDuration({ ms, locale, className }) {
|
|
7537
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("time", { dateTime: `PT${Math.max(0, Math.round(ms)) / 1e3}S`, className, children: formatDuration(ms, locale) });
|
|
7538
|
+
}
|
|
7539
|
+
function useStatusExpansion({
|
|
7540
|
+
expanded,
|
|
7541
|
+
defaultExpanded,
|
|
7542
|
+
onExpandedChange,
|
|
7543
|
+
wantsOpen,
|
|
7544
|
+
closeWhenSettled = true,
|
|
7545
|
+
initial = wantsOpen
|
|
7546
|
+
}) {
|
|
7547
|
+
const [isOpen, setOpen] = useControllableState(expanded, defaultExpanded ?? initial, onExpandedChange);
|
|
7548
|
+
const touched = (0, import_react62.useRef)(false);
|
|
7549
|
+
const previous = (0, import_react62.useRef)(wantsOpen);
|
|
7550
|
+
(0, import_react62.useEffect)(() => {
|
|
7551
|
+
if (previous.current === wantsOpen) return;
|
|
7552
|
+
previous.current = wantsOpen;
|
|
7553
|
+
if (expanded !== void 0) return;
|
|
7554
|
+
if (wantsOpen) {
|
|
7555
|
+
touched.current = false;
|
|
7556
|
+
setOpen(true);
|
|
7557
|
+
} else if (closeWhenSettled && !touched.current) {
|
|
7558
|
+
setOpen(false);
|
|
7559
|
+
}
|
|
7560
|
+
}, [wantsOpen]);
|
|
7561
|
+
return [
|
|
7562
|
+
isOpen,
|
|
7563
|
+
() => {
|
|
7564
|
+
touched.current = true;
|
|
7565
|
+
setOpen(!isOpen);
|
|
7566
|
+
}
|
|
7567
|
+
];
|
|
7568
|
+
}
|
|
7569
|
+
function ChatCollapse({
|
|
7570
|
+
id,
|
|
7571
|
+
open,
|
|
7572
|
+
bleed = false,
|
|
7573
|
+
className,
|
|
7574
|
+
children
|
|
7575
|
+
}) {
|
|
7576
|
+
const ref = (0, import_react62.useRef)(null);
|
|
7577
|
+
(0, import_react62.useEffect)(() => {
|
|
7578
|
+
if (ref.current) ref.current.inert = !open;
|
|
7579
|
+
}, [open]);
|
|
7580
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { ref, id, className: cx("ow-chat-collapse", bleed && "ow-chat-collapse--bleed"), "data-open": open, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { className: "ow-chat-collapse__clip", children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { className, children }) }) });
|
|
7581
|
+
}
|
|
7582
|
+
var codeMaxHeight = 280;
|
|
7583
|
+
function formatInput(input) {
|
|
7584
|
+
if (typeof input === "string") return input;
|
|
7585
|
+
try {
|
|
7586
|
+
return JSON.stringify(input, null, 2);
|
|
7587
|
+
} catch {
|
|
7588
|
+
return String(input);
|
|
7589
|
+
}
|
|
7590
|
+
}
|
|
7591
|
+
var ChatTool = (0, import_react62.forwardRef)(function ChatTool2({
|
|
7592
|
+
title,
|
|
7593
|
+
name,
|
|
7594
|
+
icon: icon2,
|
|
7595
|
+
status,
|
|
7596
|
+
summary,
|
|
7597
|
+
duration,
|
|
7598
|
+
input,
|
|
7599
|
+
output,
|
|
7600
|
+
error,
|
|
7601
|
+
expanded,
|
|
7602
|
+
defaultExpanded,
|
|
7603
|
+
onExpandedChange,
|
|
7604
|
+
approvalMessage,
|
|
7605
|
+
approveLabel = "Approve",
|
|
7606
|
+
denyLabel = "Deny",
|
|
7607
|
+
onApprove,
|
|
7608
|
+
onDeny,
|
|
7609
|
+
locale,
|
|
7610
|
+
className,
|
|
7611
|
+
...props
|
|
7612
|
+
}, ref) {
|
|
7613
|
+
const id = (0, import_react62.useId)();
|
|
7614
|
+
const rootRef = (0, import_react62.useRef)(null);
|
|
7615
|
+
const triggerRef = (0, import_react62.useRef)(null);
|
|
7616
|
+
const messageRef = (0, import_react62.useRef)(null);
|
|
7617
|
+
const decided = (0, import_react62.useRef)(false);
|
|
7618
|
+
const [announcement, setAnnouncement] = (0, import_react62.useState)("");
|
|
7619
|
+
const needsApproval = status === "approval";
|
|
7620
|
+
const [isOpen, toggle] = useStatusExpansion({
|
|
7621
|
+
expanded,
|
|
7622
|
+
defaultExpanded,
|
|
7623
|
+
onExpandedChange,
|
|
7624
|
+
wantsOpen: status === "error" || needsApproval
|
|
7625
|
+
});
|
|
7626
|
+
const hasInput = input !== void 0 && input !== null && input !== "";
|
|
7627
|
+
const hasOutput = output !== void 0 && output !== null && output !== false && output !== "";
|
|
7628
|
+
const hasError = error !== void 0 && error !== null && error !== false && error !== "";
|
|
7629
|
+
const hasDetails = hasInput || hasOutput || hasError;
|
|
7630
|
+
const hasMeta = Boolean(summary) || duration !== void 0;
|
|
7631
|
+
(0, import_react62.useEffect)(() => {
|
|
7632
|
+
if (!needsApproval) {
|
|
7633
|
+
setAnnouncement("");
|
|
7634
|
+
return;
|
|
7635
|
+
}
|
|
7636
|
+
const timer = window.setTimeout(() => {
|
|
7637
|
+
const request = messageRef.current?.textContent?.trim();
|
|
7638
|
+
setAnnouncement(`Needs approval. ${request ?? ""}`.trim());
|
|
7639
|
+
}, 150);
|
|
7640
|
+
return () => window.clearTimeout(timer);
|
|
7641
|
+
}, [needsApproval]);
|
|
7642
|
+
(0, import_react62.useEffect)(() => {
|
|
7643
|
+
if (needsApproval || !decided.current) return;
|
|
7644
|
+
decided.current = false;
|
|
7645
|
+
const active = document.activeElement;
|
|
7646
|
+
if (!active || active === document.body) (triggerRef.current ?? rootRef.current)?.focus();
|
|
7647
|
+
}, [needsApproval]);
|
|
7648
|
+
const running = status === "running";
|
|
7649
|
+
const header = /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(import_jsx_runtime69.Fragment, { children: [
|
|
7650
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)(ChatStatusMarker, { status }),
|
|
7651
|
+
icon2 ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { className: "ow-chat-tool__icon", "aria-hidden": "true", children: icon2 }) : null,
|
|
7652
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("span", { className: "ow-chat-tool__main", children: [
|
|
7653
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("span", { className: "ow-chat-tool__heading", children: [
|
|
7654
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { className: "ow-chat-tool__title", children: running ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(TextShimmer, { children: title }) : title }),
|
|
7655
|
+
name ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Code, { className: "ow-chat-tool__name", children: name }) : null
|
|
7656
|
+
] }),
|
|
7657
|
+
hasMeta ? /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("span", { className: "ow-chat-tool__meta", children: [
|
|
7658
|
+
summary ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { className: "ow-chat-tool__summary", children: summary }) : null,
|
|
7659
|
+
summary && duration !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { className: "ow-chat-tool__dot", "aria-hidden": "true", children: "\xB7" }) : null,
|
|
7660
|
+
duration !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(ChatDuration, { ms: duration, locale, className: "ow-chat-tool__duration" }) : null
|
|
7661
|
+
] }) : null
|
|
7662
|
+
] }),
|
|
7663
|
+
hasDetails ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { className: "ow-chat-tool__chevron", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(ChevronRightIcon, { size: 14 }) }) : null
|
|
7664
|
+
] });
|
|
7665
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(
|
|
7666
|
+
"div",
|
|
7667
|
+
{
|
|
7668
|
+
ref: (element) => {
|
|
7669
|
+
rootRef.current = element;
|
|
7670
|
+
if (typeof ref === "function") ref(element);
|
|
7671
|
+
else if (ref) ref.current = element;
|
|
7672
|
+
},
|
|
7673
|
+
className: cx("ow-chat-tool", className),
|
|
7674
|
+
"data-status": status,
|
|
7675
|
+
"data-open": hasDetails ? isOpen : void 0,
|
|
7676
|
+
"aria-busy": running || void 0,
|
|
7677
|
+
tabIndex: hasDetails ? void 0 : -1,
|
|
7678
|
+
...props,
|
|
7679
|
+
children: [
|
|
7680
|
+
hasDetails ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
7681
|
+
"button",
|
|
7682
|
+
{
|
|
7683
|
+
ref: triggerRef,
|
|
7684
|
+
type: "button",
|
|
7685
|
+
id: `${id}-trigger`,
|
|
7686
|
+
className: "ow-chat-tool__header ow-chat-tool__header--button",
|
|
7687
|
+
"aria-expanded": isOpen,
|
|
7688
|
+
"aria-controls": `${id}-details`,
|
|
7689
|
+
onClick: toggle,
|
|
7690
|
+
children: header
|
|
7691
|
+
}
|
|
7692
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { className: "ow-chat-tool__header", children: header }),
|
|
7693
|
+
hasDetails ? /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(ChatCollapse, { id: `${id}-details`, open: isOpen, className: "ow-chat-tool__details", children: [
|
|
7694
|
+
hasInput ? /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { className: "ow-chat-tool__section", children: [
|
|
7695
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { className: "ow-chat-tool__label", children: "Input" }),
|
|
7696
|
+
typeof input === "string" && !input.includes("\n") ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Snippet, { value: input, prompt: null }) : /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(CodeBlock, { code: formatInput(input), language: typeof input === "string" ? void 0 : "json", maxHeight: codeMaxHeight })
|
|
7697
|
+
] }) : null,
|
|
7698
|
+
hasOutput ? /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { className: "ow-chat-tool__section", children: [
|
|
7699
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { className: "ow-chat-tool__label", children: "Output" }),
|
|
7700
|
+
typeof output === "string" ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(CodeBlock, { code: output, maxHeight: codeMaxHeight }) : /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { className: "ow-chat-tool__output", children: output })
|
|
7701
|
+
] }) : null,
|
|
7702
|
+
hasError ? /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { className: "ow-chat-tool__section", children: [
|
|
7703
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { className: "ow-chat-tool__label", children: "Error" }),
|
|
7704
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { className: "ow-chat-tool__error", children: error })
|
|
7705
|
+
] }) : null
|
|
7706
|
+
] }) : null,
|
|
7707
|
+
needsApproval ? /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { className: "ow-chat-tool__approval", role: "group", "aria-labelledby": `${id}-request`, children: [
|
|
7708
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("p", { ref: messageRef, id: `${id}-request`, className: "ow-chat-tool__request", children: approvalMessage ?? (name ? /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(import_jsx_runtime69.Fragment, { children: [
|
|
7709
|
+
"Wants to run ",
|
|
7710
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Code, { children: name })
|
|
7711
|
+
] }) : "Wants to go ahead") }),
|
|
7712
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { className: "ow-chat-tool__actions", children: [
|
|
7713
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
7714
|
+
Button,
|
|
7715
|
+
{
|
|
7716
|
+
variant: "primary",
|
|
7717
|
+
size: "sm",
|
|
7718
|
+
onClick: () => {
|
|
7719
|
+
decided.current = true;
|
|
7720
|
+
onApprove?.();
|
|
7721
|
+
},
|
|
7722
|
+
children: approveLabel
|
|
7723
|
+
}
|
|
7724
|
+
),
|
|
7725
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
7726
|
+
Button,
|
|
7727
|
+
{
|
|
7728
|
+
size: "sm",
|
|
7729
|
+
onClick: () => {
|
|
7730
|
+
decided.current = true;
|
|
7731
|
+
onDeny?.();
|
|
7732
|
+
},
|
|
7733
|
+
children: denyLabel
|
|
7734
|
+
}
|
|
7735
|
+
)
|
|
7736
|
+
] })
|
|
7737
|
+
] }) : null,
|
|
7738
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { className: "ow-visually-hidden", "aria-live": "polite", children: announcement })
|
|
7739
|
+
]
|
|
7740
|
+
}
|
|
7741
|
+
);
|
|
7742
|
+
});
|
|
7743
|
+
|
|
7744
|
+
// src/components/ChainOfThought/ChainOfThought.tsx
|
|
7745
|
+
var import_react63 = require("react");
|
|
7746
|
+
var import_jsx_runtime70 = require("react/jsx-runtime");
|
|
7747
|
+
var plural = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`;
|
|
7748
|
+
var ChainOfThought = (0, import_react63.forwardRef)(function ChainOfThought2({
|
|
7749
|
+
steps = [],
|
|
7750
|
+
status = "success",
|
|
7751
|
+
duration,
|
|
7752
|
+
label,
|
|
7753
|
+
children,
|
|
7754
|
+
expanded,
|
|
7755
|
+
defaultExpanded,
|
|
7756
|
+
onExpandedChange,
|
|
7757
|
+
collapseWhenDone = true,
|
|
7758
|
+
locale,
|
|
7759
|
+
className,
|
|
7760
|
+
...props
|
|
7761
|
+
}, ref) {
|
|
7762
|
+
const id = (0, import_react63.useId)();
|
|
7763
|
+
const running = status === "running";
|
|
7764
|
+
const [isOpen, toggle] = useStatusExpansion({
|
|
7765
|
+
expanded,
|
|
7766
|
+
defaultExpanded,
|
|
7767
|
+
onExpandedChange,
|
|
7768
|
+
wantsOpen: running,
|
|
7769
|
+
closeWhenSettled: collapseWhenDone,
|
|
7770
|
+
initial: running || !collapseWhenDone
|
|
7771
|
+
});
|
|
7772
|
+
const hasReasoning = children !== void 0 && children !== null && children !== false && children !== "";
|
|
7773
|
+
const hasBody = hasReasoning || steps.length > 0;
|
|
7774
|
+
const finished = steps.filter((step) => step.status === "success" || step.status === "error").length;
|
|
7775
|
+
const failed = steps.filter((step) => step.status === "error").length;
|
|
7776
|
+
const heading = label ?? (running ? "Thinking\u2026" : duration !== void 0 ? `Thought for ${formatDuration(duration, locale)}` : "Reasoning");
|
|
7777
|
+
const count = steps.length > 0 ? running ? `${finished} of ${plural(steps.length, "step")}` : plural(steps.length, "step") : null;
|
|
7778
|
+
const headerText = /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("span", { className: "ow-chat-toggle__text", children: [
|
|
7779
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("span", { className: "ow-chain-of-thought__label", children: running ? /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(TextShimmer, { children: heading }) : heading }),
|
|
7780
|
+
count ? /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("span", { className: "ow-chat-toggle__meta", children: [
|
|
7781
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("span", { "aria-hidden": "true", children: "\xB7 " }),
|
|
7782
|
+
count,
|
|
7783
|
+
failed > 0 ? /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("span", { className: "ow-chain-of-thought__failed", children: [
|
|
7784
|
+
", ",
|
|
7785
|
+
failed,
|
|
7786
|
+
" failed"
|
|
7787
|
+
] }) : null
|
|
7788
|
+
] }) : null
|
|
7789
|
+
] });
|
|
7790
|
+
return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { ref, className: cx("ow-chain-of-thought", className), "data-status": status, "aria-busy": running || void 0, ...props, children: [
|
|
7791
|
+
hasBody ? /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("button", { type: "button", className: "ow-chat-toggle", "aria-expanded": isOpen, "aria-controls": `${id}-body`, onClick: toggle, children: [
|
|
7792
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("span", { className: "ow-chat-toggle__chevron", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ChevronRightIcon, { size: 14 }) }),
|
|
7793
|
+
headerText
|
|
7794
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "ow-chat-toggle ow-chain-of-thought__static", children: headerText }),
|
|
7795
|
+
hasBody ? /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(ChatCollapse, { id: `${id}-body`, open: isOpen, bleed: true, className: "ow-chain-of-thought__body", children: [
|
|
7796
|
+
hasReasoning ? /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "ow-chain-of-thought__reasoning", children }) : null,
|
|
7797
|
+
steps.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("ol", { className: "ow-chain-of-thought__steps", children: steps.map((step) => /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("li", { className: "ow-chain-of-thought__step", "data-status": step.status, children: [
|
|
7798
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ChatStatusMarker, { status: step.status, icon: step.icon }),
|
|
7799
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "ow-chain-of-thought__step-body", children: [
|
|
7800
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("span", { className: "ow-chain-of-thought__step-title", children: step.status === "running" ? /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(TextShimmer, { children: step.title }) : step.title }),
|
|
7801
|
+
step.detail !== void 0 && step.detail !== null ? /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "ow-chain-of-thought__detail", children: step.detail }) : null
|
|
7802
|
+
] })
|
|
7803
|
+
] }, step.id)) }) : null
|
|
7804
|
+
] }) : null
|
|
7805
|
+
] });
|
|
7806
|
+
});
|
|
7807
|
+
|
|
7808
|
+
// src/components/ChatSource/ChatSource.tsx
|
|
7809
|
+
var import_react64 = require("react");
|
|
7810
|
+
var import_jsx_runtime71 = require("react/jsx-runtime");
|
|
7811
|
+
var openDelay = 250;
|
|
7812
|
+
var closeDelay = 150;
|
|
7813
|
+
var ChatSource = (0, import_react64.forwardRef)(function ChatSource2({
|
|
7814
|
+
title,
|
|
7815
|
+
source,
|
|
7816
|
+
snippet,
|
|
7817
|
+
href,
|
|
7818
|
+
external = false,
|
|
7819
|
+
icon: icon2,
|
|
7820
|
+
index,
|
|
7821
|
+
label,
|
|
7822
|
+
snippetFormat = "text",
|
|
7823
|
+
openLabel = "Open",
|
|
7824
|
+
onClick,
|
|
7825
|
+
"aria-label": ariaLabel,
|
|
7826
|
+
className
|
|
7827
|
+
}, ref) {
|
|
7828
|
+
const id = (0, import_react64.useId)();
|
|
7829
|
+
const wrapperRef = (0, import_react64.useRef)(null);
|
|
7830
|
+
const chipRef = (0, import_react64.useRef)(null);
|
|
7831
|
+
const cardRef = (0, import_react64.useRef)(null);
|
|
7832
|
+
const timer = (0, import_react64.useRef)(0);
|
|
7833
|
+
const pointer = (0, import_react64.useRef)("mouse");
|
|
7834
|
+
const [open, setOpen] = (0, import_react64.useState)(false);
|
|
7835
|
+
const { mounted, state } = usePresence(open);
|
|
7836
|
+
const style = useFloating({ open: mounted, anchorRef: chipRef, floatingRef: cardRef, placement: "bottom-start", offset: 6, maxHeight: 360 });
|
|
7837
|
+
const schedule = (next, delay) => {
|
|
7838
|
+
window.clearTimeout(timer.current);
|
|
7839
|
+
if (delay === 0) setOpen(next);
|
|
7840
|
+
else timer.current = window.setTimeout(() => setOpen(next), delay);
|
|
7841
|
+
};
|
|
7842
|
+
const close = (0, import_react64.useCallback)(() => {
|
|
7843
|
+
window.clearTimeout(timer.current);
|
|
7844
|
+
setOpen(false);
|
|
7845
|
+
}, []);
|
|
7846
|
+
useDismiss(open, [wrapperRef], close);
|
|
7847
|
+
(0, import_react64.useEffect)(() => () => window.clearTimeout(timer.current), []);
|
|
7848
|
+
const name = ariaLabel ?? (index !== void 0 ? `Source ${index}` : label ?? "Source");
|
|
7849
|
+
const describedBy = [`${id}-title`, source ? `${id}-source` : null, snippet ? `${id}-snippet` : null].filter(Boolean).join(" ");
|
|
7850
|
+
const externalProps = external ? { target: "_blank", rel: "noopener noreferrer" } : {};
|
|
7851
|
+
const chipProps = {
|
|
7852
|
+
ref: (element) => {
|
|
7853
|
+
chipRef.current = element;
|
|
7854
|
+
if (typeof ref === "function") ref(element);
|
|
7855
|
+
else if (ref) ref.current = element;
|
|
7856
|
+
},
|
|
7857
|
+
className: cx("ow-chat-source__chip", index === void 0 && "ow-chat-source__chip--label", open && "ow-chat-source__chip--open"),
|
|
7858
|
+
"aria-label": name,
|
|
7859
|
+
"aria-describedby": describedBy,
|
|
7860
|
+
onFocus: (event) => {
|
|
7861
|
+
if (event.currentTarget.matches(":focus-visible")) schedule(true, 0);
|
|
7862
|
+
},
|
|
7863
|
+
onBlur: () => schedule(false, 0),
|
|
7864
|
+
onPointerDown: (event) => {
|
|
7865
|
+
pointer.current = event.pointerType;
|
|
7866
|
+
},
|
|
7867
|
+
onClick: (event) => {
|
|
7868
|
+
const tapped = event.detail > 0 && pointer.current !== "mouse";
|
|
7869
|
+
pointer.current = "mouse";
|
|
7870
|
+
if (tapped && !open) {
|
|
7871
|
+
event.preventDefault();
|
|
7872
|
+
schedule(true, 0);
|
|
7873
|
+
return;
|
|
7874
|
+
}
|
|
7875
|
+
if (!href) schedule(true, 0);
|
|
7876
|
+
onClick?.(event);
|
|
7877
|
+
}
|
|
7878
|
+
};
|
|
7879
|
+
const chipText = /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "ow-chat-source__chip-text", children: index ?? label });
|
|
7880
|
+
return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
|
|
7881
|
+
"span",
|
|
7882
|
+
{
|
|
7883
|
+
ref: wrapperRef,
|
|
7884
|
+
className: cx("ow-chat-source", className),
|
|
7885
|
+
onPointerEnter: (event) => {
|
|
7886
|
+
if (event.pointerType === "mouse") schedule(true, open ? 0 : openDelay);
|
|
7887
|
+
},
|
|
7888
|
+
onPointerLeave: (event) => {
|
|
7889
|
+
if (event.pointerType === "mouse") schedule(false, closeDelay);
|
|
7890
|
+
},
|
|
7891
|
+
children: [
|
|
7892
|
+
href ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("a", { href, ...externalProps, ...chipProps, children: chipText }) : /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("button", { type: "button", ...chipProps, children: chipText }),
|
|
7893
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("span", { ref: cardRef, ...manualPopover, hidden: !mounted, "data-state": state, className: "ow-chat-source-card ow-floating", style, children: [
|
|
7894
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("span", { className: "ow-chat-source-card__header", children: [
|
|
7895
|
+
icon2 ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "ow-chat-source-card__icon", "aria-hidden": "true", children: icon2 }) : null,
|
|
7896
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { id: `${id}-title`, className: "ow-chat-source-card__title", children: title })
|
|
7897
|
+
] }),
|
|
7898
|
+
source ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { id: `${id}-source`, className: "ow-chat-source-card__source", children: source }) : null,
|
|
7899
|
+
snippet ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { id: `${id}-snippet`, className: cx("ow-chat-source-card__snippet", `ow-chat-source-card__snippet--${snippetFormat}`), children: snippet }) : null,
|
|
7900
|
+
href ? (
|
|
7901
|
+
// The chip is the same link, so this one stays out of the tab order.
|
|
7902
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("a", { href, ...externalProps, tabIndex: -1, className: cx(linkClassName({ variant: "standalone" }), "ow-chat-source-card__open"), children: [
|
|
7903
|
+
openLabel,
|
|
7904
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ArrowUpRightIcon, { size: 13 })
|
|
7905
|
+
] })
|
|
7906
|
+
) : null
|
|
7907
|
+
] })
|
|
7908
|
+
]
|
|
7909
|
+
}
|
|
7910
|
+
);
|
|
7911
|
+
});
|
|
7912
|
+
var ChatSources = (0, import_react64.forwardRef)(function ChatSources2({ sources, label, expanded, defaultExpanded = false, onExpandedChange, className, ...props }, ref) {
|
|
7913
|
+
const id = (0, import_react64.useId)();
|
|
7914
|
+
const [isOpen, setOpen] = useControllableState(expanded, defaultExpanded, onExpandedChange);
|
|
7915
|
+
if (sources.length === 0) return null;
|
|
7916
|
+
return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { ref, className: cx("ow-chat-sources", className), ...props, children: [
|
|
7917
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("button", { type: "button", className: "ow-chat-toggle", "aria-expanded": isOpen, "aria-controls": `${id}-list`, onClick: () => setOpen(!isOpen), children: [
|
|
7918
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "ow-chat-toggle__chevron", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ChevronRightIcon, { size: 14 }) }),
|
|
7919
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "ow-chat-toggle__text", children: label ?? `${sources.length} ${sources.length === 1 ? "source" : "sources"}` })
|
|
7920
|
+
] }),
|
|
7921
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ChatCollapse, { id: `${id}-list`, open: isOpen, bleed: true, className: "ow-chat-sources__body", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("ul", { className: "ow-chat-sources__list", children: sources.map((item, position) => {
|
|
7922
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [
|
|
7923
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("span", { className: "ow-chat-sources__lead", children: [
|
|
7924
|
+
item.index !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("span", { className: "ow-chat-sources__index", children: [
|
|
7925
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "ow-visually-hidden", children: "Source " }),
|
|
7926
|
+
item.index
|
|
7927
|
+
] }) : null,
|
|
7928
|
+
item.icon || item.index === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "ow-chat-sources__icon", "aria-hidden": "true", children: item.icon ?? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(FileIcon, { size: 15 }) }) : null
|
|
7929
|
+
] }),
|
|
7930
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("span", { className: "ow-chat-sources__text", children: [
|
|
7931
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "ow-chat-sources__title", children: item.title }),
|
|
7932
|
+
item.source ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "ow-chat-sources__source", children: item.source }) : null
|
|
7933
|
+
] }),
|
|
7934
|
+
item.href && item.external ? /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [
|
|
7935
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "ow-chat-sources__external", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ArrowUpRightIcon, { size: 14 }) }),
|
|
7936
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "ow-visually-hidden", children: " (opens in a new tab)" })
|
|
7937
|
+
] }) : null
|
|
7938
|
+
] });
|
|
7939
|
+
return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("li", { children: item.href ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
7940
|
+
"a",
|
|
7941
|
+
{
|
|
7942
|
+
href: item.href,
|
|
7943
|
+
className: "ow-chat-sources__card ow-chat-sources__card--link",
|
|
7944
|
+
...item.external ? { target: "_blank", rel: "noopener noreferrer" } : {},
|
|
7945
|
+
children: content
|
|
7946
|
+
}
|
|
7947
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "ow-chat-sources__card", children: content }) }, item.id ?? item.index ?? position);
|
|
7948
|
+
}) }) })
|
|
7949
|
+
] });
|
|
7950
|
+
});
|
|
7951
|
+
|
|
7952
|
+
// src/components/ColorPicker/ColorPicker.tsx
|
|
7953
|
+
var import_react65 = require("react");
|
|
7954
|
+
var import_react_colorful = require("react-colorful");
|
|
7955
|
+
var import_jsx_runtime72 = require("react/jsx-runtime");
|
|
6481
7956
|
var swatchColor = (swatch) => typeof swatch === "string" ? swatch : swatch.color;
|
|
6482
7957
|
var swatchName = (swatch) => typeof swatch === "string" ? swatch : swatch.name;
|
|
6483
7958
|
var same = (a, b) => a.toLowerCase().replace(/^#/, "") === b.toLowerCase().replace(/^#/, "");
|
|
@@ -6493,10 +7968,10 @@ function ColorPicker({
|
|
|
6493
7968
|
className
|
|
6494
7969
|
}) {
|
|
6495
7970
|
const [color, setColor] = useControllableState(value, defaultValue, onChange);
|
|
6496
|
-
const [canPick, setCanPick] = (0,
|
|
6497
|
-
const rootRef = (0,
|
|
6498
|
-
(0,
|
|
6499
|
-
(0,
|
|
7971
|
+
const [canPick, setCanPick] = (0, import_react65.useState)(false);
|
|
7972
|
+
const rootRef = (0, import_react65.useRef)(null);
|
|
7973
|
+
(0, import_react65.useEffect)(() => setCanPick(typeof window !== "undefined" && "EyeDropper" in window), []);
|
|
7974
|
+
(0, import_react65.useEffect)(() => {
|
|
6500
7975
|
const names = { saturation: "Colour", hue: "Hue", alpha: "Opacity" };
|
|
6501
7976
|
for (const [part, label] of Object.entries(names)) {
|
|
6502
7977
|
rootRef.current?.querySelector(`.react-colorful__${part} .react-colorful__interactive`)?.setAttribute("aria-label", label);
|
|
@@ -6512,13 +7987,13 @@ function ColorPicker({
|
|
|
6512
7987
|
} catch {
|
|
6513
7988
|
}
|
|
6514
7989
|
}
|
|
6515
|
-
return /* @__PURE__ */ (0,
|
|
6516
|
-
/* @__PURE__ */ (0,
|
|
6517
|
-
showInput || eyeDropper && canPick ? /* @__PURE__ */ (0,
|
|
6518
|
-
eyeDropper && canPick ? /* @__PURE__ */ (0,
|
|
6519
|
-
showInput ? /* @__PURE__ */ (0,
|
|
6520
|
-
/* @__PURE__ */ (0,
|
|
6521
|
-
/* @__PURE__ */ (0,
|
|
7990
|
+
return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { ref: rootRef, role: "group", "aria-label": ariaLabel, className: cx("ow-color-picker", className), children: [
|
|
7991
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Picker, { color, onChange: change }),
|
|
7992
|
+
showInput || eyeDropper && canPick ? /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { className: "ow-color-picker__row", children: [
|
|
7993
|
+
eyeDropper && canPick ? /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("button", { type: "button", className: "ow-color-picker__dropper", "aria-label": "Pick a colour from the screen", onClick: pickFromScreen, children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(PipetteIcon, { size: 15 }) }) : null,
|
|
7994
|
+
showInput ? /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("span", { className: "ow-input-group ow-input-group--sm ow-color-picker__input", children: [
|
|
7995
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "ow-input-group__addon", "aria-hidden": "true", children: "#" }),
|
|
7996
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
6522
7997
|
import_react_colorful.HexColorInput,
|
|
6523
7998
|
{
|
|
6524
7999
|
className: "ow-input-group__input",
|
|
@@ -6530,11 +8005,11 @@ function ColorPicker({
|
|
|
6530
8005
|
}
|
|
6531
8006
|
)
|
|
6532
8007
|
] }) : null,
|
|
6533
|
-
/* @__PURE__ */ (0,
|
|
8008
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "ow-color-picker__preview", style: { "--ow-color-picker-value": color }, "aria-hidden": "true" })
|
|
6534
8009
|
] }) : null,
|
|
6535
|
-
swatches?.length ? /* @__PURE__ */ (0,
|
|
8010
|
+
swatches?.length ? /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "ow-color-picker__swatches", role: "group", "aria-label": "Swatches", children: swatches.map((swatch) => {
|
|
6536
8011
|
const swatchValue = swatchColor(swatch);
|
|
6537
|
-
return /* @__PURE__ */ (0,
|
|
8012
|
+
return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
6538
8013
|
"button",
|
|
6539
8014
|
{
|
|
6540
8015
|
type: "button",
|
|
@@ -6554,7 +8029,7 @@ function assignRef7(ref, value) {
|
|
|
6554
8029
|
if (typeof ref === "function") ref(value);
|
|
6555
8030
|
else if (ref) ref.current = value;
|
|
6556
8031
|
}
|
|
6557
|
-
var ColorField = (0,
|
|
8032
|
+
var ColorField = (0, import_react65.forwardRef)(function ColorField2({
|
|
6558
8033
|
value,
|
|
6559
8034
|
defaultValue = "#312c7e",
|
|
6560
8035
|
onChange,
|
|
@@ -6570,24 +8045,24 @@ var ColorField = (0, import_react57.forwardRef)(function ColorField2({
|
|
|
6570
8045
|
...pickerProps
|
|
6571
8046
|
}, ref) {
|
|
6572
8047
|
const [color, setColor] = useControllableState(value, defaultValue, onChange);
|
|
6573
|
-
const [isOpen, setOpen] = (0,
|
|
6574
|
-
const triggerRef = (0,
|
|
6575
|
-
const panelRef = (0,
|
|
6576
|
-
const panelId = (0,
|
|
8048
|
+
const [isOpen, setOpen] = (0, import_react65.useState)(false);
|
|
8049
|
+
const triggerRef = (0, import_react65.useRef)(null);
|
|
8050
|
+
const panelRef = (0, import_react65.useRef)(null);
|
|
8051
|
+
const panelId = (0, import_react65.useId)();
|
|
6577
8052
|
const { mounted, state } = usePresence(isOpen);
|
|
6578
8053
|
const style = useFloating({ open: mounted, anchorRef: triggerRef, floatingRef: panelRef, placement, offset: 6, maxHeight: 640 });
|
|
6579
|
-
const close = (0,
|
|
8054
|
+
const close = (0, import_react65.useCallback)((reason) => {
|
|
6580
8055
|
setOpen(false);
|
|
6581
8056
|
if (reason !== "outside") triggerRef.current?.focus();
|
|
6582
8057
|
}, []);
|
|
6583
8058
|
useDismiss(isOpen, [panelRef, triggerRef], close);
|
|
6584
|
-
(0,
|
|
8059
|
+
(0, import_react65.useEffect)(() => {
|
|
6585
8060
|
if (!isOpen) return void 0;
|
|
6586
8061
|
const frame = requestAnimationFrame(() => panelRef.current?.querySelector(".react-colorful__interactive")?.focus());
|
|
6587
8062
|
return () => cancelAnimationFrame(frame);
|
|
6588
8063
|
}, [isOpen]);
|
|
6589
|
-
return /* @__PURE__ */ (0,
|
|
6590
|
-
/* @__PURE__ */ (0,
|
|
8064
|
+
return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_jsx_runtime72.Fragment, { children: [
|
|
8065
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
|
|
6591
8066
|
"button",
|
|
6592
8067
|
{
|
|
6593
8068
|
ref: (element) => {
|
|
@@ -6619,13 +8094,13 @@ var ColorField = (0, import_react57.forwardRef)(function ColorField2({
|
|
|
6619
8094
|
}
|
|
6620
8095
|
},
|
|
6621
8096
|
children: [
|
|
6622
|
-
/* @__PURE__ */ (0,
|
|
6623
|
-
/* @__PURE__ */ (0,
|
|
6624
|
-
/* @__PURE__ */ (0,
|
|
8097
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "ow-color-field__swatch", style: { "--ow-color-picker-value": color }, "aria-hidden": "true" }),
|
|
8098
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { id: `${panelId}-value`, className: "ow-select__value ow-color-field__value", children: color.toUpperCase() }),
|
|
8099
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ChevronDownIcon, { size: size2 === "sm" ? 14 : 16, className: "ow-select__chevron" })
|
|
6625
8100
|
]
|
|
6626
8101
|
}
|
|
6627
8102
|
),
|
|
6628
|
-
mounted ? /* @__PURE__ */ (0,
|
|
8103
|
+
mounted ? /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
6629
8104
|
"div",
|
|
6630
8105
|
{
|
|
6631
8106
|
ref: panelRef,
|
|
@@ -6639,17 +8114,17 @@ var ColorField = (0, import_react57.forwardRef)(function ColorField2({
|
|
|
6639
8114
|
onKeyDown: (event) => {
|
|
6640
8115
|
if (event.key === "Enter" && event.target.closest(".react-colorful")) close();
|
|
6641
8116
|
},
|
|
6642
|
-
children: /* @__PURE__ */ (0,
|
|
8117
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ColorPicker, { ...pickerProps, value: color, onChange: setColor })
|
|
6643
8118
|
}
|
|
6644
8119
|
) : null
|
|
6645
8120
|
] });
|
|
6646
8121
|
});
|
|
6647
8122
|
|
|
6648
8123
|
// src/components/ColorPicker/ColorArea.tsx
|
|
6649
|
-
var
|
|
8124
|
+
var import_react67 = require("react");
|
|
6650
8125
|
|
|
6651
8126
|
// src/components/ColorPicker/color.ts
|
|
6652
|
-
var
|
|
8127
|
+
var import_react66 = require("react");
|
|
6653
8128
|
var clamp2 = (n, min, max) => Math.min(max, Math.max(min, n));
|
|
6654
8129
|
function parseHex(color) {
|
|
6655
8130
|
let hex = color.trim().replace(/^#/, "");
|
|
@@ -6726,8 +8201,8 @@ var hslModel = {
|
|
|
6726
8201
|
var fallback = { r: 0, g: 0, b: 0, a: 1 };
|
|
6727
8202
|
function useColorModel(value, defaultValue, onChange, model, { hue, alpha = false } = {}) {
|
|
6728
8203
|
const [color, setColor] = useControllableState(value, defaultValue, onChange);
|
|
6729
|
-
const memory = (0,
|
|
6730
|
-
const [, rerender] = (0,
|
|
8204
|
+
const memory = (0, import_react66.useRef)(null);
|
|
8205
|
+
const [, rerender] = (0, import_react66.useReducer)((n) => n + 1, 0);
|
|
6731
8206
|
const incoming = normalizeHex(color);
|
|
6732
8207
|
if (!memory.current || memory.current.hex !== incoming || memory.current.model !== model) {
|
|
6733
8208
|
const rgba2 = parseHex(incoming);
|
|
@@ -6738,7 +8213,7 @@ function useColorModel(value, defaultValue, onChange, model, { hue, alpha = fals
|
|
|
6738
8213
|
const isGrey = rgba.r === rgba.g && rgba.g === rgba.b;
|
|
6739
8214
|
const current = isGrey && hue !== void 0 ? { ...memory.current.value, h: hue } : memory.current.value;
|
|
6740
8215
|
const withAlpha = alpha || hasAlpha(color);
|
|
6741
|
-
const set = (0,
|
|
8216
|
+
const set = (0, import_react66.useCallback)(
|
|
6742
8217
|
(next) => {
|
|
6743
8218
|
const hex = toHex(model.write(next), withAlpha);
|
|
6744
8219
|
memory.current = { hex, model, value: next };
|
|
@@ -6748,7 +8223,7 @@ function useColorModel(value, defaultValue, onChange, model, { hue, alpha = fals
|
|
|
6748
8223
|
},
|
|
6749
8224
|
[model, withAlpha, setColor]
|
|
6750
8225
|
);
|
|
6751
|
-
const latest = (0,
|
|
8226
|
+
const latest = (0, import_react66.useCallback)(() => memory.current?.hex ?? incoming, [incoming]);
|
|
6752
8227
|
return { value: current, rgba: model.write(current), hex: memory.current.hex, set, latest };
|
|
6753
8228
|
}
|
|
6754
8229
|
function useDrag({
|
|
@@ -6757,8 +8232,8 @@ function useDrag({
|
|
|
6757
8232
|
onStart,
|
|
6758
8233
|
disabled = false
|
|
6759
8234
|
}) {
|
|
6760
|
-
const [dragging, setDragging] = (0,
|
|
6761
|
-
const [pointerFocus, setPointerFocus] = (0,
|
|
8235
|
+
const [dragging, setDragging] = (0, import_react66.useState)(false);
|
|
8236
|
+
const [pointerFocus, setPointerFocus] = (0, import_react66.useState)(false);
|
|
6762
8237
|
const move = (event) => {
|
|
6763
8238
|
const rect = event.currentTarget.getBoundingClientRect();
|
|
6764
8239
|
onMove(clamp2((event.clientX - rect.left) / (rect.width || 1), 0, 1), clamp2((event.clientY - rect.top) / (rect.height || 1), 0, 1));
|
|
@@ -6830,13 +8305,13 @@ var hueHex = (h) => toHex(hsvToRgb({ h, s: 100, v: 100, a: 1 }));
|
|
|
6830
8305
|
var hueStops = "#ff0000 0%, #ffff00 16.67%, #00ff00 33.33%, #00ffff 50%, #0000ff 66.67%, #ff00ff 83.33%, #ff0000 100%";
|
|
6831
8306
|
|
|
6832
8307
|
// src/components/ColorPicker/ColorArea.tsx
|
|
6833
|
-
var
|
|
8308
|
+
var import_jsx_runtime73 = require("react/jsx-runtime");
|
|
6834
8309
|
var size = (length) => typeof length === "number" ? `${length}px` : length;
|
|
6835
8310
|
function assignRef8(ref, value) {
|
|
6836
8311
|
if (typeof ref === "function") ref(value);
|
|
6837
8312
|
else if (ref) ref.current = value;
|
|
6838
8313
|
}
|
|
6839
|
-
var ColorArea = (0,
|
|
8314
|
+
var ColorArea = (0, import_react67.forwardRef)(function ColorArea2({
|
|
6840
8315
|
value,
|
|
6841
8316
|
defaultValue = "#312c7e",
|
|
6842
8317
|
onChange,
|
|
@@ -6854,9 +8329,9 @@ var ColorArea = (0, import_react59.forwardRef)(function ColorArea2({
|
|
|
6854
8329
|
className
|
|
6855
8330
|
}, ref) {
|
|
6856
8331
|
const { value: hsv, rgba, hex, set, latest } = useColorModel(value, defaultValue, onChange, hsvModel, { hue });
|
|
6857
|
-
const rootRef = (0,
|
|
6858
|
-
const inputs = (0,
|
|
6859
|
-
const [axis, setAxis] = (0,
|
|
8332
|
+
const rootRef = (0, import_react67.useRef)(null);
|
|
8333
|
+
const inputs = (0, import_react67.useRef)({ x: null, y: null });
|
|
8334
|
+
const [axis, setAxis] = (0, import_react67.useState)("x");
|
|
6860
8335
|
const isRtl = () => rootRef.current ? getComputedStyle(rootRef.current).direction === "rtl" : false;
|
|
6861
8336
|
const end = () => onChangeEnd?.(latest());
|
|
6862
8337
|
const drag = useDrag({
|
|
@@ -6911,7 +8386,7 @@ var ColorArea = (0, import_react59.forwardRef)(function ColorArea2({
|
|
|
6911
8386
|
const saturation = `Saturation ${percent.format(hsv.s / 100)}`;
|
|
6912
8387
|
const brightness = `brightness ${percent.format(hsv.v / 100)}`;
|
|
6913
8388
|
const colorName = describeColor(rgba);
|
|
6914
|
-
const input = (which) => /* @__PURE__ */ (0,
|
|
8389
|
+
const input = (which) => /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
6915
8390
|
"input",
|
|
6916
8391
|
{
|
|
6917
8392
|
ref: (element) => {
|
|
@@ -6938,7 +8413,7 @@ var ColorArea = (0, import_react59.forwardRef)(function ColorArea2({
|
|
|
6938
8413
|
onKeyUp
|
|
6939
8414
|
}
|
|
6940
8415
|
);
|
|
6941
|
-
return /* @__PURE__ */ (0,
|
|
8416
|
+
return /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(
|
|
6942
8417
|
"div",
|
|
6943
8418
|
{
|
|
6944
8419
|
ref: rootRef,
|
|
@@ -6959,7 +8434,7 @@ var ColorArea = (0, import_react59.forwardRef)(function ColorArea2({
|
|
|
6959
8434
|
},
|
|
6960
8435
|
...drag.handlers,
|
|
6961
8436
|
children: [
|
|
6962
|
-
/* @__PURE__ */ (0,
|
|
8437
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(
|
|
6963
8438
|
"div",
|
|
6964
8439
|
{
|
|
6965
8440
|
className: "ow-color-area__thumb",
|
|
@@ -6970,15 +8445,15 @@ var ColorArea = (0, import_react59.forwardRef)(function ColorArea2({
|
|
|
6970
8445
|
]
|
|
6971
8446
|
}
|
|
6972
8447
|
),
|
|
6973
|
-
name ? /* @__PURE__ */ (0,
|
|
8448
|
+
name ? /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("input", { type: "hidden", name, value: hex }) : null
|
|
6974
8449
|
]
|
|
6975
8450
|
}
|
|
6976
8451
|
);
|
|
6977
8452
|
});
|
|
6978
8453
|
|
|
6979
8454
|
// src/components/ColorPicker/ColorSlider.tsx
|
|
6980
|
-
var
|
|
6981
|
-
var
|
|
8455
|
+
var import_react68 = require("react");
|
|
8456
|
+
var import_jsx_runtime74 = require("react/jsx-runtime");
|
|
6982
8457
|
var channels = {
|
|
6983
8458
|
hue: { name: "Hue", max: 360, unit: "degree" },
|
|
6984
8459
|
saturation: { name: "Saturation", max: 100, unit: "percent" },
|
|
@@ -7025,7 +8500,7 @@ function assignRef9(ref, value) {
|
|
|
7025
8500
|
if (typeof ref === "function") ref(value);
|
|
7026
8501
|
else if (ref) ref.current = value;
|
|
7027
8502
|
}
|
|
7028
|
-
var ColorSlider = (0,
|
|
8503
|
+
var ColorSlider = (0, import_react68.forwardRef)(function ColorSlider2({
|
|
7029
8504
|
channel,
|
|
7030
8505
|
value,
|
|
7031
8506
|
defaultValue = "#312c7e",
|
|
@@ -7053,9 +8528,9 @@ var ColorSlider = (0, import_react60.forwardRef)(function ColorSlider2({
|
|
|
7053
8528
|
});
|
|
7054
8529
|
const { rgba, latest } = color;
|
|
7055
8530
|
const current = read(channel, color.value, rgba);
|
|
7056
|
-
const labelId = (0,
|
|
7057
|
-
const trackRef = (0,
|
|
7058
|
-
const inputRef = (0,
|
|
8531
|
+
const labelId = (0, import_react68.useId)();
|
|
8532
|
+
const trackRef = (0, import_react68.useRef)(null);
|
|
8533
|
+
const inputRef = (0, import_react68.useRef)(null);
|
|
7059
8534
|
const vertical = orientation === "vertical";
|
|
7060
8535
|
const isRtl = () => !vertical && trackRef.current !== null && getComputedStyle(trackRef.current).direction === "rtl";
|
|
7061
8536
|
const end = () => onChangeEnd?.(latest());
|
|
@@ -7093,7 +8568,7 @@ var ColorSlider = (0, import_react60.forwardRef)(function ColorSlider2({
|
|
|
7093
8568
|
const shown = format.format(spec.unit === "percent" ? current / 100 : current);
|
|
7094
8569
|
const named = channel === "hue" ? describeColor(parseHex(hueHex(color.value.h))) : describeColor({ ...rgba, a: 1 });
|
|
7095
8570
|
const fill = channel === "hue" ? hueHex(color.value.h) : toHex(rgba, channel === "alpha");
|
|
7096
|
-
return /* @__PURE__ */ (0,
|
|
8571
|
+
return /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(
|
|
7097
8572
|
"div",
|
|
7098
8573
|
{
|
|
7099
8574
|
className: cx(
|
|
@@ -7108,11 +8583,11 @@ var ColorSlider = (0, import_react60.forwardRef)(function ColorSlider2({
|
|
|
7108
8583
|
className
|
|
7109
8584
|
),
|
|
7110
8585
|
children: [
|
|
7111
|
-
label || showValue ? /* @__PURE__ */ (0,
|
|
7112
|
-
label ? /* @__PURE__ */ (0,
|
|
7113
|
-
showValue ? /* @__PURE__ */ (0,
|
|
8586
|
+
label || showValue ? /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)("div", { className: "ow-color-slider__header", children: [
|
|
8587
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("span", { id: labelId, className: "ow-color-slider__label", children: label }) : /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("span", {}),
|
|
8588
|
+
showValue ? /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("output", { className: "ow-color-slider__value", "aria-hidden": "true", children: shown }) : null
|
|
7114
8589
|
] }) : null,
|
|
7115
|
-
/* @__PURE__ */ (0,
|
|
8590
|
+
/* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
7116
8591
|
"div",
|
|
7117
8592
|
{
|
|
7118
8593
|
ref: trackRef,
|
|
@@ -7121,12 +8596,12 @@ var ColorSlider = (0, import_react60.forwardRef)(function ColorSlider2({
|
|
|
7121
8596
|
"--ow-color-slider-gradient": `linear-gradient(var(--ow-color-slider-direction), ${gradient(channel, color.value, rgba)})`
|
|
7122
8597
|
},
|
|
7123
8598
|
...drag.handlers,
|
|
7124
|
-
children: /* @__PURE__ */ (0,
|
|
8599
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
7125
8600
|
"div",
|
|
7126
8601
|
{
|
|
7127
8602
|
className: "ow-color-slider__thumb",
|
|
7128
8603
|
style: { "--ow-color-slider-position": `${current / spec.max * 100}%`, "--ow-color-slider-thumb": fill },
|
|
7129
|
-
children: /* @__PURE__ */ (0,
|
|
8604
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
7130
8605
|
"input",
|
|
7131
8606
|
{
|
|
7132
8607
|
ref: (element) => {
|
|
@@ -7158,18 +8633,18 @@ var ColorSlider = (0, import_react60.forwardRef)(function ColorSlider2({
|
|
|
7158
8633
|
)
|
|
7159
8634
|
}
|
|
7160
8635
|
),
|
|
7161
|
-
name ? /* @__PURE__ */ (0,
|
|
8636
|
+
name ? /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("input", { type: "hidden", name, value: color.hex }) : null
|
|
7162
8637
|
]
|
|
7163
8638
|
}
|
|
7164
8639
|
);
|
|
7165
8640
|
});
|
|
7166
8641
|
|
|
7167
8642
|
// src/components/ColorPicker/ColorSwatchPicker.tsx
|
|
7168
|
-
var
|
|
7169
|
-
var
|
|
7170
|
-
var ColorSwatchPicker = (0,
|
|
8643
|
+
var import_react69 = require("react");
|
|
8644
|
+
var import_jsx_runtime75 = require("react/jsx-runtime");
|
|
8645
|
+
var ColorSwatchPicker = (0, import_react69.forwardRef)(function ColorSwatchPicker2({ options, value, defaultValue, onChange, size: size2 = "md", shape = "square", disabled = false, name, className, ...aria }, ref) {
|
|
7171
8646
|
const [current, setCurrent] = useControllableState(value, defaultValue ?? "", onChange);
|
|
7172
|
-
const refs = (0,
|
|
8647
|
+
const refs = (0, import_react69.useRef)([]);
|
|
7173
8648
|
const items2 = options.map((option) => {
|
|
7174
8649
|
const item = typeof option === "string" ? { value: option } : option;
|
|
7175
8650
|
const rgba = parseHex(item.value);
|
|
@@ -7203,7 +8678,7 @@ var ColorSwatchPicker = (0, import_react61.forwardRef)(function ColorSwatchPicke
|
|
|
7203
8678
|
refs.current[target]?.focus();
|
|
7204
8679
|
choose(target);
|
|
7205
8680
|
}
|
|
7206
|
-
return /* @__PURE__ */ (0,
|
|
8681
|
+
return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
|
|
7207
8682
|
"div",
|
|
7208
8683
|
{
|
|
7209
8684
|
ref,
|
|
@@ -7220,7 +8695,7 @@ var ColorSwatchPicker = (0, import_react61.forwardRef)(function ColorSwatchPicke
|
|
|
7220
8695
|
items2.map((item, index) => {
|
|
7221
8696
|
const isSelected = index === selectedIndex;
|
|
7222
8697
|
const isDisabled = disabled || Boolean(item.disabled);
|
|
7223
|
-
return /* @__PURE__ */ (0,
|
|
8698
|
+
return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
7224
8699
|
"div",
|
|
7225
8700
|
{
|
|
7226
8701
|
ref: (element) => {
|
|
@@ -7237,12 +8712,12 @@ var ColorSwatchPicker = (0, import_react61.forwardRef)(function ColorSwatchPicke
|
|
|
7237
8712
|
style: { "--ow-color-swatch-picker-value": item.value },
|
|
7238
8713
|
onClick: () => choose(index),
|
|
7239
8714
|
onKeyDown: (event) => onKeyDown(event, index),
|
|
7240
|
-
children: /* @__PURE__ */ (0,
|
|
8715
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(CheckIcon, { size: size2 === "sm" ? 14 : 16, strokeWidth: 2.5, className: "ow-color-swatch-picker__check", "aria-hidden": "true" })
|
|
7241
8716
|
},
|
|
7242
8717
|
`${item.value}-${index}`
|
|
7243
8718
|
);
|
|
7244
8719
|
}),
|
|
7245
|
-
name ? /* @__PURE__ */ (0,
|
|
8720
|
+
name ? /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("input", { type: "hidden", name, value: selectedIndex >= 0 ? items2[selectedIndex].value : "" }) : null
|
|
7246
8721
|
]
|
|
7247
8722
|
}
|
|
7248
8723
|
);
|