import { DeesElement, html, customElement, type TemplateResult, property, state, cssManager, } from '@design.estate/dees-element'; import '../../00group-utility/dees-icon/dees-icon.js'; import { demo } from './demo.js'; declare global { interface HTMLElementTagNameMap { 'dees-audio-viewer': DeesAudioViewer; } } @customElement('dees-audio-viewer') export class DeesAudioViewer extends DeesElement { public static demo = demo; public static demoGroups = ['Media']; @property() accessor src: string = ''; @property() accessor title: string = ''; @property() accessor artist: string = ''; @property({ type: Boolean }) accessor showWaveform: boolean = true; @property({ type: Boolean }) accessor autoplay: boolean = false; @property({ type: Boolean }) accessor loop: boolean = false; @state() accessor isPlaying: boolean = false; @state() accessor currentTime: number = 0; @state() accessor duration: number = 0; @state() accessor volume: number = 1; @state() accessor isMuted: boolean = false; @state() accessor loading: boolean = false; @state() accessor error: string = ''; @state() accessor waveformData: number[] = []; @state() accessor waveformReady: boolean = false; private audioElement: HTMLAudioElement | null = null; private canvasElement: HTMLCanvasElement | null = null; private animFrameId: number = 0; private volumeBeforeMute: number = 1; public render(): TemplateResult { const titleText = this.title && this.artist ? `${this.title} — ${this.artist}` : this.title || this.artist || ''; return html`