@btst/stack 1.3.1 → 1.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.
Files changed (238) hide show
  1. package/README.md +85 -37
  2. package/dist/node_modules/.pnpm/@radix-ui_react-accordion@1.2.12_@types_react-dom@19.2.3_@types_react@19.2.6__@types_re_947719a27ff11ec6f09710dd9e85efc5/node_modules/@radix-ui/react-accordion/dist/index.cjs +321 -0
  3. package/dist/node_modules/.pnpm/@radix-ui_react-accordion@1.2.12_@types_react-dom@19.2.3_@types_react@19.2.6__@types_re_947719a27ff11ec6f09710dd9e85efc5/node_modules/@radix-ui/react-accordion/dist/index.mjs +306 -0
  4. package/dist/node_modules/.pnpm/{@radix-ui_react-alert-dialog@1.1.15_@types_react-dom@19.2.2_@types_react@19.2.2__@types_ec789942cd38340bd7362c09e7d34384 → @radix-ui_react-alert-dialog@1.1.15_@types_react-dom@19.2.3_@types_react@19.2.6__@types_4f58c757aa677e233cf96d60fda2f1da}/node_modules/@radix-ui/react-alert-dialog/dist/index.cjs +2 -2
  5. package/dist/node_modules/.pnpm/{@radix-ui_react-alert-dialog@1.1.15_@types_react-dom@19.2.2_@types_react@19.2.2__@types_ec789942cd38340bd7362c09e7d34384 → @radix-ui_react-alert-dialog@1.1.15_@types_react-dom@19.2.3_@types_react@19.2.6__@types_4f58c757aa677e233cf96d60fda2f1da}/node_modules/@radix-ui/react-alert-dialog/dist/index.mjs +2 -2
  6. package/dist/node_modules/.pnpm/{@radix-ui_react-arrow@1.1.7_@types_react-dom@19.2.2_@types_react@19.2.2__@types_react@1_9e04309f365863673e44407648bb0cb6 → @radix-ui_react-arrow@1.1.7_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@1_35df44f6d87656c1401686c91d770dbb}/node_modules/@radix-ui/react-arrow/dist/index.cjs +1 -1
  7. package/dist/node_modules/.pnpm/{@radix-ui_react-arrow@1.1.7_@types_react-dom@19.2.2_@types_react@19.2.2__@types_react@1_9e04309f365863673e44407648bb0cb6 → @radix-ui_react-arrow@1.1.7_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@1_35df44f6d87656c1401686c91d770dbb}/node_modules/@radix-ui/react-arrow/dist/index.mjs +1 -1
  8. package/dist/node_modules/.pnpm/@radix-ui_react-collapsible@1.1.12_@types_react-dom@19.2.3_@types_react@19.2.6__@types__d025a77f62ee83ca6bd8b0ea1f9de738/node_modules/@radix-ui/react-collapsible/dist/index.cjs +168 -0
  9. package/dist/node_modules/.pnpm/@radix-ui_react-collapsible@1.1.12_@types_react-dom@19.2.3_@types_react@19.2.6__@types__d025a77f62ee83ca6bd8b0ea1f9de738/node_modules/@radix-ui/react-collapsible/dist/index.mjs +146 -0
  10. package/dist/node_modules/.pnpm/{@radix-ui_react-collection@1.1.7_@types_react-dom@19.2.2_@types_react@19.2.2__@types_re_6d7c277722b3619c9ee7e64e9a822c45 → @radix-ui_react-collection@1.1.7_@types_react-dom@19.2.3_@types_react@19.2.6__@types_re_59aa5e150e70a3e7bfb1567148b021b5}/node_modules/@radix-ui/react-collection/dist/index.cjs +2 -2
  11. package/dist/node_modules/.pnpm/{@radix-ui_react-collection@1.1.7_@types_react-dom@19.2.2_@types_react@19.2.2__@types_re_6d7c277722b3619c9ee7e64e9a822c45 → @radix-ui_react-collection@1.1.7_@types_react-dom@19.2.3_@types_react@19.2.6__@types_re_59aa5e150e70a3e7bfb1567148b021b5}/node_modules/@radix-ui/react-collection/dist/index.mjs +2 -2
  12. package/dist/node_modules/.pnpm/{@radix-ui_react-dismissable-layer@1.1.11_@types_react-dom@19.2.2_@types_react@19.2.2__@_ca5522e5d45d4722cb9eb5ce53defa61 → @radix-ui_react-dismissable-layer@1.1.11_@types_react-dom@19.2.3_@types_react@19.2.6__@_9ee1db7daf927866cf505b31d40047ad}/node_modules/@radix-ui/react-dismissable-layer/dist/index.cjs +4 -4
  13. package/dist/node_modules/.pnpm/{@radix-ui_react-dismissable-layer@1.1.11_@types_react-dom@19.2.2_@types_react@19.2.2__@_ca5522e5d45d4722cb9eb5ce53defa61 → @radix-ui_react-dismissable-layer@1.1.11_@types_react-dom@19.2.3_@types_react@19.2.6__@_9ee1db7daf927866cf505b31d40047ad}/node_modules/@radix-ui/react-dismissable-layer/dist/index.mjs +4 -4
  14. package/dist/node_modules/.pnpm/@radix-ui_react-dropdown-menu@2.1.16_@types_react-dom@19.2.3_@types_react@19.2.6__@type_a50051c7210b6fbd5be09388bda08578/node_modules/@radix-ui/react-dropdown-menu/dist/index.cjs +282 -0
  15. package/dist/node_modules/.pnpm/@radix-ui_react-dropdown-menu@2.1.16_@types_react-dom@19.2.3_@types_react@19.2.6__@type_a50051c7210b6fbd5be09388bda08578/node_modules/@radix-ui/react-dropdown-menu/dist/index.mjs +247 -0
  16. package/dist/node_modules/.pnpm/{@radix-ui_react-focus-scope@1.1.7_@types_react-dom@19.2.2_@types_react@19.2.2__@types_r_93de389b3f622f9f764acc8e59ec80c0 → @radix-ui_react-focus-scope@1.1.7_@types_react-dom@19.2.3_@types_react@19.2.6__@types_r_0a31b7f987af9482d13505312e1a1be9}/node_modules/@radix-ui/react-focus-scope/dist/index.cjs +3 -3
  17. package/dist/node_modules/.pnpm/{@radix-ui_react-focus-scope@1.1.7_@types_react-dom@19.2.2_@types_react@19.2.2__@types_r_93de389b3f622f9f764acc8e59ec80c0 → @radix-ui_react-focus-scope@1.1.7_@types_react-dom@19.2.3_@types_react@19.2.6__@types_r_0a31b7f987af9482d13505312e1a1be9}/node_modules/@radix-ui/react-focus-scope/dist/index.mjs +3 -3
  18. package/dist/node_modules/.pnpm/{@radix-ui_react-id@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-id@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-id/dist/index.cjs +1 -1
  19. package/dist/node_modules/.pnpm/{@radix-ui_react-id@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-id@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-id/dist/index.mjs +1 -1
  20. package/dist/node_modules/.pnpm/@radix-ui_react-menu@2.1.16_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@1_82ed1fcd848b6984d9291a784d477cf4/node_modules/@radix-ui/react-menu/dist/index.cjs +845 -0
  21. package/dist/node_modules/.pnpm/@radix-ui_react-menu@2.1.16_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@1_82ed1fcd848b6984d9291a784d477cf4/node_modules/@radix-ui/react-menu/dist/index.mjs +799 -0
  22. package/dist/node_modules/.pnpm/{@radix-ui_react-popper@1.2.8_@types_react-dom@19.2.2_@types_react@19.2.2__@types_react@_d6285b8269ea5d6b59b300f5be279a0c → @radix-ui_react-popper@1.2.8_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@_7ac2caae1e39f9ba93d5015614525161}/node_modules/@radix-ui/react-popper/dist/index.cjs +7 -7
  23. package/dist/node_modules/.pnpm/{@radix-ui_react-popper@1.2.8_@types_react-dom@19.2.2_@types_react@19.2.2__@types_react@_d6285b8269ea5d6b59b300f5be279a0c → @radix-ui_react-popper@1.2.8_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@_7ac2caae1e39f9ba93d5015614525161}/node_modules/@radix-ui/react-popper/dist/index.mjs +7 -7
  24. package/dist/node_modules/.pnpm/{@radix-ui_react-portal@1.1.9_@types_react-dom@19.2.2_@types_react@19.2.2__@types_react@_478b3d5dd4afab1a3dcce7ed1748cb95 → @radix-ui_react-portal@1.1.9_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@_1bb4e0f97f86496802d28a2e74e2a8b9}/node_modules/@radix-ui/react-portal/dist/index.cjs +2 -2
  25. package/dist/node_modules/.pnpm/{@radix-ui_react-portal@1.1.9_@types_react-dom@19.2.2_@types_react@19.2.2__@types_react@_478b3d5dd4afab1a3dcce7ed1748cb95 → @radix-ui_react-portal@1.1.9_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@_1bb4e0f97f86496802d28a2e74e2a8b9}/node_modules/@radix-ui/react-portal/dist/index.mjs +2 -2
  26. package/dist/node_modules/.pnpm/@radix-ui_react-presence@1.1.5_@types_react-dom@19.2.3_@types_react@19.2.6__@types_reac_90f8e5c12233caef3399d5fd66452a13/node_modules/@radix-ui/react-presence/dist/index.cjs +147 -0
  27. package/dist/node_modules/.pnpm/@radix-ui_react-presence@1.1.5_@types_react-dom@19.2.3_@types_react@19.2.6__@types_reac_90f8e5c12233caef3399d5fd66452a13/node_modules/@radix-ui/react-presence/dist/index.mjs +131 -0
  28. package/dist/node_modules/.pnpm/@radix-ui_react-roving-focus@1.1.11_@types_react-dom@19.2.3_@types_react@19.2.6__@types_fe1151d1f393bbc1072b24a86dff3a23/node_modules/@radix-ui/react-roving-focus/dist/index.cjs +244 -0
  29. package/dist/node_modules/.pnpm/@radix-ui_react-roving-focus@1.1.11_@types_react-dom@19.2.3_@types_react@19.2.6__@types_fe1151d1f393bbc1072b24a86dff3a23/node_modules/@radix-ui/react-roving-focus/dist/index.mjs +224 -0
  30. package/dist/node_modules/.pnpm/@radix-ui_react-scroll-area@1.2.10_@types_react-dom@19.2.3_@types_react@19.2.6__@types__e3f7735e9b444a10b3bbfd9fe97d44d0/node_modules/@radix-ui/react-scroll-area/dist/index.cjs +742 -0
  31. package/dist/node_modules/.pnpm/@radix-ui_react-scroll-area@1.2.10_@types_react-dom@19.2.3_@types_react@19.2.6__@types__e3f7735e9b444a10b3bbfd9fe97d44d0/node_modules/@radix-ui/react-scroll-area/dist/index.mjs +719 -0
  32. package/dist/node_modules/.pnpm/{@radix-ui_react-select@2.2.6_@types_react-dom@19.2.2_@types_react@19.2.2__@types_react@_802c3d414c85063bee785fcc98a39c07 → @radix-ui_react-select@2.2.6_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@_38dc681bb1f2bcfeb5249d8ca2bc01f5}/node_modules/@radix-ui/react-select/dist/index.cjs +17 -17
  33. package/dist/node_modules/.pnpm/{@radix-ui_react-select@2.2.6_@types_react-dom@19.2.2_@types_react@19.2.2__@types_react@_802c3d414c85063bee785fcc98a39c07 → @radix-ui_react-select@2.2.6_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@_38dc681bb1f2bcfeb5249d8ca2bc01f5}/node_modules/@radix-ui/react-select/dist/index.mjs +17 -17
  34. package/dist/node_modules/.pnpm/{@radix-ui_react-use-controllable-state@1.2.2_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-controllable-state@1.2.2_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-controllable-state/dist/index.cjs +1 -1
  35. package/dist/node_modules/.pnpm/{@radix-ui_react-use-controllable-state@1.2.2_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-controllable-state@1.2.2_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs +1 -1
  36. package/dist/node_modules/.pnpm/{@radix-ui_react-use-escape-keydown@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-escape-keydown@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-escape-keydown/dist/index.cjs +1 -1
  37. package/dist/node_modules/.pnpm/{@radix-ui_react-use-escape-keydown@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-escape-keydown@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-escape-keydown/dist/index.mjs +1 -1
  38. package/dist/node_modules/.pnpm/{@radix-ui_react-use-size@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-size@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-size/dist/index.cjs +1 -1
  39. package/dist/node_modules/.pnpm/{@radix-ui_react-use-size@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-size@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-size/dist/index.mjs +1 -1
  40. package/dist/node_modules/.pnpm/{@radix-ui_react-visually-hidden@1.2.3_@types_react-dom@19.2.2_@types_react@19.2.2__@typ_a84e98a44624c31e835a98d4b8b0c30d → @radix-ui_react-visually-hidden@1.2.3_@types_react-dom@19.2.3_@types_react@19.2.6__@typ_f453379bbd5a4932ec515167f81be42a}/node_modules/@radix-ui/react-visually-hidden/dist/index.cjs +1 -1
  41. package/dist/node_modules/.pnpm/{@radix-ui_react-visually-hidden@1.2.3_@types_react-dom@19.2.2_@types_react@19.2.2__@typ_a84e98a44624c31e835a98d4b8b0c30d → @radix-ui_react-visually-hidden@1.2.3_@types_react-dom@19.2.3_@types_react@19.2.6__@typ_f453379bbd5a4932ec515167f81be42a}/node_modules/@radix-ui/react-visually-hidden/dist/index.mjs +1 -1
  42. package/dist/node_modules/.pnpm/{react-remove-scroll-bar@2.3.8_@types_react@19.2.2_react@19.2.0 → react-remove-scroll-bar@2.3.8_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll-bar/dist/es2015/component.cjs +1 -1
  43. package/dist/node_modules/.pnpm/{react-remove-scroll-bar@2.3.8_@types_react@19.2.2_react@19.2.0 → react-remove-scroll-bar@2.3.8_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll-bar/dist/es2015/component.mjs +1 -1
  44. package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/SideEffect.cjs +2 -2
  45. package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/SideEffect.mjs +2 -2
  46. package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/UI.cjs +2 -2
  47. package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/UI.mjs +2 -2
  48. package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/medium.cjs +1 -1
  49. package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/medium.mjs +1 -1
  50. package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0/node_modules/react-remove-scroll/dist/es2015/sidecar.cjs +9 -0
  51. package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/sidecar.mjs +1 -1
  52. package/dist/packages/better-stack/src/plugins/ai-chat/api/plugin.cjs +610 -0
  53. package/dist/packages/better-stack/src/plugins/ai-chat/api/plugin.mjs +608 -0
  54. package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-input.cjs +221 -0
  55. package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-input.mjs +219 -0
  56. package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-interface.cjs +341 -0
  57. package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-interface.mjs +339 -0
  58. package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-layout.cjs +135 -0
  59. package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-layout.mjs +133 -0
  60. package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-message.cjs +429 -0
  61. package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-message.mjs +423 -0
  62. package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-sidebar.cjs +227 -0
  63. package/dist/packages/better-stack/src/plugins/ai-chat/client/components/chat-sidebar.mjs +225 -0
  64. package/dist/packages/better-stack/src/plugins/ai-chat/client/components/loading/chat-page-skeleton.cjs +31 -0
  65. package/dist/packages/better-stack/src/plugins/ai-chat/client/components/loading/chat-page-skeleton.mjs +29 -0
  66. package/dist/packages/better-stack/src/plugins/ai-chat/client/components/loading/index.cjs +11 -0
  67. package/dist/packages/better-stack/src/plugins/ai-chat/client/components/loading/index.mjs +8 -0
  68. package/dist/packages/better-stack/src/plugins/ai-chat/client/components/pages/404-page.cjs +18 -0
  69. package/dist/packages/better-stack/src/plugins/ai-chat/client/components/pages/404-page.mjs +16 -0
  70. package/dist/packages/better-stack/src/plugins/ai-chat/client/components/pages/chat-page.cjs +39 -0
  71. package/dist/packages/better-stack/src/plugins/ai-chat/client/components/pages/chat-page.internal.cjs +22 -0
  72. package/dist/packages/better-stack/src/plugins/ai-chat/client/components/pages/chat-page.internal.mjs +20 -0
  73. package/dist/packages/better-stack/src/plugins/ai-chat/client/components/pages/chat-page.mjs +37 -0
  74. package/dist/packages/better-stack/src/plugins/ai-chat/client/components/shared/default-error.cjs +18 -0
  75. package/dist/packages/better-stack/src/plugins/ai-chat/client/components/shared/default-error.mjs +16 -0
  76. package/dist/packages/better-stack/src/plugins/ai-chat/client/components/shared/error-placeholder.cjs +26 -0
  77. package/dist/packages/better-stack/src/plugins/ai-chat/client/components/shared/error-placeholder.mjs +24 -0
  78. package/dist/packages/better-stack/src/plugins/ai-chat/client/components/tool-call-display.cjs +123 -0
  79. package/dist/packages/better-stack/src/plugins/ai-chat/client/components/tool-call-display.mjs +121 -0
  80. package/dist/packages/better-stack/src/plugins/ai-chat/client/hooks/chat-hooks.cjs +199 -0
  81. package/dist/packages/better-stack/src/plugins/ai-chat/client/hooks/chat-hooks.mjs +191 -0
  82. package/dist/packages/better-stack/src/plugins/ai-chat/client/localization/index.cjs +63 -0
  83. package/dist/packages/better-stack/src/plugins/ai-chat/client/localization/index.mjs +61 -0
  84. package/dist/packages/better-stack/src/plugins/ai-chat/client/overrides.cjs +14 -0
  85. package/dist/packages/better-stack/src/plugins/ai-chat/client/overrides.mjs +11 -0
  86. package/dist/packages/better-stack/src/plugins/ai-chat/client/plugin.cjs +241 -0
  87. package/dist/packages/better-stack/src/plugins/ai-chat/client/plugin.mjs +239 -0
  88. package/dist/packages/better-stack/src/plugins/ai-chat/db.cjs +65 -0
  89. package/dist/packages/better-stack/src/plugins/ai-chat/db.mjs +63 -0
  90. package/dist/packages/better-stack/src/plugins/ai-chat/schemas.cjs +42 -0
  91. package/dist/packages/better-stack/src/plugins/ai-chat/schemas.mjs +38 -0
  92. package/dist/packages/better-stack/src/plugins/blog/client/components/shared/markdown-content.cjs +12 -309
  93. package/dist/packages/better-stack/src/plugins/blog/client/components/shared/markdown-content.mjs +13 -303
  94. package/dist/packages/better-stack/src/plugins/blog/client/components/shared/page-wrapper.cjs +2 -2
  95. package/dist/packages/better-stack/src/plugins/blog/client/components/shared/page-wrapper.mjs +2 -2
  96. package/dist/packages/ui/src/components/accordion.cjs +67 -0
  97. package/dist/packages/ui/src/components/accordion.mjs +62 -0
  98. package/dist/packages/ui/src/components/alert-dialog.cjs +1 -1
  99. package/dist/packages/ui/src/components/alert-dialog.mjs +1 -1
  100. package/dist/packages/{better-stack/src/plugins/blog/client/components/shared/better-blog-attribution.cjs → ui/src/components/better-stack-attribution.cjs} +3 -3
  101. package/dist/packages/{better-stack/src/plugins/blog/client/components/shared/better-blog-attribution.mjs → ui/src/components/better-stack-attribution.mjs} +3 -3
  102. package/dist/packages/ui/src/components/dialog.cjs +14 -0
  103. package/dist/packages/ui/src/components/dialog.mjs +14 -1
  104. package/dist/packages/ui/src/components/dropdown-menu.cjs +67 -0
  105. package/dist/packages/ui/src/components/dropdown-menu.mjs +62 -0
  106. package/dist/packages/ui/src/components/markdown-content.cjs +306 -0
  107. package/dist/packages/ui/src/components/markdown-content.mjs +297 -0
  108. package/dist/packages/ui/src/components/scroll-area.cjs +63 -0
  109. package/dist/packages/ui/src/components/scroll-area.mjs +60 -0
  110. package/dist/packages/ui/src/components/select.cjs +1 -1
  111. package/dist/packages/ui/src/components/select.mjs +1 -1
  112. package/dist/packages/ui/src/components/sheet.cjs +87 -0
  113. package/dist/packages/ui/src/components/sheet.mjs +69 -0
  114. package/dist/plugins/ai-chat/api/index.cjs +9 -0
  115. package/dist/plugins/ai-chat/api/index.d.cts +9 -0
  116. package/dist/plugins/ai-chat/api/index.d.mts +9 -0
  117. package/dist/plugins/ai-chat/api/index.d.ts +9 -0
  118. package/dist/plugins/ai-chat/api/index.mjs +2 -0
  119. package/dist/plugins/ai-chat/client/components/index.cjs +29 -0
  120. package/dist/plugins/ai-chat/client/components/index.d.cts +30 -0
  121. package/dist/plugins/ai-chat/client/components/index.d.mts +30 -0
  122. package/dist/plugins/ai-chat/client/components/index.d.ts +30 -0
  123. package/dist/plugins/ai-chat/client/components/index.mjs +12 -0
  124. package/dist/plugins/ai-chat/client/hooks/index.cjs +13 -0
  125. package/dist/plugins/ai-chat/client/hooks/index.d.cts +98 -0
  126. package/dist/plugins/ai-chat/client/hooks/index.d.mts +98 -0
  127. package/dist/plugins/ai-chat/client/hooks/index.d.ts +98 -0
  128. package/dist/plugins/ai-chat/client/hooks/index.mjs +1 -0
  129. package/dist/plugins/ai-chat/client/index.cjs +21 -0
  130. package/dist/plugins/ai-chat/client/index.d.cts +156 -0
  131. package/dist/plugins/ai-chat/client/index.d.mts +156 -0
  132. package/dist/plugins/ai-chat/client/index.d.ts +156 -0
  133. package/dist/plugins/ai-chat/client/index.mjs +8 -0
  134. package/dist/plugins/ai-chat/client.css +6 -0
  135. package/dist/plugins/ai-chat/query-keys.cjs +60 -0
  136. package/dist/plugins/ai-chat/query-keys.d.cts +478 -0
  137. package/dist/plugins/ai-chat/query-keys.d.mts +478 -0
  138. package/dist/plugins/ai-chat/query-keys.d.ts +478 -0
  139. package/dist/plugins/ai-chat/query-keys.mjs +58 -0
  140. package/dist/plugins/ai-chat/style.css +19 -0
  141. package/dist/plugins/blog/api/index.d.cts +1 -1
  142. package/dist/plugins/blog/api/index.d.mts +1 -1
  143. package/dist/plugins/blog/api/index.d.ts +1 -1
  144. package/dist/plugins/blog/client/components/shared/markdown-content-styles.css +91 -62
  145. package/dist/plugins/blog/client/hooks/index.d.cts +4 -4
  146. package/dist/plugins/blog/client/hooks/index.d.mts +4 -4
  147. package/dist/plugins/blog/client/hooks/index.d.ts +4 -4
  148. package/dist/plugins/blog/client/index.d.cts +1 -1
  149. package/dist/plugins/blog/client/index.d.mts +1 -1
  150. package/dist/plugins/blog/client/index.d.ts +1 -1
  151. package/dist/plugins/blog/query-keys.d.cts +7 -7
  152. package/dist/plugins/blog/query-keys.d.mts +7 -7
  153. package/dist/plugins/blog/query-keys.d.ts +7 -7
  154. package/dist/shared/stack.Be1QIHEn.d.cts +23 -0
  155. package/dist/shared/stack.Be1QIHEn.d.mts +23 -0
  156. package/dist/shared/stack.Be1QIHEn.d.ts +23 -0
  157. package/dist/shared/stack.DaOcgmrM.d.cts +323 -0
  158. package/dist/shared/stack.DaOcgmrM.d.mts +323 -0
  159. package/dist/shared/stack.DaOcgmrM.d.ts +323 -0
  160. package/package.json +59 -1
  161. package/src/plugins/ai-chat/api/index.ts +2 -0
  162. package/src/plugins/ai-chat/api/plugin.ts +1083 -0
  163. package/src/plugins/ai-chat/client/components/chat-input.tsx +295 -0
  164. package/src/plugins/ai-chat/client/components/chat-interface.tsx +494 -0
  165. package/src/plugins/ai-chat/client/components/chat-layout.tsx +175 -0
  166. package/src/plugins/ai-chat/client/components/chat-message.tsx +561 -0
  167. package/src/plugins/ai-chat/client/components/chat-sidebar.tsx +296 -0
  168. package/src/plugins/ai-chat/client/components/index.ts +18 -0
  169. package/src/plugins/ai-chat/client/components/loading/chat-page-skeleton.tsx +57 -0
  170. package/src/plugins/ai-chat/client/components/loading/index.tsx +11 -0
  171. package/src/plugins/ai-chat/client/components/pages/404-page.tsx +27 -0
  172. package/src/plugins/ai-chat/client/components/pages/chat-page.internal.tsx +31 -0
  173. package/src/plugins/ai-chat/client/components/pages/chat-page.tsx +46 -0
  174. package/src/plugins/ai-chat/client/components/shared/default-error.tsx +28 -0
  175. package/src/plugins/ai-chat/client/components/shared/error-placeholder.tsx +22 -0
  176. package/src/plugins/ai-chat/client/components/tool-call-display.tsx +197 -0
  177. package/src/plugins/ai-chat/client/hooks/chat-hooks.tsx +349 -0
  178. package/src/plugins/ai-chat/client/hooks/index.tsx +1 -0
  179. package/src/plugins/ai-chat/client/index.ts +25 -0
  180. package/src/plugins/ai-chat/client/localization/index.ts +156 -0
  181. package/src/plugins/ai-chat/client/overrides.ts +241 -0
  182. package/src/plugins/ai-chat/client/plugin.tsx +449 -0
  183. package/src/plugins/ai-chat/client.css +6 -0
  184. package/src/plugins/ai-chat/db.ts +65 -0
  185. package/src/plugins/ai-chat/query-keys.ts +87 -0
  186. package/src/plugins/ai-chat/schemas.ts +40 -0
  187. package/src/plugins/ai-chat/style.css +19 -0
  188. package/src/plugins/ai-chat/types.ts +29 -0
  189. package/src/plugins/blog/client/components/shared/markdown-content-styles.css +91 -62
  190. package/src/plugins/blog/client/components/shared/markdown-content.tsx +19 -427
  191. package/src/plugins/blog/client/components/shared/page-wrapper.tsx +2 -2
  192. package/dist/node_modules/.pnpm/react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0/node_modules/react-remove-scroll/dist/es2015/sidecar.cjs +0 -9
  193. package/src/plugins/blog/client/components/shared/better-blog-attribution.tsx +0 -19
  194. package/dist/node_modules/.pnpm/{@radix-ui_react-compose-refs@1.1.2_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-compose-refs@1.1.2_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-compose-refs/dist/index.cjs +0 -0
  195. package/dist/node_modules/.pnpm/{@radix-ui_react-compose-refs@1.1.2_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-compose-refs@1.1.2_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-compose-refs/dist/index.mjs +0 -0
  196. package/dist/node_modules/.pnpm/{@radix-ui_react-context@1.1.2_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-context@1.1.2_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-context/dist/index.cjs +0 -0
  197. package/dist/node_modules/.pnpm/{@radix-ui_react-context@1.1.2_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-context@1.1.2_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-context/dist/index.mjs +0 -0
  198. package/dist/node_modules/.pnpm/{@radix-ui_react-direction@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-direction@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-direction/dist/index.cjs +0 -0
  199. package/dist/node_modules/.pnpm/{@radix-ui_react-direction@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-direction@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-direction/dist/index.mjs +0 -0
  200. package/dist/node_modules/.pnpm/{@radix-ui_react-focus-guards@1.1.3_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-focus-guards@1.1.3_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-focus-guards/dist/index.cjs +0 -0
  201. package/dist/node_modules/.pnpm/{@radix-ui_react-focus-guards@1.1.3_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-focus-guards@1.1.3_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-focus-guards/dist/index.mjs +0 -0
  202. package/dist/node_modules/.pnpm/{@radix-ui_react-primitive@2.1.3_@types_react-dom@19.2.2_@types_react@19.2.2__@types_rea_bdc15f10281778271ffcbe8dd3cd491e → @radix-ui_react-primitive@2.1.3_@types_react-dom@19.2.3_@types_react@19.2.6__@types_rea_a92a69cb1cb39305138539e4fa72f596}/node_modules/@radix-ui/react-primitive/dist/index.cjs +0 -0
  203. package/dist/node_modules/.pnpm/{@radix-ui_react-primitive@2.1.3_@types_react-dom@19.2.2_@types_react@19.2.2__@types_rea_bdc15f10281778271ffcbe8dd3cd491e → @radix-ui_react-primitive@2.1.3_@types_react-dom@19.2.3_@types_react@19.2.6__@types_rea_a92a69cb1cb39305138539e4fa72f596}/node_modules/@radix-ui/react-primitive/dist/index.mjs +0 -0
  204. package/dist/node_modules/.pnpm/{@radix-ui_react-use-callback-ref@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-callback-ref@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-callback-ref/dist/index.cjs +0 -0
  205. package/dist/node_modules/.pnpm/{@radix-ui_react-use-callback-ref@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-callback-ref@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-callback-ref/dist/index.mjs +0 -0
  206. package/dist/node_modules/.pnpm/{@radix-ui_react-use-layout-effect@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-layout-effect@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-layout-effect/dist/index.cjs +0 -0
  207. package/dist/node_modules/.pnpm/{@radix-ui_react-use-layout-effect@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-layout-effect@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-layout-effect/dist/index.mjs +0 -0
  208. package/dist/node_modules/.pnpm/{@radix-ui_react-use-previous@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-previous@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-previous/dist/index.cjs +0 -0
  209. package/dist/node_modules/.pnpm/{@radix-ui_react-use-previous@1.1.1_@types_react@19.2.2_react@19.2.0 → @radix-ui_react-use-previous@1.1.1_@types_react@19.2.6_react@19.2.0}/node_modules/@radix-ui/react-use-previous/dist/index.mjs +0 -0
  210. package/dist/node_modules/.pnpm/{react-remove-scroll-bar@2.3.8_@types_react@19.2.2_react@19.2.0 → react-remove-scroll-bar@2.3.8_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll-bar/dist/es2015/constants.cjs +0 -0
  211. package/dist/node_modules/.pnpm/{react-remove-scroll-bar@2.3.8_@types_react@19.2.2_react@19.2.0 → react-remove-scroll-bar@2.3.8_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll-bar/dist/es2015/constants.mjs +0 -0
  212. package/dist/node_modules/.pnpm/{react-remove-scroll-bar@2.3.8_@types_react@19.2.2_react@19.2.0 → react-remove-scroll-bar@2.3.8_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll-bar/dist/es2015/utils.cjs +0 -0
  213. package/dist/node_modules/.pnpm/{react-remove-scroll-bar@2.3.8_@types_react@19.2.2_react@19.2.0 → react-remove-scroll-bar@2.3.8_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll-bar/dist/es2015/utils.mjs +0 -0
  214. package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/Combination.cjs +0 -0
  215. package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/Combination.mjs +0 -0
  216. package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.cjs +0 -0
  217. package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.mjs +0 -0
  218. package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/handleScroll.cjs +0 -0
  219. package/dist/node_modules/.pnpm/{react-remove-scroll@2.7.1_@types_react@19.2.2_react@19.2.0 → react-remove-scroll@2.7.1_@types_react@19.2.6_react@19.2.0}/node_modules/react-remove-scroll/dist/es2015/handleScroll.mjs +0 -0
  220. package/dist/node_modules/.pnpm/{react-style-singleton@2.2.3_@types_react@19.2.2_react@19.2.0 → react-style-singleton@2.2.3_@types_react@19.2.6_react@19.2.0}/node_modules/react-style-singleton/dist/es2015/component.cjs +0 -0
  221. package/dist/node_modules/.pnpm/{react-style-singleton@2.2.3_@types_react@19.2.2_react@19.2.0 → react-style-singleton@2.2.3_@types_react@19.2.6_react@19.2.0}/node_modules/react-style-singleton/dist/es2015/component.mjs +0 -0
  222. package/dist/node_modules/.pnpm/{react-style-singleton@2.2.3_@types_react@19.2.2_react@19.2.0 → react-style-singleton@2.2.3_@types_react@19.2.6_react@19.2.0}/node_modules/react-style-singleton/dist/es2015/hook.cjs +0 -0
  223. package/dist/node_modules/.pnpm/{react-style-singleton@2.2.3_@types_react@19.2.2_react@19.2.0 → react-style-singleton@2.2.3_@types_react@19.2.6_react@19.2.0}/node_modules/react-style-singleton/dist/es2015/hook.mjs +0 -0
  224. package/dist/node_modules/.pnpm/{react-style-singleton@2.2.3_@types_react@19.2.2_react@19.2.0 → react-style-singleton@2.2.3_@types_react@19.2.6_react@19.2.0}/node_modules/react-style-singleton/dist/es2015/singleton.cjs +0 -0
  225. package/dist/node_modules/.pnpm/{react-style-singleton@2.2.3_@types_react@19.2.2_react@19.2.0 → react-style-singleton@2.2.3_@types_react@19.2.6_react@19.2.0}/node_modules/react-style-singleton/dist/es2015/singleton.mjs +0 -0
  226. package/dist/node_modules/.pnpm/{use-callback-ref@1.3.3_@types_react@19.2.2_react@19.2.0 → use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-callback-ref/dist/es2015/assignRef.cjs +0 -0
  227. package/dist/node_modules/.pnpm/{use-callback-ref@1.3.3_@types_react@19.2.2_react@19.2.0 → use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-callback-ref/dist/es2015/assignRef.mjs +0 -0
  228. package/dist/node_modules/.pnpm/{use-callback-ref@1.3.3_@types_react@19.2.2_react@19.2.0 → use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-callback-ref/dist/es2015/useMergeRef.cjs +0 -0
  229. package/dist/node_modules/.pnpm/{use-callback-ref@1.3.3_@types_react@19.2.2_react@19.2.0 → use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-callback-ref/dist/es2015/useMergeRef.mjs +0 -0
  230. package/dist/node_modules/.pnpm/{use-callback-ref@1.3.3_@types_react@19.2.2_react@19.2.0 → use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-callback-ref/dist/es2015/useRef.cjs +0 -0
  231. package/dist/node_modules/.pnpm/{use-callback-ref@1.3.3_@types_react@19.2.2_react@19.2.0 → use-callback-ref@1.3.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-callback-ref/dist/es2015/useRef.mjs +0 -0
  232. package/dist/node_modules/.pnpm/{use-sidecar@1.1.3_@types_react@19.2.2_react@19.2.0 → use-sidecar@1.1.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-sidecar/dist/es2015/exports.cjs +0 -0
  233. package/dist/node_modules/.pnpm/{use-sidecar@1.1.3_@types_react@19.2.2_react@19.2.0 → use-sidecar@1.1.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-sidecar/dist/es2015/exports.mjs +0 -0
  234. package/dist/node_modules/.pnpm/{use-sidecar@1.1.3_@types_react@19.2.2_react@19.2.0 → use-sidecar@1.1.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-sidecar/dist/es2015/medium.cjs +0 -0
  235. package/dist/node_modules/.pnpm/{use-sidecar@1.1.3_@types_react@19.2.2_react@19.2.0 → use-sidecar@1.1.3_@types_react@19.2.6_react@19.2.0}/node_modules/use-sidecar/dist/es2015/medium.mjs +0 -0
  236. package/dist/shared/{stack.CbuN2zVV.d.ts → stack.CcI4sYJP.d.cts} +3 -3
  237. package/dist/shared/{stack.CbuN2zVV.d.cts → stack.CcI4sYJP.d.mts} +3 -3
  238. package/dist/shared/{stack.CbuN2zVV.d.mts → stack.CcI4sYJP.d.ts} +3 -3
@@ -0,0 +1,341 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ const jsxRuntime = require('react/jsx-runtime');
5
+ const react = require('@ai-sdk/react');
6
+ const React = require('react');
7
+ const reactQuery = require('@tanstack/react-query');
8
+ const chatMessage = require('./chat-message.cjs');
9
+ const chatInput = require('./chat-input.cjs');
10
+ const betterStackAttribution = require('../../../../../../ui/src/components/better-stack-attribution.cjs');
11
+ const scrollArea = require('../../../../../../ui/src/components/scroll-area.cjs');
12
+ const ai = require('ai');
13
+ const utils = require('../../../../../../ui/src/lib/utils.cjs');
14
+ const context = require('@btst/stack/context');
15
+ const index = require('../localization/index.cjs');
16
+ const client = require('@btst/stack/plugins/client');
17
+ const plugins_aiChat_queryKeys = require('../../../../../../../plugins/ai-chat/query-keys.cjs');
18
+ const chatHooks = require('../hooks/chat-hooks.cjs');
19
+
20
+ function ChatInterface({
21
+ apiPath = "/api/chat",
22
+ initialMessages,
23
+ id,
24
+ variant = "full",
25
+ className,
26
+ onMessagesChange
27
+ }) {
28
+ const {
29
+ navigate,
30
+ localization: customLocalization,
31
+ apiBaseURL,
32
+ apiBasePath,
33
+ headers,
34
+ mode,
35
+ showAttribution,
36
+ chatSuggestions
37
+ } = context.usePluginOverrides(
38
+ "ai-chat",
39
+ { showAttribution: true }
40
+ );
41
+ const basePath = context.useBasePath();
42
+ const isPublicMode = mode === "public";
43
+ const localization = { ...index.AI_CHAT_LOCALIZATION, ...customLocalization };
44
+ const queryClient = reactQuery.useQueryClient();
45
+ const conversationsListQueryKey = React.useMemo(() => {
46
+ if (isPublicMode) return ["ai-chat", "disabled"];
47
+ const client$1 = client.createApiClient({
48
+ baseURL: apiBaseURL,
49
+ basePath: apiBasePath
50
+ });
51
+ const queries = plugins_aiChat_queryKeys.createAiChatQueryKeys(client$1, headers);
52
+ return queries.conversations.list().queryKey;
53
+ }, [apiBaseURL, apiBasePath, headers, isPublicMode]);
54
+ const [currentConversationId, setCurrentConversationId] = React.useState(isPublicMode ? void 0 : id);
55
+ const isFirstMessageSentRef = React.useRef(false);
56
+ const hasNavigatedRef = React.useRef(false);
57
+ React.useEffect(() => {
58
+ if (!isPublicMode) {
59
+ setCurrentConversationId(id);
60
+ isFirstMessageSentRef.current = false;
61
+ hasNavigatedRef.current = false;
62
+ }
63
+ }, [id, isPublicMode]);
64
+ const { conversation, isLoading: isLoadingConversation } = chatHooks.useConversation(
65
+ id,
66
+ { enabled: !!id && !isPublicMode }
67
+ );
68
+ const { conversations } = chatHooks.useConversations({ enabled: !isPublicMode });
69
+ const conversationIdRef = React.useRef(
70
+ isPublicMode ? void 0 : id
71
+ );
72
+ React.useEffect(() => {
73
+ if (!isPublicMode) {
74
+ conversationIdRef.current = currentConversationId;
75
+ }
76
+ }, [currentConversationId, isPublicMode]);
77
+ const editMessagesRef = React.useRef(null);
78
+ const [isMessagesInitialized, setIsMessagesInitialized] = React.useState(
79
+ () => (
80
+ // Start as initialized if there are no initialMessages to load
81
+ !initialMessages || initialMessages.length === 0
82
+ )
83
+ );
84
+ const transport = React.useMemo(
85
+ () => new ai.DefaultChatTransport({
86
+ api: apiPath,
87
+ // In public mode, don't send conversationId
88
+ body: isPublicMode ? void 0 : () => ({ conversationId: conversationIdRef.current }),
89
+ // Handle edit operations by using truncated messages from the ref
90
+ prepareSendMessagesRequest: ({ messages: hookMessages }) => {
91
+ if (editMessagesRef.current !== null) {
92
+ const newUserMessage = hookMessages[hookMessages.length - 1];
93
+ const messagesToSend = [...editMessagesRef.current];
94
+ if (newUserMessage) {
95
+ messagesToSend.push(newUserMessage);
96
+ }
97
+ editMessagesRef.current = null;
98
+ return {
99
+ body: {
100
+ messages: messagesToSend,
101
+ conversationId: conversationIdRef.current
102
+ }
103
+ };
104
+ }
105
+ return {
106
+ body: {
107
+ messages: hookMessages,
108
+ conversationId: conversationIdRef.current
109
+ }
110
+ };
111
+ }
112
+ }),
113
+ [apiPath, isPublicMode]
114
+ );
115
+ const { messages, sendMessage, status, error, setMessages, regenerate } = react.useChat({
116
+ transport,
117
+ onError: (err) => {
118
+ console.error("useChat onError:", err);
119
+ },
120
+ onFinish: async () => {
121
+ if (isPublicMode) return;
122
+ await queryClient.invalidateQueries({
123
+ queryKey: conversationsListQueryKey
124
+ });
125
+ if (isFirstMessageSentRef.current && !id && !hasNavigatedRef.current) {
126
+ hasNavigatedRef.current = true;
127
+ await queryClient.refetchQueries({
128
+ queryKey: conversationsListQueryKey
129
+ });
130
+ const cachedConversations = queryClient.getQueryData(conversationsListQueryKey);
131
+ if (cachedConversations && cachedConversations.length > 0) {
132
+ const newConversation = cachedConversations[0];
133
+ if (newConversation) {
134
+ setCurrentConversationId(newConversation.id);
135
+ conversationIdRef.current = newConversation.id;
136
+ const newUrl = `${basePath}/chat/${newConversation.id}`;
137
+ if (typeof window !== "undefined") {
138
+ window.history.replaceState(
139
+ { ...window.history.state },
140
+ "",
141
+ newUrl
142
+ );
143
+ }
144
+ }
145
+ }
146
+ }
147
+ }
148
+ });
149
+ React.useEffect(() => {
150
+ if (conversation?.messages && conversation.messages.length > 0 && messages.length === 0) {
151
+ const uiMessages = conversation.messages.filter((m) => m.role !== "data").map((m) => {
152
+ let parts;
153
+ try {
154
+ const parsed = JSON.parse(m.content);
155
+ if (Array.isArray(parsed)) {
156
+ parts = parsed;
157
+ } else {
158
+ parts = [{ type: "text", text: m.content }];
159
+ }
160
+ } catch {
161
+ parts = [{ type: "text", text: m.content }];
162
+ }
163
+ return {
164
+ id: m.id,
165
+ role: m.role,
166
+ parts
167
+ };
168
+ });
169
+ setMessages(uiMessages);
170
+ }
171
+ }, [conversation, messages.length, setMessages]);
172
+ React.useEffect(() => {
173
+ if (initialMessages && initialMessages.length > 0 && messages.length === 0) {
174
+ setMessages(initialMessages);
175
+ setIsMessagesInitialized(true);
176
+ }
177
+ }, [initialMessages, setMessages, messages.length]);
178
+ const [input, setInput] = React.useState("");
179
+ const [attachedFiles, setAttachedFiles] = React.useState([]);
180
+ const scrollRef = React.useRef(null);
181
+ React.useEffect(() => {
182
+ if (scrollRef.current) {
183
+ const scrollElement = scrollRef.current.querySelector(
184
+ "[data-radix-scroll-area-viewport]"
185
+ );
186
+ if (scrollElement) {
187
+ scrollElement.scrollTop = scrollElement.scrollHeight;
188
+ }
189
+ }
190
+ }, [messages]);
191
+ React.useEffect(() => {
192
+ if (isPublicMode && onMessagesChange && isMessagesInitialized) {
193
+ onMessagesChange(messages);
194
+ }
195
+ }, [messages, isPublicMode, onMessagesChange, isMessagesInitialized]);
196
+ const handleInputChange = (e) => {
197
+ setInput(e.target.value);
198
+ };
199
+ const handleSubmit = async (e, files) => {
200
+ e.preventDefault();
201
+ const text = input.trim();
202
+ if (!text && (!files || files.length === 0)) return;
203
+ if (!isPublicMode && !id && messages.length === 0) {
204
+ isFirstMessageSentRef.current = true;
205
+ }
206
+ const savedInput = input;
207
+ const savedFiles = files ? [...files] : [];
208
+ setInput("");
209
+ setAttachedFiles([]);
210
+ try {
211
+ if (files && files.length > 0) {
212
+ const fileUIParts = files.map((file) => ({
213
+ type: "file",
214
+ mediaType: file.mediaType,
215
+ url: file.url,
216
+ filename: file.filename
217
+ }));
218
+ await sendMessage({
219
+ text: text || "",
220
+ // AI SDK requires text, even if empty
221
+ files: fileUIParts
222
+ });
223
+ } else {
224
+ await sendMessage({ text });
225
+ }
226
+ } catch (error2) {
227
+ setInput(savedInput);
228
+ setAttachedFiles(savedFiles);
229
+ console.error("Error sending message:", error2);
230
+ }
231
+ };
232
+ const isLoading = status === "streaming" || status === "submitted";
233
+ const handleRetry = React.useCallback(() => {
234
+ regenerate();
235
+ }, [regenerate]);
236
+ const [pendingEdit, setPendingEdit] = React.useState(null);
237
+ React.useEffect(() => {
238
+ if (pendingEdit && messages.length === pendingEdit.expectedLength) {
239
+ const textToSend = pendingEdit.text;
240
+ setPendingEdit(null);
241
+ sendMessage({ text: textToSend });
242
+ }
243
+ }, [messages.length, pendingEdit, sendMessage]);
244
+ const handleEditMessage = React.useCallback(
245
+ (messageId, newText) => {
246
+ const messageIndex = messages.findIndex((m) => m.id === messageId);
247
+ if (messageIndex === -1) return;
248
+ const messageToEdit = messages[messageIndex];
249
+ if (!messageToEdit || messageToEdit.role !== "user") return;
250
+ const truncatedMessages = messages.slice(0, messageIndex);
251
+ editMessagesRef.current = truncatedMessages;
252
+ setPendingEdit({ text: newText, expectedLength: messageIndex });
253
+ setMessages(truncatedMessages);
254
+ },
255
+ [messages, setMessages]
256
+ );
257
+ const isWidget = variant === "widget";
258
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
259
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
260
+ "div",
261
+ {
262
+ className: utils.cn(
263
+ "flex flex-col h-full w-full bg-background",
264
+ isWidget && "rounded-xl",
265
+ className
266
+ ),
267
+ "data-testid": "chat-interface",
268
+ children: /* @__PURE__ */ jsxRuntime.jsx(scrollArea.ScrollArea, { ref: scrollRef, className: "flex-1 h-full", children: /* @__PURE__ */ jsxRuntime.jsxs(
269
+ "div",
270
+ {
271
+ className: utils.cn(
272
+ "flex flex-col p-4",
273
+ isWidget ? "max-w-full" : "max-w-3xl mx-auto w-full"
274
+ ),
275
+ children: [
276
+ messages.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col h-full min-h-[300px]", children: [
277
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 flex items-center justify-center text-muted-foreground", children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: localization.CHAT_EMPTY_STATE }) }),
278
+ chatSuggestions && chatSuggestions.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap justify-center gap-2 pb-4 max-w-md mx-auto", children: chatSuggestions.map((suggestion, index) => /* @__PURE__ */ jsxRuntime.jsx(
279
+ "button",
280
+ {
281
+ type: "button",
282
+ onClick: () => setInput(suggestion),
283
+ className: "px-3 py-2 text-sm rounded-lg border border-border bg-background hover:bg-accent hover:text-accent-foreground transition-colors text-foreground",
284
+ children: suggestion
285
+ },
286
+ index
287
+ )) })
288
+ ] }) : messages.map((m, index) => /* @__PURE__ */ jsxRuntime.jsx(
289
+ chatMessage.ChatMessage,
290
+ {
291
+ message: m,
292
+ isStreaming: status === "streaming" && m.id === messages[messages.length - 1]?.id && m.role === "assistant",
293
+ variant: isWidget ? "compact" : "default",
294
+ onRetry: (
295
+ // Only show retry on the last assistant message
296
+ m.role === "assistant" && index === messages.length - 1 ? handleRetry : void 0
297
+ ),
298
+ onEdit: (
299
+ // Allow editing user messages
300
+ m.role === "user" ? (newText) => handleEditMessage(m.id, newText) : void 0
301
+ ),
302
+ isRetrying: isLoading && m.role === "assistant"
303
+ },
304
+ m.id || `msg-${index}`
305
+ )),
306
+ isLoading && messages[messages.length - 1]?.role !== "assistant" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2 text-muted-foreground text-sm py-4", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "animate-pulse", children: localization.CHAT_LOADING }) }),
307
+ error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2 text-destructive text-sm py-4 px-3 bg-destructive/10 rounded-md", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: localization.CHAT_ERROR }) })
308
+ ]
309
+ }
310
+ ) })
311
+ }
312
+ ) }),
313
+ /* @__PURE__ */ jsxRuntime.jsx(
314
+ "div",
315
+ {
316
+ className: utils.cn(
317
+ "border-t bg-background p-4",
318
+ isWidget ? "px-3 py-3" : "px-4"
319
+ ),
320
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: utils.cn(!isWidget && "max-w-3xl mx-auto"), children: [
321
+ /* @__PURE__ */ jsxRuntime.jsx(
322
+ chatInput.ChatInput,
323
+ {
324
+ input,
325
+ handleInputChange,
326
+ handleSubmit,
327
+ isLoading,
328
+ placeholder: localization.CHAT_PLACEHOLDER,
329
+ variant: isWidget ? "compact" : "default",
330
+ onFilesAttached: setAttachedFiles,
331
+ attachedFiles
332
+ }
333
+ ),
334
+ showAttribution && /* @__PURE__ */ jsxRuntime.jsx(betterStackAttribution.BetterStackAttribution, {})
335
+ ] })
336
+ }
337
+ )
338
+ ] });
339
+ }
340
+
341
+ exports.ChatInterface = ChatInterface;
@@ -0,0 +1,339 @@
1
+ "use client";
2
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
+ import { useChat } from '@ai-sdk/react';
4
+ import { useMemo, useState, useRef, useEffect, useCallback } from 'react';
5
+ import { useQueryClient } from '@tanstack/react-query';
6
+ import { ChatMessage } from './chat-message.mjs';
7
+ import { ChatInput } from './chat-input.mjs';
8
+ import { BetterStackAttribution } from '../../../../../../ui/src/components/better-stack-attribution.mjs';
9
+ import { ScrollArea } from '../../../../../../ui/src/components/scroll-area.mjs';
10
+ import { DefaultChatTransport } from 'ai';
11
+ import { cn } from '../../../../../../ui/src/lib/utils.mjs';
12
+ import { usePluginOverrides, useBasePath } from '@btst/stack/context';
13
+ import { AI_CHAT_LOCALIZATION } from '../localization/index.mjs';
14
+ import { createApiClient } from '@btst/stack/plugins/client';
15
+ import { createAiChatQueryKeys } from '../../../../../../../plugins/ai-chat/query-keys.mjs';
16
+ import { useConversation, useConversations } from '../hooks/chat-hooks.mjs';
17
+
18
+ function ChatInterface({
19
+ apiPath = "/api/chat",
20
+ initialMessages,
21
+ id,
22
+ variant = "full",
23
+ className,
24
+ onMessagesChange
25
+ }) {
26
+ const {
27
+ navigate,
28
+ localization: customLocalization,
29
+ apiBaseURL,
30
+ apiBasePath,
31
+ headers,
32
+ mode,
33
+ showAttribution,
34
+ chatSuggestions
35
+ } = usePluginOverrides(
36
+ "ai-chat",
37
+ { showAttribution: true }
38
+ );
39
+ const basePath = useBasePath();
40
+ const isPublicMode = mode === "public";
41
+ const localization = { ...AI_CHAT_LOCALIZATION, ...customLocalization };
42
+ const queryClient = useQueryClient();
43
+ const conversationsListQueryKey = useMemo(() => {
44
+ if (isPublicMode) return ["ai-chat", "disabled"];
45
+ const client = createApiClient({
46
+ baseURL: apiBaseURL,
47
+ basePath: apiBasePath
48
+ });
49
+ const queries = createAiChatQueryKeys(client, headers);
50
+ return queries.conversations.list().queryKey;
51
+ }, [apiBaseURL, apiBasePath, headers, isPublicMode]);
52
+ const [currentConversationId, setCurrentConversationId] = useState(isPublicMode ? void 0 : id);
53
+ const isFirstMessageSentRef = useRef(false);
54
+ const hasNavigatedRef = useRef(false);
55
+ useEffect(() => {
56
+ if (!isPublicMode) {
57
+ setCurrentConversationId(id);
58
+ isFirstMessageSentRef.current = false;
59
+ hasNavigatedRef.current = false;
60
+ }
61
+ }, [id, isPublicMode]);
62
+ const { conversation, isLoading: isLoadingConversation } = useConversation(
63
+ id,
64
+ { enabled: !!id && !isPublicMode }
65
+ );
66
+ const { conversations } = useConversations({ enabled: !isPublicMode });
67
+ const conversationIdRef = useRef(
68
+ isPublicMode ? void 0 : id
69
+ );
70
+ useEffect(() => {
71
+ if (!isPublicMode) {
72
+ conversationIdRef.current = currentConversationId;
73
+ }
74
+ }, [currentConversationId, isPublicMode]);
75
+ const editMessagesRef = useRef(null);
76
+ const [isMessagesInitialized, setIsMessagesInitialized] = useState(
77
+ () => (
78
+ // Start as initialized if there are no initialMessages to load
79
+ !initialMessages || initialMessages.length === 0
80
+ )
81
+ );
82
+ const transport = useMemo(
83
+ () => new DefaultChatTransport({
84
+ api: apiPath,
85
+ // In public mode, don't send conversationId
86
+ body: isPublicMode ? void 0 : () => ({ conversationId: conversationIdRef.current }),
87
+ // Handle edit operations by using truncated messages from the ref
88
+ prepareSendMessagesRequest: ({ messages: hookMessages }) => {
89
+ if (editMessagesRef.current !== null) {
90
+ const newUserMessage = hookMessages[hookMessages.length - 1];
91
+ const messagesToSend = [...editMessagesRef.current];
92
+ if (newUserMessage) {
93
+ messagesToSend.push(newUserMessage);
94
+ }
95
+ editMessagesRef.current = null;
96
+ return {
97
+ body: {
98
+ messages: messagesToSend,
99
+ conversationId: conversationIdRef.current
100
+ }
101
+ };
102
+ }
103
+ return {
104
+ body: {
105
+ messages: hookMessages,
106
+ conversationId: conversationIdRef.current
107
+ }
108
+ };
109
+ }
110
+ }),
111
+ [apiPath, isPublicMode]
112
+ );
113
+ const { messages, sendMessage, status, error, setMessages, regenerate } = useChat({
114
+ transport,
115
+ onError: (err) => {
116
+ console.error("useChat onError:", err);
117
+ },
118
+ onFinish: async () => {
119
+ if (isPublicMode) return;
120
+ await queryClient.invalidateQueries({
121
+ queryKey: conversationsListQueryKey
122
+ });
123
+ if (isFirstMessageSentRef.current && !id && !hasNavigatedRef.current) {
124
+ hasNavigatedRef.current = true;
125
+ await queryClient.refetchQueries({
126
+ queryKey: conversationsListQueryKey
127
+ });
128
+ const cachedConversations = queryClient.getQueryData(conversationsListQueryKey);
129
+ if (cachedConversations && cachedConversations.length > 0) {
130
+ const newConversation = cachedConversations[0];
131
+ if (newConversation) {
132
+ setCurrentConversationId(newConversation.id);
133
+ conversationIdRef.current = newConversation.id;
134
+ const newUrl = `${basePath}/chat/${newConversation.id}`;
135
+ if (typeof window !== "undefined") {
136
+ window.history.replaceState(
137
+ { ...window.history.state },
138
+ "",
139
+ newUrl
140
+ );
141
+ }
142
+ }
143
+ }
144
+ }
145
+ }
146
+ });
147
+ useEffect(() => {
148
+ if (conversation?.messages && conversation.messages.length > 0 && messages.length === 0) {
149
+ const uiMessages = conversation.messages.filter((m) => m.role !== "data").map((m) => {
150
+ let parts;
151
+ try {
152
+ const parsed = JSON.parse(m.content);
153
+ if (Array.isArray(parsed)) {
154
+ parts = parsed;
155
+ } else {
156
+ parts = [{ type: "text", text: m.content }];
157
+ }
158
+ } catch {
159
+ parts = [{ type: "text", text: m.content }];
160
+ }
161
+ return {
162
+ id: m.id,
163
+ role: m.role,
164
+ parts
165
+ };
166
+ });
167
+ setMessages(uiMessages);
168
+ }
169
+ }, [conversation, messages.length, setMessages]);
170
+ useEffect(() => {
171
+ if (initialMessages && initialMessages.length > 0 && messages.length === 0) {
172
+ setMessages(initialMessages);
173
+ setIsMessagesInitialized(true);
174
+ }
175
+ }, [initialMessages, setMessages, messages.length]);
176
+ const [input, setInput] = useState("");
177
+ const [attachedFiles, setAttachedFiles] = useState([]);
178
+ const scrollRef = useRef(null);
179
+ useEffect(() => {
180
+ if (scrollRef.current) {
181
+ const scrollElement = scrollRef.current.querySelector(
182
+ "[data-radix-scroll-area-viewport]"
183
+ );
184
+ if (scrollElement) {
185
+ scrollElement.scrollTop = scrollElement.scrollHeight;
186
+ }
187
+ }
188
+ }, [messages]);
189
+ useEffect(() => {
190
+ if (isPublicMode && onMessagesChange && isMessagesInitialized) {
191
+ onMessagesChange(messages);
192
+ }
193
+ }, [messages, isPublicMode, onMessagesChange, isMessagesInitialized]);
194
+ const handleInputChange = (e) => {
195
+ setInput(e.target.value);
196
+ };
197
+ const handleSubmit = async (e, files) => {
198
+ e.preventDefault();
199
+ const text = input.trim();
200
+ if (!text && (!files || files.length === 0)) return;
201
+ if (!isPublicMode && !id && messages.length === 0) {
202
+ isFirstMessageSentRef.current = true;
203
+ }
204
+ const savedInput = input;
205
+ const savedFiles = files ? [...files] : [];
206
+ setInput("");
207
+ setAttachedFiles([]);
208
+ try {
209
+ if (files && files.length > 0) {
210
+ const fileUIParts = files.map((file) => ({
211
+ type: "file",
212
+ mediaType: file.mediaType,
213
+ url: file.url,
214
+ filename: file.filename
215
+ }));
216
+ await sendMessage({
217
+ text: text || "",
218
+ // AI SDK requires text, even if empty
219
+ files: fileUIParts
220
+ });
221
+ } else {
222
+ await sendMessage({ text });
223
+ }
224
+ } catch (error2) {
225
+ setInput(savedInput);
226
+ setAttachedFiles(savedFiles);
227
+ console.error("Error sending message:", error2);
228
+ }
229
+ };
230
+ const isLoading = status === "streaming" || status === "submitted";
231
+ const handleRetry = useCallback(() => {
232
+ regenerate();
233
+ }, [regenerate]);
234
+ const [pendingEdit, setPendingEdit] = useState(null);
235
+ useEffect(() => {
236
+ if (pendingEdit && messages.length === pendingEdit.expectedLength) {
237
+ const textToSend = pendingEdit.text;
238
+ setPendingEdit(null);
239
+ sendMessage({ text: textToSend });
240
+ }
241
+ }, [messages.length, pendingEdit, sendMessage]);
242
+ const handleEditMessage = useCallback(
243
+ (messageId, newText) => {
244
+ const messageIndex = messages.findIndex((m) => m.id === messageId);
245
+ if (messageIndex === -1) return;
246
+ const messageToEdit = messages[messageIndex];
247
+ if (!messageToEdit || messageToEdit.role !== "user") return;
248
+ const truncatedMessages = messages.slice(0, messageIndex);
249
+ editMessagesRef.current = truncatedMessages;
250
+ setPendingEdit({ text: newText, expectedLength: messageIndex });
251
+ setMessages(truncatedMessages);
252
+ },
253
+ [messages, setMessages]
254
+ );
255
+ const isWidget = variant === "widget";
256
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
257
+ /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(
258
+ "div",
259
+ {
260
+ className: cn(
261
+ "flex flex-col h-full w-full bg-background",
262
+ isWidget && "rounded-xl",
263
+ className
264
+ ),
265
+ "data-testid": "chat-interface",
266
+ children: /* @__PURE__ */ jsx(ScrollArea, { ref: scrollRef, className: "flex-1 h-full", children: /* @__PURE__ */ jsxs(
267
+ "div",
268
+ {
269
+ className: cn(
270
+ "flex flex-col p-4",
271
+ isWidget ? "max-w-full" : "max-w-3xl mx-auto w-full"
272
+ ),
273
+ children: [
274
+ messages.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full min-h-[300px]", children: [
275
+ /* @__PURE__ */ jsx("div", { className: "flex-1 flex items-center justify-center text-muted-foreground", children: /* @__PURE__ */ jsx("p", { children: localization.CHAT_EMPTY_STATE }) }),
276
+ chatSuggestions && chatSuggestions.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap justify-center gap-2 pb-4 max-w-md mx-auto", children: chatSuggestions.map((suggestion, index) => /* @__PURE__ */ jsx(
277
+ "button",
278
+ {
279
+ type: "button",
280
+ onClick: () => setInput(suggestion),
281
+ className: "px-3 py-2 text-sm rounded-lg border border-border bg-background hover:bg-accent hover:text-accent-foreground transition-colors text-foreground",
282
+ children: suggestion
283
+ },
284
+ index
285
+ )) })
286
+ ] }) : messages.map((m, index) => /* @__PURE__ */ jsx(
287
+ ChatMessage,
288
+ {
289
+ message: m,
290
+ isStreaming: status === "streaming" && m.id === messages[messages.length - 1]?.id && m.role === "assistant",
291
+ variant: isWidget ? "compact" : "default",
292
+ onRetry: (
293
+ // Only show retry on the last assistant message
294
+ m.role === "assistant" && index === messages.length - 1 ? handleRetry : void 0
295
+ ),
296
+ onEdit: (
297
+ // Allow editing user messages
298
+ m.role === "user" ? (newText) => handleEditMessage(m.id, newText) : void 0
299
+ ),
300
+ isRetrying: isLoading && m.role === "assistant"
301
+ },
302
+ m.id || `msg-${index}`
303
+ )),
304
+ isLoading && messages[messages.length - 1]?.role !== "assistant" && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 text-muted-foreground text-sm py-4", children: /* @__PURE__ */ jsx("div", { className: "animate-pulse", children: localization.CHAT_LOADING }) }),
305
+ error && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 text-destructive text-sm py-4 px-3 bg-destructive/10 rounded-md", children: /* @__PURE__ */ jsx("span", { children: localization.CHAT_ERROR }) })
306
+ ]
307
+ }
308
+ ) })
309
+ }
310
+ ) }),
311
+ /* @__PURE__ */ jsx(
312
+ "div",
313
+ {
314
+ className: cn(
315
+ "border-t bg-background p-4",
316
+ isWidget ? "px-3 py-3" : "px-4"
317
+ ),
318
+ children: /* @__PURE__ */ jsxs("div", { className: cn(!isWidget && "max-w-3xl mx-auto"), children: [
319
+ /* @__PURE__ */ jsx(
320
+ ChatInput,
321
+ {
322
+ input,
323
+ handleInputChange,
324
+ handleSubmit,
325
+ isLoading,
326
+ placeholder: localization.CHAT_PLACEHOLDER,
327
+ variant: isWidget ? "compact" : "default",
328
+ onFilesAttached: setAttachedFiles,
329
+ attachedFiles
330
+ }
331
+ ),
332
+ showAttribution && /* @__PURE__ */ jsx(BetterStackAttribution, {})
333
+ ] })
334
+ }
335
+ )
336
+ ] });
337
+ }
338
+
339
+ export { ChatInterface };