@optifye/dashboard-core 4.2.3 → 4.2.4

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.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import * as React33 from 'react';
2
- import React33__default, { createContext, memo, useState, useEffect, useRef, useCallback, useMemo, useContext, useLayoutEffect, useId, Children, isValidElement, useInsertionEffect, forwardRef, Fragment as Fragment$1, createElement, Component } from 'react';
1
+ import * as React14 from 'react';
2
+ import React14__default, { createContext, memo, useState, useEffect, useRef, useCallback, useMemo, useContext, useLayoutEffect, useId, Children, isValidElement, useInsertionEffect, forwardRef, Fragment as Fragment$1, createElement, Component } from 'react';
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
4
  import { useRouter } from 'next/router';
5
5
  import { subDays, format, parseISO, isValid, isFuture, isToday } from 'date-fns';
@@ -188,14 +188,14 @@ var _getDashboardConfigInstance = () => {
188
188
  }
189
189
  return dashboardConfigInstance;
190
190
  };
191
- var DashboardConfigContext = React33.createContext(void 0);
191
+ var DashboardConfigContext = React14.createContext(void 0);
192
192
  var DashboardProvider = ({ config: userProvidedConfig, children }) => {
193
- const fullConfig = React33.useMemo(() => mergeWithDefaultConfig(userProvidedConfig), [userProvidedConfig]);
193
+ const fullConfig = React14.useMemo(() => mergeWithDefaultConfig(userProvidedConfig), [userProvidedConfig]);
194
194
  _setDashboardConfigInstance(fullConfig);
195
- React33.useEffect(() => {
195
+ React14.useEffect(() => {
196
196
  _setDashboardConfigInstance(fullConfig);
197
197
  }, [fullConfig]);
198
- React33.useEffect(() => {
198
+ React14.useEffect(() => {
199
199
  if (!fullConfig.theme) return;
200
200
  const styleId = "dashboard-core-theme-vars";
201
201
  let styleEl = document.getElementById(styleId);
@@ -221,7 +221,7 @@ var DashboardProvider = ({ config: userProvidedConfig, children }) => {
221
221
  return /* @__PURE__ */ jsx(DashboardConfigContext.Provider, { value: fullConfig, children });
222
222
  };
223
223
  var useDashboardConfig = () => {
224
- const ctx = React33.useContext(DashboardConfigContext);
224
+ const ctx = React14.useContext(DashboardConfigContext);
225
225
  if (!ctx) throw new Error("useDashboardConfig must be used within a DashboardProvider");
226
226
  return ctx;
227
227
  };
@@ -849,6 +849,63 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
849
849
  if (recentData) {
850
850
  console.log(`[useWorkspaceDetailedMetrics] Found fallback data from date: ${recentData.date}, shift: ${recentData.shift_id}`);
851
851
  const outputDifference2 = (recentData.total_output || 0) - (recentData.ideal_output || 0);
852
+ const workspaceMatch2 = recentData.workspace_name?.match(/WS(\d+)/);
853
+ const workspaceNumber2 = workspaceMatch2 ? parseInt(workspaceMatch2[1]) : 0;
854
+ const specialWsStart2 = workspaceConfig.specialWorkspaces?.startId ?? 19;
855
+ const specialWsEnd2 = workspaceConfig.specialWorkspaces?.endId ?? 34;
856
+ const isSpecialWorkspace2 = workspaceNumber2 >= specialWsStart2 && workspaceNumber2 <= specialWsEnd2;
857
+ const outputHourly2 = recentData.output_hourly || {};
858
+ const hasOutputHourlyData2 = outputHourly2 && typeof outputHourly2 === "object" && Object.keys(outputHourly2).length > 0;
859
+ let hourlyActionCounts2 = [];
860
+ if (hasOutputHourlyData2) {
861
+ console.log("Using new output_hourly column for workspace (fallback):", recentData.workspace_name);
862
+ console.log("Raw output_hourly data (fallback):", outputHourly2);
863
+ const isNightShift = recentData.shift_id === 1;
864
+ const shiftStart = recentData.shift_start || (isNightShift ? "22:00" : "06:00");
865
+ const shiftEnd = recentData.shift_end || (isNightShift ? "06:00" : "14:00");
866
+ const startHour = parseInt(shiftStart.split(":")[0]);
867
+ let expectedHours = [];
868
+ if (isNightShift) {
869
+ for (let i = 0; i < 9; i++) {
870
+ expectedHours.push((startHour + i) % 24);
871
+ }
872
+ } else {
873
+ for (let i = 0; i < 9; i++) {
874
+ expectedHours.push((startHour + i) % 24);
875
+ }
876
+ }
877
+ console.log("Expected shift hours (fallback):", expectedHours);
878
+ console.log("Available data hours (fallback):", Object.keys(outputHourly2));
879
+ hourlyActionCounts2 = expectedHours.map((expectedHour) => {
880
+ let hourData = outputHourly2[expectedHour.toString()];
881
+ if (!hourData && isNightShift) {
882
+ for (const [storedHour, data2] of Object.entries(outputHourly2)) {
883
+ if (Array.isArray(data2) && data2.length > 0 && data2.some((val) => val > 0)) {
884
+ if (storedHour === "18" && expectedHour === 1) {
885
+ hourData = data2;
886
+ console.log(`Mapping stored hour ${storedHour} to expected hour ${expectedHour} (fallback)`);
887
+ break;
888
+ }
889
+ }
890
+ }
891
+ }
892
+ return Array.isArray(hourData) ? hourData.reduce((sum, count) => sum + (count || 0), 0) : 0;
893
+ });
894
+ console.log("Final hourly action counts (fallback):", hourlyActionCounts2);
895
+ } else {
896
+ console.log("Using output_array fallback for workspace (fallback):", recentData.workspace_name);
897
+ const minuteByMinuteArray = recentData.output_array || [];
898
+ if (isSpecialWorkspace2) {
899
+ const last40Readings = minuteByMinuteArray.slice(Math.max(0, minuteByMinuteArray.length - 40));
900
+ hourlyActionCounts2 = last40Readings;
901
+ } else {
902
+ for (let i = 0; i < minuteByMinuteArray.length; i += 60) {
903
+ const hourSlice = minuteByMinuteArray.slice(i, Math.min(i + 60, minuteByMinuteArray.length));
904
+ const hourlySum = hourSlice.reduce((sum, count) => sum + count, 0);
905
+ hourlyActionCounts2.push(hourlySum);
906
+ }
907
+ }
908
+ }
852
909
  const transformedData2 = {
853
910
  workspace_id: recentData.workspace_id,
854
911
  workspace_name: recentData.workspace_name,
@@ -869,12 +926,14 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
869
926
  ideal_cycle_time: recentData.ideal_cycle_time || 0,
870
927
  avg_efficiency: recentData.efficiency || 0,
871
928
  total_actions: recentData.total_output || 0,
872
- hourly_action_counts: recentData.output_array || [],
929
+ hourly_action_counts: hourlyActionCounts2,
930
+ // Now uses the NEW logic with fallback
873
931
  workspace_rank: recentData.workspace_rank || 0,
874
932
  total_workspaces: recentData.total_workspaces || workspaceConfig.totalWorkspaces || 42,
875
933
  ideal_output_until_now: recentData.ideal_output || 0,
876
934
  output_difference: outputDifference2,
877
935
  idle_time: recentData.idle_time || 0,
936
+ idle_time_hourly: recentData.idle_time_hourly || void 0,
878
937
  ...recentData.compliance_efficiency !== void 0 && { compliance_efficiency: recentData.compliance_efficiency },
879
938
  ...recentData.sop_check !== void 0 && { sop_check: recentData.sop_check }
880
939
  };
@@ -901,17 +960,66 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
901
960
  const specialWsStart = workspaceConfig.specialWorkspaces?.startId ?? 19;
902
961
  const specialWsEnd = workspaceConfig.specialWorkspaces?.endId ?? 34;
903
962
  const isSpecialWorkspace = workspaceNumber >= specialWsStart && workspaceNumber <= specialWsEnd;
904
- const minuteByMinuteArray = data.output_array || [];
963
+ const outputHourly = data.output_hourly || {};
964
+ console.log("[DEBUG] Raw data.output_hourly:", data.output_hourly);
965
+ console.log("[DEBUG] outputHourly after || {}:", outputHourly);
966
+ console.log("[DEBUG] typeof outputHourly:", typeof outputHourly);
967
+ console.log("[DEBUG] Object.keys(outputHourly):", Object.keys(outputHourly));
968
+ console.log("[DEBUG] Object.keys(outputHourly).length:", Object.keys(outputHourly).length);
969
+ const hasOutputHourlyData = outputHourly && typeof outputHourly === "object" && Object.keys(outputHourly).length > 0;
970
+ console.log("[DEBUG] hasOutputHourlyData:", hasOutputHourlyData);
905
971
  let hourlyActionCounts = [];
906
- if (isSpecialWorkspace) {
907
- const last40Readings = minuteByMinuteArray.slice(Math.max(0, minuteByMinuteArray.length - 40));
908
- hourlyActionCounts = last40Readings;
972
+ if (hasOutputHourlyData) {
973
+ console.log("\u2705 Using new output_hourly column for workspace:", data.workspace_name);
974
+ console.log("Raw output_hourly data:", JSON.stringify(outputHourly));
975
+ const isNightShift = data.shift_id === 1;
976
+ const shiftStart = data.shift_start || (isNightShift ? "22:00" : "06:00");
977
+ const shiftEnd = data.shift_end || (isNightShift ? "06:00" : "14:00");
978
+ const startHour = parseInt(shiftStart.split(":")[0]);
979
+ let expectedHours = [];
980
+ if (isNightShift) {
981
+ for (let i = 0; i < 9; i++) {
982
+ expectedHours.push((startHour + i) % 24);
983
+ }
984
+ } else {
985
+ for (let i = 0; i < 9; i++) {
986
+ expectedHours.push((startHour + i) % 24);
987
+ }
988
+ }
989
+ console.log("Expected shift hours:", expectedHours);
990
+ console.log("Available data hours:", Object.keys(outputHourly));
991
+ hourlyActionCounts = expectedHours.map((expectedHour) => {
992
+ let hourData = outputHourly[expectedHour.toString()];
993
+ if (!hourData && isNightShift) {
994
+ for (const [storedHour, data2] of Object.entries(outputHourly)) {
995
+ if (Array.isArray(data2) && data2.length > 0 && data2.some((val) => val > 0)) {
996
+ if (storedHour === "18" && expectedHour === 1) {
997
+ hourData = data2;
998
+ console.log(`Mapping stored hour ${storedHour} to expected hour ${expectedHour}`);
999
+ break;
1000
+ }
1001
+ }
1002
+ }
1003
+ }
1004
+ return Array.isArray(hourData) ? hourData.reduce((sum, count) => sum + (count || 0), 0) : 0;
1005
+ });
1006
+ console.log("Final hourly action counts:", hourlyActionCounts);
909
1007
  } else {
910
- for (let i = 0; i < minuteByMinuteArray.length; i += 60) {
911
- const hourSlice = minuteByMinuteArray.slice(i, Math.min(i + 60, minuteByMinuteArray.length));
912
- const hourlySum = hourSlice.reduce((sum, count) => sum + count, 0);
913
- hourlyActionCounts.push(hourlySum);
1008
+ console.log("\u274C Using output_array fallback for workspace:", data.workspace_name);
1009
+ console.log("[DEBUG] Fallback reason - hasOutputHourlyData is false");
1010
+ console.log("[DEBUG] data.output_hourly was:", data.output_hourly);
1011
+ const minuteByMinuteArray = data.output_array || [];
1012
+ if (isSpecialWorkspace) {
1013
+ const last40Readings = minuteByMinuteArray.slice(Math.max(0, minuteByMinuteArray.length - 40));
1014
+ hourlyActionCounts = last40Readings;
1015
+ } else {
1016
+ for (let i = 0; i < minuteByMinuteArray.length; i += 60) {
1017
+ const hourSlice = minuteByMinuteArray.slice(i, Math.min(i + 60, minuteByMinuteArray.length));
1018
+ const hourlySum = hourSlice.reduce((sum, count) => sum + count, 0);
1019
+ hourlyActionCounts.push(hourlySum);
1020
+ }
914
1021
  }
1022
+ console.log("Final hourly action counts:", hourlyActionCounts);
915
1023
  }
916
1024
  const transformedData = {
917
1025
  workspace_id: data.workspace_id,
@@ -940,6 +1048,8 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
940
1048
  output_difference: outputDifference,
941
1049
  idle_time: data.idle_time || 0,
942
1050
  // Add idle_time from performance_metrics table
1051
+ idle_time_hourly: data.idle_time_hourly || void 0,
1052
+ // Add idle_time_hourly from performance_metrics table
943
1053
  ...data.compliance_efficiency !== void 0 && { compliance_efficiency: data.compliance_efficiency },
944
1054
  ...data.sop_check !== void 0 && { sop_check: data.sop_check }
945
1055
  };
@@ -1460,16 +1570,56 @@ var dashboardService = {
1460
1570
  const specialStart = workspaceConfig.specialWorkspaces?.startId ?? 19;
1461
1571
  const specialEnd = workspaceConfig.specialWorkspaces?.endId ?? 34;
1462
1572
  const isSpecialWorkspace = workspaceNumber >= specialStart && workspaceNumber <= specialEnd;
1463
- const minuteByMinuteArray = data.output_array || [];
1573
+ const outputHourly = data.output_hourly || {};
1574
+ const hasOutputHourlyData = outputHourly && typeof outputHourly === "object" && Object.keys(outputHourly).length > 0;
1464
1575
  let hourlyActionCounts = [];
1465
- if (isSpecialWorkspace) {
1466
- const numReadings = workspaceConfig.specialWorkspaces?.hourlyReadingsCount ?? 40;
1467
- hourlyActionCounts = minuteByMinuteArray.slice(-numReadings);
1576
+ if (hasOutputHourlyData) {
1577
+ console.log("Using new output_hourly column for workspace:", data.workspace_name);
1578
+ console.log("Raw output_hourly data:", outputHourly);
1579
+ const isNightShift = data.shift_id === 1;
1580
+ const shiftStart = data.shift_start || (isNightShift ? "22:00" : "06:00");
1581
+ const shiftEnd = data.shift_end || (isNightShift ? "06:00" : "14:00");
1582
+ const startHour = parseInt(shiftStart.split(":")[0]);
1583
+ let expectedHours = [];
1584
+ if (isNightShift) {
1585
+ for (let i = 0; i < 9; i++) {
1586
+ expectedHours.push((startHour + i) % 24);
1587
+ }
1588
+ } else {
1589
+ for (let i = 0; i < 9; i++) {
1590
+ expectedHours.push((startHour + i) % 24);
1591
+ }
1592
+ }
1593
+ console.log("Expected shift hours:", expectedHours);
1594
+ console.log("Available data hours:", Object.keys(outputHourly));
1595
+ hourlyActionCounts = expectedHours.map((expectedHour) => {
1596
+ let hourData = outputHourly[expectedHour.toString()];
1597
+ if (!hourData && isNightShift) {
1598
+ for (const [storedHour, data2] of Object.entries(outputHourly)) {
1599
+ if (Array.isArray(data2) && data2.length > 0 && data2.some((val) => val > 0)) {
1600
+ if (storedHour === "18" && expectedHour === 1) {
1601
+ hourData = data2;
1602
+ console.log(`Mapping stored hour ${storedHour} to expected hour ${expectedHour}`);
1603
+ break;
1604
+ }
1605
+ }
1606
+ }
1607
+ }
1608
+ return Array.isArray(hourData) ? hourData.reduce((sum, count) => sum + (count || 0), 0) : 0;
1609
+ });
1610
+ console.log("Final hourly action counts:", hourlyActionCounts);
1468
1611
  } else {
1469
- for (let i = 0; i < minuteByMinuteArray.length; i += 60) {
1470
- const hourSlice = minuteByMinuteArray.slice(i, Math.min(i + 60, minuteByMinuteArray.length));
1471
- const hourlySum = hourSlice.reduce((sum, count) => sum + (count ?? 0), 0);
1472
- hourlyActionCounts.push(hourlySum);
1612
+ console.log("Using output_array fallback for workspace:", data.workspace_name);
1613
+ const minuteByMinuteArray = data.output_array || [];
1614
+ if (isSpecialWorkspace) {
1615
+ const numReadings = workspaceConfig.specialWorkspaces?.hourlyReadingsCount ?? 40;
1616
+ hourlyActionCounts = minuteByMinuteArray.slice(-numReadings);
1617
+ } else {
1618
+ for (let i = 0; i < minuteByMinuteArray.length; i += 60) {
1619
+ const hourSlice = minuteByMinuteArray.slice(i, Math.min(i + 60, minuteByMinuteArray.length));
1620
+ const hourlySum = hourSlice.reduce((sum, count) => sum + (count ?? 0), 0);
1621
+ hourlyActionCounts.push(hourlySum);
1622
+ }
1473
1623
  }
1474
1624
  }
1475
1625
  const transformedData = {
@@ -1498,6 +1648,7 @@ var dashboardService = {
1498
1648
  ideal_output_until_now: data.ideal_output || 0,
1499
1649
  output_difference: outputDifference,
1500
1650
  idle_time: data.idle_time || 0,
1651
+ idle_time_hourly: data.idle_time_hourly || void 0,
1501
1652
  ...data.compliance_efficiency !== void 0 && { compliance_efficiency: data.compliance_efficiency },
1502
1653
  ...data.sop_check !== void 0 && { sop_check: data.sop_check }
1503
1654
  };
@@ -4284,8 +4435,26 @@ async function initializeWorkspaceDisplayNames(explicitLineId) {
4284
4435
  isInitializing = false;
4285
4436
  }
4286
4437
  }
4438
+ var preInitializeWorkspaceDisplayNames = async (lineId) => {
4439
+ console.log("\u{1F504} preInitializeWorkspaceDisplayNames called for lineId:", lineId);
4440
+ if (isInitialized || isInitializing) {
4441
+ console.log("\u{1F504} Already initialized or initializing, skipping pre-init");
4442
+ return;
4443
+ }
4444
+ await initializeWorkspaceDisplayNames(lineId);
4445
+ };
4446
+ var forceRefreshWorkspaceDisplayNames = async (lineId) => {
4447
+ console.log("\u{1F504} forceRefreshWorkspaceDisplayNames called for lineId:", lineId);
4448
+ clearWorkspaceDisplayNamesCache();
4449
+ await initializeWorkspaceDisplayNames(lineId);
4450
+ };
4287
4451
  console.log("\u{1F504} Module loaded, will initialize lazily when first function is called");
4288
4452
  var getWorkspaceDisplayName = (workspaceId, lineId) => {
4453
+ if (!isInitialized && !isInitializing) {
4454
+ console.log(`\u{1F504} [DEBUG] getWorkspaceDisplayName(${workspaceId}) - Not initialized, triggering lazy init...`);
4455
+ } else if (isInitializing) {
4456
+ console.log(`\u{1F504} [DEBUG] getWorkspaceDisplayName(${workspaceId}) - Currently initializing...`);
4457
+ }
4289
4458
  if (!isInitialized && !isInitializing) {
4290
4459
  console.log("\u{1F504} Lazy initialization triggered by getWorkspaceDisplayName");
4291
4460
  initializeWorkspaceDisplayNames(lineId).catch((error) => {
@@ -4369,6 +4538,7 @@ var clearWorkspaceDisplayNamesCache = () => {
4369
4538
  workspaceService.clearWorkspaceDisplayNamesCache();
4370
4539
  runtimeWorkspaceDisplayNames = {};
4371
4540
  isInitialized = false;
4541
+ isInitializing = false;
4372
4542
  };
4373
4543
 
4374
4544
  // src/lib/hooks/useWorkspaceDisplayNames.ts
@@ -8037,7 +8207,7 @@ var MotionConfigContext = createContext({
8037
8207
  });
8038
8208
 
8039
8209
  // ../../node_modules/framer-motion/dist/es/components/AnimatePresence/PopChild.mjs
8040
- var PopChildMeasure = class extends React33.Component {
8210
+ var PopChildMeasure = class extends React14.Component {
8041
8211
  getSnapshotBeforeUpdate(prevProps) {
8042
8212
  const element = this.props.childRef.current;
8043
8213
  if (element && prevProps.isPresent && !this.props.isPresent) {
@@ -8092,7 +8262,7 @@ function PopChild({ children, isPresent }) {
8092
8262
  document.head.removeChild(style);
8093
8263
  };
8094
8264
  }, [isPresent]);
8095
- return jsx(PopChildMeasure, { isPresent, childRef: ref, sizeRef: size, children: React33.cloneElement(children, { ref }) });
8265
+ return jsx(PopChildMeasure, { isPresent, childRef: ref, sizeRef: size, children: React14.cloneElement(children, { ref }) });
8096
8266
  }
8097
8267
 
8098
8268
  // ../../node_modules/framer-motion/dist/es/components/AnimatePresence/PresenceChild.mjs
@@ -8129,7 +8299,7 @@ var PresenceChild = ({ children, initial, isPresent, onExitComplete, custom, pre
8129
8299
  useMemo(() => {
8130
8300
  presenceChildren.forEach((_, key) => presenceChildren.set(key, false));
8131
8301
  }, [isPresent]);
8132
- React33.useEffect(() => {
8302
+ React14.useEffect(() => {
8133
8303
  !isPresent && !presenceChildren.size && onExitComplete && onExitComplete();
8134
8304
  }, [isPresent]);
8135
8305
  if (mode === "popLayout") {
@@ -15398,7 +15568,7 @@ var LoadingPage = ({
15398
15568
  subMessage = "Please wait while we prepare your data",
15399
15569
  className
15400
15570
  }) => {
15401
- React33__default.useEffect(() => {
15571
+ React14__default.useEffect(() => {
15402
15572
  console.log("LoadingPage rendered with message:", message);
15403
15573
  const timeout = setTimeout(() => {
15404
15574
  console.warn("LoadingPage has been visible for more than 8 seconds. This might indicate an issue.");
@@ -15441,10 +15611,10 @@ var withAuth = (WrappedComponent2, options) => {
15441
15611
  return function WithAuthComponent(props) {
15442
15612
  const { session, loading } = useAuth();
15443
15613
  const router = useRouter();
15444
- React33.useEffect(() => {
15614
+ React14.useEffect(() => {
15445
15615
  console.log("withAuth state:", { loading, hasSession: !!session, requireAuth: defaultOptions.requireAuth });
15446
15616
  }, [session, loading]);
15447
- React33.useEffect(() => {
15617
+ React14.useEffect(() => {
15448
15618
  if (!loading && defaultOptions.requireAuth && !session) {
15449
15619
  console.log("Redirecting to login from withAuth");
15450
15620
  router.replace(defaultOptions.redirectTo);
@@ -16131,10 +16301,10 @@ var CycleTimeOverTimeChart = ({
16131
16301
  };
16132
16302
  const displayData = getDisplayData(data);
16133
16303
  const DURATION = displayData.length;
16134
- const [animatedData, setAnimatedData] = React33__default.useState(Array(DURATION).fill(0));
16135
- const prevDataRef = React33__default.useRef(Array(DURATION).fill(0));
16136
- const animationFrameRef = React33__default.useRef(null);
16137
- const animateToNewData = React33__default.useCallback((targetData) => {
16304
+ const [animatedData, setAnimatedData] = React14__default.useState(Array(DURATION).fill(0));
16305
+ const prevDataRef = React14__default.useRef(Array(DURATION).fill(0));
16306
+ const animationFrameRef = React14__default.useRef(null);
16307
+ const animateToNewData = React14__default.useCallback((targetData) => {
16138
16308
  const startData = [...prevDataRef.current];
16139
16309
  const startTime = performance.now();
16140
16310
  const duration = 1200;
@@ -16164,7 +16334,7 @@ var CycleTimeOverTimeChart = ({
16164
16334
  }
16165
16335
  animationFrameRef.current = requestAnimationFrame(animate);
16166
16336
  }, []);
16167
- React33__default.useEffect(() => {
16337
+ React14__default.useEffect(() => {
16168
16338
  if (JSON.stringify(data) !== JSON.stringify(prevDataRef.current)) {
16169
16339
  const processedData = getDisplayData(data);
16170
16340
  animateToNewData(processedData);
@@ -16388,7 +16558,7 @@ var CycleTimeOverTimeChart = ({
16388
16558
  renderLegend()
16389
16559
  ] });
16390
16560
  };
16391
- var Card = React33.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
16561
+ var Card = React14.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
16392
16562
  "div",
16393
16563
  {
16394
16564
  ref,
@@ -16400,7 +16570,7 @@ var Card = React33.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
16400
16570
  }
16401
16571
  ));
16402
16572
  Card.displayName = "Card";
16403
- var CardHeader = React33.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
16573
+ var CardHeader = React14.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
16404
16574
  "div",
16405
16575
  {
16406
16576
  ref,
@@ -16409,7 +16579,7 @@ var CardHeader = React33.forwardRef(({ className, ...props }, ref) => /* @__PURE
16409
16579
  }
16410
16580
  ));
16411
16581
  CardHeader.displayName = "CardHeader";
16412
- var CardTitle = React33.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
16582
+ var CardTitle = React14.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
16413
16583
  "h3",
16414
16584
  {
16415
16585
  ref,
@@ -16421,7 +16591,7 @@ var CardTitle = React33.forwardRef(({ className, ...props }, ref) => /* @__PURE_
16421
16591
  }
16422
16592
  ));
16423
16593
  CardTitle.displayName = "CardTitle";
16424
- var CardDescription = React33.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
16594
+ var CardDescription = React14.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
16425
16595
  "p",
16426
16596
  {
16427
16597
  ref,
@@ -16430,9 +16600,9 @@ var CardDescription = React33.forwardRef(({ className, ...props }, ref) => /* @_
16430
16600
  }
16431
16601
  ));
16432
16602
  CardDescription.displayName = "CardDescription";
16433
- var CardContent = React33.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("p-6 pt-0", className), ...props }));
16603
+ var CardContent = React14.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("p-6 pt-0", className), ...props }));
16434
16604
  CardContent.displayName = "CardContent";
16435
- var CardFooter = React33.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
16605
+ var CardFooter = React14.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
16436
16606
  "div",
16437
16607
  {
16438
16608
  ref,
@@ -16508,7 +16678,7 @@ var buttonVariants = cva(
16508
16678
  }
16509
16679
  }
16510
16680
  );
16511
- var Button = React33.forwardRef(
16681
+ var Button = React14.forwardRef(
16512
16682
  ({ className, variant, size, asChild = false, ...props }, ref) => {
16513
16683
  const Comp = asChild ? Slot : "button";
16514
16684
  return /* @__PURE__ */ jsx(
@@ -16539,10 +16709,30 @@ var HourlyOutputChart = ({
16539
16709
  };
16540
16710
  const shiftStartTime = getTimeFromTimeString(shiftStart);
16541
16711
  const SHIFT_DURATION = 11;
16542
- const [animatedData, setAnimatedData] = React33__default.useState(Array(SHIFT_DURATION).fill(0));
16543
- const prevDataRef = React33__default.useRef(Array(SHIFT_DURATION).fill(0));
16544
- const animationFrameRef = React33__default.useRef(null);
16545
- const animateToNewData = React33__default.useCallback((targetData) => {
16712
+ const [animatedData, setAnimatedData] = React14__default.useState(Array(SHIFT_DURATION).fill(0));
16713
+ const prevDataRef = React14__default.useRef(Array(SHIFT_DURATION).fill(0));
16714
+ const animationFrameRef = React14__default.useRef(null);
16715
+ const [shouldAnimateIdle, setShouldAnimateIdle] = React14__default.useState(false);
16716
+ const prevShowIdleTimeRef = React14__default.useRef(showIdleTime);
16717
+ const animationTimeoutRef = React14__default.useRef(null);
16718
+ React14__default.useEffect(() => {
16719
+ if (showIdleTime && !prevShowIdleTimeRef.current) {
16720
+ setShouldAnimateIdle(true);
16721
+ if (animationTimeoutRef.current) {
16722
+ clearTimeout(animationTimeoutRef.current);
16723
+ }
16724
+ animationTimeoutRef.current = setTimeout(() => {
16725
+ setShouldAnimateIdle(false);
16726
+ }, 1e3);
16727
+ }
16728
+ prevShowIdleTimeRef.current = showIdleTime;
16729
+ return () => {
16730
+ if (animationTimeoutRef.current) {
16731
+ clearTimeout(animationTimeoutRef.current);
16732
+ }
16733
+ };
16734
+ }, [showIdleTime]);
16735
+ const animateToNewData = React14__default.useCallback((targetData) => {
16546
16736
  const startData = [...prevDataRef.current];
16547
16737
  const startTime = performance.now();
16548
16738
  const duration = 1200;
@@ -16572,7 +16762,7 @@ var HourlyOutputChart = ({
16572
16762
  }
16573
16763
  animationFrameRef.current = requestAnimationFrame(animate);
16574
16764
  }, []);
16575
- React33__default.useEffect(() => {
16765
+ React14__default.useEffect(() => {
16576
16766
  if (JSON.stringify(data) !== JSON.stringify(prevDataRef.current)) {
16577
16767
  const shiftData = data.slice(0, SHIFT_DURATION);
16578
16768
  animateToNewData(shiftData);
@@ -16583,7 +16773,7 @@ var HourlyOutputChart = ({
16583
16773
  }
16584
16774
  };
16585
16775
  }, [data, animateToNewData]);
16586
- const formatHour = (hourIndex) => {
16776
+ const formatHour = React14__default.useCallback((hourIndex) => {
16587
16777
  const startDecimalHour = shiftStartTime.decimalHour + hourIndex;
16588
16778
  const startHour = Math.floor(startDecimalHour) % 24;
16589
16779
  const startMinute = Math.round(startDecimalHour % 1 * 60);
@@ -16599,8 +16789,8 @@ var HourlyOutputChart = ({
16599
16789
  return `${hour12}:${m.toString().padStart(2, "0")}${period}`;
16600
16790
  };
16601
16791
  return `${formatTime2(startHour, startMinute)}-${formatTime2(endHour, endMinute)}`;
16602
- };
16603
- const formatTimeRange = (hourIndex) => {
16792
+ }, [shiftStartTime.decimalHour]);
16793
+ const formatTimeRange = React14__default.useCallback((hourIndex) => {
16604
16794
  const startDecimalHour = shiftStartTime.decimalHour + hourIndex;
16605
16795
  const startHour = Math.floor(startDecimalHour) % 24;
16606
16796
  const startMinute = Math.round(startDecimalHour % 1 * 60);
@@ -16613,22 +16803,24 @@ var HourlyOutputChart = ({
16613
16803
  return `${hour12}:${m.toString().padStart(2, "0")} ${period}`;
16614
16804
  };
16615
16805
  return `${formatTime2(startHour, startMinute)} - ${formatTime2(endHour, endMinute)}`;
16616
- };
16617
- const chartData = Array.from({ length: SHIFT_DURATION }, (_, i) => {
16618
- const actualHour = (shiftStartTime.hour + i) % 24;
16619
- const idleArray = idleTimeHourly?.[actualHour.toString()] || [];
16620
- const idleMinutes = idleArray.filter((val) => val === "1").length;
16621
- return {
16622
- hour: formatHour(i),
16623
- timeRange: formatTimeRange(i),
16624
- output: animatedData[i] || 0,
16625
- originalOutput: data[i] || 0,
16626
- // Keep original data for labels
16627
- color: (animatedData[i] || 0) >= Math.round(pphThreshold) ? "#00AB45" : "#E34329",
16628
- idleMinutes,
16629
- idleArray
16630
- };
16631
- });
16806
+ }, [shiftStartTime.decimalHour]);
16807
+ const chartData = React14__default.useMemo(() => {
16808
+ return Array.from({ length: SHIFT_DURATION }, (_, i) => {
16809
+ const actualHour = (shiftStartTime.hour + i) % 24;
16810
+ const idleArray = idleTimeHourly?.[actualHour.toString()] || [];
16811
+ const idleMinutes = idleArray.filter((val) => val === "1").length;
16812
+ return {
16813
+ hour: formatHour(i),
16814
+ timeRange: formatTimeRange(i),
16815
+ output: animatedData[i] || 0,
16816
+ originalOutput: data[i] || 0,
16817
+ // Keep original data for labels
16818
+ color: (animatedData[i] || 0) >= Math.round(pphThreshold) ? "#00AB45" : "#E34329",
16819
+ idleMinutes,
16820
+ idleArray
16821
+ };
16822
+ });
16823
+ }, [animatedData, data, pphThreshold, idleTimeHourly, shiftStartTime.hour, formatHour, formatTimeRange]);
16632
16824
  const maxYValue = Math.ceil(pphThreshold * 1.5);
16633
16825
  const generateYAxisTicks = () => {
16634
16826
  const targetValue = Math.round(pphThreshold);
@@ -16721,10 +16913,10 @@ var HourlyOutputChart = ({
16721
16913
  contentStyle: {
16722
16914
  backgroundColor: "white",
16723
16915
  border: "none",
16724
- borderRadius: "8px",
16725
- boxShadow: "0 4px 12px rgba(0,0,0,0.1)",
16726
- padding: "8px 12px",
16727
- fontSize: "13px"
16916
+ borderRadius: "12px",
16917
+ boxShadow: "0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",
16918
+ padding: "0",
16919
+ fontSize: "14px"
16728
16920
  },
16729
16921
  content: (props) => {
16730
16922
  if (!props.active || !props.payload || props.payload.length === 0) return null;
@@ -16758,48 +16950,54 @@ var HourlyOutputChart = ({
16758
16950
  const hour12 = hour === 0 ? 12 : hour > 12 ? hour - 12 : hour;
16759
16951
  return `${hour12}:${minute.toString().padStart(2, "0")} ${period}`;
16760
16952
  };
16761
- return /* @__PURE__ */ jsxs("div", { className: "bg-white rounded-lg shadow-lg p-3 min-w-[180px]", children: [
16762
- /* @__PURE__ */ jsx("p", { className: "font-semibold text-gray-700 mb-2", children: data2.timeRange }),
16763
- /* @__PURE__ */ jsxs("p", { className: "text-gray-600", children: [
16764
- "Output: ",
16765
- /* @__PURE__ */ jsxs("span", { className: "font-medium text-gray-800", children: [
16766
- Math.round(data2.output),
16767
- " units"
16768
- ] })
16769
- ] }),
16770
- showIdleTime && data2.idleMinutes > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
16771
- /* @__PURE__ */ jsxs("p", { className: "text-gray-600 mb-1 border-t pt-1 mt-1", children: [
16772
- "Idle Time: ",
16773
- /* @__PURE__ */ jsxs("span", { className: "font-medium text-gray-700", children: [
16774
- data2.idleMinutes,
16775
- " minutes"
16953
+ return /* @__PURE__ */ jsxs("div", { className: "bg-white rounded-xl shadow-xl border border-gray-100 p-4 min-w-[220px]", children: [
16954
+ /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between mb-3", children: /* @__PURE__ */ jsx("p", { className: "font-semibold text-gray-900 text-sm", children: data2.timeRange }) }),
16955
+ /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
16956
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
16957
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-gray-500", children: "Output" }),
16958
+ /* @__PURE__ */ jsxs("span", { className: "font-semibold text-gray-900 text-sm", children: [
16959
+ Math.round(data2.output),
16960
+ " units"
16776
16961
  ] })
16777
16962
  ] }),
16778
- idleRanges.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mt-2 text-xs", children: [
16779
- /* @__PURE__ */ jsx("p", { className: "font-medium text-gray-600 mb-1", children: "Idle periods:" }),
16780
- /* @__PURE__ */ jsx("div", { className: "space-y-0.5 max-h-32 overflow-y-auto", children: idleRanges.map((range, index) => {
16781
- const duration = range.end - range.start + 1;
16782
- const startTime = formatIdleTimestamp(range.start);
16783
- const endTime = formatIdleTimestamp(range.end + 1);
16784
- return /* @__PURE__ */ jsxs("div", { className: "text-gray-500 flex items-center gap-1", children: [
16785
- /* @__PURE__ */ jsx("span", { className: "inline-block w-1 h-1 bg-gray-400 rounded-full" }),
16786
- duration === 1 ? /* @__PURE__ */ jsxs("span", { children: [
16787
- startTime,
16788
- " ",
16789
- /* @__PURE__ */ jsx("span", { className: "text-gray-400", children: "(1 min)" })
16790
- ] }) : /* @__PURE__ */ jsxs("span", { children: [
16791
- startTime,
16792
- " - ",
16793
- endTime,
16794
- " ",
16795
- /* @__PURE__ */ jsxs("span", { className: "text-gray-400", children: [
16796
- "(",
16797
- duration,
16798
- " min)"
16799
- ] })
16800
- ] })
16801
- ] }, index);
16802
- }) })
16963
+ showIdleTime && data2.idleMinutes > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
16964
+ /* @__PURE__ */ jsx("div", { className: "border-t border-gray-100 pt-2", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
16965
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-gray-500", children: "Idle Time" }),
16966
+ /* @__PURE__ */ jsxs("span", { className: "font-semibold text-orange-600 text-sm", children: [
16967
+ data2.idleMinutes,
16968
+ " minutes"
16969
+ ] })
16970
+ ] }) }),
16971
+ idleRanges.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mt-3 bg-gray-50 rounded-lg p-2.5", children: [
16972
+ /* @__PURE__ */ jsx("p", { className: "font-medium text-gray-700 text-xs mb-2", children: "Idle periods:" }),
16973
+ /* @__PURE__ */ jsx("div", { className: "space-y-1 max-h-32 overflow-y-auto pr-1", children: idleRanges.map((range, index) => {
16974
+ const duration = range.end - range.start + 1;
16975
+ const startTime = formatIdleTimestamp(range.start);
16976
+ const endTime = formatIdleTimestamp(range.end + 1);
16977
+ return /* @__PURE__ */ jsxs("div", { className: "text-gray-600 flex items-center gap-2 text-xs", children: [
16978
+ /* @__PURE__ */ jsx("span", { className: "inline-block w-1.5 h-1.5 bg-orange-400 rounded-full flex-shrink-0" }),
16979
+ /* @__PURE__ */ jsx("span", { children: duration === 1 ? /* @__PURE__ */ jsxs(Fragment, { children: [
16980
+ startTime,
16981
+ " ",
16982
+ /* @__PURE__ */ jsxs("span", { className: "text-gray-400", children: [
16983
+ "(",
16984
+ duration,
16985
+ " min)"
16986
+ ] })
16987
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
16988
+ startTime,
16989
+ " - ",
16990
+ endTime,
16991
+ " ",
16992
+ /* @__PURE__ */ jsxs("span", { className: "text-gray-400", children: [
16993
+ "(",
16994
+ duration,
16995
+ " min)"
16996
+ ] })
16997
+ ] }) })
16998
+ ] }, index);
16999
+ }) })
17000
+ ] })
16803
17001
  ] })
16804
17002
  ] })
16805
17003
  ] });
@@ -16889,10 +17087,40 @@ var HourlyOutputChart = ({
16889
17087
  radius: [10, 10, 0, 0],
16890
17088
  fill: "url(#idlePattern)",
16891
17089
  opacity: 0.7,
16892
- isAnimationActive: true,
16893
- animationBegin: 200,
16894
- animationDuration: 800,
16895
- animationEasing: "ease-out"
17090
+ isAnimationActive: shouldAnimateIdle,
17091
+ animationBegin: shouldAnimateIdle ? 200 : 0,
17092
+ animationDuration: shouldAnimateIdle ? 800 : 0,
17093
+ animationEasing: "ease-out",
17094
+ children: /* @__PURE__ */ jsx(
17095
+ LabelList,
17096
+ {
17097
+ dataKey: "idleMinutes",
17098
+ position: "top",
17099
+ content: (props) => {
17100
+ const { x, y, width, value } = props;
17101
+ if (!value || value === 0) return null;
17102
+ return /* @__PURE__ */ jsxs(
17103
+ "text",
17104
+ {
17105
+ x: x + width / 2,
17106
+ y: y - 2,
17107
+ textAnchor: "middle",
17108
+ fontSize: "9",
17109
+ fontWeight: "600",
17110
+ fill: "#6b7280",
17111
+ style: {
17112
+ opacity: 1,
17113
+ pointerEvents: "none"
17114
+ },
17115
+ children: [
17116
+ value,
17117
+ "m"
17118
+ ]
17119
+ }
17120
+ );
17121
+ }
17122
+ }
17123
+ )
16896
17124
  }
16897
17125
  ),
16898
17126
  /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("pattern", { id: "idlePattern", patternUnits: "userSpaceOnUse", width: "4", height: "4", children: [
@@ -17321,7 +17549,7 @@ var EmptyStateMessage = ({
17321
17549
  iconClassName
17322
17550
  }) => {
17323
17551
  let IconContent = null;
17324
- if (React33__default.isValidElement(iconType)) {
17552
+ if (React14__default.isValidElement(iconType)) {
17325
17553
  IconContent = iconType;
17326
17554
  } else if (typeof iconType === "string") {
17327
17555
  const MappedIcon = IconMap[iconType];
@@ -19887,7 +20115,7 @@ function Skeleton({ className, ...props }) {
19887
20115
  var Select = SelectPrimitive.Root;
19888
20116
  var SelectGroup = SelectPrimitive.Group;
19889
20117
  var SelectValue = SelectPrimitive.Value;
19890
- var SelectTrigger = React33.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
20118
+ var SelectTrigger = React14.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
19891
20119
  SelectPrimitive.Trigger,
19892
20120
  {
19893
20121
  ref,
@@ -19903,7 +20131,7 @@ var SelectTrigger = React33.forwardRef(({ className, children, ...props }, ref)
19903
20131
  }
19904
20132
  ));
19905
20133
  SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
19906
- var SelectScrollUpButton = React33.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
20134
+ var SelectScrollUpButton = React14.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
19907
20135
  SelectPrimitive.ScrollUpButton,
19908
20136
  {
19909
20137
  ref,
@@ -19913,7 +20141,7 @@ var SelectScrollUpButton = React33.forwardRef(({ className, ...props }, ref) =>
19913
20141
  }
19914
20142
  ));
19915
20143
  SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
19916
- var SelectScrollDownButton = React33.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
20144
+ var SelectScrollDownButton = React14.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
19917
20145
  SelectPrimitive.ScrollDownButton,
19918
20146
  {
19919
20147
  ref,
@@ -19923,7 +20151,7 @@ var SelectScrollDownButton = React33.forwardRef(({ className, ...props }, ref) =
19923
20151
  }
19924
20152
  ));
19925
20153
  SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
19926
- var SelectContent = React33.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsx(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsxs(
20154
+ var SelectContent = React14.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsx(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsxs(
19927
20155
  SelectPrimitive.Content,
19928
20156
  {
19929
20157
  ref,
@@ -19951,7 +20179,7 @@ var SelectContent = React33.forwardRef(({ className, children, position = "poppe
19951
20179
  }
19952
20180
  ) }));
19953
20181
  SelectContent.displayName = SelectPrimitive.Content.displayName;
19954
- var SelectLabel = React33.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
20182
+ var SelectLabel = React14.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
19955
20183
  SelectPrimitive.Label,
19956
20184
  {
19957
20185
  ref,
@@ -19960,7 +20188,7 @@ var SelectLabel = React33.forwardRef(({ className, ...props }, ref) => /* @__PUR
19960
20188
  }
19961
20189
  ));
19962
20190
  SelectLabel.displayName = SelectPrimitive.Label.displayName;
19963
- var SelectItem = React33.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
20191
+ var SelectItem = React14.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
19964
20192
  SelectPrimitive.Item,
19965
20193
  {
19966
20194
  ref,
@@ -19976,7 +20204,7 @@ var SelectItem = React33.forwardRef(({ className, children, ...props }, ref) =>
19976
20204
  }
19977
20205
  ));
19978
20206
  SelectItem.displayName = SelectPrimitive.Item.displayName;
19979
- var SelectSeparator = React33.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
20207
+ var SelectSeparator = React14.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
19980
20208
  SelectPrimitive.Separator,
19981
20209
  {
19982
20210
  ref,
@@ -21718,7 +21946,7 @@ var TREND_STYLES = {
21718
21946
  // Up
21719
21947
  };
21720
21948
  var getTrendArrowAndColor = (trend) => TREND_STYLES[trend] || { arrow: "", color: "" };
21721
- var VideoCard = React33__default.memo(({
21949
+ var VideoCard = React14__default.memo(({
21722
21950
  workspace,
21723
21951
  hlsUrl,
21724
21952
  shouldPlay,
@@ -21849,7 +22077,7 @@ var DEFAULT_WORKSPACE_HLS_URLS = {
21849
22077
  "WS06": "https://59.144.218.58:8443/camera5.m3u8"
21850
22078
  };
21851
22079
  var DEFAULT_HLS_URL = "https://192.168.5.9:8443/cam1.m3u8";
21852
- var VideoGridView = React33__default.memo(({
22080
+ var VideoGridView = React14__default.memo(({
21853
22081
  workspaces,
21854
22082
  selectedLine,
21855
22083
  className = "",
@@ -22132,7 +22360,7 @@ var arePropsEqual = (prevProps, nextProps) => {
22132
22360
  return prevProps.data.efficiency === nextProps.data.efficiency && prevProps.data.trend_score === nextProps.data.trend_score && prevProps.data.workspace_id === nextProps.data.workspace_id && prevProps.data.workspace_name === nextProps.data.workspace_name && prevProps.isBottleneck === nextProps.isBottleneck && prevProps.isLowEfficiency === nextProps.isLowEfficiency && prevProps.isVeryLowEfficiency === nextProps.isVeryLowEfficiency && // Position doesn't need deep equality check as it's generally static
22133
22361
  prevProps.position.id === nextProps.position.id;
22134
22362
  };
22135
- var WorkspaceGridItem = React33__default.memo(({
22363
+ var WorkspaceGridItem = React14__default.memo(({
22136
22364
  data,
22137
22365
  position,
22138
22366
  isBottleneck = false,
@@ -22225,7 +22453,7 @@ var WorkspaceGridItem = React33__default.memo(({
22225
22453
  );
22226
22454
  }, arePropsEqual);
22227
22455
  WorkspaceGridItem.displayName = "WorkspaceGridItem";
22228
- var WorkspaceGrid = React33__default.memo(({
22456
+ var WorkspaceGrid = React14__default.memo(({
22229
22457
  workspaces,
22230
22458
  isPdfMode = false,
22231
22459
  customWorkspacePositions,
@@ -22414,7 +22642,7 @@ var KPICard = ({
22414
22642
  }) => {
22415
22643
  useThemeConfig();
22416
22644
  const { formatNumber } = useFormatNumber();
22417
- const trendInfo = React33__default.useMemo(() => {
22645
+ const trendInfo = React14__default.useMemo(() => {
22418
22646
  let trendValue = trend || "neutral";
22419
22647
  if (change !== void 0 && trend === void 0) {
22420
22648
  trendValue = change > 0 ? "up" : change < 0 ? "down" : "neutral";
@@ -22437,7 +22665,7 @@ var KPICard = ({
22437
22665
  const shouldShowTrend = !(change === 0 && trend === void 0);
22438
22666
  return { trendValue, Icon: Icon2, colorClass, shouldShowTrend };
22439
22667
  }, [trend, change]);
22440
- const formattedValue = React33__default.useMemo(() => {
22668
+ const formattedValue = React14__default.useMemo(() => {
22441
22669
  if (title === "Quality Compliance" && typeof value === "number") {
22442
22670
  return value.toFixed(1);
22443
22671
  }
@@ -22451,7 +22679,7 @@ var KPICard = ({
22451
22679
  }
22452
22680
  return value;
22453
22681
  }, [value, title]);
22454
- const formattedChange = React33__default.useMemo(() => {
22682
+ const formattedChange = React14__default.useMemo(() => {
22455
22683
  if (change === void 0 || change === 0) return null;
22456
22684
  const absChange = Math.abs(change);
22457
22685
  return formatNumber(absChange, { minimumFractionDigits: 0, maximumFractionDigits: 1 });
@@ -22863,7 +23091,7 @@ var Breadcrumbs = ({ items }) => {
22863
23091
  }
22864
23092
  }
22865
23093
  };
22866
- return /* @__PURE__ */ jsx("nav", { "aria-label": "Breadcrumb", className: "mb-1 flex items-center space-x-1 text-xs font-medium text-gray-500 dark:text-gray-400", children: items.map((item, index) => /* @__PURE__ */ jsxs(React33__default.Fragment, { children: [
23094
+ return /* @__PURE__ */ jsx("nav", { "aria-label": "Breadcrumb", className: "mb-1 flex items-center space-x-1 text-xs font-medium text-gray-500 dark:text-gray-400", children: items.map((item, index) => /* @__PURE__ */ jsxs(React14__default.Fragment, { children: [
22867
23095
  index > 0 && /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 text-gray-400 dark:text-gray-500" }),
22868
23096
  /* @__PURE__ */ jsxs(
22869
23097
  "span",
@@ -23682,7 +23910,7 @@ var ThreadSidebar = ({
23682
23910
  ] });
23683
23911
  };
23684
23912
  var axelProfilePng = "/axel-profile.png";
23685
- var ProfilePicture = React33__default.memo(({ alt = "Axel", className = "w-12 h-12" }) => {
23913
+ var ProfilePicture = React14__default.memo(({ alt = "Axel", className = "w-12 h-12" }) => {
23686
23914
  return /* @__PURE__ */ jsx("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsx("div", { className: `${className} rounded-xl overflow-hidden shadow-sm`, children: /* @__PURE__ */ jsx(
23687
23915
  "img",
23688
23916
  {
@@ -25547,6 +25775,24 @@ function HomeView({
25547
25775
  const [selectedLineId, setSelectedLineId] = useState(defaultLineId);
25548
25776
  const [isChangingFilter, setIsChangingFilter] = useState(false);
25549
25777
  const [errorMessage, setErrorMessage] = useState(null);
25778
+ const [displayNamesInitialized, setDisplayNamesInitialized] = useState(false);
25779
+ useEffect(() => {
25780
+ const initDisplayNames = async () => {
25781
+ try {
25782
+ await preInitializeWorkspaceDisplayNames(selectedLineId);
25783
+ setDisplayNamesInitialized(true);
25784
+ } catch (error) {
25785
+ console.error("Failed to pre-initialize workspace display names:", error);
25786
+ setDisplayNamesInitialized(true);
25787
+ }
25788
+ };
25789
+ initDisplayNames();
25790
+ }, [selectedLineId]);
25791
+ const {
25792
+ displayNames: workspaceDisplayNames,
25793
+ loading: displayNamesLoading,
25794
+ error: displayNamesError
25795
+ } = useWorkspaceDisplayNames(void 0, selectedLineId);
25550
25796
  useCallback(() => {
25551
25797
  console.log("Refetching KPIs after line metrics update");
25552
25798
  }, []);
@@ -25619,16 +25865,16 @@ function HomeView({
25619
25865
  const lineTitle = useMemo(() => {
25620
25866
  return factoryName;
25621
25867
  }, [factoryName]);
25622
- const isLoading = !isHydrated || metricsLoading || kpisLoading || isChangingFilter;
25868
+ const isLoading = !isHydrated || metricsLoading || kpisLoading || isChangingFilter || displayNamesLoading || !displayNamesInitialized;
25623
25869
  if (isLoading) {
25624
25870
  return /* @__PURE__ */ jsx("div", { className: "min-h-screen bg-slate-50", children: /* @__PURE__ */ jsx(LoadingPageCmp, { message: "Loading dashboard..." }) });
25625
25871
  }
25626
- if (errorMessage) {
25872
+ if (errorMessage || displayNamesError) {
25627
25873
  return /* @__PURE__ */ jsx("div", { className: "flex h-screen items-center justify-center", children: /* @__PURE__ */ jsx("div", { className: "rounded-lg bg-white p-6 shadow-lg", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-3 text-red-500", children: [
25628
25874
  /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
25629
25875
  /* @__PURE__ */ jsxs("span", { className: "text-lg font-medium", children: [
25630
25876
  "Error: ",
25631
- errorMessage
25877
+ errorMessage || displayNamesError?.message
25632
25878
  ] })
25633
25879
  ] }) }) });
25634
25880
  }
@@ -25648,7 +25894,7 @@ function HomeView({
25648
25894
  /* @__PURE__ */ jsx(DashboardHeader, { lineTitle, className: "mb-1 sm:mb-0" }),
25649
25895
  memoizedKPIs && /* @__PURE__ */ jsx(KPISection2, { kpis: memoizedKPIs, className: "w-full sm:w-auto" })
25650
25896
  ] }) }),
25651
- /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto sm:overflow-hidden", children: memoizedWorkspaceMetrics.length > 0 ? /* @__PURE__ */ jsx("div", { className: "h-full sm:h-full min-h-[calc(100vh-80px)] sm:min-h-0", children: React33__default.createElement(WorkspaceGrid, {
25897
+ /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto sm:overflow-hidden", children: memoizedWorkspaceMetrics.length > 0 ? /* @__PURE__ */ jsx("div", { className: "h-full sm:h-full min-h-[calc(100vh-80px)] sm:min-h-0", children: React14__default.createElement(WorkspaceGrid, {
25652
25898
  workspaces: memoizedWorkspaceMetrics,
25653
25899
  lineNames,
25654
25900
  factoryView: factoryViewId,
@@ -25669,7 +25915,7 @@ function HomeView({
25669
25915
  }
25670
25916
  );
25671
25917
  }
25672
- var AuthenticatedHomeView = withAuth(React33__default.memo(HomeView));
25918
+ var AuthenticatedHomeView = withAuth(React14__default.memo(HomeView));
25673
25919
  var HomeView_default = HomeView;
25674
25920
 
25675
25921
  // src/views/kpi-detail-view.types.ts
@@ -26502,7 +26748,7 @@ var LineCard = ({ line, onClick }) => {
26502
26748
  const { kpis, isLoading, error } = useLineKPIs({ lineId: line.id });
26503
26749
  const shiftConfig = useShiftConfig();
26504
26750
  const dateTimeConfig = useDateTimeConfig();
26505
- const isOnTrack = React33__default.useMemo(() => {
26751
+ const isOnTrack = React14__default.useMemo(() => {
26506
26752
  if (!kpis) return null;
26507
26753
  const currentTime = /* @__PURE__ */ new Date();
26508
26754
  const timezone = dateTimeConfig.defaultTimezone || "Asia/Kolkata";
@@ -30466,4 +30712,4 @@ var S3Service = class {
30466
30712
  }
30467
30713
  };
30468
30714
 
30469
- export { ACTION_NAMES, AIAgentView_default as AIAgentView, AuthCallback, AuthCallbackView_default as AuthCallbackView, AuthProvider, AuthenticatedFactoryView, AuthenticatedHelpView, AuthenticatedHomeView, AuthenticatedTargetsView, BarChart, BaseHistoryCalendar, BottlenecksContent, BreakNotificationPopup, Card2 as Card, CardContent2 as CardContent, CardDescription2 as CardDescription, CardFooter2 as CardFooter, CardHeader2 as CardHeader, CardTitle2 as CardTitle, CycleTimeChart, CycleTimeOverTimeChart, DEFAULT_ANALYTICS_CONFIG, DEFAULT_AUTH_CONFIG, DEFAULT_CONFIG, DEFAULT_DATABASE_CONFIG, DEFAULT_DATE_TIME_CONFIG, DEFAULT_ENDPOINTS_CONFIG, DEFAULT_ENTITY_CONFIG, DEFAULT_SHIFT_CONFIG, DEFAULT_THEME_CONFIG, DEFAULT_WORKSPACE_CONFIG, DEFAULT_WORKSPACE_POSITIONS, DashboardHeader, DashboardLayout, DashboardOverridesProvider, DashboardProvider, DateDisplay_default as DateDisplay, DateTimeDisplay, DebugAuth, DebugAuthView_default as DebugAuthView, EmptyStateMessage, FactoryView_default as FactoryView, GridComponentsPlaceholder, Header, HelpView_default as HelpView, HomeView_default as HomeView, HourlyOutputChart2 as HourlyOutputChart, ISTTimer_default as ISTTimer, KPICard, KPIDetailView_default as KPIDetailView, KPIGrid, KPIHeader, KPISection, KPIsOverviewView_default as KPIsOverviewView, LINE_1_UUID, LargeOutputProgressChart, LeaderboardDetailView_default as LeaderboardDetailView, Legend5 as Legend, LineChart, LineHistoryCalendar, LineMonthlyHistory, LineMonthlyPdfGenerator, LinePdfExportButton, LinePdfGenerator, LineWhatsAppShareButton, LiveTimer, LoadingOverlay_default as LoadingOverlay, LoadingPage_default as LoadingPage, LoadingSpinner_default as LoadingSpinner, LoginPage, LoginView_default as LoginView, MainLayout, MetricCard_default as MetricCard, NoWorkspaceData, OptifyeAgentClient, OutputProgressChart, PageHeader, ProfileView_default as ProfileView, RegistryProvider, S3Service, SOPComplianceChart, SSEChatClient, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, ShiftDisplay_default as ShiftDisplay, ShiftsView_default as ShiftsView, SideNavBar, SingleVideoStream_default as SingleVideoStream, Skeleton, SlackAPI, SupabaseProvider, TargetWorkspaceGrid, TargetsView_default as TargetsView, ThreadSidebar, TimeDisplay_default as TimeDisplay, TimePickerDropdown, VideoCard, VideoGridView, VideoPreloader, WORKSPACE_POSITIONS, WhatsAppShareButton, WorkspaceCard, WorkspaceDetailView_default as WorkspaceDetailView, WorkspaceGrid, WorkspaceGridItem, WorkspaceHistoryCalendar, WorkspaceMetricCards, WorkspaceMonthlyDataFetcher, WorkspaceMonthlyPdfGenerator, WorkspacePdfExportButton, WorkspacePdfGenerator, WorkspaceWhatsAppShareButton, actionService, apiUtils, authCoreService, authOTPService, authRateLimitService, checkRateLimit2 as checkRateLimit, clearAllRateLimits2 as clearAllRateLimits, clearRateLimit2 as clearRateLimit, clearS3VideoCache, clearS3VideoFromCache, clearWorkspaceDisplayNamesCache, cn, createStreamProxyHandler, createSupabaseClient, createThrottledReload, dashboardService, deleteThread, formatDateInZone, formatDateTimeInZone, formatISTDate, formatIdleTime, formatTimeInZone, fromUrlFriendlyName, getAllThreadMessages, getAllWorkspaceDisplayNamesAsync, getAnonClient, getCameraNumber, getCompanyMetricsTableName, getConfigurableShortWorkspaceDisplayName, getConfigurableWorkspaceDisplayName, getCurrentShift, getCurrentTimeInZone, getDashboardHeaderTimeInZone, getDaysDifferenceInZone, getDefaultCameraStreamUrl, getDefaultTabForWorkspace, getManufacturingInsights, getMetricsTablePrefix, getOperationalDate, getS3SignedUrl, getS3VideoSrc, getShortWorkspaceDisplayName, getShortWorkspaceDisplayNameAsync, getStoredWorkspaceMappings, getThreadMessages, getUserThreads, getUserThreadsPaginated, getWorkspaceDisplayName, getWorkspaceDisplayNameAsync, getWorkspaceDisplayNamesMap, getWorkspaceFromUrl, getWorkspaceNavigationParams, identifyCoreUser, initializeCoreMixpanel, isTransitionPeriod, isValidLineInfoPayload, isValidWorkspaceDetailedMetricsPayload, isValidWorkspaceMetricsPayload, isWorkspaceDisplayNamesLoaded, isWorkspaceDisplayNamesLoading, mergeWithDefaultConfig, optifyeAgentClient, preloadS3Video, preloadS3VideoUrl, preloadS3VideosUrl, preloadVideoUrl, preloadVideosUrl, qualityService, realtimeService, refreshWorkspaceDisplayNames, resetCoreMixpanel, s3VideoPreloader, storeWorkspaceMapping, streamProxyConfig, throttledReloadDashboard, toUrlFriendlyName, trackCoreEvent, trackCorePageView, updateThreadTitle, useActiveBreaks, useAnalyticsConfig, useAuth, useAuthConfig, useComponentOverride, useCustomConfig, useDashboardConfig, useDashboardMetrics, useDatabaseConfig, useDateFormatter, useDateTimeConfig, useEndpointsConfig, useEntityConfig, useFactoryOverviewMetrics, useFeatureFlags, useFormatNumber, useHistoricWorkspaceMetrics, useHlsStream, useHookOverride, useLeaderboardMetrics, useLineDetailedMetrics, useLineKPIs, useLineMetrics, useLineWorkspaceMetrics, useMessages, useMetrics, useNavigation, useOverrides, usePageOverride, useRealtimeLineMetrics, useRegistry, useShiftConfig, useShifts, useSupabase, useSupabaseClient, useTargets, useTheme, useThemeConfig, useThreads, useWorkspaceConfig, useWorkspaceDetailedMetrics, useWorkspaceDisplayName, useWorkspaceDisplayNames, useWorkspaceDisplayNamesMap, useWorkspaceMetrics, useWorkspaceNavigation, useWorkspaceOperators, videoPreloader, whatsappService, withAuth, withRegistry, workspaceService };
30715
+ export { ACTION_NAMES, AIAgentView_default as AIAgentView, AuthCallback, AuthCallbackView_default as AuthCallbackView, AuthProvider, AuthenticatedFactoryView, AuthenticatedHelpView, AuthenticatedHomeView, AuthenticatedTargetsView, BarChart, BaseHistoryCalendar, BottlenecksContent, BreakNotificationPopup, Card2 as Card, CardContent2 as CardContent, CardDescription2 as CardDescription, CardFooter2 as CardFooter, CardHeader2 as CardHeader, CardTitle2 as CardTitle, CycleTimeChart, CycleTimeOverTimeChart, DEFAULT_ANALYTICS_CONFIG, DEFAULT_AUTH_CONFIG, DEFAULT_CONFIG, DEFAULT_DATABASE_CONFIG, DEFAULT_DATE_TIME_CONFIG, DEFAULT_ENDPOINTS_CONFIG, DEFAULT_ENTITY_CONFIG, DEFAULT_SHIFT_CONFIG, DEFAULT_THEME_CONFIG, DEFAULT_WORKSPACE_CONFIG, DEFAULT_WORKSPACE_POSITIONS, DashboardHeader, DashboardLayout, DashboardOverridesProvider, DashboardProvider, DateDisplay_default as DateDisplay, DateTimeDisplay, DebugAuth, DebugAuthView_default as DebugAuthView, EmptyStateMessage, FactoryView_default as FactoryView, GridComponentsPlaceholder, Header, HelpView_default as HelpView, HomeView_default as HomeView, HourlyOutputChart2 as HourlyOutputChart, ISTTimer_default as ISTTimer, KPICard, KPIDetailView_default as KPIDetailView, KPIGrid, KPIHeader, KPISection, KPIsOverviewView_default as KPIsOverviewView, LINE_1_UUID, LargeOutputProgressChart, LeaderboardDetailView_default as LeaderboardDetailView, Legend5 as Legend, LineChart, LineHistoryCalendar, LineMonthlyHistory, LineMonthlyPdfGenerator, LinePdfExportButton, LinePdfGenerator, LineWhatsAppShareButton, LiveTimer, LoadingOverlay_default as LoadingOverlay, LoadingPage_default as LoadingPage, LoadingSpinner_default as LoadingSpinner, LoginPage, LoginView_default as LoginView, MainLayout, MetricCard_default as MetricCard, NoWorkspaceData, OptifyeAgentClient, OutputProgressChart, PageHeader, ProfileView_default as ProfileView, RegistryProvider, S3Service, SOPComplianceChart, SSEChatClient, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, ShiftDisplay_default as ShiftDisplay, ShiftsView_default as ShiftsView, SideNavBar, SingleVideoStream_default as SingleVideoStream, Skeleton, SlackAPI, SupabaseProvider, TargetWorkspaceGrid, TargetsView_default as TargetsView, ThreadSidebar, TimeDisplay_default as TimeDisplay, TimePickerDropdown, VideoCard, VideoGridView, VideoPreloader, WORKSPACE_POSITIONS, WhatsAppShareButton, WorkspaceCard, WorkspaceDetailView_default as WorkspaceDetailView, WorkspaceGrid, WorkspaceGridItem, WorkspaceHistoryCalendar, WorkspaceMetricCards, WorkspaceMonthlyDataFetcher, WorkspaceMonthlyPdfGenerator, WorkspacePdfExportButton, WorkspacePdfGenerator, WorkspaceWhatsAppShareButton, actionService, apiUtils, authCoreService, authOTPService, authRateLimitService, checkRateLimit2 as checkRateLimit, clearAllRateLimits2 as clearAllRateLimits, clearRateLimit2 as clearRateLimit, clearS3VideoCache, clearS3VideoFromCache, clearWorkspaceDisplayNamesCache, cn, createStreamProxyHandler, createSupabaseClient, createThrottledReload, dashboardService, deleteThread, forceRefreshWorkspaceDisplayNames, formatDateInZone, formatDateTimeInZone, formatISTDate, formatIdleTime, formatTimeInZone, fromUrlFriendlyName, getAllThreadMessages, getAllWorkspaceDisplayNamesAsync, getAnonClient, getCameraNumber, getCompanyMetricsTableName, getConfigurableShortWorkspaceDisplayName, getConfigurableWorkspaceDisplayName, getCurrentShift, getCurrentTimeInZone, getDashboardHeaderTimeInZone, getDaysDifferenceInZone, getDefaultCameraStreamUrl, getDefaultTabForWorkspace, getManufacturingInsights, getMetricsTablePrefix, getOperationalDate, getS3SignedUrl, getS3VideoSrc, getShortWorkspaceDisplayName, getShortWorkspaceDisplayNameAsync, getStoredWorkspaceMappings, getThreadMessages, getUserThreads, getUserThreadsPaginated, getWorkspaceDisplayName, getWorkspaceDisplayNameAsync, getWorkspaceDisplayNamesMap, getWorkspaceFromUrl, getWorkspaceNavigationParams, identifyCoreUser, initializeCoreMixpanel, isTransitionPeriod, isValidLineInfoPayload, isValidWorkspaceDetailedMetricsPayload, isValidWorkspaceMetricsPayload, isWorkspaceDisplayNamesLoaded, isWorkspaceDisplayNamesLoading, mergeWithDefaultConfig, optifyeAgentClient, preInitializeWorkspaceDisplayNames, preloadS3Video, preloadS3VideoUrl, preloadS3VideosUrl, preloadVideoUrl, preloadVideosUrl, qualityService, realtimeService, refreshWorkspaceDisplayNames, resetCoreMixpanel, s3VideoPreloader, storeWorkspaceMapping, streamProxyConfig, throttledReloadDashboard, toUrlFriendlyName, trackCoreEvent, trackCorePageView, updateThreadTitle, useActiveBreaks, useAnalyticsConfig, useAuth, useAuthConfig, useComponentOverride, useCustomConfig, useDashboardConfig, useDashboardMetrics, useDatabaseConfig, useDateFormatter, useDateTimeConfig, useEndpointsConfig, useEntityConfig, useFactoryOverviewMetrics, useFeatureFlags, useFormatNumber, useHistoricWorkspaceMetrics, useHlsStream, useHookOverride, useLeaderboardMetrics, useLineDetailedMetrics, useLineKPIs, useLineMetrics, useLineWorkspaceMetrics, useMessages, useMetrics, useNavigation, useOverrides, usePageOverride, useRealtimeLineMetrics, useRegistry, useShiftConfig, useShifts, useSupabase, useSupabaseClient, useTargets, useTheme, useThemeConfig, useThreads, useWorkspaceConfig, useWorkspaceDetailedMetrics, useWorkspaceDisplayName, useWorkspaceDisplayNames, useWorkspaceDisplayNamesMap, useWorkspaceMetrics, useWorkspaceNavigation, useWorkspaceOperators, videoPreloader, whatsappService, withAuth, withRegistry, workspaceService };