dp-widgets-framework 1.6.8 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 apiResponse = await loadSessionStateDirect$5(widgetBackendUrl, widget.id);
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, (_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]);
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: !isInitialFetchComplete && !isFirstLoad ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.RefreshCw, { className: "h-6 w-6 animate-spin text-gray-400" }) }) : (chartState == null ? void 0 : chartState.agent_message) && agentType !== "chatbot" && // Check if data is empty based on agent type
44313
- (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(
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: (_V = widget.config) == null ? void 0 : _V.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: (_W = widget.config) == null ? void 0 : _W.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: (_X = widget.config) == null ? void 0 : _X.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: (_Y = widget.config) == null ? void 0 : _Y.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: (_Z = widget.config) == null ? void 0 : _Z.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: (__ = widget.config) == null ? void 0 : __.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: (_$ = widget.config) == null ? void 0 : _$.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 apiResponse = await loadSessionStateDirect$4(widgetBackendUrl, widget.id);
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, (_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]);
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, (_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]);
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: ((_f = filterState.ambiguous_columns) == null ? void 0 : _f.length) || 0,
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) && !((_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" ? (
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: (_h = widget.config) == null ? void 0 : _h.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 apiResponse = await loadSessionStateDirect$3(widgetBackendUrl, widget.id);
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, (_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]);
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: !isInitialFetchComplete && !isFirstLoad ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.RefreshCw, { className: "h-6 w-6 animate-spin text-gray-400" }) }) : (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(
45938
45886
  PieChartComponent,
45939
45887
  {
45940
45888
  pieChartState: chartState,
45941
45889
  styles,
45942
45890
  appendMessage,
45943
45891
  content,
45944
- query: (_l = widget.config) == null ? void 0 : _l.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: !!(((_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))
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 apiResponse = await loadSessionStateDirect$2(widgetBackendUrl, widget.id);
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, (_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]);
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: !isInitialFetchComplete && !isFirstLoad ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.RefreshCw, { className: "h-6 w-6 animate-spin text-gray-400" }) }) : (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(
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: (_m = widget.config) == null ? void 0 : _m.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: !!(((_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))
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 apiResponse = await loadSessionStateDirect$1(widgetBackendUrl, widget.id);
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, (_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]);
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: !isInitialFetchComplete && !isFirstLoad ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.RefreshCw, { className: "h-6 w-6 animate-spin text-gray-400" }) }) : (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(
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: (_m = widget.config) == null ? void 0 : _m.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: !!(((_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))
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 apiResponse = await loadSessionStateDirect(widgetBackendUrl, widget.id);
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, (_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]);
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: !isInitialFetchComplete && !isFirstLoad ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.RefreshCw, { className: "h-6 w-6 animate-spin text-gray-400" }) }) : (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(
47237
47131
  DataGridComponent,
47238
47132
  {
47239
47133
  dataGridState: chartState,
47240
47134
  styles,
47241
47135
  appendMessage,
47242
47136
  content,
47243
- query: (_l = widget.config) == null ? void 0 : _l.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: !!(((_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))
47250
47144
  }
47251
47145
  ) })
47252
47146
  ] });
@@ -48211,7 +48105,8 @@ function WidgetDashboard({
48211
48105
  userId,
48212
48106
  onApplyFilters,
48213
48107
  filterResults,
48214
- isApplyingFilters = false
48108
+ isApplyingFilters = false,
48109
+ focusWidgetId
48215
48110
  }) {
48216
48111
  const [widgets, setWidgets] = React.useState([]);
48217
48112
  const [datasetId, setDatasetId] = React.useState("");
@@ -48228,6 +48123,12 @@ function WidgetDashboard({
48228
48123
  const [editInitialQuery, setEditInitialQuery] = React.useState("");
48229
48124
  const [editingWidget, setEditingWidget] = React.useState(null);
48230
48125
  const [widgetResetFunctions, setWidgetResetFunctions] = React.useState(/* @__PURE__ */ new Map());
48126
+ const displayWidgets = React.useMemo(() => {
48127
+ if (focusWidgetId) {
48128
+ return widgets.filter((w) => w.id === focusWidgetId);
48129
+ }
48130
+ return widgets;
48131
+ }, [widgets, focusWidgetId]);
48231
48132
  const getWidgetFilterStatus = React.useCallback((widgetId) => {
48232
48133
  if (!filterResults) return null;
48233
48134
  const result = filterResults.results.find((r) => r.widgetId === widgetId);
@@ -48826,7 +48727,7 @@ function WidgetDashboard({
48826
48727
  };
48827
48728
  const getLayoutFromWidgets = () => {
48828
48729
  const processedIds = /* @__PURE__ */ new Set();
48829
- return widgets.filter((widget) => {
48730
+ return displayWidgets.filter((widget) => {
48830
48731
  if (processedIds.has(widget.id)) {
48831
48732
  return false;
48832
48733
  }
@@ -48834,6 +48735,22 @@ function WidgetDashboard({
48834
48735
  return true;
48835
48736
  }).map((widget) => {
48836
48737
  widget.type === "text";
48738
+ if (focusWidgetId && widget.id === focusWidgetId) {
48739
+ return {
48740
+ i: widget.id,
48741
+ x: 0,
48742
+ y: 0,
48743
+ w: 12,
48744
+ // Full width
48745
+ h: 10,
48746
+ // Increased height for presentation
48747
+ minW: 0,
48748
+ minH: 1,
48749
+ isResizable: false,
48750
+ static: true
48751
+ // Prevent any movement in focus mode
48752
+ };
48753
+ }
48837
48754
  return {
48838
48755
  i: widget.id,
48839
48756
  x: widget.position_x,
@@ -48916,11 +48833,15 @@ function WidgetDashboard({
48916
48833
  compactType: "vertical",
48917
48834
  containerPadding: [0, 0],
48918
48835
  margin: [16, 16],
48919
- children: widgets.map((w) => {
48836
+ children: displayWidgets.map((w) => {
48920
48837
  var _a, _b;
48921
48838
  const filterStatus = w.type === "agent" ? getWidgetFilterStatus(w.id) : null;
48922
48839
  const badgeInfo = filterStatus ? getFilterStatusBadge(filterStatus.status) : null;
48923
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `${w.type === "text" || w.type === "spacer" ? `${((_b = (_a = w == null ? void 0 : w.config) == null ? void 0 : _a.content) == null ? void 0 : _b.divider) === "yes" && "border-b border-gray-300"} ${isEditing ? "shadow-lg rounded-xl border border-primary-300" : "flex items-center"}` : `shadow-lg rounded-xl border border-primary-300 p-4 ${isEditing ? "pb-14" : "pb-5"}`} relative`, children: [
48840
+ const isFocusMode = focusWidgetId && w.id === focusWidgetId;
48841
+ const widgetBaseStyles = "rounded-xl border border-gray-200 !bg-white";
48842
+ const widgetHoverStyles = isEditing ? "hover:border-primary-500 hover:shadow-lg transition-all duration-200" : "";
48843
+ const widgetShadow = "shadow-[0_2px_8px_-2px_rgba(0,0,0,0.15)]";
48844
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { "data-widget-id": w.id, className: `${w.type === "text" || w.type === "spacer" ? `${((_b = (_a = w == null ? void 0 : w.config) == null ? void 0 : _a.content) == null ? void 0 : _b.divider) === "yes" && "border-b border-gray-300"} ${isEditing ? `${widgetBaseStyles} ${widgetShadow} ${widgetHoverStyles}` : "flex items-center"}` : `${widgetBaseStyles} ${widgetShadow} ${widgetHoverStyles} p-4 ${isEditing ? "pb-14" : "pb-5"}`} ${isFocusMode ? "h-full" : ""} relative`, children: [
48924
48845
  w.type === "agent" && badgeInfo && !isApplyingFilters && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute top-2 right-2 z-10", title: (filterStatus == null ? void 0 : filterStatus.reason) || (filterStatus == null ? void 0 : filterStatus.error) || "", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Badge, { variant: badgeInfo.variant, className: "text-[10px] px-2 py-0.5 gap-1", children: [
48925
48846
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: badgeInfo.icon }),
48926
48847
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: badgeInfo.label })
@@ -48963,6 +48884,366 @@ function WidgetDashboard({
48963
48884
  ] });
48964
48885
  }
48965
48886
 
48887
+ const EXCLUDED_WIDGET_TYPES = ["text", "spacer", "filter", "filters", "Text", "Spacer", "Filter", "Filters"];
48888
+ const LaserPointerIcon = ({ className }) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
48889
+ "svg",
48890
+ {
48891
+ viewBox: "0 0 24 24",
48892
+ fill: "none",
48893
+ stroke: "currentColor",
48894
+ strokeWidth: "2",
48895
+ strokeLinecap: "round",
48896
+ strokeLinejoin: "round",
48897
+ className,
48898
+ children: [
48899
+ /* @__PURE__ */ jsxRuntimeExports.jsx("circle", { cx: "12", cy: "12", r: "3", fill: "currentColor" }),
48900
+ /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "12", y1: "2", x2: "12", y2: "6" }),
48901
+ /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "12", y1: "18", x2: "12", y2: "22" }),
48902
+ /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "2", y1: "12", x2: "6", y2: "12" }),
48903
+ /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "18", y1: "12", x2: "22", y2: "12" })
48904
+ ]
48905
+ }
48906
+ );
48907
+ function PresentationMode({
48908
+ isOpen,
48909
+ onClose,
48910
+ pageId,
48911
+ dashboardTitle,
48912
+ widgetBackendUrl = "http://localhost:3001",
48913
+ branding = { title: "DASHBOARD", subtitle: "COMPOSER" }
48914
+ }) {
48915
+ const [viewMode, setViewMode] = React.useState("grid");
48916
+ const [widgets, setWidgets] = React.useState([]);
48917
+ const [focusableWidgets, setFocusableWidgets] = React.useState([]);
48918
+ const [currentFocusIndex, setCurrentFocusIndex] = React.useState(0);
48919
+ const [loading, setLoading] = React.useState(true);
48920
+ const [laserPointerActive, setLaserPointerActive] = React.useState(false);
48921
+ const [mousePosition, setMousePosition] = React.useState({ x: 0, y: 0 });
48922
+ const focusContainerRef = React.useRef(null);
48923
+ const gridContainerRef = React.useRef(null);
48924
+ React.useEffect(() => {
48925
+ if (isOpen && pageId) {
48926
+ setLoading(true);
48927
+ setCurrentFocusIndex(0);
48928
+ fetch(`${widgetBackendUrl}/api/widgets?page_id=${pageId}`).then((res) => {
48929
+ if (!res.ok) throw new Error("Failed to fetch widgets");
48930
+ return res.json();
48931
+ }).then((data) => {
48932
+ const widgetsArray = Array.isArray(data) ? data : [];
48933
+ setWidgets(widgetsArray);
48934
+ const focusable = widgetsArray.filter((widget) => !EXCLUDED_WIDGET_TYPES.includes(widget.type)).sort((a, b) => {
48935
+ if (a.position_y !== b.position_y) return a.position_y - b.position_y;
48936
+ return a.position_x - b.position_x;
48937
+ });
48938
+ setFocusableWidgets(focusable);
48939
+ console.log(`[PresentationMode] Loaded ${widgetsArray.length} widgets, ${focusable.length} focusable`);
48940
+ }).catch((error) => {
48941
+ console.error("Failed to fetch widgets:", error);
48942
+ setWidgets([]);
48943
+ setFocusableWidgets([]);
48944
+ }).finally(() => {
48945
+ setLoading(false);
48946
+ });
48947
+ }
48948
+ }, [isOpen, pageId, widgetBackendUrl]);
48949
+ React.useEffect(() => {
48950
+ if (focusableWidgets.length > 0 && currentFocusIndex >= focusableWidgets.length) {
48951
+ setCurrentFocusIndex(focusableWidgets.length - 1);
48952
+ }
48953
+ }, [focusableWidgets.length, currentFocusIndex]);
48954
+ React.useEffect(() => {
48955
+ if (!laserPointerActive) return;
48956
+ const handleMouseMove = (e) => {
48957
+ setMousePosition({ x: e.clientX, y: e.clientY });
48958
+ };
48959
+ window.addEventListener("mousemove", handleMouseMove);
48960
+ return () => window.removeEventListener("mousemove", handleMouseMove);
48961
+ }, [laserPointerActive]);
48962
+ React.useEffect(() => {
48963
+ if (!isOpen || viewMode !== "grid" || !gridContainerRef.current) return;
48964
+ const setupWidgetInteractions = () => {
48965
+ var _a;
48966
+ const gridItems = (_a = gridContainerRef.current) == null ? void 0 : _a.querySelectorAll(".react-grid-item");
48967
+ if (!gridItems) return;
48968
+ const handleMouseEnter = (e) => {
48969
+ var _a2;
48970
+ const item = e.currentTarget;
48971
+ const widgetId = item.getAttribute("data-widget-id") || ((_a2 = item.querySelector("[data-widget-id]")) == null ? void 0 : _a2.getAttribute("data-widget-id"));
48972
+ const widget = widgets.find((w) => w.id === widgetId);
48973
+ if (widget && EXCLUDED_WIDGET_TYPES.includes(widget.type)) {
48974
+ return;
48975
+ }
48976
+ item.style.cursor = "pointer";
48977
+ item.style.boxShadow = "0 0 0 3px var(--primary-500, #3b82f6), 0 10px 30px -5px rgba(0, 0, 0, 0.2)";
48978
+ item.style.transition = "box-shadow 0.2s ease-out";
48979
+ item.style.zIndex = "10";
48980
+ };
48981
+ const handleMouseLeave = (e) => {
48982
+ const item = e.currentTarget;
48983
+ item.style.cursor = "";
48984
+ item.style.boxShadow = "";
48985
+ item.style.zIndex = "";
48986
+ };
48987
+ const handleClick = (e) => {
48988
+ var _a2;
48989
+ const item = e.currentTarget;
48990
+ const widgetId = item.getAttribute("data-widget-id") || ((_a2 = item.querySelector("[data-widget-id]")) == null ? void 0 : _a2.getAttribute("data-widget-id"));
48991
+ const widget = widgets.find((w) => w.id === widgetId);
48992
+ if (widget && EXCLUDED_WIDGET_TYPES.includes(widget.type)) {
48993
+ return;
48994
+ }
48995
+ if (widgetId) {
48996
+ const index = focusableWidgets.findIndex((w) => w.id === widgetId);
48997
+ if (index !== -1) {
48998
+ setCurrentFocusIndex(index);
48999
+ setViewMode("focus");
49000
+ }
49001
+ }
49002
+ };
49003
+ gridItems.forEach((item) => {
49004
+ item.addEventListener("mouseenter", handleMouseEnter);
49005
+ item.addEventListener("mouseleave", handleMouseLeave);
49006
+ item.addEventListener("click", handleClick);
49007
+ });
49008
+ return () => {
49009
+ gridItems.forEach((item) => {
49010
+ item.removeEventListener("mouseenter", handleMouseEnter);
49011
+ item.removeEventListener("mouseleave", handleMouseLeave);
49012
+ item.removeEventListener("click", handleClick);
49013
+ item.style.cursor = "";
49014
+ item.style.transform = "";
49015
+ item.style.boxShadow = "";
49016
+ });
49017
+ };
49018
+ };
49019
+ const timeoutId = setTimeout(setupWidgetInteractions, 500);
49020
+ const observer = new MutationObserver(() => {
49021
+ setupWidgetInteractions();
49022
+ });
49023
+ if (gridContainerRef.current) {
49024
+ observer.observe(gridContainerRef.current, {
49025
+ childList: true,
49026
+ subtree: true
49027
+ });
49028
+ }
49029
+ return () => {
49030
+ clearTimeout(timeoutId);
49031
+ observer.disconnect();
49032
+ };
49033
+ }, [isOpen, viewMode, widgets, focusableWidgets, loading]);
49034
+ const handleKeyDown = React.useCallback(
49035
+ (e) => {
49036
+ if (!isOpen) return;
49037
+ if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) {
49038
+ return;
49039
+ }
49040
+ switch (e.key) {
49041
+ case "Escape":
49042
+ onClose();
49043
+ break;
49044
+ case "f":
49045
+ case "F":
49046
+ setViewMode((prev) => prev === "grid" ? "focus" : "grid");
49047
+ break;
49048
+ case "l":
49049
+ case "L":
49050
+ setLaserPointerActive((prev) => !prev);
49051
+ break;
49052
+ case "ArrowLeft":
49053
+ if (viewMode === "focus") {
49054
+ e.preventDefault();
49055
+ setCurrentFocusIndex(
49056
+ (prev) => prev > 0 ? prev - 1 : focusableWidgets.length - 1
49057
+ );
49058
+ }
49059
+ break;
49060
+ case "ArrowRight":
49061
+ if (viewMode === "focus") {
49062
+ e.preventDefault();
49063
+ setCurrentFocusIndex(
49064
+ (prev) => prev < focusableWidgets.length - 1 ? prev + 1 : 0
49065
+ );
49066
+ }
49067
+ break;
49068
+ }
49069
+ },
49070
+ [isOpen, onClose, viewMode, focusableWidgets.length]
49071
+ );
49072
+ React.useEffect(() => {
49073
+ window.addEventListener("keydown", handleKeyDown);
49074
+ return () => window.removeEventListener("keydown", handleKeyDown);
49075
+ }, [handleKeyDown]);
49076
+ React.useEffect(() => {
49077
+ if (isOpen) {
49078
+ document.body.style.overflow = "hidden";
49079
+ } else {
49080
+ document.body.style.overflow = "";
49081
+ }
49082
+ return () => {
49083
+ document.body.style.overflow = "";
49084
+ };
49085
+ }, [isOpen]);
49086
+ React.useEffect(() => {
49087
+ if (!isOpen) {
49088
+ setViewMode("grid");
49089
+ setCurrentFocusIndex(0);
49090
+ setLaserPointerActive(false);
49091
+ }
49092
+ }, [isOpen]);
49093
+ if (!isOpen) return null;
49094
+ const currentFocusWidget = focusableWidgets[currentFocusIndex];
49095
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "fixed inset-0 z-50 bg-white flex flex-col", children: [
49096
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("header", { className: "flex items-center justify-between px-6 py-4 border-b border-gray-200 bg-white shrink-0", children: [
49097
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col", children: [
49098
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xl font-bold text-primary-700 tracking-wide", children: branding.title }),
49099
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-primary-500 tracking-[0.2em] -mt-1", children: branding.subtitle })
49100
+ ] }) }),
49101
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "absolute left-1/2 transform -translate-x-1/2 text-center", children: [
49102
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h1", { className: "text-lg font-bold text-gray-900 uppercase tracking-wide", children: dashboardTitle }),
49103
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-12 h-1 bg-primary-600 mx-auto mt-1 rounded" })
49104
+ ] }),
49105
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
49106
+ "button",
49107
+ {
49108
+ onClick: onClose,
49109
+ className: "p-2 hover:bg-gray-100 rounded-lg transition-colors",
49110
+ "aria-label": "Close presentation",
49111
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.X, { className: "w-6 h-6 text-gray-600" })
49112
+ }
49113
+ )
49114
+ ] }),
49115
+ /* @__PURE__ */ jsxRuntimeExports.jsx("main", { className: `flex-1 min-h-0 ${viewMode === "grid" ? "overflow-auto bg-gray-50 p-6" : "overflow-hidden bg-gray-100"}`, children: loading ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center gap-3", children: [
49116
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-8 h-8 border-4 border-primary-600 border-t-transparent rounded-full animate-spin" }),
49117
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-600", children: "Loading widgets..." })
49118
+ ] }) }) : viewMode === "grid" ? (
49119
+ /* Grid View - Show all widgets using WidgetDashboard */
49120
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-full relative", ref: gridContainerRef, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
49121
+ WidgetDashboard,
49122
+ {
49123
+ pageId,
49124
+ isEditing: false,
49125
+ selectedWidget: null,
49126
+ onWidgetSelect: () => {
49127
+ },
49128
+ openWidgetPallete: false,
49129
+ onCloseWidgetPallete: () => {
49130
+ },
49131
+ onApplyFilters: () => {
49132
+ },
49133
+ isApplyingFilters: false,
49134
+ onSaveLayoutReady: () => {
49135
+ },
49136
+ widgetBackendUrl
49137
+ },
49138
+ `presentation-grid-${pageId}`
49139
+ ) })
49140
+ ) : (
49141
+ /* Focus View - Show one widget at a time */
49142
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-full flex flex-col", ref: focusContainerRef, children: focusableWidgets.length > 0 && currentFocusWidget ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 flex flex-col min-h-0", children: [
49143
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "shrink-0 bg-white border-b border-gray-200 px-6 py-3 flex items-center justify-between", children: [
49144
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
49145
+ "button",
49146
+ {
49147
+ onClick: () => setCurrentFocusIndex((prev) => prev > 0 ? prev - 1 : focusableWidgets.length - 1),
49148
+ className: "p-2 rounded-full hover:bg-gray-100 transition-colors disabled:opacity-30",
49149
+ disabled: focusableWidgets.length <= 1,
49150
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.ChevronLeft, { className: "w-5 h-5 text-gray-600" })
49151
+ }
49152
+ ),
49153
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-sm text-gray-500", children: [
49154
+ currentFocusIndex + 1,
49155
+ " of ",
49156
+ focusableWidgets.length
49157
+ ] }) }),
49158
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
49159
+ "button",
49160
+ {
49161
+ onClick: () => setCurrentFocusIndex((prev) => prev < focusableWidgets.length - 1 ? prev + 1 : 0),
49162
+ className: "p-2 rounded-full hover:bg-gray-100 transition-colors disabled:opacity-30",
49163
+ disabled: focusableWidgets.length <= 1,
49164
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.ChevronRight, { className: "w-5 h-5 text-gray-600" })
49165
+ }
49166
+ )
49167
+ ] }),
49168
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 bg-white p-6 min-h-0 overflow-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-full w-full rounded-xl border border-gray-200 bg-white shadow-sm overflow-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
49169
+ WidgetRenderer,
49170
+ {
49171
+ widget: currentFocusWidget,
49172
+ widgetBackendUrl,
49173
+ pageId,
49174
+ isEditing: false
49175
+ },
49176
+ `focus-widget-${currentFocusWidget.id}`
49177
+ ) }) })
49178
+ ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-center text-gray-500", children: [
49179
+ /* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.Maximize2, { className: "w-12 h-12 mx-auto mb-4 text-gray-300" }),
49180
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-lg font-medium", children: "No widgets available for focus view" }),
49181
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm mt-2", children: "Text, Spacer, and Filter widgets are excluded." })
49182
+ ] }) }) })
49183
+ ) }),
49184
+ /* @__PURE__ */ jsxRuntimeExports.jsx("footer", { className: "bg-white border-t border-gray-200 py-4 shrink-0", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center gap-3", children: [
49185
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1 bg-gray-100 rounded-full p-1", children: [
49186
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
49187
+ "button",
49188
+ {
49189
+ onClick: () => setViewMode("grid"),
49190
+ className: `flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all ${viewMode === "grid" ? "bg-primary-700 text-white shadow-md" : "text-gray-600 hover:text-gray-900"}`,
49191
+ children: [
49192
+ /* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.Grid3X3, { className: "w-4 h-4" }),
49193
+ "Grid"
49194
+ ]
49195
+ }
49196
+ ),
49197
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
49198
+ "button",
49199
+ {
49200
+ onClick: () => setViewMode("focus"),
49201
+ className: `flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all ${viewMode === "focus" ? "bg-primary-700 text-white shadow-md" : "text-gray-600 hover:text-gray-900"}`,
49202
+ children: [
49203
+ /* @__PURE__ */ jsxRuntimeExports.jsx(lucideReact.Maximize2, { className: "w-4 h-4" }),
49204
+ "Focus"
49205
+ ]
49206
+ }
49207
+ ),
49208
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-px h-6 bg-gray-300 mx-2" }),
49209
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
49210
+ "button",
49211
+ {
49212
+ onClick: () => setLaserPointerActive((prev) => !prev),
49213
+ className: `p-2 transition-colors rounded-full ${laserPointerActive ? "bg-primary-600 text-white" : "text-gray-600 hover:text-gray-900 hover:bg-gray-200"}`,
49214
+ "aria-label": "Toggle laser pointer (L)",
49215
+ title: "Toggle laser pointer (L)",
49216
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(LaserPointerIcon, { className: "w-4 h-4" })
49217
+ }
49218
+ ),
49219
+ viewMode === "focus" && focusableWidgets.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
49220
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-px h-6 bg-gray-300 mx-2" }),
49221
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-sm text-gray-600 px-2", children: [
49222
+ currentFocusIndex + 1,
49223
+ " / ",
49224
+ focusableWidgets.length
49225
+ ] })
49226
+ ] })
49227
+ ] }),
49228
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-400 uppercase tracking-wider", children: "ESC TO EXIT \u2022 F TO TOGGLE \u2022 L FOR LASER \u2022 ARROWS TO NAVIGATE" })
49229
+ ] }) }),
49230
+ laserPointerActive && /* @__PURE__ */ jsxRuntimeExports.jsxs(
49231
+ "div",
49232
+ {
49233
+ className: "fixed pointer-events-none z-[100] transform -translate-x-1/2 -translate-y-1/2",
49234
+ style: {
49235
+ left: mousePosition.x,
49236
+ top: mousePosition.y
49237
+ },
49238
+ children: [
49239
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute inset-0 w-8 h-8 -translate-x-1/2 -translate-y-1/2 bg-red-500/20 rounded-full blur-md" }),
49240
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute w-4 h-4 -translate-x-1/2 -translate-y-1/2 bg-red-500 rounded-full shadow-lg shadow-red-500/50" })
49241
+ ]
49242
+ }
49243
+ )
49244
+ ] });
49245
+ }
49246
+
48966
49247
  var __defProp = Object.defineProperty;
48967
49248
  var __defProps = Object.defineProperties;
48968
49249
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
@@ -49427,6 +49708,7 @@ function DashboardPages({ widgetBackendUrl }) {
49427
49708
  exports.Button = Button;
49428
49709
  exports.DashboardPages = DashboardPages;
49429
49710
  exports.Input = Input;
49711
+ exports.PresentationMode = PresentationMode;
49430
49712
  exports.SavedPages = SavedPages;
49431
49713
  exports.WidgetDashboard = WidgetDashboard;
49432
49714
  exports.WidgetPalette = WidgetPalette;