bstp-agent-widget 0.2.68 → 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.
- package/dist/agent-widget.js +75 -54
- package/dist/agent-widget.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/index.d.ts +2 -21
package/dist/agent-widget.js
CHANGED
|
@@ -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:
|
|
29052
|
-
right:
|
|
29053
|
-
}, { isOpen:
|
|
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:
|
|
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:
|
|
29061
|
-
}),
|
|
29060
|
+
onTextChange: b
|
|
29061
|
+
}), te = _(() => /* @__PURE__ */ T(Xd, {
|
|
29062
29062
|
fw: 800,
|
|
29063
29063
|
children: e?.panelTitle ?? "Agent Chat"
|
|
29064
|
-
}), [e?.panelTitle]),
|
|
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]),
|
|
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 (
|
|
29078
|
-
let { element: e, inlinePaddingBefore: t, inlineWidthBefore: n } =
|
|
29079
|
-
e.style.paddingRight = t, e.style.width = n,
|
|
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
|
-
|
|
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
|
-
}, [
|
|
29090
|
-
|
|
29091
|
-
},
|
|
29092
|
-
|
|
29093
|
-
},
|
|
29094
|
-
|
|
29095
|
-
},
|
|
29096
|
-
|
|
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
|
-
|
|
29100
|
-
await
|
|
29112
|
+
d && !ie.current && (ie.current = !0, (async () => {
|
|
29113
|
+
await A(), await D();
|
|
29101
29114
|
})());
|
|
29102
|
-
}, [
|
|
29103
|
-
let
|
|
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
|
-
|
|
29109
|
-
}, [t,
|
|
29121
|
+
I.current = n, re(n);
|
|
29122
|
+
}, [t, re])
|
|
29110
29123
|
});
|
|
29111
29124
|
return f(() => {
|
|
29112
29125
|
let e = Math.max(280, t);
|
|
29113
|
-
|
|
29126
|
+
I.current = e, d && re(e);
|
|
29114
29127
|
}, [
|
|
29115
29128
|
t,
|
|
29116
|
-
|
|
29117
|
-
|
|
29129
|
+
d,
|
|
29130
|
+
re
|
|
29118
29131
|
]), f(() => {
|
|
29119
29132
|
if (!(typeof document > "u")) {
|
|
29120
|
-
if (!
|
|
29121
|
-
|
|
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
|
-
|
|
29138
|
+
re(null), document.documentElement.removeAttribute("data-agent-widget-open");
|
|
29126
29139
|
};
|
|
29127
29140
|
}
|
|
29128
|
-
}, [
|
|
29129
|
-
|
|
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:
|
|
29152
|
+
position: l,
|
|
29132
29153
|
color: e?.accentColor,
|
|
29133
29154
|
label: e?.fabButtonLabel
|
|
29134
|
-
}),
|
|
29155
|
+
}), d && /* @__PURE__ */ T(zO, {
|
|
29135
29156
|
visible: !0,
|
|
29136
|
-
onClose:
|
|
29137
|
-
messages:
|
|
29138
|
-
composerText:
|
|
29139
|
-
onComposerTextChange:
|
|
29140
|
-
isLoading:
|
|
29141
|
-
error:
|
|
29142
|
-
canSend:
|
|
29143
|
-
onSubmit:
|
|
29144
|
-
isListening:
|
|
29145
|
-
isVoiceSupported:
|
|
29146
|
-
onToggleVoice:
|
|
29147
|
-
panelTitle:
|
|
29148
|
-
runtimeInfo:
|
|
29149
|
-
scrollViewportRef:
|
|
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:
|
|
29174
|
+
panelResizableWidth: ce,
|
|
29154
29175
|
zIndex: i
|
|
29155
29176
|
})] });
|
|
29156
29177
|
}
|