File size: 26,656 Bytes
9a826b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
class GeneratorControls extends HTMLElement {
    constructor() {
        super();
    }

    connectedCallback() {
        this.attachShadow({ mode: 'open' });
        this.shadowRoot.innerHTML = `
            <style>
                :host {
                    display: block;
                }
                .panel {
                    background: rgba(30, 41, 59, 0.4);
                    backdrop-filter: blur(12px);
                    border: 1px solid rgba(139, 92, 246, 0.2);
                    border-radius: 1rem;
                    padding: 1.5rem;
                }
                .input-group {
                    margin-bottom: 1rem;
                }
                .input-label {
                    display: block;
                    color: #94a3b8;
                    font-size: 0.875rem;
                    font-weight: 500;
                    margin-bottom: 0.5rem;
                }
                .cyber-input {
                    width: 100%;
                    background: rgba(15, 23, 42, 0.8);
                    border: 1px solid rgba(139, 92, 246, 0.2);
                    border-radius: 0.5rem;
                    padding: 0.75rem 1rem;
                    color: #f1f5f9;
                    font-size: 0.875rem;
                    transition: all 0.3s;
                    resize: vertical;
                    font-family: inherit;
                }
                .cyber-input:focus {
                    outline: none;
                    border-color: rgba(139, 92, 246, 0.6);
                    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
                }
                .cyber-input::placeholder {
                    color: #475569;
                }
                .ratio-grid {
                    display: grid;
                    grid-template-columns: repeat(5, 1fr);
                    gap: 0.5rem;
                    margin-top: 0.5rem;
                }
                .ratio-btn {
                    padding: 0.5rem;
                    background: rgba(30, 41, 59, 0.8);
                    border: 1px solid rgba(139, 92, 246, 0.2);
                    border-radius: 0.375rem;
                    color: #94a3b8;
                    font-size: 0.75rem;
                    cursor: pointer;
                    transition: all 0.2s;
                    text-align: center;
                }
                .ratio-btn:hover {
                    border-color: rgba(139, 92, 246, 0.4);
                    color: #c4b5fd;
                }
                .ratio-btn.active {
                    background: #7c3aed;
                    border-color: #7c3aed;
                    color: white;
                }
                .generate-btn {
                    width: 100%;
                    padding: 0.875rem;
                    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
                    border: none;
                    border-radius: 0.5rem;
                    color: white;
                    font-weight: 600;
                    font-size: 0.875rem;
                    cursor: pointer;
                    transition: all 0.3s;
                    position: relative;
                    overflow: hidden;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    gap: 0.5rem;
                }
                .generate-btn:hover {
                    transform: translateY(-1px);
                    box-shadow: 0 10px 25px -5px rgba(124, 58, 237, 0.4);
                }
                .generate-btn:active {
                    transform: translateY(0);
                }
                .enhance-btn {
                    position: absolute;
                    right: 0.5rem;
                    top: 50%;
                    transform: translateY(-50%);
                    padding: 0.25rem 0.75rem;
                    background: rgba(6, 182, 212, 0.1);
                    border: 1px solid rgba(6, 182, 212, 0.3);
                    border-radius: 0.25rem;
                    color: #06b6d4;
                    font-size: 0.75rem;
                    cursor: pointer;
                    transition: all 0.2s;
                }
                .enhance-btn:hover {
                    background: rgba(6, 182, 212, 0.2);
                }
                .settings-grid {
                    display: grid;
                    grid-template-columns: 1fr 1fr;
                    gap: 1rem;
                    margin-top: 1rem;
                }
                .setting-item label {
                    display: block;
                    color: #64748b;
                    font-size: 0.75rem;
                    margin-bottom: 0.25rem;
                }
                .setting-item input {
                    width: 100%;
                    background: rgba(15, 23, 42, 0.6);
                    border: 1px solid rgba(139, 92, 246, 0.2);
                    border-radius: 0.25rem;
                    padding: 0.375rem;
                    color: #94a3b8;
                    font-size: 0.75rem;
                }
                .slider-container {
                    margin-top: 0.5rem;
                }
                .slider-label {
                    display: flex;
                    justify-content: space-between;
                    color: #64748b;
                    font-size: 0.75rem;
                    margin-bottom: 0.25rem;
                }
                input[type="range"] {
                    width: 100%;
                    height: 4px;
                    background: rgba(139, 92, 246, 0.2);
                    border-radius: 2px;
                    outline: none;
                    -webkit-appearance: none;
                }
                input[type="range"]::-webkit-slider-thumb {
                    -webkit-appearance: none;
                    width: 16px;
                    height: 16px;
                    background: #7c3aed;
                    border-radius: 50%;
                    cursor: pointer;
                    box-shadow: 0 0 10px rgba(124, 58, 237, 0.5);
                }
                .tag-suggestions {
                    display: flex;
                    flex-wrap: wrap;
                    gap: 0.5rem;
                    margin-top: 0.5rem;
                }
                .tag {
                    padding: 0.25rem 0.5rem;
                    background: rgba(139, 92, 246, 0.1);
                    border: 1px solid rgba(139, 92, 246, 0.3);
                    border-radius: 0.25rem;
                    color: #a78bfa;
                    font-size: 0.75rem;
                    cursor: pointer;
                    transition: all 0.2s;
                }
                .tag:hover {
                    background: rgba(139, 92, 246, 0.2);
                    transform: translateY(-1px);
                }
            </style>
            
            <div class="panel">
                <div class="input-group">
                    <label class="input-label flex justify-between">
                        Prompt
                        <span id="prompt-length" class="text-xs text-slate-500">0 chars</span>
                    </label>
                    <div style="position: relative;">
                        <textarea 
                            id="prompt-input" 
                            class="cyber-input" 
                            rows="4" 
                            placeholder="Describe what you want to see... (e.g., 'a cyberpunk street at night, neon lights, rain, 8k photorealistic')"
                        ></textarea>
                        <button class="enhance-btn" title="Auto-enhance prompt">
                            <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display: inline; margin-right: 4px;"><path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"/></svg>
                            Enhance
                        </button>
                    </div>
                    <div class="tag-suggestions">
                        <span class="tag" onclick="document.getElementById('prompt-input').value += (document.getElementById('prompt-input').value ? ', ' : '') + '8k photorealistic'">+ 8k</span>
                        <span class="tag" onclick="document.getElementById('prompt-input').value += (document.getElementById('prompt-input').value ? ', ' : '') + 'cinematic lighting'">+ cinematic</span>
                        <span class="tag" onclick="document.getElementById('prompt-input').value += (document.getElementById('prompt-input').value ? ', ' : '') + 'unreal engine 5'">+ UE5</span>
                        <span class="tag" onclick="document.getElementById('prompt-input').value += (document.getElementById('prompt-input').value ? ', ' : '') + 'highly detailed'">+ detailed</span>
                    </div>
                </div>
                
                <div class="input-group">
                    <label class="input-label">Negative Prompt</label>
                    <textarea 
                        id="negative-prompt" 
                        class="cyber-input" 
                        rows="2" 
                        placeholder="What to avoid... (e.g., 'blurry, low quality, distorted, ugly')"
                    ></textarea>
                </div>
                
                <div class="input-group">
                    <label class="input-label">Aspect Ratio</label>
                    <div class="ratio-grid">
                        <button class="ratio-btn active" data-ratio="1:1">1:1</button>
                        <button class="ratio-btn" data-ratio="16:9">16:9</button>
                        <button class="ratio-btn" data-ratio="9:16">9:16</button>
                        <button class="ratio-btn" data-ratio="4:3">4:3</button>
                        <button class="ratio-btn" data-ratio="3:4">3:4</button>
                    </div>
                </div>
                
                <div class="slider-container">
                    <div class="slider-label">
                        <span>CFG Scale</span>
                        <span id="cfg-value">7.5</span>
                    </div>
                    <input type="range" min="1" max="20" step="0.5" value="7.5" data-setting="cfgScale" oninput="document.getElementById('cfg-value').textContent = this.value">
                </div>
                
                <div class="slider-container">
                    <div class="slider-label">
                        <span>Steps</span>
                        <span id="steps-value">30</span>
                    </div>
                    <input type="range" min="10" max="50" step="1" value="30" data-setting="steps" oninput="document.getElementById('steps-value').textContent = this.value">
                </div>
                
                <div class="settings-grid">
                    <div class="setting-item">
                        <label>Seed (-1 for random)</label>
                        <input type="number" value="-1" data-setting="seed">
                    </div>
                    <div class="setting-item">
                        <label>Model</label>
                        <select class="cyber-input" style="padding: 0.375rem; font-size: 0.75rem; height: auto;">
                            <option>SDXL Photorealistic</option>
                            <option>Uncensored V3</option>
                            <option>Realistic Vision</option>
                            <option>Epic Realism</option>
                        </select>
                    </div>
                </div>
                
                <button id="generate-btn" class="generate-btn" style="margin-top: 1.5rem;">
                    <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"/></svg>
                    Generate Image
                </button>
            </div>
        `;
        // Handle ratio button clicks
        this.shadowRoot.querySelectorAll('.ratio-btn').forEach(btn => {
            btn.addEventListener('click', (e) => {
                this.shadowRoot.querySelectorAll('.ratio-btn').forEach(b => b.classList.remove('active'));
                e.target.classList.add('active');
                
                // Dispatch custom event for app to handle
                const ratio = e.target.getAttribute('data-ratio');
                this.dispatchEvent(new CustomEvent('ratio-change', {
                    detail: { ratio },
                    bubbles: true,
                    composed: true
                }));
            });
        });

        // Handle generate button click
        const generateBtn = this.shadowRoot.getElementById('generate-btn');
        if (generateBtn) {
            generateBtn.addEventListener('click', () => {
                this.dispatchEvent(new CustomEvent('generate-image', {
                    bubbles: true,
                    composed: true
                }));
            });
        }

        // Handle enhance button click
        const enhanceBtn = this.shadowRoot.querySelector('.enhance-btn');
        if (enhanceBtn) {
            enhanceBtn.addEventListener('click', () => {
                this.dispatchEvent(new CustomEvent('enhance-prompt', {
                    bubbles: true,
                    composed: true
                }));
            });
        }
    }

    getPrompt() {
        return this.shadowRoot.getElementById('prompt-input')?.value || '';
    }

    getNegativePrompt() {
        return this.shadowRoot.getElementById('negative-prompt')?.value || '';
    }

    setPrompt(value) {
        const input = this.shadowRoot.getElementById('prompt-input');
        if (input) input.value = value;
    }
}
class GeneratorPreview extends HTMLElement {
    constructor() {
        super();
    }

    connectedCallback() {
        this.attachShadow({ mode: 'open' });
        this.shadowRoot.innerHTML = `
            <style>
                :host {
                    display: block;
                }
                .preview-container {
                    background: rgba(15, 23, 42, 0.6);
                    border: 1px solid rgba(139, 92, 246, 0.2);
                    border-radius: 1rem;
                    min-height: 500px;
                    display: flex;
                    flex-direction: column;
                    overflow: hidden;
                }
                .preview-header {
                    padding: 1rem 1.5rem;
                    border-bottom: 1px solid rgba(139, 92, 246, 0.1);
                    display: flex;
                    justify-content: space-between;
                    align-items: center;
                }
                .preview-title {
                    color: #e2e8f0;
                    font-weight: 600;
                    font-size: 0.875rem;
                }
                .preview-content {
                    flex: 1;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    padding: 1.5rem;
                    position: relative;
                }
                .empty-state {
                    text-align: center;
                    color: #475569;
                }
                .empty-icon {
                    width: 64px;
                    height: 64px;
                    margin: 0 auto 1rem;
                    opacity: 0.3;
                }
                .video-controls {
                    padding: 1rem 1.5rem;
                    background: rgba(15, 23, 42, 0.8);
                    border-top: 1px solid rgba(6, 182, 212, 0.2);
                    display: none;
                }
                .video-controls.active {
                    display: block;
                }
                .control-row {
                    display: flex;
                    gap: 1rem;
                    margin-bottom: 0.75rem;
                }
                .control-group {
                    flex: 1;
                }
                .control-label {
                    display: block;
                    color: #64748b;
                    font-size: 0.75rem;
                    margin-bottom: 0.25rem;
                }
            </style>
            
            <div class="preview-container" id="preview-container">
                <div class="preview-header">
                    <span class="preview-title">Preview</span>
                    <div class="flex gap-2">
                        <span class="text-xs text-slate-500 px-2 py-1 bg-slate-800 rounded">1024 × 1024</span>
                    </div>
                </div>
                <div class="preview-content">
                    <div class="empty-state">
                        <svg class="empty-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>
                        <p class="text-sm">Enter a prompt and click generate</p>
                        <p class="text-xs mt-2 opacity-50">Your creation will appear here</p>
                    </div>
                </div>
                <div class="video-controls" id="video-controls">
                    <div class="control-row">
                        <div class="control-group">
                            <label class="control-label">Motion Strength</label>
                            <input type="range" min="1" max="10" value="5" class="w-full" data-setting="motionStrength">
                        </div>
                        <div class="control-group">
                            <label class="control-label">Duration (seconds)</label>
                            <input type="range" min="2" max="10" value="4" class="w-full" data-setting="videoDuration">
                        </div>
                    </div>
                    <button id="generate-video-btn" class="w-full py-2 bg-secondary-600 hover:bg-secondary-500 text-white rounded-lg text-sm font-medium transition-colors flex items-center justify-center gap-2">
                        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2" ry="2"/></svg>
                        Generate Video from Image
                    </button>
                </div>
            </div>
        `;
    }
}
class GeneratorPreview extends HTMLElement {
    constructor() {
        super();
        this._content = null;
    }

    connectedCallback() {
        this.attachShadow({ mode: 'open' });
        this.render();
    }

    render() {
        this.shadowRoot.innerHTML = `
            <style>
                :host {
                    display: block;
                }
                .preview-container {
                    background: rgba(15, 23, 42, 0.6);
                    border: 1px solid rgba(139, 92, 246, 0.2);
                    border-radius: 1rem;
                    min-height: 500px;
                    display: flex;
                    flex-direction: column;
                    overflow: hidden;
                }
                .preview-header {
                    padding: 1rem 1.5rem;
                    border-bottom: 1px solid rgba(139, 92, 246, 0.1);
                    display: flex;
                    justify-content: space-between;
                    align-items: center;
                }
                .preview-title {
                    color: #e2e8f0;
                    font-weight: 600;
                    font-size: 0.875rem;
                }
                .preview-content {
                    flex: 1;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    padding: 1.5rem;
                    position: relative;
                }
                .empty-state {
                    text-align: center;
                    color: #475569;
                }
                .empty-icon {
                    width: 64px;
                    height: 64px;
                    margin: 0 auto 1rem;
                    opacity: 0.3;
                }
                .video-controls {
                    padding: 1rem 1.5rem;
                    background: rgba(15, 23, 42, 0.8);
                    border-top: 1px solid rgba(6, 182, 212, 0.2);
                    display: none;
                }
                .video-controls.active {
                    display: block;
                }
                .control-row {
                    display: flex;
                    gap: 1rem;
                    margin-bottom: 0.75rem;
                }
                .control-group {
                    flex: 1;
                }
                .control-label {
                    display: block;
                    color: #64748b;
                    font-size: 0.75rem;
                    margin-bottom: 0.25rem;
                }
                .generated-image {
                    max-width: 100%;
                    max-height: 100%;
                    object-fit: contain;
                    border-radius: 0.5rem;
                }
                .loading-overlay {
                    position: absolute;
                    inset: 0;
                    display: flex;
                    flex-direction: column;
                    align-items: center;
                    justify-content: center;
                    background: rgba(15, 23, 42, 0.9);
                }
                .spinner {
                    width: 48px;
                    height: 48px;
                    border: 4px solid rgba(139, 92, 246, 0.2);
                    border-top-color: #7c3aed;
                    border-radius: 50%;
                    animation: spin 1s linear infinite;
                }
                @keyframes spin {
                    to { transform: rotate(360deg); }
                }
            </style>
            
            <div class="preview-container" id="preview-container">
                <div class="preview-header">
                    <span class="preview-title">Preview</span>
                    <div class="flex gap-2">
                        <span class="text-xs text-slate-500 px-2 py-1 bg-slate-800 rounded">1024 × 1024</span>
                    </div>
                </div>
                <div class="preview-content" id="preview-content">
                    <div class="empty-state">
                        <svg class="empty-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>
                        <p class="text-sm">Enter a prompt and click generate</p>
                        <p class="text-xs mt-2 opacity-50">Your creation will appear here</p>
                    </div>
                </div>
                <div class="video-controls" id="video-controls">
                    <div class="control-row">
                        <div class="control-group">
                            <label class="control-label">Motion Strength</label>
                            <input type="range" min="1" max="10" value="5" class="w-full" data-setting="motionStrength">
                        </div>
                        <div class="control-group">
                            <label class="control-label">Duration (seconds)</label>
                            <input type="range" min="2" max="10" value="4" class="w-full" data-setting="videoDuration">
                        </div>
                    </div>
                    <button id="generate-video-btn" class="w-full py-2 bg-secondary-600 hover:bg-secondary-500 text-white rounded-lg text-sm font-medium transition-colors flex items-center justify-center gap-2">
                        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2" ry="2"/></svg>
                        Generate Video from Image
                    </button>
                </div>
            </div>
        `;

        // Restore content if exists
        if (this._content) {
            this.setContent(this._content);
        }

        // Bind video generate button
        const videoBtn = this.shadowRoot.getElementById('generate-video-btn');
        if (videoBtn) {
            videoBtn.addEventListener('click', () => {
                this.dispatchEvent(new CustomEvent('generate-video', {
                    bubbles: true,
                    composed: true
                }));
            });
        }
    }

    setLoading(isLoading, text = 'Generating...') {
        const content = this.shadowRoot.getElementById('preview-content');
        if (!content) return;
        
        if (isLoading) {
            content.innerHTML = `
                <div class="loading-overlay">
                    <div class="spinner"></div>
                    <p style="color: #a78bfa; margin-top: 1rem; font-size: 0.875rem;">${text}</p>
                </div>
            `;
        } else {
            this.render();
        }
    }

    setContent(html) {
        this._content = html;
        const content = this.shadowRoot.getElementById('preview-content');
        if (content) {
            content.innerHTML = html;
        }
    }

    showVideoControls(show) {
        const controls = this.shadowRoot.getElementById('video-controls');
        if (controls) {
            controls.classList.toggle('active', show);
        }
    }
}

customElements.define('generator-controls', GeneratorControls);
customElements.define('generator-preview', GeneratorPreview);