const es = [
{ 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 }
], ii = {
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"
}
};
es.reduce(
(t, { color: e, primary: n, secondary: i }) => ({
...t,
[e]: {
primary: ii[e][n],
secondary: ii[e][i]
}
}),
{}
);
function ts(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 Bt extends Error {
constructor(e) {
super(e), this.name = "ShareError";
}
}
async function ns(t, e) {
if (window.__gradio_space__ == null)
throw new Bt("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 = is(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 (ts([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 Bt(`Upload failed: ${a.error}`);
}
throw new Bt("Upload failed.");
}
return await o.text();
}
function is(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: rs,
append: xn,
attr: Ie,
bubble: ss,
create_component: os,
destroy_component: as,
detach: nr,
element: An,
init: ls,
insert: ir,
listen: us,
mount_component: cs,
safe_not_equal: hs,
set_data: ds,
space: fs,
text: ms,
toggle_class: Ae,
transition_in: ps,
transition_out: _s
} = window.__gradio__svelte__internal;
function ri(t) {
let e, n;
return {
c() {
e = An("span"), n = ms(
/*label*/
t[1]
), Ie(e, "class", "svelte-xtz2g8");
},
m(i, r) {
ir(i, e, r), xn(e, n);
},
p(i, r) {
r & /*label*/
2 && ds(
n,
/*label*/
i[1]
);
},
d(i) {
i && nr(e);
}
};
}
function gs(t) {
let e, n, i, r, s, o, u, a = (
/*show_label*/
t[2] && ri(t)
);
return r = new /*Icon*/
t[0]({}), {
c() {
e = An("button"), a && a.c(), n = fs(), i = An("div"), os(r.$$.fragment), Ie(i, "class", "svelte-xtz2g8"), Ae(
i,
"small",
/*size*/
t[4] === "small"
), Ae(
i,
"large",
/*size*/
t[4] === "large"
), Ie(
e,
"aria-label",
/*label*/
t[1]
), Ie(
e,
"title",
/*label*/
t[1]
), Ie(e, "class", "svelte-xtz2g8"), Ae(
e,
"pending",
/*pending*/
t[3]
), Ae(
e,
"padded",
/*padded*/
t[5]
);
},
m(c, l) {
ir(c, e, l), a && a.m(e, null), xn(e, n), xn(e, i), cs(r, i, null), s = !0, o || (u = us(
e,
"click",
/*click_handler*/
t[6]
), o = !0);
},
p(c, [l]) {
/*show_label*/
c[2] ? a ? a.p(c, l) : (a = ri(c), a.c(), a.m(e, n)) : a && (a.d(1), a = null), (!s || l & /*size*/
16) && Ae(
i,
"small",
/*size*/
c[4] === "small"
), (!s || l & /*size*/
16) && Ae(
i,
"large",
/*size*/
c[4] === "large"
), (!s || l & /*label*/
2) && Ie(
e,
"aria-label",
/*label*/
c[1]
), (!s || l & /*label*/
2) && Ie(
e,
"title",
/*label*/
c[1]
), (!s || l & /*pending*/
8) && Ae(
e,
"pending",
/*pending*/
c[3]
), (!s || l & /*padded*/
32) && Ae(
e,
"padded",
/*padded*/
c[5]
);
},
i(c) {
s || (ps(r.$$.fragment, c), s = !0);
},
o(c) {
_s(r.$$.fragment, c), s = !1;
},
d(c) {
c && nr(e), a && a.d(), as(r), o = !1, u();
}
};
}
function bs(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) {
ss.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 vs extends rs {
constructor(e) {
super(), ls(this, e, bs, gs, hs, {
Icon: 0,
label: 1,
show_label: 2,
pending: 3,
size: 4,
padded: 5
});
}
}
const {
SvelteComponent: ys,
append: ws,
attr: tn,
binding_callbacks: Es,
create_slot: Ss,
detach: Cs,
element: si,
get_all_dirty_from_scope: xs,
get_slot_changes: As,
init: Ts,
insert: Ps,
safe_not_equal: ks,
toggle_class: Te,
transition_in: Rs,
transition_out: Bs,
update_slot_base: Ls
} = window.__gradio__svelte__internal;
function Ds(t) {
let e, n, i;
const r = (
/*#slots*/
t[5].default
), s = Ss(
r,
t,
/*$$scope*/
t[4],
null
);
return {
c() {
e = si("div"), n = si("div"), s && s.c(), tn(n, "class", "icon svelte-3w3rth"), tn(e, "class", "empty svelte-3w3rth"), tn(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) {
Ps(o, e, u), ws(e, n), s && s.m(n, null), t[6](e), i = !0;
},
p(o, [u]) {
s && s.p && (!i || u & /*$$scope*/
16) && Ls(
s,
r,
o,
/*$$scope*/
o[4],
i ? As(
r,
/*$$scope*/
o[4],
u,
null
) : xs(
/*$$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 || (Rs(s, o), i = !0);
},
o(o) {
Bs(s, o), i = !1;
},
d(o) {
o && Cs(e), s && s.d(o), t[6](null);
}
};
}
function Hs(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 Os(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: f } = Hs([
d,
"access",
(p) => p.parentElement,
"optionalAccess",
(p) => p.getBoundingClientRect,
"call",
(p) => p()
]) || { height: h };
return h > f + 2;
}
function l(d) {
Es[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 rr extends ys {
constructor(e) {
super(), Ts(this, e, Os, Ds, ks, { size: 0, unpadded_box: 1 });
}
}
const {
SvelteComponent: Ms,
append: Ns,
attr: ce,
detach: Is,
init: Us,
insert: Gs,
noop: nn,
safe_not_equal: Fs,
svg_element: oi
} = window.__gradio__svelte__internal;
function Ws(t) {
let e, n;
return {
c() {
e = oi("svg"), n = oi("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) {
Gs(i, e, r), Ns(e, n);
},
p: nn,
i: nn,
o: nn,
d(i) {
i && Is(e);
}
};
}
class js extends Ms {
constructor(e) {
super(), Us(this, e, null, Ws, Fs, {});
}
}
const {
SvelteComponent: zs,
append: qs,
attr: ft,
detach: Vs,
init: Xs,
insert: Zs,
noop: rn,
safe_not_equal: Js,
svg_element: ai
} = window.__gradio__svelte__internal;
function Qs(t) {
let e, n;
return {
c() {
e = ai("svg"), n = ai("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), qs(e, n);
},
p: rn,
i: rn,
o: rn,
d(i) {
i && Vs(e);
}
};
}
class Ys extends zs {
constructor(e) {
super(), Xs(this, e, null, Qs, Js, {});
}
}
const {
SvelteComponent: Ks,
append: $s,
attr: he,
detach: eo,
init: to,
insert: no,
noop: sn,
safe_not_equal: io,
svg_element: li
} = window.__gradio__svelte__internal;
function ro(t) {
let e, n;
return {
c() {
e = li("svg"), n = li("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) {
no(i, e, r), $s(e, n);
},
p: sn,
i: sn,
o: sn,
d(i) {
i && eo(e);
}
};
}
class so extends Ks {
constructor(e) {
super(), to(this, e, null, ro, io, {});
}
}
const {
SvelteComponent: oo,
append: on,
attr: K,
detach: ao,
init: lo,
insert: uo,
noop: an,
safe_not_equal: co,
svg_element: Tt
} = window.__gradio__svelte__internal;
function ho(t) {
let e, n, i, r;
return {
c() {
e = Tt("svg"), n = Tt("path"), i = Tt("circle"), r = Tt("circle"), K(n, "d", "M9 18V5l12-2v13"), K(i, "cx", "6"), K(i, "cy", "18"), K(i, "r", "3"), K(r, "cx", "18"), K(r, "cy", "16"), K(r, "r", "3"), 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", "none"), K(e, "stroke", "currentColor"), K(e, "stroke-width", "1.5"), K(e, "stroke-linecap", "round"), K(e, "stroke-linejoin", "round"), K(e, "class", "feather feather-music");
},
m(s, o) {
uo(s, e, o), on(e, n), on(e, i), on(e, r);
},
p: an,
i: an,
o: an,
d(s) {
s && ao(e);
}
};
}
class sr extends oo {
constructor(e) {
super(), lo(this, e, null, ho, co, {});
}
}
const {
SvelteComponent: fo,
append: ui,
attr: $,
detach: mo,
init: po,
insert: _o,
noop: ln,
safe_not_equal: go,
svg_element: un
} = window.__gradio__svelte__internal;
function bo(t) {
let e, n, i;
return {
c() {
e = un("svg"), n = un("rect"), i = un("rect"), $(n, "x", "6"), $(n, "y", "4"), $(n, "width", "4"), $(n, "height", "16"), $(i, "x", "14"), $(i, "y", "4"), $(i, "width", "4"), $(i, "height", "16"), $(e, "xmlns", "http://www.w3.org/2000/svg"), $(e, "width", "100%"), $(e, "height", "100%"), $(e, "viewBox", "0 0 24 24"), $(e, "fill", "currentColor"), $(e, "stroke", "currentColor"), $(e, "stroke-width", "1.5"), $(e, "stroke-linecap", "round"), $(e, "stroke-linejoin", "round");
},
m(r, s) {
_o(r, e, s), ui(e, n), ui(e, i);
},
p: ln,
i: ln,
o: ln,
d(r) {
r && mo(e);
}
};
}
class vo extends fo {
constructor(e) {
super(), po(this, e, null, bo, go, {});
}
}
const {
SvelteComponent: yo,
append: wo,
attr: ye,
detach: Eo,
init: So,
insert: Co,
noop: cn,
safe_not_equal: xo,
svg_element: ci
} = window.__gradio__svelte__internal;
function Ao(t) {
let e, n;
return {
c() {
e = ci("svg"), n = ci("polygon"), ye(n, "points", "5 3 19 12 5 21 5 3"), ye(e, "xmlns", "http://www.w3.org/2000/svg"), ye(e, "width", "100%"), ye(e, "height", "100%"), ye(e, "viewBox", "0 0 24 24"), ye(e, "fill", "currentColor"), ye(e, "stroke", "currentColor"), ye(e, "stroke-width", "1.5"), ye(e, "stroke-linecap", "round"), ye(e, "stroke-linejoin", "round");
},
m(i, r) {
Co(i, e, r), wo(e, n);
},
p: cn,
i: cn,
o: cn,
d(i) {
i && Eo(e);
}
};
}
class To extends yo {
constructor(e) {
super(), So(this, e, null, Ao, xo, {});
}
}
const {
SvelteComponent: Po,
append: mt,
attr: I,
detach: ko,
init: Ro,
insert: Bo,
noop: hn,
safe_not_equal: Lo,
svg_element: Ze
} = window.__gradio__svelte__internal;
function Do(t) {
let e, n, i, r, s, o;
return {
c() {
e = Ze("svg"), n = Ze("circle"), i = Ze("circle"), r = Ze("line"), s = Ze("line"), o = Ze("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) {
Bo(u, e, a), mt(e, n), mt(e, i), mt(e, r), mt(e, s), mt(e, o);
},
p: hn,
i: hn,
o: hn,
d(u) {
u && ko(e);
}
};
}
class Ho extends Po {
constructor(e) {
super(), Ro(this, e, null, Do, Lo, {});
}
}
const {
SvelteComponent: Oo,
append: hi,
attr: de,
detach: Mo,
init: No,
insert: Io,
noop: dn,
safe_not_equal: Uo,
svg_element: fn
} = window.__gradio__svelte__internal;
function Go(t) {
let e, n, i;
return {
c() {
e = fn("svg"), n = fn("polyline"), i = fn("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) {
Io(r, e, s), hi(e, n), hi(e, i);
},
p: dn,
i: dn,
o: dn,
d(r) {
r && Mo(e);
}
};
}
class Fo extends Oo {
constructor(e) {
super(), No(this, e, null, Go, Uo, {});
}
}
const {
SvelteComponent: Wo,
create_component: jo,
destroy_component: zo,
init: qo,
mount_component: Vo,
safe_not_equal: Xo,
transition_in: Zo,
transition_out: Jo
} = window.__gradio__svelte__internal, { createEventDispatcher: Qo } = window.__gradio__svelte__internal;
function Yo(t) {
let e, n;
return e = new vs({
props: {
Icon: Ys,
label: (
/*i18n*/
t[2]("common.share")
),
pending: (
/*pending*/
t[3]
)
}
}), e.$on(
"click",
/*click_handler*/
t[5]
), {
c() {
jo(e.$$.fragment);
},
m(i, r) {
Vo(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) {
Jo(e.$$.fragment, i), n = !1;
},
d(i) {
zo(e, i);
}
};
}
function Ko(t, e, n) {
const i = Qo();
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 Bt ? 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 $o extends Wo {
constructor(e) {
super(), qo(this, e, Ko, Yo, Xo, { 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 Q(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 St = 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 di = { decode: function(t, e) {
return Q(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 or(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(or(s, o));
else
i === "style" ? Object.assign(n.style, r) : i === "textContent" ? n.textContent = r : n.setAttribute(i, r.toString());
return n;
}
function fi(t, e, n) {
const i = or(t, e || {});
return n == null || n.appendChild(i), i;
}
var ea = Object.freeze({ __proto__: null, createElement: fi, default: fi });
const ta = { fetchBlob: function(t, e, n) {
return Q(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) {
Q(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) => Q(this, void 0, void 0, function* () {
a += (d == null ? void 0 : d.length) || 0;
const h = Math.round(a / u * 100);
s(h);
}), l = () => Q(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 na extends St {
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 Q(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 Jt extends St {
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 f = (g) => {
g.preventDefault(), g.stopPropagation();
const T = g.clientX, x = g.clientY, R = T - l, B = x - d;
if (h || Math.abs(R) > s || Math.abs(B) > s) {
const A = e.getBoundingClientRect(), { left: E, top: G } = A;
h || (i == null || i(l - E, d - G), h = !0), n(R, B, T - E, x - G), l = T, d = x;
}
}, p = () => {
h && (r == null || r()), u();
}, _ = (g) => {
g.relatedTarget && g.relatedTarget !== document.documentElement || p();
}, b = (g) => {
h && (g.stopPropagation(), g.preventDefault());
}, y = (g) => {
h && g.preventDefault();
};
document.addEventListener("pointermove", f), document.addEventListener("pointerup", p), document.addEventListener("pointerout", _), document.addEventListener("pointercancel", _), document.addEventListener("touchmove", y, { passive: !1 }), document.addEventListener("click", b, { capture: !0 }), u = () => {
document.removeEventListener("pointermove", f), document.removeEventListener("pointerup", p), document.removeEventListener("pointerout", _), document.removeEventListener("pointercancel", _), document.removeEventListener("touchmove", y), setTimeout(() => {
document.removeEventListener("click", b, { 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, f = n.barGap ? n.barGap * d : n.barWidth ? h / 2 : 0, p = n.barRadius || 0, _ = a / (h + f) / u, b = p && "roundRect" in i ? "roundRect" : "rect";
i.beginPath();
let y = 0, g = 0, T = 0;
for (let x = 0; x <= u; x++) {
const R = Math.round(x * _);
if (R > y) {
const E = Math.round(g * l * r), G = E + Math.round(T * l * r) || 1;
let V = l - E;
n.barAlign === "top" ? V = 0 : n.barAlign === "bottom" && (V = c - G), i[b](y * (h + f), V, h, G, p), y = R, g = 0, T = 0;
}
const B = Math.abs(s[x] || 0), A = Math.abs(o[x] || 0);
B > g && (g = B), A > T && (T = A);
}
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, f = 0;
for (let p = 0; p <= a; p++) {
const _ = Math.round(p * d);
if (_ > h) {
const y = l + (Math.round(f * l * r) || 1) * (o === 0 ? -1 : 1);
i.lineTo(h, y), h = _, f = 0;
}
const b = Math.abs(u[p] || 0);
b > f && (f = b);
}
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((f) => f.slice(s, o)), n, h), l.width > 0 && l.height > 0) {
const f = l.cloneNode(), p = f.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(f);
}
}
renderChannel(e, n, i) {
return Q(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 = (y, g) => {
this.renderSingleCanvas(e, n, i, s, Math.max(0, y), Math.min(g, u), r, o);
};
if (!this.isScrollable)
return void a(0, u);
const { scrollLeft: c, scrollWidth: l, clientWidth: d } = this.scrollContainer, h = u / l;
let f = Math.min(Jt.MAX_CANVAS_WIDTH, d);
if (n.barWidth || n.barGap) {
const y = n.barWidth || 0.5, g = y + (n.barGap || y / 2);
f % g != 0 && (f = Math.floor(f / g) * g);
}
const p = Math.floor(Math.abs(c) * h), _ = Math.floor(p + f * h), b = _ - p;
b <= 0 || (a(p, _), yield Promise.all([(() => Q(this, void 0, void 0, function* () {
if (p === 0)
return;
const y = this.createDelay();
for (let g = p; g >= 0; g -= b)
yield y(), a(Math.max(0, g - b), g);
}))(), (() => Q(this, void 0, void 0, function* () {
if (_ === u)
return;
const y = this.createDelay();
for (let g = _; g < u; g += b)
yield y(), a(g, Math.min(u, g + b));
}))()]));
});
}
render(e) {
return Q(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 Q(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);
})));
});
}
}
Jt.MAX_CANVAS_WIDTH = 4e3;
class ia extends St {
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 ra extends St {
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 Q(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 Q(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 Q(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 sa = { waveColor: "#999", progressColor: "#555", cursorWidth: 1, minPxPerSec: 0, fillParent: !0, interact: !0, dragToSeek: !1, autoScroll: !0, autoCenter: !0, sampleRate: 8e3 };
class je extends na {
static create(e) {
return new je(e);
}
constructor(e) {
const n = e.media || (e.backend === "WebAudio" ? new ra() : 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({}, sa, e), this.timer = new ia();
const i = n ? void 0 : this.getMediaElement();
this.renderer = new Jt(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 Q(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 ta.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 = di.createBuffer(i, s || 0);
else if (n) {
const o = yield n.arrayBuffer();
this.decodedData = yield di.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 Q(this, void 0, void 0, function* () {
yield this.loadAudio(e, void 0, n, i);
});
}
loadBlob(e, n, i) {
return Q(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 f = 0; f < d.length; f++) {
const p = d[f];
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 Q(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 Q(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();
}
}
je.BasePlugin = class extends St {
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());
}
}, je.dom = ea;
let ar = 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));
}
}, oa = class extends ar {
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 Lt(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 = (y) => {
y.preventDefault(), y.stopPropagation();
const g = y.clientX, T = y.clientY, x = g - c, R = T - l;
if (d || Math.abs(x) > r || Math.abs(R) > r) {
const B = t.getBoundingClientRect(), { left: A, top: E } = B;
d || (n == null || n(c - A, l - E), d = !0), e(x, R, g - A, T - E), c = g, l = T;
}
}, f = () => {
d && (i == null || i()), o();
}, p = (y) => {
y.relatedTarget && y.relatedTarget !== document.documentElement || f();
}, _ = (y) => {
d && (y.stopPropagation(), y.preventDefault());
}, b = (y) => {
d && y.preventDefault();
};
document.addEventListener("pointermove", h), document.addEventListener("pointerup", f), document.addEventListener("pointerout", p), document.addEventListener("pointercancel", p), document.addEventListener("touchmove", b, { passive: !1 }), document.addEventListener("click", _, { capture: !0 }), o = () => {
document.removeEventListener("pointermove", h), document.removeEventListener("pointerup", f), document.removeEventListener("pointerout", p), document.removeEventListener("pointercancel", p), document.removeEventListener("touchmove", b), setTimeout(() => {
document.removeEventListener("click", _, { capture: !0 });
}, 10);
};
};
return t.addEventListener("pointerdown", u), () => {
o(), t.removeEventListener("pointerdown", u);
};
}
function lr(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(lr(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 = lr(t, e || {});
return n == null || n.appendChild(i), i;
}
let mi = class extends ar {
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);
Lt(i, (s) => this.onResize(s, "start"), () => null, () => this.onEndResizing(), 1), Lt(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)), Lt(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;
}
}, aa = class ur extends oa {
constructor(e) {
super(e), this.regions = [], this.regionsContainer = this.initRegionsContainer();
}
static create(e) {
return new ur(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 mi(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 Lt(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(), f = u / h * l, p = (u + 5) / h * l;
s = new mi(Object.assign(Object.assign({}, e), { start: f, 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 la(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 Tn = 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 la(a);
}, Gt = (t, e) => {
t && t.skip(e);
}, Ke = (t, e) => t / 100 * (e || 5);
const {
SvelteComponent: ua,
append: ie,
attr: j,
check_outros: Dt,
create_component: tt,
destroy_component: nt,
detach: Ge,
element: fe,
empty: ca,
group_outros: Ht,
init: ha,
insert: Fe,
listen: Le,
mount_component: it,
noop: bt,
run_all: cr,
safe_not_equal: da,
set_data: fa,
space: Ye,
text: pi,
transition_in: te,
transition_out: re
} = window.__gradio__svelte__internal;
function ma(t) {
let e, n;
return e = new To({}), {
c() {
tt(e.$$.fragment);
},
m(i, r) {
it(e, i, r), n = !0;
},
i(i) {
n || (te(e.$$.fragment, i), n = !0);
},
o(i) {
re(e.$$.fragment, i), n = !1;
},
d(i) {
nt(e, i);
}
};
}
function pa(t) {
let e, n;
return e = new vo({}), {
c() {
tt(e.$$.fragment);
},
m(i, r) {
it(e, i, r), n = !0;
},
i(i) {
n || (te(e.$$.fragment, i), n = !0);
},
o(i) {
re(e.$$.fragment, i), n = !1;
},
d(i) {
nt(e, i);
}
};
}
function _i(t) {
let e, n, i, r, s;
return n = new Fo({}), {
c() {
e = fe("button"), tt(n.$$.fragment), j(e, "class", "action icon svelte-1duohn5"), j(e, "aria-label", "Reset audio");
},
m(o, u) {
Fe(o, e, u), it(n, e, null), i = !0, r || (s = Le(
e,
"click",
/*click_handler_4*/
t[26]
), r = !0);
},
p: bt,
i(o) {
i || (te(n.$$.fragment, o), i = !0);
},
o(o) {
re(n.$$.fragment, o), i = !1;
},
d(o) {
o && Ge(e), nt(n), r = !1, s();
}
};
}
function gi(t) {
let e, n, i, r;
const s = [ga, _a], 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 = ca();
},
m(a, c) {
o[e].m(a, c), Fe(a, i, c), r = !0;
},
p(a, c) {
let l = e;
e = u(a), e === l ? o[e].p(a, c) : (Ht(), re(o[l], 1, 1, () => {
o[l] = null;
}), Dt(), n = o[e], n ? n.p(a, c) : (n = o[e] = s[e](a), n.c()), te(n, 1), n.m(i.parentNode, i));
},
i(a) {
r || (te(n), r = !0);
},
o(a) {
re(n), r = !1;
},
d(a) {
a && Ge(i), o[e].d(a);
}
};
}
function _a(t) {
let e, n, i, r, s;
return {
c() {
e = fe("button"), e.textContent = "Trim", n = Ye(), i = fe("button"), i.textContent = "Cancel", j(e, "class", "text-button svelte-1duohn5"), j(i, "class", "text-button svelte-1duohn5");
},
m(o, u) {
Fe(o, e, u), Fe(o, n, u), Fe(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 && (Ge(e), Ge(n), Ge(i)), r = !1, cr(s);
}
};
}
function ga(t) {
let e, n, i, r, s;
return n = new Ho({}), {
c() {
e = fe("button"), tt(n.$$.fragment), j(e, "class", "action icon svelte-1duohn5"), j(e, "aria-label", "Trim audio to selection");
},
m(o, u) {
Fe(o, e, u), it(n, e, null), i = !0, r || (s = Le(
e,
"click",
/*toggleTrimmingMode*/
t[13]
), r = !0);
},
p: bt,
i(o) {
i || (te(n.$$.fragment, o), i = !0);
},
o(o) {
re(n.$$.fragment, o), i = !1;
},
d(o) {
o && Ge(e), nt(n), r = !1, s();
}
};
}
function ba(t) {
let e, n, i, r, s, o, u, a, c, l, d, h, f, p, _, b, y, g, T, x, R, B, A, E, G, V;
l = new js({});
const ee = [pa, ma], m = [];
function H(v, w) {
return (
/*playing*/
v[4] ? 0 : 1
);
}
p = H(t), _ = m[p] = ee[p](t), T = new so({});
let C = (
/*showRedo*/
t[5] && /*mode*/
t[0] === "" && _i(t)
), k = (
/*interactive*/
t[6] && gi(t)
);
return {
c() {
e = fe("div"), n = fe("button"), i = fe("span"), r = pi(
/*playbackSpeed*/
t[9]
), s = pi("x"), u = Ye(), a = fe("div"), c = fe("button"), tt(l.$$.fragment), h = Ye(), f = fe("button"), _.c(), y = Ye(), g = fe("button"), tt(T.$$.fragment), R = Ye(), B = fe("div"), C && C.c(), A = Ye(), k && k.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 ${Ke(
/*audioDuration*/
t[2],
/*waveform_settings*/
t[8].skip_length
)} seconds`), j(f, "class", "play-pause-button icon svelte-1duohn5"), j(f, "aria-label", b = /*playing*/
t[4] ? (
/*i18n*/
t[3]("common.play")
) : (
/*i18n*/
t[3]("common.pause")
)), j(g, "class", "skip icon svelte-1duohn5"), j(g, "aria-label", x = "Skip forward by " + Ke(
/*audioDuration*/
t[2],
/*waveform_settings*/
t[8].skip_length
) + " seconds"), j(a, "class", "play-pause-wrapper svelte-1duohn5"), j(B, "class", "settings-wrapper svelte-1duohn5"), j(e, "class", "controls svelte-1duohn5"), j(e, "data-testid", "waveform-controls");
},
m(v, w) {
Fe(v, e, w), ie(e, n), ie(n, i), ie(i, r), ie(i, s), ie(e, u), ie(e, a), ie(a, c), it(l, c, null), ie(a, h), ie(a, f), m[p].m(f, null), ie(a, y), ie(a, g), it(T, g, null), ie(e, R), ie(e, B), C && C.m(B, null), ie(B, A), k && k.m(B, null), E = !0, G || (V = [
Le(
n,
"click",
/*click_handler*/
t[22]
),
Le(
c,
"click",
/*click_handler_1*/
t[23]
),
Le(
f,
"click",
/*click_handler_2*/
t[24]
),
Le(
g,
"click",
/*click_handler_3*/
t[25]
)
], G = !0);
},
p(v, [w]) {
(!E || w & /*playbackSpeed*/
512) && fa(
r,
/*playbackSpeed*/
v[9]
), (!E || w & /*playbackSpeed*/
512 && o !== (o = `Adjust playback speed to ${/*playbackSpeeds*/
v[10][
/*playbackSpeeds*/
(v[10].indexOf(
/*playbackSpeed*/
v[9]
) + 1) % /*playbackSpeeds*/
v[10].length
]}x`)) && j(n, "aria-label", o), (!E || w & /*audioDuration, waveform_settings*/
260 && d !== (d = `Skip backwards by ${Ke(
/*audioDuration*/
v[2],
/*waveform_settings*/
v[8].skip_length
)} seconds`)) && j(c, "aria-label", d);
let U = p;
p = H(v), p !== U && (Ht(), re(m[U], 1, 1, () => {
m[U] = null;
}), Dt(), _ = m[p], _ || (_ = m[p] = ee[p](v), _.c()), te(_, 1), _.m(f, null)), (!E || w & /*playing, i18n*/
24 && b !== (b = /*playing*/
v[4] ? (
/*i18n*/
v[3]("common.play")
) : (
/*i18n*/
v[3]("common.pause")
))) && j(f, "aria-label", b), (!E || w & /*audioDuration, waveform_settings*/
260 && x !== (x = "Skip forward by " + Ke(
/*audioDuration*/
v[2],
/*waveform_settings*/
v[8].skip_length
) + " seconds")) && j(g, "aria-label", x), /*showRedo*/
v[5] && /*mode*/
v[0] === "" ? C ? (C.p(v, w), w & /*showRedo, mode*/
33 && te(C, 1)) : (C = _i(v), C.c(), te(C, 1), C.m(B, A)) : C && (Ht(), re(C, 1, 1, () => {
C = null;
}), Dt()), /*interactive*/
v[6] ? k ? (k.p(v, w), w & /*interactive*/
64 && te(k, 1)) : (k = gi(v), k.c(), te(k, 1), k.m(B, null)) : k && (Ht(), re(k, 1, 1, () => {
k = null;
}), Dt());
},
i(v) {
E || (te(l.$$.fragment, v), te(_), te(T.$$.fragment, v), te(C), te(k), E = !0);
},
o(v) {
re(l.$$.fragment, v), re(_), re(T.$$.fragment, v), re(C), re(k), E = !1;
},
d(v) {
v && Ge(e), nt(l), m[p].d(), nt(T), C && C.d(), k && k.d(), G = !1, cr(V);
}
};
}
function Ce(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 va(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: f = {} } = e, { trimDuration: p = 0 } = e, _ = [0.5, 1, 1.5, 2], b = _[1], y, g = null, T, x, R = "";
const B = () => {
n(18, g = y.addRegion({
start: r / 4,
end: r / 2,
color: "hsla(15, 85%, 40%, 0.4)",
drag: !0,
resize: !0
})), n(14, p = g.end - g.start);
}, A = () => {
if (i && y && g) {
const v = g.start, w = g.end;
c(v, w), n(0, l = ""), n(18, g = null);
}
}, E = () => {
Ce([
y,
"optionalAccess",
(v) => v.getRegions,
"call",
(v) => v(),
"access",
(v) => v.forEach,
"call",
(v) => v((w) => {
w.remove();
})
]), Ce([y, "optionalAccess", (v) => v.clearRegions, "call", (v) => v()]);
}, G = () => {
E(), l === "edit" ? n(0, l = "") : (n(0, l = "edit"), B());
}, V = (v, w) => {
let U, N;
g && (v === "left" ? w === "ArrowLeft" ? (U = g.start - 0.05, N = g.end) : (U = g.start + 0.05, N = g.end) : w === "ArrowLeft" ? (U = g.start, N = g.end - 0.05) : (U = g.start, N = g.end + 0.05), g.setOptions({ start: U, end: N }), n(14, p = g.end - g.start));
}, ee = () => {
n(9, b = _[(_.indexOf(b) + 1) % _.length]), i.setPlaybackRate(b);
}, m = () => i.skip(Ke(r, f.skip_length) * -1), H = () => i.playPause(), C = () => i.skip(Ke(r, f.skip_length)), k = () => {
h(), E(), n(0, l = "");
};
return t.$$set = (v) => {
"waveform" in v && n(1, i = v.waveform), "audioDuration" in v && n(2, r = v.audioDuration), "i18n" in v && n(3, s = v.i18n), "playing" in v && n(4, o = v.playing), "showRedo" in v && n(5, u = v.showRedo), "interactive" in v && n(6, a = v.interactive), "handle_trim_audio" in v && n(15, c = v.handle_trim_audio), "mode" in v && n(0, l = v.mode), "container" in v && n(16, d = v.container), "handle_reset_value" in v && n(7, h = v.handle_reset_value), "waveform_settings" in v && n(8, f = v.waveform_settings), "trimDuration" in v && n(14, p = v.trimDuration);
}, t.$$.update = () => {
if (t.$$.dirty & /*waveform*/
2 && n(17, y = i.registerPlugin(aa.create())), t.$$.dirty & /*trimRegion*/
131072 && Ce([
y,
"optionalAccess",
(v) => v.on,
"call",
(v) => v("region-out", (w) => {
w.play();
})
]), t.$$.dirty & /*trimRegion*/
131072 && Ce([
y,
"optionalAccess",
(v) => v.on,
"call",
(v) => v("region-updated", (w) => {
n(14, p = w.end - w.start);
})
]), t.$$.dirty & /*trimRegion*/
131072 && Ce([
y,
"optionalAccess",
(v) => v.on,
"call",
(v) => v("region-clicked", (w, U) => {
U.stopPropagation(), n(18, g = w), w.play();
})
]), t.$$.dirty & /*activeRegion, container, leftRegionHandle, rightRegionHandle, trimRegion*/
2031616 && g) {
const v = d.children[0].shadowRoot;
n(20, x = v.querySelector('[data-resize="right"]')), n(19, T = v.querySelector('[data-resize="left"]')), T && x && (T.setAttribute("role", "button"), x.setAttribute("role", "button"), Ce([
T,
"optionalAccess",
(w) => w.setAttribute,
"call",
(w) => w("aria-label", "Drag to adjust start time")
]), Ce([
x,
"optionalAccess",
(w) => w.setAttribute,
"call",
(w) => w("aria-label", "Drag to adjust end time")
]), Ce([
T,
"optionalAccess",
(w) => w.setAttribute,
"call",
(w) => w("tabindex", "0")
]), Ce([
x,
"optionalAccess",
(w) => w.setAttribute,
"call",
(w) => w("tabindex", "0")
]), T.addEventListener("focus", () => {
y && n(21, R = "left");
}), x.addEventListener("focus", () => {
y && n(21, R = "right");
}));
}
t.$$.dirty & /*trimRegion, activeHandle*/
2228224 && y && window.addEventListener("keydown", (v) => {
v.key === "ArrowLeft" ? V(R, "ArrowLeft") : v.key === "ArrowRight" && V(R, "ArrowRight");
});
}, [
l,
i,
r,
s,
o,
u,
a,
h,
f,
b,
_,
A,
E,
G,
p,
c,
d,
y,
g,
T,
x,
R,
ee,
m,
H,
C,
k
];
}
class hr extends ua {
constructor(e) {
super(), ha(this, e, va, ba, da, {
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: yh, getContext: ya } = window.__gradio__svelte__internal, wa = "WORKER_PROXY_CONTEXT_KEY";
function Ea() {
return ya(wa);
}
function Sa(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 Ca(t) {
if (t == null)
return t;
const e = new URL(t);
if (!Sa(e) || e.protocol !== "http:" && e.protocol !== "https:")
return t;
const n = Ea();
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: xa,
add_flush_callback: bi,
append: ge,
attr: ae,
bind: vi,
binding_callbacks: vt,
check_outros: dr,
create_component: Un,
destroy_component: Gn,
detach: Fn,
element: ke,
empty: Aa,
group_outros: fr,
init: Ta,
insert: Wn,
mount_component: jn,
safe_not_equal: Pa,
set_data: ka,
space: Pt,
text: Ra,
transition_in: He,
transition_out: ze
} = window.__gradio__svelte__internal, { onMount: Ba } = window.__gradio__svelte__internal;
function La(t) {
let e, n, i, r, s, o, u, a, c, l, d, h, f, p = (
/*mode*/
t[0] === "edit" && /*trimDuration*/
t[13] > 0 && yi(t)
), _ = (
/*waveform*/
t[8] && wi(t)
);
return {
c() {
e = ke("div"), n = ke("div"), i = ke("div"), r = Pt(), s = ke("div"), o = ke("time"), o.textContent = "0:00", u = Pt(), a = ke("div"), p && p.c(), c = Pt(), l = ke("time"), l.textContent = "0:00", d = Pt(), _ && _.c(), ae(i, "id", "waveform"), ae(i, "class", "svelte-1iry1ax"), ae(n, "class", "waveform-container svelte-1iry1ax"), ae(o, "id", "time"), ae(o, "class", "svelte-1iry1ax"), ae(l, "id", "duration"), ae(l, "class", "svelte-1iry1ax"), ae(s, "class", "timestamps svelte-1iry1ax"), ae(e, "class", "component-wrapper svelte-1iry1ax"), ae(e, "data-testid", h = /*label*/
t[2] ? "waveform-" + /*label*/
t[2] : "unlabelled-audio");
},
m(b, y) {
Wn(b, e, y), 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), _ && _.m(e, null), f = !0;
},
p(b, y) {
/*mode*/
b[0] === "edit" && /*trimDuration*/
b[13] > 0 ? p ? p.p(b, y) : (p = yi(b), p.c(), p.m(a, c)) : p && (p.d(1), p = null), /*waveform*/
b[8] ? _ ? (_.p(b, y), y & /*waveform*/
256 && He(_, 1)) : (_ = wi(b), _.c(), He(_, 1), _.m(e, null)) : _ && (fr(), ze(_, 1, 1, () => {
_ = null;
}), dr()), (!f || y & /*label*/
4 && h !== (h = /*label*/
b[2] ? "waveform-" + /*label*/
b[2] : "unlabelled-audio")) && ae(e, "data-testid", h);
},
i(b) {
f || (He(_), f = !0);
},
o(b) {
ze(_), f = !1;
},
d(b) {
b && Fn(e), t[18](null), t[19](null), p && p.d(), t[20](null), _ && _.d();
}
};
}
function Da(t) {
let e, n;
return e = new rr({
props: {
size: "small",
$$slots: { default: [Ha] },
$$scope: { ctx: t }
}
}), {
c() {
Un(e.$$.fragment);
},
m(i, r) {
jn(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) {
ze(e.$$.fragment, i), n = !1;
},
d(i) {
Gn(e, i);
}
};
}
function yi(t) {
let e, n = (
/*formatTime*/
t[14](
/*trimDuration*/
t[13]
) + ""
), i;
return {
c() {
e = ke("time"), i = Ra(n), ae(e, "id", "trim-duration"), ae(e, "class", "svelte-1iry1ax");
},
m(r, s) {
Wn(r, e, s), ge(e, i);
},
p(r, s) {
s & /*trimDuration*/
8192 && n !== (n = /*formatTime*/
r[14](
/*trimDuration*/
r[13]
) + "") && ka(i, n);
},
d(r) {
r && Fn(e);
}
};
}
function wi(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 hr({ props: u }), vt.push(() => vi(e, "mode", s)), vt.push(() => vi(e, "trimDuration", o)), {
c() {
Un(e.$$.fragment);
},
m(a, c) {
jn(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], bi(() => n = !1)), !i && c & /*trimDuration*/
8192 && (i = !0, l.trimDuration = /*trimDuration*/
a[13], bi(() => i = !1)), e.$set(l);
},
i(a) {
r || (He(e.$$.fragment, a), r = !0);
},
o(a) {
ze(e.$$.fragment, a), r = !1;
},
d(a) {
Gn(e, a);
}
}
);
}
function Ha(t) {
let e, n;
return e = new sr({}), {
c() {
Un(e.$$.fragment);
},
m(i, r) {
jn(e, i, r), n = !0;
},
i(i) {
n || (He(e.$$.fragment, i), n = !0);
},
o(i) {
ze(e.$$.fragment, i), n = !1;
},
d(i) {
Gn(e, i);
}
};
}
function Oa(t) {
let e, n, i, r;
const s = [Da, La], 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 = Aa();
},
m(a, c) {
o[e].m(a, c), Wn(a, i, c), r = !0;
},
p(a, [c]) {
let l = e;
e = u(a), e === l ? o[e].p(a, c) : (fr(), ze(o[l], 1, 1, () => {
o[l] = null;
}), dr(), 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) {
ze(n), r = !1;
},
d(a) {
a && Fn(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 Ma(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, f, p = !1, _, b, y, g = 0;
const T = (m) => {
const H = Math.floor(m / 60), k = `0${Math.round(m) % 60}`.slice(-2);
return `${H}:${k}`;
}, x = () => {
n(8, f = je.create({
container: h,
url: Pe([i, "optionalAccess", (m) => m.url]),
...c
}));
}, R = async (m, H) => {
n(0, l = "");
const C = f.getDecodedData();
C && await Tn(C, m, H).then(async (k) => {
await u([k], "change"), f.destroy(), x();
}), o("edit");
};
async function B(m) {
await Ca(m).then((H) => {
if (H)
return Pe([
f,
"optionalAccess",
(C) => C.load,
"call",
(C) => C(H)
]);
});
}
Ba(() => {
window.addEventListener("keydown", (m) => {
m.key === "ArrowRight" && l !== "edit" ? Gt(f, 0.1) : m.key === "ArrowLeft" && l !== "edit" && Gt(f, -0.1);
});
});
function A(m) {
vt[m ? "unshift" : "push"](() => {
h = m, n(7, h), n(8, f);
});
}
function E(m) {
vt[m ? "unshift" : "push"](() => {
_ = m, n(9, _), n(8, f);
});
}
function G(m) {
vt[m ? "unshift" : "push"](() => {
b = m, n(10, b), n(8, f);
});
}
function V(m) {
l = m, n(0, l);
}
function ee(m) {
g = m, n(13, g);
}
return t.$$set = (m) => {
"value" in m && n(1, i = m.value), "label" in m && n(2, r = m.label), "i18n" in m && n(3, s = m.i18n), "dispatch" in m && n(16, o = m.dispatch), "dispatch_blob" in m && n(17, u = m.dispatch_blob), "interactive" in m && n(4, a = m.interactive), "waveform_settings" in m && n(5, c = m.waveform_settings), "mode" in m && n(0, l = m.mode), "handle_reset_value" in m && n(6, d = m.handle_reset_value);
}, t.$$.update = () => {
t.$$.dirty & /*container, waveform*/
384 && h !== void 0 && (f !== void 0 && f.destroy(), n(7, h.innerHTML = "", h), x(), n(11, p = !1)), t.$$.dirty & /*waveform, durationRef*/
1280 && Pe([
f,
"optionalAccess",
(m) => m.on,
"call",
(m) => m("decode", (H) => {
n(12, y = H), b && n(10, b.textContent = T(H), b);
})
]), t.$$.dirty & /*waveform, timeRef*/
768 && Pe([
f,
"optionalAccess",
(m) => m.on,
"call",
(m) => m("timeupdate", (H) => _ && n(9, _.textContent = T(H), _))
]), t.$$.dirty & /*waveform, dispatch*/
65792 && Pe([
f,
"optionalAccess",
(m) => m.on,
"call",
(m) => m("finish", () => {
n(11, p = !1), o("stop"), o("end");
})
]), t.$$.dirty & /*waveform, dispatch*/
65792 && Pe([
f,
"optionalAccess",
(m) => m.on,
"call",
(m) => m("pause", () => {
n(11, p = !1), o("pause");
})
]), t.$$.dirty & /*waveform, dispatch*/
65792 && Pe([
f,
"optionalAccess",
(m) => m.on,
"call",
(m) => m("play", () => {
n(11, p = !0), o("play");
})
]), t.$$.dirty & /*value*/
2 && Pe([i, "optionalAccess", (m) => m.url]) && B(i.url);
}, [
l,
i,
r,
s,
a,
c,
d,
h,
f,
_,
b,
p,
y,
g,
T,
R,
o,
u,
A,
E,
G,
V,
ee
];
}
class wh extends xa {
constructor(e) {
super(), Ta(this, e, Ma, Oa, Pa, {
value: 1,
label: 2,
i18n: 3,
dispatch: 16,
dispatch_blob: 17,
interactive: 4,
waveform_settings: 5,
mode: 0,
handle_reset_value: 6
});
}
}
var mn = new Intl.Collator(0, { numeric: 1 }).compare;
function Ei(t, e, n) {
return t = t.split("."), e = e.split("."), mn(t[0], e[0]) || mn(t[1], e[1]) || (e[2] = e.slice(2).join("."), n = /[.-]/.test(t[2] = t.slice(2).join(".")), n == /[.-]/.test(e[2]) ? mn(t[2], e[2]) : n ? -1 : 1);
}
function Re(t, e, n) {
return e.startsWith("http://") || e.startsWith("https://") ? n ? t : e : t + e;
}
function pn(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 mr = /^[^\/]*\/[^\/]*$/, Na = /.*hf\.space\/{0,1}$/;
async function Ia(t, e) {
const n = {};
e && (n.Authorization = `Bearer ${e}`);
const i = t.trim();
if (mr.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,
...pn(s)
};
} catch (r) {
throw new Error("Space metadata could not be loaded." + r.message);
}
if (Na.test(i)) {
const { ws_protocol: r, http_protocol: s, host: o } = pn(i);
return {
space_id: o.replace(".hf.space", ""),
ws_protocol: r,
http_protocol: s,
host: o
};
}
return {
space_id: !1,
...pn(i)
};
}
function Ua(t) {
let e = {};
return t.forEach(({ api_name: n }, i) => {
n && (e[n] = i);
}), e;
}
const Ga = /^(?=[^]*\b[dD]iscussions{0,1}\b)(?=[^]*\b[dD]isabled\b)[^]*$/;
async function Si(t) {
try {
const n = (await fetch(
`https://huggingface.co/api/spaces/${t}/discussions`,
{
method: "HEAD"
}
)).headers.get("x-error-message");
return !(n && Ga.test(n));
} catch {
return !1;
}
}
function Ue(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(Ue(r, e, n));
return i;
}
return t.is_stream ? n == null ? new We({
...t,
url: e + "/stream/" + t.path
}) : new We({
...t,
url: "/proxy=" + n + "stream/" + t.path
}) : new We({
...t,
url: pr(t.path, e, n)
});
}
function Fa(t) {
try {
const e = new URL(t);
return e.protocol === "http:" || e.protocol === "https:";
} catch {
return !1;
}
}
function pr(t, e, n) {
return t == null ? n ? `/proxy=${n}file=` : `${e}/file=` : Fa(t) ? t : n ? `/proxy=${n}file=${t}` : `${e}/file=${t}`;
}
async function Wa(t, e, n = Va) {
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 We({ ...t[o], path: s });
return Ue(u, e, null);
}) : [];
}
)
);
}
async function ja(t, e) {
return t.map(
(n, i) => new We({
path: n.name,
orig_name: n.name,
blob: n,
size: n.size,
mime_type: n.type,
is_stream: e
})
);
}
class We {
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 za = "This application is too busy. Keep trying!", pt = "Connection errored out.";
let _r;
function qa(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 f = 0; f < u.length; f += l) {
const p = u.slice(f, f + l), _ = new FormData();
p.forEach((y) => {
_.append("files", y);
});
try {
var h = await t(`${o}/upload`, {
method: "POST",
body: _,
headers: c
});
} catch {
return { error: pt };
}
const b = await h.json();
d.push(...b);
}
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: ee,
view_api: H,
component_server: m
}, f = d ?? !0;
if ((typeof window > "u" || !("WebSocket" in window)) && !global.Websocket) {
const C = await import("./wrapper-98f94c21-f7f71f53.js");
_r = (await import("./__vite-browser-external-2447137e.js")).Blob, global.WebSocket = C.WebSocket;
}
const { ws_protocol: p, http_protocol: _, host: b, space_id: y } = await Ia(o, l), g = Math.random().toString(36).substring(2), T = {};
let x, R = {}, B = !1;
l && y && (B = await Za(y, l));
async function A(C) {
if (x = C, R = Ua((C == null ? void 0 : C.dependencies) || []), x.auth_required)
return {
config: x,
...h
};
try {
E = await H(x);
} catch (k) {
console.error(`Could not get api details: ${k.message}`);
}
return {
config: x,
...h
};
}
let E;
async function G(C) {
if (c && c(C), C.status === "running")
try {
x = await Ti(
t,
`${_}//${b}`,
l
);
const k = await A(x);
a(k);
} catch (k) {
console.error(k), c && c({
status: "error",
message: "Could not load this space.",
load_status: "error",
detail: "NOT_FOUND"
});
}
}
try {
x = await Ti(
t,
`${_}//${b}`,
l
);
const C = await A(x);
a(C);
} catch (C) {
console.error(C), y ? kn(
y,
mr.test(y) ? "space_name" : "subdomain",
G
) : c && c({
status: "error",
message: "Could not load this space.",
load_status: "error",
detail: "NOT_FOUND"
});
}
function V(C, k, v) {
let w = !1, U = !1, N;
if (typeof C == "number")
N = x.dependencies[C];
else {
const Y = C.replace(/^\//, "");
N = x.dependencies[R[Y]];
}
if (N.types.continuous)
throw new Error(
"Cannot call predict on this function as it may run forever. Use submit instead"
);
return new Promise((Y, ve) => {
const O = ee(C, k, v);
let me;
O.on("data", (le) => {
U && (O.destroy(), Y(le)), w = !0, me = le;
}).on("status", (le) => {
le.stage === "error" && ve(le), le.stage === "complete" && (U = !0, w && (O.destroy(), Y(me)));
});
});
}
function ee(C, k, v) {
let w, U;
if (typeof C == "number")
w = C, U = E.unnamed_endpoints[w];
else {
const X = C.replace(/^\//, "");
w = R[X], U = E.named_endpoints[C.trim()];
}
if (typeof w != "number")
throw new Error(
"There is no endpoint matching that name of fn_index matching that number."
);
let N, Y, ve = x.protocol ?? "sse";
const O = typeof C == "number" ? "/predict" : C;
let me, le = null, pe = !1;
const Ne = {};
let Se = "";
typeof window < "u" && (Se = new URLSearchParams(window.location.search).toString()), s(
`${_}//${Re(b, x.path, !0)}`,
k,
U,
l
).then((X) => {
if (me = { data: X || [], event_data: v, fn_index: w }, Ja(w, x))
z({
type: "status",
endpoint: O,
stage: "pending",
queue: !1,
fn_index: w,
time: /* @__PURE__ */ new Date()
}), n(
`${_}//${Re(b, x.path, !0)}/run${O.startsWith("/") ? O : `/${O}`}${Se ? "?" + Se : ""}`,
{
...me,
session_hash: g
},
l
).then(([W, Z]) => {
const xe = f ? _n(
W.data,
U,
x.root,
x.root_url
) : W.data;
Z == 200 ? (z({
type: "data",
endpoint: O,
fn_index: w,
data: xe,
time: /* @__PURE__ */ new Date()
}), z({
type: "status",
endpoint: O,
fn_index: w,
stage: "complete",
eta: W.average_duration,
queue: !1,
time: /* @__PURE__ */ new Date()
})) : z({
type: "status",
stage: "error",
endpoint: O,
fn_index: w,
message: W.error,
queue: !1,
time: /* @__PURE__ */ new Date()
});
}).catch((W) => {
z({
type: "status",
stage: "error",
message: W.message,
endpoint: O,
fn_index: w,
queue: !1,
time: /* @__PURE__ */ new Date()
});
});
else if (ve == "ws") {
z({
type: "status",
stage: "pending",
queue: !0,
endpoint: O,
fn_index: w,
time: /* @__PURE__ */ new Date()
});
let W = new URL(`${p}://${Re(
b,
x.path,
!0
)}
/queue/join${Se ? "?" + Se : ""}`);
B && W.searchParams.set("__sign", B), N = e(W), N.onclose = (Z) => {
Z.wasClean || z({
type: "status",
stage: "error",
broken: !0,
message: pt,
queue: !0,
endpoint: O,
fn_index: w,
time: /* @__PURE__ */ new Date()
});
}, N.onmessage = function(Z) {
const xe = JSON.parse(Z.data), { type: ue, status: J, data: _e } = Pi(
xe,
T[w]
);
if (ue === "update" && J && !pe)
z({
type: "status",
endpoint: O,
fn_index: w,
time: /* @__PURE__ */ new Date(),
...J
}), J.stage === "error" && N.close();
else if (ue === "hash") {
N.send(JSON.stringify({ fn_index: w, session_hash: g }));
return;
} else
ue === "data" ? N.send(JSON.stringify({ ...me, session_hash: g })) : ue === "complete" ? pe = J : ue === "log" ? z({
type: "log",
log: _e.log,
level: _e.level,
endpoint: O,
fn_index: w
}) : ue === "generating" && z({
type: "status",
time: /* @__PURE__ */ new Date(),
...J,
stage: J == null ? void 0 : J.stage,
queue: !0,
endpoint: O,
fn_index: w
});
_e && (z({
type: "data",
time: /* @__PURE__ */ new Date(),
data: f ? _n(
_e.data,
U,
x.root,
x.root_url
) : _e.data,
endpoint: O,
fn_index: w
}), pe && (z({
type: "status",
time: /* @__PURE__ */ new Date(),
...pe,
stage: J == null ? void 0 : J.stage,
queue: !0,
endpoint: O,
fn_index: w
}), N.close()));
}, Ei(x.version || "2.0.0", "3.6") < 0 && addEventListener(
"open",
() => N.send(JSON.stringify({ hash: g }))
);
} else {
z({
type: "status",
stage: "pending",
queue: !0,
endpoint: O,
fn_index: w,
time: /* @__PURE__ */ new Date()
});
var S = new URLSearchParams({
fn_index: w.toString(),
session_hash: g
}).toString();
let W = new URL(
`${_}//${Re(
b,
x.path,
!0
)}/queue/join?${Se ? Se + "&" : ""}${S}`
);
Y = new EventSource(W), Y.onmessage = async function(Z) {
const xe = JSON.parse(Z.data), { type: ue, status: J, data: _e } = Pi(
xe,
T[w]
);
if (ue === "update" && J && !pe)
z({
type: "status",
endpoint: O,
fn_index: w,
time: /* @__PURE__ */ new Date(),
...J
}), J.stage === "error" && Y.close();
else if (ue === "data") {
le = xe.event_id;
let [ph, $r] = await n(
`${_}//${Re(
b,
x.path,
!0
)}/queue/data`,
{
...me,
session_hash: g,
event_id: le
},
l
);
$r !== 200 && (z({
type: "status",
stage: "error",
message: pt,
queue: !0,
endpoint: O,
fn_index: w,
time: /* @__PURE__ */ new Date()
}), Y.close());
} else
ue === "complete" ? pe = J : ue === "log" ? z({
type: "log",
log: _e.log,
level: _e.level,
endpoint: O,
fn_index: w
}) : ue === "generating" && z({
type: "status",
time: /* @__PURE__ */ new Date(),
...J,
stage: J == null ? void 0 : J.stage,
queue: !0,
endpoint: O,
fn_index: w
});
_e && (z({
type: "data",
time: /* @__PURE__ */ new Date(),
data: f ? _n(
_e.data,
U,
x.root,
x.root_url
) : _e.data,
endpoint: O,
fn_index: w
}), pe && (z({
type: "status",
time: /* @__PURE__ */ new Date(),
...pe,
stage: J == null ? void 0 : J.stage,
queue: !0,
endpoint: O,
fn_index: w
}), Y.close()));
};
}
});
function z(X) {
const W = Ne[X.type] || [];
W == null || W.forEach((Z) => Z(X));
}
function ct(X, S) {
const W = Ne, Z = W[X] || [];
return W[X] = Z, Z == null || Z.push(S), { on: ct, off: Xe, cancel: ht, destroy: dt };
}
function Xe(X, S) {
const W = Ne;
let Z = W[X] || [];
return Z = Z == null ? void 0 : Z.filter((xe) => xe !== S), W[X] = Z, { on: ct, off: Xe, cancel: ht, destroy: dt };
}
async function ht() {
const X = {
stage: "complete",
queue: !1,
time: /* @__PURE__ */ new Date()
};
pe = X, z({
...X,
type: "status",
endpoint: O,
fn_index: w
});
let S = {};
ve === "ws" ? (N && N.readyState === 0 ? N.addEventListener("open", () => {
N.close();
}) : N.close(), S = { fn_index: w, session_hash: g }) : (Y.close(), S = { event_id: le });
try {
await t(
`${_}//${Re(
b,
x.path,
!0
)}/reset`,
{
headers: { "Content-Type": "application/json" },
method: "POST",
body: JSON.stringify(S)
}
);
} catch {
console.warn(
"The `/reset` endpoint could not be called. Subsequent endpoint results may be unreliable."
);
}
}
function dt() {
for (const X in Ne)
Ne[X].forEach((S) => {
Xe(X, S);
});
}
return {
on: ct,
off: Xe,
cancel: ht,
destroy: dt
};
}
async function m(C, k, v) {
var w;
const U = { "Content-Type": "application/json" };
l && (U.Authorization = `Bearer ${l}`);
let N, Y = x.components.find(
(me) => me.id === C
);
(w = Y == null ? void 0 : Y.props) != null && w.root_url ? N = Y.props.root_url : N = `${_}//${Re(
b,
x.path,
!0
)}/`;
const ve = await t(
`${N}component_server/`,
{
method: "POST",
body: JSON.stringify({
data: v,
component_id: C,
fn_name: k,
session_hash: g
}),
headers: U
}
);
if (!ve.ok)
throw new Error(
"Could not connect to component server: " + ve.statusText
);
return await ve.json();
}
async function H(C) {
if (E)
return E;
const k = { "Content-Type": "application/json" };
l && (k.Authorization = `Bearer ${l}`);
let v;
if (Ei(C.version || "2.0.0", "3.30") < 0 ? v = await t(
"https://gradio-space-api-fetcher-v2.hf.space/api",
{
method: "POST",
body: JSON.stringify({
serialize: !1,
config: JSON.stringify(C)
}),
headers: k
}
) : v = await t(`${C.root}/info`, {
headers: k
}), !v.ok)
throw new Error(pt);
let w = await v.json();
return "api" in w && (w = w.api), w.named_endpoints["/predict"] && !w.unnamed_endpoints[0] && (w.unnamed_endpoints[0] = w.named_endpoints["/predict"]), Xa(w, C, R);
}
});
}
async function s(o, u, a, c) {
const l = await Pn(
u,
void 0,
[],
!0,
a
);
return Promise.all(
l.map(async ({ path: d, blob: h, type: f }) => {
if (h) {
const p = (await i(o, [h], c)).files[0];
return { path: d, file_url: p, type: f, name: h == null ? void 0 : h.name };
}
return { path: d, type: f };
})
).then((d) => (d.forEach(({ path: h, file_url: f, type: p, name: _ }) => {
if (p === "Gallery")
Ai(u, f, h);
else if (f) {
const b = new We({ path: f, orig_name: _ });
Ai(u, b, h);
}
}), u));
}
}
const { post_data: Eh, upload_files: Va, client: Sh, handle_blob: Ch } = qa(
fetch,
(...t) => new WebSocket(...t)
);
function _n(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" ? Ue(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) ? [Ue(l[0], n, i), l[1]] : [Ue(l, n, i), null]) : typeof r == "object" && r.path ? Ue(r, n, i) : r;
});
}
function Ci(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 xi(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 Xa(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: Ci(d, l, h, "parameter"),
description: xi(d, h)
})
), i[r][o].returns = a.returns.map(
({ label: c, component: l, type: d, serializer: h }) => ({
label: c,
component: l,
type: Ci(d, l, h, "return"),
description: xi(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 Ai(t, e, n) {
for (; n.length > 1; )
t = t[n.shift()];
t[n.shift()] = e;
}
async function Pn(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 Pn(
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 _r([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 Pn(
t[o],
void 0,
u,
!1,
r
)
);
}
return s;
}
}
return [];
}
function Ja(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 Ti(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 = Re(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 kn(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(() => {
kn(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 Si(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(() => {
kn(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 Si(u)
});
break;
}
}
function Pi(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: za,
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: Qa,
append: be,
attr: P,
binding_callbacks: Ya,
bubble: ki,
check_outros: gr,
create_component: zn,
destroy_block: br,
destroy_component: qn,
detach: se,
element: Oe,
empty: vr,
ensure_array_like: Ft,
group_outros: yr,
init: Ka,
insert: oe,
listen: Vn,
mount_component: Xn,
null_to_empty: Wt,
safe_not_equal: $a,
set_style: Ct,
space: yt,
src_url_equal: jt,
svg_element: Ee,
transition_in: Me,
transition_out: qe,
update_keyed_each: wr
} = window.__gradio__svelte__internal, { createEventDispatcher: el, onMount: xh } = window.__gradio__svelte__internal;
function Ri(t, e, n) {
const i = t.slice();
return i[20] = e[n], i[22] = n, i;
}
function Bi(t, e, n) {
const i = t.slice();
return i[20] = e[n], i[22] = n, i;
}
function tl(t) {
let e, n;
return e = new rr({
props: {
size: "small",
$$slots: { default: [il] },
$$scope: { ctx: t }
}
}), {
c() {
zn(e.$$.fragment);
},
m(i, r) {
Xn(e, i, r), n = !0;
},
p(i, r) {
const s = {};
r & /*$$scope*/
16777216 && (s.$$scope = { dirty: r, ctx: i }), e.$set(s);
},
i(i) {
n || (Me(e.$$.fragment, i), n = !0);
},
o(i) {
qe(e.$$.fragment, i), n = !1;
},
d(i) {
qn(e, i);
}
};
}
function nl(t) {
let e, n, i, r, s, o, u, a, c, l = (
/*show_share_button*/
t[2] && Li(t)
);
function d(p, _) {
return (
/*image*/
p[1] ? sl : rl
);
}
let h = d(t), f = h(t);
return {
c() {
e = Oe("div"), l && l.c(), n = yt(), i = Oe("audio"), s = yt(), f.c(), o = vr(), P(e, "class", "icon-buttons"), jt(i.src, r = /*value*/
t[0].url) || P(i, "src", r), i.controls = !0, P(i, "class", "svelte-1cxvpx");
},
m(p, _) {
oe(p, e, _), l && l.m(e, null), oe(p, n, _), oe(p, i, _), t[18](i), oe(p, s, _), f.m(p, _), oe(p, o, _), u = !0, a || (c = Vn(
i,
"ended",
/*handle_audio_end*/
t[8]
), a = !0);
},
p(p, _) {
/*show_share_button*/
p[2] ? l ? (l.p(p, _), _ & /*show_share_button*/
4 && Me(l, 1)) : (l = Li(p), l.c(), Me(l, 1), l.m(e, null)) : l && (yr(), qe(l, 1, 1, () => {
l = null;
}), gr()), (!u || _ & /*value*/
1 && !jt(i.src, r = /*value*/
p[0].url)) && P(i, "src", r), h === (h = d(p)) && f ? f.p(p, _) : (f.d(1), f = h(p), f && (f.c(), f.m(o.parentNode, o)));
},
i(p) {
u || (Me(l), u = !0);
},
o(p) {
qe(l), u = !1;
},
d(p) {
p && (se(e), se(n), se(i), se(s), se(o)), l && l.d(), t[18](null), f.d(p), a = !1, c();
}
};
}
function il(t) {
let e, n;
return e = new sr({}), {
c() {
zn(e.$$.fragment);
},
m(i, r) {
Xn(e, i, r), n = !0;
},
i(i) {
n || (Me(e.$$.fragment, i), n = !0);
},
o(i) {
qe(e.$$.fragment, i), n = !1;
},
d(i) {
qn(e, i);
}
};
}
function Li(t) {
let e, n;
return e = new $o({
props: {
i18n: (
/*i18n*/
t[3]
),
formatter: (
/*func*/
t[15]
),
value: (
/*value*/
t[0]
)
}
}), e.$on(
"error",
/*error_handler*/
t[16]
), e.$on(
"share",
/*share_handler*/
t[17]
), {
c() {
zn(e.$$.fragment);
},
m(i, r) {
Xn(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 || (Me(e.$$.fragment, i), n = !0);
},
o(i) {
qe(e.$$.fragment, i), n = !1;
},
d(i) {
qn(e, i);
}
};
}
function rl(t) {
let e, n = [], i = /* @__PURE__ */ new Map(), r, s, o, u = Ft(Array(15));
const a = (h) => (
/*i*/
h[22]
);
for (let h = 0; h < u.length; h += 1) {
let f = Ri(t, u, h), p = a(f);
i.set(p, n[h] = Di(p, f));
}
function c(h, f) {
return (
/*isPlaying*/
h[6] ? ol : al
);
}
let l = c(t), d = l(t);
return {
c() {
e = Oe("div");
for (let h = 0; h < n.length; h += 1)
n[h].c();
r = yt(), d.c(), P(e, "class", "circle-container svelte-1cxvpx"), P(e, "role", "button"), P(e, "tabindex", "0"), P(e, "aria-hidden", "true");
},
m(h, f) {
oe(h, e, f);
for (let p = 0; p < n.length; p += 1)
n[p] && n[p].m(e, null);
be(e, r), d.m(e, null), s || (o = Vn(
e,
"click",
/*play_audio*/
t[7]
), s = !0);
},
p(h, f) {
f & /*isPlaying, Array*/
64 && (u = Ft(Array(15)), n = wr(n, f, a, 1, h, u, i, e, br, Di, r, Ri)), l !== (l = c(h)) && (d.d(1), d = l(h), d && (d.c(), d.m(e, null)));
},
d(h) {
h && se(e);
for (let f = 0; f < n.length; f += 1)
n[f].d();
d.d(), s = !1, o();
}
};
}
function sl(t) {
let e, n, i, r, s, o, u = [], a = /* @__PURE__ */ new Map(), c, l;
function d(b, y) {
return (
/*isPlaying*/
b[6] ? ll : ul
);
}
let h = d(t), f = h(t), p = Ft(Array(15));
const _ = (b) => (
/*i*/
b[22]
);
for (let b = 0; b < p.length; b += 1) {
let y = Bi(t, p, b), g = _(y);
a.set(g, u[b] = Hi(g, y));
}
return {
c() {
e = Oe("div"), n = Oe("img"), r = yt(), f.c(), s = yt(), o = Oe("div");
for (let b = 0; b < u.length; b += 1)
u[b].c();
P(n, "class", "image-player svelte-1cxvpx"), jt(n.src, i = /*image_path*/
t[4]) || P(n, "src", i), P(n, "alt", "test"), P(o, "class", "circle-container waveform-image svelte-1cxvpx"), Ct(o, "pointer-events", "none"), P(e, "class", "image-container svelte-1cxvpx"), P(e, "role", "button"), P(e, "tabindex", "0"), P(e, "aria-hidden", "true");
},
m(b, y) {
oe(b, e, y), be(e, n), be(e, r), f.m(e, null), be(e, s), be(e, o);
for (let g = 0; g < u.length; g += 1)
u[g] && u[g].m(o, null);
c || (l = Vn(
e,
"click",
/*play_audio*/
t[7]
), c = !0);
},
p(b, y) {
y & /*image_path*/
16 && !jt(n.src, i = /*image_path*/
b[4]) && P(n, "src", i), h !== (h = d(b)) && (f.d(1), f = h(b), f && (f.c(), f.m(e, s))), y & /*isPlaying, Array*/
64 && (p = Ft(Array(15)), u = wr(u, y, _, 1, b, p, a, o, br, Hi, null, Bi));
},
d(b) {
b && se(e), f.d();
for (let y = 0; y < u.length; y += 1)
u[y].d();
c = !1, l();
}
};
}
function Di(t, e) {
let n, i;
return {
key: t,
first: null,
c() {
n = Oe("div"), P(n, "class", i = Wt(`waveform-bar ${/*isPlaying*/
e[6] ? `waveform-animation-${/*i*/
e[22] % 5}` : ""}`) + " svelte-1cxvpx"), P(n, "style", `height: ${20 + /*i*/
e[22] % 5 * 10}%`), this.first = n;
},
m(r, s) {
oe(r, n, s);
},
p(r, s) {
e = r, s & /*isPlaying*/
64 && i !== (i = Wt(`waveform-bar ${/*isPlaying*/
e[6] ? `waveform-animation-${/*i*/
e[22] % 5}` : ""}`) + " svelte-1cxvpx") && P(n, "class", i);
},
d(r) {
r && se(n);
}
};
}
function ol(t) {
let e, n, i;
return {
c() {
e = Ee("svg"), n = Ee("rect"), i = Ee("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-1cxvpx"), P(e, "viewBox", "0 0 24 24"), Ct(e, "pointer-events", "none");
},
m(r, s) {
oe(r, e, s), be(e, n), be(e, i);
},
d(r) {
r && se(e);
}
};
}
function al(t) {
let e, n;
return {
c() {
e = Ee("svg"), n = Ee("polygon"), P(n, "points", "5,3 19,12 5,21"), P(n, "fill", "#fff"), P(e, "class", "play-icon svelte-1cxvpx"), P(e, "viewBox", "0 0 24 24"), Ct(e, "pointer-events", "none");
},
m(i, r) {
oe(i, e, r), be(e, n);
},
d(i) {
i && se(e);
}
};
}
function ll(t) {
let e, n, i;
return {
c() {
e = Ee("svg"), n = Ee("rect"), i = Ee("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-1cxvpx"), P(e, "viewBox", "0 0 24 24"), Ct(e, "pointer-events", "none");
},
m(r, s) {
oe(r, e, s), be(e, n), be(e, i);
},
d(r) {
r && se(e);
}
};
}
function ul(t) {
let e, n;
return {
c() {
e = Ee("svg"), n = Ee("polygon"), P(n, "points", "5,3 19,12 5,21"), P(n, "fill", "#fff"), P(e, "class", "play-icon svelte-1cxvpx"), P(e, "viewBox", "0 0 24 24"), Ct(e, "pointer-events", "none");
},
m(i, r) {
oe(i, e, r), be(e, n);
},
d(i) {
i && se(e);
}
};
}
function Hi(t, e) {
let n, i;
return {
key: t,
first: null,
c() {
n = Oe("div"), P(n, "class", i = Wt(`waveform-bar ${/*isPlaying*/
e[6] ? `waveform-animation-${/*i*/
e[22] % 5}` : ""}`) + " svelte-1cxvpx"), P(n, "style", `height: ${20 + /*i*/
e[22] % 5 * 10}%`), this.first = n;
},
m(r, s) {
oe(r, n, s);
},
p(r, s) {
e = r, s & /*isPlaying*/
64 && i !== (i = Wt(`waveform-bar ${/*isPlaying*/
e[6] ? `waveform-animation-${/*i*/
e[22] % 5}` : ""}`) + " svelte-1cxvpx") && P(n, "class", i);
},
d(r) {
r && se(n);
}
};
}
function cl(t) {
let e, n, i, r;
const s = [nl, tl], 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 = vr();
},
m(a, c) {
o[e].m(a, c), oe(a, i, c), r = !0;
},
p(a, [c]) {
let l = e;
e = u(a), e === l ? o[e].p(a, c) : (yr(), qe(o[l], 1, 1, () => {
o[l] = null;
}), gr(), n = o[e], n ? n.p(a, c) : (n = o[e] = s[e](a), n.c()), Me(n, 1), n.m(i.parentNode, i));
},
i(a) {
r || (Me(n), r = !0);
},
o(a) {
qe(n), r = !1;
},
d(a) {
a && se(i), o[e].d(a);
}
};
}
function hl(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, f;
const p = el();
let _, b = !1;
function y() {
if (b) {
_.pause(), n(6, b = !1);
return;
} else
_.play(), n(6, b = !0);
}
function g() {
p("end");
}
const T = async (A) => A ? `` : "";
function x(A) {
ki.call(this, t, A);
}
function R(A) {
ki.call(this, t, A);
}
function B(A) {
Ya[A ? "unshift" : "push"](() => {
_ = A, n(5, _);
});
}
return t.$$set = (A) => {
"value" in A && n(0, i = A.value), "image" in A && n(1, r = A.image), "label" in A && n(9, s = A.label), "show_label" in A && n(10, o = A.show_label), "show_download_button" in A && n(11, u = A.show_download_button), "show_share_button" in A && n(2, a = A.show_share_button), "i18n" in A && n(3, c = A.i18n), "waveform_settings" in A && n(12, l = A.waveform_settings), "root" in A && n(13, d = A.root), "proxy_url" in A && n(14, h = A.proxy_url);
}, t.$$.update = () => {
t.$$.dirty & /*image, root, proxy_url*/
24578 && (r instanceof We ? n(4, f = r.path) : n(4, f = pr(r, d, h))), t.$$.dirty & /*value*/
1 && i && p("change", i);
}, [
i,
r,
a,
c,
f,
_,
b,
y,
g,
s,
o,
u,
l,
d,
h,
T,
x,
R,
B
];
}
class dl extends Qa {
constructor(e) {
super(), Ka(this, e, hl, cl, $a, {
value: 0,
image: 1,
label: 9,
show_label: 10,
show_download_button: 11,
show_share_button: 2,
i18n: 3,
waveform_settings: 12,
root: 13,
proxy_url: 14
});
}
}
function et() {
}
function fl(t) {
return t();
}
function ml(t) {
t.forEach(fl);
}
function pl(t) {
return typeof t == "function";
}
function _l(t, e) {
return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
}
function gl(t, ...e) {
if (t == null) {
for (const i of e)
i(void 0);
return et;
}
const n = t.subscribe(...e);
return n.unsubscribe ? () => n.unsubscribe() : n;
}
const Je = [];
function bl(t, e) {
return {
subscribe: Qt(t, e).subscribe
};
}
function Qt(t, e = et) {
let n;
const i = /* @__PURE__ */ new Set();
function r(u) {
if (_l(t, u) && (t = u, n)) {
const a = !Je.length;
for (const c of i)
c[1](), Je.push(c, t);
if (a) {
for (let c = 0; c < Je.length; c += 2)
Je[c][0](Je[c + 1]);
Je.length = 0;
}
}
}
function s(u) {
r(u(t));
}
function o(u, a = et) {
const c = [u, a];
return i.add(c), i.size === 1 && (n = e(r, s) || et), 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 bl(n, (o, u) => {
let a = !1;
const c = [];
let l = 0, d = et;
const h = () => {
if (l)
return;
d();
const p = e(i ? c[0] : c, o, u);
s ? o(p) : d = pl(p) ? p : et;
}, f = r.map(
(p, _) => gl(
p,
(b) => {
c[_] = b, l &= ~(1 << _), a && h();
},
() => {
l |= 1 << _;
}
)
);
return a = !0, h(), function() {
ml(f), d(), a = !1;
};
});
}
function vl(t) {
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
}
var yl = function(e) {
return wl(e) && !El(e);
};
function wl(t) {
return !!t && typeof t == "object";
}
function El(t) {
var e = Object.prototype.toString.call(t);
return e === "[object RegExp]" || e === "[object Date]" || xl(t);
}
var Sl = typeof Symbol == "function" && Symbol.for, Cl = Sl ? Symbol.for("react.element") : 60103;
function xl(t) {
return t.$$typeof === Cl;
}
function Al(t) {
return Array.isArray(t) ? [] : {};
}
function wt(t, e) {
return e.clone !== !1 && e.isMergeableObject(t) ? rt(Al(t), t, e) : t;
}
function Tl(t, e, n) {
return t.concat(e).map(function(i) {
return wt(i, n);
});
}
function Pl(t, e) {
if (!e.customMerge)
return rt;
var n = e.customMerge(t);
return typeof n == "function" ? n : rt;
}
function kl(t) {
return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(t).filter(function(e) {
return Object.propertyIsEnumerable.call(t, e);
}) : [];
}
function Oi(t) {
return Object.keys(t).concat(kl(t));
}
function Er(t, e) {
try {
return e in t;
} catch {
return !1;
}
}
function Rl(t, e) {
return Er(t, e) && !(Object.hasOwnProperty.call(t, e) && Object.propertyIsEnumerable.call(t, e));
}
function Bl(t, e, n) {
var i = {};
return n.isMergeableObject(t) && Oi(t).forEach(function(r) {
i[r] = wt(t[r], n);
}), Oi(e).forEach(function(r) {
Rl(t, r) || (Er(t, r) && n.isMergeableObject(e[r]) ? i[r] = Pl(r, n)(t[r], e[r], n) : i[r] = wt(e[r], n));
}), i;
}
function rt(t, e, n) {
n = n || {}, n.arrayMerge = n.arrayMerge || Tl, n.isMergeableObject = n.isMergeableObject || yl, n.cloneUnlessOtherwiseSpecified = wt;
var i = Array.isArray(e), r = Array.isArray(t), s = i === r;
return s ? i ? n.arrayMerge(t, e, n) : Bl(t, e, n) : wt(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 Ll = rt, Dl = Ll;
const Hl = /* @__PURE__ */ vl(Dl);
var Rn = function(t, e) {
return Rn = 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]);
}, Rn(t, e);
};
function Yt(t, e) {
if (typeof e != "function" && e !== null)
throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
Rn(t, e);
function n() {
this.constructor = t;
}
t.prototype = e === null ? Object.create(e) : (n.prototype = e.prototype, new n());
}
var M = function() {
return M = 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;
}, M.apply(this, arguments);
};
function gn(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 L;
(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";
})(L || (L = {}));
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 Mi(t) {
return t.type === F.literal;
}
function Ol(t) {
return t.type === F.argument;
}
function Sr(t) {
return t.type === F.number;
}
function Cr(t) {
return t.type === F.date;
}
function xr(t) {
return t.type === F.time;
}
function Ar(t) {
return t.type === F.select;
}
function Tr(t) {
return t.type === F.plural;
}
function Ml(t) {
return t.type === F.pound;
}
function Pr(t) {
return t.type === F.tag;
}
function kr(t) {
return !!(t && typeof t == "object" && t.type === st.number);
}
function Bn(t) {
return !!(t && typeof t == "object" && t.type === st.dateTime);
}
var Rr = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/, Nl = /(?:[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 Il(t) {
var e = {};
return t.replace(Nl, 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 Ul = /[\t-\r \x85\u200E\u200F\u2028\u2029]/i;
function Gl(t) {
if (t.length === 0)
throw new Error("Number skeleton cannot be empty");
for (var e = t.split(Ul).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 Fl(t) {
return t.replace(/^(.*?)-/, "");
}
var Ni = /^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g, Br = /^(@+)?(\+|#+)?[rs]?$/g, Wl = /(\*)(0+)|(#+)(0+)|(0+)/g, Lr = /^(0+)$/;
function Ii(t) {
var e = {};
return t[t.length - 1] === "r" ? e.roundingPriority = "morePrecision" : t[t.length - 1] === "s" && (e.roundingPriority = "lessPrecision"), t.replace(Br, 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 Dr(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 jl(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)), !Lr.test(t))
throw new Error("Malformed concise eng/scientific notation");
e.minimumIntegerDigits = t.length;
}
return e;
}
function Ui(t) {
var e = {}, n = Dr(t);
return n || e;
}
function zl(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 = Fl(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 = M(M(M({}, e), { notation: "scientific" }), r.options.reduce(function(a, c) {
return M(M({}, a), Ui(c));
}, {}));
continue;
case "engineering":
e = M(M(M({}, e), { notation: "engineering" }), r.options.reduce(function(a, c) {
return M(M({}, a), Ui(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(Wl, function(a, c, l, d, h, f) {
if (c)
e.minimumIntegerDigits = l.length;
else {
if (d && h)
throw new Error("We currently do not support maximum integer digits");
if (f)
throw new Error("We currently do not support exact integer digits");
}
return "";
});
continue;
}
if (Lr.test(r.stem)) {
e.minimumIntegerDigits = r.stem.length;
continue;
}
if (Ni.test(r.stem)) {
if (r.options.length > 1)
throw new RangeError("Fraction-precision stems only accept a single optional option");
r.stem.replace(Ni, function(a, c, l, d, h, f) {
return l === "*" ? e.minimumFractionDigits = c.length : d && d[0] === "#" ? e.maximumFractionDigits = d.length : h && f ? (e.minimumFractionDigits = h.length, e.maximumFractionDigits = h.length + f.length) : (e.minimumFractionDigits = c.length, e.maximumFractionDigits = c.length), "";
});
var s = r.options[0];
s === "w" ? e = M(M({}, e), { trailingZeroDisplay: "stripIfInteger" }) : s && (e = M(M({}, e), Ii(s)));
continue;
}
if (Br.test(r.stem)) {
e = M(M({}, e), Ii(r.stem));
continue;
}
var o = Dr(r.stem);
o && (e = M(M({}, e), o));
var u = jl(r.stem);
u && (e = M(M({}, e), u));
}
return e;
}
var kt = {
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 ql(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 = Vl(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 Vl(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 = kt[i || ""] || kt[n || ""] || kt["".concat(n, "-001")] || kt["001"];
return r[0];
}
var bn, Xl = new RegExp("^".concat(Rr.source, "*")), Zl = new RegExp("".concat(Rr.source, "*$"));
function D(t, e) {
return { start: t, end: e };
}
var Jl = !!String.prototype.startsWith, Ql = !!String.fromCodePoint, Yl = !!Object.fromEntries, Kl = !!String.prototype.codePointAt, $l = !!String.prototype.trimStart, eu = !!String.prototype.trimEnd, tu = !!Number.isSafeInteger, nu = tu ? Number.isSafeInteger : function(t) {
return typeof t == "number" && isFinite(t) && Math.floor(t) === t && Math.abs(t) <= 9007199254740991;
}, Ln = !0;
try {
var iu = Or("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
Ln = ((bn = iu.exec("a")) === null || bn === void 0 ? void 0 : bn[0]) === "a";
} catch {
Ln = !1;
}
var Gi = Jl ? (
// Native
function(e, n, i) {
return e.startsWith(n, i);
}
) : (
// For IE11
function(e, n, i) {
return e.slice(i, i + n.length) === n;
}
), Dn = Ql ? 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;
}
), Fi = (
// native
Yl ? 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;
}
)
), Hr = Kl ? (
// 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;
}
}
), ru = $l ? (
// Native
function(e) {
return e.trimStart();
}
) : (
// Ponyfill
function(e) {
return e.replace(Xl, "");
}
), su = eu ? (
// Native
function(e) {
return e.trimEnd();
}
) : (
// Ponyfill
function(e) {
return e.replace(Zl, "");
}
);
function Or(t, e) {
return new RegExp(t, e);
}
var Hn;
if (Ln) {
var Wi = Or("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
Hn = function(e, n) {
var i;
Wi.lastIndex = n;
var r = Wi.exec(e);
return (i = r[1]) !== null && i !== void 0 ? i : "";
};
} else
Hn = function(e, n) {
for (var i = []; ; ) {
var r = Hr(e, n);
if (r === void 0 || Mr(r) || uu(r))
break;
i.push(r), n += r >= 65536 ? 2 : 1;
}
return Dn.apply(void 0, i);
};
var ou = (
/** @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: D(u, this.clonePosition())
});
} else if (s === 60 && !this.ignoreTag && this.peek() === 47) {
if (i)
break;
return this.error(L.UNMATCHED_CLOSING_TAG, D(this.clonePosition(), this.clonePosition()));
} else if (s === 60 && !this.ignoreTag && On(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: D(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() || !On(this.char()))
return this.error(L.INVALID_TAG, D(u, this.clonePosition()));
var a = this.clonePosition(), c = this.parseTagName();
return r !== c ? this.error(L.UNMATCHED_CLOSING_TAG, D(a, this.clonePosition())) : (this.bumpSpace(), this.bumpIf(">") ? {
val: {
type: F.tag,
value: r,
children: o,
location: D(i, this.clonePosition())
},
err: null
} : this.error(L.INVALID_TAG, D(u, this.clonePosition())));
} else
return this.error(L.UNCLOSED_TAG, D(i, this.clonePosition()));
} else
return this.error(L.INVALID_TAG, D(i, this.clonePosition()));
}, t.prototype.parseTagName = function() {
var e = this.offset();
for (this.bump(); !this.isEOF() && lu(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 = D(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.
!au(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 Dn.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(), Dn(i));
}, t.prototype.parseArgument = function(e, n) {
var i = this.clonePosition();
if (this.bump(), this.bumpSpace(), this.isEOF())
return this.error(L.EXPECT_ARGUMENT_CLOSING_BRACE, D(i, this.clonePosition()));
if (this.char() === 125)
return this.bump(), this.error(L.EMPTY_ARGUMENT, D(i, this.clonePosition()));
var r = this.parseIdentifierIfPossible().value;
if (!r)
return this.error(L.MALFORMED_ARGUMENT, D(i, this.clonePosition()));
if (this.bumpSpace(), this.isEOF())
return this.error(L.EXPECT_ARGUMENT_CLOSING_BRACE, D(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: D(i, this.clonePosition())
},
err: null
};
case 44:
return this.bump(), this.bumpSpace(), this.isEOF() ? this.error(L.EXPECT_ARGUMENT_CLOSING_BRACE, D(i, this.clonePosition())) : this.parseArgumentOptions(e, n, r, i);
default:
return this.error(L.MALFORMED_ARGUMENT, D(i, this.clonePosition()));
}
}, t.prototype.parseIdentifierIfPossible = function() {
var e = this.clonePosition(), n = this.offset(), i = Hn(this.message, n), r = n + i.length;
this.bumpTo(r);
var s = this.clonePosition(), o = D(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(L.EXPECT_ARGUMENT_TYPE, D(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 = su(d.val);
if (h.length === 0)
return this.error(L.EXPECT_ARGUMENT_STYLE, D(this.clonePosition(), this.clonePosition()));
var f = D(l, this.clonePosition());
c = { style: h, styleLocation: f };
}
var p = this.tryParseArgumentClose(r);
if (p.err)
return p;
var _ = D(r, this.clonePosition());
if (c && Gi(c == null ? void 0 : c.style, "::", 0)) {
var b = ru(c.style.slice(2));
if (u === "number") {
var d = this.parseNumberSkeletonFromString(b, c.styleLocation);
return d.err ? d : {
val: { type: F.number, value: i, location: _, style: d.val },
err: null
};
} else {
if (b.length === 0)
return this.error(L.EXPECT_DATE_TIME_SKELETON, _);
var y = b;
this.locale && (y = ql(b, this.locale));
var h = {
type: st.dateTime,
pattern: y,
location: c.styleLocation,
parsedOptions: this.shouldParseSkeletons ? Il(y) : {}
}, g = u === "date" ? F.date : F.time;
return {
val: { type: g, value: i, location: _, style: h },
err: null
};
}
}
return {
val: {
type: u === "number" ? F.number : u === "date" ? F.date : F.time,
value: i,
location: _,
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(L.EXPECT_SELECT_ARGUMENT_OPTIONS, D(T, M({}, T)));
this.bumpSpace();
var x = this.parseIdentifierIfPossible(), R = 0;
if (u !== "select" && x.value === "offset") {
if (!this.bumpIf(":"))
return this.error(L.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, D(this.clonePosition(), this.clonePosition()));
this.bumpSpace();
var d = this.tryParseDecimalInteger(L.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, L.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);
if (d.err)
return d;
this.bumpSpace(), x = this.parseIdentifierIfPossible(), R = d.val;
}
var B = this.tryParsePluralOrSelectOptions(e, u, n, x);
if (B.err)
return B;
var p = this.tryParseArgumentClose(r);
if (p.err)
return p;
var A = D(r, this.clonePosition());
return u === "select" ? {
val: {
type: F.select,
value: i,
options: Fi(B.val),
location: A
},
err: null
} : {
val: {
type: F.plural,
value: i,
options: Fi(B.val),
offset: R,
pluralType: u === "plural" ? "cardinal" : "ordinal",
location: A
},
err: null
};
}
default:
return this.error(L.INVALID_ARGUMENT_TYPE, D(o, a));
}
}, t.prototype.tryParseArgumentClose = function(e) {
return this.isEOF() || this.char() !== 125 ? this.error(L.EXPECT_ARGUMENT_CLOSING_BRACE, D(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(L.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE, D(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 = Gl(e);
} catch {
return this.error(L.INVALID_NUMBER_SKELETON, n);
}
return {
val: {
type: st.number,
tokens: i,
location: n,
parsedOptions: this.shouldParseSkeletons ? zl(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(L.EXPECT_PLURAL_ARGUMENT_SELECTOR, L.INVALID_PLURAL_ARGUMENT_SELECTOR);
if (h.err)
return h;
l = D(d, this.clonePosition()), c = this.message.slice(d.offset, this.offset());
} else
break;
}
if (a.has(c))
return this.error(n === "select" ? L.DUPLICATE_SELECT_ARGUMENT_SELECTOR : L.DUPLICATE_PLURAL_ARGUMENT_SELECTOR, l);
c === "other" && (o = !0), this.bumpSpace();
var f = this.clonePosition();
if (!this.bumpIf("{"))
return this.error(n === "select" ? L.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT : L.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT, D(this.clonePosition(), this.clonePosition()));
var p = this.parseMessage(e + 1, n, i);
if (p.err)
return p;
var _ = this.tryParseArgumentClose(f);
if (_.err)
return _;
u.push([
c,
{
value: p.val,
location: D(f, this.clonePosition())
}
]), a.add(c), this.bumpSpace(), s = this.parseIdentifierIfPossible(), c = s.value, l = s.location;
}
return u.length === 0 ? this.error(n === "select" ? L.EXPECT_SELECT_ARGUMENT_SELECTOR : L.EXPECT_PLURAL_ARGUMENT_SELECTOR, D(this.clonePosition(), this.clonePosition())) : this.requiresOtherClause && !o ? this.error(L.MISSING_OTHER_CLAUSE, D(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 = D(r, this.clonePosition());
return s ? (o *= i, nu(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 = Hr(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 (Gi(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() && Mr(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 On(t) {
return t >= 97 && t <= 122 || t >= 65 && t <= 90;
}
function au(t) {
return On(t) || t === 47;
}
function lu(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 Mr(t) {
return t >= 9 && t <= 13 || t === 32 || t === 133 || t >= 8206 && t <= 8207 || t === 8232 || t === 8233;
}
function uu(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 Mn(t) {
t.forEach(function(e) {
if (delete e.location, Ar(e) || Tr(e))
for (var n in e.options)
delete e.options[n].location, Mn(e.options[n].value);
else
Sr(e) && kr(e.style) || (Cr(e) || xr(e)) && Bn(e.style) ? delete e.style.location : Pr(e) && Mn(e.children);
});
}
function cu(t, e) {
e === void 0 && (e = {}), e = M({ shouldParseSkeletons: !0, requiresOtherClause: !0 }, e);
var n = new ou(t, e).parse();
if (n.err) {
var i = SyntaxError(L[n.err.kind]);
throw i.location = n.err.location, i.originalMessage = n.err.message, i;
}
return e != null && e.captureLocation || Mn(n.val), n.val;
}
function vn(t, e) {
var n = e && e.cache ? e.cache : _u, i = e && e.serializer ? e.serializer : pu, r = e && e.strategy ? e.strategy : du;
return r(t, {
cache: n,
serializer: i
});
}
function hu(t) {
return t == null || typeof t == "number" || typeof t == "boolean";
}
function Nr(t, e, n, i) {
var r = hu(i) ? i : n(i), s = e.get(r);
return typeof s > "u" && (s = t.call(this, i), e.set(r, s)), s;
}
function Ir(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 Zn(t, e, n, i, r) {
return n.bind(e, t, i, r);
}
function du(t, e) {
var n = t.length === 1 ? Nr : Ir;
return Zn(t, this, n, e.cache.create(), e.serializer);
}
function fu(t, e) {
return Zn(t, this, Ir, e.cache.create(), e.serializer);
}
function mu(t, e) {
return Zn(t, this, Nr, e.cache.create(), e.serializer);
}
var pu = function() {
return JSON.stringify(arguments);
};
function Jn() {
this.cache = /* @__PURE__ */ Object.create(null);
}
Jn.prototype.get = function(t) {
return this.cache[t];
};
Jn.prototype.set = function(t, e) {
this.cache[t] = e;
};
var _u = {
create: function() {
return new Jn();
}
}, yn = {
variadic: fu,
monadic: mu
}, ot;
(function(t) {
t.MISSING_VALUE = "MISSING_VALUE", t.INVALID_VALUE = "INVALID_VALUE", t.MISSING_INTL_API = "MISSING_INTL_API";
})(ot || (ot = {}));
var Kt = (
/** @class */
function(t) {
Yt(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)
), ji = (
/** @class */
function(t) {
Yt(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;
}(Kt)
), gu = (
/** @class */
function(t) {
Yt(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;
}(Kt)
), bu = (
/** @class */
function(t) {
Yt(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;
}(Kt)
), ne;
(function(t) {
t[t.literal = 0] = "literal", t[t.object = 1] = "object";
})(ne || (ne = {}));
function vu(t) {
return t.length < 2 ? t : t.reduce(function(e, n) {
var i = e[e.length - 1];
return !i || i.type !== ne.literal || n.type !== ne.literal ? e.push(n) : i.value += n.value, e;
}, []);
}
function yu(t) {
return typeof t == "function";
}
function Ot(t, e, n, i, r, s, o) {
if (t.length === 1 && Mi(t[0]))
return [
{
type: ne.literal,
value: t[0].value
}
];
for (var u = [], a = 0, c = t; a < c.length; a++) {
var l = c[a];
if (Mi(l)) {
u.push({
type: ne.literal,
value: l.value
});
continue;
}
if (Ml(l)) {
typeof s == "number" && u.push({
type: ne.literal,
value: n.getNumberFormat(e).format(s)
});
continue;
}
var d = l.value;
if (!(r && d in r))
throw new bu(d, o);
var h = r[d];
if (Ol(l)) {
(!h || typeof h == "string" || typeof h == "number") && (h = typeof h == "string" || typeof h == "number" ? String(h) : ""), u.push({
type: typeof h == "string" ? ne.literal : ne.object,
value: h
});
continue;
}
if (Cr(l)) {
var f = typeof l.style == "string" ? i.date[l.style] : Bn(l.style) ? l.style.parsedOptions : void 0;
u.push({
type: ne.literal,
value: n.getDateTimeFormat(e, f).format(h)
});
continue;
}
if (xr(l)) {
var f = typeof l.style == "string" ? i.time[l.style] : Bn(l.style) ? l.style.parsedOptions : i.time.medium;
u.push({
type: ne.literal,
value: n.getDateTimeFormat(e, f).format(h)
});
continue;
}
if (Sr(l)) {
var f = typeof l.style == "string" ? i.number[l.style] : kr(l.style) ? l.style.parsedOptions : void 0;
f && f.scale && (h = h * (f.scale || 1)), u.push({
type: ne.literal,
value: n.getNumberFormat(e, f).format(h)
});
continue;
}
if (Pr(l)) {
var p = l.children, _ = l.value, b = r[_];
if (!yu(b))
throw new gu(_, "function", o);
var y = Ot(p, e, n, i, r, s), g = b(y.map(function(R) {
return R.value;
}));
Array.isArray(g) || (g = [g]), u.push.apply(u, g.map(function(R) {
return {
type: typeof R == "string" ? ne.literal : ne.object,
value: R
};
}));
}
if (Ar(l)) {
var T = l.options[h] || l.options.other;
if (!T)
throw new ji(l.value, h, Object.keys(l.options), o);
u.push.apply(u, Ot(T.value, e, n, i, r));
continue;
}
if (Tr(l)) {
var T = l.options["=".concat(h)];
if (!T) {
if (!Intl.PluralRules)
throw new Kt(`Intl.PluralRules is not available in this environment.
Try polyfilling it using "@formatjs/intl-pluralrules"
`, ot.MISSING_INTL_API, o);
var x = n.getPluralRules(e, { type: l.pluralType }).select(h - (l.offset || 0));
T = l.options[x] || l.options.other;
}
if (!T)
throw new ji(l.value, h, Object.keys(l.options), o);
u.push.apply(u, Ot(T.value, e, n, i, r, h - (l.offset || 0)));
continue;
}
}
return vu(u);
}
function wu(t, e) {
return e ? M(M(M({}, t || {}), e || {}), Object.keys(t).reduce(function(n, i) {
return n[i] = M(M({}, t[i]), e[i] || {}), n;
}, {})) : t;
}
function Eu(t, e) {
return e ? Object.keys(t).reduce(function(n, i) {
return n[i] = wu(t[i], e[i]), n;
}, M({}, t)) : t;
}
function wn(t) {
return {
create: function() {
return {
get: function(e) {
return t[e];
},
set: function(e, n) {
t[e] = n;
}
};
}
};
}
function Su(t) {
return t === void 0 && (t = {
number: {},
dateTime: {},
pluralRules: {}
}), {
getNumberFormat: vn(function() {
for (var e, n = [], i = 0; i < arguments.length; i++)
n[i] = arguments[i];
return new ((e = Intl.NumberFormat).bind.apply(e, gn([void 0], n, !1)))();
}, {
cache: wn(t.number),
strategy: yn.variadic
}),
getDateTimeFormat: vn(function() {
for (var e, n = [], i = 0; i < arguments.length; i++)
n[i] = arguments[i];
return new ((e = Intl.DateTimeFormat).bind.apply(e, gn([void 0], n, !1)))();
}, {
cache: wn(t.dateTime),
strategy: yn.variadic
}),
getPluralRules: vn(function() {
for (var e, n = [], i = 0; i < arguments.length; i++)
n[i] = arguments[i];
return new ((e = Intl.PluralRules).bind.apply(e, gn([void 0], n, !1)))();
}, {
cache: wn(t.pluralRules),
strategy: yn.variadic
})
};
}
var Cu = (
/** @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 !== ne.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 Ot(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 = Eu(t.formats, i), this.formatters = r && r.formatters || Su(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 = cu, 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 xu(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 = {}, Au = (t, e, n) => n && (e in De || (De[e] = {}), t in De[e] || (De[e][t] = n), n), Ur = (t, e) => {
if (e == null)
return;
if (e in De && t in De[e])
return De[e][t];
const n = $t(e);
for (let i = 0; i < n.length; i++) {
const r = n[i], s = Pu(r, t);
if (s)
return Au(t, e, s);
}
};
let Qn;
const xt = Qt({});
function Tu(t) {
return Qn[t] || null;
}
function Gr(t) {
return t in Qn;
}
function Pu(t, e) {
if (!Gr(t))
return null;
const n = Tu(t);
return xu(n, e);
}
function ku(t) {
if (t == null)
return;
const e = $t(t);
for (let n = 0; n < e.length; n++) {
const i = e[n];
if (Gr(i))
return i;
}
}
function Ru(t, ...e) {
delete De[t], xt.update((n) => (n[t] = Hl.all([n[t] || {}, ...e]), n));
}
lt(
[xt],
([t]) => Object.keys(t)
);
xt.subscribe((t) => Qn = t);
const Mt = {};
function Bu(t, e) {
Mt[t].delete(e), Mt[t].size === 0 && delete Mt[t];
}
function Fr(t) {
return Mt[t];
}
function Lu(t) {
return $t(t).map((e) => {
const n = Fr(e);
return [e, n ? [...n] : []];
}).filter(([, e]) => e.length > 0);
}
function Nn(t) {
return t == null ? !1 : $t(t).some(
(e) => {
var n;
return (n = Fr(e)) == null ? void 0 : n.size;
}
);
}
function Du(t, e) {
return Promise.all(
e.map((i) => (Bu(t, i), i().then((r) => r.default || r)))
).then((i) => Ru(t, ...i));
}
const _t = {};
function Wr(t) {
if (!Nn(t))
return t in _t ? _t[t] : Promise.resolve();
const e = Lu(t);
return _t[t] = Promise.all(
e.map(
([n, i]) => Du(n, i)
)
).then(() => {
if (Nn(t))
return Wr(t);
delete _t[t];
}), _t[t];
}
const Hu = {
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"
}
}
}, Ou = {
fallbackLocale: null,
loadingDelay: 200,
formats: Hu,
warnOnMissingMessages: !0,
handleMissingMessage: void 0,
ignoreTag: !0
}, Mu = Ou;
function at() {
return Mu;
}
const En = Qt(!1);
var Nu = Object.defineProperty, Iu = Object.defineProperties, Uu = Object.getOwnPropertyDescriptors, zi = Object.getOwnPropertySymbols, Gu = Object.prototype.hasOwnProperty, Fu = Object.prototype.propertyIsEnumerable, qi = (t, e, n) => e in t ? Nu(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, Wu = (t, e) => {
for (var n in e || (e = {}))
Gu.call(e, n) && qi(t, n, e[n]);
if (zi)
for (var n of zi(e))
Fu.call(e, n) && qi(t, n, e[n]);
return t;
}, ju = (t, e) => Iu(t, Uu(e));
let In;
const zt = Qt(null);
function Vi(t) {
return t.split("-").map((e, n, i) => i.slice(0, n + 1).join("-")).reverse();
}
function $t(t, e = at().fallbackLocale) {
const n = Vi(t);
return e ? [.../* @__PURE__ */ new Set([...n, ...Vi(e)])] : n;
}
function Ve() {
return In ?? void 0;
}
zt.subscribe((t) => {
In = t ?? void 0, typeof window < "u" && t != null && document.documentElement.setAttribute("lang", t);
});
const zu = (t) => {
if (t && ku(t) && Nn(t)) {
const { loadingDelay: e } = at();
let n;
return typeof window < "u" && Ve() != null && e ? n = window.setTimeout(
() => En.set(!0),
e
) : En.set(!0), Wr(t).then(() => {
zt.set(t);
}).finally(() => {
clearTimeout(n), En.set(!1);
});
}
return zt.set(t);
}, At = ju(Wu({}, zt), {
set: zu
}), en = (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 qu = Object.defineProperty, qt = Object.getOwnPropertySymbols, jr = Object.prototype.hasOwnProperty, zr = Object.prototype.propertyIsEnumerable, Xi = (t, e, n) => e in t ? qu(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, Yn = (t, e) => {
for (var n in e || (e = {}))
jr.call(e, n) && Xi(t, n, e[n]);
if (qt)
for (var n of qt(e))
zr.call(e, n) && Xi(t, n, e[n]);
return t;
}, ut = (t, e) => {
var n = {};
for (var i in t)
jr.call(t, i) && e.indexOf(i) < 0 && (n[i] = t[i]);
if (t != null && qt)
for (var i of qt(t))
e.indexOf(i) < 0 && zr.call(t, i) && (n[i] = t[i]);
return n;
};
const Et = (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.`);
}, Vu = en(
(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 = Et("number", i)), new Intl.NumberFormat(n, r);
}
), Xu = en(
(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 = Et("date", i) : Object.keys(r).length === 0 && (r = Et("date", "short")), new Intl.DateTimeFormat(n, r);
}
), Zu = en(
(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 = Et("time", i) : Object.keys(r).length === 0 && (r = Et("time", "short")), new Intl.DateTimeFormat(n, r);
}
), Ju = (t = {}) => {
var e = t, {
locale: n = Ve()
} = e, i = ut(e, [
"locale"
]);
return Vu(Yn({ locale: n }, i));
}, Qu = (t = {}) => {
var e = t, {
locale: n = Ve()
} = e, i = ut(e, [
"locale"
]);
return Xu(Yn({ locale: n }, i));
}, Yu = (t = {}) => {
var e = t, {
locale: n = Ve()
} = e, i = ut(e, [
"locale"
]);
return Zu(Yn({ locale: n }, i));
}, Ku = en(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
(t, e = Ve()) => new Cu(t, e, at().formats, {
ignoreTag: at().ignoreTag
})
), $u = (t, e = {}) => {
var n, i, r, s;
let o = e;
typeof t == "object" && (o = t, t = o.id);
const {
values: u,
locale: a = Ve(),
default: c
} = o;
if (a == null)
throw new Error(
"[svelte-i18n] Cannot format a message without first setting the initial locale."
);
let l = Ur(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 = Ku(l, a).format(u);
} catch (h) {
h instanceof Error && console.warn(
`[svelte-i18n] Message "${t}" has syntax error:`,
h.message
);
}
return d;
}, ec = (t, e) => Yu(e).format(t), tc = (t, e) => Qu(e).format(t), nc = (t, e) => Ju(e).format(t), ic = (t, e = Ve()) => Ur(t, e);
lt([At, xt], () => $u);
lt([At], () => ec);
lt([At], () => tc);
lt([At], () => nc);
lt([At, xt], () => ic);
/*! *****************************************************************************
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 Sn(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 qr {
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 rc extends qr {
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 sc extends qr {
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 oc = ["audio/webm", "audio/wav", "audio/mpeg", "audio/mp4", "audio/mp3"];
class Kn extends rc {
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 sc(), 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 Kn(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), f = new Float32Array(a);
if (this.dataWindow) {
const p = Math.max(0, a - this.dataWindow.length);
f.set(this.dataWindow.slice(-h + s), p);
}
f.set(o, a - s), this.dataWindow = f;
} 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 Sn(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 Sn(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 || oc.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 Sn(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: ac,
attr: $n,
binding_callbacks: Zi,
detach: ei,
element: ti,
init: lc,
insert: ni,
listen: Vr,
noop: Vt,
safe_not_equal: uc
} = window.__gradio__svelte__internal, { onMount: cc } = window.__gradio__svelte__internal;
function hc(t) {
let e, n, i;
return {
c() {
e = ti("button"), e.innerHTML = '
', $n(e, "class", "stop-button svelte-g0zaxm");
},
m(r, s) {
ni(r, e, s), t[7](e), n || (i = Vr(
e,
"click",
/*record_click*/
t[3]
), n = !0);
},
p: Vt,
d(r) {
r && ei(e), t[7](null), n = !1, i();
}
};
}
function dc(t) {
let e, n, i;
return {
c() {
e = ti("button"), e.innerHTML = '
', $n(e, "class", "record-button svelte-g0zaxm");
},
m(r, s) {
ni(r, e, s), t[6](e), n || (i = Vr(
e,
"click",
/*record_click*/
t[3]
), n = !0);
},
p: Vt,
d(r) {
r && ei(e), t[6](null), n = !1, i();
}
};
}
function fc(t) {
let e;
function n(s, o) {
return (
/*isRecording*/
s[2] ? hc : dc
);
}
let i = n(t), r = i(t);
return {
c() {
e = ti("div"), r.c(), $n(e, "class", "wrapper svelte-g0zaxm");
},
m(s, o) {
ni(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: Vt,
o: Vt,
d(s) {
s && ei(e), r.d();
}
};
}
function mc(t, e, n) {
let { record: i } = e, { dispatch: r } = e, s, o;
cc(() => {
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) {
Zi[d ? "unshift" : "push"](() => {
s = d, n(0, s);
});
}
function l(d) {
Zi[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 pc extends ac {
constructor(e) {
super(), lc(this, e, mc, fc, uc, { record: 4, dispatch: 5 });
}
}
const {
SvelteComponent: _c,
add_flush_callback: Nt,
append: Cn,
attr: Rt,
bind: It,
binding_callbacks: Ut,
check_outros: Ji,
create_component: Xr,
destroy_component: Zr,
detach: gc,
element: Qi,
group_outros: Yi,
init: bc,
insert: vc,
mount_component: Jr,
safe_not_equal: yc,
space: Ki,
transition_in: Be,
transition_out: $e
} = window.__gradio__svelte__internal, { onMount: wc } = window.__gradio__svelte__internal;
function $i(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 pc({ props: s }), Ut.push(() => It(e, "record", r)), {
c() {
Xr(e.$$.fragment);
},
m(o, u) {
Jr(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], Nt(() => n = !1)), e.$set(a);
},
i(o) {
i || (Be(e.$$.fragment, o), i = !0);
},
o(o) {
$e(e.$$.fragment, o), i = !1;
},
d(o) {
Zr(e, o);
}
}
);
}
function er(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 hr({ props: c }), Ut.push(() => It(e, "waveform", o)), Ut.push(() => It(e, "trimDuration", u)), Ut.push(() => It(e, "mode", a)), {
c() {
Xr(e.$$.fragment);
},
m(l, d) {
Jr(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], Nt(() => n = !1)), !i && d & /*trimDuration*/
2048 && (i = !0, h.trimDuration = /*trimDuration*/
l[11], Nt(() => i = !1)), !r && d & /*mode*/
1 && (r = !0, h.mode = /*mode*/
l[0], Nt(() => r = !1)), e.$set(h);
},
i(l) {
s || (Be(e.$$.fragment, l), s = !0);
},
o(l) {
$e(e.$$.fragment, l), s = !1;
},
d(l) {
Zr(e, l);
}
}
);
}
function Ec(t) {
let e, n, i, r, s, o = (
/*micWaveform*/
t[8] && !/*recordedAudio*/
t[7] && $i(t)
), u = (
/*recordingWaveform*/
t[5] && /*recordedAudio*/
t[7] && er(t)
);
return {
c() {
e = Qi("div"), n = Qi("div"), i = Ki(), o && o.c(), r = Ki(), u && u.c(), Rt(n, "id", "microphone"), Rt(n, "data-testid", "microphone-waveform"), Rt(n, "class", "svelte-1smaui2"), Rt(e, "class", "component-wrapper svelte-1smaui2");
},
m(a, c) {
vc(a, e, c), Cn(e, n), Cn(e, i), o && o.m(e, null), Cn(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 = $i(a), o.c(), Be(o, 1), o.m(e, r)) : o && (Yi(), $e(o, 1, 1, () => {
o = null;
}), Ji()), /*recordingWaveform*/
a[5] && /*recordedAudio*/
a[7] ? u ? (u.p(a, c), c & /*recordingWaveform, recordedAudio*/
160 && Be(u, 1)) : (u = er(a), u.c(), Be(u, 1), u.m(e, null)) : u && (Yi(), $e(u, 1, 1, () => {
u = null;
}), Ji());
},
i(a) {
s || (Be(o), Be(u), s = !0);
},
o(a) {
$e(o), $e(u), s = !1;
},
d(a) {
a && gc(e), o && o.d(), u && u.d();
}
};
}
function we(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 Sc(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, f, p = null, _, b, y, g, T = 0;
const x = () => {
clearInterval(g), n(17, g = setInterval(
() => {
},
1e3
));
}, R = () => {
const m = document.getElementById("microphone");
m && (m.innerHTML = ""), c !== void 0 && c.destroy(), m && (n(8, c = je.create({
...u,
container: m
})), n(6, f = c.registerPlugin(Kn.create())), f.startMic());
}, B = () => {
let m = document.getElementById("recording");
!p || !m || n(5, l = je.create({
container: m,
url: p,
...u
}));
}, A = async (m, H) => {
n(0, i = "edit");
const C = l.getDecodedData();
C && await Tn(C, m, H).then(async (k) => {
await o([k], "change"), l.destroy(), B();
}), s("edit");
};
wc(() => {
R(), window.addEventListener("keydown", (m) => {
m.key === "ArrowRight" ? Gt(l, 0.1) : m.key === "ArrowLeft" && Gt(l, -0.1);
});
});
function E(m) {
f = m, n(6, f);
}
function G(m) {
l = m, n(5, l);
}
function V(m) {
T = m, n(11, T);
}
function ee(m) {
i = m, n(0, i);
}
return t.$$set = (m) => {
"mode" in m && n(0, i = m.mode), "i18n" in m && n(1, r = m.i18n), "dispatch" in m && n(2, s = m.dispatch), "dispatch_blob" in m && n(14, o = m.dispatch_blob), "waveform_settings" in m && n(3, u = m.waveform_settings), "handle_reset_value" in m && n(4, a = m.handle_reset_value);
}, t.$$.update = () => {
t.$$.dirty & /*record, dispatch*/
68 && we([
f,
"optionalAccess",
(m) => m.on,
"call",
(m) => m("record-start", () => {
x(), s("start_recording");
})
]), t.$$.dirty & /*record, interval, dispatch_blob*/
147520 && we([
f,
"optionalAccess",
(m) => m.on,
"call",
(m) => m("record-end", async (H) => {
clearInterval(g);
const C = await H.arrayBuffer(), v = await new AudioContext().decodeAudioData(C);
v && await Tn(v).then(async (w) => {
await o([w], "change"), await o([w], "stop_recording");
});
})
]), t.$$.dirty & /*record, dispatch, interval*/
131140 && we([
f,
"optionalAccess",
(m) => m.on,
"call",
(m) => m("record-pause", () => {
s("pause_recording"), clearInterval(g);
})
]), t.$$.dirty & /*record*/
64 && we([
f,
"optionalAccess",
(m) => m.on,
"call",
(m) => m("record-resume", () => {
x();
})
]), t.$$.dirty & /*recordingWaveform, durationRef*/
65568 && we([
l,
"optionalAccess",
(m) => m.on,
"call",
(m) => m("decode", (H) => {
n(10, y = H);
})
]), t.$$.dirty & /*recordingWaveform, timeRef*/
32800 && we([
l,
"optionalAccess",
(m) => m.on,
"call",
(m) => m("timeupdate", (H) => _)
]), t.$$.dirty & /*recordingWaveform, dispatch*/
36 && we([
l,
"optionalAccess",
(m) => m.on,
"call",
(m) => m("pause", () => {
s("pause"), n(9, d = !1);
})
]), t.$$.dirty & /*recordingWaveform, dispatch*/
36 && we([
l,
"optionalAccess",
(m) => m.on,
"call",
(m) => m("play", () => {
s("play"), n(9, d = !0);
})
]), t.$$.dirty & /*recordingWaveform, dispatch*/
36 && we([
l,
"optionalAccess",
(m) => m.on,
"call",
(m) => m("finish", () => {
s("stop"), s("end"), n(9, d = !1);
})
]), t.$$.dirty & /*record, recordedAudio*/
192 && we([
f,
"optionalAccess",
(m) => m.on,
"call",
(m) => m("record-end", (H) => {
n(7, p = URL.createObjectURL(H));
const C = document.getElementById("microphone"), k = document.getElementById("recording");
C && (C.style.display = "none"), k && p && (k.innerHTML = "", B());
})
]);
}, [
i,
r,
s,
u,
a,
l,
f,
p,
c,
d,
y,
T,
h,
A,
o,
_,
b,
g,
E,
G,
V,
ee
];
}
class Cc extends _c {
constructor(e) {
super(), bc(this, e, Sc, Ec, yc, {
mode: 0,
i18n: 1,
dispatch: 2,
dispatch_blob: 14,
waveform_settings: 3,
handle_reset_value: 4
});
}
}
const {
SvelteComponent: xc,
add_flush_callback: Ac,
bind: Tc,
binding_callbacks: Pc,
create_component: kc,
destroy_component: Rc,
init: Bc,
mount_component: Lc,
safe_not_equal: Dc,
transition_in: Hc,
transition_out: Oc
} = window.__gradio__svelte__internal, { onMount: Ah, onDestroy: Mc, createEventDispatcher: Nc } = window.__gradio__svelte__internal;
function Ic(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 Cc({ props: s }), Pc.push(() => Tc(e, "mode", r)), {
c() {
kc(e.$$.fragment);
},
m(o, u) {
Lc(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], Ac(() => n = !1)), e.$set(a);
},
i(o) {
i || (Hc(e.$$.fragment, o), i = !0);
},
o(o) {
Oc(e.$$.fragment, o), i = !1;
},
d(o) {
Rc(e, o);
}
}
);
}
async function Uc(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 Gc(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: f } = e, { handle_reset_value: p = () => {
} } = e, _, b = "", y, g = [], T = !1;
function x() {
import("./module-d647edd9.js"), import("./module-ef7e7a9a.js");
}
c && x();
const R = Nc(), B = async (E, G) => {
let V = new File(E, "audio.wav");
const ee = await ja([V], G === "stream");
n(6, i = (await Uc([
await Wa(ee, s),
"optionalAccess",
async (m) => m.filter,
"call",
async (m) => m(Boolean)
]))[0]), R(G, i);
};
Mc(() => {
c && _ && _.state !== "inactive" && _.stop();
});
function A(E) {
b = E, n(3, b);
}
return t.$$set = (E) => {
"value" in E && n(6, i = E.value), "label" in E && n(7, r = E.label), "root" in E && n(8, s = E.root), "show_label" in E && n(9, o = E.show_label), "sources" in E && n(10, u = E.sources), "pending" in E && n(11, a = E.pending), "streaming" in E && n(12, c = E.streaming), "i18n" in E && n(0, l = E.i18n), "waveform_settings" in E && n(1, d = E.waveform_settings), "dragging" in E && n(13, h = E.dragging), "active_source" in E && n(14, f = E.active_source), "handle_reset_value" in E && n(2, p = E.handle_reset_value);
}, t.$$.update = () => {
t.$$.dirty & /*dragging*/
8192 && R("drag", h), t.$$.dirty & /*submit_pending_stream_on_pending_end, pending, header, pending_stream*/
231424;
}, [
l,
d,
p,
b,
R,
B,
i,
r,
s,
o,
u,
a,
c,
h,
f,
y,
g,
T,
A
];
}
class Fc extends xc {
constructor(e) {
super(), Bc(this, e, Gc, Ic, Dc, {
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: Wc,
add_flush_callback: jc,
bind: zc,
binding_callbacks: qc,
check_outros: Vc,
create_component: Qr,
destroy_component: Yr,
detach: Xc,
empty: Zc,
flush: q,
group_outros: Jc,
init: Qc,
insert: Yc,
mount_component: Kr,
safe_not_equal: Kc,
transition_in: Xt,
transition_out: Zt
} = window.__gradio__svelte__internal;
function $c(t) {
let e, n, i;
function r(o) {
t[33](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 Fc({ props: s }), qc.push(() => zc(e, "dragging", r)), e.$on(
"change",
/*change_handler*/
t[34]
), e.$on(
"stream",
/*stream_handler*/
t[35]
), e.$on(
"drag",
/*drag_handler*/
t[36]
), e.$on(
"edit",
/*edit_handler*/
t[37]
), e.$on(
"play",
/*play_handler*/
t[38]
), e.$on(
"pause",
/*pause_handler*/
t[39]
), e.$on(
"stop",
/*stop_handler*/
t[40]
), e.$on(
"end",
/*end_handler_1*/
t[41]
), e.$on(
"start_recording",
/*start_recording_handler*/
t[42]
), e.$on(
"pause_recording",
/*pause_recording_handler*/
t[43]
), e.$on(
"stop_recording",
/*stop_recording_handler*/
t[44]
), e.$on(
"upload",
/*upload_handler*/
t[45]
), e.$on(
"clear",
/*clear_handler*/
t[46]
), e.$on(
"error",
/*handle_error*/
t[18]
), {
c() {
Qr(e.$$.fragment);
},
m(o, u) {
Kr(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], jc(() => n = !1)), e.$set(a);
},
i(o) {
i || (Xt(e.$$.fragment, o), i = !0);
},
o(o) {
Zt(e.$$.fragment, o), i = !1;
},
d(o) {
Yr(e, o);
}
}
);
}
function eh(t) {
let e, n;
return e = new dl({
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]
), e.$on(
"end",
/*end_handler*/
t[32]
), {
c() {
Qr(e.$$.fragment);
},
m(i, r) {
Kr(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 || (Xt(e.$$.fragment, i), n = !0);
},
o(i) {
Zt(e.$$.fragment, i), n = !1;
},
d(i) {
Yr(e, i);
}
};
}
function th(t) {
let e, n, i, r;
const s = [eh, $c], 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 = Zc();
},
m(a, c) {
o[e].m(a, c), Yc(a, i, c), r = !0;
},
p(a, c) {
let l = e;
e = u(a), e === l ? o[e].p(a, c) : (Jc(), Zt(o[l], 1, 1, () => {
o[l] = null;
}), Vc(), n = o[e], n ? n.p(a, c) : (n = o[e] = s[e](a), n.c()), Xt(n, 1), n.m(i.parentNode, i));
},
i(a) {
r || (Xt(n), r = !0);
},
o(a) {
Zt(n), r = !1;
},
d(a) {
a && Xc(i), o[e].d(a);
}
};
}
function nh(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: f } = e, { container: p = !0 } = e, { scale: _ = null } = e, { min_width: b = void 0 } = e, { loading_status: y } = e, { autoplay: g = !1 } = e, { show_download_button: T = !0 } = e, { show_share_button: x = !1 } = e, { waveform_options: R = {} } = e, { pending: B } = e, { streaming: A } = e, { gradio: E } = e, G = null, V, ee, m = u;
const H = () => {
m === null || u === m || n(0, u = m);
};
let C;
const k = {
height: 50,
waveColor: R.waveform_color || "#9ca3af",
progressColor: R.waveform_progress_color || "#f97316",
barWidth: 2,
barGap: 3,
barHeight: 4,
cursorWidth: 2,
cursorColor: "#ddd5e9",
autoplay: g,
barRadius: 10,
dragToSeek: !0,
mediaControls: R.show_controls
};
function v({ detail: S }) {
const [W, Z] = S.includes("Invalid file type") ? ["warning", "complete"] : ["error", "error"];
n(19, y = y || {}), n(19, y.status = Z, y), n(19, y.message = S, y), E.dispatch(W, S);
}
const w = (S) => E.dispatch("share", S.detail), U = (S) => E.dispatch("error", S.detail), N = () => E.dispatch("end");
function Y(S) {
C = S, n(15, C);
}
const ve = ({ detail: S }) => n(0, u = S), O = ({ detail: S }) => {
n(0, u = S), E.dispatch("stream", u);
}, me = ({ detail: S }) => n(15, C = S), le = () => E.dispatch("edit"), pe = () => E.dispatch("play"), Ne = () => E.dispatch("pause"), Se = () => E.dispatch("stop"), z = () => E.dispatch("end"), ct = () => E.dispatch("start_recording"), Xe = () => E.dispatch("pause_recording"), ht = (S) => E.dispatch("stop_recording", S.detail), dt = () => E.dispatch("upload"), X = () => E.dispatch("clear");
return t.$$set = (S) => {
"elem_id" in S && n(20, i = S.elem_id), "elem_classes" in S && n(21, r = S.elem_classes), "visible" in S && n(22, s = S.visible), "interactive" in S && n(1, o = S.interactive), "value" in S && n(0, u = S.value), "sources" in S && n(2, a = S.sources), "image" in S && n(3, c = S.image), "label" in S && n(4, l = S.label), "root" in S && n(5, d = S.root), "show_label" in S && n(6, h = S.show_label), "proxy_url" in S && n(7, f = S.proxy_url), "container" in S && n(23, p = S.container), "scale" in S && n(24, _ = S.scale), "min_width" in S && n(25, b = S.min_width), "loading_status" in S && n(19, y = S.loading_status), "autoplay" in S && n(26, g = S.autoplay), "show_download_button" in S && n(8, T = S.show_download_button), "show_share_button" in S && n(9, x = S.show_share_button), "waveform_options" in S && n(27, R = S.waveform_options), "pending" in S && n(10, B = S.pending), "streaming" in S && n(11, A = S.streaming), "gradio" in S && n(12, E = S.gradio);
}, t.$$.update = () => {
t.$$.dirty[0] & /*value, root, proxy_url*/
161 && n(13, V = Ue(u, d, f)), t.$$.dirty[0] & /*value, initial_value*/
536870913 && u && m === null && n(29, m = u), t.$$.dirty[0] & /*value, old_value, gradio*/
268439553 && JSON.stringify(u) !== JSON.stringify(G) && (n(28, G = u), E.dispatch("change")), t.$$.dirty[0] & /*sources*/
4 && a && n(14, ee = a[0]);
}, [
u,
o,
a,
c,
l,
d,
h,
f,
T,
x,
B,
A,
E,
V,
ee,
C,
H,
k,
v,
y,
i,
r,
s,
p,
_,
b,
g,
R,
G,
m,
w,
U,
N,
Y,
ve,
O,
me,
le,
pe,
Ne,
Se,
z,
ct,
Xe,
ht,
dt,
X
];
}
class Th extends Wc {
constructor(e) {
super(), Qc(
this,
e,
nh,
th,
Kc,
{
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: ih,
append: rh,
attr: sh,
detach: oh,
element: ah,
init: lh,
insert: uh,
noop: tr,
safe_not_equal: ch,
set_data: hh,
text: dh,
toggle_class: Qe
} = window.__gradio__svelte__internal;
function fh(t) {
let e, n;
return {
c() {
e = ah("div"), n = dh(
/*value*/
t[0]
), sh(e, "class", "svelte-1gecy8w"), Qe(
e,
"table",
/*type*/
t[1] === "table"
), Qe(
e,
"gallery",
/*type*/
t[1] === "gallery"
), Qe(
e,
"selected",
/*selected*/
t[2]
);
},
m(i, r) {
uh(i, e, r), rh(e, n);
},
p(i, [r]) {
r & /*value*/
1 && hh(
n,
/*value*/
i[0]
), r & /*type*/
2 && Qe(
e,
"table",
/*type*/
i[1] === "table"
), r & /*type*/
2 && Qe(
e,
"gallery",
/*type*/
i[1] === "gallery"
), r & /*selected*/
4 && Qe(
e,
"selected",
/*selected*/
i[2]
);
},
i: tr,
o: tr,
d(i) {
i && oh(e);
}
};
}
function mh(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 Ph extends ih {
constructor(e) {
super(), lh(this, e, mh, fh, ch, { value: 0, type: 1, selected: 2 });
}
}
export {
wh as A,
Ph as E,
Th as I,
dl as S,
Fc as a,
vl as g
};