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