@corti/dictation-web
Version:
Web component for Corti Dictation
1,332 lines (1,302 loc) • 612 kB
JavaScript
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
// (disabled):fs
var require_fs = __commonJS({
"(disabled):fs"() {
}
});
// node_modules/ws/browser.js
var require_browser = __commonJS({
"node_modules/ws/browser.js"(exports, module) {
"use strict";
module.exports = function() {
throw new Error(
"ws does not work in the browser. Browser clients must use the native WebSocket object"
);
};
}
});
// node_modules/@lit/reactive-element/css-tag.js
var t = globalThis;
var e = t.ShadowRoot && (void 0 === t.ShadyCSS || t.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype;
var s = Symbol();
var o = /* @__PURE__ */ new WeakMap();
var n = class {
constructor(t7, e10, o10) {
if (this._$cssResult$ = true, o10 !== s) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
this.cssText = t7, this.t = e10;
}
get styleSheet() {
let t7 = this.o;
const s8 = this.t;
if (e && void 0 === t7) {
const e10 = void 0 !== s8 && 1 === s8.length;
e10 && (t7 = o.get(s8)), void 0 === t7 && ((this.o = t7 = new CSSStyleSheet()).replaceSync(this.cssText), e10 && o.set(s8, t7));
}
return t7;
}
toString() {
return this.cssText;
}
};
var r = (t7) => new n("string" == typeof t7 ? t7 : t7 + "", void 0, s);
var i = (t7, ...e10) => {
const o10 = 1 === t7.length ? t7[0] : e10.reduce((e11, s8, o11) => e11 + ((t8) => {
if (true === t8._$cssResult$) return t8.cssText;
if ("number" == typeof t8) return t8;
throw Error("Value passed to 'css' function must be a 'css' function result: " + t8 + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.");
})(s8) + t7[o11 + 1], t7[0]);
return new n(o10, t7, s);
};
var S = (s8, o10) => {
if (e) s8.adoptedStyleSheets = o10.map((t7) => t7 instanceof CSSStyleSheet ? t7 : t7.styleSheet);
else for (const e10 of o10) {
const o11 = document.createElement("style"), n8 = t.litNonce;
void 0 !== n8 && o11.setAttribute("nonce", n8), o11.textContent = e10.cssText, s8.appendChild(o11);
}
};
var c = e ? (t7) => t7 : (t7) => t7 instanceof CSSStyleSheet ? ((t8) => {
let e10 = "";
for (const s8 of t8.cssRules) e10 += s8.cssText;
return r(e10);
})(t7) : t7;
// node_modules/@lit/reactive-element/reactive-element.js
var { is: i2, defineProperty: e2, getOwnPropertyDescriptor: h, getOwnPropertyNames: r2, getOwnPropertySymbols: o2, getPrototypeOf: n2 } = Object;
var a = globalThis;
var c2 = a.trustedTypes;
var l = c2 ? c2.emptyScript : "";
var p = a.reactiveElementPolyfillSupport;
var d = (t7, s8) => t7;
var u = { toAttribute(t7, s8) {
switch (s8) {
case Boolean:
t7 = t7 ? l : null;
break;
case Object:
case Array:
t7 = null == t7 ? t7 : JSON.stringify(t7);
}
return t7;
}, fromAttribute(t7, s8) {
let i7 = t7;
switch (s8) {
case Boolean:
i7 = null !== t7;
break;
case Number:
i7 = null === t7 ? null : Number(t7);
break;
case Object:
case Array:
try {
i7 = JSON.parse(t7);
} catch (t8) {
i7 = null;
}
}
return i7;
} };
var f = (t7, s8) => !i2(t7, s8);
var b = { attribute: true, type: String, converter: u, reflect: false, useDefault: false, hasChanged: f };
Symbol.metadata ??= Symbol("metadata"), a.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
var y = class extends HTMLElement {
static addInitializer(t7) {
this._$Ei(), (this.l ??= []).push(t7);
}
static get observedAttributes() {
return this.finalize(), this._$Eh && [...this._$Eh.keys()];
}
static createProperty(t7, s8 = b) {
if (s8.state && (s8.attribute = false), this._$Ei(), this.prototype.hasOwnProperty(t7) && ((s8 = Object.create(s8)).wrapped = true), this.elementProperties.set(t7, s8), !s8.noAccessor) {
const i7 = Symbol(), h5 = this.getPropertyDescriptor(t7, i7, s8);
void 0 !== h5 && e2(this.prototype, t7, h5);
}
}
static getPropertyDescriptor(t7, s8, i7) {
const { get: e10, set: r7 } = h(this.prototype, t7) ?? { get() {
return this[s8];
}, set(t8) {
this[s8] = t8;
} };
return { get: e10, set(s9) {
const h5 = e10?.call(this);
r7?.call(this, s9), this.requestUpdate(t7, h5, i7);
}, configurable: true, enumerable: true };
}
static getPropertyOptions(t7) {
return this.elementProperties.get(t7) ?? b;
}
static _$Ei() {
if (this.hasOwnProperty(d("elementProperties"))) return;
const t7 = n2(this);
t7.finalize(), void 0 !== t7.l && (this.l = [...t7.l]), this.elementProperties = new Map(t7.elementProperties);
}
static finalize() {
if (this.hasOwnProperty(d("finalized"))) return;
if (this.finalized = true, this._$Ei(), this.hasOwnProperty(d("properties"))) {
const t8 = this.properties, s8 = [...r2(t8), ...o2(t8)];
for (const i7 of s8) this.createProperty(i7, t8[i7]);
}
const t7 = this[Symbol.metadata];
if (null !== t7) {
const s8 = litPropertyMetadata.get(t7);
if (void 0 !== s8) for (const [t8, i7] of s8) this.elementProperties.set(t8, i7);
}
this._$Eh = /* @__PURE__ */ new Map();
for (const [t8, s8] of this.elementProperties) {
const i7 = this._$Eu(t8, s8);
void 0 !== i7 && this._$Eh.set(i7, t8);
}
this.elementStyles = this.finalizeStyles(this.styles);
}
static finalizeStyles(s8) {
const i7 = [];
if (Array.isArray(s8)) {
const e10 = new Set(s8.flat(1 / 0).reverse());
for (const s9 of e10) i7.unshift(c(s9));
} else void 0 !== s8 && i7.push(c(s8));
return i7;
}
static _$Eu(t7, s8) {
const i7 = s8.attribute;
return false === i7 ? void 0 : "string" == typeof i7 ? i7 : "string" == typeof t7 ? t7.toLowerCase() : void 0;
}
constructor() {
super(), this._$Ep = void 0, this.isUpdatePending = false, this.hasUpdated = false, this._$Em = null, this._$Ev();
}
_$Ev() {
this._$ES = new Promise((t7) => this.enableUpdating = t7), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach((t7) => t7(this));
}
addController(t7) {
(this._$EO ??= /* @__PURE__ */ new Set()).add(t7), void 0 !== this.renderRoot && this.isConnected && t7.hostConnected?.();
}
removeController(t7) {
this._$EO?.delete(t7);
}
_$E_() {
const t7 = /* @__PURE__ */ new Map(), s8 = this.constructor.elementProperties;
for (const i7 of s8.keys()) this.hasOwnProperty(i7) && (t7.set(i7, this[i7]), delete this[i7]);
t7.size > 0 && (this._$Ep = t7);
}
createRenderRoot() {
const t7 = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
return S(t7, this.constructor.elementStyles), t7;
}
connectedCallback() {
this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(true), this._$EO?.forEach((t7) => t7.hostConnected?.());
}
enableUpdating(t7) {
}
disconnectedCallback() {
this._$EO?.forEach((t7) => t7.hostDisconnected?.());
}
attributeChangedCallback(t7, s8, i7) {
this._$AK(t7, i7);
}
_$ET(t7, s8) {
const i7 = this.constructor.elementProperties.get(t7), e10 = this.constructor._$Eu(t7, i7);
if (void 0 !== e10 && true === i7.reflect) {
const h5 = (void 0 !== i7.converter?.toAttribute ? i7.converter : u).toAttribute(s8, i7.type);
this._$Em = t7, null == h5 ? this.removeAttribute(e10) : this.setAttribute(e10, h5), this._$Em = null;
}
}
_$AK(t7, s8) {
const i7 = this.constructor, e10 = i7._$Eh.get(t7);
if (void 0 !== e10 && this._$Em !== e10) {
const t8 = i7.getPropertyOptions(e10), h5 = "function" == typeof t8.converter ? { fromAttribute: t8.converter } : void 0 !== t8.converter?.fromAttribute ? t8.converter : u;
this._$Em = e10;
const r7 = h5.fromAttribute(s8, t8.type);
this[e10] = r7 ?? this._$Ej?.get(e10) ?? r7, this._$Em = null;
}
}
requestUpdate(t7, s8, i7) {
if (void 0 !== t7) {
const e10 = this.constructor, h5 = this[t7];
if (i7 ??= e10.getPropertyOptions(t7), !((i7.hasChanged ?? f)(h5, s8) || i7.useDefault && i7.reflect && h5 === this._$Ej?.get(t7) && !this.hasAttribute(e10._$Eu(t7, i7)))) return;
this.C(t7, s8, i7);
}
false === this.isUpdatePending && (this._$ES = this._$EP());
}
C(t7, s8, { useDefault: i7, reflect: e10, wrapped: h5 }, r7) {
i7 && !(this._$Ej ??= /* @__PURE__ */ new Map()).has(t7) && (this._$Ej.set(t7, r7 ?? s8 ?? this[t7]), true !== h5 || void 0 !== r7) || (this._$AL.has(t7) || (this.hasUpdated || i7 || (s8 = void 0), this._$AL.set(t7, s8)), true === e10 && this._$Em !== t7 && (this._$Eq ??= /* @__PURE__ */ new Set()).add(t7));
}
async _$EP() {
this.isUpdatePending = true;
try {
await this._$ES;
} catch (t8) {
Promise.reject(t8);
}
const t7 = this.scheduleUpdate();
return null != t7 && await t7, !this.isUpdatePending;
}
scheduleUpdate() {
return this.performUpdate();
}
performUpdate() {
if (!this.isUpdatePending) return;
if (!this.hasUpdated) {
if (this.renderRoot ??= this.createRenderRoot(), this._$Ep) {
for (const [t9, s9] of this._$Ep) this[t9] = s9;
this._$Ep = void 0;
}
const t8 = this.constructor.elementProperties;
if (t8.size > 0) for (const [s9, i7] of t8) {
const { wrapped: t9 } = i7, e10 = this[s9];
true !== t9 || this._$AL.has(s9) || void 0 === e10 || this.C(s9, void 0, i7, e10);
}
}
let t7 = false;
const s8 = this._$AL;
try {
t7 = this.shouldUpdate(s8), t7 ? (this.willUpdate(s8), this._$EO?.forEach((t8) => t8.hostUpdate?.()), this.update(s8)) : this._$EM();
} catch (s9) {
throw t7 = false, this._$EM(), s9;
}
t7 && this._$AE(s8);
}
willUpdate(t7) {
}
_$AE(t7) {
this._$EO?.forEach((t8) => t8.hostUpdated?.()), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t7)), this.updated(t7);
}
_$EM() {
this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = false;
}
get updateComplete() {
return this.getUpdateComplete();
}
getUpdateComplete() {
return this._$ES;
}
shouldUpdate(t7) {
return true;
}
update(t7) {
this._$Eq &&= this._$Eq.forEach((t8) => this._$ET(t8, this[t8])), this._$EM();
}
updated(t7) {
}
firstUpdated(t7) {
}
};
y.elementStyles = [], y.shadowRootOptions = { mode: "open" }, y[d("elementProperties")] = /* @__PURE__ */ new Map(), y[d("finalized")] = /* @__PURE__ */ new Map(), p?.({ ReactiveElement: y }), (a.reactiveElementVersions ??= []).push("2.1.1");
// node_modules/lit-html/lit-html.js
var t2 = globalThis;
var i3 = t2.trustedTypes;
var s2 = i3 ? i3.createPolicy("lit-html", { createHTML: (t7) => t7 }) : void 0;
var e3 = "$lit$";
var h2 = `lit$${Math.random().toFixed(9).slice(2)}$`;
var o3 = "?" + h2;
var n3 = `<${o3}>`;
var r3 = document;
var l2 = () => r3.createComment("");
var c3 = (t7) => null === t7 || "object" != typeof t7 && "function" != typeof t7;
var a2 = Array.isArray;
var u2 = (t7) => a2(t7) || "function" == typeof t7?.[Symbol.iterator];
var d2 = "[ \n\f\r]";
var f2 = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g;
var v = /-->/g;
var _ = />/g;
var m = RegExp(`>|${d2}(?:([^\\s"'>=/]+)(${d2}*=${d2}*(?:[^
\f\r"'\`<>=]|("|')|))|$)`, "g");
var p2 = /'/g;
var g = /"/g;
var $ = /^(?:script|style|textarea|title)$/i;
var y2 = (t7) => (i7, ...s8) => ({ _$litType$: t7, strings: i7, values: s8 });
var x = y2(1);
var b2 = y2(2);
var w = y2(3);
var T = Symbol.for("lit-noChange");
var E = Symbol.for("lit-nothing");
var A = /* @__PURE__ */ new WeakMap();
var C = r3.createTreeWalker(r3, 129);
function P(t7, i7) {
if (!a2(t7) || !t7.hasOwnProperty("raw")) throw Error("invalid template strings array");
return void 0 !== s2 ? s2.createHTML(i7) : i7;
}
var V = (t7, i7) => {
const s8 = t7.length - 1, o10 = [];
let r7, l3 = 2 === i7 ? "<svg>" : 3 === i7 ? "<math>" : "", c6 = f2;
for (let i8 = 0; i8 < s8; i8++) {
const s9 = t7[i8];
let a3, u3, d3 = -1, y3 = 0;
for (; y3 < s9.length && (c6.lastIndex = y3, u3 = c6.exec(s9), null !== u3); ) y3 = c6.lastIndex, c6 === f2 ? "!--" === u3[1] ? c6 = v : void 0 !== u3[1] ? c6 = _ : void 0 !== u3[2] ? ($.test(u3[2]) && (r7 = RegExp("</" + u3[2], "g")), c6 = m) : void 0 !== u3[3] && (c6 = m) : c6 === m ? ">" === u3[0] ? (c6 = r7 ?? f2, d3 = -1) : void 0 === u3[1] ? d3 = -2 : (d3 = c6.lastIndex - u3[2].length, a3 = u3[1], c6 = void 0 === u3[3] ? m : '"' === u3[3] ? g : p2) : c6 === g || c6 === p2 ? c6 = m : c6 === v || c6 === _ ? c6 = f2 : (c6 = m, r7 = void 0);
const x2 = c6 === m && t7[i8 + 1].startsWith("/>") ? " " : "";
l3 += c6 === f2 ? s9 + n3 : d3 >= 0 ? (o10.push(a3), s9.slice(0, d3) + e3 + s9.slice(d3) + h2 + x2) : s9 + h2 + (-2 === d3 ? i8 : x2);
}
return [P(t7, l3 + (t7[s8] || "<?>") + (2 === i7 ? "</svg>" : 3 === i7 ? "</math>" : "")), o10];
};
var N = class _N {
constructor({ strings: t7, _$litType$: s8 }, n8) {
let r7;
this.parts = [];
let c6 = 0, a3 = 0;
const u3 = t7.length - 1, d3 = this.parts, [f5, v2] = V(t7, s8);
if (this.el = _N.createElement(f5, n8), C.currentNode = this.el.content, 2 === s8 || 3 === s8) {
const t8 = this.el.content.firstChild;
t8.replaceWith(...t8.childNodes);
}
for (; null !== (r7 = C.nextNode()) && d3.length < u3; ) {
if (1 === r7.nodeType) {
if (r7.hasAttributes()) for (const t8 of r7.getAttributeNames()) if (t8.endsWith(e3)) {
const i7 = v2[a3++], s9 = r7.getAttribute(t8).split(h2), e10 = /([.?@])?(.*)/.exec(i7);
d3.push({ type: 1, index: c6, name: e10[2], strings: s9, ctor: "." === e10[1] ? H : "?" === e10[1] ? I : "@" === e10[1] ? L : k }), r7.removeAttribute(t8);
} else t8.startsWith(h2) && (d3.push({ type: 6, index: c6 }), r7.removeAttribute(t8));
if ($.test(r7.tagName)) {
const t8 = r7.textContent.split(h2), s9 = t8.length - 1;
if (s9 > 0) {
r7.textContent = i3 ? i3.emptyScript : "";
for (let i7 = 0; i7 < s9; i7++) r7.append(t8[i7], l2()), C.nextNode(), d3.push({ type: 2, index: ++c6 });
r7.append(t8[s9], l2());
}
}
} else if (8 === r7.nodeType) if (r7.data === o3) d3.push({ type: 2, index: c6 });
else {
let t8 = -1;
for (; -1 !== (t8 = r7.data.indexOf(h2, t8 + 1)); ) d3.push({ type: 7, index: c6 }), t8 += h2.length - 1;
}
c6++;
}
}
static createElement(t7, i7) {
const s8 = r3.createElement("template");
return s8.innerHTML = t7, s8;
}
};
function S2(t7, i7, s8 = t7, e10) {
if (i7 === T) return i7;
let h5 = void 0 !== e10 ? s8._$Co?.[e10] : s8._$Cl;
const o10 = c3(i7) ? void 0 : i7._$litDirective$;
return h5?.constructor !== o10 && (h5?._$AO?.(false), void 0 === o10 ? h5 = void 0 : (h5 = new o10(t7), h5._$AT(t7, s8, e10)), void 0 !== e10 ? (s8._$Co ??= [])[e10] = h5 : s8._$Cl = h5), void 0 !== h5 && (i7 = S2(t7, h5._$AS(t7, i7.values), h5, e10)), i7;
}
var M = class {
constructor(t7, i7) {
this._$AV = [], this._$AN = void 0, this._$AD = t7, this._$AM = i7;
}
get parentNode() {
return this._$AM.parentNode;
}
get _$AU() {
return this._$AM._$AU;
}
u(t7) {
const { el: { content: i7 }, parts: s8 } = this._$AD, e10 = (t7?.creationScope ?? r3).importNode(i7, true);
C.currentNode = e10;
let h5 = C.nextNode(), o10 = 0, n8 = 0, l3 = s8[0];
for (; void 0 !== l3; ) {
if (o10 === l3.index) {
let i8;
2 === l3.type ? i8 = new R(h5, h5.nextSibling, this, t7) : 1 === l3.type ? i8 = new l3.ctor(h5, l3.name, l3.strings, this, t7) : 6 === l3.type && (i8 = new z(h5, this, t7)), this._$AV.push(i8), l3 = s8[++n8];
}
o10 !== l3?.index && (h5 = C.nextNode(), o10++);
}
return C.currentNode = r3, e10;
}
p(t7) {
let i7 = 0;
for (const s8 of this._$AV) void 0 !== s8 && (void 0 !== s8.strings ? (s8._$AI(t7, s8, i7), i7 += s8.strings.length - 2) : s8._$AI(t7[i7])), i7++;
}
};
var R = class _R {
get _$AU() {
return this._$AM?._$AU ?? this._$Cv;
}
constructor(t7, i7, s8, e10) {
this.type = 2, this._$AH = E, this._$AN = void 0, this._$AA = t7, this._$AB = i7, this._$AM = s8, this.options = e10, this._$Cv = e10?.isConnected ?? true;
}
get parentNode() {
let t7 = this._$AA.parentNode;
const i7 = this._$AM;
return void 0 !== i7 && 11 === t7?.nodeType && (t7 = i7.parentNode), t7;
}
get startNode() {
return this._$AA;
}
get endNode() {
return this._$AB;
}
_$AI(t7, i7 = this) {
t7 = S2(this, t7, i7), c3(t7) ? t7 === E || null == t7 || "" === t7 ? (this._$AH !== E && this._$AR(), this._$AH = E) : t7 !== this._$AH && t7 !== T && this._(t7) : void 0 !== t7._$litType$ ? this.$(t7) : void 0 !== t7.nodeType ? this.T(t7) : u2(t7) ? this.k(t7) : this._(t7);
}
O(t7) {
return this._$AA.parentNode.insertBefore(t7, this._$AB);
}
T(t7) {
this._$AH !== t7 && (this._$AR(), this._$AH = this.O(t7));
}
_(t7) {
this._$AH !== E && c3(this._$AH) ? this._$AA.nextSibling.data = t7 : this.T(r3.createTextNode(t7)), this._$AH = t7;
}
$(t7) {
const { values: i7, _$litType$: s8 } = t7, e10 = "number" == typeof s8 ? this._$AC(t7) : (void 0 === s8.el && (s8.el = N.createElement(P(s8.h, s8.h[0]), this.options)), s8);
if (this._$AH?._$AD === e10) this._$AH.p(i7);
else {
const t8 = new M(e10, this), s9 = t8.u(this.options);
t8.p(i7), this.T(s9), this._$AH = t8;
}
}
_$AC(t7) {
let i7 = A.get(t7.strings);
return void 0 === i7 && A.set(t7.strings, i7 = new N(t7)), i7;
}
k(t7) {
a2(this._$AH) || (this._$AH = [], this._$AR());
const i7 = this._$AH;
let s8, e10 = 0;
for (const h5 of t7) e10 === i7.length ? i7.push(s8 = new _R(this.O(l2()), this.O(l2()), this, this.options)) : s8 = i7[e10], s8._$AI(h5), e10++;
e10 < i7.length && (this._$AR(s8 && s8._$AB.nextSibling, e10), i7.length = e10);
}
_$AR(t7 = this._$AA.nextSibling, i7) {
for (this._$AP?.(false, true, i7); t7 !== this._$AB; ) {
const i8 = t7.nextSibling;
t7.remove(), t7 = i8;
}
}
setConnected(t7) {
void 0 === this._$AM && (this._$Cv = t7, this._$AP?.(t7));
}
};
var k = class {
get tagName() {
return this.element.tagName;
}
get _$AU() {
return this._$AM._$AU;
}
constructor(t7, i7, s8, e10, h5) {
this.type = 1, this._$AH = E, this._$AN = void 0, this.element = t7, this.name = i7, this._$AM = e10, this.options = h5, s8.length > 2 || "" !== s8[0] || "" !== s8[1] ? (this._$AH = Array(s8.length - 1).fill(new String()), this.strings = s8) : this._$AH = E;
}
_$AI(t7, i7 = this, s8, e10) {
const h5 = this.strings;
let o10 = false;
if (void 0 === h5) t7 = S2(this, t7, i7, 0), o10 = !c3(t7) || t7 !== this._$AH && t7 !== T, o10 && (this._$AH = t7);
else {
const e11 = t7;
let n8, r7;
for (t7 = h5[0], n8 = 0; n8 < h5.length - 1; n8++) r7 = S2(this, e11[s8 + n8], i7, n8), r7 === T && (r7 = this._$AH[n8]), o10 ||= !c3(r7) || r7 !== this._$AH[n8], r7 === E ? t7 = E : t7 !== E && (t7 += (r7 ?? "") + h5[n8 + 1]), this._$AH[n8] = r7;
}
o10 && !e10 && this.j(t7);
}
j(t7) {
t7 === E ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t7 ?? "");
}
};
var H = class extends k {
constructor() {
super(...arguments), this.type = 3;
}
j(t7) {
this.element[this.name] = t7 === E ? void 0 : t7;
}
};
var I = class extends k {
constructor() {
super(...arguments), this.type = 4;
}
j(t7) {
this.element.toggleAttribute(this.name, !!t7 && t7 !== E);
}
};
var L = class extends k {
constructor(t7, i7, s8, e10, h5) {
super(t7, i7, s8, e10, h5), this.type = 5;
}
_$AI(t7, i7 = this) {
if ((t7 = S2(this, t7, i7, 0) ?? E) === T) return;
const s8 = this._$AH, e10 = t7 === E && s8 !== E || t7.capture !== s8.capture || t7.once !== s8.once || t7.passive !== s8.passive, h5 = t7 !== E && (s8 === E || e10);
e10 && this.element.removeEventListener(this.name, this, s8), h5 && this.element.addEventListener(this.name, this, t7), this._$AH = t7;
}
handleEvent(t7) {
"function" == typeof this._$AH ? this._$AH.call(this.options?.host ?? this.element, t7) : this._$AH.handleEvent(t7);
}
};
var z = class {
constructor(t7, i7, s8) {
this.element = t7, this.type = 6, this._$AN = void 0, this._$AM = i7, this.options = s8;
}
get _$AU() {
return this._$AM._$AU;
}
_$AI(t7) {
S2(this, t7);
}
};
var Z = { M: e3, P: h2, A: o3, C: 1, L: V, R: M, D: u2, V: S2, I: R, H: k, N: I, U: L, B: H, F: z };
var j = t2.litHtmlPolyfillSupport;
j?.(N, R), (t2.litHtmlVersions ??= []).push("3.3.1");
var B = (t7, i7, s8) => {
const e10 = s8?.renderBefore ?? i7;
let h5 = e10._$litPart$;
if (void 0 === h5) {
const t8 = s8?.renderBefore ?? null;
e10._$litPart$ = h5 = new R(i7.insertBefore(l2(), t8), t8, void 0, s8 ?? {});
}
return h5._$AI(t7), h5;
};
// node_modules/lit-element/lit-element.js
var s3 = globalThis;
var i4 = class extends y {
constructor() {
super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
}
createRenderRoot() {
const t7 = super.createRenderRoot();
return this.renderOptions.renderBefore ??= t7.firstChild, t7;
}
update(t7) {
const r7 = this.render();
this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t7), this._$Do = B(r7, this.renderRoot, this.renderOptions);
}
connectedCallback() {
super.connectedCallback(), this._$Do?.setConnected(true);
}
disconnectedCallback() {
super.disconnectedCallback(), this._$Do?.setConnected(false);
}
render() {
return T;
}
};
i4._$litElement$ = true, i4["finalized"] = true, s3.litElementHydrateSupport?.({ LitElement: i4 });
var o4 = s3.litElementPolyfillSupport;
o4?.({ LitElement: i4 });
(s3.litElementVersions ??= []).push("4.2.1");
// node_modules/@lit/reactive-element/decorators/custom-element.js
var t3 = (t7) => (e10, o10) => {
void 0 !== o10 ? o10.addInitializer(() => {
customElements.define(t7, e10);
}) : customElements.define(t7, e10);
};
// node_modules/@lit/reactive-element/decorators/property.js
var o5 = { attribute: true, type: String, converter: u, reflect: false, hasChanged: f };
var r4 = (t7 = o5, e10, r7) => {
const { kind: n8, metadata: i7 } = r7;
let s8 = globalThis.litPropertyMetadata.get(i7);
if (void 0 === s8 && globalThis.litPropertyMetadata.set(i7, s8 = /* @__PURE__ */ new Map()), "setter" === n8 && ((t7 = Object.create(t7)).wrapped = true), s8.set(r7.name, t7), "accessor" === n8) {
const { name: o10 } = r7;
return { set(r8) {
const n9 = e10.get.call(this);
e10.set.call(this, r8), this.requestUpdate(o10, n9, t7);
}, init(e11) {
return void 0 !== e11 && this.C(o10, void 0, t7, e11), e11;
} };
}
if ("setter" === n8) {
const { name: o10 } = r7;
return function(r8) {
const n9 = this[o10];
e10.call(this, r8), this.requestUpdate(o10, n9, t7);
};
}
throw Error("Unsupported decorator location: " + n8);
};
function n4(t7) {
return (e10, o10) => "object" == typeof o10 ? r4(t7, e10, o10) : ((t8, e11, o11) => {
const r7 = e11.hasOwnProperty(o11);
return e11.constructor.createProperty(o11, t8), r7 ? Object.getOwnPropertyDescriptor(e11, o11) : void 0;
})(t7, e10, o10);
}
// node_modules/@lit/reactive-element/decorators/state.js
function r5(r7) {
return n4({ ...r7, state: true, attribute: false });
}
// node_modules/lit-html/directive.js
var t4 = { ATTRIBUTE: 1, CHILD: 2, PROPERTY: 3, BOOLEAN_ATTRIBUTE: 4, EVENT: 5, ELEMENT: 6 };
var e5 = (t7) => (...e10) => ({ _$litDirective$: t7, values: e10 });
var i5 = class {
constructor(t7) {
}
get _$AU() {
return this._$AM._$AU;
}
_$AT(t7, e10, i7) {
this._$Ct = t7, this._$AM = e10, this._$Ci = i7;
}
_$AS(t7, e10) {
return this.update(t7, e10);
}
update(t7, e10) {
return this.render(...e10);
}
};
// node_modules/lit-html/directives/class-map.js
var e6 = e5(class extends i5 {
constructor(t7) {
if (super(t7), t7.type !== t4.ATTRIBUTE || "class" !== t7.name || t7.strings?.length > 2) throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.");
}
render(t7) {
return " " + Object.keys(t7).filter((s8) => t7[s8]).join(" ") + " ";
}
update(s8, [i7]) {
if (void 0 === this.st) {
this.st = /* @__PURE__ */ new Set(), void 0 !== s8.strings && (this.nt = new Set(s8.strings.join(" ").split(/\s/).filter((t7) => "" !== t7)));
for (const t7 in i7) i7[t7] && !this.nt?.has(t7) && this.st.add(t7);
return this.render(i7);
}
const r7 = s8.element.classList;
for (const t7 of this.st) t7 in i7 || (r7.remove(t7), this.st.delete(t7));
for (const t7 in i7) {
const s9 = !!i7[t7];
s9 === this.st.has(t7) || this.nt?.has(t7) || (s9 ? (r7.add(t7), this.st.add(t7)) : (r7.remove(t7), this.st.delete(t7)));
}
return T;
}
});
// node_modules/lit-html/directive-helpers.js
var { I: t5 } = Z;
var f3 = (o10) => void 0 === o10.strings;
// node_modules/lit-html/async-directive.js
var s4 = (i7, t7) => {
const e10 = i7._$AN;
if (void 0 === e10) return false;
for (const i8 of e10) i8._$AO?.(t7, false), s4(i8, t7);
return true;
};
var o6 = (i7) => {
let t7, e10;
do {
if (void 0 === (t7 = i7._$AM)) break;
e10 = t7._$AN, e10.delete(i7), i7 = t7;
} while (0 === e10?.size);
};
var r6 = (i7) => {
for (let t7; t7 = i7._$AM; i7 = t7) {
let e10 = t7._$AN;
if (void 0 === e10) t7._$AN = e10 = /* @__PURE__ */ new Set();
else if (e10.has(i7)) break;
e10.add(i7), c4(t7);
}
};
function h3(i7) {
void 0 !== this._$AN ? (o6(this), this._$AM = i7, r6(this)) : this._$AM = i7;
}
function n5(i7, t7 = false, e10 = 0) {
const r7 = this._$AH, h5 = this._$AN;
if (void 0 !== h5 && 0 !== h5.size) if (t7) if (Array.isArray(r7)) for (let i8 = e10; i8 < r7.length; i8++) s4(r7[i8], false), o6(r7[i8]);
else null != r7 && (s4(r7, false), o6(r7));
else s4(this, i7);
}
var c4 = (i7) => {
i7.type == t4.CHILD && (i7._$AP ??= n5, i7._$AQ ??= h3);
};
var f4 = class extends i5 {
constructor() {
super(...arguments), this._$AN = void 0;
}
_$AT(i7, t7, e10) {
super._$AT(i7, t7, e10), r6(this), this.isConnected = i7._$AU;
}
_$AO(i7, t7 = true) {
i7 !== this.isConnected && (this.isConnected = i7, i7 ? this.reconnected?.() : this.disconnected?.()), t7 && (s4(this, i7), o6(this));
}
setValue(t7) {
if (f3(this._$Ct)) this._$Ct._$AI(t7, this);
else {
const i7 = [...this._$Ct._$AH];
i7[this._$Ci] = t7, this._$Ct._$AI(i7, this, 0);
}
}
disconnected() {
}
reconnected() {
}
};
// node_modules/lit-html/directives/ref.js
var e7 = () => new h4();
var h4 = class {
};
var o7 = /* @__PURE__ */ new WeakMap();
var n6 = e5(class extends f4 {
render(i7) {
return E;
}
update(i7, [s8]) {
const e10 = s8 !== this.G;
return e10 && void 0 !== this.G && this.rt(void 0), (e10 || this.lt !== this.ct) && (this.G = s8, this.ht = i7.options?.host, this.rt(this.ct = i7.element)), E;
}
rt(t7) {
if (this.isConnected || (t7 = void 0), "function" == typeof this.G) {
const i7 = this.ht ?? globalThis;
let s8 = o7.get(i7);
void 0 === s8 && (s8 = /* @__PURE__ */ new WeakMap(), o7.set(i7, s8)), void 0 !== s8.get(this.G) && this.G.call(this.ht, void 0), s8.set(this.G, t7), void 0 !== t7 && this.G.call(this.ht, t7);
} else this.G.value = t7;
}
get lt() {
return "function" == typeof this.G ? o7.get(this.ht ?? globalThis)?.get(this.G) : this.G?.value;
}
disconnected() {
this.lt === this.ct && this.rt(void 0);
}
reconnected() {
this.rt(this.ct);
}
});
// dist/constants.js
var LANGUAGES_SUPPORTED_EU = [
"da",
"de",
"de-CH",
"en",
"en-GB",
"es",
"fr",
"hu",
"it",
"nl",
"no",
"pt",
"sv",
"gsw-CH"
].sort();
var LANGUAGES_SUPPORTED_US = [
"da",
"de",
"de-CH",
"en",
"en-GB",
"es",
"fr",
"hu",
"it",
"nl",
"no",
"pt",
"sv"
].sort();
var DEFAULT_DICTATION_CONFIG = {
automaticPunctuation: false,
primaryLanguage: "en",
spokenPunctuation: true
};
var AUDIO_CHUNK_INTERVAL_MS = 250;
// dist/utils/converters.js
var commaSeparatedConverter = {
fromAttribute: (value) => value?.split(",").map((s8) => s8.trim()).filter(Boolean),
toAttribute: (value) => value?.join(",")
};
// node_modules/@lit/context/lib/context-request-event.js
var s5 = class extends Event {
constructor(s8, t7, e10, o10) {
super("context-request", { bubbles: true, composed: true }), this.context = s8, this.contextTarget = t7, this.callback = e10, this.subscribe = o10 ?? false;
}
};
// node_modules/@lit/context/lib/create-context.js
function n7(n8) {
return n8;
}
// node_modules/@lit/context/lib/controllers/context-consumer.js
var s6 = class {
constructor(t7, s8, i7, h5) {
if (this.subscribe = false, this.provided = false, this.value = void 0, this.t = (t8, s9) => {
this.unsubscribe && (this.unsubscribe !== s9 && (this.provided = false, this.unsubscribe()), this.subscribe || this.unsubscribe()), this.value = t8, this.host.requestUpdate(), this.provided && !this.subscribe || (this.provided = true, this.callback && this.callback(t8, s9)), this.unsubscribe = s9;
}, this.host = t7, void 0 !== s8.context) {
const t8 = s8;
this.context = t8.context, this.callback = t8.callback, this.subscribe = t8.subscribe ?? false;
} else this.context = s8, this.callback = i7, this.subscribe = h5 ?? false;
this.host.addController(this);
}
hostConnected() {
this.dispatchRequest();
}
hostDisconnected() {
this.unsubscribe && (this.unsubscribe(), this.unsubscribe = void 0);
}
dispatchRequest() {
this.host.dispatchEvent(new s5(this.context, this.host, this.t, this.subscribe));
}
};
// node_modules/@lit/context/lib/value-notifier.js
var s7 = class {
get value() {
return this.o;
}
set value(s8) {
this.setValue(s8);
}
setValue(s8, t7 = false) {
const i7 = t7 || !Object.is(s8, this.o);
this.o = s8, i7 && this.updateObservers();
}
constructor(s8) {
this.subscriptions = /* @__PURE__ */ new Map(), this.updateObservers = () => {
for (const [s9, { disposer: t7 }] of this.subscriptions) s9(this.o, t7);
}, void 0 !== s8 && (this.value = s8);
}
addCallback(s8, t7, i7) {
if (!i7) return void s8(this.value);
this.subscriptions.has(s8) || this.subscriptions.set(s8, { disposer: () => {
this.subscriptions.delete(s8);
}, consumerHost: t7 });
const { disposer: h5 } = this.subscriptions.get(s8);
s8(this.value, h5);
}
clearCallbacks() {
this.subscriptions.clear();
}
};
// node_modules/@lit/context/lib/controllers/context-provider.js
var e8 = class extends Event {
constructor(t7, s8) {
super("context-provider", { bubbles: true, composed: true }), this.context = t7, this.contextTarget = s8;
}
};
var i6 = class extends s7 {
constructor(s8, e10, i7) {
super(void 0 !== e10.context ? e10.initialValue : i7), this.onContextRequest = (t7) => {
if (t7.context !== this.context) return;
const s9 = t7.contextTarget ?? t7.composedPath()[0];
s9 !== this.host && (t7.stopPropagation(), this.addCallback(t7.callback, s9, t7.subscribe));
}, this.onProviderRequest = (s9) => {
if (s9.context !== this.context) return;
if ((s9.contextTarget ?? s9.composedPath()[0]) === this.host) return;
const e11 = /* @__PURE__ */ new Set();
for (const [s10, { consumerHost: i8 }] of this.subscriptions) e11.has(s10) || (e11.add(s10), i8.dispatchEvent(new s5(this.context, i8, s10, true)));
s9.stopPropagation();
}, this.host = s8, void 0 !== e10.context ? this.context = e10.context : this.context = e10, this.attachListeners(), this.host.addController?.(this);
}
attachListeners() {
this.host.addEventListener("context-request", this.onContextRequest), this.host.addEventListener("context-provider", this.onProviderRequest);
}
hostConnected() {
this.host.dispatchEvent(new e8(this.context, this.host));
}
};
// node_modules/@lit/context/lib/decorators/provide.js
function e9({ context: e10 }) {
return (n8, i7) => {
const r7 = /* @__PURE__ */ new WeakMap();
if ("object" == typeof i7) return { get() {
return n8.get.call(this);
}, set(t7) {
return r7.get(this).setValue(t7), n8.set.call(this, t7);
}, init(n9) {
return r7.set(this, new i6(this, { context: e10, initialValue: n9 })), n9;
} };
{
n8.constructor.addInitializer((n9) => {
r7.set(n9, new i6(n9, { context: e10 }));
});
const o10 = Object.getOwnPropertyDescriptor(n8, i7);
let s8;
if (void 0 === o10) {
const t7 = /* @__PURE__ */ new WeakMap();
s8 = { get() {
return t7.get(this);
}, set(e11) {
r7.get(this).setValue(e11), t7.set(this, e11);
}, configurable: true, enumerable: true };
} else {
const t7 = o10.set;
s8 = { ...o10, set(e11) {
r7.get(this).setValue(e11), t7?.call(this, e11);
} };
}
return void Object.defineProperty(n8, i7, s8);
}
};
}
// node_modules/@lit/context/lib/decorators/consume.js
function c5({ context: c6, subscribe: e10 }) {
return (o10, n8) => {
"object" == typeof n8 ? n8.addInitializer(function() {
new s6(this, { context: c6, callback: (t7) => {
o10.set.call(this, t7);
}, subscribe: e10 });
}) : o10.constructor.addInitializer((o11) => {
new s6(o11, { context: c6, callback: (t7) => {
o11[n8] = t7;
}, subscribe: e10 });
});
};
}
// dist/utils/devices.js
async function requestMicAccess() {
if (!navigator.permissions) {
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
stream.getTracks().forEach((track) => {
track.stop();
});
return;
}
const permissionStatus = await navigator.permissions.query({
name: "microphone"
});
if (permissionStatus.state === "denied") {
throw new Error("Microphone permission is denied");
}
if (permissionStatus.state === "prompt") {
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
stream.getTracks().forEach((track) => {
track.stop();
});
}
}
async function getAudioDevices() {
if (!navigator.mediaDevices?.enumerateDevices) {
throw new Error("MediaDevices API is not available");
}
await requestMicAccess();
const devices = await navigator.mediaDevices.enumerateDevices();
const audioDevices = devices.filter((device) => device.kind === "audioinput");
const defaultDevice = audioDevices.length > 0 ? audioDevices[0] : void 0;
return { defaultDevice, devices: audioDevices };
}
// dist/utils/events.js
function languagesChangedEvent(languages, selectedLanguage) {
return new CustomEvent("languages-changed", {
bubbles: true,
composed: true,
detail: { languages, selectedLanguage }
});
}
function languageChangedEvent(language) {
return new CustomEvent("language-changed", {
bubbles: true,
composed: true,
detail: { language }
});
}
function recordingDevicesChangedEvent(devices, selectedDevice) {
return new CustomEvent("recording-devices-changed", {
bubbles: true,
composed: true,
detail: { devices, selectedDevice }
});
}
function recordingStateChangedEvent(state, options = {}) {
return new CustomEvent("recording-state-changed", {
bubbles: true,
composed: true,
detail: {
connection: options.connection,
processing: options.processing,
state
}
});
}
function transcriptEvent(detail) {
return new CustomEvent("transcript", {
bubbles: true,
composed: true,
detail
});
}
function commandEvent(detail) {
return new CustomEvent("command", {
bubbles: true,
composed: true,
detail
});
}
function usageEvent(detail) {
return new CustomEvent("usage", {
bubbles: true,
composed: true,
detail
});
}
function deltaUsageEvent(detail) {
return new CustomEvent("delta-usage", {
bubbles: true,
composed: true,
detail
});
}
function errorToMessage(error) {
if (error instanceof Error) {
return error.message;
}
if (typeof error === "object" && error !== null) {
try {
return JSON.stringify(error);
} catch {
return String(error);
}
}
return String(error);
}
function errorEvent(error) {
const message = errorToMessage(error);
return new CustomEvent("error", {
bubbles: false,
composed: true,
detail: { message }
});
}
function streamClosedEvent(detail) {
return new CustomEvent("stream-closed", {
bubbles: true,
composed: true,
detail
});
}
function readyEvent() {
return new CustomEvent("ready", {
bubbles: true,
composed: true
});
}
function audioLevelChangedEvent(audioLevel) {
return new CustomEvent("audio-level-changed", {
bubbles: true,
composed: true,
detail: { audioLevel }
});
}
function networkActivityEvent(direction, data) {
return new CustomEvent("network-activity", {
bubbles: true,
composed: true,
detail: { data, direction }
});
}
function keybindingChangedEvent(key, code, keybinding, type) {
return new CustomEvent("keybinding-changed", {
bubbles: true,
composed: true,
detail: { code, key, keybinding, type }
});
}
function keybindingActivatedEvent(keyboardEvent) {
return new CustomEvent("keybinding-activated", {
bubbles: true,
cancelable: true,
composed: true,
detail: { keyboardEvent }
});
}
// dist/controllers/devices-controller.js
var __classPrivateFieldSet = function(receiver, state, value, kind, f5) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f5) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f5 : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return kind === "a" ? f5.call(receiver, value) : f5 ? f5.value = value : state.set(receiver, value), value;
};
var __classPrivateFieldGet = function(receiver, state, kind, f5) {
if (kind === "a" && !f5) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f5 : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f5 : kind === "a" ? f5.call(receiver) : f5 ? f5.value : state.get(receiver);
};
var _DevicesController_instances;
var _DevicesController_autoLoadedDevices;
var _DevicesController_loadingDevices;
var _DevicesController_deviceChangeHandler;
var _DevicesController_initialized;
var _DevicesController_setupDeviceChangeListener;
var _DevicesController_removeDeviceChangeListener;
var _DevicesController_loadDevices;
var DevicesController = class {
constructor(host) {
_DevicesController_instances.add(this);
_DevicesController_autoLoadedDevices.set(this, false);
_DevicesController_loadingDevices.set(this, false);
_DevicesController_deviceChangeHandler.set(this, void 0);
_DevicesController_initialized.set(this, false);
this.host = host;
host.addController(this);
}
initialize() {
__classPrivateFieldSet(this, _DevicesController_initialized, true, "f");
if (this.host.devices === void 0) {
__classPrivateFieldGet(this, _DevicesController_instances, "m", _DevicesController_loadDevices).call(this);
__classPrivateFieldGet(this, _DevicesController_instances, "m", _DevicesController_setupDeviceChangeListener).call(this);
}
}
hostDisconnected() {
__classPrivateFieldGet(this, _DevicesController_instances, "m", _DevicesController_removeDeviceChangeListener).call(this);
}
hostUpdate() {
if (!__classPrivateFieldGet(this, _DevicesController_initialized, "f")) {
return;
}
if (this.host.devices === void 0) {
__classPrivateFieldGet(this, _DevicesController_instances, "m", _DevicesController_loadDevices).call(this);
}
}
/**
* Clear the auto-loaded flag (when devices are set externally)
*/
clearAutoLoadedFlag() {
__classPrivateFieldSet(this, _DevicesController_autoLoadedDevices, false, "f");
}
};
_DevicesController_autoLoadedDevices = /* @__PURE__ */ new WeakMap(), _DevicesController_loadingDevices = /* @__PURE__ */ new WeakMap(), _DevicesController_deviceChangeHandler = /* @__PURE__ */ new WeakMap(), _DevicesController_initialized = /* @__PURE__ */ new WeakMap(), _DevicesController_instances = /* @__PURE__ */ new WeakSet(), _DevicesController_setupDeviceChangeListener = function _DevicesController_setupDeviceChangeListener2() {
if (__classPrivateFieldGet(this, _DevicesController_deviceChangeHandler, "f")) {
return;
}
__classPrivateFieldSet(this, _DevicesController_deviceChangeHandler, () => {
if (__classPrivateFieldGet(this, _DevicesController_autoLoadedDevices, "f")) {
__classPrivateFieldGet(this, _DevicesController_instances, "m", _DevicesController_loadDevices).call(this);
}
}, "f");
navigator.mediaDevices.addEventListener("devicechange", __classPrivateFieldGet(this, _DevicesController_deviceChangeHandler, "f"));
}, _DevicesController_removeDeviceChangeListener = function _DevicesController_removeDeviceChangeListener2() {
if (!__classPrivateFieldGet(this, _DevicesController_deviceChangeHandler, "f")) {
return;
}
navigator.mediaDevices.removeEventListener("devicechange", __classPrivateFieldGet(this, _DevicesController_deviceChangeHandler, "f"));
__classPrivateFieldSet(this, _DevicesController_deviceChangeHandler, void 0, "f");
}, _DevicesController_loadDevices = async function _DevicesController_loadDevices2() {
if (__classPrivateFieldGet(this, _DevicesController_loadingDevices, "f")) {
return;
}
__classPrivateFieldSet(this, _DevicesController_loadingDevices, true, "f");
try {
const { devices, defaultDevice } = await getAudioDevices();
__classPrivateFieldSet(this, _DevicesController_autoLoadedDevices, true, "f");
this.host._devices = devices;
const previousDevice = this.host.selectedDevice;
const selectedDevice = (previousDevice && devices.find((d3) => d3.deviceId === previousDevice.deviceId)) ?? defaultDevice;
this.host.selectedDevice = selectedDevice;
this.host.requestUpdate();
this.host.dispatchEvent(recordingDevicesChangedEvent(devices, selectedDevice));
this.host.dispatchEvent(readyEvent());
} catch (error) {
this.host.dispatchEvent(errorEvent(error));
} finally {
__classPrivateFieldSet(this, _DevicesController_loadingDevices, false, "f");
}
};
// dist/utils/languages.js
var DEFAULT_LANGUAGES_BY_REGION = {
default: LANGUAGES_SUPPORTED_EU,
eu: LANGUAGES_SUPPORTED_EU,
us: LANGUAGES_SUPPORTED_US
};
function getLanguageName(languageCode) {
try {
const userLocale = navigator.language || "en";
const displayNames = new Intl.DisplayNames([userLocale], {
type: "language"
});
const languageName = displayNames.of(languageCode);
return languageName || languageCode;
} catch {
return languageCode;
}
}
function getLanguagesByRegion(region) {
const languages = DEFAULT_LANGUAGES_BY_REGION[region || "default"] || DEFAULT_LANGUAGES_BY_REGION["default"];
const defaultLanguage = languages?.[0];
return { defaultLanguage, languages };
}
// dist/controllers/languages-controller.js
var __classPrivateFieldSet2 = function(receiver, state, value, kind, f5) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f5) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f5 : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return kind === "a" ? f5.call(receiver, value) : f5 ? f5.value = value : state.set(receiver, value), value;
};
var __classPrivateFieldGet2 = function(receiver, state, kind, f5) {
if (kind === "a" && !f5) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f5 : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f5 : kind === "a" ? f5.call(receiver) : f5 ? f5.value : state.get(receiver);
};
var _LanguagesController_instances;
var _LanguagesController_autoLoadedLanguages;
var _LanguagesController_loadingLanguages;
var _LanguagesController_previousRegion;
var _LanguagesController_initialized;
var _LanguagesController_loadLanguages;
var LanguagesController = class {
constructor(host) {
_LanguagesController_instances.add(this);
_LanguagesController_autoLoadedLanguages.set(this, false);
_LanguagesController_loadingLanguages.set(this, false);
_LanguagesController_previousRegion.set(this, void 0);
_LanguagesController_initialized.set(this, false);
this.host = host;
host.addController(this);
}
initialize() {
__classPrivateFieldSet2(this, _LanguagesController_initialized, true, "f");
if (this.host._languages === void 0) {
__classPrivateFieldGet2(this, _LanguagesController_instances, "m", _LanguagesController_loadLanguages).call(this);
}
}
hostUpdate() {
if (!__classPrivateFieldGet2(this, _LanguagesController_initialized, "f")) {
return;
}
if (__classPrivateFieldGet2(this, _LanguagesController_previousRegion, "f") !== this.host.region && __classPrivateFieldGet2(this, _LanguagesController_autoLoadedLanguages, "f") || this.host._languages === void 0) {
__classPrivateFieldGet2(this, _LanguagesController_instances, "m", _LanguagesController_loadLanguages).call(this);
}
__classPrivateFieldSet2(this, _LanguagesController_previousRegion, this.host.region, "f");
}
/**
* Clear the auto-loaded flag (when languages are set externally)
*/
clearAutoLoadedFlag() {
__classPrivateFieldSet2(this, _LanguagesController_autoLoadedLanguages, false, "f");
}
};
_LanguagesController_autoLoadedLanguages = /* @__PURE__ */ new WeakMap(), _LanguagesController_loadingLanguages = /* @__PURE__ */ new WeakMap(), _LanguagesController_previousRegion = /* @__PURE__ */ new WeakMap(), _LanguagesController_initialized = /* @__PURE__ */ new WeakMap(), _LanguagesController_instances = /* @__PURE__ */ new WeakSet(), _LanguagesController_loadLanguages = async function _LanguagesController_loadLanguages2() {
if (__classPrivateFieldGet2(this, _LanguagesController_loadingLanguages, "f")) {
return;
}
__classPrivateFieldSet2(this, _LanguagesController_loadingLanguages, true, "f");
try {
const { languages, defaultLanguage } = getLanguagesByRegion(this.host.region);
__classPrivateFieldSet2(this, _LanguagesController_autoLoadedLanguages, true, "f");
this.host._languages = languages;
const previousLanguage = this.host.dictationConfig?.primaryLanguage;
const selectedLanguage = previousLanguage && languages.includes(previousLanguage) ? previousLanguage : defaultLanguage;
this.host.dictationConfig = {
...this.host.dictationConfig,
primaryLanguage: selectedLanguage || "en"
};
this.host.requestUpdate();
this.host.dispatchEvent(languagesChangedEvent(languages, selectedLanguage));
} catch (error) {
this.host.dispatchEvent(errorEvent(error));
} finally {
__classPrivateFieldSet2(this, _LanguagesController_loadingLanguages, false, "f");
}
};
// dist/styles/component-styles.js
var ComponentStyles = i`
:host {
font-family: var(--component-font-family, -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, Cantarell, Ubuntu, roboto, noto, helvetica, arial, sans-serif);
}
.wrapper {
background-color: var(--card-background, light-dark(#fff, #333));
border: 1px solid var(--card-border-color, light-dark(#ddd, #555));
border-radius: var(--card-border-radius, 8px);
box-shadow: var(--card-box-shadow, 0 2px 5px rgba(0, 0, 0, 0.1));
padding: var(--card-padding, 4px);
display: flex;
gap: 4px;
height: 46px;
width: fit-content;
box-sizing: border-box;
overflow: hidden;
}
`