bstp-agent-widget 0.2.108 → 0.2.110

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.
@@ -22112,7 +22112,8 @@ var aD = {
22112
22112
  ...e,
22113
22113
  [t]: `${oD}${n}`
22114
22114
  }), {});
22115
- new pD("local-storage.utils");
22115
+ //#endregion
22116
+ //#region src/utils/local-storage.utils.ts
22116
22117
  function cD(e, t = null) {
22117
22118
  let n = localStorage.getItem(e);
22118
22119
  if (n === null) return t;
@@ -33718,19 +33719,23 @@ function FV(e, t = {}) {
33718
33719
  }
33719
33720
  //#endregion
33720
33721
  //#region src/hooks/useAgentChatSpeechToText.ts
33721
- var IV = new pD("useAgentChatSpeechToText");
33722
- function LV(e = {}) {
33722
+ function IV(e = {}) {
33723
33723
  let { lang: t = "en-EN", continuous: n = !0, interimResults: r = !0, onResult: i, onError: a, onTextChange: o, pauseOnSubmit: s = !1 } = e, [c, l] = y(!1), [d, p] = y(""), [m, h] = y(!1), g = v(null), _ = v(""), b = v(!1), x = v(!1), S = v(""), C = v(""), w = v(null), T = v(!1), E = v(o), D = v(c);
33724
33724
  f(() => {
33725
33725
  E.current = o, D.current = c;
33726
33726
  }), f(() => {
33727
33727
  let e = window.SpeechRecognition || window.webkitSpeechRecognition;
33728
- if (!e) {
33728
+ if (typeof e != "function") {
33729
33729
  h(!1);
33730
33730
  return;
33731
33731
  }
33732
- h(!0);
33733
- let o = new e();
33732
+ let o;
33733
+ try {
33734
+ o = new e(), h(!0);
33735
+ } catch (e) {
33736
+ console.log("useAgentChatSpeechToText: Speech recognition is present but not constructable", e), h(!1);
33737
+ return;
33738
+ }
33734
33739
  return o.lang = t, o.continuous = n, o.interimResults = r, o.onresult = (e) => {
33735
33740
  if (T.current) return;
33736
33741
  x.current = !0;
@@ -33751,7 +33756,7 @@ function LV(e = {}) {
33751
33756
  E.current?.(e);
33752
33757
  });
33753
33758
  }, o.onerror = (e) => {
33754
- IV.error("Speech recognition error", { error: e.error }), l(!1), a?.(e.error);
33759
+ console.log("useAgentChatSpeechToText: Speech recognition error", e.error), l(!1), a?.(e.error);
33755
33760
  }, o.onend = () => {
33756
33761
  if (b.current || !D.current) {
33757
33762
  l(!1);
@@ -33778,13 +33783,13 @@ function LV(e = {}) {
33778
33783
  if (!(!g.current || !m)) try {
33779
33784
  p(""), _.current = "", b.current = !1, x.current = !1, T.current = !1, S.current = "", C.current = "", w.current != null && (cancelAnimationFrame(w.current), w.current = null), g.current.start(), l(!0);
33780
33785
  } catch (e) {
33781
- IV.error("Failed to start speech recognition", { error: e instanceof Error ? e.message : String(e) }), a?.("Failed to start speech recognition");
33786
+ console.log("useAgentChatSpeechToText: Failed to start speech recognition", e), a?.("Failed to start speech recognition");
33782
33787
  }
33783
33788
  }, [m, a]), k = u(() => {
33784
33789
  if (g.current) try {
33785
33790
  b.current = !0, g.current.stop(), l(!1);
33786
33791
  } catch (e) {
33787
- IV.error("Failed to stop speech recognition", { error: e instanceof Error ? e.message : String(e) });
33792
+ console.log("useAgentChatSpeechToText: Failed to stop speech recognition", e);
33788
33793
  }
33789
33794
  }, []);
33790
33795
  return {
@@ -33809,11 +33814,11 @@ function LV(e = {}) {
33809
33814
  }
33810
33815
  //#endregion
33811
33816
  //#region src/hooks/useAgentChatSpeechLanguage.ts
33812
- function RV() {
33817
+ function LV() {
33813
33818
  let e = $P();
33814
33819
  return _(() => e && iF(e) || "en-US", [e]);
33815
33820
  }
33816
- var zV = o({
33821
+ var RV = o({
33817
33822
  keycloak: {
33818
33823
  url: "",
33819
33824
  realm: "",
@@ -33836,19 +33841,19 @@ var zV = o({
33836
33841
  });
33837
33842
  //#endregion
33838
33843
  //#region src/hooks/useConfig.ts
33839
- function BV() {
33840
- let e = d(zV);
33844
+ function zV() {
33845
+ let e = d(RV);
33841
33846
  if (!e) throw Error("useConfig must be used within a ConfigProvider");
33842
33847
  return e;
33843
33848
  }
33844
33849
  //#endregion
33845
33850
  //#region src/queries/genai/useGenaiLoginMutation.ts
33846
- var VV = kV({
33851
+ var BV = kV({
33847
33852
  mutationKey: ["genai", "login"],
33848
33853
  mutationFn: async ({ serviceAccount: e, serviceKey: t }) => OV.loginToGenai(e, t)
33849
- }), HV = new pD("useGenaiLogin"), UV = null, WV = null;
33850
- function GV(e = !1) {
33851
- let t = BV(), { mutateAsync: n } = VV(), [r, i] = y(!1), [a, o] = y(null), [s, c] = y(null), [l, u] = y(null);
33854
+ }), VV = new pD("useGenaiLogin"), HV = null, UV = null;
33855
+ function WV(e = !1) {
33856
+ let t = zV(), { mutateAsync: n } = BV(), [r, i] = y(!1), [a, o] = y(null), [s, c] = y(null), [l, u] = y(null);
33852
33857
  return f(() => {
33853
33858
  (async () => {
33854
33859
  let r = bF();
@@ -33860,20 +33865,20 @@ function GV(e = !1) {
33860
33865
  if (!a) return;
33861
33866
  u(a);
33862
33867
  let s = `${a.serviceAccount}::${a.serviceKey}`;
33863
- if (UV === s && !e) {
33864
- WV && c(await WV);
33868
+ if (HV === s && !e) {
33869
+ UV && c(await UV);
33865
33870
  return;
33866
33871
  }
33867
- e && (UV = null, WV = null), UV = s, i(!0), o(null), WV = (async () => (await n({
33872
+ e && (HV = null, UV = null), HV = s, i(!0), o(null), UV = (async () => (await n({
33868
33873
  serviceAccount: a.serviceAccount,
33869
33874
  serviceKey: a.serviceKey
33870
33875
  })).access_token ?? null)();
33871
33876
  try {
33872
- c(await WV);
33877
+ c(await UV);
33873
33878
  } catch (e) {
33874
- HV.error("GenAI login failed", { error: e instanceof Error ? e.message : String(e) }), o("Failed to authenticate with GenAI service");
33879
+ VV.error("GenAI login failed", { error: e instanceof Error ? e.message : String(e) }), o("Failed to authenticate with GenAI service");
33875
33880
  } finally {
33876
- WV = null, i(!1);
33881
+ UV = null, i(!1);
33877
33882
  }
33878
33883
  })();
33879
33884
  }, [
@@ -33889,12 +33894,12 @@ function GV(e = !1) {
33889
33894
  }
33890
33895
  //#endregion
33891
33896
  //#region src/queries/genai/useTenantSwitchMutation.ts
33892
- var KV = kV({
33897
+ var GV = kV({
33893
33898
  mutationKey: ["genai", "tenant-switch"],
33894
33899
  mutationFn: async ({ tenant_id: e, token: t }) => OV.switchTenant(e, t)
33895
- }), qV = new pD("useGenaiTenantSwitch"), JV = null, YV = null;
33896
- function XV(e, t, n = !1) {
33897
- let { mutateAsync: r } = KV(), [i, a] = y(!1), [o, s] = y(null), [c, l] = y(!1);
33900
+ }), KV = new pD("useGenaiTenantSwitch"), qV = null, JV = null;
33901
+ function YV(e, t, n = !1) {
33902
+ let { mutateAsync: r } = GV(), [i, a] = y(!1), [o, s] = y(null), [c, l] = y(!1);
33898
33903
  return f(() => {
33899
33904
  (async () => {
33900
33905
  if (!e || !t) return;
@@ -33903,22 +33908,22 @@ function XV(e, t, n = !1) {
33903
33908
  l(!0);
33904
33909
  return;
33905
33910
  }
33906
- if (YV === e && !n) {
33907
- JV && (await JV, l(!!bF()));
33911
+ if (JV === e && !n) {
33912
+ qV && (await qV, l(!!bF()));
33908
33913
  return;
33909
33914
  }
33910
- n && (YV = null, JV = null), YV = e, a(!0), s(null), JV = (async () => {
33915
+ n && (JV = null, qV = null), JV = e, a(!0), s(null), qV = (async () => {
33911
33916
  await r({
33912
33917
  tenant_id: t,
33913
33918
  token: e
33914
33919
  });
33915
33920
  })();
33916
33921
  try {
33917
- await JV, l(!0);
33922
+ await qV, l(!0);
33918
33923
  } catch (e) {
33919
- qV.error("GenAI tenant switch failed", { error: e instanceof Error ? e.message : String(e) }), s("Failed to switch tenant");
33924
+ KV.error("GenAI tenant switch failed", { error: e instanceof Error ? e.message : String(e) }), s("Failed to switch tenant");
33920
33925
  } finally {
33921
- JV = null, a(!1);
33926
+ qV = null, a(!1);
33922
33927
  }
33923
33928
  })();
33924
33929
  }, [
@@ -33934,8 +33939,8 @@ function XV(e, t, n = !1) {
33934
33939
  }
33935
33940
  //#endregion
33936
33941
  //#region src/hooks/useGenaiAuth.ts
33937
- function ZV(e = !1) {
33938
- let { isLoggingIn: t, loginError: n, loginToken: r, genaiInit: i } = GV(e), { isSwitching: a, switchError: o, hasToken: s } = XV(r, i?.tenantId, e);
33942
+ function XV(e = !1) {
33943
+ let { isLoggingIn: t, loginError: n, loginToken: r, genaiInit: i } = WV(e), { isSwitching: a, switchError: o, hasToken: s } = YV(r, i?.tenantId, e);
33939
33944
  return {
33940
33945
  isAuthenticating: t || a,
33941
33946
  authError: n ?? o,
@@ -33944,7 +33949,7 @@ function ZV(e = !1) {
33944
33949
  }
33945
33950
  //#endregion
33946
33951
  //#region src/hooks/usePanelState.ts
33947
- function QV(e = {}) {
33952
+ function ZV(e = {}) {
33948
33953
  let { defaultOpen: t = !1, persist: n = !0 } = e, [r, i] = nt({
33949
33954
  key: n ? sD.PANEL_OPEN : `panel-state-${Date.now()}`,
33950
33955
  defaultValue: t,
@@ -33975,14 +33980,14 @@ function QV(e = {}) {
33975
33980
  }
33976
33981
  //#endregion
33977
33982
  //#region src/hooks/useAgentChatUiOptions.ts
33978
- var $V = {
33983
+ var QV = {
33979
33984
  bottom: 24,
33980
33985
  right: 24
33981
- }, eH = 1e4;
33982
- function tH(e) {
33983
- let t = e?.panelWidth ?? 420, n = e?.panelHeight ?? "100%", r = e?.panelHeaderHeight ?? 56, i = e?.panelTopOffset, a = e?.zIndex ?? eH, o = {
33984
- ...typeof e?.fabTopOffset == "number" ? { top: e.fabTopOffset } : { bottom: e?.fabBottomOffset ?? $V.bottom },
33985
- ...typeof e?.fabLeftOffset == "number" ? { left: e.fabLeftOffset } : { right: e?.fabRightOffset ?? $V.right }
33986
+ }, $V = 1e4;
33987
+ function eH(e) {
33988
+ let t = e?.panelWidth ?? 420, n = e?.panelHeight ?? "100%", r = e?.panelHeaderHeight ?? 56, i = e?.panelTopOffset, a = e?.zIndex ?? $V, o = {
33989
+ ...typeof e?.fabTopOffset == "number" ? { top: e.fabTopOffset } : { bottom: e?.fabBottomOffset ?? QV.bottom },
33990
+ ...typeof e?.fabLeftOffset == "number" ? { left: e.fabLeftOffset } : { right: e?.fabRightOffset ?? QV.right }
33986
33991
  }, s = e?.panelTitle ?? "Agent Chat";
33987
33992
  return {
33988
33993
  panelWidth: t,
@@ -33998,7 +34003,7 @@ function tH(e) {
33998
34003
  }
33999
34004
  //#endregion
34000
34005
  //#region src/hooks/useAgentChatActions.ts
34001
- function nH(e, t) {
34006
+ function tH(e, t) {
34002
34007
  let n = v([]);
34003
34008
  return {
34004
34009
  actions: _(() => {
@@ -34014,7 +34019,7 @@ function nH(e, t) {
34014
34019
  }
34015
34020
  //#endregion
34016
34021
  //#region src/hooks/useResizable.ts
34017
- function rH(e = {}) {
34022
+ function nH(e = {}) {
34018
34023
  let { axis: t = "y", direction: n = 1, onResizeChange: r } = e, [i, a] = y(0), o = v({
34019
34024
  startPos: 0,
34020
34025
  startOffset: 0
@@ -34052,7 +34057,7 @@ function rH(e = {}) {
34052
34057
  }
34053
34058
  //#endregion
34054
34059
  //#region src/hooks/useAgentChatLayout.ts
34055
- var iH = [
34060
+ var rH = [
34056
34061
  "#root main",
34057
34062
  "#root",
34058
34063
  "main",
@@ -34060,9 +34065,9 @@ var iH = [
34060
34065
  "#app",
34061
34066
  "body"
34062
34067
  ];
34063
- function aH(e, t, n) {
34068
+ function iH(e, t, n) {
34064
34069
  let r = v(Math.max(280, t ?? 420)), i = v(n ?? !1), a = v(null), o = u(() => {
34065
- let t = e?.hostContainerSelector, n = [...t ? t.split(",").map((e) => e.trim()).filter(Boolean) : [], ...iH];
34070
+ let t = e?.hostContainerSelector, n = [...t ? t.split(",").map((e) => e.trim()).filter(Boolean) : [], ...rH];
34066
34071
  for (let e of n) {
34067
34072
  let t = document.querySelector(e);
34068
34073
  if (t) return t;
@@ -34088,7 +34093,7 @@ function aH(e, t, n) {
34088
34093
  }
34089
34094
  let { element: n, inlinePaddingBefore: r, widthApplied: i } = a.current;
34090
34095
  e !== i && (n.style.paddingRight = r, n.style.paddingRight = `calc(${r || "0px"} + ${e}px)`, a.current.widthApplied = e);
34091
- }, [o]), c = rH({
34096
+ }, [o]), c = nH({
34092
34097
  axis: "x",
34093
34098
  direction: -1,
34094
34099
  onResizeChange: u((e) => {
@@ -34113,7 +34118,7 @@ function aH(e, t, n) {
34113
34118
  }
34114
34119
  //#endregion
34115
34120
  //#region src/hooks/useAgentChatVoiceHandlers.ts
34116
- function oH({ isListening: e, stopListening: t, reset: n, sendMessage: r, composerText: i, setComposerText: a, startListening: o, close: s }) {
34121
+ function aH({ isListening: e, stopListening: t, reset: n, sendMessage: r, composerText: i, setComposerText: a, startListening: o, close: s }) {
34117
34122
  return {
34118
34123
  handleSubmit: () => {
34119
34124
  e && t(), n(), r(i);
@@ -34128,7 +34133,7 @@ function oH({ isListening: e, stopListening: t, reset: n, sendMessage: r, compos
34128
34133
  }
34129
34134
  //#endregion
34130
34135
  //#region src/utils/color-utils.ts
34131
- function sH(e) {
34136
+ function oH(e) {
34132
34137
  let t = 0, n = 0, r = 0;
34133
34138
  if (e.startsWith("rgb")) {
34134
34139
  let i = e.match(/\d+/g);
@@ -34143,16 +34148,16 @@ function sH(e) {
34143
34148
  b: r
34144
34149
  };
34145
34150
  }
34146
- function cH(e, t) {
34147
- let { r: n, g: r, b: i } = sH(e), a = t / 100;
34151
+ function sH(e, t) {
34152
+ let { r: n, g: r, b: i } = oH(e), a = t / 100;
34148
34153
  return `rgb(${Math.min(255, n + (255 - n) * a)}, ${Math.min(255, r + (255 - r) * a)}, ${Math.min(255, i + (255 - i) * a)})`;
34149
34154
  }
34150
- function lH(e, t) {
34151
- let { r: n, g: r, b: i } = sH(e), a = t / 100;
34155
+ function cH(e, t) {
34156
+ let { r: n, g: r, b: i } = oH(e), a = t / 100;
34152
34157
  return `rgb(${Math.max(0, n - n * a)}, ${Math.max(0, r - r * a)}, ${Math.max(0, i - i * a)})`;
34153
34158
  }
34154
- function uH(e) {
34155
- let { r: t, g: n, b: r } = sH(e);
34159
+ function lH(e) {
34160
+ let { r: t, g: n, b: r } = oH(e);
34156
34161
  return [
34157
34162
  `rgb(${t + 50}, ${n + 50}, ${r + 50})`,
34158
34163
  `rgb(${t + 40}, ${n + 40}, ${r + 40})`,
@@ -34169,35 +34174,35 @@ function uH(e) {
34169
34174
  }
34170
34175
  //#endregion
34171
34176
  //#region src/hooks/useAccentColor.ts
34172
- var dH = new pD("useAccentColor");
34173
- function fH(e) {
34177
+ var uH = new pD("useAccentColor");
34178
+ function dH(e) {
34174
34179
  let t = _(() => {
34175
34180
  if (e) try {
34176
- let t = uH(e);
34181
+ let t = lH(e);
34177
34182
  if (t && t.length === 11) return nT({
34178
34183
  colors: { accent: t },
34179
34184
  primaryColor: "accent"
34180
34185
  });
34181
34186
  } catch (e) {
34182
- dH.error("Failed to create theme with accent color", { error: e instanceof Error ? e.message : String(e) });
34187
+ uH.error("Failed to create theme with accent color", { error: e instanceof Error ? e.message : String(e) });
34183
34188
  }
34184
34189
  return rT;
34185
34190
  }, [e]);
34186
34191
  return f(() => {
34187
34192
  try {
34188
- let t = document.documentElement, n = e || "#414275", r = cH(n, 40), i = lH(n, 15);
34189
- t.style.setProperty("--agent-accent-color", n), t.style.setProperty("--agent-accent-color-light", cH(n, 40)), t.style.setProperty("--agent-accent-color-dark", i), t.style.setProperty("--agent-accent-bg", n), t.style.setProperty("--agent-accent-bg-light", r), t.style.setProperty("--agent-accent-border", n), t.style.setProperty("--agent-accent-text", "#ffffff"), t.style.setProperty("--agent-accent-text-muted", "rgba(255, 255, 255, 0.8)");
34193
+ let t = document.documentElement, n = e || "#414275", r = sH(n, 40), i = cH(n, 15);
34194
+ t.style.setProperty("--agent-accent-color", n), t.style.setProperty("--agent-accent-color-light", sH(n, 40)), t.style.setProperty("--agent-accent-color-dark", i), t.style.setProperty("--agent-accent-bg", n), t.style.setProperty("--agent-accent-bg-light", r), t.style.setProperty("--agent-accent-border", n), t.style.setProperty("--agent-accent-text", "#ffffff"), t.style.setProperty("--agent-accent-text-muted", "rgba(255, 255, 255, 0.8)");
34190
34195
  } catch (e) {
34191
- dH.error("Failed to set accent color CSS properties", { error: e instanceof Error ? e.message : String(e) });
34196
+ uH.error("Failed to set accent color CSS properties", { error: e instanceof Error ? e.message : String(e) });
34192
34197
  }
34193
34198
  }, [e]), t;
34194
34199
  }
34195
34200
  //#endregion
34196
34201
  //#region src/features/agent-chat/components/AgentChatLauncher/AgentChatLauncher.tsx
34197
- function pH(e) {
34198
- let t = d(QP).forceReAuth, { isAuthenticating: n, hasToken: r } = ZV(t), { panelWidth: i, panelHeight: a, panelHeaderHeight: o, panelTopOffset: s, zIndex: c, fabPosition: l, fabButtonLabel: u, panelTitle: p, accentColor: m } = tH(e);
34199
- fH(m);
34200
- let h = v(!1), { messages: g, composerText: _, setComposerText: y, isLoading: b, error: x, sendMessage: S, sendInitialMessage: C, canSend: D } = MV(), { actions: O, handleActionClick: k } = nH(g, S), { runtimeInfo: A, refreshRuntimeInfo: j } = NV(), { isOpen: M, open: N, close: P } = QV({
34202
+ function fH(e) {
34203
+ let t = d(QP).forceReAuth, { isAuthenticating: n, hasToken: r } = XV(t), { panelWidth: i, panelHeight: a, panelHeaderHeight: o, panelTopOffset: s, zIndex: c, fabPosition: l, fabButtonLabel: u, panelTitle: p, accentColor: m } = eH(e);
34204
+ dH(m);
34205
+ let h = v(!1), { messages: g, composerText: _, setComposerText: y, isLoading: b, error: x, sendMessage: S, sendInitialMessage: C, canSend: D } = MV(), { actions: O, handleActionClick: k } = tH(g, S), { runtimeInfo: A, refreshRuntimeInfo: j } = NV(), { isOpen: M, open: N, close: P } = ZV({
34201
34206
  defaultOpen: !1,
34202
34207
  persist: !0,
34203
34208
  onOpen: async () => {
@@ -34214,12 +34219,12 @@ function pH(e) {
34214
34219
  r,
34215
34220
  C
34216
34221
  ]);
34217
- let F = FV([g.length, b]), { isListening: ee, isSupported: te, startListening: I, stopListening: L, reset: R } = LV({
34218
- lang: RV(),
34222
+ let F = FV([g.length, b]), { isListening: ee, isSupported: te, startListening: I, stopListening: L, reset: R } = IV({
34223
+ lang: LV(),
34219
34224
  continuous: !0,
34220
34225
  pauseOnSubmit: !0,
34221
34226
  onTextChange: y
34222
- }), { panelResizableWidth: ne } = aH(e, i, M), { handleSubmit: re, handleToggleVoice: ie, handleClose: ae } = oH({
34227
+ }), { panelResizableWidth: ne } = iH(e, i, M), { handleSubmit: re, handleToggleVoice: ie, handleClose: ae } = aH({
34223
34228
  isListening: ee,
34224
34229
  stopListening: L,
34225
34230
  reset: R,
@@ -34262,13 +34267,13 @@ function pH(e) {
34262
34267
  }
34263
34268
  //#endregion
34264
34269
  //#region src/providers/AgentChatProviders.tsx
34265
- function mH({ runtime: e, children: t }) {
34270
+ function pH({ runtime: e, children: t }) {
34266
34271
  return /* @__PURE__ */ T(QP.Provider, {
34267
34272
  value: e,
34268
34273
  children: t
34269
34274
  });
34270
34275
  }
34271
- function hH({ config: e, children: t }) {
34276
+ function mH({ config: e, children: t }) {
34272
34277
  return /* @__PURE__ */ T(eF.Provider, {
34273
34278
  value: e,
34274
34279
  children: t
@@ -34276,10 +34281,10 @@ function hH({ config: e, children: t }) {
34276
34281
  }
34277
34282
  //#endregion
34278
34283
  //#region src/providers/ConfigProvider.tsx
34279
- var gH = ({ children: e, config: t }) => /* @__PURE__ */ T(zV.Provider, {
34284
+ var hH = ({ children: e, config: t }) => /* @__PURE__ */ T(RV.Provider, {
34280
34285
  value: t,
34281
34286
  children: e
34282
- }), _H = {
34287
+ }), gH = {
34283
34288
  url: {
34284
34289
  app: "http://localhost:4201",
34285
34290
  api: "https://cognitus-etiyacell.etiyacloud.com",
@@ -34325,12 +34330,12 @@ var gH = ({ children: e, config: t }) => /* @__PURE__ */ T(zV.Provider, {
34325
34330
  tenantId: 54
34326
34331
  }
34327
34332
  }
34328
- }, vH = null;
34329
- function yH() {
34330
- return vH;
34333
+ }, _H = null;
34334
+ function vH() {
34335
+ return _H;
34331
34336
  }
34332
- function bH(e) {
34333
- let t = _H.genai?.init;
34337
+ function yH(e) {
34338
+ let t = gH.genai?.init;
34334
34339
  return !t || e.genai?.init ? e : {
34335
34340
  ...e,
34336
34341
  genai: {
@@ -34339,23 +34344,22 @@ function bH(e) {
34339
34344
  }
34340
34345
  };
34341
34346
  }
34342
- async function xH(e) {
34347
+ async function bH(e) {
34343
34348
  let t = `${(globalThis.__BASE_URL__ ?? "").replace(/\/$/, "")}/environment.json`, n = e ?? t;
34344
34349
  try {
34345
34350
  let e = await fetch(n);
34346
- if (!e.ok) return vH = _H, _H;
34347
- let t = bH(await e.json());
34348
- return vH = t, t;
34351
+ if (!e.ok) return _H = gH, gH;
34352
+ let t = yH(await e.json());
34353
+ return _H = t, t;
34349
34354
  } catch {
34350
- return vH = _H, _H;
34355
+ return _H = gH, gH;
34351
34356
  }
34352
34357
  }
34353
34358
  //#endregion
34354
34359
  //#region src/lib/agent-widget.tsx
34355
- var SH = new pD("AgentChatWidget");
34356
- function CH({ config: e, runtime: t, theme: n }) {
34360
+ function xH({ config: e, runtime: t, theme: n }) {
34357
34361
  bI.locale || bI.activate("en");
34358
- let r = fH(n?.accentColor), i = yH();
34362
+ let r = dH(n?.accentColor), i = vH();
34359
34363
  return i ? /* @__PURE__ */ T($O, {
34360
34364
  i18n: bI,
34361
34365
  children: /* @__PURE__ */ T(Gn, {
@@ -34363,38 +34367,38 @@ function CH({ config: e, runtime: t, theme: n }) {
34363
34367
  defaultColorScheme: "auto",
34364
34368
  children: /* @__PURE__ */ T(eR, {
34365
34369
  client: gV,
34366
- children: /* @__PURE__ */ T(gH, {
34370
+ children: /* @__PURE__ */ T(hH, {
34367
34371
  config: i,
34368
- children: /* @__PURE__ */ T(hH, {
34372
+ children: /* @__PURE__ */ T(mH, {
34369
34373
  config: e,
34370
- children: /* @__PURE__ */ T(mH, {
34374
+ children: /* @__PURE__ */ T(pH, {
34371
34375
  runtime: t,
34372
- children: /* @__PURE__ */ T(pH, { ...n ?? {} })
34376
+ children: /* @__PURE__ */ T(fH, { ...n ?? {} })
34373
34377
  })
34374
34378
  })
34375
34379
  })
34376
34380
  })
34377
34381
  })
34378
- }) : (SH.error("No environment config loaded. Login will not work."), null);
34382
+ }) : (console.log("AgentChatWidget: No environment config loaded. Login will not work."), null);
34379
34383
  }
34380
34384
  //#endregion
34381
34385
  //#region src/lib/mount-widget.tsx
34382
- var wH = new pD("mount-widget"), TH = /* @__PURE__ */ new WeakMap();
34383
- async function EH(e, t, n) {
34386
+ var SH = /* @__PURE__ */ new WeakMap();
34387
+ async function CH(e, t, n) {
34384
34388
  try {
34385
- CV(await xH(n?.environmentUrl));
34389
+ CV(await bH(n?.environmentUrl));
34386
34390
  } catch (e) {
34387
- throw wH.error("Failed to initialize agent widget rest services", { error: e instanceof Error ? e.message : String(e) }), e;
34391
+ throw console.log("mountAgentChatWidget: Failed to initialize agent widget rest services", e), e;
34388
34392
  }
34389
- let r = TH.get(e);
34393
+ let r = SH.get(e);
34390
34394
  r && r.unmount();
34391
34395
  let i = D(e);
34392
- return i.render(/* @__PURE__ */ T(CH, { ...t })), TH.set(e, i), () => {
34393
- let t = TH.get(e);
34394
- t && (t.unmount(), TH.delete(e));
34396
+ return i.render(/* @__PURE__ */ T(xH, { ...t })), SH.set(e, i), () => {
34397
+ let t = SH.get(e);
34398
+ t && (t.unmount(), SH.delete(e));
34395
34399
  };
34396
34400
  }
34397
- function DH(e) {
34401
+ function wH(e) {
34398
34402
  let t = e.genai?.config;
34399
34403
  if (!t?.assistantId) throw Error("GenAI config is missing in environment.json.");
34400
34404
  return {
@@ -34402,24 +34406,24 @@ function DH(e) {
34402
34406
  agents: t.agents
34403
34407
  };
34404
34408
  }
34405
- function OH(e, t) {
34409
+ function TH(e, t) {
34406
34410
  return t ? {
34407
34411
  assistantId: t.assistantId ?? e.assistantId,
34408
34412
  agents: t.agents ?? e.agents
34409
34413
  } : e;
34410
34414
  }
34411
- function kH(e, t) {
34415
+ function EH(e, t) {
34412
34416
  return t ? (e.genai ||= {}, e.genai.config || (e.genai.config = {}), typeof t.assistantId == "number" && (e.genai.config.assistantId = t.assistantId), t.agents && (e.genai.config.agents = t.agents), e) : e;
34413
34417
  }
34414
- async function AH(e, t) {
34415
- let n = kH(await xH(t.environmentUrl), t.config);
34416
- return CV(n), EH(e, {
34417
- config: OH(DH(n), t.config),
34418
+ async function DH(e, t) {
34419
+ let n = EH(await bH(t.environmentUrl), t.config);
34420
+ return CV(n), CH(e, {
34421
+ config: TH(wH(n), t.config),
34418
34422
  runtime: t.runtime,
34419
34423
  theme: t.theme
34420
34424
  });
34421
34425
  }
34422
34426
  //#endregion
34423
- export { CH as AgentChatWidget, pD as Logger, EH as mountAgentChatWidget, AH as mountAgentChatWidgetFromEnvironment };
34427
+ export { xH as AgentChatWidget, pD as Logger, CH as mountAgentChatWidget, DH as mountAgentChatWidgetFromEnvironment };
34424
34428
 
34425
34429
  //# sourceMappingURL=agent-widget.js.map