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