@optifye/dashboard-core 6.0.4 → 6.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -487,6 +487,76 @@ var getMetricsTablePrefix = (companyId) => {
487
487
  return "performance_metrics";
488
488
  };
489
489
 
490
+ // src/lib/utils/lineConfig.ts
491
+ function getConfiguredLineIds(entityConfig) {
492
+ if (entityConfig.lines && Object.keys(entityConfig.lines).length > 0) {
493
+ return Object.keys(entityConfig.lines);
494
+ }
495
+ const lineIds = [];
496
+ if (entityConfig.defaultLineId) {
497
+ lineIds.push(entityConfig.defaultLineId);
498
+ }
499
+ if (entityConfig.secondaryLineId && entityConfig.secondaryLineId !== entityConfig.defaultLineId) {
500
+ lineIds.push(entityConfig.secondaryLineId);
501
+ }
502
+ return lineIds;
503
+ }
504
+ function getLineDisplayName(entityConfig, lineId) {
505
+ if (entityConfig.lines && entityConfig.lines[lineId]) {
506
+ return entityConfig.lines[lineId];
507
+ }
508
+ if (entityConfig.lineNames && entityConfig.lineNames[lineId]) {
509
+ return entityConfig.lineNames[lineId];
510
+ }
511
+ return `Line ${lineId.substring(0, 8)}`;
512
+ }
513
+ function getAllLineDisplayNames(entityConfig) {
514
+ const displayNames = {};
515
+ if (entityConfig.lineNames) {
516
+ Object.assign(displayNames, entityConfig.lineNames);
517
+ }
518
+ if (entityConfig.lines) {
519
+ Object.assign(displayNames, entityConfig.lines);
520
+ }
521
+ return displayNames;
522
+ }
523
+ function getDefaultLineId(entityConfig) {
524
+ if (entityConfig.lines && Object.keys(entityConfig.lines).length > 0) {
525
+ return Object.keys(entityConfig.lines)[0];
526
+ }
527
+ return entityConfig.defaultLineId;
528
+ }
529
+ function isLegacyConfiguration(entityConfig) {
530
+ return !entityConfig.lines || Object.keys(entityConfig.lines).length === 0;
531
+ }
532
+ function migrateLegacyConfiguration(entityConfig) {
533
+ if (!isLegacyConfiguration(entityConfig)) {
534
+ return entityConfig;
535
+ }
536
+ const lines = {};
537
+ if (entityConfig.defaultLineId) {
538
+ lines[entityConfig.defaultLineId] = getLineDisplayName(entityConfig, entityConfig.defaultLineId);
539
+ }
540
+ if (entityConfig.secondaryLineId && entityConfig.secondaryLineId !== entityConfig.defaultLineId) {
541
+ lines[entityConfig.secondaryLineId] = getLineDisplayName(entityConfig, entityConfig.secondaryLineId);
542
+ }
543
+ if (entityConfig.lineNames) {
544
+ Object.entries(entityConfig.lineNames).forEach(([id3, name]) => {
545
+ if (!lines[id3]) {
546
+ lines[id3] = name;
547
+ }
548
+ });
549
+ }
550
+ return {
551
+ ...entityConfig,
552
+ lines
553
+ };
554
+ }
555
+ function isValidFactoryViewConfiguration(entityConfig) {
556
+ const lineIds = getConfiguredLineIds(entityConfig);
557
+ return lineIds.length > 0;
558
+ }
559
+
490
560
  // src/lib/services/dashboardService.ts
491
561
  var getTable2 = (dbConfig, tableName) => {
492
562
  const defaults2 = DEFAULT_DATABASE_CONFIG.tables;
@@ -508,15 +578,15 @@ var dashboardService = {
508
578
  const companyId = entityConfig.companyId;
509
579
  const metricsTablePrefixStr = getMetricsTablePrefix();
510
580
  const metricsTable = `${metricsTablePrefixStr}_${companyId ? companyId.replace(/-/g, "_") : "unknown_company"}`;
511
- const defaultLineId = entityConfig.defaultLineId;
512
- const secondaryLineId = entityConfig.secondaryLineId;
581
+ const configuredLineIds = getConfiguredLineIds(entityConfig);
582
+ const defaultLineId = configuredLineIds[0];
513
583
  const factoryViewId = entityConfig.factoryViewId ?? "factory";
514
584
  const defaultTimezone = dateTimeConfig.defaultTimezone;
515
585
  const { shiftId, date } = getCurrentShift(defaultTimezone, shiftConfig);
516
586
  const lineId = lineIdInput;
517
587
  if (lineId === factoryViewId) {
518
- if (!defaultLineId || !secondaryLineId || !companyId) {
519
- throw new Error("Factory View requires defaultLineId, secondaryLineId, and companyId to be configured.");
588
+ if (!isValidFactoryViewConfiguration(entityConfig) || !companyId) {
589
+ throw new Error("Factory View requires at least one configured line and companyId to be configured.");
520
590
  }
521
591
  const [lineResult, metricsResult, performanceResult] = await Promise.all([
522
592
  // Get Line 1's info for general factory details
@@ -528,10 +598,10 @@ var dashboardService = {
528
598
  company_id,
529
599
  companies!lines_company_id_fkey(company_name:name)
530
600
  `).eq("id", defaultLineId).maybeSingle(),
531
- // Get metrics from line_metrics table for both lines
532
- supabase.from(lineMetricsTable).select("*").in("line_id", [defaultLineId, secondaryLineId]).eq("shift_id", shiftId).eq("date", date),
533
- // Get performance data from the dynamic metrics table for both lines
534
- supabase.from(metricsTable).select("efficiency").in("line_id", [defaultLineId, secondaryLineId]).eq("shift_id", shiftId).eq("date", date)
601
+ // Get metrics from line_metrics table for all configured lines
602
+ supabase.from(lineMetricsTable).select("*").in("line_id", configuredLineIds).eq("shift_id", shiftId).eq("date", date),
603
+ // Get performance data from the dynamic metrics table for all configured lines
604
+ supabase.from(metricsTable).select("efficiency").in("line_id", configuredLineIds).eq("shift_id", shiftId).eq("date", date)
535
605
  ]);
536
606
  if (lineResult.error) throw lineResult.error;
537
607
  if (!lineResult.data) throw new Error(`Configured default line (${defaultLineId}) not found`);
@@ -678,8 +748,8 @@ var dashboardService = {
678
748
  }
679
749
  const metricsTablePrefixStr = getMetricsTablePrefix();
680
750
  const metricsTable = `${metricsTablePrefixStr}_${companyId.replace(/-/g, "_")}`;
681
- const defaultLineId = entityConfig.defaultLineId;
682
- const secondaryLineId = entityConfig.secondaryLineId;
751
+ const configuredLineIds = getConfiguredLineIds(entityConfig);
752
+ configuredLineIds[0];
683
753
  const factoryViewId = entityConfig.factoryViewId ?? "factory";
684
754
  const defaultTimezone = dateTimeConfig.defaultTimezone;
685
755
  const currentShiftResult = getCurrentShift(defaultTimezone, shiftConfig);
@@ -688,10 +758,10 @@ var dashboardService = {
688
758
  const lineId = lineIdInput;
689
759
  let query = supabase.from(metricsTable).select("company_id,line_id,shift_id,date,workspace_id,workspace_name,total_output,avg_pph,performance_score,avg_cycle_time,trend_score,ideal_output,efficiency,total_day_output").eq("shift_id", queryShiftId).eq("date", queryDate);
690
760
  if (!lineId || lineId === factoryViewId) {
691
- if (!defaultLineId || !secondaryLineId) {
692
- throw new Error("Factory View requires defaultLineId and secondaryLineId to be configured for workspace data.");
761
+ if (!isValidFactoryViewConfiguration(entityConfig)) {
762
+ throw new Error("Factory View requires at least one configured line for workspace data.");
693
763
  }
694
- query = query.in("line_id", [defaultLineId, secondaryLineId]);
764
+ query = query.in("line_id", configuredLineIds);
695
765
  } else {
696
766
  query = query.eq("line_id", lineId);
697
767
  }
@@ -916,8 +986,8 @@ var dashboardService = {
916
986
  const companyId = entityConfig.companyId;
917
987
  const metricsTablePrefixStr = getMetricsTablePrefix();
918
988
  const metricsTable = `${metricsTablePrefixStr}_${companyId ? companyId.replace(/-/g, "_") : "unknown_company"}`;
919
- const defaultLineId = entityConfig.defaultLineId;
920
- const secondaryLineId = entityConfig.secondaryLineId;
989
+ const configuredLineIds = getConfiguredLineIds(entityConfig);
990
+ const defaultLineId = configuredLineIds[0];
921
991
  const factoryViewId = entityConfig.factoryViewId ?? "factory";
922
992
  const defaultTimezone = dateTimeConfig.defaultTimezone;
923
993
  const lineIdToQuery = lineIdInput || factoryViewId;
@@ -926,10 +996,10 @@ var dashboardService = {
926
996
  const queryShiftId = shiftProp !== void 0 ? shiftProp : currentShiftResult.shiftId;
927
997
  try {
928
998
  if (lineIdToQuery === factoryViewId) {
929
- if (!defaultLineId || !companyId) {
930
- throw new Error("Factory View requires at least defaultLineId and companyId to be configured.");
999
+ if (!isValidFactoryViewConfiguration(entityConfig) || !companyId) {
1000
+ throw new Error("Factory View requires at least one configured line and companyId to be configured.");
931
1001
  }
932
- const lineIdsToQuery = [defaultLineId, secondaryLineId].filter((id3) => id3 !== void 0 && id3 !== null);
1002
+ const lineIdsToQuery = configuredLineIds;
933
1003
  const [line1Result, metricsResult2, performanceResult2] = await Promise.all([
934
1004
  supabase.from(linesTable).select("id, line_name, factory_id, factories!lines_factory_id_fkey(factory_name), company_id, companies!lines_company_id_fkey(company_name:name)").eq("id", defaultLineId).single(),
935
1005
  supabase.from(lineMetricsTable).select("*").in("line_id", lineIdsToQuery).eq("shift_id", queryShiftId).eq("date", queryDate),
@@ -1100,8 +1170,7 @@ var dashboardService = {
1100
1170
  const dbConfig = config.databaseConfig ?? DEFAULT_DATABASE_CONFIG;
1101
1171
  const entityConfig = config.entityConfig ?? DEFAULT_ENTITY_CONFIG;
1102
1172
  const lineMetricsTable = getTable2(dbConfig, "lineMetrics");
1103
- const defaultLineId = entityConfig.defaultLineId;
1104
- const secondaryLineId = entityConfig.secondaryLineId;
1173
+ const configuredLineIds = getConfiguredLineIds(entityConfig);
1105
1174
  const factoryViewId = entityConfig.factoryViewId ?? "factory";
1106
1175
  const startDate = new Date(year, month, 1);
1107
1176
  const endDate = new Date(year, month + 1, 0);
@@ -1110,10 +1179,10 @@ var dashboardService = {
1110
1179
  const formattedEndDate = formatDate(endDate);
1111
1180
  let query = supabase.from(lineMetricsTable).select("date, shift_id, avg_efficiency, underperforming_workspaces, total_workspaces").gte("date", formattedStartDate).lte("date", formattedEndDate);
1112
1181
  if (lineIdInput === factoryViewId) {
1113
- if (!defaultLineId || !secondaryLineId) {
1114
- throw new Error("Factory View requires defaultLineId and secondaryLineId for monthly data.");
1182
+ if (!isValidFactoryViewConfiguration(entityConfig)) {
1183
+ throw new Error("Factory View requires at least one configured line for monthly data.");
1115
1184
  }
1116
- query = query.in("line_id", [defaultLineId, secondaryLineId]);
1185
+ query = query.in("line_id", configuredLineIds);
1117
1186
  } else {
1118
1187
  query = query.eq("line_id", lineIdInput);
1119
1188
  }
@@ -1144,8 +1213,7 @@ var dashboardService = {
1144
1213
  const companyId = entityConfig.companyId;
1145
1214
  const metricsTablePrefixStr = getMetricsTablePrefix();
1146
1215
  const metricsTable = `${metricsTablePrefixStr}_${companyId ? companyId.replace(/-/g, "_") : "unknown_company"}`;
1147
- const defaultLineId = entityConfig.defaultLineId;
1148
- const secondaryLineId = entityConfig.secondaryLineId;
1216
+ const configuredLineIds = getConfiguredLineIds(entityConfig);
1149
1217
  const factoryViewId = entityConfig.factoryViewId ?? "factory";
1150
1218
  const worstPerformingEndpoint = endpointsConfig?.worstPerformingWorkspaces;
1151
1219
  if (!worstPerformingEndpoint) throw new Error("worstPerformingWorkspaces endpoint must be configured.");
@@ -1157,7 +1225,7 @@ var dashboardService = {
1157
1225
  const currentMonth = monthInput !== void 0 ? monthInput : currentDate.getMonth();
1158
1226
  const currentYear = yearInput !== void 0 ? yearInput : currentDate.getFullYear();
1159
1227
  const bodyPayload = {
1160
- lineId: lineIdInput === factoryViewId ? [defaultLineId, secondaryLineId] : lineIdInput,
1228
+ lineId: lineIdInput === factoryViewId ? configuredLineIds : lineIdInput,
1161
1229
  month: currentMonth,
1162
1230
  year: currentYear,
1163
1231
  companyId,
@@ -2010,7 +2078,7 @@ var authRateLimitService = {
2010
2078
  };
2011
2079
  var isMixpanelInitialized = false;
2012
2080
  var currentUserProperties;
2013
- var initializeCoreMixpanel = (token, debug, trackPageView) => {
2081
+ var initializeCoreMixpanel = (token, debugOrOptions, trackPageViewArg) => {
2014
2082
  if (!token) {
2015
2083
  console.warn("Mixpanel token not provided for initialization. Mixpanel will not be enabled.");
2016
2084
  return;
@@ -2019,15 +2087,51 @@ var initializeCoreMixpanel = (token, debug, trackPageView) => {
2019
2087
  console.warn("Mixpanel already initialized. Ignoring subsequent initialization.");
2020
2088
  return;
2021
2089
  }
2022
- mixpanel.init(token, {
2090
+ let debug;
2091
+ let trackPageView;
2092
+ let sessionOpts = {};
2093
+ if (typeof debugOrOptions === "boolean" || debugOrOptions === void 0) {
2094
+ debug = debugOrOptions;
2095
+ trackPageView = trackPageViewArg;
2096
+ } else {
2097
+ const opts = debugOrOptions;
2098
+ ({ debug, trackPageView, ...sessionOpts } = opts);
2099
+ }
2100
+ const initOptions = {
2023
2101
  debug: debug ?? process.env.NODE_ENV === "development",
2024
- // Keep env var as fallback if not explicitly passed
2025
2102
  track_pageview: trackPageView ?? true,
2026
- // Default to true if not specified in config
2027
2103
  persistence: "localStorage"
2104
+ };
2105
+ if (sessionOpts.recordSessionsPercent !== void 0) {
2106
+ initOptions.record_sessions_percent = sessionOpts.recordSessionsPercent;
2107
+ } else {
2108
+ initOptions.record_sessions_percent = 1;
2109
+ }
2110
+ if (sessionOpts.recordIdleTimeoutMs !== void 0) {
2111
+ initOptions.record_idle_timeout_ms = sessionOpts.recordIdleTimeoutMs;
2112
+ }
2113
+ if (sessionOpts.recordHeatmapData !== void 0) {
2114
+ initOptions.record_heatmap_data = sessionOpts.recordHeatmapData;
2115
+ } else {
2116
+ initOptions.record_heatmap_data = true;
2117
+ }
2118
+ if (sessionOpts.recordCanvas !== void 0) {
2119
+ initOptions.record_canvas = sessionOpts.recordCanvas;
2120
+ }
2121
+ if (sessionOpts.recordBlockSelector !== void 0) {
2122
+ initOptions.record_block_selector = sessionOpts.recordBlockSelector;
2123
+ }
2124
+ if (sessionOpts.recordMaskTextSelector !== void 0) {
2125
+ initOptions.record_mask_text_selector = sessionOpts.recordMaskTextSelector;
2126
+ }
2127
+ Object.keys(sessionOpts).forEach((key) => {
2128
+ if (!(key in initOptions)) {
2129
+ initOptions[key] = sessionOpts[key];
2130
+ }
2028
2131
  });
2132
+ mixpanel.init(token, initOptions);
2029
2133
  isMixpanelInitialized = true;
2030
- console.log("Mixpanel initialized in dashboard-core.");
2134
+ console.log("Mixpanel initialized in dashboard-core with Session Replay support.");
2031
2135
  };
2032
2136
  var trackCorePageView = (pageName, properties) => {
2033
2137
  if (!isMixpanelInitialized) return;
@@ -2043,6 +2147,46 @@ var trackCoreEvent = (eventName, properties) => {
2043
2147
  };
2044
2148
  mixpanel.track(eventName, mergedProps);
2045
2149
  };
2150
+ var startCoreSessionRecording = () => {
2151
+ try {
2152
+ if (!isMixpanelInitialized) return;
2153
+ if (typeof mixpanel.start_session_recording === "function") {
2154
+ mixpanel.start_session_recording();
2155
+ }
2156
+ } catch (err) {
2157
+ console.error("[Mixpanel] Unable to start session recording:", err);
2158
+ }
2159
+ };
2160
+ var stopCoreSessionRecording = () => {
2161
+ try {
2162
+ if (!isMixpanelInitialized) return;
2163
+ if (typeof mixpanel.stop_session_recording === "function") {
2164
+ mixpanel.stop_session_recording();
2165
+ }
2166
+ } catch (err) {
2167
+ console.error("[Mixpanel] Unable to stop session recording:", err);
2168
+ }
2169
+ };
2170
+ var getCoreSessionRecordingProperties = () => {
2171
+ try {
2172
+ if (!isMixpanelInitialized) return {};
2173
+ if (typeof mixpanel.get_session_recording_properties === "function") {
2174
+ return mixpanel.get_session_recording_properties() || {};
2175
+ }
2176
+ } catch {
2177
+ }
2178
+ return {};
2179
+ };
2180
+ var getCoreSessionReplayUrl = () => {
2181
+ try {
2182
+ if (!isMixpanelInitialized) return null;
2183
+ if (typeof mixpanel.get_session_replay_url === "function") {
2184
+ return mixpanel.get_session_replay_url();
2185
+ }
2186
+ } catch {
2187
+ }
2188
+ return null;
2189
+ };
2046
2190
  var identifyCoreUser = (userId, userProperties) => {
2047
2191
  if (!isMixpanelInitialized) return;
2048
2192
  mixpanel.identify(userId);
@@ -2094,8 +2238,9 @@ var SSEChatClient = class {
2094
2238
  thread_id: threadId,
2095
2239
  user_id: userId,
2096
2240
  company_id: context.companyId,
2097
- line_id: context.lineId,
2098
- shift_id: context.shiftId
2241
+ shift_id: context.shiftId,
2242
+ // Send all_lines if available, otherwise fall back to single line_id
2243
+ ...context.allLines && context.allLines.length > 0 ? { all_lines: context.allLines } : { line_id: context.lineId }
2099
2244
  }),
2100
2245
  signal: controller.signal,
2101
2246
  // Don't include credentials since the API returns Access-Control-Allow-Origin: *
@@ -3820,11 +3965,11 @@ var useLineDetailedMetrics = (lineIdFromProp) => {
3820
3965
  let targetLineIdsForSubscription = [];
3821
3966
  const factoryViewIdentifier = entityConfig.factoryViewId || "factory";
3822
3967
  if (lineIdToUse === factoryViewIdentifier) {
3823
- if (entityConfig.defaultLineId && entityConfig.secondaryLineId) {
3824
- targetLineIdsForSubscription = [entityConfig.defaultLineId, entityConfig.secondaryLineId];
3968
+ if (isValidFactoryViewConfiguration(entityConfig)) {
3969
+ targetLineIdsForSubscription = getConfiguredLineIds(entityConfig);
3825
3970
  filterString += `,line_id=in.(${targetLineIdsForSubscription.join(",")})`;
3826
3971
  } else {
3827
- console.warn("[useLineDetailedMetrics] Factory view selected but defaultLineId/secondaryLineId not in entityConfig. Realtime updates may be incomplete.");
3972
+ console.warn("[useLineDetailedMetrics] Factory view selected but no lines configured in entityConfig. Realtime updates may be incomplete.");
3828
3973
  return;
3829
3974
  }
3830
3975
  } else {
@@ -4042,9 +4187,9 @@ var useDashboardMetrics = ({ onLineMetricsUpdate, lineId }) => {
4042
4187
  try {
4043
4188
  const currentShiftDetails = getCurrentShift(defaultTimezone, shiftConfig);
4044
4189
  const operationalDate = getOperationalDate(defaultTimezone);
4045
- const targetLineIds = currentLineIdToUse === (entityConfig.factoryViewId || "factory") ? [entityConfig.defaultLineId, entityConfig.secondaryLineId].filter((id3) => !!id3) : [currentLineIdToUse];
4190
+ const targetLineIds = currentLineIdToUse === (entityConfig.factoryViewId || "factory") ? getConfiguredLineIds(entityConfig) : [currentLineIdToUse];
4046
4191
  if (targetLineIds.length === 0 && currentLineIdToUse === (entityConfig.factoryViewId || "factory")) {
4047
- throw new Error("Factory view selected, but defaultLineId and/or secondaryLineId are not configured in entityConfig.");
4192
+ throw new Error("Factory view selected, but no lines are configured in entityConfig.");
4048
4193
  }
4049
4194
  if (targetLineIds.length === 0) {
4050
4195
  throw new Error("No target line IDs available for fetching metrics.");
@@ -4144,7 +4289,7 @@ var useDashboardMetrics = ({ onLineMetricsUpdate, lineId }) => {
4144
4289
  }
4145
4290
  const currentShiftDetails = getCurrentShift(defaultTimezone, shiftConfig);
4146
4291
  const operationalDateForSubscription = getOperationalDate(defaultTimezone);
4147
- const targetLineIds = currentLineIdToUse === (entityConfig.factoryViewId || "factory") ? [entityConfig.defaultLineId, entityConfig.secondaryLineId].filter((id3) => !!id3) : [currentLineIdToUse];
4292
+ const targetLineIds = currentLineIdToUse === (entityConfig.factoryViewId || "factory") ? getConfiguredLineIds(entityConfig) : [currentLineIdToUse];
4148
4293
  if (targetLineIds.length === 0) return;
4149
4294
  const wsMetricsFilter = `date=eq.${operationalDateForSubscription}&shift_id=eq.${currentShiftDetails.shiftId}&line_id=in.(${targetLineIds.join(",")})`;
4150
4295
  const lineMetricsFilter = `date=eq.${operationalDateForSubscription}&shift_id=eq.${currentShiftDetails.shiftId}&line_id=in.(${targetLineIds.join(",")})`;
@@ -4313,11 +4458,8 @@ var useLineKPIs = ({ lineId }) => {
4313
4458
  const currentShiftDetails = getCurrentShift(defaultTimezone, shiftConfig);
4314
4459
  const operationalDate = currentShiftDetails.date;
4315
4460
  const factoryViewIdentifier = entityConfig.factoryViewId || "factory";
4316
- const targetLineIds = currentLineId === factoryViewIdentifier ? [entityConfig.defaultLineId, entityConfig.secondaryLineId].filter((id3) => !!id3) : [currentLineId];
4317
- if (targetLineIds.length === 0 && currentLineId === factoryViewIdentifier) {
4318
- console.warn("[useLineKPIs] Factory view: defaultLineId/secondaryLineId not in entityConfig. Cannot subscribe effectively.");
4319
- return;
4320
- } else if (targetLineIds.length === 0) {
4461
+ const targetLineIds = currentLineId === factoryViewIdentifier ? getConfiguredLineIds(entityConfig) : [currentLineId];
4462
+ if (targetLineIds.length === 0) {
4321
4463
  console.warn("[useLineKPIs] No target line IDs for subscription. LineId:", currentLineId);
4322
4464
  return;
4323
4465
  }
@@ -4417,10 +4559,8 @@ var useRealtimeLineMetrics = ({
4417
4559
  currentTime: (/* @__PURE__ */ new Date()).toLocaleString("en-US", { timeZone: dateTimeConfig.defaultTimezone || "Asia/Kolkata" })
4418
4560
  });
4419
4561
  const factoryViewId = entityConfig.factoryViewId || "factory";
4420
- const defaultLineId = entityConfig.defaultLineId;
4421
- const secondaryLineId = entityConfig.secondaryLineId;
4422
4562
  if (lineIdRef.current === factoryViewId) {
4423
- const targetLineIds = [defaultLineId, secondaryLineId].filter(Boolean);
4563
+ const targetLineIds = getConfiguredLineIds(entityConfig);
4424
4564
  if (targetLineIds.length === 0) {
4425
4565
  throw new Error("No configured line IDs for factory view");
4426
4566
  }
@@ -4634,9 +4774,7 @@ var useRealtimeLineMetrics = ({
4634
4774
  console.log("Setting up line metrics subscriptions for:", lineIdRef.current);
4635
4775
  }
4636
4776
  const factoryViewId = entityConfig.factoryViewId || "factory";
4637
- const defaultLineId = entityConfig.defaultLineId;
4638
- const secondaryLineId = entityConfig.secondaryLineId;
4639
- const targetLineIds = lineIdRef.current === factoryViewId ? [defaultLineId, secondaryLineId].filter(Boolean) : [lineIdRef.current];
4777
+ const targetLineIds = lineIdRef.current === factoryViewId ? getConfiguredLineIds(entityConfig) : [lineIdRef.current];
4640
4778
  if (targetLineIds.length === 0) {
4641
4779
  return;
4642
4780
  }
@@ -25680,6 +25818,12 @@ var AIAgentView = () => {
25680
25818
  const lineId = getLineIdFromPath();
25681
25819
  const { shiftId } = getCurrentShift(dateTimeConfig.defaultTimezone || "Asia/Kolkata", shiftConfig);
25682
25820
  const companyId = entityConfig.companyId || "default-company-id";
25821
+ const configuredLineIds = getConfiguredLineIds(entityConfig);
25822
+ const lineDisplayNames = getAllLineDisplayNames(entityConfig);
25823
+ const allLines = configuredLineIds.map((id3) => ({
25824
+ id: id3,
25825
+ name: lineDisplayNames[id3] || `Line ${id3.substring(0, 8)}`
25826
+ }));
25683
25827
  const ACTIVE_THREAD_STORAGE_KEY = `ai-agent-active-thread-${lineId}`;
25684
25828
  useLayoutEffect(() => {
25685
25829
  const savedThreadId = localStorage.getItem(ACTIVE_THREAD_STORAGE_KEY);
@@ -25850,7 +25994,8 @@ var AIAgentView = () => {
25850
25994
  {
25851
25995
  companyId,
25852
25996
  lineId,
25853
- shiftId
25997
+ shiftId,
25998
+ allLines
25854
25999
  },
25855
26000
  {
25856
26001
  onThreadCreated: (threadId) => {
@@ -26497,6 +26642,13 @@ var AIAgentView = () => {
26497
26642
  console.error("Bar chart missing required parameters:", { data: !!args.data, x_field: !!args.x_field, y_field: !!args.y_field });
26498
26643
  return null;
26499
26644
  }
26645
+ if (!Array.isArray(args.data)) {
26646
+ console.error("Bar chart data must be an array, got:", typeof args.data, args.data);
26647
+ return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxs("div", { className: "text-red-500 text-sm", children: [
26648
+ "Error: Chart data must be an array. Received: ",
26649
+ typeof args.data
26650
+ ] }) }, `bar-error-${key}`);
26651
+ }
26500
26652
  return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsx("div", { className: "w-full h-64", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(BarChart$1, { data: args.data, margin: CHART_STYLES.margin, children: [
26501
26653
  /* @__PURE__ */ jsx(CartesianGrid, { ...CHART_STYLES.grid }),
26502
26654
  /* @__PURE__ */ jsx(
@@ -26534,6 +26686,13 @@ var AIAgentView = () => {
26534
26686
  console.error("Line chart missing required parameters:", { data: !!args.data, x_field: !!args.x_field, y_field: !!args.y_field });
26535
26687
  return null;
26536
26688
  }
26689
+ if (!Array.isArray(args.data)) {
26690
+ console.error("Line chart data must be an array, got:", typeof args.data, args.data);
26691
+ return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxs("div", { className: "text-red-500 text-sm", children: [
26692
+ "Error: Chart data must be an array. Received: ",
26693
+ typeof args.data
26694
+ ] }) }, `line-error-${key}`);
26695
+ }
26537
26696
  return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsx("div", { className: "w-full h-64", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(LineChart$1, { data: args.data, margin: CHART_STYLES.margin, children: [
26538
26697
  /* @__PURE__ */ jsx(CartesianGrid, { ...CHART_STYLES.grid }),
26539
26698
  /* @__PURE__ */ jsx(
@@ -26575,6 +26734,13 @@ var AIAgentView = () => {
26575
26734
  console.error("Available args:", Object.keys(args));
26576
26735
  return null;
26577
26736
  }
26737
+ if (!Array.isArray(args.data)) {
26738
+ console.error("Pie chart data must be an array, got:", typeof args.data, args.data);
26739
+ return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxs("div", { className: "text-red-500 text-sm", children: [
26740
+ "Error: Chart data must be an array. Received: ",
26741
+ typeof args.data
26742
+ ] }) }, `pie-error-${key}`);
26743
+ }
26578
26744
  const pieData = args.data.map((item) => ({
26579
26745
  name: item[args.label_field],
26580
26746
  value: item[args.value_field]
@@ -26594,6 +26760,13 @@ var AIAgentView = () => {
26594
26760
  console.error("Comparison table missing required data");
26595
26761
  return null;
26596
26762
  }
26763
+ if (!Array.isArray(args.data)) {
26764
+ console.error("Comparison table data must be an array, got:", typeof args.data, args.data);
26765
+ return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxs("div", { className: "text-red-500 text-sm", children: [
26766
+ "Error: Table data must be an array. Received: ",
26767
+ typeof args.data
26768
+ ] }) }, `table-error-${key}`);
26769
+ }
26597
26770
  const columns = args.columns || Object.keys(args.data[0] || {});
26598
26771
  let sortedData = [...args.data];
26599
26772
  if (args.sort_by && columns.includes(args.sort_by)) {
@@ -26633,6 +26806,13 @@ var AIAgentView = () => {
26633
26806
  });
26634
26807
  return null;
26635
26808
  }
26809
+ if (!Array.isArray(args.data)) {
26810
+ console.error("Multi-line chart data must be an array, got:", typeof args.data, args.data);
26811
+ return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxs("div", { className: "text-red-500 text-sm", children: [
26812
+ "Error: Chart data must be an array. Received: ",
26813
+ typeof args.data
26814
+ ] }) }, `multi-line-error-${key}`);
26815
+ }
26636
26816
  return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsx("div", { className: "w-full h-80", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(LineChart$1, { data: args.data, margin: CHART_STYLES.margin, children: [
26637
26817
  /* @__PURE__ */ jsx(CartesianGrid, { ...CHART_STYLES.grid }),
26638
26818
  /* @__PURE__ */ jsx(
@@ -26686,6 +26866,13 @@ var AIAgentView = () => {
26686
26866
  });
26687
26867
  return null;
26688
26868
  }
26869
+ if (!Array.isArray(args.data)) {
26870
+ console.error("Stacked bar chart data must be an array, got:", typeof args.data, args.data);
26871
+ return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxs("div", { className: "text-red-500 text-sm", children: [
26872
+ "Error: Chart data must be an array. Received: ",
26873
+ typeof args.data
26874
+ ] }) }, `stacked-bar-error-${key}`);
26875
+ }
26689
26876
  return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsx("div", { className: "w-full h-80", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(BarChart$1, { data: args.data, margin: CHART_STYLES.margin, children: [
26690
26877
  /* @__PURE__ */ jsx(CartesianGrid, { ...CHART_STYLES.grid }),
26691
26878
  /* @__PURE__ */ jsx(
@@ -26738,6 +26925,13 @@ var AIAgentView = () => {
26738
26925
  });
26739
26926
  return null;
26740
26927
  }
26928
+ if (!Array.isArray(args.data)) {
26929
+ console.error("Dual-axis chart data must be an array, got:", typeof args.data, args.data);
26930
+ return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxs("div", { className: "text-red-500 text-sm", children: [
26931
+ "Error: Chart data must be an array. Received: ",
26932
+ typeof args.data
26933
+ ] }) }, `dual-axis-error-${key}`);
26934
+ }
26741
26935
  return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsx("div", { className: "w-full h-80", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(ComposedChart, { data: args.data, margin: { ...CHART_STYLES.margin, bottom: 80 }, children: [
26742
26936
  /* @__PURE__ */ jsx(CartesianGrid, { ...CHART_STYLES.grid }),
26743
26937
  /* @__PURE__ */ jsx(
@@ -26825,6 +27019,13 @@ var AIAgentView = () => {
26825
27019
  });
26826
27020
  return null;
26827
27021
  }
27022
+ if (!Array.isArray(args.data)) {
27023
+ console.error("Scatter plot data must be an array, got:", typeof args.data, args.data);
27024
+ return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxs("div", { className: "text-red-500 text-sm", children: [
27025
+ "Error: Chart data must be an array. Received: ",
27026
+ typeof args.data
27027
+ ] }) }, `scatter-error-${key}`);
27028
+ }
26828
27029
  const groupedData = args.data.reduce((acc, item) => {
26829
27030
  const group = item[args.group_field];
26830
27031
  if (!acc[group]) {
@@ -26888,6 +27089,13 @@ var AIAgentView = () => {
26888
27089
  });
26889
27090
  return null;
26890
27091
  }
27092
+ if (!Array.isArray(args.data)) {
27093
+ console.error("Combo chart data must be an array, got:", typeof args.data, args.data);
27094
+ return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxs("div", { className: "text-red-500 text-sm", children: [
27095
+ "Error: Chart data must be an array. Received: ",
27096
+ typeof args.data
27097
+ ] }) }, `combo-error-${key}`);
27098
+ }
26891
27099
  return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsx("div", { className: "w-full h-80", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(ComposedChart, { data: args.data, margin: { ...CHART_STYLES.margin, bottom: 80 }, children: [
26892
27100
  /* @__PURE__ */ jsx(CartesianGrid, { ...CHART_STYLES.grid }),
26893
27101
  /* @__PURE__ */ jsx(
@@ -26962,6 +27170,13 @@ var AIAgentView = () => {
26962
27170
  });
26963
27171
  return null;
26964
27172
  }
27173
+ if (!Array.isArray(args.data)) {
27174
+ console.error("Area chart data must be an array, got:", typeof args.data, args.data);
27175
+ return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxs("div", { className: "text-red-500 text-sm", children: [
27176
+ "Error: Chart data must be an array. Received: ",
27177
+ typeof args.data
27178
+ ] }) }, `area-error-${key}`);
27179
+ }
26965
27180
  return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsx("div", { className: "w-full h-80", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(ComposedChart, { data: args.data, margin: { ...CHART_STYLES.margin, bottom: 80 }, children: [
26966
27181
  /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", { id: "colorGradient", x1: "0", y1: "0", x2: "0", y2: "1", children: [
26967
27182
  /* @__PURE__ */ jsx("stop", { offset: "5%", stopColor: CHART_COLORS.primary, stopOpacity: 0.8 }),
@@ -27399,20 +27614,33 @@ var DEFAULT_SHIFT_CONFIG2 = {
27399
27614
  var FactoryView = ({
27400
27615
  line1Id,
27401
27616
  line2Id,
27617
+ lineIds,
27618
+ lineNames = {},
27402
27619
  factoryName = "Plant 1",
27403
27620
  timezone = DEFAULT_TIMEZONE,
27404
27621
  shiftConfig = DEFAULT_SHIFT_CONFIG2,
27405
27622
  productIds = {}
27406
27623
  }) => {
27624
+ const effectiveLineIds = useMemo(() => {
27625
+ if (lineIds && lineIds.length > 0) {
27626
+ return lineIds;
27627
+ }
27628
+ const ids = [];
27629
+ if (line1Id) ids.push(line1Id);
27630
+ if (line2Id && line2Id !== line1Id) ids.push(line2Id);
27631
+ return ids;
27632
+ }, [lineIds, line1Id, line2Id]);
27407
27633
  const router = useRouter();
27408
27634
  const supabase = useSupabase();
27409
- const line1DataHook = useLineDetailedMetrics(line1Id);
27410
- const line2DataHook = useLineDetailedMetrics(line2Id);
27635
+ const lineDataHooks = effectiveLineIds.map((lineId) => ({
27636
+ lineId,
27637
+ hook: useLineDetailedMetrics(lineId)
27638
+ }));
27411
27639
  const [lines, setLines] = useState([]);
27412
27640
  const [loading, setLoading] = useState(true);
27413
27641
  const [error, setError] = useState(null);
27414
27642
  useMemo(() => {
27415
- const processLineData = (hookData, defaultName) => {
27643
+ const processLineData = (hookData, lineId) => {
27416
27644
  const currentLineInfo = hookData.lineData;
27417
27645
  let last5HoursData = [];
27418
27646
  if (currentLineInfo && currentLineInfo.metrics && currentLineInfo.metrics.output_array && currentLineInfo.metrics.output_array.length > 0) {
@@ -27433,6 +27661,7 @@ var FactoryView = ({
27433
27661
  }
27434
27662
  }
27435
27663
  }
27664
+ const defaultName = lineNames[lineId] || `Line ${lineId.substring(0, 8)}`;
27436
27665
  return {
27437
27666
  name: currentLineInfo?.line_name || defaultName,
27438
27667
  metrics: currentLineInfo,
@@ -27441,11 +27670,8 @@ var FactoryView = ({
27441
27670
  last5Hours: last5HoursData.slice(-5)
27442
27671
  };
27443
27672
  };
27444
- return [
27445
- processLineData(line1DataHook, "Line 1"),
27446
- processLineData(line2DataHook, "Line 2")
27447
- ];
27448
- }, [line1DataHook, line2DataHook]);
27673
+ return lineDataHooks.map(({ lineId, hook }) => processLineData(hook, lineId));
27674
+ }, [lineDataHooks, lineNames]);
27449
27675
  useEffect(() => {
27450
27676
  const fetchHourlyData = async () => {
27451
27677
  try {
@@ -27456,45 +27682,37 @@ var FactoryView = ({
27456
27682
  }
27457
27683
  const { shiftId } = getCurrentShift(timezone, shiftConfig);
27458
27684
  const date = getOperationalDate();
27459
- const { data: hourlyDataLine1, error: errorL1 } = await supabase.from("line_hourly_metrics").select("hour, efficiency").eq("line_id", line1Id).eq("shift_id", shiftId).eq("date", date).order("hour", { ascending: false }).limit(5);
27460
- if (errorL1) throw errorL1;
27461
- const { data: hourlyDataLine2, error: errorL2 } = await supabase.from("line_hourly_metrics").select("hour, efficiency").eq("line_id", line2Id).eq("shift_id", shiftId).eq("date", date).order("hour", { ascending: false }).limit(5);
27462
- if (errorL2) throw errorL2;
27463
- const linesData = [];
27464
- if (line1DataHook.lineData && line1DataHook.lineData.metrics && line1DataHook.lineData.metrics.output_array) {
27465
- linesData.push({
27466
- details: {
27467
- id: line1Id,
27468
- line_name: line1DataHook.lineData.line_name || "Line 1",
27469
- factory_id: line1DataHook.lineData.factory_id || "",
27470
- factory_name: line1DataHook.lineData.factory_name || "Factory 1"
27471
- },
27472
- current_output: line1DataHook.lineData.metrics.current_output || 0,
27473
- ideal_output: line1DataHook.lineData.metrics.ideal_output || 0,
27474
- avg_efficiency: line1DataHook.lineData.metrics.avg_efficiency || 0,
27475
- total_workspaces: line1DataHook.lineData.metrics.total_workspaces || 0,
27476
- underperforming_workspaces: line1DataHook.lineData.metrics.underperforming_workspaces || 0,
27477
- last5Hours: (hourlyDataLine1 || []).map((h) => ({ hour: h.hour, efficiency: h.efficiency })).reverse(),
27478
- productId: productIds[line1Id] || "Product A"
27479
- });
27480
- }
27481
- if (line2DataHook.lineData && line2DataHook.lineData.metrics && line2DataHook.lineData.metrics.output_array) {
27482
- linesData.push({
27483
- details: {
27484
- id: line2Id,
27485
- line_name: line2DataHook.lineData.line_name || "Line 2",
27486
- factory_id: line2DataHook.lineData.factory_id || "",
27487
- factory_name: line2DataHook.lineData.factory_name || "Factory 2"
27488
- },
27489
- current_output: line2DataHook.lineData.metrics.current_output || 0,
27490
- ideal_output: line2DataHook.lineData.metrics.ideal_output || 0,
27491
- avg_efficiency: line2DataHook.lineData.metrics.avg_efficiency || 0,
27492
- total_workspaces: line2DataHook.lineData.metrics.total_workspaces || 0,
27493
- underperforming_workspaces: line2DataHook.lineData.metrics.underperforming_workspaces || 0,
27494
- last5Hours: (hourlyDataLine2 || []).map((h) => ({ hour: h.hour, efficiency: h.efficiency })).reverse(),
27495
- productId: productIds[line2Id] || "Product B"
27496
- });
27685
+ const hourlyDataPromises = effectiveLineIds.map(
27686
+ (lineId) => supabase.from("line_hourly_metrics").select("hour, efficiency").eq("line_id", lineId).eq("shift_id", shiftId).eq("date", date).order("hour", { ascending: false }).limit(5)
27687
+ );
27688
+ const hourlyDataResults = await Promise.all(hourlyDataPromises);
27689
+ for (let i = 0; i < hourlyDataResults.length; i++) {
27690
+ if (hourlyDataResults[i].error) {
27691
+ throw hourlyDataResults[i].error;
27692
+ }
27497
27693
  }
27694
+ const linesData = [];
27695
+ lineDataHooks.forEach(({ lineId, hook }, index) => {
27696
+ const lineData = hook.lineData;
27697
+ const hourlyData = hourlyDataResults[index].data;
27698
+ if (lineData && lineData.metrics && lineData.metrics.output_array) {
27699
+ linesData.push({
27700
+ details: {
27701
+ id: lineId,
27702
+ line_name: lineData.line_name || lineNames[lineId] || `Line ${index + 1}`,
27703
+ factory_id: lineData.factory_id || "",
27704
+ factory_name: lineData.factory_name || factoryName
27705
+ },
27706
+ current_output: lineData.metrics.current_output || 0,
27707
+ ideal_output: lineData.metrics.ideal_output || 0,
27708
+ avg_efficiency: lineData.metrics.avg_efficiency || 0,
27709
+ total_workspaces: lineData.metrics.total_workspaces || 0,
27710
+ underperforming_workspaces: lineData.metrics.underperforming_workspaces || 0,
27711
+ last5Hours: (hourlyData || []).map((h) => ({ hour: h.hour, efficiency: h.efficiency })).reverse(),
27712
+ productId: productIds[lineId] || `Product ${String.fromCharCode(65 + index)}`
27713
+ });
27714
+ }
27715
+ });
27498
27716
  setLines(linesData);
27499
27717
  setLoading(false);
27500
27718
  } catch (err) {
@@ -27503,10 +27721,11 @@ var FactoryView = ({
27503
27721
  setLoading(false);
27504
27722
  }
27505
27723
  };
27506
- if (!line1DataHook.loading && !line2DataHook.loading) {
27724
+ const allHooksLoaded = lineDataHooks.every(({ hook }) => !hook.loading);
27725
+ if (allHooksLoaded) {
27507
27726
  fetchHourlyData();
27508
27727
  }
27509
- }, [supabase, line1DataHook, line2DataHook, line1Id, line2Id, timezone, shiftConfig, productIds]);
27728
+ }, [supabase, lineDataHooks, effectiveLineIds, lineNames, factoryName, timezone, shiftConfig, productIds]);
27510
27729
  const getShiftName = () => {
27511
27730
  const now2 = /* @__PURE__ */ new Date();
27512
27731
  const currentHour = now2.getHours();
@@ -27520,7 +27739,7 @@ var FactoryView = ({
27520
27739
  return /* @__PURE__ */ jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ 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" }) });
27521
27740
  }
27522
27741
  };
27523
- if (loading || line1DataHook.loading || line2DataHook.loading) {
27742
+ if (loading || lineDataHooks.some((hookData) => hookData.hook.loading)) {
27524
27743
  return /* @__PURE__ */ jsx("div", { className: "p-4", children: /* @__PURE__ */ jsxs("div", { className: "animate-pulse space-y-4", children: [
27525
27744
  /* @__PURE__ */ jsx("div", { className: "h-12 bg-gray-200 rounded" }),
27526
27745
  /* @__PURE__ */ jsx("div", { className: "h-12 bg-gray-200 rounded" })
@@ -28270,6 +28489,7 @@ var HelpView = ({
28270
28489
  var AuthenticatedHelpView = withAuth(HelpView);
28271
28490
  var HelpView_default = HelpView;
28272
28491
  var KPISection2 = KPISection;
28492
+ var LoadingPageCmp = LoadingPage_default;
28273
28493
  function HomeView({
28274
28494
  defaultLineId,
28275
28495
  factoryViewId,
@@ -28409,53 +28629,7 @@ function HomeView({
28409
28629
  const isInitialLoading = !isHydrated || !displayNamesInitialized && displayNamesLoading;
28410
28630
  const isDataLoading = metricsLoading || kpisLoading;
28411
28631
  if (isInitialLoading) {
28412
- return /* @__PURE__ */ jsx("div", { className: "min-h-screen bg-gradient-to-br from-slate-50 via-blue-50 to-slate-50 flex items-center justify-center", children: /* @__PURE__ */ jsx(
28413
- motion.div,
28414
- {
28415
- className: "text-center",
28416
- initial: { opacity: 0, scale: 0.9 },
28417
- animate: { opacity: 1, scale: 1 },
28418
- transition: { duration: 0.5 },
28419
- children: /* @__PURE__ */ jsxs("div", { className: "bg-white rounded-2xl shadow-2xl p-12 max-w-md mx-auto", children: [
28420
- /* @__PURE__ */ jsx("div", { className: "relative mb-8", children: /* @__PURE__ */ jsxs("div", { className: "w-24 h-24 mx-auto", children: [
28421
- /* @__PURE__ */ jsxs("svg", { className: "animate-spin", viewBox: "0 0 100 100", xmlns: "http://www.w3.org/2000/svg", children: [
28422
- /* @__PURE__ */ jsx("circle", { cx: "50", cy: "50", r: "45", fill: "none", stroke: "#e5e7eb", strokeWidth: "8" }),
28423
- /* @__PURE__ */ jsx(
28424
- "circle",
28425
- {
28426
- cx: "50",
28427
- cy: "50",
28428
- r: "45",
28429
- fill: "none",
28430
- stroke: "#3b82f6",
28431
- strokeWidth: "8",
28432
- strokeDasharray: "150 283",
28433
- strokeLinecap: "round",
28434
- className: "transform -rotate-90 origin-center"
28435
- }
28436
- )
28437
- ] }),
28438
- /* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ jsx("div", { className: "w-16 h-16 bg-gradient-to-br from-blue-500 to-blue-600 rounded-full animate-pulse" }) })
28439
- ] }) }),
28440
- /* @__PURE__ */ jsx("h2", { className: "text-2xl font-bold text-gray-800 mb-2", children: "Loading Dashboard" }),
28441
- /* @__PURE__ */ jsx("p", { className: "text-gray-600 mb-6", children: "Initializing your workspace..." }),
28442
- /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
28443
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center space-x-2 text-sm text-gray-500", children: [
28444
- /* @__PURE__ */ jsx("div", { className: "w-2 h-2 bg-blue-500 rounded-full animate-pulse" }),
28445
- /* @__PURE__ */ jsx("span", { children: "Connecting to services" })
28446
- ] }),
28447
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center space-x-2 text-sm text-gray-500", children: [
28448
- /* @__PURE__ */ jsx("div", { className: "w-2 h-2 bg-blue-500 rounded-full animate-pulse", style: { animationDelay: "0.2s" } }),
28449
- /* @__PURE__ */ jsx("span", { children: "Loading workspace configurations" })
28450
- ] }),
28451
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center space-x-2 text-sm text-gray-500", children: [
28452
- /* @__PURE__ */ jsx("div", { className: "w-2 h-2 bg-blue-500 rounded-full animate-pulse", style: { animationDelay: "0.4s" } }),
28453
- /* @__PURE__ */ jsx("span", { children: "Preparing dashboard view" })
28454
- ] })
28455
- ] })
28456
- ] })
28457
- }
28458
- ) });
28632
+ return /* @__PURE__ */ jsx(LoadingPageCmp, { message: "Loading Dashboard..." });
28459
28633
  }
28460
28634
  if (errorMessage || displayNamesError) {
28461
28635
  return /* @__PURE__ */ jsx("div", { className: "flex h-screen items-center justify-center", children: /* @__PURE__ */ jsx("div", { className: "rounded-lg bg-white p-6 shadow-lg", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-3 text-red-500", children: [
@@ -33932,4 +34106,4 @@ var S3Service = class {
33932
34106
  }
33933
34107
  };
33934
34108
 
33935
- export { ACTION_NAMES, AIAgentView_default as AIAgentView, AuthCallback, AuthCallbackView_default as AuthCallbackView, AuthProvider, AuthenticatedFactoryView, AuthenticatedHelpView, AuthenticatedHomeView, AuthenticatedTargetsView, BarChart, BaseHistoryCalendar, BottlenecksContent, BreakNotificationPopup, Card2 as Card, CardContent2 as CardContent, CardDescription2 as CardDescription, CardFooter2 as CardFooter, CardHeader2 as CardHeader, CardTitle2 as CardTitle, CycleTimeChart, CycleTimeOverTimeChart, DEFAULT_ANALYTICS_CONFIG, DEFAULT_AUTH_CONFIG, DEFAULT_CONFIG, DEFAULT_DATABASE_CONFIG, DEFAULT_DATE_TIME_CONFIG, DEFAULT_ENDPOINTS_CONFIG, DEFAULT_ENTITY_CONFIG, DEFAULT_SHIFT_CONFIG, DEFAULT_THEME_CONFIG, DEFAULT_VIDEO_CONFIG, DEFAULT_WORKSPACE_CONFIG, DEFAULT_WORKSPACE_POSITIONS, DashboardHeader, DashboardLayout, DashboardOverridesProvider, DashboardProvider, DateDisplay_default as DateDisplay, DateTimeDisplay, DebugAuth, DebugAuthView_default as DebugAuthView, EmptyStateMessage, FactoryView_default as FactoryView, GaugeChart, GridComponentsPlaceholder, Header, HelpView_default as HelpView, HomeView_default as HomeView, HourlyOutputChart2 as HourlyOutputChart, ISTTimer_default as ISTTimer, KPICard, KPIDetailView_default as KPIDetailView, KPIGrid, KPIHeader, KPISection, KPIsOverviewView_default as KPIsOverviewView, LINE_1_UUID, LINE_2_UUID, LargeOutputProgressChart, LeaderboardDetailView_default as LeaderboardDetailView, Legend6 as Legend, LineChart, LineHistoryCalendar, LineMonthlyHistory, LineMonthlyPdfGenerator, LinePdfExportButton, LinePdfGenerator, LineWhatsAppShareButton, LiveTimer, LoadingInline, LoadingOverlay_default as LoadingOverlay, LoadingPage_default as LoadingPage, LoadingSkeleton, LoadingSpinner_default as LoadingSpinner, LoadingState, LoginPage, LoginView_default as LoginView, MainLayout, MetricCard_default as MetricCard, NoWorkspaceData, OptifyeAgentClient, OutputProgressChart, PageHeader, PieChart4 as PieChart, ProfileView_default as ProfileView, RegistryProvider, S3Service, SKUManagementView, SOPComplianceChart, SSEChatClient, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, ShiftDisplay_default as ShiftDisplay, ShiftsView_default as ShiftsView, SideNavBar, SingleVideoStream_default as SingleVideoStream, Skeleton, SlackAPI, SubscriptionManager, SubscriptionManagerProvider, SupabaseProvider, TargetWorkspaceGrid, TargetsView_default as TargetsView, ThreadSidebar, TimeDisplay_default as TimeDisplay, TimePickerDropdown, VideoCard, VideoGridView, VideoPreloader, WORKSPACE_POSITIONS, WhatsAppShareButton, WorkspaceCard, WorkspaceDetailView_default as WorkspaceDetailView, WorkspaceDisplayNameExample, WorkspaceGrid, WorkspaceGridItem, WorkspaceHistoryCalendar, WorkspaceMetricCards, WorkspaceMonthlyDataFetcher, WorkspaceMonthlyPdfGenerator, WorkspacePdfExportButton, WorkspacePdfGenerator, WorkspaceWhatsAppShareButton, actionService, apiUtils, authCoreService, authOTPService, authRateLimitService, cacheService, checkRateLimit2 as checkRateLimit, clearAllRateLimits2 as clearAllRateLimits, clearRateLimit2 as clearRateLimit, clearS3VideoCache, clearS3VideoFromCache, clearWorkspaceDisplayNamesCache, cn, createStreamProxyHandler, createSupabaseClient, createThrottledReload, dashboardService, deleteThread, forceRefreshWorkspaceDisplayNames, formatDateInZone, formatDateTimeInZone, formatISTDate, formatIdleTime, formatTimeInZone, fromUrlFriendlyName, getAllThreadMessages, getAllWorkspaceDisplayNamesAsync, getAnonClient, getCameraNumber, getCompanyMetricsTableName, getConfigurableShortWorkspaceDisplayName, getConfigurableWorkspaceDisplayName, getCurrentShift, getCurrentTimeInZone, getDashboardHeaderTimeInZone, getDaysDifferenceInZone, getDefaultCameraStreamUrl, getDefaultTabForWorkspace, getManufacturingInsights, getMetricsTablePrefix, getOperationalDate, getS3SignedUrl, getS3VideoSrc, getShortWorkspaceDisplayName, getShortWorkspaceDisplayNameAsync, getStoredWorkspaceMappings, getSubscriptionManager, getThreadMessages, getUserThreads, getUserThreadsPaginated, getWorkspaceDisplayName, getWorkspaceDisplayNameAsync, getWorkspaceDisplayNamesMap, getWorkspaceFromUrl, getWorkspaceNavigationParams, identifyCoreUser, initializeCoreMixpanel, isTransitionPeriod, isValidLineInfoPayload, isValidWorkspaceDetailedMetricsPayload, isValidWorkspaceMetricsPayload, isWorkspaceDisplayNamesLoaded, isWorkspaceDisplayNamesLoading, mergeWithDefaultConfig, optifyeAgentClient, preInitializeWorkspaceDisplayNames, preloadS3Video, preloadS3VideoUrl, preloadS3VideosUrl, preloadVideoUrl, preloadVideosUrl, qualityService, realtimeService, refreshWorkspaceDisplayNames, resetCoreMixpanel, resetSubscriptionManager, s3VideoPreloader, skuService, storeWorkspaceMapping, streamProxyConfig, throttledReloadDashboard, toUrlFriendlyName, trackCoreEvent, trackCorePageView, updateThreadTitle, useActiveBreaks, useAllWorkspaceMetrics, useAnalyticsConfig, useAuth, useAuthConfig, useComponentOverride, useCustomConfig, useDashboardConfig, useDashboardMetrics, useDatabaseConfig, useDateFormatter, useDateTimeConfig, useEndpointsConfig, useEntityConfig, useFactoryOverviewMetrics, useFeatureFlags, useFormatNumber, useHistoricWorkspaceMetrics, useHlsStream, useHlsStreamWithCropping, useHookOverride, useLeaderboardMetrics, useLineDetailedMetrics, useLineKPIs, useLineMetrics, useLineWorkspaceMetrics, useMessages, useMetrics, useNavigation, useOverrides, usePageOverride, useRealtimeLineMetrics, useRegistry, useSKUs, useShiftConfig, useShifts, useSubscriptionManager, useSubscriptionManagerSafe, useSupabase, useSupabaseClient, useTargets, useTheme, useThemeConfig, useThreads, useVideoConfig, useWorkspaceConfig, useWorkspaceDetailedMetrics, useWorkspaceDisplayName, useWorkspaceDisplayNames, useWorkspaceDisplayNamesMap, useWorkspaceMetrics, useWorkspaceNavigation, useWorkspaceOperators, videoPreloader, whatsappService, withAuth, withRegistry, workspaceService };
34109
+ export { ACTION_NAMES, AIAgentView_default as AIAgentView, AuthCallback, AuthCallbackView_default as AuthCallbackView, AuthProvider, AuthenticatedFactoryView, AuthenticatedHelpView, AuthenticatedHomeView, AuthenticatedTargetsView, BarChart, BaseHistoryCalendar, BottlenecksContent, BreakNotificationPopup, Card2 as Card, CardContent2 as CardContent, CardDescription2 as CardDescription, CardFooter2 as CardFooter, CardHeader2 as CardHeader, CardTitle2 as CardTitle, CycleTimeChart, CycleTimeOverTimeChart, DEFAULT_ANALYTICS_CONFIG, DEFAULT_AUTH_CONFIG, DEFAULT_CONFIG, DEFAULT_DATABASE_CONFIG, DEFAULT_DATE_TIME_CONFIG, DEFAULT_ENDPOINTS_CONFIG, DEFAULT_ENTITY_CONFIG, DEFAULT_SHIFT_CONFIG, DEFAULT_THEME_CONFIG, DEFAULT_VIDEO_CONFIG, DEFAULT_WORKSPACE_CONFIG, DEFAULT_WORKSPACE_POSITIONS, DashboardHeader, DashboardLayout, DashboardOverridesProvider, DashboardProvider, DateDisplay_default as DateDisplay, DateTimeDisplay, DebugAuth, DebugAuthView_default as DebugAuthView, EmptyStateMessage, FactoryView_default as FactoryView, GaugeChart, GridComponentsPlaceholder, Header, HelpView_default as HelpView, HomeView_default as HomeView, HourlyOutputChart2 as HourlyOutputChart, ISTTimer_default as ISTTimer, KPICard, KPIDetailView_default as KPIDetailView, KPIGrid, KPIHeader, KPISection, KPIsOverviewView_default as KPIsOverviewView, LINE_1_UUID, LINE_2_UUID, LargeOutputProgressChart, LeaderboardDetailView_default as LeaderboardDetailView, Legend6 as Legend, LineChart, LineHistoryCalendar, LineMonthlyHistory, LineMonthlyPdfGenerator, LinePdfExportButton, LinePdfGenerator, LineWhatsAppShareButton, LiveTimer, LoadingInline, LoadingOverlay_default as LoadingOverlay, LoadingPage_default as LoadingPage, LoadingSkeleton, LoadingSpinner_default as LoadingSpinner, LoadingState, LoginPage, LoginView_default as LoginView, MainLayout, MetricCard_default as MetricCard, NoWorkspaceData, OptifyeAgentClient, OutputProgressChart, PageHeader, PieChart4 as PieChart, ProfileView_default as ProfileView, RegistryProvider, S3Service, SKUManagementView, SOPComplianceChart, SSEChatClient, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, ShiftDisplay_default as ShiftDisplay, ShiftsView_default as ShiftsView, SideNavBar, SingleVideoStream_default as SingleVideoStream, Skeleton, SlackAPI, SubscriptionManager, SubscriptionManagerProvider, SupabaseProvider, TargetWorkspaceGrid, TargetsView_default as TargetsView, ThreadSidebar, TimeDisplay_default as TimeDisplay, TimePickerDropdown, VideoCard, VideoGridView, VideoPreloader, WORKSPACE_POSITIONS, WhatsAppShareButton, WorkspaceCard, WorkspaceDetailView_default as WorkspaceDetailView, WorkspaceDisplayNameExample, WorkspaceGrid, WorkspaceGridItem, WorkspaceHistoryCalendar, WorkspaceMetricCards, WorkspaceMonthlyDataFetcher, WorkspaceMonthlyPdfGenerator, WorkspacePdfExportButton, WorkspacePdfGenerator, WorkspaceWhatsAppShareButton, actionService, apiUtils, authCoreService, authOTPService, authRateLimitService, cacheService, checkRateLimit2 as checkRateLimit, clearAllRateLimits2 as clearAllRateLimits, clearRateLimit2 as clearRateLimit, clearS3VideoCache, clearS3VideoFromCache, clearWorkspaceDisplayNamesCache, cn, createStreamProxyHandler, createSupabaseClient, createThrottledReload, dashboardService, deleteThread, forceRefreshWorkspaceDisplayNames, formatDateInZone, formatDateTimeInZone, formatISTDate, formatIdleTime, formatTimeInZone, fromUrlFriendlyName, getAllLineDisplayNames, getAllThreadMessages, getAllWorkspaceDisplayNamesAsync, getAnonClient, getCameraNumber, getCompanyMetricsTableName, getConfigurableShortWorkspaceDisplayName, getConfigurableWorkspaceDisplayName, getConfiguredLineIds, getCoreSessionRecordingProperties, getCoreSessionReplayUrl, getCurrentShift, getCurrentTimeInZone, getDashboardHeaderTimeInZone, getDaysDifferenceInZone, getDefaultCameraStreamUrl, getDefaultLineId, getDefaultTabForWorkspace, getLineDisplayName, getManufacturingInsights, getMetricsTablePrefix, getOperationalDate, getS3SignedUrl, getS3VideoSrc, getShortWorkspaceDisplayName, getShortWorkspaceDisplayNameAsync, getStoredWorkspaceMappings, getSubscriptionManager, getThreadMessages, getUserThreads, getUserThreadsPaginated, getWorkspaceDisplayName, getWorkspaceDisplayNameAsync, getWorkspaceDisplayNamesMap, getWorkspaceFromUrl, getWorkspaceNavigationParams, identifyCoreUser, initializeCoreMixpanel, isLegacyConfiguration, isTransitionPeriod, isValidFactoryViewConfiguration, isValidLineInfoPayload, isValidWorkspaceDetailedMetricsPayload, isValidWorkspaceMetricsPayload, isWorkspaceDisplayNamesLoaded, isWorkspaceDisplayNamesLoading, mergeWithDefaultConfig, migrateLegacyConfiguration, optifyeAgentClient, preInitializeWorkspaceDisplayNames, preloadS3Video, preloadS3VideoUrl, preloadS3VideosUrl, preloadVideoUrl, preloadVideosUrl, qualityService, realtimeService, refreshWorkspaceDisplayNames, resetCoreMixpanel, resetSubscriptionManager, s3VideoPreloader, skuService, startCoreSessionRecording, stopCoreSessionRecording, storeWorkspaceMapping, streamProxyConfig, throttledReloadDashboard, toUrlFriendlyName, trackCoreEvent, trackCorePageView, updateThreadTitle, useActiveBreaks, useAllWorkspaceMetrics, useAnalyticsConfig, useAuth, useAuthConfig, useComponentOverride, useCustomConfig, useDashboardConfig, useDashboardMetrics, useDatabaseConfig, useDateFormatter, useDateTimeConfig, useEndpointsConfig, useEntityConfig, useFactoryOverviewMetrics, useFeatureFlags, useFormatNumber, useHistoricWorkspaceMetrics, useHlsStream, useHlsStreamWithCropping, useHookOverride, useLeaderboardMetrics, useLineDetailedMetrics, useLineKPIs, useLineMetrics, useLineWorkspaceMetrics, useMessages, useMetrics, useNavigation, useOverrides, usePageOverride, useRealtimeLineMetrics, useRegistry, useSKUs, useShiftConfig, useShifts, useSubscriptionManager, useSubscriptionManagerSafe, useSupabase, useSupabaseClient, useTargets, useTheme, useThemeConfig, useThreads, useVideoConfig, useWorkspaceConfig, useWorkspaceDetailedMetrics, useWorkspaceDisplayName, useWorkspaceDisplayNames, useWorkspaceDisplayNamesMap, useWorkspaceMetrics, useWorkspaceNavigation, useWorkspaceOperators, videoPreloader, whatsappService, withAuth, withRegistry, workspaceService };