dp-widgets-framework 1.6.8 → 1.6.9
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/index.esm.js +61 -167
- package/dist/index.js +61 -167
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -43606,24 +43606,6 @@ const loadAgentState$5 = async (widgetBackendUrl, threadId, agentName) => {
|
|
|
43606
43606
|
return null;
|
|
43607
43607
|
}
|
|
43608
43608
|
};
|
|
43609
|
-
const loadSessionStateDirect$5 = async (widgetBackendUrl, sessionId) => {
|
|
43610
|
-
try {
|
|
43611
|
-
const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
|
|
43612
|
-
method: "GET",
|
|
43613
|
-
headers: {
|
|
43614
|
-
"Content-Type": "application/json"
|
|
43615
|
-
}
|
|
43616
|
-
});
|
|
43617
|
-
if (!response.ok) {
|
|
43618
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
43619
|
-
}
|
|
43620
|
-
const result = await response.json();
|
|
43621
|
-
return result;
|
|
43622
|
-
} catch (error) {
|
|
43623
|
-
console.error("Failed to load session state directly:", error);
|
|
43624
|
-
return null;
|
|
43625
|
-
}
|
|
43626
|
-
};
|
|
43627
43609
|
const parseAndUpdateChartState$4 = (apiResponse, setChartState) => {
|
|
43628
43610
|
var _a, _b;
|
|
43629
43611
|
try {
|
|
@@ -44148,7 +44130,7 @@ function CopilotKitAgent({
|
|
|
44148
44130
|
datasetId,
|
|
44149
44131
|
widgetData
|
|
44150
44132
|
}) {
|
|
44151
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _
|
|
44133
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa;
|
|
44152
44134
|
const agentType = (_a = widget.config) == null ? void 0 : _a.agentType;
|
|
44153
44135
|
const orientation = (_b = widget.config) == null ? void 0 : _b.orientation;
|
|
44154
44136
|
const isFirstLoad = (_c = widget.config) == null ? void 0 : _c.isFirstLoad;
|
|
@@ -44159,7 +44141,6 @@ function CopilotKitAgent({
|
|
|
44159
44141
|
const [apiCallCount, setApiCallCount] = useState(0);
|
|
44160
44142
|
const [hasTimeoutError, setHasTimeoutError] = useState(false);
|
|
44161
44143
|
const hasInitialFetchRef = useRef(false);
|
|
44162
|
-
const [isInitialFetchComplete, setIsInitialFetchComplete] = useState(false);
|
|
44163
44144
|
useEffect(() => {
|
|
44164
44145
|
setThreadId(widget.id);
|
|
44165
44146
|
}, [widget.id, setThreadId]);
|
|
@@ -44169,16 +44150,17 @@ function CopilotKitAgent({
|
|
|
44169
44150
|
});
|
|
44170
44151
|
useEffect(() => {
|
|
44171
44152
|
const fetchInitialState = async () => {
|
|
44153
|
+
var _a2;
|
|
44172
44154
|
if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
|
|
44173
44155
|
hasInitialFetchRef.current = true;
|
|
44174
|
-
const
|
|
44156
|
+
const agentName = ((_a2 = widget.config) == null ? void 0 : _a2.agentName) || "adk-construction-project-agent";
|
|
44157
|
+
const apiResponse = await loadAgentState$5(widgetBackendUrl, widget.id, agentName);
|
|
44175
44158
|
if (apiResponse) {
|
|
44176
44159
|
parseAndUpdateChartState$4(apiResponse, setChartState);
|
|
44177
44160
|
}
|
|
44178
|
-
setIsInitialFetchComplete(true);
|
|
44179
44161
|
};
|
|
44180
44162
|
fetchInitialState();
|
|
44181
|
-
}, [widgetBackendUrl, widget.id, setChartState]);
|
|
44163
|
+
}, [widgetBackendUrl, widget.id, (_f = widget.config) == null ? void 0 : _f.agentName, setChartState]);
|
|
44182
44164
|
const handleLoadingTimeout = useCallback(async () => {
|
|
44183
44165
|
var _a2;
|
|
44184
44166
|
if (!widgetBackendUrl || !widget.id || isTimeoutTriggered || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) return;
|
|
@@ -44198,7 +44180,7 @@ function CopilotKitAgent({
|
|
|
44198
44180
|
if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
|
|
44199
44181
|
parseAndUpdateChartState$4(apiResponse, setChartState);
|
|
44200
44182
|
}
|
|
44201
|
-
}, [widgetBackendUrl, widget.id, isTimeoutTriggered, setChartState, (
|
|
44183
|
+
}, [widgetBackendUrl, widget.id, isTimeoutTriggered, setChartState, (_g = widget.config) == null ? void 0 : _g.agentName, chartState, apiCallCount, hasTimeoutError]);
|
|
44202
44184
|
const startLoadingTimeout = useCallback(() => {
|
|
44203
44185
|
if (timeoutRef.current) {
|
|
44204
44186
|
clearTimeout(timeoutRef.current);
|
|
@@ -44281,8 +44263,8 @@ function CopilotKitAgent({
|
|
|
44281
44263
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Bot, { className: "h-4 w-4" }),
|
|
44282
44264
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
|
|
44283
44265
|
] }) }),
|
|
44284
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children:
|
|
44285
|
-
(agentType === "Bar Chart Agent" && (!((
|
|
44266
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && agentType !== "chatbot" && // Check if data is empty based on agent type
|
|
44267
|
+
(agentType === "Bar Chart Agent" && (!((_j = (_i = (_h = chartState.bar_chart_data) == null ? void 0 : _h.data) == null ? void 0 : _i.labels) == null ? void 0 : _j.length) || !((_m = (_l = (_k = chartState.bar_chart_data) == null ? void 0 : _k.data) == null ? void 0 : _l.values) == null ? void 0 : _m.length)) || agentType === "Series Bar Chart Agent" && (!((_p = (_o = (_n = chartState.series_bar_chart_data) == null ? void 0 : _n.data) == null ? void 0 : _o.labels) == null ? void 0 : _p.length) || !((_s = (_r = (_q = chartState.series_bar_chart_data) == null ? void 0 : _q.data) == null ? void 0 : _r.series) == null ? void 0 : _s.length)) || agentType === "Series Line Chart Agent" && (!((_v = (_u = (_t = chartState.series_bar_chart_data) == null ? void 0 : _t.data) == null ? void 0 : _u.labels) == null ? void 0 : _v.length) || !((_y = (_x = (_w = chartState.series_bar_chart_data) == null ? void 0 : _w.data) == null ? void 0 : _x.series) == null ? void 0 : _y.length)) || agentType === "Pie Chart Agent" && (!((_B = (_A = (_z = chartState.pie_chart_data) == null ? void 0 : _z.data) == null ? void 0 : _A.labels) == null ? void 0 : _B.length) || !((_E = (_D = (_C = chartState.pie_chart_data) == null ? void 0 : _C.data) == null ? void 0 : _D.values) == null ? void 0 : _E.length)) || agentType === "Line Chart Agent" && (!((_H = (_G = (_F = chartState.bar_chart_data) == null ? void 0 : _F.data) == null ? void 0 : _G.labels) == null ? void 0 : _H.length) || !((_K = (_J = (_I = chartState.bar_chart_data) == null ? void 0 : _I.data) == null ? void 0 : _J.values) == null ? void 0 : _K.length)) || agentType === "Data Grid Agent" && (!((_N = (_M = (_L = chartState.matrix_grid_data) == null ? void 0 : _L.data) == null ? void 0 : _M.headers) == null ? void 0 : _N.length) || !((_Q = (_P = (_O = chartState.matrix_grid_data) == null ? void 0 : _O.data) == null ? void 0 : _P.rows) == null ? void 0 : _Q.length)) || agentType === "Summary Agent" && (!((_S = (_R = chartState.summary_data) == null ? void 0 : _R.data) == null ? void 0 : _S.content) || ((_V = (_U = (_T = chartState.summary_data) == null ? void 0 : _T.data) == null ? void 0 : _U.content) == null ? void 0 : _V.trim()) === "")) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : agentType === "Bar Chart Agent" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
44286
44268
|
BarChartComponent,
|
|
44287
44269
|
{
|
|
44288
44270
|
barChartState: chartState,
|
|
@@ -44290,7 +44272,7 @@ function CopilotKitAgent({
|
|
|
44290
44272
|
orientation,
|
|
44291
44273
|
content,
|
|
44292
44274
|
appendMessage,
|
|
44293
|
-
query: (
|
|
44275
|
+
query: (_W = widget.config) == null ? void 0 : _W.query,
|
|
44294
44276
|
isFirstLoad,
|
|
44295
44277
|
widgetBackendUrl,
|
|
44296
44278
|
widgetId: widget.id,
|
|
@@ -44305,7 +44287,7 @@ function CopilotKitAgent({
|
|
|
44305
44287
|
orientation,
|
|
44306
44288
|
content,
|
|
44307
44289
|
appendMessage,
|
|
44308
|
-
query: (
|
|
44290
|
+
query: (_X = widget.config) == null ? void 0 : _X.query,
|
|
44309
44291
|
isFirstLoad,
|
|
44310
44292
|
widgetBackendUrl,
|
|
44311
44293
|
widgetId: widget.id,
|
|
@@ -44320,7 +44302,7 @@ function CopilotKitAgent({
|
|
|
44320
44302
|
orientation,
|
|
44321
44303
|
content,
|
|
44322
44304
|
appendMessage,
|
|
44323
|
-
query: (
|
|
44305
|
+
query: (_Y = widget.config) == null ? void 0 : _Y.query,
|
|
44324
44306
|
isFirstLoad,
|
|
44325
44307
|
widgetBackendUrl,
|
|
44326
44308
|
widgetId: widget.id,
|
|
@@ -44334,7 +44316,7 @@ function CopilotKitAgent({
|
|
|
44334
44316
|
styles,
|
|
44335
44317
|
appendMessage,
|
|
44336
44318
|
content,
|
|
44337
|
-
query: (
|
|
44319
|
+
query: (_Z = widget.config) == null ? void 0 : _Z.query,
|
|
44338
44320
|
isFirstLoad,
|
|
44339
44321
|
widgetBackendUrl,
|
|
44340
44322
|
widgetId: widget.id,
|
|
@@ -44348,7 +44330,7 @@ function CopilotKitAgent({
|
|
|
44348
44330
|
styles,
|
|
44349
44331
|
appendMessage,
|
|
44350
44332
|
content,
|
|
44351
|
-
query: (
|
|
44333
|
+
query: (__ = widget.config) == null ? void 0 : __.query,
|
|
44352
44334
|
isFirstLoad,
|
|
44353
44335
|
widgetBackendUrl,
|
|
44354
44336
|
widgetId: widget.id,
|
|
@@ -44361,7 +44343,7 @@ function CopilotKitAgent({
|
|
|
44361
44343
|
dataGridState: chartState,
|
|
44362
44344
|
styles,
|
|
44363
44345
|
appendMessage,
|
|
44364
|
-
query: (
|
|
44346
|
+
query: (_$ = widget.config) == null ? void 0 : _$.query,
|
|
44365
44347
|
isFirstLoad,
|
|
44366
44348
|
widgetBackendUrl,
|
|
44367
44349
|
widgetId: widget.id,
|
|
@@ -44374,7 +44356,7 @@ function CopilotKitAgent({
|
|
|
44374
44356
|
summaryState: chartState,
|
|
44375
44357
|
styles,
|
|
44376
44358
|
appendMessage,
|
|
44377
|
-
query: (
|
|
44359
|
+
query: (_aa = widget.config) == null ? void 0 : _aa.query,
|
|
44378
44360
|
isFirstLoad,
|
|
44379
44361
|
widgetBackendUrl,
|
|
44380
44362
|
widgetId: widget.id,
|
|
@@ -44805,24 +44787,6 @@ const loadAgentState$4 = async (widgetBackendUrl, threadId, agentName) => {
|
|
|
44805
44787
|
return null;
|
|
44806
44788
|
}
|
|
44807
44789
|
};
|
|
44808
|
-
const loadSessionStateDirect$4 = async (widgetBackendUrl, sessionId) => {
|
|
44809
|
-
try {
|
|
44810
|
-
const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
|
|
44811
|
-
method: "GET",
|
|
44812
|
-
headers: {
|
|
44813
|
-
"Content-Type": "application/json"
|
|
44814
|
-
}
|
|
44815
|
-
});
|
|
44816
|
-
if (!response.ok) {
|
|
44817
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
44818
|
-
}
|
|
44819
|
-
const result = await response.json();
|
|
44820
|
-
return result;
|
|
44821
|
-
} catch (error) {
|
|
44822
|
-
console.error("Failed to load session state directly:", error);
|
|
44823
|
-
return null;
|
|
44824
|
-
}
|
|
44825
|
-
};
|
|
44826
44790
|
const parseAndUpdateFilterState = (apiResponse, setFilterState) => {
|
|
44827
44791
|
var _a, _b;
|
|
44828
44792
|
try {
|
|
@@ -45279,7 +45243,7 @@ function CopilotKitFilters({
|
|
|
45279
45243
|
onApplyFilters,
|
|
45280
45244
|
isEditing = false
|
|
45281
45245
|
}) {
|
|
45282
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
45246
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
45283
45247
|
const isFirstLoad = (_a = widget.config) == null ? void 0 : _a.isFirstLoad;
|
|
45284
45248
|
const widget_data = (_b = widget.widget_data) == null ? void 0 : _b.column_values;
|
|
45285
45249
|
const { setThreadId } = useCopilotContext();
|
|
@@ -45297,15 +45261,17 @@ function CopilotKitFilters({
|
|
|
45297
45261
|
const [filterState, setFilterState] = useState(createInitialFilterState(datasetId, widget_data));
|
|
45298
45262
|
useEffect(() => {
|
|
45299
45263
|
const fetchInitialState = async () => {
|
|
45264
|
+
var _a2;
|
|
45300
45265
|
if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
|
|
45301
45266
|
hasInitialFetchRef.current = true;
|
|
45302
|
-
const
|
|
45267
|
+
const agentName = ((_a2 = widget.config) == null ? void 0 : _a2.agentName) || "adk-construction-project-agent";
|
|
45268
|
+
const apiResponse = await loadAgentState$4(widgetBackendUrl, widget.id, agentName);
|
|
45303
45269
|
if (apiResponse) {
|
|
45304
45270
|
parseAndUpdateFilterState(apiResponse, setFilterState);
|
|
45305
45271
|
}
|
|
45306
45272
|
};
|
|
45307
45273
|
fetchInitialState();
|
|
45308
|
-
}, [widgetBackendUrl, widget.id, setFilterState]);
|
|
45274
|
+
}, [widgetBackendUrl, widget.id, (_d = widget.config) == null ? void 0 : _d.agentName, setFilterState]);
|
|
45309
45275
|
const handleLoadingTimeout = useCallback(async () => {
|
|
45310
45276
|
var _a2;
|
|
45311
45277
|
if (!widgetBackendUrl || !widget.id || (filterState == null ? void 0 : filterState.agent_message) || hasTimeoutError) {
|
|
@@ -45329,7 +45295,7 @@ function CopilotKitFilters({
|
|
|
45329
45295
|
if (apiResponse && !(filterState == null ? void 0 : filterState.agent_message)) {
|
|
45330
45296
|
parseAndUpdateFilterState(apiResponse, setFilterState);
|
|
45331
45297
|
}
|
|
45332
|
-
}, [widgetBackendUrl, widget.id, setFilterState, (
|
|
45298
|
+
}, [widgetBackendUrl, widget.id, setFilterState, (_e = widget.config) == null ? void 0 : _e.agentName, filterState, apiCallCount, hasTimeoutError]);
|
|
45333
45299
|
const startLoadingTimeout = useCallback(() => {
|
|
45334
45300
|
if (timeoutRef.current) {
|
|
45335
45301
|
clearTimeout(timeoutRef.current);
|
|
@@ -45455,7 +45421,7 @@ function CopilotKitFilters({
|
|
|
45455
45421
|
setHasTimeoutError(false);
|
|
45456
45422
|
console.log("[FiltersWidget] Starting polling after confirmation");
|
|
45457
45423
|
startLoadingTimeout();
|
|
45458
|
-
}, [filterState.filter_columns, filterState.ambiguous_columns, (
|
|
45424
|
+
}, [filterState.filter_columns, filterState.ambiguous_columns, (_f = widget.config) == null ? void 0 : _f.query, datasetId, appendMessage, setFilterState, setAgentState, startLoadingTimeout, setApiCallCount, setHasTimeoutError]);
|
|
45459
45425
|
const handleCancelConfirmation = useCallback(() => {
|
|
45460
45426
|
setFilterState((prev) => __spreadProps$7(__spreadValues$9({}, prev), {
|
|
45461
45427
|
status: void 0,
|
|
@@ -45468,7 +45434,7 @@ function CopilotKitFilters({
|
|
|
45468
45434
|
console.log("[CopilotKitFilters] Filter state check:", {
|
|
45469
45435
|
status: filterState.status,
|
|
45470
45436
|
hasAmbiguousColumns: !!filterState.ambiguous_columns,
|
|
45471
|
-
ambiguousColumnsLength: ((
|
|
45437
|
+
ambiguousColumnsLength: ((_g = filterState.ambiguous_columns) == null ? void 0 : _g.length) || 0,
|
|
45472
45438
|
isWaitingForConfirmation,
|
|
45473
45439
|
fullFilterState: filterState
|
|
45474
45440
|
});
|
|
@@ -45484,7 +45450,7 @@ function CopilotKitFilters({
|
|
|
45484
45450
|
onCancel: handleCancelConfirmation
|
|
45485
45451
|
}
|
|
45486
45452
|
)
|
|
45487
|
-
) : (filterState == null ? void 0 : filterState.agent_message) && !((
|
|
45453
|
+
) : (filterState == null ? void 0 : filterState.agent_message) && !((_h = filterState.column_values) == null ? void 0 : _h.length) && filterState.status !== "waiting_for_confirmation" ? (
|
|
45488
45454
|
// Show agent message (errors, warnings, etc.)
|
|
45489
45455
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700 whitespace-pre-line", children: filterState.agent_message }) }) })
|
|
45490
45456
|
) : (
|
|
@@ -45497,7 +45463,7 @@ function CopilotKitFilters({
|
|
|
45497
45463
|
onFilterChange,
|
|
45498
45464
|
widget,
|
|
45499
45465
|
appendMessage,
|
|
45500
|
-
query: (
|
|
45466
|
+
query: (_i = widget.config) == null ? void 0 : _i.query,
|
|
45501
45467
|
isFirstLoad,
|
|
45502
45468
|
widgetBackendUrl,
|
|
45503
45469
|
widgetId: widget.id,
|
|
@@ -45636,24 +45602,6 @@ const loadAgentState$3 = async (widgetBackendUrl, threadId, agentName) => {
|
|
|
45636
45602
|
return null;
|
|
45637
45603
|
}
|
|
45638
45604
|
};
|
|
45639
|
-
const loadSessionStateDirect$3 = async (widgetBackendUrl, sessionId) => {
|
|
45640
|
-
try {
|
|
45641
|
-
const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
|
|
45642
|
-
method: "GET",
|
|
45643
|
-
headers: {
|
|
45644
|
-
"Content-Type": "application/json"
|
|
45645
|
-
}
|
|
45646
|
-
});
|
|
45647
|
-
if (!response.ok) {
|
|
45648
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
45649
|
-
}
|
|
45650
|
-
const result = await response.json();
|
|
45651
|
-
return result;
|
|
45652
|
-
} catch (error) {
|
|
45653
|
-
console.error("Failed to load session state directly:", error);
|
|
45654
|
-
return null;
|
|
45655
|
-
}
|
|
45656
|
-
};
|
|
45657
45605
|
const parseAndUpdateChartState$3 = (apiResponse, setChartState) => {
|
|
45658
45606
|
var _a, _b;
|
|
45659
45607
|
try {
|
|
@@ -45779,7 +45727,7 @@ function CopilotKitPieChart({
|
|
|
45779
45727
|
datasetId,
|
|
45780
45728
|
widgetData
|
|
45781
45729
|
}) {
|
|
45782
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
45730
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
45783
45731
|
const isFirstLoad = (_a = widget.config) == null ? void 0 : _a.isFirstLoad;
|
|
45784
45732
|
const content = (_b = widget.config) == null ? void 0 : _b.content;
|
|
45785
45733
|
const widget_data = (_c = widget.widget_data) == null ? void 0 : _c.pie_chart_data;
|
|
@@ -45796,19 +45744,19 @@ function CopilotKitPieChart({
|
|
|
45796
45744
|
initialState: createInitialChartState$3(datasetId, widget_data)
|
|
45797
45745
|
});
|
|
45798
45746
|
const [chartState, setChartState] = useState(createInitialChartState$3(datasetId, widget_data));
|
|
45799
|
-
const [isInitialFetchComplete, setIsInitialFetchComplete] = useState(false);
|
|
45800
45747
|
useEffect(() => {
|
|
45801
45748
|
const fetchInitialState = async () => {
|
|
45749
|
+
var _a2;
|
|
45802
45750
|
if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
|
|
45803
45751
|
hasInitialFetchRef.current = true;
|
|
45804
|
-
const
|
|
45752
|
+
const agentName = ((_a2 = widget.config) == null ? void 0 : _a2.agentName) || "adk-construction-project-agent";
|
|
45753
|
+
const apiResponse = await loadAgentState$3(widgetBackendUrl, widget.id, agentName);
|
|
45805
45754
|
if (apiResponse) {
|
|
45806
45755
|
parseAndUpdateChartState$3(apiResponse, setChartState);
|
|
45807
45756
|
}
|
|
45808
|
-
setIsInitialFetchComplete(true);
|
|
45809
45757
|
};
|
|
45810
45758
|
fetchInitialState();
|
|
45811
|
-
}, [widgetBackendUrl, widget.id, setChartState]);
|
|
45759
|
+
}, [widgetBackendUrl, widget.id, (_e = widget.config) == null ? void 0 : _e.agentName, setChartState]);
|
|
45812
45760
|
const handleLoadingTimeout = useCallback(async () => {
|
|
45813
45761
|
var _a2;
|
|
45814
45762
|
if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
|
|
@@ -45832,7 +45780,7 @@ function CopilotKitPieChart({
|
|
|
45832
45780
|
if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
|
|
45833
45781
|
parseAndUpdateChartState$3(apiResponse, setChartState);
|
|
45834
45782
|
}
|
|
45835
|
-
}, [widgetBackendUrl, widget.id, setChartState, (
|
|
45783
|
+
}, [widgetBackendUrl, widget.id, setChartState, (_f = widget.config) == null ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
|
|
45836
45784
|
const startLoadingTimeout = useCallback(() => {
|
|
45837
45785
|
if (timeoutRef.current) {
|
|
45838
45786
|
clearTimeout(timeoutRef.current);
|
|
@@ -45906,20 +45854,20 @@ function CopilotKitPieChart({
|
|
|
45906
45854
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Bot, { className: "h-4 w-4" }),
|
|
45907
45855
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
|
|
45908
45856
|
] }) }),
|
|
45909
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children:
|
|
45857
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((_i = (_h = (_g = chartState.pie_chart_data) == null ? void 0 : _g.data) == null ? void 0 : _h.labels) == null ? void 0 : _i.length) || !((_l = (_k = (_j = chartState.pie_chart_data) == null ? void 0 : _j.data) == null ? void 0 : _k.values) == null ? void 0 : _l.length)) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
45910
45858
|
PieChartComponent,
|
|
45911
45859
|
{
|
|
45912
45860
|
pieChartState: chartState,
|
|
45913
45861
|
styles,
|
|
45914
45862
|
appendMessage,
|
|
45915
45863
|
content,
|
|
45916
|
-
query: (
|
|
45864
|
+
query: (_m = widget.config) == null ? void 0 : _m.query,
|
|
45917
45865
|
isFirstLoad,
|
|
45918
45866
|
widgetBackendUrl,
|
|
45919
45867
|
widgetId: widget.id,
|
|
45920
45868
|
startLoadingTimeout,
|
|
45921
45869
|
clearLoadingTimeout,
|
|
45922
|
-
hasWidgetData: !!(((
|
|
45870
|
+
hasWidgetData: !!(((_o = (_n = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _n.labels) == null ? void 0 : _o.length) && ((_q = (_p = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _p.values) == null ? void 0 : _q.length))
|
|
45923
45871
|
}
|
|
45924
45872
|
) })
|
|
45925
45873
|
] });
|
|
@@ -46068,24 +46016,6 @@ const loadAgentState$2 = async (widgetBackendUrl, threadId, agentName) => {
|
|
|
46068
46016
|
return null;
|
|
46069
46017
|
}
|
|
46070
46018
|
};
|
|
46071
|
-
const loadSessionStateDirect$2 = async (widgetBackendUrl, sessionId) => {
|
|
46072
|
-
try {
|
|
46073
|
-
const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
|
|
46074
|
-
method: "GET",
|
|
46075
|
-
headers: {
|
|
46076
|
-
"Content-Type": "application/json"
|
|
46077
|
-
}
|
|
46078
|
-
});
|
|
46079
|
-
if (!response.ok) {
|
|
46080
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
46081
|
-
}
|
|
46082
|
-
const result = await response.json();
|
|
46083
|
-
return result;
|
|
46084
|
-
} catch (error) {
|
|
46085
|
-
console.error("Failed to load session state directly:", error);
|
|
46086
|
-
return null;
|
|
46087
|
-
}
|
|
46088
|
-
};
|
|
46089
46019
|
const parseAndUpdateChartState$2 = (apiResponse, setChartState) => {
|
|
46090
46020
|
var _a, _b;
|
|
46091
46021
|
try {
|
|
@@ -46220,7 +46150,7 @@ function CopilotKitSeriesBarChart$1({
|
|
|
46220
46150
|
datasetId,
|
|
46221
46151
|
widgetData
|
|
46222
46152
|
}) {
|
|
46223
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
46153
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
46224
46154
|
const orientation = ((_a = widget.config) == null ? void 0 : _a.orientation) || "vertical";
|
|
46225
46155
|
const isFirstLoad = (_b = widget.config) == null ? void 0 : _b.isFirstLoad;
|
|
46226
46156
|
const content = (_c = widget.config) == null ? void 0 : _c.content;
|
|
@@ -46238,19 +46168,19 @@ function CopilotKitSeriesBarChart$1({
|
|
|
46238
46168
|
initialState: createInitialChartState$2(datasetId, widget_data)
|
|
46239
46169
|
});
|
|
46240
46170
|
const [chartState, setChartState] = useState(createInitialChartState$2(datasetId, widget_data));
|
|
46241
|
-
const [isInitialFetchComplete, setIsInitialFetchComplete] = useState(false);
|
|
46242
46171
|
useEffect(() => {
|
|
46243
46172
|
const fetchInitialState = async () => {
|
|
46173
|
+
var _a2;
|
|
46244
46174
|
if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
|
|
46245
46175
|
hasInitialFetchRef.current = true;
|
|
46246
|
-
const
|
|
46176
|
+
const agentName = ((_a2 = widget.config) == null ? void 0 : _a2.agentName) || "adk-construction-project-agent";
|
|
46177
|
+
const apiResponse = await loadAgentState$2(widgetBackendUrl, widget.id, agentName);
|
|
46247
46178
|
if (apiResponse) {
|
|
46248
46179
|
parseAndUpdateChartState$2(apiResponse, setChartState);
|
|
46249
46180
|
}
|
|
46250
|
-
setIsInitialFetchComplete(true);
|
|
46251
46181
|
};
|
|
46252
46182
|
fetchInitialState();
|
|
46253
|
-
}, [widgetBackendUrl, widget.id, setChartState]);
|
|
46183
|
+
}, [widgetBackendUrl, widget.id, (_f = widget.config) == null ? void 0 : _f.agentName, setChartState]);
|
|
46254
46184
|
const handleLoadingTimeout = useCallback(async () => {
|
|
46255
46185
|
var _a2;
|
|
46256
46186
|
if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
|
|
@@ -46274,7 +46204,7 @@ function CopilotKitSeriesBarChart$1({
|
|
|
46274
46204
|
if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
|
|
46275
46205
|
parseAndUpdateChartState$2(apiResponse, setChartState);
|
|
46276
46206
|
}
|
|
46277
|
-
}, [widgetBackendUrl, widget.id, setChartState, (
|
|
46207
|
+
}, [widgetBackendUrl, widget.id, setChartState, (_g = widget.config) == null ? void 0 : _g.agentName, chartState, apiCallCount, hasTimeoutError]);
|
|
46278
46208
|
const startLoadingTimeout = useCallback(() => {
|
|
46279
46209
|
if (timeoutRef.current) {
|
|
46280
46210
|
clearTimeout(timeoutRef.current);
|
|
@@ -46348,7 +46278,7 @@ function CopilotKitSeriesBarChart$1({
|
|
|
46348
46278
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Bot, { className: "h-4 w-4" }),
|
|
46349
46279
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
|
|
46350
46280
|
] }) }),
|
|
46351
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children:
|
|
46281
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((_j = (_i = (_h = chartState.series_bar_chart_data) == null ? void 0 : _h.data) == null ? void 0 : _i.labels) == null ? void 0 : _j.length) || !((_m = (_l = (_k = chartState.series_bar_chart_data) == null ? void 0 : _k.data) == null ? void 0 : _l.series) == null ? void 0 : _m.length)) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
46352
46282
|
SeriesBarChartComponent$1,
|
|
46353
46283
|
{
|
|
46354
46284
|
orientation,
|
|
@@ -46356,13 +46286,13 @@ function CopilotKitSeriesBarChart$1({
|
|
|
46356
46286
|
styles,
|
|
46357
46287
|
appendMessage,
|
|
46358
46288
|
content,
|
|
46359
|
-
query: (
|
|
46289
|
+
query: (_n = widget.config) == null ? void 0 : _n.query,
|
|
46360
46290
|
isFirstLoad,
|
|
46361
46291
|
widgetBackendUrl,
|
|
46362
46292
|
widgetId: widget.id,
|
|
46363
46293
|
startLoadingTimeout,
|
|
46364
46294
|
clearLoadingTimeout,
|
|
46365
|
-
hasWidgetData: !!(((
|
|
46295
|
+
hasWidgetData: !!(((_p = (_o = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _o.labels) == null ? void 0 : _p.length) && ((_r = (_q = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _q.series) == null ? void 0 : _r.length))
|
|
46366
46296
|
}
|
|
46367
46297
|
) })
|
|
46368
46298
|
] });
|
|
@@ -46511,24 +46441,6 @@ const loadAgentState$1 = async (widgetBackendUrl, threadId, agentName) => {
|
|
|
46511
46441
|
return null;
|
|
46512
46442
|
}
|
|
46513
46443
|
};
|
|
46514
|
-
const loadSessionStateDirect$1 = async (widgetBackendUrl, sessionId) => {
|
|
46515
|
-
try {
|
|
46516
|
-
const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
|
|
46517
|
-
method: "GET",
|
|
46518
|
-
headers: {
|
|
46519
|
-
"Content-Type": "application/json"
|
|
46520
|
-
}
|
|
46521
|
-
});
|
|
46522
|
-
if (!response.ok) {
|
|
46523
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
46524
|
-
}
|
|
46525
|
-
const result = await response.json();
|
|
46526
|
-
return result;
|
|
46527
|
-
} catch (error) {
|
|
46528
|
-
console.error("Failed to load session state directly:", error);
|
|
46529
|
-
return null;
|
|
46530
|
-
}
|
|
46531
|
-
};
|
|
46532
46444
|
const parseAndUpdateChartState$1 = (apiResponse, setChartState) => {
|
|
46533
46445
|
var _a, _b;
|
|
46534
46446
|
try {
|
|
@@ -46663,7 +46575,7 @@ function CopilotKitSeriesBarChart({
|
|
|
46663
46575
|
datasetId,
|
|
46664
46576
|
widgetData
|
|
46665
46577
|
}) {
|
|
46666
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
46578
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
46667
46579
|
const orientation = ((_a = widget.config) == null ? void 0 : _a.orientation) || "vertical";
|
|
46668
46580
|
const isFirstLoad = (_b = widget.config) == null ? void 0 : _b.isFirstLoad;
|
|
46669
46581
|
const content = (_c = widget.config) == null ? void 0 : _c.content;
|
|
@@ -46681,19 +46593,19 @@ function CopilotKitSeriesBarChart({
|
|
|
46681
46593
|
initialState: createInitialChartState$1(datasetId, widget_data)
|
|
46682
46594
|
});
|
|
46683
46595
|
const [chartState, setChartState] = useState(createInitialChartState$1(datasetId, widget_data));
|
|
46684
|
-
const [isInitialFetchComplete, setIsInitialFetchComplete] = useState(false);
|
|
46685
46596
|
useEffect(() => {
|
|
46686
46597
|
const fetchInitialState = async () => {
|
|
46598
|
+
var _a2;
|
|
46687
46599
|
if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
|
|
46688
46600
|
hasInitialFetchRef.current = true;
|
|
46689
|
-
const
|
|
46601
|
+
const agentName = ((_a2 = widget.config) == null ? void 0 : _a2.agentName) || "adk-construction-project-agent";
|
|
46602
|
+
const apiResponse = await loadAgentState$1(widgetBackendUrl, widget.id, agentName);
|
|
46690
46603
|
if (apiResponse) {
|
|
46691
46604
|
parseAndUpdateChartState$1(apiResponse, setChartState);
|
|
46692
46605
|
}
|
|
46693
|
-
setIsInitialFetchComplete(true);
|
|
46694
46606
|
};
|
|
46695
46607
|
fetchInitialState();
|
|
46696
|
-
}, [widgetBackendUrl, widget.id, setChartState]);
|
|
46608
|
+
}, [widgetBackendUrl, widget.id, (_f = widget.config) == null ? void 0 : _f.agentName, setChartState]);
|
|
46697
46609
|
const handleLoadingTimeout = useCallback(async () => {
|
|
46698
46610
|
var _a2;
|
|
46699
46611
|
if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
|
|
@@ -46717,7 +46629,7 @@ function CopilotKitSeriesBarChart({
|
|
|
46717
46629
|
if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
|
|
46718
46630
|
parseAndUpdateChartState$1(apiResponse, setChartState);
|
|
46719
46631
|
}
|
|
46720
|
-
}, [widgetBackendUrl, widget.id, setChartState, (
|
|
46632
|
+
}, [widgetBackendUrl, widget.id, setChartState, (_g = widget.config) == null ? void 0 : _g.agentName, chartState, apiCallCount, hasTimeoutError]);
|
|
46721
46633
|
const startLoadingTimeout = useCallback(() => {
|
|
46722
46634
|
if (timeoutRef.current) {
|
|
46723
46635
|
clearTimeout(timeoutRef.current);
|
|
@@ -46791,7 +46703,7 @@ function CopilotKitSeriesBarChart({
|
|
|
46791
46703
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Bot, { className: "h-4 w-4" }),
|
|
46792
46704
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
|
|
46793
46705
|
] }) }),
|
|
46794
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children:
|
|
46706
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((_j = (_i = (_h = chartState.series_bar_chart_data) == null ? void 0 : _h.data) == null ? void 0 : _i.labels) == null ? void 0 : _j.length) || !((_m = (_l = (_k = chartState.series_bar_chart_data) == null ? void 0 : _k.data) == null ? void 0 : _l.series) == null ? void 0 : _m.length)) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
46795
46707
|
SeriesBarChartComponent,
|
|
46796
46708
|
{
|
|
46797
46709
|
orientation,
|
|
@@ -46799,13 +46711,13 @@ function CopilotKitSeriesBarChart({
|
|
|
46799
46711
|
styles,
|
|
46800
46712
|
appendMessage,
|
|
46801
46713
|
content,
|
|
46802
|
-
query: (
|
|
46714
|
+
query: (_n = widget.config) == null ? void 0 : _n.query,
|
|
46803
46715
|
isFirstLoad,
|
|
46804
46716
|
widgetBackendUrl,
|
|
46805
46717
|
widgetId: widget.id,
|
|
46806
46718
|
startLoadingTimeout,
|
|
46807
46719
|
clearLoadingTimeout,
|
|
46808
|
-
hasWidgetData: !!(((
|
|
46720
|
+
hasWidgetData: !!(((_p = (_o = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _o.labels) == null ? void 0 : _p.length) && ((_r = (_q = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _q.series) == null ? void 0 : _r.length))
|
|
46809
46721
|
}
|
|
46810
46722
|
) })
|
|
46811
46723
|
] });
|
|
@@ -46944,24 +46856,6 @@ const loadAgentState = async (widgetBackendUrl, threadId, agentName) => {
|
|
|
46944
46856
|
return null;
|
|
46945
46857
|
}
|
|
46946
46858
|
};
|
|
46947
|
-
const loadSessionStateDirect = async (widgetBackendUrl, sessionId) => {
|
|
46948
|
-
try {
|
|
46949
|
-
const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
|
|
46950
|
-
method: "GET",
|
|
46951
|
-
headers: {
|
|
46952
|
-
"Content-Type": "application/json"
|
|
46953
|
-
}
|
|
46954
|
-
});
|
|
46955
|
-
if (!response.ok) {
|
|
46956
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
46957
|
-
}
|
|
46958
|
-
const result = await response.json();
|
|
46959
|
-
return result;
|
|
46960
|
-
} catch (error) {
|
|
46961
|
-
console.error("Failed to load session state directly:", error);
|
|
46962
|
-
return null;
|
|
46963
|
-
}
|
|
46964
|
-
};
|
|
46965
46859
|
const parseAndUpdateChartState = (apiResponse, setChartState) => {
|
|
46966
46860
|
var _a, _b;
|
|
46967
46861
|
try {
|
|
@@ -47078,7 +46972,7 @@ function CopilotKitDataGrid({
|
|
|
47078
46972
|
datasetId,
|
|
47079
46973
|
widgetData
|
|
47080
46974
|
}) {
|
|
47081
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
46975
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
47082
46976
|
const isFirstLoad = (_a = widget.config) == null ? void 0 : _a.isFirstLoad;
|
|
47083
46977
|
const content = (_b = widget.config) == null ? void 0 : _b.content;
|
|
47084
46978
|
const widget_data = (_c = widget.widget_data) == null ? void 0 : _c.matrix_grid_data;
|
|
@@ -47095,19 +46989,19 @@ function CopilotKitDataGrid({
|
|
|
47095
46989
|
initialState: createInitialChartState(datasetId, widget_data)
|
|
47096
46990
|
});
|
|
47097
46991
|
const [chartState, setChartState] = useState(createInitialChartState(datasetId, widget_data));
|
|
47098
|
-
const [isInitialFetchComplete, setIsInitialFetchComplete] = useState(false);
|
|
47099
46992
|
useEffect(() => {
|
|
47100
46993
|
const fetchInitialState = async () => {
|
|
46994
|
+
var _a2;
|
|
47101
46995
|
if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
|
|
47102
46996
|
hasInitialFetchRef.current = true;
|
|
47103
|
-
const
|
|
46997
|
+
const agentName = ((_a2 = widget.config) == null ? void 0 : _a2.agentName) || "adk-construction-project-agent";
|
|
46998
|
+
const apiResponse = await loadAgentState(widgetBackendUrl, widget.id, agentName);
|
|
47104
46999
|
if (apiResponse) {
|
|
47105
47000
|
parseAndUpdateChartState(apiResponse, setChartState);
|
|
47106
47001
|
}
|
|
47107
|
-
setIsInitialFetchComplete(true);
|
|
47108
47002
|
};
|
|
47109
47003
|
fetchInitialState();
|
|
47110
|
-
}, [widgetBackendUrl, widget.id, setChartState]);
|
|
47004
|
+
}, [widgetBackendUrl, widget.id, (_e = widget.config) == null ? void 0 : _e.agentName, setChartState]);
|
|
47111
47005
|
const handleLoadingTimeout = useCallback(async () => {
|
|
47112
47006
|
var _a2;
|
|
47113
47007
|
if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
|
|
@@ -47131,7 +47025,7 @@ function CopilotKitDataGrid({
|
|
|
47131
47025
|
if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
|
|
47132
47026
|
parseAndUpdateChartState(apiResponse, setChartState);
|
|
47133
47027
|
}
|
|
47134
|
-
}, [widgetBackendUrl, widget.id, setChartState, (
|
|
47028
|
+
}, [widgetBackendUrl, widget.id, setChartState, (_f = widget.config) == null ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
|
|
47135
47029
|
const startLoadingTimeout = useCallback(() => {
|
|
47136
47030
|
if (timeoutRef.current) {
|
|
47137
47031
|
clearTimeout(timeoutRef.current);
|
|
@@ -47205,20 +47099,20 @@ function CopilotKitDataGrid({
|
|
|
47205
47099
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Bot, { className: "h-4 w-4" }),
|
|
47206
47100
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
|
|
47207
47101
|
] }) }),
|
|
47208
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children:
|
|
47102
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((_i = (_h = (_g = chartState.matrix_grid_data) == null ? void 0 : _g.data) == null ? void 0 : _h.headers) == null ? void 0 : _i.length) || !((_l = (_k = (_j = chartState.matrix_grid_data) == null ? void 0 : _j.data) == null ? void 0 : _k.rows) == null ? void 0 : _l.length)) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
47209
47103
|
DataGridComponent,
|
|
47210
47104
|
{
|
|
47211
47105
|
dataGridState: chartState,
|
|
47212
47106
|
styles,
|
|
47213
47107
|
appendMessage,
|
|
47214
47108
|
content,
|
|
47215
|
-
query: (
|
|
47109
|
+
query: (_m = widget.config) == null ? void 0 : _m.query,
|
|
47216
47110
|
isFirstLoad,
|
|
47217
47111
|
widgetBackendUrl,
|
|
47218
47112
|
widgetId: widget.id,
|
|
47219
47113
|
startLoadingTimeout,
|
|
47220
47114
|
clearLoadingTimeout,
|
|
47221
|
-
hasWidgetData: !!(((
|
|
47115
|
+
hasWidgetData: !!(((_o = (_n = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _n.headers) == null ? void 0 : _o.length) && ((_q = (_p = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _p.rows) == null ? void 0 : _q.length))
|
|
47222
47116
|
}
|
|
47223
47117
|
) })
|
|
47224
47118
|
] });
|
package/dist/index.js
CHANGED
|
@@ -43634,24 +43634,6 @@ const loadAgentState$5 = async (widgetBackendUrl, threadId, agentName) => {
|
|
|
43634
43634
|
return null;
|
|
43635
43635
|
}
|
|
43636
43636
|
};
|
|
43637
|
-
const loadSessionStateDirect$5 = async (widgetBackendUrl, sessionId) => {
|
|
43638
|
-
try {
|
|
43639
|
-
const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
|
|
43640
|
-
method: "GET",
|
|
43641
|
-
headers: {
|
|
43642
|
-
"Content-Type": "application/json"
|
|
43643
|
-
}
|
|
43644
|
-
});
|
|
43645
|
-
if (!response.ok) {
|
|
43646
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
43647
|
-
}
|
|
43648
|
-
const result = await response.json();
|
|
43649
|
-
return result;
|
|
43650
|
-
} catch (error) {
|
|
43651
|
-
console.error("Failed to load session state directly:", error);
|
|
43652
|
-
return null;
|
|
43653
|
-
}
|
|
43654
|
-
};
|
|
43655
43637
|
const parseAndUpdateChartState$4 = (apiResponse, setChartState) => {
|
|
43656
43638
|
var _a, _b;
|
|
43657
43639
|
try {
|
|
@@ -44176,7 +44158,7 @@ function CopilotKitAgent({
|
|
|
44176
44158
|
datasetId,
|
|
44177
44159
|
widgetData
|
|
44178
44160
|
}) {
|
|
44179
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _
|
|
44161
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa;
|
|
44180
44162
|
const agentType = (_a = widget.config) == null ? void 0 : _a.agentType;
|
|
44181
44163
|
const orientation = (_b = widget.config) == null ? void 0 : _b.orientation;
|
|
44182
44164
|
const isFirstLoad = (_c = widget.config) == null ? void 0 : _c.isFirstLoad;
|
|
@@ -44187,7 +44169,6 @@ function CopilotKitAgent({
|
|
|
44187
44169
|
const [apiCallCount, setApiCallCount] = React.useState(0);
|
|
44188
44170
|
const [hasTimeoutError, setHasTimeoutError] = React.useState(false);
|
|
44189
44171
|
const hasInitialFetchRef = React.useRef(false);
|
|
44190
|
-
const [isInitialFetchComplete, setIsInitialFetchComplete] = React.useState(false);
|
|
44191
44172
|
React.useEffect(() => {
|
|
44192
44173
|
setThreadId(widget.id);
|
|
44193
44174
|
}, [widget.id, setThreadId]);
|
|
@@ -44197,16 +44178,17 @@ function CopilotKitAgent({
|
|
|
44197
44178
|
});
|
|
44198
44179
|
React.useEffect(() => {
|
|
44199
44180
|
const fetchInitialState = async () => {
|
|
44181
|
+
var _a2;
|
|
44200
44182
|
if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
|
|
44201
44183
|
hasInitialFetchRef.current = true;
|
|
44202
|
-
const
|
|
44184
|
+
const agentName = ((_a2 = widget.config) == null ? void 0 : _a2.agentName) || "adk-construction-project-agent";
|
|
44185
|
+
const apiResponse = await loadAgentState$5(widgetBackendUrl, widget.id, agentName);
|
|
44203
44186
|
if (apiResponse) {
|
|
44204
44187
|
parseAndUpdateChartState$4(apiResponse, setChartState);
|
|
44205
44188
|
}
|
|
44206
|
-
setIsInitialFetchComplete(true);
|
|
44207
44189
|
};
|
|
44208
44190
|
fetchInitialState();
|
|
44209
|
-
}, [widgetBackendUrl, widget.id, setChartState]);
|
|
44191
|
+
}, [widgetBackendUrl, widget.id, (_f = widget.config) == null ? void 0 : _f.agentName, setChartState]);
|
|
44210
44192
|
const handleLoadingTimeout = React.useCallback(async () => {
|
|
44211
44193
|
var _a2;
|
|
44212
44194
|
if (!widgetBackendUrl || !widget.id || isTimeoutTriggered || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) return;
|
|
@@ -44226,7 +44208,7 @@ function CopilotKitAgent({
|
|
|
44226
44208
|
if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
|
|
44227
44209
|
parseAndUpdateChartState$4(apiResponse, setChartState);
|
|
44228
44210
|
}
|
|
44229
|
-
}, [widgetBackendUrl, widget.id, isTimeoutTriggered, setChartState, (
|
|
44211
|
+
}, [widgetBackendUrl, widget.id, isTimeoutTriggered, setChartState, (_g = widget.config) == null ? void 0 : _g.agentName, chartState, apiCallCount, hasTimeoutError]);
|
|
44230
44212
|
const startLoadingTimeout = React.useCallback(() => {
|
|
44231
44213
|
if (timeoutRef.current) {
|
|
44232
44214
|
clearTimeout(timeoutRef.current);
|
|
@@ -44309,8 +44291,8 @@ function CopilotKitAgent({
|
|
|
44309
44291
|
/* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.Bot, { className: "h-4 w-4" }),
|
|
44310
44292
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
|
|
44311
44293
|
] }) }),
|
|
44312
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children:
|
|
44313
|
-
(agentType === "Bar Chart Agent" && (!((
|
|
44294
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && agentType !== "chatbot" && // Check if data is empty based on agent type
|
|
44295
|
+
(agentType === "Bar Chart Agent" && (!((_j = (_i = (_h = chartState.bar_chart_data) == null ? void 0 : _h.data) == null ? void 0 : _i.labels) == null ? void 0 : _j.length) || !((_m = (_l = (_k = chartState.bar_chart_data) == null ? void 0 : _k.data) == null ? void 0 : _l.values) == null ? void 0 : _m.length)) || agentType === "Series Bar Chart Agent" && (!((_p = (_o = (_n = chartState.series_bar_chart_data) == null ? void 0 : _n.data) == null ? void 0 : _o.labels) == null ? void 0 : _p.length) || !((_s = (_r = (_q = chartState.series_bar_chart_data) == null ? void 0 : _q.data) == null ? void 0 : _r.series) == null ? void 0 : _s.length)) || agentType === "Series Line Chart Agent" && (!((_v = (_u = (_t = chartState.series_bar_chart_data) == null ? void 0 : _t.data) == null ? void 0 : _u.labels) == null ? void 0 : _v.length) || !((_y = (_x = (_w = chartState.series_bar_chart_data) == null ? void 0 : _w.data) == null ? void 0 : _x.series) == null ? void 0 : _y.length)) || agentType === "Pie Chart Agent" && (!((_B = (_A = (_z = chartState.pie_chart_data) == null ? void 0 : _z.data) == null ? void 0 : _A.labels) == null ? void 0 : _B.length) || !((_E = (_D = (_C = chartState.pie_chart_data) == null ? void 0 : _C.data) == null ? void 0 : _D.values) == null ? void 0 : _E.length)) || agentType === "Line Chart Agent" && (!((_H = (_G = (_F = chartState.bar_chart_data) == null ? void 0 : _F.data) == null ? void 0 : _G.labels) == null ? void 0 : _H.length) || !((_K = (_J = (_I = chartState.bar_chart_data) == null ? void 0 : _I.data) == null ? void 0 : _J.values) == null ? void 0 : _K.length)) || agentType === "Data Grid Agent" && (!((_N = (_M = (_L = chartState.matrix_grid_data) == null ? void 0 : _L.data) == null ? void 0 : _M.headers) == null ? void 0 : _N.length) || !((_Q = (_P = (_O = chartState.matrix_grid_data) == null ? void 0 : _O.data) == null ? void 0 : _P.rows) == null ? void 0 : _Q.length)) || agentType === "Summary Agent" && (!((_S = (_R = chartState.summary_data) == null ? void 0 : _R.data) == null ? void 0 : _S.content) || ((_V = (_U = (_T = chartState.summary_data) == null ? void 0 : _T.data) == null ? void 0 : _U.content) == null ? void 0 : _V.trim()) === "")) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : agentType === "Bar Chart Agent" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
44314
44296
|
BarChartComponent,
|
|
44315
44297
|
{
|
|
44316
44298
|
barChartState: chartState,
|
|
@@ -44318,7 +44300,7 @@ function CopilotKitAgent({
|
|
|
44318
44300
|
orientation,
|
|
44319
44301
|
content,
|
|
44320
44302
|
appendMessage,
|
|
44321
|
-
query: (
|
|
44303
|
+
query: (_W = widget.config) == null ? void 0 : _W.query,
|
|
44322
44304
|
isFirstLoad,
|
|
44323
44305
|
widgetBackendUrl,
|
|
44324
44306
|
widgetId: widget.id,
|
|
@@ -44333,7 +44315,7 @@ function CopilotKitAgent({
|
|
|
44333
44315
|
orientation,
|
|
44334
44316
|
content,
|
|
44335
44317
|
appendMessage,
|
|
44336
|
-
query: (
|
|
44318
|
+
query: (_X = widget.config) == null ? void 0 : _X.query,
|
|
44337
44319
|
isFirstLoad,
|
|
44338
44320
|
widgetBackendUrl,
|
|
44339
44321
|
widgetId: widget.id,
|
|
@@ -44348,7 +44330,7 @@ function CopilotKitAgent({
|
|
|
44348
44330
|
orientation,
|
|
44349
44331
|
content,
|
|
44350
44332
|
appendMessage,
|
|
44351
|
-
query: (
|
|
44333
|
+
query: (_Y = widget.config) == null ? void 0 : _Y.query,
|
|
44352
44334
|
isFirstLoad,
|
|
44353
44335
|
widgetBackendUrl,
|
|
44354
44336
|
widgetId: widget.id,
|
|
@@ -44362,7 +44344,7 @@ function CopilotKitAgent({
|
|
|
44362
44344
|
styles,
|
|
44363
44345
|
appendMessage,
|
|
44364
44346
|
content,
|
|
44365
|
-
query: (
|
|
44347
|
+
query: (_Z = widget.config) == null ? void 0 : _Z.query,
|
|
44366
44348
|
isFirstLoad,
|
|
44367
44349
|
widgetBackendUrl,
|
|
44368
44350
|
widgetId: widget.id,
|
|
@@ -44376,7 +44358,7 @@ function CopilotKitAgent({
|
|
|
44376
44358
|
styles,
|
|
44377
44359
|
appendMessage,
|
|
44378
44360
|
content,
|
|
44379
|
-
query: (
|
|
44361
|
+
query: (__ = widget.config) == null ? void 0 : __.query,
|
|
44380
44362
|
isFirstLoad,
|
|
44381
44363
|
widgetBackendUrl,
|
|
44382
44364
|
widgetId: widget.id,
|
|
@@ -44389,7 +44371,7 @@ function CopilotKitAgent({
|
|
|
44389
44371
|
dataGridState: chartState,
|
|
44390
44372
|
styles,
|
|
44391
44373
|
appendMessage,
|
|
44392
|
-
query: (
|
|
44374
|
+
query: (_$ = widget.config) == null ? void 0 : _$.query,
|
|
44393
44375
|
isFirstLoad,
|
|
44394
44376
|
widgetBackendUrl,
|
|
44395
44377
|
widgetId: widget.id,
|
|
@@ -44402,7 +44384,7 @@ function CopilotKitAgent({
|
|
|
44402
44384
|
summaryState: chartState,
|
|
44403
44385
|
styles,
|
|
44404
44386
|
appendMessage,
|
|
44405
|
-
query: (
|
|
44387
|
+
query: (_aa = widget.config) == null ? void 0 : _aa.query,
|
|
44406
44388
|
isFirstLoad,
|
|
44407
44389
|
widgetBackendUrl,
|
|
44408
44390
|
widgetId: widget.id,
|
|
@@ -44833,24 +44815,6 @@ const loadAgentState$4 = async (widgetBackendUrl, threadId, agentName) => {
|
|
|
44833
44815
|
return null;
|
|
44834
44816
|
}
|
|
44835
44817
|
};
|
|
44836
|
-
const loadSessionStateDirect$4 = async (widgetBackendUrl, sessionId) => {
|
|
44837
|
-
try {
|
|
44838
|
-
const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
|
|
44839
|
-
method: "GET",
|
|
44840
|
-
headers: {
|
|
44841
|
-
"Content-Type": "application/json"
|
|
44842
|
-
}
|
|
44843
|
-
});
|
|
44844
|
-
if (!response.ok) {
|
|
44845
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
44846
|
-
}
|
|
44847
|
-
const result = await response.json();
|
|
44848
|
-
return result;
|
|
44849
|
-
} catch (error) {
|
|
44850
|
-
console.error("Failed to load session state directly:", error);
|
|
44851
|
-
return null;
|
|
44852
|
-
}
|
|
44853
|
-
};
|
|
44854
44818
|
const parseAndUpdateFilterState = (apiResponse, setFilterState) => {
|
|
44855
44819
|
var _a, _b;
|
|
44856
44820
|
try {
|
|
@@ -45307,7 +45271,7 @@ function CopilotKitFilters({
|
|
|
45307
45271
|
onApplyFilters,
|
|
45308
45272
|
isEditing = false
|
|
45309
45273
|
}) {
|
|
45310
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
45274
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
45311
45275
|
const isFirstLoad = (_a = widget.config) == null ? void 0 : _a.isFirstLoad;
|
|
45312
45276
|
const widget_data = (_b = widget.widget_data) == null ? void 0 : _b.column_values;
|
|
45313
45277
|
const { setThreadId } = reactCore.useCopilotContext();
|
|
@@ -45325,15 +45289,17 @@ function CopilotKitFilters({
|
|
|
45325
45289
|
const [filterState, setFilterState] = React.useState(createInitialFilterState(datasetId, widget_data));
|
|
45326
45290
|
React.useEffect(() => {
|
|
45327
45291
|
const fetchInitialState = async () => {
|
|
45292
|
+
var _a2;
|
|
45328
45293
|
if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
|
|
45329
45294
|
hasInitialFetchRef.current = true;
|
|
45330
|
-
const
|
|
45295
|
+
const agentName = ((_a2 = widget.config) == null ? void 0 : _a2.agentName) || "adk-construction-project-agent";
|
|
45296
|
+
const apiResponse = await loadAgentState$4(widgetBackendUrl, widget.id, agentName);
|
|
45331
45297
|
if (apiResponse) {
|
|
45332
45298
|
parseAndUpdateFilterState(apiResponse, setFilterState);
|
|
45333
45299
|
}
|
|
45334
45300
|
};
|
|
45335
45301
|
fetchInitialState();
|
|
45336
|
-
}, [widgetBackendUrl, widget.id, setFilterState]);
|
|
45302
|
+
}, [widgetBackendUrl, widget.id, (_d = widget.config) == null ? void 0 : _d.agentName, setFilterState]);
|
|
45337
45303
|
const handleLoadingTimeout = React.useCallback(async () => {
|
|
45338
45304
|
var _a2;
|
|
45339
45305
|
if (!widgetBackendUrl || !widget.id || (filterState == null ? void 0 : filterState.agent_message) || hasTimeoutError) {
|
|
@@ -45357,7 +45323,7 @@ function CopilotKitFilters({
|
|
|
45357
45323
|
if (apiResponse && !(filterState == null ? void 0 : filterState.agent_message)) {
|
|
45358
45324
|
parseAndUpdateFilterState(apiResponse, setFilterState);
|
|
45359
45325
|
}
|
|
45360
|
-
}, [widgetBackendUrl, widget.id, setFilterState, (
|
|
45326
|
+
}, [widgetBackendUrl, widget.id, setFilterState, (_e = widget.config) == null ? void 0 : _e.agentName, filterState, apiCallCount, hasTimeoutError]);
|
|
45361
45327
|
const startLoadingTimeout = React.useCallback(() => {
|
|
45362
45328
|
if (timeoutRef.current) {
|
|
45363
45329
|
clearTimeout(timeoutRef.current);
|
|
@@ -45483,7 +45449,7 @@ function CopilotKitFilters({
|
|
|
45483
45449
|
setHasTimeoutError(false);
|
|
45484
45450
|
console.log("[FiltersWidget] Starting polling after confirmation");
|
|
45485
45451
|
startLoadingTimeout();
|
|
45486
|
-
}, [filterState.filter_columns, filterState.ambiguous_columns, (
|
|
45452
|
+
}, [filterState.filter_columns, filterState.ambiguous_columns, (_f = widget.config) == null ? void 0 : _f.query, datasetId, appendMessage, setFilterState, setAgentState, startLoadingTimeout, setApiCallCount, setHasTimeoutError]);
|
|
45487
45453
|
const handleCancelConfirmation = React.useCallback(() => {
|
|
45488
45454
|
setFilterState((prev) => __spreadProps$7(__spreadValues$9({}, prev), {
|
|
45489
45455
|
status: void 0,
|
|
@@ -45496,7 +45462,7 @@ function CopilotKitFilters({
|
|
|
45496
45462
|
console.log("[CopilotKitFilters] Filter state check:", {
|
|
45497
45463
|
status: filterState.status,
|
|
45498
45464
|
hasAmbiguousColumns: !!filterState.ambiguous_columns,
|
|
45499
|
-
ambiguousColumnsLength: ((
|
|
45465
|
+
ambiguousColumnsLength: ((_g = filterState.ambiguous_columns) == null ? void 0 : _g.length) || 0,
|
|
45500
45466
|
isWaitingForConfirmation,
|
|
45501
45467
|
fullFilterState: filterState
|
|
45502
45468
|
});
|
|
@@ -45512,7 +45478,7 @@ function CopilotKitFilters({
|
|
|
45512
45478
|
onCancel: handleCancelConfirmation
|
|
45513
45479
|
}
|
|
45514
45480
|
)
|
|
45515
|
-
) : (filterState == null ? void 0 : filterState.agent_message) && !((
|
|
45481
|
+
) : (filterState == null ? void 0 : filterState.agent_message) && !((_h = filterState.column_values) == null ? void 0 : _h.length) && filterState.status !== "waiting_for_confirmation" ? (
|
|
45516
45482
|
// Show agent message (errors, warnings, etc.)
|
|
45517
45483
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700 whitespace-pre-line", children: filterState.agent_message }) }) })
|
|
45518
45484
|
) : (
|
|
@@ -45525,7 +45491,7 @@ function CopilotKitFilters({
|
|
|
45525
45491
|
onFilterChange,
|
|
45526
45492
|
widget,
|
|
45527
45493
|
appendMessage,
|
|
45528
|
-
query: (
|
|
45494
|
+
query: (_i = widget.config) == null ? void 0 : _i.query,
|
|
45529
45495
|
isFirstLoad,
|
|
45530
45496
|
widgetBackendUrl,
|
|
45531
45497
|
widgetId: widget.id,
|
|
@@ -45664,24 +45630,6 @@ const loadAgentState$3 = async (widgetBackendUrl, threadId, agentName) => {
|
|
|
45664
45630
|
return null;
|
|
45665
45631
|
}
|
|
45666
45632
|
};
|
|
45667
|
-
const loadSessionStateDirect$3 = async (widgetBackendUrl, sessionId) => {
|
|
45668
|
-
try {
|
|
45669
|
-
const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
|
|
45670
|
-
method: "GET",
|
|
45671
|
-
headers: {
|
|
45672
|
-
"Content-Type": "application/json"
|
|
45673
|
-
}
|
|
45674
|
-
});
|
|
45675
|
-
if (!response.ok) {
|
|
45676
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
45677
|
-
}
|
|
45678
|
-
const result = await response.json();
|
|
45679
|
-
return result;
|
|
45680
|
-
} catch (error) {
|
|
45681
|
-
console.error("Failed to load session state directly:", error);
|
|
45682
|
-
return null;
|
|
45683
|
-
}
|
|
45684
|
-
};
|
|
45685
45633
|
const parseAndUpdateChartState$3 = (apiResponse, setChartState) => {
|
|
45686
45634
|
var _a, _b;
|
|
45687
45635
|
try {
|
|
@@ -45807,7 +45755,7 @@ function CopilotKitPieChart({
|
|
|
45807
45755
|
datasetId,
|
|
45808
45756
|
widgetData
|
|
45809
45757
|
}) {
|
|
45810
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
45758
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
45811
45759
|
const isFirstLoad = (_a = widget.config) == null ? void 0 : _a.isFirstLoad;
|
|
45812
45760
|
const content = (_b = widget.config) == null ? void 0 : _b.content;
|
|
45813
45761
|
const widget_data = (_c = widget.widget_data) == null ? void 0 : _c.pie_chart_data;
|
|
@@ -45824,19 +45772,19 @@ function CopilotKitPieChart({
|
|
|
45824
45772
|
initialState: createInitialChartState$3(datasetId, widget_data)
|
|
45825
45773
|
});
|
|
45826
45774
|
const [chartState, setChartState] = React.useState(createInitialChartState$3(datasetId, widget_data));
|
|
45827
|
-
const [isInitialFetchComplete, setIsInitialFetchComplete] = React.useState(false);
|
|
45828
45775
|
React.useEffect(() => {
|
|
45829
45776
|
const fetchInitialState = async () => {
|
|
45777
|
+
var _a2;
|
|
45830
45778
|
if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
|
|
45831
45779
|
hasInitialFetchRef.current = true;
|
|
45832
|
-
const
|
|
45780
|
+
const agentName = ((_a2 = widget.config) == null ? void 0 : _a2.agentName) || "adk-construction-project-agent";
|
|
45781
|
+
const apiResponse = await loadAgentState$3(widgetBackendUrl, widget.id, agentName);
|
|
45833
45782
|
if (apiResponse) {
|
|
45834
45783
|
parseAndUpdateChartState$3(apiResponse, setChartState);
|
|
45835
45784
|
}
|
|
45836
|
-
setIsInitialFetchComplete(true);
|
|
45837
45785
|
};
|
|
45838
45786
|
fetchInitialState();
|
|
45839
|
-
}, [widgetBackendUrl, widget.id, setChartState]);
|
|
45787
|
+
}, [widgetBackendUrl, widget.id, (_e = widget.config) == null ? void 0 : _e.agentName, setChartState]);
|
|
45840
45788
|
const handleLoadingTimeout = React.useCallback(async () => {
|
|
45841
45789
|
var _a2;
|
|
45842
45790
|
if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
|
|
@@ -45860,7 +45808,7 @@ function CopilotKitPieChart({
|
|
|
45860
45808
|
if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
|
|
45861
45809
|
parseAndUpdateChartState$3(apiResponse, setChartState);
|
|
45862
45810
|
}
|
|
45863
|
-
}, [widgetBackendUrl, widget.id, setChartState, (
|
|
45811
|
+
}, [widgetBackendUrl, widget.id, setChartState, (_f = widget.config) == null ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
|
|
45864
45812
|
const startLoadingTimeout = React.useCallback(() => {
|
|
45865
45813
|
if (timeoutRef.current) {
|
|
45866
45814
|
clearTimeout(timeoutRef.current);
|
|
@@ -45934,20 +45882,20 @@ function CopilotKitPieChart({
|
|
|
45934
45882
|
/* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.Bot, { className: "h-4 w-4" }),
|
|
45935
45883
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
|
|
45936
45884
|
] }) }),
|
|
45937
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children:
|
|
45885
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((_i = (_h = (_g = chartState.pie_chart_data) == null ? void 0 : _g.data) == null ? void 0 : _h.labels) == null ? void 0 : _i.length) || !((_l = (_k = (_j = chartState.pie_chart_data) == null ? void 0 : _j.data) == null ? void 0 : _k.values) == null ? void 0 : _l.length)) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
45938
45886
|
PieChartComponent,
|
|
45939
45887
|
{
|
|
45940
45888
|
pieChartState: chartState,
|
|
45941
45889
|
styles,
|
|
45942
45890
|
appendMessage,
|
|
45943
45891
|
content,
|
|
45944
|
-
query: (
|
|
45892
|
+
query: (_m = widget.config) == null ? void 0 : _m.query,
|
|
45945
45893
|
isFirstLoad,
|
|
45946
45894
|
widgetBackendUrl,
|
|
45947
45895
|
widgetId: widget.id,
|
|
45948
45896
|
startLoadingTimeout,
|
|
45949
45897
|
clearLoadingTimeout,
|
|
45950
|
-
hasWidgetData: !!(((
|
|
45898
|
+
hasWidgetData: !!(((_o = (_n = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _n.labels) == null ? void 0 : _o.length) && ((_q = (_p = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _p.values) == null ? void 0 : _q.length))
|
|
45951
45899
|
}
|
|
45952
45900
|
) })
|
|
45953
45901
|
] });
|
|
@@ -46096,24 +46044,6 @@ const loadAgentState$2 = async (widgetBackendUrl, threadId, agentName) => {
|
|
|
46096
46044
|
return null;
|
|
46097
46045
|
}
|
|
46098
46046
|
};
|
|
46099
|
-
const loadSessionStateDirect$2 = async (widgetBackendUrl, sessionId) => {
|
|
46100
|
-
try {
|
|
46101
|
-
const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
|
|
46102
|
-
method: "GET",
|
|
46103
|
-
headers: {
|
|
46104
|
-
"Content-Type": "application/json"
|
|
46105
|
-
}
|
|
46106
|
-
});
|
|
46107
|
-
if (!response.ok) {
|
|
46108
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
46109
|
-
}
|
|
46110
|
-
const result = await response.json();
|
|
46111
|
-
return result;
|
|
46112
|
-
} catch (error) {
|
|
46113
|
-
console.error("Failed to load session state directly:", error);
|
|
46114
|
-
return null;
|
|
46115
|
-
}
|
|
46116
|
-
};
|
|
46117
46047
|
const parseAndUpdateChartState$2 = (apiResponse, setChartState) => {
|
|
46118
46048
|
var _a, _b;
|
|
46119
46049
|
try {
|
|
@@ -46248,7 +46178,7 @@ function CopilotKitSeriesBarChart$1({
|
|
|
46248
46178
|
datasetId,
|
|
46249
46179
|
widgetData
|
|
46250
46180
|
}) {
|
|
46251
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
46181
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
46252
46182
|
const orientation = ((_a = widget.config) == null ? void 0 : _a.orientation) || "vertical";
|
|
46253
46183
|
const isFirstLoad = (_b = widget.config) == null ? void 0 : _b.isFirstLoad;
|
|
46254
46184
|
const content = (_c = widget.config) == null ? void 0 : _c.content;
|
|
@@ -46266,19 +46196,19 @@ function CopilotKitSeriesBarChart$1({
|
|
|
46266
46196
|
initialState: createInitialChartState$2(datasetId, widget_data)
|
|
46267
46197
|
});
|
|
46268
46198
|
const [chartState, setChartState] = React.useState(createInitialChartState$2(datasetId, widget_data));
|
|
46269
|
-
const [isInitialFetchComplete, setIsInitialFetchComplete] = React.useState(false);
|
|
46270
46199
|
React.useEffect(() => {
|
|
46271
46200
|
const fetchInitialState = async () => {
|
|
46201
|
+
var _a2;
|
|
46272
46202
|
if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
|
|
46273
46203
|
hasInitialFetchRef.current = true;
|
|
46274
|
-
const
|
|
46204
|
+
const agentName = ((_a2 = widget.config) == null ? void 0 : _a2.agentName) || "adk-construction-project-agent";
|
|
46205
|
+
const apiResponse = await loadAgentState$2(widgetBackendUrl, widget.id, agentName);
|
|
46275
46206
|
if (apiResponse) {
|
|
46276
46207
|
parseAndUpdateChartState$2(apiResponse, setChartState);
|
|
46277
46208
|
}
|
|
46278
|
-
setIsInitialFetchComplete(true);
|
|
46279
46209
|
};
|
|
46280
46210
|
fetchInitialState();
|
|
46281
|
-
}, [widgetBackendUrl, widget.id, setChartState]);
|
|
46211
|
+
}, [widgetBackendUrl, widget.id, (_f = widget.config) == null ? void 0 : _f.agentName, setChartState]);
|
|
46282
46212
|
const handleLoadingTimeout = React.useCallback(async () => {
|
|
46283
46213
|
var _a2;
|
|
46284
46214
|
if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
|
|
@@ -46302,7 +46232,7 @@ function CopilotKitSeriesBarChart$1({
|
|
|
46302
46232
|
if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
|
|
46303
46233
|
parseAndUpdateChartState$2(apiResponse, setChartState);
|
|
46304
46234
|
}
|
|
46305
|
-
}, [widgetBackendUrl, widget.id, setChartState, (
|
|
46235
|
+
}, [widgetBackendUrl, widget.id, setChartState, (_g = widget.config) == null ? void 0 : _g.agentName, chartState, apiCallCount, hasTimeoutError]);
|
|
46306
46236
|
const startLoadingTimeout = React.useCallback(() => {
|
|
46307
46237
|
if (timeoutRef.current) {
|
|
46308
46238
|
clearTimeout(timeoutRef.current);
|
|
@@ -46376,7 +46306,7 @@ function CopilotKitSeriesBarChart$1({
|
|
|
46376
46306
|
/* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.Bot, { className: "h-4 w-4" }),
|
|
46377
46307
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
|
|
46378
46308
|
] }) }),
|
|
46379
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children:
|
|
46309
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((_j = (_i = (_h = chartState.series_bar_chart_data) == null ? void 0 : _h.data) == null ? void 0 : _i.labels) == null ? void 0 : _j.length) || !((_m = (_l = (_k = chartState.series_bar_chart_data) == null ? void 0 : _k.data) == null ? void 0 : _l.series) == null ? void 0 : _m.length)) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
46380
46310
|
SeriesBarChartComponent$1,
|
|
46381
46311
|
{
|
|
46382
46312
|
orientation,
|
|
@@ -46384,13 +46314,13 @@ function CopilotKitSeriesBarChart$1({
|
|
|
46384
46314
|
styles,
|
|
46385
46315
|
appendMessage,
|
|
46386
46316
|
content,
|
|
46387
|
-
query: (
|
|
46317
|
+
query: (_n = widget.config) == null ? void 0 : _n.query,
|
|
46388
46318
|
isFirstLoad,
|
|
46389
46319
|
widgetBackendUrl,
|
|
46390
46320
|
widgetId: widget.id,
|
|
46391
46321
|
startLoadingTimeout,
|
|
46392
46322
|
clearLoadingTimeout,
|
|
46393
|
-
hasWidgetData: !!(((
|
|
46323
|
+
hasWidgetData: !!(((_p = (_o = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _o.labels) == null ? void 0 : _p.length) && ((_r = (_q = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _q.series) == null ? void 0 : _r.length))
|
|
46394
46324
|
}
|
|
46395
46325
|
) })
|
|
46396
46326
|
] });
|
|
@@ -46539,24 +46469,6 @@ const loadAgentState$1 = async (widgetBackendUrl, threadId, agentName) => {
|
|
|
46539
46469
|
return null;
|
|
46540
46470
|
}
|
|
46541
46471
|
};
|
|
46542
|
-
const loadSessionStateDirect$1 = async (widgetBackendUrl, sessionId) => {
|
|
46543
|
-
try {
|
|
46544
|
-
const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
|
|
46545
|
-
method: "GET",
|
|
46546
|
-
headers: {
|
|
46547
|
-
"Content-Type": "application/json"
|
|
46548
|
-
}
|
|
46549
|
-
});
|
|
46550
|
-
if (!response.ok) {
|
|
46551
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
46552
|
-
}
|
|
46553
|
-
const result = await response.json();
|
|
46554
|
-
return result;
|
|
46555
|
-
} catch (error) {
|
|
46556
|
-
console.error("Failed to load session state directly:", error);
|
|
46557
|
-
return null;
|
|
46558
|
-
}
|
|
46559
|
-
};
|
|
46560
46472
|
const parseAndUpdateChartState$1 = (apiResponse, setChartState) => {
|
|
46561
46473
|
var _a, _b;
|
|
46562
46474
|
try {
|
|
@@ -46691,7 +46603,7 @@ function CopilotKitSeriesBarChart({
|
|
|
46691
46603
|
datasetId,
|
|
46692
46604
|
widgetData
|
|
46693
46605
|
}) {
|
|
46694
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
46606
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
46695
46607
|
const orientation = ((_a = widget.config) == null ? void 0 : _a.orientation) || "vertical";
|
|
46696
46608
|
const isFirstLoad = (_b = widget.config) == null ? void 0 : _b.isFirstLoad;
|
|
46697
46609
|
const content = (_c = widget.config) == null ? void 0 : _c.content;
|
|
@@ -46709,19 +46621,19 @@ function CopilotKitSeriesBarChart({
|
|
|
46709
46621
|
initialState: createInitialChartState$1(datasetId, widget_data)
|
|
46710
46622
|
});
|
|
46711
46623
|
const [chartState, setChartState] = React.useState(createInitialChartState$1(datasetId, widget_data));
|
|
46712
|
-
const [isInitialFetchComplete, setIsInitialFetchComplete] = React.useState(false);
|
|
46713
46624
|
React.useEffect(() => {
|
|
46714
46625
|
const fetchInitialState = async () => {
|
|
46626
|
+
var _a2;
|
|
46715
46627
|
if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
|
|
46716
46628
|
hasInitialFetchRef.current = true;
|
|
46717
|
-
const
|
|
46629
|
+
const agentName = ((_a2 = widget.config) == null ? void 0 : _a2.agentName) || "adk-construction-project-agent";
|
|
46630
|
+
const apiResponse = await loadAgentState$1(widgetBackendUrl, widget.id, agentName);
|
|
46718
46631
|
if (apiResponse) {
|
|
46719
46632
|
parseAndUpdateChartState$1(apiResponse, setChartState);
|
|
46720
46633
|
}
|
|
46721
|
-
setIsInitialFetchComplete(true);
|
|
46722
46634
|
};
|
|
46723
46635
|
fetchInitialState();
|
|
46724
|
-
}, [widgetBackendUrl, widget.id, setChartState]);
|
|
46636
|
+
}, [widgetBackendUrl, widget.id, (_f = widget.config) == null ? void 0 : _f.agentName, setChartState]);
|
|
46725
46637
|
const handleLoadingTimeout = React.useCallback(async () => {
|
|
46726
46638
|
var _a2;
|
|
46727
46639
|
if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
|
|
@@ -46745,7 +46657,7 @@ function CopilotKitSeriesBarChart({
|
|
|
46745
46657
|
if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
|
|
46746
46658
|
parseAndUpdateChartState$1(apiResponse, setChartState);
|
|
46747
46659
|
}
|
|
46748
|
-
}, [widgetBackendUrl, widget.id, setChartState, (
|
|
46660
|
+
}, [widgetBackendUrl, widget.id, setChartState, (_g = widget.config) == null ? void 0 : _g.agentName, chartState, apiCallCount, hasTimeoutError]);
|
|
46749
46661
|
const startLoadingTimeout = React.useCallback(() => {
|
|
46750
46662
|
if (timeoutRef.current) {
|
|
46751
46663
|
clearTimeout(timeoutRef.current);
|
|
@@ -46819,7 +46731,7 @@ function CopilotKitSeriesBarChart({
|
|
|
46819
46731
|
/* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.Bot, { className: "h-4 w-4" }),
|
|
46820
46732
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
|
|
46821
46733
|
] }) }),
|
|
46822
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children:
|
|
46734
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((_j = (_i = (_h = chartState.series_bar_chart_data) == null ? void 0 : _h.data) == null ? void 0 : _i.labels) == null ? void 0 : _j.length) || !((_m = (_l = (_k = chartState.series_bar_chart_data) == null ? void 0 : _k.data) == null ? void 0 : _l.series) == null ? void 0 : _m.length)) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
46823
46735
|
SeriesBarChartComponent,
|
|
46824
46736
|
{
|
|
46825
46737
|
orientation,
|
|
@@ -46827,13 +46739,13 @@ function CopilotKitSeriesBarChart({
|
|
|
46827
46739
|
styles,
|
|
46828
46740
|
appendMessage,
|
|
46829
46741
|
content,
|
|
46830
|
-
query: (
|
|
46742
|
+
query: (_n = widget.config) == null ? void 0 : _n.query,
|
|
46831
46743
|
isFirstLoad,
|
|
46832
46744
|
widgetBackendUrl,
|
|
46833
46745
|
widgetId: widget.id,
|
|
46834
46746
|
startLoadingTimeout,
|
|
46835
46747
|
clearLoadingTimeout,
|
|
46836
|
-
hasWidgetData: !!(((
|
|
46748
|
+
hasWidgetData: !!(((_p = (_o = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _o.labels) == null ? void 0 : _p.length) && ((_r = (_q = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _q.series) == null ? void 0 : _r.length))
|
|
46837
46749
|
}
|
|
46838
46750
|
) })
|
|
46839
46751
|
] });
|
|
@@ -46972,24 +46884,6 @@ const loadAgentState = async (widgetBackendUrl, threadId, agentName) => {
|
|
|
46972
46884
|
return null;
|
|
46973
46885
|
}
|
|
46974
46886
|
};
|
|
46975
|
-
const loadSessionStateDirect = async (widgetBackendUrl, sessionId) => {
|
|
46976
|
-
try {
|
|
46977
|
-
const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
|
|
46978
|
-
method: "GET",
|
|
46979
|
-
headers: {
|
|
46980
|
-
"Content-Type": "application/json"
|
|
46981
|
-
}
|
|
46982
|
-
});
|
|
46983
|
-
if (!response.ok) {
|
|
46984
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
46985
|
-
}
|
|
46986
|
-
const result = await response.json();
|
|
46987
|
-
return result;
|
|
46988
|
-
} catch (error) {
|
|
46989
|
-
console.error("Failed to load session state directly:", error);
|
|
46990
|
-
return null;
|
|
46991
|
-
}
|
|
46992
|
-
};
|
|
46993
46887
|
const parseAndUpdateChartState = (apiResponse, setChartState) => {
|
|
46994
46888
|
var _a, _b;
|
|
46995
46889
|
try {
|
|
@@ -47106,7 +47000,7 @@ function CopilotKitDataGrid({
|
|
|
47106
47000
|
datasetId,
|
|
47107
47001
|
widgetData
|
|
47108
47002
|
}) {
|
|
47109
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
47003
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
47110
47004
|
const isFirstLoad = (_a = widget.config) == null ? void 0 : _a.isFirstLoad;
|
|
47111
47005
|
const content = (_b = widget.config) == null ? void 0 : _b.content;
|
|
47112
47006
|
const widget_data = (_c = widget.widget_data) == null ? void 0 : _c.matrix_grid_data;
|
|
@@ -47123,19 +47017,19 @@ function CopilotKitDataGrid({
|
|
|
47123
47017
|
initialState: createInitialChartState(datasetId, widget_data)
|
|
47124
47018
|
});
|
|
47125
47019
|
const [chartState, setChartState] = React.useState(createInitialChartState(datasetId, widget_data));
|
|
47126
|
-
const [isInitialFetchComplete, setIsInitialFetchComplete] = React.useState(false);
|
|
47127
47020
|
React.useEffect(() => {
|
|
47128
47021
|
const fetchInitialState = async () => {
|
|
47022
|
+
var _a2;
|
|
47129
47023
|
if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
|
|
47130
47024
|
hasInitialFetchRef.current = true;
|
|
47131
|
-
const
|
|
47025
|
+
const agentName = ((_a2 = widget.config) == null ? void 0 : _a2.agentName) || "adk-construction-project-agent";
|
|
47026
|
+
const apiResponse = await loadAgentState(widgetBackendUrl, widget.id, agentName);
|
|
47132
47027
|
if (apiResponse) {
|
|
47133
47028
|
parseAndUpdateChartState(apiResponse, setChartState);
|
|
47134
47029
|
}
|
|
47135
|
-
setIsInitialFetchComplete(true);
|
|
47136
47030
|
};
|
|
47137
47031
|
fetchInitialState();
|
|
47138
|
-
}, [widgetBackendUrl, widget.id, setChartState]);
|
|
47032
|
+
}, [widgetBackendUrl, widget.id, (_e = widget.config) == null ? void 0 : _e.agentName, setChartState]);
|
|
47139
47033
|
const handleLoadingTimeout = React.useCallback(async () => {
|
|
47140
47034
|
var _a2;
|
|
47141
47035
|
if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
|
|
@@ -47159,7 +47053,7 @@ function CopilotKitDataGrid({
|
|
|
47159
47053
|
if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
|
|
47160
47054
|
parseAndUpdateChartState(apiResponse, setChartState);
|
|
47161
47055
|
}
|
|
47162
|
-
}, [widgetBackendUrl, widget.id, setChartState, (
|
|
47056
|
+
}, [widgetBackendUrl, widget.id, setChartState, (_f = widget.config) == null ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
|
|
47163
47057
|
const startLoadingTimeout = React.useCallback(() => {
|
|
47164
47058
|
if (timeoutRef.current) {
|
|
47165
47059
|
clearTimeout(timeoutRef.current);
|
|
@@ -47233,20 +47127,20 @@ function CopilotKitDataGrid({
|
|
|
47233
47127
|
/* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.Bot, { className: "h-4 w-4" }),
|
|
47234
47128
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
|
|
47235
47129
|
] }) }),
|
|
47236
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children:
|
|
47130
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((_i = (_h = (_g = chartState.matrix_grid_data) == null ? void 0 : _g.data) == null ? void 0 : _h.headers) == null ? void 0 : _i.length) || !((_l = (_k = (_j = chartState.matrix_grid_data) == null ? void 0 : _j.data) == null ? void 0 : _k.rows) == null ? void 0 : _l.length)) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
47237
47131
|
DataGridComponent,
|
|
47238
47132
|
{
|
|
47239
47133
|
dataGridState: chartState,
|
|
47240
47134
|
styles,
|
|
47241
47135
|
appendMessage,
|
|
47242
47136
|
content,
|
|
47243
|
-
query: (
|
|
47137
|
+
query: (_m = widget.config) == null ? void 0 : _m.query,
|
|
47244
47138
|
isFirstLoad,
|
|
47245
47139
|
widgetBackendUrl,
|
|
47246
47140
|
widgetId: widget.id,
|
|
47247
47141
|
startLoadingTimeout,
|
|
47248
47142
|
clearLoadingTimeout,
|
|
47249
|
-
hasWidgetData: !!(((
|
|
47143
|
+
hasWidgetData: !!(((_o = (_n = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _n.headers) == null ? void 0 : _o.length) && ((_q = (_p = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _p.rows) == null ? void 0 : _q.length))
|
|
47250
47144
|
}
|
|
47251
47145
|
) })
|
|
47252
47146
|
] });
|