@inkeep/agents-ui 0.14.9 → 0.14.11

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 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),T=require("react"),p=require("@radix-ui/primitive"),P=require("@radix-ui/react-compose-refs"),H=require("@radix-ui/react-context"),C=require("@radix-ui/react-id"),z=require("@radix-ui/react-use-controllable-state"),B=require("@radix-ui/react-dismissable-layer"),K=require("@zag-js/focus-trap"),U=require("@radix-ui/react-portal"),_=require("@radix-ui/react-presence"),g=require("@radix-ui/react-primitive"),V=require("@radix-ui/react-focus-guards"),Y=require("react-remove-scroll"),Z=require("aria-hidden"),J=require("@radix-ui/react-slot");function Q(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,s.get?s:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const c=Q(T),x="Dialog",[N,W]=H.createContextScope(x),[X,l]=N(x),O=e=>{const{__scopeDialog:n,children:t,open:s,defaultOpen:o,onOpenChange:r,modal:a=!0}=e,u=c.useRef(null),f=c.useRef(null),[R=!1,m]=z.useControllableState({prop:s,defaultProp:o??!1,onChange:r});return i.jsx(X,{scope:n,triggerRef:u,contentRef:f,contentId:C.useId(),titleId:C.useId(),descriptionId:C.useId(),open:R,onOpenChange:m,onOpenToggle:c.useCallback(()=>m(G=>!G),[m]),modal:a,children:t})};O.displayName=x;const M="DialogTrigger",S=c.forwardRef((e,n)=>{const{__scopeDialog:t,...s}=e,o=l(M,t),r=P.useComposedRefs(n,o.triggerRef);return i.jsx(g.Primitive.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":j(o.open),...s,ref:r,onClick:p.composeEventHandlers(e.onClick,o.onOpenToggle)})});S.displayName=M;const v="DialogPortal",[$,q]=N(v,{forceMount:void 0}),y=e=>{const{__scopeDialog:n,forceMount:t,children:s,container:o}=e,r=l(v,n);return i.jsx($,{scope:n,forceMount:t,children:c.Children.map(s,a=>i.jsx(_.Presence,{present:t||r.open,children:i.jsx(U.Portal,{asChild:!0,container:o,children:a})}))})};y.displayName=v;const D="DialogOverlay",E=c.forwardRef((e,n)=>{const t=q(D,e.__scopeDialog),{forceMount:s=t.forceMount,...o}=e,r=l(D,e.__scopeDialog);return r.modal?i.jsx(_.Presence,{present:s||r.open,children:i.jsx(ee,{...o,ref:n})}):null});E.displayName=D;const ee=c.forwardRef((e,n)=>{const{__scopeDialog:t,...s}=e,o=l(D,t);return i.jsx(Y.RemoveScroll,{as:J.Slot,allowPinchZoom:!0,shards:[o.contentRef],gapMode:"padding",removeScrollBar:!0,children:i.jsx(g.Primitive.div,{"data-state":j(o.open),...s,ref:n,style:{pointerEvents:"auto",...s.style}})})}),d="DialogContent",b=c.forwardRef((e,n)=>{const t=q(d,e.__scopeDialog),{forceMount:s=t.forceMount,...o}=e,r=l(d,e.__scopeDialog);return i.jsx(_.Presence,{present:s||r.open,children:r.modal?i.jsx(te,{...o,ref:n}):i.jsx(oe,{...o,ref:n})})});b.displayName=d;const te=c.forwardRef((e,n)=>{const t=l(d,e.__scopeDialog),s=c.useRef(null),o=P.useComposedRefs(n,t.contentRef,s);return c.useEffect(()=>{const r=s.current;if(r)return Z.hideOthers(r)},[]),i.jsx(w,{...e,ref:o,trapFocus:t.open,disableOutsidePointerEvents:!0,onPointerDownOutside:p.composeEventHandlers(e.onPointerDownOutside,r=>{const a=r.detail.originalEvent,u=a.button===0&&a.ctrlKey===!0;(a.button===2||u)&&r.preventDefault()}),onFocusOutside:p.composeEventHandlers(e.onFocusOutside,r=>r.preventDefault())})}),oe=c.forwardRef((e,n)=>{const t=l(d,e.__scopeDialog),s=c.useRef(!1),o=c.useRef(!1);return i.jsx(w,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onInteractOutside:r=>{e.onInteractOutside?.(r),r.defaultPrevented||(s.current=!0,r.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=r.target;t.triggerRef.current?.contains(a)&&r.preventDefault(),r.detail.originalEvent.type==="focusin"&&o.current&&r.preventDefault()}})}),w=c.forwardRef((e,n)=>{const{__scopeDialog:t,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:r,...a}=e,u=l(d,t),f=c.useRef(null),R=P.useComposedRefs(n,f);return V.useFocusGuards(),T.useEffect(()=>{if(s)return K.trapFocus(f.current,{preventScroll:!0,onActivate:o,onDeactivate:r,initialFocus:!1})},[]),i.jsx(B.DismissableLayer,{role:"dialog",id:u.contentId,"aria-describedby":u.descriptionId,"aria-labelledby":u.titleId,"data-state":j(u.open),...a,ref:R,onDismiss:()=>u.onOpenChange(!1)})}),A="DialogTitle",h=c.forwardRef((e,n)=>{const{__scopeDialog:t,...s}=e,o=l(A,t);return i.jsx(g.Primitive.h2,{id:o.titleId,...s,ref:n})});h.displayName=A;const F="DialogDescription",k=c.forwardRef((e,n)=>{const{__scopeDialog:t,...s}=e,o=l(F,t);return i.jsx(g.Primitive.p,{id:o.descriptionId,...s,ref:n})});k.displayName=F;const L="DialogClose",I=c.forwardRef((e,n)=>{const{__scopeDialog:t,...s}=e,o=l(L,t);return i.jsx(g.Primitive.button,{type:"button",...s,ref:n,onClick:p.composeEventHandlers(e.onClick,()=>o.onOpenChange(!1))})});I.displayName=L;function j(e){return e?"open":"closed"}const ne=O,re=y,se=E,ce=b,ie=h,ae=I;exports.Close=ae;exports.Content=ce;exports.Dialog=O;exports.DialogClose=I;exports.DialogContent=b;exports.DialogDescription=k;exports.DialogOverlay=E;exports.DialogPortal=y;exports.DialogTitle=h;exports.DialogTrigger=S;exports.Overlay=se;exports.Portal=re;exports.Root=ne;exports.Title=ie;exports.createDialogScope=W;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),T=require("react"),m=require("@radix-ui/primitive"),P=require("@radix-ui/react-compose-refs"),H=require("@radix-ui/react-context"),R=require("@radix-ui/react-id"),W=require("@radix-ui/react-use-controllable-state"),z=require("@radix-ui/react-dismissable-layer"),B=require("@zag-js/focus-trap"),K=require("@radix-ui/react-portal"),_=require("@radix-ui/react-presence"),f=require("@radix-ui/react-primitive"),U=require("@radix-ui/react-focus-guards"),V=require("react-remove-scroll"),Y=require("aria-hidden"),Z=require("@radix-ui/react-slot");function J(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const s=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(r,o,s.get?s:{enumerable:!0,get:()=>e[o]})}}return r.default=e,Object.freeze(r)}const c=J(T),x="Dialog",[N,Q]=H.createContextScope(x),[X,l]=N(x),O=e=>{const{__scopeDialog:r,children:o,open:s,defaultOpen:n,onOpenChange:t,modal:a=!0}=e,u=c.useRef(null),p=c.useRef(null),[g=!1,D]=W.useControllableState({prop:s,defaultProp:n??!1,onChange:t});return i.jsx(X,{scope:r,triggerRef:u,contentRef:p,contentId:R.useId(),titleId:R.useId(),descriptionId:R.useId(),open:g,onOpenChange:D,onOpenToggle:c.useCallback(()=>D(G=>!G),[D]),modal:a,children:o})};O.displayName=x;const M="DialogTrigger",S=c.forwardRef((e,r)=>{const{__scopeDialog:o,...s}=e,n=l(M,o),t=P.useComposedRefs(r,n.triggerRef);return i.jsx(f.Primitive.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":j(n.open),...s,ref:t,onClick:m.composeEventHandlers(e.onClick,n.onOpenToggle)})});S.displayName=M;const v="DialogPortal",[$,q]=N(v,{forceMount:void 0}),y=e=>{const{__scopeDialog:r,forceMount:o,children:s,container:n}=e,t=l(v,r);return i.jsx($,{scope:r,forceMount:o,children:c.Children.map(s,a=>i.jsx(_.Presence,{present:o||t.open,children:i.jsx(K.Portal,{asChild:!0,container:n,children:a})}))})};y.displayName=v;const C="DialogOverlay",E=c.forwardRef((e,r)=>{const o=q(C,e.__scopeDialog),{forceMount:s=o.forceMount,...n}=e,t=l(C,e.__scopeDialog);return t.modal?i.jsx(_.Presence,{present:s||t.open,children:i.jsx(ee,{...n,ref:r})}):null});E.displayName=C;const ee=c.forwardRef((e,r)=>{const{__scopeDialog:o,...s}=e,n=l(C,o);return i.jsx(V.RemoveScroll,{as:Z.Slot,allowPinchZoom:!0,shards:[n.contentRef],gapMode:"padding",removeScrollBar:!0,children:i.jsx(f.Primitive.div,{"data-state":j(n.open),...s,ref:r,style:{pointerEvents:"auto",...s.style}})})}),d="DialogContent",h=c.forwardRef((e,r)=>{const o=q(d,e.__scopeDialog),{forceMount:s=o.forceMount,...n}=e,t=l(d,e.__scopeDialog);return i.jsx(_.Presence,{present:s||t.open,children:t.modal?i.jsx(te,{...n,ref:r}):i.jsx(oe,{...n,ref:r})})});h.displayName=d;const te=c.forwardRef((e,r)=>{const o=l(d,e.__scopeDialog),s=c.useRef(null),n=P.useComposedRefs(r,o.contentRef,s);return c.useEffect(()=>{const t=s.current;if(t){const a=document.querySelectorAll("[data-ikp-component]");return Y.hideOthers([t,...Array.from(a)])}},[]),i.jsx(A,{...e,ref:n,trapFocus:o.open,disableOutsidePointerEvents:!0,onPointerDownOutside:m.composeEventHandlers(e.onPointerDownOutside,t=>{const a=t.detail.originalEvent,u=a.button===0&&a.ctrlKey===!0;(a.button===2||u)&&t.preventDefault(),t.target.closest("[data-ikp-component]")&&t.preventDefault()}),onFocusOutside:m.composeEventHandlers(e.onFocusOutside,t=>t.preventDefault())})}),oe=c.forwardRef((e,r)=>{const o=l(d,e.__scopeDialog),s=c.useRef(!1),n=c.useRef(!1);return i.jsx(A,{...e,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(s.current=!0,t.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const a=t.target;o.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type==="focusin"&&n.current&&t.preventDefault()}})}),A=c.forwardRef((e,r)=>{const{__scopeDialog:o,trapFocus:s,onOpenAutoFocus:n,onCloseAutoFocus:t,...a}=e,u=l(d,o),p=c.useRef(null),g=P.useComposedRefs(r,p);return U.useFocusGuards(),T.useEffect(()=>{if(s)return B.trapFocus(p.current,{preventScroll:!0,onActivate:n,onDeactivate:t,initialFocus:!1})},[]),i.jsx(z.DismissableLayer,{role:"dialog",id:u.contentId,"aria-describedby":u.descriptionId,"aria-labelledby":u.titleId,"data-state":j(u.open),...a,ref:g,onDismiss:()=>u.onOpenChange(!1)})}),w="DialogTitle",I=c.forwardRef((e,r)=>{const{__scopeDialog:o,...s}=e,n=l(w,o);return i.jsx(f.Primitive.h2,{id:n.titleId,...s,ref:r})});I.displayName=w;const k="DialogDescription",F=c.forwardRef((e,r)=>{const{__scopeDialog:o,...s}=e,n=l(k,o);return i.jsx(f.Primitive.p,{id:n.descriptionId,...s,ref:r})});F.displayName=k;const L="DialogClose",b=c.forwardRef((e,r)=>{const{__scopeDialog:o,...s}=e,n=l(L,o);return i.jsx(f.Primitive.button,{type:"button",...s,ref:r,onClick:m.composeEventHandlers(e.onClick,()=>n.onOpenChange(!1))})});b.displayName=L;function j(e){return e?"open":"closed"}const ne=O,re=y,se=E,ce=h,ie=I,ae=b;exports.Close=ae;exports.Content=ce;exports.Dialog=O;exports.DialogClose=b;exports.DialogContent=h;exports.DialogDescription=F;exports.DialogOverlay=E;exports.DialogPortal=y;exports.DialogTitle=I;exports.DialogTrigger=S;exports.Overlay=se;exports.Portal=re;exports.Root=ne;exports.Title=ie;exports.createDialogScope=Q;
@@ -1,49 +1,49 @@
1
1
  "use client";
2
- import { jsx as i } from "react/jsx-runtime";
3
- import * as c from "react";
2
+ import { jsx as c } from "react/jsx-runtime";
3
+ import * as i from "react";
4
4
  import { useEffect as G } from "react";
5
- import { composeEventHandlers as g } from "@radix-ui/primitive";
5
+ import { composeEventHandlers as D } from "@radix-ui/primitive";
6
6
  import { useComposedRefs as _ } from "@radix-ui/react-compose-refs";
7
- import { createContextScope as $ } from "@radix-ui/react-context";
7
+ import { createContextScope as W } from "@radix-ui/react-context";
8
8
  import { useId as C } from "@radix-ui/react-id";
9
- import { useControllableState as j } from "@radix-ui/react-use-controllable-state";
10
- import { DismissableLayer as B } from "@radix-ui/react-dismissable-layer";
11
- import { trapFocus as H } from "@zag-js/focus-trap";
12
- import { Portal as K } from "@radix-ui/react-portal";
9
+ import { useControllableState as $ } from "@radix-ui/react-use-controllable-state";
10
+ import { DismissableLayer as j } from "@radix-ui/react-dismissable-layer";
11
+ import { trapFocus as q } from "@zag-js/focus-trap";
12
+ import { Portal as B } from "@radix-ui/react-portal";
13
13
  import { Presence as O } from "@radix-ui/react-presence";
14
14
  import { Primitive as d } from "@radix-ui/react-primitive";
15
- import { useFocusGuards as V } from "@radix-ui/react-focus-guards";
16
- import { RemoveScroll as Y } from "react-remove-scroll";
17
- import { hideOthers as Z } from "aria-hidden";
18
- import { Slot as q } from "@radix-ui/react-slot";
19
- const P = "Dialog", [E, Co] = $(P), [z, l] = E(P), v = (o) => {
20
- const { __scopeDialog: n, children: r, open: s, defaultOpen: e, onOpenChange: t, modal: a = !0 } = o, f = c.useRef(null), p = c.useRef(null), [D = !1, R] = j({
15
+ import { useFocusGuards as H } from "@radix-ui/react-focus-guards";
16
+ import { RemoveScroll as K } from "react-remove-scroll";
17
+ import { hideOthers as V } from "aria-hidden";
18
+ import { Slot as Y } from "@radix-ui/react-slot";
19
+ const P = "Dialog", [E, Co] = W(P), [Z, l] = E(P), I = (o) => {
20
+ const { __scopeDialog: n, children: r, open: s, defaultOpen: e, onOpenChange: t, modal: a = !0 } = o, p = i.useRef(null), u = i.useRef(null), [g = !1, m] = $({
21
21
  prop: s,
22
22
  defaultProp: e ?? !1,
23
23
  onChange: t
24
24
  });
25
- return /* @__PURE__ */ i(
26
- z,
25
+ return /* @__PURE__ */ c(
26
+ Z,
27
27
  {
28
28
  scope: n,
29
- triggerRef: f,
30
- contentRef: p,
29
+ triggerRef: p,
30
+ contentRef: u,
31
31
  contentId: C(),
32
32
  titleId: C(),
33
33
  descriptionId: C(),
34
- open: D,
35
- onOpenChange: R,
36
- onOpenToggle: c.useCallback(() => R((L) => !L), [R]),
34
+ open: g,
35
+ onOpenChange: m,
36
+ onOpenToggle: i.useCallback(() => m((L) => !L), [m]),
37
37
  modal: a,
38
38
  children: r
39
39
  }
40
40
  );
41
41
  };
42
- v.displayName = P;
43
- const I = "DialogTrigger", J = c.forwardRef(
42
+ I.displayName = P;
43
+ const v = "DialogTrigger", z = i.forwardRef(
44
44
  (o, n) => {
45
- const { __scopeDialog: r, ...s } = o, e = l(I, r), t = _(n, e.triggerRef);
46
- return /* @__PURE__ */ i(
45
+ const { __scopeDialog: r, ...s } = o, e = l(v, r), t = _(n, e.triggerRef);
46
+ return /* @__PURE__ */ c(
47
47
  d.button,
48
48
  {
49
49
  type: "button",
@@ -53,41 +53,41 @@ const I = "DialogTrigger", J = c.forwardRef(
53
53
  "data-state": y(e.open),
54
54
  ...s,
55
55
  ref: t,
56
- onClick: g(o.onClick, e.onOpenToggle)
56
+ onClick: D(o.onClick, e.onOpenToggle)
57
57
  }
58
58
  );
59
59
  }
60
60
  );
61
- J.displayName = I;
62
- const h = "DialogPortal", [Q, x] = E(h, {
61
+ z.displayName = v;
62
+ const h = "DialogPortal", [J, x] = E(h, {
63
63
  forceMount: void 0
64
64
  }), N = (o) => {
65
65
  const { __scopeDialog: n, forceMount: r, children: s, container: e } = o, t = l(h, n);
66
- return /* @__PURE__ */ i(Q, { scope: n, forceMount: r, children: c.Children.map(s, (a) => /* @__PURE__ */ i(O, { present: r || t.open, children: /* @__PURE__ */ i(K, { asChild: !0, container: e, children: a }) })) });
66
+ return /* @__PURE__ */ c(J, { scope: n, forceMount: r, children: i.Children.map(s, (a) => /* @__PURE__ */ c(O, { present: r || t.open, children: /* @__PURE__ */ c(B, { asChild: !0, container: e, children: a }) })) });
67
67
  };
68
68
  N.displayName = h;
69
- const m = "DialogOverlay", M = c.forwardRef(
69
+ const R = "DialogOverlay", M = i.forwardRef(
70
70
  (o, n) => {
71
- const r = x(m, o.__scopeDialog), { forceMount: s = r.forceMount, ...e } = o, t = l(m, o.__scopeDialog);
72
- return t.modal ? /* @__PURE__ */ i(O, { present: s || t.open, children: /* @__PURE__ */ i(U, { ...e, ref: n }) }) : null;
71
+ const r = x(R, o.__scopeDialog), { forceMount: s = r.forceMount, ...e } = o, t = l(R, o.__scopeDialog);
72
+ return t.modal ? /* @__PURE__ */ c(O, { present: s || t.open, children: /* @__PURE__ */ c(Q, { ...e, ref: n }) }) : null;
73
73
  }
74
74
  );
75
- M.displayName = m;
76
- const U = c.forwardRef(
75
+ M.displayName = R;
76
+ const Q = i.forwardRef(
77
77
  (o, n) => {
78
- const { __scopeDialog: r, ...s } = o, e = l(m, r);
78
+ const { __scopeDialog: r, ...s } = o, e = l(R, r);
79
79
  return (
80
80
  // Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
81
81
  // ie. when `Overlay` and `Content` are siblings
82
- /* @__PURE__ */ i(
83
- Y,
82
+ /* @__PURE__ */ c(
83
+ K,
84
84
  {
85
- as: q,
85
+ as: Y,
86
86
  allowPinchZoom: !0,
87
87
  shards: [e.contentRef],
88
88
  gapMode: "padding",
89
89
  removeScrollBar: !0,
90
- children: /* @__PURE__ */ i(
90
+ children: /* @__PURE__ */ c(
91
91
  d.div,
92
92
  {
93
93
  "data-state": y(e.open),
@@ -100,42 +100,45 @@ const U = c.forwardRef(
100
100
  )
101
101
  );
102
102
  }
103
- ), u = "DialogContent", T = c.forwardRef(
103
+ ), f = "DialogContent", T = i.forwardRef(
104
104
  (o, n) => {
105
- const r = x(u, o.__scopeDialog), { forceMount: s = r.forceMount, ...e } = o, t = l(u, o.__scopeDialog);
106
- return /* @__PURE__ */ i(O, { present: s || t.open, children: t.modal ? /* @__PURE__ */ i(W, { ...e, ref: n }) : /* @__PURE__ */ i(X, { ...e, ref: n }) });
105
+ const r = x(f, o.__scopeDialog), { forceMount: s = r.forceMount, ...e } = o, t = l(f, o.__scopeDialog);
106
+ return /* @__PURE__ */ c(O, { present: s || t.open, children: t.modal ? /* @__PURE__ */ c(U, { ...e, ref: n }) : /* @__PURE__ */ c(X, { ...e, ref: n }) });
107
107
  }
108
108
  );
109
- T.displayName = u;
110
- const W = c.forwardRef(
109
+ T.displayName = f;
110
+ const U = i.forwardRef(
111
111
  (o, n) => {
112
- const r = l(u, o.__scopeDialog), s = c.useRef(null), e = _(n, r.contentRef, s);
113
- return c.useEffect(() => {
112
+ const r = l(f, o.__scopeDialog), s = i.useRef(null), e = _(n, r.contentRef, s);
113
+ return i.useEffect(() => {
114
114
  const t = s.current;
115
- if (t) return Z(t);
116
- }, []), /* @__PURE__ */ i(
117
- b,
115
+ if (t) {
116
+ const a = document.querySelectorAll("[data-ikp-component]");
117
+ return V([t, ...Array.from(a)]);
118
+ }
119
+ }, []), /* @__PURE__ */ c(
120
+ A,
118
121
  {
119
122
  ...o,
120
123
  ref: e,
121
124
  trapFocus: r.open,
122
125
  disableOutsidePointerEvents: !0,
123
- onPointerDownOutside: g(o.onPointerDownOutside, (t) => {
124
- const a = t.detail.originalEvent, f = a.button === 0 && a.ctrlKey === !0;
125
- (a.button === 2 || f) && t.preventDefault();
126
+ onPointerDownOutside: D(o.onPointerDownOutside, (t) => {
127
+ const a = t.detail.originalEvent, p = a.button === 0 && a.ctrlKey === !0;
128
+ (a.button === 2 || p) && t.preventDefault(), t.target.closest("[data-ikp-component]") && t.preventDefault();
126
129
  }),
127
- onFocusOutside: g(
130
+ onFocusOutside: D(
128
131
  o.onFocusOutside,
129
132
  (t) => t.preventDefault()
130
133
  )
131
134
  }
132
135
  );
133
136
  }
134
- ), X = c.forwardRef(
137
+ ), X = i.forwardRef(
135
138
  (o, n) => {
136
- const r = l(u, o.__scopeDialog), s = c.useRef(!1), e = c.useRef(!1);
137
- return /* @__PURE__ */ i(
138
- b,
139
+ const r = l(f, o.__scopeDialog), s = i.useRef(!1), e = i.useRef(!1);
140
+ return /* @__PURE__ */ c(
141
+ A,
139
142
  {
140
143
  ...o,
141
144
  ref: n,
@@ -149,75 +152,75 @@ const W = c.forwardRef(
149
152
  }
150
153
  );
151
154
  }
152
- ), b = c.forwardRef(
155
+ ), A = i.forwardRef(
153
156
  (o, n) => {
154
- const { __scopeDialog: r, trapFocus: s, onOpenAutoFocus: e, onCloseAutoFocus: t, ...a } = o, f = l(u, r), p = c.useRef(null), D = _(n, p);
155
- return V(), G(() => {
157
+ const { __scopeDialog: r, trapFocus: s, onOpenAutoFocus: e, onCloseAutoFocus: t, ...a } = o, p = l(f, r), u = i.useRef(null), g = _(n, u);
158
+ return H(), G(() => {
156
159
  if (s)
157
- return H(p.current, {
160
+ return q(u.current, {
158
161
  preventScroll: !0,
159
162
  onActivate: e,
160
163
  onDeactivate: t,
161
164
  initialFocus: !1
162
165
  });
163
- }, []), /* @__PURE__ */ i(
164
- B,
166
+ }, []), /* @__PURE__ */ c(
167
+ j,
165
168
  {
166
169
  role: "dialog",
167
- id: f.contentId,
168
- "aria-describedby": f.descriptionId,
169
- "aria-labelledby": f.titleId,
170
- "data-state": y(f.open),
170
+ id: p.contentId,
171
+ "aria-describedby": p.descriptionId,
172
+ "aria-labelledby": p.titleId,
173
+ "data-state": y(p.open),
171
174
  ...a,
172
- ref: D,
173
- onDismiss: () => f.onOpenChange(!1)
175
+ ref: g,
176
+ onDismiss: () => p.onOpenChange(!1)
174
177
  }
175
178
  );
176
179
  }
177
- ), w = "DialogTitle", A = c.forwardRef(
180
+ ), b = "DialogTitle", w = i.forwardRef(
178
181
  (o, n) => {
179
- const { __scopeDialog: r, ...s } = o, e = l(w, r);
180
- return /* @__PURE__ */ i(d.h2, { id: e.titleId, ...s, ref: n });
182
+ const { __scopeDialog: r, ...s } = o, e = l(b, r);
183
+ return /* @__PURE__ */ c(d.h2, { id: e.titleId, ...s, ref: n });
181
184
  }
182
185
  );
183
- A.displayName = w;
184
- const F = "DialogDescription", oo = c.forwardRef(
186
+ w.displayName = b;
187
+ const k = "DialogDescription", oo = i.forwardRef(
185
188
  (o, n) => {
186
- const { __scopeDialog: r, ...s } = o, e = l(F, r);
187
- return /* @__PURE__ */ i(d.p, { id: e.descriptionId, ...s, ref: n });
189
+ const { __scopeDialog: r, ...s } = o, e = l(k, r);
190
+ return /* @__PURE__ */ c(d.p, { id: e.descriptionId, ...s, ref: n });
188
191
  }
189
192
  );
190
- oo.displayName = F;
191
- const S = "DialogClose", k = c.forwardRef(
193
+ oo.displayName = k;
194
+ const F = "DialogClose", S = i.forwardRef(
192
195
  (o, n) => {
193
- const { __scopeDialog: r, ...s } = o, e = l(S, r);
194
- return /* @__PURE__ */ i(
196
+ const { __scopeDialog: r, ...s } = o, e = l(F, r);
197
+ return /* @__PURE__ */ c(
195
198
  d.button,
196
199
  {
197
200
  type: "button",
198
201
  ...s,
199
202
  ref: n,
200
- onClick: g(o.onClick, () => e.onOpenChange(!1))
203
+ onClick: D(o.onClick, () => e.onOpenChange(!1))
201
204
  }
202
205
  );
203
206
  }
204
207
  );
205
- k.displayName = S;
208
+ S.displayName = F;
206
209
  function y(o) {
207
210
  return o ? "open" : "closed";
208
211
  }
209
- const _o = v, Oo = N, Po = M, ho = T, yo = A, Eo = k;
212
+ const _o = I, Oo = N, Po = M, ho = T, yo = w, Eo = S;
210
213
  export {
211
214
  Eo as Close,
212
215
  ho as Content,
213
- v as Dialog,
214
- k as DialogClose,
216
+ I as Dialog,
217
+ S as DialogClose,
215
218
  T as DialogContent,
216
219
  oo as DialogDescription,
217
220
  M as DialogOverlay,
218
221
  N as DialogPortal,
219
- A as DialogTitle,
220
- J as DialogTrigger,
222
+ w as DialogTitle,
223
+ z as DialogTrigger,
221
224
  Po as Overlay,
222
225
  Oo as Portal,
223
226
  _o as Root,
@@ -1,3 +1,3 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("@ai-sdk/react"),V=require("ai"),t=require("react"),G=require("../../providers/config-provider.cjs"),X=require("../../hooks/use-media-query.cjs"),Y=require("../../utils/generate-uid.cjs"),Z=require("../../providers/base-events-provider.cjs"),ee=require("../../providers/chat-form-provider.cjs"),te=require("../../providers/widget-provider.cjs"),se=require("@radix-ui/react-use-controllable-state"),ne=()=>{const{baseSettings:m,aiChatSettings:o}=G.useInkeepConfig(),[n="",f]=se.useControllableState({prop:o.conversationId,defaultProp:o.conversationId??""}),{logEvent:i}=Z.useBaseEvents(),[a,u]=t.useState(""),_=e=>u(e.target.value),{filters:v}=m,{onInputMessageChange:k,filters:b,graphUrl:F,context:P,headers:x,apiKey:y}=o,N=e=>{switch(e.code){case 400:return e.message;case 403:return`There seems to be a configuration error. Please contact ${m.organizationDisplayName??"Administrator"}`;default:return`Hmm..
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const G=require("@ai-sdk/react"),X=require("ai"),t=require("react"),Y=require("../../providers/config-provider.cjs"),Z=require("../../hooks/use-media-query.cjs"),ee=require("../../utils/generate-uid.cjs"),te=require("../../providers/base-events-provider.cjs"),se=require("../../providers/chat-form-provider.cjs"),ne=require("../../providers/widget-provider.cjs"),re=require("@radix-ui/react-use-controllable-state"),ae=require("../../hooks/use-streaming-events.cjs"),oe=()=>{const{baseSettings:h,aiChatSettings:o}=Y.useInkeepConfig(),[n="",f]=re.useControllableState({prop:o.conversationId,defaultProp:o.conversationId??""}),{logEvent:i}=te.useBaseEvents(),{setConversationId:_,emitStreamError:k}=ae.useStreamingEvents(),[a,u]=t.useState(""),F=e=>u(e.target.value),{filters:v}=h,{onInputMessageChange:P,filters:S,graphUrl:x,context:N,headers:D,apiKey:C}=o,A=e=>{switch(e.code){case 400:return e.message;case 403:return`There seems to be a configuration error. Please contact ${h.organizationDisplayName??"Administrator"}`;default:return`Hmm..
2
2
 
3
- It seems I might be having some issues right now. Please clear the chat and try again.`}},[D,A]=t.useState({}),[B,l]=t.useState([]),[R,C]=t.useState(null),{messages:g,sendMessage:U,status:I,setMessages:S,stop:K,error:d}=L.useChat({transport:new V.DefaultChatTransport({api:F,headers:{...y?{Authorization:`Bearer ${y}`}:{},...x},body:{requestContext:P}}),async onFinish(e){await i({eventName:"assistant_message_received",properties:{conversationId:n}}),i({eventName:"assistant_answer_displayed",properties:{conversationId:n}})},onError(e){console.log("onError",e.message),S(c=>{const r=[...c],s=r[r.length-1];return s&&(s.parts=[{type:"text",text:N(e)}]),r})}}),w=I==="submitted",T=I==="streaming",W=g.length===0,p=!a.trim()||w,$=X.useMediaQuery("(max-width: 768px)"),[z,E]=t.useState(null);t.useEffect(()=>{d&&E(d)},[d]);const H=()=>E(null),M=t.useRef(null);t.useEffect(()=>{k?.(a)},[a]);const O=e=>{e.key==="Enter"&&!e.shiftKey&&!p&&!e.nativeEvent.isComposing&&(e.preventDefault(),h())},h=async(e=a)=>{if(p&&(!e||e.trim().length===0))return;l([]),u(""),await i({eventName:"user_message_submitted",properties:{conversationId:n}});const c=v||b?JSON.stringify({...v,...b}):void 0,r={};c&&(r["inkeep-filters"]=c);let s=n;s||(s=`conv_${Y.generateUid(16)}`,f(s)),U({text:e},{headers:r,body:{conversationId:s}})},Q=()=>{K()},q=()=>{H(),S([]),f(""),A({}),l([]),C(null),i({eventName:"chat_clear_button_clicked",properties:{conversationId:n}})},{openForm:j}=ee.useChatForm(),J=te.useWidget();return t.useImperativeHandle(o.chatFunctionsRef,()=>({submitMessage:h,updateInputMessage(e){u(e)},clearChat:q,openForm:e=>{J?.setView("chat"),j(e,void 0)},focusInput:()=>{M.current?.focus()}})),{messages:g,isLoading:w,isStreaming:T,error:z,isSubmitDisabled:p,input:a,handleInputChange:_,handleInputKeyDown:O,handleSubmit:h,stop:Q,clear:q,messageButtons:D,isEmpty:g.length===0,inputRef:M,isMobile:$,messageAttachments:B,setMessageAttachments:l,selectedWorkflow:R,setSelectedWorkflow:C,isNewChat:W,conversationId:n}};exports.useInkeepChat=ne;
3
+ It seems I might be having some issues right now. Please clear the chat and try again.`}},[B,R]=t.useState({}),[U,l]=t.useState([]),[K,I]=t.useState(null),{messages:g,sendMessage:T,status:b,setMessages:y,stop:W,error:d}=G.useChat({transport:new X.DefaultChatTransport({api:x,headers:{...C?{Authorization:`Bearer ${C}`}:{},...D},body:{requestContext:N}}),async onFinish(){await i({eventName:"assistant_message_received",properties:{conversationId:n}}),i({eventName:"assistant_answer_displayed",properties:{conversationId:n}})},onError(e){console.log("onError",e.message),k(e.message,void 0,e.code?.toString()),y(c=>{const r=[...c],s=r[r.length-1];return s&&(s.parts=[{type:"text",text:A(e)}]),r})}}),E=b==="submitted",$=b==="streaming",z=g.length===0,m=!a.trim()||E,H=Z.useMediaQuery("(max-width: 768px)"),[O,w]=t.useState(null);t.useEffect(()=>{d&&w(d)},[d]);const Q=()=>w(null),M=t.useRef(null);t.useEffect(()=>{P?.(a)},[a]);const j=e=>{e.key==="Enter"&&!e.shiftKey&&!m&&!e.nativeEvent.isComposing&&(e.preventDefault(),p())},p=async(e=a)=>{if(m&&(!e||e.trim().length===0))return;l([]),u(""),await i({eventName:"user_message_submitted",properties:{conversationId:n}});const c=v||S?JSON.stringify({...v,...S}):void 0,r={};c&&(r["inkeep-filters"]=c);let s=n;s||(s=`conv_${ee.generateUid(16)}`,f(s)),_(s),T({text:e},{headers:r,body:{conversationId:s}})},J=()=>{W()},q=()=>{Q(),y([]),f(""),R({}),l([]),I(null),i({eventName:"chat_clear_button_clicked",properties:{conversationId:n}})},{openForm:L}=se.useChatForm(),V=ne.useWidget();return t.useImperativeHandle(o.chatFunctionsRef,()=>({submitMessage:p,updateInputMessage(e){u(e)},clearChat:q,openForm:e=>{V?.setView("chat"),L(e,void 0)},focusInput:()=>{M.current?.focus()}})),{messages:g,isLoading:E,isStreaming:$,error:O,isSubmitDisabled:m,input:a,handleInputChange:F,handleInputKeyDown:j,handleSubmit:p,stop:J,clear:q,messageButtons:B,isEmpty:g.length===0,inputRef:M,isMobile:H,messageAttachments:U,setMessageAttachments:l,selectedWorkflow:K,setSelectedWorkflow:I,isNewChat:z,conversationId:n}};exports.useInkeepChat=oe;
@@ -1,29 +1,30 @@
1
1
  "use client";
2
- import { useChat as j } from "@ai-sdk/react";
3
- import { DefaultChatTransport as G } from "ai";
4
- import { useState as r, useEffect as x, useRef as X, useImperativeHandle as Y } from "react";
5
- import { useInkeepConfig as Z } from "../../providers/config-provider.js";
6
- import { useMediaQuery as ee } from "../../hooks/use-media-query.js";
7
- import { generateUid as te } from "../../utils/generate-uid.js";
8
- import { useBaseEvents as se } from "../../providers/base-events-provider.js";
9
- import { useChatForm as ne } from "../../providers/chat-form-provider.js";
10
- import { useWidget as oe } from "../../providers/widget-provider.js";
11
- import { useControllableState as re } from "@radix-ui/react-use-controllable-state";
12
- const fe = () => {
13
- const { baseSettings: h, aiChatSettings: a } = Z(), [s = "", f] = re({
2
+ import { useChat as X } from "@ai-sdk/react";
3
+ import { DefaultChatTransport as Y } from "ai";
4
+ import { useState as r, useEffect as x, useRef as Z, useImperativeHandle as ee } from "react";
5
+ import { useInkeepConfig as te } from "../../providers/config-provider.js";
6
+ import { useMediaQuery as se } from "../../hooks/use-media-query.js";
7
+ import { generateUid as ne } from "../../utils/generate-uid.js";
8
+ import { useBaseEvents as oe } from "../../providers/base-events-provider.js";
9
+ import { useChatForm as re } from "../../providers/chat-form-provider.js";
10
+ import { useWidget as ae } from "../../providers/widget-provider.js";
11
+ import { useControllableState as ie } from "@radix-ui/react-use-controllable-state";
12
+ import { useStreamingEvents as ce } from "../../hooks/use-streaming-events.js";
13
+ const be = () => {
14
+ const { baseSettings: h, aiChatSettings: a } = te(), [s = "", f] = ie({
14
15
  prop: a.conversationId,
15
16
  defaultProp: a.conversationId ?? ""
16
- }), { logEvent: i } = se(), [o, m] = r(""), k = (e) => m(e.target.value), {
17
+ }), { logEvent: i } = oe(), { setConversationId: k, emitStreamError: F } = ce(), [o, m] = r(""), N = (e) => m(e.target.value), {
17
18
  /* shouldBypassCaptcha, */
18
19
  filters: v
19
20
  } = h, {
20
- onInputMessageChange: F,
21
+ onInputMessageChange: D,
21
22
  filters: I,
22
- graphUrl: N,
23
- context: D,
24
- headers: A,
23
+ graphUrl: A,
24
+ context: B,
25
+ headers: K,
25
26
  apiKey: C
26
- } = a, B = (e) => {
27
+ } = a, P = (e) => {
27
28
  switch (e.code) {
28
29
  case 400:
29
30
  return e.message;
@@ -34,25 +35,25 @@ const fe = () => {
34
35
 
35
36
  It seems I might be having some issues right now. Please clear the chat and try again.`;
36
37
  }
37
- }, [K, P] = r({}), [R, u] = r([]), [W, b] = r(null), {
38
+ }, [R, W] = r({}), [$, u] = r([]), [z, b] = r(null), {
38
39
  messages: l,
39
- sendMessage: $,
40
+ sendMessage: H,
40
41
  status: y,
41
42
  setMessages: w,
42
- stop: z,
43
+ stop: T,
43
44
  error: p
44
- } = j({
45
- transport: new G({
46
- api: N,
45
+ } = X({
46
+ transport: new Y({
47
+ api: A,
47
48
  headers: {
48
49
  ...C ? { Authorization: `Bearer ${C}` } : {},
49
- ...A
50
+ ...K
50
51
  },
51
52
  body: {
52
- requestContext: D
53
+ requestContext: B
53
54
  }
54
55
  }),
55
- async onFinish(e) {
56
+ async onFinish() {
56
57
  await i({
57
58
  eventName: "assistant_message_received",
58
59
  properties: {
@@ -66,20 +67,20 @@ It seems I might be having some issues right now. Please clear the chat and try
66
67
  });
67
68
  },
68
69
  onError(e) {
69
- console.log("onError", e.message), w((c) => {
70
+ console.log("onError", e.message), F(e.message, void 0, e.code?.toString()), w((c) => {
70
71
  const n = [...c], t = n[n.length - 1];
71
- return t && (t.parts = [{ type: "text", text: B(e) }]), n;
72
+ return t && (t.parts = [{ type: "text", text: P(e) }]), n;
72
73
  });
73
74
  }
74
- }), E = y === "submitted", H = y === "streaming", T = l.length === 0, g = !o.trim() || E, U = ee("(max-width: 768px)"), [q, M] = r(null);
75
+ }), E = y === "submitted", U = y === "streaming", q = l.length === 0, g = !o.trim() || E, J = se("(max-width: 768px)"), [L, S] = r(null);
75
76
  x(() => {
76
- p && M(p);
77
+ p && S(p);
77
78
  }, [p]);
78
- const J = () => M(null), S = X(null);
79
+ const O = () => S(null), M = Z(null);
79
80
  x(() => {
80
- F?.(o);
81
+ D?.(o);
81
82
  }, [o]);
82
- const L = (e) => {
83
+ const Q = (e) => {
83
84
  e.key === "Enter" && !e.shiftKey && !g && !e.nativeEvent.isComposing && (e.preventDefault(), d());
84
85
  }, d = async (e = o) => {
85
86
  if (g && (!e || e.trim().length === 0)) return;
@@ -95,7 +96,7 @@ It seems I might be having some issues right now. Please clear the chat and try
95
96
  }) : void 0, n = {};
96
97
  c && (n["inkeep-filters"] = c);
97
98
  let t = s;
98
- t || (t = `conv_${te(16)}`, f(t)), $(
99
+ t || (t = `conv_${ne(16)}`, f(t)), k(t), H(
99
100
  // { ...userMessage, files },
100
101
  // { ...userMessage, },
101
102
  {
@@ -108,53 +109,53 @@ It seems I might be having some issues right now. Please clear the chat and try
108
109
  }
109
110
  }
110
111
  );
111
- }, O = () => {
112
- z();
112
+ }, V = () => {
113
+ T();
113
114
  }, _ = () => {
114
- J(), w([]), f(""), P({}), u([]), b(null), i({
115
+ O(), w([]), f(""), W({}), u([]), b(null), i({
115
116
  eventName: "chat_clear_button_clicked",
116
117
  properties: {
117
118
  conversationId: s
118
119
  }
119
120
  });
120
- }, { openForm: Q } = ne(), V = oe();
121
- return Y(a.chatFunctionsRef, () => ({
121
+ }, { openForm: j } = re(), G = ae();
122
+ return ee(a.chatFunctionsRef, () => ({
122
123
  submitMessage: d,
123
124
  updateInputMessage(e) {
124
125
  m(e);
125
126
  },
126
127
  clearChat: _,
127
128
  openForm: (e) => {
128
- V?.setView("chat"), Q(e, void 0);
129
+ G?.setView("chat"), j(e, void 0);
129
130
  },
130
131
  focusInput: () => {
131
- S.current?.focus();
132
+ M.current?.focus();
132
133
  }
133
134
  })), {
134
135
  messages: l,
135
136
  isLoading: E,
136
- isStreaming: H,
137
- error: q,
137
+ isStreaming: U,
138
+ error: L,
138
139
  isSubmitDisabled: g,
139
140
  input: o,
140
- handleInputChange: k,
141
- handleInputKeyDown: L,
141
+ handleInputChange: N,
142
+ handleInputKeyDown: Q,
142
143
  handleSubmit: d,
143
- stop: O,
144
+ stop: V,
144
145
  clear: _,
145
- messageButtons: K,
146
+ messageButtons: R,
146
147
  isEmpty: l.length === 0,
147
- inputRef: S,
148
- isMobile: U,
148
+ inputRef: M,
149
+ isMobile: J,
149
150
  // Additional state for attachments and workflow
150
- messageAttachments: R,
151
+ messageAttachments: $,
151
152
  setMessageAttachments: u,
152
- selectedWorkflow: W,
153
+ selectedWorkflow: z,
153
154
  setSelectedWorkflow: b,
154
- isNewChat: T,
155
+ isNewChat: q,
155
156
  conversationId: s
156
157
  };
157
158
  };
158
159
  export {
159
- fe as useInkeepChat
160
+ be as useInkeepChat
160
161
  };
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),A=require("../../../types/message.cjs");function D(a,f){const[i,x]=n.useState([]),[h,w]=n.useState(new Map),[y,P]=n.useState(Date.now()),[R,p]=n.useState(!1),g=n.useRef(0),d=n.useRef(0),S=n.useRef([]),c=n.useRef(h);c.current=h;const C=n.useCallback(()=>{const s=[];let e="",o=[];a.length>g.current&&(P(Date.now()),g.current=a.length),d.current=0;const u=new Map,l=(t=!1)=>{if(o.length>0){const r=`group-${d.current++}`,m=c.current.get(r);m?u.set(r,{...m,isCompleted:t}):u.set(r,{isCompleted:t}),s.push({type:"summary-group",summaries:[...o],groupKey:r}),o=[]}};for(const t of a)if(t.type==="text")l(!0),e+=t.text||"";else if(t.type==="data-summary")e.trim()&&(s.push({type:"text",text:e}),e=""),o.push(t.data);else if(t.type==="data-operation")t.data.type==="completion"&&l(!0);else if(t.type==="data-artifact")if(t.data?.type?.toLowerCase()===A.CITATION_ARTIFACT_TYPE){const r=t.data,m=r.artifactSummary||{title:r.name};e+=` ^${m?.title||r.name}^`}else e.trim()&&(s.push({type:"text",text:e}),e=""),s.push(t);else t.type==="data-component"&&(e.trim()&&(s.push({type:"text",text:e}),e=""),s.push(t));return l(!f),e.trim()&&s.push({type:"text",text:e}),{processed:s,newTimings:u}},[a,f]);n.useEffect(()=>{if(S.current===a)return;S.current=a;const{processed:s,newTimings:e}=C();x(s),(e.size!==c.current.size||Array.from(e.entries()).some(([u,l])=>{const t=c.current.get(u);return!t||t.isCompleted!==l.isCompleted}))&&w(e)},[C,a]);const T=n.useCallback(()=>{const s=Date.now()-y,e=Array.from(c.current.values()).some(u=>!u.isCompleted),o=s>1e3&&!e;p(o)},[y]);n.useEffect(()=>{if(!f){p(!1);return}if(!(i.length>0)){p(!1);return}const e=setInterval(T,200);return()=>clearInterval(e)},[f,T,i.length]);const v=n.useMemo(()=>!(i.length>0),[i.length]);return{processedParts:i,summaryTimings:h,shouldShowInitialLoading:v,shouldShowStreamDelayLoading:R}}exports.useStreamProcessor=D;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react"),b=require("../../../types/message.cjs"),L=require("../../hooks/use-streaming-events.cjs");function E(r,c){const[u,A]=a.useState([]),[p,D]=a.useState(new Map),[d,P]=a.useState(Date.now()),[R,g]=a.useState(!1),h=a.useRef(0),y=a.useRef(0),w=a.useRef([]),l=a.useRef(p);l.current=p;const{emitArtifactSaved:S,emitCompletion:x,emitAgentInitializing:k,emitTextDelta:C}=L.useStreamingEvents(),T=a.useCallback(()=>{const n=[];let e="",o=[];r.length>h.current&&(P(Date.now()),h.current=r.length),y.current=0;const i=new Map,m=(t=!1)=>{if(o.length>0){const s=`group-${y.current++}`,f=l.current.get(s);f?i.set(s,{...f,isCompleted:t}):i.set(s,{isCompleted:t}),n.push({type:"summary-group",summaries:[...o],groupKey:s}),o=[]}};for(const t of r)if(t.type==="text")m(!0),t.text&&c&&C(t.text),e+=t.text||"";else if(t.type==="data-summary")e.trim()&&(n.push({type:"text",text:e}),e=""),o.push(t.data);else if(t.type==="data-operation"){const s=t.data;if(s?.type)switch(s.type){case"completion":x("unknown",1),m(!0);break;case"agent_initializing":k("unknown","unknown");break;case"error":console.warn("Data operation error:",s.ctx);break;case"agent_thinking":case"agent_ready":console.log("Agent state:",s.type,s.ctx);break}}else if(t.type==="data-artifact")if(t.data?.type?.toLowerCase()===b.CITATION_ARTIFACT_TYPE){const s=t.data,f=s.artifactSummary||{title:s.name};e+=` ^${f?.title||s.name}^`}else e.trim()&&(n.push({type:"text",text:e}),e=""),n.push(t),t.data&&S(t.data.artifactId||"unknown",t.data.taskId||"unknown","unknown",t.data.artifactType||"unknown",t.data.artifactSummary||{},{},{name:t.data.name,description:t.data.description});else t.type==="data-component"&&(e.trim()&&(n.push({type:"text",text:e}),e=""),n.push(t));return m(!c),e.trim()&&n.push({type:"text",text:e}),{processed:n,newTimings:i}},[r,c,S,x,k,C]);a.useEffect(()=>{if(w.current===r)return;w.current=r;const{processed:n,newTimings:e}=T();A(n),(e.size!==l.current.size||Array.from(e.entries()).some(([i,m])=>{const t=l.current.get(i);return!t||t.isCompleted!==m.isCompleted}))&&D(e)},[T,r]);const v=a.useCallback(()=>{const n=Date.now()-d,e=Array.from(l.current.values()).some(i=>!i.isCompleted),o=n>1e3&&!e;g(o)},[d]);a.useEffect(()=>{if(!c){g(!1);return}if(!(u.length>0)){g(!1);return}const e=setInterval(v,200);return()=>clearInterval(e)},[c,v,u.length]);const I=a.useMemo(()=>!(u.length>0),[u.length]);return{processedParts:u,summaryTimings:p,shouldShowInitialLoading:I,shouldShowStreamDelayLoading:R}}exports.useStreamProcessor=E;