aizek-chatbot 1.0.9 → 1.0.11

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
@@ -105,181 +105,299 @@ var useChatbot = (options = {}) => {
105
105
  const generateId = () => {
106
106
  return Date.now().toString() + Math.random().toString(36).substr(2, 9);
107
107
  };
108
- const addMessage = (content, role) => {
108
+ const addMessage = (payload, role) => {
109
109
  const newMessage = {
110
110
  id: generateId(),
111
- content,
111
+ text: payload.text,
112
+ ui: payload.ui,
112
113
  role,
113
114
  timestamp: /* @__PURE__ */ new Date()
114
115
  };
115
116
  setMessages((prev) => [...prev, newMessage]);
116
117
  return newMessage;
117
118
  };
118
- const getHtmlUiInstructions = (config2) => {
119
- const headerColor = config2?.headerBackground || "#f5f5f5";
120
- const accentColor = config2?.buttonBackground || "#007bff";
121
- const companyName = config2?.companyName || "AI Assistant";
122
- const companyLogo = config2?.companyLogo || "\u{1F916}";
123
- return `
124
- You are a helpful assistant that creates UI using ONLY HTML tags.
119
+ const extractUiComponents = (raw) => {
120
+ const regex = /```ui-component([\s\S]*?)```/g;
121
+ const components = [];
122
+ let cleaned = raw;
123
+ let match;
124
+ let componentIndex = 0;
125
+ while ((match = regex.exec(raw)) !== null) {
126
+ const block = match[1].trim();
127
+ try {
128
+ const json = JSON.parse(block);
129
+ if (json.type === "buttons" && json.data && typeof json.data === "object" && !Array.isArray(json.data)) {
130
+ if (json.data.options && Array.isArray(json.data.options)) {
131
+ json.data = json.data.options.map((opt) => {
132
+ if (opt.id && opt.label) {
133
+ return {
134
+ label: opt.label,
135
+ value: opt.id,
136
+ variant: opt.variant
137
+ };
138
+ }
139
+ return opt;
140
+ });
141
+ }
142
+ }
143
+ if (json.type === "table" && json.data) {
144
+ if (Array.isArray(json.data.columns) && json.data.columns.length > 0) {
145
+ const firstCol = json.data.columns[0];
146
+ if (typeof firstCol === "string") {
147
+ json.data.columns = json.data.columns.map(
148
+ (col, idx) => ({
149
+ id: `col-${idx}`,
150
+ label: col
151
+ })
152
+ );
153
+ }
154
+ }
155
+ if (Array.isArray(json.data.rows) && json.data.rows.length > 0) {
156
+ const firstRow = json.data.rows[0];
157
+ if (Array.isArray(firstRow) && typeof firstRow[0] === "string") {
158
+ json.data.rows = json.data.rows.map((row) => {
159
+ const rowObj = {};
160
+ json.data.columns.forEach((col, idx) => {
161
+ const colId = typeof col === "string" ? `col-${idx}` : col.id;
162
+ const cellValue = row[idx];
163
+ if (typeof cellValue === "string" && (cellValue.startsWith("http") || cellValue.startsWith("data:"))) {
164
+ rowObj[colId] = {
165
+ type: "image",
166
+ src: cellValue,
167
+ alt: ""
168
+ };
169
+ } else {
170
+ rowObj[colId] = {
171
+ type: "text",
172
+ value: cellValue || ""
173
+ };
174
+ }
175
+ });
176
+ return rowObj;
177
+ });
178
+ }
179
+ }
180
+ }
181
+ if (json.type === "form" && json.data) {
182
+ if (!json.data.id) {
183
+ json.data.id = json.id || `form-${componentIndex}`;
184
+ }
185
+ if (json.data.fields && Array.isArray(json.data.fields)) {
186
+ json.data.fields = json.data.fields.map((field) => {
187
+ if (field.optional !== void 0) {
188
+ field.required = !field.optional;
189
+ delete field.optional;
190
+ }
191
+ if (!field.type) {
192
+ field.type = "text";
193
+ }
194
+ if (field.options && Array.isArray(field.options)) {
195
+ const firstOption = field.options[0];
196
+ if (typeof firstOption === "string") {
197
+ field.options = field.options.map((opt) => ({
198
+ label: opt,
199
+ value: opt
200
+ }));
201
+ }
202
+ }
203
+ return field;
204
+ });
205
+ }
206
+ }
207
+ if (json.id && typeof json.id !== "string") {
208
+ json.id = String(json.id);
209
+ }
210
+ if (!json.id || !json.id.trim()) {
211
+ json.id = `ui-comp-${componentIndex}-${Date.now()}`;
212
+ }
213
+ components.push(json);
214
+ componentIndex++;
215
+ } catch (e) {
216
+ console.error("Invalid ui-component JSON:", e, block);
217
+ }
218
+ cleaned = cleaned.replace(match[0], "").trim();
219
+ }
220
+ return { text: cleaned, components };
221
+ };
222
+ const instructions = `You are Aizek, an AI assistant running in an environment with Model Context Protocol (MCP) tools.
223
+
224
+ Your top priority is to USE MCP TOOLS whenever they can handle the user's request.
225
+ Do NOT bypass available tools to answer from generic knowledge, web browsing, or other external sources if a suitable MCP tool exists.
226
+
227
+ ==================================================
228
+ 1. GENERAL BEHAVIOR
229
+ ==================================================
230
+
231
+ - Default language: reply in the same language as the user (Turkish/English).
232
+ - Be concise and task-focused. Avoid small talk, philosophy, or meta-chat unless the user explicitly asks.
233
+ - Do not invent capabilities or tools that are not actually defined in the MCP tool list.
234
+ - If a tool call fails or returns an error, explain briefly and either:
235
+ - try again with a corrected call, or
236
+ - ask the user for the minimal extra info required.
237
+
238
+ ==================================================
239
+ 2. MCP TOOL PRIORITY RULES
240
+ ==================================================
241
+
242
+ ALWAYS prefer MCP tools over any other strategy WHEN:
243
+
244
+ - The user asks for information that matches a tool's domain (weather, products, etc.).
245
+ - The user asks to perform an action (create/update/delete something) that an MCP tool can perform.
246
+
247
+ Only if NO provided MCP tool is relevant may you fall back to:
248
+ 1) other tools such as web/browsing, or
249
+ 2) your own internal knowledge.
125
250
 
126
- Your task:
127
- - Read the user message and respond.
128
- - Render your response as a small HTML layout (card OR table OR mini-table).
129
- - Use inline CSS styles.
130
- - Use a clean, light (white-based) theme.
131
- - Use branding and colors from options.config.
132
- - Return ONLY raw HTML (no markdown, no backticks, no JSON, no explanations).
251
+ When deciding whether a tool is relevant:
252
+ - Read the tool name, description, and parameters.
253
+ - If it is even moderately related to what the user wants, you SHOULD try using it.
254
+ - Do NOT choose external (e.g., MGM, random APIs) sources when a matching MCP tool exists.
133
255
 
134
- ====================
135
- THEME & BRANDING (from options.config)
136
- ====================
137
- The chat widget configuration provides:
256
+ If multiple tools could work:
257
+ - Choose the single BEST-FIT tool first.
258
+ - If the task clearly requires multiple tools (e.g., get weather then log it), you may call them sequentially.
138
259
 
139
- - Header Background Color: ${headerColor}
140
- - Button / Accent Color: ${accentColor}
141
- - Company Name: ${companyName}
142
- - Company Logo: ${companyLogo}
260
+ ==================================================
261
+ 3. ACTION TOOLS VS. DRAFTS (IKAS MCP, PRODUCT CREATION)
262
+ ==================================================
143
263
 
144
- How to use these:
145
- - Use Header Background Color mainly for top headers, title strips, or main highlight areas.
146
- - Use Button / Accent Color for important accents: borders, highlights, small badges, table headers, key text highlights, links, etc.
147
- - Use a white or very light background for main surfaces.
148
- - Text color should generally be dark (#111\u2013#333) for readability.
264
+ Some MCP tools can PERFORM REAL ACTIONS (e.g., create a product in an e-commerce system via ikas MCP).
149
265
 
150
- Do NOT create real interactive buttons. You can visually style elements using the accent color, but you must NOT use <button>.
266
+ Critical rule:
267
+ - If the user's intent is to PERFORM an action, you MUST call the appropriate tool.
268
+ - Do NOT just "simulate" the action or write a draft object.
269
+ - Do NOT stop at: "Burada \u015F\xF6yle bir \xFCr\xFCn olu\u015Fturabilirim..." and then not call the tool.
270
+ - The goal is that the side effect actually happens through the tool.
151
271
 
152
- ====================
153
- ALLOWED / FORBIDDEN TAGS
154
- ====================
155
- You may use ANY NON-INTERACTIVE HTML element, for example:
156
- - Text and headings:
157
- <h1>, <h2>, <h3>, <h4>, <h5>, <h6>,
158
- <p>, <span>, <strong>, <em>, <small>, <blockquote>, <code>, <pre>
159
- - Layout:
160
- <div>, <section>, <article>, <header>, <footer>
161
- - Lists:
162
- <ul>, <ol>, <li>
163
- - Tables:
164
- <table>, <thead>, <tbody>, <tr>, <th>, <td>
165
- - Media:
166
- <img>, <figure>, <figcaption>
167
- - Links (non-interactive navigation style only):
168
- <a>
272
+ Examples (Turkish / ikas):
169
273
 
170
- FORBIDDEN (NEVER USE):
171
- - <button>, <input>, <textarea>, <select>, <option>, <form>, <label>
172
- - <details>, <summary>, <dialog>
173
- - <video> or <audio> with controls for user interaction
174
- - Any inline event handlers like onclick, onmouseover, etc.
175
- - <script> or any JavaScript code.
274
+ 1) User:
275
+ "\u0130kas'ta yeni bir \xFCr\xFCn olu\u015Ftur:
276
+ isim: Siyah T-Shirt,
277
+ fiyat: 299 TL,
278
+ stok: 50,
279
+ kategori: Ti\u015F\xF6rtler."
176
280
 
177
- ====================
178
- LAYOUT TYPE RULES
179
- ====================
180
- You have exactly THREE layout types you can use:
281
+ \u2192 You MUST:
282
+ - Map these fields to the ikas product-creation tool schema.
283
+ - CALL the ikas MCP tool to actually create the product.
284
+ - Then answer with something like:
285
+ "\xDCr\xFCn ba\u015Far\u0131yla olu\u015Fturuldu. ID: <tool_output_id>, ad: Siyah T-Shirt, fiyat: 299 TL, stok: 50."
181
286
 
182
- 1) CARD
183
- 2) TABLE
184
- 3) MINI TABLE
287
+ \u2192 You MUST NOT:
288
+ - Only respond with a JSON draft or description like:
289
+ "\u015E\xF6yle bir taslak \xFCr\xFCn olu\u015Fturabilirsin: {...}"
290
+ without calling the tool.
185
291
 
186
- For EACH response:
187
- - You MUST choose exactly ONE of these layout types.
188
- - You MUST NOT mix layout types in the same response.
189
- (Do NOT render card + table together, or table + mini-table together.)
292
+ 2) If the tool requires fields that the user didn't provide (e.g. currency code, SKU):
293
+ - Ask ONLY the minimal clarifying question needed.
294
+ - Or, if the field is safely inferrable by convention (e.g. default currency for a given store), use the default.
190
295
 
191
- Which layout to choose:
192
- - CARD (DEFAULT):
193
- - Use this for normal answers, explanations, descriptions, welcome messages,
194
- and any content that is mostly free text.
195
- - TABLE:
196
- - Use this ONLY when the content is clearly structured with multiple columns
197
- (for example: comparisons, lists of items with several attributes).
198
- - MINI TABLE:
199
- - Use this for small, compact key-value style data
200
- (for example: a few fields like "Token", "Price", "Network"),
201
- or when a full table would be visually too heavy.
296
+ 3) If the tool response indicates "draft" vs. "published" status:
297
+ - Respect the user's explicit intention.
298
+ - If the user says "taslak olarak kaydet", then request draft=true.
299
+ - If the user says "direkt yay\u0131na al" or clearly wants the product live, then request published/active status.
300
+ - Do NOT downgrade a clear "publish" intent into just a draft.
202
301
 
203
- If the user does NOT explicitly ask for a table or very structured data,
204
- you MUST use the CARD layout.
302
+ ==================================================
303
+ 4. INTERPRETING USER INTENT
304
+ ==================================================
205
305
 
206
- ====================
207
- STYLE RULES
208
- ====================
209
- General style (CARD or container):
210
- - Use a main wrapper <div> with styles similar to:
211
- background: #ffffff;
212
- color: #111111;
213
- border: 1px solid #e5e5e5;
214
- border-radius: 8px;
215
- padding: 12px;
216
- font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
217
- - You may add a top header area using the header background color:
218
- background: ${headerColor};
306
+ - Treat verbs like "olu\u015Ftur", "yarat", "ekle", "sil", "g\xFCncelle", "publish et", "yay\u0131na al"
307
+ as strong indicators that an ACTION tool call is expected, not just text output.
219
308
 
220
- Use branding:
221
- - Include the company logo and name in a subtle way when appropriate
222
- (for example, in a small header bar):
223
- - Logo (emoji or image) on the left,
224
- - Company name text next to it.
309
+ - Treat questions like "nas\u0131l yap\u0131l\u0131r?", "bana g\xF6ster", "\xF6rnek ver", "JSON tasla\u011F\u0131 olu\u015Ftur"
310
+ as more educational; then you may provide drafts/examples without executing tools,
311
+ UNLESS the user explicitly says they want the real action too.
225
312
 
226
- Typography:
227
- - Titles: 18\u201322px, bold.
228
- - Body text: 12\u201316px, regular.
229
- - Line-height should be comfortable (around 1.4\u20131.6).
313
+ Examples:
230
314
 
231
- Tables:
232
- - Use <table> with <thead> and <tbody> where appropriate.
233
- - Header row background: ${accentColor};
234
- - Header row text color: #ffffff;
235
- - Body rows background: #ffffff;
236
- - Row borders: 1px solid #e5e5e5 (or a faint version of the border color).
315
+ - "\u0130kas'ta \xFCr\xFCn olu\u015Fturmay\u0131 bana JSON \xF6rne\u011Fiyle anlat\u0131r m\u0131s\u0131n?"
316
+ \u2192 Explain the schema, show a draft, you may skip real tool call unless they also say "ve bunu benim i\xE7in \u015Fimdi olu\u015Ftur."
237
317
 
238
- Mini table:
239
- - Can be a simple two-column table or stacked key-value pairs.
240
- - Keep it compact (less padding, fewer rows).
318
+ - "Benim ad\u0131ma bu \xFCr\xFCn\xFC ger\xE7ekten olu\u015Ftur ve yay\u0131na al."
319
+ \u2192 This MUST trigger the actual ikas MCP product-creation tool call.
241
320
 
242
- Links:
243
- - You can use <a> for styling or static URLs.
244
- - Use the accent color for links:
245
- color: ${accentColor};
321
+ ==================================================
322
+ 5. IRRELEVANT TOPICS & SCOPE
323
+ ==================================================
246
324
 
247
- ====================
248
- OUTPUT FORMAT
249
- ====================
250
- Your final output MUST follow these rules:
251
- - Output ONLY a single HTML snippet.
252
- - Do NOT wrap it in backticks or markdown.
253
- - Do NOT include any explanation text.
254
- - Do NOT include JSON.
255
- - Must use exactly ONE of: card, table, mini table.
256
- - Must respect allowed/forbidden tags.
257
- - Must use colors derived from:
258
- - header_background
259
- - button_background
260
- and otherwise a light theme.
325
+ - Aizek's primary job in this environment is:
326
+ - Using MCP tools effectively (weather, e-commerce, etc.).
327
+ - Providing concise, helpful answers strictly related to the user's requests.
261
328
 
262
- ====================
263
- BEHAVIOR SUMMARY
264
- ====================
265
- 1) Read the user message.
266
- 2) Decide whether CARD, TABLE, or MINI TABLE is most suitable.
267
- 3) Generate a single HTML layout using only allowed, non-interactive tags.
268
- 4) Style the layout with inline CSS using:
269
- - ${headerColor} for header areas,
270
- - ${accentColor} for accents,
271
- - white/light backgrounds and dark text.
272
- 5) Return ONLY the HTML snippet.
329
+ - Avoid:
330
+ - Long off-topic chats.
331
+ - Unnecessary explanations of MCP internals or tool schemas unless the user specifically asks.
332
+ - Using random non-MCP APIs or external services when an MCP tool already exists in that domain.
333
+
334
+ ==================================================
335
+ 6. TOOL-CALLING STYLE
336
+ ==================================================
337
+
338
+ When you decide to call a tool:
339
+ - Use the exact tool name and parameter schema given by the environment.
340
+ - Provide all required parameters; do NOT omit fields the schema marks as required.
341
+ - Prefer a single well-structured call over multiple fragmented ones whenever possible.
342
+
343
+ Once you receive tool results:
344
+ - Summarize them clearly for the user in natural language.
345
+ - If the user requested an action (e.g., create product, update something), confirm:
346
+ - What was done,
347
+ - Any IDs or references returned,
348
+ - Any next steps they might need.
349
+
350
+ ==================================================
351
+ 7. FALLBACK LOGIC
352
+ ==================================================
353
+
354
+ In this order of priority:
355
+
356
+ 1) If an MCP tool matches the user's request \u2192 USE IT.
357
+ 2) If no tool fits, and the user just needs information \u2192 answer from your own knowledge or other allowed tools.
358
+ 3) If the user asks something completely outside your domain/scope \u2192
359
+ - Briefly explain that it is outside Aizek's scope or that you have limited info,
360
+ - Offer to help only if you can still add value without contradicting previous rules.
361
+
362
+ Always keep in mind:
363
+ Your core value in this environment is to be an intelligent router and operator for MCP tools, not a generic, unconstrained chatbot.`;
364
+ const SYSTEM_PROMPT = `
365
+ You are a helpful assistant that can generate both natural language responses and UI components.
366
+
367
+ You MUST:
368
+ - Always respond with normal conversational text.
369
+ - Optionally include one or more UI components inside code blocks with language "ui-component".
370
+
371
+ When to use components:
372
+ - User needs to provide multiple structured values \u2192 generate a FORM
373
+ - User must choose among options \u2192 generate BUTTONS
374
+ - User must see structured data comparison \u2192 generate a TABLE
375
+ - User must see entity details/summary \u2192 generate a CARD
376
+
377
+ Format for each component (strictly):
378
+
379
+ \`\`\`ui-component
380
+ {
381
+ "type": "form" | "buttons" | "table" | "card",
382
+ "data": { ...component-specific fields... }
383
+ }
384
+ \`\`\`
385
+
386
+ IMPORTANT:
387
+ - Do NOT invent HTML. Only JSON as described.
388
+ - Keep JSON strictly valid.
389
+ - Text response should be outside of code blocks.
273
390
  `;
274
- };
275
- const sendMessage = async (message) => {
391
+ const sendMessage = async (message, approval) => {
276
392
  if (!message.trim() || isLoading) return;
277
- addMessage(message, "user");
393
+ if (approval) {
394
+ addMessage({ text: message }, "approval");
395
+ } else {
396
+ addMessage({ text: message }, "user");
397
+ }
278
398
  setIsLoading(true);
279
- console.log(options.config);
280
399
  try {
281
400
  let resp;
282
- console.log(options.headers);
283
401
  resp = await client.responses.create({
284
402
  model: "gpt-5",
285
403
  tools: [
@@ -291,35 +409,45 @@ BEHAVIOR SUMMARY
291
409
  headers: options.headers || {}
292
410
  }
293
411
  ],
294
- input: message,
412
+ input: [
413
+ { role: "system", content: SYSTEM_PROMPT },
414
+ { role: "user", content: message }
415
+ ],
295
416
  previous_response_id: responseId || void 0,
296
- instructions: getHtmlUiInstructions(options.config)
417
+ instructions
297
418
  });
419
+ console.log("Response:", resp);
298
420
  setResponseId(resp.id);
299
- let responseText = "";
300
- if (resp && Array.isArray(resp)) {
301
- const messageItem = resp.find((item) => item.type === "message");
302
- if (messageItem && messageItem.content && Array.isArray(messageItem.content)) {
303
- const textContent = messageItem.content.find((content) => content.type === "output_text");
304
- if (textContent && textContent.text) {
305
- responseText = textContent.text;
421
+ let rawText = "";
422
+ const output = resp.output;
423
+ if (Array.isArray(output) && output.length > 0) {
424
+ const assistantMsg = output.find((o) => o.role === "assistant") ?? output[0];
425
+ if (assistantMsg && Array.isArray(assistantMsg.content)) {
426
+ const textItem = assistantMsg.content.find(
427
+ (c) => c.type === "output_text"
428
+ );
429
+ if (textItem?.text?.value) {
430
+ rawText = textItem.text.value;
431
+ } else if (textItem?.text?.annotations?.[0]?.text) {
432
+ rawText = textItem.text.annotations[0].text;
306
433
  }
307
434
  }
308
- } else {
309
- if (resp && resp.output_text) {
310
- responseText = resp.output_text;
311
- } else if (typeof resp === "string") {
312
- responseText = resp;
313
- }
314
435
  }
315
- if (!responseText) {
316
- responseText = `"${message}" mesaj\u0131n\u0131z\u0131 ald\u0131m. Size nas\u0131l yard\u0131mc\u0131 olabilirim?`;
436
+ if (!rawText && resp.output_text) {
437
+ rawText = resp.output_text;
438
+ }
439
+ if (!rawText) {
440
+ rawText = `"${message}" mesaj\u0131n\u0131z\u0131 ald\u0131m. Size nas\u0131l yard\u0131mc\u0131 olabilirim?`;
317
441
  }
318
- addMessage(responseText, "assistant");
442
+ const { text, components } = extractUiComponents(rawText);
443
+ addMessage({ text, ui: components }, "assistant");
319
444
  setIsLoading(false);
320
445
  } catch (error) {
321
446
  console.error("Error sending message:", error);
322
- addMessage("\xDCzg\xFCn\xFCm, bir hata olu\u015Ftu. L\xFCtfen tekrar deneyin.", "assistant");
447
+ addMessage(
448
+ { text: "\xDCzg\xFCn\xFCm, bir hata olu\u015Ftu. L\xFCtfen tekrar deneyin." },
449
+ "assistant"
450
+ );
323
451
  setIsLoading(false);
324
452
  }
325
453
  };
@@ -332,7 +460,7 @@ BEHAVIOR SUMMARY
332
460
  };
333
461
 
334
462
  // src/services/chatWidgetApi.ts
335
- var API_BASE_URL = "https://api.elviz24.com";
463
+ var API_BASE_URL = "https://api-alpha.aizek.ai";
336
464
  var fetchChatWidgetSettings = async (clientId) => {
337
465
  try {
338
466
  const response = await fetch(`${API_BASE_URL}/ChatWidgetSettings/GetByClientId?client_id=${clientId}`, {
@@ -345,7 +473,6 @@ var fetchChatWidgetSettings = async (clientId) => {
345
473
  throw new Error(`HTTP error! status: ${response.status}`);
346
474
  }
347
475
  const data = await response.json();
348
- console.log(data);
349
476
  return data;
350
477
  } catch (error) {
351
478
  console.error("Error fetching chat widget settings:", error);
@@ -378,7 +505,7 @@ var mapApiSettingsToConfig = (apiSettings) => {
378
505
  };
379
506
 
380
507
  // src/styles/messageStyles.ts
381
- var getMessageBubbleStyles = (isUser) => ({
508
+ var getMessageBubbleStyles = (isUser, isTyping) => ({
382
509
  maxWidth: "80%",
383
510
  padding: "12px 16px",
384
511
  borderRadius: isUser ? "18px 18px 4px 18px" : "18px 18px 18px 4px",
@@ -407,7 +534,8 @@ var getTimeStyles = (isUser) => ({
407
534
  textAlign: isUser ? "right" : "left"
408
535
  });
409
536
  var getMarkdownStyles = () => ({
410
- lineHeight: 1.6
537
+ lineHeight: 1.6,
538
+ marginBottom: "6px"
411
539
  });
412
540
  var getMarkdownElementStyles = (isUser) => `
413
541
  .markdown-content p {
@@ -854,7 +982,905 @@ var getAlertAnimationStyles = () => `
854
982
  }
855
983
  }
856
984
  `;
857
- var AizekChatBot = ({ clientId, headers }) => {
985
+ function UIRenderer({ components, onInteraction }) {
986
+ console.log(components);
987
+ if (!Array.isArray(components) || components.length === 0) {
988
+ return null;
989
+ }
990
+ return /* @__PURE__ */ jsx(
991
+ "div",
992
+ {
993
+ style: {
994
+ display: "flex",
995
+ flexDirection: "column",
996
+ gap: "16px",
997
+ width: "100%"
998
+ },
999
+ children: components.map((comp, idx) => {
1000
+ if (!comp || typeof comp !== "object" || !comp.type) {
1001
+ return null;
1002
+ }
1003
+ const key = typeof comp.id === "string" && comp.id.trim() ? comp.id : `${comp.type}-${idx}`;
1004
+ switch (comp.type) {
1005
+ case "form":
1006
+ return /* @__PURE__ */ jsx(
1007
+ FormComponent,
1008
+ {
1009
+ data: comp.data,
1010
+ onSubmit: (values) => onInteraction?.({
1011
+ type: "formSubmit",
1012
+ componentId: comp.data.id,
1013
+ values
1014
+ })
1015
+ },
1016
+ key
1017
+ );
1018
+ case "buttons":
1019
+ if (!comp.data || !Array.isArray(comp.data)) {
1020
+ return null;
1021
+ }
1022
+ return /* @__PURE__ */ jsx(
1023
+ ButtonsComponent,
1024
+ {
1025
+ data: comp.data,
1026
+ onClick: (value) => onInteraction?.({ type: "buttonClick", value })
1027
+ },
1028
+ key
1029
+ );
1030
+ case "table":
1031
+ return /* @__PURE__ */ jsx(TableComponent, { data: comp.data }, key);
1032
+ case "card":
1033
+ return /* @__PURE__ */ jsx(CardComponent, { data: comp.data }, key);
1034
+ default:
1035
+ return null;
1036
+ }
1037
+ })
1038
+ }
1039
+ );
1040
+ }
1041
+ function FormComponent({
1042
+ data,
1043
+ onSubmit
1044
+ }) {
1045
+ const handleSubmit = (e) => {
1046
+ e.preventDefault();
1047
+ console.log(e.currentTarget);
1048
+ const formData = new FormData(e.currentTarget);
1049
+ console.log(formData);
1050
+ const values = {};
1051
+ data.fields.forEach((f) => {
1052
+ values[f.id || f.name] = String(formData.get(f.id || f.name) ?? "");
1053
+ });
1054
+ onSubmit(values);
1055
+ };
1056
+ console.log("formdata", data);
1057
+ return /* @__PURE__ */ jsxs(
1058
+ "form",
1059
+ {
1060
+ onSubmit: handleSubmit,
1061
+ style: {
1062
+ width: "100%",
1063
+ maxWidth: "500px",
1064
+ border: "1px solid #e0e0e0",
1065
+ borderRadius: "12px",
1066
+ padding: "24px",
1067
+ backgroundColor: "#ffffff",
1068
+ boxShadow: "0 2px 8px rgba(0, 0, 0, 0.08)",
1069
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'
1070
+ },
1071
+ children: [
1072
+ data.title && /* @__PURE__ */ jsx(
1073
+ "h3",
1074
+ {
1075
+ style: {
1076
+ fontWeight: 600,
1077
+ fontSize: "16px",
1078
+ marginBottom: "20px",
1079
+ color: "#1a1a1a",
1080
+ marginTop: 0
1081
+ },
1082
+ children: data.title
1083
+ }
1084
+ ),
1085
+ /* @__PURE__ */ jsx(
1086
+ "div",
1087
+ {
1088
+ style: {
1089
+ display: "flex",
1090
+ flexDirection: "column",
1091
+ gap: "20px"
1092
+ },
1093
+ children: data.fields.map((field, fieldIdx) => {
1094
+ const fieldKey = typeof field.id === "string" && field.id.trim() ? field.id : `field-${fieldIdx}`;
1095
+ return /* @__PURE__ */ jsxs(
1096
+ "div",
1097
+ {
1098
+ style: {
1099
+ display: "flex",
1100
+ flexDirection: "column",
1101
+ gap: "8px"
1102
+ },
1103
+ children: [
1104
+ /* @__PURE__ */ jsxs(
1105
+ "label",
1106
+ {
1107
+ style: {
1108
+ fontWeight: 500,
1109
+ fontSize: "13px",
1110
+ color: "#374151",
1111
+ display: "flex",
1112
+ alignItems: "center",
1113
+ gap: "4px"
1114
+ },
1115
+ children: [
1116
+ field.label,
1117
+ field.required && /* @__PURE__ */ jsx("span", { style: { color: "#ef4444", fontSize: "14px" }, children: "*" })
1118
+ ]
1119
+ }
1120
+ ),
1121
+ field.type === "select" ? /* @__PURE__ */ jsxs(
1122
+ "select",
1123
+ {
1124
+ name: field.id || field.name,
1125
+ required: field.required,
1126
+ defaultValue: field.value ? String(field.value) : "",
1127
+ style: {
1128
+ border: "1px solid #d1d5db",
1129
+ borderRadius: "8px",
1130
+ padding: "10px 12px",
1131
+ fontSize: "13px",
1132
+ color: "#1a1a1a",
1133
+ backgroundColor: "#ffffff",
1134
+ fontFamily: "inherit",
1135
+ outline: "none",
1136
+ transition: "border-color 0.15s ease, box-shadow 0.15s ease",
1137
+ cursor: "pointer"
1138
+ },
1139
+ onFocus: (e) => {
1140
+ e.currentTarget.style.borderColor = "#3b82f6";
1141
+ e.currentTarget.style.boxShadow = "0 0 0 3px rgba(59, 130, 246, 0.1)";
1142
+ },
1143
+ onBlur: (e) => {
1144
+ e.currentTarget.style.borderColor = "#d1d5db";
1145
+ e.currentTarget.style.boxShadow = "none";
1146
+ },
1147
+ children: [
1148
+ /* @__PURE__ */ jsx("option", { value: "", children: "Se\xE7iniz" }),
1149
+ field.options?.map((opt, optIdx) => {
1150
+ const optKey = typeof opt.value === "string" ? opt.value : `opt-${fieldIdx}-${optIdx}`;
1151
+ return /* @__PURE__ */ jsx("option", { value: opt.value, children: opt.label }, optKey);
1152
+ })
1153
+ ]
1154
+ }
1155
+ ) : /* @__PURE__ */ jsx(
1156
+ "input",
1157
+ {
1158
+ type: field.type === "number" ? "number" : "text",
1159
+ name: field.id || field.name,
1160
+ required: field.required,
1161
+ defaultValue: field.value ? String(field.value) : "",
1162
+ placeholder: field.placeholder || "",
1163
+ min: field.min,
1164
+ max: field.max,
1165
+ style: {
1166
+ border: "1px solid #d1d5db",
1167
+ borderRadius: "8px",
1168
+ padding: "10px 12px",
1169
+ fontSize: "13px",
1170
+ color: "#1a1a1a",
1171
+ backgroundColor: "#ffffff",
1172
+ fontFamily: "inherit",
1173
+ outline: "none",
1174
+ transition: "border-color 0.15s ease, box-shadow 0.15s ease"
1175
+ },
1176
+ onFocus: (e) => {
1177
+ e.currentTarget.style.borderColor = "#3b82f6";
1178
+ e.currentTarget.style.boxShadow = "0 0 0 3px rgba(59, 130, 246, 0.1)";
1179
+ },
1180
+ onBlur: (e) => {
1181
+ e.currentTarget.style.borderColor = "#d1d5db";
1182
+ e.currentTarget.style.boxShadow = "none";
1183
+ }
1184
+ }
1185
+ )
1186
+ ]
1187
+ },
1188
+ fieldKey
1189
+ );
1190
+ })
1191
+ }
1192
+ ),
1193
+ /* @__PURE__ */ jsx(
1194
+ "button",
1195
+ {
1196
+ type: "submit",
1197
+ style: {
1198
+ marginTop: "24px",
1199
+ display: "inline-flex",
1200
+ alignItems: "center",
1201
+ justifyContent: "center",
1202
+ borderRadius: "8px",
1203
+ padding: "12px 24px",
1204
+ fontSize: "13px",
1205
+ fontWeight: 500,
1206
+ backgroundColor: "#3b82f6",
1207
+ color: "#ffffff",
1208
+ border: "none",
1209
+ cursor: "pointer",
1210
+ transition: "background-color 0.15s ease, transform 0.1s ease",
1211
+ fontFamily: "inherit"
1212
+ },
1213
+ onMouseEnter: (e) => {
1214
+ e.currentTarget.style.backgroundColor = "#2563eb";
1215
+ },
1216
+ onMouseLeave: (e) => {
1217
+ e.currentTarget.style.backgroundColor = "#3b82f6";
1218
+ },
1219
+ onMouseDown: (e) => {
1220
+ e.currentTarget.style.transform = "scale(0.98)";
1221
+ },
1222
+ onMouseUp: (e) => {
1223
+ e.currentTarget.style.transform = "scale(1)";
1224
+ },
1225
+ children: data.submitLabel ?? "G\xF6nder"
1226
+ }
1227
+ )
1228
+ ]
1229
+ }
1230
+ );
1231
+ }
1232
+ function ButtonsComponent({
1233
+ data,
1234
+ onClick
1235
+ }) {
1236
+ if (!Array.isArray(data) || data.length === 0) {
1237
+ return null;
1238
+ }
1239
+ const getButtonStyles = (variant) => {
1240
+ const baseStyles = {
1241
+ borderRadius: "8px",
1242
+ padding: "10px 20px",
1243
+ fontSize: "13px",
1244
+ fontWeight: 500,
1245
+ border: "1px solid #e0e0e0",
1246
+ backgroundColor: "#ffffff",
1247
+ color: "#374151",
1248
+ cursor: "pointer",
1249
+ transition: "all 0.15s ease",
1250
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
1251
+ outline: "none"
1252
+ };
1253
+ if (variant === "primary") {
1254
+ return {
1255
+ ...baseStyles,
1256
+ backgroundColor: "#3b82f6",
1257
+ color: "#ffffff",
1258
+ borderColor: "#3b82f6"
1259
+ };
1260
+ } else if (variant === "secondary") {
1261
+ return {
1262
+ ...baseStyles,
1263
+ backgroundColor: "#f3f4f6",
1264
+ color: "#374151",
1265
+ borderColor: "#d1d5db"
1266
+ };
1267
+ } else if (variant === "danger") {
1268
+ return {
1269
+ ...baseStyles,
1270
+ backgroundColor: "#ef4444",
1271
+ color: "#ffffff",
1272
+ borderColor: "#ef4444"
1273
+ };
1274
+ }
1275
+ return baseStyles;
1276
+ };
1277
+ const getHoverStyles = (variant) => {
1278
+ if (variant === "primary") {
1279
+ return { backgroundColor: "#2563eb", borderColor: "#2563eb" };
1280
+ } else if (variant === "secondary") {
1281
+ return { backgroundColor: "#e5e7eb", borderColor: "#9ca3af" };
1282
+ } else if (variant === "danger") {
1283
+ return { backgroundColor: "#dc2626", borderColor: "#dc2626" };
1284
+ }
1285
+ return { backgroundColor: "#f9fafb", borderColor: "#d1d5db" };
1286
+ };
1287
+ return /* @__PURE__ */ jsx(
1288
+ "div",
1289
+ {
1290
+ style: {
1291
+ display: "flex",
1292
+ gap: "12px",
1293
+ flexWrap: "wrap"
1294
+ },
1295
+ children: data.map((btn, idx) => {
1296
+ if (!btn || typeof btn !== "object") {
1297
+ return null;
1298
+ }
1299
+ const btnValue = typeof btn.value === "string" ? btn.value : typeof btn.value === "number" ? String(btn.value) : btn.value && typeof btn.value === "object" ? JSON.stringify(btn.value) : `btn-value-${idx}`;
1300
+ const btnKey = typeof btn.value === "string" && btn.value.trim() ? btn.value : `btn-${idx}`;
1301
+ const btnLabel = btn.label || `Button ${idx + 1}`;
1302
+ const buttonStyles = getButtonStyles(btn.variant);
1303
+ const hoverStyles = getHoverStyles(btn.variant);
1304
+ return /* @__PURE__ */ jsx(
1305
+ "button",
1306
+ {
1307
+ onClick: () => {
1308
+ try {
1309
+ onClick(btnValue);
1310
+ } catch (error) {
1311
+ console.error("Error in button onClick:", error);
1312
+ }
1313
+ },
1314
+ style: buttonStyles,
1315
+ onMouseEnter: (e) => {
1316
+ Object.assign(e.currentTarget.style, hoverStyles);
1317
+ },
1318
+ onMouseLeave: (e) => {
1319
+ Object.assign(e.currentTarget.style, buttonStyles);
1320
+ },
1321
+ onMouseDown: (e) => {
1322
+ e.currentTarget.style.transform = "scale(0.97)";
1323
+ },
1324
+ onMouseUp: (e) => {
1325
+ e.currentTarget.style.transform = "scale(1)";
1326
+ },
1327
+ children: btnLabel
1328
+ },
1329
+ btnKey
1330
+ );
1331
+ })
1332
+ }
1333
+ );
1334
+ }
1335
+ function TableComponent({ data }) {
1336
+ if (!data.columns || !Array.isArray(data.columns) || data.columns.length === 0) {
1337
+ return null;
1338
+ }
1339
+ return /* @__PURE__ */ jsxs(
1340
+ "div",
1341
+ {
1342
+ style: {
1343
+ border: "1px solid #e0e0e0",
1344
+ borderRadius: "12px",
1345
+ overflow: "hidden",
1346
+ fontSize: "13px",
1347
+ backgroundColor: "#ffffff",
1348
+ boxShadow: "0 2px 8px rgba(0, 0, 0, 0.08)",
1349
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'
1350
+ },
1351
+ children: [
1352
+ data.caption && /* @__PURE__ */ jsx(
1353
+ "div",
1354
+ {
1355
+ style: {
1356
+ padding: "16px 20px",
1357
+ fontWeight: 600,
1358
+ fontSize: "14px",
1359
+ borderBottom: "1px solid #e0e0e0",
1360
+ backgroundColor: "#f8f9fa",
1361
+ color: "#1a1a1a"
1362
+ },
1363
+ children: data.caption
1364
+ }
1365
+ ),
1366
+ /* @__PURE__ */ jsx("div", { style: { overflowX: "auto" }, children: /* @__PURE__ */ jsxs(
1367
+ "table",
1368
+ {
1369
+ style: {
1370
+ width: "100%",
1371
+ borderCollapse: "collapse",
1372
+ minWidth: "100%"
1373
+ },
1374
+ children: [
1375
+ /* @__PURE__ */ jsx("thead", { style: { backgroundColor: "#f8f9fa" }, children: /* @__PURE__ */ jsx("tr", { children: data.columns.map((col, i) => {
1376
+ const colKey = typeof col === "string" ? `col-${i}` : col.key || col.id || `col-${i}`;
1377
+ const colLabel = typeof col === "string" ? col : col.label || "";
1378
+ return /* @__PURE__ */ jsx(
1379
+ "th",
1380
+ {
1381
+ style: {
1382
+ borderBottom: "2px solid #e0e0e0",
1383
+ padding: "14px 20px",
1384
+ textAlign: "left",
1385
+ fontWeight: 600,
1386
+ fontSize: "12px",
1387
+ color: "#4a5568",
1388
+ textTransform: "uppercase",
1389
+ letterSpacing: "0.5px",
1390
+ whiteSpace: "nowrap"
1391
+ },
1392
+ children: colLabel
1393
+ },
1394
+ colKey
1395
+ );
1396
+ }) }) }),
1397
+ /* @__PURE__ */ jsx("tbody", { children: data.rows && data.rows.length > 0 ? data.rows.map((row, rowIdx) => /* @__PURE__ */ jsx(
1398
+ "tr",
1399
+ {
1400
+ style: {
1401
+ backgroundColor: rowIdx % 2 === 0 ? "#ffffff" : "#fafbfc",
1402
+ transition: "background-color 0.15s ease"
1403
+ },
1404
+ onMouseEnter: (e) => {
1405
+ e.currentTarget.style.backgroundColor = "#f0f4f8";
1406
+ },
1407
+ onMouseLeave: (e) => {
1408
+ e.currentTarget.style.backgroundColor = rowIdx % 2 === 0 ? "#ffffff" : "#fafbfc";
1409
+ },
1410
+ children: data.columns.map((col, colIdx) => {
1411
+ const colKey = typeof col === "string" ? `col-${colIdx}` : col.key || col.id || `col-${colIdx}`;
1412
+ const colType = typeof col === "object" ? col.type : void 0;
1413
+ const cellKey = `cell-${rowIdx}-${colIdx}`;
1414
+ let cellContent = null;
1415
+ if (typeof row === "object" && row !== null && !Array.isArray(row)) {
1416
+ const cellValue = row[colKey];
1417
+ if (cellValue !== void 0 && cellValue !== null) {
1418
+ if (typeof cellValue === "object" && "type" in cellValue) {
1419
+ cellContent = renderField(cellValue);
1420
+ } else {
1421
+ const stringValue = String(cellValue);
1422
+ const isImageUrl = typeof stringValue === "string" && (stringValue.startsWith("http") || stringValue.startsWith("data:") || stringValue.startsWith("/")) && (stringValue.match(
1423
+ /\.(jpg|jpeg|png|gif|webp|svg)$/i
1424
+ ) || stringValue.includes("image") || stringValue.includes("avatar"));
1425
+ if (colType === "image" || !colType && isImageUrl) {
1426
+ cellContent = /* @__PURE__ */ jsx(
1427
+ "div",
1428
+ {
1429
+ style: {
1430
+ display: "flex",
1431
+ alignItems: "center"
1432
+ },
1433
+ children: /* @__PURE__ */ jsx(
1434
+ "img",
1435
+ {
1436
+ src: stringValue,
1437
+ alt: "",
1438
+ style: {
1439
+ width: "40px",
1440
+ height: "40px",
1441
+ borderRadius: "8px",
1442
+ objectFit: "cover",
1443
+ border: "1px solid #e0e0e0"
1444
+ },
1445
+ onError: (e) => {
1446
+ e.target.style.display = "none";
1447
+ }
1448
+ }
1449
+ )
1450
+ }
1451
+ );
1452
+ } else {
1453
+ cellContent = /* @__PURE__ */ jsx(
1454
+ "span",
1455
+ {
1456
+ style: {
1457
+ color: "#2d3748",
1458
+ lineHeight: "1.5"
1459
+ },
1460
+ children: stringValue
1461
+ }
1462
+ );
1463
+ }
1464
+ }
1465
+ }
1466
+ } else if (Array.isArray(row)) {
1467
+ const cellValue = row[colIdx];
1468
+ if (cellValue !== void 0 && cellValue !== null) {
1469
+ const stringValue = String(cellValue);
1470
+ const isImageUrl = typeof stringValue === "string" && (stringValue.startsWith("http") || stringValue.startsWith("data:") || stringValue.startsWith("/")) && (stringValue.match(
1471
+ /\.(jpg|jpeg|png|gif|webp|svg)$/i
1472
+ ) || stringValue.includes("image") || stringValue.includes("avatar"));
1473
+ if (colType === "image" || !colType && isImageUrl) {
1474
+ cellContent = /* @__PURE__ */ jsx(
1475
+ "div",
1476
+ {
1477
+ style: { display: "flex", alignItems: "center" },
1478
+ children: /* @__PURE__ */ jsx(
1479
+ "img",
1480
+ {
1481
+ src: stringValue,
1482
+ alt: "",
1483
+ style: {
1484
+ width: "40px",
1485
+ height: "40px",
1486
+ borderRadius: "8px",
1487
+ objectFit: "cover",
1488
+ border: "1px solid #e0e0e0"
1489
+ },
1490
+ onError: (e) => {
1491
+ e.target.style.display = "none";
1492
+ }
1493
+ }
1494
+ )
1495
+ }
1496
+ );
1497
+ } else {
1498
+ cellContent = /* @__PURE__ */ jsx(
1499
+ "span",
1500
+ {
1501
+ style: {
1502
+ color: "#2d3748",
1503
+ lineHeight: "1.5"
1504
+ },
1505
+ children: stringValue
1506
+ }
1507
+ );
1508
+ }
1509
+ }
1510
+ }
1511
+ return /* @__PURE__ */ jsx(
1512
+ "td",
1513
+ {
1514
+ style: {
1515
+ borderBottom: "1px solid #e8e8e8",
1516
+ padding: "16px 20px",
1517
+ fontSize: "13px",
1518
+ verticalAlign: "middle"
1519
+ },
1520
+ children: cellContent || /* @__PURE__ */ jsx(
1521
+ "span",
1522
+ {
1523
+ style: { color: "#a0a0a0", fontStyle: "italic" },
1524
+ children: "\u2014"
1525
+ }
1526
+ )
1527
+ },
1528
+ cellKey
1529
+ );
1530
+ })
1531
+ },
1532
+ `row-${rowIdx}`
1533
+ )) : /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx(
1534
+ "td",
1535
+ {
1536
+ colSpan: data.columns.length,
1537
+ style: {
1538
+ padding: "40px",
1539
+ textAlign: "center",
1540
+ color: "#9ca3af",
1541
+ fontSize: "13px"
1542
+ },
1543
+ children: "Veri bulunamad\u0131"
1544
+ }
1545
+ ) }) })
1546
+ ]
1547
+ }
1548
+ ) })
1549
+ ]
1550
+ }
1551
+ );
1552
+ }
1553
+ function CardComponent({ data }) {
1554
+ if (data.title) {
1555
+ const hasImage = data.image && typeof data.image === "string";
1556
+ const hasFields = data.fields && Array.isArray(data.fields) && data.fields.length > 0;
1557
+ const hasAttributes = data.attributes && Array.isArray(data.attributes) && data.attributes.length > 0;
1558
+ const hasStatus = data.status && typeof data.status === "string";
1559
+ const hasSubtitle = data.subtitle && typeof data.subtitle === "string";
1560
+ const displayFields = hasAttributes ? data.attributes : hasFields ? data.fields : [];
1561
+ return /* @__PURE__ */ jsx(
1562
+ "div",
1563
+ {
1564
+ style: {
1565
+ border: "1px solid #e5e7eb",
1566
+ borderRadius: "16px",
1567
+ padding: "16px",
1568
+ backgroundColor: "#ffffff",
1569
+ boxShadow: "0 1px 3px 0 rgba(0, 0, 0, 0.1)",
1570
+ overflow: "hidden",
1571
+ marginBottom: "12px"
1572
+ },
1573
+ children: /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "12px" }, children: [
1574
+ hasImage && /* @__PURE__ */ jsx(
1575
+ "img",
1576
+ {
1577
+ src: data.image,
1578
+ alt: data.title || "Card image",
1579
+ style: {
1580
+ width: "64px",
1581
+ height: "64px",
1582
+ borderRadius: "8px",
1583
+ objectFit: "cover",
1584
+ flexShrink: 0
1585
+ },
1586
+ onError: (e) => {
1587
+ e.target.style.display = "none";
1588
+ }
1589
+ }
1590
+ ),
1591
+ /* @__PURE__ */ jsxs("div", { style: { flex: 1, minWidth: 0 }, children: [
1592
+ /* @__PURE__ */ jsx(
1593
+ "h4",
1594
+ {
1595
+ style: {
1596
+ fontWeight: 600,
1597
+ fontSize: "14px",
1598
+ marginBottom: "8px",
1599
+ overflow: "hidden",
1600
+ textOverflow: "ellipsis",
1601
+ whiteSpace: "nowrap"
1602
+ },
1603
+ children: data.title
1604
+ }
1605
+ ),
1606
+ hasStatus && /* @__PURE__ */ jsxs(
1607
+ "div",
1608
+ {
1609
+ style: {
1610
+ display: "flex",
1611
+ gap: "8px",
1612
+ fontSize: "12px",
1613
+ marginBottom: "4px"
1614
+ },
1615
+ children: [
1616
+ /* @__PURE__ */ jsx("span", { style: { color: "#6b7280", fontWeight: 500 }, children: "Durum:" }),
1617
+ /* @__PURE__ */ jsx("span", { style: { color: "#374151" }, children: data.status })
1618
+ ]
1619
+ }
1620
+ ),
1621
+ hasSubtitle && /* @__PURE__ */ jsx(
1622
+ "p",
1623
+ {
1624
+ style: {
1625
+ color: "#6b7280",
1626
+ fontSize: "12px",
1627
+ marginBottom: "4px",
1628
+ margin: 0
1629
+ },
1630
+ children: data.subtitle
1631
+ }
1632
+ ),
1633
+ displayFields && displayFields.length > 0 && /* @__PURE__ */ jsx(
1634
+ "div",
1635
+ {
1636
+ style: { display: "flex", flexDirection: "column", gap: "4px" },
1637
+ children: displayFields.map((field, i) => /* @__PURE__ */ jsxs(
1638
+ "div",
1639
+ {
1640
+ style: { display: "flex", gap: "8px", fontSize: "12px" },
1641
+ children: [
1642
+ /* @__PURE__ */ jsxs("span", { style: { color: "#6b7280", fontWeight: 500 }, children: [
1643
+ field.label,
1644
+ ":"
1645
+ ] }),
1646
+ /* @__PURE__ */ jsx("span", { style: { color: "#374151" }, children: field.value })
1647
+ ]
1648
+ },
1649
+ i
1650
+ ))
1651
+ }
1652
+ ),
1653
+ data.description && /* @__PURE__ */ jsx(
1654
+ "p",
1655
+ {
1656
+ style: {
1657
+ color: "#6b7280",
1658
+ fontSize: "12px",
1659
+ marginTop: "8px",
1660
+ margin: 0
1661
+ },
1662
+ children: data.description
1663
+ }
1664
+ )
1665
+ ] })
1666
+ ] })
1667
+ }
1668
+ );
1669
+ }
1670
+ if (!data.items || !Array.isArray(data.items) || data.items.length === 0) {
1671
+ return null;
1672
+ }
1673
+ return /* @__PURE__ */ jsxs("div", { style: { width: "100%" }, children: [
1674
+ data.title && !data.items.some((item) => item.title) && /* @__PURE__ */ jsx(
1675
+ "h3",
1676
+ {
1677
+ style: {
1678
+ fontWeight: 600,
1679
+ marginBottom: "12px",
1680
+ fontSize: "14px",
1681
+ color: "#1a1a1a",
1682
+ marginTop: 0
1683
+ },
1684
+ children: data.title
1685
+ }
1686
+ ),
1687
+ data.description && /* @__PURE__ */ jsx(
1688
+ "p",
1689
+ {
1690
+ style: {
1691
+ color: "#6b7280",
1692
+ marginBottom: "12px",
1693
+ fontSize: "12px",
1694
+ marginTop: 0
1695
+ },
1696
+ children: data.description
1697
+ }
1698
+ ),
1699
+ /* @__PURE__ */ jsx(
1700
+ "div",
1701
+ {
1702
+ style: {
1703
+ display: "grid",
1704
+ gridTemplateColumns: "repeat(auto-fit, minmax(250px, 1fr))",
1705
+ gap: "12px"
1706
+ },
1707
+ children: data.items.map((item, i) => {
1708
+ const itemKey = item.id || `card-item-${i}`;
1709
+ const hasImage = item.image && typeof item.image === "string";
1710
+ const hasTitle = item.title && typeof item.title === "string";
1711
+ const hasSubtitle = item.subtitle && typeof item.subtitle === "string";
1712
+ const isLegacyFormat = item.label && item.value;
1713
+ if (isLegacyFormat && !hasTitle) {
1714
+ return /* @__PURE__ */ jsx(
1715
+ "div",
1716
+ {
1717
+ style: {
1718
+ border: "1px solid #e0e0e0",
1719
+ borderRadius: "12px",
1720
+ padding: "16px",
1721
+ backgroundColor: "#ffffff",
1722
+ boxShadow: "0 2px 8px rgba(0, 0, 0, 0.08)",
1723
+ fontSize: "12px"
1724
+ },
1725
+ children: /* @__PURE__ */ jsxs(
1726
+ "div",
1727
+ {
1728
+ style: {
1729
+ display: "flex",
1730
+ justifyContent: "space-between",
1731
+ gap: "8px"
1732
+ },
1733
+ children: [
1734
+ /* @__PURE__ */ jsx("dt", { style: { color: "#6b7280", margin: 0 }, children: item.label }),
1735
+ /* @__PURE__ */ jsx(
1736
+ "dd",
1737
+ {
1738
+ style: {
1739
+ fontWeight: 500,
1740
+ color: "#1a1a1a",
1741
+ margin: 0
1742
+ },
1743
+ children: item.value
1744
+ }
1745
+ )
1746
+ ]
1747
+ }
1748
+ )
1749
+ },
1750
+ itemKey
1751
+ );
1752
+ }
1753
+ return /* @__PURE__ */ jsx(
1754
+ "div",
1755
+ {
1756
+ style: {
1757
+ border: "1px solid #e0e0e0",
1758
+ borderRadius: "12px",
1759
+ padding: "16px",
1760
+ backgroundColor: "#ffffff",
1761
+ boxShadow: "0 2px 8px rgba(0, 0, 0, 0.08)",
1762
+ overflow: "hidden"
1763
+ },
1764
+ children: /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "12px" }, children: [
1765
+ hasImage && /* @__PURE__ */ jsx(
1766
+ "img",
1767
+ {
1768
+ src: item.image,
1769
+ alt: item.title || `Card ${i + 1}`,
1770
+ style: {
1771
+ width: "64px",
1772
+ height: "64px",
1773
+ borderRadius: "8px",
1774
+ objectFit: "cover",
1775
+ flexShrink: 0
1776
+ },
1777
+ onError: (e) => {
1778
+ e.target.style.display = "none";
1779
+ }
1780
+ }
1781
+ ),
1782
+ /* @__PURE__ */ jsxs(
1783
+ "div",
1784
+ {
1785
+ style: {
1786
+ flex: 1,
1787
+ minWidth: 0
1788
+ },
1789
+ children: [
1790
+ hasTitle && /* @__PURE__ */ jsx(
1791
+ "h4",
1792
+ {
1793
+ style: {
1794
+ fontWeight: 600,
1795
+ fontSize: "14px",
1796
+ marginBottom: "4px",
1797
+ overflow: "hidden",
1798
+ textOverflow: "ellipsis",
1799
+ whiteSpace: "nowrap",
1800
+ color: "#1a1a1a",
1801
+ marginTop: 0
1802
+ },
1803
+ children: item.title
1804
+ }
1805
+ ),
1806
+ hasSubtitle && /* @__PURE__ */ jsx(
1807
+ "p",
1808
+ {
1809
+ style: {
1810
+ color: "#6b7280",
1811
+ fontSize: "12px",
1812
+ margin: 0
1813
+ },
1814
+ children: item.subtitle
1815
+ }
1816
+ )
1817
+ ]
1818
+ }
1819
+ )
1820
+ ] })
1821
+ },
1822
+ itemKey
1823
+ );
1824
+ })
1825
+ }
1826
+ )
1827
+ ] });
1828
+ }
1829
+ function renderField(field) {
1830
+ switch (field.type) {
1831
+ case "text":
1832
+ return /* @__PURE__ */ jsx("span", { children: field.value });
1833
+ case "image":
1834
+ return /* @__PURE__ */ jsx(
1835
+ "img",
1836
+ {
1837
+ src: field.src,
1838
+ alt: field.alt ?? "",
1839
+ style: {
1840
+ width: 24,
1841
+ height: 24,
1842
+ borderRadius: "999px",
1843
+ objectFit: "cover"
1844
+ }
1845
+ }
1846
+ );
1847
+ case "link":
1848
+ return /* @__PURE__ */ jsx(
1849
+ "a",
1850
+ {
1851
+ href: field.href,
1852
+ target: "_blank",
1853
+ rel: "noreferrer",
1854
+ style: { textDecoration: "underline" },
1855
+ children: field.label
1856
+ }
1857
+ );
1858
+ case "badge":
1859
+ return /* @__PURE__ */ jsx(
1860
+ "span",
1861
+ {
1862
+ style: {
1863
+ display: "inline-block",
1864
+ padding: "2px 6px",
1865
+ borderRadius: 999,
1866
+ fontSize: 10,
1867
+ fontWeight: 500,
1868
+ backgroundColor: field.tone === "success" ? "#e0fce5" : field.tone === "warning" ? "#fff7d6" : field.tone === "danger" ? "#ffe4e4" : "#f2f2f2",
1869
+ color: field.tone === "success" ? "#1a7f36" : field.tone === "warning" ? "#8a6a00" : field.tone === "danger" ? "#b42318" : "#333"
1870
+ },
1871
+ children: field.label
1872
+ }
1873
+ );
1874
+ case "list":
1875
+ return /* @__PURE__ */ jsx("ul", { style: { margin: 0, paddingLeft: 16 }, children: field.items.map((item, i) => /* @__PURE__ */ jsx("li", { children: renderField(item) }, i)) });
1876
+ default:
1877
+ return null;
1878
+ }
1879
+ }
1880
+ var AizekChatBot = ({
1881
+ clientId,
1882
+ headers
1883
+ }) => {
858
1884
  const defaultConfig = {
859
1885
  welcomeMessage: "Merhaba! Size nas\u0131l yard\u0131mc\u0131 olabilirim?",
860
1886
  buttonBackground: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
@@ -873,27 +1899,44 @@ var AizekChatBot = ({ clientId, headers }) => {
873
1899
  const [isConfigLoading, setIsConfigLoading] = useState(true);
874
1900
  const [finalMcpUrl, setFinalMcpUrl] = useState("");
875
1901
  const [apiKey, setApiKey] = useState("");
876
- const { welcomeMessage, buttonBackground, placeholder, buttonPosition, buttonSize, chatWidth, chatHeight, showTypingIndicator, initialOpen, headerBackground, companyLogo, companyName } = config;
1902
+ const {
1903
+ welcomeMessage,
1904
+ buttonBackground,
1905
+ placeholder,
1906
+ buttonPosition,
1907
+ buttonSize,
1908
+ chatWidth,
1909
+ chatHeight,
1910
+ showTypingIndicator,
1911
+ initialOpen,
1912
+ headerBackground,
1913
+ companyLogo,
1914
+ companyName
1915
+ } = config;
877
1916
  const [isOpen, setIsOpen] = useState(false);
878
1917
  const [headerValidation, setHeaderValidation] = useState(null);
879
1918
  const [showAlert, setShowAlert] = useState(true);
880
1919
  useEffect(() => {
881
- console.log("render");
882
1920
  const loadConfig = async () => {
883
1921
  try {
884
1922
  setIsConfigLoading(true);
885
1923
  const apiResponse = await fetchChatWidgetSettings(clientId);
886
1924
  if (headers && apiResponse.data.auth_config) {
887
- const validationResult = validateHeaders(headers, apiResponse.data.auth_config, {
888
- allowExtra: false,
889
- caseSensitive: true
890
- });
891
- console.log(validationResult);
1925
+ const validationResult = validateHeaders(
1926
+ headers,
1927
+ apiResponse.data.auth_config,
1928
+ {
1929
+ allowExtra: false,
1930
+ caseSensitive: true
1931
+ }
1932
+ );
892
1933
  setHeaderValidation(validationResult);
893
1934
  }
894
1935
  setFinalMcpUrl(apiResponse.data.mcp_url);
895
1936
  setApiKey(apiResponse.data.openai_key || "");
896
- const apiConfig = mapApiSettingsToConfig(apiResponse.data.chat_widget_settings);
1937
+ const apiConfig = mapApiSettingsToConfig(
1938
+ apiResponse.data.chat_widget_settings
1939
+ );
897
1940
  if (apiConfig) {
898
1941
  setConfig(apiConfig);
899
1942
  }
@@ -906,7 +1949,12 @@ var AizekChatBot = ({ clientId, headers }) => {
906
1949
  };
907
1950
  loadConfig();
908
1951
  }, [clientId]);
909
- const internalChatbot = useChatbot({ mcpUrl: finalMcpUrl, apiKey, headers, config });
1952
+ const internalChatbot = useChatbot({
1953
+ mcpUrl: finalMcpUrl,
1954
+ apiKey,
1955
+ headers,
1956
+ config
1957
+ });
910
1958
  const messages = internalChatbot.messages;
911
1959
  const isLoading = internalChatbot.isLoading;
912
1960
  const handleSendMessage = internalChatbot.sendMessage;
@@ -921,22 +1969,56 @@ var AizekChatBot = ({ clientId, headers }) => {
921
1969
  useEffect(() => {
922
1970
  messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
923
1971
  }, [messages]);
924
- const MessageBubble = ({ message }) => {
1972
+ const MessageBubble = ({ message, onAction }) => {
925
1973
  const isUser = message.role === "user";
926
1974
  return /* @__PURE__ */ jsxs("div", { style: getMessageContainerStyles(isUser), children: [
927
1975
  /* @__PURE__ */ jsx("style", { children: getMarkdownElementStyles(isUser) }),
928
- /* @__PURE__ */ jsxs("div", { style: getMessageBubbleStyles(isUser), children: [
929
- isUser ? /* @__PURE__ */ jsx("div", { style: getMarkdownStyles(), className: "markdown-content", children: /* @__PURE__ */ jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], children: message.content }) }) : /* @__PURE__ */ jsx("div", { dangerouslySetInnerHTML: { __html: message.content } }),
930
- message.isTyping && /* @__PURE__ */ jsx("div", { style: {
931
- display: "inline-flex",
932
- alignItems: "center",
933
- marginLeft: "8px"
934
- }, children: /* @__PURE__ */ jsx(TypingDots, {}) })
1976
+ isUser && /* @__PURE__ */ jsxs(Fragment, { children: [
1977
+ /* @__PURE__ */ jsx("div", { style: getMessageBubbleStyles(isUser), children: message.text && /* @__PURE__ */ jsx("div", { style: getMarkdownStyles(), children: message.text }) }),
1978
+ /* @__PURE__ */ jsx("div", { style: getTimeStyles(isUser), children: message.timestamp.toLocaleTimeString("tr-TR", {
1979
+ hour: "2-digit",
1980
+ minute: "2-digit"
1981
+ }) })
935
1982
  ] }),
936
- /* @__PURE__ */ jsx("div", { style: getTimeStyles(isUser), children: message.timestamp.toLocaleTimeString("tr-TR", {
937
- hour: "2-digit",
938
- minute: "2-digit"
939
- }) })
1983
+ !isUser && message.role !== "approval" && /* @__PURE__ */ jsxs(Fragment, { children: [
1984
+ /* @__PURE__ */ jsx(
1985
+ "div",
1986
+ {
1987
+ style: getMessageBubbleStyles(isUser, message.isTyping ?? false),
1988
+ children: message.isTyping ? /* @__PURE__ */ jsx(
1989
+ "div",
1990
+ {
1991
+ style: {
1992
+ display: "inline-flex",
1993
+ alignItems: "center",
1994
+ marginLeft: message.text ? "8px" : "0"
1995
+ },
1996
+ children: /* @__PURE__ */ jsx(TypingDots, {})
1997
+ }
1998
+ ) : /* @__PURE__ */ jsxs(Fragment, { children: [
1999
+ /* @__PURE__ */ jsx("div", { style: getMarkdownStyles(), className: "markdown-content", children: /* @__PURE__ */ jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], children: message.text }) }),
2000
+ message.ui && /* @__PURE__ */ jsx(
2001
+ UIRenderer,
2002
+ {
2003
+ components: message.ui,
2004
+ onInteraction: (event) => {
2005
+ console.log(event);
2006
+ if (event.type === "buttonClick" && typeof event.value === "string") {
2007
+ onAction(event.value, true);
2008
+ } else if (event.type === "formSubmit") {
2009
+ onAction(JSON.stringify(event.values), true);
2010
+ }
2011
+ }
2012
+ }
2013
+ )
2014
+ ] })
2015
+ }
2016
+ ),
2017
+ /* @__PURE__ */ jsx("div", { style: getTimeStyles(isUser), children: message.timestamp.toLocaleTimeString("tr-TR", {
2018
+ hour: "2-digit",
2019
+ minute: "2-digit"
2020
+ }) })
2021
+ ] })
940
2022
  ] });
941
2023
  };
942
2024
  const TypingDots = () => {
@@ -977,60 +2059,102 @@ var AizekChatBot = ({ clientId, headers }) => {
977
2059
  missingKeys.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
978
2060
  /* @__PURE__ */ jsx("strong", { style: { fontSize: "13px" }, children: "Eksik Header'lar:" }),
979
2061
  /* @__PURE__ */ jsx("ul", { style: getAlertListStyles(), children: missingKeys.map((key, index) => /* @__PURE__ */ jsxs("li", { style: getAlertListItemStyles(), children: [
980
- /* @__PURE__ */ jsx("span", { style: {
981
- position: "absolute",
982
- left: "0",
983
- top: "2px",
984
- fontWeight: "bold"
985
- }, children: "\u2022" }),
986
- /* @__PURE__ */ jsx("code", { style: {
987
- background: "rgba(255, 255, 255, 0.2)",
988
- padding: "2px 6px",
989
- borderRadius: "4px",
990
- fontFamily: "monospace",
991
- fontSize: "12px"
992
- }, children: key })
2062
+ /* @__PURE__ */ jsx(
2063
+ "span",
2064
+ {
2065
+ style: {
2066
+ position: "absolute",
2067
+ left: "0",
2068
+ top: "2px",
2069
+ fontWeight: "bold"
2070
+ },
2071
+ children: "\u2022"
2072
+ }
2073
+ ),
2074
+ /* @__PURE__ */ jsx(
2075
+ "code",
2076
+ {
2077
+ style: {
2078
+ background: "rgba(255, 255, 255, 0.2)",
2079
+ padding: "2px 6px",
2080
+ borderRadius: "4px",
2081
+ fontFamily: "monospace",
2082
+ fontSize: "12px"
2083
+ },
2084
+ children: key
2085
+ }
2086
+ )
993
2087
  ] }, index)) })
994
2088
  ] }),
995
2089
  emptyValueKeys.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
996
2090
  /* @__PURE__ */ jsx("strong", { style: { fontSize: "13px" }, children: "Bo\u015F De\u011Ferli Header'lar:" }),
997
2091
  /* @__PURE__ */ jsx("ul", { style: getAlertListStyles(), children: emptyValueKeys.map((key, index) => /* @__PURE__ */ jsxs("li", { style: getAlertListItemStyles(), children: [
998
- /* @__PURE__ */ jsx("span", { style: {
999
- position: "absolute",
1000
- left: "0",
1001
- top: "2px",
1002
- fontWeight: "bold"
1003
- }, children: "\u2022" }),
1004
- /* @__PURE__ */ jsx("code", { style: {
1005
- background: "rgba(255, 255, 255, 0.2)",
1006
- padding: "2px 6px",
1007
- borderRadius: "4px",
1008
- fontFamily: "monospace",
1009
- fontSize: "12px"
1010
- }, children: key }),
1011
- /* @__PURE__ */ jsx("span", { style: {
1012
- marginLeft: "6px",
1013
- fontSize: "11px",
1014
- opacity: 0.9
1015
- }, children: "(de\u011Fer bo\u015F olamaz)" })
2092
+ /* @__PURE__ */ jsx(
2093
+ "span",
2094
+ {
2095
+ style: {
2096
+ position: "absolute",
2097
+ left: "0",
2098
+ top: "2px",
2099
+ fontWeight: "bold"
2100
+ },
2101
+ children: "\u2022"
2102
+ }
2103
+ ),
2104
+ /* @__PURE__ */ jsx(
2105
+ "code",
2106
+ {
2107
+ style: {
2108
+ background: "rgba(255, 255, 255, 0.2)",
2109
+ padding: "2px 6px",
2110
+ borderRadius: "4px",
2111
+ fontFamily: "monospace",
2112
+ fontSize: "12px"
2113
+ },
2114
+ children: key
2115
+ }
2116
+ ),
2117
+ /* @__PURE__ */ jsx(
2118
+ "span",
2119
+ {
2120
+ style: {
2121
+ marginLeft: "6px",
2122
+ fontSize: "11px",
2123
+ opacity: 0.9
2124
+ },
2125
+ children: "(de\u011Fer bo\u015F olamaz)"
2126
+ }
2127
+ )
1016
2128
  ] }, index)) })
1017
2129
  ] }),
1018
2130
  extraKeys.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
1019
2131
  /* @__PURE__ */ jsx("strong", { style: { fontSize: "13px" }, children: "Fazla Header'lar:" }),
1020
2132
  /* @__PURE__ */ jsx("ul", { style: getAlertListStyles(), children: extraKeys.map((key, index) => /* @__PURE__ */ jsxs("li", { style: getAlertListItemStyles(), children: [
1021
- /* @__PURE__ */ jsx("span", { style: {
1022
- position: "absolute",
1023
- left: "0",
1024
- top: "2px",
1025
- fontWeight: "bold"
1026
- }, children: "\u2022" }),
1027
- /* @__PURE__ */ jsx("code", { style: {
1028
- background: "rgba(255, 255, 255, 0.2)",
1029
- padding: "2px 6px",
1030
- borderRadius: "4px",
1031
- fontFamily: "monospace",
1032
- fontSize: "12px"
1033
- }, children: key })
2133
+ /* @__PURE__ */ jsx(
2134
+ "span",
2135
+ {
2136
+ style: {
2137
+ position: "absolute",
2138
+ left: "0",
2139
+ top: "2px",
2140
+ fontWeight: "bold"
2141
+ },
2142
+ children: "\u2022"
2143
+ }
2144
+ ),
2145
+ /* @__PURE__ */ jsx(
2146
+ "code",
2147
+ {
2148
+ style: {
2149
+ background: "rgba(255, 255, 255, 0.2)",
2150
+ padding: "2px 6px",
2151
+ borderRadius: "4px",
2152
+ fontFamily: "monospace",
2153
+ fontSize: "12px"
2154
+ },
2155
+ children: key
2156
+ }
2157
+ )
1034
2158
  ] }, index)) })
1035
2159
  ] })
1036
2160
  ] }),
@@ -1113,7 +2237,18 @@ var AizekChatBot = ({ clientId, headers }) => {
1113
2237
  return /* @__PURE__ */ jsx("div", { style: getLoadingSpinnerStyles() });
1114
2238
  };
1115
2239
  if (isConfigLoading) {
1116
- return /* @__PURE__ */ jsx("div", { style: getFloatingButtonStyles(buttonPosition, buttonSize, buttonBackground, false), children: /* @__PURE__ */ jsx("div", { style: getLoadingSpinnerStyles() }) });
2240
+ return /* @__PURE__ */ jsx(
2241
+ "div",
2242
+ {
2243
+ style: getFloatingButtonStyles(
2244
+ buttonPosition,
2245
+ buttonSize,
2246
+ buttonBackground,
2247
+ false
2248
+ ),
2249
+ children: /* @__PURE__ */ jsx("div", { style: getLoadingSpinnerStyles() })
2250
+ }
2251
+ );
1117
2252
  }
1118
2253
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1119
2254
  isOpen && /* @__PURE__ */ jsx(
@@ -1124,49 +2259,75 @@ var AizekChatBot = ({ clientId, headers }) => {
1124
2259
  className: "floating-chat-overlay"
1125
2260
  }
1126
2261
  ),
1127
- /* @__PURE__ */ jsx("div", { style: getChatContainerStyles(buttonPosition, chatWidth, chatHeight, isOpen), className: "floating-chat-container", children: /* @__PURE__ */ jsxs("div", { style: getChatbotContainerStyles(), children: [
1128
- /* @__PURE__ */ jsxs("div", { style: getHeaderStyles(headerBackground), children: [
1129
- /* @__PURE__ */ jsx("div", { style: getLogoContainerStyles(), children: companyLogo ? companyLogo.startsWith("http") || companyLogo.startsWith("data:") ? /* @__PURE__ */ jsx(
1130
- "img",
1131
- {
1132
- src: companyLogo,
1133
- alt: "Company Logo",
1134
- style: getLogoImageStyles()
1135
- }
1136
- ) : /* @__PURE__ */ jsx("span", { style: getLogoTextStyles(), children: companyLogo }) : "\u{1F916}" }),
1137
- /* @__PURE__ */ jsxs("div", { children: [
1138
- /* @__PURE__ */ jsx("h3", { style: getCompanyNameStyles(), children: companyName }),
1139
- /* @__PURE__ */ jsx("p", { style: getStatusTextStyles(), children: isLoading ? "Yaz\u0131yor..." : "\xC7evrimi\xE7i" })
1140
- ] })
1141
- ] }),
1142
- /* @__PURE__ */ jsxs("div", { style: getMessagesContainerStyles(), children: [
1143
- /* @__PURE__ */ jsx(HeaderValidationAlert, {}),
1144
- messages.length === 0 ? /* @__PURE__ */ jsxs("div", { style: getEmptyStateStyles(), children: [
1145
- /* @__PURE__ */ jsx("div", { style: { fontSize: "48px", marginBottom: "16px" }, children: "\u{1F4AC}" }),
1146
- /* @__PURE__ */ jsx("h4", { style: { margin: "0 0 8px 0", fontSize: "18px" }, children: welcomeMessage }),
1147
- /* @__PURE__ */ jsx("p", { style: { margin: 0, fontSize: "14px", opacity: 0.8 }, children: "A\u015Fa\u011F\u0131daki alana mesaj\u0131n\u0131z\u0131 yazarak ba\u015Flayabilirsiniz." })
1148
- ] }) : messages.map((message) => /* @__PURE__ */ jsx(MessageBubble, { message }, message.id)),
1149
- showTypingIndicator && isLoading && messages.length > 0 && /* @__PURE__ */ jsx(
1150
- MessageBubble,
1151
- {
1152
- message: {
1153
- id: "typing",
1154
- content: "",
1155
- role: "assistant",
1156
- timestamp: /* @__PURE__ */ new Date(),
1157
- isTyping: true
1158
- }
1159
- }
2262
+ /* @__PURE__ */ jsx(
2263
+ "div",
2264
+ {
2265
+ style: getChatContainerStyles(
2266
+ buttonPosition,
2267
+ chatWidth,
2268
+ chatHeight,
2269
+ isOpen
1160
2270
  ),
1161
- /* @__PURE__ */ jsx("div", { ref: messagesEndRef })
1162
- ] }),
1163
- /* @__PURE__ */ jsx(ChatInput, {})
1164
- ] }) }),
2271
+ className: "floating-chat-container",
2272
+ children: /* @__PURE__ */ jsxs("div", { style: getChatbotContainerStyles(), children: [
2273
+ /* @__PURE__ */ jsxs("div", { style: getHeaderStyles(headerBackground), children: [
2274
+ /* @__PURE__ */ jsx("div", { style: getLogoContainerStyles(), children: companyLogo ? companyLogo.startsWith("http") || companyLogo.startsWith("data:") ? /* @__PURE__ */ jsx(
2275
+ "img",
2276
+ {
2277
+ src: companyLogo,
2278
+ alt: "Company Logo",
2279
+ style: getLogoImageStyles()
2280
+ }
2281
+ ) : /* @__PURE__ */ jsx("span", { style: getLogoTextStyles(), children: companyLogo }) : "\u{1F916}" }),
2282
+ /* @__PURE__ */ jsxs("div", { children: [
2283
+ /* @__PURE__ */ jsx("h3", { style: getCompanyNameStyles(), children: companyName }),
2284
+ /* @__PURE__ */ jsx("p", { style: getStatusTextStyles(), children: isLoading ? "Yaz\u0131yor..." : "\xC7evrimi\xE7i" })
2285
+ ] })
2286
+ ] }),
2287
+ /* @__PURE__ */ jsxs("div", { style: getMessagesContainerStyles(), children: [
2288
+ /* @__PURE__ */ jsx(HeaderValidationAlert, {}),
2289
+ messages.length === 0 ? /* @__PURE__ */ jsxs("div", { style: getEmptyStateStyles(), children: [
2290
+ /* @__PURE__ */ jsx("div", { style: { fontSize: "48px", marginBottom: "16px" }, children: "\u{1F4AC}" }),
2291
+ /* @__PURE__ */ jsx("h4", { style: { margin: "0 0 8px 0", fontSize: "18px" }, children: welcomeMessage }),
2292
+ /* @__PURE__ */ jsx("p", { style: { margin: 0, fontSize: "14px", opacity: 0.8 }, children: "A\u015Fa\u011F\u0131daki alana mesaj\u0131n\u0131z\u0131 yazarak ba\u015Flayabilirsiniz." })
2293
+ ] }) : messages.map((message) => /* @__PURE__ */ jsx(
2294
+ MessageBubble,
2295
+ {
2296
+ message,
2297
+ onAction: handleSendMessage
2298
+ },
2299
+ message.id
2300
+ )),
2301
+ showTypingIndicator && isLoading && messages.length > 0 && /* @__PURE__ */ jsx(
2302
+ MessageBubble,
2303
+ {
2304
+ message: {
2305
+ id: `typing-${messages.length}`,
2306
+ text: "",
2307
+ role: "assistant",
2308
+ timestamp: /* @__PURE__ */ new Date(),
2309
+ isTyping: true
2310
+ },
2311
+ onAction: handleSendMessage
2312
+ },
2313
+ `typing-${messages.length}`
2314
+ ),
2315
+ /* @__PURE__ */ jsx("div", { ref: messagesEndRef })
2316
+ ] }),
2317
+ /* @__PURE__ */ jsx(ChatInput, {})
2318
+ ] })
2319
+ }
2320
+ ),
1165
2321
  /* @__PURE__ */ jsx(
1166
2322
  "button",
1167
2323
  {
1168
2324
  onClick: toggleChat,
1169
- style: getFloatingButtonStyles(buttonPosition, buttonSize, buttonBackground, isOpen),
2325
+ style: getFloatingButtonStyles(
2326
+ buttonPosition,
2327
+ buttonSize,
2328
+ buttonBackground,
2329
+ isOpen
2330
+ ),
1170
2331
  onMouseEnter: (e) => {
1171
2332
  e.currentTarget.style.transform = isOpen ? "scale(0.85)" : "scale(1.1)";
1172
2333
  e.currentTarget.style.boxShadow = "0 6px 20px rgba(0, 0, 0, 0.25)";