bstp-agent-widget 0.2.70 → 0.2.72

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.
@@ -23917,23 +23917,28 @@ function UO(e = {}) {
23917
23917
  };
23918
23918
  }
23919
23919
  var WO = {
23920
- root: "_root_76f4f_2",
23921
- button: "_button_76f4f_7",
23922
- icon: "_icon_76f4f_24",
23923
- label: "_label_76f4f_30"
23920
+ root: "_root_1r0du_1",
23921
+ button: "_button_1r0du_5",
23922
+ icon: "_icon_1r0du_22",
23923
+ label: "_label_1r0du_28"
23924
23924
  };
23925
23925
  //#endregion
23926
23926
  //#region src/components/AgentChat/AgentChatFab.tsx
23927
23927
  function GO({ onClick: e, zIndex: t, position: n, color: r, label: i }) {
23928
- let { handlePointerDown: a, style: o } = UO({ skipSelector: "" }), { transform: s, cursor: c, touchAction: l } = o, u = r ? r.includes("linear-gradient") ? r : `linear-gradient(135deg, ${r}, ${r})` : void 0;
23928
+ let { handlePointerDown: a, style: o } = UO({ skipSelector: "" }), { transform: s, cursor: c, touchAction: l } = o, u = _(() => ({
23929
+ transform: s,
23930
+ touchAction: l,
23931
+ zIndex: t,
23932
+ ...n
23933
+ }), [
23934
+ n,
23935
+ l,
23936
+ s,
23937
+ t
23938
+ ]), d = r ? r.includes("linear-gradient") ? r : `linear-gradient(135deg, ${r}, ${r})` : void 0;
23929
23939
  return /* @__PURE__ */ T("div", {
23930
23940
  className: WO.root,
23931
- style: {
23932
- transform: s,
23933
- touchAction: l,
23934
- zIndex: t,
23935
- ...n
23936
- },
23941
+ style: u,
23937
23942
  children: /* @__PURE__ */ T(_v, {
23938
23943
  label: "Open agent widget",
23939
23944
  position: "left",
@@ -23941,8 +23946,8 @@ function GO({ onClick: e, zIndex: t, position: n, color: r, label: i }) {
23941
23946
  type: "button",
23942
23947
  onClick: e,
23943
23948
  onPointerDown: a,
23944
- style: u ? {
23945
- background: u,
23949
+ style: d ? {
23950
+ background: d,
23946
23951
  cursor: c ?? "pointer"
23947
23952
  } : { cursor: c ?? "pointer" },
23948
23953
  className: WO.button,
@@ -29047,29 +29052,21 @@ var BF = {
29047
29052
  ];
29048
29053
  function UF({ ui: e }) {
29049
29054
  RF();
29050
- let t = e?.panelWidth ?? 420, n = e?.panelHeight ?? "100%", r = e?.panelHeaderHeight ?? 56, i = e?.zIndex ?? VF, a = e?.fabBottomOffset ?? BF.bottom, o = e?.fabRightOffset ?? BF.right, [s, c] = y(a), l = {
29051
- bottom: s,
29052
- right: o
29053
- }, { isOpen: d, open: p, close: m } = zF({
29055
+ let t = e?.panelWidth ?? 420, n = e?.panelHeight ?? "100%", r = e?.panelHeaderHeight ?? 56, i = e?.zIndex ?? VF, a = {
29056
+ bottom: e?.fabBottomOffset ?? BF.bottom,
29057
+ right: e?.fabRightOffset ?? BF.right
29058
+ }, { isOpen: o, open: s, close: c } = zF({
29054
29059
  defaultOpen: !1,
29055
29060
  persist: !0
29056
- }), { messages: h, composerText: g, setComposerText: b, isLoading: x, error: S, sendMessage: C, sendInitialMessage: D, canSend: O } = OF(), { runtimeInfo: k, refreshRuntimeInfo: A } = kF(), j = MF([h.length, x]), { isListening: M, isSupported: N, startListening: P, stopListening: F, reset: ee } = NF({
29061
+ }), { messages: l, composerText: d, setComposerText: p, isLoading: m, error: h, sendMessage: g, sendInitialMessage: y, canSend: b } = OF(), { runtimeInfo: x, refreshRuntimeInfo: S } = kF(), C = MF([l.length, m]), { isListening: D, isSupported: O, startListening: k, stopListening: A, reset: j } = NF({
29057
29062
  lang: PF(),
29058
29063
  continuous: !0,
29059
29064
  pauseOnSubmit: !0,
29060
- onTextChange: b
29061
- }), te = _(() => /* @__PURE__ */ T(Xd, {
29065
+ onTextChange: p
29066
+ }), M = _(() => /* @__PURE__ */ T(Xd, {
29062
29067
  fw: 800,
29063
29068
  children: e?.panelTitle ?? "Agent Chat"
29064
- }), [e?.panelTitle]), I = v(Math.max(280, t)), L = v(null), R = u((e) => {
29065
- if (typeof window > "u") return;
29066
- if (!e) {
29067
- c(a);
29068
- return;
29069
- }
29070
- let t = e.getBoundingClientRect();
29071
- c(a + Math.max(0, window.innerHeight - t.bottom));
29072
- }, [a]), ne = u(() => {
29069
+ }), [e?.panelTitle]), N = v(Math.max(280, t)), P = v(null), F = u(() => {
29073
29070
  if (typeof document > "u") return null;
29074
29071
  let t = [...typeof e?.hostContainerSelector == "string" ? e.hostContainerSelector.split(",").map((e) => e.trim()).filter(Boolean) : [], ...HF];
29075
29072
  for (let e of t) {
@@ -29077,101 +29074,93 @@ function UF({ ui: e }) {
29077
29074
  if (t) return t;
29078
29075
  }
29079
29076
  return document.body;
29080
- }, [e?.hostContainerSelector]), re = u((e) => {
29077
+ }, [e?.hostContainerSelector]), ee = u((e) => {
29081
29078
  if (typeof document > "u") return;
29082
29079
  let t = document.documentElement;
29083
29080
  if (e === null ? t.style.removeProperty("--agent-widget-panel-width") : t.style.setProperty("--agent-widget-panel-width", `${e}px`), typeof window > "u") return;
29084
29081
  if (e === null) {
29085
- if (L.current) {
29086
- let { element: e, inlinePaddingBefore: t, inlineWidthBefore: n } = L.current;
29087
- e.style.paddingRight = t, e.style.width = n, L.current = null;
29082
+ if (P.current) {
29083
+ let { element: e, inlinePaddingBefore: t } = P.current;
29084
+ e.style.paddingRight = t, P.current = null;
29088
29085
  }
29089
- R(null);
29090
29086
  return;
29091
29087
  }
29092
- let n = L.current?.element ?? null;
29093
- if ((!n || !document.contains(n)) && (n = ne(), L.current = null), !n) {
29094
- R(null);
29095
- return;
29088
+ if (!P.current || !document.contains(P.current.element)) {
29089
+ let e = F();
29090
+ if (!e) return;
29091
+ P.current = {
29092
+ element: e,
29093
+ inlinePaddingBefore: e.style.paddingRight,
29094
+ widthApplied: 0
29095
+ };
29096
29096
  }
29097
- L.current ||= {
29098
- element: n,
29099
- inlinePaddingBefore: n.style.paddingRight,
29100
- inlineWidthBefore: n.style.width
29101
- }, n.style.paddingRight = "", n.style.width = `max(0px, calc(100vw - ${e}px))`, R(n);
29102
- }, [ne, R]), ie = v(!1), ae = () => {
29103
- M && F(), ee(), C(g);
29104
- }, oe = () => {
29105
- M ? F() : (b(""), P());
29106
- }, z = () => {
29107
- M && F(), m();
29108
- }, se = async () => {
29109
- p(), ie.current || (ie.current = !0, await A(), await D());
29097
+ let { element: n, inlinePaddingBefore: r, widthApplied: i } = P.current;
29098
+ e !== i && (n.style.paddingRight = r, n.style.paddingRight = `calc(${r || "0px"} + ${e}px)`, P.current.widthApplied = e);
29099
+ }, [F]), te = v(!1), I = () => {
29100
+ D && A(), j(), g(d);
29101
+ }, L = () => {
29102
+ D ? A() : (p(""), k());
29103
+ }, R = () => {
29104
+ D && A(), c();
29105
+ }, ne = async () => {
29106
+ s(), te.current || (te.current = !0, await S(), await y());
29110
29107
  };
29111
29108
  f(() => {
29112
- d && !ie.current && (ie.current = !0, (async () => {
29113
- await A(), await D();
29109
+ o && !te.current && (te.current = !0, (async () => {
29110
+ await S(), await y();
29114
29111
  })());
29115
- }, [d]);
29116
- let ce = AF({
29112
+ }, [o]);
29113
+ let re = AF({
29117
29114
  axis: "x",
29118
29115
  direction: -1,
29119
29116
  onResizeChange: u((e) => {
29120
29117
  let n = Math.max(280, t + e);
29121
- I.current = n, re(n);
29122
- }, [t, re])
29118
+ N.current = n, ee(n);
29119
+ }, [t, ee])
29123
29120
  });
29124
29121
  return f(() => {
29125
29122
  let e = Math.max(280, t);
29126
- I.current = e, d && re(e);
29123
+ N.current = e, o && ee(e);
29127
29124
  }, [
29128
29125
  t,
29129
- d,
29130
- re
29126
+ o,
29127
+ ee
29131
29128
  ]), f(() => {
29132
29129
  if (!(typeof document > "u")) {
29133
- if (!d) {
29134
- re(null), document.documentElement.removeAttribute("data-agent-widget-open");
29130
+ if (!o) {
29131
+ ee(null), document.documentElement.removeAttribute("data-agent-widget-open");
29135
29132
  return;
29136
29133
  }
29137
29134
  return document.documentElement.setAttribute("data-agent-widget-open", "true"), () => {
29138
- re(null), document.documentElement.removeAttribute("data-agent-widget-open");
29135
+ ee(null), document.documentElement.removeAttribute("data-agent-widget-open");
29139
29136
  };
29140
29137
  }
29141
- }, [d, re]), f(() => {
29142
- if (typeof window > "u") return;
29143
- let e = () => {
29144
- R(L.current?.element ?? ne() ?? null);
29145
- };
29146
- return window.addEventListener("resize", e), () => {
29147
- window.removeEventListener("resize", e);
29148
- };
29149
- }, [ne, R]), /* @__PURE__ */ E(w, { children: [!d && /* @__PURE__ */ T(GO, {
29150
- onClick: () => void se(),
29138
+ }, [o, ee]), /* @__PURE__ */ E(w, { children: [!o && /* @__PURE__ */ T(GO, {
29139
+ onClick: () => void ne(),
29151
29140
  zIndex: i,
29152
- position: l,
29141
+ position: a,
29153
29142
  color: e?.accentColor,
29154
29143
  label: e?.fabButtonLabel
29155
- }), d && /* @__PURE__ */ T(zO, {
29144
+ }), o && /* @__PURE__ */ T(zO, {
29156
29145
  visible: !0,
29157
- onClose: z,
29158
- messages: h,
29159
- composerText: g,
29160
- onComposerTextChange: b,
29161
- isLoading: x,
29162
- error: S,
29163
- canSend: O,
29164
- onSubmit: ae,
29165
- isListening: M,
29166
- isVoiceSupported: N,
29167
- onToggleVoice: oe,
29168
- panelTitle: te,
29169
- runtimeInfo: k,
29170
- scrollViewportRef: j,
29146
+ onClose: R,
29147
+ messages: l,
29148
+ composerText: d,
29149
+ onComposerTextChange: p,
29150
+ isLoading: m,
29151
+ error: h,
29152
+ canSend: b,
29153
+ onSubmit: I,
29154
+ isListening: D,
29155
+ isVoiceSupported: O,
29156
+ onToggleVoice: L,
29157
+ panelTitle: M,
29158
+ runtimeInfo: x,
29159
+ scrollViewportRef: C,
29171
29160
  panelWidth: t,
29172
29161
  panelHeight: n,
29173
29162
  panelHeaderHeight: r,
29174
- panelResizableWidth: ce,
29163
+ panelResizableWidth: re,
29175
29164
  zIndex: i
29176
29165
  })] });
29177
29166
  }