Flair
English
code
File size: 25,437 Bytes
d2dbcc2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
<<<<< this file contains your perchance lists first, and your HTML code underneath it >>>>>



generateText = {import:ai-text-plugin}
generateImage = {import:text-to-image-plugin}

$meta
  title = Future HTML
  description = 💻 Coder Helper standalone code assistant 👩‍💻
  image = https://user.uploads.dev/file/a08d899d09d55507326bbf40cc0e9c60.gif
  





















<html lang="en-US">
<meta charset="utf-16">
  <center>
  <p>
  <a href="https://perchance.org/advanced-ai-web-dev">
  🧑‍🔬<br>
» AIdev Tutorial «
  </a>
  </p>
<style>
@import url('https://fonts.googleapis.com/css2?family=VT323&family=Share+Tech+Mono&display=swap');

body { 
  width: 100%;
  max-width: 720px;
  margin: 0px;
  padding: 10px;
  background-color: #000;
  color: #0F0;
  font-family: 'Share Tech Mono', 'Courier New', monospace;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(rgba(0,0,0,0.9), rgba(0,0,0,0.9)), 
              url("data:image/svg+xml,%3Csvg width='100%25' height='100%25' xmlns='http://www.w3.org/2000/svg'%3E%3Cdefs%3E%3Cpattern id='matrix' width='120' height='180' patternUnits='userSpaceOnUse'%3E%3Ctext fill='%2300FF00' font-family='monospace' font-size='14' x='0' y='15'%3E01010111001010101110%3C/text%3E%3Ctext fill='%2300CC00' font-family='monospace' font-size='14' x='10' y='30'%3E10101001010101110010%3C/text%3E%3Ctext fill='%2300FF00' font-family='monospace' font-size='14' x='5' y='45'%3E01010111001010101110%3C/text%3E%3Ctext fill='%2300DD00' font-family='monospace' font-size='14' x='15' y='60'%3E10010101001010100101%3C/text%3E%3Ctext fill='%2300FF00' font-family='monospace' font-size='14' x='0' y='75'%3E01010111001010101110%3C/text%3E%3Ctext fill='%2300CC00' font-family='monospace' font-size='14' x='10' y='90'%3E10101001010101110010%3C/text%3E%3Ctext fill='%2300FF00' font-family='monospace' font-size='14' x='5' y='105'%3E01010111001010101110%3C/text%3E%3Ctext fill='%2300DD00' font-family='monospace' font-size='14' x='15' y='120'%3E10010101001010100101%3C/text%3E%3Ctext fill='%2300FF00' font-family='monospace' font-size='14' x='0' y='135'%3E01010111001010101110%3C/text%3E%3Ctext fill='%2300CC00' font-family='monospace' font-size='14' x='10' y='150'%3E10101001010101110010%3C/text%3E%3Ctext fill='%2300FF00' font-family='monospace' font-size='14' x='5' y='165'%3E01010111001010101110%3C/text%3E%3Ctext fill='%2300DD00' font-family='monospace' font-size='14' x='15' y='180'%3E10010101001010100101%3C/text%3E%3C/pattern%3E%3C/defs%3E%3Crect width='100%25' height='100%25' fill='url(%23matrix)' opacity='0.1'/%3E%3C/svg%3E");
  z-index: -1;
  opacity: 0.2;
}

h1 {
  margin-bottom: 10px;
  color: #0F0;
  font-size: 1.8rem;
  text-align: center;
  text-shadow: 0 0 5px #0F0;
  font-family: 'VT323', monospace;
  letter-spacing: 1px;
}

.chat-container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 10px;
}

.content-area {
  display: flex;
  flex-direction: column;
  width: 100%;
}

#outputCtn {
  width: 100%;
  margin-bottom: 15px;
  padding: 15px;
  background: #000800;
  border-radius: 10px;
  border: 3px solid #0F0;
  box-shadow: 0 0 15px rgba(0,255,0,0.2);
  min-height: 150px;
  position: relative;
  overflow: hidden;
}

#outputCtn::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 255, 0, 0.03),
    rgba(0, 255, 0, 0.03) 2px,
    transparent 2px,
    transparent 4px
  );
  pointer-events: none;
}

.input-container {
  width: 100%;
}

#topicInput {
  width: 100%;
  padding: 12px;
  border: 2px solid #0F0;
  border-radius: 8px;
  margin-bottom: 15px;
  font-size: 1rem;
  resize: vertical;
  background-color: rgba(0, 20, 0, 0.9);
  color: #0F0;
  font-family: 'Share Tech Mono', monospace;
  box-shadow: 0 0 10px rgba(0,255,0,0.2);
}

.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button-group button {
  padding: 10px 15px;
  border: 1px solid #0F0;
  border-radius: 5px;
  background-color: rgba(0, 40, 0, 0.8);
  color: #0F0;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s;
  flex: 1;
  min-width: 120px;
  font-family: 'Share Tech Mono', monospace;
  text-shadow: 0 0 5px #0F0;
  box-shadow: 0 0 10px rgba(0,255,0,0.2);
}

.button-group button:hover {
  background-color: rgba(0, 80, 0, 0.8);
  box-shadow: 0 0 15px rgba(0,255,0,0.4);
}

/* Mobile adjustments */
@media (max-width: 600px) {
  h1 {
    font-size: 1.5rem;
  }
  
  #outputCtn {
    padding: 10px;
  }
  
  .button-group button {
    min-width: 100%;
  }
}
</style>
<div class="main-container">
<a href="https://poe.com/Future-HTML" title="Future-HTML Assistant">
<img src="https://user.uploads.dev/file/a08d899d09d55507326bbf40cc0e9c60.gif" width="222px">
</a>
<hr style="border-color: #0F0; box-shadow: 0 0 5px #0F0;">
   <h1>↓ Future HTML Code Helper ↓</h1>
    <div class="chat-container">
      <div class="content-area">
        <div id="outputCtn">
          <div id="textOutputEl" style="white-space: pre-wrap; font-size: 1.1rem; line-height: 1.5; color: #0F0; font-family: 'Share Tech Mono', monospace;"></div>
        </div>
        <div class="input-container">
          <textarea id="topicInput" placeholder="Enter your HTML, CSS, JavaScript, or coding question:"></textarea>
          <div class="button-group">
            <button id="generateTextBtn" onclick="generateTextOutput()">ANALYZE CODE</button>
            <button id="askGptBtn" onclick="askGPT()">ASK HTML GPT™️</button>
            <button id="copyPromptBtn" onclick="copyPrompt()" style="display: none;">COPY CODE</button>
            <button id="generateImageBtn" onclick="generateImageFromText()" style="display: none;">GENERATE IMAGE</button>
            <button id="stopBtn" hidden onclick="currentPromise?.stop()">Stop Generation</button>
          </div>
        </div>
      </div>
    </div>
</div>
<div class="main-container">
    <h1>AI Text to Image Generator</h1>
    <p class="subtitle" style="color: #0F0; text-shadow: 0 0 3px #0F0;">Create amazing images with AI</p>
  <div class="gallery-container">
    <div class="image-display">
      <img id="generatedImageEl" alt="Generated AI Image" src="https://placehold.co/600x400/000/0F0?text=Your+Image+Will+Appear+Here" style="border: 2px solid #0F0; box-shadow: 0 0 15px rgba(0,255,0,0.3);">
      <div class="prompt-info" id="promptInfoEl"></div>
    </div>
    <div class="prompt-input-container">
      <input type="text" id="customPromptInput" class="prompt-input" placeholder="Enter your image prompt here...">
      <div class="button-container">
        <button id="generateCustomBtn" class="action-button generate-custom-btn">Generate From Prompt</button>
        <button id="generateRandomBtn" class="action-button generate-random-btn">Generate Random</button>
      </div>
      <div id="errorMessageEl" class="error-message" hidden></div>
    </div>
  </div>
  <footer>
    <p style="color: #0F0;">Made with <a href="https://poe.com/Ai-Coder-Thingy" target="_blank" style="color: #0F0; text-decoration: underline;">Ai-Coder-Thingy Assistant</a> | Created 2025</p>
  </footer>
</div>
<style>
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body { font-family: 'Share Tech Mono', 'Courier New', monospace; line-height: 1.6; color: #0F0; background-color: #000; text-align: left; }
  
  .main-container { max-width: 1200px; margin: 0 auto; padding: 20px; }
  
  header { text-align: center; margin-bottom: 30px; }
  header h1 { color: #0F0; margin-bottom: 5px; text-shadow: 0 0 5px #0F0; }
  header .subtitle { color: #0F0; font-size: 1.2rem; }
  
  .gallery-container { display: flex; flex-direction: column; gap: 20px; margin-bottom: 30px; }
  
  .image-display { background-color: rgba(0, 10, 0, 0.8); border-radius: 10px; box-shadow: 0 0 15px rgba(0,255,0,0.2); overflow: hidden; position: relative; border: 1px solid #0F0; }
  .image-display img { width: 100%; height: auto; display: block; max-height: 60vh; object-fit: contain; }
  
  .prompt-info { padding: 15px; background-color: rgba(0, 20, 0, 0.9); color: #0F0; font-size: 0.9rem; border-top: 1px solid #0F0; }
  
  .prompt-input-container { background-color: rgba(0, 10, 0, 0.8); border-radius: 10px; padding: 20px; box-shadow: 0 0 15px rgba(0,255,0,0.2); border: 1px solid #0F0; }
  
  .prompt-input { width: 100%; padding: 12px 15px; border: 2px solid #0F0; border-radius: 5px; font-size: 1rem; margin-bottom: 15px; transition: all 0.3s; background-color: rgba(0, 20, 0, 0.9); color: #0F0; font-family: 'Share Tech Mono', monospace; }
  .prompt-input:focus { border-color: #0F0; outline: none; box-shadow: 0 0 10px rgba(0,255,0,0.4); }
  
  .button-container { display: flex; gap: 10px; flex-wrap: wrap; }
  
  .action-button { padding: 12px 20px; border: 1px solid #0F0; border-radius: 5px; font-size: 1rem; cursor: pointer; transition: all 0.3s; flex: 1; min-width: 180px; background-color: rgba(0, 40, 0, 0.8); color: #0F0; font-family: 'Share Tech Mono', monospace; text-shadow: 0 0 5px #0F0; }
  .action-button:hover { transform: translateY(-2px); background-color: rgba(0, 80, 0, 0.8); box-shadow: 0 0 10px rgba(0,255,0,0.4); }
  .action-button:active { transform: translateY(0); }
  .action-button:disabled { background-color: rgba(0, 20, 0, 0.5); cursor: not-allowed; transform: none; color: rgba(0, 255, 0, 0.5); }
  
  .generate-custom-btn { background-color: rgba(0, 40, 0, 0.8); color: #0F0; }
  .generate-custom-btn:hover:not(:disabled) { background-color: rgba(0, 80, 0, 0.8); }
  
  .generate-random-btn { background-color: rgba(0, 60, 0, 0.8); color: #0F0; }
  .generate-random-btn:hover:not(:disabled) { background-color: rgba(0, 100, 0, 0.8); }
  
  .error-message { background-color: rgba(60, 0, 0, 0.8); color: #0F0; padding: 12px; border-radius: 5px; margin-top: 15px; border: 1px solid #F00; }
  
  footer { text-align: center; margin-top: 30px; padding-top: 20px; border-top: 1px solid #0F0; color: #0F0; }
  footer a { color: #0F0; text-decoration: none; text-shadow: 0 0 3px #0F0; }
  footer a:hover { text-decoration: underline; }
  
  .loading-indicator { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 10, 0, 0.8); display: flex; justify-content: center; align-items: center; font-size: 1.5rem; color: #0F0; text-shadow: 0 0 5px #0F0; }
  
  @media (min-width: 768px) {
    .gallery-container { flex-direction: row; }
    .image-display { flex: 3; }
    .prompt-input-container { flex: 2; }
  }
  
  @media (max-width: 767px) {
    .button-container { flex-direction: column; }
    .action-button { width: 100%; }
  }
  
  a { color: #0F0; text-shadow: 0 0 3px #0F0; }
  hr { border-color: #0F0; box-shadow: 0 0 5px #0F0; }
  
  /* Matrix code rain effect */
  @keyframes matrixRain {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(1000%); }
  }
  
  .matrix-code {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: -1;
  }
  
  .matrix-code span {
    color: #0F0;
    font-size: 1.2rem;
    position: absolute;
    opacity: 0.8;
    animation: matrixRain 15s linear infinite;
    text-shadow: 0 0 5px #0F0;
  }
  
  .green-button {
    background-color: rgba(0, 40, 0, 0.8);
    color: #0F0;
    padding: 10px 20px;
    border: 1px solid #0F0;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-family: 'Share Tech Mono', monospace;
    text-shadow: 0 0 5px #0F0;
    transition: all 0.3s;
    box-shadow: 0 0 10px rgba(0,255,0,0.2);
  }
  
  .green-button a {
    color: #0F0;
    text-decoration: none;
    text-shadow: 0 0 3px #0F0;
  }
  
  .green-button:hover {
    background-color: rgba(0, 80, 0, 0.8);
    box-shadow: 0 0 15px rgba(0,255,0,0.4);
  }
</style>

<div class="matrix-code" id="matrixCodeContainer"></div>

<script>
  // Matrix code rain effect
  function createMatrixRain() {
    const container = document.getElementById('matrixCodeContainer');
    const characters = "01アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲン";
    const columns = Math.floor(window.innerWidth / 20);
    
    for (let i = 0; i < columns; i++) {
      const span = document.createElement('span');
      span.innerText = characters.charAt(Math.floor(Math.random() * characters.length));
      span.style.left = (i * 20) + 'px';
      span.style.animationDelay = Math.random() * 10 + 's';
      span.style.animationDuration = Math.random() * 10 + 10 + 's';
      span.style.opacity = Math.random() * 0.5 + 0.25;
      container.appendChild(span);
      
      setInterval(() => {
        span.innerText = characters.charAt(Math.floor(Math.random() * characters.length));
      }, 100 + Math.random() * 2000);
    }
  }

  // Rest of the original script
  const aitext = {
    generatePrompt: async () => {
      console.log("AI text prompt generator called");
      await new Promise(resolve => setTimeout(resolve, 800));
      
      const prompts = [
        "A crystalline cave illuminated by bioluminescent insects",
        "A steampunk airship harbor floating among the clouds",
        "An ancient temple overgrown with flowering vines",
        "A cyberpunk marketplace with neon-lit food stalls",
        "A desert oasis under a triple moon sky",
        "A forgotten library with books that whisper their stories",
        "A volcanic island with rivers of glowing magma",
        "A celestial observatory perched on the edge of a cosmic void",
        "A bamboo forest where time flows backwards",
        "A subterranean city built inside a massive geode",
        "A floating garden with gravity-defying waterfalls",
        "A post-apocalyptic amusement park reclaimed by nature",
        "A dimension where shadows cast light instead of darkness",
        "A crystal palace reflecting a thousand different sunsets",
        "An arctic research station during the aurora borealis",
        "A hidden valley where mythical creatures roam freely",
        "A clockwork metropolis powered by impossible mathematics",
        "A coastal village built on the back of a sleeping sea monster",
        "A jungle treehouse network connected by rainbow bridges",
        "A mirrored canyon that shows alternate realities in its reflections",
        "A magical forest with glowing mushrooms",
        "A futuristic city with flying cars",
        "A peaceful mountain lake at sunset",
        "An underwater scene with colorful coral reef",
        "A spaceship approaching an alien planet",
        "A medieval castle on a hill during thunderstorm",
        "A cozy cabin in the snow with northern lights",
        "A surreal dreamscape with floating islands"
      ];

      return prompts[Math.floor(Math.random() * prompts.length)];
    }
  };
  
  const imageCache = new Map();
  
  function showLoading() {
    const loadingEl = document.createElement('div');
    loadingEl.className = 'loading-indicator';
    loadingEl.id = 'loadingIndicatorEl';
    loadingEl.innerHTML = '<div>⏳ Generating image...</div>';
    
    const imageDisplay = document.querySelector('.image-display');
    imageDisplay.appendChild(loadingEl);
  }
  
  function hideLoading() {
    const loadingEl = document.getElementById('loadingIndicatorEl');
    if (loadingEl) {
      loadingEl.remove();
    }
  }
  
  function showError(message) {
    const errorMessageEl = document.getElementById('errorMessageEl');
    errorMessageEl.textContent = message;
    errorMessageEl.hidden = false;
    
    setTimeout(() => {
      errorMessageEl.hidden = true;
    }, 5000);
  }
  
  async function generateImageFromPrompt(prompt) {
    if (imageCache.has(prompt)) {
      console.log("Using cached image for prompt:", prompt);
      return imageCache.get(prompt);
    }
    
    try {
      let imageUrl = await generateImage(prompt);
      
      imageCache.set(prompt, imageUrl);
      
      return imageUrl;
    } catch (error) {
      console.error("Error generating image:", error);
      throw new Error("Failed to generate image. Please try again.");
    }
  }
  
  async function generateNewImage() {
    try {
      const generateRandomBtn = document.getElementById('generateRandomBtn');
      const generateCustomBtn = document.getElementById('generateCustomBtn');
      const generatedImageEl = document.getElementById('generatedImageEl');
      const promptInfoEl = document.getElementById('promptInfoEl');
      
      generateRandomBtn.disabled = true;
      generateCustomBtn.disabled = true;
      
      generateRandomBtn.textContent = "⏳ Generating...";
      
      showLoading();
      
      const prompt = await aitext.generatePrompt();
      
      const imageUrl = await generateImageFromPrompt(prompt);
      
      generatedImageEl.src = imageUrl;
      promptInfoEl.textContent = `Prompt: "${prompt}"`;
      
      hideLoading();
      
      generateRandomBtn.disabled = false;
      generateCustomBtn.disabled = false;
      
      generateRandomBtn.textContent = "Generate Random";
    } catch (error) {
      hideLoading();
      showError(error.message);
      
      const generateRandomBtn = document.getElementById('generateRandomBtn');
      const generateCustomBtn = document.getElementById('generateCustomBtn');
      generateRandomBtn.disabled = false;
      generateCustomBtn.disabled = false;
      
      generateRandomBtn.textContent = "Generate Random";
    }
  }
  
  async function generateFromCustomPrompt() {
    const customPromptInput = document.getElementById('customPromptInput');
    const generateRandomBtn = document.getElementById('generateRandomBtn');
    const generateCustomBtn = document.getElementById('generateCustomBtn');
    const generatedImageEl = document.getElementById('generatedImageEl');
    const promptInfoEl = document.getElementById('promptInfoEl');
    
    const prompt = customPromptInput.value.trim();
    
    if (!prompt) {
      showError("Please enter a prompt before generating.");
      return;
    }
    
    try {
      generateRandomBtn.disabled = true;
      generateCustomBtn.disabled = true;
      
      generateCustomBtn.textContent = "⏳ Generating...";
      
      showLoading();
      
      const imageUrl = await generateImageFromPrompt(prompt);
      
      generatedImageEl.src = imageUrl;
      promptInfoEl.textContent = `Prompt: "${prompt}"`;
      
      hideLoading();
      
      generateRandomBtn.disabled = false;
      generateCustomBtn.disabled = false;
      
      generateCustomBtn.textContent = "Generate From Prompt";
    } catch (error) {
      hideLoading();
      showError(error.message);
      
      generateRandomBtn.disabled = false;
      generateCustomBtn.disabled = false;
      
      generateCustomBtn.textContent = "Generate From Prompt";
    }
  }
  
  async function generateImageFromText() {
    const textOutputEl = document.getElementById('textOutputEl');
    const customPromptInput = document.getElementById('customPromptInput');
    const prompt = textOutputEl.innerText.trim();
    
    if (!prompt) {
      showError("No text generated yet. Please generate text first.");
      return;
    }
    
    customPromptInput.value = prompt;
    
    await generateFromCustomPrompt();
  }
  
  let currentPromise;
  let hasGeneratedPrompt = false;

  function constructPrompt() {
    const topicInput = document.getElementById('topicInput');
    let topic = topicInput.value;
    return `You are a professional HTML/CSS/JavaScript coding assistant specializing in web development best practices and modern coding standards. Analyze this code or answer this coding question: ${topic}. Provide clear, specific solutions focusing on: 1) Syntax corrections, 2) Best practices, 3) Browser compatibility, 4) Modern standards, 5) Performance optimization. Give detailed explanations and working code examples.`;
  }

  async function generateTextOutput() {
    const topicInput = document.getElementById('topicInput');
    const generateTextBtn = document.getElementById('generateTextBtn');
    const stopBtn = document.getElementById('stopBtn');
    const textOutputEl = document.getElementById('textOutputEl');
    const copyPromptBtn = document.getElementById('copyPromptBtn');
    const generateImageBtn = document.getElementById('generateImageBtn');
    
    if (!topicInput.value.trim()) return alert("Please enter your code or coding question");

    generateTextBtn.disabled = true;
    generateTextBtn.textContent = "⏳ Analyzing Code...";
    stopBtn.hidden = false;
    textOutputEl.innerHTML = "";

    try {
      currentPromise = generateText({
        instruction: constructPrompt(),
        onChunk: (data) => {
          textOutputEl.innerHTML += data.textChunk;
        },
      });

      await currentPromise;
      
      copyPromptBtn.style.display = "inline-block";
      generateImageBtn.style.display = "inline-block";
      
      hasGeneratedPrompt = true;
    } catch (error) {
      console.error("Error generating text:", error);
      alert("Error generating text: " + error.message);
    } finally {
      generateTextBtn.disabled = false;
      generateTextBtn.textContent = "ANALYZE CODE";
      stopBtn.hidden = true;
    }
  }

  function copyPrompt() {
    const textOutputEl = document.getElementById('textOutputEl');
    let promptText = textOutputEl.innerText;
    navigator.clipboard.writeText(promptText).then(() => {
      alert("Code analysis copied to clipboard successfully!");
    }, (err) => {
      console.error('Could not copy text: ', err);
      alert("Failed to copy analysis. Please try again.");
    });
  }

  async function askGPT() {
    const topicInput = document.getElementById('topicInput');
    const askGptBtn = document.getElementById('askGptBtn');
    const stopBtn = document.getElementById('stopBtn');
    const textOutputEl = document.getElementById('textOutputEl');
    
    if (!topicInput.value.trim()) return alert("Please enter your HTML/coding question");

    askGptBtn.disabled = true;
    askGptBtn.textContent = "⏳ Asking HTML GPT...";
    stopBtn.hidden = false;
    textOutputEl.innerHTML = "";

    try {
      currentPromise = generateText({
        instruction: `You are an expert HTML/CSS/JavaScript developer and coding tutor. Answer this web development question with detailed explanations and working code examples: ${topicInput.value}`,
        onChunk: (data) => {
          textOutputEl.innerHTML += data.textChunk;
        },
      });

      await currentPromise;
    } catch (error) {
      console.error("Error asking GPT:", error);
      alert("Error asking GPT: " + error.message);
    } finally {
      askGptBtn.disabled = false;
      askGptBtn.textContent = "ASK HTML GPT";
      stopBtn.hidden = true;
    }
  }
  
  window.onload = function() {
    createMatrixRain();
    generateNewImage();
    
    const generateRandomBtn = document.getElementById('generateRandomBtn');
    const generateCustomBtn = document.getElementById('generateCustomBtn');
    const customPromptInput = document.getElementById('customPromptInput');
    
    generateRandomBtn.addEventListener('click', generateNewImage);
    generateCustomBtn.addEventListener('click', generateFromCustomPrompt);
    
    customPromptInput.addEventListener('keypress', function(event) {
      if (event.key === 'Enter') {
        generateFromCustomPrompt();
      }
    });
  };
</script>
 
<!-- TOS -->
  <center>
  <hr><br><button style="background-color: #4CAF50; color: white; padding: 10px 20px; border: none; border-radius: 5px; cursor: pointer; font-size: 16px;">
  <a href="https://poe.com/Future-HTML" style="color: white; text-decoration: none;">Future-HTML Coder Assistant</a>
</button>
<br><br>
  <div style="text-align:center;">
    <div>⚖️ <a href="https://poe.com/s/FCFHKtkp9Cn67SNTQEFf">AI Imagery Rules</a> 👮‍♂️</div>
    <br><sup><i><strong>Affiliate:</strong></i></sup><br><a href="https://candy.ai/ai-anime?via=youmakeai-friend">
          <img src="https://user-uploads.perchance.org/file/5c04e64b4a86d317b9a78613d6467259.jpg" height="100px" alt="AI FRIEND">
        </a>
        <br>
       <strong>Not Getting The AI Art You Wanted?</strong><br>
        Try the Prompt support on our <a href="https://poe.com/youmakeai"><strong><u>POE</u></strong></a>
    <br>
    <br>
    <sub>This is an AI fan site; we are NOT endorsed by,<br>NOR affiliated with any of the following companies:</sub>
  </div>
  <h4>
    <div style="text-align:center;">
      <a href="https://perchance.org/privacy-policy">Perchance Privacy</a> |
      <a href="https://poe.com/pages/privacy-center">Poe Privacy</a><br>
      <a href="https://youmakeaiart.blogspot.com/p/privacy-policy.html?m=1">Our Privacy</a> |
      <a href="https://nightcafe.studio/policies/terms-of-service">NightCafe TOS</a> |
      <a href="https://youmakeaiart.blogspot.com/p/terms-of-use.html">Our TOS</a><br>
      <a href="https://openai.com/policies/terms-of-use/">OpenAI TOS</a> |
      <a href="https://stability.ai/tos-api-ds">Stability AI TOS</a><br>
      <a href="https://bfl.ai/legal/terms-of-service">BFL/Flux TOS</a>
    </div>
  </h4>
  <hr>
  <p>©️ Copyright 2025 YouMake.Ai</p>
  </center>
</html>