@optifye/dashboard-core 4.1.0 → 4.1.1

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.
Files changed (3) hide show
  1. package/dist/index.js +367 -114
  2. package/dist/index.mjs +368 -115
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -28122,9 +28122,9 @@ var SideNavBar = React46.memo(({
28122
28122
  }
28123
28123
  )
28124
28124
  ] }),
28125
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-auto", children: [
28126
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-10 h-px bg-gray-200 my-4" }),
28127
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pb-2 w-full", children: /* @__PURE__ */ jsxRuntime.jsx(
28125
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-auto mb-2", children: [
28126
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-10 h-px bg-gray-200 my-3" }),
28127
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxRuntime.jsx(
28128
28128
  "button",
28129
28129
  {
28130
28130
  onClick: handleProfileClick,
@@ -28706,7 +28706,7 @@ var ThreadSidebar = ({
28706
28706
  if (error) {
28707
28707
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `p-4 text-red-600 text-sm ${className}`, children: "Failed to load conversations" });
28708
28708
  }
28709
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex flex-col h-full bg-gray-50 border-r border-gray-200 ${className}`, children: [
28709
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex flex-col h-screen bg-gray-50 border-r border-gray-200 ${className}`, children: [
28710
28710
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-shrink-0 p-4 border-b border-gray-200", children: /* @__PURE__ */ jsxRuntime.jsxs(
28711
28711
  "button",
28712
28712
  {
@@ -28718,7 +28718,7 @@ var ThreadSidebar = ({
28718
28718
  ]
28719
28719
  }
28720
28720
  ) }),
28721
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-y-auto", children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center p-8", children: /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner_default, { size: "sm" }) }) : threads.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 text-center text-gray-500 text-sm", children: "No conversations yet" }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-2", children: threads.map((thread) => /* @__PURE__ */ jsxRuntime.jsxs(
28721
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-y-auto min-h-0", children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center p-8", children: /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner_default, { size: "sm" }) }) : threads.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 text-center text-gray-500 text-sm", children: "No conversations yet" }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-2", children: threads.map((thread) => /* @__PURE__ */ jsxRuntime.jsxs(
28722
28722
  "div",
28723
28723
  {
28724
28724
  onClick: () => onSelectThread(thread.id),
@@ -28761,10 +28761,13 @@ var AIAgentView = () => {
28761
28761
  const [lastError, setLastError] = React46.useState(null);
28762
28762
  const [copiedMessageId, setCopiedMessageId] = React46.useState(null);
28763
28763
  const [activeThreadId, setActiveThreadId] = React46.useState(void 0);
28764
- const [isSidebarOpen, setIsSidebarOpen] = React46.useState(true);
28764
+ const [isSidebarOpen, setIsSidebarOpen] = React46.useState(false);
28765
28765
  const [streamingStates, setStreamingStates] = React46.useState(/* @__PURE__ */ new Map());
28766
28766
  const [userId, setUserId] = React46.useState(null);
28767
28767
  const [pendingThreadId, setPendingThreadId] = React46.useState(null);
28768
+ const [isTransitioning, setIsTransitioning] = React46.useState(false);
28769
+ const [typedText, setTypedText] = React46.useState("");
28770
+ const [newChatCount, setNewChatCount] = React46.useState(0);
28768
28771
  const isThreadLoading = (threadId) => {
28769
28772
  return threadId ? loadingThreads.has(threadId) : false;
28770
28773
  };
@@ -28792,6 +28795,20 @@ var AIAgentView = () => {
28792
28795
  const lineId = getLineIdFromPath();
28793
28796
  const { shiftId } = getCurrentShift(dateTimeConfig.defaultTimezone || "Asia/Kolkata", shiftConfig);
28794
28797
  const companyId = entityConfig.companyId || "default-company-id";
28798
+ const ACTIVE_THREAD_STORAGE_KEY = `ai-agent-active-thread-${lineId}`;
28799
+ React46.useEffect(() => {
28800
+ const savedThreadId = localStorage.getItem(ACTIVE_THREAD_STORAGE_KEY);
28801
+ if (savedThreadId && savedThreadId !== "undefined") {
28802
+ setActiveThreadId(savedThreadId);
28803
+ }
28804
+ }, [ACTIVE_THREAD_STORAGE_KEY]);
28805
+ React46.useEffect(() => {
28806
+ if (activeThreadId) {
28807
+ localStorage.setItem(ACTIVE_THREAD_STORAGE_KEY, activeThreadId);
28808
+ } else {
28809
+ localStorage.removeItem(ACTIVE_THREAD_STORAGE_KEY);
28810
+ }
28811
+ }, [activeThreadId, ACTIVE_THREAD_STORAGE_KEY]);
28795
28812
  React46.useEffect(() => {
28796
28813
  if (textareaRef.current) {
28797
28814
  textareaRef.current.style.height = "auto";
@@ -28806,6 +28823,27 @@ var AIAgentView = () => {
28806
28823
  setTimeout(scrollToBottom, 100);
28807
28824
  }
28808
28825
  }, [activeThreadId]);
28826
+ React46.useEffect(() => {
28827
+ if (messages.length === 0 && !isTransitioning) {
28828
+ const fullText = "Hi, I'm Axel - Your AI Supervisor";
28829
+ let index = 0;
28830
+ setTypedText("");
28831
+ const typeInterval = setInterval(() => {
28832
+ if (index < fullText.length) {
28833
+ setTypedText(fullText.substring(0, index + 1));
28834
+ index++;
28835
+ } else {
28836
+ clearInterval(typeInterval);
28837
+ }
28838
+ }, 50);
28839
+ return () => clearInterval(typeInterval);
28840
+ }
28841
+ }, [messages.length, isTransitioning]);
28842
+ React46.useEffect(() => {
28843
+ if (isSidebarOpen) {
28844
+ setNewChatCount(0);
28845
+ }
28846
+ }, [isSidebarOpen]);
28809
28847
  const copyToClipboard = async (text, messageId) => {
28810
28848
  try {
28811
28849
  await navigator.clipboard.writeText(text);
@@ -28820,6 +28858,8 @@ var AIAgentView = () => {
28820
28858
  setMessages([]);
28821
28859
  setInputValue("");
28822
28860
  setPendingThreadId(null);
28861
+ setTypedText("");
28862
+ localStorage.removeItem(ACTIVE_THREAD_STORAGE_KEY);
28823
28863
  textareaRef.current?.focus();
28824
28864
  };
28825
28865
  React46.useEffect(() => {
@@ -28852,6 +28892,12 @@ var AIAgentView = () => {
28852
28892
  let currentThreadId = activeThreadId || `temp-${Date.now()}`;
28853
28893
  if (isThreadLoading(currentThreadId)) return;
28854
28894
  const userMessage = inputValue.trim();
28895
+ if (displayMessages.length === 0) {
28896
+ setIsTransitioning(true);
28897
+ setTimeout(() => {
28898
+ setIsTransitioning(false);
28899
+ }, 800);
28900
+ }
28855
28901
  setInputValue("");
28856
28902
  setLoadingThreads((prev) => new Set(prev).add(currentThreadId));
28857
28903
  setLastError(null);
@@ -28895,6 +28941,9 @@ var AIAgentView = () => {
28895
28941
  currentThreadId = threadId;
28896
28942
  setActiveThreadId(threadId);
28897
28943
  setPendingThreadId(null);
28944
+ if (!isSidebarOpen) {
28945
+ setNewChatCount((prev) => prev + 1);
28946
+ }
28898
28947
  setLoadingThreads((prev) => {
28899
28948
  const newSet = new Set(prev);
28900
28949
  if (newSet.has(oldThreadId)) {
@@ -28993,7 +29042,9 @@ var AIAgentView = () => {
28993
29042
  const handleKeyDown = (e) => {
28994
29043
  if (e.key === "Enter" && !e.shiftKey) {
28995
29044
  e.preventDefault();
28996
- handleSubmit(e);
29045
+ if (!isCurrentThreadLoading) {
29046
+ handleSubmit(e);
29047
+ }
28997
29048
  }
28998
29049
  };
28999
29050
  const formatMessage = (content) => {
@@ -29002,7 +29053,81 @@ var AIAgentView = () => {
29002
29053
  text = text.replace(/`([^`]+)`/g, '<code class="bg-gray-100 px-1.5 py-0.5 rounded text-sm font-mono text-gray-800">$1</code>');
29003
29054
  return text;
29004
29055
  };
29005
- const lines = content.split("\n");
29056
+ const parseTableFromText = (lines2, startIndex) => {
29057
+ const tableLines = [];
29058
+ let i = startIndex;
29059
+ while (i < lines2.length) {
29060
+ const line = lines2[i].trim();
29061
+ if (!line) {
29062
+ i++;
29063
+ break;
29064
+ }
29065
+ if (line.includes("|") || line.match(/^[-|=\s]+$/)) {
29066
+ tableLines.push(line);
29067
+ i++;
29068
+ } else {
29069
+ break;
29070
+ }
29071
+ }
29072
+ if (tableLines.length === 0) return { html: "", endIndex: startIndex };
29073
+ const dataLines = tableLines.filter((line) => !line.match(/^[-|=\s]+$/));
29074
+ if (dataLines.length === 0) return { html: "", endIndex: i };
29075
+ let headerRow = [];
29076
+ let dataRows = [];
29077
+ const firstLine = dataLines[0];
29078
+ if (firstLine.includes("|")) {
29079
+ const cells = firstLine.split("|").map((cell) => cell.trim()).filter((cell) => cell.length > 0);
29080
+ if (cells.length >= 2) {
29081
+ headerRow = cells;
29082
+ for (let j = 1; j < dataLines.length; j++) {
29083
+ const row = dataLines[j];
29084
+ if (row.includes("|")) {
29085
+ const rowCells = row.split("|").map((cell) => cell.trim()).filter((cell) => cell.length > 0);
29086
+ while (rowCells.length < headerRow.length) rowCells.push("");
29087
+ if (rowCells.length > headerRow.length) rowCells.splice(headerRow.length);
29088
+ dataRows.push(rowCells);
29089
+ }
29090
+ }
29091
+ }
29092
+ }
29093
+ if (headerRow.length === 0) {
29094
+ for (const line of dataLines) {
29095
+ if (line.includes("|")) {
29096
+ const rowCells = line.split("|").map((cell) => cell.trim()).filter((cell) => cell.length > 0);
29097
+ if (rowCells.length >= 2) {
29098
+ dataRows.push(rowCells);
29099
+ }
29100
+ }
29101
+ }
29102
+ if (dataRows.length > 0 && dataRows[0].length > 0) {
29103
+ headerRow = dataRows[0].map((_, index) => `Column ${index + 1}`);
29104
+ }
29105
+ }
29106
+ if (headerRow.length > 0 && dataRows.length > 0) {
29107
+ let tableHtml = '<div class="overflow-x-auto my-4"><table class="min-w-full border-collapse border border-gray-300 rounded-lg shadow-sm">';
29108
+ tableHtml += '<thead class="bg-gray-50">';
29109
+ tableHtml += "<tr>";
29110
+ headerRow.forEach((header) => {
29111
+ tableHtml += `<th class="border border-gray-300 px-4 py-2 text-left font-semibold text-gray-900">${processInlineFormatting(header)}</th>`;
29112
+ });
29113
+ tableHtml += "</tr>";
29114
+ tableHtml += "</thead>";
29115
+ tableHtml += '<tbody class="bg-white">';
29116
+ dataRows.forEach((row, rowIndex) => {
29117
+ tableHtml += `<tr class="${rowIndex % 2 === 0 ? "bg-white" : "bg-gray-50"}">`;
29118
+ row.forEach((cell) => {
29119
+ tableHtml += `<td class="border border-gray-300 px-4 py-2 text-gray-800">${processInlineFormatting(cell)}</td>`;
29120
+ });
29121
+ tableHtml += "</tr>";
29122
+ });
29123
+ tableHtml += "</tbody>";
29124
+ tableHtml += "</table></div>";
29125
+ return { html: tableHtml, endIndex: i };
29126
+ }
29127
+ return { html: "", endIndex: startIndex };
29128
+ };
29129
+ const processedContent = content;
29130
+ const lines = processedContent.split("\n");
29006
29131
  const formattedLines = [];
29007
29132
  let inList = false;
29008
29133
  for (let i = 0; i < lines.length; i++) {
@@ -29016,6 +29141,18 @@ var AIAgentView = () => {
29016
29141
  formattedLines.push("<br/>");
29017
29142
  continue;
29018
29143
  }
29144
+ if (trimmedLine.includes("|") && (trimmedLine.match(/\|/g) || []).length >= 1) {
29145
+ if (inList) {
29146
+ formattedLines.push("</ul>");
29147
+ inList = false;
29148
+ }
29149
+ const tableResult = parseTableFromText(lines, i);
29150
+ if (tableResult.html) {
29151
+ formattedLines.push(tableResult.html);
29152
+ i = tableResult.endIndex - 1;
29153
+ continue;
29154
+ }
29155
+ }
29019
29156
  if (trimmedLine.startsWith("###")) {
29020
29157
  if (inList) {
29021
29158
  formattedLines.push("</ul>");
@@ -29099,71 +29236,185 @@ var AIAgentView = () => {
29099
29236
  position: messages.length
29100
29237
  });
29101
29238
  }
29102
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-screen bg-white", children: [
29103
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${isSidebarOpen ? "w-80" : "w-0"} transition-all duration-300 overflow-hidden flex-shrink-0`, children: /* @__PURE__ */ jsxRuntime.jsx(
29104
- ThreadSidebar,
29239
+ const renderAssistantContent = (content) => {
29240
+ return /* @__PURE__ */ jsxRuntime.jsx(
29241
+ "div",
29105
29242
  {
29106
- activeThreadId,
29107
- onSelectThread: setActiveThreadId,
29108
- onNewThread: handleNewThread,
29109
- className: "h-full"
29243
+ className: "formatted-content",
29244
+ dangerouslySetInnerHTML: { __html: formatMessage(content) }
29110
29245
  }
29111
- ) }),
29112
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 flex flex-col", children: [
29113
- /* @__PURE__ */ jsxRuntime.jsx("header", { className: "flex-shrink-0 bg-white border-b border-gray-200", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-6 py-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
29114
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4", children: [
29115
- /* @__PURE__ */ jsxRuntime.jsx(
29116
- "button",
29117
- {
29118
- onClick: () => setIsSidebarOpen(!isSidebarOpen),
29119
- className: "p-2 hover:bg-gray-100 rounded-lg transition-colors",
29120
- "aria-label": "Toggle sidebar",
29121
- children: isSidebarOpen ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "w-5 h-5" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Menu, { className: "w-5 h-5" })
29246
+ );
29247
+ };
29248
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-screen bg-white", children: [
29249
+ /* @__PURE__ */ jsxRuntime.jsx("style", { dangerouslySetInnerHTML: {
29250
+ __html: `
29251
+ @keyframes slideDown {
29252
+ 0% {
29253
+ transform: translateY(-40vh);
29254
+ opacity: 1;
29122
29255
  }
29123
- ),
29124
- /* @__PURE__ */ jsxRuntime.jsxs(
29125
- "button",
29126
- {
29127
- onClick: () => navigate("/"),
29128
- className: "flex items-center gap-2 text-gray-600 hover:text-gray-900 transition-colors",
29129
- "aria-label": "Go back",
29130
- children: [
29131
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowLeft, { className: "w-5 h-5" }),
29132
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium", children: "Back" })
29133
- ]
29256
+ 100% {
29257
+ transform: translateY(0);
29258
+ opacity: 1;
29134
29259
  }
29135
- )
29136
- ] }),
29260
+ }
29261
+ `
29262
+ } }),
29263
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex-1 flex flex-col h-screen transition-all duration-300 ${isSidebarOpen ? "mr-80" : "mr-0"}`, children: [
29264
+ /* @__PURE__ */ jsxRuntime.jsx("header", { className: "flex-shrink-0 bg-white border-b border-gray-200 sticky top-0 z-10", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-6 py-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
29265
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-4", children: /* @__PURE__ */ jsxRuntime.jsxs(
29266
+ "button",
29267
+ {
29268
+ onClick: () => navigate("/"),
29269
+ className: "flex items-center gap-2 text-gray-600 hover:text-gray-900 transition-colors",
29270
+ "aria-label": "Go back",
29271
+ children: [
29272
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowLeft, { className: "w-5 h-5" }),
29273
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium", children: "Back" })
29274
+ ]
29275
+ }
29276
+ ) }),
29137
29277
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center", children: [
29138
29278
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
29139
- /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-xl sm:text-2xl md:text-3xl font-bold text-gray-800 tracking-tight leading-none", children: "Axel - AI Manufacturing Expert" }),
29279
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-xl sm:text-2xl md:text-3xl font-bold text-gray-800 tracking-tight leading-none", children: "Chat with Axel" }),
29140
29280
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-2 w-2 rounded-full bg-blue-500 animate-pulse ring-2 ring-blue-500/30" })
29141
29281
  ] }),
29142
29282
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center mt-1", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-medium text-gray-500", children: /* @__PURE__ */ jsxRuntime.jsx(ISTTimer_default, {}) }) })
29143
29283
  ] }),
29144
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-24" })
29284
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center", children: /* @__PURE__ */ jsxRuntime.jsxs(
29285
+ "button",
29286
+ {
29287
+ onClick: () => setIsSidebarOpen(!isSidebarOpen),
29288
+ className: "relative p-2 hover:bg-gray-100 rounded-lg transition-colors",
29289
+ "aria-label": "Toggle sidebar",
29290
+ children: [
29291
+ isSidebarOpen ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "w-5 h-5" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Menu, { className: "w-5 h-5" }),
29292
+ !isSidebarOpen && newChatCount > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute -top-1 -right-1 bg-red-500 text-white text-xs rounded-full w-5 h-5 flex items-center justify-center font-medium", children: newChatCount })
29293
+ ]
29294
+ }
29295
+ ) })
29145
29296
  ] }) }) }),
29146
29297
  /* @__PURE__ */ jsxRuntime.jsx(
29147
29298
  "main",
29148
29299
  {
29149
29300
  ref: containerRef,
29150
- className: "flex-1 overflow-y-auto bg-gray-50/50 min-h-0",
29151
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-w-5xl mx-auto p-4 sm:p-6 md:p-8", children: [
29152
- displayMessages.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-8 bg-white border border-gray-200/80 shadow-sm rounded-2xl p-6 sm:p-8", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-4", children: [
29153
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-16 h-16 rounded-xl overflow-hidden shadow-sm flex-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(
29154
- "img",
29301
+ className: `flex-1 bg-gray-50/50 min-h-0 ${displayMessages.length === 0 && !isTransitioning ? "flex items-center justify-center" : "overflow-y-auto"}`,
29302
+ children: displayMessages.length === 0 && !isTransitioning ? (
29303
+ /* Centered welcome and input for new chat */
29304
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full max-w-3xl mx-auto px-4 sm:px-6 flex flex-col items-center justify-center space-y-12 -mt-16", children: [
29305
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center", children: [
29306
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center mb-8", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-24 h-24 rounded-xl overflow-hidden shadow-sm", children: /* @__PURE__ */ jsxRuntime.jsx(
29307
+ "img",
29308
+ {
29309
+ src: axelProfilePng,
29310
+ alt: "Axel - AI Manufacturing Expert",
29311
+ className: "w-full h-full object-cover"
29312
+ }
29313
+ ) }) }),
29314
+ /* @__PURE__ */ jsxRuntime.jsxs("h2", { className: "text-3xl font-semibold text-gray-900", children: [
29315
+ typedText,
29316
+ typedText.length < "Hi, I'm Axel - Your AI Supervisor".length && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "animate-pulse", children: "|" })
29317
+ ] })
29318
+ ] }),
29319
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full max-w-2xl", children: [
29320
+ activeThreadId && messages.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center mb-4", children: /* @__PURE__ */ jsxRuntime.jsxs(
29321
+ "button",
29322
+ {
29323
+ onClick: handleNewThread,
29324
+ className: "inline-flex items-center gap-2 px-3 py-1.5 text-xs font-medium text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-lg transition-colors",
29325
+ children: [
29326
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RefreshCw, { className: "w-3.5 h-3.5" }),
29327
+ "New conversation"
29328
+ ]
29329
+ }
29330
+ ) }),
29331
+ /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, children: [
29332
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative bg-white rounded-3xl shadow-lg border border-gray-200 focus-within:border-gray-300 transition-all duration-200", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-end gap-2 p-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 relative", children: [
29333
+ /* @__PURE__ */ jsxRuntime.jsx(
29334
+ "textarea",
29335
+ {
29336
+ ref: textareaRef,
29337
+ value: inputValue,
29338
+ onChange: (e) => setInputValue(e.target.value),
29339
+ onKeyDown: handleKeyDown,
29340
+ placeholder: "Ask me about production optimization, quality metrics, or any manufacturing challenge...",
29341
+ className: "w-full resize-none bg-transparent px-2 py-2 pr-12 focus:outline-none placeholder-gray-500 text-gray-900 text-sm leading-relaxed",
29342
+ rows: 1,
29343
+ style: { minHeight: "24px", maxHeight: "120px" }
29344
+ }
29345
+ ),
29346
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute right-2 bottom-2 flex items-center gap-2", children: /* @__PURE__ */ jsxRuntime.jsx(
29347
+ "button",
29348
+ {
29349
+ type: "submit",
29350
+ disabled: !inputValue.trim() || isCurrentThreadLoading,
29351
+ className: "inline-flex items-center justify-center w-8 h-8 bg-gray-900 text-white rounded-full hover:bg-gray-800 transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed focus:outline-none focus:ring-2 focus:ring-gray-500/20",
29352
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Send, { className: "w-4 h-4" })
29353
+ }
29354
+ ) })
29355
+ ] }) }) }),
29356
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center mt-2 text-xs text-gray-400", children: [
29357
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: isCurrentThreadLoading ? "You can type your next message while Axel responds" : "Press Enter to send \u2022 Shift+Enter for new line" }),
29358
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 ml-4", children: [
29359
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: `w-1.5 h-1.5 rounded-full ${isCurrentThreadLoading ? "bg-orange-500" : "bg-green-500"}` }),
29360
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: isCurrentThreadLoading ? "Responding..." : "Connected" })
29361
+ ] })
29362
+ ] })
29363
+ ] })
29364
+ ] })
29365
+ ] })
29366
+ ) : isTransitioning ? (
29367
+ /* Transition state - show user message first, then thinking */
29368
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-w-4xl mx-auto px-4 sm:px-6 py-6 pb-32", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
29369
+ displayMessages.map((message, index) => /* @__PURE__ */ jsxRuntime.jsxs(
29370
+ "div",
29155
29371
  {
29156
- src: axelProfilePng,
29157
- alt: "Axel - AI Manufacturing Expert",
29158
- className: "w-full h-full object-cover"
29159
- }
29160
- ) }),
29161
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 pt-1", children: [
29162
- /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-xl font-semibold text-gray-900 mb-2", children: "Hi, I'm Axel - Your AI Supervisor" }),
29163
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-gray-600 leading-relaxed", children: "Ask me anything about your shop-floor. I'll remember our conversation and help you optimize your manufacturing processes." })
29372
+ className: `flex gap-4 ${message.role === "user" ? "justify-end" : "justify-start"}`,
29373
+ children: [
29374
+ message.role === "assistant" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-12 h-12 rounded-xl overflow-hidden shadow-sm", children: /* @__PURE__ */ jsxRuntime.jsx(
29375
+ "img",
29376
+ {
29377
+ src: axelProfilePng,
29378
+ alt: "Axel",
29379
+ className: "w-full h-full object-cover"
29380
+ }
29381
+ ) }) }),
29382
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: `max-w-none w-full group ${message.role === "user" ? "order-1" : ""}`, children: /* @__PURE__ */ jsxRuntime.jsx(
29383
+ "div",
29384
+ {
29385
+ className: `relative px-5 py-4 rounded-2xl shadow-sm ${message.role === "user" ? "bg-blue-600 text-white max-w-[85%] ml-auto" : "bg-white border border-gray-200/80 max-w-full"}`,
29386
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${message.role === "user" ? "text-white" : "text-gray-800"}`, children: [
29387
+ message.role === "assistant" ? renderAssistantContent(message.content) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "whitespace-pre-wrap leading-relaxed", children: message.content }),
29388
+ message.id === -1 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-block w-0.5 h-4 bg-gray-400 animate-pulse ml-0.5" })
29389
+ ] })
29390
+ }
29391
+ ) })
29392
+ ]
29393
+ },
29394
+ message.id === -1 ? `streaming-${currentStreaming.message.length}` : `${message.id}-${index}`
29395
+ )),
29396
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-4 justify-start", children: [
29397
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-12 h-12 rounded-xl overflow-hidden shadow-sm", children: /* @__PURE__ */ jsxRuntime.jsx(
29398
+ "img",
29399
+ {
29400
+ src: axelProfilePng,
29401
+ alt: "Axel",
29402
+ className: "w-full h-full object-cover"
29403
+ }
29404
+ ) }) }),
29405
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-white border border-gray-200/80 px-5 py-4 rounded-2xl shadow-sm max-w-full", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
29406
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex space-x-1", children: [
29407
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-2 h-2 bg-blue-500 rounded-full animate-bounce" }),
29408
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-2 h-2 bg-blue-500 rounded-full animate-bounce", style: { animationDelay: "0.1s" } }),
29409
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-2 h-2 bg-blue-500 rounded-full animate-bounce", style: { animationDelay: "0.2s" } })
29410
+ ] }),
29411
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-600 text-sm", children: "Axel is thinking..." })
29412
+ ] }) })
29164
29413
  ] })
29165
- ] }) }),
29166
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
29414
+ ] }) })
29415
+ ) : (
29416
+ /* Regular chat view with messages */
29417
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-w-4xl mx-auto px-4 sm:px-6 py-6 pb-32", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
29167
29418
  displayMessages.map((message, index) => /* @__PURE__ */ jsxRuntime.jsxs(
29168
29419
  "div",
29169
29420
  {
@@ -29177,22 +29428,14 @@ var AIAgentView = () => {
29177
29428
  className: "w-full h-full object-cover"
29178
29429
  }
29179
29430
  ) }) }),
29180
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `max-w-[75%] group ${message.role === "user" ? "order-1" : ""}`, children: [
29431
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `max-w-none w-full group ${message.role === "user" ? "order-1" : ""}`, children: [
29181
29432
  /* @__PURE__ */ jsxRuntime.jsxs(
29182
29433
  "div",
29183
29434
  {
29184
- className: `relative px-5 py-4 rounded-2xl shadow-sm ${message.role === "user" ? "bg-blue-600 text-white" : "bg-white border border-gray-200/80"}`,
29435
+ className: `relative px-5 py-4 rounded-2xl shadow-sm ${message.role === "user" ? "bg-blue-600 text-white max-w-[85%] ml-auto" : "bg-white border border-gray-200/80 max-w-full"}`,
29185
29436
  children: [
29186
29437
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${message.role === "user" ? "text-white" : "text-gray-800"}`, children: [
29187
- message.role === "assistant" ? /* @__PURE__ */ jsxRuntime.jsx(
29188
- "div",
29189
- {
29190
- className: "formatted-content",
29191
- dangerouslySetInnerHTML: {
29192
- __html: formatMessage(message.content)
29193
- }
29194
- }
29195
- ) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "whitespace-pre-wrap leading-relaxed", children: message.content }),
29438
+ message.role === "assistant" ? renderAssistantContent(message.content) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "whitespace-pre-wrap leading-relaxed", children: message.content }),
29196
29439
  message.id === -1 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-block w-0.5 h-4 bg-gray-400 animate-pulse ml-0.5" })
29197
29440
  ] }),
29198
29441
  message.role === "assistant" && message.id !== -1 && /* @__PURE__ */ jsxRuntime.jsx(
@@ -29218,15 +29461,14 @@ var AIAgentView = () => {
29218
29461
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Axel" })
29219
29462
  ] })
29220
29463
  ] })
29221
- ] }),
29222
- message.role === "user" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-10 h-10 bg-gray-700 text-white rounded-xl flex items-center justify-center text-sm font-semibold", children: entityConfig.companyId?.charAt(0).toUpperCase() || "U" }) })
29464
+ ] })
29223
29465
  ]
29224
29466
  },
29225
29467
  message.id === -1 ? `streaming-${currentStreaming.message.length}` : `${message.id}-${index}`
29226
29468
  )),
29227
29469
  lastError && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-4 justify-start", children: [
29228
29470
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-12 h-12 rounded-xl bg-red-100 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { className: "w-6 h-6 text-red-600" }) }) }),
29229
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-red-50 border border-red-200 px-5 py-4 rounded-2xl shadow-sm max-w-[75%]", children: [
29471
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-red-50 border border-red-200 px-5 py-4 rounded-2xl shadow-sm max-w-full", children: [
29230
29472
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-red-800 text-sm", children: lastError }),
29231
29473
  /* @__PURE__ */ jsxRuntime.jsx(
29232
29474
  "button",
@@ -29247,21 +29489,21 @@ var AIAgentView = () => {
29247
29489
  className: "w-full h-full object-cover"
29248
29490
  }
29249
29491
  ) }) }),
29250
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-white border border-gray-200/80 px-5 py-4 rounded-2xl shadow-sm max-w-[75%]", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
29492
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-white border border-gray-200/80 px-5 py-4 rounded-2xl shadow-sm max-w-full", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
29251
29493
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex space-x-1", children: [
29252
29494
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-2 h-2 bg-blue-500 rounded-full animate-bounce" }),
29253
29495
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-2 h-2 bg-blue-500 rounded-full animate-bounce", style: { animationDelay: "0.1s" } }),
29254
29496
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-2 h-2 bg-blue-500 rounded-full animate-bounce", style: { animationDelay: "0.2s" } })
29255
29497
  ] }),
29256
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-600 text-sm", children: "Axel is analyzing your request..." })
29498
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-600 text-sm", children: "Axel is thinking..." })
29257
29499
  ] }) })
29258
29500
  ] }),
29259
29501
  /* @__PURE__ */ jsxRuntime.jsx("div", { ref: messagesEndRef })
29260
- ] })
29261
- ] })
29502
+ ] }) })
29503
+ )
29262
29504
  }
29263
29505
  ),
29264
- /* @__PURE__ */ jsxRuntime.jsx("footer", { className: "flex-shrink-0 border-t border-gray-200 bg-white sticky bottom-0", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-w-5xl mx-auto p-4 sm:p-6", children: [
29506
+ (displayMessages.length > 0 || isTransitioning) && /* @__PURE__ */ jsxRuntime.jsx("footer", { className: "fixed bottom-0 left-0 right-0 bg-gradient-to-t from-gray-50/50 to-transparent pointer-events-none", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-w-4xl mx-auto p-4 sm:p-6 pointer-events-auto", children: [
29265
29507
  activeThreadId && messages.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center mb-4", children: /* @__PURE__ */ jsxRuntime.jsxs(
29266
29508
  "button",
29267
29509
  {
@@ -29273,48 +29515,59 @@ var AIAgentView = () => {
29273
29515
  ]
29274
29516
  }
29275
29517
  ) }),
29276
- /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, className: "space-y-3", children: [
29277
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-3 items-end", children: [
29278
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 relative", children: [
29279
- /* @__PURE__ */ jsxRuntime.jsx(
29280
- "textarea",
29281
- {
29282
- ref: textareaRef,
29283
- value: inputValue,
29284
- onChange: (e) => setInputValue(e.target.value),
29285
- onKeyDown: handleKeyDown,
29286
- placeholder: "Ask me about production optimization, quality metrics, or any manufacturing challenge...",
29287
- className: "w-full resize-none rounded-xl border border-gray-300 px-4 py-3.5 pr-16 focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-400 bg-white placeholder-gray-500 text-gray-900 text-sm leading-relaxed shadow-sm transition-all duration-200",
29288
- rows: 1,
29289
- disabled: isCurrentThreadLoading,
29290
- style: { minHeight: "48px", maxHeight: "120px" }
29291
- }
29292
- ),
29293
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute bottom-3 right-3 flex items-center gap-2", children: inputValue.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-gray-400 font-mono", children: inputValue.length }) })
29294
- ] }),
29295
- /* @__PURE__ */ jsxRuntime.jsxs(
29296
- "button",
29297
- {
29298
- type: "submit",
29299
- disabled: !inputValue.trim() || isCurrentThreadLoading,
29300
- className: "inline-flex items-center justify-center gap-2 h-12 px-5 bg-blue-600 text-white rounded-xl hover:bg-blue-700 transition-all duration-200 text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:ring-offset-2 shadow-sm hover:shadow-md disabled:hover:shadow-sm",
29301
- children: [
29302
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Send, { className: "w-4 h-4" }),
29303
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "hidden sm:inline", children: "Send" })
29304
- ]
29305
- }
29306
- )
29307
- ] }),
29308
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between text-xs text-gray-400", children: [
29309
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-4", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Press Enter to send \u2022 Shift+Enter for new line" }) }),
29310
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
29311
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-1.5 h-1.5 bg-green-500 rounded-full" }),
29312
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Connected" })
29313
- ] }) })
29518
+ /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, children: [
29519
+ /* @__PURE__ */ jsxRuntime.jsx(
29520
+ "div",
29521
+ {
29522
+ className: `relative bg-white rounded-3xl shadow-lg border border-gray-200 focus-within:border-gray-300 transition-all duration-200 ${isTransitioning ? "animate-slide-down" : ""}`,
29523
+ style: isTransitioning ? {
29524
+ animation: "slideDown 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards"
29525
+ } : {},
29526
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-end gap-2 p-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 relative", children: [
29527
+ /* @__PURE__ */ jsxRuntime.jsx(
29528
+ "textarea",
29529
+ {
29530
+ ref: textareaRef,
29531
+ value: inputValue,
29532
+ onChange: (e) => setInputValue(e.target.value),
29533
+ onKeyDown: handleKeyDown,
29534
+ placeholder: "Ask me about production optimization, quality metrics, or any manufacturing challenge...",
29535
+ className: "w-full resize-none bg-transparent px-2 py-2 pr-12 focus:outline-none placeholder-gray-500 text-gray-900 text-sm leading-relaxed",
29536
+ rows: 1,
29537
+ style: { minHeight: "24px", maxHeight: "120px" }
29538
+ }
29539
+ ),
29540
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute right-2 bottom-2 flex items-center gap-2", children: /* @__PURE__ */ jsxRuntime.jsx(
29541
+ "button",
29542
+ {
29543
+ type: "submit",
29544
+ disabled: !inputValue.trim() || isCurrentThreadLoading,
29545
+ className: "inline-flex items-center justify-center w-8 h-8 bg-gray-900 text-white rounded-full hover:bg-gray-800 transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed focus:outline-none focus:ring-2 focus:ring-gray-500/20",
29546
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Send, { className: "w-4 h-4" })
29547
+ }
29548
+ ) })
29549
+ ] }) })
29550
+ }
29551
+ ),
29552
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center mt-2 text-xs text-gray-400", children: [
29553
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: isCurrentThreadLoading ? "You can type your next message while Axel responds" : "Press Enter to send \u2022 Shift+Enter for new line" }),
29554
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 ml-4", children: [
29555
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: `w-1.5 h-1.5 rounded-full ${isCurrentThreadLoading ? "bg-orange-500" : "bg-green-500"}` }),
29556
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: isCurrentThreadLoading ? "Responding..." : "Connected" })
29557
+ ] })
29314
29558
  ] })
29315
29559
  ] })
29316
29560
  ] }) })
29317
- ] })
29561
+ ] }),
29562
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${isSidebarOpen ? "w-80" : "w-0"} transition-all duration-300 overflow-hidden flex-shrink-0 border-l border-gray-200 h-screen fixed right-0 top-0 z-20`, children: /* @__PURE__ */ jsxRuntime.jsx(
29563
+ ThreadSidebar,
29564
+ {
29565
+ activeThreadId,
29566
+ onSelectThread: setActiveThreadId,
29567
+ onNewThread: handleNewThread,
29568
+ className: "h-full"
29569
+ }
29570
+ ) })
29318
29571
  ] });
29319
29572
  };
29320
29573
  var AIAgentView_default = AIAgentView;