prithivMLmods commited on
Commit
4d9c42d
·
verified ·
1 Parent(s): 5e9baec

update UI

Browse files
Files changed (1) hide show
  1. index.html +1379 -0
index.html ADDED
@@ -0,0 +1,1379 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Wan2.2 Studio · Fast Video</title>
7
+ <style>
8
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');
9
+ *{box-sizing:border-box;margin:0;padding:0}
10
+ :root{
11
+ --bg:#0a0a0c;--panel:#131316;--panel2:#0e0e11;--canvas:#08080a;
12
+ --border:#1f1f2a;--border2:#2a2a3a;
13
+ --text:#e4e4e7;--muted:#a1a1aa;--dim:#6b6b75;--faint:#4a4a52;
14
+ --accent:#00008B;--accent2:#1A1AFF;--accent3:#5D5DFF;
15
+ --menubar-h:48px;--statusbar-h:30px;--rail-w:52px;--inspector-w:360px;--filmstrip-h:132px;
16
+ }
17
+ html,body{height:100%}
18
+ body{
19
+ background:var(--bg);font-family:'Inter',system-ui,-apple-system,sans-serif;
20
+ font-size:13px;color:var(--text);overflow:hidden;
21
+ }
22
+
23
+ /* ══ Layout grid ══ */
24
+ .studio{
25
+ display:grid;height:100vh;
26
+ grid-template-rows:var(--menubar-h) 1fr var(--statusbar-h);
27
+ grid-template-columns:var(--rail-w) 1fr var(--inspector-w);
28
+ grid-template-areas:
29
+ "menubar menubar menubar"
30
+ "rail workspace inspector"
31
+ "statusbar statusbar statusbar";
32
+ }
33
+
34
+ /* ══ Menu bar ══ */
35
+ .menubar{
36
+ grid-area:menubar;display:flex;align-items:center;gap:14px;
37
+ background:var(--panel);border-bottom:1px solid var(--border);
38
+ padding:0 16px;z-index:50;
39
+ }
40
+ .menubar-logo{
41
+ width:28px;height:28px;background:linear-gradient(135deg,#00008B,#1A1AFF,#5D5DFF);
42
+ border-radius:8px;display:flex;align-items:center;justify-content:center;
43
+ box-shadow:0 2px 8px rgba(0,0,139,.35);flex-shrink:0;
44
+ }
45
+ .menubar-logo svg{width:15px;height:15px;fill:#fff}
46
+ .menubar-title{font-size:14px;font-weight:700;letter-spacing:-.2px;white-space:nowrap}
47
+ .menubar-title span{color:var(--dim);font-weight:500}
48
+ .menubar-badge{
49
+ font-size:10px;font-weight:700;padding:2px 8px;border-radius:12px;
50
+ background:rgba(0,0,139,.14);color:var(--accent2);border:1px solid rgba(0,0,139,.25);
51
+ letter-spacing:.4px;white-space:nowrap;
52
+ }
53
+ .menubar-badge.fast{background:rgba(34,197,94,.12);color:#4ade80;border-color:rgba(34,197,94,.25)}
54
+ .menubar-spacer{flex:1}
55
+ .menubar-status{
56
+ display:flex;align-items:center;gap:7px;font-family:'JetBrains Mono',monospace;
57
+ font-size:11px;color:var(--dim);
58
+ }
59
+ .menubar-status .dot{width:7px;height:7px;border-radius:50%;background:#4ade80;box-shadow:0 0 6px rgba(74,222,128,.6)}
60
+ .menubar-status .dot.off{background:#f87171;box-shadow:0 0 6px rgba(248,113,113,.5)}
61
+ .gh-btn{
62
+ display:inline-flex;align-items:center;gap:6px;
63
+ padding:5px 13px;border-radius:7px;text-decoration:none;
64
+ font-size:12px;font-weight:600;background:var(--accent);color:#fff;
65
+ border:1px solid rgba(255,255,255,.15);
66
+ transition:all .15s ease;flex-shrink:0;
67
+ }
68
+ .gh-btn:hover{background:var(--accent2)}
69
+ .gh-btn svg{fill:#fff;width:13px;height:13px}
70
+
71
+ /* ══ Left icon rail ══ */
72
+ .rail{
73
+ grid-area:rail;background:var(--panel);border-right:1px solid var(--border);
74
+ display:flex;flex-direction:column;align-items:center;padding:10px 0;gap:4px;
75
+ overflow-y:auto;z-index:40;
76
+ }
77
+ .rail-btn{
78
+ width:38px;height:38px;border-radius:9px;border:1px solid transparent;
79
+ background:transparent;color:var(--dim);cursor:pointer;
80
+ display:flex;align-items:center;justify-content:center;
81
+ transition:all .15s ease;position:relative;
82
+ }
83
+ .rail-btn:hover:not(:disabled){background:rgba(0,0,139,.12);color:var(--accent3);border-color:rgba(0,0,139,.25)}
84
+ .rail-btn.active{background:rgba(0,0,139,.2);color:var(--accent2);border-color:rgba(0,0,139,.4)}
85
+ .rail-btn:disabled{opacity:.3;cursor:not-allowed}
86
+ .rail-btn svg{width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
87
+ .rail-btn svg.fill{fill:currentColor;stroke:none}
88
+ .rail-sep{width:24px;height:1px;background:var(--border);margin:6px 0}
89
+ .rail-label{
90
+ font-size:8px;font-weight:700;color:var(--faint);letter-spacing:1px;
91
+ text-transform:uppercase;margin:8px 0 2px;user-select:none;
92
+ }
93
+
94
+ /* ══ Workspace ══ */
95
+ .workspace{
96
+ grid-area:workspace;display:flex;flex-direction:column;min-width:0;min-height:0;
97
+ background:var(--canvas);
98
+ }
99
+ .canvas-head{
100
+ display:flex;align-items:center;gap:10px;padding:8px 16px;
101
+ border-bottom:1px solid var(--border);background:var(--panel2);flex-shrink:0;
102
+ }
103
+ .seg-control{
104
+ display:inline-flex;background:var(--panel);border:1px solid var(--border);
105
+ border-radius:8px;padding:2px;gap:2px;
106
+ }
107
+ .seg-btn{
108
+ padding:4px 14px;font-size:11px;font-weight:600;color:var(--dim);
109
+ background:transparent;border:none;border-radius:6px;cursor:pointer;
110
+ font-family:'Inter',sans-serif;transition:all .15s;letter-spacing:.2px;
111
+ }
112
+ .seg-btn:hover:not(.active){color:var(--muted)}
113
+ .seg-btn.active{background:rgba(0,0,139,.18);color:var(--accent2)}
114
+ .canvas-meta{
115
+ font-family:'JetBrains Mono',monospace;font-size:11px;color:var(--faint);
116
+ overflow:hidden;white-space:nowrap;text-overflow:ellipsis;flex:1;
117
+ }
118
+ .canvas-actions{display:flex;align-items:center;gap:6px}
119
+ .out-seed-chip{
120
+ display:none;font-family:'JetBrains Mono',monospace;font-size:10px;font-weight:500;
121
+ color:var(--dim);background:var(--panel);border:1px solid var(--border);
122
+ border-radius:6px;padding:4px 9px;cursor:pointer;transition:all .15s;
123
+ }
124
+ .out-seed-chip.visible{display:inline-flex}
125
+ .out-seed-chip:hover{color:var(--accent3);border-color:rgba(0,0,139,.35)}
126
+
127
+ .canvas-stage{
128
+ flex:1;position:relative;overflow:hidden;min-height:0;
129
+ display:flex;align-items:center;justify-content:center;
130
+ background:
131
+ repeating-conic-gradient(#0c0c0f 0% 25%, #08080a 0% 50%) 0 0/24px 24px;
132
+ }
133
+ .canvas-stage video.modern-out-vid,
134
+ .canvas-stage img.modern-out-img{
135
+ max-width:calc(100% - 48px);max-height:calc(100% - 48px);
136
+ box-shadow:0 12px 48px rgba(0,0,0,.7),0 0 0 1px var(--border);
137
+ border-radius:4px;image-rendering:auto;
138
+ animation:canvasIn .3s ease;
139
+ }
140
+ .canvas-stage video.modern-out-vid{cursor:pointer}
141
+ .canvas-stage img.modern-out-img{cursor:zoom-in}
142
+ @keyframes canvasIn{from{opacity:0;transform:scale(.985)}to{opacity:1;transform:scale(1)}}
143
+ .canvas-placeholder{
144
+ text-align:center;color:var(--faint);user-select:none;
145
+ display:flex;flex-direction:column;align-items:center;gap:14px;padding:24px;
146
+ }
147
+ .canvas-placeholder svg{width:72px;height:72px;opacity:.5}
148
+ .canvas-placeholder .cp-title{font-size:15px;font-weight:600;color:var(--dim)}
149
+ .canvas-placeholder .cp-sub{font-size:12px;line-height:1.7;max-width:340px}
150
+ .canvas-placeholder kbd{
151
+ padding:1px 6px;background:var(--panel);border:1px solid var(--border2);
152
+ border-radius:4px;font-family:'JetBrains Mono',monospace;font-size:10px;color:var(--muted);
153
+ }
154
+
155
+ /* Compare slider */
156
+ .compare-wrap{
157
+ position:relative;max-width:calc(100% - 48px);max-height:calc(100% - 48px);overflow:hidden;
158
+ display:none;user-select:none;touch-action:none;cursor:ew-resize;
159
+ box-shadow:0 12px 48px rgba(0,0,0,.7),0 0 0 1px var(--border);border-radius:4px;
160
+ }
161
+ .compare-wrap.visible{display:block}
162
+ .compare-wrap img{display:block;max-width:100%;max-height:100%;pointer-events:none}
163
+ .compare-top{position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden}
164
+ .compare-top img{position:absolute;top:0;left:0;height:100%;width:auto;max-width:none!important;max-height:none!important}
165
+ .compare-divider{position:absolute;top:0;bottom:0;width:2px;background:#fff;box-shadow:0 0 8px rgba(0,0,0,.6);pointer-events:none}
166
+ .compare-handle{
167
+ position:absolute;top:50%;transform:translate(-50%,-50%);
168
+ width:32px;height:32px;border-radius:50%;background:#fff;
169
+ display:flex;align-items:center;justify-content:center;
170
+ box-shadow:0 2px 8px rgba(0,0,0,.5);color:#111;font-size:13px;font-weight:800;
171
+ }
172
+ .compare-label{
173
+ position:absolute;top:8px;padding:2px 8px;border-radius:4px;
174
+ background:rgba(0,0,0,.65);color:#fff;font-size:10px;font-weight:600;
175
+ font-family:'JetBrains Mono',monospace;pointer-events:none;
176
+ }
177
+ .compare-label.before{left:8px}
178
+ .compare-label.after{right:8px}
179
+
180
+ /* Loader */
181
+ .modern-loader{
182
+ display:none;position:absolute;inset:0;background:rgba(8,8,10,.9);
183
+ z-index:15;flex-direction:column;align-items:center;justify-content:center;gap:16px;backdrop-filter:blur(5px);
184
+ }
185
+ .modern-loader.active{display:flex}
186
+ .loader-spinner{
187
+ width:38px;height:38px;border:3px solid var(--border);border-top-color:var(--accent);
188
+ border-radius:50%;animation:spin .8s linear infinite;
189
+ }
190
+ @keyframes spin{to{transform:rotate(360deg)}}
191
+ .loader-text{font-size:13px;color:var(--muted);font-weight:500;text-align:center;padding:0 16px}
192
+ .loader-bar-track{width:220px;height:4px;background:var(--border);border-radius:2px;overflow:hidden}
193
+ .loader-bar-fill{
194
+ height:100%;width:100%;background:linear-gradient(90deg,#00008B,#1A1AFF,#00008B);
195
+ background-size:200% 100%;animation:shimmer 1.5s ease-in-out infinite;border-radius:2px;
196
+ transition:width .3s ease;
197
+ }
198
+ .loader-bar-fill.determinate{animation:none;background:var(--accent)}
199
+ @keyframes shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}
200
+
201
+ /* ══ Filmstrip ══ */
202
+ .filmstrip{
203
+ height:var(--filmstrip-h);flex-shrink:0;background:var(--panel);
204
+ border-top:1px solid var(--border);display:flex;min-height:0;overflow:hidden;
205
+ }
206
+ .filmstrip-section{
207
+ display:flex;flex-direction:column;min-width:0;padding:8px 0 8px 14px;
208
+ }
209
+ .filmstrip-section.inputs{flex:1.2;border-right:1px solid var(--border)}
210
+ .filmstrip-section.history{flex:1}
211
+ .filmstrip-label{
212
+ font-size:9px;font-weight:700;color:var(--faint);letter-spacing:1.2px;
213
+ text-transform:uppercase;margin-bottom:6px;display:flex;align-items:center;gap:8px;
214
+ user-select:none;flex-shrink:0;
215
+ }
216
+ .filmstrip-label .count{
217
+ font-family:'JetBrains Mono',monospace;font-weight:500;color:var(--dim);
218
+ background:var(--panel2);border:1px solid var(--border);border-radius:4px;padding:0 5px;font-size:9px;
219
+ }
220
+ .filmstrip-row{
221
+ display:flex;gap:8px;overflow-x:auto;overflow-y:hidden;flex:1;
222
+ align-items:flex-start;padding-bottom:4px;padding-right:14px;
223
+ }
224
+ .filmstrip-row::-webkit-scrollbar{height:5px}
225
+ .filmstrip-row::-webkit-scrollbar-thumb{background:var(--border);border-radius:3px}
226
+ .fs-thumb{
227
+ position:relative;flex-shrink:0;width:76px;height:76px;border-radius:8px;overflow:hidden;
228
+ border:2px solid var(--border);cursor:pointer;transition:all .15s;background:var(--panel2);
229
+ animation:thumbIn .25s ease;
230
+ }
231
+ @keyframes thumbIn{from{opacity:0;transform:scale(.92)}to{opacity:1;transform:scale(1)}}
232
+ .fs-thumb:hover{border-color:var(--border2);transform:translateY(-2px)}
233
+ .fs-thumb.selected{border-color:var(--accent);box-shadow:0 0 0 2px rgba(0,0,139,.25)}
234
+ .fs-thumb img{width:100%;height:100%;object-fit:cover}
235
+ .fs-badge{
236
+ position:absolute;bottom:4px;left:4px;background:rgba(0,0,0,.75);color:#fff;
237
+ padding:1px 6px;border-radius:4px;font-family:'JetBrains Mono',monospace;font-size:9px;font-weight:600;
238
+ }
239
+ .fs-remove{
240
+ position:absolute;top:4px;right:4px;width:20px;height:20px;background:rgba(0,0,0,.8);
241
+ color:#fff;border:1px solid rgba(255,255,255,.2);border-radius:50%;cursor:pointer;
242
+ display:none;align-items:center;justify-content:center;font-size:10px;transition:all .15s;line-height:1;
243
+ }
244
+ .fs-thumb:hover .fs-remove{display:flex}
245
+ .fs-remove:hover{background:#ef4444;border-color:#ef4444}
246
+ .fs-add{
247
+ flex-shrink:0;width:76px;height:76px;border-radius:8px;border:2px dashed var(--border2);
248
+ display:flex;flex-direction:column;align-items:center;justify-content:center;
249
+ cursor:pointer;transition:all .2s;background:rgba(0,0,139,.03);gap:3px;
250
+ }
251
+ .fs-add:hover{border-color:var(--accent);background:rgba(0,0,139,.08)}
252
+ .fs-add .add-icon{font-size:22px;color:var(--dim);font-weight:300}
253
+ .fs-add .add-text{font-size:9px;color:var(--dim);font-weight:600;text-transform:uppercase;letter-spacing:.5px}
254
+ .fs-empty{
255
+ flex-shrink:0;display:flex;align-items:center;height:76px;
256
+ color:var(--faint);font-size:11px;font-style:italic;padding-right:12px;
257
+ }
258
+
259
+ /* ══ Inspector ══ */
260
+ .inspector{
261
+ grid-area:inspector;background:var(--panel);border-left:1px solid var(--border);
262
+ display:flex;flex-direction:column;min-height:0;z-index:40;
263
+ }
264
+ .inspector-tabs{
265
+ display:flex;border-bottom:1px solid var(--border);flex-shrink:0;
266
+ }
267
+ .insp-tab{
268
+ flex:1;padding:11px 8px;font-size:11px;font-weight:700;color:var(--dim);
269
+ background:transparent;border:none;border-bottom:2px solid transparent;
270
+ cursor:pointer;font-family:'Inter',sans-serif;text-transform:uppercase;letter-spacing:.8px;
271
+ transition:all .15s;
272
+ }
273
+ .insp-tab:hover:not(.active){color:var(--muted)}
274
+ .insp-tab.active{color:var(--accent2);border-bottom-color:var(--accent)}
275
+ .insp-page{display:none;flex:1;overflow-y:auto;min-height:0;flex-direction:column}
276
+ .insp-page.active{display:flex}
277
+
278
+ .insp-section{border-bottom:1px solid var(--border);padding:14px 18px}
279
+ .insp-section-title{
280
+ font-size:10px;font-weight:700;color:var(--dim);text-transform:uppercase;
281
+ letter-spacing:1px;margin-bottom:10px;display:flex;align-items:center;justify-content:space-between;
282
+ }
283
+ .char-count{font-size:9px;font-weight:500;color:var(--faint);font-family:'JetBrains Mono',monospace;text-transform:none;letter-spacing:0}
284
+ .modern-textarea{
285
+ width:100%;background:var(--panel2);border:1px solid var(--border);border-radius:8px;
286
+ padding:10px 13px;font-family:'Inter',sans-serif;font-size:13px;color:var(--text);
287
+ resize:vertical;outline:none;min-height:64px;transition:border-color .2s;line-height:1.55;
288
+ }
289
+ .modern-textarea:focus{border-color:var(--accent);box-shadow:0 0 0 3px rgba(0,0,139,.15)}
290
+ .modern-textarea::placeholder{color:var(--faint)}
291
+ .modern-textarea.error-flash{
292
+ border-color:#ef4444!important;box-shadow:0 0 0 3px rgba(239,68,68,.2)!important;animation:shake .4s ease;
293
+ }
294
+ @keyframes shake{0%,100%{transform:translateX(0)}20%,60%{transform:translateX(-4px)}40%,80%{transform:translateX(4px)}}
295
+
296
+ .suggestions-wrap{display:flex;flex-wrap:wrap;gap:5px}
297
+ .suggestion-chip{
298
+ display:inline-flex;align-items:center;padding:4px 11px;
299
+ background:rgba(0,0,139,.07);border:1px solid rgba(0,0,139,.18);border-radius:14px;
300
+ color:var(--accent3);font-size:11px;font-weight:500;font-family:'Inter',sans-serif;
301
+ cursor:pointer;transition:all .15s;white-space:nowrap;
302
+ }
303
+ .suggestion-chip:hover{background:rgba(0,0,139,.15);border-color:rgba(0,0,139,.35);color:var(--accent2)}
304
+ .suggestion-chip.active{background:rgba(0,0,139,.25);border-color:var(--accent);color:#fff}
305
+
306
+ .btn-run{
307
+ display:flex;align-items:center;justify-content:center;gap:8px;width:100%;
308
+ background:linear-gradient(135deg,#00008B,#00006B);border:none;border-radius:9px;
309
+ padding:12px 24px;cursor:pointer;font-size:14px;font-weight:700;font-family:'Inter',sans-serif;
310
+ color:#fff;transition:all .2s ease;letter-spacing:-.2px;
311
+ box-shadow:0 4px 16px rgba(0,0,139,.3),inset 0 1px 0 rgba(255,255,255,.1);
312
+ }
313
+ .btn-run:hover:not(:disabled){
314
+ background:linear-gradient(135deg,#1A1AFF,#00008B);transform:translateY(-1px);
315
+ box-shadow:0 6px 24px rgba(0,0,139,.45),inset 0 1px 0 rgba(255,255,255,.15);
316
+ }
317
+ .btn-run:active:not(:disabled){transform:translateY(0)}
318
+ .btn-run:disabled{opacity:.55;cursor:not-allowed}
319
+ .btn-cancel{
320
+ display:flex;align-items:center;justify-content:center;gap:6px;width:100%;
321
+ margin-top:8px;background:transparent;border:1px solid var(--border2);border-radius:9px;
322
+ padding:8px 24px;cursor:pointer;font-size:12px;font-weight:600;font-family:'Inter',sans-serif;
323
+ color:var(--muted);transition:all .15s;
324
+ }
325
+ .btn-cancel:hover{border-color:#ef4444;color:#ef4444;background:rgba(239,68,68,.08)}
326
+ .run-hint{
327
+ text-align:center;font-size:10px;color:var(--faint);margin-top:8px;
328
+ font-family:'JetBrains Mono',monospace;
329
+ }
330
+
331
+ .slider-row{display:flex;align-items:center;gap:9px;min-height:26px;margin-bottom:10px}
332
+ .slider-row:last-child{margin-bottom:0}
333
+ .slider-row label{font-size:12px;font-weight:500;color:var(--muted);min-width:64px;flex-shrink:0}
334
+ .slider-row input[type="range"]{
335
+ flex:1;-webkit-appearance:none;appearance:none;height:5px;background:var(--border);
336
+ border-radius:3px;outline:none;min-width:0;
337
+ }
338
+ .slider-row input[type="range"]::-webkit-slider-thumb{
339
+ -webkit-appearance:none;width:14px;height:14px;background:linear-gradient(135deg,#00008B,#00006B);
340
+ border-radius:50%;cursor:pointer;box-shadow:0 2px 6px rgba(0,0,139,.4);transition:transform .15s;
341
+ }
342
+ .slider-row input[type="range"]::-webkit-slider-thumb:hover{transform:scale(1.2)}
343
+ .slider-row input[type="range"]::-moz-range-thumb{
344
+ width:14px;height:14px;background:linear-gradient(135deg,#00008B,#00006B);
345
+ border-radius:50%;cursor:pointer;border:none;box-shadow:0 2px 6px rgba(0,0,139,.4);
346
+ }
347
+ .slider-val{
348
+ min-width:48px;text-align:right;font-family:'JetBrains Mono',monospace;font-size:11px;
349
+ font-weight:500;padding:2px 7px;background:var(--panel2);border:1px solid var(--border);
350
+ border-radius:5px;color:var(--muted);flex-shrink:0;
351
+ }
352
+ .dice-btn{
353
+ display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;
354
+ background:var(--panel2);border:1px solid var(--border);border-radius:5px;cursor:pointer;
355
+ color:var(--dim);transition:all .15s;flex-shrink:0;padding:0;
356
+ }
357
+ .dice-btn:hover{border-color:var(--accent);color:var(--accent3)}
358
+ .dice-btn svg{width:13px;height:13px;fill:currentColor}
359
+ .checkbox-row{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--muted);margin-bottom:10px}
360
+ .checkbox-row input[type="checkbox"]{accent-color:var(--accent);width:15px;height:15px;cursor:pointer}
361
+ .checkbox-row label{color:var(--muted);font-size:12px;cursor:pointer}
362
+
363
+ /* Examples page */
364
+ .examples-list{padding:12px 14px;display:flex;flex-direction:column;gap:10px}
365
+ .example-card{
366
+ background:var(--panel2);border:1px solid var(--border);
367
+ border-radius:10px;overflow:hidden;cursor:pointer;transition:all .2s ease;flex-shrink:0;
368
+ display:flex;align-items:stretch;
369
+ }
370
+ .example-card:hover{border-color:var(--accent);box-shadow:0 4px 14px rgba(0,0,139,.15)}
371
+ .example-card.loading{opacity:.5;pointer-events:none}
372
+ .example-thumb-wrap{width:96px;flex-shrink:0;background:var(--panel);overflow:hidden;display:flex}
373
+ .example-thumb-wrap img{width:100%;height:100%;object-fit:cover}
374
+ .example-thumb-placeholder{
375
+ width:100%;height:100%;display:flex;align-items:center;justify-content:center;
376
+ background:var(--panel);color:var(--border2);font-size:10px;
377
+ }
378
+ .example-meta{padding:6px 10px 2px;display:flex;align-items:center;gap:5px;flex-wrap:wrap}
379
+ .example-lora-badge{
380
+ display:inline-flex;padding:2px 7px;background:rgba(0,0,139,.1);border-radius:4px;
381
+ font-size:9px;font-weight:600;color:var(--accent2);font-family:'JetBrains Mono',monospace;
382
+ white-space:nowrap;border:1px solid rgba(0,0,139,.25);
383
+ }
384
+ .example-body{flex:1;display:flex;flex-direction:column;justify-content:center;min-width:0}
385
+ .example-prompt-text{
386
+ padding:4px 10px 9px;font-size:11px;color:var(--muted);line-height:1.45;
387
+ display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;
388
+ }
389
+
390
+ /* ══ Status bar ══ */
391
+ .statusbar{
392
+ grid-area:statusbar;background:var(--panel);border-top:1px solid var(--border);
393
+ display:flex;align-items:center;gap:4px;padding:0 14px;font-size:11px;z-index:50;
394
+ }
395
+ .statusbar .sb-section{
396
+ padding:0 10px;display:flex;align-items:center;font-family:'JetBrains Mono',monospace;
397
+ font-size:11px;color:var(--faint);overflow:hidden;white-space:nowrap;gap:6px;
398
+ }
399
+ .statusbar .sb-right{margin-left:auto;display:flex;align-items:center;gap:10px}
400
+ .sb-pill{
401
+ padding:2px 12px;border-radius:5px;font-weight:600;font-size:10px;
402
+ background:rgba(0,0,139,.1);color:var(--accent2);
403
+ }
404
+ .sb-pill.error{background:rgba(239,68,68,.12);color:#f87171}
405
+ .sb-pill.done{background:rgba(34,197,94,.12);color:#4ade80}
406
+ .sb-link{color:var(--faint);text-decoration:none;font-family:'JetBrains Mono',monospace;font-size:10px}
407
+ .sb-link:hover{color:var(--accent3)}
408
+
409
+ /* ══ Toast ══ */
410
+ .toast-notification{
411
+ position:fixed;top:60px;left:50%;transform:translateX(-50%) translateY(-140%);
412
+ z-index:9999;padding:10px 22px;border-radius:9px;font-family:'Inter',sans-serif;
413
+ font-size:13px;font-weight:600;display:flex;align-items:center;gap:8px;
414
+ box-shadow:0 8px 24px rgba(0,0,0,.5);
415
+ transition:transform .35s cubic-bezier(.34,1.56,.64,1),opacity .35s ease;opacity:0;pointer-events:none;
416
+ }
417
+ .toast-notification.visible{transform:translateX(-50%) translateY(0);opacity:1;pointer-events:auto}
418
+ .toast-notification.error{background:linear-gradient(135deg,#dc2626,#b91c1c);color:#fff;border:1px solid rgba(255,255,255,.15)}
419
+ .toast-notification.warning{background:linear-gradient(135deg,#d97706,#b45309);color:#fff;border:1px solid rgba(255,255,255,.15)}
420
+ .toast-notification.info{background:linear-gradient(135deg,#00008B,#00006B);color:#fff;border:1px solid rgba(255,255,255,.15)}
421
+ .toast-notification .toast-icon{font-size:15px;line-height:1}
422
+
423
+ /* ══ Lightbox ══ */
424
+ .lightbox{
425
+ position:fixed;inset:0;background:rgba(0,0,0,.92);z-index:10000;
426
+ display:none;align-items:center;justify-content:center;cursor:zoom-out;
427
+ backdrop-filter:blur(6px);animation:fadeIn .2s ease;
428
+ }
429
+ .lightbox.visible{display:flex}
430
+ .lightbox img{max-width:94vw;max-height:94vh;border-radius:6px;box-shadow:0 20px 60px rgba(0,0,0,.8)}
431
+ @keyframes fadeIn{from{opacity:0}to{opacity:1}}
432
+
433
+ /* ══ Drop overlay ══ */
434
+ .drop-overlay{
435
+ position:fixed;inset:0;z-index:9000;background:rgba(8,8,10,.85);
436
+ display:none;align-items:center;justify-content:center;pointer-events:none;
437
+ backdrop-filter:blur(3px);
438
+ }
439
+ .drop-overlay.visible{display:flex}
440
+ .drop-overlay-inner{
441
+ border:3px dashed var(--accent);border-radius:22px;padding:56px 76px;
442
+ font-size:19px;font-weight:700;color:var(--accent2);background:rgba(0,0,139,.06);
443
+ }
444
+
445
+ /* ══ Scrollbars ══ */
446
+ ::-webkit-scrollbar{width:8px;height:8px}
447
+ ::-webkit-scrollbar-track{background:transparent}
448
+ ::-webkit-scrollbar-thumb{background:var(--border);border-radius:4px}
449
+ ::-webkit-scrollbar-thumb:hover{background:var(--border2)}
450
+
451
+ /* ══ Touch devices ══ */
452
+ @media (pointer:coarse){
453
+ .fs-remove{display:flex}
454
+ .rail-btn{width:44px;height:44px}
455
+ .rail-btn svg{width:19px;height:19px}
456
+ }
457
+
458
+ /* ══ Responsive ══ */
459
+ @media(max-width:960px){
460
+ html,body{height:auto}
461
+ body{overflow:auto!important}
462
+ .studio{
463
+ display:flex;flex-direction:column;height:auto;min-height:100vh;
464
+ }
465
+ .menubar{
466
+ flex-wrap:wrap;gap:8px;padding:10px 12px;min-height:var(--menubar-h);
467
+ position:sticky;top:0;
468
+ }
469
+ .menubar-title{font-size:13px}
470
+ .menubar-status{display:none}
471
+ .menubar-spacer{flex:1}
472
+ .gh-btn{padding:6px 10px}
473
+ .gh-btn span{display:none}
474
+ .rail{
475
+ flex-direction:row;justify-content:flex-start;flex-wrap:nowrap;
476
+ overflow-x:auto;overflow-y:hidden;border-right:none;
477
+ border-bottom:1px solid var(--border);padding:6px 10px;gap:6px;
478
+ }
479
+ .rail-sep{width:1px;height:26px;margin:0 4px;flex-shrink:0}
480
+ .rail-label{display:none}
481
+ .rail-btn{flex-shrink:0}
482
+ .workspace{min-height:0}
483
+ .canvas-head{flex-wrap:wrap;gap:8px;padding:8px 12px}
484
+ .canvas-meta{flex-basis:100%;order:3;font-size:10px}
485
+ .canvas-stage{min-height:42vh}
486
+ .canvas-stage img.modern-out-img, .canvas-stage video.modern-out-vid{max-width:calc(100% - 20px);max-height:52vh}
487
+ .compare-wrap{max-width:calc(100% - 20px);max-height:52vh}
488
+ .canvas-placeholder .cp-sub{font-size:11px;max-width:280px}
489
+ .filmstrip{flex-direction:column;height:auto;max-height:none}
490
+ .filmstrip-section.inputs{border-right:none;border-bottom:1px solid var(--border)}
491
+ .filmstrip-section{padding:8px 0 8px 12px}
492
+ .fs-thumb{width:68px;height:68px}
493
+ .fs-add{width:68px;height:68px}
494
+ .fs-empty{height:68px}
495
+ .inspector{border-left:none;border-top:1px solid var(--border)}
496
+ .inspector-tabs{position:sticky;top:0;background:var(--panel);z-index:30}
497
+ .insp-tab{padding:13px 8px;font-size:12px}
498
+ .insp-page{overflow-y:visible}
499
+ .insp-section{padding:14px 16px}
500
+ .modern-textarea{font-size:16px}
501
+ .btn-run{padding:14px 24px;font-size:15px}
502
+ .suggestion-chip{padding:6px 13px;font-size:12px}
503
+ .statusbar{flex-wrap:wrap;height:auto;min-height:var(--statusbar-h);padding:4px 10px;gap:2px}
504
+ .sb-link{display:none}
505
+ .toast-notification{max-width:calc(100vw - 32px);font-size:12px;padding:10px 16px}
506
+ .drop-overlay-inner{padding:32px 28px;font-size:15px;border-radius:16px;margin:0 16px}
507
+ .example-card{flex-direction:column}
508
+ .example-thumb-wrap{width:100%;height:96px}
509
+ }
510
+
511
+ @media(max-width:400px){
512
+ .menubar-badge.fast{display:none}
513
+ .seg-btn{padding:4px 12px}
514
+ .canvas-stage{min-height:36vh}
515
+ }
516
+ </style>
517
+ </head>
518
+ <body>
519
+ <div class="studio">
520
+
521
+ <!-- ══ Menu bar ══ -->
522
+ <div class="menubar">
523
+ <div class="menubar-logo">
524
+ <svg viewBox="0 0 24 24" fill="white" xmlns="http://www.w3.org/2000/svg"><path d="M12 23c-3.6 0-8-2.69-8-7.5 0-3.5 3-6.5 4.5-8 .27-.27.75-.08.75.28v2.44c0 .42.5.63.72.28C12.28 7.5 13 3 13 1c0-.42.48-.64.8-.35C18 4.5 20 9 20 12c0 5.5-3.5 11-8 11z"/></svg>
525
+ </div>
526
+ <div class="menubar-title">Wan2.2 Studio <span>/ Fast I2V</span></div>
527
+ <span class="menubar-badge">14B</span>
528
+ <span class="menubar-badge fast">4-STEP FAST</span>
529
+ <div class="menubar-spacer"></div>
530
+ <div class="menubar-status"><span class="dot" id="conn-dot"></span><span id="conn-text">connecting…</span></div>
531
+ <a href="https://github.com/PRITHIVSAKTHIUR/wan2.2-i2v-fast"
532
+ target="_blank" rel="noopener" class="gh-btn">
533
+ <svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg>
534
+ <span>GitHub</span>
535
+ </a>
536
+ </div>
537
+
538
+ <!-- ══ Left icon rail ══ -->
539
+ <div class="rail">
540
+ <div class="rail-label">Input</div>
541
+ <button class="rail-btn" id="tb-upload" title="Upload image">
542
+ <svg viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg>
543
+ </button>
544
+ <button class="rail-btn" id="tb-remove" title="Remove image" disabled>
545
+ <svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>
546
+ </button>
547
+ <button class="rail-btn" id="tb-clear" title="Clear image" disabled>
548
+ <svg viewBox="0 0 24 24"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>
549
+ </button>
550
+ <div class="rail-sep"></div>
551
+ <div class="rail-label">Result</div>
552
+ <button class="rail-btn" id="compare-btn" title="Compare frames" disabled>
553
+ <svg viewBox="0 0 24 24"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="12" y1="3" x2="12" y2="21"/></svg>
554
+ </button>
555
+ <button class="rail-btn" id="use-as-input-btn" title="Use result frame as input" disabled>
556
+ <svg viewBox="0 0 24 24"><polyline points="17 1 21 5 17 9"/><path d="M3 11V9a4 4 0 014-4h14"/><polyline points="7 23 3 19 7 15"/><path d="M21 13v2a4 4 0 01-4 4H3"/></svg>
557
+ </button>
558
+ <button class="rail-btn" id="dl-btn-output" title="Download result video" disabled>
559
+ <svg viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
560
+ </button>
561
+ <button class="rail-btn" id="zoom-btn" title="Zoom result" disabled>
562
+ <svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/><line x1="11" y1="8" x2="11" y2="14"/><line x1="8" y1="11" x2="14" y2="11"/></svg>
563
+ </button>
564
+ </div>
565
+
566
+ <!-- ══ Workspace ══ -->
567
+ <div class="workspace">
568
+ <div class="canvas-head">
569
+ <div class="seg-control">
570
+ <button class="seg-btn active" id="seg-result">Result</button>
571
+ <button class="seg-btn" id="seg-input">Input</button>
572
+ </div>
573
+ <div class="canvas-meta" id="canvas-meta">No image loaded</div>
574
+ <div class="canvas-actions">
575
+ <span id="out-seed-chip" class="out-seed-chip" title="Click to copy seed"></span>
576
+ </div>
577
+ </div>
578
+
579
+ <div class="canvas-stage" id="output-image-container">
580
+ <div class="modern-loader" id="output-loader">
581
+ <div class="loader-spinner"></div>
582
+ <div class="loader-text" id="loader-text">Processing video&hellip;</div>
583
+ <div class="loader-bar-track"><div class="loader-bar-fill" id="loader-bar-fill"></div></div>
584
+ </div>
585
+
586
+ <div class="canvas-placeholder" id="output-placeholder">
587
+ <svg viewBox="0 0 80 80" fill="none" xmlns="http://www.w3.org/2000/svg">
588
+ <rect x="8" y="14" width="64" height="52" rx="6" fill="none" stroke="#2a2a3a" stroke-width="2" stroke-dasharray="4 3"/>
589
+ <polygon points="12,62 30,40 42,50 54,34 68,62" fill="rgba(0,0,139,0.1)" stroke="#2a2a3a" stroke-width="1.5"/>
590
+ <circle cx="28" cy="30" r="6" fill="rgba(0,0,139,0.12)" stroke="#2a2a3a" stroke-width="1.5"/>
591
+ </svg>
592
+ <div class="cp-title">Canvas is empty</div>
593
+ <div class="cp-sub">
594
+ Drop an image anywhere, paste with <kbd>⌘/Ctrl+V</kbd>, or use the rail to upload.
595
+ Then write an instruction and press <kbd>⌘/Ctrl</kbd>+<kbd>↵</kbd>.
596
+ </div>
597
+ </div>
598
+
599
+ <div class="compare-wrap" id="compare-wrap">
600
+ <img id="compare-after-img" alt="after">
601
+ <div class="compare-top" id="compare-top"><img id="compare-before-img" alt="before"></div>
602
+ <div class="compare-divider" id="compare-divider"><div class="compare-handle">⇄</div></div>
603
+ <span class="compare-label before">Original</span>
604
+ <span class="compare-label after">Upscaled</span>
605
+ </div>
606
+ </div>
607
+
608
+ <!-- Filmstrip -->
609
+ <div class="filmstrip">
610
+ <div class="filmstrip-section inputs">
611
+ <div class="filmstrip-label">Input <span class="count" id="tb-image-count">0</span></div>
612
+ <div class="filmstrip-row" id="image-gallery-grid"></div>
613
+ </div>
614
+ <div class="filmstrip-section history">
615
+ <div class="filmstrip-label">Upscaled Frames <span class="count" id="history-count">0</span></div>
616
+ <div class="filmstrip-row" id="history-strip"></div>
617
+ </div>
618
+ </div>
619
+ </div>
620
+
621
+ <!-- ══ Inspector ══ -->
622
+ <div class="inspector">
623
+ <div class="inspector-tabs">
624
+ <button class="insp-tab active" id="tab-edit">Edit</button>
625
+ <button class="insp-tab" id="tab-examples">Examples</button>
626
+ </div>
627
+
628
+ <!-- Edit page -->
629
+ <div class="insp-page active" id="page-edit">
630
+ <div class="insp-section">
631
+ <div class="insp-section-title"><span>Instruction</span><span class="char-count" id="char-count">0</span></div>
632
+ <textarea id="custom-prompt-input" class="modern-textarea" rows="3"
633
+ placeholder="e.g., make this image come alive, cinematic motion…"></textarea>
634
+ </div>
635
+
636
+ <div class="insp-section">
637
+ <div class="insp-section-title"><span>Quick Prompts</span></div>
638
+ <div class="suggestions-wrap" id="suggestions-wrap"></div>
639
+ </div>
640
+
641
+ <div class="insp-section">
642
+ <button id="custom-run-btn" class="btn-run">
643
+ <span id="run-btn-label">Generate Video</span>
644
+ </button>
645
+ <button id="custom-cancel-btn" class="btn-cancel" style="display:none;">Cancel</button>
646
+ <div class="run-hint">⌘/Ctrl + Enter</div>
647
+ </div>
648
+
649
+ <div class="insp-section">
650
+ <div class="insp-section-title"><span>Advanced</span></div>
651
+ <div class="slider-row">
652
+ <label>Seed</label>
653
+ <input type="range" id="custom-seed" min="0" max="2147483647" step="1" value="0">
654
+ <span class="slider-val" id="custom-seed-val">0</span>
655
+ <button class="dice-btn" id="dice-btn" title="Random seed">
656
+ <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM7.5 18c-.83 0-1.5-.67-1.5-1.5S6.67 15 7.5 15s1.5.67 1.5 1.5S8.33 18 7.5 18zm0-9C6.67 9 6 8.33 6 7.5S6.67 6 7.5 6 9 6.67 9 7.5 8.33 9 7.5 9zm4.5 4.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm4.5 4.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm0-9c-.83 0-1.5-.67-1.5-1.5S15.67 6 16.5 6s1.5.67 1.5 1.5S17.33 9 16.5 9z"/></svg>
657
+ </button>
658
+ </div>
659
+ <div class="checkbox-row">
660
+ <input type="checkbox" id="custom-randomize" checked>
661
+ <label for="custom-randomize">Randomize seed</label>
662
+ </div>
663
+ <div class="slider-row">
664
+ <label>Duration</label>
665
+ <input type="range" id="custom-duration" min="0.5" max="5.0" step="0.1" value="3.5">
666
+ <span class="slider-val" id="custom-duration-val">3.5s</span>
667
+ </div>
668
+ <div class="slider-row">
669
+ <label>Steps</label>
670
+ <input type="range" id="custom-steps" min="1" max="30" step="1" value="4">
671
+ <span class="slider-val" id="custom-steps-val">4</span>
672
+ </div>
673
+ <div class="slider-row">
674
+ <label>CFG 1</label>
675
+ <input type="range" id="custom-cfg1" min="0.0" max="10.0" step="0.5" value="1.0">
676
+ <span class="slider-val" id="custom-cfg1-val">1.0</span>
677
+ </div>
678
+ <div class="slider-row">
679
+ <label>CFG 2</label>
680
+ <input type="range" id="custom-cfg2" min="0.0" max="10.0" step="0.5" value="1.0">
681
+ <span class="slider-val" id="custom-cfg2-val">1.0</span>
682
+ </div>
683
+ </div>
684
+ </div>
685
+
686
+ <!-- Examples page -->
687
+ <div class="insp-page" id="page-examples">
688
+ <div class="examples-list" id="examples-scroll"></div>
689
+ </div>
690
+ </div>
691
+
692
+ <!-- ══ Status bar ══ -->
693
+ <div class="statusbar">
694
+ <div class="sb-section" id="sb-image-count">No input</div>
695
+ <div class="sb-right">
696
+ <a class="sb-link" href="https://huggingface.co/Wan-AI/Wan2.2-I2V-A14B-Diffusers" target="_blank" rel="noopener">Wan2.2-I2V-A14B</a>
697
+ <span class="sb-pill" id="sb-status">Ready</span>
698
+ </div>
699
+ </div>
700
+
701
+ </div>
702
+
703
+ <input id="custom-file-input" type="file" accept="image/*" style="display:none;" />
704
+
705
+ <!-- Lightbox -->
706
+ <div class="lightbox" id="lightbox"><img id="lightbox-img" alt="zoom"></div>
707
+
708
+ <!-- Global drop overlay -->
709
+ <div class="drop-overlay" id="drop-overlay"><div class="drop-overlay-inner">Drop image to upload</div></div>
710
+
711
+ <script type="module">
712
+ import { Client } from "https://cdn.jsdelivr.net/npm/@gradio/client/dist/index.min.js";
713
+
714
+ /* ── DOM refs ── */
715
+ const galleryGrid = document.getElementById('image-gallery-grid');
716
+ const fileInput = document.getElementById('custom-file-input');
717
+ const btnUpload = document.getElementById('tb-upload');
718
+ const btnRemove = document.getElementById('tb-remove');
719
+ const btnClear = document.getElementById('tb-clear');
720
+ const promptInput = document.getElementById('custom-prompt-input');
721
+ const charCount = document.getElementById('char-count');
722
+ const runBtn = document.getElementById('custom-run-btn');
723
+ const runBtnLabel = document.getElementById('run-btn-label');
724
+ const cancelBtn = document.getElementById('custom-cancel-btn');
725
+ const imgCountTb = document.getElementById('tb-image-count');
726
+ const imgCountSb = document.getElementById('sb-image-count');
727
+ const sbStatus = document.getElementById('sb-status');
728
+ const loader = document.getElementById('output-loader');
729
+ const loaderText = document.getElementById('loader-text');
730
+ const loaderFill = document.getElementById('loader-bar-fill');
731
+ const outBody = document.getElementById('output-image-container');
732
+ const outPh = document.getElementById('output-placeholder');
733
+ const dlBtn = document.getElementById('dl-btn-output');
734
+ const compareBtn = document.getElementById('compare-btn');
735
+ const useAsInputBtn= document.getElementById('use-as-input-btn');
736
+ const zoomBtn = document.getElementById('zoom-btn');
737
+ const seedChip = document.getElementById('out-seed-chip');
738
+ const historyStrip = document.getElementById('history-strip');
739
+ const historyCount = document.getElementById('history-count');
740
+ const seedSlider = document.getElementById('custom-seed');
741
+ const seedVal = document.getElementById('custom-seed-val');
742
+ const durationSlider = document.getElementById('custom-duration');
743
+ const durationVal = document.getElementById('custom-duration-val');
744
+ const stepsSlider = document.getElementById('custom-steps');
745
+ const stepsVal = document.getElementById('custom-steps-val');
746
+ const cfg1Slider = document.getElementById('custom-cfg1');
747
+ const cfg1Val = document.getElementById('custom-cfg1-val');
748
+ const cfg2Slider = document.getElementById('custom-cfg2');
749
+ const cfg2Val = document.getElementById('custom-cfg2-val');
750
+ const lightbox = document.getElementById('lightbox');
751
+ const lightboxImg = document.getElementById('lightbox-img');
752
+ const dropOverlay = document.getElementById('drop-overlay');
753
+ const compareWrap = document.getElementById('compare-wrap');
754
+ const compareTop = document.getElementById('compare-top');
755
+ const compareDivider = document.getElementById('compare-divider');
756
+ const compareBeforeImg = document.getElementById('compare-before-img');
757
+ const compareAfterImg = document.getElementById('compare-after-img');
758
+ const canvasMeta = document.getElementById('canvas-meta');
759
+ const segResult = document.getElementById('seg-result');
760
+ const segInput = document.getElementById('seg-input');
761
+ const connDot = document.getElementById('conn-dot');
762
+ const connText = document.getElementById('conn-text');
763
+
764
+ /* ── State ── */
765
+ let currentImage = null; // {b64, name}
766
+ let toastTimer = null;
767
+ let running = false;
768
+ let currentJob = null;
769
+ let currentResult = null; // {video, seed, prompt, frames: [{orig, upscaled}]}
770
+ let historyIdx = -1;
771
+ let compareMode = false;
772
+ let viewMode = 'result'; // 'result' | 'input'
773
+
774
+ const SUGGESTIONS = [
775
+ ['Cinematic', 'make this image come alive, cinematic motion, smooth animation.'],
776
+ ['Selfie Cat', 'POV selfie video, white cat with sunglasses standing on surfboard, relaxed smile, tropical beach behind.'],
777
+ ['Lunar', 'A sleek lunar vehicle glides into view from left to right, kicking up moon dust.'],
778
+ ['Melting Sword', 'Uma Thurman holds her katana blade steady. Suddenly, the polished steel begins to soften and distort.'],
779
+ ];
780
+
781
+ /* ── Toast ── */
782
+ function showToast(message, type) {
783
+ let toast = document.getElementById('app-toast');
784
+ if (!toast) {
785
+ toast = document.createElement('div');
786
+ toast.id = 'app-toast';
787
+ toast.className = 'toast-notification';
788
+ toast.innerHTML = '<span class="toast-icon"></span><span class="toast-text"></span>';
789
+ document.body.appendChild(toast);
790
+ }
791
+ const icon = toast.querySelector('.toast-icon');
792
+ const text = toast.querySelector('.toast-text');
793
+ toast.className = 'toast-notification ' + (type || 'error');
794
+ icon.textContent = type === 'warning' ? '⚠' : type === 'info' ? 'ℹ' : '✗';
795
+ text.textContent = message;
796
+ if (toastTimer) clearTimeout(toastTimer);
797
+ void toast.offsetWidth;
798
+ toast.classList.add('visible');
799
+ toastTimer = setTimeout(() => toast.classList.remove('visible'), 3500);
800
+ }
801
+
802
+ function flashPromptError() {
803
+ promptInput.classList.add('error-flash');
804
+ promptInput.focus();
805
+ setTimeout(() => promptInput.classList.remove('error-flash'), 800);
806
+ }
807
+
808
+ function setStatus(text, cls) {
809
+ sbStatus.textContent = text;
810
+ sbStatus.className = 'sb-pill' + (cls ? ' ' + cls : '');
811
+ }
812
+
813
+ /* ── View mode ── */
814
+ function setViewMode(mode) {
815
+ viewMode = mode;
816
+ segResult.classList.toggle('active', mode === 'result');
817
+ segInput.classList.toggle('active', mode === 'input');
818
+ renderCanvas();
819
+ }
820
+ segResult.addEventListener('click', () => setViewMode('result'));
821
+ segInput.addEventListener('click', () => setViewMode('input'));
822
+
823
+ let canvasMedia = null; // Can be <video> or <img>
824
+
825
+ function renderCanvas() {
826
+ exitCompareMode();
827
+ outBody.querySelectorAll('video.modern-out-vid, img.modern-out-img').forEach(e => e.remove());
828
+
829
+ const showResult = viewMode === 'result' && currentResult;
830
+ const showInput = viewMode === 'input' && currentImage;
831
+
832
+ if (showResult || showInput) {
833
+ outPh.style.display = 'none';
834
+
835
+ if (showResult) {
836
+ if (historyIdx >= 0 && currentResult.frames[historyIdx]) {
837
+ // Show compare slider
838
+ enterCompareMode();
839
+ canvasMeta.textContent = 'frame #' + (historyIdx + 1) + ' · seed ' + currentResult.seed;
840
+ } else {
841
+ // Show video
842
+ const vid = document.createElement('video');
843
+ vid.src = currentResult.video;
844
+ vid.className = 'modern-out-vid';
845
+ vid.controls = true;
846
+ vid.autoplay = true;
847
+ vid.loop = true;
848
+ vid.muted = true;
849
+ outBody.appendChild(vid);
850
+ canvasMeta.textContent = 'video · seed ' + currentResult.seed;
851
+ }
852
+ } else {
853
+ // Show input image
854
+ const img = document.createElement('img');
855
+ img.src = currentImage.b64;
856
+ img.className = 'modern-out-img';
857
+ img.addEventListener('click', () => {
858
+ lightboxImg.src = img.src; lightbox.classList.add('visible');
859
+ });
860
+ outBody.appendChild(img);
861
+ canvasMeta.textContent = 'input · ' + (currentImage.name || 'image');
862
+ }
863
+ } else {
864
+ outPh.style.display = '';
865
+ canvasMeta.textContent = currentImage
866
+ ? 'input ready — run an edit'
867
+ : 'No image loaded';
868
+ }
869
+ updateRailState();
870
+ }
871
+
872
+ function updateRailState() {
873
+ const hasResult = !!currentResult;
874
+ dlBtn.disabled = !hasResult;
875
+ zoomBtn.disabled = !hasResult && !currentImage;
876
+ useAsInputBtn.disabled = !(hasResult && historyIdx >= 0);
877
+ compareBtn.disabled = !(hasResult && historyIdx >= 0);
878
+ btnRemove.disabled = !currentImage;
879
+ btnClear.disabled = !currentImage;
880
+ }
881
+
882
+ /* ── Inputs filmstrip ── */
883
+ function updateCounts() {
884
+ const n = currentImage ? 1 : 0;
885
+ imgCountTb.textContent = n;
886
+ const hCount = currentResult ? currentResult.frames.length : 0;
887
+ imgCountSb.textContent = n > 0 ? '1 input · ' + hCount + ' frames' : 'No input';
888
+ }
889
+
890
+ function setImage(b64, name) {
891
+ currentImage = { b64, name: name || 'image' };
892
+ renderFilmstrip();
893
+ updateCounts();
894
+ if (!currentResult || viewMode === 'input') renderCanvas();
895
+ else setViewMode('input');
896
+ }
897
+
898
+ function removeImage() {
899
+ currentImage = null;
900
+ renderFilmstrip();
901
+ updateCounts();
902
+ renderCanvas();
903
+ }
904
+
905
+ function clearAll() {
906
+ currentImage = null;
907
+ renderFilmstrip();
908
+ updateCounts();
909
+ renderCanvas();
910
+ }
911
+
912
+ function renderFilmstrip() {
913
+ galleryGrid.innerHTML = '';
914
+ if (!currentImage) {
915
+ const empty = document.createElement('div');
916
+ empty.className = 'fs-empty';
917
+ empty.textContent = 'Drop or paste an image…';
918
+ galleryGrid.appendChild(empty);
919
+ } else {
920
+ const t = document.createElement('div');
921
+ t.className = 'fs-thumb selected';
922
+ t.innerHTML = '<img src="' + currentImage.b64 + '" alt="">' +
923
+ '<span class="fs-badge">input</span>' +
924
+ '<button class="fs-remove">✕</button>';
925
+ t.addEventListener('click', (e) => {
926
+ if (e.target.closest('.fs-remove')) return;
927
+ historyIdx = -1; // Reset frame selection
928
+ renderHistory();
929
+ setViewMode('input');
930
+ });
931
+ t.querySelector('.fs-remove').addEventListener('click', (e) => {
932
+ e.stopPropagation(); removeImage();
933
+ });
934
+ galleryGrid.appendChild(t);
935
+ }
936
+ const add = document.createElement('div');
937
+ add.className = 'fs-add';
938
+ add.innerHTML = '<span class="add-icon">+</span><span class="add-text">' + (currentImage ? 'Replace' : 'Add') + '</span>';
939
+ add.addEventListener('click', () => fileInput.click());
940
+ galleryGrid.appendChild(add);
941
+ updateRailState();
942
+ }
943
+
944
+ function processFiles(files) {
945
+ const file = files && files[0];
946
+ if (!file || !file.type.startsWith('image/')) return 0;
947
+ const reader = new FileReader();
948
+ reader.onload = (e) => setImage(e.target.result, file.name);
949
+ reader.readAsDataURL(file);
950
+ return 1;
951
+ }
952
+
953
+ fileInput.addEventListener('change', (e) => { processFiles(e.target.files); e.target.value = ''; });
954
+ btnUpload.addEventListener('click', () => fileInput.click());
955
+ btnRemove.addEventListener('click', removeImage);
956
+ btnClear.addEventListener('click', clearAll);
957
+
958
+ /* ── Drop anywhere ── */
959
+ let dragDepth = 0;
960
+ window.addEventListener('dragenter', (e) => {
961
+ if (!e.dataTransfer || !Array.from(e.dataTransfer.types).includes('Files')) return;
962
+ e.preventDefault();
963
+ dragDepth++;
964
+ dropOverlay.classList.add('visible');
965
+ });
966
+ window.addEventListener('dragleave', (e) => {
967
+ if (!e.dataTransfer || !Array.from(e.dataTransfer.types).includes('Files')) return;
968
+ dragDepth = Math.max(0, dragDepth - 1);
969
+ if (dragDepth === 0) dropOverlay.classList.remove('visible');
970
+ });
971
+ window.addEventListener('dragover', (e) => { e.preventDefault(); });
972
+ window.addEventListener('drop', (e) => {
973
+ e.preventDefault();
974
+ dragDepth = 0;
975
+ dropOverlay.classList.remove('visible');
976
+ if (e.dataTransfer.files.length) {
977
+ const n = processFiles(e.dataTransfer.files);
978
+ if (n > 0) showToast('Image loaded', 'info');
979
+ }
980
+ });
981
+
982
+ /* ── Paste ── */
983
+ document.addEventListener('paste', (e) => {
984
+ if (e.target === promptInput) return;
985
+ const items = e.clipboardData && e.clipboardData.items;
986
+ if (!items) return;
987
+ for (const item of items) {
988
+ if (item.kind === 'file' && item.type.startsWith('image/')) {
989
+ const f = item.getAsFile();
990
+ if (f) {
991
+ e.preventDefault();
992
+ processFiles([f]);
993
+ showToast('Pasted image', 'info');
994
+ return;
995
+ }
996
+ }
997
+ }
998
+ });
999
+
1000
+ /* ── Inspector tabs ── */
1001
+ const tabEdit = document.getElementById('tab-edit');
1002
+ const tabExamples = document.getElementById('tab-examples');
1003
+ const pageEdit = document.getElementById('page-edit');
1004
+ const pageExamples = document.getElementById('page-examples');
1005
+ tabEdit.addEventListener('click', () => {
1006
+ tabEdit.classList.add('active'); tabExamples.classList.remove('active');
1007
+ pageEdit.classList.add('active'); pageExamples.classList.remove('active');
1008
+ });
1009
+ tabExamples.addEventListener('click', () => {
1010
+ tabExamples.classList.add('active'); tabEdit.classList.remove('active');
1011
+ pageExamples.classList.add('active'); pageEdit.classList.remove('active');
1012
+ });
1013
+
1014
+ /* ── Suggestion chips ── */
1015
+ const suggWrap = document.getElementById('suggestions-wrap');
1016
+ SUGGESTIONS.forEach(([label, prompt]) => {
1017
+ const chip = document.createElement('button');
1018
+ chip.className = 'suggestion-chip';
1019
+ chip.textContent = label;
1020
+ chip.addEventListener('click', () => {
1021
+ promptInput.value = prompt;
1022
+ updateCharCount();
1023
+ suggWrap.querySelectorAll('.suggestion-chip').forEach(c => c.classList.remove('active'));
1024
+ chip.classList.add('active');
1025
+ promptInput.focus();
1026
+ });
1027
+ suggWrap.appendChild(chip);
1028
+ });
1029
+
1030
+ function updateCharCount() { charCount.textContent = promptInput.value.length; }
1031
+ promptInput.addEventListener('input', () => {
1032
+ updateCharCount();
1033
+ suggWrap.querySelectorAll('.suggestion-chip').forEach(c => c.classList.remove('active'));
1034
+ });
1035
+ updateCharCount();
1036
+
1037
+ /* ── Sliders ── */
1038
+ function bindSlider(id, suffix='') {
1039
+ const slider = document.getElementById(id);
1040
+ const valSpan = document.getElementById(id + '-val');
1041
+ slider.addEventListener('input', () => { valSpan.textContent = slider.value + suffix; });
1042
+ }
1043
+ bindSlider('custom-seed');
1044
+ bindSlider('custom-duration', 's');
1045
+ bindSlider('custom-steps');
1046
+ bindSlider('custom-cfg1');
1047
+ bindSlider('custom-cfg2');
1048
+
1049
+ document.getElementById('dice-btn').addEventListener('click', () => {
1050
+ const s = Math.floor(Math.random() * 2147483647);
1051
+ seedSlider.value = s; seedVal.textContent = s;
1052
+ });
1053
+
1054
+ /* ── Loader ── */
1055
+ function showLoader(text) {
1056
+ loaderText.textContent = text || 'Processing video…';
1057
+ loaderFill.classList.remove('determinate');
1058
+ loaderFill.style.width = '100%';
1059
+ loader.classList.add('active');
1060
+ setStatus('Processing…');
1061
+ }
1062
+ function setLoaderProgress(text, frac) {
1063
+ loaderText.textContent = text;
1064
+ if (frac != null && frac >= 0 && frac <= 1) {
1065
+ loaderFill.classList.add('determinate');
1066
+ loaderFill.style.width = Math.max(4, Math.round(frac * 100)) + '%';
1067
+ }
1068
+ }
1069
+ function hideLoader(statusText, cls) {
1070
+ loader.classList.remove('active');
1071
+ setStatus(statusText || 'Done', cls || 'done');
1072
+ }
1073
+
1074
+ /* ── Result / history ── */
1075
+ function renderHistory() {
1076
+ historyStrip.innerHTML = '';
1077
+ if (!currentResult || currentResult.frames.length === 0) {
1078
+ const empty = document.createElement('div');
1079
+ empty.className = 'fs-empty';
1080
+ empty.textContent = 'No frames yet';
1081
+ historyStrip.appendChild(empty);
1082
+ historyCount.textContent = 0;
1083
+ return;
1084
+ }
1085
+ historyCount.textContent = currentResult.frames.length;
1086
+ currentResult.frames.forEach((entry, i) => {
1087
+ const t = document.createElement('div');
1088
+ t.className = 'fs-thumb' + (i === historyIdx ? ' selected' : '');
1089
+ t.title = 'Frame ' + (i + 1);
1090
+ const im = document.createElement('img');
1091
+ im.src = entry.upscaled;
1092
+ t.appendChild(im);
1093
+ t.addEventListener('click', () => {
1094
+ historyIdx = i;
1095
+ renderHistory();
1096
+ setViewMode('result');
1097
+ });
1098
+ historyStrip.appendChild(t);
1099
+ });
1100
+ }
1101
+
1102
+ /* ── Compare slider ── */
1103
+ function enterCompareMode() {
1104
+ if (!currentResult || historyIdx < 0) return;
1105
+ const frame = currentResult.frames[historyIdx];
1106
+ if (!frame) return;
1107
+
1108
+ compareMode = true;
1109
+ compareBtn.classList.add('active');
1110
+
1111
+ // Remove video if present
1112
+ outBody.querySelectorAll('video.modern-out-vid').forEach(e => e.remove());
1113
+
1114
+ compareAfterImg.src = frame.upscaled;
1115
+ compareBeforeImg.src = frame.orig;
1116
+ compareWrap.classList.add('visible');
1117
+ requestAnimationFrame(() => setComparePos(0.5));
1118
+ }
1119
+ function exitCompareMode() {
1120
+ if (!compareMode) return;
1121
+ compareMode = false;
1122
+ compareBtn.classList.remove('active');
1123
+ compareWrap.classList.remove('visible');
1124
+ }
1125
+ function setComparePos(frac) {
1126
+ frac = Math.max(0, Math.min(1, frac));
1127
+ const w = compareWrap.clientWidth;
1128
+ const x = frac * w;
1129
+ compareTop.style.clipPath = 'inset(0 ' + (w - x) + 'px 0 0)';
1130
+ compareDivider.style.left = x + 'px';
1131
+ }
1132
+ compareBtn.addEventListener('click', () => {
1133
+ if (historyIdx < 0) return;
1134
+ compareMode ? exitCompareMode() : enterCompareMode();
1135
+ renderCanvas(); // Refresh canvas state
1136
+ });
1137
+
1138
+ let compareDragging = false;
1139
+ function compareMove(clientX) {
1140
+ const rect = compareWrap.getBoundingClientRect();
1141
+ setComparePos((clientX - rect.left) / rect.width);
1142
+ }
1143
+ compareWrap.addEventListener('pointerdown', (e) => {
1144
+ compareDragging = true;
1145
+ compareWrap.setPointerCapture(e.pointerId);
1146
+ compareMove(e.clientX);
1147
+ });
1148
+ compareWrap.addEventListener('pointermove', (e) => { if (compareDragging) compareMove(e.clientX); });
1149
+ compareWrap.addEventListener('pointerup', () => { compareDragging = false; });
1150
+ compareWrap.addEventListener('pointercancel', () => { compareDragging = false; });
1151
+
1152
+ /* ── Lightbox ── */
1153
+ lightbox.addEventListener('click', () => lightbox.classList.remove('visible'));
1154
+ document.addEventListener('keydown', (e) => { if (e.key === 'Escape') lightbox.classList.remove('visible'); });
1155
+ zoomBtn.addEventListener('click', () => {
1156
+ const src = (viewMode === 'result' && historyIdx >= 0 && currentResult) ? currentResult.frames[historyIdx].upscaled
1157
+ : (currentImage ? currentImage.b64 : null);
1158
+ if (src) { lightboxImg.src = src; lightbox.classList.add('visible'); }
1159
+ });
1160
+
1161
+ /* ── Download / chain / seed ── */
1162
+ dlBtn.addEventListener('click', () => {
1163
+ if (currentResult && currentResult.video) {
1164
+ const a = document.createElement('a');
1165
+ a.href = currentResult.video;
1166
+ a.download = 'wan22_' + (currentResult.seed != null ? currentResult.seed : 'output') + '.mp4';
1167
+ document.body.appendChild(a); a.click(); document.body.removeChild(a);
1168
+ }
1169
+ });
1170
+ useAsInputBtn.addEventListener('click', () => {
1171
+ if (!currentResult || historyIdx < 0) return;
1172
+ const frame = currentResult.frames[historyIdx];
1173
+ setImage(frame.upscaled, 'frame_' + (historyIdx + 1) + '.png');
1174
+ showToast('Upscaled frame set as input image', 'info');
1175
+ });
1176
+ seedChip.addEventListener('click', () => {
1177
+ if (currentResult && currentResult.seed != null) {
1178
+ navigator.clipboard.writeText(String(currentResult.seed)).then(
1179
+ () => showToast('Seed copied: ' + currentResult.seed, 'info'), () => {});
1180
+ }
1181
+ });
1182
+
1183
+ /* ── Backend connection ── */
1184
+ let client = null;
1185
+ try {
1186
+ client = await Client.connect(window.location.origin);
1187
+ setStatus('Ready');
1188
+ connDot.classList.remove('off');
1189
+ connText.textContent = 'connected';
1190
+ } catch (e) {
1191
+ console.error('Failed to connect to Gradio backend:', e);
1192
+ setStatus('Offline', 'error');
1193
+ connDot.classList.add('off');
1194
+ connText.textContent = 'offline';
1195
+ showToast('Could not connect to the backend API', 'error');
1196
+ }
1197
+
1198
+ /* ── Config: examples ── */
1199
+ function renderConfig(cfg) {
1200
+ const list = document.getElementById('examples-scroll');
1201
+ list.innerHTML = '';
1202
+ cfg.examples.forEach(ex => {
1203
+ const card = document.createElement('div');
1204
+ card.className = 'example-card';
1205
+ const thumbHtml = ex.thumb
1206
+ ? '<img src="' + ex.thumb + '" alt="">'
1207
+ : '<div class="example-thumb-placeholder">Preview</div>';
1208
+ const promptShort = ex.prompt.length > 90 ? ex.prompt.slice(0, 90) + '…' : ex.prompt;
1209
+ card.innerHTML =
1210
+ '<div class="example-thumb-wrap">' + thumbHtml + '</div>'
1211
+ + '<div class="example-body">'
1212
+ + '<div class="example-meta"><span class="example-lora-badge">' + ex.steps + ' steps</span></div>'
1213
+ + '<div class="example-prompt-text"></div>'
1214
+ + '</div>';
1215
+ card.querySelector('.example-prompt-text').textContent = promptShort;
1216
+ card.addEventListener('click', () => loadExample(card, ex.idx));
1217
+ list.appendChild(card);
1218
+ });
1219
+ }
1220
+
1221
+ async function loadExample(card, idx) {
1222
+ if (!client) { showToast('Backend not connected', 'error'); return; }
1223
+ document.querySelectorAll('.example-card.loading').forEach(c => c.classList.remove('loading'));
1224
+ card.classList.add('loading');
1225
+ showToast('Loading example…', 'info');
1226
+ try {
1227
+ const result = await client.predict('/load_example', { idx: idx });
1228
+ const data = result.data[0];
1229
+ if (data && data.status === 'ok' && data.image) {
1230
+ if (data.prompt) { promptInput.value = data.prompt; updateCharCount(); }
1231
+ if (data.steps) {
1232
+ stepsSlider.value = data.steps;
1233
+ stepsVal.textContent = data.steps;
1234
+ }
1235
+ setImage(data.image, data.name || 'example.jpg');
1236
+ tabEdit.click();
1237
+ showToast('Example loaded', 'info');
1238
+ } else {
1239
+ showToast('Could not load example image', 'error');
1240
+ }
1241
+ } catch (e) {
1242
+ console.error('Example load error:', e);
1243
+ showToast('Could not load example image', 'error');
1244
+ } finally {
1245
+ card.classList.remove('loading');
1246
+ }
1247
+ }
1248
+
1249
+ try {
1250
+ const cfg = await fetch('api/config').then(r => r.json());
1251
+ renderConfig(cfg);
1252
+ } catch (e) {
1253
+ console.error('Failed to load config:', e);
1254
+ }
1255
+
1256
+ /* ── Run ── */
1257
+ function validateBeforeRun() {
1258
+ const promptVal = promptInput.value.trim();
1259
+ const hasImage = !!currentImage;
1260
+ if (!hasImage && !promptVal) { showToast('Please upload an image and enter a prompt', 'error'); flashPromptError(); return false; }
1261
+ if (!hasImage) { showToast('Please upload an image', 'error'); return false; }
1262
+ if (!promptVal) { showToast('Please enter a prompt', 'warning'); flashPromptError(); return false; }
1263
+ return true;
1264
+ }
1265
+
1266
+ function setRunningUI(on) {
1267
+ running = on;
1268
+ runBtn.disabled = on;
1269
+ runBtnLabel.textContent = on ? 'Generating…' : 'Generate Video';
1270
+ cancelBtn.style.display = on ? 'flex' : 'none';
1271
+ }
1272
+
1273
+ async function runEdit() {
1274
+ if (running) return;
1275
+ if (!client) { showToast('Backend not connected', 'error'); return; }
1276
+ if (!validateBeforeRun()) return;
1277
+
1278
+ setRunningUI(true);
1279
+ historyIdx = -1; // Reset frame selection
1280
+ setViewMode('result');
1281
+ showLoader('Submitting to queue…');
1282
+
1283
+ const usedPrompt = promptInput.value;
1284
+
1285
+ const payload = {
1286
+ image_b64: currentImage ? currentImage.b64 : '',
1287
+ prompt: usedPrompt,
1288
+ steps: parseInt(stepsSlider.value) || 4,
1289
+ negative_prompt: "色调艳丽, 过曝, 静态, 细节模糊不清, 字幕, 风格, 作品, 画作, 画面, 静止, 整体发灰, 最差质量, 低质量, JPEG压缩残留, 丑陋的, 残缺的, 多余的手指, 画得不好的手部, 画得不好的脸部, 畸形的, 毁容的, 形态畸形的肢体, 手指融合, 静止不动的画面, 杂乱的背景, 三条腿, 背景人很多, 倒着走",
1290
+ duration_seconds: parseFloat(durationSlider.value) || 3.5,
1291
+ guidance_scale: parseFloat(cfg1Slider.value) || 1.0,
1292
+ guidance_scale_2: parseFloat(cfg2Slider.value) || 1.0,
1293
+ seed: parseInt(seedSlider.value) || 0,
1294
+ randomize_seed: document.getElementById('custom-randomize').checked,
1295
+ };
1296
+
1297
+ try {
1298
+ currentJob = client.submit('/generate_video', payload);
1299
+ for await (const msg of currentJob) {
1300
+ if (msg.type === 'status') {
1301
+ if (msg.status === 'pending') {
1302
+ const pos = (msg.position != null && msg.position >= 0)
1303
+ ? 'In queue — position ' + (msg.position + 1) + (msg.queue_size ? ' of ' + msg.queue_size : '')
1304
+ : 'Waiting in queue…';
1305
+ setLoaderProgress(pos, null);
1306
+ setStatus('Queued');
1307
+ } else if (msg.status === 'generating') {
1308
+ setStatus('Processing…');
1309
+ const pd = msg.progress_data;
1310
+ if (pd && pd.length > 0) {
1311
+ const p = pd[pd.length - 1];
1312
+ if (p.index != null && p.length) {
1313
+ const pct = Math.round((p.index / p.length) * 100);
1314
+ setLoaderProgress('Generating video… ' + p.index + '/' + p.length + ' (' + pct + '%)', p.index / p.length);
1315
+ } else {
1316
+ setLoaderProgress('Generating…', null);
1317
+ }
1318
+ } else {
1319
+ setLoaderProgress('Generating video…', null);
1320
+ }
1321
+ } else if (msg.status === 'error') {
1322
+ throw new Error(msg.message || 'Generation failed');
1323
+ }
1324
+ } else if (msg.type === 'data') {
1325
+ const out = msg.data && msg.data[0];
1326
+ if (out && out.video) {
1327
+ currentResult = out;
1328
+ renderHistory();
1329
+ if (out.seed != null) {
1330
+ seedSlider.value = out.seed;
1331
+ seedVal.textContent = out.seed;
1332
+ seedChip.textContent = 'seed ' + out.seed;
1333
+ seedChip.classList.add('visible');
1334
+ }
1335
+ hideLoader('Done', 'done');
1336
+ showToast('Video generated successfully', 'info');
1337
+ renderCanvas();
1338
+ } else {
1339
+ hideLoader('Done', 'done');
1340
+ }
1341
+ }
1342
+ }
1343
+ } catch (e) {
1344
+ console.error('Edit error:', e);
1345
+ hideLoader('Error', 'error');
1346
+ const msg = (e && e.message) ? e.message : 'Generation failed';
1347
+ showToast(msg.length > 120 ? msg.slice(0, 120) + '…' : msg, 'error');
1348
+ } finally {
1349
+ setRunningUI(false);
1350
+ currentJob = null;
1351
+ }
1352
+ }
1353
+
1354
+ runBtn.addEventListener('click', runEdit);
1355
+
1356
+ cancelBtn.addEventListener('click', async () => {
1357
+ if (currentJob) {
1358
+ try { await currentJob.cancel(); } catch (e) { console.warn('Cancel error:', e); }
1359
+ currentJob = null;
1360
+ }
1361
+ setRunningUI(false);
1362
+ hideLoader('Cancelled');
1363
+ showToast('Generation cancelled', 'warning');
1364
+ });
1365
+
1366
+ document.addEventListener('keydown', (e) => {
1367
+ if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') {
1368
+ e.preventDefault();
1369
+ runEdit();
1370
+ }
1371
+ });
1372
+
1373
+ renderFilmstrip();
1374
+ renderHistory();
1375
+ updateCounts();
1376
+ renderCanvas();
1377
+ </script>
1378
+ </body>
1379
+ </html>