const Ac = [
  { 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 }
], ws = {
  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"
  }
};
Ac.reduce((t, { color: e, primary: n, secondary: i }) => ({
  ...t,
  [e]: {
    primary: ws[e][n],
    secondary: ws[e][i]
  }
}), {});
function Tc(t) {
  let e, n = t[0], i = 1;
  for (; i < t.length; ) {
    const r = t[i], o = t[i + 1];
    if (i += 2, (r === "optionalAccess" || r === "optionalCall") && n == null)
      return;
    r === "access" || r === "optionalAccess" ? (e = n, n = o(n)) : (r === "call" || r === "optionalCall") && (n = o((...s) => n.call(e, ...s)), e = void 0);
  }
  return n;
}
class ji extends Error {
  constructor(e) {
    super(e), this.name = "ShareError";
  }
}
async function Pc(t, e) {
  if (window.__gradio_space__ == null)
    throw new ji("Must be on Spaces to share.");
  let n, i, r;
  if (e === "url") {
    const l = await fetch(t);
    n = await l.blob(), i = l.headers.get("content-type") || "", r = l.headers.get("content-disposition") || "";
  } else
    n = Dc(t), i = t.split(";")[0].split(":")[1], r = "file" + i.split("/")[1];
  const o = new File([n], r, { type: i }), s = await fetch("https://huggingface.co/uploads", {
    method: "POST",
    body: o,
    headers: {
      "Content-Type": o.type,
      "X-Requested-With": "XMLHttpRequest"
    }
  });
  if (!s.ok) {
    if (Tc([s, "access", (l) => l.headers, "access", (l) => l.get, "call", (l) => l("content-type"), "optionalAccess", (l) => l.includes, "call", (l) => l("application/json")])) {
      const l = await s.json();
      throw new ji(`Upload failed: ${l.error}`);
    }
    throw new ji("Upload failed.");
  }
  return await s.text();
}
function Dc(t) {
  for (var e = t.split(","), n = e[0].match(/:(.*?);/)[1], i = atob(e[1]), r = i.length, o = new Uint8Array(r); r--; )
    o[r] = i.charCodeAt(r);
  return new Blob([o], { type: n });
}
const xe = (t) => {
  const e = Math.floor(t / 3600), n = Math.floor(t % 3600 / 60), i = Math.round(t) % 60, r = `${n < 10 ? "0" : ""}${n}`, o = `${i < 10 ? "0" : ""}${i}`;
  return e > 0 ? `${e}:${r}:${o}` : `${n}:${o}`;
};
const {
  SvelteComponent: Mc,
  assign: Rc,
  create_slot: Lc,
  detach: Bc,
  element: Oc,
  get_all_dirty_from_scope: Nc,
  get_slot_changes: Hc,
  get_spread_update: Ic,
  init: Uc,
  insert: jc,
  safe_not_equal: zc,
  set_dynamic_element_data: ys,
  set_style: We,
  toggle_class: ut,
  transition_in: Na,
  transition_out: Ha,
  update_slot_base: Fc
} = window.__gradio__svelte__internal;
function qc(t) {
  let e, n, i;
  const r = (
    /*#slots*/
    t[18].default
  ), o = Lc(
    r,
    t,
    /*$$scope*/
    t[17],
    null
  );
  let s = [
    { "data-testid": (
      /*test_id*/
      t[7]
    ) },
    { id: (
      /*elem_id*/
      t[2]
    ) },
    {
      class: n = "block " + /*elem_classes*/
      t[3].join(" ") + " svelte-nl1om8"
    }
  ], a = {};
  for (let l = 0; l < s.length; l += 1)
    a = Rc(a, s[l]);
  return {
    c() {
      e = Oc(
        /*tag*/
        t[14]
      ), o && o.c(), ys(
        /*tag*/
        t[14]
      )(e, a), ut(
        e,
        "hidden",
        /*visible*/
        t[10] === !1
      ), ut(
        e,
        "padded",
        /*padding*/
        t[6]
      ), ut(
        e,
        "border_focus",
        /*border_mode*/
        t[5] === "focus"
      ), ut(
        e,
        "border_contrast",
        /*border_mode*/
        t[5] === "contrast"
      ), ut(e, "hide-container", !/*explicit_call*/
      t[8] && !/*container*/
      t[9]), We(
        e,
        "height",
        /*get_dimension*/
        t[15](
          /*height*/
          t[0]
        )
      ), We(e, "width", typeof /*width*/
      t[1] == "number" ? `calc(min(${/*width*/
      t[1]}px, 100%))` : (
        /*get_dimension*/
        t[15](
          /*width*/
          t[1]
        )
      )), We(
        e,
        "border-style",
        /*variant*/
        t[4]
      ), We(
        e,
        "overflow",
        /*allow_overflow*/
        t[11] ? "visible" : "hidden"
      ), We(
        e,
        "flex-grow",
        /*scale*/
        t[12]
      ), We(e, "min-width", `calc(min(${/*min_width*/
      t[13]}px, 100%))`), We(e, "border-width", "var(--block-border-width)");
    },
    m(l, u) {
      jc(l, e, u), o && o.m(e, null), i = !0;
    },
    p(l, u) {
      o && o.p && (!i || u & /*$$scope*/
      131072) && Fc(
        o,
        r,
        l,
        /*$$scope*/
        l[17],
        i ? Hc(
          r,
          /*$$scope*/
          l[17],
          u,
          null
        ) : Nc(
          /*$$scope*/
          l[17]
        ),
        null
      ), ys(
        /*tag*/
        l[14]
      )(e, a = Ic(s, [
        (!i || u & /*test_id*/
        128) && { "data-testid": (
          /*test_id*/
          l[7]
        ) },
        (!i || u & /*elem_id*/
        4) && { id: (
          /*elem_id*/
          l[2]
        ) },
        (!i || u & /*elem_classes*/
        8 && n !== (n = "block " + /*elem_classes*/
        l[3].join(" ") + " svelte-nl1om8")) && { class: n }
      ])), ut(
        e,
        "hidden",
        /*visible*/
        l[10] === !1
      ), ut(
        e,
        "padded",
        /*padding*/
        l[6]
      ), ut(
        e,
        "border_focus",
        /*border_mode*/
        l[5] === "focus"
      ), ut(
        e,
        "border_contrast",
        /*border_mode*/
        l[5] === "contrast"
      ), ut(e, "hide-container", !/*explicit_call*/
      l[8] && !/*container*/
      l[9]), u & /*height*/
      1 && We(
        e,
        "height",
        /*get_dimension*/
        l[15](
          /*height*/
          l[0]
        )
      ), u & /*width*/
      2 && We(e, "width", typeof /*width*/
      l[1] == "number" ? `calc(min(${/*width*/
      l[1]}px, 100%))` : (
        /*get_dimension*/
        l[15](
          /*width*/
          l[1]
        )
      )), u & /*variant*/
      16 && We(
        e,
        "border-style",
        /*variant*/
        l[4]
      ), u & /*allow_overflow*/
      2048 && We(
        e,
        "overflow",
        /*allow_overflow*/
        l[11] ? "visible" : "hidden"
      ), u & /*scale*/
      4096 && We(
        e,
        "flex-grow",
        /*scale*/
        l[12]
      ), u & /*min_width*/
      8192 && We(e, "min-width", `calc(min(${/*min_width*/
      l[13]}px, 100%))`);
    },
    i(l) {
      i || (Na(o, l), i = !0);
    },
    o(l) {
      Ha(o, l), i = !1;
    },
    d(l) {
      l && Bc(e), o && o.d(l);
    }
  };
}
function Wc(t) {
  let e, n = (
    /*tag*/
    t[14] && qc(t)
  );
  return {
    c() {
      n && n.c();
    },
    m(i, r) {
      n && n.m(i, r), e = !0;
    },
    p(i, [r]) {
      /*tag*/
      i[14] && n.p(i, r);
    },
    i(i) {
      e || (Na(n, i), e = !0);
    },
    o(i) {
      Ha(n, i), e = !1;
    },
    d(i) {
      n && n.d(i);
    }
  };
}
function Gc(t, e, n) {
  let { $$slots: i = {}, $$scope: r } = e, { height: o = void 0 } = e, { width: s = void 0 } = e, { elem_id: a = "" } = e, { elem_classes: l = [] } = e, { variant: u = "solid" } = e, { border_mode: c = "base" } = e, { padding: f = !0 } = e, { type: d = "normal" } = e, { test_id: h = void 0 } = e, { explicit_call: _ = !1 } = e, { container: m = !0 } = e, { visible: p = !0 } = e, { allow_overflow: E = !0 } = e, { scale: w = null } = e, { min_width: g = 0 } = e, b = d === "fieldset" ? "fieldset" : "div";
  const T = (C) => {
    if (C !== void 0) {
      if (typeof C == "number")
        return C + "px";
      if (typeof C == "string")
        return C;
    }
  };
  return t.$$set = (C) => {
    "height" in C && n(0, o = C.height), "width" in C && n(1, s = C.width), "elem_id" in C && n(2, a = C.elem_id), "elem_classes" in C && n(3, l = C.elem_classes), "variant" in C && n(4, u = C.variant), "border_mode" in C && n(5, c = C.border_mode), "padding" in C && n(6, f = C.padding), "type" in C && n(16, d = C.type), "test_id" in C && n(7, h = C.test_id), "explicit_call" in C && n(8, _ = C.explicit_call), "container" in C && n(9, m = C.container), "visible" in C && n(10, p = C.visible), "allow_overflow" in C && n(11, E = C.allow_overflow), "scale" in C && n(12, w = C.scale), "min_width" in C && n(13, g = C.min_width), "$$scope" in C && n(17, r = C.$$scope);
  }, [
    o,
    s,
    a,
    l,
    u,
    c,
    f,
    h,
    _,
    m,
    p,
    E,
    w,
    g,
    b,
    T,
    d,
    r,
    i
  ];
}
class Ia extends Mc {
  constructor(e) {
    super(), Uc(this, e, Gc, Wc, zc, {
      height: 0,
      width: 1,
      elem_id: 2,
      elem_classes: 3,
      variant: 4,
      border_mode: 5,
      padding: 6,
      type: 16,
      test_id: 7,
      explicit_call: 8,
      container: 9,
      visible: 10,
      allow_overflow: 11,
      scale: 12,
      min_width: 13
    });
  }
}
const {
  SvelteComponent: Vc,
  append: Br,
  attr: Pi,
  create_component: Xc,
  destroy_component: Zc,
  detach: Jc,
  element: ks,
  init: Yc,
  insert: Qc,
  mount_component: Kc,
  safe_not_equal: xc,
  set_data: $c,
  space: ef,
  text: tf,
  toggle_class: Pt,
  transition_in: nf,
  transition_out: rf
} = window.__gradio__svelte__internal;
function of(t) {
  let e, n, i, r, o, s;
  return i = new /*Icon*/
  t[1]({}), {
    c() {
      e = ks("label"), n = ks("span"), Xc(i.$$.fragment), r = ef(), o = tf(
        /*label*/
        t[0]
      ), Pi(n, "class", "svelte-9gxdi0"), Pi(e, "for", ""), Pi(e, "data-testid", "block-label"), Pi(e, "class", "svelte-9gxdi0"), Pt(e, "hide", !/*show_label*/
      t[2]), Pt(e, "sr-only", !/*show_label*/
      t[2]), Pt(
        e,
        "float",
        /*float*/
        t[4]
      ), Pt(
        e,
        "hide-label",
        /*disable*/
        t[3]
      );
    },
    m(a, l) {
      Qc(a, e, l), Br(e, n), Kc(i, n, null), Br(e, r), Br(e, o), s = !0;
    },
    p(a, [l]) {
      (!s || l & /*label*/
      1) && $c(
        o,
        /*label*/
        a[0]
      ), (!s || l & /*show_label*/
      4) && Pt(e, "hide", !/*show_label*/
      a[2]), (!s || l & /*show_label*/
      4) && Pt(e, "sr-only", !/*show_label*/
      a[2]), (!s || l & /*float*/
      16) && Pt(
        e,
        "float",
        /*float*/
        a[4]
      ), (!s || l & /*disable*/
      8) && Pt(
        e,
        "hide-label",
        /*disable*/
        a[3]
      );
    },
    i(a) {
      s || (nf(i.$$.fragment, a), s = !0);
    },
    o(a) {
      rf(i.$$.fragment, a), s = !1;
    },
    d(a) {
      a && Jc(e), Zc(i);
    }
  };
}
function sf(t, e, n) {
  let { label: i = null } = e, { Icon: r } = e, { show_label: o = !0 } = e, { disable: s = !1 } = e, { float: a = !0 } = e;
  return t.$$set = (l) => {
    "label" in l && n(0, i = l.label), "Icon" in l && n(1, r = l.Icon), "show_label" in l && n(2, o = l.show_label), "disable" in l && n(3, s = l.disable), "float" in l && n(4, a = l.float);
  }, [i, r, o, s, a];
}
class Ua extends Vc {
  constructor(e) {
    super(), Yc(this, e, sf, of, xc, {
      label: 0,
      Icon: 1,
      show_label: 2,
      disable: 3,
      float: 4
    });
  }
}
const {
  SvelteComponent: lf,
  append: So,
  attr: gt,
  bubble: af,
  create_component: uf,
  destroy_component: cf,
  detach: ja,
  element: Ao,
  init: ff,
  insert: za,
  listen: df,
  mount_component: hf,
  safe_not_equal: _f,
  set_data: mf,
  set_style: yn,
  space: pf,
  text: gf,
  toggle_class: Ie,
  transition_in: bf,
  transition_out: vf
} = window.__gradio__svelte__internal;
function Es(t) {
  let e, n;
  return {
    c() {
      e = Ao("span"), n = gf(
        /*label*/
        t[1]
      ), gt(e, "class", "svelte-1lrphxw");
    },
    m(i, r) {
      za(i, e, r), So(e, n);
    },
    p(i, r) {
      r & /*label*/
      2 && mf(
        n,
        /*label*/
        i[1]
      );
    },
    d(i) {
      i && ja(e);
    }
  };
}
function wf(t) {
  let e, n, i, r, o, s, a, l = (
    /*show_label*/
    t[2] && Es(t)
  );
  return r = new /*Icon*/
  t[0]({}), {
    c() {
      e = Ao("button"), l && l.c(), n = pf(), i = Ao("div"), uf(r.$$.fragment), gt(i, "class", "svelte-1lrphxw"), Ie(
        i,
        "small",
        /*size*/
        t[4] === "small"
      ), Ie(
        i,
        "large",
        /*size*/
        t[4] === "large"
      ), Ie(
        i,
        "medium",
        /*size*/
        t[4] === "medium"
      ), e.disabled = /*disabled*/
      t[7], gt(
        e,
        "aria-label",
        /*label*/
        t[1]
      ), gt(
        e,
        "aria-haspopup",
        /*hasPopup*/
        t[8]
      ), gt(
        e,
        "title",
        /*label*/
        t[1]
      ), gt(e, "class", "svelte-1lrphxw"), Ie(
        e,
        "pending",
        /*pending*/
        t[3]
      ), Ie(
        e,
        "padded",
        /*padded*/
        t[5]
      ), Ie(
        e,
        "highlight",
        /*highlight*/
        t[6]
      ), Ie(
        e,
        "transparent",
        /*transparent*/
        t[9]
      ), yn(e, "color", !/*disabled*/
      t[7] && /*_color*/
      t[12] ? (
        /*_color*/
        t[12]
      ) : "var(--block-label-text-color)"), yn(e, "--bg-color", /*disabled*/
      t[7] ? "auto" : (
        /*background*/
        t[10]
      )), yn(
        e,
        "margin-left",
        /*offset*/
        t[11] + "px"
      );
    },
    m(u, c) {
      za(u, e, c), l && l.m(e, null), So(e, n), So(e, i), hf(r, i, null), o = !0, s || (a = df(
        e,
        "click",
        /*click_handler*/
        t[14]
      ), s = !0);
    },
    p(u, [c]) {
      /*show_label*/
      u[2] ? l ? l.p(u, c) : (l = Es(u), l.c(), l.m(e, n)) : l && (l.d(1), l = null), (!o || c & /*size*/
      16) && Ie(
        i,
        "small",
        /*size*/
        u[4] === "small"
      ), (!o || c & /*size*/
      16) && Ie(
        i,
        "large",
        /*size*/
        u[4] === "large"
      ), (!o || c & /*size*/
      16) && Ie(
        i,
        "medium",
        /*size*/
        u[4] === "medium"
      ), (!o || c & /*disabled*/
      128) && (e.disabled = /*disabled*/
      u[7]), (!o || c & /*label*/
      2) && gt(
        e,
        "aria-label",
        /*label*/
        u[1]
      ), (!o || c & /*hasPopup*/
      256) && gt(
        e,
        "aria-haspopup",
        /*hasPopup*/
        u[8]
      ), (!o || c & /*label*/
      2) && gt(
        e,
        "title",
        /*label*/
        u[1]
      ), (!o || c & /*pending*/
      8) && Ie(
        e,
        "pending",
        /*pending*/
        u[3]
      ), (!o || c & /*padded*/
      32) && Ie(
        e,
        "padded",
        /*padded*/
        u[5]
      ), (!o || c & /*highlight*/
      64) && Ie(
        e,
        "highlight",
        /*highlight*/
        u[6]
      ), (!o || c & /*transparent*/
      512) && Ie(
        e,
        "transparent",
        /*transparent*/
        u[9]
      ), c & /*disabled, _color*/
      4224 && yn(e, "color", !/*disabled*/
      u[7] && /*_color*/
      u[12] ? (
        /*_color*/
        u[12]
      ) : "var(--block-label-text-color)"), c & /*disabled, background*/
      1152 && yn(e, "--bg-color", /*disabled*/
      u[7] ? "auto" : (
        /*background*/
        u[10]
      )), c & /*offset*/
      2048 && yn(
        e,
        "margin-left",
        /*offset*/
        u[11] + "px"
      );
    },
    i(u) {
      o || (bf(r.$$.fragment, u), o = !0);
    },
    o(u) {
      vf(r.$$.fragment, u), o = !1;
    },
    d(u) {
      u && ja(e), l && l.d(), cf(r), s = !1, a();
    }
  };
}
function yf(t, e, n) {
  let i, { Icon: r } = e, { label: o = "" } = e, { show_label: s = !1 } = e, { pending: a = !1 } = e, { size: l = "small" } = e, { padded: u = !0 } = e, { highlight: c = !1 } = e, { disabled: f = !1 } = e, { hasPopup: d = !1 } = e, { color: h = "var(--block-label-text-color)" } = e, { transparent: _ = !1 } = e, { background: m = "var(--background-fill-primary)" } = e, { offset: p = 0 } = e;
  function E(w) {
    af.call(this, t, w);
  }
  return t.$$set = (w) => {
    "Icon" in w && n(0, r = w.Icon), "label" in w && n(1, o = w.label), "show_label" in w && n(2, s = w.show_label), "pending" in w && n(3, a = w.pending), "size" in w && n(4, l = w.size), "padded" in w && n(5, u = w.padded), "highlight" in w && n(6, c = w.highlight), "disabled" in w && n(7, f = w.disabled), "hasPopup" in w && n(8, d = w.hasPopup), "color" in w && n(13, h = w.color), "transparent" in w && n(9, _ = w.transparent), "background" in w && n(10, m = w.background), "offset" in w && n(11, p = w.offset);
  }, t.$$.update = () => {
    t.$$.dirty & /*highlight, color*/
    8256 && n(12, i = c ? "var(--color-accent)" : h);
  }, [
    r,
    o,
    s,
    a,
    l,
    u,
    c,
    f,
    d,
    _,
    m,
    p,
    i,
    h,
    E
  ];
}
class Xn extends lf {
  constructor(e) {
    super(), ff(this, e, yf, wf, _f, {
      Icon: 0,
      label: 1,
      show_label: 2,
      pending: 3,
      size: 4,
      padded: 5,
      highlight: 6,
      disabled: 7,
      hasPopup: 8,
      color: 13,
      transparent: 9,
      background: 10,
      offset: 11
    });
  }
}
const {
  SvelteComponent: kf,
  append: Ef,
  attr: Or,
  binding_callbacks: Cf,
  create_slot: Sf,
  detach: Af,
  element: Cs,
  get_all_dirty_from_scope: Tf,
  get_slot_changes: Pf,
  init: Df,
  insert: Mf,
  safe_not_equal: Rf,
  toggle_class: Dt,
  transition_in: Lf,
  transition_out: Bf,
  update_slot_base: Of
} = window.__gradio__svelte__internal;
function Nf(t) {
  let e, n, i;
  const r = (
    /*#slots*/
    t[5].default
  ), o = Sf(
    r,
    t,
    /*$$scope*/
    t[4],
    null
  );
  return {
    c() {
      e = Cs("div"), n = Cs("div"), o && o.c(), Or(n, "class", "icon svelte-3w3rth"), Or(e, "class", "empty svelte-3w3rth"), Or(e, "aria-label", "Empty value"), Dt(
        e,
        "small",
        /*size*/
        t[0] === "small"
      ), Dt(
        e,
        "large",
        /*size*/
        t[0] === "large"
      ), Dt(
        e,
        "unpadded_box",
        /*unpadded_box*/
        t[1]
      ), Dt(
        e,
        "small_parent",
        /*parent_height*/
        t[3]
      );
    },
    m(s, a) {
      Mf(s, e, a), Ef(e, n), o && o.m(n, null), t[6](e), i = !0;
    },
    p(s, [a]) {
      o && o.p && (!i || a & /*$$scope*/
      16) && Of(
        o,
        r,
        s,
        /*$$scope*/
        s[4],
        i ? Pf(
          r,
          /*$$scope*/
          s[4],
          a,
          null
        ) : Tf(
          /*$$scope*/
          s[4]
        ),
        null
      ), (!i || a & /*size*/
      1) && Dt(
        e,
        "small",
        /*size*/
        s[0] === "small"
      ), (!i || a & /*size*/
      1) && Dt(
        e,
        "large",
        /*size*/
        s[0] === "large"
      ), (!i || a & /*unpadded_box*/
      2) && Dt(
        e,
        "unpadded_box",
        /*unpadded_box*/
        s[1]
      ), (!i || a & /*parent_height*/
      8) && Dt(
        e,
        "small_parent",
        /*parent_height*/
        s[3]
      );
    },
    i(s) {
      i || (Lf(o, s), i = !0);
    },
    o(s) {
      Bf(o, s), i = !1;
    },
    d(s) {
      s && Af(e), o && o.d(s), t[6](null);
    }
  };
}
function Hf(t) {
  let e, n = t[0], i = 1;
  for (; i < t.length; ) {
    const r = t[i], o = t[i + 1];
    if (i += 2, (r === "optionalAccess" || r === "optionalCall") && n == null)
      return;
    r === "access" || r === "optionalAccess" ? (e = n, n = o(n)) : (r === "call" || r === "optionalCall") && (n = o((...s) => n.call(e, ...s)), e = void 0);
  }
  return n;
}
function If(t, e, n) {
  let i, { $$slots: r = {}, $$scope: o } = e, { size: s = "small" } = e, { unpadded_box: a = !1 } = e, l;
  function u(f) {
    if (!f)
      return !1;
    const { height: d } = f.getBoundingClientRect(), { height: h } = Hf([
      f,
      "access",
      (_) => _.parentElement,
      "optionalAccess",
      (_) => _.getBoundingClientRect,
      "call",
      (_) => _()
    ]) || { height: d };
    return d > h + 2;
  }
  function c(f) {
    Cf[f ? "unshift" : "push"](() => {
      l = f, n(2, l);
    });
  }
  return t.$$set = (f) => {
    "size" in f && n(0, s = f.size), "unpadded_box" in f && n(1, a = f.unpadded_box), "$$scope" in f && n(4, o = f.$$scope);
  }, t.$$.update = () => {
    t.$$.dirty & /*el*/
    4 && n(3, i = u(l));
  }, [s, a, l, i, o, r, c];
}
class Fa extends kf {
  constructor(e) {
    super(), Df(this, e, If, Nf, Rf, { size: 0, unpadded_box: 1 });
  }
}
const {
  SvelteComponent: Uf,
  append: jf,
  attr: Ze,
  detach: zf,
  init: Ff,
  insert: qf,
  noop: Nr,
  safe_not_equal: Wf,
  svg_element: Ss
} = window.__gradio__svelte__internal;
function Gf(t) {
  let e, n;
  return {
    c() {
      e = Ss("svg"), n = Ss("path"), Ze(n, "stroke", "currentColor"), Ze(n, "stroke-width", "1.5"), Ze(n, "stroke-linecap", "round"), Ze(n, "stroke-linejoin", "round"), Ze(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"), Ze(e, "xmlns", "http://www.w3.org/2000/svg"), Ze(e, "width", "24px"), Ze(e, "height", "24px"), Ze(e, "fill", "currentColor"), Ze(e, "stroke-width", "1.5"), Ze(e, "viewBox", "0 0 24 24"), Ze(e, "color", "currentColor");
    },
    m(i, r) {
      qf(i, e, r), jf(e, n);
    },
    p: Nr,
    i: Nr,
    o: Nr,
    d(i) {
      i && zf(e);
    }
  };
}
class Vf extends Uf {
  constructor(e) {
    super(), Ff(this, e, null, Gf, Wf, {});
  }
}
const {
  SvelteComponent: Xf,
  append: Hr,
  attr: tt,
  detach: Zf,
  init: Jf,
  insert: Yf,
  noop: Ir,
  safe_not_equal: Qf,
  set_style: ct,
  svg_element: Di
} = window.__gradio__svelte__internal;
function Kf(t) {
  let e, n, i, r;
  return {
    c() {
      e = Di("svg"), n = Di("g"), i = Di("path"), r = Di("path"), tt(i, "d", "M18,6L6.087,17.913"), ct(i, "fill", "none"), ct(i, "fill-rule", "nonzero"), ct(i, "stroke-width", "2px"), tt(n, "transform", "matrix(1.14096,-0.140958,-0.140958,1.14096,-0.0559523,0.0559523)"), tt(r, "d", "M4.364,4.364L19.636,19.636"), ct(r, "fill", "none"), ct(r, "fill-rule", "nonzero"), ct(r, "stroke-width", "2px"), tt(e, "width", "100%"), tt(e, "height", "100%"), tt(e, "viewBox", "0 0 24 24"), tt(e, "version", "1.1"), tt(e, "xmlns", "http://www.w3.org/2000/svg"), tt(e, "xmlns:xlink", "http://www.w3.org/1999/xlink"), tt(e, "xml:space", "preserve"), tt(e, "stroke", "currentColor"), ct(e, "fill-rule", "evenodd"), ct(e, "clip-rule", "evenodd"), ct(e, "stroke-linecap", "round"), ct(e, "stroke-linejoin", "round");
    },
    m(o, s) {
      Yf(o, e, s), Hr(e, n), Hr(n, i), Hr(e, r);
    },
    p: Ir,
    i: Ir,
    o: Ir,
    d(o) {
      o && Zf(e);
    }
  };
}
class xf extends Xf {
  constructor(e) {
    super(), Jf(this, e, null, Kf, Qf, {});
  }
}
const {
  SvelteComponent: $f,
  append: ed,
  attr: xn,
  detach: td,
  init: nd,
  insert: id,
  noop: Ur,
  safe_not_equal: rd,
  svg_element: As
} = window.__gradio__svelte__internal;
function od(t) {
  let e, n;
  return {
    c() {
      e = As("svg"), n = As("path"), xn(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"), xn(n, "fill", "currentColor"), xn(e, "id", "icon"), xn(e, "xmlns", "http://www.w3.org/2000/svg"), xn(e, "viewBox", "0 0 32 32");
    },
    m(i, r) {
      id(i, e, r), ed(e, n);
    },
    p: Ur,
    i: Ur,
    o: Ur,
    d(i) {
      i && td(e);
    }
  };
}
class sd extends $f {
  constructor(e) {
    super(), nd(this, e, null, od, rd, {});
  }
}
const {
  SvelteComponent: ld,
  append: ad,
  attr: kn,
  detach: ud,
  init: cd,
  insert: fd,
  noop: jr,
  safe_not_equal: dd,
  svg_element: Ts
} = window.__gradio__svelte__internal;
function hd(t) {
  let e, n;
  return {
    c() {
      e = Ts("svg"), n = Ts("path"), kn(n, "fill", "currentColor"), kn(n, "d", "M26 24v4H6v-4H4v4a2 2 0 0 0 2 2h20a2 2 0 0 0 2-2v-4zm0-10l-1.41-1.41L17 20.17V2h-2v18.17l-7.59-7.58L6 14l10 10l10-10z"), kn(e, "xmlns", "http://www.w3.org/2000/svg"), kn(e, "width", "100%"), kn(e, "height", "100%"), kn(e, "viewBox", "0 0 32 32");
    },
    m(i, r) {
      fd(i, e, r), ad(e, n);
    },
    p: jr,
    i: jr,
    o: jr,
    d(i) {
      i && ud(e);
    }
  };
}
class qa extends ld {
  constructor(e) {
    super(), cd(this, e, null, hd, dd, {});
  }
}
const {
  SvelteComponent: _d,
  append: md,
  attr: nt,
  detach: pd,
  init: gd,
  insert: bd,
  noop: zr,
  safe_not_equal: vd,
  svg_element: Ps
} = window.__gradio__svelte__internal;
function wd(t) {
  let e, n;
  return {
    c() {
      e = Ps("svg"), n = Ps("path"), nt(n, "d", "M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"), nt(e, "xmlns", "http://www.w3.org/2000/svg"), nt(e, "width", "100%"), nt(e, "height", "100%"), nt(e, "viewBox", "0 0 24 24"), nt(e, "fill", "none"), nt(e, "stroke", "currentColor"), nt(e, "stroke-width", "1.5"), nt(e, "stroke-linecap", "round"), nt(e, "stroke-linejoin", "round"), nt(e, "class", "feather feather-edit-2");
    },
    m(i, r) {
      bd(i, e, r), md(e, n);
    },
    p: zr,
    i: zr,
    o: zr,
    d(i) {
      i && pd(e);
    }
  };
}
class yd extends _d {
  constructor(e) {
    super(), gd(this, e, null, wd, vd, {});
  }
}
const {
  SvelteComponent: kd,
  append: Ed,
  attr: Je,
  detach: Cd,
  init: Sd,
  insert: Ad,
  noop: Fr,
  safe_not_equal: Td,
  svg_element: Ds
} = window.__gradio__svelte__internal;
function Pd(t) {
  let e, n;
  return {
    c() {
      e = Ds("svg"), n = Ds("path"), Je(n, "stroke", "currentColor"), Je(n, "stroke-width", "1.5"), Je(n, "stroke-linecap", "round"), Je(n, "stroke-linejoin", "round"), Je(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"), Je(e, "xmlns", "http://www.w3.org/2000/svg"), Je(e, "width", "24px"), Je(e, "height", "24px"), Je(e, "fill", "currentColor"), Je(e, "stroke-width", "1.5"), Je(e, "viewBox", "0 0 24 24"), Je(e, "color", "currentColor");
    },
    m(i, r) {
      Ad(i, e, r), Ed(e, n);
    },
    p: Fr,
    i: Fr,
    o: Fr,
    d(i) {
      i && Cd(e);
    }
  };
}
class Dd extends kd {
  constructor(e) {
    super(), Sd(this, e, null, Pd, Td, {});
  }
}
const {
  SvelteComponent: Md,
  append: Rd,
  attr: Mi,
  detach: Ld,
  init: Bd,
  insert: Od,
  noop: qr,
  safe_not_equal: Nd,
  svg_element: Ms
} = window.__gradio__svelte__internal;
function Hd(t) {
  let e, n;
  return {
    c() {
      e = Ms("svg"), n = Ms("path"), Mi(n, "fill", "currentColor"), Mi(n, "d", "M13.75 2a2.25 2.25 0 0 1 2.236 2.002V4h1.764A2.25 2.25 0 0 1 20 6.25V11h-1.5V6.25a.75.75 0 0 0-.75-.75h-2.129c-.404.603-1.091 1-1.871 1h-3.5c-.78 0-1.467-.397-1.871-1H6.25a.75.75 0 0 0-.75.75v13.5c0 .414.336.75.75.75h4.78a4 4 0 0 0 .505 1.5H6.25A2.25 2.25 0 0 1 4 19.75V6.25A2.25 2.25 0 0 1 6.25 4h1.764a2.25 2.25 0 0 1 2.236-2zm2.245 2.096L16 4.25q0-.078-.005-.154M13.75 3.5h-3.5a.75.75 0 0 0 0 1.5h3.5a.75.75 0 0 0 0-1.5M15 12a3 3 0 0 0-3 3v5c0 .556.151 1.077.415 1.524l3.494-3.494a2.25 2.25 0 0 1 3.182 0l3.494 3.494c.264-.447.415-.968.415-1.524v-5a3 3 0 0 0-3-3zm0 11a3 3 0 0 1-1.524-.415l3.494-3.494a.75.75 0 0 1 1.06 0l3.494 3.494A3 3 0 0 1 20 23zm5-7a1 1 0 1 1 0-2 1 1 0 0 1 0 2"), Mi(e, "xmlns", "http://www.w3.org/2000/svg"), Mi(e, "viewBox", "0 0 24 24");
    },
    m(i, r) {
      Od(i, e, r), Rd(e, n);
    },
    p: qr,
    i: qr,
    o: qr,
    d(i) {
      i && Ld(e);
    }
  };
}
class Wa extends Md {
  constructor(e) {
    super(), Bd(this, e, null, Hd, Nd, {});
  }
}
const {
  SvelteComponent: Id,
  append: Ri,
  attr: fe,
  detach: Ud,
  init: jd,
  insert: zd,
  noop: Wr,
  safe_not_equal: Fd,
  svg_element: $n
} = window.__gradio__svelte__internal;
function qd(t) {
  let e, n, i, r, o;
  return {
    c() {
      e = $n("svg"), n = $n("path"), i = $n("path"), r = $n("line"), o = $n("line"), fe(n, "d", "M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"), fe(i, "d", "M19 10v2a7 7 0 0 1-14 0v-2"), fe(r, "x1", "12"), fe(r, "y1", "19"), fe(r, "x2", "12"), fe(r, "y2", "23"), fe(o, "x1", "8"), fe(o, "y1", "23"), fe(o, "x2", "16"), fe(o, "y2", "23"), fe(e, "xmlns", "http://www.w3.org/2000/svg"), fe(e, "width", "100%"), fe(e, "height", "100%"), fe(e, "viewBox", "0 0 24 24"), fe(e, "fill", "none"), fe(e, "stroke", "currentColor"), fe(e, "stroke-width", "2"), fe(e, "stroke-linecap", "round"), fe(e, "stroke-linejoin", "round"), fe(e, "class", "feather feather-mic");
    },
    m(s, a) {
      zd(s, e, a), Ri(e, n), Ri(e, i), Ri(e, r), Ri(e, o);
    },
    p: Wr,
    i: Wr,
    o: Wr,
    d(s) {
      s && Ud(e);
    }
  };
}
class Wd extends Id {
  constructor(e) {
    super(), jd(this, e, null, qd, Fd, {});
  }
}
const {
  SvelteComponent: Gd,
  append: Gr,
  attr: we,
  detach: Vd,
  init: Xd,
  insert: Zd,
  noop: Vr,
  safe_not_equal: Jd,
  svg_element: Li
} = window.__gradio__svelte__internal;
function Yd(t) {
  let e, n, i, r;
  return {
    c() {
      e = Li("svg"), n = Li("path"), i = Li("circle"), r = Li("circle"), we(n, "d", "M9 18V5l12-2v13"), we(i, "cx", "6"), we(i, "cy", "18"), we(i, "r", "3"), we(r, "cx", "18"), we(r, "cy", "16"), we(r, "r", "3"), we(e, "xmlns", "http://www.w3.org/2000/svg"), we(e, "width", "100%"), we(e, "height", "100%"), we(e, "viewBox", "0 0 24 24"), we(e, "fill", "none"), we(e, "stroke", "currentColor"), we(e, "stroke-width", "1.5"), we(e, "stroke-linecap", "round"), we(e, "stroke-linejoin", "round"), we(e, "class", "feather feather-music");
    },
    m(o, s) {
      Zd(o, e, s), Gr(e, n), Gr(e, i), Gr(e, r);
    },
    p: Vr,
    i: Vr,
    o: Vr,
    d(o) {
      o && Vd(e);
    }
  };
}
class ur extends Gd {
  constructor(e) {
    super(), Xd(this, e, null, Yd, Jd, {});
  }
}
const {
  SvelteComponent: Qd,
  append: Rs,
  attr: ye,
  detach: Kd,
  init: xd,
  insert: $d,
  noop: Xr,
  safe_not_equal: eh,
  svg_element: Zr
} = window.__gradio__svelte__internal;
function th(t) {
  let e, n, i;
  return {
    c() {
      e = Zr("svg"), n = Zr("rect"), i = Zr("rect"), ye(n, "x", "6"), ye(n, "y", "4"), ye(n, "width", "4"), ye(n, "height", "16"), ye(i, "x", "14"), ye(i, "y", "4"), ye(i, "width", "4"), ye(i, "height", "16"), 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(r, o) {
      $d(r, e, o), Rs(e, n), Rs(e, i);
    },
    p: Xr,
    i: Xr,
    o: Xr,
    d(r) {
      r && Kd(e);
    }
  };
}
class Ga extends Qd {
  constructor(e) {
    super(), xd(this, e, null, th, eh, {});
  }
}
const {
  SvelteComponent: nh,
  append: ih,
  attr: ft,
  detach: rh,
  init: oh,
  insert: sh,
  noop: Jr,
  safe_not_equal: lh,
  svg_element: Ls
} = window.__gradio__svelte__internal;
function ah(t) {
  let e, n;
  return {
    c() {
      e = Ls("svg"), n = Ls("polygon"), ft(n, "points", "5 3 19 12 5 21 5 3"), ft(e, "xmlns", "http://www.w3.org/2000/svg"), ft(e, "width", "100%"), ft(e, "height", "100%"), ft(e, "viewBox", "0 0 24 24"), ft(e, "fill", "currentColor"), ft(e, "stroke", "currentColor"), ft(e, "stroke-width", "1.5"), ft(e, "stroke-linecap", "round"), ft(e, "stroke-linejoin", "round");
    },
    m(i, r) {
      sh(i, e, r), ih(e, n);
    },
    p: Jr,
    i: Jr,
    o: Jr,
    d(i) {
      i && rh(e);
    }
  };
}
class uh extends nh {
  constructor(e) {
    super(), oh(this, e, null, ah, lh, {});
  }
}
const {
  SvelteComponent: ch,
  append: Bs,
  attr: Ye,
  detach: fh,
  init: dh,
  insert: hh,
  noop: Yr,
  safe_not_equal: _h,
  svg_element: Qr
} = window.__gradio__svelte__internal;
function mh(t) {
  let e, n, i;
  return {
    c() {
      e = Qr("svg"), n = Qr("polyline"), i = Qr("path"), Ye(n, "points", "1 4 1 10 7 10"), Ye(i, "d", "M3.51 15a9 9 0 1 0 2.13-9.36L1 10"), 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", "none"), Ye(e, "stroke", "currentColor"), Ye(e, "stroke-width", "2"), Ye(e, "stroke-linecap", "round"), Ye(e, "stroke-linejoin", "round"), Ye(e, "class", "feather feather-rotate-ccw");
    },
    m(r, o) {
      hh(r, e, o), Bs(e, n), Bs(e, i);
    },
    p: Yr,
    i: Yr,
    o: Yr,
    d(r) {
      r && fh(e);
    }
  };
}
class Va extends ch {
  constructor(e) {
    super(), dh(this, e, null, mh, _h, {});
  }
}
const {
  SvelteComponent: ph,
  append: Kr,
  attr: Pe,
  detach: gh,
  init: bh,
  insert: vh,
  noop: xr,
  safe_not_equal: wh,
  svg_element: Bi
} = window.__gradio__svelte__internal;
function yh(t) {
  let e, n, i, r;
  return {
    c() {
      e = Bi("svg"), n = Bi("path"), i = Bi("polyline"), r = Bi("line"), Pe(n, "d", "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"), Pe(i, "points", "17 8 12 3 7 8"), Pe(r, "x1", "12"), Pe(r, "y1", "3"), Pe(r, "x2", "12"), Pe(r, "y2", "15"), Pe(e, "xmlns", "http://www.w3.org/2000/svg"), Pe(e, "width", "90%"), Pe(e, "height", "90%"), Pe(e, "viewBox", "0 0 24 24"), Pe(e, "fill", "none"), Pe(e, "stroke", "currentColor"), Pe(e, "stroke-width", "2"), Pe(e, "stroke-linecap", "round"), Pe(e, "stroke-linejoin", "round"), Pe(e, "class", "feather feather-upload");
    },
    m(o, s) {
      vh(o, e, s), Kr(e, n), Kr(e, i), Kr(e, r);
    },
    p: xr,
    i: xr,
    o: xr,
    d(o) {
      o && gh(e);
    }
  };
}
let Xa = class extends ph {
  constructor(e) {
    super(), bh(this, e, null, yh, wh, {});
  }
};
const {
  SvelteComponent: kh,
  append: Oi,
  attr: Ue,
  detach: Eh,
  init: Ch,
  insert: Sh,
  noop: $r,
  safe_not_equal: Ah,
  svg_element: Ni,
  text: Th
} = window.__gradio__svelte__internal;
function Ph(t) {
  let e, n, i, r, o;
  return {
    c() {
      e = Ni("svg"), n = Ni("title"), i = Th("Low volume"), r = Ni("path"), o = Ni("path"), Ue(r, "d", "M19.5 7.5C19.5 7.5 21 9 21 11.5C21 14 19.5 15.5 19.5 15.5"), Ue(r, "stroke-width", "1.5"), Ue(r, "stroke-linecap", "round"), Ue(r, "stroke-linejoin", "round"), Ue(o, "d", "M2 13.8571V10.1429C2 9.03829 2.89543 8.14286 4 8.14286H6.9C7.09569 8.14286 7.28708 8.08544 7.45046 7.97772L13.4495 4.02228C14.1144 3.5839 15 4.06075 15 4.85714V19.1429C15 19.9392 14.1144 20.4161 13.4495 19.9777L7.45046 16.0223C7.28708 15.9146 7.09569 15.8571 6.9 15.8571H4C2.89543 15.8571 2 14.9617 2 13.8571Z"), Ue(o, "stroke-width", "1.5"), Ue(e, "width", "100%"), Ue(e, "height", "100%"), Ue(e, "viewBox", "0 0 24 24"), Ue(e, "stroke-width", "1.5"), Ue(e, "fill", "none"), Ue(e, "xmlns", "http://www.w3.org/2000/svg"), Ue(e, "stroke", "currentColor"), Ue(e, "color", "currentColor");
    },
    m(s, a) {
      Sh(s, e, a), Oi(e, n), Oi(n, i), Oi(e, r), Oi(e, o);
    },
    p: $r,
    i: $r,
    o: $r,
    d(s) {
      s && Eh(e);
    }
  };
}
class Dh extends kh {
  constructor(e) {
    super(), Ch(this, e, null, Ph, Ah, {});
  }
}
const {
  SvelteComponent: Mh,
  append: ei,
  attr: me,
  detach: Rh,
  init: Lh,
  insert: Bh,
  noop: eo,
  safe_not_equal: Oh,
  svg_element: ti,
  text: Nh
} = window.__gradio__svelte__internal;
function Hh(t) {
  let e, n, i, r, o, s;
  return {
    c() {
      e = ti("svg"), n = ti("title"), i = Nh("High volume"), r = ti("path"), o = ti("path"), s = ti("path"), me(r, "d", "M1 13.8571V10.1429C1 9.03829 1.89543 8.14286 3 8.14286H5.9C6.09569 8.14286 6.28708 8.08544 6.45046 7.97772L12.4495 4.02228C13.1144 3.5839 14 4.06075 14 4.85714V19.1429C14 19.9392 13.1144 20.4161 12.4495 19.9777L6.45046 16.0223C6.28708 15.9146 6.09569 15.8571 5.9 15.8571H3C1.89543 15.8571 1 14.9617 1 13.8571Z"), me(r, "stroke-width", "1.5"), me(o, "d", "M17.5 7.5C17.5 7.5 19 9 19 11.5C19 14 17.5 15.5 17.5 15.5"), me(o, "stroke-width", "1.5"), me(o, "stroke-linecap", "round"), me(o, "stroke-linejoin", "round"), me(s, "d", "M20.5 4.5C20.5 4.5 23 7 23 11.5C23 16 20.5 18.5 20.5 18.5"), me(s, "stroke-width", "1.5"), me(s, "stroke-linecap", "round"), me(s, "stroke-linejoin", "round"), me(e, "width", "100%"), me(e, "height", "100%"), me(e, "viewBox", "0 0 24 24"), me(e, "stroke-width", "1.5"), me(e, "fill", "none"), me(e, "stroke", "currentColor"), me(e, "xmlns", "http://www.w3.org/2000/svg"), me(e, "color", "currentColor");
    },
    m(a, l) {
      Bh(a, e, l), ei(e, n), ei(n, i), ei(e, r), ei(e, o), ei(e, s);
    },
    p: eo,
    i: eo,
    o: eo,
    d(a) {
      a && Rh(e);
    }
  };
}
class Ih extends Mh {
  constructor(e) {
    super(), Lh(this, e, null, Hh, Oh, {});
  }
}
const {
  SvelteComponent: Uh,
  append: Mt,
  attr: de,
  detach: jh,
  init: zh,
  insert: Fh,
  noop: to,
  safe_not_equal: qh,
  svg_element: Rt,
  text: Wh
} = window.__gradio__svelte__internal;
function Gh(t) {
  let e, n, i, r, o, s, a, l, u;
  return {
    c() {
      e = Rt("svg"), n = Rt("title"), i = Wh("Muted volume"), r = Rt("g"), o = Rt("path"), s = Rt("path"), a = Rt("defs"), l = Rt("clipPath"), u = Rt("rect"), de(o, "d", "M18 14L20.0005 12M22 10L20.0005 12M20.0005 12L18 10M20.0005 12L22 14"), de(o, "stroke-width", "1.5"), de(o, "stroke-linecap", "round"), de(o, "stroke-linejoin", "round"), de(s, "d", "M2 13.8571V10.1429C2 9.03829 2.89543 8.14286 4 8.14286H6.9C7.09569 8.14286 7.28708 8.08544 7.45046 7.97772L13.4495 4.02228C14.1144 3.5839 15 4.06075 15 4.85714V19.1429C15 19.9392 14.1144 20.4161 13.4495 19.9777L7.45046 16.0223C7.28708 15.9146 7.09569 15.8571 6.9 15.8571H4C2.89543 15.8571 2 14.9617 2 13.8571Z"), de(s, "stroke-width", "1.5"), de(r, "clip-path", "url(#clip0_3173_16686)"), de(u, "width", "24"), de(u, "height", "24"), de(u, "fill", "white"), de(l, "id", "clip0_3173_16686"), de(e, "width", "100%"), de(e, "height", "100%"), de(e, "viewBox", "0 0 24 24"), de(e, "stroke-width", "1.5"), de(e, "fill", "none"), de(e, "xmlns", "http://www.w3.org/2000/svg"), de(e, "stroke", "currentColor"), de(e, "color", "currentColor");
    },
    m(c, f) {
      Fh(c, e, f), Mt(e, n), Mt(n, i), Mt(e, r), Mt(r, o), Mt(r, s), Mt(e, a), Mt(a, l), Mt(l, u);
    },
    p: to,
    i: to,
    o: to,
    d(c) {
      c && jh(e);
    }
  };
}
class Vh extends Uh {
  constructor(e) {
    super(), zh(this, e, null, Gh, qh, {});
  }
}
const {
  SvelteComponent: Xh,
  append: Os,
  attr: Lt,
  detach: Zh,
  init: Jh,
  insert: Yh,
  noop: no,
  safe_not_equal: Qh,
  svg_element: io
} = window.__gradio__svelte__internal;
function Kh(t) {
  let e, n, i;
  return {
    c() {
      e = io("svg"), n = io("path"), i = io("path"), Lt(n, "fill", "currentColor"), Lt(n, "d", "M12 2c-4.963 0-9 4.038-9 9c0 3.328 1.82 6.232 4.513 7.79l-2.067 1.378A1 1 0 0 0 6 22h12a1 1 0 0 0 .555-1.832l-2.067-1.378C19.18 17.232 21 14.328 21 11c0-4.962-4.037-9-9-9zm0 16c-3.859 0-7-3.141-7-7c0-3.86 3.141-7 7-7s7 3.14 7 7c0 3.859-3.141 7-7 7z"), Lt(i, "fill", "currentColor"), Lt(i, "d", "M12 6c-2.757 0-5 2.243-5 5s2.243 5 5 5s5-2.243 5-5s-2.243-5-5-5zm0 8c-1.654 0-3-1.346-3-3s1.346-3 3-3s3 1.346 3 3s-1.346 3-3 3z"), Lt(e, "xmlns", "http://www.w3.org/2000/svg"), Lt(e, "width", "100%"), Lt(e, "height", "100%"), Lt(e, "viewBox", "0 0 24 24");
    },
    m(r, o) {
      Yh(r, e, o), Os(e, n), Os(e, i);
    },
    p: no,
    i: no,
    o: no,
    d(r) {
      r && Zh(e);
    }
  };
}
class xh extends Xh {
  constructor(e) {
    super(), Jh(this, e, null, Kh, Qh, {});
  }
}
const {
  SvelteComponent: $h,
  create_component: e_,
  destroy_component: t_,
  init: n_,
  mount_component: i_,
  safe_not_equal: r_,
  transition_in: o_,
  transition_out: s_
} = window.__gradio__svelte__internal, { createEventDispatcher: l_ } = window.__gradio__svelte__internal;
function a_(t) {
  let e, n;
  return e = new Xn({
    props: {
      Icon: sd,
      label: (
        /*i18n*/
        t[2]("common.share")
      ),
      pending: (
        /*pending*/
        t[3]
      )
    }
  }), e.$on(
    "click",
    /*click_handler*/
    t[5]
  ), {
    c() {
      e_(e.$$.fragment);
    },
    m(i, r) {
      i_(e, i, r), n = !0;
    },
    p(i, [r]) {
      const o = {};
      r & /*i18n*/
      4 && (o.label = /*i18n*/
      i[2]("common.share")), r & /*pending*/
      8 && (o.pending = /*pending*/
      i[3]), e.$set(o);
    },
    i(i) {
      n || (o_(e.$$.fragment, i), n = !0);
    },
    o(i) {
      s_(e.$$.fragment, i), n = !1;
    },
    d(i) {
      t_(e, i);
    }
  };
}
function u_(t, e, n) {
  const i = l_();
  let { formatter: r } = e, { value: o } = e, { i18n: s } = e, a = !1;
  const l = async () => {
    try {
      n(3, a = !0);
      const u = await r(o);
      i("share", { description: u });
    } catch (u) {
      console.error(u);
      let c = u instanceof ji ? u.message : "Share failed.";
      i("error", c);
    } finally {
      n(3, a = !1);
    }
  };
  return t.$$set = (u) => {
    "formatter" in u && n(0, r = u.formatter), "value" in u && n(1, o = u.value), "i18n" in u && n(2, s = u.i18n);
  }, [r, o, s, a, i, l];
}
class c_ extends $h {
  constructor(e) {
    super(), n_(this, e, u_, a_, r_, { formatter: 0, value: 1, i18n: 2 });
  }
}
const {
  SvelteComponent: f_,
  append: en,
  attr: To,
  check_outros: d_,
  create_component: Za,
  destroy_component: Ja,
  detach: zi,
  element: Po,
  group_outros: h_,
  init: __,
  insert: Fi,
  mount_component: Ya,
  safe_not_equal: m_,
  set_data: Do,
  space: Mo,
  text: oi,
  toggle_class: Ns,
  transition_in: Yi,
  transition_out: Qi
} = window.__gradio__svelte__internal;
function p_(t) {
  let e, n;
  return e = new Xa({}), {
    c() {
      Za(e.$$.fragment);
    },
    m(i, r) {
      Ya(e, i, r), n = !0;
    },
    i(i) {
      n || (Yi(e.$$.fragment, i), n = !0);
    },
    o(i) {
      Qi(e.$$.fragment, i), n = !1;
    },
    d(i) {
      Ja(e, i);
    }
  };
}
function g_(t) {
  let e, n;
  return e = new Wa({}), {
    c() {
      Za(e.$$.fragment);
    },
    m(i, r) {
      Ya(e, i, r), n = !0;
    },
    i(i) {
      n || (Yi(e.$$.fragment, i), n = !0);
    },
    o(i) {
      Qi(e.$$.fragment, i), n = !1;
    },
    d(i) {
      Ja(e, i);
    }
  };
}
function Hs(t) {
  let e, n, i = (
    /*i18n*/
    t[1]("common.or") + ""
  ), r, o, s, a = (
    /*message*/
    (t[2] || /*i18n*/
    t[1]("upload_text.click_to_upload")) + ""
  ), l;
  return {
    c() {
      e = Po("span"), n = oi("- "), r = oi(i), o = oi(" -"), s = Mo(), l = oi(a), To(e, "class", "or svelte-kzcjhc");
    },
    m(u, c) {
      Fi(u, e, c), en(e, n), en(e, r), en(e, o), Fi(u, s, c), Fi(u, l, c);
    },
    p(u, c) {
      c & /*i18n*/
      2 && i !== (i = /*i18n*/
      u[1]("common.or") + "") && Do(r, i), c & /*message, i18n*/
      6 && a !== (a = /*message*/
      (u[2] || /*i18n*/
      u[1]("upload_text.click_to_upload")) + "") && Do(l, a);
    },
    d(u) {
      u && (zi(e), zi(s), zi(l));
    }
  };
}
function b_(t) {
  let e, n, i, r, o, s = (
    /*i18n*/
    t[1](
      /*defs*/
      t[5][
        /*type*/
        t[0]
      ] || /*defs*/
      t[5].file
    ) + ""
  ), a, l, u;
  const c = [g_, p_], f = [];
  function d(_, m) {
    return (
      /*type*/
      _[0] === "clipboard" ? 0 : 1
    );
  }
  i = d(t), r = f[i] = c[i](t);
  let h = (
    /*mode*/
    t[3] !== "short" && Hs(t)
  );
  return {
    c() {
      e = Po("div"), n = Po("span"), r.c(), o = Mo(), a = oi(s), l = Mo(), h && h.c(), To(n, "class", "icon-wrap svelte-kzcjhc"), Ns(
        n,
        "hovered",
        /*hovered*/
        t[4]
      ), To(e, "class", "wrap svelte-kzcjhc");
    },
    m(_, m) {
      Fi(_, e, m), en(e, n), f[i].m(n, null), en(e, o), en(e, a), en(e, l), h && h.m(e, null), u = !0;
    },
    p(_, [m]) {
      let p = i;
      i = d(_), i !== p && (h_(), Qi(f[p], 1, 1, () => {
        f[p] = null;
      }), d_(), r = f[i], r || (r = f[i] = c[i](_), r.c()), Yi(r, 1), r.m(n, null)), (!u || m & /*hovered*/
      16) && Ns(
        n,
        "hovered",
        /*hovered*/
        _[4]
      ), (!u || m & /*i18n, type*/
      3) && s !== (s = /*i18n*/
      _[1](
        /*defs*/
        _[5][
          /*type*/
          _[0]
        ] || /*defs*/
        _[5].file
      ) + "") && Do(a, s), /*mode*/
      _[3] !== "short" ? h ? h.p(_, m) : (h = Hs(_), h.c(), h.m(e, null)) : h && (h.d(1), h = null);
    },
    i(_) {
      u || (Yi(r), u = !0);
    },
    o(_) {
      Qi(r), u = !1;
    },
    d(_) {
      _ && zi(e), f[i].d(), h && h.d();
    }
  };
}
function v_(t, e, n) {
  let { type: i = "file" } = e, { i18n: r } = e, { message: o = void 0 } = e, { mode: s = "full" } = e, { hovered: a = !1 } = e;
  const l = {
    image: "upload_text.drop_image",
    video: "upload_text.drop_video",
    audio: "upload_text.drop_audio",
    file: "upload_text.drop_file",
    csv: "upload_text.drop_csv",
    gallery: "upload_text.drop_gallery",
    clipboard: "upload_text.paste_clipboard"
  };
  return t.$$set = (u) => {
    "type" in u && n(0, i = u.type), "i18n" in u && n(1, r = u.i18n), "message" in u && n(2, o = u.message), "mode" in u && n(3, s = u.mode), "hovered" in u && n(4, a = u.hovered);
  }, [i, r, o, s, a, l];
}
class w_ extends f_ {
  constructor(e) {
    super(), __(this, e, v_, b_, m_, {
      type: 0,
      i18n: 1,
      message: 2,
      mode: 3,
      hovered: 4
    });
  }
}
const {
  SvelteComponent: y_,
  append: ro,
  attr: mt,
  check_outros: si,
  create_component: cr,
  destroy_component: fr,
  detach: Zn,
  element: pi,
  empty: k_,
  group_outros: li,
  init: E_,
  insert: Jn,
  listen: dr,
  mount_component: hr,
  safe_not_equal: C_,
  space: oo,
  toggle_class: Ft,
  transition_in: he,
  transition_out: ze
} = window.__gradio__svelte__internal;
function Is(t) {
  let e, n = (
    /*sources*/
    t[1].includes("upload")
  ), i, r = (
    /*sources*/
    t[1].includes("microphone")
  ), o, s = (
    /*sources*/
    t[1].includes("webcam")
  ), a, l = (
    /*sources*/
    t[1].includes("clipboard")
  ), u, c = n && Us(t), f = r && js(t), d = s && zs(t), h = l && Fs(t);
  return {
    c() {
      e = pi("span"), c && c.c(), i = oo(), f && f.c(), o = oo(), d && d.c(), a = oo(), h && h.c(), mt(e, "class", "source-selection svelte-1jp3vgd"), mt(e, "data-testid", "source-select");
    },
    m(_, m) {
      Jn(_, e, m), c && c.m(e, null), ro(e, i), f && f.m(e, null), ro(e, o), d && d.m(e, null), ro(e, a), h && h.m(e, null), u = !0;
    },
    p(_, m) {
      m & /*sources*/
      2 && (n = /*sources*/
      _[1].includes("upload")), n ? c ? (c.p(_, m), m & /*sources*/
      2 && he(c, 1)) : (c = Us(_), c.c(), he(c, 1), c.m(e, i)) : c && (li(), ze(c, 1, 1, () => {
        c = null;
      }), si()), m & /*sources*/
      2 && (r = /*sources*/
      _[1].includes("microphone")), r ? f ? (f.p(_, m), m & /*sources*/
      2 && he(f, 1)) : (f = js(_), f.c(), he(f, 1), f.m(e, o)) : f && (li(), ze(f, 1, 1, () => {
        f = null;
      }), si()), m & /*sources*/
      2 && (s = /*sources*/
      _[1].includes("webcam")), s ? d ? (d.p(_, m), m & /*sources*/
      2 && he(d, 1)) : (d = zs(_), d.c(), he(d, 1), d.m(e, a)) : d && (li(), ze(d, 1, 1, () => {
        d = null;
      }), si()), m & /*sources*/
      2 && (l = /*sources*/
      _[1].includes("clipboard")), l ? h ? (h.p(_, m), m & /*sources*/
      2 && he(h, 1)) : (h = Fs(_), h.c(), he(h, 1), h.m(e, null)) : h && (li(), ze(h, 1, 1, () => {
        h = null;
      }), si());
    },
    i(_) {
      u || (he(c), he(f), he(d), he(h), u = !0);
    },
    o(_) {
      ze(c), ze(f), ze(d), ze(h), u = !1;
    },
    d(_) {
      _ && Zn(e), c && c.d(), f && f.d(), d && d.d(), h && h.d();
    }
  };
}
function Us(t) {
  let e, n, i, r, o;
  return n = new Xa({}), {
    c() {
      e = pi("button"), cr(n.$$.fragment), mt(e, "class", "icon svelte-1jp3vgd"), mt(e, "aria-label", "Upload file"), Ft(
        e,
        "selected",
        /*active_source*/
        t[0] === "upload" || !/*active_source*/
        t[0]
      );
    },
    m(s, a) {
      Jn(s, e, a), hr(n, e, null), i = !0, r || (o = dr(
        e,
        "click",
        /*click_handler*/
        t[6]
      ), r = !0);
    },
    p(s, a) {
      (!i || a & /*active_source*/
      1) && Ft(
        e,
        "selected",
        /*active_source*/
        s[0] === "upload" || !/*active_source*/
        s[0]
      );
    },
    i(s) {
      i || (he(n.$$.fragment, s), i = !0);
    },
    o(s) {
      ze(n.$$.fragment, s), i = !1;
    },
    d(s) {
      s && Zn(e), fr(n), r = !1, o();
    }
  };
}
function js(t) {
  let e, n, i, r, o;
  return n = new Wd({}), {
    c() {
      e = pi("button"), cr(n.$$.fragment), mt(e, "class", "icon svelte-1jp3vgd"), mt(e, "aria-label", "Record audio"), Ft(
        e,
        "selected",
        /*active_source*/
        t[0] === "microphone"
      );
    },
    m(s, a) {
      Jn(s, e, a), hr(n, e, null), i = !0, r || (o = dr(
        e,
        "click",
        /*click_handler_1*/
        t[7]
      ), r = !0);
    },
    p(s, a) {
      (!i || a & /*active_source*/
      1) && Ft(
        e,
        "selected",
        /*active_source*/
        s[0] === "microphone"
      );
    },
    i(s) {
      i || (he(n.$$.fragment, s), i = !0);
    },
    o(s) {
      ze(n.$$.fragment, s), i = !1;
    },
    d(s) {
      s && Zn(e), fr(n), r = !1, o();
    }
  };
}
function zs(t) {
  let e, n, i, r, o;
  return n = new xh({}), {
    c() {
      e = pi("button"), cr(n.$$.fragment), mt(e, "class", "icon svelte-1jp3vgd"), mt(e, "aria-label", "Capture from camera"), Ft(
        e,
        "selected",
        /*active_source*/
        t[0] === "webcam"
      );
    },
    m(s, a) {
      Jn(s, e, a), hr(n, e, null), i = !0, r || (o = dr(
        e,
        "click",
        /*click_handler_2*/
        t[8]
      ), r = !0);
    },
    p(s, a) {
      (!i || a & /*active_source*/
      1) && Ft(
        e,
        "selected",
        /*active_source*/
        s[0] === "webcam"
      );
    },
    i(s) {
      i || (he(n.$$.fragment, s), i = !0);
    },
    o(s) {
      ze(n.$$.fragment, s), i = !1;
    },
    d(s) {
      s && Zn(e), fr(n), r = !1, o();
    }
  };
}
function Fs(t) {
  let e, n, i, r, o;
  return n = new Wa({}), {
    c() {
      e = pi("button"), cr(n.$$.fragment), mt(e, "class", "icon svelte-1jp3vgd"), mt(e, "aria-label", "Paste from clipboard"), Ft(
        e,
        "selected",
        /*active_source*/
        t[0] === "clipboard"
      );
    },
    m(s, a) {
      Jn(s, e, a), hr(n, e, null), i = !0, r || (o = dr(
        e,
        "click",
        /*click_handler_3*/
        t[9]
      ), r = !0);
    },
    p(s, a) {
      (!i || a & /*active_source*/
      1) && Ft(
        e,
        "selected",
        /*active_source*/
        s[0] === "clipboard"
      );
    },
    i(s) {
      i || (he(n.$$.fragment, s), i = !0);
    },
    o(s) {
      ze(n.$$.fragment, s), i = !1;
    },
    d(s) {
      s && Zn(e), fr(n), r = !1, o();
    }
  };
}
function S_(t) {
  let e, n, i = (
    /*unique_sources*/
    t[2].length > 1 && Is(t)
  );
  return {
    c() {
      i && i.c(), e = k_();
    },
    m(r, o) {
      i && i.m(r, o), Jn(r, e, o), n = !0;
    },
    p(r, [o]) {
      /*unique_sources*/
      r[2].length > 1 ? i ? (i.p(r, o), o & /*unique_sources*/
      4 && he(i, 1)) : (i = Is(r), i.c(), he(i, 1), i.m(e.parentNode, e)) : i && (li(), ze(i, 1, 1, () => {
        i = null;
      }), si());
    },
    i(r) {
      n || (he(i), n = !0);
    },
    o(r) {
      ze(i), n = !1;
    },
    d(r) {
      r && Zn(e), i && i.d(r);
    }
  };
}
function A_(t, e, n) {
  let i, { sources: r } = e, { active_source: o } = e, { handle_clear: s = () => {
  } } = e, { handle_select: a = () => {
  } } = e;
  async function l(h) {
    s(), n(0, o = h), a(h);
  }
  const u = () => l("upload"), c = () => l("microphone"), f = () => l("webcam"), d = () => l("clipboard");
  return t.$$set = (h) => {
    "sources" in h && n(1, r = h.sources), "active_source" in h && n(0, o = h.active_source), "handle_clear" in h && n(4, s = h.handle_clear), "handle_select" in h && n(5, a = h.handle_select);
  }, t.$$.update = () => {
    t.$$.dirty & /*sources*/
    2 && n(2, i = [...new Set(r)]);
  }, [
    o,
    r,
    i,
    l,
    s,
    a,
    u,
    c,
    f,
    d
  ];
}
class T_ extends y_ {
  constructor(e) {
    super(), E_(this, e, A_, S_, C_, {
      sources: 1,
      active_source: 0,
      handle_clear: 4,
      handle_select: 5
    });
  }
}
function Me(t, e, n, i) {
  return new (n || (n = Promise))(function(r, o) {
    function s(u) {
      try {
        l(i.next(u));
      } catch (c) {
        o(c);
      }
    }
    function a(u) {
      try {
        l(i.throw(u));
      } catch (c) {
        o(c);
      }
    }
    function l(u) {
      var c;
      u.done ? r(u.value) : (c = u.value, c instanceof n ? c : new n(function(f) {
        f(c);
      })).then(s, a);
    }
    l((i = i.apply(t, e || [])).next());
  });
}
let gi = 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 qs = { decode: function(t, e) {
  return Me(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 o = 0;
      for (let s = 0; s < r; s++) {
        const a = Math.abs(i[s]);
        a > o && (o = a);
      }
      for (const s of n)
        for (let a = 0; a < r; a++)
          s[a] /= o;
    }
  }(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 Qa(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 [o, s] of Object.entries(e))
        typeof s == "string" ? n.appendChild(document.createTextNode(s)) : n.appendChild(Qa(o, s));
    else
      i === "style" ? Object.assign(n.style, r) : i === "textContent" ? n.textContent = r : n.setAttribute(i, r.toString());
  return n;
}
function Ws(t, e, n) {
  const i = Qa(t, e || {});
  return n == null || n.appendChild(i), i;
}
var P_ = Object.freeze({ __proto__: null, createElement: Ws, default: Ws });
const D_ = { fetchBlob: function(t, e, n) {
  return Me(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, o) {
      Me(this, void 0, void 0, function* () {
        if (!r.body || !r.headers)
          return;
        const s = r.body.getReader(), a = Number(r.headers.get("Content-Length")) || 0;
        let l = 0;
        const u = (f) => Me(this, void 0, void 0, function* () {
          l += (f == null ? void 0 : f.length) || 0;
          const d = Math.round(l / a * 100);
          o(d);
        }), c = () => Me(this, void 0, void 0, function* () {
          let f;
          try {
            f = yield s.read();
          } catch {
            return;
          }
          f.done || (u(f.value), yield c());
        });
        c();
      });
    }(i.clone(), e), i.blob();
  });
} };
class M_ extends gi {
  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.onMediaEvent("canplay", () => {
      e.playbackRate != null && (this.media.playbackRate = e.playbackRate);
    }, { once: !0 });
  }
  onMediaEvent(e, n, i) {
    return this.media.addEventListener(e, n, i), () => this.media.removeEventListener(e, n, i);
  }
  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) {
    const i = this.getSrc();
    if (e && i === e)
      return;
    this.revokeSrc();
    const r = n instanceof Blob && (this.canPlayType(n.type) || !e) ? URL.createObjectURL(n) : e;
    try {
      this.media.src = r;
    } catch {
      this.media.src = e;
    }
  }
  destroy() {
    this.media.pause(), this.isExternalMedia || (this.media.remove(), this.revokeSrc(), this.media.src = "", this.media.load());
  }
  setMediaElement(e) {
    this.media = e;
  }
  play() {
    return Me(this, void 0, void 0, function* () {
      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 In extends gi {
  constructor(e, n) {
    super(), this.timeouts = [], this.isScrollable = !1, this.audioData = null, this.resizeObserver = null, this.lastContainerWidth = 0, this.isDragging = !1, this.subscriptions = [], this.subscriptions = [], this.options = e;
    const i = this.parentFromOptionsContainer(e.container);
    this.parent = i;
    const [r, o] = this.initHtml();
    i.appendChild(r), this.container = r, this.scrollContainer = o.querySelector(".scroll"), this.wrapper = o.querySelector(".wrapper"), this.canvasWrapper = o.querySelector(".canvases"), this.progressWrapper = o.querySelector(".progress"), this.cursor = o.querySelector(".cursor"), n && o.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 = (n) => {
      const i = this.wrapper.getBoundingClientRect(), r = n.clientX - i.left, o = n.clientY - i.top;
      return [r / i.width, o / i.height];
    };
    if (this.wrapper.addEventListener("click", (n) => {
      const [i, r] = e(n);
      this.emit("click", i, r);
    }), this.wrapper.addEventListener("dblclick", (n) => {
      const [i, r] = e(n);
      this.emit("dblclick", i, r);
    }), this.options.dragToSeek !== !0 && typeof this.options.dragToSeek != "object" || this.initDrag(), this.scrollContainer.addEventListener("scroll", () => {
      const { scrollLeft: n, scrollWidth: i, clientWidth: r } = this.scrollContainer, o = n / i, s = (n + r) / i;
      this.emit("scroll", o, s, n, n + r);
    }), typeof ResizeObserver == "function") {
      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() {
    this.subscriptions.push(function(e, n, i, r, o = 3, s = 0, a = 100) {
      if (!e)
        return () => {
        };
      const l = matchMedia("(pointer: coarse)").matches;
      let u = () => {
      };
      const c = (f) => {
        if (f.button !== s)
          return;
        f.preventDefault(), f.stopPropagation();
        let d = f.clientX, h = f.clientY, _ = !1;
        const m = Date.now(), p = (T) => {
          if (T.preventDefault(), T.stopPropagation(), l && Date.now() - m < a)
            return;
          const C = T.clientX, M = T.clientY, A = C - d, P = M - h;
          if (_ || Math.abs(A) > o || Math.abs(P) > o) {
            const D = e.getBoundingClientRect(), { left: W, top: j } = D;
            _ || (i == null || i(d - W, h - j), _ = !0), n(A, P, C - W, M - j), d = C, h = M;
          }
        }, E = (T) => {
          if (_) {
            const C = T.clientX, M = T.clientY, A = e.getBoundingClientRect(), { left: P, top: D } = A;
            r == null || r(C - P, M - D);
          }
          u();
        }, w = (T) => {
          T.relatedTarget && T.relatedTarget !== document.documentElement || E(T);
        }, g = (T) => {
          _ && (T.stopPropagation(), T.preventDefault());
        }, b = (T) => {
          _ && T.preventDefault();
        };
        document.addEventListener("pointermove", p), document.addEventListener("pointerup", E), document.addEventListener("pointerout", w), document.addEventListener("pointercancel", w), document.addEventListener("touchmove", b, { passive: !1 }), document.addEventListener("click", g, { capture: !0 }), u = () => {
          document.removeEventListener("pointermove", p), document.removeEventListener("pointerup", E), document.removeEventListener("pointerout", w), document.removeEventListener("pointercancel", w), document.removeEventListener("touchmove", b), setTimeout(() => {
            document.removeEventListener("click", g, { capture: !0 });
          }, 10);
        };
      };
      return e.addEventListener("pointerdown", c), () => {
        u(), e.removeEventListener("pointerdown", c);
      };
    }(this.wrapper, (e, n, i) => {
      this.emit("drag", Math.max(0, Math.min(1, i / this.wrapper.getBoundingClientRect().width)));
    }, (e) => {
      this.isDragging = !0, this.emit("dragstart", Math.max(0, Math.min(1, e / this.wrapper.getBoundingClientRect().width)));
    }, (e) => {
      this.isDragging = !1, this.emit("dragend", Math.max(0, Math.min(1, e / this.wrapper.getBoundingClientRect().width)));
    }));
  }
  getHeight(e, n) {
    var i;
    const r = ((i = this.audioData) === null || i === void 0 ? void 0 : i.numberOfChannels) || 1;
    if (e == null)
      return 128;
    if (!isNaN(Number(e)))
      return Number(e);
    if (e === "auto") {
      const o = this.parent.clientHeight || 128;
      return n != null && n.every((s) => !s.overlay) ? o / r : o;
    }
    return 128;
  }
  initHtml() {
    const e = document.createElement("div"), n = e.attachShadow({ mode: "open" }), i = this.options.cspNonce && typeof this.options.cspNonce == "string" ? this.options.cspNonce.replace(/"/g, "") : "";
    return n.innerHTML = `
      <style${i ? ` nonce="${i}"` : ""}>
        :host {
          user-select: none;
          min-width: 1px;
        }
        :host audio {
          display: block;
          width: 100%;
        }
        :host .scroll {
          overflow-x: auto;
          overflow-y: hidden;
          width: 100%;
          position: relative;
        }
        :host .noScrollbar {
          scrollbar-color: transparent;
          scrollbar-width: none;
        }
        :host .noScrollbar::-webkit-scrollbar {
          display: none;
          -webkit-appearance: none;
        }
        :host .wrapper {
          position: relative;
          overflow: visible;
          z-index: 2;
        }
        :host .canvases {
          min-height: ${this.getHeight(this.options.height, this.options.splitChannels)}px;
        }
        :host .canvases > div {
          position: relative;
        }
        :host canvas {
          display: block;
          position: absolute;
          top: 0;
          image-rendering: pixelated;
        }
        :host .progress {
          pointer-events: none;
          position: absolute;
          z-index: 2;
          top: 0;
          left: 0;
          width: 0;
          height: 100%;
          overflow: hidden;
        }
        :host .progress > div {
          position: relative;
        }
        :host .cursor {
          pointer-events: none;
          position: absolute;
          z-index: 5;
          top: 0;
          left: 0;
          height: 100%;
          border-radius: 2px;
        }
      </style>

      <div class="scroll" part="scroll">
        <div class="wrapper" part="wrapper">
          <div class="canvases" part="canvases"></div>
          <div class="progress" part="progress"></div>
          <div class="cursor" part="cursor"></div>
        </div>
      </div>
    `, [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 !== !0 && typeof this.options.dragToSeek != "object" || this.initDrag(), this.options = e, this.reRender();
  }
  getWrapper() {
    return this.wrapper;
  }
  getWidth() {
    return this.scrollContainer.clientWidth;
  }
  getScroll() {
    return this.scrollContainer.scrollLeft;
  }
  setScroll(e) {
    this.scrollContainer.scrollLeft = e;
  }
  setScrollPercentage(e) {
    const { scrollWidth: n } = this.scrollContainer, i = n * e;
    this.setScroll(i);
  }
  destroy() {
    var e, n;
    this.subscriptions.forEach((i) => i()), this.container.remove(), (e = this.resizeObserver) === null || e === void 0 || e.disconnect(), (n = this.unsubscribeOnScroll) === null || n === void 0 || n.call(this);
  }
  createDelay(e = 10) {
    let n, i;
    const r = () => {
      n && clearTimeout(n), i && i();
    };
    return this.timeouts.push(r), () => new Promise((o, s) => {
      r(), i = s, n = setTimeout(() => {
        n = void 0, i = void 0, o();
      }, 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), o = i.createLinearGradient(0, 0, 0, r), s = 1 / (e.length - 1);
    return e.forEach((a, l) => {
      const u = l * s;
      o.addColorStop(u, a);
    }), o;
  }
  getPixelRatio() {
    return Math.max(1, window.devicePixelRatio || 1);
  }
  renderBarWaveform(e, n, i, r) {
    const o = e[0], s = e[1] || e[0], a = o.length, { width: l, height: u } = i.canvas, c = u / 2, f = this.getPixelRatio(), d = n.barWidth ? n.barWidth * f : 1, h = n.barGap ? n.barGap * f : n.barWidth ? d / 2 : 0, _ = n.barRadius || 0, m = l / (d + h) / a, p = _ && "roundRect" in i ? "roundRect" : "rect";
    i.beginPath();
    let E = 0, w = 0, g = 0;
    for (let b = 0; b <= a; b++) {
      const T = Math.round(b * m);
      if (T > E) {
        const A = Math.round(w * c * r), P = A + Math.round(g * c * r) || 1;
        let D = c - A;
        n.barAlign === "top" ? D = 0 : n.barAlign === "bottom" && (D = u - P), i[p](E * (d + h), D, d, P, _), E = T, w = 0, g = 0;
      }
      const C = Math.abs(o[b] || 0), M = Math.abs(s[b] || 0);
      C > w && (w = C), M > g && (g = M);
    }
    i.fill(), i.closePath();
  }
  renderLineWaveform(e, n, i, r) {
    const o = (s) => {
      const a = e[s] || e[0], l = a.length, { height: u } = i.canvas, c = u / 2, f = i.canvas.width / l;
      i.moveTo(0, c);
      let d = 0, h = 0;
      for (let _ = 0; _ <= l; _++) {
        const m = Math.round(_ * f);
        if (m > d) {
          const E = c + (Math.round(h * c * r) || 1) * (s === 0 ? -1 : 1);
          i.lineTo(d, E), d = m, h = 0;
        }
        const p = Math.abs(a[_] || 0);
        p > h && (h = p);
      }
      i.lineTo(d, c);
    };
    i.beginPath(), o(0), o(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 o = Array.from(e[0]).reduce((s, a) => Math.max(s, Math.abs(a)), 0);
      r = o ? 1 / o : 1;
    }
    n.barWidth || n.barGap || n.barAlign ? this.renderBarWaveform(e, n, i, r) : this.renderLineWaveform(e, n, i, r);
  }
  renderSingleCanvas(e, n, i, r, o, s, a) {
    const l = this.getPixelRatio(), u = document.createElement("canvas");
    u.width = Math.round(i * l), u.height = Math.round(r * l), u.style.width = `${i}px`, u.style.height = `${r}px`, u.style.left = `${Math.round(o)}px`, s.appendChild(u);
    const c = u.getContext("2d");
    if (this.renderWaveform(e, n, c), u.width > 0 && u.height > 0) {
      const f = u.cloneNode(), d = f.getContext("2d");
      d.drawImage(u, 0, 0), d.globalCompositeOperation = "source-in", d.fillStyle = this.convertColorValues(n.progressColor), d.fillRect(0, 0, u.width, u.height), a.appendChild(f);
    }
  }
  renderMultiCanvas(e, n, i, r, o, s) {
    const a = this.getPixelRatio(), { clientWidth: l } = this.scrollContainer, u = i / a;
    let c = Math.min(In.MAX_CANVAS_WIDTH, l, u), f = {};
    if (n.barWidth || n.barGap) {
      const p = n.barWidth || 0.5, E = p + (n.barGap || p / 2);
      c % E != 0 && (c = Math.floor(c / E) * E);
    }
    const d = (p) => {
      if (p < 0 || p >= h || f[p])
        return;
      f[p] = !0;
      const E = p * c, w = Math.min(u - E, c);
      if (w <= 0)
        return;
      const g = e.map((b) => {
        const T = Math.floor(E / u * b.length), C = Math.floor((E + w) / u * b.length);
        return b.slice(T, C);
      });
      this.renderSingleCanvas(g, n, w, r, E, o, s);
    }, h = Math.ceil(u / c);
    if (!this.isScrollable) {
      for (let p = 0; p < h; p++)
        d(p);
      return;
    }
    const _ = this.scrollContainer.scrollLeft / u, m = Math.floor(_ * h);
    d(m - 1), d(m), d(m + 1), h > 1 && (this.unsubscribeOnScroll = this.on("scroll", () => {
      const { scrollLeft: p } = this.scrollContainer, E = Math.floor(p / u * h);
      Object.keys(f).length > In.MAX_NODES && (o.innerHTML = "", s.innerHTML = "", f = {}), d(E - 1), d(E), d(E + 1);
    }));
  }
  renderChannel(e, n, i, r) {
    var { overlay: o } = n, s = function(c, f) {
      var d = {};
      for (var h in c)
        Object.prototype.hasOwnProperty.call(c, h) && f.indexOf(h) < 0 && (d[h] = c[h]);
      if (c != null && typeof Object.getOwnPropertySymbols == "function") {
        var _ = 0;
        for (h = Object.getOwnPropertySymbols(c); _ < h.length; _++)
          f.indexOf(h[_]) < 0 && Object.prototype.propertyIsEnumerable.call(c, h[_]) && (d[h[_]] = c[h[_]]);
      }
      return d;
    }(n, ["overlay"]);
    const a = document.createElement("div"), l = this.getHeight(s.height, s.splitChannels);
    a.style.height = `${l}px`, o && r > 0 && (a.style.marginTop = `-${l}px`), this.canvasWrapper.style.minHeight = `${l}px`, this.canvasWrapper.appendChild(a);
    const u = a.cloneNode();
    this.progressWrapper.appendChild(u), this.renderMultiCanvas(e, s, i, l, a, u);
  }
  render(e) {
    return Me(this, void 0, void 0, function* () {
      var n;
      this.timeouts.forEach((l) => l()), 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 i = this.getPixelRatio(), r = this.scrollContainer.clientWidth, o = Math.ceil(e.duration * (this.options.minPxPerSec || 0));
      this.isScrollable = o > r;
      const s = this.options.fillParent && !this.isScrollable, a = (s ? r : o) * i;
      if (this.wrapper.style.width = s ? "100%" : `${o}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"), this.options.splitChannels)
        for (let l = 0; l < e.numberOfChannels; l++) {
          const u = Object.assign(Object.assign({}, this.options), (n = this.options.splitChannels) === null || n === void 0 ? void 0 : n[l]);
          this.renderChannel([e.getChannelData(l)], u, a, l);
        }
      else {
        const l = [e.getChannelData(0)];
        e.numberOfChannels > 1 && l.push(e.getChannelData(1)), this.renderChannel(l, this.options, a, 0);
      }
      Promise.resolve().then(() => this.emit("rendered"));
    });
  }
  reRender() {
    var e;
    if ((e = this.unsubscribeOnScroll) === null || e === void 0 || e.call(this), delete this.unsubscribeOnScroll, !this.audioData)
      return;
    const { scrollWidth: n } = this.scrollContainer, { right: i } = this.progressWrapper.getBoundingClientRect();
    if (this.render(this.audioData), this.isScrollable && n !== this.scrollContainer.scrollWidth) {
      const { right: r } = this.progressWrapper.getBoundingClientRect();
      let o = r - i;
      o *= 2, o = o < 0 ? Math.floor(o) : Math.ceil(o), o /= 2, this.scrollContainer.scrollLeft += o;
    }
  }
  zoom(e) {
    this.options.minPxPerSec = e, this.reRender();
  }
  scrollIntoView(e, n = !1) {
    const { scrollLeft: i, scrollWidth: r, clientWidth: o } = this.scrollContainer, s = e * r, a = i, l = i + o, u = o / 2;
    if (this.isDragging)
      s + 30 > l ? this.scrollContainer.scrollLeft += 30 : s - 30 < a && (this.scrollContainer.scrollLeft -= 30);
    else {
      (s < a || s > l) && (this.scrollContainer.scrollLeft = s - (this.options.autoCenter ? u : 0));
      const c = s - i - u;
      n && this.options.autoCenter && c > 0 && (this.scrollContainer.scrollLeft += Math.min(c, 10));
    }
    {
      const c = this.scrollContainer.scrollLeft, f = c / r, d = (c + o) / r;
      this.emit("scroll", f, d, c, c + o);
    }
  }
  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 Me(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 o = Array.from(r).map((s) => s.toDataURL(e, n));
        return Promise.resolve(o);
      }
      return Promise.all(Array.from(r).map((o) => new Promise((s, a) => {
        o.toBlob((l) => {
          l ? s(l) : a(new Error("Could not export image"));
        }, e, n);
      })));
    });
  }
}
In.MAX_CANVAS_WIDTH = 8e3, In.MAX_NODES = 10;
class R_ extends gi {
  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 Gs extends gi {
  constructor(e = new AudioContext()) {
    super(), this.bufferNode = null, this.playStartTime = 0, this.playedDuration = 0, this._muted = !1, this._playbackRate = 1, this._duration = void 0, this.buffer = null, this.currentSrc = "", this.paused = !0, this.crossOrigin = null, this.seeking = !1, this.autoplay = !1, this.addEventListener = this.on, this.removeEventListener = this.un, this.audioContext = e, this.gainNode = this.audioContext.createGain(), this.gainNode.connect(this.audioContext.destination);
  }
  load() {
    return Me(this, void 0, void 0, function* () {
    });
  }
  get src() {
    return this.currentSrc;
  }
  set src(e) {
    if (this.currentSrc = e, this._duration = void 0, !e)
      return this.buffer = null, void this.emit("emptied");
    fetch(e).then((n) => {
      if (n.status >= 400)
        throw new Error(`Failed to fetch ${e}: ${n.status} (${n.statusText})`);
      return 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;
    if (!this.paused)
      return;
    this.paused = !1, (e = this.bufferNode) === null || e === void 0 || e.disconnect(), this.bufferNode = this.audioContext.createBufferSource(), this.buffer && (this.bufferNode.buffer = this.buffer), this.bufferNode.playbackRate.value = this._playbackRate, this.bufferNode.connect(this.gainNode);
    let n = this.playedDuration * this._playbackRate;
    n >= this.duration && (n = 0, this.playedDuration = 0), this.bufferNode.start(this.audioContext.currentTime, n), this.playStartTime = this.audioContext.currentTime, this.bufferNode.onended = () => {
      this.currentTime >= this.duration && (this.pause(), this.emit("ended"));
    };
  }
  _pause() {
    var e;
    this.paused = !0, (e = this.bufferNode) === null || e === void 0 || e.stop(), this.playedDuration += this.audioContext.currentTime - this.playStartTime;
  }
  play() {
    return Me(this, void 0, void 0, function* () {
      this.paused && (this._play(), this.emit("play"));
    });
  }
  pause() {
    this.paused || (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 Me(this, void 0, void 0, function* () {
      return this.audioContext.setSinkId(e);
    });
  }
  get playbackRate() {
    return this._playbackRate;
  }
  set playbackRate(e) {
    this._playbackRate = e, this.bufferNode && (this.bufferNode.playbackRate.value = e);
  }
  get currentTime() {
    return (this.paused ? this.playedDuration : this.playedDuration + (this.audioContext.currentTime - this.playStartTime)) * this._playbackRate;
  }
  set currentTime(e) {
    const n = !this.paused;
    n && this._pause(), this.playedDuration = e / this._playbackRate, n && this._play(), this.emit("seeking"), this.emit("timeupdate");
  }
  get duration() {
    var e, n;
    return (e = this._duration) !== null && e !== void 0 ? e : ((n = this.buffer) === null || n === void 0 ? void 0 : n.duration) || 0;
  }
  set duration(e) {
    this._duration = e;
  }
  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 L_ = { waveColor: "#999", progressColor: "#555", cursorWidth: 1, minPxPerSec: 0, fillParent: !0, interact: !0, dragToSeek: !1, autoScroll: !0, autoCenter: !0, sampleRate: 8e3 };
class qt extends M_ {
  static create(e) {
    return new qt(e);
  }
  constructor(e) {
    const n = e.media || (e.backend === "WebAudio" ? new Gs() : void 0);
    super({ media: n, mediaControls: e.mediaControls, autoplay: e.autoplay, playbackRate: e.audioRate }), this.plugins = [], this.decodedData = null, this.subscriptions = [], this.mediaSubscriptions = [], this.abortController = null, this.options = Object.assign({}, L_, e), this.timer = new R_();
    const i = n ? void 0 : this.getMediaElement();
    this.renderer = new In(this.options, i), this.initPlayerEvents(), this.initRendererEvents(), this.initTimerEvents(), this.initPlugins();
    const r = this.options.url || this.getSrc() || "";
    Promise.resolve().then(() => {
      this.emit("init");
      const { peaks: o, duration: s } = this.options;
      (r || o && s) && this.load(r, o, s).catch(() => null);
    });
  }
  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());
    }), this.onMediaEvent("error", (e) => {
      this.emit("error", e.error);
    }));
  }
  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, i, r) => {
      const o = this.getDuration();
      this.emit("scroll", e * o, n * o, i, r);
    }), this.renderer.on("render", () => {
      this.emit("redraw");
    }), this.renderer.on("rendered", () => {
      this.emit("redrawcomplete");
    }), this.renderer.on("dragstart", (e) => {
      this.emit("dragstart", e);
    }), this.renderer.on("dragend", (e) => {
      this.emit("dragend", e);
    }));
    {
      let e;
      this.subscriptions.push(this.renderer.on("drag", (n) => {
        if (!this.options.interact)
          return;
        let i;
        this.renderer.renderProgress(n), clearTimeout(e), this.isPlaying() ? i = 0 : this.options.dragToSeek === !0 ? i = 200 : typeof this.options.dragToSeek == "object" && this.options.dragToSeek !== void 0 && (i = this.options.dragToSeek.debounceTime), e = setTimeout(() => {
          this.seekTo(n);
        }, i), 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();
  }
  getWidth() {
    return this.renderer.getWidth();
  }
  getScroll() {
    return this.renderer.getScroll();
  }
  setScroll(e) {
    return this.renderer.setScroll(e);
  }
  setScrollTime(e) {
    const n = e / this.getDuration();
    this.renderer.setScrollPercentage(n);
  }
  getActivePlugins() {
    return this.plugins;
  }
  loadAudio(e, n, i, r) {
    return Me(this, void 0, void 0, function* () {
      var o;
      if (this.emit("load", e), !this.options.media && this.isPlaying() && this.pause(), this.decodedData = null, !n && !i) {
        const a = this.options.fetchParams || {};
        window.AbortController && !a.signal && (this.abortController = new AbortController(), a.signal = (o = this.abortController) === null || o === void 0 ? void 0 : o.signal);
        const l = (u) => this.emit("loading", u);
        n = yield D_.fetchBlob(e, l, a);
      }
      this.setSrc(e, n);
      const s = yield new Promise((a) => {
        const l = r || this.getDuration();
        l ? a(l) : this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata", () => a(this.getDuration()), { once: !0 }));
      });
      if (!e && !n) {
        const a = this.getMediaElement();
        a instanceof Gs && (a.duration = s);
      }
      if (i)
        this.decodedData = qs.createBuffer(i, s || 0);
      else if (n) {
        const a = yield n.arrayBuffer();
        this.decodedData = yield qs.decode(a, 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 Me(this, void 0, void 0, function* () {
      try {
        return yield this.loadAudio(e, void 0, n, i);
      } catch (r) {
        throw this.emit("error", r), r;
      }
    });
  }
  loadBlob(e, n, i) {
    return Me(this, void 0, void 0, function* () {
      try {
        return yield this.loadAudio("", e, n, i);
      } catch (r) {
        throw this.emit("error", r), r;
      }
    });
  }
  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), o = [];
    for (let s = 0; s < r; s++) {
      const a = this.decodedData.getChannelData(s), l = [], u = a.length / n;
      for (let c = 0; c < n; c++) {
        const f = a.slice(Math.floor(c * u), Math.ceil((c + 1) * u));
        let d = 0;
        for (let h = 0; h < f.length; h++) {
          const _ = f[h];
          Math.abs(_) > Math.abs(d) && (d = _);
        }
        l.push(Math.round(d * i) / i);
      }
      o.push(l);
    }
    return o;
  }
  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), this.emit("timeupdate", e);
  }
  seekTo(e) {
    const n = this.getDuration() * e;
    this.setTime(n);
  }
  playPause() {
    return Me(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() {
    return Me(this, arguments, void 0, function* (e = "image/png", n = 1, i = "dataURL") {
      return this.renderer.exportImage(e, n, i);
    });
  }
  destroy() {
    var e;
    this.emit("destroy"), (e = this.abortController) === null || e === void 0 || e.abort(), this.plugins.forEach((n) => n.destroy()), this.subscriptions.forEach((n) => n()), this.unsubscribePlayerEvents(), this.timer.destroy(), this.renderer.destroy(), super.destroy();
  }
}
qt.BasePlugin = class extends gi {
  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());
  }
}, qt.dom = P_;
let Ka = 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));
  }
}, B_ = class extends Ka {
  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 qi(t, e, n, i, r = 3, o = 0, s = 100) {
  if (!t)
    return () => {
    };
  const a = matchMedia("(pointer: coarse)").matches;
  let l = () => {
  };
  const u = (c) => {
    if (c.button !== o)
      return;
    c.preventDefault(), c.stopPropagation();
    let f = c.clientX, d = c.clientY, h = !1;
    const _ = Date.now(), m = (b) => {
      if (b.preventDefault(), b.stopPropagation(), a && Date.now() - _ < s)
        return;
      const T = b.clientX, C = b.clientY, M = T - f, A = C - d;
      if (h || Math.abs(M) > r || Math.abs(A) > r) {
        const P = t.getBoundingClientRect(), { left: D, top: W } = P;
        h || (n == null || n(f - D, d - W), h = !0), e(M, A, T - D, C - W), f = T, d = C;
      }
    }, p = (b) => {
      if (h) {
        const T = b.clientX, C = b.clientY, M = t.getBoundingClientRect(), { left: A, top: P } = M;
        i == null || i(T - A, C - P);
      }
      l();
    }, E = (b) => {
      b.relatedTarget && b.relatedTarget !== document.documentElement || p(b);
    }, w = (b) => {
      h && (b.stopPropagation(), b.preventDefault());
    }, g = (b) => {
      h && b.preventDefault();
    };
    document.addEventListener("pointermove", m), document.addEventListener("pointerup", p), document.addEventListener("pointerout", E), document.addEventListener("pointercancel", E), document.addEventListener("touchmove", g, { passive: !1 }), document.addEventListener("click", w, { capture: !0 }), l = () => {
      document.removeEventListener("pointermove", m), document.removeEventListener("pointerup", p), document.removeEventListener("pointerout", E), document.removeEventListener("pointercancel", E), document.removeEventListener("touchmove", g), setTimeout(() => {
        document.removeEventListener("click", w, { capture: !0 });
      }, 10);
    };
  };
  return t.addEventListener("pointerdown", u), () => {
    l(), t.removeEventListener("pointerdown", u);
  };
}
function xa(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 [o, s] of Object.entries(e))
        typeof s == "string" ? n.appendChild(document.createTextNode(s)) : n.appendChild(xa(o, s));
    else
      i === "style" ? Object.assign(n.style, r) : i === "textContent" ? n.textContent = r : n.setAttribute(i, r.toString());
  return n;
}
function ai(t, e, n) {
  const i = xa(t, e || {});
  return n == null || n.appendChild(i), i;
}
let Vs = class extends Ka {
  constructor(e, n, i = 0) {
    var r, o, s, a, l, u, c, f;
    super(), this.totalDuration = n, this.numberOfChannels = i, this.minLength = 0, this.maxLength = 1 / 0, this.contentEditable = !1, this.subscriptions = [], this.subscriptions = [], 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 = (o = e.drag) === null || o === void 0 || o, this.resize = (s = e.resize) === null || s === void 0 || s, this.color = (a = e.color) !== null && a !== void 0 ? a : "rgba(0, 0, 0, 0.1)", this.minLength = (l = e.minLength) !== null && l !== void 0 ? l : this.minLength, this.maxLength = (u = e.maxLength) !== null && u !== void 0 ? u : this.maxLength, this.channelIdx = (c = e.channelIdx) !== null && c !== void 0 ? c : -1, this.contentEditable = (f = e.contentEditable) !== null && f !== void 0 ? f : 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 = ai("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 = ai("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);
    this.subscriptions.push(qi(i, (o) => this.onResize(o, "start"), () => null, () => this.onEndResizing(), 1), qi(r, (o) => this.onResize(o, "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 = ai("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)), this.subscriptions.push(qi(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, o = n && n !== "start" ? this.start : this.start + r, s = n && n !== "end" ? this.end : this.end + r, a = s - o;
    o >= 0 && s <= this.totalDuration && o <= s && a >= this.minLength && a <= this.maxLength && (this.start = o, this.end = s, 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 = ai("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.subscriptions.forEach((e) => e()), this.element.remove(), this.element = null;
  }
}, O_ = class $a extends B_ {
  constructor(e) {
    super(e), this.regions = [], this.regionsContainer = this.initRegionsContainer();
  }
  static create(e) {
    return new $a(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 ai("div", { style: { position: "absolute", top: "0", left: "0", width: "100%", height: "100%", zIndex: "3", pointerEvents: "none" } });
  }
  getRegions() {
    return this.regions;
  }
  avoidOverlapping(e) {
    e.content && setTimeout(() => {
      const n = e.content, i = n.getBoundingClientRect(), r = this.regions.map((o) => {
        if (o === e || !o.content)
          return 0;
        const s = o.content.getBoundingClientRect();
        return i.left < s.left + s.width && s.left < i.left + i.width ? s.height : 0;
      }).reduce((o, s) => o + s, 0);
      n.style.marginTop = `${r}px`;
    }, 10);
  }
  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: o, scrollWidth: s } = r;
    if (s <= o)
      return;
    const a = r.getBoundingClientRect(), l = e.element.getBoundingClientRect(), u = l.left - a.left, c = l.right - a.left;
    u < 0 ? r.scrollLeft += u : c > o && (r.scrollLeft += c - o);
  }
  virtualAppend(e, n, i) {
    const r = () => {
      if (!this.wavesurfer)
        return;
      const o = this.wavesurfer.getWidth(), s = this.wavesurfer.getScroll(), a = n.clientWidth, l = this.wavesurfer.getDuration(), u = Math.round(e.start / l * a);
      u + (Math.round((e.end - e.start) / l * a) || 1) > s && u < s + o ? n.appendChild(i) : i.remove();
    };
    setTimeout(() => {
      if (!this.wavesurfer)
        return;
      r();
      const o = this.wavesurfer.on("scroll", r);
      this.subscriptions.push(e.once("remove", o), o);
    }, 0);
  }
  saveRegion(e) {
    this.virtualAppend(e, this.regionsContainer, e.element), this.avoidOverlapping(e), this.regions.push(e);
    const n = [e.on("update", (i) => {
      i || this.adjustScroll(e), this.emit("region-update", e, i);
    }), 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(), o = (i = (n = this.wavesurfer) === null || n === void 0 ? void 0 : n.getDecodedData()) === null || i === void 0 ? void 0 : i.numberOfChannels, s = new Vs(e, r, o);
    return r ? this.saveRegion(s) : this.subscriptions.push(this.wavesurfer.once("ready", (a) => {
      s._setTotalDuration(a), this.saveRegion(s);
    })), s;
  }
  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 o = null, s = 0;
    return qi(r, (a, l, u) => {
      o && o._onUpdate(a, u > s ? "end" : "start");
    }, (a) => {
      var l, u;
      if (s = a, !this.wavesurfer)
        return;
      const c = this.wavesurfer.getDuration(), f = (u = (l = this.wavesurfer) === null || l === void 0 ? void 0 : l.getDecodedData()) === null || u === void 0 ? void 0 : u.numberOfChannels, { width: d } = this.wavesurfer.getWrapper().getBoundingClientRect(), h = a / d * c, _ = (a + 5) / d * c;
      o = new Vs(Object.assign(Object.assign({}, e), { start: h, end: _ }), c, f), this.regionsContainer.appendChild(o.element);
    }, () => {
      o && (this.saveRegion(o), o = null);
    }, n);
  }
  clearRegions() {
    this.regions.slice().forEach((e) => e.remove()), this.regions = [];
  }
  destroy() {
    this.clearRegions(), super.destroy(), this.regionsContainer.remove();
  }
};
function N_(t) {
  const e = t.numberOfChannels, n = t.length * e * 2 + 44, i = new ArrayBuffer(n), r = new DataView(i);
  let o = 0;
  const s = function(a, l, u) {
    for (let c = 0; c < u.length; c++)
      a.setUint8(l + c, u.charCodeAt(c));
  };
  s(r, o, "RIFF"), o += 4, r.setUint32(o, n - 8, !0), o += 4, s(r, o, "WAVE"), o += 4, s(r, o, "fmt "), o += 4, r.setUint32(o, 16, !0), o += 4, r.setUint16(o, 1, !0), o += 2, r.setUint16(o, e, !0), o += 2, r.setUint32(o, t.sampleRate, !0), o += 4, r.setUint32(o, t.sampleRate * 2 * e, !0), o += 4, r.setUint16(o, e * 2, !0), o += 2, r.setUint16(o, 16, !0), o += 2, s(r, o, "data"), o += 4, r.setUint32(o, t.length * e * 2, !0), o += 4;
  for (let a = 0; a < t.length; a++)
    for (let l = 0; l < e; l++) {
      const u = Math.max(
        -1,
        Math.min(1, t.getChannelData(l)[a])
      );
      r.setInt16(o, u * 32767, !0), o += 2;
    }
  return new Uint8Array(i);
}
const Xs = async (t, e, n, i) => {
  const r = new AudioContext({
    sampleRate: i || t.sampleRate
  }), o = t.numberOfChannels, s = i || t.sampleRate;
  let a = t.length, l = 0;
  e && n && (l = Math.round(e * s), a = Math.round(n * s) - l);
  const u = r.createBuffer(
    o,
    a,
    s
  );
  for (let c = 0; c < o; c++) {
    const f = t.getChannelData(c), d = u.getChannelData(c);
    for (let h = 0; h < a; h++)
      d[h] = f[l + h];
  }
  return N_(u);
}, Ki = (t, e) => {
  t && t.skip(e);
}, Mn = (t, e) => (e || (e = 5), t / 100 * e || 5), {
  SvelteComponent: H_,
  check_outros: I_,
  create_component: Qo,
  destroy_component: Ko,
  detach: U_,
  empty: j_,
  group_outros: z_,
  init: F_,
  insert: q_,
  mount_component: xo,
  safe_not_equal: W_,
  transition_in: di,
  transition_out: hi
} = window.__gradio__svelte__internal;
function G_(t) {
  let e, n;
  return e = new Ih({}), {
    c() {
      Qo(e.$$.fragment);
    },
    m(i, r) {
      xo(e, i, r), n = !0;
    },
    i(i) {
      n || (di(e.$$.fragment, i), n = !0);
    },
    o(i) {
      hi(e.$$.fragment, i), n = !1;
    },
    d(i) {
      Ko(e, i);
    }
  };
}
function V_(t) {
  let e, n;
  return e = new Dh({}), {
    c() {
      Qo(e.$$.fragment);
    },
    m(i, r) {
      xo(e, i, r), n = !0;
    },
    i(i) {
      n || (di(e.$$.fragment, i), n = !0);
    },
    o(i) {
      hi(e.$$.fragment, i), n = !1;
    },
    d(i) {
      Ko(e, i);
    }
  };
}
function X_(t) {
  let e, n;
  return e = new Vh({}), {
    c() {
      Qo(e.$$.fragment);
    },
    m(i, r) {
      xo(e, i, r), n = !0;
    },
    i(i) {
      n || (di(e.$$.fragment, i), n = !0);
    },
    o(i) {
      hi(e.$$.fragment, i), n = !1;
    },
    d(i) {
      Ko(e, i);
    }
  };
}
function Z_(t) {
  let e, n, i, r;
  const o = [X_, V_, G_], s = [];
  function a(l, u) {
    return (
      /*currentVolume*/
      l[0] == 0 ? 0 : (
        /*currentVolume*/
        l[0] < 0.5 ? 1 : (
          /*currentVolume*/
          l[0] >= 0.5 ? 2 : -1
        )
      )
    );
  }
  return ~(e = a(t)) && (n = s[e] = o[e](t)), {
    c() {
      n && n.c(), i = j_();
    },
    m(l, u) {
      ~e && s[e].m(l, u), q_(l, i, u), r = !0;
    },
    p(l, [u]) {
      let c = e;
      e = a(l), e !== c && (n && (z_(), hi(s[c], 1, 1, () => {
        s[c] = null;
      }), I_()), ~e ? (n = s[e], n || (n = s[e] = o[e](l), n.c()), di(n, 1), n.m(i.parentNode, i)) : n = null);
    },
    i(l) {
      r || (di(n), r = !0);
    },
    o(l) {
      hi(n), r = !1;
    },
    d(l) {
      l && U_(i), ~e && s[e].d(l);
    }
  };
}
function J_(t, e, n) {
  let { currentVolume: i } = e;
  return t.$$set = (r) => {
    "currentVolume" in r && n(0, i = r.currentVolume);
  }, [i];
}
class Y_ extends H_ {
  constructor(e) {
    super(), F_(this, e, J_, Z_, W_, { currentVolume: 0 });
  }
}
const {
  SvelteComponent: Q_,
  attr: En,
  binding_callbacks: K_,
  detach: x_,
  element: $_,
  init: e0,
  insert: t0,
  listen: Zs,
  noop: Js,
  run_all: n0,
  safe_not_equal: i0
} = window.__gradio__svelte__internal, { onMount: r0 } = window.__gradio__svelte__internal;
function o0(t) {
  let e, n, i;
  return {
    c() {
      e = $_("input"), En(e, "id", "volume"), En(e, "class", "volume-slider svelte-1xy0951"), En(e, "type", "range"), En(e, "min", "0"), En(e, "max", "1"), En(e, "step", "0.01"), e.value = /*currentVolume*/
      t[0];
    },
    m(r, o) {
      t0(r, e, o), t[4](e), n || (i = [
        Zs(
          e,
          "focusout",
          /*focusout_handler*/
          t[5]
        ),
        Zs(
          e,
          "input",
          /*input_handler*/
          t[6]
        )
      ], n = !0);
    },
    p(r, [o]) {
      o & /*currentVolume*/
      1 && (e.value = /*currentVolume*/
      r[0]);
    },
    i: Js,
    o: Js,
    d(r) {
      r && x_(e), t[4](null), n = !1, n0(i);
    }
  };
}
function s0(t, e, n) {
  let { currentVolume: i = 1 } = e, { show_volume_slider: r = !1 } = e, { waveform: o } = e, s;
  r0(() => {
    a();
  });
  const a = () => {
    let f = s;
    f && (f.style.background = `linear-gradient(to right, var(--color-accent) ${i * 100}%, var(--neutral-400) ${i * 100}%)`);
  };
  function l(f) {
    K_[f ? "unshift" : "push"](() => {
      s = f, n(3, s);
    });
  }
  const u = () => n(1, r = !1), c = (f) => {
    f.target instanceof HTMLInputElement && (n(0, i = parseFloat(f.target.value)), o.setVolume(i));
  };
  return t.$$set = (f) => {
    "currentVolume" in f && n(0, i = f.currentVolume), "show_volume_slider" in f && n(1, r = f.show_volume_slider), "waveform" in f && n(2, o = f.waveform);
  }, t.$$.update = () => {
    t.$$.dirty & /*currentVolume*/
    1 && a();
  }, [
    i,
    r,
    o,
    s,
    l,
    u,
    c
  ];
}
class l0 extends Q_ {
  constructor(e) {
    super(), e0(this, e, s0, o0, i0, {
      currentVolume: 0,
      show_volume_slider: 1,
      waveform: 2
    });
  }
}
const {
  SvelteComponent: a0,
  add_flush_callback: Ys,
  append: ke,
  attr: ue,
  bind: Qs,
  binding_callbacks: Ks,
  check_outros: Wi,
  create_component: nn,
  destroy_component: rn,
  detach: $o,
  element: ot,
  empty: u0,
  group_outros: Gi,
  init: c0,
  insert: es,
  listen: Pn,
  mount_component: on,
  noop: f0,
  run_all: d0,
  safe_not_equal: h0,
  set_data: _0,
  set_style: xs,
  space: Cn,
  text: $s,
  toggle_class: el,
  transition_in: pe,
  transition_out: Le
} = window.__gradio__svelte__internal;
function tl(t) {
  let e, n, i, r;
  function o(l) {
    t[16](l);
  }
  function s(l) {
    t[17](l);
  }
  let a = { waveform: (
    /*waveform*/
    t[2]
  ) };
  return (
    /*currentVolume*/
    t[12] !== void 0 && (a.currentVolume = /*currentVolume*/
    t[12]), /*show_volume_slider*/
    t[1] !== void 0 && (a.show_volume_slider = /*show_volume_slider*/
    t[1]), e = new l0({ props: a }), Ks.push(() => Qs(e, "currentVolume", o)), Ks.push(() => Qs(e, "show_volume_slider", s)), {
      c() {
        nn(e.$$.fragment);
      },
      m(l, u) {
        on(e, l, u), r = !0;
      },
      p(l, u) {
        const c = {};
        u & /*waveform*/
        4 && (c.waveform = /*waveform*/
        l[2]), !n && u & /*currentVolume*/
        4096 && (n = !0, c.currentVolume = /*currentVolume*/
        l[12], Ys(() => n = !1)), !i && u & /*show_volume_slider*/
        2 && (i = !0, c.show_volume_slider = /*show_volume_slider*/
        l[1], Ys(() => i = !1)), e.$set(c);
      },
      i(l) {
        r || (pe(e.$$.fragment, l), r = !0);
      },
      o(l) {
        Le(e.$$.fragment, l), r = !1;
      },
      d(l) {
        rn(e, l);
      }
    }
  );
}
function m0(t) {
  let e, n;
  return e = new uh({}), {
    c() {
      nn(e.$$.fragment);
    },
    m(i, r) {
      on(e, i, r), n = !0;
    },
    i(i) {
      n || (pe(e.$$.fragment, i), n = !0);
    },
    o(i) {
      Le(e.$$.fragment, i), n = !1;
    },
    d(i) {
      rn(e, i);
    }
  };
}
function p0(t) {
  let e, n;
  return e = new Ga({}), {
    c() {
      nn(e.$$.fragment);
    },
    m(i, r) {
      on(e, i, r), n = !0;
    },
    i(i) {
      n || (pe(e.$$.fragment, i), n = !0);
    },
    o(i) {
      Le(e.$$.fragment, i), n = !1;
    },
    d(i) {
      rn(e, i);
    }
  };
}
function nl(t) {
  let e, n, i = (
    /*show_redo*/
    t[6] && /*mode*/
    t[0] === "" && il(t)
  );
  return {
    c() {
      i && i.c(), e = u0();
    },
    m(r, o) {
      i && i.m(r, o), es(r, e, o), n = !0;
    },
    p(r, o) {
      /*show_redo*/
      r[6] && /*mode*/
      r[0] === "" ? i ? (i.p(r, o), o & /*show_redo, mode*/
      65 && pe(i, 1)) : (i = il(r), i.c(), pe(i, 1), i.m(e.parentNode, e)) : i && (Gi(), Le(i, 1, 1, () => {
        i = null;
      }), Wi());
    },
    i(r) {
      n || (pe(i), n = !0);
    },
    o(r) {
      Le(i), n = !1;
    },
    d(r) {
      r && $o(e), i && i.d(r);
    }
  };
}
function il(t) {
  let e, n, i, r, o;
  return n = new Va({}), {
    c() {
      e = ot("button"), nn(n.$$.fragment), ue(e, "class", "action icon svelte-28lhvz"), ue(e, "aria-label", "Reset audio");
    },
    m(s, a) {
      es(s, e, a), on(n, e, null), i = !0, r || (o = Pn(
        e,
        "click",
        /*click_handler_5*/
        t[22]
      ), r = !0);
    },
    p: f0,
    i(s) {
      i || (pe(n.$$.fragment, s), i = !0);
    },
    o(s) {
      Le(n.$$.fragment, s), i = !1;
    },
    d(s) {
      s && $o(e), rn(n), r = !1, o();
    }
  };
}
function g0(t) {
  let e, n, i, r, o, s, a, l, u, c, f, d, h, _, m, p, E, w, g, b, T, C, M, A, P, D, W, j, U, oe;
  r = new Y_({
    props: { currentVolume: (
      /*currentVolume*/
      t[12]
    ) }
  });
  let B = (
    /*show_volume_slider*/
    t[1] && tl(t)
  );
  m = new Vf({});
  const O = [p0, m0], X = [];
  function le(v, y) {
    return (
      /*playing*/
      v[5] ? 0 : 1
    );
  }
  g = le(t), b = X[g] = O[g](t), A = new Dd({});
  let J = (
    /*editable*/
    t[10] && /*interactive*/
    t[7] && nl(t)
  );
  return {
    c() {
      e = ot("div"), n = ot("div"), i = ot("button"), nn(r.$$.fragment), o = Cn(), B && B.c(), s = Cn(), a = ot("button"), l = ot("span"), u = $s(
        /*playbackSpeed*/
        t[11]
      ), c = $s("x"), d = Cn(), h = ot("div"), _ = ot("button"), nn(m.$$.fragment), E = Cn(), w = ot("button"), b.c(), C = Cn(), M = ot("button"), nn(A.$$.fragment), D = Cn(), W = ot("div"), J && J.c(), ue(i, "class", "action icon volume svelte-28lhvz"), ue(i, "aria-label", "Adjust volume"), xs(
        i,
        "color",
        /*show_volume_slider*/
        t[1] ? "var(--color-accent)" : "var(--neutral-400)"
      ), ue(a, "class", "playback icon svelte-28lhvz"), ue(a, "aria-label", f = `Adjust playback speed to ${/*playbackSpeeds*/
      t[13][
        /*playbackSpeeds*/
        (t[13].indexOf(
          /*playbackSpeed*/
          t[11]
        ) + 1) % /*playbackSpeeds*/
        t[13].length
      ]}x`), el(
        a,
        "hidden",
        /*show_volume_slider*/
        t[1]
      ), ue(n, "class", "control-wrapper svelte-28lhvz"), ue(_, "class", "rewind icon svelte-28lhvz"), ue(_, "aria-label", p = `Skip backwards by ${Mn(
        /*audio_duration*/
        t[3],
        /*waveform_options*/
        t[9].skip_length
      )} seconds`), ue(w, "class", "play-pause-button icon svelte-28lhvz"), ue(w, "aria-label", T = /*playing*/
      t[5] ? (
        /*i18n*/
        t[4]("audio.pause")
      ) : (
        /*i18n*/
        t[4]("audio.play")
      )), ue(M, "class", "skip icon svelte-28lhvz"), ue(M, "aria-label", P = "Skip forward by " + Mn(
        /*audio_duration*/
        t[3],
        /*waveform_options*/
        t[9].skip_length
      ) + " seconds"), ue(h, "class", "play-pause-wrapper svelte-28lhvz"), ue(W, "class", "settings-wrapper svelte-28lhvz"), ue(e, "class", "controls svelte-28lhvz"), ue(e, "data-testid", "waveform-controls");
    },
    m(v, y) {
      es(v, e, y), ke(e, n), ke(n, i), on(r, i, null), ke(n, o), B && B.m(n, null), ke(n, s), ke(n, a), ke(a, l), ke(l, u), ke(l, c), ke(e, d), ke(e, h), ke(h, _), on(m, _, null), ke(h, E), ke(h, w), X[g].m(w, null), ke(h, C), ke(h, M), on(A, M, null), ke(e, D), ke(e, W), J && J.m(W, null), j = !0, U || (oe = [
        Pn(
          i,
          "click",
          /*click_handler*/
          t[15]
        ),
        Pn(
          a,
          "click",
          /*click_handler_1*/
          t[18]
        ),
        Pn(
          _,
          "click",
          /*click_handler_2*/
          t[19]
        ),
        Pn(
          w,
          "click",
          /*click_handler_3*/
          t[20]
        ),
        Pn(
          M,
          "click",
          /*click_handler_4*/
          t[21]
        )
      ], U = !0);
    },
    p(v, [y]) {
      const N = {};
      y & /*currentVolume*/
      4096 && (N.currentVolume = /*currentVolume*/
      v[12]), r.$set(N), y & /*show_volume_slider*/
      2 && xs(
        i,
        "color",
        /*show_volume_slider*/
        v[1] ? "var(--color-accent)" : "var(--neutral-400)"
      ), /*show_volume_slider*/
      v[1] ? B ? (B.p(v, y), y & /*show_volume_slider*/
      2 && pe(B, 1)) : (B = tl(v), B.c(), pe(B, 1), B.m(n, s)) : B && (Gi(), Le(B, 1, 1, () => {
        B = null;
      }), Wi()), (!j || y & /*playbackSpeed*/
      2048) && _0(
        u,
        /*playbackSpeed*/
        v[11]
      ), (!j || y & /*playbackSpeed*/
      2048 && f !== (f = `Adjust playback speed to ${/*playbackSpeeds*/
      v[13][
        /*playbackSpeeds*/
        (v[13].indexOf(
          /*playbackSpeed*/
          v[11]
        ) + 1) % /*playbackSpeeds*/
        v[13].length
      ]}x`)) && ue(a, "aria-label", f), (!j || y & /*show_volume_slider*/
      2) && el(
        a,
        "hidden",
        /*show_volume_slider*/
        v[1]
      ), (!j || y & /*audio_duration, waveform_options*/
      520 && p !== (p = `Skip backwards by ${Mn(
        /*audio_duration*/
        v[3],
        /*waveform_options*/
        v[9].skip_length
      )} seconds`)) && ue(_, "aria-label", p);
      let S = g;
      g = le(v), g !== S && (Gi(), Le(X[S], 1, 1, () => {
        X[S] = null;
      }), Wi(), b = X[g], b || (b = X[g] = O[g](v), b.c()), pe(b, 1), b.m(w, null)), (!j || y & /*playing, i18n*/
      48 && T !== (T = /*playing*/
      v[5] ? (
        /*i18n*/
        v[4]("audio.pause")
      ) : (
        /*i18n*/
        v[4]("audio.play")
      ))) && ue(w, "aria-label", T), (!j || y & /*audio_duration, waveform_options*/
      520 && P !== (P = "Skip forward by " + Mn(
        /*audio_duration*/
        v[3],
        /*waveform_options*/
        v[9].skip_length
      ) + " seconds")) && ue(M, "aria-label", P), /*editable*/
      v[10] && /*interactive*/
      v[7] ? J ? (J.p(v, y), y & /*editable, interactive*/
      1152 && pe(J, 1)) : (J = nl(v), J.c(), pe(J, 1), J.m(W, null)) : J && (Gi(), Le(J, 1, 1, () => {
        J = null;
      }), Wi());
    },
    i(v) {
      j || (pe(r.$$.fragment, v), pe(B), pe(m.$$.fragment, v), pe(b), pe(A.$$.fragment, v), pe(J), j = !0);
    },
    o(v) {
      Le(r.$$.fragment, v), Le(B), Le(m.$$.fragment, v), Le(b), Le(A.$$.fragment, v), Le(J), j = !1;
    },
    d(v) {
      v && $o(e), rn(r), B && B.d(), rn(m), X[g].d(), rn(A), J && J.d(), U = !1, d0(oe);
    }
  };
}
function b0(t, e, n) {
  let { waveform: i } = e, { audio_duration: r } = e, { i18n: o } = e, { playing: s } = e, { show_redo: a = !1 } = e, { interactive: l = !1 } = e, { mode: u = "" } = e, { handle_reset_value: c } = e, { waveform_options: f = {} } = e, { show_volume_slider: d = !1 } = e, { editable: h = !0 } = e, { trimDuration: _ = 0 } = e, m = [0.5, 1, 1.5, 2], p = m[1], E = 1;
  const w = () => n(1, d = !d);
  function g(D) {
    E = D, n(12, E);
  }
  function b(D) {
    d = D, n(1, d);
  }
  const T = () => {
    n(11, p = m[(m.indexOf(p) + 1) % m.length]), i.setPlaybackRate(p);
  }, C = () => i.skip(Mn(r, f.skip_length) * -1), M = () => i.playPause(), A = () => i.skip(Mn(r, f.skip_length)), P = () => {
    c(), n(0, u = "");
  };
  return t.$$set = (D) => {
    "waveform" in D && n(2, i = D.waveform), "audio_duration" in D && n(3, r = D.audio_duration), "i18n" in D && n(4, o = D.i18n), "playing" in D && n(5, s = D.playing), "show_redo" in D && n(6, a = D.show_redo), "interactive" in D && n(7, l = D.interactive), "mode" in D && n(0, u = D.mode), "handle_reset_value" in D && n(8, c = D.handle_reset_value), "waveform_options" in D && n(9, f = D.waveform_options), "show_volume_slider" in D && n(1, d = D.show_volume_slider), "editable" in D && n(10, h = D.editable), "trimDuration" in D && n(14, _ = D.trimDuration);
  }, [
    u,
    d,
    i,
    r,
    o,
    s,
    a,
    l,
    c,
    f,
    h,
    p,
    E,
    m,
    _,
    w,
    g,
    b,
    T,
    C,
    M,
    A,
    P
  ];
}
class eu extends a0 {
  constructor(e) {
    super(), c0(this, e, b0, g0, h0, {
      waveform: 2,
      audio_duration: 3,
      i18n: 4,
      playing: 5,
      show_redo: 6,
      interactive: 7,
      mode: 0,
      handle_reset_value: 8,
      waveform_options: 9,
      show_volume_slider: 1,
      editable: 10,
      trimDuration: 14
    });
  }
}
const {
  SvelteComponent: v0,
  add_flush_callback: so,
  append: se,
  attr: $,
  bind: lo,
  binding_callbacks: Nn,
  check_outros: tu,
  create_component: ts,
  destroy_component: ns,
  destroy_each: nu,
  detach: St,
  element: Be,
  empty: _r,
  ensure_array_like: xi,
  group_outros: iu,
  init: w0,
  insert: At,
  listen: y0,
  mount_component: is,
  noop: rl,
  safe_not_equal: k0,
  set_data: rs,
  space: bt,
  src_url_equal: ol,
  text: os,
  transition_in: jt,
  transition_out: an
} = window.__gradio__svelte__internal, { onMount: E0 } = window.__gradio__svelte__internal, { createEventDispatcher: C0 } = window.__gradio__svelte__internal;
function sl(t, e, n) {
  const i = t.slice();
  return i[36] = e[n], i;
}
function ll(t, e, n) {
  const i = t.slice();
  return i[33] = e[n], i;
}
function S0(t) {
  let e, n, i, r, o, s, a, l, u, c, f, d, h, _, m, p, E = (
    /*audioDecoded*/
    t[17] && al(t)
  ), w = (
    /*mode*/
    t[0] === "edit" && /*trimDuration*/
    t[18] > 0 && fl(t)
  ), g = (
    /*waveform*/
    t[10] && dl(t)
  );
  return {
    c() {
      e = Be("div"), n = Be("div"), i = Be("div"), E && E.c(), r = bt(), o = Be("div"), s = Be("div"), a = bt(), l = Be("div"), u = Be("time"), u.textContent = "0:00", c = bt(), f = Be("div"), w && w.c(), d = bt(), h = Be("time"), h.textContent = "0:00", _ = bt(), g && g.c(), $(i, "class", "source-selection svelte-vzn0r6"), $(s, "id", "waveform"), $(s, "class", "svelte-vzn0r6"), $(u, "id", "time"), $(u, "class", "svelte-vzn0r6"), $(h, "id", "duration"), $(h, "class", "svelte-vzn0r6"), $(l, "class", "timestamps svelte-vzn0r6"), $(o, "class", "waveform-container svelte-vzn0r6"), $(n, "class", "viewer svelte-vzn0r6"), $(e, "class", "component-wrapper svelte-vzn0r6"), $(e, "data-testid", m = /*label*/
      t[2] ? "waveform-" + /*label*/
      t[2] : "unlabelled-audio");
    },
    m(b, T) {
      At(b, e, T), se(e, n), se(n, i), E && E.m(i, null), se(n, r), se(n, o), se(o, s), t[25](s), se(o, a), se(o, l), se(l, u), t[26](u), se(l, c), se(l, f), w && w.m(f, null), se(f, d), se(f, h), t[27](h), se(e, _), g && g.m(e, null), p = !0;
    },
    p(b, T) {
      /*audioDecoded*/
      b[17] ? E ? E.p(b, T) : (E = al(b), E.c(), E.m(i, null)) : E && (E.d(1), E = null), /*mode*/
      b[0] === "edit" && /*trimDuration*/
      b[18] > 0 ? w ? w.p(b, T) : (w = fl(b), w.c(), w.m(f, d)) : w && (w.d(1), w = null), /*waveform*/
      b[10] ? g ? (g.p(b, T), T[0] & /*waveform*/
      1024 && jt(g, 1)) : (g = dl(b), g.c(), jt(g, 1), g.m(e, null)) : g && (iu(), an(g, 1, 1, () => {
        g = null;
      }), tu()), (!p || T[0] & /*label*/
      4 && m !== (m = /*label*/
      b[2] ? "waveform-" + /*label*/
      b[2] : "unlabelled-audio")) && $(e, "data-testid", m);
    },
    i(b) {
      p || (jt(g), p = !0);
    },
    o(b) {
      an(g), p = !1;
    },
    d(b) {
      b && St(e), E && E.d(), t[25](null), t[26](null), w && w.d(), t[27](null), g && g.d();
    }
  };
}
function A0(t) {
  let e, n, i;
  return {
    c() {
      e = Be("audio"), $(e, "class", "standard-player svelte-vzn0r6"), ol(e.src, n = /*value*/
      t[1].audio_file.url) || $(e, "src", n), e.controls = !0, e.autoplay = i = /*waveform_settings*/
      t[6].autoplay;
    },
    m(r, o) {
      At(r, e, o);
    },
    p(r, o) {
      o[0] & /*value*/
      2 && !ol(e.src, n = /*value*/
      r[1].audio_file.url) && $(e, "src", n), o[0] & /*waveform_settings*/
      64 && i !== (i = /*waveform_settings*/
      r[6].autoplay) && (e.autoplay = i);
    },
    i: rl,
    o: rl,
    d(r) {
      r && St(e);
    }
  };
}
function T0(t) {
  let e, n;
  return e = new Fa({
    props: {
      size: "small",
      $$slots: { default: [M0] },
      $$scope: { ctx: t }
    }
  }), {
    c() {
      ts(e.$$.fragment);
    },
    m(i, r) {
      is(e, i, r), n = !0;
    },
    p(i, r) {
      const o = {};
      r[1] & /*$$scope*/
      256 && (o.$$scope = { dirty: r, ctx: i }), e.$set(o);
    },
    i(i) {
      n || (jt(e.$$.fragment, i), n = !0);
    },
    o(i) {
      an(e.$$.fragment, i), n = !1;
    },
    d(i) {
      ns(e, i);
    }
  };
}
function al(t) {
  let e;
  function n(o, s) {
    return (
      /*value*/
      o[1].multichannel ? D0 : P0
    );
  }
  let i = n(t), r = i(t);
  return {
    c() {
      r.c(), e = _r();
    },
    m(o, s) {
      r.m(o, s), At(o, e, s);
    },
    p(o, s) {
      i === (i = n(o)) && r ? r.p(o, s) : (r.d(1), r = i(o), r && (r.c(), r.m(e.parentNode, e)));
    },
    d(o) {
      o && St(e), r.d(o);
    }
  };
}
function P0(t) {
  let e, n = xi([...Array(
    /*value*/
    t[1].labels.length
  )].keys()), i = [];
  for (let r = 0; r < n.length; r += 1)
    i[r] = ul(sl(t, n, r));
  return {
    c() {
      for (let r = 0; r < i.length; r += 1)
        i[r].c();
      e = _r();
    },
    m(r, o) {
      for (let s = 0; s < i.length; s += 1)
        i[s] && i[s].m(r, o);
      At(r, e, o);
    },
    p(r, o) {
      if (o[0] & /*colors, value*/
      1048578) {
        n = xi([...Array(
          /*value*/
          r[1].labels.length
        )].keys());
        let s;
        for (s = 0; s < n.length; s += 1) {
          const a = sl(r, n, s);
          i[s] ? i[s].p(a, o) : (i[s] = ul(a), i[s].c(), i[s].m(e.parentNode, e));
        }
        for (; s < i.length; s += 1)
          i[s].d(1);
        i.length = n.length;
      }
    },
    d(r) {
      r && St(e), nu(i, r);
    }
  };
}
function D0(t) {
  let e, n = xi([...Array(
    /*waveform*/
    t[10].getDecodedData().numberOfChannels
  ).keys()]), i = [];
  for (let r = 0; r < n.length; r += 1)
    i[r] = cl(ll(t, n, r));
  return {
    c() {
      for (let r = 0; r < i.length; r += 1)
        i[r].c();
      e = _r();
    },
    m(r, o) {
      for (let s = 0; s < i.length; s += 1)
        i[s] && i[s].m(r, o);
      At(r, e, o);
    },
    p(r, o) {
      if (o[0] & /*waveform_settings, colors, waveform, value, splitter, audioContext*/
      1074242) {
        n = xi([...Array(
          /*waveform*/
          r[10].getDecodedData().numberOfChannels
        ).keys()]);
        let s;
        for (s = 0; s < n.length; s += 1) {
          const a = ll(r, n, s);
          i[s] ? i[s].p(a, o) : (i[s] = cl(a), i[s].c(), i[s].m(e.parentNode, e));
        }
        for (; s < i.length; s += 1)
          i[s].d(1);
        i.length = n.length;
      }
    },
    d(r) {
      r && St(e), nu(i, r);
    }
  };
}
function ul(t) {
  let e, n, i, r = (
    /*value*/
    t[1].labels[
      /*labelIdx*/
      t[36]
    ] + ""
  ), o, s, a;
  return {
    c() {
      e = Be("label"), n = Be("input"), i = bt(), o = os(r), s = bt(), $(n, "type", "hidden"), $(e, "style", a = `background-color: ${/*colors*/
      t[20][
        /*labelIdx*/
        t[36] % /*colors*/
        t[20].length
      ]};`), $(e, "class", "svelte-vzn0r6");
    },
    m(l, u) {
      At(l, e, u), se(e, n), se(e, i), se(e, o), se(e, s);
    },
    p(l, u) {
      u[0] & /*value*/
      2 && r !== (r = /*value*/
      l[1].labels[
        /*labelIdx*/
        l[36]
      ] + "") && rs(o, r), u[0] & /*value*/
      2 && a !== (a = `background-color: ${/*colors*/
      l[20][
        /*labelIdx*/
        l[36] % /*colors*/
        l[20].length
      ]};`) && $(e, "style", a);
    },
    d(l) {
      l && St(e);
    }
  };
}
function cl(t) {
  let e, n, i, r, o = (
    /*value*/
    t[1].labels[
      /*channelIdx*/
      t[33]
    ] + ""
  ), s, a, l, u, c;
  return {
    c() {
      e = Be("label"), n = Be("input"), r = bt(), s = os(o), a = bt(), $(n, "type", "radio"), $(n, "name", "channels"), n.value = i = `${/*channelIdx*/
      t[33]}`, $(n, "class", "svelte-vzn0r6"), $(e, "style", l = `height: ${/*waveform_settings*/
      t[6].height}px; background-color: ${/*colors*/
      t[20][
        /*channelIdx*/
        t[33] % /*colors*/
        t[20].length
      ]}`), $(e, "class", "svelte-vzn0r6");
    },
    m(f, d) {
      At(f, e, d), se(e, n), se(e, r), se(e, s), se(e, a), u || (c = y0(
        n,
        "change",
        /*change_handler*/
        t[24]
      ), u = !0);
    },
    p(f, d) {
      d[0] & /*waveform*/
      1024 && i !== (i = `${/*channelIdx*/
      f[33]}`) && (n.value = i), d[0] & /*value, waveform*/
      1026 && o !== (o = /*value*/
      f[1].labels[
        /*channelIdx*/
        f[33]
      ] + "") && rs(s, o), d[0] & /*waveform_settings, waveform*/
      1088 && l !== (l = `height: ${/*waveform_settings*/
      f[6].height}px; background-color: ${/*colors*/
      f[20][
        /*channelIdx*/
        f[33] % /*colors*/
        f[20].length
      ]}`) && $(e, "style", l);
    },
    d(f) {
      f && St(e), u = !1, c();
    }
  };
}
function fl(t) {
  let e, n = xe(
    /*trimDuration*/
    t[18]
  ) + "", i;
  return {
    c() {
      e = Be("time"), i = os(n), $(e, "id", "trim-duration"), $(e, "class", "svelte-vzn0r6");
    },
    m(r, o) {
      At(r, e, o), se(e, i);
    },
    p(r, o) {
      o[0] & /*trimDuration*/
      262144 && n !== (n = xe(
        /*trimDuration*/
        r[18]
      ) + "") && rs(i, n);
    },
    d(r) {
      r && St(e);
    }
  };
}
function dl(t) {
  let e, n, i, r, o;
  function s(c) {
    t[28](c);
  }
  function a(c) {
    t[29](c);
  }
  function l(c) {
    t[30](c);
  }
  let u = {
    waveform: (
      /*waveform*/
      t[10]
    ),
    playing: (
      /*playing*/
      t[15]
    ),
    audio_duration: (
      /*audio_duration*/
      t[16]
    ),
    i18n: (
      /*i18n*/
      t[3]
    ),
    interactive: (
      /*interactive*/
      t[4]
    ),
    show_redo: (
      /*interactive*/
      t[4]
    ),
    handle_reset_value: (
      /*handle_reset_value*/
      t[8]
    ),
    waveform_options: (
      /*waveform_options*/
      t[7]
    ),
    editable: (
      /*editable*/
      t[5]
    )
  };
  return (
    /*mode*/
    t[0] !== void 0 && (u.mode = /*mode*/
    t[0]), /*trimDuration*/
    t[18] !== void 0 && (u.trimDuration = /*trimDuration*/
    t[18]), /*show_volume_slider*/
    t[19] !== void 0 && (u.show_volume_slider = /*show_volume_slider*/
    t[19]), e = new eu({ props: u }), Nn.push(() => lo(e, "mode", s)), Nn.push(() => lo(e, "trimDuration", a)), Nn.push(() => lo(e, "show_volume_slider", l)), {
      c() {
        ts(e.$$.fragment);
      },
      m(c, f) {
        is(e, c, f), o = !0;
      },
      p(c, f) {
        const d = {};
        f[0] & /*waveform*/
        1024 && (d.waveform = /*waveform*/
        c[10]), f[0] & /*playing*/
        32768 && (d.playing = /*playing*/
        c[15]), f[0] & /*audio_duration*/
        65536 && (d.audio_duration = /*audio_duration*/
        c[16]), f[0] & /*i18n*/
        8 && (d.i18n = /*i18n*/
        c[3]), f[0] & /*interactive*/
        16 && (d.interactive = /*interactive*/
        c[4]), f[0] & /*interactive*/
        16 && (d.show_redo = /*interactive*/
        c[4]), f[0] & /*handle_reset_value*/
        256 && (d.handle_reset_value = /*handle_reset_value*/
        c[8]), f[0] & /*waveform_options*/
        128 && (d.waveform_options = /*waveform_options*/
        c[7]), f[0] & /*editable*/
        32 && (d.editable = /*editable*/
        c[5]), !n && f[0] & /*mode*/
        1 && (n = !0, d.mode = /*mode*/
        c[0], so(() => n = !1)), !i && f[0] & /*trimDuration*/
        262144 && (i = !0, d.trimDuration = /*trimDuration*/
        c[18], so(() => i = !1)), !r && f[0] & /*show_volume_slider*/
        524288 && (r = !0, d.show_volume_slider = /*show_volume_slider*/
        c[19], so(() => r = !1)), e.$set(d);
      },
      i(c) {
        o || (jt(e.$$.fragment, c), o = !0);
      },
      o(c) {
        an(e.$$.fragment, c), o = !1;
      },
      d(c) {
        ns(e, c);
      }
    }
  );
}
function M0(t) {
  let e, n;
  return e = new ur({}), {
    c() {
      ts(e.$$.fragment);
    },
    m(i, r) {
      is(e, i, r), n = !0;
    },
    i(i) {
      n || (jt(e.$$.fragment, i), n = !0);
    },
    o(i) {
      an(e.$$.fragment, i), n = !1;
    },
    d(i) {
      ns(e, i);
    }
  };
}
function R0(t) {
  let e, n, i, r;
  const o = [T0, A0, S0], s = [];
  function a(l, u) {
    return (
      /*value*/
      l[1] === null ? 0 : (
        /*value*/
        l[1].audio_file.is_stream ? 1 : 2
      )
    );
  }
  return e = a(t), n = s[e] = o[e](t), {
    c() {
      n.c(), i = _r();
    },
    m(l, u) {
      s[e].m(l, u), At(l, i, u), r = !0;
    },
    p(l, u) {
      let c = e;
      e = a(l), e === c ? s[e].p(l, u) : (iu(), an(s[c], 1, 1, () => {
        s[c] = null;
      }), tu(), n = s[e], n ? n.p(l, u) : (n = s[e] = o[e](l), n.c()), jt(n, 1), n.m(i.parentNode, i));
    },
    i(l) {
      r || (jt(n), r = !0);
    },
    o(l) {
      an(n), r = !1;
    },
    d(l) {
      l && St(i), s[e].d(l);
    }
  };
}
function Bt(t) {
  let e, n = t[0], i = 1;
  for (; i < t.length; ) {
    const r = t[i], o = t[i + 1];
    if (i += 2, (r === "optionalAccess" || r === "optionalCall") && n == null)
      return;
    r === "access" || r === "optionalAccess" ? (e = n, n = o(n)) : (r === "call" || r === "optionalCall") && (n = o((...s) => n.call(e, ...s)), e = void 0);
  }
  return n;
}
function L0(t, e, n) {
  let { value: i = null } = e, { label: r } = e, { root: o } = e, { i18n: s } = e, { interactive: a = !1 } = e, { editable: l = !0 } = e, { waveform_settings: u } = e, { waveform_options: c } = e, { mode: f = "" } = e, { handle_reset_value: d = () => {
  } } = e, h, _, m, p = !1, E, w, g, b = ["#f005", "#0f05", "#00f5", "#ff05", "#f0f5", "#0ff5"], T = !1, C, M, A, P = 0, D = !1;
  const W = C0(), j = () => {
    const v = new Audio(o + `/file=${i.audio_file.path}`);
    v.crossOrigin = "anonymous", n(13, C = new AudioContext()), n(10, _ = qt.create({
      container: h,
      media: v,
      splitChannels: i.multichannel,
      ...u
    }));
  };
  E0(() => {
    window.addEventListener("keydown", (v) => {
      !_ || D || (v.key === "ArrowRight" && f !== "edit" ? Ki(_, 0.1) : v.key === "ArrowLeft" && f !== "edit" && Ki(_, -0.1));
    });
  });
  const U = (v) => {
    A.disconnect(), A.connect(C.destination, Number(v.target.value), 0);
  };
  function oe(v) {
    Nn[v ? "unshift" : "push"](() => {
      h = v, n(9, h), n(10, _);
    });
  }
  function B(v) {
    Nn[v ? "unshift" : "push"](() => {
      E = v, n(11, E), n(10, _);
    });
  }
  function O(v) {
    Nn[v ? "unshift" : "push"](() => {
      w = v, n(12, w), n(10, _), n(13, C), n(23, M), n(14, A), n(1, i), n(22, m), n(20, b);
    });
  }
  function X(v) {
    f = v, n(0, f);
  }
  function le(v) {
    P = v, n(18, P);
  }
  function J(v) {
    D = v, n(19, D);
  }
  return t.$$set = (v) => {
    "value" in v && n(1, i = v.value), "label" in v && n(2, r = v.label), "root" in v && n(21, o = v.root), "i18n" in v && n(3, s = v.i18n), "interactive" in v && n(4, a = v.interactive), "editable" in v && n(5, l = v.editable), "waveform_settings" in v && n(6, u = v.waveform_settings), "waveform_options" in v && n(7, c = v.waveform_options), "mode" in v && n(0, f = v.mode), "handle_reset_value" in v && n(8, d = v.handle_reset_value);
  }, t.$$.update = () => {
    t.$$.dirty[0] & /*container, waveform*/
    1536 && h !== void 0 && (_ !== void 0 && _.destroy(), n(9, h.innerHTML = "", h), j(), n(15, p = !1)), t.$$.dirty[0] & /*waveform, durationRef, audioContext, mediaNode, splitter, value, wsRegion*/
    12612610 && Bt([
      _,
      "optionalAccess",
      (v) => v.on,
      "call",
      (v) => v("decode", (y) => {
        n(17, T = !0);
        const N = _.getDecodedData().numberOfChannels;
        console.log(N), n(16, g = y), w && n(12, w.textContent = xe(y), w), n(23, M = C.createMediaElementSource(_.getMediaElement())), n(14, A = C.createChannelSplitter(N)), M.connect(A), i.multichannel || A.connect(C.destination, 0), m || (n(22, m = _.registerPlugin(O_.create())), i.segments.forEach((S) => {
          const k = m.addRegion({
            start: S.start,
            end: S.end,
            channelIdx: i.multichannel ? S.channel : 0,
            drag: !1,
            resize: !1,
            color: b[S.channel % b.length]
          }), z = 100 / (i.multichannel ? N : 1);
          k.element.style.cssText += `height: ${z}% !important;`, k.element.style.cssText += `background-color: ${k.color} !important;`;
        }));
      })
    ]), t.$$.dirty[0] & /*waveform, timeRef*/
    3072 && Bt([
      _,
      "optionalAccess",
      (v) => v.on,
      "call",
      (v) => v("timeupdate", (y) => E && n(11, E.textContent = xe(y), E))
    ]), t.$$.dirty[0] & /*waveform, waveform_settings*/
    1088 && Bt([
      _,
      "optionalAccess",
      (v) => v.on,
      "call",
      (v) => v("ready", () => {
        u.autoplay ? Bt([_, "optionalAccess", (y) => y.play, "call", (y) => y()]) : Bt([_, "optionalAccess", (y) => y.stop, "call", (y) => y()]);
      })
    ]), t.$$.dirty[0] & /*waveform*/
    1024 && Bt([
      _,
      "optionalAccess",
      (v) => v.on,
      "call",
      (v) => v("finish", () => {
        n(15, p = !1), W("stop");
      })
    ]), t.$$.dirty[0] & /*waveform*/
    1024 && Bt([
      _,
      "optionalAccess",
      (v) => v.on,
      "call",
      (v) => v("pause", () => {
        n(15, p = !1), W("pause");
      })
    ]), t.$$.dirty[0] & /*waveform*/
    1024 && Bt([
      _,
      "optionalAccess",
      (v) => v.on,
      "call",
      (v) => v("play", () => {
        n(15, p = !0), W("play");
      })
    ]);
  }, [
    f,
    i,
    r,
    s,
    a,
    l,
    u,
    c,
    d,
    h,
    _,
    E,
    w,
    C,
    A,
    p,
    g,
    T,
    P,
    D,
    b,
    o,
    m,
    M,
    U,
    oe,
    B,
    O,
    X,
    le,
    J
  ];
}
class ru extends v0 {
  constructor(e) {
    super(), w0(
      this,
      e,
      L0,
      R0,
      k0,
      {
        value: 1,
        label: 2,
        root: 21,
        i18n: 3,
        interactive: 4,
        editable: 5,
        waveform_settings: 6,
        waveform_options: 7,
        mode: 0,
        handle_reset_value: 8
      },
      null,
      [-1, -1]
    );
  }
}
const { setContext: Iv, getContext: B0 } = window.__gradio__svelte__internal, O0 = "WORKER_PROXY_CONTEXT_KEY";
function N0() {
  return B0(O0);
}
function H0(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";
}
function I0(t, e) {
  const n = e.toLowerCase();
  for (const [i, r] of Object.entries(t))
    if (i.toLowerCase() === n)
      return r;
}
function U0(t) {
  if (t == null)
    return !1;
  const e = new URL(t, window.location.href);
  return !(!H0(e) || e.protocol !== "http:" && e.protocol !== "https:");
}
const {
  SvelteComponent: j0,
  assign: $i,
  check_outros: ou,
  compute_rest_props: hl,
  create_slot: ss,
  detach: mr,
  element: su,
  empty: lu,
  exclude_internal_props: z0,
  get_all_dirty_from_scope: ls,
  get_slot_changes: as,
  get_spread_update: au,
  group_outros: uu,
  init: F0,
  insert: pr,
  listen: cu,
  prevent_default: q0,
  safe_not_equal: W0,
  set_attributes: er,
  transition_in: un,
  transition_out: cn,
  update_slot_base: us
} = window.__gradio__svelte__internal, { createEventDispatcher: G0 } = window.__gradio__svelte__internal;
function V0(t) {
  let e, n, i, r, o;
  const s = (
    /*#slots*/
    t[8].default
  ), a = ss(
    s,
    t,
    /*$$scope*/
    t[7],
    null
  );
  let l = [
    { href: (
      /*href*/
      t[0]
    ) },
    {
      target: n = typeof window < "u" && window.__is_colab__ ? "_blank" : null
    },
    { rel: "noopener noreferrer" },
    { download: (
      /*download*/
      t[1]
    ) },
    /*$$restProps*/
    t[6]
  ], u = {};
  for (let c = 0; c < l.length; c += 1)
    u = $i(u, l[c]);
  return {
    c() {
      e = su("a"), a && a.c(), er(e, u);
    },
    m(c, f) {
      pr(c, e, f), a && a.m(e, null), i = !0, r || (o = cu(
        e,
        "click",
        /*dispatch*/
        t[3].bind(null, "click")
      ), r = !0);
    },
    p(c, f) {
      a && a.p && (!i || f & /*$$scope*/
      128) && us(
        a,
        s,
        c,
        /*$$scope*/
        c[7],
        i ? as(
          s,
          /*$$scope*/
          c[7],
          f,
          null
        ) : ls(
          /*$$scope*/
          c[7]
        ),
        null
      ), er(e, u = au(l, [
        (!i || f & /*href*/
        1) && { href: (
          /*href*/
          c[0]
        ) },
        { target: n },
        { rel: "noopener noreferrer" },
        (!i || f & /*download*/
        2) && { download: (
          /*download*/
          c[1]
        ) },
        f & /*$$restProps*/
        64 && /*$$restProps*/
        c[6]
      ]));
    },
    i(c) {
      i || (un(a, c), i = !0);
    },
    o(c) {
      cn(a, c), i = !1;
    },
    d(c) {
      c && mr(e), a && a.d(c), r = !1, o();
    }
  };
}
function X0(t) {
  let e, n, i, r;
  const o = [J0, Z0], s = [];
  function a(l, u) {
    return (
      /*is_downloading*/
      l[2] ? 0 : 1
    );
  }
  return e = a(t), n = s[e] = o[e](t), {
    c() {
      n.c(), i = lu();
    },
    m(l, u) {
      s[e].m(l, u), pr(l, i, u), r = !0;
    },
    p(l, u) {
      let c = e;
      e = a(l), e === c ? s[e].p(l, u) : (uu(), cn(s[c], 1, 1, () => {
        s[c] = null;
      }), ou(), n = s[e], n ? n.p(l, u) : (n = s[e] = o[e](l), n.c()), un(n, 1), n.m(i.parentNode, i));
    },
    i(l) {
      r || (un(n), r = !0);
    },
    o(l) {
      cn(n), r = !1;
    },
    d(l) {
      l && mr(i), s[e].d(l);
    }
  };
}
function Z0(t) {
  let e, n, i, r;
  const o = (
    /*#slots*/
    t[8].default
  ), s = ss(
    o,
    t,
    /*$$scope*/
    t[7],
    null
  );
  let a = [
    /*$$restProps*/
    t[6],
    { href: (
      /*href*/
      t[0]
    ) }
  ], l = {};
  for (let u = 0; u < a.length; u += 1)
    l = $i(l, a[u]);
  return {
    c() {
      e = su("a"), s && s.c(), er(e, l);
    },
    m(u, c) {
      pr(u, e, c), s && s.m(e, null), n = !0, i || (r = cu(e, "click", q0(
        /*wasm_click_handler*/
        t[5]
      )), i = !0);
    },
    p(u, c) {
      s && s.p && (!n || c & /*$$scope*/
      128) && us(
        s,
        o,
        u,
        /*$$scope*/
        u[7],
        n ? as(
          o,
          /*$$scope*/
          u[7],
          c,
          null
        ) : ls(
          /*$$scope*/
          u[7]
        ),
        null
      ), er(e, l = au(a, [
        c & /*$$restProps*/
        64 && /*$$restProps*/
        u[6],
        (!n || c & /*href*/
        1) && { href: (
          /*href*/
          u[0]
        ) }
      ]));
    },
    i(u) {
      n || (un(s, u), n = !0);
    },
    o(u) {
      cn(s, u), n = !1;
    },
    d(u) {
      u && mr(e), s && s.d(u), i = !1, r();
    }
  };
}
function J0(t) {
  let e;
  const n = (
    /*#slots*/
    t[8].default
  ), i = ss(
    n,
    t,
    /*$$scope*/
    t[7],
    null
  );
  return {
    c() {
      i && i.c();
    },
    m(r, o) {
      i && i.m(r, o), e = !0;
    },
    p(r, o) {
      i && i.p && (!e || o & /*$$scope*/
      128) && us(
        i,
        n,
        r,
        /*$$scope*/
        r[7],
        e ? as(
          n,
          /*$$scope*/
          r[7],
          o,
          null
        ) : ls(
          /*$$scope*/
          r[7]
        ),
        null
      );
    },
    i(r) {
      e || (un(i, r), e = !0);
    },
    o(r) {
      cn(i, r), e = !1;
    },
    d(r) {
      i && i.d(r);
    }
  };
}
function Y0(t) {
  let e, n, i, r, o;
  const s = [X0, V0], a = [];
  function l(u, c) {
    return c & /*href*/
    1 && (e = null), e == null && (e = !!/*worker_proxy*/
    (u[4] && U0(
      /*href*/
      u[0]
    ))), e ? 0 : 1;
  }
  return n = l(t, -1), i = a[n] = s[n](t), {
    c() {
      i.c(), r = lu();
    },
    m(u, c) {
      a[n].m(u, c), pr(u, r, c), o = !0;
    },
    p(u, [c]) {
      let f = n;
      n = l(u, c), n === f ? a[n].p(u, c) : (uu(), cn(a[f], 1, 1, () => {
        a[f] = null;
      }), ou(), i = a[n], i ? i.p(u, c) : (i = a[n] = s[n](u), i.c()), un(i, 1), i.m(r.parentNode, r));
    },
    i(u) {
      o || (un(i), o = !0);
    },
    o(u) {
      cn(i), o = !1;
    },
    d(u) {
      u && mr(r), a[n].d(u);
    }
  };
}
function Q0(t, e, n) {
  const i = ["href", "download"];
  let r = hl(e, i), { $$slots: o = {}, $$scope: s } = e, { href: a = void 0 } = e, { download: l } = e;
  const u = G0();
  let c = !1;
  const f = N0();
  async function d() {
    if (c)
      return;
    if (u("click"), a == null)
      throw new Error("href is not defined.");
    if (f == null)
      throw new Error("Wasm worker proxy is not available.");
    const _ = new URL(a, window.location.href).pathname;
    n(2, c = !0), f.httpRequest({
      method: "GET",
      path: _,
      headers: {},
      query_string: ""
    }).then((m) => {
      if (m.status !== 200)
        throw new Error(`Failed to get file ${_} from the Wasm worker.`);
      const p = new Blob(
        [m.body],
        {
          type: I0(m.headers, "content-type")
        }
      ), E = URL.createObjectURL(p), w = document.createElement("a");
      w.href = E, w.download = l, w.click(), URL.revokeObjectURL(E);
    }).finally(() => {
      n(2, c = !1);
    });
  }
  return t.$$set = (h) => {
    e = $i($i({}, e), z0(h)), n(6, r = hl(e, i)), "href" in h && n(0, a = h.href), "download" in h && n(1, l = h.download), "$$scope" in h && n(7, s = h.$$scope);
  }, [
    a,
    l,
    c,
    u,
    f,
    d,
    r,
    s,
    o
  ];
}
class fu extends j0 {
  constructor(e) {
    super(), F0(this, e, Q0, Y0, W0, { href: 0, download: 1 });
  }
}
const {
  SvelteComponent: K0,
  append: x0,
  attr: $0,
  bubble: ni,
  check_outros: Ro,
  create_component: pn,
  destroy_component: gn,
  detach: tr,
  element: em,
  empty: tm,
  group_outros: Lo,
  init: nm,
  insert: nr,
  mount_component: bn,
  safe_not_equal: im,
  space: Bo,
  transition_in: Oe,
  transition_out: Ve
} = window.__gradio__svelte__internal, { createEventDispatcher: rm } = window.__gradio__svelte__internal;
function om(t) {
  let e, n;
  return e = new Fa({
    props: {
      size: "small",
      $$slots: { default: [lm] },
      $$scope: { ctx: t }
    }
  }), {
    c() {
      pn(e.$$.fragment);
    },
    m(i, r) {
      bn(e, i, r), n = !0;
    },
    p(i, r) {
      const o = {};
      r & /*$$scope*/
      131072 && (o.$$scope = { dirty: r, ctx: i }), e.$set(o);
    },
    i(i) {
      n || (Oe(e.$$.fragment, i), n = !0);
    },
    o(i) {
      Ve(e.$$.fragment, i), n = !1;
    },
    d(i) {
      gn(e, i);
    }
  };
}
function sm(t) {
  let e, n, i, r, o, s = (
    /*show_download_button*/
    t[4] && _l(t)
  ), a = (
    /*show_share_button*/
    t[5] && ml(t)
  );
  return r = new ru({
    props: {
      value: (
        /*value*/
        t[0]
      ),
      label: (
        /*label*/
        t[1]
      ),
      root: (
        /*root*/
        t[2]
      ),
      i18n: (
        /*i18n*/
        t[6]
      ),
      waveform_settings: (
        /*waveform_settings*/
        t[7]
      ),
      waveform_options: (
        /*waveform_options*/
        t[8]
      ),
      editable: (
        /*editable*/
        t[9]
      )
    }
  }), r.$on(
    "pause",
    /*pause_handler*/
    t[13]
  ), r.$on(
    "play",
    /*play_handler*/
    t[14]
  ), r.$on(
    "stop",
    /*stop_handler*/
    t[15]
  ), {
    c() {
      e = em("div"), s && s.c(), n = Bo(), a && a.c(), i = Bo(), pn(r.$$.fragment), $0(e, "class", "icon-buttons svelte-1mrvp2o");
    },
    m(l, u) {
      nr(l, e, u), s && s.m(e, null), x0(e, n), a && a.m(e, null), nr(l, i, u), bn(r, l, u), o = !0;
    },
    p(l, u) {
      /*show_download_button*/
      l[4] ? s ? (s.p(l, u), u & /*show_download_button*/
      16 && Oe(s, 1)) : (s = _l(l), s.c(), Oe(s, 1), s.m(e, n)) : s && (Lo(), Ve(s, 1, 1, () => {
        s = null;
      }), Ro()), /*show_share_button*/
      l[5] ? a ? (a.p(l, u), u & /*show_share_button*/
      32 && Oe(a, 1)) : (a = ml(l), a.c(), Oe(a, 1), a.m(e, null)) : a && (Lo(), Ve(a, 1, 1, () => {
        a = null;
      }), Ro());
      const c = {};
      u & /*value*/
      1 && (c.value = /*value*/
      l[0]), u & /*label*/
      2 && (c.label = /*label*/
      l[1]), u & /*root*/
      4 && (c.root = /*root*/
      l[2]), u & /*i18n*/
      64 && (c.i18n = /*i18n*/
      l[6]), u & /*waveform_settings*/
      128 && (c.waveform_settings = /*waveform_settings*/
      l[7]), u & /*waveform_options*/
      256 && (c.waveform_options = /*waveform_options*/
      l[8]), u & /*editable*/
      512 && (c.editable = /*editable*/
      l[9]), r.$set(c);
    },
    i(l) {
      o || (Oe(s), Oe(a), Oe(r.$$.fragment, l), o = !0);
    },
    o(l) {
      Ve(s), Ve(a), Ve(r.$$.fragment, l), o = !1;
    },
    d(l) {
      l && (tr(e), tr(i)), s && s.d(), a && a.d(), gn(r, l);
    }
  };
}
function lm(t) {
  let e, n;
  return e = new ur({}), {
    c() {
      pn(e.$$.fragment);
    },
    m(i, r) {
      bn(e, i, r), n = !0;
    },
    i(i) {
      n || (Oe(e.$$.fragment, i), n = !0);
    },
    o(i) {
      Ve(e.$$.fragment, i), n = !1;
    },
    d(i) {
      gn(e, i);
    }
  };
}
function _l(t) {
  let e, n;
  return e = new fu({
    props: {
      href: (
        /*value*/
        t[0].audio_file.url
      ),
      download: (
        /*value*/
        t[0].audio_file.orig_name || /*value*/
        t[0].audio_file.path
      ),
      $$slots: { default: [am] },
      $$scope: { ctx: t }
    }
  }), {
    c() {
      pn(e.$$.fragment);
    },
    m(i, r) {
      bn(e, i, r), n = !0;
    },
    p(i, r) {
      const o = {};
      r & /*value*/
      1 && (o.href = /*value*/
      i[0].audio_file.url), r & /*value*/
      1 && (o.download = /*value*/
      i[0].audio_file.orig_name || /*value*/
      i[0].audio_file.path), r & /*$$scope, i18n*/
      131136 && (o.$$scope = { dirty: r, ctx: i }), e.$set(o);
    },
    i(i) {
      n || (Oe(e.$$.fragment, i), n = !0);
    },
    o(i) {
      Ve(e.$$.fragment, i), n = !1;
    },
    d(i) {
      gn(e, i);
    }
  };
}
function am(t) {
  let e, n;
  return e = new Xn({
    props: {
      Icon: qa,
      label: (
        /*i18n*/
        t[6]("common.download")
      )
    }
  }), {
    c() {
      pn(e.$$.fragment);
    },
    m(i, r) {
      bn(e, i, r), n = !0;
    },
    p(i, r) {
      const o = {};
      r & /*i18n*/
      64 && (o.label = /*i18n*/
      i[6]("common.download")), e.$set(o);
    },
    i(i) {
      n || (Oe(e.$$.fragment, i), n = !0);
    },
    o(i) {
      Ve(e.$$.fragment, i), n = !1;
    },
    d(i) {
      gn(e, i);
    }
  };
}
function ml(t) {
  let e, n;
  return e = new c_({
    props: {
      i18n: (
        /*i18n*/
        t[6]
      ),
      formatter: (
        /*func*/
        t[10]
      ),
      value: (
        /*value*/
        t[0]
      )
    }
  }), e.$on(
    "error",
    /*error_handler*/
    t[11]
  ), e.$on(
    "share",
    /*share_handler*/
    t[12]
  ), {
    c() {
      pn(e.$$.fragment);
    },
    m(i, r) {
      bn(e, i, r), n = !0;
    },
    p(i, r) {
      const o = {};
      r & /*i18n*/
      64 && (o.i18n = /*i18n*/
      i[6]), r & /*value*/
      1 && (o.value = /*value*/
      i[0]), e.$set(o);
    },
    i(i) {
      n || (Oe(e.$$.fragment, i), n = !0);
    },
    o(i) {
      Ve(e.$$.fragment, i), n = !1;
    },
    d(i) {
      gn(e, i);
    }
  };
}
function um(t) {
  let e, n, i, r, o, s;
  e = new Ua({
    props: {
      show_label: (
        /*show_label*/
        t[3]
      ),
      Icon: ur,
      float: !1,
      label: (
        /*label*/
        t[1] || /*i18n*/
        t[6]("audio.audio")
      )
    }
  });
  const a = [sm, om], l = [];
  function u(c, f) {
    return (
      /*value*/
      c[0] !== null ? 0 : 1
    );
  }
  return i = u(t), r = l[i] = a[i](t), {
    c() {
      pn(e.$$.fragment), n = Bo(), r.c(), o = tm();
    },
    m(c, f) {
      bn(e, c, f), nr(c, n, f), l[i].m(c, f), nr(c, o, f), s = !0;
    },
    p(c, [f]) {
      const d = {};
      f & /*show_label*/
      8 && (d.show_label = /*show_label*/
      c[3]), f & /*label, i18n*/
      66 && (d.label = /*label*/
      c[1] || /*i18n*/
      c[6]("audio.audio")), e.$set(d);
      let h = i;
      i = u(c), i === h ? l[i].p(c, f) : (Lo(), Ve(l[h], 1, 1, () => {
        l[h] = null;
      }), Ro(), r = l[i], r ? r.p(c, f) : (r = l[i] = a[i](c), r.c()), Oe(r, 1), r.m(o.parentNode, o));
    },
    i(c) {
      s || (Oe(e.$$.fragment, c), Oe(r), s = !0);
    },
    o(c) {
      Ve(e.$$.fragment, c), Ve(r), s = !1;
    },
    d(c) {
      c && (tr(n), tr(o)), gn(e, c), l[i].d(c);
    }
  };
}
function cm(t, e, n) {
  let { value: i = null } = e, { label: r } = e, { root: o } = e, { show_label: s = !0 } = e, { show_download_button: a = !0 } = e, { show_share_button: l = !1 } = e, { i18n: u } = e, { waveform_settings: c } = e, { waveform_options: f } = e, { editable: d = !0 } = e;
  const h = rm(), _ = async (b) => b ? `<audio controls src="${await Pc(b.url, "url")}"></audio>` : "";
  function m(b) {
    ni.call(this, t, b);
  }
  function p(b) {
    ni.call(this, t, b);
  }
  function E(b) {
    ni.call(this, t, b);
  }
  function w(b) {
    ni.call(this, t, b);
  }
  function g(b) {
    ni.call(this, t, b);
  }
  return t.$$set = (b) => {
    "value" in b && n(0, i = b.value), "label" in b && n(1, r = b.label), "root" in b && n(2, o = b.root), "show_label" in b && n(3, s = b.show_label), "show_download_button" in b && n(4, a = b.show_download_button), "show_share_button" in b && n(5, l = b.show_share_button), "i18n" in b && n(6, u = b.i18n), "waveform_settings" in b && n(7, c = b.waveform_settings), "waveform_options" in b && n(8, f = b.waveform_options), "editable" in b && n(9, d = b.editable);
  }, t.$$.update = () => {
    t.$$.dirty & /*value*/
    1 && i && h("change", i);
  }, [
    i,
    r,
    o,
    s,
    a,
    l,
    u,
    c,
    f,
    d,
    _,
    m,
    p,
    E,
    w,
    g
  ];
}
class fm extends K0 {
  constructor(e) {
    super(), nm(this, e, cm, um, im, {
      value: 0,
      label: 1,
      root: 2,
      show_label: 3,
      show_download_button: 4,
      show_share_button: 5,
      i18n: 6,
      waveform_settings: 7,
      waveform_options: 8,
      editable: 9
    });
  }
}
var ao = new Intl.Collator(0, { numeric: 1 }).compare;
function pl(t, e, n) {
  return t = t.split("."), e = e.split("."), ao(t[0], e[0]) || ao(t[1], e[1]) || (e[2] = e.slice(2).join("."), n = /[.-]/.test(t[2] = t.slice(2).join(".")), n == /[.-]/.test(e[2]) ? ao(t[2], e[2]) : n ? -1 : 1);
}
function du(t, e, n) {
  return e.startsWith("http://") || e.startsWith("https://") ? n ? t : e : t + e;
}
function uo(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 hu = /^[^\/]*\/[^\/]*$/, dm = /.*hf\.space\/{0,1}$/;
async function hm(t, e) {
  const n = {};
  e && (n.Authorization = `Bearer ${e}`);
  const i = t.trim();
  if (hu.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 o = (await r.json()).host;
      return {
        space_id: t,
        ...uo(o)
      };
    } catch (r) {
      throw new Error("Space metadata could not be loaded." + r.message);
    }
  if (dm.test(i)) {
    const { ws_protocol: r, http_protocol: o, host: s } = uo(i);
    return {
      space_id: s.replace(".hf.space", ""),
      ws_protocol: r,
      http_protocol: o,
      host: s
    };
  }
  return {
    space_id: !1,
    ...uo(i)
  };
}
function _m(t) {
  let e = {};
  return t.forEach(({ api_name: n }, i) => {
    n && (e[n] = i);
  }), e;
}
const mm = /^(?=[^]*\b[dD]iscussions{0,1}\b)(?=[^]*\b[dD]isabled\b)[^]*$/;
async function gl(t) {
  try {
    const n = (await fetch(
      `https://huggingface.co/api/spaces/${t}/discussions`,
      {
        method: "HEAD"
      }
    )).headers.get("x-error-message");
    return !(n && mm.test(n));
  } catch {
    return !1;
  }
}
function pm(t, e, n, i) {
  if (e.length === 0) {
    if (n === "replace")
      return i;
    if (n === "append")
      return t + i;
    throw new Error(`Unsupported action: ${n}`);
  }
  let r = t;
  for (let s = 0; s < e.length - 1; s++)
    r = r[e[s]];
  const o = e[e.length - 1];
  switch (n) {
    case "replace":
      r[o] = i;
      break;
    case "append":
      r[o] += i;
      break;
    case "add":
      Array.isArray(r) ? r.splice(Number(o), 0, i) : r[o] = i;
      break;
    case "delete":
      Array.isArray(r) ? r.splice(Number(o), 1) : delete r[o];
      break;
    default:
      throw new Error(`Unknown action: ${n}`);
  }
  return t;
}
function gm(t, e) {
  return e.forEach(([n, i, r]) => {
    t = pm(t, i, n, r);
  }), t;
}
function bm(t, e) {
  return new Promise((n, i) => {
    const r = new MessageChannel();
    r.port1.onmessage = ({ data: o }) => {
      r.port1.close(), n(o);
    }, window.parent.postMessage(t, e, [r.port2]);
  });
}
async function _u(t, e, n, i = wm) {
  let r = (Array.isArray(t) ? t : [t]).map(
    (o) => o.blob
  );
  return await Promise.all(
    await i(e, r, void 0, n).then(
      async (o) => {
        if (o.error)
          throw new Error(o.error);
        return o.files ? o.files.map((s, a) => new cs({
          ...t[a],
          path: s,
          url: e + "/file=" + s
        })) : [];
      }
    )
  );
}
async function mu(t, e) {
  return t.map(
    (n, i) => new cs({
      path: n.name,
      orig_name: n.name,
      blob: n,
      size: n.size,
      mime_type: n.type,
      is_stream: e
    })
  );
}
class cs {
  constructor({
    path: e,
    url: n,
    orig_name: i,
    size: r,
    blob: o,
    is_stream: s,
    mime_type: a,
    alt_text: l
  }) {
    this.meta = { _type: "gradio.FileData" }, this.path = e, this.url = n, this.orig_name = i, this.size = r, this.blob = n ? void 0 : o, this.is_stream = s, this.mime_type = a, this.alt_text = l;
  }
}
const pu = "This application is too busy. Keep trying!", Zt = "Connection errored out.";
let gu;
function vm(t, e) {
  return { post_data: n, upload_files: i, client: r, handle_blob: o };
  async function n(s, a, l, u) {
    const c = { "Content-Type": "application/json" };
    l && (c.Authorization = `Bearer ${l}`);
    try {
      var f = await t(s, {
        method: "POST",
        body: JSON.stringify(a),
        headers: { ...c, ...u }
      });
    } catch {
      return [{ error: Zt }, 500];
    }
    let d, h;
    try {
      d = await f.json(), h = f.status;
    } catch (_) {
      d = { error: `Could not parse server response: ${_}` }, h = 500;
    }
    return [d, h];
  }
  async function i(s, a, l, u) {
    const c = {};
    l && (c.Authorization = `Bearer ${l}`);
    const f = 1e3, d = [];
    for (let _ = 0; _ < a.length; _ += f) {
      const m = a.slice(_, _ + f), p = new FormData();
      m.forEach((w) => {
        p.append("files", w);
      });
      try {
        const w = u ? `${s}/upload?upload_id=${u}` : `${s}/upload`;
        var h = await t(w, {
          method: "POST",
          body: p,
          headers: c
        });
      } catch {
        return { error: Zt };
      }
      const E = await h.json();
      d.push(...E);
    }
    return { files: d };
  }
  async function r(s, a = {}) {
    return new Promise(async (l) => {
      const { status_callback: u, hf_token: c } = a, f = {
        predict: oe,
        submit: B,
        view_api: J,
        component_server: le
      };
      if ((typeof window > "u" || !("WebSocket" in window)) && !global.Websocket) {
        const v = await import("./wrapper-6f348d45-19fa94bf.js");
        gu = (await import("./__vite-browser-external-2447137e.js")).Blob, global.WebSocket = v.WebSocket;
      }
      const { ws_protocol: d, http_protocol: h, host: _, space_id: m } = await hm(s, c), p = Math.random().toString(36).substring(2), E = {};
      let w = !1, g = {}, b = {}, T = null;
      const C = {}, M = /* @__PURE__ */ new Set();
      let A, P = {}, D = !1;
      c && m && (D = await km(m, c));
      async function W(v) {
        if (A = v, window.location.protocol === "https:" && (A.root = A.root.replace("http://", "https://")), P = _m((v == null ? void 0 : v.dependencies) || []), A.auth_required)
          return {
            config: A,
            ...f
          };
        try {
          j = await J(A);
        } catch (y) {
          console.error(`Could not get api details: ${y.message}`);
        }
        return {
          config: A,
          ...f
        };
      }
      let j;
      async function U(v) {
        if (u && u(v), v.status === "running")
          try {
            A = await yl(
              t,
              `${h}//${_}`,
              c
            );
            const y = await W(A);
            l(y);
          } catch (y) {
            console.error(y), u && u({
              status: "error",
              message: "Could not load this space.",
              load_status: "error",
              detail: "NOT_FOUND"
            });
          }
      }
      try {
        A = await yl(
          t,
          `${h}//${_}`,
          c
        );
        const v = await W(A), y = new URL(
          `${A.root}/heartbeat/${p}`
        );
        e(y), l(v);
      } catch (v) {
        console.error(v), m ? No(
          m,
          hu.test(m) ? "space_name" : "subdomain",
          U
        ) : u && u({
          status: "error",
          message: "Could not load this space.",
          load_status: "error",
          detail: "NOT_FOUND"
        });
      }
      function oe(v, y, N) {
        let S = !1, k = !1, z;
        if (typeof v == "number")
          z = A.dependencies[v];
        else {
          const V = v.replace(/^\//, "");
          z = A.dependencies[P[V]];
        }
        if (z.types.continuous)
          throw new Error(
            "Cannot call predict on this function as it may run forever. Use submit instead"
          );
        return new Promise((V, G) => {
          const x = B(v, y, N);
          let be;
          x.on("data", (I) => {
            k && (x.destroy(), V(I)), S = !0, be = I;
          }).on("status", (I) => {
            I.stage === "error" && G(I), I.stage === "complete" && (k = !0, S && (x.destroy(), V(be)));
          });
        });
      }
      function B(v, y, N, S = null) {
        let k, z, V;
        if (typeof v == "number")
          k = v, z = j.unnamed_endpoints[k], V = A.dependencies[v];
        else {
          const ee = v.replace(/^\//, "");
          k = P[ee], z = j.named_endpoints[v.trim()], V = A.dependencies[P[ee]];
        }
        if (typeof k != "number")
          throw new Error(
            "There is no endpoint matching that name of fn_index matching that number."
          );
        let G, x, be = A.protocol ?? "ws";
        const I = typeof v == "number" ? "/predict" : v;
        let pt, _e = null, ve = !1;
        const L = {};
        let Xe = "";
        typeof window < "u" && (Xe = new URLSearchParams(window.location.search).toString()), o(`${A.root}`, y, z, c).then(
          (ee) => {
            if (pt = {
              data: ee || [],
              event_data: N,
              fn_index: k,
              trigger_id: S
            }, Em(k, A))
              H({
                type: "status",
                endpoint: I,
                stage: "pending",
                queue: !1,
                fn_index: k,
                time: /* @__PURE__ */ new Date()
              }), n(
                `${A.root}/run${I.startsWith("/") ? I : `/${I}`}${Xe ? "?" + Xe : ""}`,
                {
                  ...pt,
                  session_hash: p
                },
                c
              ).then(([te, ie]) => {
                const Se = te.data;
                ie == 200 ? (H({
                  type: "data",
                  endpoint: I,
                  fn_index: k,
                  data: Se,
                  time: /* @__PURE__ */ new Date()
                }), H({
                  type: "status",
                  endpoint: I,
                  fn_index: k,
                  stage: "complete",
                  eta: te.average_duration,
                  queue: !1,
                  time: /* @__PURE__ */ new Date()
                })) : H({
                  type: "status",
                  stage: "error",
                  endpoint: I,
                  fn_index: k,
                  message: te.error,
                  queue: !1,
                  time: /* @__PURE__ */ new Date()
                });
              }).catch((te) => {
                H({
                  type: "status",
                  stage: "error",
                  message: te.message,
                  endpoint: I,
                  fn_index: k,
                  queue: !1,
                  time: /* @__PURE__ */ new Date()
                });
              });
            else if (be == "ws") {
              H({
                type: "status",
                stage: "pending",
                queue: !0,
                endpoint: I,
                fn_index: k,
                time: /* @__PURE__ */ new Date()
              });
              let te = new URL(`${d}://${du(
                _,
                A.path,
                !0
              )}
							/queue/join${Xe ? "?" + Xe : ""}`);
              D && te.searchParams.set("__sign", D), G = new WebSocket(te), G.onclose = (ie) => {
                ie.wasClean || H({
                  type: "status",
                  stage: "error",
                  broken: !0,
                  message: Zt,
                  queue: !0,
                  endpoint: I,
                  fn_index: k,
                  time: /* @__PURE__ */ new Date()
                });
              }, G.onmessage = function(ie) {
                const Se = JSON.parse(ie.data), { type: Ae, status: ce, data: qe } = co(
                  Se,
                  E[k]
                );
                if (Ae === "update" && ce && !ve)
                  H({
                    type: "status",
                    endpoint: I,
                    fn_index: k,
                    time: /* @__PURE__ */ new Date(),
                    ...ce
                  }), ce.stage === "error" && G.close();
                else if (Ae === "hash") {
                  G.send(JSON.stringify({ fn_index: k, session_hash: p }));
                  return;
                } else
                  Ae === "data" ? G.send(JSON.stringify({ ...pt, session_hash: p })) : Ae === "complete" ? ve = ce : Ae === "log" ? H({
                    type: "log",
                    log: qe.log,
                    level: qe.level,
                    endpoint: I,
                    fn_index: k
                  }) : Ae === "generating" && H({
                    type: "status",
                    time: /* @__PURE__ */ new Date(),
                    ...ce,
                    stage: ce == null ? void 0 : ce.stage,
                    queue: !0,
                    endpoint: I,
                    fn_index: k
                  });
                qe && (H({
                  type: "data",
                  time: /* @__PURE__ */ new Date(),
                  data: qe.data,
                  endpoint: I,
                  fn_index: k
                }), ve && (H({
                  type: "status",
                  time: /* @__PURE__ */ new Date(),
                  ...ve,
                  stage: ce == null ? void 0 : ce.stage,
                  queue: !0,
                  endpoint: I,
                  fn_index: k
                }), G.close()));
              }, pl(A.version || "2.0.0", "3.6") < 0 && addEventListener(
                "open",
                () => G.send(JSON.stringify({ hash: p }))
              );
            } else if (be == "sse") {
              H({
                type: "status",
                stage: "pending",
                queue: !0,
                endpoint: I,
                fn_index: k,
                time: /* @__PURE__ */ new Date()
              });
              var Ce = new URLSearchParams({
                fn_index: k.toString(),
                session_hash: p
              }).toString();
              let te = new URL(
                `${A.root}/queue/join?${Xe ? Xe + "&" : ""}${Ce}`
              );
              x = e(te), x.onmessage = async function(ie) {
                const Se = JSON.parse(ie.data), { type: Ae, status: ce, data: qe } = co(
                  Se,
                  E[k]
                );
                if (Ae === "update" && ce && !ve)
                  H({
                    type: "status",
                    endpoint: I,
                    fn_index: k,
                    time: /* @__PURE__ */ new Date(),
                    ...ce
                  }), ce.stage === "error" && x.close();
                else if (Ae === "data") {
                  _e = Se.event_id;
                  let [Rr, Ti] = await n(
                    `${A.root}/queue/data`,
                    {
                      ...pt,
                      session_hash: p,
                      event_id: _e
                    },
                    c
                  );
                  Ti !== 200 && (H({
                    type: "status",
                    stage: "error",
                    message: Zt,
                    queue: !0,
                    endpoint: I,
                    fn_index: k,
                    time: /* @__PURE__ */ new Date()
                  }), x.close());
                } else
                  Ae === "complete" ? ve = ce : Ae === "log" ? H({
                    type: "log",
                    log: qe.log,
                    level: qe.level,
                    endpoint: I,
                    fn_index: k
                  }) : Ae === "generating" && H({
                    type: "status",
                    time: /* @__PURE__ */ new Date(),
                    ...ce,
                    stage: ce == null ? void 0 : ce.stage,
                    queue: !0,
                    endpoint: I,
                    fn_index: k
                  });
                qe && (H({
                  type: "data",
                  time: /* @__PURE__ */ new Date(),
                  data: qe.data,
                  endpoint: I,
                  fn_index: k
                }), ve && (H({
                  type: "status",
                  time: /* @__PURE__ */ new Date(),
                  ...ve,
                  stage: ce == null ? void 0 : ce.stage,
                  queue: !0,
                  endpoint: I,
                  fn_index: k
                }), x.close()));
              };
            } else if (be == "sse_v1" || be == "sse_v2" || be == "sse_v2.1" || be == "sse_v3") {
              H({
                type: "status",
                stage: "pending",
                queue: !0,
                endpoint: I,
                fn_index: k,
                time: /* @__PURE__ */ new Date()
              });
              let te = window.location.hostname;
              const Se = te.includes(".dev.") ? `https://moon-${te.split(".")[1]}.dev.spaces.huggingface.tech` : "https://huggingface.co";
              (V.zerogpu && window.parent != window && A.space_id ? bm("zerogpu-headers", Se) : Promise.resolve(null)).then((qe) => n(
                `${A.root}/queue/join?${Xe}`,
                {
                  ...pt,
                  session_hash: p
                },
                c,
                qe
              )).then(([qe, Rr]) => {
                if (Rr === 503)
                  H({
                    type: "status",
                    stage: "error",
                    message: pu,
                    queue: !0,
                    endpoint: I,
                    fn_index: k,
                    time: /* @__PURE__ */ new Date()
                  });
                else if (Rr !== 200)
                  H({
                    type: "status",
                    stage: "error",
                    message: Zt,
                    queue: !0,
                    endpoint: I,
                    fn_index: k,
                    time: /* @__PURE__ */ new Date()
                  });
                else {
                  _e = qe.event_id;
                  let Ti = async function(Lr) {
                    try {
                      const { type: Tt, status: Te, data: wn } = co(
                        Lr,
                        E[k]
                      );
                      if (Tt == "heartbeat")
                        return;
                      if (Tt === "update" && Te && !ve)
                        H({
                          type: "status",
                          endpoint: I,
                          fn_index: k,
                          time: /* @__PURE__ */ new Date(),
                          ...Te
                        });
                      else if (Tt === "complete")
                        ve = Te;
                      else if (Tt == "unexpected_error")
                        console.error("Unexpected error", Te == null ? void 0 : Te.message), H({
                          type: "status",
                          stage: "error",
                          message: (Te == null ? void 0 : Te.message) || "An Unexpected Error Occurred!",
                          queue: !0,
                          endpoint: I,
                          fn_index: k,
                          time: /* @__PURE__ */ new Date()
                        });
                      else if (Tt === "log") {
                        H({
                          type: "log",
                          log: wn.log,
                          level: wn.level,
                          endpoint: I,
                          fn_index: k
                        });
                        return;
                      } else
                        Tt === "generating" && (H({
                          type: "status",
                          time: /* @__PURE__ */ new Date(),
                          ...Te,
                          stage: Te == null ? void 0 : Te.stage,
                          queue: !0,
                          endpoint: I,
                          fn_index: k
                        }), wn && ["sse_v2", "sse_v2.1", "sse_v3"].includes(be) && R(_e, wn));
                      wn && (H({
                        type: "data",
                        time: /* @__PURE__ */ new Date(),
                        data: wn.data,
                        endpoint: I,
                        fn_index: k
                      }), ve && H({
                        type: "status",
                        time: /* @__PURE__ */ new Date(),
                        ...ve,
                        stage: Te == null ? void 0 : Te.stage,
                        queue: !0,
                        endpoint: I,
                        fn_index: k
                      })), ((Te == null ? void 0 : Te.stage) === "complete" || (Te == null ? void 0 : Te.stage) === "error") && (C[_e] && delete C[_e], _e in b && delete b[_e]);
                    } catch (Tt) {
                      console.error("Unexpected client exception", Tt), H({
                        type: "status",
                        stage: "error",
                        message: "An Unexpected Error Occurred!",
                        queue: !0,
                        endpoint: I,
                        fn_index: k,
                        time: /* @__PURE__ */ new Date()
                      }), ["sse_v2", "sse_v2.1"].includes(be) && X();
                    }
                  };
                  _e in g && (g[_e].forEach(
                    (Lr) => Ti(Lr)
                  ), delete g[_e]), C[_e] = Ti, M.add(_e), w || O();
                }
              });
            }
          }
        );
        function R(ee, Ce) {
          !b[ee] ? (b[ee] = [], Ce.data.forEach((ie, Se) => {
            b[ee][Se] = ie;
          })) : Ce.data.forEach((ie, Se) => {
            let Ae = gm(
              b[ee][Se],
              ie
            );
            b[ee][Se] = Ae, Ce.data[Se] = Ae;
          });
        }
        function H(ee) {
          const te = L[ee.type] || [];
          te == null || te.forEach((ie) => ie(ee));
        }
        function et(ee, Ce) {
          const te = L, ie = te[ee] || [];
          return te[ee] = ie, ie == null || ie.push(Ce), { on: et, off: at, cancel: Xt, destroy: Mr };
        }
        function at(ee, Ce) {
          const te = L;
          let ie = te[ee] || [];
          return ie = ie == null ? void 0 : ie.filter((Se) => Se !== Ce), te[ee] = ie, { on: et, off: at, cancel: Xt, destroy: Mr };
        }
        async function Xt() {
          const ee = {
            stage: "complete",
            queue: !1,
            time: /* @__PURE__ */ new Date()
          };
          ve = ee, H({
            ...ee,
            type: "status",
            endpoint: I,
            fn_index: k
          });
          let Ce = {};
          be === "ws" ? (G && G.readyState === 0 ? G.addEventListener("open", () => {
            G.close();
          }) : G.close(), Ce = { fn_index: k, session_hash: p }) : (x.close(), Ce = { event_id: _e });
          try {
            await t(`${A.root}/reset`, {
              headers: { "Content-Type": "application/json" },
              method: "POST",
              body: JSON.stringify(Ce)
            });
          } catch {
            console.warn(
              "The `/reset` endpoint could not be called. Subsequent endpoint results may be unreliable."
            );
          }
        }
        function Mr() {
          for (const ee in L)
            L[ee].forEach((Ce) => {
              at(ee, Ce);
            });
        }
        return {
          on: et,
          off: at,
          cancel: Xt,
          destroy: Mr
        };
      }
      function O() {
        w = !0;
        let v = new URLSearchParams({
          session_hash: p
        }).toString(), y = new URL(`${A.root}/queue/data?${v}`);
        T = e(y), T.onmessage = async function(N) {
          let S = JSON.parse(N.data);
          if (S.msg === "close_stream") {
            X();
            return;
          }
          const k = S.event_id;
          if (!k)
            await Promise.all(
              Object.keys(C).map(
                (z) => C[z](S)
              )
            );
          else if (C[k]) {
            S.msg === "process_completed" && ["sse", "sse_v1", "sse_v2", "sse_v2.1"].includes(A.protocol) && (M.delete(k), M.size === 0 && X());
            let z = C[k];
            window.setTimeout(z, 0, S);
          } else
            g[k] || (g[k] = []), g[k].push(S);
        }, T.onerror = async function(N) {
          await Promise.all(
            Object.keys(C).map(
              (S) => C[S]({
                msg: "unexpected_error",
                message: Zt
              })
            )
          ), X();
        };
      }
      function X() {
        w = !1, T == null || T.close();
      }
      async function le(v, y, N) {
        var S;
        const k = {};
        let z, V = A.components.find(
          (x) => x.id === v
        );
        (S = V == null ? void 0 : V.props) != null && S.root_url ? z = V.props.root_url : z = A.root;
        let G;
        if (N.binary) {
          G = new FormData();
          for (const x in N.data)
            x !== "binary" && G.append(x, N.data[x]);
          G.set("component_id", v), G.set("fn_name", y), G.set("session_hash", p);
        } else
          G = JSON.stringify({
            data: N,
            component_id: v,
            fn_name: y,
            session_hash: p
          }), k["Content-Type"] = "application/json";
        c && (k.Authorization = `Bearer ${c}`);
        try {
          const x = await t(
            `${z}/component_server/`,
            {
              method: "POST",
              body: G,
              headers: k
            }
          );
          if (!x.ok)
            throw new Error(
              "Could not connect to component server: " + x.statusText
            );
          return await x.json();
        } catch (x) {
          console.warn(x);
        }
      }
      async function J(v) {
        if (j)
          return j;
        const y = { "Content-Type": "application/json" };
        c && (y.Authorization = `Bearer ${c}`);
        let N;
        if (pl(v.version || "2.0.0", "3.30") < 0 ? N = await t(
          "https://gradio-space-api-fetcher-v2.hf.space/api",
          {
            method: "POST",
            body: JSON.stringify({
              serialize: !1,
              config: JSON.stringify(v)
            }),
            headers: y
          }
        ) : N = await t(`${v.root}/info`, {
          headers: y
        }), !N.ok)
          throw new Error(Zt);
        let S = await N.json();
        return "api" in S && (S = S.api), S.named_endpoints["/predict"] && !S.unnamed_endpoints[0] && (S.unnamed_endpoints[0] = S.named_endpoints["/predict"]), ym(S, v, P);
      }
    });
  }
  async function o(s, a, l, u) {
    const c = await Oo(
      a,
      void 0,
      [],
      !0,
      l
    );
    return Promise.all(
      c.map(async ({ path: f, blob: d, type: h }) => {
        if (d) {
          const _ = (await i(s, [d], u)).files[0];
          return { path: f, file_url: _, type: h, name: d == null ? void 0 : d.name };
        }
        return { path: f, type: h };
      })
    ).then((f) => (f.forEach(({ path: d, file_url: h, type: _, name: m }) => {
      if (_ === "Gallery")
        wl(a, h, d);
      else if (h) {
        const p = new cs({ path: h, orig_name: m });
        wl(a, p, d);
      }
    }), a));
  }
}
const { post_data: Uv, upload_files: wm, client: jv, handle_blob: zv } = vm(
  fetch,
  (...t) => new EventSource(...t)
);
function bl(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 vl(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 ym(t, e, n) {
  const i = {
    named_endpoints: {},
    unnamed_endpoints: {}
  };
  for (const r in t) {
    const o = t[r];
    for (const s in o) {
      const a = e.dependencies[s] ? s : n[s.replace("/", "")], l = o[s];
      i[r][s] = {}, i[r][s].parameters = {}, i[r][s].returns = {}, i[r][s].type = e.dependencies[a].types, i[r][s].parameters = l.parameters.map(
        ({ label: u, component: c, type: f, serializer: d }) => ({
          label: u,
          component: c,
          type: bl(f, c, d, "parameter"),
          description: vl(f, d)
        })
      ), i[r][s].returns = l.returns.map(
        ({ label: u, component: c, type: f, serializer: d }) => ({
          label: u,
          component: c,
          type: bl(f, c, d, "return"),
          description: vl(f, d)
        })
      );
    }
  }
  return i;
}
async function km(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 wl(t, e, n) {
  for (; n.length > 1; )
    t = t[n.shift()];
  t[n.shift()] = e;
}
async function Oo(t, e = void 0, n = [], i = !1, r = void 0) {
  if (Array.isArray(t)) {
    let o = [];
    return await Promise.all(
      t.map(async (s, a) => {
        var l;
        let u = n.slice();
        u.push(a);
        const c = await Oo(
          t[a],
          i ? ((l = r == null ? void 0 : r.parameters[a]) == null ? void 0 : l.component) || void 0 : e,
          u,
          !1,
          r
        );
        o = o.concat(c);
      })
    ), o;
  } else {
    if (globalThis.Buffer && t instanceof globalThis.Buffer)
      return [
        {
          path: n,
          blob: e === "Image" ? !1 : new gu([t]),
          type: e
        }
      ];
    if (typeof t == "object") {
      let o = [];
      for (let s in t)
        if (t.hasOwnProperty(s)) {
          let a = n.slice();
          a.push(s), o = o.concat(
            await Oo(
              t[s],
              void 0,
              a,
              !1,
              r
            )
          );
        }
      return o;
    }
  }
  return [];
}
function Em(t, e) {
  var n, i, r, o;
  return !(((i = (n = e == null ? void 0 : e.dependencies) == null ? void 0 : n[t]) == null ? void 0 : i.queue) === null ? e.enable_queue : (o = (r = e == null ? void 0 : e.dependencies) == null ? void 0 : r[t]) != null && o.queue) || !1;
}
async function yl(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, o = window.gradio_config;
    return o.root = du(e, o.root, !1), { ...o, path: r };
  } else if (e) {
    let r = await t(`${e}/config`, {
      headers: i
    });
    if (r.status === 200) {
      const o = await r.json();
      return o.path = o.path ?? "", o.root = e, o;
    }
    throw new Error("Could not get config.");
  }
  throw new Error("No config or app endpoint found");
}
async function No(t, e, n) {
  let i = e === "subdomain" ? `https://huggingface.co/api/spaces/by-subdomain/${t}` : `https://huggingface.co/api/spaces/${t}`, r, o;
  try {
    if (r = await fetch(i), o = r.status, o !== 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 || o !== 200)
    return;
  const {
    runtime: { stage: s },
    id: a
  } = r;
  switch (s) {
    case "STOPPED":
    case "SLEEPING":
      n({
        status: "sleeping",
        load_status: "pending",
        message: "Space is asleep. Waking it up...",
        detail: s
      }), setTimeout(() => {
        No(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: s,
        discussions_enabled: await gl(a)
      });
      break;
    case "RUNNING":
    case "RUNNING_BUILDING":
      n({
        status: "running",
        load_status: "complete",
        message: "",
        detail: s
      });
      break;
    case "BUILDING":
      n({
        status: "building",
        load_status: "pending",
        message: "Space is building...",
        detail: s
      }), setTimeout(() => {
        No(t, e, n);
      }, 1e3);
      break;
    default:
      n({
        status: "space_error",
        load_status: "error",
        message: "This space is experiencing an issue.",
        detail: s,
        discussions_enabled: await gl(a)
      });
      break;
  }
}
function co(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: pu,
          stage: "error",
          code: t.code,
          success: t.success
        }
      };
    case "heartbeat":
      return {
        type: "heartbeat"
      };
    case "unexpected_error":
      return {
        type: "unexpected_error",
        status: {
          queue: !0,
          message: t.message,
          stage: "error",
          success: !1
        }
      };
    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
        },
        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,
          eta: t.eta
        }
      };
  }
  return { type: "none", status: { stage: "error", queue: !0 } };
}
function sn() {
}
function Cm(t) {
  return t();
}
function Sm(t) {
  t.forEach(Cm);
}
function Am(t) {
  return typeof t == "function";
}
function Tm(t, e) {
  return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
}
function Pm(t, ...e) {
  if (t == null) {
    for (const i of e)
      i(void 0);
    return sn;
  }
  const n = t.subscribe(...e);
  return n.unsubscribe ? () => n.unsubscribe() : n;
}
const bu = typeof window < "u";
let kl = bu ? () => window.performance.now() : () => Date.now(), vu = bu ? (t) => requestAnimationFrame(t) : sn;
const Hn = /* @__PURE__ */ new Set();
function wu(t) {
  Hn.forEach((e) => {
    e.c(t) || (Hn.delete(e), e.f());
  }), Hn.size !== 0 && vu(wu);
}
function Dm(t) {
  let e;
  return Hn.size === 0 && vu(wu), {
    promise: new Promise((n) => {
      Hn.add(e = { c: t, f: n });
    }),
    abort() {
      Hn.delete(e);
    }
  };
}
const Sn = [];
function Mm(t, e) {
  return {
    subscribe: bi(t, e).subscribe
  };
}
function bi(t, e = sn) {
  let n;
  const i = /* @__PURE__ */ new Set();
  function r(a) {
    if (Tm(t, a) && (t = a, n)) {
      const l = !Sn.length;
      for (const u of i)
        u[1](), Sn.push(u, t);
      if (l) {
        for (let u = 0; u < Sn.length; u += 2)
          Sn[u][0](Sn[u + 1]);
        Sn.length = 0;
      }
    }
  }
  function o(a) {
    r(a(t));
  }
  function s(a, l = sn) {
    const u = [a, l];
    return i.add(u), i.size === 1 && (n = e(r, o) || sn), a(t), () => {
      i.delete(u), i.size === 0 && n && (n(), n = null);
    };
  }
  return { set: r, update: o, subscribe: s };
}
function Yn(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 o = e.length < 2;
  return Mm(n, (s, a) => {
    let l = !1;
    const u = [];
    let c = 0, f = sn;
    const d = () => {
      if (c)
        return;
      f();
      const _ = e(i ? u[0] : u, s, a);
      o ? s(_) : f = Am(_) ? _ : sn;
    }, h = r.map(
      (_, m) => Pm(
        _,
        (p) => {
          u[m] = p, c &= ~(1 << m), l && d();
        },
        () => {
          c |= 1 << m;
        }
      )
    );
    return l = !0, d(), function() {
      Sm(h), f(), l = !1;
    };
  });
}
function El(t) {
  return Object.prototype.toString.call(t) === "[object Date]";
}
function Ho(t, e, n, i) {
  if (typeof n == "number" || El(n)) {
    const r = i - n, o = (n - e) / (t.dt || 1 / 60), s = t.opts.stiffness * r, a = t.opts.damping * o, l = (s - a) * t.inv_mass, u = (o + l) * t.dt;
    return Math.abs(u) < t.opts.precision && Math.abs(r) < t.opts.precision ? i : (t.settled = !1, El(n) ? new Date(n.getTime() + u) : n + u);
  } else {
    if (Array.isArray(n))
      return n.map(
        (r, o) => Ho(t, e[o], n[o], i[o])
      );
    if (typeof n == "object") {
      const r = {};
      for (const o in n)
        r[o] = Ho(t, e[o], n[o], i[o]);
      return r;
    } else
      throw new Error(`Cannot spring ${typeof n} values`);
  }
}
function Cl(t, e = {}) {
  const n = bi(t), { stiffness: i = 0.15, damping: r = 0.8, precision: o = 0.01 } = e;
  let s, a, l, u = t, c = t, f = 1, d = 0, h = !1;
  function _(p, E = {}) {
    c = p;
    const w = l = {};
    return t == null || E.hard || m.stiffness >= 1 && m.damping >= 1 ? (h = !0, s = kl(), u = p, n.set(t = c), Promise.resolve()) : (E.soft && (d = 1 / ((E.soft === !0 ? 0.5 : +E.soft) * 60), f = 0), a || (s = kl(), h = !1, a = Dm((g) => {
      if (h)
        return h = !1, a = null, !1;
      f = Math.min(f + d, 1);
      const b = {
        inv_mass: f,
        opts: m,
        settled: !0,
        dt: (g - s) * 60 / 1e3
      }, T = Ho(b, u, t, c);
      return s = g, u = t, n.set(t = T), b.settled && (a = null), !b.settled;
    })), new Promise((g) => {
      a.promise.then(() => {
        w === l && g();
      });
    }));
  }
  const m = {
    set: _,
    update: (p, E) => _(p(c, t), E),
    subscribe: n.subscribe,
    stiffness: i,
    damping: r,
    precision: o
  };
  return m;
}
function Rm(t) {
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
}
var Lm = function(e) {
  return Bm(e) && !Om(e);
};
function Bm(t) {
  return !!t && typeof t == "object";
}
function Om(t) {
  var e = Object.prototype.toString.call(t);
  return e === "[object RegExp]" || e === "[object Date]" || Im(t);
}
var Nm = typeof Symbol == "function" && Symbol.for, Hm = Nm ? Symbol.for("react.element") : 60103;
function Im(t) {
  return t.$$typeof === Hm;
}
function Um(t) {
  return Array.isArray(t) ? [] : {};
}
function _i(t, e) {
  return e.clone !== !1 && e.isMergeableObject(t) ? Un(Um(t), t, e) : t;
}
function jm(t, e, n) {
  return t.concat(e).map(function(i) {
    return _i(i, n);
  });
}
function zm(t, e) {
  if (!e.customMerge)
    return Un;
  var n = e.customMerge(t);
  return typeof n == "function" ? n : Un;
}
function Fm(t) {
  return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(t).filter(function(e) {
    return Object.propertyIsEnumerable.call(t, e);
  }) : [];
}
function Sl(t) {
  return Object.keys(t).concat(Fm(t));
}
function yu(t, e) {
  try {
    return e in t;
  } catch {
    return !1;
  }
}
function qm(t, e) {
  return yu(t, e) && !(Object.hasOwnProperty.call(t, e) && Object.propertyIsEnumerable.call(t, e));
}
function Wm(t, e, n) {
  var i = {};
  return n.isMergeableObject(t) && Sl(t).forEach(function(r) {
    i[r] = _i(t[r], n);
  }), Sl(e).forEach(function(r) {
    qm(t, r) || (yu(t, r) && n.isMergeableObject(e[r]) ? i[r] = zm(r, n)(t[r], e[r], n) : i[r] = _i(e[r], n));
  }), i;
}
function Un(t, e, n) {
  n = n || {}, n.arrayMerge = n.arrayMerge || jm, n.isMergeableObject = n.isMergeableObject || Lm, n.cloneUnlessOtherwiseSpecified = _i;
  var i = Array.isArray(e), r = Array.isArray(t), o = i === r;
  return o ? i ? n.arrayMerge(t, e, n) : Wm(t, e, n) : _i(e, n);
}
Un.all = function(e, n) {
  if (!Array.isArray(e))
    throw new Error("first argument should be an array");
  return e.reduce(function(i, r) {
    return Un(i, r, n);
  }, {});
};
var Gm = Un, Vm = Gm;
const Xm = /* @__PURE__ */ Rm(Vm);
var Io = function(t, e) {
  return Io = 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]);
  }, Io(t, e);
};
function gr(t, e) {
  if (typeof e != "function" && e !== null)
    throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
  Io(t, e);
  function n() {
    this.constructor = t;
  }
  t.prototype = e === null ? Object.create(e) : (n.prototype = e.prototype, new n());
}
var K = function() {
  return K = Object.assign || function(e) {
    for (var n, i = 1, r = arguments.length; i < r; i++) {
      n = arguments[i];
      for (var o in n)
        Object.prototype.hasOwnProperty.call(n, o) && (e[o] = n[o]);
    }
    return e;
  }, K.apply(this, arguments);
};
function fo(t, e, n) {
  if (n || arguments.length === 2)
    for (var i = 0, r = e.length, o; i < r; i++)
      (o || !(i in e)) && (o || (o = Array.prototype.slice.call(e, 0, i)), o[i] = e[i]);
  return t.concat(o || Array.prototype.slice.call(e));
}
var Z;
(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";
})(Z || (Z = {}));
var ne;
(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";
})(ne || (ne = {}));
var jn;
(function(t) {
  t[t.number = 0] = "number", t[t.dateTime = 1] = "dateTime";
})(jn || (jn = {}));
function Al(t) {
  return t.type === ne.literal;
}
function Zm(t) {
  return t.type === ne.argument;
}
function ku(t) {
  return t.type === ne.number;
}
function Eu(t) {
  return t.type === ne.date;
}
function Cu(t) {
  return t.type === ne.time;
}
function Su(t) {
  return t.type === ne.select;
}
function Au(t) {
  return t.type === ne.plural;
}
function Jm(t) {
  return t.type === ne.pound;
}
function Tu(t) {
  return t.type === ne.tag;
}
function Pu(t) {
  return !!(t && typeof t == "object" && t.type === jn.number);
}
function Uo(t) {
  return !!(t && typeof t == "object" && t.type === jn.dateTime);
}
var Du = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/, Ym = /(?:[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 Qm(t) {
  var e = {};
  return t.replace(Ym, 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 Km = /[\t-\r \x85\u200E\u200F\u2028\u2029]/i;
function xm(t) {
  if (t.length === 0)
    throw new Error("Number skeleton cannot be empty");
  for (var e = t.split(Km).filter(function(d) {
    return d.length > 0;
  }), n = [], i = 0, r = e; i < r.length; i++) {
    var o = r[i], s = o.split("/");
    if (s.length === 0)
      throw new Error("Invalid number skeleton");
    for (var a = s[0], l = s.slice(1), u = 0, c = l; u < c.length; u++) {
      var f = c[u];
      if (f.length === 0)
        throw new Error("Invalid number skeleton");
    }
    n.push({ stem: a, options: l });
  }
  return n;
}
function $m(t) {
  return t.replace(/^(.*?)-/, "");
}
var Tl = /^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g, Mu = /^(@+)?(\+|#+)?[rs]?$/g, ep = /(\*)(0+)|(#+)(0+)|(0+)/g, Ru = /^(0+)$/;
function Pl(t) {
  var e = {};
  return t[t.length - 1] === "r" ? e.roundingPriority = "morePrecision" : t[t.length - 1] === "s" && (e.roundingPriority = "lessPrecision"), t.replace(Mu, 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 Lu(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 tp(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)), !Ru.test(t))
      throw new Error("Malformed concise eng/scientific notation");
    e.minimumIntegerDigits = t.length;
  }
  return e;
}
function Dl(t) {
  var e = {}, n = Lu(t);
  return n || e;
}
function np(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 = $m(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 = K(K(K({}, e), { notation: "scientific" }), r.options.reduce(function(l, u) {
          return K(K({}, l), Dl(u));
        }, {}));
        continue;
      case "engineering":
        e = K(K(K({}, e), { notation: "engineering" }), r.options.reduce(function(l, u) {
          return K(K({}, l), Dl(u));
        }, {}));
        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(ep, function(l, u, c, f, d, h) {
          if (u)
            e.minimumIntegerDigits = c.length;
          else {
            if (f && d)
              throw new Error("We currently do not support maximum integer digits");
            if (h)
              throw new Error("We currently do not support exact integer digits");
          }
          return "";
        });
        continue;
    }
    if (Ru.test(r.stem)) {
      e.minimumIntegerDigits = r.stem.length;
      continue;
    }
    if (Tl.test(r.stem)) {
      if (r.options.length > 1)
        throw new RangeError("Fraction-precision stems only accept a single optional option");
      r.stem.replace(Tl, function(l, u, c, f, d, h) {
        return c === "*" ? e.minimumFractionDigits = u.length : f && f[0] === "#" ? e.maximumFractionDigits = f.length : d && h ? (e.minimumFractionDigits = d.length, e.maximumFractionDigits = d.length + h.length) : (e.minimumFractionDigits = u.length, e.maximumFractionDigits = u.length), "";
      });
      var o = r.options[0];
      o === "w" ? e = K(K({}, e), { trailingZeroDisplay: "stripIfInteger" }) : o && (e = K(K({}, e), Pl(o)));
      continue;
    }
    if (Mu.test(r.stem)) {
      e = K(K({}, e), Pl(r.stem));
      continue;
    }
    var s = Lu(r.stem);
    s && (e = K(K({}, e), s));
    var a = tp(r.stem);
    a && (e = K(K({}, e), a));
  }
  return e;
}
var Hi = {
  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 ip(t, e) {
  for (var n = "", i = 0; i < t.length; i++) {
    var r = t.charAt(i);
    if (r === "j") {
      for (var o = 0; i + 1 < t.length && t.charAt(i + 1) === r; )
        o++, i++;
      var s = 1 + (o & 1), a = o < 2 ? 1 : 3 + (o >> 1), l = "a", u = rp(e);
      for ((u == "H" || u == "k") && (a = 0); a-- > 0; )
        n += l;
      for (; s-- > 0; )
        n = u + n;
    } else
      r === "J" ? n += "H" : n += r;
  }
  return n;
}
function rp(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 = Hi[i || ""] || Hi[n || ""] || Hi["".concat(n, "-001")] || Hi["001"];
  return r[0];
}
var ho, op = new RegExp("^".concat(Du.source, "*")), sp = new RegExp("".concat(Du.source, "*$"));
function Y(t, e) {
  return { start: t, end: e };
}
var lp = !!String.prototype.startsWith, ap = !!String.fromCodePoint, up = !!Object.fromEntries, cp = !!String.prototype.codePointAt, fp = !!String.prototype.trimStart, dp = !!String.prototype.trimEnd, hp = !!Number.isSafeInteger, _p = hp ? Number.isSafeInteger : function(t) {
  return typeof t == "number" && isFinite(t) && Math.floor(t) === t && Math.abs(t) <= 9007199254740991;
}, jo = !0;
try {
  var mp = Ou("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
  jo = ((ho = mp.exec("a")) === null || ho === void 0 ? void 0 : ho[0]) === "a";
} catch {
  jo = !1;
}
var Ml = lp ? (
  // Native
  function(e, n, i) {
    return e.startsWith(n, i);
  }
) : (
  // For IE11
  function(e, n, i) {
    return e.slice(i, i + n.length) === n;
  }
), zo = ap ? String.fromCodePoint : (
  // IE11
  function() {
    for (var e = [], n = 0; n < arguments.length; n++)
      e[n] = arguments[n];
    for (var i = "", r = e.length, o = 0, s; r > o; ) {
      if (s = e[o++], s > 1114111)
        throw RangeError(s + " is not a valid code point");
      i += s < 65536 ? String.fromCharCode(s) : String.fromCharCode(((s -= 65536) >> 10) + 55296, s % 1024 + 56320);
    }
    return i;
  }
), Rl = (
  // native
  up ? Object.fromEntries : (
    // Ponyfill
    function(e) {
      for (var n = {}, i = 0, r = e; i < r.length; i++) {
        var o = r[i], s = o[0], a = o[1];
        n[s] = a;
      }
      return n;
    }
  )
), Bu = cp ? (
  // 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), o;
      return r < 55296 || r > 56319 || n + 1 === i || (o = e.charCodeAt(n + 1)) < 56320 || o > 57343 ? r : (r - 55296 << 10) + (o - 56320) + 65536;
    }
  }
), pp = fp ? (
  // Native
  function(e) {
    return e.trimStart();
  }
) : (
  // Ponyfill
  function(e) {
    return e.replace(op, "");
  }
), gp = dp ? (
  // Native
  function(e) {
    return e.trimEnd();
  }
) : (
  // Ponyfill
  function(e) {
    return e.replace(sp, "");
  }
);
function Ou(t, e) {
  return new RegExp(t, e);
}
var Fo;
if (jo) {
  var Ll = Ou("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
  Fo = function(e, n) {
    var i;
    Ll.lastIndex = n;
    var r = Ll.exec(e);
    return (i = r[1]) !== null && i !== void 0 ? i : "";
  };
} else
  Fo = function(e, n) {
    for (var i = []; ; ) {
      var r = Bu(e, n);
      if (r === void 0 || Nu(r) || yp(r))
        break;
      i.push(r), n += r >= 65536 ? 2 : 1;
    }
    return zo.apply(void 0, i);
  };
var bp = (
  /** @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 o = this.char();
        if (o === 123) {
          var s = this.parseArgument(e, i);
          if (s.err)
            return s;
          r.push(s.val);
        } else {
          if (o === 125 && e > 0)
            break;
          if (o === 35 && (n === "plural" || n === "selectordinal")) {
            var a = this.clonePosition();
            this.bump(), r.push({
              type: ne.pound,
              location: Y(a, this.clonePosition())
            });
          } else if (o === 60 && !this.ignoreTag && this.peek() === 47) {
            if (i)
              break;
            return this.error(Z.UNMATCHED_CLOSING_TAG, Y(this.clonePosition(), this.clonePosition()));
          } else if (o === 60 && !this.ignoreTag && qo(this.peek() || 0)) {
            var s = this.parseTag(e, n);
            if (s.err)
              return s;
            r.push(s.val);
          } else {
            var s = this.parseLiteral(e, n);
            if (s.err)
              return s;
            r.push(s.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: ne.literal,
            value: "<".concat(r, "/>"),
            location: Y(i, this.clonePosition())
          },
          err: null
        };
      if (this.bumpIf(">")) {
        var o = this.parseMessage(e + 1, n, !0);
        if (o.err)
          return o;
        var s = o.val, a = this.clonePosition();
        if (this.bumpIf("</")) {
          if (this.isEOF() || !qo(this.char()))
            return this.error(Z.INVALID_TAG, Y(a, this.clonePosition()));
          var l = this.clonePosition(), u = this.parseTagName();
          return r !== u ? this.error(Z.UNMATCHED_CLOSING_TAG, Y(l, this.clonePosition())) : (this.bumpSpace(), this.bumpIf(">") ? {
            val: {
              type: ne.tag,
              value: r,
              children: s,
              location: Y(i, this.clonePosition())
            },
            err: null
          } : this.error(Z.INVALID_TAG, Y(a, this.clonePosition())));
        } else
          return this.error(Z.UNCLOSED_TAG, Y(i, this.clonePosition()));
      } else
        return this.error(Z.INVALID_TAG, Y(i, this.clonePosition()));
    }, t.prototype.parseTagName = function() {
      var e = this.offset();
      for (this.bump(); !this.isEOF() && wp(this.char()); )
        this.bump();
      return this.message.slice(e, this.offset());
    }, t.prototype.parseLiteral = function(e, n) {
      for (var i = this.clonePosition(), r = ""; ; ) {
        var o = this.tryParseQuote(n);
        if (o) {
          r += o;
          continue;
        }
        var s = this.tryParseUnquoted(e, n);
        if (s) {
          r += s;
          continue;
        }
        var a = this.tryParseLeftAngleBracket();
        if (a) {
          r += a;
          continue;
        }
        break;
      }
      var l = Y(i, this.clonePosition());
      return {
        val: { type: ne.literal, value: r, location: l },
        err: null
      };
    }, t.prototype.tryParseLeftAngleBracket = function() {
      return !this.isEOF() && this.char() === 60 && (this.ignoreTag || // If at the opening tag or closing tag position, bail.
      !vp(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 zo.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(), zo(i));
    }, t.prototype.parseArgument = function(e, n) {
      var i = this.clonePosition();
      if (this.bump(), this.bumpSpace(), this.isEOF())
        return this.error(Z.EXPECT_ARGUMENT_CLOSING_BRACE, Y(i, this.clonePosition()));
      if (this.char() === 125)
        return this.bump(), this.error(Z.EMPTY_ARGUMENT, Y(i, this.clonePosition()));
      var r = this.parseIdentifierIfPossible().value;
      if (!r)
        return this.error(Z.MALFORMED_ARGUMENT, Y(i, this.clonePosition()));
      if (this.bumpSpace(), this.isEOF())
        return this.error(Z.EXPECT_ARGUMENT_CLOSING_BRACE, Y(i, this.clonePosition()));
      switch (this.char()) {
        case 125:
          return this.bump(), {
            val: {
              type: ne.argument,
              // value does not include the opening and closing braces.
              value: r,
              location: Y(i, this.clonePosition())
            },
            err: null
          };
        case 44:
          return this.bump(), this.bumpSpace(), this.isEOF() ? this.error(Z.EXPECT_ARGUMENT_CLOSING_BRACE, Y(i, this.clonePosition())) : this.parseArgumentOptions(e, n, r, i);
        default:
          return this.error(Z.MALFORMED_ARGUMENT, Y(i, this.clonePosition()));
      }
    }, t.prototype.parseIdentifierIfPossible = function() {
      var e = this.clonePosition(), n = this.offset(), i = Fo(this.message, n), r = n + i.length;
      this.bumpTo(r);
      var o = this.clonePosition(), s = Y(e, o);
      return { value: i, location: s };
    }, t.prototype.parseArgumentOptions = function(e, n, i, r) {
      var o, s = this.clonePosition(), a = this.parseIdentifierIfPossible().value, l = this.clonePosition();
      switch (a) {
        case "":
          return this.error(Z.EXPECT_ARGUMENT_TYPE, Y(s, l));
        case "number":
        case "date":
        case "time": {
          this.bumpSpace();
          var u = null;
          if (this.bumpIf(",")) {
            this.bumpSpace();
            var c = this.clonePosition(), f = this.parseSimpleArgStyleIfPossible();
            if (f.err)
              return f;
            var d = gp(f.val);
            if (d.length === 0)
              return this.error(Z.EXPECT_ARGUMENT_STYLE, Y(this.clonePosition(), this.clonePosition()));
            var h = Y(c, this.clonePosition());
            u = { style: d, styleLocation: h };
          }
          var _ = this.tryParseArgumentClose(r);
          if (_.err)
            return _;
          var m = Y(r, this.clonePosition());
          if (u && Ml(u == null ? void 0 : u.style, "::", 0)) {
            var p = pp(u.style.slice(2));
            if (a === "number") {
              var f = this.parseNumberSkeletonFromString(p, u.styleLocation);
              return f.err ? f : {
                val: { type: ne.number, value: i, location: m, style: f.val },
                err: null
              };
            } else {
              if (p.length === 0)
                return this.error(Z.EXPECT_DATE_TIME_SKELETON, m);
              var E = p;
              this.locale && (E = ip(p, this.locale));
              var d = {
                type: jn.dateTime,
                pattern: E,
                location: u.styleLocation,
                parsedOptions: this.shouldParseSkeletons ? Qm(E) : {}
              }, w = a === "date" ? ne.date : ne.time;
              return {
                val: { type: w, value: i, location: m, style: d },
                err: null
              };
            }
          }
          return {
            val: {
              type: a === "number" ? ne.number : a === "date" ? ne.date : ne.time,
              value: i,
              location: m,
              style: (o = u == null ? void 0 : u.style) !== null && o !== void 0 ? o : null
            },
            err: null
          };
        }
        case "plural":
        case "selectordinal":
        case "select": {
          var g = this.clonePosition();
          if (this.bumpSpace(), !this.bumpIf(","))
            return this.error(Z.EXPECT_SELECT_ARGUMENT_OPTIONS, Y(g, K({}, g)));
          this.bumpSpace();
          var b = this.parseIdentifierIfPossible(), T = 0;
          if (a !== "select" && b.value === "offset") {
            if (!this.bumpIf(":"))
              return this.error(Z.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, Y(this.clonePosition(), this.clonePosition()));
            this.bumpSpace();
            var f = this.tryParseDecimalInteger(Z.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, Z.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);
            if (f.err)
              return f;
            this.bumpSpace(), b = this.parseIdentifierIfPossible(), T = f.val;
          }
          var C = this.tryParsePluralOrSelectOptions(e, a, n, b);
          if (C.err)
            return C;
          var _ = this.tryParseArgumentClose(r);
          if (_.err)
            return _;
          var M = Y(r, this.clonePosition());
          return a === "select" ? {
            val: {
              type: ne.select,
              value: i,
              options: Rl(C.val),
              location: M
            },
            err: null
          } : {
            val: {
              type: ne.plural,
              value: i,
              options: Rl(C.val),
              offset: T,
              pluralType: a === "plural" ? "cardinal" : "ordinal",
              location: M
            },
            err: null
          };
        }
        default:
          return this.error(Z.INVALID_ARGUMENT_TYPE, Y(s, l));
      }
    }, t.prototype.tryParseArgumentClose = function(e) {
      return this.isEOF() || this.char() !== 125 ? this.error(Z.EXPECT_ARGUMENT_CLOSING_BRACE, Y(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(Z.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE, Y(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 = xm(e);
      } catch {
        return this.error(Z.INVALID_NUMBER_SKELETON, n);
      }
      return {
        val: {
          type: jn.number,
          tokens: i,
          location: n,
          parsedOptions: this.shouldParseSkeletons ? np(i) : {}
        },
        err: null
      };
    }, t.prototype.tryParsePluralOrSelectOptions = function(e, n, i, r) {
      for (var o, s = !1, a = [], l = /* @__PURE__ */ new Set(), u = r.value, c = r.location; ; ) {
        if (u.length === 0) {
          var f = this.clonePosition();
          if (n !== "select" && this.bumpIf("=")) {
            var d = this.tryParseDecimalInteger(Z.EXPECT_PLURAL_ARGUMENT_SELECTOR, Z.INVALID_PLURAL_ARGUMENT_SELECTOR);
            if (d.err)
              return d;
            c = Y(f, this.clonePosition()), u = this.message.slice(f.offset, this.offset());
          } else
            break;
        }
        if (l.has(u))
          return this.error(n === "select" ? Z.DUPLICATE_SELECT_ARGUMENT_SELECTOR : Z.DUPLICATE_PLURAL_ARGUMENT_SELECTOR, c);
        u === "other" && (s = !0), this.bumpSpace();
        var h = this.clonePosition();
        if (!this.bumpIf("{"))
          return this.error(n === "select" ? Z.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT : Z.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT, Y(this.clonePosition(), this.clonePosition()));
        var _ = this.parseMessage(e + 1, n, i);
        if (_.err)
          return _;
        var m = this.tryParseArgumentClose(h);
        if (m.err)
          return m;
        a.push([
          u,
          {
            value: _.val,
            location: Y(h, this.clonePosition())
          }
        ]), l.add(u), this.bumpSpace(), o = this.parseIdentifierIfPossible(), u = o.value, c = o.location;
      }
      return a.length === 0 ? this.error(n === "select" ? Z.EXPECT_SELECT_ARGUMENT_SELECTOR : Z.EXPECT_PLURAL_ARGUMENT_SELECTOR, Y(this.clonePosition(), this.clonePosition())) : this.requiresOtherClause && !s ? this.error(Z.MISSING_OTHER_CLAUSE, Y(this.clonePosition(), this.clonePosition())) : { val: a, err: null };
    }, t.prototype.tryParseDecimalInteger = function(e, n) {
      var i = 1, r = this.clonePosition();
      this.bumpIf("+") || this.bumpIf("-") && (i = -1);
      for (var o = !1, s = 0; !this.isEOF(); ) {
        var a = this.char();
        if (a >= 48 && a <= 57)
          o = !0, s = s * 10 + (a - 48), this.bump();
        else
          break;
      }
      var l = Y(r, this.clonePosition());
      return o ? (s *= i, _p(s) ? { val: s, err: null } : this.error(n, l)) : this.error(e, l);
    }, 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 = Bu(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 (Ml(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() && Nu(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 qo(t) {
  return t >= 97 && t <= 122 || t >= 65 && t <= 90;
}
function vp(t) {
  return qo(t) || t === 47;
}
function wp(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 Nu(t) {
  return t >= 9 && t <= 13 || t === 32 || t === 133 || t >= 8206 && t <= 8207 || t === 8232 || t === 8233;
}
function yp(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 Wo(t) {
  t.forEach(function(e) {
    if (delete e.location, Su(e) || Au(e))
      for (var n in e.options)
        delete e.options[n].location, Wo(e.options[n].value);
    else
      ku(e) && Pu(e.style) || (Eu(e) || Cu(e)) && Uo(e.style) ? delete e.style.location : Tu(e) && Wo(e.children);
  });
}
function kp(t, e) {
  e === void 0 && (e = {}), e = K({ shouldParseSkeletons: !0, requiresOtherClause: !0 }, e);
  var n = new bp(t, e).parse();
  if (n.err) {
    var i = SyntaxError(Z[n.err.kind]);
    throw i.location = n.err.location, i.originalMessage = n.err.message, i;
  }
  return e != null && e.captureLocation || Wo(n.val), n.val;
}
function _o(t, e) {
  var n = e && e.cache ? e.cache : Pp, i = e && e.serializer ? e.serializer : Tp, r = e && e.strategy ? e.strategy : Cp;
  return r(t, {
    cache: n,
    serializer: i
  });
}
function Ep(t) {
  return t == null || typeof t == "number" || typeof t == "boolean";
}
function Hu(t, e, n, i) {
  var r = Ep(i) ? i : n(i), o = e.get(r);
  return typeof o > "u" && (o = t.call(this, i), e.set(r, o)), o;
}
function Iu(t, e, n) {
  var i = Array.prototype.slice.call(arguments, 3), r = n(i), o = e.get(r);
  return typeof o > "u" && (o = t.apply(this, i), e.set(r, o)), o;
}
function fs(t, e, n, i, r) {
  return n.bind(e, t, i, r);
}
function Cp(t, e) {
  var n = t.length === 1 ? Hu : Iu;
  return fs(t, this, n, e.cache.create(), e.serializer);
}
function Sp(t, e) {
  return fs(t, this, Iu, e.cache.create(), e.serializer);
}
function Ap(t, e) {
  return fs(t, this, Hu, e.cache.create(), e.serializer);
}
var Tp = function() {
  return JSON.stringify(arguments);
};
function ds() {
  this.cache = /* @__PURE__ */ Object.create(null);
}
ds.prototype.get = function(t) {
  return this.cache[t];
};
ds.prototype.set = function(t, e) {
  this.cache[t] = e;
};
var Pp = {
  create: function() {
    return new ds();
  }
}, mo = {
  variadic: Sp,
  monadic: Ap
}, zn;
(function(t) {
  t.MISSING_VALUE = "MISSING_VALUE", t.INVALID_VALUE = "INVALID_VALUE", t.MISSING_INTL_API = "MISSING_INTL_API";
})(zn || (zn = {}));
var br = (
  /** @class */
  function(t) {
    gr(e, t);
    function e(n, i, r) {
      var o = t.call(this, n) || this;
      return o.code = i, o.originalMessage = r, o;
    }
    return e.prototype.toString = function() {
      return "[formatjs Error: ".concat(this.code, "] ").concat(this.message);
    }, e;
  }(Error)
), Bl = (
  /** @class */
  function(t) {
    gr(e, t);
    function e(n, i, r, o) {
      return t.call(this, 'Invalid values for "'.concat(n, '": "').concat(i, '". Options are "').concat(Object.keys(r).join('", "'), '"'), zn.INVALID_VALUE, o) || this;
    }
    return e;
  }(br)
), Dp = (
  /** @class */
  function(t) {
    gr(e, t);
    function e(n, i, r) {
      return t.call(this, 'Value for "'.concat(n, '" must be of type ').concat(i), zn.INVALID_VALUE, r) || this;
    }
    return e;
  }(br)
), Mp = (
  /** @class */
  function(t) {
    gr(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, '"'), zn.MISSING_VALUE, i) || this;
    }
    return e;
  }(br)
), Re;
(function(t) {
  t[t.literal = 0] = "literal", t[t.object = 1] = "object";
})(Re || (Re = {}));
function Rp(t) {
  return t.length < 2 ? t : t.reduce(function(e, n) {
    var i = e[e.length - 1];
    return !i || i.type !== Re.literal || n.type !== Re.literal ? e.push(n) : i.value += n.value, e;
  }, []);
}
function Lp(t) {
  return typeof t == "function";
}
function Vi(t, e, n, i, r, o, s) {
  if (t.length === 1 && Al(t[0]))
    return [
      {
        type: Re.literal,
        value: t[0].value
      }
    ];
  for (var a = [], l = 0, u = t; l < u.length; l++) {
    var c = u[l];
    if (Al(c)) {
      a.push({
        type: Re.literal,
        value: c.value
      });
      continue;
    }
    if (Jm(c)) {
      typeof o == "number" && a.push({
        type: Re.literal,
        value: n.getNumberFormat(e).format(o)
      });
      continue;
    }
    var f = c.value;
    if (!(r && f in r))
      throw new Mp(f, s);
    var d = r[f];
    if (Zm(c)) {
      (!d || typeof d == "string" || typeof d == "number") && (d = typeof d == "string" || typeof d == "number" ? String(d) : ""), a.push({
        type: typeof d == "string" ? Re.literal : Re.object,
        value: d
      });
      continue;
    }
    if (Eu(c)) {
      var h = typeof c.style == "string" ? i.date[c.style] : Uo(c.style) ? c.style.parsedOptions : void 0;
      a.push({
        type: Re.literal,
        value: n.getDateTimeFormat(e, h).format(d)
      });
      continue;
    }
    if (Cu(c)) {
      var h = typeof c.style == "string" ? i.time[c.style] : Uo(c.style) ? c.style.parsedOptions : i.time.medium;
      a.push({
        type: Re.literal,
        value: n.getDateTimeFormat(e, h).format(d)
      });
      continue;
    }
    if (ku(c)) {
      var h = typeof c.style == "string" ? i.number[c.style] : Pu(c.style) ? c.style.parsedOptions : void 0;
      h && h.scale && (d = d * (h.scale || 1)), a.push({
        type: Re.literal,
        value: n.getNumberFormat(e, h).format(d)
      });
      continue;
    }
    if (Tu(c)) {
      var _ = c.children, m = c.value, p = r[m];
      if (!Lp(p))
        throw new Dp(m, "function", s);
      var E = Vi(_, e, n, i, r, o), w = p(E.map(function(T) {
        return T.value;
      }));
      Array.isArray(w) || (w = [w]), a.push.apply(a, w.map(function(T) {
        return {
          type: typeof T == "string" ? Re.literal : Re.object,
          value: T
        };
      }));
    }
    if (Su(c)) {
      var g = c.options[d] || c.options.other;
      if (!g)
        throw new Bl(c.value, d, Object.keys(c.options), s);
      a.push.apply(a, Vi(g.value, e, n, i, r));
      continue;
    }
    if (Au(c)) {
      var g = c.options["=".concat(d)];
      if (!g) {
        if (!Intl.PluralRules)
          throw new br(`Intl.PluralRules is not available in this environment.
Try polyfilling it using "@formatjs/intl-pluralrules"
`, zn.MISSING_INTL_API, s);
        var b = n.getPluralRules(e, { type: c.pluralType }).select(d - (c.offset || 0));
        g = c.options[b] || c.options.other;
      }
      if (!g)
        throw new Bl(c.value, d, Object.keys(c.options), s);
      a.push.apply(a, Vi(g.value, e, n, i, r, d - (c.offset || 0)));
      continue;
    }
  }
  return Rp(a);
}
function Bp(t, e) {
  return e ? K(K(K({}, t || {}), e || {}), Object.keys(t).reduce(function(n, i) {
    return n[i] = K(K({}, t[i]), e[i] || {}), n;
  }, {})) : t;
}
function Op(t, e) {
  return e ? Object.keys(t).reduce(function(n, i) {
    return n[i] = Bp(t[i], e[i]), n;
  }, K({}, t)) : t;
}
function po(t) {
  return {
    create: function() {
      return {
        get: function(e) {
          return t[e];
        },
        set: function(e, n) {
          t[e] = n;
        }
      };
    }
  };
}
function Np(t) {
  return t === void 0 && (t = {
    number: {},
    dateTime: {},
    pluralRules: {}
  }), {
    getNumberFormat: _o(function() {
      for (var e, n = [], i = 0; i < arguments.length; i++)
        n[i] = arguments[i];
      return new ((e = Intl.NumberFormat).bind.apply(e, fo([void 0], n, !1)))();
    }, {
      cache: po(t.number),
      strategy: mo.variadic
    }),
    getDateTimeFormat: _o(function() {
      for (var e, n = [], i = 0; i < arguments.length; i++)
        n[i] = arguments[i];
      return new ((e = Intl.DateTimeFormat).bind.apply(e, fo([void 0], n, !1)))();
    }, {
      cache: po(t.dateTime),
      strategy: mo.variadic
    }),
    getPluralRules: _o(function() {
      for (var e, n = [], i = 0; i < arguments.length; i++)
        n[i] = arguments[i];
      return new ((e = Intl.PluralRules).bind.apply(e, fo([void 0], n, !1)))();
    }, {
      cache: po(t.pluralRules),
      strategy: mo.variadic
    })
  };
}
var Hp = (
  /** @class */
  function() {
    function t(e, n, i, r) {
      var o = this;
      if (n === void 0 && (n = t.defaultLocale), this.formatterCache = {
        number: {},
        dateTime: {},
        pluralRules: {}
      }, this.format = function(s) {
        var a = o.formatToParts(s);
        if (a.length === 1)
          return a[0].value;
        var l = a.reduce(function(u, c) {
          return !u.length || c.type !== Re.literal || typeof u[u.length - 1] != "string" ? u.push(c.value) : u[u.length - 1] += c.value, u;
        }, []);
        return l.length <= 1 ? l[0] || "" : l;
      }, this.formatToParts = function(s) {
        return Vi(o.ast, o.locales, o.formatters, o.formats, s, void 0, o.message);
      }, this.resolvedOptions = function() {
        return {
          locale: o.resolvedLocale.toString()
        };
      }, this.getAst = function() {
        return o.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 = Op(t.formats, i), this.formatters = r && r.formatters || Np(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 = kp, 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 Ip(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 o = n.slice(r, n.length).join(".");
        if (o in i) {
          i = i[o];
          break;
        }
      }
      i = i[n[r]];
    } else
      i = void 0;
  return i;
}
const Ht = {}, Up = (t, e, n) => n && (e in Ht || (Ht[e] = {}), t in Ht[e] || (Ht[e][t] = n), n), Uu = (t, e) => {
  if (e == null)
    return;
  if (e in Ht && t in Ht[e])
    return Ht[e][t];
  const n = vr(e);
  for (let i = 0; i < n.length; i++) {
    const r = n[i], o = zp(r, t);
    if (o)
      return Up(t, e, o);
  }
};
let hs;
const vi = bi({});
function jp(t) {
  return hs[t] || null;
}
function ju(t) {
  return t in hs;
}
function zp(t, e) {
  if (!ju(t))
    return null;
  const n = jp(t);
  return Ip(n, e);
}
function Fp(t) {
  if (t == null)
    return;
  const e = vr(t);
  for (let n = 0; n < e.length; n++) {
    const i = e[n];
    if (ju(i))
      return i;
  }
}
function qp(t, ...e) {
  delete Ht[t], vi.update((n) => (n[t] = Xm.all([n[t] || {}, ...e]), n));
}
Yn(
  [vi],
  ([t]) => Object.keys(t)
);
vi.subscribe((t) => hs = t);
const Xi = {};
function Wp(t, e) {
  Xi[t].delete(e), Xi[t].size === 0 && delete Xi[t];
}
function zu(t) {
  return Xi[t];
}
function Gp(t) {
  return vr(t).map((e) => {
    const n = zu(e);
    return [e, n ? [...n] : []];
  }).filter(([, e]) => e.length > 0);
}
function Go(t) {
  return t == null ? !1 : vr(t).some(
    (e) => {
      var n;
      return (n = zu(e)) == null ? void 0 : n.size;
    }
  );
}
function Vp(t, e) {
  return Promise.all(
    e.map((i) => (Wp(t, i), i().then((r) => r.default || r)))
  ).then((i) => qp(t, ...i));
}
const ii = {};
function Fu(t) {
  if (!Go(t))
    return t in ii ? ii[t] : Promise.resolve();
  const e = Gp(t);
  return ii[t] = Promise.all(
    e.map(
      ([n, i]) => Vp(n, i)
    )
  ).then(() => {
    if (Go(t))
      return Fu(t);
    delete ii[t];
  }), ii[t];
}
const Xp = {
  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"
    }
  }
}, Zp = {
  fallbackLocale: null,
  loadingDelay: 200,
  formats: Xp,
  warnOnMissingMessages: !0,
  handleMissingMessage: void 0,
  ignoreTag: !0
}, Jp = Zp;
function Fn() {
  return Jp;
}
const go = bi(!1);
var Yp = Object.defineProperty, Qp = Object.defineProperties, Kp = Object.getOwnPropertyDescriptors, Ol = Object.getOwnPropertySymbols, xp = Object.prototype.hasOwnProperty, $p = Object.prototype.propertyIsEnumerable, Nl = (t, e, n) => e in t ? Yp(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, e1 = (t, e) => {
  for (var n in e || (e = {}))
    xp.call(e, n) && Nl(t, n, e[n]);
  if (Ol)
    for (var n of Ol(e))
      $p.call(e, n) && Nl(t, n, e[n]);
  return t;
}, t1 = (t, e) => Qp(t, Kp(e));
let Vo;
const ir = bi(null);
function Hl(t) {
  return t.split("-").map((e, n, i) => i.slice(0, n + 1).join("-")).reverse();
}
function vr(t, e = Fn().fallbackLocale) {
  const n = Hl(t);
  return e ? [.../* @__PURE__ */ new Set([...n, ...Hl(e)])] : n;
}
function vn() {
  return Vo ?? void 0;
}
ir.subscribe((t) => {
  Vo = t ?? void 0, typeof window < "u" && t != null && document.documentElement.setAttribute("lang", t);
});
const n1 = (t) => {
  if (t && Fp(t) && Go(t)) {
    const { loadingDelay: e } = Fn();
    let n;
    return typeof window < "u" && vn() != null && e ? n = window.setTimeout(
      () => go.set(!0),
      e
    ) : go.set(!0), Fu(t).then(() => {
      ir.set(t);
    }).finally(() => {
      clearTimeout(n), go.set(!1);
    });
  }
  return ir.set(t);
}, wi = t1(e1({}, ir), {
  set: n1
}), wr = (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 i1 = Object.defineProperty, rr = Object.getOwnPropertySymbols, qu = Object.prototype.hasOwnProperty, Wu = Object.prototype.propertyIsEnumerable, Il = (t, e, n) => e in t ? i1(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, _s = (t, e) => {
  for (var n in e || (e = {}))
    qu.call(e, n) && Il(t, n, e[n]);
  if (rr)
    for (var n of rr(e))
      Wu.call(e, n) && Il(t, n, e[n]);
  return t;
}, Qn = (t, e) => {
  var n = {};
  for (var i in t)
    qu.call(t, i) && e.indexOf(i) < 0 && (n[i] = t[i]);
  if (t != null && rr)
    for (var i of rr(t))
      e.indexOf(i) < 0 && Wu.call(t, i) && (n[i] = t[i]);
  return n;
};
const mi = (t, e) => {
  const { formats: n } = Fn();
  if (t in n && e in n[t])
    return n[t][e];
  throw new Error(`[svelte-i18n] Unknown "${e}" ${t} format.`);
}, r1 = wr(
  (t) => {
    var e = t, { locale: n, format: i } = e, r = Qn(e, ["locale", "format"]);
    if (n == null)
      throw new Error('[svelte-i18n] A "locale" must be set to format numbers');
    return i && (r = mi("number", i)), new Intl.NumberFormat(n, r);
  }
), o1 = wr(
  (t) => {
    var e = t, { locale: n, format: i } = e, r = Qn(e, ["locale", "format"]);
    if (n == null)
      throw new Error('[svelte-i18n] A "locale" must be set to format dates');
    return i ? r = mi("date", i) : Object.keys(r).length === 0 && (r = mi("date", "short")), new Intl.DateTimeFormat(n, r);
  }
), s1 = wr(
  (t) => {
    var e = t, { locale: n, format: i } = e, r = Qn(e, ["locale", "format"]);
    if (n == null)
      throw new Error(
        '[svelte-i18n] A "locale" must be set to format time values'
      );
    return i ? r = mi("time", i) : Object.keys(r).length === 0 && (r = mi("time", "short")), new Intl.DateTimeFormat(n, r);
  }
), l1 = (t = {}) => {
  var e = t, {
    locale: n = vn()
  } = e, i = Qn(e, [
    "locale"
  ]);
  return r1(_s({ locale: n }, i));
}, a1 = (t = {}) => {
  var e = t, {
    locale: n = vn()
  } = e, i = Qn(e, [
    "locale"
  ]);
  return o1(_s({ locale: n }, i));
}, u1 = (t = {}) => {
  var e = t, {
    locale: n = vn()
  } = e, i = Qn(e, [
    "locale"
  ]);
  return s1(_s({ locale: n }, i));
}, c1 = wr(
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
  (t, e = vn()) => new Hp(t, e, Fn().formats, {
    ignoreTag: Fn().ignoreTag
  })
), f1 = (t, e = {}) => {
  var n, i, r, o;
  let s = e;
  typeof t == "object" && (s = t, t = s.id);
  const {
    values: a,
    locale: l = vn(),
    default: u
  } = s;
  if (l == null)
    throw new Error(
      "[svelte-i18n] Cannot format a message without first setting the initial locale."
    );
  let c = Uu(t, l);
  if (!c)
    c = (o = (r = (i = (n = Fn()).handleMissingMessage) == null ? void 0 : i.call(n, { locale: l, id: t, defaultValue: u })) != null ? r : u) != null ? o : t;
  else if (typeof c != "string")
    return console.warn(
      `[svelte-i18n] Message with id "${t}" must be of type "string", found: "${typeof c}". Gettin its value through the "$format" method is deprecated; use the "json" method instead.`
    ), c;
  if (!a)
    return c;
  let f = c;
  try {
    f = c1(c, l).format(a);
  } catch (d) {
    d instanceof Error && console.warn(
      `[svelte-i18n] Message "${t}" has syntax error:`,
      d.message
    );
  }
  return f;
}, d1 = (t, e) => u1(e).format(t), h1 = (t, e) => a1(e).format(t), _1 = (t, e) => l1(e).format(t), m1 = (t, e = vn()) => Uu(t, e);
Yn([wi, vi], () => f1);
Yn([wi], () => d1);
Yn([wi], () => h1);
Yn([wi], () => _1);
Yn([wi, vi], () => m1);
const {
  SvelteComponent: p1,
  append: Fe,
  attr: xt,
  detach: Gu,
  element: $t,
  init: g1,
  insert: Vu,
  noop: Ul,
  safe_not_equal: b1,
  set_data: or,
  set_style: bo,
  space: Xo,
  text: Rn,
  toggle_class: jl
} = window.__gradio__svelte__internal, { onMount: v1, createEventDispatcher: w1, getContext: y1 } = window.__gradio__svelte__internal;
function zl(t) {
  let e, n, i, r, o = ui(
    /*file_to_display*/
    t[2]
  ) + "", s, a, l, u, c = (
    /*file_to_display*/
    t[2].orig_name + ""
  ), f;
  return {
    c() {
      e = $t("div"), n = $t("span"), i = $t("div"), r = $t("progress"), s = Rn(o), l = Xo(), u = $t("span"), f = Rn(c), bo(r, "visibility", "hidden"), bo(r, "height", "0"), bo(r, "width", "0"), r.value = a = ui(
        /*file_to_display*/
        t[2]
      ), xt(r, "max", "100"), xt(r, "class", "svelte-cr2edf"), xt(i, "class", "progress-bar svelte-cr2edf"), xt(u, "class", "file-name svelte-cr2edf"), xt(e, "class", "file svelte-cr2edf");
    },
    m(d, h) {
      Vu(d, e, h), Fe(e, n), Fe(n, i), Fe(i, r), Fe(r, s), Fe(e, l), Fe(e, u), Fe(u, f);
    },
    p(d, h) {
      h & /*file_to_display*/
      4 && o !== (o = ui(
        /*file_to_display*/
        d[2]
      ) + "") && or(s, o), h & /*file_to_display*/
      4 && a !== (a = ui(
        /*file_to_display*/
        d[2]
      )) && (r.value = a), h & /*file_to_display*/
      4 && c !== (c = /*file_to_display*/
      d[2].orig_name + "") && or(f, c);
    },
    d(d) {
      d && Gu(e);
    }
  };
}
function k1(t) {
  let e, n, i, r = (
    /*files_with_progress*/
    t[0].length + ""
  ), o, s, a = (
    /*files_with_progress*/
    t[0].length > 1 ? "files" : "file"
  ), l, u, c, f = (
    /*file_to_display*/
    t[2] && zl(t)
  );
  return {
    c() {
      e = $t("div"), n = $t("span"), i = Rn("Uploading "), o = Rn(r), s = Xo(), l = Rn(a), u = Rn("..."), c = Xo(), f && f.c(), xt(n, "class", "uploading svelte-cr2edf"), xt(e, "class", "wrap svelte-cr2edf"), jl(
        e,
        "progress",
        /*progress*/
        t[1]
      );
    },
    m(d, h) {
      Vu(d, e, h), Fe(e, n), Fe(n, i), Fe(n, o), Fe(n, s), Fe(n, l), Fe(n, u), Fe(e, c), f && f.m(e, null);
    },
    p(d, [h]) {
      h & /*files_with_progress*/
      1 && r !== (r = /*files_with_progress*/
      d[0].length + "") && or(o, r), h & /*files_with_progress*/
      1 && a !== (a = /*files_with_progress*/
      d[0].length > 1 ? "files" : "file") && or(l, a), /*file_to_display*/
      d[2] ? f ? f.p(d, h) : (f = zl(d), f.c(), f.m(e, null)) : f && (f.d(1), f = null), h & /*progress*/
      2 && jl(
        e,
        "progress",
        /*progress*/
        d[1]
      );
    },
    i: Ul,
    o: Ul,
    d(d) {
      d && Gu(e), f && f.d();
    }
  };
}
function ui(t) {
  return t.progress * 100 / (t.size || 0) || 0;
}
function E1(t) {
  let e = 0;
  return t.forEach((n) => {
    e += ui(n);
  }), document.documentElement.style.setProperty("--upload-progress-width", (e / t.length).toFixed(2) + "%"), e / t.length;
}
function C1(t, e, n) {
  let { upload_id: i } = e, { root: r } = e, { files: o } = e, s, a = !1, l, u, c = o.map((_) => ({ ..._, progress: 0 }));
  const f = w1();
  function d(_, m) {
    n(0, c = c.map((p) => (p.orig_name === _ && (p.progress += m), p)));
  }
  const h = y1("EventSource_factory");
  return v1(() => {
    s = h(new URL(`${r}/upload_progress?upload_id=${i}`)), s.onmessage = async function(_) {
      const m = JSON.parse(_.data);
      a || n(1, a = !0), m.msg === "done" ? (s.close(), f("done")) : (n(6, l = m), d(m.orig_name, m.chunk_size));
    };
  }), t.$$set = (_) => {
    "upload_id" in _ && n(3, i = _.upload_id), "root" in _ && n(4, r = _.root), "files" in _ && n(5, o = _.files);
  }, t.$$.update = () => {
    t.$$.dirty & /*files_with_progress*/
    1 && E1(c), t.$$.dirty & /*current_file_upload, files_with_progress*/
    65 && n(2, u = l || c[0]);
  }, [
    c,
    a,
    u,
    i,
    r,
    o,
    l
  ];
}
class S1 extends p1 {
  constructor(e) {
    super(), g1(this, e, C1, k1, b1, { upload_id: 3, root: 4, files: 5 });
  }
}
const {
  SvelteComponent: A1,
  append: Fl,
  attr: De,
  binding_callbacks: T1,
  bubble: Jt,
  check_outros: Xu,
  create_component: P1,
  create_slot: Zu,
  destroy_component: D1,
  detach: yr,
  element: Zo,
  empty: Ju,
  get_all_dirty_from_scope: Yu,
  get_slot_changes: Qu,
  group_outros: Ku,
  init: M1,
  insert: kr,
  listen: Ge,
  mount_component: R1,
  prevent_default: Yt,
  run_all: L1,
  safe_not_equal: B1,
  set_style: xu,
  space: O1,
  stop_propagation: Qt,
  toggle_class: ge,
  transition_in: zt,
  transition_out: fn,
  update_slot_base: $u
} = window.__gradio__svelte__internal, { createEventDispatcher: N1, tick: H1, getContext: I1 } = window.__gradio__svelte__internal;
function U1(t) {
  let e, n, i, r, o, s, a, l, u, c, f;
  const d = (
    /*#slots*/
    t[23].default
  ), h = Zu(
    d,
    t,
    /*$$scope*/
    t[22],
    null
  );
  return {
    c() {
      e = Zo("button"), h && h.c(), n = O1(), i = Zo("input"), De(i, "aria-label", "file upload"), De(i, "data-testid", "file-upload"), De(i, "type", "file"), De(i, "accept", r = /*accept_file_types*/
      t[15] || void 0), i.multiple = o = /*file_count*/
      t[6] === "multiple" || void 0, De(i, "webkitdirectory", s = /*file_count*/
      t[6] === "directory" || void 0), De(i, "mozdirectory", a = /*file_count*/
      t[6] === "directory" || void 0), De(i, "class", "svelte-1s26xmt"), De(e, "tabindex", l = /*hidden*/
      t[9] ? -1 : 0), De(e, "class", "svelte-1s26xmt"), ge(
        e,
        "hidden",
        /*hidden*/
        t[9]
      ), ge(
        e,
        "center",
        /*center*/
        t[4]
      ), ge(
        e,
        "boundedheight",
        /*boundedheight*/
        t[3]
      ), ge(
        e,
        "flex",
        /*flex*/
        t[5]
      ), ge(
        e,
        "disable_click",
        /*disable_click*/
        t[7]
      ), xu(e, "height", "100%");
    },
    m(_, m) {
      kr(_, e, m), h && h.m(e, null), Fl(e, n), Fl(e, i), t[31](i), u = !0, c || (f = [
        Ge(
          i,
          "change",
          /*load_files_from_upload*/
          t[17]
        ),
        Ge(e, "drag", Qt(Yt(
          /*drag_handler*/
          t[24]
        ))),
        Ge(e, "dragstart", Qt(Yt(
          /*dragstart_handler*/
          t[25]
        ))),
        Ge(e, "dragend", Qt(Yt(
          /*dragend_handler*/
          t[26]
        ))),
        Ge(e, "dragover", Qt(Yt(
          /*dragover_handler*/
          t[27]
        ))),
        Ge(e, "dragenter", Qt(Yt(
          /*dragenter_handler*/
          t[28]
        ))),
        Ge(e, "dragleave", Qt(Yt(
          /*dragleave_handler*/
          t[29]
        ))),
        Ge(e, "drop", Qt(Yt(
          /*drop_handler*/
          t[30]
        ))),
        Ge(
          e,
          "click",
          /*open_file_upload*/
          t[12]
        ),
        Ge(
          e,
          "drop",
          /*loadFilesFromDrop*/
          t[18]
        ),
        Ge(
          e,
          "dragenter",
          /*updateDragging*/
          t[16]
        ),
        Ge(
          e,
          "dragleave",
          /*updateDragging*/
          t[16]
        )
      ], c = !0);
    },
    p(_, m) {
      h && h.p && (!u || m[0] & /*$$scope*/
      4194304) && $u(
        h,
        d,
        _,
        /*$$scope*/
        _[22],
        u ? Qu(
          d,
          /*$$scope*/
          _[22],
          m,
          null
        ) : Yu(
          /*$$scope*/
          _[22]
        ),
        null
      ), (!u || m[0] & /*accept_file_types*/
      32768 && r !== (r = /*accept_file_types*/
      _[15] || void 0)) && De(i, "accept", r), (!u || m[0] & /*file_count*/
      64 && o !== (o = /*file_count*/
      _[6] === "multiple" || void 0)) && (i.multiple = o), (!u || m[0] & /*file_count*/
      64 && s !== (s = /*file_count*/
      _[6] === "directory" || void 0)) && De(i, "webkitdirectory", s), (!u || m[0] & /*file_count*/
      64 && a !== (a = /*file_count*/
      _[6] === "directory" || void 0)) && De(i, "mozdirectory", a), (!u || m[0] & /*hidden*/
      512 && l !== (l = /*hidden*/
      _[9] ? -1 : 0)) && De(e, "tabindex", l), (!u || m[0] & /*hidden*/
      512) && ge(
        e,
        "hidden",
        /*hidden*/
        _[9]
      ), (!u || m[0] & /*center*/
      16) && ge(
        e,
        "center",
        /*center*/
        _[4]
      ), (!u || m[0] & /*boundedheight*/
      8) && ge(
        e,
        "boundedheight",
        /*boundedheight*/
        _[3]
      ), (!u || m[0] & /*flex*/
      32) && ge(
        e,
        "flex",
        /*flex*/
        _[5]
      ), (!u || m[0] & /*disable_click*/
      128) && ge(
        e,
        "disable_click",
        /*disable_click*/
        _[7]
      );
    },
    i(_) {
      u || (zt(h, _), u = !0);
    },
    o(_) {
      fn(h, _), u = !1;
    },
    d(_) {
      _ && yr(e), h && h.d(_), t[31](null), c = !1, L1(f);
    }
  };
}
function j1(t) {
  let e, n, i = !/*hidden*/
  t[9] && ql(t);
  return {
    c() {
      i && i.c(), e = Ju();
    },
    m(r, o) {
      i && i.m(r, o), kr(r, e, o), n = !0;
    },
    p(r, o) {
      /*hidden*/
      r[9] ? i && (Ku(), fn(i, 1, 1, () => {
        i = null;
      }), Xu()) : i ? (i.p(r, o), o[0] & /*hidden*/
      512 && zt(i, 1)) : (i = ql(r), i.c(), zt(i, 1), i.m(e.parentNode, e));
    },
    i(r) {
      n || (zt(i), n = !0);
    },
    o(r) {
      fn(i), n = !1;
    },
    d(r) {
      r && yr(e), i && i.d(r);
    }
  };
}
function z1(t) {
  let e, n, i, r, o;
  const s = (
    /*#slots*/
    t[23].default
  ), a = Zu(
    s,
    t,
    /*$$scope*/
    t[22],
    null
  );
  return {
    c() {
      e = Zo("button"), a && a.c(), De(e, "tabindex", n = /*hidden*/
      t[9] ? -1 : 0), De(e, "class", "svelte-1s26xmt"), ge(
        e,
        "hidden",
        /*hidden*/
        t[9]
      ), ge(
        e,
        "center",
        /*center*/
        t[4]
      ), ge(
        e,
        "boundedheight",
        /*boundedheight*/
        t[3]
      ), ge(
        e,
        "flex",
        /*flex*/
        t[5]
      ), xu(e, "height", "100%");
    },
    m(l, u) {
      kr(l, e, u), a && a.m(e, null), i = !0, r || (o = Ge(
        e,
        "click",
        /*paste_clipboard*/
        t[11]
      ), r = !0);
    },
    p(l, u) {
      a && a.p && (!i || u[0] & /*$$scope*/
      4194304) && $u(
        a,
        s,
        l,
        /*$$scope*/
        l[22],
        i ? Qu(
          s,
          /*$$scope*/
          l[22],
          u,
          null
        ) : Yu(
          /*$$scope*/
          l[22]
        ),
        null
      ), (!i || u[0] & /*hidden*/
      512 && n !== (n = /*hidden*/
      l[9] ? -1 : 0)) && De(e, "tabindex", n), (!i || u[0] & /*hidden*/
      512) && ge(
        e,
        "hidden",
        /*hidden*/
        l[9]
      ), (!i || u[0] & /*center*/
      16) && ge(
        e,
        "center",
        /*center*/
        l[4]
      ), (!i || u[0] & /*boundedheight*/
      8) && ge(
        e,
        "boundedheight",
        /*boundedheight*/
        l[3]
      ), (!i || u[0] & /*flex*/
      32) && ge(
        e,
        "flex",
        /*flex*/
        l[5]
      );
    },
    i(l) {
      i || (zt(a, l), i = !0);
    },
    o(l) {
      fn(a, l), i = !1;
    },
    d(l) {
      l && yr(e), a && a.d(l), r = !1, o();
    }
  };
}
function ql(t) {
  let e, n;
  return e = new S1({
    props: {
      root: (
        /*root*/
        t[8]
      ),
      upload_id: (
        /*upload_id*/
        t[13]
      ),
      files: (
        /*file_data*/
        t[14]
      )
    }
  }), {
    c() {
      P1(e.$$.fragment);
    },
    m(i, r) {
      R1(e, i, r), n = !0;
    },
    p(i, r) {
      const o = {};
      r[0] & /*root*/
      256 && (o.root = /*root*/
      i[8]), r[0] & /*upload_id*/
      8192 && (o.upload_id = /*upload_id*/
      i[13]), r[0] & /*file_data*/
      16384 && (o.files = /*file_data*/
      i[14]), e.$set(o);
    },
    i(i) {
      n || (zt(e.$$.fragment, i), n = !0);
    },
    o(i) {
      fn(e.$$.fragment, i), n = !1;
    },
    d(i) {
      D1(e, i);
    }
  };
}
function F1(t) {
  let e, n, i, r;
  const o = [z1, j1, U1], s = [];
  function a(l, u) {
    return (
      /*filetype*/
      l[0] === "clipboard" ? 0 : (
        /*uploading*/
        l[1] && /*show_progress*/
        l[10] ? 1 : 2
      )
    );
  }
  return e = a(t), n = s[e] = o[e](t), {
    c() {
      n.c(), i = Ju();
    },
    m(l, u) {
      s[e].m(l, u), kr(l, i, u), r = !0;
    },
    p(l, u) {
      let c = e;
      e = a(l), e === c ? s[e].p(l, u) : (Ku(), fn(s[c], 1, 1, () => {
        s[c] = null;
      }), Xu(), n = s[e], n ? n.p(l, u) : (n = s[e] = o[e](l), n.c()), zt(n, 1), n.m(i.parentNode, i));
    },
    i(l) {
      r || (zt(n), r = !0);
    },
    o(l) {
      fn(n), r = !1;
    },
    d(l) {
      l && yr(i), s[e].d(l);
    }
  };
}
function Wl(t) {
  let e, n = t[0], i = 1;
  for (; i < t.length; ) {
    const r = t[i], o = t[i + 1];
    if (i += 2, (r === "optionalAccess" || r === "optionalCall") && n == null)
      return;
    r === "access" || r === "optionalAccess" ? (e = n, n = o(n)) : (r === "call" || r === "optionalCall") && (n = o((...s) => n.call(e, ...s)), e = void 0);
  }
  return n;
}
function q1(t, e, n) {
  if (!t || t === "*" || t === "file/*" || Array.isArray(t) && t.some((r) => r === "*" || r === "file/*"))
    return !0;
  let i;
  if (typeof t == "string")
    i = t.split(",").map((r) => r.trim());
  else if (Array.isArray(t))
    i = t;
  else
    return !1;
  return i.includes(e) || i.some((r) => {
    const [o] = r.split("/").map((s) => s.trim());
    return r.endsWith("/*") && n.startsWith(o + "/");
  });
}
function W1(t, e, n) {
  let { $$slots: i = {}, $$scope: r } = e, { filetype: o = null } = e, { dragging: s = !1 } = e, { boundedheight: a = !0 } = e, { center: l = !0 } = e, { flex: u = !0 } = e, { file_count: c = "single" } = e, { disable_click: f = !1 } = e, { root: d } = e, { hidden: h = !1 } = e, { format: _ = "file" } = e, { uploading: m = !1 } = e, { hidden_upload: p = null } = e, { show_progress: E = !0 } = e, w, g, b;
  const T = I1("upload_files"), C = N1(), M = ["image", "video", "audio", "text", "file"], A = (k) => k.startsWith(".") || k.endsWith("/*") ? k : M.includes(k) ? k + "/*" : "." + k;
  function P() {
    n(19, s = !s);
  }
  function D() {
    navigator.clipboard.read().then(async (k) => {
      for (let z = 0; z < k.length; z++) {
        const V = k[z].types.find((G) => G.startsWith("image/"));
        if (V) {
          k[z].getType(V).then(async (G) => {
            const x = new File([G], `clipboard.${V.replace("image/", "")}`);
            await U([x]);
          });
          break;
        }
      }
    });
  }
  function W() {
    f || p && (n(2, p.value = "", p), p.click());
  }
  async function j(k) {
    await H1(), n(13, w = Math.random().toString(36).substring(2, 15)), n(1, m = !0);
    const z = await _u(k, d, w, T);
    return C("load", c === "single" ? Wl([z, "optionalAccess", (V) => V[0]]) : z), n(1, m = !1), z || [];
  }
  async function U(k) {
    if (!k.length)
      return;
    let z = k.map((V) => new File([V], V.name, { type: V.type }));
    return n(14, g = await mu(z)), await j(g);
  }
  async function oe(k) {
    const z = k.target;
    if (z.files)
      if (_ != "blob")
        await U(Array.from(z.files));
      else {
        if (c === "single") {
          C("load", z.files[0]);
          return;
        }
        C("load", z.files);
      }
  }
  async function B(k) {
    if (n(19, s = !1), !Wl([k, "access", (V) => V.dataTransfer, "optionalAccess", (V) => V.files]))
      return;
    const z = Array.from(k.dataTransfer.files).filter((V) => {
      const G = "." + V.name.split(".").pop();
      return G && q1(b, G, V.type) || (G && Array.isArray(o) ? o.includes(G) : G === o) ? !0 : (C("error", `Invalid file type only ${o} allowed.`), !1);
    });
    await U(z);
  }
  function O(k) {
    Jt.call(this, t, k);
  }
  function X(k) {
    Jt.call(this, t, k);
  }
  function le(k) {
    Jt.call(this, t, k);
  }
  function J(k) {
    Jt.call(this, t, k);
  }
  function v(k) {
    Jt.call(this, t, k);
  }
  function y(k) {
    Jt.call(this, t, k);
  }
  function N(k) {
    Jt.call(this, t, k);
  }
  function S(k) {
    T1[k ? "unshift" : "push"](() => {
      p = k, n(2, p);
    });
  }
  return t.$$set = (k) => {
    "filetype" in k && n(0, o = k.filetype), "dragging" in k && n(19, s = k.dragging), "boundedheight" in k && n(3, a = k.boundedheight), "center" in k && n(4, l = k.center), "flex" in k && n(5, u = k.flex), "file_count" in k && n(6, c = k.file_count), "disable_click" in k && n(7, f = k.disable_click), "root" in k && n(8, d = k.root), "hidden" in k && n(9, h = k.hidden), "format" in k && n(20, _ = k.format), "uploading" in k && n(1, m = k.uploading), "hidden_upload" in k && n(2, p = k.hidden_upload), "show_progress" in k && n(10, E = k.show_progress), "$$scope" in k && n(22, r = k.$$scope);
  }, t.$$.update = () => {
    t.$$.dirty[0] & /*filetype*/
    1 && (o == null ? n(15, b = null) : typeof o == "string" ? n(15, b = A(o)) : (n(0, o = o.map(A)), n(15, b = o.join(", "))));
  }, [
    o,
    m,
    p,
    a,
    l,
    u,
    c,
    f,
    d,
    h,
    E,
    D,
    W,
    w,
    g,
    b,
    P,
    oe,
    B,
    s,
    _,
    U,
    r,
    i,
    O,
    X,
    le,
    J,
    v,
    y,
    N,
    S
  ];
}
class G1 extends A1 {
  constructor(e) {
    super(), M1(
      this,
      e,
      W1,
      F1,
      B1,
      {
        filetype: 0,
        dragging: 19,
        boundedheight: 3,
        center: 4,
        flex: 5,
        file_count: 6,
        disable_click: 7,
        root: 8,
        hidden: 9,
        format: 20,
        uploading: 1,
        hidden_upload: 2,
        show_progress: 10,
        paste_clipboard: 11,
        open_file_upload: 12,
        load_files: 21
      },
      null,
      [-1, -1]
    );
  }
  get paste_clipboard() {
    return this.$$.ctx[11];
  }
  get open_file_upload() {
    return this.$$.ctx[12];
  }
  get load_files() {
    return this.$$.ctx[21];
  }
}
const {
  SvelteComponent: V1,
  append: vo,
  attr: X1,
  check_outros: wo,
  create_component: yi,
  destroy_component: ki,
  detach: Z1,
  element: J1,
  group_outros: yo,
  init: Y1,
  insert: Q1,
  mount_component: Ei,
  safe_not_equal: K1,
  set_style: Gl,
  space: ko,
  toggle_class: Vl,
  transition_in: je,
  transition_out: lt
} = window.__gradio__svelte__internal, { createEventDispatcher: x1 } = window.__gradio__svelte__internal;
function Xl(t) {
  let e, n;
  return e = new Xn({
    props: {
      Icon: yd,
      label: (
        /*i18n*/
        t[4]("common.edit")
      )
    }
  }), e.$on(
    "click",
    /*click_handler*/
    t[6]
  ), {
    c() {
      yi(e.$$.fragment);
    },
    m(i, r) {
      Ei(e, i, r), n = !0;
    },
    p(i, r) {
      const o = {};
      r & /*i18n*/
      16 && (o.label = /*i18n*/
      i[4]("common.edit")), e.$set(o);
    },
    i(i) {
      n || (je(e.$$.fragment, i), n = !0);
    },
    o(i) {
      lt(e.$$.fragment, i), n = !1;
    },
    d(i) {
      ki(e, i);
    }
  };
}
function Zl(t) {
  let e, n;
  return e = new Xn({
    props: {
      Icon: Va,
      label: (
        /*i18n*/
        t[4]("common.undo")
      )
    }
  }), e.$on(
    "click",
    /*click_handler_1*/
    t[7]
  ), {
    c() {
      yi(e.$$.fragment);
    },
    m(i, r) {
      Ei(e, i, r), n = !0;
    },
    p(i, r) {
      const o = {};
      r & /*i18n*/
      16 && (o.label = /*i18n*/
      i[4]("common.undo")), e.$set(o);
    },
    i(i) {
      n || (je(e.$$.fragment, i), n = !0);
    },
    o(i) {
      lt(e.$$.fragment, i), n = !1;
    },
    d(i) {
      ki(e, i);
    }
  };
}
function Jl(t) {
  let e, n;
  return e = new fu({
    props: {
      href: (
        /*download*/
        t[2]
      ),
      download: !0,
      $$slots: { default: [$1] },
      $$scope: { ctx: t }
    }
  }), {
    c() {
      yi(e.$$.fragment);
    },
    m(i, r) {
      Ei(e, i, r), n = !0;
    },
    p(i, r) {
      const o = {};
      r & /*download*/
      4 && (o.href = /*download*/
      i[2]), r & /*$$scope, i18n*/
      528 && (o.$$scope = { dirty: r, ctx: i }), e.$set(o);
    },
    i(i) {
      n || (je(e.$$.fragment, i), n = !0);
    },
    o(i) {
      lt(e.$$.fragment, i), n = !1;
    },
    d(i) {
      ki(e, i);
    }
  };
}
function $1(t) {
  let e, n;
  return e = new Xn({
    props: {
      Icon: qa,
      label: (
        /*i18n*/
        t[4]("common.download")
      )
    }
  }), {
    c() {
      yi(e.$$.fragment);
    },
    m(i, r) {
      Ei(e, i, r), n = !0;
    },
    p(i, r) {
      const o = {};
      r & /*i18n*/
      16 && (o.label = /*i18n*/
      i[4]("common.download")), e.$set(o);
    },
    i(i) {
      n || (je(e.$$.fragment, i), n = !0);
    },
    o(i) {
      lt(e.$$.fragment, i), n = !1;
    },
    d(i) {
      ki(e, i);
    }
  };
}
function eg(t) {
  let e, n, i, r, o, s, a = (
    /*editable*/
    t[0] && Xl(t)
  ), l = (
    /*undoable*/
    t[1] && Zl(t)
  ), u = (
    /*download*/
    t[2] && Jl(t)
  );
  return o = new Xn({
    props: {
      Icon: xf,
      label: (
        /*i18n*/
        t[4]("common.clear")
      )
    }
  }), o.$on(
    "click",
    /*click_handler_2*/
    t[8]
  ), {
    c() {
      e = J1("div"), a && a.c(), n = ko(), l && l.c(), i = ko(), u && u.c(), r = ko(), yi(o.$$.fragment), X1(e, "class", "svelte-1wj0ocy"), Vl(e, "not-absolute", !/*absolute*/
      t[3]), Gl(
        e,
        "position",
        /*absolute*/
        t[3] ? "absolute" : "static"
      );
    },
    m(c, f) {
      Q1(c, e, f), a && a.m(e, null), vo(e, n), l && l.m(e, null), vo(e, i), u && u.m(e, null), vo(e, r), Ei(o, e, null), s = !0;
    },
    p(c, [f]) {
      /*editable*/
      c[0] ? a ? (a.p(c, f), f & /*editable*/
      1 && je(a, 1)) : (a = Xl(c), a.c(), je(a, 1), a.m(e, n)) : a && (yo(), lt(a, 1, 1, () => {
        a = null;
      }), wo()), /*undoable*/
      c[1] ? l ? (l.p(c, f), f & /*undoable*/
      2 && je(l, 1)) : (l = Zl(c), l.c(), je(l, 1), l.m(e, i)) : l && (yo(), lt(l, 1, 1, () => {
        l = null;
      }), wo()), /*download*/
      c[2] ? u ? (u.p(c, f), f & /*download*/
      4 && je(u, 1)) : (u = Jl(c), u.c(), je(u, 1), u.m(e, r)) : u && (yo(), lt(u, 1, 1, () => {
        u = null;
      }), wo());
      const d = {};
      f & /*i18n*/
      16 && (d.label = /*i18n*/
      c[4]("common.clear")), o.$set(d), (!s || f & /*absolute*/
      8) && Vl(e, "not-absolute", !/*absolute*/
      c[3]), f & /*absolute*/
      8 && Gl(
        e,
        "position",
        /*absolute*/
        c[3] ? "absolute" : "static"
      );
    },
    i(c) {
      s || (je(a), je(l), je(u), je(o.$$.fragment, c), s = !0);
    },
    o(c) {
      lt(a), lt(l), lt(u), lt(o.$$.fragment, c), s = !1;
    },
    d(c) {
      c && Z1(e), a && a.d(), l && l.d(), u && u.d(), ki(o);
    }
  };
}
function tg(t, e, n) {
  let { editable: i = !1 } = e, { undoable: r = !1 } = e, { download: o = null } = e, { absolute: s = !0 } = e, { i18n: a } = e;
  const l = x1(), u = () => l("edit"), c = () => l("undo"), f = (d) => {
    l("clear"), d.stopPropagation();
  };
  return t.$$set = (d) => {
    "editable" in d && n(0, i = d.editable), "undoable" in d && n(1, r = d.undoable), "download" in d && n(2, o = d.download), "absolute" in d && n(3, s = d.absolute), "i18n" in d && n(4, a = d.i18n);
  }, [
    i,
    r,
    o,
    s,
    a,
    l,
    u,
    c,
    f
  ];
}
class ec extends V1 {
  constructor(e) {
    super(), Y1(this, e, tg, eg, K1, {
      editable: 0,
      undoable: 1,
      download: 2,
      absolute: 3,
      i18n: 4
    });
  }
}
function Eo(t, e, n, i) {
  return new (n || (n = Promise))(function(r, o) {
    function s(u) {
      try {
        l(i.next(u));
      } catch (c) {
        o(c);
      }
    }
    function a(u) {
      try {
        l(i.throw(u));
      } catch (c) {
        o(c);
      }
    }
    function l(u) {
      var c;
      u.done ? r(u.value) : (c = u.value, c instanceof n ? c : new n(function(f) {
        f(c);
      })).then(s, a);
    }
    l((i = i.apply(t, e || [])).next());
  });
}
class tc {
  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 ng extends tc {
  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 ig extends tc {
  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 rg = ["audio/webm", "audio/wav", "audio/mpeg", "audio/mp4", "audio/mp3"];
class Ci extends ng {
  constructor(e) {
    var n, i, r, o, s, a;
    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, continuousWaveform: (o = e.continuousWaveform) !== null && o !== void 0 && o, renderRecordedAudio: (s = e.renderRecordedAudio) === null || s === void 0 || s, mediaRecorderTimeslice: (a = e.mediaRecorderTimeslice) !== null && a !== void 0 ? a : void 0 })), this.stream = null, this.mediaRecorder = null, this.dataWindow = null, this.isWaveformPaused = !1, this.lastStartTime = 0, this.lastDuration = 0, this.duration = 0, this.timer = new ig(), this.subscriptions.push(this.timer.on("tick", () => {
      const l = performance.now() - this.lastStartTime;
      this.duration = this.isPaused() ? this.duration : this.lastDuration + l, this.emit("record-progress", this.duration);
    }));
  }
  static create(e) {
    return new Ci(e || {});
  }
  renderMicStream(e) {
    var n;
    const i = new AudioContext(), r = i.createMediaStreamSource(e), o = i.createAnalyser();
    r.connect(o), this.options.continuousWaveform && (o.fftSize = 32);
    const s = o.frequencyBinCount, a = new Float32Array(s);
    let l = 0;
    this.wavesurfer && ((n = this.originalOptions) !== null && n !== void 0 || (this.originalOptions = Object.assign({}, this.wavesurfer.options)), this.wavesurfer.options.interact = !1, this.options.scrollingWaveform && (this.wavesurfer.options.cursorWidth = 0));
    const u = setInterval(() => {
      var c, f, d, h;
      if (!this.isWaveformPaused) {
        if (o.getFloatTimeDomainData(a), this.options.scrollingWaveform) {
          const _ = Math.floor((this.options.scrollingWaveformWindow || 0) * i.sampleRate), m = Math.min(_, this.dataWindow ? this.dataWindow.length + s : s), p = new Float32Array(_);
          if (this.dataWindow) {
            const E = Math.max(0, _ - this.dataWindow.length);
            p.set(this.dataWindow.slice(-m + s), E);
          }
          p.set(a, _ - s), this.dataWindow = p;
        } else if (this.options.continuousWaveform) {
          if (!this.dataWindow) {
            const m = this.options.continuousWaveformDuration ? Math.round(100 * this.options.continuousWaveformDuration) : ((f = (c = this.wavesurfer) === null || c === void 0 ? void 0 : c.getWidth()) !== null && f !== void 0 ? f : 0) * window.devicePixelRatio;
            this.dataWindow = new Float32Array(m);
          }
          let _ = 0;
          for (let m = 0; m < s; m++) {
            const p = Math.abs(a[m]);
            p > _ && (_ = p);
          }
          if (l + 1 > this.dataWindow.length) {
            const m = new Float32Array(2 * this.dataWindow.length);
            m.set(this.dataWindow, 0), this.dataWindow = m;
          }
          this.dataWindow[l] = _, l++;
        } else
          this.dataWindow = a;
        if (this.wavesurfer) {
          const _ = ((h = (d = this.dataWindow) === null || d === void 0 ? void 0 : d.length) !== null && h !== void 0 ? h : 0) / 100;
          this.wavesurfer.load("", [this.dataWindow], this.options.scrollingWaveform ? this.options.scrollingWaveformWindow : _).then(() => {
            this.wavesurfer && this.options.continuousWaveform && (this.wavesurfer.setTime(this.getDuration() / 1e3), this.wavesurfer.options.minPxPerSec || this.wavesurfer.setOptions({ minPxPerSec: this.wavesurfer.getWidth() / this.wavesurfer.getDuration() }));
          }).catch((m) => {
            console.error("Error rendering real-time recording data:", m);
          });
        }
      }
    }, 10);
    return { onDestroy: () => {
      clearInterval(u), r == null || r.disconnect(), i == null || i.close();
    }, onEnd: () => {
      this.isWaveformPaused = !0, clearInterval(u), this.stopMic();
    } };
  }
  startMic(e) {
    return Eo(this, void 0, void 0, function* () {
      let n;
      try {
        n = yield navigator.mediaDevices.getUserMedia({ audio: !(e != null && e.deviceId) || { deviceId: e.deviceId } });
      } catch (o) {
        throw new Error("Error accessing the microphone: " + o.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 Eo(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 || rg.find((s) => MediaRecorder.isTypeSupported(s)), audioBitsPerSecond: this.options.audioBitsPerSecond });
      this.mediaRecorder = i, this.stopRecording();
      const r = [];
      i.ondataavailable = (s) => {
        s.data.size > 0 && r.push(s.data), this.emit("record-data-available", s.data);
      };
      const o = (s) => {
        var a;
        const l = new Blob(r, { type: i.mimeType });
        this.emit(s, l), this.options.renderRecordedAudio && (this.applyOriginalOptionsIfNeeded(), (a = this.wavesurfer) === null || a === void 0 || a.load(URL.createObjectURL(l)));
      };
      i.onpause = () => o("record-pause"), i.onstop = () => o("record-end"), i.start(this.options.mediaRecorderTimeslice), 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 Eo(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.setOptions(this.originalOptions), delete this.originalOptions);
  }
}
const {
  SvelteComponent: og,
  append: nc,
  attr: Yl,
  destroy_each: sg,
  detach: Er,
  element: ms,
  empty: lg,
  ensure_array_like: Ql,
  init: ag,
  insert: Cr,
  noop: Kl,
  safe_not_equal: ug,
  set_data: ic,
  set_input_value: Jo,
  text: rc
} = window.__gradio__svelte__internal, { createEventDispatcher: cg } = window.__gradio__svelte__internal;
function xl(t, e, n) {
  const i = t.slice();
  return i[3] = e[n], i;
}
function fg(t) {
  let e, n = Ql(
    /*micDevices*/
    t[0]
  ), i = [];
  for (let r = 0; r < n.length; r += 1)
    i[r] = $l(xl(t, n, r));
  return {
    c() {
      for (let r = 0; r < i.length; r += 1)
        i[r].c();
      e = lg();
    },
    m(r, o) {
      for (let s = 0; s < i.length; s += 1)
        i[s] && i[s].m(r, o);
      Cr(r, e, o);
    },
    p(r, o) {
      if (o & /*micDevices*/
      1) {
        n = Ql(
          /*micDevices*/
          r[0]
        );
        let s;
        for (s = 0; s < n.length; s += 1) {
          const a = xl(r, n, s);
          i[s] ? i[s].p(a, o) : (i[s] = $l(a), i[s].c(), i[s].m(e.parentNode, e));
        }
        for (; s < i.length; s += 1)
          i[s].d(1);
        i.length = n.length;
      }
    },
    d(r) {
      r && Er(e), sg(i, r);
    }
  };
}
function dg(t) {
  let e, n = (
    /*i18n*/
    t[1]("audio.no_microphone") + ""
  ), i;
  return {
    c() {
      e = ms("option"), i = rc(n), e.__value = "", Jo(e, e.__value);
    },
    m(r, o) {
      Cr(r, e, o), nc(e, i);
    },
    p(r, o) {
      o & /*i18n*/
      2 && n !== (n = /*i18n*/
      r[1]("audio.no_microphone") + "") && ic(i, n);
    },
    d(r) {
      r && Er(e);
    }
  };
}
function $l(t) {
  let e, n = (
    /*micDevice*/
    t[3].label + ""
  ), i, r;
  return {
    c() {
      e = ms("option"), i = rc(n), e.__value = r = /*micDevice*/
      t[3].deviceId, Jo(e, e.__value);
    },
    m(o, s) {
      Cr(o, e, s), nc(e, i);
    },
    p(o, s) {
      s & /*micDevices*/
      1 && n !== (n = /*micDevice*/
      o[3].label + "") && ic(i, n), s & /*micDevices*/
      1 && r !== (r = /*micDevice*/
      o[3].deviceId) && (e.__value = r, Jo(e, e.__value));
    },
    d(o) {
      o && Er(e);
    }
  };
}
function hg(t) {
  let e, n;
  function i(s, a) {
    return (
      /*micDevices*/
      s[0].length === 0 ? dg : fg
    );
  }
  let r = i(t), o = r(t);
  return {
    c() {
      e = ms("select"), o.c(), Yl(e, "class", "mic-select svelte-15krn1r"), Yl(e, "aria-label", "Select input device"), e.disabled = n = /*micDevices*/
      t[0].length === 0;
    },
    m(s, a) {
      Cr(s, e, a), o.m(e, null);
    },
    p(s, [a]) {
      r === (r = i(s)) && o ? o.p(s, a) : (o.d(1), o = r(s), o && (o.c(), o.m(e, null))), a & /*micDevices*/
      1 && n !== (n = /*micDevices*/
      s[0].length === 0) && (e.disabled = n);
    },
    i: Kl,
    o: Kl,
    d(s) {
      s && Er(e), o.d();
    }
  };
}
function _g(t, e, n) {
  let { i18n: i } = e, { micDevices: r = [] } = e;
  const o = cg();
  return t.$$set = (s) => {
    "i18n" in s && n(1, i = s.i18n), "micDevices" in s && n(0, r = s.micDevices);
  }, t.$$.update = () => {
    if (t.$$.dirty & /*i18n*/
    2)
      try {
        let s = [];
        Ci.getAvailableAudioDevices().then((a) => {
          n(0, r = a), a.forEach((l) => {
            l.deviceId && s.push(l);
          }), n(0, r = s);
        });
      } catch (s) {
        throw s instanceof DOMException && s.name == "NotAllowedError" && o("error", i("audio.allow_recording_access")), s;
      }
  }, [r, i];
}
class oc extends og {
  constructor(e) {
    super(), ag(this, e, _g, hg, ug, { i18n: 1, micDevices: 0 });
  }
}
const {
  SvelteComponent: mg,
  add_flush_callback: pg,
  append: Ee,
  attr: st,
  bind: gg,
  binding_callbacks: Dn,
  create_component: ea,
  destroy_component: ta,
  detach: sc,
  element: Ot,
  init: bg,
  insert: lc,
  listen: ri,
  mount_component: na,
  run_all: vg,
  safe_not_equal: wg,
  set_data: ci,
  space: An,
  text: fi,
  transition_in: ia,
  transition_out: ra
} = window.__gradio__svelte__internal;
function oa(t) {
  let e, n;
  return {
    c() {
      e = Ot("time"), n = fi(
        /*record_time*/
        t[2]
      ), st(e, "class", "duration-button duration svelte-1czhgji");
    },
    m(i, r) {
      lc(i, e, r), Ee(e, n);
    },
    p(i, r) {
      r & /*record_time*/
      4 && ci(
        n,
        /*record_time*/
        i[2]
      );
    },
    d(i) {
      i && sc(e);
    }
  };
}
function yg(t) {
  let e, n, i, r = (
    /*i18n*/
    t[1]("audio.record") + ""
  ), o, s, a, l = (
    /*i18n*/
    t[1]("audio.stop") + ""
  ), u, c, f, d, h = (
    /*i18n*/
    t[1]("audio.stop") + ""
  ), _, m, p, E, w, g, b = (
    /*i18n*/
    t[1]("audio.resume") + ""
  ), T, C, M, A, P, D, W, j;
  E = new Ga({});
  let U = (
    /*timing*/
    t[4] && !/*show_recording_waveform*/
    t[3] && oa(t)
  );
  function oe(O) {
    t[21](O);
  }
  let B = { i18n: (
    /*i18n*/
    t[1]
  ) };
  return (
    /*micDevices*/
    t[5] !== void 0 && (B.micDevices = /*micDevices*/
    t[5]), A = new oc({ props: B }), Dn.push(() => gg(A, "micDevices", oe)), {
      c() {
        e = Ot("div"), n = Ot("div"), i = Ot("button"), o = fi(r), s = An(), a = Ot("button"), u = fi(l), f = An(), d = Ot("button"), _ = fi(h), m = An(), p = Ot("button"), ea(E.$$.fragment), w = An(), g = Ot("button"), T = fi(b), C = An(), U && U.c(), M = An(), ea(A.$$.fragment), st(i, "class", "record record-button svelte-1czhgji"), st(a, "class", c = "stop-button " + /*record*/
        (t[0].isPaused() ? "stop-button-paused" : "") + " svelte-1czhgji"), st(d, "id", "stop-paused"), st(d, "class", "stop-button-paused svelte-1czhgji"), st(p, "aria-label", "pause"), st(p, "class", "pause-button svelte-1czhgji"), st(g, "class", "resume-button svelte-1czhgji"), st(n, "class", "wrapper svelte-1czhgji"), st(e, "class", "controls svelte-1czhgji");
      },
      m(O, X) {
        lc(O, e, X), Ee(e, n), Ee(n, i), Ee(i, o), t[11](i), Ee(n, s), Ee(n, a), Ee(a, u), t[13](a), Ee(n, f), Ee(n, d), Ee(d, _), t[15](d), Ee(n, m), Ee(n, p), na(E, p, null), t[17](p), Ee(n, w), Ee(n, g), Ee(g, T), t[19](g), Ee(n, C), U && U.m(n, null), Ee(e, M), na(A, e, null), D = !0, W || (j = [
          ri(
            i,
            "click",
            /*click_handler*/
            t[12]
          ),
          ri(
            a,
            "click",
            /*click_handler_1*/
            t[14]
          ),
          ri(
            d,
            "click",
            /*click_handler_2*/
            t[16]
          ),
          ri(
            p,
            "click",
            /*click_handler_3*/
            t[18]
          ),
          ri(
            g,
            "click",
            /*click_handler_4*/
            t[20]
          )
        ], W = !0);
      },
      p(O, [X]) {
        (!D || X & /*i18n*/
        2) && r !== (r = /*i18n*/
        O[1]("audio.record") + "") && ci(o, r), (!D || X & /*i18n*/
        2) && l !== (l = /*i18n*/
        O[1]("audio.stop") + "") && ci(u, l), (!D || X & /*record*/
        1 && c !== (c = "stop-button " + /*record*/
        (O[0].isPaused() ? "stop-button-paused" : "") + " svelte-1czhgji")) && st(a, "class", c), (!D || X & /*i18n*/
        2) && h !== (h = /*i18n*/
        O[1]("audio.stop") + "") && ci(_, h), (!D || X & /*i18n*/
        2) && b !== (b = /*i18n*/
        O[1]("audio.resume") + "") && ci(T, b), /*timing*/
        O[4] && !/*show_recording_waveform*/
        O[3] ? U ? U.p(O, X) : (U = oa(O), U.c(), U.m(n, null)) : U && (U.d(1), U = null);
        const le = {};
        X & /*i18n*/
        2 && (le.i18n = /*i18n*/
        O[1]), !P && X & /*micDevices*/
        32 && (P = !0, le.micDevices = /*micDevices*/
        O[5], pg(() => P = !1)), A.$set(le);
      },
      i(O) {
        D || (ia(E.$$.fragment, O), ia(A.$$.fragment, O), D = !0);
      },
      o(O) {
        ra(E.$$.fragment, O), ra(A.$$.fragment, O), D = !1;
      },
      d(O) {
        O && sc(e), t[11](null), t[13](null), t[15](null), ta(E), t[17](null), t[19](null), U && U.d(), ta(A), W = !1, vg(j);
      }
    }
  );
}
function kg(t, e, n) {
  let { record: i } = e, { i18n: r } = e, o = [], s, a, l, u, c, { record_time: f } = e, { show_recording_waveform: d } = e, { timing: h = !1 } = e;
  function _(P) {
    Dn[P ? "unshift" : "push"](() => {
      s = P, n(6, s), n(0, i);
    });
  }
  const m = () => i.startRecording();
  function p(P) {
    Dn[P ? "unshift" : "push"](() => {
      u = P, n(9, u), n(0, i);
    });
  }
  const E = () => {
    i.isPaused() && (i.resumeRecording(), i.stopRecording()), i.stopRecording();
  };
  function w(P) {
    Dn[P ? "unshift" : "push"](() => {
      c = P, n(10, c), n(0, i);
    });
  }
  const g = () => {
    i.isPaused() && (i.resumeRecording(), i.stopRecording()), i.stopRecording();
  };
  function b(P) {
    Dn[P ? "unshift" : "push"](() => {
      a = P, n(7, a), n(0, i);
    });
  }
  const T = () => i.pauseRecording();
  function C(P) {
    Dn[P ? "unshift" : "push"](() => {
      l = P, n(8, l), n(0, i);
    });
  }
  const M = () => i.resumeRecording();
  function A(P) {
    o = P, n(5, o);
  }
  return t.$$set = (P) => {
    "record" in P && n(0, i = P.record), "i18n" in P && n(1, r = P.i18n), "record_time" in P && n(2, f = P.record_time), "show_recording_waveform" in P && n(3, d = P.show_recording_waveform), "timing" in P && n(4, h = P.timing);
  }, t.$$.update = () => {
    t.$$.dirty & /*record*/
    1 && i.on("record-start", () => {
      i.startMic(), n(6, s.style.display = "none", s), n(9, u.style.display = "flex", u), n(7, a.style.display = "block", a);
    }), t.$$.dirty & /*record*/
    1 && i.on("record-end", () => {
      i.isPaused() && (i.resumeRecording(), i.stopRecording()), i.stopMic(), n(6, s.style.display = "flex", s), n(9, u.style.display = "none", u), n(7, a.style.display = "none", a), n(6, s.disabled = !1, s);
    }), t.$$.dirty & /*record*/
    1 && i.on("record-pause", () => {
      n(7, a.style.display = "none", a), n(8, l.style.display = "block", l), n(9, u.style.display = "none", u), n(10, c.style.display = "flex", c);
    }), t.$$.dirty & /*record*/
    1 && i.on("record-resume", () => {
      n(7, a.style.display = "block", a), n(8, l.style.display = "none", l), n(6, s.style.display = "none", s), n(9, u.style.display = "flex", u), n(10, c.style.display = "none", c);
    });
  }, [
    i,
    r,
    f,
    d,
    h,
    o,
    s,
    a,
    l,
    u,
    c,
    _,
    m,
    p,
    E,
    w,
    g,
    b,
    T,
    C,
    M,
    A
  ];
}
class Eg extends mg {
  constructor(e) {
    super(), bg(this, e, kg, yg, wg, {
      record: 0,
      i18n: 1,
      record_time: 2,
      show_recording_waveform: 3,
      timing: 4
    });
  }
}
const {
  SvelteComponent: Cg,
  add_flush_callback: Zi,
  append: Ke,
  attr: vt,
  bind: Ji,
  binding_callbacks: It,
  check_outros: sa,
  create_component: ac,
  destroy_component: uc,
  detach: Si,
  element: yt,
  group_outros: la,
  init: Sg,
  insert: Ai,
  mount_component: cc,
  noop: Ag,
  safe_not_equal: Tg,
  set_data: fc,
  space: Ln,
  text: dc,
  transition_in: Nt,
  transition_out: Bn
} = window.__gradio__svelte__internal, { onMount: Pg } = window.__gradio__svelte__internal, { createEventDispatcher: Dg } = window.__gradio__svelte__internal;
function aa(t) {
  let e, n, i, r, o, s = (
    /*mode*/
    t[0] === "edit" && /*trimDuration*/
    t[16] > 0 && ua(t)
  );
  function a(c, f) {
    return (
      /*timing*/
      c[15] ? Rg : Mg
    );
  }
  let l = a(t), u = l(t);
  return {
    c() {
      e = yt("div"), n = yt("time"), n.textContent = "0:00", i = Ln(), r = yt("div"), s && s.c(), o = Ln(), u.c(), vt(n, "class", "time svelte-1z0uz8p"), vt(e, "class", "timestamps svelte-1z0uz8p");
    },
    m(c, f) {
      Ai(c, e, f), Ke(e, n), t[23](n), Ke(e, i), Ke(e, r), s && s.m(r, null), Ke(r, o), u.m(r, null);
    },
    p(c, f) {
      /*mode*/
      c[0] === "edit" && /*trimDuration*/
      c[16] > 0 ? s ? s.p(c, f) : (s = ua(c), s.c(), s.m(r, o)) : s && (s.d(1), s = null), l === (l = a(c)) && u ? u.p(c, f) : (u.d(1), u = l(c), u && (u.c(), u.m(r, null)));
    },
    d(c) {
      c && Si(e), t[23](null), s && s.d(), u.d();
    }
  };
}
function ua(t) {
  let e, n = xe(
    /*trimDuration*/
    t[16]
  ) + "", i;
  return {
    c() {
      e = yt("time"), i = dc(n), vt(e, "class", "trim-duration svelte-1z0uz8p");
    },
    m(r, o) {
      Ai(r, e, o), Ke(e, i);
    },
    p(r, o) {
      o[0] & /*trimDuration*/
      65536 && n !== (n = xe(
        /*trimDuration*/
        r[16]
      ) + "") && fc(i, n);
    },
    d(r) {
      r && Si(e);
    }
  };
}
function Mg(t) {
  let e;
  return {
    c() {
      e = yt("time"), e.textContent = "0:00", vt(e, "class", "duration svelte-1z0uz8p");
    },
    m(n, i) {
      Ai(n, e, i), t[24](e);
    },
    p: Ag,
    d(n) {
      n && Si(e), t[24](null);
    }
  };
}
function Rg(t) {
  let e, n = xe(
    /*seconds*/
    t[14]
  ) + "", i;
  return {
    c() {
      e = yt("time"), i = dc(n), vt(e, "class", "duration svelte-1z0uz8p");
    },
    m(r, o) {
      Ai(r, e, o), Ke(e, i);
    },
    p(r, o) {
      o[0] & /*seconds*/
      16384 && n !== (n = xe(
        /*seconds*/
        r[14]
      ) + "") && fc(i, n);
    },
    d(r) {
      r && Si(e);
    }
  };
}
function ca(t) {
  let e, n, i;
  function r(s) {
    t[25](s);
  }
  let o = {
    i18n: (
      /*i18n*/
      t[1]
    ),
    timing: (
      /*timing*/
      t[15]
    ),
    show_recording_waveform: (
      /*waveform_options*/
      t[2].show_recording_waveform
    ),
    record_time: xe(
      /*seconds*/
      t[14]
    )
  };
  return (
    /*record*/
    t[8] !== void 0 && (o.record = /*record*/
    t[8]), e = new Eg({ props: o }), It.push(() => Ji(e, "record", r)), {
      c() {
        ac(e.$$.fragment);
      },
      m(s, a) {
        cc(e, s, a), i = !0;
      },
      p(s, a) {
        const l = {};
        a[0] & /*i18n*/
        2 && (l.i18n = /*i18n*/
        s[1]), a[0] & /*timing*/
        32768 && (l.timing = /*timing*/
        s[15]), a[0] & /*waveform_options*/
        4 && (l.show_recording_waveform = /*waveform_options*/
        s[2].show_recording_waveform), a[0] & /*seconds*/
        16384 && (l.record_time = xe(
          /*seconds*/
          s[14]
        )), !n && a[0] & /*record*/
        256 && (n = !0, l.record = /*record*/
        s[8], Zi(() => n = !1)), e.$set(l);
      },
      i(s) {
        i || (Nt(e.$$.fragment, s), i = !0);
      },
      o(s) {
        Bn(e.$$.fragment, s), i = !1;
      },
      d(s) {
        uc(e, s);
      }
    }
  );
}
function fa(t) {
  let e, n, i, r, o;
  function s(c) {
    t[26](c);
  }
  function a(c) {
    t[27](c);
  }
  function l(c) {
    t[28](c);
  }
  let u = {
    container: (
      /*recordingContainer*/
      t[6]
    ),
    playing: (
      /*playing*/
      t[12]
    ),
    audio_duration: (
      /*audio_duration*/
      t[13]
    ),
    i18n: (
      /*i18n*/
      t[1]
    ),
    editable: (
      /*editable*/
      t[4]
    ),
    interactive: !0,
    handle_trim_audio: (
      /*handle_trim_audio*/
      t[17]
    ),
    show_redo: !0,
    handle_reset_value: (
      /*handle_reset_value*/
      t[3]
    ),
    waveform_options: (
      /*waveform_options*/
      t[2]
    )
  };
  return (
    /*recordingWaveform*/
    t[5] !== void 0 && (u.waveform = /*recordingWaveform*/
    t[5]), /*trimDuration*/
    t[16] !== void 0 && (u.trimDuration = /*trimDuration*/
    t[16]), /*mode*/
    t[0] !== void 0 && (u.mode = /*mode*/
    t[0]), e = new eu({ props: u }), It.push(() => Ji(e, "waveform", s)), It.push(() => Ji(e, "trimDuration", a)), It.push(() => Ji(e, "mode", l)), {
      c() {
        ac(e.$$.fragment);
      },
      m(c, f) {
        cc(e, c, f), o = !0;
      },
      p(c, f) {
        const d = {};
        f[0] & /*recordingContainer*/
        64 && (d.container = /*recordingContainer*/
        c[6]), f[0] & /*playing*/
        4096 && (d.playing = /*playing*/
        c[12]), f[0] & /*audio_duration*/
        8192 && (d.audio_duration = /*audio_duration*/
        c[13]), f[0] & /*i18n*/
        2 && (d.i18n = /*i18n*/
        c[1]), f[0] & /*editable*/
        16 && (d.editable = /*editable*/
        c[4]), f[0] & /*handle_reset_value*/
        8 && (d.handle_reset_value = /*handle_reset_value*/
        c[3]), f[0] & /*waveform_options*/
        4 && (d.waveform_options = /*waveform_options*/
        c[2]), !n && f[0] & /*recordingWaveform*/
        32 && (n = !0, d.waveform = /*recordingWaveform*/
        c[5], Zi(() => n = !1)), !i && f[0] & /*trimDuration*/
        65536 && (i = !0, d.trimDuration = /*trimDuration*/
        c[16], Zi(() => i = !1)), !r && f[0] & /*mode*/
        1 && (r = !0, d.mode = /*mode*/
        c[0], Zi(() => r = !1)), e.$set(d);
      },
      i(c) {
        o || (Nt(e.$$.fragment, c), o = !0);
      },
      o(c) {
        Bn(e.$$.fragment, c), o = !1;
      },
      d(c) {
        uc(e, c);
      }
    }
  );
}
function Lg(t) {
  let e, n, i, r, o, s, a, l, u = (
    /*timing*/
    (t[15] || /*recordedAudio*/
    t[9]) && /*waveform_options*/
    t[2].show_recording_waveform && aa(t)
  ), c = (
    /*microphoneContainer*/
    t[7] && !/*recordedAudio*/
    t[9] && ca(t)
  ), f = (
    /*recordingWaveform*/
    t[5] && /*recordedAudio*/
    t[9] && fa(t)
  );
  return {
    c() {
      e = yt("div"), n = yt("div"), i = Ln(), r = yt("div"), o = Ln(), u && u.c(), s = Ln(), c && c.c(), a = Ln(), f && f.c(), vt(n, "class", "microphone svelte-1z0uz8p"), vt(n, "data-testid", "microphone-waveform"), vt(r, "data-testid", "recording-waveform"), vt(e, "class", "component-wrapper svelte-1z0uz8p");
    },
    m(d, h) {
      Ai(d, e, h), Ke(e, n), t[21](n), Ke(e, i), Ke(e, r), t[22](r), Ke(e, o), u && u.m(e, null), Ke(e, s), c && c.m(e, null), Ke(e, a), f && f.m(e, null), l = !0;
    },
    p(d, h) {
      /*timing*/
      (d[15] || /*recordedAudio*/
      d[9]) && /*waveform_options*/
      d[2].show_recording_waveform ? u ? u.p(d, h) : (u = aa(d), u.c(), u.m(e, s)) : u && (u.d(1), u = null), /*microphoneContainer*/
      d[7] && !/*recordedAudio*/
      d[9] ? c ? (c.p(d, h), h[0] & /*microphoneContainer, recordedAudio*/
      640 && Nt(c, 1)) : (c = ca(d), c.c(), Nt(c, 1), c.m(e, a)) : c && (la(), Bn(c, 1, 1, () => {
        c = null;
      }), sa()), /*recordingWaveform*/
      d[5] && /*recordedAudio*/
      d[9] ? f ? (f.p(d, h), h[0] & /*recordingWaveform, recordedAudio*/
      544 && Nt(f, 1)) : (f = fa(d), f.c(), Nt(f, 1), f.m(e, null)) : f && (la(), Bn(f, 1, 1, () => {
        f = null;
      }), sa());
    },
    i(d) {
      l || (Nt(c), Nt(f), l = !0);
    },
    o(d) {
      Bn(c), Bn(f), l = !1;
    },
    d(d) {
      d && Si(e), t[21](null), t[22](null), u && u.d(), c && c.d(), f && f.d();
    }
  };
}
function dt(t) {
  let e, n = t[0], i = 1;
  for (; i < t.length; ) {
    const r = t[i], o = t[i + 1];
    if (i += 2, (r === "optionalAccess" || r === "optionalCall") && n == null)
      return;
    r === "access" || r === "optionalAccess" ? (e = n, n = o(n)) : (r === "call" || r === "optionalCall") && (n = o((...s) => n.call(e, ...s)), e = void 0);
  }
  return n;
}
function Bg(t, e, n) {
  let { mode: i } = e, { i18n: r } = e, { dispatch_blob: o } = e, { waveform_settings: s } = e, { waveform_options: a = { show_recording_waveform: !0 } } = e, { handle_reset_value: l } = e, { editable: u = !0 } = e, c, f, d = !1, h, _, m, p = null, E, w, g, b = 0, T, C = !1, M = 0;
  const A = () => {
    clearInterval(T), n(20, T = setInterval(
      () => {
        n(14, b++, b);
      },
      1e3
    ));
  }, P = Dg(), D = () => {
    _ && n(7, _.innerHTML = "", _), c !== void 0 && c.destroy(), _ && (c = qt.create({
      ...s,
      normalize: !1,
      container: _
    }), n(8, m = c.registerPlugin(Ci.create())), m.startMic());
  }, W = () => {
    let y = h;
    !p || !y || n(5, f = qt.create({
      container: y,
      url: p,
      ...s
    }));
  }, j = async (y, N) => {
    n(0, i = "edit");
    const S = f.getDecodedData();
    S && await Xs(S, y, N).then(async (k) => {
      await o([k], "change"), await o([k], "stop_recording"), f.destroy(), W();
    }), P("edit");
  };
  Pg(() => {
    D(), window.addEventListener("keydown", (y) => {
      y.key === "ArrowRight" ? Ki(f, 0.1) : y.key === "ArrowLeft" && Ki(f, -0.1);
    });
  });
  function U(y) {
    It[y ? "unshift" : "push"](() => {
      _ = y, n(7, _);
    });
  }
  function oe(y) {
    It[y ? "unshift" : "push"](() => {
      h = y, n(6, h);
    });
  }
  function B(y) {
    It[y ? "unshift" : "push"](() => {
      E = y, n(10, E), n(5, f);
    });
  }
  function O(y) {
    It[y ? "unshift" : "push"](() => {
      w = y, n(11, w), n(5, f);
    });
  }
  function X(y) {
    m = y, n(8, m);
  }
  function le(y) {
    f = y, n(5, f);
  }
  function J(y) {
    M = y, n(16, M);
  }
  function v(y) {
    i = y, n(0, i);
  }
  return t.$$set = (y) => {
    "mode" in y && n(0, i = y.mode), "i18n" in y && n(1, r = y.i18n), "dispatch_blob" in y && n(18, o = y.dispatch_blob), "waveform_settings" in y && n(19, s = y.waveform_settings), "waveform_options" in y && n(2, a = y.waveform_options), "handle_reset_value" in y && n(3, l = y.handle_reset_value), "editable" in y && n(4, u = y.editable);
  }, t.$$.update = () => {
    t.$$.dirty[0] & /*record, waveform_options, microphoneContainer*/
    388 && dt([
      m,
      "optionalAccess",
      (y) => y.on,
      "call",
      (y) => y("record-start", () => {
        if (A(), n(15, C = !0), P("start_recording"), a.show_recording_waveform) {
          let N = _;
          N && (N.style.display = "block");
        }
      })
    ]), t.$$.dirty[0] & /*record, interval, waveform_settings, dispatch_blob*/
    1835264 && dt([
      m,
      "optionalAccess",
      (y) => y.on,
      "call",
      (y) => y("record-end", async (N) => {
        n(14, b = 0), n(15, C = !1), clearInterval(T);
        try {
          const S = await N.arrayBuffer(), z = await new AudioContext({ sampleRate: s.sampleRate }).decodeAudioData(S);
          z && await Xs(z).then(async (V) => {
            await o([V], "change"), await o([V], "stop_recording");
          });
        } catch (S) {
          console.error(S);
        }
      })
    ]), t.$$.dirty[0] & /*record, interval*/
    1048832 && dt([
      m,
      "optionalAccess",
      (y) => y.on,
      "call",
      (y) => y("record-pause", () => {
        P("pause_recording"), clearInterval(T);
      })
    ]), t.$$.dirty[0] & /*record*/
    256 && dt([
      m,
      "optionalAccess",
      (y) => y.on,
      "call",
      (y) => y("record-resume", () => {
        A();
      })
    ]), t.$$.dirty[0] & /*recordingWaveform, durationRef*/
    2080 && dt([
      f,
      "optionalAccess",
      (y) => y.on,
      "call",
      (y) => y("decode", (N) => {
        n(13, g = N), w && n(11, w.textContent = xe(N), w);
      })
    ]), t.$$.dirty[0] & /*recordingWaveform, timeRef*/
    1056 && dt([
      f,
      "optionalAccess",
      (y) => y.on,
      "call",
      (y) => y("timeupdate", (N) => E && n(10, E.textContent = xe(N), E))
    ]), t.$$.dirty[0] & /*recordingWaveform*/
    32 && dt([
      f,
      "optionalAccess",
      (y) => y.on,
      "call",
      (y) => y("pause", () => {
        P("pause"), n(12, d = !1);
      })
    ]), t.$$.dirty[0] & /*recordingWaveform*/
    32 && dt([
      f,
      "optionalAccess",
      (y) => y.on,
      "call",
      (y) => y("play", () => {
        P("play"), n(12, d = !0);
      })
    ]), t.$$.dirty[0] & /*recordingWaveform*/
    32 && dt([
      f,
      "optionalAccess",
      (y) => y.on,
      "call",
      (y) => y("finish", () => {
        P("stop"), n(12, d = !1);
      })
    ]), t.$$.dirty[0] & /*record, microphoneContainer, recordingContainer, recordedAudio*/
    960 && dt([
      m,
      "optionalAccess",
      (y) => y.on,
      "call",
      (y) => y("record-end", (N) => {
        n(9, p = URL.createObjectURL(N));
        const S = _, k = h;
        S && (S.style.display = "none"), k && p && (k.innerHTML = "", W());
      })
    ]);
  }, [
    i,
    r,
    a,
    l,
    u,
    f,
    h,
    _,
    m,
    p,
    E,
    w,
    d,
    g,
    b,
    C,
    M,
    j,
    o,
    s,
    T,
    U,
    oe,
    B,
    O,
    X,
    le,
    J,
    v
  ];
}
class Og extends Cg {
  constructor(e) {
    super(), Sg(
      this,
      e,
      Bg,
      Lg,
      Tg,
      {
        mode: 0,
        i18n: 1,
        dispatch_blob: 18,
        waveform_settings: 19,
        waveform_options: 2,
        handle_reset_value: 3,
        editable: 4
      },
      null,
      [-1, -1]
    );
  }
}
const {
  SvelteComponent: Ng,
  add_flush_callback: Hg,
  append: kt,
  attr: ln,
  bind: Ig,
  binding_callbacks: hc,
  create_component: Ug,
  destroy_component: jg,
  detach: Sr,
  element: dn,
  init: zg,
  insert: Ar,
  listen: _c,
  mount_component: Fg,
  null_to_empty: da,
  safe_not_equal: qg,
  set_data: mc,
  set_style: ha,
  space: sr,
  text: pc,
  transition_in: Wg,
  transition_out: Gg
} = window.__gradio__svelte__internal, { onMount: Vg } = window.__gradio__svelte__internal;
function _a(t) {
  let e;
  return {
    c() {
      e = dn("div"), ha(
        e,
        "display",
        /*recording*/
        t[0] ? "block" : "none"
      );
    },
    m(n, i) {
      Ar(n, e, i), t[10](e);
    },
    p(n, i) {
      i & /*recording*/
      1 && ha(
        e,
        "display",
        /*recording*/
        n[0] ? "block" : "none"
      );
    },
    d(n) {
      n && Sr(e), t[10](null);
    }
  };
}
function Xg(t) {
  let e, n, i, r = (
    /*i18n*/
    t[4]("audio.record") + ""
  ), o, s, a;
  return {
    c() {
      e = dn("button"), n = dn("span"), n.innerHTML = '<span class="dot"></span>', i = sr(), o = pc(r), ln(n, "class", "record-icon"), ln(e, "class", "record-button svelte-4em7wf");
    },
    m(l, u) {
      Ar(l, e, u), kt(e, n), kt(e, i), kt(e, o), s || (a = _c(
        e,
        "click",
        /*click_handler_1*/
        t[12]
      ), s = !0);
    },
    p(l, u) {
      u & /*i18n*/
      16 && r !== (r = /*i18n*/
      l[4]("audio.record") + "") && mc(o, r);
    },
    d(l) {
      l && Sr(e), s = !1, a();
    }
  };
}
function Zg(t) {
  let e, n, i, r = (
    /*paused_recording*/
    (t[1] ? (
      /*i18n*/
      t[4]("audio.pause")
    ) : (
      /*i18n*/
      t[4]("audio.stop")
    )) + ""
  ), o, s, a, l;
  return {
    c() {
      e = dn("button"), n = dn("span"), n.innerHTML = '<span class="pinger"></span> <span class="dot"></span>', i = sr(), o = pc(r), ln(n, "class", "record-icon"), ln(e, "class", s = da(
        /*paused_recording*/
        t[1] ? "stop-button-paused" : "stop-button"
      ) + " svelte-4em7wf");
    },
    m(u, c) {
      Ar(u, e, c), kt(e, n), kt(e, i), kt(e, o), a || (l = _c(
        e,
        "click",
        /*click_handler*/
        t[11]
      ), a = !0);
    },
    p(u, c) {
      c & /*paused_recording, i18n*/
      18 && r !== (r = /*paused_recording*/
      (u[1] ? (
        /*i18n*/
        u[4]("audio.pause")
      ) : (
        /*i18n*/
        u[4]("audio.stop")
      )) + "") && mc(o, r), c & /*paused_recording*/
      2 && s !== (s = da(
        /*paused_recording*/
        u[1] ? "stop-button-paused" : "stop-button"
      ) + " svelte-4em7wf") && ln(e, "class", s);
    },
    d(u) {
      u && Sr(e), a = !1, l();
    }
  };
}
function Jg(t) {
  let e, n, i, r, o, s, a, l = (
    /*waveform_options*/
    t[5].show_recording_waveform && _a(t)
  );
  function u(_, m) {
    return (
      /*recording*/
      _[0] ? Zg : Xg
    );
  }
  let c = u(t), f = c(t);
  function d(_) {
    t[13](_);
  }
  let h = { i18n: (
    /*i18n*/
    t[4]
  ) };
  return (
    /*micDevices*/
    t[8] !== void 0 && (h.micDevices = /*micDevices*/
    t[8]), o = new oc({ props: h }), hc.push(() => Ig(o, "micDevices", d)), {
      c() {
        e = dn("div"), l && l.c(), n = sr(), i = dn("div"), f.c(), r = sr(), Ug(o.$$.fragment), ln(i, "class", "controls svelte-4em7wf"), ln(e, "class", "mic-wrap svelte-4em7wf");
      },
      m(_, m) {
        Ar(_, e, m), l && l.m(e, null), kt(e, n), kt(e, i), f.m(i, null), kt(i, r), Fg(o, i, null), a = !0;
      },
      p(_, [m]) {
        /*waveform_options*/
        _[5].show_recording_waveform ? l ? l.p(_, m) : (l = _a(_), l.c(), l.m(e, n)) : l && (l.d(1), l = null), c === (c = u(_)) && f ? f.p(_, m) : (f.d(1), f = c(_), f && (f.c(), f.m(i, r)));
        const p = {};
        m & /*i18n*/
        16 && (p.i18n = /*i18n*/
        _[4]), !s && m & /*micDevices*/
        256 && (s = !0, p.micDevices = /*micDevices*/
        _[8], Hg(() => s = !1)), o.$set(p);
      },
      i(_) {
        a || (Wg(o.$$.fragment, _), a = !0);
      },
      o(_) {
        Gg(o.$$.fragment, _), a = !1;
      },
      d(_) {
        _ && Sr(e), l && l.d(), f.d(), jg(o);
      }
    }
  );
}
function Yg(t, e, n) {
  let { recording: i = !1 } = e, { paused_recording: r = !1 } = e, { stop: o } = e, { record: s } = e, { i18n: a } = e, { waveform_settings: l } = e, { waveform_options: u = { show_recording_waveform: !0 } } = e, c, f, d, h = [];
  Vg(() => {
    _();
  });
  const _ = () => {
    c !== void 0 && c.destroy(), d && (c = qt.create({
      ...l,
      height: 100,
      container: d
    }), n(6, f = c.registerPlugin(Ci.create())));
  };
  function m(g) {
    hc[g ? "unshift" : "push"](() => {
      d = g, n(7, d);
    });
  }
  const p = () => {
    f == null || f.stopMic(), o();
  }, E = () => {
    f == null || f.startMic(), s();
  };
  function w(g) {
    h = g, n(8, h);
  }
  return t.$$set = (g) => {
    "recording" in g && n(0, i = g.recording), "paused_recording" in g && n(1, r = g.paused_recording), "stop" in g && n(2, o = g.stop), "record" in g && n(3, s = g.record), "i18n" in g && n(4, a = g.i18n), "waveform_settings" in g && n(9, l = g.waveform_settings), "waveform_options" in g && n(5, u = g.waveform_options);
  }, [
    i,
    r,
    o,
    s,
    a,
    u,
    f,
    d,
    h,
    l,
    m,
    p,
    E,
    w
  ];
}
class Qg extends Ng {
  constructor(e) {
    super(), zg(this, e, Yg, Jg, qg, {
      recording: 0,
      paused_recording: 1,
      stop: 2,
      record: 3,
      i18n: 4,
      waveform_settings: 9,
      waveform_options: 5
    });
  }
}
const {
  SvelteComponent: Kg,
  add_flush_callback: Tr,
  append: xg,
  attr: $g,
  bind: Pr,
  binding_callbacks: Dr,
  bubble: Kt,
  check_outros: ps,
  create_component: Wt,
  create_slot: eb,
  destroy_component: Gt,
  detach: qn,
  element: tb,
  empty: gc,
  get_all_dirty_from_scope: nb,
  get_slot_changes: ib,
  group_outros: gs,
  init: rb,
  insert: Wn,
  mount_component: Vt,
  safe_not_equal: ob,
  space: lr,
  transition_in: Ne,
  transition_out: He,
  update_slot_base: sb
} = window.__gradio__svelte__internal, { getContext: lb, onDestroy: ab, createEventDispatcher: ub } = window.__gradio__svelte__internal;
function cb(t) {
  let e, n, i, r, o;
  e = new ec({
    props: {
      i18n: (
        /*i18n*/
        t[9]
      ),
      download: (
        /*show_download_button*/
        t[6] ? (
          /*value*/
          t[1].audio_file.url
        ) : null
      ),
      absolute: !0
    }
  }), e.$on(
    "clear",
    /*clear*/
    t[19]
  ), e.$on(
    "edit",
    /*edit_handler_1*/
    t[33]
  );
  function s(l) {
    t[34](l);
  }
  let a = {
    value: (
      /*value*/
      t[1]
    ),
    label: (
      /*label*/
      t[3]
    ),
    root: (
      /*root*/
      t[4]
    ),
    i18n: (
      /*i18n*/
      t[9]
    ),
    waveform_settings: (
      /*waveform_settings*/
      t[10]
    ),
    waveform_options: (
      /*waveform_options*/
      t[11]
    ),
    handle_reset_value: (
      /*handle_reset_value*/
      t[12]
    ),
    editable: (
      /*editable*/
      t[13]
    ),
    interactive: !0
  };
  return (
    /*mode*/
    t[15] !== void 0 && (a.mode = /*mode*/
    t[15]), i = new ru({ props: a }), Dr.push(() => Pr(i, "mode", s)), i.$on(
      "stop",
      /*stop_handler*/
      t[35]
    ), i.$on(
      "play",
      /*play_handler*/
      t[36]
    ), i.$on(
      "pause",
      /*pause_handler*/
      t[37]
    ), i.$on(
      "edit",
      /*edit_handler*/
      t[38]
    ), {
      c() {
        Wt(e.$$.fragment), n = lr(), Wt(i.$$.fragment);
      },
      m(l, u) {
        Vt(e, l, u), Wn(l, n, u), Vt(i, l, u), o = !0;
      },
      p(l, u) {
        const c = {};
        u[0] & /*i18n*/
        512 && (c.i18n = /*i18n*/
        l[9]), u[0] & /*show_download_button, value*/
        66 && (c.download = /*show_download_button*/
        l[6] ? (
          /*value*/
          l[1].audio_file.url
        ) : null), e.$set(c);
        const f = {};
        u[0] & /*value*/
        2 && (f.value = /*value*/
        l[1]), u[0] & /*label*/
        8 && (f.label = /*label*/
        l[3]), u[0] & /*root*/
        16 && (f.root = /*root*/
        l[4]), u[0] & /*i18n*/
        512 && (f.i18n = /*i18n*/
        l[9]), u[0] & /*waveform_settings*/
        1024 && (f.waveform_settings = /*waveform_settings*/
        l[10]), u[0] & /*waveform_options*/
        2048 && (f.waveform_options = /*waveform_options*/
        l[11]), u[0] & /*handle_reset_value*/
        4096 && (f.handle_reset_value = /*handle_reset_value*/
        l[12]), u[0] & /*editable*/
        8192 && (f.editable = /*editable*/
        l[13]), !r && u[0] & /*mode*/
        32768 && (r = !0, f.mode = /*mode*/
        l[15], Tr(() => r = !1)), i.$set(f);
      },
      i(l) {
        o || (Ne(e.$$.fragment, l), Ne(i.$$.fragment, l), o = !0);
      },
      o(l) {
        He(e.$$.fragment, l), He(i.$$.fragment, l), o = !1;
      },
      d(l) {
        l && qn(n), Gt(e, l), Gt(i, l);
      }
    }
  );
}
function fb(t) {
  let e, n, i, r;
  const o = [hb, db], s = [];
  function a(l, u) {
    return (
      /*active_source*/
      l[2] === "microphone" ? 0 : (
        /*active_source*/
        l[2] === "upload" ? 1 : -1
      )
    );
  }
  return ~(e = a(t)) && (n = s[e] = o[e](t)), {
    c() {
      n && n.c(), i = gc();
    },
    m(l, u) {
      ~e && s[e].m(l, u), Wn(l, i, u), r = !0;
    },
    p(l, u) {
      let c = e;
      e = a(l), e === c ? ~e && s[e].p(l, u) : (n && (gs(), He(s[c], 1, 1, () => {
        s[c] = null;
      }), ps()), ~e ? (n = s[e], n ? n.p(l, u) : (n = s[e] = o[e](l), n.c()), Ne(n, 1), n.m(i.parentNode, i)) : n = null);
    },
    i(l) {
      r || (Ne(n), r = !0);
    },
    o(l) {
      He(n), r = !1;
    },
    d(l) {
      l && qn(i), ~e && s[e].d(l);
    }
  };
}
function db(t) {
  let e, n, i;
  function r(s) {
    t[31](s);
  }
  let o = {
    filetype: "audio/aac,audio/midi,audio/mpeg,audio/ogg,audio/wav,audio/x-wav,audio/opus,audio/webm,audio/flac,audio/vnd.rn-realaudio,audio/x-ms-wma,audio/x-aiff,audio/amr,audio/*",
    root: (
      /*root*/
      t[4]
    ),
    $$slots: { default: [_b] },
    $$scope: { ctx: t }
  };
  return (
    /*dragging*/
    t[0] !== void 0 && (o.dragging = /*dragging*/
    t[0]), e = new G1({ props: o }), Dr.push(() => Pr(e, "dragging", r)), e.$on(
      "load",
      /*handle_load*/
      t[20]
    ), e.$on(
      "error",
      /*error_handler*/
      t[32]
    ), {
      c() {
        Wt(e.$$.fragment);
      },
      m(s, a) {
        Vt(e, s, a), i = !0;
      },
      p(s, a) {
        const l = {};
        a[0] & /*root*/
        16 && (l.root = /*root*/
        s[4]), a[1] & /*$$scope*/
        512 && (l.$$scope = { dirty: a, ctx: s }), !n && a[0] & /*dragging*/
        1 && (n = !0, l.dragging = /*dragging*/
        s[0], Tr(() => n = !1)), e.$set(l);
      },
      i(s) {
        i || (Ne(e.$$.fragment, s), i = !0);
      },
      o(s) {
        He(e.$$.fragment, s), i = !1;
      },
      d(s) {
        Gt(e, s);
      }
    }
  );
}
function hb(t) {
  let e, n, i, r, o, s;
  e = new ec({
    props: { i18n: (
      /*i18n*/
      t[9]
    ), absolute: !0 }
  }), e.$on(
    "clear",
    /*clear*/
    t[19]
  );
  const a = [pb, mb], l = [];
  function u(c, f) {
    return (
      /*streaming*/
      c[8] ? 0 : 1
    );
  }
  return i = u(t), r = l[i] = a[i](t), {
    c() {
      Wt(e.$$.fragment), n = lr(), r.c(), o = gc();
    },
    m(c, f) {
      Vt(e, c, f), Wn(c, n, f), l[i].m(c, f), Wn(c, o, f), s = !0;
    },
    p(c, f) {
      const d = {};
      f[0] & /*i18n*/
      512 && (d.i18n = /*i18n*/
      c[9]), e.$set(d);
      let h = i;
      i = u(c), i === h ? l[i].p(c, f) : (gs(), He(l[h], 1, 1, () => {
        l[h] = null;
      }), ps(), r = l[i], r ? r.p(c, f) : (r = l[i] = a[i](c), r.c()), Ne(r, 1), r.m(o.parentNode, o));
    },
    i(c) {
      s || (Ne(e.$$.fragment, c), Ne(r), s = !0);
    },
    o(c) {
      He(e.$$.fragment, c), He(r), s = !1;
    },
    d(c) {
      c && (qn(n), qn(o)), Gt(e, c), l[i].d(c);
    }
  };
}
function _b(t) {
  let e;
  const n = (
    /*#slots*/
    t[26].default
  ), i = eb(
    n,
    t,
    /*$$scope*/
    t[40],
    null
  );
  return {
    c() {
      i && i.c();
    },
    m(r, o) {
      i && i.m(r, o), e = !0;
    },
    p(r, o) {
      i && i.p && (!e || o[1] & /*$$scope*/
      512) && sb(
        i,
        n,
        r,
        /*$$scope*/
        r[40],
        e ? ib(
          n,
          /*$$scope*/
          r[40],
          o,
          null
        ) : nb(
          /*$$scope*/
          r[40]
        ),
        null
      );
    },
    i(r) {
      e || (Ne(i, r), e = !0);
    },
    o(r) {
      He(i, r), e = !1;
    },
    d(r) {
      i && i.d(r);
    }
  };
}
function mb(t) {
  let e, n, i;
  function r(s) {
    t[27](s);
  }
  let o = {
    i18n: (
      /*i18n*/
      t[9]
    ),
    editable: (
      /*editable*/
      t[13]
    ),
    dispatch_blob: (
      /*dispatch_blob*/
      t[17]
    ),
    waveform_settings: (
      /*waveform_settings*/
      t[10]
    ),
    waveform_options: (
      /*waveform_options*/
      t[11]
    ),
    handle_reset_value: (
      /*handle_reset_value*/
      t[12]
    )
  };
  return (
    /*mode*/
    t[15] !== void 0 && (o.mode = /*mode*/
    t[15]), e = new Og({ props: o }), Dr.push(() => Pr(e, "mode", r)), e.$on(
      "start_recording",
      /*start_recording_handler*/
      t[28]
    ), e.$on(
      "pause_recording",
      /*pause_recording_handler*/
      t[29]
    ), e.$on(
      "stop_recording",
      /*stop_recording_handler*/
      t[30]
    ), {
      c() {
        Wt(e.$$.fragment);
      },
      m(s, a) {
        Vt(e, s, a), i = !0;
      },
      p(s, a) {
        const l = {};
        a[0] & /*i18n*/
        512 && (l.i18n = /*i18n*/
        s[9]), a[0] & /*editable*/
        8192 && (l.editable = /*editable*/
        s[13]), a[0] & /*waveform_settings*/
        1024 && (l.waveform_settings = /*waveform_settings*/
        s[10]), a[0] & /*waveform_options*/
        2048 && (l.waveform_options = /*waveform_options*/
        s[11]), a[0] & /*handle_reset_value*/
        4096 && (l.handle_reset_value = /*handle_reset_value*/
        s[12]), !n && a[0] & /*mode*/
        32768 && (n = !0, l.mode = /*mode*/
        s[15], Tr(() => n = !1)), e.$set(l);
      },
      i(s) {
        i || (Ne(e.$$.fragment, s), i = !0);
      },
      o(s) {
        He(e.$$.fragment, s), i = !1;
      },
      d(s) {
        Gt(e, s);
      }
    }
  );
}
function pb(t) {
  let e, n;
  return e = new Qg({
    props: {
      record: (
        /*record*/
        t[18]
      ),
      recording: (
        /*recording*/
        t[14]
      ),
      stop: (
        /*stop*/
        t[21]
      ),
      i18n: (
        /*i18n*/
        t[9]
      ),
      waveform_settings: (
        /*waveform_settings*/
        t[10]
      ),
      waveform_options: (
        /*waveform_options*/
        t[11]
      )
    }
  }), {
    c() {
      Wt(e.$$.fragment);
    },
    m(i, r) {
      Vt(e, i, r), n = !0;
    },
    p(i, r) {
      const o = {};
      r[0] & /*recording*/
      16384 && (o.recording = /*recording*/
      i[14]), r[0] & /*i18n*/
      512 && (o.i18n = /*i18n*/
      i[9]), r[0] & /*waveform_settings*/
      1024 && (o.waveform_settings = /*waveform_settings*/
      i[10]), r[0] & /*waveform_options*/
      2048 && (o.waveform_options = /*waveform_options*/
      i[11]), e.$set(o);
    },
    i(i) {
      n || (Ne(e.$$.fragment, i), n = !0);
    },
    o(i) {
      He(e.$$.fragment, i), n = !1;
    },
    d(i) {
      Gt(e, i);
    }
  };
}
function gb(t) {
  let e, n, i, r, o, s, a, l, u;
  e = new Ua({
    props: {
      show_label: (
        /*show_label*/
        t[5]
      ),
      Icon: ur,
      float: (
        /*active_source*/
        t[2] === "upload" && /*value*/
        t[1] === null
      ),
      label: (
        /*label*/
        t[3] || /*i18n*/
        t[9]("audio.audio")
      )
    }
  });
  const c = [fb, cb], f = [];
  function d(m, p) {
    return (
      /*value*/
      m[1] === null || /*streaming*/
      m[8] ? 0 : 1
    );
  }
  r = d(t), o = f[r] = c[r](t);
  function h(m) {
    t[39](m);
  }
  let _ = {
    sources: (
      /*sources*/
      t[7]
    ),
    handle_clear: (
      /*clear*/
      t[19]
    )
  };
  return (
    /*active_source*/
    t[2] !== void 0 && (_.active_source = /*active_source*/
    t[2]), a = new T_({ props: _ }), Dr.push(() => Pr(a, "active_source", h)), {
      c() {
        Wt(e.$$.fragment), n = lr(), i = tb("div"), o.c(), s = lr(), Wt(a.$$.fragment), $g(i, "class", "audio-container svelte-1or5kk1");
      },
      m(m, p) {
        Vt(e, m, p), Wn(m, n, p), Wn(m, i, p), f[r].m(i, null), xg(i, s), Vt(a, i, null), u = !0;
      },
      p(m, p) {
        const E = {};
        p[0] & /*show_label*/
        32 && (E.show_label = /*show_label*/
        m[5]), p[0] & /*active_source, value*/
        6 && (E.float = /*active_source*/
        m[2] === "upload" && /*value*/
        m[1] === null), p[0] & /*label, i18n*/
        520 && (E.label = /*label*/
        m[3] || /*i18n*/
        m[9]("audio.audio")), e.$set(E);
        let w = r;
        r = d(m), r === w ? f[r].p(m, p) : (gs(), He(f[w], 1, 1, () => {
          f[w] = null;
        }), ps(), o = f[r], o ? o.p(m, p) : (o = f[r] = c[r](m), o.c()), Ne(o, 1), o.m(i, s));
        const g = {};
        p[0] & /*sources*/
        128 && (g.sources = /*sources*/
        m[7]), !l && p[0] & /*active_source*/
        4 && (l = !0, g.active_source = /*active_source*/
        m[2], Tr(() => l = !1)), a.$set(g);
      },
      i(m) {
        u || (Ne(e.$$.fragment, m), Ne(o), Ne(a.$$.fragment, m), u = !0);
      },
      o(m) {
        He(e.$$.fragment, m), He(o), He(a.$$.fragment, m), u = !1;
      },
      d(m) {
        m && (qn(n), qn(i)), Gt(e, m), f[r].d(), Gt(a);
      }
    }
  );
}
const bb = 500, ma = 44;
async function vb(t) {
  let e, n = t[0], i = 1;
  for (; i < t.length; ) {
    const r = t[i], o = t[i + 1];
    if (i += 2, (r === "optionalAccess" || r === "optionalCall") && n == null)
      return;
    r === "access" || r === "optionalAccess" ? (e = n, n = await o(n)) : (r === "call" || r === "optionalCall") && (n = await o((...s) => n.call(e, ...s)), e = void 0);
  }
  return n;
}
function wb(t, e, n) {
  let { $$slots: i = {}, $$scope: r } = e, { value: o = null } = e, { label: s } = e, { root: a } = e, { show_label: l = !0 } = e, { show_download_button: u = !1 } = e, { sources: c = ["microphone", "upload"] } = e, { pending: f = !1 } = e, { streaming: d = !1 } = e, { i18n: h } = e, { waveform_settings: _ } = e, { waveform_options: m = {} } = e, { dragging: p } = e, { active_source: E } = e, { handle_reset_value: w = () => {
  } } = e, { editable: g = !0 } = e;
  const b = lb("upload_files");
  let T = !1, C, M = "", A, P = [], D = !1, W = !1, j = [], U;
  function oe() {
    U = [
      import("./module-a5e22de5.js"),
      import("./module-5eba924d.js")
    ];
  }
  d && oe();
  const B = ub(), O = async (R, H) => {
    let et = new File(R, "audio.wav");
    const at = await mu([et], H === "stream");
    n(
      1,
      o.audio_file = (await vb([
        await _u(at, a, void 0, b),
        "optionalAccess",
        async (Xt) => Xt.filter,
        "call",
        async (Xt) => Xt(Boolean)
      ]))[0],
      o
    ), B(H, o);
  };
  ab(() => {
    d && C && C.state !== "inactive" && C.stop();
  });
  async function X() {
    let R;
    try {
      R = await navigator.mediaDevices.getUserMedia({ audio: !0 });
    } catch (H) {
      if (!navigator.mediaDevices) {
        B("error", h("audio.no_device_support"));
        return;
      }
      if (H instanceof DOMException && H.name == "NotAllowedError") {
        B("error", h("audio.allow_recording_access"));
        return;
      }
      throw H;
    }
    if (R != null) {
      if (d) {
        const [{ MediaRecorder: H, register: et }, { connect: at }] = await Promise.all(U);
        await et(await at()), C = new H(R, { mimeType: "audio/wav" }), C.addEventListener("dataavailable", le);
      } else
        C = new MediaRecorder(R), C.addEventListener("dataavailable", (H) => {
          j.push(H.data);
        }), C.addEventListener("stop", async () => {
          n(14, T = !1), await O(j, "change"), await O(j, "stop_recording"), j = [];
        });
      W = !0;
    }
  }
  async function le(R) {
    let H = await R.data.arrayBuffer(), et = new Uint8Array(H);
    if (A || (n(23, A = new Uint8Array(H.slice(0, ma))), et = new Uint8Array(H.slice(ma))), f)
      P.push(et);
    else {
      let at = [A].concat(P, [et]);
      O(at, "stream"), n(24, P = []);
    }
  }
  async function J() {
    n(14, T = !0), B("start_recording"), W || await X(), n(23, A = void 0), d && C.start(bb);
  }
  function v() {
    B("change", null), B("clear"), n(15, M = ""), n(1, o = null);
  }
  function y({ detail: R }) {
    n(1, o = {
      segments: [],
      labels: [],
      multichannel: !1,
      audioFile: null
    }), n(1, o.audio_file = R, o), B("change", o), B("upload", R);
  }
  function N() {
    n(14, T = !1), d && (B("stop_recording"), C.stop(), f && n(25, D = !0), O(j, "stop_recording"), B("clear"), n(15, M = ""));
  }
  function S(R) {
    M = R, n(15, M);
  }
  function k(R) {
    Kt.call(this, t, R);
  }
  function z(R) {
    Kt.call(this, t, R);
  }
  function V(R) {
    Kt.call(this, t, R);
  }
  function G(R) {
    p = R, n(0, p);
  }
  const x = ({ detail: R }) => B("error", R), be = () => n(15, M = "edit");
  function I(R) {
    M = R, n(15, M);
  }
  function pt(R) {
    Kt.call(this, t, R);
  }
  function _e(R) {
    Kt.call(this, t, R);
  }
  function ve(R) {
    Kt.call(this, t, R);
  }
  function L(R) {
    Kt.call(this, t, R);
  }
  function Xe(R) {
    E = R, n(2, E);
  }
  return t.$$set = (R) => {
    "value" in R && n(1, o = R.value), "label" in R && n(3, s = R.label), "root" in R && n(4, a = R.root), "show_label" in R && n(5, l = R.show_label), "show_download_button" in R && n(6, u = R.show_download_button), "sources" in R && n(7, c = R.sources), "pending" in R && n(22, f = R.pending), "streaming" in R && n(8, d = R.streaming), "i18n" in R && n(9, h = R.i18n), "waveform_settings" in R && n(10, _ = R.waveform_settings), "waveform_options" in R && n(11, m = R.waveform_options), "dragging" in R && n(0, p = R.dragging), "active_source" in R && n(2, E = R.active_source), "handle_reset_value" in R && n(12, w = R.handle_reset_value), "editable" in R && n(13, g = R.editable), "$$scope" in R && n(40, r = R.$$scope);
  }, t.$$.update = () => {
    if (t.$$.dirty[0] & /*dragging*/
    1 && B("drag", p), t.$$.dirty[0] & /*submit_pending_stream_on_pending_end, pending, header, pending_stream*/
    62914560 && D && f === !1 && (n(25, D = !1), A && P)) {
      let R = [A].concat(P);
      n(24, P = []), O(R, "stream");
    }
  }, [
    p,
    o,
    E,
    s,
    a,
    l,
    u,
    c,
    d,
    h,
    _,
    m,
    w,
    g,
    T,
    M,
    B,
    O,
    J,
    v,
    y,
    N,
    f,
    A,
    P,
    D,
    i,
    S,
    k,
    z,
    V,
    G,
    x,
    be,
    I,
    pt,
    _e,
    ve,
    L,
    Xe,
    r
  ];
}
class yb extends Kg {
  constructor(e) {
    super(), rb(
      this,
      e,
      wb,
      gb,
      ob,
      {
        value: 1,
        label: 3,
        root: 4,
        show_label: 5,
        show_download_button: 6,
        sources: 7,
        pending: 22,
        streaming: 8,
        i18n: 9,
        waveform_settings: 10,
        waveform_options: 11,
        dragging: 0,
        active_source: 2,
        handle_reset_value: 12,
        editable: 13
      },
      null,
      [-1, -1]
    );
  }
}
function On(t) {
  let e = ["", "k", "M", "G", "T", "P", "E", "Z"], n = 0;
  for (; t > 1e3 && n < e.length - 1; )
    t /= 1e3, n++;
  let i = e[n];
  return (Number.isInteger(t) ? t : t.toFixed(1)) + i;
}
const {
  SvelteComponent: kb,
  append: it,
  attr: Q,
  component_subscribe: pa,
  detach: Eb,
  element: Cb,
  init: Sb,
  insert: Ab,
  noop: ga,
  safe_not_equal: Tb,
  set_style: Ii,
  svg_element: rt,
  toggle_class: ba
} = window.__gradio__svelte__internal, { onMount: Pb } = window.__gradio__svelte__internal;
function Db(t) {
  let e, n, i, r, o, s, a, l, u, c, f, d;
  return {
    c() {
      e = Cb("div"), n = rt("svg"), i = rt("g"), r = rt("path"), o = rt("path"), s = rt("path"), a = rt("path"), l = rt("g"), u = rt("path"), c = rt("path"), f = rt("path"), d = rt("path"), Q(r, "d", "M255.926 0.754768L509.702 139.936V221.027L255.926 81.8465V0.754768Z"), Q(r, "fill", "#FF7C00"), Q(r, "fill-opacity", "0.4"), Q(r, "class", "svelte-43sxxs"), Q(o, "d", "M509.69 139.936L254.981 279.641V361.255L509.69 221.55V139.936Z"), Q(o, "fill", "#FF7C00"), Q(o, "class", "svelte-43sxxs"), Q(s, "d", "M0.250138 139.937L254.981 279.641V361.255L0.250138 221.55V139.937Z"), Q(s, "fill", "#FF7C00"), Q(s, "fill-opacity", "0.4"), Q(s, "class", "svelte-43sxxs"), Q(a, "d", "M255.923 0.232622L0.236328 139.936V221.55L255.923 81.8469V0.232622Z"), Q(a, "fill", "#FF7C00"), Q(a, "class", "svelte-43sxxs"), Ii(i, "transform", "translate(" + /*$top*/
      t[1][0] + "px, " + /*$top*/
      t[1][1] + "px)"), Q(u, "d", "M255.926 141.5L509.702 280.681V361.773L255.926 222.592V141.5Z"), Q(u, "fill", "#FF7C00"), Q(u, "fill-opacity", "0.4"), Q(u, "class", "svelte-43sxxs"), Q(c, "d", "M509.69 280.679L254.981 420.384V501.998L509.69 362.293V280.679Z"), Q(c, "fill", "#FF7C00"), Q(c, "class", "svelte-43sxxs"), Q(f, "d", "M0.250138 280.681L254.981 420.386V502L0.250138 362.295V280.681Z"), Q(f, "fill", "#FF7C00"), Q(f, "fill-opacity", "0.4"), Q(f, "class", "svelte-43sxxs"), Q(d, "d", "M255.923 140.977L0.236328 280.68V362.294L255.923 222.591V140.977Z"), Q(d, "fill", "#FF7C00"), Q(d, "class", "svelte-43sxxs"), Ii(l, "transform", "translate(" + /*$bottom*/
      t[2][0] + "px, " + /*$bottom*/
      t[2][1] + "px)"), Q(n, "viewBox", "-1200 -1200 3000 3000"), Q(n, "fill", "none"), Q(n, "xmlns", "http://www.w3.org/2000/svg"), Q(n, "class", "svelte-43sxxs"), Q(e, "class", "svelte-43sxxs"), ba(
        e,
        "margin",
        /*margin*/
        t[0]
      );
    },
    m(h, _) {
      Ab(h, e, _), it(e, n), it(n, i), it(i, r), it(i, o), it(i, s), it(i, a), it(n, l), it(l, u), it(l, c), it(l, f), it(l, d);
    },
    p(h, [_]) {
      _ & /*$top*/
      2 && Ii(i, "transform", "translate(" + /*$top*/
      h[1][0] + "px, " + /*$top*/
      h[1][1] + "px)"), _ & /*$bottom*/
      4 && Ii(l, "transform", "translate(" + /*$bottom*/
      h[2][0] + "px, " + /*$bottom*/
      h[2][1] + "px)"), _ & /*margin*/
      1 && ba(
        e,
        "margin",
        /*margin*/
        h[0]
      );
    },
    i: ga,
    o: ga,
    d(h) {
      h && Eb(e);
    }
  };
}
function Mb(t, e, n) {
  let i, r, { margin: o = !0 } = e;
  const s = Cl([0, 0]);
  pa(t, s, (d) => n(1, i = d));
  const a = Cl([0, 0]);
  pa(t, a, (d) => n(2, r = d));
  let l;
  async function u() {
    await Promise.all([s.set([125, 140]), a.set([-125, -140])]), await Promise.all([s.set([-125, 140]), a.set([125, -140])]), await Promise.all([s.set([-125, 0]), a.set([125, -0])]), await Promise.all([s.set([125, 0]), a.set([-125, 0])]);
  }
  async function c() {
    await u(), l || c();
  }
  async function f() {
    await Promise.all([s.set([125, 0]), a.set([-125, 0])]), c();
  }
  return Pb(() => (f(), () => l = !0)), t.$$set = (d) => {
    "margin" in d && n(0, o = d.margin);
  }, [o, i, r, s, a];
}
class Rb extends kb {
  constructor(e) {
    super(), Sb(this, e, Mb, Db, Tb, { margin: 0 });
  }
}
const {
  SvelteComponent: Lb,
  append: tn,
  attr: ht,
  binding_callbacks: va,
  check_outros: bc,
  create_component: Bb,
  create_slot: Ob,
  destroy_component: Nb,
  destroy_each: vc,
  detach: F,
  element: wt,
  empty: Kn,
  ensure_array_like: ar,
  get_all_dirty_from_scope: Hb,
  get_slot_changes: Ib,
  group_outros: wc,
  init: Ub,
  insert: q,
  mount_component: jb,
  noop: Yo,
  safe_not_equal: zb,
  set_data: $e,
  set_style: Ut,
  space: _t,
  text: re,
  toggle_class: Qe,
  transition_in: Gn,
  transition_out: Vn,
  update_slot_base: Fb
} = window.__gradio__svelte__internal, { tick: qb } = window.__gradio__svelte__internal, { onDestroy: Wb } = window.__gradio__svelte__internal, Gb = (t) => ({}), wa = (t) => ({});
function ya(t, e, n) {
  const i = t.slice();
  return i[38] = e[n], i[40] = n, i;
}
function ka(t, e, n) {
  const i = t.slice();
  return i[38] = e[n], i;
}
function Vb(t) {
  let e, n = (
    /*i18n*/
    t[1]("common.error") + ""
  ), i, r, o;
  const s = (
    /*#slots*/
    t[29].error
  ), a = Ob(
    s,
    t,
    /*$$scope*/
    t[28],
    wa
  );
  return {
    c() {
      e = wt("span"), i = re(n), r = _t(), a && a.c(), ht(e, "class", "error svelte-1yserjw");
    },
    m(l, u) {
      q(l, e, u), tn(e, i), q(l, r, u), a && a.m(l, u), o = !0;
    },
    p(l, u) {
      (!o || u[0] & /*i18n*/
      2) && n !== (n = /*i18n*/
      l[1]("common.error") + "") && $e(i, n), a && a.p && (!o || u[0] & /*$$scope*/
      268435456) && Fb(
        a,
        s,
        l,
        /*$$scope*/
        l[28],
        o ? Ib(
          s,
          /*$$scope*/
          l[28],
          u,
          Gb
        ) : Hb(
          /*$$scope*/
          l[28]
        ),
        wa
      );
    },
    i(l) {
      o || (Gn(a, l), o = !0);
    },
    o(l) {
      Vn(a, l), o = !1;
    },
    d(l) {
      l && (F(e), F(r)), a && a.d(l);
    }
  };
}
function Xb(t) {
  let e, n, i, r, o, s, a, l, u, c = (
    /*variant*/
    t[8] === "default" && /*show_eta_bar*/
    t[18] && /*show_progress*/
    t[6] === "full" && Ea(t)
  );
  function f(g, b) {
    if (
      /*progress*/
      g[7]
    )
      return Yb;
    if (
      /*queue_position*/
      g[2] !== null && /*queue_size*/
      g[3] !== void 0 && /*queue_position*/
      g[2] >= 0
    )
      return Jb;
    if (
      /*queue_position*/
      g[2] === 0
    )
      return Zb;
  }
  let d = f(t), h = d && d(t), _ = (
    /*timer*/
    t[5] && Aa(t)
  );
  const m = [$b, xb], p = [];
  function E(g, b) {
    return (
      /*last_progress_level*/
      g[15] != null ? 0 : (
        /*show_progress*/
        g[6] === "full" ? 1 : -1
      )
    );
  }
  ~(o = E(t)) && (s = p[o] = m[o](t));
  let w = !/*timer*/
  t[5] && Ba(t);
  return {
    c() {
      c && c.c(), e = _t(), n = wt("div"), h && h.c(), i = _t(), _ && _.c(), r = _t(), s && s.c(), a = _t(), w && w.c(), l = Kn(), ht(n, "class", "progress-text svelte-1yserjw"), Qe(
        n,
        "meta-text-center",
        /*variant*/
        t[8] === "center"
      ), Qe(
        n,
        "meta-text",
        /*variant*/
        t[8] === "default"
      );
    },
    m(g, b) {
      c && c.m(g, b), q(g, e, b), q(g, n, b), h && h.m(n, null), tn(n, i), _ && _.m(n, null), q(g, r, b), ~o && p[o].m(g, b), q(g, a, b), w && w.m(g, b), q(g, l, b), u = !0;
    },
    p(g, b) {
      /*variant*/
      g[8] === "default" && /*show_eta_bar*/
      g[18] && /*show_progress*/
      g[6] === "full" ? c ? c.p(g, b) : (c = Ea(g), c.c(), c.m(e.parentNode, e)) : c && (c.d(1), c = null), d === (d = f(g)) && h ? h.p(g, b) : (h && h.d(1), h = d && d(g), h && (h.c(), h.m(n, i))), /*timer*/
      g[5] ? _ ? _.p(g, b) : (_ = Aa(g), _.c(), _.m(n, null)) : _ && (_.d(1), _ = null), (!u || b[0] & /*variant*/
      256) && Qe(
        n,
        "meta-text-center",
        /*variant*/
        g[8] === "center"
      ), (!u || b[0] & /*variant*/
      256) && Qe(
        n,
        "meta-text",
        /*variant*/
        g[8] === "default"
      );
      let T = o;
      o = E(g), o === T ? ~o && p[o].p(g, b) : (s && (wc(), Vn(p[T], 1, 1, () => {
        p[T] = null;
      }), bc()), ~o ? (s = p[o], s ? s.p(g, b) : (s = p[o] = m[o](g), s.c()), Gn(s, 1), s.m(a.parentNode, a)) : s = null), /*timer*/
      g[5] ? w && (w.d(1), w = null) : w ? w.p(g, b) : (w = Ba(g), w.c(), w.m(l.parentNode, l));
    },
    i(g) {
      u || (Gn(s), u = !0);
    },
    o(g) {
      Vn(s), u = !1;
    },
    d(g) {
      g && (F(e), F(n), F(r), F(a), F(l)), c && c.d(g), h && h.d(), _ && _.d(), ~o && p[o].d(g), w && w.d(g);
    }
  };
}
function Ea(t) {
  let e, n = `translateX(${/*eta_level*/
  (t[17] || 0) * 100 - 100}%)`;
  return {
    c() {
      e = wt("div"), ht(e, "class", "eta-bar svelte-1yserjw"), Ut(e, "transform", n);
    },
    m(i, r) {
      q(i, e, r);
    },
    p(i, r) {
      r[0] & /*eta_level*/
      131072 && n !== (n = `translateX(${/*eta_level*/
      (i[17] || 0) * 100 - 100}%)`) && Ut(e, "transform", n);
    },
    d(i) {
      i && F(e);
    }
  };
}
function Zb(t) {
  let e;
  return {
    c() {
      e = re("processing |");
    },
    m(n, i) {
      q(n, e, i);
    },
    p: Yo,
    d(n) {
      n && F(e);
    }
  };
}
function Jb(t) {
  let e, n = (
    /*queue_position*/
    t[2] + 1 + ""
  ), i, r, o, s;
  return {
    c() {
      e = re("queue: "), i = re(n), r = re("/"), o = re(
        /*queue_size*/
        t[3]
      ), s = re(" |");
    },
    m(a, l) {
      q(a, e, l), q(a, i, l), q(a, r, l), q(a, o, l), q(a, s, l);
    },
    p(a, l) {
      l[0] & /*queue_position*/
      4 && n !== (n = /*queue_position*/
      a[2] + 1 + "") && $e(i, n), l[0] & /*queue_size*/
      8 && $e(
        o,
        /*queue_size*/
        a[3]
      );
    },
    d(a) {
      a && (F(e), F(i), F(r), F(o), F(s));
    }
  };
}
function Yb(t) {
  let e, n = ar(
    /*progress*/
    t[7]
  ), i = [];
  for (let r = 0; r < n.length; r += 1)
    i[r] = Sa(ka(t, n, r));
  return {
    c() {
      for (let r = 0; r < i.length; r += 1)
        i[r].c();
      e = Kn();
    },
    m(r, o) {
      for (let s = 0; s < i.length; s += 1)
        i[s] && i[s].m(r, o);
      q(r, e, o);
    },
    p(r, o) {
      if (o[0] & /*progress*/
      128) {
        n = ar(
          /*progress*/
          r[7]
        );
        let s;
        for (s = 0; s < n.length; s += 1) {
          const a = ka(r, n, s);
          i[s] ? i[s].p(a, o) : (i[s] = Sa(a), i[s].c(), i[s].m(e.parentNode, e));
        }
        for (; s < i.length; s += 1)
          i[s].d(1);
        i.length = n.length;
      }
    },
    d(r) {
      r && F(e), vc(i, r);
    }
  };
}
function Ca(t) {
  let e, n = (
    /*p*/
    t[38].unit + ""
  ), i, r, o = " ", s;
  function a(c, f) {
    return (
      /*p*/
      c[38].length != null ? Kb : Qb
    );
  }
  let l = a(t), u = l(t);
  return {
    c() {
      u.c(), e = _t(), i = re(n), r = re(" | "), s = re(o);
    },
    m(c, f) {
      u.m(c, f), q(c, e, f), q(c, i, f), q(c, r, f), q(c, s, f);
    },
    p(c, f) {
      l === (l = a(c)) && u ? u.p(c, f) : (u.d(1), u = l(c), u && (u.c(), u.m(e.parentNode, e))), f[0] & /*progress*/
      128 && n !== (n = /*p*/
      c[38].unit + "") && $e(i, n);
    },
    d(c) {
      c && (F(e), F(i), F(r), F(s)), u.d(c);
    }
  };
}
function Qb(t) {
  let e = On(
    /*p*/
    t[38].index || 0
  ) + "", n;
  return {
    c() {
      n = re(e);
    },
    m(i, r) {
      q(i, n, r);
    },
    p(i, r) {
      r[0] & /*progress*/
      128 && e !== (e = On(
        /*p*/
        i[38].index || 0
      ) + "") && $e(n, e);
    },
    d(i) {
      i && F(n);
    }
  };
}
function Kb(t) {
  let e = On(
    /*p*/
    t[38].index || 0
  ) + "", n, i, r = On(
    /*p*/
    t[38].length
  ) + "", o;
  return {
    c() {
      n = re(e), i = re("/"), o = re(r);
    },
    m(s, a) {
      q(s, n, a), q(s, i, a), q(s, o, a);
    },
    p(s, a) {
      a[0] & /*progress*/
      128 && e !== (e = On(
        /*p*/
        s[38].index || 0
      ) + "") && $e(n, e), a[0] & /*progress*/
      128 && r !== (r = On(
        /*p*/
        s[38].length
      ) + "") && $e(o, r);
    },
    d(s) {
      s && (F(n), F(i), F(o));
    }
  };
}
function Sa(t) {
  let e, n = (
    /*p*/
    t[38].index != null && Ca(t)
  );
  return {
    c() {
      n && n.c(), e = Kn();
    },
    m(i, r) {
      n && n.m(i, r), q(i, e, r);
    },
    p(i, r) {
      /*p*/
      i[38].index != null ? n ? n.p(i, r) : (n = Ca(i), n.c(), n.m(e.parentNode, e)) : n && (n.d(1), n = null);
    },
    d(i) {
      i && F(e), n && n.d(i);
    }
  };
}
function Aa(t) {
  let e, n = (
    /*eta*/
    t[0] ? `/${/*formatted_eta*/
    t[19]}` : ""
  ), i, r;
  return {
    c() {
      e = re(
        /*formatted_timer*/
        t[20]
      ), i = re(n), r = re("s");
    },
    m(o, s) {
      q(o, e, s), q(o, i, s), q(o, r, s);
    },
    p(o, s) {
      s[0] & /*formatted_timer*/
      1048576 && $e(
        e,
        /*formatted_timer*/
        o[20]
      ), s[0] & /*eta, formatted_eta*/
      524289 && n !== (n = /*eta*/
      o[0] ? `/${/*formatted_eta*/
      o[19]}` : "") && $e(i, n);
    },
    d(o) {
      o && (F(e), F(i), F(r));
    }
  };
}
function xb(t) {
  let e, n;
  return e = new Rb({
    props: { margin: (
      /*variant*/
      t[8] === "default"
    ) }
  }), {
    c() {
      Bb(e.$$.fragment);
    },
    m(i, r) {
      jb(e, i, r), n = !0;
    },
    p(i, r) {
      const o = {};
      r[0] & /*variant*/
      256 && (o.margin = /*variant*/
      i[8] === "default"), e.$set(o);
    },
    i(i) {
      n || (Gn(e.$$.fragment, i), n = !0);
    },
    o(i) {
      Vn(e.$$.fragment, i), n = !1;
    },
    d(i) {
      Nb(e, i);
    }
  };
}
function $b(t) {
  let e, n, i, r, o, s = `${/*last_progress_level*/
  t[15] * 100}%`, a = (
    /*progress*/
    t[7] != null && Ta(t)
  );
  return {
    c() {
      e = wt("div"), n = wt("div"), a && a.c(), i = _t(), r = wt("div"), o = wt("div"), ht(n, "class", "progress-level-inner svelte-1yserjw"), ht(o, "class", "progress-bar svelte-1yserjw"), Ut(o, "width", s), ht(r, "class", "progress-bar-wrap svelte-1yserjw"), ht(e, "class", "progress-level svelte-1yserjw");
    },
    m(l, u) {
      q(l, e, u), tn(e, n), a && a.m(n, null), tn(e, i), tn(e, r), tn(r, o), t[30](o);
    },
    p(l, u) {
      /*progress*/
      l[7] != null ? a ? a.p(l, u) : (a = Ta(l), a.c(), a.m(n, null)) : a && (a.d(1), a = null), u[0] & /*last_progress_level*/
      32768 && s !== (s = `${/*last_progress_level*/
      l[15] * 100}%`) && Ut(o, "width", s);
    },
    i: Yo,
    o: Yo,
    d(l) {
      l && F(e), a && a.d(), t[30](null);
    }
  };
}
function Ta(t) {
  let e, n = ar(
    /*progress*/
    t[7]
  ), i = [];
  for (let r = 0; r < n.length; r += 1)
    i[r] = La(ya(t, n, r));
  return {
    c() {
      for (let r = 0; r < i.length; r += 1)
        i[r].c();
      e = Kn();
    },
    m(r, o) {
      for (let s = 0; s < i.length; s += 1)
        i[s] && i[s].m(r, o);
      q(r, e, o);
    },
    p(r, o) {
      if (o[0] & /*progress_level, progress*/
      16512) {
        n = ar(
          /*progress*/
          r[7]
        );
        let s;
        for (s = 0; s < n.length; s += 1) {
          const a = ya(r, n, s);
          i[s] ? i[s].p(a, o) : (i[s] = La(a), i[s].c(), i[s].m(e.parentNode, e));
        }
        for (; s < i.length; s += 1)
          i[s].d(1);
        i.length = n.length;
      }
    },
    d(r) {
      r && F(e), vc(i, r);
    }
  };
}
function Pa(t) {
  let e, n, i, r, o = (
    /*i*/
    t[40] !== 0 && ev()
  ), s = (
    /*p*/
    t[38].desc != null && Da(t)
  ), a = (
    /*p*/
    t[38].desc != null && /*progress_level*/
    t[14] && /*progress_level*/
    t[14][
      /*i*/
      t[40]
    ] != null && Ma()
  ), l = (
    /*progress_level*/
    t[14] != null && Ra(t)
  );
  return {
    c() {
      o && o.c(), e = _t(), s && s.c(), n = _t(), a && a.c(), i = _t(), l && l.c(), r = Kn();
    },
    m(u, c) {
      o && o.m(u, c), q(u, e, c), s && s.m(u, c), q(u, n, c), a && a.m(u, c), q(u, i, c), l && l.m(u, c), q(u, r, c);
    },
    p(u, c) {
      /*p*/
      u[38].desc != null ? s ? s.p(u, c) : (s = Da(u), s.c(), s.m(n.parentNode, n)) : s && (s.d(1), s = null), /*p*/
      u[38].desc != null && /*progress_level*/
      u[14] && /*progress_level*/
      u[14][
        /*i*/
        u[40]
      ] != null ? a || (a = Ma(), a.c(), a.m(i.parentNode, i)) : a && (a.d(1), a = null), /*progress_level*/
      u[14] != null ? l ? l.p(u, c) : (l = Ra(u), l.c(), l.m(r.parentNode, r)) : l && (l.d(1), l = null);
    },
    d(u) {
      u && (F(e), F(n), F(i), F(r)), o && o.d(u), s && s.d(u), a && a.d(u), l && l.d(u);
    }
  };
}
function ev(t) {
  let e;
  return {
    c() {
      e = re(" /");
    },
    m(n, i) {
      q(n, e, i);
    },
    d(n) {
      n && F(e);
    }
  };
}
function Da(t) {
  let e = (
    /*p*/
    t[38].desc + ""
  ), n;
  return {
    c() {
      n = re(e);
    },
    m(i, r) {
      q(i, n, r);
    },
    p(i, r) {
      r[0] & /*progress*/
      128 && e !== (e = /*p*/
      i[38].desc + "") && $e(n, e);
    },
    d(i) {
      i && F(n);
    }
  };
}
function Ma(t) {
  let e;
  return {
    c() {
      e = re("-");
    },
    m(n, i) {
      q(n, e, i);
    },
    d(n) {
      n && F(e);
    }
  };
}
function Ra(t) {
  let e = (100 * /*progress_level*/
  (t[14][
    /*i*/
    t[40]
  ] || 0)).toFixed(1) + "", n, i;
  return {
    c() {
      n = re(e), i = re("%");
    },
    m(r, o) {
      q(r, n, o), q(r, i, o);
    },
    p(r, o) {
      o[0] & /*progress_level*/
      16384 && e !== (e = (100 * /*progress_level*/
      (r[14][
        /*i*/
        r[40]
      ] || 0)).toFixed(1) + "") && $e(n, e);
    },
    d(r) {
      r && (F(n), F(i));
    }
  };
}
function La(t) {
  let e, n = (
    /*p*/
    (t[38].desc != null || /*progress_level*/
    t[14] && /*progress_level*/
    t[14][
      /*i*/
      t[40]
    ] != null) && Pa(t)
  );
  return {
    c() {
      n && n.c(), e = Kn();
    },
    m(i, r) {
      n && n.m(i, r), q(i, e, r);
    },
    p(i, r) {
      /*p*/
      i[38].desc != null || /*progress_level*/
      i[14] && /*progress_level*/
      i[14][
        /*i*/
        i[40]
      ] != null ? n ? n.p(i, r) : (n = Pa(i), n.c(), n.m(e.parentNode, e)) : n && (n.d(1), n = null);
    },
    d(i) {
      i && F(e), n && n.d(i);
    }
  };
}
function Ba(t) {
  let e, n;
  return {
    c() {
      e = wt("p"), n = re(
        /*loading_text*/
        t[9]
      ), ht(e, "class", "loading svelte-1yserjw");
    },
    m(i, r) {
      q(i, e, r), tn(e, n);
    },
    p(i, r) {
      r[0] & /*loading_text*/
      512 && $e(
        n,
        /*loading_text*/
        i[9]
      );
    },
    d(i) {
      i && F(e);
    }
  };
}
function tv(t) {
  let e, n, i, r, o;
  const s = [Xb, Vb], a = [];
  function l(u, c) {
    return (
      /*status*/
      u[4] === "pending" ? 0 : (
        /*status*/
        u[4] === "error" ? 1 : -1
      )
    );
  }
  return ~(n = l(t)) && (i = a[n] = s[n](t)), {
    c() {
      e = wt("div"), i && i.c(), ht(e, "class", r = "wrap " + /*variant*/
      t[8] + " " + /*show_progress*/
      t[6] + " svelte-1yserjw"), Qe(e, "hide", !/*status*/
      t[4] || /*status*/
      t[4] === "complete" || /*show_progress*/
      t[6] === "hidden"), Qe(
        e,
        "translucent",
        /*variant*/
        t[8] === "center" && /*status*/
        (t[4] === "pending" || /*status*/
        t[4] === "error") || /*translucent*/
        t[11] || /*show_progress*/
        t[6] === "minimal"
      ), Qe(
        e,
        "generating",
        /*status*/
        t[4] === "generating"
      ), Qe(
        e,
        "border",
        /*border*/
        t[12]
      ), Ut(
        e,
        "position",
        /*absolute*/
        t[10] ? "absolute" : "static"
      ), Ut(
        e,
        "padding",
        /*absolute*/
        t[10] ? "0" : "var(--size-8) 0"
      );
    },
    m(u, c) {
      q(u, e, c), ~n && a[n].m(e, null), t[31](e), o = !0;
    },
    p(u, c) {
      let f = n;
      n = l(u), n === f ? ~n && a[n].p(u, c) : (i && (wc(), Vn(a[f], 1, 1, () => {
        a[f] = null;
      }), bc()), ~n ? (i = a[n], i ? i.p(u, c) : (i = a[n] = s[n](u), i.c()), Gn(i, 1), i.m(e, null)) : i = null), (!o || c[0] & /*variant, show_progress*/
      320 && r !== (r = "wrap " + /*variant*/
      u[8] + " " + /*show_progress*/
      u[6] + " svelte-1yserjw")) && ht(e, "class", r), (!o || c[0] & /*variant, show_progress, status, show_progress*/
      336) && Qe(e, "hide", !/*status*/
      u[4] || /*status*/
      u[4] === "complete" || /*show_progress*/
      u[6] === "hidden"), (!o || c[0] & /*variant, show_progress, variant, status, translucent, show_progress*/
      2384) && Qe(
        e,
        "translucent",
        /*variant*/
        u[8] === "center" && /*status*/
        (u[4] === "pending" || /*status*/
        u[4] === "error") || /*translucent*/
        u[11] || /*show_progress*/
        u[6] === "minimal"
      ), (!o || c[0] & /*variant, show_progress, status*/
      336) && Qe(
        e,
        "generating",
        /*status*/
        u[4] === "generating"
      ), (!o || c[0] & /*variant, show_progress, border*/
      4416) && Qe(
        e,
        "border",
        /*border*/
        u[12]
      ), c[0] & /*absolute*/
      1024 && Ut(
        e,
        "position",
        /*absolute*/
        u[10] ? "absolute" : "static"
      ), c[0] & /*absolute*/
      1024 && Ut(
        e,
        "padding",
        /*absolute*/
        u[10] ? "0" : "var(--size-8) 0"
      );
    },
    i(u) {
      o || (Gn(i), o = !0);
    },
    o(u) {
      Vn(i), o = !1;
    },
    d(u) {
      u && F(e), ~n && a[n].d(), t[31](null);
    }
  };
}
let Ui = [], Co = !1;
async function nv(t, e = !0) {
  if (!(window.__gradio_mode__ === "website" || window.__gradio_mode__ !== "app" && e !== !0)) {
    if (Ui.push(t), !Co)
      Co = !0;
    else
      return;
    await qb(), requestAnimationFrame(() => {
      let n = [0, 0];
      for (let i = 0; i < Ui.length; i++) {
        const o = Ui[i].getBoundingClientRect();
        (i === 0 || o.top + window.scrollY <= n[0]) && (n[0] = o.top + window.scrollY, n[1] = i);
      }
      window.scrollTo({ top: n[0] - 20, behavior: "smooth" }), Co = !1, Ui = [];
    });
  }
}
function iv(t, e, n) {
  let i, { $$slots: r = {}, $$scope: o } = e, { i18n: s } = e, { eta: a = null } = e, { queue_position: l } = e, { queue_size: u } = e, { status: c } = e, { scroll_to_output: f = !1 } = e, { timer: d = !0 } = e, { show_progress: h = "full" } = e, { message: _ = null } = e, { progress: m = null } = e, { variant: p = "default" } = e, { loading_text: E = "Loading..." } = e, { absolute: w = !0 } = e, { translucent: g = !1 } = e, { border: b = !1 } = e, { autoscroll: T } = e, C, M = !1, A = 0, P = 0, D = null, W = null, j = 0, U = null, oe, B = null, O = !0;
  const X = () => {
    n(0, a = n(26, D = n(19, v = null))), n(24, A = performance.now()), n(25, P = 0), M = !0, le();
  };
  function le() {
    requestAnimationFrame(() => {
      n(25, P = (performance.now() - A) / 1e3), M && le();
    });
  }
  function J() {
    n(25, P = 0), n(0, a = n(26, D = n(19, v = null))), M && (M = !1);
  }
  Wb(() => {
    M && J();
  });
  let v = null;
  function y(S) {
    va[S ? "unshift" : "push"](() => {
      B = S, n(16, B), n(7, m), n(14, U), n(15, oe);
    });
  }
  function N(S) {
    va[S ? "unshift" : "push"](() => {
      C = S, n(13, C);
    });
  }
  return t.$$set = (S) => {
    "i18n" in S && n(1, s = S.i18n), "eta" in S && n(0, a = S.eta), "queue_position" in S && n(2, l = S.queue_position), "queue_size" in S && n(3, u = S.queue_size), "status" in S && n(4, c = S.status), "scroll_to_output" in S && n(21, f = S.scroll_to_output), "timer" in S && n(5, d = S.timer), "show_progress" in S && n(6, h = S.show_progress), "message" in S && n(22, _ = S.message), "progress" in S && n(7, m = S.progress), "variant" in S && n(8, p = S.variant), "loading_text" in S && n(9, E = S.loading_text), "absolute" in S && n(10, w = S.absolute), "translucent" in S && n(11, g = S.translucent), "border" in S && n(12, b = S.border), "autoscroll" in S && n(23, T = S.autoscroll), "$$scope" in S && n(28, o = S.$$scope);
  }, t.$$.update = () => {
    t.$$.dirty[0] & /*eta, old_eta, timer_start, eta_from_start*/
    218103809 && (a === null && n(0, a = D), a != null && D !== a && (n(27, W = (performance.now() - A) / 1e3 + a), n(19, v = W.toFixed(1)), n(26, D = a))), t.$$.dirty[0] & /*eta_from_start, timer_diff*/
    167772160 && n(17, j = W === null || W <= 0 || !P ? null : Math.min(P / W, 1)), t.$$.dirty[0] & /*progress*/
    128 && m != null && n(18, O = !1), t.$$.dirty[0] & /*progress, progress_level, progress_bar, last_progress_level*/
    114816 && (m != null ? n(14, U = m.map((S) => {
      if (S.index != null && S.length != null)
        return S.index / S.length;
      if (S.progress != null)
        return S.progress;
    })) : n(14, U = null), U ? (n(15, oe = U[U.length - 1]), B && (oe === 0 ? n(16, B.style.transition = "0", B) : n(16, B.style.transition = "150ms", B))) : n(15, oe = void 0)), t.$$.dirty[0] & /*status*/
    16 && (c === "pending" ? X() : J()), t.$$.dirty[0] & /*el, scroll_to_output, status, autoscroll*/
    10493968 && C && f && (c === "pending" || c === "complete") && nv(C, T), t.$$.dirty[0] & /*status, message*/
    4194320, t.$$.dirty[0] & /*timer_diff*/
    33554432 && n(20, i = P.toFixed(1));
  }, [
    a,
    s,
    l,
    u,
    c,
    d,
    h,
    m,
    p,
    E,
    w,
    g,
    b,
    C,
    U,
    oe,
    B,
    j,
    O,
    v,
    i,
    f,
    _,
    T,
    A,
    P,
    D,
    W,
    o,
    r,
    y,
    N
  ];
}
class yc extends Lb {
  constructor(e) {
    super(), Ub(
      this,
      e,
      iv,
      tv,
      zb,
      {
        i18n: 1,
        eta: 0,
        queue_position: 2,
        queue_size: 3,
        status: 4,
        scroll_to_output: 21,
        timer: 5,
        show_progress: 6,
        message: 22,
        progress: 7,
        variant: 8,
        loading_text: 9,
        absolute: 10,
        translucent: 11,
        border: 12,
        autoscroll: 23
      },
      null,
      [-1, -1]
    );
  }
}
const {
  SvelteComponent: rv,
  add_flush_callback: ov,
  assign: kc,
  bind: sv,
  binding_callbacks: lv,
  check_outros: av,
  create_component: hn,
  destroy_component: _n,
  detach: bs,
  empty: uv,
  flush: ae,
  get_spread_object: Ec,
  get_spread_update: Cc,
  group_outros: cv,
  init: fv,
  insert: vs,
  mount_component: mn,
  safe_not_equal: dv,
  space: Sc,
  transition_in: Et,
  transition_out: Ct
} = window.__gradio__svelte__internal;
function hv(t) {
  let e, n;
  return e = new Ia({
    props: {
      variant: (
        /*value*/
        t[0] === null && /*active_source*/
        t[20] === "upload" ? "dashed" : "solid"
      ),
      border_mode: (
        /*dragging*/
        t[21] ? "focus" : "base"
      ),
      padding: !1,
      allow_overflow: !1,
      elem_id: (
        /*elem_id*/
        t[2]
      ),
      elem_classes: (
        /*elem_classes*/
        t[3]
      ),
      visible: (
        /*visible*/
        t[4]
      ),
      container: (
        /*container*/
        t[10]
      ),
      scale: (
        /*scale*/
        t[11]
      ),
      min_width: (
        /*min_width*/
        t[12]
      ),
      $$slots: { default: [pv] },
      $$scope: { ctx: t }
    }
  }), {
    c() {
      hn(e.$$.fragment);
    },
    m(i, r) {
      mn(e, i, r), n = !0;
    },
    p(i, r) {
      const o = {};
      r[0] & /*value, active_source*/
      1048577 && (o.variant = /*value*/
      i[0] === null && /*active_source*/
      i[20] === "upload" ? "dashed" : "solid"), r[0] & /*dragging*/
      2097152 && (o.border_mode = /*dragging*/
      i[21] ? "focus" : "base"), r[0] & /*elem_id*/
      4 && (o.elem_id = /*elem_id*/
      i[2]), r[0] & /*elem_classes*/
      8 && (o.elem_classes = /*elem_classes*/
      i[3]), r[0] & /*visible*/
      16 && (o.visible = /*visible*/
      i[4]), r[0] & /*container*/
      1024 && (o.container = /*container*/
      i[10]), r[0] & /*scale*/
      2048 && (o.scale = /*scale*/
      i[11]), r[0] & /*min_width*/
      4096 && (o.min_width = /*min_width*/
      i[12]), r[0] & /*label, show_label, show_download_button, value, root, sources, active_source, pending, streaming, editable, gradio, waveform_settings, waveform_options, dragging, loading_status*/
      8364995 | r[1] & /*$$scope*/
      65536 && (o.$$scope = { dirty: r, ctx: i }), e.$set(o);
    },
    i(i) {
      n || (Et(e.$$.fragment, i), n = !0);
    },
    o(i) {
      Ct(e.$$.fragment, i), n = !1;
    },
    d(i) {
      _n(e, i);
    }
  };
}
function _v(t) {
  let e, n;
  return e = new Ia({
    props: {
      variant: "solid",
      border_mode: (
        /*dragging*/
        t[21] ? "focus" : "base"
      ),
      padding: !1,
      allow_overflow: !1,
      elem_id: (
        /*elem_id*/
        t[2]
      ),
      elem_classes: (
        /*elem_classes*/
        t[3]
      ),
      visible: (
        /*visible*/
        t[4]
      ),
      container: (
        /*container*/
        t[10]
      ),
      scale: (
        /*scale*/
        t[11]
      ),
      min_width: (
        /*min_width*/
        t[12]
      ),
      $$slots: { default: [gv] },
      $$scope: { ctx: t }
    }
  }), {
    c() {
      hn(e.$$.fragment);
    },
    m(i, r) {
      mn(e, i, r), n = !0;
    },
    p(i, r) {
      const o = {};
      r[0] & /*dragging*/
      2097152 && (o.border_mode = /*dragging*/
      i[21] ? "focus" : "base"), r[0] & /*elem_id*/
      4 && (o.elem_id = /*elem_id*/
      i[2]), r[0] & /*elem_classes*/
      8 && (o.elem_classes = /*elem_classes*/
      i[3]), r[0] & /*visible*/
      16 && (o.visible = /*visible*/
      i[4]), r[0] & /*container*/
      1024 && (o.container = /*container*/
      i[10]), r[0] & /*scale*/
      2048 && (o.scale = /*scale*/
      i[11]), r[0] & /*min_width*/
      4096 && (o.min_width = /*min_width*/
      i[12]), r[0] & /*gradio, show_label, show_download_button, show_share_button, value, label, root, waveform_settings, waveform_options, editable, loading_status*/
      4842371 | r[1] & /*$$scope*/
      65536 && (o.$$scope = { dirty: r, ctx: i }), e.$set(o);
    },
    i(i) {
      n || (Et(e.$$.fragment, i), n = !0);
    },
    o(i) {
      Ct(e.$$.fragment, i), n = !1;
    },
    d(i) {
      _n(e, i);
    }
  };
}
function mv(t) {
  let e, n;
  return e = new w_({
    props: {
      i18n: (
        /*gradio*/
        t[19].i18n
      ),
      type: "audio"
    }
  }), {
    c() {
      hn(e.$$.fragment);
    },
    m(i, r) {
      mn(e, i, r), n = !0;
    },
    p(i, r) {
      const o = {};
      r[0] & /*gradio*/
      524288 && (o.i18n = /*gradio*/
      i[19].i18n), e.$set(o);
    },
    i(i) {
      n || (Et(e.$$.fragment, i), n = !0);
    },
    o(i) {
      Ct(e.$$.fragment, i), n = !1;
    },
    d(i) {
      _n(e, i);
    }
  };
}
function pv(t) {
  let e, n, i, r, o;
  const s = [
    {
      autoscroll: (
        /*gradio*/
        t[19].autoscroll
      )
    },
    { i18n: (
      /*gradio*/
      t[19].i18n
    ) },
    /*loading_status*/
    t[1]
  ];
  let a = {};
  for (let c = 0; c < s.length; c += 1)
    a = kc(a, s[c]);
  e = new yc({ props: a });
  function l(c) {
    t[33](c);
  }
  let u = {
    label: (
      /*label*/
      t[7]
    ),
    show_label: (
      /*show_label*/
      t[9]
    ),
    show_download_button: (
      /*show_download_button*/
      t[13]
    ),
    value: (
      /*value*/
      t[0]
    ),
    root: (
      /*root*/
      t[8]
    ),
    sources: (
      /*sources*/
      t[6]
    ),
    active_source: (
      /*active_source*/
      t[20]
    ),
    pending: (
      /*pending*/
      t[17]
    ),
    streaming: (
      /*streaming*/
      t[18]
    ),
    handle_reset_value: (
      /*handle_reset_value*/
      t[23]
    ),
    editable: (
      /*editable*/
      t[15]
    ),
    i18n: (
      /*gradio*/
      t[19].i18n
    ),
    waveform_settings: (
      /*waveform_settings*/
      t[22]
    ),
    waveform_options: (
      /*waveform_options*/
      t[16]
    ),
    $$slots: { default: [mv] },
    $$scope: { ctx: t }
  };
  return (
    /*dragging*/
    t[21] !== void 0 && (u.dragging = /*dragging*/
    t[21]), i = new yb({ props: u }), lv.push(() => sv(i, "dragging", l)), i.$on(
      "change",
      /*change_handler*/
      t[34]
    ), i.$on(
      "stream",
      /*stream_handler*/
      t[35]
    ), i.$on(
      "drag",
      /*drag_handler*/
      t[36]
    ), i.$on(
      "edit",
      /*edit_handler*/
      t[37]
    ), i.$on(
      "play",
      /*play_handler_1*/
      t[38]
    ), i.$on(
      "pause",
      /*pause_handler_1*/
      t[39]
    ), i.$on(
      "stop",
      /*stop_handler_1*/
      t[40]
    ), i.$on(
      "start_recording",
      /*start_recording_handler*/
      t[41]
    ), i.$on(
      "pause_recording",
      /*pause_recording_handler*/
      t[42]
    ), i.$on(
      "stop_recording",
      /*stop_recording_handler*/
      t[43]
    ), i.$on(
      "upload",
      /*upload_handler*/
      t[44]
    ), i.$on(
      "clear",
      /*clear_handler*/
      t[45]
    ), i.$on(
      "error",
      /*handle_error*/
      t[24]
    ), {
      c() {
        hn(e.$$.fragment), n = Sc(), hn(i.$$.fragment);
      },
      m(c, f) {
        mn(e, c, f), vs(c, n, f), mn(i, c, f), o = !0;
      },
      p(c, f) {
        const d = f[0] & /*gradio, loading_status*/
        524290 ? Cc(s, [
          f[0] & /*gradio*/
          524288 && {
            autoscroll: (
              /*gradio*/
              c[19].autoscroll
            )
          },
          f[0] & /*gradio*/
          524288 && { i18n: (
            /*gradio*/
            c[19].i18n
          ) },
          f[0] & /*loading_status*/
          2 && Ec(
            /*loading_status*/
            c[1]
          )
        ]) : {};
        e.$set(d);
        const h = {};
        f[0] & /*label*/
        128 && (h.label = /*label*/
        c[7]), f[0] & /*show_label*/
        512 && (h.show_label = /*show_label*/
        c[9]), f[0] & /*show_download_button*/
        8192 && (h.show_download_button = /*show_download_button*/
        c[13]), f[0] & /*value*/
        1 && (h.value = /*value*/
        c[0]), f[0] & /*root*/
        256 && (h.root = /*root*/
        c[8]), f[0] & /*sources*/
        64 && (h.sources = /*sources*/
        c[6]), f[0] & /*active_source*/
        1048576 && (h.active_source = /*active_source*/
        c[20]), f[0] & /*pending*/
        131072 && (h.pending = /*pending*/
        c[17]), f[0] & /*streaming*/
        262144 && (h.streaming = /*streaming*/
        c[18]), f[0] & /*editable*/
        32768 && (h.editable = /*editable*/
        c[15]), f[0] & /*gradio*/
        524288 && (h.i18n = /*gradio*/
        c[19].i18n), f[0] & /*waveform_settings*/
        4194304 && (h.waveform_settings = /*waveform_settings*/
        c[22]), f[0] & /*waveform_options*/
        65536 && (h.waveform_options = /*waveform_options*/
        c[16]), f[0] & /*gradio*/
        524288 | f[1] & /*$$scope*/
        65536 && (h.$$scope = { dirty: f, ctx: c }), !r && f[0] & /*dragging*/
        2097152 && (r = !0, h.dragging = /*dragging*/
        c[21], ov(() => r = !1)), i.$set(h);
      },
      i(c) {
        o || (Et(e.$$.fragment, c), Et(i.$$.fragment, c), o = !0);
      },
      o(c) {
        Ct(e.$$.fragment, c), Ct(i.$$.fragment, c), o = !1;
      },
      d(c) {
        c && bs(n), _n(e, c), _n(i, c);
      }
    }
  );
}
function gv(t) {
  let e, n, i, r;
  const o = [
    {
      autoscroll: (
        /*gradio*/
        t[19].autoscroll
      )
    },
    { i18n: (
      /*gradio*/
      t[19].i18n
    ) },
    /*loading_status*/
    t[1]
  ];
  let s = {};
  for (let a = 0; a < o.length; a += 1)
    s = kc(s, o[a]);
  return e = new yc({ props: s }), i = new fm({
    props: {
      i18n: (
        /*gradio*/
        t[19].i18n
      ),
      show_label: (
        /*show_label*/
        t[9]
      ),
      show_download_button: (
        /*show_download_button*/
        t[13]
      ),
      show_share_button: (
        /*show_share_button*/
        t[14]
      ),
      value: (
        /*value*/
        t[0]
      ),
      label: (
        /*label*/
        t[7]
      ),
      root: (
        /*root*/
        t[8]
      ),
      waveform_settings: (
        /*waveform_settings*/
        t[22]
      ),
      waveform_options: (
        /*waveform_options*/
        t[16]
      ),
      editable: (
        /*editable*/
        t[15]
      )
    }
  }), i.$on(
    "share",
    /*share_handler*/
    t[28]
  ), i.$on(
    "error",
    /*error_handler*/
    t[29]
  ), i.$on(
    "play",
    /*play_handler*/
    t[30]
  ), i.$on(
    "pause",
    /*pause_handler*/
    t[31]
  ), i.$on(
    "stop",
    /*stop_handler*/
    t[32]
  ), {
    c() {
      hn(e.$$.fragment), n = Sc(), hn(i.$$.fragment);
    },
    m(a, l) {
      mn(e, a, l), vs(a, n, l), mn(i, a, l), r = !0;
    },
    p(a, l) {
      const u = l[0] & /*gradio, loading_status*/
      524290 ? Cc(o, [
        l[0] & /*gradio*/
        524288 && {
          autoscroll: (
            /*gradio*/
            a[19].autoscroll
          )
        },
        l[0] & /*gradio*/
        524288 && { i18n: (
          /*gradio*/
          a[19].i18n
        ) },
        l[0] & /*loading_status*/
        2 && Ec(
          /*loading_status*/
          a[1]
        )
      ]) : {};
      e.$set(u);
      const c = {};
      l[0] & /*gradio*/
      524288 && (c.i18n = /*gradio*/
      a[19].i18n), l[0] & /*show_label*/
      512 && (c.show_label = /*show_label*/
      a[9]), l[0] & /*show_download_button*/
      8192 && (c.show_download_button = /*show_download_button*/
      a[13]), l[0] & /*show_share_button*/
      16384 && (c.show_share_button = /*show_share_button*/
      a[14]), l[0] & /*value*/
      1 && (c.value = /*value*/
      a[0]), l[0] & /*label*/
      128 && (c.label = /*label*/
      a[7]), l[0] & /*root*/
      256 && (c.root = /*root*/
      a[8]), l[0] & /*waveform_settings*/
      4194304 && (c.waveform_settings = /*waveform_settings*/
      a[22]), l[0] & /*waveform_options*/
      65536 && (c.waveform_options = /*waveform_options*/
      a[16]), l[0] & /*editable*/
      32768 && (c.editable = /*editable*/
      a[15]), i.$set(c);
    },
    i(a) {
      r || (Et(e.$$.fragment, a), Et(i.$$.fragment, a), r = !0);
    },
    o(a) {
      Ct(e.$$.fragment, a), Ct(i.$$.fragment, a), r = !1;
    },
    d(a) {
      a && bs(n), _n(e, a), _n(i, a);
    }
  };
}
function bv(t) {
  let e, n, i, r;
  const o = [_v, hv], s = [];
  function a(l, u) {
    return (
      /*interactive*/
      l[5] ? 1 : 0
    );
  }
  return e = a(t), n = s[e] = o[e](t), {
    c() {
      n.c(), i = uv();
    },
    m(l, u) {
      s[e].m(l, u), vs(l, i, u), r = !0;
    },
    p(l, u) {
      let c = e;
      e = a(l), e === c ? s[e].p(l, u) : (cv(), Ct(s[c], 1, 1, () => {
        s[c] = null;
      }), av(), n = s[e], n ? n.p(l, u) : (n = s[e] = o[e](l), n.c()), Et(n, 1), n.m(i.parentNode, i));
    },
    i(l) {
      r || (Et(n), r = !0);
    },
    o(l) {
      Ct(n), r = !1;
    },
    d(l) {
      l && bs(i), s[e].d(l);
    }
  };
}
function vv(t, e, n) {
  let { elem_id: i = "" } = e, { elem_classes: r = [] } = e, { visible: o = !0 } = e, { interactive: s } = e, { value: a = null } = e, { sources: l } = e, { label: u } = e, { root: c } = e, { show_label: f } = e, { container: d = !0 } = e, { scale: h = null } = e, { min_width: _ = void 0 } = e, { loading_status: m } = e, { autoplay: p = !1 } = e, { show_download_button: E } = e, { show_share_button: w = !1 } = e, { editable: g = !0 } = e, { waveform_options: b = {} } = e, { pending: T } = e, { streaming: C } = e, { gradio: M } = e, A = null, P, D = a;
  const W = () => {
    D === null || a === D || n(0, a = D);
  };
  let j, U, oe = getComputedStyle(document.documentElement).getPropertyValue("--color-accent");
  function B({ detail: L }) {
    const [Xe, R] = L.includes("Invalid file type") ? ["warning", "complete"] : ["error", "error"];
    n(1, m = m || {}), n(1, m.status = R, m), n(1, m.message = L, m), M.dispatch(Xe, L);
  }
  const O = (L) => M.dispatch("share", L.detail), X = (L) => M.dispatch("error", L.detail), le = () => M.dispatch("play"), J = () => M.dispatch("pause"), v = () => M.dispatch("stop");
  function y(L) {
    j = L, n(21, j);
  }
  const N = ({ detail: L }) => n(0, a = L), S = ({ detail: L }) => {
    n(0, a = L), M.dispatch("stream", a);
  }, k = ({ detail: L }) => n(21, j = L), z = () => M.dispatch("edit"), V = () => M.dispatch("play"), G = () => M.dispatch("pause"), x = () => M.dispatch("stop"), be = () => M.dispatch("start_recording"), I = () => M.dispatch("pause_recording"), pt = (L) => M.dispatch("stop_recording"), _e = () => M.dispatch("upload"), ve = () => M.dispatch("clear");
  return t.$$set = (L) => {
    "elem_id" in L && n(2, i = L.elem_id), "elem_classes" in L && n(3, r = L.elem_classes), "visible" in L && n(4, o = L.visible), "interactive" in L && n(5, s = L.interactive), "value" in L && n(0, a = L.value), "sources" in L && n(6, l = L.sources), "label" in L && n(7, u = L.label), "root" in L && n(8, c = L.root), "show_label" in L && n(9, f = L.show_label), "container" in L && n(10, d = L.container), "scale" in L && n(11, h = L.scale), "min_width" in L && n(12, _ = L.min_width), "loading_status" in L && n(1, m = L.loading_status), "autoplay" in L && n(25, p = L.autoplay), "show_download_button" in L && n(13, E = L.show_download_button), "show_share_button" in L && n(14, w = L.show_share_button), "editable" in L && n(15, g = L.editable), "waveform_options" in L && n(16, b = L.waveform_options), "pending" in L && n(17, T = L.pending), "streaming" in L && n(18, C = L.streaming), "gradio" in L && n(19, M = L.gradio);
  }, t.$$.update = () => {
    t.$$.dirty[0] & /*value, initial_value*/
    134217729 && a && D === null && n(27, D = a), t.$$.dirty[0] & /*value, old_value, gradio*/
    67633153 && JSON.stringify(a) !== JSON.stringify(A) && (n(26, A = a), M.dispatch("change")), t.$$.dirty[0] & /*active_source, sources*/
    1048640 && !P && l && n(20, P = l[0]), t.$$.dirty[0] & /*waveform_options, autoplay*/
    33619968 && n(22, U = {
      height: 50,
      waveColor: b.waveform_color || "#9ca3af",
      progressColor: b.waveform_progress_color || oe,
      barWidth: 2,
      barGap: 3,
      cursorWidth: 2,
      cursorColor: "#ddd5e9",
      autoplay: p,
      barRadius: 10,
      dragToSeek: !0,
      normalize: !0,
      minPxPerSec: 20,
      mediaControls: b.show_controls,
      sampleRate: b.sample_rate || 44100
    });
  }, [
    a,
    m,
    i,
    r,
    o,
    s,
    l,
    u,
    c,
    f,
    d,
    h,
    _,
    E,
    w,
    g,
    b,
    T,
    C,
    M,
    P,
    j,
    U,
    W,
    B,
    p,
    A,
    D,
    O,
    X,
    le,
    J,
    v,
    y,
    N,
    S,
    k,
    z,
    V,
    G,
    x,
    be,
    I,
    pt,
    _e,
    ve
  ];
}
class Fv extends rv {
  constructor(e) {
    super(), fv(
      this,
      e,
      vv,
      bv,
      dv,
      {
        elem_id: 2,
        elem_classes: 3,
        visible: 4,
        interactive: 5,
        value: 0,
        sources: 6,
        label: 7,
        root: 8,
        show_label: 9,
        container: 10,
        scale: 11,
        min_width: 12,
        loading_status: 1,
        autoplay: 25,
        show_download_button: 13,
        show_share_button: 14,
        editable: 15,
        waveform_options: 16,
        pending: 17,
        streaming: 18,
        gradio: 19
      },
      null,
      [-1, -1]
    );
  }
  get elem_id() {
    return this.$$.ctx[2];
  }
  set elem_id(e) {
    this.$$set({ elem_id: e }), ae();
  }
  get elem_classes() {
    return this.$$.ctx[3];
  }
  set elem_classes(e) {
    this.$$set({ elem_classes: e }), ae();
  }
  get visible() {
    return this.$$.ctx[4];
  }
  set visible(e) {
    this.$$set({ visible: e }), ae();
  }
  get interactive() {
    return this.$$.ctx[5];
  }
  set interactive(e) {
    this.$$set({ interactive: e }), ae();
  }
  get value() {
    return this.$$.ctx[0];
  }
  set value(e) {
    this.$$set({ value: e }), ae();
  }
  get sources() {
    return this.$$.ctx[6];
  }
  set sources(e) {
    this.$$set({ sources: e }), ae();
  }
  get label() {
    return this.$$.ctx[7];
  }
  set label(e) {
    this.$$set({ label: e }), ae();
  }
  get root() {
    return this.$$.ctx[8];
  }
  set root(e) {
    this.$$set({ root: e }), ae();
  }
  get show_label() {
    return this.$$.ctx[9];
  }
  set show_label(e) {
    this.$$set({ show_label: e }), ae();
  }
  get container() {
    return this.$$.ctx[10];
  }
  set container(e) {
    this.$$set({ container: e }), ae();
  }
  get scale() {
    return this.$$.ctx[11];
  }
  set scale(e) {
    this.$$set({ scale: e }), ae();
  }
  get min_width() {
    return this.$$.ctx[12];
  }
  set min_width(e) {
    this.$$set({ min_width: e }), ae();
  }
  get loading_status() {
    return this.$$.ctx[1];
  }
  set loading_status(e) {
    this.$$set({ loading_status: e }), ae();
  }
  get autoplay() {
    return this.$$.ctx[25];
  }
  set autoplay(e) {
    this.$$set({ autoplay: e }), ae();
  }
  get show_download_button() {
    return this.$$.ctx[13];
  }
  set show_download_button(e) {
    this.$$set({ show_download_button: e }), ae();
  }
  get show_share_button() {
    return this.$$.ctx[14];
  }
  set show_share_button(e) {
    this.$$set({ show_share_button: e }), ae();
  }
  get editable() {
    return this.$$.ctx[15];
  }
  set editable(e) {
    this.$$set({ editable: e }), ae();
  }
  get waveform_options() {
    return this.$$.ctx[16];
  }
  set waveform_options(e) {
    this.$$set({ waveform_options: e }), ae();
  }
  get pending() {
    return this.$$.ctx[17];
  }
  set pending(e) {
    this.$$set({ pending: e }), ae();
  }
  get streaming() {
    return this.$$.ctx[18];
  }
  set streaming(e) {
    this.$$set({ streaming: e }), ae();
  }
  get gradio() {
    return this.$$.ctx[19];
  }
  set gradio(e) {
    this.$$set({ gradio: e }), ae();
  }
}
const {
  SvelteComponent: wv,
  append: yv,
  attr: kv,
  detach: Ev,
  element: Cv,
  init: Sv,
  insert: Av,
  noop: Oa,
  safe_not_equal: Tv,
  set_data: Pv,
  text: Dv,
  toggle_class: Tn
} = window.__gradio__svelte__internal;
function Mv(t) {
  let e, n = (
    /*value*/
    (t[0] ? (
      /*value*/
      t[0]
    ) : "") + ""
  ), i;
  return {
    c() {
      e = Cv("div"), i = Dv(n), kv(e, "class", "svelte-1gecy8w"), Tn(
        e,
        "table",
        /*type*/
        t[1] === "table"
      ), Tn(
        e,
        "gallery",
        /*type*/
        t[1] === "gallery"
      ), Tn(
        e,
        "selected",
        /*selected*/
        t[2]
      );
    },
    m(r, o) {
      Av(r, e, o), yv(e, i);
    },
    p(r, [o]) {
      o & /*value*/
      1 && n !== (n = /*value*/
      (r[0] ? (
        /*value*/
        r[0]
      ) : "") + "") && Pv(i, n), o & /*type*/
      2 && Tn(
        e,
        "table",
        /*type*/
        r[1] === "table"
      ), o & /*type*/
      2 && Tn(
        e,
        "gallery",
        /*type*/
        r[1] === "gallery"
      ), o & /*selected*/
      4 && Tn(
        e,
        "selected",
        /*selected*/
        r[2]
      );
    },
    i: Oa,
    o: Oa,
    d(r) {
      r && Ev(e);
    }
  };
}
function Rv(t, e, n) {
  let { value: i } = e, { type: r } = e, { selected: o = !1 } = e;
  return t.$$set = (s) => {
    "value" in s && n(0, i = s.value), "type" in s && n(1, r = s.type), "selected" in s && n(2, o = s.selected);
  }, [i, r, o];
}
class qv extends wv {
  constructor(e) {
    super(), Sv(this, e, Rv, Mv, Tv, { value: 0, type: 1, selected: 2 });
  }
}
export {
  qv as BaseExample,
  yb as BaseInteractiveAudio,
  ru as BasePlayer,
  fm as BaseStaticAudio,
  Fv as default
};
