@eyeglass/inspector 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,33 +1,1392 @@
1
- /**
2
- * @eyeglass/inspector - Browser-side inspection web component
3
- *
4
- * Usage:
5
- * import '@eyeglass/inspector';
6
- * // Or inject via script tag
7
- *
8
- * This automatically registers the <eyeglass-inspector> custom element.
9
- */
10
- export { EyeglassInspector } from './inspector.js';
11
- export { captureSnapshot } from './snapshot.js';
12
- export { extractFrameworkInfo } from './fiber-walker.js';
13
- /**
14
- * Initialize the inspector by appending it to the document
15
- */
16
- export function initInspector() {
17
- if (document.querySelector('eyeglass-inspector')) {
18
- console.warn('[eyeglass] Inspector already initialized');
19
- return;
20
- }
21
- const inspector = document.createElement('eyeglass-inspector');
22
- document.body.appendChild(inspector);
23
- console.log('[eyeglass] Inspector initialized. Hover over elements and click to annotate.');
24
- }
25
- // Auto-initialize when imported in a browser context
26
- if (typeof window !== 'undefined' && typeof document !== 'undefined') {
27
- if (document.readyState === 'loading') {
28
- document.addEventListener('DOMContentLoaded', initInspector);
29
- }
30
- else {
31
- initInspector();
32
- }
1
+ var R=new Set([0,1,11,14,15]);function F(s){let t=Object.keys(s).find(e=>e.startsWith("__reactFiber$")||e.startsWith("__reactInternalInstance$"));return t?s[t]:null}function H(s){if(!R.has(s.tag)||typeof s.type!="function")return!1;let r=s.type.displayName||s.type.name||"";return!(!r||r.startsWith("Context")||r.endsWith("Provider")||r==="StrictMode")}function C(s){return s.type.displayName||s.type.name||void 0}function B(s){let r=s;for(;r;){if(H(r))return r;r=r.return}return null}function M(s){let r=[],t=s;for(;t;){if(H(t)){let e=C(t);e&&r.push(e)}t=t.return}return r}function T(s){if(!s)return;let r={};for(let[t,e]of Object.entries(s)){if(t==="children")continue;let i=typeof e;(i==="string"||i==="number"||i==="boolean"||e===null)&&(r[t]=e)}return Object.keys(r).length>0?r:void 0}function _(s){let r=s.__vue__;if(r)return{name:"vue",componentName:r.$options?.name||r.$options?._componentTag};let e=Object.keys(s).find(i=>i.startsWith("__vue"));if(e){let i=s[e];if(i){let n=i,o,a;n?.type?.name?o=n.type.name:n?.type?.__name?o=n.type.__name:n?.component?.type?.name?o=n.component.type.name:n?.component?.type?.__name&&(o=n.component.type.__name);let l=n?.props||n?.component?.props;l&&(a=T(l));let d;return n?.type?.__file?d=n.type.__file:n?.component?.type?.__file&&(d=n.component.type.__file),{name:"vue",componentName:o,filePath:d,props:a}}return{name:"vue"}}return null}function j(s){let t=Object.keys(s).find(e=>e.startsWith("__svelte"));if(t){let e=s[t],i;if(e?.constructor?.name&&e.constructor.name!=="Object"&&(i=e.constructor.name),!i&&e?.$$?.ctx){let n=e.$$.ctx;n?.constructor?.name&&n.constructor.name!=="Object"&&(i=n.constructor.name)}return{name:"svelte",componentName:i}}return null}function I(s){let r=F(s);if(r){let i=B(r);if(i){let o=C(i),a=i._debugSource,l=M(i);return{name:"react",componentName:o,filePath:a?.fileName,lineNumber:a?.lineNumber,props:T(i.memoizedProps),ancestry:l.length>0?l:void 0}}let n=M(r);return{name:"react",ancestry:n.length>0?n:void 0}}let t=_(s);if(t)return t;let e=j(s);return e||{name:"vanilla"}}function O(s){let r=s.getAttribute("aria-label"),t=s.getAttribute("aria-describedby"),e=s.getAttribute("aria-disabled"),i=s.getAttribute("aria-expanded"),n=s.getAttribute("aria-checked"),o=s.getAttribute("aria-hidden"),a=null;t&&(a=document.getElementById(t)?.textContent?.trim()||null);let l=e==="true"||s.disabled||s.hasAttribute("disabled");return{label:r||s.getAttribute("title")||null,description:a,disabled:l,expanded:i?i==="true":void 0,checked:n==="true"?!0:n==="false"?!1:n==="mixed"?"mixed":void 0,hidden:o==="true"||s.hidden||!1}}function G(s){let r=s.getBoundingClientRect();return{x:Math.round(r.x),y:Math.round(r.y),width:Math.round(r.width),height:Math.round(r.height),visible:r.width>0&&r.height>0}}function U(s){let r=getComputedStyle(s);return{display:r.display,position:r.position,flexDirection:r.flexDirection!=="row"?r.flexDirection:void 0,gridTemplate:r.display==="grid"?`${r.gridTemplateColumns} / ${r.gridTemplateRows}`:void 0,padding:r.padding,margin:r.margin,color:r.color,backgroundColor:r.backgroundColor,fontFamily:r.fontFamily,zIndex:r.zIndex}}function Y(s){let r=s.getAttribute("role");if(r)return r;let t=s.tagName.toLowerCase();return{a:"link",button:"button",input:s.type||"textbox",select:"combobox",textarea:"textbox",img:"img",nav:"navigation",main:"main",header:"banner",footer:"contentinfo",aside:"complementary",article:"article",section:"region",form:"form",ul:"list",ol:"list",li:"listitem",table:"table",tr:"row",td:"cell",th:"columnheader",dialog:"dialog",h1:"heading",h2:"heading",h3:"heading",h4:"heading",h5:"heading",h6:"heading"}[t]||"generic"}function W(s){let r=s.getAttribute("aria-label");if(r)return r;let t=s.getAttribute("aria-labelledby");if(t){let i=document.getElementById(t);if(i)return i.textContent?.trim()||""}if(s.tagName==="INPUT"||s.tagName==="SELECT"||s.tagName==="TEXTAREA"){let i=s.getAttribute("id");if(i){let n=document.querySelector(`label[for="${i}"]`);if(n)return n.textContent?.trim()||""}}if(s.tagName==="IMG")return s.alt||"";let e=s.textContent?.trim()||"";return e.length>50?e.slice(0,50)+"...":e}function J(s){let r={},t=s.getAttribute("id");t&&(r.id=t);let e=s.getAttribute("class");e?.trim()&&(r.className=e.trim());let i={};for(let n=0;n<s.attributes.length;n++){let o=s.attributes[n];o.name.startsWith("data-")&&(i[o.name]=o.value)}return Object.keys(i).length>0&&(r.dataAttributes=i),r}function x(s){let r=J(s);return{role:Y(s),name:W(s),tagName:s.tagName.toLowerCase(),...r,framework:I(s),a11y:O(s),geometry:G(s),styles:U(s),timestamp:Date.now(),url:window.location.href}}var b="http://localhost:3300",v="eyeglass_session",P="eyeglass_history",L="eyeglass_enabled",$="eyeglass_autocommit",K=1e4,y=["Ruminating...","Percolating...","Divining...","Grokking...","Communing...","Concocting...","Synthesizing...","Distilling...","Incubating...","Forging...","Scrutinizing...","Triangulating...","Unraveling...","Traversing...","Sifting...","Marshaling...","Hydrating...","Harmonizing...","Indexing...","Entangling..."],Z='url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiM2MzY2ZjEiIHN0cm9rZS13aWR0aD0iMi41IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPjxwYXRoIGQ9Ik0xIDEyczQtOCAxMS04IDExIDggMTEgOC00IDgtMTEgOC0xMS04LTExLTh6Ii8+PGNpcmNsZSBjeD0iMTIiIGN5PSIxMiIgcj0iMyIgZmlsbD0iIzYzNjZmMSIvPjwvc3ZnPg==") 8 8, crosshair',X=`
2
+ :host {
3
+ all: initial;
4
+ position: fixed;
5
+ top: 0;
6
+ left: 0;
7
+ width: 100%;
8
+ height: 100%;
9
+ z-index: 2147483647;
10
+ pointer-events: none;
11
+ font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
12
+ font-size: 13px;
13
+ line-height: 1.5;
14
+ box-sizing: border-box;
15
+ --glass-bg: rgba(255, 255, 255, 0.88);
16
+ --glass-border: rgba(0, 0, 0, 0.25);
17
+ --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
18
+ --divider: rgba(0, 0, 0, 0.18);
19
+ --text-primary: #0f172a;
20
+ --text-secondary: #64748b;
21
+ --text-muted: #94a3b8;
22
+ --accent: #6366f1;
23
+ --accent-soft: rgba(99, 102, 241, 0.1);
24
+ --success: #10b981;
25
+ --error: #ef4444;
26
+ --border-radius: 16px;
27
+ --border-radius-sm: 10px;
33
28
  }
29
+
30
+ *, *::before, *::after {
31
+ box-sizing: border-box;
32
+ }
33
+
34
+ /* Highlight overlay */
35
+ .highlight {
36
+ position: absolute;
37
+ z-index: 2147483640;
38
+ border: 2px solid var(--accent);
39
+ background: rgba(99, 102, 241, 0.06);
40
+ pointer-events: none;
41
+ border-radius: 6px;
42
+ transition: all 0.1s ease-out;
43
+ box-shadow:
44
+ 0 0 0 3px rgba(99, 102, 241, 0.08),
45
+ 0 2px 8px rgba(99, 102, 241, 0.1);
46
+ }
47
+
48
+ .highlight.no-transition {
49
+ transition: none;
50
+ }
51
+
52
+ /* Glass Panel */
53
+ .glass-panel {
54
+ position: absolute;
55
+ z-index: 2147483647;
56
+ background: var(--glass-bg);
57
+ backdrop-filter: blur(20px) saturate(180%);
58
+ -webkit-backdrop-filter: blur(20px) saturate(180%);
59
+ border: 1px solid var(--glass-border);
60
+ border-radius: var(--border-radius);
61
+ box-shadow: var(--glass-shadow);
62
+ pointer-events: auto;
63
+ width: 340px;
64
+ overflow: hidden;
65
+ animation: panelIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
66
+ cursor: default;
67
+ }
68
+
69
+ .glass-panel *, .glass-panel *::before, .glass-panel *::after {
70
+ cursor: inherit;
71
+ }
72
+
73
+ .glass-panel button, .glass-panel input {
74
+ cursor: pointer;
75
+ }
76
+
77
+ .glass-panel input[type="text"] {
78
+ cursor: text;
79
+ }
80
+
81
+ @keyframes panelIn {
82
+ from {
83
+ opacity: 0;
84
+ transform: translateY(8px) scale(0.96);
85
+ }
86
+ to {
87
+ opacity: 1;
88
+ transform: translateY(0) scale(1);
89
+ }
90
+ }
91
+
92
+ /* Panel Header */
93
+ .panel-header {
94
+ padding: 14px 16px;
95
+ border-bottom: 1px solid var(--divider);
96
+ display: flex;
97
+ align-items: center;
98
+ gap: 10px;
99
+ cursor: grab;
100
+ user-select: none;
101
+ }
102
+
103
+ .panel-header:active {
104
+ cursor: grabbing;
105
+ }
106
+
107
+ .component-tag {
108
+ font-family: 'SF Mono', 'Fira Code', monospace;
109
+ font-size: 12px;
110
+ font-weight: 500;
111
+ color: var(--accent);
112
+ background: var(--accent-soft);
113
+ padding: 4px 10px;
114
+ border-radius: 6px;
115
+ letter-spacing: -0.01em;
116
+ }
117
+
118
+ .file-path {
119
+ font-size: 11px;
120
+ color: var(--text-muted);
121
+ overflow: hidden;
122
+ text-overflow: ellipsis;
123
+ white-space: nowrap;
124
+ flex: 1;
125
+ }
126
+
127
+ .close-btn {
128
+ width: 24px;
129
+ height: 24px;
130
+ border: none;
131
+ background: transparent;
132
+ color: var(--text-muted);
133
+ cursor: pointer;
134
+ border-radius: 6px;
135
+ display: flex;
136
+ align-items: center;
137
+ justify-content: center;
138
+ transition: all 0.15s;
139
+ font-size: 18px;
140
+ line-height: 1;
141
+ }
142
+
143
+ .close-btn:hover {
144
+ background: rgba(0, 0, 0, 0.05);
145
+ color: var(--text-secondary);
146
+ }
147
+
148
+ /* User Request */
149
+ .user-request {
150
+ padding: 12px 16px;
151
+ background: rgba(0, 0, 0, 0.02);
152
+ border-bottom: 1px solid var(--divider);
153
+ }
154
+
155
+ .user-request-label {
156
+ font-size: 10px;
157
+ font-weight: 600;
158
+ text-transform: uppercase;
159
+ letter-spacing: 0.05em;
160
+ color: var(--text-muted);
161
+ margin-bottom: 4px;
162
+ }
163
+
164
+ .user-request-text {
165
+ color: var(--text-primary);
166
+ font-weight: 500;
167
+ }
168
+
169
+ /* Input Mode */
170
+ .input-area {
171
+ padding: 12px 16px 16px;
172
+ }
173
+
174
+ .input-field {
175
+ width: 100%;
176
+ padding: 10px 14px;
177
+ border: 1px solid rgba(0, 0, 0, 0.08);
178
+ border-radius: var(--border-radius-sm);
179
+ font-size: 13px;
180
+ font-family: inherit;
181
+ background: rgba(255, 255, 255, 0.6);
182
+ color: var(--text-primary);
183
+ outline: none;
184
+ transition: all 0.15s;
185
+ }
186
+
187
+ .input-field::placeholder {
188
+ color: var(--text-muted);
189
+ }
190
+
191
+ .input-field:focus {
192
+ border-color: var(--accent);
193
+ box-shadow: 0 0 0 3px var(--accent-soft);
194
+ background: white;
195
+ }
196
+
197
+ .btn-row {
198
+ display: flex;
199
+ gap: 8px;
200
+ margin-top: 10px;
201
+ }
202
+
203
+ .btn {
204
+ flex: 1;
205
+ padding: 9px 14px;
206
+ border: none;
207
+ border-radius: var(--border-radius-sm);
208
+ font-size: 12px;
209
+ font-weight: 600;
210
+ font-family: inherit;
211
+ cursor: pointer;
212
+ transition: all 0.15s;
213
+ }
214
+
215
+ .btn-primary {
216
+ background: var(--accent);
217
+ color: white;
218
+ }
219
+
220
+ .btn-primary:hover {
221
+ background: #4f46e5;
222
+ transform: translateY(-1px);
223
+ }
224
+
225
+ .btn-secondary {
226
+ background: rgba(0, 0, 0, 0.04);
227
+ color: var(--text-secondary);
228
+ }
229
+
230
+ .btn-secondary:hover {
231
+ background: rgba(0, 0, 0, 0.08);
232
+ }
233
+
234
+ /* Activity Feed */
235
+ .activity-feed {
236
+ max-height: 280px;
237
+ overflow-y: auto;
238
+ padding: 8px 0;
239
+ }
240
+
241
+ .activity-feed::-webkit-scrollbar {
242
+ width: 6px;
243
+ }
244
+
245
+ .activity-feed::-webkit-scrollbar-track {
246
+ background: transparent;
247
+ }
248
+
249
+ .activity-feed::-webkit-scrollbar-thumb {
250
+ background: rgba(0, 0, 0, 0.1);
251
+ border-radius: 3px;
252
+ }
253
+
254
+ .activity-item {
255
+ padding: 8px 16px;
256
+ display: flex;
257
+ gap: 10px;
258
+ align-items: flex-start;
259
+ animation: itemIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
260
+ }
261
+
262
+ @keyframes itemIn {
263
+ from {
264
+ opacity: 0;
265
+ transform: translateX(-8px);
266
+ }
267
+ to {
268
+ opacity: 1;
269
+ transform: translateX(0);
270
+ }
271
+ }
272
+
273
+ .activity-icon {
274
+ width: 20px;
275
+ height: 20px;
276
+ border-radius: 50%;
277
+ display: flex;
278
+ align-items: center;
279
+ justify-content: center;
280
+ flex-shrink: 0;
281
+ font-size: 10px;
282
+ }
283
+
284
+ .activity-icon.status { background: var(--accent-soft); color: var(--accent); }
285
+ .activity-icon.thought { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; }
286
+ .activity-icon.action { background: rgba(14, 165, 233, 0.1); color: #0ea5e9; }
287
+ .activity-icon.question { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }
288
+ .activity-icon.success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
289
+ .activity-icon.error { background: rgba(239, 68, 68, 0.1); color: var(--error); }
290
+
291
+ .activity-content {
292
+ flex: 1;
293
+ min-width: 0;
294
+ }
295
+
296
+ .activity-text {
297
+ color: var(--text-primary);
298
+ word-wrap: break-word;
299
+ }
300
+
301
+ .activity-text.muted {
302
+ color: var(--text-secondary);
303
+ }
304
+
305
+ .activity-target {
306
+ font-family: 'SF Mono', 'Fira Code', monospace;
307
+ font-size: 11px;
308
+ color: var(--text-muted);
309
+ margin-top: 2px;
310
+ }
311
+
312
+ /* Question UI */
313
+ .question-box {
314
+ background: rgba(245, 158, 11, 0.06);
315
+ border: 1px solid rgba(245, 158, 11, 0.15);
316
+ border-radius: var(--border-radius-sm);
317
+ padding: 12px;
318
+ margin: 8px 16px;
319
+ animation: questionIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
320
+ }
321
+
322
+ @keyframes questionIn {
323
+ from {
324
+ opacity: 0;
325
+ transform: scale(0.95);
326
+ }
327
+ to {
328
+ opacity: 1;
329
+ transform: scale(1);
330
+ }
331
+ }
332
+
333
+ .question-text {
334
+ font-weight: 500;
335
+ color: var(--text-primary);
336
+ margin-bottom: 10px;
337
+ }
338
+
339
+ .question-options {
340
+ display: flex;
341
+ flex-wrap: wrap;
342
+ gap: 6px;
343
+ }
344
+
345
+ .question-option {
346
+ padding: 7px 14px;
347
+ border: 1px solid rgba(0, 0, 0, 0.1);
348
+ border-radius: 8px;
349
+ background: white;
350
+ font-size: 12px;
351
+ font-weight: 500;
352
+ font-family: inherit;
353
+ color: var(--text-primary);
354
+ cursor: pointer;
355
+ transition: all 0.15s;
356
+ }
357
+
358
+ .question-option:hover {
359
+ border-color: var(--accent);
360
+ background: var(--accent-soft);
361
+ color: var(--accent);
362
+ }
363
+
364
+ /* Skeleton loader */
365
+ .skeleton-item {
366
+ padding: 8px 16px;
367
+ display: flex;
368
+ gap: 10px;
369
+ align-items: center;
370
+ }
371
+
372
+ .skeleton-icon {
373
+ width: 20px;
374
+ height: 20px;
375
+ border-radius: 50%;
376
+ background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
377
+ background-size: 200% 100%;
378
+ animation: shimmer 1.5s infinite;
379
+ }
380
+
381
+ .skeleton-line {
382
+ height: 14px;
383
+ border-radius: 4px;
384
+ background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
385
+ background-size: 200% 100%;
386
+ animation: shimmer 1.5s infinite;
387
+ width: 60%;
388
+ }
389
+
390
+ @keyframes shimmer {
391
+ 0% { background-position: 200% 0; }
392
+ 100% { background-position: -200% 0; }
393
+ }
394
+
395
+ /* Status Footer */
396
+ .panel-footer {
397
+ padding: 10px 16px;
398
+ border-top: 1px solid var(--divider);
399
+ display: flex;
400
+ align-items: center;
401
+ gap: 8px;
402
+ }
403
+
404
+ .status-indicator {
405
+ width: 8px;
406
+ height: 8px;
407
+ border-radius: 50%;
408
+ background: var(--text-muted);
409
+ }
410
+
411
+ .status-indicator.pending {
412
+ background: var(--accent);
413
+ animation: pulse 1.5s ease-in-out infinite;
414
+ }
415
+
416
+ .status-indicator.fixing {
417
+ background: #0ea5e9;
418
+ animation: pulse 1s ease-in-out infinite;
419
+ }
420
+
421
+ .status-indicator.success { background: var(--success); }
422
+ .status-indicator.failed { background: var(--error); }
423
+
424
+ @keyframes pulse {
425
+ 0%, 100% { opacity: 1; transform: scale(1); }
426
+ 50% { opacity: 0.5; transform: scale(0.9); }
427
+ }
428
+
429
+ .status-text {
430
+ font-size: 12px;
431
+ color: var(--text-secondary);
432
+ flex: 1;
433
+ }
434
+
435
+ /* Done state */
436
+ .panel-footer.done {
437
+ background: rgba(16, 185, 129, 0.06);
438
+ }
439
+
440
+ .panel-footer.done .status-text {
441
+ color: var(--success);
442
+ font-weight: 500;
443
+ }
444
+
445
+ /* Result Toast - shows after page reload */
446
+ .result-toast {
447
+ position: fixed;
448
+ bottom: 24px;
449
+ right: 24px;
450
+ background: var(--glass-bg);
451
+ backdrop-filter: blur(20px) saturate(180%);
452
+ -webkit-backdrop-filter: blur(20px) saturate(180%);
453
+ border: 1px solid var(--glass-border);
454
+ border-radius: var(--border-radius);
455
+ box-shadow: var(--glass-shadow);
456
+ padding: 14px 18px;
457
+ pointer-events: auto;
458
+ display: flex;
459
+ align-items: center;
460
+ gap: 12px;
461
+ animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
462
+ max-width: 320px;
463
+ }
464
+
465
+ @keyframes toastIn {
466
+ from {
467
+ opacity: 0;
468
+ transform: translateY(16px) scale(0.95);
469
+ }
470
+ to {
471
+ opacity: 1;
472
+ transform: translateY(0) scale(1);
473
+ }
474
+ }
475
+
476
+ .toast-icon {
477
+ width: 32px;
478
+ height: 32px;
479
+ border-radius: 50%;
480
+ display: flex;
481
+ align-items: center;
482
+ justify-content: center;
483
+ font-size: 16px;
484
+ flex-shrink: 0;
485
+ }
486
+
487
+ .toast-icon.success {
488
+ background: rgba(16, 185, 129, 0.15);
489
+ color: var(--success);
490
+ }
491
+
492
+ .toast-icon.failed {
493
+ background: rgba(239, 68, 68, 0.15);
494
+ color: var(--error);
495
+ }
496
+
497
+ .toast-content {
498
+ flex: 1;
499
+ min-width: 0;
500
+ }
501
+
502
+ .toast-title {
503
+ font-weight: 600;
504
+ color: var(--text-primary);
505
+ margin-bottom: 2px;
506
+ }
507
+
508
+ .toast-message {
509
+ font-size: 12px;
510
+ color: var(--text-secondary);
511
+ overflow: hidden;
512
+ text-overflow: ellipsis;
513
+ white-space: nowrap;
514
+ }
515
+
516
+ .toast-close {
517
+ width: 24px;
518
+ height: 24px;
519
+ border: none;
520
+ background: transparent;
521
+ color: var(--text-muted);
522
+ cursor: pointer;
523
+ border-radius: 6px;
524
+ display: flex;
525
+ align-items: center;
526
+ justify-content: center;
527
+ font-size: 16px;
528
+ }
529
+
530
+ .toast-close:hover {
531
+ background: rgba(0, 0, 0, 0.05);
532
+ color: var(--text-secondary);
533
+ }
534
+
535
+ /* Hub - Request History */
536
+ .hub {
537
+ position: fixed;
538
+ bottom: 16px;
539
+ left: 16px;
540
+ background: var(--glass-bg);
541
+ backdrop-filter: blur(20px) saturate(180%);
542
+ -webkit-backdrop-filter: blur(20px) saturate(180%);
543
+ border: 1px solid var(--glass-border);
544
+ border-radius: 10px;
545
+ box-shadow: var(--glass-shadow);
546
+ pointer-events: auto;
547
+ min-width: 36px;
548
+ max-width: 200px;
549
+ overflow: hidden;
550
+ animation: hubIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
551
+ cursor: default;
552
+ }
553
+
554
+ .hub *, .hub *::before, .hub *::after {
555
+ cursor: inherit;
556
+ }
557
+
558
+ .hub button {
559
+ cursor: pointer;
560
+ }
561
+
562
+ @keyframes hubIn {
563
+ from {
564
+ opacity: 0;
565
+ transform: translateY(8px) scale(0.96);
566
+ }
567
+ to {
568
+ opacity: 1;
569
+ transform: translateY(0) scale(1);
570
+ }
571
+ }
572
+
573
+ .hub.disabled.collapsed {
574
+ opacity: 0.5;
575
+ }
576
+
577
+ .hub-header {
578
+ display: flex;
579
+ align-items: center;
580
+ justify-content: space-between;
581
+ gap: 6px;
582
+ padding: 6px 8px;
583
+ cursor: pointer;
584
+ user-select: none;
585
+ }
586
+
587
+ .hub-header:hover {
588
+ background: rgba(0, 0, 0, 0.03);
589
+ }
590
+
591
+ .hub-header-left {
592
+ display: flex;
593
+ align-items: center;
594
+ gap: 6px;
595
+ }
596
+
597
+ .hub-logo {
598
+ width: 20px;
599
+ height: 20px;
600
+ border-radius: 5px;
601
+ display: flex;
602
+ align-items: center;
603
+ justify-content: center;
604
+ font-size: 11px;
605
+ color: white;
606
+ flex-shrink: 0;
607
+ }
608
+
609
+ .hub-title {
610
+ font-size: 11px;
611
+ font-weight: 600;
612
+ color: var(--text-primary);
613
+ flex: 1;
614
+ }
615
+
616
+ .hub-badge {
617
+ font-size: 9px;
618
+ font-weight: 600;
619
+ background: var(--accent);
620
+ color: white;
621
+ padding: 1px 5px;
622
+ border-radius: 8px;
623
+ min-width: 14px;
624
+ text-align: center;
625
+ }
626
+
627
+ .hub-toggle {
628
+ width: 16px;
629
+ height: 16px;
630
+ border: none;
631
+ background: transparent;
632
+ color: var(--text-muted);
633
+ cursor: pointer;
634
+ display: flex;
635
+ align-items: center;
636
+ justify-content: center;
637
+ font-size: 10px;
638
+ transition: transform 0.2s;
639
+ }
640
+
641
+ .hub-toggle.expanded {
642
+ transform: rotate(180deg);
643
+ }
644
+
645
+ .hub-disable {
646
+ width: 20px;
647
+ height: 20px;
648
+ border: none;
649
+ background: transparent;
650
+ color: var(--text-muted);
651
+ cursor: pointer;
652
+ border-radius: 4px;
653
+ display: flex;
654
+ align-items: center;
655
+ justify-content: center;
656
+ transition: all 0.15s;
657
+ flex-shrink: 0;
658
+ }
659
+
660
+ .hub-disable:hover {
661
+ background: rgba(0, 0, 0, 0.05);
662
+ color: var(--text-secondary);
663
+ }
664
+
665
+ .hub-disable.active {
666
+ color: var(--accent);
667
+ }
668
+
669
+ .hub-disable svg {
670
+ width: 14px;
671
+ height: 14px;
672
+ }
673
+
674
+ .hub-content {
675
+ border-top: 1px solid var(--divider);
676
+ max-height: 0;
677
+ overflow: hidden;
678
+ transition: max-height 0.25s cubic-bezier(0.4, 0, 0.2, 1);
679
+ }
680
+
681
+ .hub-content.expanded {
682
+ max-height: 220px;
683
+ }
684
+
685
+ .hub-list {
686
+ max-height: 200px;
687
+ overflow-y: auto;
688
+ padding: 4px 0;
689
+ }
690
+
691
+ .hub-list::-webkit-scrollbar {
692
+ width: 6px;
693
+ }
694
+
695
+ .hub-list::-webkit-scrollbar-track {
696
+ background: transparent;
697
+ }
698
+
699
+ .hub-list::-webkit-scrollbar-thumb {
700
+ background: rgba(0, 0, 0, 0.1);
701
+ border-radius: 3px;
702
+ }
703
+
704
+ .hub-item {
705
+ padding: 5px 8px;
706
+ display: flex;
707
+ align-items: center;
708
+ gap: 8px;
709
+ }
710
+
711
+ .hub-item:hover {
712
+ background: rgba(0, 0, 0, 0.02);
713
+ }
714
+
715
+ .hub-item-status {
716
+ width: 6px;
717
+ height: 6px;
718
+ border-radius: 50%;
719
+ flex-shrink: 0;
720
+ }
721
+
722
+ .hub-item-status.pending { background: var(--accent); animation: pulse 1.5s ease-in-out infinite; }
723
+ .hub-item-status.fixing { background: #0ea5e9; animation: pulse 1s ease-in-out infinite; }
724
+ .hub-item-status.success { background: var(--success); }
725
+ .hub-item-status.failed { background: var(--error); }
726
+
727
+ .hub-item-content {
728
+ flex: 1;
729
+ min-width: 0;
730
+ }
731
+
732
+ .hub-item-component {
733
+ font-size: 10px;
734
+ font-weight: 500;
735
+ color: var(--text-secondary);
736
+ }
737
+
738
+ .hub-item-note {
739
+ font-size: 11px;
740
+ color: var(--text-primary);
741
+ word-wrap: break-word;
742
+ }
743
+
744
+ .hub-item-undo {
745
+ width: 18px;
746
+ height: 18px;
747
+ border: none;
748
+ background: transparent;
749
+ color: var(--text-muted);
750
+ cursor: pointer;
751
+ border-radius: 3px;
752
+ display: flex;
753
+ align-items: center;
754
+ justify-content: center;
755
+ font-size: 10px;
756
+ opacity: 0;
757
+ transition: all 0.15s;
758
+ flex-shrink: 0;
759
+ }
760
+
761
+ .hub-item:hover .hub-item-undo {
762
+ opacity: 1;
763
+ }
764
+
765
+ .hub-item-undo:hover {
766
+ background: rgba(239, 68, 68, 0.1);
767
+ color: var(--error);
768
+ }
769
+
770
+ .hub-empty {
771
+ padding: 10px 8px;
772
+ text-align: center;
773
+ font-size: 10px;
774
+ color: var(--text-muted);
775
+ }
776
+
777
+ .hub-settings-btn {
778
+ width: 20px;
779
+ height: 20px;
780
+ border: none;
781
+ background: transparent;
782
+ color: var(--text-muted);
783
+ cursor: pointer;
784
+ border-radius: 4px;
785
+ display: flex;
786
+ align-items: center;
787
+ justify-content: center;
788
+ transition: all 0.15s;
789
+ flex-shrink: 0;
790
+ }
791
+
792
+ .hub-settings-btn:hover {
793
+ background: rgba(0, 0, 0, 0.05);
794
+ color: var(--text-secondary);
795
+ }
796
+
797
+ .hub-settings-btn svg {
798
+ width: 12px;
799
+ height: 12px;
800
+ }
801
+
802
+ /* Settings Page */
803
+ .hub-settings-page {
804
+ padding: 8px 0;
805
+ }
806
+
807
+ .hub-settings-header {
808
+ display: flex;
809
+ align-items: center;
810
+ gap: 6px;
811
+ padding: 4px 8px 8px;
812
+ border-bottom: 1px solid var(--divider);
813
+ }
814
+
815
+ .hub-back-btn {
816
+ width: 20px;
817
+ height: 20px;
818
+ border: none;
819
+ background: transparent;
820
+ color: var(--text-secondary);
821
+ cursor: pointer;
822
+ border-radius: 4px;
823
+ display: flex;
824
+ align-items: center;
825
+ justify-content: center;
826
+ transition: all 0.15s;
827
+ }
828
+
829
+ .hub-back-btn:hover {
830
+ background: rgba(0, 0, 0, 0.05);
831
+ color: var(--text-primary);
832
+ }
833
+
834
+ .hub-settings-title {
835
+ font-size: 11px;
836
+ font-weight: 600;
837
+ color: var(--text-primary);
838
+ }
839
+
840
+ .hub-settings-list {
841
+ padding: 8px;
842
+ }
843
+
844
+ .hub-setting-row {
845
+ display: flex;
846
+ align-items: center;
847
+ justify-content: space-between;
848
+ gap: 8px;
849
+ padding: 6px 0;
850
+ }
851
+
852
+ .hub-setting-row:not(:last-child) {
853
+ border-bottom: 1px solid var(--divider);
854
+ padding-bottom: 10px;
855
+ margin-bottom: 4px;
856
+ }
857
+
858
+ .hub-setting-info {
859
+ flex: 1;
860
+ }
861
+
862
+ .hub-setting-label {
863
+ font-size: 11px;
864
+ font-weight: 500;
865
+ color: var(--text-primary);
866
+ }
867
+
868
+ .hub-setting-desc {
869
+ font-size: 9px;
870
+ color: var(--text-muted);
871
+ margin-top: 2px;
872
+ }
873
+
874
+ .hub-button-group {
875
+ display: flex;
876
+ }
877
+
878
+ /* Collapsed hub (minimal) */
879
+ .hub.collapsed .hub-title,
880
+ .hub.collapsed .hub-toggle {
881
+ display: none;
882
+ }
883
+
884
+ .hub.collapsed .hub-header {
885
+ padding: 5px;
886
+ }
887
+
888
+ .hub.collapsed .hub-header-left {
889
+ gap: 4px;
890
+ }
891
+
892
+ .toggle-switch {
893
+ position: relative;
894
+ width: 32px;
895
+ height: 18px;
896
+ background: #cbd5e1;
897
+ border-radius: 9px;
898
+ cursor: pointer;
899
+ transition: background 0.2s;
900
+ border: none;
901
+ padding: 0;
902
+ }
903
+
904
+ .toggle-switch.active {
905
+ background: var(--accent);
906
+ }
907
+
908
+ .toggle-switch::after {
909
+ content: '';
910
+ position: absolute;
911
+ top: 2px;
912
+ left: 2px;
913
+ width: 14px;
914
+ height: 14px;
915
+ background: white;
916
+ border-radius: 50%;
917
+ transition: transform 0.2s;
918
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
919
+ }
920
+
921
+ .toggle-switch.active::after {
922
+ transform: translateX(14px);
923
+ }
924
+
925
+ /* Success action buttons */
926
+ .success-actions {
927
+ display: flex;
928
+ gap: 6px;
929
+ margin-left: auto;
930
+ }
931
+
932
+ .action-btn {
933
+ padding: 4px 10px;
934
+ border: none;
935
+ border-radius: 6px;
936
+ font-size: 11px;
937
+ font-weight: 600;
938
+ font-family: inherit;
939
+ cursor: pointer;
940
+ transition: all 0.15s;
941
+ }
942
+
943
+ .action-btn-commit {
944
+ background: var(--success);
945
+ color: white;
946
+ }
947
+
948
+ .action-btn-commit:hover {
949
+ background: #059669;
950
+ }
951
+
952
+ .action-btn-undo {
953
+ background: rgba(239, 68, 68, 0.1);
954
+ color: var(--error);
955
+ }
956
+
957
+ .action-btn-undo:hover {
958
+ background: rgba(239, 68, 68, 0.2);
959
+ }
960
+
961
+ /* Follow-up input */
962
+ .followup-area {
963
+ padding: 12px;
964
+ border-top: 1px solid var(--divider);
965
+ background: rgba(16, 185, 129, 0.04);
966
+ }
967
+
968
+ .followup-row {
969
+ display: flex;
970
+ gap: 8px;
971
+ align-items: center;
972
+ }
973
+
974
+ .followup-input {
975
+ flex: 1;
976
+ padding: 8px 12px;
977
+ border: 1px solid rgba(0, 0, 0, 0.08);
978
+ border-radius: var(--border-radius-sm);
979
+ font-size: 12px;
980
+ font-family: inherit;
981
+ background: rgba(255, 255, 255, 0.8);
982
+ color: var(--text-primary);
983
+ outline: none;
984
+ transition: all 0.15s;
985
+ }
986
+
987
+ .followup-input::placeholder {
988
+ color: var(--text-muted);
989
+ }
990
+
991
+ .followup-input:focus {
992
+ border-color: var(--accent);
993
+ box-shadow: 0 0 0 2px var(--accent-soft);
994
+ background: white;
995
+ }
996
+
997
+ .followup-send {
998
+ flex-shrink: 0;
999
+ padding: 9px 16px;
1000
+ border: 1px solid transparent;
1001
+ border-radius: var(--border-radius-sm);
1002
+ background: var(--accent);
1003
+ color: white;
1004
+ font-size: 12px;
1005
+ font-weight: 600;
1006
+ font-family: inherit;
1007
+ cursor: pointer;
1008
+ transition: all 0.15s;
1009
+ }
1010
+
1011
+ .followup-send:hover {
1012
+ background: #4f46e5;
1013
+ }
1014
+
1015
+ .followup-send:disabled {
1016
+ opacity: 0.5;
1017
+ cursor: not-allowed;
1018
+ }
1019
+
1020
+ .followup-done {
1021
+ flex-shrink: 0;
1022
+ width: 32px;
1023
+ height: 32px;
1024
+ padding: 0;
1025
+ border: 1px solid var(--divider);
1026
+ border-radius: var(--border-radius-sm);
1027
+ background: transparent;
1028
+ color: var(--text-secondary);
1029
+ font-size: 14px;
1030
+ font-family: inherit;
1031
+ cursor: pointer;
1032
+ transition: all 0.15s;
1033
+ display: flex;
1034
+ align-items: center;
1035
+ justify-content: center;
1036
+ }
1037
+
1038
+ .followup-done:hover {
1039
+ background: rgba(0, 0, 0, 0.04);
1040
+ }
1041
+
1042
+ /* Multi-select styles */
1043
+ .highlight.multi {
1044
+ border-style: dashed;
1045
+ border-width: 2px;
1046
+ box-shadow:
1047
+ 0 0 0 2px rgba(99, 102, 241, 0.06),
1048
+ 0 2px 6px rgba(99, 102, 241, 0.08);
1049
+ }
1050
+
1051
+ .highlight-badge {
1052
+ position: absolute;
1053
+ top: -10px;
1054
+ left: -10px;
1055
+ width: 20px;
1056
+ height: 20px;
1057
+ background: var(--accent);
1058
+ color: white;
1059
+ font-size: 11px;
1060
+ font-weight: 600;
1061
+ border-radius: 50%;
1062
+ display: flex;
1063
+ align-items: center;
1064
+ justify-content: center;
1065
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
1066
+ }
1067
+
1068
+ .multi-select-icon {
1069
+ width: 24px;
1070
+ height: 24px;
1071
+ border: none;
1072
+ background: transparent;
1073
+ color: var(--text-muted);
1074
+ cursor: pointer;
1075
+ border-radius: 6px;
1076
+ display: flex;
1077
+ align-items: center;
1078
+ justify-content: center;
1079
+ transition: all 0.15s;
1080
+ font-size: 16px;
1081
+ line-height: 1;
1082
+ }
1083
+
1084
+ .multi-select-icon:hover {
1085
+ background: var(--accent-soft);
1086
+ color: var(--accent);
1087
+ }
1088
+
1089
+ .multi-select-icon.active {
1090
+ background: var(--accent);
1091
+ color: white;
1092
+ }
1093
+
1094
+ .selected-list {
1095
+ padding: 8px 16px;
1096
+ border-bottom: 1px solid var(--divider);
1097
+ background: rgba(0, 0, 0, 0.02);
1098
+ }
1099
+
1100
+ .selected-list-header {
1101
+ display: flex;
1102
+ justify-content: space-between;
1103
+ align-items: center;
1104
+ margin-bottom: 8px;
1105
+ }
1106
+
1107
+ .selected-count {
1108
+ font-size: 11px;
1109
+ font-weight: 600;
1110
+ color: var(--text-secondary);
1111
+ }
1112
+
1113
+ .selected-chips {
1114
+ display: flex;
1115
+ flex-wrap: wrap;
1116
+ gap: 6px;
1117
+ }
1118
+
1119
+ .selected-chip {
1120
+ display: flex;
1121
+ align-items: center;
1122
+ gap: 4px;
1123
+ padding: 4px 8px;
1124
+ background: var(--accent-soft);
1125
+ border-radius: 6px;
1126
+ font-size: 11px;
1127
+ color: var(--accent);
1128
+ font-weight: 500;
1129
+ }
1130
+
1131
+ .selected-chip-number {
1132
+ width: 16px;
1133
+ height: 16px;
1134
+ background: var(--accent);
1135
+ color: white;
1136
+ border-radius: 50%;
1137
+ display: flex;
1138
+ align-items: center;
1139
+ justify-content: center;
1140
+ font-size: 10px;
1141
+ font-weight: 600;
1142
+ }
1143
+
1144
+ .selected-chip-remove {
1145
+ width: 16px;
1146
+ height: 16px;
1147
+ border: none;
1148
+ background: transparent;
1149
+ color: var(--accent);
1150
+ cursor: pointer;
1151
+ border-radius: 50%;
1152
+ display: flex;
1153
+ align-items: center;
1154
+ justify-content: center;
1155
+ font-size: 14px;
1156
+ line-height: 1;
1157
+ opacity: 0.7;
1158
+ transition: all 0.15s;
1159
+ padding: 0;
1160
+ }
1161
+
1162
+ .selected-chip-remove:hover {
1163
+ opacity: 1;
1164
+ background: rgba(99, 102, 241, 0.2);
1165
+ }
1166
+
1167
+ .multi-mode-hint {
1168
+ padding: 8px 16px;
1169
+ background: var(--accent-soft);
1170
+ border-bottom: 1px solid var(--divider);
1171
+ font-size: 11px;
1172
+ color: var(--accent);
1173
+ text-align: center;
1174
+ }
1175
+ `,w=class s extends HTMLElement{constructor(){super();this.highlight=null;this.panel=null;this.toast=null;this.hub=null;this.currentElement=null;this.currentSnapshot=null;this.interactionId=null;this.frozen=!1;this.eventSource=null;this.throttleTimeout=null;this.mode="input";this.activityEvents=[];this.currentStatus="idle";this.hubExpanded=!1;this.hubPage="main";this.inspectorEnabled=!0;this.autoCommitEnabled=!0;this.history=[];this.isDragging=!1;this.dragOffset={x:0,y:0};this.customPanelPosition=null;this.multiSelectMode=!1;this.selectedElements=[];this.selectedSnapshots=[];this.multiSelectHighlights=[];this.submittedSnapshots=[];this.cursorStyleElement=null;this.scrollTimeout=null;this.phraseIndex=0;this.phraseInterval=null;this.handlePanelDrag=t=>{if(!this.isDragging||!this.panel)return;let e=Math.max(0,Math.min(t.clientX-this.dragOffset.x,window.innerWidth-340)),i=Math.max(0,Math.min(t.clientY-this.dragOffset.y,window.innerHeight-100));this.customPanelPosition={x:e,y:i},this.panel.style.left=`${e}px`,this.panel.style.top=`${i}px`};this.handlePanelDragEnd=()=>{this.isDragging=!1,document.removeEventListener("mousemove",this.handlePanelDrag),document.removeEventListener("mouseup",this.handlePanelDragEnd)};this.shadow=this.attachShadow({mode:"closed"})}static{this.MAX_SELECTION=5}connectedCallback(){let t=document.createElement("style");t.textContent=X,this.shadow.appendChild(t),this.highlight=document.createElement("div"),this.highlight.className="highlight",this.highlight.style.display="none",this.shadow.appendChild(this.highlight),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleClick=this.handleClick.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handlePanelDragStart=this.handlePanelDragStart.bind(this),this.handleScroll=this.handleScroll.bind(this),document.addEventListener("mousemove",this.handleMouseMove,!0),document.addEventListener("click",this.handleClick,!0),document.addEventListener("keydown",this.handleKeyDown,!0),window.addEventListener("scroll",this.handleScroll,!0),this.loadEnabledState(),this.loadAutoCommitState(),this.loadHistory(),this.renderHub(),this.connectSSE(),this.restoreSession(),this.updateCursor()}saveSession(t){if(!this.interactionId)return;let e={interactionId:this.interactionId,userNote:this._userNote||"",componentName:this.currentSnapshot?.framework.componentName||this.currentSnapshot?.tagName||"element",status:this.currentStatus,message:t,timestamp:Date.now()};try{sessionStorage.setItem(v,JSON.stringify(e))}catch{}}restoreSession(){try{let t=sessionStorage.getItem(v);if(!t)return;let e=JSON.parse(t);if(Date.now()-e.timestamp>K){sessionStorage.removeItem(v);return}(e.status==="success"||e.status==="failed")&&(this.showResultToast(e),sessionStorage.removeItem(v))}catch{}}showResultToast(t){this.toast=document.createElement("div"),this.toast.className="result-toast";let e=t.status==="success",i=e?"\u2713":"\u2715",n=e?"Done!":"Failed";this.toast.innerHTML=`
1176
+ <div class="toast-icon ${t.status}">${i}</div>
1177
+ <div class="toast-content">
1178
+ <div class="toast-title">${n}</div>
1179
+ <div class="toast-message">${this.escapeHtml(t.message||t.userNote)}</div>
1180
+ </div>
1181
+ <button class="toast-close">&times;</button>
1182
+ `,this.toast.querySelector(".toast-close").addEventListener("click",()=>this.hideToast()),this.shadow.appendChild(this.toast),setTimeout(()=>this.hideToast(),4e3)}hideToast(){this.toast&&(this.toast.remove(),this.toast=null)}loadEnabledState(){try{let t=localStorage.getItem(L);t!==null&&(this.inspectorEnabled=t==="true")}catch{}}saveEnabledState(){try{localStorage.setItem(L,String(this.inspectorEnabled))}catch{}}loadAutoCommitState(){try{let t=localStorage.getItem($);t!==null&&(this.autoCommitEnabled=t==="true")}catch{}}saveAutoCommitState(){try{localStorage.setItem($,String(this.autoCommitEnabled))}catch{}}loadHistory(){try{let t=sessionStorage.getItem(P);t&&(this.history=JSON.parse(t))}catch{this.history=[]}}saveHistory(){try{sessionStorage.setItem(P,JSON.stringify(this.history))}catch{}}addToHistory(t){let e=this.history.findIndex(i=>i.interactionId===t.interactionId);e>=0?this.history[e]=t:(this.history.unshift(t),this.history.length>20&&(this.history=this.history.slice(0,20))),this.saveHistory(),this.renderHub()}updateHistoryStatus(t,e){let i=this.history.find(n=>n.interactionId===t);i&&(i.status=e,this.saveHistory(),this.renderHub())}renderHub(){this.hub||(this.hub=document.createElement("div"),this.hub.className="hub",this.shadow.appendChild(this.hub)),this.hubPage==="settings"?this.renderHubSettingsPage():this.renderHubMainPage()}renderHubMainPage(){if(!this.hub)return;let t=this.hubExpanded?"":"collapsed",e=this.inspectorEnabled?"":"disabled",i=this.hubExpanded?"expanded":"",n=this.history.filter(c=>c.status==="pending"||c.status==="fixing").length;this.hub.className=`hub ${t} ${e}`.trim();let o='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>',a='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"/><line x1="1" y1="1" x2="23" y2="23"/></svg>',l='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>',d=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
1183
+ <defs>
1184
+ <linearGradient id="lensGrad" x1="0%" y1="0%" x2="100%" y2="100%">
1185
+ <stop offset="0%" style="stop-color:#60a5fa;stop-opacity:0.3"/>
1186
+ <stop offset="100%" style="stop-color:#3b82f6;stop-opacity:0.1"/>
1187
+ </linearGradient>
1188
+ </defs>
1189
+ <circle cx="30" cy="50" r="20" fill="url(#lensGrad)" stroke="#3b82f6" stroke-width="3"/>
1190
+ <circle cx="70" cy="50" r="20" fill="url(#lensGrad)" stroke="#3b82f6" stroke-width="3"/>
1191
+ <path d="M 50 50 Q 50 42 50 50" stroke="#3b82f6" stroke-width="3" fill="none"/>
1192
+ <line x1="50" y1="47" x2="50" y2="53" stroke="#3b82f6" stroke-width="3" stroke-linecap="round"/>
1193
+ <line x1="10" y1="50" x2="10" y2="50" stroke="#3b82f6" stroke-width="3"/>
1194
+ <path d="M 10 50 L 5 45" stroke="#3b82f6" stroke-width="3" stroke-linecap="round"/>
1195
+ <path d="M 90 50 L 95 45" stroke="#3b82f6" stroke-width="3" stroke-linecap="round"/>
1196
+ <path d="M 65 45 L 65 60 L 69 56 L 74 63 L 76 61 L 71 54 L 76 54 Z" fill="#3b82f6"/>
1197
+ </svg>`;this.hub.innerHTML=`
1198
+ <div class="hub-header">
1199
+ <div class="hub-header-left">
1200
+ <div class="hub-logo">${d}</div>
1201
+ <span class="hub-title">Eyeglass</span>
1202
+ ${n>0?`<span class="hub-badge">${n}</span>`:""}
1203
+ <button class="hub-toggle ${i}" title="Toggle history">\u25BC</button>
1204
+ </div>
1205
+ <div class="hub-button-group">
1206
+ <button class="hub-settings-btn" title="Settings">${l}</button>
1207
+ <button class="hub-disable ${this.inspectorEnabled?"active":""}" title="${this.inspectorEnabled?"Disable":"Enable"} inspector">
1208
+ ${this.inspectorEnabled?o:a}
1209
+ </button>
1210
+ </div>
1211
+ </div>
1212
+ <div class="hub-content ${i}">
1213
+ ${this.history.length>0?`
1214
+ <div class="hub-list">
1215
+ ${this.history.map(c=>`
1216
+ <div class="hub-item" data-id="${c.interactionId}">
1217
+ <div class="hub-item-status ${c.status}"></div>
1218
+ <div class="hub-item-content">
1219
+ <div class="hub-item-component">${this.escapeHtml(c.componentName)}</div>
1220
+ <div class="hub-item-note">${this.escapeHtml(c.userNote)}</div>
1221
+ </div>
1222
+ ${c.status==="success"?`
1223
+ <button class="hub-item-undo" data-id="${c.interactionId}" title="Undo">\u21A9</button>
1224
+ `:""}
1225
+ </div>
1226
+ `).join("")}
1227
+ </div>
1228
+ `:`
1229
+ <div class="hub-empty">No requests yet</div>
1230
+ `}
1231
+ </div>
1232
+ `;let u=this.hub.querySelector(".hub-header"),f=this.hub.querySelector(".hub-disable"),g=this.hub.querySelector(".hub-settings-btn");u.addEventListener("click",c=>{c.target===f||c.target===g||c.target.closest(".hub-settings-btn")||(this.hubExpanded=!this.hubExpanded,this.renderHub())}),g.addEventListener("click",c=>{c.stopPropagation(),this.hubPage="settings",this.hubExpanded=!0,this.renderHub()}),f.addEventListener("click",c=>{c.stopPropagation(),this.inspectorEnabled=!this.inspectorEnabled,this.saveEnabledState(),this.inspectorEnabled||this.unfreeze(),this.updateCursor(),this.renderHub()}),this.hub.querySelectorAll(".hub-item-undo").forEach(c=>{c.addEventListener("click",h=>{h.stopPropagation();let p=h.currentTarget.dataset.id;this.requestUndo(p)})})}renderHubSettingsPage(){if(!this.hub)return;let t=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
1233
+ <defs>
1234
+ <linearGradient id="lensGrad" x1="0%" y1="0%" x2="100%" y2="100%">
1235
+ <stop offset="0%" style="stop-color:#60a5fa;stop-opacity:0.3"/>
1236
+ <stop offset="100%" style="stop-color:#3b82f6;stop-opacity:0.1"/>
1237
+ </linearGradient>
1238
+ </defs>
1239
+ <circle cx="30" cy="50" r="20" fill="url(#lensGrad)" stroke="#3b82f6" stroke-width="3"/>
1240
+ <circle cx="70" cy="50" r="20" fill="url(#lensGrad)" stroke="#3b82f6" stroke-width="3"/>
1241
+ <path d="M 50 50 Q 50 42 50 50" stroke="#3b82f6" stroke-width="3" fill="none"/>
1242
+ <line x1="50" y1="47" x2="50" y2="53" stroke="#3b82f6" stroke-width="3" stroke-linecap="round"/>
1243
+ <line x1="10" y1="50" x2="10" y2="50" stroke="#3b82f6" stroke-width="3"/>
1244
+ <path d="M 10 50 L 5 45" stroke="#3b82f6" stroke-width="3" stroke-linecap="round"/>
1245
+ <path d="M 90 50 L 95 45" stroke="#3b82f6" stroke-width="3" stroke-linecap="round"/>
1246
+ <path d="M 65 45 L 65 60 L 69 56 L 74 63 L 76 61 L 71 54 L 76 54 Z" fill="#3b82f6"/>
1247
+ </svg>`;this.hub.className="hub",this.hub.innerHTML=`
1248
+ <div class="hub-header">
1249
+ <div class="hub-header-left">
1250
+ <div class="hub-logo">${t}</div>
1251
+ <span class="hub-title">Eyeglass</span>
1252
+ </div>
1253
+ </div>
1254
+ <div class="hub-content expanded">
1255
+ <div class="hub-settings-page">
1256
+ <div class="hub-settings-header">
1257
+ <button class="hub-back-btn" title="Back">\u2190</button>
1258
+ <span class="hub-settings-title">Settings</span>
1259
+ </div>
1260
+ <div class="hub-settings-list">
1261
+ <div class="hub-setting-row">
1262
+ <div class="hub-setting-info">
1263
+ <div class="hub-setting-label">Auto-commit</div>
1264
+ <div class="hub-setting-desc">Automatically commit changes on success</div>
1265
+ </div>
1266
+ <button class="toggle-switch ${this.autoCommitEnabled?"active":""}" data-setting="autoCommit"></button>
1267
+ </div>
1268
+ </div>
1269
+ </div>
1270
+ </div>
1271
+ `,this.hub.querySelector(".hub-back-btn").addEventListener("click",()=>{this.hubPage="main",this.renderHub()}),this.hub.querySelectorAll(".toggle-switch").forEach(i=>{i.addEventListener("click",n=>{n.currentTarget.dataset.setting==="autoCommit"&&(this.autoCommitEnabled=!this.autoCommitEnabled,this.saveAutoCommitState(),this.renderHub())})})}async requestUndo(t){let e=this.history.findIndex(i=>i.interactionId===t);if(e!==-1){this.history[e].status="pending",this.saveHistory(),this.renderHub();try{(await fetch(`${b}/undo`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({interactionId:t})})).ok?(this.history.splice(e,1),this.saveHistory(),this.renderHub()):(this.history[e].status="failed",this.saveHistory(),this.renderHub())}catch(i){this.history[e]&&(this.history[e].status="failed",this.saveHistory(),this.renderHub()),console.warn("Undo request failed:",i)}}}async requestCommit(t){let e=this.history.findIndex(i=>i.interactionId===t);try{(await fetch(`${b}/commit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({interactionId:t})})).ok?(e>=0&&(this.history[e].status="success",this.saveHistory(),this.renderHub()),this.unfreeze()):console.warn("Commit request failed")}catch(i){console.warn("Commit request failed:",i)}}disconnectedCallback(){document.removeEventListener("mousemove",this.handleMouseMove,!0),document.removeEventListener("click",this.handleClick,!0),document.removeEventListener("keydown",this.handleKeyDown,!0),window.removeEventListener("scroll",this.handleScroll,!0),this.eventSource?.close(),this.cursorStyleElement&&(this.cursorStyleElement.remove(),this.cursorStyleElement=null)}connectSSE(){this.eventSource=new EventSource(`${b}/events`),this.eventSource.onmessage=t=>{try{let e=JSON.parse(t.data);e.type==="activity"&&this.handleActivityEvent(e.payload)}catch{}},this.eventSource.onerror=()=>{this.eventSource?.close(),setTimeout(()=>this.connectSSE(),3e3)}}handleActivityEvent(t){t.type==="status"&&this.updateHistoryStatus(t.interactionId,t.status),t.interactionId===this.interactionId&&(this.activityEvents.push(t),t.type==="status"&&(this.currentStatus=t.status,this.saveSession(t.message),t.status==="fixing"?this.startPhraseRotation():this.stopPhraseRotation(),t.status==="failed"&&setTimeout(()=>this.unfreeze(),4e3)),this.renderPanel())}handleMouseMove(t){if(!this.multiSelectMode&&this.frozen||!this.inspectorEnabled)return;if(t.composedPath().includes(this)){this.multiSelectMode||this.hideHighlight();return}if(this.throttleTimeout)return;this.throttleTimeout=window.setTimeout(()=>{this.throttleTimeout=null},16),this.style.pointerEvents="none";let i=document.elementFromPoint(t.clientX,t.clientY);if(this.style.pointerEvents="",!i||i===document.documentElement||i===document.body){this.multiSelectMode||this.hideHighlight();return}this.shadow.contains(i)||(this.currentElement=i,this.showHighlight(i))}handleClick(t){if(!(!this.inspectorEnabled||!this.currentElement||t.composedPath().some(i=>i===this))){if(t.preventDefault(),t.stopPropagation(),this.multiSelectMode){this.toggleInSelection(this.currentElement);return}this.frozen||this.freeze()}}handleKeyDown(t){t.key==="Escape"&&this.unfreeze()}handleScroll(){this.frozen&&(this.disableHighlightTransitions(),this.currentElement&&this.highlight&&!this.multiSelectMode&&this.showHighlight(this.currentElement),this.multiSelectMode&&this.selectedElements.length>0&&this.updateMultiSelectHighlightPositions(),this.scrollTimeout&&window.clearTimeout(this.scrollTimeout),this.scrollTimeout=window.setTimeout(()=>{this.enableHighlightTransitions(),this.scrollTimeout=null},150))}disableHighlightTransitions(){this.highlight&&this.highlight.classList.add("no-transition"),this.multiSelectHighlights.forEach(t=>t.classList.add("no-transition"))}enableHighlightTransitions(){this.highlight&&this.highlight.classList.remove("no-transition"),this.multiSelectHighlights.forEach(t=>t.classList.remove("no-transition"))}updateMultiSelectHighlightPositions(){this.selectedElements.forEach((e,i)=>{let n=this.multiSelectHighlights[i];if(!n)return;let o=e.getBoundingClientRect();n.style.left=`${o.left-3}px`,n.style.top=`${o.top-3}px`,n.style.width=`${o.width+3*2}px`,n.style.height=`${o.height+3*2}px`})}handlePanelDragStart(t){if(t.target.closest("button"))return;this.isDragging=!0;let e=this.panel.getBoundingClientRect();this.dragOffset={x:t.clientX-e.left,y:t.clientY-e.top},document.addEventListener("mousemove",this.handlePanelDrag),document.addEventListener("mouseup",this.handlePanelDragEnd)}showHighlight(t){if(!this.highlight)return;let e=t.getBoundingClientRect(),i=3;this.highlight.style.display="block",this.highlight.style.left=`${e.left-i}px`,this.highlight.style.top=`${e.top-i}px`,this.highlight.style.width=`${e.width+i*2}px`,this.highlight.style.height=`${e.height+i*2}px`}hideHighlight(){this.highlight&&(this.highlight.style.display="none"),this.currentElement=null}freeze(){this.currentElement&&(this.frozen=!0,this.currentSnapshot=x(this.currentElement),this.selectedElements=[this.currentElement],this.selectedSnapshots=[this.currentSnapshot],this.mode="input",this.activityEvents=[],this.currentStatus="idle",this.updateCursor(),this.renderPanel())}enterMultiSelectMode(){!this.frozen||this.multiSelectMode||(this.multiSelectMode=!0,this.renderMultiSelectHighlights(),this.updateCursor(),this.renderPanel())}toggleInSelection(t){if(!this.multiSelectMode)return;let e=this.selectedElements.indexOf(t);if(e>=0)this.removeFromSelection(e);else{if(this.selectedElements.length>=s.MAX_SELECTION)return;let i=x(t);this.selectedElements.push(t),this.selectedSnapshots.push(i)}this.renderMultiSelectHighlights(),this.renderPanel()}removeFromSelection(t){if(!(t<0||t>=this.selectedElements.length)){if(this.selectedElements.length===1){this.exitMultiSelectMode();return}this.selectedElements.splice(t,1),this.selectedSnapshots.splice(t,1),this.renderMultiSelectHighlights(),this.renderPanel()}}exitMultiSelectMode(){this.multiSelectMode=!1,this.selectedElements.length>0&&(this.currentElement=this.selectedElements[0],this.currentSnapshot=this.selectedSnapshots[0]),this.selectedElements=this.currentElement?[this.currentElement]:[],this.selectedSnapshots=this.currentSnapshot?[this.currentSnapshot]:[],this.clearMultiSelectHighlights(),this.currentElement&&this.showHighlight(this.currentElement),this.updateCursor(),this.renderPanel()}renderMultiSelectHighlights(){this.clearMultiSelectHighlights();let t=3;this.selectedElements.forEach((e,i)=>{let n=e.getBoundingClientRect(),o=document.createElement("div");o.className="highlight multi",o.style.display="block",o.style.left=`${n.left-t}px`,o.style.top=`${n.top-t}px`,o.style.width=`${n.width+t*2}px`,o.style.height=`${n.height+t*2}px`;let a=document.createElement("div");a.className="highlight-badge",a.textContent=String(i+1),o.appendChild(a),this.shadow.appendChild(o),this.multiSelectHighlights.push(o)}),this.highlight&&(this.highlight.style.display="none")}clearMultiSelectHighlights(){this.multiSelectHighlights.forEach(t=>t.remove()),this.multiSelectHighlights=[]}unfreeze(){this.frozen=!1,this.currentSnapshot=null,this.interactionId=null,this.mode="input",this.activityEvents=[],this.customPanelPosition=null,this.multiSelectMode=!1,this.selectedElements=[],this.selectedSnapshots=[],this.submittedSnapshots=[],this.clearMultiSelectHighlights(),this.stopPhraseRotation(),this.hidePanel(),this.hideHighlight(),this.updateCursor();try{sessionStorage.removeItem(v)}catch{}}renderPanel(){if(!this.currentSnapshot||!this.currentElement)return;let t=this.currentElement.getBoundingClientRect(),{framework:e}=this.currentSnapshot;if(this.panel||(this.panel=document.createElement("div"),this.panel.className="glass-panel",this.shadow.appendChild(this.panel)),this.customPanelPosition)this.panel.style.left=`${this.customPanelPosition.x}px`,this.panel.style.top=`${this.customPanelPosition.y}px`;else{let o=window.innerHeight-t.bottom,a=this.mode==="activity"?400:200,l=t.bottom+12;o<a&&t.top>a&&(l=t.top-a-12);let d=t.left;d+340>window.innerWidth-20&&(d=window.innerWidth-360),d<20&&(d=20),this.panel.style.left=`${d}px`,this.panel.style.top=`${l}px`}let i=e.componentName||this.currentSnapshot.tagName,n=e.filePath?e.filePath.split("/").slice(-2).join("/"):null;this.mode==="input"?this.renderInputMode(i,n):this.renderActivityMode(i,n)}renderInputMode(t,e){if(!this.panel)return;let i=this.multiSelectMode,n=i?"multi-select-icon active":"multi-select-icon",o=i?`
1272
+ <div class="selected-list">
1273
+ <div class="selected-list-header">
1274
+ <span class="selected-count">${this.selectedElements.length} element${this.selectedElements.length!==1?"s":""} selected</span>
1275
+ </div>
1276
+ <div class="selected-chips">
1277
+ ${this.selectedSnapshots.map((h,p)=>{let m=h.framework.componentName||h.tagName;return`
1278
+ <div class="selected-chip" data-index="${p}">
1279
+ <span class="selected-chip-number">${p+1}</span>
1280
+ <span>${this.escapeHtml(m)}</span>
1281
+ <button class="selected-chip-remove" data-index="${p}" title="Remove">&times;</button>
1282
+ </div>
1283
+ `}).join("")}
1284
+ </div>
1285
+ </div>
1286
+ `:"",a=i?`
1287
+ <div class="multi-mode-hint">Click elements to add/remove from selection (max ${s.MAX_SELECTION})</div>
1288
+ `:"";this.panel.innerHTML=`
1289
+ <div class="panel-header">
1290
+ <span class="component-tag">&lt;${this.escapeHtml(t)} /&gt;</span>
1291
+ ${e?`<span class="file-path">${this.escapeHtml(e)}</span>`:""}
1292
+ <button class="${n}" title="${i?"Exit multi-select":"Select multiple elements"}">+</button>
1293
+ <button class="close-btn" title="Cancel (Esc)">&times;</button>
1294
+ </div>
1295
+ ${a}
1296
+ ${o}
1297
+ <div class="input-area">
1298
+ <input
1299
+ type="text"
1300
+ class="input-field"
1301
+ placeholder="${i?"Describe what to change for these elements...":"What do you want to change?"}"
1302
+ autofocus
1303
+ />
1304
+ <div class="btn-row">
1305
+ <button class="btn btn-secondary">Cancel</button>
1306
+ <button class="btn btn-primary">Send</button>
1307
+ </div>
1308
+ </div>
1309
+ `;let l=this.panel.querySelector(".input-field"),d=this.panel.querySelector(".close-btn"),u=this.panel.querySelector(".btn-secondary"),f=this.panel.querySelector(".btn-primary"),g=this.panel.querySelector(".multi-select-icon");d.addEventListener("click",()=>this.unfreeze()),u.addEventListener("click",()=>this.unfreeze()),f.addEventListener("click",()=>this.submit(l.value)),l.addEventListener("keydown",h=>{h.key==="Enter"&&l.value.trim()&&this.submit(l.value)}),g.addEventListener("click",()=>{this.multiSelectMode?this.exitMultiSelectMode():this.enterMultiSelectMode()}),this.panel.querySelectorAll(".selected-chip-remove").forEach(h=>{h.addEventListener("click",p=>{p.stopPropagation();let m=parseInt(p.currentTarget.dataset.index,10);this.removeFromSelection(m)})}),this.panel.querySelector(".panel-header").addEventListener("mousedown",this.handlePanelDragStart),requestAnimationFrame(()=>l.focus())}renderActivityMode(t,e){if(!this.panel)return;let i=this.activityEvents.length>0&&this.panel.querySelector(".user-request-text")?.textContent||"",n=this.currentStatus==="success"||this.currentStatus==="failed",o=this.currentStatus==="success"&&!this.autoCommitEnabled,a=this.currentStatus==="success",l=this.submittedSnapshots.length,d=l>1?`${l} elements`:`&lt;${this.escapeHtml(t)} /&gt;`;this.panel.innerHTML=`
1310
+ <div class="panel-header">
1311
+ <span class="component-tag">${d}</span>
1312
+ ${l<=1&&e?`<span class="file-path">${this.escapeHtml(e)}</span>`:""}
1313
+ <button class="close-btn" title="Close">&times;</button>
1314
+ </div>
1315
+ <div class="user-request">
1316
+ <div class="user-request-label">Your request</div>
1317
+ <div class="user-request-text">${this.escapeHtml(this.getUserNote())}</div>
1318
+ </div>
1319
+ <div class="activity-feed">
1320
+ ${this.renderActivityFeed()}
1321
+ </div>
1322
+ <div class="panel-footer ${n?"done":""}">
1323
+ <div class="status-indicator ${this.currentStatus}"></div>
1324
+ <span class="status-text">${this.getStatusText()}</span>
1325
+ ${o?`
1326
+ <div class="success-actions">
1327
+ <button class="action-btn action-btn-undo" title="Discard changes">Undo</button>
1328
+ <button class="action-btn action-btn-commit" title="Commit changes">Commit</button>
1329
+ </div>
1330
+ `:""}
1331
+ </div>
1332
+ ${a?`
1333
+ <div class="followup-area">
1334
+ <div class="followup-row">
1335
+ <input type="text" class="followup-input" placeholder="Anything else?" />
1336
+ <button class="followup-send">Send</button>
1337
+ <button class="followup-done">\u2715</button>
1338
+ </div>
1339
+ </div>
1340
+ `:""}
1341
+ `,this.panel.querySelector(".close-btn").addEventListener("click",()=>this.unfreeze()),this.panel.querySelector(".panel-header").addEventListener("mousedown",this.handlePanelDragStart),this.panel.querySelectorAll(".question-option").forEach(k=>{k.addEventListener("click",z=>{let E=z.target,A=E.dataset.questionId,q=E.dataset.answerId,D=E.textContent;this.submitAnswer(A,q,D)})});let g=this.panel.querySelector(".action-btn-commit"),c=this.panel.querySelector(".action-btn-undo");g&&this.interactionId&&g.addEventListener("click",()=>this.requestCommit(this.interactionId)),c&&this.interactionId&&c.addEventListener("click",()=>this.requestUndo(this.interactionId));let h=this.panel.querySelector(".followup-input"),p=this.panel.querySelector(".followup-send"),m=this.panel.querySelector(".followup-done");h&&p&&(p.addEventListener("click",()=>{h.value.trim()&&this.submitFollowUp(h.value)}),h.addEventListener("keydown",k=>{k.key==="Enter"&&h.value.trim()&&this.submitFollowUp(h.value)}),requestAnimationFrame(()=>h.focus())),m&&m.addEventListener("click",()=>this.unfreeze());let S=this.panel.querySelector(".activity-feed");S&&(S.scrollTop=S.scrollHeight)}renderActivityFeed(){let t=this.activityEvents.map(e=>{switch(e.type){case"status":return e.status==="pending"||e.status==="fixing"&&(!e.message||e.message==="Agent is working...")?"":this.renderStatusItem(e);case"thought":return this.renderThoughtItem(e);case"action":return this.renderActionItem(e);case"question":return this.renderQuestionItem(e);default:return""}}).filter(Boolean);return t.length===0&&(this.currentStatus==="pending"||this.currentStatus==="fixing")?`
1342
+ <div class="skeleton-item">
1343
+ <div class="skeleton-icon"></div>
1344
+ <div class="skeleton-line"></div>
1345
+ </div>
1346
+ `:t.join("")}renderStatusItem(t){let e=t.status==="success"?"success":t.status==="failed"?"error":"status",i=t.status==="success"?"\u2713":t.status==="failed"?"\u2715":"\u25CF";return`
1347
+ <div class="activity-item">
1348
+ <div class="activity-icon ${e}">${i}</div>
1349
+ <div class="activity-content">
1350
+ <div class="activity-text">${this.escapeHtml(t.message||t.status)}</div>
1351
+ </div>
1352
+ </div>
1353
+ `}renderThoughtItem(t){return`
1354
+ <div class="activity-item">
1355
+ <div class="activity-icon thought">\u{1F4AD}</div>
1356
+ <div class="activity-content">
1357
+ <div class="activity-text muted">${this.escapeHtml(t.content)}</div>
1358
+ </div>
1359
+ </div>
1360
+ `}renderActionItem(t){let e={reading:"\u{1F4D6}",writing:"\u270F\uFE0F",searching:"\u{1F50D}",thinking:"\u{1F9E0}"},i={reading:"Reading",writing:"Writing",searching:"Searching",thinking:"Thinking about"};return`
1361
+ <div class="activity-item">
1362
+ <div class="activity-icon action">${e[t.action]||"\u25CF"}</div>
1363
+ <div class="activity-content">
1364
+ <div class="activity-text">${i[t.action]||t.action}${t.complete?" \u2713":"..."}</div>
1365
+ <div class="activity-target">${this.escapeHtml(t.target)}</div>
1366
+ </div>
1367
+ </div>
1368
+ `}renderQuestionItem(t){return this.activityEvents.some(i=>i.type==="status"&&i.timestamp>t.timestamp)?`
1369
+ <div class="activity-item">
1370
+ <div class="activity-icon question">?</div>
1371
+ <div class="activity-content">
1372
+ <div class="activity-text muted">${this.escapeHtml(t.question)}</div>
1373
+ </div>
1374
+ </div>
1375
+ `:`
1376
+ <div class="question-box">
1377
+ <div class="question-text">${this.escapeHtml(t.question)}</div>
1378
+ <div class="question-options">
1379
+ ${t.options.map(i=>`
1380
+ <button
1381
+ class="question-option"
1382
+ data-question-id="${t.questionId}"
1383
+ data-answer-id="${i.id}"
1384
+ >${this.escapeHtml(i.label)}</button>
1385
+ `).join("")}
1386
+ </div>
1387
+ </div>
1388
+ `}getUserNote(){let t=this.activityEvents.find(e=>e.type==="status");return this._userNote||""}getStatusText(){switch(this.currentStatus){case"idle":return"Ready";case"pending":return"Waiting for agent...";case"fixing":return y[this.phraseIndex%y.length];case"success":return"Done!";case"failed":return"Failed";default:return this.currentStatus}}startPhraseRotation(){this.phraseInterval||(this.phraseIndex=Math.floor(Math.random()*y.length),this.phraseInterval=window.setInterval(()=>{this.phraseIndex=(this.phraseIndex+1)%y.length,this.updateFooterText()},1e4))}stopPhraseRotation(){this.phraseInterval&&(window.clearInterval(this.phraseInterval),this.phraseInterval=null)}updateFooterText(){if(!this.panel)return;let t=this.panel.querySelector(".status-text");t&&(t.textContent=this.getStatusText())}hidePanel(){this.panel&&(this.panel.remove(),this.panel=null)}async submit(t){if(!t.trim()||this.selectedSnapshots.length===0&&!this.currentSnapshot)return;this.interactionId=`eyeglass-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,this._userNote=t.trim();let e=this.selectedSnapshots.length>0?this.selectedSnapshots:this.currentSnapshot?[this.currentSnapshot]:[];this.submittedSnapshots=[...e];let i={interactionId:this.interactionId,userNote:t.trim(),autoCommit:this.autoCommitEnabled,...e.length===1?{snapshot:e[0]}:{snapshots:e}},n=e.map(u=>u.framework.componentName||u.tagName),o=e.length===1?n[0]:`${n.length} elements`;this.addToHistory({interactionId:this.interactionId,userNote:t.trim(),componentName:o,filePath:e[0]?.framework.filePath,status:"pending",timestamp:Date.now()});let a=this.multiSelectMode,l=[...this.selectedElements],d=[...this.selectedSnapshots];this.clearMultiSelectHighlights(),this.multiSelectMode=!1,this.mode="activity",this.activityEvents=[],this.currentStatus="pending",this.renderPanel();try{let u=await fetch(`${b}/focus`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!u.ok)throw new Error(`HTTP ${u.status}`)}catch{this.currentStatus="failed",this.updateHistoryStatus(this.interactionId,"failed"),this.activityEvents.push({type:"status",interactionId:this.interactionId,status:"failed",message:"Failed to connect to bridge",timestamp:Date.now()}),a&&l.length>1&&(this.multiSelectMode=!0,this.selectedElements=l,this.selectedSnapshots=d,this.mode="input",this.renderMultiSelectHighlights()),this.renderPanel()}}async submitFollowUp(t){if(!t.trim()||this.submittedSnapshots.length===0)return;this.interactionId=`eyeglass-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,this._userNote=t.trim();let e=this.submittedSnapshots,i={interactionId:this.interactionId,userNote:t.trim(),autoCommit:this.autoCommitEnabled,...e.length===1?{snapshot:e[0]}:{snapshots:e}},n=e.map(a=>a.framework.componentName||a.tagName),o=e.length===1?n[0]:`${n.length} elements`;this.addToHistory({interactionId:this.interactionId,userNote:t.trim(),componentName:o,filePath:e[0]?.framework.filePath,status:"pending",timestamp:Date.now()}),this.activityEvents=[],this.currentStatus="pending",this.renderPanel();try{let a=await fetch(`${b}/focus`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!a.ok)throw new Error(`HTTP ${a.status}`)}catch{this.currentStatus="failed",this.updateHistoryStatus(this.interactionId,"failed"),this.activityEvents.push({type:"status",interactionId:this.interactionId,status:"failed",message:"Failed to connect to bridge",timestamp:Date.now()}),this.renderPanel()}}async submitAnswer(t,e,i){if(!this.interactionId)return;let n={interactionId:this.interactionId,questionId:t,answerId:e,answerLabel:i};try{await fetch(`${b}/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}catch{}}escapeHtml(t){let e=document.createElement("div");return e.textContent=t,e.innerHTML}updateCursor(){this.inspectorEnabled&&(!this.frozen||this.multiSelectMode)?(this.cursorStyleElement||(this.cursorStyleElement=document.createElement("style"),this.cursorStyleElement.id="eyeglass-cursor-style",document.head.appendChild(this.cursorStyleElement)),this.cursorStyleElement.textContent=`
1389
+ html, body, body * {
1390
+ cursor: ${Z} !important;
1391
+ }
1392
+ `):this.cursorStyleElement&&(this.cursorStyleElement.textContent="")}};customElements.get("eyeglass-inspector")||customElements.define("eyeglass-inspector",w);function N(){if(document.querySelector("eyeglass-inspector")){console.warn("[eyeglass] Inspector already initialized");return}let s=document.createElement("eyeglass-inspector");document.body.appendChild(s),console.log("[eyeglass] Inspector initialized. Hover over elements and click to annotate.")}typeof window<"u"&&typeof document<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",N):N());export{w as EyeglassInspector,x as captureSnapshot,I as extractFrameworkInfo,N as initInspector};