import { DeesElement, customElement, html, css, property, state, type TemplateResult } from '@design.estate/dees-element'; import { RecorderService } from '../services/recorder.service.js'; import type { WccDashboard } from './wcc-dashboard.js'; @customElement('wcc-recording-panel') export class WccRecordingPanel extends DeesElement { // External configuration @property({ attribute: false }) accessor dashboardRef: WccDashboard; // Panel state @state() accessor panelState: 'options' | 'recording' | 'preview' = 'options'; // Recording options @state() accessor recordingMode: 'viewport' | 'screen' = 'viewport'; @state() accessor audioEnabled: boolean = false; @state() accessor selectedMicrophoneId: string = ''; @state() accessor availableMicrophones: MediaDeviceInfo[] = []; @state() accessor audioLevel: number = 0; // Recording state @state() accessor recordingDuration: number = 0; // Preview/trim state @state() accessor previewVideoUrl: string = ''; @state() accessor trimStart: number = 0; @state() accessor trimEnd: number = 0; @state() accessor videoDuration: number = 0; @state() accessor isDraggingTrim: 'start' | 'end' | null = null; @state() accessor isExporting: boolean = false; // Service instance private recorderService: RecorderService; constructor() { super(); this.recorderService = new RecorderService({ onDurationUpdate: (duration) => { this.recordingDuration = duration; this.dispatchEvent(new CustomEvent('duration-update', { detail: { duration }, bubbles: true, composed: true })); }, onRecordingComplete: (blob) => { this.handleRecordingComplete(blob); }, onAudioLevelUpdate: (level) => { this.audioLevel = level; }, onStreamEnded: () => { this.stopRecording(); } }); } public static styles = [ css` :host { /* CSS Variables */ --background: #0a0a0a; --foreground: #e5e5e5; --input: #141414; --primary: #3b82f6; --border: rgba(255, 255, 255, 0.06); --radius-sm: 2px; --radius-md: 4px; --radius-lg: 6px; } /* Recording Options Panel */ .recording-options-panel { position: fixed; right: 16px; bottom: 116px; width: 360px; background: #0c0c0c; border: 1px solid rgba(255, 255, 255, 0.1); border-radius: var(--radius-md); box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4); z-index: 1000; overflow: hidden; font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif; } .recording-options-header { padding: 0.75rem 1rem; background: rgba(255, 255, 255, 0.02); border-bottom: 1px solid rgba(255, 255, 255, 0.05); display: flex; justify-content: space-between; align-items: center; } .recording-options-title { font-size: 0.8rem; font-weight: 500; color: #ccc; } .recording-options-close { width: 24px; height: 24px; background: transparent; border: none; color: #666; cursor: pointer; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); transition: all 0.15s ease; } .recording-options-close:hover { background: rgba(255, 255, 255, 0.05); color: #999; } .recording-options-content { padding: 1rem; } .recording-option-group { margin-bottom: 1rem; } .recording-option-group:last-child { margin-bottom: 0; } .recording-option-label { font-size: 0.7rem; font-weight: 500; color: #888; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.5rem; } .recording-mode-buttons { display: flex; gap: 0.5rem; } .recording-mode-btn { flex: 1; padding: 0.6rem 0.75rem; background: var(--input); border: 1px solid transparent; border-radius: var(--radius-sm); color: #999; font-size: 0.75rem; cursor: pointer; transition: all 0.15s ease; text-align: center; } .recording-mode-btn:hover { border-color: var(--primary); color: #ccc; } .recording-mode-btn.selected { background: rgba(59, 130, 246, 0.15); border-color: var(--primary); color: var(--primary); } .audio-toggle { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; } .audio-toggle input[type="checkbox"] { width: 1rem; height: 1rem; accent-color: var(--primary); } .audio-toggle label { font-size: 0.75rem; color: #999; cursor: pointer; } .microphone-select { width: 100%; padding: 0.5rem 0.75rem; background: var(--input); border: 1px solid transparent; border-radius: var(--radius-sm); color: var(--foreground); font-size: 0.75rem; outline: none; cursor: pointer; transition: all 0.15s ease; } .microphone-select:focus { border-color: var(--primary); } .microphone-select:disabled { opacity: 0.5; cursor: not-allowed; } .audio-level-container { margin-top: 0.75rem; padding: 0.5rem; background: rgba(255, 255, 255, 0.02); border-radius: var(--radius-sm); } .audio-level-label { font-size: 0.65rem; color: #666; margin-bottom: 0.25rem; } .audio-level-bar { height: 8px; background: var(--input); border-radius: 4px; overflow: hidden; } .audio-level-fill { height: 100%; background: linear-gradient(90deg, #22c55e, #84cc16, #eab308); border-radius: 4px; transition: width 0.1s ease; } .start-recording-btn { width: 100%; padding: 0.75rem; background: #dc2626; border: none; border-radius: var(--radius-sm); color: white; font-size: 0.8rem; font-weight: 500; cursor: pointer; transition: all 0.15s ease; margin-top: 1rem; display: flex; align-items: center; justify-content: center; gap: 0.5rem; } .start-recording-btn:hover { background: #b91c1c; } .start-recording-btn .rec-dot { width: 10px; height: 10px; background: white; border-radius: 50%; } /* Preview Modal */ .preview-modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.8); display: flex; align-items: center; justify-content: center; z-index: 1000; backdrop-filter: blur(4px); font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif; } .preview-modal { width: 90%; max-width: 800px; background: #0c0c0c; border: 1px solid rgba(255, 255, 255, 0.1); border-radius: var(--radius-lg); overflow: hidden; box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5); } .preview-modal-header { padding: 1rem 1.25rem; background: rgba(255, 255, 255, 0.02); border-bottom: 1px solid rgba(255, 255, 255, 0.05); display: flex; justify-content: space-between; align-items: center; } .preview-modal-title { font-size: 0.9rem; font-weight: 500; color: #ccc; } .preview-modal-close { width: 28px; height: 28px; background: transparent; border: none; color: #666; cursor: pointer; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); font-size: 1.2rem; transition: all 0.15s ease; } .preview-modal-close:hover { background: rgba(255, 255, 255, 0.05); color: #999; } .preview-modal-content { padding: 1.25rem; } .preview-video-container { background: #000; border-radius: var(--radius-sm); overflow: hidden; aspect-ratio: 16 / 9; } .preview-video { width: 100%; height: 100%; object-fit: contain; } .preview-modal-actions { padding: 1rem 1.25rem; border-top: 1px solid rgba(255, 255, 255, 0.05); display: flex; justify-content: flex-end; gap: 0.75rem; } .preview-btn { padding: 0.6rem 1.25rem; border-radius: var(--radius-sm); font-size: 0.8rem; font-weight: 500; cursor: pointer; transition: all 0.15s ease; } .preview-btn.secondary { background: transparent; border: 1px solid rgba(255, 255, 255, 0.1); color: #999; } .preview-btn.secondary:hover { border-color: rgba(255, 255, 255, 0.2); color: #ccc; } .preview-btn.primary { background: var(--primary); border: none; color: white; } .preview-btn.primary:hover { background: #2563eb; } .preview-btn.primary:disabled { background: #1e3a5f; cursor: not-allowed; opacity: 0.7; } /* Trim Timeline Styles */ .trim-section { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid rgba(255, 255, 255, 0.05); } .trim-section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; } .trim-section-title { font-size: 0.75rem; font-weight: 500; color: #888; text-transform: uppercase; letter-spacing: 0.05em; } .trim-duration-info { font-size: 0.7rem; color: #666; font-family: 'Consolas', 'Monaco', monospace; } .trim-timeline { position: relative; height: 48px; background: var(--input); border-radius: var(--radius-sm); margin-bottom: 0.75rem; user-select: none; } .trim-track { position: absolute; top: 50%; left: 12px; right: 12px; height: 6px; background: #333; transform: translateY(-50%); border-radius: 3px; } .trim-selected { position: absolute; top: 50%; height: 6px; background: var(--primary); transform: translateY(-50%); border-radius: 3px; pointer-events: none; } .trim-handle { position: absolute; top: 50%; width: 16px; height: 36px; background: white; border: 2px solid var(--primary); border-radius: 4px; transform: translate(-50%, -50%); cursor: ew-resize; z-index: 2; display: flex; align-items: center; justify-content: center; transition: background 0.15s ease, transform 0.1s ease; } .trim-handle:hover { background: #e0e0e0; } .trim-handle:active { background: var(--primary); transform: translate(-50%, -50%) scale(1.05); } .trim-handle::before { content: ''; width: 2px; height: 16px; background: #666; border-radius: 1px; } .trim-handle:active::before { background: white; } .trim-time-labels { display: flex; justify-content: space-between; font-size: 0.65rem; color: #666; font-family: 'Consolas', 'Monaco', monospace; padding: 0 12px; } .trim-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; } .trim-action-btn { flex: 1; padding: 0.5rem 0.75rem; background: var(--input); border: 1px solid transparent; border-radius: var(--radius-sm); color: #999; font-size: 0.75rem; cursor: pointer; transition: all 0.15s ease; text-align: center; } .trim-action-btn:hover { border-color: var(--primary); color: #ccc; } .export-spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, 0.3); border-radius: 50%; border-top-color: white; animation: spin 0.8s linear infinite; margin-right: 0.5rem; } @keyframes spin { to { transform: rotate(360deg); } } ` ]; public render(): TemplateResult { if (this.panelState === 'options') { return this.renderOptionsPanel(); } else if (this.panelState === 'preview') { return this.renderPreviewModal(); } return html``; } private renderOptionsPanel(): TemplateResult { return html`
`; } private renderPreviewModal(): TemplateResult { return html` `; } // ==================== Audio Methods ==================== private async handleAudioToggle(enabled: boolean): Promise