@ghchinoy/lit-audio-ui 0.5.1 → 0.6.0

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.
Files changed (40) hide show
  1. package/custom-elements.json +134 -60
  2. package/dist/components/atoms/ui-audio-next-button.js +9 -13
  3. package/dist/components/atoms/ui-audio-play-button.js +10 -14
  4. package/dist/components/atoms/ui-audio-player-error.js +10 -14
  5. package/dist/components/atoms/ui-audio-prev-button.js +9 -13
  6. package/dist/components/atoms/ui-audio-progress-slider.js +16 -20
  7. package/dist/components/atoms/ui-audio-time-display.js +15 -19
  8. package/dist/components/atoms/ui-audio-volume-slider.js +17 -21
  9. package/dist/components/atoms/ui-speech-cancel-button.js +5 -5
  10. package/dist/components/atoms/ui-speech-record-button.js +5 -5
  11. package/dist/components/atoms/ui-timed-text.js +14 -18
  12. package/dist/components/atoms/ui-voice-waveform.js +15 -19
  13. package/dist/components/molecules/ui-live-waveform.js +33 -32
  14. package/dist/components/molecules/ui-mic-selector.js +14 -18
  15. package/dist/components/molecules/ui-playlist.js +15 -19
  16. package/dist/components/molecules/ui-scrolling-waveform.js +30 -29
  17. package/dist/components/molecules/ui-spectrum-visualizer.js +23 -25
  18. package/dist/components/molecules/ui-speech-preview.js +16 -20
  19. package/dist/components/molecules/ui-voice-button.js +25 -29
  20. package/dist/components/molecules/ui-voice-picker.js +21 -25
  21. package/dist/components/molecules/ui-voice-pill.js +5 -5
  22. package/dist/components/molecules/ui-waveform.js +46 -36
  23. package/dist/components/organisms/ui-audio-player.js +7 -11
  24. package/dist/components/providers/ui-audio-provider.js +17 -22
  25. package/dist/components/providers/ui-speech-provider.js +13 -17
  26. package/dist/index.js +36 -36
  27. package/dist/node_modules/@chenglou/pretext/dist/analysis.js +456 -0
  28. package/dist/node_modules/@chenglou/pretext/dist/bidi.js +62 -0
  29. package/dist/node_modules/@chenglou/pretext/dist/layout.js +190 -0
  30. package/dist/node_modules/@chenglou/pretext/dist/line-break.js +234 -0
  31. package/dist/node_modules/@chenglou/pretext/dist/measurement.js +106 -0
  32. package/dist/scream-audio-ui.umd.js +45 -42
  33. package/dist/src/components/molecules/ui-waveform.d.ts +7 -1
  34. package/dist/src/components/providers/ui-audio-provider.d.ts +2 -1
  35. package/dist/src/utils/audio-context.d.ts +0 -1
  36. package/dist/src/utils/audio-utils.d.ts +8 -0
  37. package/dist/standalone/scream-audio-ui.standalone.js +2626 -1655
  38. package/dist/tsconfig.tsbuildinfo +1 -1
  39. package/dist/utils/audio-utils.js +27 -16
  40. package/package.json +7 -4
@@ -1,8 +1,9 @@
1
1
  import { audioPlayerContext as e } from "../../utils/audio-context.js";
2
- import { getNormalizedFrequencyData as t } from "../../utils/audio-utils.js";
3
- import { LitElement as n, css as r, html as i } from "lit";
4
- import { customElement as a, property as o, query as s } from "lit/decorators.js";
5
- import { consume as c } from "@lit/context";
2
+ import { __decorate as t } from "../../_virtual/_@oxc-project_runtime@0.113.0/helpers/decorate.js";
3
+ import { getNormalizedFrequencyData as n } from "../../utils/audio-utils.js";
4
+ import { LitElement as r, css as i, html as a } from "lit";
5
+ import { customElement as o, property as s, query as c } from "lit/decorators.js";
6
+ import { consume as l } from "@lit/context";
6
7
  /**
7
8
  * Copyright 2026 Google LLC
8
9
  *
@@ -18,17 +19,12 @@ import { consume as c } from "@lit/context";
18
19
  * See the License for the specific language governing permissions and
19
20
  * limitations under the License.
20
21
  */
21
- var l = function(e, t, n, r) {
22
- var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
23
- if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
24
- else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
25
- return i > 3 && a && Object.defineProperty(t, n, a), a;
26
- }, u = class extends n {
27
- constructor() {
28
- super(...arguments), this.barWidth = 4, this.barGap = 2, this._animationFrameId = 0;
22
+ var u = class extends r {
23
+ constructor(...e) {
24
+ super(...e), this.barWidth = 4, this.barGap = 2, this._animationFrameId = 0;
29
25
  }
30
26
  static {
31
- this.styles = r`
27
+ this.styles = i`
32
28
  :host {
33
29
  display: block;
34
30
  width: 100%;
@@ -43,7 +39,7 @@ var l = function(e, t, n, r) {
43
39
  `;
44
40
  }
45
41
  render() {
46
- return i`<canvas style="height: ${this.height === void 0 ? "100%" : typeof this.height == "number" || !isNaN(Number(this.height)) ? `${this.height}px` : this.height};"></canvas>`;
42
+ return a`<canvas style="height: ${this.height === void 0 ? "100%" : typeof this.height == "number" || !isNaN(Number(this.height)) ? `${this.height}px` : this.height};"></canvas>`;
47
43
  }
48
44
  firstUpdated() {
49
45
  this._startLoop();
@@ -61,20 +57,22 @@ var l = function(e, t, n, r) {
61
57
  if (!this._canvas || !this.playerState?.analyserNode) return;
62
58
  let e = this.playerState.analyserNode;
63
59
  this._dataArray ||= new Uint8Array(e.frequencyBinCount);
64
- let n = this._canvas.getContext("2d");
65
- if (!n) return;
66
- let r = this._canvas.getBoundingClientRect(), i = window.devicePixelRatio || 1;
67
- this._canvas.width !== r.width * i && (this._canvas.width = r.width * i, this._canvas.height = r.height * i, n.scale(i, i)), n.clearRect(0, 0, r.width, r.height);
68
- let a = t(e, this._dataArray), o = this.barWidth + this.barGap, s = Math.floor(r.width / o), c = getComputedStyle(this), l = this.color;
69
- l ||= c.getPropertyValue("--md-sys-color-primary").trim() || "#0066cc", n.fillStyle = l;
70
- for (let e = 0; e < s; e++) {
71
- let t = (a[Math.floor(e / s * (a.length * .6))] || 0) * r.height, i = e * o, c = r.height - t;
72
- n.fillRect(i, c, this.barWidth, t);
60
+ let t = this._canvas.getContext("2d");
61
+ if (!t) return;
62
+ let r = this.getBoundingClientRect();
63
+ if (r.width === 0 || r.height === 0) return;
64
+ let i = window.devicePixelRatio || 1, a = Math.round(r.width * i), o = Math.round(r.height * i);
65
+ this._canvas.width !== a || this._canvas.height !== o ? (this._canvas.width = a, this._canvas.height = o, this._canvas.style.width = `${r.width}px`, this._canvas.style.height = `${r.height}px`, t.scale(i, i)) : t.clearRect(0, 0, r.width, r.height);
66
+ let s = n(e, this._dataArray), c = this.barWidth + this.barGap, l = Math.floor(r.width / c), u = getComputedStyle(this), d = this.color;
67
+ d ||= u.getPropertyValue("--md-sys-color-primary").trim() || "#0066cc", t.fillStyle = d;
68
+ for (let e = 0; e < l; e++) {
69
+ let n = (s[Math.floor(e / l * (s.length * .6))] || 0) * r.height, i = e * c, a = r.height - n;
70
+ t.fillRect(i, a, this.barWidth, n);
73
71
  }
74
72
  }
75
73
  };
76
- l([c({
74
+ t([l({
77
75
  context: e,
78
76
  subscribe: !0
79
- })], u.prototype, "playerState", void 0), l([o({ type: Number })], u.prototype, "barWidth", void 0), l([o({ type: Number })], u.prototype, "barGap", void 0), l([o()], u.prototype, "height", void 0), l([o({ type: String })], u.prototype, "color", void 0), l([s("canvas")], u.prototype, "_canvas", void 0), u = l([a("ui-spectrum-visualizer")], u);
77
+ })], u.prototype, "playerState", void 0), t([s({ type: Number })], u.prototype, "barWidth", void 0), t([s({ type: Number })], u.prototype, "barGap", void 0), t([s()], u.prototype, "height", void 0), t([s({ type: String })], u.prototype, "color", void 0), t([c("canvas")], u.prototype, "_canvas", void 0), u = t([o("ui-spectrum-visualizer")], u);
80
78
  export { u as UiSpectrumVisualizer };
@@ -1,19 +1,15 @@
1
- import { speechContext as e } from "../../utils/speech-context.js";
1
+ import { __decorate as e } from "../../_virtual/_@oxc-project_runtime@0.113.0/helpers/decorate.js";
2
+ import { speechContext as t } from "../../utils/speech-context.js";
2
3
  import "./ui-live-waveform.js";
3
- import { LitElement as t, css as n, html as r } from "lit";
4
- import { customElement as i, property as a } from "lit/decorators.js";
5
- import { consume as o } from "@lit/context";
6
- var s = function(e, t, n, r) {
7
- var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
8
- if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
9
- else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
10
- return i > 3 && a && Object.defineProperty(t, n, a), a;
11
- }, c = class extends t {
12
- constructor() {
13
- super(...arguments), this.placeholder = "Jot down some thoughts...";
4
+ import { LitElement as n, css as r, html as i } from "lit";
5
+ import { customElement as a, property as o } from "lit/decorators.js";
6
+ import { consume as s } from "@lit/context";
7
+ var c = class extends n {
8
+ constructor(...e) {
9
+ super(...e), this.placeholder = "Jot down some thoughts...";
14
10
  }
15
11
  static {
16
- this.styles = n`
12
+ this.styles = r`
17
13
  :host {
18
14
  display: inline-flex;
19
15
  align-items: center;
@@ -59,9 +55,9 @@ var s = function(e, t, n, r) {
59
55
  `;
60
56
  }
61
57
  render() {
62
- let { state: e = "idle", transcript: t = "", partialTranscript: n = "", analyserNode: i = void 0 } = this._context || {}, a = e === "recording", o = e === "processing" || e === "connecting";
63
- return r`
64
- ${!a && !o && !(t || n) ? r`<span class="placeholder">${this.placeholder}</span>` : r`<span class="transcript">${n || t}</span>`}
58
+ let { state: e = "idle", transcript: t = "", partialTranscript: n = "", analyserNode: r = void 0 } = this._context || {}, a = e === "recording", o = e === "processing" || e === "connecting";
59
+ return i`
60
+ ${!a && !o && !(t || n) ? i`<span class="placeholder">${this.placeholder}</span>` : i`<span class="transcript">${n || t}</span>`}
65
61
 
66
62
  <div
67
63
  class="waveform-container ${a || o ? "" : "hidden"}"
@@ -69,7 +65,7 @@ var s = function(e, t, n, r) {
69
65
  <ui-live-waveform
70
66
  .active=${a}
71
67
  .processing=${o}
72
- .analyserNode=${i}
68
+ .analyserNode=${r}
73
69
  barWidth="2"
74
70
  barGap="1"
75
71
  height="20"
@@ -79,8 +75,8 @@ var s = function(e, t, n, r) {
79
75
  `;
80
76
  }
81
77
  };
82
- s([o({
83
- context: e,
78
+ e([s({
79
+ context: t,
84
80
  subscribe: !0
85
- })], c.prototype, "_context", void 0), s([a({ type: String })], c.prototype, "placeholder", void 0), c = s([i("ui-speech-preview")], c);
81
+ })], c.prototype, "_context", void 0), e([o({ type: String })], c.prototype, "placeholder", void 0), c = e([a("ui-speech-preview")], c);
86
82
  export { c as UiSpeechPreview };
@@ -1,26 +1,22 @@
1
- import { speechContext as e } from "../../utils/speech-context.js";
1
+ import { __decorate as e } from "../../_virtual/_@oxc-project_runtime@0.113.0/helpers/decorate.js";
2
+ import { speechContext as t } from "../../utils/speech-context.js";
2
3
  import "./ui-live-waveform.js";
3
4
  import "@material/web/icon/icon.js";
4
- import { LitElement as t, css as n, html as r } from "lit";
5
- import { customElement as i, property as a, state as o } from "lit/decorators.js";
6
- import { consume as s } from "@lit/context";
5
+ import { LitElement as n, css as r, html as i } from "lit";
6
+ import { customElement as a, property as o, state as s } from "lit/decorators.js";
7
+ import { consume as c } from "@lit/context";
7
8
  import "@material/web/button/outlined-button.js";
8
- import { classMap as c } from "lit/directives/class-map.js";
9
+ import { classMap as l } from "lit/directives/class-map.js";
9
10
  import "@material/web/button/filled-button.js";
10
11
  /**
11
12
  * Copyright 2026 Google LLC
12
13
  */
13
- var l = function(e, t, n, r) {
14
- var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
15
- if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
16
- else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
17
- return i > 3 && a && Object.defineProperty(t, n, a), a;
18
- }, u = class extends t {
19
- constructor() {
20
- super(...arguments), this.state = "idle", this.disabled = !1, this._showFeedback = !1, this._feedbackType = null;
14
+ var u = class extends n {
15
+ constructor(...e) {
16
+ super(...e), this.state = "idle", this.disabled = !1, this._showFeedback = !1, this._feedbackType = null;
21
17
  }
22
18
  static {
23
- this.styles = n`
19
+ this.styles = r`
24
20
  :host {
25
21
  display: inline-block;
26
22
  --ui-waveform-height: 24px;
@@ -98,29 +94,29 @@ var l = function(e, t, n, r) {
98
94
  }, 1500));
99
95
  }
100
96
  render() {
101
- let e = this._context?.state || this.state, t = e === "recording", n = e === "processing" || e === "connecting", i = t || n, a = this.disabled || n, o = {
97
+ let e = this._context?.state || this.state, t = e === "recording", n = e === "processing" || e === "connecting", r = t || n, a = this.disabled || n, o = {
102
98
  recording: t,
103
99
  processing: n,
104
100
  success: this._feedbackType === "success",
105
101
  error: this._feedbackType === "error"
106
102
  }, s = {
107
103
  "waveform-slot": !0,
108
- active: i
109
- }, l = this._context?.analyserNode || this.analyserNode;
110
- return r`
104
+ active: r
105
+ }, c = this._context?.analyserNode || this.analyserNode;
106
+ return i`
111
107
  <md-filled-button
112
- class=${c(o)}
108
+ class=${l(o)}
113
109
  ?disabled=${a}
114
110
  @click=${this._handleClick}
115
111
  >
116
- <div class="wrapper ${i ? "active" : ""}">
117
- ${this.label ? r`<span>${this.label}</span>` : ""}
118
- <div class=${c(s)}>
119
- ${i ? r`
112
+ <div class="wrapper ${r ? "active" : ""}">
113
+ ${this.label ? i`<span>${this.label}</span>` : ""}
114
+ <div class=${l(s)}>
115
+ ${r ? i`
120
116
  <ui-live-waveform
121
117
  .active=${t}
122
118
  .processing=${n}
123
- .analyserNode=${l}
119
+ .analyserNode=${c}
124
120
  .barWidth=${2}
125
121
  .barGap=${1}
126
122
  barColor="currentColor"
@@ -129,10 +125,10 @@ var l = function(e, t, n, r) {
129
125
  ></ui-live-waveform>
130
126
  ` : ""}
131
127
  </div>
132
- ${this._showFeedback && this._feedbackType === "success" ? r`<div class="feedback-overlay success">
128
+ ${this._showFeedback && this._feedbackType === "success" ? i`<div class="feedback-overlay success">
133
129
  <md-icon>check</md-icon>
134
130
  </div>` : ""}
135
- ${this._showFeedback && this._feedbackType === "error" ? r`<div class="feedback-overlay error">
131
+ ${this._showFeedback && this._feedbackType === "error" ? i`<div class="feedback-overlay error">
136
132
  <md-icon>close</md-icon>
137
133
  </div>` : ""}
138
134
  </div>
@@ -147,8 +143,8 @@ var l = function(e, t, n, r) {
147
143
  }));
148
144
  }
149
145
  };
150
- l([s({
151
- context: e,
146
+ e([c({
147
+ context: t,
152
148
  subscribe: !0
153
- })], u.prototype, "_context", void 0), l([a({ type: String })], u.prototype, "state", void 0), l([a({ type: String })], u.prototype, "label", void 0), l([a({ type: String })], u.prototype, "trailing", void 0), l([a({ type: Boolean })], u.prototype, "disabled", void 0), l([a({ attribute: !1 })], u.prototype, "analyserNode", void 0), l([o()], u.prototype, "_showFeedback", void 0), l([o()], u.prototype, "_feedbackType", void 0), u = l([i("ui-voice-button")], u);
149
+ })], u.prototype, "_context", void 0), e([o({ type: String })], u.prototype, "state", void 0), e([o({ type: String })], u.prototype, "label", void 0), e([o({ type: String })], u.prototype, "trailing", void 0), e([o({ type: Boolean })], u.prototype, "disabled", void 0), e([o({ attribute: !1 })], u.prototype, "analyserNode", void 0), e([s()], u.prototype, "_showFeedback", void 0), e([s()], u.prototype, "_feedbackType", void 0), u = e([a("ui-voice-button")], u);
154
150
  export { u as UiVoiceButton };
@@ -1,7 +1,8 @@
1
+ import { __decorate as e } from "../../_virtual/_@oxc-project_runtime@0.113.0/helpers/decorate.js";
1
2
  import "./ui-live-waveform.js";
2
3
  import "@material/web/icon/icon.js";
3
- import { LitElement as e, css as t, html as n } from "lit";
4
- import { customElement as r, property as i, query as a, state as o } from "lit/decorators.js";
4
+ import { LitElement as t, css as n, html as r } from "lit";
5
+ import { customElement as i, property as a, query as o, state as s } from "lit/decorators.js";
5
6
  import "@material/web/menu/menu.js";
6
7
  import "@material/web/menu/menu-item.js";
7
8
  import "@material/web/button/outlined-button.js";
@@ -21,17 +22,12 @@ import "@material/web/textfield/outlined-text-field.js";
21
22
  * See the License for the specific language governing permissions and
22
23
  * limitations under the License.
23
24
  */
24
- var s = function(e, t, n, r) {
25
- var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
26
- if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
27
- else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
28
- return i > 3 && a && Object.defineProperty(t, n, a), a;
29
- }, c = class extends e {
30
- constructor() {
31
- super(...arguments), this.voices = [], this.placeholder = "Select a voice...", this.idKey = "voiceId", this.titleKey = "name", this.subtitleKey = "category", this.previewUrlKey = "previewUrl", this.useOrbs = !1, this.colorKey = "colors", this._searchQuery = "";
25
+ var c = class extends t {
26
+ constructor(...e) {
27
+ super(...e), this.voices = [], this.placeholder = "Select a voice...", this.idKey = "voiceId", this.titleKey = "name", this.subtitleKey = "category", this.previewUrlKey = "previewUrl", this.useOrbs = !1, this.colorKey = "colors", this._searchQuery = "";
32
28
  }
33
29
  static {
34
- this.styles = t`
30
+ this.styles = n`
35
31
  :host {
36
32
  display: inline-block;
37
33
  width: 100%;
@@ -239,7 +235,7 @@ var s = function(e, t, n, r) {
239
235
  let t = this._searchQuery.toLowerCase();
240
236
  return e[this.titleKey].toLowerCase().includes(t) || e.labels?.accent?.toLowerCase().includes(t) || e.labels?.gender?.toLowerCase().includes(t) || e.labels?.age?.toLowerCase().includes(t);
241
237
  });
242
- return n`
238
+ return r`
243
239
  <!-- Hidden audio player for previews -->
244
240
  <audio
245
241
  crossorigin="anonymous"
@@ -258,22 +254,22 @@ var s = function(e, t, n, r) {
258
254
  >
259
255
  <div class="trigger-content">
260
256
  <div class="trigger-left">
261
- ${e ? n`
257
+ ${e ? r`
262
258
  <div
263
259
  class="trigger-icon"
264
260
  style="${this.useOrbs ? "overflow: hidden;" : ""}"
265
261
  >
266
- ${this.useOrbs ? n`<ui-orb
262
+ ${this.useOrbs ? r`<ui-orb
267
263
  agentState="listening"
268
264
  .colors="${e[this.colorKey] || ["#CADCFC", "#A0B9D1"]}"
269
- ></ui-orb>` : n`<md-icon style="font-size: 16px;"
265
+ ></ui-orb>` : r`<md-icon style="font-size: 16px;"
270
266
  >record_voice_over</md-icon
271
267
  >`}
272
268
  </div>
273
269
  <span class="trigger-text"
274
270
  >${e[this.titleKey] || e.name}</span
275
271
  >
276
- ` : n`
272
+ ` : r`
277
273
  <span
278
274
  class="trigger-text"
279
275
  style="color: var(--md-sys-color-on-surface-variant)"
@@ -310,7 +306,7 @@ var s = function(e, t, n, r) {
310
306
  </md-outlined-text-field>
311
307
  </div>
312
308
 
313
- ${t.length === 0 ? n` <div class="empty-state">No voice found.</div> ` : t.map((e) => n`
309
+ ${t.length === 0 ? r` <div class="empty-state">No voice found.</div> ` : t.map((e) => r`
314
310
  <md-menu-item
315
311
  @click=${() => this._selectVoice(e[this.idKey])}
316
312
  ?selected=${this.value === e[this.idKey]}
@@ -323,13 +319,13 @@ var s = function(e, t, n, r) {
323
319
  role="button"
324
320
  @click=${(t) => this._togglePreview(t, e)}
325
321
  >
326
- ${this.useOrbs ? n`<ui-orb
322
+ ${this.useOrbs ? r`<ui-orb
327
323
  agentState="${this._previewingVoiceId === e[this.idKey] ? "talking" : "listening"}"
328
324
  .colors="${e[this.colorKey] || ["#CADCFC", "#A0B9D1"]}"
329
- ></ui-orb>` : n`<md-icon style="font-size: 18px;"
325
+ ></ui-orb>` : r`<md-icon style="font-size: 18px;"
330
326
  >face</md-icon
331
327
  >`}
332
- ${e[this.previewUrlKey] ? n`
328
+ ${e[this.previewUrlKey] ? r`
333
329
  <div
334
330
  class="play-overlay ${this._previewingVoiceId === e[this.idKey] ? "active" : ""}"
335
331
  >
@@ -343,11 +339,11 @@ var s = function(e, t, n, r) {
343
339
  <!-- Voice Info -->
344
340
  <div class="voice-info">
345
341
  <span class="voice-name">${e[this.titleKey]}</span>
346
- ${e[this.subtitleKey] || e.labels ? n`
342
+ ${e[this.subtitleKey] || e.labels ? r`
347
343
  <div class="voice-labels">
348
- ${e[this.subtitleKey] ? n`<span class="voice-badge"
344
+ ${e[this.subtitleKey] ? r`<span class="voice-badge"
349
345
  >${e[this.subtitleKey]}</span
350
- >` : Object.values(e.labels || {}).filter(Boolean).map((e) => n`<span class="voice-badge"
346
+ >` : Object.values(e.labels || {}).filter(Boolean).map((e) => r`<span class="voice-badge"
351
347
  >${e}</span
352
348
  >`)}
353
349
  </div>
@@ -355,7 +351,7 @@ var s = function(e, t, n, r) {
355
351
  </div>
356
352
  </div>
357
353
 
358
- ${this.value === e[this.idKey] ? n`<md-icon slot="end">check</md-icon>` : ""}
354
+ ${this.value === e[this.idKey] ? r`<md-icon slot="end">check</md-icon>` : ""}
359
355
  </md-menu-item>
360
356
  `)}
361
357
  </md-menu>
@@ -381,5 +377,5 @@ var s = function(e, t, n, r) {
381
377
  this._audioEl && (this._audioEl.pause(), this._audioEl.currentTime = 0), this._previewingVoiceId = void 0;
382
378
  }
383
379
  };
384
- s([i({ type: Array })], c.prototype, "voices", void 0), s([i({ type: String })], c.prototype, "value", void 0), s([i({ type: String })], c.prototype, "placeholder", void 0), s([i({ type: String })], c.prototype, "idKey", void 0), s([i({ type: String })], c.prototype, "titleKey", void 0), s([i({ type: String })], c.prototype, "subtitleKey", void 0), s([i({ type: String })], c.prototype, "previewUrlKey", void 0), s([i({ type: Boolean })], c.prototype, "useOrbs", void 0), s([i({ type: String })], c.prototype, "colorKey", void 0), s([o()], c.prototype, "_searchQuery", void 0), s([o()], c.prototype, "_previewingVoiceId", void 0), s([a("md-menu")], c.prototype, "_menuEl", void 0), s([a("audio")], c.prototype, "_audioEl", void 0), c = s([r("ui-voice-picker")], c);
380
+ e([a({ type: Array })], c.prototype, "voices", void 0), e([a({ type: String })], c.prototype, "value", void 0), e([a({ type: String })], c.prototype, "placeholder", void 0), e([a({ type: String })], c.prototype, "idKey", void 0), e([a({ type: String })], c.prototype, "titleKey", void 0), e([a({ type: String })], c.prototype, "subtitleKey", void 0), e([a({ type: String })], c.prototype, "previewUrlKey", void 0), e([a({ type: Boolean })], c.prototype, "useOrbs", void 0), e([a({ type: String })], c.prototype, "colorKey", void 0), e([s()], c.prototype, "_searchQuery", void 0), e([s()], c.prototype, "_previewingVoiceId", void 0), e([o("md-menu")], c.prototype, "_menuEl", void 0), e([o("audio")], c.prototype, "_audioEl", void 0), c = e([i("ui-voice-picker")], c);
385
381
  export { c as UiVoicePicker };
@@ -1,5 +1,5 @@
1
- import { speechContext as e } from "../../utils/speech-context.js";
2
- import { __decorate as t } from "../../_virtual/_@oxc-project_runtime@0.113.0/helpers/decorate.js";
1
+ import { __decorate as e } from "../../_virtual/_@oxc-project_runtime@0.113.0/helpers/decorate.js";
2
+ import { speechContext as t } from "../../utils/speech-context.js";
3
3
  import "../atoms/ui-speech-record-button.js";
4
4
  import "../atoms/ui-speech-cancel-button.js";
5
5
  import "../atoms/ui-voice-waveform.js";
@@ -110,8 +110,8 @@ var l = class extends n {
110
110
  `;
111
111
  }
112
112
  };
113
- t([c({
114
- context: e,
113
+ e([c({
114
+ context: t,
115
115
  subscribe: !0
116
- })], l.prototype, "_context", void 0), t([o({ type: String })], l.prototype, "label", void 0), t([o({ type: Boolean })], l.prototype, "disabled", void 0), t([s()], l.prototype, "_showFeedback", void 0), t([s()], l.prototype, "_feedbackType", void 0), l = t([a("ui-voice-pill")], l);
116
+ })], l.prototype, "_context", void 0), e([o({ type: String })], l.prototype, "label", void 0), e([o({ type: Boolean })], l.prototype, "disabled", void 0), e([s()], l.prototype, "_showFeedback", void 0), e([s()], l.prototype, "_feedbackType", void 0), l = e([a("ui-voice-pill")], l);
117
117
  export { l as UiVoicePill };
@@ -1,6 +1,8 @@
1
- import { applyCanvasEdgeFade as e } from "../../utils/audio-utils.js";
2
- import { LitElement as t, css as n, html as r } from "lit";
3
- import { customElement as i, property as a, query as o } from "lit/decorators.js";
1
+ import { __decorate as e } from "../../_virtual/_@oxc-project_runtime@0.113.0/helpers/decorate.js";
2
+ import { applyCanvasEdgeFade as t, computeAudioPeaks as n } from "../../utils/audio-utils.js";
3
+ import { layoutWithLines as r, prepareWithSegments as i } from "../../node_modules/@chenglou/pretext/dist/layout.js";
4
+ import { LitElement as a, css as o, html as s } from "lit";
5
+ import { customElement as c, property as l, query as u, state as d } from "lit/decorators.js";
4
6
  /**
5
7
  * Copyright 2026 Google LLC
6
8
  *
@@ -16,17 +18,12 @@ import { customElement as i, property as a, query as o } from "lit/decorators.js
16
18
  * See the License for the specific language governing permissions and
17
19
  * limitations under the License.
18
20
  */
19
- var s = function(e, t, n, r) {
20
- var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
21
- if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
22
- else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
23
- return i > 3 && a && Object.defineProperty(t, n, a), a;
24
- }, c = class extends t {
25
- constructor() {
26
- super(...arguments), this.data = [], this.barWidth = 4, this.barHeight = 4, this.barGap = 2, this.barRadius = 2, this.align = "center", this.fadeEdges = !0, this.fadeWidth = 24;
21
+ var f = class extends a {
22
+ constructor(...e) {
23
+ super(...e), this.data = [], this.barWidth = 4, this.barHeight = 4, this.barGap = 2, this.barRadius = 2, this.align = "center", this.fadeEdges = !0, this.fadeWidth = 24, this.overlayFont = "14px Inter, sans-serif", this.overlayColor = "#ffffff", this._computedPeaks = null, this._preparedOverlayText = null;
27
24
  }
28
25
  static {
29
- this.styles = n`
26
+ this.styles = o`
30
27
  :host {
31
28
  display: block;
32
29
  width: 100%;
@@ -48,7 +45,7 @@ var s = function(e, t, n, r) {
48
45
  `;
49
46
  }
50
47
  render() {
51
- return r`
48
+ return s`
52
49
  <div class="container" style="height: ${this.height === void 0 ? "100%" : typeof this.height == "number" || !isNaN(Number(this.height)) ? `${this.height}px` : this.height};">
53
50
  <canvas></canvas>
54
51
  </div>
@@ -59,37 +56,50 @@ var s = function(e, t, n, r) {
59
56
  this._handleResize();
60
57
  }), this._resizeObserver.observe(this._container);
61
58
  }
62
- updated(e) {
63
- super.updated(e), (e.has("data") || e.has("peaks") || e.has("barColor") || e.has("align")) && this._renderWaveform();
59
+ async updated(e) {
60
+ super.updated(e);
61
+ let t = !1;
62
+ if ((e.has("overlayText") || e.has("overlayFont")) && (this.overlayText ? this._preparedOverlayText = i(this.overlayText, this.overlayFont, { whiteSpace: "pre-wrap" }) : this._preparedOverlayText = null, t = !0), e.has("src") && this.src) {
63
+ this._computedPeaks = null, this._renderWaveform();
64
+ try {
65
+ let e = this._container?.getBoundingClientRect().width || 800, t = Math.max(10, Math.floor(e / (this.barWidth + this.barGap)));
66
+ this._computedPeaks = await n(this.src, t);
67
+ } catch (e) {
68
+ console.error("Failed to compute audio peaks for src:", this.src, e);
69
+ }
70
+ }
71
+ (t || e.has("data") || e.has("peaks") || e.has("src") || e.has("barColor") || e.has("align") || e.has("_computedPeaks") || e.has("overlayColor")) && this._renderWaveform();
64
72
  }
65
73
  disconnectedCallback() {
66
74
  super.disconnectedCallback(), this._resizeObserver && this._resizeObserver.disconnect();
67
75
  }
68
76
  _handleResize() {
69
- if (!this._canvas || !this._container) return;
70
- let e = this._container.getBoundingClientRect(), t = window.devicePixelRatio || 1;
71
- this._canvas.width = e.width * t, this._canvas.height = e.height * t, this._canvas.style.width = `${e.width}px`, this._canvas.style.height = `${e.height}px`;
72
- let n = this._canvas.getContext("2d");
73
- n && (n.scale(t, t), this._renderWaveform());
77
+ this._renderWaveform();
74
78
  }
75
79
  _renderWaveform() {
76
- if (!this._canvas) return;
77
- let t = this._canvas.getContext("2d");
78
- if (!t) return;
79
- let n = this._canvas.getBoundingClientRect();
80
- t.clearRect(0, 0, n.width, n.height);
81
- let r = getComputedStyle(this), i = this.barColor;
82
- if (!i) {
83
- let e = r.getPropertyValue("--md-sys-color-primary").trim(), t = r.getPropertyValue("color").trim();
84
- i = e || t || "#0066cc";
80
+ if (!this._canvas || !this._container) return;
81
+ let e = this._container.getBoundingClientRect();
82
+ if (e.width === 0 || e.height === 0) return;
83
+ let n = window.devicePixelRatio || 1, i = Math.round(e.width * n), a = Math.round(e.height * n), o = this._canvas.getContext("2d");
84
+ if (!o) return;
85
+ this._canvas.width !== i || this._canvas.height !== a ? (this._canvas.width = i, this._canvas.height = a, this._canvas.style.width = `${e.width}px`, this._canvas.style.height = `${e.height}px`, o.scale(n, n)) : o.clearRect(0, 0, e.width, e.height);
86
+ let s = getComputedStyle(this), c = this.barColor;
87
+ if (!c) {
88
+ let e = s.getPropertyValue("--md-sys-color-primary").trim(), t = s.getPropertyValue("color").trim();
89
+ c = e || t || "#0066cc";
90
+ }
91
+ let l = Math.floor(e.width / (this.barWidth + this.barGap)), u = e.height / 2, d = l * (this.barWidth + this.barGap) - this.barGap, f = Math.max(0, (e.width - d) / 2), p = this.peaks && this.peaks.length > 0 ? this.peaks : this._computedPeaks && this._computedPeaks.length > 0 ? this._computedPeaks : this.data;
92
+ for (let t = 0; t < l; t++) {
93
+ let n = p[p.length > 0 ? Math.floor(t / l * p.length) : 0] || .1, r = Math.max(this.barHeight, n * e.height * .8), i = f + t * (this.barWidth + this.barGap), a = u - r / 2;
94
+ this.align === "bottom" ? a = e.height - r : this.align === "top" && (a = 0), o.fillStyle = c, o.globalAlpha = .6 + n * .4, this.barRadius > 0 ? (o.beginPath(), o.roundRect(i, a, this.barWidth, r, this.barRadius), o.fill()) : o.fillRect(i, a, this.barWidth, r);
85
95
  }
86
- let a = Math.floor(n.width / (this.barWidth + this.barGap)), o = n.height / 2;
87
- for (let e = 0; e < a; e++) {
88
- let r = this.peaks && this.peaks.length > 0 ? this.peaks : this.data, s = r[r.length > 0 ? Math.floor(e / a * r.length) : 0] || 0, c = Math.max(this.barHeight, s * n.height * .8), l = e * (this.barWidth + this.barGap), u = o - c / 2;
89
- t.fillStyle = i, t.globalAlpha = .6 + s * .4, this.barRadius > 0 ? (t.beginPath(), t.roundRect(l, u, this.barWidth, c, this.barRadius), t.fill()) : t.fillRect(l, u, this.barWidth, c);
96
+ if (o.globalAlpha = 1, this._preparedOverlayText) {
97
+ let t = parseInt(this.overlayFont, 10) * 1.5 || 20, { lines: n } = r(this._preparedOverlayText, e.width - 20, t);
98
+ o.font = this.overlayFont, o.fillStyle = this.overlayColor, o.textBaseline = "top";
99
+ for (let e = 0; e < n.length; e++) o.fillText(n[e].text, 10, 10 + e * t);
90
100
  }
91
- this.fadeEdges && e(t, n.width, n.height, this.fadeWidth), t.globalAlpha = 1;
101
+ this.fadeEdges && t(o, e.width, e.height, this.fadeWidth);
92
102
  }
93
103
  };
94
- s([a({ type: Array })], c.prototype, "data", void 0), s([a({ type: Array })], c.prototype, "peaks", void 0), s([a({ type: Number })], c.prototype, "barWidth", void 0), s([a({ type: Number })], c.prototype, "barHeight", void 0), s([a({ type: Number })], c.prototype, "barGap", void 0), s([a({ type: Number })], c.prototype, "barRadius", void 0), s([a({ type: String })], c.prototype, "barColor", void 0), s([a({ type: String })], c.prototype, "align", void 0), s([a({ type: Boolean })], c.prototype, "fadeEdges", void 0), s([a({ type: Number })], c.prototype, "fadeWidth", void 0), s([a()], c.prototype, "height", void 0), s([o("canvas")], c.prototype, "_canvas", void 0), s([o(".container")], c.prototype, "_container", void 0), c = s([i("ui-waveform")], c);
95
- export { c as UiWaveform };
104
+ e([l({ type: String })], f.prototype, "src", void 0), e([l({ type: Array })], f.prototype, "data", void 0), e([l({ type: Array })], f.prototype, "peaks", void 0), e([l({ type: Number })], f.prototype, "barWidth", void 0), e([l({ type: Number })], f.prototype, "barHeight", void 0), e([l({ type: Number })], f.prototype, "barGap", void 0), e([l({ type: Number })], f.prototype, "barRadius", void 0), e([l({ type: String })], f.prototype, "barColor", void 0), e([l({ type: String })], f.prototype, "align", void 0), e([l({ type: Boolean })], f.prototype, "fadeEdges", void 0), e([l({ type: Number })], f.prototype, "fadeWidth", void 0), e([l()], f.prototype, "height", void 0), e([l({ type: String })], f.prototype, "overlayText", void 0), e([l({ type: String })], f.prototype, "overlayFont", void 0), e([l({ type: String })], f.prototype, "overlayColor", void 0), e([d()], f.prototype, "_computedPeaks", void 0), e([u("canvas")], f.prototype, "_canvas", void 0), e([u(".container")], f.prototype, "_container", void 0), f = e([c("ui-waveform")], f);
105
+ export { f as UiWaveform };
@@ -1,18 +1,14 @@
1
+ import { __decorate as e } from "../../_virtual/_@oxc-project_runtime@0.113.0/helpers/decorate.js";
1
2
  import "../atoms/ui-audio-play-button.js";
2
3
  import "../atoms/ui-audio-progress-slider.js";
3
4
  import "../atoms/ui-audio-time-display.js";
4
5
  import "../atoms/ui-audio-player-error.js";
5
6
  import "../providers/ui-audio-provider.js";
6
- import { LitElement as e, css as t, html as n } from "lit";
7
- import { customElement as r, property as i } from "lit/decorators.js";
8
- var a = function(e, t, n, r) {
9
- var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
10
- if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
11
- else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
12
- return i > 3 && a && Object.defineProperty(t, n, a), a;
13
- }, o = class extends e {
7
+ import { LitElement as t, css as n, html as r } from "lit";
8
+ import { customElement as i, property as a } from "lit/decorators.js";
9
+ var o = class extends t {
14
10
  static {
15
- this.styles = t`
11
+ this.styles = n`
16
12
  :host {
17
13
  display: inline-block;
18
14
  width: 100%;
@@ -42,7 +38,7 @@ var a = function(e, t, n, r) {
42
38
  `;
43
39
  }
44
40
  render() {
45
- return n`
41
+ return r`
46
42
  <ui-audio-provider .src="${this.item?.src || ""}">
47
43
  <div class="player-pill" part="container">
48
44
  <!-- Atomic Play/Pause Button -->
@@ -65,5 +61,5 @@ var a = function(e, t, n, r) {
65
61
  `;
66
62
  }
67
63
  };
68
- a([i({ type: Object })], o.prototype, "item", void 0), o = a([r("ui-audio-player")], o);
64
+ e([a({ type: Object })], o.prototype, "item", void 0), o = e([i("ui-audio-player")], o);
69
65
  export { o as UiAudioPlayer };