diff --git "a/src/backend/gradio_unifiedaudio/templates/component/index-c48f56d2.js" "b/src/backend/gradio_unifiedaudio/templates/component/index-c48f56d2.js"
new file mode 100644--- /dev/null
+++ "b/src/backend/gradio_unifiedaudio/templates/component/index-c48f56d2.js"
@@ -0,0 +1,9275 @@
+const Qr = [
+ { color: "red", primary: 600, secondary: 100 },
+ { color: "green", primary: 600, secondary: 100 },
+ { color: "blue", primary: 600, secondary: 100 },
+ { color: "yellow", primary: 500, secondary: 100 },
+ { color: "purple", primary: 600, secondary: 100 },
+ { color: "teal", primary: 600, secondary: 100 },
+ { color: "orange", primary: 600, secondary: 100 },
+ { color: "cyan", primary: 600, secondary: 100 },
+ { color: "lime", primary: 500, secondary: 100 },
+ { color: "pink", primary: 600, secondary: 100 }
+], ei = {
+ inherit: "inherit",
+ current: "currentColor",
+ transparent: "transparent",
+ black: "#000",
+ white: "#fff",
+ slate: {
+ 50: "#f8fafc",
+ 100: "#f1f5f9",
+ 200: "#e2e8f0",
+ 300: "#cbd5e1",
+ 400: "#94a3b8",
+ 500: "#64748b",
+ 600: "#475569",
+ 700: "#334155",
+ 800: "#1e293b",
+ 900: "#0f172a",
+ 950: "#020617"
+ },
+ gray: {
+ 50: "#f9fafb",
+ 100: "#f3f4f6",
+ 200: "#e5e7eb",
+ 300: "#d1d5db",
+ 400: "#9ca3af",
+ 500: "#6b7280",
+ 600: "#4b5563",
+ 700: "#374151",
+ 800: "#1f2937",
+ 900: "#111827",
+ 950: "#030712"
+ },
+ zinc: {
+ 50: "#fafafa",
+ 100: "#f4f4f5",
+ 200: "#e4e4e7",
+ 300: "#d4d4d8",
+ 400: "#a1a1aa",
+ 500: "#71717a",
+ 600: "#52525b",
+ 700: "#3f3f46",
+ 800: "#27272a",
+ 900: "#18181b",
+ 950: "#09090b"
+ },
+ neutral: {
+ 50: "#fafafa",
+ 100: "#f5f5f5",
+ 200: "#e5e5e5",
+ 300: "#d4d4d4",
+ 400: "#a3a3a3",
+ 500: "#737373",
+ 600: "#525252",
+ 700: "#404040",
+ 800: "#262626",
+ 900: "#171717",
+ 950: "#0a0a0a"
+ },
+ stone: {
+ 50: "#fafaf9",
+ 100: "#f5f5f4",
+ 200: "#e7e5e4",
+ 300: "#d6d3d1",
+ 400: "#a8a29e",
+ 500: "#78716c",
+ 600: "#57534e",
+ 700: "#44403c",
+ 800: "#292524",
+ 900: "#1c1917",
+ 950: "#0c0a09"
+ },
+ red: {
+ 50: "#fef2f2",
+ 100: "#fee2e2",
+ 200: "#fecaca",
+ 300: "#fca5a5",
+ 400: "#f87171",
+ 500: "#ef4444",
+ 600: "#dc2626",
+ 700: "#b91c1c",
+ 800: "#991b1b",
+ 900: "#7f1d1d",
+ 950: "#450a0a"
+ },
+ orange: {
+ 50: "#fff7ed",
+ 100: "#ffedd5",
+ 200: "#fed7aa",
+ 300: "#fdba74",
+ 400: "#fb923c",
+ 500: "#f97316",
+ 600: "#ea580c",
+ 700: "#c2410c",
+ 800: "#9a3412",
+ 900: "#7c2d12",
+ 950: "#431407"
+ },
+ amber: {
+ 50: "#fffbeb",
+ 100: "#fef3c7",
+ 200: "#fde68a",
+ 300: "#fcd34d",
+ 400: "#fbbf24",
+ 500: "#f59e0b",
+ 600: "#d97706",
+ 700: "#b45309",
+ 800: "#92400e",
+ 900: "#78350f",
+ 950: "#451a03"
+ },
+ yellow: {
+ 50: "#fefce8",
+ 100: "#fef9c3",
+ 200: "#fef08a",
+ 300: "#fde047",
+ 400: "#facc15",
+ 500: "#eab308",
+ 600: "#ca8a04",
+ 700: "#a16207",
+ 800: "#854d0e",
+ 900: "#713f12",
+ 950: "#422006"
+ },
+ lime: {
+ 50: "#f7fee7",
+ 100: "#ecfccb",
+ 200: "#d9f99d",
+ 300: "#bef264",
+ 400: "#a3e635",
+ 500: "#84cc16",
+ 600: "#65a30d",
+ 700: "#4d7c0f",
+ 800: "#3f6212",
+ 900: "#365314",
+ 950: "#1a2e05"
+ },
+ green: {
+ 50: "#f0fdf4",
+ 100: "#dcfce7",
+ 200: "#bbf7d0",
+ 300: "#86efac",
+ 400: "#4ade80",
+ 500: "#22c55e",
+ 600: "#16a34a",
+ 700: "#15803d",
+ 800: "#166534",
+ 900: "#14532d",
+ 950: "#052e16"
+ },
+ emerald: {
+ 50: "#ecfdf5",
+ 100: "#d1fae5",
+ 200: "#a7f3d0",
+ 300: "#6ee7b7",
+ 400: "#34d399",
+ 500: "#10b981",
+ 600: "#059669",
+ 700: "#047857",
+ 800: "#065f46",
+ 900: "#064e3b",
+ 950: "#022c22"
+ },
+ teal: {
+ 50: "#f0fdfa",
+ 100: "#ccfbf1",
+ 200: "#99f6e4",
+ 300: "#5eead4",
+ 400: "#2dd4bf",
+ 500: "#14b8a6",
+ 600: "#0d9488",
+ 700: "#0f766e",
+ 800: "#115e59",
+ 900: "#134e4a",
+ 950: "#042f2e"
+ },
+ cyan: {
+ 50: "#ecfeff",
+ 100: "#cffafe",
+ 200: "#a5f3fc",
+ 300: "#67e8f9",
+ 400: "#22d3ee",
+ 500: "#06b6d4",
+ 600: "#0891b2",
+ 700: "#0e7490",
+ 800: "#155e75",
+ 900: "#164e63",
+ 950: "#083344"
+ },
+ sky: {
+ 50: "#f0f9ff",
+ 100: "#e0f2fe",
+ 200: "#bae6fd",
+ 300: "#7dd3fc",
+ 400: "#38bdf8",
+ 500: "#0ea5e9",
+ 600: "#0284c7",
+ 700: "#0369a1",
+ 800: "#075985",
+ 900: "#0c4a6e",
+ 950: "#082f49"
+ },
+ blue: {
+ 50: "#eff6ff",
+ 100: "#dbeafe",
+ 200: "#bfdbfe",
+ 300: "#93c5fd",
+ 400: "#60a5fa",
+ 500: "#3b82f6",
+ 600: "#2563eb",
+ 700: "#1d4ed8",
+ 800: "#1e40af",
+ 900: "#1e3a8a",
+ 950: "#172554"
+ },
+ indigo: {
+ 50: "#eef2ff",
+ 100: "#e0e7ff",
+ 200: "#c7d2fe",
+ 300: "#a5b4fc",
+ 400: "#818cf8",
+ 500: "#6366f1",
+ 600: "#4f46e5",
+ 700: "#4338ca",
+ 800: "#3730a3",
+ 900: "#312e81",
+ 950: "#1e1b4b"
+ },
+ violet: {
+ 50: "#f5f3ff",
+ 100: "#ede9fe",
+ 200: "#ddd6fe",
+ 300: "#c4b5fd",
+ 400: "#a78bfa",
+ 500: "#8b5cf6",
+ 600: "#7c3aed",
+ 700: "#6d28d9",
+ 800: "#5b21b6",
+ 900: "#4c1d95",
+ 950: "#2e1065"
+ },
+ purple: {
+ 50: "#faf5ff",
+ 100: "#f3e8ff",
+ 200: "#e9d5ff",
+ 300: "#d8b4fe",
+ 400: "#c084fc",
+ 500: "#a855f7",
+ 600: "#9333ea",
+ 700: "#7e22ce",
+ 800: "#6b21a8",
+ 900: "#581c87",
+ 950: "#3b0764"
+ },
+ fuchsia: {
+ 50: "#fdf4ff",
+ 100: "#fae8ff",
+ 200: "#f5d0fe",
+ 300: "#f0abfc",
+ 400: "#e879f9",
+ 500: "#d946ef",
+ 600: "#c026d3",
+ 700: "#a21caf",
+ 800: "#86198f",
+ 900: "#701a75",
+ 950: "#4a044e"
+ },
+ pink: {
+ 50: "#fdf2f8",
+ 100: "#fce7f3",
+ 200: "#fbcfe8",
+ 300: "#f9a8d4",
+ 400: "#f472b6",
+ 500: "#ec4899",
+ 600: "#db2777",
+ 700: "#be185d",
+ 800: "#9d174d",
+ 900: "#831843",
+ 950: "#500724"
+ },
+ rose: {
+ 50: "#fff1f2",
+ 100: "#ffe4e6",
+ 200: "#fecdd3",
+ 300: "#fda4af",
+ 400: "#fb7185",
+ 500: "#f43f5e",
+ 600: "#e11d48",
+ 700: "#be123c",
+ 800: "#9f1239",
+ 900: "#881337",
+ 950: "#4c0519"
+ }
+};
+Qr.reduce(
+ (t, { color: e, primary: n, secondary: i }) => ({
+ ...t,
+ [e]: {
+ primary: ei[e][n],
+ secondary: ei[e][i]
+ }
+ }),
+ {}
+);
+function Yr(t) {
+ let e, n = t[0], i = 1;
+ for (; i < t.length; ) {
+ const r = t[i], s = t[i + 1];
+ if (i += 2, (r === "optionalAccess" || r === "optionalCall") && n == null)
+ return;
+ r === "access" || r === "optionalAccess" ? (e = n, n = s(n)) : (r === "call" || r === "optionalCall") && (n = s((...o) => n.call(e, ...o)), e = void 0);
+ }
+ return n;
+}
+class Rt extends Error {
+ constructor(e) {
+ super(e), this.name = "ShareError";
+ }
+}
+async function Kr(t, e) {
+ if (window.__gradio_space__ == null)
+ throw new Rt("Must be on Spaces to share.");
+ let n, i, r;
+ if (e === "url") {
+ const a = await fetch(t);
+ n = await a.blob(), i = a.headers.get("content-type") || "", r = a.headers.get("content-disposition") || "";
+ } else
+ n = $r(t), i = t.split(";")[0].split(":")[1], r = "file" + i.split("/")[1];
+ const s = new File([n], r, { type: i }), o = await fetch("https://huggingface.co./uploads", {
+ method: "POST",
+ body: s,
+ headers: {
+ "Content-Type": s.type,
+ "X-Requested-With": "XMLHttpRequest"
+ }
+ });
+ if (!o.ok) {
+ if (Yr([o, "access", (a) => a.headers, "access", (a) => a.get, "call", (a) => a("content-type"), "optionalAccess", (a) => a.includes, "call", (a) => a("application/json")])) {
+ const a = await o.json();
+ throw new Rt(`Upload failed: ${a.error}`);
+ }
+ throw new Rt("Upload failed.");
+ }
+ return await o.text();
+}
+function $r(t) {
+ for (var e = t.split(","), n = e[0].match(/:(.*?);/)[1], i = atob(e[1]), r = i.length, s = new Uint8Array(r); r--; )
+ s[r] = i.charCodeAt(r);
+ return new Blob([s], { type: n });
+}
+const {
+ SvelteComponent: es,
+ append: Sn,
+ attr: Ne,
+ bubble: ts,
+ create_component: ns,
+ destroy_component: is,
+ detach: $i,
+ element: Cn,
+ init: rs,
+ insert: er,
+ listen: ss,
+ mount_component: os,
+ safe_not_equal: as,
+ set_data: ls,
+ space: us,
+ text: cs,
+ toggle_class: xe,
+ transition_in: hs,
+ transition_out: ds
+} = window.__gradio__svelte__internal;
+function ti(t) {
+ let e, n;
+ return {
+ c() {
+ e = Cn("span"), n = cs(
+ /*label*/
+ t[1]
+ ), Ne(e, "class", "svelte-xtz2g8");
+ },
+ m(i, r) {
+ er(i, e, r), Sn(e, n);
+ },
+ p(i, r) {
+ r & /*label*/
+ 2 && ls(
+ n,
+ /*label*/
+ i[1]
+ );
+ },
+ d(i) {
+ i && $i(e);
+ }
+ };
+}
+function fs(t) {
+ let e, n, i, r, s, o, u, a = (
+ /*show_label*/
+ t[2] && ti(t)
+ );
+ return r = new /*Icon*/
+ t[0]({}), {
+ c() {
+ e = Cn("button"), a && a.c(), n = us(), i = Cn("div"), ns(r.$$.fragment), Ne(i, "class", "svelte-xtz2g8"), xe(
+ i,
+ "small",
+ /*size*/
+ t[4] === "small"
+ ), xe(
+ i,
+ "large",
+ /*size*/
+ t[4] === "large"
+ ), Ne(
+ e,
+ "aria-label",
+ /*label*/
+ t[1]
+ ), Ne(
+ e,
+ "title",
+ /*label*/
+ t[1]
+ ), Ne(e, "class", "svelte-xtz2g8"), xe(
+ e,
+ "pending",
+ /*pending*/
+ t[3]
+ ), xe(
+ e,
+ "padded",
+ /*padded*/
+ t[5]
+ );
+ },
+ m(c, l) {
+ er(c, e, l), a && a.m(e, null), Sn(e, n), Sn(e, i), os(r, i, null), s = !0, o || (u = ss(
+ e,
+ "click",
+ /*click_handler*/
+ t[6]
+ ), o = !0);
+ },
+ p(c, [l]) {
+ /*show_label*/
+ c[2] ? a ? a.p(c, l) : (a = ti(c), a.c(), a.m(e, n)) : a && (a.d(1), a = null), (!s || l & /*size*/
+ 16) && xe(
+ i,
+ "small",
+ /*size*/
+ c[4] === "small"
+ ), (!s || l & /*size*/
+ 16) && xe(
+ i,
+ "large",
+ /*size*/
+ c[4] === "large"
+ ), (!s || l & /*label*/
+ 2) && Ne(
+ e,
+ "aria-label",
+ /*label*/
+ c[1]
+ ), (!s || l & /*label*/
+ 2) && Ne(
+ e,
+ "title",
+ /*label*/
+ c[1]
+ ), (!s || l & /*pending*/
+ 8) && xe(
+ e,
+ "pending",
+ /*pending*/
+ c[3]
+ ), (!s || l & /*padded*/
+ 32) && xe(
+ e,
+ "padded",
+ /*padded*/
+ c[5]
+ );
+ },
+ i(c) {
+ s || (hs(r.$$.fragment, c), s = !0);
+ },
+ o(c) {
+ ds(r.$$.fragment, c), s = !1;
+ },
+ d(c) {
+ c && $i(e), a && a.d(), is(r), o = !1, u();
+ }
+ };
+}
+function ms(t, e, n) {
+ let { Icon: i } = e, { label: r = "" } = e, { show_label: s = !1 } = e, { pending: o = !1 } = e, { size: u = "small" } = e, { padded: a = !0 } = e;
+ function c(l) {
+ ts.call(this, t, l);
+ }
+ return t.$$set = (l) => {
+ "Icon" in l && n(0, i = l.Icon), "label" in l && n(1, r = l.label), "show_label" in l && n(2, s = l.show_label), "pending" in l && n(3, o = l.pending), "size" in l && n(4, u = l.size), "padded" in l && n(5, a = l.padded);
+ }, [i, r, s, o, u, a, c];
+}
+class ps extends es {
+ constructor(e) {
+ super(), rs(this, e, ms, fs, as, {
+ Icon: 0,
+ label: 1,
+ show_label: 2,
+ pending: 3,
+ size: 4,
+ padded: 5
+ });
+ }
+}
+const {
+ SvelteComponent: _s,
+ append: gs,
+ attr: $t,
+ binding_callbacks: bs,
+ create_slot: vs,
+ detach: ys,
+ element: ni,
+ get_all_dirty_from_scope: ws,
+ get_slot_changes: Es,
+ init: Ss,
+ insert: Cs,
+ safe_not_equal: As,
+ toggle_class: Te,
+ transition_in: xs,
+ transition_out: Ts,
+ update_slot_base: Ps
+} = window.__gradio__svelte__internal;
+function Rs(t) {
+ let e, n, i;
+ const r = (
+ /*#slots*/
+ t[5].default
+ ), s = vs(
+ r,
+ t,
+ /*$$scope*/
+ t[4],
+ null
+ );
+ return {
+ c() {
+ e = ni("div"), n = ni("div"), s && s.c(), $t(n, "class", "icon svelte-3w3rth"), $t(e, "class", "empty svelte-3w3rth"), $t(e, "aria-label", "Empty value"), Te(
+ e,
+ "small",
+ /*size*/
+ t[0] === "small"
+ ), Te(
+ e,
+ "large",
+ /*size*/
+ t[0] === "large"
+ ), Te(
+ e,
+ "unpadded_box",
+ /*unpadded_box*/
+ t[1]
+ ), Te(
+ e,
+ "small_parent",
+ /*parent_height*/
+ t[3]
+ );
+ },
+ m(o, u) {
+ Cs(o, e, u), gs(e, n), s && s.m(n, null), t[6](e), i = !0;
+ },
+ p(o, [u]) {
+ s && s.p && (!i || u & /*$$scope*/
+ 16) && Ps(
+ s,
+ r,
+ o,
+ /*$$scope*/
+ o[4],
+ i ? Es(
+ r,
+ /*$$scope*/
+ o[4],
+ u,
+ null
+ ) : ws(
+ /*$$scope*/
+ o[4]
+ ),
+ null
+ ), (!i || u & /*size*/
+ 1) && Te(
+ e,
+ "small",
+ /*size*/
+ o[0] === "small"
+ ), (!i || u & /*size*/
+ 1) && Te(
+ e,
+ "large",
+ /*size*/
+ o[0] === "large"
+ ), (!i || u & /*unpadded_box*/
+ 2) && Te(
+ e,
+ "unpadded_box",
+ /*unpadded_box*/
+ o[1]
+ ), (!i || u & /*parent_height*/
+ 8) && Te(
+ e,
+ "small_parent",
+ /*parent_height*/
+ o[3]
+ );
+ },
+ i(o) {
+ i || (xs(s, o), i = !0);
+ },
+ o(o) {
+ Ts(s, o), i = !1;
+ },
+ d(o) {
+ o && ys(e), s && s.d(o), t[6](null);
+ }
+ };
+}
+function ks(t) {
+ let e, n = t[0], i = 1;
+ for (; i < t.length; ) {
+ const r = t[i], s = t[i + 1];
+ if (i += 2, (r === "optionalAccess" || r === "optionalCall") && n == null)
+ return;
+ r === "access" || r === "optionalAccess" ? (e = n, n = s(n)) : (r === "call" || r === "optionalCall") && (n = s((...o) => n.call(e, ...o)), e = void 0);
+ }
+ return n;
+}
+function Bs(t, e, n) {
+ let i, { $$slots: r = {}, $$scope: s } = e, { size: o = "small" } = e, { unpadded_box: u = !1 } = e, a;
+ function c(d) {
+ if (!d)
+ return !1;
+ const { height: h } = d.getBoundingClientRect(), { height: m } = ks([
+ d,
+ "access",
+ (p) => p.parentElement,
+ "optionalAccess",
+ (p) => p.getBoundingClientRect,
+ "call",
+ (p) => p()
+ ]) || { height: h };
+ return h > m + 2;
+ }
+ function l(d) {
+ bs[d ? "unshift" : "push"](() => {
+ a = d, n(2, a);
+ });
+ }
+ return t.$$set = (d) => {
+ "size" in d && n(0, o = d.size), "unpadded_box" in d && n(1, u = d.unpadded_box), "$$scope" in d && n(4, s = d.$$scope);
+ }, t.$$.update = () => {
+ t.$$.dirty & /*el*/
+ 4 && n(3, i = c(a));
+ }, [o, u, a, i, s, r, l];
+}
+class tr extends _s {
+ constructor(e) {
+ super(), Ss(this, e, Bs, Rs, As, { size: 0, unpadded_box: 1 });
+ }
+}
+const {
+ SvelteComponent: Ls,
+ append: Ds,
+ attr: ce,
+ detach: Hs,
+ init: Os,
+ insert: Ms,
+ noop: en,
+ safe_not_equal: Ns,
+ svg_element: ii
+} = window.__gradio__svelte__internal;
+function Is(t) {
+ let e, n;
+ return {
+ c() {
+ e = ii("svg"), n = ii("path"), ce(n, "stroke", "currentColor"), ce(n, "stroke-width", "1.5"), ce(n, "stroke-linecap", "round"), ce(n, "stroke-linejoin", "round"), ce(n, "d", "M21.044 5.704a.6.6 0 0 1 .956.483v11.626a.6.6 0 0 1-.956.483l-7.889-5.813a.6.6 0 0 1 0-.966l7.89-5.813ZM10.044 5.704a.6.6 0 0 1 .956.483v11.626a.6.6 0 0 1-.956.483l-7.888-5.813a.6.6 0 0 1 0-.966l7.888-5.813Z"), ce(e, "xmlns", "http://www.w3.org/2000/svg"), ce(e, "width", "24px"), ce(e, "height", "24px"), ce(e, "fill", "currentColor"), ce(e, "stroke-width", "1.5"), ce(e, "viewBox", "0 0 24 24"), ce(e, "color", "currentColor");
+ },
+ m(i, r) {
+ Ms(i, e, r), Ds(e, n);
+ },
+ p: en,
+ i: en,
+ o: en,
+ d(i) {
+ i && Hs(e);
+ }
+ };
+}
+class Us extends Ls {
+ constructor(e) {
+ super(), Os(this, e, null, Is, Ns, {});
+ }
+}
+const {
+ SvelteComponent: Gs,
+ append: Fs,
+ attr: ft,
+ detach: Ws,
+ init: js,
+ insert: zs,
+ noop: tn,
+ safe_not_equal: qs,
+ svg_element: ri
+} = window.__gradio__svelte__internal;
+function Vs(t) {
+ let e, n;
+ return {
+ c() {
+ e = ri("svg"), n = ri("path"), ft(n, "d", "M23,20a5,5,0,0,0-3.89,1.89L11.8,17.32a4.46,4.46,0,0,0,0-2.64l7.31-4.57A5,5,0,1,0,18,7a4.79,4.79,0,0,0,.2,1.32l-7.31,4.57a5,5,0,1,0,0,6.22l7.31,4.57A4.79,4.79,0,0,0,18,25a5,5,0,1,0,5-5ZM23,4a3,3,0,1,1-3,3A3,3,0,0,1,23,4ZM7,19a3,3,0,1,1,3-3A3,3,0,0,1,7,19Zm16,9a3,3,0,1,1,3-3A3,3,0,0,1,23,28Z"), ft(n, "fill", "currentColor"), ft(e, "id", "icon"), ft(e, "xmlns", "http://www.w3.org/2000/svg"), ft(e, "viewBox", "0 0 32 32");
+ },
+ m(i, r) {
+ zs(i, e, r), Fs(e, n);
+ },
+ p: tn,
+ i: tn,
+ o: tn,
+ d(i) {
+ i && Ws(e);
+ }
+ };
+}
+class Xs extends Gs {
+ constructor(e) {
+ super(), js(this, e, null, Vs, qs, {});
+ }
+}
+const {
+ SvelteComponent: Zs,
+ append: Js,
+ attr: he,
+ detach: Qs,
+ init: Ys,
+ insert: Ks,
+ noop: nn,
+ safe_not_equal: $s,
+ svg_element: si
+} = window.__gradio__svelte__internal;
+function eo(t) {
+ let e, n;
+ return {
+ c() {
+ e = si("svg"), n = si("path"), he(n, "stroke", "currentColor"), he(n, "stroke-width", "1.5"), he(n, "stroke-linecap", "round"), he(n, "stroke-linejoin", "round"), he(n, "d", "M2.956 5.704A.6.6 0 0 0 2 6.187v11.626a.6.6 0 0 0 .956.483l7.889-5.813a.6.6 0 0 0 0-.966l-7.89-5.813ZM13.956 5.704a.6.6 0 0 0-.956.483v11.626a.6.6 0 0 0 .956.483l7.889-5.813a.6.6 0 0 0 0-.966l-7.89-5.813Z"), he(e, "xmlns", "http://www.w3.org/2000/svg"), he(e, "width", "24px"), he(e, "height", "24px"), he(e, "fill", "currentColor"), he(e, "stroke-width", "1.5"), he(e, "viewBox", "0 0 24 24"), he(e, "color", "currentColor");
+ },
+ m(i, r) {
+ Ks(i, e, r), Js(e, n);
+ },
+ p: nn,
+ i: nn,
+ o: nn,
+ d(i) {
+ i && Qs(e);
+ }
+ };
+}
+class to extends Zs {
+ constructor(e) {
+ super(), Ys(this, e, null, eo, $s, {});
+ }
+}
+const {
+ SvelteComponent: no,
+ append: rn,
+ attr: Y,
+ detach: io,
+ init: ro,
+ insert: so,
+ noop: sn,
+ safe_not_equal: oo,
+ svg_element: At
+} = window.__gradio__svelte__internal;
+function ao(t) {
+ let e, n, i, r;
+ return {
+ c() {
+ e = At("svg"), n = At("path"), i = At("circle"), r = At("circle"), Y(n, "d", "M9 18V5l12-2v13"), Y(i, "cx", "6"), Y(i, "cy", "18"), Y(i, "r", "3"), Y(r, "cx", "18"), Y(r, "cy", "16"), Y(r, "r", "3"), Y(e, "xmlns", "http://www.w3.org/2000/svg"), Y(e, "width", "100%"), Y(e, "height", "100%"), Y(e, "viewBox", "0 0 24 24"), Y(e, "fill", "none"), Y(e, "stroke", "currentColor"), Y(e, "stroke-width", "1.5"), Y(e, "stroke-linecap", "round"), Y(e, "stroke-linejoin", "round"), Y(e, "class", "feather feather-music");
+ },
+ m(s, o) {
+ so(s, e, o), rn(e, n), rn(e, i), rn(e, r);
+ },
+ p: sn,
+ i: sn,
+ o: sn,
+ d(s) {
+ s && io(e);
+ }
+ };
+}
+class nr extends no {
+ constructor(e) {
+ super(), ro(this, e, null, ao, oo, {});
+ }
+}
+const {
+ SvelteComponent: lo,
+ append: oi,
+ attr: K,
+ detach: uo,
+ init: co,
+ insert: ho,
+ noop: on,
+ safe_not_equal: fo,
+ svg_element: an
+} = window.__gradio__svelte__internal;
+function mo(t) {
+ let e, n, i;
+ return {
+ c() {
+ e = an("svg"), n = an("rect"), i = an("rect"), K(n, "x", "6"), K(n, "y", "4"), K(n, "width", "4"), K(n, "height", "16"), K(i, "x", "14"), K(i, "y", "4"), K(i, "width", "4"), K(i, "height", "16"), K(e, "xmlns", "http://www.w3.org/2000/svg"), K(e, "width", "100%"), K(e, "height", "100%"), K(e, "viewBox", "0 0 24 24"), K(e, "fill", "currentColor"), K(e, "stroke", "currentColor"), K(e, "stroke-width", "1.5"), K(e, "stroke-linecap", "round"), K(e, "stroke-linejoin", "round");
+ },
+ m(r, s) {
+ ho(r, e, s), oi(e, n), oi(e, i);
+ },
+ p: on,
+ i: on,
+ o: on,
+ d(r) {
+ r && uo(e);
+ }
+ };
+}
+class po extends lo {
+ constructor(e) {
+ super(), co(this, e, null, mo, fo, {});
+ }
+}
+const {
+ SvelteComponent: _o,
+ append: go,
+ attr: ve,
+ detach: bo,
+ init: vo,
+ insert: yo,
+ noop: ln,
+ safe_not_equal: wo,
+ svg_element: ai
+} = window.__gradio__svelte__internal;
+function Eo(t) {
+ let e, n;
+ return {
+ c() {
+ e = ai("svg"), n = ai("polygon"), ve(n, "points", "5 3 19 12 5 21 5 3"), ve(e, "xmlns", "http://www.w3.org/2000/svg"), ve(e, "width", "100%"), ve(e, "height", "100%"), ve(e, "viewBox", "0 0 24 24"), ve(e, "fill", "currentColor"), ve(e, "stroke", "currentColor"), ve(e, "stroke-width", "1.5"), ve(e, "stroke-linecap", "round"), ve(e, "stroke-linejoin", "round");
+ },
+ m(i, r) {
+ yo(i, e, r), go(e, n);
+ },
+ p: ln,
+ i: ln,
+ o: ln,
+ d(i) {
+ i && bo(e);
+ }
+ };
+}
+class So extends _o {
+ constructor(e) {
+ super(), vo(this, e, null, Eo, wo, {});
+ }
+}
+const {
+ SvelteComponent: Co,
+ append: mt,
+ attr: I,
+ detach: Ao,
+ init: xo,
+ insert: To,
+ noop: un,
+ safe_not_equal: Po,
+ svg_element: Xe
+} = window.__gradio__svelte__internal;
+function Ro(t) {
+ let e, n, i, r, s, o;
+ return {
+ c() {
+ e = Xe("svg"), n = Xe("circle"), i = Xe("circle"), r = Xe("line"), s = Xe("line"), o = Xe("line"), I(n, "cx", "6"), I(n, "cy", "6"), I(n, "r", "3"), I(i, "cx", "6"), I(i, "cy", "18"), I(i, "r", "3"), I(r, "x1", "20"), I(r, "y1", "4"), I(r, "x2", "8.12"), I(r, "y2", "15.88"), I(s, "x1", "14.47"), I(s, "y1", "14.48"), I(s, "x2", "20"), I(s, "y2", "20"), I(o, "x1", "8.12"), I(o, "y1", "8.12"), I(o, "x2", "12"), I(o, "y2", "12"), I(e, "xmlns", "http://www.w3.org/2000/svg"), I(e, "width", "20"), I(e, "height", "20"), I(e, "viewBox", "0 0 24 24"), I(e, "fill", "none"), I(e, "stroke", "currentColor"), I(e, "stroke-width", "2"), I(e, "stroke-linecap", "round"), I(e, "stroke-linejoin", "round"), I(e, "class", "feather feather-scissors");
+ },
+ m(u, a) {
+ To(u, e, a), mt(e, n), mt(e, i), mt(e, r), mt(e, s), mt(e, o);
+ },
+ p: un,
+ i: un,
+ o: un,
+ d(u) {
+ u && Ao(e);
+ }
+ };
+}
+class ko extends Co {
+ constructor(e) {
+ super(), xo(this, e, null, Ro, Po, {});
+ }
+}
+const {
+ SvelteComponent: Bo,
+ append: li,
+ attr: de,
+ detach: Lo,
+ init: Do,
+ insert: Ho,
+ noop: cn,
+ safe_not_equal: Oo,
+ svg_element: hn
+} = window.__gradio__svelte__internal;
+function Mo(t) {
+ let e, n, i;
+ return {
+ c() {
+ e = hn("svg"), n = hn("polyline"), i = hn("path"), de(n, "points", "1 4 1 10 7 10"), de(i, "d", "M3.51 15a9 9 0 1 0 2.13-9.36L1 10"), de(e, "xmlns", "http://www.w3.org/2000/svg"), de(e, "width", "100%"), de(e, "height", "100%"), de(e, "viewBox", "0 0 24 24"), de(e, "fill", "none"), de(e, "stroke", "currentColor"), de(e, "stroke-width", "2"), de(e, "stroke-linecap", "round"), de(e, "stroke-linejoin", "round"), de(e, "class", "feather feather-rotate-ccw");
+ },
+ m(r, s) {
+ Ho(r, e, s), li(e, n), li(e, i);
+ },
+ p: cn,
+ i: cn,
+ o: cn,
+ d(r) {
+ r && Lo(e);
+ }
+ };
+}
+class No extends Bo {
+ constructor(e) {
+ super(), Do(this, e, null, Mo, Oo, {});
+ }
+}
+const {
+ SvelteComponent: Io,
+ create_component: Uo,
+ destroy_component: Go,
+ init: Fo,
+ mount_component: Wo,
+ safe_not_equal: jo,
+ transition_in: zo,
+ transition_out: qo
+} = window.__gradio__svelte__internal, { createEventDispatcher: Vo } = window.__gradio__svelte__internal;
+function Xo(t) {
+ let e, n;
+ return e = new ps({
+ props: {
+ Icon: Xs,
+ label: (
+ /*i18n*/
+ t[2]("common.share")
+ ),
+ pending: (
+ /*pending*/
+ t[3]
+ )
+ }
+ }), e.$on(
+ "click",
+ /*click_handler*/
+ t[5]
+ ), {
+ c() {
+ Uo(e.$$.fragment);
+ },
+ m(i, r) {
+ Wo(e, i, r), n = !0;
+ },
+ p(i, [r]) {
+ const s = {};
+ r & /*i18n*/
+ 4 && (s.label = /*i18n*/
+ i[2]("common.share")), r & /*pending*/
+ 8 && (s.pending = /*pending*/
+ i[3]), e.$set(s);
+ },
+ i(i) {
+ n || (zo(e.$$.fragment, i), n = !0);
+ },
+ o(i) {
+ qo(e.$$.fragment, i), n = !1;
+ },
+ d(i) {
+ Go(e, i);
+ }
+ };
+}
+function Zo(t, e, n) {
+ const i = Vo();
+ let { formatter: r } = e, { value: s } = e, { i18n: o } = e, u = !1;
+ const a = async () => {
+ try {
+ n(3, u = !0);
+ const c = await r(s);
+ i("share", { description: c });
+ } catch (c) {
+ console.error(c);
+ let l = c instanceof Rt ? c.message : "Share failed.";
+ i("error", l);
+ } finally {
+ n(3, u = !1);
+ }
+ };
+ return t.$$set = (c) => {
+ "formatter" in c && n(0, r = c.formatter), "value" in c && n(1, s = c.value), "i18n" in c && n(2, o = c.i18n);
+ }, [r, s, o, u, i, a];
+}
+class Jo extends Io {
+ constructor(e) {
+ super(), Fo(this, e, Zo, Xo, jo, { formatter: 0, value: 1, i18n: 2 });
+ }
+}
+/*! *****************************************************************************
+Copyright (c) Microsoft Corporation.
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
+***************************************************************************** */
+function Z(t, e, n, i) {
+ return new (n || (n = Promise))(function(r, s) {
+ function o(c) {
+ try {
+ a(i.next(c));
+ } catch (l) {
+ s(l);
+ }
+ }
+ function u(c) {
+ try {
+ a(i.throw(c));
+ } catch (l) {
+ s(l);
+ }
+ }
+ function a(c) {
+ var l;
+ c.done ? r(c.value) : (l = c.value, l instanceof n ? l : new n(function(d) {
+ d(l);
+ })).then(o, u);
+ }
+ a((i = i.apply(t, e || [])).next());
+ });
+}
+let Et = class {
+ constructor() {
+ this.listeners = {};
+ }
+ on(e, n, i) {
+ if (this.listeners[e] || (this.listeners[e] = /* @__PURE__ */ new Set()), this.listeners[e].add(n), i == null ? void 0 : i.once) {
+ const r = () => {
+ this.un(e, r), this.un(e, n);
+ };
+ return this.on(e, r), r;
+ }
+ return () => this.un(e, n);
+ }
+ un(e, n) {
+ var i;
+ (i = this.listeners[e]) === null || i === void 0 || i.delete(n);
+ }
+ once(e, n) {
+ return this.on(e, n, { once: !0 });
+ }
+ unAll() {
+ this.listeners = {};
+ }
+ emit(e, ...n) {
+ this.listeners[e] && this.listeners[e].forEach((i) => i(...n));
+ }
+};
+const ui = { decode: function(t, e) {
+ return Z(this, void 0, void 0, function* () {
+ const n = new AudioContext({ sampleRate: e });
+ return n.decodeAudioData(t).finally(() => n.close());
+ });
+}, createBuffer: function(t, e) {
+ return typeof t[0] == "number" && (t = [t]), function(n) {
+ const i = n[0];
+ if (i.some((r) => r > 1 || r < -1)) {
+ const r = i.length;
+ let s = 0;
+ for (let o = 0; o < r; o++) {
+ const u = Math.abs(i[o]);
+ u > s && (s = u);
+ }
+ for (const o of n)
+ for (let u = 0; u < r; u++)
+ o[u] /= s;
+ }
+ }(t), { duration: e, length: t[0].length, sampleRate: t[0].length / e, numberOfChannels: t.length, getChannelData: (n) => t == null ? void 0 : t[n], copyFromChannel: AudioBuffer.prototype.copyFromChannel, copyToChannel: AudioBuffer.prototype.copyToChannel };
+} };
+function ir(t, e) {
+ const n = e.xmlns ? document.createElementNS(e.xmlns, t) : document.createElement(t);
+ for (const [i, r] of Object.entries(e))
+ if (i === "children")
+ for (const [s, o] of Object.entries(e))
+ typeof o == "string" ? n.appendChild(document.createTextNode(o)) : n.appendChild(ir(s, o));
+ else
+ i === "style" ? Object.assign(n.style, r) : i === "textContent" ? n.textContent = r : n.setAttribute(i, r.toString());
+ return n;
+}
+function ci(t, e, n) {
+ const i = ir(t, e || {});
+ return n == null || n.appendChild(i), i;
+}
+var Qo = Object.freeze({ __proto__: null, createElement: ci, default: ci });
+const Yo = { fetchBlob: function(t, e, n) {
+ return Z(this, void 0, void 0, function* () {
+ const i = yield fetch(t, n);
+ if (i.status >= 400)
+ throw new Error(`Failed to fetch ${t}: ${i.status} (${i.statusText})`);
+ return function(r, s) {
+ Z(this, void 0, void 0, function* () {
+ if (!r.body || !r.headers)
+ return;
+ const o = r.body.getReader(), u = Number(r.headers.get("Content-Length")) || 0;
+ let a = 0;
+ const c = (d) => Z(this, void 0, void 0, function* () {
+ a += (d == null ? void 0 : d.length) || 0;
+ const h = Math.round(a / u * 100);
+ s(h);
+ }), l = () => Z(this, void 0, void 0, function* () {
+ let d;
+ try {
+ d = yield o.read();
+ } catch {
+ return;
+ }
+ d.done || (c(d.value), yield l());
+ });
+ l();
+ });
+ }(i.clone(), e), i.blob();
+ });
+} };
+class Ko extends Et {
+ constructor(e) {
+ super(), this.isExternalMedia = !1, e.media ? (this.media = e.media, this.isExternalMedia = !0) : this.media = document.createElement("audio"), e.mediaControls && (this.media.controls = !0), e.autoplay && (this.media.autoplay = !0), e.playbackRate != null && this.onceMediaEvent("canplay", () => {
+ e.playbackRate != null && (this.media.playbackRate = e.playbackRate);
+ });
+ }
+ onMediaEvent(e, n, i) {
+ return this.media.addEventListener(e, n, i), () => this.media.removeEventListener(e, n);
+ }
+ onceMediaEvent(e, n) {
+ return this.onMediaEvent(e, n, { once: !0 });
+ }
+ getSrc() {
+ return this.media.currentSrc || this.media.src || "";
+ }
+ revokeSrc() {
+ const e = this.getSrc();
+ e.startsWith("blob:") && URL.revokeObjectURL(e);
+ }
+ canPlayType(e) {
+ return this.media.canPlayType(e) !== "";
+ }
+ setSrc(e, n) {
+ if (this.getSrc() === e)
+ return;
+ this.revokeSrc();
+ const i = n instanceof Blob && this.canPlayType(n.type) ? URL.createObjectURL(n) : e;
+ this.media.src = i;
+ }
+ destroy() {
+ this.media.pause(), this.isExternalMedia || (this.media.remove(), this.revokeSrc(), this.media.src = "", this.media.load());
+ }
+ setMediaElement(e) {
+ this.media = e;
+ }
+ play() {
+ return Z(this, void 0, void 0, function* () {
+ if (this.media.src)
+ return this.media.play();
+ });
+ }
+ pause() {
+ this.media.pause();
+ }
+ isPlaying() {
+ return !this.media.paused && !this.media.ended;
+ }
+ setTime(e) {
+ this.media.currentTime = e;
+ }
+ getDuration() {
+ return this.media.duration;
+ }
+ getCurrentTime() {
+ return this.media.currentTime;
+ }
+ getVolume() {
+ return this.media.volume;
+ }
+ setVolume(e) {
+ this.media.volume = e;
+ }
+ getMuted() {
+ return this.media.muted;
+ }
+ setMuted(e) {
+ this.media.muted = e;
+ }
+ getPlaybackRate() {
+ return this.media.playbackRate;
+ }
+ isSeeking() {
+ return this.media.seeking;
+ }
+ setPlaybackRate(e, n) {
+ n != null && (this.media.preservesPitch = n), this.media.playbackRate = e;
+ }
+ getMediaElement() {
+ return this.media;
+ }
+ setSinkId(e) {
+ return this.media.setSinkId(e);
+ }
+}
+class Vt extends Et {
+ constructor(e, n) {
+ super(), this.timeouts = [], this.isScrollable = !1, this.audioData = null, this.resizeObserver = null, this.lastContainerWidth = 0, this.isDragging = !1, this.options = e;
+ const i = this.parentFromOptionsContainer(e.container);
+ this.parent = i;
+ const [r, s] = this.initHtml();
+ i.appendChild(r), this.container = r, this.scrollContainer = s.querySelector(".scroll"), this.wrapper = s.querySelector(".wrapper"), this.canvasWrapper = s.querySelector(".canvases"), this.progressWrapper = s.querySelector(".progress"), this.cursor = s.querySelector(".cursor"), n && s.appendChild(n), this.initEvents();
+ }
+ parentFromOptionsContainer(e) {
+ let n;
+ if (typeof e == "string" ? n = document.querySelector(e) : e instanceof HTMLElement && (n = e), !n)
+ throw new Error("Container not found");
+ return n;
+ }
+ initEvents() {
+ const e = (i) => {
+ const r = this.wrapper.getBoundingClientRect(), s = i.clientX - r.left, o = i.clientX - r.left;
+ return [s / r.width, o / r.height];
+ };
+ this.wrapper.addEventListener("click", (i) => {
+ const [r, s] = e(i);
+ this.emit("click", r, s);
+ }), this.wrapper.addEventListener("dblclick", (i) => {
+ const [r, s] = e(i);
+ this.emit("dblclick", r, s);
+ }), this.options.dragToSeek && this.initDrag(), this.scrollContainer.addEventListener("scroll", () => {
+ const { scrollLeft: i, scrollWidth: r, clientWidth: s } = this.scrollContainer, o = i / r, u = (i + s) / r;
+ this.emit("scroll", o, u);
+ });
+ const n = this.createDelay(100);
+ this.resizeObserver = new ResizeObserver(() => {
+ n().then(() => this.onContainerResize()).catch(() => {
+ });
+ }), this.resizeObserver.observe(this.scrollContainer);
+ }
+ onContainerResize() {
+ const e = this.parent.clientWidth;
+ e === this.lastContainerWidth && this.options.height !== "auto" || (this.lastContainerWidth = e, this.reRender());
+ }
+ initDrag() {
+ (function(e, n, i, r, s = 3, o = 0) {
+ if (!e)
+ return () => {
+ };
+ let u = () => {
+ };
+ const a = (c) => {
+ if (c.button !== o)
+ return;
+ c.preventDefault(), c.stopPropagation();
+ let l = c.clientX, d = c.clientY, h = !1;
+ const m = (b) => {
+ b.preventDefault(), b.stopPropagation();
+ const T = b.clientX, A = b.clientY, k = T - l, x = A - d;
+ if (h || Math.abs(k) > s || Math.abs(x) > s) {
+ const M = e.getBoundingClientRect(), { left: S, top: G } = M;
+ h || (i == null || i(l - S, d - G), h = !0), n(k, x, T - S, A - G), l = T, d = A;
+ }
+ }, p = () => {
+ h && (r == null || r()), u();
+ }, g = (b) => {
+ b.relatedTarget && b.relatedTarget !== document.documentElement || p();
+ }, y = (b) => {
+ h && (b.stopPropagation(), b.preventDefault());
+ }, w = (b) => {
+ h && b.preventDefault();
+ };
+ document.addEventListener("pointermove", m), document.addEventListener("pointerup", p), document.addEventListener("pointerout", g), document.addEventListener("pointercancel", g), document.addEventListener("touchmove", w, { passive: !1 }), document.addEventListener("click", y, { capture: !0 }), u = () => {
+ document.removeEventListener("pointermove", m), document.removeEventListener("pointerup", p), document.removeEventListener("pointerout", g), document.removeEventListener("pointercancel", g), document.removeEventListener("touchmove", w), setTimeout(() => {
+ document.removeEventListener("click", y, { capture: !0 });
+ }, 10);
+ };
+ };
+ e.addEventListener("pointerdown", a);
+ })(this.wrapper, (e, n, i) => {
+ this.emit("drag", Math.max(0, Math.min(1, i / this.wrapper.getBoundingClientRect().width)));
+ }, () => this.isDragging = !0, () => this.isDragging = !1);
+ }
+ getHeight(e) {
+ return e == null ? 128 : isNaN(Number(e)) ? e === "auto" && this.parent.clientHeight || 128 : Number(e);
+ }
+ initHtml() {
+ const e = document.createElement("div"), n = e.attachShadow({ mode: "open" });
+ return n.innerHTML = `
+
+
+
+ `, [e, n];
+ }
+ setOptions(e) {
+ if (this.options.container !== e.container) {
+ const n = this.parentFromOptionsContainer(e.container);
+ n.appendChild(this.container), this.parent = n;
+ }
+ e.dragToSeek && !this.options.dragToSeek && this.initDrag(), this.options = e, this.reRender();
+ }
+ getWrapper() {
+ return this.wrapper;
+ }
+ getScroll() {
+ return this.scrollContainer.scrollLeft;
+ }
+ destroy() {
+ var e;
+ this.container.remove(), (e = this.resizeObserver) === null || e === void 0 || e.disconnect();
+ }
+ createDelay(e = 10) {
+ let n, i;
+ const r = () => {
+ n && clearTimeout(n), i && i();
+ };
+ return this.timeouts.push(r), () => new Promise((s, o) => {
+ r(), i = o, n = setTimeout(() => {
+ n = void 0, i = void 0, s();
+ }, e);
+ });
+ }
+ convertColorValues(e) {
+ if (!Array.isArray(e))
+ return e || "";
+ if (e.length < 2)
+ return e[0] || "";
+ const n = document.createElement("canvas"), i = n.getContext("2d"), r = n.height * (window.devicePixelRatio || 1), s = i.createLinearGradient(0, 0, 0, r), o = 1 / (e.length - 1);
+ return e.forEach((u, a) => {
+ const c = a * o;
+ s.addColorStop(c, u);
+ }), s;
+ }
+ renderBarWaveform(e, n, i, r) {
+ const s = e[0], o = e[1] || e[0], u = s.length, { width: a, height: c } = i.canvas, l = c / 2, d = window.devicePixelRatio || 1, h = n.barWidth ? n.barWidth * d : 1, m = n.barGap ? n.barGap * d : n.barWidth ? h / 2 : 0, p = n.barRadius || 0, g = a / (h + m) / u, y = p && "roundRect" in i ? "roundRect" : "rect";
+ i.beginPath();
+ let w = 0, b = 0, T = 0;
+ for (let A = 0; A <= u; A++) {
+ const k = Math.round(A * g);
+ if (k > w) {
+ const S = Math.round(b * l * r), G = S + Math.round(T * l * r) || 1;
+ let V = l - S;
+ n.barAlign === "top" ? V = 0 : n.barAlign === "bottom" && (V = c - G), i[y](w * (h + m), V, h, G, p), w = k, b = 0, T = 0;
+ }
+ const x = Math.abs(s[A] || 0), M = Math.abs(o[A] || 0);
+ x > b && (b = x), M > T && (T = M);
+ }
+ i.fill(), i.closePath();
+ }
+ renderLineWaveform(e, n, i, r) {
+ const s = (o) => {
+ const u = e[o] || e[0], a = u.length, { height: c } = i.canvas, l = c / 2, d = i.canvas.width / a;
+ i.moveTo(0, l);
+ let h = 0, m = 0;
+ for (let p = 0; p <= a; p++) {
+ const g = Math.round(p * d);
+ if (g > h) {
+ const w = l + (Math.round(m * l * r) || 1) * (o === 0 ? -1 : 1);
+ i.lineTo(h, w), h = g, m = 0;
+ }
+ const y = Math.abs(u[p] || 0);
+ y > m && (m = y);
+ }
+ i.lineTo(h, l);
+ };
+ i.beginPath(), s(0), s(1), i.fill(), i.closePath();
+ }
+ renderWaveform(e, n, i) {
+ if (i.fillStyle = this.convertColorValues(n.waveColor), n.renderFunction)
+ return void n.renderFunction(e, i);
+ let r = n.barHeight || 1;
+ if (n.normalize) {
+ const s = Array.from(e[0]).reduce((o, u) => Math.max(o, Math.abs(u)), 0);
+ r = s ? 1 / s : 1;
+ }
+ n.barWidth || n.barGap || n.barAlign ? this.renderBarWaveform(e, n, i, r) : this.renderLineWaveform(e, n, i, r);
+ }
+ renderSingleCanvas(e, n, i, r, s, o, u, a) {
+ const c = window.devicePixelRatio || 1, l = document.createElement("canvas"), d = e[0].length;
+ l.width = Math.round(i * (o - s) / d), l.height = r * c, l.style.width = `${Math.floor(l.width / c)}px`, l.style.height = `${r}px`, l.style.left = `${Math.floor(s * i / c / d)}px`, u.appendChild(l);
+ const h = l.getContext("2d");
+ if (this.renderWaveform(e.map((m) => m.slice(s, o)), n, h), l.width > 0 && l.height > 0) {
+ const m = l.cloneNode(), p = m.getContext("2d");
+ p.drawImage(l, 0, 0), p.globalCompositeOperation = "source-in", p.fillStyle = this.convertColorValues(n.progressColor), p.fillRect(0, 0, l.width, l.height), a.appendChild(m);
+ }
+ }
+ renderChannel(e, n, i) {
+ return Z(this, void 0, void 0, function* () {
+ const r = document.createElement("div"), s = this.getHeight(n.height);
+ r.style.height = `${s}px`, this.canvasWrapper.style.minHeight = `${s}px`, this.canvasWrapper.appendChild(r);
+ const o = r.cloneNode();
+ this.progressWrapper.appendChild(o);
+ const u = e[0].length, a = (w, b) => {
+ this.renderSingleCanvas(e, n, i, s, Math.max(0, w), Math.min(b, u), r, o);
+ };
+ if (!this.isScrollable)
+ return void a(0, u);
+ const { scrollLeft: c, scrollWidth: l, clientWidth: d } = this.scrollContainer, h = u / l;
+ let m = Math.min(Vt.MAX_CANVAS_WIDTH, d);
+ if (n.barWidth || n.barGap) {
+ const w = n.barWidth || 0.5, b = w + (n.barGap || w / 2);
+ m % b != 0 && (m = Math.floor(m / b) * b);
+ }
+ const p = Math.floor(Math.abs(c) * h), g = Math.floor(p + m * h), y = g - p;
+ y <= 0 || (a(p, g), yield Promise.all([(() => Z(this, void 0, void 0, function* () {
+ if (p === 0)
+ return;
+ const w = this.createDelay();
+ for (let b = p; b >= 0; b -= y)
+ yield w(), a(Math.max(0, b - y), b);
+ }))(), (() => Z(this, void 0, void 0, function* () {
+ if (g === u)
+ return;
+ const w = this.createDelay();
+ for (let b = g; b < u; b += y)
+ yield w(), a(b, Math.min(u, b + y));
+ }))()]));
+ });
+ }
+ render(e) {
+ return Z(this, void 0, void 0, function* () {
+ this.timeouts.forEach((u) => u()), this.timeouts = [], this.canvasWrapper.innerHTML = "", this.progressWrapper.innerHTML = "", this.options.width != null && (this.scrollContainer.style.width = typeof this.options.width == "number" ? `${this.options.width}px` : this.options.width);
+ const n = window.devicePixelRatio || 1, i = this.scrollContainer.clientWidth, r = Math.ceil(e.duration * (this.options.minPxPerSec || 0));
+ this.isScrollable = r > i;
+ const s = this.options.fillParent && !this.isScrollable, o = (s ? i : r) * n;
+ this.wrapper.style.width = s ? "100%" : `${r}px`, this.scrollContainer.style.overflowX = this.isScrollable ? "auto" : "hidden", this.scrollContainer.classList.toggle("noScrollbar", !!this.options.hideScrollbar), this.cursor.style.backgroundColor = `${this.options.cursorColor || this.options.progressColor}`, this.cursor.style.width = `${this.options.cursorWidth}px`, this.audioData = e, this.emit("render");
+ try {
+ if (this.options.splitChannels)
+ yield Promise.all(Array.from({ length: e.numberOfChannels }).map((u, a) => {
+ var c;
+ const l = Object.assign(Object.assign({}, this.options), (c = this.options.splitChannels) === null || c === void 0 ? void 0 : c[a]);
+ return this.renderChannel([e.getChannelData(a)], l, o);
+ }));
+ else {
+ const u = [e.getChannelData(0)];
+ e.numberOfChannels > 1 && u.push(e.getChannelData(1)), yield this.renderChannel(u, this.options, o);
+ }
+ } catch {
+ return;
+ }
+ this.emit("rendered");
+ });
+ }
+ reRender() {
+ if (!this.audioData)
+ return;
+ const { scrollWidth: e } = this.scrollContainer, { right: n } = this.progressWrapper.getBoundingClientRect();
+ if (this.render(this.audioData), this.isScrollable && e !== this.scrollContainer.scrollWidth) {
+ const { right: i } = this.progressWrapper.getBoundingClientRect();
+ let r = i - n;
+ r *= 2, r = r < 0 ? Math.floor(r) : Math.ceil(r), r /= 2, this.scrollContainer.scrollLeft += r;
+ }
+ }
+ zoom(e) {
+ this.options.minPxPerSec = e, this.reRender();
+ }
+ scrollIntoView(e, n = !1) {
+ const { scrollLeft: i, scrollWidth: r, clientWidth: s } = this.scrollContainer, o = e * r, u = i, a = i + s, c = s / 2;
+ if (this.isDragging)
+ o + 30 > a ? this.scrollContainer.scrollLeft += 30 : o - 30 < u && (this.scrollContainer.scrollLeft -= 30);
+ else {
+ (o < u || o > a) && (this.scrollContainer.scrollLeft = o - (this.options.autoCenter ? c : 0));
+ const l = o - i - c;
+ n && this.options.autoCenter && l > 0 && (this.scrollContainer.scrollLeft += Math.min(l, 10));
+ }
+ {
+ const l = this.scrollContainer.scrollLeft, d = l / r, h = (l + s) / r;
+ this.emit("scroll", d, h);
+ }
+ }
+ renderProgress(e, n) {
+ if (isNaN(e))
+ return;
+ const i = 100 * e;
+ this.canvasWrapper.style.clipPath = `polygon(${i}% 0, 100% 0, 100% 100%, ${i}% 100%)`, this.progressWrapper.style.width = `${i}%`, this.cursor.style.left = `${i}%`, this.cursor.style.transform = `translateX(-${Math.round(i) === 100 ? this.options.cursorWidth : 0}px)`, this.isScrollable && this.options.autoScroll && this.scrollIntoView(e, n);
+ }
+ exportImage(e, n, i) {
+ return Z(this, void 0, void 0, function* () {
+ const r = this.canvasWrapper.querySelectorAll("canvas");
+ if (!r.length)
+ throw new Error("No waveform data");
+ if (i === "dataURL") {
+ const s = Array.from(r).map((o) => o.toDataURL(e, n));
+ return Promise.resolve(s);
+ }
+ return Promise.all(Array.from(r).map((s) => new Promise((o, u) => {
+ s.toBlob((a) => {
+ a ? o(a) : u(new Error("Could not export image"));
+ }, e, n);
+ })));
+ });
+ }
+}
+Vt.MAX_CANVAS_WIDTH = 4e3;
+class $o extends Et {
+ constructor() {
+ super(...arguments), this.unsubscribe = () => {
+ };
+ }
+ start() {
+ this.unsubscribe = this.on("tick", () => {
+ requestAnimationFrame(() => {
+ this.emit("tick");
+ });
+ }), this.emit("tick");
+ }
+ stop() {
+ this.unsubscribe();
+ }
+ destroy() {
+ this.unsubscribe();
+ }
+}
+class ea extends Et {
+ constructor(e = new AudioContext()) {
+ super(), this.bufferNode = null, this.autoplay = !1, this.playStartTime = 0, this.playedDuration = 0, this._muted = !1, this.buffer = null, this.currentSrc = "", this.paused = !0, this.crossOrigin = null, this.addEventListener = this.on, this.removeEventListener = this.un, this.audioContext = e, this.gainNode = this.audioContext.createGain(), this.gainNode.connect(this.audioContext.destination);
+ }
+ load() {
+ return Z(this, void 0, void 0, function* () {
+ });
+ }
+ get src() {
+ return this.currentSrc;
+ }
+ set src(e) {
+ if (this.currentSrc = e, !e)
+ return this.buffer = null, void this.emit("emptied");
+ fetch(e).then((n) => n.arrayBuffer()).then((n) => this.currentSrc !== e ? null : this.audioContext.decodeAudioData(n)).then((n) => {
+ this.currentSrc === e && (this.buffer = n, this.emit("loadedmetadata"), this.emit("canplay"), this.autoplay && this.play());
+ });
+ }
+ _play() {
+ var e;
+ this.paused && (this.paused = !1, (e = this.bufferNode) === null || e === void 0 || e.disconnect(), this.bufferNode = this.audioContext.createBufferSource(), this.bufferNode.buffer = this.buffer, this.bufferNode.connect(this.gainNode), this.playedDuration >= this.duration && (this.playedDuration = 0), this.bufferNode.start(this.audioContext.currentTime, this.playedDuration), this.playStartTime = this.audioContext.currentTime, this.bufferNode.onended = () => {
+ this.currentTime >= this.duration && (this.pause(), this.emit("ended"));
+ });
+ }
+ _pause() {
+ var e;
+ this.paused || (this.paused = !0, (e = this.bufferNode) === null || e === void 0 || e.stop(), this.playedDuration += this.audioContext.currentTime - this.playStartTime);
+ }
+ play() {
+ return Z(this, void 0, void 0, function* () {
+ this._play(), this.emit("play");
+ });
+ }
+ pause() {
+ this._pause(), this.emit("pause");
+ }
+ stopAt(e) {
+ var n, i;
+ const r = e - this.currentTime;
+ (n = this.bufferNode) === null || n === void 0 || n.stop(this.audioContext.currentTime + r), (i = this.bufferNode) === null || i === void 0 || i.addEventListener("ended", () => {
+ this.bufferNode = null, this.pause();
+ }, { once: !0 });
+ }
+ setSinkId(e) {
+ return Z(this, void 0, void 0, function* () {
+ return this.audioContext.setSinkId(e);
+ });
+ }
+ get playbackRate() {
+ var e, n;
+ return (n = (e = this.bufferNode) === null || e === void 0 ? void 0 : e.playbackRate.value) !== null && n !== void 0 ? n : 1;
+ }
+ set playbackRate(e) {
+ this.bufferNode && (this.bufferNode.playbackRate.value = e);
+ }
+ get currentTime() {
+ return this.paused ? this.playedDuration : this.playedDuration + this.audioContext.currentTime - this.playStartTime;
+ }
+ set currentTime(e) {
+ this.emit("seeking"), this.paused ? this.playedDuration = e : (this._pause(), this.playedDuration = e, this._play()), this.emit("timeupdate");
+ }
+ get duration() {
+ var e;
+ return ((e = this.buffer) === null || e === void 0 ? void 0 : e.duration) || 0;
+ }
+ get volume() {
+ return this.gainNode.gain.value;
+ }
+ set volume(e) {
+ this.gainNode.gain.value = e, this.emit("volumechange");
+ }
+ get muted() {
+ return this._muted;
+ }
+ set muted(e) {
+ this._muted !== e && (this._muted = e, this._muted ? this.gainNode.disconnect() : this.gainNode.connect(this.audioContext.destination));
+ }
+ canPlayType(e) {
+ return /^(audio|video)\//.test(e);
+ }
+ getGainNode() {
+ return this.gainNode;
+ }
+ getChannelData() {
+ const e = [];
+ if (!this.buffer)
+ return e;
+ const n = this.buffer.numberOfChannels;
+ for (let i = 0; i < n; i++)
+ e.push(this.buffer.getChannelData(i));
+ return e;
+ }
+}
+const ta = { waveColor: "#999", progressColor: "#555", cursorWidth: 1, minPxPerSec: 0, fillParent: !0, interact: !0, dragToSeek: !1, autoScroll: !0, autoCenter: !0, sampleRate: 8e3 };
+class We extends Ko {
+ static create(e) {
+ return new We(e);
+ }
+ constructor(e) {
+ const n = e.media || (e.backend === "WebAudio" ? new ea() : void 0);
+ super({ media: n, mediaControls: e.mediaControls, autoplay: e.autoplay, playbackRate: e.audioRate }), this.plugins = [], this.decodedData = null, this.subscriptions = [], this.mediaSubscriptions = [], this.options = Object.assign({}, ta, e), this.timer = new $o();
+ const i = n ? void 0 : this.getMediaElement();
+ this.renderer = new Vt(this.options, i), this.initPlayerEvents(), this.initRendererEvents(), this.initTimerEvents(), this.initPlugins(), Promise.resolve().then(() => {
+ this.emit("init");
+ const r = this.options.url || this.getSrc() || "";
+ (r || this.options.peaks && this.options.duration) && this.load(r, this.options.peaks, this.options.duration);
+ });
+ }
+ updateProgress(e = this.getCurrentTime()) {
+ return this.renderer.renderProgress(e / this.getDuration(), this.isPlaying()), e;
+ }
+ initTimerEvents() {
+ this.subscriptions.push(this.timer.on("tick", () => {
+ if (!this.isSeeking()) {
+ const e = this.updateProgress();
+ this.emit("timeupdate", e), this.emit("audioprocess", e);
+ }
+ }));
+ }
+ initPlayerEvents() {
+ this.isPlaying() && (this.emit("play"), this.timer.start()), this.mediaSubscriptions.push(this.onMediaEvent("timeupdate", () => {
+ const e = this.updateProgress();
+ this.emit("timeupdate", e);
+ }), this.onMediaEvent("play", () => {
+ this.emit("play"), this.timer.start();
+ }), this.onMediaEvent("pause", () => {
+ this.emit("pause"), this.timer.stop();
+ }), this.onMediaEvent("emptied", () => {
+ this.timer.stop();
+ }), this.onMediaEvent("ended", () => {
+ this.emit("finish");
+ }), this.onMediaEvent("seeking", () => {
+ this.emit("seeking", this.getCurrentTime());
+ }));
+ }
+ initRendererEvents() {
+ this.subscriptions.push(this.renderer.on("click", (e, n) => {
+ this.options.interact && (this.seekTo(e), this.emit("interaction", e * this.getDuration()), this.emit("click", e, n));
+ }), this.renderer.on("dblclick", (e, n) => {
+ this.emit("dblclick", e, n);
+ }), this.renderer.on("scroll", (e, n) => {
+ const i = this.getDuration();
+ this.emit("scroll", e * i, n * i);
+ }), this.renderer.on("render", () => {
+ this.emit("redraw");
+ }), this.renderer.on("rendered", () => {
+ this.emit("redrawcomplete");
+ }));
+ {
+ let e;
+ this.subscriptions.push(this.renderer.on("drag", (n) => {
+ this.options.interact && (this.renderer.renderProgress(n), clearTimeout(e), e = setTimeout(() => {
+ this.seekTo(n);
+ }, this.isPlaying() ? 0 : 200), this.emit("interaction", n * this.getDuration()), this.emit("drag", n));
+ }));
+ }
+ }
+ initPlugins() {
+ var e;
+ !((e = this.options.plugins) === null || e === void 0) && e.length && this.options.plugins.forEach((n) => {
+ this.registerPlugin(n);
+ });
+ }
+ unsubscribePlayerEvents() {
+ this.mediaSubscriptions.forEach((e) => e()), this.mediaSubscriptions = [];
+ }
+ setOptions(e) {
+ this.options = Object.assign({}, this.options, e), this.renderer.setOptions(this.options), e.audioRate && this.setPlaybackRate(e.audioRate), e.mediaControls != null && (this.getMediaElement().controls = e.mediaControls);
+ }
+ registerPlugin(e) {
+ return e._init(this), this.plugins.push(e), this.subscriptions.push(e.once("destroy", () => {
+ this.plugins = this.plugins.filter((n) => n !== e);
+ })), e;
+ }
+ getWrapper() {
+ return this.renderer.getWrapper();
+ }
+ getScroll() {
+ return this.renderer.getScroll();
+ }
+ getActivePlugins() {
+ return this.plugins;
+ }
+ loadAudio(e, n, i, r) {
+ return Z(this, void 0, void 0, function* () {
+ if (this.emit("load", e), !this.options.media && this.isPlaying() && this.pause(), this.decodedData = null, !n && !i) {
+ const o = (u) => this.emit("loading", u);
+ n = yield Yo.fetchBlob(e, o, this.options.fetchParams);
+ }
+ this.setSrc(e, n);
+ const s = r || this.getDuration() || (yield new Promise((o) => {
+ this.onceMediaEvent("loadedmetadata", () => o(this.getDuration()));
+ }));
+ if (i)
+ this.decodedData = ui.createBuffer(i, s || 0);
+ else if (n) {
+ const o = yield n.arrayBuffer();
+ this.decodedData = yield ui.decode(o, this.options.sampleRate);
+ }
+ this.decodedData && (this.emit("decode", this.getDuration()), this.renderer.render(this.decodedData)), this.emit("ready", this.getDuration());
+ });
+ }
+ load(e, n, i) {
+ return Z(this, void 0, void 0, function* () {
+ yield this.loadAudio(e, void 0, n, i);
+ });
+ }
+ loadBlob(e, n, i) {
+ return Z(this, void 0, void 0, function* () {
+ yield this.loadAudio("blob", e, n, i);
+ });
+ }
+ zoom(e) {
+ if (!this.decodedData)
+ throw new Error("No audio loaded");
+ this.renderer.zoom(e), this.emit("zoom", e);
+ }
+ getDecodedData() {
+ return this.decodedData;
+ }
+ exportPeaks({ channels: e = 2, maxLength: n = 8e3, precision: i = 1e4 } = {}) {
+ if (!this.decodedData)
+ throw new Error("The audio has not been decoded yet");
+ const r = Math.min(e, this.decodedData.numberOfChannels), s = [];
+ for (let o = 0; o < r; o++) {
+ const u = this.decodedData.getChannelData(o), a = [], c = Math.round(u.length / n);
+ for (let l = 0; l < n; l++) {
+ const d = u.slice(l * c, (l + 1) * c);
+ let h = 0;
+ for (let m = 0; m < d.length; m++) {
+ const p = d[m];
+ Math.abs(p) > Math.abs(h) && (h = p);
+ }
+ a.push(Math.round(h * i) / i);
+ }
+ s.push(a);
+ }
+ return s;
+ }
+ getDuration() {
+ let e = super.getDuration() || 0;
+ return e !== 0 && e !== 1 / 0 || !this.decodedData || (e = this.decodedData.duration), e;
+ }
+ toggleInteraction(e) {
+ this.options.interact = e;
+ }
+ setTime(e) {
+ super.setTime(e), this.updateProgress(e);
+ }
+ seekTo(e) {
+ const n = this.getDuration() * e;
+ this.setTime(n);
+ }
+ playPause() {
+ return Z(this, void 0, void 0, function* () {
+ return this.isPlaying() ? this.pause() : this.play();
+ });
+ }
+ stop() {
+ this.pause(), this.setTime(0);
+ }
+ skip(e) {
+ this.setTime(this.getCurrentTime() + e);
+ }
+ empty() {
+ this.load("", [[0]], 1e-3);
+ }
+ setMediaElement(e) {
+ this.unsubscribePlayerEvents(), super.setMediaElement(e), this.initPlayerEvents();
+ }
+ exportImage(e = "image/png", n = 1, i = "dataURL") {
+ return Z(this, void 0, void 0, function* () {
+ return this.renderer.exportImage(e, n, i);
+ });
+ }
+ destroy() {
+ this.emit("destroy"), this.plugins.forEach((e) => e.destroy()), this.subscriptions.forEach((e) => e()), this.unsubscribePlayerEvents(), this.timer.destroy(), this.renderer.destroy(), super.destroy();
+ }
+}
+We.BasePlugin = class extends Et {
+ constructor(t) {
+ super(), this.subscriptions = [], this.options = t;
+ }
+ onInit() {
+ }
+ _init(t) {
+ this.wavesurfer = t, this.onInit();
+ }
+ destroy() {
+ this.emit("destroy"), this.subscriptions.forEach((t) => t());
+ }
+}, We.dom = Qo;
+let rr = class {
+ constructor() {
+ this.listeners = {};
+ }
+ on(e, n, i) {
+ if (this.listeners[e] || (this.listeners[e] = /* @__PURE__ */ new Set()), this.listeners[e].add(n), i == null ? void 0 : i.once) {
+ const r = () => {
+ this.un(e, r), this.un(e, n);
+ };
+ return this.on(e, r), r;
+ }
+ return () => this.un(e, n);
+ }
+ un(e, n) {
+ var i;
+ (i = this.listeners[e]) === null || i === void 0 || i.delete(n);
+ }
+ once(e, n) {
+ return this.on(e, n, { once: !0 });
+ }
+ unAll() {
+ this.listeners = {};
+ }
+ emit(e, ...n) {
+ this.listeners[e] && this.listeners[e].forEach((i) => i(...n));
+ }
+}, na = class extends rr {
+ constructor(e) {
+ super(), this.subscriptions = [], this.options = e;
+ }
+ onInit() {
+ }
+ _init(e) {
+ this.wavesurfer = e, this.onInit();
+ }
+ destroy() {
+ this.emit("destroy"), this.subscriptions.forEach((e) => e());
+ }
+};
+function kt(t, e, n, i, r = 3, s = 0) {
+ if (!t)
+ return () => {
+ };
+ let o = () => {
+ };
+ const u = (a) => {
+ if (a.button !== s)
+ return;
+ a.preventDefault(), a.stopPropagation();
+ let c = a.clientX, l = a.clientY, d = !1;
+ const h = (w) => {
+ w.preventDefault(), w.stopPropagation();
+ const b = w.clientX, T = w.clientY, A = b - c, k = T - l;
+ if (d || Math.abs(A) > r || Math.abs(k) > r) {
+ const x = t.getBoundingClientRect(), { left: M, top: S } = x;
+ d || (n == null || n(c - M, l - S), d = !0), e(A, k, b - M, T - S), c = b, l = T;
+ }
+ }, m = () => {
+ d && (i == null || i()), o();
+ }, p = (w) => {
+ w.relatedTarget && w.relatedTarget !== document.documentElement || m();
+ }, g = (w) => {
+ d && (w.stopPropagation(), w.preventDefault());
+ }, y = (w) => {
+ d && w.preventDefault();
+ };
+ document.addEventListener("pointermove", h), document.addEventListener("pointerup", m), document.addEventListener("pointerout", p), document.addEventListener("pointercancel", p), document.addEventListener("touchmove", y, { passive: !1 }), document.addEventListener("click", g, { capture: !0 }), o = () => {
+ document.removeEventListener("pointermove", h), document.removeEventListener("pointerup", m), document.removeEventListener("pointerout", p), document.removeEventListener("pointercancel", p), document.removeEventListener("touchmove", y), setTimeout(() => {
+ document.removeEventListener("click", g, { capture: !0 });
+ }, 10);
+ };
+ };
+ return t.addEventListener("pointerdown", u), () => {
+ o(), t.removeEventListener("pointerdown", u);
+ };
+}
+function sr(t, e) {
+ const n = e.xmlns ? document.createElementNS(e.xmlns, t) : document.createElement(t);
+ for (const [i, r] of Object.entries(e))
+ if (i === "children")
+ for (const [s, o] of Object.entries(e))
+ typeof o == "string" ? n.appendChild(document.createTextNode(o)) : n.appendChild(sr(s, o));
+ else
+ i === "style" ? Object.assign(n.style, r) : i === "textContent" ? n.textContent = r : n.setAttribute(i, r.toString());
+ return n;
+}
+function gt(t, e, n) {
+ const i = sr(t, e || {});
+ return n == null || n.appendChild(i), i;
+}
+let hi = class extends rr {
+ constructor(e, n, i = 0) {
+ var r, s, o, u, a, c, l, d;
+ super(), this.totalDuration = n, this.numberOfChannels = i, this.minLength = 0, this.maxLength = 1 / 0, this.contentEditable = !1, this.id = e.id || `region-${Math.random().toString(32).slice(2)}`, this.start = this.clampPosition(e.start), this.end = this.clampPosition((r = e.end) !== null && r !== void 0 ? r : e.start), this.drag = (s = e.drag) === null || s === void 0 || s, this.resize = (o = e.resize) === null || o === void 0 || o, this.color = (u = e.color) !== null && u !== void 0 ? u : "rgba(0, 0, 0, 0.1)", this.minLength = (a = e.minLength) !== null && a !== void 0 ? a : this.minLength, this.maxLength = (c = e.maxLength) !== null && c !== void 0 ? c : this.maxLength, this.channelIdx = (l = e.channelIdx) !== null && l !== void 0 ? l : -1, this.contentEditable = (d = e.contentEditable) !== null && d !== void 0 ? d : this.contentEditable, this.element = this.initElement(), this.setContent(e.content), this.setPart(), this.renderPosition(), this.initMouseEvents();
+ }
+ clampPosition(e) {
+ return Math.max(0, Math.min(this.totalDuration, e));
+ }
+ setPart() {
+ const e = this.start === this.end;
+ this.element.setAttribute("part", `${e ? "marker" : "region"} ${this.id}`);
+ }
+ addResizeHandles(e) {
+ const n = { position: "absolute", zIndex: "2", width: "6px", height: "100%", top: "0", cursor: "ew-resize", wordBreak: "keep-all" }, i = gt("div", { part: "region-handle region-handle-left", style: Object.assign(Object.assign({}, n), { left: "0", borderLeft: "2px solid rgba(0, 0, 0, 0.5)", borderRadius: "2px 0 0 2px" }) }, e), r = gt("div", { part: "region-handle region-handle-right", style: Object.assign(Object.assign({}, n), { right: "0", borderRight: "2px solid rgba(0, 0, 0, 0.5)", borderRadius: "0 2px 2px 0" }) }, e);
+ kt(i, (s) => this.onResize(s, "start"), () => null, () => this.onEndResizing(), 1), kt(r, (s) => this.onResize(s, "end"), () => null, () => this.onEndResizing(), 1);
+ }
+ removeResizeHandles(e) {
+ const n = e.querySelector('[part*="region-handle-left"]'), i = e.querySelector('[part*="region-handle-right"]');
+ n && e.removeChild(n), i && e.removeChild(i);
+ }
+ initElement() {
+ const e = this.start === this.end;
+ let n = 0, i = 100;
+ this.channelIdx >= 0 && this.channelIdx < this.numberOfChannels && (i = 100 / this.numberOfChannels, n = i * this.channelIdx);
+ const r = gt("div", { style: { position: "absolute", top: `${n}%`, height: `${i}%`, backgroundColor: e ? "none" : this.color, borderLeft: e ? "2px solid " + this.color : "none", borderRadius: "2px", boxSizing: "border-box", transition: "background-color 0.2s ease", cursor: this.drag ? "grab" : "default", pointerEvents: "all" } });
+ return !e && this.resize && this.addResizeHandles(r), r;
+ }
+ renderPosition() {
+ const e = this.start / this.totalDuration, n = (this.totalDuration - this.end) / this.totalDuration;
+ this.element.style.left = 100 * e + "%", this.element.style.right = 100 * n + "%";
+ }
+ toggleCursor(e) {
+ var n;
+ this.drag && (!((n = this.element) === null || n === void 0) && n.style) && (this.element.style.cursor = e ? "grabbing" : "grab");
+ }
+ initMouseEvents() {
+ const { element: e } = this;
+ e && (e.addEventListener("click", (n) => this.emit("click", n)), e.addEventListener("mouseenter", (n) => this.emit("over", n)), e.addEventListener("mouseleave", (n) => this.emit("leave", n)), e.addEventListener("dblclick", (n) => this.emit("dblclick", n)), e.addEventListener("pointerdown", () => this.toggleCursor(!0)), e.addEventListener("pointerup", () => this.toggleCursor(!1)), kt(e, (n) => this.onMove(n), () => this.toggleCursor(!0), () => {
+ this.toggleCursor(!1), this.drag && this.emit("update-end");
+ }), this.contentEditable && this.content && (this.content.addEventListener("click", (n) => this.onContentClick(n)), this.content.addEventListener("blur", () => this.onContentBlur())));
+ }
+ _onUpdate(e, n) {
+ if (!this.element.parentElement)
+ return;
+ const { width: i } = this.element.parentElement.getBoundingClientRect(), r = e / i * this.totalDuration, s = n && n !== "start" ? this.start : this.start + r, o = n && n !== "end" ? this.end : this.end + r, u = o - s;
+ s >= 0 && o <= this.totalDuration && s <= o && u >= this.minLength && u <= this.maxLength && (this.start = s, this.end = o, this.renderPosition(), this.emit("update", n));
+ }
+ onMove(e) {
+ this.drag && this._onUpdate(e);
+ }
+ onResize(e, n) {
+ this.resize && this._onUpdate(e, n);
+ }
+ onEndResizing() {
+ this.resize && this.emit("update-end");
+ }
+ onContentClick(e) {
+ e.stopPropagation(), e.target.focus(), this.emit("click", e);
+ }
+ onContentBlur() {
+ this.emit("update-end");
+ }
+ _setTotalDuration(e) {
+ this.totalDuration = e, this.renderPosition();
+ }
+ play() {
+ this.emit("play");
+ }
+ setContent(e) {
+ var n;
+ if ((n = this.content) === null || n === void 0 || n.remove(), e) {
+ if (typeof e == "string") {
+ const i = this.start === this.end;
+ this.content = gt("div", { style: { padding: `0.2em ${i ? 0.2 : 0.4}em`, display: "inline-block" }, textContent: e });
+ } else
+ this.content = e;
+ this.contentEditable && (this.content.contentEditable = "true"), this.content.setAttribute("part", "region-content"), this.element.appendChild(this.content);
+ } else
+ this.content = void 0;
+ }
+ setOptions(e) {
+ var n, i;
+ if (e.color && (this.color = e.color, this.element.style.backgroundColor = this.color), e.drag !== void 0 && (this.drag = e.drag, this.element.style.cursor = this.drag ? "grab" : "default"), e.start !== void 0 || e.end !== void 0) {
+ const r = this.start === this.end;
+ this.start = this.clampPosition((n = e.start) !== null && n !== void 0 ? n : this.start), this.end = this.clampPosition((i = e.end) !== null && i !== void 0 ? i : r ? this.start : this.end), this.renderPosition(), this.setPart();
+ }
+ if (e.content && this.setContent(e.content), e.id && (this.id = e.id, this.setPart()), e.resize !== void 0 && e.resize !== this.resize) {
+ const r = this.start === this.end;
+ this.resize = e.resize, this.resize && !r ? this.addResizeHandles(this.element) : this.removeResizeHandles(this.element);
+ }
+ }
+ remove() {
+ this.emit("remove"), this.element.remove(), this.element = null;
+ }
+}, ia = class or extends na {
+ constructor(e) {
+ super(e), this.regions = [], this.regionsContainer = this.initRegionsContainer();
+ }
+ static create(e) {
+ return new or(e);
+ }
+ onInit() {
+ if (!this.wavesurfer)
+ throw Error("WaveSurfer is not initialized");
+ this.wavesurfer.getWrapper().appendChild(this.regionsContainer);
+ let e = [];
+ this.subscriptions.push(this.wavesurfer.on("timeupdate", (n) => {
+ const i = this.regions.filter((r) => r.start <= n && (r.end === r.start ? r.start + 0.05 : r.end) >= n);
+ i.forEach((r) => {
+ e.includes(r) || this.emit("region-in", r);
+ }), e.forEach((r) => {
+ i.includes(r) || this.emit("region-out", r);
+ }), e = i;
+ }));
+ }
+ initRegionsContainer() {
+ return gt("div", { style: { position: "absolute", top: "0", left: "0", width: "100%", height: "100%", zIndex: "3", pointerEvents: "none" } });
+ }
+ getRegions() {
+ return this.regions;
+ }
+ avoidOverlapping(e) {
+ if (!e.content)
+ return;
+ const n = e.content, i = n.getBoundingClientRect(), r = this.regions.map((s) => {
+ if (s === e || !s.content)
+ return 0;
+ const o = s.content.getBoundingClientRect();
+ return i.left < o.left + o.width && o.left < i.left + i.width ? o.height : 0;
+ }).reduce((s, o) => s + o, 0);
+ n.style.marginTop = `${r}px`;
+ }
+ adjustScroll(e) {
+ var n, i;
+ const r = (i = (n = this.wavesurfer) === null || n === void 0 ? void 0 : n.getWrapper()) === null || i === void 0 ? void 0 : i.parentElement;
+ if (!r)
+ return;
+ const { clientWidth: s, scrollWidth: o } = r;
+ if (o <= s)
+ return;
+ const u = r.getBoundingClientRect(), a = e.element.getBoundingClientRect(), c = a.left - u.left, l = a.right - u.left;
+ c < 0 ? r.scrollLeft += c : l > s && (r.scrollLeft += l - s);
+ }
+ saveRegion(e) {
+ this.regionsContainer.appendChild(e.element), this.avoidOverlapping(e), this.regions.push(e);
+ const n = [e.on("update", (i) => {
+ i || this.adjustScroll(e);
+ }), e.on("update-end", () => {
+ this.avoidOverlapping(e), this.emit("region-updated", e);
+ }), e.on("play", () => {
+ var i, r;
+ (i = this.wavesurfer) === null || i === void 0 || i.play(), (r = this.wavesurfer) === null || r === void 0 || r.setTime(e.start);
+ }), e.on("click", (i) => {
+ this.emit("region-clicked", e, i);
+ }), e.on("dblclick", (i) => {
+ this.emit("region-double-clicked", e, i);
+ }), e.once("remove", () => {
+ n.forEach((i) => i()), this.regions = this.regions.filter((i) => i !== e), this.emit("region-removed", e);
+ })];
+ this.subscriptions.push(...n), this.emit("region-created", e);
+ }
+ addRegion(e) {
+ var n, i;
+ if (!this.wavesurfer)
+ throw Error("WaveSurfer is not initialized");
+ const r = this.wavesurfer.getDuration(), s = (i = (n = this.wavesurfer) === null || n === void 0 ? void 0 : n.getDecodedData()) === null || i === void 0 ? void 0 : i.numberOfChannels, o = new hi(e, r, s);
+ return r ? this.saveRegion(o) : this.subscriptions.push(this.wavesurfer.once("ready", (u) => {
+ o._setTotalDuration(u), this.saveRegion(o);
+ })), o;
+ }
+ enableDragSelection(e, n = 3) {
+ var i;
+ const r = (i = this.wavesurfer) === null || i === void 0 ? void 0 : i.getWrapper();
+ if (!(r && r instanceof HTMLElement))
+ return () => {
+ };
+ let s = null, o = 0;
+ return kt(r, (u, a, c) => {
+ s && s._onUpdate(u, c > o ? "end" : "start");
+ }, (u) => {
+ var a, c;
+ if (o = u, !this.wavesurfer)
+ return;
+ const l = this.wavesurfer.getDuration(), d = (c = (a = this.wavesurfer) === null || a === void 0 ? void 0 : a.getDecodedData()) === null || c === void 0 ? void 0 : c.numberOfChannels, { width: h } = this.wavesurfer.getWrapper().getBoundingClientRect(), m = u / h * l, p = (u + 5) / h * l;
+ s = new hi(Object.assign(Object.assign({}, e), { start: m, end: p }), l, d), this.regionsContainer.appendChild(s.element);
+ }, () => {
+ s && (this.saveRegion(s), s = null);
+ }, n);
+ }
+ clearRegions() {
+ this.regions.forEach((e) => e.remove());
+ }
+ destroy() {
+ this.clearRegions(), super.destroy(), this.regionsContainer.remove();
+ }
+};
+function ra(t) {
+ const e = t.numberOfChannels, n = t.length * e * 2 + 44, i = new ArrayBuffer(n), r = new DataView(i);
+ let s = 0;
+ const o = function(u, a, c) {
+ for (let l = 0; l < c.length; l++)
+ u.setUint8(a + l, c.charCodeAt(l));
+ };
+ o(r, s, "RIFF"), s += 4, r.setUint32(s, n - 8, !0), s += 4, o(r, s, "WAVE"), s += 4, o(r, s, "fmt "), s += 4, r.setUint32(s, 16, !0), s += 4, r.setUint16(s, 1, !0), s += 2, r.setUint16(s, e, !0), s += 2, r.setUint32(s, t.sampleRate, !0), s += 4, r.setUint32(s, t.sampleRate * 2 * e, !0), s += 4, r.setUint16(s, e * 2, !0), s += 2, r.setUint16(s, 16, !0), s += 2, o(r, s, "data"), s += 4, r.setUint32(s, t.length * e * 2, !0), s += 4;
+ for (let u = 0; u < t.numberOfChannels; u++) {
+ const a = t.getChannelData(u);
+ for (let c = 0; c < a.length; c++)
+ r.setInt16(s, a[c] * 65535, !0), s += 2;
+ }
+ return new Uint8Array(i);
+}
+const An = async (t, e, n) => {
+ const i = new AudioContext(), r = t.numberOfChannels, s = t.sampleRate;
+ let o = t.length, u = 0;
+ e && n && (u = Math.round(e * s), o = Math.round(n * s) - u);
+ const a = i.createBuffer(
+ r,
+ o,
+ s
+ );
+ for (let c = 0; c < r; c++) {
+ const l = t.getChannelData(c), d = a.getChannelData(c);
+ for (let h = 0; h < o; h++)
+ d[h] = l[u + h];
+ }
+ return ra(a);
+}, It = (t, e) => {
+ t && t.skip(e);
+}, Ye = (t, e) => t / 100 * (e || 5);
+const {
+ SvelteComponent: sa,
+ append: ie,
+ attr: j,
+ check_outros: Bt,
+ create_component: et,
+ destroy_component: tt,
+ detach: Ue,
+ element: fe,
+ empty: oa,
+ group_outros: Lt,
+ init: aa,
+ insert: Ge,
+ listen: Le,
+ mount_component: nt,
+ noop: bt,
+ run_all: ar,
+ safe_not_equal: la,
+ set_data: ua,
+ space: Qe,
+ text: di,
+ transition_in: ee,
+ transition_out: re
+} = window.__gradio__svelte__internal;
+function ca(t) {
+ let e, n;
+ return e = new So({}), {
+ c() {
+ et(e.$$.fragment);
+ },
+ m(i, r) {
+ nt(e, i, r), n = !0;
+ },
+ i(i) {
+ n || (ee(e.$$.fragment, i), n = !0);
+ },
+ o(i) {
+ re(e.$$.fragment, i), n = !1;
+ },
+ d(i) {
+ tt(e, i);
+ }
+ };
+}
+function ha(t) {
+ let e, n;
+ return e = new po({}), {
+ c() {
+ et(e.$$.fragment);
+ },
+ m(i, r) {
+ nt(e, i, r), n = !0;
+ },
+ i(i) {
+ n || (ee(e.$$.fragment, i), n = !0);
+ },
+ o(i) {
+ re(e.$$.fragment, i), n = !1;
+ },
+ d(i) {
+ tt(e, i);
+ }
+ };
+}
+function fi(t) {
+ let e, n, i, r, s;
+ return n = new No({}), {
+ c() {
+ e = fe("button"), et(n.$$.fragment), j(e, "class", "action icon svelte-1duohn5"), j(e, "aria-label", "Reset audio");
+ },
+ m(o, u) {
+ Ge(o, e, u), nt(n, e, null), i = !0, r || (s = Le(
+ e,
+ "click",
+ /*click_handler_4*/
+ t[26]
+ ), r = !0);
+ },
+ p: bt,
+ i(o) {
+ i || (ee(n.$$.fragment, o), i = !0);
+ },
+ o(o) {
+ re(n.$$.fragment, o), i = !1;
+ },
+ d(o) {
+ o && Ue(e), tt(n), r = !1, s();
+ }
+ };
+}
+function mi(t) {
+ let e, n, i, r;
+ const s = [fa, da], o = [];
+ function u(a, c) {
+ return (
+ /*mode*/
+ a[0] === "" ? 0 : 1
+ );
+ }
+ return e = u(t), n = o[e] = s[e](t), {
+ c() {
+ n.c(), i = oa();
+ },
+ m(a, c) {
+ o[e].m(a, c), Ge(a, i, c), r = !0;
+ },
+ p(a, c) {
+ let l = e;
+ e = u(a), e === l ? o[e].p(a, c) : (Lt(), re(o[l], 1, 1, () => {
+ o[l] = null;
+ }), Bt(), n = o[e], n ? n.p(a, c) : (n = o[e] = s[e](a), n.c()), ee(n, 1), n.m(i.parentNode, i));
+ },
+ i(a) {
+ r || (ee(n), r = !0);
+ },
+ o(a) {
+ re(n), r = !1;
+ },
+ d(a) {
+ a && Ue(i), o[e].d(a);
+ }
+ };
+}
+function da(t) {
+ let e, n, i, r, s;
+ return {
+ c() {
+ e = fe("button"), e.textContent = "Trim", n = Qe(), i = fe("button"), i.textContent = "Cancel", j(e, "class", "text-button svelte-1duohn5"), j(i, "class", "text-button svelte-1duohn5");
+ },
+ m(o, u) {
+ Ge(o, e, u), Ge(o, n, u), Ge(o, i, u), r || (s = [
+ Le(
+ e,
+ "click",
+ /*trimAudio*/
+ t[11]
+ ),
+ Le(
+ i,
+ "click",
+ /*toggleTrimmingMode*/
+ t[13]
+ )
+ ], r = !0);
+ },
+ p: bt,
+ i: bt,
+ o: bt,
+ d(o) {
+ o && (Ue(e), Ue(n), Ue(i)), r = !1, ar(s);
+ }
+ };
+}
+function fa(t) {
+ let e, n, i, r, s;
+ return n = new ko({}), {
+ c() {
+ e = fe("button"), et(n.$$.fragment), j(e, "class", "action icon svelte-1duohn5"), j(e, "aria-label", "Trim audio to selection");
+ },
+ m(o, u) {
+ Ge(o, e, u), nt(n, e, null), i = !0, r || (s = Le(
+ e,
+ "click",
+ /*toggleTrimmingMode*/
+ t[13]
+ ), r = !0);
+ },
+ p: bt,
+ i(o) {
+ i || (ee(n.$$.fragment, o), i = !0);
+ },
+ o(o) {
+ re(n.$$.fragment, o), i = !1;
+ },
+ d(o) {
+ o && Ue(e), tt(n), r = !1, s();
+ }
+ };
+}
+function ma(t) {
+ let e, n, i, r, s, o, u, a, c, l, d, h, m, p, g, y, w, b, T, A, k, x, M, S, G, V;
+ l = new Us({});
+ const $ = [ha, ca], f = [];
+ function D(_, v) {
+ return (
+ /*playing*/
+ _[4] ? 0 : 1
+ );
+ }
+ p = D(t), g = f[p] = $[p](t), T = new to({});
+ let C = (
+ /*showRedo*/
+ t[5] && /*mode*/
+ t[0] === "" && fi(t)
+ ), R = (
+ /*interactive*/
+ t[6] && mi(t)
+ );
+ return {
+ c() {
+ e = fe("div"), n = fe("button"), i = fe("span"), r = di(
+ /*playbackSpeed*/
+ t[9]
+ ), s = di("x"), u = Qe(), a = fe("div"), c = fe("button"), et(l.$$.fragment), h = Qe(), m = fe("button"), g.c(), w = Qe(), b = fe("button"), et(T.$$.fragment), k = Qe(), x = fe("div"), C && C.c(), M = Qe(), R && R.c(), j(i, "class", "svelte-1duohn5"), j(n, "class", "playback icon svelte-1duohn5"), j(n, "aria-label", o = `Adjust playback speed to ${/*playbackSpeeds*/
+ t[10][
+ /*playbackSpeeds*/
+ (t[10].indexOf(
+ /*playbackSpeed*/
+ t[9]
+ ) + 1) % /*playbackSpeeds*/
+ t[10].length
+ ]}x`), j(c, "class", "rewind icon svelte-1duohn5"), j(c, "aria-label", d = `Skip backwards by ${Ye(
+ /*audioDuration*/
+ t[2],
+ /*waveform_settings*/
+ t[8].skip_length
+ )} seconds`), j(m, "class", "play-pause-button icon svelte-1duohn5"), j(m, "aria-label", y = /*playing*/
+ t[4] ? (
+ /*i18n*/
+ t[3]("common.play")
+ ) : (
+ /*i18n*/
+ t[3]("common.pause")
+ )), j(b, "class", "skip icon svelte-1duohn5"), j(b, "aria-label", A = "Skip forward by " + Ye(
+ /*audioDuration*/
+ t[2],
+ /*waveform_settings*/
+ t[8].skip_length
+ ) + " seconds"), j(a, "class", "play-pause-wrapper svelte-1duohn5"), j(x, "class", "settings-wrapper svelte-1duohn5"), j(e, "class", "controls svelte-1duohn5"), j(e, "data-testid", "waveform-controls");
+ },
+ m(_, v) {
+ Ge(_, e, v), ie(e, n), ie(n, i), ie(i, r), ie(i, s), ie(e, u), ie(e, a), ie(a, c), nt(l, c, null), ie(a, h), ie(a, m), f[p].m(m, null), ie(a, w), ie(a, b), nt(T, b, null), ie(e, k), ie(e, x), C && C.m(x, null), ie(x, M), R && R.m(x, null), S = !0, G || (V = [
+ Le(
+ n,
+ "click",
+ /*click_handler*/
+ t[22]
+ ),
+ Le(
+ c,
+ "click",
+ /*click_handler_1*/
+ t[23]
+ ),
+ Le(
+ m,
+ "click",
+ /*click_handler_2*/
+ t[24]
+ ),
+ Le(
+ b,
+ "click",
+ /*click_handler_3*/
+ t[25]
+ )
+ ], G = !0);
+ },
+ p(_, [v]) {
+ (!S || v & /*playbackSpeed*/
+ 512) && ua(
+ r,
+ /*playbackSpeed*/
+ _[9]
+ ), (!S || v & /*playbackSpeed*/
+ 512 && o !== (o = `Adjust playback speed to ${/*playbackSpeeds*/
+ _[10][
+ /*playbackSpeeds*/
+ (_[10].indexOf(
+ /*playbackSpeed*/
+ _[9]
+ ) + 1) % /*playbackSpeeds*/
+ _[10].length
+ ]}x`)) && j(n, "aria-label", o), (!S || v & /*audioDuration, waveform_settings*/
+ 260 && d !== (d = `Skip backwards by ${Ye(
+ /*audioDuration*/
+ _[2],
+ /*waveform_settings*/
+ _[8].skip_length
+ )} seconds`)) && j(c, "aria-label", d);
+ let U = p;
+ p = D(_), p !== U && (Lt(), re(f[U], 1, 1, () => {
+ f[U] = null;
+ }), Bt(), g = f[p], g || (g = f[p] = $[p](_), g.c()), ee(g, 1), g.m(m, null)), (!S || v & /*playing, i18n*/
+ 24 && y !== (y = /*playing*/
+ _[4] ? (
+ /*i18n*/
+ _[3]("common.play")
+ ) : (
+ /*i18n*/
+ _[3]("common.pause")
+ ))) && j(m, "aria-label", y), (!S || v & /*audioDuration, waveform_settings*/
+ 260 && A !== (A = "Skip forward by " + Ye(
+ /*audioDuration*/
+ _[2],
+ /*waveform_settings*/
+ _[8].skip_length
+ ) + " seconds")) && j(b, "aria-label", A), /*showRedo*/
+ _[5] && /*mode*/
+ _[0] === "" ? C ? (C.p(_, v), v & /*showRedo, mode*/
+ 33 && ee(C, 1)) : (C = fi(_), C.c(), ee(C, 1), C.m(x, M)) : C && (Lt(), re(C, 1, 1, () => {
+ C = null;
+ }), Bt()), /*interactive*/
+ _[6] ? R ? (R.p(_, v), v & /*interactive*/
+ 64 && ee(R, 1)) : (R = mi(_), R.c(), ee(R, 1), R.m(x, null)) : R && (Lt(), re(R, 1, 1, () => {
+ R = null;
+ }), Bt());
+ },
+ i(_) {
+ S || (ee(l.$$.fragment, _), ee(g), ee(T.$$.fragment, _), ee(C), ee(R), S = !0);
+ },
+ o(_) {
+ re(l.$$.fragment, _), re(g), re(T.$$.fragment, _), re(C), re(R), S = !1;
+ },
+ d(_) {
+ _ && Ue(e), tt(l), f[p].d(), tt(T), C && C.d(), R && R.d(), G = !1, ar(V);
+ }
+ };
+}
+function Se(t) {
+ let e, n = t[0], i = 1;
+ for (; i < t.length; ) {
+ const r = t[i], s = t[i + 1];
+ if (i += 2, (r === "optionalAccess" || r === "optionalCall") && n == null)
+ return;
+ r === "access" || r === "optionalAccess" ? (e = n, n = s(n)) : (r === "call" || r === "optionalCall") && (n = s((...o) => n.call(e, ...o)), e = void 0);
+ }
+ return n;
+}
+function pa(t, e, n) {
+ let { waveform: i } = e, { audioDuration: r } = e, { i18n: s } = e, { playing: o } = e, { showRedo: u = !1 } = e, { interactive: a = !1 } = e, { handle_trim_audio: c } = e, { mode: l = "" } = e, { container: d } = e, { handle_reset_value: h } = e, { waveform_settings: m = {} } = e, { trimDuration: p = 0 } = e, g = [0.5, 1, 1.5, 2], y = g[1], w, b = null, T, A, k = "";
+ const x = () => {
+ n(18, b = w.addRegion({
+ start: r / 4,
+ end: r / 2,
+ color: "hsla(15, 85%, 40%, 0.4)",
+ drag: !0,
+ resize: !0
+ })), n(14, p = b.end - b.start);
+ }, M = () => {
+ if (i && w && b) {
+ const _ = b.start, v = b.end;
+ c(_, v), n(0, l = ""), n(18, b = null);
+ }
+ }, S = () => {
+ Se([
+ w,
+ "optionalAccess",
+ (_) => _.getRegions,
+ "call",
+ (_) => _(),
+ "access",
+ (_) => _.forEach,
+ "call",
+ (_) => _((v) => {
+ v.remove();
+ })
+ ]), Se([w, "optionalAccess", (_) => _.clearRegions, "call", (_) => _()]);
+ }, G = () => {
+ S(), l === "edit" ? n(0, l = "") : (n(0, l = "edit"), x());
+ }, V = (_, v) => {
+ let U, N;
+ b && (_ === "left" ? v === "ArrowLeft" ? (U = b.start - 0.05, N = b.end) : (U = b.start + 0.05, N = b.end) : v === "ArrowLeft" ? (U = b.start, N = b.end - 0.05) : (U = b.start, N = b.end + 0.05), b.setOptions({ start: U, end: N }), n(14, p = b.end - b.start));
+ }, $ = () => {
+ n(9, y = g[(g.indexOf(y) + 1) % g.length]), i.setPlaybackRate(y);
+ }, f = () => i.skip(Ye(r, m.skip_length) * -1), D = () => i.playPause(), C = () => i.skip(Ye(r, m.skip_length)), R = () => {
+ h(), S(), n(0, l = "");
+ };
+ return t.$$set = (_) => {
+ "waveform" in _ && n(1, i = _.waveform), "audioDuration" in _ && n(2, r = _.audioDuration), "i18n" in _ && n(3, s = _.i18n), "playing" in _ && n(4, o = _.playing), "showRedo" in _ && n(5, u = _.showRedo), "interactive" in _ && n(6, a = _.interactive), "handle_trim_audio" in _ && n(15, c = _.handle_trim_audio), "mode" in _ && n(0, l = _.mode), "container" in _ && n(16, d = _.container), "handle_reset_value" in _ && n(7, h = _.handle_reset_value), "waveform_settings" in _ && n(8, m = _.waveform_settings), "trimDuration" in _ && n(14, p = _.trimDuration);
+ }, t.$$.update = () => {
+ if (t.$$.dirty & /*waveform*/
+ 2 && n(17, w = i.registerPlugin(ia.create())), t.$$.dirty & /*trimRegion*/
+ 131072 && Se([
+ w,
+ "optionalAccess",
+ (_) => _.on,
+ "call",
+ (_) => _("region-out", (v) => {
+ v.play();
+ })
+ ]), t.$$.dirty & /*trimRegion*/
+ 131072 && Se([
+ w,
+ "optionalAccess",
+ (_) => _.on,
+ "call",
+ (_) => _("region-updated", (v) => {
+ n(14, p = v.end - v.start);
+ })
+ ]), t.$$.dirty & /*trimRegion*/
+ 131072 && Se([
+ w,
+ "optionalAccess",
+ (_) => _.on,
+ "call",
+ (_) => _("region-clicked", (v, U) => {
+ U.stopPropagation(), n(18, b = v), v.play();
+ })
+ ]), t.$$.dirty & /*activeRegion, container, leftRegionHandle, rightRegionHandle, trimRegion*/
+ 2031616 && b) {
+ const _ = d.children[0].shadowRoot;
+ n(20, A = _.querySelector('[data-resize="right"]')), n(19, T = _.querySelector('[data-resize="left"]')), T && A && (T.setAttribute("role", "button"), A.setAttribute("role", "button"), Se([
+ T,
+ "optionalAccess",
+ (v) => v.setAttribute,
+ "call",
+ (v) => v("aria-label", "Drag to adjust start time")
+ ]), Se([
+ A,
+ "optionalAccess",
+ (v) => v.setAttribute,
+ "call",
+ (v) => v("aria-label", "Drag to adjust end time")
+ ]), Se([
+ T,
+ "optionalAccess",
+ (v) => v.setAttribute,
+ "call",
+ (v) => v("tabindex", "0")
+ ]), Se([
+ A,
+ "optionalAccess",
+ (v) => v.setAttribute,
+ "call",
+ (v) => v("tabindex", "0")
+ ]), T.addEventListener("focus", () => {
+ w && n(21, k = "left");
+ }), A.addEventListener("focus", () => {
+ w && n(21, k = "right");
+ }));
+ }
+ t.$$.dirty & /*trimRegion, activeHandle*/
+ 2228224 && w && window.addEventListener("keydown", (_) => {
+ _.key === "ArrowLeft" ? V(k, "ArrowLeft") : _.key === "ArrowRight" && V(k, "ArrowRight");
+ });
+ }, [
+ l,
+ i,
+ r,
+ s,
+ o,
+ u,
+ a,
+ h,
+ m,
+ y,
+ g,
+ M,
+ S,
+ G,
+ p,
+ c,
+ d,
+ w,
+ b,
+ T,
+ A,
+ k,
+ $,
+ f,
+ D,
+ C,
+ R
+ ];
+}
+class lr extends sa {
+ constructor(e) {
+ super(), aa(this, e, pa, ma, la, {
+ waveform: 1,
+ audioDuration: 2,
+ i18n: 3,
+ playing: 4,
+ showRedo: 5,
+ interactive: 6,
+ handle_trim_audio: 15,
+ mode: 0,
+ container: 16,
+ handle_reset_value: 7,
+ waveform_settings: 8,
+ trimDuration: 14
+ });
+ }
+}
+const { setContext: bh, getContext: _a } = window.__gradio__svelte__internal, ga = "WORKER_PROXY_CONTEXT_KEY";
+function ba() {
+ return _a(ga);
+}
+function va(t) {
+ return t.host === window.location.host || t.host === "localhost:7860" || t.host === "127.0.0.1:7860" || // Ref: https://github.com/gradio-app/gradio/blob/v3.32.0/js/app/src/Index.svelte#L194
+ t.host === "lite.local";
+}
+async function ya(t) {
+ if (t == null)
+ return t;
+ const e = new URL(t);
+ if (!va(e) || e.protocol !== "http:" && e.protocol !== "https:")
+ return t;
+ const n = ba();
+ if (n == null)
+ return t;
+ const i = e.pathname;
+ return n.httpRequest({
+ method: "GET",
+ path: i,
+ headers: {},
+ query_string: ""
+ }).then((r) => {
+ if (r.status !== 200)
+ throw new Error(`Failed to get file ${i} from the Wasm worker.`);
+ const s = new Blob([r.body], {
+ type: r.headers["Content-Type"]
+ });
+ return URL.createObjectURL(s);
+ });
+}
+const {
+ SvelteComponent: wa,
+ add_flush_callback: pi,
+ append: ge,
+ attr: se,
+ bind: _i,
+ binding_callbacks: vt,
+ check_outros: ur,
+ create_component: Nn,
+ destroy_component: In,
+ detach: Un,
+ element: Re,
+ empty: Ea,
+ group_outros: cr,
+ init: Sa,
+ insert: Gn,
+ mount_component: Fn,
+ safe_not_equal: Ca,
+ set_data: Aa,
+ space: xt,
+ text: xa,
+ transition_in: He,
+ transition_out: je
+} = window.__gradio__svelte__internal, { onMount: Ta } = window.__gradio__svelte__internal;
+function Pa(t) {
+ let e, n, i, r, s, o, u, a, c, l, d, h, m, p = (
+ /*mode*/
+ t[0] === "edit" && /*trimDuration*/
+ t[13] > 0 && gi(t)
+ ), g = (
+ /*waveform*/
+ t[8] && bi(t)
+ );
+ return {
+ c() {
+ e = Re("div"), n = Re("div"), i = Re("div"), r = xt(), s = Re("div"), o = Re("time"), o.textContent = "0:00", u = xt(), a = Re("div"), p && p.c(), c = xt(), l = Re("time"), l.textContent = "0:00", d = xt(), g && g.c(), se(i, "id", "waveform"), se(i, "class", "svelte-1iry1ax"), se(n, "class", "waveform-container svelte-1iry1ax"), se(o, "id", "time"), se(o, "class", "svelte-1iry1ax"), se(l, "id", "duration"), se(l, "class", "svelte-1iry1ax"), se(s, "class", "timestamps svelte-1iry1ax"), se(e, "class", "component-wrapper svelte-1iry1ax"), se(e, "data-testid", h = /*label*/
+ t[2] ? "waveform-" + /*label*/
+ t[2] : "unlabelled-audio");
+ },
+ m(y, w) {
+ Gn(y, e, w), ge(e, n), ge(n, i), t[18](i), ge(e, r), ge(e, s), ge(s, o), t[19](o), ge(s, u), ge(s, a), p && p.m(a, null), ge(a, c), ge(a, l), t[20](l), ge(e, d), g && g.m(e, null), m = !0;
+ },
+ p(y, w) {
+ /*mode*/
+ y[0] === "edit" && /*trimDuration*/
+ y[13] > 0 ? p ? p.p(y, w) : (p = gi(y), p.c(), p.m(a, c)) : p && (p.d(1), p = null), /*waveform*/
+ y[8] ? g ? (g.p(y, w), w & /*waveform*/
+ 256 && He(g, 1)) : (g = bi(y), g.c(), He(g, 1), g.m(e, null)) : g && (cr(), je(g, 1, 1, () => {
+ g = null;
+ }), ur()), (!m || w & /*label*/
+ 4 && h !== (h = /*label*/
+ y[2] ? "waveform-" + /*label*/
+ y[2] : "unlabelled-audio")) && se(e, "data-testid", h);
+ },
+ i(y) {
+ m || (He(g), m = !0);
+ },
+ o(y) {
+ je(g), m = !1;
+ },
+ d(y) {
+ y && Un(e), t[18](null), t[19](null), p && p.d(), t[20](null), g && g.d();
+ }
+ };
+}
+function Ra(t) {
+ let e, n;
+ return e = new tr({
+ props: {
+ size: "small",
+ $$slots: { default: [ka] },
+ $$scope: { ctx: t }
+ }
+ }), {
+ c() {
+ Nn(e.$$.fragment);
+ },
+ m(i, r) {
+ Fn(e, i, r), n = !0;
+ },
+ p(i, r) {
+ const s = {};
+ r & /*$$scope*/
+ 33554432 && (s.$$scope = { dirty: r, ctx: i }), e.$set(s);
+ },
+ i(i) {
+ n || (He(e.$$.fragment, i), n = !0);
+ },
+ o(i) {
+ je(e.$$.fragment, i), n = !1;
+ },
+ d(i) {
+ In(e, i);
+ }
+ };
+}
+function gi(t) {
+ let e, n = (
+ /*formatTime*/
+ t[14](
+ /*trimDuration*/
+ t[13]
+ ) + ""
+ ), i;
+ return {
+ c() {
+ e = Re("time"), i = xa(n), se(e, "id", "trim-duration"), se(e, "class", "svelte-1iry1ax");
+ },
+ m(r, s) {
+ Gn(r, e, s), ge(e, i);
+ },
+ p(r, s) {
+ s & /*trimDuration*/
+ 8192 && n !== (n = /*formatTime*/
+ r[14](
+ /*trimDuration*/
+ r[13]
+ ) + "") && Aa(i, n);
+ },
+ d(r) {
+ r && Un(e);
+ }
+ };
+}
+function bi(t) {
+ let e, n, i, r;
+ function s(a) {
+ t[21](a);
+ }
+ function o(a) {
+ t[22](a);
+ }
+ let u = {
+ container: (
+ /*container*/
+ t[7]
+ ),
+ waveform: (
+ /*waveform*/
+ t[8]
+ ),
+ playing: (
+ /*playing*/
+ t[11]
+ ),
+ audioDuration: (
+ /*audioDuration*/
+ t[12]
+ ),
+ i18n: (
+ /*i18n*/
+ t[3]
+ ),
+ interactive: (
+ /*interactive*/
+ t[4]
+ ),
+ handle_trim_audio: (
+ /*handle_trim_audio*/
+ t[15]
+ ),
+ showRedo: (
+ /*interactive*/
+ t[4]
+ ),
+ handle_reset_value: (
+ /*handle_reset_value*/
+ t[6]
+ ),
+ waveform_settings: (
+ /*waveform_settings*/
+ t[5]
+ )
+ };
+ return (
+ /*mode*/
+ t[0] !== void 0 && (u.mode = /*mode*/
+ t[0]), /*trimDuration*/
+ t[13] !== void 0 && (u.trimDuration = /*trimDuration*/
+ t[13]), e = new lr({ props: u }), vt.push(() => _i(e, "mode", s)), vt.push(() => _i(e, "trimDuration", o)), {
+ c() {
+ Nn(e.$$.fragment);
+ },
+ m(a, c) {
+ Fn(e, a, c), r = !0;
+ },
+ p(a, c) {
+ const l = {};
+ c & /*container*/
+ 128 && (l.container = /*container*/
+ a[7]), c & /*waveform*/
+ 256 && (l.waveform = /*waveform*/
+ a[8]), c & /*playing*/
+ 2048 && (l.playing = /*playing*/
+ a[11]), c & /*audioDuration*/
+ 4096 && (l.audioDuration = /*audioDuration*/
+ a[12]), c & /*i18n*/
+ 8 && (l.i18n = /*i18n*/
+ a[3]), c & /*interactive*/
+ 16 && (l.interactive = /*interactive*/
+ a[4]), c & /*interactive*/
+ 16 && (l.showRedo = /*interactive*/
+ a[4]), c & /*handle_reset_value*/
+ 64 && (l.handle_reset_value = /*handle_reset_value*/
+ a[6]), c & /*waveform_settings*/
+ 32 && (l.waveform_settings = /*waveform_settings*/
+ a[5]), !n && c & /*mode*/
+ 1 && (n = !0, l.mode = /*mode*/
+ a[0], pi(() => n = !1)), !i && c & /*trimDuration*/
+ 8192 && (i = !0, l.trimDuration = /*trimDuration*/
+ a[13], pi(() => i = !1)), e.$set(l);
+ },
+ i(a) {
+ r || (He(e.$$.fragment, a), r = !0);
+ },
+ o(a) {
+ je(e.$$.fragment, a), r = !1;
+ },
+ d(a) {
+ In(e, a);
+ }
+ }
+ );
+}
+function ka(t) {
+ let e, n;
+ return e = new nr({}), {
+ c() {
+ Nn(e.$$.fragment);
+ },
+ m(i, r) {
+ Fn(e, i, r), n = !0;
+ },
+ i(i) {
+ n || (He(e.$$.fragment, i), n = !0);
+ },
+ o(i) {
+ je(e.$$.fragment, i), n = !1;
+ },
+ d(i) {
+ In(e, i);
+ }
+ };
+}
+function Ba(t) {
+ let e, n, i, r;
+ const s = [Ra, Pa], o = [];
+ function u(a, c) {
+ return (
+ /*value*/
+ a[1] === null ? 0 : 1
+ );
+ }
+ return e = u(t), n = o[e] = s[e](t), {
+ c() {
+ n.c(), i = Ea();
+ },
+ m(a, c) {
+ o[e].m(a, c), Gn(a, i, c), r = !0;
+ },
+ p(a, [c]) {
+ let l = e;
+ e = u(a), e === l ? o[e].p(a, c) : (cr(), je(o[l], 1, 1, () => {
+ o[l] = null;
+ }), ur(), n = o[e], n ? n.p(a, c) : (n = o[e] = s[e](a), n.c()), He(n, 1), n.m(i.parentNode, i));
+ },
+ i(a) {
+ r || (He(n), r = !0);
+ },
+ o(a) {
+ je(n), r = !1;
+ },
+ d(a) {
+ a && Un(i), o[e].d(a);
+ }
+ };
+}
+function Pe(t) {
+ let e, n = t[0], i = 1;
+ for (; i < t.length; ) {
+ const r = t[i], s = t[i + 1];
+ if (i += 2, (r === "optionalAccess" || r === "optionalCall") && n == null)
+ return;
+ r === "access" || r === "optionalAccess" ? (e = n, n = s(n)) : (r === "call" || r === "optionalCall") && (n = s((...o) => n.call(e, ...o)), e = void 0);
+ }
+ return n;
+}
+function La(t, e, n) {
+ let { value: i = null } = e, { label: r } = e, { i18n: s } = e, { dispatch: o } = e, { dispatch_blob: u = () => Promise.resolve() } = e, { interactive: a = !1 } = e, { waveform_settings: c = {} } = e, { mode: l = "" } = e, { handle_reset_value: d = () => {
+ } } = e, h, m, p = !1, g, y, w, b = 0;
+ const T = (f) => {
+ const D = Math.floor(f / 60), R = `0${Math.round(f) % 60}`.slice(-2);
+ return `${D}:${R}`;
+ }, A = () => {
+ n(8, m = We.create({
+ container: h,
+ url: Pe([i, "optionalAccess", (f) => f.url]),
+ ...c
+ }));
+ }, k = async (f, D) => {
+ n(0, l = "");
+ const C = m.getDecodedData();
+ C && await An(C, f, D).then(async (R) => {
+ await u([R], "change"), m.destroy(), A();
+ }), o("edit");
+ };
+ async function x(f) {
+ await ya(f).then((D) => {
+ if (D)
+ return Pe([
+ m,
+ "optionalAccess",
+ (C) => C.load,
+ "call",
+ (C) => C(D)
+ ]);
+ });
+ }
+ Ta(() => {
+ window.addEventListener("keydown", (f) => {
+ f.key === "ArrowRight" && l !== "edit" ? It(m, 0.1) : f.key === "ArrowLeft" && l !== "edit" && It(m, -0.1);
+ });
+ });
+ function M(f) {
+ vt[f ? "unshift" : "push"](() => {
+ h = f, n(7, h), n(8, m);
+ });
+ }
+ function S(f) {
+ vt[f ? "unshift" : "push"](() => {
+ g = f, n(9, g), n(8, m);
+ });
+ }
+ function G(f) {
+ vt[f ? "unshift" : "push"](() => {
+ y = f, n(10, y), n(8, m);
+ });
+ }
+ function V(f) {
+ l = f, n(0, l);
+ }
+ function $(f) {
+ b = f, n(13, b);
+ }
+ return t.$$set = (f) => {
+ "value" in f && n(1, i = f.value), "label" in f && n(2, r = f.label), "i18n" in f && n(3, s = f.i18n), "dispatch" in f && n(16, o = f.dispatch), "dispatch_blob" in f && n(17, u = f.dispatch_blob), "interactive" in f && n(4, a = f.interactive), "waveform_settings" in f && n(5, c = f.waveform_settings), "mode" in f && n(0, l = f.mode), "handle_reset_value" in f && n(6, d = f.handle_reset_value);
+ }, t.$$.update = () => {
+ t.$$.dirty & /*container, waveform*/
+ 384 && h !== void 0 && (m !== void 0 && m.destroy(), n(7, h.innerHTML = "", h), A(), n(11, p = !1)), t.$$.dirty & /*waveform, durationRef*/
+ 1280 && Pe([
+ m,
+ "optionalAccess",
+ (f) => f.on,
+ "call",
+ (f) => f("decode", (D) => {
+ n(12, w = D), y && n(10, y.textContent = T(D), y);
+ })
+ ]), t.$$.dirty & /*waveform, timeRef*/
+ 768 && Pe([
+ m,
+ "optionalAccess",
+ (f) => f.on,
+ "call",
+ (f) => f("timeupdate", (D) => g && n(9, g.textContent = T(D), g))
+ ]), t.$$.dirty & /*waveform, dispatch*/
+ 65792 && Pe([
+ m,
+ "optionalAccess",
+ (f) => f.on,
+ "call",
+ (f) => f("finish", () => {
+ n(11, p = !1), o("stop"), o("end");
+ })
+ ]), t.$$.dirty & /*waveform, dispatch*/
+ 65792 && Pe([
+ m,
+ "optionalAccess",
+ (f) => f.on,
+ "call",
+ (f) => f("pause", () => {
+ n(11, p = !1), o("pause");
+ })
+ ]), t.$$.dirty & /*waveform, dispatch*/
+ 65792 && Pe([
+ m,
+ "optionalAccess",
+ (f) => f.on,
+ "call",
+ (f) => f("play", () => {
+ n(11, p = !0), o("play");
+ })
+ ]), t.$$.dirty & /*value*/
+ 2 && Pe([i, "optionalAccess", (f) => f.url]) && x(i.url);
+ }, [
+ l,
+ i,
+ r,
+ s,
+ a,
+ c,
+ d,
+ h,
+ m,
+ g,
+ y,
+ p,
+ w,
+ b,
+ T,
+ k,
+ o,
+ u,
+ M,
+ S,
+ G,
+ V,
+ $
+ ];
+}
+class vh extends wa {
+ constructor(e) {
+ super(), Sa(this, e, La, Ba, Ca, {
+ value: 1,
+ label: 2,
+ i18n: 3,
+ dispatch: 16,
+ dispatch_blob: 17,
+ interactive: 4,
+ waveform_settings: 5,
+ mode: 0,
+ handle_reset_value: 6
+ });
+ }
+}
+var dn = new Intl.Collator(0, { numeric: 1 }).compare;
+function vi(t, e, n) {
+ return t = t.split("."), e = e.split("."), dn(t[0], e[0]) || dn(t[1], e[1]) || (e[2] = e.slice(2).join("."), n = /[.-]/.test(t[2] = t.slice(2).join(".")), n == /[.-]/.test(e[2]) ? dn(t[2], e[2]) : n ? -1 : 1);
+}
+function ke(t, e, n) {
+ return e.startsWith("http://") || e.startsWith("https://") ? n ? t : e : t + e;
+}
+function fn(t) {
+ if (t.startsWith("http")) {
+ const { protocol: e, host: n } = new URL(t);
+ return n.endsWith("hf.space") ? {
+ ws_protocol: "wss",
+ host: n,
+ http_protocol: e
+ } : {
+ ws_protocol: e === "https:" ? "wss" : "ws",
+ http_protocol: e,
+ host: n
+ };
+ } else if (t.startsWith("file:"))
+ return {
+ ws_protocol: "ws",
+ http_protocol: "http:",
+ host: "lite.local"
+ // Special fake hostname only used for this case. This matches the hostname allowed in `is_self_host()` in `js/wasm/network/host.ts`.
+ };
+ return {
+ ws_protocol: "wss",
+ http_protocol: "https:",
+ host: t
+ };
+}
+const hr = /^[^\/]*\/[^\/]*$/, Da = /.*hf\.space\/{0,1}$/;
+async function Ha(t, e) {
+ const n = {};
+ e && (n.Authorization = `Bearer ${e}`);
+ const i = t.trim();
+ if (hr.test(i))
+ try {
+ const r = await fetch(
+ `https://huggingface.co./api/spaces/${i}/host`,
+ { headers: n }
+ );
+ if (r.status !== 200)
+ throw new Error("Space metadata could not be loaded.");
+ const s = (await r.json()).host;
+ return {
+ space_id: t,
+ ...fn(s)
+ };
+ } catch (r) {
+ throw new Error("Space metadata could not be loaded." + r.message);
+ }
+ if (Da.test(i)) {
+ const { ws_protocol: r, http_protocol: s, host: o } = fn(i);
+ return {
+ space_id: o.replace(".hf.space", ""),
+ ws_protocol: r,
+ http_protocol: s,
+ host: o
+ };
+ }
+ return {
+ space_id: !1,
+ ...fn(i)
+ };
+}
+function Oa(t) {
+ let e = {};
+ return t.forEach(({ api_name: n }, i) => {
+ n && (e[n] = i);
+ }), e;
+}
+const Ma = /^(?=[^]*\b[dD]iscussions{0,1}\b)(?=[^]*\b[dD]isabled\b)[^]*$/;
+async function yi(t) {
+ try {
+ const n = (await fetch(
+ `https://huggingface.co./api/spaces/${t}/discussions`,
+ {
+ method: "HEAD"
+ }
+ )).headers.get("x-error-message");
+ return !(n && Ma.test(n));
+ } catch {
+ return !1;
+ }
+}
+function Ie(t, e, n) {
+ if (t == null)
+ return null;
+ if (Array.isArray(t)) {
+ const i = [];
+ for (const r of t)
+ r == null ? i.push(null) : i.push(Ie(r, e, n));
+ return i;
+ }
+ return t.is_stream ? n == null ? new Fe({
+ ...t,
+ url: e + "/stream/" + t.path
+ }) : new Fe({
+ ...t,
+ url: "/proxy=" + n + "stream/" + t.path
+ }) : new Fe({
+ ...t,
+ url: dr(t.path, e, n)
+ });
+}
+function Na(t) {
+ try {
+ const e = new URL(t);
+ return e.protocol === "http:" || e.protocol === "https:";
+ } catch {
+ return !1;
+ }
+}
+function dr(t, e, n) {
+ return t == null ? n ? `/proxy=${n}file=` : `${e}/file=` : Na(t) ? t : n ? `/proxy=${n}file=${t}` : `${e}/file=${t}`;
+}
+async function Ia(t, e, n = Wa) {
+ let i = (Array.isArray(t) ? t : [t]).map(
+ (r) => r.blob
+ );
+ return await Promise.all(
+ await n(e, i).then(
+ async (r) => {
+ if (r.error)
+ throw new Error(r.error);
+ return r.files ? r.files.map((s, o) => {
+ const u = new Fe({ ...t[o], path: s });
+ return Ie(u, e, null);
+ }) : [];
+ }
+ )
+ );
+}
+async function Ua(t, e) {
+ return t.map(
+ (n, i) => new Fe({
+ path: n.name,
+ orig_name: n.name,
+ blob: n,
+ size: n.size,
+ mime_type: n.type,
+ is_stream: e
+ })
+ );
+}
+class Fe {
+ constructor({
+ path: e,
+ url: n,
+ orig_name: i,
+ size: r,
+ blob: s,
+ is_stream: o,
+ mime_type: u,
+ alt_text: a
+ }) {
+ this.path = e, this.url = n, this.orig_name = i, this.size = r, this.blob = n ? void 0 : s, this.is_stream = o, this.mime_type = u, this.alt_text = a;
+ }
+}
+const Ga = "This application is too busy. Keep trying!", pt = "Connection errored out.";
+let fr;
+function Fa(t, e) {
+ return { post_data: n, upload_files: i, client: r, handle_blob: s };
+ async function n(o, u, a) {
+ const c = { "Content-Type": "application/json" };
+ a && (c.Authorization = `Bearer ${a}`);
+ try {
+ var l = await t(o, {
+ method: "POST",
+ body: JSON.stringify(u),
+ headers: c
+ });
+ } catch {
+ return [{ error: pt }, 500];
+ }
+ return [await l.json(), l.status];
+ }
+ async function i(o, u, a) {
+ const c = {};
+ a && (c.Authorization = `Bearer ${a}`);
+ const l = 1e3, d = [];
+ for (let m = 0; m < u.length; m += l) {
+ const p = u.slice(m, m + l), g = new FormData();
+ p.forEach((w) => {
+ g.append("files", w);
+ });
+ try {
+ var h = await t(`${o}/upload`, {
+ method: "POST",
+ body: g,
+ headers: c
+ });
+ } catch {
+ return { error: pt };
+ }
+ const y = await h.json();
+ d.push(...y);
+ }
+ return { files: d };
+ }
+ async function r(o, u = { normalise_files: !0 }) {
+ return new Promise(async (a) => {
+ const { status_callback: c, hf_token: l, normalise_files: d } = u, h = {
+ predict: V,
+ submit: $,
+ view_api: D,
+ component_server: f
+ }, m = d ?? !0;
+ if ((typeof window > "u" || !("WebSocket" in window)) && !global.Websocket) {
+ const C = await import("./wrapper-98f94c21-f7f71f53.js");
+ fr = (await import("./__vite-browser-external-2447137e.js")).Blob, global.WebSocket = C.WebSocket;
+ }
+ const { ws_protocol: p, http_protocol: g, host: y, space_id: w } = await Ha(o, l), b = Math.random().toString(36).substring(2), T = {};
+ let A, k = {}, x = !1;
+ l && w && (x = await za(w, l));
+ async function M(C) {
+ if (A = C, k = Oa((C == null ? void 0 : C.dependencies) || []), A.auth_required)
+ return {
+ config: A,
+ ...h
+ };
+ try {
+ S = await D(A);
+ } catch (R) {
+ console.error(`Could not get api details: ${R.message}`);
+ }
+ return {
+ config: A,
+ ...h
+ };
+ }
+ let S;
+ async function G(C) {
+ if (c && c(C), C.status === "running")
+ try {
+ A = await Ci(
+ t,
+ `${g}//${y}`,
+ l
+ );
+ const R = await M(A);
+ a(R);
+ } catch (R) {
+ console.error(R), c && c({
+ status: "error",
+ message: "Could not load this space.",
+ load_status: "error",
+ detail: "NOT_FOUND"
+ });
+ }
+ }
+ try {
+ A = await Ci(
+ t,
+ `${g}//${y}`,
+ l
+ );
+ const C = await M(A);
+ a(C);
+ } catch (C) {
+ console.error(C), w ? Tn(
+ w,
+ hr.test(w) ? "space_name" : "subdomain",
+ G
+ ) : c && c({
+ status: "error",
+ message: "Could not load this space.",
+ load_status: "error",
+ detail: "NOT_FOUND"
+ });
+ }
+ function V(C, R, _) {
+ let v = !1, U = !1, N;
+ if (typeof C == "number")
+ N = A.dependencies[C];
+ else {
+ const Q = C.replace(/^\//, "");
+ N = A.dependencies[k[Q]];
+ }
+ if (N.types.continuous)
+ throw new Error(
+ "Cannot call predict on this function as it may run forever. Use submit instead"
+ );
+ return new Promise((Q, be) => {
+ const H = $(C, R, _);
+ let me;
+ H.on("data", (le) => {
+ U && (H.destroy(), Q(le)), v = !0, me = le;
+ }).on("status", (le) => {
+ le.stage === "error" && be(le), le.stage === "complete" && (U = !0, v && (H.destroy(), Q(me)));
+ });
+ });
+ }
+ function $(C, R, _) {
+ let v, U;
+ if (typeof C == "number")
+ v = C, U = S.unnamed_endpoints[v];
+ else {
+ const E = C.replace(/^\//, "");
+ v = k[E], U = S.named_endpoints[C.trim()];
+ }
+ if (typeof v != "number")
+ throw new Error(
+ "There is no endpoint matching that name of fn_index matching that number."
+ );
+ let N, Q, be = A.protocol ?? "sse";
+ const H = typeof C == "number" ? "/predict" : C;
+ let me, le = null, pe = !1;
+ const Me = {};
+ let Ee = "";
+ typeof window < "u" && (Ee = new URLSearchParams(window.location.search).toString()), s(
+ `${g}//${ke(y, A.path, !0)}`,
+ R,
+ U,
+ l
+ ).then((E) => {
+ if (me = { data: E || [], event_data: _, fn_index: v }, qa(v, A))
+ z({
+ type: "status",
+ endpoint: H,
+ stage: "pending",
+ queue: !1,
+ fn_index: v,
+ time: /* @__PURE__ */ new Date()
+ }), n(
+ `${g}//${ke(y, A.path, !0)}/run${H.startsWith("/") ? H : `/${H}`}${Ee ? "?" + Ee : ""}`,
+ {
+ ...me,
+ session_hash: b
+ },
+ l
+ ).then(([W, J]) => {
+ const Ae = m ? mn(
+ W.data,
+ U,
+ A.root,
+ A.root_url
+ ) : W.data;
+ J == 200 ? (z({
+ type: "data",
+ endpoint: H,
+ fn_index: v,
+ data: Ae,
+ time: /* @__PURE__ */ new Date()
+ }), z({
+ type: "status",
+ endpoint: H,
+ fn_index: v,
+ stage: "complete",
+ eta: W.average_duration,
+ queue: !1,
+ time: /* @__PURE__ */ new Date()
+ })) : z({
+ type: "status",
+ stage: "error",
+ endpoint: H,
+ fn_index: v,
+ message: W.error,
+ queue: !1,
+ time: /* @__PURE__ */ new Date()
+ });
+ }).catch((W) => {
+ z({
+ type: "status",
+ stage: "error",
+ message: W.message,
+ endpoint: H,
+ fn_index: v,
+ queue: !1,
+ time: /* @__PURE__ */ new Date()
+ });
+ });
+ else if (be == "ws") {
+ z({
+ type: "status",
+ stage: "pending",
+ queue: !0,
+ endpoint: H,
+ fn_index: v,
+ time: /* @__PURE__ */ new Date()
+ });
+ let W = new URL(`${p}://${ke(
+ y,
+ A.path,
+ !0
+ )}
+ /queue/join${Ee ? "?" + Ee : ""}`);
+ x && W.searchParams.set("__sign", x), N = e(W), N.onclose = (J) => {
+ J.wasClean || z({
+ type: "status",
+ stage: "error",
+ broken: !0,
+ message: pt,
+ queue: !0,
+ endpoint: H,
+ fn_index: v,
+ time: /* @__PURE__ */ new Date()
+ });
+ }, N.onmessage = function(J) {
+ const Ae = JSON.parse(J.data), { type: ue, status: X, data: _e } = Ai(
+ Ae,
+ T[v]
+ );
+ if (ue === "update" && X && !pe)
+ z({
+ type: "status",
+ endpoint: H,
+ fn_index: v,
+ time: /* @__PURE__ */ new Date(),
+ ...X
+ }), X.stage === "error" && N.close();
+ else if (ue === "hash") {
+ N.send(JSON.stringify({ fn_index: v, session_hash: b }));
+ return;
+ } else
+ ue === "data" ? N.send(JSON.stringify({ ...me, session_hash: b })) : ue === "complete" ? pe = X : ue === "log" ? z({
+ type: "log",
+ log: _e.log,
+ level: _e.level,
+ endpoint: H,
+ fn_index: v
+ }) : ue === "generating" && z({
+ type: "status",
+ time: /* @__PURE__ */ new Date(),
+ ...X,
+ stage: X == null ? void 0 : X.stage,
+ queue: !0,
+ endpoint: H,
+ fn_index: v
+ });
+ _e && (z({
+ type: "data",
+ time: /* @__PURE__ */ new Date(),
+ data: m ? mn(
+ _e.data,
+ U,
+ A.root,
+ A.root_url
+ ) : _e.data,
+ endpoint: H,
+ fn_index: v
+ }), pe && (z({
+ type: "status",
+ time: /* @__PURE__ */ new Date(),
+ ...pe,
+ stage: X == null ? void 0 : X.stage,
+ queue: !0,
+ endpoint: H,
+ fn_index: v
+ }), N.close()));
+ }, vi(A.version || "2.0.0", "3.6") < 0 && addEventListener(
+ "open",
+ () => N.send(JSON.stringify({ hash: b }))
+ );
+ } else {
+ z({
+ type: "status",
+ stage: "pending",
+ queue: !0,
+ endpoint: H,
+ fn_index: v,
+ time: /* @__PURE__ */ new Date()
+ });
+ var ne = new URLSearchParams({
+ fn_index: v.toString(),
+ session_hash: b
+ }).toString();
+ let W = new URL(
+ `${g}//${ke(
+ y,
+ A.path,
+ !0
+ )}/queue/join?${Ee ? Ee + "&" : ""}${ne}`
+ );
+ Q = new EventSource(W), Q.onmessage = async function(J) {
+ const Ae = JSON.parse(J.data), { type: ue, status: X, data: _e } = Ai(
+ Ae,
+ T[v]
+ );
+ if (ue === "update" && X && !pe)
+ z({
+ type: "status",
+ endpoint: H,
+ fn_index: v,
+ time: /* @__PURE__ */ new Date(),
+ ...X
+ }), X.stage === "error" && Q.close();
+ else if (ue === "data") {
+ le = Ae.event_id;
+ let [fh, Jr] = await n(
+ `${g}//${ke(
+ y,
+ A.path,
+ !0
+ )}/queue/data`,
+ {
+ ...me,
+ session_hash: b,
+ event_id: le
+ },
+ l
+ );
+ Jr !== 200 && (z({
+ type: "status",
+ stage: "error",
+ message: pt,
+ queue: !0,
+ endpoint: H,
+ fn_index: v,
+ time: /* @__PURE__ */ new Date()
+ }), Q.close());
+ } else
+ ue === "complete" ? pe = X : ue === "log" ? z({
+ type: "log",
+ log: _e.log,
+ level: _e.level,
+ endpoint: H,
+ fn_index: v
+ }) : ue === "generating" && z({
+ type: "status",
+ time: /* @__PURE__ */ new Date(),
+ ...X,
+ stage: X == null ? void 0 : X.stage,
+ queue: !0,
+ endpoint: H,
+ fn_index: v
+ });
+ _e && (z({
+ type: "data",
+ time: /* @__PURE__ */ new Date(),
+ data: m ? mn(
+ _e.data,
+ U,
+ A.root,
+ A.root_url
+ ) : _e.data,
+ endpoint: H,
+ fn_index: v
+ }), pe && (z({
+ type: "status",
+ time: /* @__PURE__ */ new Date(),
+ ...pe,
+ stage: X == null ? void 0 : X.stage,
+ queue: !0,
+ endpoint: H,
+ fn_index: v
+ }), Q.close()));
+ };
+ }
+ });
+ function z(E) {
+ const W = Me[E.type] || [];
+ W == null || W.forEach((J) => J(E));
+ }
+ function ct(E, ne) {
+ const W = Me, J = W[E] || [];
+ return W[E] = J, J == null || J.push(ne), { on: ct, off: Ve, cancel: ht, destroy: dt };
+ }
+ function Ve(E, ne) {
+ const W = Me;
+ let J = W[E] || [];
+ return J = J == null ? void 0 : J.filter((Ae) => Ae !== ne), W[E] = J, { on: ct, off: Ve, cancel: ht, destroy: dt };
+ }
+ async function ht() {
+ const E = {
+ stage: "complete",
+ queue: !1,
+ time: /* @__PURE__ */ new Date()
+ };
+ pe = E, z({
+ ...E,
+ type: "status",
+ endpoint: H,
+ fn_index: v
+ });
+ let ne = {};
+ be === "ws" ? (N && N.readyState === 0 ? N.addEventListener("open", () => {
+ N.close();
+ }) : N.close(), ne = { fn_index: v, session_hash: b }) : (Q.close(), ne = { event_id: le });
+ try {
+ await t(
+ `${g}//${ke(
+ y,
+ A.path,
+ !0
+ )}/reset`,
+ {
+ headers: { "Content-Type": "application/json" },
+ method: "POST",
+ body: JSON.stringify(ne)
+ }
+ );
+ } catch {
+ console.warn(
+ "The `/reset` endpoint could not be called. Subsequent endpoint results may be unreliable."
+ );
+ }
+ }
+ function dt() {
+ for (const E in Me)
+ Me[E].forEach((ne) => {
+ Ve(E, ne);
+ });
+ }
+ return {
+ on: ct,
+ off: Ve,
+ cancel: ht,
+ destroy: dt
+ };
+ }
+ async function f(C, R, _) {
+ var v;
+ const U = { "Content-Type": "application/json" };
+ l && (U.Authorization = `Bearer ${l}`);
+ let N, Q = A.components.find(
+ (me) => me.id === C
+ );
+ (v = Q == null ? void 0 : Q.props) != null && v.root_url ? N = Q.props.root_url : N = `${g}//${ke(
+ y,
+ A.path,
+ !0
+ )}/`;
+ const be = await t(
+ `${N}component_server/`,
+ {
+ method: "POST",
+ body: JSON.stringify({
+ data: _,
+ component_id: C,
+ fn_name: R,
+ session_hash: b
+ }),
+ headers: U
+ }
+ );
+ if (!be.ok)
+ throw new Error(
+ "Could not connect to component server: " + be.statusText
+ );
+ return await be.json();
+ }
+ async function D(C) {
+ if (S)
+ return S;
+ const R = { "Content-Type": "application/json" };
+ l && (R.Authorization = `Bearer ${l}`);
+ let _;
+ if (vi(C.version || "2.0.0", "3.30") < 0 ? _ = await t(
+ "https://gradio-space-api-fetcher-v2.hf.space/api",
+ {
+ method: "POST",
+ body: JSON.stringify({
+ serialize: !1,
+ config: JSON.stringify(C)
+ }),
+ headers: R
+ }
+ ) : _ = await t(`${C.root}/info`, {
+ headers: R
+ }), !_.ok)
+ throw new Error(pt);
+ let v = await _.json();
+ return "api" in v && (v = v.api), v.named_endpoints["/predict"] && !v.unnamed_endpoints[0] && (v.unnamed_endpoints[0] = v.named_endpoints["/predict"]), ja(v, C, k);
+ }
+ });
+ }
+ async function s(o, u, a, c) {
+ const l = await xn(
+ u,
+ void 0,
+ [],
+ !0,
+ a
+ );
+ return Promise.all(
+ l.map(async ({ path: d, blob: h, type: m }) => {
+ if (h) {
+ const p = (await i(o, [h], c)).files[0];
+ return { path: d, file_url: p, type: m, name: h == null ? void 0 : h.name };
+ }
+ return { path: d, type: m };
+ })
+ ).then((d) => (d.forEach(({ path: h, file_url: m, type: p, name: g }) => {
+ if (p === "Gallery")
+ Si(u, m, h);
+ else if (m) {
+ const y = new Fe({ path: m, orig_name: g });
+ Si(u, y, h);
+ }
+ }), u));
+ }
+}
+const { post_data: yh, upload_files: Wa, client: wh, handle_blob: Eh } = Fa(
+ fetch,
+ (...t) => new WebSocket(...t)
+);
+function mn(t, e, n, i) {
+ return t.map((r, s) => {
+ var o, u, a, c;
+ return ((u = (o = e == null ? void 0 : e.returns) == null ? void 0 : o[s]) == null ? void 0 : u.component) === "File" ? Ie(r, n, i) : ((c = (a = e == null ? void 0 : e.returns) == null ? void 0 : a[s]) == null ? void 0 : c.component) === "Gallery" ? r.map((l) => Array.isArray(l) ? [Ie(l[0], n, i), l[1]] : [Ie(l, n, i), null]) : typeof r == "object" && r.path ? Ie(r, n, i) : r;
+ });
+}
+function wi(t, e, n, i) {
+ switch (t.type) {
+ case "string":
+ return "string";
+ case "boolean":
+ return "boolean";
+ case "number":
+ return "number";
+ }
+ if (n === "JSONSerializable" || n === "StringSerializable")
+ return "any";
+ if (n === "ListStringSerializable")
+ return "string[]";
+ if (e === "Image")
+ return i === "parameter" ? "Blob | File | Buffer" : "string";
+ if (n === "FileSerializable")
+ return (t == null ? void 0 : t.type) === "array" ? i === "parameter" ? "(Blob | File | Buffer)[]" : "{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}[]" : i === "parameter" ? "Blob | File | Buffer" : "{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}";
+ if (n === "GallerySerializable")
+ return i === "parameter" ? "[(Blob | File | Buffer), (string | null)][]" : "[{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}, (string | null))][]";
+}
+function Ei(t, e) {
+ return e === "GallerySerializable" ? "array of [file, label] tuples" : e === "ListStringSerializable" ? "array of strings" : e === "FileSerializable" ? "array of files or single file" : t.description;
+}
+function ja(t, e, n) {
+ const i = {
+ named_endpoints: {},
+ unnamed_endpoints: {}
+ };
+ for (const r in t) {
+ const s = t[r];
+ for (const o in s) {
+ const u = e.dependencies[o] ? o : n[o.replace("/", "")], a = s[o];
+ i[r][o] = {}, i[r][o].parameters = {}, i[r][o].returns = {}, i[r][o].type = e.dependencies[u].types, i[r][o].parameters = a.parameters.map(
+ ({ label: c, component: l, type: d, serializer: h }) => ({
+ label: c,
+ component: l,
+ type: wi(d, l, h, "parameter"),
+ description: Ei(d, h)
+ })
+ ), i[r][o].returns = a.returns.map(
+ ({ label: c, component: l, type: d, serializer: h }) => ({
+ label: c,
+ component: l,
+ type: wi(d, l, h, "return"),
+ description: Ei(d, h)
+ })
+ );
+ }
+ }
+ return i;
+}
+async function za(t, e) {
+ try {
+ return (await (await fetch(`https://huggingface.co./api/spaces/${t}/jwt`, {
+ headers: {
+ Authorization: `Bearer ${e}`
+ }
+ })).json()).token || !1;
+ } catch (n) {
+ return console.error(n), !1;
+ }
+}
+function Si(t, e, n) {
+ for (; n.length > 1; )
+ t = t[n.shift()];
+ t[n.shift()] = e;
+}
+async function xn(t, e = void 0, n = [], i = !1, r = void 0) {
+ if (Array.isArray(t)) {
+ let s = [];
+ return await Promise.all(
+ t.map(async (o, u) => {
+ var a;
+ let c = n.slice();
+ c.push(u);
+ const l = await xn(
+ t[u],
+ i ? ((a = r == null ? void 0 : r.parameters[u]) == null ? void 0 : a.component) || void 0 : e,
+ c,
+ !1,
+ r
+ );
+ s = s.concat(l);
+ })
+ ), s;
+ } else {
+ if (globalThis.Buffer && t instanceof globalThis.Buffer)
+ return [
+ {
+ path: n,
+ blob: e === "Image" ? !1 : new fr([t]),
+ type: e
+ }
+ ];
+ if (typeof t == "object") {
+ let s = [];
+ for (let o in t)
+ if (t.hasOwnProperty(o)) {
+ let u = n.slice();
+ u.push(o), s = s.concat(
+ await xn(
+ t[o],
+ void 0,
+ u,
+ !1,
+ r
+ )
+ );
+ }
+ return s;
+ }
+ }
+ return [];
+}
+function qa(t, e) {
+ var n, i, r, s;
+ return !(((i = (n = e == null ? void 0 : e.dependencies) == null ? void 0 : n[t]) == null ? void 0 : i.queue) === null ? e.enable_queue : (s = (r = e == null ? void 0 : e.dependencies) == null ? void 0 : r[t]) != null && s.queue) || !1;
+}
+async function Ci(t, e, n) {
+ const i = {};
+ if (n && (i.Authorization = `Bearer ${n}`), typeof window < "u" && window.gradio_config && location.origin !== "http://localhost:9876" && !window.gradio_config.dev_mode) {
+ const r = window.gradio_config.root, s = window.gradio_config;
+ return s.root = ke(e, s.root, !1), { ...s, path: r };
+ } else if (e) {
+ let r = await t(`${e}/config`, {
+ headers: i
+ });
+ if (r.status === 200) {
+ const s = await r.json();
+ return s.path = s.path ?? "", s.root = e, s;
+ }
+ throw new Error("Could not get config.");
+ }
+ throw new Error("No config or app endpoint found");
+}
+async function Tn(t, e, n) {
+ let i = e === "subdomain" ? `https://huggingface.co./api/spaces/by-subdomain/${t}` : `https://huggingface.co./api/spaces/${t}`, r, s;
+ try {
+ if (r = await fetch(i), s = r.status, s !== 200)
+ throw new Error();
+ r = await r.json();
+ } catch {
+ n({
+ status: "error",
+ load_status: "error",
+ message: "Could not get space status",
+ detail: "NOT_FOUND"
+ });
+ return;
+ }
+ if (!r || s !== 200)
+ return;
+ const {
+ runtime: { stage: o },
+ id: u
+ } = r;
+ switch (o) {
+ case "STOPPED":
+ case "SLEEPING":
+ n({
+ status: "sleeping",
+ load_status: "pending",
+ message: "Space is asleep. Waking it up...",
+ detail: o
+ }), setTimeout(() => {
+ Tn(t, e, n);
+ }, 1e3);
+ break;
+ case "PAUSED":
+ n({
+ status: "paused",
+ load_status: "error",
+ message: "This space has been paused by the author. If you would like to try this demo, consider duplicating the space.",
+ detail: o,
+ discussions_enabled: await yi(u)
+ });
+ break;
+ case "RUNNING":
+ case "RUNNING_BUILDING":
+ n({
+ status: "running",
+ load_status: "complete",
+ message: "",
+ detail: o
+ });
+ break;
+ case "BUILDING":
+ n({
+ status: "building",
+ load_status: "pending",
+ message: "Space is building...",
+ detail: o
+ }), setTimeout(() => {
+ Tn(t, e, n);
+ }, 1e3);
+ break;
+ default:
+ n({
+ status: "space_error",
+ load_status: "error",
+ message: "This space is experiencing an issue.",
+ detail: o,
+ discussions_enabled: await yi(u)
+ });
+ break;
+ }
+}
+function Ai(t, e) {
+ switch (t.msg) {
+ case "send_data":
+ return { type: "data" };
+ case "send_hash":
+ return { type: "hash" };
+ case "queue_full":
+ return {
+ type: "update",
+ status: {
+ queue: !0,
+ message: Ga,
+ stage: "error",
+ code: t.code,
+ success: t.success
+ }
+ };
+ case "estimation":
+ return {
+ type: "update",
+ status: {
+ queue: !0,
+ stage: e || "pending",
+ code: t.code,
+ size: t.queue_size,
+ position: t.rank,
+ eta: t.rank_eta,
+ success: t.success
+ }
+ };
+ case "progress":
+ return {
+ type: "update",
+ status: {
+ queue: !0,
+ stage: "pending",
+ code: t.code,
+ progress_data: t.progress_data,
+ success: t.success
+ }
+ };
+ case "log":
+ return { type: "log", data: t };
+ case "process_generating":
+ return {
+ type: "generating",
+ status: {
+ queue: !0,
+ message: t.success ? null : t.output.error,
+ stage: t.success ? "generating" : "error",
+ code: t.code,
+ progress_data: t.progress_data,
+ eta: t.average_duration
+ },
+ data: t.success ? t.output : null
+ };
+ case "process_completed":
+ return "error" in t.output ? {
+ type: "update",
+ status: {
+ queue: !0,
+ message: t.output.error,
+ stage: "error",
+ code: t.code,
+ success: t.success
+ }
+ } : {
+ type: "complete",
+ status: {
+ queue: !0,
+ message: t.success ? void 0 : t.output.error,
+ stage: t.success ? "complete" : "error",
+ code: t.code,
+ progress_data: t.progress_data,
+ eta: t.output.average_duration
+ },
+ data: t.success ? t.output : null
+ };
+ case "process_starts":
+ return {
+ type: "update",
+ status: {
+ queue: !0,
+ stage: "pending",
+ code: t.code,
+ size: t.rank,
+ position: 0,
+ success: t.success
+ }
+ };
+ }
+ return { type: "none", status: { stage: "error", queue: !0 } };
+}
+const {
+ SvelteComponent: Va,
+ append: Ce,
+ attr: P,
+ binding_callbacks: Xa,
+ bubble: xi,
+ check_outros: mr,
+ create_component: Wn,
+ destroy_block: Za,
+ destroy_component: jn,
+ detach: oe,
+ element: it,
+ empty: pr,
+ ensure_array_like: Ti,
+ group_outros: _r,
+ init: Ja,
+ insert: ae,
+ listen: gr,
+ mount_component: zn,
+ null_to_empty: Pi,
+ safe_not_equal: Qa,
+ set_style: Xt,
+ space: Ut,
+ src_url_equal: Gt,
+ svg_element: we,
+ transition_in: Oe,
+ transition_out: ze,
+ update_keyed_each: Ya
+} = window.__gradio__svelte__internal, { createEventDispatcher: Ka, onMount: Sh } = window.__gradio__svelte__internal;
+function Ri(t, e, n) {
+ const i = t.slice();
+ return i[19] = e[n], i[21] = n, i;
+}
+function $a(t) {
+ let e, n;
+ return e = new tr({
+ props: {
+ size: "small",
+ $$slots: { default: [tl] },
+ $$scope: { ctx: t }
+ }
+ }), {
+ c() {
+ Wn(e.$$.fragment);
+ },
+ m(i, r) {
+ zn(e, i, r), n = !0;
+ },
+ p(i, r) {
+ const s = {};
+ r & /*$$scope*/
+ 4194304 && (s.$$scope = { dirty: r, ctx: i }), e.$set(s);
+ },
+ i(i) {
+ n || (Oe(e.$$.fragment, i), n = !0);
+ },
+ o(i) {
+ ze(e.$$.fragment, i), n = !1;
+ },
+ d(i) {
+ jn(e, i);
+ }
+ };
+}
+function el(t) {
+ let e, n, i, r, s, o, u, a = (
+ /*show_share_button*/
+ t[2] && ki(t)
+ );
+ function c(h, m) {
+ return (
+ /*image*/
+ h[1] ? il : nl
+ );
+ }
+ let l = c(t), d = l(t);
+ return {
+ c() {
+ e = it("div"), a && a.c(), n = Ut(), i = it("audio"), s = Ut(), d.c(), o = pr(), P(e, "class", "icon-buttons"), Gt(i.src, r = /*value*/
+ t[0].url) || P(i, "src", r), i.controls = !0, P(i, "class", "svelte-34w466");
+ },
+ m(h, m) {
+ ae(h, e, m), a && a.m(e, null), ae(h, n, m), ae(h, i, m), t[17](i), ae(h, s, m), d.m(h, m), ae(h, o, m), u = !0;
+ },
+ p(h, m) {
+ /*show_share_button*/
+ h[2] ? a ? (a.p(h, m), m & /*show_share_button*/
+ 4 && Oe(a, 1)) : (a = ki(h), a.c(), Oe(a, 1), a.m(e, null)) : a && (_r(), ze(a, 1, 1, () => {
+ a = null;
+ }), mr()), (!u || m & /*value*/
+ 1 && !Gt(i.src, r = /*value*/
+ h[0].url)) && P(i, "src", r), l === (l = c(h)) && d ? d.p(h, m) : (d.d(1), d = l(h), d && (d.c(), d.m(o.parentNode, o)));
+ },
+ i(h) {
+ u || (Oe(a), u = !0);
+ },
+ o(h) {
+ ze(a), u = !1;
+ },
+ d(h) {
+ h && (oe(e), oe(n), oe(i), oe(s), oe(o)), a && a.d(), t[17](null), d.d(h);
+ }
+ };
+}
+function tl(t) {
+ let e, n;
+ return e = new nr({}), {
+ c() {
+ Wn(e.$$.fragment);
+ },
+ m(i, r) {
+ zn(e, i, r), n = !0;
+ },
+ i(i) {
+ n || (Oe(e.$$.fragment, i), n = !0);
+ },
+ o(i) {
+ ze(e.$$.fragment, i), n = !1;
+ },
+ d(i) {
+ jn(e, i);
+ }
+ };
+}
+function ki(t) {
+ let e, n;
+ return e = new Jo({
+ props: {
+ i18n: (
+ /*i18n*/
+ t[3]
+ ),
+ formatter: (
+ /*func*/
+ t[14]
+ ),
+ value: (
+ /*value*/
+ t[0]
+ )
+ }
+ }), e.$on(
+ "error",
+ /*error_handler*/
+ t[15]
+ ), e.$on(
+ "share",
+ /*share_handler*/
+ t[16]
+ ), {
+ c() {
+ Wn(e.$$.fragment);
+ },
+ m(i, r) {
+ zn(e, i, r), n = !0;
+ },
+ p(i, r) {
+ const s = {};
+ r & /*i18n*/
+ 8 && (s.i18n = /*i18n*/
+ i[3]), r & /*value*/
+ 1 && (s.value = /*value*/
+ i[0]), e.$set(s);
+ },
+ i(i) {
+ n || (Oe(e.$$.fragment, i), n = !0);
+ },
+ o(i) {
+ ze(e.$$.fragment, i), n = !1;
+ },
+ d(i) {
+ jn(e, i);
+ }
+ };
+}
+function nl(t) {
+ let e, n = [], i = /* @__PURE__ */ new Map(), r, s, o, u = Ti(Array(15));
+ const a = (h) => (
+ /*i*/
+ h[21]
+ );
+ for (let h = 0; h < u.length; h += 1) {
+ let m = Ri(t, u, h), p = a(m);
+ i.set(p, n[h] = Bi(p, m));
+ }
+ function c(h, m) {
+ return (
+ /*isPlaying*/
+ h[6] ? rl : sl
+ );
+ }
+ let l = c(t), d = l(t);
+ return {
+ c() {
+ e = it("div");
+ for (let h = 0; h < n.length; h += 1)
+ n[h].c();
+ r = Ut(), d.c(), P(e, "class", "circle-container svelte-34w466"), P(e, "role", "button"), P(e, "tabindex", "0"), P(e, "aria-hidden", "true");
+ },
+ m(h, m) {
+ ae(h, e, m);
+ for (let p = 0; p < n.length; p += 1)
+ n[p] && n[p].m(e, null);
+ Ce(e, r), d.m(e, null), s || (o = gr(
+ e,
+ "click",
+ /*play_audio*/
+ t[7]
+ ), s = !0);
+ },
+ p(h, m) {
+ m & /*isPlaying, Array*/
+ 64 && (u = Ti(Array(15)), n = Ya(n, m, a, 1, h, u, i, e, Za, Bi, r, Ri)), l !== (l = c(h)) && (d.d(1), d = l(h), d && (d.c(), d.m(e, null)));
+ },
+ d(h) {
+ h && oe(e);
+ for (let m = 0; m < n.length; m += 1)
+ n[m].d();
+ d.d(), s = !1, o();
+ }
+ };
+}
+function il(t) {
+ let e, n, i, r, s, o;
+ function u(l, d) {
+ return (
+ /*isPlaying*/
+ l[6] ? ol : al
+ );
+ }
+ let a = u(t), c = a(t);
+ return {
+ c() {
+ e = it("div"), n = it("img"), r = Ut(), c.c(), P(n, "class", "image-player svelte-34w466"), Gt(n.src, i = /*image_path*/
+ t[4]) || P(n, "src", i), P(n, "alt", "test"), P(e, "class", "image-container svelte-34w466"), P(e, "role", "button"), P(e, "tabindex", "0"), P(e, "aria-hidden", "true");
+ },
+ m(l, d) {
+ ae(l, e, d), Ce(e, n), Ce(e, r), c.m(e, null), s || (o = gr(
+ e,
+ "click",
+ /*play_audio*/
+ t[7]
+ ), s = !0);
+ },
+ p(l, d) {
+ d & /*image_path*/
+ 16 && !Gt(n.src, i = /*image_path*/
+ l[4]) && P(n, "src", i), a !== (a = u(l)) && (c.d(1), c = a(l), c && (c.c(), c.m(e, null)));
+ },
+ d(l) {
+ l && oe(e), c.d(), s = !1, o();
+ }
+ };
+}
+function Bi(t, e) {
+ let n, i;
+ return {
+ key: t,
+ first: null,
+ c() {
+ n = it("div"), P(n, "class", i = Pi(`waveform-bar ${/*isPlaying*/
+ e[6] ? `waveform-animation-${/*i*/
+ e[21] % 5}` : ""}`) + " svelte-34w466"), P(n, "style", `height: ${20 + /*i*/
+ e[21] % 5 * 10}%`), this.first = n;
+ },
+ m(r, s) {
+ ae(r, n, s);
+ },
+ p(r, s) {
+ e = r, s & /*isPlaying*/
+ 64 && i !== (i = Pi(`waveform-bar ${/*isPlaying*/
+ e[6] ? `waveform-animation-${/*i*/
+ e[21] % 5}` : ""}`) + " svelte-34w466") && P(n, "class", i);
+ },
+ d(r) {
+ r && oe(n);
+ }
+ };
+}
+function rl(t) {
+ let e, n, i;
+ return {
+ c() {
+ e = we("svg"), n = we("rect"), i = we("rect"), P(n, "x", "6"), P(n, "y", "4"), P(n, "width", "4"), P(n, "height", "16"), P(n, "fill", "#fff"), P(i, "x", "14"), P(i, "y", "4"), P(i, "width", "4"), P(i, "height", "16"), P(i, "fill", "#fff"), P(e, "class", "pause-icon svelte-34w466"), P(e, "viewBox", "0 0 24 24"), Xt(e, "pointer-events", "none");
+ },
+ m(r, s) {
+ ae(r, e, s), Ce(e, n), Ce(e, i);
+ },
+ d(r) {
+ r && oe(e);
+ }
+ };
+}
+function sl(t) {
+ let e, n;
+ return {
+ c() {
+ e = we("svg"), n = we("polygon"), P(n, "points", "5,3 19,12 5,21"), P(n, "fill", "#fff"), P(e, "class", "play-icon svelte-34w466"), P(e, "viewBox", "0 0 24 24"), Xt(e, "pointer-events", "none");
+ },
+ m(i, r) {
+ ae(i, e, r), Ce(e, n);
+ },
+ d(i) {
+ i && oe(e);
+ }
+ };
+}
+function ol(t) {
+ let e, n, i;
+ return {
+ c() {
+ e = we("svg"), n = we("rect"), i = we("rect"), P(n, "x", "6"), P(n, "y", "4"), P(n, "width", "4"), P(n, "height", "16"), P(n, "fill", "#fff"), P(i, "x", "14"), P(i, "y", "4"), P(i, "width", "4"), P(i, "height", "16"), P(i, "fill", "#fff"), P(e, "class", "pause-icon svelte-34w466"), P(e, "viewBox", "0 0 24 24"), Xt(e, "pointer-events", "none");
+ },
+ m(r, s) {
+ ae(r, e, s), Ce(e, n), Ce(e, i);
+ },
+ d(r) {
+ r && oe(e);
+ }
+ };
+}
+function al(t) {
+ let e, n;
+ return {
+ c() {
+ e = we("svg"), n = we("polygon"), P(n, "points", "5,3 19,12 5,21"), P(n, "fill", "#fff"), P(e, "class", "play-icon svelte-34w466"), P(e, "viewBox", "0 0 24 24"), Xt(e, "pointer-events", "none");
+ },
+ m(i, r) {
+ ae(i, e, r), Ce(e, n);
+ },
+ d(i) {
+ i && oe(e);
+ }
+ };
+}
+function ll(t) {
+ let e, n, i, r;
+ const s = [el, $a], o = [];
+ function u(a, c) {
+ return (
+ /*value*/
+ a[0] !== null ? 0 : 1
+ );
+ }
+ return e = u(t), n = o[e] = s[e](t), {
+ c() {
+ n.c(), i = pr();
+ },
+ m(a, c) {
+ o[e].m(a, c), ae(a, i, c), r = !0;
+ },
+ p(a, [c]) {
+ let l = e;
+ e = u(a), e === l ? o[e].p(a, c) : (_r(), ze(o[l], 1, 1, () => {
+ o[l] = null;
+ }), mr(), n = o[e], n ? n.p(a, c) : (n = o[e] = s[e](a), n.c()), Oe(n, 1), n.m(i.parentNode, i));
+ },
+ i(a) {
+ r || (Oe(n), r = !0);
+ },
+ o(a) {
+ ze(n), r = !1;
+ },
+ d(a) {
+ a && oe(i), o[e].d(a);
+ }
+ };
+}
+function ul(t, e, n) {
+ let { value: i = null } = e, { image: r = null } = e, { label: s } = e, { show_label: o = !0 } = e, { show_download_button: u = !0 } = e, { show_share_button: a = !1 } = e, { i18n: c } = e, { waveform_settings: l = {} } = e, { root: d = "" } = e, { proxy_url: h = null } = e, m;
+ const p = Ka();
+ let g, y = !1;
+ function w() {
+ if (y) {
+ g.pause(), n(6, y = !1);
+ return;
+ } else
+ g.play(), n(6, y = !0);
+ }
+ const b = async (x) => x ? `` : "";
+ function T(x) {
+ xi.call(this, t, x);
+ }
+ function A(x) {
+ xi.call(this, t, x);
+ }
+ function k(x) {
+ Xa[x ? "unshift" : "push"](() => {
+ g = x, n(5, g);
+ });
+ }
+ return t.$$set = (x) => {
+ "value" in x && n(0, i = x.value), "image" in x && n(1, r = x.image), "label" in x && n(8, s = x.label), "show_label" in x && n(9, o = x.show_label), "show_download_button" in x && n(10, u = x.show_download_button), "show_share_button" in x && n(2, a = x.show_share_button), "i18n" in x && n(3, c = x.i18n), "waveform_settings" in x && n(11, l = x.waveform_settings), "root" in x && n(12, d = x.root), "proxy_url" in x && n(13, h = x.proxy_url);
+ }, t.$$.update = () => {
+ t.$$.dirty & /*image, root, proxy_url*/
+ 12290 && (r instanceof Fe ? n(4, m = r.path) : n(4, m = dr(r, d, h))), t.$$.dirty & /*value*/
+ 1 && i && p("change", i);
+ }, [
+ i,
+ r,
+ a,
+ c,
+ m,
+ g,
+ y,
+ w,
+ s,
+ o,
+ u,
+ l,
+ d,
+ h,
+ b,
+ T,
+ A,
+ k
+ ];
+}
+class cl extends Va {
+ constructor(e) {
+ super(), Ja(this, e, ul, ll, Qa, {
+ value: 0,
+ image: 1,
+ label: 8,
+ show_label: 9,
+ show_download_button: 10,
+ show_share_button: 2,
+ i18n: 3,
+ waveform_settings: 11,
+ root: 12,
+ proxy_url: 13
+ });
+ }
+}
+function $e() {
+}
+function hl(t) {
+ return t();
+}
+function dl(t) {
+ t.forEach(hl);
+}
+function fl(t) {
+ return typeof t == "function";
+}
+function ml(t, e) {
+ return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
+}
+function pl(t, ...e) {
+ if (t == null) {
+ for (const i of e)
+ i(void 0);
+ return $e;
+ }
+ const n = t.subscribe(...e);
+ return n.unsubscribe ? () => n.unsubscribe() : n;
+}
+const Ze = [];
+function _l(t, e) {
+ return {
+ subscribe: Zt(t, e).subscribe
+ };
+}
+function Zt(t, e = $e) {
+ let n;
+ const i = /* @__PURE__ */ new Set();
+ function r(u) {
+ if (ml(t, u) && (t = u, n)) {
+ const a = !Ze.length;
+ for (const c of i)
+ c[1](), Ze.push(c, t);
+ if (a) {
+ for (let c = 0; c < Ze.length; c += 2)
+ Ze[c][0](Ze[c + 1]);
+ Ze.length = 0;
+ }
+ }
+ }
+ function s(u) {
+ r(u(t));
+ }
+ function o(u, a = $e) {
+ const c = [u, a];
+ return i.add(c), i.size === 1 && (n = e(r, s) || $e), u(t), () => {
+ i.delete(c), i.size === 0 && n && (n(), n = null);
+ };
+ }
+ return { set: r, update: s, subscribe: o };
+}
+function lt(t, e, n) {
+ const i = !Array.isArray(t), r = i ? [t] : t;
+ if (!r.every(Boolean))
+ throw new Error("derived() expects stores as input, got a falsy value");
+ const s = e.length < 2;
+ return _l(n, (o, u) => {
+ let a = !1;
+ const c = [];
+ let l = 0, d = $e;
+ const h = () => {
+ if (l)
+ return;
+ d();
+ const p = e(i ? c[0] : c, o, u);
+ s ? o(p) : d = fl(p) ? p : $e;
+ }, m = r.map(
+ (p, g) => pl(
+ p,
+ (y) => {
+ c[g] = y, l &= ~(1 << g), a && h();
+ },
+ () => {
+ l |= 1 << g;
+ }
+ )
+ );
+ return a = !0, h(), function() {
+ dl(m), d(), a = !1;
+ };
+ });
+}
+function gl(t) {
+ return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
+}
+var bl = function(e) {
+ return vl(e) && !yl(e);
+};
+function vl(t) {
+ return !!t && typeof t == "object";
+}
+function yl(t) {
+ var e = Object.prototype.toString.call(t);
+ return e === "[object RegExp]" || e === "[object Date]" || Sl(t);
+}
+var wl = typeof Symbol == "function" && Symbol.for, El = wl ? Symbol.for("react.element") : 60103;
+function Sl(t) {
+ return t.$$typeof === El;
+}
+function Cl(t) {
+ return Array.isArray(t) ? [] : {};
+}
+function yt(t, e) {
+ return e.clone !== !1 && e.isMergeableObject(t) ? rt(Cl(t), t, e) : t;
+}
+function Al(t, e, n) {
+ return t.concat(e).map(function(i) {
+ return yt(i, n);
+ });
+}
+function xl(t, e) {
+ if (!e.customMerge)
+ return rt;
+ var n = e.customMerge(t);
+ return typeof n == "function" ? n : rt;
+}
+function Tl(t) {
+ return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(t).filter(function(e) {
+ return Object.propertyIsEnumerable.call(t, e);
+ }) : [];
+}
+function Li(t) {
+ return Object.keys(t).concat(Tl(t));
+}
+function br(t, e) {
+ try {
+ return e in t;
+ } catch {
+ return !1;
+ }
+}
+function Pl(t, e) {
+ return br(t, e) && !(Object.hasOwnProperty.call(t, e) && Object.propertyIsEnumerable.call(t, e));
+}
+function Rl(t, e, n) {
+ var i = {};
+ return n.isMergeableObject(t) && Li(t).forEach(function(r) {
+ i[r] = yt(t[r], n);
+ }), Li(e).forEach(function(r) {
+ Pl(t, r) || (br(t, r) && n.isMergeableObject(e[r]) ? i[r] = xl(r, n)(t[r], e[r], n) : i[r] = yt(e[r], n));
+ }), i;
+}
+function rt(t, e, n) {
+ n = n || {}, n.arrayMerge = n.arrayMerge || Al, n.isMergeableObject = n.isMergeableObject || bl, n.cloneUnlessOtherwiseSpecified = yt;
+ var i = Array.isArray(e), r = Array.isArray(t), s = i === r;
+ return s ? i ? n.arrayMerge(t, e, n) : Rl(t, e, n) : yt(e, n);
+}
+rt.all = function(e, n) {
+ if (!Array.isArray(e))
+ throw new Error("first argument should be an array");
+ return e.reduce(function(i, r) {
+ return rt(i, r, n);
+ }, {});
+};
+var kl = rt, Bl = kl;
+const Ll = /* @__PURE__ */ gl(Bl);
+var Pn = function(t, e) {
+ return Pn = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n, i) {
+ n.__proto__ = i;
+ } || function(n, i) {
+ for (var r in i)
+ Object.prototype.hasOwnProperty.call(i, r) && (n[r] = i[r]);
+ }, Pn(t, e);
+};
+function Jt(t, e) {
+ if (typeof e != "function" && e !== null)
+ throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
+ Pn(t, e);
+ function n() {
+ this.constructor = t;
+ }
+ t.prototype = e === null ? Object.create(e) : (n.prototype = e.prototype, new n());
+}
+var O = function() {
+ return O = Object.assign || function(e) {
+ for (var n, i = 1, r = arguments.length; i < r; i++) {
+ n = arguments[i];
+ for (var s in n)
+ Object.prototype.hasOwnProperty.call(n, s) && (e[s] = n[s]);
+ }
+ return e;
+ }, O.apply(this, arguments);
+};
+function pn(t, e, n) {
+ if (n || arguments.length === 2)
+ for (var i = 0, r = e.length, s; i < r; i++)
+ (s || !(i in e)) && (s || (s = Array.prototype.slice.call(e, 0, i)), s[i] = e[i]);
+ return t.concat(s || Array.prototype.slice.call(e));
+}
+var B;
+(function(t) {
+ t[t.EXPECT_ARGUMENT_CLOSING_BRACE = 1] = "EXPECT_ARGUMENT_CLOSING_BRACE", t[t.EMPTY_ARGUMENT = 2] = "EMPTY_ARGUMENT", t[t.MALFORMED_ARGUMENT = 3] = "MALFORMED_ARGUMENT", t[t.EXPECT_ARGUMENT_TYPE = 4] = "EXPECT_ARGUMENT_TYPE", t[t.INVALID_ARGUMENT_TYPE = 5] = "INVALID_ARGUMENT_TYPE", t[t.EXPECT_ARGUMENT_STYLE = 6] = "EXPECT_ARGUMENT_STYLE", t[t.INVALID_NUMBER_SKELETON = 7] = "INVALID_NUMBER_SKELETON", t[t.INVALID_DATE_TIME_SKELETON = 8] = "INVALID_DATE_TIME_SKELETON", t[t.EXPECT_NUMBER_SKELETON = 9] = "EXPECT_NUMBER_SKELETON", t[t.EXPECT_DATE_TIME_SKELETON = 10] = "EXPECT_DATE_TIME_SKELETON", t[t.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE = 11] = "UNCLOSED_QUOTE_IN_ARGUMENT_STYLE", t[t.EXPECT_SELECT_ARGUMENT_OPTIONS = 12] = "EXPECT_SELECT_ARGUMENT_OPTIONS", t[t.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE = 13] = "EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE", t[t.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE = 14] = "INVALID_PLURAL_ARGUMENT_OFFSET_VALUE", t[t.EXPECT_SELECT_ARGUMENT_SELECTOR = 15] = "EXPECT_SELECT_ARGUMENT_SELECTOR", t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR = 16] = "EXPECT_PLURAL_ARGUMENT_SELECTOR", t[t.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT = 17] = "EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT", t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT = 18] = "EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT", t[t.INVALID_PLURAL_ARGUMENT_SELECTOR = 19] = "INVALID_PLURAL_ARGUMENT_SELECTOR", t[t.DUPLICATE_PLURAL_ARGUMENT_SELECTOR = 20] = "DUPLICATE_PLURAL_ARGUMENT_SELECTOR", t[t.DUPLICATE_SELECT_ARGUMENT_SELECTOR = 21] = "DUPLICATE_SELECT_ARGUMENT_SELECTOR", t[t.MISSING_OTHER_CLAUSE = 22] = "MISSING_OTHER_CLAUSE", t[t.INVALID_TAG = 23] = "INVALID_TAG", t[t.INVALID_TAG_NAME = 25] = "INVALID_TAG_NAME", t[t.UNMATCHED_CLOSING_TAG = 26] = "UNMATCHED_CLOSING_TAG", t[t.UNCLOSED_TAG = 27] = "UNCLOSED_TAG";
+})(B || (B = {}));
+var F;
+(function(t) {
+ t[t.literal = 0] = "literal", t[t.argument = 1] = "argument", t[t.number = 2] = "number", t[t.date = 3] = "date", t[t.time = 4] = "time", t[t.select = 5] = "select", t[t.plural = 6] = "plural", t[t.pound = 7] = "pound", t[t.tag = 8] = "tag";
+})(F || (F = {}));
+var st;
+(function(t) {
+ t[t.number = 0] = "number", t[t.dateTime = 1] = "dateTime";
+})(st || (st = {}));
+function Di(t) {
+ return t.type === F.literal;
+}
+function Dl(t) {
+ return t.type === F.argument;
+}
+function vr(t) {
+ return t.type === F.number;
+}
+function yr(t) {
+ return t.type === F.date;
+}
+function wr(t) {
+ return t.type === F.time;
+}
+function Er(t) {
+ return t.type === F.select;
+}
+function Sr(t) {
+ return t.type === F.plural;
+}
+function Hl(t) {
+ return t.type === F.pound;
+}
+function Cr(t) {
+ return t.type === F.tag;
+}
+function Ar(t) {
+ return !!(t && typeof t == "object" && t.type === st.number);
+}
+function Rn(t) {
+ return !!(t && typeof t == "object" && t.type === st.dateTime);
+}
+var xr = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/, Ol = /(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;
+function Ml(t) {
+ var e = {};
+ return t.replace(Ol, function(n) {
+ var i = n.length;
+ switch (n[0]) {
+ case "G":
+ e.era = i === 4 ? "long" : i === 5 ? "narrow" : "short";
+ break;
+ case "y":
+ e.year = i === 2 ? "2-digit" : "numeric";
+ break;
+ case "Y":
+ case "u":
+ case "U":
+ case "r":
+ throw new RangeError("`Y/u/U/r` (year) patterns are not supported, use `y` instead");
+ case "q":
+ case "Q":
+ throw new RangeError("`q/Q` (quarter) patterns are not supported");
+ case "M":
+ case "L":
+ e.month = ["numeric", "2-digit", "short", "long", "narrow"][i - 1];
+ break;
+ case "w":
+ case "W":
+ throw new RangeError("`w/W` (week) patterns are not supported");
+ case "d":
+ e.day = ["numeric", "2-digit"][i - 1];
+ break;
+ case "D":
+ case "F":
+ case "g":
+ throw new RangeError("`D/F/g` (day) patterns are not supported, use `d` instead");
+ case "E":
+ e.weekday = i === 4 ? "short" : i === 5 ? "narrow" : "short";
+ break;
+ case "e":
+ if (i < 4)
+ throw new RangeError("`e..eee` (weekday) patterns are not supported");
+ e.weekday = ["short", "long", "narrow", "short"][i - 4];
+ break;
+ case "c":
+ if (i < 4)
+ throw new RangeError("`c..ccc` (weekday) patterns are not supported");
+ e.weekday = ["short", "long", "narrow", "short"][i - 4];
+ break;
+ case "a":
+ e.hour12 = !0;
+ break;
+ case "b":
+ case "B":
+ throw new RangeError("`b/B` (period) patterns are not supported, use `a` instead");
+ case "h":
+ e.hourCycle = "h12", e.hour = ["numeric", "2-digit"][i - 1];
+ break;
+ case "H":
+ e.hourCycle = "h23", e.hour = ["numeric", "2-digit"][i - 1];
+ break;
+ case "K":
+ e.hourCycle = "h11", e.hour = ["numeric", "2-digit"][i - 1];
+ break;
+ case "k":
+ e.hourCycle = "h24", e.hour = ["numeric", "2-digit"][i - 1];
+ break;
+ case "j":
+ case "J":
+ case "C":
+ throw new RangeError("`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead");
+ case "m":
+ e.minute = ["numeric", "2-digit"][i - 1];
+ break;
+ case "s":
+ e.second = ["numeric", "2-digit"][i - 1];
+ break;
+ case "S":
+ case "A":
+ throw new RangeError("`S/A` (second) patterns are not supported, use `s` instead");
+ case "z":
+ e.timeZoneName = i < 4 ? "short" : "long";
+ break;
+ case "Z":
+ case "O":
+ case "v":
+ case "V":
+ case "X":
+ case "x":
+ throw new RangeError("`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead");
+ }
+ return "";
+ }), e;
+}
+var Nl = /[\t-\r \x85\u200E\u200F\u2028\u2029]/i;
+function Il(t) {
+ if (t.length === 0)
+ throw new Error("Number skeleton cannot be empty");
+ for (var e = t.split(Nl).filter(function(h) {
+ return h.length > 0;
+ }), n = [], i = 0, r = e; i < r.length; i++) {
+ var s = r[i], o = s.split("/");
+ if (o.length === 0)
+ throw new Error("Invalid number skeleton");
+ for (var u = o[0], a = o.slice(1), c = 0, l = a; c < l.length; c++) {
+ var d = l[c];
+ if (d.length === 0)
+ throw new Error("Invalid number skeleton");
+ }
+ n.push({ stem: u, options: a });
+ }
+ return n;
+}
+function Ul(t) {
+ return t.replace(/^(.*?)-/, "");
+}
+var Hi = /^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g, Tr = /^(@+)?(\+|#+)?[rs]?$/g, Gl = /(\*)(0+)|(#+)(0+)|(0+)/g, Pr = /^(0+)$/;
+function Oi(t) {
+ var e = {};
+ return t[t.length - 1] === "r" ? e.roundingPriority = "morePrecision" : t[t.length - 1] === "s" && (e.roundingPriority = "lessPrecision"), t.replace(Tr, function(n, i, r) {
+ return typeof r != "string" ? (e.minimumSignificantDigits = i.length, e.maximumSignificantDigits = i.length) : r === "+" ? e.minimumSignificantDigits = i.length : i[0] === "#" ? e.maximumSignificantDigits = i.length : (e.minimumSignificantDigits = i.length, e.maximumSignificantDigits = i.length + (typeof r == "string" ? r.length : 0)), "";
+ }), e;
+}
+function Rr(t) {
+ switch (t) {
+ case "sign-auto":
+ return {
+ signDisplay: "auto"
+ };
+ case "sign-accounting":
+ case "()":
+ return {
+ currencySign: "accounting"
+ };
+ case "sign-always":
+ case "+!":
+ return {
+ signDisplay: "always"
+ };
+ case "sign-accounting-always":
+ case "()!":
+ return {
+ signDisplay: "always",
+ currencySign: "accounting"
+ };
+ case "sign-except-zero":
+ case "+?":
+ return {
+ signDisplay: "exceptZero"
+ };
+ case "sign-accounting-except-zero":
+ case "()?":
+ return {
+ signDisplay: "exceptZero",
+ currencySign: "accounting"
+ };
+ case "sign-never":
+ case "+_":
+ return {
+ signDisplay: "never"
+ };
+ }
+}
+function Fl(t) {
+ var e;
+ if (t[0] === "E" && t[1] === "E" ? (e = {
+ notation: "engineering"
+ }, t = t.slice(2)) : t[0] === "E" && (e = {
+ notation: "scientific"
+ }, t = t.slice(1)), e) {
+ var n = t.slice(0, 2);
+ if (n === "+!" ? (e.signDisplay = "always", t = t.slice(2)) : n === "+?" && (e.signDisplay = "exceptZero", t = t.slice(2)), !Pr.test(t))
+ throw new Error("Malformed concise eng/scientific notation");
+ e.minimumIntegerDigits = t.length;
+ }
+ return e;
+}
+function Mi(t) {
+ var e = {}, n = Rr(t);
+ return n || e;
+}
+function Wl(t) {
+ for (var e = {}, n = 0, i = t; n < i.length; n++) {
+ var r = i[n];
+ switch (r.stem) {
+ case "percent":
+ case "%":
+ e.style = "percent";
+ continue;
+ case "%x100":
+ e.style = "percent", e.scale = 100;
+ continue;
+ case "currency":
+ e.style = "currency", e.currency = r.options[0];
+ continue;
+ case "group-off":
+ case ",_":
+ e.useGrouping = !1;
+ continue;
+ case "precision-integer":
+ case ".":
+ e.maximumFractionDigits = 0;
+ continue;
+ case "measure-unit":
+ case "unit":
+ e.style = "unit", e.unit = Ul(r.options[0]);
+ continue;
+ case "compact-short":
+ case "K":
+ e.notation = "compact", e.compactDisplay = "short";
+ continue;
+ case "compact-long":
+ case "KK":
+ e.notation = "compact", e.compactDisplay = "long";
+ continue;
+ case "scientific":
+ e = O(O(O({}, e), { notation: "scientific" }), r.options.reduce(function(a, c) {
+ return O(O({}, a), Mi(c));
+ }, {}));
+ continue;
+ case "engineering":
+ e = O(O(O({}, e), { notation: "engineering" }), r.options.reduce(function(a, c) {
+ return O(O({}, a), Mi(c));
+ }, {}));
+ continue;
+ case "notation-simple":
+ e.notation = "standard";
+ continue;
+ case "unit-width-narrow":
+ e.currencyDisplay = "narrowSymbol", e.unitDisplay = "narrow";
+ continue;
+ case "unit-width-short":
+ e.currencyDisplay = "code", e.unitDisplay = "short";
+ continue;
+ case "unit-width-full-name":
+ e.currencyDisplay = "name", e.unitDisplay = "long";
+ continue;
+ case "unit-width-iso-code":
+ e.currencyDisplay = "symbol";
+ continue;
+ case "scale":
+ e.scale = parseFloat(r.options[0]);
+ continue;
+ case "integer-width":
+ if (r.options.length > 1)
+ throw new RangeError("integer-width stems only accept a single optional option");
+ r.options[0].replace(Gl, function(a, c, l, d, h, m) {
+ if (c)
+ e.minimumIntegerDigits = l.length;
+ else {
+ if (d && h)
+ throw new Error("We currently do not support maximum integer digits");
+ if (m)
+ throw new Error("We currently do not support exact integer digits");
+ }
+ return "";
+ });
+ continue;
+ }
+ if (Pr.test(r.stem)) {
+ e.minimumIntegerDigits = r.stem.length;
+ continue;
+ }
+ if (Hi.test(r.stem)) {
+ if (r.options.length > 1)
+ throw new RangeError("Fraction-precision stems only accept a single optional option");
+ r.stem.replace(Hi, function(a, c, l, d, h, m) {
+ return l === "*" ? e.minimumFractionDigits = c.length : d && d[0] === "#" ? e.maximumFractionDigits = d.length : h && m ? (e.minimumFractionDigits = h.length, e.maximumFractionDigits = h.length + m.length) : (e.minimumFractionDigits = c.length, e.maximumFractionDigits = c.length), "";
+ });
+ var s = r.options[0];
+ s === "w" ? e = O(O({}, e), { trailingZeroDisplay: "stripIfInteger" }) : s && (e = O(O({}, e), Oi(s)));
+ continue;
+ }
+ if (Tr.test(r.stem)) {
+ e = O(O({}, e), Oi(r.stem));
+ continue;
+ }
+ var o = Rr(r.stem);
+ o && (e = O(O({}, e), o));
+ var u = Fl(r.stem);
+ u && (e = O(O({}, e), u));
+ }
+ return e;
+}
+var Tt = {
+ AX: [
+ "H"
+ ],
+ BQ: [
+ "H"
+ ],
+ CP: [
+ "H"
+ ],
+ CZ: [
+ "H"
+ ],
+ DK: [
+ "H"
+ ],
+ FI: [
+ "H"
+ ],
+ ID: [
+ "H"
+ ],
+ IS: [
+ "H"
+ ],
+ ML: [
+ "H"
+ ],
+ NE: [
+ "H"
+ ],
+ RU: [
+ "H"
+ ],
+ SE: [
+ "H"
+ ],
+ SJ: [
+ "H"
+ ],
+ SK: [
+ "H"
+ ],
+ AS: [
+ "h",
+ "H"
+ ],
+ BT: [
+ "h",
+ "H"
+ ],
+ DJ: [
+ "h",
+ "H"
+ ],
+ ER: [
+ "h",
+ "H"
+ ],
+ GH: [
+ "h",
+ "H"
+ ],
+ IN: [
+ "h",
+ "H"
+ ],
+ LS: [
+ "h",
+ "H"
+ ],
+ PG: [
+ "h",
+ "H"
+ ],
+ PW: [
+ "h",
+ "H"
+ ],
+ SO: [
+ "h",
+ "H"
+ ],
+ TO: [
+ "h",
+ "H"
+ ],
+ VU: [
+ "h",
+ "H"
+ ],
+ WS: [
+ "h",
+ "H"
+ ],
+ "001": [
+ "H",
+ "h"
+ ],
+ AL: [
+ "h",
+ "H",
+ "hB"
+ ],
+ TD: [
+ "h",
+ "H",
+ "hB"
+ ],
+ "ca-ES": [
+ "H",
+ "h",
+ "hB"
+ ],
+ CF: [
+ "H",
+ "h",
+ "hB"
+ ],
+ CM: [
+ "H",
+ "h",
+ "hB"
+ ],
+ "fr-CA": [
+ "H",
+ "h",
+ "hB"
+ ],
+ "gl-ES": [
+ "H",
+ "h",
+ "hB"
+ ],
+ "it-CH": [
+ "H",
+ "h",
+ "hB"
+ ],
+ "it-IT": [
+ "H",
+ "h",
+ "hB"
+ ],
+ LU: [
+ "H",
+ "h",
+ "hB"
+ ],
+ NP: [
+ "H",
+ "h",
+ "hB"
+ ],
+ PF: [
+ "H",
+ "h",
+ "hB"
+ ],
+ SC: [
+ "H",
+ "h",
+ "hB"
+ ],
+ SM: [
+ "H",
+ "h",
+ "hB"
+ ],
+ SN: [
+ "H",
+ "h",
+ "hB"
+ ],
+ TF: [
+ "H",
+ "h",
+ "hB"
+ ],
+ VA: [
+ "H",
+ "h",
+ "hB"
+ ],
+ CY: [
+ "h",
+ "H",
+ "hb",
+ "hB"
+ ],
+ GR: [
+ "h",
+ "H",
+ "hb",
+ "hB"
+ ],
+ CO: [
+ "h",
+ "H",
+ "hB",
+ "hb"
+ ],
+ DO: [
+ "h",
+ "H",
+ "hB",
+ "hb"
+ ],
+ KP: [
+ "h",
+ "H",
+ "hB",
+ "hb"
+ ],
+ KR: [
+ "h",
+ "H",
+ "hB",
+ "hb"
+ ],
+ NA: [
+ "h",
+ "H",
+ "hB",
+ "hb"
+ ],
+ PA: [
+ "h",
+ "H",
+ "hB",
+ "hb"
+ ],
+ PR: [
+ "h",
+ "H",
+ "hB",
+ "hb"
+ ],
+ VE: [
+ "h",
+ "H",
+ "hB",
+ "hb"
+ ],
+ AC: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ AI: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ BW: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ BZ: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ CC: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ CK: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ CX: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ DG: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ FK: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ GB: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ GG: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ GI: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ IE: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ IM: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ IO: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ JE: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ LT: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ MK: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ MN: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ MS: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ NF: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ NG: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ NR: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ NU: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ PN: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ SH: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ SX: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ TA: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ ZA: [
+ "H",
+ "h",
+ "hb",
+ "hB"
+ ],
+ "af-ZA": [
+ "H",
+ "h",
+ "hB",
+ "hb"
+ ],
+ AR: [
+ "H",
+ "h",
+ "hB",
+ "hb"
+ ],
+ CL: [
+ "H",
+ "h",
+ "hB",
+ "hb"
+ ],
+ CR: [
+ "H",
+ "h",
+ "hB",
+ "hb"
+ ],
+ CU: [
+ "H",
+ "h",
+ "hB",
+ "hb"
+ ],
+ EA: [
+ "H",
+ "h",
+ "hB",
+ "hb"
+ ],
+ "es-BO": [
+ "H",
+ "h",
+ "hB",
+ "hb"
+ ],
+ "es-BR": [
+ "H",
+ "h",
+ "hB",
+ "hb"
+ ],
+ "es-EC": [
+ "H",
+ "h",
+ "hB",
+ "hb"
+ ],
+ "es-ES": [
+ "H",
+ "h",
+ "hB",
+ "hb"
+ ],
+ "es-GQ": [
+ "H",
+ "h",
+ "hB",
+ "hb"
+ ],
+ "es-PE": [
+ "H",
+ "h",
+ "hB",
+ "hb"
+ ],
+ GT: [
+ "H",
+ "h",
+ "hB",
+ "hb"
+ ],
+ HN: [
+ "H",
+ "h",
+ "hB",
+ "hb"
+ ],
+ IC: [
+ "H",
+ "h",
+ "hB",
+ "hb"
+ ],
+ KG: [
+ "H",
+ "h",
+ "hB",
+ "hb"
+ ],
+ KM: [
+ "H",
+ "h",
+ "hB",
+ "hb"
+ ],
+ LK: [
+ "H",
+ "h",
+ "hB",
+ "hb"
+ ],
+ MA: [
+ "H",
+ "h",
+ "hB",
+ "hb"
+ ],
+ MX: [
+ "H",
+ "h",
+ "hB",
+ "hb"
+ ],
+ NI: [
+ "H",
+ "h",
+ "hB",
+ "hb"
+ ],
+ PY: [
+ "H",
+ "h",
+ "hB",
+ "hb"
+ ],
+ SV: [
+ "H",
+ "h",
+ "hB",
+ "hb"
+ ],
+ UY: [
+ "H",
+ "h",
+ "hB",
+ "hb"
+ ],
+ JP: [
+ "H",
+ "h",
+ "K"
+ ],
+ AD: [
+ "H",
+ "hB"
+ ],
+ AM: [
+ "H",
+ "hB"
+ ],
+ AO: [
+ "H",
+ "hB"
+ ],
+ AT: [
+ "H",
+ "hB"
+ ],
+ AW: [
+ "H",
+ "hB"
+ ],
+ BE: [
+ "H",
+ "hB"
+ ],
+ BF: [
+ "H",
+ "hB"
+ ],
+ BJ: [
+ "H",
+ "hB"
+ ],
+ BL: [
+ "H",
+ "hB"
+ ],
+ BR: [
+ "H",
+ "hB"
+ ],
+ CG: [
+ "H",
+ "hB"
+ ],
+ CI: [
+ "H",
+ "hB"
+ ],
+ CV: [
+ "H",
+ "hB"
+ ],
+ DE: [
+ "H",
+ "hB"
+ ],
+ EE: [
+ "H",
+ "hB"
+ ],
+ FR: [
+ "H",
+ "hB"
+ ],
+ GA: [
+ "H",
+ "hB"
+ ],
+ GF: [
+ "H",
+ "hB"
+ ],
+ GN: [
+ "H",
+ "hB"
+ ],
+ GP: [
+ "H",
+ "hB"
+ ],
+ GW: [
+ "H",
+ "hB"
+ ],
+ HR: [
+ "H",
+ "hB"
+ ],
+ IL: [
+ "H",
+ "hB"
+ ],
+ IT: [
+ "H",
+ "hB"
+ ],
+ KZ: [
+ "H",
+ "hB"
+ ],
+ MC: [
+ "H",
+ "hB"
+ ],
+ MD: [
+ "H",
+ "hB"
+ ],
+ MF: [
+ "H",
+ "hB"
+ ],
+ MQ: [
+ "H",
+ "hB"
+ ],
+ MZ: [
+ "H",
+ "hB"
+ ],
+ NC: [
+ "H",
+ "hB"
+ ],
+ NL: [
+ "H",
+ "hB"
+ ],
+ PM: [
+ "H",
+ "hB"
+ ],
+ PT: [
+ "H",
+ "hB"
+ ],
+ RE: [
+ "H",
+ "hB"
+ ],
+ RO: [
+ "H",
+ "hB"
+ ],
+ SI: [
+ "H",
+ "hB"
+ ],
+ SR: [
+ "H",
+ "hB"
+ ],
+ ST: [
+ "H",
+ "hB"
+ ],
+ TG: [
+ "H",
+ "hB"
+ ],
+ TR: [
+ "H",
+ "hB"
+ ],
+ WF: [
+ "H",
+ "hB"
+ ],
+ YT: [
+ "H",
+ "hB"
+ ],
+ BD: [
+ "h",
+ "hB",
+ "H"
+ ],
+ PK: [
+ "h",
+ "hB",
+ "H"
+ ],
+ AZ: [
+ "H",
+ "hB",
+ "h"
+ ],
+ BA: [
+ "H",
+ "hB",
+ "h"
+ ],
+ BG: [
+ "H",
+ "hB",
+ "h"
+ ],
+ CH: [
+ "H",
+ "hB",
+ "h"
+ ],
+ GE: [
+ "H",
+ "hB",
+ "h"
+ ],
+ LI: [
+ "H",
+ "hB",
+ "h"
+ ],
+ ME: [
+ "H",
+ "hB",
+ "h"
+ ],
+ RS: [
+ "H",
+ "hB",
+ "h"
+ ],
+ UA: [
+ "H",
+ "hB",
+ "h"
+ ],
+ UZ: [
+ "H",
+ "hB",
+ "h"
+ ],
+ XK: [
+ "H",
+ "hB",
+ "h"
+ ],
+ AG: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ AU: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ BB: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ BM: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ BS: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ CA: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ DM: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ "en-001": [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ FJ: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ FM: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ GD: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ GM: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ GU: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ GY: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ JM: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ KI: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ KN: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ KY: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ LC: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ LR: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ MH: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ MP: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ MW: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ NZ: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ SB: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ SG: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ SL: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ SS: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ SZ: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ TC: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ TT: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ UM: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ US: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ VC: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ VG: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ VI: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ ZM: [
+ "h",
+ "hb",
+ "H",
+ "hB"
+ ],
+ BO: [
+ "H",
+ "hB",
+ "h",
+ "hb"
+ ],
+ EC: [
+ "H",
+ "hB",
+ "h",
+ "hb"
+ ],
+ ES: [
+ "H",
+ "hB",
+ "h",
+ "hb"
+ ],
+ GQ: [
+ "H",
+ "hB",
+ "h",
+ "hb"
+ ],
+ PE: [
+ "H",
+ "hB",
+ "h",
+ "hb"
+ ],
+ AE: [
+ "h",
+ "hB",
+ "hb",
+ "H"
+ ],
+ "ar-001": [
+ "h",
+ "hB",
+ "hb",
+ "H"
+ ],
+ BH: [
+ "h",
+ "hB",
+ "hb",
+ "H"
+ ],
+ DZ: [
+ "h",
+ "hB",
+ "hb",
+ "H"
+ ],
+ EG: [
+ "h",
+ "hB",
+ "hb",
+ "H"
+ ],
+ EH: [
+ "h",
+ "hB",
+ "hb",
+ "H"
+ ],
+ HK: [
+ "h",
+ "hB",
+ "hb",
+ "H"
+ ],
+ IQ: [
+ "h",
+ "hB",
+ "hb",
+ "H"
+ ],
+ JO: [
+ "h",
+ "hB",
+ "hb",
+ "H"
+ ],
+ KW: [
+ "h",
+ "hB",
+ "hb",
+ "H"
+ ],
+ LB: [
+ "h",
+ "hB",
+ "hb",
+ "H"
+ ],
+ LY: [
+ "h",
+ "hB",
+ "hb",
+ "H"
+ ],
+ MO: [
+ "h",
+ "hB",
+ "hb",
+ "H"
+ ],
+ MR: [
+ "h",
+ "hB",
+ "hb",
+ "H"
+ ],
+ OM: [
+ "h",
+ "hB",
+ "hb",
+ "H"
+ ],
+ PH: [
+ "h",
+ "hB",
+ "hb",
+ "H"
+ ],
+ PS: [
+ "h",
+ "hB",
+ "hb",
+ "H"
+ ],
+ QA: [
+ "h",
+ "hB",
+ "hb",
+ "H"
+ ],
+ SA: [
+ "h",
+ "hB",
+ "hb",
+ "H"
+ ],
+ SD: [
+ "h",
+ "hB",
+ "hb",
+ "H"
+ ],
+ SY: [
+ "h",
+ "hB",
+ "hb",
+ "H"
+ ],
+ TN: [
+ "h",
+ "hB",
+ "hb",
+ "H"
+ ],
+ YE: [
+ "h",
+ "hB",
+ "hb",
+ "H"
+ ],
+ AF: [
+ "H",
+ "hb",
+ "hB",
+ "h"
+ ],
+ LA: [
+ "H",
+ "hb",
+ "hB",
+ "h"
+ ],
+ CN: [
+ "H",
+ "hB",
+ "hb",
+ "h"
+ ],
+ LV: [
+ "H",
+ "hB",
+ "hb",
+ "h"
+ ],
+ TL: [
+ "H",
+ "hB",
+ "hb",
+ "h"
+ ],
+ "zu-ZA": [
+ "H",
+ "hB",
+ "hb",
+ "h"
+ ],
+ CD: [
+ "hB",
+ "H"
+ ],
+ IR: [
+ "hB",
+ "H"
+ ],
+ "hi-IN": [
+ "hB",
+ "h",
+ "H"
+ ],
+ "kn-IN": [
+ "hB",
+ "h",
+ "H"
+ ],
+ "ml-IN": [
+ "hB",
+ "h",
+ "H"
+ ],
+ "te-IN": [
+ "hB",
+ "h",
+ "H"
+ ],
+ KH: [
+ "hB",
+ "h",
+ "H",
+ "hb"
+ ],
+ "ta-IN": [
+ "hB",
+ "h",
+ "hb",
+ "H"
+ ],
+ BN: [
+ "hb",
+ "hB",
+ "h",
+ "H"
+ ],
+ MY: [
+ "hb",
+ "hB",
+ "h",
+ "H"
+ ],
+ ET: [
+ "hB",
+ "hb",
+ "h",
+ "H"
+ ],
+ "gu-IN": [
+ "hB",
+ "hb",
+ "h",
+ "H"
+ ],
+ "mr-IN": [
+ "hB",
+ "hb",
+ "h",
+ "H"
+ ],
+ "pa-IN": [
+ "hB",
+ "hb",
+ "h",
+ "H"
+ ],
+ TW: [
+ "hB",
+ "hb",
+ "h",
+ "H"
+ ],
+ KE: [
+ "hB",
+ "hb",
+ "H",
+ "h"
+ ],
+ MM: [
+ "hB",
+ "hb",
+ "H",
+ "h"
+ ],
+ TZ: [
+ "hB",
+ "hb",
+ "H",
+ "h"
+ ],
+ UG: [
+ "hB",
+ "hb",
+ "H",
+ "h"
+ ]
+};
+function jl(t, e) {
+ for (var n = "", i = 0; i < t.length; i++) {
+ var r = t.charAt(i);
+ if (r === "j") {
+ for (var s = 0; i + 1 < t.length && t.charAt(i + 1) === r; )
+ s++, i++;
+ var o = 1 + (s & 1), u = s < 2 ? 1 : 3 + (s >> 1), a = "a", c = zl(e);
+ for ((c == "H" || c == "k") && (u = 0); u-- > 0; )
+ n += a;
+ for (; o-- > 0; )
+ n = c + n;
+ } else
+ r === "J" ? n += "H" : n += r;
+ }
+ return n;
+}
+function zl(t) {
+ var e = t.hourCycle;
+ if (e === void 0 && // @ts-ignore hourCycle(s) is not identified yet
+ t.hourCycles && // @ts-ignore
+ t.hourCycles.length && (e = t.hourCycles[0]), e)
+ switch (e) {
+ case "h24":
+ return "k";
+ case "h23":
+ return "H";
+ case "h12":
+ return "h";
+ case "h11":
+ return "K";
+ default:
+ throw new Error("Invalid hourCycle");
+ }
+ var n = t.language, i;
+ n !== "root" && (i = t.maximize().region);
+ var r = Tt[i || ""] || Tt[n || ""] || Tt["".concat(n, "-001")] || Tt["001"];
+ return r[0];
+}
+var _n, ql = new RegExp("^".concat(xr.source, "*")), Vl = new RegExp("".concat(xr.source, "*$"));
+function L(t, e) {
+ return { start: t, end: e };
+}
+var Xl = !!String.prototype.startsWith, Zl = !!String.fromCodePoint, Jl = !!Object.fromEntries, Ql = !!String.prototype.codePointAt, Yl = !!String.prototype.trimStart, Kl = !!String.prototype.trimEnd, $l = !!Number.isSafeInteger, eu = $l ? Number.isSafeInteger : function(t) {
+ return typeof t == "number" && isFinite(t) && Math.floor(t) === t && Math.abs(t) <= 9007199254740991;
+}, kn = !0;
+try {
+ var tu = Br("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
+ kn = ((_n = tu.exec("a")) === null || _n === void 0 ? void 0 : _n[0]) === "a";
+} catch {
+ kn = !1;
+}
+var Ni = Xl ? (
+ // Native
+ function(e, n, i) {
+ return e.startsWith(n, i);
+ }
+) : (
+ // For IE11
+ function(e, n, i) {
+ return e.slice(i, i + n.length) === n;
+ }
+), Bn = Zl ? String.fromCodePoint : (
+ // IE11
+ function() {
+ for (var e = [], n = 0; n < arguments.length; n++)
+ e[n] = arguments[n];
+ for (var i = "", r = e.length, s = 0, o; r > s; ) {
+ if (o = e[s++], o > 1114111)
+ throw RangeError(o + " is not a valid code point");
+ i += o < 65536 ? String.fromCharCode(o) : String.fromCharCode(((o -= 65536) >> 10) + 55296, o % 1024 + 56320);
+ }
+ return i;
+ }
+), Ii = (
+ // native
+ Jl ? Object.fromEntries : (
+ // Ponyfill
+ function(e) {
+ for (var n = {}, i = 0, r = e; i < r.length; i++) {
+ var s = r[i], o = s[0], u = s[1];
+ n[o] = u;
+ }
+ return n;
+ }
+ )
+), kr = Ql ? (
+ // Native
+ function(e, n) {
+ return e.codePointAt(n);
+ }
+) : (
+ // IE 11
+ function(e, n) {
+ var i = e.length;
+ if (!(n < 0 || n >= i)) {
+ var r = e.charCodeAt(n), s;
+ return r < 55296 || r > 56319 || n + 1 === i || (s = e.charCodeAt(n + 1)) < 56320 || s > 57343 ? r : (r - 55296 << 10) + (s - 56320) + 65536;
+ }
+ }
+), nu = Yl ? (
+ // Native
+ function(e) {
+ return e.trimStart();
+ }
+) : (
+ // Ponyfill
+ function(e) {
+ return e.replace(ql, "");
+ }
+), iu = Kl ? (
+ // Native
+ function(e) {
+ return e.trimEnd();
+ }
+) : (
+ // Ponyfill
+ function(e) {
+ return e.replace(Vl, "");
+ }
+);
+function Br(t, e) {
+ return new RegExp(t, e);
+}
+var Ln;
+if (kn) {
+ var Ui = Br("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
+ Ln = function(e, n) {
+ var i;
+ Ui.lastIndex = n;
+ var r = Ui.exec(e);
+ return (i = r[1]) !== null && i !== void 0 ? i : "";
+ };
+} else
+ Ln = function(e, n) {
+ for (var i = []; ; ) {
+ var r = kr(e, n);
+ if (r === void 0 || Lr(r) || au(r))
+ break;
+ i.push(r), n += r >= 65536 ? 2 : 1;
+ }
+ return Bn.apply(void 0, i);
+ };
+var ru = (
+ /** @class */
+ function() {
+ function t(e, n) {
+ n === void 0 && (n = {}), this.message = e, this.position = { offset: 0, line: 1, column: 1 }, this.ignoreTag = !!n.ignoreTag, this.locale = n.locale, this.requiresOtherClause = !!n.requiresOtherClause, this.shouldParseSkeletons = !!n.shouldParseSkeletons;
+ }
+ return t.prototype.parse = function() {
+ if (this.offset() !== 0)
+ throw Error("parser can only be used once");
+ return this.parseMessage(0, "", !1);
+ }, t.prototype.parseMessage = function(e, n, i) {
+ for (var r = []; !this.isEOF(); ) {
+ var s = this.char();
+ if (s === 123) {
+ var o = this.parseArgument(e, i);
+ if (o.err)
+ return o;
+ r.push(o.val);
+ } else {
+ if (s === 125 && e > 0)
+ break;
+ if (s === 35 && (n === "plural" || n === "selectordinal")) {
+ var u = this.clonePosition();
+ this.bump(), r.push({
+ type: F.pound,
+ location: L(u, this.clonePosition())
+ });
+ } else if (s === 60 && !this.ignoreTag && this.peek() === 47) {
+ if (i)
+ break;
+ return this.error(B.UNMATCHED_CLOSING_TAG, L(this.clonePosition(), this.clonePosition()));
+ } else if (s === 60 && !this.ignoreTag && Dn(this.peek() || 0)) {
+ var o = this.parseTag(e, n);
+ if (o.err)
+ return o;
+ r.push(o.val);
+ } else {
+ var o = this.parseLiteral(e, n);
+ if (o.err)
+ return o;
+ r.push(o.val);
+ }
+ }
+ }
+ return { val: r, err: null };
+ }, t.prototype.parseTag = function(e, n) {
+ var i = this.clonePosition();
+ this.bump();
+ var r = this.parseTagName();
+ if (this.bumpSpace(), this.bumpIf("/>"))
+ return {
+ val: {
+ type: F.literal,
+ value: "<".concat(r, "/>"),
+ location: L(i, this.clonePosition())
+ },
+ err: null
+ };
+ if (this.bumpIf(">")) {
+ var s = this.parseMessage(e + 1, n, !0);
+ if (s.err)
+ return s;
+ var o = s.val, u = this.clonePosition();
+ if (this.bumpIf("")) {
+ if (this.isEOF() || !Dn(this.char()))
+ return this.error(B.INVALID_TAG, L(u, this.clonePosition()));
+ var a = this.clonePosition(), c = this.parseTagName();
+ return r !== c ? this.error(B.UNMATCHED_CLOSING_TAG, L(a, this.clonePosition())) : (this.bumpSpace(), this.bumpIf(">") ? {
+ val: {
+ type: F.tag,
+ value: r,
+ children: o,
+ location: L(i, this.clonePosition())
+ },
+ err: null
+ } : this.error(B.INVALID_TAG, L(u, this.clonePosition())));
+ } else
+ return this.error(B.UNCLOSED_TAG, L(i, this.clonePosition()));
+ } else
+ return this.error(B.INVALID_TAG, L(i, this.clonePosition()));
+ }, t.prototype.parseTagName = function() {
+ var e = this.offset();
+ for (this.bump(); !this.isEOF() && ou(this.char()); )
+ this.bump();
+ return this.message.slice(e, this.offset());
+ }, t.prototype.parseLiteral = function(e, n) {
+ for (var i = this.clonePosition(), r = ""; ; ) {
+ var s = this.tryParseQuote(n);
+ if (s) {
+ r += s;
+ continue;
+ }
+ var o = this.tryParseUnquoted(e, n);
+ if (o) {
+ r += o;
+ continue;
+ }
+ var u = this.tryParseLeftAngleBracket();
+ if (u) {
+ r += u;
+ continue;
+ }
+ break;
+ }
+ var a = L(i, this.clonePosition());
+ return {
+ val: { type: F.literal, value: r, location: a },
+ err: null
+ };
+ }, t.prototype.tryParseLeftAngleBracket = function() {
+ return !this.isEOF() && this.char() === 60 && (this.ignoreTag || // If at the opening tag or closing tag position, bail.
+ !su(this.peek() || 0)) ? (this.bump(), "<") : null;
+ }, t.prototype.tryParseQuote = function(e) {
+ if (this.isEOF() || this.char() !== 39)
+ return null;
+ switch (this.peek()) {
+ case 39:
+ return this.bump(), this.bump(), "'";
+ case 123:
+ case 60:
+ case 62:
+ case 125:
+ break;
+ case 35:
+ if (e === "plural" || e === "selectordinal")
+ break;
+ return null;
+ default:
+ return null;
+ }
+ this.bump();
+ var n = [this.char()];
+ for (this.bump(); !this.isEOF(); ) {
+ var i = this.char();
+ if (i === 39)
+ if (this.peek() === 39)
+ n.push(39), this.bump();
+ else {
+ this.bump();
+ break;
+ }
+ else
+ n.push(i);
+ this.bump();
+ }
+ return Bn.apply(void 0, n);
+ }, t.prototype.tryParseUnquoted = function(e, n) {
+ if (this.isEOF())
+ return null;
+ var i = this.char();
+ return i === 60 || i === 123 || i === 35 && (n === "plural" || n === "selectordinal") || i === 125 && e > 0 ? null : (this.bump(), Bn(i));
+ }, t.prototype.parseArgument = function(e, n) {
+ var i = this.clonePosition();
+ if (this.bump(), this.bumpSpace(), this.isEOF())
+ return this.error(B.EXPECT_ARGUMENT_CLOSING_BRACE, L(i, this.clonePosition()));
+ if (this.char() === 125)
+ return this.bump(), this.error(B.EMPTY_ARGUMENT, L(i, this.clonePosition()));
+ var r = this.parseIdentifierIfPossible().value;
+ if (!r)
+ return this.error(B.MALFORMED_ARGUMENT, L(i, this.clonePosition()));
+ if (this.bumpSpace(), this.isEOF())
+ return this.error(B.EXPECT_ARGUMENT_CLOSING_BRACE, L(i, this.clonePosition()));
+ switch (this.char()) {
+ case 125:
+ return this.bump(), {
+ val: {
+ type: F.argument,
+ // value does not include the opening and closing braces.
+ value: r,
+ location: L(i, this.clonePosition())
+ },
+ err: null
+ };
+ case 44:
+ return this.bump(), this.bumpSpace(), this.isEOF() ? this.error(B.EXPECT_ARGUMENT_CLOSING_BRACE, L(i, this.clonePosition())) : this.parseArgumentOptions(e, n, r, i);
+ default:
+ return this.error(B.MALFORMED_ARGUMENT, L(i, this.clonePosition()));
+ }
+ }, t.prototype.parseIdentifierIfPossible = function() {
+ var e = this.clonePosition(), n = this.offset(), i = Ln(this.message, n), r = n + i.length;
+ this.bumpTo(r);
+ var s = this.clonePosition(), o = L(e, s);
+ return { value: i, location: o };
+ }, t.prototype.parseArgumentOptions = function(e, n, i, r) {
+ var s, o = this.clonePosition(), u = this.parseIdentifierIfPossible().value, a = this.clonePosition();
+ switch (u) {
+ case "":
+ return this.error(B.EXPECT_ARGUMENT_TYPE, L(o, a));
+ case "number":
+ case "date":
+ case "time": {
+ this.bumpSpace();
+ var c = null;
+ if (this.bumpIf(",")) {
+ this.bumpSpace();
+ var l = this.clonePosition(), d = this.parseSimpleArgStyleIfPossible();
+ if (d.err)
+ return d;
+ var h = iu(d.val);
+ if (h.length === 0)
+ return this.error(B.EXPECT_ARGUMENT_STYLE, L(this.clonePosition(), this.clonePosition()));
+ var m = L(l, this.clonePosition());
+ c = { style: h, styleLocation: m };
+ }
+ var p = this.tryParseArgumentClose(r);
+ if (p.err)
+ return p;
+ var g = L(r, this.clonePosition());
+ if (c && Ni(c == null ? void 0 : c.style, "::", 0)) {
+ var y = nu(c.style.slice(2));
+ if (u === "number") {
+ var d = this.parseNumberSkeletonFromString(y, c.styleLocation);
+ return d.err ? d : {
+ val: { type: F.number, value: i, location: g, style: d.val },
+ err: null
+ };
+ } else {
+ if (y.length === 0)
+ return this.error(B.EXPECT_DATE_TIME_SKELETON, g);
+ var w = y;
+ this.locale && (w = jl(y, this.locale));
+ var h = {
+ type: st.dateTime,
+ pattern: w,
+ location: c.styleLocation,
+ parsedOptions: this.shouldParseSkeletons ? Ml(w) : {}
+ }, b = u === "date" ? F.date : F.time;
+ return {
+ val: { type: b, value: i, location: g, style: h },
+ err: null
+ };
+ }
+ }
+ return {
+ val: {
+ type: u === "number" ? F.number : u === "date" ? F.date : F.time,
+ value: i,
+ location: g,
+ style: (s = c == null ? void 0 : c.style) !== null && s !== void 0 ? s : null
+ },
+ err: null
+ };
+ }
+ case "plural":
+ case "selectordinal":
+ case "select": {
+ var T = this.clonePosition();
+ if (this.bumpSpace(), !this.bumpIf(","))
+ return this.error(B.EXPECT_SELECT_ARGUMENT_OPTIONS, L(T, O({}, T)));
+ this.bumpSpace();
+ var A = this.parseIdentifierIfPossible(), k = 0;
+ if (u !== "select" && A.value === "offset") {
+ if (!this.bumpIf(":"))
+ return this.error(B.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, L(this.clonePosition(), this.clonePosition()));
+ this.bumpSpace();
+ var d = this.tryParseDecimalInteger(B.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, B.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);
+ if (d.err)
+ return d;
+ this.bumpSpace(), A = this.parseIdentifierIfPossible(), k = d.val;
+ }
+ var x = this.tryParsePluralOrSelectOptions(e, u, n, A);
+ if (x.err)
+ return x;
+ var p = this.tryParseArgumentClose(r);
+ if (p.err)
+ return p;
+ var M = L(r, this.clonePosition());
+ return u === "select" ? {
+ val: {
+ type: F.select,
+ value: i,
+ options: Ii(x.val),
+ location: M
+ },
+ err: null
+ } : {
+ val: {
+ type: F.plural,
+ value: i,
+ options: Ii(x.val),
+ offset: k,
+ pluralType: u === "plural" ? "cardinal" : "ordinal",
+ location: M
+ },
+ err: null
+ };
+ }
+ default:
+ return this.error(B.INVALID_ARGUMENT_TYPE, L(o, a));
+ }
+ }, t.prototype.tryParseArgumentClose = function(e) {
+ return this.isEOF() || this.char() !== 125 ? this.error(B.EXPECT_ARGUMENT_CLOSING_BRACE, L(e, this.clonePosition())) : (this.bump(), { val: !0, err: null });
+ }, t.prototype.parseSimpleArgStyleIfPossible = function() {
+ for (var e = 0, n = this.clonePosition(); !this.isEOF(); ) {
+ var i = this.char();
+ switch (i) {
+ case 39: {
+ this.bump();
+ var r = this.clonePosition();
+ if (!this.bumpUntil("'"))
+ return this.error(B.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE, L(r, this.clonePosition()));
+ this.bump();
+ break;
+ }
+ case 123: {
+ e += 1, this.bump();
+ break;
+ }
+ case 125: {
+ if (e > 0)
+ e -= 1;
+ else
+ return {
+ val: this.message.slice(n.offset, this.offset()),
+ err: null
+ };
+ break;
+ }
+ default:
+ this.bump();
+ break;
+ }
+ }
+ return {
+ val: this.message.slice(n.offset, this.offset()),
+ err: null
+ };
+ }, t.prototype.parseNumberSkeletonFromString = function(e, n) {
+ var i = [];
+ try {
+ i = Il(e);
+ } catch {
+ return this.error(B.INVALID_NUMBER_SKELETON, n);
+ }
+ return {
+ val: {
+ type: st.number,
+ tokens: i,
+ location: n,
+ parsedOptions: this.shouldParseSkeletons ? Wl(i) : {}
+ },
+ err: null
+ };
+ }, t.prototype.tryParsePluralOrSelectOptions = function(e, n, i, r) {
+ for (var s, o = !1, u = [], a = /* @__PURE__ */ new Set(), c = r.value, l = r.location; ; ) {
+ if (c.length === 0) {
+ var d = this.clonePosition();
+ if (n !== "select" && this.bumpIf("=")) {
+ var h = this.tryParseDecimalInteger(B.EXPECT_PLURAL_ARGUMENT_SELECTOR, B.INVALID_PLURAL_ARGUMENT_SELECTOR);
+ if (h.err)
+ return h;
+ l = L(d, this.clonePosition()), c = this.message.slice(d.offset, this.offset());
+ } else
+ break;
+ }
+ if (a.has(c))
+ return this.error(n === "select" ? B.DUPLICATE_SELECT_ARGUMENT_SELECTOR : B.DUPLICATE_PLURAL_ARGUMENT_SELECTOR, l);
+ c === "other" && (o = !0), this.bumpSpace();
+ var m = this.clonePosition();
+ if (!this.bumpIf("{"))
+ return this.error(n === "select" ? B.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT : B.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT, L(this.clonePosition(), this.clonePosition()));
+ var p = this.parseMessage(e + 1, n, i);
+ if (p.err)
+ return p;
+ var g = this.tryParseArgumentClose(m);
+ if (g.err)
+ return g;
+ u.push([
+ c,
+ {
+ value: p.val,
+ location: L(m, this.clonePosition())
+ }
+ ]), a.add(c), this.bumpSpace(), s = this.parseIdentifierIfPossible(), c = s.value, l = s.location;
+ }
+ return u.length === 0 ? this.error(n === "select" ? B.EXPECT_SELECT_ARGUMENT_SELECTOR : B.EXPECT_PLURAL_ARGUMENT_SELECTOR, L(this.clonePosition(), this.clonePosition())) : this.requiresOtherClause && !o ? this.error(B.MISSING_OTHER_CLAUSE, L(this.clonePosition(), this.clonePosition())) : { val: u, err: null };
+ }, t.prototype.tryParseDecimalInteger = function(e, n) {
+ var i = 1, r = this.clonePosition();
+ this.bumpIf("+") || this.bumpIf("-") && (i = -1);
+ for (var s = !1, o = 0; !this.isEOF(); ) {
+ var u = this.char();
+ if (u >= 48 && u <= 57)
+ s = !0, o = o * 10 + (u - 48), this.bump();
+ else
+ break;
+ }
+ var a = L(r, this.clonePosition());
+ return s ? (o *= i, eu(o) ? { val: o, err: null } : this.error(n, a)) : this.error(e, a);
+ }, t.prototype.offset = function() {
+ return this.position.offset;
+ }, t.prototype.isEOF = function() {
+ return this.offset() === this.message.length;
+ }, t.prototype.clonePosition = function() {
+ return {
+ offset: this.position.offset,
+ line: this.position.line,
+ column: this.position.column
+ };
+ }, t.prototype.char = function() {
+ var e = this.position.offset;
+ if (e >= this.message.length)
+ throw Error("out of bound");
+ var n = kr(this.message, e);
+ if (n === void 0)
+ throw Error("Offset ".concat(e, " is at invalid UTF-16 code unit boundary"));
+ return n;
+ }, t.prototype.error = function(e, n) {
+ return {
+ val: null,
+ err: {
+ kind: e,
+ message: this.message,
+ location: n
+ }
+ };
+ }, t.prototype.bump = function() {
+ if (!this.isEOF()) {
+ var e = this.char();
+ e === 10 ? (this.position.line += 1, this.position.column = 1, this.position.offset += 1) : (this.position.column += 1, this.position.offset += e < 65536 ? 1 : 2);
+ }
+ }, t.prototype.bumpIf = function(e) {
+ if (Ni(this.message, e, this.offset())) {
+ for (var n = 0; n < e.length; n++)
+ this.bump();
+ return !0;
+ }
+ return !1;
+ }, t.prototype.bumpUntil = function(e) {
+ var n = this.offset(), i = this.message.indexOf(e, n);
+ return i >= 0 ? (this.bumpTo(i), !0) : (this.bumpTo(this.message.length), !1);
+ }, t.prototype.bumpTo = function(e) {
+ if (this.offset() > e)
+ throw Error("targetOffset ".concat(e, " must be greater than or equal to the current offset ").concat(this.offset()));
+ for (e = Math.min(e, this.message.length); ; ) {
+ var n = this.offset();
+ if (n === e)
+ break;
+ if (n > e)
+ throw Error("targetOffset ".concat(e, " is at invalid UTF-16 code unit boundary"));
+ if (this.bump(), this.isEOF())
+ break;
+ }
+ }, t.prototype.bumpSpace = function() {
+ for (; !this.isEOF() && Lr(this.char()); )
+ this.bump();
+ }, t.prototype.peek = function() {
+ if (this.isEOF())
+ return null;
+ var e = this.char(), n = this.offset(), i = this.message.charCodeAt(n + (e >= 65536 ? 2 : 1));
+ return i ?? null;
+ }, t;
+ }()
+);
+function Dn(t) {
+ return t >= 97 && t <= 122 || t >= 65 && t <= 90;
+}
+function su(t) {
+ return Dn(t) || t === 47;
+}
+function ou(t) {
+ return t === 45 || t === 46 || t >= 48 && t <= 57 || t === 95 || t >= 97 && t <= 122 || t >= 65 && t <= 90 || t == 183 || t >= 192 && t <= 214 || t >= 216 && t <= 246 || t >= 248 && t <= 893 || t >= 895 && t <= 8191 || t >= 8204 && t <= 8205 || t >= 8255 && t <= 8256 || t >= 8304 && t <= 8591 || t >= 11264 && t <= 12271 || t >= 12289 && t <= 55295 || t >= 63744 && t <= 64975 || t >= 65008 && t <= 65533 || t >= 65536 && t <= 983039;
+}
+function Lr(t) {
+ return t >= 9 && t <= 13 || t === 32 || t === 133 || t >= 8206 && t <= 8207 || t === 8232 || t === 8233;
+}
+function au(t) {
+ return t >= 33 && t <= 35 || t === 36 || t >= 37 && t <= 39 || t === 40 || t === 41 || t === 42 || t === 43 || t === 44 || t === 45 || t >= 46 && t <= 47 || t >= 58 && t <= 59 || t >= 60 && t <= 62 || t >= 63 && t <= 64 || t === 91 || t === 92 || t === 93 || t === 94 || t === 96 || t === 123 || t === 124 || t === 125 || t === 126 || t === 161 || t >= 162 && t <= 165 || t === 166 || t === 167 || t === 169 || t === 171 || t === 172 || t === 174 || t === 176 || t === 177 || t === 182 || t === 187 || t === 191 || t === 215 || t === 247 || t >= 8208 && t <= 8213 || t >= 8214 && t <= 8215 || t === 8216 || t === 8217 || t === 8218 || t >= 8219 && t <= 8220 || t === 8221 || t === 8222 || t === 8223 || t >= 8224 && t <= 8231 || t >= 8240 && t <= 8248 || t === 8249 || t === 8250 || t >= 8251 && t <= 8254 || t >= 8257 && t <= 8259 || t === 8260 || t === 8261 || t === 8262 || t >= 8263 && t <= 8273 || t === 8274 || t === 8275 || t >= 8277 && t <= 8286 || t >= 8592 && t <= 8596 || t >= 8597 && t <= 8601 || t >= 8602 && t <= 8603 || t >= 8604 && t <= 8607 || t === 8608 || t >= 8609 && t <= 8610 || t === 8611 || t >= 8612 && t <= 8613 || t === 8614 || t >= 8615 && t <= 8621 || t === 8622 || t >= 8623 && t <= 8653 || t >= 8654 && t <= 8655 || t >= 8656 && t <= 8657 || t === 8658 || t === 8659 || t === 8660 || t >= 8661 && t <= 8691 || t >= 8692 && t <= 8959 || t >= 8960 && t <= 8967 || t === 8968 || t === 8969 || t === 8970 || t === 8971 || t >= 8972 && t <= 8991 || t >= 8992 && t <= 8993 || t >= 8994 && t <= 9e3 || t === 9001 || t === 9002 || t >= 9003 && t <= 9083 || t === 9084 || t >= 9085 && t <= 9114 || t >= 9115 && t <= 9139 || t >= 9140 && t <= 9179 || t >= 9180 && t <= 9185 || t >= 9186 && t <= 9254 || t >= 9255 && t <= 9279 || t >= 9280 && t <= 9290 || t >= 9291 && t <= 9311 || t >= 9472 && t <= 9654 || t === 9655 || t >= 9656 && t <= 9664 || t === 9665 || t >= 9666 && t <= 9719 || t >= 9720 && t <= 9727 || t >= 9728 && t <= 9838 || t === 9839 || t >= 9840 && t <= 10087 || t === 10088 || t === 10089 || t === 10090 || t === 10091 || t === 10092 || t === 10093 || t === 10094 || t === 10095 || t === 10096 || t === 10097 || t === 10098 || t === 10099 || t === 10100 || t === 10101 || t >= 10132 && t <= 10175 || t >= 10176 && t <= 10180 || t === 10181 || t === 10182 || t >= 10183 && t <= 10213 || t === 10214 || t === 10215 || t === 10216 || t === 10217 || t === 10218 || t === 10219 || t === 10220 || t === 10221 || t === 10222 || t === 10223 || t >= 10224 && t <= 10239 || t >= 10240 && t <= 10495 || t >= 10496 && t <= 10626 || t === 10627 || t === 10628 || t === 10629 || t === 10630 || t === 10631 || t === 10632 || t === 10633 || t === 10634 || t === 10635 || t === 10636 || t === 10637 || t === 10638 || t === 10639 || t === 10640 || t === 10641 || t === 10642 || t === 10643 || t === 10644 || t === 10645 || t === 10646 || t === 10647 || t === 10648 || t >= 10649 && t <= 10711 || t === 10712 || t === 10713 || t === 10714 || t === 10715 || t >= 10716 && t <= 10747 || t === 10748 || t === 10749 || t >= 10750 && t <= 11007 || t >= 11008 && t <= 11055 || t >= 11056 && t <= 11076 || t >= 11077 && t <= 11078 || t >= 11079 && t <= 11084 || t >= 11085 && t <= 11123 || t >= 11124 && t <= 11125 || t >= 11126 && t <= 11157 || t === 11158 || t >= 11159 && t <= 11263 || t >= 11776 && t <= 11777 || t === 11778 || t === 11779 || t === 11780 || t === 11781 || t >= 11782 && t <= 11784 || t === 11785 || t === 11786 || t === 11787 || t === 11788 || t === 11789 || t >= 11790 && t <= 11798 || t === 11799 || t >= 11800 && t <= 11801 || t === 11802 || t === 11803 || t === 11804 || t === 11805 || t >= 11806 && t <= 11807 || t === 11808 || t === 11809 || t === 11810 || t === 11811 || t === 11812 || t === 11813 || t === 11814 || t === 11815 || t === 11816 || t === 11817 || t >= 11818 && t <= 11822 || t === 11823 || t >= 11824 && t <= 11833 || t >= 11834 && t <= 11835 || t >= 11836 && t <= 11839 || t === 11840 || t === 11841 || t === 11842 || t >= 11843 && t <= 11855 || t >= 11856 && t <= 11857 || t === 11858 || t >= 11859 && t <= 11903 || t >= 12289 && t <= 12291 || t === 12296 || t === 12297 || t === 12298 || t === 12299 || t === 12300 || t === 12301 || t === 12302 || t === 12303 || t === 12304 || t === 12305 || t >= 12306 && t <= 12307 || t === 12308 || t === 12309 || t === 12310 || t === 12311 || t === 12312 || t === 12313 || t === 12314 || t === 12315 || t === 12316 || t === 12317 || t >= 12318 && t <= 12319 || t === 12320 || t === 12336 || t === 64830 || t === 64831 || t >= 65093 && t <= 65094;
+}
+function Hn(t) {
+ t.forEach(function(e) {
+ if (delete e.location, Er(e) || Sr(e))
+ for (var n in e.options)
+ delete e.options[n].location, Hn(e.options[n].value);
+ else
+ vr(e) && Ar(e.style) || (yr(e) || wr(e)) && Rn(e.style) ? delete e.style.location : Cr(e) && Hn(e.children);
+ });
+}
+function lu(t, e) {
+ e === void 0 && (e = {}), e = O({ shouldParseSkeletons: !0, requiresOtherClause: !0 }, e);
+ var n = new ru(t, e).parse();
+ if (n.err) {
+ var i = SyntaxError(B[n.err.kind]);
+ throw i.location = n.err.location, i.originalMessage = n.err.message, i;
+ }
+ return e != null && e.captureLocation || Hn(n.val), n.val;
+}
+function gn(t, e) {
+ var n = e && e.cache ? e.cache : mu, i = e && e.serializer ? e.serializer : fu, r = e && e.strategy ? e.strategy : cu;
+ return r(t, {
+ cache: n,
+ serializer: i
+ });
+}
+function uu(t) {
+ return t == null || typeof t == "number" || typeof t == "boolean";
+}
+function Dr(t, e, n, i) {
+ var r = uu(i) ? i : n(i), s = e.get(r);
+ return typeof s > "u" && (s = t.call(this, i), e.set(r, s)), s;
+}
+function Hr(t, e, n) {
+ var i = Array.prototype.slice.call(arguments, 3), r = n(i), s = e.get(r);
+ return typeof s > "u" && (s = t.apply(this, i), e.set(r, s)), s;
+}
+function qn(t, e, n, i, r) {
+ return n.bind(e, t, i, r);
+}
+function cu(t, e) {
+ var n = t.length === 1 ? Dr : Hr;
+ return qn(t, this, n, e.cache.create(), e.serializer);
+}
+function hu(t, e) {
+ return qn(t, this, Hr, e.cache.create(), e.serializer);
+}
+function du(t, e) {
+ return qn(t, this, Dr, e.cache.create(), e.serializer);
+}
+var fu = function() {
+ return JSON.stringify(arguments);
+};
+function Vn() {
+ this.cache = /* @__PURE__ */ Object.create(null);
+}
+Vn.prototype.get = function(t) {
+ return this.cache[t];
+};
+Vn.prototype.set = function(t, e) {
+ this.cache[t] = e;
+};
+var mu = {
+ create: function() {
+ return new Vn();
+ }
+}, bn = {
+ variadic: hu,
+ monadic: du
+}, ot;
+(function(t) {
+ t.MISSING_VALUE = "MISSING_VALUE", t.INVALID_VALUE = "INVALID_VALUE", t.MISSING_INTL_API = "MISSING_INTL_API";
+})(ot || (ot = {}));
+var Qt = (
+ /** @class */
+ function(t) {
+ Jt(e, t);
+ function e(n, i, r) {
+ var s = t.call(this, n) || this;
+ return s.code = i, s.originalMessage = r, s;
+ }
+ return e.prototype.toString = function() {
+ return "[formatjs Error: ".concat(this.code, "] ").concat(this.message);
+ }, e;
+ }(Error)
+), Gi = (
+ /** @class */
+ function(t) {
+ Jt(e, t);
+ function e(n, i, r, s) {
+ return t.call(this, 'Invalid values for "'.concat(n, '": "').concat(i, '". Options are "').concat(Object.keys(r).join('", "'), '"'), ot.INVALID_VALUE, s) || this;
+ }
+ return e;
+ }(Qt)
+), pu = (
+ /** @class */
+ function(t) {
+ Jt(e, t);
+ function e(n, i, r) {
+ return t.call(this, 'Value for "'.concat(n, '" must be of type ').concat(i), ot.INVALID_VALUE, r) || this;
+ }
+ return e;
+ }(Qt)
+), _u = (
+ /** @class */
+ function(t) {
+ Jt(e, t);
+ function e(n, i) {
+ return t.call(this, 'The intl string context variable "'.concat(n, '" was not provided to the string "').concat(i, '"'), ot.MISSING_VALUE, i) || this;
+ }
+ return e;
+ }(Qt)
+), te;
+(function(t) {
+ t[t.literal = 0] = "literal", t[t.object = 1] = "object";
+})(te || (te = {}));
+function gu(t) {
+ return t.length < 2 ? t : t.reduce(function(e, n) {
+ var i = e[e.length - 1];
+ return !i || i.type !== te.literal || n.type !== te.literal ? e.push(n) : i.value += n.value, e;
+ }, []);
+}
+function bu(t) {
+ return typeof t == "function";
+}
+function Dt(t, e, n, i, r, s, o) {
+ if (t.length === 1 && Di(t[0]))
+ return [
+ {
+ type: te.literal,
+ value: t[0].value
+ }
+ ];
+ for (var u = [], a = 0, c = t; a < c.length; a++) {
+ var l = c[a];
+ if (Di(l)) {
+ u.push({
+ type: te.literal,
+ value: l.value
+ });
+ continue;
+ }
+ if (Hl(l)) {
+ typeof s == "number" && u.push({
+ type: te.literal,
+ value: n.getNumberFormat(e).format(s)
+ });
+ continue;
+ }
+ var d = l.value;
+ if (!(r && d in r))
+ throw new _u(d, o);
+ var h = r[d];
+ if (Dl(l)) {
+ (!h || typeof h == "string" || typeof h == "number") && (h = typeof h == "string" || typeof h == "number" ? String(h) : ""), u.push({
+ type: typeof h == "string" ? te.literal : te.object,
+ value: h
+ });
+ continue;
+ }
+ if (yr(l)) {
+ var m = typeof l.style == "string" ? i.date[l.style] : Rn(l.style) ? l.style.parsedOptions : void 0;
+ u.push({
+ type: te.literal,
+ value: n.getDateTimeFormat(e, m).format(h)
+ });
+ continue;
+ }
+ if (wr(l)) {
+ var m = typeof l.style == "string" ? i.time[l.style] : Rn(l.style) ? l.style.parsedOptions : i.time.medium;
+ u.push({
+ type: te.literal,
+ value: n.getDateTimeFormat(e, m).format(h)
+ });
+ continue;
+ }
+ if (vr(l)) {
+ var m = typeof l.style == "string" ? i.number[l.style] : Ar(l.style) ? l.style.parsedOptions : void 0;
+ m && m.scale && (h = h * (m.scale || 1)), u.push({
+ type: te.literal,
+ value: n.getNumberFormat(e, m).format(h)
+ });
+ continue;
+ }
+ if (Cr(l)) {
+ var p = l.children, g = l.value, y = r[g];
+ if (!bu(y))
+ throw new pu(g, "function", o);
+ var w = Dt(p, e, n, i, r, s), b = y(w.map(function(k) {
+ return k.value;
+ }));
+ Array.isArray(b) || (b = [b]), u.push.apply(u, b.map(function(k) {
+ return {
+ type: typeof k == "string" ? te.literal : te.object,
+ value: k
+ };
+ }));
+ }
+ if (Er(l)) {
+ var T = l.options[h] || l.options.other;
+ if (!T)
+ throw new Gi(l.value, h, Object.keys(l.options), o);
+ u.push.apply(u, Dt(T.value, e, n, i, r));
+ continue;
+ }
+ if (Sr(l)) {
+ var T = l.options["=".concat(h)];
+ if (!T) {
+ if (!Intl.PluralRules)
+ throw new Qt(`Intl.PluralRules is not available in this environment.
+Try polyfilling it using "@formatjs/intl-pluralrules"
+`, ot.MISSING_INTL_API, o);
+ var A = n.getPluralRules(e, { type: l.pluralType }).select(h - (l.offset || 0));
+ T = l.options[A] || l.options.other;
+ }
+ if (!T)
+ throw new Gi(l.value, h, Object.keys(l.options), o);
+ u.push.apply(u, Dt(T.value, e, n, i, r, h - (l.offset || 0)));
+ continue;
+ }
+ }
+ return gu(u);
+}
+function vu(t, e) {
+ return e ? O(O(O({}, t || {}), e || {}), Object.keys(t).reduce(function(n, i) {
+ return n[i] = O(O({}, t[i]), e[i] || {}), n;
+ }, {})) : t;
+}
+function yu(t, e) {
+ return e ? Object.keys(t).reduce(function(n, i) {
+ return n[i] = vu(t[i], e[i]), n;
+ }, O({}, t)) : t;
+}
+function vn(t) {
+ return {
+ create: function() {
+ return {
+ get: function(e) {
+ return t[e];
+ },
+ set: function(e, n) {
+ t[e] = n;
+ }
+ };
+ }
+ };
+}
+function wu(t) {
+ return t === void 0 && (t = {
+ number: {},
+ dateTime: {},
+ pluralRules: {}
+ }), {
+ getNumberFormat: gn(function() {
+ for (var e, n = [], i = 0; i < arguments.length; i++)
+ n[i] = arguments[i];
+ return new ((e = Intl.NumberFormat).bind.apply(e, pn([void 0], n, !1)))();
+ }, {
+ cache: vn(t.number),
+ strategy: bn.variadic
+ }),
+ getDateTimeFormat: gn(function() {
+ for (var e, n = [], i = 0; i < arguments.length; i++)
+ n[i] = arguments[i];
+ return new ((e = Intl.DateTimeFormat).bind.apply(e, pn([void 0], n, !1)))();
+ }, {
+ cache: vn(t.dateTime),
+ strategy: bn.variadic
+ }),
+ getPluralRules: gn(function() {
+ for (var e, n = [], i = 0; i < arguments.length; i++)
+ n[i] = arguments[i];
+ return new ((e = Intl.PluralRules).bind.apply(e, pn([void 0], n, !1)))();
+ }, {
+ cache: vn(t.pluralRules),
+ strategy: bn.variadic
+ })
+ };
+}
+var Eu = (
+ /** @class */
+ function() {
+ function t(e, n, i, r) {
+ var s = this;
+ if (n === void 0 && (n = t.defaultLocale), this.formatterCache = {
+ number: {},
+ dateTime: {},
+ pluralRules: {}
+ }, this.format = function(o) {
+ var u = s.formatToParts(o);
+ if (u.length === 1)
+ return u[0].value;
+ var a = u.reduce(function(c, l) {
+ return !c.length || l.type !== te.literal || typeof c[c.length - 1] != "string" ? c.push(l.value) : c[c.length - 1] += l.value, c;
+ }, []);
+ return a.length <= 1 ? a[0] || "" : a;
+ }, this.formatToParts = function(o) {
+ return Dt(s.ast, s.locales, s.formatters, s.formats, o, void 0, s.message);
+ }, this.resolvedOptions = function() {
+ return {
+ locale: s.resolvedLocale.toString()
+ };
+ }, this.getAst = function() {
+ return s.ast;
+ }, this.locales = n, this.resolvedLocale = t.resolveLocale(n), typeof e == "string") {
+ if (this.message = e, !t.__parse)
+ throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");
+ this.ast = t.__parse(e, {
+ ignoreTag: r == null ? void 0 : r.ignoreTag,
+ locale: this.resolvedLocale
+ });
+ } else
+ this.ast = e;
+ if (!Array.isArray(this.ast))
+ throw new TypeError("A message must be provided as a String or AST.");
+ this.formats = yu(t.formats, i), this.formatters = r && r.formatters || wu(this.formatterCache);
+ }
+ return Object.defineProperty(t, "defaultLocale", {
+ get: function() {
+ return t.memoizedDefaultLocale || (t.memoizedDefaultLocale = new Intl.NumberFormat().resolvedOptions().locale), t.memoizedDefaultLocale;
+ },
+ enumerable: !1,
+ configurable: !0
+ }), t.memoizedDefaultLocale = null, t.resolveLocale = function(e) {
+ var n = Intl.NumberFormat.supportedLocalesOf(e);
+ return n.length > 0 ? new Intl.Locale(n[0]) : new Intl.Locale(typeof e == "string" ? e : e[0]);
+ }, t.__parse = lu, t.formats = {
+ number: {
+ integer: {
+ maximumFractionDigits: 0
+ },
+ currency: {
+ style: "currency"
+ },
+ percent: {
+ style: "percent"
+ }
+ },
+ date: {
+ short: {
+ month: "numeric",
+ day: "numeric",
+ year: "2-digit"
+ },
+ medium: {
+ month: "short",
+ day: "numeric",
+ year: "numeric"
+ },
+ long: {
+ month: "long",
+ day: "numeric",
+ year: "numeric"
+ },
+ full: {
+ weekday: "long",
+ month: "long",
+ day: "numeric",
+ year: "numeric"
+ }
+ },
+ time: {
+ short: {
+ hour: "numeric",
+ minute: "numeric"
+ },
+ medium: {
+ hour: "numeric",
+ minute: "numeric",
+ second: "numeric"
+ },
+ long: {
+ hour: "numeric",
+ minute: "numeric",
+ second: "numeric",
+ timeZoneName: "short"
+ },
+ full: {
+ hour: "numeric",
+ minute: "numeric",
+ second: "numeric",
+ timeZoneName: "short"
+ }
+ }
+ }, t;
+ }()
+);
+function Su(t, e) {
+ if (e == null)
+ return;
+ if (e in t)
+ return t[e];
+ const n = e.split(".");
+ let i = t;
+ for (let r = 0; r < n.length; r++)
+ if (typeof i == "object") {
+ if (r > 0) {
+ const s = n.slice(r, n.length).join(".");
+ if (s in i) {
+ i = i[s];
+ break;
+ }
+ }
+ i = i[n[r]];
+ } else
+ i = void 0;
+ return i;
+}
+const De = {}, Cu = (t, e, n) => n && (e in De || (De[e] = {}), t in De[e] || (De[e][t] = n), n), Or = (t, e) => {
+ if (e == null)
+ return;
+ if (e in De && t in De[e])
+ return De[e][t];
+ const n = Yt(e);
+ for (let i = 0; i < n.length; i++) {
+ const r = n[i], s = xu(r, t);
+ if (s)
+ return Cu(t, e, s);
+ }
+};
+let Xn;
+const St = Zt({});
+function Au(t) {
+ return Xn[t] || null;
+}
+function Mr(t) {
+ return t in Xn;
+}
+function xu(t, e) {
+ if (!Mr(t))
+ return null;
+ const n = Au(t);
+ return Su(n, e);
+}
+function Tu(t) {
+ if (t == null)
+ return;
+ const e = Yt(t);
+ for (let n = 0; n < e.length; n++) {
+ const i = e[n];
+ if (Mr(i))
+ return i;
+ }
+}
+function Pu(t, ...e) {
+ delete De[t], St.update((n) => (n[t] = Ll.all([n[t] || {}, ...e]), n));
+}
+lt(
+ [St],
+ ([t]) => Object.keys(t)
+);
+St.subscribe((t) => Xn = t);
+const Ht = {};
+function Ru(t, e) {
+ Ht[t].delete(e), Ht[t].size === 0 && delete Ht[t];
+}
+function Nr(t) {
+ return Ht[t];
+}
+function ku(t) {
+ return Yt(t).map((e) => {
+ const n = Nr(e);
+ return [e, n ? [...n] : []];
+ }).filter(([, e]) => e.length > 0);
+}
+function On(t) {
+ return t == null ? !1 : Yt(t).some(
+ (e) => {
+ var n;
+ return (n = Nr(e)) == null ? void 0 : n.size;
+ }
+ );
+}
+function Bu(t, e) {
+ return Promise.all(
+ e.map((i) => (Ru(t, i), i().then((r) => r.default || r)))
+ ).then((i) => Pu(t, ...i));
+}
+const _t = {};
+function Ir(t) {
+ if (!On(t))
+ return t in _t ? _t[t] : Promise.resolve();
+ const e = ku(t);
+ return _t[t] = Promise.all(
+ e.map(
+ ([n, i]) => Bu(n, i)
+ )
+ ).then(() => {
+ if (On(t))
+ return Ir(t);
+ delete _t[t];
+ }), _t[t];
+}
+const Lu = {
+ number: {
+ scientific: { notation: "scientific" },
+ engineering: { notation: "engineering" },
+ compactLong: { notation: "compact", compactDisplay: "long" },
+ compactShort: { notation: "compact", compactDisplay: "short" }
+ },
+ date: {
+ short: { month: "numeric", day: "numeric", year: "2-digit" },
+ medium: { month: "short", day: "numeric", year: "numeric" },
+ long: { month: "long", day: "numeric", year: "numeric" },
+ full: { weekday: "long", month: "long", day: "numeric", year: "numeric" }
+ },
+ time: {
+ short: { hour: "numeric", minute: "numeric" },
+ medium: { hour: "numeric", minute: "numeric", second: "numeric" },
+ long: {
+ hour: "numeric",
+ minute: "numeric",
+ second: "numeric",
+ timeZoneName: "short"
+ },
+ full: {
+ hour: "numeric",
+ minute: "numeric",
+ second: "numeric",
+ timeZoneName: "short"
+ }
+ }
+}, Du = {
+ fallbackLocale: null,
+ loadingDelay: 200,
+ formats: Lu,
+ warnOnMissingMessages: !0,
+ handleMissingMessage: void 0,
+ ignoreTag: !0
+}, Hu = Du;
+function at() {
+ return Hu;
+}
+const yn = Zt(!1);
+var Ou = Object.defineProperty, Mu = Object.defineProperties, Nu = Object.getOwnPropertyDescriptors, Fi = Object.getOwnPropertySymbols, Iu = Object.prototype.hasOwnProperty, Uu = Object.prototype.propertyIsEnumerable, Wi = (t, e, n) => e in t ? Ou(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, Gu = (t, e) => {
+ for (var n in e || (e = {}))
+ Iu.call(e, n) && Wi(t, n, e[n]);
+ if (Fi)
+ for (var n of Fi(e))
+ Uu.call(e, n) && Wi(t, n, e[n]);
+ return t;
+}, Fu = (t, e) => Mu(t, Nu(e));
+let Mn;
+const Ft = Zt(null);
+function ji(t) {
+ return t.split("-").map((e, n, i) => i.slice(0, n + 1).join("-")).reverse();
+}
+function Yt(t, e = at().fallbackLocale) {
+ const n = ji(t);
+ return e ? [.../* @__PURE__ */ new Set([...n, ...ji(e)])] : n;
+}
+function qe() {
+ return Mn ?? void 0;
+}
+Ft.subscribe((t) => {
+ Mn = t ?? void 0, typeof window < "u" && t != null && document.documentElement.setAttribute("lang", t);
+});
+const Wu = (t) => {
+ if (t && Tu(t) && On(t)) {
+ const { loadingDelay: e } = at();
+ let n;
+ return typeof window < "u" && qe() != null && e ? n = window.setTimeout(
+ () => yn.set(!0),
+ e
+ ) : yn.set(!0), Ir(t).then(() => {
+ Ft.set(t);
+ }).finally(() => {
+ clearTimeout(n), yn.set(!1);
+ });
+ }
+ return Ft.set(t);
+}, Ct = Fu(Gu({}, Ft), {
+ set: Wu
+}), Kt = (t) => {
+ const e = /* @__PURE__ */ Object.create(null);
+ return (i) => {
+ const r = JSON.stringify(i);
+ return r in e ? e[r] : e[r] = t(i);
+ };
+};
+var ju = Object.defineProperty, Wt = Object.getOwnPropertySymbols, Ur = Object.prototype.hasOwnProperty, Gr = Object.prototype.propertyIsEnumerable, zi = (t, e, n) => e in t ? ju(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, Zn = (t, e) => {
+ for (var n in e || (e = {}))
+ Ur.call(e, n) && zi(t, n, e[n]);
+ if (Wt)
+ for (var n of Wt(e))
+ Gr.call(e, n) && zi(t, n, e[n]);
+ return t;
+}, ut = (t, e) => {
+ var n = {};
+ for (var i in t)
+ Ur.call(t, i) && e.indexOf(i) < 0 && (n[i] = t[i]);
+ if (t != null && Wt)
+ for (var i of Wt(t))
+ e.indexOf(i) < 0 && Gr.call(t, i) && (n[i] = t[i]);
+ return n;
+};
+const wt = (t, e) => {
+ const { formats: n } = at();
+ if (t in n && e in n[t])
+ return n[t][e];
+ throw new Error(`[svelte-i18n] Unknown "${e}" ${t} format.`);
+}, zu = Kt(
+ (t) => {
+ var e = t, { locale: n, format: i } = e, r = ut(e, ["locale", "format"]);
+ if (n == null)
+ throw new Error('[svelte-i18n] A "locale" must be set to format numbers');
+ return i && (r = wt("number", i)), new Intl.NumberFormat(n, r);
+ }
+), qu = Kt(
+ (t) => {
+ var e = t, { locale: n, format: i } = e, r = ut(e, ["locale", "format"]);
+ if (n == null)
+ throw new Error('[svelte-i18n] A "locale" must be set to format dates');
+ return i ? r = wt("date", i) : Object.keys(r).length === 0 && (r = wt("date", "short")), new Intl.DateTimeFormat(n, r);
+ }
+), Vu = Kt(
+ (t) => {
+ var e = t, { locale: n, format: i } = e, r = ut(e, ["locale", "format"]);
+ if (n == null)
+ throw new Error(
+ '[svelte-i18n] A "locale" must be set to format time values'
+ );
+ return i ? r = wt("time", i) : Object.keys(r).length === 0 && (r = wt("time", "short")), new Intl.DateTimeFormat(n, r);
+ }
+), Xu = (t = {}) => {
+ var e = t, {
+ locale: n = qe()
+ } = e, i = ut(e, [
+ "locale"
+ ]);
+ return zu(Zn({ locale: n }, i));
+}, Zu = (t = {}) => {
+ var e = t, {
+ locale: n = qe()
+ } = e, i = ut(e, [
+ "locale"
+ ]);
+ return qu(Zn({ locale: n }, i));
+}, Ju = (t = {}) => {
+ var e = t, {
+ locale: n = qe()
+ } = e, i = ut(e, [
+ "locale"
+ ]);
+ return Vu(Zn({ locale: n }, i));
+}, Qu = Kt(
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ (t, e = qe()) => new Eu(t, e, at().formats, {
+ ignoreTag: at().ignoreTag
+ })
+), Yu = (t, e = {}) => {
+ var n, i, r, s;
+ let o = e;
+ typeof t == "object" && (o = t, t = o.id);
+ const {
+ values: u,
+ locale: a = qe(),
+ default: c
+ } = o;
+ if (a == null)
+ throw new Error(
+ "[svelte-i18n] Cannot format a message without first setting the initial locale."
+ );
+ let l = Or(t, a);
+ if (!l)
+ l = (s = (r = (i = (n = at()).handleMissingMessage) == null ? void 0 : i.call(n, { locale: a, id: t, defaultValue: c })) != null ? r : c) != null ? s : t;
+ else if (typeof l != "string")
+ return console.warn(
+ `[svelte-i18n] Message with id "${t}" must be of type "string", found: "${typeof l}". Gettin its value through the "$format" method is deprecated; use the "json" method instead.`
+ ), l;
+ if (!u)
+ return l;
+ let d = l;
+ try {
+ d = Qu(l, a).format(u);
+ } catch (h) {
+ h instanceof Error && console.warn(
+ `[svelte-i18n] Message "${t}" has syntax error:`,
+ h.message
+ );
+ }
+ return d;
+}, Ku = (t, e) => Ju(e).format(t), $u = (t, e) => Zu(e).format(t), ec = (t, e) => Xu(e).format(t), tc = (t, e = qe()) => Or(t, e);
+lt([Ct, St], () => Yu);
+lt([Ct], () => Ku);
+lt([Ct], () => $u);
+lt([Ct], () => ec);
+lt([Ct, St], () => tc);
+/*! *****************************************************************************
+Copyright (c) Microsoft Corporation.
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
+***************************************************************************** */
+function wn(t, e, n, i) {
+ return new (n || (n = Promise))(function(r, s) {
+ function o(c) {
+ try {
+ a(i.next(c));
+ } catch (l) {
+ s(l);
+ }
+ }
+ function u(c) {
+ try {
+ a(i.throw(c));
+ } catch (l) {
+ s(l);
+ }
+ }
+ function a(c) {
+ var l;
+ c.done ? r(c.value) : (l = c.value, l instanceof n ? l : new n(function(d) {
+ d(l);
+ })).then(o, u);
+ }
+ a((i = i.apply(t, e || [])).next());
+ });
+}
+class Fr {
+ constructor() {
+ this.listeners = {};
+ }
+ on(e, n, i) {
+ if (this.listeners[e] || (this.listeners[e] = /* @__PURE__ */ new Set()), this.listeners[e].add(n), i == null ? void 0 : i.once) {
+ const r = () => {
+ this.un(e, r), this.un(e, n);
+ };
+ return this.on(e, r), r;
+ }
+ return () => this.un(e, n);
+ }
+ un(e, n) {
+ var i;
+ (i = this.listeners[e]) === null || i === void 0 || i.delete(n);
+ }
+ once(e, n) {
+ return this.on(e, n, { once: !0 });
+ }
+ unAll() {
+ this.listeners = {};
+ }
+ emit(e, ...n) {
+ this.listeners[e] && this.listeners[e].forEach((i) => i(...n));
+ }
+}
+class nc extends Fr {
+ constructor(e) {
+ super(), this.subscriptions = [], this.options = e;
+ }
+ onInit() {
+ }
+ _init(e) {
+ this.wavesurfer = e, this.onInit();
+ }
+ destroy() {
+ this.emit("destroy"), this.subscriptions.forEach((e) => e());
+ }
+}
+class ic extends Fr {
+ constructor() {
+ super(...arguments), this.unsubscribe = () => {
+ };
+ }
+ start() {
+ this.unsubscribe = this.on("tick", () => {
+ requestAnimationFrame(() => {
+ this.emit("tick");
+ });
+ }), this.emit("tick");
+ }
+ stop() {
+ this.unsubscribe();
+ }
+ destroy() {
+ this.unsubscribe();
+ }
+}
+const rc = ["audio/webm", "audio/wav", "audio/mpeg", "audio/mp4", "audio/mp3"];
+class Jn extends nc {
+ constructor(e) {
+ var n, i, r, s;
+ super(Object.assign(Object.assign({}, e), { audioBitsPerSecond: (n = e.audioBitsPerSecond) !== null && n !== void 0 ? n : 128e3, scrollingWaveform: (i = e.scrollingWaveform) !== null && i !== void 0 && i, scrollingWaveformWindow: (r = e.scrollingWaveformWindow) !== null && r !== void 0 ? r : 5, renderRecordedAudio: (s = e.renderRecordedAudio) === null || s === void 0 || s })), this.stream = null, this.mediaRecorder = null, this.dataWindow = null, this.isWaveformPaused = !1, this.lastStartTime = 0, this.lastDuration = 0, this.duration = 0, this.timer = new ic(), this.subscriptions.push(this.timer.on("tick", () => {
+ const o = performance.now() - this.lastStartTime;
+ this.duration = this.isPaused() ? this.duration : this.lastDuration + o, this.emit("record-progress", this.duration);
+ }));
+ }
+ static create(e) {
+ return new Jn(e || {});
+ }
+ renderMicStream(e) {
+ const n = new AudioContext(), i = n.createMediaStreamSource(e), r = n.createAnalyser();
+ i.connect(r);
+ const s = r.frequencyBinCount, o = new Float32Array(s);
+ let u;
+ const a = Math.floor((this.options.scrollingWaveformWindow || 0) * n.sampleRate), c = () => {
+ var l;
+ if (this.isWaveformPaused)
+ return void (u = requestAnimationFrame(c));
+ if (r.getFloatTimeDomainData(o), this.options.scrollingWaveform) {
+ const h = Math.min(a, this.dataWindow ? this.dataWindow.length + s : s), m = new Float32Array(a);
+ if (this.dataWindow) {
+ const p = Math.max(0, a - this.dataWindow.length);
+ m.set(this.dataWindow.slice(-h + s), p);
+ }
+ m.set(o, a - s), this.dataWindow = m;
+ } else
+ this.dataWindow = o;
+ const d = this.options.scrollingWaveformWindow;
+ this.wavesurfer && ((l = this.originalOptions) !== null && l !== void 0 || (this.originalOptions = { cursorWidth: this.wavesurfer.options.cursorWidth, interact: this.wavesurfer.options.interact }), this.wavesurfer.options.cursorWidth = 0, this.wavesurfer.options.interact = !1, this.wavesurfer.load("", [this.dataWindow], d)), u = requestAnimationFrame(c);
+ };
+ return c(), { onDestroy: () => {
+ cancelAnimationFrame(u), i == null || i.disconnect(), n == null || n.close();
+ }, onEnd: () => {
+ this.isWaveformPaused = !0, cancelAnimationFrame(u), this.stopMic();
+ } };
+ }
+ startMic(e) {
+ return wn(this, void 0, void 0, function* () {
+ let n;
+ try {
+ n = yield navigator.mediaDevices.getUserMedia({ audio: !(e != null && e.deviceId) || { deviceId: e.deviceId } });
+ } catch (s) {
+ throw new Error("Error accessing the microphone: " + s.message);
+ }
+ const { onDestroy: i, onEnd: r } = this.renderMicStream(n);
+ return this.subscriptions.push(this.once("destroy", i)), this.subscriptions.push(this.once("record-end", r)), this.stream = n, n;
+ });
+ }
+ stopMic() {
+ this.stream && (this.stream.getTracks().forEach((e) => e.stop()), this.stream = null, this.mediaRecorder = null);
+ }
+ startRecording(e) {
+ return wn(this, void 0, void 0, function* () {
+ const n = this.stream || (yield this.startMic(e));
+ this.dataWindow = null;
+ const i = this.mediaRecorder || new MediaRecorder(n, { mimeType: this.options.mimeType || rc.find((o) => MediaRecorder.isTypeSupported(o)), audioBitsPerSecond: this.options.audioBitsPerSecond });
+ this.mediaRecorder = i, this.stopRecording();
+ const r = [];
+ i.ondataavailable = (o) => {
+ o.data.size > 0 && r.push(o.data);
+ };
+ const s = (o) => {
+ var u;
+ const a = new Blob(r, { type: i.mimeType });
+ this.emit(o, a), this.options.renderRecordedAudio && (this.applyOriginalOptionsIfNeeded(), (u = this.wavesurfer) === null || u === void 0 || u.load(URL.createObjectURL(a)));
+ };
+ i.onpause = () => s("record-pause"), i.onstop = () => s("record-end"), i.start(), this.lastStartTime = performance.now(), this.lastDuration = 0, this.duration = 0, this.isWaveformPaused = !1, this.timer.start(), this.emit("record-start");
+ });
+ }
+ getDuration() {
+ return this.duration;
+ }
+ isRecording() {
+ var e;
+ return ((e = this.mediaRecorder) === null || e === void 0 ? void 0 : e.state) === "recording";
+ }
+ isPaused() {
+ var e;
+ return ((e = this.mediaRecorder) === null || e === void 0 ? void 0 : e.state) === "paused";
+ }
+ isActive() {
+ var e;
+ return ((e = this.mediaRecorder) === null || e === void 0 ? void 0 : e.state) !== "inactive";
+ }
+ stopRecording() {
+ var e;
+ this.isActive() && ((e = this.mediaRecorder) === null || e === void 0 || e.stop(), this.timer.stop());
+ }
+ pauseRecording() {
+ var e, n;
+ this.isRecording() && (this.isWaveformPaused = !0, (e = this.mediaRecorder) === null || e === void 0 || e.requestData(), (n = this.mediaRecorder) === null || n === void 0 || n.pause(), this.timer.stop(), this.lastDuration = this.duration);
+ }
+ resumeRecording() {
+ var e;
+ this.isPaused() && (this.isWaveformPaused = !1, (e = this.mediaRecorder) === null || e === void 0 || e.resume(), this.timer.start(), this.lastStartTime = performance.now(), this.emit("record-resume"));
+ }
+ static getAvailableAudioDevices() {
+ return wn(this, void 0, void 0, function* () {
+ return navigator.mediaDevices.enumerateDevices().then((e) => e.filter((n) => n.kind === "audioinput"));
+ });
+ }
+ destroy() {
+ this.applyOriginalOptionsIfNeeded(), super.destroy(), this.stopRecording(), this.stopMic();
+ }
+ applyOriginalOptionsIfNeeded() {
+ this.wavesurfer && this.originalOptions && (this.wavesurfer.options.cursorWidth = this.originalOptions.cursorWidth, this.wavesurfer.options.interact = this.originalOptions.interact, delete this.originalOptions);
+ }
+}
+const {
+ SvelteComponent: sc,
+ attr: Qn,
+ binding_callbacks: qi,
+ detach: Yn,
+ element: Kn,
+ init: oc,
+ insert: $n,
+ listen: Wr,
+ noop: jt,
+ safe_not_equal: ac
+} = window.__gradio__svelte__internal, { onMount: lc } = window.__gradio__svelte__internal;
+function uc(t) {
+ let e, n, i;
+ return {
+ c() {
+ e = Kn("button"), e.innerHTML = '', Qn(e, "class", "stop-button svelte-g0zaxm");
+ },
+ m(r, s) {
+ $n(r, e, s), t[7](e), n || (i = Wr(
+ e,
+ "click",
+ /*record_click*/
+ t[3]
+ ), n = !0);
+ },
+ p: jt,
+ d(r) {
+ r && Yn(e), t[7](null), n = !1, i();
+ }
+ };
+}
+function cc(t) {
+ let e, n, i;
+ return {
+ c() {
+ e = Kn("button"), e.innerHTML = '', Qn(e, "class", "record-button svelte-g0zaxm");
+ },
+ m(r, s) {
+ $n(r, e, s), t[6](e), n || (i = Wr(
+ e,
+ "click",
+ /*record_click*/
+ t[3]
+ ), n = !0);
+ },
+ p: jt,
+ d(r) {
+ r && Yn(e), t[6](null), n = !1, i();
+ }
+ };
+}
+function hc(t) {
+ let e;
+ function n(s, o) {
+ return (
+ /*isRecording*/
+ s[2] ? uc : cc
+ );
+ }
+ let i = n(t), r = i(t);
+ return {
+ c() {
+ e = Kn("div"), r.c(), Qn(e, "class", "wrapper svelte-g0zaxm");
+ },
+ m(s, o) {
+ $n(s, e, o), r.m(e, null);
+ },
+ p(s, [o]) {
+ i === (i = n(s)) && r ? r.p(s, o) : (r.d(1), r = i(s), r && (r.c(), r.m(e, null)));
+ },
+ i: jt,
+ o: jt,
+ d(s) {
+ s && Yn(e), r.d();
+ }
+ };
+}
+function dc(t, e, n) {
+ let { record: i } = e, { dispatch: r } = e, s, o;
+ lc(() => {
+ n(0, s = document.getElementById("record")), n(1, o = document.getElementById("stop"));
+ });
+ function u() {
+ a ? (i.stopRecording(), r("stop_recording")) : (i.startRecording(), r("start_recording")), n(2, a = !a);
+ }
+ let a = !1;
+ function c(d) {
+ qi[d ? "unshift" : "push"](() => {
+ s = d, n(0, s);
+ });
+ }
+ function l(d) {
+ qi[d ? "unshift" : "push"](() => {
+ o = d, n(1, o);
+ });
+ }
+ return t.$$set = (d) => {
+ "record" in d && n(4, i = d.record), "dispatch" in d && n(5, r = d.dispatch);
+ }, [
+ s,
+ o,
+ a,
+ u,
+ i,
+ r,
+ c,
+ l
+ ];
+}
+class fc extends sc {
+ constructor(e) {
+ super(), oc(this, e, dc, hc, ac, { record: 4, dispatch: 5 });
+ }
+}
+const {
+ SvelteComponent: mc,
+ add_flush_callback: Ot,
+ append: En,
+ attr: Pt,
+ bind: Mt,
+ binding_callbacks: Nt,
+ check_outros: Vi,
+ create_component: jr,
+ destroy_component: zr,
+ detach: pc,
+ element: Xi,
+ group_outros: Zi,
+ init: _c,
+ insert: gc,
+ mount_component: qr,
+ safe_not_equal: bc,
+ space: Ji,
+ transition_in: Be,
+ transition_out: Ke
+} = window.__gradio__svelte__internal, { onMount: vc } = window.__gradio__svelte__internal;
+function Qi(t) {
+ let e, n, i;
+ function r(o) {
+ t[18](o);
+ }
+ let s = { dispatch: (
+ /*dispatch*/
+ t[2]
+ ) };
+ return (
+ /*record*/
+ t[6] !== void 0 && (s.record = /*record*/
+ t[6]), e = new fc({ props: s }), Nt.push(() => Mt(e, "record", r)), {
+ c() {
+ jr(e.$$.fragment);
+ },
+ m(o, u) {
+ qr(e, o, u), i = !0;
+ },
+ p(o, u) {
+ const a = {};
+ u & /*dispatch*/
+ 4 && (a.dispatch = /*dispatch*/
+ o[2]), !n && u & /*record*/
+ 64 && (n = !0, a.record = /*record*/
+ o[6], Ot(() => n = !1)), e.$set(a);
+ },
+ i(o) {
+ i || (Be(e.$$.fragment, o), i = !0);
+ },
+ o(o) {
+ Ke(e.$$.fragment, o), i = !1;
+ },
+ d(o) {
+ zr(e, o);
+ }
+ }
+ );
+}
+function Yi(t) {
+ let e, n, i, r, s;
+ function o(l) {
+ t[19](l);
+ }
+ function u(l) {
+ t[20](l);
+ }
+ function a(l) {
+ t[21](l);
+ }
+ let c = {
+ container: (
+ /*container*/
+ t[12]
+ ),
+ playing: (
+ /*playing*/
+ t[9]
+ ),
+ audioDuration: (
+ /*audioDuration*/
+ t[10]
+ ),
+ i18n: (
+ /*i18n*/
+ t[1]
+ ),
+ interactive: !0,
+ handle_trim_audio: (
+ /*handle_trim_audio*/
+ t[13]
+ ),
+ showRedo: !0,
+ handle_reset_value: (
+ /*handle_reset_value*/
+ t[4]
+ ),
+ waveform_settings: (
+ /*waveform_settings*/
+ t[3]
+ )
+ };
+ return (
+ /*recordingWaveform*/
+ t[5] !== void 0 && (c.waveform = /*recordingWaveform*/
+ t[5]), /*trimDuration*/
+ t[11] !== void 0 && (c.trimDuration = /*trimDuration*/
+ t[11]), /*mode*/
+ t[0] !== void 0 && (c.mode = /*mode*/
+ t[0]), e = new lr({ props: c }), Nt.push(() => Mt(e, "waveform", o)), Nt.push(() => Mt(e, "trimDuration", u)), Nt.push(() => Mt(e, "mode", a)), {
+ c() {
+ jr(e.$$.fragment);
+ },
+ m(l, d) {
+ qr(e, l, d), s = !0;
+ },
+ p(l, d) {
+ const h = {};
+ d & /*playing*/
+ 512 && (h.playing = /*playing*/
+ l[9]), d & /*audioDuration*/
+ 1024 && (h.audioDuration = /*audioDuration*/
+ l[10]), d & /*i18n*/
+ 2 && (h.i18n = /*i18n*/
+ l[1]), d & /*handle_reset_value*/
+ 16 && (h.handle_reset_value = /*handle_reset_value*/
+ l[4]), d & /*waveform_settings*/
+ 8 && (h.waveform_settings = /*waveform_settings*/
+ l[3]), !n && d & /*recordingWaveform*/
+ 32 && (n = !0, h.waveform = /*recordingWaveform*/
+ l[5], Ot(() => n = !1)), !i && d & /*trimDuration*/
+ 2048 && (i = !0, h.trimDuration = /*trimDuration*/
+ l[11], Ot(() => i = !1)), !r && d & /*mode*/
+ 1 && (r = !0, h.mode = /*mode*/
+ l[0], Ot(() => r = !1)), e.$set(h);
+ },
+ i(l) {
+ s || (Be(e.$$.fragment, l), s = !0);
+ },
+ o(l) {
+ Ke(e.$$.fragment, l), s = !1;
+ },
+ d(l) {
+ zr(e, l);
+ }
+ }
+ );
+}
+function yc(t) {
+ let e, n, i, r, s, o = (
+ /*micWaveform*/
+ t[8] && !/*recordedAudio*/
+ t[7] && Qi(t)
+ ), u = (
+ /*recordingWaveform*/
+ t[5] && /*recordedAudio*/
+ t[7] && Yi(t)
+ );
+ return {
+ c() {
+ e = Xi("div"), n = Xi("div"), i = Ji(), o && o.c(), r = Ji(), u && u.c(), Pt(n, "id", "microphone"), Pt(n, "data-testid", "microphone-waveform"), Pt(n, "class", "svelte-1smaui2"), Pt(e, "class", "component-wrapper svelte-1smaui2");
+ },
+ m(a, c) {
+ gc(a, e, c), En(e, n), En(e, i), o && o.m(e, null), En(e, r), u && u.m(e, null), s = !0;
+ },
+ p(a, [c]) {
+ /*micWaveform*/
+ a[8] && !/*recordedAudio*/
+ a[7] ? o ? (o.p(a, c), c & /*micWaveform, recordedAudio*/
+ 384 && Be(o, 1)) : (o = Qi(a), o.c(), Be(o, 1), o.m(e, r)) : o && (Zi(), Ke(o, 1, 1, () => {
+ o = null;
+ }), Vi()), /*recordingWaveform*/
+ a[5] && /*recordedAudio*/
+ a[7] ? u ? (u.p(a, c), c & /*recordingWaveform, recordedAudio*/
+ 160 && Be(u, 1)) : (u = Yi(a), u.c(), Be(u, 1), u.m(e, null)) : u && (Zi(), Ke(u, 1, 1, () => {
+ u = null;
+ }), Vi());
+ },
+ i(a) {
+ s || (Be(o), Be(u), s = !0);
+ },
+ o(a) {
+ Ke(o), Ke(u), s = !1;
+ },
+ d(a) {
+ a && pc(e), o && o.d(), u && u.d();
+ }
+ };
+}
+function ye(t) {
+ let e, n = t[0], i = 1;
+ for (; i < t.length; ) {
+ const r = t[i], s = t[i + 1];
+ if (i += 2, (r === "optionalAccess" || r === "optionalCall") && n == null)
+ return;
+ r === "access" || r === "optionalAccess" ? (e = n, n = s(n)) : (r === "call" || r === "optionalCall") && (n = s((...o) => n.call(e, ...o)), e = void 0);
+ }
+ return n;
+}
+function wc(t, e, n) {
+ let { mode: i } = e, { i18n: r } = e, { dispatch: s } = e, { dispatch_blob: o } = e, { waveform_settings: u = {} } = e, { handle_reset_value: a } = e, c, l, d = !1, h, m, p = null, g, y, w, b, T = 0;
+ const A = () => {
+ clearInterval(b), n(17, b = setInterval(
+ () => {
+ },
+ 1e3
+ ));
+ }, k = () => {
+ const f = document.getElementById("microphone");
+ f && (f.innerHTML = ""), c !== void 0 && c.destroy(), f && (n(8, c = We.create({
+ ...u,
+ container: f
+ })), n(6, m = c.registerPlugin(Jn.create())), m.startMic());
+ }, x = () => {
+ let f = document.getElementById("recording");
+ !p || !f || n(5, l = We.create({
+ container: f,
+ url: p,
+ ...u
+ }));
+ }, M = async (f, D) => {
+ n(0, i = "edit");
+ const C = l.getDecodedData();
+ C && await An(C, f, D).then(async (R) => {
+ await o([R], "change"), l.destroy(), x();
+ }), s("edit");
+ };
+ vc(() => {
+ k(), window.addEventListener("keydown", (f) => {
+ f.key === "ArrowRight" ? It(l, 0.1) : f.key === "ArrowLeft" && It(l, -0.1);
+ });
+ });
+ function S(f) {
+ m = f, n(6, m);
+ }
+ function G(f) {
+ l = f, n(5, l);
+ }
+ function V(f) {
+ T = f, n(11, T);
+ }
+ function $(f) {
+ i = f, n(0, i);
+ }
+ return t.$$set = (f) => {
+ "mode" in f && n(0, i = f.mode), "i18n" in f && n(1, r = f.i18n), "dispatch" in f && n(2, s = f.dispatch), "dispatch_blob" in f && n(14, o = f.dispatch_blob), "waveform_settings" in f && n(3, u = f.waveform_settings), "handle_reset_value" in f && n(4, a = f.handle_reset_value);
+ }, t.$$.update = () => {
+ t.$$.dirty & /*record, dispatch*/
+ 68 && ye([
+ m,
+ "optionalAccess",
+ (f) => f.on,
+ "call",
+ (f) => f("record-start", () => {
+ A(), s("start_recording");
+ })
+ ]), t.$$.dirty & /*record, interval, dispatch_blob*/
+ 147520 && ye([
+ m,
+ "optionalAccess",
+ (f) => f.on,
+ "call",
+ (f) => f("record-end", async (D) => {
+ clearInterval(b);
+ const C = await D.arrayBuffer(), _ = await new AudioContext().decodeAudioData(C);
+ _ && await An(_).then(async (v) => {
+ await o([v], "change"), await o([v], "stop_recording");
+ });
+ })
+ ]), t.$$.dirty & /*record, dispatch, interval*/
+ 131140 && ye([
+ m,
+ "optionalAccess",
+ (f) => f.on,
+ "call",
+ (f) => f("record-pause", () => {
+ s("pause_recording"), clearInterval(b);
+ })
+ ]), t.$$.dirty & /*record*/
+ 64 && ye([
+ m,
+ "optionalAccess",
+ (f) => f.on,
+ "call",
+ (f) => f("record-resume", () => {
+ A();
+ })
+ ]), t.$$.dirty & /*recordingWaveform, durationRef*/
+ 65568 && ye([
+ l,
+ "optionalAccess",
+ (f) => f.on,
+ "call",
+ (f) => f("decode", (D) => {
+ n(10, w = D);
+ })
+ ]), t.$$.dirty & /*recordingWaveform, timeRef*/
+ 32800 && ye([
+ l,
+ "optionalAccess",
+ (f) => f.on,
+ "call",
+ (f) => f("timeupdate", (D) => g)
+ ]), t.$$.dirty & /*recordingWaveform, dispatch*/
+ 36 && ye([
+ l,
+ "optionalAccess",
+ (f) => f.on,
+ "call",
+ (f) => f("pause", () => {
+ s("pause"), n(9, d = !1);
+ })
+ ]), t.$$.dirty & /*recordingWaveform, dispatch*/
+ 36 && ye([
+ l,
+ "optionalAccess",
+ (f) => f.on,
+ "call",
+ (f) => f("play", () => {
+ s("play"), n(9, d = !0);
+ })
+ ]), t.$$.dirty & /*recordingWaveform, dispatch*/
+ 36 && ye([
+ l,
+ "optionalAccess",
+ (f) => f.on,
+ "call",
+ (f) => f("finish", () => {
+ s("stop"), s("end"), n(9, d = !1);
+ })
+ ]), t.$$.dirty & /*record, recordedAudio*/
+ 192 && ye([
+ m,
+ "optionalAccess",
+ (f) => f.on,
+ "call",
+ (f) => f("record-end", (D) => {
+ n(7, p = URL.createObjectURL(D));
+ const C = document.getElementById("microphone"), R = document.getElementById("recording");
+ C && (C.style.display = "none"), R && p && (R.innerHTML = "", x());
+ })
+ ]);
+ }, [
+ i,
+ r,
+ s,
+ u,
+ a,
+ l,
+ m,
+ p,
+ c,
+ d,
+ w,
+ T,
+ h,
+ M,
+ o,
+ g,
+ y,
+ b,
+ S,
+ G,
+ V,
+ $
+ ];
+}
+class Ec extends mc {
+ constructor(e) {
+ super(), _c(this, e, wc, yc, bc, {
+ mode: 0,
+ i18n: 1,
+ dispatch: 2,
+ dispatch_blob: 14,
+ waveform_settings: 3,
+ handle_reset_value: 4
+ });
+ }
+}
+const {
+ SvelteComponent: Sc,
+ add_flush_callback: Cc,
+ bind: Ac,
+ binding_callbacks: xc,
+ create_component: Tc,
+ destroy_component: Pc,
+ init: Rc,
+ mount_component: kc,
+ safe_not_equal: Bc,
+ transition_in: Lc,
+ transition_out: Dc
+} = window.__gradio__svelte__internal, { onMount: Ch, onDestroy: Hc, createEventDispatcher: Oc } = window.__gradio__svelte__internal;
+function Mc(t) {
+ let e, n, i;
+ function r(o) {
+ t[18](o);
+ }
+ let s = {
+ i18n: (
+ /*i18n*/
+ t[0]
+ ),
+ dispatch: (
+ /*dispatch*/
+ t[4]
+ ),
+ dispatch_blob: (
+ /*dispatch_blob*/
+ t[5]
+ ),
+ waveform_settings: (
+ /*waveform_settings*/
+ t[1]
+ ),
+ handle_reset_value: (
+ /*handle_reset_value*/
+ t[2]
+ )
+ };
+ return (
+ /*mode*/
+ t[3] !== void 0 && (s.mode = /*mode*/
+ t[3]), e = new Ec({ props: s }), xc.push(() => Ac(e, "mode", r)), {
+ c() {
+ Tc(e.$$.fragment);
+ },
+ m(o, u) {
+ kc(e, o, u), i = !0;
+ },
+ p(o, [u]) {
+ const a = {};
+ u & /*i18n*/
+ 1 && (a.i18n = /*i18n*/
+ o[0]), u & /*waveform_settings*/
+ 2 && (a.waveform_settings = /*waveform_settings*/
+ o[1]), u & /*handle_reset_value*/
+ 4 && (a.handle_reset_value = /*handle_reset_value*/
+ o[2]), !n && u & /*mode*/
+ 8 && (n = !0, a.mode = /*mode*/
+ o[3], Cc(() => n = !1)), e.$set(a);
+ },
+ i(o) {
+ i || (Lc(e.$$.fragment, o), i = !0);
+ },
+ o(o) {
+ Dc(e.$$.fragment, o), i = !1;
+ },
+ d(o) {
+ Pc(e, o);
+ }
+ }
+ );
+}
+async function Nc(t) {
+ let e, n = t[0], i = 1;
+ for (; i < t.length; ) {
+ const r = t[i], s = t[i + 1];
+ if (i += 2, (r === "optionalAccess" || r === "optionalCall") && n == null)
+ return;
+ r === "access" || r === "optionalAccess" ? (e = n, n = await s(n)) : (r === "call" || r === "optionalCall") && (n = await s((...o) => n.call(e, ...o)), e = void 0);
+ }
+ return n;
+}
+function Ic(t, e, n) {
+ let { value: i = null } = e, { label: r } = e, { root: s } = e, { show_label: o = !0 } = e, { sources: u = ["microphone", "upload"] } = e, { pending: a = !1 } = e, { streaming: c = !1 } = e, { i18n: l } = e, { waveform_settings: d = {} } = e, { dragging: h } = e, { active_source: m } = e, { handle_reset_value: p = () => {
+ } } = e, g, y = "", w, b = [], T = !1;
+ function A() {
+ import("./module-ae1e1517.js"), import("./module-ef7e7a9a.js");
+ }
+ c && A();
+ const k = Oc(), x = async (S, G) => {
+ let V = new File(S, "audio.wav");
+ const $ = await Ua([V], G === "stream");
+ n(6, i = (await Nc([
+ await Ia($, s),
+ "optionalAccess",
+ async (f) => f.filter,
+ "call",
+ async (f) => f(Boolean)
+ ]))[0]), console.log("dispatch blobbbb: ", i), k(G, i);
+ };
+ Hc(() => {
+ c && g && g.state !== "inactive" && g.stop();
+ });
+ function M(S) {
+ y = S, n(3, y);
+ }
+ return t.$$set = (S) => {
+ "value" in S && n(6, i = S.value), "label" in S && n(7, r = S.label), "root" in S && n(8, s = S.root), "show_label" in S && n(9, o = S.show_label), "sources" in S && n(10, u = S.sources), "pending" in S && n(11, a = S.pending), "streaming" in S && n(12, c = S.streaming), "i18n" in S && n(0, l = S.i18n), "waveform_settings" in S && n(1, d = S.waveform_settings), "dragging" in S && n(13, h = S.dragging), "active_source" in S && n(14, m = S.active_source), "handle_reset_value" in S && n(2, p = S.handle_reset_value);
+ }, t.$$.update = () => {
+ t.$$.dirty & /*dragging*/
+ 8192 && k("drag", h), t.$$.dirty & /*submit_pending_stream_on_pending_end, pending, header, pending_stream*/
+ 231424;
+ }, [
+ l,
+ d,
+ p,
+ y,
+ k,
+ x,
+ i,
+ r,
+ s,
+ o,
+ u,
+ a,
+ c,
+ h,
+ m,
+ w,
+ b,
+ T,
+ M
+ ];
+}
+class Uc extends Sc {
+ constructor(e) {
+ super(), Rc(this, e, Ic, Mc, Bc, {
+ value: 6,
+ label: 7,
+ root: 8,
+ show_label: 9,
+ sources: 10,
+ pending: 11,
+ streaming: 12,
+ i18n: 0,
+ waveform_settings: 1,
+ dragging: 13,
+ active_source: 14,
+ handle_reset_value: 2
+ });
+ }
+}
+const {
+ SvelteComponent: Gc,
+ add_flush_callback: Fc,
+ bind: Wc,
+ binding_callbacks: jc,
+ check_outros: zc,
+ create_component: Vr,
+ destroy_component: Xr,
+ detach: qc,
+ empty: Vc,
+ flush: q,
+ group_outros: Xc,
+ init: Zc,
+ insert: Jc,
+ mount_component: Zr,
+ safe_not_equal: Qc,
+ transition_in: zt,
+ transition_out: qt
+} = window.__gradio__svelte__internal;
+function Yc(t) {
+ let e, n, i;
+ function r(o) {
+ t[32](o);
+ }
+ let s = {
+ label: (
+ /*label*/
+ t[4]
+ ),
+ show_label: (
+ /*show_label*/
+ t[6]
+ ),
+ value: (
+ /*_value*/
+ t[13]
+ ),
+ root: (
+ /*root*/
+ t[5]
+ ),
+ sources: (
+ /*sources*/
+ t[2]
+ ),
+ active_source: (
+ /*active_source*/
+ t[14]
+ ),
+ pending: (
+ /*pending*/
+ t[10]
+ ),
+ streaming: (
+ /*streaming*/
+ t[11]
+ ),
+ handle_reset_value: (
+ /*handle_reset_value*/
+ t[16]
+ ),
+ i18n: (
+ /*gradio*/
+ t[12].i18n
+ ),
+ waveform_settings: (
+ /*waveform_settings*/
+ t[17]
+ )
+ };
+ return (
+ /*dragging*/
+ t[15] !== void 0 && (s.dragging = /*dragging*/
+ t[15]), e = new Uc({ props: s }), jc.push(() => Wc(e, "dragging", r)), e.$on(
+ "change",
+ /*change_handler*/
+ t[33]
+ ), e.$on(
+ "stream",
+ /*stream_handler*/
+ t[34]
+ ), e.$on(
+ "drag",
+ /*drag_handler*/
+ t[35]
+ ), e.$on(
+ "edit",
+ /*edit_handler*/
+ t[36]
+ ), e.$on(
+ "play",
+ /*play_handler*/
+ t[37]
+ ), e.$on(
+ "pause",
+ /*pause_handler*/
+ t[38]
+ ), e.$on(
+ "stop",
+ /*stop_handler*/
+ t[39]
+ ), e.$on(
+ "end",
+ /*end_handler*/
+ t[40]
+ ), e.$on(
+ "start_recording",
+ /*start_recording_handler*/
+ t[41]
+ ), e.$on(
+ "pause_recording",
+ /*pause_recording_handler*/
+ t[42]
+ ), e.$on(
+ "stop_recording",
+ /*stop_recording_handler*/
+ t[43]
+ ), e.$on(
+ "upload",
+ /*upload_handler*/
+ t[44]
+ ), e.$on(
+ "clear",
+ /*clear_handler*/
+ t[45]
+ ), e.$on(
+ "error",
+ /*handle_error*/
+ t[18]
+ ), {
+ c() {
+ Vr(e.$$.fragment);
+ },
+ m(o, u) {
+ Zr(e, o, u), i = !0;
+ },
+ p(o, u) {
+ const a = {};
+ u[0] & /*label*/
+ 16 && (a.label = /*label*/
+ o[4]), u[0] & /*show_label*/
+ 64 && (a.show_label = /*show_label*/
+ o[6]), u[0] & /*_value*/
+ 8192 && (a.value = /*_value*/
+ o[13]), u[0] & /*root*/
+ 32 && (a.root = /*root*/
+ o[5]), u[0] & /*sources*/
+ 4 && (a.sources = /*sources*/
+ o[2]), u[0] & /*active_source*/
+ 16384 && (a.active_source = /*active_source*/
+ o[14]), u[0] & /*pending*/
+ 1024 && (a.pending = /*pending*/
+ o[10]), u[0] & /*streaming*/
+ 2048 && (a.streaming = /*streaming*/
+ o[11]), u[0] & /*gradio*/
+ 4096 && (a.i18n = /*gradio*/
+ o[12].i18n), !n && u[0] & /*dragging*/
+ 32768 && (n = !0, a.dragging = /*dragging*/
+ o[15], Fc(() => n = !1)), e.$set(a);
+ },
+ i(o) {
+ i || (zt(e.$$.fragment, o), i = !0);
+ },
+ o(o) {
+ qt(e.$$.fragment, o), i = !1;
+ },
+ d(o) {
+ Xr(e, o);
+ }
+ }
+ );
+}
+function Kc(t) {
+ let e, n;
+ return e = new cl({
+ props: {
+ i18n: (
+ /*gradio*/
+ t[12].i18n
+ ),
+ image: (
+ /*image*/
+ t[3]
+ ),
+ show_label: (
+ /*show_label*/
+ t[6]
+ ),
+ show_download_button: (
+ /*show_download_button*/
+ t[8]
+ ),
+ show_share_button: (
+ /*show_share_button*/
+ t[9]
+ ),
+ value: (
+ /*_value*/
+ t[13]
+ ),
+ label: (
+ /*label*/
+ t[4]
+ ),
+ root: (
+ /*root*/
+ t[5]
+ ),
+ proxy_url: (
+ /*proxy_url*/
+ t[7]
+ ),
+ waveform_settings: (
+ /*waveform_settings*/
+ t[17]
+ )
+ }
+ }), e.$on(
+ "share",
+ /*share_handler*/
+ t[30]
+ ), e.$on(
+ "error",
+ /*error_handler*/
+ t[31]
+ ), {
+ c() {
+ Vr(e.$$.fragment);
+ },
+ m(i, r) {
+ Zr(e, i, r), n = !0;
+ },
+ p(i, r) {
+ const s = {};
+ r[0] & /*gradio*/
+ 4096 && (s.i18n = /*gradio*/
+ i[12].i18n), r[0] & /*image*/
+ 8 && (s.image = /*image*/
+ i[3]), r[0] & /*show_label*/
+ 64 && (s.show_label = /*show_label*/
+ i[6]), r[0] & /*show_download_button*/
+ 256 && (s.show_download_button = /*show_download_button*/
+ i[8]), r[0] & /*show_share_button*/
+ 512 && (s.show_share_button = /*show_share_button*/
+ i[9]), r[0] & /*_value*/
+ 8192 && (s.value = /*_value*/
+ i[13]), r[0] & /*label*/
+ 16 && (s.label = /*label*/
+ i[4]), r[0] & /*root*/
+ 32 && (s.root = /*root*/
+ i[5]), r[0] & /*proxy_url*/
+ 128 && (s.proxy_url = /*proxy_url*/
+ i[7]), e.$set(s);
+ },
+ i(i) {
+ n || (zt(e.$$.fragment, i), n = !0);
+ },
+ o(i) {
+ qt(e.$$.fragment, i), n = !1;
+ },
+ d(i) {
+ Xr(e, i);
+ }
+ };
+}
+function $c(t) {
+ let e, n, i, r;
+ const s = [Kc, Yc], o = [];
+ function u(a, c) {
+ return !/*interactive*/
+ a[1] || /*value*/
+ a[0] !== null ? 0 : 1;
+ }
+ return e = u(t), n = o[e] = s[e](t), {
+ c() {
+ n.c(), i = Vc();
+ },
+ m(a, c) {
+ o[e].m(a, c), Jc(a, i, c), r = !0;
+ },
+ p(a, c) {
+ let l = e;
+ e = u(a), e === l ? o[e].p(a, c) : (Xc(), qt(o[l], 1, 1, () => {
+ o[l] = null;
+ }), zc(), n = o[e], n ? n.p(a, c) : (n = o[e] = s[e](a), n.c()), zt(n, 1), n.m(i.parentNode, i));
+ },
+ i(a) {
+ r || (zt(n), r = !0);
+ },
+ o(a) {
+ qt(n), r = !1;
+ },
+ d(a) {
+ a && qc(i), o[e].d(a);
+ }
+ };
+}
+function eh(t, e, n) {
+ let { elem_id: i = "" } = e, { elem_classes: r = [] } = e, { visible: s = !0 } = e, { interactive: o } = e, { value: u = null } = e, { sources: a } = e, { image: c = null } = e, { label: l } = e, { root: d } = e, { show_label: h } = e, { proxy_url: m } = e, { container: p = !0 } = e, { scale: g = null } = e, { min_width: y = void 0 } = e, { loading_status: w } = e, { autoplay: b = !1 } = e, { show_download_button: T = !0 } = e, { show_share_button: A = !1 } = e, { waveform_options: k = {} } = e, { pending: x } = e, { streaming: M } = e, { gradio: S } = e, G = null, V, $, f = u;
+ const D = () => {
+ f === null || u === f || n(0, u = f);
+ };
+ let C;
+ const R = {
+ height: 50,
+ waveColor: k.waveform_color || "#9ca3af",
+ progressColor: k.waveform_progress_color || "#f97316",
+ barWidth: 2,
+ barGap: 3,
+ barHeight: 4,
+ cursorWidth: 2,
+ cursorColor: "#ddd5e9",
+ autoplay: b,
+ barRadius: 10,
+ dragToSeek: !0,
+ mediaControls: k.show_controls
+ };
+ function _({ detail: E }) {
+ const [ne, W] = E.includes("Invalid file type") ? ["warning", "complete"] : ["error", "error"];
+ n(19, w = w || {}), n(19, w.status = W, w), n(19, w.message = E, w), S.dispatch(ne, E);
+ }
+ const v = (E) => S.dispatch("share", E.detail), U = (E) => S.dispatch("error", E.detail);
+ function N(E) {
+ C = E, n(15, C);
+ }
+ const Q = ({ detail: E }) => n(0, u = E), be = ({ detail: E }) => {
+ n(0, u = E), S.dispatch("stream", u);
+ }, H = ({ detail: E }) => n(15, C = E), me = () => S.dispatch("edit"), le = () => S.dispatch("play"), pe = () => S.dispatch("pause"), Me = () => S.dispatch("stop"), Ee = () => S.dispatch("end"), z = () => S.dispatch("start_recording"), ct = () => S.dispatch("pause_recording"), Ve = (E) => S.dispatch("stop_recording", E.detail), ht = () => S.dispatch("upload"), dt = () => S.dispatch("clear");
+ return t.$$set = (E) => {
+ "elem_id" in E && n(20, i = E.elem_id), "elem_classes" in E && n(21, r = E.elem_classes), "visible" in E && n(22, s = E.visible), "interactive" in E && n(1, o = E.interactive), "value" in E && n(0, u = E.value), "sources" in E && n(2, a = E.sources), "image" in E && n(3, c = E.image), "label" in E && n(4, l = E.label), "root" in E && n(5, d = E.root), "show_label" in E && n(6, h = E.show_label), "proxy_url" in E && n(7, m = E.proxy_url), "container" in E && n(23, p = E.container), "scale" in E && n(24, g = E.scale), "min_width" in E && n(25, y = E.min_width), "loading_status" in E && n(19, w = E.loading_status), "autoplay" in E && n(26, b = E.autoplay), "show_download_button" in E && n(8, T = E.show_download_button), "show_share_button" in E && n(9, A = E.show_share_button), "waveform_options" in E && n(27, k = E.waveform_options), "pending" in E && n(10, x = E.pending), "streaming" in E && n(11, M = E.streaming), "gradio" in E && n(12, S = E.gradio);
+ }, t.$$.update = () => {
+ t.$$.dirty[0] & /*value, root, proxy_url*/
+ 161 && n(13, V = Ie(u, d, m)), t.$$.dirty[0] & /*value, initial_value*/
+ 536870913 && u && f === null && n(29, f = u), t.$$.dirty[0] & /*value, old_value, gradio*/
+ 268439553 && JSON.stringify(u) !== JSON.stringify(G) && (n(28, G = u), S.dispatch("change")), t.$$.dirty[0] & /*sources*/
+ 4 && a && n(14, $ = a[0]);
+ }, [
+ u,
+ o,
+ a,
+ c,
+ l,
+ d,
+ h,
+ m,
+ T,
+ A,
+ x,
+ M,
+ S,
+ V,
+ $,
+ C,
+ D,
+ R,
+ _,
+ w,
+ i,
+ r,
+ s,
+ p,
+ g,
+ y,
+ b,
+ k,
+ G,
+ f,
+ v,
+ U,
+ N,
+ Q,
+ be,
+ H,
+ me,
+ le,
+ pe,
+ Me,
+ Ee,
+ z,
+ ct,
+ Ve,
+ ht,
+ dt
+ ];
+}
+class Ah extends Gc {
+ constructor(e) {
+ super(), Zc(
+ this,
+ e,
+ eh,
+ $c,
+ Qc,
+ {
+ elem_id: 20,
+ elem_classes: 21,
+ visible: 22,
+ interactive: 1,
+ value: 0,
+ sources: 2,
+ image: 3,
+ label: 4,
+ root: 5,
+ show_label: 6,
+ proxy_url: 7,
+ container: 23,
+ scale: 24,
+ min_width: 25,
+ loading_status: 19,
+ autoplay: 26,
+ show_download_button: 8,
+ show_share_button: 9,
+ waveform_options: 27,
+ pending: 10,
+ streaming: 11,
+ gradio: 12
+ },
+ null,
+ [-1, -1]
+ );
+ }
+ get elem_id() {
+ return this.$$.ctx[20];
+ }
+ set elem_id(e) {
+ this.$$set({ elem_id: e }), q();
+ }
+ get elem_classes() {
+ return this.$$.ctx[21];
+ }
+ set elem_classes(e) {
+ this.$$set({ elem_classes: e }), q();
+ }
+ get visible() {
+ return this.$$.ctx[22];
+ }
+ set visible(e) {
+ this.$$set({ visible: e }), q();
+ }
+ get interactive() {
+ return this.$$.ctx[1];
+ }
+ set interactive(e) {
+ this.$$set({ interactive: e }), q();
+ }
+ get value() {
+ return this.$$.ctx[0];
+ }
+ set value(e) {
+ this.$$set({ value: e }), q();
+ }
+ get sources() {
+ return this.$$.ctx[2];
+ }
+ set sources(e) {
+ this.$$set({ sources: e }), q();
+ }
+ get image() {
+ return this.$$.ctx[3];
+ }
+ set image(e) {
+ this.$$set({ image: e }), q();
+ }
+ get label() {
+ return this.$$.ctx[4];
+ }
+ set label(e) {
+ this.$$set({ label: e }), q();
+ }
+ get root() {
+ return this.$$.ctx[5];
+ }
+ set root(e) {
+ this.$$set({ root: e }), q();
+ }
+ get show_label() {
+ return this.$$.ctx[6];
+ }
+ set show_label(e) {
+ this.$$set({ show_label: e }), q();
+ }
+ get proxy_url() {
+ return this.$$.ctx[7];
+ }
+ set proxy_url(e) {
+ this.$$set({ proxy_url: e }), q();
+ }
+ get container() {
+ return this.$$.ctx[23];
+ }
+ set container(e) {
+ this.$$set({ container: e }), q();
+ }
+ get scale() {
+ return this.$$.ctx[24];
+ }
+ set scale(e) {
+ this.$$set({ scale: e }), q();
+ }
+ get min_width() {
+ return this.$$.ctx[25];
+ }
+ set min_width(e) {
+ this.$$set({ min_width: e }), q();
+ }
+ get loading_status() {
+ return this.$$.ctx[19];
+ }
+ set loading_status(e) {
+ this.$$set({ loading_status: e }), q();
+ }
+ get autoplay() {
+ return this.$$.ctx[26];
+ }
+ set autoplay(e) {
+ this.$$set({ autoplay: e }), q();
+ }
+ get show_download_button() {
+ return this.$$.ctx[8];
+ }
+ set show_download_button(e) {
+ this.$$set({ show_download_button: e }), q();
+ }
+ get show_share_button() {
+ return this.$$.ctx[9];
+ }
+ set show_share_button(e) {
+ this.$$set({ show_share_button: e }), q();
+ }
+ get waveform_options() {
+ return this.$$.ctx[27];
+ }
+ set waveform_options(e) {
+ this.$$set({ waveform_options: e }), q();
+ }
+ get pending() {
+ return this.$$.ctx[10];
+ }
+ set pending(e) {
+ this.$$set({ pending: e }), q();
+ }
+ get streaming() {
+ return this.$$.ctx[11];
+ }
+ set streaming(e) {
+ this.$$set({ streaming: e }), q();
+ }
+ get gradio() {
+ return this.$$.ctx[12];
+ }
+ set gradio(e) {
+ this.$$set({ gradio: e }), q();
+ }
+}
+const {
+ SvelteComponent: th,
+ append: nh,
+ attr: ih,
+ detach: rh,
+ element: sh,
+ init: oh,
+ insert: ah,
+ noop: Ki,
+ safe_not_equal: lh,
+ set_data: uh,
+ text: ch,
+ toggle_class: Je
+} = window.__gradio__svelte__internal;
+function hh(t) {
+ let e, n;
+ return {
+ c() {
+ e = sh("div"), n = ch(
+ /*value*/
+ t[0]
+ ), ih(e, "class", "svelte-1gecy8w"), Je(
+ e,
+ "table",
+ /*type*/
+ t[1] === "table"
+ ), Je(
+ e,
+ "gallery",
+ /*type*/
+ t[1] === "gallery"
+ ), Je(
+ e,
+ "selected",
+ /*selected*/
+ t[2]
+ );
+ },
+ m(i, r) {
+ ah(i, e, r), nh(e, n);
+ },
+ p(i, [r]) {
+ r & /*value*/
+ 1 && uh(
+ n,
+ /*value*/
+ i[0]
+ ), r & /*type*/
+ 2 && Je(
+ e,
+ "table",
+ /*type*/
+ i[1] === "table"
+ ), r & /*type*/
+ 2 && Je(
+ e,
+ "gallery",
+ /*type*/
+ i[1] === "gallery"
+ ), r & /*selected*/
+ 4 && Je(
+ e,
+ "selected",
+ /*selected*/
+ i[2]
+ );
+ },
+ i: Ki,
+ o: Ki,
+ d(i) {
+ i && rh(e);
+ }
+ };
+}
+function dh(t, e, n) {
+ let { value: i } = e, { type: r } = e, { selected: s = !1 } = e;
+ return t.$$set = (o) => {
+ "value" in o && n(0, i = o.value), "type" in o && n(1, r = o.type), "selected" in o && n(2, s = o.selected);
+ }, [i, r, s];
+}
+class xh extends th {
+ constructor(e) {
+ super(), oh(this, e, dh, hh, lh, { value: 0, type: 1, selected: 2 });
+ }
+}
+export {
+ vh as A,
+ xh as E,
+ Ah as I,
+ cl as S,
+ Uc as a,
+ gl as g
+};