@optifye/dashboard-core 4.2.9 → 4.3.3

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
@@ -2080,28 +2080,42 @@ var AuthProvider = ({ children }) => {
2080
2080
  id: supabaseUser.id,
2081
2081
  email: supabaseUser.email
2082
2082
  };
2083
- if (!userProfileTable || !supabase) return basicUser;
2083
+ if (!supabase) return basicUser;
2084
2084
  try {
2085
2085
  const timeoutPromise = new Promise(
2086
2086
  (_, reject) => setTimeout(() => reject(new Error("Profile fetch timeout")), 5e3)
2087
2087
  );
2088
- const fetchPromise = supabase.from(userProfileTable).select(roleColumn).eq("id", supabaseUser.id).single();
2089
- const { data: profile, error: profileError } = await Promise.race([
2090
- fetchPromise,
2091
- timeoutPromise
2088
+ const rolePromise = supabase.from("user_roles").select("role_level").eq("user_id", supabaseUser.id).single();
2089
+ let profilePromise = null;
2090
+ if (userProfileTable) {
2091
+ profilePromise = supabase.from(userProfileTable).select(roleColumn).eq("id", supabaseUser.id).single();
2092
+ }
2093
+ const [roleResult, profileResult] = await Promise.race([
2094
+ Promise.all([
2095
+ rolePromise,
2096
+ profilePromise || Promise.resolve(null)
2097
+ ]),
2098
+ timeoutPromise.then(() => {
2099
+ throw new Error("Timeout");
2100
+ })
2092
2101
  ]);
2093
- if (profileError) {
2094
- if (profileError.message.includes("does not exist") || profileError.message.includes("No rows found") || profileError.code === "PGRST116") {
2095
- console.log("User profile table not found or user not in table, using basic auth info");
2096
- return basicUser;
2097
- }
2098
- console.error("Error fetching user profile:", profileError);
2099
- return basicUser;
2102
+ let roleLevel = void 0;
2103
+ if (roleResult && !roleResult.error && roleResult.data) {
2104
+ roleLevel = roleResult.data.role_level;
2105
+ } else if (roleResult?.error) {
2106
+ console.log("Error fetching role_level:", roleResult.error.message);
2100
2107
  }
2101
- const roleValue = profile ? profile[roleColumn] : void 0;
2102
- return { ...basicUser, role: roleValue };
2108
+ let roleValue = void 0;
2109
+ if (profileResult && !profileResult.error && profileResult.data) {
2110
+ roleValue = profileResult.data[roleColumn];
2111
+ }
2112
+ return {
2113
+ ...basicUser,
2114
+ role: roleValue,
2115
+ role_level: roleLevel
2116
+ };
2103
2117
  } catch (err) {
2104
- console.error("Error fetching user profile:", err);
2118
+ console.error("Error fetching user details:", err);
2105
2119
  return basicUser;
2106
2120
  }
2107
2121
  }, [supabase, userProfileTable, roleColumn]);
@@ -2136,7 +2150,8 @@ var AuthProvider = ({ children }) => {
2136
2150
  email: userDetails.email,
2137
2151
  name: userDetails.email,
2138
2152
  // using email as the display name for now
2139
- role: userDetails.role
2153
+ role: userDetails.role,
2154
+ role_level: userDetails.role_level
2140
2155
  });
2141
2156
  }
2142
2157
  }
@@ -2174,7 +2189,8 @@ var AuthProvider = ({ children }) => {
2174
2189
  identifyCoreUser(userDetails.id, {
2175
2190
  email: userDetails.email,
2176
2191
  name: userDetails.email,
2177
- role: userDetails.role
2192
+ role: userDetails.role,
2193
+ role_level: userDetails.role_level
2178
2194
  });
2179
2195
  }
2180
2196
  }
@@ -17960,6 +17976,187 @@ var SOPComplianceChart = ({
17960
17976
  renderLegend()
17961
17977
  ] });
17962
17978
  };
17979
+ var GaugeChart = ({
17980
+ value,
17981
+ min,
17982
+ max,
17983
+ target,
17984
+ label,
17985
+ unit = "",
17986
+ thresholds,
17987
+ className = ""
17988
+ }) => {
17989
+ const normalizedValue = (value - min) / (max - min) * 100;
17990
+ const clampedValue = Math.max(0, Math.min(100, normalizedValue));
17991
+ const data = [
17992
+ { name: "value", value: clampedValue },
17993
+ { name: "empty", value: 100 - clampedValue }
17994
+ ];
17995
+ const getColor = () => {
17996
+ if (thresholds && thresholds.length > 0) {
17997
+ const sortedThresholds = [...thresholds].sort((a, b) => a.value - b.value);
17998
+ for (let i = sortedThresholds.length - 1; i >= 0; i--) {
17999
+ if (value >= sortedThresholds[i].value) {
18000
+ return sortedThresholds[i].color;
18001
+ }
18002
+ }
18003
+ return sortedThresholds[0].color;
18004
+ }
18005
+ if (clampedValue < 33) return "#ef4444";
18006
+ if (clampedValue < 66) return "#f59e0b";
18007
+ return "#10b981";
18008
+ };
18009
+ const gaugeColor = getColor();
18010
+ const targetAngle = target !== void 0 ? 180 - (target - min) / (max - min) * 180 : null;
18011
+ return /* @__PURE__ */ jsx("div", { className: `relative w-full h-full flex flex-col items-center justify-center ${className}`, children: /* @__PURE__ */ jsxs("div", { className: "relative w-full max-w-[280px] aspect-square", children: [
18012
+ /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsx(PieChart, { children: /* @__PURE__ */ jsxs(
18013
+ Pie,
18014
+ {
18015
+ data,
18016
+ cx: "50%",
18017
+ cy: "50%",
18018
+ startAngle: 180,
18019
+ endAngle: 0,
18020
+ innerRadius: "65%",
18021
+ outerRadius: "85%",
18022
+ paddingAngle: 0,
18023
+ dataKey: "value",
18024
+ animationBegin: 0,
18025
+ animationDuration: 1e3,
18026
+ animationEasing: "ease-out",
18027
+ children: [
18028
+ /* @__PURE__ */ jsx(Cell, { fill: gaugeColor }),
18029
+ /* @__PURE__ */ jsx(Cell, { fill: "#f3f4f6" })
18030
+ ]
18031
+ }
18032
+ ) }) }),
18033
+ targetAngle !== null && /* @__PURE__ */ jsx(
18034
+ "div",
18035
+ {
18036
+ className: "absolute top-1/2 left-1/2 w-1 h-[42%] bg-gray-800 origin-bottom",
18037
+ style: {
18038
+ transform: `translate(-50%, -100%) rotate(${targetAngle}deg)`,
18039
+ transition: "transform 0.3s ease-out"
18040
+ },
18041
+ children: /* @__PURE__ */ jsx("div", { className: "absolute -top-1 -left-1.5 w-3 h-3 bg-gray-800 rounded-full" })
18042
+ }
18043
+ ),
18044
+ /* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex flex-col items-center justify-center", children: /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
18045
+ /* @__PURE__ */ jsxs("div", { className: "text-3xl font-bold text-gray-800", children: [
18046
+ value.toFixed(unit === "%" ? 1 : 0),
18047
+ unit
18048
+ ] }),
18049
+ /* @__PURE__ */ jsx("div", { className: "text-sm text-gray-600 mt-1 font-medium", children: label }),
18050
+ target !== void 0 && /* @__PURE__ */ jsxs("div", { className: "text-xs text-gray-500 mt-1", children: [
18051
+ "Target: ",
18052
+ target,
18053
+ unit
18054
+ ] })
18055
+ ] }) }),
18056
+ /* @__PURE__ */ jsxs("div", { className: "absolute bottom-[15%] left-[15%] text-xs text-gray-500", children: [
18057
+ min,
18058
+ unit
18059
+ ] }),
18060
+ /* @__PURE__ */ jsxs("div", { className: "absolute bottom-[15%] right-[15%] text-xs text-gray-500", children: [
18061
+ max,
18062
+ unit
18063
+ ] })
18064
+ ] }) });
18065
+ };
18066
+ var DEFAULT_COLORS = [
18067
+ "#3b82f6",
18068
+ // blue-500
18069
+ "#10b981",
18070
+ // green-500
18071
+ "#f59e0b",
18072
+ // amber-500
18073
+ "#ef4444",
18074
+ // red-500
18075
+ "#8b5cf6",
18076
+ // violet-500
18077
+ "#06b6d4",
18078
+ // cyan-500
18079
+ "#f97316",
18080
+ // orange-500
18081
+ "#6366f1"
18082
+ // indigo-500
18083
+ ];
18084
+ var PieChart4 = ({
18085
+ data,
18086
+ className = "",
18087
+ showPercentages = false,
18088
+ colors = DEFAULT_COLORS
18089
+ }) => {
18090
+ const total = data.reduce((sum, entry) => sum + entry.value, 0);
18091
+ const dataWithPercentage = data.map((entry) => ({
18092
+ ...entry,
18093
+ percentage: (entry.value / total * 100).toFixed(1)
18094
+ }));
18095
+ const renderCustomLabel = (props) => {
18096
+ if (!showPercentages) return null;
18097
+ const { cx: cx2, cy, midAngle, innerRadius, outerRadius, percentage } = props;
18098
+ const RADIAN = Math.PI / 180;
18099
+ const radius = innerRadius + (outerRadius - innerRadius) * 0.5;
18100
+ const x = cx2 + radius * Math.cos(-midAngle * RADIAN);
18101
+ const y = cy + radius * Math.sin(-midAngle * RADIAN);
18102
+ return /* @__PURE__ */ jsxs(
18103
+ "text",
18104
+ {
18105
+ x,
18106
+ y,
18107
+ fill: "white",
18108
+ textAnchor: x > cx2 ? "start" : "end",
18109
+ dominantBaseline: "central",
18110
+ className: "text-xs font-medium",
18111
+ children: [
18112
+ percentage,
18113
+ "%"
18114
+ ]
18115
+ }
18116
+ );
18117
+ };
18118
+ const CustomTooltip = ({ active, payload }) => {
18119
+ if (active && payload && payload.length) {
18120
+ const data2 = payload[0];
18121
+ return /* @__PURE__ */ jsxs("div", { className: "bg-white px-3 py-2 shadow-lg rounded-lg border border-gray-200", children: [
18122
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-gray-900", children: data2.name }),
18123
+ /* @__PURE__ */ jsxs("p", { className: "text-sm text-gray-600", children: [
18124
+ "Value: ",
18125
+ data2.value,
18126
+ showPercentages && ` (${data2.payload.percentage}%)`
18127
+ ] })
18128
+ ] });
18129
+ }
18130
+ return null;
18131
+ };
18132
+ return /* @__PURE__ */ jsx("div", { className: `w-full h-full ${className}`, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(PieChart, { children: [
18133
+ /* @__PURE__ */ jsx(
18134
+ Pie,
18135
+ {
18136
+ data: dataWithPercentage,
18137
+ cx: "50%",
18138
+ cy: "50%",
18139
+ labelLine: false,
18140
+ label: showPercentages ? renderCustomLabel : void 0,
18141
+ outerRadius: "80%",
18142
+ fill: "#8884d8",
18143
+ dataKey: "value",
18144
+ animationBegin: 0,
18145
+ animationDuration: 800,
18146
+ children: dataWithPercentage.map((entry, index) => /* @__PURE__ */ jsx(Cell, { fill: colors[index % colors.length] }, `cell-${index}`))
18147
+ }
18148
+ ),
18149
+ /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(CustomTooltip, {}) }),
18150
+ /* @__PURE__ */ jsx(
18151
+ Legend,
18152
+ {
18153
+ verticalAlign: "bottom",
18154
+ height: 36,
18155
+ formatter: (value) => /* @__PURE__ */ jsx("span", { className: "text-sm", children: value })
18156
+ }
18157
+ )
18158
+ ] }) }) });
18159
+ };
17963
18160
  var TrendIcon = ({ trend }) => {
17964
18161
  if (trend === "up") {
17965
18162
  return /* @__PURE__ */ jsx(ArrowUp, { className: "h-4 w-4 text-green-500" });
@@ -22558,7 +22755,7 @@ var getWorkspaceStyles = (position, isPlaceholder = false) => {
22558
22755
  ${additionalStyles}
22559
22756
  ${isPlaceholder ? "cursor-default" : ""}`;
22560
22757
  };
22561
- var Legend5 = () => /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2 sm:gap-3 bg-white/95 rounded-lg shadow-sm px-2 sm:px-4 py-1 sm:py-1.5 border border-gray-200/60 backdrop-blur-sm text-xs sm:text-sm", children: [
22758
+ var Legend6 = () => /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2 sm:gap-3 bg-white/95 rounded-lg shadow-sm px-2 sm:px-4 py-1 sm:py-1.5 border border-gray-200/60 backdrop-blur-sm text-xs sm:text-sm", children: [
22562
22759
  /* @__PURE__ */ jsx("div", { className: "font-medium text-gray-700 hidden sm:block", children: "Efficiency:" }),
22563
22760
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 sm:gap-4", children: [
22564
22761
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 sm:gap-2", children: [
@@ -22696,8 +22893,8 @@ var WorkspaceGrid = React14__default.memo(({
22696
22893
  const { VideoGridView: VideoGridViewComponent } = useRegistry();
22697
22894
  return /* @__PURE__ */ jsxs("div", { className: `relative w-full h-full overflow-hidden ${className}`, children: [
22698
22895
  /* @__PURE__ */ jsxs("div", { className: "absolute top-0 left-2 sm:left-4 right-2 sm:right-8 z-20", children: [
22699
- /* @__PURE__ */ jsx("div", { className: "flex flex-row items-center justify-between py-1 sm:py-1.5 gap-2", children: /* @__PURE__ */ jsx("div", { className: "hidden sm:block", children: /* @__PURE__ */ jsx(Legend5, {}) }) }),
22700
- /* @__PURE__ */ jsx("div", { className: "sm:hidden mt-1", children: /* @__PURE__ */ jsx(Legend5, {}) })
22896
+ /* @__PURE__ */ jsx("div", { className: "flex flex-row items-center justify-between py-1 sm:py-1.5 gap-2", children: /* @__PURE__ */ jsx("div", { className: "hidden sm:block", children: /* @__PURE__ */ jsx(Legend6, {}) }) }),
22897
+ /* @__PURE__ */ jsx("div", { className: "sm:hidden mt-1", children: /* @__PURE__ */ jsx(Legend6, {}) })
22701
22898
  ] }),
22702
22899
  /* @__PURE__ */ jsx("div", { className: "absolute top-10 sm:top-16 left-0 right-0 bottom-0", children: /* @__PURE__ */ jsx(
22703
22900
  VideoGridViewComponent,
@@ -23300,6 +23497,78 @@ var WorkspaceMonthlyDataFetcher = ({
23300
23497
  }, [workspaceId, selectedMonth, selectedYear, supabase, onDataLoaded, onLoadingChange]);
23301
23498
  return null;
23302
23499
  };
23500
+ var WorkspaceDisplayNameExample = () => {
23501
+ const { displayNames, loading, error } = useWorkspaceDisplayNames();
23502
+ const { displayName: singleWorkspaceName, loading: singleLoading } = useWorkspaceDisplayName("WS01");
23503
+ const { displayNames: displayNamesMap, loading: mapLoading } = useWorkspaceDisplayNamesMap(["WS01", "WS02", "WS03"]);
23504
+ if (loading) {
23505
+ return /* @__PURE__ */ jsx("div", { className: "p-4", children: "Loading workspace display names..." });
23506
+ }
23507
+ if (error) {
23508
+ return /* @__PURE__ */ jsxs("div", { className: "p-4 text-red-600", children: [
23509
+ "Error loading workspace display names: ",
23510
+ error.message
23511
+ ] });
23512
+ }
23513
+ return /* @__PURE__ */ jsxs("div", { className: "p-6 max-w-4xl mx-auto", children: [
23514
+ /* @__PURE__ */ jsx("h2", { className: "text-2xl font-bold mb-6", children: "Workspace Display Names Examples" }),
23515
+ /* @__PURE__ */ jsxs("div", { className: "mb-8", children: [
23516
+ /* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold mb-4", children: "1. All Workspace Display Names" }),
23517
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4", children: Object.entries(displayNames).map(([workspaceId, displayName]) => /* @__PURE__ */ jsxs("div", { className: "p-3 border rounded-lg", children: [
23518
+ /* @__PURE__ */ jsx("div", { className: "font-medium", children: workspaceId }),
23519
+ /* @__PURE__ */ jsx("div", { className: "text-sm text-gray-600", children: displayName })
23520
+ ] }, workspaceId)) }),
23521
+ /* @__PURE__ */ jsx("div", { className: "mt-4 p-3 bg-gray-50 rounded-lg", children: /* @__PURE__ */ jsxs("p", { className: "text-sm", children: [
23522
+ /* @__PURE__ */ jsx("strong", { children: "Using utility function:" }),
23523
+ ` getWorkspaceDisplayName('WS01') = "`,
23524
+ getWorkspaceDisplayName("WS01"),
23525
+ '"'
23526
+ ] }) })
23527
+ ] }),
23528
+ /* @__PURE__ */ jsxs("div", { className: "mb-8", children: [
23529
+ /* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold mb-4", children: "2. Single Workspace Display Name" }),
23530
+ /* @__PURE__ */ jsx("div", { className: "p-3 border rounded-lg", children: singleLoading ? /* @__PURE__ */ jsx("div", { children: "Loading WS01..." }) : /* @__PURE__ */ jsxs("div", { children: [
23531
+ /* @__PURE__ */ jsx("strong", { children: "WS01:" }),
23532
+ " ",
23533
+ singleWorkspaceName
23534
+ ] }) })
23535
+ ] }),
23536
+ /* @__PURE__ */ jsxs("div", { className: "mb-8", children: [
23537
+ /* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold mb-4", children: "3. Specific Workspaces Map" }),
23538
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-4", children: mapLoading ? /* @__PURE__ */ jsx("div", { children: "Loading specific workspaces..." }) : Object.entries(displayNamesMap).map(([workspaceId, displayName]) => /* @__PURE__ */ jsxs("div", { className: "p-3 border rounded-lg", children: [
23539
+ /* @__PURE__ */ jsx("div", { className: "font-medium", children: workspaceId }),
23540
+ /* @__PURE__ */ jsx("div", { className: "text-sm text-gray-600", children: displayName })
23541
+ ] }, workspaceId)) })
23542
+ ] }),
23543
+ /* @__PURE__ */ jsxs("div", { className: "mt-8 p-4 bg-blue-50 rounded-lg", children: [
23544
+ /* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold mb-2", children: "Migration Guide" }),
23545
+ /* @__PURE__ */ jsxs("div", { className: "text-sm space-y-2", children: [
23546
+ /* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx("strong", { children: "Before (hardcoded):" }) }),
23547
+ /* @__PURE__ */ jsxs("code", { className: "block p-2 bg-gray-100 rounded", children: [
23548
+ "import ",
23549
+ `{getWorkspaceDisplayName}`,
23550
+ " from '@optifye/dashboard-core';",
23551
+ /* @__PURE__ */ jsx("br", {}),
23552
+ "const name = getWorkspaceDisplayName('WS01'); // Synchronous, hardcoded"
23553
+ ] }),
23554
+ /* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx("strong", { children: "After (from Supabase):" }) }),
23555
+ /* @__PURE__ */ jsxs("code", { className: "block p-2 bg-gray-100 rounded", children: [
23556
+ "import ",
23557
+ `{useWorkspaceDisplayName}`,
23558
+ " from '@optifye/dashboard-core';",
23559
+ /* @__PURE__ */ jsx("br", {}),
23560
+ "const ",
23561
+ `{displayName, loading}`,
23562
+ " = useWorkspaceDisplayName('WS01'); // Async, from database"
23563
+ ] }),
23564
+ /* @__PURE__ */ jsxs("p", { className: "text-blue-700", children: [
23565
+ /* @__PURE__ */ jsx("strong", { children: "Note:" }),
23566
+ " The old synchronous functions are still available as fallbacks and for backward compatibility."
23567
+ ] })
23568
+ ] })
23569
+ ] })
23570
+ ] });
23571
+ };
23303
23572
  var Breadcrumbs = ({ items }) => {
23304
23573
  const navigation = useNavigation();
23305
23574
  if (!items || items.length === 0) return null;
@@ -24745,6 +25014,234 @@ var AIAgentView = () => {
24745
25014
  });
24746
25015
  }
24747
25016
  const renderAssistantContent = (content) => {
25017
+ const parseChartPatterns = (text) => {
25018
+ const chartElements = [];
25019
+ let lastIndex = 0;
25020
+ const chartRegex = /\[\s*(?:Calling\s+|CALL\s+)?(create_[a-z_]+)\s*\(([\s\S]*?)\)\s*\]/g;
25021
+ let match;
25022
+ const processedIndices = /* @__PURE__ */ new Set();
25023
+ while ((match = chartRegex.exec(text)) !== null) {
25024
+ const startIndex = match.index;
25025
+ const endIndex = startIndex + match[0].length;
25026
+ if (!processedIndices.has(startIndex)) {
25027
+ processedIndices.add(startIndex);
25028
+ if (startIndex > lastIndex) {
25029
+ const beforeText = text.substring(lastIndex, startIndex);
25030
+ chartElements.push(
25031
+ /* @__PURE__ */ jsx(
25032
+ "div",
25033
+ {
25034
+ dangerouslySetInnerHTML: { __html: formatMessage(beforeText) }
25035
+ },
25036
+ `text-${lastIndex}`
25037
+ )
25038
+ );
25039
+ }
25040
+ const chartType = match[1];
25041
+ const argsString = match[2];
25042
+ try {
25043
+ const args = parseChartArguments(argsString);
25044
+ const chartElement = renderChart(chartType, args, startIndex);
25045
+ if (chartElement) {
25046
+ chartElements.push(chartElement);
25047
+ }
25048
+ } catch (error) {
25049
+ console.error(`Failed to parse chart ${chartType}:`, error);
25050
+ chartElements.push(
25051
+ /* @__PURE__ */ jsxs(
25052
+ "div",
25053
+ {
25054
+ className: "text-red-500 text-sm",
25055
+ children: [
25056
+ "Error rendering chart: ",
25057
+ match[0]
25058
+ ]
25059
+ },
25060
+ `error-${startIndex}`
25061
+ )
25062
+ );
25063
+ }
25064
+ lastIndex = endIndex;
25065
+ }
25066
+ }
25067
+ if (lastIndex < text.length) {
25068
+ const remainingText = text.substring(lastIndex);
25069
+ chartElements.push(
25070
+ /* @__PURE__ */ jsx(
25071
+ "div",
25072
+ {
25073
+ dangerouslySetInnerHTML: { __html: formatMessage(remainingText) }
25074
+ },
25075
+ `text-${lastIndex}`
25076
+ )
25077
+ );
25078
+ }
25079
+ if (chartElements.length === 1 && lastIndex === 0) {
25080
+ return null;
25081
+ }
25082
+ return chartElements;
25083
+ };
25084
+ const parseChartArguments = (argsString) => {
25085
+ const args = {};
25086
+ const jsonParamRegex = /(\w+)\s*=\s*(\[[\s\S]*?\](?=\s*(?:,|\s*\)|\s*$))|\{[\s\S]*?\}(?=\s*(?:,|\s*\)|\s*$)))/g;
25087
+ let jsonMatch;
25088
+ while ((jsonMatch = jsonParamRegex.exec(argsString)) !== null) {
25089
+ const paramName = jsonMatch[1];
25090
+ const jsonValue = jsonMatch[2];
25091
+ try {
25092
+ args[paramName] = JSON.parse(jsonValue);
25093
+ argsString = argsString.replace(jsonMatch[0], "");
25094
+ } catch (e) {
25095
+ console.error(`Failed to parse ${paramName} JSON:`, e);
25096
+ }
25097
+ }
25098
+ const argRegex = /(\w+)\s*=\s*("([^"]*)"|'([^']*)'|([^,\s\)]+))/g;
25099
+ let argMatch;
25100
+ while ((argMatch = argRegex.exec(argsString)) !== null) {
25101
+ const key = argMatch[1];
25102
+ const value = argMatch[3] || argMatch[4] || argMatch[5];
25103
+ if (key === "data") continue;
25104
+ if (value === "true" || value === "True") {
25105
+ args[key] = true;
25106
+ } else if (value === "false" || value === "False") {
25107
+ args[key] = false;
25108
+ } else if (value === "null" || value === "None") {
25109
+ args[key] = null;
25110
+ } else if (!isNaN(Number(value)) && value !== "") {
25111
+ args[key] = Number(value);
25112
+ } else {
25113
+ args[key] = value;
25114
+ }
25115
+ }
25116
+ return args;
25117
+ };
25118
+ const renderChart = (chartType, args, key) => {
25119
+ switch (chartType) {
25120
+ case "create_gauge_chart":
25121
+ return /* @__PURE__ */ jsx("div", { className: "my-6 h-64 w-full flex justify-center", children: /* @__PURE__ */ jsx(
25122
+ GaugeChart,
25123
+ {
25124
+ value: args.value || 0,
25125
+ min: args.min_value || 0,
25126
+ max: args.max_value || 100,
25127
+ target: args.target,
25128
+ label: args.title || "",
25129
+ unit: args.unit || "",
25130
+ thresholds: args.thresholds,
25131
+ className: "w-full max-w-sm"
25132
+ }
25133
+ ) }, `gauge-${key}`);
25134
+ case "create_bar_chart":
25135
+ if (!args.data || !args.x_field || !args.y_field) {
25136
+ console.error("Bar chart missing required parameters");
25137
+ return null;
25138
+ }
25139
+ return /* @__PURE__ */ jsxs("div", { className: "my-6 w-full", style: { maxWidth: args.max_width || "100%" }, children: [
25140
+ /* @__PURE__ */ jsx(
25141
+ BarChart,
25142
+ {
25143
+ data: args.data,
25144
+ bars: [{
25145
+ dataKey: args.y_field,
25146
+ fill: args.color || "#3b82f6",
25147
+ labelList: args.show_values
25148
+ }],
25149
+ xAxisDataKey: args.x_field,
25150
+ className: "h-64",
25151
+ showLegend: false
25152
+ }
25153
+ ),
25154
+ args.title && /* @__PURE__ */ jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
25155
+ ] }, `bar-${key}`);
25156
+ case "create_line_chart":
25157
+ if (!args.data || !args.x_field || !args.y_field) {
25158
+ console.error("Line chart missing required parameters");
25159
+ return null;
25160
+ }
25161
+ return /* @__PURE__ */ jsxs("div", { className: "my-6 w-full", style: {
25162
+ height: args.height || 256,
25163
+ width: args.width || "100%"
25164
+ }, children: [
25165
+ /* @__PURE__ */ jsx(
25166
+ LineChart,
25167
+ {
25168
+ data: args.data,
25169
+ lines: [{
25170
+ dataKey: args.y_field,
25171
+ stroke: "#3b82f6",
25172
+ strokeWidth: 2
25173
+ }],
25174
+ xAxisDataKey: args.x_field,
25175
+ className: "h-full",
25176
+ showLegend: false
25177
+ }
25178
+ ),
25179
+ args.title && /* @__PURE__ */ jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
25180
+ ] }, `line-${key}`);
25181
+ case "create_pie_chart":
25182
+ if (!args.data || !args.label_field || !args.value_field) {
25183
+ console.error("Pie chart missing required parameters");
25184
+ return null;
25185
+ }
25186
+ const pieData = args.data.map((item) => ({
25187
+ name: item[args.label_field],
25188
+ value: item[args.value_field]
25189
+ }));
25190
+ return /* @__PURE__ */ jsxs("div", { className: "my-6 w-full flex flex-col items-center", children: [
25191
+ args.title && /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-gray-700 mb-2", children: args.title }),
25192
+ /* @__PURE__ */ jsx("div", { className: "h-64 w-full max-w-md", children: /* @__PURE__ */ jsx(
25193
+ PieChart4,
25194
+ {
25195
+ data: pieData,
25196
+ showPercentages: args.show_percentages || false
25197
+ }
25198
+ ) })
25199
+ ] }, `pie-${key}`);
25200
+ case "create_comparison_table":
25201
+ if (!args.data) {
25202
+ console.error("Comparison table missing required data");
25203
+ return null;
25204
+ }
25205
+ const columns = args.columns || Object.keys(args.data[0] || {});
25206
+ let sortedData = [...args.data];
25207
+ if (args.sort_by && columns.includes(args.sort_by)) {
25208
+ sortedData.sort((a, b) => {
25209
+ const aVal = a[args.sort_by];
25210
+ const bVal = b[args.sort_by];
25211
+ const comparison = aVal > bVal ? 1 : aVal < bVal ? -1 : 0;
25212
+ return args.sort_descending === false ? comparison : -comparison;
25213
+ });
25214
+ }
25215
+ return /* @__PURE__ */ jsxs("div", { className: "my-6 w-full overflow-x-auto", children: [
25216
+ args.title && /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-gray-700 mb-2", children: args.title }),
25217
+ /* @__PURE__ */ jsxs("table", { className: "min-w-full divide-y divide-gray-200", children: [
25218
+ /* @__PURE__ */ jsx("thead", { className: "bg-gray-50", children: /* @__PURE__ */ jsx("tr", { children: columns.map((col) => /* @__PURE__ */ jsx(
25219
+ "th",
25220
+ {
25221
+ className: `px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider ${col === args.highlight_column ? "bg-blue-50" : ""}`,
25222
+ children: col
25223
+ },
25224
+ col
25225
+ )) }) }),
25226
+ /* @__PURE__ */ jsx("tbody", { className: "bg-white divide-y divide-gray-200", children: sortedData.map((row, rowIdx) => /* @__PURE__ */ jsx("tr", { className: rowIdx % 2 === 0 ? "bg-white" : "bg-gray-50", children: columns.map((col) => /* @__PURE__ */ jsx(
25227
+ "td",
25228
+ {
25229
+ className: `px-4 py-2 whitespace-nowrap text-sm ${col === args.highlight_column ? "font-medium text-blue-600 bg-blue-50" : "text-gray-900"}`,
25230
+ children: row[col]
25231
+ },
25232
+ col
25233
+ )) }, rowIdx)) })
25234
+ ] })
25235
+ ] }, `table-${key}`);
25236
+ default:
25237
+ console.warn(`Unknown chart type: ${chartType}`);
25238
+ return null;
25239
+ }
25240
+ };
25241
+ const chartContent = parseChartPatterns(content);
25242
+ if (chartContent) {
25243
+ return /* @__PURE__ */ jsx("div", { className: "formatted-content", children: chartContent });
25244
+ }
24748
25245
  return /* @__PURE__ */ jsx(
24749
25246
  "div",
24750
25247
  {
@@ -30957,4 +31454,4 @@ var S3Service = class {
30957
31454
  }
30958
31455
  };
30959
31456
 
30960
- 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, GridComponentsPlaceholder, Header, HelpView_default as HelpView, HomeView_default as HomeView, HourlyOutputChart2 as HourlyOutputChart, ISTTimer_default as ISTTimer, KPICard, KPIDetailView_default as KPIDetailView, KPIGrid, KPIHeader, KPISection, KPIsOverviewView_default as KPIsOverviewView, LINE_1_UUID, LargeOutputProgressChart, LeaderboardDetailView_default as LeaderboardDetailView, Legend5 as Legend, LineChart, LineHistoryCalendar, LineMonthlyHistory, LineMonthlyPdfGenerator, LinePdfExportButton, LinePdfGenerator, LineWhatsAppShareButton, LiveTimer, LoadingOverlay_default as LoadingOverlay, LoadingPage_default as LoadingPage, LoadingSpinner_default as LoadingSpinner, LoginPage, LoginView_default as LoginView, MainLayout, MetricCard_default as MetricCard, NoWorkspaceData, OptifyeAgentClient, OutputProgressChart, PageHeader, ProfileView_default as ProfileView, RegistryProvider, S3Service, SOPComplianceChart, SSEChatClient, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, ShiftDisplay_default as ShiftDisplay, ShiftsView_default as ShiftsView, SideNavBar, SingleVideoStream_default as SingleVideoStream, Skeleton, SlackAPI, SupabaseProvider, TargetWorkspaceGrid, TargetsView_default as TargetsView, ThreadSidebar, TimeDisplay_default as TimeDisplay, TimePickerDropdown, VideoCard, VideoGridView, VideoPreloader, WORKSPACE_POSITIONS, WhatsAppShareButton, WorkspaceCard, WorkspaceDetailView_default as WorkspaceDetailView, WorkspaceGrid, WorkspaceGridItem, WorkspaceHistoryCalendar, WorkspaceMetricCards, WorkspaceMonthlyDataFetcher, WorkspaceMonthlyPdfGenerator, WorkspacePdfExportButton, WorkspacePdfGenerator, WorkspaceWhatsAppShareButton, actionService, apiUtils, authCoreService, authOTPService, authRateLimitService, checkRateLimit2 as checkRateLimit, clearAllRateLimits2 as clearAllRateLimits, clearRateLimit2 as clearRateLimit, clearS3VideoCache, clearS3VideoFromCache, clearWorkspaceDisplayNamesCache, cn, createStreamProxyHandler, createSupabaseClient, createThrottledReload, dashboardService, deleteThread, forceRefreshWorkspaceDisplayNames, formatDateInZone, formatDateTimeInZone, formatISTDate, formatIdleTime, formatTimeInZone, fromUrlFriendlyName, getAllThreadMessages, getAllWorkspaceDisplayNamesAsync, getAnonClient, getCameraNumber, getCompanyMetricsTableName, getConfigurableShortWorkspaceDisplayName, getConfigurableWorkspaceDisplayName, getCurrentShift, getCurrentTimeInZone, getDashboardHeaderTimeInZone, getDaysDifferenceInZone, getDefaultCameraStreamUrl, getDefaultTabForWorkspace, getManufacturingInsights, getMetricsTablePrefix, getOperationalDate, getS3SignedUrl, getS3VideoSrc, getShortWorkspaceDisplayName, getShortWorkspaceDisplayNameAsync, getStoredWorkspaceMappings, getThreadMessages, getUserThreads, getUserThreadsPaginated, getWorkspaceDisplayName, getWorkspaceDisplayNameAsync, getWorkspaceDisplayNamesMap, getWorkspaceFromUrl, getWorkspaceNavigationParams, identifyCoreUser, initializeCoreMixpanel, isTransitionPeriod, isValidLineInfoPayload, isValidWorkspaceDetailedMetricsPayload, isValidWorkspaceMetricsPayload, isWorkspaceDisplayNamesLoaded, isWorkspaceDisplayNamesLoading, mergeWithDefaultConfig, optifyeAgentClient, preInitializeWorkspaceDisplayNames, preloadS3Video, preloadS3VideoUrl, preloadS3VideosUrl, preloadVideoUrl, preloadVideosUrl, qualityService, realtimeService, refreshWorkspaceDisplayNames, resetCoreMixpanel, s3VideoPreloader, storeWorkspaceMapping, streamProxyConfig, throttledReloadDashboard, toUrlFriendlyName, trackCoreEvent, trackCorePageView, updateThreadTitle, useActiveBreaks, useAnalyticsConfig, useAuth, useAuthConfig, useComponentOverride, useCustomConfig, useDashboardConfig, useDashboardMetrics, useDatabaseConfig, useDateFormatter, useDateTimeConfig, useEndpointsConfig, useEntityConfig, useFactoryOverviewMetrics, useFeatureFlags, useFormatNumber, useHistoricWorkspaceMetrics, useHlsStream, useHlsStreamWithCropping, useHookOverride, useLeaderboardMetrics, useLineDetailedMetrics, useLineKPIs, useLineMetrics, useLineWorkspaceMetrics, useMessages, useMetrics, useNavigation, useOverrides, usePageOverride, useRealtimeLineMetrics, useRegistry, useShiftConfig, useShifts, useSupabase, useSupabaseClient, useTargets, useTheme, useThemeConfig, useThreads, useVideoConfig, useWorkspaceConfig, useWorkspaceDetailedMetrics, useWorkspaceDisplayName, useWorkspaceDisplayNames, useWorkspaceDisplayNamesMap, useWorkspaceMetrics, useWorkspaceNavigation, useWorkspaceOperators, videoPreloader, whatsappService, withAuth, withRegistry, workspaceService };
31457
+ 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, LargeOutputProgressChart, LeaderboardDetailView_default as LeaderboardDetailView, Legend6 as Legend, LineChart, LineHistoryCalendar, LineMonthlyHistory, LineMonthlyPdfGenerator, LinePdfExportButton, LinePdfGenerator, LineWhatsAppShareButton, LiveTimer, LoadingOverlay_default as LoadingOverlay, LoadingPage_default as LoadingPage, LoadingSpinner_default as LoadingSpinner, LoginPage, LoginView_default as LoginView, MainLayout, MetricCard_default as MetricCard, NoWorkspaceData, OptifyeAgentClient, OutputProgressChart, PageHeader, PieChart4 as PieChart, ProfileView_default as ProfileView, RegistryProvider, S3Service, SOPComplianceChart, SSEChatClient, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, ShiftDisplay_default as ShiftDisplay, ShiftsView_default as ShiftsView, SideNavBar, SingleVideoStream_default as SingleVideoStream, Skeleton, SlackAPI, SupabaseProvider, TargetWorkspaceGrid, TargetsView_default as TargetsView, ThreadSidebar, TimeDisplay_default as TimeDisplay, TimePickerDropdown, VideoCard, VideoGridView, VideoPreloader, WORKSPACE_POSITIONS, WhatsAppShareButton, WorkspaceCard, WorkspaceDetailView_default as WorkspaceDetailView, WorkspaceDisplayNameExample, WorkspaceGrid, WorkspaceGridItem, WorkspaceHistoryCalendar, WorkspaceMetricCards, WorkspaceMonthlyDataFetcher, WorkspaceMonthlyPdfGenerator, WorkspacePdfExportButton, WorkspacePdfGenerator, WorkspaceWhatsAppShareButton, actionService, apiUtils, authCoreService, authOTPService, authRateLimitService, checkRateLimit2 as checkRateLimit, clearAllRateLimits2 as clearAllRateLimits, clearRateLimit2 as clearRateLimit, clearS3VideoCache, clearS3VideoFromCache, clearWorkspaceDisplayNamesCache, cn, createStreamProxyHandler, createSupabaseClient, createThrottledReload, dashboardService, deleteThread, forceRefreshWorkspaceDisplayNames, formatDateInZone, formatDateTimeInZone, formatISTDate, formatIdleTime, formatTimeInZone, fromUrlFriendlyName, getAllThreadMessages, getAllWorkspaceDisplayNamesAsync, getAnonClient, getCameraNumber, getCompanyMetricsTableName, getConfigurableShortWorkspaceDisplayName, getConfigurableWorkspaceDisplayName, getCurrentShift, getCurrentTimeInZone, getDashboardHeaderTimeInZone, getDaysDifferenceInZone, getDefaultCameraStreamUrl, getDefaultTabForWorkspace, getManufacturingInsights, getMetricsTablePrefix, getOperationalDate, getS3SignedUrl, getS3VideoSrc, getShortWorkspaceDisplayName, getShortWorkspaceDisplayNameAsync, getStoredWorkspaceMappings, getThreadMessages, getUserThreads, getUserThreadsPaginated, getWorkspaceDisplayName, getWorkspaceDisplayNameAsync, getWorkspaceDisplayNamesMap, getWorkspaceFromUrl, getWorkspaceNavigationParams, identifyCoreUser, initializeCoreMixpanel, isTransitionPeriod, isValidLineInfoPayload, isValidWorkspaceDetailedMetricsPayload, isValidWorkspaceMetricsPayload, isWorkspaceDisplayNamesLoaded, isWorkspaceDisplayNamesLoading, mergeWithDefaultConfig, optifyeAgentClient, preInitializeWorkspaceDisplayNames, preloadS3Video, preloadS3VideoUrl, preloadS3VideosUrl, preloadVideoUrl, preloadVideosUrl, qualityService, realtimeService, refreshWorkspaceDisplayNames, resetCoreMixpanel, s3VideoPreloader, storeWorkspaceMapping, streamProxyConfig, throttledReloadDashboard, toUrlFriendlyName, trackCoreEvent, trackCorePageView, updateThreadTitle, useActiveBreaks, useAnalyticsConfig, useAuth, useAuthConfig, useComponentOverride, useCustomConfig, useDashboardConfig, useDashboardMetrics, useDatabaseConfig, useDateFormatter, useDateTimeConfig, useEndpointsConfig, useEntityConfig, useFactoryOverviewMetrics, useFeatureFlags, useFormatNumber, useHistoricWorkspaceMetrics, useHlsStream, useHlsStreamWithCropping, useHookOverride, useLeaderboardMetrics, useLineDetailedMetrics, useLineKPIs, useLineMetrics, useLineWorkspaceMetrics, useMessages, useMetrics, useNavigation, useOverrides, usePageOverride, useRealtimeLineMetrics, useRegistry, useShiftConfig, useShifts, useSupabase, useSupabaseClient, useTargets, useTheme, useThemeConfig, useThreads, useVideoConfig, useWorkspaceConfig, useWorkspaceDetailedMetrics, useWorkspaceDisplayName, useWorkspaceDisplayNames, useWorkspaceDisplayNamesMap, useWorkspaceMetrics, useWorkspaceNavigation, useWorkspaceOperators, videoPreloader, whatsappService, withAuth, withRegistry, workspaceService };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optifye/dashboard-core",
3
- "version": "4.2.9",
3
+ "version": "4.3.3",
4
4
  "description": "Reusable UI & logic for Optifye dashboard",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",