File size: 34,149 Bytes
857cdcf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
<!DOCTYPE html>
<html lang="th">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>แดชบอร์ดวินิจฉัยระบบ Chahua Development</title>
    <style>
        /* --- CSS Variables for Clean Theme (Based on chahua_license) --- */
        :root {
            --bg-color: #f8f9fa;
            --surface-color: #ffffff;
            --primary-text-color: #212529;
            --secondary-text-color: #6c757d;
            --accent-color: #0056b3;
            --accent-hover-color: #004085;
            --border-color: #dee2e6;
            --shadow-color: rgba(0, 0, 0, 0.1);
            --success-color: #28a745;
            --warning-color: #ffc107;
            --danger-color: #dc3545;
            --info-color: #17a2b8;
            --terminal-bg: #2d3748;
            --terminal-border: #4a5568;
            --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            --border-radius: 12px;
            --shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
            --transition: all 0.3s ease;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: var(--font-family);
            background: var(--bg-color);
            color: var(--primary-text-color);
            line-height: 1.6;
            overflow: hidden;
            height: 100vh;
            width: 100vw;
        }

        /* Main Container Layout */
        .dashboard-container {
            display: flex;
            height: 100vh;
            gap: 20px;
            padding: 20px;
            position: relative;
        }

        /* Left Panel - Terminal Section */
        .terminal-panel {
            background: var(--terminal-bg);
            border-radius: var(--border-radius);
            color: #ffffff;
            font-family: 'Courier New', monospace;
            box-shadow: var(--shadow);
            display: flex;
            flex-direction: column;
            overflow: hidden;
            border: 1px solid var(--border-color);
            flex: 0 0 auto;
            position: relative;
            min-width: 400px;
            max-width: 75%;
            width: calc(60% - 10px);
        }

        .terminal-header {
            background: rgba(0, 86, 179, 0.1);
            padding: 15px 20px;
            border-bottom: 1px solid var(--border-color);
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .terminal-title {
            color: var(--accent-color);
            font-size: 1.1rem;
            margin: 0;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .terminal-controls {
            display: flex;
            gap: 8px;
        }

        .terminal-btn {
            background: var(--surface-color);
            color: var(--accent-color);
            border: 1px solid var(--border-color);
            padding: 6px 12px;
            border-radius: var(--border-radius);
            cursor: pointer;
            font-size: 0.8rem;
            font-weight: 500;
            transition: var(--transition);
            white-space: nowrap;
        }

        .terminal-btn:hover {
            background: var(--accent-color);
            color: white;
            border-color: var(--accent-color);
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0, 86, 179, 0.2);
        }

        .terminal-btn:disabled {
            background: var(--bg-color);
            color: var(--secondary-text-color);
            cursor: not-allowed;
            border-color: var(--border-color);
            transform: none;
            box-shadow: none;
        }

        .terminal-btn.export-btn {
            background: var(--success-color);
            border-color: var(--success-color);
            color: white;
        }

        .terminal-btn.export-btn:hover:not(:disabled) {
            background: #1e7e34;
            border-color: #1e7e34;
        }

        #terminal-container {
            flex: 1;
            padding: 20px;
            background: var(--terminal-bg);
            overflow: hidden;
            font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
            font-size: 0.9rem;
            line-height: 1.4;
        }

        /* Resize Handle */
        .resize-handle {
            position: absolute;
            top: 0;
            right: -10px;
            width: 20px;
            height: 100%;
            cursor: col-resize;
            background: transparent;
            z-index: 10;
            user-select: none;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .resize-handle::before {
            content: '';
            width: 4px;
            height: 40px;
            background: var(--border-color);
            border-radius: 2px;
            transition: var(--transition);
        }

        .resize-handle:hover::before {
            background: var(--accent-color);
            opacity: 0.7;
        }

        .resize-handle.resizing::before {
            background: var(--accent-color);
            opacity: 1;
            box-shadow: 0 0 10px rgba(0, 86, 179, 0.5);
        }

        .dashboard-container.resizing {
            user-select: none;
        }

        .dashboard-container.resizing * {
            pointer-events: none;
        }

        .dashboard-container.resizing .resize-handle {
            pointer-events: auto;
        }

        /* Right Panel - Analysis Panel */
        .analysis-panel {
            background: var(--surface-color);
            border-radius: var(--border-radius);
            box-shadow: var(--shadow);
            overflow: hidden;
            border: 1px solid var(--border-color);
            flex: 1;
            min-width: 300px;
            display: flex;
            flex-direction: column;
        }

        .analysis-header {
            background: var(--surface-color);
            padding: 20px;
            border-bottom: 1px solid var(--border-color);
        }

        .analysis-title {
            color: var(--accent-color);
            font-size: 1.3rem;
            font-weight: 600;
            margin: 0;
            text-align: center;
        }

        .analysis-content {
            flex: 1;
            overflow-y: auto;
            padding: 20px;
        }

        /* Inspector Panel */
        .inspector-panel {
            background: var(--surface-color);
            border-radius: var(--border-radius);
            border: 1px solid var(--border-color);
            overflow: hidden;
        }

        .inspector-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
            gap: 10px;
            padding: 15px 20px;
            background: rgba(0, 86, 179, 0.05);
            border-bottom: 1px solid var(--border-color);
        }

        .inspector-title {
            color: var(--accent-color);
            font-size: 1.1rem;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .inspector-controls {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
        }

        .inspector-content {
            padding: 20px;
            display: flex;
            flex-direction: column;
            gap: 15px;
        }

        /* Inspector Stats */
        .inspector-stats {
            background: rgba(0, 86, 179, 0.05);
            border-radius: var(--border-radius);
            padding: 15px;
            border: 1px solid var(--border-color);
        }

        .stats-row {
            display: flex;
            justify-content: space-around;
            gap: 10px;
            margin-bottom: 10px;
        }

        .stat-item {
            text-align: center;
        }

        .stat-label {
            color: var(--secondary-text-color);
            font-size: 0.85rem;
            margin-bottom: 5px;
        }

        .stat-value {
            color: var(--primary-text-color);
            font-size: 1.5rem;
            font-weight: bold;
        }

        .stat-error {
            color: var(--danger-color);
        }

        .stat-warning {
            color: var(--warning-color);
        }

        /* Inspector Filters */
        .inspector-filters {
            background: var(--surface-color);
            border-radius: var(--border-radius);
            padding: 15px;
            border: 1px solid var(--border-color);
        }

        .filter-group {
            margin-bottom: 10px;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .filter-group label {
            color: var(--secondary-text-color);
            font-size: 0.9rem;
            font-weight: 500;
            min-width: 120px;
        }

        .filter-group select {
            flex: 1;
            padding: 8px 12px;
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius);
            background: var(--surface-color);
            color: var(--primary-text-color);
            font-size: 0.9rem;
            transition: var(--transition);
        }

        .filter-group select:focus {
            outline: none;
            border-color: var(--accent-color);
            box-shadow: 0 0 0 2px rgba(0, 86, 179, 0.2);
        }

        /* Inspector Results */
        .inspector-results {
            background: var(--surface-color);
            border-radius: var(--border-radius);
            padding: 20px;
            border: 1px solid var(--border-color);
            min-height: 200px;
        }

        .no-selection {
            text-align: center;
            color: var(--secondary-text-color);
            padding: 30px;
        }

        .no-selection i {
            font-size: 3rem;
            margin-bottom: 20px;
            color: var(--border-color);
        }

        .no-selection h3 {
            color: var(--primary-text-color);
            margin-bottom: 10px;
            font-size: 1.2rem;
        }

        /* Code Snippet */
        .code-snippet {
            background: var(--terminal-bg) !important;
            color: #c9d1d9;
            font-family: 'Consolas', 'Courier New', monospace;
            white-space: pre;
            overflow-x: auto;
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius);
            padding: 15px;
            margin: 10px 0;
            font-size: 0.85rem;
            line-height: 1.4;
        }

        /* Detail Section */
        .detail-section {
            margin-bottom: 20px;
        }

        .detail-label {
            color: var(--accent-color);
            font-weight: 600;
            margin-bottom: 8px;
            font-size: 0.9rem;
        }

        .detail-value {
            background: rgba(0, 86, 179, 0.05);
            padding: 12px;
            border-radius: var(--border-radius);
            font-family: 'Courier New', monospace;
            white-space: pre-wrap;
            word-break: break-word;
            border: 1px solid var(--border-color);
            font-size: 0.85rem;
        }

        /* Scrollbar */
        ::-webkit-scrollbar {
            width: 8px;
        }

        ::-webkit-scrollbar-track {
            background: var(--bg-color);
        }

        ::-webkit-scrollbar-thumb {
            background: var(--border-color);
            border-radius: 4px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: var(--secondary-text-color);
        }

        /*  CSS สำหรับ Log Viewer ใหม่  */
        .log-viewer-container {
            flex: 1;
            background: #0d1117; /* สีดำสนิท */
            color: #c9d1d9;      /* สีเทาอ่อน */
            font-family: 'Consolas', 'Courier New', monospace;
            font-size: 13px;
            padding: 15px;
            overflow-y: auto;    /*  ทำให้เลื่อนได้เมื่อ Log ยาว */
            white-space: pre-wrap; /*  ทำให้ขึ้นบรรทัดใหม่เมื่อยาวเกิน */
            word-break: break-all;
            margin: 0;
            border: none;
            outline: none;
        }

        /* สไตล์สำหรับแต่ละบรรทัดของ Log */
        .log-line {
            display: block;
            margin: 0;
            padding: 1px 0;
        }

        /* สีสำหรับ Log แต่ละประเภท */
        .log-line.log-error   { color: #f85149; font-weight: bold; }
        .log-line.log-warning { color: #f2cc60; }
        .log-line.log-success { color: #7ee787; }
        .log-line.log-info    { color: #8b949e; } /* สีเทาสำหรับข้อมูลทั่วไป */
        .log-line.log-debug   { color: #58a6ff; } /* สีฟ้าสำหรับ debug */
        .log-line.log-command { color: #bc8cff; font-style: italic; }

        /* Responsive adjustments */
        @media (max-width: 768px) {
            .dashboard-container {
                flex-direction: column;
            }
            
            .terminal-panel {
                width: 100%;
                max-width: none;
                height: 50%;
            }
            
            .inspector-controls {
                justify-content: center;
            }
        }

        /* Hide dev buttons unless in dev mode */
        body:not(.dev-mode) .dev-only {
            display: none !important;
        }
    </style>
</head>
<body>
    <div class="dashboard-container">
        <!-- Left Panel - Terminal Section -->
        <div class="terminal-panel">
            <div class="terminal-header">
                <div class="terminal-title">
                    <i class="fas fa-terminal"></i> 
                    เทอร์มินัลแบบโต้ตอบ
                </div>
 
            </div>
            <pre id="log-viewer" class="log-viewer-container"></pre>
            <!-- Resize Handle -->
            <div class="resize-handle" id="resizeHandle"></div>
        </div>

        <!-- Right Panel - Inspector Panel -->
        <div class="analysis-panel">
            <div class="analysis-header">
                <div class="analysis-title">
                    <i class="fas fa-search"></i> เครื่องมือตรวจสอบโปรเจค
                </div>
            </div>
            <div class="analysis-content">
                <div class="inspector-panel">
                    <div class="inspector-header">
                        <div class="inspector-title">
                            <i class="fas fa-bug"></i>
                            ตรวจสอบและวิเคราะห์
                        </div>
                        <div class="inspector-controls">
                            <button class="terminal-btn dev-only" id="scanSelfBtn">
                                <i class="fas fa-user-secret"></i> สแกนตัวเอง (Dev)
                            </button>
                            <button class="terminal-btn" id="scanPluginsBtn">
                                <i class="fas fa-puzzle-piece"></i> สแกนปลั๊กอิน
                            </button>
                            <button class="terminal-btn dev-only" id="runE2eTestsBtn" style="color: var(--success-color) !important; border-color: var(--success-color) !important;">
                                <i class="fas fa-vial"></i> เริ่มการทดสอบ E2E (Dev)
                            </button>
                            <button class="terminal-btn dev-only" id="openTestReportBtn" style="color: var(--warning-color) !important; border-color: var(--warning-color) !important;">
                                <i class="fas fa-chart-line"></i> เปิดรายงานผลการทดสอบ (Dev)
                            </button>
                            <button class="terminal-btn export-btn" id="exportIssuesBtn" disabled style="display: none;">
                                <i class="fas fa-download"></i> ส่งออก JSON
                            </button>
                        </div>
                    </div>
                    
                    <div class="inspector-content">
                        <div class="inspector-stats" id="inspectorStats" style="display: none;">
                            <div class="stats-row">
                                <div class="stat-item">
                                    <div class="stat-label">ไฟล์ทั้งหมด</div>
                                    <div class="stat-value" id="totalFiles">0</div>
                                </div>
                                <div class="stat-item">
                                    <div class="stat-label">ปัญหาทั้งหมด</div>
                                    <div class="stat-value" id="totalIssues">0</div>
                                </div>
                                <div class="stat-item">
                                    <div class="stat-label">ข้อผิดพลาด</div>
                                    <div class="stat-value stat-error" id="totalErrors">0</div>
                                </div>
                                <div class="stat-item">
                                    <div class="stat-label">คำเตือน</div>
                                    <div class="stat-value stat-warning" id="totalWarnings">0</div>
                                </div>
                            </div>
                        </div>
                        
                        <div class="inspector-filters" id="inspectorFilters" style="display: none;">
                            <div class="filter-group">
                                <label>กรองตามประเภท:</label>
                                <select id="typeFilter">
                                    <option value="all">ทุกประเภท</option>
                                    <option value="SyntaxError">ข้อผิดพลาดไวยากรณ์</option>
                                    <option value="MissingFile">ไฟล์หายไป</option>
                                    <option value="UnusedFile">ไฟล์ไม่ได้ใช้</option>
                                    <option value="MissingDependency">การพึ่งพาหายไป</option>
                                    <option value="CircularDependency">การพึ่งพาแบบวนรอบ</option>
                                    <option value="DuplicateExport">การส่งออกซ้ำ</option>
                                    <option value="MissingExport">การนำเข้า/ส่งออกไม่ตรงกัน</option>
                                </select>
                            </div>
                            <div class="filter-group">
                                <label>กรองตามความรุนแรง:</label>
                                <select id="severityFilter">
                                    <option value="all">ทุกระดับ</option>
                                    <option value="error">ข้อผิดพลาด</option>
                                    <option value="warning">คำเตือน</option>
                                    <option value="info">ข้อมูล</option>
                                </select>
                            </div>
                        </div>
                        
                        <div class="inspector-results" id="inspectorResults">
                            <div class="no-selection">
                                <i class="fas fa-search"></i>
                                <h3>เครื่องมือตรวจสอบโปรเจค</h3>
                                <p>เครื่องมือวิเคราะห์โค้ดเพื่อหาปัญหาต่างๆ ก่อนการรัน</p>
                                <div style="margin-top: 20px; text-align: left;">
                                    <h4 style="color: var(--accent-color); margin-bottom: 10px;">ความสามารถ:</h4>
                                    <ul style="color: var(--secondary-text-color); line-height: 1.6;">
                                        <li>ตรวจสอบไวยากรณ์ (ข้อผิดพลาดไวยากรณ์)</li>
                                        <li>หาไฟล์ที่ไม่มีอยู่จริง (ไฟล์หายไป)</li>
                                        <li>หาไฟล์ที่ไม่ได้ใช้งาน (ไฟล์ไม่ได้ใช้)</li>
                                        <li>ตรวจสอบการพึ่งพาที่ขาดหาย</li>
                                        <li>หาการพึ่งพาแบบวนรอบ</li>
                                        <li>หาการส่งออกซ้ำ</li>
                                        <li>หาการนำเข้า/ส่งออกไม่ตรงกัน (ข้อผิดพลาดรันไทม์)</li>
                                    </ul>
                                </div>
                                <div style="margin-top: 20px;">
                                    <p style="color: var(--warning-color);">คลิก "สแกนปลั๊กอิน" เพื่อเริ่มวิเคราะห์</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="debugger.js"></script>
    
    <script>
        // =================================
        //  PRODUCTION SECURITY SYSTEM
        // =================================
        
        // ตรวจสอบโหมดการทำงาน
        const isDevelopmentMode = () => {
            // ตรวจสอบจาก URL parameters
            const urlParams = new URLSearchParams(window.location.search);
            const devParam = urlParams.get('dev');
            
            // ตรวจสอบจาก localStorage
            const devStorage = localStorage.getItem('chahua_dev_mode');
            
            // ตรวจสอบจาก environment variables (ถ้ามี)
            const isLocalhost = window.location.hostname === 'localhost' || 
                               window.location.hostname === '127.0.0.1' ||
                               window.location.hostname === '';
            
            return devParam === 'true' || devStorage === 'true' || isLocalhost;
        };

        // ระบบป้องกัน Console และ Developer Tools
        const initProductionSecurity = () => {
            if (isDevelopmentMode()) {
                // เปิดใช้งาน dev mode
                document.body.classList.add('dev-mode');
                console.log('%c Developer Mode Enabled', 'color: #28a745; font-weight: bold; font-size: 14px;');
                return;
            }

            // ปิดใช้งาน console ทั้งหมด
            const noop = () => {};
            const consoleMethods = [
                'log', 'debug', 'info', 'warn', 'error', 'assert', 'dir', 'dirxml',
                'group', 'groupEnd', 'time', 'timeEnd', 'count', 'trace', 'profile', 'profileEnd'
            ];
            
            consoleMethods.forEach(method => {
                console[method] = noop;
            });

            // ป้องกันการเปิด Developer Tools
            let devtools = {open: false, orientation: null};
            const threshold = 160;

            setInterval(() => {
                if (window.outerHeight - window.innerHeight > threshold || 
                    window.outerWidth - window.innerWidth > threshold) {
                    if (!devtools.open) {
                        devtools.open = true;
                        // Redirect หรือ แสดงข้อความเตือน
                        document.body.innerHTML = `
                            <div style="
                                position: fixed; top: 0; left: 0; right: 0; bottom: 0;
                                background: #f8f9fa; display: flex; align-items: center; justify-content: center;
                                font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
                            ">
                                <div style="text-align: center; color: #212529;">
                                    <h2 style="color: #dc3545; margin-bottom: 20px;"> การเข้าถึงถูกจำกัด</h2>
                                    <p>กรุณาปิด Developer Tools เพื่อดำเนินการต่อ</p>
                                    <p style="color: #6c757d; font-size: 0.9rem;">Developer Tools detected. Please close to continue.</p>
                                </div>
                            </div>
                        `;
                    }
                } else {
                    devtools.open = false;
                }
            }, 500);

            // ปิดใช้งานคำสั่งลัดของ Developer Tools
            document.addEventListener('keydown', (e) => {
                // ปิด F12
                if (e.key === 'F12') {
                    e.preventDefault();
                    return false;
                }
                
                // ปิด Ctrl+Shift+I, Ctrl+Shift+J, Ctrl+Shift+C
                if (e.ctrlKey && e.shiftKey && (e.key === 'I' || e.key === 'J' || e.key === 'C')) {
                    e.preventDefault();
                    return false;
                }
                
                // ปิด Ctrl+U (View Source)
                if (e.ctrlKey && e.key === 'U') {
                    e.preventDefault();
                    return false;
                }
                
                // ปิด Ctrl+S (Save Page)
                if (e.ctrlKey && e.key === 'S') {
                    e.preventDefault();
                    return false;
                }
            });

            // ป้องกัน Right Click Context Menu
            document.addEventListener('contextmenu', (e) => {
                e.preventDefault();
                return false;
            });

            // ป้องกัน Text Selection
            document.addEventListener('selectstart', (e) => {
                e.preventDefault();
                return false;
            });

            // ป้องกัน Drag and Drop
            document.addEventListener('dragstart', (e) => {
                e.preventDefault();
                return false;
            });
        };

        // =================================
        //  RESIZE HANDLE FUNCTIONALITY
        // =================================
        
        // Resize Handle Functionality
        class ResizeController {
            constructor() {
                this.container = document.querySelector('.dashboard-container');
                this.terminalPanel = document.querySelector('.terminal-panel');
                this.resizeHandle = document.getElementById('resizeHandle');
                this.isResizing = false;
                this.resizeTimeout = null;

                if (this.resizeHandle) {
                    this.init();
                }
            }

            init() {
                //  เพิ่ม throttled resize method 
                this.boundThrottledResize = this.throttle(this.resizeTerminal.bind(this), 100);
                
                // Bound methods for proper event handling
                this.boundHandleResize = this.handleResize.bind(this);
                this.boundStopResize = this.stopResize.bind(this);
                this.boundKeydownHandler = this.handleKeydown.bind(this);
                this.emergencyCleanup = this.stopResize.bind(this);

                // Mouse events
                this.resizeHandle.addEventListener('mousedown', this.startResize.bind(this));
                
                // Log เฉพาะใน dev mode
                if (isDevelopmentMode()) {
                    console.log(" Resize controller initialized for debugger");
                }
            }

            startResize(e) {
                e.preventDefault();
                this.isResizing = true;
                
                // Add visual feedback
                this.container.classList.add('resizing');
                this.resizeHandle.classList.add('resizing');
                
                // Add event listeners
                document.addEventListener('mousemove', this.boundHandleResize);
                document.addEventListener('mouseup', this.boundStopResize);
                
                // Emergency cleanup listeners
                document.addEventListener('mouseleave', this.emergencyCleanup);
                window.addEventListener('blur', this.emergencyCleanup);
                document.addEventListener('keydown', this.boundKeydownHandler);
                
                // Log เฉพาะใน dev mode
                if (isDevelopmentMode()) {
                    console.log(" Resize started");
                }
            }

            handleResize(e) {
                if (!this.isResizing) return;
                
                e.preventDefault();
                
                const containerRect = this.container.getBoundingClientRect();
                const newWidth = e.clientX - containerRect.left;
                const containerWidth = containerRect.width;
                const minWidth = 300;
                const maxWidth = containerWidth * 0.8;
                
                if (newWidth >= minWidth && newWidth <= maxWidth) {
                    this.terminalPanel.style.width = `${newWidth}px`;
                    this.terminalPanel.style.flex = 'none';
                }
            }

            handleKeydown(e) {
                if (e.key === 'Escape' && this.isResizing) {
                    this.stopResize();
                }
            }

            stopResize() {
                if (!this.isResizing) return;
                
                this.isResizing = false;
                
                // Remove visual feedback
                this.container.classList.remove('resizing');
                this.resizeHandle.classList.remove('resizing');
                
                // Remove event listeners
                document.removeEventListener('mousemove', this.boundHandleResize);
                document.removeEventListener('mouseup', this.boundStopResize);
                
                // Remove emergency cleanup listeners
                document.removeEventListener('mouseleave', this.emergencyCleanup);
                window.removeEventListener('blur', this.emergencyCleanup);
                document.removeEventListener('keydown', this.boundKeydownHandler);
                
                // Clear timeout
                if (this.resizeTimeout) {
                    clearTimeout(this.resizeTimeout);
                    this.resizeTimeout = null;
                }
                
                // Log เฉพาะใน dev mode
                if (isDevelopmentMode()) {
                    console.log(" Resize stopped and listeners cleaned up");
                }
            }

            //  เพิ่มฟังก์ชัน throttle เข้าไปใน Class 
            throttle(func, limit) {
                let inThrottle;
                return function() {
                    const args = arguments;
                    const context = this;
                    if (!inThrottle) {
                        func.apply(context, args);
                        inThrottle = true;
                        setTimeout(() => inThrottle = false, limit);
                    }
                }
            }

            //  เพิ่มฟังก์ชัน resizeTerminal สำหรับการอ้างอิงใน boundThrottledResize 
            resizeTerminal() {
                // ถ้ามี diagnostic dashboard ให้เรียกใช้ resizeTerminal ของมัน
                if (window.diagnosticDashboard && window.diagnosticDashboard.resizeTerminal) {
                    window.diagnosticDashboard.resizeTerminal();
                }
            }
        }

        // =================================
        //  INITIALIZATION
        // =================================

        // Initialize security system first
        initProductionSecurity();

        // Initialize resize controller when DOM is loaded
        document.addEventListener('DOMContentLoaded', () => {
            window.resizeController = new ResizeController();
        });

        // Cleanup on page unload
        window.addEventListener('beforeunload', () => {
            if (window.resizeController) {
                window.resizeController.stopResize();
            }
        });
    </script>
</body>
</html>