@envive-ai/react-widgets 0.1.1 → 0.1.2-arthur-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 (42) hide show
  1. package/dist/SearchResults/index-D8nrHueo.d.ts +6 -0
  2. package/dist/{index.cjs → SearchResults/index.cjs} +2 -24
  3. package/dist/SearchZeroState/index-19CiYvee.d.cts +27 -0
  4. package/dist/SearchZeroState/index-6EaGWYP4.d.ts +27 -0
  5. package/dist/SearchZeroState/index.cjs +3047 -0
  6. package/dist/SearchZeroState/index.js +3043 -0
  7. package/dist/SuggestionBar/index-DZU9kbWS.d.cts +39 -0
  8. package/dist/SuggestionBar/index-DyXd4-b7.d.ts +39 -0
  9. package/dist/SuggestionBar/index.cjs +5 -0
  10. package/dist/SuggestionBar/index.js +4 -0
  11. package/dist/SuggestionBar-BOThXJvJ.cjs +453 -0
  12. package/dist/SuggestionBar-DeMmAK4M.js +131 -0
  13. package/dist/SuggestionButtonContainer/index-B_X537jw.d.cts +20 -0
  14. package/dist/SuggestionButtonContainer/index-vwelzDzM.d.ts +20 -0
  15. package/dist/SuggestionButtonContainer/index.cjs +3 -0
  16. package/dist/SuggestionButtonContainer/index.js +3 -0
  17. package/dist/SuggestionButtonContainer-BeWPpeQk.cjs +173 -0
  18. package/dist/SuggestionButtonContainer-CZhOkZaJ.js +167 -0
  19. package/dist/chunk-DWy1uDak.cjs +39 -0
  20. package/package.json +18 -6
  21. package/src/SearchZeroState/SearchIcon.tsx +57 -0
  22. package/src/SearchZeroState/SearchOverlay.tsx +81 -0
  23. package/src/SearchZeroState/SearchZeroState.tsx +264 -0
  24. package/src/SearchZeroState/SearchZeroStateWidget.tsx +33 -0
  25. package/src/SearchZeroState/components/RecommendedProducts.tsx +118 -0
  26. package/src/SearchZeroState/index.ts +8 -0
  27. package/src/SearchZeroState/overlay/overlayHostLocator.ts +17 -0
  28. package/src/SearchZeroState/types.ts +9 -0
  29. package/src/SearchZeroState/zeroStateSearchVariants.ts +24 -0
  30. package/src/SuggestionBar/SuggestionBar.tsx +139 -0
  31. package/src/SuggestionBar/index.ts +2 -0
  32. package/src/SuggestionBar/types.ts +4 -0
  33. package/src/SuggestionButtonContainer/SuggestionButtonContainer.tsx +141 -0
  34. package/src/SuggestionButtonContainer/index.ts +2 -0
  35. package/src/SuggestionButtonContainer/types.ts +16 -0
  36. package/src/stories/SearchZeroState.stories.tsx +44 -0
  37. package/src/stories/SuggestionBar.stories.tsx +46 -0
  38. package/src/util/useHorizontalScrollAnimation.ts +121 -0
  39. package/src/util/useReducedMotionWithOverride.ts +24 -0
  40. package/dist/index-VWNd4lyI.d.cts +0 -6
  41. /package/dist/{index-BPfKr14f.d.ts → SearchResults/index-D52sX_I2.d.cts} +0 -0
  42. /package/dist/{index.js → SearchResults/index.js} +0 -0
@@ -0,0 +1,39 @@
1
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
2
+ import { SuggestionButtonVariant } from "@envive-ai/react-hooks/contexts/types";
3
+ import { TestProps } from "@envive-ai/react-hooks/types";
4
+ import { Message } from "postcss";
5
+
6
+ //#region src/SuggestionBar/types.d.ts
7
+ declare enum SuggestionBarLocationForMetrics {
8
+ SUGGESTION_BAR_TOP = "top",
9
+ SUGGESTION_BAR_BOTTOM = "bottom",
10
+ }
11
+ //#endregion
12
+ //#region src/SuggestionBar/SuggestionBar.d.ts
13
+ interface SuggestionBarProps extends TestProps {
14
+ id: string;
15
+ locationForMetrics: SuggestionBarLocationForMetrics;
16
+ buttonTexts: string[];
17
+ buttonVariation: SuggestionButtonVariant;
18
+ hoverButtonVariation: SuggestionButtonVariant;
19
+ handleReply: (message: Message) => void;
20
+ boldFirstButton?: boolean | undefined;
21
+ twoRowsOnMobile?: boolean | undefined;
22
+ animationSpeed?: 'standard' | 'slow' | 'none';
23
+ buttonBorderRadius?: 'sm' | 'md' | 'lg';
24
+ }
25
+ declare function SuggestionBar({
26
+ id,
27
+ locationForMetrics,
28
+ buttonTexts,
29
+ buttonVariation,
30
+ hoverButtonVariation,
31
+ boldFirstButton,
32
+ twoRowsOnMobile,
33
+ animationSpeed,
34
+ buttonBorderRadius,
35
+ handleReply,
36
+ dataTestId
37
+ }: Readonly<SuggestionBarProps>): react_jsx_runtime0.JSX.Element;
38
+ //#endregion
39
+ export { SuggestionBar, SuggestionBarLocationForMetrics };
@@ -0,0 +1,39 @@
1
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
2
+ import { TestProps } from "@envive-ai/react-hooks/types";
3
+ import { SuggestionButtonVariant } from "@envive-ai/react-hooks/contexts/types";
4
+ import { Message } from "postcss";
5
+
6
+ //#region src/SuggestionBar/types.d.ts
7
+ declare enum SuggestionBarLocationForMetrics {
8
+ SUGGESTION_BAR_TOP = "top",
9
+ SUGGESTION_BAR_BOTTOM = "bottom",
10
+ }
11
+ //#endregion
12
+ //#region src/SuggestionBar/SuggestionBar.d.ts
13
+ interface SuggestionBarProps extends TestProps {
14
+ id: string;
15
+ locationForMetrics: SuggestionBarLocationForMetrics;
16
+ buttonTexts: string[];
17
+ buttonVariation: SuggestionButtonVariant;
18
+ hoverButtonVariation: SuggestionButtonVariant;
19
+ handleReply: (message: Message) => void;
20
+ boldFirstButton?: boolean | undefined;
21
+ twoRowsOnMobile?: boolean | undefined;
22
+ animationSpeed?: 'standard' | 'slow' | 'none';
23
+ buttonBorderRadius?: 'sm' | 'md' | 'lg';
24
+ }
25
+ declare function SuggestionBar({
26
+ id,
27
+ locationForMetrics,
28
+ buttonTexts,
29
+ buttonVariation,
30
+ hoverButtonVariation,
31
+ boldFirstButton,
32
+ twoRowsOnMobile,
33
+ animationSpeed,
34
+ buttonBorderRadius,
35
+ handleReply,
36
+ dataTestId
37
+ }: Readonly<SuggestionBarProps>): react_jsx_runtime0.JSX.Element;
38
+ //#endregion
39
+ export { SuggestionBar, SuggestionBarLocationForMetrics };
@@ -0,0 +1,5 @@
1
+ const require_SuggestionBar = require('../SuggestionBar-BOThXJvJ.cjs');
2
+ require('../SuggestionButtonContainer-BeWPpeQk.cjs');
3
+
4
+ exports.SuggestionBar = require_SuggestionBar.SuggestionBar;
5
+ exports.SuggestionBarLocationForMetrics = require_SuggestionBar.SuggestionBarLocationForMetrics;
@@ -0,0 +1,4 @@
1
+ import { n as SuggestionBarLocationForMetrics, t as SuggestionBar } from "../SuggestionBar-DeMmAK4M.js";
2
+ import "../SuggestionButtonContainer-CZhOkZaJ.js";
3
+
4
+ export { SuggestionBar, SuggestionBarLocationForMetrics };
@@ -0,0 +1,453 @@
1
+ const require_chunk = require('./chunk-DWy1uDak.cjs');
2
+ const require_SuggestionButtonContainer = require('./SuggestionButtonContainer-BeWPpeQk.cjs');
3
+ let react = require("react");
4
+ let jotai = require("jotai");
5
+ let react_jsx_runtime = require("react/jsx-runtime");
6
+ let __envive_ai_react_hooks_application_models = require("@envive-ai/react-hooks/application/models");
7
+ let node_crypto = require("node:crypto");
8
+ let __envive_ai_react_hooks_atoms_chat = require("@envive-ai/react-hooks/atoms/chat");
9
+ let __envive_ai_react_hooks_config = require("@envive-ai/react-hooks/config");
10
+ let __envive_ai_react_hooks_hooks_IsSmallScreen = require("@envive-ai/react-hooks/hooks/IsSmallScreen");
11
+ let __envive_ai_react_hooks_hooks_TrackComponentVisibleEvent = require("@envive-ai/react-hooks/hooks/TrackComponentVisibleEvent");
12
+
13
+ //#region ../../node_modules/react-indiana-drag-scroll/dist/index.js
14
+ var require_dist = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_modules/react-indiana-drag-scroll/dist/index.js": ((exports) => {
15
+ Object.defineProperty(exports, "__esModule", { value: !0 });
16
+ var e = require("react");
17
+ function t(e$1) {
18
+ return e$1 && "object" == typeof e$1 && "default" in e$1 ? e$1 : { default: e$1 };
19
+ }
20
+ var r = t(e), n = function() {
21
+ return (n = Object.assign || function(e$1) {
22
+ for (var t$1, r$1 = 1, n$1 = arguments.length; r$1 < n$1; r$1++) for (var o$1 in t$1 = arguments[r$1]) Object.prototype.hasOwnProperty.call(t$1, o$1) && (e$1[o$1] = t$1[o$1]);
23
+ return e$1;
24
+ }).apply(this, arguments);
25
+ };
26
+ function o(e$1, t$1, r$1, n$1, o$1) {
27
+ var c$1 = r$1 > 0 ? Math.max(0, Math.min(r$1, -t$1)) : Math.min(0, Math.max(r$1, -t$1)), l$1 = Math.min(Math.max(e$1 + r$1 - c$1, n$1), o$1) - Math.min(Math.max(e$1, n$1), o$1);
28
+ return [l$1, r$1 - l$1];
29
+ }
30
+ function c(e$1, t$1, r$1) {
31
+ return 0 === Math.abs(t$1) && Math.abs(r$1) > 0 || Math.sign(t$1) === Math.sign(r$1) ? .3 * e$1 * Math.sign(r$1) * Math.log10(1 + .5 * Math.abs(r$1) / e$1) : r$1;
32
+ }
33
+ function l(e$1) {
34
+ return !!e$1 && e$1.scrollWidth > e$1.clientWidth;
35
+ }
36
+ function i(e$1) {
37
+ return !!e$1 && e$1.scrollHeight > e$1.clientHeight;
38
+ }
39
+ var u;
40
+ function s(e$1) {
41
+ return "function" == typeof e$1;
42
+ }
43
+ function a(e$1, t$1) {
44
+ var r$1, n$1, o$1 = function() {
45
+ for (var c$2 = [], l$1 = 0; l$1 < arguments.length; l$1++) c$2[l$1] = arguments[l$1];
46
+ var i$1 = Date.now() - r$1, u$1 = s(t$1) ? t$1() : t$1 || 0;
47
+ i$1 < u$1 && i$1 >= 0 ? n$1 = setTimeout((function() {
48
+ return o$1.apply(void 0, c$2);
49
+ }), u$1 - i$1) : e$1.apply(void 0, c$2);
50
+ }, c$1 = function() {
51
+ for (var e$2 = [], c$2 = 0; c$2 < arguments.length; c$2++) e$2[c$2] = arguments[c$2];
52
+ r$1 = Date.now(), n$1 = setTimeout((function() {
53
+ return o$1.apply(void 0, e$2);
54
+ }), s(t$1) ? t$1() : t$1 || 0);
55
+ };
56
+ return c$1.clear = function() {
57
+ clearTimeout(n$1);
58
+ }, c$1;
59
+ }
60
+ function f(t$1) {
61
+ var r$1 = e.useRef(t$1);
62
+ return e.useEffect((function() {
63
+ r$1.current = t$1;
64
+ }), [t$1]), r$1;
65
+ }
66
+ exports.MouseButton = void 0, (u = exports.MouseButton || (exports.MouseButton = {}))[u.Left = 1] = "Left", u[u.Middle = 4] = "Middle", u[u.Right = 2] = "Right";
67
+ var p = function() {
68
+ function e$1(e$2, t$1) {
69
+ var r$1, n$1, o$1, c$1, l$1 = this;
70
+ this.getScrollMode = function(e$3) {
71
+ if (l$1.getOptions().overscroll && l$1.reference.current && e$3) {
72
+ var t$2 = l$1.reference.current, r$2 = t$2.scrollLeft, n$2 = t$2.scrollTop, o$2 = t$2.clientHeight, c$2 = t$2.clientWidth, i$1 = t$2.scrollHeight, u$1 = t$2.scrollWidth;
73
+ return e$3.left < 0 && r$2 > 0 || e$3.left > 0 && r$2 < u$1 - c$2 || e$3.top < 0 && n$2 > 0 || e$3.top > 0 && n$2 < i$1 - o$2 ? "local" : "global";
74
+ }
75
+ return "local";
76
+ }, this.clearStyles = function() {
77
+ l$1.reference.current && l$1.reference.current.childNodes.forEach((function(e$3, t$2) {
78
+ e$3.style.transition = l$1.originalStyles.transition[t$2], e$3.style.transform = l$1.originalStyles.transform[t$2], e$3.style.pointerEvents = l$1.originalStyles.pointerEvents[t$2];
79
+ })), l$1.overflow.left = 0, l$1.overflow.top = 0, l$1.overflow.prevent = !1;
80
+ }, this.inertia = function(e$3, t$2) {
81
+ var r$2 = l$1.calculateScroll({
82
+ left: l$1.inertiaSpeed.left * e$3,
83
+ top: l$1.inertiaSpeed.top * e$3
84
+ });
85
+ l$1.inertiaSpeed.left = (r$2.left.local + r$2.left.overflow) / e$3 * .95, l$1.inertiaSpeed.top = (r$2.top.local + r$2.top.overflow) / e$3 * .95, l$1.applyScroll(r$2), Math.abs(l$1.inertiaSpeed.left) < .05 && Math.abs(l$1.inertiaSpeed.top) < .05 && t$2?.();
86
+ }, this.reference = e$2, this.options = t$1, this.originalStyles = {
87
+ transform: [],
88
+ transition: [],
89
+ pointerEvents: []
90
+ }, this.overflow = {
91
+ left: 0,
92
+ top: 0,
93
+ prevent: !1
94
+ }, this.inertiaSpeed = {
95
+ left: 0,
96
+ top: 0
97
+ }, this.mode = null, this.active = !1, this.loopedInertia = (r$1 = this.inertia, o$1 = !1, c$1 = {
98
+ run: function(e$3) {
99
+ o$1 = !1;
100
+ var t$2 = performance.now(), l$2 = function() {
101
+ c$1.cancel(), e$3?.();
102
+ }, i$1 = function(e$4) {
103
+ o$1 || (r$1(e$4 - t$2, l$2), t$2 = e$4, n$1 = window.requestAnimationFrame((function(e$5) {
104
+ return i$1(e$5);
105
+ })));
106
+ };
107
+ n$1 = window.requestAnimationFrame((function(e$4) {
108
+ return i$1(e$4);
109
+ }));
110
+ },
111
+ cancel: function() {
112
+ o$1 = !0, window.cancelAnimationFrame(n$1);
113
+ }
114
+ }), this.debouncedClearStyles = a(this.clearStyles, 300);
115
+ }
116
+ return e$1.prototype.getOptions = function() {
117
+ return n({
118
+ inertia: !0,
119
+ rubberBand: !0
120
+ }, this.options.current);
121
+ }, e$1.prototype.start = function(e$2) {
122
+ var t$1 = this;
123
+ this.active && this.cancel(), this.mode = this.getScrollMode(e$2), this.reference.current && this.reference.current.childNodes.forEach((function(e$3) {
124
+ e$3.addEventListener("click", t$1.preventEvent);
125
+ var r$1 = window.getComputedStyle(e$3), n$1 = r$1.transform, o$1 = r$1.transition, c$1 = r$1.pointerEvents;
126
+ t$1.originalStyles.transition.push(o$1), t$1.originalStyles.transform.push(n$1), t$1.originalStyles.pointerEvents.push(c$1), e$3.style.pointerEvents = "none";
127
+ })), this.active = !0;
128
+ }, e$1.prototype.scroll = function(e$2) {
129
+ this.applyScroll(this.calculateScroll(e$2));
130
+ }, e$1.prototype.end = function(e$2, t$1) {
131
+ var r$1 = this, n$1 = this.getOptions().inertia, o$1 = function() {
132
+ r$1.cancel(), t$1?.();
133
+ };
134
+ this.inertiaSpeed.left = e$2 ? e$2.left : 0, this.inertiaSpeed.top = e$2 ? e$2.top : 0, n$1 ? this.loopedInertia.run(o$1) : o$1();
135
+ }, e$1.prototype.cancel = function() {
136
+ var e$2, t$1 = this;
137
+ null === (e$2 = this.reference.current) || void 0 === e$2 || e$2.childNodes.forEach((function(e$3) {
138
+ e$3.removeEventListener("click", t$1.preventEvent);
139
+ })), this.resetOverflow(), this.loopedInertia.cancel(), this.mode = null, this.active = !1;
140
+ }, e$1.prototype.resetOverflow = function() {
141
+ var e$2, t$1 = this.overflow.left || this.overflow.top;
142
+ t$1 && (this.overflow.prevent = !0, (null === (e$2 = this.reference.current) || void 0 === e$2 ? void 0 : e$2.childNodes).forEach((function(e$3) {
143
+ e$3.style.transform = "translate3d(0px, 0px, 0px)", e$3.style.transition = "300ms";
144
+ }))), t$1 ? this.debouncedClearStyles() : this.clearStyles();
145
+ }, e$1.prototype.preventEvent = function(e$2) {
146
+ e$2.preventDefault(), e$2.stopImmediatePropagation();
147
+ }, e$1.prototype.applyScroll = function(e$2) {
148
+ var t$1 = this, r$1 = e$2.left, n$1 = e$2.top;
149
+ (r$1.global || n$1.global) && window.scrollTo({
150
+ left: window.scrollX + r$1.global,
151
+ top: window.scrollY + n$1.global,
152
+ behavior: "auto"
153
+ }), this.reference.current && (this.reference.current.scrollLeft += r$1.local, this.reference.current.scrollTop += n$1.local, this.overflow.prevent || !r$1.overflow && !n$1.overflow || (this.overflow.left += r$1.overflow, this.overflow.top += n$1.overflow, this.reference.current.childNodes.forEach((function(e$3) {
154
+ e$3.style.transform = "translate3d(" + -t$1.overflow.left + "px, " + -t$1.overflow.top + "px, 0px)", e$3.style.transition = "0ms";
155
+ }))));
156
+ }, e$1.prototype.calculateScroll = function(e$2) {
157
+ var t$1 = this.getOptions().rubberBand, r$1 = {
158
+ local: 0,
159
+ global: 0,
160
+ overflow: 0
161
+ }, n$1 = {
162
+ local: 0,
163
+ global: 0,
164
+ overflow: 0
165
+ };
166
+ if ("global" === this.mode) r$1.global = e$2.left, n$1.global = e$2.top;
167
+ else if (this.reference.current) {
168
+ var u$1 = this.reference.current, s$1 = u$1.scrollLeft, a$1 = u$1.scrollTop, f$1 = u$1.scrollWidth, p$1 = u$1.clientWidth, d$1 = u$1.scrollHeight, v$1 = u$1.clientHeight;
169
+ if (l(this.reference.current)) {
170
+ var h = o(s$1, this.overflow.left, e$2.left, 0, f$1 - p$1), m = h[0], S = h[1];
171
+ r$1.local = m, t$1 && (r$1.overflow = c(p$1, this.overflow.left, S));
172
+ }
173
+ if (i(this.reference.current)) {
174
+ var w = o(a$1, this.overflow.top, e$2.top, 0, d$1 - v$1);
175
+ m = w[0], S = w[1];
176
+ n$1.local = m, t$1 && (n$1.overflow = c(p$1, this.overflow.top, S));
177
+ }
178
+ }
179
+ return {
180
+ left: r$1,
181
+ top: n$1
182
+ };
183
+ }, e$1;
184
+ }();
185
+ function d(t$1) {
186
+ void 0 === t$1 && (t$1 = { mouseScroll: !0 });
187
+ var r$1, o$1, c$1, u$1, s$1 = e.useRef(null), d$1 = 1 / 60 * 1e3, v$1 = e.useRef({
188
+ scrolling: !1,
189
+ started: !1,
190
+ pressed: !1,
191
+ artificial: !1,
192
+ mouse: !1
193
+ }), h = e.useRef({
194
+ active: {
195
+ left: !1,
196
+ top: !1
197
+ },
198
+ initialClick: {
199
+ left: 0,
200
+ top: 0
201
+ },
202
+ speedX: 0,
203
+ speedY: 0,
204
+ clientX: 0,
205
+ clientY: 0
206
+ }), m = e.useRef({
207
+ body: {},
208
+ reference: {}
209
+ }), S = f(t$1), w = f(n({
210
+ activationDistance: 20,
211
+ cursor: !0,
212
+ buttons: [exports.MouseButton.Left]
213
+ }, null !== (r$1 = S.current.mouseScroll) && "object" == typeof r$1 ? S.current.mouseScroll : {})), y = e.useState("mouseScrollImplementation" in t$1 && t$1.mouseScrollImplementation ? t$1.mouseScrollImplementation(s$1, w) : function(e$1, t$2) {
214
+ return new p(e$1, t$2);
215
+ }(s$1, w))[0], g = function() {
216
+ var e$1 = function() {
217
+ window.requestAnimationFrame((function() {
218
+ var e$2, t$2;
219
+ null === (t$2 = (e$2 = S.current).onEndScroll) || void 0 === t$2 || t$2.call(e$2), v$1.current.started = !1, v$1.current.scrolling = !1, v$1.current.artificial = !1;
220
+ }));
221
+ };
222
+ v$1.current.artificial ? y.end({
223
+ left: h.current.speedX,
224
+ top: h.current.speedY
225
+ }, e$1) : e$1();
226
+ }, b = function(e$1) {
227
+ var t$2, r$2, n$1 = w.current.ignoreElements;
228
+ S.current.mouseScroll && function(e$2, t$3, r$3) {
229
+ if (r$3 && e$2 && t$3) {
230
+ var n$2 = e$2.closest(r$3);
231
+ return null === n$2 || n$2.contains(t$3);
232
+ }
233
+ return Boolean(e$2 && t$3);
234
+ }(e$1.target, s$1.current, n$1) && (l(s$1.current) || i(s$1.current)) && -1 !== w.current.buttons.indexOf(e$1.buttons) && (t$2 = e$1.clientX, r$2 = e$1.clientY, h.current.speedY = 0, h.current.speedX = 0, h.current.clientX = t$2, h.current.clientY = r$2, h.current.active.left = !1, h.current.active.top = !1, h.current.initialClick.top = r$2, h.current.initialClick.left = t$2, v$1.current.mouse = !0, v$1.current.pressed = !0, y.cancel());
235
+ }, E = function(e$1) {
236
+ S.current.mouseScroll && v$1.current.pressed && v$1.current.mouse && (function(e$2, t$2) {
237
+ var r$2 = w.current, n$1 = r$2.activationDistance, o$2 = r$2.cursor;
238
+ Math.abs(e$2 - h.current.initialClick.left) > n$1 && (h.current.active.left = !0), Math.abs(t$2 - h.current.initialClick.top) > n$1 && (h.current.active.top = !0);
239
+ var c$2 = {
240
+ left: h.current.active.left ? h.current.clientX - e$2 : 0,
241
+ top: h.current.active.top ? h.current.clientY - t$2 : 0
242
+ };
243
+ y.active ? v$1.current.pressed && (h.current.speedX = c$2.left / d$1, h.current.speedY = c$2.top / d$1, h.current.clientX = e$2, h.current.clientY = t$2, y.scroll(c$2), window.requestAnimationFrame((function() {
244
+ h.current.speedX = 0, h.current.speedY = 0;
245
+ }))) : (h.current.active.top || h.current.active.left) && (y.start(c$2), h.current.clientX = e$2, h.current.clientY = t$2, v$1.current.artificial = !0, o$2 && (m.current.body.cursor = document.body.style.cursor, document.body.style.cursor = "grabbing", s$1.current && (m.current.reference.cursor = s$1.current.style.cursor, s$1.current.style.cursor = "grabbing")), s$1.current && (m.current.reference.userSelect = s$1.current.style.userSelect, s$1.current.style.userSelect = "none"));
246
+ }(e$1.clientX, e$1.clientY), e$1.preventDefault(), e$1.stopPropagation());
247
+ }, M = function() {
248
+ v$1.current.pressed && (y.active && g(), v$1.current.pressed = !1, v$1.current.mouse = !1, x());
249
+ }, x = function() {
250
+ w.current.cursor && (document.body.style.cursor = m.current.body.cursor || "", s$1.current && (s$1.current.style.cursor = m.current.reference.cursor || "")), s$1.current && (s$1.current.style.userSelect = m.current.reference.userSelect || "");
251
+ }, L = function() {
252
+ v$1.current.artificial = !1, v$1.current.pressed = !0;
253
+ }, O = function() {
254
+ v$1.current.pressed && (v$1.current.started && !v$1.current.scrolling && g(), v$1.current.pressed = !1);
255
+ }, X = function() {
256
+ var e$1, t$2;
257
+ v$1.current.scrolling = !0, v$1.current.started ? null === (t$2 = (e$1 = S.current).onScroll) || void 0 === t$2 || t$2.call(e$1) : function() {
258
+ var e$2, t$3;
259
+ v$1.current.started = !0, null === (t$3 = (e$2 = S.current).onStartScroll) || void 0 === t$3 || t$3.call(e$2);
260
+ }(), Y();
261
+ }, Y = (o$1 = 250, c$1 = f((function() {
262
+ var e$1 = v$1.current, t$2 = e$1.pressed, r$2 = e$1.started, n$1 = e$1.artificial;
263
+ t$2 || !r$2 || n$1 || g(), v$1.current.scrolling = !1;
264
+ })), u$1 = f(o$1), e.useRef(a((function() {
265
+ var e$1;
266
+ null === (e$1 = c$1.current) || void 0 === e$1 || e$1.call(c$1);
267
+ }), (function() {
268
+ return u$1.current;
269
+ }))).current), I = e.useCallback((function(e$1) {
270
+ s$1.current !== e$1 && (s$1.current && (s$1.current.removeEventListener("mousedown", b), s$1.current.removeEventListener("scroll", X), s$1.current.removeEventListener("touchstart", L)), s$1.current = e$1, s$1.current && (s$1.current.addEventListener("mousedown", b, { passive: !1 }), s$1.current.addEventListener("scroll", X, { passive: !1 }), s$1.current.addEventListener("touchstart", L)));
271
+ }), []);
272
+ return e.useEffect((function() {
273
+ return window.addEventListener("mouseup", M), window.addEventListener("mousemove", E), window.addEventListener("touchend", O), function() {
274
+ window.removeEventListener("mouseup", M), window.removeEventListener("mousemove", E), window.removeEventListener("touchend", O), x();
275
+ };
276
+ }), []), { ref: I };
277
+ }
278
+ var v = e.forwardRef((function(e$1, t$1) {
279
+ var o$1, c$1, l$1 = n({ mouseScrollImplementation: void 0 }, e$1), i$1 = l$1.children, u$1 = l$1.className, s$1 = l$1.component, a$1 = l$1.hideScrollbars, f$1 = void 0 === a$1 || a$1, p$1 = l$1.mouseScroll, v$1 = void 0 === p$1 || p$1, h = l$1.mouseScrollImplementation, m = l$1.onStartScroll, S = l$1.onEndScroll, w = l$1.onScroll, y = function(e$2, t$2) {
280
+ var r$1 = {};
281
+ for (var n$1 in e$2) Object.prototype.hasOwnProperty.call(e$2, n$1) && t$2.indexOf(n$1) < 0 && (r$1[n$1] = e$2[n$1]);
282
+ if (null != e$2 && "function" == typeof Object.getOwnPropertySymbols) {
283
+ var o$2 = 0;
284
+ for (n$1 = Object.getOwnPropertySymbols(e$2); o$2 < n$1.length; o$2++) t$2.indexOf(n$1[o$2]) < 0 && Object.prototype.propertyIsEnumerable.call(e$2, n$1[o$2]) && (r$1[n$1[o$2]] = e$2[n$1[o$2]]);
285
+ }
286
+ return r$1;
287
+ }(l$1, [
288
+ "children",
289
+ "className",
290
+ "component",
291
+ "hideScrollbars",
292
+ "mouseScroll",
293
+ "mouseScrollImplementation",
294
+ "onStartScroll",
295
+ "onEndScroll",
296
+ "onScroll"
297
+ ]), g = s$1 || "div", b = d({
298
+ mouseScroll: v$1,
299
+ mouseScrollImplementation: h,
300
+ onStartScroll: m,
301
+ onEndScroll: S,
302
+ onScroll: w
303
+ });
304
+ return r.default.createElement(g, n({
305
+ className: (c$1 = [
306
+ u$1,
307
+ "indiana-scroll-container",
308
+ f$1 && "indiana-scroll-container--hide-scrollbars"
309
+ ], c$1.filter((function(e$2) {
310
+ return e$2;
311
+ })).join(" ")),
312
+ ref: (o$1 = [t$1, b.ref], function(e$2) {
313
+ o$1.forEach((function(t$2) {
314
+ "function" == typeof t$2 ? t$2(e$2) : null != t$2 && (t$2.current = e$2);
315
+ }));
316
+ })
317
+ }, y), i$1);
318
+ }));
319
+ exports.ScrollContainer = v, exports.default = v, exports.useScrollContainer = d;
320
+ }) });
321
+
322
+ //#endregion
323
+ //#region ../../node_modules/uuid/dist-node/stringify.js
324
+ const byteToHex = [];
325
+ for (let i$1 = 0; i$1 < 256; ++i$1) byteToHex.push((i$1 + 256).toString(16).slice(1));
326
+ function unsafeStringify(arr, offset = 0) {
327
+ return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
328
+ }
329
+
330
+ //#endregion
331
+ //#region ../../node_modules/uuid/dist-node/rng.js
332
+ const rnds8Pool = new Uint8Array(256);
333
+ let poolPtr = rnds8Pool.length;
334
+ function rng() {
335
+ if (poolPtr > rnds8Pool.length - 16) {
336
+ (0, node_crypto.randomFillSync)(rnds8Pool);
337
+ poolPtr = 0;
338
+ }
339
+ return rnds8Pool.slice(poolPtr, poolPtr += 16);
340
+ }
341
+
342
+ //#endregion
343
+ //#region ../../node_modules/uuid/dist-node/native.js
344
+ var native_default = { randomUUID: node_crypto.randomUUID };
345
+
346
+ //#endregion
347
+ //#region ../../node_modules/uuid/dist-node/v4.js
348
+ function _v4(options, buf, offset) {
349
+ options = options || {};
350
+ const rnds = options.random ?? options.rng?.() ?? rng();
351
+ if (rnds.length < 16) throw new Error("Random bytes length must be >= 16");
352
+ rnds[6] = rnds[6] & 15 | 64;
353
+ rnds[8] = rnds[8] & 63 | 128;
354
+ if (buf) {
355
+ offset = offset || 0;
356
+ if (offset < 0 || offset + 16 > buf.length) throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
357
+ for (let i$1 = 0; i$1 < 16; ++i$1) buf[offset + i$1] = rnds[i$1];
358
+ return buf;
359
+ }
360
+ return unsafeStringify(rnds);
361
+ }
362
+ function v4(options, buf, offset) {
363
+ if (native_default.randomUUID && !buf && !options) return native_default.randomUUID();
364
+ return _v4(options, buf, offset);
365
+ }
366
+ var v4_default = v4;
367
+
368
+ //#endregion
369
+ //#region src/SuggestionBar/types.ts
370
+ let SuggestionBarLocationForMetrics = /* @__PURE__ */ function(SuggestionBarLocationForMetrics$1) {
371
+ SuggestionBarLocationForMetrics$1["SUGGESTION_BAR_TOP"] = "top";
372
+ SuggestionBarLocationForMetrics$1["SUGGESTION_BAR_BOTTOM"] = "bottom";
373
+ return SuggestionBarLocationForMetrics$1;
374
+ }({});
375
+
376
+ //#endregion
377
+ //#region src/SuggestionBar/SuggestionBar.tsx
378
+ var import_dist = require_dist();
379
+ function SuggestionBar({ id, locationForMetrics, buttonTexts, buttonVariation, hoverButtonVariation, boldFirstButton = false, twoRowsOnMobile = false, animationSpeed = "none", buttonBorderRadius = "lg", handleReply, dataTestId }) {
380
+ const componentVisibleTriggerRef = (0, react.useRef)(null);
381
+ const containerRef = (0, react.useRef)(null);
382
+ const { ref } = (0, import_dist.useScrollContainer)();
383
+ const isSmallScreen = (0, __envive_ai_react_hooks_hooks_IsSmallScreen.useIsSmallScreen)();
384
+ const logPerfMetric = (0, jotai.useSetAtom)(__envive_ai_react_hooks_atoms_chat.logPerfMetricAtom);
385
+ const isAnimated = animationSpeed !== "none";
386
+ (0, __envive_ai_react_hooks_hooks_TrackComponentVisibleEvent.useTrackComponentVisibleEvent)(__envive_ai_react_hooks_application_models.SpiffyWidgets.SuggestionBar, componentVisibleTriggerRef, { animated: isAnimated });
387
+ const handleClickSuggestion = (0, react.useCallback)((buttonText) => {
388
+ handleReply({
389
+ id: v4_default(),
390
+ role: __envive_ai_react_hooks_application_models.MessageRole.User,
391
+ type: __envive_ai_react_hooks_application_models.MessageType.QueryTyped,
392
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
393
+ metadata: { content: buttonText }
394
+ });
395
+ }, [handleReply]);
396
+ const setRefs = (0, react.useCallback)((el) => {
397
+ if (typeof ref === "function") ref(el);
398
+ containerRef.current = el;
399
+ }, [ref]);
400
+ const handleContainerRef = (0, react.useCallback)((el) => {
401
+ if (el) logPerfMetric(locationForMetrics === SuggestionBarLocationForMetrics.SUGGESTION_BAR_TOP ? __envive_ai_react_hooks_atoms_chat.PerfMetricsEvents.TopSuggestionsBarRendered : __envive_ai_react_hooks_atoms_chat.PerfMetricsEvents.BottomSuggestionsBarRendered);
402
+ setRefs(el);
403
+ }, [
404
+ locationForMetrics,
405
+ logPerfMetric,
406
+ setRefs
407
+ ]);
408
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
409
+ id,
410
+ className: "spiffy-tw-justify-center spiffy-tw-w-full spiffy-tw-overflow-hidden",
411
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
412
+ className: `
413
+ spiffy-tw-relative
414
+ spiffy-tw-w-full
415
+ spiffy-tw-overflow-x-scroll
416
+ spiffy-tw-overflow-y-hidden
417
+ spiffy-tw-no-scrollbar
418
+ ${twoRowsOnMobile && isSmallScreen ? "spiffy-tw-h-20" : "spiffy-tw-h-9"}
419
+ `,
420
+ ref: handleContainerRef,
421
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
422
+ className: "spiffy-tw-relative spiffy-tw-inline-block spiffy-tw-whitespace-nowrap",
423
+ ref: componentVisibleTriggerRef,
424
+ "data-testid": dataTestId || __envive_ai_react_hooks_config.SUGGESTION_BAR_TESTID,
425
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SuggestionButtonContainer.SuggestionButtonContainer, {
426
+ buttonVariation,
427
+ hoverButtonVariation,
428
+ buttonTexts,
429
+ onButtonClick: handleClickSuggestion,
430
+ scrollContainerRef: containerRef,
431
+ boldFirstButton,
432
+ twoRowsOnMobile,
433
+ animationSpeed,
434
+ buttonBorderRadius
435
+ })
436
+ })
437
+ })
438
+ });
439
+ }
440
+
441
+ //#endregion
442
+ Object.defineProperty(exports, 'SuggestionBar', {
443
+ enumerable: true,
444
+ get: function () {
445
+ return SuggestionBar;
446
+ }
447
+ });
448
+ Object.defineProperty(exports, 'SuggestionBarLocationForMetrics', {
449
+ enumerable: true,
450
+ get: function () {
451
+ return SuggestionBarLocationForMetrics;
452
+ }
453
+ });
@@ -0,0 +1,131 @@
1
+ import { t as SuggestionButtonContainer } from "./SuggestionButtonContainer-CZhOkZaJ.js";
2
+ import { useCallback, useRef } from "react";
3
+ import { useSetAtom } from "jotai";
4
+ import { jsx } from "react/jsx-runtime";
5
+ import { MessageRole, MessageType, SpiffyWidgets } from "@envive-ai/react-hooks/application/models";
6
+ import { useScrollContainer } from "react-indiana-drag-scroll";
7
+ import { PerfMetricsEvents, logPerfMetricAtom } from "@envive-ai/react-hooks/atoms/chat";
8
+ import { SUGGESTION_BAR_TESTID } from "@envive-ai/react-hooks/config";
9
+ import { useIsSmallScreen } from "@envive-ai/react-hooks/hooks/IsSmallScreen";
10
+ import { useTrackComponentVisibleEvent } from "@envive-ai/react-hooks/hooks/TrackComponentVisibleEvent";
11
+
12
+ //#region ../../node_modules/uuid/dist/stringify.js
13
+ const byteToHex = [];
14
+ for (let i = 0; i < 256; ++i) byteToHex.push((i + 256).toString(16).slice(1));
15
+ function unsafeStringify(arr, offset = 0) {
16
+ return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
17
+ }
18
+
19
+ //#endregion
20
+ //#region ../../node_modules/uuid/dist/rng.js
21
+ let getRandomValues;
22
+ const rnds8 = new Uint8Array(16);
23
+ function rng() {
24
+ if (!getRandomValues) {
25
+ if (typeof crypto === "undefined" || !crypto.getRandomValues) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
26
+ getRandomValues = crypto.getRandomValues.bind(crypto);
27
+ }
28
+ return getRandomValues(rnds8);
29
+ }
30
+
31
+ //#endregion
32
+ //#region ../../node_modules/uuid/dist/native.js
33
+ const randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
34
+ var native_default = { randomUUID };
35
+
36
+ //#endregion
37
+ //#region ../../node_modules/uuid/dist/v4.js
38
+ function _v4(options, buf, offset) {
39
+ options = options || {};
40
+ const rnds = options.random ?? options.rng?.() ?? rng();
41
+ if (rnds.length < 16) throw new Error("Random bytes length must be >= 16");
42
+ rnds[6] = rnds[6] & 15 | 64;
43
+ rnds[8] = rnds[8] & 63 | 128;
44
+ if (buf) {
45
+ offset = offset || 0;
46
+ if (offset < 0 || offset + 16 > buf.length) throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
47
+ for (let i = 0; i < 16; ++i) buf[offset + i] = rnds[i];
48
+ return buf;
49
+ }
50
+ return unsafeStringify(rnds);
51
+ }
52
+ function v4(options, buf, offset) {
53
+ if (native_default.randomUUID && !buf && !options) return native_default.randomUUID();
54
+ return _v4(options, buf, offset);
55
+ }
56
+ var v4_default = v4;
57
+
58
+ //#endregion
59
+ //#region src/SuggestionBar/types.ts
60
+ let SuggestionBarLocationForMetrics = /* @__PURE__ */ function(SuggestionBarLocationForMetrics$1) {
61
+ SuggestionBarLocationForMetrics$1["SUGGESTION_BAR_TOP"] = "top";
62
+ SuggestionBarLocationForMetrics$1["SUGGESTION_BAR_BOTTOM"] = "bottom";
63
+ return SuggestionBarLocationForMetrics$1;
64
+ }({});
65
+
66
+ //#endregion
67
+ //#region src/SuggestionBar/SuggestionBar.tsx
68
+ function SuggestionBar({ id, locationForMetrics, buttonTexts, buttonVariation, hoverButtonVariation, boldFirstButton = false, twoRowsOnMobile = false, animationSpeed = "none", buttonBorderRadius = "lg", handleReply, dataTestId }) {
69
+ const componentVisibleTriggerRef = useRef(null);
70
+ const containerRef = useRef(null);
71
+ const { ref } = useScrollContainer();
72
+ const isSmallScreen = useIsSmallScreen();
73
+ const logPerfMetric = useSetAtom(logPerfMetricAtom);
74
+ const isAnimated = animationSpeed !== "none";
75
+ useTrackComponentVisibleEvent(SpiffyWidgets.SuggestionBar, componentVisibleTriggerRef, { animated: isAnimated });
76
+ const handleClickSuggestion = useCallback((buttonText) => {
77
+ handleReply({
78
+ id: v4_default(),
79
+ role: MessageRole.User,
80
+ type: MessageType.QueryTyped,
81
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
82
+ metadata: { content: buttonText }
83
+ });
84
+ }, [handleReply]);
85
+ const setRefs = useCallback((el) => {
86
+ if (typeof ref === "function") ref(el);
87
+ containerRef.current = el;
88
+ }, [ref]);
89
+ const handleContainerRef = useCallback((el) => {
90
+ if (el) logPerfMetric(locationForMetrics === SuggestionBarLocationForMetrics.SUGGESTION_BAR_TOP ? PerfMetricsEvents.TopSuggestionsBarRendered : PerfMetricsEvents.BottomSuggestionsBarRendered);
91
+ setRefs(el);
92
+ }, [
93
+ locationForMetrics,
94
+ logPerfMetric,
95
+ setRefs
96
+ ]);
97
+ return /* @__PURE__ */ jsx("div", {
98
+ id,
99
+ className: "spiffy-tw-justify-center spiffy-tw-w-full spiffy-tw-overflow-hidden",
100
+ children: /* @__PURE__ */ jsx("div", {
101
+ className: `
102
+ spiffy-tw-relative
103
+ spiffy-tw-w-full
104
+ spiffy-tw-overflow-x-scroll
105
+ spiffy-tw-overflow-y-hidden
106
+ spiffy-tw-no-scrollbar
107
+ ${twoRowsOnMobile && isSmallScreen ? "spiffy-tw-h-20" : "spiffy-tw-h-9"}
108
+ `,
109
+ ref: handleContainerRef,
110
+ children: /* @__PURE__ */ jsx("div", {
111
+ className: "spiffy-tw-relative spiffy-tw-inline-block spiffy-tw-whitespace-nowrap",
112
+ ref: componentVisibleTriggerRef,
113
+ "data-testid": dataTestId || SUGGESTION_BAR_TESTID,
114
+ children: /* @__PURE__ */ jsx(SuggestionButtonContainer, {
115
+ buttonVariation,
116
+ hoverButtonVariation,
117
+ buttonTexts,
118
+ onButtonClick: handleClickSuggestion,
119
+ scrollContainerRef: containerRef,
120
+ boldFirstButton,
121
+ twoRowsOnMobile,
122
+ animationSpeed,
123
+ buttonBorderRadius
124
+ })
125
+ })
126
+ })
127
+ });
128
+ }
129
+
130
+ //#endregion
131
+ export { SuggestionBarLocationForMetrics as n, SuggestionBar as t };