File size: 8,638 Bytes
20fda5d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
class ClaudeHeader extends HTMLElement {
    constructor() {
        super();
    }

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

    render() {
        this.shadowRoot.innerHTML = `
            <style>
                .header {
                    background: rgba(255, 255, 255, 0.8);
                    backdrop-filter: blur(10px);
                    border-bottom: 1px solid #e2e8f0;
                    padding: 1rem 1.5rem;
                    position: sticky;
                    top: 0;
                    z-index: 40;
                }
                
                .header-content {
                    max-width: 1200px;
                    margin: 0 auto;
                    display: flex;
                    justify-content: space-between;
                    align-items: center;
                }
                
                .app-identity {
                    display: flex;
                    flex-direction: column;
                    gap: 0.25rem;
                }
                
                .app-name {
                    font-size: 1.5rem;
                    font-weight: 700;
                    color: #1e293b;
                    cursor: pointer;
                    transition: color 0.2s;
                }
                
                .app-name:hover {
                    color: var(--primary-blue);
                }
                
                .tagline {
                    font-size: 0.875rem;
                    color: #64748b;
                }
                
                .model-selector {
                    position: relative;
                }
                
                .model-button {
                    display: flex;
                    align-items: center;
                    gap: 0.5rem;
                    padding: 0.5rem 1rem;
                    background: white;
                    border: 1px solid #d1d5db;
                    border-radius: 0.75rem;
                    font-size: 0.875rem;
                    font-weight: 500;
                    color: #374151;
                    cursor: pointer;
                    transition: all 0.2s;
                }
                
                .model-button:hover {
                    border-color: var(--primary-blue);
                    background: #f8fafc;
                }
                
                .model-button:disabled {
                    opacity: 0.6;
                    cursor: not-allowed;
                }
                
                .dropdown {
                    position: absolute;
                    top: 100%;
                    right: 0;
                    margin-top: 0.5rem;
                    background: white;
                    border: 1px solid #e2e8f0;
                    border-radius: 0.75rem;
                    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
                    z-index: 50;
                    min-width: 200px;
                    display: none;
                }
                
                .dropdown.show {
                    display: block;
                }
                
                .dropdown-item {
                    padding: 0.75rem 1rem;
                    cursor: pointer;
                    transition: background 0.2s;
                    border-bottom: 1px solid #f1f5f9;
                }
                
                .dropdown-item:last-child {
                    border-bottom: none;
                }
                
                .dropdown-item:hover {
                    background: #f8fafc;
                }
                
                .dropdown-item.selected {
                    background: #eff6ff;
                    color: var(--primary-blue);
                }
                
                @media (max-width: 767px) {
                    .header {
                        padding: 0.75rem 1rem;
                    }
                    
                    .app-name {
                        font-size: 1.25rem;
                    }
                    
                    .tagline {
                        display: none;
                    }
                }
            </style>
            
            <header class="header">
                <div class="header-content">
                    <div class="app-identity">
                        <div class="app-name" id="appName">
                            ClaudeVerse AI
                        </div>
                        <div class="tagline">
                            Powered by Puter.js
                        </div>
                    </div>
                    
                    <div class="model-selector">
                        <button class="model-button" id="modelButton">
                            <span id="currentModel">Claude Sonnet 4.5</span>
                            <i data-feather="chevron-down" width="16" height="16"></i>
                        </button>
                        
                        <div class="dropdown" id="modelDropdown">
                            <div class="dropdown-item" data-model="claude-sonnet-4-5">Claude Sonnet 4.5</div>
                            <div class="dropdown-item" data-model="claude-sonnet-4">Claude Sonnet 4</div>
                            <div class="dropdown-item" data-model="claude-opus-4-1">Claude Opus 4.1</div>
                            <div class="dropdown-item" data-model="claude-opus-4">Claude Opus 4</div>
                            <div class="dropdown-item" data-model="claude-haiku-4-5">Claude Haiku 4.5</div>
                        </div>
                    </div>
                </div>
            </header>
        `;
        
        // Update feather icons
        setTimeout(() => {
            if (this.shadowRoot.querySelector('[data-feather]')) {
                feather.replace();
            }
        }, 100);
    }

    setupEventListeners() {
        const appName = this.shadowRoot.getElementById('appName');
        const modelButton = this.shadowRoot.getElementById('modelButton');
        const modelDropdown = this.shadowRoot.getElementById('modelDropdown');
        const currentModel = this.shadowRoot.getElementById('currentModel');

        // Reset conversation on app name click
        appName.addEventListener('click', () => {
            document.dispatchEvent(new CustomEvent('claude-new-chat'));
        });

        // Toggle dropdown
        modelButton.addEventListener('click', () => {
            if (window.claudeApp.isProcessing) return;
            
            const isShowing = modelDropdown.classList.contains('show');
            if (isShowing) {
                modelDropdown.classList.remove('show');
            } else {
                modelDropdown.classList.add('show');
            }
        });

        // Model selection
        modelDropdown.addEventListener('click', (event) => {
            const item = event.target.closest('.dropdown-item');
            if (item) {
                const model = item.dataset.model;
                document.dispatchEvent(new CustomEvent('claude-change-model', {
                    detail: { model }
                }));
                
                // Update current model display
                currentModel.textContent = this.getModelLabel(model);
                
                // Close dropdown
                modelDropdown.classList.remove('show');
                
                // Show selection feedback
                item.classList.add('selected');
                setTimeout(() => item.classList.remove('selected'), 500);
            }
        });

        // Close dropdown when clicking outside
        document.addEventListener('click', (event) => {
            if (!this.contains(event.target)) {
                modelDropdown.classList.remove('show');
            }
        });

        // Update model display when changed externally
        document.addEventListener('claude-model-changed', (event) => {
            const { model } = event.detail;
            currentModel.textContent = this.getModelLabel(model);
        });
    }

    getModelLabel(model) {
        const modelLabels = {
            'claude-sonnet-4-5': 'Claude Sonnet 4.5',
            'claude-sonnet-4': 'Claude Sonnet 4',
            'claude-opus-4-1': 'Claude Opus 4.1',
            'claude-opus-4': 'Claude Opus 4',
            'claude-haiku-4-5': 'Claude Haiku 4.5'
        };
        
        return modelLabels[model] || model;
    }
}

customElements.define('claude-header', ClaudeHeader);