@shapesos/clay 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.
Files changed (75) hide show
  1. package/dist/chat.cjs +259 -417
  2. package/dist/chat.cjs.map +1 -1
  3. package/dist/chat.d.cts +16 -22
  4. package/dist/chat.d.ts +16 -22
  5. package/dist/chat.js +16 -6
  6. package/dist/chunk-72TJUKMV.js +1 -0
  7. package/dist/{chunk-UKM5VQKW.js → chunk-BIATJTD4.js} +5 -5
  8. package/dist/chunk-BIATJTD4.js.map +1 -0
  9. package/dist/chunk-DRBRT57F.js +1 -0
  10. package/dist/chunk-DRBRT57F.js.map +1 -0
  11. package/dist/chunk-JC2RQL5O.js +76 -0
  12. package/dist/chunk-JC2RQL5O.js.map +1 -0
  13. package/dist/{chunk-6HNZQ2BF.js → chunk-JF3P66JF.js} +2 -1
  14. package/dist/chunk-JF3P66JF.js.map +1 -0
  15. package/dist/chunk-K2Q5MQWJ.js +17 -0
  16. package/dist/chunk-K2Q5MQWJ.js.map +1 -0
  17. package/dist/chunk-MLCRDVQ2.js +89 -0
  18. package/dist/chunk-MLCRDVQ2.js.map +1 -0
  19. package/dist/chunk-OLJIJYB5.js +46 -0
  20. package/dist/chunk-OLJIJYB5.js.map +1 -0
  21. package/dist/chunk-PCBRMJJJ.js +415 -0
  22. package/dist/chunk-PCBRMJJJ.js.map +1 -0
  23. package/dist/chunk-SMTOVZ3O.js +19 -0
  24. package/dist/chunk-SMTOVZ3O.js.map +1 -0
  25. package/dist/{chunk-A6DKIFWS.js → chunk-WQ2QTUYA.js} +9 -1
  26. package/dist/chunk-WQ2QTUYA.js.map +1 -0
  27. package/dist/chunk-WZHNMC6P.js +77 -0
  28. package/dist/chunk-WZHNMC6P.js.map +1 -0
  29. package/dist/icon.cjs +38 -23
  30. package/dist/icon.cjs.map +1 -1
  31. package/dist/icon.d.cts +6 -2
  32. package/dist/icon.d.ts +6 -2
  33. package/dist/icon.js +6 -4
  34. package/dist/index.cjs +417 -449
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +5 -11
  37. package/dist/index.d.ts +5 -11
  38. package/dist/index.js +42 -34
  39. package/dist/index.js.map +1 -1
  40. package/dist/keyboard-shortcut.cjs +238 -0
  41. package/dist/keyboard-shortcut.cjs.map +1 -0
  42. package/dist/keyboard-shortcut.d.cts +19 -0
  43. package/dist/keyboard-shortcut.d.ts +19 -0
  44. package/dist/keyboard-shortcut.js +14 -0
  45. package/dist/keyboard-shortcut.js.map +1 -0
  46. package/dist/lottie.cjs +5 -5
  47. package/dist/lottie.cjs.map +1 -1
  48. package/dist/lottie.js +1 -1
  49. package/dist/text-area.cjs +497 -0
  50. package/dist/text-area.cjs.map +1 -0
  51. package/dist/text-area.d.cts +18 -0
  52. package/dist/text-area.d.ts +18 -0
  53. package/dist/text-area.js +11 -0
  54. package/dist/text-area.js.map +1 -0
  55. package/dist/tokens.cjs +9 -0
  56. package/dist/tokens.cjs.map +1 -1
  57. package/dist/tokens.d.cts +2 -0
  58. package/dist/tokens.d.ts +2 -0
  59. package/dist/tokens.js +2 -2
  60. package/dist/utils.cjs +60 -0
  61. package/dist/utils.cjs.map +1 -0
  62. package/dist/utils.d.cts +7 -0
  63. package/dist/utils.d.ts +7 -0
  64. package/dist/utils.js +13 -0
  65. package/dist/utils.js.map +1 -0
  66. package/package.json +17 -1
  67. package/dist/chunk-2GFOESHR.js +0 -613
  68. package/dist/chunk-2GFOESHR.js.map +0 -1
  69. package/dist/chunk-6HNZQ2BF.js.map +0 -1
  70. package/dist/chunk-7AJSQJQ5.js +0 -1
  71. package/dist/chunk-A6DKIFWS.js.map +0 -1
  72. package/dist/chunk-P7NISN4V.js +0 -115
  73. package/dist/chunk-P7NISN4V.js.map +0 -1
  74. package/dist/chunk-UKM5VQKW.js.map +0 -1
  75. /package/dist/{chunk-7AJSQJQ5.js.map → chunk-72TJUKMV.js.map} +0 -0
package/dist/index.cjs CHANGED
@@ -16342,16 +16342,25 @@ 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,
16346
16347
  Icon: () => Icon,
16347
16348
  IconButton: () => IconButton,
16349
+ IconCtrl: () => IconCtrl,
16350
+ KEYBOARD_SHORTCUT_VARIANTS: () => KEYBOARD_SHORTCUT_VARIANTS,
16348
16351
  KeyboardShortcut: () => KeyboardShortcut,
16349
16352
  Lottie: () => Lottie,
16353
+ MESSAGE_ROLE: () => MESSAGE_ROLE,
16354
+ TextArea: () => TextArea,
16350
16355
  colors: () => colors,
16351
16356
  fontFamilies: () => fontFamilies,
16357
+ markdownToPlainText: () => markdownToPlainText,
16358
+ mergeRefs: () => mergeRefs,
16352
16359
  typographyMixin: () => typographyMixin,
16353
16360
  typographyStyles: () => typographyStyles,
16354
- typographyTypes: () => typographyTypes
16361
+ typographyTypes: () => typographyTypes,
16362
+ useChatContext: () => useChatContext,
16363
+ useCopyToClipboard: () => useCopyToClipboard
16355
16364
  });
16356
16365
  module.exports = __toCommonJS(src_exports);
16357
16366
 
@@ -16360,6 +16369,7 @@ var colors = {
16360
16369
  // White
16361
16370
  white: "#FFFFFF",
16362
16371
  "white-alpha-85": "rgba(255, 255, 255, 0.85)",
16372
+ "white-alpha-40": "rgba(255, 255, 255, 0.40)",
16363
16373
  // Brown
16364
16374
  "brown-10": "#FAF9F8",
16365
16375
  "brown-20": "#F5F3F0",
@@ -16460,6 +16470,7 @@ var typographyTypes = {
16460
16470
  GEIST_BODY_S_REGULAR: "GEIST_BODY_S_REGULAR",
16461
16471
  GEIST_BODY_S_MEDIUM: "GEIST_BODY_S_MEDIUM",
16462
16472
  GEIST_BODY_S_SEMI_BOLD: "GEIST_BODY_S_SEMI_BOLD",
16473
+ GEIST_BODY_S_BOLD: "GEIST_BODY_S_BOLD",
16463
16474
  // Geist Body Medium (18px)
16464
16475
  GEIST_BODY_M_LIGHT: "GEIST_BODY_M_LIGHT",
16465
16476
  GEIST_BODY_M_REGULAR: "GEIST_BODY_M_REGULAR",
@@ -16553,6 +16564,13 @@ var typographyStyles = {
16553
16564
  lineHeight: 24,
16554
16565
  letterSpacing: -0.08
16555
16566
  },
16567
+ [typographyTypes.GEIST_BODY_S_BOLD]: {
16568
+ fontFamily: fontFamilies.GEIST,
16569
+ fontSize: 16,
16570
+ fontWeight: 700,
16571
+ lineHeight: 24,
16572
+ letterSpacing: -0.08
16573
+ },
16556
16574
  // Geist Body Medium (18px)
16557
16575
  [typographyTypes.GEIST_BODY_M_LIGHT]: {
16558
16576
  fontFamily: fontFamilies.GEIST,
@@ -16727,136 +16745,149 @@ function typographyMixin(type) {
16727
16745
  ].join(";\n ");
16728
16746
  }
16729
16747
 
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
16748
  // src/chat/chat-message-content/chat-message-content.tsx
16773
16749
  var import_react_markdown = __toESM(require("react-markdown"), 1);
16750
+ var import_remark_breaks = __toESM(require("remark-breaks"), 1);
16774
16751
  var import_remark_gfm = __toESM(require("remark-gfm"), 1);
16775
16752
 
16776
16753
  // 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`
16779
- ${typographyMixin(typographyTypes.GEIST_BODY_XS_MEDIUM)};
16754
+ var import_styled_components = __toESM(require("styled-components"), 1);
16755
+ var ContentWrapper = import_styled_components.default.div`
16756
+ ${typographyMixin(typographyTypes.GEIST_BODY_S_REGULAR)};
16780
16757
  color: ${colors["brown-100"]};
16781
16758
  word-break: break-word;
16782
16759
 
16783
- & p {
16784
- margin: 0;
16760
+ & h1 {
16761
+ ${typographyMixin(typographyTypes.GEIST_HEADING_S_BOLD)};
16762
+ margin-block: 20px;
16763
+ }
16764
+
16765
+ & h2 {
16766
+ ${typographyMixin(typographyTypes.GEIST_BODY_L_SEMI_BOLD)};
16767
+ margin-block: 12px;
16768
+ }
16769
+
16770
+ & h3,
16771
+ & h4,
16772
+ & h5,
16773
+ & h6 {
16774
+ ${typographyMixin(typographyTypes.GEIST_BODY_M_SEMI_BOLD)};
16775
+ margin-block: 8px;
16785
16776
  }
16786
16777
 
16787
- & p + p {
16788
- margin-top: 8px;
16778
+ & strong {
16779
+ ${typographyMixin(typographyTypes.GEIST_BODY_S_SEMI_BOLD)};
16780
+ }
16781
+
16782
+ & p {
16783
+ margin-block: 8px;
16789
16784
  }
16790
16785
 
16791
16786
  & ul,
16792
16787
  & ol {
16793
- margin: 4px 0;
16788
+ margin-block: 16px;
16794
16789
  padding-left: 20px;
16795
16790
  }
16796
16791
 
16797
- & a {
16798
- color: ${colors["brown-100"]};
16799
- text-decoration: underline;
16792
+ & li + li {
16793
+ margin-block: 4px;
16800
16794
  }
16801
16795
 
16802
- & pre {
16803
- overflow-x: auto;
16804
- padding: 8px;
16805
- margin: 4px 0;
16806
- background: ${colors["brown-10"]};
16807
- border: 1px solid ${colors["brown-alpha-12"]};
16808
- border-radius: 8px;
16796
+ & ol {
16797
+ list-style-type: decimal;
16809
16798
  }
16810
16799
 
16811
- & pre code {
16812
- padding: 0;
16813
- background: none;
16814
- border-radius: 0;
16800
+ & ol ol {
16801
+ list-style-type: lower-alpha;
16815
16802
  }
16816
16803
 
16817
- & code {
16818
- padding: 2px 4px;
16819
- background: ${colors["brown-10"]};
16820
- border-radius: 4px;
16804
+ & ol ol ol {
16805
+ list-style-type: lower-roman;
16806
+ }
16807
+
16808
+ & a {
16809
+ color: inherit;
16810
+ text-decoration-line: underline;
16811
+ text-decoration-style: dotted;
16812
+ text-decoration-thickness: auto;
16813
+ text-underline-offset: auto;
16814
+ text-underline-position: from-font;
16815
+ transition: color 75ms ease-in-out;
16816
+
16817
+ &:hover {
16818
+ color: ${colors["blue-600"]};
16819
+ }
16820
+ }
16821
+
16822
+ & hr {
16823
+ border: none;
16824
+ border-top: 1px solid ${colors["brown-40"]};
16825
+ margin-block: 20px;
16821
16826
  }
16822
16827
 
16823
16828
  & table {
16824
- border-collapse: collapse;
16825
- margin: 8px 0;
16829
+ margin: 0;
16826
16830
  width: 100%;
16831
+ border-collapse: collapse;
16827
16832
  }
16828
16833
 
16829
16834
  & th,
16830
16835
  & td {
16831
- border: 1px solid ${colors["brown-alpha-12"]};
16832
- padding: 6px 12px;
16836
+ border: none;
16837
+ border-bottom: 1px solid ${colors["brown-40"]};
16833
16838
  text-align: left;
16834
16839
  }
16835
16840
 
16836
16841
  & th {
16837
- background: ${colors["brown-10"]};
16838
- font-weight: 600;
16842
+ ${typographyMixin(typographyTypes.GEIST_LABEL_CAPTION_MEDIUM)};
16843
+ padding: 8px;
16844
+ }
16845
+
16846
+ & td {
16847
+ ${typographyMixin(typographyTypes.GEIST_BODY_XS_MEDIUM)};
16848
+ padding: 16px 8px;
16849
+ min-width: 150px;
16850
+ width: 1%;
16851
+ }
16852
+
16853
+ & td strong {
16854
+ font-weight: inherit;
16855
+ font-size: inherit;
16856
+ line-height: inherit;
16839
16857
  }
16840
16858
 
16841
16859
  & blockquote {
16842
- margin: 4px 0;
16843
- padding-left: 12px;
16844
- border-left: 3px solid ${colors["brown-30"]};
16845
- color: ${colors["brown-70"]};
16860
+ margin-block: 4px;
16861
+ margin-inline: 0px;
16862
+ padding-left: 16px;
16863
+ border-left: 4px solid ${colors["brown-40"]};
16864
+ color: ${colors["brown-80"]};
16846
16865
  }
16847
16866
  `;
16867
+ var TableScroll = import_styled_components.default.div`
16868
+ width: 100%;
16869
+ overflow-x: auto;
16870
+ overflow-y: hidden;
16871
+ margin-block: 8px 16px;
16872
+ `;
16848
16873
 
16849
16874
  // src/chat/chat-message-content/chat-message-content.tsx
16850
- var import_jsx_runtime2 = require("react/jsx-runtime");
16875
+ var import_jsx_runtime = require("react/jsx-runtime");
16876
+ function ScrollableTable({ node: _node, ...props }) {
16877
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableScroll, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("table", { ...props }) });
16878
+ }
16879
+ var markdownComponents = {
16880
+ table: ScrollableTable
16881
+ };
16851
16882
  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 }) });
16883
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ContentWrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_markdown.default, { remarkPlugins: [import_remark_gfm.default, import_remark_breaks.default], components: markdownComponents, children: content2 }) });
16853
16884
  }
16854
16885
 
16855
16886
  // src/chat/chat-message-actions/chat-message-actions.tsx
16856
- var import_react7 = require("react");
16887
+ var import_react5 = require("react");
16857
16888
 
16858
16889
  // node_modules/@tabler/icons-react/dist/esm/createReactComponent.mjs
16859
- var import_react3 = require("react");
16890
+ var import_react = require("react");
16860
16891
 
16861
16892
  // node_modules/@tabler/icons-react/dist/esm/defaultAttributes.mjs
16862
16893
  var defaultAttributes = {
@@ -16883,8 +16914,8 @@ var defaultAttributes = {
16883
16914
 
16884
16915
  // node_modules/@tabler/icons-react/dist/esm/createReactComponent.mjs
16885
16916
  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)(
16917
+ const Component = (0, import_react.forwardRef)(
16918
+ ({ color = "currentColor", size = 24, stroke = 2, title, className, children, ...rest }, ref) => (0, import_react.createElement)(
16888
16919
  "svg",
16889
16920
  {
16890
16921
  ref,
@@ -16901,8 +16932,8 @@ var createReactComponent = (type, iconName, iconNamePascal, iconNode) => {
16901
16932
  ...rest
16902
16933
  },
16903
16934
  [
16904
- title && (0, import_react3.createElement)("title", { key: "svg-title" }, title),
16905
- ...iconNode.map(([tag, attrs]) => (0, import_react3.createElement)(tag, attrs)),
16935
+ title && (0, import_react.createElement)("title", { key: "svg-title" }, title),
16936
+ ...iconNode.map(([tag, attrs]) => (0, import_react.createElement)(tag, attrs)),
16906
16937
  ...Array.isArray(children) ? children : [children]
16907
16938
  ]
16908
16939
  )
@@ -16911,41 +16942,30 @@ var createReactComponent = (type, iconName, iconNamePascal, iconNode) => {
16911
16942
  return Component;
16912
16943
  };
16913
16944
 
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
16945
  // 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);
16946
+ var __iconNode = [["path", { "d": "M5 12l5 5l10 -10", "key": "svg-0" }]];
16947
+ var IconCheck = createReactComponent("outline", "check", "Check", __iconNode);
16921
16948
 
16922
16949
  // 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);
16950
+ 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" }]];
16951
+ var IconCopy = createReactComponent("outline", "copy", "Copy", __iconNode2);
16925
16952
 
16926
16953
  // 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);
16954
+ 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" }]];
16955
+ var IconThumbDown = createReactComponent("outline", "thumb-down", "ThumbDown", __iconNode3);
16929
16956
 
16930
16957
  // 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);
16958
+ 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" }]];
16959
+ var IconThumbUp = createReactComponent("outline", "thumb-up", "ThumbUp", __iconNode4);
16933
16960
 
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");
16940
-
16941
- // src/icon/icon.tsx
16942
- var import_react4 = require("react");
16961
+ // src/components/icon/icon.tsx
16962
+ var import_react2 = require("react");
16943
16963
 
16944
- // src/icon/icon-styles.ts
16945
- var import_styled_components3 = __toESM(require("styled-components"), 1);
16964
+ // src/components/icon/icon-styles.ts
16965
+ var import_styled_components2 = __toESM(require("styled-components"), 1);
16946
16966
  var STROKE_WIDTH_BY_SIZE = {
16947
- 12: 1.2,
16948
- 14: 1.2,
16967
+ 12: 1.4,
16968
+ 14: 1.4,
16949
16969
  16: 1.8,
16950
16970
  18: 1.8,
16951
16971
  20: 1.8,
@@ -16955,7 +16975,7 @@ var DEFAULT_STROKE_WIDTH = 1.8;
16955
16975
  function getStrokeWidth(size) {
16956
16976
  return STROKE_WIDTH_BY_SIZE[size] ?? DEFAULT_STROKE_WIDTH;
16957
16977
  }
16958
- var IconWrapper = import_styled_components3.default.span`
16978
+ var IconWrapper = import_styled_components2.default.span`
16959
16979
  display: inline-flex;
16960
16980
  align-items: center;
16961
16981
  justify-content: center;
@@ -16963,11 +16983,11 @@ var IconWrapper = import_styled_components3.default.span`
16963
16983
  flex-shrink: 0;
16964
16984
  `;
16965
16985
 
16966
- // src/icon/icon.tsx
16967
- var import_jsx_runtime3 = require("react/jsx-runtime");
16986
+ // src/components/icon/icon.tsx
16987
+ var import_jsx_runtime2 = require("react/jsx-runtime");
16968
16988
  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)(
16989
+ var Icon = (0, import_react2.forwardRef)(function Icon2({ icon: IconComponent, size = DEFAULT_SIZE, color, className, "aria-label": ariaLabel }, ref) {
16990
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
16971
16991
  IconWrapper,
16972
16992
  {
16973
16993
  ref,
@@ -16975,28 +16995,32 @@ var Icon = (0, import_react4.forwardRef)(function Icon2({ icon: IconComponent, s
16975
16995
  $color: color,
16976
16996
  "aria-label": ariaLabel,
16977
16997
  role: ariaLabel ? "img" : void 0,
16978
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(IconComponent, { width: size, height: size, strokeWidth: getStrokeWidth(size) })
16998
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(IconComponent, { width: size, height: size, strokeWidth: getStrokeWidth(size) })
16979
16999
  }
16980
17000
  );
16981
17001
  });
16982
17002
 
16983
- // src/icon-button/icon-button-styles.ts
16984
- var import_styled_components4 = __toESM(require("styled-components"), 1);
16985
- var DIMENSIONS = {
16986
- small: 28,
16987
- medium: 32
17003
+ // src/components/icon-button/icon-button-styles.ts
17004
+ var import_styled_components3 = __toESM(require("styled-components"), 1);
17005
+ var PADDING = {
17006
+ short: {
17007
+ small: "4px",
17008
+ medium: "6px"
17009
+ },
17010
+ long: {
17011
+ small: "4px 6px",
17012
+ medium: "6px 10px"
17013
+ }
16988
17014
  };
16989
17015
  var BORDER_RADIUS = {
16990
17016
  small: 6,
16991
17017
  medium: 10
16992
17018
  };
16993
- var Button = import_styled_components4.default.button`
17019
+ var Button = import_styled_components3.default.button`
16994
17020
  display: inline-flex;
16995
17021
  align-items: center;
16996
17022
  justify-content: center;
16997
- width: ${({ $size }) => DIMENSIONS[$size]}px;
16998
- height: ${({ $size }) => DIMENSIONS[$size]}px;
16999
- padding: 0;
17023
+ padding: ${({ $size, $variant }) => PADDING[$variant][$size]};
17000
17024
  border: none;
17001
17025
  border-radius: ${({ $size }) => BORDER_RADIUS[$size]}px;
17002
17026
  background: ${({ $isSelected }) => $isSelected ? colors["brown-40"] : "transparent"};
@@ -17019,30 +17043,54 @@ var Button = import_styled_components4.default.button`
17019
17043
  }
17020
17044
  `;
17021
17045
 
17022
- // src/icon-button/icon-button.tsx
17023
- var import_jsx_runtime4 = require("react/jsx-runtime");
17046
+ // src/components/icon-button/icon-button.tsx
17047
+ var import_jsx_runtime3 = require("react/jsx-runtime");
17024
17048
  var ICON_SIZE_BY_BUTTON_SIZE = {
17025
- small: 14,
17026
- medium: 16
17049
+ small: 16,
17050
+ medium: 20
17027
17051
  };
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)(
17052
+ function IconButton({
17053
+ icon,
17054
+ size = "small",
17055
+ variant = "short",
17056
+ isSelected = false,
17057
+ disabled = false,
17058
+ onClick,
17059
+ className,
17060
+ id,
17061
+ as,
17062
+ "aria-label": ariaLabel
17063
+ }) {
17064
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
17030
17065
  Button,
17031
17066
  {
17032
- ref,
17033
17067
  className,
17068
+ id,
17069
+ as,
17034
17070
  $size: size,
17071
+ $variant: variant,
17035
17072
  $isSelected: isSelected,
17036
17073
  disabled,
17037
17074
  onClick: disabled ? void 0 : onClick,
17038
17075
  "aria-label": ariaLabel,
17039
- children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { icon, size: ICON_SIZE_BY_BUTTON_SIZE[size] })
17076
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon, { icon, size: ICON_SIZE_BY_BUTTON_SIZE[size] })
17040
17077
  }
17041
17078
  );
17042
- });
17079
+ }
17080
+
17081
+ // src/chat/chat-context/chat-context.ts
17082
+ var import_react3 = require("react");
17083
+ var ChatContext = (0, import_react3.createContext)(null);
17084
+ function useChatContext() {
17085
+ const context = (0, import_react3.useContext)(ChatContext);
17086
+ if (!context) {
17087
+ throw new Error("useChatContext must be used within a Chat.Root component");
17088
+ }
17089
+ return context;
17090
+ }
17043
17091
 
17044
17092
  // src/chat/hooks/use-copy-to-clipboard.ts
17045
- var import_react6 = require("react");
17093
+ var import_react4 = require("react");
17046
17094
 
17047
17095
  // src/utils/clipboard.ts
17048
17096
  function copyToClipboard(text2, options) {
@@ -17052,18 +17100,33 @@ function copyToClipboard(text2, options) {
17052
17100
  );
17053
17101
  }
17054
17102
 
17103
+ // src/utils/markdown-to-plain-text.ts
17104
+ var PLACEHOLDER_PREFIX = "\u200B\u200BIC";
17105
+ var PLACEHOLDER_SUFFIX = "\u200B\u200B";
17106
+ var PLACEHOLDER_REGEX = new RegExp(`${PLACEHOLDER_PREFIX}(\\d+)${PLACEHOLDER_SUFFIX}`, "g");
17107
+ function markdownToPlainText(markdown) {
17108
+ if (!markdown) return "";
17109
+ const inlineCodeSnippets = [];
17110
+ let result = markdown.replace(/```[\s\S]*?```/g, "").replace(/`([^`]+)`/g, (_match, code) => {
17111
+ inlineCodeSnippets.push(code);
17112
+ return `${PLACEHOLDER_PREFIX}${inlineCodeSnippets.length - 1}${PLACEHOLDER_SUFFIX}`;
17113
+ }).replace(/^#{1,6}\s+/gm, "").replace(/^(?:---|\*\*\*|___)\s*$/gm, "").replace(/\*{3}(.+?)\*{3}/g, "$1").replace(/\*{2}(.+?)\*{2}/g, "$1").replace(/_{2}(.+?)_{2}/g, "$1").replace(/\*(.+?)\*/g, "$1").replace(/_(.+?)_/g, "$1").replace(/~~(.+?)~~/g, "$1").replace(/!\[([^\]]*)\]\([^)]+\)/g, "$1").replace(/\[([^\]]+)\]\([^)]+\)/g, "$1").replace(/^>\s?/gm, "").replace(/^\|[-:\s|]+\|\s*$/gm, "").replace(/^\|\s?/gm, "").replace(/\s?\|$/gm, "").replace(/\n{3,}/g, "\n\n").trim();
17114
+ result = result.replace(PLACEHOLDER_REGEX, (_match, index2) => inlineCodeSnippets[Number(index2)]);
17115
+ return result;
17116
+ }
17117
+
17055
17118
  // src/chat/hooks/use-copy-to-clipboard.ts
17056
17119
  var RESET_DELAY_MS = 2e3;
17057
17120
  function useCopyToClipboard() {
17058
- const [isCopied, setIsCopied] = (0, import_react6.useState)(false);
17059
- const timeoutRef = (0, import_react6.useRef)(null);
17060
- (0, import_react6.useEffect)(() => {
17121
+ const [isCopied, setIsCopied] = (0, import_react4.useState)(false);
17122
+ const timeoutRef = (0, import_react4.useRef)(null);
17123
+ (0, import_react4.useEffect)(() => {
17061
17124
  return () => {
17062
17125
  if (timeoutRef.current) clearTimeout(timeoutRef.current);
17063
17126
  };
17064
17127
  }, []);
17065
- const copy = (0, import_react6.useCallback)((text2) => {
17066
- copyToClipboard(text2, {
17128
+ const copy = (0, import_react4.useCallback)((text2) => {
17129
+ copyToClipboard(markdownToPlainText(text2), {
17067
17130
  onSuccess: () => {
17068
17131
  setIsCopied(true);
17069
17132
  if (timeoutRef.current) clearTimeout(timeoutRef.current);
@@ -17077,36 +17140,49 @@ function useCopyToClipboard() {
17077
17140
  return { isCopied, copy };
17078
17141
  }
17079
17142
 
17143
+ // src/chat/constants.ts
17144
+ var MESSAGE_ROLE = {
17145
+ USER: "user",
17146
+ ASSISTANT: "assistant"
17147
+ };
17148
+
17080
17149
  // 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`
17150
+ var import_styled_components4 = __toESM(require("styled-components"), 1);
17151
+ var FADE_DURATION_MS = 150;
17152
+ var ANIMATE_DURATION_MS = 200;
17153
+ var ActionsContainer = import_styled_components4.default.div`
17083
17154
  display: flex;
17084
- gap: 2px;
17085
- margin-top: 4px;
17086
- opacity: 0;
17087
- pointer-events: none;
17088
- transition: opacity 150ms ease;
17155
+ opacity: ${({ $role }) => $role === MESSAGE_ROLE.ASSISTANT ? 1 : 0};
17156
+ pointer-events: ${({ $role }) => $role === MESSAGE_ROLE.ASSISTANT ? "auto" : "none"};
17157
+ transition: opacity ${FADE_DURATION_MS}ms ease;
17158
+ `;
17159
+ var AnimatedAction = import_styled_components4.default.div`
17160
+ display: flex;
17161
+ overflow: hidden;
17162
+ max-width: ${({ $visible }) => $visible ? "40px" : "0"};
17163
+ opacity: ${({ $visible }) => $visible ? 1 : 0};
17164
+ transition: max-width ${ANIMATE_DURATION_MS}ms ease, opacity ${ANIMATE_DURATION_MS}ms ease;
17089
17165
  `;
17090
17166
 
17091
17167
  // src/chat/chat-message-actions/chat-message-actions.tsx
17092
- var import_jsx_runtime5 = require("react/jsx-runtime");
17093
- function ChatMessageActions({ messageId, content: content2, role, isHelpful }) {
17168
+ var import_jsx_runtime4 = require("react/jsx-runtime");
17169
+ function ChatMessageActions({ className, messageId, content: content2, role, isHelpful }) {
17094
17170
  const { onCopyMessage, onThumbUpClick, onThumbDownClick } = useChatContext();
17095
17171
  const { isCopied, copy } = useCopyToClipboard();
17096
- const handleCopy = (0, import_react7.useCallback)(() => {
17172
+ const handleCopy = (0, import_react5.useCallback)(() => {
17097
17173
  copy(content2);
17098
17174
  onCopyMessage?.(messageId);
17099
17175
  }, [content2, messageId, copy, onCopyMessage]);
17100
- const handleThumbUp = (0, import_react7.useCallback)(() => {
17176
+ const handleThumbUp = (0, import_react5.useCallback)(() => {
17101
17177
  onThumbUpClick?.(messageId, isHelpful === true ? null : true);
17102
17178
  }, [messageId, isHelpful, onThumbUpClick]);
17103
- const handleThumbDown = (0, import_react7.useCallback)(() => {
17179
+ const handleThumbDown = (0, import_react5.useCallback)(() => {
17104
17180
  onThumbDownClick?.(messageId, isHelpful === false ? null : false);
17105
17181
  }, [messageId, isHelpful, onThumbDownClick]);
17106
- const isAssistant = role === "assistant";
17182
+ const isAssistant = role === MESSAGE_ROLE.ASSISTANT;
17107
17183
  const hasFeedback = isAssistant && (onThumbUpClick || onThumbDownClick);
17108
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(ActionsContainer, { children: [
17109
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
17184
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(ActionsContainer, { $role: role, className, children: [
17185
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
17110
17186
  IconButton,
17111
17187
  {
17112
17188
  icon: isCopied ? IconCheck : IconCopy,
@@ -17114,7 +17190,7 @@ function ChatMessageActions({ messageId, content: content2, role, isHelpful }) {
17114
17190
  "aria-label": isCopied ? "Copied" : "Copy message"
17115
17191
  }
17116
17192
  ),
17117
- hasFeedback && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
17193
+ hasFeedback && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AnimatedAction, { $visible: isHelpful !== false, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
17118
17194
  IconButton,
17119
17195
  {
17120
17196
  icon: IconThumbUp,
@@ -17122,8 +17198,8 @@ function ChatMessageActions({ messageId, content: content2, role, isHelpful }) {
17122
17198
  isSelected: isHelpful === true,
17123
17199
  "aria-label": "Good response"
17124
17200
  }
17125
- ),
17126
- hasFeedback && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
17201
+ ) }),
17202
+ hasFeedback && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AnimatedAction, { $visible: isHelpful !== true, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
17127
17203
  IconButton,
17128
17204
  {
17129
17205
  icon: IconThumbDown,
@@ -17131,41 +17207,45 @@ function ChatMessageActions({ messageId, content: content2, role, isHelpful }) {
17131
17207
  isSelected: isHelpful === false,
17132
17208
  "aria-label": "Bad response"
17133
17209
  }
17134
- )
17210
+ ) })
17135
17211
  ] });
17136
17212
  }
17137
17213
 
17138
17214
  // 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`
17141
- display: flex;
17142
- justify-content: ${({ $role }) => $role === "user" ? "flex-end" : "flex-start"};
17143
- `;
17144
- var MessageContainer = import_styled_components6.default.div`
17215
+ var import_styled_components5 = __toESM(require("styled-components"), 1);
17216
+ var MessageRow = import_styled_components5.default.div`
17145
17217
  display: flex;
17146
- flex-direction: column;
17147
- align-items: ${({ $role }) => $role === "user" ? "flex-end" : "flex-start"};
17148
- max-width: 90%;
17218
+ justify-content: ${({ $role }) => $role === MESSAGE_ROLE.USER ? "flex-end" : "flex-start"};
17149
17219
 
17150
17220
  &:hover ${ActionsContainer} {
17151
17221
  opacity: 1;
17152
17222
  pointer-events: auto;
17153
17223
  }
17154
17224
  `;
17155
- var MessageBubble = import_styled_components6.default.div`
17156
- ${typographyMixin(typographyTypes.GEIST_BODY_XS_MEDIUM)};
17225
+ var MessageContainer = import_styled_components5.default.div`
17226
+ display: flex;
17227
+ flex-direction: column;
17228
+ align-items: ${({ $role }) => $role === MESSAGE_ROLE.USER ? "flex-end" : "flex-start"};
17229
+ max-width: 90%;
17230
+ width: ${({ $role }) => $role === MESSAGE_ROLE.USER ? "auto" : "100%"};
17231
+ gap: 12px;
17232
+ `;
17233
+ var MessageBubble = import_styled_components5.default.div`
17234
+ ${typographyMixin(typographyTypes.GEIST_BODY_S_REGULAR)};
17157
17235
  color: ${colors["brown-100"]};
17158
- background: ${({ $role }) => $role === "user" ? colors.white : "transparent"};
17159
- padding: ${({ $role }) => $role === "user" ? "12px 16px" : "0"};
17160
- border-radius: ${({ $role }) => $role === "user" ? "16px" : "0"};
17236
+ background: ${({ $role }) => $role === MESSAGE_ROLE.USER ? colors.white : "transparent"};
17237
+ padding: ${({ $role }) => $role === MESSAGE_ROLE.USER ? "12px 16px" : "0"};
17238
+ border-radius: ${({ $role }) => $role === MESSAGE_ROLE.USER ? "16px" : "0"};
17239
+ max-width: 100%;
17240
+ min-width: 0;
17161
17241
  `;
17162
17242
 
17163
17243
  // src/chat/chat-message/chat-message.tsx
17164
- var import_jsx_runtime6 = require("react/jsx-runtime");
17244
+ var import_jsx_runtime5 = require("react/jsx-runtime");
17165
17245
  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)(
17246
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(MessageRow, { $role: message.role, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(MessageContainer, { $role: message.role, children: [
17247
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(MessageBubble, { $role: message.role, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ChatMessageContent, { content: message.content }) }),
17248
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
17169
17249
  ChatMessageActions,
17170
17250
  {
17171
17251
  messageId: message.id,
@@ -17177,269 +17257,76 @@ function ChatMessage({ message }) {
17177
17257
  ] }) });
17178
17258
  }
17179
17259
 
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;
17260
+ // src/components/keyboard-shortcut/keyboard-shortcut-styles.ts
17261
+ var import_styled_components6 = __toESM(require("styled-components"), 1);
17307
17262
 
17308
- &::placeholder {
17309
- color: ${colors["brown-60"]};
17310
- }
17263
+ // src/components/keyboard-shortcut/types.ts
17264
+ var KEYBOARD_SHORTCUT_VARIANTS = {
17265
+ OUTLINED: "outlined",
17266
+ FILLED: "filled"
17267
+ };
17311
17268
 
17312
- &:focus {
17313
- outline: none;
17314
- }
17269
+ // src/components/keyboard-shortcut/keyboard-shortcut-styles.ts
17270
+ var variantStyles = {
17271
+ [KEYBOARD_SHORTCUT_VARIANTS.OUTLINED]: import_styled_components6.css`
17272
+ border: 1px solid ${colors["white-alpha-40"]};
17273
+ color: ${colors["brown-10"]};
17274
+ `,
17275
+ [KEYBOARD_SHORTCUT_VARIANTS.FILLED]: import_styled_components6.css`
17276
+ background: ${colors["brown-80"]};
17277
+ color: ${colors["brown-10"]};
17278
+ `
17279
+ };
17280
+ var Wrapper = import_styled_components6.default.div`
17281
+ display: inline-flex;
17282
+ align-items: center;
17283
+ gap: 2px;
17315
17284
  `;
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;
17285
+ var Key = import_styled_components6.default.kbd`
17286
+ display: inline-flex;
17326
17287
  align-items: center;
17327
17288
  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
- }
17289
+ padding: 2px;
17290
+ border-radius: 6px;
17291
+ ${({ $variant }) => variantStyles[$variant]};
17337
17292
  `;
17338
17293
 
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
- ] });
17294
+ // src/components/keyboard-shortcut/keyboard-shortcut.tsx
17295
+ var import_jsx_runtime6 = require("react/jsx-runtime");
17296
+ function KeyboardShortcut({
17297
+ keys,
17298
+ variant = KEYBOARD_SHORTCUT_VARIANTS.OUTLINED,
17299
+ className
17300
+ }) {
17301
+ 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
17302
  }
17407
17303
 
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)) });
17304
+ // src/components/keyboard-shortcut/icons/icon-ctrl.tsx
17305
+ var import_jsx_runtime7 = require("react/jsx-runtime");
17306
+ function IconCtrl(props) {
17307
+ const { width: width2 = 24, height: height2 = 24, ...rest } = props;
17308
+ 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)(
17309
+ "text",
17310
+ {
17311
+ x: "50%",
17312
+ y: "50%",
17313
+ dominantBaseline: "central",
17314
+ textAnchor: "middle",
17315
+ fill: "currentColor",
17316
+ fontFamily: "Geist, sans-serif",
17317
+ fontWeight: 300,
17318
+ fontSize: 14,
17319
+ children: "Ctrl"
17320
+ }
17321
+ ) });
17435
17322
  }
17436
17323
 
17437
- // src/lottie/lottie.tsx
17438
- var import_react11 = require("react");
17324
+ // src/components/lottie/lottie.tsx
17325
+ var import_react7 = require("react");
17439
17326
 
17440
- // src/lottie/lottie-styles.ts
17441
- var import_styled_components10 = __toESM(require("styled-components"), 1);
17442
- var LottieContainer = import_styled_components10.default.div`
17327
+ // src/components/lottie/lottie-styles.ts
17328
+ var import_styled_components7 = __toESM(require("styled-components"), 1);
17329
+ var LottieContainer = import_styled_components7.default.div`
17443
17330
  display: inline-flex;
17444
17331
  width: ${({ $width }) => typeof $width === "number" ? `${$width}px` : $width};
17445
17332
  height: ${({ $height }) => typeof $height === "number" ? `${$height}px` : $height};
@@ -17450,8 +17337,8 @@ var LottieContainer = import_styled_components10.default.div`
17450
17337
  }
17451
17338
  `;
17452
17339
 
17453
- // src/lottie/use-lottie.ts
17454
- var import_react10 = require("react");
17340
+ // src/components/lottie/use-lottie.ts
17341
+ var import_react6 = require("react");
17455
17342
  var import_lottie_web = __toESM(require_lottie(), 1);
17456
17343
  function useLottie({
17457
17344
  animationData: animationData2,
@@ -17466,17 +17353,17 @@ function useLottie({
17466
17353
  onLoopComplete,
17467
17354
  onEnterFrame
17468
17355
  }) {
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);
17356
+ const containerRef = (0, import_react6.useRef)(null);
17357
+ const animationRef = (0, import_react6.useRef)(null);
17358
+ const onAnimationLoadedRef = (0, import_react6.useRef)(onAnimationLoaded);
17359
+ const onCompleteRef = (0, import_react6.useRef)(onComplete);
17360
+ const onLoopCompleteRef = (0, import_react6.useRef)(onLoopComplete);
17361
+ const onEnterFrameRef = (0, import_react6.useRef)(onEnterFrame);
17475
17362
  onAnimationLoadedRef.current = onAnimationLoaded;
17476
17363
  onCompleteRef.current = onComplete;
17477
17364
  onLoopCompleteRef.current = onLoopComplete;
17478
17365
  onEnterFrameRef.current = onEnterFrame;
17479
- (0, import_react10.useEffect)(() => {
17366
+ (0, import_react6.useEffect)(() => {
17480
17367
  if (!containerRef.current) return;
17481
17368
  const anim = import_lottie_web.default.loadAnimation({
17482
17369
  container: containerRef.current,
@@ -17567,9 +17454,9 @@ function createLottieRef(animationRef) {
17567
17454
  };
17568
17455
  }
17569
17456
 
17570
- // src/lottie/lottie.tsx
17571
- var import_jsx_runtime10 = require("react/jsx-runtime");
17572
- var Lottie = (0, import_react11.forwardRef)(function Lottie2({
17457
+ // src/components/lottie/lottie.tsx
17458
+ var import_jsx_runtime8 = require("react/jsx-runtime");
17459
+ var Lottie = (0, import_react7.forwardRef)(function Lottie2({
17573
17460
  animationData: animationData2,
17574
17461
  autoplay,
17575
17462
  loop,
@@ -17599,8 +17486,8 @@ var Lottie = (0, import_react11.forwardRef)(function Lottie2({
17599
17486
  onLoopComplete,
17600
17487
  onEnterFrame
17601
17488
  });
17602
- (0, import_react11.useImperativeHandle)(ref, () => createLottieRef(animationRef), [animationRef]);
17603
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
17489
+ (0, import_react7.useImperativeHandle)(ref, () => createLottieRef(animationRef), [animationRef]);
17490
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
17604
17491
  LottieContainer,
17605
17492
  {
17606
17493
  ref: containerRef,
@@ -17612,18 +17499,101 @@ var Lottie = (0, import_react11.forwardRef)(function Lottie2({
17612
17499
  }
17613
17500
  );
17614
17501
  });
17502
+
17503
+ // src/components/text-area/text-area.tsx
17504
+ var import_react8 = require("react");
17505
+
17506
+ // src/utils/merge-refs.ts
17507
+ function mergeRefs(...refs) {
17508
+ return (node) => {
17509
+ for (const ref of refs) {
17510
+ if (typeof ref === "function") {
17511
+ ref(node);
17512
+ } else if (ref) {
17513
+ ref.current = node;
17514
+ }
17515
+ }
17516
+ };
17517
+ }
17518
+
17519
+ // src/components/text-area/text-area-styles.ts
17520
+ var import_styled_components8 = __toESM(require("styled-components"), 1);
17521
+ var StyledTextArea = import_styled_components8.default.textarea`
17522
+ ${typographyMixin(typographyTypes.GEIST_BODY_S_REGULAR)};
17523
+ color: ${colors["brown-100"]};
17524
+ border: none;
17525
+ outline: none;
17526
+ resize: none;
17527
+ width: 100%;
17528
+ background: transparent;
17529
+ vertical-align: bottom;
17530
+ max-height: ${({ $maxHeight }) => $maxHeight ? `${$maxHeight}px` : "none"};
17531
+ overflow-y: ${({ $maxHeight }) => $maxHeight ? "auto" : "hidden"};
17532
+
17533
+ &::placeholder {
17534
+ color: ${colors["brown-50"]};
17535
+ }
17536
+
17537
+ &:disabled {
17538
+ opacity: 0.5;
17539
+ cursor: not-allowed;
17540
+ }
17541
+ `;
17542
+
17543
+ // src/components/text-area/text-area.tsx
17544
+ var import_jsx_runtime9 = require("react/jsx-runtime");
17545
+ var TextArea = (0, import_react8.forwardRef)(function TextArea2({ value: value2, onChange, placeholder, maxHeight, rows = 1, autoFocus, onKeyDown, disabled, className }, externalRef) {
17546
+ const internalRef = (0, import_react8.useRef)(null);
17547
+ (0, import_react8.useLayoutEffect)(() => {
17548
+ const el = internalRef.current;
17549
+ if (el) {
17550
+ el.style.height = "auto";
17551
+ el.style.height = `${el.scrollHeight}px`;
17552
+ }
17553
+ }, [value2]);
17554
+ const handleChange = (0, import_react8.useCallback)(
17555
+ (e) => {
17556
+ onChange(e.target.value);
17557
+ },
17558
+ [onChange]
17559
+ );
17560
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
17561
+ StyledTextArea,
17562
+ {
17563
+ ref: mergeRefs(internalRef, externalRef),
17564
+ value: value2,
17565
+ onChange: handleChange,
17566
+ placeholder,
17567
+ $maxHeight: maxHeight,
17568
+ rows,
17569
+ autoFocus,
17570
+ onKeyDown,
17571
+ disabled,
17572
+ className
17573
+ }
17574
+ );
17575
+ });
17615
17576
  // Annotate the CommonJS export names for ESM import in node:
17616
17577
  0 && (module.exports = {
17617
- Chat,
17578
+ ChatContext,
17579
+ ChatMessage,
17618
17580
  Icon,
17619
17581
  IconButton,
17582
+ IconCtrl,
17583
+ KEYBOARD_SHORTCUT_VARIANTS,
17620
17584
  KeyboardShortcut,
17621
17585
  Lottie,
17586
+ MESSAGE_ROLE,
17587
+ TextArea,
17622
17588
  colors,
17623
17589
  fontFamilies,
17590
+ markdownToPlainText,
17591
+ mergeRefs,
17624
17592
  typographyMixin,
17625
17593
  typographyStyles,
17626
- typographyTypes
17594
+ typographyTypes,
17595
+ useChatContext,
17596
+ useCopyToClipboard
17627
17597
  });
17628
17598
  /*! Bundled license information:
17629
17599
 
@@ -17639,12 +17609,10 @@ lottie-web/build/player/lottie.js:
17639
17609
 
17640
17610
  @tabler/icons-react/dist/esm/defaultAttributes.mjs:
17641
17611
  @tabler/icons-react/dist/esm/createReactComponent.mjs:
17642
- @tabler/icons-react/dist/esm/icons/IconArrowUp.mjs:
17643
17612
  @tabler/icons-react/dist/esm/icons/IconCheck.mjs:
17644
17613
  @tabler/icons-react/dist/esm/icons/IconCopy.mjs:
17645
17614
  @tabler/icons-react/dist/esm/icons/IconThumbDown.mjs:
17646
17615
  @tabler/icons-react/dist/esm/icons/IconThumbUp.mjs:
17647
- @tabler/icons-react/dist/esm/icons/IconPlayerStopFilled.mjs:
17648
17616
  @tabler/icons-react/dist/esm/tabler-icons-react.mjs:
17649
17617
  (**
17650
17618
  * @license @tabler/icons-react v3.37.1 - MIT