File size: 25,342 Bytes
c20600f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="id" class="dark">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>Tools - Botz Control Panel</title>
    <link rel="icon" type="image/jpeg" href="https://cdn.yupra.my.id/yp/4r4oy0ze.jpg">
    <script src="https://cdn.tailwindcss.com"></script>
    <script>
        tailwind.config = {
            darkMode: 'class',
            theme: {
                extend: {
                    colors: {
                        primary: '#6366f1',
                        secondary: '#ec4899',
                        darkbg: '#0f172a',
                        cardbg: '#1e293b',
                        inputbg: '#334155',
                        sidebar: '#111827'
                    },
                    fontFamily: {
                        sans: ['Inter', 'sans-serif'],
                        mono: ['JetBrains Mono', 'monospace']
                    }
                }
            }
        }
    </script>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
    <style>
        ::-webkit-scrollbar { width: 6px; }
        ::-webkit-scrollbar-track { background: transparent; }
        ::-webkit-scrollbar-thumb { background: #475569; border-radius: 20px; }
        .glass { background: rgba(30, 41, 59, 0.7); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid rgba(255, 255, 255, 0.05); }
    </style>
</head>
<body class="bg-[#020617] text-slate-300 font-sans h-screen flex overflow-hidden selection:bg-primary selection:text-white">

    <div id="toast-container" class="fixed top-6 right-6 z-[100] flex flex-col gap-3 pointer-events-none"></div>

    <aside class="hidden md:flex flex-col w-64 bg-sidebar border-r border-white/5 h-full relative z-20">
        <div class="p-6 flex items-center gap-3">
            <div class="w-10 h-10 rounded-xl bg-gradient-to-br from-primary to-indigo-700 flex items-center justify-center text-white shadow-lg shadow-primary/20">
                <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/></svg>
            </div>
            <h1 class="text-lg font-bold text-white tracking-tight">Panel Botz</h1>
        </div>

        <nav class="flex-1 px-4 space-y-2 py-4">
            <a href="/" class="nav-item w-full flex items-center gap-3 px-4 py-3 rounded-xl text-sm font-medium text-slate-400 hover:bg-white/5 hover:text-white transition-all border border-transparent">
                <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zM14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6zM4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zM14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z"/></svg>
                Dashboard
            </a>
            <a href="/broadcast" class="nav-item w-full flex items-center gap-3 px-4 py-3 rounded-xl text-sm font-medium text-slate-400 hover:bg-white/5 hover:text-white transition-all border border-transparent">
                <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5.882V19.24a1.76 1.76 0 01-3.417.592l-2.147-6.15M18 13a3 3 0 100-6M5.436 13.683A4.001 4.001 0 017 6h1.832c4.1 0 7.625-1.234 9.168-3v14c-1.543-1.766-5.067-3-9.168-3H7a3.988 3.988 0 01-1.564-.317z"/></svg>
                Broadcast
            </a>
            <a href="/tools" class="nav-item active w-full flex items-center gap-3 px-4 py-3 rounded-xl text-sm font-medium text-slate-400 hover:bg-white/5 hover:text-white transition-all border border-transparent">
                <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/></svg>
                Tools
            </a>
            <a href="/settings" class="nav-item w-full flex items-center gap-3 px-4 py-3 rounded-xl text-sm font-medium text-slate-400 hover:bg-white/5 hover:text-white transition-all border border-transparent">
                <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/></svg>
                Settings
            </a>
        </nav>

        <div class="p-4 border-t border-white/5">
            <div class="glass p-3 rounded-xl flex items-center gap-3">
                <div id="status-dot" class="w-2.5 h-2.5 rounded-full bg-red-500 animate-pulse"></div>
                <div>
                    <p id="status-text" class="text-[10px] font-bold uppercase tracking-widest text-red-500">DISCONNECTED</p>
                    <p id="bot-name-display" class="text-xs text-slate-400 truncate w-32">Connecting...</p>
                </div>
            </div>
        </div>
    </aside>

    <main class="flex-1 flex flex-col h-full relative overflow-hidden bg-[#020617]">
        <header class="glass sticky top-0 z-30 px-6 py-4 flex md:hidden items-center justify-between border-b border-white/5">
             <div class="flex items-center gap-3">
                <div class="w-9 h-9 rounded-lg bg-gradient-to-br from-primary to-indigo-700 flex items-center justify-center text-white shadow-lg shadow-primary/20">
                    <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/></svg>
                </div>
                <h1 class="text-lg font-bold text-white tracking-tight">Panel Botz</h1>
            </div>
            <div class="flex items-center gap-2">
                 <div id="status-dot-m" class="w-2 h-2 rounded-full bg-red-500 animate-pulse"></div>
            </div>
        </header>

        <div class="flex-1 overflow-y-auto p-4 md:p-8 pb-24 md:pb-8 custom-scroll relative">
            <div class="max-w-7xl mx-auto space-y-6">
                <div>
                    <h2 class="text-3xl md:text-4xl font-bold text-white mb-2">Tools</h2>
                    <p class="text-slate-400 text-base">Alat bantu utilitas WhatsApp</p>
                </div>

                <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
                    <div class="glass p-6 md:p-7 rounded-2xl shadow-xl space-y-5">
                        <h2 class="text-white font-bold flex items-center gap-3 text-lg uppercase tracking-wide">
                            <span class="w-2 h-7 bg-blue-500 rounded-full"></span> Stalk WhatsApp
                        </h2>
                        <form id="form-stalk" class="space-y-4">
                            <input type="text" id="stalk-num" placeholder="628xxxx" class="w-full bg-inputbg/50 px-4 py-3 rounded-xl border border-slate-700 focus:border-blue-500 focus:bg-inputbg outline-none transition-all text-white placeholder-slate-500">
                            <button type="submit" class="w-full bg-blue-600 hover:bg-blue-500 text-white font-semibold py-3 rounded-xl transition-all shadow-lg shadow-blue-900/20 active:scale-[0.98]">Check Profile</button>
                        </form>
                        <div id="stalk-result" class="hidden bg-slate-900/60 rounded-xl p-5 border border-slate-700/50">
                            <div class="flex items-center gap-4 mb-4">
                                <img id="stalk-img" src="" class="w-16 h-16 rounded-full object-cover border-2 border-slate-600">
                                <div class="overflow-hidden">
                                    <p id="stalk-jid" class="text-base text-white font-mono font-bold truncate">...</p>
                                    <span id="stalk-type" class="text-xs bg-slate-800 text-slate-400 px-2 py-0.5 rounded border border-slate-700">PERSONAL</span>
                                </div>
                            </div>
                            <div class="space-y-3 text-sm">
                                <div class="bg-white/5 p-3 rounded border border-white/5">
                                    <p class="text-xs text-slate-500 uppercase font-bold mb-1">Status</p>
                                    <p id="stalk-bio" class="text-slate-300 italic line-clamp-2">...</p>
                                </div>
                                <div id="biz-info" class="hidden bg-blue-500/10 p-3 rounded border border-blue-500/20 space-y-1">
                                    <p id="biz-cat" class="text-slate-300">Category: -</p>
                                    <p id="biz-email" class="text-slate-300">Email: -</p>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="glass p-6 md:p-7 rounded-2xl shadow-xl space-y-5">
                        <h2 class="text-white font-bold flex items-center gap-3 text-lg uppercase tracking-wide">
                            <span class="w-2 h-7 bg-emerald-500 rounded-full"></span> Cek ID Channel
                        </h2>
                        <form id="form-cekid" class="space-y-4">
                            <input type="text" id="id-url" placeholder="https://whatsapp.com/channel/..." class="w-full bg-inputbg/50 px-4 py-3 rounded-xl border border-slate-700 focus:border-emerald-500 focus:bg-inputbg outline-none transition-all text-white placeholder-slate-500">
                            <button type="submit" class="w-full bg-emerald-600 hover:bg-emerald-500 text-white font-semibold py-3 rounded-xl transition-all shadow-lg shadow-emerald-900/20 active:scale-[0.98]">Get Metadata</button>
                        </form>
                         <div id="id-result" class="hidden bg-slate-900/60 rounded-xl p-5 border border-slate-700/50 space-y-4">
                            <div class="flex items-center gap-4">
                                <img id="ch-img" src="" class="w-14 h-14 rounded-full object-cover border border-slate-600" onerror="this.style.display='none'">
                                <div>
                                    <p id="ch-name" class="text-base font-bold text-white">Name</p>
                                    <p id="ch-subs" class="text-sm text-emerald-400">0 Subs</p>
                                </div>
                            </div>
                            <div class="bg-black/20 p-3 rounded border border-white/5">
                                <p class="text-xs text-slate-500 font-bold mb-1">ID</p>
                                <p id="ch-id" class="text-sm font-mono text-slate-300 break-all select-all">...</p>
                            </div>
                             <div class="bg-black/20 p-3 rounded border border-white/5">
                                <p class="text-xs text-slate-500 font-bold mb-1">Description</p>
                                <p id="ch-desc" class="text-sm text-slate-300 line-clamp-3">...</p>
                            </div>
                         </div>
                    </div>

                    <div class="glass p-6 md:p-7 rounded-2xl shadow-xl space-y-5">
                        <h2 class="text-white font-bold flex items-center gap-3 text-lg uppercase tracking-wide">
                             <span class="w-2 h-7 bg-red-600 rounded-full"></span> Play to Channel
                        </h2>
                        <form id="form-playch" class="space-y-4">
                            <input type="text" id="play-query" placeholder="Judul Lagu..." class="w-full bg-inputbg/50 px-4 py-3 rounded-xl border border-slate-700 focus:border-red-600 focus:bg-inputbg outline-none transition-all text-white placeholder-slate-500">
                            <button type="submit" id="btn-playch" class="w-full bg-red-600 hover:bg-red-500 text-white font-semibold py-3 rounded-xl transition-all shadow-lg shadow-red-900/20 active:scale-[0.98]">Kirim ke Channel</button>
                        </form>
                    </div>
    
                    <div class="glass p-6 md:p-7 rounded-2xl shadow-xl space-y-5">
                        <h2 class="text-white font-bold flex items-center gap-3 text-lg uppercase tracking-wide">
                             <span class="w-2 h-7 bg-rose-600 rounded-full"></span> Spam Pairing
                        </h2>
                        <form id="form-spam" class="space-y-4">
                            <div class="grid grid-cols-2 gap-3">
                                <input type="text" id="spam-number" placeholder="628xxxxx" class="w-full bg-inputbg/50 px-4 py-3 rounded-xl border border-slate-700 focus:border-rose-500 focus:bg-inputbg outline-none transition-all text-white placeholder-slate-500">
                                <input type="number" id="spam-amount" placeholder="Jumlah" class="w-full bg-inputbg/50 px-4 py-3 rounded-xl border border-slate-700 focus:border-rose-500 focus:bg-inputbg outline-none transition-all text-white placeholder-slate-500">
                            </div>
                            <button type="submit" id="btn-spam" class="w-full bg-rose-600 hover:bg-rose-500 text-white font-semibold py-3 rounded-xl transition-all shadow-lg shadow-rose-900/20 active:scale-[0.98]">GAS NGENGGG</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </main>

    <div class="md:hidden fixed bottom-0 inset-x-0 bg-sidebar border-t border-white/5 z-50 flex justify-around items-center p-2 pb-5">
        <a href="/" class="nav-item flex flex-col items-center gap-1 p-2 rounded-xl text-slate-400">
            <svg class="w-7 h-7" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zM14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6zM4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zM14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z"/></svg>
            <span class="text-[11px] font-medium">Home</span>
        </a>
        <a href="/broadcast" class="nav-item flex flex-col items-center gap-1 p-2 rounded-xl text-slate-400">
            <svg class="w-7 h-7" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5.882V19.24a1.76 1.76 0 01-3.417.592l-2.147-6.15M18 13a3 3 0 100-6M5.436 13.683A4.001 4.001 0 017 6h1.832c4.1 0 7.625-1.234 9.168-3v14c-1.543-1.766-5.067-3-9.168-3H7a3.988 3.988 0 01-1.564-.317z"/></svg>
            <span class="text-[11px] font-medium">Broad</span>
        </a>
        <a href="/tools" class="nav-item flex flex-col items-center gap-1 p-2 rounded-xl text-slate-400">
            <svg class="w-7 h-7" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/></svg>
            <span class="text-[11px] font-medium">Tools</span>
        </a>
        <a href="/settings" class="nav-item flex flex-col items-center gap-1 p-2 rounded-xl text-slate-400">
            <svg class="w-7 h-7" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/></svg>
            <span class="text-[11px] font-medium">Set</span>
        </a>
    </div>

    <script>
        function showToast(msg, type = 'success') {
            const container = document.getElementById('toast-container');
            const div = document.createElement('div');
            const bg = type === 'success' ? 'bg-green-500/10 border-green-500/30 text-green-200' : 'bg-red-500/10 border-red-500/30 text-red-200';
            
            div.className = `glass px-4 py-3 rounded-xl border backdrop-blur-md shadow-2xl flex items-center gap-3 transform translate-x-full transition-all duration-300 pointer-events-auto min-w-[280px] ${bg}`;
            div.innerHTML = `<span class="font-medium text-sm">${msg}</span>`;
            
            container.appendChild(div);
            requestAnimationFrame(() => div.classList.remove('translate-x-full'));
            setTimeout(() => {
                div.classList.add('translate-x-full', 'opacity-0');
                setTimeout(() => div.remove(), 300);
            }, 3000);
        }

        document.getElementById('form-stalk').addEventListener('submit', async (e) => {
            e.preventDefault();
            const num = document.getElementById('stalk-num').value;
            if(!num) return showToast('Enter number', 'error');
            
            const resCard = document.getElementById('stalk-result');
            const bizDiv = document.getElementById('biz-info');
            
            try {
                showToast('Searching...', 'success');
                const req = await fetch(`/stalkwa?number=${num}`);
                const res = await req.json();
                
                if(res.status) {
                    resCard.classList.remove('hidden');
                    const d = res.data;
                    document.getElementById('stalk-img').src = d.photo;
                    document.getElementById('stalk-jid').innerText = d.jid;
                    document.getElementById('stalk-bio').innerText = d.bio;
                    
                    if (d.business_info && d.business_info.is_business) {
                        document.getElementById('stalk-type').innerText = "BUSINESS";
                        document.getElementById('stalk-type').className = "text-xs bg-blue-900/50 text-blue-300 px-2 py-0.5 rounded border border-blue-500/30";
                        bizDiv.classList.remove('hidden');
                        document.getElementById('biz-cat').innerText = `Category: ${d.business_info.category || '-'}`;
                        document.getElementById('biz-email').innerText = `Email: ${d.business_info.email || '-'}`;
                    } else {
                        document.getElementById('stalk-type').innerText = "PERSONAL";
                        document.getElementById('stalk-type').className = "text-xs bg-slate-800 text-slate-400 px-2 py-0.5 rounded border border-slate-700";
                        bizDiv.classList.add('hidden');
                    }
                } else {
                    showToast(res.message, 'error');
                }
            } catch(e) { showToast('Error', 'error'); }
        });

        document.getElementById('form-cekid').addEventListener('submit', async (e) => {
            e.preventDefault();
            const url = document.getElementById('id-url').value;
            if(!url) return showToast('Enter URL', 'error');

            const resDiv = document.getElementById('id-result');
            
            try {
                showToast('Fetching...', 'success');
                const req = await fetch(`/cekidch?url=${encodeURIComponent(url)}`);
                const res = await req.json();

                if(res.status) {
                    resDiv.classList.remove('hidden');
                    const d = res.data;
                    document.getElementById('ch-name').innerText = d.name;
                    document.getElementById('ch-subs').innerText = d.Pengikut + ' Subscribers';
                    document.getElementById('ch-desc').innerText = d.Deskripsi || 'No description';
                    document.getElementById('ch-id').innerText = d.id;
                    if(d.Photo) document.getElementById('ch-img').src = d.Photo;
                } else {
                     showToast(res.message, 'error');
                }
            } catch(e) { showToast('Error', 'error'); }
        });

        document.getElementById('form-playch').addEventListener('submit', async (e) => {
            e.preventDefault();
            const q = document.getElementById('play-query').value;
            if(!q) return showToast('Masukkan judul lagu', 'error');

            const btn = document.getElementById('btn-playch');
            const originalTxt = btn.innerText;
            btn.innerText = 'SEARCHING...'; btn.disabled = true; btn.classList.add('opacity-70');

            try {
                const req = await fetch(`/playch?query=${encodeURIComponent(q)}`);
                const res = await req.json();
                
                if(res.status) {
                    showToast(res.message);
                    document.getElementById('play-query').value = '';
                } else {
                    showToast(res.message || 'Error', 'error');
                }
            } catch(e) { showToast('Connection failed', 'error'); }

            btn.innerText = originalTxt; btn.disabled = false; btn.classList.remove('opacity-70');
        });

        document.getElementById('form-spam').addEventListener('submit', async (e) => {
            e.preventDefault();
            const num = document.getElementById('spam-number').value;
            const amt = document.getElementById('spam-amount').value;
            
            if(!num) return showToast('Enter Number!', 'error');

            const btn = document.getElementById('btn-spam');
            const originalTxt = btn.innerText;
            btn.innerText = 'PROSES...'; btn.disabled = true; btn.classList.add('opacity-70');

            try {
                showToast('Spamming started...', 'success');
                const req = await fetch('/spampairing', {
                    method: 'POST',
                    headers: {'Content-Type': 'application/json'},
                    body: JSON.stringify({ number: num, amount: amt || 50 })
                });
                const res = await req.json();
                
                if(res.status) {
                    showToast(res.message);
                } else {
                    showToast(res.message || 'Error occurred', 'error');
                }
            } catch(e) { showToast('Connection failed', 'error'); }

            btn.innerText = originalTxt; btn.disabled = false; btn.classList.remove('opacity-70');
        });

        async function fetchStats() {
            try {
                const res = await fetch('/stats');
                if (res.redirected) {
                    window.location.href = res.url;
                    return;
                }
                const data = await res.json();
                
                const stText = document.getElementById('status-text');
                const stDot = document.getElementById('status-dot');
                const stDotM = document.getElementById('status-dot-m');
                
                if(data.wa.connected) {
                    stText.innerText = 'ONLINE'; stText.className = 'text-[10px] font-bold uppercase tracking-widest text-primary';
                    stDot.className = 'w-2.5 h-2.5 rounded-full bg-primary shadow-[0_0_12px_#6366f1]';
                    stDotM.className = 'w-2 h-2 rounded-full bg-primary shadow-[0_0_12px_#6366f1]';
                    if(data.wa.user) document.getElementById('bot-name-display').innerText = data.wa.user.name || data.wa.user.id;
                } else {
                    stText.innerText = 'DISCONNECTED'; stText.className = 'text-[10px] font-bold uppercase tracking-widest text-red-500';
                    stDot.className = 'w-2.5 h-2.5 rounded-full bg-red-500 animate-pulse';
                    stDotM.className = 'w-2 h-2 rounded-full bg-red-500 animate-pulse';
                }
            } catch (e) {}
        }
        setInterval(fetchStats, 2000);
        fetchStats();
    </script>
</body>
</html>