bstp-agent-widget 0.2.69 → 0.2.70

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.
@@ -29047,21 +29047,29 @@ var BF = {
29047
29047
  ];
29048
29048
  function UF({ ui: e }) {
29049
29049
  RF();
29050
- let t = e?.panelWidth ?? 420, n = e?.panelHeight ?? "100%", r = e?.panelHeaderHeight ?? 56, i = e?.zIndex ?? VF, a = {
29051
- bottom: e?.fabBottomOffset ?? BF.bottom,
29052
- right: e?.fabRightOffset ?? BF.right
29053
- }, { isOpen: o, open: s, close: c } = zF({
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({
29054
29054
  defaultOpen: !1,
29055
29055
  persist: !0
29056
- }), { 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({
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({
29057
29057
  lang: PF(),
29058
29058
  continuous: !0,
29059
29059
  pauseOnSubmit: !0,
29060
- onTextChange: p
29061
- }), M = _(() => /* @__PURE__ */ T(Xd, {
29060
+ onTextChange: b
29061
+ }), te = _(() => /* @__PURE__ */ T(Xd, {
29062
29062
  fw: 800,
29063
29063
  children: e?.panelTitle ?? "Agent Chat"
29064
- }), [e?.panelTitle]), N = v(Math.max(280, t)), P = v(null), F = u(() => {
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(() => {
29065
29073
  if (typeof document > "u") return null;
29066
29074
  let t = [...typeof e?.hostContainerSelector == "string" ? e.hostContainerSelector.split(",").map((e) => e.trim()).filter(Boolean) : [], ...HF];
29067
29075
  for (let e of t) {
@@ -29069,88 +29077,101 @@ function UF({ ui: e }) {
29069
29077
  if (t) return t;
29070
29078
  }
29071
29079
  return document.body;
29072
- }, [e?.hostContainerSelector]), ee = u((e) => {
29080
+ }, [e?.hostContainerSelector]), re = u((e) => {
29073
29081
  if (typeof document > "u") return;
29074
29082
  let t = document.documentElement;
29075
29083
  if (e === null ? t.style.removeProperty("--agent-widget-panel-width") : t.style.setProperty("--agent-widget-panel-width", `${e}px`), typeof window > "u") return;
29076
29084
  if (e === null) {
29077
- if (P.current) {
29078
- let { element: e, inlinePaddingBefore: t, inlineWidthBefore: n } = P.current;
29079
- e.style.paddingRight = t, e.style.width = n, P.current = 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;
29080
29088
  }
29089
+ R(null);
29090
+ return;
29091
+ }
29092
+ let n = L.current?.element ?? null;
29093
+ if ((!n || !document.contains(n)) && (n = ne(), L.current = null), !n) {
29094
+ R(null);
29081
29095
  return;
29082
29096
  }
29083
- let n = P.current?.element ?? null;
29084
- (!n || !document.contains(n)) && (n = F(), P.current = null), n && (P.current ||= {
29097
+ L.current ||= {
29085
29098
  element: n,
29086
29099
  inlinePaddingBefore: n.style.paddingRight,
29087
29100
  inlineWidthBefore: n.style.width
29088
- }, n.style.paddingRight = "", n.style.width = `max(0px, calc(100vw - ${e}px))`);
29089
- }, [F]), te = v(!1), I = () => {
29090
- D && A(), j(), g(d);
29091
- }, L = () => {
29092
- D ? A() : (p(""), k());
29093
- }, R = () => {
29094
- D && A(), c();
29095
- }, ne = async () => {
29096
- s(), te.current || (te.current = !0, await S(), await y());
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
29110
  };
29098
29111
  f(() => {
29099
- o && !te.current && (te.current = !0, (async () => {
29100
- await S(), await y();
29112
+ d && !ie.current && (ie.current = !0, (async () => {
29113
+ await A(), await D();
29101
29114
  })());
29102
- }, [o]);
29103
- let re = AF({
29115
+ }, [d]);
29116
+ let ce = AF({
29104
29117
  axis: "x",
29105
29118
  direction: -1,
29106
29119
  onResizeChange: u((e) => {
29107
29120
  let n = Math.max(280, t + e);
29108
- N.current = n, ee(n);
29109
- }, [t, ee])
29121
+ I.current = n, re(n);
29122
+ }, [t, re])
29110
29123
  });
29111
29124
  return f(() => {
29112
29125
  let e = Math.max(280, t);
29113
- N.current = e, o && ee(e);
29126
+ I.current = e, d && re(e);
29114
29127
  }, [
29115
29128
  t,
29116
- o,
29117
- ee
29129
+ d,
29130
+ re
29118
29131
  ]), f(() => {
29119
29132
  if (!(typeof document > "u")) {
29120
- if (!o) {
29121
- ee(null), document.documentElement.removeAttribute("data-agent-widget-open");
29133
+ if (!d) {
29134
+ re(null), document.documentElement.removeAttribute("data-agent-widget-open");
29122
29135
  return;
29123
29136
  }
29124
29137
  return document.documentElement.setAttribute("data-agent-widget-open", "true"), () => {
29125
- ee(null), document.documentElement.removeAttribute("data-agent-widget-open");
29138
+ re(null), document.documentElement.removeAttribute("data-agent-widget-open");
29126
29139
  };
29127
29140
  }
29128
- }, [o, ee]), /* @__PURE__ */ E(w, { children: [!o && /* @__PURE__ */ T(GO, {
29129
- onClick: () => void ne(),
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(),
29130
29151
  zIndex: i,
29131
- position: a,
29152
+ position: l,
29132
29153
  color: e?.accentColor,
29133
29154
  label: e?.fabButtonLabel
29134
- }), o && /* @__PURE__ */ T(zO, {
29155
+ }), d && /* @__PURE__ */ T(zO, {
29135
29156
  visible: !0,
29136
- onClose: R,
29137
- messages: l,
29138
- composerText: d,
29139
- onComposerTextChange: p,
29140
- isLoading: m,
29141
- error: h,
29142
- canSend: b,
29143
- onSubmit: I,
29144
- isListening: D,
29145
- isVoiceSupported: O,
29146
- onToggleVoice: L,
29147
- panelTitle: M,
29148
- runtimeInfo: x,
29149
- scrollViewportRef: C,
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,
29150
29171
  panelWidth: t,
29151
29172
  panelHeight: n,
29152
29173
  panelHeaderHeight: r,
29153
- panelResizableWidth: re,
29174
+ panelResizableWidth: ce,
29154
29175
  zIndex: i
29155
29176
  })] });
29156
29177
  }