@cuadra-ai/uikit 0.1.28 → 0.1.30

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.
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  var Pr = Object.defineProperty;
2
2
  var Rr = (e, r, t) => r in e ? Pr(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
3
- var oe = (e, r, t) => Rr(e, typeof r != "symbol" ? r + "" : r, t);
3
+ var ce = (e, r, t) => Rr(e, typeof r != "symbol" ? r + "" : r, t);
4
4
  import { jsx as d, jsxs as w, Fragment as ae } from "react/jsx-runtime";
5
5
  import vt, { forwardRef as Ae, createElement as tt, useMemo as Q, useState as R, useEffect as O, useCallback as G, memo as Dr, useImperativeHandle as ct, useSyncExternalStore as _r, useRef as pe, createContext as Er } from "react";
6
6
  import { createPortal as rt } from "react-dom";
@@ -210,9 +210,9 @@ const wa = [
210
210
  ], st = U("x", wa);
211
211
  class Vt {
212
212
  constructor(r, t, a = !1) {
213
- oe(this, "baseUrl");
214
- oe(this, "sessionToken", null);
215
- oe(this, "isProxyMode", !1);
213
+ ce(this, "baseUrl");
214
+ ce(this, "sessionToken", null);
215
+ ce(this, "isProxyMode", !1);
216
216
  this.baseUrl = r.replace(/\/$/, ""), this.isProxyMode = a, t && (this.sessionToken = t);
217
217
  }
218
218
  /**
@@ -620,10 +620,10 @@ function Ma(e, r) {
620
620
  class Aa {
621
621
  constructor() {
622
622
  /** Per-message metadata, keyed by message ID */
623
- oe(this, "messageMetadata", /* @__PURE__ */ new Map());
623
+ ce(this, "messageMetadata", /* @__PURE__ */ new Map());
624
624
  /** Current streaming message ID */
625
- oe(this, "currentMessageId", null);
626
- oe(this, "listeners", /* @__PURE__ */ new Set());
625
+ ce(this, "currentMessageId", null);
626
+ ce(this, "listeners", /* @__PURE__ */ new Set());
627
627
  }
628
628
  /**
629
629
  * Set the current streaming message ID
@@ -677,7 +677,7 @@ class Aa {
677
677
  this.listeners.forEach((r) => r());
678
678
  }
679
679
  }
680
- const se = new Aa(), At = /* @__PURE__ */ new Map(), nt = [];
680
+ const ie = new Aa(), At = /* @__PURE__ */ new Map(), nt = [];
681
681
  let Ee = [];
682
682
  function Xt(e, r, t = 50, a = 800) {
683
683
  nt.push({ question: e, response: r, streamingSpeed: t, initialDelay: a });
@@ -758,18 +758,18 @@ function Kt(e, r) {
758
758
  if (q > 0 && await new Promise((Y) => setTimeout(Y, q)), m?.aborted)
759
759
  throw new Error("Request aborted");
760
760
  const V = S.response.split(" ");
761
- let ie = "";
761
+ let oe = "";
762
762
  const le = S.streamingSpeed || 40, de = `mock-${Date.now()}`;
763
763
  i && n?.(de);
764
764
  for (let Y = 0; Y < V.length; Y++) {
765
765
  if (m?.aborted)
766
766
  throw new Error("Request aborted");
767
- ie += (Y === 0 ? "" : " ") + V[Y], yield {
768
- content: [{ type: "text", text: ie }]
767
+ oe += (Y === 0 ? "" : " ") + V[Y], yield {
768
+ content: [{ type: "text", text: oe }]
769
769
  }, await new Promise((Le) => setTimeout(Le, le + Math.random() * (le * 0.3)));
770
770
  }
771
771
  yield {
772
- content: [{ type: "text", text: ie }]
772
+ content: [{ type: "text", text: oe }]
773
773
  };
774
774
  return;
775
775
  }
@@ -781,9 +781,9 @@ function Kt(e, r) {
781
781
  const z = [];
782
782
  let X = 0, K = !1;
783
783
  const Ie = `msg_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
784
- se.clear(), se.setCurrentMessage(Ie);
784
+ ie.clear(), ie.setCurrentMessage(Ie);
785
785
  const Se = () => {
786
- z.length !== X && (X = z.length, se.update({
786
+ z.length !== X && (X = z.length, ie.update({
787
787
  sources: z.length > 0 ? [...z] : void 0
788
788
  }));
789
789
  }, J = () => {
@@ -2495,9 +2495,9 @@ function Ci() {
2495
2495
  text: Z
2496
2496
  };
2497
2497
  }
2498
- let ce = 48;
2499
- for (; ce < 123; )
2500
- Z[ce] = ne, ce++, ce === 58 ? ce = 65 : ce === 91 && (ce = 97);
2498
+ let se = 48;
2499
+ for (; se < 123; )
2500
+ Z[se] = ne, se++, se === 58 ? se = 65 : se === 91 && (se = 97);
2501
2501
  Z[43] = ne;
2502
2502
  Z[45] = ne;
2503
2503
  Z[46] = ne;
@@ -3746,17 +3746,22 @@ function go() {
3746
3746
  ] });
3747
3747
  }
3748
3748
  function bo() {
3749
- const [e] = R(() => se.getCurrentMessageId()), r = Ce(({ message: i }) => i?.status?.type === "running"), t = Ce(({ message: i }) => {
3749
+ const [e] = R(() => ie.getCurrentMessageId()), r = Ce(({ message: i }) => i?.status?.type === "running"), t = Ce(({ message: i }) => {
3750
3750
  const o = i?.content;
3751
3751
  return !o || !Array.isArray(o) ? !1 : o.some((n) => !!(n.type === "text" && n.text && n.text.length > 0 || n.type === "reasoning" && n.text && n.text.length > 0));
3752
3752
  }), a = _r(
3753
- (i) => se.subscribe(i),
3753
+ (i) => ie.subscribe(i),
3754
3754
  () => {
3755
3755
  if (e) {
3756
- const i = se.getForMessage(e);
3757
- if (i.sources?.length) return i.sources;
3756
+ const o = ie.getForMessage(e);
3757
+ return o.sources?.length ? o.sources : null;
3758
3758
  }
3759
- return se.get().sources || null;
3759
+ const i = ie.getCurrentMessageId();
3760
+ if (i) {
3761
+ const o = ie.getForMessage(i);
3762
+ return o.sources?.length ? o.sources : null;
3763
+ }
3764
+ return null;
3760
3765
  },
3761
3766
  () => null
3762
3767
  );
@@ -4286,7 +4291,7 @@ const vo = Ae(
4286
4291
  }, 500);
4287
4292
  return () => clearTimeout(M);
4288
4293
  }, [E, A, I, C]);
4289
- const [N, _] = R(!1), [L, H] = R(null), [S, q] = R(null), [V, ie] = R(!1), le = pe(null), de = (M) => {
4294
+ const [N, _] = R(!1), [L, H] = R(null), [S, q] = R(null), [V, oe] = R(!1), le = pe(null), de = (M) => {
4290
4295
  if (M < 30) return !0;
4291
4296
  if (le.current) {
4292
4297
  const F = le.current.getBoundingClientRect();
@@ -4295,18 +4300,18 @@ const vo = Ae(
4295
4300
  return !1;
4296
4301
  }, Y = (M) => {
4297
4302
  const j = M.touches[0].clientX;
4298
- (de(j) || N) && (H(j), q(j), ie(!0));
4303
+ (de(j) || N) && (H(j), q(j), oe(!0));
4299
4304
  }, Le = (M) => {
4300
4305
  if (L === null || !V) return;
4301
4306
  const F = M.touches[0];
4302
4307
  q(F.clientX);
4303
4308
  }, mt = () => {
4304
4309
  if (L === null || S === null) {
4305
- ie(!1);
4310
+ oe(!1);
4306
4311
  return;
4307
4312
  }
4308
4313
  const M = S - L, F = 50, j = 0.3, wt = Math.abs(M) / 300;
4309
- M > F && !N && L !== null ? de(L) && _(!0) : ((M < -F || M < 0 && wt > j) && N || N && M < -20 && wt > j) && _(!1), H(null), q(null), ie(!1);
4314
+ M > F && !N && L !== null ? de(L) && _(!0) : ((M < -F || M < 0 && wt > j) && N || N && M < -20 && wt > j) && _(!1), H(null), q(null), oe(!1);
4310
4315
  }, Ar = () => {
4311
4316
  if (V && L !== null && S !== null) {
4312
4317
  const M = S - L;
@@ -4684,6 +4689,6 @@ export {
4684
4689
  uo as SourceCitations,
4685
4690
  Co as applyTheme,
4686
4691
  _o as removeTheme,
4687
- se as streamingMetadataStore
4692
+ ie as streamingMetadataStore
4688
4693
  };
4689
4694
  //# sourceMappingURL=index.mjs.map