aizek-chatbot 1.0.12 → 1.0.13

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
@@ -1,225 +1,12 @@
1
- import * as React from 'react';
2
1
  import { useState, useEffect, useRef } from 'react';
3
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
2
  import OpenAI from 'openai';
5
3
  import ReactMarkdown from 'react-markdown';
6
4
  import remarkGfm from 'remark-gfm';
5
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
+ import "./index.css"
7
7
 
8
- // src/utils/cx.ts
9
- function cx(...args) {
10
- return args.filter(Boolean).join(" ");
11
- }
12
- function validateHeaders(headers, authConfig, opts = {}) {
13
- const { caseSensitive = false, allowExtra = false } = opts;
14
- const normalize = (s) => caseSensitive ? s : s.toLowerCase();
15
- const headerEntries = Object.entries(headers).map(([k, v]) => [normalize(k), v.trim()]);
16
- const authEntries = Object.entries(authConfig).map(([k, v]) => [normalize(k), v.trim()]);
17
- const headerKeys = headerEntries.map(([k]) => k);
18
- const authKeys = authEntries.map(([k]) => k);
19
- const requiredSet = new Set(authKeys);
20
- const missingKeys = authKeys.filter((k) => !headerKeys.includes(k));
21
- const extraKeys = headerKeys.filter((k) => !requiredSet.has(k));
22
- const hasAllRequired = missingKeys.length === 0;
23
- const hasExtraKeys = extraKeys.length > 0 && !allowExtra;
24
- const emptyValueKeys = authKeys.filter((k) => {
25
- const val = headerEntries.find(([key]) => key === k)?.[1];
26
- return !val || val.length === 0;
27
- });
28
- const isValid = hasAllRequired && !hasExtraKeys && emptyValueKeys.length === 0;
29
- return { isValid, missingKeys, extraKeys, emptyValueKeys };
30
- }
31
- var base = {
32
- display: "inline-flex",
33
- alignItems: "center",
34
- justifyContent: "center",
35
- borderRadius: 12,
36
- fontWeight: 600,
37
- lineHeight: 1,
38
- transition: "background-color .2s ease, color .2s ease, border-color .2s ease",
39
- outline: "none",
40
- cursor: "pointer"
41
- };
42
- var sizes = {
43
- sm: { height: 36, padding: "0 12px", fontSize: 14 },
44
- md: { height: 40, padding: "0 16px", fontSize: 16 },
45
- lg: { height: 44, padding: "0 20px", fontSize: 18 }
46
- };
47
- var palette = {
48
- brand: {
49
- primary: "#2563eb",
50
- primaryHover: "#1d4ed8"
51
- }
52
- };
53
- function styleFor(variant) {
54
- switch (variant) {
55
- case "outline":
56
- return {
57
- background: "transparent",
58
- color: palette.brand.primary,
59
- border: `1px solid ${palette.brand.primary}`
60
- };
61
- case "ghost":
62
- return {
63
- background: "transparent",
64
- color: palette.brand.primary,
65
- border: "1px solid transparent"
66
- };
67
- default:
68
- return {
69
- background: palette.brand.primary,
70
- color: "#fff",
71
- border: "1px solid transparent"
72
- };
73
- }
74
- }
75
- var Button = React.forwardRef(
76
- ({ variant = "primary", size = "md", style, className, onMouseEnter, onMouseLeave, ...props }, ref) => {
77
- const [hover, setHover] = React.useState(false);
78
- const hoverStyle = variant === "primary" ? { background: hover ? palette.brand.primaryHover : palette.brand.primary } : variant === "outline" ? { borderColor: hover ? palette.brand.primaryHover : palette.brand.primary } : { background: hover ? "rgba(37, 99, 235, 0.08)" : "transparent" };
79
- return /* @__PURE__ */ jsx(
80
- "button",
81
- {
82
- ref,
83
- className: cx("rui-btn", className),
84
- style: { ...base, ...sizes[size], ...styleFor(variant), ...hover ? hoverStyle : {}, ...style },
85
- onMouseEnter: (e) => {
86
- setHover(true);
87
- onMouseEnter?.(e);
88
- },
89
- onMouseLeave: (e) => {
90
- setHover(false);
91
- onMouseLeave?.(e);
92
- },
93
- ...props
94
- }
95
- );
96
- }
97
- );
98
- Button.displayName = "Button";
99
- var useChatbot = (options = {}) => {
100
- const { mcpUrl, apiKey, config } = options;
101
- const client = new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
102
- const [responseId, setResponseId] = useState(null);
103
- const [messages, setMessages] = useState([]);
104
- const [isLoading, setIsLoading] = useState(false);
105
- const generateId = () => {
106
- return Date.now().toString() + Math.random().toString(36).substr(2, 9);
107
- };
108
- const addMessage = (payload, role) => {
109
- const newMessage = {
110
- id: generateId(),
111
- text: payload.text,
112
- ui: payload.ui,
113
- role,
114
- timestamp: /* @__PURE__ */ new Date()
115
- };
116
- setMessages((prev) => [...prev, newMessage]);
117
- return newMessage;
118
- };
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.
8
+ // src/utils/prompt.ts
9
+ var instructions = `You are Aizek, an AI assistant running in an environment with Model Context Protocol (MCP) tools.
223
10
 
224
11
  Your top priority is to USE MCP TOOLS whenever they can handle the user's request.
225
12
  Do NOT bypass available tools to answer from generic knowledge, web browsing, or other external sources if a suitable MCP tool exists.
@@ -361,33 +148,301 @@ In this order of priority:
361
148
 
362
149
  Always keep in mind:
363
150
  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 = `
151
+ var SYSTEM_PROMPT = `
365
152
  You are a helpful assistant that can generate both natural language responses and UI components.
366
153
 
367
154
  You MUST:
368
155
  - Always respond with normal conversational text.
369
156
  - Optionally include one or more UI components inside code blocks with language "ui-component".
370
157
 
371
- When to use components:
158
+ IMPORTANT:
159
+ - Do NOT invent HTML. Only JSON as described.
160
+ - Keep JSON strictly valid.
161
+ - Text response should be outside of code blocks.
162
+
163
+ STRICT REQUIREMENTS (CRITICAL):
164
+ - All component JSON must STRICTLY MATCH the TypeScript types given below.
165
+ - You MUST NOT create extra fields not defined in the types.
166
+ - You MUST NOT rename keys. Example: using "key" instead of "id" in a form field is INVALID.
167
+ - Only use the exact field names defined in the interfaces below.
168
+ - All JSON must be strictly valid.
169
+
170
+ -------------------------------------------
171
+ TYPES YOU MUST FOLLOW EXACTLY:
172
+
173
+ UIField =
174
+ UITextField | UIImageField | UILinkField | UIBadgeField | UIListField
175
+
176
+ UITextField:
177
+ {
178
+ "type": "text",
179
+ "value": string
180
+ }
181
+
182
+ UIImageField:
183
+ {
184
+ "type": "image",
185
+ "src": string,
186
+ "alt"?: string
187
+ }
188
+
189
+ UILinkField:
190
+ {
191
+ "type": "link",
192
+ "label": string,
193
+ "href": string
194
+ }
195
+
196
+ UIBadgeField:
197
+ {
198
+ "type": "badge",
199
+ "label": string,
200
+ "tone"?: "success" | "warning" | "danger" | "info" | "neutral"
201
+ }
202
+
203
+ UIListField:
204
+ {
205
+ "type": "list",
206
+ "items": UIField[]
207
+ }
208
+
209
+ -------------------------------------------------
210
+
211
+ UIFormData:
212
+ {
213
+ "id": string,
214
+ "title"?: string,
215
+ "fields": UIFormField[],
216
+ "submitLabel"?: string
217
+ }
218
+
219
+ UIFormField:
220
+ {
221
+ "id": string,
222
+ "name": string,
223
+ "label": string,
224
+ "placeholder"?: string,
225
+ "type": "text" | "select" | "number" | "file",
226
+ "accept"?: string,
227
+ "required"?: boolean,
228
+ "validation"?: string,
229
+ "options"?: { "label": string, "value": string }[],
230
+ "value"?: string | number,
231
+ "min"?: number,
232
+ "max"?: number
233
+ }
234
+
235
+ -------------------------------------------------
236
+
237
+ UIButtonData:
238
+ {
239
+ "label": string,
240
+ "value": string,
241
+ "variant"?: "primary" | "secondary" | "danger"
242
+ }
243
+
244
+ -------------------------------------------------
245
+
246
+ UITableData:
247
+ {
248
+ "caption"?: string,
249
+ "columns": UITableColumn[] | string[],
250
+ "rows": Array<Record<string, UIField | string>> | string[][]
251
+ }
252
+
253
+ UITableColumn:
254
+ {
255
+ "id"?: string,
256
+ "key"?: string,
257
+ "label": string,
258
+ "type"?: "image" | "text" | "badge"
259
+ }
260
+
261
+ -------------------------------------------------
262
+
263
+ UICardData:
264
+ {
265
+ "title"?: string,
266
+ "description"?: string,
267
+ "image"?: string,
268
+ "status"?: string,
269
+ "subtitle"?: string,
270
+ "fields"?: UICardField[],
271
+ "attributes"?: UICardField[],
272
+ "items"?: UICardItem[],
273
+ "[key: string]": any
274
+ }
275
+
276
+ UICardField:
277
+ {
278
+ "label": string,
279
+ "value": string
280
+ }
281
+
282
+ UICardItem:
283
+ {
284
+ "id"?: string,
285
+ "title"?: string,
286
+ "subtitle"?: string,
287
+ "image"?: string,
288
+ "label"?: string,
289
+ "value"?: string
290
+ }
291
+
292
+ -------------------------------------------------
293
+
294
+ UIComponent:
295
+ {
296
+ "type": "form" | "buttons" | "table" | "card",
297
+ "data": (the relevant data according to type)
298
+ }
299
+
300
+ -------------------------------------------
301
+
302
+ RULES FOR WHEN TO USE COMPONENTS:
372
303
  - User needs to provide multiple structured values \u2192 generate a FORM
373
304
  - User must choose among options \u2192 generate BUTTONS
374
305
  - User must see structured data comparison \u2192 generate a TABLE
375
306
  - User must see entity details/summary \u2192 generate a CARD
376
307
 
377
- Format for each component (strictly):
308
+ FORMAT FOR EACH COMPONENT:
378
309
 
379
310
  \`\`\`ui-component
380
311
  {
381
- "type": "form" | "buttons" | "table" | "card",
382
- "data": { ...component-specific fields... }
312
+ "type": "...",
313
+ "data": { ... }
383
314
  }
384
315
  \`\`\`
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.
390
316
  `;
317
+
318
+ // src/hooks/use-chatbot.ts
319
+ var useChatbot = (options = {}) => {
320
+ const { mcpUrl, apiKey, config } = options;
321
+ const client = new OpenAI({
322
+ apiKey,
323
+ baseURL: "https://api.anthropic.com/v1/",
324
+ dangerouslyAllowBrowser: true
325
+ });
326
+ const [responseId, setResponseId] = useState(null);
327
+ const [messages, setMessages] = useState([]);
328
+ const [isLoading, setIsLoading] = useState(false);
329
+ const generateId = () => {
330
+ return Date.now().toString() + Math.random().toString(36).substr(2, 9);
331
+ };
332
+ const addMessage = (payload, role) => {
333
+ const newMessage = {
334
+ id: generateId(),
335
+ text: payload.text,
336
+ ui: payload.ui,
337
+ role,
338
+ timestamp: /* @__PURE__ */ new Date()
339
+ };
340
+ setMessages((prev) => [...prev, newMessage]);
341
+ return newMessage;
342
+ };
343
+ const extractUiComponents = (raw) => {
344
+ const regex = /```ui-component([\s\S]*?)```/g;
345
+ const components = [];
346
+ let cleaned = raw;
347
+ let match;
348
+ let componentIndex = 0;
349
+ while ((match = regex.exec(raw)) !== null) {
350
+ const block = match[1].trim();
351
+ try {
352
+ const json = JSON.parse(block);
353
+ if (json.type === "buttons" && json.data && typeof json.data === "object" && !Array.isArray(json.data)) {
354
+ if (json.data.options && Array.isArray(json.data.options)) {
355
+ json.data = json.data.options.map((opt) => {
356
+ if (opt.id && opt.label) {
357
+ return {
358
+ label: opt.label,
359
+ value: opt.id,
360
+ variant: opt.variant
361
+ };
362
+ }
363
+ return opt;
364
+ });
365
+ }
366
+ }
367
+ if (json.type === "table" && json.data) {
368
+ if (Array.isArray(json.data.columns) && json.data.columns.length > 0) {
369
+ const firstCol = json.data.columns[0];
370
+ if (typeof firstCol === "string") {
371
+ json.data.columns = json.data.columns.map(
372
+ (col, idx) => ({
373
+ id: `col-${idx}`,
374
+ label: col
375
+ })
376
+ );
377
+ }
378
+ }
379
+ if (Array.isArray(json.data.rows) && json.data.rows.length > 0) {
380
+ const firstRow = json.data.rows[0];
381
+ if (Array.isArray(firstRow) && typeof firstRow[0] === "string") {
382
+ json.data.rows = json.data.rows.map((row) => {
383
+ const rowObj = {};
384
+ json.data.columns.forEach((col, idx) => {
385
+ const colId = typeof col === "string" ? `col-${idx}` : col.id;
386
+ const cellValue = row[idx];
387
+ if (typeof cellValue === "string" && (cellValue.startsWith("http") || cellValue.startsWith("data:"))) {
388
+ rowObj[colId] = {
389
+ type: "image",
390
+ src: cellValue,
391
+ alt: ""
392
+ };
393
+ } else {
394
+ rowObj[colId] = {
395
+ type: "text",
396
+ value: cellValue || ""
397
+ };
398
+ }
399
+ });
400
+ return rowObj;
401
+ });
402
+ }
403
+ }
404
+ }
405
+ if (json.type === "form" && json.data) {
406
+ if (!json.data.id) {
407
+ json.data.id = json.id || `form-${componentIndex}`;
408
+ }
409
+ if (json.data.fields && Array.isArray(json.data.fields)) {
410
+ json.data.fields = json.data.fields.map((field) => {
411
+ if (field.optional !== void 0) {
412
+ field.required = !field.optional;
413
+ delete field.optional;
414
+ }
415
+ if (!field.type) {
416
+ field.type = "text";
417
+ }
418
+ if (field.options && Array.isArray(field.options)) {
419
+ const firstOption = field.options[0];
420
+ if (typeof firstOption === "string") {
421
+ field.options = field.options.map((opt) => ({
422
+ label: opt,
423
+ value: opt
424
+ }));
425
+ }
426
+ }
427
+ return field;
428
+ });
429
+ }
430
+ }
431
+ if (json.id && typeof json.id !== "string") {
432
+ json.id = String(json.id);
433
+ }
434
+ if (!json.id || !json.id.trim()) {
435
+ json.id = `ui-comp-${componentIndex}-${Date.now()}`;
436
+ }
437
+ components.push(json);
438
+ componentIndex++;
439
+ } catch (e) {
440
+ console.error("Invalid ui-component JSON:", e, block);
441
+ }
442
+ cleaned = cleaned.replace(match[0], "").trim();
443
+ }
444
+ return { text: cleaned, components };
445
+ };
391
446
  const sendMessage = async (message, approval) => {
392
447
  if (!message.trim() || isLoading) return;
393
448
  if (approval) {
@@ -399,7 +454,7 @@ IMPORTANT:
399
454
  try {
400
455
  let resp;
401
456
  resp = await client.responses.create({
402
- model: "gpt-5",
457
+ model: "claude-sonnet-4-5",
403
458
  tools: [
404
459
  {
405
460
  type: "mcp",
@@ -459,7 +514,7 @@ IMPORTANT:
459
514
  };
460
515
  };
461
516
 
462
- // src/services/chatWidgetApi.ts
517
+ // src/services/chat-widget-api.ts
463
518
  var API_BASE_URL = "https://api-alpha.aizek.ai";
464
519
  var fetchChatWidgetSettings = async (clientId) => {
465
520
  try {
@@ -504,730 +559,25 @@ var mapApiSettingsToConfig = (apiSettings) => {
504
559
  };
505
560
  };
506
561
 
507
- // src/styles/messageStyles.ts
508
- var getMessageBubbleStyles = (isUser, isTyping) => ({
509
- maxWidth: "80%",
510
- padding: "12px 16px",
511
- borderRadius: isUser ? "18px 18px 4px 18px" : "18px 18px 18px 4px",
512
- marginBottom: "8px",
513
- wordWrap: "break-word",
514
- lineHeight: 1.4,
515
- fontSize: "14px",
516
- position: "relative",
517
- ...isUser ? {
518
- background: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
519
- color: "#ffffff",
520
- marginLeft: "auto",
521
- marginRight: "0"
522
- } : {
523
- background: "#f8fafc",
524
- color: "#334155",
525
- border: "1px solid #e2e8f0",
526
- marginLeft: "0",
527
- marginRight: "auto"
528
- }
529
- });
530
- var getTimeStyles = (isUser) => ({
531
- fontSize: "11px",
532
- opacity: 0.7,
533
- marginTop: "4px",
534
- textAlign: isUser ? "right" : "left"
535
- });
536
- var getMarkdownStyles = () => ({
537
- lineHeight: 1.6,
538
- marginBottom: "6px"
539
- });
540
- var getMarkdownElementStyles = (isUser) => `
541
- .markdown-content p {
542
- margin: 0 0 12px 0;
543
- line-height: 1.6;
544
- }
545
- .markdown-content p:last-child {
546
- margin-bottom: 0;
547
- }
548
- .markdown-content ul {
549
- margin: 12px 0 16px 0;
550
- padding-left: 0;
551
- list-style: none;
552
- }
553
- .markdown-content li {
554
- margin-bottom: 12px;
555
- line-height: 1.6;
556
- padding: 12px 16px;
557
- background: ${isUser ? "rgba(255,255,255,0.1)" : "#ffffff"};
558
- border-radius: 12px;
559
- border: 1px solid ${isUser ? "rgba(255,255,255,0.2)" : "#e2e8f0"};
560
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
561
- position: relative;
562
- transition: all 0.2s ease;
563
- }
564
- .markdown-content li:hover {
565
- transform: translateY(-1px);
566
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
567
- }
568
- .markdown-content li::before {
569
- content: "\u2022";
570
- color: ${isUser ? "#ffffff" : "#667eea"};
571
- font-weight: bold;
572
- font-size: 18px;
573
- position: absolute;
574
- left: -8px;
575
- top: 12px;
576
- }
577
- .markdown-content li strong {
578
- display: block;
579
- font-size: 15px;
580
- margin-bottom: 4px;
581
- color: ${isUser ? "#ffffff" : "#1e293b"};
582
- }
583
- .markdown-content li em {
584
- display: block;
585
- font-size: 13px;
586
- opacity: 0.8;
587
- margin-top: 4px;
588
- }
589
- .markdown-content strong {
590
- font-weight: 600;
591
- color: ${isUser ? "#ffffff" : "#1e293b"};
592
- }
593
- .markdown-content em {
594
- font-style: italic;
595
- opacity: 0.9;
596
- }
597
- .markdown-content code {
598
- background: ${isUser ? "rgba(255,255,255,0.2)" : "#f1f5f9"};
599
- padding: 2px 6px;
600
- border-radius: 4px;
601
- font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
602
- font-size: 13px;
603
- }
604
- .markdown-content pre {
605
- background: ${isUser ? "rgba(255,255,255,0.1)" : "#f8fafc"};
606
- padding: 12px;
607
- border-radius: 8px;
608
- overflow-x: auto;
609
- margin: 8px 0;
610
- border: 1px solid ${isUser ? "rgba(255,255,255,0.2)" : "#e2e8f0"};
611
- }
612
- .markdown-content pre code {
613
- background: none;
614
- padding: 0;
615
- }
616
- .markdown-content blockquote {
617
- border-left: 3px solid ${isUser ? "rgba(255,255,255,0.5)" : "#cbd5e1"};
618
- padding-left: 12px;
619
- margin: 8px 0;
620
- opacity: 0.8;
621
- }
622
- .markdown-content h1, .markdown-content h2, .markdown-content h3 {
623
- margin: 16px 0 8px 0;
624
- font-weight: 600;
625
- }
626
- .markdown-content h1 {
627
- font-size: 18px;
628
- }
629
- .markdown-content h2 {
630
- font-size: 16px;
631
- }
632
- .markdown-content h3 {
633
- font-size: 15px;
634
- }
635
- .markdown-content table {
636
- border-collapse: collapse;
637
- width: 100%;
638
- margin: 8px 0;
639
- }
640
- .markdown-content th, .markdown-content td {
641
- border: 1px solid ${isUser ? "rgba(255,255,255,0.3)" : "#e2e8f0"};
642
- padding: 8px 12px;
643
- text-align: left;
644
- }
645
- .markdown-content th {
646
- background: ${isUser ? "rgba(255,255,255,0.1)" : "#f8fafc"};
647
- font-weight: 600;
648
- }
649
-
650
- /* Enhanced list styling */
651
- .markdown-content li {
652
- position: relative;
653
- overflow: hidden;
654
- }
655
-
656
- .markdown-content li::after {
657
- content: "";
658
- position: absolute;
659
- top: 0;
660
- left: 0;
661
- width: 4px;
662
- height: 100%;
663
- background: linear-gradient(135deg, ${isUser ? "#ffffff" : "#667eea"}, ${isUser ? "rgba(255,255,255,0.5)" : "#764ba2"});
664
- border-radius: 0 2px 2px 0;
665
- }
666
-
667
- /* Product name styling */
668
- .markdown-content li strong:first-child {
669
- color: ${isUser ? "#ffffff" : "#1e293b"};
670
- font-size: 16px;
671
- font-weight: 700;
672
- display: block;
673
- margin-bottom: 8px;
674
- }
675
-
676
- /* Product details styling */
677
- .markdown-content li strong:not(:first-child) {
678
- color: ${isUser ? "#ffffff" : "#059669"};
679
- font-size: 13px;
680
- font-weight: 600;
681
- margin-right: 8px;
682
- }
683
-
684
- /* Add some spacing between product details */
685
- .markdown-content li br + * {
686
- margin-top: 4px;
687
- }
688
-
689
- /* Hover effect enhancement */
690
- .markdown-content li:hover::after {
691
- width: 6px;
692
- background: linear-gradient(135deg, ${isUser ? "#ffffff" : "#667eea"}, ${isUser ? "#ffffff" : "#764ba2"});
693
- }
694
- `;
695
- var getMessageContainerStyles = (isUser) => ({
696
- display: "flex",
697
- flexDirection: "column",
698
- alignItems: isUser ? "flex-end" : "flex-start",
699
- width: "100%"
700
- });
701
-
702
- // src/styles/inputStyles.ts
703
- var getInputContainerStyles = () => ({
704
- display: "flex",
705
- alignItems: "flex-end",
706
- gap: "12px",
707
- padding: "16px",
708
- background: "#ffffff",
709
- borderTop: "1px solid #e2e8f0",
710
- borderRadius: "0 0 12px 12px"
711
- });
712
- var getTextareaStyles = (isLoading) => ({
713
- flex: 1,
714
- minHeight: "44px",
715
- maxHeight: "120px",
716
- padding: "12px 16px",
717
- border: "1px solid #e2e8f0",
718
- borderRadius: "22px",
719
- fontSize: "14px",
720
- lineHeight: 1.4,
721
- resize: "none",
722
- outline: "none",
723
- transition: "border-color 0.2s ease, box-shadow 0.2s ease",
724
- fontFamily: "inherit",
725
- background: "#f8fafc",
726
- color: "#334155",
727
- ...isLoading ? {
728
- opacity: 0.6,
729
- cursor: "not-allowed"
730
- } : {}
731
- });
732
- var getSendButtonStyles = (isLoading, hasMessage) => ({
733
- width: "44px",
734
- height: "44px",
735
- borderRadius: "50%",
736
- border: "none",
737
- background: isLoading || !hasMessage ? "#e2e8f0" : "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
738
- color: "#ffffff",
739
- cursor: isLoading || !hasMessage ? "not-allowed" : "pointer",
740
- display: "flex",
741
- alignItems: "center",
742
- justifyContent: "center",
743
- transition: "all 0.2s ease",
744
- fontSize: "16px"
745
- });
746
-
747
- // src/styles/headerStyles.ts
748
- var getHeaderStyles = (headerBackground) => ({
749
- padding: "16px 20px",
750
- background: headerBackground,
751
- color: "#ffffff",
752
- display: "flex",
753
- alignItems: "center",
754
- gap: "12px"
755
- });
756
- var getLogoContainerStyles = () => ({
757
- width: "40px",
758
- height: "40px",
759
- borderRadius: "50%",
760
- background: "rgba(255, 255, 255, 0.2)",
761
- display: "flex",
762
- alignItems: "center",
763
- justifyContent: "center",
764
- fontSize: "18px",
765
- overflow: "hidden"
766
- });
767
- var getLogoImageStyles = () => ({
768
- width: "100%",
769
- height: "100%",
770
- objectFit: "cover",
771
- borderRadius: "50%"
772
- });
773
- var getLogoTextStyles = () => ({
774
- fontSize: "16px",
775
- fontWeight: "bold"
776
- });
777
- var getCompanyNameStyles = () => ({
778
- margin: 0,
779
- fontSize: "16px",
780
- fontWeight: 600
781
- });
782
- var getStatusTextStyles = () => ({
783
- margin: 0,
784
- fontSize: "12px",
785
- opacity: 0.8
786
- });
787
-
788
- // src/styles/containerStyles.ts
789
- var getButtonSizes = () => ({
790
- sm: { width: "50px", height: "50px", fontSize: "20px" },
791
- md: { width: "60px", height: "60px", fontSize: "24px" },
792
- lg: { width: "70px", height: "70px", fontSize: "28px" }
793
- });
794
- var getFloatingButtonStyles = (buttonPosition, buttonSize, buttonBackground, isOpen) => {
795
- const buttonSizes = getButtonSizes();
796
- const buttonSizeStyle = buttonSizes[buttonSize];
797
- return {
798
- position: "fixed",
799
- [buttonPosition === "bottom-left" ? "left" : "right"]: "20px",
800
- bottom: "20px",
801
- width: buttonSizeStyle.width,
802
- height: buttonSizeStyle.height,
803
- borderRadius: "50%",
804
- background: buttonBackground,
805
- border: "none",
806
- color: "#ffffff",
807
- cursor: "pointer",
808
- display: "flex",
809
- alignItems: "center",
810
- justifyContent: "center",
811
- fontSize: buttonSizeStyle.fontSize,
812
- boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
813
- transition: "all 0.3s ease",
814
- zIndex: 1e3,
815
- transform: isOpen ? "scale(0.9)" : "scale(1)"
816
- };
817
- };
818
- var getChatContainerStyles = (buttonPosition, chatWidth, chatHeight, isOpen) => ({
819
- position: "fixed",
820
- [buttonPosition === "bottom-left" ? "left" : "right"]: "20px",
821
- bottom: "90px",
822
- width: chatWidth,
823
- height: chatHeight,
824
- zIndex: 9999999,
825
- transform: isOpen ? "translateY(0) scale(1)" : "translateY(20px) scale(0.95)",
826
- opacity: isOpen ? 1 : 0,
827
- visibility: isOpen ? "visible" : "hidden",
828
- transition: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",
829
- transformOrigin: buttonPosition === "bottom-left" ? "bottom left" : "bottom right"
830
- });
831
- var getOverlayStyles = (isOpen) => ({
832
- position: "fixed",
833
- top: 0,
834
- left: 0,
835
- right: 0,
836
- bottom: 0,
837
- background: "rgba(0, 0, 0, 0.1)",
838
- zIndex: 998,
839
- opacity: isOpen ? 1 : 0,
840
- visibility: isOpen ? "visible" : "hidden",
841
- transition: "all 0.3s ease"
842
- });
843
- var getChatbotContainerStyles = () => ({
844
- display: "flex",
845
- flexDirection: "column",
846
- height: "100%",
847
- background: "#ffffff",
848
- borderRadius: "12px",
849
- boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
850
- border: "1px solid #e2e8f0",
851
- overflow: "hidden"
852
- });
853
- var getMessagesContainerStyles = () => ({
854
- flex: 1,
855
- overflowY: "auto",
856
- padding: "16px",
857
- display: "flex",
858
- flexDirection: "column",
859
- gap: "4px",
860
- background: "#f8fafc"
861
- });
862
- var getEmptyStateStyles = () => ({
863
- display: "flex",
864
- flexDirection: "column",
865
- alignItems: "center",
866
- justifyContent: "center",
867
- height: "100%",
868
- color: "#64748b",
869
- textAlign: "center",
870
- padding: "40px 20px"
871
- });
872
-
873
- // src/styles/loadingStyles.ts
874
- var getLoadingSpinnerStyles = () => ({
875
- width: "16px",
876
- height: "16px",
877
- border: "2px solid transparent",
878
- borderTop: "2px solid currentColor",
879
- borderRadius: "50%",
880
- animation: "spin 1s linear infinite"
881
- });
882
-
883
- // src/styles/alertStyles.ts
884
- var getAlertContainerStyles = (type) => {
885
- const colors = {
886
- error: {
887
- background: "linear-gradient(135deg, #ef4444 0%, #dc2626 100%)",
888
- border: "#dc2626",
889
- shadow: "rgba(239, 68, 68, 0.2)"
890
- },
891
- warning: {
892
- background: "linear-gradient(135deg, #f59e0b 0%, #d97706 100%)",
893
- border: "#d97706",
894
- shadow: "rgba(245, 158, 11, 0.2)"
895
- },
896
- success: {
897
- background: "linear-gradient(135deg, #10b981 0%, #059669 100%)",
898
- border: "#059669",
899
- shadow: "rgba(16, 185, 129, 0.2)"
900
- }
901
- };
902
- const selectedColor = colors[type];
903
- return {
904
- background: selectedColor.background,
905
- border: `1px solid ${selectedColor.border}`,
906
- borderRadius: "12px",
907
- padding: "14px 16px",
908
- margin: "12px 16px",
909
- boxShadow: `0 4px 12px ${selectedColor.shadow}`,
910
- color: "#ffffff",
911
- fontSize: "13px",
912
- display: "flex",
913
- alignItems: "flex-start",
914
- gap: "12px",
915
- position: "relative",
916
- animation: "slideDown 0.3s ease-out"
917
- };
918
- };
919
- var getAlertIconContainerStyles = () => ({
920
- display: "flex",
921
- alignItems: "center",
922
- justifyContent: "center",
923
- width: "24px",
924
- height: "24px",
925
- flexShrink: 0,
926
- marginTop: "2px"
927
- });
928
- var getAlertContentStyles = () => ({
929
- flex: 1,
930
- display: "flex",
931
- flexDirection: "column",
932
- gap: "8px"
933
- });
934
- var getAlertTitleStyles = () => ({
935
- fontWeight: 600,
936
- fontSize: "14px",
937
- margin: 0,
938
- lineHeight: 1.4
939
- });
940
- var getAlertMessageStyles = () => ({
941
- margin: 0,
942
- lineHeight: 1.5,
943
- opacity: 0.95
944
- });
945
- var getAlertListStyles = () => ({
946
- margin: "8px 0 0 0",
947
- paddingLeft: "20px",
948
- listStyle: "none"
949
- });
950
- var getAlertListItemStyles = () => ({
951
- marginBottom: "4px",
952
- position: "relative",
953
- paddingLeft: "12px",
954
- lineHeight: 1.4
955
- });
956
- var getAlertCloseButtonStyles = () => ({
957
- position: "absolute",
958
- top: "12px",
959
- right: "12px",
960
- background: "rgba(255, 255, 255, 0.2)",
961
- border: "none",
962
- borderRadius: "6px",
963
- width: "24px",
964
- height: "24px",
965
- display: "flex",
966
- alignItems: "center",
967
- justifyContent: "center",
968
- cursor: "pointer",
969
- color: "#ffffff",
970
- transition: "all 0.2s ease",
971
- padding: 0
972
- });
973
- var getAlertAnimationStyles = () => `
974
- @keyframes slideDown {
975
- from {
976
- opacity: 0;
977
- transform: translateY(-10px);
978
- }
979
- to {
980
- opacity: 1;
981
- transform: translateY(0);
982
- }
983
- }
984
- `;
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
- );
562
+ // src/utils/cx.ts
563
+ function validateHeaders(headers, authConfig, opts = {}) {
564
+ const { caseSensitive = false, allowExtra = false } = opts;
565
+ const normalize = (s) => caseSensitive ? s : s.toLowerCase();
566
+ const headerEntries = Object.entries(headers).map(([k, v]) => [normalize(k), v.trim()]);
567
+ const authEntries = Object.entries(authConfig).map(([k, v]) => [normalize(k), v.trim()]);
568
+ const headerKeys = headerEntries.map(([k]) => k);
569
+ const authKeys = authEntries.map(([k]) => k);
570
+ const requiredSet = new Set(authKeys);
571
+ const missingKeys = authKeys.filter((k) => !headerKeys.includes(k));
572
+ const extraKeys = headerKeys.filter((k) => !requiredSet.has(k));
573
+ const hasAllRequired = missingKeys.length === 0;
574
+ const hasExtraKeys = extraKeys.length > 0 && !allowExtra;
575
+ const emptyValueKeys = authKeys.filter((k) => {
576
+ const val = headerEntries.find(([key]) => key === k)?.[1];
577
+ return !val || val.length === 0;
578
+ });
579
+ const isValid = hasAllRequired && !hasExtraKeys && emptyValueKeys.length === 0;
580
+ return { isValid, missingKeys, extraKeys, emptyValueKeys };
1231
581
  }
1232
582
  function ButtonsComponent({
1233
583
  data,
@@ -1236,319 +586,30 @@ function ButtonsComponent({
1236
586
  if (!Array.isArray(data) || data.length === 0) {
1237
587
  return null;
1238
588
  }
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
- })
589
+ return /* @__PURE__ */ jsx("div", { className: "buttons-component", children: data.map((btn, idx) => {
590
+ if (!btn || typeof btn !== "object") {
591
+ return null;
1332
592
  }
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
- ]
593
+ 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}`;
594
+ const btnKey = typeof btn.value === "string" && btn.value.trim() ? btn.value : `btn-${idx}`;
595
+ const btnLabel = btn.label || `Button ${idx + 1}`;
596
+ const variantClass = btn.variant || "";
597
+ return /* @__PURE__ */ jsx(
598
+ "button",
599
+ {
600
+ onClick: () => {
601
+ try {
602
+ onClick(btnValue);
603
+ } catch (error) {
604
+ console.error("Error in button onClick:", error);
1547
605
  }
1548
- ) })
1549
- ]
1550
- }
1551
- );
606
+ },
607
+ className: `button-component ${variantClass}`,
608
+ children: btnLabel
609
+ },
610
+ btnKey
611
+ );
612
+ }) });
1552
613
  }
1553
614
  function CardComponent({ data }) {
1554
615
  if (data.title) {
@@ -1558,290 +619,165 @@ function CardComponent({ data }) {
1558
619
  const hasStatus = data.status && typeof data.status === "string";
1559
620
  const hasSubtitle = data.subtitle && typeof data.subtitle === "string";
1560
621
  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
- }
622
+ return /* @__PURE__ */ jsx("div", { className: "card-component", children: /* @__PURE__ */ jsxs("div", { className: "card-content", children: [
623
+ hasImage && /* @__PURE__ */ jsx(
624
+ "img",
625
+ {
626
+ src: data.image,
627
+ alt: data.title || "Card image",
628
+ className: "card-image",
629
+ onError: (e) => {
630
+ e.target.style.display = "none";
631
+ }
632
+ }
633
+ ),
634
+ /* @__PURE__ */ jsxs("div", { className: "card-info", children: [
635
+ /* @__PURE__ */ jsx("h4", { className: "card-title", children: data.title }),
636
+ hasStatus && /* @__PURE__ */ jsxs("div", { className: "card-status", children: [
637
+ /* @__PURE__ */ jsx("span", { className: "card-status-label", children: "Durum:" }),
638
+ /* @__PURE__ */ jsx("span", { className: "card-status-value", children: data.status })
639
+ ] }),
640
+ hasSubtitle && /* @__PURE__ */ jsx("p", { className: "card-subtitle", children: data.subtitle }),
641
+ displayFields && displayFields.length > 0 && /* @__PURE__ */ jsx("div", { className: "card-fields", children: displayFields.map((field, i) => /* @__PURE__ */ jsxs("div", { className: "card-field", children: [
642
+ /* @__PURE__ */ jsxs("span", { className: "card-field-label", children: [
643
+ field.label,
644
+ ":"
645
+ ] }),
646
+ /* @__PURE__ */ jsx("span", { className: "card-field-value", children: field.value })
647
+ ] }, i)) }),
648
+ data.description && /* @__PURE__ */ jsx("p", { className: "card-description", children: data.description })
649
+ ] })
650
+ ] }) });
651
+ }
652
+ if (!data.items || !Array.isArray(data.items) || data.items.length === 0) {
653
+ return null;
654
+ }
655
+ return /* @__PURE__ */ jsxs("div", { className: "card-list", children: [
656
+ data.title && !data.items.some((item) => item.title) && /* @__PURE__ */ jsx("h3", { className: "card-list-title", children: data.title }),
657
+ data.description && /* @__PURE__ */ jsx("p", { className: "card-list-description", children: data.description }),
658
+ /* @__PURE__ */ jsx("div", { className: "card-grid", children: data.items.map((item, i) => {
659
+ const itemKey = item.id || `card-item-${i}`;
660
+ const hasImage = item.image && typeof item.image === "string";
661
+ const hasTitle = item.title && typeof item.title === "string";
662
+ const hasSubtitle = item.subtitle && typeof item.subtitle === "string";
663
+ const isLegacyFormat = item.label && item.value;
664
+ if (isLegacyFormat && !hasTitle) {
665
+ return /* @__PURE__ */ jsx("div", { className: "card-item", children: /* @__PURE__ */ jsxs("div", { className: "card-item-legacy", children: [
666
+ /* @__PURE__ */ jsx("dt", { className: "card-item-legacy-label", children: item.label }),
667
+ /* @__PURE__ */ jsx("dd", { className: "card-item-legacy-value", children: item.value })
668
+ ] }) }, itemKey);
669
+ }
670
+ return /* @__PURE__ */ jsx("div", { className: "card-item", children: /* @__PURE__ */ jsxs("div", { className: "card-item-content", children: [
671
+ hasImage && /* @__PURE__ */ jsx(
672
+ "img",
673
+ {
674
+ src: item.image,
675
+ alt: item.title || `Card ${i + 1}`,
676
+ className: "card-item-image",
677
+ onError: (e) => {
678
+ e.target.style.display = "none";
1589
679
  }
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",
680
+ }
681
+ ),
682
+ /* @__PURE__ */ jsxs("div", { className: "card-item-info", children: [
683
+ hasTitle && /* @__PURE__ */ jsx("h4", { className: "card-item-title", children: item.title }),
684
+ hasSubtitle && /* @__PURE__ */ jsx("p", { className: "card-item-subtitle", children: item.subtitle })
685
+ ] })
686
+ ] }) }, itemKey);
687
+ }) })
688
+ ] });
689
+ }
690
+ function FormComponent({
691
+ data,
692
+ onSubmit
693
+ }) {
694
+ const handleSubmit = (e) => {
695
+ e.preventDefault();
696
+ const formData = new FormData(e.currentTarget);
697
+ const values = {};
698
+ data.fields.forEach((f) => {
699
+ const fieldName = f.id || f.name || `field-${data.fields.indexOf(f)}`;
700
+ values[fieldName] = String(formData.get(fieldName) ?? "");
701
+ if (f.type === "file") {
702
+ const file = formData.get(fieldName);
703
+ values[fieldName] = JSON.stringify({
704
+ name: file?.name,
705
+ size: file?.size,
706
+ type: file?.type
707
+ });
708
+ }
709
+ });
710
+ console.log(values);
711
+ onSubmit(values);
712
+ };
713
+ return /* @__PURE__ */ jsxs(
714
+ "form",
715
+ {
716
+ onSubmit: handleSubmit,
717
+ className: "form-component",
718
+ children: [
719
+ data.title && /* @__PURE__ */ jsx("h3", { className: "form-title", children: data.title }),
720
+ /* @__PURE__ */ jsx("div", { className: "form-fields", children: data.fields.map((field, fieldIdx) => {
721
+ return /* @__PURE__ */ jsxs("div", { className: "form-field", children: [
722
+ /* @__PURE__ */ jsxs("label", { className: "form-label", children: [
723
+ field.label,
724
+ field.required && /* @__PURE__ */ jsx("span", { children: "*" })
725
+ ] }),
726
+ field.type === "select" ? /* @__PURE__ */ jsxs(
727
+ "select",
1608
728
  {
1609
- style: {
1610
- display: "flex",
1611
- gap: "8px",
1612
- fontSize: "12px",
1613
- marginBottom: "4px"
1614
- },
729
+ name: field.id || field.name,
730
+ required: field.required,
731
+ defaultValue: field.value ? String(field.value) : "",
732
+ className: "form-select",
1615
733
  children: [
1616
- /* @__PURE__ */ jsx("span", { style: { color: "#6b7280", fontWeight: 500 }, children: "Durum:" }),
1617
- /* @__PURE__ */ jsx("span", { style: { color: "#374151" }, children: data.status })
734
+ /* @__PURE__ */ jsx("option", { value: "", children: "Se\xE7iniz" }),
735
+ field.options?.map((opt, optIdx) => {
736
+ const optKey = typeof opt.value === "string" ? opt.value : `opt-${fieldIdx}-${optIdx}`;
737
+ return /* @__PURE__ */ jsx("option", { value: opt.value, children: opt.label }, optKey);
738
+ })
1618
739
  ]
1619
740
  }
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",
741
+ ) : field.type === "file" ? /* @__PURE__ */ jsx(
742
+ "input",
1635
743
  {
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
- ))
744
+ type: "file",
745
+ name: field.id || field.name,
746
+ required: field.required,
747
+ className: "form-input",
748
+ accept: field.accept || "*"
1651
749
  }
1652
- ),
1653
- data.description && /* @__PURE__ */ jsx(
1654
- "p",
750
+ ) : /* @__PURE__ */ jsx(
751
+ "input",
1655
752
  {
1656
- style: {
1657
- color: "#6b7280",
1658
- fontSize: "12px",
1659
- marginTop: "8px",
1660
- margin: 0
1661
- },
1662
- children: data.description
753
+ type: field.type === "number" ? "number" : "text",
754
+ name: field.id || field.name,
755
+ required: field.required,
756
+ defaultValue: field.value ? String(field.value) : "",
757
+ placeholder: field.placeholder || "",
758
+ min: field.min,
759
+ max: field.max,
760
+ className: "form-input"
1663
761
  }
1664
762
  )
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
- ] });
763
+ ] }, fieldIdx);
764
+ }) }),
765
+ /* @__PURE__ */ jsx("button", { type: "submit", className: "form-submit-button", children: data.submitLabel ?? "G\xF6nder" })
766
+ ]
767
+ }
768
+ );
1828
769
  }
1829
770
  function renderField(field) {
1830
771
  switch (field.type) {
1831
772
  case "text":
1832
- return /* @__PURE__ */ jsx("span", { children: field.value });
773
+ return /* @__PURE__ */ jsx("span", { className: "field-text", children: field.value });
1833
774
  case "image":
1834
775
  return /* @__PURE__ */ jsx(
1835
776
  "img",
1836
777
  {
1837
778
  src: field.src,
1838
779
  alt: field.alt ?? "",
1839
- style: {
1840
- width: 24,
1841
- height: 24,
1842
- borderRadius: "999px",
1843
- objectFit: "cover"
1844
- }
780
+ className: "field-image"
1845
781
  }
1846
782
  );
1847
783
  case "link":
@@ -1851,38 +787,143 @@ function renderField(field) {
1851
787
  href: field.href,
1852
788
  target: "_blank",
1853
789
  rel: "noreferrer",
1854
- style: { textDecoration: "underline" },
790
+ className: "field-link",
1855
791
  children: field.label
1856
792
  }
1857
793
  );
1858
794
  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
- );
795
+ const toneClass = field.tone || "neutral";
796
+ return /* @__PURE__ */ jsx("span", { className: `field-badge ${toneClass}`, children: field.label });
1874
797
  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)) });
798
+ return /* @__PURE__ */ jsx("ul", { className: "field-list", children: field.items.map((item, i) => /* @__PURE__ */ jsx("li", { children: renderField(item) }, i)) });
1876
799
  default:
1877
800
  return null;
1878
801
  }
1879
802
  }
803
+ function TableComponent({ data }) {
804
+ if (!data.columns || !Array.isArray(data.columns) || data.columns.length === 0) {
805
+ return null;
806
+ }
807
+ return /* @__PURE__ */ jsxs("div", { className: "table-component", children: [
808
+ data.caption && /* @__PURE__ */ jsx("div", { className: "table-caption", children: data.caption }),
809
+ /* @__PURE__ */ jsx("div", { className: "table-wrapper", children: /* @__PURE__ */ jsxs("table", { className: "table", children: [
810
+ /* @__PURE__ */ jsx("thead", { className: "table-header", children: /* @__PURE__ */ jsx("tr", { children: data.columns.map((col, i) => {
811
+ const colKey = typeof col === "string" ? `col-${i}` : col.key || col.id || `col-${i}`;
812
+ const colLabel = typeof col === "string" ? col : col.label || "";
813
+ return /* @__PURE__ */ jsx("th", { className: "table-th", children: colLabel }, colKey);
814
+ }) }) }),
815
+ /* @__PURE__ */ jsx("tbody", { className: "table-tbody", children: data.rows && data.rows.length > 0 ? data.rows.map((row, rowIdx) => /* @__PURE__ */ jsx("tr", { children: data.columns.map((col, colIdx) => {
816
+ const colKey = typeof col === "string" ? `col-${colIdx}` : col.key || col.id || `col-${colIdx}`;
817
+ const colType = typeof col === "object" ? col.type : void 0;
818
+ const cellKey = `cell-${rowIdx}-${colIdx}`;
819
+ let cellContent = null;
820
+ if (typeof row === "object" && row !== null && !Array.isArray(row)) {
821
+ const cellValue = row[colKey];
822
+ if (cellValue !== void 0 && cellValue !== null) {
823
+ if (typeof cellValue === "object" && "type" in cellValue) {
824
+ cellContent = renderField(cellValue);
825
+ } else {
826
+ const stringValue = String(cellValue);
827
+ const isImageUrl = typeof stringValue === "string" && (stringValue.startsWith("http") || stringValue.startsWith("data:") || stringValue.startsWith("/")) && (stringValue.match(
828
+ /\.(jpg|jpeg|png|gif|webp|svg)$/i
829
+ ) || stringValue.includes("image") || stringValue.includes("avatar"));
830
+ if (colType === "image" || !colType && isImageUrl) {
831
+ cellContent = /* @__PURE__ */ jsx("div", { className: "table-cell-image", children: /* @__PURE__ */ jsx(
832
+ "img",
833
+ {
834
+ src: stringValue,
835
+ alt: "",
836
+ className: "table-image",
837
+ onError: (e) => {
838
+ e.target.style.display = "none";
839
+ }
840
+ }
841
+ ) });
842
+ } else {
843
+ cellContent = /* @__PURE__ */ jsx("span", { className: "table-cell-text", children: stringValue });
844
+ }
845
+ }
846
+ }
847
+ } else if (Array.isArray(row)) {
848
+ const cellValue = row[colIdx];
849
+ if (cellValue !== void 0 && cellValue !== null) {
850
+ const stringValue = String(cellValue);
851
+ const isImageUrl = typeof stringValue === "string" && (stringValue.startsWith("http") || stringValue.startsWith("data:") || stringValue.startsWith("/")) && (stringValue.match(
852
+ /\.(jpg|jpeg|png|gif|webp|svg)$/i
853
+ ) || stringValue.includes("image") || stringValue.includes("avatar"));
854
+ if (colType === "image" || !colType && isImageUrl) {
855
+ cellContent = /* @__PURE__ */ jsx("div", { className: "table-cell-image", children: /* @__PURE__ */ jsx(
856
+ "img",
857
+ {
858
+ src: stringValue,
859
+ alt: "",
860
+ className: "table-image",
861
+ onError: (e) => {
862
+ e.target.style.display = "none";
863
+ }
864
+ }
865
+ ) });
866
+ } else {
867
+ cellContent = /* @__PURE__ */ jsx("span", { className: "table-cell-text", children: stringValue });
868
+ }
869
+ }
870
+ }
871
+ return /* @__PURE__ */ jsx("td", { className: "table-td", children: cellContent || /* @__PURE__ */ jsx("span", { children: "\u2014" }) }, cellKey);
872
+ }) }, `row-${rowIdx}`)) : /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan: data.columns.length, className: "table-empty", children: "Veri bulunamad\u0131" }) }) })
873
+ ] }) })
874
+ ] });
875
+ }
876
+ function GenerativeUI({ components, onInteraction }) {
877
+ console.log(components);
878
+ if (!Array.isArray(components) || components.length === 0) {
879
+ return null;
880
+ }
881
+ return /* @__PURE__ */ jsx("div", { className: "ui-renderer", children: components.map((comp, idx) => {
882
+ if (!comp || typeof comp !== "object" || !comp.type) {
883
+ return null;
884
+ }
885
+ const key = typeof comp.id === "string" && comp.id.trim() ? comp.id : `${comp.type}-${idx}`;
886
+ switch (comp.type) {
887
+ case "form":
888
+ return /* @__PURE__ */ jsx(
889
+ FormComponent,
890
+ {
891
+ data: comp.data,
892
+ onSubmit: (values) => onInteraction?.({
893
+ type: "formSubmit",
894
+ componentId: comp.data.id,
895
+ values
896
+ })
897
+ },
898
+ key
899
+ );
900
+ case "buttons":
901
+ if (!comp.data || !Array.isArray(comp.data)) {
902
+ return null;
903
+ }
904
+ return /* @__PURE__ */ jsx(
905
+ ButtonsComponent,
906
+ {
907
+ data: comp.data,
908
+ onClick: (value) => onInteraction?.({ type: "buttonClick", value })
909
+ },
910
+ key
911
+ );
912
+ case "table":
913
+ return /* @__PURE__ */ jsx(TableComponent, { data: comp.data }, key);
914
+ case "card":
915
+ return /* @__PURE__ */ jsx(CardComponent, { data: comp.data }, key);
916
+ default:
917
+ return null;
918
+ }
919
+ }) });
920
+ }
1880
921
  var AizekChatBot = ({
1881
922
  clientId,
1882
923
  headers
1883
924
  }) => {
1884
925
  const defaultConfig = {
1885
- welcomeMessage: "Merhaba! Size nas\u0131l yard\u0131mc\u0131 olabilirim?",
926
+ welcomeMessage: "Merhaba! Size nas\u0131l yard\u0131mc\u0131 olabilirimmmmm?",
1886
927
  buttonBackground: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
1887
928
  placeholder: "Mesaj\u0131n\u0131z\u0131 yaz\u0131n...",
1888
929
  buttonPosition: "bottom-left",
@@ -1971,50 +1012,33 @@ var AizekChatBot = ({
1971
1012
  }, [messages]);
1972
1013
  const MessageBubble = ({ message, onAction }) => {
1973
1014
  const isUser = message.role === "user";
1974
- return /* @__PURE__ */ jsxs("div", { style: getMessageContainerStyles(isUser), children: [
1975
- /* @__PURE__ */ jsx("style", { children: getMarkdownElementStyles(isUser) }),
1015
+ return /* @__PURE__ */ jsxs("div", { className: `message-container ${isUser ? "user" : "assistant"}`, children: [
1976
1016
  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", {
1017
+ /* @__PURE__ */ jsx("div", { className: `message-bubble ${isUser ? "user" : "assistant"}`, children: message.text && /* @__PURE__ */ jsx("div", { className: "markdown-content", children: message.text }) }),
1018
+ /* @__PURE__ */ jsx("div", { className: `message-time ${isUser ? "user" : "assistant"}`, children: message.timestamp.toLocaleTimeString("tr-TR", {
1979
1019
  hour: "2-digit",
1980
1020
  minute: "2-digit"
1981
1021
  }) })
1982
1022
  ] }),
1983
1023
  !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
- }
1024
+ /* @__PURE__ */ jsx("div", { className: `message-bubble ${isUser ? "user" : "assistant"}`, children: message.isTyping ? /* @__PURE__ */ jsx("div", { className: "message-typing-indicator", children: /* @__PURE__ */ jsx(TypingDots, {}) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1025
+ /* @__PURE__ */ jsx("div", { className: "markdown-content", children: /* @__PURE__ */ jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], children: message.text }) }),
1026
+ message.ui && /* @__PURE__ */ jsx(
1027
+ GenerativeUI,
1028
+ {
1029
+ components: message.ui,
1030
+ onInteraction: (event) => {
1031
+ console.log(event);
1032
+ if (event.type === "buttonClick" && typeof event.value === "string") {
1033
+ onAction(event.value, true);
1034
+ } else if (event.type === "formSubmit") {
1035
+ onAction(JSON.stringify(event.values), true);
2012
1036
  }
2013
- )
2014
- ] })
2015
- }
2016
- ),
2017
- /* @__PURE__ */ jsx("div", { style: getTimeStyles(isUser), children: message.timestamp.toLocaleTimeString("tr-TR", {
1037
+ }
1038
+ }
1039
+ )
1040
+ ] }) }),
1041
+ /* @__PURE__ */ jsx("div", { className: `message-time ${isUser ? "user" : "assistant"}`, children: message.timestamp.toLocaleTimeString("tr-TR", {
2018
1042
  hour: "2-digit",
2019
1043
  minute: "2-digit"
2020
1044
  }) })
@@ -2049,132 +1073,44 @@ var AizekChatBot = ({
2049
1073
  }
2050
1074
  return /* @__PURE__ */ jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { d: "M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z" }) });
2051
1075
  };
2052
- return /* @__PURE__ */ jsxs(Fragment, { children: [
2053
- /* @__PURE__ */ jsx("style", { children: getAlertAnimationStyles() }),
2054
- /* @__PURE__ */ jsxs("div", { style: getAlertContainerStyles(alertType), children: [
2055
- /* @__PURE__ */ jsx("div", { style: getAlertIconContainerStyles(), children: getAlertIcon() }),
2056
- /* @__PURE__ */ jsxs("div", { style: getAlertContentStyles(), children: [
2057
- /* @__PURE__ */ jsx("h4", { style: getAlertTitleStyles(), children: hasErrors ? "Header Do\u011Frulama Hatas\u0131" : "Header Uyar\u0131s\u0131" }),
2058
- /* @__PURE__ */ jsx("p", { style: getAlertMessageStyles(), children: hasErrors && hasWarnings ? "Header yap\u0131land\u0131rman\u0131zda hatalar ve uyar\u0131lar bulundu." : hasErrors ? "Header yap\u0131land\u0131rman\u0131zda hatalar bulundu." : "Header yap\u0131land\u0131rman\u0131zda fazla anahtarlar bulundu." }),
2059
- missingKeys.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
2060
- /* @__PURE__ */ jsx("strong", { style: { fontSize: "13px" }, children: "Eksik Header'lar:" }),
2061
- /* @__PURE__ */ jsx("ul", { style: getAlertListStyles(), children: missingKeys.map((key, index) => /* @__PURE__ */ jsxs("li", { style: getAlertListItemStyles(), children: [
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
- )
2087
- ] }, index)) })
2088
- ] }),
2089
- emptyValueKeys.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
2090
- /* @__PURE__ */ jsx("strong", { style: { fontSize: "13px" }, children: "Bo\u015F De\u011Ferli Header'lar:" }),
2091
- /* @__PURE__ */ jsx("ul", { style: getAlertListStyles(), children: emptyValueKeys.map((key, index) => /* @__PURE__ */ jsxs("li", { style: getAlertListItemStyles(), children: [
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
- )
2128
- ] }, index)) })
2129
- ] }),
2130
- extraKeys.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
2131
- /* @__PURE__ */ jsx("strong", { style: { fontSize: "13px" }, children: "Fazla Header'lar:" }),
2132
- /* @__PURE__ */ jsx("ul", { style: getAlertListStyles(), children: extraKeys.map((key, index) => /* @__PURE__ */ jsxs("li", { style: getAlertListItemStyles(), children: [
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
- )
2158
- ] }, index)) })
2159
- ] })
1076
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: `alert-container ${alertType}`, children: [
1077
+ /* @__PURE__ */ jsx("div", { className: "alert-icon-container", children: getAlertIcon() }),
1078
+ /* @__PURE__ */ jsxs("div", { className: "alert-content", children: [
1079
+ /* @__PURE__ */ jsx("h4", { className: "alert-title", children: hasErrors ? "Header Do\u011Frulama Hatas\u0131" : "Header Uyar\u0131s\u0131" }),
1080
+ /* @__PURE__ */ jsx("p", { className: "alert-message", children: hasErrors && hasWarnings ? "Header yap\u0131land\u0131rman\u0131zda hatalar ve uyar\u0131lar bulundu." : hasErrors ? "Header yap\u0131land\u0131rman\u0131zda hatalar bulundu." : "Header yap\u0131land\u0131rman\u0131zda fazla anahtarlar bulundu." }),
1081
+ missingKeys.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
1082
+ /* @__PURE__ */ jsx("strong", { children: "Eksik Header'lar:" }),
1083
+ /* @__PURE__ */ jsx("ul", { className: "alert-list", children: missingKeys.map((key, index) => /* @__PURE__ */ jsxs("li", { className: "alert-list-item", children: [
1084
+ /* @__PURE__ */ jsx("span", { children: "\u2022" }),
1085
+ /* @__PURE__ */ jsx("code", { children: key })
1086
+ ] }, index)) })
2160
1087
  ] }),
2161
- /* @__PURE__ */ jsx(
2162
- "button",
2163
- {
2164
- onClick: () => setShowAlert(false),
2165
- style: getAlertCloseButtonStyles(),
2166
- onMouseEnter: (e) => {
2167
- e.currentTarget.style.background = "rgba(255, 255, 255, 0.3)";
2168
- },
2169
- onMouseLeave: (e) => {
2170
- e.currentTarget.style.background = "rgba(255, 255, 255, 0.2)";
2171
- },
2172
- "aria-label": "Uyar\u0131y\u0131 kapat",
2173
- children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) })
2174
- }
2175
- )
2176
- ] })
2177
- ] });
1088
+ emptyValueKeys.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
1089
+ /* @__PURE__ */ jsx("strong", { children: "Bo\u015F De\u011Ferli Header'lar:" }),
1090
+ /* @__PURE__ */ jsx("ul", { className: "alert-list", children: emptyValueKeys.map((key, index) => /* @__PURE__ */ jsxs("li", { className: "alert-list-item", children: [
1091
+ /* @__PURE__ */ jsx("span", { children: "\u2022" }),
1092
+ /* @__PURE__ */ jsx("code", { children: key }),
1093
+ /* @__PURE__ */ jsx("span", { children: "(de\u011Fer bo\u015F olamaz)" })
1094
+ ] }, index)) })
1095
+ ] }),
1096
+ extraKeys.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
1097
+ /* @__PURE__ */ jsx("strong", { children: "Fazla Header'lar:" }),
1098
+ /* @__PURE__ */ jsx("ul", { className: "alert-list", children: extraKeys.map((key, index) => /* @__PURE__ */ jsxs("li", { className: "alert-list-item", children: [
1099
+ /* @__PURE__ */ jsx("span", { children: "\u2022" }),
1100
+ /* @__PURE__ */ jsx("code", { children: key })
1101
+ ] }, index)) })
1102
+ ] })
1103
+ ] }),
1104
+ /* @__PURE__ */ jsx(
1105
+ "button",
1106
+ {
1107
+ onClick: () => setShowAlert(false),
1108
+ className: "alert-close-button",
1109
+ "aria-label": "Uyar\u0131y\u0131 kapat",
1110
+ children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) })
1111
+ }
1112
+ )
1113
+ ] }) });
2178
1114
  };
2179
1115
  const ChatInput = () => {
2180
1116
  const [message, setMessage] = useState("");
@@ -2201,7 +1137,7 @@ var AizekChatBot = ({
2201
1137
  textarea.style.height = "auto";
2202
1138
  textarea.style.height = Math.min(textarea.scrollHeight, 120) + "px";
2203
1139
  };
2204
- return /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, style: getInputContainerStyles(), children: [
1140
+ return /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, className: "input-container", children: [
2205
1141
  /* @__PURE__ */ jsx(
2206
1142
  "textarea",
2207
1143
  {
@@ -2211,7 +1147,7 @@ var AizekChatBot = ({
2211
1147
  onKeyDown: handleKeyDown,
2212
1148
  placeholder,
2213
1149
  disabled: isLoading,
2214
- style: getTextareaStyles(isLoading)
1150
+ className: "textarea"
2215
1151
  }
2216
1152
  ),
2217
1153
  /* @__PURE__ */ jsx(
@@ -2219,124 +1155,80 @@ var AizekChatBot = ({
2219
1155
  {
2220
1156
  type: "submit",
2221
1157
  disabled: isLoading || !message.trim(),
2222
- style: getSendButtonStyles(isLoading, !!message.trim()),
2223
- onMouseEnter: (e) => {
2224
- if (!isLoading && message.trim()) {
2225
- e.currentTarget.style.transform = "scale(1.05)";
2226
- }
2227
- },
2228
- onMouseLeave: (e) => {
2229
- e.currentTarget.style.transform = "scale(1)";
2230
- },
1158
+ className: "send-button",
2231
1159
  children: isLoading ? /* @__PURE__ */ jsx(LoadingSpinner, {}) : /* @__PURE__ */ jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { d: "M2.01 21L23 12 2.01 3 2 10l15 2-15 2z" }) })
2232
1160
  }
2233
1161
  )
2234
1162
  ] });
2235
1163
  };
2236
1164
  const LoadingSpinner = () => {
2237
- return /* @__PURE__ */ jsx("div", { style: getLoadingSpinnerStyles() });
1165
+ return /* @__PURE__ */ jsx("div", { className: "loading-spinner" });
2238
1166
  };
2239
1167
  if (isConfigLoading) {
2240
1168
  return /* @__PURE__ */ jsx(
2241
- "div",
1169
+ "button",
2242
1170
  {
2243
- style: getFloatingButtonStyles(
2244
- buttonPosition,
2245
- buttonSize,
2246
- buttonBackground,
2247
- false
2248
- ),
2249
- children: /* @__PURE__ */ jsx("div", { style: getLoadingSpinnerStyles() })
1171
+ className: `floating-button ${buttonPosition} button-sizes ${buttonSize}`,
1172
+ style: { background: buttonBackground },
1173
+ children: /* @__PURE__ */ jsx("div", { className: "loading-spinner" })
2250
1174
  }
2251
1175
  );
2252
1176
  }
2253
1177
  return /* @__PURE__ */ jsxs(Fragment, { children: [
2254
- isOpen && /* @__PURE__ */ jsx(
2255
- "div",
2256
- {
2257
- style: getOverlayStyles(isOpen),
2258
- onClick: toggleChat,
2259
- className: "floating-chat-overlay"
2260
- }
2261
- ),
2262
- /* @__PURE__ */ jsx(
2263
- "div",
2264
- {
2265
- style: getChatContainerStyles(
2266
- buttonPosition,
2267
- chatWidth,
2268
- chatHeight,
2269
- isOpen
2270
- ),
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, {})
1178
+ isOpen && /* @__PURE__ */ jsx("div", { className: `overlay floating-chat-overlay ${isOpen ? "is-open" : ""}`, onClick: toggleChat }),
1179
+ /* @__PURE__ */ jsx("div", { className: `chat-container ${buttonPosition} ${isOpen ? "is-open" : ""}`, style: { width: chatWidth, height: chatHeight }, children: /* @__PURE__ */ jsxs("div", { className: "chatbot-container", children: [
1180
+ /* @__PURE__ */ jsxs("div", { className: "header", style: { background: headerBackground }, children: [
1181
+ /* @__PURE__ */ jsx("div", { className: "logo-container", children: companyLogo ? companyLogo.startsWith("http") || companyLogo.startsWith("data:") ? /* @__PURE__ */ jsx(
1182
+ "img",
1183
+ {
1184
+ src: companyLogo,
1185
+ alt: "Company Logo",
1186
+ className: "logo-image"
1187
+ }
1188
+ ) : /* @__PURE__ */ jsx("span", { className: "logo-text", children: companyLogo }) : "\u{1F916}" }),
1189
+ /* @__PURE__ */ jsxs("div", { children: [
1190
+ /* @__PURE__ */ jsx("h3", { className: "company-name", children: companyName }),
1191
+ /* @__PURE__ */ jsx("p", { className: "status-text", children: isLoading ? "Yaz\u0131yor..." : "\xC7evrimi\xE7i" })
2318
1192
  ] })
2319
- }
2320
- ),
1193
+ ] }),
1194
+ /* @__PURE__ */ jsxs("div", { className: "messages-container", children: [
1195
+ /* @__PURE__ */ jsx(HeaderValidationAlert, {}),
1196
+ messages.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "empty-state", children: [
1197
+ /* @__PURE__ */ jsx("div", { className: "empty-state-icon", children: "\u{1F4AC}" }),
1198
+ /* @__PURE__ */ jsx("h4", { className: "empty-state-title", children: welcomeMessage }),
1199
+ /* @__PURE__ */ jsx("p", { className: "empty-state-description", children: "A\u015Fa\u011F\u0131daki alana mesaj\u0131n\u0131z\u0131 yazarak ba\u015Flayabilirsiniz." })
1200
+ ] }) : messages.map((message) => /* @__PURE__ */ jsx(
1201
+ MessageBubble,
1202
+ {
1203
+ message,
1204
+ onAction: handleSendMessage
1205
+ },
1206
+ message.id
1207
+ )),
1208
+ showTypingIndicator && isLoading && messages.length > 0 && /* @__PURE__ */ jsx(
1209
+ MessageBubble,
1210
+ {
1211
+ message: {
1212
+ id: `typing-${messages.length}`,
1213
+ text: "",
1214
+ role: "assistant",
1215
+ timestamp: /* @__PURE__ */ new Date(),
1216
+ isTyping: true
1217
+ },
1218
+ onAction: handleSendMessage
1219
+ },
1220
+ `typing-${messages.length}`
1221
+ ),
1222
+ /* @__PURE__ */ jsx("div", { ref: messagesEndRef })
1223
+ ] }),
1224
+ /* @__PURE__ */ jsx(ChatInput, {})
1225
+ ] }) }),
2321
1226
  /* @__PURE__ */ jsx(
2322
1227
  "button",
2323
1228
  {
2324
1229
  onClick: toggleChat,
2325
- style: getFloatingButtonStyles(
2326
- buttonPosition,
2327
- buttonSize,
2328
- buttonBackground,
2329
- isOpen
2330
- ),
2331
- onMouseEnter: (e) => {
2332
- e.currentTarget.style.transform = isOpen ? "scale(0.85)" : "scale(1.1)";
2333
- e.currentTarget.style.boxShadow = "0 6px 20px rgba(0, 0, 0, 0.25)";
2334
- },
2335
- onMouseLeave: (e) => {
2336
- e.currentTarget.style.transform = isOpen ? "scale(0.9)" : "scale(1)";
2337
- e.currentTarget.style.boxShadow = "0 4px 12px rgba(0, 0, 0, 0.15)";
2338
- },
2339
- className: "floating-chat-button",
1230
+ className: `floating-button ${buttonPosition} button-sizes ${buttonSize} ${isOpen ? "is-open" : ""}`,
1231
+ style: { background: buttonBackground },
2340
1232
  "aria-label": isOpen ? "Chati kapat" : "Chati a\xE7",
2341
1233
  children: isOpen ? /* @__PURE__ */ jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) }) : /* @__PURE__ */ jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { d: "M20 2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h4l4 4 4-4h4c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-2 12H6v-2h12v2zm0-3H6V9h12v2zm0-3H6V6h12v2z" }) })
2342
1234
  }
@@ -2344,6 +1236,6 @@ var AizekChatBot = ({
2344
1236
  ] });
2345
1237
  };
2346
1238
 
2347
- export { AizekChatBot, Button, useChatbot };
1239
+ export { AizekChatBot };
2348
1240
  //# sourceMappingURL=index.mjs.map
2349
1241
  //# sourceMappingURL=index.mjs.map