File size: 15,346 Bytes
c48c3d4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91332db
 
3c3a731
 
 
 
 
 
 
 
91332db
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3c3a731
 
 
 
 
 
 
 
 
 
 
 
 
91332db
 
 
 
 
 
 
 
 
 
 
 
 
 
3c3a731
c48c3d4
 
 
91332db
 
3c3a731
91332db
 
3c3a731
 
91332db
 
 
3c3a731
 
 
91332db
 
 
3c3a731
91332db
3c3a731
 
 
 
c48c3d4
 
 
91332db
7e1ea6f
91332db
3c3a731
 
91332db
 
 
3c3a731
 
 
 
 
91332db
 
3c3a731
91332db
3c3a731
91332db
 
3c3a731
 
c48c3d4
 
 
 
 
 
 
 
 
 
 
91332db
c48c3d4
 
91332db
 
7e1ea6f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91332db
 
c48c3d4
 
 
 
 
 
 
3c3a731
 
 
 
 
 
91332db
 
 
 
 
 
 
 
 
 
c48c3d4
 
91332db
 
 
 
 
 
 
7e1ea6f
 
91332db
 
 
 
 
 
7e1ea6f
 
 
 
 
 
 
 
 
 
 
 
 
3c3a731
 
91332db
 
7e1ea6f
91332db
7e1ea6f
91332db
 
 
 
 
 
 
 
7e1ea6f
91332db
 
7e1ea6f
 
91332db
 
 
7e1ea6f
91332db
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7e1ea6f
91332db
 
 
 
7e1ea6f
 
91332db
 
 
 
 
 
 
 
 
7e1ea6f
91332db
 
 
3c3a731
 
 
 
 
 
91332db
 
7e1ea6f
3c3a731
eb62174
 
 
 
 
 
 
 
 
 
 
 
 
7e1ea6f
3c3a731
eb62174
 
 
3c3a731
91332db
 
 
3c3a731
 
91332db
 
3c3a731
 
 
91332db
7e1ea6f
91332db
3c3a731
 
 
 
c48c3d4
3c3a731
 
 
91332db
 
 
3c3a731
 
91332db
 
 
 
3c3a731
c48c3d4
91332db
 
3c3a731
 
 
 
 
 
91332db
 
3c3a731
 
c48c3d4
91332db
 
 
 
3c3a731
c48c3d4
3c3a731
eb62174
 
91332db
 
 
 
3c3a731
 
eb62174
3c3a731
91332db
3c3a731
 
eb62174
3c3a731
 
91332db
3c3a731
 
 
c48c3d4
3c3a731
 
 
 
 
 
c48c3d4
3c3a731
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91332db
 
 
 
 
 
 
 
 
 
 
 
 
3c3a731
 
91332db
3c3a731
 
 
 
 
 
 
 
 
 
 
91332db
 
c48c3d4
3c3a731
 
 
91332db
 
3c3a731
91332db
3c3a731
 
 
 
 
c48c3d4
 
3c3a731
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
<!DOCTYPE html>
<html lang="ko">
<head>
  <meta charset="UTF-8">
  <title>Hugging Face URL ์นด๋“œ ๋ฆฌ์ŠคํŠธ</title>
  <style>
    /* ์นด๋“œ๋“ค์„ ๋‹ด์„ ์ปจํ…Œ์ด๋„ˆ */
    .container {
      display: flex;
      flex-wrap: wrap;
      gap: 1rem;
      padding: 1rem;
    }
    /* ๊ฐ ์นด๋“œ ์Šคํƒ€์ผ */
    .card {
      border: 1px solid #ccc;
      border-radius: 5px;
      padding: 1rem;
      width: 300px;
      box-shadow: 2px 2px 8px rgba(0,0,0,0.1);
      position: relative;
      background-color: #f9f9f9;
    }
    /* ์นด๋“œ ๋‚ด๋ถ€ ๋งํฌ ์Šคํƒ€์ผ */
    .card a {
      text-decoration: none;
      color: #333;
      word-break: break-all;
    }
    /* ์ข‹์•„์š” ๋ฒ„ํŠผ ๊ธฐ๋ณธ ์Šคํƒ€์ผ */
    .like-button {
      position: absolute;
      top: 1rem;
      right: 1rem;
      border: none;
      background: transparent;
      font-size: 1.5rem;
      cursor: pointer;
      transition: color 0.2s;
    }
    /* ์ข‹์•„์š” ํ•œ ์ƒํƒœ: ๋นจ๊ฐ„์ƒ‰ */
    .like-button.liked {
      color: red;
    }
    /* ์ข‹์•„์š” ์•ˆํ•œ ์ƒํƒœ: ํฐ์ƒ‰ (ํ…Œ๋‘๋ฆฌ ํšจ๊ณผ) */
    .like-button.not-liked {
      color: white;
      -webkit-text-stroke: 1px #333;
    }
    /* ํ† ํฐ ์ž…๋ ฅ ๋ฐ ์ƒํƒœ ํ‘œ์‹œ ์˜์—ญ */
    .auth-controls {
      padding: 1rem;
      margin-bottom: 1rem;
      background-color: #f0f0f0;
      border-radius: 5px;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    .auth-controls input {
      padding: 0.5rem;
      width: 300px;
      border: 1px solid #ccc;
      border-radius: 4px;
    }
    .auth-controls button {
      padding: 0.5rem 1rem;
      margin-left: 0.5rem;
      background-color: #4CAF50;
      color: white;
      border: none;
      border-radius: 4px;
      cursor: pointer;
    }
    .auth-controls button:hover {
      background-color: #45a049;
    }
    /* ๋กœ๋”ฉ ํ‘œ์‹œ */
    .loading {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-color: rgba(255, 255, 255, 0.7);
      display: flex;
      justify-content: center;
      align-items: center;
      z-index: 1000;
      font-size: 1.5rem;
    }
    /* ์ƒํƒœ ๋ฉ”์‹œ์ง€ */
    .status-message {
      margin: 1rem;
      padding: 1rem;
      border-radius: 4px;
    }
    .success {
      background-color: #dff0d8;
      color: #3c763d;
    }
    .error {
      background-color: #f2dede;
      color: #a94442;
    }
  </style>
</head>
<body>
  <!-- ํ† ํฐ ์ž…๋ ฅ ๋ฐ ์ธ์ฆ ์ปจํŠธ๋กค -->
  <div class="auth-controls" id="authControls">
    <div>
      <span>Hugging Face ์ธ์ฆ: </span>
      <span id="authStatus">์ธ์ฆ๋˜์ง€ ์•Š์Œ</span>
    </div>
    <div>
      <input type="password" id="tokenInput" placeholder="Hugging Face API ํ† ํฐ ์ž…๋ ฅ" />
      <button id="authButton">์ธ์ฆํ•˜๊ธฐ</button>
      <button id="logoutButton" style="display: none; background-color: #f44336;">๋กœ๊ทธ์•„์›ƒ</button>
    </div>
  </div>
  
  <!-- ์ƒํƒœ ๋ฉ”์‹œ์ง€ -->
  <div id="statusMessage" class="status-message" style="display: none;"></div>
  
  <!-- ๋กœ๋”ฉ ํ‘œ์‹œ -->
  <div class="loading" id="loadingIndicator" style="display: none;">
    ๋ฐ์ดํ„ฐ๋ฅผ ๋ถˆ๋Ÿฌ์˜ค๋Š” ์ค‘...
  </div>
  
  <!-- ์นด๋“œ ์ปจํ…Œ์ด๋„ˆ -->
  <div class="container" id="cardsContainer"></div>
  
  <script>
    // API ์—”๋“œํฌ์ธํŠธ
    const HF_API_BASE = 'https://huggingface.co';
    
    // ์ƒํƒœ ๊ด€๋ฆฌ
    const state = {
      token: null,
      username: null,
      likedModels: {},
      isLoading: false
    };
    
    // DOM ์š”์†Œ ์ฐธ์กฐ
    const elements = {
      tokenInput: document.getElementById('tokenInput'),
      authButton: document.getElementById('authButton'),
      logoutButton: document.getElementById('logoutButton'),
      authStatus: document.getElementById('authStatus'),
      cardsContainer: document.getElementById('cardsContainer'),
      loadingIndicator: document.getElementById('loadingIndicator'),
      statusMessage: document.getElementById('statusMessage')
    };
    
    // Hugging Face์˜ spaces/models URL ๋ชฉ๋ก
    const urls = [
      "https://huggingface.co/spaces/ginipick/Tech_Hangman_Game",
      "https://huggingface.co/spaces/openfree/deepseek_r1_API",
      "https://huggingface.co/spaces/ginipick/open_Deep-Research",
      "https://huggingface.co/spaces/aiqmaster/open-deep-research",
      "https://huggingface.co/spaces/seawolf2357/DeepSeek-R1-32b-search",
      "https://huggingface.co/spaces/ginigen/LLaDA",
      "https://huggingface.co/spaces/VIDraft/PHI4-Multimodal",
      "https://huggingface.co/spaces/ginigen/Ovis2-8B",
      "https://huggingface.co/spaces/ginigen/Graph-Mind",
      // ๋‚˜๋จธ์ง€ URL ๋ชฉ๋ก... ์‹ค์ œ๋กœ๋Š” ๋ชจ๋“  URL์„ ํฌํ•จํ•ด์•ผ ํ•จ
    ];
    
    // URL์—์„œ ๋ชจ๋ธ/์ŠคํŽ˜์ด์Šค ID ์ถ”์ถœ
    function extractModelInfo(url) {
      try {
        const parts = url.split('/');
        let type, owner, repo;
        
        // URL ํ˜•์‹์— ๋”ฐ๋ผ ๋‹ค๋ฅธ ์ฒ˜๋ฆฌ
        if (parts[3] === 'spaces' || parts[3] === 'models') {
          type = parts[3];
          owner = parts[4];
          repo = parts[5];
        } else {
          // ํ˜•์‹์ด ๋‹ค๋ฅธ ๊ฒฝ์šฐ (์˜ˆ: https://huggingface.co/deepseek/deepseek-ai)
          type = 'models'; // ๊ธฐ๋ณธ๊ฐ’์œผ๋กœ models ์‚ฌ์šฉ
          owner = parts[3];
          repo = parts[4];
        }
        
        // ์—†๋Š” ๊ฐ’์ด ์žˆ์œผ๋ฉด ๊ธฐ๋ณธ๊ฐ’ ์„ค์ •
        type = type || 'models';
        owner = owner || '';
        repo = repo || '';
        
        return { type, owner, repo, fullId: `${owner}/${repo}` };
      } catch (e) {
        console.error('URL ํŒŒ์‹ฑ ์˜ค๋ฅ˜:', e, url);
        return { type: 'models', owner: '', repo: '', fullId: '' };
      }
    }
    
    // URL์˜ ๋งˆ์ง€๋ง‰ ๋ถ€๋ถ„์„ ์ œ๋ชฉ์œผ๋กœ ์ถ”์ถœ (์–ธ๋”๋ฐ”, ํ•˜์ดํ”ˆ์„ ๊ณต๋ฐฑ์œผ๋กœ ๋ณ€ํ™˜)
    function extractTitle(url) {
      const parts = url.split("/");
      let title = parts[parts.length - 1];
      return title.replace(/[_-]/g, " ");
    }
    
    // ๋กœ๋”ฉ ์ƒํƒœ ํ‘œ์‹œ ํ•จ์ˆ˜
    function setLoading(isLoading) {
      state.isLoading = isLoading;
      elements.loadingIndicator.style.display = isLoading ? 'flex' : 'none';
    }
    
    // ์ƒํƒœ ๋ฉ”์‹œ์ง€ ํ‘œ์‹œ ํ•จ์ˆ˜
    function showMessage(message, isError = false) {
      elements.statusMessage.textContent = message;
      elements.statusMessage.className = `status-message ${isError ? 'error' : 'success'}`;
      elements.statusMessage.style.display = 'block';
      
      // 3์ดˆ ํ›„ ๋ฉ”์‹œ์ง€ ์‚ฌ๋ผ์ง
      setTimeout(() => {
        elements.statusMessage.style.display = 'none';
      }, 3000);
    }
    
    // Hugging Face API ํ˜ธ์ถœ ํ•จ์ˆ˜
    async function fetchWithToken(endpoint, options = {}) {
      if (!state.token) {
        throw new Error('์ธ์ฆ ํ† ํฐ์ด ์—†์Šต๋‹ˆ๋‹ค.');
      }
      
      const url = `${HF_API_BASE}${endpoint}`;
      console.log('API ํ˜ธ์ถœ:', url, options.method || 'GET');
      
      const headers = {
        'Authorization': `Bearer ${state.token}`,
        'Content-Type': 'application/json',
        ...options.headers
      };
      
      try {
        const response = await fetch(url, {
          ...options,
          headers
        });
        
        // ๋””๋ฒ„๊น…์„ ์œ„ํ•œ ์‘๋‹ต ์ •๋ณด ์ถœ๋ ฅ
        console.log('API ์‘๋‹ต ์ƒํƒœ:', response.status, response.statusText);
        return response;
      } catch (error) {
        console.error('API ํ˜ธ์ถœ ์˜ค๋ฅ˜:', error);
        throw error;
      }
    }
    
    // ์‚ฌ์šฉ์ž ์ •๋ณด ๊ฐ€์ ธ์˜ค๊ธฐ
    async function fetchUserInfo() {
      const response = await fetchWithToken('/api/whoami-v2');
      if (!response.ok) {
        throw new Error('์‚ฌ์šฉ์ž ์ •๋ณด๋ฅผ ๊ฐ€์ ธ์˜ค๋Š”๋ฐ ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค. ์ƒํƒœ ์ฝ”๋“œ: ' + response.status);
      }
      return response.json();
    }
    
    // ์‚ฌ์šฉ์ž๊ฐ€ ์ข‹์•„์š”ํ•œ ๋ชจ๋ธ/์ŠคํŽ˜์ด์Šค ๋ชฉ๋ก ๊ฐ€์ ธ์˜ค๊ธฐ
    async function fetchLikedRepos() {
      try {
        // ์ข‹์•„์š”ํ•œ ๋ชจ๋ธ ๊ฐ€์ ธ์˜ค๊ธฐ
        const modelsResponse = await fetchWithToken('/api/me/likes');
        
        if (!modelsResponse.ok) {
          console.error('์ข‹์•„์š” ๋ชฉ๋ก ๊ฐ€์ ธ์˜ค๊ธฐ ์‘๋‹ต:', modelsResponse.status, modelsResponse.statusText);
          throw new Error('์ข‹์•„์š” ๋ชฉ๋ก์„ ๊ฐ€์ ธ์˜ค๋Š”๋ฐ ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค. ์ƒํƒœ ์ฝ”๋“œ: ' + modelsResponse.status);
        }
        
        const likedModels = await modelsResponse.json();
        console.log('๊ฐ€์ ธ์˜จ ์ข‹์•„์š” ๋ชฉ๋ก:', likedModels);
        
        // ๊ฒฐ๊ณผ๋ฅผ ๊ฐ์ฒด๋กœ ๋ณ€ํ™˜ (๋น ๋ฅธ ๊ฒ€์ƒ‰์„ ์œ„ํ•ด)
        const likedMap = {};
        likedModels.forEach(model => {
          likedMap[`${model.owner}/${model.name}`] = true;
        });
        
        return likedMap;
      } catch (error) {
        console.error('์ข‹์•„์š” ๋ชฉ๋ก ๊ฐ€์ ธ์˜ค๊ธฐ ์˜ค๋ฅ˜:', error);
        throw error;
      }
    }
    
    // ์ข‹์•„์š” ํ† ๊ธ€ API ํ˜ธ์ถœ
    async function toggleLikeAPI(type, owner, repo, isLiked) {
      try {
        const method = isLiked ? 'DELETE' : 'POST';
        const response = await fetchWithToken(`/api/${type}/${owner}/${repo}/like`, {
          method
        });
        
        if (!response.ok) {
          console.error('์ข‹์•„์š” ํ† ๊ธ€ ์‘๋‹ต:', response.status, response.statusText);
          throw new Error(`์ข‹์•„์š” ${isLiked ? '์ทจ์†Œ' : '์ถ”๊ฐ€'} ์‹คํŒจ. ์ƒํƒœ ์ฝ”๋“œ: ${response.status}`);
        }
        
        return response.ok;
      } catch (error) {
        console.error('์ข‹์•„์š” ํ† ๊ธ€ API ์˜ค๋ฅ˜:', error);
        throw error;
      }
    }
    
          // ์ธ์ฆ ์ฒ˜๋ฆฌ
    async function authenticate(token) {
      if (!token.trim()) {
        showMessage('ํ† ํฐ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.', true);
        return;
      }
      
      setLoading(true);
      
      try {
        // ํ† ํฐ ์ €์žฅ
        state.token = token;
        console.log('์ธ์ฆ ์‹œ๋„ (ํ† ํฐ ์ผ๋ถ€):', token.substring(0, 4) + '...');
        
        // ์‚ฌ์šฉ์ž ์ •๋ณด ๊ฐ€์ ธ์˜ค๊ธฐ
        const userInfo = await fetchUserInfo();
        console.log('์‚ฌ์šฉ์ž ์ •๋ณด:', userInfo);
        
        // ์‚ฌ์šฉ์ž ์ด๋ฆ„ ์ถ”์ถœ (API ์‘๋‹ต ๊ตฌ์กฐ์— ๋”ฐ๋ผ ๋‹ค๋ฅผ ์ˆ˜ ์žˆ์Œ)
        if (userInfo.name) {
          state.username = userInfo.name;
        } else if (userInfo.user && userInfo.user.username) {
          state.username = userInfo.user.username;
        } else if (userInfo.username) {
          state.username = userInfo.username;
        } else {
          state.username = '์ธ์ฆ๋œ ์‚ฌ์šฉ์ž';
        }
        
        // ์‹ค์ œ ์ข‹์•„์š” ๋ชฉ๋ก ๊ฐ€์ ธ์˜ค๊ธฐ
        state.likedModels = await fetchLikedRepos();
        
        // UI ์—…๋ฐ์ดํŠธ
        elements.authStatus.textContent = `${state.username}๋‹˜์œผ๋กœ ์ธ์ฆ๋จ`;
        elements.tokenInput.style.display = 'none';
        elements.authButton.style.display = 'none';
        elements.logoutButton.style.display = 'inline-block';
        
        showMessage('์ธ์ฆ ์„ฑ๊ณต! ์ข‹์•„์š” ์ •๋ณด๋ฅผ ๋ถˆ๋Ÿฌ์™”์Šต๋‹ˆ๋‹ค.');
        
        // ์นด๋“œ ๋‹ค์‹œ ๋ Œ๋”๋ง
        renderCards();
      } catch (error) {
        console.error('์ธ์ฆ ์˜ค๋ฅ˜:', error);
        showMessage(`์ธ์ฆ์— ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค: ${error.message}`, true);
        state.token = null;
      } finally {
        setLoading(false);
      }
    }
    
    // ๋กœ๊ทธ์•„์›ƒ ์ฒ˜๋ฆฌ
    function logout() {
      // ์ƒํƒœ ์ดˆ๊ธฐํ™”
      state.token = null;
      state.username = null;
      state.likedModels = {};
      
      // UI ์—…๋ฐ์ดํŠธ
      elements.authStatus.textContent = '์ธ์ฆ๋˜์ง€ ์•Š์Œ';
      elements.tokenInput.style.display = 'inline-block';
      elements.tokenInput.value = '';
      elements.authButton.style.display = 'inline-block';
      elements.logoutButton.style.display = 'none';
      
      showMessage('๋กœ๊ทธ์•„์›ƒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.');
      
      // ์นด๋“œ ๋‹ค์‹œ ๋ Œ๋”๋ง
      renderCards();
    }
    
    // ์ข‹์•„์š” ํ† ๊ธ€ ์ฒ˜๋ฆฌ
    async function toggleLike(url, button) {
      if (!state.token) {
        showMessage('์ข‹์•„์š”๋ฅผ ํ•˜๋ ค๋ฉด HF ํ† ํฐ์œผ๋กœ ์ธ์ฆ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.', true);
        return;
      }
      
      const modelInfo = extractModelInfo(url);
      const modelId = modelInfo.fullId;
      const isCurrentlyLiked = state.likedModels[modelId] || false;
      
      setLoading(true);
      
      try {
        // ์‹ค์ œ API ํ˜ธ์ถœ๋กœ ์ข‹์•„์š” ์ƒํƒœ ํ† ๊ธ€
        await toggleLikeAPI(modelInfo.type, modelInfo.owner, modelInfo.repo, isCurrentlyLiked);
        
        // ์ƒํƒœ ์—…๋ฐ์ดํŠธ
        if (isCurrentlyLiked) {
          delete state.likedModels[modelId];
          button.classList.remove("liked");
          button.classList.add("not-liked");
          showMessage(`${modelInfo.repo}์— ๋Œ€ํ•œ ์ข‹์•„์š”๋ฅผ ์ทจ์†Œํ–ˆ์Šต๋‹ˆ๋‹ค.`);
        } else {
          state.likedModels[modelId] = true;
          button.classList.add("liked");
          button.classList.remove("not-liked");
          showMessage(`${modelInfo.repo}๋ฅผ ์ข‹์•„์š” ํ–ˆ์Šต๋‹ˆ๋‹ค.`);
        }
      } catch (error) {
        showMessage('์ข‹์•„์š” ์ฒ˜๋ฆฌ ์ค‘ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.', true);
        console.error('์ข‹์•„์š” ์˜ค๋ฅ˜:', error);
      } finally {
        setLoading(false);
      }
    }
    
    // ์นด๋“œ ๋ Œ๋”๋ง
    function renderCards() {
      // ์นด๋“œ ์ปจํ…Œ์ด๋„ˆ ์ดˆ๊ธฐํ™”
      elements.cardsContainer.innerHTML = '';
      
      // ๊ฐ URL์— ๋Œ€ํ•ด ์นด๋“œ ์ƒ์„ฑ
      urls.forEach(url => {
        const card = document.createElement("div");
        card.className = "card";
        
        // ์ œ๋ชฉ
        const titleEl = document.createElement("h3");
        titleEl.textContent = extractTitle(url);
        card.appendChild(titleEl);
        
        // URL ๋งํฌ
        const linkEl = document.createElement("a");
        linkEl.href = url;
        linkEl.textContent = url;
        linkEl.target = "_blank";
        card.appendChild(linkEl);
        
        // ์ข‹์•„์š” ๋ฒ„ํŠผ (โ™ฅ ์•„์ด์ฝ˜)
        const likeBtn = document.createElement("button");
        likeBtn.className = "like-button";
        likeBtn.textContent = "โ™ฅ";
        
        // ์ข‹์•„์š” ์ƒํƒœ ์„ค์ •
        try {
          const modelInfo = extractModelInfo(url);
          const isLiked = state.token && state.likedModels[modelInfo.fullId];
          
          if (isLiked) {
            likeBtn.classList.add("liked");
          } else {
            likeBtn.classList.add("not-liked");
          }
        } catch (e) {
          // URL ํŒŒ์‹ฑ ์˜ค๋ฅ˜ ๋“ฑ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ
          likeBtn.classList.add("not-liked");
        }
        
        likeBtn.addEventListener("click", function(e) {
          e.preventDefault();  // ๋งํฌ ํด๋ฆญ ๋ฐฉ์ง€
          toggleLike(url, likeBtn);
        });
        card.appendChild(likeBtn);
        
        elements.cardsContainer.appendChild(card);
      });
    }
    
    // ์ด๋ฒคํŠธ ๋ฆฌ์Šค๋„ˆ ์„ค์ •
    elements.authButton.addEventListener('click', () => {
      authenticate(elements.tokenInput.value);
    });
    
    elements.logoutButton.addEventListener('click', logout);
    
    // ์—”ํ„ฐ ํ‚ค๋กœ ์ธ์ฆ ๊ฐ€๋Šฅํ•˜๊ฒŒ
    elements.tokenInput.addEventListener('keypress', (event) => {
      if (event.key === 'Enter') {
        authenticate(elements.tokenInput.value);
      }
    });
    
    // ์ดˆ๊ธฐ ๋ Œ๋”๋ง
    renderCards();
  </script>
</body>
</html>