dp-widgets-framework 1.6.6 → 1.6.7

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 CHANGED
@@ -44130,7 +44130,7 @@ function CopilotKitAgent({
44130
44130
  datasetId,
44131
44131
  widgetData
44132
44132
  }) {
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, __, _$;
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;
44134
44134
  const agentType = (_a = widget.config) == null ? void 0 : _a.agentType;
44135
44135
  const orientation = (_b = widget.config) == null ? void 0 : _b.orientation;
44136
44136
  const isFirstLoad = (_c = widget.config) == null ? void 0 : _c.isFirstLoad;
@@ -44140,6 +44140,7 @@ function CopilotKitAgent({
44140
44140
  const [isTimeoutTriggered, setIsTimeoutTriggered] = useState(false);
44141
44141
  const [apiCallCount, setApiCallCount] = useState(0);
44142
44142
  const [hasTimeoutError, setHasTimeoutError] = useState(false);
44143
+ const hasInitialFetchRef = useRef(false);
44143
44144
  useEffect(() => {
44144
44145
  setThreadId(widget.id);
44145
44146
  }, [widget.id, setThreadId]);
@@ -44147,6 +44148,19 @@ function CopilotKitAgent({
44147
44148
  name: (_e = widget.config) == null ? void 0 : _e.agentName,
44148
44149
  initialState: createInitialChartState$4(agentType || "", widgetIds, datasetId)
44149
44150
  });
44151
+ useEffect(() => {
44152
+ const fetchInitialState = async () => {
44153
+ var _a2;
44154
+ if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
44155
+ hasInitialFetchRef.current = true;
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);
44158
+ if (apiResponse) {
44159
+ parseAndUpdateChartState$4(apiResponse, setChartState);
44160
+ }
44161
+ };
44162
+ fetchInitialState();
44163
+ }, [widgetBackendUrl, widget.id, (_f = widget.config) == null ? void 0 : _f.agentName, setChartState]);
44150
44164
  const handleLoadingTimeout = useCallback(async () => {
44151
44165
  var _a2;
44152
44166
  if (!widgetBackendUrl || !widget.id || isTimeoutTriggered || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) return;
@@ -44166,7 +44180,7 @@ function CopilotKitAgent({
44166
44180
  if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
44167
44181
  parseAndUpdateChartState$4(apiResponse, setChartState);
44168
44182
  }
44169
- }, [widgetBackendUrl, widget.id, isTimeoutTriggered, setChartState, (_f = widget.config) == null ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
44183
+ }, [widgetBackendUrl, widget.id, isTimeoutTriggered, setChartState, (_g = widget.config) == null ? void 0 : _g.agentName, chartState, apiCallCount, hasTimeoutError]);
44170
44184
  const startLoadingTimeout = useCallback(() => {
44171
44185
  if (timeoutRef.current) {
44172
44186
  clearTimeout(timeoutRef.current);
@@ -44250,7 +44264,7 @@ function CopilotKitAgent({
44250
44264
  /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
44251
44265
  ] }) }),
44252
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
44253
- (agentType === "Bar Chart Agent" && (!((_i = (_h = (_g = chartState.bar_chart_data) == null ? void 0 : _g.data) == null ? void 0 : _h.labels) == null ? void 0 : _i.length) || !((_l = (_k = (_j = chartState.bar_chart_data) == null ? void 0 : _j.data) == null ? void 0 : _k.values) == null ? void 0 : _l.length)) || agentType === "Series Bar Chart Agent" && (!((_o = (_n = (_m = chartState.series_bar_chart_data) == null ? void 0 : _m.data) == null ? void 0 : _n.labels) == null ? void 0 : _o.length) || !((_r = (_q = (_p = chartState.series_bar_chart_data) == null ? void 0 : _p.data) == null ? void 0 : _q.series) == null ? void 0 : _r.length)) || agentType === "Series Line Chart Agent" && (!((_u = (_t = (_s = chartState.series_bar_chart_data) == null ? void 0 : _s.data) == null ? void 0 : _t.labels) == null ? void 0 : _u.length) || !((_x = (_w = (_v = chartState.series_bar_chart_data) == null ? void 0 : _v.data) == null ? void 0 : _w.series) == null ? void 0 : _x.length)) || agentType === "Pie Chart Agent" && (!((_A = (_z = (_y = chartState.pie_chart_data) == null ? void 0 : _y.data) == null ? void 0 : _z.labels) == null ? void 0 : _A.length) || !((_D = (_C = (_B = chartState.pie_chart_data) == null ? void 0 : _B.data) == null ? void 0 : _C.values) == null ? void 0 : _D.length)) || agentType === "Line Chart Agent" && (!((_G = (_F = (_E = chartState.bar_chart_data) == null ? void 0 : _E.data) == null ? void 0 : _F.labels) == null ? void 0 : _G.length) || !((_J = (_I = (_H = chartState.bar_chart_data) == null ? void 0 : _H.data) == null ? void 0 : _I.values) == null ? void 0 : _J.length)) || agentType === "Data Grid Agent" && (!((_M = (_L = (_K = chartState.matrix_grid_data) == null ? void 0 : _K.data) == null ? void 0 : _L.headers) == null ? void 0 : _M.length) || !((_P = (_O = (_N = chartState.matrix_grid_data) == null ? void 0 : _N.data) == null ? void 0 : _O.rows) == null ? void 0 : _P.length)) || agentType === "Summary Agent" && (!((_R = (_Q = chartState.summary_data) == null ? void 0 : _Q.data) == null ? void 0 : _R.content) || ((_U = (_T = (_S = chartState.summary_data) == null ? void 0 : _S.data) == null ? void 0 : _T.content) == null ? void 0 : _U.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(
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(
44254
44268
  BarChartComponent,
44255
44269
  {
44256
44270
  barChartState: chartState,
@@ -44258,7 +44272,7 @@ function CopilotKitAgent({
44258
44272
  orientation,
44259
44273
  content,
44260
44274
  appendMessage,
44261
- query: (_V = widget.config) == null ? void 0 : _V.query,
44275
+ query: (_W = widget.config) == null ? void 0 : _W.query,
44262
44276
  isFirstLoad,
44263
44277
  widgetBackendUrl,
44264
44278
  widgetId: widget.id,
@@ -44273,7 +44287,7 @@ function CopilotKitAgent({
44273
44287
  orientation,
44274
44288
  content,
44275
44289
  appendMessage,
44276
- query: (_W = widget.config) == null ? void 0 : _W.query,
44290
+ query: (_X = widget.config) == null ? void 0 : _X.query,
44277
44291
  isFirstLoad,
44278
44292
  widgetBackendUrl,
44279
44293
  widgetId: widget.id,
@@ -44288,7 +44302,7 @@ function CopilotKitAgent({
44288
44302
  orientation,
44289
44303
  content,
44290
44304
  appendMessage,
44291
- query: (_X = widget.config) == null ? void 0 : _X.query,
44305
+ query: (_Y = widget.config) == null ? void 0 : _Y.query,
44292
44306
  isFirstLoad,
44293
44307
  widgetBackendUrl,
44294
44308
  widgetId: widget.id,
@@ -44302,7 +44316,7 @@ function CopilotKitAgent({
44302
44316
  styles,
44303
44317
  appendMessage,
44304
44318
  content,
44305
- query: (_Y = widget.config) == null ? void 0 : _Y.query,
44319
+ query: (_Z = widget.config) == null ? void 0 : _Z.query,
44306
44320
  isFirstLoad,
44307
44321
  widgetBackendUrl,
44308
44322
  widgetId: widget.id,
@@ -44316,7 +44330,7 @@ function CopilotKitAgent({
44316
44330
  styles,
44317
44331
  appendMessage,
44318
44332
  content,
44319
- query: (_Z = widget.config) == null ? void 0 : _Z.query,
44333
+ query: (__ = widget.config) == null ? void 0 : __.query,
44320
44334
  isFirstLoad,
44321
44335
  widgetBackendUrl,
44322
44336
  widgetId: widget.id,
@@ -44329,7 +44343,7 @@ function CopilotKitAgent({
44329
44343
  dataGridState: chartState,
44330
44344
  styles,
44331
44345
  appendMessage,
44332
- query: (__ = widget.config) == null ? void 0 : __.query,
44346
+ query: (_$ = widget.config) == null ? void 0 : _$.query,
44333
44347
  isFirstLoad,
44334
44348
  widgetBackendUrl,
44335
44349
  widgetId: widget.id,
@@ -44342,7 +44356,7 @@ function CopilotKitAgent({
44342
44356
  summaryState: chartState,
44343
44357
  styles,
44344
44358
  appendMessage,
44345
- query: (_$ = widget.config) == null ? void 0 : _$.query,
44359
+ query: (_aa = widget.config) == null ? void 0 : _aa.query,
44346
44360
  isFirstLoad,
44347
44361
  widgetBackendUrl,
44348
44362
  widgetId: widget.id,
@@ -45229,13 +45243,14 @@ function CopilotKitFilters({
45229
45243
  onApplyFilters,
45230
45244
  isEditing = false
45231
45245
  }) {
45232
- var _a, _b, _c, _d, _e, _f, _g, _h;
45246
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
45233
45247
  const isFirstLoad = (_a = widget.config) == null ? void 0 : _a.isFirstLoad;
45234
45248
  const widget_data = (_b = widget.widget_data) == null ? void 0 : _b.column_values;
45235
45249
  const { setThreadId } = useCopilotContext();
45236
45250
  const timeoutRef = useRef(null);
45237
45251
  const [apiCallCount, setApiCallCount] = useState(0);
45238
45252
  const [hasTimeoutError, setHasTimeoutError] = useState(false);
45253
+ const hasInitialFetchRef = useRef(false);
45239
45254
  useEffect(() => {
45240
45255
  setThreadId(widget.id);
45241
45256
  }, [widget.id, setThreadId]);
@@ -45244,6 +45259,19 @@ function CopilotKitFilters({
45244
45259
  initialState: createInitialFilterState(datasetId, widget_data)
45245
45260
  });
45246
45261
  const [filterState, setFilterState] = useState(createInitialFilterState(datasetId, widget_data));
45262
+ useEffect(() => {
45263
+ const fetchInitialState = async () => {
45264
+ var _a2;
45265
+ if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
45266
+ hasInitialFetchRef.current = true;
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);
45269
+ if (apiResponse) {
45270
+ parseAndUpdateFilterState(apiResponse, setFilterState);
45271
+ }
45272
+ };
45273
+ fetchInitialState();
45274
+ }, [widgetBackendUrl, widget.id, (_d = widget.config) == null ? void 0 : _d.agentName, setFilterState]);
45247
45275
  const handleLoadingTimeout = useCallback(async () => {
45248
45276
  var _a2;
45249
45277
  if (!widgetBackendUrl || !widget.id || (filterState == null ? void 0 : filterState.agent_message) || hasTimeoutError) {
@@ -45267,7 +45295,7 @@ function CopilotKitFilters({
45267
45295
  if (apiResponse && !(filterState == null ? void 0 : filterState.agent_message)) {
45268
45296
  parseAndUpdateFilterState(apiResponse, setFilterState);
45269
45297
  }
45270
- }, [widgetBackendUrl, widget.id, setFilterState, (_d = widget.config) == null ? void 0 : _d.agentName, filterState, apiCallCount, hasTimeoutError]);
45298
+ }, [widgetBackendUrl, widget.id, setFilterState, (_e = widget.config) == null ? void 0 : _e.agentName, filterState, apiCallCount, hasTimeoutError]);
45271
45299
  const startLoadingTimeout = useCallback(() => {
45272
45300
  if (timeoutRef.current) {
45273
45301
  clearTimeout(timeoutRef.current);
@@ -45393,7 +45421,7 @@ function CopilotKitFilters({
45393
45421
  setHasTimeoutError(false);
45394
45422
  console.log("[FiltersWidget] Starting polling after confirmation");
45395
45423
  startLoadingTimeout();
45396
- }, [filterState.filter_columns, filterState.ambiguous_columns, (_e = widget.config) == null ? void 0 : _e.query, datasetId, appendMessage, setFilterState, setAgentState, startLoadingTimeout, setApiCallCount, setHasTimeoutError]);
45424
+ }, [filterState.filter_columns, filterState.ambiguous_columns, (_f = widget.config) == null ? void 0 : _f.query, datasetId, appendMessage, setFilterState, setAgentState, startLoadingTimeout, setApiCallCount, setHasTimeoutError]);
45397
45425
  const handleCancelConfirmation = useCallback(() => {
45398
45426
  setFilterState((prev) => __spreadProps$7(__spreadValues$9({}, prev), {
45399
45427
  status: void 0,
@@ -45406,7 +45434,7 @@ function CopilotKitFilters({
45406
45434
  console.log("[CopilotKitFilters] Filter state check:", {
45407
45435
  status: filterState.status,
45408
45436
  hasAmbiguousColumns: !!filterState.ambiguous_columns,
45409
- ambiguousColumnsLength: ((_f = filterState.ambiguous_columns) == null ? void 0 : _f.length) || 0,
45437
+ ambiguousColumnsLength: ((_g = filterState.ambiguous_columns) == null ? void 0 : _g.length) || 0,
45410
45438
  isWaitingForConfirmation,
45411
45439
  fullFilterState: filterState
45412
45440
  });
@@ -45422,7 +45450,7 @@ function CopilotKitFilters({
45422
45450
  onCancel: handleCancelConfirmation
45423
45451
  }
45424
45452
  )
45425
- ) : (filterState == null ? void 0 : filterState.agent_message) && !((_g = filterState.column_values) == null ? void 0 : _g.length) && filterState.status !== "waiting_for_confirmation" ? (
45453
+ ) : (filterState == null ? void 0 : filterState.agent_message) && !((_h = filterState.column_values) == null ? void 0 : _h.length) && filterState.status !== "waiting_for_confirmation" ? (
45426
45454
  // Show agent message (errors, warnings, etc.)
45427
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 }) }) })
45428
45456
  ) : (
@@ -45435,7 +45463,7 @@ function CopilotKitFilters({
45435
45463
  onFilterChange,
45436
45464
  widget,
45437
45465
  appendMessage,
45438
- query: (_h = widget.config) == null ? void 0 : _h.query,
45466
+ query: (_i = widget.config) == null ? void 0 : _i.query,
45439
45467
  isFirstLoad,
45440
45468
  widgetBackendUrl,
45441
45469
  widgetId: widget.id,
@@ -45699,7 +45727,7 @@ function CopilotKitPieChart({
45699
45727
  datasetId,
45700
45728
  widgetData
45701
45729
  }) {
45702
- 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;
45703
45731
  const isFirstLoad = (_a = widget.config) == null ? void 0 : _a.isFirstLoad;
45704
45732
  const content = (_b = widget.config) == null ? void 0 : _b.content;
45705
45733
  const widget_data = (_c = widget.widget_data) == null ? void 0 : _c.pie_chart_data;
@@ -45707,6 +45735,7 @@ function CopilotKitPieChart({
45707
45735
  const timeoutRef = useRef(null);
45708
45736
  const [apiCallCount, setApiCallCount] = useState(0);
45709
45737
  const [hasTimeoutError, setHasTimeoutError] = useState(false);
45738
+ const hasInitialFetchRef = useRef(false);
45710
45739
  useEffect(() => {
45711
45740
  setThreadId(widget.id);
45712
45741
  }, [widget.id, setThreadId]);
@@ -45715,6 +45744,19 @@ function CopilotKitPieChart({
45715
45744
  initialState: createInitialChartState$3(datasetId, widget_data)
45716
45745
  });
45717
45746
  const [chartState, setChartState] = useState(createInitialChartState$3(datasetId, widget_data));
45747
+ useEffect(() => {
45748
+ const fetchInitialState = async () => {
45749
+ var _a2;
45750
+ if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
45751
+ hasInitialFetchRef.current = true;
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);
45754
+ if (apiResponse) {
45755
+ parseAndUpdateChartState$3(apiResponse, setChartState);
45756
+ }
45757
+ };
45758
+ fetchInitialState();
45759
+ }, [widgetBackendUrl, widget.id, (_e = widget.config) == null ? void 0 : _e.agentName, setChartState]);
45718
45760
  const handleLoadingTimeout = useCallback(async () => {
45719
45761
  var _a2;
45720
45762
  if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
@@ -45738,7 +45780,7 @@ function CopilotKitPieChart({
45738
45780
  if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
45739
45781
  parseAndUpdateChartState$3(apiResponse, setChartState);
45740
45782
  }
45741
- }, [widgetBackendUrl, widget.id, setChartState, (_e = widget.config) == null ? void 0 : _e.agentName, chartState, apiCallCount, hasTimeoutError]);
45783
+ }, [widgetBackendUrl, widget.id, setChartState, (_f = widget.config) == null ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
45742
45784
  const startLoadingTimeout = useCallback(() => {
45743
45785
  if (timeoutRef.current) {
45744
45786
  clearTimeout(timeoutRef.current);
@@ -45812,20 +45854,20 @@ function CopilotKitPieChart({
45812
45854
  /* @__PURE__ */ jsxRuntimeExports.jsx(Bot, { className: "h-4 w-4" }),
45813
45855
  /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
45814
45856
  ] }) }),
45815
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((_h = (_g = (_f = chartState.pie_chart_data) == null ? void 0 : _f.data) == null ? void 0 : _g.labels) == null ? void 0 : _h.length) || !((_k = (_j = (_i = chartState.pie_chart_data) == null ? void 0 : _i.data) == null ? void 0 : _j.values) == null ? void 0 : _k.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(
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(
45816
45858
  PieChartComponent,
45817
45859
  {
45818
45860
  pieChartState: chartState,
45819
45861
  styles,
45820
45862
  appendMessage,
45821
45863
  content,
45822
- query: (_l = widget.config) == null ? void 0 : _l.query,
45864
+ query: (_m = widget.config) == null ? void 0 : _m.query,
45823
45865
  isFirstLoad,
45824
45866
  widgetBackendUrl,
45825
45867
  widgetId: widget.id,
45826
45868
  startLoadingTimeout,
45827
45869
  clearLoadingTimeout,
45828
- hasWidgetData: !!(((_n = (_m = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _m.labels) == null ? void 0 : _n.length) && ((_p = (_o = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _o.values) == null ? void 0 : _p.length))
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))
45829
45871
  }
45830
45872
  ) })
45831
45873
  ] });
@@ -46108,7 +46150,7 @@ function CopilotKitSeriesBarChart$1({
46108
46150
  datasetId,
46109
46151
  widgetData
46110
46152
  }) {
46111
- 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;
46112
46154
  const orientation = ((_a = widget.config) == null ? void 0 : _a.orientation) || "vertical";
46113
46155
  const isFirstLoad = (_b = widget.config) == null ? void 0 : _b.isFirstLoad;
46114
46156
  const content = (_c = widget.config) == null ? void 0 : _c.content;
@@ -46117,6 +46159,7 @@ function CopilotKitSeriesBarChart$1({
46117
46159
  const timeoutRef = useRef(null);
46118
46160
  const [apiCallCount, setApiCallCount] = useState(0);
46119
46161
  const [hasTimeoutError, setHasTimeoutError] = useState(false);
46162
+ const hasInitialFetchRef = useRef(false);
46120
46163
  useEffect(() => {
46121
46164
  setThreadId(widget.id);
46122
46165
  }, [widget.id, setThreadId]);
@@ -46125,6 +46168,19 @@ function CopilotKitSeriesBarChart$1({
46125
46168
  initialState: createInitialChartState$2(datasetId, widget_data)
46126
46169
  });
46127
46170
  const [chartState, setChartState] = useState(createInitialChartState$2(datasetId, widget_data));
46171
+ useEffect(() => {
46172
+ const fetchInitialState = async () => {
46173
+ var _a2;
46174
+ if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
46175
+ hasInitialFetchRef.current = true;
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);
46178
+ if (apiResponse) {
46179
+ parseAndUpdateChartState$2(apiResponse, setChartState);
46180
+ }
46181
+ };
46182
+ fetchInitialState();
46183
+ }, [widgetBackendUrl, widget.id, (_f = widget.config) == null ? void 0 : _f.agentName, setChartState]);
46128
46184
  const handleLoadingTimeout = useCallback(async () => {
46129
46185
  var _a2;
46130
46186
  if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
@@ -46148,7 +46204,7 @@ function CopilotKitSeriesBarChart$1({
46148
46204
  if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
46149
46205
  parseAndUpdateChartState$2(apiResponse, setChartState);
46150
46206
  }
46151
- }, [widgetBackendUrl, widget.id, setChartState, (_f = widget.config) == null ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
46207
+ }, [widgetBackendUrl, widget.id, setChartState, (_g = widget.config) == null ? void 0 : _g.agentName, chartState, apiCallCount, hasTimeoutError]);
46152
46208
  const startLoadingTimeout = useCallback(() => {
46153
46209
  if (timeoutRef.current) {
46154
46210
  clearTimeout(timeoutRef.current);
@@ -46222,7 +46278,7 @@ function CopilotKitSeriesBarChart$1({
46222
46278
  /* @__PURE__ */ jsxRuntimeExports.jsx(Bot, { className: "h-4 w-4" }),
46223
46279
  /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
46224
46280
  ] }) }),
46225
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((_i = (_h = (_g = chartState.series_bar_chart_data) == null ? void 0 : _g.data) == null ? void 0 : _h.labels) == null ? void 0 : _i.length) || !((_l = (_k = (_j = chartState.series_bar_chart_data) == null ? void 0 : _j.data) == null ? void 0 : _k.series) == 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(
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(
46226
46282
  SeriesBarChartComponent$1,
46227
46283
  {
46228
46284
  orientation,
@@ -46230,13 +46286,13 @@ function CopilotKitSeriesBarChart$1({
46230
46286
  styles,
46231
46287
  appendMessage,
46232
46288
  content,
46233
- query: (_m = widget.config) == null ? void 0 : _m.query,
46289
+ query: (_n = widget.config) == null ? void 0 : _n.query,
46234
46290
  isFirstLoad,
46235
46291
  widgetBackendUrl,
46236
46292
  widgetId: widget.id,
46237
46293
  startLoadingTimeout,
46238
46294
  clearLoadingTimeout,
46239
- 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.series) == null ? void 0 : _q.length))
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))
46240
46296
  }
46241
46297
  ) })
46242
46298
  ] });
@@ -46519,7 +46575,7 @@ function CopilotKitSeriesBarChart({
46519
46575
  datasetId,
46520
46576
  widgetData
46521
46577
  }) {
46522
- 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;
46523
46579
  const orientation = ((_a = widget.config) == null ? void 0 : _a.orientation) || "vertical";
46524
46580
  const isFirstLoad = (_b = widget.config) == null ? void 0 : _b.isFirstLoad;
46525
46581
  const content = (_c = widget.config) == null ? void 0 : _c.content;
@@ -46528,6 +46584,7 @@ function CopilotKitSeriesBarChart({
46528
46584
  const timeoutRef = useRef(null);
46529
46585
  const [apiCallCount, setApiCallCount] = useState(0);
46530
46586
  const [hasTimeoutError, setHasTimeoutError] = useState(false);
46587
+ const hasInitialFetchRef = useRef(false);
46531
46588
  useEffect(() => {
46532
46589
  setThreadId(widget.id);
46533
46590
  }, [widget.id, setThreadId]);
@@ -46536,6 +46593,19 @@ function CopilotKitSeriesBarChart({
46536
46593
  initialState: createInitialChartState$1(datasetId, widget_data)
46537
46594
  });
46538
46595
  const [chartState, setChartState] = useState(createInitialChartState$1(datasetId, widget_data));
46596
+ useEffect(() => {
46597
+ const fetchInitialState = async () => {
46598
+ var _a2;
46599
+ if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
46600
+ hasInitialFetchRef.current = true;
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);
46603
+ if (apiResponse) {
46604
+ parseAndUpdateChartState$1(apiResponse, setChartState);
46605
+ }
46606
+ };
46607
+ fetchInitialState();
46608
+ }, [widgetBackendUrl, widget.id, (_f = widget.config) == null ? void 0 : _f.agentName, setChartState]);
46539
46609
  const handleLoadingTimeout = useCallback(async () => {
46540
46610
  var _a2;
46541
46611
  if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
@@ -46559,7 +46629,7 @@ function CopilotKitSeriesBarChart({
46559
46629
  if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
46560
46630
  parseAndUpdateChartState$1(apiResponse, setChartState);
46561
46631
  }
46562
- }, [widgetBackendUrl, widget.id, setChartState, (_f = widget.config) == null ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
46632
+ }, [widgetBackendUrl, widget.id, setChartState, (_g = widget.config) == null ? void 0 : _g.agentName, chartState, apiCallCount, hasTimeoutError]);
46563
46633
  const startLoadingTimeout = useCallback(() => {
46564
46634
  if (timeoutRef.current) {
46565
46635
  clearTimeout(timeoutRef.current);
@@ -46633,7 +46703,7 @@ function CopilotKitSeriesBarChart({
46633
46703
  /* @__PURE__ */ jsxRuntimeExports.jsx(Bot, { className: "h-4 w-4" }),
46634
46704
  /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
46635
46705
  ] }) }),
46636
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((_i = (_h = (_g = chartState.series_bar_chart_data) == null ? void 0 : _g.data) == null ? void 0 : _h.labels) == null ? void 0 : _i.length) || !((_l = (_k = (_j = chartState.series_bar_chart_data) == null ? void 0 : _j.data) == null ? void 0 : _k.series) == 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(
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(
46637
46707
  SeriesBarChartComponent,
46638
46708
  {
46639
46709
  orientation,
@@ -46641,13 +46711,13 @@ function CopilotKitSeriesBarChart({
46641
46711
  styles,
46642
46712
  appendMessage,
46643
46713
  content,
46644
- query: (_m = widget.config) == null ? void 0 : _m.query,
46714
+ query: (_n = widget.config) == null ? void 0 : _n.query,
46645
46715
  isFirstLoad,
46646
46716
  widgetBackendUrl,
46647
46717
  widgetId: widget.id,
46648
46718
  startLoadingTimeout,
46649
46719
  clearLoadingTimeout,
46650
- 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.series) == null ? void 0 : _q.length))
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))
46651
46721
  }
46652
46722
  ) })
46653
46723
  ] });
@@ -46902,7 +46972,7 @@ function CopilotKitDataGrid({
46902
46972
  datasetId,
46903
46973
  widgetData
46904
46974
  }) {
46905
- 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;
46906
46976
  const isFirstLoad = (_a = widget.config) == null ? void 0 : _a.isFirstLoad;
46907
46977
  const content = (_b = widget.config) == null ? void 0 : _b.content;
46908
46978
  const widget_data = (_c = widget.widget_data) == null ? void 0 : _c.matrix_grid_data;
@@ -46910,6 +46980,7 @@ function CopilotKitDataGrid({
46910
46980
  const timeoutRef = useRef(null);
46911
46981
  const [apiCallCount, setApiCallCount] = useState(0);
46912
46982
  const [hasTimeoutError, setHasTimeoutError] = useState(false);
46983
+ const hasInitialFetchRef = useRef(false);
46913
46984
  useEffect(() => {
46914
46985
  setThreadId(widget.id);
46915
46986
  }, [widget.id, setThreadId]);
@@ -46918,6 +46989,19 @@ function CopilotKitDataGrid({
46918
46989
  initialState: createInitialChartState(datasetId, widget_data)
46919
46990
  });
46920
46991
  const [chartState, setChartState] = useState(createInitialChartState(datasetId, widget_data));
46992
+ useEffect(() => {
46993
+ const fetchInitialState = async () => {
46994
+ var _a2;
46995
+ if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
46996
+ hasInitialFetchRef.current = true;
46997
+ const agentName = ((_a2 = widget.config) == null ? void 0 : _a2.agentName) || "adk-construction-project-agent";
46998
+ const apiResponse = await loadAgentState(widgetBackendUrl, widget.id, agentName);
46999
+ if (apiResponse) {
47000
+ parseAndUpdateChartState(apiResponse, setChartState);
47001
+ }
47002
+ };
47003
+ fetchInitialState();
47004
+ }, [widgetBackendUrl, widget.id, (_e = widget.config) == null ? void 0 : _e.agentName, setChartState]);
46921
47005
  const handleLoadingTimeout = useCallback(async () => {
46922
47006
  var _a2;
46923
47007
  if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
@@ -46941,7 +47025,7 @@ function CopilotKitDataGrid({
46941
47025
  if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
46942
47026
  parseAndUpdateChartState(apiResponse, setChartState);
46943
47027
  }
46944
- }, [widgetBackendUrl, widget.id, setChartState, (_e = widget.config) == null ? void 0 : _e.agentName, chartState, apiCallCount, hasTimeoutError]);
47028
+ }, [widgetBackendUrl, widget.id, setChartState, (_f = widget.config) == null ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
46945
47029
  const startLoadingTimeout = useCallback(() => {
46946
47030
  if (timeoutRef.current) {
46947
47031
  clearTimeout(timeoutRef.current);
@@ -47015,20 +47099,20 @@ function CopilotKitDataGrid({
47015
47099
  /* @__PURE__ */ jsxRuntimeExports.jsx(Bot, { className: "h-4 w-4" }),
47016
47100
  /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
47017
47101
  ] }) }),
47018
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((_h = (_g = (_f = chartState.matrix_grid_data) == null ? void 0 : _f.data) == null ? void 0 : _g.headers) == null ? void 0 : _h.length) || !((_k = (_j = (_i = chartState.matrix_grid_data) == null ? void 0 : _i.data) == null ? void 0 : _j.rows) == null ? void 0 : _k.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(
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(
47019
47103
  DataGridComponent,
47020
47104
  {
47021
47105
  dataGridState: chartState,
47022
47106
  styles,
47023
47107
  appendMessage,
47024
47108
  content,
47025
- query: (_l = widget.config) == null ? void 0 : _l.query,
47109
+ query: (_m = widget.config) == null ? void 0 : _m.query,
47026
47110
  isFirstLoad,
47027
47111
  widgetBackendUrl,
47028
47112
  widgetId: widget.id,
47029
47113
  startLoadingTimeout,
47030
47114
  clearLoadingTimeout,
47031
- hasWidgetData: !!(((_n = (_m = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _m.headers) == null ? void 0 : _n.length) && ((_p = (_o = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _o.rows) == null ? void 0 : _p.length))
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))
47032
47116
  }
47033
47117
  ) })
47034
47118
  ] });
package/dist/index.js CHANGED
@@ -44158,7 +44158,7 @@ function CopilotKitAgent({
44158
44158
  datasetId,
44159
44159
  widgetData
44160
44160
  }) {
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, __, _$;
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;
44162
44162
  const agentType = (_a = widget.config) == null ? void 0 : _a.agentType;
44163
44163
  const orientation = (_b = widget.config) == null ? void 0 : _b.orientation;
44164
44164
  const isFirstLoad = (_c = widget.config) == null ? void 0 : _c.isFirstLoad;
@@ -44168,6 +44168,7 @@ function CopilotKitAgent({
44168
44168
  const [isTimeoutTriggered, setIsTimeoutTriggered] = React.useState(false);
44169
44169
  const [apiCallCount, setApiCallCount] = React.useState(0);
44170
44170
  const [hasTimeoutError, setHasTimeoutError] = React.useState(false);
44171
+ const hasInitialFetchRef = React.useRef(false);
44171
44172
  React.useEffect(() => {
44172
44173
  setThreadId(widget.id);
44173
44174
  }, [widget.id, setThreadId]);
@@ -44175,6 +44176,19 @@ function CopilotKitAgent({
44175
44176
  name: (_e = widget.config) == null ? void 0 : _e.agentName,
44176
44177
  initialState: createInitialChartState$4(agentType || "", widgetIds, datasetId)
44177
44178
  });
44179
+ React.useEffect(() => {
44180
+ const fetchInitialState = async () => {
44181
+ var _a2;
44182
+ if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
44183
+ hasInitialFetchRef.current = true;
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);
44186
+ if (apiResponse) {
44187
+ parseAndUpdateChartState$4(apiResponse, setChartState);
44188
+ }
44189
+ };
44190
+ fetchInitialState();
44191
+ }, [widgetBackendUrl, widget.id, (_f = widget.config) == null ? void 0 : _f.agentName, setChartState]);
44178
44192
  const handleLoadingTimeout = React.useCallback(async () => {
44179
44193
  var _a2;
44180
44194
  if (!widgetBackendUrl || !widget.id || isTimeoutTriggered || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) return;
@@ -44194,7 +44208,7 @@ function CopilotKitAgent({
44194
44208
  if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
44195
44209
  parseAndUpdateChartState$4(apiResponse, setChartState);
44196
44210
  }
44197
- }, [widgetBackendUrl, widget.id, isTimeoutTriggered, setChartState, (_f = widget.config) == null ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
44211
+ }, [widgetBackendUrl, widget.id, isTimeoutTriggered, setChartState, (_g = widget.config) == null ? void 0 : _g.agentName, chartState, apiCallCount, hasTimeoutError]);
44198
44212
  const startLoadingTimeout = React.useCallback(() => {
44199
44213
  if (timeoutRef.current) {
44200
44214
  clearTimeout(timeoutRef.current);
@@ -44278,7 +44292,7 @@ function CopilotKitAgent({
44278
44292
  /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
44279
44293
  ] }) }),
44280
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
44281
- (agentType === "Bar Chart Agent" && (!((_i = (_h = (_g = chartState.bar_chart_data) == null ? void 0 : _g.data) == null ? void 0 : _h.labels) == null ? void 0 : _i.length) || !((_l = (_k = (_j = chartState.bar_chart_data) == null ? void 0 : _j.data) == null ? void 0 : _k.values) == null ? void 0 : _l.length)) || agentType === "Series Bar Chart Agent" && (!((_o = (_n = (_m = chartState.series_bar_chart_data) == null ? void 0 : _m.data) == null ? void 0 : _n.labels) == null ? void 0 : _o.length) || !((_r = (_q = (_p = chartState.series_bar_chart_data) == null ? void 0 : _p.data) == null ? void 0 : _q.series) == null ? void 0 : _r.length)) || agentType === "Series Line Chart Agent" && (!((_u = (_t = (_s = chartState.series_bar_chart_data) == null ? void 0 : _s.data) == null ? void 0 : _t.labels) == null ? void 0 : _u.length) || !((_x = (_w = (_v = chartState.series_bar_chart_data) == null ? void 0 : _v.data) == null ? void 0 : _w.series) == null ? void 0 : _x.length)) || agentType === "Pie Chart Agent" && (!((_A = (_z = (_y = chartState.pie_chart_data) == null ? void 0 : _y.data) == null ? void 0 : _z.labels) == null ? void 0 : _A.length) || !((_D = (_C = (_B = chartState.pie_chart_data) == null ? void 0 : _B.data) == null ? void 0 : _C.values) == null ? void 0 : _D.length)) || agentType === "Line Chart Agent" && (!((_G = (_F = (_E = chartState.bar_chart_data) == null ? void 0 : _E.data) == null ? void 0 : _F.labels) == null ? void 0 : _G.length) || !((_J = (_I = (_H = chartState.bar_chart_data) == null ? void 0 : _H.data) == null ? void 0 : _I.values) == null ? void 0 : _J.length)) || agentType === "Data Grid Agent" && (!((_M = (_L = (_K = chartState.matrix_grid_data) == null ? void 0 : _K.data) == null ? void 0 : _L.headers) == null ? void 0 : _M.length) || !((_P = (_O = (_N = chartState.matrix_grid_data) == null ? void 0 : _N.data) == null ? void 0 : _O.rows) == null ? void 0 : _P.length)) || agentType === "Summary Agent" && (!((_R = (_Q = chartState.summary_data) == null ? void 0 : _Q.data) == null ? void 0 : _R.content) || ((_U = (_T = (_S = chartState.summary_data) == null ? void 0 : _S.data) == null ? void 0 : _T.content) == null ? void 0 : _U.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(
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(
44282
44296
  BarChartComponent,
44283
44297
  {
44284
44298
  barChartState: chartState,
@@ -44286,7 +44300,7 @@ function CopilotKitAgent({
44286
44300
  orientation,
44287
44301
  content,
44288
44302
  appendMessage,
44289
- query: (_V = widget.config) == null ? void 0 : _V.query,
44303
+ query: (_W = widget.config) == null ? void 0 : _W.query,
44290
44304
  isFirstLoad,
44291
44305
  widgetBackendUrl,
44292
44306
  widgetId: widget.id,
@@ -44301,7 +44315,7 @@ function CopilotKitAgent({
44301
44315
  orientation,
44302
44316
  content,
44303
44317
  appendMessage,
44304
- query: (_W = widget.config) == null ? void 0 : _W.query,
44318
+ query: (_X = widget.config) == null ? void 0 : _X.query,
44305
44319
  isFirstLoad,
44306
44320
  widgetBackendUrl,
44307
44321
  widgetId: widget.id,
@@ -44316,7 +44330,7 @@ function CopilotKitAgent({
44316
44330
  orientation,
44317
44331
  content,
44318
44332
  appendMessage,
44319
- query: (_X = widget.config) == null ? void 0 : _X.query,
44333
+ query: (_Y = widget.config) == null ? void 0 : _Y.query,
44320
44334
  isFirstLoad,
44321
44335
  widgetBackendUrl,
44322
44336
  widgetId: widget.id,
@@ -44330,7 +44344,7 @@ function CopilotKitAgent({
44330
44344
  styles,
44331
44345
  appendMessage,
44332
44346
  content,
44333
- query: (_Y = widget.config) == null ? void 0 : _Y.query,
44347
+ query: (_Z = widget.config) == null ? void 0 : _Z.query,
44334
44348
  isFirstLoad,
44335
44349
  widgetBackendUrl,
44336
44350
  widgetId: widget.id,
@@ -44344,7 +44358,7 @@ function CopilotKitAgent({
44344
44358
  styles,
44345
44359
  appendMessage,
44346
44360
  content,
44347
- query: (_Z = widget.config) == null ? void 0 : _Z.query,
44361
+ query: (__ = widget.config) == null ? void 0 : __.query,
44348
44362
  isFirstLoad,
44349
44363
  widgetBackendUrl,
44350
44364
  widgetId: widget.id,
@@ -44357,7 +44371,7 @@ function CopilotKitAgent({
44357
44371
  dataGridState: chartState,
44358
44372
  styles,
44359
44373
  appendMessage,
44360
- query: (__ = widget.config) == null ? void 0 : __.query,
44374
+ query: (_$ = widget.config) == null ? void 0 : _$.query,
44361
44375
  isFirstLoad,
44362
44376
  widgetBackendUrl,
44363
44377
  widgetId: widget.id,
@@ -44370,7 +44384,7 @@ function CopilotKitAgent({
44370
44384
  summaryState: chartState,
44371
44385
  styles,
44372
44386
  appendMessage,
44373
- query: (_$ = widget.config) == null ? void 0 : _$.query,
44387
+ query: (_aa = widget.config) == null ? void 0 : _aa.query,
44374
44388
  isFirstLoad,
44375
44389
  widgetBackendUrl,
44376
44390
  widgetId: widget.id,
@@ -45257,13 +45271,14 @@ function CopilotKitFilters({
45257
45271
  onApplyFilters,
45258
45272
  isEditing = false
45259
45273
  }) {
45260
- var _a, _b, _c, _d, _e, _f, _g, _h;
45274
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
45261
45275
  const isFirstLoad = (_a = widget.config) == null ? void 0 : _a.isFirstLoad;
45262
45276
  const widget_data = (_b = widget.widget_data) == null ? void 0 : _b.column_values;
45263
45277
  const { setThreadId } = reactCore.useCopilotContext();
45264
45278
  const timeoutRef = React.useRef(null);
45265
45279
  const [apiCallCount, setApiCallCount] = React.useState(0);
45266
45280
  const [hasTimeoutError, setHasTimeoutError] = React.useState(false);
45281
+ const hasInitialFetchRef = React.useRef(false);
45267
45282
  React.useEffect(() => {
45268
45283
  setThreadId(widget.id);
45269
45284
  }, [widget.id, setThreadId]);
@@ -45272,6 +45287,19 @@ function CopilotKitFilters({
45272
45287
  initialState: createInitialFilterState(datasetId, widget_data)
45273
45288
  });
45274
45289
  const [filterState, setFilterState] = React.useState(createInitialFilterState(datasetId, widget_data));
45290
+ React.useEffect(() => {
45291
+ const fetchInitialState = async () => {
45292
+ var _a2;
45293
+ if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
45294
+ hasInitialFetchRef.current = true;
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);
45297
+ if (apiResponse) {
45298
+ parseAndUpdateFilterState(apiResponse, setFilterState);
45299
+ }
45300
+ };
45301
+ fetchInitialState();
45302
+ }, [widgetBackendUrl, widget.id, (_d = widget.config) == null ? void 0 : _d.agentName, setFilterState]);
45275
45303
  const handleLoadingTimeout = React.useCallback(async () => {
45276
45304
  var _a2;
45277
45305
  if (!widgetBackendUrl || !widget.id || (filterState == null ? void 0 : filterState.agent_message) || hasTimeoutError) {
@@ -45295,7 +45323,7 @@ function CopilotKitFilters({
45295
45323
  if (apiResponse && !(filterState == null ? void 0 : filterState.agent_message)) {
45296
45324
  parseAndUpdateFilterState(apiResponse, setFilterState);
45297
45325
  }
45298
- }, [widgetBackendUrl, widget.id, setFilterState, (_d = widget.config) == null ? void 0 : _d.agentName, filterState, apiCallCount, hasTimeoutError]);
45326
+ }, [widgetBackendUrl, widget.id, setFilterState, (_e = widget.config) == null ? void 0 : _e.agentName, filterState, apiCallCount, hasTimeoutError]);
45299
45327
  const startLoadingTimeout = React.useCallback(() => {
45300
45328
  if (timeoutRef.current) {
45301
45329
  clearTimeout(timeoutRef.current);
@@ -45421,7 +45449,7 @@ function CopilotKitFilters({
45421
45449
  setHasTimeoutError(false);
45422
45450
  console.log("[FiltersWidget] Starting polling after confirmation");
45423
45451
  startLoadingTimeout();
45424
- }, [filterState.filter_columns, filterState.ambiguous_columns, (_e = widget.config) == null ? void 0 : _e.query, datasetId, appendMessage, setFilterState, setAgentState, startLoadingTimeout, setApiCallCount, setHasTimeoutError]);
45452
+ }, [filterState.filter_columns, filterState.ambiguous_columns, (_f = widget.config) == null ? void 0 : _f.query, datasetId, appendMessage, setFilterState, setAgentState, startLoadingTimeout, setApiCallCount, setHasTimeoutError]);
45425
45453
  const handleCancelConfirmation = React.useCallback(() => {
45426
45454
  setFilterState((prev) => __spreadProps$7(__spreadValues$9({}, prev), {
45427
45455
  status: void 0,
@@ -45434,7 +45462,7 @@ function CopilotKitFilters({
45434
45462
  console.log("[CopilotKitFilters] Filter state check:", {
45435
45463
  status: filterState.status,
45436
45464
  hasAmbiguousColumns: !!filterState.ambiguous_columns,
45437
- ambiguousColumnsLength: ((_f = filterState.ambiguous_columns) == null ? void 0 : _f.length) || 0,
45465
+ ambiguousColumnsLength: ((_g = filterState.ambiguous_columns) == null ? void 0 : _g.length) || 0,
45438
45466
  isWaitingForConfirmation,
45439
45467
  fullFilterState: filterState
45440
45468
  });
@@ -45450,7 +45478,7 @@ function CopilotKitFilters({
45450
45478
  onCancel: handleCancelConfirmation
45451
45479
  }
45452
45480
  )
45453
- ) : (filterState == null ? void 0 : filterState.agent_message) && !((_g = filterState.column_values) == null ? void 0 : _g.length) && filterState.status !== "waiting_for_confirmation" ? (
45481
+ ) : (filterState == null ? void 0 : filterState.agent_message) && !((_h = filterState.column_values) == null ? void 0 : _h.length) && filterState.status !== "waiting_for_confirmation" ? (
45454
45482
  // Show agent message (errors, warnings, etc.)
45455
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 }) }) })
45456
45484
  ) : (
@@ -45463,7 +45491,7 @@ function CopilotKitFilters({
45463
45491
  onFilterChange,
45464
45492
  widget,
45465
45493
  appendMessage,
45466
- query: (_h = widget.config) == null ? void 0 : _h.query,
45494
+ query: (_i = widget.config) == null ? void 0 : _i.query,
45467
45495
  isFirstLoad,
45468
45496
  widgetBackendUrl,
45469
45497
  widgetId: widget.id,
@@ -45727,7 +45755,7 @@ function CopilotKitPieChart({
45727
45755
  datasetId,
45728
45756
  widgetData
45729
45757
  }) {
45730
- 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;
45731
45759
  const isFirstLoad = (_a = widget.config) == null ? void 0 : _a.isFirstLoad;
45732
45760
  const content = (_b = widget.config) == null ? void 0 : _b.content;
45733
45761
  const widget_data = (_c = widget.widget_data) == null ? void 0 : _c.pie_chart_data;
@@ -45735,6 +45763,7 @@ function CopilotKitPieChart({
45735
45763
  const timeoutRef = React.useRef(null);
45736
45764
  const [apiCallCount, setApiCallCount] = React.useState(0);
45737
45765
  const [hasTimeoutError, setHasTimeoutError] = React.useState(false);
45766
+ const hasInitialFetchRef = React.useRef(false);
45738
45767
  React.useEffect(() => {
45739
45768
  setThreadId(widget.id);
45740
45769
  }, [widget.id, setThreadId]);
@@ -45743,6 +45772,19 @@ function CopilotKitPieChart({
45743
45772
  initialState: createInitialChartState$3(datasetId, widget_data)
45744
45773
  });
45745
45774
  const [chartState, setChartState] = React.useState(createInitialChartState$3(datasetId, widget_data));
45775
+ React.useEffect(() => {
45776
+ const fetchInitialState = async () => {
45777
+ var _a2;
45778
+ if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
45779
+ hasInitialFetchRef.current = true;
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);
45782
+ if (apiResponse) {
45783
+ parseAndUpdateChartState$3(apiResponse, setChartState);
45784
+ }
45785
+ };
45786
+ fetchInitialState();
45787
+ }, [widgetBackendUrl, widget.id, (_e = widget.config) == null ? void 0 : _e.agentName, setChartState]);
45746
45788
  const handleLoadingTimeout = React.useCallback(async () => {
45747
45789
  var _a2;
45748
45790
  if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
@@ -45766,7 +45808,7 @@ function CopilotKitPieChart({
45766
45808
  if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
45767
45809
  parseAndUpdateChartState$3(apiResponse, setChartState);
45768
45810
  }
45769
- }, [widgetBackendUrl, widget.id, setChartState, (_e = widget.config) == null ? void 0 : _e.agentName, chartState, apiCallCount, hasTimeoutError]);
45811
+ }, [widgetBackendUrl, widget.id, setChartState, (_f = widget.config) == null ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
45770
45812
  const startLoadingTimeout = React.useCallback(() => {
45771
45813
  if (timeoutRef.current) {
45772
45814
  clearTimeout(timeoutRef.current);
@@ -45840,20 +45882,20 @@ function CopilotKitPieChart({
45840
45882
  /* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.Bot, { className: "h-4 w-4" }),
45841
45883
  /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
45842
45884
  ] }) }),
45843
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((_h = (_g = (_f = chartState.pie_chart_data) == null ? void 0 : _f.data) == null ? void 0 : _g.labels) == null ? void 0 : _h.length) || !((_k = (_j = (_i = chartState.pie_chart_data) == null ? void 0 : _i.data) == null ? void 0 : _j.values) == null ? void 0 : _k.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(
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(
45844
45886
  PieChartComponent,
45845
45887
  {
45846
45888
  pieChartState: chartState,
45847
45889
  styles,
45848
45890
  appendMessage,
45849
45891
  content,
45850
- query: (_l = widget.config) == null ? void 0 : _l.query,
45892
+ query: (_m = widget.config) == null ? void 0 : _m.query,
45851
45893
  isFirstLoad,
45852
45894
  widgetBackendUrl,
45853
45895
  widgetId: widget.id,
45854
45896
  startLoadingTimeout,
45855
45897
  clearLoadingTimeout,
45856
- hasWidgetData: !!(((_n = (_m = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _m.labels) == null ? void 0 : _n.length) && ((_p = (_o = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _o.values) == null ? void 0 : _p.length))
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))
45857
45899
  }
45858
45900
  ) })
45859
45901
  ] });
@@ -46136,7 +46178,7 @@ function CopilotKitSeriesBarChart$1({
46136
46178
  datasetId,
46137
46179
  widgetData
46138
46180
  }) {
46139
- 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;
46140
46182
  const orientation = ((_a = widget.config) == null ? void 0 : _a.orientation) || "vertical";
46141
46183
  const isFirstLoad = (_b = widget.config) == null ? void 0 : _b.isFirstLoad;
46142
46184
  const content = (_c = widget.config) == null ? void 0 : _c.content;
@@ -46145,6 +46187,7 @@ function CopilotKitSeriesBarChart$1({
46145
46187
  const timeoutRef = React.useRef(null);
46146
46188
  const [apiCallCount, setApiCallCount] = React.useState(0);
46147
46189
  const [hasTimeoutError, setHasTimeoutError] = React.useState(false);
46190
+ const hasInitialFetchRef = React.useRef(false);
46148
46191
  React.useEffect(() => {
46149
46192
  setThreadId(widget.id);
46150
46193
  }, [widget.id, setThreadId]);
@@ -46153,6 +46196,19 @@ function CopilotKitSeriesBarChart$1({
46153
46196
  initialState: createInitialChartState$2(datasetId, widget_data)
46154
46197
  });
46155
46198
  const [chartState, setChartState] = React.useState(createInitialChartState$2(datasetId, widget_data));
46199
+ React.useEffect(() => {
46200
+ const fetchInitialState = async () => {
46201
+ var _a2;
46202
+ if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
46203
+ hasInitialFetchRef.current = true;
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);
46206
+ if (apiResponse) {
46207
+ parseAndUpdateChartState$2(apiResponse, setChartState);
46208
+ }
46209
+ };
46210
+ fetchInitialState();
46211
+ }, [widgetBackendUrl, widget.id, (_f = widget.config) == null ? void 0 : _f.agentName, setChartState]);
46156
46212
  const handleLoadingTimeout = React.useCallback(async () => {
46157
46213
  var _a2;
46158
46214
  if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
@@ -46176,7 +46232,7 @@ function CopilotKitSeriesBarChart$1({
46176
46232
  if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
46177
46233
  parseAndUpdateChartState$2(apiResponse, setChartState);
46178
46234
  }
46179
- }, [widgetBackendUrl, widget.id, setChartState, (_f = widget.config) == null ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
46235
+ }, [widgetBackendUrl, widget.id, setChartState, (_g = widget.config) == null ? void 0 : _g.agentName, chartState, apiCallCount, hasTimeoutError]);
46180
46236
  const startLoadingTimeout = React.useCallback(() => {
46181
46237
  if (timeoutRef.current) {
46182
46238
  clearTimeout(timeoutRef.current);
@@ -46250,7 +46306,7 @@ function CopilotKitSeriesBarChart$1({
46250
46306
  /* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.Bot, { className: "h-4 w-4" }),
46251
46307
  /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
46252
46308
  ] }) }),
46253
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((_i = (_h = (_g = chartState.series_bar_chart_data) == null ? void 0 : _g.data) == null ? void 0 : _h.labels) == null ? void 0 : _i.length) || !((_l = (_k = (_j = chartState.series_bar_chart_data) == null ? void 0 : _j.data) == null ? void 0 : _k.series) == 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(
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(
46254
46310
  SeriesBarChartComponent$1,
46255
46311
  {
46256
46312
  orientation,
@@ -46258,13 +46314,13 @@ function CopilotKitSeriesBarChart$1({
46258
46314
  styles,
46259
46315
  appendMessage,
46260
46316
  content,
46261
- query: (_m = widget.config) == null ? void 0 : _m.query,
46317
+ query: (_n = widget.config) == null ? void 0 : _n.query,
46262
46318
  isFirstLoad,
46263
46319
  widgetBackendUrl,
46264
46320
  widgetId: widget.id,
46265
46321
  startLoadingTimeout,
46266
46322
  clearLoadingTimeout,
46267
- 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.series) == null ? void 0 : _q.length))
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))
46268
46324
  }
46269
46325
  ) })
46270
46326
  ] });
@@ -46547,7 +46603,7 @@ function CopilotKitSeriesBarChart({
46547
46603
  datasetId,
46548
46604
  widgetData
46549
46605
  }) {
46550
- 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;
46551
46607
  const orientation = ((_a = widget.config) == null ? void 0 : _a.orientation) || "vertical";
46552
46608
  const isFirstLoad = (_b = widget.config) == null ? void 0 : _b.isFirstLoad;
46553
46609
  const content = (_c = widget.config) == null ? void 0 : _c.content;
@@ -46556,6 +46612,7 @@ function CopilotKitSeriesBarChart({
46556
46612
  const timeoutRef = React.useRef(null);
46557
46613
  const [apiCallCount, setApiCallCount] = React.useState(0);
46558
46614
  const [hasTimeoutError, setHasTimeoutError] = React.useState(false);
46615
+ const hasInitialFetchRef = React.useRef(false);
46559
46616
  React.useEffect(() => {
46560
46617
  setThreadId(widget.id);
46561
46618
  }, [widget.id, setThreadId]);
@@ -46564,6 +46621,19 @@ function CopilotKitSeriesBarChart({
46564
46621
  initialState: createInitialChartState$1(datasetId, widget_data)
46565
46622
  });
46566
46623
  const [chartState, setChartState] = React.useState(createInitialChartState$1(datasetId, widget_data));
46624
+ React.useEffect(() => {
46625
+ const fetchInitialState = async () => {
46626
+ var _a2;
46627
+ if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
46628
+ hasInitialFetchRef.current = true;
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);
46631
+ if (apiResponse) {
46632
+ parseAndUpdateChartState$1(apiResponse, setChartState);
46633
+ }
46634
+ };
46635
+ fetchInitialState();
46636
+ }, [widgetBackendUrl, widget.id, (_f = widget.config) == null ? void 0 : _f.agentName, setChartState]);
46567
46637
  const handleLoadingTimeout = React.useCallback(async () => {
46568
46638
  var _a2;
46569
46639
  if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
@@ -46587,7 +46657,7 @@ function CopilotKitSeriesBarChart({
46587
46657
  if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
46588
46658
  parseAndUpdateChartState$1(apiResponse, setChartState);
46589
46659
  }
46590
- }, [widgetBackendUrl, widget.id, setChartState, (_f = widget.config) == null ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
46660
+ }, [widgetBackendUrl, widget.id, setChartState, (_g = widget.config) == null ? void 0 : _g.agentName, chartState, apiCallCount, hasTimeoutError]);
46591
46661
  const startLoadingTimeout = React.useCallback(() => {
46592
46662
  if (timeoutRef.current) {
46593
46663
  clearTimeout(timeoutRef.current);
@@ -46661,7 +46731,7 @@ function CopilotKitSeriesBarChart({
46661
46731
  /* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.Bot, { className: "h-4 w-4" }),
46662
46732
  /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
46663
46733
  ] }) }),
46664
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((_i = (_h = (_g = chartState.series_bar_chart_data) == null ? void 0 : _g.data) == null ? void 0 : _h.labels) == null ? void 0 : _i.length) || !((_l = (_k = (_j = chartState.series_bar_chart_data) == null ? void 0 : _j.data) == null ? void 0 : _k.series) == 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(
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(
46665
46735
  SeriesBarChartComponent,
46666
46736
  {
46667
46737
  orientation,
@@ -46669,13 +46739,13 @@ function CopilotKitSeriesBarChart({
46669
46739
  styles,
46670
46740
  appendMessage,
46671
46741
  content,
46672
- query: (_m = widget.config) == null ? void 0 : _m.query,
46742
+ query: (_n = widget.config) == null ? void 0 : _n.query,
46673
46743
  isFirstLoad,
46674
46744
  widgetBackendUrl,
46675
46745
  widgetId: widget.id,
46676
46746
  startLoadingTimeout,
46677
46747
  clearLoadingTimeout,
46678
- 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.series) == null ? void 0 : _q.length))
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))
46679
46749
  }
46680
46750
  ) })
46681
46751
  ] });
@@ -46930,7 +47000,7 @@ function CopilotKitDataGrid({
46930
47000
  datasetId,
46931
47001
  widgetData
46932
47002
  }) {
46933
- 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;
46934
47004
  const isFirstLoad = (_a = widget.config) == null ? void 0 : _a.isFirstLoad;
46935
47005
  const content = (_b = widget.config) == null ? void 0 : _b.content;
46936
47006
  const widget_data = (_c = widget.widget_data) == null ? void 0 : _c.matrix_grid_data;
@@ -46938,6 +47008,7 @@ function CopilotKitDataGrid({
46938
47008
  const timeoutRef = React.useRef(null);
46939
47009
  const [apiCallCount, setApiCallCount] = React.useState(0);
46940
47010
  const [hasTimeoutError, setHasTimeoutError] = React.useState(false);
47011
+ const hasInitialFetchRef = React.useRef(false);
46941
47012
  React.useEffect(() => {
46942
47013
  setThreadId(widget.id);
46943
47014
  }, [widget.id, setThreadId]);
@@ -46946,6 +47017,19 @@ function CopilotKitDataGrid({
46946
47017
  initialState: createInitialChartState(datasetId, widget_data)
46947
47018
  });
46948
47019
  const [chartState, setChartState] = React.useState(createInitialChartState(datasetId, widget_data));
47020
+ React.useEffect(() => {
47021
+ const fetchInitialState = async () => {
47022
+ var _a2;
47023
+ if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
47024
+ hasInitialFetchRef.current = true;
47025
+ const agentName = ((_a2 = widget.config) == null ? void 0 : _a2.agentName) || "adk-construction-project-agent";
47026
+ const apiResponse = await loadAgentState(widgetBackendUrl, widget.id, agentName);
47027
+ if (apiResponse) {
47028
+ parseAndUpdateChartState(apiResponse, setChartState);
47029
+ }
47030
+ };
47031
+ fetchInitialState();
47032
+ }, [widgetBackendUrl, widget.id, (_e = widget.config) == null ? void 0 : _e.agentName, setChartState]);
46949
47033
  const handleLoadingTimeout = React.useCallback(async () => {
46950
47034
  var _a2;
46951
47035
  if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
@@ -46969,7 +47053,7 @@ function CopilotKitDataGrid({
46969
47053
  if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
46970
47054
  parseAndUpdateChartState(apiResponse, setChartState);
46971
47055
  }
46972
- }, [widgetBackendUrl, widget.id, setChartState, (_e = widget.config) == null ? void 0 : _e.agentName, chartState, apiCallCount, hasTimeoutError]);
47056
+ }, [widgetBackendUrl, widget.id, setChartState, (_f = widget.config) == null ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
46973
47057
  const startLoadingTimeout = React.useCallback(() => {
46974
47058
  if (timeoutRef.current) {
46975
47059
  clearTimeout(timeoutRef.current);
@@ -47043,20 +47127,20 @@ function CopilotKitDataGrid({
47043
47127
  /* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.Bot, { className: "h-4 w-4" }),
47044
47128
  /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
47045
47129
  ] }) }),
47046
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((_h = (_g = (_f = chartState.matrix_grid_data) == null ? void 0 : _f.data) == null ? void 0 : _g.headers) == null ? void 0 : _h.length) || !((_k = (_j = (_i = chartState.matrix_grid_data) == null ? void 0 : _i.data) == null ? void 0 : _j.rows) == null ? void 0 : _k.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(
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(
47047
47131
  DataGridComponent,
47048
47132
  {
47049
47133
  dataGridState: chartState,
47050
47134
  styles,
47051
47135
  appendMessage,
47052
47136
  content,
47053
- query: (_l = widget.config) == null ? void 0 : _l.query,
47137
+ query: (_m = widget.config) == null ? void 0 : _m.query,
47054
47138
  isFirstLoad,
47055
47139
  widgetBackendUrl,
47056
47140
  widgetId: widget.id,
47057
47141
  startLoadingTimeout,
47058
47142
  clearLoadingTimeout,
47059
- hasWidgetData: !!(((_n = (_m = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _m.headers) == null ? void 0 : _n.length) && ((_p = (_o = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _o.rows) == null ? void 0 : _p.length))
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))
47060
47144
  }
47061
47145
  ) })
47062
47146
  ] });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dp-widgets-framework",
3
- "version": "1.6.6",
3
+ "version": "1.6.7",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org"