@inkeep/cxkit-primitives 0.5.95 → 0.5.96

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.
@@ -1,9 +1,9 @@
1
1
  "use client";
2
- import { jsx as n, jsxs as $, Fragment as Z } from "react/jsx-runtime";
3
- import { forwardRef as Q, memo as P, useState as ge, useEffect as Me, useMemo as Ie } from "react";
2
+ import { jsx as n, jsxs as V, Fragment as Z } from "react/jsx-runtime";
3
+ import { forwardRef as U, memo as P, useState as ge, useEffect as Me, useMemo as Ie } from "react";
4
4
  import ee from "react-textarea-autosize";
5
5
  import * as te from "@radix-ui/react-avatar";
6
- import * as V from "@radix-ui/react-checkbox";
6
+ import * as K from "@radix-ui/react-checkbox";
7
7
  import * as S from "@radix-ui/react-popover";
8
8
  import * as k from "@radix-ui/react-tooltip";
9
9
  import * as x from "@radix-ui/react-scroll-area";
@@ -14,13 +14,13 @@ import xe from "../atoms/avatars/user.js";
14
14
  import { CustomIcon as A } from "../atoms/icons/custom-icon.js";
15
15
  import { BuiltInIconRenderer as B } from "../atoms/icons/built-in-icon-renderer.js";
16
16
  import { LinkWithQueryParams as De } from "../atoms/link.js";
17
- import { Markdown as U } from "../atoms/markdown/index.js";
17
+ import { Markdown as q } from "../atoms/markdown/index.js";
18
18
  import { AttachmentItemProvider as be, useAttachmentItem as D } from "../providers/attachment-item-provider.js";
19
19
  import { AttachmentsBarProvider as Oe, useAttachmentsBar as F } from "../providers/attachments-bar-provider.js";
20
20
  import { SourceItemProvider as We, useSourceItem as w } from "../providers/source-item-provider.js";
21
- import { useInkeepConfig as u } from "../providers/config-provider.js";
22
- import { useInkeepConversation as K, SHARE_QUERY_PARAM as Ne } from "../providers/conversation-provider.js";
23
- import { useChatEvents as q } from "../providers/chat-events-provider.js";
21
+ import { useInkeepConfig as C } from "../providers/config-provider.js";
22
+ import { useInkeepConversation as O, SHARE_QUERY_PARAM as Ne } from "../providers/conversation-provider.js";
23
+ import { useChatEvents as W } from "../providers/chat-events-provider.js";
24
24
  import { useMessageFeedback as re } from "../providers/feedback-provider.js";
25
25
  import { MessageAttachmentsProvider as Re, useMessageAttachments as j } from "../providers/message-attachments-provider.js";
26
26
  import { MessageProvider as $e, useMessage as b } from "../providers/message-provider.js";
@@ -53,7 +53,7 @@ import { HoverPopoverProvider as ot, useHoverPopover as Ae } from "../providers/
53
53
  import { useWidgetAutoFocus as rt } from "./modal/widget-auto-focus.js";
54
54
  const ct = "__intro__", dt = i("div", {
55
55
  _id: "aiChatWrapper"
56
- }), rn = Q((t, e) => {
56
+ }), rn = U((t, e) => {
57
57
  const { ...a } = t, { isHidden: s, isMobile: o } = g(), [r, c] = je(), d = le(e, r), m = c?.width ? c.width > 580 : !0, l = et();
58
58
  return /* @__PURE__ */ n(
59
59
  dt,
@@ -86,7 +86,7 @@ const ct = "__intro__", dt = i("div", {
86
86
  _id: "aiChatHeader__ToolbarHeader"
87
87
  }), un = P(
88
88
  (t) => {
89
- const { aiChatSettings: e } = u(), a = `Ask ${e.aiAssistantName || "AI"}`;
89
+ const { aiChatSettings: e } = C(), a = `Ask ${e.aiAssistantName || "AI"}`;
90
90
  return /* @__PURE__ */ n(ht, { ...t, children: a });
91
91
  }
92
92
  ), Cn = i("div", {
@@ -95,7 +95,7 @@ const ct = "__intro__", dt = i("div", {
95
95
  _id: "aiChatContentScrollArea"
96
96
  }), ut = i(x.Viewport, {
97
97
  _id: "aiChatContentScrollArea__Viewport"
98
- }), vn = Q(({ children: t, ...e }, a) => {
98
+ }), vn = U(({ children: t, ...e }, a) => {
99
99
  const { containerRef: s } = it(), o = le(a, s);
100
100
  return /* @__PURE__ */ n(
101
101
  ut,
@@ -129,14 +129,14 @@ const ct = "__intro__", dt = i("div", {
129
129
  _id: "aiChatDisclaimer"
130
130
  }), Pn = P(
131
131
  (t) => {
132
- const { aiChatSettings: e } = u(), [a, s] = ge(!1), o = st(a, 100);
132
+ const { aiChatSettings: e } = C(), [a, s] = ge(!1), o = st(a, 100);
133
133
  return e.disclaimerSettings?.isEnabled ? /* @__PURE__ */ n(ot, { open: a, setOpen: s, children: /* @__PURE__ */ n(S.Root, { open: o, onOpenChange: s, children: /* @__PURE__ */ n(pt, { ...t }) }) }) : null;
134
134
  }
135
135
  ), vt = i("span", {
136
136
  _id: "aiChatDisclaimerLabel"
137
137
  }), Fn = P(
138
138
  (t) => {
139
- const { aiChatSettings: e } = u(), a = e.disclaimerSettings;
139
+ const { aiChatSettings: e } = C(), a = e.disclaimerSettings;
140
140
  return /* @__PURE__ */ n(vt, { children: a?.label, ...t });
141
141
  }
142
142
  ), gt = i(S.Trigger, {
@@ -170,11 +170,11 @@ const ct = "__intro__", dt = i("div", {
170
170
  ...t
171
171
  }
172
172
  );
173
- }, _t = i(U, {
173
+ }, _t = i(q, {
174
174
  _id: "aiChatDisclaimerText"
175
175
  }), fn = P(
176
176
  (t) => {
177
- const { aiChatSettings: e } = u(), a = e.aiAssistantName, o = e.disclaimerSettings?.tooltip || `Information provided by ${a || "this AI assistant"} is not guaranteed to be accurate or comprehensive.`;
177
+ const { aiChatSettings: e } = C(), a = e.aiAssistantName, o = e.disclaimerSettings?.tooltip || `Information provided by ${a || "this AI assistant"} is not guaranteed to be accurate or comprehensive.`;
178
178
  return /* @__PURE__ */ n(_t, { shouldOpenLinksInNewTab: !0, children: o, ...t });
179
179
  }
180
180
  ), En = i(S.Arrow, {
@@ -182,26 +182,26 @@ const ct = "__intro__", dt = i("div", {
182
182
  }), At = i("div", {
183
183
  _id: "aiChatExampleQuestions"
184
184
  }), Sn = (t) => {
185
- const { aiChatSettings: e } = u(), { messages: a } = g();
185
+ const { aiChatSettings: e } = C(), { messages: a } = g();
186
186
  return !e.exampleQuestions?.length || a.length ? null : /* @__PURE__ */ n(At, { ...t });
187
187
  }, Pt = i("h3", {
188
188
  _id: "aiChatExampleQuestionsLabel"
189
189
  }), kn = P(
190
190
  (t) => {
191
- const { aiChatSettings: e } = u();
191
+ const { aiChatSettings: e } = C();
192
192
  return /* @__PURE__ */ n(Pt, { children: e.exampleQuestionsLabel, ...t });
193
193
  }
194
194
  ), Ft = i("div", {
195
195
  _id: "aiChatExampleQuestionsList"
196
196
  }), Bn = P(
197
197
  (t) => {
198
- const { aiChatSettings: e } = u(), a = e.exampleQuestions, { children: s, ...o } = t;
198
+ const { aiChatSettings: e } = C(), a = e.exampleQuestions, { children: s, ...o } = t;
199
199
  return /* @__PURE__ */ n(Ft, { children: M(s, a), ...o });
200
200
  }
201
201
  ), Mt = i("div", {
202
202
  _id: "aiChatExampleQuestion"
203
- }), Tn = Q((t, e) => {
204
- const { aiChatSettings: a } = u(), s = a.isFirstExampleQuestionHighlighted;
203
+ }), Tn = U((t, e) => {
204
+ const { aiChatSettings: a } = C(), s = a.isFirstExampleQuestionHighlighted;
205
205
  return /* @__PURE__ */ n(Mt, { ref: e, "data-highlight": p(s), ...t });
206
206
  }), It = i("button", {
207
207
  _id: "aiChatExampleQuestionButton"
@@ -218,18 +218,18 @@ const ct = "__intro__", dt = i("div", {
218
218
  }, ft = i("div", {
219
219
  _id: "aiChatWorkflows"
220
220
  }), wn = (t) => {
221
- const { aiChatSettings: e } = u(), { messages: a } = g();
221
+ const { aiChatSettings: e } = C(), { messages: a } = g();
222
222
  return !e.workflows?.length || a.length ? null : /* @__PURE__ */ n(ft, { ...t });
223
223
  }, Et = i("h3", {
224
224
  _id: "aiChatWorkflowsLabel"
225
225
  }), Hn = P((t) => {
226
- const { aiChatSettings: e } = u();
226
+ const { aiChatSettings: e } = C();
227
227
  return /* @__PURE__ */ n(Et, { children: e.workflowsHeader, ...t });
228
228
  }), St = i("div", {
229
229
  _id: "aiChatWorkflowsList"
230
230
  }), Ln = P(
231
231
  (t) => {
232
- const { aiChatSettings: e } = u(), a = e.workflows, { children: s, ...o } = t;
232
+ const { aiChatSettings: e } = C(), a = e.workflows, { children: s, ...o } = t;
233
233
  return /* @__PURE__ */ n(St, { children: M(s, a), ...o });
234
234
  }
235
235
  ), kt = i("button", {
@@ -251,7 +251,7 @@ const ct = "__intro__", dt = i("div", {
251
251
  return e.role === "system" ? null : /* @__PURE__ */ n($e, { message: e, children: /* @__PURE__ */ n(Bt, { "data-role": e.role, ...a }) });
252
252
  }, Dn = P(
253
253
  (t) => {
254
- const { message: e, ...a } = t, { aiChatSettings: s, baseSettings: o } = u(), r = s.aiAssistantName, c = r ? `Hi, I'm ${r}!` : "Hi!", d = s.chatSubjectName ?? o.organizationDisplayName, m = `${c}
254
+ const { message: e, ...a } = t, { aiChatSettings: s, baseSettings: o } = C(), r = s.aiAssistantName, c = r ? `Hi, I'm ${r}!` : "Hi!", d = s.chatSubjectName ?? o.organizationDisplayName, m = `${c}
255
255
 
256
256
  I'm an AI assistant trained on documentation, help articles, and other content.`, l = d ? `
257
257
 
@@ -284,7 +284,7 @@ const ct = "__intro__", dt = i("div", {
284
284
  }, Lt = i(te.Root, {
285
285
  _id: "aiChatMessageAvatarContent"
286
286
  }), Rn = (t) => {
287
- const { message: e } = b(), { baseSettings: a } = u();
287
+ const { message: e } = b(), { baseSettings: a } = C();
288
288
  return /* @__PURE__ */ n(
289
289
  Lt,
290
290
  {
@@ -297,7 +297,7 @@ const ct = "__intro__", dt = i("div", {
297
297
  _id: "aiChatMessageAvatarFallback"
298
298
  }), $n = P(
299
299
  (t) => {
300
- const { baseSettings: e } = u(), { message: a } = b();
300
+ const { baseSettings: e } = C(), { message: a } = b();
301
301
  return e.userProperties.name ? /* @__PURE__ */ n(
302
302
  xt,
303
303
  {
@@ -314,7 +314,7 @@ const ct = "__intro__", dt = i("div", {
314
314
  const { onLoadingStatusChange: e, ...a } = t, {
315
315
  aiChatSettings: s,
316
316
  baseSettings: { userProperties: o }
317
- } = u(), { message: r } = b(), { aiAssistantAvatar: c } = s ?? {}, d = typeof c == "string" ? c : c?.light, m = (typeof c == "string" ? c : c?.dark) ?? d, l = tt(d, m), [C, v] = ge(l);
317
+ } = C(), { message: r } = b(), { aiAssistantAvatar: c } = s ?? {}, d = typeof c == "string" ? c : c?.light, m = (typeof c == "string" ? c : c?.dark) ?? d, l = tt(d, m), [u, v] = ge(l);
318
318
  Me(() => {
319
319
  v(l);
320
320
  }, [l]);
@@ -337,10 +337,10 @@ const ct = "__intro__", dt = i("div", {
337
337
  "data-role": r.role,
338
338
  ...t
339
339
  }
340
- ) : C ? /* @__PURE__ */ n(
340
+ ) : u ? /* @__PURE__ */ n(
341
341
  pe,
342
342
  {
343
- src: C,
343
+ src: u,
344
344
  alt: "AI assistant avatar",
345
345
  "data-type": "image",
346
346
  "data-role": r.role,
@@ -462,9 +462,9 @@ const ct = "__intro__", dt = i("div", {
462
462
  }, ve = i("div", {
463
463
  _id: "aiChatMessage"
464
464
  }), as = (t) => {
465
- const { aiChatSettings: e } = u(), { componentStyles: a, ...s } = t, { message: o } = b(), { logEvent: r } = q(), c = de(o), { conversation: d } = K();
465
+ const { aiChatSettings: e } = C(), { componentStyles: a, ...s } = t, { message: o } = b(), { logEvent: r } = W(), c = de(o), { conversation: d } = O();
466
466
  return o.role === "user" ? /* @__PURE__ */ n(ve, { "data-role": o.role, children: c, ...s }) : /* @__PURE__ */ n(ve, { "data-role": o.role, ...s, children: /* @__PURE__ */ n(
467
- U,
467
+ q,
468
468
  {
469
469
  children: c,
470
470
  componentStyles: a,
@@ -505,11 +505,17 @@ const ct = "__intro__", dt = i("div", {
505
505
  }), Yt = i("button", {
506
506
  _id: "aiChatMessageToolAction"
507
507
  }), os = (t) => {
508
- const { onClick: e, action: a, ...s } = t, { handleAction: o } = me(a), r = () => {
509
- o();
510
- }, c = a.label || "Contact Support", d = /* @__PURE__ */ $(Z, { children: [
508
+ const { onClick: e, action: a, ...s } = t, { handleAction: o } = me(a), { logEvent: r } = W(), { conversation: c } = O(), d = () => {
509
+ o(), r({
510
+ eventName: "user_escalation_indicated",
511
+ properties: {
512
+ escalationType: "contact_us",
513
+ conversation: c
514
+ }
515
+ });
516
+ }, m = a.label || "Contact Support", l = /* @__PURE__ */ V(Z, { children: [
511
517
  a.icon && /* @__PURE__ */ n(B, { iconSettings: a.icon }),
512
- c
518
+ m
513
519
  ] });
514
520
  return a.action.type === "open_link" ? /* @__PURE__ */ n(
515
521
  zt,
@@ -518,25 +524,25 @@ const ct = "__intro__", dt = i("div", {
518
524
  target: "_blank",
519
525
  rel: "noopener",
520
526
  "data-type": a.action.type,
521
- onClick: h(e, r),
522
- children: d,
527
+ onClick: h(e, d),
528
+ children: l,
523
529
  ...s
524
530
  }
525
531
  ) : /* @__PURE__ */ n(
526
532
  Yt,
527
533
  {
528
534
  "data-type": a.action.type,
529
- onClick: h(e, r),
530
- children: d,
535
+ onClick: h(e, d),
536
+ children: l,
531
537
  ...s
532
538
  }
533
539
  );
534
540
  }, Jt = i("button", {
535
541
  _id: "aiChatMessageAction"
536
542
  }), rs = (t) => {
537
- const { action: e, onClick: a, className: s, ...o } = t, { conversation: r } = K(), { message: c } = b(), { isStreaming: d, messages: m } = g(), [l, C] = X(), { feedback: v, submitPositiveFeedback: I, setCurrentFeedback: T, currentFeedback: O } = re(), { logEvent: G } = q(), [W, z] = qe(), {
543
+ const { action: e, onClick: a, className: s, ...o } = t, { conversation: r } = O(), { message: c } = b(), { isStreaming: d, messages: m } = g(), [l, u] = X(), { feedback: v, submitPositiveFeedback: I, setCurrentFeedback: T, currentFeedback: N } = re(), { logEvent: G } = W(), [R, z] = qe(), {
538
544
  baseSettings: { privacyPreferences: he }
539
- } = u(), { optOutAllAnalytics: Y } = he, ue = m.at(-1)?.id === c?.id, J = c.role === "assistant";
545
+ } = C(), { optOutAllAnalytics: Y } = he, ue = m.at(-1)?.id === c?.id, J = c.role === "assistant";
540
546
  if (ue && d || !J || {
541
547
  copy: !1,
542
548
  upvote: Y,
@@ -544,7 +550,7 @@ const ct = "__intro__", dt = i("div", {
544
550
  }[e]) return null;
545
551
  const y = {
546
552
  copy() {
547
- C(de(c)), G({
553
+ u(de(c)), G({
548
554
  eventName: "assistant_message_copied",
549
555
  properties: {
550
556
  conversation: r
@@ -565,7 +571,7 @@ const ct = "__intro__", dt = i("div", {
565
571
  downvote: "Downvote Message"
566
572
  }, f = {
567
573
  copy: /* @__PURE__ */ n(A, { iconKey: l ? "messageCopied" : "messageCopy" }),
568
- upvote: /* @__PURE__ */ n(A, { iconKey: W ? "messageCopied" : "thumbsUp" }),
574
+ upvote: /* @__PURE__ */ n(A, { iconKey: R ? "messageCopied" : "thumbsUp" }),
569
575
  downvote: /* @__PURE__ */ n(A, { iconKey: "thumbsDown" })
570
576
  }, E = {
571
577
  copy: { "data-copied": p(l) },
@@ -574,7 +580,7 @@ const ct = "__intro__", dt = i("div", {
574
580
  },
575
581
  downvote: {
576
582
  "data-downvoted": p(v[c.id]?.type === "negative"),
577
- "data-state": O === null ? "closed" : "open"
583
+ "data-state": N === null ? "closed" : "open"
578
584
  }
579
585
  };
580
586
  return /* @__PURE__ */ n(
@@ -603,21 +609,21 @@ const ct = "__intro__", dt = i("div", {
603
609
  baseSettings: { transformSource: o, organizationDisplayName: r },
604
610
  aiChatSettings: { shouldOpenLinksInNewTab: c },
605
611
  searchSettings: { tabs: d }
606
- } = u();
612
+ } = C();
607
613
  if (e.role !== "assistant") return null;
608
614
  const m = e.links.map((l) => {
609
- const C = nt(l, "chatSourceItem", {
615
+ const u = nt(l, "chatSourceItem", {
610
616
  organizationDisplayName: r,
611
617
  tabs: d,
612
618
  transformSource: o
613
- }), v = C.shouldOpenInNewTab !== void 0 ? C.shouldOpenInNewTab : c;
614
- return { ...C, isExternal: v };
619
+ }), v = u.shouldOpenInNewTab !== void 0 ? u.shouldOpenInNewTab : c;
620
+ return { ...u, isExternal: v };
615
621
  });
616
622
  return /* @__PURE__ */ n(ei, { children: M(a, m), ...s });
617
623
  }, ti = i(De, {
618
624
  _id: "aiChatMessageSourceItem"
619
625
  }), ls = (t) => {
620
- const { source: e, onClick: a, ...s } = t, { logEvent: o } = q(), { conversation: r } = K(), c = () => {
626
+ const { source: e, onClick: a, ...s } = t, { logEvent: o } = W(), { conversation: r } = O(), c = () => {
621
627
  o({
622
628
  eventName: "assistant_source_item_clicked",
623
629
  properties: {
@@ -704,8 +710,8 @@ const ct = "__intro__", dt = i("div", {
704
710
  _id: "aiChatInput__Group"
705
711
  }), di = i("textarea", {
706
712
  _id: "aiChatInput"
707
- }), Ms = Q(({ onChange: t, onKeyDown: e, ...a }, s) => {
708
- const { handleInputChange: o, handleInputKeyDown: r, input: c, error: d, shouldAutoFocusInput: m, inputRef: l } = g(), { aiChatSettings: C } = u(), v = le(
713
+ }), Ms = U(({ onChange: t, onKeyDown: e, ...a }, s) => {
714
+ const { handleInputChange: o, handleInputKeyDown: r, input: c, error: d, shouldAutoFocusInput: m, inputRef: l } = g(), { aiChatSettings: u } = C(), v = le(
709
715
  s,
710
716
  l
711
717
  );
@@ -715,11 +721,11 @@ const ct = "__intro__", dt = i("div", {
715
721
  asChild: !0,
716
722
  ref: v,
717
723
  maxLength: 99999,
718
- placeholder: C.placeholder,
724
+ placeholder: u.placeholder,
719
725
  value: c,
720
726
  onChange: h(t, o),
721
727
  onKeyDown: h(e, r),
722
- disabled: !!d || C.isViewOnly,
728
+ disabled: !!d || u.isViewOnly,
723
729
  ...a,
724
730
  children: /* @__PURE__ */ n(ee, {})
725
731
  }
@@ -727,7 +733,7 @@ const ct = "__intro__", dt = i("div", {
727
733
  }), mi = i("button", {
728
734
  _id: "aiChatInput__SendButton"
729
735
  }), Is = (t) => {
730
- const { handleSubmit: e, isSubmitDisabled: a, error: s } = g(), { aiChatSettings: o } = u(), { onClick: r, ...c } = t;
736
+ const { handleSubmit: e, isSubmitDisabled: a, error: s } = g(), { aiChatSettings: o } = C(), { onClick: r, ...c } = t;
731
737
  return /* @__PURE__ */ n(
732
738
  mi,
733
739
  {
@@ -795,7 +801,7 @@ const ct = "__intro__", dt = i("div", {
795
801
  side: "bottom",
796
802
  sideOffset: 3,
797
803
  align: "center",
798
- children: /* @__PURE__ */ $(Z, { children: [
804
+ children: /* @__PURE__ */ V(Z, { children: [
799
805
  /* @__PURE__ */ n(gi, {}),
800
806
  "Attachments will be kept in context for the entire conversation."
801
807
  ] })
@@ -991,11 +997,11 @@ const ct = "__intro__", dt = i("div", {
991
997
  }), yi = i(k.Trigger, {
992
998
  _id: "aiChat__ChatAction"
993
999
  }), Pe = (t) => {
994
- const { action: e, onClick: a, className: s, ...o } = t, { clear: r, stop: c, isLoading: d, messages: m, selectedWorkflow: l } = g(), { conversation: C } = K(), { aiChatSettings: v, baseSettings: I } = u(), { logEvent: T } = q(), [O, G] = X(), [W, z] = X();
1000
+ const { action: e, onClick: a, className: s, ...o } = t, { clear: r, stop: c, isLoading: d, messages: m, selectedWorkflow: l } = g(), { conversation: u } = O(), { aiChatSettings: v, baseSettings: I } = C(), { logEvent: T } = W(), [N, G] = X(), [R, z] = X();
995
1001
  if ({
996
1002
  help: !1,
997
1003
  copy: m.length === 0 || !v.isCopyChatButtonVisible || d,
998
- share: m.length === 0 || !v.isShareButtonVisible || !C.id || !!l || d,
1004
+ share: m.length === 0 || !v.isShareButtonVisible || !u.id || !!l || d,
999
1005
  clear: m.length === 0 || v.isViewOnly || d,
1000
1006
  stop: !d
1001
1007
  }[e]) return null;
@@ -1004,28 +1010,28 @@ const ct = "__intro__", dt = i("div", {
1004
1010
  help: () => {
1005
1011
  },
1006
1012
  copy: () => {
1007
- const N = m.map((y) => {
1008
- const L = `**${y.role === "assistant" ? "AI Assistant" : "User"}**`, f = de(y), E = Ve(y.metadata?.attributes?.attachments), R = E ? `
1013
+ const $ = m.map((y) => {
1014
+ const L = `**${y.role === "assistant" ? "AI Assistant" : "User"}**`, f = de(y), E = Ve(y.metadata?.attributes?.attachments), Q = E ? `
1009
1015
 
1010
1016
  **Attachments**
1011
1017
 
1012
1018
  ${E}` : "";
1013
1019
  return `${L}
1014
1020
 
1015
- ${f}${R}`;
1021
+ ${f}${Q}`;
1016
1022
  }).join(`
1017
1023
 
1018
1024
  ---
1019
1025
 
1020
1026
  `);
1021
- G(N);
1027
+ G($);
1022
1028
  },
1023
1029
  share: async () => {
1024
- const N = {
1030
+ const $ = {
1025
1031
  visibility: "public",
1026
1032
  tags: [],
1027
1033
  userProperties: {},
1028
- messages: C.messages.map((E) => ({
1034
+ messages: u.messages.map((E) => ({
1029
1035
  ...E,
1030
1036
  createdAt: void 0,
1031
1037
  updatedAt: void 0,
@@ -1034,18 +1040,18 @@ ${f}${R}`;
1034
1040
  }))
1035
1041
  }, { apiKey: y, analyticsApiBaseUrl: L } = I, f = await at(
1036
1042
  "",
1037
- N,
1043
+ $,
1038
1044
  y,
1039
1045
  L
1040
1046
  );
1041
1047
  if (f) {
1042
- const R = `${v.shareChatUrlBasePath}?${Ne}=${f?.id}`;
1043
- z(R), T({
1048
+ const Q = `${v.shareChatUrlBasePath}?${Ne}=${f?.id}`;
1049
+ z(Q), T({
1044
1050
  eventName: "chat_share_button_clicked",
1045
1051
  properties: {
1046
1052
  sharedConversationId: f?.id,
1047
- originalConversationId: C.id,
1048
- sharedChatUrl: R,
1053
+ originalConversationId: u.id,
1054
+ sharedChatUrl: Q,
1049
1055
  conversation: f
1050
1056
  }
1051
1057
  });
@@ -1054,14 +1060,14 @@ ${f}${R}`;
1054
1060
  clear: r,
1055
1061
  stop: c
1056
1062
  }, Ce = {
1057
- copy: O,
1058
- share: W
1063
+ copy: N,
1064
+ share: R
1059
1065
  };
1060
1066
  return /* @__PURE__ */ n(k.Tooltip, { delayDuration: 0, open: Ce[e], children: /* @__PURE__ */ n(
1061
1067
  yi,
1062
1068
  {
1063
1069
  "data-type": e,
1064
- "data-copied": p(O || W),
1070
+ "data-copied": p(N || R),
1065
1071
  className: `${s} ${e}`,
1066
1072
  children: /* @__PURE__ */ n(Hi, { action: e }),
1067
1073
  onClick: h(a, J[e]),
@@ -1071,7 +1077,7 @@ ${f}${R}`;
1071
1077
  }, wi = i("span", {
1072
1078
  _id: "aiChat__ChatActionLabel"
1073
1079
  }), Hi = (t) => {
1074
- const { action: e, ...a } = t, { aiChatSettings: s } = u(), o = s.toolbarButtonLabels ?? {}, r = {
1080
+ const { action: e, ...a } = t, { aiChatSettings: s } = C(), o = s.toolbarButtonLabels ?? {}, r = {
1075
1081
  help: o.getHelp ?? "Get Help",
1076
1082
  copy: o.copyChat ?? "Copy",
1077
1083
  share: o.share ?? "Share",
@@ -1086,20 +1092,20 @@ ${f}${R}`;
1086
1092
  copy: "Copied!",
1087
1093
  share: "Link copied!"
1088
1094
  };
1089
- return /* @__PURE__ */ $(Li, { sideOffset: 5, ...s, children: [
1095
+ return /* @__PURE__ */ V(Li, { sideOffset: 5, ...s, children: [
1090
1096
  /* @__PURE__ */ n(k.Arrow, {}),
1091
1097
  a || o[e]
1092
1098
  ] });
1093
1099
  }, xi = i(S.Root, {
1094
1100
  _id: "aiChatHelpActions"
1095
1101
  }), lo = (t) => {
1096
- const { children: e, ...a } = t, { aiChatSettings: s } = u(), { getHelpOptions: o } = s;
1102
+ const { children: e, ...a } = t, { aiChatSettings: s } = C(), { getHelpOptions: o } = s;
1097
1103
  if (!o || (o ?? []).length === 0)
1098
1104
  return null;
1099
1105
  const { _pinned: r, _unpinned: c } = o.reduce(
1100
- (C, v) => {
1106
+ (u, v) => {
1101
1107
  const I = v.isPinnedToToolbar ? "_pinned" : "_unpinned";
1102
- return { ...C, [I]: [...C[I], v] };
1108
+ return { ...u, [I]: [...u[I], v] };
1103
1109
  },
1104
1110
  { _pinned: [], _unpinned: [] }
1105
1111
  ), d = c.length === 1 ? [...r, c[0]] : r, m = c.length === 1 ? [] : c, l = Ge();
@@ -1135,7 +1141,7 @@ ${f}${R}`;
1135
1141
  _id: "aiChatHelpActions__Trigger"
1136
1142
  }), uo = P(
1137
1143
  (t) => {
1138
- const { aiChatSettings: e } = u();
1144
+ const { aiChatSettings: e } = C();
1139
1145
  return /* @__PURE__ */ n(Pe, { action: "help", ...t, asChild: !0, children: /* @__PURE__ */ n(Wi, { children: e.toolbarButtonLabels?.getHelp ?? "Get Help" }) });
1140
1146
  }
1141
1147
  ), Ni = i(S.Content, {
@@ -1206,15 +1212,15 @@ ${f}${R}`;
1206
1212
  const { onSubmit: e, ...a } = t, { submitNegativeFeedback: s, currentFeedback: o, setCurrentFeedback: r } = re();
1207
1213
  return /* @__PURE__ */ n(Qi, { onSubmit: h(e, (d) => {
1208
1214
  d.preventDefault();
1209
- const m = d.target, l = new FormData(m), C = Object.fromEntries(l.entries());
1210
- o && (s(o, C), r(null));
1215
+ const m = d.target, l = new FormData(m), u = Object.fromEntries(l.entries());
1216
+ o && (s(o, u), r(null));
1211
1217
  }), ...a });
1212
1218
  }, Vi = i("div", {
1213
1219
  _id: "aiChatFeedbackItem"
1214
1220
  }), fo = (t) => {
1215
1221
  const { name: e, ...a } = t;
1216
1222
  return /* @__PURE__ */ n(Qe, { name: e, children: /* @__PURE__ */ n(Vi, { ...a }) });
1217
- }, Ui = i(V.Root, {
1223
+ }, Ui = i(K.Root, {
1218
1224
  _id: "aiChatFeedbackItem__Checkbox"
1219
1225
  }), Eo = (t) => {
1220
1226
  const { name: e, focusItem: a } = ce(), { onCheckedChange: s, ...o } = t, r = (c) => {
@@ -1229,7 +1235,7 @@ ${f}${R}`;
1229
1235
  ...o
1230
1236
  }
1231
1237
  );
1232
- }, So = i(V.Indicator, {
1238
+ }, So = i(K.Indicator, {
1233
1239
  _id: "aiChatFeedbackItem__CheckboxIndicator",
1234
1240
  children: /* @__PURE__ */ n(_e, {})
1235
1241
  }), Ki = i("label", {
@@ -1282,7 +1288,7 @@ ${f}${R}`;
1282
1288
  }), xo = (t) => {
1283
1289
  const { form: e } = _();
1284
1290
  return e?.heading ? /* @__PURE__ */ n(Yi, { children: e.heading, ...t }) : null;
1285
- }, Ji = i(U, {
1291
+ }, Ji = i(q, {
1286
1292
  _id: "aiChatForm__Description"
1287
1293
  }), Do = (t) => {
1288
1294
  const { form: e } = _();
@@ -1373,7 +1379,7 @@ ${f}${R}`;
1373
1379
  error: a,
1374
1380
  fieldProps: { value: s, onChange: o, onBlur: r, ...c },
1375
1381
  autoFocus: d
1376
- } = H(), { onChange: m, onBlur: l, ...C } = t, v = (I) => {
1382
+ } = H(), { onChange: m, onBlur: l, ...u } = t, v = (I) => {
1377
1383
  const T = I.target.files;
1378
1384
  o(T);
1379
1385
  };
@@ -1384,7 +1390,7 @@ ${f}${R}`;
1384
1390
  autoFocus: d,
1385
1391
  "data-value": s,
1386
1392
  "data-invalid": p(!!a),
1387
- ...C,
1393
+ ...u,
1388
1394
  ...c,
1389
1395
  onChange: h(m, v),
1390
1396
  onBlur: h(l, r)
@@ -1395,7 +1401,7 @@ ${f}${R}`;
1395
1401
  type: "textarea",
1396
1402
  asChild: !0,
1397
1403
  children: /* @__PURE__ */ n(ee, { maxRows: 8 })
1398
- }), aa = i(V.Root, {
1404
+ }), aa = i(K.Root, {
1399
1405
  _id: "aiChatForm__FieldCheckbox"
1400
1406
  }), Vo = (t) => {
1401
1407
  const { field: e, error: a, fieldProps: s, autoFocus: o } = H(), { onCheckedChange: r, ...c } = t;
@@ -1411,7 +1417,7 @@ ${f}${R}`;
1411
1417
  ...c
1412
1418
  }
1413
1419
  );
1414
- }, Uo = i(V.Indicator, {
1420
+ }, Uo = i(K.Indicator, {
1415
1421
  _id: "aiChatForm__FieldCheckboxIndicator",
1416
1422
  children: /* @__PURE__ */ n(_e, {})
1417
1423
  }), na = i(we, {
@@ -1497,7 +1503,7 @@ ${f}${R}`;
1497
1503
  }), or = (t) => {
1498
1504
  const { form: e } = _();
1499
1505
  return /* @__PURE__ */ n(la, { children: e?.successView?.heading, ...t });
1500
- }, ha = i(U, {
1506
+ }, ha = i(q, {
1501
1507
  _id: "aiChatForm__SuccessMessage"
1502
1508
  }), rr = (t) => {
1503
1509
  const { form: e } = _();
@@ -1512,7 +1518,7 @@ ${f}${R}`;
1512
1518
  ua,
1513
1519
  {
1514
1520
  onClick: h(e, o),
1515
- children: /* @__PURE__ */ $(Z, { children: [
1521
+ children: /* @__PURE__ */ V(Z, { children: [
1516
1522
  c,
1517
1523
  d
1518
1524
  ] }),
package/dist/index.d.cts CHANGED
@@ -398,7 +398,7 @@ export declare type ChatEventsContextValue = {
398
398
  * Pass messages if you want it to also log a conversation.
399
399
  * The conversation will be appended to the event properties.
400
400
  */
401
- logEvent: (event: InkeepEvent, messages?: Message[]) => void;
401
+ logEvent: (event: InkeepEvent, messages?: Message[]) => Promise<void>;
402
402
  /**
403
403
  * Log a conversation.
404
404
  */
@@ -4311,7 +4311,7 @@ export declare const useChatForm: () => ChatFormContextValue;
4311
4311
 
4312
4312
  export declare function useChatFormState(): {
4313
4313
  form: AIChatFormSettings | null;
4314
- openForm: (formSettings: AIChatFormSettings) => void;
4314
+ openForm: (formSettings: AIChatFormSettings, getHelpOption?: GetHelpOption) => void;
4315
4315
  closeForm: () => void;
4316
4316
  handleSubmit: (e?: React.BaseSyntheticEvent) => Promise<void>;
4317
4317
  isSuccess: boolean;
package/dist/index.d.ts CHANGED
@@ -398,7 +398,7 @@ export declare type ChatEventsContextValue = {
398
398
  * Pass messages if you want it to also log a conversation.
399
399
  * The conversation will be appended to the event properties.
400
400
  */
401
- logEvent: (event: InkeepEvent, messages?: Message[]) => void;
401
+ logEvent: (event: InkeepEvent, messages?: Message[]) => Promise<void>;
402
402
  /**
403
403
  * Log a conversation.
404
404
  */
@@ -4311,7 +4311,7 @@ export declare const useChatForm: () => ChatFormContextValue;
4311
4311
 
4312
4312
  export declare function useChatFormState(): {
4313
4313
  form: AIChatFormSettings | null;
4314
- openForm: (formSettings: AIChatFormSettings) => void;
4314
+ openForm: (formSettings: AIChatFormSettings, getHelpOption?: GetHelpOption) => void;
4315
4315
  closeForm: () => void;
4316
4316
  handleSubmit: (e?: React.BaseSyntheticEvent) => Promise<void>;
4317
4317
  isSuccess: boolean;
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react/jsx-runtime"),t=require("react"),f=require("../atoms/api/analytics/events.cjs"),b=require("./config-provider.cjs"),x=require("./user-provider.cjs"),E=t.createContext(void 0),q=({children:e})=>{const{baseSettings:s,componentType:r}=b.useInkeepConfig(),{apiKey:i,analyticsApiBaseUrl:c,tags:a,privacyPreferences:m,env:g,analyticsProperties:v}=s,{userProperties:u}=x.useUser(),l=t.useMemo(()=>({widgetLibraryVersion:"0.5.95",componentType:r,tags:a}),[r,a]),d=!m.optOutAllAnalytics&&g!=="development",P={logEvent:t.useCallback(async n=>{const o={...l,...n.properties,...v},p={eventName:n.eventName,properties:o,userProperties:u},y=["modal_opened","modal_closed"].includes(n.eventName);if(d&&!y){if("conversation"in o&&!o.conversation?.id)return;f.logEvent(p,i,c)}s.onEvent?.(p)},[d,s,i,c,u,l,v])};return B.jsx(E.Provider,{value:P,children:e})},C=()=>{const e=t.useContext(E);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsProvider=q;exports.useBaseEvents=C;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react/jsx-runtime"),t=require("react"),f=require("../atoms/api/analytics/events.cjs"),b=require("./config-provider.cjs"),x=require("./user-provider.cjs"),E=t.createContext(void 0),q=({children:e})=>{const{baseSettings:s,componentType:r}=b.useInkeepConfig(),{apiKey:i,analyticsApiBaseUrl:c,tags:a,privacyPreferences:m,env:g,analyticsProperties:v}=s,{userProperties:u}=x.useUser(),l=t.useMemo(()=>({widgetLibraryVersion:"0.5.96",componentType:r,tags:a}),[r,a]),d=!m.optOutAllAnalytics&&g!=="development",P={logEvent:t.useCallback(async n=>{const o={...l,...n.properties,...v},p={eventName:n.eventName,properties:o,userProperties:u},y=["modal_opened","modal_closed"].includes(n.eventName);if(d&&!y){if("conversation"in o&&!o.conversation?.id)return;f.logEvent(p,i,c)}s.onEvent?.(p)},[d,s,i,c,u,l,v])};return B.jsx(E.Provider,{value:P,children:e})},C=()=>{const e=t.useContext(E);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsProvider=q;exports.useBaseEvents=C;
@@ -7,7 +7,7 @@ import { useUser as A } from "./user-provider.js";
7
7
  const u = B(void 0), $ = ({ children: e }) => {
8
8
  const { baseSettings: t, componentType: s } = w(), { apiKey: r, analyticsApiBaseUrl: i, tags: a, privacyPreferences: d, env: E, analyticsProperties: c } = t, { userProperties: v } = A(), p = P(
9
9
  () => ({
10
- widgetLibraryVersion: "0.5.95",
10
+ widgetLibraryVersion: "0.5.96",
11
11
  componentType: s,
12
12
  tags: a
13
13
  }),
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react/jsx-runtime"),e=require("react"),R=require("../atoms/api/analytics/conversation.cjs"),U=require("./config-provider.cjs"),A=require("./conversation-provider.cjs"),O=require("./user-provider.cjs"),m=require("./base-events-provider.cjs"),B=require("../utils/generate-uid.cjs"),x=e.createContext(void 0),K=({children:o})=>{const{baseSettings:w,aiChatSettings:I}=U.useInkeepConfig(),{apiKey:p,analyticsApiBaseUrl:E,tags:f,privacyPreferences:{optOutAllAnalytics:a},env:c,analyticsProperties:v}=w,{conversationVisibility:g}=I,{userProperties:P}=O.useUser(),{logEvent:y}=m.useBaseEvents(),{conversation:u,setConversation:S,chatId:d,isSharedChat:l,setExternalChatId:b}=A.useInkeepConversation(),i=e.useRef(u),C=e.useRef(l?d:void 0);e.useEffect(()=>{i.current=u},[u]),e.useEffect(()=>{C.current=l?d:void 0},[d,l]);const h=e.useCallback(async r=>{const t=i.current;C.current&&(t.id="",b(void 0),C.current=void 0);const n=!a&&c!=="development";let s=Object.assign({},t,{messages:r});if(n){const q=await R.logConversation(t.id,{messages:r,tags:f,userProperties:P,properties:v,visibility:g},p,E);q&&(s=q)}else s.id="conv_"+B.generateUid(16);return s},[E,p,f,P,a,c,v,b,g]),j={logEvent:e.useCallback(async(r,t)=>{let n=i.current;t&&(n=await h(t),S(n),i.current=n);const s={...r,properties:{conversation:n,...r.properties}};y(s)},[y,h,a,c,v]),logConversation:h};return k.jsx(x.Provider,{value:j,children:o})},L=()=>{const o=e.useContext(x);if(!o)throw new Error("useChatEvents must be used within a ChatEventsProvider");return o};exports.ChatEventsProvider=K;exports.useChatEvents=L;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("react/jsx-runtime"),t=require("react"),A=require("../atoms/api/analytics/conversation.cjs"),L=require("./config-provider.cjs"),O=require("./conversation-provider.cjs"),m=require("./user-provider.cjs"),B=require("./base-events-provider.cjs"),M=require("../utils/generate-uid.cjs"),x=t.createContext(void 0),K=({children:a})=>{const{baseSettings:w,aiChatSettings:I}=L.useInkeepConfig(),{apiKey:E,analyticsApiBaseUrl:g,tags:f,privacyPreferences:{optOutAllAnalytics:c},env:v,analyticsProperties:u}=w,{conversationVisibility:P}=I,{userProperties:y}=m.useUser(),{logEvent:b}=B.useBaseEvents(),{conversation:d,setConversation:S,chatId:l,isSharedChat:C,setExternalChatId:q}=O.useInkeepConversation(),o=t.useRef(d),h=t.useRef(C?l:void 0);t.useEffect(()=>{o.current=d},[d]),t.useEffect(()=>{h.current=C?l:void 0},[l,C]);const p=t.useCallback(async r=>{const e=o.current;h.current&&(e.id="",q(void 0),h.current=void 0);const n=!c&&v!=="development";let s=Object.assign({},e,{messages:r});if(n){const i=await A.logConversation(e.id,{messages:r,tags:f,userProperties:y,properties:u,visibility:P},E,g);i&&(s=i)}else s.id="conv_"+M.generateUid(16);return s},[g,E,f,y,c,v,u,q,P]),j={logEvent:t.useCallback(async(r,e)=>{let n=o.current;if(e){const i=o.current.messages||[];(e.length!==i.length||e.some((k,R)=>k.id!==i[R]?.id))&&(n=await p(e),S(n),o.current=n)}const s={...r,properties:{conversation:n,...r.properties}};b(s)},[b,p,c,v,u]),logConversation:p};return U.jsx(x.Provider,{value:j,children:a})},T=()=>{const a=t.useContext(x);if(!a)throw new Error("useChatEvents must be used within a ChatEventsProvider");return a};exports.ChatEventsProvider=K;exports.useChatEvents=T;