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 
 
 
 
 
eb6f430
 
d1f45a6
eb6f430
 
 
d1f45a6
eb6f430
 
 
d1f45a6
 
 
 
 
eb6f430
d1f45a6
 
 
eb6f430
 
 
d1f45a6
 
eb6f430
d1f45a6
 
 
 
 
 
eb6f430
 
 
d1f45a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
eb6f430
d1f45a6
 
 
 
 
eb6f430
d1f45a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
eb6f430
 
d1f45a6
 
 
 
 
 
 
eb6f430
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d1f45a6
 
 
 
 
 
 
eb6f430
d1f45a6
eb6f430
d1f45a6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
<!DOCTYPE html>
<html lang="he" dir="rtl">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>צ'אאאט בינה מל מלאכותית - ס סגנון צברי</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
  <style>
    :root {
      --primary-color: #0056b3;
      --secondary-color: #ffd700;
      --accent-color: #d40000;
      --bg-color: #f5f5f5;
      --chat-bg: #ffffff;
      --text-color: #333;
      --user-bubble: #e3f2fd;
      --ai-bubble: #f1f1f1;
    }

    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    }

    body {
      background-color: var(--bg-color);
      color: var(--text-color);
      direction: rtl;
    }

    .header {
      background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
      color: white;
      padding: 1rem;
      text-align: center;
      box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
      position: relative;
    }

    .header h1 {
      font-size: 1.8rem;
      margin-bottom: 0.5rem;
      font-weight: bold;
    }

    .header p {
      font-size: 0.9rem;
      opacity: 0.9;
    }

    .header a {
      position: absolute;
      left: 1rem;
      top: 50%;
      transform: translateY(-50%);
      color: white;
      text-decoration: none;
      font-size: 0.8rem;
    }

    .container {
      max-width: 1000px;
      margin: 0 auto;
      padding: 1rem;
    }

    .chat-container {
      background-color: var(--chat-bg);
      border-radius: 10px;
      box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
      overflow: hidden;
      height: 70vh;
      display: flex;
      flex-direction: column;
    }

    .chat-messages {
      flex: 1;
      padding: 1rem;
      overflow-y: auto;
      display: flex;
      flex-direction: column;
      gap: 1rem;
    }

    .message {
      max-width: 80%;
      padding: 0.8rem 1rem;
      border-radius: 15px;
      line-height: 1.4;
      position: relative;
      animation: fadeIn 0.3s ease;
    }

    @keyframes fadeIn {
      from {
        opacity: 0;
        transform: translateY(10px);
      }

      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    .user-message {
      align-self: flex-end;
      background-color: var(--user-bubble);
      border-bottom-right-radius: 5px;
      color: #000;
      font-weight: 500;
    }

    .ai-message {
      align-self: flex-start;
      background-color: var(--ai-bubble);
      border-bottom-left-radius: 5px;
      color: #000;
      font-weight: bold;
    }

    .ai-message::before {
      content: "🤖";
      margin-left: 5px;
    }

    .user-message::before {
      content: "👤";
      margin-right: 5px;
    }

    .input-area {
      display: flex;
      padding: 1rem;
      background-color: #fff;
      border-top: 1px solid #eee;
      gap: 0.5rem;
      position: relative;
    }

    .input-area input {
      flex: 1;
      padding: 0.8rem 1rem;
      border: 1px solid #ddd;
      border-radius: 25px;
      font-size: 1rem;
      outline: none;
      transition: border 0.3s;
    }

    .input-area input:focus {
      border-color: var(--primary-color);
    }

    .input-area button {
      background-color: var(--primary-color);
      color: white;
      border: none;
      border-radius: 25px;
      padding: 0 1.5rem;
      cursor: pointer;
      font-weight: bold;
      transition: background 0.3s;
    }

    .input-area button:hover {
      background-color: #003d82;
    }

    .file-upload {
      position: relative;
      width: 40px;
      height: 40px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 50%;
      background-color: var(--secondary-color);
      color: #333;
      cursor: pointer;
    }

    .file-upload input {
      position: absolute;
      width: 100%;
      height: 100%;
      opacity: 0;
      cursor: pointer;
    }

    .typing-indicator {
      display: flex;
      align-items: center;
      gap: 5px;
      padding: 0.5rem 1rem;
      background-color: var(--ai-bubble);
      border-radius: 15px;
      align-self: flex-start;
      margin-bottom: 0.5rem;
      display: none;
    }

    .typing-dot {
      width: 8px;
      height: 8px;
      background-color: #666;
      border-radius: 50%;
      animation: typingAnimation 1.4s infinite ease-in-out;
    }

    .typing-dot:nth-child(1) {
      animation-delay: 0s;
    }

    .typing-dot:nth-child(2) {
      animation-delay: 0.2s;
    }

    .typing-dot:nth-child(3) {
      animation-delay: 0.4s;
    }

    @keyframes typingAnimation {

      0%,
      60%,
      100% {
        transform: translateY(0);
      }

      30% {
        transform: translateY(-5px);
      }
    }

    .uploaded-file {
      display: inline-block;
      margin-top: 0.5rem;
      padding: 0.5rem;
      background-color: rgba(0, 0, 0, 0.05);
      border-radius: 5px;
      font-size: 0.8rem;
    }

    .uploaded-file i {
      margin-left: 5px;
    }

    .uploaded-image {
      max-width: 200px;
      max-height: 200px;
      border-radius: 10px;
      margin-top: 0.5rem;
      cursor: pointer;
      transition: transform 0.2s;
    }

    .uploaded-image:hover {
      transform: scale(1.05);
    }

    /* Preview message styling */
    .preview-message {
      position: absolute;
      bottom: 100%;
      right: 1rem;
      background-color: var(--user-bubble);
      padding: 0.8rem 1rem;
      border-radius: 15px;
      border-bottom-right-radius: 5px;
      max-width: 80%;
      opacity: 0;
      transform: translateY(20px);
      transition: all 0.3s ease;
      pointer-events: none;
      box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }

    .preview-message.visible {
      opacity: 0.8;
      transform: translateY(0);
    }

    .preview-message::before {
      content: "👤";
      margin-right: 5px;
    }

    @media (max-width: 768px) {
      .chat-container {
        height: 80vh;
      }

      .message {
        max-width: 90%;
      }

      .input-area {
        flex-direction: row;
        align-items: center;
      }

      .file-upload {
        width: 35px;
        height: 35px;
      }
      
      .preview-message {
        max-width: 70%;
      }
    }

    /* Israeli style additions */
    .ai-message {
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      font-weight: bold;
    }

    .bold-text {
      font-weight: bold;
    }

    .punctuation {
      color: var(--accent-color);
      font-weight: bold;
    }

    .israeli-slang {
      color: var(--primary-color);
      font-style: italic;
    }
  </style>
</head>

<body>
  <div class="header">
    <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank">Built with anycoder</a>
    <h1>צ'אט בינה מלאכותית ב ב בסגנון צברי!  🤖💬</h1>
    <p>שששאל כל שאלה ו וקבל ת תשובה ב ב בסגנון ישראלי נוועז!</p>
  </div>

  <div class="container">
    <div class="chat-container">
      <div class="chat-messages" id="chat-messages">
        <div class="ai-message">
          <span class="bold-text">היי חבר!   👋</span> <span class="punctuation">!</span><br>
                    אני הבוט הצברי של שלך, מו מוכן לע לע לעזור עם כל מה שא שא שאתה צריך
          <span class="israeli-slang">(גם אם זה קצת משוגע...)</span>.<br>
          <span class="punctuation">??</span> <span class="bold-text">מה הבררנז'ה</span>
        </div>
      </div>

      <div class="typing-indicator" id="typing-indicator">
        <div class="typing-dot"></div>
        <div class="typing-dot"></div>
        <div class="typing-dot"></div>
      </div>

      <div class="input-area">
        <div class="file-upload" title="ההעללאת קובובובץ או תמונה">
          <i class="fas fa-paperclip"></i>
          <input type="file" id="file-input" accept=".txt,.pdf,.doc,.docx,.jpg,.jpeg,.png,.gif">
        </div>
        <input type="text" id="user-input" placeholder="כתוב כאן את ההודעה של של שלך..." autocomplete="off">
        <button id="send-button"><i class="fas fa-paper-plane"></i> של של שלח</button>
        <div class="preview-message" id="preview-message"></div>
      </div>
    </div>
  </div>

  <script>
    document.addEventListener('DOMContentLoaded', function() {
            const chatMessages = document.getElementById('chat-messages');
            const userInput = document.getElementById('user-input');
            const sendButton = document.getElementById('send-button');
            const fileInput = document.getElementById('file-input');
            const typingIndicator = document.getElementById('typing-indicator');
            const previewMessage = document.getElementById('preview-message');

            // Sample Israeli-style responses
            const israeliResponses = [
                "וואי אחי, איזה שאלה!  😎 ה ה הנה הת התשובה שלי:",
                "תשמע, זה לא פ פשוט אבל א א אנסה להסביר:",
                "יאללה בוא נ נדבר על זה...",
                "חחח, אייזה כיף ש ששאלת! אז כ ככה:",
                "וואו, שאלה מטורפת! ה הנה מה שא שאני חושב:",
                "תראה, אני א א אגיד לך את הא האמת...",
                "בום! ה הנה הת הת התשובה של של שלך:",
                "נו טוב, בוא נ נטפל ב בזה...",
                "סבבה, אני על זה! ה ה הנה מה שמ שמצאתי:",
                "אוקיי, בוא ניגש לע לע לעניין..."
            ];

            // Sample Israeli slang words to sprinkle in responses
            const israeliSlang = [
                "אאחי", "סבבה", "יאללה", "חחח", "וואי", "נו", "תראה", "ברנז'ה", 
                "מממטורף", "כיף", "פצצה", "אאש", "סתם", "חמוד", "ממגניב", "פאדיחה"
            ];

            // Function to add punctuation for Israeli style
            function addPunctuation(text) {
                const punctuations = ["!", "?", "...", "!!", "??"];
                // 30% chance to add punctuation at end
                if (Math.random() < 0.3) {
                    return text + punctuations[Math.floor(Math.random() * punctuations.length)];
                }
                return text;
            }

            // Function to add bold text randomly
            function addBold(text) {
                const words = text.split(' ');
                // 20% chance to make a word bold
                return words.map(word => 
                    Math.random() < 0.2 ? `<span class="bold-text">${word}</span>` : word
                ).join(' ');
            }

            // Function to add slang randomly
            function addSlang(text) {
                // 15% chance to add slang
                if (Math.random() < 0.15) {
                    const slang = israeliSlang[Math.floor(Math.random() * israeliSlang.length)];
                    const positions = [
                        ` ${slang}, `,
                        ` ${slang}... `,
                        ` (${slang}) `,
                        ` - ${slang} - `
                    ];
                    const position = positions[Math.floor(Math.random() * positions.length)];
                    const insertAt = Math.floor(Math.random() * text.length);
                    return text.slice(0, insertAt) + position + text.slice(insertAt);
                }
                return text;
            }

            // Function to generate AI response
            function generateAIResponse(userMessage, fileContent = null) {
                let response = israeliResponses[Math.floor(Math.random() * israeliResponses.length)];
                
                if (fileContent) {
                    response += `<br><span class="punctuation">!!</span> ראיתי את הקובובובץ שה שהעלת <span class="israeli-slang">(ממגניב)</span>`;
                }
                
                // Generate some "intelligent" response based on user input
                const inputWords = userMessage.split(' ');
                if (inputWords.length > 3) {
                    response += `<br>לגבי "${inputWords.slice(0, 3).join(' ')}...", אני חושב ש`;
                    
                    const opinions = [
                        "זה מ מ ממש מע מעניין!",
                        "צריך לחשוב על זה יותר לעוומומק.",
                        "יש לי כמה ר רעיונות לגבי זה.",
                        "זה נושא חשוב ש ש שצריך ל ל לבדוק.",
                        "אאני מס מסכים איתיתך לגמרי!",
                        "יש לי נקודת מב מב מבט קצת שונה...",
                        "זה משהו שכולם צריכים לדעת.",
                        "אאאני לא בטוח שא שאני מס מסכים עם זה.",
                        "וואו, מעולם לא ח חשבתי על זה כ ככה!",
                        "זה נושא ש ש שדורש עוד מחקר."
                    ];
                    
                    response += opinions[Math.floor(Math.random() * opinions.length)];
                } else {
                    response += "<br>" + [
                        "אייייזה כיף שא שאתה פה!",
                        "מה עוד מע מעניין אותך לדעת?",
                        "יש ל לך עוד שאלות בש בשבילי?",
                        "אאני פה לכל מה שא שאתה צריך!",
                        "ממשהו נוס נוסף שברצונונונך ל לשאול?",
                        "אאאני אוהוהב את הש הש השאלות שלך!",
                        "בוא נ נ נמשיך את השיחה המ המעניינת הזו!",
                        "יש לי כל כך הרבה מה להגיד על זה!",
                        "אתה מעלה נקודות מע מעניינות!",
                        "בוא נ נדבר עוד על הנושא הזה!"
                    ][Math.floor(Math.random() * 10)];
                }
                
                // Add some random facts
                if (Math.random() < 0.4) {
                    const facts = [
                        "<br><br>דרך א א אגב, ידעת ש-90% מהישראלים אוהבים חומווס?",
                        "<br><br>אאאגב, מ מ מחקר חדש מר מראה ש...",
                        "<br><br>קצת טריוויה: התל אביבי המ הממווצע שותה 3 ק ק קפה ביום!",
                        "<br><br>חשבת פעם על זה ש...",
                        "<br><br>משהו מע מעניין: רוב הא האנשים לא יודעים ש..."
                    ];
                    response += facts[Math.floor(Math.random() * facts.length)];
                }
                
                // Process the text with Israeli style
                response = addPunctuation(response);
                response = addBold(response);
                response = addSlang(response);
                
                return response;
            }

            // Function to add message to chat
            function addMessage(content, isUser = false) {
                const messageDiv = document.createElement('div');
                messageDiv.className = `message ${isUser ? 'user-message' : 'ai-message'}`;
                
                if (typeof content === 'string') {
                    messageDiv.innerHTML = content;
                } else {
                    // Handle file content
                    if (content.type.startsWith('image/')) {
                        const reader = new FileReader();
                        reader.onload = function(e) {
                            messageDiv.innerHTML = `<div>${isUser ? 'אתה העלית ת תמונה:' : 'ההנה הת התמונה של של שלך:'}</div>
                            <img src="${e.target.result}" class="uploaded-image" alt="Uploaded image">`;
                        };
                        reader.readAsDataURL(content);
                    } else {
                        messageDiv.innerHTML = `<div class="uploaded-file">
                            <i class="fas fa-file-alt"></i> ${isUser ? 'ההעלית קובובץ:' : 'ההנה הקובץ שלך:'} ${content.name}
                        </div>`;
                    }
                }
                
                chatMessages.appendChild(messageDiv);
                chatMessages.scrollTop = chatMessages.scrollHeight;
            }

            // Function to simulate AI typing
            function simulateTyping(callback) {
                typingIndicator.style.display = 'flex';
                chatMessages.scrollTop = chatMessages.scrollHeight;
                
                // Random typing duration between 1-3 seconds
                const duration = 1000 + Math.random() * 2000;
                
                setTimeout(() => {
                    typingIndicator.style.display = 'none';
                    callback();
                    chatMessages.scrollTop = chatMessages.scrollHeight;
                }, duration);
            }

            // Handle send button click
            sendButton.addEventListener('click', sendMessage);
            
            // Handle Enter key press
            userInput.addEventListener('keypress', function(e) {
                if (e.key === 'Enter') {
                    sendMessage();
                }
            });

            // Handle file upload
            fileInput.addEventListener('change', function(e) {
                if (fileInput.files.length > 0) {
                    const file = fileInput.files[0];
                    addMessage(file, true);
                    
                    // In a real app, you would process the file here
                    // For demo, we'll just show a response
                    simulateTyping(() => {
                        addMessage(generateAIResponse("קובץ שהועלה", true));
                    });
                    
                    // Reset file input
                    fileInput.value = '';
                }
            });

            // Function to send message
            function sendMessage() {
                const message = userInput.value.trim();
                if (message) {
                    addMessage(message, true);
                    userInput.value = '';
                    previewMessage.textContent = '';
                    previewMessage.classList.remove('visible');
                    
                    simulateTyping(() => {
                        addMessage(generateAIResponse(message));
                    });
                }
            }

            // Show preview of message while typing
            userInput.addEventListener('input', function() {
                if (userInput.value.trim()) {
                    previewMessage.textContent = userInput.value;
                    previewMessage.classList.add('visible');
                } else {
                    previewMessage.classList.remove('visible');
                }
            });

            // Hide preview when input loses focus
            userInput.addEventListener('blur', function() {
                setTimeout(() => {
                    previewMessage.classList.remove('visible');
                }, 200);
            });

            // Show preview when input gains focus (if there's text)
            userInput.addEventListener('focus', function() {
                if (userInput.value.trim()) {
                    previewMessage.textContent = userInput.value;
                    previewMessage.classList.add('visible');
                }
            });

            // Initial demo messages
            setTimeout(() => {
                simulateTyping(() => {
                    addMessage("אאני פה כדי לעזור לך עם כל מה שא שאתה צריך, <span class='bold-text'>בלי בעיות!</span> <span class='punctuation'>!!</span>");
                });
            }, 1500);
        });
  </script>
</body>

</html>