@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.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var React33 = require('react');
3
+ var React14 = require('react');
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
5
  var router = require('next/router');
6
6
  var dateFns = require('date-fns');
@@ -44,7 +44,7 @@ function _interopNamespace(e) {
44
44
  return Object.freeze(n);
45
45
  }
46
46
 
47
- var React33__namespace = /*#__PURE__*/_interopNamespace(React33);
47
+ var React14__namespace = /*#__PURE__*/_interopNamespace(React14);
48
48
  var mixpanel__default = /*#__PURE__*/_interopDefault(mixpanel);
49
49
  var useSWR__default = /*#__PURE__*/_interopDefault(useSWR);
50
50
  var Hls2__default = /*#__PURE__*/_interopDefault(Hls2);
@@ -217,14 +217,14 @@ var _getDashboardConfigInstance = () => {
217
217
  }
218
218
  return dashboardConfigInstance;
219
219
  };
220
- var DashboardConfigContext = React33__namespace.createContext(void 0);
220
+ var DashboardConfigContext = React14__namespace.createContext(void 0);
221
221
  var DashboardProvider = ({ config: userProvidedConfig, children }) => {
222
- const fullConfig = React33__namespace.useMemo(() => mergeWithDefaultConfig(userProvidedConfig), [userProvidedConfig]);
222
+ const fullConfig = React14__namespace.useMemo(() => mergeWithDefaultConfig(userProvidedConfig), [userProvidedConfig]);
223
223
  _setDashboardConfigInstance(fullConfig);
224
- React33__namespace.useEffect(() => {
224
+ React14__namespace.useEffect(() => {
225
225
  _setDashboardConfigInstance(fullConfig);
226
226
  }, [fullConfig]);
227
- React33__namespace.useEffect(() => {
227
+ React14__namespace.useEffect(() => {
228
228
  if (!fullConfig.theme) return;
229
229
  const styleId = "dashboard-core-theme-vars";
230
230
  let styleEl = document.getElementById(styleId);
@@ -250,7 +250,7 @@ var DashboardProvider = ({ config: userProvidedConfig, children }) => {
250
250
  return /* @__PURE__ */ jsxRuntime.jsx(DashboardConfigContext.Provider, { value: fullConfig, children });
251
251
  };
252
252
  var useDashboardConfig = () => {
253
- const ctx = React33__namespace.useContext(DashboardConfigContext);
253
+ const ctx = React14__namespace.useContext(DashboardConfigContext);
254
254
  if (!ctx) throw new Error("useDashboardConfig must be used within a DashboardProvider");
255
255
  return ctx;
256
256
  };
@@ -299,7 +299,7 @@ function useCustomConfig() {
299
299
  const { customConfig } = useDashboardConfig();
300
300
  return customConfig ?? {};
301
301
  }
302
- var AuthContext = React33.createContext({
302
+ var AuthContext = React14.createContext({
303
303
  session: null,
304
304
  user: null,
305
305
  loading: true,
@@ -307,18 +307,18 @@ var AuthContext = React33.createContext({
307
307
  signOut: async () => {
308
308
  }
309
309
  });
310
- var useAuth = () => React33.useContext(AuthContext);
310
+ var useAuth = () => React14.useContext(AuthContext);
311
311
  var AuthProvider = ({ children }) => {
312
312
  const supabase = useSupabase();
313
313
  const { authConfig } = useDashboardConfig();
314
- const [session, setSession] = React33.useState(null);
315
- const [user, setUser] = React33.useState(null);
316
- const [loading, setLoading] = React33.useState(true);
317
- const [error, setError] = React33.useState(null);
314
+ const [session, setSession] = React14.useState(null);
315
+ const [user, setUser] = React14.useState(null);
316
+ const [loading, setLoading] = React14.useState(true);
317
+ const [error, setError] = React14.useState(null);
318
318
  const router$1 = router.useRouter();
319
319
  const userProfileTable = authConfig?.userProfileTable;
320
320
  const roleColumn = authConfig?.roleColumn || "role";
321
- const fetchUserDetails = React33.useCallback(async (supabaseUser) => {
321
+ const fetchUserDetails = React14.useCallback(async (supabaseUser) => {
322
322
  if (!supabaseUser) return null;
323
323
  const basicUser = {
324
324
  id: supabaseUser.id,
@@ -349,7 +349,7 @@ var AuthProvider = ({ children }) => {
349
349
  return basicUser;
350
350
  }
351
351
  }, [supabase, userProfileTable, roleColumn]);
352
- React33.useEffect(() => {
352
+ React14.useEffect(() => {
353
353
  if (!supabase) return;
354
354
  let mounted = true;
355
355
  const safetyTimeout = setTimeout(() => {
@@ -437,12 +437,12 @@ var defaultContextValue = {
437
437
  hooks: {},
438
438
  pages: {}
439
439
  };
440
- var DashboardOverridesContext = React33.createContext(defaultContextValue);
440
+ var DashboardOverridesContext = React14.createContext(defaultContextValue);
441
441
  var DashboardOverridesProvider = ({
442
442
  overrides = defaultContextValue,
443
443
  children
444
444
  }) => {
445
- const normalizedOverrides = React33.useMemo(() => {
445
+ const normalizedOverrides = React14.useMemo(() => {
446
446
  return {
447
447
  components: overrides.components || {},
448
448
  hooks: overrides.hooks || {},
@@ -452,19 +452,19 @@ var DashboardOverridesProvider = ({
452
452
  return /* @__PURE__ */ jsxRuntime.jsx(DashboardOverridesContext.Provider, { value: normalizedOverrides, children });
453
453
  };
454
454
  function useComponentOverride(key, Default) {
455
- const { components = {} } = React33.useContext(DashboardOverridesContext);
455
+ const { components = {} } = React14.useContext(DashboardOverridesContext);
456
456
  return components[key] ?? Default;
457
457
  }
458
458
  function useHookOverride(key, Default) {
459
- const { hooks = {} } = React33.useContext(DashboardOverridesContext);
459
+ const { hooks = {} } = React14.useContext(DashboardOverridesContext);
460
460
  return hooks[key] ?? Default;
461
461
  }
462
462
  function usePageOverride(key, Default) {
463
- const { pages = {} } = React33.useContext(DashboardOverridesContext);
463
+ const { pages = {} } = React14.useContext(DashboardOverridesContext);
464
464
  return pages[key] ?? Default;
465
465
  }
466
466
  function useOverrides() {
467
- return React33.useContext(DashboardOverridesContext);
467
+ return React14.useContext(DashboardOverridesContext);
468
468
  }
469
469
 
470
470
  // src/lib/internal/supabaseClientInstance.ts
@@ -480,17 +480,17 @@ var _getSupabaseInstance = () => {
480
480
  }
481
481
  return supabaseInstance;
482
482
  };
483
- var SupabaseContext = React33.createContext(void 0);
483
+ var SupabaseContext = React14.createContext(void 0);
484
484
  var SupabaseProvider = ({ client, children }) => {
485
485
  _setSupabaseInstance(client);
486
- React33.useEffect(() => {
486
+ React14.useEffect(() => {
487
487
  _setSupabaseInstance(client);
488
488
  }, [client]);
489
- const contextValue = React33.useMemo(() => ({ supabase: client }), [client]);
489
+ const contextValue = React14.useMemo(() => ({ supabase: client }), [client]);
490
490
  return /* @__PURE__ */ jsxRuntime.jsx(SupabaseContext.Provider, { value: contextValue, children });
491
491
  };
492
492
  var useSupabase = () => {
493
- const context = React33.useContext(SupabaseContext);
493
+ const context = React14.useContext(SupabaseContext);
494
494
  if (context === void 0) {
495
495
  throw new Error("useSupabase must be used within a SupabaseProvider.");
496
496
  }
@@ -533,10 +533,10 @@ var useWorkspaceMetrics = (workspaceId) => {
533
533
  const entityConfig = useEntityConfig();
534
534
  useDatabaseConfig();
535
535
  const dateTimeConfig = useDateTimeConfig();
536
- const [workspaceMetrics, setWorkspaceMetrics] = React33.useState(null);
537
- const [isLoading, setIsLoading] = React33.useState(true);
538
- const [error, setError] = React33.useState(null);
539
- const fetchWorkspaceMetrics = React33.useCallback(async () => {
536
+ const [workspaceMetrics, setWorkspaceMetrics] = React14.useState(null);
537
+ const [isLoading, setIsLoading] = React14.useState(true);
538
+ const [error, setError] = React14.useState(null);
539
+ const fetchWorkspaceMetrics = React14.useCallback(async () => {
540
540
  try {
541
541
  const operationalDate = getOperationalDate(dateTimeConfig.defaultTimezone);
542
542
  const { data, error: fetchError } = await supabase.from("overview_workspace_metrics").select("*").eq("workspace_id", workspaceId).eq("date", operationalDate).single();
@@ -549,7 +549,7 @@ var useWorkspaceMetrics = (workspaceId) => {
549
549
  setIsLoading(false);
550
550
  }
551
551
  }, [supabase, workspaceId, dateTimeConfig.defaultTimezone]);
552
- React33.useEffect(() => {
552
+ React14.useEffect(() => {
553
553
  let channels = [];
554
554
  const operationalDate = getOperationalDate(dateTimeConfig.defaultTimezone);
555
555
  const setupSubscriptions = () => {
@@ -602,10 +602,10 @@ var useWorkspaceMetrics = (workspaceId) => {
602
602
  var useLineMetrics = (lineId) => {
603
603
  const supabase = useSupabase();
604
604
  const dateTimeConfig = useDateTimeConfig();
605
- const [lineMetrics, setLineMetrics] = React33.useState(null);
606
- const [isLoading, setIsLoading] = React33.useState(true);
607
- const [error, setError] = React33.useState(null);
608
- const fetchLineMetrics = React33.useCallback(async () => {
605
+ const [lineMetrics, setLineMetrics] = React14.useState(null);
606
+ const [isLoading, setIsLoading] = React14.useState(true);
607
+ const [error, setError] = React14.useState(null);
608
+ const fetchLineMetrics = React14.useCallback(async () => {
609
609
  try {
610
610
  const operationalDate = getOperationalDate(dateTimeConfig.defaultTimezone);
611
611
  const { data, error: fetchError } = await supabase.from("overview_line_metrics").select("*").eq("line_id", lineId).eq("date", operationalDate).single();
@@ -618,7 +618,7 @@ var useLineMetrics = (lineId) => {
618
618
  setIsLoading(false);
619
619
  }
620
620
  }, [supabase, lineId, dateTimeConfig.defaultTimezone]);
621
- React33.useEffect(() => {
621
+ React14.useEffect(() => {
622
622
  let channels = [];
623
623
  const operationalDate = getOperationalDate(dateTimeConfig.defaultTimezone);
624
624
  const setupSubscriptions = () => {
@@ -668,11 +668,11 @@ var useLineMetrics = (lineId) => {
668
668
  var useMetrics = (tableName, options) => {
669
669
  const supabase = useSupabase();
670
670
  const entityConfig = useEntityConfig();
671
- const [data, setData] = React33.useState([]);
672
- const [isLoading, setIsLoading] = React33.useState(true);
673
- const [error, setError] = React33.useState(null);
674
- const channelRef = React33.useRef(null);
675
- React33.useEffect(() => {
671
+ const [data, setData] = React14.useState([]);
672
+ const [isLoading, setIsLoading] = React14.useState(true);
673
+ const [error, setError] = React14.useState(null);
674
+ const channelRef = React14.useRef(null);
675
+ React14.useEffect(() => {
676
676
  const fetchData = async () => {
677
677
  try {
678
678
  setIsLoading(true);
@@ -845,13 +845,13 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
845
845
  const shiftConfig = useShiftConfig();
846
846
  const workspaceConfig = useWorkspaceConfig();
847
847
  const supabase = useSupabase();
848
- const [metrics2, setMetrics] = React33.useState(null);
849
- const [isLoading, setIsLoading] = React33.useState(true);
850
- const [error, setError] = React33.useState(null);
851
- const updateQueueRef = React33.useRef(false);
852
- const isFetchingRef = React33.useRef(false);
853
- const timeoutRef = React33.useRef(null);
854
- const channelRef = React33.useRef(null);
848
+ const [metrics2, setMetrics] = React14.useState(null);
849
+ const [isLoading, setIsLoading] = React14.useState(true);
850
+ const [error, setError] = React14.useState(null);
851
+ const updateQueueRef = React14.useRef(false);
852
+ const isFetchingRef = React14.useRef(false);
853
+ const timeoutRef = React14.useRef(null);
854
+ const channelRef = React14.useRef(null);
855
855
  const schema = databaseConfig.schema ?? "public";
856
856
  const companyId = entityConfig.companyId || "";
857
857
  const metricsTablePrefix = getMetricsTablePrefix();
@@ -859,7 +859,7 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
859
859
  const defaultTimezone = dateTimeConfig.defaultTimezone;
860
860
  const workspaceMetricsBaseTable = databaseConfig.tables?.workspaces ?? "workspace_metrics";
861
861
  const workspaceActionsTable = databaseConfig.tables?.actions ?? "workspace_actions";
862
- const fetchMetrics = React33.useCallback(async () => {
862
+ const fetchMetrics = React14.useCallback(async () => {
863
863
  if (!workspaceId || isFetchingRef.current) return;
864
864
  try {
865
865
  isFetchingRef.current = true;
@@ -878,6 +878,63 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
878
878
  if (recentData) {
879
879
  console.log(`[useWorkspaceDetailedMetrics] Found fallback data from date: ${recentData.date}, shift: ${recentData.shift_id}`);
880
880
  const outputDifference2 = (recentData.total_output || 0) - (recentData.ideal_output || 0);
881
+ const workspaceMatch2 = recentData.workspace_name?.match(/WS(\d+)/);
882
+ const workspaceNumber2 = workspaceMatch2 ? parseInt(workspaceMatch2[1]) : 0;
883
+ const specialWsStart2 = workspaceConfig.specialWorkspaces?.startId ?? 19;
884
+ const specialWsEnd2 = workspaceConfig.specialWorkspaces?.endId ?? 34;
885
+ const isSpecialWorkspace2 = workspaceNumber2 >= specialWsStart2 && workspaceNumber2 <= specialWsEnd2;
886
+ const outputHourly2 = recentData.output_hourly || {};
887
+ const hasOutputHourlyData2 = outputHourly2 && typeof outputHourly2 === "object" && Object.keys(outputHourly2).length > 0;
888
+ let hourlyActionCounts2 = [];
889
+ if (hasOutputHourlyData2) {
890
+ console.log("Using new output_hourly column for workspace (fallback):", recentData.workspace_name);
891
+ console.log("Raw output_hourly data (fallback):", outputHourly2);
892
+ const isNightShift = recentData.shift_id === 1;
893
+ const shiftStart = recentData.shift_start || (isNightShift ? "22:00" : "06:00");
894
+ const shiftEnd = recentData.shift_end || (isNightShift ? "06:00" : "14:00");
895
+ const startHour = parseInt(shiftStart.split(":")[0]);
896
+ let expectedHours = [];
897
+ if (isNightShift) {
898
+ for (let i = 0; i < 9; i++) {
899
+ expectedHours.push((startHour + i) % 24);
900
+ }
901
+ } else {
902
+ for (let i = 0; i < 9; i++) {
903
+ expectedHours.push((startHour + i) % 24);
904
+ }
905
+ }
906
+ console.log("Expected shift hours (fallback):", expectedHours);
907
+ console.log("Available data hours (fallback):", Object.keys(outputHourly2));
908
+ hourlyActionCounts2 = expectedHours.map((expectedHour) => {
909
+ let hourData = outputHourly2[expectedHour.toString()];
910
+ if (!hourData && isNightShift) {
911
+ for (const [storedHour, data2] of Object.entries(outputHourly2)) {
912
+ if (Array.isArray(data2) && data2.length > 0 && data2.some((val) => val > 0)) {
913
+ if (storedHour === "18" && expectedHour === 1) {
914
+ hourData = data2;
915
+ console.log(`Mapping stored hour ${storedHour} to expected hour ${expectedHour} (fallback)`);
916
+ break;
917
+ }
918
+ }
919
+ }
920
+ }
921
+ return Array.isArray(hourData) ? hourData.reduce((sum, count) => sum + (count || 0), 0) : 0;
922
+ });
923
+ console.log("Final hourly action counts (fallback):", hourlyActionCounts2);
924
+ } else {
925
+ console.log("Using output_array fallback for workspace (fallback):", recentData.workspace_name);
926
+ const minuteByMinuteArray = recentData.output_array || [];
927
+ if (isSpecialWorkspace2) {
928
+ const last40Readings = minuteByMinuteArray.slice(Math.max(0, minuteByMinuteArray.length - 40));
929
+ hourlyActionCounts2 = last40Readings;
930
+ } else {
931
+ for (let i = 0; i < minuteByMinuteArray.length; i += 60) {
932
+ const hourSlice = minuteByMinuteArray.slice(i, Math.min(i + 60, minuteByMinuteArray.length));
933
+ const hourlySum = hourSlice.reduce((sum, count) => sum + count, 0);
934
+ hourlyActionCounts2.push(hourlySum);
935
+ }
936
+ }
937
+ }
881
938
  const transformedData2 = {
882
939
  workspace_id: recentData.workspace_id,
883
940
  workspace_name: recentData.workspace_name,
@@ -898,12 +955,14 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
898
955
  ideal_cycle_time: recentData.ideal_cycle_time || 0,
899
956
  avg_efficiency: recentData.efficiency || 0,
900
957
  total_actions: recentData.total_output || 0,
901
- hourly_action_counts: recentData.output_array || [],
958
+ hourly_action_counts: hourlyActionCounts2,
959
+ // Now uses the NEW logic with fallback
902
960
  workspace_rank: recentData.workspace_rank || 0,
903
961
  total_workspaces: recentData.total_workspaces || workspaceConfig.totalWorkspaces || 42,
904
962
  ideal_output_until_now: recentData.ideal_output || 0,
905
963
  output_difference: outputDifference2,
906
964
  idle_time: recentData.idle_time || 0,
965
+ idle_time_hourly: recentData.idle_time_hourly || void 0,
907
966
  ...recentData.compliance_efficiency !== void 0 && { compliance_efficiency: recentData.compliance_efficiency },
908
967
  ...recentData.sop_check !== void 0 && { sop_check: recentData.sop_check }
909
968
  };
@@ -930,17 +989,66 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
930
989
  const specialWsStart = workspaceConfig.specialWorkspaces?.startId ?? 19;
931
990
  const specialWsEnd = workspaceConfig.specialWorkspaces?.endId ?? 34;
932
991
  const isSpecialWorkspace = workspaceNumber >= specialWsStart && workspaceNumber <= specialWsEnd;
933
- const minuteByMinuteArray = data.output_array || [];
992
+ const outputHourly = data.output_hourly || {};
993
+ console.log("[DEBUG] Raw data.output_hourly:", data.output_hourly);
994
+ console.log("[DEBUG] outputHourly after || {}:", outputHourly);
995
+ console.log("[DEBUG] typeof outputHourly:", typeof outputHourly);
996
+ console.log("[DEBUG] Object.keys(outputHourly):", Object.keys(outputHourly));
997
+ console.log("[DEBUG] Object.keys(outputHourly).length:", Object.keys(outputHourly).length);
998
+ const hasOutputHourlyData = outputHourly && typeof outputHourly === "object" && Object.keys(outputHourly).length > 0;
999
+ console.log("[DEBUG] hasOutputHourlyData:", hasOutputHourlyData);
934
1000
  let hourlyActionCounts = [];
935
- if (isSpecialWorkspace) {
936
- const last40Readings = minuteByMinuteArray.slice(Math.max(0, minuteByMinuteArray.length - 40));
937
- hourlyActionCounts = last40Readings;
1001
+ if (hasOutputHourlyData) {
1002
+ console.log("\u2705 Using new output_hourly column for workspace:", data.workspace_name);
1003
+ console.log("Raw output_hourly data:", JSON.stringify(outputHourly));
1004
+ const isNightShift = data.shift_id === 1;
1005
+ const shiftStart = data.shift_start || (isNightShift ? "22:00" : "06:00");
1006
+ const shiftEnd = data.shift_end || (isNightShift ? "06:00" : "14:00");
1007
+ const startHour = parseInt(shiftStart.split(":")[0]);
1008
+ let expectedHours = [];
1009
+ if (isNightShift) {
1010
+ for (let i = 0; i < 9; i++) {
1011
+ expectedHours.push((startHour + i) % 24);
1012
+ }
1013
+ } else {
1014
+ for (let i = 0; i < 9; i++) {
1015
+ expectedHours.push((startHour + i) % 24);
1016
+ }
1017
+ }
1018
+ console.log("Expected shift hours:", expectedHours);
1019
+ console.log("Available data hours:", Object.keys(outputHourly));
1020
+ hourlyActionCounts = expectedHours.map((expectedHour) => {
1021
+ let hourData = outputHourly[expectedHour.toString()];
1022
+ if (!hourData && isNightShift) {
1023
+ for (const [storedHour, data2] of Object.entries(outputHourly)) {
1024
+ if (Array.isArray(data2) && data2.length > 0 && data2.some((val) => val > 0)) {
1025
+ if (storedHour === "18" && expectedHour === 1) {
1026
+ hourData = data2;
1027
+ console.log(`Mapping stored hour ${storedHour} to expected hour ${expectedHour}`);
1028
+ break;
1029
+ }
1030
+ }
1031
+ }
1032
+ }
1033
+ return Array.isArray(hourData) ? hourData.reduce((sum, count) => sum + (count || 0), 0) : 0;
1034
+ });
1035
+ console.log("Final hourly action counts:", hourlyActionCounts);
938
1036
  } else {
939
- for (let i = 0; i < minuteByMinuteArray.length; i += 60) {
940
- const hourSlice = minuteByMinuteArray.slice(i, Math.min(i + 60, minuteByMinuteArray.length));
941
- const hourlySum = hourSlice.reduce((sum, count) => sum + count, 0);
942
- hourlyActionCounts.push(hourlySum);
1037
+ console.log("\u274C Using output_array fallback for workspace:", data.workspace_name);
1038
+ console.log("[DEBUG] Fallback reason - hasOutputHourlyData is false");
1039
+ console.log("[DEBUG] data.output_hourly was:", data.output_hourly);
1040
+ const minuteByMinuteArray = data.output_array || [];
1041
+ if (isSpecialWorkspace) {
1042
+ const last40Readings = minuteByMinuteArray.slice(Math.max(0, minuteByMinuteArray.length - 40));
1043
+ hourlyActionCounts = last40Readings;
1044
+ } else {
1045
+ for (let i = 0; i < minuteByMinuteArray.length; i += 60) {
1046
+ const hourSlice = minuteByMinuteArray.slice(i, Math.min(i + 60, minuteByMinuteArray.length));
1047
+ const hourlySum = hourSlice.reduce((sum, count) => sum + count, 0);
1048
+ hourlyActionCounts.push(hourlySum);
1049
+ }
943
1050
  }
1051
+ console.log("Final hourly action counts:", hourlyActionCounts);
944
1052
  }
945
1053
  const transformedData = {
946
1054
  workspace_id: data.workspace_id,
@@ -969,6 +1077,8 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
969
1077
  output_difference: outputDifference,
970
1078
  idle_time: data.idle_time || 0,
971
1079
  // Add idle_time from performance_metrics table
1080
+ idle_time_hourly: data.idle_time_hourly || void 0,
1081
+ // Add idle_time_hourly from performance_metrics table
972
1082
  ...data.compliance_efficiency !== void 0 && { compliance_efficiency: data.compliance_efficiency },
973
1083
  ...data.sop_check !== void 0 && { sop_check: data.sop_check }
974
1084
  };
@@ -982,7 +1092,7 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
982
1092
  setIsLoading(false);
983
1093
  }
984
1094
  }, [supabase, workspaceId, date, shiftId, metricsTable, defaultTimezone, shiftConfig, workspaceConfig, companyId]);
985
- const queueUpdate = React33.useCallback(() => {
1095
+ const queueUpdate = React14.useCallback(() => {
986
1096
  if (!workspaceId || updateQueueRef.current) return;
987
1097
  updateQueueRef.current = true;
988
1098
  if (timeoutRef.current) {
@@ -992,7 +1102,7 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
992
1102
  fetchMetrics();
993
1103
  }, 500);
994
1104
  }, [fetchMetrics, workspaceId]);
995
- const setupSubscription = React33.useCallback(() => {
1105
+ const setupSubscription = React14.useCallback(() => {
996
1106
  if (!workspaceId) return;
997
1107
  if (channelRef.current) {
998
1108
  supabase.removeChannel(channelRef.current);
@@ -1013,7 +1123,7 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
1013
1123
  console.log(`Workspace detailed metrics subscription status:`, status);
1014
1124
  });
1015
1125
  }, [supabase, workspaceId, fetchMetrics, schema, metricsTable, metricsTablePrefix]);
1016
- React33.useEffect(() => {
1126
+ React14.useEffect(() => {
1017
1127
  if (!workspaceId) {
1018
1128
  setIsLoading(false);
1019
1129
  return;
@@ -1126,28 +1236,28 @@ var useLineWorkspaceMetrics = (lineId, options) => {
1126
1236
  const dateTimeConfig = useDateTimeConfig();
1127
1237
  const shiftConfig = useShiftConfig();
1128
1238
  const supabase = useSupabase();
1129
- const [workspaces, setWorkspaces] = React33.useState([]);
1130
- const [loading, setLoading] = React33.useState(true);
1131
- const [error, setError] = React33.useState(null);
1132
- const [initialized, setInitialized] = React33.useState(false);
1133
- const queryShiftId = React33.useMemo(() => {
1239
+ const [workspaces, setWorkspaces] = React14.useState([]);
1240
+ const [loading, setLoading] = React14.useState(true);
1241
+ const [error, setError] = React14.useState(null);
1242
+ const [initialized, setInitialized] = React14.useState(false);
1243
+ const queryShiftId = React14.useMemo(() => {
1134
1244
  const currentShift = getCurrentShift(
1135
1245
  dateTimeConfig.defaultTimezone || "Asia/Kolkata",
1136
1246
  shiftConfig
1137
1247
  );
1138
1248
  return options?.initialShiftId !== void 0 ? options.initialShiftId : currentShift.shiftId;
1139
1249
  }, [options?.initialShiftId, dateTimeConfig.defaultTimezone, shiftConfig]);
1140
- const queryDate = React33.useMemo(() => {
1250
+ const queryDate = React14.useMemo(() => {
1141
1251
  return options?.initialDate || getOperationalDate(dateTimeConfig.defaultTimezone);
1142
1252
  }, [options?.initialDate, dateTimeConfig.defaultTimezone]);
1143
- const metricsTable = React33.useMemo(() => {
1253
+ const metricsTable = React14.useMemo(() => {
1144
1254
  const companyId = entityConfig.companyId;
1145
1255
  if (!companyId) return "";
1146
1256
  const metricsTablePrefix = getMetricsTablePrefix();
1147
1257
  return `${metricsTablePrefix}_${companyId.replace(/-/g, "_")}`;
1148
1258
  }, [entityConfig.companyId]);
1149
1259
  const schema = databaseConfig.schema ?? "public";
1150
- const fetchWorkspaceMetrics = React33.useCallback(async () => {
1260
+ const fetchWorkspaceMetrics = React14.useCallback(async () => {
1151
1261
  if (!lineId) return;
1152
1262
  if (!initialized) {
1153
1263
  setLoading(true);
@@ -1198,7 +1308,7 @@ var useLineWorkspaceMetrics = (lineId, options) => {
1198
1308
  setLoading(false);
1199
1309
  }
1200
1310
  }, [lineId, queryDate, queryShiftId, metricsTable, supabase, entityConfig.companyId]);
1201
- React33.useEffect(() => {
1311
+ React14.useEffect(() => {
1202
1312
  if (!initialized) {
1203
1313
  fetchWorkspaceMetrics();
1204
1314
  }
@@ -1228,11 +1338,11 @@ var useLineWorkspaceMetrics = (lineId, options) => {
1228
1338
  }
1229
1339
  };
1230
1340
  }, [lineId, queryDate, queryShiftId, metricsTable, fetchWorkspaceMetrics, initialized, supabase, schema]);
1231
- React33.useEffect(() => {
1341
+ React14.useEffect(() => {
1232
1342
  setInitialized(false);
1233
1343
  }, [lineId, queryDate, queryShiftId]);
1234
1344
  const refreshWorkspaces = fetchWorkspaceMetrics;
1235
- return React33.useMemo(
1345
+ return React14.useMemo(
1236
1346
  () => ({ workspaces, loading, error, refreshWorkspaces }),
1237
1347
  [workspaces, loading, error, refreshWorkspaces]
1238
1348
  );
@@ -1489,16 +1599,56 @@ var dashboardService = {
1489
1599
  const specialStart = workspaceConfig.specialWorkspaces?.startId ?? 19;
1490
1600
  const specialEnd = workspaceConfig.specialWorkspaces?.endId ?? 34;
1491
1601
  const isSpecialWorkspace = workspaceNumber >= specialStart && workspaceNumber <= specialEnd;
1492
- const minuteByMinuteArray = data.output_array || [];
1602
+ const outputHourly = data.output_hourly || {};
1603
+ const hasOutputHourlyData = outputHourly && typeof outputHourly === "object" && Object.keys(outputHourly).length > 0;
1493
1604
  let hourlyActionCounts = [];
1494
- if (isSpecialWorkspace) {
1495
- const numReadings = workspaceConfig.specialWorkspaces?.hourlyReadingsCount ?? 40;
1496
- hourlyActionCounts = minuteByMinuteArray.slice(-numReadings);
1605
+ if (hasOutputHourlyData) {
1606
+ console.log("Using new output_hourly column for workspace:", data.workspace_name);
1607
+ console.log("Raw output_hourly data:", outputHourly);
1608
+ const isNightShift = data.shift_id === 1;
1609
+ const shiftStart = data.shift_start || (isNightShift ? "22:00" : "06:00");
1610
+ const shiftEnd = data.shift_end || (isNightShift ? "06:00" : "14:00");
1611
+ const startHour = parseInt(shiftStart.split(":")[0]);
1612
+ let expectedHours = [];
1613
+ if (isNightShift) {
1614
+ for (let i = 0; i < 9; i++) {
1615
+ expectedHours.push((startHour + i) % 24);
1616
+ }
1617
+ } else {
1618
+ for (let i = 0; i < 9; i++) {
1619
+ expectedHours.push((startHour + i) % 24);
1620
+ }
1621
+ }
1622
+ console.log("Expected shift hours:", expectedHours);
1623
+ console.log("Available data hours:", Object.keys(outputHourly));
1624
+ hourlyActionCounts = expectedHours.map((expectedHour) => {
1625
+ let hourData = outputHourly[expectedHour.toString()];
1626
+ if (!hourData && isNightShift) {
1627
+ for (const [storedHour, data2] of Object.entries(outputHourly)) {
1628
+ if (Array.isArray(data2) && data2.length > 0 && data2.some((val) => val > 0)) {
1629
+ if (storedHour === "18" && expectedHour === 1) {
1630
+ hourData = data2;
1631
+ console.log(`Mapping stored hour ${storedHour} to expected hour ${expectedHour}`);
1632
+ break;
1633
+ }
1634
+ }
1635
+ }
1636
+ }
1637
+ return Array.isArray(hourData) ? hourData.reduce((sum, count) => sum + (count || 0), 0) : 0;
1638
+ });
1639
+ console.log("Final hourly action counts:", hourlyActionCounts);
1497
1640
  } else {
1498
- for (let i = 0; i < minuteByMinuteArray.length; i += 60) {
1499
- const hourSlice = minuteByMinuteArray.slice(i, Math.min(i + 60, minuteByMinuteArray.length));
1500
- const hourlySum = hourSlice.reduce((sum, count) => sum + (count ?? 0), 0);
1501
- hourlyActionCounts.push(hourlySum);
1641
+ console.log("Using output_array fallback for workspace:", data.workspace_name);
1642
+ const minuteByMinuteArray = data.output_array || [];
1643
+ if (isSpecialWorkspace) {
1644
+ const numReadings = workspaceConfig.specialWorkspaces?.hourlyReadingsCount ?? 40;
1645
+ hourlyActionCounts = minuteByMinuteArray.slice(-numReadings);
1646
+ } else {
1647
+ for (let i = 0; i < minuteByMinuteArray.length; i += 60) {
1648
+ const hourSlice = minuteByMinuteArray.slice(i, Math.min(i + 60, minuteByMinuteArray.length));
1649
+ const hourlySum = hourSlice.reduce((sum, count) => sum + (count ?? 0), 0);
1650
+ hourlyActionCounts.push(hourlySum);
1651
+ }
1502
1652
  }
1503
1653
  }
1504
1654
  const transformedData = {
@@ -1527,6 +1677,7 @@ var dashboardService = {
1527
1677
  ideal_output_until_now: data.ideal_output || 0,
1528
1678
  output_difference: outputDifference,
1529
1679
  idle_time: data.idle_time || 0,
1680
+ idle_time_hourly: data.idle_time_hourly || void 0,
1530
1681
  ...data.compliance_efficiency !== void 0 && { compliance_efficiency: data.compliance_efficiency },
1531
1682
  ...data.sop_check !== void 0 && { sop_check: data.sop_check }
1532
1683
  };
@@ -1874,10 +2025,10 @@ var dashboardService = {
1874
2025
  // src/lib/hooks/useHistoricWorkspaceMetrics.ts
1875
2026
  var useHistoricWorkspaceMetrics = (workspaceId, date, inputShiftId) => {
1876
2027
  useSupabase();
1877
- const [metrics2, setMetrics] = React33.useState(null);
1878
- const [isLoading, setIsLoading] = React33.useState(true);
1879
- const [error, setError] = React33.useState(null);
1880
- const fetchAndAnimateMetrics = React33.useCallback(async () => {
2028
+ const [metrics2, setMetrics] = React14.useState(null);
2029
+ const [isLoading, setIsLoading] = React14.useState(true);
2030
+ const [error, setError] = React14.useState(null);
2031
+ const fetchAndAnimateMetrics = React14.useCallback(async () => {
1881
2032
  if (!workspaceId || !date || inputShiftId === void 0) {
1882
2033
  setMetrics(null);
1883
2034
  setIsLoading(false);
@@ -1935,10 +2086,10 @@ var useHistoricWorkspaceMetrics = (workspaceId, date, inputShiftId) => {
1935
2086
  setMetrics(null);
1936
2087
  }
1937
2088
  }, [workspaceId, date, inputShiftId]);
1938
- React33.useEffect(() => {
2089
+ React14.useEffect(() => {
1939
2090
  fetchAndAnimateMetrics();
1940
2091
  }, [fetchAndAnimateMetrics]);
1941
- const refetch = React33.useCallback(async () => {
2092
+ const refetch = React14.useCallback(async () => {
1942
2093
  if (!workspaceId || !date || inputShiftId === void 0) {
1943
2094
  setError(null);
1944
2095
  return;
@@ -2949,15 +3100,15 @@ var useLineDetailedMetrics = (lineIdFromProp) => {
2949
3100
  const dateTimeConfig = useDateTimeConfig();
2950
3101
  const shiftConfig = useShiftConfig();
2951
3102
  const supabase = useSupabase();
2952
- const [lineData, setLineData] = React33.useState(null);
2953
- const [loading, setLoading] = React33.useState(true);
2954
- const [error, setError] = React33.useState(null);
2955
- const channelRef = React33.useRef(null);
3103
+ const [lineData, setLineData] = React14.useState(null);
3104
+ const [loading, setLoading] = React14.useState(true);
3105
+ const [error, setError] = React14.useState(null);
3106
+ const channelRef = React14.useRef(null);
2956
3107
  const defaultTimezone = dateTimeConfig.defaultTimezone;
2957
3108
  const schema = databaseConfig.schema ?? "public";
2958
3109
  const lineMetricsTable = databaseConfig.tables?.lineMetrics ?? "line_metrics";
2959
3110
  const lineIdToUse = lineIdFromProp === "factory" ? entityConfig.factoryViewId || "factory" : lineIdFromProp;
2960
- const fetchData = React33.useCallback(async () => {
3111
+ const fetchData = React14.useCallback(async () => {
2961
3112
  if (!dashboardService || !lineIdToUse) {
2962
3113
  setLoading(false);
2963
3114
  if (!dashboardService && lineIdToUse) {
@@ -2986,7 +3137,7 @@ var useLineDetailedMetrics = (lineIdFromProp) => {
2986
3137
  setLoading(false);
2987
3138
  }
2988
3139
  }, [dashboardService, lineIdToUse, defaultTimezone, shiftConfig, entityConfig]);
2989
- React33.useEffect(() => {
3140
+ React14.useEffect(() => {
2990
3141
  if (!supabase || !lineIdToUse || !entityConfig.companyId) {
2991
3142
  setLoading(false);
2992
3143
  if (!entityConfig.companyId && (!error || error.code !== "SERVICE_ERROR")) {
@@ -3068,15 +3219,15 @@ var useLeaderboardMetrics = (lineId, topCount = 10) => {
3068
3219
  const dateTimeConfig = useDateTimeConfig();
3069
3220
  const shiftConfig = useShiftConfig();
3070
3221
  const supabase = useSupabase();
3071
- const [topPerformers, setTopPerformers] = React33.useState([]);
3072
- const [isLoading, setIsLoading] = React33.useState(true);
3073
- const [error, setError] = React33.useState(null);
3074
- const companySpecificMetricsTable = React33.useMemo(() => {
3222
+ const [topPerformers, setTopPerformers] = React14.useState([]);
3223
+ const [isLoading, setIsLoading] = React14.useState(true);
3224
+ const [error, setError] = React14.useState(null);
3225
+ const companySpecificMetricsTable = React14.useMemo(() => {
3075
3226
  return getCompanyMetricsTableName(entityConfig.companyId);
3076
3227
  }, [entityConfig.companyId]);
3077
3228
  const schema = databaseConfig.schema ?? "public";
3078
3229
  const defaultTimezone = dateTimeConfig.defaultTimezone;
3079
- const fetchLeaderboardData = React33.useCallback(async () => {
3230
+ const fetchLeaderboardData = React14.useCallback(async () => {
3080
3231
  if (!lineId || !supabase || companySpecificMetricsTable.includes("unknown_company")) {
3081
3232
  setIsLoading(false);
3082
3233
  if (companySpecificMetricsTable.includes("unknown_company")) {
@@ -3109,7 +3260,7 @@ var useLeaderboardMetrics = (lineId, topCount = 10) => {
3109
3260
  setIsLoading(false);
3110
3261
  }
3111
3262
  }, [supabase, lineId, topCount, companySpecificMetricsTable, defaultTimezone, shiftConfig]);
3112
- React33.useEffect(() => {
3263
+ React14.useEffect(() => {
3113
3264
  if (!lineId || !supabase || companySpecificMetricsTable.includes("unknown_company")) {
3114
3265
  setIsLoading(false);
3115
3266
  if (error?.code !== "CONFIG_ERROR") setError(null);
@@ -3187,27 +3338,27 @@ var useDashboardMetrics = ({ onLineMetricsUpdate, lineId }) => {
3187
3338
  const dateTimeConfig = useDateTimeConfig();
3188
3339
  const shiftConfig = useShiftConfig();
3189
3340
  const supabase = useSupabase();
3190
- const [metrics2, setMetrics] = React33.useState(() => getCache(lineId) || { workspaceMetrics: [], lineMetrics: [] });
3191
- const [isLoading, setIsLoading] = React33.useState(() => !getCache(lineId));
3192
- const [error, setError] = React33.useState(null);
3193
- const lineIdRef = React33.useRef(lineId);
3194
- const isFetchingRef = React33.useRef(false);
3195
- const updateQueueRef = React33.useRef(false);
3196
- const timeoutRef = React33.useRef(null);
3197
- const companySpecificMetricsTable = React33.useMemo(
3341
+ const [metrics2, setMetrics] = React14.useState(() => getCache(lineId) || { workspaceMetrics: [], lineMetrics: [] });
3342
+ const [isLoading, setIsLoading] = React14.useState(() => !getCache(lineId));
3343
+ const [error, setError] = React14.useState(null);
3344
+ const lineIdRef = React14.useRef(lineId);
3345
+ const isFetchingRef = React14.useRef(false);
3346
+ const updateQueueRef = React14.useRef(false);
3347
+ const timeoutRef = React14.useRef(null);
3348
+ const companySpecificMetricsTable = React14.useMemo(
3198
3349
  () => getCompanyMetricsTableName(entityConfig.companyId, "performance_metrics"),
3199
3350
  [entityConfig.companyId]
3200
3351
  );
3201
3352
  const configuredLineMetricsTable = databaseConfig.tables?.lineMetrics ?? "line_metrics";
3202
3353
  const schema = databaseConfig.schema ?? "public";
3203
3354
  const defaultTimezone = dateTimeConfig.defaultTimezone || "UTC";
3204
- React33.useEffect(() => {
3355
+ React14.useEffect(() => {
3205
3356
  lineIdRef.current = lineId;
3206
3357
  const cachedData = getCache(lineId);
3207
3358
  setMetrics(cachedData || { workspaceMetrics: [], lineMetrics: [] });
3208
3359
  setIsLoading(!cachedData);
3209
3360
  }, [lineId]);
3210
- const fetchAllMetrics = React33.useCallback(async () => {
3361
+ const fetchAllMetrics = React14.useCallback(async () => {
3211
3362
  const currentLineIdToUse = lineIdRef.current;
3212
3363
  if (!currentLineIdToUse || !supabase || isFetchingRef.current || companySpecificMetricsTable.includes("unknown_company")) {
3213
3364
  if (!metrics2.workspaceMetrics.length && !metrics2.lineMetrics.length) setIsLoading(false);
@@ -3293,7 +3444,7 @@ var useDashboardMetrics = ({ onLineMetricsUpdate, lineId }) => {
3293
3444
  defaultTimezone,
3294
3445
  shiftConfig
3295
3446
  ]);
3296
- const queueUpdate = React33.useCallback(() => {
3447
+ const queueUpdate = React14.useCallback(() => {
3297
3448
  if (updateQueueRef.current || !supabase) {
3298
3449
  return;
3299
3450
  }
@@ -3305,12 +3456,12 @@ var useDashboardMetrics = ({ onLineMetricsUpdate, lineId }) => {
3305
3456
  fetchAllMetrics();
3306
3457
  }, 500);
3307
3458
  }, [fetchAllMetrics, supabase]);
3308
- React33.useEffect(() => {
3459
+ React14.useEffect(() => {
3309
3460
  if (lineId && supabase) {
3310
3461
  fetchAllMetrics();
3311
3462
  }
3312
3463
  }, [lineId, supabase, fetchAllMetrics]);
3313
- React33.useEffect(() => {
3464
+ React14.useEffect(() => {
3314
3465
  const currentLineIdToUse = lineIdRef.current;
3315
3466
  if (!currentLineIdToUse || !supabase || companySpecificMetricsTable.includes("unknown_company") || !entityConfig.companyId) {
3316
3467
  return;
@@ -3410,27 +3561,27 @@ var useLineKPIs = ({ lineId }) => {
3410
3561
  const dateTimeConfig = useDateTimeConfig();
3411
3562
  const shiftConfig = useShiftConfig();
3412
3563
  const supabase = useSupabase();
3413
- const dashboardServiceInstance = React33.useMemo(() => {
3564
+ const dashboardServiceInstance = React14.useMemo(() => {
3414
3565
  return dashboardService;
3415
3566
  }, []);
3416
- const [kpis, setKPIs] = React33.useState(() => getCache2(lineId));
3417
- const [isLoading, setIsLoading] = React33.useState(!getCache2(lineId));
3418
- const [error, setError] = React33.useState(null);
3419
- const lineIdRef = React33.useRef(lineId);
3420
- const isFetchingRef = React33.useRef(false);
3421
- const updateQueueRef = React33.useRef(false);
3422
- const timeoutRef = React33.useRef(null);
3567
+ const [kpis, setKPIs] = React14.useState(() => getCache2(lineId));
3568
+ const [isLoading, setIsLoading] = React14.useState(!getCache2(lineId));
3569
+ const [error, setError] = React14.useState(null);
3570
+ const lineIdRef = React14.useRef(lineId);
3571
+ const isFetchingRef = React14.useRef(false);
3572
+ const updateQueueRef = React14.useRef(false);
3573
+ const timeoutRef = React14.useRef(null);
3423
3574
  const defaultTimezone = dateTimeConfig.defaultTimezone;
3424
3575
  const schema = databaseConfig.schema ?? "public";
3425
3576
  const lineMetricsTable = databaseConfig.tables?.lineMetrics ?? "line_metrics";
3426
- const companySpecificMetricsTable = React33.useMemo(
3577
+ const companySpecificMetricsTable = React14.useMemo(
3427
3578
  () => entityConfig.companyId ? getCompanyMetricsTableName(entityConfig.companyId, "workspace_performance") : null,
3428
3579
  [entityConfig.companyId]
3429
3580
  );
3430
- React33.useEffect(() => {
3581
+ React14.useEffect(() => {
3431
3582
  lineIdRef.current = lineId;
3432
3583
  }, [lineId]);
3433
- const fetchKPIs = React33.useCallback(async () => {
3584
+ const fetchKPIs = React14.useCallback(async () => {
3434
3585
  const currentLineId = lineIdRef.current;
3435
3586
  if (!currentLineId || !dashboardServiceInstance || isFetchingRef.current) {
3436
3587
  if (!kpis && !isFetchingRef.current) setIsLoading(false);
@@ -3464,7 +3615,7 @@ var useLineKPIs = ({ lineId }) => {
3464
3615
  updateQueueRef.current = false;
3465
3616
  }
3466
3617
  }, [dashboardServiceInstance, kpis, defaultTimezone, shiftConfig, entityConfig.companyId]);
3467
- const queueUpdate = React33.useCallback(() => {
3618
+ const queueUpdate = React14.useCallback(() => {
3468
3619
  if (updateQueueRef.current) return;
3469
3620
  updateQueueRef.current = true;
3470
3621
  if (timeoutRef.current) {
@@ -3474,7 +3625,7 @@ var useLineKPIs = ({ lineId }) => {
3474
3625
  fetchKPIs();
3475
3626
  }, 500);
3476
3627
  }, [fetchKPIs]);
3477
- React33.useEffect(() => {
3628
+ React14.useEffect(() => {
3478
3629
  const currentLineId = lineIdRef.current;
3479
3630
  if (!currentLineId || !supabase || !dashboardServiceInstance) {
3480
3631
  if (!kpis) setIsLoading(false);
@@ -3557,23 +3708,23 @@ var useRealtimeLineMetrics = ({
3557
3708
  useDatabaseConfig();
3558
3709
  const dateTimeConfig = useDateTimeConfig();
3559
3710
  const shiftConfig = useShiftConfig();
3560
- const [metrics2, setMetrics] = React33.useState(null);
3561
- const [lineDetails, setLineDetails] = React33.useState(null);
3562
- const [loading, setLoading] = React33.useState(true);
3563
- const [error, setError] = React33.useState(null);
3564
- const [initialized, setInitialized] = React33.useState(false);
3565
- const lineIdRef = React33.useRef(null);
3566
- const updateQueueRef = React33.useRef(false);
3567
- const timeoutRef = React33.useRef(null);
3568
- const isFetchingRef = React33.useRef(false);
3569
- const channelsRef = React33.useRef([]);
3570
- const currentShift = React33.useMemo(() => getCurrentShift(dateTimeConfig.defaultTimezone || "Asia/Kolkata", shiftConfig), [dateTimeConfig.defaultTimezone, shiftConfig]);
3571
- const shiftId = React33.useMemo(
3711
+ const [metrics2, setMetrics] = React14.useState(null);
3712
+ const [lineDetails, setLineDetails] = React14.useState(null);
3713
+ const [loading, setLoading] = React14.useState(true);
3714
+ const [error, setError] = React14.useState(null);
3715
+ const [initialized, setInitialized] = React14.useState(false);
3716
+ const lineIdRef = React14.useRef(null);
3717
+ const updateQueueRef = React14.useRef(false);
3718
+ const timeoutRef = React14.useRef(null);
3719
+ const isFetchingRef = React14.useRef(false);
3720
+ const channelsRef = React14.useRef([]);
3721
+ const currentShift = React14.useMemo(() => getCurrentShift(dateTimeConfig.defaultTimezone || "Asia/Kolkata", shiftConfig), [dateTimeConfig.defaultTimezone, shiftConfig]);
3722
+ const shiftId = React14.useMemo(
3572
3723
  () => urlShiftId !== void 0 ? urlShiftId : currentShift.shiftId,
3573
3724
  [urlShiftId, currentShift.shiftId]
3574
3725
  );
3575
- const date = React33.useMemo(() => urlDate || getOperationalDate(dateTimeConfig.defaultTimezone), [urlDate, dateTimeConfig.defaultTimezone]);
3576
- const fetchData = React33.useCallback(async () => {
3726
+ const date = React14.useMemo(() => urlDate || getOperationalDate(dateTimeConfig.defaultTimezone), [urlDate, dateTimeConfig.defaultTimezone]);
3727
+ const fetchData = React14.useCallback(async () => {
3577
3728
  try {
3578
3729
  if (!lineIdRef.current || isFetchingRef.current) return;
3579
3730
  isFetchingRef.current = true;
@@ -3784,7 +3935,7 @@ var useRealtimeLineMetrics = ({
3784
3935
  isFetchingRef.current = false;
3785
3936
  }
3786
3937
  }, [supabase, date, shiftId, urlShiftId, onMetricsUpdate, entityConfig, dateTimeConfig.defaultTimezone]);
3787
- const queueUpdate = React33.useCallback(() => {
3938
+ const queueUpdate = React14.useCallback(() => {
3788
3939
  if (updateQueueRef.current) return;
3789
3940
  updateQueueRef.current = true;
3790
3941
  if (timeoutRef.current) {
@@ -3794,7 +3945,7 @@ var useRealtimeLineMetrics = ({
3794
3945
  fetchData();
3795
3946
  }, 500);
3796
3947
  }, [fetchData]);
3797
- const setupSubscriptions = React33.useCallback(() => {
3948
+ const setupSubscriptions = React14.useCallback(() => {
3798
3949
  if (channelsRef.current.length > 0) {
3799
3950
  channelsRef.current.forEach((channel) => {
3800
3951
  supabase.removeChannel(channel);
@@ -3864,7 +4015,7 @@ var useRealtimeLineMetrics = ({
3864
4015
  });
3865
4016
  channelsRef.current = [lineMetricsChannel, metricsChannel];
3866
4017
  }, [supabase, queueUpdate, urlDate, shiftId, entityConfig, dateTimeConfig.defaultTimezone]);
3867
- React33.useEffect(() => {
4018
+ React14.useEffect(() => {
3868
4019
  if (!lineId) return;
3869
4020
  lineIdRef.current = lineId;
3870
4021
  if (!initialized) {
@@ -3885,10 +4036,10 @@ var useRealtimeLineMetrics = ({
3885
4036
  }
3886
4037
  };
3887
4038
  }, [lineId, fetchData, setupSubscriptions, initialized, supabase]);
3888
- React33.useEffect(() => {
4039
+ React14.useEffect(() => {
3889
4040
  setInitialized(false);
3890
4041
  }, [lineId, date, shiftId]);
3891
- return React33.useMemo(() => ({
4042
+ return React14.useMemo(() => ({
3892
4043
  metrics: metrics2,
3893
4044
  lineDetails,
3894
4045
  loading,
@@ -3900,11 +4051,11 @@ var DEFAULT_TARGETS_TABLE_NAME = "targets";
3900
4051
  var useTargets = (options) => {
3901
4052
  const { companyId } = useEntityConfig();
3902
4053
  const supabase = useSupabase();
3903
- const [targets, setTargets] = React33.useState([]);
3904
- const [isLoading, setIsLoading] = React33.useState(true);
3905
- const [error, setError] = React33.useState(null);
4054
+ const [targets, setTargets] = React14.useState([]);
4055
+ const [isLoading, setIsLoading] = React14.useState(true);
4056
+ const [error, setError] = React14.useState(null);
3906
4057
  const targetsTable = DEFAULT_TARGETS_TABLE_NAME;
3907
- const fetchData = React33.useCallback(async () => {
4058
+ const fetchData = React14.useCallback(async () => {
3908
4059
  if (!supabase) {
3909
4060
  setError({ message: "Supabase client not initialized.", code: "CLIENT_INIT_ERROR" });
3910
4061
  setIsLoading(false);
@@ -3948,7 +4099,7 @@ var useTargets = (options) => {
3948
4099
  setIsLoading(false);
3949
4100
  }
3950
4101
  }, [supabase, companyId, targetsTable, options]);
3951
- React33.useEffect(() => {
4102
+ React14.useEffect(() => {
3952
4103
  fetchData();
3953
4104
  }, [fetchData]);
3954
4105
  return {
@@ -3963,15 +4114,15 @@ var useShifts = () => {
3963
4114
  const { supabaseUrl, supabaseKey } = useDashboardConfig();
3964
4115
  const { companyId } = useEntityConfig();
3965
4116
  const { tables } = useDatabaseConfig();
3966
- const [shifts, setShifts] = React33.useState([]);
3967
- const [isLoading, setIsLoading] = React33.useState(true);
3968
- const [error, setError] = React33.useState(null);
3969
- const supabase = React33.useMemo(() => {
4117
+ const [shifts, setShifts] = React14.useState([]);
4118
+ const [isLoading, setIsLoading] = React14.useState(true);
4119
+ const [error, setError] = React14.useState(null);
4120
+ const supabase = React14.useMemo(() => {
3970
4121
  if (!supabaseUrl || !supabaseKey) return null;
3971
4122
  return supabaseJs.createClient(supabaseUrl, supabaseKey);
3972
4123
  }, [supabaseUrl, supabaseKey]);
3973
4124
  const shiftsTable = tables?.shiftConfigurations || DEFAULT_SHIFTS_TABLE_NAME;
3974
- const fetchData = React33.useCallback(async () => {
4125
+ const fetchData = React14.useCallback(async () => {
3975
4126
  if (!supabase) {
3976
4127
  setError({ message: "Supabase client not initialized.", code: "CLIENT_INIT_ERROR" });
3977
4128
  setIsLoading(false);
@@ -4000,7 +4151,7 @@ var useShifts = () => {
4000
4151
  setIsLoading(false);
4001
4152
  }
4002
4153
  }, [supabase, companyId, shiftsTable]);
4003
- React33.useEffect(() => {
4154
+ React14.useEffect(() => {
4004
4155
  fetchData();
4005
4156
  }, [fetchData]);
4006
4157
  return {
@@ -4014,11 +4165,11 @@ var DEFAULT_OPERATORS_TABLE_NAME = "workspace_operator_assignments";
4014
4165
  var useWorkspaceOperators = (workspaceId, options) => {
4015
4166
  const { companyId } = useEntityConfig();
4016
4167
  const supabase = useSupabase();
4017
- const [operators, setOperators] = React33.useState([]);
4018
- const [isLoading, setIsLoading] = React33.useState(true);
4019
- const [error, setError] = React33.useState(null);
4168
+ const [operators, setOperators] = React14.useState([]);
4169
+ const [isLoading, setIsLoading] = React14.useState(true);
4170
+ const [error, setError] = React14.useState(null);
4020
4171
  const operatorsTable = DEFAULT_OPERATORS_TABLE_NAME;
4021
- const fetchData = React33.useCallback(async () => {
4172
+ const fetchData = React14.useCallback(async () => {
4022
4173
  if (!workspaceId) {
4023
4174
  setError({ message: "Workspace ID is required.", code: "MISSING_PARAM" });
4024
4175
  setIsLoading(false);
@@ -4060,7 +4211,7 @@ var useWorkspaceOperators = (workspaceId, options) => {
4060
4211
  setIsLoading(false);
4061
4212
  }
4062
4213
  }, [supabase, companyId, workspaceId, operatorsTable, options]);
4063
- React33.useEffect(() => {
4214
+ React14.useEffect(() => {
4064
4215
  fetchData();
4065
4216
  }, [fetchData]);
4066
4217
  return {
@@ -4101,7 +4252,7 @@ function useThreads() {
4101
4252
  revalidateOnFocus: false,
4102
4253
  revalidateOnReconnect: true
4103
4254
  });
4104
- const createThread = React33.useCallback(async (title) => {
4255
+ const createThread = React14.useCallback(async (title) => {
4105
4256
  const { data: { session } } = await supabase.auth.getSession();
4106
4257
  if (!session?.user) throw new Error("Not authenticated");
4107
4258
  const user = session.user;
@@ -4123,7 +4274,7 @@ function useThreads() {
4123
4274
  mutate([data, ...threads], false);
4124
4275
  return data;
4125
4276
  }, [supabase, threads, mutate]);
4126
- const deleteThread2 = React33.useCallback(async (threadId) => {
4277
+ const deleteThread2 = React14.useCallback(async (threadId) => {
4127
4278
  const { error: error2 } = await supabase.schema("ai").from("chat_threads").delete().eq("id", threadId);
4128
4279
  if (error2) throw error2;
4129
4280
  mutate(threads.filter((t) => t.id !== threadId), false);
@@ -4139,10 +4290,10 @@ function useThreads() {
4139
4290
  }
4140
4291
  function useMessages(threadId) {
4141
4292
  const supabase = _getSupabaseInstance();
4142
- const [messages, setMessages] = React33.useState([]);
4143
- const [isLoading, setIsLoading] = React33.useState(true);
4144
- const [error, setError] = React33.useState(null);
4145
- React33.useEffect(() => {
4293
+ const [messages, setMessages] = React14.useState([]);
4294
+ const [isLoading, setIsLoading] = React14.useState(true);
4295
+ const [error, setError] = React14.useState(null);
4296
+ React14.useEffect(() => {
4146
4297
  if (!threadId) {
4147
4298
  setMessages([]);
4148
4299
  setIsLoading(false);
@@ -4164,7 +4315,7 @@ function useMessages(threadId) {
4164
4315
  };
4165
4316
  loadMessages();
4166
4317
  }, [threadId, supabase]);
4167
- const addMessage = React33.useCallback(async (message) => {
4318
+ const addMessage = React14.useCallback(async (message) => {
4168
4319
  const maxPosition = messages.reduce((max, msg) => Math.max(max, msg.position), -1);
4169
4320
  const { data, error: insertError } = await supabase.schema("ai").from("chat_messages").insert([{
4170
4321
  ...message,
@@ -4173,7 +4324,7 @@ function useMessages(threadId) {
4173
4324
  if (insertError) throw insertError;
4174
4325
  return data;
4175
4326
  }, [supabase, messages]);
4176
- const updateMessage = React33.useCallback(async (id3, content) => {
4327
+ const updateMessage = React14.useCallback(async (id3, content) => {
4177
4328
  const { error: updateError } = await supabase.schema("ai").from("chat_messages").update({ content }).eq("id", id3);
4178
4329
  if (updateError) throw updateError;
4179
4330
  }, [supabase]);
@@ -4192,14 +4343,14 @@ var useFactoryOverviewMetrics = (options) => {
4192
4343
  const { defaultTimezone } = useDateTimeConfig();
4193
4344
  const shiftConfig = useShiftConfig();
4194
4345
  const supabase = useSupabase();
4195
- const [factoryOverview, setFactoryOverview] = React33.useState(null);
4196
- const [isLoading, setIsLoading] = React33.useState(true);
4197
- const [error, setError] = React33.useState(null);
4346
+ const [factoryOverview, setFactoryOverview] = React14.useState(null);
4347
+ const [isLoading, setIsLoading] = React14.useState(true);
4348
+ const [error, setError] = React14.useState(null);
4198
4349
  const overviewTable = DEFAULT_FACTORY_OVERVIEW_TABLE_NAME;
4199
4350
  const determinedDate = options?.date;
4200
4351
  const determinedShiftId = options?.shiftId;
4201
4352
  const targetFactoryId = options?.factoryId || entityFactoryId;
4202
- const fetchData = React33.useCallback(async () => {
4353
+ const fetchData = React14.useCallback(async () => {
4203
4354
  if (!supabase) {
4204
4355
  setError({ message: "Supabase client not initialized.", code: "CLIENT_INIT_ERROR" });
4205
4356
  setIsLoading(false);
@@ -4238,7 +4389,7 @@ var useFactoryOverviewMetrics = (options) => {
4238
4389
  setIsLoading(false);
4239
4390
  }
4240
4391
  }, [supabase, companyId, targetFactoryId, overviewTable, determinedDate, determinedShiftId, defaultTimezone, shiftConfig]);
4241
- React33.useEffect(() => {
4392
+ React14.useEffect(() => {
4242
4393
  fetchData();
4243
4394
  }, [fetchData]);
4244
4395
  return {
@@ -4313,8 +4464,26 @@ async function initializeWorkspaceDisplayNames(explicitLineId) {
4313
4464
  isInitializing = false;
4314
4465
  }
4315
4466
  }
4467
+ var preInitializeWorkspaceDisplayNames = async (lineId) => {
4468
+ console.log("\u{1F504} preInitializeWorkspaceDisplayNames called for lineId:", lineId);
4469
+ if (isInitialized || isInitializing) {
4470
+ console.log("\u{1F504} Already initialized or initializing, skipping pre-init");
4471
+ return;
4472
+ }
4473
+ await initializeWorkspaceDisplayNames(lineId);
4474
+ };
4475
+ var forceRefreshWorkspaceDisplayNames = async (lineId) => {
4476
+ console.log("\u{1F504} forceRefreshWorkspaceDisplayNames called for lineId:", lineId);
4477
+ clearWorkspaceDisplayNamesCache();
4478
+ await initializeWorkspaceDisplayNames(lineId);
4479
+ };
4316
4480
  console.log("\u{1F504} Module loaded, will initialize lazily when first function is called");
4317
4481
  var getWorkspaceDisplayName = (workspaceId, lineId) => {
4482
+ if (!isInitialized && !isInitializing) {
4483
+ console.log(`\u{1F504} [DEBUG] getWorkspaceDisplayName(${workspaceId}) - Not initialized, triggering lazy init...`);
4484
+ } else if (isInitializing) {
4485
+ console.log(`\u{1F504} [DEBUG] getWorkspaceDisplayName(${workspaceId}) - Currently initializing...`);
4486
+ }
4318
4487
  if (!isInitialized && !isInitializing) {
4319
4488
  console.log("\u{1F504} Lazy initialization triggered by getWorkspaceDisplayName");
4320
4489
  initializeWorkspaceDisplayNames(lineId).catch((error) => {
@@ -4398,14 +4567,15 @@ var clearWorkspaceDisplayNamesCache = () => {
4398
4567
  workspaceService.clearWorkspaceDisplayNamesCache();
4399
4568
  runtimeWorkspaceDisplayNames = {};
4400
4569
  isInitialized = false;
4570
+ isInitializing = false;
4401
4571
  };
4402
4572
 
4403
4573
  // src/lib/hooks/useWorkspaceDisplayNames.ts
4404
4574
  var useWorkspaceDisplayNames = (companyId, lineId) => {
4405
- const [displayNames, setDisplayNames] = React33.useState({});
4406
- const [loading, setLoading] = React33.useState(true);
4407
- const [error, setError] = React33.useState(null);
4408
- const fetchDisplayNames = React33.useCallback(async () => {
4575
+ const [displayNames, setDisplayNames] = React14.useState({});
4576
+ const [loading, setLoading] = React14.useState(true);
4577
+ const [error, setError] = React14.useState(null);
4578
+ const fetchDisplayNames = React14.useCallback(async () => {
4409
4579
  try {
4410
4580
  setLoading(true);
4411
4581
  setError(null);
@@ -4417,7 +4587,7 @@ var useWorkspaceDisplayNames = (companyId, lineId) => {
4417
4587
  setLoading(false);
4418
4588
  }
4419
4589
  }, [companyId, lineId]);
4420
- React33.useEffect(() => {
4590
+ React14.useEffect(() => {
4421
4591
  fetchDisplayNames();
4422
4592
  }, [fetchDisplayNames]);
4423
4593
  return {
@@ -4428,10 +4598,10 @@ var useWorkspaceDisplayNames = (companyId, lineId) => {
4428
4598
  };
4429
4599
  };
4430
4600
  var useWorkspaceDisplayName = (workspaceId, companyId, lineId) => {
4431
- const [displayName, setDisplayName] = React33.useState(workspaceId);
4432
- const [loading, setLoading] = React33.useState(true);
4433
- const [error, setError] = React33.useState(null);
4434
- const fetchDisplayName = React33.useCallback(async () => {
4601
+ const [displayName, setDisplayName] = React14.useState(workspaceId);
4602
+ const [loading, setLoading] = React14.useState(true);
4603
+ const [error, setError] = React14.useState(null);
4604
+ const fetchDisplayName = React14.useCallback(async () => {
4435
4605
  try {
4436
4606
  setLoading(true);
4437
4607
  setError(null);
@@ -4444,7 +4614,7 @@ var useWorkspaceDisplayName = (workspaceId, companyId, lineId) => {
4444
4614
  setLoading(false);
4445
4615
  }
4446
4616
  }, [workspaceId, companyId, lineId]);
4447
- React33.useEffect(() => {
4617
+ React14.useEffect(() => {
4448
4618
  fetchDisplayName();
4449
4619
  }, [fetchDisplayName]);
4450
4620
  return {
@@ -4455,10 +4625,10 @@ var useWorkspaceDisplayName = (workspaceId, companyId, lineId) => {
4455
4625
  };
4456
4626
  };
4457
4627
  var useWorkspaceDisplayNamesMap = (workspaceIds, companyId, lineId) => {
4458
- const [displayNames, setDisplayNames] = React33.useState({});
4459
- const [loading, setLoading] = React33.useState(true);
4460
- const [error, setError] = React33.useState(null);
4461
- const fetchDisplayNames = React33.useCallback(async () => {
4628
+ const [displayNames, setDisplayNames] = React14.useState({});
4629
+ const [loading, setLoading] = React14.useState(true);
4630
+ const [error, setError] = React14.useState(null);
4631
+ const fetchDisplayNames = React14.useCallback(async () => {
4462
4632
  try {
4463
4633
  setLoading(true);
4464
4634
  setError(null);
@@ -4474,7 +4644,7 @@ var useWorkspaceDisplayNamesMap = (workspaceIds, companyId, lineId) => {
4474
4644
  setLoading(false);
4475
4645
  }
4476
4646
  }, [workspaceIds, companyId, lineId]);
4477
- React33.useEffect(() => {
4647
+ React14.useEffect(() => {
4478
4648
  fetchDisplayNames();
4479
4649
  }, [fetchDisplayNames]);
4480
4650
  return {
@@ -4485,9 +4655,9 @@ var useWorkspaceDisplayNamesMap = (workspaceIds, companyId, lineId) => {
4485
4655
  };
4486
4656
  };
4487
4657
  var useActiveBreaks = (lineIds) => {
4488
- const [activeBreaks, setActiveBreaks] = React33.useState([]);
4489
- const [isLoading, setIsLoading] = React33.useState(true);
4490
- const [error, setError] = React33.useState(null);
4658
+ const [activeBreaks, setActiveBreaks] = React14.useState([]);
4659
+ const [isLoading, setIsLoading] = React14.useState(true);
4660
+ const [error, setError] = React14.useState(null);
4491
4661
  const supabase = useSupabase();
4492
4662
  const parseTimeToMinutes2 = (timeStr) => {
4493
4663
  const [hours, minutes] = timeStr.split(":").map(Number);
@@ -4534,7 +4704,7 @@ var useActiveBreaks = (lineIds) => {
4534
4704
  return currentMinutes >= dayStartMinutes && currentMinutes < nightStartMinutes ? "day" : "night";
4535
4705
  }
4536
4706
  };
4537
- const checkActiveBreaks = React33.useCallback(async () => {
4707
+ const checkActiveBreaks = React14.useCallback(async () => {
4538
4708
  try {
4539
4709
  setError(null);
4540
4710
  if (!lineIds || lineIds.length === 0) {
@@ -4599,7 +4769,7 @@ var useActiveBreaks = (lineIds) => {
4599
4769
  setIsLoading(false);
4600
4770
  }
4601
4771
  }, [lineIds, supabase]);
4602
- React33.useEffect(() => {
4772
+ React14.useEffect(() => {
4603
4773
  checkActiveBreaks();
4604
4774
  const interval = setInterval(checkActiveBreaks, 6e4);
4605
4775
  return () => clearInterval(interval);
@@ -4618,18 +4788,18 @@ function useNavigation(customNavigate) {
4618
4788
  const pathname = router$1.pathname;
4619
4789
  const query = router$1.query;
4620
4790
  const isReady = router$1.isReady;
4621
- const isActive = React33.useCallback((path) => {
4791
+ const isActive = React14.useCallback((path) => {
4622
4792
  const normalizedPath = path.endsWith("/") ? path.slice(0, -1) : path;
4623
4793
  const normalizedPathname = pathname.endsWith("/") ? pathname.slice(0, -1) : pathname;
4624
4794
  return normalizedPathname === normalizedPath;
4625
4795
  }, [pathname]);
4626
- const isInSection = React33.useCallback((path) => {
4796
+ const isInSection = React14.useCallback((path) => {
4627
4797
  return pathname.startsWith(path);
4628
4798
  }, [pathname]);
4629
- const goToDashboard = React33.useCallback(() => {
4799
+ const goToDashboard = React14.useCallback(() => {
4630
4800
  router$1.push("/");
4631
4801
  }, [router$1]);
4632
- const goToWorkspace = React33.useCallback(({ workspaceId, date, shift, sourceType }) => {
4802
+ const goToWorkspace = React14.useCallback(({ workspaceId, date, shift, sourceType }) => {
4633
4803
  const queryParams = {};
4634
4804
  if (date) queryParams.date = date;
4635
4805
  if (shift !== void 0) queryParams.shift = String(shift);
@@ -4639,7 +4809,7 @@ function useNavigation(customNavigate) {
4639
4809
  query: queryParams
4640
4810
  });
4641
4811
  }, [router$1]);
4642
- const goToLine = React33.useCallback(({ lineId, date, shift, tab }) => {
4812
+ const goToLine = React14.useCallback(({ lineId, date, shift, tab }) => {
4643
4813
  const queryParams = {};
4644
4814
  if (date) queryParams.date = date;
4645
4815
  if (shift !== void 0) queryParams.shift = String(shift);
@@ -4649,42 +4819,42 @@ function useNavigation(customNavigate) {
4649
4819
  query: queryParams
4650
4820
  });
4651
4821
  }, [router$1]);
4652
- const goToTargets = React33.useCallback(() => {
4822
+ const goToTargets = React14.useCallback(() => {
4653
4823
  router$1.push("/targets");
4654
4824
  }, [router$1]);
4655
- const goToShifts = React33.useCallback(() => {
4825
+ const goToShifts = React14.useCallback(() => {
4656
4826
  router$1.push("/shifts");
4657
4827
  }, [router$1]);
4658
- const goToLeaderboard = React33.useCallback(() => {
4828
+ const goToLeaderboard = React14.useCallback(() => {
4659
4829
  const lineId = entityConfig?.defaultLineId || "line-1";
4660
4830
  router$1.push(`/leaderboard/${lineId}`);
4661
4831
  }, [router$1, entityConfig?.defaultLineId]);
4662
- const goToFactoryView = React33.useCallback(() => {
4832
+ const goToFactoryView = React14.useCallback(() => {
4663
4833
  router$1.push("/factory-view");
4664
4834
  }, [router$1]);
4665
- const goToProfile = React33.useCallback(() => {
4835
+ const goToProfile = React14.useCallback(() => {
4666
4836
  router$1.push("/profile");
4667
4837
  }, [router$1]);
4668
- const isLineView = React33.useMemo(() => {
4838
+ const isLineView = React14.useMemo(() => {
4669
4839
  return pathname.startsWith("/kpis/") && !!router$1.query.lineId;
4670
4840
  }, [pathname, router$1.query.lineId]);
4671
- const isWorkspaceView = React33.useMemo(() => {
4841
+ const isWorkspaceView = React14.useMemo(() => {
4672
4842
  return pathname.startsWith("/workspace/") && !!router$1.query.id;
4673
4843
  }, [pathname, router$1.query.id]);
4674
4844
  const defaultLineIdFromConfig = entityConfig?.defaultLineId;
4675
- const activeLineId = React33.useMemo(() => {
4845
+ const activeLineId = React14.useMemo(() => {
4676
4846
  if (isLineView && typeof router$1.query.lineId === "string") {
4677
4847
  return router$1.query.lineId;
4678
4848
  }
4679
4849
  return defaultLineIdFromConfig;
4680
4850
  }, [isLineView, router$1.query.lineId, defaultLineIdFromConfig]);
4681
- const activeWorkspaceId = React33.useMemo(() => {
4851
+ const activeWorkspaceId = React14.useMemo(() => {
4682
4852
  if (isWorkspaceView && typeof router$1.query.id === "string") {
4683
4853
  return router$1.query.id;
4684
4854
  }
4685
4855
  return null;
4686
4856
  }, [isWorkspaceView, router$1.query.id]);
4687
- const navigate = React33.useCallback(
4857
+ const navigate = React14.useCallback(
4688
4858
  async (path, options) => {
4689
4859
  if (options?.trackingEvent) {
4690
4860
  trackCoreEvent(options.trackingEvent.name, options.trackingEvent.properties);
@@ -4733,7 +4903,7 @@ function useNavigation(customNavigate) {
4733
4903
  }
4734
4904
  function useWorkspaceNavigation() {
4735
4905
  const { defaultTimezone } = useDateTimeConfig();
4736
- const getWorkspaceNavigationParams3 = React33.useCallback(
4906
+ const getWorkspaceNavigationParams3 = React14.useCallback(
4737
4907
  (workspaceId, options) => {
4738
4908
  let dateToUse = options?.date;
4739
4909
  if (!dateToUse && options?.useCurrentDate) {
@@ -4754,7 +4924,7 @@ function useWorkspaceNavigation() {
4754
4924
  }
4755
4925
  function useDateFormatter() {
4756
4926
  const { defaultTimezone, defaultLocale, dateFormatOptions, timeFormatOptions, dateTimeFormatOptions } = useDateTimeConfig();
4757
- const formatDate = React33.useCallback(
4927
+ const formatDate = React14.useCallback(
4758
4928
  (date, formatString) => {
4759
4929
  const dateObj = typeof date === "string" ? dateFns.parseISO(date) : date;
4760
4930
  if (!dateFns.isValid(dateObj)) return "Invalid Date";
@@ -4767,7 +4937,7 @@ function useDateFormatter() {
4767
4937
  },
4768
4938
  [defaultTimezone, defaultLocale, dateFormatOptions]
4769
4939
  );
4770
- const formatTime2 = React33.useCallback(
4940
+ const formatTime2 = React14.useCallback(
4771
4941
  (date, formatString) => {
4772
4942
  const dateObj = typeof date === "string" ? dateFns.parseISO(date) : date;
4773
4943
  if (!dateFns.isValid(dateObj)) return "Invalid Time";
@@ -4780,7 +4950,7 @@ function useDateFormatter() {
4780
4950
  },
4781
4951
  [defaultTimezone, defaultLocale, timeFormatOptions]
4782
4952
  );
4783
- const formatDateTime = React33.useCallback(
4953
+ const formatDateTime = React14.useCallback(
4784
4954
  (date, formatString) => {
4785
4955
  const dateObj = typeof date === "string" ? dateFns.parseISO(date) : date;
4786
4956
  if (!dateFns.isValid(dateObj)) return "Invalid Date/Time";
@@ -4793,7 +4963,7 @@ function useDateFormatter() {
4793
4963
  },
4794
4964
  [defaultTimezone, defaultLocale, dateTimeFormatOptions]
4795
4965
  );
4796
- const getNow = React33.useCallback(() => {
4966
+ const getNow = React14.useCallback(() => {
4797
4967
  return /* @__PURE__ */ new Date();
4798
4968
  }, []);
4799
4969
  return {
@@ -4807,7 +4977,7 @@ function useDateFormatter() {
4807
4977
  }
4808
4978
  var useFormatNumber = () => {
4809
4979
  const { defaultLocale } = useDateTimeConfig();
4810
- const formatNumber = React33.useCallback(
4980
+ const formatNumber = React14.useCallback(
4811
4981
  (value, options) => {
4812
4982
  try {
4813
4983
  return new Intl.NumberFormat(defaultLocale || "en-US", options).format(value);
@@ -4867,14 +5037,14 @@ var HLS_CONFIG = {
4867
5037
  // Follow live edge aggressively
4868
5038
  };
4869
5039
  function useHlsStream(videoRef, { src, shouldPlay, onFatalError }) {
4870
- const [restartKey, setRestartKey] = React33.useState(0);
4871
- const hlsRef = React33.useRef(null);
4872
- const stallCheckIntervalRef = React33.useRef(null);
4873
- const noProgressTimerRef = React33.useRef(null);
4874
- const lastTimeUpdateRef = React33.useRef(0);
4875
- const softRestartCountRef = React33.useRef(0);
4876
- const isNativeHlsRef = React33.useRef(false);
4877
- const waitingTimerRef = React33.useRef(null);
5040
+ const [restartKey, setRestartKey] = React14.useState(0);
5041
+ const hlsRef = React14.useRef(null);
5042
+ const stallCheckIntervalRef = React14.useRef(null);
5043
+ const noProgressTimerRef = React14.useRef(null);
5044
+ const lastTimeUpdateRef = React14.useRef(0);
5045
+ const softRestartCountRef = React14.useRef(0);
5046
+ const isNativeHlsRef = React14.useRef(false);
5047
+ const waitingTimerRef = React14.useRef(null);
4878
5048
  const cleanup = () => {
4879
5049
  if (stallCheckIntervalRef.current) {
4880
5050
  clearInterval(stallCheckIntervalRef.current);
@@ -4996,7 +5166,7 @@ function useHlsStream(videoRef, { src, shouldPlay, onFatalError }) {
4996
5166
  }
4997
5167
  }, 7e3);
4998
5168
  };
4999
- React33.useEffect(() => {
5169
+ React14.useEffect(() => {
5000
5170
  if (!src || !shouldPlay) {
5001
5171
  cleanup();
5002
5172
  return;
@@ -8015,7 +8185,7 @@ var formatIdleTime = (idleTimeInSeconds) => {
8015
8185
  };
8016
8186
  function useSupabaseClient() {
8017
8187
  const { supabaseUrl, supabaseKey } = useDashboardConfig();
8018
- const supabase = React33.useMemo(() => supabaseJs.createClient(supabaseUrl, supabaseKey), [supabaseUrl, supabaseKey]);
8188
+ const supabase = React14.useMemo(() => supabaseJs.createClient(supabaseUrl, supabaseKey), [supabaseUrl, supabaseKey]);
8019
8189
  return supabase;
8020
8190
  }
8021
8191
  var createSupabaseClient = (url, key) => supabaseJs.createClient(url, key, {
@@ -8050,23 +8220,23 @@ var getAnonClient = () => {
8050
8220
  }
8051
8221
  });
8052
8222
  };
8053
- var LayoutGroupContext = React33.createContext({});
8223
+ var LayoutGroupContext = React14.createContext({});
8054
8224
  function useConstant(init) {
8055
- const ref = React33.useRef(null);
8225
+ const ref = React14.useRef(null);
8056
8226
  if (ref.current === null) {
8057
8227
  ref.current = init();
8058
8228
  }
8059
8229
  return ref.current;
8060
8230
  }
8061
- var PresenceContext = React33.createContext(null);
8062
- var MotionConfigContext = React33.createContext({
8231
+ var PresenceContext = React14.createContext(null);
8232
+ var MotionConfigContext = React14.createContext({
8063
8233
  transformPagePoint: (p) => p,
8064
8234
  isStatic: false,
8065
8235
  reducedMotion: "never"
8066
8236
  });
8067
8237
 
8068
8238
  // ../../node_modules/framer-motion/dist/es/components/AnimatePresence/PopChild.mjs
8069
- var PopChildMeasure = class extends React33__namespace.Component {
8239
+ var PopChildMeasure = class extends React14__namespace.Component {
8070
8240
  getSnapshotBeforeUpdate(prevProps) {
8071
8241
  const element = this.props.childRef.current;
8072
8242
  if (element && prevProps.isPresent && !this.props.isPresent) {
@@ -8088,16 +8258,16 @@ var PopChildMeasure = class extends React33__namespace.Component {
8088
8258
  }
8089
8259
  };
8090
8260
  function PopChild({ children, isPresent }) {
8091
- const id3 = React33.useId();
8092
- const ref = React33.useRef(null);
8093
- const size = React33.useRef({
8261
+ const id3 = React14.useId();
8262
+ const ref = React14.useRef(null);
8263
+ const size = React14.useRef({
8094
8264
  width: 0,
8095
8265
  height: 0,
8096
8266
  top: 0,
8097
8267
  left: 0
8098
8268
  });
8099
- const { nonce } = React33.useContext(MotionConfigContext);
8100
- React33.useInsertionEffect(() => {
8269
+ const { nonce } = React14.useContext(MotionConfigContext);
8270
+ React14.useInsertionEffect(() => {
8101
8271
  const { width, height, top, left } = size.current;
8102
8272
  if (isPresent || !ref.current || !width || !height)
8103
8273
  return;
@@ -8121,14 +8291,14 @@ function PopChild({ children, isPresent }) {
8121
8291
  document.head.removeChild(style);
8122
8292
  };
8123
8293
  }, [isPresent]);
8124
- return jsxRuntime.jsx(PopChildMeasure, { isPresent, childRef: ref, sizeRef: size, children: React33__namespace.cloneElement(children, { ref }) });
8294
+ return jsxRuntime.jsx(PopChildMeasure, { isPresent, childRef: ref, sizeRef: size, children: React14__namespace.cloneElement(children, { ref }) });
8125
8295
  }
8126
8296
 
8127
8297
  // ../../node_modules/framer-motion/dist/es/components/AnimatePresence/PresenceChild.mjs
8128
8298
  var PresenceChild = ({ children, initial, isPresent, onExitComplete, custom, presenceAffectsLayout, mode }) => {
8129
8299
  const presenceChildren = useConstant(newChildrenMap);
8130
- const id3 = React33.useId();
8131
- const memoizedOnExitComplete = React33.useCallback((childId) => {
8300
+ const id3 = React14.useId();
8301
+ const memoizedOnExitComplete = React14.useCallback((childId) => {
8132
8302
  presenceChildren.set(childId, true);
8133
8303
  for (const isComplete of presenceChildren.values()) {
8134
8304
  if (!isComplete)
@@ -8136,7 +8306,7 @@ var PresenceChild = ({ children, initial, isPresent, onExitComplete, custom, pre
8136
8306
  }
8137
8307
  onExitComplete && onExitComplete();
8138
8308
  }, [presenceChildren, onExitComplete]);
8139
- const context = React33.useMemo(
8309
+ const context = React14.useMemo(
8140
8310
  () => ({
8141
8311
  id: id3,
8142
8312
  initial,
@@ -8155,10 +8325,10 @@ var PresenceChild = ({ children, initial, isPresent, onExitComplete, custom, pre
8155
8325
  */
8156
8326
  presenceAffectsLayout ? [Math.random(), memoizedOnExitComplete] : [isPresent, memoizedOnExitComplete]
8157
8327
  );
8158
- React33.useMemo(() => {
8328
+ React14.useMemo(() => {
8159
8329
  presenceChildren.forEach((_, key) => presenceChildren.set(key, false));
8160
8330
  }, [isPresent]);
8161
- React33__namespace.useEffect(() => {
8331
+ React14__namespace.useEffect(() => {
8162
8332
  !isPresent && !presenceChildren.size && onExitComplete && onExitComplete();
8163
8333
  }, [isPresent]);
8164
8334
  if (mode === "popLayout") {
@@ -8170,23 +8340,23 @@ function newChildrenMap() {
8170
8340
  return /* @__PURE__ */ new Map();
8171
8341
  }
8172
8342
  function usePresence(subscribe = true) {
8173
- const context = React33.useContext(PresenceContext);
8343
+ const context = React14.useContext(PresenceContext);
8174
8344
  if (context === null)
8175
8345
  return [true, null];
8176
8346
  const { isPresent, onExitComplete, register } = context;
8177
- const id3 = React33.useId();
8178
- React33.useEffect(() => {
8347
+ const id3 = React14.useId();
8348
+ React14.useEffect(() => {
8179
8349
  if (subscribe)
8180
8350
  register(id3);
8181
8351
  }, [subscribe]);
8182
- const safeToRemove = React33.useCallback(() => subscribe && onExitComplete && onExitComplete(id3), [id3, onExitComplete, subscribe]);
8352
+ const safeToRemove = React14.useCallback(() => subscribe && onExitComplete && onExitComplete(id3), [id3, onExitComplete, subscribe]);
8183
8353
  return !isPresent && onExitComplete ? [false, safeToRemove] : [true];
8184
8354
  }
8185
8355
  var getChildKey = (child) => child.key || "";
8186
8356
  function onlyElements(children) {
8187
8357
  const filtered = [];
8188
- React33.Children.forEach(children, (child) => {
8189
- if (React33.isValidElement(child))
8358
+ React14.Children.forEach(children, (child) => {
8359
+ if (React14.isValidElement(child))
8190
8360
  filtered.push(child);
8191
8361
  });
8192
8362
  return filtered;
@@ -8196,18 +8366,18 @@ function onlyElements(children) {
8196
8366
  var isBrowser = typeof window !== "undefined";
8197
8367
 
8198
8368
  // ../../node_modules/framer-motion/dist/es/utils/use-isomorphic-effect.mjs
8199
- var useIsomorphicLayoutEffect = isBrowser ? React33.useLayoutEffect : React33.useEffect;
8369
+ var useIsomorphicLayoutEffect = isBrowser ? React14.useLayoutEffect : React14.useEffect;
8200
8370
 
8201
8371
  // ../../node_modules/framer-motion/dist/es/components/AnimatePresence/index.mjs
8202
8372
  var AnimatePresence = ({ children, custom, initial = true, onExitComplete, presenceAffectsLayout = true, mode = "sync", propagate = false }) => {
8203
8373
  const [isParentPresent, safeToRemove] = usePresence(propagate);
8204
- const presentChildren = React33.useMemo(() => onlyElements(children), [children]);
8374
+ const presentChildren = React14.useMemo(() => onlyElements(children), [children]);
8205
8375
  const presentKeys = propagate && !isParentPresent ? [] : presentChildren.map(getChildKey);
8206
- const isInitialRender = React33.useRef(true);
8207
- const pendingPresentChildren = React33.useRef(presentChildren);
8376
+ const isInitialRender = React14.useRef(true);
8377
+ const pendingPresentChildren = React14.useRef(presentChildren);
8208
8378
  const exitComplete = useConstant(() => /* @__PURE__ */ new Map());
8209
- const [diffedChildren, setDiffedChildren] = React33.useState(presentChildren);
8210
- const [renderedChildren, setRenderedChildren] = React33.useState(presentChildren);
8379
+ const [diffedChildren, setDiffedChildren] = React14.useState(presentChildren);
8380
+ const [renderedChildren, setRenderedChildren] = React14.useState(presentChildren);
8211
8381
  useIsomorphicLayoutEffect(() => {
8212
8382
  isInitialRender.current = false;
8213
8383
  pendingPresentChildren.current = presentChildren;
@@ -8243,7 +8413,7 @@ var AnimatePresence = ({ children, custom, initial = true, onExitComplete, prese
8243
8413
  if (process.env.NODE_ENV !== "production" && mode === "wait" && renderedChildren.length > 1) {
8244
8414
  console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);
8245
8415
  }
8246
- const { forceRender } = React33.useContext(LayoutGroupContext);
8416
+ const { forceRender } = React14.useContext(LayoutGroupContext);
8247
8417
  return jsxRuntime.jsx(jsxRuntime.Fragment, { children: renderedChildren.map((child) => {
8248
8418
  const key = getChildKey(child);
8249
8419
  const isPresent = propagate && !isParentPresent ? false : presentChildren === renderedChildren || presentKeys.includes(key);
@@ -8410,7 +8580,7 @@ function createRenderBatcher(scheduleNextBatch, allowKeepAlive) {
8410
8580
 
8411
8581
  // ../../node_modules/framer-motion/dist/es/frameloop/frame.mjs
8412
8582
  var { schedule: frame, cancel: cancelFrame, state: frameData, steps: frameSteps } = createRenderBatcher(typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : motionUtils.noop, true);
8413
- var LazyContext = React33.createContext({ strict: false });
8583
+ var LazyContext = React14.createContext({ strict: false });
8414
8584
 
8415
8585
  // ../../node_modules/framer-motion/dist/es/motion/features/definitions.mjs
8416
8586
  var featureProps = {
@@ -8548,7 +8718,7 @@ function createDOMMotionComponentProxy(componentFactory) {
8548
8718
  }
8549
8719
  });
8550
8720
  }
8551
- var MotionContext = React33.createContext({});
8721
+ var MotionContext = React14.createContext({});
8552
8722
 
8553
8723
  // ../../node_modules/framer-motion/dist/es/render/utils/is-variant-label.mjs
8554
8724
  function isVariantLabel(v) {
@@ -8594,8 +8764,8 @@ function getCurrentTreeVariants(props, context) {
8594
8764
 
8595
8765
  // ../../node_modules/framer-motion/dist/es/context/MotionContext/create.mjs
8596
8766
  function useCreateMotionContext(props) {
8597
- const { initial, animate } = getCurrentTreeVariants(props, React33.useContext(MotionContext));
8598
- return React33.useMemo(() => ({ initial, animate }), [variantLabelsAsDependency(initial), variantLabelsAsDependency(animate)]);
8767
+ const { initial, animate } = getCurrentTreeVariants(props, React14.useContext(MotionContext));
8768
+ return React14.useMemo(() => ({ initial, animate }), [variantLabelsAsDependency(initial), variantLabelsAsDependency(animate)]);
8599
8769
  }
8600
8770
  function variantLabelsAsDependency(prop) {
8601
8771
  return Array.isArray(prop) ? prop.join(" ") : prop;
@@ -8611,7 +8781,7 @@ function isRefObject(ref) {
8611
8781
 
8612
8782
  // ../../node_modules/framer-motion/dist/es/motion/utils/use-motion-ref.mjs
8613
8783
  function useMotionRef(visualState, visualElement, externalRef) {
8614
- return React33.useCallback(
8784
+ return React14.useCallback(
8615
8785
  (instance) => {
8616
8786
  if (instance) {
8617
8787
  visualState.onMount && visualState.onMount(instance);
@@ -8649,16 +8819,16 @@ var optimizedAppearDataAttribute = "data-" + camelToDash(optimizedAppearDataId);
8649
8819
 
8650
8820
  // ../../node_modules/framer-motion/dist/es/frameloop/microtask.mjs
8651
8821
  var { schedule: microtask} = createRenderBatcher(queueMicrotask, false);
8652
- var SwitchLayoutGroupContext = React33.createContext({});
8822
+ var SwitchLayoutGroupContext = React14.createContext({});
8653
8823
 
8654
8824
  // ../../node_modules/framer-motion/dist/es/motion/utils/use-visual-element.mjs
8655
8825
  function useVisualElement(Component3, visualState, props, createVisualElement, ProjectionNodeConstructor) {
8656
8826
  var _a, _b;
8657
- const { visualElement: parent } = React33.useContext(MotionContext);
8658
- const lazyContext = React33.useContext(LazyContext);
8659
- const presenceContext = React33.useContext(PresenceContext);
8660
- const reducedMotionConfig = React33.useContext(MotionConfigContext).reducedMotion;
8661
- const visualElementRef = React33.useRef(null);
8827
+ const { visualElement: parent } = React14.useContext(MotionContext);
8828
+ const lazyContext = React14.useContext(LazyContext);
8829
+ const presenceContext = React14.useContext(PresenceContext);
8830
+ const reducedMotionConfig = React14.useContext(MotionConfigContext).reducedMotion;
8831
+ const visualElementRef = React14.useRef(null);
8662
8832
  createVisualElement = createVisualElement || lazyContext.renderer;
8663
8833
  if (!visualElementRef.current && createVisualElement) {
8664
8834
  visualElementRef.current = createVisualElement(Component3, {
@@ -8671,18 +8841,18 @@ function useVisualElement(Component3, visualState, props, createVisualElement, P
8671
8841
  });
8672
8842
  }
8673
8843
  const visualElement = visualElementRef.current;
8674
- const initialLayoutGroupConfig = React33.useContext(SwitchLayoutGroupContext);
8844
+ const initialLayoutGroupConfig = React14.useContext(SwitchLayoutGroupContext);
8675
8845
  if (visualElement && !visualElement.projection && ProjectionNodeConstructor && (visualElement.type === "html" || visualElement.type === "svg")) {
8676
8846
  createProjectionNode(visualElementRef.current, props, ProjectionNodeConstructor, initialLayoutGroupConfig);
8677
8847
  }
8678
- const isMounted = React33.useRef(false);
8679
- React33.useInsertionEffect(() => {
8848
+ const isMounted = React14.useRef(false);
8849
+ React14.useInsertionEffect(() => {
8680
8850
  if (visualElement && isMounted.current) {
8681
8851
  visualElement.update(props, presenceContext);
8682
8852
  }
8683
8853
  });
8684
8854
  const optimisedAppearId = props[optimizedAppearDataAttribute];
8685
- const wantsHandoff = React33.useRef(Boolean(optimisedAppearId) && !((_a = window.MotionHandoffIsComplete) === null || _a === void 0 ? void 0 : _a.call(window, optimisedAppearId)) && ((_b = window.MotionHasOptimisedAnimation) === null || _b === void 0 ? void 0 : _b.call(window, optimisedAppearId)));
8855
+ const wantsHandoff = React14.useRef(Boolean(optimisedAppearId) && !((_a = window.MotionHandoffIsComplete) === null || _a === void 0 ? void 0 : _a.call(window, optimisedAppearId)) && ((_b = window.MotionHasOptimisedAnimation) === null || _b === void 0 ? void 0 : _b.call(window, optimisedAppearId)));
8686
8856
  useIsomorphicLayoutEffect(() => {
8687
8857
  if (!visualElement)
8688
8858
  return;
@@ -8694,7 +8864,7 @@ function useVisualElement(Component3, visualState, props, createVisualElement, P
8694
8864
  visualElement.animationState.animateChanges();
8695
8865
  }
8696
8866
  });
8697
- React33.useEffect(() => {
8867
+ React14.useEffect(() => {
8698
8868
  if (!visualElement)
8699
8869
  return;
8700
8870
  if (!wantsHandoff.current && visualElement.animationState) {
@@ -8744,7 +8914,7 @@ function createRendererMotionComponent({ preloadedFeatures, createVisualElement,
8744
8914
  function MotionComponent(props, externalRef) {
8745
8915
  let MeasureLayout2;
8746
8916
  const configAndProps = {
8747
- ...React33.useContext(MotionConfigContext),
8917
+ ...React14.useContext(MotionConfigContext),
8748
8918
  ...props,
8749
8919
  layoutId: useLayoutId(props)
8750
8920
  };
@@ -8760,16 +8930,16 @@ function createRendererMotionComponent({ preloadedFeatures, createVisualElement,
8760
8930
  return jsxRuntime.jsxs(MotionContext.Provider, { value: context, children: [MeasureLayout2 && context.visualElement ? jsxRuntime.jsx(MeasureLayout2, { visualElement: context.visualElement, ...configAndProps }) : null, useRender(Component3, props, useMotionRef(visualState, context.visualElement, externalRef), visualState, isStatic, context.visualElement)] });
8761
8931
  }
8762
8932
  MotionComponent.displayName = `motion.${typeof Component3 === "string" ? Component3 : `create(${(_b = (_a = Component3.displayName) !== null && _a !== void 0 ? _a : Component3.name) !== null && _b !== void 0 ? _b : ""})`}`;
8763
- const ForwardRefMotionComponent = React33.forwardRef(MotionComponent);
8933
+ const ForwardRefMotionComponent = React14.forwardRef(MotionComponent);
8764
8934
  ForwardRefMotionComponent[motionComponentSymbol] = Component3;
8765
8935
  return ForwardRefMotionComponent;
8766
8936
  }
8767
8937
  function useLayoutId({ layoutId }) {
8768
- const layoutGroupId = React33.useContext(LayoutGroupContext).id;
8938
+ const layoutGroupId = React14.useContext(LayoutGroupContext).id;
8769
8939
  return layoutGroupId && layoutId !== void 0 ? layoutGroupId + "-" + layoutId : layoutId;
8770
8940
  }
8771
8941
  function useStrictMode(configAndProps, preloadedFeatures) {
8772
- const isStrict = React33.useContext(LazyContext).strict;
8942
+ const isStrict = React14.useContext(LazyContext).strict;
8773
8943
  if (process.env.NODE_ENV !== "production" && preloadedFeatures && isStrict) {
8774
8944
  const strictMessage = "You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";
8775
8945
  configAndProps.ignoreStrict ? motionUtils.warning(false, strictMessage) : motionUtils.invariant(false, strictMessage);
@@ -8901,8 +9071,8 @@ function makeState({ scrapeMotionValuesFromProps: scrapeMotionValuesFromProps3,
8901
9071
  return state;
8902
9072
  }
8903
9073
  var makeUseVisualState = (config) => (props, isStatic) => {
8904
- const context = React33.useContext(MotionContext);
8905
- const presenceContext = React33.useContext(PresenceContext);
9074
+ const context = React14.useContext(MotionContext);
9075
+ const presenceContext = React14.useContext(PresenceContext);
8906
9076
  const make = () => makeState(config, props, context, presenceContext);
8907
9077
  return isStatic ? make() : useConstant(make);
8908
9078
  };
@@ -9428,7 +9598,7 @@ function copyRawValuesOnly(target, source, props) {
9428
9598
  }
9429
9599
  }
9430
9600
  function useInitialMotionValues({ transformTemplate }, visualState) {
9431
- return React33.useMemo(() => {
9601
+ return React14.useMemo(() => {
9432
9602
  const state = createHtmlRenderState();
9433
9603
  buildHTMLStyles(state, visualState, transformTemplate);
9434
9604
  return Object.assign({}, state.vars, state.style);
@@ -9456,7 +9626,7 @@ function useHTMLProps(props, visualState) {
9456
9626
  return htmlProps;
9457
9627
  }
9458
9628
  function useSVGProps(props, visualState, _isStatic, Component3) {
9459
- const visualProps = React33.useMemo(() => {
9629
+ const visualProps = React14.useMemo(() => {
9460
9630
  const state = createSvgRenderState();
9461
9631
  buildSVGAttrs(state, visualState, isSVGTag(Component3), props.transformTemplate);
9462
9632
  return {
@@ -9478,10 +9648,10 @@ function createUseRender(forwardMotionProps = false) {
9478
9648
  const useVisualProps = isSVGComponent(Component3) ? useSVGProps : useHTMLProps;
9479
9649
  const visualProps = useVisualProps(props, latestValues, isStatic, Component3);
9480
9650
  const filteredProps = filterProps(props, typeof Component3 === "string", forwardMotionProps);
9481
- const elementProps = Component3 !== React33.Fragment ? { ...filteredProps, ...visualProps, ref } : {};
9651
+ const elementProps = Component3 !== React14.Fragment ? { ...filteredProps, ...visualProps, ref } : {};
9482
9652
  const { children } = props;
9483
- const renderedChildren = React33.useMemo(() => isMotionValue(children) ? children.get() : children, [children]);
9484
- return React33.createElement(Component3, {
9653
+ const renderedChildren = React14.useMemo(() => isMotionValue(children) ? children.get() : children, [children]);
9654
+ return React14.createElement(Component3, {
9485
9655
  ...elementProps,
9486
9656
  children: renderedChildren
9487
9657
  });
@@ -13180,7 +13350,7 @@ var correctBoxShadow = {
13180
13350
  };
13181
13351
 
13182
13352
  // ../../node_modules/framer-motion/dist/es/motion/features/layout/MeasureLayout.mjs
13183
- var MeasureLayoutWithContext = class extends React33.Component {
13353
+ var MeasureLayoutWithContext = class extends React14.Component {
13184
13354
  /**
13185
13355
  * This only mounts projection nodes for components that
13186
13356
  * need measuring, we might want to do it for all components
@@ -13264,8 +13434,8 @@ var MeasureLayoutWithContext = class extends React33.Component {
13264
13434
  };
13265
13435
  function MeasureLayout(props) {
13266
13436
  const [isPresent, safeToRemove] = usePresence();
13267
- const layoutGroup = React33.useContext(LayoutGroupContext);
13268
- return jsxRuntime.jsx(MeasureLayoutWithContext, { ...props, layoutGroup, switchLayoutGroup: React33.useContext(SwitchLayoutGroupContext), isPresent, safeToRemove });
13437
+ const layoutGroup = React14.useContext(LayoutGroupContext);
13438
+ return jsxRuntime.jsx(MeasureLayoutWithContext, { ...props, layoutGroup, switchLayoutGroup: React14.useContext(SwitchLayoutGroupContext), isPresent, safeToRemove });
13269
13439
  }
13270
13440
  var defaultScaleCorrectors = {
13271
13441
  borderRadius: {
@@ -15389,7 +15559,7 @@ var SVGVisualElement = class extends DOMVisualElement {
15389
15559
  // ../../node_modules/framer-motion/dist/es/render/dom/create-visual-element.mjs
15390
15560
  var createDomVisualElement = (Component3, options) => {
15391
15561
  return isSVGComponent(Component3) ? new SVGVisualElement(options) : new HTMLVisualElement(options, {
15392
- allowProjection: Component3 !== React33.Fragment
15562
+ allowProjection: Component3 !== React14.Fragment
15393
15563
  });
15394
15564
  };
15395
15565
 
@@ -15427,7 +15597,7 @@ var LoadingPage = ({
15427
15597
  subMessage = "Please wait while we prepare your data",
15428
15598
  className
15429
15599
  }) => {
15430
- React33__namespace.default.useEffect(() => {
15600
+ React14__namespace.default.useEffect(() => {
15431
15601
  console.log("LoadingPage rendered with message:", message);
15432
15602
  const timeout = setTimeout(() => {
15433
15603
  console.warn("LoadingPage has been visible for more than 8 seconds. This might indicate an issue.");
@@ -15470,10 +15640,10 @@ var withAuth = (WrappedComponent2, options) => {
15470
15640
  return function WithAuthComponent(props) {
15471
15641
  const { session, loading } = useAuth();
15472
15642
  const router$1 = router.useRouter();
15473
- React33__namespace.useEffect(() => {
15643
+ React14__namespace.useEffect(() => {
15474
15644
  console.log("withAuth state:", { loading, hasSession: !!session, requireAuth: defaultOptions.requireAuth });
15475
15645
  }, [session, loading]);
15476
- React33__namespace.useEffect(() => {
15646
+ React14__namespace.useEffect(() => {
15477
15647
  if (!loading && defaultOptions.requireAuth && !session) {
15478
15648
  console.log("Redirecting to login from withAuth");
15479
15649
  router$1.replace(defaultOptions.redirectTo);
@@ -15494,12 +15664,12 @@ var LoginPage = ({
15494
15664
  logoAlt = "Optifye",
15495
15665
  brandName = "Optifye"
15496
15666
  }) => {
15497
- const [email, setEmail] = React33.useState("");
15498
- const [otp, setOtp] = React33.useState("");
15499
- const [step, setStep] = React33.useState("email");
15500
- const [loading, setLoading] = React33.useState(false);
15501
- const [error, setError] = React33.useState(null);
15502
- const [countdown, setCountdown] = React33.useState(0);
15667
+ const [email, setEmail] = React14.useState("");
15668
+ const [otp, setOtp] = React14.useState("");
15669
+ const [step, setStep] = React14.useState("email");
15670
+ const [loading, setLoading] = React14.useState(false);
15671
+ const [error, setError] = React14.useState(null);
15672
+ const [countdown, setCountdown] = React14.useState(0);
15503
15673
  const supabase = useSupabase();
15504
15674
  const router$1 = router.useRouter();
15505
15675
  const handleSendOTP = async (e) => {
@@ -15689,7 +15859,7 @@ var AuthCallback = ({
15689
15859
  }) => {
15690
15860
  const router$1 = router.useRouter();
15691
15861
  const supabase = useSupabase();
15692
- React33.useEffect(() => {
15862
+ React14.useEffect(() => {
15693
15863
  const handleAuthCallback = async () => {
15694
15864
  try {
15695
15865
  const { data: { session }, error } = await supabase.auth.getSession();
@@ -15713,7 +15883,7 @@ var AuthCallback = ({
15713
15883
  return /* @__PURE__ */ jsxRuntime.jsx(LoadingPage, { message: "Completing sign in..." });
15714
15884
  };
15715
15885
  var DebugAuth = () => {
15716
- const [debugInfo, setDebugInfo] = React33.useState({});
15886
+ const [debugInfo, setDebugInfo] = React14.useState({});
15717
15887
  const supabase = useSupabase();
15718
15888
  const checkSupabaseConfig = () => {
15719
15889
  const info = {
@@ -16160,10 +16330,10 @@ var CycleTimeOverTimeChart = ({
16160
16330
  };
16161
16331
  const displayData = getDisplayData(data);
16162
16332
  const DURATION = displayData.length;
16163
- const [animatedData, setAnimatedData] = React33__namespace.default.useState(Array(DURATION).fill(0));
16164
- const prevDataRef = React33__namespace.default.useRef(Array(DURATION).fill(0));
16165
- const animationFrameRef = React33__namespace.default.useRef(null);
16166
- const animateToNewData = React33__namespace.default.useCallback((targetData) => {
16333
+ const [animatedData, setAnimatedData] = React14__namespace.default.useState(Array(DURATION).fill(0));
16334
+ const prevDataRef = React14__namespace.default.useRef(Array(DURATION).fill(0));
16335
+ const animationFrameRef = React14__namespace.default.useRef(null);
16336
+ const animateToNewData = React14__namespace.default.useCallback((targetData) => {
16167
16337
  const startData = [...prevDataRef.current];
16168
16338
  const startTime = performance.now();
16169
16339
  const duration = 1200;
@@ -16193,7 +16363,7 @@ var CycleTimeOverTimeChart = ({
16193
16363
  }
16194
16364
  animationFrameRef.current = requestAnimationFrame(animate);
16195
16365
  }, []);
16196
- React33__namespace.default.useEffect(() => {
16366
+ React14__namespace.default.useEffect(() => {
16197
16367
  if (JSON.stringify(data) !== JSON.stringify(prevDataRef.current)) {
16198
16368
  const processedData = getDisplayData(data);
16199
16369
  animateToNewData(processedData);
@@ -16417,7 +16587,7 @@ var CycleTimeOverTimeChart = ({
16417
16587
  renderLegend()
16418
16588
  ] });
16419
16589
  };
16420
- var Card = React33__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
16590
+ var Card = React14__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
16421
16591
  "div",
16422
16592
  {
16423
16593
  ref,
@@ -16429,7 +16599,7 @@ var Card = React33__namespace.forwardRef(({ className, ...props }, ref) => /* @_
16429
16599
  }
16430
16600
  ));
16431
16601
  Card.displayName = "Card";
16432
- var CardHeader = React33__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
16602
+ var CardHeader = React14__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
16433
16603
  "div",
16434
16604
  {
16435
16605
  ref,
@@ -16438,7 +16608,7 @@ var CardHeader = React33__namespace.forwardRef(({ className, ...props }, ref) =>
16438
16608
  }
16439
16609
  ));
16440
16610
  CardHeader.displayName = "CardHeader";
16441
- var CardTitle = React33__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
16611
+ var CardTitle = React14__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
16442
16612
  "h3",
16443
16613
  {
16444
16614
  ref,
@@ -16450,7 +16620,7 @@ var CardTitle = React33__namespace.forwardRef(({ className, ...props }, ref) =>
16450
16620
  }
16451
16621
  ));
16452
16622
  CardTitle.displayName = "CardTitle";
16453
- var CardDescription = React33__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
16623
+ var CardDescription = React14__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
16454
16624
  "p",
16455
16625
  {
16456
16626
  ref,
@@ -16459,9 +16629,9 @@ var CardDescription = React33__namespace.forwardRef(({ className, ...props }, re
16459
16629
  }
16460
16630
  ));
16461
16631
  CardDescription.displayName = "CardDescription";
16462
- var CardContent = React33__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("p-6 pt-0", className), ...props }));
16632
+ var CardContent = React14__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("p-6 pt-0", className), ...props }));
16463
16633
  CardContent.displayName = "CardContent";
16464
- var CardFooter = React33__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
16634
+ var CardFooter = React14__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
16465
16635
  "div",
16466
16636
  {
16467
16637
  ref,
@@ -16537,7 +16707,7 @@ var buttonVariants = cva(
16537
16707
  }
16538
16708
  }
16539
16709
  );
16540
- var Button = React33__namespace.forwardRef(
16710
+ var Button = React14__namespace.forwardRef(
16541
16711
  ({ className, variant, size, asChild = false, ...props }, ref) => {
16542
16712
  const Comp = asChild ? reactSlot.Slot : "button";
16543
16713
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -16568,10 +16738,30 @@ var HourlyOutputChart = ({
16568
16738
  };
16569
16739
  const shiftStartTime = getTimeFromTimeString(shiftStart);
16570
16740
  const SHIFT_DURATION = 11;
16571
- const [animatedData, setAnimatedData] = React33__namespace.default.useState(Array(SHIFT_DURATION).fill(0));
16572
- const prevDataRef = React33__namespace.default.useRef(Array(SHIFT_DURATION).fill(0));
16573
- const animationFrameRef = React33__namespace.default.useRef(null);
16574
- const animateToNewData = React33__namespace.default.useCallback((targetData) => {
16741
+ const [animatedData, setAnimatedData] = React14__namespace.default.useState(Array(SHIFT_DURATION).fill(0));
16742
+ const prevDataRef = React14__namespace.default.useRef(Array(SHIFT_DURATION).fill(0));
16743
+ const animationFrameRef = React14__namespace.default.useRef(null);
16744
+ const [shouldAnimateIdle, setShouldAnimateIdle] = React14__namespace.default.useState(false);
16745
+ const prevShowIdleTimeRef = React14__namespace.default.useRef(showIdleTime);
16746
+ const animationTimeoutRef = React14__namespace.default.useRef(null);
16747
+ React14__namespace.default.useEffect(() => {
16748
+ if (showIdleTime && !prevShowIdleTimeRef.current) {
16749
+ setShouldAnimateIdle(true);
16750
+ if (animationTimeoutRef.current) {
16751
+ clearTimeout(animationTimeoutRef.current);
16752
+ }
16753
+ animationTimeoutRef.current = setTimeout(() => {
16754
+ setShouldAnimateIdle(false);
16755
+ }, 1e3);
16756
+ }
16757
+ prevShowIdleTimeRef.current = showIdleTime;
16758
+ return () => {
16759
+ if (animationTimeoutRef.current) {
16760
+ clearTimeout(animationTimeoutRef.current);
16761
+ }
16762
+ };
16763
+ }, [showIdleTime]);
16764
+ const animateToNewData = React14__namespace.default.useCallback((targetData) => {
16575
16765
  const startData = [...prevDataRef.current];
16576
16766
  const startTime = performance.now();
16577
16767
  const duration = 1200;
@@ -16601,7 +16791,7 @@ var HourlyOutputChart = ({
16601
16791
  }
16602
16792
  animationFrameRef.current = requestAnimationFrame(animate);
16603
16793
  }, []);
16604
- React33__namespace.default.useEffect(() => {
16794
+ React14__namespace.default.useEffect(() => {
16605
16795
  if (JSON.stringify(data) !== JSON.stringify(prevDataRef.current)) {
16606
16796
  const shiftData = data.slice(0, SHIFT_DURATION);
16607
16797
  animateToNewData(shiftData);
@@ -16612,7 +16802,7 @@ var HourlyOutputChart = ({
16612
16802
  }
16613
16803
  };
16614
16804
  }, [data, animateToNewData]);
16615
- const formatHour = (hourIndex) => {
16805
+ const formatHour = React14__namespace.default.useCallback((hourIndex) => {
16616
16806
  const startDecimalHour = shiftStartTime.decimalHour + hourIndex;
16617
16807
  const startHour = Math.floor(startDecimalHour) % 24;
16618
16808
  const startMinute = Math.round(startDecimalHour % 1 * 60);
@@ -16628,8 +16818,8 @@ var HourlyOutputChart = ({
16628
16818
  return `${hour12}:${m.toString().padStart(2, "0")}${period}`;
16629
16819
  };
16630
16820
  return `${formatTime2(startHour, startMinute)}-${formatTime2(endHour, endMinute)}`;
16631
- };
16632
- const formatTimeRange = (hourIndex) => {
16821
+ }, [shiftStartTime.decimalHour]);
16822
+ const formatTimeRange = React14__namespace.default.useCallback((hourIndex) => {
16633
16823
  const startDecimalHour = shiftStartTime.decimalHour + hourIndex;
16634
16824
  const startHour = Math.floor(startDecimalHour) % 24;
16635
16825
  const startMinute = Math.round(startDecimalHour % 1 * 60);
@@ -16642,22 +16832,24 @@ var HourlyOutputChart = ({
16642
16832
  return `${hour12}:${m.toString().padStart(2, "0")} ${period}`;
16643
16833
  };
16644
16834
  return `${formatTime2(startHour, startMinute)} - ${formatTime2(endHour, endMinute)}`;
16645
- };
16646
- const chartData = Array.from({ length: SHIFT_DURATION }, (_, i) => {
16647
- const actualHour = (shiftStartTime.hour + i) % 24;
16648
- const idleArray = idleTimeHourly?.[actualHour.toString()] || [];
16649
- const idleMinutes = idleArray.filter((val) => val === "1").length;
16650
- return {
16651
- hour: formatHour(i),
16652
- timeRange: formatTimeRange(i),
16653
- output: animatedData[i] || 0,
16654
- originalOutput: data[i] || 0,
16655
- // Keep original data for labels
16656
- color: (animatedData[i] || 0) >= Math.round(pphThreshold) ? "#00AB45" : "#E34329",
16657
- idleMinutes,
16658
- idleArray
16659
- };
16660
- });
16835
+ }, [shiftStartTime.decimalHour]);
16836
+ const chartData = React14__namespace.default.useMemo(() => {
16837
+ return Array.from({ length: SHIFT_DURATION }, (_, i) => {
16838
+ const actualHour = (shiftStartTime.hour + i) % 24;
16839
+ const idleArray = idleTimeHourly?.[actualHour.toString()] || [];
16840
+ const idleMinutes = idleArray.filter((val) => val === "1").length;
16841
+ return {
16842
+ hour: formatHour(i),
16843
+ timeRange: formatTimeRange(i),
16844
+ output: animatedData[i] || 0,
16845
+ originalOutput: data[i] || 0,
16846
+ // Keep original data for labels
16847
+ color: (animatedData[i] || 0) >= Math.round(pphThreshold) ? "#00AB45" : "#E34329",
16848
+ idleMinutes,
16849
+ idleArray
16850
+ };
16851
+ });
16852
+ }, [animatedData, data, pphThreshold, idleTimeHourly, shiftStartTime.hour, formatHour, formatTimeRange]);
16661
16853
  const maxYValue = Math.ceil(pphThreshold * 1.5);
16662
16854
  const generateYAxisTicks = () => {
16663
16855
  const targetValue = Math.round(pphThreshold);
@@ -16750,10 +16942,10 @@ var HourlyOutputChart = ({
16750
16942
  contentStyle: {
16751
16943
  backgroundColor: "white",
16752
16944
  border: "none",
16753
- borderRadius: "8px",
16754
- boxShadow: "0 4px 12px rgba(0,0,0,0.1)",
16755
- padding: "8px 12px",
16756
- fontSize: "13px"
16945
+ borderRadius: "12px",
16946
+ boxShadow: "0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",
16947
+ padding: "0",
16948
+ fontSize: "14px"
16757
16949
  },
16758
16950
  content: (props) => {
16759
16951
  if (!props.active || !props.payload || props.payload.length === 0) return null;
@@ -16787,48 +16979,54 @@ var HourlyOutputChart = ({
16787
16979
  const hour12 = hour === 0 ? 12 : hour > 12 ? hour - 12 : hour;
16788
16980
  return `${hour12}:${minute.toString().padStart(2, "0")} ${period}`;
16789
16981
  };
16790
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white rounded-lg shadow-lg p-3 min-w-[180px]", children: [
16791
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-semibold text-gray-700 mb-2", children: data2.timeRange }),
16792
- /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-gray-600", children: [
16793
- "Output: ",
16794
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-medium text-gray-800", children: [
16795
- Math.round(data2.output),
16796
- " units"
16797
- ] })
16798
- ] }),
16799
- showIdleTime && data2.idleMinutes > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
16800
- /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-gray-600 mb-1 border-t pt-1 mt-1", children: [
16801
- "Idle Time: ",
16802
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-medium text-gray-700", children: [
16803
- data2.idleMinutes,
16804
- " minutes"
16982
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white rounded-xl shadow-xl border border-gray-100 p-4 min-w-[220px]", children: [
16983
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-between mb-3", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-semibold text-gray-900 text-sm", children: data2.timeRange }) }),
16984
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
16985
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
16986
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-gray-500", children: "Output" }),
16987
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-semibold text-gray-900 text-sm", children: [
16988
+ Math.round(data2.output),
16989
+ " units"
16805
16990
  ] })
16806
16991
  ] }),
16807
- idleRanges.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2 text-xs", children: [
16808
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium text-gray-600 mb-1", children: "Idle periods:" }),
16809
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-0.5 max-h-32 overflow-y-auto", children: idleRanges.map((range, index) => {
16810
- const duration = range.end - range.start + 1;
16811
- const startTime = formatIdleTimestamp(range.start);
16812
- const endTime = formatIdleTimestamp(range.end + 1);
16813
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-gray-500 flex items-center gap-1", children: [
16814
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-block w-1 h-1 bg-gray-400 rounded-full" }),
16815
- duration === 1 ? /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
16816
- startTime,
16817
- " ",
16818
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-400", children: "(1 min)" })
16819
- ] }) : /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
16820
- startTime,
16821
- " - ",
16822
- endTime,
16823
- " ",
16824
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-gray-400", children: [
16825
- "(",
16826
- duration,
16827
- " min)"
16828
- ] })
16829
- ] })
16830
- ] }, index);
16831
- }) })
16992
+ showIdleTime && data2.idleMinutes > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
16993
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t border-gray-100 pt-2", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
16994
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-gray-500", children: "Idle Time" }),
16995
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-semibold text-orange-600 text-sm", children: [
16996
+ data2.idleMinutes,
16997
+ " minutes"
16998
+ ] })
16999
+ ] }) }),
17000
+ idleRanges.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 bg-gray-50 rounded-lg p-2.5", children: [
17001
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium text-gray-700 text-xs mb-2", children: "Idle periods:" }),
17002
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-1 max-h-32 overflow-y-auto pr-1", children: idleRanges.map((range, index) => {
17003
+ const duration = range.end - range.start + 1;
17004
+ const startTime = formatIdleTimestamp(range.start);
17005
+ const endTime = formatIdleTimestamp(range.end + 1);
17006
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-gray-600 flex items-center gap-2 text-xs", children: [
17007
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-block w-1.5 h-1.5 bg-orange-400 rounded-full flex-shrink-0" }),
17008
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: duration === 1 ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
17009
+ startTime,
17010
+ " ",
17011
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-gray-400", children: [
17012
+ "(",
17013
+ duration,
17014
+ " min)"
17015
+ ] })
17016
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
17017
+ startTime,
17018
+ " - ",
17019
+ endTime,
17020
+ " ",
17021
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-gray-400", children: [
17022
+ "(",
17023
+ duration,
17024
+ " min)"
17025
+ ] })
17026
+ ] }) })
17027
+ ] }, index);
17028
+ }) })
17029
+ ] })
16832
17030
  ] })
16833
17031
  ] })
16834
17032
  ] });
@@ -16918,10 +17116,40 @@ var HourlyOutputChart = ({
16918
17116
  radius: [10, 10, 0, 0],
16919
17117
  fill: "url(#idlePattern)",
16920
17118
  opacity: 0.7,
16921
- isAnimationActive: true,
16922
- animationBegin: 200,
16923
- animationDuration: 800,
16924
- animationEasing: "ease-out"
17119
+ isAnimationActive: shouldAnimateIdle,
17120
+ animationBegin: shouldAnimateIdle ? 200 : 0,
17121
+ animationDuration: shouldAnimateIdle ? 800 : 0,
17122
+ animationEasing: "ease-out",
17123
+ children: /* @__PURE__ */ jsxRuntime.jsx(
17124
+ recharts.LabelList,
17125
+ {
17126
+ dataKey: "idleMinutes",
17127
+ position: "top",
17128
+ content: (props) => {
17129
+ const { x, y, width, value } = props;
17130
+ if (!value || value === 0) return null;
17131
+ return /* @__PURE__ */ jsxRuntime.jsxs(
17132
+ "text",
17133
+ {
17134
+ x: x + width / 2,
17135
+ y: y - 2,
17136
+ textAnchor: "middle",
17137
+ fontSize: "9",
17138
+ fontWeight: "600",
17139
+ fill: "#6b7280",
17140
+ style: {
17141
+ opacity: 1,
17142
+ pointerEvents: "none"
17143
+ },
17144
+ children: [
17145
+ value,
17146
+ "m"
17147
+ ]
17148
+ }
17149
+ );
17150
+ }
17151
+ }
17152
+ )
16925
17153
  }
16926
17154
  ),
16927
17155
  /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs("pattern", { id: "idlePattern", patternUnits: "userSpaceOnUse", width: "4", height: "4", children: [
@@ -16944,9 +17172,9 @@ var defaults = {
16944
17172
  Button,
16945
17173
  HourlyOutputChart
16946
17174
  };
16947
- var RegistryCtx = React33.createContext(defaults);
17175
+ var RegistryCtx = React14.createContext(defaults);
16948
17176
  var useRegistry = () => {
16949
- const context = React33.useContext(RegistryCtx);
17177
+ const context = React14.useContext(RegistryCtx);
16950
17178
  if (!context) {
16951
17179
  throw new Error("useRegistry must be used within a RegistryProvider");
16952
17180
  }
@@ -17024,10 +17252,10 @@ var SOPComplianceChart = ({
17024
17252
  { length: TOTAL_MINUTES },
17025
17253
  () => Math.floor(Math.random() * 10) + 90
17026
17254
  );
17027
- const [animatedData, setAnimatedData] = React33.useState([]);
17028
- const prevDataRef = React33.useRef([]);
17029
- const animationFrameRef = React33.useRef(null);
17030
- const animateToNewData = React33.useCallback((targetData) => {
17255
+ const [animatedData, setAnimatedData] = React14.useState([]);
17256
+ const prevDataRef = React14.useRef([]);
17257
+ const animationFrameRef = React14.useRef(null);
17258
+ const animateToNewData = React14.useCallback((targetData) => {
17031
17259
  const startData = [...prevDataRef.current];
17032
17260
  while (startData.length < targetData.length) {
17033
17261
  startData.push(startData.length > 0 ? startData[startData.length - 1] : 0);
@@ -17059,7 +17287,7 @@ var SOPComplianceChart = ({
17059
17287
  }
17060
17288
  animationFrameRef.current = requestAnimationFrame(animate);
17061
17289
  }, []);
17062
- React33.useEffect(() => {
17290
+ React14.useEffect(() => {
17063
17291
  if (data.length === 0) {
17064
17292
  if (prevDataRef.current.length === 0) {
17065
17293
  animateToNewData(mockData);
@@ -17315,8 +17543,8 @@ var DateTimeDisplay = ({
17315
17543
  defaultTimezone
17316
17544
  } = useDateTimeConfig();
17317
17545
  const { formatDate, formatTime: formatTime2 } = useDateFormatter();
17318
- const [now2, setNow] = React33.useState(() => getCurrentTimeInZone(defaultTimezone || "UTC"));
17319
- React33.useEffect(() => {
17546
+ const [now2, setNow] = React14.useState(() => getCurrentTimeInZone(defaultTimezone || "UTC"));
17547
+ React14.useEffect(() => {
17320
17548
  const timerId = setInterval(() => {
17321
17549
  setNow(getCurrentTimeInZone(defaultTimezone || "UTC"));
17322
17550
  }, 1e3);
@@ -17350,7 +17578,7 @@ var EmptyStateMessage = ({
17350
17578
  iconClassName
17351
17579
  }) => {
17352
17580
  let IconContent = null;
17353
- if (React33__namespace.default.isValidElement(iconType)) {
17581
+ if (React14__namespace.default.isValidElement(iconType)) {
17354
17582
  IconContent = iconType;
17355
17583
  } else if (typeof iconType === "string") {
17356
17584
  const MappedIcon = IconMap[iconType];
@@ -17441,15 +17669,15 @@ var BreakNotificationPopup = ({
17441
17669
  className = "",
17442
17670
  lineNames = {}
17443
17671
  }) => {
17444
- const [isDismissed, setIsDismissed] = React33.useState(false);
17445
- const [currentTime, setCurrentTime] = React33.useState(/* @__PURE__ */ new Date());
17446
- React33.useEffect(() => {
17672
+ const [isDismissed, setIsDismissed] = React14.useState(false);
17673
+ const [currentTime, setCurrentTime] = React14.useState(/* @__PURE__ */ new Date());
17674
+ React14.useEffect(() => {
17447
17675
  const timer = setInterval(() => {
17448
17676
  setCurrentTime(/* @__PURE__ */ new Date());
17449
17677
  }, 6e4);
17450
17678
  return () => clearInterval(timer);
17451
17679
  }, []);
17452
- React33.useEffect(() => {
17680
+ React14.useEffect(() => {
17453
17681
  if (activeBreaks.length > 0) {
17454
17682
  setIsDismissed(false);
17455
17683
  }
@@ -17572,7 +17800,7 @@ var BaseHistoryCalendar = ({
17572
17800
  className,
17573
17801
  dayCellClassName
17574
17802
  }) => {
17575
- const today = React33.useMemo(() => /* @__PURE__ */ new Date(), []);
17803
+ const today = React14.useMemo(() => /* @__PURE__ */ new Date(), []);
17576
17804
  const Day = (dayProps) => {
17577
17805
  const { day, modifiers, ...divProps } = dayProps;
17578
17806
  const date = day.date;
@@ -17652,7 +17880,7 @@ var BaseHistoryCalendar = ({
17652
17880
  }
17653
17881
  );
17654
17882
  };
17655
- var ShiftDisplay = React33.memo(({ className, variant = "default" }) => {
17883
+ var ShiftDisplay = React14.memo(({ className, variant = "default" }) => {
17656
17884
  const { dateTimeConfig, shiftConfig } = useDashboardConfig();
17657
17885
  const getShiftInfo = () => {
17658
17886
  const tz = dateTimeConfig?.defaultTimezone;
@@ -17674,8 +17902,8 @@ var ShiftDisplay = React33.memo(({ className, variant = "default" }) => {
17674
17902
  return /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-4 h-4", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M17.293 13.293A8 8 0 016.707 2.707a8.001 8.001 0 1010.586 10.586z" }) });
17675
17903
  }
17676
17904
  };
17677
- const [currentShiftText, setCurrentShiftText] = React33.useState(getShiftInfo());
17678
- React33.useEffect(() => {
17905
+ const [currentShiftText, setCurrentShiftText] = React14.useState(getShiftInfo());
17906
+ React14.useEffect(() => {
17679
17907
  setCurrentShiftText(getShiftInfo());
17680
17908
  const interval = setInterval(() => {
17681
17909
  setCurrentShiftText(getShiftInfo());
@@ -17706,11 +17934,11 @@ ShiftDisplay.displayName = "ShiftDisplay";
17706
17934
  var ShiftDisplay_default = ShiftDisplay;
17707
17935
  var TimeDisplay = ({ className, variant = "default" }) => {
17708
17936
  const { dateTimeConfig } = useDashboardConfig();
17709
- const [time2, setTime] = React33.useState("");
17937
+ const [time2, setTime] = React14.useState("");
17710
17938
  const timezoneToDisplay = dateTimeConfig?.defaultTimezone || "UTC";
17711
17939
  const localeToUse = dateTimeConfig?.defaultLocale || "en-US";
17712
17940
  const timeSuffix = "";
17713
- React33.useEffect(() => {
17941
+ React14.useEffect(() => {
17714
17942
  const updateTime = () => {
17715
17943
  const now2 = /* @__PURE__ */ new Date();
17716
17944
  const effectiveFormatOptions = {
@@ -17761,7 +17989,7 @@ var TimeDisplay = ({ className, variant = "default" }) => {
17761
17989
  };
17762
17990
  var TimeDisplay_default = TimeDisplay;
17763
17991
  var TimeDisplay2 = TimeDisplay_default;
17764
- var ISTTimer = React33.memo(() => {
17992
+ var ISTTimer = React14.memo(() => {
17765
17993
  return /* @__PURE__ */ jsxRuntime.jsx(
17766
17994
  TimeDisplay2,
17767
17995
  {
@@ -17785,8 +18013,8 @@ var LinePdfExportButton = ({
17785
18013
  html2canvasOptions,
17786
18014
  jsPdfOptions
17787
18015
  }) => {
17788
- const [isExporting, setIsExporting] = React33.useState(false);
17789
- const handleExport = React33.useCallback(async () => {
18016
+ const [isExporting, setIsExporting] = React14.useState(false);
18017
+ const handleExport = React14.useCallback(async () => {
17790
18018
  const elementToCapture = typeof targetElement === "string" ? document.querySelector(targetElement) : targetElement;
17791
18019
  if (!elementToCapture) {
17792
18020
  console.error("PDF Export Error: Target element not found.");
@@ -17868,11 +18096,11 @@ var LineHistoryCalendar = ({
17868
18096
  const router = useNavigation();
17869
18097
  const { dateTimeConfig } = useDashboardConfig();
17870
18098
  const configuredTimezone = dateTimeConfig?.defaultTimezone || "Asia/Kolkata";
17871
- const todayInZone = React33.useMemo(() => {
18099
+ const todayInZone = React14.useMemo(() => {
17872
18100
  const currentTimeInZone = getCurrentTimeInZone(configuredTimezone);
17873
18101
  return typeof currentTimeInZone === "string" ? new Date(currentTimeInZone) : currentTimeInZone;
17874
18102
  }, [configuredTimezone]);
17875
- const calendarData = React33.useMemo(() => {
18103
+ const calendarData = React14.useMemo(() => {
17876
18104
  const startOfMonth = dateFnsTz.toZonedTime(new Date(year, month, 1), configuredTimezone);
17877
18105
  const endOfMonth = dateFnsTz.toZonedTime(new Date(year, month + 1, 0), configuredTimezone);
17878
18106
  const totalDays = endOfMonth.getDate();
@@ -18203,7 +18431,7 @@ var LineMonthlyPdfGenerator = ({
18203
18431
  selectedShift,
18204
18432
  className
18205
18433
  }) => {
18206
- const [isGenerating, setIsGenerating] = React33.useState(false);
18434
+ const [isGenerating, setIsGenerating] = React14.useState(false);
18207
18435
  const generatePDF = async () => {
18208
18436
  setIsGenerating(true);
18209
18437
  try {
@@ -18518,7 +18746,7 @@ var LinePdfGenerator = ({
18518
18746
  workspaceData,
18519
18747
  className
18520
18748
  }) => {
18521
- const [isGenerating, setIsGenerating] = React33.useState(false);
18749
+ const [isGenerating, setIsGenerating] = React14.useState(false);
18522
18750
  const generatePDF = async () => {
18523
18751
  setIsGenerating(true);
18524
18752
  try {
@@ -18803,8 +19031,8 @@ var WorkspacePdfExportButton = ({
18803
19031
  html2canvasOptions,
18804
19032
  jsPdfOptions
18805
19033
  }) => {
18806
- const [isExporting, setIsExporting] = React33.useState(false);
18807
- const handleExport = React33.useCallback(async () => {
19034
+ const [isExporting, setIsExporting] = React14.useState(false);
19035
+ const handleExport = React14.useCallback(async () => {
18808
19036
  const elementToCapture = typeof targetElement === "string" ? document.querySelector(targetElement) : targetElement;
18809
19037
  if (!elementToCapture) {
18810
19038
  console.error("PDF Export Error: Target element not found.");
@@ -19061,7 +19289,7 @@ var WorkspaceHistoryCalendar = ({
19061
19289
  }) => {
19062
19290
  const { dateTimeConfig } = useDashboardConfig();
19063
19291
  const configuredTimezone = dateTimeConfig?.defaultTimezone || "Asia/Kolkata";
19064
- const calendarData = React33.useMemo(() => {
19292
+ const calendarData = React14.useMemo(() => {
19065
19293
  const startOfMonth = dateFnsTz.toZonedTime(new Date(year, month, 1), configuredTimezone);
19066
19294
  const endOfMonth = dateFnsTz.toZonedTime(new Date(year, month + 1, 0), configuredTimezone);
19067
19295
  const totalDays = endOfMonth.getDate();
@@ -19132,7 +19360,7 @@ var WorkspaceHistoryCalendar = ({
19132
19360
  }
19133
19361
  return calendar;
19134
19362
  }, [data, month, year, configuredTimezone]);
19135
- const monthlyMetrics = React33.useMemo(() => {
19363
+ const monthlyMetrics = React14.useMemo(() => {
19136
19364
  const validDays = data.filter((day) => {
19137
19365
  const date = dateFnsTz.toZonedTime(new Date(day.date), configuredTimezone);
19138
19366
  return date.getMonth() === month && date.getFullYear() === year;
@@ -19157,7 +19385,7 @@ var WorkspaceHistoryCalendar = ({
19157
19385
  totalDays: validShifts.length
19158
19386
  };
19159
19387
  }, [data, month, year, configuredTimezone]);
19160
- const handleDayClick = React33.useCallback((day, shift) => {
19388
+ const handleDayClick = React14.useCallback((day, shift) => {
19161
19389
  if (!day || isFutureDate(day.date)) return;
19162
19390
  const year2 = day.date.getFullYear();
19163
19391
  const month2 = String(day.date.getMonth() + 1).padStart(2, "0");
@@ -19174,7 +19402,7 @@ var WorkspaceHistoryCalendar = ({
19174
19402
  });
19175
19403
  onDateSelect(formattedDate);
19176
19404
  }, [workspaceId, onDateSelect]);
19177
- const handleShiftChange = React33.useCallback((shift) => {
19405
+ const handleShiftChange = React14.useCallback((shift) => {
19178
19406
  trackCoreEvent("Workspace Calendar Shift Changed", {
19179
19407
  workspace_id: workspaceId,
19180
19408
  new_shift: shift
@@ -19183,19 +19411,19 @@ var WorkspaceHistoryCalendar = ({
19183
19411
  onShiftChange(shift);
19184
19412
  }
19185
19413
  }, [workspaceId, onShiftChange]);
19186
- const isCurrentDate = React33.useCallback((date) => {
19414
+ const isCurrentDate = React14.useCallback((date) => {
19187
19415
  const istNow = getTimeInZoneAsDate(configuredTimezone);
19188
19416
  const compareDate = dateFnsTz.toZonedTime(date, configuredTimezone);
19189
19417
  return compareDate.getDate() === istNow.getDate() && compareDate.getMonth() === istNow.getMonth() && compareDate.getFullYear() === istNow.getFullYear();
19190
19418
  }, [configuredTimezone]);
19191
- const isFutureDate = React33.useCallback((date) => {
19419
+ const isFutureDate = React14.useCallback((date) => {
19192
19420
  const istNow = getTimeInZoneAsDate(configuredTimezone);
19193
19421
  istNow.setHours(0, 0, 0, 0);
19194
19422
  const compareDate = dateFnsTz.toZonedTime(date, configuredTimezone);
19195
19423
  compareDate.setHours(0, 0, 0, 0);
19196
19424
  return compareDate > istNow;
19197
19425
  }, [configuredTimezone]);
19198
- const getPerformanceColor = React33.useCallback((efficiency, date) => {
19426
+ const getPerformanceColor = React14.useCallback((efficiency, date) => {
19199
19427
  const istNow = getTimeInZoneAsDate(configuredTimezone);
19200
19428
  istNow.setHours(0, 0, 0, 0);
19201
19429
  const compareDate = dateFnsTz.toZonedTime(date, configuredTimezone);
@@ -19241,7 +19469,7 @@ var WorkspaceHistoryCalendar = ({
19241
19469
  ] })
19242
19470
  ] }) });
19243
19471
  };
19244
- const renderDayCell = React33.useCallback((day) => {
19472
+ const renderDayCell = React14.useCallback((day) => {
19245
19473
  if (!day) return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full border border-gray-100 rounded-lg bg-gray-50 transition-all duration-200 ease-in-out" });
19246
19474
  const shiftData = selectedShift === "day" ? day.dayShift : day.nightShift;
19247
19475
  const isToday = isCurrentDate(day.date);
@@ -19367,7 +19595,7 @@ var WorkspaceWhatsAppShareButton = ({
19367
19595
  );
19368
19596
  };
19369
19597
  var WorkspacePdfGenerator = ({ workspace, className }) => {
19370
- const [isGenerating, setIsGenerating] = React33.useState(false);
19598
+ const [isGenerating, setIsGenerating] = React14.useState(false);
19371
19599
  const generatePDF = async () => {
19372
19600
  setIsGenerating(true);
19373
19601
  try {
@@ -19572,7 +19800,7 @@ var WorkspaceMonthlyPdfGenerator = ({
19572
19800
  selectedShift,
19573
19801
  className
19574
19802
  }) => {
19575
- const [isGenerating, setIsGenerating] = React33.useState(false);
19803
+ const [isGenerating, setIsGenerating] = React14.useState(false);
19576
19804
  const generatePDF = async () => {
19577
19805
  setIsGenerating(true);
19578
19806
  try {
@@ -19852,8 +20080,8 @@ var WorkspaceMetricCards = ({
19852
20080
  ] });
19853
20081
  };
19854
20082
  var LiveTimer = () => {
19855
- const [time2, setTime] = React33.useState(/* @__PURE__ */ new Date());
19856
- React33.useEffect(() => {
20083
+ const [time2, setTime] = React14.useState(/* @__PURE__ */ new Date());
20084
+ React14.useEffect(() => {
19857
20085
  const timer = setInterval(() => {
19858
20086
  setTime(/* @__PURE__ */ new Date());
19859
20087
  }, 1e3);
@@ -19916,7 +20144,7 @@ function Skeleton({ className, ...props }) {
19916
20144
  var Select = SelectPrimitive__namespace.Root;
19917
20145
  var SelectGroup = SelectPrimitive__namespace.Group;
19918
20146
  var SelectValue = SelectPrimitive__namespace.Value;
19919
- var SelectTrigger = React33__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
20147
+ var SelectTrigger = React14__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
19920
20148
  SelectPrimitive__namespace.Trigger,
19921
20149
  {
19922
20150
  ref,
@@ -19932,7 +20160,7 @@ var SelectTrigger = React33__namespace.forwardRef(({ className, children, ...pro
19932
20160
  }
19933
20161
  ));
19934
20162
  SelectTrigger.displayName = SelectPrimitive__namespace.Trigger.displayName;
19935
- var SelectScrollUpButton = React33__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
20163
+ var SelectScrollUpButton = React14__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
19936
20164
  SelectPrimitive__namespace.ScrollUpButton,
19937
20165
  {
19938
20166
  ref,
@@ -19942,7 +20170,7 @@ var SelectScrollUpButton = React33__namespace.forwardRef(({ className, ...props
19942
20170
  }
19943
20171
  ));
19944
20172
  SelectScrollUpButton.displayName = SelectPrimitive__namespace.ScrollUpButton.displayName;
19945
- var SelectScrollDownButton = React33__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
20173
+ var SelectScrollDownButton = React14__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
19946
20174
  SelectPrimitive__namespace.ScrollDownButton,
19947
20175
  {
19948
20176
  ref,
@@ -19952,7 +20180,7 @@ var SelectScrollDownButton = React33__namespace.forwardRef(({ className, ...prop
19952
20180
  }
19953
20181
  ));
19954
20182
  SelectScrollDownButton.displayName = SelectPrimitive__namespace.ScrollDownButton.displayName;
19955
- var SelectContent = React33__namespace.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
20183
+ var SelectContent = React14__namespace.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
19956
20184
  SelectPrimitive__namespace.Content,
19957
20185
  {
19958
20186
  ref,
@@ -19980,7 +20208,7 @@ var SelectContent = React33__namespace.forwardRef(({ className, children, positi
19980
20208
  }
19981
20209
  ) }));
19982
20210
  SelectContent.displayName = SelectPrimitive__namespace.Content.displayName;
19983
- var SelectLabel = React33__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
20211
+ var SelectLabel = React14__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
19984
20212
  SelectPrimitive__namespace.Label,
19985
20213
  {
19986
20214
  ref,
@@ -19989,7 +20217,7 @@ var SelectLabel = React33__namespace.forwardRef(({ className, ...props }, ref) =
19989
20217
  }
19990
20218
  ));
19991
20219
  SelectLabel.displayName = SelectPrimitive__namespace.Label.displayName;
19992
- var SelectItem = React33__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
20220
+ var SelectItem = React14__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
19993
20221
  SelectPrimitive__namespace.Item,
19994
20222
  {
19995
20223
  ref,
@@ -20005,7 +20233,7 @@ var SelectItem = React33__namespace.forwardRef(({ className, children, ...props
20005
20233
  }
20006
20234
  ));
20007
20235
  SelectItem.displayName = SelectPrimitive__namespace.Item.displayName;
20008
- var SelectSeparator = React33__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
20236
+ var SelectSeparator = React14__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
20009
20237
  SelectPrimitive__namespace.Separator,
20010
20238
  {
20011
20239
  ref,
@@ -20040,10 +20268,10 @@ var LoadingOverlay = ({
20040
20268
  var LoadingOverlay_default = LoadingOverlay;
20041
20269
  var DateDisplay = ({ className, variant = "default" }) => {
20042
20270
  const { dateTimeConfig } = useDashboardConfig();
20043
- const [date, setDate] = React33.useState("");
20271
+ const [date, setDate] = React14.useState("");
20044
20272
  const timezoneToDisplay = dateTimeConfig?.defaultTimezone || "UTC";
20045
20273
  const localeToUse = dateTimeConfig?.defaultLocale || "en-US";
20046
- React33.useEffect(() => {
20274
+ React14.useEffect(() => {
20047
20275
  const getCurrentFormattedDate = () => {
20048
20276
  const now2 = /* @__PURE__ */ new Date();
20049
20277
  const effectiveFormatOptions = {
@@ -20130,10 +20358,10 @@ var TimePickerDropdown = ({
20130
20358
  className = "",
20131
20359
  disabled = false
20132
20360
  }) => {
20133
- const [isOpen, setIsOpen] = React33.useState(false);
20134
- const [searchTerm, setSearchTerm] = React33.useState("");
20135
- const dropdownRef = React33.useRef(null);
20136
- const inputRef = React33.useRef(null);
20361
+ const [isOpen, setIsOpen] = React14.useState(false);
20362
+ const [searchTerm, setSearchTerm] = React14.useState("");
20363
+ const dropdownRef = React14.useRef(null);
20364
+ const inputRef = React14.useRef(null);
20137
20365
  const generateTimeSlots = () => {
20138
20366
  const slots = [];
20139
20367
  for (let hour = 0; hour < 24; hour++) {
@@ -20156,7 +20384,7 @@ var TimePickerDropdown = ({
20156
20384
  const slot = timeSlots.find((s) => s.value === value2);
20157
20385
  return slot ? slot.label : value2;
20158
20386
  };
20159
- React33.useEffect(() => {
20387
+ React14.useEffect(() => {
20160
20388
  const handleClickOutside = (event) => {
20161
20389
  if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
20162
20390
  setIsOpen(false);
@@ -20823,22 +21051,22 @@ var BottlenecksContent = ({
20823
21051
  className
20824
21052
  }) => {
20825
21053
  const dashboardConfig = useDashboardConfig();
20826
- const videoRef = React33.useRef(null);
20827
- const fullscreenContainerRef = React33.useRef(null);
20828
- const timestampFilterRef = React33.useRef(null);
20829
- const [isPlaying, setIsPlaying] = React33.useState(false);
20830
- const [currentTime, setCurrentTime] = React33.useState(0);
20831
- const [duration, setDuration] = React33.useState(0);
20832
- const [isFullscreen, setIsFullscreen] = React33.useState(false);
20833
- const [currentIndex, setCurrentIndex] = React33.useState(0);
20834
- const [activeFilter, setActiveFilter] = React33.useState("low_value");
20835
- const [allVideos, setAllVideos] = React33.useState([]);
20836
- const [isLoading, setIsLoading] = React33.useState(true);
20837
- const [error, setError] = React33.useState(null);
20838
- const [showTimestampFilter, setShowTimestampFilter] = React33.useState(false);
20839
- const [timestampStart, setTimestampStart] = React33.useState("");
20840
- const [timestampEnd, setTimestampEnd] = React33.useState("");
20841
- React33.useEffect(() => {
21054
+ const videoRef = React14.useRef(null);
21055
+ const fullscreenContainerRef = React14.useRef(null);
21056
+ const timestampFilterRef = React14.useRef(null);
21057
+ const [isPlaying, setIsPlaying] = React14.useState(false);
21058
+ const [currentTime, setCurrentTime] = React14.useState(0);
21059
+ const [duration, setDuration] = React14.useState(0);
21060
+ const [isFullscreen, setIsFullscreen] = React14.useState(false);
21061
+ const [currentIndex, setCurrentIndex] = React14.useState(0);
21062
+ const [activeFilter, setActiveFilter] = React14.useState("low_value");
21063
+ const [allVideos, setAllVideos] = React14.useState([]);
21064
+ const [isLoading, setIsLoading] = React14.useState(true);
21065
+ const [error, setError] = React14.useState(null);
21066
+ const [showTimestampFilter, setShowTimestampFilter] = React14.useState(false);
21067
+ const [timestampStart, setTimestampStart] = React14.useState("");
21068
+ const [timestampEnd, setTimestampEnd] = React14.useState("");
21069
+ React14.useEffect(() => {
20842
21070
  const handleClickOutside = (event) => {
20843
21071
  if (timestampFilterRef.current && !timestampFilterRef.current.contains(event.target)) {
20844
21072
  setShowTimestampFilter(false);
@@ -20851,14 +21079,14 @@ var BottlenecksContent = ({
20851
21079
  document.removeEventListener("mousedown", handleClickOutside);
20852
21080
  };
20853
21081
  }, [showTimestampFilter]);
20854
- const s3ClipsService = React33.useMemo(() => {
21082
+ const s3ClipsService = React14.useMemo(() => {
20855
21083
  if (!dashboardConfig?.s3Config) {
20856
21084
  console.warn("S3 configuration not found in dashboard config");
20857
21085
  return null;
20858
21086
  }
20859
21087
  return new S3ClipsService(dashboardConfig);
20860
21088
  }, [dashboardConfig]);
20861
- const fetchClips = React33.useCallback(async () => {
21089
+ const fetchClips = React14.useCallback(async () => {
20862
21090
  if (!workspaceId || !s3ClipsService) return;
20863
21091
  setIsLoading(true);
20864
21092
  setError(null);
@@ -20911,12 +21139,12 @@ var BottlenecksContent = ({
20911
21139
  setIsLoading(false);
20912
21140
  }
20913
21141
  }, [workspaceId, date, s3ClipsService, timestampStart, timestampEnd]);
20914
- React33.useEffect(() => {
21142
+ React14.useEffect(() => {
20915
21143
  if (s3ClipsService) {
20916
21144
  fetchClips();
20917
21145
  }
20918
21146
  }, [workspaceId, fetchClips, s3ClipsService]);
20919
- React33.useEffect(() => {
21147
+ React14.useEffect(() => {
20920
21148
  setCurrentIndex(0);
20921
21149
  const filtered = allVideos.filter((video) => {
20922
21150
  if (activeFilter === "all") return true;
@@ -20933,7 +21161,7 @@ var BottlenecksContent = ({
20933
21161
  preloadVideoUrl2(filtered[0].src);
20934
21162
  }
20935
21163
  }, [activeFilter, allVideos]);
20936
- const filteredVideos = React33.useMemo(() => {
21164
+ const filteredVideos = React14.useMemo(() => {
20937
21165
  if (!allVideos) return [];
20938
21166
  let filtered = [];
20939
21167
  if (activeFilter === "all") {
@@ -20957,7 +21185,7 @@ var BottlenecksContent = ({
20957
21185
  return new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime();
20958
21186
  });
20959
21187
  }, [activeFilter, allVideos]);
20960
- React33.useEffect(() => {
21188
+ React14.useEffect(() => {
20961
21189
  if (filteredVideos.length === 0) return;
20962
21190
  const upcoming = [];
20963
21191
  if (currentIndex + 1 < filteredVideos.length) {
@@ -20971,7 +21199,7 @@ var BottlenecksContent = ({
20971
21199
  }
20972
21200
  preloadVideosUrl2(upcoming);
20973
21201
  }, [currentIndex, filteredVideos]);
20974
- const handleNext = React33.useCallback(() => {
21202
+ const handleNext = React14.useCallback(() => {
20975
21203
  setCurrentIndex((prevIndex) => {
20976
21204
  if (prevIndex < filteredVideos.length - 1) {
20977
21205
  return prevIndex + 1;
@@ -20981,7 +21209,7 @@ var BottlenecksContent = ({
20981
21209
  return 0;
20982
21210
  });
20983
21211
  }, [filteredVideos.length]);
20984
- const handlePrevious = React33.useCallback(() => {
21212
+ const handlePrevious = React14.useCallback(() => {
20985
21213
  setCurrentIndex((prevIndex) => {
20986
21214
  if (prevIndex > 0) {
20987
21215
  return prevIndex - 1;
@@ -20991,7 +21219,7 @@ var BottlenecksContent = ({
20991
21219
  return 0;
20992
21220
  });
20993
21221
  }, [filteredVideos.length]);
20994
- React33.useEffect(() => {
21222
+ React14.useEffect(() => {
20995
21223
  if (videoRef.current && filteredVideos.length > 0 && currentIndex < filteredVideos.length) {
20996
21224
  const video = videoRef.current;
20997
21225
  const currentVideoData = filteredVideos[currentIndex];
@@ -21190,7 +21418,7 @@ var BottlenecksContent = ({
21190
21418
  videoRef.current.load();
21191
21419
  }
21192
21420
  }, [currentIndex, filteredVideos, handleNext]);
21193
- React33.useEffect(() => {
21421
+ React14.useEffect(() => {
21194
21422
  const handleKeyDown = (e) => {
21195
21423
  if (e.key === "Escape" && isFullscreen) {
21196
21424
  setIsFullscreen(false);
@@ -21229,7 +21457,7 @@ var BottlenecksContent = ({
21229
21457
  }
21230
21458
  }
21231
21459
  };
21232
- const clipCounts = React33.useMemo(() => {
21460
+ const clipCounts = React14.useMemo(() => {
21233
21461
  if (!allVideos) return {
21234
21462
  bottlenecks: 0,
21235
21463
  lowValue: 0,
@@ -21257,7 +21485,7 @@ var BottlenecksContent = ({
21257
21485
  total: allVideos.length
21258
21486
  };
21259
21487
  }, [allVideos]);
21260
- const currentVideo = React33.useMemo(() => {
21488
+ const currentVideo = React14.useMemo(() => {
21261
21489
  if (!filteredVideos || filteredVideos.length === 0 || currentIndex >= filteredVideos.length) {
21262
21490
  return null;
21263
21491
  }
@@ -21747,7 +21975,7 @@ var TREND_STYLES = {
21747
21975
  // Up
21748
21976
  };
21749
21977
  var getTrendArrowAndColor = (trend) => TREND_STYLES[trend] || { arrow: "", color: "" };
21750
- var VideoCard = React33__namespace.default.memo(({
21978
+ var VideoCard = React14__namespace.default.memo(({
21751
21979
  workspace,
21752
21980
  hlsUrl,
21753
21981
  shouldPlay,
@@ -21756,7 +21984,7 @@ var VideoCard = React33__namespace.default.memo(({
21756
21984
  isVeryLowEfficiency = false,
21757
21985
  className = ""
21758
21986
  }) => {
21759
- const videoRef = React33.useRef(null);
21987
+ const videoRef = React14.useRef(null);
21760
21988
  useHlsStream(videoRef, {
21761
21989
  src: hlsUrl,
21762
21990
  shouldPlay,
@@ -21785,7 +22013,7 @@ var VideoCard = React33__namespace.default.memo(({
21785
22013
  const efficiencyOverlayClass = getEfficiencyOverlayColor(workspace.efficiency);
21786
22014
  const efficiencyBarClass = getEfficiencyBarColor(workspace.efficiency);
21787
22015
  const trendInfo = workspace.trend !== void 0 ? getTrendArrowAndColor(workspace.trend) : null;
21788
- const handleClick = React33.useCallback(() => {
22016
+ const handleClick = React14.useCallback(() => {
21789
22017
  if (onClick) {
21790
22018
  onClick();
21791
22019
  }
@@ -21878,7 +22106,7 @@ var DEFAULT_WORKSPACE_HLS_URLS = {
21878
22106
  "WS06": "https://59.144.218.58:8443/camera5.m3u8"
21879
22107
  };
21880
22108
  var DEFAULT_HLS_URL = "https://192.168.5.9:8443/cam1.m3u8";
21881
- var VideoGridView = React33__namespace.default.memo(({
22109
+ var VideoGridView = React14__namespace.default.memo(({
21882
22110
  workspaces,
21883
22111
  selectedLine,
21884
22112
  className = "",
@@ -21886,24 +22114,24 @@ var VideoGridView = React33__namespace.default.memo(({
21886
22114
  videoSources = {}
21887
22115
  }) => {
21888
22116
  const router$1 = router.useRouter();
21889
- const containerRef = React33.useRef(null);
21890
- const observerRef = React33.useRef(null);
21891
- const [gridCols, setGridCols] = React33.useState(4);
21892
- const [visibleWorkspaces, setVisibleWorkspaces] = React33.useState(/* @__PURE__ */ new Set());
22117
+ const containerRef = React14.useRef(null);
22118
+ const observerRef = React14.useRef(null);
22119
+ const [gridCols, setGridCols] = React14.useState(4);
22120
+ const [visibleWorkspaces, setVisibleWorkspaces] = React14.useState(/* @__PURE__ */ new Set());
21893
22121
  const mergedVideoSources = {
21894
22122
  defaultHlsUrl: videoSources.defaultHlsUrl || DEFAULT_HLS_URL,
21895
22123
  workspaceHlsUrls: { ...DEFAULT_WORKSPACE_HLS_URLS, ...videoSources.workspaceHlsUrls }
21896
22124
  };
21897
- const getWorkspaceHlsUrl = React33.useCallback((workspaceName) => {
22125
+ const getWorkspaceHlsUrl = React14.useCallback((workspaceName) => {
21898
22126
  const wsName = workspaceName.toUpperCase();
21899
22127
  return mergedVideoSources.workspaceHlsUrls[wsName] || mergedVideoSources.defaultHlsUrl;
21900
22128
  }, [mergedVideoSources]);
21901
- const veryLowEfficiencyWorkspaces = React33.useMemo(() => {
22129
+ const veryLowEfficiencyWorkspaces = React14.useMemo(() => {
21902
22130
  return new Set(
21903
22131
  workspaces.filter((w) => w.efficiency < 50 && w.efficiency >= 10).map((w) => w.workspace_name)
21904
22132
  );
21905
22133
  }, [workspaces]);
21906
- const filteredWorkspaces = React33.useMemo(() => {
22134
+ const filteredWorkspaces = React14.useMemo(() => {
21907
22135
  return selectedLine === 1 ? workspaces.filter((w) => {
21908
22136
  if (w.workspace_name === "WS5-5") return true;
21909
22137
  if (w.workspace_name === "WS32-5") return false;
@@ -21924,7 +22152,7 @@ var VideoGridView = React33__namespace.default.memo(({
21924
22152
  }
21925
22153
  }) : workspaces;
21926
22154
  }, [workspaces, selectedLine]);
21927
- const calculateOptimalGrid = React33.useCallback(() => {
22155
+ const calculateOptimalGrid = React14.useCallback(() => {
21928
22156
  if (!containerRef.current) return;
21929
22157
  const containerPadding = 16;
21930
22158
  const containerWidth = containerRef.current.clientWidth - containerPadding;
@@ -21964,13 +22192,13 @@ var VideoGridView = React33__namespace.default.memo(({
21964
22192
  }
21965
22193
  setGridCols(bestCols);
21966
22194
  }, [filteredWorkspaces.length]);
21967
- React33.useEffect(() => {
22195
+ React14.useEffect(() => {
21968
22196
  calculateOptimalGrid();
21969
22197
  const handleResize = () => calculateOptimalGrid();
21970
22198
  window.addEventListener("resize", handleResize);
21971
22199
  return () => window.removeEventListener("resize", handleResize);
21972
22200
  }, [calculateOptimalGrid]);
21973
- React33.useEffect(() => {
22201
+ React14.useEffect(() => {
21974
22202
  if (!containerRef.current) return;
21975
22203
  const options = {
21976
22204
  root: null,
@@ -21998,7 +22226,7 @@ var VideoGridView = React33__namespace.default.memo(({
21998
22226
  observerRef.current?.disconnect();
21999
22227
  };
22000
22228
  }, [filteredWorkspaces]);
22001
- const handleWorkspaceClick = React33.useCallback((workspace) => {
22229
+ const handleWorkspaceClick = React14.useCallback((workspace) => {
22002
22230
  const workspaceId = workspace.workspace_uuid || workspace.workspace_name;
22003
22231
  trackCoreEvent("Workspace Detail Clicked", {
22004
22232
  workspace_name: workspace.workspace_name,
@@ -22161,7 +22389,7 @@ var arePropsEqual = (prevProps, nextProps) => {
22161
22389
  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
22162
22390
  prevProps.position.id === nextProps.position.id;
22163
22391
  };
22164
- var WorkspaceGridItem = React33__namespace.default.memo(({
22392
+ var WorkspaceGridItem = React14__namespace.default.memo(({
22165
22393
  data,
22166
22394
  position,
22167
22395
  isBottleneck = false,
@@ -22170,8 +22398,8 @@ var WorkspaceGridItem = React33__namespace.default.memo(({
22170
22398
  onHoverChange
22171
22399
  }) => {
22172
22400
  const { navigate } = useNavigation();
22173
- const isInactive = React33.useMemo(() => !data.workspace_id || data.efficiency < 10, [data.workspace_id, data.efficiency]);
22174
- const colorClass = React33.useMemo(() => {
22401
+ const isInactive = React14.useMemo(() => !data.workspace_id || data.efficiency < 10, [data.workspace_id, data.efficiency]);
22402
+ const colorClass = React14.useMemo(() => {
22175
22403
  const isConveyorEnd = position.size === "conveyor" && position.orientation;
22176
22404
  if (isConveyorEnd) {
22177
22405
  if (isInactive) return "bg-gray-300/90";
@@ -22181,11 +22409,11 @@ var WorkspaceGridItem = React33__namespace.default.memo(({
22181
22409
  }
22182
22410
  return isInactive ? "bg-gray-300/90" : getEfficiencyColor(data.efficiency);
22183
22411
  }, [data.efficiency, isInactive, position.size, position.orientation]);
22184
- const { arrow, color: arrowColor } = React33.useMemo(() => getTrendArrowAndColor2(data.trend_score), [data.trend_score]);
22185
- const workspaceNumber = React33.useMemo(() => getWorkspaceNumber(data.workspace_name), [data.workspace_name]);
22186
- const styles = React33.useMemo(() => getWorkspaceStyles(position, isInactive), [position, isInactive]);
22187
- const arrowPosition = React33.useMemo(() => getArrowPositionClass(position), [position]);
22188
- const handleClick = React33.useCallback((e) => {
22412
+ const { arrow, color: arrowColor } = React14.useMemo(() => getTrendArrowAndColor2(data.trend_score), [data.trend_score]);
22413
+ const workspaceNumber = React14.useMemo(() => getWorkspaceNumber(data.workspace_name), [data.workspace_name]);
22414
+ const styles = React14.useMemo(() => getWorkspaceStyles(position, isInactive), [position, isInactive]);
22415
+ const arrowPosition = React14.useMemo(() => getArrowPositionClass(position), [position]);
22416
+ const handleClick = React14.useCallback((e) => {
22189
22417
  e.preventDefault();
22190
22418
  if (isInactive) return;
22191
22419
  const displayName = getWorkspaceDisplayName(data.workspace_name);
@@ -22205,8 +22433,8 @@ var WorkspaceGridItem = React33__namespace.default.memo(({
22205
22433
  }
22206
22434
  });
22207
22435
  }, [data, position, navigate, isInactive]);
22208
- const handleMouseEnter = React33.useCallback(() => onHoverChange?.(true), [onHoverChange]);
22209
- const handleMouseLeave = React33.useCallback(() => onHoverChange?.(false), [onHoverChange]);
22436
+ const handleMouseEnter = React14.useCallback(() => onHoverChange?.(true), [onHoverChange]);
22437
+ const handleMouseLeave = React14.useCallback(() => onHoverChange?.(false), [onHoverChange]);
22210
22438
  return /* @__PURE__ */ jsxRuntime.jsxs(
22211
22439
  "div",
22212
22440
  {
@@ -22254,7 +22482,7 @@ var WorkspaceGridItem = React33__namespace.default.memo(({
22254
22482
  );
22255
22483
  }, arePropsEqual);
22256
22484
  WorkspaceGridItem.displayName = "WorkspaceGridItem";
22257
- var WorkspaceGrid = React33__namespace.default.memo(({
22485
+ var WorkspaceGrid = React14__namespace.default.memo(({
22258
22486
  workspaces,
22259
22487
  isPdfMode = false,
22260
22488
  customWorkspacePositions,
@@ -22264,7 +22492,7 @@ var WorkspaceGrid = React33__namespace.default.memo(({
22264
22492
  className = "",
22265
22493
  videoSources = {}
22266
22494
  }) => {
22267
- React33.useEffect(() => {
22495
+ React14.useEffect(() => {
22268
22496
  trackCoreEvent("Dashboard View Loaded", {
22269
22497
  view_type: "Camera Grid",
22270
22498
  total_workspaces: workspaces.length
@@ -22294,8 +22522,8 @@ var TargetWorkspaceGrid = ({
22294
22522
  lineNames = {},
22295
22523
  className = ""
22296
22524
  }) => {
22297
- const [scale2, setScale] = React33.useState(1);
22298
- const filteredPositions = React33.useMemo(() => {
22525
+ const [scale2, setScale] = React14.useState(1);
22526
+ const filteredPositions = React14.useMemo(() => {
22299
22527
  const isLine2 = lineId === "line-2";
22300
22528
  return positions.filter((pos) => {
22301
22529
  if (pos.id === "WS5-5") {
@@ -22313,7 +22541,7 @@ var TargetWorkspaceGrid = ({
22313
22541
  return isLine2 ? wsNumber >= 23 && wsNumber <= 44 : wsNumber >= 1 && wsNumber <= 22;
22314
22542
  });
22315
22543
  }, [lineId, positions]);
22316
- const boundaries = React33.useMemo(() => filteredPositions.reduce(
22544
+ const boundaries = React14.useMemo(() => filteredPositions.reduce(
22317
22545
  (acc, pos) => ({
22318
22546
  minX: Math.min(acc.minX, pos.x),
22319
22547
  maxX: Math.max(acc.maxX, pos.x),
@@ -22322,9 +22550,9 @@ var TargetWorkspaceGrid = ({
22322
22550
  }),
22323
22551
  { minX: Infinity, maxX: -Infinity, minY: Infinity, maxY: -Infinity }
22324
22552
  ), [filteredPositions]);
22325
- const baseWidth = React33.useMemo(() => (boundaries.maxX - boundaries.minX + 1) * 80, [boundaries]);
22326
- const baseHeight = React33.useMemo(() => (boundaries.maxY - boundaries.minY + 1) * 120, [boundaries]);
22327
- const updateLayout2 = React33.useCallback(() => {
22553
+ const baseWidth = React14.useMemo(() => (boundaries.maxX - boundaries.minX + 1) * 80, [boundaries]);
22554
+ const baseHeight = React14.useMemo(() => (boundaries.maxY - boundaries.minY + 1) * 120, [boundaries]);
22555
+ const updateLayout2 = React14.useCallback(() => {
22328
22556
  const container = document.querySelector(".workspace-grid-container");
22329
22557
  if (!container) return;
22330
22558
  const rect = container.getBoundingClientRect();
@@ -22335,7 +22563,7 @@ var TargetWorkspaceGrid = ({
22335
22563
  const finalScale = Math.min(scaleX, scaleY, 1);
22336
22564
  setScale(finalScale);
22337
22565
  }, [baseWidth, baseHeight]);
22338
- React33.useEffect(() => {
22566
+ React14.useEffect(() => {
22339
22567
  updateLayout2();
22340
22568
  window.addEventListener("resize", updateLayout2);
22341
22569
  return () => {
@@ -22443,7 +22671,7 @@ var KPICard = ({
22443
22671
  }) => {
22444
22672
  useThemeConfig();
22445
22673
  const { formatNumber } = useFormatNumber();
22446
- const trendInfo = React33__namespace.default.useMemo(() => {
22674
+ const trendInfo = React14__namespace.default.useMemo(() => {
22447
22675
  let trendValue = trend || "neutral";
22448
22676
  if (change !== void 0 && trend === void 0) {
22449
22677
  trendValue = change > 0 ? "up" : change < 0 ? "down" : "neutral";
@@ -22466,7 +22694,7 @@ var KPICard = ({
22466
22694
  const shouldShowTrend = !(change === 0 && trend === void 0);
22467
22695
  return { trendValue, Icon: Icon2, colorClass, shouldShowTrend };
22468
22696
  }, [trend, change]);
22469
- const formattedValue = React33__namespace.default.useMemo(() => {
22697
+ const formattedValue = React14__namespace.default.useMemo(() => {
22470
22698
  if (title === "Quality Compliance" && typeof value === "number") {
22471
22699
  return value.toFixed(1);
22472
22700
  }
@@ -22480,7 +22708,7 @@ var KPICard = ({
22480
22708
  }
22481
22709
  return value;
22482
22710
  }, [value, title]);
22483
- const formattedChange = React33__namespace.default.useMemo(() => {
22711
+ const formattedChange = React14__namespace.default.useMemo(() => {
22484
22712
  if (change === void 0 || change === 0) return null;
22485
22713
  const absChange = Math.abs(change);
22486
22714
  return formatNumber(absChange, { minimumFractionDigits: 0, maximumFractionDigits: 1 });
@@ -22686,7 +22914,7 @@ var KPIHeader = ({
22686
22914
  }
22687
22915
  );
22688
22916
  };
22689
- var KPISection = React33.memo(({
22917
+ var KPISection = React14.memo(({
22690
22918
  kpis,
22691
22919
  className,
22692
22920
  layout: layout2 = "row",
@@ -22795,7 +23023,7 @@ var KPISection = React33.memo(({
22795
23023
  });
22796
23024
  KPISection.displayName = "KPISection";
22797
23025
  var ISTTimer2 = ISTTimer_default;
22798
- var DashboardHeader = React33.memo(({ lineTitle, className = "" }) => {
23026
+ var DashboardHeader = React14.memo(({ lineTitle, className = "" }) => {
22799
23027
  const getShiftName = () => {
22800
23028
  const now2 = /* @__PURE__ */ new Date();
22801
23029
  const currentHour = now2.getHours();
@@ -22830,7 +23058,7 @@ var DashboardHeader = React33.memo(({ lineTitle, className = "" }) => {
22830
23058
  ] });
22831
23059
  });
22832
23060
  DashboardHeader.displayName = "DashboardHeader";
22833
- var NoWorkspaceData = React33.memo(({ className = "" }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: `flex h-full items-center justify-center ${className}`, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg bg-white p-4 shadow-md", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center space-x-2 text-gray-500", children: [
23061
+ var NoWorkspaceData = React14.memo(({ className = "" }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: `flex h-full items-center justify-center ${className}`, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg bg-white p-4 shadow-md", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center space-x-2 text-gray-500", children: [
22834
23062
  /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-5 w-5", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ jsxRuntime.jsx("path", { fillRule: "evenodd", d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z", clipRule: "evenodd" }) }),
22835
23063
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: "No workspace data available" })
22836
23064
  ] }) }) }));
@@ -22843,7 +23071,7 @@ var WorkspaceMonthlyDataFetcher = ({
22843
23071
  onLoadingChange
22844
23072
  }) => {
22845
23073
  const supabase = useSupabase();
22846
- React33.useEffect(() => {
23074
+ React14.useEffect(() => {
22847
23075
  if (!workspaceId) return;
22848
23076
  const fetchMonthlyData = async () => {
22849
23077
  onLoadingChange(true);
@@ -22892,7 +23120,7 @@ var Breadcrumbs = ({ items }) => {
22892
23120
  }
22893
23121
  }
22894
23122
  };
22895
- return /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsxs(React33__namespace.default.Fragment, { children: [
23123
+ return /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsxs(React14__namespace.default.Fragment, { children: [
22896
23124
  index > 0 && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-3 w-3 text-gray-400 dark:text-gray-500" }),
22897
23125
  /* @__PURE__ */ jsxRuntime.jsxs(
22898
23126
  "span",
@@ -22916,9 +23144,9 @@ var UserProfileDropdown = ({ config }) => {
22916
23144
  const { user, signOut } = useAuth();
22917
23145
  const { featureFlags } = useDashboardConfig();
22918
23146
  const navigation = useNavigation();
22919
- const [isOpen, setIsOpen] = React33.useState(false);
22920
- const dropdownRef = React33.useRef(null);
22921
- React33.useEffect(() => {
23147
+ const [isOpen, setIsOpen] = React14.useState(false);
23148
+ const dropdownRef = React14.useRef(null);
23149
+ React14.useEffect(() => {
22922
23150
  const handleClickOutside = (event) => {
22923
23151
  if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
22924
23152
  setIsOpen(false);
@@ -23018,8 +23246,8 @@ var PageHeader = ({
23018
23246
  headerLogo,
23019
23247
  sticky = true
23020
23248
  }) => {
23021
- const [darkMode, setDarkMode] = React33.useState(false);
23022
- React33.useEffect(() => {
23249
+ const [darkMode, setDarkMode] = React14.useState(false);
23250
+ React14.useEffect(() => {
23023
23251
  if (typeof window !== "undefined") {
23024
23252
  if (localStorage.theme === "dark" || !("theme" in localStorage) && window.matchMedia("(prefers-color-scheme: dark)").matches) {
23025
23253
  document.documentElement.classList.add("dark");
@@ -23073,7 +23301,7 @@ var PageHeader = ({
23073
23301
  }
23074
23302
  );
23075
23303
  };
23076
- var SideNavBar = React33.memo(({
23304
+ var SideNavBar = React14.memo(({
23077
23305
  // These props are accepted but not used in this implementation
23078
23306
  navItems = [],
23079
23307
  logo,
@@ -23086,13 +23314,13 @@ var SideNavBar = React33.memo(({
23086
23314
  const entityConfig = useEntityConfig();
23087
23315
  const lineId = entityConfig.defaultLineId || LINE_1_UUID;
23088
23316
  const pathname = propPathname || router$1.pathname;
23089
- const getButtonClasses = React33.useCallback((path) => {
23317
+ const getButtonClasses = React14.useCallback((path) => {
23090
23318
  const isActive = pathname === path || pathname.startsWith(path + "/");
23091
23319
  return `w-full flex flex-col items-center justify-center py-3 px-1 rounded-lg relative group
23092
23320
  ${isActive ? "bg-blue-100 text-blue-700 shadow-md border border-blue-200 font-semibold" : "hover:bg-gray-50 text-gray-500 hover:text-gray-700 font-medium"}
23093
23321
  transition-all duration-300 ease-in-out focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2`;
23094
23322
  }, [pathname]);
23095
- const handleHomeClick = React33.useCallback(() => navigate("/", {
23323
+ const handleHomeClick = React14.useCallback(() => navigate("/", {
23096
23324
  trackingEvent: {
23097
23325
  name: "Line Overview Page Clicked",
23098
23326
  properties: {
@@ -23102,7 +23330,7 @@ var SideNavBar = React33.memo(({
23102
23330
  }
23103
23331
  }
23104
23332
  }), [navigate, lineId]);
23105
- const handleLeaderboardClick = React33.useCallback(() => navigate(`/leaderboard/${lineId}`, {
23333
+ const handleLeaderboardClick = React14.useCallback(() => navigate(`/leaderboard/${lineId}`, {
23106
23334
  trackingEvent: {
23107
23335
  name: "Leaderboard Page Clicked",
23108
23336
  properties: {
@@ -23111,7 +23339,7 @@ var SideNavBar = React33.memo(({
23111
23339
  }
23112
23340
  }
23113
23341
  }), [navigate, lineId]);
23114
- const handleKPIsClick = React33.useCallback(() => navigate(`/kpis`, {
23342
+ const handleKPIsClick = React14.useCallback(() => navigate(`/kpis`, {
23115
23343
  trackingEvent: {
23116
23344
  name: "KPI Page Clicked",
23117
23345
  properties: {
@@ -23120,7 +23348,7 @@ var SideNavBar = React33.memo(({
23120
23348
  }
23121
23349
  }
23122
23350
  }), [navigate]);
23123
- const handleTargetsClick = React33.useCallback(() => navigate("/targets", {
23351
+ const handleTargetsClick = React14.useCallback(() => navigate("/targets", {
23124
23352
  trackingEvent: {
23125
23353
  name: "Targets Page Clicked",
23126
23354
  properties: {
@@ -23128,7 +23356,7 @@ var SideNavBar = React33.memo(({
23128
23356
  }
23129
23357
  }
23130
23358
  }), [navigate]);
23131
- const handleShiftsClick = React33.useCallback(() => navigate("/shifts", {
23359
+ const handleShiftsClick = React14.useCallback(() => navigate("/shifts", {
23132
23360
  trackingEvent: {
23133
23361
  name: "Shifts Page Clicked",
23134
23362
  properties: {
@@ -23136,7 +23364,7 @@ var SideNavBar = React33.memo(({
23136
23364
  }
23137
23365
  }
23138
23366
  }), [navigate]);
23139
- const handleAIAgentClick = React33.useCallback(() => navigate("/ai-agent", {
23367
+ const handleAIAgentClick = React14.useCallback(() => navigate("/ai-agent", {
23140
23368
  trackingEvent: {
23141
23369
  name: "AI Agent Page Clicked",
23142
23370
  properties: {
@@ -23144,7 +23372,7 @@ var SideNavBar = React33.memo(({
23144
23372
  }
23145
23373
  }
23146
23374
  }), [navigate]);
23147
- const handleProfileClick = React33.useCallback(() => navigate("/profile", {
23375
+ const handleProfileClick = React14.useCallback(() => navigate("/profile", {
23148
23376
  trackingEvent: {
23149
23377
  name: "Profile Page Clicked",
23150
23378
  properties: {
@@ -23152,7 +23380,7 @@ var SideNavBar = React33.memo(({
23152
23380
  }
23153
23381
  }
23154
23382
  }), [navigate]);
23155
- const handleHelpClick = React33.useCallback(() => navigate("/help", {
23383
+ const handleHelpClick = React14.useCallback(() => navigate("/help", {
23156
23384
  trackingEvent: {
23157
23385
  name: "Help Page Clicked",
23158
23386
  properties: {
@@ -23160,14 +23388,14 @@ var SideNavBar = React33.memo(({
23160
23388
  }
23161
23389
  }
23162
23390
  }), [navigate]);
23163
- const homeButtonClasses = React33.useMemo(() => getButtonClasses("/"), [getButtonClasses, pathname]);
23164
- const leaderboardButtonClasses = React33.useMemo(() => getButtonClasses("/leaderboard"), [getButtonClasses, pathname]);
23165
- const kpisButtonClasses = React33.useMemo(() => getButtonClasses("/kpis"), [getButtonClasses, pathname]);
23166
- const targetsButtonClasses = React33.useMemo(() => getButtonClasses("/targets"), [getButtonClasses, pathname]);
23167
- const shiftsButtonClasses = React33.useMemo(() => getButtonClasses("/shifts"), [getButtonClasses, pathname]);
23168
- const aiAgentButtonClasses = React33.useMemo(() => getButtonClasses("/ai-agent"), [getButtonClasses, pathname]);
23169
- const profileButtonClasses = React33.useMemo(() => getButtonClasses("/profile"), [getButtonClasses, pathname]);
23170
- const helpButtonClasses = React33.useMemo(() => getButtonClasses("/help"), [getButtonClasses, pathname]);
23391
+ const homeButtonClasses = React14.useMemo(() => getButtonClasses("/"), [getButtonClasses, pathname]);
23392
+ const leaderboardButtonClasses = React14.useMemo(() => getButtonClasses("/leaderboard"), [getButtonClasses, pathname]);
23393
+ const kpisButtonClasses = React14.useMemo(() => getButtonClasses("/kpis"), [getButtonClasses, pathname]);
23394
+ const targetsButtonClasses = React14.useMemo(() => getButtonClasses("/targets"), [getButtonClasses, pathname]);
23395
+ const shiftsButtonClasses = React14.useMemo(() => getButtonClasses("/shifts"), [getButtonClasses, pathname]);
23396
+ const aiAgentButtonClasses = React14.useMemo(() => getButtonClasses("/ai-agent"), [getButtonClasses, pathname]);
23397
+ const profileButtonClasses = React14.useMemo(() => getButtonClasses("/profile"), [getButtonClasses, pathname]);
23398
+ const helpButtonClasses = React14.useMemo(() => getButtonClasses("/help"), [getButtonClasses, pathname]);
23171
23399
  return /* @__PURE__ */ jsxRuntime.jsxs("aside", { className: `w-20 h-screen bg-white shadow-lg border-r border-gray-100 flex flex-col items-center fixed ${className}`, children: [
23172
23400
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full py-6 px-4 flex-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(
23173
23401
  "button",
@@ -23415,7 +23643,7 @@ var Header = ({
23415
23643
  }) => {
23416
23644
  const { pathname } = useNavigation();
23417
23645
  const { user, signOut } = useAuth();
23418
- const [showDropdown, setShowDropdown] = React33.useState(false);
23646
+ const [showDropdown, setShowDropdown] = React14.useState(false);
23419
23647
  const getPageTitle = () => {
23420
23648
  if (pathname === "/") return "Factory View";
23421
23649
  if (pathname.startsWith("/workspace/")) return "Workspace Details";
@@ -23492,18 +23720,18 @@ var SingleVideoStream = ({
23492
23720
  initialPlayDelay = 100,
23493
23721
  hlsConfig = {}
23494
23722
  }) => {
23495
- const videoRef = React33.useRef(null);
23496
- const hlsRef = React33.useRef(null);
23497
- const [loading, setLoading] = React33.useState(true);
23498
- const [error, setError] = React33.useState(null);
23499
- const [totalRetries, setTotalRetries] = React33.useState(0);
23723
+ const videoRef = React14.useRef(null);
23724
+ const hlsRef = React14.useRef(null);
23725
+ const [loading, setLoading] = React14.useState(true);
23726
+ const [error, setError] = React14.useState(null);
23727
+ const [totalRetries, setTotalRetries] = React14.useState(0);
23500
23728
  const cleanupHls = () => {
23501
23729
  if (hlsRef.current) {
23502
23730
  hlsRef.current.destroy();
23503
23731
  hlsRef.current = null;
23504
23732
  }
23505
23733
  };
23506
- React33.useEffect(() => {
23734
+ React14.useEffect(() => {
23507
23735
  const video = videoRef.current;
23508
23736
  if (!video) return;
23509
23737
  console.log(`SingleVideoStream: Initializing stream for workspace ${workspaceName}`);
@@ -23638,7 +23866,7 @@ var ThreadSidebar = ({
23638
23866
  className = ""
23639
23867
  }) => {
23640
23868
  const { threads, isLoading, error, deleteThread: deleteThread2 } = useThreads();
23641
- const [deletingId, setDeletingId] = React33.useState(null);
23869
+ const [deletingId, setDeletingId] = React14.useState(null);
23642
23870
  const handleDelete = async (e, threadId) => {
23643
23871
  e.stopPropagation();
23644
23872
  if (confirm("Are you sure you want to delete this conversation?")) {
@@ -23711,7 +23939,7 @@ var ThreadSidebar = ({
23711
23939
  ] });
23712
23940
  };
23713
23941
  var axelProfilePng = "/axel-profile.png";
23714
- var ProfilePicture = React33__namespace.default.memo(({ alt = "Axel", className = "w-12 h-12" }) => {
23942
+ var ProfilePicture = React14__namespace.default.memo(({ alt = "Axel", className = "w-12 h-12" }) => {
23715
23943
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${className} rounded-xl overflow-hidden shadow-sm`, children: /* @__PURE__ */ jsxRuntime.jsx(
23716
23944
  "img",
23717
23945
  {
@@ -23734,23 +23962,23 @@ var AIAgentView = () => {
23734
23962
  const entityConfig = useEntityConfig();
23735
23963
  const dateTimeConfig = useDateTimeConfig();
23736
23964
  const shiftConfig = useShiftConfig();
23737
- const [inputValue, setInputValue] = React33.useState("");
23738
- const [loadingThreads, setLoadingThreads] = React33.useState(/* @__PURE__ */ new Set());
23739
- const [lastError, setLastError] = React33.useState(null);
23740
- const [copiedMessageId, setCopiedMessageId] = React33.useState(null);
23741
- const [activeThreadId, setActiveThreadId] = React33.useState(void 0);
23742
- const [isSidebarOpen, setIsSidebarOpen] = React33.useState(false);
23743
- const [streamingStates, setStreamingStates] = React33.useState(/* @__PURE__ */ new Map());
23744
- const [userId, setUserId] = React33.useState(null);
23745
- const [pendingThreadId, setPendingThreadId] = React33.useState(null);
23746
- const [isTransitioning, setIsTransitioning] = React33.useState(false);
23747
- const [typedText, setTypedText] = React33.useState("");
23748
- const [newChatCount, setNewChatCount] = React33.useState(0);
23749
- const [hasStartedTyping, setHasStartedTyping] = React33.useState(false);
23750
- const [typingStartTime, setTypingStartTime] = React33.useState(null);
23751
- const [lastTypingTime, setLastTypingTime] = React33.useState(null);
23752
- const [characterCount, setCharacterCount] = React33.useState(0);
23753
- const typingTimeoutRef = React33.useRef(null);
23965
+ const [inputValue, setInputValue] = React14.useState("");
23966
+ const [loadingThreads, setLoadingThreads] = React14.useState(/* @__PURE__ */ new Set());
23967
+ const [lastError, setLastError] = React14.useState(null);
23968
+ const [copiedMessageId, setCopiedMessageId] = React14.useState(null);
23969
+ const [activeThreadId, setActiveThreadId] = React14.useState(void 0);
23970
+ const [isSidebarOpen, setIsSidebarOpen] = React14.useState(false);
23971
+ const [streamingStates, setStreamingStates] = React14.useState(/* @__PURE__ */ new Map());
23972
+ const [userId, setUserId] = React14.useState(null);
23973
+ const [pendingThreadId, setPendingThreadId] = React14.useState(null);
23974
+ const [isTransitioning, setIsTransitioning] = React14.useState(false);
23975
+ const [typedText, setTypedText] = React14.useState("");
23976
+ const [newChatCount, setNewChatCount] = React14.useState(0);
23977
+ const [hasStartedTyping, setHasStartedTyping] = React14.useState(false);
23978
+ const [typingStartTime, setTypingStartTime] = React14.useState(null);
23979
+ const [lastTypingTime, setLastTypingTime] = React14.useState(null);
23980
+ const [characterCount, setCharacterCount] = React14.useState(0);
23981
+ const typingTimeoutRef = React14.useRef(null);
23754
23982
  const isThreadLoading = (threadId) => {
23755
23983
  return threadId ? loadingThreads.has(threadId) : false;
23756
23984
  };
@@ -23825,13 +24053,13 @@ var AIAgentView = () => {
23825
24053
  typingTimeoutRef.current = null;
23826
24054
  }
23827
24055
  };
23828
- const textareaRef = React33.useRef(null);
23829
- const messagesEndRef = React33.useRef(null);
23830
- const containerRef = React33.useRef(null);
24056
+ const textareaRef = React14.useRef(null);
24057
+ const messagesEndRef = React14.useRef(null);
24058
+ const containerRef = React14.useRef(null);
23831
24059
  const { createThread, mutate: mutateThreads } = useThreads();
23832
24060
  const { messages, addMessage, setMessages } = useMessages(activeThreadId);
23833
24061
  const agnoApiUrl = config.endpoints?.agnoApiUrl || "https://optifye-agent-production.up.railway.app";
23834
- const sseClient = React33.useMemo(() => {
24062
+ const sseClient = React14.useMemo(() => {
23835
24063
  console.log("[AIAgentView] Using AGNO API URL:", agnoApiUrl);
23836
24064
  return new SSEChatClient(agnoApiUrl);
23837
24065
  }, [agnoApiUrl]);
@@ -23847,20 +24075,20 @@ var AIAgentView = () => {
23847
24075
  const { shiftId } = getCurrentShift(dateTimeConfig.defaultTimezone || "Asia/Kolkata", shiftConfig);
23848
24076
  const companyId = entityConfig.companyId || "default-company-id";
23849
24077
  const ACTIVE_THREAD_STORAGE_KEY = `ai-agent-active-thread-${lineId}`;
23850
- React33.useLayoutEffect(() => {
24078
+ React14.useLayoutEffect(() => {
23851
24079
  const savedThreadId = localStorage.getItem(ACTIVE_THREAD_STORAGE_KEY);
23852
24080
  if (savedThreadId && savedThreadId !== "undefined") {
23853
24081
  setActiveThreadId(savedThreadId);
23854
24082
  }
23855
24083
  }, [ACTIVE_THREAD_STORAGE_KEY]);
23856
- React33.useEffect(() => {
24084
+ React14.useEffect(() => {
23857
24085
  if (activeThreadId) {
23858
24086
  localStorage.setItem(ACTIVE_THREAD_STORAGE_KEY, activeThreadId);
23859
24087
  } else {
23860
24088
  localStorage.removeItem(ACTIVE_THREAD_STORAGE_KEY);
23861
24089
  }
23862
24090
  }, [activeThreadId, ACTIVE_THREAD_STORAGE_KEY]);
23863
- React33.useEffect(() => {
24091
+ React14.useEffect(() => {
23864
24092
  const handleVisibilityChange = () => {
23865
24093
  if (document.visibilityState === "hidden" && activeThreadId) {
23866
24094
  localStorage.setItem(ACTIVE_THREAD_STORAGE_KEY, activeThreadId);
@@ -23881,7 +24109,7 @@ var AIAgentView = () => {
23881
24109
  }
23882
24110
  };
23883
24111
  }, [activeThreadId, ACTIVE_THREAD_STORAGE_KEY]);
23884
- React33.useEffect(() => {
24112
+ React14.useEffect(() => {
23885
24113
  if (textareaRef.current) {
23886
24114
  textareaRef.current.style.height = "auto";
23887
24115
  textareaRef.current.style.height = `${Math.min(textareaRef.current.scrollHeight, 120)}px`;
@@ -23890,12 +24118,12 @@ var AIAgentView = () => {
23890
24118
  const scrollToBottom = () => {
23891
24119
  messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
23892
24120
  };
23893
- React33.useEffect(() => {
24121
+ React14.useEffect(() => {
23894
24122
  if (activeThreadId && messages.length > 0) {
23895
24123
  setTimeout(scrollToBottom, 100);
23896
24124
  }
23897
24125
  }, [activeThreadId]);
23898
- React33.useEffect(() => {
24126
+ React14.useEffect(() => {
23899
24127
  if (messages.length === 0 && !isTransitioning) {
23900
24128
  const fullText = "Hi, I'm Axel - Your AI Supervisor";
23901
24129
  let index = 0;
@@ -23911,7 +24139,7 @@ var AIAgentView = () => {
23911
24139
  return () => clearInterval(typeInterval);
23912
24140
  }
23913
24141
  }, [messages.length, isTransitioning]);
23914
- React33.useEffect(() => {
24142
+ React14.useEffect(() => {
23915
24143
  if (isSidebarOpen) {
23916
24144
  setNewChatCount(0);
23917
24145
  }
@@ -23935,17 +24163,17 @@ var AIAgentView = () => {
23935
24163
  localStorage.removeItem(ACTIVE_THREAD_STORAGE_KEY);
23936
24164
  textareaRef.current?.focus();
23937
24165
  };
23938
- React33.useEffect(() => {
24166
+ React14.useEffect(() => {
23939
24167
  preloadImage(axelProfilePng);
23940
24168
  }, []);
23941
- React33.useEffect(() => {
24169
+ React14.useEffect(() => {
23942
24170
  return () => {
23943
24171
  if (typingTimeoutRef.current) {
23944
24172
  clearTimeout(typingTimeoutRef.current);
23945
24173
  }
23946
24174
  };
23947
24175
  }, []);
23948
- React33.useEffect(() => {
24176
+ React14.useEffect(() => {
23949
24177
  const checkAuth = async () => {
23950
24178
  const supabase2 = _getSupabaseInstance();
23951
24179
  const { data: { session } } = await supabase2.auth.getSession();
@@ -24696,10 +24924,10 @@ var FactoryView = ({
24696
24924
  const supabase = useSupabase();
24697
24925
  const line1DataHook = useLineDetailedMetrics(line1Id);
24698
24926
  const line2DataHook = useLineDetailedMetrics(line2Id);
24699
- const [lines, setLines] = React33.useState([]);
24700
- const [loading, setLoading] = React33.useState(true);
24701
- const [error, setError] = React33.useState(null);
24702
- React33.useMemo(() => {
24927
+ const [lines, setLines] = React14.useState([]);
24928
+ const [loading, setLoading] = React14.useState(true);
24929
+ const [error, setError] = React14.useState(null);
24930
+ React14.useMemo(() => {
24703
24931
  const processLineData = (hookData, defaultName) => {
24704
24932
  const currentLineInfo = hookData.lineData;
24705
24933
  let last5HoursData = [];
@@ -24734,7 +24962,7 @@ var FactoryView = ({
24734
24962
  processLineData(line2DataHook, "Line 2")
24735
24963
  ];
24736
24964
  }, [line1DataHook, line2DataHook]);
24737
- React33.useEffect(() => {
24965
+ React14.useEffect(() => {
24738
24966
  const fetchHourlyData = async () => {
24739
24967
  try {
24740
24968
  if (!supabase) {
@@ -25314,16 +25542,16 @@ var HelpView = ({
25314
25542
  supportEmail = "support@optifye.com"
25315
25543
  }) => {
25316
25544
  const { navigate } = useNavigation();
25317
- const [formData, setFormData] = React33.useState({
25545
+ const [formData, setFormData] = React14.useState({
25318
25546
  subject: "",
25319
25547
  category: "general",
25320
25548
  priority: "normal",
25321
25549
  description: "",
25322
25550
  email: ""
25323
25551
  });
25324
- const [isSubmitting, setIsSubmitting] = React33.useState(false);
25325
- const [submitStatus, setSubmitStatus] = React33.useState("idle");
25326
- const [errorMessage, setErrorMessage] = React33.useState(null);
25552
+ const [isSubmitting, setIsSubmitting] = React14.useState(false);
25553
+ const [submitStatus, setSubmitStatus] = React14.useState("idle");
25554
+ const [errorMessage, setErrorMessage] = React14.useState(null);
25327
25555
  const categories = [
25328
25556
  { value: "general", label: "General Inquiry", icon: outline.QuestionMarkCircleIcon },
25329
25557
  { value: "technical", label: "Technical Issue", icon: outline.ExclamationCircleIcon },
@@ -25572,11 +25800,29 @@ function HomeView({
25572
25800
  },
25573
25801
  factoryName = "Simba Beer - Line 1"
25574
25802
  }) {
25575
- const [isHydrated, setIsHydrated] = React33.useState(false);
25576
- const [selectedLineId, setSelectedLineId] = React33.useState(defaultLineId);
25577
- const [isChangingFilter, setIsChangingFilter] = React33.useState(false);
25578
- const [errorMessage, setErrorMessage] = React33.useState(null);
25579
- React33.useCallback(() => {
25803
+ const [isHydrated, setIsHydrated] = React14.useState(false);
25804
+ const [selectedLineId, setSelectedLineId] = React14.useState(defaultLineId);
25805
+ const [isChangingFilter, setIsChangingFilter] = React14.useState(false);
25806
+ const [errorMessage, setErrorMessage] = React14.useState(null);
25807
+ const [displayNamesInitialized, setDisplayNamesInitialized] = React14.useState(false);
25808
+ React14.useEffect(() => {
25809
+ const initDisplayNames = async () => {
25810
+ try {
25811
+ await preInitializeWorkspaceDisplayNames(selectedLineId);
25812
+ setDisplayNamesInitialized(true);
25813
+ } catch (error) {
25814
+ console.error("Failed to pre-initialize workspace display names:", error);
25815
+ setDisplayNamesInitialized(true);
25816
+ }
25817
+ };
25818
+ initDisplayNames();
25819
+ }, [selectedLineId]);
25820
+ const {
25821
+ displayNames: workspaceDisplayNames,
25822
+ loading: displayNamesLoading,
25823
+ error: displayNamesError
25824
+ } = useWorkspaceDisplayNames(void 0, selectedLineId);
25825
+ React14.useCallback(() => {
25580
25826
  console.log("Refetching KPIs after line metrics update");
25581
25827
  }, []);
25582
25828
  const {
@@ -25587,7 +25833,7 @@ function HomeView({
25587
25833
  } = useLineKPIs({
25588
25834
  lineId: selectedLineId
25589
25835
  });
25590
- const onLineMetricsUpdate = React33.useCallback(() => {
25836
+ const onLineMetricsUpdate = React14.useCallback(() => {
25591
25837
  const timer = setTimeout(() => {
25592
25838
  refetchKPIs();
25593
25839
  }, 1e3);
@@ -25608,12 +25854,12 @@ function HomeView({
25608
25854
  isLoading: breaksLoading,
25609
25855
  error: breaksError
25610
25856
  } = useActiveBreaks([selectedLineId]);
25611
- const memoizedWorkspaceMetrics = React33.useMemo(() => workspaceMetrics, [
25857
+ const memoizedWorkspaceMetrics = React14.useMemo(() => workspaceMetrics, [
25612
25858
  // Only update reference if meaningful properties change
25613
25859
  workspaceMetrics.length,
25614
25860
  ...workspaceMetrics.map((w) => `${w.workspace_uuid}-${Math.round(w.efficiency)}-${w.trend}`)
25615
25861
  ]);
25616
- const memoizedKPIs = React33.useMemo(() => kpis, [
25862
+ const memoizedKPIs = React14.useMemo(() => kpis, [
25617
25863
  // Only update reference when values change by at least 1%
25618
25864
  kpis?.efficiency?.value ? Math.round(kpis.efficiency.value) : null,
25619
25865
  kpis?.underperformingWorkers?.current,
@@ -25624,10 +25870,10 @@ function HomeView({
25624
25870
  // Round to 1 decimal
25625
25871
  kpis?.qualityCompliance?.value ? Math.round(kpis.qualityCompliance.value) : null
25626
25872
  ]);
25627
- React33.useEffect(() => {
25873
+ React14.useEffect(() => {
25628
25874
  setIsHydrated(true);
25629
25875
  }, []);
25630
- React33.useEffect(() => {
25876
+ React14.useEffect(() => {
25631
25877
  if (metricsError) {
25632
25878
  setErrorMessage(metricsError.message);
25633
25879
  } else if (kpisError) {
@@ -25636,28 +25882,28 @@ function HomeView({
25636
25882
  setErrorMessage(null);
25637
25883
  }
25638
25884
  }, [metricsError, kpisError]);
25639
- React33.useCallback((e) => {
25885
+ React14.useCallback((e) => {
25640
25886
  setIsChangingFilter(true);
25641
25887
  setSelectedLineId(e.target.value);
25642
25888
  }, []);
25643
- React33.useEffect(() => {
25889
+ React14.useEffect(() => {
25644
25890
  if (!metricsLoading && !kpisLoading && isChangingFilter && workspaceMetrics.length > 0) {
25645
25891
  setIsChangingFilter(false);
25646
25892
  }
25647
25893
  }, [metricsLoading, kpisLoading, workspaceMetrics, isChangingFilter]);
25648
- const lineTitle = React33.useMemo(() => {
25894
+ const lineTitle = React14.useMemo(() => {
25649
25895
  return factoryName;
25650
25896
  }, [factoryName]);
25651
- const isLoading = !isHydrated || metricsLoading || kpisLoading || isChangingFilter;
25897
+ const isLoading = !isHydrated || metricsLoading || kpisLoading || isChangingFilter || displayNamesLoading || !displayNamesInitialized;
25652
25898
  if (isLoading) {
25653
25899
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-h-screen bg-slate-50", children: /* @__PURE__ */ jsxRuntime.jsx(LoadingPageCmp, { message: "Loading dashboard..." }) });
25654
25900
  }
25655
- if (errorMessage) {
25901
+ if (errorMessage || displayNamesError) {
25656
25902
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-screen items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg bg-white p-6 shadow-lg", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center space-x-3 text-red-500", children: [
25657
25903
  /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
25658
25904
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-lg font-medium", children: [
25659
25905
  "Error: ",
25660
- errorMessage
25906
+ errorMessage || displayNamesError?.message
25661
25907
  ] })
25662
25908
  ] }) }) });
25663
25909
  }
@@ -25677,7 +25923,7 @@ function HomeView({
25677
25923
  /* @__PURE__ */ jsxRuntime.jsx(DashboardHeader, { lineTitle, className: "mb-1 sm:mb-0" }),
25678
25924
  memoizedKPIs && /* @__PURE__ */ jsxRuntime.jsx(KPISection2, { kpis: memoizedKPIs, className: "w-full sm:w-auto" })
25679
25925
  ] }) }),
25680
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-y-auto sm:overflow-hidden", children: memoizedWorkspaceMetrics.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full sm:h-full min-h-[calc(100vh-80px)] sm:min-h-0", children: React33__namespace.default.createElement(WorkspaceGrid, {
25926
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-y-auto sm:overflow-hidden", children: memoizedWorkspaceMetrics.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full sm:h-full min-h-[calc(100vh-80px)] sm:min-h-0", children: React14__namespace.default.createElement(WorkspaceGrid, {
25681
25927
  workspaces: memoizedWorkspaceMetrics,
25682
25928
  lineNames,
25683
25929
  factoryView: factoryViewId,
@@ -25698,7 +25944,7 @@ function HomeView({
25698
25944
  }
25699
25945
  );
25700
25946
  }
25701
- var AuthenticatedHomeView = withAuth(React33__namespace.default.memo(HomeView));
25947
+ var AuthenticatedHomeView = withAuth(React14__namespace.default.memo(HomeView));
25702
25948
  var HomeView_default = HomeView;
25703
25949
 
25704
25950
  // src/views/kpi-detail-view.types.ts
@@ -25773,7 +26019,7 @@ var formatLocalDate = (date) => {
25773
26019
  };
25774
26020
  return date.toLocaleDateString("en-US", options);
25775
26021
  };
25776
- var MetricCards = React33.memo(({ lineInfo }) => {
26022
+ var MetricCards = React14.memo(({ lineInfo }) => {
25777
26023
  return /* @__PURE__ */ jsxRuntime.jsxs(
25778
26024
  motion.div,
25779
26025
  {
@@ -25819,7 +26065,7 @@ var MetricCards = React33.memo(({ lineInfo }) => {
25819
26065
  return prevMetrics.current_output === nextMetrics.current_output && prevMetrics.line_threshold === nextMetrics.line_threshold && prevMetrics.underperforming_workspaces === nextMetrics.underperforming_workspaces && prevMetrics.total_workspaces === nextMetrics.total_workspaces && prevMetrics.avg_efficiency === nextMetrics.avg_efficiency;
25820
26066
  });
25821
26067
  MetricCards.displayName = "MetricCards";
25822
- var BottomSection = React33.memo(({
26068
+ var BottomSection = React14.memo(({
25823
26069
  lineInfo,
25824
26070
  workspaceData,
25825
26071
  sortedByEfficiency,
@@ -25831,7 +26077,7 @@ var BottomSection = React33.memo(({
25831
26077
  }) => {
25832
26078
  const navigation = useNavigation();
25833
26079
  const handleNavigate = navigate || navigation.navigate;
25834
- const handleWorkspaceClick = React33.useCallback((ws, index) => {
26080
+ const handleWorkspaceClick = React14.useCallback((ws, index) => {
25835
26081
  trackCoreEvent("Workspace from KPI Clicked", {
25836
26082
  workspace_name: ws.workspace_name,
25837
26083
  workspace_id: ws.workspace_uuid,
@@ -25975,7 +26221,7 @@ var BottomSection = React33.memo(({
25975
26221
  return true;
25976
26222
  });
25977
26223
  BottomSection.displayName = "BottomSection";
25978
- var QualityOverview = React33.memo(({ lineInfo }) => {
26224
+ var QualityOverview = React14.memo(({ lineInfo }) => {
25979
26225
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center justify-center h-full p-6 bg-white rounded-lg shadow-sm", children: [
25980
26226
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-xl font-semibold text-gray-700 mb-4", children: "Quality Overview" }),
25981
26227
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-gray-500", children: "Quality metrics have been deprecated and are no longer available." })
@@ -25995,8 +26241,8 @@ var KPIDetailView = ({
25995
26241
  backLinkUrl,
25996
26242
  onBackClick
25997
26243
  }) => {
25998
- const [activeTab, setActiveTab] = React33.useState("overview");
25999
- const [currentMonth, setCurrentMonth] = React33.useState(() => {
26244
+ const [activeTab, setActiveTab] = React14.useState("overview");
26245
+ const [currentMonth, setCurrentMonth] = React14.useState(() => {
26000
26246
  if (urlMonth && typeof urlMonth === "string") {
26001
26247
  const parsedMonth = parseInt(urlMonth);
26002
26248
  if (!isNaN(parsedMonth) && parsedMonth >= 0 && parsedMonth <= 11) {
@@ -26005,7 +26251,7 @@ var KPIDetailView = ({
26005
26251
  }
26006
26252
  return (/* @__PURE__ */ new Date()).getMonth();
26007
26253
  });
26008
- const [currentYear, setCurrentYear] = React33.useState(() => {
26254
+ const [currentYear, setCurrentYear] = React14.useState(() => {
26009
26255
  if (urlYear && typeof urlYear === "string") {
26010
26256
  const parsedYear = parseInt(urlYear);
26011
26257
  if (!isNaN(parsedYear) && parsedYear >= 2e3 && parsedYear <= 2100) {
@@ -26014,13 +26260,13 @@ var KPIDetailView = ({
26014
26260
  }
26015
26261
  return (/* @__PURE__ */ new Date()).getFullYear();
26016
26262
  });
26017
- const [monthlyData, setMonthlyData] = React33.useState([]);
26018
- const [underperformingWorkspaces, setUnderperformingWorkspaces] = React33.useState({ dayShift: [], nightShift: [] });
26019
- const [selectedShift, setSelectedShift] = React33.useState("day");
26020
- const [showLineDataNotFound, setShowLineDataNotFound] = React33.useState(false);
26263
+ const [monthlyData, setMonthlyData] = React14.useState([]);
26264
+ const [underperformingWorkspaces, setUnderperformingWorkspaces] = React14.useState({ dayShift: [], nightShift: [] });
26265
+ const [selectedShift, setSelectedShift] = React14.useState("day");
26266
+ const [showLineDataNotFound, setShowLineDataNotFound] = React14.useState(false);
26021
26267
  const navigation = useNavigation(navigate);
26022
26268
  const handleNavigate = navigate || navigation.navigate;
26023
- const parsedShiftId = React33.useMemo(() => {
26269
+ const parsedShiftId = React14.useMemo(() => {
26024
26270
  if (urlShift === "0") return 0;
26025
26271
  if (urlShift === "1") return 1;
26026
26272
  if (typeof urlShift === "string") {
@@ -26032,8 +26278,8 @@ var KPIDetailView = ({
26032
26278
  const supabase = useSupabase();
26033
26279
  const dashboardConfig = useDashboardConfig();
26034
26280
  const configuredTimezone = dashboardConfig.dateTimeConfig?.defaultTimezone || "Asia/Kolkata";
26035
- React33.useMemo(() => getCurrentTimeInZone(configuredTimezone), [configuredTimezone]);
26036
- React33.useEffect(() => {
26281
+ React14.useMemo(() => getCurrentTimeInZone(configuredTimezone), [configuredTimezone]);
26282
+ React14.useEffect(() => {
26037
26283
  if (urlDate || urlShift !== void 0) {
26038
26284
  setActiveTab("overview");
26039
26285
  } else if (urlTab === "monthly_history") {
@@ -26044,10 +26290,10 @@ var KPIDetailView = ({
26044
26290
  setActiveTab("overview");
26045
26291
  }
26046
26292
  }, [urlDate, urlShift, urlTab]);
26047
- const getShiftName = React33.useCallback((shiftId) => {
26293
+ const getShiftName = React14.useCallback((shiftId) => {
26048
26294
  return shiftId === 0 ? "Day" : "Night";
26049
26295
  }, []);
26050
- const getShiftIcon = React33.useCallback((shiftId) => {
26296
+ const getShiftIcon = React14.useCallback((shiftId) => {
26051
26297
  const shift = getShiftName(shiftId);
26052
26298
  if (shift === "Day") {
26053
26299
  return /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z" }) });
@@ -26055,7 +26301,7 @@ var KPIDetailView = ({
26055
26301
  return /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" }) });
26056
26302
  }
26057
26303
  }, [getShiftName]);
26058
- const getDaysDifference2 = React33.useCallback((date) => {
26304
+ const getDaysDifference2 = React14.useCallback((date) => {
26059
26305
  const today = /* @__PURE__ */ new Date();
26060
26306
  const compareDate = new Date(date);
26061
26307
  const todayInZone = new Date(today.toLocaleString("en-US", { timeZone: configuredTimezone }));
@@ -26088,7 +26334,7 @@ var KPIDetailView = ({
26088
26334
  initialDate: typeof urlDate === "string" ? urlDate : void 0,
26089
26335
  initialShiftId: parsedShiftId
26090
26336
  });
26091
- React33.useEffect(() => {
26337
+ React14.useEffect(() => {
26092
26338
  if (activeTab === "monthly_history" && lineId) {
26093
26339
  if (!supabase || !dashboardConfig || !dashboardConfig.supabaseUrl || !dashboardConfig.supabaseKey) {
26094
26340
  console.error("Supabase client or required config not available in KPIsPage for monthly data");
@@ -26170,7 +26416,7 @@ var KPIDetailView = ({
26170
26416
  });
26171
26417
  }
26172
26418
  }, [activeTab, lineId, currentMonth, currentYear, supabase, dashboardConfig]);
26173
- const lineInfo = React33.useMemo(() => {
26419
+ const lineInfo = React14.useMemo(() => {
26174
26420
  if (!metrics2 || !lineDetails || !lineDetails.factory) {
26175
26421
  return null;
26176
26422
  }
@@ -26202,7 +26448,7 @@ var KPIDetailView = ({
26202
26448
  }
26203
26449
  };
26204
26450
  }, [metrics2, lineDetails, companyId]);
26205
- const hourlyOutputData = React33.useMemo(() => {
26451
+ const hourlyOutputData = React14.useMemo(() => {
26206
26452
  if (!metrics2 || !metrics2.output_array) return [];
26207
26453
  return metrics2.output_array.reduce((acc, val, i) => {
26208
26454
  const hourIndex = Math.floor(i / 60);
@@ -26211,12 +26457,12 @@ var KPIDetailView = ({
26211
26457
  return acc;
26212
26458
  }, []);
26213
26459
  }, [metrics2?.output_array]);
26214
- const hourlyThreshold = React33.useMemo(() => metrics2 ? metrics2.threshold_pph || 0 : 0, [metrics2]);
26215
- const sortedByEfficiency = React33.useMemo(() => {
26460
+ const hourlyThreshold = React14.useMemo(() => metrics2 ? metrics2.threshold_pph || 0 : 0, [metrics2]);
26461
+ const sortedByEfficiency = React14.useMemo(() => {
26216
26462
  if (!workspaces) return [];
26217
26463
  return [...workspaces].filter((w) => w.efficiency >= 10).sort((a, b) => (a.efficiency || 0) - (b.efficiency || 0)).slice(0, 5);
26218
26464
  }, [workspaces]);
26219
- React33.useEffect(() => {
26465
+ React14.useEffect(() => {
26220
26466
  let timeoutId;
26221
26467
  if (!lineMetricsLoading && !workspacesLoading && !lineInfo && activeTab !== "monthly_history") {
26222
26468
  timeoutId = setTimeout(() => {
@@ -26231,7 +26477,7 @@ var KPIDetailView = ({
26231
26477
  }
26232
26478
  };
26233
26479
  }, [lineMetricsLoading, workspacesLoading, lineInfo, activeTab]);
26234
- React33.useCallback(() => {
26480
+ React14.useCallback(() => {
26235
26481
  trackCoreEvent("Quality Overview Viewed", {
26236
26482
  source: "line_kpi",
26237
26483
  line_id: lineInfo?.line_id,
@@ -26241,12 +26487,12 @@ var KPIDetailView = ({
26241
26487
  const url = `/kpis/${lineId}?tab=overview&month=${currentMonth}&year=${currentYear}`;
26242
26488
  handleNavigate(url, { shallow: true });
26243
26489
  }, [lineInfo, lineId, currentMonth, currentYear, handleNavigate]);
26244
- const handleOverviewClick = React33.useCallback(() => {
26490
+ const handleOverviewClick = React14.useCallback(() => {
26245
26491
  setActiveTab("overview");
26246
26492
  const url = `/kpis/${lineId}?tab=overview&month=${currentMonth}&year=${currentYear}`;
26247
26493
  handleNavigate(url, { shallow: true });
26248
26494
  }, [lineId, currentMonth, currentYear, handleNavigate]);
26249
- const handleMonthlyHistoryClick = React33.useCallback(() => {
26495
+ const handleMonthlyHistoryClick = React14.useCallback(() => {
26250
26496
  trackCoreEvent("Monthly History Viewed", {
26251
26497
  source: "line_kpi",
26252
26498
  line_id: lineInfo?.line_id,
@@ -26256,7 +26502,7 @@ var KPIDetailView = ({
26256
26502
  const url = `/kpis/${lineId}?tab=monthly_history&month=${currentMonth}&year=${currentYear}`;
26257
26503
  handleNavigate(url, { shallow: true });
26258
26504
  }, [lineInfo, lineId, currentMonth, currentYear, handleNavigate]);
26259
- const handleBackClick = React33.useCallback(() => {
26505
+ const handleBackClick = React14.useCallback(() => {
26260
26506
  if (!urlDate && !urlShift) {
26261
26507
  trackCoreEvent("Dashboard Viewed", {
26262
26508
  source: "line_kpi",
@@ -26531,7 +26777,7 @@ var LineCard = ({ line, onClick }) => {
26531
26777
  const { kpis, isLoading, error } = useLineKPIs({ lineId: line.id });
26532
26778
  const shiftConfig = useShiftConfig();
26533
26779
  const dateTimeConfig = useDateTimeConfig();
26534
- const isOnTrack = React33__namespace.default.useMemo(() => {
26780
+ const isOnTrack = React14__namespace.default.useMemo(() => {
26535
26781
  if (!kpis) return null;
26536
26782
  const currentTime = /* @__PURE__ */ new Date();
26537
26783
  const timezone = dateTimeConfig.defaultTimezone || "Asia/Kolkata";
@@ -26669,16 +26915,16 @@ var KPIsOverviewView = ({
26669
26915
  onBackClick,
26670
26916
  backLinkUrl
26671
26917
  }) => {
26672
- const [lines, setLines] = React33.useState([]);
26673
- const [loading, setLoading] = React33.useState(true);
26674
- const [error, setError] = React33.useState(null);
26918
+ const [lines, setLines] = React14.useState([]);
26919
+ const [loading, setLoading] = React14.useState(true);
26920
+ const [error, setError] = React14.useState(null);
26675
26921
  const supabase = useSupabase();
26676
26922
  const dashboardConfig = useDashboardConfig();
26677
26923
  const navigation = useNavigation(navigate);
26678
26924
  const dateTimeConfig = useDateTimeConfig();
26679
26925
  const shiftConfig = useShiftConfig();
26680
26926
  const configuredTimezone = dateTimeConfig.defaultTimezone || "Asia/Kolkata";
26681
- React33.useEffect(() => {
26927
+ React14.useEffect(() => {
26682
26928
  const fetchLines = async () => {
26683
26929
  try {
26684
26930
  if (!supabase || !dashboardConfig) {
@@ -26705,7 +26951,7 @@ var KPIsOverviewView = ({
26705
26951
  });
26706
26952
  navigation.navigate(`/kpis/${line.id}`);
26707
26953
  };
26708
- const handleBackClick = React33.useCallback(() => {
26954
+ const handleBackClick = React14.useCallback(() => {
26709
26955
  if (onBackClick) {
26710
26956
  onBackClick();
26711
26957
  } else if (backLinkUrl) {
@@ -26826,11 +27072,11 @@ var KPIsOverviewView = ({
26826
27072
  ] });
26827
27073
  };
26828
27074
  var KPIsOverviewView_default = KPIsOverviewView;
26829
- var IsolatedTimer = React33.memo(() => {
27075
+ var IsolatedTimer = React14.memo(() => {
26830
27076
  return /* @__PURE__ */ jsxRuntime.jsx(ISTTimer_default, {});
26831
27077
  }, () => true);
26832
27078
  IsolatedTimer.displayName = "IsolatedTimer";
26833
- var HeaderRibbon = React33.memo(({
27079
+ var HeaderRibbon = React14.memo(({
26834
27080
  currentDate,
26835
27081
  shiftId,
26836
27082
  getShiftIcon,
@@ -26849,7 +27095,7 @@ var HeaderRibbon = React33.memo(({
26849
27095
  ] })
26850
27096
  ] }) }));
26851
27097
  HeaderRibbon.displayName = "HeaderRibbon";
26852
- var MobileWorkspaceCard = React33.memo(({
27098
+ var MobileWorkspaceCard = React14.memo(({
26853
27099
  workspace,
26854
27100
  rank,
26855
27101
  cardClass,
@@ -26906,7 +27152,7 @@ var MobileWorkspaceCard = React33.memo(({
26906
27152
  }
26907
27153
  ));
26908
27154
  MobileWorkspaceCard.displayName = "MobileWorkspaceCard";
26909
- var DesktopWorkspaceRow = React33.memo(({
27155
+ var DesktopWorkspaceRow = React14.memo(({
26910
27156
  workspace,
26911
27157
  index,
26912
27158
  rowClass,
@@ -26945,7 +27191,7 @@ var DesktopWorkspaceRow = React33.memo(({
26945
27191
  }
26946
27192
  ));
26947
27193
  DesktopWorkspaceRow.displayName = "DesktopWorkspaceRow";
26948
- var LeaderboardDetailView = React33.memo(({
27194
+ var LeaderboardDetailView = React14.memo(({
26949
27195
  lineId,
26950
27196
  date,
26951
27197
  shift,
@@ -26956,11 +27202,11 @@ var LeaderboardDetailView = React33.memo(({
26956
27202
  className = ""
26957
27203
  }) => {
26958
27204
  const navigation = useNavigation();
26959
- const [sortAscending, setSortAscending] = React33.useState(true);
26960
- const handleSortToggle = React33.useCallback(() => {
27205
+ const [sortAscending, setSortAscending] = React14.useState(true);
27206
+ const handleSortToggle = React14.useCallback(() => {
26961
27207
  setSortAscending(!sortAscending);
26962
27208
  }, [sortAscending]);
26963
- const realtimeMetricsParams = React33.useMemo(() => ({
27209
+ const realtimeMetricsParams = React14.useMemo(() => ({
26964
27210
  lineId: lineId || "",
26965
27211
  date,
26966
27212
  shiftId: typeof shift === "number" ? shift : typeof shift === "string" ? parseInt(shift) : void 0
@@ -26972,18 +27218,18 @@ var LeaderboardDetailView = React33.memo(({
26972
27218
  error: metricsError,
26973
27219
  refreshMetrics
26974
27220
  } = useRealtimeLineMetrics(realtimeMetricsParams);
26975
- const memoizedLineId = React33.useMemo(() => lineId || "", [lineId]);
27221
+ const memoizedLineId = React14.useMemo(() => lineId || "", [lineId]);
26976
27222
  const {
26977
27223
  workspaces,
26978
27224
  loading: workspacesLoading,
26979
27225
  error: workspacesError,
26980
27226
  refreshWorkspaces
26981
27227
  } = useLineWorkspaceMetrics(memoizedLineId);
26982
- const getShiftName = React33.useCallback((shiftId) => {
27228
+ const getShiftName = React14.useCallback((shiftId) => {
26983
27229
  if (shiftId === void 0) return "Day";
26984
27230
  return shiftId === 0 ? "Day" : "Night";
26985
27231
  }, []);
26986
- const getShiftIcon = React33.useCallback((shiftId) => {
27232
+ const getShiftIcon = React14.useCallback((shiftId) => {
26987
27233
  const shift2 = getShiftName(shiftId);
26988
27234
  if (shift2 === "Day") {
26989
27235
  return /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z" }) });
@@ -26991,7 +27237,7 @@ var LeaderboardDetailView = React33.memo(({
26991
27237
  return /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" }) });
26992
27238
  }
26993
27239
  }, [getShiftName]);
26994
- const formatDate = React33.useCallback((date2) => {
27240
+ const formatDate = React14.useCallback((date2) => {
26995
27241
  return new Intl.DateTimeFormat("en-US", {
26996
27242
  weekday: "long",
26997
27243
  day: "numeric",
@@ -27000,14 +27246,14 @@ var LeaderboardDetailView = React33.memo(({
27000
27246
  timeZone: "Asia/Kolkata"
27001
27247
  }).format(date2);
27002
27248
  }, []);
27003
- const handleBackClick = React33.useCallback(() => {
27249
+ const handleBackClick = React14.useCallback(() => {
27004
27250
  if (onBackClick) {
27005
27251
  onBackClick();
27006
27252
  } else {
27007
27253
  navigation.navigate("/");
27008
27254
  }
27009
27255
  }, [onBackClick, navigation]);
27010
- const getMedalIcon = React33.useCallback((rank) => {
27256
+ const getMedalIcon = React14.useCallback((rank) => {
27011
27257
  if (sortAscending) return null;
27012
27258
  switch (rank) {
27013
27259
  case 1:
@@ -27020,7 +27266,7 @@ var LeaderboardDetailView = React33.memo(({
27020
27266
  return null;
27021
27267
  }
27022
27268
  }, [sortAscending]);
27023
- const handleWorkspaceClick = React33.useCallback((workspace, rank) => {
27269
+ const handleWorkspaceClick = React14.useCallback((workspace, rank) => {
27024
27270
  trackCoreEvent("Workspace from Leaderboard Clicked", {
27025
27271
  workspace_name: workspace.workspace_name,
27026
27272
  workspace_id: workspace.workspace_uuid,
@@ -27039,7 +27285,7 @@ var LeaderboardDetailView = React33.memo(({
27039
27285
  navigation.navigate(`/workspace/${workspace.workspace_uuid}${navParams}${returnToParam}`);
27040
27286
  }
27041
27287
  }, [onWorkspaceClick, navigation, lineId, workspaces?.length]);
27042
- const sortedWorkspaces = React33.useMemo(() => {
27288
+ const sortedWorkspaces = React14.useMemo(() => {
27043
27289
  if (!workspaces) return [];
27044
27290
  return [...workspaces].sort((a, b) => {
27045
27291
  const effA = a.efficiency || 0;
@@ -27047,9 +27293,9 @@ var LeaderboardDetailView = React33.memo(({
27047
27293
  return sortAscending ? effA - effB : effB - effA;
27048
27294
  });
27049
27295
  }, [workspaces, sortAscending]);
27050
- const loading = React33.useMemo(() => metricsLoading || workspacesLoading, [metricsLoading, workspacesLoading]);
27051
- const error = React33.useMemo(() => metricsError || workspacesError, [metricsError, workspacesError]);
27052
- const currentDateFormatted = React33.useMemo(() => formatDate(/* @__PURE__ */ new Date()), [formatDate]);
27296
+ const loading = React14.useMemo(() => metricsLoading || workspacesLoading, [metricsLoading, workspacesLoading]);
27297
+ const error = React14.useMemo(() => metricsError || workspacesError, [metricsError, workspacesError]);
27298
+ const currentDateFormatted = React14.useMemo(() => formatDate(/* @__PURE__ */ new Date()), [formatDate]);
27053
27299
  if (loading) {
27054
27300
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `h-[calc(100vh-64px)] flex items-center justify-center bg-slate-50 ${className}`, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xl text-gray-600", children: "Loading workspaces..." }) });
27055
27301
  }
@@ -27194,15 +27440,15 @@ var ProfileView = () => {
27194
27440
  const supabase = useSupabase();
27195
27441
  const navigation = useNavigation();
27196
27442
  const { authConfig } = useDashboardConfig();
27197
- const [activeTab, setActiveTab] = React33.useState("profile");
27198
- const [profileData, setProfileData] = React33.useState({
27443
+ const [activeTab, setActiveTab] = React14.useState("profile");
27444
+ const [profileData, setProfileData] = React14.useState({
27199
27445
  email: user?.email || ""
27200
27446
  });
27201
- const [isEditing, setIsEditing] = React33.useState(false);
27202
- const [loading, setLoading] = React33.useState(false);
27203
- const [error, setError] = React33.useState(null);
27204
- const [success, setSuccess] = React33.useState(null);
27205
- React33.useEffect(() => {
27447
+ const [isEditing, setIsEditing] = React14.useState(false);
27448
+ const [loading, setLoading] = React14.useState(false);
27449
+ const [error, setError] = React14.useState(null);
27450
+ const [success, setSuccess] = React14.useState(null);
27451
+ React14.useEffect(() => {
27206
27452
  const loadProfileData = async () => {
27207
27453
  if (!user || !supabase) return;
27208
27454
  setLoading(true);
@@ -27579,7 +27825,7 @@ var formatBreaks = (breaks) => {
27579
27825
  }))
27580
27826
  };
27581
27827
  };
27582
- var BreakRow = React33.memo(({
27828
+ var BreakRow = React14.memo(({
27583
27829
  break: breakItem,
27584
27830
  onUpdate,
27585
27831
  onRemove,
@@ -27630,7 +27876,7 @@ var BreakRow = React33.memo(({
27630
27876
  ] });
27631
27877
  });
27632
27878
  BreakRow.displayName = "BreakRow";
27633
- var ShiftPanel = React33.memo(({
27879
+ var ShiftPanel = React14.memo(({
27634
27880
  title,
27635
27881
  icon,
27636
27882
  startTime,
@@ -27645,8 +27891,8 @@ var ShiftPanel = React33.memo(({
27645
27891
  }) => {
27646
27892
  const panelId = `panel-${title.toLowerCase().replace(/\s+/g, "-")}`;
27647
27893
  const storageKey = `shift_panel_${panelId}_minimized`;
27648
- const [isMinimized, setIsMinimized] = React33.useState(true);
27649
- React33.useEffect(() => {
27894
+ const [isMinimized, setIsMinimized] = React14.useState(true);
27895
+ React14.useEffect(() => {
27650
27896
  setIsMinimized(true);
27651
27897
  }, []);
27652
27898
  const toggleMinimize = (e) => {
@@ -27777,7 +28023,7 @@ var ShiftsView = ({
27777
28023
  }) => {
27778
28024
  const supabase = useSupabase();
27779
28025
  const auth = useAuth();
27780
- const [lineConfigs, setLineConfigs] = React33.useState(
28026
+ const [lineConfigs, setLineConfigs] = React14.useState(
27781
28027
  () => lineIds.map((id3) => ({
27782
28028
  id: id3,
27783
28029
  name: lineNames[id3] || `Line ${id3.substring(0, 4)}`,
@@ -27796,9 +28042,9 @@ var ShiftsView = ({
27796
28042
  saveSuccess: false
27797
28043
  }))
27798
28044
  );
27799
- const [loading, setLoading] = React33.useState(true);
27800
- const [error, setError] = React33.useState(null);
27801
- const showToast = React33.useCallback((type, message) => {
28045
+ const [loading, setLoading] = React14.useState(true);
28046
+ const [error, setError] = React14.useState(null);
28047
+ const showToast = React14.useCallback((type, message) => {
27802
28048
  if (onToast) {
27803
28049
  onToast(type, message);
27804
28050
  } else {
@@ -27809,7 +28055,7 @@ var ShiftsView = ({
27809
28055
  }
27810
28056
  }
27811
28057
  }, [onToast]);
27812
- React33.useEffect(() => {
28058
+ React14.useEffect(() => {
27813
28059
  const fetchShiftConfigs = async () => {
27814
28060
  try {
27815
28061
  setLoading(true);
@@ -27875,7 +28121,7 @@ var ShiftsView = ({
27875
28121
  };
27876
28122
  fetchShiftConfigs();
27877
28123
  }, [supabase, lineIds, showToast]);
27878
- React33.useCallback((lineId) => {
28124
+ React14.useCallback((lineId) => {
27879
28125
  setLineConfigs((prev) => {
27880
28126
  const typedPrev = prev;
27881
28127
  const newIsOpen = !typedPrev.find((config) => config.id === lineId)?.isOpen;
@@ -27885,7 +28131,7 @@ var ShiftsView = ({
27885
28131
  );
27886
28132
  });
27887
28133
  }, []);
27888
- const updateDayShiftStartTime = React33.useCallback((lineId, value) => {
28134
+ const updateDayShiftStartTime = React14.useCallback((lineId, value) => {
27889
28135
  setLineConfigs((prev) => prev.map((config) => {
27890
28136
  const typedConfig = config;
27891
28137
  if (typedConfig.id === lineId) {
@@ -27898,7 +28144,7 @@ var ShiftsView = ({
27898
28144
  return typedConfig;
27899
28145
  }));
27900
28146
  }, []);
27901
- const updateDayShiftEndTime = React33.useCallback((lineId, value) => {
28147
+ const updateDayShiftEndTime = React14.useCallback((lineId, value) => {
27902
28148
  setLineConfigs((prev) => prev.map((config) => {
27903
28149
  const typedConfig = config;
27904
28150
  if (typedConfig.id === lineId) {
@@ -27911,7 +28157,7 @@ var ShiftsView = ({
27911
28157
  return typedConfig;
27912
28158
  }));
27913
28159
  }, []);
27914
- const updateNightShiftStartTime = React33.useCallback((lineId, value) => {
28160
+ const updateNightShiftStartTime = React14.useCallback((lineId, value) => {
27915
28161
  setLineConfigs((prev) => prev.map((config) => {
27916
28162
  const typedConfig = config;
27917
28163
  if (typedConfig.id === lineId) {
@@ -27924,7 +28170,7 @@ var ShiftsView = ({
27924
28170
  return typedConfig;
27925
28171
  }));
27926
28172
  }, []);
27927
- const updateNightShiftEndTime = React33.useCallback((lineId, value) => {
28173
+ const updateNightShiftEndTime = React14.useCallback((lineId, value) => {
27928
28174
  setLineConfigs((prev) => prev.map((config) => {
27929
28175
  const typedConfig = config;
27930
28176
  if (typedConfig.id === lineId) {
@@ -27937,7 +28183,7 @@ var ShiftsView = ({
27937
28183
  return typedConfig;
27938
28184
  }));
27939
28185
  }, []);
27940
- const addDayShiftBreak = React33.useCallback((lineId) => {
28186
+ const addDayShiftBreak = React14.useCallback((lineId) => {
27941
28187
  setLineConfigs((prev) => prev.map((config) => {
27942
28188
  const typedConfig = config;
27943
28189
  if (typedConfig.id === lineId) {
@@ -27959,7 +28205,7 @@ var ShiftsView = ({
27959
28205
  return typedConfig;
27960
28206
  }));
27961
28207
  }, []);
27962
- const addNightShiftBreak = React33.useCallback((lineId) => {
28208
+ const addNightShiftBreak = React14.useCallback((lineId) => {
27963
28209
  setLineConfigs((prev) => prev.map((config) => {
27964
28210
  const typedConfig = config;
27965
28211
  if (typedConfig.id === lineId) {
@@ -27980,7 +28226,7 @@ var ShiftsView = ({
27980
28226
  return typedConfig;
27981
28227
  }));
27982
28228
  }, []);
27983
- const updateDayShiftBreak = React33.useCallback((lineId, index, field, value) => {
28229
+ const updateDayShiftBreak = React14.useCallback((lineId, index, field, value) => {
27984
28230
  setLineConfigs((prev) => prev.map((config) => {
27985
28231
  const typedConfig = config;
27986
28232
  if (typedConfig.id === lineId) {
@@ -28008,7 +28254,7 @@ var ShiftsView = ({
28008
28254
  return typedConfig;
28009
28255
  }));
28010
28256
  }, []);
28011
- const updateNightShiftBreak = React33.useCallback((lineId, index, field, value) => {
28257
+ const updateNightShiftBreak = React14.useCallback((lineId, index, field, value) => {
28012
28258
  setLineConfigs((prev) => prev.map((config) => {
28013
28259
  const typedConfig = config;
28014
28260
  if (typedConfig.id === lineId) {
@@ -28036,7 +28282,7 @@ var ShiftsView = ({
28036
28282
  return typedConfig;
28037
28283
  }));
28038
28284
  }, []);
28039
- const removeDayShiftBreak = React33.useCallback((lineId, index) => {
28285
+ const removeDayShiftBreak = React14.useCallback((lineId, index) => {
28040
28286
  setLineConfigs((prev) => prev.map((config) => {
28041
28287
  if (config.id === lineId) {
28042
28288
  const dayShift = { ...config.dayShift };
@@ -28051,7 +28297,7 @@ var ShiftsView = ({
28051
28297
  return config;
28052
28298
  }));
28053
28299
  }, []);
28054
- const removeNightShiftBreak = React33.useCallback((lineId, index) => {
28300
+ const removeNightShiftBreak = React14.useCallback((lineId, index) => {
28055
28301
  setLineConfigs((prev) => prev.map((config) => {
28056
28302
  if (config.id === lineId) {
28057
28303
  const nightShift = { ...config.nightShift };
@@ -28066,7 +28312,7 @@ var ShiftsView = ({
28066
28312
  return config;
28067
28313
  }));
28068
28314
  }, []);
28069
- const handleSaveShifts = React33.useCallback(async (lineId) => {
28315
+ const handleSaveShifts = React14.useCallback(async (lineId) => {
28070
28316
  if (!auth.user?.id && false) ;
28071
28317
  setLineConfigs((prev) => prev.map(
28072
28318
  (config) => config.id === lineId ? { ...config, isSaving: true, saveSuccess: false } : config
@@ -28292,27 +28538,27 @@ var BulkConfigureModal = ({
28292
28538
  onSave,
28293
28539
  selectedShift
28294
28540
  }) => {
28295
- const [selectedLine, setSelectedLine] = React33.useState("");
28296
- const [selectedWorkspaces, setSelectedWorkspaces] = React33.useState([]);
28297
- const [actionType, setActionType] = React33.useState("assembly");
28298
- const [targetPPH, setTargetPPH] = React33.useState("");
28299
- const [targetCycleTime, setTargetCycleTime] = React33.useState("");
28300
- const [targetDayOutput, setTargetDayOutput] = React33.useState("");
28301
- const [productId, setProductId] = React33.useState("");
28302
- const [selectedCount, setSelectedCount] = React33.useState(0);
28303
- const shiftHours = React33.useMemo(() => {
28541
+ const [selectedLine, setSelectedLine] = React14.useState("");
28542
+ const [selectedWorkspaces, setSelectedWorkspaces] = React14.useState([]);
28543
+ const [actionType, setActionType] = React14.useState("assembly");
28544
+ const [targetPPH, setTargetPPH] = React14.useState("");
28545
+ const [targetCycleTime, setTargetCycleTime] = React14.useState("");
28546
+ const [targetDayOutput, setTargetDayOutput] = React14.useState("");
28547
+ const [productId, setProductId] = React14.useState("");
28548
+ const [selectedCount, setSelectedCount] = React14.useState(0);
28549
+ const shiftHours = React14.useMemo(() => {
28304
28550
  if (selectedLine && lineWorkspaces[selectedLine]) {
28305
28551
  return lineWorkspaces[selectedLine].shiftHours;
28306
28552
  }
28307
28553
  return 8;
28308
28554
  }, [selectedLine, lineWorkspaces]);
28309
- const selectedLineBreaks = React33.useMemo(() => {
28555
+ const selectedLineBreaks = React14.useMemo(() => {
28310
28556
  if (selectedLine && lineWorkspaces[selectedLine]) {
28311
28557
  return lineWorkspaces[selectedLine].breaks;
28312
28558
  }
28313
28559
  return [];
28314
28560
  }, [selectedLine, lineWorkspaces]);
28315
- React33.useEffect(() => {
28561
+ React14.useEffect(() => {
28316
28562
  if (!isOpen) {
28317
28563
  setTimeout(() => {
28318
28564
  setSelectedLine("");
@@ -28325,12 +28571,12 @@ var BulkConfigureModal = ({
28325
28571
  }, 200);
28326
28572
  }
28327
28573
  }, [isOpen]);
28328
- React33.useEffect(() => {
28574
+ React14.useEffect(() => {
28329
28575
  if (selectedLine && lineWorkspaces[selectedLine]) {
28330
28576
  setProductId(lineWorkspaces[selectedLine].productId);
28331
28577
  }
28332
28578
  }, [selectedLine, lineWorkspaces]);
28333
- React33.useEffect(() => {
28579
+ React14.useEffect(() => {
28334
28580
  setSelectedCount(selectedWorkspaces.length);
28335
28581
  }, [selectedWorkspaces]);
28336
28582
  const handleSave = async () => {
@@ -28385,7 +28631,7 @@ var BulkConfigureModal = ({
28385
28631
  setSelectedWorkspaces(allWorkspaceIds);
28386
28632
  }
28387
28633
  };
28388
- React33.useEffect(() => {
28634
+ React14.useEffect(() => {
28389
28635
  const handleEscape = (e) => {
28390
28636
  if (e.key === "Escape") {
28391
28637
  onClose();
@@ -28909,7 +29155,7 @@ var TargetsView = ({
28909
29155
  userId,
28910
29156
  onSaveChanges
28911
29157
  }) => {
28912
- const initialLineWorkspaces = React33.useMemo(() => {
29158
+ const initialLineWorkspaces = React14.useMemo(() => {
28913
29159
  return lineIds.reduce((acc, lineId) => ({
28914
29160
  ...acc,
28915
29161
  [lineId]: {
@@ -28926,22 +29172,22 @@ var TargetsView = ({
28926
29172
  }
28927
29173
  }), {});
28928
29174
  }, [lineIds]);
28929
- const [lineWorkspaces, setLineWorkspaces] = React33.useState(initialLineWorkspaces);
28930
- const [actionIds, setActionIds] = React33.useState(null);
28931
- const [savingLines, setSavingLines] = React33.useState(
29175
+ const [lineWorkspaces, setLineWorkspaces] = React14.useState(initialLineWorkspaces);
29176
+ const [actionIds, setActionIds] = React14.useState(null);
29177
+ const [savingLines, setSavingLines] = React14.useState(
28932
29178
  () => lineIds.reduce((acc, id3) => ({ ...acc, [id3]: false }), {})
28933
29179
  );
28934
- const [saveSuccess, setSaveSuccess] = React33.useState(
29180
+ const [saveSuccess, setSaveSuccess] = React14.useState(
28935
29181
  () => lineIds.reduce((acc, id3) => ({ ...acc, [id3]: false }), {})
28936
29182
  );
28937
- const [isLoading, setIsLoading] = React33.useState(true);
28938
- const [isBulkConfigureOpen, setIsBulkConfigureOpen] = React33.useState(false);
28939
- const [selectedWorkspaces, setSelectedWorkspaces] = React33.useState([]);
28940
- const [selectedShift, setSelectedShift] = React33.useState(0);
29183
+ const [isLoading, setIsLoading] = React14.useState(true);
29184
+ const [isBulkConfigureOpen, setIsBulkConfigureOpen] = React14.useState(false);
29185
+ const [selectedWorkspaces, setSelectedWorkspaces] = React14.useState([]);
29186
+ const [selectedShift, setSelectedShift] = React14.useState(0);
28941
29187
  const supabase = useSupabase();
28942
29188
  const auth = useAuth();
28943
29189
  userId || auth?.user?.id;
28944
- React33.useEffect(() => {
29190
+ React14.useEffect(() => {
28945
29191
  const fetchLineDetails = async () => {
28946
29192
  if (!supabase || lineIds.length === 0) return;
28947
29193
  const detailsPromises = lineIds.map(async (lineId) => {
@@ -28972,7 +29218,7 @@ var TargetsView = ({
28972
29218
  };
28973
29219
  fetchLineDetails();
28974
29220
  }, [supabase, lineIds]);
28975
- React33.useEffect(() => {
29221
+ React14.useEffect(() => {
28976
29222
  const fetchActions = async () => {
28977
29223
  if (!supabase) {
28978
29224
  console.error("Supabase client not available in fetchActions");
@@ -29005,7 +29251,7 @@ var TargetsView = ({
29005
29251
  };
29006
29252
  fetchActions();
29007
29253
  }, [supabase, companyId]);
29008
- const fetchLineThresholds = React33.useCallback(async () => {
29254
+ const fetchLineThresholds = React14.useCallback(async () => {
29009
29255
  try {
29010
29256
  if (!supabase) return;
29011
29257
  const currentDate = getOperationalDate();
@@ -29096,7 +29342,7 @@ var TargetsView = ({
29096
29342
  console.error("Error in fetchLineThresholds outer try-catch:", error);
29097
29343
  }
29098
29344
  }, [selectedShift, supabase, lineIds, lineWorkspaces]);
29099
- const loadOperatingHours = React33.useCallback(async (lineId, shiftId) => {
29345
+ const loadOperatingHours = React14.useCallback(async (lineId, shiftId) => {
29100
29346
  try {
29101
29347
  if (!supabase) return null;
29102
29348
  const { data, error } = await supabase.from("line_operating_hours").select("start_time, end_time, breaks").eq("line_id", lineId).eq("shift_id", shiftId).maybeSingle();
@@ -29191,7 +29437,7 @@ var TargetsView = ({
29191
29437
  };
29192
29438
  }
29193
29439
  }, [supabase]);
29194
- React33.useEffect(() => {
29440
+ React14.useEffect(() => {
29195
29441
  const allFactoryIdsLoaded = lineIds.every((lineId) => lineWorkspaces[lineId]?.factoryId);
29196
29442
  if (!actionIds || !allFactoryIdsLoaded) {
29197
29443
  return;
@@ -29254,7 +29500,7 @@ var TargetsView = ({
29254
29500
  };
29255
29501
  fetchWorkspacesAndThenThresholds();
29256
29502
  }, [actionIds, supabase, lineIds, lineWorkspaces, fetchLineThresholds]);
29257
- React33.useEffect(() => {
29503
+ React14.useEffect(() => {
29258
29504
  if (Object.keys(lineWorkspaces).length > 0) {
29259
29505
  const updatedLineWorkspaces = { ...lineWorkspaces };
29260
29506
  let hasChanges = false;
@@ -29284,7 +29530,7 @@ var TargetsView = ({
29284
29530
  }
29285
29531
  }
29286
29532
  }, [selectedShift]);
29287
- const toggleLineDropdown = React33.useCallback((lineId) => {
29533
+ const toggleLineDropdown = React14.useCallback((lineId) => {
29288
29534
  setLineWorkspaces((prev) => {
29289
29535
  const newIsOpen = !prev[lineId].isOpen;
29290
29536
  if (typeof window !== "undefined") {
@@ -29396,7 +29642,7 @@ var TargetsView = ({
29396
29642
  };
29397
29643
  loadShiftHours();
29398
29644
  };
29399
- const handleActionTypeChange = React33.useCallback((lineId, workspaceId, newActionType) => {
29645
+ const handleActionTypeChange = React14.useCallback((lineId, workspaceId, newActionType) => {
29400
29646
  if (!actionIds) return;
29401
29647
  setLineWorkspaces((prev) => ({
29402
29648
  ...prev,
@@ -29412,7 +29658,7 @@ var TargetsView = ({
29412
29658
  }
29413
29659
  }));
29414
29660
  }, [actionIds]);
29415
- const handleSaveLine = React33.useCallback(async (lineId) => {
29661
+ const handleSaveLine = React14.useCallback(async (lineId) => {
29416
29662
  console.log(`[handleSaveLine] Attempting to save line: ${lineId}`);
29417
29663
  const hardcodedUserId = "6bf6f271-1e55-4a95-9b89-1c3820b58739";
29418
29664
  const currentEffectiveUserId = hardcodedUserId;
@@ -29647,7 +29893,7 @@ var WorkspaceDetailView = ({
29647
29893
  showCycleTimeChart,
29648
29894
  renderHeaderActions
29649
29895
  }) => {
29650
- const parsedShiftId = React33.useMemo(() => {
29896
+ const parsedShiftId = React14.useMemo(() => {
29651
29897
  if (shift) {
29652
29898
  const shiftNumber = typeof shift === "string" ? parseInt(shift, 10) : shift;
29653
29899
  if (!isNaN(shiftNumber)) {
@@ -29656,19 +29902,19 @@ var WorkspaceDetailView = ({
29656
29902
  }
29657
29903
  return void 0;
29658
29904
  }, [shift]);
29659
- const [previousView, setPreviousView] = React33.useState("dashboard");
29660
- const [monthlyData, setMonthlyData] = React33.useState([]);
29661
- const [monthlyDataLoading, setMonthlyDataLoading] = React33.useState(false);
29905
+ const [previousView, setPreviousView] = React14.useState("dashboard");
29906
+ const [monthlyData, setMonthlyData] = React14.useState([]);
29907
+ const [monthlyDataLoading, setMonthlyDataLoading] = React14.useState(false);
29662
29908
  const today = new Date((/* @__PURE__ */ new Date()).toLocaleString("en-US", { timeZone: "Asia/Kolkata" }));
29663
- const [selectedMonth, setSelectedMonth] = React33.useState(today.getMonth());
29664
- const [selectedYear, setSelectedYear] = React33.useState(today.getFullYear());
29665
- const [selectedShift, setSelectedShift] = React33.useState("day");
29909
+ const [selectedMonth, setSelectedMonth] = React14.useState(today.getMonth());
29910
+ const [selectedYear, setSelectedYear] = React14.useState(today.getFullYear());
29911
+ const [selectedShift, setSelectedShift] = React14.useState("day");
29666
29912
  const isHistoricView = Boolean(date && parsedShiftId !== void 0);
29667
29913
  const initialTab = getInitialTab(sourceType, defaultTab, fromMonthly, date);
29668
- const [activeTab, setActiveTab] = React33.useState(initialTab);
29669
- const [isTransitioning, setIsTransitioning] = React33.useState(false);
29670
- const [usingFallbackData, setUsingFallbackData] = React33.useState(false);
29671
- const [showIdleTime, setShowIdleTime] = React33.useState(false);
29914
+ const [activeTab, setActiveTab] = React14.useState(initialTab);
29915
+ const [isTransitioning, setIsTransitioning] = React14.useState(false);
29916
+ const [usingFallbackData, setUsingFallbackData] = React14.useState(false);
29917
+ const [showIdleTime, setShowIdleTime] = React14.useState(false);
29672
29918
  const {
29673
29919
  metrics: historicMetrics,
29674
29920
  isLoading: historicLoading,
@@ -29690,17 +29936,17 @@ var WorkspaceDetailView = ({
29690
29936
  const workspace = isHistoricView ? historicMetrics : liveMetrics;
29691
29937
  const loading = isHistoricView ? historicLoading : liveLoading;
29692
29938
  const error = isHistoricView ? historicError : liveError;
29693
- React33.useEffect(() => {
29939
+ React14.useEffect(() => {
29694
29940
  if (onTabChange) {
29695
29941
  onTabChange(activeTab);
29696
29942
  }
29697
29943
  }, [activeTab, onTabChange]);
29698
- React33.useEffect(() => {
29944
+ React14.useEffect(() => {
29699
29945
  if (date) {
29700
29946
  setActiveTab("overview");
29701
29947
  }
29702
29948
  }, [date]);
29703
- React33.useEffect(() => {
29949
+ React14.useEffect(() => {
29704
29950
  if (liveMetrics && !date && !shift) {
29705
29951
  const currentDate = getOperationalDate();
29706
29952
  if (liveMetrics.date !== currentDate) {
@@ -29713,7 +29959,7 @@ var WorkspaceDetailView = ({
29713
29959
  }
29714
29960
  }
29715
29961
  }, [liveMetrics, date, shift, activeTab]);
29716
- React33.useMemo(() => {
29962
+ React14.useMemo(() => {
29717
29963
  if (isHistoricView && date) {
29718
29964
  try {
29719
29965
  new Date(date);
@@ -29725,7 +29971,7 @@ var WorkspaceDetailView = ({
29725
29971
  }
29726
29972
  return getOperationalDate();
29727
29973
  }, [isHistoricView, date]);
29728
- const handleMonthlyDataLoaded = React33.useCallback((data) => {
29974
+ const handleMonthlyDataLoaded = React14.useCallback((data) => {
29729
29975
  if (!data || !Array.isArray(data)) {
29730
29976
  console.error("Invalid monthly metrics data received:", data);
29731
29977
  setMonthlyData([]);
@@ -30632,6 +30878,7 @@ exports.createSupabaseClient = createSupabaseClient;
30632
30878
  exports.createThrottledReload = createThrottledReload;
30633
30879
  exports.dashboardService = dashboardService;
30634
30880
  exports.deleteThread = deleteThread;
30881
+ exports.forceRefreshWorkspaceDisplayNames = forceRefreshWorkspaceDisplayNames;
30635
30882
  exports.formatDateInZone = formatDateInZone;
30636
30883
  exports.formatDateTimeInZone = formatDateTimeInZone;
30637
30884
  exports.formatISTDate = formatISTDate;
@@ -30677,6 +30924,7 @@ exports.isWorkspaceDisplayNamesLoaded = isWorkspaceDisplayNamesLoaded;
30677
30924
  exports.isWorkspaceDisplayNamesLoading = isWorkspaceDisplayNamesLoading;
30678
30925
  exports.mergeWithDefaultConfig = mergeWithDefaultConfig;
30679
30926
  exports.optifyeAgentClient = optifyeAgentClient;
30927
+ exports.preInitializeWorkspaceDisplayNames = preInitializeWorkspaceDisplayNames;
30680
30928
  exports.preloadS3Video = preloadS3Video;
30681
30929
  exports.preloadS3VideoUrl = preloadS3VideoUrl;
30682
30930
  exports.preloadS3VideosUrl = preloadS3VideosUrl;