@sme.up/ketchup 9.4.0 → 9.5.0

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.
Files changed (118) hide show
  1. package/dist/cjs/{f-button-4bef0f8e.js → f-button-033ed6d4.js} +1 -1
  2. package/dist/cjs/{f-cell-5e0a400e.js → f-cell-ef276797.js} +5 -5
  3. package/dist/cjs/{f-chip-9159b2a5.js → f-chip-d4e26a2b.js} +2 -2
  4. package/dist/cjs/{f-image-b9074ea8.js → f-image-33be7baf.js} +1 -1
  5. package/dist/cjs/{f-paginator-utils-bfa0fa70.js → f-paginator-utils-5a18cc19.js} +2 -2
  6. package/dist/cjs/{f-text-field-bd197af7.js → f-text-field-f03e97f8.js} +1 -1
  7. package/dist/cjs/index.cjs.js +1 -1
  8. package/dist/cjs/ketchup.cjs.js +1 -1
  9. package/dist/cjs/kup-accordion.cjs.entry.js +2 -2
  10. package/dist/cjs/kup-autocomplete_27.cjs.entry.js +18 -9
  11. package/dist/cjs/kup-box.cjs.entry.js +7 -7
  12. package/dist/cjs/kup-calendar.cjs.entry.js +4 -4
  13. package/dist/cjs/kup-card-list.cjs.entry.js +1 -1
  14. package/dist/cjs/kup-cell.cjs.entry.js +6 -6
  15. package/dist/cjs/kup-dashboard.cjs.entry.js +4 -4
  16. package/dist/cjs/kup-drawer.cjs.entry.js +1 -1
  17. package/dist/cjs/kup-echart.cjs.entry.js +1 -1
  18. package/dist/cjs/kup-family-tree.cjs.entry.js +3 -3
  19. package/dist/cjs/kup-grid.cjs.entry.js +1 -1
  20. package/dist/cjs/kup-iframe.cjs.entry.js +1 -1
  21. package/dist/cjs/kup-image-list.cjs.entry.js +6 -6
  22. package/dist/cjs/kup-lazy.cjs.entry.js +1 -1
  23. package/dist/cjs/kup-magic-box.cjs.entry.js +2 -2
  24. package/dist/cjs/{kup-manager-5106d5c6.js → kup-manager-f90f1b6d.js} +124 -0
  25. package/dist/cjs/kup-nav-bar.cjs.entry.js +1 -1
  26. package/dist/cjs/kup-numeric-picker.cjs.entry.js +2 -2
  27. package/dist/cjs/kup-openai-interface.cjs.entry.js +146 -0
  28. package/dist/cjs/kup-photo-frame.cjs.entry.js +1 -1
  29. package/dist/cjs/kup-planner.cjs.entry.js +2 -2
  30. package/dist/cjs/kup-probe.cjs.entry.js +1 -1
  31. package/dist/cjs/kup-qlik.cjs.entry.js +1 -1
  32. package/dist/cjs/kup-snackbar.cjs.entry.js +3 -3
  33. package/dist/cjs/loader.cjs.js +1 -1
  34. package/dist/collection/collection-manifest.json +1 -0
  35. package/dist/collection/components/kup-data-table/kup-data-table.js +11 -2
  36. package/dist/collection/components/kup-image/assets/svg/open-ai.svg +1 -0
  37. package/dist/collection/components/kup-openai-interface/kup-openai-interface-declarations.js +11 -0
  38. package/dist/collection/components/kup-openai-interface/kup-openai-interface.css +64 -0
  39. package/dist/collection/components/kup-openai-interface/kup-openai-interface.js +340 -0
  40. package/dist/collection/managers/kup-manager/kup-manager.js +124 -0
  41. package/dist/components/kup-autocomplete2.js +11 -2
  42. package/dist/components/kup-manager.js +124 -0
  43. package/dist/components/kup-openai-interface.d.ts +11 -0
  44. package/dist/components/kup-openai-interface.js +301 -0
  45. package/dist/esm/{f-button-4d7a0b09.js → f-button-ccde4447.js} +1 -1
  46. package/dist/esm/{f-cell-0bf956b8.js → f-cell-2ad41d52.js} +5 -5
  47. package/dist/esm/{f-chip-91249dc2.js → f-chip-3df1c255.js} +2 -2
  48. package/dist/esm/{f-image-d666df65.js → f-image-5434b351.js} +1 -1
  49. package/dist/esm/{f-paginator-utils-b5be40ee.js → f-paginator-utils-b90cdd2b.js} +2 -2
  50. package/dist/esm/{f-text-field-00a4d490.js → f-text-field-f0b81f8b.js} +1 -1
  51. package/dist/esm/index.js +1 -1
  52. package/dist/esm/ketchup.js +1 -1
  53. package/dist/esm/kup-accordion.entry.js +2 -2
  54. package/dist/esm/kup-autocomplete_27.entry.js +18 -9
  55. package/dist/esm/kup-box.entry.js +7 -7
  56. package/dist/esm/kup-calendar.entry.js +4 -4
  57. package/dist/esm/kup-card-list.entry.js +1 -1
  58. package/dist/esm/kup-cell.entry.js +6 -6
  59. package/dist/esm/kup-dashboard.entry.js +4 -4
  60. package/dist/esm/kup-drawer.entry.js +1 -1
  61. package/dist/esm/kup-echart.entry.js +1 -1
  62. package/dist/esm/kup-family-tree.entry.js +3 -3
  63. package/dist/esm/kup-grid.entry.js +1 -1
  64. package/dist/esm/kup-iframe.entry.js +1 -1
  65. package/dist/esm/kup-image-list.entry.js +6 -6
  66. package/dist/esm/kup-lazy.entry.js +1 -1
  67. package/dist/esm/kup-magic-box.entry.js +2 -2
  68. package/dist/esm/{kup-manager-7f0372fb.js → kup-manager-e33d8d8c.js} +124 -0
  69. package/dist/esm/kup-nav-bar.entry.js +1 -1
  70. package/dist/esm/kup-numeric-picker.entry.js +2 -2
  71. package/dist/esm/kup-openai-interface.entry.js +142 -0
  72. package/dist/esm/kup-photo-frame.entry.js +1 -1
  73. package/dist/esm/kup-planner.entry.js +2 -2
  74. package/dist/esm/kup-probe.entry.js +1 -1
  75. package/dist/esm/kup-qlik.entry.js +1 -1
  76. package/dist/esm/kup-snackbar.entry.js +3 -3
  77. package/dist/esm/loader.js +1 -1
  78. package/dist/ketchup/assets/svg/open-ai.svg +1 -0
  79. package/dist/ketchup/index.esm.js +1 -1
  80. package/dist/ketchup/ketchup.esm.js +1 -1
  81. package/dist/ketchup/{p-491c3cd0.entry.js → p-01aaf3e4.entry.js} +1 -1
  82. package/dist/ketchup/{p-378bbbcf.js → p-11e7be94.js} +1 -1
  83. package/dist/ketchup/{p-1180f9e0.entry.js → p-190d0bc5.entry.js} +1 -1
  84. package/dist/ketchup/{p-9fdd98be.entry.js → p-1a594e06.entry.js} +1 -1
  85. package/dist/ketchup/{p-bbc121a2.entry.js → p-1dbfcab5.entry.js} +1 -1
  86. package/dist/ketchup/{p-e4657f9b.entry.js → p-23e4caa1.entry.js} +2 -2
  87. package/dist/ketchup/p-2681d3a2.entry.js +1 -0
  88. package/dist/ketchup/{p-d5a9924b.entry.js → p-269a1dfe.entry.js} +1 -1
  89. package/dist/ketchup/{p-3ba32190.entry.js → p-2940b559.entry.js} +1 -1
  90. package/dist/ketchup/{p-91ee68b1.js → p-39ba3355.js} +1 -1
  91. package/dist/ketchup/{p-f0b3d110.entry.js → p-4725191c.entry.js} +1 -1
  92. package/dist/ketchup/{p-8e04781a.js → p-4afe8662.js} +1 -1
  93. package/dist/ketchup/{p-e8f5b996.entry.js → p-58798e2d.entry.js} +1 -1
  94. package/dist/ketchup/{p-1ecff2b9.entry.js → p-5b3d8636.entry.js} +1 -1
  95. package/dist/ketchup/{p-613ef7fa.entry.js → p-5fa089cd.entry.js} +1 -1
  96. package/dist/ketchup/{p-8c835b19.entry.js → p-645d881d.entry.js} +1 -1
  97. package/dist/ketchup/{p-466d3604.entry.js → p-6a8fcb02.entry.js} +1 -1
  98. package/dist/ketchup/p-6f108540.entry.js +1 -0
  99. package/dist/ketchup/{p-19be646f.entry.js → p-788da2d9.entry.js} +1 -1
  100. package/dist/ketchup/{p-31a3eb96.entry.js → p-7e5d8532.entry.js} +1 -1
  101. package/dist/ketchup/{p-1e77ddec.js → p-95b31ede.js} +1 -1
  102. package/dist/ketchup/{p-28dcc98b.js → p-9df95b9f.js} +1 -1
  103. package/dist/ketchup/{p-96678597.entry.js → p-a5229d3d.entry.js} +1 -1
  104. package/dist/ketchup/{p-f5b5b35d.entry.js → p-b104afb6.entry.js} +1 -1
  105. package/dist/ketchup/{p-abdbd35e.entry.js → p-b857aab2.entry.js} +1 -1
  106. package/dist/ketchup/{p-b51b1000.entry.js → p-c0c65349.entry.js} +1 -1
  107. package/dist/ketchup/{p-01401fba.entry.js → p-ddd25869.entry.js} +1 -1
  108. package/dist/ketchup/p-eea1ee1b.js +1 -0
  109. package/dist/ketchup/{p-6d51125a.js → p-f0e4e190.js} +1 -1
  110. package/dist/ketchup/{p-16c23ab7.entry.js → p-f81d7218.entry.js} +1 -1
  111. package/dist/types/components/kup-openai-interface/kup-openai-interface-declarations.d.ts +10 -0
  112. package/dist/types/components/kup-openai-interface/kup-openai-interface.d.ts +59 -0
  113. package/dist/types/components.d.ts +86 -0
  114. package/dist/types/managers/kup-manager/kup-manager-declarations.d.ts +15 -0
  115. package/dist/types/managers/kup-manager/kup-manager.d.ts +17 -1
  116. package/package.json +1 -1
  117. package/dist/ketchup/p-bfa85d01.js +0 -1
  118. package/dist/ketchup/p-d6aa3b78.entry.js +0 -1
@@ -0,0 +1,340 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f)
3
+ throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
5
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
6
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
7
+ };
8
+ var _KupOpenAiInterface_instances, _KupOpenAiInterface_openAiInteract, _KupOpenAiInterface_dataTableData;
9
+ import { forceUpdate, h, Host, } from "@stencil/core";
10
+ import { kupManagerInstance } from "../../managers/kup-manager/kup-manager";
11
+ import { getProps, setProps } from "../../utils/utils";
12
+ import { componentWrapperId } from "../../variables/GenericVariables";
13
+ import { KupOpenAiInterfaceProps } from "./kup-openai-interface-declarations";
14
+ import { FImage } from "../../f-components/f-image/f-image";
15
+ export class KupOpenAiInterface {
16
+ constructor() {
17
+ _KupOpenAiInterface_instances.add(this);
18
+ /*-------------------------------------------------*/
19
+ /* I n t e r n a l V a r i a b l e s */
20
+ /*-------------------------------------------------*/
21
+ this.dragHandler = null;
22
+ this.kupManager = kupManagerInstance();
23
+ this.textArea = null;
24
+ this.dataTable = null;
25
+ this.button = null;
26
+ this.messages = [];
27
+ this.customStyle = '';
28
+ this.data = null;
29
+ this.dialogTitle = 'Open AI integration';
30
+ this.label = 'Insert natural language request...';
31
+ }
32
+ /*-------------------------------------------------*/
33
+ /* P u b l i c M e t h o d s */
34
+ /*-------------------------------------------------*/
35
+ /**
36
+ * Used to retrieve component's props values.
37
+ * @param {boolean} descriptions - When provided and true, the result will be the list of props with their description.
38
+ * @returns {Promise<GenericObject>} List of props as object, each key will be a prop.
39
+ */
40
+ async getProps(descriptions) {
41
+ return getProps(this, KupOpenAiInterfaceProps, descriptions);
42
+ }
43
+ /**
44
+ * This method is used to trigger a new render of the component.
45
+ */
46
+ async refresh() {
47
+ forceUpdate(this);
48
+ }
49
+ /**
50
+ * Sets the props to the component.
51
+ * @param {GenericObject} props - Object containing props that will be set to the component.
52
+ */
53
+ async setProps(props) {
54
+ setProps(this, KupOpenAiInterfaceProps, props);
55
+ }
56
+ /*-------------------------------------------------*/
57
+ /* L i f e c y c l e H o o k s */
58
+ /*-------------------------------------------------*/
59
+ componentWillLoad() {
60
+ this.kupManager.debug.logLoad(this, false);
61
+ this.kupManager.language.register(this);
62
+ this.kupManager.theme.register(this);
63
+ }
64
+ componentDidLoad() {
65
+ this.dragHandler =
66
+ this.rootElement.shadowRoot.querySelector('#drag-handle');
67
+ this.kupManager.interact.dialogify(this.rootElement, this.dragHandler);
68
+ this.kupReady.emit({
69
+ comp: this,
70
+ id: this.rootElement.id,
71
+ });
72
+ this.kupManager.debug.logLoad(this, true);
73
+ }
74
+ componentWillRender() {
75
+ this.kupManager.debug.logRender(this, false);
76
+ }
77
+ componentDidRender() {
78
+ this.kupManager.debug.logRender(this, true);
79
+ }
80
+ render() {
81
+ const dataTableProps = {};
82
+ dataTableProps.data = __classPrivateFieldGet(this, _KupOpenAiInterface_instances, "m", _KupOpenAiInterface_dataTableData).call(this);
83
+ const textAreaProps = {};
84
+ textAreaProps.textArea = true;
85
+ textAreaProps.label = this.label;
86
+ const buttonProps = {};
87
+ buttonProps.label = 'Confirm';
88
+ buttonProps.icon = 'check';
89
+ buttonProps.showSpinner = false;
90
+ return (h(Host, null, h("style", null, this.kupManager.theme.setKupStyle(this.rootElement)), h("div", { id: componentWrapperId }, h("div", { class: "openai-interface-wrapper" }, h("div", { class: "actions", id: "drag-handle" }, h("div", { class: "header" }, this.dialogTitle ? (h("div", { class: "header__title" }, this.dialogTitle)) : null, h(FImage, { onClick: () => this.kupManager.hideOpenAI(), sizeX: "1.25em", sizeY: "1.25em", resource: "clear", wrapperClass: "header__close" })), h("kup-text-field", Object.assign({}, textAreaProps, { ref: (el) => (this.textArea = el) })), h("kup-button", Object.assign({}, buttonProps, { ref: (el) => (this.button = el), "onKup-button-click": () => __classPrivateFieldGet(this, _KupOpenAiInterface_instances, "m", _KupOpenAiInterface_openAiInteract).call(this) })), h("kup-data-table", Object.assign({}, dataTableProps, { ref: (el) => (this.dataTable = el) })))))));
91
+ }
92
+ disconnectedCallback() {
93
+ this.kupManager.language.unregister(this);
94
+ this.kupManager.theme.unregister(this);
95
+ }
96
+ static get is() { return "kup-openai-interface"; }
97
+ static get encapsulation() { return "shadow"; }
98
+ static get originalStyleUrls() {
99
+ return {
100
+ "$": ["kup-openai-interface.scss"]
101
+ };
102
+ }
103
+ static get styleUrls() {
104
+ return {
105
+ "$": ["kup-openai-interface.css"]
106
+ };
107
+ }
108
+ static get properties() {
109
+ return {
110
+ "customStyle": {
111
+ "type": "string",
112
+ "mutable": false,
113
+ "complexType": {
114
+ "original": "string",
115
+ "resolved": "string",
116
+ "references": {}
117
+ },
118
+ "required": false,
119
+ "optional": false,
120
+ "docs": {
121
+ "tags": [{
122
+ "name": "default",
123
+ "text": "\"\""
124
+ }, {
125
+ "name": "see",
126
+ "text": "https://ketchup.smeup.com/ketchup-showcase/#/customization"
127
+ }],
128
+ "text": "Custom style of the component."
129
+ },
130
+ "attribute": "custom-style",
131
+ "reflect": false,
132
+ "defaultValue": "''"
133
+ },
134
+ "data": {
135
+ "type": "unknown",
136
+ "mutable": true,
137
+ "complexType": {
138
+ "original": "KupDataDataset",
139
+ "resolved": "KupDataDataset",
140
+ "references": {
141
+ "KupDataDataset": {
142
+ "location": "import",
143
+ "path": "../../managers/kup-data/kup-data-declarations",
144
+ "id": "src/managers/kup-data/kup-data-declarations.ts::KupDataDataset"
145
+ }
146
+ }
147
+ },
148
+ "required": false,
149
+ "optional": false,
150
+ "docs": {
151
+ "tags": [{
152
+ "name": "default",
153
+ "text": "null"
154
+ }],
155
+ "text": "Sets the data that will be used for OpenAI comunication."
156
+ },
157
+ "defaultValue": "null"
158
+ },
159
+ "dialogTitle": {
160
+ "type": "string",
161
+ "mutable": false,
162
+ "complexType": {
163
+ "original": "string",
164
+ "resolved": "string",
165
+ "references": {}
166
+ },
167
+ "required": false,
168
+ "optional": false,
169
+ "docs": {
170
+ "tags": [{
171
+ "name": "default",
172
+ "text": "\"Open AI integration\""
173
+ }],
174
+ "text": "Sets the dialog title"
175
+ },
176
+ "attribute": "dialog-title",
177
+ "reflect": false,
178
+ "defaultValue": "'Open AI integration'"
179
+ },
180
+ "label": {
181
+ "type": "string",
182
+ "mutable": false,
183
+ "complexType": {
184
+ "original": "string",
185
+ "resolved": "string",
186
+ "references": {}
187
+ },
188
+ "required": false,
189
+ "optional": false,
190
+ "docs": {
191
+ "tags": [{
192
+ "name": "default",
193
+ "text": "\"Insert natural language request...\""
194
+ }],
195
+ "text": "Sets the text area label"
196
+ },
197
+ "attribute": "label",
198
+ "reflect": false,
199
+ "defaultValue": "'Insert natural language request...'"
200
+ }
201
+ };
202
+ }
203
+ static get events() {
204
+ return [{
205
+ "method": "kupReady",
206
+ "name": "kup-openai-interface-ready",
207
+ "bubbles": true,
208
+ "cancelable": false,
209
+ "composed": true,
210
+ "docs": {
211
+ "tags": [],
212
+ "text": ""
213
+ },
214
+ "complexType": {
215
+ "original": "KupEventPayload",
216
+ "resolved": "KupEventPayload",
217
+ "references": {
218
+ "KupEventPayload": {
219
+ "location": "import",
220
+ "path": "../../types/GenericTypes",
221
+ "id": "src/types/GenericTypes.ts::KupEventPayload"
222
+ }
223
+ }
224
+ }
225
+ }];
226
+ }
227
+ static get methods() {
228
+ return {
229
+ "getProps": {
230
+ "complexType": {
231
+ "signature": "(descriptions?: boolean) => Promise<GenericObject>",
232
+ "parameters": [{
233
+ "tags": [{
234
+ "name": "param",
235
+ "text": "descriptions - When provided and true, the result will be the list of props with their description."
236
+ }],
237
+ "text": "- When provided and true, the result will be the list of props with their description."
238
+ }],
239
+ "references": {
240
+ "Promise": {
241
+ "location": "global",
242
+ "id": "global::Promise"
243
+ },
244
+ "GenericObject": {
245
+ "location": "import",
246
+ "path": "../../types/GenericTypes",
247
+ "id": "src/types/GenericTypes.ts::GenericObject"
248
+ }
249
+ },
250
+ "return": "Promise<GenericObject>"
251
+ },
252
+ "docs": {
253
+ "text": "Used to retrieve component's props values.",
254
+ "tags": [{
255
+ "name": "param",
256
+ "text": "descriptions - When provided and true, the result will be the list of props with their description."
257
+ }, {
258
+ "name": "returns",
259
+ "text": "List of props as object, each key will be a prop."
260
+ }]
261
+ }
262
+ },
263
+ "refresh": {
264
+ "complexType": {
265
+ "signature": "() => Promise<void>",
266
+ "parameters": [],
267
+ "references": {
268
+ "Promise": {
269
+ "location": "global",
270
+ "id": "global::Promise"
271
+ }
272
+ },
273
+ "return": "Promise<void>"
274
+ },
275
+ "docs": {
276
+ "text": "This method is used to trigger a new render of the component.",
277
+ "tags": []
278
+ }
279
+ },
280
+ "setProps": {
281
+ "complexType": {
282
+ "signature": "(props: GenericObject) => Promise<void>",
283
+ "parameters": [{
284
+ "tags": [{
285
+ "name": "param",
286
+ "text": "props - Object containing props that will be set to the component."
287
+ }],
288
+ "text": "- Object containing props that will be set to the component."
289
+ }],
290
+ "references": {
291
+ "Promise": {
292
+ "location": "global",
293
+ "id": "global::Promise"
294
+ },
295
+ "GenericObject": {
296
+ "location": "import",
297
+ "path": "../../types/GenericTypes",
298
+ "id": "src/types/GenericTypes.ts::GenericObject"
299
+ }
300
+ },
301
+ "return": "Promise<void>"
302
+ },
303
+ "docs": {
304
+ "text": "Sets the props to the component.",
305
+ "tags": [{
306
+ "name": "param",
307
+ "text": "props - Object containing props that will be set to the component."
308
+ }]
309
+ }
310
+ }
311
+ };
312
+ }
313
+ static get elementRef() { return "rootElement"; }
314
+ }
315
+ _KupOpenAiInterface_instances = new WeakSet(), _KupOpenAiInterface_openAiInteract =
316
+ /*-------------------------------------------------*/
317
+ /* P r i v a t e M e t h o d s */
318
+ /*-------------------------------------------------*/
319
+ async function _KupOpenAiInterface_openAiInteract() {
320
+ this.button.showSpinner = true;
321
+ this.messages = await this.kupManager.interactOpenAI(await this.textArea.getValue());
322
+ this.dataTable.data = __classPrivateFieldGet(this, _KupOpenAiInterface_instances, "m", _KupOpenAiInterface_dataTableData).call(this);
323
+ this.button.showSpinner = false;
324
+ }, _KupOpenAiInterface_dataTableData = function _KupOpenAiInterface_dataTableData() {
325
+ const data = {};
326
+ data.columns = [{ name: 'mess', title: 'Message' }];
327
+ data.rows = [];
328
+ if (this.messages) {
329
+ for (let i = 0; i < this.messages.length; i++) {
330
+ const mess = this.messages[i];
331
+ if (mess) {
332
+ data.rows.push({
333
+ unselectable: true,
334
+ cells: { mess: { value: mess } },
335
+ });
336
+ }
337
+ }
338
+ }
339
+ return data;
340
+ };
@@ -29,6 +29,8 @@ export class KupManager {
29
29
  */
30
30
  constructor(overrides) {
31
31
  let datesLocale = null, debugActive = null, debugAutoprint = null, debugLogLimit = null, dialogRestrictContainer = null, dialogZIndex = null, languageList = null, languageName = null, objectsList = null, scrollOnHoverDelay = null, scrollOnHoverStep = null, themeList = null, themeName = null, tooltipDelay = null, tooltipFCellCallbacks = null;
32
+ /** POI VIA */
33
+ this.openAIInterface = { url: 'https://kokosstaging.smeup.com' };
32
34
  if (overrides) {
33
35
  const assetsPath = overrides.assetsPath;
34
36
  const dates = overrides.dates;
@@ -39,6 +41,7 @@ export class KupManager {
39
41
  const scrollOnHover = overrides.scrollOnHover;
40
42
  const theme = overrides.theme;
41
43
  const tooltip = overrides.tooltip;
44
+ const openAIUrl = overrides.openAIUrl;
42
45
  if (assetsPath) {
43
46
  setAssetPath(assetsPath);
44
47
  }
@@ -81,6 +84,9 @@ export class KupManager {
81
84
  ? tooltip.fCellCallbacks
82
85
  : null;
83
86
  }
87
+ if (openAIUrl) {
88
+ this.openAIInterface = { url: openAIUrl };
89
+ }
84
90
  }
85
91
  this.data = new KupData();
86
92
  this.dates = new KupDates(datesLocale);
@@ -89,6 +95,7 @@ export class KupManager {
89
95
  this.interact = new KupInteract(dialogZIndex, dialogRestrictContainer);
90
96
  this.language = new KupLanguage(languageList, languageName);
91
97
  this.magicBox = null;
98
+ this.openAI = null;
92
99
  this.math = new KupMath();
93
100
  this.overrides = overrides ? overrides : null;
94
101
  this.objects = new KupObjects(objectsList);
@@ -201,6 +208,123 @@ export class KupManager {
201
208
  this.hideMagicBox();
202
209
  }
203
210
  }
211
+ /**
212
+ * Creates OpenAI component interface.
213
+ */
214
+ async showOpenAI(data) {
215
+ if (!this.openAIInterface || !this.openAIInterface.url) {
216
+ return;
217
+ }
218
+ if (this.openAI) {
219
+ return;
220
+ }
221
+ const response = await fetch(this.openAIInterface.url + '/api/init', {
222
+ method: 'POST',
223
+ headers: {
224
+ 'Content-Type': 'application/json',
225
+ },
226
+ body: JSON.stringify({ data: data }),
227
+ });
228
+ console.log('kup-manager.showOpenAI() response', response);
229
+ if (response) {
230
+ if (response.status != 200) {
231
+ this.debug.logMessage(this, await response.text(), KupDebugCategory.ERROR);
232
+ return;
233
+ }
234
+ const responseJson = await response.json();
235
+ this.openAIInterface.sessionInfo = {
236
+ fileId: responseJson.fileId,
237
+ threadId: responseJson.threadId,
238
+ };
239
+ }
240
+ this.openAI = document.createElement('kup-openai-interface');
241
+ this.openAI.id = 'kup-openai-interface';
242
+ this.openAI.style.position = 'fixed';
243
+ this.openAI.style.left = 'calc(50% - 250px)';
244
+ this.openAI.style.top = 'calc(50% - 85px)';
245
+ this.openAI.data = data;
246
+ document.body.appendChild(this.openAI);
247
+ }
248
+ /**
249
+ * Removes OpenAI component interface.
250
+ */
251
+ async hideOpenAI() {
252
+ if (!this.openAI) {
253
+ return;
254
+ }
255
+ this.openAI.remove();
256
+ this.openAI = null;
257
+ if (!this.openAIInterface || !this.openAIInterface.url) {
258
+ return;
259
+ }
260
+ if (!this.openAIInterface.sessionInfo) {
261
+ return;
262
+ }
263
+ const response = await fetch(this.openAIInterface.url + '/api/finalize', {
264
+ method: 'POST',
265
+ headers: {
266
+ 'Content-Type': 'application/json',
267
+ },
268
+ body: JSON.stringify({
269
+ fileId: this.openAIInterface.sessionInfo.fileId,
270
+ threadId: this.openAIInterface.sessionInfo.threadId,
271
+ }),
272
+ });
273
+ console.log('kup-manager.hideOpenAI() response', response);
274
+ if (response) {
275
+ if (response.status != 200) {
276
+ this.debug.logMessage(this, await response.text(), KupDebugCategory.ERROR);
277
+ return;
278
+ }
279
+ this.openAIInterface.sessionInfo = null;
280
+ }
281
+ }
282
+ /**
283
+ * Creates or removes OpenAI component interface depending on its existence.
284
+ */
285
+ toggleOpenAI(data) {
286
+ if (!this.openAI) {
287
+ this.showOpenAI(data);
288
+ }
289
+ else {
290
+ this.hideOpenAI();
291
+ }
292
+ }
293
+ async interactOpenAI(question) {
294
+ if (!this.openAI) {
295
+ return;
296
+ }
297
+ if (!this.openAIInterface || !this.openAIInterface.url) {
298
+ return;
299
+ }
300
+ if (!this.openAIInterface.sessionInfo) {
301
+ return;
302
+ }
303
+ const responseArray = [];
304
+ const response = await fetch(this.openAIInterface.url + '/api/chat', {
305
+ method: 'POST',
306
+ headers: {
307
+ 'Content-Type': 'application/json',
308
+ },
309
+ body: JSON.stringify({
310
+ fileId: this.openAIInterface.sessionInfo.fileId,
311
+ threadId: this.openAIInterface.sessionInfo.threadId,
312
+ question: question,
313
+ }),
314
+ });
315
+ console.log('kup-manager.interactOpenAI() response', response);
316
+ if (response) {
317
+ if (response.status != 200) {
318
+ this.debug.logMessage(this, await response.text(), KupDebugCategory.ERROR);
319
+ return;
320
+ }
321
+ const responseJson = await response.json();
322
+ if (responseJson && responseJson.messages) {
323
+ responseArray.push(...responseJson.messages);
324
+ }
325
+ }
326
+ return responseArray;
327
+ }
204
328
  /**
205
329
  * Sets both locale and language library-wide.
206
330
  * @param {KupDatesLocales} locale - The supported locale.
@@ -21560,11 +21560,20 @@ const KupDataTable = /*@__PURE__*/ proxyCustomElement(class KupDataTable extends
21560
21560
  }
21561
21561
  return (h("kup-card", { customStyle: "::slotted(kup-switch) { width: max-content !important; } ::slotted(*) { margin: auto !important; } ::slotted(.customize-element) { margin: auto !important; padding: 0 1em 1em 1em !important; width: max-content !important; } ::slotted(.customize-element):nth-child(1) { padding-top: 1em !important; }", isMenu: true, layoutFamily: KupCardFamily.FREE, ref: (el) => {
21562
21562
  __classPrivateFieldSet$2(this, _KupDataTable_customizeTopPanelRef, el, "f");
21563
- }, sizeX: "360px", sizeY: "300px" }, density, grid, fontsize, transpose, h("kup-switch", { class: "customize-element", checked: this.dragEnabled, label: __classPrivateFieldGet$3(this, _KupDataTable_kupManager, "f").language.translate(KupLanguageGeneric.DRAG_AND_DROP), leadingLabel: true, "onkup-switch-change": () => (this.dragEnabled = !this.dragEnabled) }), h("kup-switch", { class: "customize-element", checked: this.editableData, label: __classPrivateFieldGet$3(this, _KupDataTable_kupManager, "f").language.translate(KupLanguageGeneric.EDITABLE), leadingLabel: true, "onkup-switch-change": () => (this.editableData = !this.editableData) }), h("kup-button", { title: __classPrivateFieldGet$3(this, _KupDataTable_kupManager, "f").language.translate(KupLanguageGeneric.TOGGLE) +
21563
+ }, sizeX: "360px", sizeY: "300px" }, density, grid, fontsize, transpose, h("kup-switch", { class: "customize-element", checked: this.dragEnabled, label: __classPrivateFieldGet$3(this, _KupDataTable_kupManager, "f").language.translate(KupLanguageGeneric.DRAG_AND_DROP), leadingLabel: true, "onkup-switch-change": () => (this.dragEnabled = !this.dragEnabled) }), h("kup-switch", { class: "customize-element", checked: this.editableData, label: __classPrivateFieldGet$3(this, _KupDataTable_kupManager, "f").language.translate(KupLanguageGeneric.EDITABLE), leadingLabel: true, "onkup-switch-change": () => (this.editableData = !this.editableData) }), h("div", { style: {
21564
+ display: 'grid',
21565
+ 'grid-template-columns': 'repeat(2, auto)',
21566
+ width: 'max-content',
21567
+ } }, h("kup-button", { title: __classPrivateFieldGet$3(this, _KupDataTable_kupManager, "f").language.translate(KupLanguageGeneric.TOGGLE) +
21564
21568
  ' Magic Box ' +
21565
21569
  '(' +
21566
21570
  __classPrivateFieldGet$3(this, _KupDataTable_kupManager, "f").language.translate(KupLanguageGeneric.EXPERIMENTAL_FEAT) +
21567
- ')', icon: "auto-fix", "onkup-button-click": () => __classPrivateFieldGet$3(this, _KupDataTable_kupManager, "f").toggleMagicBox() }), totalsMatrix));
21571
+ ')', icon: "auto-fix", "onkup-button-click": () => __classPrivateFieldGet$3(this, _KupDataTable_kupManager, "f").toggleMagicBox() }), __classPrivateFieldGet$3(this, _KupDataTable_kupManager, "f").openAIInterface &&
21572
+ __classPrivateFieldGet$3(this, _KupDataTable_kupManager, "f").openAIInterface.url ? (h("kup-button", { title: __classPrivateFieldGet$3(this, _KupDataTable_kupManager, "f").language.translate(KupLanguageGeneric.TOGGLE) +
21573
+ ' Open AI ' +
21574
+ '(' +
21575
+ __classPrivateFieldGet$3(this, _KupDataTable_kupManager, "f").language.translate(KupLanguageGeneric.EXPERIMENTAL_FEAT) +
21576
+ ')', icon: "open-ai", "onkup-button-click": () => __classPrivateFieldGet$3(this, _KupDataTable_kupManager, "f").toggleOpenAI(this.data) })) : null), totalsMatrix));
21568
21577
  }
21569
21578
  render() {
21570
21579
  __classPrivateFieldSet$2(this, _KupDataTable_thRefs, [], "f");
@@ -17585,6 +17585,8 @@ class KupManager {
17585
17585
  */
17586
17586
  constructor(overrides) {
17587
17587
  let datesLocale = null, debugActive = null, debugAutoprint = null, debugLogLimit = null, dialogRestrictContainer = null, dialogZIndex = null, languageList = null, languageName = null, objectsList = null, scrollOnHoverDelay = null, scrollOnHoverStep = null, themeList = null, themeName = null, tooltipDelay = null, tooltipFCellCallbacks = null;
17588
+ /** POI VIA */
17589
+ this.openAIInterface = { url: 'https://kokosstaging.smeup.com' };
17588
17590
  if (overrides) {
17589
17591
  const assetsPath = overrides.assetsPath;
17590
17592
  const dates = overrides.dates;
@@ -17595,6 +17597,7 @@ class KupManager {
17595
17597
  const scrollOnHover = overrides.scrollOnHover;
17596
17598
  const theme = overrides.theme;
17597
17599
  const tooltip = overrides.tooltip;
17600
+ const openAIUrl = overrides.openAIUrl;
17598
17601
  if (assetsPath) {
17599
17602
  setAssetPath(assetsPath);
17600
17603
  }
@@ -17637,6 +17640,9 @@ class KupManager {
17637
17640
  ? tooltip.fCellCallbacks
17638
17641
  : null;
17639
17642
  }
17643
+ if (openAIUrl) {
17644
+ this.openAIInterface = { url: openAIUrl };
17645
+ }
17640
17646
  }
17641
17647
  this.data = new KupData();
17642
17648
  this.dates = new KupDates(datesLocale);
@@ -17645,6 +17651,7 @@ class KupManager {
17645
17651
  this.interact = new KupInteract(dialogZIndex, dialogRestrictContainer);
17646
17652
  this.language = new KupLanguage(languageList, languageName);
17647
17653
  this.magicBox = null;
17654
+ this.openAI = null;
17648
17655
  this.math = new KupMath();
17649
17656
  this.overrides = overrides ? overrides : null;
17650
17657
  this.objects = new KupObjects(objectsList);
@@ -17757,6 +17764,123 @@ class KupManager {
17757
17764
  this.hideMagicBox();
17758
17765
  }
17759
17766
  }
17767
+ /**
17768
+ * Creates OpenAI component interface.
17769
+ */
17770
+ async showOpenAI(data) {
17771
+ if (!this.openAIInterface || !this.openAIInterface.url) {
17772
+ return;
17773
+ }
17774
+ if (this.openAI) {
17775
+ return;
17776
+ }
17777
+ const response = await fetch(this.openAIInterface.url + '/api/init', {
17778
+ method: 'POST',
17779
+ headers: {
17780
+ 'Content-Type': 'application/json',
17781
+ },
17782
+ body: JSON.stringify({ data: data }),
17783
+ });
17784
+ console.log('kup-manager.showOpenAI() response', response);
17785
+ if (response) {
17786
+ if (response.status != 200) {
17787
+ this.debug.logMessage(this, await response.text(), KupDebugCategory.ERROR);
17788
+ return;
17789
+ }
17790
+ const responseJson = await response.json();
17791
+ this.openAIInterface.sessionInfo = {
17792
+ fileId: responseJson.fileId,
17793
+ threadId: responseJson.threadId,
17794
+ };
17795
+ }
17796
+ this.openAI = document.createElement('kup-openai-interface');
17797
+ this.openAI.id = 'kup-openai-interface';
17798
+ this.openAI.style.position = 'fixed';
17799
+ this.openAI.style.left = 'calc(50% - 250px)';
17800
+ this.openAI.style.top = 'calc(50% - 85px)';
17801
+ this.openAI.data = data;
17802
+ document.body.appendChild(this.openAI);
17803
+ }
17804
+ /**
17805
+ * Removes OpenAI component interface.
17806
+ */
17807
+ async hideOpenAI() {
17808
+ if (!this.openAI) {
17809
+ return;
17810
+ }
17811
+ this.openAI.remove();
17812
+ this.openAI = null;
17813
+ if (!this.openAIInterface || !this.openAIInterface.url) {
17814
+ return;
17815
+ }
17816
+ if (!this.openAIInterface.sessionInfo) {
17817
+ return;
17818
+ }
17819
+ const response = await fetch(this.openAIInterface.url + '/api/finalize', {
17820
+ method: 'POST',
17821
+ headers: {
17822
+ 'Content-Type': 'application/json',
17823
+ },
17824
+ body: JSON.stringify({
17825
+ fileId: this.openAIInterface.sessionInfo.fileId,
17826
+ threadId: this.openAIInterface.sessionInfo.threadId,
17827
+ }),
17828
+ });
17829
+ console.log('kup-manager.hideOpenAI() response', response);
17830
+ if (response) {
17831
+ if (response.status != 200) {
17832
+ this.debug.logMessage(this, await response.text(), KupDebugCategory.ERROR);
17833
+ return;
17834
+ }
17835
+ this.openAIInterface.sessionInfo = null;
17836
+ }
17837
+ }
17838
+ /**
17839
+ * Creates or removes OpenAI component interface depending on its existence.
17840
+ */
17841
+ toggleOpenAI(data) {
17842
+ if (!this.openAI) {
17843
+ this.showOpenAI(data);
17844
+ }
17845
+ else {
17846
+ this.hideOpenAI();
17847
+ }
17848
+ }
17849
+ async interactOpenAI(question) {
17850
+ if (!this.openAI) {
17851
+ return;
17852
+ }
17853
+ if (!this.openAIInterface || !this.openAIInterface.url) {
17854
+ return;
17855
+ }
17856
+ if (!this.openAIInterface.sessionInfo) {
17857
+ return;
17858
+ }
17859
+ const responseArray = [];
17860
+ const response = await fetch(this.openAIInterface.url + '/api/chat', {
17861
+ method: 'POST',
17862
+ headers: {
17863
+ 'Content-Type': 'application/json',
17864
+ },
17865
+ body: JSON.stringify({
17866
+ fileId: this.openAIInterface.sessionInfo.fileId,
17867
+ threadId: this.openAIInterface.sessionInfo.threadId,
17868
+ question: question,
17869
+ }),
17870
+ });
17871
+ console.log('kup-manager.interactOpenAI() response', response);
17872
+ if (response) {
17873
+ if (response.status != 200) {
17874
+ this.debug.logMessage(this, await response.text(), KupDebugCategory.ERROR);
17875
+ return;
17876
+ }
17877
+ const responseJson = await response.json();
17878
+ if (responseJson && responseJson.messages) {
17879
+ responseArray.push(...responseJson.messages);
17880
+ }
17881
+ }
17882
+ return responseArray;
17883
+ }
17760
17884
  /**
17761
17885
  * Sets both locale and language library-wide.
17762
17886
  * @param {KupDatesLocales} locale - The supported locale.