@shapesos/clay 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -16342,16 +16342,21 @@ var require_lottie = __commonJS({
16342
16342
  // src/index.ts
16343
16343
  var src_exports = {};
16344
16344
  __export(src_exports, {
16345
- Chat: () => Chat,
16345
+ ChatContext: () => ChatContext,
16346
+ ChatMessage: () => ChatMessage,
16347
+ CtrlIcon: () => CtrlIcon,
16346
16348
  Icon: () => Icon,
16347
16349
  IconButton: () => IconButton,
16350
+ KEYBOARD_SHORTCUT_VARIANTS: () => KEYBOARD_SHORTCUT_VARIANTS,
16348
16351
  KeyboardShortcut: () => KeyboardShortcut,
16349
16352
  Lottie: () => Lottie,
16350
16353
  colors: () => colors,
16351
16354
  fontFamilies: () => fontFamilies,
16352
16355
  typographyMixin: () => typographyMixin,
16353
16356
  typographyStyles: () => typographyStyles,
16354
- typographyTypes: () => typographyTypes
16357
+ typographyTypes: () => typographyTypes,
16358
+ useChatContext: () => useChatContext,
16359
+ useCopyToClipboard: () => useCopyToClipboard
16355
16360
  });
16356
16361
  module.exports = __toCommonJS(src_exports);
16357
16362
 
@@ -16727,55 +16732,13 @@ function typographyMixin(type) {
16727
16732
  ].join(";\n ");
16728
16733
  }
16729
16734
 
16730
- // src/chat/chat-root/chat-root.tsx
16731
- var import_react2 = require("react");
16732
-
16733
- // src/chat/chat-context/chat-context.ts
16734
- var import_react = require("react");
16735
- var ChatContext = (0, import_react.createContext)(null);
16736
- function useChatContext() {
16737
- const context = (0, import_react.useContext)(ChatContext);
16738
- if (!context) {
16739
- throw new Error("useChatContext must be used within a Chat.Root component");
16740
- }
16741
- return context;
16742
- }
16743
-
16744
- // src/chat/chat-root/chat-root-styles.ts
16745
- var import_styled_components = __toESM(require("styled-components"), 1);
16746
- var RootContainer = import_styled_components.default.div`
16747
- display: flex;
16748
- flex-direction: column;
16749
- height: 100%;
16750
- overflow: hidden;
16751
- `;
16752
-
16753
- // src/chat/chat-root/chat-root.tsx
16754
- var import_jsx_runtime = require("react/jsx-runtime");
16755
- function ChatRoot({
16756
- messages,
16757
- onSendMessage,
16758
- isLoading = false,
16759
- onStop,
16760
- onCopyMessage,
16761
- onThumbUpClick,
16762
- onThumbDownClick,
16763
- children
16764
- }) {
16765
- const contextValue = (0, import_react2.useMemo)(
16766
- () => ({ messages, onSendMessage, isLoading, onStop, onCopyMessage, onThumbUpClick, onThumbDownClick }),
16767
- [messages, onSendMessage, isLoading, onStop, onCopyMessage, onThumbUpClick, onThumbDownClick]
16768
- );
16769
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChatContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RootContainer, { children }) });
16770
- }
16771
-
16772
16735
  // src/chat/chat-message-content/chat-message-content.tsx
16773
16736
  var import_react_markdown = __toESM(require("react-markdown"), 1);
16774
16737
  var import_remark_gfm = __toESM(require("remark-gfm"), 1);
16775
16738
 
16776
16739
  // src/chat/chat-message-content/chat-message-content-styles.ts
16777
- var import_styled_components2 = __toESM(require("styled-components"), 1);
16778
- var ContentWrapper = import_styled_components2.default.div`
16740
+ var import_styled_components = __toESM(require("styled-components"), 1);
16741
+ var ContentWrapper = import_styled_components.default.div`
16779
16742
  ${typographyMixin(typographyTypes.GEIST_BODY_XS_MEDIUM)};
16780
16743
  color: ${colors["brown-100"]};
16781
16744
  word-break: break-word;
@@ -16847,16 +16810,16 @@ var ContentWrapper = import_styled_components2.default.div`
16847
16810
  `;
16848
16811
 
16849
16812
  // src/chat/chat-message-content/chat-message-content.tsx
16850
- var import_jsx_runtime2 = require("react/jsx-runtime");
16813
+ var import_jsx_runtime = require("react/jsx-runtime");
16851
16814
  function ChatMessageContent({ content: content2 }) {
16852
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ContentWrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_markdown.default, { remarkPlugins: [import_remark_gfm.default], children: content2 }) });
16815
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ContentWrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_markdown.default, { remarkPlugins: [import_remark_gfm.default], children: content2 }) });
16853
16816
  }
16854
16817
 
16855
16818
  // src/chat/chat-message-actions/chat-message-actions.tsx
16856
- var import_react7 = require("react");
16819
+ var import_react6 = require("react");
16857
16820
 
16858
16821
  // node_modules/@tabler/icons-react/dist/esm/createReactComponent.mjs
16859
- var import_react3 = require("react");
16822
+ var import_react = require("react");
16860
16823
 
16861
16824
  // node_modules/@tabler/icons-react/dist/esm/defaultAttributes.mjs
16862
16825
  var defaultAttributes = {
@@ -16883,8 +16846,8 @@ var defaultAttributes = {
16883
16846
 
16884
16847
  // node_modules/@tabler/icons-react/dist/esm/createReactComponent.mjs
16885
16848
  var createReactComponent = (type, iconName, iconNamePascal, iconNode) => {
16886
- const Component = (0, import_react3.forwardRef)(
16887
- ({ color = "currentColor", size = 24, stroke = 2, title, className, children, ...rest }, ref) => (0, import_react3.createElement)(
16849
+ const Component = (0, import_react.forwardRef)(
16850
+ ({ color = "currentColor", size = 24, stroke = 2, title, className, children, ...rest }, ref) => (0, import_react.createElement)(
16888
16851
  "svg",
16889
16852
  {
16890
16853
  ref,
@@ -16901,8 +16864,8 @@ var createReactComponent = (type, iconName, iconNamePascal, iconNode) => {
16901
16864
  ...rest
16902
16865
  },
16903
16866
  [
16904
- title && (0, import_react3.createElement)("title", { key: "svg-title" }, title),
16905
- ...iconNode.map(([tag, attrs]) => (0, import_react3.createElement)(tag, attrs)),
16867
+ title && (0, import_react.createElement)("title", { key: "svg-title" }, title),
16868
+ ...iconNode.map(([tag, attrs]) => (0, import_react.createElement)(tag, attrs)),
16906
16869
  ...Array.isArray(children) ? children : [children]
16907
16870
  ]
16908
16871
  )
@@ -16911,43 +16874,35 @@ var createReactComponent = (type, iconName, iconNamePascal, iconNode) => {
16911
16874
  return Component;
16912
16875
  };
16913
16876
 
16914
- // node_modules/@tabler/icons-react/dist/esm/icons/IconArrowUp.mjs
16915
- var __iconNode = [["path", { "d": "M12 5l0 14", "key": "svg-0" }], ["path", { "d": "M18 11l-6 -6", "key": "svg-1" }], ["path", { "d": "M6 11l6 -6", "key": "svg-2" }]];
16916
- var IconArrowUp = createReactComponent("outline", "arrow-up", "ArrowUp", __iconNode);
16917
-
16918
16877
  // node_modules/@tabler/icons-react/dist/esm/icons/IconCheck.mjs
16919
- var __iconNode2 = [["path", { "d": "M5 12l5 5l10 -10", "key": "svg-0" }]];
16920
- var IconCheck = createReactComponent("outline", "check", "Check", __iconNode2);
16878
+ var __iconNode = [["path", { "d": "M5 12l5 5l10 -10", "key": "svg-0" }]];
16879
+ var IconCheck = createReactComponent("outline", "check", "Check", __iconNode);
16921
16880
 
16922
16881
  // node_modules/@tabler/icons-react/dist/esm/icons/IconCopy.mjs
16923
- var __iconNode3 = [["path", { "d": "M7 9.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667l0 -8.666", "key": "svg-0" }], ["path", { "d": "M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1", "key": "svg-1" }]];
16924
- var IconCopy = createReactComponent("outline", "copy", "Copy", __iconNode3);
16882
+ var __iconNode2 = [["path", { "d": "M7 9.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667l0 -8.666", "key": "svg-0" }], ["path", { "d": "M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1", "key": "svg-1" }]];
16883
+ var IconCopy = createReactComponent("outline", "copy", "Copy", __iconNode2);
16925
16884
 
16926
16885
  // node_modules/@tabler/icons-react/dist/esm/icons/IconThumbDown.mjs
16927
- var __iconNode4 = [["path", { "d": "M7 13v-8a1 1 0 0 0 -1 -1h-2a1 1 0 0 0 -1 1v7a1 1 0 0 0 1 1h3a4 4 0 0 1 4 4v1a2 2 0 0 0 4 0v-5h3a2 2 0 0 0 2 -2l-1 -5a2 3 0 0 0 -2 -2h-7a3 3 0 0 0 -3 3", "key": "svg-0" }]];
16928
- var IconThumbDown = createReactComponent("outline", "thumb-down", "ThumbDown", __iconNode4);
16886
+ var __iconNode3 = [["path", { "d": "M7 13v-8a1 1 0 0 0 -1 -1h-2a1 1 0 0 0 -1 1v7a1 1 0 0 0 1 1h3a4 4 0 0 1 4 4v1a2 2 0 0 0 4 0v-5h3a2 2 0 0 0 2 -2l-1 -5a2 3 0 0 0 -2 -2h-7a3 3 0 0 0 -3 3", "key": "svg-0" }]];
16887
+ var IconThumbDown = createReactComponent("outline", "thumb-down", "ThumbDown", __iconNode3);
16929
16888
 
16930
16889
  // node_modules/@tabler/icons-react/dist/esm/icons/IconThumbUp.mjs
16931
- var __iconNode5 = [["path", { "d": "M7 11v8a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1v-7a1 1 0 0 1 1 -1h3a4 4 0 0 0 4 -4v-1a2 2 0 0 1 4 0v5h3a2 2 0 0 1 2 2l-1 5a2 3 0 0 1 -2 2h-7a3 3 0 0 1 -3 -3", "key": "svg-0" }]];
16932
- var IconThumbUp = createReactComponent("outline", "thumb-up", "ThumbUp", __iconNode5);
16890
+ var __iconNode4 = [["path", { "d": "M7 11v8a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1v-7a1 1 0 0 1 1 -1h3a4 4 0 0 0 4 -4v-1a2 2 0 0 1 4 0v5h3a2 2 0 0 1 2 2l-1 5a2 3 0 0 1 -2 2h-7a3 3 0 0 1 -3 -3", "key": "svg-0" }]];
16891
+ var IconThumbUp = createReactComponent("outline", "thumb-up", "ThumbUp", __iconNode4);
16933
16892
 
16934
- // node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerStopFilled.mjs
16935
- var __iconNode6 = [["path", { "d": "M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z", "key": "svg-0" }]];
16936
- var IconPlayerStopFilled = createReactComponent("filled", "player-stop-filled", "PlayerStopFilled", __iconNode6);
16937
-
16938
- // src/icon-button/icon-button.tsx
16939
- var import_react5 = require("react");
16893
+ // src/components/icon-button/icon-button.tsx
16894
+ var import_react3 = require("react");
16940
16895
 
16941
- // src/icon/icon.tsx
16942
- var import_react4 = require("react");
16896
+ // src/components/icon/icon.tsx
16897
+ var import_react2 = require("react");
16943
16898
 
16944
- // src/icon/icon-styles.ts
16945
- var import_styled_components3 = __toESM(require("styled-components"), 1);
16899
+ // src/components/icon/icon-styles.ts
16900
+ var import_styled_components2 = __toESM(require("styled-components"), 1);
16946
16901
  var STROKE_WIDTH_BY_SIZE = {
16947
- 12: 1.2,
16948
- 14: 1.2,
16949
- 16: 1.8,
16950
- 18: 1.8,
16902
+ 12: 1.4,
16903
+ 14: 1.4,
16904
+ 16: 1.6,
16905
+ 18: 1.6,
16951
16906
  20: 1.8,
16952
16907
  24: 1.8
16953
16908
  };
@@ -16955,7 +16910,7 @@ var DEFAULT_STROKE_WIDTH = 1.8;
16955
16910
  function getStrokeWidth(size) {
16956
16911
  return STROKE_WIDTH_BY_SIZE[size] ?? DEFAULT_STROKE_WIDTH;
16957
16912
  }
16958
- var IconWrapper = import_styled_components3.default.span`
16913
+ var IconWrapper = import_styled_components2.default.span`
16959
16914
  display: inline-flex;
16960
16915
  align-items: center;
16961
16916
  justify-content: center;
@@ -16963,11 +16918,11 @@ var IconWrapper = import_styled_components3.default.span`
16963
16918
  flex-shrink: 0;
16964
16919
  `;
16965
16920
 
16966
- // src/icon/icon.tsx
16967
- var import_jsx_runtime3 = require("react/jsx-runtime");
16921
+ // src/components/icon/icon.tsx
16922
+ var import_jsx_runtime2 = require("react/jsx-runtime");
16968
16923
  var DEFAULT_SIZE = 16;
16969
- var Icon = (0, import_react4.forwardRef)(function Icon2({ icon: IconComponent, size = DEFAULT_SIZE, color, className, "aria-label": ariaLabel }, ref) {
16970
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
16924
+ var Icon = (0, import_react2.forwardRef)(function Icon2({ icon: IconComponent, size = DEFAULT_SIZE, color, className, "aria-label": ariaLabel }, ref) {
16925
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
16971
16926
  IconWrapper,
16972
16927
  {
16973
16928
  ref,
@@ -16975,13 +16930,13 @@ var Icon = (0, import_react4.forwardRef)(function Icon2({ icon: IconComponent, s
16975
16930
  $color: color,
16976
16931
  "aria-label": ariaLabel,
16977
16932
  role: ariaLabel ? "img" : void 0,
16978
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(IconComponent, { width: size, height: size, strokeWidth: getStrokeWidth(size) })
16933
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(IconComponent, { width: size, height: size, strokeWidth: getStrokeWidth(size) })
16979
16934
  }
16980
16935
  );
16981
16936
  });
16982
16937
 
16983
- // src/icon-button/icon-button-styles.ts
16984
- var import_styled_components4 = __toESM(require("styled-components"), 1);
16938
+ // src/components/icon-button/icon-button-styles.ts
16939
+ var import_styled_components3 = __toESM(require("styled-components"), 1);
16985
16940
  var DIMENSIONS = {
16986
16941
  small: 28,
16987
16942
  medium: 32
@@ -16990,7 +16945,7 @@ var BORDER_RADIUS = {
16990
16945
  small: 6,
16991
16946
  medium: 10
16992
16947
  };
16993
- var Button = import_styled_components4.default.button`
16948
+ var Button = import_styled_components3.default.button`
16994
16949
  display: inline-flex;
16995
16950
  align-items: center;
16996
16951
  justify-content: center;
@@ -17019,14 +16974,14 @@ var Button = import_styled_components4.default.button`
17019
16974
  }
17020
16975
  `;
17021
16976
 
17022
- // src/icon-button/icon-button.tsx
17023
- var import_jsx_runtime4 = require("react/jsx-runtime");
16977
+ // src/components/icon-button/icon-button.tsx
16978
+ var import_jsx_runtime3 = require("react/jsx-runtime");
17024
16979
  var ICON_SIZE_BY_BUTTON_SIZE = {
17025
16980
  small: 14,
17026
16981
  medium: 16
17027
16982
  };
17028
- var IconButton = (0, import_react5.forwardRef)(function IconButton2({ icon, size = "small", isSelected = false, disabled = false, onClick, className, "aria-label": ariaLabel }, ref) {
17029
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
16983
+ var IconButton = (0, import_react3.forwardRef)(function IconButton2({ icon, size = "small", isSelected = false, disabled = false, onClick, className, "aria-label": ariaLabel }, ref) {
16984
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
17030
16985
  Button,
17031
16986
  {
17032
16987
  ref,
@@ -17036,13 +16991,24 @@ var IconButton = (0, import_react5.forwardRef)(function IconButton2({ icon, size
17036
16991
  disabled,
17037
16992
  onClick: disabled ? void 0 : onClick,
17038
16993
  "aria-label": ariaLabel,
17039
- children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { icon, size: ICON_SIZE_BY_BUTTON_SIZE[size] })
16994
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon, { icon, size: ICON_SIZE_BY_BUTTON_SIZE[size] })
17040
16995
  }
17041
16996
  );
17042
16997
  });
17043
16998
 
16999
+ // src/chat/chat-context/chat-context.ts
17000
+ var import_react4 = require("react");
17001
+ var ChatContext = (0, import_react4.createContext)(null);
17002
+ function useChatContext() {
17003
+ const context = (0, import_react4.useContext)(ChatContext);
17004
+ if (!context) {
17005
+ throw new Error("useChatContext must be used within a Chat.Root component");
17006
+ }
17007
+ return context;
17008
+ }
17009
+
17044
17010
  // src/chat/hooks/use-copy-to-clipboard.ts
17045
- var import_react6 = require("react");
17011
+ var import_react5 = require("react");
17046
17012
 
17047
17013
  // src/utils/clipboard.ts
17048
17014
  function copyToClipboard(text2, options) {
@@ -17055,14 +17021,14 @@ function copyToClipboard(text2, options) {
17055
17021
  // src/chat/hooks/use-copy-to-clipboard.ts
17056
17022
  var RESET_DELAY_MS = 2e3;
17057
17023
  function useCopyToClipboard() {
17058
- const [isCopied, setIsCopied] = (0, import_react6.useState)(false);
17059
- const timeoutRef = (0, import_react6.useRef)(null);
17060
- (0, import_react6.useEffect)(() => {
17024
+ const [isCopied, setIsCopied] = (0, import_react5.useState)(false);
17025
+ const timeoutRef = (0, import_react5.useRef)(null);
17026
+ (0, import_react5.useEffect)(() => {
17061
17027
  return () => {
17062
17028
  if (timeoutRef.current) clearTimeout(timeoutRef.current);
17063
17029
  };
17064
17030
  }, []);
17065
- const copy = (0, import_react6.useCallback)((text2) => {
17031
+ const copy = (0, import_react5.useCallback)((text2) => {
17066
17032
  copyToClipboard(text2, {
17067
17033
  onSuccess: () => {
17068
17034
  setIsCopied(true);
@@ -17078,8 +17044,8 @@ function useCopyToClipboard() {
17078
17044
  }
17079
17045
 
17080
17046
  // src/chat/chat-message-actions/chat-message-actions-styles.ts
17081
- var import_styled_components5 = __toESM(require("styled-components"), 1);
17082
- var ActionsContainer = import_styled_components5.default.div`
17047
+ var import_styled_components4 = __toESM(require("styled-components"), 1);
17048
+ var ActionsContainer = import_styled_components4.default.div`
17083
17049
  display: flex;
17084
17050
  gap: 2px;
17085
17051
  margin-top: 4px;
@@ -17089,24 +17055,24 @@ var ActionsContainer = import_styled_components5.default.div`
17089
17055
  `;
17090
17056
 
17091
17057
  // src/chat/chat-message-actions/chat-message-actions.tsx
17092
- var import_jsx_runtime5 = require("react/jsx-runtime");
17058
+ var import_jsx_runtime4 = require("react/jsx-runtime");
17093
17059
  function ChatMessageActions({ messageId, content: content2, role, isHelpful }) {
17094
17060
  const { onCopyMessage, onThumbUpClick, onThumbDownClick } = useChatContext();
17095
17061
  const { isCopied, copy } = useCopyToClipboard();
17096
- const handleCopy = (0, import_react7.useCallback)(() => {
17062
+ const handleCopy = (0, import_react6.useCallback)(() => {
17097
17063
  copy(content2);
17098
17064
  onCopyMessage?.(messageId);
17099
17065
  }, [content2, messageId, copy, onCopyMessage]);
17100
- const handleThumbUp = (0, import_react7.useCallback)(() => {
17066
+ const handleThumbUp = (0, import_react6.useCallback)(() => {
17101
17067
  onThumbUpClick?.(messageId, isHelpful === true ? null : true);
17102
17068
  }, [messageId, isHelpful, onThumbUpClick]);
17103
- const handleThumbDown = (0, import_react7.useCallback)(() => {
17069
+ const handleThumbDown = (0, import_react6.useCallback)(() => {
17104
17070
  onThumbDownClick?.(messageId, isHelpful === false ? null : false);
17105
17071
  }, [messageId, isHelpful, onThumbDownClick]);
17106
17072
  const isAssistant = role === "assistant";
17107
17073
  const hasFeedback = isAssistant && (onThumbUpClick || onThumbDownClick);
17108
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(ActionsContainer, { children: [
17109
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
17074
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(ActionsContainer, { children: [
17075
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
17110
17076
  IconButton,
17111
17077
  {
17112
17078
  icon: isCopied ? IconCheck : IconCopy,
@@ -17114,7 +17080,7 @@ function ChatMessageActions({ messageId, content: content2, role, isHelpful }) {
17114
17080
  "aria-label": isCopied ? "Copied" : "Copy message"
17115
17081
  }
17116
17082
  ),
17117
- hasFeedback && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
17083
+ hasFeedback && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
17118
17084
  IconButton,
17119
17085
  {
17120
17086
  icon: IconThumbUp,
@@ -17123,7 +17089,7 @@ function ChatMessageActions({ messageId, content: content2, role, isHelpful }) {
17123
17089
  "aria-label": "Good response"
17124
17090
  }
17125
17091
  ),
17126
- hasFeedback && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
17092
+ hasFeedback && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
17127
17093
  IconButton,
17128
17094
  {
17129
17095
  icon: IconThumbDown,
@@ -17136,12 +17102,12 @@ function ChatMessageActions({ messageId, content: content2, role, isHelpful }) {
17136
17102
  }
17137
17103
 
17138
17104
  // src/chat/chat-message/chat-message-styles.ts
17139
- var import_styled_components6 = __toESM(require("styled-components"), 1);
17140
- var MessageRow = import_styled_components6.default.div`
17105
+ var import_styled_components5 = __toESM(require("styled-components"), 1);
17106
+ var MessageRow = import_styled_components5.default.div`
17141
17107
  display: flex;
17142
17108
  justify-content: ${({ $role }) => $role === "user" ? "flex-end" : "flex-start"};
17143
17109
  `;
17144
- var MessageContainer = import_styled_components6.default.div`
17110
+ var MessageContainer = import_styled_components5.default.div`
17145
17111
  display: flex;
17146
17112
  flex-direction: column;
17147
17113
  align-items: ${({ $role }) => $role === "user" ? "flex-end" : "flex-start"};
@@ -17152,7 +17118,7 @@ var MessageContainer = import_styled_components6.default.div`
17152
17118
  pointer-events: auto;
17153
17119
  }
17154
17120
  `;
17155
- var MessageBubble = import_styled_components6.default.div`
17121
+ var MessageBubble = import_styled_components5.default.div`
17156
17122
  ${typographyMixin(typographyTypes.GEIST_BODY_XS_MEDIUM)};
17157
17123
  color: ${colors["brown-100"]};
17158
17124
  background: ${({ $role }) => $role === "user" ? colors.white : "transparent"};
@@ -17161,11 +17127,11 @@ var MessageBubble = import_styled_components6.default.div`
17161
17127
  `;
17162
17128
 
17163
17129
  // src/chat/chat-message/chat-message.tsx
17164
- var import_jsx_runtime6 = require("react/jsx-runtime");
17130
+ var import_jsx_runtime5 = require("react/jsx-runtime");
17165
17131
  function ChatMessage({ message }) {
17166
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(MessageRow, { $role: message.role, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(MessageContainer, { $role: message.role, children: [
17167
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(MessageBubble, { $role: message.role, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ChatMessageContent, { content: message.content }) }),
17168
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
17132
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(MessageRow, { $role: message.role, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(MessageContainer, { $role: message.role, children: [
17133
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(MessageBubble, { $role: message.role, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ChatMessageContent, { content: message.content }) }),
17134
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
17169
17135
  ChatMessageActions,
17170
17136
  {
17171
17137
  messageId: message.id,
@@ -17177,269 +17143,76 @@ function ChatMessage({ message }) {
17177
17143
  ] }) });
17178
17144
  }
17179
17145
 
17180
- // src/chat/hooks/use-auto-scroll.ts
17181
- var import_react8 = require("react");
17182
- function useAutoScroll(messageCount) {
17183
- const scrollContainerRef = (0, import_react8.useRef)(null);
17184
- const sentinelRef = (0, import_react8.useRef)(null);
17185
- const [isAtBottom, setIsAtBottom] = (0, import_react8.useState)(true);
17186
- const prevMessageCountRef = (0, import_react8.useRef)(messageCount);
17187
- const hasInitializedRef = (0, import_react8.useRef)(false);
17188
- (0, import_react8.useLayoutEffect)(() => {
17189
- const el = scrollContainerRef.current;
17190
- if (el) {
17191
- el.scrollTop = el.scrollHeight;
17192
- }
17193
- }, []);
17194
- (0, import_react8.useEffect)(() => {
17195
- if (!hasInitializedRef.current) {
17196
- hasInitializedRef.current = true;
17197
- requestAnimationFrame(() => {
17198
- const el = scrollContainerRef.current;
17199
- if (el) {
17200
- el.scrollTop = el.scrollHeight;
17201
- }
17202
- });
17203
- }
17204
- }, []);
17205
- (0, import_react8.useEffect)(() => {
17206
- const sentinel = sentinelRef.current;
17207
- const scrollContainer = scrollContainerRef.current;
17208
- if (!sentinel || !scrollContainer) return;
17209
- const observer = new IntersectionObserver(
17210
- ([entry]) => {
17211
- setIsAtBottom(entry.isIntersecting);
17212
- },
17213
- { root: scrollContainer, threshold: 0 }
17214
- );
17215
- observer.observe(sentinel);
17216
- return () => observer.disconnect();
17217
- }, []);
17218
- (0, import_react8.useEffect)(() => {
17219
- if (!hasInitializedRef.current) return;
17220
- if (messageCount > prevMessageCountRef.current) {
17221
- requestAnimationFrame(() => {
17222
- const el = scrollContainerRef.current;
17223
- if (el) {
17224
- el.scrollTo({ top: el.scrollHeight, behavior: "smooth" });
17225
- }
17226
- });
17227
- }
17228
- prevMessageCountRef.current = messageCount;
17229
- }, [messageCount]);
17230
- const scrollToBottom = (0, import_react8.useCallback)(() => {
17231
- const el = scrollContainerRef.current;
17232
- if (el) {
17233
- el.scrollTo({ top: el.scrollHeight, behavior: "smooth" });
17234
- }
17235
- }, []);
17236
- return { scrollContainerRef, sentinelRef, isAtBottom, scrollToBottom };
17237
- }
17238
-
17239
- // src/chat/chat-message-list/chat-message-list-styles.ts
17240
- var import_styled_components7 = __toESM(require("styled-components"), 1);
17241
- var ListContainer = import_styled_components7.default.div`
17242
- display: flex;
17243
- flex-direction: column;
17244
- flex: 1;
17245
- overflow-y: auto;
17246
-
17247
- &::-webkit-scrollbar {
17248
- width: 6px;
17249
- }
17250
-
17251
- &::-webkit-scrollbar-track {
17252
- background: transparent;
17253
- }
17254
-
17255
- &::-webkit-scrollbar-thumb {
17256
- background: ${colors["brown-30"]};
17257
- border-radius: 3px;
17258
- }
17259
- `;
17260
- var MessagesList = import_styled_components7.default.div`
17261
- display: flex;
17262
- flex-direction: column;
17263
- gap: 40px;
17264
- padding: 0 16px 32px 16px;
17265
- `;
17266
- var ScrollSentinel = import_styled_components7.default.div`
17267
- flex-shrink: 0;
17268
- height: 16px;
17269
- `;
17270
-
17271
- // src/chat/chat-message-list/chat-message-list.tsx
17272
- var import_jsx_runtime7 = require("react/jsx-runtime");
17273
- function ChatMessageList() {
17274
- const { messages } = useChatContext();
17275
- const { scrollContainerRef, sentinelRef } = useAutoScroll(messages.length);
17276
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(ListContainer, { ref: scrollContainerRef, "data-testid": "chat-list-container", children: [
17277
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MessagesList, { children: messages.map((message) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ChatMessage, { message }, message.id)) }),
17278
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ScrollSentinel, { ref: sentinelRef, "data-testid": "chat-scroll-sentinel" })
17279
- ] });
17280
- }
17281
-
17282
- // src/chat/chat-composer/chat-composer.tsx
17283
- var import_react9 = require("react");
17284
-
17285
- // src/chat/chat-composer/chat-composer-styles.ts
17286
- var import_styled_components8 = __toESM(require("styled-components"), 1);
17287
- var ComposerContainer = import_styled_components8.default.div`
17288
- position: relative;
17289
- background: ${colors.white};
17290
- border-radius: 12px;
17291
- box-shadow: 0 0 4px 0 ${colors["brown-alpha-12"]};
17292
- padding: 8px 0;
17293
- `;
17294
- var TextArea = import_styled_components8.default.textarea`
17295
- display: block;
17296
- width: 100%;
17297
- resize: none;
17298
- border: none;
17299
- background: transparent;
17300
- ${typographyMixin(typographyTypes.GEIST_BODY_XS_MEDIUM)};
17301
- color: ${colors["brown-90"]};
17302
- padding: 4px 46px 4px 16px;
17303
- min-height: 20px;
17304
- max-height: 200px;
17305
- overflow-y: auto;
17306
- box-sizing: border-box;
17146
+ // src/components/keyboard-shortcut/keyboard-shortcut-styles.ts
17147
+ var import_styled_components6 = __toESM(require("styled-components"), 1);
17307
17148
 
17308
- &::placeholder {
17309
- color: ${colors["brown-60"]};
17310
- }
17149
+ // src/components/keyboard-shortcut/types.ts
17150
+ var KEYBOARD_SHORTCUT_VARIANTS = {
17151
+ OUTLINED: "outlined",
17152
+ FILLED: "filled"
17153
+ };
17311
17154
 
17312
- &:focus {
17313
- outline: none;
17314
- }
17155
+ // src/components/keyboard-shortcut/keyboard-shortcut-styles.ts
17156
+ var variantStyles = {
17157
+ [KEYBOARD_SHORTCUT_VARIANTS.OUTLINED]: import_styled_components6.css`
17158
+ border: 1px solid ${colors["brown-70"]};
17159
+ color: ${colors["brown-10"]};
17160
+ `,
17161
+ [KEYBOARD_SHORTCUT_VARIANTS.FILLED]: import_styled_components6.css`
17162
+ background: ${colors["brown-80"]};
17163
+ color: ${colors["brown-10"]};
17164
+ `
17165
+ };
17166
+ var Wrapper = import_styled_components6.default.div`
17167
+ display: inline-flex;
17168
+ align-items: center;
17169
+ gap: 2px;
17315
17170
  `;
17316
- var SendButton = import_styled_components8.default.button`
17317
- position: absolute;
17318
- bottom: 8px;
17319
- right: 8px;
17320
- width: 30px;
17321
- height: 30px;
17322
- border: none;
17323
- border-radius: 12px;
17324
- cursor: pointer;
17325
- display: flex;
17171
+ var Key = import_styled_components6.default.kbd`
17172
+ display: inline-flex;
17326
17173
  align-items: center;
17327
17174
  justify-content: center;
17328
- background: ${colors["brown-100"]};
17329
- color: ${colors.white};
17330
- transition: background-color 75ms;
17331
- padding: 0;
17332
-
17333
- &:disabled {
17334
- background: ${colors["brown-50"]};
17335
- cursor: default;
17336
- }
17175
+ padding: 4px;
17176
+ border-radius: 6px;
17177
+ ${({ $variant }) => variantStyles[$variant]};
17337
17178
  `;
17338
17179
 
17339
- // src/chat/chat-composer/chat-composer.tsx
17340
- var import_jsx_runtime8 = require("react/jsx-runtime");
17341
- function ChatComposer({ placeholder = "Type a message..." }) {
17342
- const { onSendMessage, isLoading, onStop } = useChatContext();
17343
- const [value2, setValue] = (0, import_react9.useState)("");
17344
- const textAreaRef = (0, import_react9.useRef)(null);
17345
- const isEmpty = value2.trim().length === 0;
17346
- const resizeTextArea = (0, import_react9.useCallback)(() => {
17347
- const el = textAreaRef.current;
17348
- if (!el) return;
17349
- el.style.height = "auto";
17350
- el.style.height = `${el.scrollHeight}px`;
17351
- }, []);
17352
- (0, import_react9.useEffect)(() => {
17353
- resizeTextArea();
17354
- }, [value2, resizeTextArea]);
17355
- (0, import_react9.useEffect)(() => {
17356
- textAreaRef.current?.focus();
17357
- }, []);
17358
- const handleSend = (0, import_react9.useCallback)(() => {
17359
- const trimmed = value2.trim();
17360
- if (!trimmed) return;
17361
- onSendMessage(trimmed);
17362
- setValue("");
17363
- requestAnimationFrame(() => textAreaRef.current?.focus());
17364
- }, [value2, onSendMessage]);
17365
- const handleKeyDown = (0, import_react9.useCallback)(
17366
- (e) => {
17367
- if (e.key === "Enter" && !e.shiftKey) {
17368
- e.preventDefault();
17369
- handleSend();
17370
- }
17371
- },
17372
- [handleSend]
17373
- );
17374
- const handleChange = (0, import_react9.useCallback)((e) => {
17375
- setValue(e.target.value);
17376
- }, []);
17377
- const handleButtonClick = (0, import_react9.useCallback)(() => {
17378
- if (isLoading && onStop) {
17379
- onStop();
17380
- } else {
17381
- handleSend();
17382
- }
17383
- }, [isLoading, onStop, handleSend]);
17384
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(ComposerContainer, { children: [
17385
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
17386
- TextArea,
17387
- {
17388
- ref: textAreaRef,
17389
- value: value2,
17390
- onChange: handleChange,
17391
- onKeyDown: handleKeyDown,
17392
- placeholder,
17393
- rows: 1
17394
- }
17395
- ),
17396
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
17397
- SendButton,
17398
- {
17399
- onClick: handleButtonClick,
17400
- disabled: !isLoading && isEmpty,
17401
- "aria-label": isLoading ? "Stop generating" : "Send message",
17402
- children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { icon: IconPlayerStopFilled, size: 16 }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { icon: IconArrowUp, size: 16 })
17403
- }
17404
- )
17405
- ] });
17180
+ // src/components/keyboard-shortcut/keyboard-shortcut.tsx
17181
+ var import_jsx_runtime6 = require("react/jsx-runtime");
17182
+ function KeyboardShortcut({
17183
+ keys,
17184
+ variant = KEYBOARD_SHORTCUT_VARIANTS.OUTLINED,
17185
+ className
17186
+ }) {
17187
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Wrapper, { className, children: keys.map((KeyComponent, index2) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Key, { $variant: variant, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { icon: KeyComponent, size: 12 }) }, index2)) });
17406
17188
  }
17407
17189
 
17408
- // src/chat/chat-namespace.ts
17409
- var Chat = {
17410
- Root: ChatRoot,
17411
- MessageList: ChatMessageList,
17412
- Composer: ChatComposer
17413
- };
17414
-
17415
- // src/keyboard-shortcut/keyboard-shortcut-styles.ts
17416
- var import_styled_components9 = __toESM(require("styled-components"), 1);
17417
- var Wrapper = import_styled_components9.default.div`
17418
- display: inline-flex;
17419
- align-items: center;
17420
- gap: 4px;
17421
- `;
17422
- var Key = import_styled_components9.default.kbd`
17423
- padding: 1px 4px;
17424
- border-radius: 4px;
17425
- border: 1px solid ${colors["brown-70"]};
17426
- border-bottom-width: 2px;
17427
- ${typographyMixin(typographyTypes.GEIST_LABEL_CAPTION_MEDIUM)};
17428
- color: inherit;
17429
- `;
17430
-
17431
- // src/keyboard-shortcut/keyboard-shortcut.tsx
17432
- var import_jsx_runtime9 = require("react/jsx-runtime");
17433
- function KeyboardShortcut({ keys, className }) {
17434
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Wrapper, { className, children: keys.map((key2) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Key, { children: key2 }, key2)) });
17190
+ // src/components/keyboard-shortcut/icons/ctrl-icon.tsx
17191
+ var import_jsx_runtime7 = require("react/jsx-runtime");
17192
+ function CtrlIcon(props) {
17193
+ const { width: width2 = 24, height: height2 = 24, ...rest } = props;
17194
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: width2, height: height2, fill: "none", ...rest, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
17195
+ "text",
17196
+ {
17197
+ x: "50%",
17198
+ y: "50%",
17199
+ dominantBaseline: "central",
17200
+ textAnchor: "middle",
17201
+ fill: "currentColor",
17202
+ fontFamily: "Geist, sans-serif",
17203
+ fontWeight: 500,
17204
+ fontSize: 14,
17205
+ children: "Ctrl"
17206
+ }
17207
+ ) });
17435
17208
  }
17436
17209
 
17437
- // src/lottie/lottie.tsx
17438
- var import_react11 = require("react");
17210
+ // src/components/lottie/lottie.tsx
17211
+ var import_react8 = require("react");
17439
17212
 
17440
- // src/lottie/lottie-styles.ts
17441
- var import_styled_components10 = __toESM(require("styled-components"), 1);
17442
- var LottieContainer = import_styled_components10.default.div`
17213
+ // src/components/lottie/lottie-styles.ts
17214
+ var import_styled_components7 = __toESM(require("styled-components"), 1);
17215
+ var LottieContainer = import_styled_components7.default.div`
17443
17216
  display: inline-flex;
17444
17217
  width: ${({ $width }) => typeof $width === "number" ? `${$width}px` : $width};
17445
17218
  height: ${({ $height }) => typeof $height === "number" ? `${$height}px` : $height};
@@ -17450,8 +17223,8 @@ var LottieContainer = import_styled_components10.default.div`
17450
17223
  }
17451
17224
  `;
17452
17225
 
17453
- // src/lottie/use-lottie.ts
17454
- var import_react10 = require("react");
17226
+ // src/components/lottie/use-lottie.ts
17227
+ var import_react7 = require("react");
17455
17228
  var import_lottie_web = __toESM(require_lottie(), 1);
17456
17229
  function useLottie({
17457
17230
  animationData: animationData2,
@@ -17466,17 +17239,17 @@ function useLottie({
17466
17239
  onLoopComplete,
17467
17240
  onEnterFrame
17468
17241
  }) {
17469
- const containerRef = (0, import_react10.useRef)(null);
17470
- const animationRef = (0, import_react10.useRef)(null);
17471
- const onAnimationLoadedRef = (0, import_react10.useRef)(onAnimationLoaded);
17472
- const onCompleteRef = (0, import_react10.useRef)(onComplete);
17473
- const onLoopCompleteRef = (0, import_react10.useRef)(onLoopComplete);
17474
- const onEnterFrameRef = (0, import_react10.useRef)(onEnterFrame);
17242
+ const containerRef = (0, import_react7.useRef)(null);
17243
+ const animationRef = (0, import_react7.useRef)(null);
17244
+ const onAnimationLoadedRef = (0, import_react7.useRef)(onAnimationLoaded);
17245
+ const onCompleteRef = (0, import_react7.useRef)(onComplete);
17246
+ const onLoopCompleteRef = (0, import_react7.useRef)(onLoopComplete);
17247
+ const onEnterFrameRef = (0, import_react7.useRef)(onEnterFrame);
17475
17248
  onAnimationLoadedRef.current = onAnimationLoaded;
17476
17249
  onCompleteRef.current = onComplete;
17477
17250
  onLoopCompleteRef.current = onLoopComplete;
17478
17251
  onEnterFrameRef.current = onEnterFrame;
17479
- (0, import_react10.useEffect)(() => {
17252
+ (0, import_react7.useEffect)(() => {
17480
17253
  if (!containerRef.current) return;
17481
17254
  const anim = import_lottie_web.default.loadAnimation({
17482
17255
  container: containerRef.current,
@@ -17567,9 +17340,9 @@ function createLottieRef(animationRef) {
17567
17340
  };
17568
17341
  }
17569
17342
 
17570
- // src/lottie/lottie.tsx
17571
- var import_jsx_runtime10 = require("react/jsx-runtime");
17572
- var Lottie = (0, import_react11.forwardRef)(function Lottie2({
17343
+ // src/components/lottie/lottie.tsx
17344
+ var import_jsx_runtime8 = require("react/jsx-runtime");
17345
+ var Lottie = (0, import_react8.forwardRef)(function Lottie2({
17573
17346
  animationData: animationData2,
17574
17347
  autoplay,
17575
17348
  loop,
@@ -17599,8 +17372,8 @@ var Lottie = (0, import_react11.forwardRef)(function Lottie2({
17599
17372
  onLoopComplete,
17600
17373
  onEnterFrame
17601
17374
  });
17602
- (0, import_react11.useImperativeHandle)(ref, () => createLottieRef(animationRef), [animationRef]);
17603
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
17375
+ (0, import_react8.useImperativeHandle)(ref, () => createLottieRef(animationRef), [animationRef]);
17376
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
17604
17377
  LottieContainer,
17605
17378
  {
17606
17379
  ref: containerRef,
@@ -17614,16 +17387,21 @@ var Lottie = (0, import_react11.forwardRef)(function Lottie2({
17614
17387
  });
17615
17388
  // Annotate the CommonJS export names for ESM import in node:
17616
17389
  0 && (module.exports = {
17617
- Chat,
17390
+ ChatContext,
17391
+ ChatMessage,
17392
+ CtrlIcon,
17618
17393
  Icon,
17619
17394
  IconButton,
17395
+ KEYBOARD_SHORTCUT_VARIANTS,
17620
17396
  KeyboardShortcut,
17621
17397
  Lottie,
17622
17398
  colors,
17623
17399
  fontFamilies,
17624
17400
  typographyMixin,
17625
17401
  typographyStyles,
17626
- typographyTypes
17402
+ typographyTypes,
17403
+ useChatContext,
17404
+ useCopyToClipboard
17627
17405
  });
17628
17406
  /*! Bundled license information:
17629
17407
 
@@ -17639,12 +17417,10 @@ lottie-web/build/player/lottie.js:
17639
17417
 
17640
17418
  @tabler/icons-react/dist/esm/defaultAttributes.mjs:
17641
17419
  @tabler/icons-react/dist/esm/createReactComponent.mjs:
17642
- @tabler/icons-react/dist/esm/icons/IconArrowUp.mjs:
17643
17420
  @tabler/icons-react/dist/esm/icons/IconCheck.mjs:
17644
17421
  @tabler/icons-react/dist/esm/icons/IconCopy.mjs:
17645
17422
  @tabler/icons-react/dist/esm/icons/IconThumbDown.mjs:
17646
17423
  @tabler/icons-react/dist/esm/icons/IconThumbUp.mjs:
17647
- @tabler/icons-react/dist/esm/icons/IconPlayerStopFilled.mjs:
17648
17424
  @tabler/icons-react/dist/esm/tabler-icons-react.mjs:
17649
17425
  (**
17650
17426
  * @license @tabler/icons-react v3.37.1 - MIT