@websolutespa/bom-llm 0.2.5 → 0.2.6

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/umd/index.js CHANGED
@@ -19,36 +19,36 @@
19
19
  return Object.freeze(n);
20
20
  }
21
21
 
22
- /**
23
- * Checks if the given item is a number.
24
- * @param item The item to check.
25
- * @returns True if the item is a number, false otherwise.
22
+ /**
23
+ * Checks if the given item is a number.
24
+ * @param item The item to check.
25
+ * @returns True if the item is a number, false otherwise.
26
26
  */
27
27
 
28
- /**
29
- * Checks if the given item is an array.
30
- * @param item The item to check.
31
- * @returns True if the item is an array, false otherwise.
28
+ /**
29
+ * Checks if the given item is an array.
30
+ * @param item The item to check.
31
+ * @returns True if the item is an array, false otherwise.
32
32
  */
33
33
  function isArray(item) {
34
34
  return Array.isArray(item);
35
35
  }
36
36
 
37
- /**
38
- * Checks if the given item is an object.
39
- * @param item The item to check.
40
- * @returns True if the item is an object, false otherwise.
37
+ /**
38
+ * Checks if the given item is an object.
39
+ * @param item The item to check.
40
+ * @returns True if the item is an object, false otherwise.
41
41
  */
42
42
  function isObject$3(item) {
43
43
  return item != null && typeof item === 'object' && !isArray(item);
44
44
  }
45
45
 
46
- /**
47
- * PascalCase
48
- * camelCase
49
- * kebab-case
50
- * snake_case
51
- * char*case
46
+ /**
47
+ * PascalCase
48
+ * camelCase
49
+ * kebab-case
50
+ * snake_case
51
+ * char*case
52
52
  **/
53
53
 
54
54
  function unknownCaseToPascalCase(unknownCase) {
@@ -85,20 +85,20 @@
85
85
  return kebabCase;
86
86
  }
87
87
 
88
- /**
89
- * Represents a primitive value that can be used in the deep merge operation.
88
+ /**
89
+ * Represents a primitive value that can be used in the deep merge operation.
90
90
  */
91
91
 
92
- /**
93
- * Represents a dynamic value that can be used in the deep merge operation.
92
+ /**
93
+ * Represents a dynamic value that can be used in the deep merge operation.
94
94
  */
95
95
 
96
- /**
97
- * Deeply merges two objects or arrays.
98
- *
99
- * @param target - The target object or array to merge into.
100
- * @param source - The source object or array to merge from.
101
- * @returns The merged object or array.
96
+ /**
97
+ * Deeply merges two objects or arrays.
98
+ *
99
+ * @param target - The target object or array to merge into.
100
+ * @param source - The source object or array to merge from.
101
+ * @returns The merged object or array.
102
102
  */
103
103
  function deepMerge(target, source) {
104
104
  const output = {
@@ -122,19 +122,19 @@
122
122
 
123
123
  const isBrowser$1 = typeof window !== 'undefined';
124
124
 
125
- /**
126
- * Checks if the given value is an instance of IClassNameCollection.
127
- * @param value - The value to check.
128
- * @returns True if the value is an instance of IClassNameCollection, false otherwise.
125
+ /**
126
+ * Checks if the given value is an instance of IClassNameCollection.
127
+ * @param value - The value to check.
128
+ * @returns True if the value is an instance of IClassNameCollection, false otherwise.
129
129
  */
130
130
  function isClassNameCollection(value) {
131
131
  return typeof value === 'object' && !Array.isArray(value);
132
132
  }
133
133
 
134
- /**
135
- * Converts an IClassNameCollection object to a string of class names.
136
- * @param className - The IClassNameCollection object.
137
- * @returns A string of class names.
134
+ /**
135
+ * Converts an IClassNameCollection object to a string of class names.
136
+ * @param className - The IClassNameCollection object.
137
+ * @returns A string of class names.
138
138
  */
139
139
  function classNameCollectionToString(className) {
140
140
  const keys = Object.keys(className);
@@ -151,10 +151,10 @@
151
151
  return classNames;
152
152
  }
153
153
 
154
- /**
155
- * Combines multiple IClassName objects into a single string of class names.
156
- * @param props - The IClassName objects to combine.
157
- * @returns A string of class names.
154
+ /**
155
+ * Combines multiple IClassName objects into a single string of class names.
156
+ * @param props - The IClassName objects to combine.
157
+ * @returns A string of class names.
158
158
  */
159
159
  function getClassNames() {
160
160
  const total = arguments.length;
@@ -182,11 +182,11 @@
182
182
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
183
183
  }
184
184
 
185
- /**
186
- * Retrieves the default locale.
187
- * If the process environment variable DEFAULT_LOCALE is defined, it will be used as the default locale.
188
- * Otherwise, the default locale will be set to 'en'.
189
- * @returns The default locale.
185
+ /**
186
+ * Retrieves the default locale.
187
+ * If the process environment variable DEFAULT_LOCALE is defined, it will be used as the default locale.
188
+ * Otherwise, the default locale will be set to 'en'.
189
+ * @returns The default locale.
190
190
  */
191
191
  function getDefaultLocale() {
192
192
  let defaultLocale = 'en';
@@ -199,10 +199,10 @@
199
199
 
200
200
  const DEFAULT_LOCALE = defaultLocale;
201
201
 
202
- /**
203
- * Checks if a value is a localized string.
204
- * @param value - The value to check.
205
- * @returns A boolean indicating whether the value is a localized string.
202
+ /**
203
+ * Checks if a value is a localized string.
204
+ * @param value - The value to check.
205
+ * @returns A boolean indicating whether the value is a localized string.
206
206
  */
207
207
  function isLocalizedString(value) {
208
208
  let isLocalizedString = false;
@@ -215,12 +215,12 @@
215
215
  return isLocalizedString;
216
216
  }
217
217
 
218
- /**
219
- * Converts a localized string object to a string based on the specified locale.
220
- * @param json - The localized string object.
221
- * @param locale - The locale to use.
222
- * @param defaultLocale - The default locale to use if the specified locale is not found.
223
- * @returns The localized string.
218
+ /**
219
+ * Converts a localized string object to a string based on the specified locale.
220
+ * @param json - The localized string object.
221
+ * @param locale - The locale to use.
222
+ * @param defaultLocale - The default locale to use if the specified locale is not found.
223
+ * @returns The localized string.
224
224
  */
225
225
  function localizedToString(json, locale, defaultLocale) {
226
226
  if (defaultLocale === void 0) {
@@ -230,12 +230,12 @@
230
230
  return localizedString;
231
231
  }
232
232
 
233
- /**
234
- * Localizes a value or an array/object of values based on the specified locale.
235
- * @param value - The value or array/object of values to localize.
236
- * @param locale - The locale to use.
237
- * @param defaultLocale - The default locale to use if the specified locale is not found.
238
- * @returns The localized value or array/object of localized values.
233
+ /**
234
+ * Localizes a value or an array/object of values based on the specified locale.
235
+ * @param value - The value or array/object of values to localize.
236
+ * @param locale - The locale to use.
237
+ * @param defaultLocale - The default locale to use if the specified locale is not found.
238
+ * @returns The localized value or array/object of localized values.
239
239
  */
240
240
  function localizeValue(value, locale, defaultLocale) {
241
241
  if (defaultLocale === void 0) {
@@ -250,12 +250,12 @@
250
250
  }
251
251
  }
252
252
 
253
- /**
254
- * Localizes an array/object of values based on the specified locale.
255
- * @param item - The array/object of values to localize.
256
- * @param locale - The locale to use.
257
- * @param defaultLocale - The default locale to use if the specified locale is not found.
258
- * @returns The localized array/object of values.
253
+ /**
254
+ * Localizes an array/object of values based on the specified locale.
255
+ * @param item - The array/object of values to localize.
256
+ * @param locale - The locale to use.
257
+ * @param defaultLocale - The default locale to use if the specified locale is not found.
258
+ * @returns The localized array/object of values.
259
259
  */
260
260
  function localizeItem(item, locale, defaultLocale) {
261
261
  if (defaultLocale === void 0) {
@@ -8792,41 +8792,41 @@
8792
8792
  }, locale);
8793
8793
  }
8794
8794
 
8795
- /*
8796
- import { useMemo } from 'react';
8797
- import { useNumber } from '../useNumber/useNumber';
8798
- import { useLayout } from '../useLayout/useLayout';
8799
-
8800
- export function useCurrency(currency: string = 'EUR', locale?: string): (value: number) => string {
8801
- const layout = useLayout();
8802
- const currentLocale = locale || layout.locale;
8803
-
8804
- const formatter = useMemo(() => {
8805
- const options = { style: 'currency', currency };
8806
- const formatter = new Intl.NumberFormat(currentLocale, options).format;
8807
- return formatter;
8808
- }, [currency, currentLocale]);
8809
-
8810
- return formatter;
8811
- }
8812
-
8795
+ /*
8796
+ import { useMemo } from 'react';
8797
+ import { useNumber } from '../useNumber/useNumber';
8798
+ import { useLayout } from '../useLayout/useLayout';
8799
+
8800
+ export function useCurrency(currency: string = 'EUR', locale?: string): (value: number) => string {
8801
+ const layout = useLayout();
8802
+ const currentLocale = locale || layout.locale;
8803
+
8804
+ const formatter = useMemo(() => {
8805
+ const options = { style: 'currency', currency };
8806
+ const formatter = new Intl.NumberFormat(currentLocale, options).format;
8807
+ return formatter;
8808
+ }, [currency, currentLocale]);
8809
+
8810
+ return formatter;
8811
+ }
8812
+
8813
8813
  */
8814
8814
 
8815
- /*
8816
-
8817
- export function useCurrency(value: number, currency: string = 'EUR', locale?: string): string {
8818
-
8819
- const layout = useLayout();
8820
-
8821
- const currentLocale = locale || layout.locale;
8822
-
8823
- return useMemo(() => {
8824
- const options = { style: 'currency', currency };
8825
- const formattedValue = new Intl.NumberFormat(currentLocale, options).format(value);
8826
- return formattedValue;
8827
- }, [value, currency, currentLocale]);
8828
- }
8829
-
8815
+ /*
8816
+
8817
+ export function useCurrency(value: number, currency: string = 'EUR', locale?: string): string {
8818
+
8819
+ const layout = useLayout();
8820
+
8821
+ const currentLocale = locale || layout.locale;
8822
+
8823
+ return useMemo(() => {
8824
+ const options = { style: 'currency', currency };
8825
+ const formattedValue = new Intl.NumberFormat(currentLocale, options).format(value);
8826
+ return formattedValue;
8827
+ }, [value, currency, currentLocale]);
8828
+ }
8829
+
8830
8830
  */
8831
8831
 
8832
8832
  function useDateTimeFormat(options, locale) {
@@ -8901,13 +8901,13 @@
8901
8901
  return [state, setState];
8902
8902
  }
8903
8903
 
8904
- /**
8905
- * KeyBinding Codes
8906
- * The content of this file is based on the design of the open source project "microsoft/vscode",
8907
- * Copyright (c) Microsoft Corporation. All rights reserved.
8908
- *
8909
- * We inherit the KeyMod values from "microsoft/vscode",
8910
- * but use the Browser's KeyboardEvent event implementation, and all values are used only as identification.
8904
+ /**
8905
+ * KeyBinding Codes
8906
+ * The content of this file is based on the design of the open source project "microsoft/vscode",
8907
+ * Copyright (c) Microsoft Corporation. All rights reserved.
8908
+ *
8909
+ * We inherit the KeyMod values from "microsoft/vscode",
8910
+ * but use the Browser's KeyboardEvent event implementation, and all values are used only as identification.
8911
8911
  */
8912
8912
 
8913
8913
  let KeyCode = /*#__PURE__*/function (KeyCode) {
@@ -9141,20 +9141,20 @@
9141
9141
  });
9142
9142
  }
9143
9143
 
9144
- /*
9145
- import { useCallback, useEffect, useRef } from 'react';
9146
-
9147
- export function useMounted(): () => boolean {
9148
- const ref = useRef<boolean>(false);
9149
- const get = useCallback(() => ref.current, []);
9150
- useEffect(() => {
9151
- ref.current = true;
9152
- return () => {
9153
- ref.current = false;
9154
- };
9155
- }, []);
9156
- return get;
9157
- }
9144
+ /*
9145
+ import { useCallback, useEffect, useRef } from 'react';
9146
+
9147
+ export function useMounted(): () => boolean {
9148
+ const ref = useRef<boolean>(false);
9149
+ const get = useCallback(() => ref.current, []);
9150
+ useEffect(() => {
9151
+ ref.current = true;
9152
+ return () => {
9153
+ ref.current = false;
9154
+ };
9155
+ }, []);
9156
+ return get;
9157
+ }
9158
9158
  */
9159
9159
 
9160
9160
  function useMounted() {
@@ -19875,6 +19875,21 @@
19875
19875
  }
19876
19876
  }
19877
19877
 
19878
+ const LLM_MINIMIZED_KEY = 'llm-minimized';
19879
+ function getPersistedMinimized() {
19880
+ try {
19881
+ return sessionStorage.getItem(LLM_MINIMIZED_KEY) === 'true';
19882
+ } catch {
19883
+ return false;
19884
+ }
19885
+ }
19886
+ function persistMinimized(minimized) {
19887
+ try {
19888
+ sessionStorage.setItem(LLM_MINIMIZED_KEY, String(minimized));
19889
+ } catch {
19890
+ // error
19891
+ }
19892
+ }
19878
19893
  const createLlmViewStore = _ref => {
19879
19894
  let {
19880
19895
  threadId,
@@ -19905,6 +19920,7 @@
19905
19920
  fixed: false,
19906
19921
  idle: true,
19907
19922
  visible: false,
19923
+ minimized: getPersistedMinimized(),
19908
19924
  scrollable: false,
19909
19925
  direction: 0
19910
19926
  };
@@ -19980,13 +19996,13 @@
19980
19996
  lastScrollTop = 0;
19981
19997
  }
19982
19998
  };
19983
- /*
19984
- if ('ResizeObserver' in window) {
19985
- const resizeObserver = new ResizeObserver((entries) => {
19986
- onScroll();
19987
- });
19988
- resizeObserver.observe(document.scrollingElement as HTMLElement);
19989
- }
19999
+ /*
20000
+ if ('ResizeObserver' in window) {
20001
+ const resizeObserver = new ResizeObserver((entries) => {
20002
+ onScroll();
20003
+ });
20004
+ resizeObserver.observe(document.scrollingElement as HTMLElement);
20005
+ }
19990
20006
  */
19991
20007
  window.addEventListener('scroll', onScroll);
19992
20008
  window.addEventListener('resize', onResize);
@@ -20030,9 +20046,11 @@
20030
20046
  },
20031
20047
  send: async (prompt, onMessage, onEnd) => {
20032
20048
  await send(prompt, () => {
20049
+ persistMinimized(false);
20033
20050
  set({
20034
20051
  skipCustomIntro: true,
20035
- opened: true
20052
+ opened: true,
20053
+ minimized: false
20036
20054
  });
20037
20055
  setTimeout(() => {
20038
20056
  }, 50);
@@ -20053,8 +20071,10 @@
20053
20071
  pushDataLayer({
20054
20072
  event: opened ? 'llm_open' : 'llm_close'
20055
20073
  });
20074
+ persistMinimized(false);
20056
20075
  return {
20057
- opened
20076
+ opened,
20077
+ minimized: false
20058
20078
  };
20059
20079
  });
20060
20080
  },
@@ -20082,6 +20102,12 @@
20082
20102
  introed
20083
20103
  }));
20084
20104
  },
20105
+ setMinimized: minimized => {
20106
+ persistMinimized(minimized);
20107
+ set(state => ({
20108
+ minimized
20109
+ }));
20110
+ },
20085
20111
  setVisible: visible => set(state => ({
20086
20112
  visible
20087
20113
  })),
@@ -23326,11 +23352,11 @@ void main(void) {
23326
23352
  <img src="${href}"${title ? ` title="${title}"` : ''} alt="" />
23327
23353
  </a>`;
23328
23354
  }
23329
- /*
23330
- html(html: string, block?: boolean) {
23331
- console.log('html', html);
23332
- return html;
23333
- },
23355
+ /*
23356
+ html(html: string, block?: boolean) {
23357
+ console.log('html', html);
23358
+ return html;
23359
+ },
23334
23360
  */
23335
23361
  }
23336
23362
  });
@@ -31946,12 +31972,12 @@ void main(void) {
31946
31972
  return type.replace(/Item$/, '');
31947
31973
  }
31948
31974
 
31949
- /*
31950
- export type LlmChunkImage = {
31951
- type: 'image';
31952
- id: string;
31953
- src: string;
31954
- };
31975
+ /*
31976
+ export type LlmChunkImage = {
31977
+ type: 'image';
31978
+ id: string;
31979
+ src: string;
31980
+ };
31955
31981
  */
31956
31982
 
31957
31983
  // media
@@ -31974,11 +32000,11 @@ void main(void) {
31974
32000
 
31975
32001
  // !!! todo move to bom-core
31976
32002
 
31977
- /*
31978
- export type LlmChunkUnknownItem = Omit<Record<string, unknown>, 'type' | 'id'> & {
31979
- type: LlmChunkUnknownItemType;
31980
- id: IEquatable;
31981
- };
32003
+ /*
32004
+ export type LlmChunkUnknownItem = Omit<Record<string, unknown>, 'type' | 'id'> & {
32005
+ type: LlmChunkUnknownItemType;
32006
+ id: IEquatable;
32007
+ };
31982
32008
  */
31983
32009
 
31984
32010
  // !!! todo
@@ -31987,55 +32013,55 @@ void main(void) {
31987
32013
  // type StuctureMappedType<T extends LlmChunkType> = { [K in T]: Array<LlmChunkItem<K>> };
31988
32014
  // export type LlmChunkItems<T extends LlmChunkType = LlmChunkType> = Record<T, (item: Extract<LlmChunkItem, { type: T }>) => string>;
31989
32015
 
31990
- /*
31991
- export type LlmThemeItem = Record<string, CSSProperties> & {
31992
- [key: string]: string | boolean | number;
31993
- };
31994
-
31995
- export type LlmThemeTypography = Omit<CSSProperties, 'textTransform'> & {
31996
- family?: CSSProperties['fontFamily'];
31997
- size?: CSSProperties['fontSize'];
31998
- weight?: CSSProperties['fontWeight'];
31999
- fontSizeMin?: string;
32000
- fontSizeMax?: string;
32001
- textTransform?: string;
32002
- };
32003
-
32004
- export type LlmThemeColor = {
32005
- [key: string]: CSSProperties['color'] | LlmThemeColor;
32006
- };
32007
-
32008
- export type LlmThemeProps = {
32009
- mode?: string;
32010
- scale?: number;
32011
- font?: {
32012
- primary: CSSProperties['fontFamily'];
32013
- secondary: CSSProperties['fontFamily'];
32014
- source: string;
32015
- };
32016
- typography?: Record<string, LlmThemeTypography>,
32017
- color?: LlmThemeColor;
32018
- canvas?: {
32019
- opacity?: number;
32020
- enabled?: boolean;
32021
- };
32022
- border?: CSSProperties['border'];
32023
- toaster?: ToasterProps['theme'];
32024
- };
32016
+ /*
32017
+ export type LlmThemeItem = Record<string, CSSProperties> & {
32018
+ [key: string]: string | boolean | number;
32019
+ };
32020
+
32021
+ export type LlmThemeTypography = Omit<CSSProperties, 'textTransform'> & {
32022
+ family?: CSSProperties['fontFamily'];
32023
+ size?: CSSProperties['fontSize'];
32024
+ weight?: CSSProperties['fontWeight'];
32025
+ fontSizeMin?: string;
32026
+ fontSizeMax?: string;
32027
+ textTransform?: string;
32028
+ };
32029
+
32030
+ export type LlmThemeColor = {
32031
+ [key: string]: CSSProperties['color'] | LlmThemeColor;
32032
+ };
32033
+
32034
+ export type LlmThemeProps = {
32035
+ mode?: string;
32036
+ scale?: number;
32037
+ font?: {
32038
+ primary: CSSProperties['fontFamily'];
32039
+ secondary: CSSProperties['fontFamily'];
32040
+ source: string;
32041
+ };
32042
+ typography?: Record<string, LlmThemeTypography>,
32043
+ color?: LlmThemeColor;
32044
+ canvas?: {
32045
+ opacity?: number;
32046
+ enabled?: boolean;
32047
+ };
32048
+ border?: CSSProperties['border'];
32049
+ toaster?: ToasterProps['theme'];
32050
+ };
32025
32051
  */
32026
32052
 
32027
- /*
32028
- export type LlmTheme = Omit<{
32029
- [key: string]: LlmThemeItem | CSSProperties;
32030
- }, keyof LlmThemeProps> & LlmThemeProps;
32053
+ /*
32054
+ export type LlmTheme = Omit<{
32055
+ [key: string]: LlmThemeItem | CSSProperties;
32056
+ }, keyof LlmThemeProps> & LlmThemeProps;
32031
32057
  */
32032
32058
 
32033
- /*
32034
- export type LlmThemeBase = {
32035
- [key: string]: CSSProperties | string | number | boolean | LlmThemeBase;
32036
- };
32037
-
32038
- export type LlmTheme = LlmThemeBase & LlmThemeProps;
32059
+ /*
32060
+ export type LlmThemeBase = {
32061
+ [key: string]: CSSProperties | string | number | boolean | LlmThemeBase;
32062
+ };
32063
+
32064
+ export type LlmTheme = LlmThemeBase & LlmThemeProps;
32039
32065
  */
32040
32066
 
32041
32067
  const LLM_DEFAULT_MIME_TYPES = '.jpg, .jpeg, .png, .svg, .webp, .txt, .md, .pdf, .csv, .doc, .xls, .ppt';
@@ -32270,14 +32296,14 @@ void main(void) {
32270
32296
  const feedbackType = type || theme.feedback?.type || 'stars';
32271
32297
  const classNames = getClassNames('llm__feedback', `llm__feedback--${feedbackType}`);
32272
32298
 
32273
- /*
32274
- const [feedbackRating, setFeedbackRating] = useState<number>();
32275
- const onRating = async (event: ChangeEvent<HTMLInputElement>) => {
32276
- console.log(event.currentTarget);
32277
- const value = String(event.currentTarget.value);
32278
- const rating = parseInt(value);
32279
- setFeedbackRating(rating);
32280
- };
32299
+ /*
32300
+ const [feedbackRating, setFeedbackRating] = useState<number>();
32301
+ const onRating = async (event: ChangeEvent<HTMLInputElement>) => {
32302
+ console.log(event.currentTarget);
32303
+ const value = String(event.currentTarget.value);
32304
+ const rating = parseInt(value);
32305
+ setFeedbackRating(rating);
32306
+ };
32281
32307
  */
32282
32308
 
32283
32309
  const onSubmit = async event => {
@@ -32414,8 +32440,8 @@ void main(void) {
32414
32440
  });
32415
32441
  };
32416
32442
 
32417
- /*
32418
- <link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
32443
+ /*
32444
+ <link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
32419
32445
  */
32420
32446
  const Font = () => {
32421
32447
  const theme = useLlm(state => state.theme);
@@ -32885,6 +32911,10 @@ void main(void) {
32885
32911
  wrapper
32886
32912
  } = _ref;
32887
32913
  const label = useLabel();
32914
+ const streaming = useLlm(state => state.streaming);
32915
+ const {
32916
+ clear
32917
+ } = useLlm(state => state.actions);
32888
32918
  const {
32889
32919
  send
32890
32920
  } = useLlmView(state => state.actions);
@@ -32892,7 +32922,8 @@ void main(void) {
32892
32922
  setWrapper
32893
32923
  } = useActions();
32894
32924
  const onAction = async action => {
32895
- const prompt = action.message || `${action.label}: ${JSON.stringify(wrapper.actions)}`;
32925
+ const prompt = action.message || action.label;
32926
+ clear();
32896
32927
  await send(prompt, response => {
32897
32928
  // console.log('PageActions.onChunk', response.chunks);
32898
32929
  }, response => {
@@ -32910,7 +32941,11 @@ void main(void) {
32910
32941
  }), wrapper.actions.map(x => /*#__PURE__*/jsxRuntimeExports.jsxs("button", {
32911
32942
  type: "button",
32912
32943
  className: getClassNames(style$h.action),
32913
- onClick: () => onAction(x),
32944
+ disabled: streaming,
32945
+ onClick: e => {
32946
+ e.stopPropagation();
32947
+ onAction(x);
32948
+ },
32914
32949
  children: [/*#__PURE__*/jsxRuntimeExports.jsx(ActionIcon, {
32915
32950
  action: x
32916
32951
  }), /*#__PURE__*/jsxRuntimeExports.jsx("span", {
@@ -40825,6 +40860,9 @@ void main(void) {
40825
40860
  removeHistory
40826
40861
  } = useLlm(state => state.actions);
40827
40862
  // console.log('item', item);
40863
+ if (!item.user) {
40864
+ return;
40865
+ }
40828
40866
  return /*#__PURE__*/jsxRuntimeExports.jsxs("div", {
40829
40867
  className: getClassNames(style$e.history),
40830
40868
  onClick: () => setHistory(item),
@@ -41342,7 +41380,11 @@ void main(void) {
41342
41380
  const PageSubmit = () => {
41343
41381
  const label = useLabel();
41344
41382
  useLlm(state => state.components);
41383
+ const streaming = useLlm(state => state.streaming);
41345
41384
  const prompt = useLlm(state => state.prompt);
41385
+ const {
41386
+ clear
41387
+ } = useLlm(state => state.actions);
41346
41388
  const {
41347
41389
  send
41348
41390
  } = useLlmView(state => state.actions);
@@ -41351,6 +41393,7 @@ void main(void) {
41351
41393
  if (!prompt) {
41352
41394
  return;
41353
41395
  }
41396
+ clear();
41354
41397
  await send(prompt, response => {
41355
41398
  // console.log('PagePrompt.onChunk', response.chunks);
41356
41399
  }, response => {
@@ -41360,7 +41403,7 @@ void main(void) {
41360
41403
  return /*#__PURE__*/jsxRuntimeExports.jsx("button", {
41361
41404
  type: "submit",
41362
41405
  className: getClassNames(style$5.submit),
41363
- "aria-disabled": !prompt,
41406
+ disabled: !prompt || streaming,
41364
41407
  "aria-label": label('llm.sendPrompt'),
41365
41408
  onClick: onSubmit,
41366
41409
  children: /*#__PURE__*/jsxRuntimeExports.jsx(IconLlmArrowUp, {})
@@ -41405,7 +41448,8 @@ void main(void) {
41405
41448
  const prompt = useLlm(state => state.prompt);
41406
41449
  const streaming = useLlm(state => state.streaming);
41407
41450
  const {
41408
- setPrompt
41451
+ setPrompt,
41452
+ clear
41409
41453
  } = useLlm(state => state.actions);
41410
41454
  const {
41411
41455
  send
@@ -41416,6 +41460,7 @@ void main(void) {
41416
41460
  if (!prompt) {
41417
41461
  return;
41418
41462
  }
41463
+ clear();
41419
41464
  await send(prompt, response => {
41420
41465
  // console.log('PagePrompt.onChunk', response.chunks);
41421
41466
  }, response => {
@@ -41427,7 +41472,7 @@ void main(void) {
41427
41472
  setPrompt(prompt);
41428
41473
  };
41429
41474
  const onKeyDown = event => {
41430
- if (event.code == 'Enter' && !event.shiftKey) {
41475
+ if (event.code == 'Enter' && !event.shiftKey && !streaming) {
41431
41476
  onSubmit(event);
41432
41477
  }
41433
41478
  };
@@ -41479,10 +41524,10 @@ void main(void) {
41479
41524
  window.scrollTo({
41480
41525
  top: 0
41481
41526
  });
41482
- /*
41483
- if (ref.current) {
41484
- ref.current.scrollIntoView();
41485
- }
41527
+ /*
41528
+ if (ref.current) {
41529
+ ref.current.scrollIntoView();
41530
+ }
41486
41531
  */
41487
41532
  }, [message, hasValidChunks]);
41488
41533
  const classNames = getClassNames(style$2.thread);
@@ -41960,15 +42005,15 @@ void main(void) {
41960
42005
  }
41961
42006
  },
41962
42007
  start: () => {
41963
- /*
41964
- if (innerRef.current) {
41965
- }
42008
+ /*
42009
+ if (innerRef.current) {
42010
+ }
41966
42011
  */
41967
42012
  },
41968
42013
  stop: () => {
41969
- /*
41970
- if (innerRef.current) {
41971
- }
42014
+ /*
42015
+ if (innerRef.current) {
42016
+ }
41972
42017
  */
41973
42018
  }
41974
42019
  });
@@ -42157,30 +42202,30 @@ void main(void) {
42157
42202
  });
42158
42203
  };
42159
42204
 
42160
- /*
42161
-
42162
- const swiperProps = {
42163
- modules: [FreeMode],
42164
- spaceBetween: 8,
42165
- freeMode: true,
42166
- slidesPerView: 'auto' as const,
42167
- slidesOffsetAfter: clamp(20, 110),
42168
- slidesOffsetBefore: clamp(20, 110),
42169
- };
42170
-
42171
- <section className="llm__prompt-suggestions">
42172
- <div className="llm__suggestions">
42173
- <Swiper {...swiperProps} onInit={swiper => swiper.update()}>
42174
- {app?.contents.sampleInputTexts?.map((s, j) => (
42175
- <SwiperSlide key={j}>
42176
- <button type="button" className="llm__pill" onClick={() => onClick(s)}>
42177
- {s.sampleInputText}
42178
- </button>
42179
- </SwiperSlide>
42180
- ))}
42181
- </Swiper>
42182
- </div>
42183
- </section>
42205
+ /*
42206
+
42207
+ const swiperProps = {
42208
+ modules: [FreeMode],
42209
+ spaceBetween: 8,
42210
+ freeMode: true,
42211
+ slidesPerView: 'auto' as const,
42212
+ slidesOffsetAfter: clamp(20, 110),
42213
+ slidesOffsetBefore: clamp(20, 110),
42214
+ };
42215
+
42216
+ <section className="llm__prompt-suggestions">
42217
+ <div className="llm__suggestions">
42218
+ <Swiper {...swiperProps} onInit={swiper => swiper.update()}>
42219
+ {app?.contents.sampleInputTexts?.map((s, j) => (
42220
+ <SwiperSlide key={j}>
42221
+ <button type="button" className="llm__pill" onClick={() => onClick(s)}>
42222
+ {s.sampleInputText}
42223
+ </button>
42224
+ </SwiperSlide>
42225
+ ))}
42226
+ </Swiper>
42227
+ </div>
42228
+ </section>
42184
42229
  */
42185
42230
 
42186
42231
  const Thread = () => {
@@ -42216,6 +42261,32 @@ void main(void) {
42216
42261
  });
42217
42262
  };
42218
42263
 
42264
+ const MinimizeButton = _ref => {
42265
+ let {
42266
+ onClick,
42267
+ label
42268
+ } = _ref;
42269
+ return /*#__PURE__*/jsxRuntimeExports.jsx("button", {
42270
+ type: "button",
42271
+ className: "llm__trigger-minimize",
42272
+ onClick: onClick,
42273
+ "aria-label": label,
42274
+ children: /*#__PURE__*/jsxRuntimeExports.jsx("svg", {
42275
+ width: "16",
42276
+ height: "16",
42277
+ viewBox: "0 0 16 16",
42278
+ fill: "none",
42279
+ xmlns: "http://www.w3.org/2000/svg",
42280
+ children: /*#__PURE__*/jsxRuntimeExports.jsx("path", {
42281
+ d: "M4 6L8 10L12 6",
42282
+ stroke: "currentColor",
42283
+ strokeWidth: "1.5",
42284
+ strokeLinecap: "round",
42285
+ strokeLinejoin: "round"
42286
+ })
42287
+ })
42288
+ });
42289
+ };
42219
42290
  const Trigger = () => {
42220
42291
  const theme = useLlm(state => state.theme);
42221
42292
  const {
@@ -42223,16 +42294,21 @@ void main(void) {
42223
42294
  } = useLlm(state => state.components);
42224
42295
  const app = useLlm(state => state.app);
42225
42296
  const opened = useLlmView(state => state.opened);
42297
+ const minimized = useLlmView(state => state.minimized);
42226
42298
  const {
42227
- open
42299
+ open,
42300
+ setMinimized
42228
42301
  } = useLlmView(state => state.actions);
42229
42302
  const label = useLabel();
42303
+ const enableMinimize = app?.contents.enableMinimize;
42230
42304
  const collapsedWelcomeText = messageMapper(app?.contents.collapsedWelcomeText);
42231
42305
  const collapsedWelcomeTextCta = messageMapper(app?.contents.collapsedWelcomeTextCta);
42232
42306
  const collapsedWelcomeTextHover = messageMapper(app?.contents.collapsedWelcomeTextHover);
42233
42307
  const position = theme.trigger?.position || 'bottom';
42234
42308
  return /*#__PURE__*/jsxRuntimeExports.jsxs(motion.nav, {
42235
- className: getClassNames('llm__trigger', '-' + position),
42309
+ className: getClassNames('llm__trigger', '-' + position, {
42310
+ '-minimized': minimized
42311
+ }),
42236
42312
  initial: {
42237
42313
  y: '200%',
42238
42314
  opacity: 0
@@ -42246,12 +42322,12 @@ void main(void) {
42246
42322
  opacity: 0
42247
42323
  },
42248
42324
  transition: {
42249
- duration: .4
42325
+ duration: 0.4
42250
42326
  },
42251
42327
  "aria-label": "Trigger"
42252
- /*
42253
- aria-expanded={opened}
42254
- aria-controls={mainId}
42328
+ /*
42329
+ aria-expanded={opened}
42330
+ aria-controls={mainId}
42255
42331
  */,
42256
42332
  onClick: () => open(),
42257
42333
  children: [/*#__PURE__*/jsxRuntimeExports.jsxs("button", {
@@ -42262,14 +42338,20 @@ void main(void) {
42262
42338
  children: [/*#__PURE__*/jsxRuntimeExports.jsx(Blob, {}), /*#__PURE__*/jsxRuntimeExports.jsx("span", {
42263
42339
  children: label('llm.button')
42264
42340
  })]
42265
- }), !opened && (collapsedWelcomeText || collapsedWelcomeTextCta || collapsedWelcomeTextHover) && /*#__PURE__*/jsxRuntimeExports.jsxs("div", {
42341
+ }), !opened && !minimized && (collapsedWelcomeText || collapsedWelcomeTextCta || collapsedWelcomeTextHover) && /*#__PURE__*/jsxRuntimeExports.jsxs("div", {
42266
42342
  className: "llm__trigger-popup -llm-t-body2",
42267
42343
  children: [(collapsedWelcomeText || collapsedWelcomeTextCta) && /*#__PURE__*/jsxRuntimeExports.jsxs(motion.div, {
42268
42344
  className: "llm__trigger-message",
42269
42345
  exit: {
42270
42346
  opacity: 0
42271
42347
  },
42272
- children: [/*#__PURE__*/jsxRuntimeExports.jsx(Canvas, {}), collapsedWelcomeText, collapsedWelcomeTextCta && /*#__PURE__*/jsxRuntimeExports.jsx("button", {
42348
+ children: [/*#__PURE__*/jsxRuntimeExports.jsx(Canvas, {}), collapsedWelcomeText, enableMinimize && /*#__PURE__*/jsxRuntimeExports.jsx(MinimizeButton, {
42349
+ onClick: e => {
42350
+ e.stopPropagation();
42351
+ setMinimized(true);
42352
+ },
42353
+ label: label('llm.minimize') || 'Minimize'
42354
+ }), collapsedWelcomeTextCta && /*#__PURE__*/jsxRuntimeExports.jsx("button", {
42273
42355
  type: "button",
42274
42356
  className: "llm__trigger-cta",
42275
42357
  children: collapsedWelcomeTextCta
@@ -43432,13 +43514,13 @@ ${Object.entries(vars).map(_ref2 => {
43432
43514
  decodeMessages(messages) {
43433
43515
  return messages.map(x => {
43434
43516
  if (Array.isArray(x.content)) {
43435
- /*
43436
- if (x.role === 'user') {
43437
- return ({
43438
- ...x,
43439
- chunks: x.content.map(x => this.decodeChunk(x)),
43440
- });
43441
- }
43517
+ /*
43518
+ if (x.role === 'user') {
43519
+ return ({
43520
+ ...x,
43521
+ chunks: x.content.map(x => this.decodeChunk(x)),
43522
+ });
43523
+ }
43442
43524
  */
43443
43525
  return {
43444
43526
  ...x,
@@ -43679,163 +43761,163 @@ ${Object.entries(vars).map(_ref2 => {
43679
43761
  return chunkItems;
43680
43762
  }
43681
43763
 
43682
- /*
43683
- chunksToChunkItems___(chunks: LlmChunk[], response?: StreamResponse): LlmChunkItem[] {
43684
- const chunkItems: LlmChunkItem[] = [];
43685
- chunks.forEach(x => {
43686
- const chunk: LlmChunkItem = typeof x === 'string' ? { type: 'text', text: x } : x;
43687
- const lastMessage = chunkItems[chunkItems.length - 1];
43688
- switch (chunk.type) {
43689
- case 'text':
43690
- if (lastMessage && isChunkText(lastMessage)) {
43691
- const text = chunk.text;
43692
- const lastChunkText = lastMessage;
43693
- if (chunkItems.indexOf(lastChunkText) > 0) {
43694
- // secondary chunk
43695
- lastChunkText.text += text;
43696
- } else if (!lastChunkText.text.includes('\n')) {
43697
- // uncompleted first chunk
43698
- if (text.includes('\n')) {
43699
- const lines = text.split('\n');
43700
- lines.forEach((line, i) => {
43701
- const lastChar = (lines.length > i + 1) ? '\n' : '';
43702
- if (i === 0) {
43703
- lastChunkText.text += line + lastChar;
43704
- } else if (line.length > 0) {
43705
- chunkItems.push({
43706
- type: 'text',
43707
- text: line + lastChar,
43708
- });
43709
- }
43710
- });
43711
- } else {
43712
- // uncompleted first chunk
43713
- lastChunkText.text += text;
43714
- }
43715
- } else {
43716
- // completed first chunk
43717
- chunkItems.push(chunk);
43718
- }
43719
- } else {
43720
- // new text chunk
43721
- chunkItems.push(chunk);
43722
- }
43723
- break;
43724
- case 'log':
43725
- break;
43726
- case 'error':
43727
- chunkItems.push(chunk);
43728
- break;
43729
- case 'header': {
43730
- const { type, ...rest } = chunk;
43731
- if (response) {
43732
- Object.assign(response, rest);
43733
- }
43734
- // console.log('header', response);
43735
- }
43736
- break;
43737
- case 'info': {
43738
- if (response) {
43739
- // !!! deprecated
43740
- response.threadId = chunk.threadId || response.threadId;
43741
- }
43742
- }
43743
- break;
43744
- case 'end':
43745
- break;
43746
- case 'action':
43747
- case 'actionItem':
43748
- if (lastMessage && lastMessage.type === 'actionGroup') {
43749
- lastMessage.items.push(chunk);
43750
- } else {
43751
- chunkItems.push({
43752
- type: 'actionGroup',
43753
- items: [chunk],
43754
- });
43755
- }
43756
- break;
43757
- case 'cardItem':
43758
- if (lastMessage && lastMessage.type === 'cardGroup') {
43759
- lastMessage.items.push(chunk);
43760
- } else {
43761
- chunkItems.push({
43762
- type: 'cardGroup',
43763
- items: [chunk],
43764
- });
43765
- }
43766
- break;
43767
- case 'productItem':
43768
- if (lastMessage && lastMessage.type === 'productGroup') {
43769
- lastMessage.items.push(chunk);
43770
- } else {
43771
- chunkItems.push({
43772
- type: 'productGroup',
43773
- items: [chunk],
43774
- });
43775
- }
43776
- break;
43777
- case 'eventItem':
43778
- if (lastMessage && lastMessage.type === 'eventGroup') {
43779
- lastMessage.items.push(chunk);
43780
- } else {
43781
- chunkItems.push({
43782
- type: 'eventGroup',
43783
- items: [chunk],
43784
- });
43785
- }
43786
- break;
43787
- case 'poiItem':
43788
- if (lastMessage && lastMessage.type === 'poiGroup') {
43789
- lastMessage.items.push(chunk);
43790
- } else {
43791
- chunkItems.push({
43792
- type: 'poiGroup',
43793
- items: [chunk],
43794
- });
43795
- }
43796
- break;
43797
- case 'tripadvisor':
43798
- case 'tripadvisorItem':
43799
- if (lastMessage && lastMessage.type === 'tripadvisorGroup') {
43800
- lastMessage.items.push({
43801
- ...chunk,
43802
- type: 'tripadvisorItem',
43803
- });
43804
- } else {
43805
- chunkItems.push({
43806
- type: 'tripadvisorGroup',
43807
- items: [{
43808
- ...chunk,
43809
- type: 'tripadvisorItem',
43810
- }],
43811
- });
43812
- }
43813
- break;
43814
- default:
43815
- if (
43816
- typeof chunk.type === 'string' &&
43817
- chunk.type.match(/Item$/)
43818
- ) {
43819
- const baseName = chunk.type.replace('Item', '');
43820
- const groupName = `${baseName}Group`;
43821
- if (lastMessage && lastMessage.type === groupName) {
43822
- (lastMessage as { items: (typeof x)[] }).items.push(x);
43823
- } else {
43824
- chunkItems.push({
43825
- type: groupName,
43826
- items: [{
43827
- ...chunk,
43828
- type: baseName,
43829
- }],
43830
- } as unknown as LlmChunkUnknownItem);
43831
- }
43832
- } else {
43833
- chunkItems.push(chunk);
43834
- }
43835
- }
43836
- });
43837
- return chunkItems;
43838
- }
43764
+ /*
43765
+ chunksToChunkItems___(chunks: LlmChunk[], response?: StreamResponse): LlmChunkItem[] {
43766
+ const chunkItems: LlmChunkItem[] = [];
43767
+ chunks.forEach(x => {
43768
+ const chunk: LlmChunkItem = typeof x === 'string' ? { type: 'text', text: x } : x;
43769
+ const lastMessage = chunkItems[chunkItems.length - 1];
43770
+ switch (chunk.type) {
43771
+ case 'text':
43772
+ if (lastMessage && isChunkText(lastMessage)) {
43773
+ const text = chunk.text;
43774
+ const lastChunkText = lastMessage;
43775
+ if (chunkItems.indexOf(lastChunkText) > 0) {
43776
+ // secondary chunk
43777
+ lastChunkText.text += text;
43778
+ } else if (!lastChunkText.text.includes('\n')) {
43779
+ // uncompleted first chunk
43780
+ if (text.includes('\n')) {
43781
+ const lines = text.split('\n');
43782
+ lines.forEach((line, i) => {
43783
+ const lastChar = (lines.length > i + 1) ? '\n' : '';
43784
+ if (i === 0) {
43785
+ lastChunkText.text += line + lastChar;
43786
+ } else if (line.length > 0) {
43787
+ chunkItems.push({
43788
+ type: 'text',
43789
+ text: line + lastChar,
43790
+ });
43791
+ }
43792
+ });
43793
+ } else {
43794
+ // uncompleted first chunk
43795
+ lastChunkText.text += text;
43796
+ }
43797
+ } else {
43798
+ // completed first chunk
43799
+ chunkItems.push(chunk);
43800
+ }
43801
+ } else {
43802
+ // new text chunk
43803
+ chunkItems.push(chunk);
43804
+ }
43805
+ break;
43806
+ case 'log':
43807
+ break;
43808
+ case 'error':
43809
+ chunkItems.push(chunk);
43810
+ break;
43811
+ case 'header': {
43812
+ const { type, ...rest } = chunk;
43813
+ if (response) {
43814
+ Object.assign(response, rest);
43815
+ }
43816
+ // console.log('header', response);
43817
+ }
43818
+ break;
43819
+ case 'info': {
43820
+ if (response) {
43821
+ // !!! deprecated
43822
+ response.threadId = chunk.threadId || response.threadId;
43823
+ }
43824
+ }
43825
+ break;
43826
+ case 'end':
43827
+ break;
43828
+ case 'action':
43829
+ case 'actionItem':
43830
+ if (lastMessage && lastMessage.type === 'actionGroup') {
43831
+ lastMessage.items.push(chunk);
43832
+ } else {
43833
+ chunkItems.push({
43834
+ type: 'actionGroup',
43835
+ items: [chunk],
43836
+ });
43837
+ }
43838
+ break;
43839
+ case 'cardItem':
43840
+ if (lastMessage && lastMessage.type === 'cardGroup') {
43841
+ lastMessage.items.push(chunk);
43842
+ } else {
43843
+ chunkItems.push({
43844
+ type: 'cardGroup',
43845
+ items: [chunk],
43846
+ });
43847
+ }
43848
+ break;
43849
+ case 'productItem':
43850
+ if (lastMessage && lastMessage.type === 'productGroup') {
43851
+ lastMessage.items.push(chunk);
43852
+ } else {
43853
+ chunkItems.push({
43854
+ type: 'productGroup',
43855
+ items: [chunk],
43856
+ });
43857
+ }
43858
+ break;
43859
+ case 'eventItem':
43860
+ if (lastMessage && lastMessage.type === 'eventGroup') {
43861
+ lastMessage.items.push(chunk);
43862
+ } else {
43863
+ chunkItems.push({
43864
+ type: 'eventGroup',
43865
+ items: [chunk],
43866
+ });
43867
+ }
43868
+ break;
43869
+ case 'poiItem':
43870
+ if (lastMessage && lastMessage.type === 'poiGroup') {
43871
+ lastMessage.items.push(chunk);
43872
+ } else {
43873
+ chunkItems.push({
43874
+ type: 'poiGroup',
43875
+ items: [chunk],
43876
+ });
43877
+ }
43878
+ break;
43879
+ case 'tripadvisor':
43880
+ case 'tripadvisorItem':
43881
+ if (lastMessage && lastMessage.type === 'tripadvisorGroup') {
43882
+ lastMessage.items.push({
43883
+ ...chunk,
43884
+ type: 'tripadvisorItem',
43885
+ });
43886
+ } else {
43887
+ chunkItems.push({
43888
+ type: 'tripadvisorGroup',
43889
+ items: [{
43890
+ ...chunk,
43891
+ type: 'tripadvisorItem',
43892
+ }],
43893
+ });
43894
+ }
43895
+ break;
43896
+ default:
43897
+ if (
43898
+ typeof chunk.type === 'string' &&
43899
+ chunk.type.match(/Item$/)
43900
+ ) {
43901
+ const baseName = chunk.type.replace('Item', '');
43902
+ const groupName = `${baseName}Group`;
43903
+ if (lastMessage && lastMessage.type === groupName) {
43904
+ (lastMessage as { items: (typeof x)[] }).items.push(x);
43905
+ } else {
43906
+ chunkItems.push({
43907
+ type: groupName,
43908
+ items: [{
43909
+ ...chunk,
43910
+ type: baseName,
43911
+ }],
43912
+ } as unknown as LlmChunkUnknownItem);
43913
+ }
43914
+ } else {
43915
+ chunkItems.push(chunk);
43916
+ }
43917
+ }
43918
+ });
43919
+ return chunkItems;
43920
+ }
43839
43921
  */
43840
43922
 
43841
43923
  static decodeThread(thread) {
@@ -43990,10 +44072,10 @@ ${Object.entries(vars).map(_ref2 => {
43990
44072
  return;
43991
44073
  }
43992
44074
  const errorMessage = typeof error === 'string' ? error : JSON.stringify(error, null, 2);
43993
- /*
43994
- if (error instanceof TypeError) {
43995
- errorMessage = 'TypeError: Browser may not support async iteration';
43996
- }
44075
+ /*
44076
+ if (error instanceof TypeError) {
44077
+ errorMessage = 'TypeError: Browser may not support async iteration';
44078
+ }
43997
44079
  */
43998
44080
  if (typeof onEnd === 'function') {
43999
44081
  const errorChunk = {
@@ -44112,10 +44194,10 @@ ${Object.entries(vars).map(_ref2 => {
44112
44194
  } catch (error) {
44113
44195
  console.error('MessageService.mockMessage.error', error);
44114
44196
  const errorMessage = typeof error === 'string' ? error : JSON.stringify(error, null, 2);
44115
- /*
44116
- if (error instanceof TypeError) {
44117
- errorMessage = 'TypeError: Browser may not support async iteration';
44118
- }
44197
+ /*
44198
+ if (error instanceof TypeError) {
44199
+ errorMessage = 'TypeError: Browser may not support async iteration';
44200
+ }
44119
44201
  */
44120
44202
  if (typeof onEnd === 'function') {
44121
44203
  const errorChunk = {
@@ -44170,36 +44252,36 @@ ${Object.entries(vars).map(_ref2 => {
44170
44252
  };
44171
44253
  }
44172
44254
 
44173
- /*
44174
- async function* streamAsyncIterable<T>(stream: ReadableStream<T>) {
44175
- const reader = stream.getReader();
44176
- try {
44177
- while (true) {
44178
- const { done, value } = await reader.read();
44179
- if (done) return;
44180
- yield value;
44181
- }
44182
- } finally {
44183
- reader.releaseLock();
44184
- }
44185
- }
44186
-
44187
- class Iterator {
44188
- }
44189
-
44190
- (Iterator as any).prototype[Symbol.asyncIterator] = async function* () {
44191
- const reader = this.getReader();
44192
- try {
44193
- while (true) {
44194
- const { done, value } = await reader.read();
44195
- if (done) return;
44196
- yield value;
44197
- }
44198
- }
44199
- finally {
44200
- reader.releaseLock();
44201
- }
44202
- };
44255
+ /*
44256
+ async function* streamAsyncIterable<T>(stream: ReadableStream<T>) {
44257
+ const reader = stream.getReader();
44258
+ try {
44259
+ while (true) {
44260
+ const { done, value } = await reader.read();
44261
+ if (done) return;
44262
+ yield value;
44263
+ }
44264
+ } finally {
44265
+ reader.releaseLock();
44266
+ }
44267
+ }
44268
+
44269
+ class Iterator {
44270
+ }
44271
+
44272
+ (Iterator as any).prototype[Symbol.asyncIterator] = async function* () {
44273
+ const reader = this.getReader();
44274
+ try {
44275
+ while (true) {
44276
+ const { done, value } = await reader.read();
44277
+ if (done) return;
44278
+ yield value;
44279
+ }
44280
+ }
44281
+ finally {
44282
+ reader.releaseLock();
44283
+ }
44284
+ };
44203
44285
  */
44204
44286
 
44205
44287
  class ApiService {
@@ -44802,19 +44884,19 @@ ${Object.entries(vars).map(_ref2 => {
44802
44884
  utterance.onerror = error => {
44803
44885
  console.warn('DefaultTextToSpeech.speak.onerror', error);
44804
44886
  };
44805
- /*
44806
- utterance.onboundary = (event) => {
44807
- console.log('DefaultTextToSpeech.speak.onboundary', event);
44808
- };
44809
- utterance.onmark = (event) => {
44810
- console.log('DefaultTextToSpeech.speak.onmark', event);
44811
- };
44812
- utterance.onpause = (event) => {
44813
- console.log('DefaultTextToSpeech.speak.onpause', event);
44814
- };
44815
- utterance.onresume = (event) => {
44816
- console.log('DefaultTextToSpeech.speak.onresume', event);
44817
- };
44887
+ /*
44888
+ utterance.onboundary = (event) => {
44889
+ console.log('DefaultTextToSpeech.speak.onboundary', event);
44890
+ };
44891
+ utterance.onmark = (event) => {
44892
+ console.log('DefaultTextToSpeech.speak.onmark', event);
44893
+ };
44894
+ utterance.onpause = (event) => {
44895
+ console.log('DefaultTextToSpeech.speak.onpause', event);
44896
+ };
44897
+ utterance.onresume = (event) => {
44898
+ console.log('DefaultTextToSpeech.speak.onresume', event);
44899
+ };
44818
44900
  */
44819
44901
  utterance.voice = voice;
44820
44902
  utterance.pitch = pitch;
@@ -44998,12 +45080,12 @@ ${Object.entries(vars).map(_ref2 => {
44998
45080
  return this.recognizer_;
44999
45081
  } else {
45000
45082
  const recognizer = new this.recognition();
45001
- /*
45002
- const grammar =
45003
- "#JSGF V1.0; grammar colors; public <color> = aqua | azure | beige | bisque | black | blue | brown | chocolate | coral | crimson | cyan | fuchsia | ghostwhite | gold | goldenrod | gray | green | indigo | ivory | khaki | lavender | lime | linen | magenta | maroon | moccasin | navy | olive | orange | orchid | peru | pink | plum | purple | red | salmon | sienna | silver | snow | tan | teal | thistle | tomato | turquoise | violet | white | yellow ;";
45004
- const grammarList = new this.grammarList();
45005
- grammarList.addFromString(grammar, 1);
45006
- recognizer.grammars = grammarList;
45083
+ /*
45084
+ const grammar =
45085
+ "#JSGF V1.0; grammar colors; public <color> = aqua | azure | beige | bisque | black | blue | brown | chocolate | coral | crimson | cyan | fuchsia | ghostwhite | gold | goldenrod | gray | green | indigo | ivory | khaki | lavender | lime | linen | magenta | maroon | moccasin | navy | olive | orange | orchid | peru | pink | plum | purple | red | salmon | sienna | silver | snow | tan | teal | thistle | tomato | turquoise | violet | white | yellow ;";
45086
+ const grammarList = new this.grammarList();
45087
+ grammarList.addFromString(grammar, 1);
45088
+ recognizer.grammars = grammarList;
45007
45089
  */
45008
45090
  recognizer.lang = this.lang; // "en-US";
45009
45091
  recognizer.continuous = true;
@@ -45021,37 +45103,37 @@ ${Object.entries(vars).map(_ref2 => {
45021
45103
  // console.log('recognizer.result');
45022
45104
  this.onResult(event);
45023
45105
  });
45024
- /*
45025
- recognizer.addEventListener("audioend", (event) => {
45026
- this.log('recognizer', "audioend", event);
45027
- });
45028
- recognizer.addEventListener("speechend", (event) => {
45029
- this.log('recognizer', "speechend", event);
45030
- });
45106
+ /*
45107
+ recognizer.addEventListener("audioend", (event) => {
45108
+ this.log('recognizer', "audioend", event);
45109
+ });
45110
+ recognizer.addEventListener("speechend", (event) => {
45111
+ this.log('recognizer', "speechend", event);
45112
+ });
45031
45113
  */
45032
- /*
45033
- audiostart
45034
- Fired when the user agent has started to capture audio. Also available via the onaudiostart property.
45035
- audioend
45036
- Fired when the user agent has finished capturing audio. Also available via the onaudioend property.
45037
- end
45038
- Fired when the speech recognition service has disconnected. Also available via the onend property.
45039
- error
45040
- Fired when a speech recognition error occurs. Also available via the onerror property.
45041
- nomatch
45042
- Fired when the speech recognition service returns a final result with no significant recognition. This may involve some degree of recognition, which doesn't meet or exceed the confidence threshold. Also available via the onnomatch property.
45043
- result
45044
- Fired when the speech recognition service returns a result — a word or phrase has been positively recognized and this has been communicated back to the app. Also available via the onresult property.
45045
- soundstart
45046
- Fired when any sound — recognizable speech or not — has been detected. Also available via the onsoundstart property.
45047
- soundend
45048
- Fired when any sound — recognizable speech or not — has stopped being detected. Also available via the onsoundend property.
45049
- speechstart
45050
- Fired when sound that is recognized by the speech recognition service as speech has been detected. Also available via the onspeechstart property.
45051
- speechend
45052
- Fired when speech recognized by the speech recognition service has stopped being detected. Also available via the onspeechend property.
45053
- start
45054
- Fired when the speech recognition service has begun listening to incoming audio with intent to recognize grammars associated with the current SpeechRecognition. Also available via the onstart property.
45114
+ /*
45115
+ audiostart
45116
+ Fired when the user agent has started to capture audio. Also available via the onaudiostart property.
45117
+ audioend
45118
+ Fired when the user agent has finished capturing audio. Also available via the onaudioend property.
45119
+ end
45120
+ Fired when the speech recognition service has disconnected. Also available via the onend property.
45121
+ error
45122
+ Fired when a speech recognition error occurs. Also available via the onerror property.
45123
+ nomatch
45124
+ Fired when the speech recognition service returns a final result with no significant recognition. This may involve some degree of recognition, which doesn't meet or exceed the confidence threshold. Also available via the onnomatch property.
45125
+ result
45126
+ Fired when the speech recognition service returns a result — a word or phrase has been positively recognized and this has been communicated back to the app. Also available via the onresult property.
45127
+ soundstart
45128
+ Fired when any sound — recognizable speech or not — has been detected. Also available via the onsoundstart property.
45129
+ soundend
45130
+ Fired when any sound — recognizable speech or not — has stopped being detected. Also available via the onsoundend property.
45131
+ speechstart
45132
+ Fired when sound that is recognized by the speech recognition service as speech has been detected. Also available via the onspeechstart property.
45133
+ speechend
45134
+ Fired when speech recognized by the speech recognition service has stopped being detected. Also available via the onspeechend property.
45135
+ start
45136
+ Fired when the speech recognition service has begun listening to incoming audio with intent to recognize grammars associated with the current SpeechRecognition. Also available via the onstart property.
45055
45137
  */
45056
45138
  this.recognizer_ = recognizer;
45057
45139
  return recognizer;
@@ -45220,17 +45302,17 @@ ${Object.entries(vars).map(_ref2 => {
45220
45302
  return c(p);
45221
45303
  }, {
45222
45304
  ...config
45223
- /**
45224
- * test remote api
45225
- ...({
45226
- appKey: 'xxxxxxxxxxxxxx',
45227
- apiKey: 'xxxxxxxxxxxxxx',
45228
- threadId: 'xxxxxxxxxxxxxx',
45229
- endpoint: 'https://platform.websolute.ai',
45230
- endpoint: 'https://platform-ai-dev.ws-deploy-01.wslabs.it',
45231
- endpoint: 'http://localhost:4000/bowl',
45232
- test: false,
45233
- }),
45305
+ /**
45306
+ * test remote api
45307
+ ...({
45308
+ appKey: 'xxxxxxxxxxxxxx',
45309
+ apiKey: 'xxxxxxxxxxxxxx',
45310
+ threadId: 'xxxxxxxxxxxxxx',
45311
+ endpoint: 'https://platform.websolute.ai',
45312
+ endpoint: 'https://platform-ai-dev.ws-deploy-01.wslabs.it',
45313
+ endpoint: 'http://localhost:4000/bowl',
45314
+ test: false,
45315
+ }),
45234
45316
  */
45235
45317
  });
45236
45318
  const {
@@ -45371,12 +45453,12 @@ ${Object.entries(vars).map(_ref2 => {
45371
45453
  }
45372
45454
  const thread = MessageDecoder.decodeThread(app.thread);
45373
45455
  const testTheme = test ? getMock(locale, test).app?.contents?.customTheme : {};
45374
- /*
45375
- console.log(
45376
- 'appTheme', app.contents.customTheme,
45377
- 'testTheme', testTheme,
45378
- 'customTheme', customTheme
45379
- );
45456
+ /*
45457
+ console.log(
45458
+ 'appTheme', app.contents.customTheme,
45459
+ 'testTheme', testTheme,
45460
+ 'customTheme', customTheme
45461
+ );
45380
45462
  */
45381
45463
  const theme = getThemes([app.contents.customTheme, testTheme, customTheme], config.defaultTheme);
45382
45464
  const mode = theme.mode;
@@ -45385,22 +45467,22 @@ ${Object.entries(vars).map(_ref2 => {
45385
45467
  // console.log('useLlm.storedHistory', storedHistory);
45386
45468
  const history = await apiService.decorateHistory(storedHistory, mode);
45387
45469
  // console.log('useLlm.history', history);
45388
- /*
45389
- // !!! session restored via threadId storage merge
45390
- if (storageMode === 'session') {
45391
- // console.log('storageMode', storageMode, history);
45392
- if (history.length > 0) {
45393
- thread = {
45394
- threadId: history[0].threadId,
45395
- messages: history[0].messages,
45396
- };
45397
- }
45398
- }
45470
+ /*
45471
+ // !!! session restored via threadId storage merge
45472
+ if (storageMode === 'session') {
45473
+ // console.log('storageMode', storageMode, history);
45474
+ if (history.length > 0) {
45475
+ thread = {
45476
+ threadId: history[0].threadId,
45477
+ messages: history[0].messages,
45478
+ };
45479
+ }
45480
+ }
45399
45481
  */
45400
- /*
45401
- console.log(
45402
- 'theme', theme
45403
- );
45482
+ /*
45483
+ console.log(
45484
+ 'theme', theme
45485
+ );
45404
45486
  */
45405
45487
  const vars = getVars(theme);
45406
45488
  createVars(vars);
@@ -45499,12 +45581,12 @@ ${Object.entries(vars).map(_ref2 => {
45499
45581
  };
45500
45582
  const responseMessages = [...messages, assistantMessage];
45501
45583
  // 15/12/2025 disabling form request feature, todo add payload flag
45502
- /*
45503
- if (messageService && messageService.shouldAddFormRequest(responseMessages)) {
45504
- chunks.push({
45505
- type: 'formRequest',
45506
- });
45507
- }
45584
+ /*
45585
+ if (messageService && messageService.shouldAddFormRequest(responseMessages)) {
45586
+ chunks.push({
45587
+ type: 'formRequest',
45588
+ });
45589
+ }
45508
45590
  */
45509
45591
  // filtering history
45510
45592
  const validChunks = chunks.filter(x => typeof x.type === 'string' && !['header', 'info', 'end', 'formRequest', 'formRecap', 'formRecapSuccess', 'formRecapError'].includes(x.type));
@@ -45772,10 +45854,10 @@ ${Object.entries(vars).map(_ref2 => {
45772
45854
  threadId: history.threadId,
45773
45855
  message: history.assistant,
45774
45856
  messages: history.messages
45775
- /*
45776
- messages: state.messages.findIndex(x => x.messageId === history.messageId) === -1 ?
45777
- [...state.messages, history.user, history.assistant] :
45778
- state.messages,
45857
+ /*
45858
+ messages: state.messages.findIndex(x => x.messageId === history.messageId) === -1 ?
45859
+ [...state.messages, history.user, history.assistant] :
45860
+ state.messages,
45779
45861
  */
45780
45862
  }));
45781
45863
  },
@@ -45819,10 +45901,10 @@ ${Object.entries(vars).map(_ref2 => {
45819
45901
  currentState.storedHistory = persistedState.storedHistory && [...persistedState.storedHistory];
45820
45902
  currentState.speakEnabled = persistedState.speakEnabled || false;
45821
45903
  speech.enabled = currentState.speakEnabled;
45822
- /*
45823
- if (persistedState.messages) {
45824
- currentState.messages = [...persistedState.messages];
45825
- }
45904
+ /*
45905
+ if (persistedState.messages) {
45906
+ currentState.messages = [...persistedState.messages];
45907
+ }
45826
45908
  */
45827
45909
  currentState.hydrated = true;
45828
45910
  // console.log('currentState', currentState);
@@ -46481,21 +46563,21 @@ ${Object.entries(vars).map(_ref2 => {
46481
46563
  if (!node.hasAttribute('data-llm')) {
46482
46564
  node.setAttribute('data-llm', '');
46483
46565
 
46484
- /*
46485
- const host = node;
46486
- const shadow = host.attachShadow({ mode: 'open' });
46487
- const shadowRoot = document.createElement('div');
46488
- if (typeof window !== 'undefined' && 'llms__' in window) {
46489
- const llmStyle = (window['llms__'] || []) as string[];
46490
- const adoptedStyleSheets = llmStyle.map(style => {
46491
- const sheet = new CSSStyleSheet();
46492
- sheet.replaceSync(style);
46493
- return sheet;
46494
- });
46495
- shadow.adoptedStyleSheets = adoptedStyleSheets;
46496
- }
46497
- shadowRoot.setAttribute('data-llm', '');
46498
- shadow.appendChild(shadowRoot);
46566
+ /*
46567
+ const host = node;
46568
+ const shadow = host.attachShadow({ mode: 'open' });
46569
+ const shadowRoot = document.createElement('div');
46570
+ if (typeof window !== 'undefined' && 'llms__' in window) {
46571
+ const llmStyle = (window['llms__'] || []) as string[];
46572
+ const adoptedStyleSheets = llmStyle.map(style => {
46573
+ const sheet = new CSSStyleSheet();
46574
+ sheet.replaceSync(style);
46575
+ return sheet;
46576
+ });
46577
+ shadow.adoptedStyleSheets = adoptedStyleSheets;
46578
+ }
46579
+ shadowRoot.setAttribute('data-llm', '');
46580
+ shadow.appendChild(shadowRoot);
46499
46581
  */
46500
46582
 
46501
46583
  const root = client.createRoot(node);
@@ -46568,10 +46650,10 @@ ${Object.entries(vars).map(_ref2 => {
46568
46650
  if (mutation.type === 'childList') {
46569
46651
  callback(mutation);
46570
46652
  }
46571
- /*
46572
- else if (mutation.type === 'attributes') {
46573
- console.log(`The ${mutation.attributeName} attribute was modified.`);
46574
- }
46653
+ /*
46654
+ else if (mutation.type === 'attributes') {
46655
+ console.log(`The ${mutation.attributeName} attribute was modified.`);
46656
+ }
46575
46657
  */
46576
46658
  }
46577
46659
  });