const $u = [
  { 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 }
], _r = {
  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"
  }
};
$u.reduce(
  (i, { color: e, primary: t, secondary: n }) => ({
    ...i,
    [e]: {
      primary: _r[e][t],
      secondary: _r[e][n]
    }
  }),
  {}
);
class Lo extends Error {
  constructor(e) {
    super(e), this.name = "ShareError";
  }
}
async function xu(i, e) {
  var l;
  if (window.__gradio_space__ == null)
    throw new Lo("Must be on Spaces to share.");
  let t, n, o;
  {
    const u = await fetch(i);
    t = await u.blob(), n = u.headers.get("content-type") || "", o = u.headers.get("content-disposition") || "";
  }
  const r = new File([t], o, { type: n }), s = await fetch("https://huggingface.co/uploads", {
    method: "POST",
    body: r,
    headers: {
      "Content-Type": r.type,
      "X-Requested-With": "XMLHttpRequest"
    }
  });
  if (!s.ok) {
    if ((l = s.headers.get("content-type")) != null && l.includes("application/json")) {
      const u = await s.json();
      throw new Lo(`Upload failed: ${u.error}`);
    }
    throw new Lo("Upload failed.");
  }
  return await s.text();
}
const hn = (i) => {
  const e = Math.floor(i / 3600), t = Math.floor(i % 3600 / 60), n = Math.round(i) % 60, o = `${t < 10 ? "0" : ""}${t}`, r = `${n < 10 ? "0" : ""}${n}`;
  return e > 0 ? `${e}:${o}:${r}` : `${t}:${r}`;
}, {
  SvelteComponent: ec,
  assign: tc,
  create_slot: nc,
  detach: ic,
  element: oc,
  get_all_dirty_from_scope: sc,
  get_slot_changes: rc,
  get_spread_update: lc,
  init: ac,
  insert: uc,
  safe_not_equal: cc,
  set_dynamic_element_data: gr,
  set_style: ze,
  toggle_class: ht,
  transition_in: va,
  transition_out: ba,
  update_slot_base: dc
} = window.__gradio__svelte__internal;
function fc(i) {
  let e, t, n;
  const o = (
    /*#slots*/
    i[18].default
  ), r = nc(
    o,
    i,
    /*$$scope*/
    i[17],
    null
  );
  let s = [
    { "data-testid": (
      /*test_id*/
      i[7]
    ) },
    { id: (
      /*elem_id*/
      i[2]
    ) },
    {
      class: t = "block " + /*elem_classes*/
      i[3].join(" ") + " svelte-nl1om8"
    }
  ], a = {};
  for (let l = 0; l < s.length; l += 1)
    a = tc(a, s[l]);
  return {
    c() {
      e = oc(
        /*tag*/
        i[14]
      ), r && r.c(), gr(
        /*tag*/
        i[14]
      )(e, a), ht(
        e,
        "hidden",
        /*visible*/
        i[10] === !1
      ), ht(
        e,
        "padded",
        /*padding*/
        i[6]
      ), ht(
        e,
        "border_focus",
        /*border_mode*/
        i[5] === "focus"
      ), ht(
        e,
        "border_contrast",
        /*border_mode*/
        i[5] === "contrast"
      ), ht(e, "hide-container", !/*explicit_call*/
      i[8] && !/*container*/
      i[9]), ze(
        e,
        "height",
        /*get_dimension*/
        i[15](
          /*height*/
          i[0]
        )
      ), ze(e, "width", typeof /*width*/
      i[1] == "number" ? `calc(min(${/*width*/
      i[1]}px, 100%))` : (
        /*get_dimension*/
        i[15](
          /*width*/
          i[1]
        )
      )), ze(
        e,
        "border-style",
        /*variant*/
        i[4]
      ), ze(
        e,
        "overflow",
        /*allow_overflow*/
        i[11] ? "visible" : "hidden"
      ), ze(
        e,
        "flex-grow",
        /*scale*/
        i[12]
      ), ze(e, "min-width", `calc(min(${/*min_width*/
      i[13]}px, 100%))`), ze(e, "border-width", "var(--block-border-width)");
    },
    m(l, u) {
      uc(l, e, u), r && r.m(e, null), n = !0;
    },
    p(l, u) {
      r && r.p && (!n || u & /*$$scope*/
      131072) && dc(
        r,
        o,
        l,
        /*$$scope*/
        l[17],
        n ? rc(
          o,
          /*$$scope*/
          l[17],
          u,
          null
        ) : sc(
          /*$$scope*/
          l[17]
        ),
        null
      ), gr(
        /*tag*/
        l[14]
      )(e, a = lc(s, [
        (!n || u & /*test_id*/
        128) && { "data-testid": (
          /*test_id*/
          l[7]
        ) },
        (!n || u & /*elem_id*/
        4) && { id: (
          /*elem_id*/
          l[2]
        ) },
        (!n || u & /*elem_classes*/
        8 && t !== (t = "block " + /*elem_classes*/
        l[3].join(" ") + " svelte-nl1om8")) && { class: t }
      ])), ht(
        e,
        "hidden",
        /*visible*/
        l[10] === !1
      ), ht(
        e,
        "padded",
        /*padding*/
        l[6]
      ), ht(
        e,
        "border_focus",
        /*border_mode*/
        l[5] === "focus"
      ), ht(
        e,
        "border_contrast",
        /*border_mode*/
        l[5] === "contrast"
      ), ht(e, "hide-container", !/*explicit_call*/
      l[8] && !/*container*/
      l[9]), u & /*height*/
      1 && ze(
        e,
        "height",
        /*get_dimension*/
        l[15](
          /*height*/
          l[0]
        )
      ), u & /*width*/
      2 && ze(e, "width", typeof /*width*/
      l[1] == "number" ? `calc(min(${/*width*/
      l[1]}px, 100%))` : (
        /*get_dimension*/
        l[15](
          /*width*/
          l[1]
        )
      )), u & /*variant*/
      16 && ze(
        e,
        "border-style",
        /*variant*/
        l[4]
      ), u & /*allow_overflow*/
      2048 && ze(
        e,
        "overflow",
        /*allow_overflow*/
        l[11] ? "visible" : "hidden"
      ), u & /*scale*/
      4096 && ze(
        e,
        "flex-grow",
        /*scale*/
        l[12]
      ), u & /*min_width*/
      8192 && ze(e, "min-width", `calc(min(${/*min_width*/
      l[13]}px, 100%))`);
    },
    i(l) {
      n || (va(r, l), n = !0);
    },
    o(l) {
      ba(r, l), n = !1;
    },
    d(l) {
      l && ic(e), r && r.d(l);
    }
  };
}
function hc(i) {
  let e, t = (
    /*tag*/
    i[14] && fc(i)
  );
  return {
    c() {
      t && t.c();
    },
    m(n, o) {
      t && t.m(n, o), e = !0;
    },
    p(n, [o]) {
      /*tag*/
      n[14] && t.p(n, o);
    },
    i(n) {
      e || (va(t, n), e = !0);
    },
    o(n) {
      ba(t, n), e = !1;
    },
    d(n) {
      t && t.d(n);
    }
  };
}
function mc(i, e, t) {
  let { $$slots: n = {}, $$scope: o } = e, { height: r = 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: d = !0 } = e, { type: h = "normal" } = e, { test_id: f = void 0 } = e, { explicit_call: m = !1 } = e, { container: g = !0 } = e, { visible: p = !0 } = e, { allow_overflow: _ = !0 } = e, { scale: y = null } = e, { min_width: v = 0 } = e, C = h === "fieldset" ? "fieldset" : "div";
  const M = (k) => {
    if (k !== void 0) {
      if (typeof k == "number")
        return k + "px";
      if (typeof k == "string")
        return k;
    }
  };
  return i.$$set = (k) => {
    "height" in k && t(0, r = k.height), "width" in k && t(1, s = k.width), "elem_id" in k && t(2, a = k.elem_id), "elem_classes" in k && t(3, l = k.elem_classes), "variant" in k && t(4, u = k.variant), "border_mode" in k && t(5, c = k.border_mode), "padding" in k && t(6, d = k.padding), "type" in k && t(16, h = k.type), "test_id" in k && t(7, f = k.test_id), "explicit_call" in k && t(8, m = k.explicit_call), "container" in k && t(9, g = k.container), "visible" in k && t(10, p = k.visible), "allow_overflow" in k && t(11, _ = k.allow_overflow), "scale" in k && t(12, y = k.scale), "min_width" in k && t(13, v = k.min_width), "$$scope" in k && t(17, o = k.$$scope);
  }, [
    r,
    s,
    a,
    l,
    u,
    c,
    d,
    f,
    m,
    g,
    p,
    _,
    y,
    v,
    C,
    M,
    h,
    o,
    n
  ];
}
class wa extends ec {
  constructor(e) {
    super(), ac(this, e, mc, hc, cc, {
      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: pc,
  append: Oo,
  attr: Bi,
  create_component: _c,
  destroy_component: gc,
  detach: vc,
  element: vr,
  init: bc,
  insert: wc,
  mount_component: yc,
  safe_not_equal: kc,
  set_data: Cc,
  space: Sc,
  text: Ec,
  toggle_class: qt,
  transition_in: Dc,
  transition_out: Rc
} = window.__gradio__svelte__internal;
function Mc(i) {
  let e, t, n, o, r, s;
  return n = new /*Icon*/
  i[1]({}), {
    c() {
      e = vr("label"), t = vr("span"), _c(n.$$.fragment), o = Sc(), r = Ec(
        /*label*/
        i[0]
      ), Bi(t, "class", "svelte-9gxdi0"), Bi(e, "for", ""), Bi(e, "data-testid", "block-label"), Bi(e, "class", "svelte-9gxdi0"), qt(e, "hide", !/*show_label*/
      i[2]), qt(e, "sr-only", !/*show_label*/
      i[2]), qt(
        e,
        "float",
        /*float*/
        i[4]
      ), qt(
        e,
        "hide-label",
        /*disable*/
        i[3]
      );
    },
    m(a, l) {
      wc(a, e, l), Oo(e, t), yc(n, t, null), Oo(e, o), Oo(e, r), s = !0;
    },
    p(a, [l]) {
      (!s || l & /*label*/
      1) && Cc(
        r,
        /*label*/
        a[0]
      ), (!s || l & /*show_label*/
      4) && qt(e, "hide", !/*show_label*/
      a[2]), (!s || l & /*show_label*/
      4) && qt(e, "sr-only", !/*show_label*/
      a[2]), (!s || l & /*float*/
      16) && qt(
        e,
        "float",
        /*float*/
        a[4]
      ), (!s || l & /*disable*/
      8) && qt(
        e,
        "hide-label",
        /*disable*/
        a[3]
      );
    },
    i(a) {
      s || (Dc(n.$$.fragment, a), s = !0);
    },
    o(a) {
      Rc(n.$$.fragment, a), s = !1;
    },
    d(a) {
      a && vc(e), gc(n);
    }
  };
}
function Lc(i, e, t) {
  let { label: n = null } = e, { Icon: o } = e, { show_label: r = !0 } = e, { disable: s = !1 } = e, { float: a = !0 } = e;
  return i.$$set = (l) => {
    "label" in l && t(0, n = l.label), "Icon" in l && t(1, o = l.Icon), "show_label" in l && t(2, r = l.show_label), "disable" in l && t(3, s = l.disable), "float" in l && t(4, a = l.float);
  }, [n, o, r, s, a];
}
class ya extends pc {
  constructor(e) {
    super(), bc(this, e, Lc, Mc, kc, {
      label: 0,
      Icon: 1,
      show_label: 2,
      disable: 3,
      float: 4
    });
  }
}
const {
  SvelteComponent: Oc,
  append: ks,
  attr: Mt,
  bubble: Pc,
  create_component: Wc,
  destroy_component: Ac,
  detach: ka,
  element: Cs,
  init: Tc,
  insert: Ca,
  listen: qc,
  mount_component: jc,
  safe_not_equal: Nc,
  set_data: zc,
  set_style: Ii,
  space: Bc,
  text: Ic,
  toggle_class: Ve,
  transition_in: Uc,
  transition_out: Fc
} = window.__gradio__svelte__internal;
function br(i) {
  let e, t;
  return {
    c() {
      e = Cs("span"), t = Ic(
        /*label*/
        i[1]
      ), Mt(e, "class", "svelte-lpi64a");
    },
    m(n, o) {
      Ca(n, e, o), ks(e, t);
    },
    p(n, o) {
      o & /*label*/
      2 && zc(
        t,
        /*label*/
        n[1]
      );
    },
    d(n) {
      n && ka(e);
    }
  };
}
function Gc(i) {
  let e, t, n, o, r, s, a, l = (
    /*show_label*/
    i[2] && br(i)
  );
  return o = new /*Icon*/
  i[0]({}), {
    c() {
      e = Cs("button"), l && l.c(), t = Bc(), n = Cs("div"), Wc(o.$$.fragment), Mt(n, "class", "svelte-lpi64a"), Ve(
        n,
        "small",
        /*size*/
        i[4] === "small"
      ), Ve(
        n,
        "large",
        /*size*/
        i[4] === "large"
      ), e.disabled = /*disabled*/
      i[7], Mt(
        e,
        "aria-label",
        /*label*/
        i[1]
      ), Mt(
        e,
        "aria-haspopup",
        /*hasPopup*/
        i[8]
      ), Mt(
        e,
        "title",
        /*label*/
        i[1]
      ), Mt(e, "class", "svelte-lpi64a"), Ve(
        e,
        "pending",
        /*pending*/
        i[3]
      ), Ve(
        e,
        "padded",
        /*padded*/
        i[5]
      ), Ve(
        e,
        "highlight",
        /*highlight*/
        i[6]
      ), Ve(
        e,
        "transparent",
        /*transparent*/
        i[9]
      ), Ii(e, "color", !/*disabled*/
      i[7] && /*_color*/
      i[11] ? (
        /*_color*/
        i[11]
      ) : "var(--block-label-text-color)"), Ii(e, "--bg-color", /*disabled*/
      i[7] ? "auto" : (
        /*background*/
        i[10]
      ));
    },
    m(u, c) {
      Ca(u, e, c), l && l.m(e, null), ks(e, t), ks(e, n), jc(o, n, null), r = !0, s || (a = qc(
        e,
        "click",
        /*click_handler*/
        i[13]
      ), s = !0);
    },
    p(u, [c]) {
      /*show_label*/
      u[2] ? l ? l.p(u, c) : (l = br(u), l.c(), l.m(e, t)) : l && (l.d(1), l = null), (!r || c & /*size*/
      16) && Ve(
        n,
        "small",
        /*size*/
        u[4] === "small"
      ), (!r || c & /*size*/
      16) && Ve(
        n,
        "large",
        /*size*/
        u[4] === "large"
      ), (!r || c & /*disabled*/
      128) && (e.disabled = /*disabled*/
      u[7]), (!r || c & /*label*/
      2) && Mt(
        e,
        "aria-label",
        /*label*/
        u[1]
      ), (!r || c & /*hasPopup*/
      256) && Mt(
        e,
        "aria-haspopup",
        /*hasPopup*/
        u[8]
      ), (!r || c & /*label*/
      2) && Mt(
        e,
        "title",
        /*label*/
        u[1]
      ), (!r || c & /*pending*/
      8) && Ve(
        e,
        "pending",
        /*pending*/
        u[3]
      ), (!r || c & /*padded*/
      32) && Ve(
        e,
        "padded",
        /*padded*/
        u[5]
      ), (!r || c & /*highlight*/
      64) && Ve(
        e,
        "highlight",
        /*highlight*/
        u[6]
      ), (!r || c & /*transparent*/
      512) && Ve(
        e,
        "transparent",
        /*transparent*/
        u[9]
      ), c & /*disabled, _color*/
      2176 && Ii(e, "color", !/*disabled*/
      u[7] && /*_color*/
      u[11] ? (
        /*_color*/
        u[11]
      ) : "var(--block-label-text-color)"), c & /*disabled, background*/
      1152 && Ii(e, "--bg-color", /*disabled*/
      u[7] ? "auto" : (
        /*background*/
        u[10]
      ));
    },
    i(u) {
      r || (Uc(o.$$.fragment, u), r = !0);
    },
    o(u) {
      Fc(o.$$.fragment, u), r = !1;
    },
    d(u) {
      u && ka(e), l && l.d(), Ac(o), s = !1, a();
    }
  };
}
function Vc(i, e, t) {
  let n, { Icon: o } = e, { label: r = "" } = e, { show_label: s = !1 } = e, { pending: a = !1 } = e, { size: l = "small" } = e, { padded: u = !0 } = e, { highlight: c = !1 } = e, { disabled: d = !1 } = e, { hasPopup: h = !1 } = e, { color: f = "var(--block-label-text-color)" } = e, { transparent: m = !1 } = e, { background: g = "var(--background-fill-primary)" } = e;
  function p(_) {
    Pc.call(this, i, _);
  }
  return i.$$set = (_) => {
    "Icon" in _ && t(0, o = _.Icon), "label" in _ && t(1, r = _.label), "show_label" in _ && t(2, s = _.show_label), "pending" in _ && t(3, a = _.pending), "size" in _ && t(4, l = _.size), "padded" in _ && t(5, u = _.padded), "highlight" in _ && t(6, c = _.highlight), "disabled" in _ && t(7, d = _.disabled), "hasPopup" in _ && t(8, h = _.hasPopup), "color" in _ && t(12, f = _.color), "transparent" in _ && t(9, m = _.transparent), "background" in _ && t(10, g = _.background);
  }, i.$$.update = () => {
    i.$$.dirty & /*highlight, color*/
    4160 && t(11, n = c ? "var(--color-accent)" : f);
  }, [
    o,
    r,
    s,
    a,
    l,
    u,
    c,
    d,
    h,
    m,
    g,
    n,
    f,
    p
  ];
}
class Ri extends Oc {
  constructor(e) {
    super(), Tc(this, e, Vc, Gc, Nc, {
      Icon: 0,
      label: 1,
      show_label: 2,
      pending: 3,
      size: 4,
      padded: 5,
      highlight: 6,
      disabled: 7,
      hasPopup: 8,
      color: 12,
      transparent: 9,
      background: 10
    });
  }
}
const {
  SvelteComponent: Hc,
  append: Zc,
  attr: Po,
  binding_callbacks: Xc,
  create_slot: Jc,
  detach: Kc,
  element: wr,
  get_all_dirty_from_scope: Yc,
  get_slot_changes: Qc,
  init: $c,
  insert: xc,
  safe_not_equal: ed,
  toggle_class: jt,
  transition_in: td,
  transition_out: nd,
  update_slot_base: id
} = window.__gradio__svelte__internal;
function od(i) {
  let e, t, n;
  const o = (
    /*#slots*/
    i[5].default
  ), r = Jc(
    o,
    i,
    /*$$scope*/
    i[4],
    null
  );
  return {
    c() {
      e = wr("div"), t = wr("div"), r && r.c(), Po(t, "class", "icon svelte-3w3rth"), Po(e, "class", "empty svelte-3w3rth"), Po(e, "aria-label", "Empty value"), jt(
        e,
        "small",
        /*size*/
        i[0] === "small"
      ), jt(
        e,
        "large",
        /*size*/
        i[0] === "large"
      ), jt(
        e,
        "unpadded_box",
        /*unpadded_box*/
        i[1]
      ), jt(
        e,
        "small_parent",
        /*parent_height*/
        i[3]
      );
    },
    m(s, a) {
      xc(s, e, a), Zc(e, t), r && r.m(t, null), i[6](e), n = !0;
    },
    p(s, [a]) {
      r && r.p && (!n || a & /*$$scope*/
      16) && id(
        r,
        o,
        s,
        /*$$scope*/
        s[4],
        n ? Qc(
          o,
          /*$$scope*/
          s[4],
          a,
          null
        ) : Yc(
          /*$$scope*/
          s[4]
        ),
        null
      ), (!n || a & /*size*/
      1) && jt(
        e,
        "small",
        /*size*/
        s[0] === "small"
      ), (!n || a & /*size*/
      1) && jt(
        e,
        "large",
        /*size*/
        s[0] === "large"
      ), (!n || a & /*unpadded_box*/
      2) && jt(
        e,
        "unpadded_box",
        /*unpadded_box*/
        s[1]
      ), (!n || a & /*parent_height*/
      8) && jt(
        e,
        "small_parent",
        /*parent_height*/
        s[3]
      );
    },
    i(s) {
      n || (td(r, s), n = !0);
    },
    o(s) {
      nd(r, s), n = !1;
    },
    d(s) {
      s && Kc(e), r && r.d(s), i[6](null);
    }
  };
}
function sd(i, e, t) {
  let n, { $$slots: o = {}, $$scope: r } = e, { size: s = "small" } = e, { unpadded_box: a = !1 } = e, l;
  function u(d) {
    var h;
    if (!d) return !1;
    const { height: f } = d.getBoundingClientRect(), { height: m } = ((h = d.parentElement) === null || h === void 0 ? void 0 : h.getBoundingClientRect()) || { height: f };
    return f > m + 2;
  }
  function c(d) {
    Xc[d ? "unshift" : "push"](() => {
      l = d, t(2, l);
    });
  }
  return i.$$set = (d) => {
    "size" in d && t(0, s = d.size), "unpadded_box" in d && t(1, a = d.unpadded_box), "$$scope" in d && t(4, r = d.$$scope);
  }, i.$$.update = () => {
    i.$$.dirty & /*el*/
    4 && t(3, n = u(l));
  }, [s, a, l, n, r, o, c];
}
class Sa extends Hc {
  constructor(e) {
    super(), $c(this, e, sd, od, ed, { size: 0, unpadded_box: 1 });
  }
}
const {
  SvelteComponent: rd,
  append: ld,
  attr: He,
  detach: ad,
  init: ud,
  insert: cd,
  noop: Wo,
  safe_not_equal: dd,
  svg_element: yr
} = window.__gradio__svelte__internal;
function fd(i) {
  let e, t;
  return {
    c() {
      e = yr("svg"), t = yr("path"), He(t, "stroke", "currentColor"), He(t, "stroke-width", "1.5"), He(t, "stroke-linecap", "round"), He(t, "stroke-linejoin", "round"), He(t, "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"), He(e, "xmlns", "http://www.w3.org/2000/svg"), He(e, "width", "24px"), He(e, "height", "24px"), He(e, "fill", "currentColor"), He(e, "stroke-width", "1.5"), He(e, "viewBox", "0 0 24 24"), He(e, "color", "currentColor");
    },
    m(n, o) {
      cd(n, e, o), ld(e, t);
    },
    p: Wo,
    i: Wo,
    o: Wo,
    d(n) {
      n && ad(e);
    }
  };
}
class hd extends rd {
  constructor(e) {
    super(), ud(this, e, null, fd, dd, {});
  }
}
const {
  SvelteComponent: md,
  append: Ao,
  attr: tt,
  detach: pd,
  init: _d,
  insert: gd,
  noop: To,
  safe_not_equal: vd,
  set_style: mt,
  svg_element: Ui
} = window.__gradio__svelte__internal;
function bd(i) {
  let e, t, n, o;
  return {
    c() {
      e = Ui("svg"), t = Ui("g"), n = Ui("path"), o = Ui("path"), tt(n, "d", "M18,6L6.087,17.913"), mt(n, "fill", "none"), mt(n, "fill-rule", "nonzero"), mt(n, "stroke-width", "2px"), tt(t, "transform", "matrix(1.14096,-0.140958,-0.140958,1.14096,-0.0559523,0.0559523)"), tt(o, "d", "M4.364,4.364L19.636,19.636"), mt(o, "fill", "none"), mt(o, "fill-rule", "nonzero"), mt(o, "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"), mt(e, "fill-rule", "evenodd"), mt(e, "clip-rule", "evenodd"), mt(e, "stroke-linecap", "round"), mt(e, "stroke-linejoin", "round");
    },
    m(r, s) {
      gd(r, e, s), Ao(e, t), Ao(t, n), Ao(e, o);
    },
    p: To,
    i: To,
    o: To,
    d(r) {
      r && pd(e);
    }
  };
}
class wd extends md {
  constructor(e) {
    super(), _d(this, e, null, bd, vd, {});
  }
}
const {
  SvelteComponent: yd,
  append: kd,
  attr: yn,
  detach: Cd,
  init: Sd,
  insert: Ed,
  noop: qo,
  safe_not_equal: Dd,
  svg_element: kr
} = window.__gradio__svelte__internal;
function Rd(i) {
  let e, t;
  return {
    c() {
      e = kr("svg"), t = kr("path"), yn(t, "fill", "currentColor"), yn(t, "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"), yn(e, "xmlns", "http://www.w3.org/2000/svg"), yn(e, "width", "100%"), yn(e, "height", "100%"), yn(e, "viewBox", "0 0 32 32");
    },
    m(n, o) {
      Ed(n, e, o), kd(e, t);
    },
    p: qo,
    i: qo,
    o: qo,
    d(n) {
      n && Cd(e);
    }
  };
}
class Ea extends yd {
  constructor(e) {
    super(), Sd(this, e, null, Rd, Dd, {});
  }
}
const {
  SvelteComponent: Md,
  append: Ld,
  attr: nt,
  detach: Od,
  init: Pd,
  insert: Wd,
  noop: jo,
  safe_not_equal: Ad,
  svg_element: Cr
} = window.__gradio__svelte__internal;
function Td(i) {
  let e, t;
  return {
    c() {
      e = Cr("svg"), t = Cr("path"), nt(t, "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(n, o) {
      Wd(n, e, o), Ld(e, t);
    },
    p: jo,
    i: jo,
    o: jo,
    d(n) {
      n && Od(e);
    }
  };
}
class qd extends Md {
  constructor(e) {
    super(), Pd(this, e, null, Td, Ad, {});
  }
}
const {
  SvelteComponent: jd,
  append: Nd,
  attr: Ze,
  detach: zd,
  init: Bd,
  insert: Id,
  noop: No,
  safe_not_equal: Ud,
  svg_element: Sr
} = window.__gradio__svelte__internal;
function Fd(i) {
  let e, t;
  return {
    c() {
      e = Sr("svg"), t = Sr("path"), Ze(t, "stroke", "currentColor"), Ze(t, "stroke-width", "1.5"), Ze(t, "stroke-linecap", "round"), Ze(t, "stroke-linejoin", "round"), Ze(t, "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"), 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(n, o) {
      Id(n, e, o), Nd(e, t);
    },
    p: No,
    i: No,
    o: No,
    d(n) {
      n && zd(e);
    }
  };
}
class Gd extends jd {
  constructor(e) {
    super(), Bd(this, e, null, Fd, Ud, {});
  }
}
const {
  SvelteComponent: Vd,
  append: Hd,
  attr: kn,
  detach: Zd,
  init: Xd,
  insert: Jd,
  noop: zo,
  safe_not_equal: Kd,
  svg_element: Er
} = window.__gradio__svelte__internal;
function Yd(i) {
  let e, t;
  return {
    c() {
      e = Er("svg"), t = Er("path"), kn(t, "fill", "currentColor"), kn(t, "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.78a3.99 3.99 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-2h3.5Zm2.245 2.096L16 4.25c0-.052-.002-.103-.005-.154ZM13.75 3.5h-3.5a.75.75 0 0 0 0 1.5h3.5a.75.75 0 0 0 0-1.5ZM15 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-3h-5Zm0 11a2.985 2.985 0 0 1-1.524-.415l3.494-3.494a.75.75 0 0 1 1.06 0l3.494 3.494A2.985 2.985 0 0 1 20 23h-5Zm5-7a1 1 0 1 1 0-2a1 1 0 0 1 0 2Z"), kn(e, "xmlns", "http://www.w3.org/2000/svg"), kn(e, "width", "100%"), kn(e, "height", "100%"), kn(e, "viewBox", "0 0 24 24");
    },
    m(n, o) {
      Jd(n, e, o), Hd(e, t);
    },
    p: zo,
    i: zo,
    o: zo,
    d(n) {
      n && Zd(e);
    }
  };
}
class Da extends Vd {
  constructor(e) {
    super(), Xd(this, e, null, Yd, Kd, {});
  }
}
const {
  SvelteComponent: Qd,
  append: Fi,
  attr: me,
  detach: $d,
  init: xd,
  insert: ef,
  noop: Bo,
  safe_not_equal: tf,
  svg_element: ni
} = window.__gradio__svelte__internal;
function nf(i) {
  let e, t, n, o, r;
  return {
    c() {
      e = ni("svg"), t = ni("path"), n = ni("path"), o = ni("line"), r = ni("line"), me(t, "d", "M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"), me(n, "d", "M19 10v2a7 7 0 0 1-14 0v-2"), me(o, "x1", "12"), me(o, "y1", "19"), me(o, "x2", "12"), me(o, "y2", "23"), me(r, "x1", "8"), me(r, "y1", "23"), me(r, "x2", "16"), me(r, "y2", "23"), me(e, "xmlns", "http://www.w3.org/2000/svg"), me(e, "width", "100%"), me(e, "height", "100%"), me(e, "viewBox", "0 0 24 24"), me(e, "fill", "none"), me(e, "stroke", "currentColor"), me(e, "stroke-width", "2"), me(e, "stroke-linecap", "round"), me(e, "stroke-linejoin", "round"), me(e, "class", "feather feather-mic");
    },
    m(s, a) {
      ef(s, e, a), Fi(e, t), Fi(e, n), Fi(e, o), Fi(e, r);
    },
    p: Bo,
    i: Bo,
    o: Bo,
    d(s) {
      s && $d(e);
    }
  };
}
class of extends Qd {
  constructor(e) {
    super(), xd(this, e, null, nf, tf, {});
  }
}
const {
  SvelteComponent: sf,
  append: Io,
  attr: Ce,
  detach: rf,
  init: lf,
  insert: af,
  noop: Uo,
  safe_not_equal: uf,
  svg_element: Gi
} = window.__gradio__svelte__internal;
function cf(i) {
  let e, t, n, o;
  return {
    c() {
      e = Gi("svg"), t = Gi("path"), n = Gi("circle"), o = Gi("circle"), Ce(t, "d", "M9 18V5l12-2v13"), Ce(n, "cx", "6"), Ce(n, "cy", "18"), Ce(n, "r", "3"), Ce(o, "cx", "18"), Ce(o, "cy", "16"), Ce(o, "r", "3"), Ce(e, "xmlns", "http://www.w3.org/2000/svg"), Ce(e, "width", "100%"), Ce(e, "height", "100%"), Ce(e, "viewBox", "0 0 24 24"), Ce(e, "fill", "none"), Ce(e, "stroke", "currentColor"), Ce(e, "stroke-width", "1.5"), Ce(e, "stroke-linecap", "round"), Ce(e, "stroke-linejoin", "round"), Ce(e, "class", "feather feather-music");
    },
    m(r, s) {
      af(r, e, s), Io(e, t), Io(e, n), Io(e, o);
    },
    p: Uo,
    i: Uo,
    o: Uo,
    d(r) {
      r && rf(e);
    }
  };
}
class go extends sf {
  constructor(e) {
    super(), lf(this, e, null, cf, uf, {});
  }
}
const {
  SvelteComponent: df,
  append: Dr,
  attr: Se,
  detach: ff,
  init: hf,
  insert: mf,
  noop: Fo,
  safe_not_equal: pf,
  svg_element: Go
} = window.__gradio__svelte__internal;
function _f(i) {
  let e, t, n;
  return {
    c() {
      e = Go("svg"), t = Go("rect"), n = Go("rect"), Se(t, "x", "6"), Se(t, "y", "4"), Se(t, "width", "4"), Se(t, "height", "16"), Se(n, "x", "14"), Se(n, "y", "4"), Se(n, "width", "4"), Se(n, "height", "16"), Se(e, "xmlns", "http://www.w3.org/2000/svg"), Se(e, "width", "100%"), Se(e, "height", "100%"), Se(e, "viewBox", "0 0 24 24"), Se(e, "fill", "currentColor"), Se(e, "stroke", "currentColor"), Se(e, "stroke-width", "1.5"), Se(e, "stroke-linecap", "round"), Se(e, "stroke-linejoin", "round");
    },
    m(o, r) {
      mf(o, e, r), Dr(e, t), Dr(e, n);
    },
    p: Fo,
    i: Fo,
    o: Fo,
    d(o) {
      o && ff(e);
    }
  };
}
class Ra extends df {
  constructor(e) {
    super(), hf(this, e, null, _f, pf, {});
  }
}
const {
  SvelteComponent: gf,
  append: vf,
  attr: pt,
  detach: bf,
  init: wf,
  insert: yf,
  noop: Vo,
  safe_not_equal: kf,
  svg_element: Rr
} = window.__gradio__svelte__internal;
function Cf(i) {
  let e, t;
  return {
    c() {
      e = Rr("svg"), t = Rr("polygon"), pt(t, "points", "5 3 19 12 5 21 5 3"), pt(e, "xmlns", "http://www.w3.org/2000/svg"), pt(e, "width", "100%"), pt(e, "height", "100%"), pt(e, "viewBox", "0 0 24 24"), pt(e, "fill", "currentColor"), pt(e, "stroke", "currentColor"), pt(e, "stroke-width", "1.5"), pt(e, "stroke-linecap", "round"), pt(e, "stroke-linejoin", "round");
    },
    m(n, o) {
      yf(n, e, o), vf(e, t);
    },
    p: Vo,
    i: Vo,
    o: Vo,
    d(n) {
      n && bf(e);
    }
  };
}
class Sf extends gf {
  constructor(e) {
    super(), wf(this, e, null, Cf, kf, {});
  }
}
const {
  SvelteComponent: Ef,
  append: ii,
  attr: se,
  detach: Df,
  init: Rf,
  insert: Mf,
  noop: Ho,
  safe_not_equal: Lf,
  svg_element: Cn
} = window.__gradio__svelte__internal;
function Of(i) {
  let e, t, n, o, r, s;
  return {
    c() {
      e = Cn("svg"), t = Cn("circle"), n = Cn("circle"), o = Cn("line"), r = Cn("line"), s = Cn("line"), se(t, "cx", "6"), se(t, "cy", "6"), se(t, "r", "3"), se(n, "cx", "6"), se(n, "cy", "18"), se(n, "r", "3"), se(o, "x1", "20"), se(o, "y1", "4"), se(o, "x2", "8.12"), se(o, "y2", "15.88"), se(r, "x1", "14.47"), se(r, "y1", "14.48"), se(r, "x2", "20"), se(r, "y2", "20"), se(s, "x1", "8.12"), se(s, "y1", "8.12"), se(s, "x2", "12"), se(s, "y2", "12"), se(e, "xmlns", "http://www.w3.org/2000/svg"), se(e, "width", "100%"), se(e, "height", "100%"), se(e, "viewBox", "0 0 24 24"), se(e, "fill", "none"), se(e, "stroke", "currentColor"), se(e, "stroke-width", "2"), se(e, "stroke-linecap", "round"), se(e, "stroke-linejoin", "round"), se(e, "class", "feather feather-scissors");
    },
    m(a, l) {
      Mf(a, e, l), ii(e, t), ii(e, n), ii(e, o), ii(e, r), ii(e, s);
    },
    p: Ho,
    i: Ho,
    o: Ho,
    d(a) {
      a && Df(e);
    }
  };
}
class Pf extends Ef {
  constructor(e) {
    super(), Rf(this, e, null, Of, Lf, {});
  }
}
const {
  SvelteComponent: Wf,
  append: Mr,
  attr: Xe,
  detach: Af,
  init: Tf,
  insert: qf,
  noop: Zo,
  safe_not_equal: jf,
  svg_element: Xo
} = window.__gradio__svelte__internal;
function Nf(i) {
  let e, t, n;
  return {
    c() {
      e = Xo("svg"), t = Xo("polyline"), n = Xo("path"), Xe(t, "points", "1 4 1 10 7 10"), Xe(n, "d", "M3.51 15a9 9 0 1 0 2.13-9.36L1 10"), Xe(e, "xmlns", "http://www.w3.org/2000/svg"), Xe(e, "width", "100%"), Xe(e, "height", "100%"), Xe(e, "viewBox", "0 0 24 24"), Xe(e, "fill", "none"), Xe(e, "stroke", "currentColor"), Xe(e, "stroke-width", "2"), Xe(e, "stroke-linecap", "round"), Xe(e, "stroke-linejoin", "round"), Xe(e, "class", "feather feather-rotate-ccw");
    },
    m(o, r) {
      qf(o, e, r), Mr(e, t), Mr(e, n);
    },
    p: Zo,
    i: Zo,
    o: Zo,
    d(o) {
      o && Af(e);
    }
  };
}
class Ma extends Wf {
  constructor(e) {
    super(), Tf(this, e, null, Nf, jf, {});
  }
}
const {
  SvelteComponent: zf,
  append: Jo,
  attr: Me,
  detach: Bf,
  init: If,
  insert: Uf,
  noop: Ko,
  safe_not_equal: Ff,
  svg_element: Vi
} = window.__gradio__svelte__internal;
function Gf(i) {
  let e, t, n, o;
  return {
    c() {
      e = Vi("svg"), t = Vi("path"), n = Vi("polyline"), o = Vi("line"), Me(t, "d", "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"), Me(n, "points", "17 8 12 3 7 8"), Me(o, "x1", "12"), Me(o, "y1", "3"), Me(o, "x2", "12"), Me(o, "y2", "15"), Me(e, "xmlns", "http://www.w3.org/2000/svg"), Me(e, "width", "90%"), Me(e, "height", "90%"), Me(e, "viewBox", "0 0 24 24"), Me(e, "fill", "none"), Me(e, "stroke", "currentColor"), Me(e, "stroke-width", "2"), Me(e, "stroke-linecap", "round"), Me(e, "stroke-linejoin", "round"), Me(e, "class", "feather feather-upload");
    },
    m(r, s) {
      Uf(r, e, s), Jo(e, t), Jo(e, n), Jo(e, o);
    },
    p: Ko,
    i: Ko,
    o: Ko,
    d(r) {
      r && Bf(e);
    }
  };
}
let La = class extends zf {
  constructor(e) {
    super(), If(this, e, null, Gf, Ff, {});
  }
};
const {
  SvelteComponent: Vf,
  append: Hi,
  attr: Ae,
  detach: Hf,
  init: Zf,
  insert: Xf,
  noop: Yo,
  safe_not_equal: Jf,
  svg_element: Zi,
  text: Kf
} = window.__gradio__svelte__internal;
function Yf(i) {
  let e, t, n, o, r;
  return {
    c() {
      e = Zi("svg"), t = Zi("title"), n = Kf("Low volume"), o = Zi("path"), r = Zi("path"), Ae(o, "d", "M19.5 7.5C19.5 7.5 21 9 21 11.5C21 14 19.5 15.5 19.5 15.5"), Ae(o, "stroke-width", "1.5"), Ae(o, "stroke-linecap", "round"), Ae(o, "stroke-linejoin", "round"), Ae(r, "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"), Ae(r, "stroke-width", "1.5"), Ae(e, "width", "100%"), Ae(e, "height", "100%"), Ae(e, "viewBox", "0 0 24 24"), Ae(e, "stroke-width", "1.5"), Ae(e, "fill", "none"), Ae(e, "xmlns", "http://www.w3.org/2000/svg"), Ae(e, "stroke", "currentColor"), Ae(e, "color", "currentColor");
    },
    m(s, a) {
      Xf(s, e, a), Hi(e, t), Hi(t, n), Hi(e, o), Hi(e, r);
    },
    p: Yo,
    i: Yo,
    o: Yo,
    d(s) {
      s && Hf(e);
    }
  };
}
class Qf extends Vf {
  constructor(e) {
    super(), Zf(this, e, null, Yf, Jf, {});
  }
}
const {
  SvelteComponent: $f,
  append: oi,
  attr: we,
  detach: xf,
  init: eh,
  insert: th,
  noop: Qo,
  safe_not_equal: nh,
  svg_element: si,
  text: ih
} = window.__gradio__svelte__internal;
function oh(i) {
  let e, t, n, o, r, s;
  return {
    c() {
      e = si("svg"), t = si("title"), n = ih("High volume"), o = si("path"), r = si("path"), s = si("path"), we(o, "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"), we(o, "stroke-width", "1.5"), we(r, "d", "M17.5 7.5C17.5 7.5 19 9 19 11.5C19 14 17.5 15.5 17.5 15.5"), we(r, "stroke-width", "1.5"), we(r, "stroke-linecap", "round"), we(r, "stroke-linejoin", "round"), we(s, "d", "M20.5 4.5C20.5 4.5 23 7 23 11.5C23 16 20.5 18.5 20.5 18.5"), we(s, "stroke-width", "1.5"), we(s, "stroke-linecap", "round"), we(s, "stroke-linejoin", "round"), we(e, "width", "100%"), we(e, "height", "100%"), we(e, "viewBox", "0 0 24 24"), we(e, "stroke-width", "1.5"), we(e, "fill", "none"), we(e, "stroke", "currentColor"), we(e, "xmlns", "http://www.w3.org/2000/svg"), we(e, "color", "currentColor");
    },
    m(a, l) {
      th(a, e, l), oi(e, t), oi(t, n), oi(e, o), oi(e, r), oi(e, s);
    },
    p: Qo,
    i: Qo,
    o: Qo,
    d(a) {
      a && xf(e);
    }
  };
}
class sh extends $f {
  constructor(e) {
    super(), eh(this, e, null, oh, nh, {});
  }
}
const {
  SvelteComponent: rh,
  append: Nt,
  attr: ve,
  detach: lh,
  init: ah,
  insert: uh,
  noop: $o,
  safe_not_equal: ch,
  svg_element: zt,
  text: dh
} = window.__gradio__svelte__internal;
function fh(i) {
  let e, t, n, o, r, s, a, l, u;
  return {
    c() {
      e = zt("svg"), t = zt("title"), n = dh("Muted volume"), o = zt("g"), r = zt("path"), s = zt("path"), a = zt("defs"), l = zt("clipPath"), u = zt("rect"), ve(r, "d", "M18 14L20.0005 12M22 10L20.0005 12M20.0005 12L18 10M20.0005 12L22 14"), ve(r, "stroke-width", "1.5"), ve(r, "stroke-linecap", "round"), ve(r, "stroke-linejoin", "round"), ve(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"), ve(s, "stroke-width", "1.5"), ve(o, "clip-path", "url(#clip0_3173_16686)"), ve(u, "width", "24"), ve(u, "height", "24"), ve(u, "fill", "white"), ve(l, "id", "clip0_3173_16686"), ve(e, "width", "100%"), ve(e, "height", "100%"), ve(e, "viewBox", "0 0 24 24"), ve(e, "stroke-width", "1.5"), ve(e, "fill", "none"), ve(e, "xmlns", "http://www.w3.org/2000/svg"), ve(e, "stroke", "currentColor"), ve(e, "color", "currentColor");
    },
    m(c, d) {
      uh(c, e, d), Nt(e, t), Nt(t, n), Nt(e, o), Nt(o, r), Nt(o, s), Nt(e, a), Nt(a, l), Nt(l, u);
    },
    p: $o,
    i: $o,
    o: $o,
    d(c) {
      c && lh(e);
    }
  };
}
class hh extends rh {
  constructor(e) {
    super(), ah(this, e, null, fh, ch, {});
  }
}
const {
  SvelteComponent: mh,
  append: Lr,
  attr: Bt,
  detach: ph,
  init: _h,
  insert: gh,
  noop: xo,
  safe_not_equal: vh,
  svg_element: es
} = window.__gradio__svelte__internal;
function bh(i) {
  let e, t, n;
  return {
    c() {
      e = es("svg"), t = es("path"), n = es("path"), Bt(t, "fill", "currentColor"), Bt(t, "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"), Bt(n, "fill", "currentColor"), Bt(n, "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"), Bt(e, "xmlns", "http://www.w3.org/2000/svg"), Bt(e, "width", "100%"), Bt(e, "height", "100%"), Bt(e, "viewBox", "0 0 24 24");
    },
    m(o, r) {
      gh(o, e, r), Lr(e, t), Lr(e, n);
    },
    p: xo,
    i: xo,
    o: xo,
    d(o) {
      o && ph(e);
    }
  };
}
class wh extends mh {
  constructor(e) {
    super(), _h(this, e, null, bh, vh, {});
  }
}
const {
  SvelteComponent: yh,
  append: ln,
  attr: Ss,
  check_outros: kh,
  create_component: Oa,
  destroy_component: Pa,
  detach: to,
  element: Es,
  group_outros: Ch,
  init: Sh,
  insert: no,
  mount_component: Wa,
  safe_not_equal: Eh,
  set_data: Ds,
  space: Rs,
  text: fi,
  toggle_class: Or,
  transition_in: uo,
  transition_out: co
} = window.__gradio__svelte__internal;
function Dh(i) {
  let e, t;
  return e = new La({}), {
    c() {
      Oa(e.$$.fragment);
    },
    m(n, o) {
      Wa(e, n, o), t = !0;
    },
    i(n) {
      t || (uo(e.$$.fragment, n), t = !0);
    },
    o(n) {
      co(e.$$.fragment, n), t = !1;
    },
    d(n) {
      Pa(e, n);
    }
  };
}
function Rh(i) {
  let e, t;
  return e = new Da({}), {
    c() {
      Oa(e.$$.fragment);
    },
    m(n, o) {
      Wa(e, n, o), t = !0;
    },
    i(n) {
      t || (uo(e.$$.fragment, n), t = !0);
    },
    o(n) {
      co(e.$$.fragment, n), t = !1;
    },
    d(n) {
      Pa(e, n);
    }
  };
}
function Pr(i) {
  let e, t, n = (
    /*i18n*/
    i[1]("common.or") + ""
  ), o, r, s, a = (
    /*message*/
    (i[2] || /*i18n*/
    i[1]("upload_text.click_to_upload")) + ""
  ), l;
  return {
    c() {
      e = Es("span"), t = fi("- "), o = fi(n), r = fi(" -"), s = Rs(), l = fi(a), Ss(e, "class", "or svelte-kzcjhc");
    },
    m(u, c) {
      no(u, e, c), ln(e, t), ln(e, o), ln(e, r), no(u, s, c), no(u, l, c);
    },
    p(u, c) {
      c & /*i18n*/
      2 && n !== (n = /*i18n*/
      u[1]("common.or") + "") && Ds(o, n), c & /*message, i18n*/
      6 && a !== (a = /*message*/
      (u[2] || /*i18n*/
      u[1]("upload_text.click_to_upload")) + "") && Ds(l, a);
    },
    d(u) {
      u && (to(e), to(s), to(l));
    }
  };
}
function Mh(i) {
  let e, t, n, o, r, s = (
    /*i18n*/
    i[1](
      /*defs*/
      i[5][
        /*type*/
        i[0]
      ] || /*defs*/
      i[5].file
    ) + ""
  ), a, l, u;
  const c = [Rh, Dh], d = [];
  function h(m, g) {
    return (
      /*type*/
      m[0] === "clipboard" ? 0 : 1
    );
  }
  n = h(i), o = d[n] = c[n](i);
  let f = (
    /*mode*/
    i[3] !== "short" && Pr(i)
  );
  return {
    c() {
      e = Es("div"), t = Es("span"), o.c(), r = Rs(), a = fi(s), l = Rs(), f && f.c(), Ss(t, "class", "icon-wrap svelte-kzcjhc"), Or(
        t,
        "hovered",
        /*hovered*/
        i[4]
      ), Ss(e, "class", "wrap svelte-kzcjhc");
    },
    m(m, g) {
      no(m, e, g), ln(e, t), d[n].m(t, null), ln(e, r), ln(e, a), ln(e, l), f && f.m(e, null), u = !0;
    },
    p(m, [g]) {
      let p = n;
      n = h(m), n !== p && (Ch(), co(d[p], 1, 1, () => {
        d[p] = null;
      }), kh(), o = d[n], o || (o = d[n] = c[n](m), o.c()), uo(o, 1), o.m(t, null)), (!u || g & /*hovered*/
      16) && Or(
        t,
        "hovered",
        /*hovered*/
        m[4]
      ), (!u || g & /*i18n, type*/
      3) && s !== (s = /*i18n*/
      m[1](
        /*defs*/
        m[5][
          /*type*/
          m[0]
        ] || /*defs*/
        m[5].file
      ) + "") && Ds(a, s), /*mode*/
      m[3] !== "short" ? f ? f.p(m, g) : (f = Pr(m), f.c(), f.m(e, null)) : f && (f.d(1), f = null);
    },
    i(m) {
      u || (uo(o), u = !0);
    },
    o(m) {
      co(o), u = !1;
    },
    d(m) {
      m && to(e), d[n].d(), f && f.d();
    }
  };
}
function Lh(i, e, t) {
  let { type: n = "file" } = e, { i18n: o } = e, { message: r = 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 i.$$set = (u) => {
    "type" in u && t(0, n = u.type), "i18n" in u && t(1, o = u.i18n), "message" in u && t(2, r = u.message), "mode" in u && t(3, s = u.mode), "hovered" in u && t(4, a = u.hovered);
  }, [n, o, r, s, a, l];
}
class Oh extends yh {
  constructor(e) {
    super(), Sh(this, e, Lh, Mh, Eh, {
      type: 0,
      i18n: 1,
      message: 2,
      mode: 3,
      hovered: 4
    });
  }
}
const {
  SvelteComponent: Ph,
  append: ts,
  attr: kt,
  check_outros: hi,
  create_component: vo,
  destroy_component: bo,
  detach: Kn,
  element: Mi,
  empty: Wh,
  group_outros: mi,
  init: Ah,
  insert: Yn,
  listen: wo,
  mount_component: yo,
  safe_not_equal: Th,
  space: ns,
  toggle_class: Qt,
  transition_in: be,
  transition_out: qe
} = window.__gradio__svelte__internal;
function Wr(i) {
  let e, t = (
    /*sources*/
    i[1].includes("upload")
  ), n, o = (
    /*sources*/
    i[1].includes("microphone")
  ), r, s = (
    /*sources*/
    i[1].includes("webcam")
  ), a, l = (
    /*sources*/
    i[1].includes("clipboard")
  ), u, c = t && Ar(i), d = o && Tr(i), h = s && qr(i), f = l && jr(i);
  return {
    c() {
      e = Mi("span"), c && c.c(), n = ns(), d && d.c(), r = ns(), h && h.c(), a = ns(), f && f.c(), kt(e, "class", "source-selection svelte-1jp3vgd"), kt(e, "data-testid", "source-select");
    },
    m(m, g) {
      Yn(m, e, g), c && c.m(e, null), ts(e, n), d && d.m(e, null), ts(e, r), h && h.m(e, null), ts(e, a), f && f.m(e, null), u = !0;
    },
    p(m, g) {
      g & /*sources*/
      2 && (t = /*sources*/
      m[1].includes("upload")), t ? c ? (c.p(m, g), g & /*sources*/
      2 && be(c, 1)) : (c = Ar(m), c.c(), be(c, 1), c.m(e, n)) : c && (mi(), qe(c, 1, 1, () => {
        c = null;
      }), hi()), g & /*sources*/
      2 && (o = /*sources*/
      m[1].includes("microphone")), o ? d ? (d.p(m, g), g & /*sources*/
      2 && be(d, 1)) : (d = Tr(m), d.c(), be(d, 1), d.m(e, r)) : d && (mi(), qe(d, 1, 1, () => {
        d = null;
      }), hi()), g & /*sources*/
      2 && (s = /*sources*/
      m[1].includes("webcam")), s ? h ? (h.p(m, g), g & /*sources*/
      2 && be(h, 1)) : (h = qr(m), h.c(), be(h, 1), h.m(e, a)) : h && (mi(), qe(h, 1, 1, () => {
        h = null;
      }), hi()), g & /*sources*/
      2 && (l = /*sources*/
      m[1].includes("clipboard")), l ? f ? (f.p(m, g), g & /*sources*/
      2 && be(f, 1)) : (f = jr(m), f.c(), be(f, 1), f.m(e, null)) : f && (mi(), qe(f, 1, 1, () => {
        f = null;
      }), hi());
    },
    i(m) {
      u || (be(c), be(d), be(h), be(f), u = !0);
    },
    o(m) {
      qe(c), qe(d), qe(h), qe(f), u = !1;
    },
    d(m) {
      m && Kn(e), c && c.d(), d && d.d(), h && h.d(), f && f.d();
    }
  };
}
function Ar(i) {
  let e, t, n, o, r;
  return t = new La({}), {
    c() {
      e = Mi("button"), vo(t.$$.fragment), kt(e, "class", "icon svelte-1jp3vgd"), kt(e, "aria-label", "Upload file"), Qt(
        e,
        "selected",
        /*active_source*/
        i[0] === "upload" || !/*active_source*/
        i[0]
      );
    },
    m(s, a) {
      Yn(s, e, a), yo(t, e, null), n = !0, o || (r = wo(
        e,
        "click",
        /*click_handler*/
        i[6]
      ), o = !0);
    },
    p(s, a) {
      (!n || a & /*active_source*/
      1) && Qt(
        e,
        "selected",
        /*active_source*/
        s[0] === "upload" || !/*active_source*/
        s[0]
      );
    },
    i(s) {
      n || (be(t.$$.fragment, s), n = !0);
    },
    o(s) {
      qe(t.$$.fragment, s), n = !1;
    },
    d(s) {
      s && Kn(e), bo(t), o = !1, r();
    }
  };
}
function Tr(i) {
  let e, t, n, o, r;
  return t = new of({}), {
    c() {
      e = Mi("button"), vo(t.$$.fragment), kt(e, "class", "icon svelte-1jp3vgd"), kt(e, "aria-label", "Record audio"), Qt(
        e,
        "selected",
        /*active_source*/
        i[0] === "microphone"
      );
    },
    m(s, a) {
      Yn(s, e, a), yo(t, e, null), n = !0, o || (r = wo(
        e,
        "click",
        /*click_handler_1*/
        i[7]
      ), o = !0);
    },
    p(s, a) {
      (!n || a & /*active_source*/
      1) && Qt(
        e,
        "selected",
        /*active_source*/
        s[0] === "microphone"
      );
    },
    i(s) {
      n || (be(t.$$.fragment, s), n = !0);
    },
    o(s) {
      qe(t.$$.fragment, s), n = !1;
    },
    d(s) {
      s && Kn(e), bo(t), o = !1, r();
    }
  };
}
function qr(i) {
  let e, t, n, o, r;
  return t = new wh({}), {
    c() {
      e = Mi("button"), vo(t.$$.fragment), kt(e, "class", "icon svelte-1jp3vgd"), kt(e, "aria-label", "Capture from camera"), Qt(
        e,
        "selected",
        /*active_source*/
        i[0] === "webcam"
      );
    },
    m(s, a) {
      Yn(s, e, a), yo(t, e, null), n = !0, o || (r = wo(
        e,
        "click",
        /*click_handler_2*/
        i[8]
      ), o = !0);
    },
    p(s, a) {
      (!n || a & /*active_source*/
      1) && Qt(
        e,
        "selected",
        /*active_source*/
        s[0] === "webcam"
      );
    },
    i(s) {
      n || (be(t.$$.fragment, s), n = !0);
    },
    o(s) {
      qe(t.$$.fragment, s), n = !1;
    },
    d(s) {
      s && Kn(e), bo(t), o = !1, r();
    }
  };
}
function jr(i) {
  let e, t, n, o, r;
  return t = new Da({}), {
    c() {
      e = Mi("button"), vo(t.$$.fragment), kt(e, "class", "icon svelte-1jp3vgd"), kt(e, "aria-label", "Paste from clipboard"), Qt(
        e,
        "selected",
        /*active_source*/
        i[0] === "clipboard"
      );
    },
    m(s, a) {
      Yn(s, e, a), yo(t, e, null), n = !0, o || (r = wo(
        e,
        "click",
        /*click_handler_3*/
        i[9]
      ), o = !0);
    },
    p(s, a) {
      (!n || a & /*active_source*/
      1) && Qt(
        e,
        "selected",
        /*active_source*/
        s[0] === "clipboard"
      );
    },
    i(s) {
      n || (be(t.$$.fragment, s), n = !0);
    },
    o(s) {
      qe(t.$$.fragment, s), n = !1;
    },
    d(s) {
      s && Kn(e), bo(t), o = !1, r();
    }
  };
}
function qh(i) {
  let e, t, n = (
    /*unique_sources*/
    i[2].length > 1 && Wr(i)
  );
  return {
    c() {
      n && n.c(), e = Wh();
    },
    m(o, r) {
      n && n.m(o, r), Yn(o, e, r), t = !0;
    },
    p(o, [r]) {
      /*unique_sources*/
      o[2].length > 1 ? n ? (n.p(o, r), r & /*unique_sources*/
      4 && be(n, 1)) : (n = Wr(o), n.c(), be(n, 1), n.m(e.parentNode, e)) : n && (mi(), qe(n, 1, 1, () => {
        n = null;
      }), hi());
    },
    i(o) {
      t || (be(n), t = !0);
    },
    o(o) {
      qe(n), t = !1;
    },
    d(o) {
      o && Kn(e), n && n.d(o);
    }
  };
}
function jh(i, e, t) {
  let n;
  var o = this && this.__awaiter || function(m, g, p, _) {
    function y(v) {
      return v instanceof p ? v : new p(function(C) {
        C(v);
      });
    }
    return new (p || (p = Promise))(function(v, C) {
      function M(D) {
        try {
          P(_.next(D));
        } catch (b) {
          C(b);
        }
      }
      function k(D) {
        try {
          P(_.throw(D));
        } catch (b) {
          C(b);
        }
      }
      function P(D) {
        D.done ? v(D.value) : y(D.value).then(M, k);
      }
      P((_ = _.apply(m, g || [])).next());
    });
  };
  let { sources: r } = e, { active_source: s } = e, { handle_clear: a = () => {
  } } = e, { handle_select: l = () => {
  } } = e;
  function u(m) {
    return o(this, void 0, void 0, function* () {
      a(), t(0, s = m), l(m);
    });
  }
  const c = () => u("upload"), d = () => u("microphone"), h = () => u("webcam"), f = () => u("clipboard");
  return i.$$set = (m) => {
    "sources" in m && t(1, r = m.sources), "active_source" in m && t(0, s = m.active_source), "handle_clear" in m && t(4, a = m.handle_clear), "handle_select" in m && t(5, l = m.handle_select);
  }, i.$$.update = () => {
    i.$$.dirty & /*sources*/
    2 && t(2, n = [...new Set(r)]);
  }, [
    s,
    r,
    n,
    u,
    a,
    l,
    c,
    d,
    h,
    f
  ];
}
class Nh extends Ph {
  constructor(e) {
    super(), Ah(this, e, jh, qh, Th, {
      sources: 1,
      active_source: 0,
      handle_clear: 4,
      handle_select: 5
    });
  }
}
function Oe(i, e, t, n) {
  return new (t || (t = Promise))(function(o, r) {
    function s(u) {
      try {
        l(n.next(u));
      } catch (c) {
        r(c);
      }
    }
    function a(u) {
      try {
        l(n.throw(u));
      } catch (c) {
        r(c);
      }
    }
    function l(u) {
      var c;
      u.done ? o(u.value) : (c = u.value, c instanceof t ? c : new t(function(d) {
        d(c);
      })).then(s, a);
    }
    l((n = n.apply(i, e || [])).next());
  });
}
let Li = class {
  constructor() {
    this.listeners = {};
  }
  on(e, t, n) {
    if (this.listeners[e] || (this.listeners[e] = /* @__PURE__ */ new Set()), this.listeners[e].add(t), n == null ? void 0 : n.once) {
      const o = () => {
        this.un(e, o), this.un(e, t);
      };
      return this.on(e, o), o;
    }
    return () => this.un(e, t);
  }
  un(e, t) {
    var n;
    (n = this.listeners[e]) === null || n === void 0 || n.delete(t);
  }
  once(e, t) {
    return this.on(e, t, { once: !0 });
  }
  unAll() {
    this.listeners = {};
  }
  emit(e, ...t) {
    this.listeners[e] && this.listeners[e].forEach((n) => n(...t));
  }
};
const Nr = { decode: function(i, e) {
  return Oe(this, void 0, void 0, function* () {
    const t = new AudioContext({ sampleRate: e });
    return t.decodeAudioData(i).finally(() => t.close());
  });
}, createBuffer: function(i, e) {
  return typeof i[0] == "number" && (i = [i]), function(t) {
    const n = t[0];
    if (n.some((o) => o > 1 || o < -1)) {
      const o = n.length;
      let r = 0;
      for (let s = 0; s < o; s++) {
        const a = Math.abs(n[s]);
        a > r && (r = a);
      }
      for (const s of t) for (let a = 0; a < o; a++) s[a] /= r;
    }
  }(i), { duration: e, length: i[0].length, sampleRate: i[0].length / e, numberOfChannels: i.length, getChannelData: (t) => i == null ? void 0 : i[t], copyFromChannel: AudioBuffer.prototype.copyFromChannel, copyToChannel: AudioBuffer.prototype.copyToChannel };
} };
function Aa(i, e) {
  const t = e.xmlns ? document.createElementNS(e.xmlns, i) : document.createElement(i);
  for (const [n, o] of Object.entries(e)) if (n === "children") for (const [r, s] of Object.entries(e)) typeof s == "string" ? t.appendChild(document.createTextNode(s)) : t.appendChild(Aa(r, s));
  else n === "style" ? Object.assign(t.style, o) : n === "textContent" ? t.textContent = o : t.setAttribute(n, o.toString());
  return t;
}
function zr(i, e, t) {
  const n = Aa(i, e || {});
  return t == null || t.appendChild(n), n;
}
var zh = Object.freeze({ __proto__: null, createElement: zr, default: zr });
const Bh = { fetchBlob: function(i, e, t) {
  return Oe(this, void 0, void 0, function* () {
    const n = yield fetch(i, t);
    if (n.status >= 400) throw new Error(`Failed to fetch ${i}: ${n.status} (${n.statusText})`);
    return function(o, r) {
      Oe(this, void 0, void 0, function* () {
        if (!o.body || !o.headers) return;
        const s = o.body.getReader(), a = Number(o.headers.get("Content-Length")) || 0;
        let l = 0;
        const u = (d) => Oe(this, void 0, void 0, function* () {
          l += (d == null ? void 0 : d.length) || 0;
          const h = Math.round(l / a * 100);
          r(h);
        }), c = () => Oe(this, void 0, void 0, function* () {
          let d;
          try {
            d = yield s.read();
          } catch {
            return;
          }
          d.done || (u(d.value), yield c());
        });
        c();
      });
    }(n.clone(), e), n.blob();
  });
} };
let Ih = class extends Li {
  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, t, n) {
    return this.media.addEventListener(e, t, n), () => this.media.removeEventListener(e, t, n);
  }
  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, t) {
    const n = this.getSrc();
    if (e && n === e) return;
    this.revokeSrc();
    const o = t instanceof Blob && (this.canPlayType(t.type) || !e) ? URL.createObjectURL(t) : e;
    try {
      this.media.src = o;
    } 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 Oe(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, t) {
    t != null && (this.media.preservesPitch = t), this.media.playbackRate = e;
  }
  getMediaElement() {
    return this.media;
  }
  setSinkId(e) {
    return this.media.setSinkId(e);
  }
}, Ms = class Ls extends Li {
  constructor(e, t) {
    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 n = this.parentFromOptionsContainer(e.container);
    this.parent = n;
    const [o, r] = this.initHtml();
    n.appendChild(o), this.container = o, this.scrollContainer = r.querySelector(".scroll"), this.wrapper = r.querySelector(".wrapper"), this.canvasWrapper = r.querySelector(".canvases"), this.progressWrapper = r.querySelector(".progress"), this.cursor = r.querySelector(".cursor"), t && r.appendChild(t), this.initEvents();
  }
  parentFromOptionsContainer(e) {
    let t;
    if (typeof e == "string" ? t = document.querySelector(e) : e instanceof HTMLElement && (t = e), !t) throw new Error("Container not found");
    return t;
  }
  initEvents() {
    const e = (t) => {
      const n = this.wrapper.getBoundingClientRect(), o = t.clientX - n.left, r = t.clientY - n.top;
      return [o / n.width, r / n.height];
    };
    if (this.wrapper.addEventListener("click", (t) => {
      const [n, o] = e(t);
      this.emit("click", n, o);
    }), this.wrapper.addEventListener("dblclick", (t) => {
      const [n, o] = e(t);
      this.emit("dblclick", n, o);
    }), this.options.dragToSeek !== !0 && typeof this.options.dragToSeek != "object" || this.initDrag(), this.scrollContainer.addEventListener("scroll", () => {
      const { scrollLeft: t, scrollWidth: n, clientWidth: o } = this.scrollContainer, r = t / n, s = (t + o) / n;
      this.emit("scroll", r, s, t, t + o);
    }), typeof ResizeObserver == "function") {
      const t = this.createDelay(100);
      this.resizeObserver = new ResizeObserver(() => {
        t().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, t, n, o, r = 3, s = 0, a = 100) {
      if (!e) return () => {
      };
      const l = matchMedia("(pointer: coarse)").matches;
      let u = () => {
      };
      const c = (d) => {
        if (d.button !== s) return;
        d.preventDefault(), d.stopPropagation();
        let h = d.clientX, f = d.clientY, m = !1;
        const g = Date.now(), p = (M) => {
          if (M.preventDefault(), M.stopPropagation(), l && Date.now() - g < a) return;
          const k = M.clientX, P = M.clientY, D = k - h, b = P - f;
          if (m || Math.abs(D) > r || Math.abs(b) > r) {
            const E = e.getBoundingClientRect(), { left: U, top: T } = E;
            m || (n == null || n(h - U, f - T), m = !0), t(D, b, k - U, P - T), h = k, f = P;
          }
        }, _ = (M) => {
          if (m) {
            const k = M.clientX, P = M.clientY, D = e.getBoundingClientRect(), { left: b, top: E } = D;
            o == null || o(k - b, P - E);
          }
          u();
        }, y = (M) => {
          M.relatedTarget && M.relatedTarget !== document.documentElement || _(M);
        }, v = (M) => {
          m && (M.stopPropagation(), M.preventDefault());
        }, C = (M) => {
          m && M.preventDefault();
        };
        document.addEventListener("pointermove", p), document.addEventListener("pointerup", _), document.addEventListener("pointerout", y), document.addEventListener("pointercancel", y), document.addEventListener("touchmove", C, { passive: !1 }), document.addEventListener("click", v, { capture: !0 }), u = () => {
          document.removeEventListener("pointermove", p), document.removeEventListener("pointerup", _), document.removeEventListener("pointerout", y), document.removeEventListener("pointercancel", y), document.removeEventListener("touchmove", C), setTimeout(() => {
            document.removeEventListener("click", v, { capture: !0 });
          }, 10);
        };
      };
      return e.addEventListener("pointerdown", c), () => {
        u(), e.removeEventListener("pointerdown", c);
      };
    }(this.wrapper, (e, t, n) => {
      this.emit("drag", Math.max(0, Math.min(1, n / 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, t) {
    var n;
    const o = ((n = this.audioData) === null || n === void 0 ? void 0 : n.numberOfChannels) || 1;
    if (e == null) return 128;
    if (!isNaN(Number(e))) return Number(e);
    if (e === "auto") {
      const r = this.parent.clientHeight || 128;
      return t != null && t.every((s) => !s.overlay) ? r / o : r;
    }
    return 128;
  }
  initHtml() {
    const e = document.createElement("div"), t = e.attachShadow({ mode: "open" });
    return t.innerHTML = `
      <style>
        :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, t];
  }
  setOptions(e) {
    if (this.options.container !== e.container) {
      const t = this.parentFromOptionsContainer(e.container);
      t.appendChild(this.container), this.parent = t;
    }
    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: t } = this.scrollContainer, n = t * e;
    this.setScroll(n);
  }
  destroy() {
    var e, t;
    this.subscriptions.forEach((n) => n()), this.container.remove(), (e = this.resizeObserver) === null || e === void 0 || e.disconnect(), (t = this.unsubscribeOnScroll) === null || t === void 0 || t.call(this);
  }
  createDelay(e = 10) {
    let t, n;
    const o = () => {
      t && clearTimeout(t), n && n();
    };
    return this.timeouts.push(o), () => new Promise((r, s) => {
      o(), n = s, t = setTimeout(() => {
        t = void 0, n = void 0, r();
      }, e);
    });
  }
  convertColorValues(e) {
    if (!Array.isArray(e)) return e || "";
    if (e.length < 2) return e[0] || "";
    const t = document.createElement("canvas"), n = t.getContext("2d"), o = t.height * (window.devicePixelRatio || 1), r = n.createLinearGradient(0, 0, 0, o), s = 1 / (e.length - 1);
    return e.forEach((a, l) => {
      const u = l * s;
      r.addColorStop(u, a);
    }), r;
  }
  getPixelRatio() {
    return Math.max(1, window.devicePixelRatio || 1);
  }
  renderBarWaveform(e, t, n, o) {
    const r = e[0], s = e[1] || e[0], a = r.length, { width: l, height: u } = n.canvas, c = u / 2, d = this.getPixelRatio(), h = t.barWidth ? t.barWidth * d : 1, f = t.barGap ? t.barGap * d : t.barWidth ? h / 2 : 0, m = t.barRadius || 0, g = l / (h + f) / a, p = m && "roundRect" in n ? "roundRect" : "rect";
    n.beginPath();
    let _ = 0, y = 0, v = 0;
    for (let C = 0; C <= a; C++) {
      const M = Math.round(C * g);
      if (M > _) {
        const D = Math.round(y * c * o), b = D + Math.round(v * c * o) || 1;
        let E = c - D;
        t.barAlign === "top" ? E = 0 : t.barAlign === "bottom" && (E = u - b), n[p](_ * (h + f), E, h, b, m), _ = M, y = 0, v = 0;
      }
      const k = Math.abs(r[C] || 0), P = Math.abs(s[C] || 0);
      k > y && (y = k), P > v && (v = P);
    }
    n.fill(), n.closePath();
  }
  renderLineWaveform(e, t, n, o) {
    const r = (s) => {
      const a = e[s] || e[0], l = a.length, { height: u } = n.canvas, c = u / 2, d = n.canvas.width / l;
      n.moveTo(0, c);
      let h = 0, f = 0;
      for (let m = 0; m <= l; m++) {
        const g = Math.round(m * d);
        if (g > h) {
          const _ = c + (Math.round(f * c * o) || 1) * (s === 0 ? -1 : 1);
          n.lineTo(h, _), h = g, f = 0;
        }
        const p = Math.abs(a[m] || 0);
        p > f && (f = p);
      }
      n.lineTo(h, c);
    };
    n.beginPath(), r(0), r(1), n.fill(), n.closePath();
  }
  renderWaveform(e, t, n) {
    if (n.fillStyle = this.convertColorValues(t.waveColor), t.renderFunction) return void t.renderFunction(e, n);
    let o = t.barHeight || 1;
    if (t.normalize) {
      const r = Array.from(e[0]).reduce((s, a) => Math.max(s, Math.abs(a)), 0);
      o = r ? 1 / r : 1;
    }
    t.barWidth || t.barGap || t.barAlign ? this.renderBarWaveform(e, t, n, o) : this.renderLineWaveform(e, t, n, o);
  }
  renderSingleCanvas(e, t, n, o, r, s, a) {
    const l = this.getPixelRatio(), u = document.createElement("canvas");
    u.width = Math.round(n * l), u.height = Math.round(o * l), u.style.width = `${n}px`, u.style.height = `${o}px`, u.style.left = `${Math.round(r)}px`, s.appendChild(u);
    const c = u.getContext("2d");
    if (this.renderWaveform(e, t, c), u.width > 0 && u.height > 0) {
      const d = u.cloneNode(), h = d.getContext("2d");
      h.drawImage(u, 0, 0), h.globalCompositeOperation = "source-in", h.fillStyle = this.convertColorValues(t.progressColor), h.fillRect(0, 0, u.width, u.height), a.appendChild(d);
    }
  }
  renderMultiCanvas(e, t, n, o, r, s) {
    const a = this.getPixelRatio(), { clientWidth: l } = this.scrollContainer, u = n / a;
    let c = Math.min(Ls.MAX_CANVAS_WIDTH, l, u), d = {};
    if (t.barWidth || t.barGap) {
      const p = t.barWidth || 0.5, _ = p + (t.barGap || p / 2);
      c % _ != 0 && (c = Math.floor(c / _) * _);
    }
    const h = (p) => {
      if (p < 0 || p >= f || d[p]) return;
      d[p] = !0;
      const _ = p * c, y = Math.min(u - _, c);
      if (y <= 0) return;
      const v = e.map((C) => {
        const M = Math.floor(_ / u * C.length), k = Math.floor((_ + y) / u * C.length);
        return C.slice(M, k);
      });
      this.renderSingleCanvas(v, t, y, o, _, r, s);
    }, f = Math.ceil(u / c);
    if (!this.isScrollable) {
      for (let p = 0; p < f; p++) h(p);
      return;
    }
    const m = this.scrollContainer.scrollLeft / u, g = Math.floor(m * f);
    h(g - 1), h(g), h(g + 1), f > 1 && (this.unsubscribeOnScroll = this.on("scroll", () => {
      const { scrollLeft: p } = this.scrollContainer, _ = Math.floor(p / u * f);
      Object.keys(d).length > Ls.MAX_NODES && (r.innerHTML = "", s.innerHTML = "", d = {}), h(_ - 1), h(_), h(_ + 1);
    }));
  }
  renderChannel(e, t, n, o) {
    var { overlay: r } = t, s = function(c, d) {
      var h = {};
      for (var f in c) Object.prototype.hasOwnProperty.call(c, f) && d.indexOf(f) < 0 && (h[f] = c[f]);
      if (c != null && typeof Object.getOwnPropertySymbols == "function") {
        var m = 0;
        for (f = Object.getOwnPropertySymbols(c); m < f.length; m++) d.indexOf(f[m]) < 0 && Object.prototype.propertyIsEnumerable.call(c, f[m]) && (h[f[m]] = c[f[m]]);
      }
      return h;
    }(t, ["overlay"]);
    const a = document.createElement("div"), l = this.getHeight(s.height, s.splitChannels);
    a.style.height = `${l}px`, r && o > 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, n, l, a, u);
  }
  render(e) {
    return Oe(this, void 0, void 0, function* () {
      var t;
      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 n = this.getPixelRatio(), o = this.scrollContainer.clientWidth, r = Math.ceil(e.duration * (this.options.minPxPerSec || 0));
      this.isScrollable = r > o;
      const s = this.options.fillParent && !this.isScrollable, a = (s ? o : r) * n;
      if (this.wrapper.style.width = s ? "100%" : `${r}px`, this.scrollContainer.style.overflowX = this.isScrollable ? "auto" : "hidden", this.scrollContainer.classList.toggle("noScrollbar", !!this.options.hideScrollbar), this.cursor.style.backgroundColor = `${this.options.cursorColor || this.options.progressColor}`, this.cursor.style.width = `${this.options.cursorWidth}px`, this.audioData = e, this.emit("render"), this.options.splitChannels) for (let l = 0; l < e.numberOfChannels; l++) {
        const u = Object.assign(Object.assign({}, this.options), (t = this.options.splitChannels) === null || t === void 0 ? void 0 : t[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: t } = this.scrollContainer, { right: n } = this.progressWrapper.getBoundingClientRect();
    if (this.render(this.audioData), this.isScrollable && t !== this.scrollContainer.scrollWidth) {
      const { right: o } = this.progressWrapper.getBoundingClientRect();
      let r = o - n;
      r *= 2, r = r < 0 ? Math.floor(r) : Math.ceil(r), r /= 2, this.scrollContainer.scrollLeft += r;
    }
  }
  zoom(e) {
    this.options.minPxPerSec = e, this.reRender();
  }
  scrollIntoView(e, t = !1) {
    const { scrollLeft: n, scrollWidth: o, clientWidth: r } = this.scrollContainer, s = e * o, a = n, l = n + r, u = r / 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 - n - u;
      t && this.options.autoCenter && c > 0 && (this.scrollContainer.scrollLeft += Math.min(c, 10));
    }
    {
      const c = this.scrollContainer.scrollLeft, d = c / o, h = (c + r) / o;
      this.emit("scroll", d, h, c, c + r);
    }
  }
  renderProgress(e, t) {
    if (isNaN(e)) return;
    const n = 100 * e;
    this.canvasWrapper.style.clipPath = `polygon(${n}% 0, 100% 0, 100% 100%, ${n}% 100%)`, this.progressWrapper.style.width = `${n}%`, this.cursor.style.left = `${n}%`, this.cursor.style.transform = `translateX(-${Math.round(n) === 100 ? this.options.cursorWidth : 0}px)`, this.isScrollable && this.options.autoScroll && this.scrollIntoView(e, t);
  }
  exportImage(e, t, n) {
    return Oe(this, void 0, void 0, function* () {
      const o = this.canvasWrapper.querySelectorAll("canvas");
      if (!o.length) throw new Error("No waveform data");
      if (n === "dataURL") {
        const r = Array.from(o).map((s) => s.toDataURL(e, t));
        return Promise.resolve(r);
      }
      return Promise.all(Array.from(o).map((r) => new Promise((s, a) => {
        r.toBlob((l) => {
          l ? s(l) : a(new Error("Could not export image"));
        }, e, t);
      })));
    });
  }
};
Ms.MAX_CANVAS_WIDTH = 8e3, Ms.MAX_NODES = 10;
let Uh = class extends Li {
  constructor() {
    super(...arguments), this.unsubscribe = () => {
    };
  }
  start() {
    this.unsubscribe = this.on("tick", () => {
      requestAnimationFrame(() => {
        this.emit("tick");
      });
    }), this.emit("tick");
  }
  stop() {
    this.unsubscribe();
  }
  destroy() {
    this.unsubscribe();
  }
}, Br = class extends Li {
  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 Oe(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((t) => {
      if (t.status >= 400) throw new Error(`Failed to fetch ${e}: ${t.status} (${t.statusText})`);
      return t.arrayBuffer();
    }).then((t) => this.currentSrc !== e ? null : this.audioContext.decodeAudioData(t)).then((t) => {
      this.currentSrc === e && (this.buffer = t, 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 t = this.playedDuration * this._playbackRate;
    t >= this.duration && (t = 0, this.playedDuration = 0), this.bufferNode.start(this.audioContext.currentTime, t), 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 Oe(this, void 0, void 0, function* () {
      this.paused && (this._play(), this.emit("play"));
    });
  }
  pause() {
    this.paused || (this._pause(), this.emit("pause"));
  }
  stopAt(e) {
    var t, n;
    const o = e - this.currentTime;
    (t = this.bufferNode) === null || t === void 0 || t.stop(this.audioContext.currentTime + o), (n = this.bufferNode) === null || n === void 0 || n.addEventListener("ended", () => {
      this.bufferNode = null, this.pause();
    }, { once: !0 });
  }
  setSinkId(e) {
    return Oe(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 t = !this.paused;
    t && this._pause(), this.playedDuration = e / this._playbackRate, t && this._play(), this.emit("seeking"), this.emit("timeupdate");
  }
  get duration() {
    var e, t;
    return (e = this._duration) !== null && e !== void 0 ? e : ((t = this.buffer) === null || t === void 0 ? void 0 : t.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 t = this.buffer.numberOfChannels;
    for (let n = 0; n < t; n++) e.push(this.buffer.getChannelData(n));
    return e;
  }
};
const Fh = { waveColor: "#999", progressColor: "#555", cursorWidth: 1, minPxPerSec: 0, fillParent: !0, interact: !0, dragToSeek: !1, autoScroll: !0, autoCenter: !0, sampleRate: 8e3 };
let Fn = class Ta extends Ih {
  static create(e) {
    return new Ta(e);
  }
  constructor(e) {
    const t = e.media || (e.backend === "WebAudio" ? new Br() : void 0);
    super({ media: t, 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({}, Fh, e), this.timer = new Uh();
    const n = t ? void 0 : this.getMediaElement();
    this.renderer = new Ms(this.options, n), this.initPlayerEvents(), this.initRendererEvents(), this.initTimerEvents(), this.initPlugins();
    const o = this.options.url || this.getSrc() || "";
    Promise.resolve().then(() => {
      this.emit("init");
      const { peaks: r, duration: s } = this.options;
      (o || r && s) && this.load(o, r, s).catch(() => null);
    });
  }
  updateProgress(e = this.getCurrentTime()) {
    return this.options.waveColor !== this.options.progressColor && 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, t) => {
      this.options.interact && (this.seekTo(e), this.emit("interaction", e * this.getDuration()), this.emit("click", e, t));
    }), this.renderer.on("dblclick", (e, t) => {
      this.emit("dblclick", e, t);
    }), this.renderer.on("scroll", (e, t, n, o) => {
      const r = this.getDuration();
      this.emit("scroll", e * r, t * r, n, o);
    }), 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", (t) => {
        if (!this.options.interact) return;
        let n;
        this.options.waveColor !== this.options.progressColor && this.renderer.renderProgress(t), clearTimeout(e), this.isPlaying() ? n = 0 : this.options.dragToSeek === !0 ? n = 200 : typeof this.options.dragToSeek == "object" && this.options.dragToSeek !== void 0 && (n = this.options.dragToSeek.debounceTime), e = setTimeout(() => {
          this.seekTo(t);
        }, n), this.emit("interaction", t * this.getDuration()), this.emit("drag", t);
      }));
    }
  }
  initPlugins() {
    var e;
    !((e = this.options.plugins) === null || e === void 0) && e.length && this.options.plugins.forEach((t) => {
      this.registerPlugin(t);
    });
  }
  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((t) => t !== 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 t = e / this.getDuration();
    this.renderer.setScrollPercentage(t);
  }
  getActivePlugins() {
    return this.plugins;
  }
  loadAudio(e, t, n, o) {
    return Oe(this, void 0, void 0, function* () {
      var r;
      if (this.emit("load", e), !this.options.media && this.isPlaying() && this.pause(), this.decodedData = null, !t && !n) {
        const a = this.options.fetchParams || {};
        window.AbortController && !a.signal && (this.abortController = new AbortController(), a.signal = (r = this.abortController) === null || r === void 0 ? void 0 : r.signal);
        const l = (u) => this.emit("loading", u);
        t = yield Bh.fetchBlob(e, l, a);
      }
      this.setSrc(e, t);
      const s = yield new Promise((a) => {
        const l = o || this.getDuration();
        l ? a(l) : this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata", () => a(this.getDuration()), { once: !0 }));
      });
      if (!e && !t) {
        const a = this.getMediaElement();
        a instanceof Br && (a.duration = s);
      }
      if (n) this.decodedData = Nr.createBuffer(n, s || 0);
      else if (t) {
        const a = yield t.arrayBuffer();
        this.decodedData = yield Nr.decode(a, this.options.sampleRate);
      }
      this.decodedData && (this.emit("decode", this.getDuration()), this.renderer.render(this.decodedData)), this.emit("ready", this.getDuration());
    });
  }
  load(e, t, n) {
    return Oe(this, void 0, void 0, function* () {
      try {
        return yield this.loadAudio(e, void 0, t, n);
      } catch (o) {
        throw this.emit("error", o), o;
      }
    });
  }
  loadBlob(e, t, n) {
    return Oe(this, void 0, void 0, function* () {
      try {
        return yield this.loadAudio("", e, t, n);
      } catch (o) {
        throw this.emit("error", o), o;
      }
    });
  }
  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: t = 8e3, precision: n = 1e4 } = {}) {
    if (!this.decodedData) throw new Error("The audio has not been decoded yet");
    const o = Math.min(e, this.decodedData.numberOfChannels), r = [];
    for (let s = 0; s < o; s++) {
      const a = this.decodedData.getChannelData(s), l = [], u = a.length / t;
      for (let c = 0; c < t; c++) {
        const d = a.slice(Math.floor(c * u), Math.ceil((c + 1) * u));
        let h = 0;
        for (let f = 0; f < d.length; f++) {
          const m = d[f];
          Math.abs(m) > Math.abs(h) && (h = m);
        }
        l.push(Math.round(h * n) / n);
      }
      r.push(l);
    }
    return r;
  }
  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 t = this.getDuration() * e;
    this.setTime(t);
  }
  playPause() {
    return Oe(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 Oe(this, arguments, void 0, function* (e = "image/png", t = 1, n = "dataURL") {
      return this.renderer.exportImage(e, t, n);
    });
  }
  destroy() {
    var e;
    this.emit("destroy"), (e = this.abortController) === null || e === void 0 || e.abort(), this.plugins.forEach((t) => t.destroy()), this.subscriptions.forEach((t) => t()), this.unsubscribePlayerEvents(), this.timer.destroy(), this.renderer.destroy(), super.destroy();
  }
};
Fn.BasePlugin = class extends Li {
  constructor(i) {
    super(), this.subscriptions = [], this.options = i;
  }
  onInit() {
  }
  _init(i) {
    this.wavesurfer = i, this.onInit();
  }
  destroy() {
    this.emit("destroy"), this.subscriptions.forEach((i) => i());
  }
}, Fn.dom = zh;
let qa = class {
  constructor() {
    this.listeners = {};
  }
  on(e, t, n) {
    if (this.listeners[e] || (this.listeners[e] = /* @__PURE__ */ new Set()), this.listeners[e].add(t), n == null ? void 0 : n.once) {
      const o = () => {
        this.un(e, o), this.un(e, t);
      };
      return this.on(e, o), o;
    }
    return () => this.un(e, t);
  }
  un(e, t) {
    var n;
    (n = this.listeners[e]) === null || n === void 0 || n.delete(t);
  }
  once(e, t) {
    return this.on(e, t, { once: !0 });
  }
  unAll() {
    this.listeners = {};
  }
  emit(e, ...t) {
    this.listeners[e] && this.listeners[e].forEach((n) => n(...t));
  }
}, Gh = class extends qa {
  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());
  }
}, Vh = class extends qa {
  constructor() {
    super(), this.gamepad = null, this.buttonStates = [], this.axeValues = [], this.requestUpdateID = 0, window.addEventListener("gamepadconnected", (e) => {
      this.gamepad = e.gamepad, this.buttonStates = new Array(this.gamepad.buttons.length).fill(!1), this.axeValues = new Array(this.gamepad.axes.length).fill(0);
    }), window.addEventListener("gamepaddisconnected", (e) => {
      this.gamepad = null, window.cancelAnimationFrame(this.requestUpdateID);
    }), this.poll = this.poll.bind(this);
  }
  start() {
    setInterval(this.poll, 1e3);
  }
  isButtontPressed(e) {
    return this.buttonStates[e];
  }
  checkButtonEvent() {
    if (this.gamepad) {
      console.log(this.buttonStates);
      for (let e = 0; e < this.gamepad.buttons.length; e++) {
        const t = this.gamepad.buttons[e].value > 0;
        t && console.log("pressed: " + e), t && !this.buttonStates[e] ? this.emit("button-pressed", { idx: e }) : !t && this.buttonStates[e] && this.emit("button-released", { idx: e }), this.buttonStates[e] = t;
      }
    }
  }
  checkAxeEvent() {
    if (this.gamepad) for (let e = 0; e < this.gamepad.axes.length; e++) {
      const t = this.gamepad.axes[e];
      Math.abs(t) < 0.01 && Math.abs(this.axeValues[e]) > 0.01 ? this.emit("axe-released", { idx: e, value: t }) : Math.abs(t) > 0.01 ? this.emit("axe-pushed", { idx: e, value: t }) : Math.abs(t - this.axeValues[e]) > 0.01 && this.emit("axe-value-updated", { idx: e, value: t }), this.axeValues[e] = t;
    }
  }
  poll() {
    this.gamepad && (this.checkButtonEvent(), this.checkAxeEvent());
  }
}, Hh = class ja extends Gh {
  constructor(e) {
    super(e), this.gamepadControl = new Vh();
  }
  static create(e) {
    return new ja(e);
  }
  isButtonPressed(e) {
    return this.gamepadControl.isButtontPressed(e);
  }
  on(e, t, n) {
    return this.gamepadControl.on(e, t, n);
  }
  onInit() {
    if (!this.wavesurfer) throw Error("Wavesurfer is not initialized");
    this.gamepadControl.start(), this.subscriptions.push();
  }
}, Oi = class {
  constructor() {
    this.listeners = {};
  }
  on(e, t, n) {
    if (this.listeners[e] || (this.listeners[e] = /* @__PURE__ */ new Set()), this.listeners[e].add(t), n == null ? void 0 : n.once) {
      const o = () => {
        this.un(e, o), this.un(e, t);
      };
      return this.on(e, o), o;
    }
    return () => this.un(e, t);
  }
  un(e, t) {
    var n;
    (n = this.listeners[e]) === null || n === void 0 || n.delete(t);
  }
  once(e, t) {
    return this.on(e, t, { once: !0 });
  }
  unAll() {
    this.listeners = {};
  }
  emit(e, ...t) {
    this.listeners[e] && this.listeners[e].forEach((n) => n(...t));
  }
}, Na = class extends Oi {
  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 Pe(i, e, t, n) {
  return new (t || (t = Promise))(function(o, r) {
    function s(u) {
      try {
        l(n.next(u));
      } catch (c) {
        r(c);
      }
    }
    function a(u) {
      try {
        l(n.throw(u));
      } catch (c) {
        r(c);
      }
    }
    function l(u) {
      var c;
      u.done ? o(u.value) : (c = u.value, c instanceof t ? c : new t(function(d) {
        d(c);
      })).then(s, a);
    }
    l((n = n.apply(i, e || [])).next());
  });
}
const Ir = { decode: function(i, e) {
  return Pe(this, void 0, void 0, function* () {
    const t = new AudioContext({ sampleRate: e });
    return t.decodeAudioData(i).finally(() => t.close());
  });
}, createBuffer: function(i, e) {
  return typeof i[0] == "number" && (i = [i]), function(t) {
    const n = t[0];
    if (n.some((o) => o > 1 || o < -1)) {
      const o = n.length;
      let r = 0;
      for (let s = 0; s < o; s++) {
        const a = Math.abs(n[s]);
        a > r && (r = a);
      }
      for (const s of t) for (let a = 0; a < o; a++) s[a] /= r;
    }
  }(i), { duration: e, length: i[0].length, sampleRate: i[0].length / e, numberOfChannels: i.length, getChannelData: (t) => i == null ? void 0 : i[t], copyFromChannel: AudioBuffer.prototype.copyFromChannel, copyToChannel: AudioBuffer.prototype.copyToChannel };
} };
function za(i, e) {
  const t = e.xmlns ? document.createElementNS(e.xmlns, i) : document.createElement(i);
  for (const [n, o] of Object.entries(e)) if (n === "children") for (const [r, s] of Object.entries(e)) typeof s == "string" ? t.appendChild(document.createTextNode(s)) : t.appendChild(za(r, s));
  else n === "style" ? Object.assign(t.style, o) : n === "textContent" ? t.textContent = o : t.setAttribute(n, o.toString());
  return t;
}
function fo(i, e, t) {
  const n = za(i, e || {});
  return t == null || t.appendChild(n), n;
}
var Zh = Object.freeze({ __proto__: null, createElement: fo, default: fo });
const Xh = { fetchBlob: function(i, e, t) {
  return Pe(this, void 0, void 0, function* () {
    const n = yield fetch(i, t);
    if (n.status >= 400) throw new Error(`Failed to fetch ${i}: ${n.status} (${n.statusText})`);
    return function(o, r) {
      Pe(this, void 0, void 0, function* () {
        if (!o.body || !o.headers) return;
        const s = o.body.getReader(), a = Number(o.headers.get("Content-Length")) || 0;
        let l = 0;
        const u = (d) => Pe(this, void 0, void 0, function* () {
          l += (d == null ? void 0 : d.length) || 0;
          const h = Math.round(l / a * 100);
          r(h);
        }), c = () => Pe(this, void 0, void 0, function* () {
          let d;
          try {
            d = yield s.read();
          } catch {
            return;
          }
          d.done || (u(d.value), yield c());
        });
        c();
      });
    }(n.clone(), e), n.blob();
  });
} };
class Jh extends Oi {
  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, t, n) {
    return this.media.addEventListener(e, t, n), () => this.media.removeEventListener(e, t, n);
  }
  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, t) {
    const n = this.getSrc();
    if (e && n === e) return;
    this.revokeSrc();
    const o = t instanceof Blob && (this.canPlayType(t.type) || !e) ? URL.createObjectURL(t) : e;
    try {
      this.media.src = o;
    } 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 Pe(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, t) {
    t != null && (this.media.preservesPitch = t), this.media.playbackRate = e;
  }
  getMediaElement() {
    return this.media;
  }
  setSinkId(e) {
    return this.media.setSinkId(e);
  }
}
class Gn extends Oi {
  constructor(e, t) {
    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 n = this.parentFromOptionsContainer(e.container);
    this.parent = n;
    const [o, r] = this.initHtml();
    n.appendChild(o), this.container = o, this.scrollContainer = r.querySelector(".scroll"), this.wrapper = r.querySelector(".wrapper"), this.canvasWrapper = r.querySelector(".canvases"), this.progressWrapper = r.querySelector(".progress"), this.cursor = r.querySelector(".cursor"), t && r.appendChild(t), this.initEvents();
  }
  parentFromOptionsContainer(e) {
    let t;
    if (typeof e == "string" ? t = document.querySelector(e) : e instanceof HTMLElement && (t = e), !t) throw new Error("Container not found");
    return t;
  }
  initEvents() {
    const e = (t) => {
      const n = this.wrapper.getBoundingClientRect(), o = t.clientX - n.left, r = t.clientY - n.top;
      return [o / n.width, r / n.height];
    };
    if (this.wrapper.addEventListener("click", (t) => {
      const [n, o] = e(t);
      this.emit("click", n, o);
    }), this.wrapper.addEventListener("dblclick", (t) => {
      const [n, o] = e(t);
      this.emit("dblclick", n, o);
    }), this.options.dragToSeek !== !0 && typeof this.options.dragToSeek != "object" || this.initDrag(), this.scrollContainer.addEventListener("scroll", () => {
      const { scrollLeft: t, scrollWidth: n, clientWidth: o } = this.scrollContainer, r = t / n, s = (t + o) / n;
      this.emit("scroll", r, s, t, t + o);
    }), typeof ResizeObserver == "function") {
      const t = this.createDelay(100);
      this.resizeObserver = new ResizeObserver(() => {
        t().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, t, n, o, r = 3, s = 0, a = 100) {
      if (!e) return () => {
      };
      const l = matchMedia("(pointer: coarse)").matches;
      let u = () => {
      };
      const c = (d) => {
        if (d.button !== s) return;
        d.preventDefault(), d.stopPropagation();
        let h = d.clientX, f = d.clientY, m = !1;
        const g = Date.now(), p = (M) => {
          if (M.preventDefault(), M.stopPropagation(), l && Date.now() - g < a) return;
          const k = M.clientX, P = M.clientY, D = k - h, b = P - f;
          if (m || Math.abs(D) > r || Math.abs(b) > r) {
            const E = e.getBoundingClientRect(), { left: U, top: T } = E;
            m || (n == null || n(h - U, f - T), m = !0), t(D, b, k - U, P - T), h = k, f = P;
          }
        }, _ = (M) => {
          if (m) {
            const k = M.clientX, P = M.clientY, D = e.getBoundingClientRect(), { left: b, top: E } = D;
            o == null || o(k - b, P - E);
          }
          u();
        }, y = (M) => {
          M.relatedTarget && M.relatedTarget !== document.documentElement || _(M);
        }, v = (M) => {
          m && (M.stopPropagation(), M.preventDefault());
        }, C = (M) => {
          m && M.preventDefault();
        };
        document.addEventListener("pointermove", p), document.addEventListener("pointerup", _), document.addEventListener("pointerout", y), document.addEventListener("pointercancel", y), document.addEventListener("touchmove", C, { passive: !1 }), document.addEventListener("click", v, { capture: !0 }), u = () => {
          document.removeEventListener("pointermove", p), document.removeEventListener("pointerup", _), document.removeEventListener("pointerout", y), document.removeEventListener("pointercancel", y), document.removeEventListener("touchmove", C), setTimeout(() => {
            document.removeEventListener("click", v, { capture: !0 });
          }, 10);
        };
      };
      return e.addEventListener("pointerdown", c), () => {
        u(), e.removeEventListener("pointerdown", c);
      };
    }(this.wrapper, (e, t, n) => {
      this.emit("drag", Math.max(0, Math.min(1, n / 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, t) {
    var n;
    const o = ((n = this.audioData) === null || n === void 0 ? void 0 : n.numberOfChannels) || 1;
    if (e == null) return 128;
    if (!isNaN(Number(e))) return Number(e);
    if (e === "auto") {
      const r = this.parent.clientHeight || 128;
      return t != null && t.every((s) => !s.overlay) ? r / o : r;
    }
    return 128;
  }
  initHtml() {
    const e = document.createElement("div"), t = e.attachShadow({ mode: "open" });
    return t.innerHTML = `
      <style>
        :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, t];
  }
  setOptions(e) {
    if (this.options.container !== e.container) {
      const t = this.parentFromOptionsContainer(e.container);
      t.appendChild(this.container), this.parent = t;
    }
    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: t } = this.scrollContainer, n = t * e;
    this.setScroll(n);
  }
  destroy() {
    var e, t;
    this.subscriptions.forEach((n) => n()), this.container.remove(), (e = this.resizeObserver) === null || e === void 0 || e.disconnect(), (t = this.unsubscribeOnScroll) === null || t === void 0 || t.call(this);
  }
  createDelay(e = 10) {
    let t, n;
    const o = () => {
      t && clearTimeout(t), n && n();
    };
    return this.timeouts.push(o), () => new Promise((r, s) => {
      o(), n = s, t = setTimeout(() => {
        t = void 0, n = void 0, r();
      }, e);
    });
  }
  convertColorValues(e) {
    if (!Array.isArray(e)) return e || "";
    if (e.length < 2) return e[0] || "";
    const t = document.createElement("canvas"), n = t.getContext("2d"), o = t.height * (window.devicePixelRatio || 1), r = n.createLinearGradient(0, 0, 0, o), s = 1 / (e.length - 1);
    return e.forEach((a, l) => {
      const u = l * s;
      r.addColorStop(u, a);
    }), r;
  }
  getPixelRatio() {
    return Math.max(1, window.devicePixelRatio || 1);
  }
  renderBarWaveform(e, t, n, o) {
    const r = e[0], s = e[1] || e[0], a = r.length, { width: l, height: u } = n.canvas, c = u / 2, d = this.getPixelRatio(), h = t.barWidth ? t.barWidth * d : 1, f = t.barGap ? t.barGap * d : t.barWidth ? h / 2 : 0, m = t.barRadius || 0, g = l / (h + f) / a, p = m && "roundRect" in n ? "roundRect" : "rect";
    n.beginPath();
    let _ = 0, y = 0, v = 0;
    for (let C = 0; C <= a; C++) {
      const M = Math.round(C * g);
      if (M > _) {
        const D = Math.round(y * c * o), b = D + Math.round(v * c * o) || 1;
        let E = c - D;
        t.barAlign === "top" ? E = 0 : t.barAlign === "bottom" && (E = u - b), n[p](_ * (h + f), E, h, b, m), _ = M, y = 0, v = 0;
      }
      const k = Math.abs(r[C] || 0), P = Math.abs(s[C] || 0);
      k > y && (y = k), P > v && (v = P);
    }
    n.fill(), n.closePath();
  }
  renderLineWaveform(e, t, n, o) {
    const r = (s) => {
      const a = e[s] || e[0], l = a.length, { height: u } = n.canvas, c = u / 2, d = n.canvas.width / l;
      n.moveTo(0, c);
      let h = 0, f = 0;
      for (let m = 0; m <= l; m++) {
        const g = Math.round(m * d);
        if (g > h) {
          const _ = c + (Math.round(f * c * o) || 1) * (s === 0 ? -1 : 1);
          n.lineTo(h, _), h = g, f = 0;
        }
        const p = Math.abs(a[m] || 0);
        p > f && (f = p);
      }
      n.lineTo(h, c);
    };
    n.beginPath(), r(0), r(1), n.fill(), n.closePath();
  }
  renderWaveform(e, t, n) {
    if (n.fillStyle = this.convertColorValues(t.waveColor), t.renderFunction) return void t.renderFunction(e, n);
    let o = t.barHeight || 1;
    if (t.normalize) {
      const r = Array.from(e[0]).reduce((s, a) => Math.max(s, Math.abs(a)), 0);
      o = r ? 1 / r : 1;
    }
    t.barWidth || t.barGap || t.barAlign ? this.renderBarWaveform(e, t, n, o) : this.renderLineWaveform(e, t, n, o);
  }
  renderSingleCanvas(e, t, n, o, r, s, a) {
    const l = this.getPixelRatio(), u = document.createElement("canvas");
    u.width = Math.round(n * l), u.height = Math.round(o * l), u.style.width = `${n}px`, u.style.height = `${o}px`, u.style.left = `${Math.round(r)}px`, s.appendChild(u);
    const c = u.getContext("2d");
    if (this.renderWaveform(e, t, c), u.width > 0 && u.height > 0) {
      const d = u.cloneNode(), h = d.getContext("2d");
      h.drawImage(u, 0, 0), h.globalCompositeOperation = "source-in", h.fillStyle = this.convertColorValues(t.progressColor), h.fillRect(0, 0, u.width, u.height), a.appendChild(d);
    }
  }
  renderMultiCanvas(e, t, n, o, r, s) {
    const a = this.getPixelRatio(), { clientWidth: l } = this.scrollContainer, u = n / a;
    let c = Math.min(Gn.MAX_CANVAS_WIDTH, l, u), d = {};
    if (t.barWidth || t.barGap) {
      const p = t.barWidth || 0.5, _ = p + (t.barGap || p / 2);
      c % _ != 0 && (c = Math.floor(c / _) * _);
    }
    const h = (p) => {
      if (p < 0 || p >= f || d[p]) return;
      d[p] = !0;
      const _ = p * c, y = Math.min(u - _, c);
      if (y <= 0) return;
      const v = e.map((C) => {
        const M = Math.floor(_ / u * C.length), k = Math.floor((_ + y) / u * C.length);
        return C.slice(M, k);
      });
      this.renderSingleCanvas(v, t, y, o, _, r, s);
    }, f = Math.ceil(u / c);
    if (!this.isScrollable) {
      for (let p = 0; p < f; p++) h(p);
      return;
    }
    const m = this.scrollContainer.scrollLeft / u, g = Math.floor(m * f);
    h(g - 1), h(g), h(g + 1), f > 1 && (this.unsubscribeOnScroll = this.on("scroll", () => {
      const { scrollLeft: p } = this.scrollContainer, _ = Math.floor(p / u * f);
      Object.keys(d).length > Gn.MAX_NODES && (r.innerHTML = "", s.innerHTML = "", d = {}), h(_ - 1), h(_), h(_ + 1);
    }));
  }
  renderChannel(e, t, n, o) {
    var { overlay: r } = t, s = function(c, d) {
      var h = {};
      for (var f in c) Object.prototype.hasOwnProperty.call(c, f) && d.indexOf(f) < 0 && (h[f] = c[f]);
      if (c != null && typeof Object.getOwnPropertySymbols == "function") {
        var m = 0;
        for (f = Object.getOwnPropertySymbols(c); m < f.length; m++) d.indexOf(f[m]) < 0 && Object.prototype.propertyIsEnumerable.call(c, f[m]) && (h[f[m]] = c[f[m]]);
      }
      return h;
    }(t, ["overlay"]);
    const a = document.createElement("div"), l = this.getHeight(s.height, s.splitChannels);
    a.style.height = `${l}px`, r && o > 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, n, l, a, u);
  }
  render(e) {
    return Pe(this, void 0, void 0, function* () {
      var t;
      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 n = this.getPixelRatio(), o = this.scrollContainer.clientWidth, r = Math.ceil(e.duration * (this.options.minPxPerSec || 0));
      this.isScrollable = r > o;
      const s = this.options.fillParent && !this.isScrollable, a = (s ? o : r) * n;
      if (this.wrapper.style.width = s ? "100%" : `${r}px`, this.scrollContainer.style.overflowX = this.isScrollable ? "auto" : "hidden", this.scrollContainer.classList.toggle("noScrollbar", !!this.options.hideScrollbar), this.cursor.style.backgroundColor = `${this.options.cursorColor || this.options.progressColor}`, this.cursor.style.width = `${this.options.cursorWidth}px`, this.audioData = e, this.emit("render"), this.options.splitChannels) for (let l = 0; l < e.numberOfChannels; l++) {
        const u = Object.assign(Object.assign({}, this.options), (t = this.options.splitChannels) === null || t === void 0 ? void 0 : t[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: t } = this.scrollContainer, { right: n } = this.progressWrapper.getBoundingClientRect();
    if (this.render(this.audioData), this.isScrollable && t !== this.scrollContainer.scrollWidth) {
      const { right: o } = this.progressWrapper.getBoundingClientRect();
      let r = o - n;
      r *= 2, r = r < 0 ? Math.floor(r) : Math.ceil(r), r /= 2, this.scrollContainer.scrollLeft += r;
    }
  }
  zoom(e) {
    this.options.minPxPerSec = e, this.reRender();
  }
  scrollIntoView(e, t = !1) {
    const { scrollLeft: n, scrollWidth: o, clientWidth: r } = this.scrollContainer, s = e * o, a = n, l = n + r, u = r / 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 - n - u;
      t && this.options.autoCenter && c > 0 && (this.scrollContainer.scrollLeft += Math.min(c, 10));
    }
    {
      const c = this.scrollContainer.scrollLeft, d = c / o, h = (c + r) / o;
      this.emit("scroll", d, h, c, c + r);
    }
  }
  renderProgress(e, t) {
    if (isNaN(e)) return;
    const n = 100 * e;
    this.canvasWrapper.style.clipPath = `polygon(${n}% 0, 100% 0, 100% 100%, ${n}% 100%)`, this.progressWrapper.style.width = `${n}%`, this.cursor.style.left = `${n}%`, this.cursor.style.transform = `translateX(-${Math.round(n) === 100 ? this.options.cursorWidth : 0}px)`, this.isScrollable && this.options.autoScroll && this.scrollIntoView(e, t);
  }
  exportImage(e, t, n) {
    return Pe(this, void 0, void 0, function* () {
      const o = this.canvasWrapper.querySelectorAll("canvas");
      if (!o.length) throw new Error("No waveform data");
      if (n === "dataURL") {
        const r = Array.from(o).map((s) => s.toDataURL(e, t));
        return Promise.resolve(r);
      }
      return Promise.all(Array.from(o).map((r) => new Promise((s, a) => {
        r.toBlob((l) => {
          l ? s(l) : a(new Error("Could not export image"));
        }, e, t);
      })));
    });
  }
}
Gn.MAX_CANVAS_WIDTH = 8e3, Gn.MAX_NODES = 10;
let Kh = class extends Oi {
  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 Ur extends Oi {
  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 Pe(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((t) => {
      if (t.status >= 400) throw new Error(`Failed to fetch ${e}: ${t.status} (${t.statusText})`);
      return t.arrayBuffer();
    }).then((t) => this.currentSrc !== e ? null : this.audioContext.decodeAudioData(t)).then((t) => {
      this.currentSrc === e && (this.buffer = t, 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 t = this.playedDuration * this._playbackRate;
    t >= this.duration && (t = 0, this.playedDuration = 0), this.bufferNode.start(this.audioContext.currentTime, t), 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 Pe(this, void 0, void 0, function* () {
      this.paused && (this._play(), this.emit("play"));
    });
  }
  pause() {
    this.paused || (this._pause(), this.emit("pause"));
  }
  stopAt(e) {
    var t, n;
    const o = e - this.currentTime;
    (t = this.bufferNode) === null || t === void 0 || t.stop(this.audioContext.currentTime + o), (n = this.bufferNode) === null || n === void 0 || n.addEventListener("ended", () => {
      this.bufferNode = null, this.pause();
    }, { once: !0 });
  }
  setSinkId(e) {
    return Pe(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 t = !this.paused;
    t && this._pause(), this.playedDuration = e / this._playbackRate, t && this._play(), this.emit("seeking"), this.emit("timeupdate");
  }
  get duration() {
    var e, t;
    return (e = this._duration) !== null && e !== void 0 ? e : ((t = this.buffer) === null || t === void 0 ? void 0 : t.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 t = this.buffer.numberOfChannels;
    for (let n = 0; n < t; n++) e.push(this.buffer.getChannelData(n));
    return e;
  }
}
const Yh = { waveColor: "#999", progressColor: "#555", cursorWidth: 1, minPxPerSec: 0, fillParent: !0, interact: !0, dragToSeek: !1, autoScroll: !0, autoCenter: !0, sampleRate: 8e3 };
class bi extends Jh {
  static create(e) {
    return new bi(e);
  }
  constructor(e) {
    const t = e.media || (e.backend === "WebAudio" ? new Ur() : void 0);
    super({ media: t, 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({}, Yh, e), this.timer = new Kh();
    const n = t ? void 0 : this.getMediaElement();
    this.renderer = new Gn(this.options, n), this.initPlayerEvents(), this.initRendererEvents(), this.initTimerEvents(), this.initPlugins();
    const o = this.options.url || this.getSrc() || "";
    Promise.resolve().then(() => {
      this.emit("init");
      const { peaks: r, duration: s } = this.options;
      (o || r && s) && this.load(o, r, s).catch(() => null);
    });
  }
  updateProgress(e = this.getCurrentTime()) {
    return this.options.waveColor !== this.options.progressColor && 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, t) => {
      this.options.interact && (this.seekTo(e), this.emit("interaction", e * this.getDuration()), this.emit("click", e, t));
    }), this.renderer.on("dblclick", (e, t) => {
      this.emit("dblclick", e, t);
    }), this.renderer.on("scroll", (e, t, n, o) => {
      const r = this.getDuration();
      this.emit("scroll", e * r, t * r, n, o);
    }), 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", (t) => {
        if (!this.options.interact) return;
        let n;
        this.options.waveColor !== this.options.progressColor && this.renderer.renderProgress(t), clearTimeout(e), this.isPlaying() ? n = 0 : this.options.dragToSeek === !0 ? n = 200 : typeof this.options.dragToSeek == "object" && this.options.dragToSeek !== void 0 && (n = this.options.dragToSeek.debounceTime), e = setTimeout(() => {
          this.seekTo(t);
        }, n), this.emit("interaction", t * this.getDuration()), this.emit("drag", t);
      }));
    }
  }
  initPlugins() {
    var e;
    !((e = this.options.plugins) === null || e === void 0) && e.length && this.options.plugins.forEach((t) => {
      this.registerPlugin(t);
    });
  }
  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((t) => t !== 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 t = e / this.getDuration();
    this.renderer.setScrollPercentage(t);
  }
  getActivePlugins() {
    return this.plugins;
  }
  loadAudio(e, t, n, o) {
    return Pe(this, void 0, void 0, function* () {
      var r;
      if (this.emit("load", e), !this.options.media && this.isPlaying() && this.pause(), this.decodedData = null, !t && !n) {
        const a = this.options.fetchParams || {};
        window.AbortController && !a.signal && (this.abortController = new AbortController(), a.signal = (r = this.abortController) === null || r === void 0 ? void 0 : r.signal);
        const l = (u) => this.emit("loading", u);
        t = yield Xh.fetchBlob(e, l, a);
      }
      this.setSrc(e, t);
      const s = yield new Promise((a) => {
        const l = o || this.getDuration();
        l ? a(l) : this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata", () => a(this.getDuration()), { once: !0 }));
      });
      if (!e && !t) {
        const a = this.getMediaElement();
        a instanceof Ur && (a.duration = s);
      }
      if (n) this.decodedData = Ir.createBuffer(n, s || 0);
      else if (t) {
        const a = yield t.arrayBuffer();
        this.decodedData = yield Ir.decode(a, this.options.sampleRate);
      }
      this.decodedData && (this.emit("decode", this.getDuration()), this.renderer.render(this.decodedData)), this.emit("ready", this.getDuration());
    });
  }
  load(e, t, n) {
    return Pe(this, void 0, void 0, function* () {
      try {
        return yield this.loadAudio(e, void 0, t, n);
      } catch (o) {
        throw this.emit("error", o), o;
      }
    });
  }
  loadBlob(e, t, n) {
    return Pe(this, void 0, void 0, function* () {
      try {
        return yield this.loadAudio("", e, t, n);
      } catch (o) {
        throw this.emit("error", o), o;
      }
    });
  }
  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: t = 8e3, precision: n = 1e4 } = {}) {
    if (!this.decodedData) throw new Error("The audio has not been decoded yet");
    const o = Math.min(e, this.decodedData.numberOfChannels), r = [];
    for (let s = 0; s < o; s++) {
      const a = this.decodedData.getChannelData(s), l = [], u = a.length / t;
      for (let c = 0; c < t; c++) {
        const d = a.slice(Math.floor(c * u), Math.ceil((c + 1) * u));
        let h = 0;
        for (let f = 0; f < d.length; f++) {
          const m = d[f];
          Math.abs(m) > Math.abs(h) && (h = m);
        }
        l.push(Math.round(h * n) / n);
      }
      r.push(l);
    }
    return r;
  }
  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 t = this.getDuration() * e;
    this.setTime(t);
  }
  playPause() {
    return Pe(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 Pe(this, arguments, void 0, function* (e = "image/png", t = 1, n = "dataURL") {
      return this.renderer.exportImage(e, t, n);
    });
  }
  destroy() {
    var e;
    this.emit("destroy"), (e = this.abortController) === null || e === void 0 || e.abort(), this.plugins.forEach((t) => t.destroy()), this.subscriptions.forEach((t) => t()), this.unsubscribePlayerEvents(), this.timer.destroy(), this.renderer.destroy(), super.destroy();
  }
}
bi.BasePlugin = Na, bi.dom = Zh;
const Qh = { height: 50, overlayColor: "rgba(100, 100, 100, 0.1)", insertPosition: "afterend" };
class $s extends Na {
  constructor(e) {
    super(e), this.miniWavesurfer = null, this.container = null, this.options = Object.assign({}, Qh, e), this.minimapWrapper = this.initMinimapWrapper(), this.overlay = this.initOverlay();
  }
  static create(e) {
    return new $s(e);
  }
  getWaveform() {
    return this.miniWavesurfer;
  }
  onInit() {
    var e, t;
    if (!this.wavesurfer) throw Error("WaveSurfer is not initialized");
    this.options.container ? (typeof this.options.container == "string" ? this.container = document.querySelector(this.options.container) : this.options.container instanceof HTMLElement && (this.container = this.options.container), (e = this.container) === null || e === void 0 || e.appendChild(this.minimapWrapper)) : (this.container = this.wavesurfer.getWrapper().parentElement, (t = this.container) === null || t === void 0 || t.insertAdjacentElement(this.options.insertPosition, this.minimapWrapper)), this.initWaveSurferEvents(), Promise.resolve().then(() => {
      this.initMinimap();
    });
  }
  initMinimapWrapper() {
    return fo("div", { part: "minimap", style: { position: "relative" } });
  }
  initOverlay() {
    return fo("div", { part: "minimap-overlay", style: { position: "absolute", zIndex: "2", left: "0", top: "0", bottom: "0", transition: "left 100ms ease-out", pointerEvents: "none", backgroundColor: this.options.overlayColor } }, this.minimapWrapper);
  }
  initMinimap() {
    if (this.miniWavesurfer && (this.miniWavesurfer.destroy(), this.miniWavesurfer = null), !this.wavesurfer) return;
    const e = this.wavesurfer.getDecodedData(), t = this.wavesurfer.getMediaElement();
    if (!e || !t) return;
    const n = [];
    for (let o = 0; o < e.numberOfChannels; o++) n.push(e.getChannelData(o));
    this.miniWavesurfer = bi.create(Object.assign(Object.assign({}, this.options), { container: this.minimapWrapper, minPxPerSec: 0, fillParent: !0, media: t, peaks: n, duration: e.duration })), this.subscriptions.push(this.miniWavesurfer.on("audioprocess", (o) => {
      this.emit("audioprocess", o);
    }), this.miniWavesurfer.on("click", (o, r) => {
      this.emit("click", o, r);
    }), this.miniWavesurfer.on("dblclick", (o, r) => {
      this.emit("dblclick", o, r);
    }), this.miniWavesurfer.on("decode", (o) => {
      this.emit("decode", o);
    }), this.miniWavesurfer.on("destroy", () => {
      this.emit("destroy");
    }), this.miniWavesurfer.on("drag", (o) => {
      this.emit("drag", o);
    }), this.miniWavesurfer.on("dragend", (o) => {
      this.emit("dragend", o);
    }), this.miniWavesurfer.on("dragstart", (o) => {
      this.emit("dragstart", o);
    }), this.miniWavesurfer.on("interaction", () => {
      this.emit("interaction");
    }), this.miniWavesurfer.on("init", () => {
      this.emit("init");
    }), this.miniWavesurfer.on("ready", () => {
      this.emit("ready");
    }), this.miniWavesurfer.on("redraw", () => {
      this.emit("redraw");
    }), this.miniWavesurfer.on("redrawcomplete", () => {
      this.emit("redrawcomplete");
    }), this.miniWavesurfer.on("seeking", (o) => {
      this.emit("seeking", o);
    }), this.miniWavesurfer.on("timeupdate", (o) => {
      this.emit("timeupdate", o);
    }));
  }
  getOverlayWidth() {
    var e;
    const t = ((e = this.wavesurfer) === null || e === void 0 ? void 0 : e.getWrapper().clientWidth) || 1;
    return Math.round(this.minimapWrapper.clientWidth / t * 100);
  }
  onRedraw() {
    const e = this.getOverlayWidth();
    this.overlay.style.width = `${e}%`;
  }
  onScroll(e) {
    if (!this.wavesurfer) return;
    const t = this.wavesurfer.getDuration();
    this.overlay.style.left = e / t * 100 + "%";
  }
  initWaveSurferEvents() {
    this.wavesurfer && this.subscriptions.push(this.wavesurfer.on("decode", () => {
      this.initMinimap();
    }), this.wavesurfer.on("scroll", (e) => {
      this.onScroll(e);
    }), this.wavesurfer.on("redraw", () => {
      this.onRedraw();
    }));
  }
  destroy() {
    var e;
    (e = this.miniWavesurfer) === null || e === void 0 || e.destroy(), this.minimapWrapper.remove(), super.destroy();
  }
}
const {
  SvelteComponent: $h,
  append: xh,
  attr: It,
  detach: em,
  init: tm,
  insert: nm,
  noop: is,
  safe_not_equal: im,
  svg_element: Fr
} = window.__gradio__svelte__internal;
function om(i) {
  let e, t;
  return {
    c() {
      e = Fr("svg"), t = Fr("path"), It(t, "d", "m17.545 15.467-3.779-3.779a6.15 6.15 0 0 0 .898-3.21c0-3.417-2.961-6.377-6.378-6.377A6.185 6.185 0 0 0 2.1 8.287c0 3.416 2.961 6.377 6.377 6.377a6.15 6.15 0 0 0 3.115-.844l3.799 3.801a.953.953 0 0 0 1.346 0l.943-.943c.371-.371.236-.84-.135-1.211zM4.004 8.287a4.282 4.282 0 0 1 4.282-4.283c2.366 0 4.474 2.107 4.474 4.474a4.284 4.284 0 0 1-4.283 4.283c-2.366-.001-4.473-2.109-4.473-4.474z"), It(e, "version", "1.0"), It(e, "xmlns", "http://www.w3.org/2000/svg"), It(e, "viewBox", "0 0 20 20"), It(e, "id", "magnifier"), It(e, "width", "100%"), It(e, "height", "100%"), It(e, "color", "currentColor");
    },
    m(n, o) {
      nm(n, e, o), xh(e, t);
    },
    p: is,
    i: is,
    o: is,
    d(n) {
      n && em(e);
    }
  };
}
class sm extends $h {
  constructor(e) {
    super(), tm(this, e, null, om, im, {});
  }
}
function rm(i) {
  const e = i.numberOfChannels, t = i.length * e * 2 + 44, n = new ArrayBuffer(t), o = new DataView(n);
  let r = 0;
  const s = function(a, l, u) {
    for (let c = 0; c < u.length; c++)
      a.setUint8(l + c, u.charCodeAt(c));
  };
  s(o, r, "RIFF"), r += 4, o.setUint32(r, t - 8, !0), r += 4, s(o, r, "WAVE"), r += 4, s(o, r, "fmt "), r += 4, o.setUint32(r, 16, !0), r += 4, o.setUint16(r, 1, !0), r += 2, o.setUint16(r, e, !0), r += 2, o.setUint32(r, i.sampleRate, !0), r += 4, o.setUint32(r, i.sampleRate * 2 * e, !0), r += 4, o.setUint16(r, e * 2, !0), r += 2, o.setUint16(r, 16, !0), r += 2, s(o, r, "data"), r += 4, o.setUint32(r, i.length * e * 2, !0), r += 4;
  for (let a = 0; a < i.length; a++)
    for (let l = 0; l < e; l++) {
      const u = Math.max(
        -1,
        Math.min(1, i.getChannelData(l)[a])
      );
      o.setInt16(r, u * 32767, !0), r += 2;
    }
  return new Uint8Array(n);
}
const lm = async (i, e, t) => {
  const n = new AudioContext(), o = i.numberOfChannels, r = i.sampleRate;
  let s = i.length, a = 0;
  const l = n.createBuffer(
    o,
    s,
    r
  );
  for (let u = 0; u < o; u++) {
    const c = i.getChannelData(u), d = l.getChannelData(u);
    for (let h = 0; h < s; h++)
      d[h] = c[a + h];
  }
  return rm(l);
}, Gr = (i, e) => {
  i && i.skip(e);
}, Wn = (i, e) => (e || (e = 5), i / 100 * e || 5), {
  SvelteComponent: am,
  check_outros: um,
  create_component: xs,
  destroy_component: er,
  detach: cm,
  empty: dm,
  group_outros: fm,
  init: hm,
  insert: mm,
  mount_component: tr,
  safe_not_equal: pm,
  transition_in: wi,
  transition_out: yi
} = window.__gradio__svelte__internal;
function _m(i) {
  let e, t;
  return e = new sh({}), {
    c() {
      xs(e.$$.fragment);
    },
    m(n, o) {
      tr(e, n, o), t = !0;
    },
    i(n) {
      t || (wi(e.$$.fragment, n), t = !0);
    },
    o(n) {
      yi(e.$$.fragment, n), t = !1;
    },
    d(n) {
      er(e, n);
    }
  };
}
function gm(i) {
  let e, t;
  return e = new Qf({}), {
    c() {
      xs(e.$$.fragment);
    },
    m(n, o) {
      tr(e, n, o), t = !0;
    },
    i(n) {
      t || (wi(e.$$.fragment, n), t = !0);
    },
    o(n) {
      yi(e.$$.fragment, n), t = !1;
    },
    d(n) {
      er(e, n);
    }
  };
}
function vm(i) {
  let e, t;
  return e = new hh({}), {
    c() {
      xs(e.$$.fragment);
    },
    m(n, o) {
      tr(e, n, o), t = !0;
    },
    i(n) {
      t || (wi(e.$$.fragment, n), t = !0);
    },
    o(n) {
      yi(e.$$.fragment, n), t = !1;
    },
    d(n) {
      er(e, n);
    }
  };
}
function bm(i) {
  let e, t, n, o;
  const r = [vm, gm, _m], 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(i)) && (t = s[e] = r[e](i)), {
    c() {
      t && t.c(), n = dm();
    },
    m(l, u) {
      ~e && s[e].m(l, u), mm(l, n, u), o = !0;
    },
    p(l, [u]) {
      let c = e;
      e = a(l), e !== c && (t && (fm(), yi(s[c], 1, 1, () => {
        s[c] = null;
      }), um()), ~e ? (t = s[e], t || (t = s[e] = r[e](l), t.c()), wi(t, 1), t.m(n.parentNode, n)) : t = null);
    },
    i(l) {
      o || (wi(t), o = !0);
    },
    o(l) {
      yi(t), o = !1;
    },
    d(l) {
      l && cm(n), ~e && s[e].d(l);
    }
  };
}
function wm(i, e, t) {
  let { currentVolume: n } = e;
  return i.$$set = (o) => {
    "currentVolume" in o && t(0, n = o.currentVolume);
  }, [n];
}
class ym extends am {
  constructor(e) {
    super(), hm(this, e, wm, bm, pm, { currentVolume: 0 });
  }
}
const {
  SvelteComponent: km,
  attr: Sn,
  binding_callbacks: Cm,
  detach: Sm,
  element: Em,
  init: Dm,
  insert: Rm,
  listen: Vr,
  noop: Hr,
  run_all: Mm,
  safe_not_equal: Lm
} = window.__gradio__svelte__internal, { onMount: Om } = window.__gradio__svelte__internal;
function Pm(i) {
  let e, t, n;
  return {
    c() {
      e = Em("input"), Sn(e, "id", "volume"), Sn(e, "class", "volume-slider svelte-1xy0951"), Sn(e, "type", "range"), Sn(e, "min", "0"), Sn(e, "max", "1"), Sn(e, "step", "0.01"), e.value = /*currentVolume*/
      i[0];
    },
    m(o, r) {
      Rm(o, e, r), i[4](e), t || (n = [
        Vr(
          e,
          "focusout",
          /*focusout_handler*/
          i[5]
        ),
        Vr(
          e,
          "input",
          /*input_handler*/
          i[6]
        )
      ], t = !0);
    },
    p(o, [r]) {
      r & /*currentVolume*/
      1 && (e.value = /*currentVolume*/
      o[0]);
    },
    i: Hr,
    o: Hr,
    d(o) {
      o && Sm(e), i[4](null), t = !1, Mm(n);
    }
  };
}
function Wm(i, e, t) {
  let { currentVolume: n = 1 } = e, { show_volume_slider: o = !1 } = e, { waveform: r } = e, s;
  Om(() => {
    a();
  });
  const a = () => {
    let d = s;
    d && (d.style.background = `linear-gradient(to right, var(--color-accent) ${n * 100}%, var(--neutral-400) ${n * 100}%)`);
  };
  function l(d) {
    Cm[d ? "unshift" : "push"](() => {
      s = d, t(3, s);
    });
  }
  const u = () => t(1, o = !1), c = (d) => {
    d.target instanceof HTMLInputElement && (t(0, n = parseFloat(d.target.value)), r.setVolume(n));
  };
  return i.$$set = (d) => {
    "currentVolume" in d && t(0, n = d.currentVolume), "show_volume_slider" in d && t(1, o = d.show_volume_slider), "waveform" in d && t(2, r = d.waveform);
  }, i.$$.update = () => {
    i.$$.dirty & /*currentVolume*/
    1 && a();
  }, [
    n,
    o,
    r,
    s,
    l,
    u,
    c
  ];
}
class Am extends km {
  constructor(e) {
    super(), Dm(this, e, Wm, Pm, Lm, {
      currentVolume: 0,
      show_volume_slider: 1,
      waveform: 2
    });
  }
}
const {
  SvelteComponent: Tm,
  attr: En,
  binding_callbacks: qm,
  detach: Ba,
  element: jm,
  empty: Nm,
  init: zm,
  insert: Ia,
  listen: Xi,
  noop: Zr,
  run_all: Bm,
  safe_not_equal: Im,
  set_input_value: Xr,
  to_number: Um
} = window.__gradio__svelte__internal, { onMount: Fm } = window.__gradio__svelte__internal;
function Jr(i) {
  let e, t, n;
  return {
    c() {
      e = jm("input"), En(e, "class", "zoom-slider svelte-lb8lre"), En(e, "type", "range"), En(
        e,
        "min",
        /*zoomMin*/
        i[1]
      ), En(
        e,
        "max",
        /*zoomMax*/
        i[3]
      );
    },
    m(o, r) {
      Ia(o, e, r), i[9](e), Xr(
        e,
        /*currentZoom*/
        i[2]
      ), t || (n = [
        Xi(
          e,
          "change",
          /*input_change_input_handler*/
          i[10]
        ),
        Xi(
          e,
          "input",
          /*input_change_input_handler*/
          i[10]
        ),
        Xi(
          e,
          "input",
          /*input_handler*/
          i[11]
        ),
        Xi(
          e,
          "focusout",
          /*focusout_handler*/
          i[12]
        )
      ], t = !0);
    },
    p(o, r) {
      r & /*zoomMin*/
      2 && En(
        e,
        "min",
        /*zoomMin*/
        o[1]
      ), r & /*zoomMax*/
      8 && En(
        e,
        "max",
        /*zoomMax*/
        o[3]
      ), r & /*currentZoom*/
      4 && Xr(
        e,
        /*currentZoom*/
        o[2]
      );
    },
    d(o) {
      o && Ba(e), i[9](null), t = !1, Bm(n);
    }
  };
}
function Gm(i) {
  let e, t = (
    /*showZoomSlider*/
    i[0] && Jr(i)
  );
  return {
    c() {
      t && t.c(), e = Nm();
    },
    m(n, o) {
      t && t.m(n, o), Ia(n, e, o);
    },
    p(n, [o]) {
      /*showZoomSlider*/
      n[0] ? t ? t.p(n, o) : (t = Jr(n), t.c(), t.m(e.parentNode, e)) : t && (t.d(1), t = null);
    },
    i: Zr,
    o: Zr,
    d(n) {
      n && Ba(e), t && t.d(n);
    }
  };
}
function Vm(i, e, t) {
  let { waveform: n } = e, { wsGamepad: o } = e, { showZoomSlider: r = !1 } = e, { isDialogOpen: s = !1 } = e, a, l, u, c;
  var d;
  (function(v) {
    v[v.normalZoom = 1.1] = "normalZoom", v[v.fastZoom = 2] = "fastZoom";
  })(d || (d = {}));
  function h() {
    if (!c) return;
    const v = 100 * ((u - a) / (l - a));
    t(4, c.style.background = `linear-gradient(to right, var(--color-accent) ${v}%, var(--neutral-400) ${v}%)`, c);
  }
  function f(v) {
    v < a ? t(2, u = a) : v > l ? t(2, u = l) : t(2, u = v), n.zoom(u), h();
  }
  function m(v) {
    switch (v.idx) {
      case 12:
        f(u * d.fastZoom);
        break;
      case 13:
        f(u / d.fastZoom);
        break;
    }
  }
  Fm(() => {
    window.addEventListener("keydown", (v) => {
      if (s) return;
      const C = v.shiftKey ? d.fastZoom : d.normalZoom;
      switch (v.key) {
        case "ArrowUp":
          v.preventDefault(), f(u * C);
          break;
        case "ArrowDown":
          v.preventDefault(), f(u / C);
          break;
      }
    });
  });
  function g(v) {
    qm[v ? "unshift" : "push"](() => {
      c = v, t(4, c);
    });
  }
  function p() {
    u = Um(this.value), t(2, u), t(6, n), t(1, a);
  }
  const _ = (v) => f(v.target.value), y = () => t(0, r = !1);
  return i.$$set = (v) => {
    "waveform" in v && t(6, n = v.waveform), "wsGamepad" in v && t(7, o = v.wsGamepad), "showZoomSlider" in v && t(0, r = v.showZoomSlider), "isDialogOpen" in v && t(8, s = v.isDialogOpen);
  }, i.$$.update = () => {
    i.$$.dirty & /*waveform, zoomMin, currentZoom*/
    70 && (n == null || n.on("ready", () => {
      const v = n.getWrapper().clientWidth, C = n.getDuration();
      t(1, a = Math.trunc(v / C)), a === 0 && t(1, a = 1), t(3, l = Math.trunc(a * (C / 10))), t(2, u = a), n.zoom(u), h();
    })), i.$$.dirty & /*wsGamepad*/
    128 && (o == null || o.on("button-pressed", (v) => m(v)));
  }, [
    r,
    a,
    u,
    l,
    c,
    f,
    n,
    o,
    s,
    g,
    p,
    _,
    y
  ];
}
class Hm extends Tm {
  constructor(e) {
    super(), zm(this, e, Vm, Gm, Im, {
      waveform: 6,
      wsGamepad: 7,
      showZoomSlider: 0,
      isDialogOpen: 8
    });
  }
}
const {
  SvelteComponent: Zm,
  add_flush_callback: Os,
  append: ye,
  attr: pe,
  bind: Ps,
  binding_callbacks: Ws,
  check_outros: Kr,
  create_component: Gt,
  destroy_component: Vt,
  detach: Xm,
  element: _t,
  group_outros: Yr,
  init: Jm,
  insert: Km,
  listen: Dn,
  mount_component: Ht,
  run_all: Ym,
  safe_not_equal: Qm,
  set_data: $m,
  space: $t,
  text: Qr,
  toggle_class: $r,
  transition_in: Ue,
  transition_out: Ye
} = window.__gradio__svelte__internal, { createEventDispatcher: xm, onMount: ep } = window.__gradio__svelte__internal;
function xr(i) {
  let e, t, n, o;
  function r(l) {
    i[13](l);
  }
  function s(l) {
    i[14](l);
  }
  let a = { waveform: (
    /*waveform*/
    i[0]
  ) };
  return (
    /*currentVolume*/
    i[6] !== void 0 && (a.currentVolume = /*currentVolume*/
    i[6]), /*showVolumeSlider*/
    i[5] !== void 0 && (a.show_volume_slider = /*showVolumeSlider*/
    i[5]), e = new Am({ props: a }), Ws.push(() => Ps(e, "currentVolume", r)), Ws.push(() => Ps(e, "show_volume_slider", s)), {
      c() {
        Gt(e.$$.fragment);
      },
      m(l, u) {
        Ht(e, l, u), o = !0;
      },
      p(l, u) {
        const c = {};
        u & /*waveform*/
        1 && (c.waveform = /*waveform*/
        l[0]), !t && u & /*currentVolume*/
        64 && (t = !0, c.currentVolume = /*currentVolume*/
        l[6], Os(() => t = !1)), !n && u & /*showVolumeSlider*/
        32 && (n = !0, c.show_volume_slider = /*showVolumeSlider*/
        l[5], Os(() => n = !1)), e.$set(c);
      },
      i(l) {
        o || (Ue(e.$$.fragment, l), o = !0);
      },
      o(l) {
        Ye(e.$$.fragment, l), o = !1;
      },
      d(l) {
        Vt(e, l);
      }
    }
  );
}
function tp(i) {
  let e, t;
  return e = new Sf({}), {
    c() {
      Gt(e.$$.fragment);
    },
    m(n, o) {
      Ht(e, n, o), t = !0;
    },
    i(n) {
      t || (Ue(e.$$.fragment, n), t = !0);
    },
    o(n) {
      Ye(e.$$.fragment, n), t = !1;
    },
    d(n) {
      Vt(e, n);
    }
  };
}
function np(i) {
  let e, t;
  return e = new Ra({}), {
    c() {
      Gt(e.$$.fragment);
    },
    m(n, o) {
      Ht(e, n, o), t = !0;
    },
    i(n) {
      t || (Ue(e.$$.fragment, n), t = !0);
    },
    o(n) {
      Ye(e.$$.fragment, n), t = !1;
    },
    d(n) {
      Vt(e, n);
    }
  };
}
function ip(i) {
  let e, t, n, o, r, s, a, l, u, c, d, h, f, m, g, p, _, y, v, C, M, k, P, D, b, E, U, T, j, V, Q, q, I, H;
  o = new ym({
    props: { currentVolume: (
      /*currentVolume*/
      i[6]
    ) }
  });
  let G = (
    /*showVolumeSlider*/
    i[5] && xr(i)
  );
  m = new sm({});
  function F(W) {
    i[17](W);
  }
  let K = {
    waveform: (
      /*waveform*/
      i[0]
    ),
    wsGamepad: (
      /*wsGamepad*/
      i[1]
    )
  };
  /*showZoomSlider*/
  i[7] !== void 0 && (K.showZoomSlider = /*showZoomSlider*/
  i[7]), p = new Hm({ props: K }), Ws.push(() => Ps(p, "showZoomSlider", F)), M = new hd({});
  const x = [np, tp], A = [];
  function S(W, z) {
    return (
      /*playing*/
      W[9] ? 0 : 1
    );
  }
  return b = S(i), E = A[b] = x[b](i), V = new Gd({}), {
    c() {
      e = _t("div"), t = _t("div"), n = _t("button"), Gt(o.$$.fragment), r = $t(), G && G.c(), s = $t(), a = _t("button"), l = _t("span"), u = Qr(
        /*playbackSpeed*/
        i[8]
      ), c = Qr("x"), h = $t(), f = _t("button"), Gt(m.$$.fragment), g = $t(), Gt(p.$$.fragment), y = $t(), v = _t("div"), C = _t("button"), Gt(M.$$.fragment), P = $t(), D = _t("button"), E.c(), T = $t(), j = _t("button"), Gt(V.$$.fragment), pe(n, "class", "action icon volume svelte-1vl7tvk"), pe(n, "aria-label", "Adjust volume"), pe(l, "class", "svelte-1vl7tvk"), pe(a, "class", "playback icon svelte-1vl7tvk"), pe(a, "aria-label", d = `Adjust playback speed to ${/*playbackSpeeds*/
      i[10][
        /*playbackSpeeds*/
        (i[10].indexOf(
          /*playbackSpeed*/
          i[8]
        ) + 1) % /*playbackSpeeds*/
        i[10].length
      ]}x`), $r(
        a,
        "hidden",
        /*showVolumeSlider*/
        i[5]
      ), pe(f, "class", "zoom-button icon svelte-1vl7tvk"), pe(t, "class", "control-wrapper svelte-1vl7tvk"), pe(C, "class", "rewind icon svelte-1vl7tvk"), pe(C, "aria-label", k = `Skip backwards by ${Wn(
        /*audio_duration*/
        i[2],
        /*waveform_options*/
        i[4].skip_length
      )} seconds`), pe(D, "class", "play-pause-button icon svelte-1vl7tvk"), pe(D, "aria-label", U = /*playing*/
      i[9] ? (
        /*i18n*/
        i[3]("audio.pause")
      ) : (
        /*i18n*/
        i[3]("audio.play")
      )), pe(j, "class", "skip icon svelte-1vl7tvk"), pe(j, "aria-label", Q = "Skip forward by " + Wn(
        /*audio_duration*/
        i[2],
        /*waveform_options*/
        i[4].skip_length
      ) + " seconds"), pe(v, "class", "play-pause-wrapper svelte-1vl7tvk"), pe(e, "class", "controls svelte-1vl7tvk"), pe(e, "data-testid", "waveform-controls");
    },
    m(W, z) {
      Km(W, e, z), ye(e, t), ye(t, n), Ht(o, n, null), ye(t, r), G && G.m(t, null), ye(t, s), ye(t, a), ye(a, l), ye(l, u), ye(l, c), ye(t, h), ye(t, f), Ht(m, f, null), ye(t, g), Ht(p, t, null), ye(e, y), ye(e, v), ye(v, C), Ht(M, C, null), ye(v, P), ye(v, D), A[b].m(D, null), ye(v, T), ye(v, j), Ht(V, j, null), q = !0, I || (H = [
        Dn(
          n,
          "click",
          /*click_handler*/
          i[12]
        ),
        Dn(
          a,
          "click",
          /*click_handler_1*/
          i[15]
        ),
        Dn(
          f,
          "click",
          /*click_handler_2*/
          i[16]
        ),
        Dn(
          C,
          "click",
          /*click_handler_3*/
          i[18]
        ),
        Dn(
          D,
          "click",
          /*click_handler_4*/
          i[19]
        ),
        Dn(
          j,
          "click",
          /*click_handler_5*/
          i[20]
        )
      ], I = !0);
    },
    p(W, [z]) {
      const O = {};
      z & /*currentVolume*/
      64 && (O.currentVolume = /*currentVolume*/
      W[6]), o.$set(O), /*showVolumeSlider*/
      W[5] ? G ? (G.p(W, z), z & /*showVolumeSlider*/
      32 && Ue(G, 1)) : (G = xr(W), G.c(), Ue(G, 1), G.m(t, s)) : G && (Yr(), Ye(G, 1, 1, () => {
        G = null;
      }), Kr()), (!q || z & /*playbackSpeed*/
      256) && $m(
        u,
        /*playbackSpeed*/
        W[8]
      ), (!q || z & /*playbackSpeed*/
      256 && d !== (d = `Adjust playback speed to ${/*playbackSpeeds*/
      W[10][
        /*playbackSpeeds*/
        (W[10].indexOf(
          /*playbackSpeed*/
          W[8]
        ) + 1) % /*playbackSpeeds*/
        W[10].length
      ]}x`)) && pe(a, "aria-label", d), (!q || z & /*showVolumeSlider*/
      32) && $r(
        a,
        "hidden",
        /*showVolumeSlider*/
        W[5]
      );
      const w = {};
      z & /*waveform*/
      1 && (w.waveform = /*waveform*/
      W[0]), z & /*wsGamepad*/
      2 && (w.wsGamepad = /*wsGamepad*/
      W[1]), !_ && z & /*showZoomSlider*/
      128 && (_ = !0, w.showZoomSlider = /*showZoomSlider*/
      W[7], Os(() => _ = !1)), p.$set(w), (!q || z & /*audio_duration, waveform_options*/
      20 && k !== (k = `Skip backwards by ${Wn(
        /*audio_duration*/
        W[2],
        /*waveform_options*/
        W[4].skip_length
      )} seconds`)) && pe(C, "aria-label", k);
      let L = b;
      b = S(W), b !== L && (Yr(), Ye(A[L], 1, 1, () => {
        A[L] = null;
      }), Kr(), E = A[b], E || (E = A[b] = x[b](W), E.c()), Ue(E, 1), E.m(D, null)), (!q || z & /*playing, i18n*/
      520 && U !== (U = /*playing*/
      W[9] ? (
        /*i18n*/
        W[3]("audio.pause")
      ) : (
        /*i18n*/
        W[3]("audio.play")
      ))) && pe(D, "aria-label", U), (!q || z & /*audio_duration, waveform_options*/
      20 && Q !== (Q = "Skip forward by " + Wn(
        /*audio_duration*/
        W[2],
        /*waveform_options*/
        W[4].skip_length
      ) + " seconds")) && pe(j, "aria-label", Q);
    },
    i(W) {
      q || (Ue(o.$$.fragment, W), Ue(G), Ue(m.$$.fragment, W), Ue(p.$$.fragment, W), Ue(M.$$.fragment, W), Ue(E), Ue(V.$$.fragment, W), q = !0);
    },
    o(W) {
      Ye(o.$$.fragment, W), Ye(G), Ye(m.$$.fragment, W), Ye(p.$$.fragment, W), Ye(M.$$.fragment, W), Ye(E), Ye(V.$$.fragment, W), q = !1;
    },
    d(W) {
      W && Xm(e), Vt(o), G && G.d(), Vt(m), Vt(p), Vt(M), A[b].d(), Vt(V), I = !1, Ym(H);
    }
  };
}
function op(i, e, t) {
  let { waveform: n } = e, { wsGamepad: o } = e, { audio_duration: r } = e, { i18n: s } = e, { waveform_options: a = {} } = e, { isDialogOpen: l = !1 } = e, u = !1, c = 1, d = !1;
  const h = [0.5, 1, 1.5, 2];
  let f = h[1], m = !1;
  const g = xm();
  function p(E) {
    switch (E.idx) {
      case 10:
        n.playPause();
        break;
      case 11:
        n.playPause();
        break;
    }
  }
  ep(() => {
    window.addEventListener("keydown", (E) => {
      if (!l)
        switch (E.key) {
          case " ":
            n.playPause(), E.preventDefault();
            break;
        }
    });
  });
  const _ = () => t(5, u = !u);
  function y(E) {
    c = E, t(6, c);
  }
  function v(E) {
    u = E, t(5, u);
  }
  const C = () => {
    t(8, f = h[(h.indexOf(f) + 1) % h.length]), n.setPlaybackRate(f);
  }, M = () => t(7, d = !d);
  function k(E) {
    d = E, t(7, d);
  }
  const P = () => n.skip(Wn(r, a.skip_length) * -1), D = () => n.playPause(), b = () => n.skip(Wn(r, a.skip_length));
  return i.$$set = (E) => {
    "waveform" in E && t(0, n = E.waveform), "wsGamepad" in E && t(1, o = E.wsGamepad), "audio_duration" in E && t(2, r = E.audio_duration), "i18n" in E && t(3, s = E.i18n), "waveform_options" in E && t(4, a = E.waveform_options), "isDialogOpen" in E && t(11, l = E.isDialogOpen);
  }, i.$$.update = () => {
    i.$$.dirty & /*waveform*/
    1 && n.on("ready", () => {
      n.options.autoplay ? n.play() : n.stop();
    }), i.$$.dirty & /*waveform*/
    1 && n.on("play", () => {
      t(9, m = !0), g("play");
    }), i.$$.dirty & /*waveform*/
    1 && n.on("finish", () => {
      t(9, m = !1), g("stop");
    }), i.$$.dirty & /*waveform*/
    1 && n.on("pause", () => {
      t(9, m = !1), g("pause");
    }), i.$$.dirty & /*wsGamepad*/
    2 && (o == null || o.on("button-pressed", (E) => p(E)));
  }, [
    n,
    o,
    r,
    s,
    a,
    u,
    c,
    d,
    f,
    m,
    h,
    l,
    _,
    y,
    v,
    C,
    M,
    k,
    P,
    D,
    b
  ];
}
class Ua extends Zm {
  constructor(e) {
    super(), Jm(this, e, op, ip, Qm, {
      waveform: 0,
      wsGamepad: 1,
      audio_duration: 2,
      i18n: 3,
      waveform_options: 4,
      isDialogOpen: 11
    });
  }
}
const {
  SvelteComponent: sp,
  append: ri,
  attr: it,
  detach: rp,
  init: lp,
  insert: ap,
  noop: os,
  safe_not_equal: up,
  svg_element: Rn
} = window.__gradio__svelte__internal;
function cp(i) {
  let e, t, n, o, r, s;
  return {
    c() {
      e = Rn("svg"), t = Rn("g"), n = Rn("g"), o = Rn("path"), r = Rn("path"), s = Rn("polygon"), it(o, "d", `M348.994,102.946L250.04,3.993c-5.323-5.323-13.954-5.324-19.277,0l-153.7,153.701l118.23,118.23l153.701-153.7\r
			C354.317,116.902,354.317,108.271,348.994,102.946z`), it(r, "d", `M52.646,182.11l-41.64,41.64c-5.324,5.322-5.324,13.953,0,19.275l98.954,98.957c5.323,5.322,13.954,5.32,19.277,0\r
			l41.639-41.641L52.646,182.11z`), it(s, "points", "150.133,360 341.767,360 341.767,331.949 182.806,331.949"), it(e, "version", "1.1"), it(e, "id", "Capa_1"), it(e, "xmlns", "http://www.w3.org/2000/svg"), it(e, "xmlns:xlink", "http://www.w3.org/1999/xlink"), it(e, "width", "100%"), it(e, "height", "100%"), it(e, "viewBox", "0 0 360 360"), it(e, "color", "#9CA3AF");
    },
    m(a, l) {
      ap(a, e, l), ri(e, t), ri(t, n), ri(n, o), ri(n, r), ri(n, s);
    },
    p: os,
    i: os,
    o: os,
    d(a) {
      a && rp(e);
    }
  };
}
class dp extends sp {
  constructor(e) {
    super(), lp(this, e, null, cp, up, {});
  }
}
let Fa = class {
  constructor() {
    this.listeners = {};
  }
  on(e, t, n) {
    if (this.listeners[e] || (this.listeners[e] = /* @__PURE__ */ new Set()), this.listeners[e].add(t), n == null ? void 0 : n.once) {
      const o = () => {
        this.un(e, o), this.un(e, t);
      };
      return this.on(e, o), o;
    }
    return () => this.un(e, t);
  }
  un(e, t) {
    var n;
    (n = this.listeners[e]) === null || n === void 0 || n.delete(t);
  }
  once(e, t) {
    return this.on(e, t, { once: !0 });
  }
  unAll() {
    this.listeners = {};
  }
  emit(e, ...t) {
    this.listeners[e] && this.listeners[e].forEach((n) => n(...t));
  }
}, fp = class extends Fa {
  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 io(i, e, t, n, o = 3, r = 0, s = 100) {
  if (!i) return () => {
  };
  const a = matchMedia("(pointer: coarse)").matches;
  let l = () => {
  };
  const u = (c) => {
    if (c.button !== r) return;
    c.preventDefault(), c.stopPropagation();
    let d = c.clientX, h = c.clientY, f = !1;
    const m = Date.now(), g = (C) => {
      if (C.preventDefault(), C.stopPropagation(), a && Date.now() - m < s) return;
      const M = C.clientX, k = C.clientY, P = M - d, D = k - h;
      if (f || Math.abs(P) > o || Math.abs(D) > o) {
        const b = i.getBoundingClientRect(), { left: E, top: U } = b;
        f || (t == null || t(d - E, h - U), f = !0), e(P, D, M - E, k - U), d = M, h = k;
      }
    }, p = (C) => {
      if (f) {
        const M = C.clientX, k = C.clientY, P = i.getBoundingClientRect(), { left: D, top: b } = P;
        n == null || n(M - D, k - b);
      }
      l();
    }, _ = (C) => {
      C.relatedTarget && C.relatedTarget !== document.documentElement || p(C);
    }, y = (C) => {
      f && (C.stopPropagation(), C.preventDefault());
    }, v = (C) => {
      f && C.preventDefault();
    };
    document.addEventListener("pointermove", g), document.addEventListener("pointerup", p), document.addEventListener("pointerout", _), document.addEventListener("pointercancel", _), document.addEventListener("touchmove", v, { passive: !1 }), document.addEventListener("click", y, { capture: !0 }), l = () => {
      document.removeEventListener("pointermove", g), document.removeEventListener("pointerup", p), document.removeEventListener("pointerout", _), document.removeEventListener("pointercancel", _), document.removeEventListener("touchmove", v), setTimeout(() => {
        document.removeEventListener("click", y, { capture: !0 });
      }, 10);
    };
  };
  return i.addEventListener("pointerdown", u), () => {
    l(), i.removeEventListener("pointerdown", u);
  };
}
function Ga(i, e) {
  const t = e.xmlns ? document.createElementNS(e.xmlns, i) : document.createElement(i);
  for (const [n, o] of Object.entries(e)) if (n === "children") for (const [r, s] of Object.entries(e)) typeof s == "string" ? t.appendChild(document.createTextNode(s)) : t.appendChild(Ga(r, s));
  else n === "style" ? Object.assign(t.style, o) : n === "textContent" ? t.textContent = o : t.setAttribute(n, o.toString());
  return t;
}
function pi(i, e, t) {
  const n = Ga(i, e || {});
  return t == null || t.appendChild(n), n;
}
let hp = class As {
  constructor() {
    this.numNodes = 0, this.edges = /* @__PURE__ */ new Map();
  }
  getNumNodes() {
    return this.numNodes;
  }
  getNodes() {
    return Array.from(this.edges.keys());
  }
  getAdjNodes(e) {
    return this.edges.get(e);
  }
  isNodeInGraph(e) {
    return this.edges.get(e) !== void 0;
  }
  isEdgeInGraph(e, t) {
    let n = this.getAdjNodes(e);
    return n !== void 0 && n.find((o) => o == t) !== void 0;
  }
  addNode(e) {
    this.isNodeInGraph(e) || (this.edges.set(e, []), this.numNodes += 1);
  }
  addEdge(e, t) {
    var n, o;
    e !== t && (this.isEdgeInGraph(e, t) || (this.isNodeInGraph(e) || this.addNode(e), this.isNodeInGraph(t) || this.addNode(t), (n = this.getAdjNodes(e)) === null || n === void 0 || n.push(t), (o = this.getAdjNodes(t)) === null || o === void 0 || o.push(e)));
  }
  removeNode(e) {
    var t;
    let n = (t = this.getAdjNodes(e)) === null || t === void 0 ? void 0 : t.slice();
    return n !== void 0 && (n.forEach((o) => {
      this.removeEdge(e, o);
    }), this.edges.delete(e), this.numNodes -= 1, !0);
  }
  removeEdge(e, t) {
    var n, o, r, s;
    this.isEdgeInGraph(e, t) && ((n = this.getAdjNodes(e)) === null || n === void 0 || n.splice(Number((o = this.getAdjNodes(e)) === null || o === void 0 ? void 0 : o.indexOf(t)), 1), (r = this.getAdjNodes(t)) === null || r === void 0 || r.splice(Number((s = this.getAdjNodes(t)) === null || s === void 0 ? void 0 : s.indexOf(e)), 1));
  }
  clear() {
    this.edges.clear(), this.numNodes = 0;
  }
  equals(e) {
    if (Array.from(this.edges.keys()).length !== Array.from(e.edges.keys()).length) return !1;
    let t = !0;
    return this.edges.forEach((n, o) => {
      e.edges.has(o) || (t = !1), n.forEach((r) => {
        var s;
        !((s = e.getAdjNodes(o)) === null || s === void 0) && s.includes(r) || (t = !1);
      });
    }), t;
  }
  greedyColoring() {
    let e = /* @__PURE__ */ new Map(), t = new Array(this.numNodes).fill(!0);
    return this.getNodes().forEach((n) => {
      var o;
      let r;
      for ((o = this.getAdjNodes(n)) === null || o === void 0 || o.forEach((s) => {
        let a = e.get(s);
        a !== void 0 && (t[a] = !1);
      }), r = 0; r < t.length && !t[r]; r++) ;
      e.set(n, r), t.fill(!0);
    }), e;
  }
  getConnectedComponent(e) {
    let t = new As();
    return this.getConnectedComponentHelper(e, [], t), t;
  }
  getConnectedComponents() {
    const e = [], t = [];
    return this.getNodes().forEach((n) => {
      if (!e.includes(n)) {
        const o = new As();
        this.getConnectedComponentHelper(n, e, o), t.push(o);
      }
    }), t;
  }
  getConnectedComponentHelper(e, t, n) {
    var o;
    t.push(e), n.addNode(e), (o = this.getAdjNodes(e)) === null || o === void 0 || o.forEach((r) => {
      n.addEdge(e, r), t.find((s) => s === r) || this.getConnectedComponentHelper(r, t, n);
    });
  }
}, el = class extends Fa {
  constructor(e, t, n = 0) {
    var o, r, s, a, l, u, c, d;
    super(), this.totalDuration = t, this.numberOfChannels = n, 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((o = e.end) !== null && o !== void 0 ? o : e.start), this.drag = (r = e.drag) === null || r === void 0 || r, 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 = (d = e.contentEditable) !== null && d !== void 0 ? d : this.contentEditable, this.element = this.initElement(), this.setContent(e.content), this.setPart(), this.renderPosition(), this.initMouseEvents();
  }
  clampPosition(e) {
    return Math.max(0, Math.min(this.totalDuration, e));
  }
  setPart() {
    const e = this.start === this.end;
    this.element.setAttribute("part", `${e ? "marker" : "region"} ${this.id}`);
  }
  addResizeHandles(e) {
    const t = { position: "absolute", zIndex: "2", width: "6px", height: "100%", top: "0", cursor: "ew-resize", wordBreak: "keep-all" }, n = pi("div", { part: "region-handle region-handle-left", style: Object.assign(Object.assign({}, t), { left: "0", borderLeft: "2px solid rgba(0, 0, 0, 0.5)", borderRadius: "2px 0 0 2px" }) }, e), o = pi("div", { part: "region-handle region-handle-right", style: Object.assign(Object.assign({}, t), { right: "0", borderRight: "2px solid rgba(0, 0, 0, 0.5)", borderRadius: "0 2px 2px 0" }) }, e);
    this.subscriptions.push(io(n, (r) => this.onResize(r, "start"), () => null, () => this.onEndResizing(), 1), io(o, (r) => this.onResize(r, "end"), () => null, () => this.onEndResizing(), 1));
  }
  removeResizeHandles(e) {
    const t = e.querySelector('[part*="region-handle-left"]'), n = e.querySelector('[part*="region-handle-right"]');
    t && e.removeChild(t), n && e.removeChild(n);
  }
  initElement() {
    const e = this.start === this.end;
    let t = 0, n = 100;
    this.channelIdx >= 0 && this.channelIdx < this.numberOfChannels && (n = 100 / this.numberOfChannels, t = n * this.channelIdx);
    const o = pi("div", { style: { position: "absolute", top: `${t}%`, height: `${n}%`, 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(o), o;
  }
  renderPosition() {
    const e = this.start / this.totalDuration, t = (this.totalDuration - this.end) / this.totalDuration;
    this.element.style.left = 100 * e + "%", this.element.style.right = 100 * t + "%";
  }
  toggleCursor(e) {
    var t;
    this.drag && (!((t = this.element) === null || t === void 0) && t.style) && (this.element.style.cursor = e ? "grabbing" : "grab");
  }
  initMouseEvents() {
    const { element: e } = this;
    e && (e.addEventListener("click", (t) => this.emit("click", t)), e.addEventListener("mouseenter", (t) => this.emit("over", t)), e.addEventListener("mouseleave", (t) => this.emit("leave", t)), e.addEventListener("dblclick", (t) => this.emit("dblclick", t)), e.addEventListener("pointerdown", () => this.toggleCursor(!0)), e.addEventListener("pointerup", () => this.toggleCursor(!1)), this.subscriptions.push(io(e, (t) => this.onMove(t), () => this.toggleCursor(!0), () => {
      this.toggleCursor(!1), this.drag && this.emit("update-end");
    })), this.contentEditable && this.content && (this.content.addEventListener("click", (t) => this.onContentClick(t)), this.content.addEventListener("blur", () => this.onContentBlur())));
  }
  _onUpdate(e, t) {
    if (!this.element.parentElement) return;
    const { width: n } = this.element.parentElement.getBoundingClientRect(), o = e / n * this.totalDuration, r = t && t !== "start" ? this.start : this.start + o, s = t && t !== "end" ? this.end : this.end + o, a = s - r;
    r >= 0 && s <= this.totalDuration && r <= s && a >= this.minLength && a <= this.maxLength && (this.start = r, this.end = s, this.renderPosition(), this.emit("update", t));
  }
  onMove(e) {
    this.drag && this._onUpdate(e);
  }
  onResize(e, t) {
    this.resize && this._onUpdate(e, t);
  }
  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 t;
    if ((t = this.content) === null || t === void 0 || t.remove(), e) {
      if (typeof e == "string") {
        const n = this.start === this.end;
        this.content = pi("div", { style: { padding: `0.2em ${n ? 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 t, n;
    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 o = this.start === this.end;
      this.start = this.clampPosition((t = e.start) !== null && t !== void 0 ? t : this.start), this.end = this.clampPosition((n = e.end) !== null && n !== void 0 ? n : o ? 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 o = this.start === this.end;
      this.resize = e.resize, this.resize && !o ? this.addResizeHandles(this.element) : this.removeResizeHandles(this.element);
    }
  }
  remove() {
    this.emit("remove"), this.subscriptions.forEach((e) => e()), this.element.remove(), this.element = null;
  }
};
class nr extends fp {
  constructor(e) {
    super(e), this.regions = [], this.regionsContainer = this.initRegionsContainer(), this.overlapGraph = new hp();
  }
  static create(e) {
    return new nr(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", (t) => {
      const n = this.regions.filter((o) => o.start <= t && (o.end === o.start ? o.start + 0.05 : o.end) >= t);
      n.forEach((o) => {
        e.includes(o) || this.emit("region-in", o);
      }), e.forEach((o) => {
        n.includes(o) || this.emit("region-out", o);
      }), e = n;
    }));
  }
  initRegionsContainer() {
    return pi("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 t = e.content, n = t.getBoundingClientRect(), o = this.regions.map((r) => {
        if (r === e || !r.content) return 0;
        const s = r.content.getBoundingClientRect();
        return n.left < s.left + s.width && s.left < n.left + n.width ? s.height : 0;
      }).reduce((r, s) => r + s, 0);
      t.style.marginTop = `${o}px`;
    }, 10);
  }
  updateConnectedComponentRegions(e) {
    const t = e.greedyColoring(), n = Math.max(...Array.from(t.values())) + 1;
    e.getNodes().forEach((o) => {
      const r = this.getRegions().find((u) => u.id === o), s = t.get(r.id), a = 100 / n, l = s * a;
      r.element.style.top = `${l}%`, r.element.style.height = `${a}%`;
    });
  }
  updateOverlapGraph(e) {
    const t = this.overlapGraph.getConnectedComponent(e.id);
    t.removeNode(e.id), this.overlapGraph.getNodes().forEach((n) => {
      const o = this.getRegions().find((r) => r.id === n);
      e.start < o.end && o.start < e.end ? this.overlapGraph.addEdge(e.id, n) : this.overlapGraph.removeEdge(e.id, n);
    }), [t, this.overlapGraph.getConnectedComponent(e.id)].forEach((n) => {
      this.updateConnectedComponentRegions(n);
    });
  }
  removeRegionFromOverlapGraph(e) {
    let t = this.overlapGraph.getConnectedComponent(e.id);
    t.removeNode(e.id), this.updateConnectedComponentRegions(t), this.overlapGraph.removeNode(e.id);
  }
  adjustScroll(e) {
    var t, n;
    const o = (n = (t = this.wavesurfer) === null || t === void 0 ? void 0 : t.getWrapper()) === null || n === void 0 ? void 0 : n.parentElement;
    if (!o) return;
    const { clientWidth: r, scrollWidth: s } = o;
    if (s <= r) return;
    const a = o.getBoundingClientRect(), l = e.element.getBoundingClientRect(), u = l.left - a.left, c = l.right - a.left;
    u < 0 ? o.scrollLeft += u : c > r && (o.scrollLeft += c - r);
  }
  virtualAppend(e, t, n) {
    const o = () => {
      if (!this.wavesurfer) return;
      const r = this.wavesurfer.getWidth(), s = this.wavesurfer.getScroll(), a = t.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 + r ? t.appendChild(n) : n.remove();
    };
    setTimeout(() => {
      if (!this.wavesurfer) return;
      o();
      const r = this.wavesurfer.on("scroll", o);
      this.subscriptions.push(e.once("remove", r), r);
    }, 0);
  }
  saveRegion(e) {
    this.virtualAppend(e, this.regionsContainer, e.element), this.avoidOverlapping(e), this.regions.push(e);
    const t = [e.on("update", (n) => {
      n || this.adjustScroll(e), this.updateOverlapGraph(e), this.emit("region-update", e, n);
    }), e.on("update-end", () => {
      this.avoidOverlapping(e), this.emit("region-updated", e);
    }), e.on("play", () => {
      var n, o;
      (n = this.wavesurfer) === null || n === void 0 || n.play(), (o = this.wavesurfer) === null || o === void 0 || o.setTime(e.start);
    }), e.on("click", (n) => {
      this.emit("region-clicked", e, n);
    }), e.on("dblclick", (n) => {
      this.emit("region-double-clicked", e, n);
    }), e.once("remove", () => {
      t.forEach((n) => n()), this.regions = this.regions.filter((n) => n !== e), this.removeRegionFromOverlapGraph(e), this.emit("region-removed", e);
    })];
    this.subscriptions.push(...t), this.emit("region-created", e);
  }
  addRegion(e) {
    var t, n;
    if (!this.wavesurfer) throw Error("WaveSurfer is not initialized");
    const o = this.wavesurfer.getDuration(), r = (n = (t = this.wavesurfer) === null || t === void 0 ? void 0 : t.getDecodedData()) === null || n === void 0 ? void 0 : n.numberOfChannels, s = new el(e, o, r);
    return o ? this.saveRegion(s) : this.subscriptions.push(this.wavesurfer.once("ready", (a) => {
      s._setTotalDuration(a), this.saveRegion(s);
    })), this.overlapGraph.addNode(s.id), this.updateOverlapGraph(s), s;
  }
  enableDragSelection(e, t = 3) {
    var n;
    const o = (n = this.wavesurfer) === null || n === void 0 ? void 0 : n.getWrapper();
    if (!(o && o instanceof HTMLElement)) return () => {
    };
    let r = null, s = 0;
    return io(o, (a, l, u) => {
      r && r._onUpdate(a, u > s ? "end" : "start");
    }, (a) => {
      var l, u;
      if (s = a, !this.wavesurfer) return;
      const c = this.wavesurfer.getDuration(), d = (u = (l = this.wavesurfer) === null || l === void 0 ? void 0 : l.getDecodedData()) === null || u === void 0 ? void 0 : u.numberOfChannels, { width: h } = this.wavesurfer.getWrapper().getBoundingClientRect(), f = a / h * c, m = (a + 5) / h * c;
      r = new el(Object.assign(Object.assign({}, e), { start: f, end: m }), c, d), this.regionsContainer.appendChild(r.element);
    }, () => {
      r && (this.saveRegion(r), r = null);
    }, t);
  }
  clearRegions() {
    this.regions.forEach((e) => e.remove()), this.overlapGraph.clear();
  }
  destroy() {
    this.clearRegions(), super.destroy(), this.regionsContainer.remove();
  }
}
let Va = class {
  constructor() {
    this.listeners = {};
  }
  on(e, t, n) {
    if (this.listeners[e] || (this.listeners[e] = /* @__PURE__ */ new Set()), this.listeners[e].add(t), n == null ? void 0 : n.once) {
      const o = () => {
        this.un(e, o), this.un(e, t);
      };
      return this.on(e, o), o;
    }
    return () => this.un(e, t);
  }
  un(e, t) {
    var n;
    (n = this.listeners[e]) === null || n === void 0 || n.delete(t);
  }
  once(e, t) {
    return this.on(e, t, { once: !0 });
  }
  unAll() {
    this.listeners = {};
  }
  emit(e, ...t) {
    this.listeners[e] && this.listeners[e].forEach((n) => n(...t));
  }
}, mp = class extends Va {
  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());
  }
}, pp = class extends Va {
  constructor() {
    super(), this.gamepad = null, this.buttonStates = [], this.axeValues = [], this.requestUpdateID = 0, window.addEventListener("gamepadconnected", (e) => {
      this.gamepad = e.gamepad, this.buttonStates = new Array(this.gamepad.buttons.length).fill(!1), this.axeValues = new Array(this.gamepad.axes.length).fill(0);
    }), window.addEventListener("gamepaddisconnected", (e) => {
      this.gamepad = null, window.cancelAnimationFrame(this.requestUpdateID);
    }), this.poll = this.poll.bind(this);
  }
  start() {
    setInterval(this.poll, 1e3);
  }
  isButtontPressed(e) {
    return this.buttonStates[e];
  }
  checkButtonEvent() {
    if (this.gamepad) {
      console.log(this.buttonStates);
      for (let e = 0; e < this.gamepad.buttons.length; e++) {
        const t = this.gamepad.buttons[e].value > 0;
        t && console.log("pressed: " + e), t && !this.buttonStates[e] ? this.emit("button-pressed", { idx: e }) : !t && this.buttonStates[e] && this.emit("button-released", { idx: e }), this.buttonStates[e] = t;
      }
    }
  }
  checkAxeEvent() {
    if (this.gamepad) for (let e = 0; e < this.gamepad.axes.length; e++) {
      const t = this.gamepad.axes[e];
      Math.abs(t) < 0.01 && Math.abs(this.axeValues[e]) > 0.01 ? this.emit("axe-released", { idx: e, value: t }) : Math.abs(t) > 0.01 ? this.emit("axe-pushed", { idx: e, value: t }) : Math.abs(t - this.axeValues[e]) > 0.01 && this.emit("axe-value-updated", { idx: e, value: t }), this.axeValues[e] = t;
    }
  }
  poll() {
    this.gamepad && (this.checkButtonEvent(), this.checkAxeEvent());
  }
}, _p = class Ha extends mp {
  constructor(e) {
    super(e), this.gamepadControl = new pp();
  }
  static create(e) {
    return new Ha(e);
  }
  isButtonPressed(e) {
    return this.gamepadControl.isButtontPressed(e);
  }
  on(e, t, n) {
    return this.gamepadControl.on(e, t, n);
  }
  onInit() {
    if (!this.wavesurfer) throw Error("Wavesurfer is not initialized");
    this.gamepadControl.start(), this.subscriptions.push();
  }
};
const {
  SvelteComponent: gp,
  append: Ji,
  attr: Fe,
  check_outros: Za,
  create_component: Ts,
  destroy_component: qs,
  detach: ir,
  element: oo,
  empty: vp,
  group_outros: Xa,
  init: bp,
  insert: or,
  listen: js,
  mount_component: Ns,
  run_all: wp,
  safe_not_equal: yp,
  space: tl,
  transition_in: Lt,
  transition_out: an
} = window.__gradio__svelte__internal, { createEventDispatcher: kp, onMount: Cp } = window.__gradio__svelte__internal;
function nl(i) {
  let e, t, n, o, r, s, a, l, u, c, d, h, f = (
    /*interactive*/
    i[4] && il(i)
  );
  return o = new dp({}), l = new Pf({}), {
    c() {
      e = oo("div"), f && f.c(), t = tl(), n = oo("button"), Ts(o.$$.fragment), s = tl(), a = oo("button"), Ts(l.$$.fragment), Fe(n, "class", "action icon remove-button svelte-ni7s1"), Fe(n, "aria-label", "Remove an annotation"), Fe(n, "title", r = /*i18n*/
      i[2]("Remove an annotation")), Fe(a, "class", "action icon trim-button svelte-ni7s1"), Fe(a, "aria-label", "Split an annotation"), Fe(a, "title", u = /*i18n*/
      i[2]("Split an annotation")), Fe(e, "class", "regions-actions svelte-ni7s1");
    },
    m(m, g) {
      or(m, e, g), f && f.m(e, null), Ji(e, t), Ji(e, n), Ns(o, n, null), Ji(e, s), Ji(e, a), Ns(l, a, null), c = !0, d || (h = [
        js(
          n,
          "click",
          /*click_handler*/
          i[19]
        ),
        js(
          a,
          "click",
          /*click_handler_1*/
          i[20]
        )
      ], d = !0);
    },
    p(m, g) {
      /*interactive*/
      m[4] ? f ? (f.p(m, g), g[0] & /*interactive*/
      16 && Lt(f, 1)) : (f = il(m), f.c(), Lt(f, 1), f.m(e, t)) : f && (Xa(), an(f, 1, 1, () => {
        f = null;
      }), Za()), (!c || g[0] & /*i18n*/
      4 && r !== (r = /*i18n*/
      m[2]("Remove an annotation"))) && Fe(n, "title", r), (!c || g[0] & /*i18n*/
      4 && u !== (u = /*i18n*/
      m[2]("Split an annotation"))) && Fe(a, "title", u);
    },
    i(m) {
      c || (Lt(f), Lt(o.$$.fragment, m), Lt(l.$$.fragment, m), c = !0);
    },
    o(m) {
      an(f), an(o.$$.fragment, m), an(l.$$.fragment, m), c = !1;
    },
    d(m) {
      m && ir(e), f && f.d(), qs(o), qs(l), d = !1, wp(h);
    }
  };
}
function il(i) {
  let e, t, n, o, r, s;
  return t = new Ma({}), {
    c() {
      e = oo("button"), Ts(t.$$.fragment), Fe(e, "class", "action icon svelte-ni7s1"), Fe(e, "aria-label", "Reset annotations"), Fe(e, "title", n = /*i18n*/
      i[2]("Reset annotations"));
    },
    m(a, l) {
      or(a, e, l), Ns(t, e, null), o = !0, r || (s = js(
        e,
        "click",
        /*resetRegions*/
        i[5]
      ), r = !0);
    },
    p(a, l) {
      (!o || l[0] & /*i18n*/
      4 && n !== (n = /*i18n*/
      a[2]("Reset annotations"))) && Fe(e, "title", n);
    },
    i(a) {
      o || (Lt(t.$$.fragment, a), o = !0);
    },
    o(a) {
      an(t.$$.fragment, a), o = !1;
    },
    d(a) {
      a && ir(e), qs(t), r = !1, s();
    }
  };
}
function Sp(i) {
  let e, t, n = (
    /*value*/
    i[0] && /*waveform*/
    i[3] && nl(i)
  );
  return {
    c() {
      n && n.c(), e = vp();
    },
    m(o, r) {
      n && n.m(o, r), or(o, e, r), t = !0;
    },
    p(o, r) {
      /*value*/
      o[0] && /*waveform*/
      o[3] ? n ? (n.p(o, r), r[0] & /*value, waveform*/
      9 && Lt(n, 1)) : (n = nl(o), n.c(), Lt(n, 1), n.m(e.parentNode, e)) : n && (Xa(), an(n, 1, 1, () => {
        n = null;
      }), Za());
    },
    i(o) {
      t || (Lt(n), t = !0);
    },
    o(o) {
      an(n), t = !1;
    },
    d(o) {
      o && ir(e), n && n.d(o);
    }
  };
}
function Ep(i, e) {
  const t = e.getBoundingClientRect(), n = t.left, o = t.right, r = i.element.getBoundingClientRect(), s = r.left, a = r.right;
  return s >= n && a <= o;
}
function Dp(i, e, t) {
  var n = this && this.__rest || function(w, L) {
    var B = {};
    for (var R in w) Object.prototype.hasOwnProperty.call(w, R) && L.indexOf(R) < 0 && (B[R] = w[R]);
    if (w != null && typeof Object.getOwnPropertySymbols == "function") for (var Z = 0, R = Object.getOwnPropertySymbols(w); Z < R.length; Z++)
      L.indexOf(R[Z]) < 0 && Object.prototype.propertyIsEnumerable.call(w, R[Z]) && (B[R[Z]] = w[R[Z]]);
    return B;
  };
  let { adjustTimeCursorPosition: o } = e, { i18n: r } = e, { waveform: s } = e, { wsGamepad: a } = e, { value: l = null } = e, { interactive: u = !0 } = e, { isDialogOpen: c = !1 } = e, { caption: d } = e, { mode: h = "" } = e, f, m, g = null, p = null, _ = null, y = null, v = /* @__PURE__ */ new Map();
  const C = kp();
  function M(w) {
    return v.get(w).speaker;
  }
  function k(w, L) {
    if (!L) {
      if (!_) return;
      L = _;
    }
    const B = n(L, ["color"]);
    L.setOptions(Object.assign({ color: w.color }, B)), v.get(L.id).speaker = w.name, b(), L === _ && P(_.color);
  }
  function P(w) {
    _ && t(18, _.element.style.background = "repeating-linear-gradient(45deg," + w + " ," + w + " 10px, #ffffff 10px ,#ffffff 15px)", _);
  }
  function D() {
    return m.getRegions();
  }
  function b() {
    t(0, l.annotations = Array.from(v.values()), l), C("edit", l);
  }
  function E(w) {
    u && (_ && t(18, _.element.style.background = _.color, _), t(18, _ = w), _ && (P(w.color), s.isPlaying() || Ep(w, f) || s.setTime(w.start)));
  }
  function U(w) {
    const L = w === "backward" ? -1 : 1;
    var B = D().sort((Z, ne) => Z.start > ne.start ? 1 : -1);
    if (_ === null)
      E(B[0]);
    else {
      var R = B.indexOf(_);
      E(B.at((R + L) % B.length));
    }
  }
  function T(w, L) {
    let B = m.addRegion(w);
    const R = {
      start: B.start,
      end: B.end,
      speaker: L,
      color: B.color
    };
    return v.set(B.id, R), y || (y = [R]), b(), B;
  }
  function j(w, L) {
    if (L < w.start || L > w.end)
      throw new RangeError("split time out of region bounds");
    const B = v.get(w.id).speaker, R = n(w, ["start", "id"]), Z = T(Object.assign({ start: L }, R), B), ne = n(w, ["end"]);
    w.setOptions(Object.assign({ end: L }, ne)), G(w), E(Z);
  }
  function V(w) {
    w === _ && E(null), v.delete(w.id), w.remove(), b();
  }
  function Q(w, L, B) {
    if (!_) return;
    let R = w === "backward" ? -1 : 1;
    B && (R = R * 5), _._onUpdate(R, L), G(_);
  }
  function q(w) {
    if (y || (y = [...w]), w.length === 0)
      return;
    const L = Array.from(v.values());
    w = w.filter((B) => !L.some((R) => B.start === R.start && B.end === R.end && B.speaker === R.speaker)), w.forEach((B) => {
      let R = d.getLabel("name", B.speaker, !0);
      T(
        {
          start: B.start,
          end: B.end,
          color: R.color,
          drag: u,
          resize: u
        },
        B.speaker
      );
    });
  }
  function I() {
    E(null), m == null || m.clearRegions(), t(0, l.annotations = [], l), v.clear();
  }
  function H() {
    I(), y.forEach((w) => l.annotations.push(Object.assign({}, w))), q(l.annotations), C("edit", l);
  }
  function G(w) {
    let L = v.get(w.id);
    L.start = w.start, L.end = w.end, b();
  }
  function F(w) {
    if (!u) return;
    let L = _;
    L ? w = L.start + (L.end - L.start) / 2 : L = m.getRegions().find((B) => B.start < w && B.end > w), L && j(L, w);
  }
  function K(w) {
    if (!u) return;
    const L = d.getActiveLabel() || d.getDefaultLabel();
    let B = T(
      {
        start: w - 1,
        end: w + 1,
        color: L.color,
        drag: !0,
        resize: !0
      },
      L.name
    );
    E(B);
  }
  function x(w, L) {
    if (!_) return;
    const B = m.getRegions().find((R) => R.id === _.id);
    w === "Delete" || w == "Backspace" && L ? U("forward") : U("backward"), V(B);
  }
  function A(w, L, B) {
    if (_) {
      Q(w === "ArrowLeft" ? "backward" : "forward", B ? "end" : "start", L);
      return;
    }
    o(w, L);
  }
  function S(w) {
    switch (w.idx) {
      case 0:
        E(null);
        break;
      case 1:
        K(s.getCurrentTime());
        break;
      case 2:
        x("Delete", !1);
        break;
      case 3:
        F(s.getCurrentTime());
        break;
      case 4:
        U("backward");
        break;
      case 5:
        U("forward");
        break;
    }
  }
  function W(w) {
    let L = w.value < 0 ? "ArrowLeft" : "ArrowRight";
    switch (w.idx) {
      case 0:
        A(L, !1, !1);
        break;
      case 2:
        A(L, !1, !0);
        break;
    }
  }
  Cp(() => {
    window.addEventListener("keydown", (w) => {
      if (!c)
        switch (w.key) {
          case "ArrowLeft":
            A("ArrowLeft", w.shiftKey, w.altKey);
            break;
          case "ArrowRight":
            A("ArrowRight", w.shiftKey, w.altKey);
            break;
          case "Escape":
            E(null);
            break;
          case "Tab":
            w.preventDefault(), U(w.shiftKey ? "backward" : "forward");
            break;
          case "Delete":
            x("Delete", w.shiftKey);
            break;
          case "Backspace":
            x("Backspace", w.shiftKey);
            break;
          case "Enter":
            w.preventDefault(), w.shiftKey ? F(s.getCurrentTime()) : K(s.getCurrentTime());
            break;
        }
    });
  });
  const z = () => t(1, h = "remove"), O = () => t(1, h = "split");
  return i.$$set = (w) => {
    "adjustTimeCursorPosition" in w && t(7, o = w.adjustTimeCursorPosition), "i18n" in w && t(2, r = w.i18n), "waveform" in w && t(3, s = w.waveform), "wsGamepad" in w && t(6, a = w.wsGamepad), "value" in w && t(0, l = w.value), "interactive" in w && t(4, u = w.interactive), "isDialogOpen" in w && t(8, c = w.isDialogOpen), "caption" in w && t(9, d = w.caption), "mode" in w && t(1, h = w.mode);
  }, i.$$.update = () => {
    if (i.$$.dirty[0] & /*waveform, wsGamepad, wsRegions, interactive, mode*/
    32858 && s.on("ready", () => {
      a || (t(6, a = s.registerPlugin(_p.create())), a == null || a.on("button-pressed", (w) => {
        S(w);
      }), a == null || a.on("axe-pushed", (w) => {
        W(w);
      })), m || (t(15, m = s.registerPlugin(nr.create())), u && (m == null || m.on("region-clicked", (w, L) => {
        switch (h) {
          case "remove":
            V(w);
            break;
          case "split":
            j(w, w.start + (w.end - w.start) / 2);
            break;
          default:
            E(w), w.play();
        }
        t(1, h = "");
      }), m == null || m.on("region-updated", (w) => {
        G(w);
      })));
    }), i.$$.dirty[0] & /*value, wsRegions*/
    32769 && (l == null ? void 0 : l.annotations) !== null && m && q(l.annotations), i.$$.dirty[0] & /*waveform*/
    8 && s.on("init", () => {
      let w = s.options.container;
      typeof w == "string" && (w = document.getElementById(w)), t(14, f = w);
    }), i.$$.dirty[0] & /*waveform*/
    8 && s.on("dblclick", () => {
      K(s.getCurrentTime());
    }), i.$$.dirty[0] & /*activeRegion, container, leftRegionHandle, rightRegionHandle, wsRegions*/
    507904 && _) {
      const w = f.children[0].shadowRoot;
      t(17, p = w.querySelector('[data-resize="right"]')), t(16, g = w.querySelector('[data-resize="left"]')), g && p && (g.setAttribute("role", "button"), p.setAttribute("role", "button"), g == null || g.setAttribute("aria-label", "Drag to adjust start time"), p == null || p.setAttribute("aria-label", "Drag to adjust end time"), g == null || g.setAttribute("tabindex", "0"), p == null || p.setAttribute("tabindex", "0"), g.addEventListener("focus", () => {
      }), p.addEventListener("focus", () => {
      }));
    }
  }, [
    l,
    h,
    r,
    s,
    u,
    H,
    a,
    o,
    c,
    d,
    M,
    k,
    P,
    D,
    f,
    m,
    g,
    p,
    _,
    z,
    O
  ];
}
class Rp extends gp {
  constructor(e) {
    super(), bp(
      this,
      e,
      Dp,
      Sp,
      yp,
      {
        adjustTimeCursorPosition: 7,
        i18n: 2,
        waveform: 3,
        wsGamepad: 6,
        value: 0,
        interactive: 4,
        isDialogOpen: 8,
        caption: 9,
        mode: 1,
        getRegionLabel: 10,
        setRegionLabel: 11,
        setActiveRegionBackground: 12,
        getRegions: 13
      },
      null,
      [-1, -1]
    );
  }
  get getRegionLabel() {
    return this.$$.ctx[10];
  }
  get setRegionLabel() {
    return this.$$.ctx[11];
  }
  get setActiveRegionBackground() {
    return this.$$.ctx[12];
  }
  get getRegions() {
    return this.$$.ctx[13];
  }
}
const { setContext: Kv, getContext: Mp } = window.__gradio__svelte__internal, Lp = "WORKER_PROXY_CONTEXT_KEY";
function Ja() {
  return Mp(Lp);
}
function Op(i) {
  return i.host === window.location.host || i.host === "localhost:7860" || i.host === "127.0.0.1:7860" || // Ref: https://github.com/gradio-app/gradio/blob/v3.32.0/js/app/src/Index.svelte#L194
  i.host === "lite.local";
}
function Ka(i, e) {
  const t = e.toLowerCase();
  for (const [n, o] of Object.entries(i))
    if (n.toLowerCase() === t)
      return o;
}
function Ya(i) {
  if (i == null)
    return !1;
  const e = new URL(i, window.location.href);
  return !(!Op(e) || e.protocol !== "http:" && e.protocol !== "https:");
}
async function ol(i) {
  if (i == null || !Ya(i))
    return i;
  const e = Ja();
  if (e == null)
    return i;
  const n = new URL(i, window.location.href).pathname;
  return e.httpRequest({
    method: "GET",
    path: n,
    headers: {},
    query_string: ""
  }).then((o) => {
    if (o.status !== 200)
      throw new Error(`Failed to get file ${n} from the Wasm worker.`);
    const r = new Blob([o.body], {
      type: Ka(o.headers, "content-type")
    });
    return URL.createObjectURL(r);
  });
}
const {
  SvelteComponent: Pp,
  assign: ho,
  check_outros: Qa,
  compute_rest_props: sl,
  create_slot: sr,
  detach: ko,
  element: $a,
  empty: xa,
  exclude_internal_props: Wp,
  get_all_dirty_from_scope: rr,
  get_slot_changes: lr,
  get_spread_update: eu,
  group_outros: tu,
  init: Ap,
  insert: Co,
  listen: nu,
  prevent_default: Tp,
  safe_not_equal: qp,
  set_attributes: mo,
  transition_in: mn,
  transition_out: pn,
  update_slot_base: ar
} = window.__gradio__svelte__internal, { createEventDispatcher: jp } = window.__gradio__svelte__internal;
function Np(i) {
  let e, t, n, o, r;
  const s = (
    /*#slots*/
    i[8].default
  ), a = sr(
    s,
    i,
    /*$$scope*/
    i[7],
    null
  );
  let l = [
    { href: (
      /*href*/
      i[0]
    ) },
    {
      target: t = typeof window < "u" && window.__is_colab__ ? "_blank" : null
    },
    { rel: "noopener noreferrer" },
    { download: (
      /*download*/
      i[1]
    ) },
    /*$$restProps*/
    i[6]
  ], u = {};
  for (let c = 0; c < l.length; c += 1)
    u = ho(u, l[c]);
  return {
    c() {
      e = $a("a"), a && a.c(), mo(e, u);
    },
    m(c, d) {
      Co(c, e, d), a && a.m(e, null), n = !0, o || (r = nu(
        e,
        "click",
        /*dispatch*/
        i[3].bind(null, "click")
      ), o = !0);
    },
    p(c, d) {
      a && a.p && (!n || d & /*$$scope*/
      128) && ar(
        a,
        s,
        c,
        /*$$scope*/
        c[7],
        n ? lr(
          s,
          /*$$scope*/
          c[7],
          d,
          null
        ) : rr(
          /*$$scope*/
          c[7]
        ),
        null
      ), mo(e, u = eu(l, [
        (!n || d & /*href*/
        1) && { href: (
          /*href*/
          c[0]
        ) },
        { target: t },
        { rel: "noopener noreferrer" },
        (!n || d & /*download*/
        2) && { download: (
          /*download*/
          c[1]
        ) },
        d & /*$$restProps*/
        64 && /*$$restProps*/
        c[6]
      ]));
    },
    i(c) {
      n || (mn(a, c), n = !0);
    },
    o(c) {
      pn(a, c), n = !1;
    },
    d(c) {
      c && ko(e), a && a.d(c), o = !1, r();
    }
  };
}
function zp(i) {
  let e, t, n, o;
  const r = [Ip, Bp], s = [];
  function a(l, u) {
    return (
      /*is_downloading*/
      l[2] ? 0 : 1
    );
  }
  return e = a(i), t = s[e] = r[e](i), {
    c() {
      t.c(), n = xa();
    },
    m(l, u) {
      s[e].m(l, u), Co(l, n, u), o = !0;
    },
    p(l, u) {
      let c = e;
      e = a(l), e === c ? s[e].p(l, u) : (tu(), pn(s[c], 1, 1, () => {
        s[c] = null;
      }), Qa(), t = s[e], t ? t.p(l, u) : (t = s[e] = r[e](l), t.c()), mn(t, 1), t.m(n.parentNode, n));
    },
    i(l) {
      o || (mn(t), o = !0);
    },
    o(l) {
      pn(t), o = !1;
    },
    d(l) {
      l && ko(n), s[e].d(l);
    }
  };
}
function Bp(i) {
  let e, t, n, o;
  const r = (
    /*#slots*/
    i[8].default
  ), s = sr(
    r,
    i,
    /*$$scope*/
    i[7],
    null
  );
  let a = [
    /*$$restProps*/
    i[6],
    { href: (
      /*href*/
      i[0]
    ) }
  ], l = {};
  for (let u = 0; u < a.length; u += 1)
    l = ho(l, a[u]);
  return {
    c() {
      e = $a("a"), s && s.c(), mo(e, l);
    },
    m(u, c) {
      Co(u, e, c), s && s.m(e, null), t = !0, n || (o = nu(e, "click", Tp(
        /*wasm_click_handler*/
        i[5]
      )), n = !0);
    },
    p(u, c) {
      s && s.p && (!t || c & /*$$scope*/
      128) && ar(
        s,
        r,
        u,
        /*$$scope*/
        u[7],
        t ? lr(
          r,
          /*$$scope*/
          u[7],
          c,
          null
        ) : rr(
          /*$$scope*/
          u[7]
        ),
        null
      ), mo(e, l = eu(a, [
        c & /*$$restProps*/
        64 && /*$$restProps*/
        u[6],
        (!t || c & /*href*/
        1) && { href: (
          /*href*/
          u[0]
        ) }
      ]));
    },
    i(u) {
      t || (mn(s, u), t = !0);
    },
    o(u) {
      pn(s, u), t = !1;
    },
    d(u) {
      u && ko(e), s && s.d(u), n = !1, o();
    }
  };
}
function Ip(i) {
  let e;
  const t = (
    /*#slots*/
    i[8].default
  ), n = sr(
    t,
    i,
    /*$$scope*/
    i[7],
    null
  );
  return {
    c() {
      n && n.c();
    },
    m(o, r) {
      n && n.m(o, r), e = !0;
    },
    p(o, r) {
      n && n.p && (!e || r & /*$$scope*/
      128) && ar(
        n,
        t,
        o,
        /*$$scope*/
        o[7],
        e ? lr(
          t,
          /*$$scope*/
          o[7],
          r,
          null
        ) : rr(
          /*$$scope*/
          o[7]
        ),
        null
      );
    },
    i(o) {
      e || (mn(n, o), e = !0);
    },
    o(o) {
      pn(n, o), e = !1;
    },
    d(o) {
      n && n.d(o);
    }
  };
}
function Up(i) {
  let e, t, n, o, r;
  const s = [zp, Np], a = [];
  function l(u, c) {
    return c & /*href*/
    1 && (e = null), e == null && (e = !!/*worker_proxy*/
    (u[4] && Ya(
      /*href*/
      u[0]
    ))), e ? 0 : 1;
  }
  return t = l(i, -1), n = a[t] = s[t](i), {
    c() {
      n.c(), o = xa();
    },
    m(u, c) {
      a[t].m(u, c), Co(u, o, c), r = !0;
    },
    p(u, [c]) {
      let d = t;
      t = l(u, c), t === d ? a[t].p(u, c) : (tu(), pn(a[d], 1, 1, () => {
        a[d] = null;
      }), Qa(), n = a[t], n ? n.p(u, c) : (n = a[t] = s[t](u), n.c()), mn(n, 1), n.m(o.parentNode, o));
    },
    i(u) {
      r || (mn(n), r = !0);
    },
    o(u) {
      pn(n), r = !1;
    },
    d(u) {
      u && ko(o), a[t].d(u);
    }
  };
}
function Fp(i, e, t) {
  const n = ["href", "download"];
  let o = sl(e, n), { $$slots: r = {}, $$scope: s } = e;
  var a = this && this.__awaiter || function(m, g, p, _) {
    function y(v) {
      return v instanceof p ? v : new p(function(C) {
        C(v);
      });
    }
    return new (p || (p = Promise))(function(v, C) {
      function M(D) {
        try {
          P(_.next(D));
        } catch (b) {
          C(b);
        }
      }
      function k(D) {
        try {
          P(_.throw(D));
        } catch (b) {
          C(b);
        }
      }
      function P(D) {
        D.done ? v(D.value) : y(D.value).then(M, k);
      }
      P((_ = _.apply(m, g || [])).next());
    });
  };
  let { href: l = void 0 } = e, { download: u } = e;
  const c = jp();
  let d = !1;
  const h = Ja();
  function f() {
    return a(this, void 0, void 0, function* () {
      if (d)
        return;
      if (c("click"), l == null)
        throw new Error("href is not defined.");
      if (h == null)
        throw new Error("Wasm worker proxy is not available.");
      const g = new URL(l, window.location.href).pathname;
      t(2, d = !0), h.httpRequest({
        method: "GET",
        path: g,
        headers: {},
        query_string: ""
      }).then((p) => {
        if (p.status !== 200)
          throw new Error(`Failed to get file ${g} from the Wasm worker.`);
        const _ = new Blob(
          [p.body],
          {
            type: Ka(p.headers, "content-type")
          }
        ), y = URL.createObjectURL(_), v = document.createElement("a");
        v.href = y, v.download = u, v.click(), URL.revokeObjectURL(y);
      }).finally(() => {
        t(2, d = !1);
      });
    });
  }
  return i.$$set = (m) => {
    e = ho(ho({}, e), Wp(m)), t(6, o = sl(e, n)), "href" in m && t(0, l = m.href), "download" in m && t(1, u = m.download), "$$scope" in m && t(7, s = m.$$scope);
  }, [
    l,
    u,
    d,
    c,
    h,
    f,
    o,
    s,
    r
  ];
}
class iu extends Pp {
  constructor(e) {
    super(), Ap(this, e, Fp, Up, qp, { href: 0, download: 1 });
  }
}
const {
  SvelteComponent: Gp,
  append: rl,
  attr: St,
  detach: Vp,
  init: Hp,
  insert: Zp,
  noop: ss,
  safe_not_equal: Xp,
  svg_element: rs
} = window.__gradio__svelte__internal;
function Jp(i) {
  let e, t, n;
  return {
    c() {
      e = rs("svg"), t = rs("g"), n = rs("path"), St(n, "d", `M41.267,18.557H26.832V4.134C26.832,1.851,24.99,0,22.707,0c-2.283,0-4.124,1.851-4.124,4.135v14.432H4.141\r
		c-2.283,0-4.139,1.851-4.138,4.135c-0.001,1.141,0.46,2.187,1.207,2.934c0.748,0.749,1.78,1.222,2.92,1.222h14.453V41.27\r
		c0,1.142,0.453,2.176,1.201,2.922c0.748,0.748,1.777,1.211,2.919,1.211c2.282,0,4.129-1.851,4.129-4.133V26.857h14.435\r
		c2.283,0,4.134-1.867,4.133-4.15C45.399,20.425,43.548,18.557,41.267,18.557z`), St(e, "version", "1.1"), St(e, "id", "Capa_1"), St(e, "xmlns", "http://www.w3.org/2000/svg"), St(e, "xmlns:xlink", "http://www.w3.org/1999/xlink"), St(e, "width", "100%"), St(e, "height", "100%"), St(e, "viewBox", "0 10 45.402 45.402	"), St(e, "xml:space", "preserve");
    },
    m(o, r) {
      Zp(o, e, r), rl(e, t), rl(t, n);
    },
    p: ss,
    i: ss,
    o: ss,
    d(o) {
      o && Vp(e);
    }
  };
}
class Kp extends Gp {
  constructor(e) {
    super(), Hp(this, e, null, Jp, Xp, {});
  }
}
const {
  SvelteComponent: Yp,
  append: Je,
  attr: fe,
  binding_callbacks: Qp,
  detach: $p,
  element: Ut,
  init: xp,
  insert: e_,
  listen: Ki,
  noop: ll,
  run_all: t_,
  safe_not_equal: n_,
  set_input_value: Yi,
  space: li
} = window.__gradio__svelte__internal, { createEventDispatcher: i_, onMount: o_ } = window.__gradio__svelte__internal;
function s_(i) {
  let e, t, n, o, r, s, a, l, u, c, d, h, f, m, g;
  return {
    c() {
      e = Ut("dialog"), t = Ut("label"), t.textContent = "Label name:", n = li(), o = Ut("input"), r = li(), s = Ut("label"), s.textContent = "Label color:", a = li(), l = Ut("input"), u = li(), c = Ut("div"), d = Ut("button"), d.textContent = "Cancel", h = li(), f = Ut("button"), f.textContent = "Submit", fe(t, "for", "name"), fe(t, "class", "svelte-1b11e9c"), fe(o, "type", "text"), fe(o, "maxlength", "30"), fe(o, "id", "name"), fe(o, "name", "name"), fe(o, "class", "svelte-1b11e9c"), fe(s, "for", "color"), fe(s, "class", "svelte-1b11e9c"), fe(l, "type", "color"), fe(l, "id", "color"), fe(l, "name", "color"), fe(l, "class", "svelte-1b11e9c"), fe(d, "id", "cancel"), fe(d, "class", "svelte-1b11e9c"), fe(f, "id", "submit"), fe(f, "class", "svelte-1b11e9c"), fe(c, "class", "dialog-buttons svelte-1b11e9c"), fe(c, "id", "color"), fe(e, "class", "dialog-box svelte-1b11e9c"), fe(e, "id", "dialog-box"), e.hidden = !0;
    },
    m(p, _) {
      e_(p, e, _), Je(e, t), Je(e, n), Je(e, o), Yi(
        o,
        /*name*/
        i[0]
      ), Je(e, r), Je(e, s), Je(e, a), Je(e, l), Yi(
        l,
        /*color*/
        i[1]
      ), Je(e, u), Je(e, c), Je(c, d), Je(c, h), Je(c, f), i[9](e), m || (g = [
        Ki(
          o,
          "input",
          /*input0_input_handler*/
          i[7]
        ),
        Ki(
          l,
          "input",
          /*input1_input_handler*/
          i[8]
        ),
        Ki(
          d,
          "click",
          /*onClose*/
          i[3]
        ),
        Ki(
          f,
          "click",
          /*onSubmit*/
          i[4]
        )
      ], m = !0);
    },
    p(p, [_]) {
      _ & /*name*/
      1 && o.value !== /*name*/
      p[0] && Yi(
        o,
        /*name*/
        p[0]
      ), _ & /*color*/
      2 && Yi(
        l,
        /*color*/
        p[1]
      );
    },
    i: ll,
    o: ll,
    d(p) {
      p && $p(e), i[9](null), m = !1, t_(g);
    }
  };
}
function r_(i, e, t) {
  let { isOpen: n = !1 } = e, o, r, s, a;
  const l = i_();
  function u(g) {
    t(0, o = g.name), t(1, r = g.color.slice(0, g.color.length - 2)), s = g.shortcut, a.showModal(), document.getElementById("dialog-box").hidden = !1, document.getElementById("name").focus(), t(5, n = !0);
  }
  function c() {
    a.close(), t(0, o = t(1, r = s = void 0)), document.getElementById("dialog-box").hidden = !0, t(5, n = !1);
  }
  function d() {
    l("submit", { name: o, color: r + "80", shortcut: s }), c();
  }
  o_(() => {
    window.addEventListener("keydown", (g) => {
      if (n)
        switch (g.key) {
          case "Enter":
            d();
            break;
          case "Escape":
            c();
            break;
        }
    });
  });
  function h() {
    o = this.value, t(0, o);
  }
  function f() {
    r = this.value, t(1, r);
  }
  function m(g) {
    Qp[g ? "unshift" : "push"](() => {
      a = g, t(2, a);
    });
  }
  return i.$$set = (g) => {
    "isOpen" in g && t(5, n = g.isOpen);
  }, [
    o,
    r,
    a,
    c,
    d,
    n,
    u,
    h,
    f,
    m
  ];
}
class l_ extends Yp {
  constructor(e) {
    super(), xp(this, e, r_, s_, n_, { isOpen: 5, openDialog: 6 });
  }
  get openDialog() {
    return this.$$.ctx[6];
  }
}
const {
  SvelteComponent: a_,
  add_flush_callback: u_,
  append: ls,
  attr: so,
  bind: c_,
  binding_callbacks: zs,
  check_outros: d_,
  create_component: ou,
  destroy_component: su,
  detach: Bs,
  element: ro,
  group_outros: f_,
  init: h_,
  insert: Is,
  listen: m_,
  mount_component: ru,
  noop: p_,
  safe_not_equal: __,
  space: al,
  transition_in: _i,
  transition_out: lo
} = window.__gradio__svelte__internal, { createEventDispatcher: g_, onMount: v_ } = window.__gradio__svelte__internal;
function ul(i) {
  let e, t, n, o, r;
  return t = new Kp({}), {
    c() {
      e = ro("button"), ou(t.$$.fragment), so(e, "class", "create-label svelte-43he0g");
    },
    m(s, a) {
      Is(s, e, a), ru(t, e, null), n = !0, o || (r = m_(
        e,
        "click",
        /*click_handler*/
        i[13]
      ), o = !0);
    },
    p: p_,
    i(s) {
      n || (_i(t.$$.fragment, s), n = !0);
    },
    o(s) {
      lo(t.$$.fragment, s), n = !1;
    },
    d(s) {
      s && Bs(e), su(t), o = !1, r();
    }
  };
}
function b_(i) {
  let e, t, n, o, r, s, a, l, u = (
    /*interactive*/
    i[1] && ul(i)
  );
  function c(h) {
    i[15](h);
  }
  let d = {};
  return (
    /*isDialogOpen*/
    i[0] !== void 0 && (d.isOpen = /*isDialogOpen*/
    i[0]), s = new l_({ props: d }), i[14](s), zs.push(() => c_(s, "isOpen", c)), s.$on(
      "submit",
      /*submit_handler*/
      i[16]
    ), {
      c() {
        e = ro("div"), t = ro("div"), n = al(), o = ro("div"), u && u.c(), r = al(), ou(s.$$.fragment), so(t, "class", "caption svelte-43he0g"), so(o, "class", "action-buttons svelte-43he0g"), so(e, "class", "caption-container svelte-43he0g");
      },
      m(h, f) {
        Is(h, e, f), ls(e, t), i[12](t), ls(e, n), ls(e, o), u && u.m(o, null), Is(h, r, f), ru(s, h, f), l = !0;
      },
      p(h, [f]) {
        /*interactive*/
        h[1] ? u ? (u.p(h, f), f & /*interactive*/
        2 && _i(u, 1)) : (u = ul(h), u.c(), _i(u, 1), u.m(o, null)) : u && (f_(), lo(u, 1, 1, () => {
          u = null;
        }), d_());
        const m = {};
        !a && f & /*isDialogOpen*/
        1 && (a = !0, m.isOpen = /*isDialogOpen*/
        h[0], u_(() => a = !1)), s.$set(m);
      },
      i(h) {
        l || (_i(u), _i(s.$$.fragment, h), l = !0);
      },
      o(h) {
        lo(u), lo(s.$$.fragment, h), l = !1;
      },
      d(h) {
        h && (Bs(e), Bs(r)), i[12](null), u && u.d(), i[14](null), su(s, h);
      }
    }
  );
}
function cl(i) {
  let e = document.getElementById(i.shortcut);
  e.style.backgroundColor = i.color, e.innerHTML = '<span style="font-weight: bold;">' + i.shortcut + "</span>: " + i.name;
}
function w_(i, e, t) {
  let { isDialogOpen: n = !1 } = e, { interactive: o = !0 } = e, { wsGamepad: r } = e, s, a = [], l, u = null;
  const c = ["#ffd70080", "#0000ff80", "#ff000080", "#00ff0080"], d = g_();
  function h() {
    return u;
  }
  function f() {
    return a[0] || g({});
  }
  function m(b) {
    const E = document.createElement("button");
    E.id = b.shortcut, E.addEventListener("focusin", () => y(b.shortcut)), E.addEventListener("focusout", () => y()), E.addEventListener("dblclick", () => l.openDialog(b)), s.appendChild(E), cl(b);
  }
  function g(b) {
    const E = a.length;
    if (E === 26)
      return;
    if (b.name || (b.name = "LABEL_" + E.toString().padStart(2, "0")), p("name", b.name))
      return p("name", b.name);
    if (b.color || (b.color = c[E % c.length]), !b.shortcut)
      for (b.shortcut = "A"; a.some((T) => T.shortcut === b.shortcut) && b.shortcut !== "Z"; )
        b.shortcut = String.fromCharCode(b.shortcut.charCodeAt(0) + 1);
    const U = {
      name: b.name,
      color: b.color,
      shortcut: b.shortcut
    };
    return a.push(U), m(U), t(3, a = a.sort((T, j) => T.shortcut.localeCompare(j.shortcut))), U;
  }
  function p(b, E, U) {
    U === void 0 && (U = !1);
    let T = a.find((j) => j[b] === E);
    if (T == null && U) {
      const j = {};
      j[b] = E, T = g(j);
    }
    return T;
  }
  function _(b, E = {}) {
    const { name: U = b.name, color: T = b.color, shortcut: j = b.shortcut } = E;
    if (b.name !== U && (b.name = U, d("name_update", b)), b.color !== T && (b.color = T, d("color_update", b)), !a.find((V) => V.shortcut === j)) {
      let V = document.getElementById(b.shortcut);
      b.shortcut = j, V.id = b.shortcut;
    }
    cl(b);
  }
  function y(b) {
    let E = null;
    b !== void 0 && (E = p("shortcut", b, !0)), u && (document.getElementById(u.shortcut).classList.remove("active-button"), document.getElementById(u.shortcut).blur()), u = E, u && (document.getElementById(u.shortcut).classList.add("active-button"), document.getElementById(u.shortcut).focus(), d("select", u));
  }
  function v(b) {
    let E = a.findIndex((U) => U.shortcut === (u == null ? void 0 : u.shortcut));
    switch (b.idx) {
      case 14:
        y(a.at(E - 1 % a.length).shortcut);
        break;
      case 15:
        y(a.at((E + 1) % a.length).shortcut);
        break;
    }
  }
  v_(() => {
    window.addEventListener("keydown", (b) => {
      if (!n)
        if (b.key.match(/^[a-zA-Z]$/)) {
          let E = b.key.toUpperCase();
          y(E);
        } else b.key === "Escape" ? y() : b.key === "F2" && u && l.openDialog(u);
    });
  });
  function C(b) {
    zs[b ? "unshift" : "push"](() => {
      s = b, t(2, s);
    });
  }
  const M = () => {
    const b = g({});
    y(b.shortcut);
  };
  function k(b) {
    zs[b ? "unshift" : "push"](() => {
      l = b, t(4, l);
    });
  }
  function P(b) {
    n = b, t(0, n);
  }
  const D = (b) => {
    let E = a.find((U) => U.shortcut === b.detail.shortcut);
    _(E, b.detail);
  };
  return i.$$set = (b) => {
    "isDialogOpen" in b && t(0, n = b.isDialogOpen), "interactive" in b && t(1, o = b.interactive), "wsGamepad" in b && t(8, r = b.wsGamepad);
  }, i.$$.update = () => {
    i.$$.dirty & /*wsGamepad*/
    256 && (r == null || r.on("button-pressed", (b) => v(b)));
  }, [
    n,
    o,
    s,
    a,
    l,
    g,
    _,
    y,
    r,
    h,
    f,
    p,
    C,
    M,
    k,
    P,
    D
  ];
}
class y_ extends a_ {
  constructor(e) {
    super(), h_(this, e, w_, b_, __, {
      isDialogOpen: 0,
      interactive: 1,
      wsGamepad: 8,
      getActiveLabel: 9,
      getDefaultLabel: 10,
      getLabel: 11
    });
  }
  get getActiveLabel() {
    return this.$$.ctx[9];
  }
  get getDefaultLabel() {
    return this.$$.ctx[10];
  }
  get getLabel() {
    return this.$$.ctx[11];
  }
}
const {
  SvelteComponent: k_,
  add_flush_callback: Us,
  append: Qe,
  attr: Ee,
  bind: Fs,
  binding_callbacks: Zt,
  check_outros: ur,
  create_component: ki,
  destroy_component: Ci,
  detach: zn,
  element: lt,
  empty: lu,
  group_outros: cr,
  init: C_,
  insert: Bn,
  mount_component: Si,
  noop: dl,
  safe_not_equal: S_,
  space: vi,
  src_url_equal: fl,
  transition_in: Ge,
  transition_out: ct
} = window.__gradio__svelte__internal, { createEventDispatcher: E_ } = window.__gradio__svelte__internal;
function D_(i) {
  let e, t, n, o, r, s, a, l, u, c, d, h, f = (
    /*waveform*/
    i[9] && hl(i)
  );
  return {
    c() {
      e = lt("div"), t = lt("div"), n = lt("div"), o = vi(), r = lt("div"), s = lt("time"), s.textContent = "0:00", a = vi(), l = lt("div"), u = lt("time"), u.textContent = "0:00", c = vi(), f && f.c(), Ee(n, "id", "waveform"), Ee(n, "class", "svelte-1upl4zx"), Ee(t, "class", "waveform-container svelte-1upl4zx"), Ee(s, "id", "time"), Ee(s, "class", "svelte-1upl4zx"), Ee(u, "id", "duration"), Ee(u, "class", "svelte-1upl4zx"), Ee(r, "class", "timestamps svelte-1upl4zx"), Ee(e, "class", "component-wrapper svelte-1upl4zx"), Ee(e, "data-testid", d = /*label*/
      i[2] ? "waveform-" + /*label*/
      i[2] : "unlabelled-audio");
    },
    m(m, g) {
      Bn(m, e, g), Qe(e, t), Qe(t, n), i[22](n), Qe(e, o), Qe(e, r), Qe(r, s), i[23](s), Qe(r, a), Qe(r, l), Qe(l, u), i[24](u), Qe(e, c), f && f.m(e, null), h = !0;
    },
    p(m, g) {
      /*waveform*/
      m[9] ? f ? (f.p(m, g), g[0] & /*waveform*/
      512 && Ge(f, 1)) : (f = hl(m), f.c(), Ge(f, 1), f.m(e, null)) : f && (cr(), ct(f, 1, 1, () => {
        f = null;
      }), ur()), (!h || g[0] & /*label*/
      4 && d !== (d = /*label*/
      m[2] ? "waveform-" + /*label*/
      m[2] : "unlabelled-audio")) && Ee(e, "data-testid", d);
    },
    i(m) {
      h || (Ge(f), h = !0);
    },
    o(m) {
      ct(f), h = !1;
    },
    d(m) {
      m && zn(e), i[22](null), i[23](null), i[24](null), f && f.d();
    }
  };
}
function R_(i) {
  let e, t, n;
  return {
    c() {
      e = lt("audio"), Ee(e, "class", "standard-player svelte-1upl4zx"), fl(e.src, t = /*value*/
      i[4].file_data.url) || Ee(e, "src", t), e.controls = !0, e.autoplay = n = /*waveform_settings*/
      i[6].autoplay;
    },
    m(o, r) {
      Bn(o, e, r);
    },
    p(o, r) {
      r[0] & /*value*/
      16 && !fl(e.src, t = /*value*/
      o[4].file_data.url) && Ee(e, "src", t), r[0] & /*waveform_settings*/
      64 && n !== (n = /*waveform_settings*/
      o[6].autoplay) && (e.autoplay = n);
    },
    i: dl,
    o: dl,
    d(o) {
      o && zn(e);
    }
  };
}
function M_(i) {
  let e, t;
  return e = new Sa({
    props: {
      size: "small",
      $$slots: { default: [L_] },
      $$scope: { ctx: i }
    }
  }), {
    c() {
      ki(e.$$.fragment);
    },
    m(n, o) {
      Si(e, n, o), t = !0;
    },
    p(n, o) {
      const r = {};
      o[1] & /*$$scope*/
      1024 && (r.$$scope = { dirty: o, ctx: n }), e.$set(r);
    },
    i(n) {
      t || (Ge(e.$$.fragment, n), t = !0);
    },
    o(n) {
      ct(e.$$.fragment, n), t = !1;
    },
    d(n) {
      Ci(e, n);
    }
  };
}
function hl(i) {
  let e, t, n, o, r, s, a, l, u, c, d;
  n = new Ua({
    props: {
      isDialogOpen: (
        /*isDialogOpen*/
        i[0]
      ),
      waveform: (
        /*waveform*/
        i[9]
      ),
      wsGamepad: (
        /*wsGamepad*/
        i[10]
      ),
      audio_duration: (
        /*audio_duration*/
        i[13]
      ),
      i18n: (
        /*i18n*/
        i[3]
      ),
      waveform_options: (
        /*waveform_options*/
        i[7]
      )
    }
  }), n.$on(
    "play",
    /*play_handler*/
    i[25]
  ), n.$on(
    "stop",
    /*stop_handler*/
    i[26]
  ), n.$on(
    "pause",
    /*pause_handler*/
    i[27]
  );
  function h(p) {
    i[29](p);
  }
  function f(p) {
    i[30](p);
  }
  let m = {
    adjustTimeCursorPosition: (
      /*adjustTimeCursorPosition*/
      i[17]
    ),
    waveform: (
      /*waveform*/
      i[9]
    ),
    caption: (
      /*caption*/
      i[14]
    ),
    wsGamepad: (
      /*wsGamepad*/
      i[10]
    ),
    i18n: (
      /*i18n*/
      i[3]
    ),
    value: (
      /*value*/
      i[4]
    )
  };
  /*mode*/
  i[1] !== void 0 && (m.mode = /*mode*/
  i[1]), /*isDialogOpen*/
  i[0] !== void 0 && (m.isDialogOpen = /*isDialogOpen*/
  i[0]), s = new Rp({ props: m }), i[28](s), Zt.push(() => Fs(s, "mode", h)), Zt.push(() => Fs(s, "isDialogOpen", f)), s.$on(
    "edit",
    /*edit_handler*/
    i[31]
  );
  let g = (
    /*value*/
    i[4] && ml(i)
  );
  return {
    c() {
      e = lt("div"), t = lt("div"), ki(n.$$.fragment), o = vi(), r = lt("div"), ki(s.$$.fragment), u = vi(), g && g.c(), c = lu(), Ee(t, "class", "waveform-controls svelte-1upl4zx"), Ee(r, "class", "regions-controls"), Ee(e, "class", "commands svelte-1upl4zx");
    },
    m(p, _) {
      Bn(p, e, _), Qe(e, t), Si(n, t, null), Qe(e, o), Qe(e, r), Si(s, r, null), Bn(p, u, _), g && g.m(p, _), Bn(p, c, _), d = !0;
    },
    p(p, _) {
      const y = {};
      _[0] & /*isDialogOpen*/
      1 && (y.isDialogOpen = /*isDialogOpen*/
      p[0]), _[0] & /*waveform*/
      512 && (y.waveform = /*waveform*/
      p[9]), _[0] & /*wsGamepad*/
      1024 && (y.wsGamepad = /*wsGamepad*/
      p[10]), _[0] & /*audio_duration*/
      8192 && (y.audio_duration = /*audio_duration*/
      p[13]), _[0] & /*i18n*/
      8 && (y.i18n = /*i18n*/
      p[3]), _[0] & /*waveform_options*/
      128 && (y.waveform_options = /*waveform_options*/
      p[7]), n.$set(y);
      const v = {};
      _[0] & /*waveform*/
      512 && (v.waveform = /*waveform*/
      p[9]), _[0] & /*caption*/
      16384 && (v.caption = /*caption*/
      p[14]), _[0] & /*wsGamepad*/
      1024 && (v.wsGamepad = /*wsGamepad*/
      p[10]), _[0] & /*i18n*/
      8 && (v.i18n = /*i18n*/
      p[3]), _[0] & /*value*/
      16 && (v.value = /*value*/
      p[4]), !a && _[0] & /*mode*/
      2 && (a = !0, v.mode = /*mode*/
      p[1], Us(() => a = !1)), !l && _[0] & /*isDialogOpen*/
      1 && (l = !0, v.isDialogOpen = /*isDialogOpen*/
      p[0], Us(() => l = !1)), s.$set(v), /*value*/
      p[4] ? g ? (g.p(p, _), _[0] & /*value*/
      16 && Ge(g, 1)) : (g = ml(p), g.c(), Ge(g, 1), g.m(c.parentNode, c)) : g && (cr(), ct(g, 1, 1, () => {
        g = null;
      }), ur());
    },
    i(p) {
      d || (Ge(n.$$.fragment, p), Ge(s.$$.fragment, p), Ge(g), d = !0);
    },
    o(p) {
      ct(n.$$.fragment, p), ct(s.$$.fragment, p), ct(g), d = !1;
    },
    d(p) {
      p && (zn(e), zn(u), zn(c)), Ci(n), i[28](null), Ci(s), g && g.d(p);
    }
  };
}
function ml(i) {
  let e, t, n;
  function o(s) {
    i[33](s);
  }
  let r = {
    interactive: (
      /*interactive*/
      i[5]
    ),
    wsGamepad: (
      /*wsGamepad*/
      i[10]
    )
  };
  return (
    /*isDialogOpen*/
    i[0] !== void 0 && (r.isDialogOpen = /*isDialogOpen*/
    i[0]), e = new y_({ props: r }), i[32](e), Zt.push(() => Fs(e, "isDialogOpen", o)), e.$on(
      "select",
      /*select_handler*/
      i[34]
    ), e.$on(
      "name_update",
      /*name_update_handler*/
      i[35]
    ), e.$on(
      "color_update",
      /*color_update_handler*/
      i[36]
    ), {
      c() {
        ki(e.$$.fragment);
      },
      m(s, a) {
        Si(e, s, a), n = !0;
      },
      p(s, a) {
        const l = {};
        a[0] & /*interactive*/
        32 && (l.interactive = /*interactive*/
        s[5]), a[0] & /*wsGamepad*/
        1024 && (l.wsGamepad = /*wsGamepad*/
        s[10]), !t && a[0] & /*isDialogOpen*/
        1 && (t = !0, l.isDialogOpen = /*isDialogOpen*/
        s[0], Us(() => t = !1)), e.$set(l);
      },
      i(s) {
        n || (Ge(e.$$.fragment, s), n = !0);
      },
      o(s) {
        ct(e.$$.fragment, s), n = !1;
      },
      d(s) {
        i[32](null), Ci(e, s);
      }
    }
  );
}
function L_(i) {
  let e, t;
  return e = new go({}), {
    c() {
      ki(e.$$.fragment);
    },
    m(n, o) {
      Si(e, n, o), t = !0;
    },
    i(n) {
      t || (Ge(e.$$.fragment, n), t = !0);
    },
    o(n) {
      ct(e.$$.fragment, n), t = !1;
    },
    d(n) {
      Ci(e, n);
    }
  };
}
function O_(i) {
  let e, t, n, o;
  const r = [M_, R_, D_], s = [];
  function a(l, u) {
    return (
      /*value*/
      l[4] === null ? 0 : (
        /*value*/
        l[4].file_data.is_stream ? 1 : 2
      )
    );
  }
  return e = a(i), t = s[e] = r[e](i), {
    c() {
      t.c(), n = lu();
    },
    m(l, u) {
      s[e].m(l, u), Bn(l, n, u), o = !0;
    },
    p(l, u) {
      let c = e;
      e = a(l), e === c ? s[e].p(l, u) : (cr(), ct(s[c], 1, 1, () => {
        s[c] = null;
      }), ur(), t = s[e], t ? t.p(l, u) : (t = s[e] = r[e](l), t.c()), Ge(t, 1), t.m(n.parentNode, n));
    },
    i(l) {
      o || (Ge(t), o = !0);
    },
    o(l) {
      ct(t), o = !1;
    },
    d(l) {
      l && zn(n), s[e].d(l);
    }
  };
}
function pl(i) {
  const e = Math.floor(i / 60), n = `0${Math.round(i) % 60}`.slice(-2);
  return `${e}:${n}`;
}
function P_(i, e, t) {
  let n;
  var o = this && this.__awaiter || function(O, w, L, B) {
    function R(Z) {
      return Z instanceof L ? Z : new L(function(ne) {
        ne(Z);
      });
    }
    return new (L || (L = Promise))(function(Z, ne) {
      function ae(Ne) {
        try {
          $(B.next(Ne));
        } catch (ft) {
          ne(ft);
        }
      }
      function Ct(Ne) {
        try {
          $(B.throw(Ne));
        } catch (ft) {
          ne(ft);
        }
      }
      function $(Ne) {
        Ne.done ? Z(Ne.value) : R(Ne.value).then(ae, Ct);
      }
      $((B = B.apply(O, w || [])).next());
    });
  }, r;
  let { label: s } = e, { i18n: a } = e, { value: l = null } = e, { interactive: u = !0 } = e, { show_minimap: c = !0 } = e, { waveform_settings: d } = e, { waveform_options: h } = e, { isDialogOpen: f } = e, { mode: m = "" } = e, g, p, _, y, v, C, M, k, P;
  const D = E_();
  function b() {
    var O;
    t(9, p = Fn.create(Object.assign({ container: g }, d))), ol((O = l.file_data) === null || O === void 0 ? void 0 : O.url).then((w) => {
      if (w && p)
        return p.load(w);
    });
  }
  function E(O, w) {
    let L = p.getCurrentTime(), B, R = 0.05;
    w && (R = R * 4), O === "ArrowLeft" ? B = L - R : B = L + R, p.setTime(B);
  }
  function U(O) {
    return o(this, void 0, void 0, function* () {
      yield ol(O).then((w) => {
        var L;
        if (!(!w || !((L = l.file_data) === null || L === void 0) && L.is_stream))
          return p == null ? void 0 : p.load(w);
      });
    });
  }
  function T(O) {
    Zt[O ? "unshift" : "push"](() => {
      g = O, t(8, g), t(9, p);
    });
  }
  function j(O) {
    Zt[O ? "unshift" : "push"](() => {
      v = O, t(11, v), t(9, p);
    });
  }
  function V(O) {
    Zt[O ? "unshift" : "push"](() => {
      C = O, t(12, C), t(9, p);
    });
  }
  const Q = () => D("play"), q = () => D("stop"), I = () => D("pause");
  function H(O) {
    Zt[O ? "unshift" : "push"](() => {
      P = O, t(15, P);
    });
  }
  function G(O) {
    m = O, t(1, m);
  }
  function F(O) {
    f = O, t(0, f);
  }
  const K = (O) => D("edit", O.detail);
  function x(O) {
    Zt[O ? "unshift" : "push"](() => {
      k = O, t(14, k);
    });
  }
  function A(O) {
    f = O, t(0, f);
  }
  const S = (O) => {
    P.setRegionLabel(O.detail);
  }, W = (O) => {
    P.getRegions().forEach((w) => {
      w.color === O.detail.color && P.setRegionLabel(O.detail, w);
    });
  }, z = (O) => {
    P.getRegions().forEach((w) => {
      P.getRegionLabel(w.id) === O.detail.name && P.setRegionLabel(O.detail, w);
    });
  };
  return i.$$set = (O) => {
    "label" in O && t(2, s = O.label), "i18n" in O && t(3, a = O.i18n), "value" in O && t(4, l = O.value), "interactive" in O && t(5, u = O.interactive), "show_minimap" in O && t(18, c = O.show_minimap), "waveform_settings" in O && t(6, d = O.waveform_settings), "waveform_options" in O && t(7, h = O.waveform_options), "isDialogOpen" in O && t(0, f = O.isDialogOpen), "mode" in O && t(1, m = O.mode);
  }, i.$$.update = () => {
    i.$$.dirty[0] & /*container, waveform*/
    768 && g && (p && p.destroy(), t(8, g.innerHTML = "", g), b()), i.$$.dirty[0] & /*waveform, durationRef*/
    4608 && (p == null || p.on("decode", (O) => {
      t(13, M = O), C && t(12, C.textContent = pl(O), C);
    })), i.$$.dirty[0] & /*waveform, timeRef*/
    2560 && (p == null || p.on("timeupdate", (O) => v && t(11, v.textContent = pl(O), v))), i.$$.dirty[0] & /*waveform, wsGamepad, show_minimap, wsMinimap*/
    1312256 && (p == null || p.on("ready", () => {
      _ || t(10, _ = p.registerPlugin(Hh.create())), c && !y && t(20, y = p.registerPlugin($s.create({
        waveColor: "#9ca3af",
        progressColor: "#f97316",
        insertPosition: "beforebegin",
        height: 30
      })));
    })), i.$$.dirty[0] & /*value, _a*/
    524304 && t(21, n = t(19, r = l.file_data) === null || r === void 0 ? void 0 : r.url), i.$$.dirty[0] & /*url*/
    2097152 && n && U(n);
  }, [
    f,
    m,
    s,
    a,
    l,
    u,
    d,
    h,
    g,
    p,
    _,
    v,
    C,
    M,
    k,
    P,
    D,
    E,
    c,
    r,
    y,
    n,
    T,
    j,
    V,
    Q,
    q,
    I,
    H,
    G,
    F,
    K,
    x,
    A,
    S,
    W,
    z
  ];
}
class au extends k_ {
  constructor(e) {
    super(), C_(
      this,
      e,
      P_,
      O_,
      S_,
      {
        label: 2,
        i18n: 3,
        value: 4,
        interactive: 5,
        show_minimap: 18,
        waveform_settings: 6,
        waveform_options: 7,
        isDialogOpen: 0,
        mode: 1
      },
      null,
      [-1, -1]
    );
  }
}
const {
  SvelteComponent: W_,
  append: A_,
  attr: uu,
  bubble: ai,
  check_outros: cu,
  create_component: Qn,
  destroy_component: $n,
  detach: Ei,
  element: du,
  empty: T_,
  group_outros: fu,
  init: q_,
  insert: Di,
  mount_component: xn,
  safe_not_equal: j_,
  space: Gs,
  transition_in: xe,
  transition_out: dt
} = window.__gradio__svelte__internal, { createEventDispatcher: N_ } = window.__gradio__svelte__internal;
function z_(i) {
  let e, t;
  return e = new Sa({
    props: {
      size: "small",
      $$slots: { default: [I_] },
      $$scope: { ctx: i }
    }
  }), {
    c() {
      Qn(e.$$.fragment);
    },
    m(n, o) {
      xn(e, n, o), t = !0;
    },
    p(n, o) {
      const r = {};
      o & /*$$scope*/
      32768 && (r.$$scope = { dirty: o, ctx: n }), e.$set(r);
    },
    i(n) {
      t || (xe(e.$$.fragment, n), t = !0);
    },
    o(n) {
      dt(e.$$.fragment, n), t = !1;
    },
    d(n) {
      $n(e, n);
    }
  };
}
function B_(i) {
  let e, t, n, o, r, s = (
    /*show_download_button*/
    i[3] && /*value*/
    i[0].file_data !== null && _l(i)
  ), a = G_;
  return o = new au({
    props: {
      isDialogOpen: !1,
      value: (
        /*value*/
        i[0]
      ),
      interactive: !1,
      label: (
        /*label*/
        i[1]
      ),
      i18n: (
        /*i18n*/
        i[5]
      ),
      show_minimap: (
        /*show_minimap*/
        i[4]
      ),
      waveform_settings: (
        /*waveform_settings*/
        i[6]
      ),
      waveform_options: (
        /*waveform_options*/
        i[7]
      )
    }
  }), o.$on(
    "pause",
    /*pause_handler*/
    i[11]
  ), o.$on(
    "play",
    /*play_handler*/
    i[12]
  ), o.$on(
    "stop",
    /*stop_handler*/
    i[13]
  ), {
    c() {
      e = du("div"), s && s.c(), t = Gs(), n = Gs(), Qn(o.$$.fragment), uu(e, "class", "icon-buttons svelte-1mrvp2o");
    },
    m(l, u) {
      Di(l, e, u), s && s.m(e, null), A_(e, t), Di(l, n, u), xn(o, l, u), r = !0;
    },
    p(l, u) {
      /*show_download_button*/
      l[3] && /*value*/
      l[0].file_data !== null ? s ? (s.p(l, u), u & /*show_download_button, value*/
      9 && xe(s, 1)) : (s = _l(l), s.c(), xe(s, 1), s.m(e, t)) : s && (fu(), dt(s, 1, 1, () => {
        s = null;
      }), cu());
      const c = {};
      u & /*value*/
      1 && (c.value = /*value*/
      l[0]), u & /*label*/
      2 && (c.label = /*label*/
      l[1]), u & /*i18n*/
      32 && (c.i18n = /*i18n*/
      l[5]), u & /*show_minimap*/
      16 && (c.show_minimap = /*show_minimap*/
      l[4]), u & /*waveform_settings*/
      64 && (c.waveform_settings = /*waveform_settings*/
      l[6]), u & /*waveform_options*/
      128 && (c.waveform_options = /*waveform_options*/
      l[7]), o.$set(c);
    },
    i(l) {
      r || (xe(s), xe(a), xe(o.$$.fragment, l), r = !0);
    },
    o(l) {
      dt(s), dt(a), dt(o.$$.fragment, l), r = !1;
    },
    d(l) {
      l && (Ei(e), Ei(n)), s && s.d(), $n(o, l);
    }
  };
}
function I_(i) {
  let e, t;
  return e = new go({}), {
    c() {
      Qn(e.$$.fragment);
    },
    m(n, o) {
      xn(e, n, o), t = !0;
    },
    i(n) {
      t || (xe(e.$$.fragment, n), t = !0);
    },
    o(n) {
      dt(e.$$.fragment, n), t = !1;
    },
    d(n) {
      $n(e, n);
    }
  };
}
function _l(i) {
  let e, t, n;
  return t = new iu({
    props: {
      href: (
        /*value*/
        i[0].file_data.url
      ),
      download: (
        /*value*/
        i[0].file_data.orig_name || /*value*/
        i[0].file_data.path
      ),
      $$slots: { default: [U_] },
      $$scope: { ctx: i }
    }
  }), {
    c() {
      e = du("div"), Qn(t.$$.fragment), uu(e, "class", "download-button");
    },
    m(o, r) {
      Di(o, e, r), xn(t, e, null), n = !0;
    },
    p(o, r) {
      const s = {};
      r & /*value*/
      1 && (s.href = /*value*/
      o[0].file_data.url), r & /*value*/
      1 && (s.download = /*value*/
      o[0].file_data.orig_name || /*value*/
      o[0].file_data.path), r & /*$$scope, i18n*/
      32800 && (s.$$scope = { dirty: r, ctx: o }), t.$set(s);
    },
    i(o) {
      n || (xe(t.$$.fragment, o), n = !0);
    },
    o(o) {
      dt(t.$$.fragment, o), n = !1;
    },
    d(o) {
      o && Ei(e), $n(t);
    }
  };
}
function U_(i) {
  let e, t;
  return e = new Ri({
    props: {
      Icon: Ea,
      label: (
        /*i18n*/
        i[5]("common.download")
      )
    }
  }), {
    c() {
      Qn(e.$$.fragment);
    },
    m(n, o) {
      xn(e, n, o), t = !0;
    },
    p(n, o) {
      const r = {};
      o & /*i18n*/
      32 && (r.label = /*i18n*/
      n[5]("common.download")), e.$set(r);
    },
    i(n) {
      t || (xe(e.$$.fragment, n), t = !0);
    },
    o(n) {
      dt(e.$$.fragment, n), t = !1;
    },
    d(n) {
      $n(e, n);
    }
  };
}
function F_(i) {
  let e, t, n, o, r, s;
  e = new ya({
    props: {
      show_label: (
        /*show_label*/
        i[2]
      ),
      Icon: go,
      float: !1,
      label: (
        /*label*/
        i[1] || /*i18n*/
        i[5]("audio.audio")
      )
    }
  });
  const a = [B_, z_], l = [];
  function u(c, d) {
    return (
      /*value*/
      c[0] !== null ? 0 : 1
    );
  }
  return n = u(i), o = l[n] = a[n](i), {
    c() {
      Qn(e.$$.fragment), t = Gs(), o.c(), r = T_();
    },
    m(c, d) {
      xn(e, c, d), Di(c, t, d), l[n].m(c, d), Di(c, r, d), s = !0;
    },
    p(c, [d]) {
      const h = {};
      d & /*show_label*/
      4 && (h.show_label = /*show_label*/
      c[2]), d & /*label, i18n*/
      34 && (h.label = /*label*/
      c[1] || /*i18n*/
      c[5]("audio.audio")), e.$set(h);
      let f = n;
      n = u(c), n === f ? l[n].p(c, d) : (fu(), dt(l[f], 1, 1, () => {
        l[f] = null;
      }), cu(), o = l[n], o ? o.p(c, d) : (o = l[n] = a[n](c), o.c()), xe(o, 1), o.m(r.parentNode, r));
    },
    i(c) {
      s || (xe(e.$$.fragment, c), xe(o), s = !0);
    },
    o(c) {
      dt(e.$$.fragment, c), dt(o), s = !1;
    },
    d(c) {
      c && (Ei(t), Ei(r)), $n(e, c), l[n].d(c);
    }
  };
}
let G_ = !1;
function V_(i, e, t) {
  let { value: n = null } = e, { label: o } = e, { show_label: r = !0 } = e, { show_download_button: s = !0 } = e, { show_minimap: a = !0 } = e, { i18n: l } = e, { waveform_settings: u } = e, { waveform_options: c } = e;
  const d = N_(), h = async (y) => y ? `<audio controls src="${await xu(y.url)}"></audio>` : "";
  function f(y) {
    ai.call(this, i, y);
  }
  function m(y) {
    ai.call(this, i, y);
  }
  function g(y) {
    ai.call(this, i, y);
  }
  function p(y) {
    ai.call(this, i, y);
  }
  function _(y) {
    ai.call(this, i, y);
  }
  return i.$$set = (y) => {
    "value" in y && t(0, n = y.value), "label" in y && t(1, o = y.label), "show_label" in y && t(2, r = y.show_label), "show_download_button" in y && t(3, s = y.show_download_button), "show_minimap" in y && t(4, a = y.show_minimap), "i18n" in y && t(5, l = y.i18n), "waveform_settings" in y && t(6, u = y.waveform_settings), "waveform_options" in y && t(7, c = y.waveform_options);
  }, i.$$.update = () => {
    i.$$.dirty & /*value*/
    1 && n && d("change", n);
  }, [
    n,
    o,
    r,
    s,
    a,
    l,
    u,
    c,
    h,
    f,
    m,
    g,
    p,
    _
  ];
}
class H_ extends W_ {
  constructor(e) {
    super(), q_(this, e, V_, F_, j_, {
      value: 0,
      label: 1,
      show_label: 2,
      show_download_button: 3,
      show_minimap: 4,
      i18n: 5,
      waveform_settings: 6,
      waveform_options: 7
    });
  }
}
var as = new Intl.Collator(0, { numeric: 1 }).compare;
function gl(i, e, t) {
  return i = i.split("."), e = e.split("."), as(i[0], e[0]) || as(i[1], e[1]) || (e[2] = e.slice(2).join("."), t = /[.-]/.test(i[2] = i.slice(2).join(".")), t == /[.-]/.test(e[2]) ? as(i[2], e[2]) : t ? -1 : 1);
}
function hu(i, e, t) {
  return e.startsWith("http://") || e.startsWith("https://") ? t ? i : e : i + e;
}
function us(i) {
  if (i.startsWith("http")) {
    const { protocol: e, host: t } = new URL(i);
    return t.endsWith("hf.space") ? {
      ws_protocol: "wss",
      host: t,
      http_protocol: e
    } : {
      ws_protocol: e === "https:" ? "wss" : "ws",
      http_protocol: e,
      host: t
    };
  } else if (i.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: i
  };
}
const mu = /^[^\/]*\/[^\/]*$/, Z_ = /.*hf\.space\/{0,1}$/;
async function X_(i, e) {
  const t = {};
  e && (t.Authorization = `Bearer ${e}`);
  const n = i.trim();
  if (mu.test(n))
    try {
      const o = await fetch(
        `https://huggingface.co/api/spaces/${n}/host`,
        { headers: t }
      );
      if (o.status !== 200)
        throw new Error("Space metadata could not be loaded.");
      const r = (await o.json()).host;
      return {
        space_id: i,
        ...us(r)
      };
    } catch (o) {
      throw new Error("Space metadata could not be loaded." + o.message);
    }
  if (Z_.test(n)) {
    const { ws_protocol: o, http_protocol: r, host: s } = us(n);
    return {
      space_id: s.replace(".hf.space", ""),
      ws_protocol: o,
      http_protocol: r,
      host: s
    };
  }
  return {
    space_id: !1,
    ...us(n)
  };
}
function J_(i) {
  let e = {};
  return i.forEach(({ api_name: t }, n) => {
    t && (e[t] = n);
  }), e;
}
const K_ = /^(?=[^]*\b[dD]iscussions{0,1}\b)(?=[^]*\b[dD]isabled\b)[^]*$/;
async function vl(i) {
  try {
    const t = (await fetch(
      `https://huggingface.co/api/spaces/${i}/discussions`,
      {
        method: "HEAD"
      }
    )).headers.get("x-error-message");
    return !(t && K_.test(t));
  } catch {
    return !1;
  }
}
function Y_(i, e, t, n) {
  if (e.length === 0) {
    if (t === "replace")
      return n;
    if (t === "append")
      return i + n;
    throw new Error(`Unsupported action: ${t}`);
  }
  let o = i;
  for (let s = 0; s < e.length - 1; s++)
    o = o[e[s]];
  const r = e[e.length - 1];
  switch (t) {
    case "replace":
      o[r] = n;
      break;
    case "append":
      o[r] += n;
      break;
    case "add":
      Array.isArray(o) ? o.splice(Number(r), 0, n) : o[r] = n;
      break;
    case "delete":
      Array.isArray(o) ? o.splice(Number(r), 1) : delete o[r];
      break;
    default:
      throw new Error(`Unknown action: ${t}`);
  }
  return i;
}
function Q_(i, e) {
  return e.forEach(([t, n, o]) => {
    i = Y_(i, n, t, o);
  }), i;
}
async function pu(i, e, t, n = x_) {
  let o = (Array.isArray(i) ? i : [i]).map(
    (r) => r.blob
  );
  return await Promise.all(
    await n(e, o, void 0, t).then(
      async (r) => {
        if (r.error)
          throw new Error(r.error);
        return r.files ? r.files.map((s, a) => new So({
          ...i[a],
          path: s,
          url: e + "/file=" + s
        })) : [];
      }
    )
  );
}
async function _u(i, e) {
  return i.map(
    (t, n) => new So({
      path: t.name,
      orig_name: t.name,
      blob: t,
      size: t.size,
      mime_type: t.type,
      is_stream: e
    })
  );
}
class So {
  constructor({
    path: e,
    url: t,
    orig_name: n,
    size: o,
    blob: r,
    is_stream: s,
    mime_type: a,
    alt_text: l
  }) {
    this.meta = { _type: "gradio.FileData" }, this.path = e, this.url = t, this.orig_name = n, this.size = o, this.blob = t ? void 0 : r, this.is_stream = s, this.mime_type = a, this.alt_text = l;
  }
}
const gu = "This application is too busy. Keep trying!", xt = "Connection errored out.";
let vu;
function $_(i, e) {
  return { post_data: t, upload_files: n, client: o, handle_blob: r };
  async function t(s, a, l) {
    const u = { "Content-Type": "application/json" };
    l && (u.Authorization = `Bearer ${l}`);
    try {
      var c = await i(s, {
        method: "POST",
        body: JSON.stringify(a),
        headers: u
      });
    } catch {
      return [{ error: xt }, 500];
    }
    let d, h;
    try {
      d = await c.json(), h = c.status;
    } catch (f) {
      d = { error: `Could not parse server response: ${f}` }, h = 500;
    }
    return [d, h];
  }
  async function n(s, a, l, u) {
    const c = {};
    l && (c.Authorization = `Bearer ${l}`);
    const d = 1e3, h = [];
    for (let m = 0; m < a.length; m += d) {
      const g = a.slice(m, m + d), p = new FormData();
      g.forEach((y) => {
        p.append("files", y);
      });
      try {
        const y = u ? `${s}/upload?upload_id=${u}` : `${s}/upload`;
        var f = await i(y, {
          method: "POST",
          body: p,
          headers: c
        });
      } catch {
        return { error: xt };
      }
      const _ = await f.json();
      h.push(..._);
    }
    return { files: h };
  }
  async function o(s, a = {}) {
    return new Promise(async (l) => {
      const { status_callback: u, hf_token: c } = a, d = {
        predict: V,
        submit: Q,
        view_api: G,
        component_server: H
      };
      if ((typeof window > "u" || !("WebSocket" in window)) && !global.Websocket) {
        const F = await import("./wrapper-6f348d45-B5bCGhfq.js");
        vu = (await import("./__vite-browser-external-DYxpcVy9.js")).Blob, global.WebSocket = F.WebSocket;
      }
      const { ws_protocol: h, http_protocol: f, host: m, space_id: g } = await X_(s, c), p = Math.random().toString(36).substring(2), _ = {};
      let y = !1, v = {}, C = {}, M = null;
      const k = {}, P = /* @__PURE__ */ new Set();
      let D, b = {}, E = !1;
      c && g && (E = await t0(g, c));
      async function U(F) {
        if (D = F, window.location.protocol === "https:" && (D.root = D.root.replace("http://", "https://")), b = J_((F == null ? void 0 : F.dependencies) || []), D.auth_required)
          return {
            config: D,
            ...d
          };
        try {
          T = await G(D);
        } catch (K) {
          console.error(`Could not get api details: ${K.message}`);
        }
        return {
          config: D,
          ...d
        };
      }
      let T;
      async function j(F) {
        if (u && u(F), F.status === "running")
          try {
            D = await kl(
              i,
              `${f}//${m}`,
              c
            );
            const K = await U(D);
            l(K);
          } catch (K) {
            console.error(K), u && u({
              status: "error",
              message: "Could not load this space.",
              load_status: "error",
              detail: "NOT_FOUND"
            });
          }
      }
      try {
        D = await kl(
          i,
          `${f}//${m}`,
          c
        );
        const F = await U(D);
        l(F);
      } catch (F) {
        console.error(F), g ? Hs(
          g,
          mu.test(g) ? "space_name" : "subdomain",
          j
        ) : u && u({
          status: "error",
          message: "Could not load this space.",
          load_status: "error",
          detail: "NOT_FOUND"
        });
      }
      function V(F, K, x) {
        let A = !1, S = !1, W;
        if (typeof F == "number")
          W = D.dependencies[F];
        else {
          const z = F.replace(/^\//, "");
          W = D.dependencies[b[z]];
        }
        if (W.types.continuous)
          throw new Error(
            "Cannot call predict on this function as it may run forever. Use submit instead"
          );
        return new Promise((z, O) => {
          const w = Q(F, K, x);
          let L;
          w.on("data", (B) => {
            S && (w.destroy(), z(B)), A = !0, L = B;
          }).on("status", (B) => {
            B.stage === "error" && O(B), B.stage === "complete" && (S = !0, A && (w.destroy(), z(L)));
          });
        });
      }
      function Q(F, K, x, A = null) {
        let S, W;
        if (typeof F == "number")
          S = F, W = T.unnamed_endpoints[S];
        else {
          const Y = F.replace(/^\//, "");
          S = b[Y], W = T.named_endpoints[F.trim()];
        }
        if (typeof S != "number")
          throw new Error(
            "There is no endpoint matching that name of fn_index matching that number."
          );
        let z, O, w = D.protocol ?? "ws";
        const L = typeof F == "number" ? "/predict" : F;
        let B, R = null, Z = !1;
        const ne = {};
        let ae = "";
        typeof window < "u" && (ae = new URLSearchParams(window.location.search).toString()), r(`${D.root}`, K, W, c).then(
          (Y) => {
            if (B = {
              data: Y || [],
              event_data: x,
              fn_index: S,
              trigger_id: A
            }, n0(S, D))
              $({
                type: "status",
                endpoint: L,
                stage: "pending",
                queue: !1,
                fn_index: S,
                time: /* @__PURE__ */ new Date()
              }), t(
                `${D.root}/run${L.startsWith("/") ? L : `/${L}`}${ae ? "?" + ae : ""}`,
                {
                  ...B,
                  session_hash: p
                },
                c
              ).then(([le, ee]) => {
                const ce = le.data;
                ee == 200 ? ($({
                  type: "data",
                  endpoint: L,
                  fn_index: S,
                  data: ce,
                  time: /* @__PURE__ */ new Date()
                }), $({
                  type: "status",
                  endpoint: L,
                  fn_index: S,
                  stage: "complete",
                  eta: le.average_duration,
                  queue: !1,
                  time: /* @__PURE__ */ new Date()
                })) : $({
                  type: "status",
                  stage: "error",
                  endpoint: L,
                  fn_index: S,
                  message: le.error,
                  queue: !1,
                  time: /* @__PURE__ */ new Date()
                });
              }).catch((le) => {
                $({
                  type: "status",
                  stage: "error",
                  message: le.message,
                  endpoint: L,
                  fn_index: S,
                  queue: !1,
                  time: /* @__PURE__ */ new Date()
                });
              });
            else if (w == "ws") {
              $({
                type: "status",
                stage: "pending",
                queue: !0,
                endpoint: L,
                fn_index: S,
                time: /* @__PURE__ */ new Date()
              });
              let le = new URL(`${h}://${hu(
                m,
                D.path,
                !0
              )}
							/queue/join${ae ? "?" + ae : ""}`);
              E && le.searchParams.set("__sign", E), z = new WebSocket(le), z.onclose = (ee) => {
                ee.wasClean || $({
                  type: "status",
                  stage: "error",
                  broken: !0,
                  message: xt,
                  queue: !0,
                  endpoint: L,
                  fn_index: S,
                  time: /* @__PURE__ */ new Date()
                });
              }, z.onmessage = function(ee) {
                const ce = JSON.parse(ee.data), { type: de, status: ie, data: oe } = cs(
                  ce,
                  _[S]
                );
                if (de === "update" && ie && !Z)
                  $({
                    type: "status",
                    endpoint: L,
                    fn_index: S,
                    time: /* @__PURE__ */ new Date(),
                    ...ie
                  }), ie.stage === "error" && z.close();
                else if (de === "hash") {
                  z.send(JSON.stringify({ fn_index: S, session_hash: p }));
                  return;
                } else de === "data" ? z.send(JSON.stringify({ ...B, session_hash: p })) : de === "complete" ? Z = ie : de === "log" ? $({
                  type: "log",
                  log: oe.log,
                  level: oe.level,
                  endpoint: L,
                  fn_index: S
                }) : de === "generating" && $({
                  type: "status",
                  time: /* @__PURE__ */ new Date(),
                  ...ie,
                  stage: ie == null ? void 0 : ie.stage,
                  queue: !0,
                  endpoint: L,
                  fn_index: S
                });
                oe && ($({
                  type: "data",
                  time: /* @__PURE__ */ new Date(),
                  data: oe.data,
                  endpoint: L,
                  fn_index: S
                }), Z && ($({
                  type: "status",
                  time: /* @__PURE__ */ new Date(),
                  ...Z,
                  stage: ie == null ? void 0 : ie.stage,
                  queue: !0,
                  endpoint: L,
                  fn_index: S
                }), z.close()));
              }, gl(D.version || "2.0.0", "3.6") < 0 && addEventListener(
                "open",
                () => z.send(JSON.stringify({ hash: p }))
              );
            } else if (w == "sse") {
              $({
                type: "status",
                stage: "pending",
                queue: !0,
                endpoint: L,
                fn_index: S,
                time: /* @__PURE__ */ new Date()
              });
              var re = new URLSearchParams({
                fn_index: S.toString(),
                session_hash: p
              }).toString();
              let le = new URL(
                `${D.root}/queue/join?${ae ? ae + "&" : ""}${re}`
              );
              O = e(le), O.onmessage = async function(ee) {
                const ce = JSON.parse(ee.data), { type: de, status: ie, data: oe } = cs(
                  ce,
                  _[S]
                );
                if (de === "update" && ie && !Z)
                  $({
                    type: "status",
                    endpoint: L,
                    fn_index: S,
                    time: /* @__PURE__ */ new Date(),
                    ...ie
                  }), ie.stage === "error" && O.close();
                else if (de === "data") {
                  R = ce.event_id;
                  let [We, ti] = await t(
                    `${D.root}/queue/data`,
                    {
                      ...B,
                      session_hash: p,
                      event_id: R
                    },
                    c
                  );
                  ti !== 200 && ($({
                    type: "status",
                    stage: "error",
                    message: xt,
                    queue: !0,
                    endpoint: L,
                    fn_index: S,
                    time: /* @__PURE__ */ new Date()
                  }), O.close());
                } else de === "complete" ? Z = ie : de === "log" ? $({
                  type: "log",
                  log: oe.log,
                  level: oe.level,
                  endpoint: L,
                  fn_index: S
                }) : de === "generating" && $({
                  type: "status",
                  time: /* @__PURE__ */ new Date(),
                  ...ie,
                  stage: ie == null ? void 0 : ie.stage,
                  queue: !0,
                  endpoint: L,
                  fn_index: S
                });
                oe && ($({
                  type: "data",
                  time: /* @__PURE__ */ new Date(),
                  data: oe.data,
                  endpoint: L,
                  fn_index: S
                }), Z && ($({
                  type: "status",
                  time: /* @__PURE__ */ new Date(),
                  ...Z,
                  stage: ie == null ? void 0 : ie.stage,
                  queue: !0,
                  endpoint: L,
                  fn_index: S
                }), O.close()));
              };
            } else (w == "sse_v1" || w == "sse_v2" || w == "sse_v2.1" || w == "sse_v3") && ($({
              type: "status",
              stage: "pending",
              queue: !0,
              endpoint: L,
              fn_index: S,
              time: /* @__PURE__ */ new Date()
            }), t(
              `${D.root}/queue/join?${ae}`,
              {
                ...B,
                session_hash: p
              },
              c
            ).then(([le, ee]) => {
              if (ee === 503)
                $({
                  type: "status",
                  stage: "error",
                  message: gu,
                  queue: !0,
                  endpoint: L,
                  fn_index: S,
                  time: /* @__PURE__ */ new Date()
                });
              else if (ee !== 200)
                $({
                  type: "status",
                  stage: "error",
                  message: xt,
                  queue: !0,
                  endpoint: L,
                  fn_index: S,
                  time: /* @__PURE__ */ new Date()
                });
              else {
                R = le.event_id;
                let ce = async function(de) {
                  try {
                    const { type: ie, status: oe, data: We } = cs(
                      de,
                      _[S]
                    );
                    if (ie == "heartbeat")
                      return;
                    if (ie === "update" && oe && !Z)
                      $({
                        type: "status",
                        endpoint: L,
                        fn_index: S,
                        time: /* @__PURE__ */ new Date(),
                        ...oe
                      });
                    else if (ie === "complete")
                      Z = oe;
                    else if (ie == "unexpected_error")
                      console.error("Unexpected error", oe == null ? void 0 : oe.message), $({
                        type: "status",
                        stage: "error",
                        message: (oe == null ? void 0 : oe.message) || "An Unexpected Error Occurred!",
                        queue: !0,
                        endpoint: L,
                        fn_index: S,
                        time: /* @__PURE__ */ new Date()
                      });
                    else if (ie === "log") {
                      $({
                        type: "log",
                        log: We.log,
                        level: We.level,
                        endpoint: L,
                        fn_index: S
                      });
                      return;
                    } else ie === "generating" && ($({
                      type: "status",
                      time: /* @__PURE__ */ new Date(),
                      ...oe,
                      stage: oe == null ? void 0 : oe.stage,
                      queue: !0,
                      endpoint: L,
                      fn_index: S
                    }), We && ["sse_v2", "sse_v2.1", "sse_v3"].includes(w) && Ct(R, We));
                    We && ($({
                      type: "data",
                      time: /* @__PURE__ */ new Date(),
                      data: We.data,
                      endpoint: L,
                      fn_index: S
                    }), Z && $({
                      type: "status",
                      time: /* @__PURE__ */ new Date(),
                      ...Z,
                      stage: oe == null ? void 0 : oe.stage,
                      queue: !0,
                      endpoint: L,
                      fn_index: S
                    })), ((oe == null ? void 0 : oe.stage) === "complete" || (oe == null ? void 0 : oe.stage) === "error") && (k[R] && delete k[R], R in C && delete C[R]);
                  } catch (ie) {
                    console.error("Unexpected client exception", ie), $({
                      type: "status",
                      stage: "error",
                      message: "An Unexpected Error Occurred!",
                      queue: !0,
                      endpoint: L,
                      fn_index: S,
                      time: /* @__PURE__ */ new Date()
                    }), ["sse_v2", "sse_v2.1"].includes(w) && I();
                  }
                };
                R in v && (v[R].forEach(
                  (de) => ce(de)
                ), delete v[R]), k[R] = ce, P.add(R), y || q();
              }
            }));
          }
        );
        function Ct(Y, re) {
          !C[Y] ? (C[Y] = [], re.data.forEach((ee, ce) => {
            C[Y][ce] = ee;
          })) : re.data.forEach((ee, ce) => {
            let de = Q_(
              C[Y][ce],
              ee
            );
            C[Y][ce] = de, re.data[ce] = de;
          });
        }
        function $(Y) {
          const le = ne[Y.type] || [];
          le == null || le.forEach((ee) => ee(Y));
        }
        function Ne(Y, re) {
          const le = ne, ee = le[Y] || [];
          return le[Y] = ee, ee == null || ee.push(re), { on: Ne, off: ft, cancel: N, destroy: he };
        }
        function ft(Y, re) {
          const le = ne;
          let ee = le[Y] || [];
          return ee = ee == null ? void 0 : ee.filter((ce) => ce !== re), le[Y] = ee, { on: Ne, off: ft, cancel: N, destroy: he };
        }
        async function N() {
          const Y = {
            stage: "complete",
            queue: !1,
            time: /* @__PURE__ */ new Date()
          };
          Z = Y, $({
            ...Y,
            type: "status",
            endpoint: L,
            fn_index: S
          });
          let re = {};
          w === "ws" ? (z && z.readyState === 0 ? z.addEventListener("open", () => {
            z.close();
          }) : z.close(), re = { fn_index: S, session_hash: p }) : (O.close(), re = { event_id: R });
          try {
            await i(`${D.root}/reset`, {
              headers: { "Content-Type": "application/json" },
              method: "POST",
              body: JSON.stringify(re)
            });
          } catch {
            console.warn(
              "The `/reset` endpoint could not be called. Subsequent endpoint results may be unreliable."
            );
          }
        }
        function he() {
          for (const Y in ne)
            ne[Y].forEach((re) => {
              ft(Y, re);
            });
        }
        return {
          on: Ne,
          off: ft,
          cancel: N,
          destroy: he
        };
      }
      function q() {
        y = !0;
        let F = new URLSearchParams({
          session_hash: p
        }).toString(), K = new URL(`${D.root}/queue/data?${F}`);
        M = e(K), M.onmessage = async function(x) {
          let A = JSON.parse(x.data);
          const S = A.event_id;
          if (!S)
            await Promise.all(
              Object.keys(k).map(
                (W) => k[W](A)
              )
            );
          else if (k[S]) {
            A.msg === "process_completed" && ["sse", "sse_v1", "sse_v2", "sse_v2.1"].includes(D.protocol) && (P.delete(S), P.size === 0 && I());
            let W = k[S];
            window.setTimeout(W, 0, A);
          } else
            v[S] || (v[S] = []), v[S].push(A);
          A.msg === "close_stream" && I();
        }, M.onerror = async function(x) {
          await Promise.all(
            Object.keys(k).map(
              (A) => k[A]({
                msg: "unexpected_error",
                message: xt
              })
            )
          ), I();
        };
      }
      function I() {
        y = !1, M == null || M.close();
      }
      async function H(F, K, x) {
        var A;
        const S = { "Content-Type": "application/json" };
        c && (S.Authorization = `Bearer ${c}`);
        let W, z = D.components.find(
          (L) => L.id === F
        );
        (A = z == null ? void 0 : z.props) != null && A.root_url ? W = z.props.root_url : W = D.root;
        const O = await i(
          `${W}/component_server/`,
          {
            method: "POST",
            body: JSON.stringify({
              data: x,
              component_id: F,
              fn_name: K,
              session_hash: p
            }),
            headers: S
          }
        );
        if (!O.ok)
          throw new Error(
            "Could not connect to component server: " + O.statusText
          );
        return await O.json();
      }
      async function G(F) {
        if (T)
          return T;
        const K = { "Content-Type": "application/json" };
        c && (K.Authorization = `Bearer ${c}`);
        let x;
        if (gl(F.version || "2.0.0", "3.30") < 0 ? x = await i(
          "https://gradio-space-api-fetcher-v2.hf.space/api",
          {
            method: "POST",
            body: JSON.stringify({
              serialize: !1,
              config: JSON.stringify(F)
            }),
            headers: K
          }
        ) : x = await i(`${F.root}/info`, {
          headers: K
        }), !x.ok)
          throw new Error(xt);
        let A = await x.json();
        return "api" in A && (A = A.api), A.named_endpoints["/predict"] && !A.unnamed_endpoints[0] && (A.unnamed_endpoints[0] = A.named_endpoints["/predict"]), e0(A, F, b);
      }
    });
  }
  async function r(s, a, l, u) {
    const c = await Vs(
      a,
      void 0,
      [],
      !0,
      l
    );
    return Promise.all(
      c.map(async ({ path: d, blob: h, type: f }) => {
        if (h) {
          const m = (await n(s, [h], u)).files[0];
          return { path: d, file_url: m, type: f, name: h == null ? void 0 : h.name };
        }
        return { path: d, type: f };
      })
    ).then((d) => (d.forEach(({ path: h, file_url: f, type: m, name: g }) => {
      if (m === "Gallery")
        yl(a, f, h);
      else if (f) {
        const p = new So({ path: f, orig_name: g });
        yl(a, p, h);
      }
    }), a));
  }
}
const { post_data: Yv, upload_files: x_, client: Qv, handle_blob: $v } = $_(
  fetch,
  (...i) => new EventSource(...i)
);
function bl(i, e, t, n) {
  switch (i.type) {
    case "string":
      return "string";
    case "boolean":
      return "boolean";
    case "number":
      return "number";
  }
  if (t === "JSONSerializable" || t === "StringSerializable")
    return "any";
  if (t === "ListStringSerializable")
    return "string[]";
  if (e === "Image")
    return n === "parameter" ? "Blob | File | Buffer" : "string";
  if (t === "FileSerializable")
    return (i == null ? void 0 : i.type) === "array" ? n === "parameter" ? "(Blob | File | Buffer)[]" : "{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}[]" : n === "parameter" ? "Blob | File | Buffer" : "{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}";
  if (t === "GallerySerializable")
    return n === "parameter" ? "[(Blob | File | Buffer), (string | null)][]" : "[{ name: string; data: string; size?: number; is_file?: boolean; orig_name?: string}, (string | null))][]";
}
function wl(i, e) {
  return e === "GallerySerializable" ? "array of [file, label] tuples" : e === "ListStringSerializable" ? "array of strings" : e === "FileSerializable" ? "array of files or single file" : i.description;
}
function e0(i, e, t) {
  const n = {
    named_endpoints: {},
    unnamed_endpoints: {}
  };
  for (const o in i) {
    const r = i[o];
    for (const s in r) {
      const a = e.dependencies[s] ? s : t[s.replace("/", "")], l = r[s];
      n[o][s] = {}, n[o][s].parameters = {}, n[o][s].returns = {}, n[o][s].type = e.dependencies[a].types, n[o][s].parameters = l.parameters.map(
        ({ label: u, component: c, type: d, serializer: h }) => ({
          label: u,
          component: c,
          type: bl(d, c, h, "parameter"),
          description: wl(d, h)
        })
      ), n[o][s].returns = l.returns.map(
        ({ label: u, component: c, type: d, serializer: h }) => ({
          label: u,
          component: c,
          type: bl(d, c, h, "return"),
          description: wl(d, h)
        })
      );
    }
  }
  return n;
}
async function t0(i, e) {
  try {
    return (await (await fetch(`https://huggingface.co/api/spaces/${i}/jwt`, {
      headers: {
        Authorization: `Bearer ${e}`
      }
    })).json()).token || !1;
  } catch (t) {
    return console.error(t), !1;
  }
}
function yl(i, e, t) {
  for (; t.length > 1; )
    i = i[t.shift()];
  i[t.shift()] = e;
}
async function Vs(i, e = void 0, t = [], n = !1, o = void 0) {
  if (Array.isArray(i)) {
    let r = [];
    return await Promise.all(
      i.map(async (s, a) => {
        var l;
        let u = t.slice();
        u.push(a);
        const c = await Vs(
          i[a],
          n ? ((l = o == null ? void 0 : o.parameters[a]) == null ? void 0 : l.component) || void 0 : e,
          u,
          !1,
          o
        );
        r = r.concat(c);
      })
    ), r;
  } else {
    if (globalThis.Buffer && i instanceof globalThis.Buffer)
      return [
        {
          path: t,
          blob: e === "Image" ? !1 : new vu([i]),
          type: e
        }
      ];
    if (typeof i == "object") {
      let r = [];
      for (let s in i)
        if (i.hasOwnProperty(s)) {
          let a = t.slice();
          a.push(s), r = r.concat(
            await Vs(
              i[s],
              void 0,
              a,
              !1,
              o
            )
          );
        }
      return r;
    }
  }
  return [];
}
function n0(i, e) {
  var t, n, o, r;
  return !(((n = (t = e == null ? void 0 : e.dependencies) == null ? void 0 : t[i]) == null ? void 0 : n.queue) === null ? e.enable_queue : (r = (o = e == null ? void 0 : e.dependencies) == null ? void 0 : o[i]) != null && r.queue) || !1;
}
async function kl(i, e, t) {
  const n = {};
  if (t && (n.Authorization = `Bearer ${t}`), typeof window < "u" && window.gradio_config && location.origin !== "http://localhost:9876" && !window.gradio_config.dev_mode) {
    const o = window.gradio_config.root, r = window.gradio_config;
    return r.root = hu(e, r.root, !1), { ...r, path: o };
  } else if (e) {
    let o = await i(`${e}/config`, {
      headers: n
    });
    if (o.status === 200) {
      const r = await o.json();
      return r.path = r.path ?? "", r.root = e, r;
    }
    throw new Error("Could not get config.");
  }
  throw new Error("No config or app endpoint found");
}
async function Hs(i, e, t) {
  let n = e === "subdomain" ? `https://huggingface.co/api/spaces/by-subdomain/${i}` : `https://huggingface.co/api/spaces/${i}`, o, r;
  try {
    if (o = await fetch(n), r = o.status, r !== 200)
      throw new Error();
    o = await o.json();
  } catch {
    t({
      status: "error",
      load_status: "error",
      message: "Could not get space status",
      detail: "NOT_FOUND"
    });
    return;
  }
  if (!o || r !== 200)
    return;
  const {
    runtime: { stage: s },
    id: a
  } = o;
  switch (s) {
    case "STOPPED":
    case "SLEEPING":
      t({
        status: "sleeping",
        load_status: "pending",
        message: "Space is asleep. Waking it up...",
        detail: s
      }), setTimeout(() => {
        Hs(i, e, t);
      }, 1e3);
      break;
    case "PAUSED":
      t({
        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 vl(a)
      });
      break;
    case "RUNNING":
    case "RUNNING_BUILDING":
      t({
        status: "running",
        load_status: "complete",
        message: "",
        detail: s
      });
      break;
    case "BUILDING":
      t({
        status: "building",
        load_status: "pending",
        message: "Space is building...",
        detail: s
      }), setTimeout(() => {
        Hs(i, e, t);
      }, 1e3);
      break;
    default:
      t({
        status: "space_error",
        load_status: "error",
        message: "This space is experiencing an issue.",
        detail: s,
        discussions_enabled: await vl(a)
      });
      break;
  }
}
function cs(i, e) {
  switch (i.msg) {
    case "send_data":
      return { type: "data" };
    case "send_hash":
      return { type: "hash" };
    case "queue_full":
      return {
        type: "update",
        status: {
          queue: !0,
          message: gu,
          stage: "error",
          code: i.code,
          success: i.success
        }
      };
    case "heartbeat":
      return {
        type: "heartbeat"
      };
    case "unexpected_error":
      return {
        type: "unexpected_error",
        status: {
          queue: !0,
          message: i.message,
          stage: "error",
          success: !1
        }
      };
    case "estimation":
      return {
        type: "update",
        status: {
          queue: !0,
          stage: e || "pending",
          code: i.code,
          size: i.queue_size,
          position: i.rank,
          eta: i.rank_eta,
          success: i.success
        }
      };
    case "progress":
      return {
        type: "update",
        status: {
          queue: !0,
          stage: "pending",
          code: i.code,
          progress_data: i.progress_data,
          success: i.success
        }
      };
    case "log":
      return { type: "log", data: i };
    case "process_generating":
      return {
        type: "generating",
        status: {
          queue: !0,
          message: i.success ? null : i.output.error,
          stage: i.success ? "generating" : "error",
          code: i.code,
          progress_data: i.progress_data,
          eta: i.average_duration
        },
        data: i.success ? i.output : null
      };
    case "process_completed":
      return "error" in i.output ? {
        type: "update",
        status: {
          queue: !0,
          message: i.output.error,
          stage: "error",
          code: i.code,
          success: i.success
        }
      } : {
        type: "complete",
        status: {
          queue: !0,
          message: i.success ? void 0 : i.output.error,
          stage: i.success ? "complete" : "error",
          code: i.code,
          progress_data: i.progress_data
        },
        data: i.success ? i.output : null
      };
    case "process_starts":
      return {
        type: "update",
        status: {
          queue: !0,
          stage: "pending",
          code: i.code,
          size: i.rank,
          position: 0,
          success: i.success,
          eta: i.eta
        }
      };
  }
  return { type: "none", status: { stage: "error", queue: !0 } };
}
const {
  SvelteComponent: i0,
  append: je,
  attr: on,
  detach: bu,
  element: sn,
  init: o0,
  insert: wu,
  noop: Cl,
  safe_not_equal: s0,
  set_data: po,
  set_style: ds,
  space: Zs,
  text: An,
  toggle_class: Sl
} = window.__gradio__svelte__internal, { onMount: r0, createEventDispatcher: l0, getContext: a0 } = window.__gradio__svelte__internal;
function El(i) {
  let e, t, n, o, r = gi(
    /*file_to_display*/
    i[2]
  ) + "", s, a, l, u, c = (
    /*file_to_display*/
    i[2].orig_name + ""
  ), d;
  return {
    c() {
      e = sn("div"), t = sn("span"), n = sn("div"), o = sn("progress"), s = An(r), l = Zs(), u = sn("span"), d = An(c), ds(o, "visibility", "hidden"), ds(o, "height", "0"), ds(o, "width", "0"), o.value = a = gi(
        /*file_to_display*/
        i[2]
      ), on(o, "max", "100"), on(o, "class", "svelte-cr2edf"), on(n, "class", "progress-bar svelte-cr2edf"), on(u, "class", "file-name svelte-cr2edf"), on(e, "class", "file svelte-cr2edf");
    },
    m(h, f) {
      wu(h, e, f), je(e, t), je(t, n), je(n, o), je(o, s), je(e, l), je(e, u), je(u, d);
    },
    p(h, f) {
      f & /*file_to_display*/
      4 && r !== (r = gi(
        /*file_to_display*/
        h[2]
      ) + "") && po(s, r), f & /*file_to_display*/
      4 && a !== (a = gi(
        /*file_to_display*/
        h[2]
      )) && (o.value = a), f & /*file_to_display*/
      4 && c !== (c = /*file_to_display*/
      h[2].orig_name + "") && po(d, c);
    },
    d(h) {
      h && bu(e);
    }
  };
}
function u0(i) {
  let e, t, n, o = (
    /*files_with_progress*/
    i[0].length + ""
  ), r, s, a = (
    /*files_with_progress*/
    i[0].length > 1 ? "files" : "file"
  ), l, u, c, d = (
    /*file_to_display*/
    i[2] && El(i)
  );
  return {
    c() {
      e = sn("div"), t = sn("span"), n = An("Uploading "), r = An(o), s = Zs(), l = An(a), u = An("..."), c = Zs(), d && d.c(), on(t, "class", "uploading svelte-cr2edf"), on(e, "class", "wrap svelte-cr2edf"), Sl(
        e,
        "progress",
        /*progress*/
        i[1]
      );
    },
    m(h, f) {
      wu(h, e, f), je(e, t), je(t, n), je(t, r), je(t, s), je(t, l), je(t, u), je(e, c), d && d.m(e, null);
    },
    p(h, [f]) {
      f & /*files_with_progress*/
      1 && o !== (o = /*files_with_progress*/
      h[0].length + "") && po(r, o), f & /*files_with_progress*/
      1 && a !== (a = /*files_with_progress*/
      h[0].length > 1 ? "files" : "file") && po(l, a), /*file_to_display*/
      h[2] ? d ? d.p(h, f) : (d = El(h), d.c(), d.m(e, null)) : d && (d.d(1), d = null), f & /*progress*/
      2 && Sl(
        e,
        "progress",
        /*progress*/
        h[1]
      );
    },
    i: Cl,
    o: Cl,
    d(h) {
      h && bu(e), d && d.d();
    }
  };
}
function gi(i) {
  return i.progress * 100 / (i.size || 0) || 0;
}
function c0(i) {
  let e = 0;
  return i.forEach((t) => {
    e += gi(t);
  }), document.documentElement.style.setProperty("--upload-progress-width", (e / i.length).toFixed(2) + "%"), e / i.length;
}
function d0(i, e, t) {
  var n = this && this.__awaiter || function(g, p, _, y) {
    function v(C) {
      return C instanceof _ ? C : new _(function(M) {
        M(C);
      });
    }
    return new (_ || (_ = Promise))(function(C, M) {
      function k(b) {
        try {
          D(y.next(b));
        } catch (E) {
          M(E);
        }
      }
      function P(b) {
        try {
          D(y.throw(b));
        } catch (E) {
          M(E);
        }
      }
      function D(b) {
        b.done ? C(b.value) : v(b.value).then(k, P);
      }
      D((y = y.apply(g, p || [])).next());
    });
  };
  let { upload_id: o } = e, { root: r } = e, { files: s } = e, a, l = !1, u, c, d = s.map((g) => Object.assign(Object.assign({}, g), { progress: 0 }));
  const h = l0();
  function f(g, p) {
    t(0, d = d.map((_) => (_.orig_name === g && (_.progress += p), _)));
  }
  const m = a0("EventSource_factory");
  return r0(() => {
    a = m(new URL(`${r}/upload_progress?upload_id=${o}`)), a.onmessage = function(g) {
      return n(this, void 0, void 0, function* () {
        const p = JSON.parse(g.data);
        l || t(1, l = !0), p.msg === "done" ? (a.close(), h("done")) : (t(6, u = p), f(p.orig_name, p.chunk_size));
      });
    };
  }), i.$$set = (g) => {
    "upload_id" in g && t(3, o = g.upload_id), "root" in g && t(4, r = g.root), "files" in g && t(5, s = g.files);
  }, i.$$.update = () => {
    i.$$.dirty & /*files_with_progress*/
    1 && c0(d), i.$$.dirty & /*current_file_upload, files_with_progress*/
    65 && t(2, c = u || d[0]);
  }, [
    d,
    l,
    c,
    o,
    r,
    s,
    u
  ];
}
class f0 extends i0 {
  constructor(e) {
    super(), o0(this, e, d0, u0, s0, { upload_id: 3, root: 4, files: 5 });
  }
}
const {
  SvelteComponent: h0,
  append: Dl,
  attr: Le,
  binding_callbacks: m0,
  bubble: en,
  check_outros: yu,
  create_component: p0,
  create_slot: ku,
  destroy_component: _0,
  detach: Eo,
  element: Xs,
  empty: Cu,
  get_all_dirty_from_scope: Su,
  get_slot_changes: Eu,
  group_outros: Du,
  init: g0,
  insert: Do,
  listen: Ie,
  mount_component: v0,
  prevent_default: tn,
  run_all: b0,
  safe_not_equal: w0,
  set_style: Ru,
  space: y0,
  stop_propagation: nn,
  toggle_class: ke,
  transition_in: Yt,
  transition_out: _n,
  update_slot_base: Mu
} = window.__gradio__svelte__internal, { createEventDispatcher: k0, tick: C0, getContext: S0 } = window.__gradio__svelte__internal;
function E0(i) {
  let e, t, n, o, r, s, a, l, u, c, d;
  const h = (
    /*#slots*/
    i[22].default
  ), f = ku(
    h,
    i,
    /*$$scope*/
    i[21],
    null
  );
  return {
    c() {
      e = Xs("button"), f && f.c(), t = y0(), n = Xs("input"), Le(n, "aria-label", "file upload"), Le(n, "data-testid", "file-upload"), Le(n, "type", "file"), Le(n, "accept", o = /*accept_file_types*/
      i[14] || void 0), n.multiple = r = /*file_count*/
      i[6] === "multiple" || void 0, Le(n, "webkitdirectory", s = /*file_count*/
      i[6] === "directory" || void 0), Le(n, "mozdirectory", a = /*file_count*/
      i[6] === "directory" || void 0), Le(n, "class", "svelte-1s26xmt"), Le(e, "tabindex", l = /*hidden*/
      i[9] ? -1 : 0), Le(e, "class", "svelte-1s26xmt"), ke(
        e,
        "hidden",
        /*hidden*/
        i[9]
      ), ke(
        e,
        "center",
        /*center*/
        i[4]
      ), ke(
        e,
        "boundedheight",
        /*boundedheight*/
        i[3]
      ), ke(
        e,
        "flex",
        /*flex*/
        i[5]
      ), ke(
        e,
        "disable_click",
        /*disable_click*/
        i[7]
      ), Ru(e, "height", "100%");
    },
    m(m, g) {
      Do(m, e, g), f && f.m(e, null), Dl(e, t), Dl(e, n), i[30](n), u = !0, c || (d = [
        Ie(
          n,
          "change",
          /*load_files_from_upload*/
          i[16]
        ),
        Ie(e, "drag", nn(tn(
          /*drag_handler*/
          i[23]
        ))),
        Ie(e, "dragstart", nn(tn(
          /*dragstart_handler*/
          i[24]
        ))),
        Ie(e, "dragend", nn(tn(
          /*dragend_handler*/
          i[25]
        ))),
        Ie(e, "dragover", nn(tn(
          /*dragover_handler*/
          i[26]
        ))),
        Ie(e, "dragenter", nn(tn(
          /*dragenter_handler*/
          i[27]
        ))),
        Ie(e, "dragleave", nn(tn(
          /*dragleave_handler*/
          i[28]
        ))),
        Ie(e, "drop", nn(tn(
          /*drop_handler*/
          i[29]
        ))),
        Ie(
          e,
          "click",
          /*open_file_upload*/
          i[11]
        ),
        Ie(
          e,
          "drop",
          /*loadFilesFromDrop*/
          i[17]
        ),
        Ie(
          e,
          "dragenter",
          /*updateDragging*/
          i[15]
        ),
        Ie(
          e,
          "dragleave",
          /*updateDragging*/
          i[15]
        )
      ], c = !0);
    },
    p(m, g) {
      f && f.p && (!u || g[0] & /*$$scope*/
      2097152) && Mu(
        f,
        h,
        m,
        /*$$scope*/
        m[21],
        u ? Eu(
          h,
          /*$$scope*/
          m[21],
          g,
          null
        ) : Su(
          /*$$scope*/
          m[21]
        ),
        null
      ), (!u || g[0] & /*accept_file_types*/
      16384 && o !== (o = /*accept_file_types*/
      m[14] || void 0)) && Le(n, "accept", o), (!u || g[0] & /*file_count*/
      64 && r !== (r = /*file_count*/
      m[6] === "multiple" || void 0)) && (n.multiple = r), (!u || g[0] & /*file_count*/
      64 && s !== (s = /*file_count*/
      m[6] === "directory" || void 0)) && Le(n, "webkitdirectory", s), (!u || g[0] & /*file_count*/
      64 && a !== (a = /*file_count*/
      m[6] === "directory" || void 0)) && Le(n, "mozdirectory", a), (!u || g[0] & /*hidden*/
      512 && l !== (l = /*hidden*/
      m[9] ? -1 : 0)) && Le(e, "tabindex", l), (!u || g[0] & /*hidden*/
      512) && ke(
        e,
        "hidden",
        /*hidden*/
        m[9]
      ), (!u || g[0] & /*center*/
      16) && ke(
        e,
        "center",
        /*center*/
        m[4]
      ), (!u || g[0] & /*boundedheight*/
      8) && ke(
        e,
        "boundedheight",
        /*boundedheight*/
        m[3]
      ), (!u || g[0] & /*flex*/
      32) && ke(
        e,
        "flex",
        /*flex*/
        m[5]
      ), (!u || g[0] & /*disable_click*/
      128) && ke(
        e,
        "disable_click",
        /*disable_click*/
        m[7]
      );
    },
    i(m) {
      u || (Yt(f, m), u = !0);
    },
    o(m) {
      _n(f, m), u = !1;
    },
    d(m) {
      m && Eo(e), f && f.d(m), i[30](null), c = !1, b0(d);
    }
  };
}
function D0(i) {
  let e, t, n = !/*hidden*/
  i[9] && Rl(i);
  return {
    c() {
      n && n.c(), e = Cu();
    },
    m(o, r) {
      n && n.m(o, r), Do(o, e, r), t = !0;
    },
    p(o, r) {
      /*hidden*/
      o[9] ? n && (Du(), _n(n, 1, 1, () => {
        n = null;
      }), yu()) : n ? (n.p(o, r), r[0] & /*hidden*/
      512 && Yt(n, 1)) : (n = Rl(o), n.c(), Yt(n, 1), n.m(e.parentNode, e));
    },
    i(o) {
      t || (Yt(n), t = !0);
    },
    o(o) {
      _n(n), t = !1;
    },
    d(o) {
      o && Eo(e), n && n.d(o);
    }
  };
}
function R0(i) {
  let e, t, n, o, r;
  const s = (
    /*#slots*/
    i[22].default
  ), a = ku(
    s,
    i,
    /*$$scope*/
    i[21],
    null
  );
  return {
    c() {
      e = Xs("button"), a && a.c(), Le(e, "tabindex", t = /*hidden*/
      i[9] ? -1 : 0), Le(e, "class", "svelte-1s26xmt"), ke(
        e,
        "hidden",
        /*hidden*/
        i[9]
      ), ke(
        e,
        "center",
        /*center*/
        i[4]
      ), ke(
        e,
        "boundedheight",
        /*boundedheight*/
        i[3]
      ), ke(
        e,
        "flex",
        /*flex*/
        i[5]
      ), Ru(e, "height", "100%");
    },
    m(l, u) {
      Do(l, e, u), a && a.m(e, null), n = !0, o || (r = Ie(
        e,
        "click",
        /*paste_clipboard*/
        i[10]
      ), o = !0);
    },
    p(l, u) {
      a && a.p && (!n || u[0] & /*$$scope*/
      2097152) && Mu(
        a,
        s,
        l,
        /*$$scope*/
        l[21],
        n ? Eu(
          s,
          /*$$scope*/
          l[21],
          u,
          null
        ) : Su(
          /*$$scope*/
          l[21]
        ),
        null
      ), (!n || u[0] & /*hidden*/
      512 && t !== (t = /*hidden*/
      l[9] ? -1 : 0)) && Le(e, "tabindex", t), (!n || u[0] & /*hidden*/
      512) && ke(
        e,
        "hidden",
        /*hidden*/
        l[9]
      ), (!n || u[0] & /*center*/
      16) && ke(
        e,
        "center",
        /*center*/
        l[4]
      ), (!n || u[0] & /*boundedheight*/
      8) && ke(
        e,
        "boundedheight",
        /*boundedheight*/
        l[3]
      ), (!n || u[0] & /*flex*/
      32) && ke(
        e,
        "flex",
        /*flex*/
        l[5]
      );
    },
    i(l) {
      n || (Yt(a, l), n = !0);
    },
    o(l) {
      _n(a, l), n = !1;
    },
    d(l) {
      l && Eo(e), a && a.d(l), o = !1, r();
    }
  };
}
function Rl(i) {
  let e, t;
  return e = new f0({
    props: {
      root: (
        /*root*/
        i[8]
      ),
      upload_id: (
        /*upload_id*/
        i[12]
      ),
      files: (
        /*file_data*/
        i[13]
      )
    }
  }), {
    c() {
      p0(e.$$.fragment);
    },
    m(n, o) {
      v0(e, n, o), t = !0;
    },
    p(n, o) {
      const r = {};
      o[0] & /*root*/
      256 && (r.root = /*root*/
      n[8]), o[0] & /*upload_id*/
      4096 && (r.upload_id = /*upload_id*/
      n[12]), o[0] & /*file_data*/
      8192 && (r.files = /*file_data*/
      n[13]), e.$set(r);
    },
    i(n) {
      t || (Yt(e.$$.fragment, n), t = !0);
    },
    o(n) {
      _n(e.$$.fragment, n), t = !1;
    },
    d(n) {
      _0(e, n);
    }
  };
}
function M0(i) {
  let e, t, n, o;
  const r = [R0, D0, E0], s = [];
  function a(l, u) {
    return (
      /*filetype*/
      l[0] === "clipboard" ? 0 : (
        /*uploading*/
        l[1] && !/*hidden_upload*/
        l[2] ? 1 : 2
      )
    );
  }
  return e = a(i), t = s[e] = r[e](i), {
    c() {
      t.c(), n = Cu();
    },
    m(l, u) {
      s[e].m(l, u), Do(l, n, u), o = !0;
    },
    p(l, u) {
      let c = e;
      e = a(l), e === c ? s[e].p(l, u) : (Du(), _n(s[c], 1, 1, () => {
        s[c] = null;
      }), yu(), t = s[e], t ? t.p(l, u) : (t = s[e] = r[e](l), t.c()), Yt(t, 1), t.m(n.parentNode, n));
    },
    i(l) {
      o || (Yt(t), o = !0);
    },
    o(l) {
      _n(t), o = !1;
    },
    d(l) {
      l && Eo(n), s[e].d(l);
    }
  };
}
function L0(i, e, t) {
  if (!i || i === "*" || i === "file/*" || Array.isArray(i) && i.some((o) => o === "*" || o === "file/*"))
    return !0;
  let n;
  if (typeof i == "string")
    n = i.split(",").map((o) => o.trim());
  else if (Array.isArray(i))
    n = i;
  else
    return !1;
  return n.includes(e) || n.some((o) => {
    const [r] = o.split("/").map((s) => s.trim());
    return o.endsWith("/*") && t.startsWith(r + "/");
  });
}
function O0(i, e, t) {
  let { $$slots: n = {}, $$scope: o } = e;
  var r = this && this.__awaiter || function(S, W, z, O) {
    function w(L) {
      return L instanceof z ? L : new z(function(B) {
        B(L);
      });
    }
    return new (z || (z = Promise))(function(L, B) {
      function R(ae) {
        try {
          ne(O.next(ae));
        } catch (Ct) {
          B(Ct);
        }
      }
      function Z(ae) {
        try {
          ne(O.throw(ae));
        } catch (Ct) {
          B(Ct);
        }
      }
      function ne(ae) {
        ae.done ? L(ae.value) : w(ae.value).then(R, Z);
      }
      ne((O = O.apply(S, W || [])).next());
    });
  };
  let { filetype: s = null } = e, { dragging: a = !1 } = e, { boundedheight: l = !0 } = e, { center: u = !0 } = e, { flex: c = !0 } = e, { file_count: d = "single" } = e, { disable_click: h = !1 } = e, { root: f } = e, { hidden: m = !1 } = e, { format: g = "file" } = e, { uploading: p = !1 } = e, { hidden_upload: _ = null } = e, y, v, C;
  const M = S0("upload_files"), k = k0(), P = ["image", "video", "audio", "text", "file"], D = (S) => S.startsWith(".") || S.endsWith("/*") ? S : P.includes(S) ? S + "/*" : "." + S;
  function b() {
    t(18, a = !a);
  }
  function E() {
    navigator.clipboard.read().then((S) => r(this, void 0, void 0, function* () {
      for (let W = 0; W < S.length; W++) {
        const z = S[W].types.find((O) => O.startsWith("image/"));
        if (z) {
          S[W].getType(z).then((O) => r(this, void 0, void 0, function* () {
            const w = new File([O], `clipboard.${z.replace("image/", "")}`);
            yield j([w]);
          }));
          break;
        }
      }
    }));
  }
  function U() {
    h || _ && (t(2, _.value = "", _), _.click());
  }
  function T(S) {
    return r(this, void 0, void 0, function* () {
      yield C0(), t(12, y = Math.random().toString(36).substring(2, 15)), t(1, p = !0);
      const W = yield pu(S, f, y, M);
      return k("load", d === "single" ? W == null ? void 0 : W[0] : W), t(1, p = !1), W || [];
    });
  }
  function j(S) {
    return r(this, void 0, void 0, function* () {
      if (!S.length)
        return;
      let W = S.map((z) => new File([z], z.name, { type: z.type }));
      return t(13, v = yield _u(W)), yield T(v);
    });
  }
  function V(S) {
    return r(this, void 0, void 0, function* () {
      const W = S.target;
      if (W.files)
        if (g != "blob")
          yield j(Array.from(W.files));
        else {
          if (d === "single") {
            k("load", W.files[0]);
            return;
          }
          k("load", W.files);
        }
    });
  }
  function Q(S) {
    return r(this, void 0, void 0, function* () {
      var W;
      if (t(18, a = !1), !(!((W = S.dataTransfer) === null || W === void 0) && W.files)) return;
      const z = Array.from(S.dataTransfer.files).filter((O) => {
        const w = "." + O.name.split(".").pop();
        return w && L0(C, w, O.type) || (w && Array.isArray(s) ? s.includes(w) : w === s) ? !0 : (k("error", `Invalid file type only ${s} allowed.`), !1);
      });
      yield j(z);
    });
  }
  function q(S) {
    en.call(this, i, S);
  }
  function I(S) {
    en.call(this, i, S);
  }
  function H(S) {
    en.call(this, i, S);
  }
  function G(S) {
    en.call(this, i, S);
  }
  function F(S) {
    en.call(this, i, S);
  }
  function K(S) {
    en.call(this, i, S);
  }
  function x(S) {
    en.call(this, i, S);
  }
  function A(S) {
    m0[S ? "unshift" : "push"](() => {
      _ = S, t(2, _);
    });
  }
  return i.$$set = (S) => {
    "filetype" in S && t(0, s = S.filetype), "dragging" in S && t(18, a = S.dragging), "boundedheight" in S && t(3, l = S.boundedheight), "center" in S && t(4, u = S.center), "flex" in S && t(5, c = S.flex), "file_count" in S && t(6, d = S.file_count), "disable_click" in S && t(7, h = S.disable_click), "root" in S && t(8, f = S.root), "hidden" in S && t(9, m = S.hidden), "format" in S && t(19, g = S.format), "uploading" in S && t(1, p = S.uploading), "hidden_upload" in S && t(2, _ = S.hidden_upload), "$$scope" in S && t(21, o = S.$$scope);
  }, i.$$.update = () => {
    i.$$.dirty[0] & /*filetype*/
    1 && (s == null ? t(14, C = null) : typeof s == "string" ? t(14, C = D(s)) : (t(0, s = s.map(D)), t(14, C = s.join(", "))));
  }, [
    s,
    p,
    _,
    l,
    u,
    c,
    d,
    h,
    f,
    m,
    E,
    U,
    y,
    v,
    C,
    b,
    V,
    Q,
    a,
    g,
    j,
    o,
    n,
    q,
    I,
    H,
    G,
    F,
    K,
    x,
    A
  ];
}
class P0 extends h0 {
  constructor(e) {
    super(), g0(
      this,
      e,
      O0,
      M0,
      w0,
      {
        filetype: 0,
        dragging: 18,
        boundedheight: 3,
        center: 4,
        flex: 5,
        file_count: 6,
        disable_click: 7,
        root: 8,
        hidden: 9,
        format: 19,
        uploading: 1,
        hidden_upload: 2,
        paste_clipboard: 10,
        open_file_upload: 11,
        load_files: 20
      },
      null,
      [-1, -1]
    );
  }
  get paste_clipboard() {
    return this.$$.ctx[10];
  }
  get open_file_upload() {
    return this.$$.ctx[11];
  }
  get load_files() {
    return this.$$.ctx[20];
  }
}
const {
  SvelteComponent: W0,
  append: fs,
  attr: A0,
  check_outros: hs,
  create_component: Pi,
  destroy_component: Wi,
  detach: T0,
  element: q0,
  group_outros: ms,
  init: j0,
  insert: N0,
  mount_component: Ai,
  safe_not_equal: z0,
  set_style: Ml,
  space: ps,
  toggle_class: Ll,
  transition_in: Te,
  transition_out: at
} = window.__gradio__svelte__internal, { createEventDispatcher: B0 } = window.__gradio__svelte__internal;
function Ol(i) {
  let e, t;
  return e = new Ri({
    props: {
      Icon: qd,
      label: (
        /*i18n*/
        i[4]("common.edit")
      )
    }
  }), e.$on(
    "click",
    /*click_handler*/
    i[6]
  ), {
    c() {
      Pi(e.$$.fragment);
    },
    m(n, o) {
      Ai(e, n, o), t = !0;
    },
    p(n, o) {
      const r = {};
      o & /*i18n*/
      16 && (r.label = /*i18n*/
      n[4]("common.edit")), e.$set(r);
    },
    i(n) {
      t || (Te(e.$$.fragment, n), t = !0);
    },
    o(n) {
      at(e.$$.fragment, n), t = !1;
    },
    d(n) {
      Wi(e, n);
    }
  };
}
function Pl(i) {
  let e, t;
  return e = new Ri({
    props: {
      Icon: Ma,
      label: (
        /*i18n*/
        i[4]("common.undo")
      )
    }
  }), e.$on(
    "click",
    /*click_handler_1*/
    i[7]
  ), {
    c() {
      Pi(e.$$.fragment);
    },
    m(n, o) {
      Ai(e, n, o), t = !0;
    },
    p(n, o) {
      const r = {};
      o & /*i18n*/
      16 && (r.label = /*i18n*/
      n[4]("common.undo")), e.$set(r);
    },
    i(n) {
      t || (Te(e.$$.fragment, n), t = !0);
    },
    o(n) {
      at(e.$$.fragment, n), t = !1;
    },
    d(n) {
      Wi(e, n);
    }
  };
}
function Wl(i) {
  let e, t;
  return e = new iu({
    props: {
      href: (
        /*download*/
        i[2]
      ),
      download: !0,
      $$slots: { default: [I0] },
      $$scope: { ctx: i }
    }
  }), {
    c() {
      Pi(e.$$.fragment);
    },
    m(n, o) {
      Ai(e, n, o), t = !0;
    },
    p(n, o) {
      const r = {};
      o & /*download*/
      4 && (r.href = /*download*/
      n[2]), o & /*$$scope, i18n*/
      528 && (r.$$scope = { dirty: o, ctx: n }), e.$set(r);
    },
    i(n) {
      t || (Te(e.$$.fragment, n), t = !0);
    },
    o(n) {
      at(e.$$.fragment, n), t = !1;
    },
    d(n) {
      Wi(e, n);
    }
  };
}
function I0(i) {
  let e, t;
  return e = new Ri({
    props: {
      Icon: Ea,
      label: (
        /*i18n*/
        i[4]("common.download")
      )
    }
  }), {
    c() {
      Pi(e.$$.fragment);
    },
    m(n, o) {
      Ai(e, n, o), t = !0;
    },
    p(n, o) {
      const r = {};
      o & /*i18n*/
      16 && (r.label = /*i18n*/
      n[4]("common.download")), e.$set(r);
    },
    i(n) {
      t || (Te(e.$$.fragment, n), t = !0);
    },
    o(n) {
      at(e.$$.fragment, n), t = !1;
    },
    d(n) {
      Wi(e, n);
    }
  };
}
function U0(i) {
  let e, t, n, o, r, s, a = (
    /*editable*/
    i[0] && Ol(i)
  ), l = (
    /*undoable*/
    i[1] && Pl(i)
  ), u = (
    /*download*/
    i[2] && Wl(i)
  );
  return r = new Ri({
    props: {
      Icon: wd,
      label: (
        /*i18n*/
        i[4]("common.clear")
      )
    }
  }), r.$on(
    "click",
    /*click_handler_2*/
    i[8]
  ), {
    c() {
      e = q0("div"), a && a.c(), t = ps(), l && l.c(), n = ps(), u && u.c(), o = ps(), Pi(r.$$.fragment), A0(e, "class", "svelte-1wj0ocy"), Ll(e, "not-absolute", !/*absolute*/
      i[3]), Ml(
        e,
        "position",
        /*absolute*/
        i[3] ? "absolute" : "static"
      );
    },
    m(c, d) {
      N0(c, e, d), a && a.m(e, null), fs(e, t), l && l.m(e, null), fs(e, n), u && u.m(e, null), fs(e, o), Ai(r, e, null), s = !0;
    },
    p(c, [d]) {
      /*editable*/
      c[0] ? a ? (a.p(c, d), d & /*editable*/
      1 && Te(a, 1)) : (a = Ol(c), a.c(), Te(a, 1), a.m(e, t)) : a && (ms(), at(a, 1, 1, () => {
        a = null;
      }), hs()), /*undoable*/
      c[1] ? l ? (l.p(c, d), d & /*undoable*/
      2 && Te(l, 1)) : (l = Pl(c), l.c(), Te(l, 1), l.m(e, n)) : l && (ms(), at(l, 1, 1, () => {
        l = null;
      }), hs()), /*download*/
      c[2] ? u ? (u.p(c, d), d & /*download*/
      4 && Te(u, 1)) : (u = Wl(c), u.c(), Te(u, 1), u.m(e, o)) : u && (ms(), at(u, 1, 1, () => {
        u = null;
      }), hs());
      const h = {};
      d & /*i18n*/
      16 && (h.label = /*i18n*/
      c[4]("common.clear")), r.$set(h), (!s || d & /*absolute*/
      8) && Ll(e, "not-absolute", !/*absolute*/
      c[3]), d & /*absolute*/
      8 && Ml(
        e,
        "position",
        /*absolute*/
        c[3] ? "absolute" : "static"
      );
    },
    i(c) {
      s || (Te(a), Te(l), Te(u), Te(r.$$.fragment, c), s = !0);
    },
    o(c) {
      at(a), at(l), at(u), at(r.$$.fragment, c), s = !1;
    },
    d(c) {
      c && T0(e), a && a.d(), l && l.d(), u && u.d(), Wi(r);
    }
  };
}
function F0(i, e, t) {
  let { editable: n = !1 } = e, { undoable: o = !1 } = e, { download: r = null } = e, { absolute: s = !0 } = e, { i18n: a } = e;
  const l = B0(), u = () => l("edit"), c = () => l("undo"), d = (h) => {
    l("clear"), h.stopPropagation();
  };
  return i.$$set = (h) => {
    "editable" in h && t(0, n = h.editable), "undoable" in h && t(1, o = h.undoable), "download" in h && t(2, r = h.download), "absolute" in h && t(3, s = h.absolute), "i18n" in h && t(4, a = h.i18n);
  }, [
    n,
    o,
    r,
    s,
    a,
    l,
    u,
    c,
    d
  ];
}
class Lu extends W0 {
  constructor(e) {
    super(), j0(this, e, F0, U0, z0, {
      editable: 0,
      undoable: 1,
      download: 2,
      absolute: 3,
      i18n: 4
    });
  }
}
class Al {
  constructor({
    path: e,
    url: t,
    orig_name: n,
    size: o,
    blob: r,
    is_stream: s,
    mime_type: a,
    alt_text: l
  }) {
    this.file_data = new So({ path: e, url: t, orig_name: n, size: o, blob: r, is_stream: s, mime_type: a, alt_text: l }), this.annotations = null;
  }
}
function _s(i, e, t, n) {
  return new (t || (t = Promise))(function(o, r) {
    function s(u) {
      try {
        l(n.next(u));
      } catch (c) {
        r(c);
      }
    }
    function a(u) {
      try {
        l(n.throw(u));
      } catch (c) {
        r(c);
      }
    }
    function l(u) {
      var c;
      u.done ? o(u.value) : (c = u.value, c instanceof t ? c : new t(function(d) {
        d(c);
      })).then(s, a);
    }
    l((n = n.apply(i, [])).next());
  });
}
class Ou {
  constructor() {
    this.listeners = {};
  }
  on(e, t, n) {
    if (this.listeners[e] || (this.listeners[e] = /* @__PURE__ */ new Set()), this.listeners[e].add(t), n == null ? void 0 : n.once) {
      const o = () => {
        this.un(e, o), this.un(e, t);
      };
      return this.on(e, o), o;
    }
    return () => this.un(e, t);
  }
  un(e, t) {
    var n;
    (n = this.listeners[e]) === null || n === void 0 || n.delete(t);
  }
  once(e, t) {
    return this.on(e, t, { once: !0 });
  }
  unAll() {
    this.listeners = {};
  }
  emit(e, ...t) {
    this.listeners[e] && this.listeners[e].forEach((n) => n(...t));
  }
}
class G0 extends Ou {
  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 V0 extends Ou {
  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 H0 = ["audio/webm", "audio/wav", "audio/mpeg", "audio/mp4", "audio/mp3"];
class Ti extends G0 {
  constructor(e) {
    var t, n, o, r, s, a;
    super(Object.assign(Object.assign({}, e), { audioBitsPerSecond: (t = e.audioBitsPerSecond) !== null && t !== void 0 ? t : 128e3, scrollingWaveform: (n = e.scrollingWaveform) !== null && n !== void 0 && n, scrollingWaveformWindow: (o = e.scrollingWaveformWindow) !== null && o !== void 0 ? o : 5, continuousWaveform: (r = e.continuousWaveform) !== null && r !== void 0 && r, 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 V0(), 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 Ti(e || {});
  }
  renderMicStream(e) {
    var t;
    const n = new AudioContext(), o = n.createMediaStreamSource(e), r = n.createAnalyser();
    o.connect(r), this.options.continuousWaveform && (r.fftSize = 32);
    const s = r.frequencyBinCount, a = new Float32Array(s);
    let l = 0;
    this.wavesurfer && ((t = this.originalOptions) !== null && t !== 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, d, h, f;
      if (!this.isWaveformPaused) {
        if (r.getFloatTimeDomainData(a), this.options.scrollingWaveform) {
          const m = Math.floor((this.options.scrollingWaveformWindow || 0) * n.sampleRate), g = Math.min(m, this.dataWindow ? this.dataWindow.length + s : s), p = new Float32Array(m);
          if (this.dataWindow) {
            const _ = Math.max(0, m - this.dataWindow.length);
            p.set(this.dataWindow.slice(-g + s), _);
          }
          p.set(a, m - s), this.dataWindow = p;
        } else if (this.options.continuousWaveform) {
          if (!this.dataWindow) {
            const g = this.options.continuousWaveformDuration ? Math.round(100 * this.options.continuousWaveformDuration) : ((d = (c = this.wavesurfer) === null || c === void 0 ? void 0 : c.getWidth()) !== null && d !== void 0 ? d : 0) * window.devicePixelRatio;
            this.dataWindow = new Float32Array(g);
          }
          let m = 0;
          for (let g = 0; g < s; g++) {
            const p = Math.abs(a[g]);
            p > m && (m = p);
          }
          if (l + 1 > this.dataWindow.length) {
            const g = new Float32Array(2 * this.dataWindow.length);
            g.set(this.dataWindow, 0), this.dataWindow = g;
          }
          this.dataWindow[l] = m, l++;
        } else this.dataWindow = a;
        if (this.wavesurfer) {
          const m = ((f = (h = this.dataWindow) === null || h === void 0 ? void 0 : h.length) !== null && f !== void 0 ? f : 0) / 100;
          let g = l / this.dataWindow.length;
          this.wavesurfer.options.barWidth && (g += this.wavesurfer.options.barWidth / this.wavesurfer.getWidth()), this.wavesurfer.load("", [this.dataWindow], this.options.scrollingWaveform ? this.options.scrollingWaveformWindow : m).then(() => {
            this.wavesurfer && this.options.continuousWaveform && (this.wavesurfer.seekTo(g), this.wavesurfer.options.minPxPerSec || this.wavesurfer.setOptions({ minPxPerSec: this.wavesurfer.getWidth() / this.wavesurfer.getDuration() }));
          }).catch((p) => {
            console.error("Error rendering real-time recording data:", p);
          });
        }
      }
    }, 10);
    return { onDestroy: () => {
      clearInterval(u), o == null || o.disconnect(), n == null || n.close();
    }, onEnd: () => {
      this.isWaveformPaused = !0, clearInterval(u), this.stopMic();
    } };
  }
  startMic(e) {
    return _s(this, void 0, void 0, function* () {
      let t;
      try {
        t = yield navigator.mediaDevices.getUserMedia({ audio: !(e != null && e.deviceId) || { deviceId: e.deviceId } });
      } catch (r) {
        throw new Error("Error accessing the microphone: " + r.message);
      }
      const { onDestroy: n, onEnd: o } = this.renderMicStream(t);
      return this.subscriptions.push(this.once("destroy", n)), this.subscriptions.push(this.once("record-end", o)), this.stream = t, t;
    });
  }
  stopMic() {
    this.stream && (this.stream.getTracks().forEach((e) => e.stop()), this.stream = null, this.mediaRecorder = null);
  }
  startRecording(e) {
    return _s(this, void 0, void 0, function* () {
      const t = this.stream || (yield this.startMic(e));
      this.dataWindow = null;
      const n = this.mediaRecorder || new MediaRecorder(t, { mimeType: this.options.mimeType || H0.find((s) => MediaRecorder.isTypeSupported(s)), audioBitsPerSecond: this.options.audioBitsPerSecond });
      this.mediaRecorder = n, this.stopRecording();
      const o = [];
      n.ondataavailable = (s) => {
        s.data.size > 0 && o.push(s.data), this.emit("record-data-available", s.data);
      };
      const r = (s) => {
        var a;
        const l = new Blob(o, { type: n.mimeType });
        this.emit(s, l), this.options.renderRecordedAudio && (this.applyOriginalOptionsIfNeeded(), (a = this.wavesurfer) === null || a === void 0 || a.load(URL.createObjectURL(l)));
      };
      n.onpause = () => r("record-pause"), n.onstop = () => r("record-end"), n.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, t;
    this.isRecording() && (this.isWaveformPaused = !0, (e = this.mediaRecorder) === null || e === void 0 || e.requestData(), (t = this.mediaRecorder) === null || t === void 0 || t.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 _s(this, void 0, void 0, function* () {
      return navigator.mediaDevices.enumerateDevices().then((e) => e.filter((t) => t.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: Z0,
  append: ge,
  attr: Ke,
  binding_callbacks: ui,
  create_component: X0,
  destroy_component: J0,
  destroy_each: K0,
  detach: qi,
  element: rt,
  empty: Y0,
  ensure_array_like: Tl,
  init: Q0,
  insert: ji,
  listen: ci,
  mount_component: $0,
  run_all: x0,
  safe_not_equal: e1,
  set_data: un,
  set_input_value: Js,
  space: Mn,
  text: cn,
  transition_in: t1,
  transition_out: n1
} = window.__gradio__svelte__internal, { createEventDispatcher: i1 } = window.__gradio__svelte__internal;
function ql(i, e, t) {
  const n = i.slice();
  return n[22] = e[t], n;
}
function jl(i) {
  let e, t;
  return {
    c() {
      e = rt("time"), t = cn(
        /*record_time*/
        i[2]
      ), Ke(e, "class", "duration-button duration svelte-wjm7x4");
    },
    m(n, o) {
      ji(n, e, o), ge(e, t);
    },
    p(n, o) {
      o & /*record_time*/
      4 && un(
        t,
        /*record_time*/
        n[2]
      );
    },
    d(n) {
      n && qi(e);
    }
  };
}
function o1(i) {
  let e, t = Tl(
    /*micDevices*/
    i[5]
  ), n = [];
  for (let o = 0; o < t.length; o += 1)
    n[o] = Nl(ql(i, t, o));
  return {
    c() {
      for (let o = 0; o < n.length; o += 1)
        n[o].c();
      e = Y0();
    },
    m(o, r) {
      for (let s = 0; s < n.length; s += 1)
        n[s] && n[s].m(o, r);
      ji(o, e, r);
    },
    p(o, r) {
      if (r & /*micDevices*/
      32) {
        t = Tl(
          /*micDevices*/
          o[5]
        );
        let s;
        for (s = 0; s < t.length; s += 1) {
          const a = ql(o, t, s);
          n[s] ? n[s].p(a, r) : (n[s] = Nl(a), n[s].c(), n[s].m(e.parentNode, e));
        }
        for (; s < n.length; s += 1)
          n[s].d(1);
        n.length = t.length;
      }
    },
    d(o) {
      o && qi(e), K0(n, o);
    }
  };
}
function s1(i) {
  let e, t = (
    /*i18n*/
    i[1]("audio.no_microphone") + ""
  ), n;
  return {
    c() {
      e = rt("option"), n = cn(t), e.__value = "", Js(e, e.__value);
    },
    m(o, r) {
      ji(o, e, r), ge(e, n);
    },
    p(o, r) {
      r & /*i18n*/
      2 && t !== (t = /*i18n*/
      o[1]("audio.no_microphone") + "") && un(n, t);
    },
    d(o) {
      o && qi(e);
    }
  };
}
function Nl(i) {
  let e, t = (
    /*micDevice*/
    i[22].label + ""
  ), n, o;
  return {
    c() {
      e = rt("option"), n = cn(t), e.__value = o = /*micDevice*/
      i[22].deviceId, Js(e, e.__value);
    },
    m(r, s) {
      ji(r, e, s), ge(e, n);
    },
    p(r, s) {
      s & /*micDevices*/
      32 && t !== (t = /*micDevice*/
      r[22].label + "") && un(n, t), s & /*micDevices*/
      32 && o !== (o = /*micDevice*/
      r[22].deviceId) && (e.__value = o, Js(e, e.__value));
    },
    d(r) {
      r && qi(e);
    }
  };
}
function r1(i) {
  let e, t, n, o = (
    /*i18n*/
    i[1]("audio.record") + ""
  ), r, s, a, l = (
    /*i18n*/
    i[1]("audio.stop") + ""
  ), u, c, d, h, f = (
    /*i18n*/
    i[1]("audio.stop") + ""
  ), m, g, p, _, y, v, C = (
    /*i18n*/
    i[1]("audio.resume") + ""
  ), M, k, P, D, b, E, U, T;
  _ = new Ra({});
  let j = (
    /*timing*/
    i[4] && !/*show_recording_waveform*/
    i[3] && jl(i)
  );
  function V(I, H) {
    return (
      /*micDevices*/
      I[5].length === 0 ? s1 : o1
    );
  }
  let Q = V(i), q = Q(i);
  return {
    c() {
      e = rt("div"), t = rt("div"), n = rt("button"), r = cn(o), s = Mn(), a = rt("button"), u = cn(l), d = Mn(), h = rt("button"), m = cn(f), g = Mn(), p = rt("button"), X0(_.$$.fragment), y = Mn(), v = rt("button"), M = cn(C), k = Mn(), j && j.c(), P = Mn(), D = rt("select"), q.c(), Ke(n, "class", "record record-button svelte-wjm7x4"), Ke(a, "class", c = "stop-button " + /*record*/
      (i[0].isPaused() ? "stop-button-paused" : "") + " svelte-wjm7x4"), Ke(h, "id", "stop-paused"), Ke(h, "class", "stop-button-paused svelte-wjm7x4"), Ke(p, "class", "pause-button svelte-wjm7x4"), Ke(v, "class", "resume-button svelte-wjm7x4"), Ke(t, "class", "wrapper svelte-wjm7x4"), Ke(D, "class", "mic-select svelte-wjm7x4"), Ke(D, "aria-label", "Select input device"), D.disabled = b = /*micDevices*/
      i[5].length === 0, Ke(e, "class", "controls svelte-wjm7x4");
    },
    m(I, H) {
      ji(I, e, H), ge(e, t), ge(t, n), ge(n, r), i[11](n), ge(t, s), ge(t, a), ge(a, u), i[13](a), ge(t, d), ge(t, h), ge(h, m), i[15](h), ge(t, g), ge(t, p), $0(_, p, null), i[17](p), ge(t, y), ge(t, v), ge(v, M), i[19](v), ge(t, k), j && j.m(t, null), ge(e, P), ge(e, D), q.m(D, null), E = !0, U || (T = [
        ci(
          n,
          "click",
          /*click_handler*/
          i[12]
        ),
        ci(
          a,
          "click",
          /*click_handler_1*/
          i[14]
        ),
        ci(
          h,
          "click",
          /*click_handler_2*/
          i[16]
        ),
        ci(
          p,
          "click",
          /*click_handler_3*/
          i[18]
        ),
        ci(
          v,
          "click",
          /*click_handler_4*/
          i[20]
        )
      ], U = !0);
    },
    p(I, [H]) {
      (!E || H & /*i18n*/
      2) && o !== (o = /*i18n*/
      I[1]("audio.record") + "") && un(r, o), (!E || H & /*i18n*/
      2) && l !== (l = /*i18n*/
      I[1]("audio.stop") + "") && un(u, l), (!E || H & /*record*/
      1 && c !== (c = "stop-button " + /*record*/
      (I[0].isPaused() ? "stop-button-paused" : "") + " svelte-wjm7x4")) && Ke(a, "class", c), (!E || H & /*i18n*/
      2) && f !== (f = /*i18n*/
      I[1]("audio.stop") + "") && un(m, f), (!E || H & /*i18n*/
      2) && C !== (C = /*i18n*/
      I[1]("audio.resume") + "") && un(M, C), /*timing*/
      I[4] && !/*show_recording_waveform*/
      I[3] ? j ? j.p(I, H) : (j = jl(I), j.c(), j.m(t, null)) : j && (j.d(1), j = null), Q === (Q = V(I)) && q ? q.p(I, H) : (q.d(1), q = Q(I), q && (q.c(), q.m(D, null))), (!E || H & /*micDevices*/
      32 && b !== (b = /*micDevices*/
      I[5].length === 0)) && (D.disabled = b);
    },
    i(I) {
      E || (t1(_.$$.fragment, I), E = !0);
    },
    o(I) {
      n1(_.$$.fragment, I), E = !1;
    },
    d(I) {
      I && qi(e), i[11](null), i[13](null), i[15](null), J0(_), i[17](null), i[19](null), j && j.d(), q.d(), U = !1, x0(T);
    }
  };
}
function l1(i, e, t) {
  let { record: n } = e, { i18n: o } = e, r = [], s, a, l, u, c, { record_time: d } = e, { show_recording_waveform: h } = e, { timing: f = !1 } = e;
  const m = i1();
  function g(b) {
    ui[b ? "unshift" : "push"](() => {
      s = b, t(6, s), t(0, n);
    });
  }
  const p = () => n.startRecording();
  function _(b) {
    ui[b ? "unshift" : "push"](() => {
      u = b, t(9, u), t(0, n);
    });
  }
  const y = () => {
    n.isPaused() && (n.resumeRecording(), n.stopRecording()), n.stopRecording();
  };
  function v(b) {
    ui[b ? "unshift" : "push"](() => {
      c = b, t(10, c), t(0, n);
    });
  }
  const C = () => {
    n.isPaused() && (n.resumeRecording(), n.stopRecording()), n.stopRecording();
  };
  function M(b) {
    ui[b ? "unshift" : "push"](() => {
      a = b, t(7, a), t(0, n);
    });
  }
  const k = () => n.pauseRecording();
  function P(b) {
    ui[b ? "unshift" : "push"](() => {
      l = b, t(8, l), t(0, n);
    });
  }
  const D = () => n.resumeRecording();
  return i.$$set = (b) => {
    "record" in b && t(0, n = b.record), "i18n" in b && t(1, o = b.i18n), "record_time" in b && t(2, d = b.record_time), "show_recording_waveform" in b && t(3, h = b.show_recording_waveform), "timing" in b && t(4, f = b.timing);
  }, i.$$.update = () => {
    if (i.$$.dirty & /*micDevices, i18n*/
    34)
      try {
        let b = [];
        Ti.getAvailableAudioDevices().then((E) => {
          t(5, r = E), r.forEach((U) => {
            U.deviceId && b.push(U);
          }), t(5, r = b);
        });
      } catch (b) {
        throw b instanceof DOMException && b.name == "NotAllowedError" && m("error", o("audio.allow_recording_access")), b;
      }
    i.$$.dirty & /*record*/
    1 && n.on("record-start", () => {
      n.startMic(), t(6, s.style.display = "none", s), t(9, u.style.display = "flex", u), t(7, a.style.display = "block", a);
    }), i.$$.dirty & /*record*/
    1 && n.on("record-end", () => {
      n.isPaused() && (n.resumeRecording(), n.stopRecording()), n.stopMic(), t(6, s.style.display = "flex", s), t(9, u.style.display = "none", u), t(7, a.style.display = "none", a), t(6, s.disabled = !1, s);
    }), i.$$.dirty & /*record*/
    1 && n.on("record-pause", () => {
      t(7, a.style.display = "none", a), t(8, l.style.display = "block", l), t(9, u.style.display = "none", u), t(10, c.style.display = "flex", c);
    }), i.$$.dirty & /*record*/
    1 && n.on("record-resume", () => {
      t(7, a.style.display = "block", a), t(8, l.style.display = "none", l), t(6, s.style.display = "none", s), t(9, u.style.display = "flex", u), t(10, c.style.display = "none", c);
    });
  }, [
    n,
    o,
    d,
    h,
    f,
    r,
    s,
    a,
    l,
    u,
    c,
    g,
    p,
    _,
    y,
    v,
    C,
    M,
    k,
    P,
    D
  ];
}
class a1 extends Z0 {
  constructor(e) {
    super(), Q0(this, e, l1, r1, e1, {
      record: 0,
      i18n: 1,
      record_time: 2,
      show_recording_waveform: 3,
      timing: 4
    });
  }
}
const {
  SvelteComponent: u1,
  add_flush_callback: Pu,
  append: ut,
  attr: Ot,
  bind: Wu,
  binding_callbacks: Tn,
  check_outros: zl,
  create_component: Au,
  destroy_component: Tu,
  detach: Ni,
  element: Wt,
  group_outros: Bl,
  init: c1,
  insert: zi,
  mount_component: qu,
  noop: ju,
  safe_not_equal: d1,
  set_data: f1,
  space: qn,
  text: h1,
  transition_in: Ft,
  transition_out: jn
} = window.__gradio__svelte__internal, { onMount: m1 } = window.__gradio__svelte__internal, { createEventDispatcher: p1 } = window.__gradio__svelte__internal;
function Il(i) {
  let e, t, n, o, r, s = (
    /*mode*/
    i[0] === "edit" && Ks > 0 && Ul()
  );
  function a(c, d) {
    return (
      /*timing*/
      c[13] ? g1 : _1
    );
  }
  let l = a(i), u = l(i);
  return {
    c() {
      e = Wt("div"), t = Wt("time"), t.textContent = "0:00", n = qn(), o = Wt("div"), s && s.c(), r = qn(), u.c(), Ot(t, "class", "time svelte-1z0uz8p"), Ot(e, "class", "timestamps svelte-1z0uz8p");
    },
    m(c, d) {
      zi(c, e, d), ut(e, t), i[19](t), ut(e, n), ut(e, o), s && s.m(o, null), ut(o, r), u.m(o, null);
    },
    p(c, d) {
      /*mode*/
      c[0] === "edit" && Ks > 0 ? s ? s.p(c, d) : (s = Ul(), s.c(), s.m(o, r)) : s && (s.d(1), s = null), l === (l = a(c)) && u ? u.p(c, d) : (u.d(1), u = l(c), u && (u.c(), u.m(o, null)));
    },
    d(c) {
      c && Ni(e), i[19](null), s && s.d(), u.d();
    }
  };
}
function Ul(i) {
  let e;
  return {
    c() {
      e = Wt("time"), e.textContent = `${hn(Ks)}`, Ot(e, "class", "trim-duration svelte-1z0uz8p");
    },
    m(t, n) {
      zi(t, e, n);
    },
    p: ju,
    d(t) {
      t && Ni(e);
    }
  };
}
function _1(i) {
  let e;
  return {
    c() {
      e = Wt("time"), e.textContent = "0:00", Ot(e, "class", "duration svelte-1z0uz8p");
    },
    m(t, n) {
      zi(t, e, n), i[20](e);
    },
    p: ju,
    d(t) {
      t && Ni(e), i[20](null);
    }
  };
}
function g1(i) {
  let e, t = hn(
    /*seconds*/
    i[12]
  ) + "", n;
  return {
    c() {
      e = Wt("time"), n = h1(t), Ot(e, "class", "duration svelte-1z0uz8p");
    },
    m(o, r) {
      zi(o, e, r), ut(e, n);
    },
    p(o, r) {
      r & /*seconds*/
      4096 && t !== (t = hn(
        /*seconds*/
        o[12]
      ) + "") && f1(n, t);
    },
    d(o) {
      o && Ni(e);
    }
  };
}
function Fl(i) {
  let e, t, n;
  function o(s) {
    i[21](s);
  }
  let r = {
    i18n: (
      /*i18n*/
      i[1]
    ),
    timing: (
      /*timing*/
      i[13]
    ),
    show_recording_waveform: (
      /*waveform_options*/
      i[2].show_recording_waveform
    ),
    record_time: hn(
      /*seconds*/
      i[12]
    )
  };
  return (
    /*record*/
    i[6] !== void 0 && (r.record = /*record*/
    i[6]), e = new a1({ props: r }), Tn.push(() => Wu(e, "record", o)), {
      c() {
        Au(e.$$.fragment);
      },
      m(s, a) {
        qu(e, s, a), n = !0;
      },
      p(s, a) {
        const l = {};
        a & /*i18n*/
        2 && (l.i18n = /*i18n*/
        s[1]), a & /*timing*/
        8192 && (l.timing = /*timing*/
        s[13]), a & /*waveform_options*/
        4 && (l.show_recording_waveform = /*waveform_options*/
        s[2].show_recording_waveform), a & /*seconds*/
        4096 && (l.record_time = hn(
          /*seconds*/
          s[12]
        )), !t && a & /*record*/
        64 && (t = !0, l.record = /*record*/
        s[6], Pu(() => t = !1)), e.$set(l);
      },
      i(s) {
        n || (Ft(e.$$.fragment, s), n = !0);
      },
      o(s) {
        jn(e.$$.fragment, s), n = !1;
      },
      d(s) {
        Tu(e, s);
      }
    }
  );
}
function Gl(i) {
  let e, t, n;
  function o(s) {
    i[22](s);
  }
  let r = {
    playing: (
      /*playing*/
      i[10]
    ),
    audio_duration: (
      /*audio_duration*/
      i[11]
    ),
    i18n: (
      /*i18n*/
      i[1]
    ),
    waveform_options: (
      /*waveform_options*/
      i[2]
    )
  };
  return (
    /*recordingWaveform*/
    i[3] !== void 0 && (r.waveform = /*recordingWaveform*/
    i[3]), e = new Ua({ props: r }), Tn.push(() => Wu(e, "waveform", o)), {
      c() {
        Au(e.$$.fragment);
      },
      m(s, a) {
        qu(e, s, a), n = !0;
      },
      p(s, a) {
        const l = {};
        a & /*playing*/
        1024 && (l.playing = /*playing*/
        s[10]), a & /*audio_duration*/
        2048 && (l.audio_duration = /*audio_duration*/
        s[11]), a & /*i18n*/
        2 && (l.i18n = /*i18n*/
        s[1]), a & /*waveform_options*/
        4 && (l.waveform_options = /*waveform_options*/
        s[2]), !t && a & /*recordingWaveform*/
        8 && (t = !0, l.waveform = /*recordingWaveform*/
        s[3], Pu(() => t = !1)), e.$set(l);
      },
      i(s) {
        n || (Ft(e.$$.fragment, s), n = !0);
      },
      o(s) {
        jn(e.$$.fragment, s), n = !1;
      },
      d(s) {
        Tu(e, s);
      }
    }
  );
}
function v1(i) {
  let e, t, n, o, r, s, a, l, u = (
    /*timing*/
    (i[13] || /*recordedAudio*/
    i[7]) && /*waveform_options*/
    i[2].show_recording_waveform && Il(i)
  ), c = (
    /*microphoneContainer*/
    i[5] && !/*recordedAudio*/
    i[7] && Fl(i)
  ), d = (
    /*recordingWaveform*/
    i[3] && /*recordedAudio*/
    i[7] && Gl(i)
  );
  return {
    c() {
      e = Wt("div"), t = Wt("div"), n = qn(), o = Wt("div"), r = qn(), u && u.c(), s = qn(), c && c.c(), a = qn(), d && d.c(), Ot(t, "class", "microphone svelte-1z0uz8p"), Ot(t, "data-testid", "microphone-waveform"), Ot(o, "data-testid", "recording-waveform"), Ot(e, "class", "component-wrapper svelte-1z0uz8p");
    },
    m(h, f) {
      zi(h, e, f), ut(e, t), i[17](t), ut(e, n), ut(e, o), i[18](o), ut(e, r), u && u.m(e, null), ut(e, s), c && c.m(e, null), ut(e, a), d && d.m(e, null), l = !0;
    },
    p(h, [f]) {
      /*timing*/
      (h[13] || /*recordedAudio*/
      h[7]) && /*waveform_options*/
      h[2].show_recording_waveform ? u ? u.p(h, f) : (u = Il(h), u.c(), u.m(e, s)) : u && (u.d(1), u = null), /*microphoneContainer*/
      h[5] && !/*recordedAudio*/
      h[7] ? c ? (c.p(h, f), f & /*microphoneContainer, recordedAudio*/
      160 && Ft(c, 1)) : (c = Fl(h), c.c(), Ft(c, 1), c.m(e, a)) : c && (Bl(), jn(c, 1, 1, () => {
        c = null;
      }), zl()), /*recordingWaveform*/
      h[3] && /*recordedAudio*/
      h[7] ? d ? (d.p(h, f), f & /*recordingWaveform, recordedAudio*/
      136 && Ft(d, 1)) : (d = Gl(h), d.c(), Ft(d, 1), d.m(e, null)) : d && (Bl(), jn(d, 1, 1, () => {
        d = null;
      }), zl());
    },
    i(h) {
      l || (Ft(c), Ft(d), l = !0);
    },
    o(h) {
      jn(c), jn(d), l = !1;
    },
    d(h) {
      h && Ni(e), i[17](null), i[18](null), u && u.d(), c && c.d(), d && d.d();
    }
  };
}
let Ks = 0;
function b1(i, e, t) {
  var n = this && this.__awaiter || function(q, I, H, G) {
    function F(K) {
      return K instanceof H ? K : new H(function(x) {
        x(K);
      });
    }
    return new (H || (H = Promise))(function(K, x) {
      function A(z) {
        try {
          W(G.next(z));
        } catch (O) {
          x(O);
        }
      }
      function S(z) {
        try {
          W(G.throw(z));
        } catch (O) {
          x(O);
        }
      }
      function W(z) {
        z.done ? K(z.value) : F(z.value).then(A, S);
      }
      W((G = G.apply(q, I || [])).next());
    });
  };
  let { mode: o } = e, { i18n: r } = e, { dispatch_blob: s } = e, { waveform_settings: a } = e, { waveform_options: l = { show_recording_waveform: !0 } } = e, u, c, d = !1, h, f, m, g = null, p, _, y, v = 0, C, M = !1;
  const k = () => {
    clearInterval(C), t(16, C = setInterval(
      () => {
        t(12, v++, v);
      },
      1e3
    ));
  }, P = p1(), D = () => {
    f && t(5, f.innerHTML = "", f), u !== void 0 && u.destroy(), f && (u = Fn.create(Object.assign(Object.assign({}, a), {
      normalize: !1,
      container: f
    })), t(6, m = u.registerPlugin(Ti.create())), m.startMic());
  }, b = () => {
    let q = h;
    !g || !q || t(3, c = Fn.create(Object.assign({ container: q, url: g }, a)));
  };
  m1(() => {
    D(), window.addEventListener("keydown", (q) => {
      q.key === "ArrowRight" ? Gr(c, 0.1) : q.key === "ArrowLeft" && Gr(c, -0.1);
    });
  });
  function E(q) {
    Tn[q ? "unshift" : "push"](() => {
      f = q, t(5, f);
    });
  }
  function U(q) {
    Tn[q ? "unshift" : "push"](() => {
      h = q, t(4, h);
    });
  }
  function T(q) {
    Tn[q ? "unshift" : "push"](() => {
      p = q, t(8, p), t(3, c);
    });
  }
  function j(q) {
    Tn[q ? "unshift" : "push"](() => {
      _ = q, t(9, _), t(3, c);
    });
  }
  function V(q) {
    m = q, t(6, m);
  }
  function Q(q) {
    c = q, t(3, c);
  }
  return i.$$set = (q) => {
    "mode" in q && t(0, o = q.mode), "i18n" in q && t(1, r = q.i18n), "dispatch_blob" in q && t(14, s = q.dispatch_blob), "waveform_settings" in q && t(15, a = q.waveform_settings), "waveform_options" in q && t(2, l = q.waveform_options);
  }, i.$$.update = () => {
    i.$$.dirty & /*record, waveform_options, microphoneContainer*/
    100 && (m == null || m.on("record-start", () => {
      if (k(), t(13, M = !0), P("start_recording"), l.show_recording_waveform) {
        let q = f;
        q && (q.style.display = "block");
      }
    })), i.$$.dirty & /*record, interval, waveform_settings, dispatch_blob*/
    114752 && (m == null || m.on("record-end", (q) => n(void 0, void 0, void 0, function* () {
      t(12, v = 0), t(13, M = !1), clearInterval(C);
      try {
        const I = yield q.arrayBuffer(), G = yield new AudioContext({ sampleRate: a.sampleRate }).decodeAudioData(I);
        G && (yield lm(G).then((F) => n(void 0, void 0, void 0, function* () {
          yield s([F], "change"), yield s([F], "stop_recording");
        })));
      } catch (I) {
        console.error(I);
      }
    }))), i.$$.dirty & /*record, interval*/
    65600 && (m == null || m.on("record-pause", () => {
      P("pause_recording"), clearInterval(C);
    })), i.$$.dirty & /*record*/
    64 && (m == null || m.on("record-resume", () => {
      k();
    })), i.$$.dirty & /*recordingWaveform, durationRef*/
    520 && (c == null || c.on("decode", (q) => {
      t(11, y = q), _ && t(9, _.textContent = hn(q), _);
    })), i.$$.dirty & /*recordingWaveform, timeRef*/
    264 && (c == null || c.on("timeupdate", (q) => p && t(8, p.textContent = hn(q), p))), i.$$.dirty & /*recordingWaveform*/
    8 && (c == null || c.on("pause", () => {
      P("pause"), t(10, d = !1);
    })), i.$$.dirty & /*recordingWaveform*/
    8 && (c == null || c.on("play", () => {
      P("play"), t(10, d = !0);
    })), i.$$.dirty & /*recordingWaveform*/
    8 && (c == null || c.on("finish", () => {
      P("stop"), t(10, d = !1);
    })), i.$$.dirty & /*record, microphoneContainer, recordingContainer, recordedAudio*/
    240 && (m == null || m.on("record-end", (q) => {
      t(7, g = URL.createObjectURL(q));
      const I = f, H = h;
      I && (I.style.display = "none"), H && g && (H.innerHTML = "", b());
    }));
  }, [
    o,
    r,
    l,
    c,
    h,
    f,
    m,
    g,
    p,
    _,
    d,
    y,
    v,
    M,
    s,
    a,
    C,
    E,
    U,
    T,
    j,
    V,
    Q
  ];
}
class w1 extends u1 {
  constructor(e) {
    super(), c1(this, e, b1, v1, d1, {
      mode: 0,
      i18n: 1,
      dispatch_blob: 14,
      waveform_settings: 15,
      waveform_options: 2
    });
  }
}
const {
  SvelteComponent: y1,
  append: fn,
  attr: In,
  binding_callbacks: k1,
  detach: Ro,
  element: Vn,
  init: C1,
  insert: Mo,
  listen: Nu,
  noop: Vl,
  null_to_empty: Hl,
  safe_not_equal: S1,
  set_data: zu,
  set_style: Zl,
  space: dr,
  text: Bu
} = window.__gradio__svelte__internal, { onMount: E1 } = window.__gradio__svelte__internal;
function Xl(i) {
  let e;
  return {
    c() {
      e = Vn("div"), Zl(
        e,
        "display",
        /*recording*/
        i[0] ? "block" : "none"
      );
    },
    m(t, n) {
      Mo(t, e, n), i[9](e);
    },
    p(t, n) {
      n & /*recording*/
      1 && Zl(
        e,
        "display",
        /*recording*/
        t[0] ? "block" : "none"
      );
    },
    d(t) {
      t && Ro(e), i[9](null);
    }
  };
}
function D1(i) {
  let e, t, n, o = (
    /*i18n*/
    i[4]("audio.record") + ""
  ), r, s, a;
  return {
    c() {
      e = Vn("button"), t = Vn("span"), t.innerHTML = '<span class="dot"></span>', n = dr(), r = Bu(o), In(t, "class", "record-icon"), In(e, "class", "record-button svelte-4ycsjo");
    },
    m(l, u) {
      Mo(l, e, u), fn(e, t), fn(e, n), fn(e, r), s || (a = Nu(
        e,
        "click",
        /*click_handler_1*/
        i[11]
      ), s = !0);
    },
    p(l, u) {
      u & /*i18n*/
      16 && o !== (o = /*i18n*/
      l[4]("audio.record") + "") && zu(r, o);
    },
    d(l) {
      l && Ro(e), s = !1, a();
    }
  };
}
function R1(i) {
  let e, t, n, o = (
    /*paused_recording*/
    (i[1] ? (
      /*i18n*/
      i[4]("audio.pause")
    ) : (
      /*i18n*/
      i[4]("audio.stop")
    )) + ""
  ), r, s, a, l;
  return {
    c() {
      e = Vn("button"), t = Vn("span"), t.innerHTML = '<span class="pinger"></span> <span class="dot"></span>', n = dr(), r = Bu(o), In(t, "class", "record-icon"), In(e, "class", s = Hl(
        /*paused_recording*/
        i[1] ? "stop-button-paused" : "stop-button"
      ) + " svelte-4ycsjo");
    },
    m(u, c) {
      Mo(u, e, c), fn(e, t), fn(e, n), fn(e, r), a || (l = Nu(
        e,
        "click",
        /*click_handler*/
        i[10]
      ), a = !0);
    },
    p(u, c) {
      c & /*paused_recording, i18n*/
      18 && o !== (o = /*paused_recording*/
      (u[1] ? (
        /*i18n*/
        u[4]("audio.pause")
      ) : (
        /*i18n*/
        u[4]("audio.stop")
      )) + "") && zu(r, o), c & /*paused_recording*/
      2 && s !== (s = Hl(
        /*paused_recording*/
        u[1] ? "stop-button-paused" : "stop-button"
      ) + " svelte-4ycsjo") && In(e, "class", s);
    },
    d(u) {
      u && Ro(e), a = !1, l();
    }
  };
}
function M1(i) {
  let e, t, n = (
    /*waveform_options*/
    i[5].show_recording_waveform && Xl(i)
  );
  function o(a, l) {
    return (
      /*recording*/
      a[0] ? R1 : D1
    );
  }
  let r = o(i), s = r(i);
  return {
    c() {
      e = Vn("div"), n && n.c(), t = dr(), s.c(), In(e, "class", "mic-wrap svelte-4ycsjo");
    },
    m(a, l) {
      Mo(a, e, l), n && n.m(e, null), fn(e, t), s.m(e, null);
    },
    p(a, [l]) {
      /*waveform_options*/
      a[5].show_recording_waveform ? n ? n.p(a, l) : (n = Xl(a), n.c(), n.m(e, t)) : n && (n.d(1), n = null), r === (r = o(a)) && s ? s.p(a, l) : (s.d(1), s = r(a), s && (s.c(), s.m(e, null)));
    },
    i: Vl,
    o: Vl,
    d(a) {
      a && Ro(e), n && n.d(), s.d();
    }
  };
}
function L1(i, e, t) {
  let { recording: n = !1 } = e, { paused_recording: o = !1 } = e, { stop: r } = e, { record: s } = e, { i18n: a } = e, { waveform_settings: l } = e, { waveform_options: u = { show_recording_waveform: !0 } } = e, c, d, h;
  E1(() => {
    f();
  });
  const f = () => {
    c !== void 0 && c.destroy(), h && (c = Fn.create(Object.assign(Object.assign({}, l), {
      height: 100,
      container: h
    })), t(6, d = c.registerPlugin(Ti.create())));
  };
  function m(_) {
    k1[_ ? "unshift" : "push"](() => {
      h = _, t(7, h);
    });
  }
  const g = () => {
    d == null || d.stopMic(), r();
  }, p = () => {
    d == null || d.startMic(), s();
  };
  return i.$$set = (_) => {
    "recording" in _ && t(0, n = _.recording), "paused_recording" in _ && t(1, o = _.paused_recording), "stop" in _ && t(2, r = _.stop), "record" in _ && t(3, s = _.record), "i18n" in _ && t(4, a = _.i18n), "waveform_settings" in _ && t(8, l = _.waveform_settings), "waveform_options" in _ && t(5, u = _.waveform_options);
  }, [
    n,
    o,
    r,
    s,
    a,
    u,
    d,
    h,
    l,
    m,
    g,
    p
  ];
}
class O1 extends y1 {
  constructor(e) {
    super(), C1(this, e, L1, M1, S1, {
      recording: 0,
      paused_recording: 1,
      stop: 2,
      record: 3,
      i18n: 4,
      waveform_settings: 8,
      waveform_options: 5
    });
  }
}
const {
  SvelteComponent: P1,
  append: Jl,
  attr: Be,
  detach: W1,
  init: A1,
  insert: T1,
  noop: gs,
  safe_not_equal: q1,
  svg_element: vs
} = window.__gradio__svelte__internal;
function j1(i) {
  let e, t, n;
  return {
    c() {
      e = vs("svg"), t = vs("path"), n = vs("path"), Be(t, "d", "M983.678752 314.585575c-25.849513-60.781287-62.777388-115.474464-109.785575-162.482651s-101.701365-83.936062-162.482651-109.785575C648.433528 15.569591 581.663938 1.996101 512.998051 1.996101c-68.665887 0-135.435478 13.573489-198.412476 40.321248-60.781287 25.849513-115.474464 62.777388-162.482651 109.785575s-83.936062 101.701365-109.785575 162.482651C15.569591 377.562573 1.996101 444.332164 1.996101 512.998051c0 68.665887 13.573489 135.435478 40.321248 198.412475 25.849513 60.781287 62.777388 115.474464 109.785575 162.482651s101.701365 83.936062 162.482651 109.785575c62.976998 26.747758 129.746589 40.321248 198.412476 40.321248 68.665887 0 135.435478-13.573489 198.412475-40.321248 60.781287-25.849513 115.474464-62.777388 162.482651-109.785575s83.936062-101.701365 109.785575-162.482651c26.747758-62.976998 40.321248-129.746589 40.321248-198.412475 0-68.665887-13.573489-135.435478-40.321248-198.412476zM673.684211 894.752437c-51.00039 21.6577-105.094737 32.636257-160.68616 32.636257s-109.68577-10.978558-160.68616-32.636257c-49.403509-21.058869-93.816764-51.100195-131.9423-89.125926-38.125536-38.125536-68.067057-82.438986-89.125926-131.9423-21.6577-51.00039-32.636257-105.094737-32.636258-160.68616s10.978558-109.68577 32.636258-160.68616c21.058869-49.403509 51.100195-93.816764 89.125926-131.9423 38.125536-38.125536 82.438986-68.067057 131.9423-89.125926 51.00039-21.6577 105.094737-32.636257 160.68616-32.636258s109.68577 10.978558 160.68616 32.636258c49.403509 21.058869 93.816764 51.100195 131.9423 89.125926 38.125536 38.125536 68.067057 82.438986 89.125926 131.9423 21.6577 51.00039 32.636257 105.094737 32.636257 160.68616s-10.978558 109.68577-32.636257 160.68616c-21.058869 49.403509-51.100195 93.816764-89.125926 131.9423-38.125536 38.025731-82.538791 68.067057-131.9423 89.125926z"), Be(n, "d", "M476.868616 808.820273h74.554386c8.283821 0 14.97076-6.68694 14.97076-14.97076v-68.366472c0-8.283821-6.68694-14.97076-14.97076-14.97076h-74.554386c-8.283821 0-14.97076 6.68694-14.97076 14.97076v68.366472c0 8.283821 6.68694 14.97076 14.97076 14.97076zM687.557115 373.270955c-3.293567-51.299805-19.262378-90.922417-47.307602-117.869785-28.045224-26.947368-68.266667-41.119688-119.566472-42.217544h-0.998051c-58.585575 2.195712-104.096686 19.461988-135.235867 51.100195-31.039376 31.638207-47.906433 77.847953-50.102144 137.331774-0.299415 8.483431 6.487329 15.469786 14.97076 15.469785h65.272514c8.084211 0 14.77115-6.487329 14.970761-14.57154 1.896296-72.558285 30.440546-107.490058 90.024171-109.68577h1.297466c48.904483 2.095906 73.65614 26.947368 77.548538 77.947758 0 0.499025 0.099805 1.097856 0 1.596882-0.59883 26.548148-19.961014 59.0846-57.687329 96.810916-51.100195 48.904483-75.951657 93.118129-75.951657 135.036257v55.990643c0 8.283821 6.68694 14.97076 14.97076 14.970761h68.366472c8.283821 0 14.97076-6.68694 14.97076-14.970761v-65.272514c0-11.377778 7.8846-32.736062 45.211696-70.162963 52.497466-50.301754 79.145419-101.002729 79.145419-150.605848l0.099805-0.898246z"), Be(e, "class", "svg-icon"), Be(e, "width", "100%"), Be(e, "height", "100%"), Be(e, "fill", "currentColor"), Be(e, "stroke", "currentColor"), Be(e, "stroke-width", "2"), Be(e, "stroke-linecap", "round"), Be(e, "stroke-linejoin", "round"), Be(e, "viewBox", "0 0 1028 1024"), Be(e, "version", "1.1"), Be(e, "xmlns", "http://www.w3.org/2000/svg");
    },
    m(o, r) {
      T1(o, e, r), Jl(e, t), Jl(e, n);
    },
    p: gs,
    i: gs,
    o: gs,
    d(o) {
      o && W1(e);
    }
  };
}
class N1 extends P1 {
  constructor(e) {
    super(), A1(this, e, null, j1, q1, {});
  }
}
const {
  SvelteComponent: z1,
  append: Et,
  attr: Dt,
  binding_callbacks: B1,
  detach: I1,
  element: Ln,
  init: U1,
  insert: F1,
  listen: G1,
  noop: bs,
  safe_not_equal: V1,
  space: Qi,
  src_url_equal: H1
} = window.__gradio__svelte__internal, { onMount: Z1 } = window.__gradio__svelte__internal;
function X1(i) {
  let e, t, n, o, r, s, a, l, u, c, d, h, f;
  return {
    c() {
      e = Ln("dialog"), t = Ln("p"), t.innerHTML = `Do you have a problem or a suggestion about this component?
        Feel free to open an issue on the <a href="https://github.com/clement-pages/gryannote/issues/new" target="_blank" class="svelte-m6f5sx">gryannote github directory</a>!`, n = Qi(), o = Ln("p"), o.textContent = "Component's keyboard shortcuts:", r = Qi(), s = Ln("img"), l = Qi(), u = Ln("p"), u.innerHTML = 'You can also use a gamepad to speed up your annotation process! Go <a href="https://github.com/clement-pages/gryannote/tree/main/gryannote/audio#gamepad-shortcuts" class="svelte-m6f5sx">here</a> for further details.', c = Qi(), d = Ln("button"), d.textContent = "Close", Dt(t, "class", "svelte-m6f5sx"), Dt(o, "class", "svelte-m6f5sx"), H1(s.src, a = "https://github.com/clement-pages/gryannote/blob/main/docs/assets/shortcuts.png?raw=true") || Dt(s, "src", a), Dt(s, "alt", "component keyboard shortcut"), Dt(u, "class", "svelte-m6f5sx"), Dt(d, "id", "close"), Dt(d, "class", "svelte-m6f5sx"), Dt(e, "id", "help-dialog-box"), e.hidden = !0, Dt(e, "class", "svelte-m6f5sx");
    },
    m(m, g) {
      F1(m, e, g), Et(e, t), Et(e, n), Et(e, o), Et(e, r), Et(e, s), Et(e, l), Et(e, u), Et(e, c), Et(e, d), i[5](e), h || (f = G1(
        d,
        "click",
        /*click_handler*/
        i[4]
      ), h = !0);
    },
    p: bs,
    i: bs,
    o: bs,
    d(m) {
      m && I1(e), i[5](null), h = !1, f();
    }
  };
}
function J1(i, e, t) {
  let { isOpen: n = !1 } = e, o;
  function r() {
    o.showModal(), document.getElementById("help-dialog-box").hidden = !1, t(2, n = !0);
  }
  function s() {
    o.close(), document.getElementById("help-dialog-box").hidden = !0, t(2, n = !1);
  }
  Z1(() => {
    window.addEventListener("keydown", (u) => {
      if (n)
        switch (u.key) {
          case "Escape":
            s();
            break;
        }
    });
  });
  const a = () => s();
  function l(u) {
    B1[u ? "unshift" : "push"](() => {
      o = u, t(0, o);
    });
  }
  return i.$$set = (u) => {
    "isOpen" in u && t(2, n = u.isOpen);
  }, [o, s, n, r, a, l];
}
class K1 extends z1 {
  constructor(e) {
    super(), U1(this, e, J1, X1, V1, { isOpen: 2, openDialog: 3 });
  }
  get openDialog() {
    return this.$$.ctx[3];
  }
}
const {
  SvelteComponent: Y1,
  add_flush_callback: Hn,
  append: di,
  attr: Rt,
  bind: Zn,
  binding_callbacks: gn,
  bubble: ws,
  check_outros: fr,
  create_component: gt,
  create_slot: Q1,
  destroy_component: vt,
  detach: Xt,
  element: $i,
  empty: Iu,
  get_all_dirty_from_scope: $1,
  get_slot_changes: x1,
  group_outros: hr,
  init: eg,
  insert: Jt,
  listen: tg,
  mount_component: bt,
  safe_not_equal: ng,
  space: rn,
  transition_in: De,
  transition_out: Re,
  update_slot_base: ig
} = window.__gradio__svelte__internal, { getContext: og, onDestroy: sg, createEventDispatcher: rg } = window.__gradio__svelte__internal;
function lg(i) {
  let e, t, n, o, r, s;
  e = new Lu({
    props: {
      i18n: (
        /*i18n*/
        i[9]
      ),
      download: (
        /*show_download_button*/
        i[6] ? (
          /*value*/
          i[1].file_data.url
        ) : null
      ),
      absolute: !0
    }
  }), e.$on(
    "clear",
    /*clear*/
    i[20]
  ), e.$on(
    "edit",
    /*edit_handler*/
    i[31]
  );
  function a(c) {
    i[32](c);
  }
  function l(c) {
    i[33](c);
  }
  let u = {
    value: (
      /*value*/
      i[1]
    ),
    label: (
      /*label*/
      i[3]
    ),
    i18n: (
      /*i18n*/
      i[9]
    ),
    show_minimap: (
      /*show_minimap*/
      i[10]
    ),
    waveform_settings: (
      /*waveform_settings*/
      i[11]
    ),
    waveform_options: (
      /*waveform_options*/
      i[12]
    ),
    interactive: !0
  };
  return (
    /*mode*/
    i[14] !== void 0 && (u.mode = /*mode*/
    i[14]), /*isDialogOpen*/
    i[15] !== void 0 && (u.isDialogOpen = /*isDialogOpen*/
    i[15]), n = new au({ props: u }), gn.push(() => Zn(n, "mode", a)), gn.push(() => Zn(n, "isDialogOpen", l)), n.$on(
      "stop",
      /*stop_handler*/
      i[34]
    ), n.$on(
      "play",
      /*play_handler*/
      i[35]
    ), n.$on(
      "pause",
      /*pause_handler*/
      i[36]
    ), n.$on(
      "edit",
      /*edit_handler_1*/
      i[37]
    ), {
      c() {
        gt(e.$$.fragment), t = rn(), gt(n.$$.fragment);
      },
      m(c, d) {
        bt(e, c, d), Jt(c, t, d), bt(n, c, d), s = !0;
      },
      p(c, d) {
        const h = {};
        d[0] & /*i18n*/
        512 && (h.i18n = /*i18n*/
        c[9]), d[0] & /*show_download_button, value*/
        66 && (h.download = /*show_download_button*/
        c[6] ? (
          /*value*/
          c[1].file_data.url
        ) : null), e.$set(h);
        const f = {};
        d[0] & /*value*/
        2 && (f.value = /*value*/
        c[1]), d[0] & /*label*/
        8 && (f.label = /*label*/
        c[3]), d[0] & /*i18n*/
        512 && (f.i18n = /*i18n*/
        c[9]), d[0] & /*show_minimap*/
        1024 && (f.show_minimap = /*show_minimap*/
        c[10]), d[0] & /*waveform_settings*/
        2048 && (f.waveform_settings = /*waveform_settings*/
        c[11]), d[0] & /*waveform_options*/
        4096 && (f.waveform_options = /*waveform_options*/
        c[12]), !o && d[0] & /*mode*/
        16384 && (o = !0, f.mode = /*mode*/
        c[14], Hn(() => o = !1)), !r && d[0] & /*isDialogOpen*/
        32768 && (r = !0, f.isDialogOpen = /*isDialogOpen*/
        c[15], Hn(() => r = !1)), n.$set(f);
      },
      i(c) {
        s || (De(e.$$.fragment, c), De(n.$$.fragment, c), s = !0);
      },
      o(c) {
        Re(e.$$.fragment, c), Re(n.$$.fragment, c), s = !1;
      },
      d(c) {
        c && Xt(t), vt(e, c), vt(n, c);
      }
    }
  );
}
function ag(i) {
  let e, t, n, o;
  const r = [cg, ug], s = [];
  function a(l, u) {
    return (
      /*active_source*/
      l[2] === "microphone" ? 0 : (
        /*active_source*/
        l[2] === "upload" ? 1 : -1
      )
    );
  }
  return ~(e = a(i)) && (t = s[e] = r[e](i)), {
    c() {
      t && t.c(), n = Iu();
    },
    m(l, u) {
      ~e && s[e].m(l, u), Jt(l, n, u), o = !0;
    },
    p(l, u) {
      let c = e;
      e = a(l), e === c ? ~e && s[e].p(l, u) : (t && (hr(), Re(s[c], 1, 1, () => {
        s[c] = null;
      }), fr()), ~e ? (t = s[e], t ? t.p(l, u) : (t = s[e] = r[e](l), t.c()), De(t, 1), t.m(n.parentNode, n)) : t = null);
    },
    i(l) {
      o || (De(t), o = !0);
    },
    o(l) {
      Re(t), o = !1;
    },
    d(l) {
      l && Xt(n), ~e && s[e].d(l);
    }
  };
}
function ug(i) {
  let e, t, n;
  function o(s) {
    i[29](s);
  }
  let r = {
    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*/
      i[4]
    ),
    $$slots: { default: [dg] },
    $$scope: { ctx: i }
  };
  return (
    /*dragging*/
    i[0] !== void 0 && (r.dragging = /*dragging*/
    i[0]), e = new P0({ props: r }), gn.push(() => Zn(e, "dragging", o)), e.$on(
      "load",
      /*handle_load*/
      i[21]
    ), e.$on(
      "error",
      /*error_handler*/
      i[30]
    ), {
      c() {
        gt(e.$$.fragment);
      },
      m(s, a) {
        bt(e, s, a), n = !0;
      },
      p(s, a) {
        const l = {};
        a[0] & /*root*/
        16 && (l.root = /*root*/
        s[4]), a[1] & /*$$scope*/
        2048 && (l.$$scope = { dirty: a, ctx: s }), !t && a[0] & /*dragging*/
        1 && (t = !0, l.dragging = /*dragging*/
        s[0], Hn(() => t = !1)), e.$set(l);
      },
      i(s) {
        n || (De(e.$$.fragment, s), n = !0);
      },
      o(s) {
        Re(e.$$.fragment, s), n = !1;
      },
      d(s) {
        vt(e, s);
      }
    }
  );
}
function cg(i) {
  let e, t, n, o, r, s;
  e = new Lu({
    props: { i18n: (
      /*i18n*/
      i[9]
    ), absolute: !0 }
  }), e.$on(
    "clear",
    /*clear*/
    i[20]
  );
  const a = [hg, fg], l = [];
  function u(c, d) {
    return (
      /*streaming*/
      c[8] ? 0 : 1
    );
  }
  return n = u(i), o = l[n] = a[n](i), {
    c() {
      gt(e.$$.fragment), t = rn(), o.c(), r = Iu();
    },
    m(c, d) {
      bt(e, c, d), Jt(c, t, d), l[n].m(c, d), Jt(c, r, d), s = !0;
    },
    p(c, d) {
      const h = {};
      d[0] & /*i18n*/
      512 && (h.i18n = /*i18n*/
      c[9]), e.$set(h);
      let f = n;
      n = u(c), n === f ? l[n].p(c, d) : (hr(), Re(l[f], 1, 1, () => {
        l[f] = null;
      }), fr(), o = l[n], o ? o.p(c, d) : (o = l[n] = a[n](c), o.c()), De(o, 1), o.m(r.parentNode, r));
    },
    i(c) {
      s || (De(e.$$.fragment, c), De(o), s = !0);
    },
    o(c) {
      Re(e.$$.fragment, c), Re(o), s = !1;
    },
    d(c) {
      c && (Xt(t), Xt(r)), vt(e, c), l[n].d(c);
    }
  };
}
function dg(i) {
  let e;
  const t = (
    /*#slots*/
    i[27].default
  ), n = Q1(
    t,
    i,
    /*$$scope*/
    i[42],
    null
  );
  return {
    c() {
      n && n.c();
    },
    m(o, r) {
      n && n.m(o, r), e = !0;
    },
    p(o, r) {
      n && n.p && (!e || r[1] & /*$$scope*/
      2048) && ig(
        n,
        t,
        o,
        /*$$scope*/
        o[42],
        e ? x1(
          t,
          /*$$scope*/
          o[42],
          r,
          null
        ) : $1(
          /*$$scope*/
          o[42]
        ),
        null
      );
    },
    i(o) {
      e || (De(n, o), e = !0);
    },
    o(o) {
      Re(n, o), e = !1;
    },
    d(o) {
      n && n.d(o);
    }
  };
}
function fg(i) {
  let e, t, n;
  function o(s) {
    i[28](s);
  }
  let r = {
    i18n: (
      /*i18n*/
      i[9]
    ),
    dispatch_blob: (
      /*dispatch_blob*/
      i[18]
    ),
    waveform_settings: (
      /*waveform_settings*/
      i[11]
    ),
    waveform_options: (
      /*waveform_options*/
      i[12]
    )
  };
  return (
    /*mode*/
    i[14] !== void 0 && (r.mode = /*mode*/
    i[14]), e = new w1({ props: r }), gn.push(() => Zn(e, "mode", o)), {
      c() {
        gt(e.$$.fragment);
      },
      m(s, a) {
        bt(e, s, a), n = !0;
      },
      p(s, a) {
        const l = {};
        a[0] & /*i18n*/
        512 && (l.i18n = /*i18n*/
        s[9]), a[0] & /*waveform_settings*/
        2048 && (l.waveform_settings = /*waveform_settings*/
        s[11]), a[0] & /*waveform_options*/
        4096 && (l.waveform_options = /*waveform_options*/
        s[12]), !t && a[0] & /*mode*/
        16384 && (t = !0, l.mode = /*mode*/
        s[14], Hn(() => t = !1)), e.$set(l);
      },
      i(s) {
        n || (De(e.$$.fragment, s), n = !0);
      },
      o(s) {
        Re(e.$$.fragment, s), n = !1;
      },
      d(s) {
        vt(e, s);
      }
    }
  );
}
function hg(i) {
  let e, t;
  return e = new O1({
    props: {
      record: (
        /*record*/
        i[19]
      ),
      recording: (
        /*recording*/
        i[13]
      ),
      stop: (
        /*stop*/
        i[22]
      ),
      i18n: (
        /*i18n*/
        i[9]
      ),
      waveform_settings: (
        /*waveform_settings*/
        i[11]
      ),
      waveform_options: (
        /*waveform_options*/
        i[12]
      )
    }
  }), {
    c() {
      gt(e.$$.fragment);
    },
    m(n, o) {
      bt(e, n, o), t = !0;
    },
    p(n, o) {
      const r = {};
      o[0] & /*recording*/
      8192 && (r.recording = /*recording*/
      n[13]), o[0] & /*i18n*/
      512 && (r.i18n = /*i18n*/
      n[9]), o[0] & /*waveform_settings*/
      2048 && (r.waveform_settings = /*waveform_settings*/
      n[11]), o[0] & /*waveform_options*/
      4096 && (r.waveform_options = /*waveform_options*/
      n[12]), e.$set(r);
    },
    i(n) {
      t || (De(e.$$.fragment, n), t = !0);
    },
    o(n) {
      Re(e.$$.fragment, n), t = !1;
    },
    d(n) {
      vt(e, n);
    }
  };
}
function mg(i) {
  let e, t, n, o, r, s, a, l, u, c, d, h, f, m, g, p, _, y, v, C;
  e = new ya({
    props: {
      show_label: (
        /*show_label*/
        i[5]
      ),
      Icon: go,
      float: (
        /*active_source*/
        i[2] === "upload" && /*value*/
        i[1] === null
      ),
      label: (
        /*label*/
        i[3] || /*i18n*/
        i[9]("audio.audio")
      )
    }
  });
  const M = [ag, lg], k = [];
  function P(T, j) {
    return (
      /*value*/
      T[1] === null || /*streaming*/
      T[8] ? 0 : 1
    );
  }
  n = P(i), o = k[n] = M[n](i);
  function D(T) {
    i[38](T);
  }
  let b = {
    sources: (
      /*sources*/
      i[7]
    ),
    handle_clear: (
      /*clear*/
      i[20]
    )
  };
  /*active_source*/
  i[2] !== void 0 && (b.active_source = /*active_source*/
  i[2]), c = new Nh({ props: b }), gn.push(() => Zn(c, "active_source", D)), m = new N1({});
  function E(T) {
    i[41](T);
  }
  let U = {};
  return (
    /*isDialogOpen*/
    i[15] !== void 0 && (U.isOpen = /*isDialogOpen*/
    i[15]), p = new K1({ props: U }), i[40](p), gn.push(() => Zn(p, "isOpen", E)), {
      c() {
        gt(e.$$.fragment), t = rn(), o.c(), r = rn(), s = $i("div"), a = $i("a"), a.innerHTML = '<img src="https://github.com/clement-pages/gryannote/blob/main/docs/assets/logo-gryannote.png?raw=true" alt=" " id="logo" class="svelte-10l5pns"/> <p>provided by gryannote</p>', l = rn(), u = $i("div"), gt(c.$$.fragment), h = rn(), f = $i("button"), gt(m.$$.fragment), g = rn(), gt(p.$$.fragment), Rt(a, "href", "https://github.com/clement-pages/gryannote"), Rt(a, "id", "logo-link"), Rt(a, "class", "svelte-10l5pns"), Rt(u, "id", "select-source"), Rt(u, "class", "svelte-10l5pns"), Rt(f, "id", "help-button"), Rt(f, "title", "help"), Rt(f, "class", "svelte-10l5pns"), Rt(s, "class", "button-zone svelte-10l5pns");
      },
      m(T, j) {
        bt(e, T, j), Jt(T, t, j), k[n].m(T, j), Jt(T, r, j), Jt(T, s, j), di(s, a), di(s, l), di(s, u), bt(c, u, null), di(s, h), di(s, f), bt(m, f, null), Jt(T, g, j), bt(p, T, j), y = !0, v || (C = tg(
          f,
          "click",
          /*click_handler*/
          i[39]
        ), v = !0);
      },
      p(T, j) {
        const V = {};
        j[0] & /*show_label*/
        32 && (V.show_label = /*show_label*/
        T[5]), j[0] & /*active_source, value*/
        6 && (V.float = /*active_source*/
        T[2] === "upload" && /*value*/
        T[1] === null), j[0] & /*label, i18n*/
        520 && (V.label = /*label*/
        T[3] || /*i18n*/
        T[9]("audio.audio")), e.$set(V);
        let Q = n;
        n = P(T), n === Q ? k[n].p(T, j) : (hr(), Re(k[Q], 1, 1, () => {
          k[Q] = null;
        }), fr(), o = k[n], o ? o.p(T, j) : (o = k[n] = M[n](T), o.c()), De(o, 1), o.m(r.parentNode, r));
        const q = {};
        j[0] & /*sources*/
        128 && (q.sources = /*sources*/
        T[7]), !d && j[0] & /*active_source*/
        4 && (d = !0, q.active_source = /*active_source*/
        T[2], Hn(() => d = !1)), c.$set(q);
        const I = {};
        !_ && j[0] & /*isDialogOpen*/
        32768 && (_ = !0, I.isOpen = /*isDialogOpen*/
        T[15], Hn(() => _ = !1)), p.$set(I);
      },
      i(T) {
        y || (De(e.$$.fragment, T), De(o), De(c.$$.fragment, T), De(m.$$.fragment, T), De(p.$$.fragment, T), y = !0);
      },
      o(T) {
        Re(e.$$.fragment, T), Re(o), Re(c.$$.fragment, T), Re(m.$$.fragment, T), Re(p.$$.fragment, T), y = !1;
      },
      d(T) {
        T && (Xt(t), Xt(r), Xt(s), Xt(g)), vt(e, T), k[n].d(T), vt(c), vt(m), i[40](null), vt(p, T), v = !1, C();
      }
    }
  );
}
const pg = 500, Kl = 44;
function _g(i, e, t) {
  let { $$slots: n = {}, $$scope: o } = e;
  var r = this && this.__awaiter || function(N, he, Y, re) {
    function le(ee) {
      return ee instanceof Y ? ee : new Y(function(ce) {
        ce(ee);
      });
    }
    return new (Y || (Y = Promise))(function(ee, ce) {
      function de(We) {
        try {
          oe(re.next(We));
        } catch (ti) {
          ce(ti);
        }
      }
      function ie(We) {
        try {
          oe(re.throw(We));
        } catch (ti) {
          ce(ti);
        }
      }
      function oe(We) {
        We.done ? ee(We.value) : le(We.value).then(de, ie);
      }
      oe((re = re.apply(N, he || [])).next());
    });
  };
  let { value: s = null } = e, { label: a } = e, { root: l } = e, { show_label: u = !0 } = e, { show_download_button: c = !0 } = e, { sources: d = ["microphone", "upload"] } = e, { pending: h = !1 } = e, { streaming: f = !1 } = e, { i18n: m } = e, { show_minimap: g = !0 } = e, { waveform_settings: p } = e, { waveform_options: _ = {} } = e, { dragging: y } = e, { active_source: v } = e;
  const C = og("upload_files");
  let M = !1, k, P = "", D, b = [], E = !1, U = !1, T = !1, j, V = [], Q;
  function q() {
    Q = [
      import("./module-DwKaDiT1.js"),
      import("./module-wPUp6Scx.js")
    ];
  }
  f && q();
  const I = rg(), H = (N, he) => r(void 0, void 0, void 0, function* () {
    var Y;
    let re = new File(N, "audio.wav");
    const le = yield _u([re], he === "stream");
    let ee = ((Y = yield pu(le, l, void 0, C)) === null || Y === void 0 ? void 0 : Y.filter(Boolean))[0];
    s === null ? t(1, s = new Al(ee)) : t(1, s.file_data = ee, s), I(he, s);
  });
  sg(() => {
    f && k && k.state !== "inactive" && k.stop();
  });
  function G() {
    return r(this, void 0, void 0, function* () {
      let N;
      try {
        N = yield navigator.mediaDevices.getUserMedia({ audio: !0 });
      } catch (he) {
        if (!navigator.mediaDevices) {
          I("error", m("audio.no_device_support"));
          return;
        }
        if (he instanceof DOMException && he.name == "NotAllowedError") {
          I("error", m("audio.allow_recording_access"));
          return;
        }
        throw he;
      }
      if (N != null) {
        if (f) {
          const [{ MediaRecorder: he, register: Y }, { connect: re }] = yield Promise.all(Q);
          yield Y(yield re()), k = new he(N, { mimeType: "audio/wav" }), k.addEventListener("dataavailable", F);
        } else
          k = new MediaRecorder(N), k.addEventListener("dataavailable", (he) => {
            V.push(he.data);
          }), k.addEventListener("stop", () => r(this, void 0, void 0, function* () {
            t(13, M = !1), yield H(V, "change"), yield H(V, "stop_recording"), V = [];
          }));
        U = !0;
      }
    });
  }
  function F(N) {
    return r(this, void 0, void 0, function* () {
      let he = yield N.data.arrayBuffer(), Y = new Uint8Array(he);
      if (D || (t(24, D = new Uint8Array(he.slice(0, Kl))), Y = new Uint8Array(he.slice(Kl))), h)
        b.push(Y);
      else {
        let re = [D].concat(b, [Y]);
        H(re, "stream"), t(25, b = []);
      }
    });
  }
  function K() {
    return r(this, void 0, void 0, function* () {
      t(13, M = !0), I("start_recording"), U || (yield G()), t(24, D = void 0), f && k.start(pg);
    });
  }
  function x() {
    I("change", null), I("clear"), t(14, P = ""), t(1, s = null);
  }
  function A({ detail: N }) {
    t(1, s = new Al(N)), I("change", s), I("upload", N);
  }
  function S() {
    t(13, M = !1), f && (I("stop_recording"), k.stop(), h && t(26, E = !0), H(V, "stop_recording"), I("clear"), t(14, P = ""));
  }
  function W(N) {
    P = N, t(14, P);
  }
  function z(N) {
    y = N, t(0, y);
  }
  const O = ({ detail: N }) => I("error", N), w = () => t(14, P = "edit");
  function L(N) {
    P = N, t(14, P);
  }
  function B(N) {
    T = N, t(15, T);
  }
  function R(N) {
    ws.call(this, i, N);
  }
  function Z(N) {
    ws.call(this, i, N);
  }
  function ne(N) {
    ws.call(this, i, N);
  }
  const ae = (N) => I("edit", N.detail);
  function Ct(N) {
    v = N, t(2, v);
  }
  const $ = () => j.openDialog();
  function Ne(N) {
    gn[N ? "unshift" : "push"](() => {
      j = N, t(16, j);
    });
  }
  function ft(N) {
    T = N, t(15, T);
  }
  return i.$$set = (N) => {
    "value" in N && t(1, s = N.value), "label" in N && t(3, a = N.label), "root" in N && t(4, l = N.root), "show_label" in N && t(5, u = N.show_label), "show_download_button" in N && t(6, c = N.show_download_button), "sources" in N && t(7, d = N.sources), "pending" in N && t(23, h = N.pending), "streaming" in N && t(8, f = N.streaming), "i18n" in N && t(9, m = N.i18n), "show_minimap" in N && t(10, g = N.show_minimap), "waveform_settings" in N && t(11, p = N.waveform_settings), "waveform_options" in N && t(12, _ = N.waveform_options), "dragging" in N && t(0, y = N.dragging), "active_source" in N && t(2, v = N.active_source), "$$scope" in N && t(42, o = N.$$scope);
  }, i.$$.update = () => {
    if (i.$$.dirty[0] & /*dragging*/
    1 && I("drag", y), i.$$.dirty[0] & /*submit_pending_stream_on_pending_end, pending, header, pending_stream*/
    125829120 && E && h === !1 && (t(26, E = !1), D && b)) {
      let N = [D].concat(b);
      t(25, b = []), H(N, "stream");
    }
  }, [
    y,
    s,
    v,
    a,
    l,
    u,
    c,
    d,
    f,
    m,
    g,
    p,
    _,
    M,
    P,
    T,
    j,
    I,
    H,
    K,
    x,
    A,
    S,
    h,
    D,
    b,
    E,
    n,
    W,
    z,
    O,
    w,
    L,
    B,
    R,
    Z,
    ne,
    ae,
    Ct,
    $,
    Ne,
    ft,
    o
  ];
}
class gg extends Y1 {
  constructor(e) {
    super(), eg(
      this,
      e,
      _g,
      mg,
      ng,
      {
        value: 1,
        label: 3,
        root: 4,
        show_label: 5,
        show_download_button: 6,
        sources: 7,
        pending: 23,
        streaming: 8,
        i18n: 9,
        show_minimap: 10,
        waveform_settings: 11,
        waveform_options: 12,
        dragging: 0,
        active_source: 2
      },
      null,
      [-1, -1]
    );
  }
}
function Nn(i) {
  let e = ["", "k", "M", "G", "T", "P", "E", "Z"], t = 0;
  for (; i > 1e3 && t < e.length - 1; )
    i /= 1e3, t++;
  let n = e[t];
  return (Number.isInteger(i) ? i : i.toFixed(1)) + n;
}
function ao() {
}
function vg(i, e) {
  return i != i ? e == e : i !== e || i && typeof i == "object" || typeof i == "function";
}
const Uu = typeof window < "u";
let Yl = Uu ? () => window.performance.now() : () => Date.now(), Fu = Uu ? (i) => requestAnimationFrame(i) : ao;
const Un = /* @__PURE__ */ new Set();
function Gu(i) {
  Un.forEach((e) => {
    e.c(i) || (Un.delete(e), e.f());
  }), Un.size !== 0 && Fu(Gu);
}
function bg(i) {
  let e;
  return Un.size === 0 && Fu(Gu), {
    promise: new Promise((t) => {
      Un.add(e = { c: i, f: t });
    }),
    abort() {
      Un.delete(e);
    }
  };
}
const On = [];
function wg(i, e = ao) {
  let t;
  const n = /* @__PURE__ */ new Set();
  function o(a) {
    if (vg(i, a) && (i = a, t)) {
      const l = !On.length;
      for (const u of n)
        u[1](), On.push(u, i);
      if (l) {
        for (let u = 0; u < On.length; u += 2)
          On[u][0](On[u + 1]);
        On.length = 0;
      }
    }
  }
  function r(a) {
    o(a(i));
  }
  function s(a, l = ao) {
    const u = [a, l];
    return n.add(u), n.size === 1 && (t = e(o, r) || ao), a(i), () => {
      n.delete(u), n.size === 0 && t && (t(), t = null);
    };
  }
  return { set: o, update: r, subscribe: s };
}
function Ql(i) {
  return Object.prototype.toString.call(i) === "[object Date]";
}
function Ys(i, e, t, n) {
  if (typeof t == "number" || Ql(t)) {
    const o = n - t, r = (t - e) / (i.dt || 1 / 60), s = i.opts.stiffness * o, a = i.opts.damping * r, l = (s - a) * i.inv_mass, u = (r + l) * i.dt;
    return Math.abs(u) < i.opts.precision && Math.abs(o) < i.opts.precision ? n : (i.settled = !1, Ql(t) ? new Date(t.getTime() + u) : t + u);
  } else {
    if (Array.isArray(t))
      return t.map(
        (o, r) => Ys(i, e[r], t[r], n[r])
      );
    if (typeof t == "object") {
      const o = {};
      for (const r in t)
        o[r] = Ys(i, e[r], t[r], n[r]);
      return o;
    } else
      throw new Error(`Cannot spring ${typeof t} values`);
  }
}
function $l(i, e = {}) {
  const t = wg(i), { stiffness: n = 0.15, damping: o = 0.8, precision: r = 0.01 } = e;
  let s, a, l, u = i, c = i, d = 1, h = 0, f = !1;
  function m(p, _ = {}) {
    c = p;
    const y = l = {};
    return i == null || _.hard || g.stiffness >= 1 && g.damping >= 1 ? (f = !0, s = Yl(), u = p, t.set(i = c), Promise.resolve()) : (_.soft && (h = 1 / ((_.soft === !0 ? 0.5 : +_.soft) * 60), d = 0), a || (s = Yl(), f = !1, a = bg((v) => {
      if (f)
        return f = !1, a = null, !1;
      d = Math.min(d + h, 1);
      const C = {
        inv_mass: d,
        opts: g,
        settled: !0,
        dt: (v - s) * 60 / 1e3
      }, M = Ys(C, u, i, c);
      return s = v, u = i, t.set(i = M), C.settled && (a = null), !C.settled;
    })), new Promise((v) => {
      a.promise.then(() => {
        y === l && v();
      });
    }));
  }
  const g = {
    set: m,
    update: (p, _) => m(p(c, i), _),
    subscribe: t.subscribe,
    stiffness: n,
    damping: o,
    precision: r
  };
  return g;
}
const {
  SvelteComponent: yg,
  append: ot,
  attr: te,
  component_subscribe: xl,
  detach: kg,
  element: Cg,
  init: Sg,
  insert: Eg,
  noop: ea,
  safe_not_equal: Dg,
  set_style: xi,
  svg_element: st,
  toggle_class: ta
} = window.__gradio__svelte__internal, { onMount: Rg } = window.__gradio__svelte__internal;
function Mg(i) {
  let e, t, n, o, r, s, a, l, u, c, d, h;
  return {
    c() {
      e = Cg("div"), t = st("svg"), n = st("g"), o = st("path"), r = st("path"), s = st("path"), a = st("path"), l = st("g"), u = st("path"), c = st("path"), d = st("path"), h = st("path"), te(o, "d", "M255.926 0.754768L509.702 139.936V221.027L255.926 81.8465V0.754768Z"), te(o, "fill", "#FF7C00"), te(o, "fill-opacity", "0.4"), te(o, "class", "svelte-43sxxs"), te(r, "d", "M509.69 139.936L254.981 279.641V361.255L509.69 221.55V139.936Z"), te(r, "fill", "#FF7C00"), te(r, "class", "svelte-43sxxs"), te(s, "d", "M0.250138 139.937L254.981 279.641V361.255L0.250138 221.55V139.937Z"), te(s, "fill", "#FF7C00"), te(s, "fill-opacity", "0.4"), te(s, "class", "svelte-43sxxs"), te(a, "d", "M255.923 0.232622L0.236328 139.936V221.55L255.923 81.8469V0.232622Z"), te(a, "fill", "#FF7C00"), te(a, "class", "svelte-43sxxs"), xi(n, "transform", "translate(" + /*$top*/
      i[1][0] + "px, " + /*$top*/
      i[1][1] + "px)"), te(u, "d", "M255.926 141.5L509.702 280.681V361.773L255.926 222.592V141.5Z"), te(u, "fill", "#FF7C00"), te(u, "fill-opacity", "0.4"), te(u, "class", "svelte-43sxxs"), te(c, "d", "M509.69 280.679L254.981 420.384V501.998L509.69 362.293V280.679Z"), te(c, "fill", "#FF7C00"), te(c, "class", "svelte-43sxxs"), te(d, "d", "M0.250138 280.681L254.981 420.386V502L0.250138 362.295V280.681Z"), te(d, "fill", "#FF7C00"), te(d, "fill-opacity", "0.4"), te(d, "class", "svelte-43sxxs"), te(h, "d", "M255.923 140.977L0.236328 280.68V362.294L255.923 222.591V140.977Z"), te(h, "fill", "#FF7C00"), te(h, "class", "svelte-43sxxs"), xi(l, "transform", "translate(" + /*$bottom*/
      i[2][0] + "px, " + /*$bottom*/
      i[2][1] + "px)"), te(t, "viewBox", "-1200 -1200 3000 3000"), te(t, "fill", "none"), te(t, "xmlns", "http://www.w3.org/2000/svg"), te(t, "class", "svelte-43sxxs"), te(e, "class", "svelte-43sxxs"), ta(
        e,
        "margin",
        /*margin*/
        i[0]
      );
    },
    m(f, m) {
      Eg(f, e, m), ot(e, t), ot(t, n), ot(n, o), ot(n, r), ot(n, s), ot(n, a), ot(t, l), ot(l, u), ot(l, c), ot(l, d), ot(l, h);
    },
    p(f, [m]) {
      m & /*$top*/
      2 && xi(n, "transform", "translate(" + /*$top*/
      f[1][0] + "px, " + /*$top*/
      f[1][1] + "px)"), m & /*$bottom*/
      4 && xi(l, "transform", "translate(" + /*$bottom*/
      f[2][0] + "px, " + /*$bottom*/
      f[2][1] + "px)"), m & /*margin*/
      1 && ta(
        e,
        "margin",
        /*margin*/
        f[0]
      );
    },
    i: ea,
    o: ea,
    d(f) {
      f && kg(e);
    }
  };
}
function Lg(i, e, t) {
  let n, o;
  var r = this && this.__awaiter || function(f, m, g, p) {
    function _(y) {
      return y instanceof g ? y : new g(function(v) {
        v(y);
      });
    }
    return new (g || (g = Promise))(function(y, v) {
      function C(P) {
        try {
          k(p.next(P));
        } catch (D) {
          v(D);
        }
      }
      function M(P) {
        try {
          k(p.throw(P));
        } catch (D) {
          v(D);
        }
      }
      function k(P) {
        P.done ? y(P.value) : _(P.value).then(C, M);
      }
      k((p = p.apply(f, m || [])).next());
    });
  };
  let { margin: s = !0 } = e;
  const a = $l([0, 0]);
  xl(i, a, (f) => t(1, n = f));
  const l = $l([0, 0]);
  xl(i, l, (f) => t(2, o = f));
  let u;
  function c() {
    return r(this, void 0, void 0, function* () {
      yield Promise.all([a.set([125, 140]), l.set([-125, -140])]), yield Promise.all([a.set([-125, 140]), l.set([125, -140])]), yield Promise.all([a.set([-125, 0]), l.set([125, -0])]), yield Promise.all([a.set([125, 0]), l.set([-125, 0])]);
    });
  }
  function d() {
    return r(this, void 0, void 0, function* () {
      yield c(), u || d();
    });
  }
  function h() {
    return r(this, void 0, void 0, function* () {
      yield Promise.all([a.set([125, 0]), l.set([-125, 0])]), d();
    });
  }
  return Rg(() => (h(), () => u = !0)), i.$$set = (f) => {
    "margin" in f && t(0, s = f.margin);
  }, [s, n, o, a, l];
}
class Og extends yg {
  constructor(e) {
    super(), Sg(this, e, Lg, Mg, Dg, { margin: 0 });
  }
}
const {
  SvelteComponent: Pg,
  append: dn,
  attr: wt,
  binding_callbacks: na,
  check_outros: Vu,
  create_component: Wg,
  create_slot: Ag,
  destroy_component: Tg,
  destroy_each: Hu,
  detach: X,
  element: Pt,
  empty: ei,
  ensure_array_like: _o,
  get_all_dirty_from_scope: qg,
  get_slot_changes: jg,
  group_outros: Zu,
  init: Ng,
  insert: J,
  mount_component: zg,
  noop: Qs,
  safe_not_equal: Bg,
  set_data: et,
  set_style: Kt,
  space: yt,
  text: ue,
  toggle_class: $e,
  transition_in: Xn,
  transition_out: Jn,
  update_slot_base: Ig
} = window.__gradio__svelte__internal, { tick: Ug } = window.__gradio__svelte__internal, { onDestroy: Fg } = window.__gradio__svelte__internal, Gg = (i) => ({}), ia = (i) => ({});
function oa(i, e, t) {
  const n = i.slice();
  return n[39] = e[t], n[41] = t, n;
}
function sa(i, e, t) {
  const n = i.slice();
  return n[39] = e[t], n;
}
function Vg(i) {
  let e, t = (
    /*i18n*/
    i[1]("common.error") + ""
  ), n, o, r;
  const s = (
    /*#slots*/
    i[29].error
  ), a = Ag(
    s,
    i,
    /*$$scope*/
    i[28],
    ia
  );
  return {
    c() {
      e = Pt("span"), n = ue(t), o = yt(), a && a.c(), wt(e, "class", "error svelte-1yserjw");
    },
    m(l, u) {
      J(l, e, u), dn(e, n), J(l, o, u), a && a.m(l, u), r = !0;
    },
    p(l, u) {
      (!r || u[0] & /*i18n*/
      2) && t !== (t = /*i18n*/
      l[1]("common.error") + "") && et(n, t), a && a.p && (!r || u[0] & /*$$scope*/
      268435456) && Ig(
        a,
        s,
        l,
        /*$$scope*/
        l[28],
        r ? jg(
          s,
          /*$$scope*/
          l[28],
          u,
          Gg
        ) : qg(
          /*$$scope*/
          l[28]
        ),
        ia
      );
    },
    i(l) {
      r || (Xn(a, l), r = !0);
    },
    o(l) {
      Jn(a, l), r = !1;
    },
    d(l) {
      l && (X(e), X(o)), a && a.d(l);
    }
  };
}
function Hg(i) {
  let e, t, n, o, r, s, a, l, u, c = (
    /*variant*/
    i[8] === "default" && /*show_eta_bar*/
    i[18] && /*show_progress*/
    i[6] === "full" && ra(i)
  );
  function d(v, C) {
    if (
      /*progress*/
      v[7]
    ) return Jg;
    if (
      /*queue_position*/
      v[2] !== null && /*queue_size*/
      v[3] !== void 0 && /*queue_position*/
      v[2] >= 0
    ) return Xg;
    if (
      /*queue_position*/
      v[2] === 0
    ) return Zg;
  }
  let h = d(i), f = h && h(i), m = (
    /*timer*/
    i[5] && ua(i)
  );
  const g = [$g, Qg], p = [];
  function _(v, C) {
    return (
      /*last_progress_level*/
      v[15] != null ? 0 : (
        /*show_progress*/
        v[6] === "full" ? 1 : -1
      )
    );
  }
  ~(r = _(i)) && (s = p[r] = g[r](i));
  let y = !/*timer*/
  i[5] && _a(i);
  return {
    c() {
      c && c.c(), e = yt(), t = Pt("div"), f && f.c(), n = yt(), m && m.c(), o = yt(), s && s.c(), a = yt(), y && y.c(), l = ei(), wt(t, "class", "progress-text svelte-1yserjw"), $e(
        t,
        "meta-text-center",
        /*variant*/
        i[8] === "center"
      ), $e(
        t,
        "meta-text",
        /*variant*/
        i[8] === "default"
      );
    },
    m(v, C) {
      c && c.m(v, C), J(v, e, C), J(v, t, C), f && f.m(t, null), dn(t, n), m && m.m(t, null), J(v, o, C), ~r && p[r].m(v, C), J(v, a, C), y && y.m(v, C), J(v, l, C), u = !0;
    },
    p(v, C) {
      /*variant*/
      v[8] === "default" && /*show_eta_bar*/
      v[18] && /*show_progress*/
      v[6] === "full" ? c ? c.p(v, C) : (c = ra(v), c.c(), c.m(e.parentNode, e)) : c && (c.d(1), c = null), h === (h = d(v)) && f ? f.p(v, C) : (f && f.d(1), f = h && h(v), f && (f.c(), f.m(t, n))), /*timer*/
      v[5] ? m ? m.p(v, C) : (m = ua(v), m.c(), m.m(t, null)) : m && (m.d(1), m = null), (!u || C[0] & /*variant*/
      256) && $e(
        t,
        "meta-text-center",
        /*variant*/
        v[8] === "center"
      ), (!u || C[0] & /*variant*/
      256) && $e(
        t,
        "meta-text",
        /*variant*/
        v[8] === "default"
      );
      let M = r;
      r = _(v), r === M ? ~r && p[r].p(v, C) : (s && (Zu(), Jn(p[M], 1, 1, () => {
        p[M] = null;
      }), Vu()), ~r ? (s = p[r], s ? s.p(v, C) : (s = p[r] = g[r](v), s.c()), Xn(s, 1), s.m(a.parentNode, a)) : s = null), /*timer*/
      v[5] ? y && (y.d(1), y = null) : y ? y.p(v, C) : (y = _a(v), y.c(), y.m(l.parentNode, l));
    },
    i(v) {
      u || (Xn(s), u = !0);
    },
    o(v) {
      Jn(s), u = !1;
    },
    d(v) {
      v && (X(e), X(t), X(o), X(a), X(l)), c && c.d(v), f && f.d(), m && m.d(), ~r && p[r].d(v), y && y.d(v);
    }
  };
}
function ra(i) {
  let e, t = `translateX(${/*eta_level*/
  (i[17] || 0) * 100 - 100}%)`;
  return {
    c() {
      e = Pt("div"), wt(e, "class", "eta-bar svelte-1yserjw"), Kt(e, "transform", t);
    },
    m(n, o) {
      J(n, e, o);
    },
    p(n, o) {
      o[0] & /*eta_level*/
      131072 && t !== (t = `translateX(${/*eta_level*/
      (n[17] || 0) * 100 - 100}%)`) && Kt(e, "transform", t);
    },
    d(n) {
      n && X(e);
    }
  };
}
function Zg(i) {
  let e;
  return {
    c() {
      e = ue("processing |");
    },
    m(t, n) {
      J(t, e, n);
    },
    p: Qs,
    d(t) {
      t && X(e);
    }
  };
}
function Xg(i) {
  let e, t = (
    /*queue_position*/
    i[2] + 1 + ""
  ), n, o, r, s;
  return {
    c() {
      e = ue("queue: "), n = ue(t), o = ue("/"), r = ue(
        /*queue_size*/
        i[3]
      ), s = ue(" |");
    },
    m(a, l) {
      J(a, e, l), J(a, n, l), J(a, o, l), J(a, r, l), J(a, s, l);
    },
    p(a, l) {
      l[0] & /*queue_position*/
      4 && t !== (t = /*queue_position*/
      a[2] + 1 + "") && et(n, t), l[0] & /*queue_size*/
      8 && et(
        r,
        /*queue_size*/
        a[3]
      );
    },
    d(a) {
      a && (X(e), X(n), X(o), X(r), X(s));
    }
  };
}
function Jg(i) {
  let e, t = _o(
    /*progress*/
    i[7]
  ), n = [];
  for (let o = 0; o < t.length; o += 1)
    n[o] = aa(sa(i, t, o));
  return {
    c() {
      for (let o = 0; o < n.length; o += 1)
        n[o].c();
      e = ei();
    },
    m(o, r) {
      for (let s = 0; s < n.length; s += 1)
        n[s] && n[s].m(o, r);
      J(o, e, r);
    },
    p(o, r) {
      if (r[0] & /*progress*/
      128) {
        t = _o(
          /*progress*/
          o[7]
        );
        let s;
        for (s = 0; s < t.length; s += 1) {
          const a = sa(o, t, s);
          n[s] ? n[s].p(a, r) : (n[s] = aa(a), n[s].c(), n[s].m(e.parentNode, e));
        }
        for (; s < n.length; s += 1)
          n[s].d(1);
        n.length = t.length;
      }
    },
    d(o) {
      o && X(e), Hu(n, o);
    }
  };
}
function la(i) {
  let e, t = (
    /*p*/
    i[39].unit + ""
  ), n, o, r = " ", s;
  function a(c, d) {
    return (
      /*p*/
      c[39].length != null ? Yg : Kg
    );
  }
  let l = a(i), u = l(i);
  return {
    c() {
      u.c(), e = yt(), n = ue(t), o = ue(" | "), s = ue(r);
    },
    m(c, d) {
      u.m(c, d), J(c, e, d), J(c, n, d), J(c, o, d), J(c, s, d);
    },
    p(c, d) {
      l === (l = a(c)) && u ? u.p(c, d) : (u.d(1), u = l(c), u && (u.c(), u.m(e.parentNode, e))), d[0] & /*progress*/
      128 && t !== (t = /*p*/
      c[39].unit + "") && et(n, t);
    },
    d(c) {
      c && (X(e), X(n), X(o), X(s)), u.d(c);
    }
  };
}
function Kg(i) {
  let e = Nn(
    /*p*/
    i[39].index || 0
  ) + "", t;
  return {
    c() {
      t = ue(e);
    },
    m(n, o) {
      J(n, t, o);
    },
    p(n, o) {
      o[0] & /*progress*/
      128 && e !== (e = Nn(
        /*p*/
        n[39].index || 0
      ) + "") && et(t, e);
    },
    d(n) {
      n && X(t);
    }
  };
}
function Yg(i) {
  let e = Nn(
    /*p*/
    i[39].index || 0
  ) + "", t, n, o = Nn(
    /*p*/
    i[39].length
  ) + "", r;
  return {
    c() {
      t = ue(e), n = ue("/"), r = ue(o);
    },
    m(s, a) {
      J(s, t, a), J(s, n, a), J(s, r, a);
    },
    p(s, a) {
      a[0] & /*progress*/
      128 && e !== (e = Nn(
        /*p*/
        s[39].index || 0
      ) + "") && et(t, e), a[0] & /*progress*/
      128 && o !== (o = Nn(
        /*p*/
        s[39].length
      ) + "") && et(r, o);
    },
    d(s) {
      s && (X(t), X(n), X(r));
    }
  };
}
function aa(i) {
  let e, t = (
    /*p*/
    i[39].index != null && la(i)
  );
  return {
    c() {
      t && t.c(), e = ei();
    },
    m(n, o) {
      t && t.m(n, o), J(n, e, o);
    },
    p(n, o) {
      /*p*/
      n[39].index != null ? t ? t.p(n, o) : (t = la(n), t.c(), t.m(e.parentNode, e)) : t && (t.d(1), t = null);
    },
    d(n) {
      n && X(e), t && t.d(n);
    }
  };
}
function ua(i) {
  let e, t = (
    /*eta*/
    i[0] ? `/${/*formatted_eta*/
    i[19]}` : ""
  ), n, o;
  return {
    c() {
      e = ue(
        /*formatted_timer*/
        i[20]
      ), n = ue(t), o = ue("s");
    },
    m(r, s) {
      J(r, e, s), J(r, n, s), J(r, o, s);
    },
    p(r, s) {
      s[0] & /*formatted_timer*/
      1048576 && et(
        e,
        /*formatted_timer*/
        r[20]
      ), s[0] & /*eta, formatted_eta*/
      524289 && t !== (t = /*eta*/
      r[0] ? `/${/*formatted_eta*/
      r[19]}` : "") && et(n, t);
    },
    d(r) {
      r && (X(e), X(n), X(o));
    }
  };
}
function Qg(i) {
  let e, t;
  return e = new Og({
    props: { margin: (
      /*variant*/
      i[8] === "default"
    ) }
  }), {
    c() {
      Wg(e.$$.fragment);
    },
    m(n, o) {
      zg(e, n, o), t = !0;
    },
    p(n, o) {
      const r = {};
      o[0] & /*variant*/
      256 && (r.margin = /*variant*/
      n[8] === "default"), e.$set(r);
    },
    i(n) {
      t || (Xn(e.$$.fragment, n), t = !0);
    },
    o(n) {
      Jn(e.$$.fragment, n), t = !1;
    },
    d(n) {
      Tg(e, n);
    }
  };
}
function $g(i) {
  let e, t, n, o, r, s = `${/*last_progress_level*/
  i[15] * 100}%`, a = (
    /*progress*/
    i[7] != null && ca(i)
  );
  return {
    c() {
      e = Pt("div"), t = Pt("div"), a && a.c(), n = yt(), o = Pt("div"), r = Pt("div"), wt(t, "class", "progress-level-inner svelte-1yserjw"), wt(r, "class", "progress-bar svelte-1yserjw"), Kt(r, "width", s), wt(o, "class", "progress-bar-wrap svelte-1yserjw"), wt(e, "class", "progress-level svelte-1yserjw");
    },
    m(l, u) {
      J(l, e, u), dn(e, t), a && a.m(t, null), dn(e, n), dn(e, o), dn(o, r), i[30](r);
    },
    p(l, u) {
      /*progress*/
      l[7] != null ? a ? a.p(l, u) : (a = ca(l), a.c(), a.m(t, null)) : a && (a.d(1), a = null), u[0] & /*last_progress_level*/
      32768 && s !== (s = `${/*last_progress_level*/
      l[15] * 100}%`) && Kt(r, "width", s);
    },
    i: Qs,
    o: Qs,
    d(l) {
      l && X(e), a && a.d(), i[30](null);
    }
  };
}
function ca(i) {
  let e, t = _o(
    /*progress*/
    i[7]
  ), n = [];
  for (let o = 0; o < t.length; o += 1)
    n[o] = pa(oa(i, t, o));
  return {
    c() {
      for (let o = 0; o < n.length; o += 1)
        n[o].c();
      e = ei();
    },
    m(o, r) {
      for (let s = 0; s < n.length; s += 1)
        n[s] && n[s].m(o, r);
      J(o, e, r);
    },
    p(o, r) {
      if (r[0] & /*progress_level, progress*/
      16512) {
        t = _o(
          /*progress*/
          o[7]
        );
        let s;
        for (s = 0; s < t.length; s += 1) {
          const a = oa(o, t, s);
          n[s] ? n[s].p(a, r) : (n[s] = pa(a), n[s].c(), n[s].m(e.parentNode, e));
        }
        for (; s < n.length; s += 1)
          n[s].d(1);
        n.length = t.length;
      }
    },
    d(o) {
      o && X(e), Hu(n, o);
    }
  };
}
function da(i) {
  let e, t, n, o, r = (
    /*i*/
    i[41] !== 0 && xg()
  ), s = (
    /*p*/
    i[39].desc != null && fa(i)
  ), a = (
    /*p*/
    i[39].desc != null && /*progress_level*/
    i[14] && /*progress_level*/
    i[14][
      /*i*/
      i[41]
    ] != null && ha()
  ), l = (
    /*progress_level*/
    i[14] != null && ma(i)
  );
  return {
    c() {
      r && r.c(), e = yt(), s && s.c(), t = yt(), a && a.c(), n = yt(), l && l.c(), o = ei();
    },
    m(u, c) {
      r && r.m(u, c), J(u, e, c), s && s.m(u, c), J(u, t, c), a && a.m(u, c), J(u, n, c), l && l.m(u, c), J(u, o, c);
    },
    p(u, c) {
      /*p*/
      u[39].desc != null ? s ? s.p(u, c) : (s = fa(u), s.c(), s.m(t.parentNode, t)) : s && (s.d(1), s = null), /*p*/
      u[39].desc != null && /*progress_level*/
      u[14] && /*progress_level*/
      u[14][
        /*i*/
        u[41]
      ] != null ? a || (a = ha(), a.c(), a.m(n.parentNode, n)) : a && (a.d(1), a = null), /*progress_level*/
      u[14] != null ? l ? l.p(u, c) : (l = ma(u), l.c(), l.m(o.parentNode, o)) : l && (l.d(1), l = null);
    },
    d(u) {
      u && (X(e), X(t), X(n), X(o)), r && r.d(u), s && s.d(u), a && a.d(u), l && l.d(u);
    }
  };
}
function xg(i) {
  let e;
  return {
    c() {
      e = ue(" /");
    },
    m(t, n) {
      J(t, e, n);
    },
    d(t) {
      t && X(e);
    }
  };
}
function fa(i) {
  let e = (
    /*p*/
    i[39].desc + ""
  ), t;
  return {
    c() {
      t = ue(e);
    },
    m(n, o) {
      J(n, t, o);
    },
    p(n, o) {
      o[0] & /*progress*/
      128 && e !== (e = /*p*/
      n[39].desc + "") && et(t, e);
    },
    d(n) {
      n && X(t);
    }
  };
}
function ha(i) {
  let e;
  return {
    c() {
      e = ue("-");
    },
    m(t, n) {
      J(t, e, n);
    },
    d(t) {
      t && X(e);
    }
  };
}
function ma(i) {
  let e = (100 * /*progress_level*/
  (i[14][
    /*i*/
    i[41]
  ] || 0)).toFixed(1) + "", t, n;
  return {
    c() {
      t = ue(e), n = ue("%");
    },
    m(o, r) {
      J(o, t, r), J(o, n, r);
    },
    p(o, r) {
      r[0] & /*progress_level*/
      16384 && e !== (e = (100 * /*progress_level*/
      (o[14][
        /*i*/
        o[41]
      ] || 0)).toFixed(1) + "") && et(t, e);
    },
    d(o) {
      o && (X(t), X(n));
    }
  };
}
function pa(i) {
  let e, t = (
    /*p*/
    (i[39].desc != null || /*progress_level*/
    i[14] && /*progress_level*/
    i[14][
      /*i*/
      i[41]
    ] != null) && da(i)
  );
  return {
    c() {
      t && t.c(), e = ei();
    },
    m(n, o) {
      t && t.m(n, o), J(n, e, o);
    },
    p(n, o) {
      /*p*/
      n[39].desc != null || /*progress_level*/
      n[14] && /*progress_level*/
      n[14][
        /*i*/
        n[41]
      ] != null ? t ? t.p(n, o) : (t = da(n), t.c(), t.m(e.parentNode, e)) : t && (t.d(1), t = null);
    },
    d(n) {
      n && X(e), t && t.d(n);
    }
  };
}
function _a(i) {
  let e, t;
  return {
    c() {
      e = Pt("p"), t = ue(
        /*loading_text*/
        i[9]
      ), wt(e, "class", "loading svelte-1yserjw");
    },
    m(n, o) {
      J(n, e, o), dn(e, t);
    },
    p(n, o) {
      o[0] & /*loading_text*/
      512 && et(
        t,
        /*loading_text*/
        n[9]
      );
    },
    d(n) {
      n && X(e);
    }
  };
}
function ev(i) {
  let e, t, n, o, r;
  const s = [Hg, Vg], a = [];
  function l(u, c) {
    return (
      /*status*/
      u[4] === "pending" ? 0 : (
        /*status*/
        u[4] === "error" ? 1 : -1
      )
    );
  }
  return ~(t = l(i)) && (n = a[t] = s[t](i)), {
    c() {
      e = Pt("div"), n && n.c(), wt(e, "class", o = "wrap " + /*variant*/
      i[8] + " " + /*show_progress*/
      i[6] + " svelte-1yserjw"), $e(e, "hide", !/*status*/
      i[4] || /*status*/
      i[4] === "complete" || /*show_progress*/
      i[6] === "hidden"), $e(
        e,
        "translucent",
        /*variant*/
        i[8] === "center" && /*status*/
        (i[4] === "pending" || /*status*/
        i[4] === "error") || /*translucent*/
        i[11] || /*show_progress*/
        i[6] === "minimal"
      ), $e(
        e,
        "generating",
        /*status*/
        i[4] === "generating"
      ), $e(
        e,
        "border",
        /*border*/
        i[12]
      ), Kt(
        e,
        "position",
        /*absolute*/
        i[10] ? "absolute" : "static"
      ), Kt(
        e,
        "padding",
        /*absolute*/
        i[10] ? "0" : "var(--size-8) 0"
      );
    },
    m(u, c) {
      J(u, e, c), ~t && a[t].m(e, null), i[31](e), r = !0;
    },
    p(u, c) {
      let d = t;
      t = l(u), t === d ? ~t && a[t].p(u, c) : (n && (Zu(), Jn(a[d], 1, 1, () => {
        a[d] = null;
      }), Vu()), ~t ? (n = a[t], n ? n.p(u, c) : (n = a[t] = s[t](u), n.c()), Xn(n, 1), n.m(e, null)) : n = null), (!r || c[0] & /*variant, show_progress*/
      320 && o !== (o = "wrap " + /*variant*/
      u[8] + " " + /*show_progress*/
      u[6] + " svelte-1yserjw")) && wt(e, "class", o), (!r || c[0] & /*variant, show_progress, status, show_progress*/
      336) && $e(e, "hide", !/*status*/
      u[4] || /*status*/
      u[4] === "complete" || /*show_progress*/
      u[6] === "hidden"), (!r || c[0] & /*variant, show_progress, variant, status, translucent, show_progress*/
      2384) && $e(
        e,
        "translucent",
        /*variant*/
        u[8] === "center" && /*status*/
        (u[4] === "pending" || /*status*/
        u[4] === "error") || /*translucent*/
        u[11] || /*show_progress*/
        u[6] === "minimal"
      ), (!r || c[0] & /*variant, show_progress, status*/
      336) && $e(
        e,
        "generating",
        /*status*/
        u[4] === "generating"
      ), (!r || c[0] & /*variant, show_progress, border*/
      4416) && $e(
        e,
        "border",
        /*border*/
        u[12]
      ), c[0] & /*absolute*/
      1024 && Kt(
        e,
        "position",
        /*absolute*/
        u[10] ? "absolute" : "static"
      ), c[0] & /*absolute*/
      1024 && Kt(
        e,
        "padding",
        /*absolute*/
        u[10] ? "0" : "var(--size-8) 0"
      );
    },
    i(u) {
      r || (Xn(n), r = !0);
    },
    o(u) {
      Jn(n), r = !1;
    },
    d(u) {
      u && X(e), ~t && a[t].d(), i[31](null);
    }
  };
}
var tv = function(i, e, t, n) {
  function o(r) {
    return r instanceof t ? r : new t(function(s) {
      s(r);
    });
  }
  return new (t || (t = Promise))(function(r, s) {
    function a(c) {
      try {
        u(n.next(c));
      } catch (d) {
        s(d);
      }
    }
    function l(c) {
      try {
        u(n.throw(c));
      } catch (d) {
        s(d);
      }
    }
    function u(c) {
      c.done ? r(c.value) : o(c.value).then(a, l);
    }
    u((n = n.apply(i, e || [])).next());
  });
};
let eo = [], ys = !1;
function nv(i) {
  return tv(this, arguments, void 0, function* (e, t = !0) {
    if (!(window.__gradio_mode__ === "website" || window.__gradio_mode__ !== "app" && t !== !0)) {
      if (eo.push(e), !ys) ys = !0;
      else return;
      yield Ug(), requestAnimationFrame(() => {
        let n = [0, 0];
        for (let o = 0; o < eo.length; o++) {
          const s = eo[o].getBoundingClientRect();
          (o === 0 || s.top + window.scrollY <= n[0]) && (n[0] = s.top + window.scrollY, n[1] = o);
        }
        window.scrollTo({ top: n[0] - 20, behavior: "smooth" }), ys = !1, eo = [];
      });
    }
  });
}
function iv(i, e, t) {
  let n, { $$slots: o = {}, $$scope: r } = e;
  this && this.__awaiter;
  let { i18n: s } = e, { eta: a = null } = e, { queue_position: l } = e, { queue_size: u } = e, { status: c } = e, { scroll_to_output: d = !1 } = e, { timer: h = !0 } = e, { show_progress: f = "full" } = e, { message: m = null } = e, { progress: g = null } = e, { variant: p = "default" } = e, { loading_text: _ = "Loading..." } = e, { absolute: y = !0 } = e, { translucent: v = !1 } = e, { border: C = !1 } = e, { autoscroll: M } = e, k, P = !1, D = 0, b = 0, E = null, U = null, T = 0, j = null, V, Q = null, q = !0;
  const I = () => {
    t(0, a = t(26, E = t(19, F = null))), t(24, D = performance.now()), t(25, b = 0), P = !0, H();
  };
  function H() {
    requestAnimationFrame(() => {
      t(25, b = (performance.now() - D) / 1e3), P && H();
    });
  }
  function G() {
    t(25, b = 0), t(0, a = t(26, E = t(19, F = null))), P && (P = !1);
  }
  Fg(() => {
    P && G();
  });
  let F = null;
  function K(A) {
    na[A ? "unshift" : "push"](() => {
      Q = A, t(16, Q), t(7, g), t(14, j), t(15, V);
    });
  }
  function x(A) {
    na[A ? "unshift" : "push"](() => {
      k = A, t(13, k);
    });
  }
  return i.$$set = (A) => {
    "i18n" in A && t(1, s = A.i18n), "eta" in A && t(0, a = A.eta), "queue_position" in A && t(2, l = A.queue_position), "queue_size" in A && t(3, u = A.queue_size), "status" in A && t(4, c = A.status), "scroll_to_output" in A && t(21, d = A.scroll_to_output), "timer" in A && t(5, h = A.timer), "show_progress" in A && t(6, f = A.show_progress), "message" in A && t(22, m = A.message), "progress" in A && t(7, g = A.progress), "variant" in A && t(8, p = A.variant), "loading_text" in A && t(9, _ = A.loading_text), "absolute" in A && t(10, y = A.absolute), "translucent" in A && t(11, v = A.translucent), "border" in A && t(12, C = A.border), "autoscroll" in A && t(23, M = A.autoscroll), "$$scope" in A && t(28, r = A.$$scope);
  }, i.$$.update = () => {
    i.$$.dirty[0] & /*eta, old_eta, timer_start, eta_from_start*/
    218103809 && (a === null && t(0, a = E), a != null && E !== a && (t(27, U = (performance.now() - D) / 1e3 + a), t(19, F = U.toFixed(1)), t(26, E = a))), i.$$.dirty[0] & /*eta_from_start, timer_diff*/
    167772160 && t(17, T = U === null || U <= 0 || !b ? null : Math.min(b / U, 1)), i.$$.dirty[0] & /*progress*/
    128 && g != null && t(18, q = !1), i.$$.dirty[0] & /*progress, progress_level, progress_bar, last_progress_level*/
    114816 && (g != null ? t(14, j = g.map((A) => {
      if (A.index != null && A.length != null)
        return A.index / A.length;
      if (A.progress != null)
        return A.progress;
    })) : t(14, j = null), j ? (t(15, V = j[j.length - 1]), Q && (V === 0 ? t(16, Q.style.transition = "0", Q) : t(16, Q.style.transition = "150ms", Q))) : t(15, V = void 0)), i.$$.dirty[0] & /*status*/
    16 && (c === "pending" ? I() : G()), i.$$.dirty[0] & /*el, scroll_to_output, status, autoscroll*/
    10493968 && k && d && (c === "pending" || c === "complete") && nv(k, M), i.$$.dirty[0] & /*status, message*/
    4194320, i.$$.dirty[0] & /*timer_diff*/
    33554432 && t(20, n = b.toFixed(1));
  }, [
    a,
    s,
    l,
    u,
    c,
    h,
    f,
    g,
    p,
    _,
    y,
    v,
    C,
    k,
    j,
    V,
    Q,
    T,
    q,
    F,
    n,
    d,
    m,
    M,
    D,
    b,
    E,
    U,
    r,
    o,
    K,
    x
  ];
}
class Xu extends Pg {
  constructor(e) {
    super(), Ng(
      this,
      e,
      iv,
      ev,
      Bg,
      {
        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: ov,
  add_flush_callback: sv,
  assign: Ju,
  bind: rv,
  binding_callbacks: lv,
  check_outros: av,
  create_component: vn,
  destroy_component: bn,
  detach: mr,
  empty: uv,
  flush: _e,
  get_spread_object: Ku,
  get_spread_update: Yu,
  group_outros: cv,
  init: dv,
  insert: pr,
  mount_component: wn,
  safe_not_equal: fv,
  space: Qu,
  transition_in: At,
  transition_out: Tt
} = window.__gradio__svelte__internal;
function hv(i) {
  let e, t;
  return e = new wa({
    props: {
      variant: (
        /*value*/
        i[0] === null && /*active_source*/
        i[19] === "upload" ? "dashed" : "solid"
      ),
      border_mode: (
        /*dragging*/
        i[20] ? "focus" : "base"
      ),
      padding: !1,
      elem_id: (
        /*elem_id*/
        i[2]
      ),
      elem_classes: (
        /*elem_classes*/
        i[3]
      ),
      visible: (
        /*visible*/
        i[4]
      ),
      container: (
        /*container*/
        i[12]
      ),
      scale: (
        /*scale*/
        i[13]
      ),
      min_width: (
        /*min_width*/
        i[14]
      ),
      $$slots: { default: [_v] },
      $$scope: { ctx: i }
    }
  }), {
    c() {
      vn(e.$$.fragment);
    },
    m(n, o) {
      wn(e, n, o), t = !0;
    },
    p(n, o) {
      const r = {};
      o[0] & /*value, active_source*/
      524289 && (r.variant = /*value*/
      n[0] === null && /*active_source*/
      n[19] === "upload" ? "dashed" : "solid"), o[0] & /*dragging*/
      1048576 && (r.border_mode = /*dragging*/
      n[20] ? "focus" : "base"), o[0] & /*elem_id*/
      4 && (r.elem_id = /*elem_id*/
      n[2]), o[0] & /*elem_classes*/
      8 && (r.elem_classes = /*elem_classes*/
      n[3]), o[0] & /*visible*/
      16 && (r.visible = /*visible*/
      n[4]), o[0] & /*container*/
      4096 && (r.container = /*container*/
      n[12]), o[0] & /*scale*/
      8192 && (r.scale = /*scale*/
      n[13]), o[0] & /*min_width*/
      16384 && (r.min_width = /*min_width*/
      n[14]), o[0] & /*label, show_label, show_download_button, show_minimap, value, root, sources, active_source, pending, streaming, gradio, waveform_settings, waveform_options, dragging, loading_status*/
      4165571 | o[1] & /*$$scope*/
      16384 && (r.$$scope = { dirty: o, ctx: n }), e.$set(r);
    },
    i(n) {
      t || (At(e.$$.fragment, n), t = !0);
    },
    o(n) {
      Tt(e.$$.fragment, n), t = !1;
    },
    d(n) {
      bn(e, n);
    }
  };
}
function mv(i) {
  let e, t;
  return e = new wa({
    props: {
      variant: "solid",
      border_mode: (
        /*dragging*/
        i[20] ? "focus" : "base"
      ),
      padding: !1,
      elem_id: (
        /*elem_id*/
        i[2]
      ),
      elem_classes: (
        /*elem_classes*/
        i[3]
      ),
      visible: (
        /*visible*/
        i[4]
      ),
      container: (
        /*container*/
        i[12]
      ),
      scale: (
        /*scale*/
        i[13]
      ),
      min_width: (
        /*min_width*/
        i[14]
      ),
      $$slots: { default: [gv] },
      $$scope: { ctx: i }
    }
  }), {
    c() {
      vn(e.$$.fragment);
    },
    m(n, o) {
      wn(e, n, o), t = !0;
    },
    p(n, o) {
      const r = {};
      o[0] & /*dragging*/
      1048576 && (r.border_mode = /*dragging*/
      n[20] ? "focus" : "base"), o[0] & /*elem_id*/
      4 && (r.elem_id = /*elem_id*/
      n[2]), o[0] & /*elem_classes*/
      8 && (r.elem_classes = /*elem_classes*/
      n[3]), o[0] & /*visible*/
      16 && (r.visible = /*visible*/
      n[4]), o[0] & /*container*/
      4096 && (r.container = /*container*/
      n[12]), o[0] & /*scale*/
      8192 && (r.scale = /*scale*/
      n[13]), o[0] & /*min_width*/
      16384 && (r.min_width = /*min_width*/
      n[14]), o[0] & /*gradio, show_label, show_download_button, show_minimap, value, label, waveform_settings, waveform_options, loading_status*/
      2395779 | o[1] & /*$$scope*/
      16384 && (r.$$scope = { dirty: o, ctx: n }), e.$set(r);
    },
    i(n) {
      t || (At(e.$$.fragment, n), t = !0);
    },
    o(n) {
      Tt(e.$$.fragment, n), t = !1;
    },
    d(n) {
      bn(e, n);
    }
  };
}
function pv(i) {
  let e, t;
  return e = new Oh({
    props: {
      i18n: (
        /*gradio*/
        i[18].i18n
      ),
      type: "audio"
    }
  }), {
    c() {
      vn(e.$$.fragment);
    },
    m(n, o) {
      wn(e, n, o), t = !0;
    },
    p(n, o) {
      const r = {};
      o[0] & /*gradio*/
      262144 && (r.i18n = /*gradio*/
      n[18].i18n), e.$set(r);
    },
    i(n) {
      t || (At(e.$$.fragment, n), t = !0);
    },
    o(n) {
      Tt(e.$$.fragment, n), t = !1;
    },
    d(n) {
      bn(e, n);
    }
  };
}
function _v(i) {
  let e, t, n, o, r;
  const s = [
    {
      autoscroll: (
        /*gradio*/
        i[18].autoscroll
      )
    },
    { i18n: (
      /*gradio*/
      i[18].i18n
    ) },
    /*loading_status*/
    i[1]
  ];
  let a = {};
  for (let c = 0; c < s.length; c += 1)
    a = Ju(a, s[c]);
  e = new Xu({ props: a });
  function l(c) {
    i[31](c);
  }
  let u = {
    label: (
      /*label*/
      i[7]
    ),
    show_label: (
      /*show_label*/
      i[9]
    ),
    show_download_button: (
      /*show_download_button*/
      i[10]
    ),
    show_minimap: (
      /*show_minimap*/
      i[11]
    ),
    value: (
      /*value*/
      i[0]
    ),
    root: (
      /*root*/
      i[8]
    ),
    sources: (
      /*sources*/
      i[6]
    ),
    active_source: (
      /*active_source*/
      i[19]
    ),
    pending: (
      /*pending*/
      i[16]
    ),
    streaming: (
      /*streaming*/
      i[17]
    ),
    i18n: (
      /*gradio*/
      i[18].i18n
    ),
    waveform_settings: (
      /*waveform_settings*/
      i[21]
    ),
    waveform_options: (
      /*waveform_options*/
      i[15]
    ),
    $$slots: { default: [pv] },
    $$scope: { ctx: i }
  };
  return (
    /*dragging*/
    i[20] !== void 0 && (u.dragging = /*dragging*/
    i[20]), n = new gg({ props: u }), lv.push(() => rv(n, "dragging", l)), n.$on(
      "change",
      /*change_handler*/
      i[32]
    ), n.$on(
      "stream",
      /*stream_handler*/
      i[33]
    ), n.$on(
      "drag",
      /*drag_handler*/
      i[34]
    ), n.$on(
      "edit",
      /*edit_handler*/
      i[35]
    ), n.$on(
      "play",
      /*play_handler_1*/
      i[36]
    ), n.$on(
      "pause",
      /*pause_handler_1*/
      i[37]
    ), n.$on(
      "stop",
      /*stop_handler_1*/
      i[38]
    ), n.$on(
      "start_recording",
      /*start_recording_handler*/
      i[39]
    ), n.$on(
      "pause_recording",
      /*pause_recording_handler*/
      i[40]
    ), n.$on(
      "stop_recording",
      /*stop_recording_handler*/
      i[41]
    ), n.$on(
      "upload",
      /*upload_handler*/
      i[42]
    ), n.$on(
      "clear",
      /*clear_handler*/
      i[43]
    ), n.$on(
      "error",
      /*handle_error*/
      i[22]
    ), {
      c() {
        vn(e.$$.fragment), t = Qu(), vn(n.$$.fragment);
      },
      m(c, d) {
        wn(e, c, d), pr(c, t, d), wn(n, c, d), r = !0;
      },
      p(c, d) {
        const h = d[0] & /*gradio, loading_status*/
        262146 ? Yu(s, [
          d[0] & /*gradio*/
          262144 && {
            autoscroll: (
              /*gradio*/
              c[18].autoscroll
            )
          },
          d[0] & /*gradio*/
          262144 && { i18n: (
            /*gradio*/
            c[18].i18n
          ) },
          d[0] & /*loading_status*/
          2 && Ku(
            /*loading_status*/
            c[1]
          )
        ]) : {};
        e.$set(h);
        const f = {};
        d[0] & /*label*/
        128 && (f.label = /*label*/
        c[7]), d[0] & /*show_label*/
        512 && (f.show_label = /*show_label*/
        c[9]), d[0] & /*show_download_button*/
        1024 && (f.show_download_button = /*show_download_button*/
        c[10]), d[0] & /*show_minimap*/
        2048 && (f.show_minimap = /*show_minimap*/
        c[11]), d[0] & /*value*/
        1 && (f.value = /*value*/
        c[0]), d[0] & /*root*/
        256 && (f.root = /*root*/
        c[8]), d[0] & /*sources*/
        64 && (f.sources = /*sources*/
        c[6]), d[0] & /*active_source*/
        524288 && (f.active_source = /*active_source*/
        c[19]), d[0] & /*pending*/
        65536 && (f.pending = /*pending*/
        c[16]), d[0] & /*streaming*/
        131072 && (f.streaming = /*streaming*/
        c[17]), d[0] & /*gradio*/
        262144 && (f.i18n = /*gradio*/
        c[18].i18n), d[0] & /*waveform_settings*/
        2097152 && (f.waveform_settings = /*waveform_settings*/
        c[21]), d[0] & /*waveform_options*/
        32768 && (f.waveform_options = /*waveform_options*/
        c[15]), d[0] & /*gradio*/
        262144 | d[1] & /*$$scope*/
        16384 && (f.$$scope = { dirty: d, ctx: c }), !o && d[0] & /*dragging*/
        1048576 && (o = !0, f.dragging = /*dragging*/
        c[20], sv(() => o = !1)), n.$set(f);
      },
      i(c) {
        r || (At(e.$$.fragment, c), At(n.$$.fragment, c), r = !0);
      },
      o(c) {
        Tt(e.$$.fragment, c), Tt(n.$$.fragment, c), r = !1;
      },
      d(c) {
        c && mr(t), bn(e, c), bn(n, c);
      }
    }
  );
}
function gv(i) {
  let e, t, n, o;
  const r = [
    {
      autoscroll: (
        /*gradio*/
        i[18].autoscroll
      )
    },
    { i18n: (
      /*gradio*/
      i[18].i18n
    ) },
    /*loading_status*/
    i[1]
  ];
  let s = {};
  for (let a = 0; a < r.length; a += 1)
    s = Ju(s, r[a]);
  return e = new Xu({ props: s }), n = new H_({
    props: {
      i18n: (
        /*gradio*/
        i[18].i18n
      ),
      show_label: (
        /*show_label*/
        i[9]
      ),
      show_download_button: (
        /*show_download_button*/
        i[10]
      ),
      show_minimap: (
        /*show_minimap*/
        i[11]
      ),
      value: (
        /*value*/
        i[0]
      ),
      label: (
        /*label*/
        i[7]
      ),
      waveform_settings: (
        /*waveform_settings*/
        i[21]
      ),
      waveform_options: (
        /*waveform_options*/
        i[15]
      )
    }
  }), n.$on(
    "share",
    /*share_handler*/
    i[26]
  ), n.$on(
    "error",
    /*error_handler*/
    i[27]
  ), n.$on(
    "play",
    /*play_handler*/
    i[28]
  ), n.$on(
    "pause",
    /*pause_handler*/
    i[29]
  ), n.$on(
    "stop",
    /*stop_handler*/
    i[30]
  ), {
    c() {
      vn(e.$$.fragment), t = Qu(), vn(n.$$.fragment);
    },
    m(a, l) {
      wn(e, a, l), pr(a, t, l), wn(n, a, l), o = !0;
    },
    p(a, l) {
      const u = l[0] & /*gradio, loading_status*/
      262146 ? Yu(r, [
        l[0] & /*gradio*/
        262144 && {
          autoscroll: (
            /*gradio*/
            a[18].autoscroll
          )
        },
        l[0] & /*gradio*/
        262144 && { i18n: (
          /*gradio*/
          a[18].i18n
        ) },
        l[0] & /*loading_status*/
        2 && Ku(
          /*loading_status*/
          a[1]
        )
      ]) : {};
      e.$set(u);
      const c = {};
      l[0] & /*gradio*/
      262144 && (c.i18n = /*gradio*/
      a[18].i18n), l[0] & /*show_label*/
      512 && (c.show_label = /*show_label*/
      a[9]), l[0] & /*show_download_button*/
      1024 && (c.show_download_button = /*show_download_button*/
      a[10]), l[0] & /*show_minimap*/
      2048 && (c.show_minimap = /*show_minimap*/
      a[11]), l[0] & /*value*/
      1 && (c.value = /*value*/
      a[0]), l[0] & /*label*/
      128 && (c.label = /*label*/
      a[7]), l[0] & /*waveform_settings*/
      2097152 && (c.waveform_settings = /*waveform_settings*/
      a[21]), l[0] & /*waveform_options*/
      32768 && (c.waveform_options = /*waveform_options*/
      a[15]), n.$set(c);
    },
    i(a) {
      o || (At(e.$$.fragment, a), At(n.$$.fragment, a), o = !0);
    },
    o(a) {
      Tt(e.$$.fragment, a), Tt(n.$$.fragment, a), o = !1;
    },
    d(a) {
      a && mr(t), bn(e, a), bn(n, a);
    }
  };
}
function vv(i) {
  let e, t, n, o;
  const r = [mv, hv], s = [];
  function a(l, u) {
    return (
      /*interactive*/
      l[5] ? 1 : 0
    );
  }
  return e = a(i), t = s[e] = r[e](i), {
    c() {
      t.c(), n = uv();
    },
    m(l, u) {
      s[e].m(l, u), pr(l, n, u), o = !0;
    },
    p(l, u) {
      let c = e;
      e = a(l), e === c ? s[e].p(l, u) : (cv(), Tt(s[c], 1, 1, () => {
        s[c] = null;
      }), av(), t = s[e], t ? t.p(l, u) : (t = s[e] = r[e](l), t.c()), At(t, 1), t.m(n.parentNode, n));
    },
    i(l) {
      o || (At(t), o = !0);
    },
    o(l) {
      Tt(t), o = !1;
    },
    d(l) {
      l && mr(n), s[e].d(l);
    }
  };
}
function bv(i, e, t) {
  let { elem_id: n = "" } = e, { elem_classes: o = [] } = e, { visible: r = !0 } = e, { interactive: s } = e, { value: a = null } = e, { sources: l } = e, { label: u } = e, { root: c } = e, { show_label: d } = e, { show_download_button: h = !0 } = e, { show_minimap: f = !0 } = e, { container: m = !0 } = e, { scale: g = null } = e, { min_width: p = void 0 } = e, { loading_status: _ } = e, { autoplay: y = !1 } = e, { waveform_options: v = {} } = e, { pending: C } = e, { streaming: M } = e, { gradio: k } = e, P = null, D, b = a, E, U;
  function T({ detail: R }) {
    const [Z, ne] = R.includes("Invalid file type") ? ["warning", "complete"] : ["error", "error"];
    t(1, _ = _ || {}), t(1, _.status = ne, _), t(1, _.message = R, _), k.dispatch(Z, R);
  }
  const j = (R) => k.dispatch("share", R.detail), V = (R) => k.dispatch("error", R.detail), Q = () => k.dispatch("play"), q = () => k.dispatch("pause"), I = () => k.dispatch("stop");
  function H(R) {
    E = R, t(20, E);
  }
  const G = ({ detail: R }) => t(0, a = R), F = ({ detail: R }) => {
    t(0, a = R), k.dispatch("stream", a);
  }, K = ({ detail: R }) => t(20, E = R), x = (R) => k.dispatch("edit", R.detail), A = () => k.dispatch("play"), S = () => k.dispatch("pause"), W = () => k.dispatch("stop"), z = () => k.dispatch("start_recording"), O = () => k.dispatch("pause_recording"), w = (R) => k.dispatch("stop_recording", R.detail), L = () => k.dispatch("upload"), B = () => k.dispatch("clear");
  return i.$$set = (R) => {
    "elem_id" in R && t(2, n = R.elem_id), "elem_classes" in R && t(3, o = R.elem_classes), "visible" in R && t(4, r = R.visible), "interactive" in R && t(5, s = R.interactive), "value" in R && t(0, a = R.value), "sources" in R && t(6, l = R.sources), "label" in R && t(7, u = R.label), "root" in R && t(8, c = R.root), "show_label" in R && t(9, d = R.show_label), "show_download_button" in R && t(10, h = R.show_download_button), "show_minimap" in R && t(11, f = R.show_minimap), "container" in R && t(12, m = R.container), "scale" in R && t(13, g = R.scale), "min_width" in R && t(14, p = R.min_width), "loading_status" in R && t(1, _ = R.loading_status), "autoplay" in R && t(23, y = R.autoplay), "waveform_options" in R && t(15, v = R.waveform_options), "pending" in R && t(16, C = R.pending), "streaming" in R && t(17, M = R.streaming), "gradio" in R && t(18, k = R.gradio);
  }, i.$$.update = () => {
    i.$$.dirty[0] & /*value, initial_value*/
    33554433 && a && b === null && t(25, b = a), i.$$.dirty[0] & /*value, old_value, gradio*/
    17039361 && JSON.stringify(a) !== JSON.stringify(P) && (t(24, P = a), k.dispatch("change")), i.$$.dirty[0] & /*active_source, sources*/
    524352 && !D && l && t(19, D = l[0]), i.$$.dirty[0] & /*waveform_options, autoplay*/
    8421376 && t(21, U = {
      height: 50,
      waveColor: v.waveform_color || "#9ca3af",
      progressColor: v.waveform_progress_color || "#f97316",
      barWidth: 2,
      barGap: 3,
      cursorWidth: 2,
      cursorColor: "#ddd5e9",
      autoplay: y,
      barRadius: 10,
      dragToSeek: !0,
      normalize: !0,
      minPxPerSec: 20,
      mediaControls: v.show_controls
    });
  }, [
    a,
    _,
    n,
    o,
    r,
    s,
    l,
    u,
    c,
    d,
    h,
    f,
    m,
    g,
    p,
    v,
    C,
    M,
    k,
    D,
    E,
    U,
    T,
    y,
    P,
    b,
    j,
    V,
    Q,
    q,
    I,
    H,
    G,
    F,
    K,
    x,
    A,
    S,
    W,
    z,
    O,
    w,
    L,
    B
  ];
}
class xv extends ov {
  constructor(e) {
    super(), dv(
      this,
      e,
      bv,
      vv,
      fv,
      {
        elem_id: 2,
        elem_classes: 3,
        visible: 4,
        interactive: 5,
        value: 0,
        sources: 6,
        label: 7,
        root: 8,
        show_label: 9,
        show_download_button: 10,
        show_minimap: 11,
        container: 12,
        scale: 13,
        min_width: 14,
        loading_status: 1,
        autoplay: 23,
        waveform_options: 15,
        pending: 16,
        streaming: 17,
        gradio: 18
      },
      null,
      [-1, -1]
    );
  }
  get elem_id() {
    return this.$$.ctx[2];
  }
  set elem_id(e) {
    this.$$set({ elem_id: e }), _e();
  }
  get elem_classes() {
    return this.$$.ctx[3];
  }
  set elem_classes(e) {
    this.$$set({ elem_classes: e }), _e();
  }
  get visible() {
    return this.$$.ctx[4];
  }
  set visible(e) {
    this.$$set({ visible: e }), _e();
  }
  get interactive() {
    return this.$$.ctx[5];
  }
  set interactive(e) {
    this.$$set({ interactive: e }), _e();
  }
  get value() {
    return this.$$.ctx[0];
  }
  set value(e) {
    this.$$set({ value: e }), _e();
  }
  get sources() {
    return this.$$.ctx[6];
  }
  set sources(e) {
    this.$$set({ sources: e }), _e();
  }
  get label() {
    return this.$$.ctx[7];
  }
  set label(e) {
    this.$$set({ label: e }), _e();
  }
  get root() {
    return this.$$.ctx[8];
  }
  set root(e) {
    this.$$set({ root: e }), _e();
  }
  get show_label() {
    return this.$$.ctx[9];
  }
  set show_label(e) {
    this.$$set({ show_label: e }), _e();
  }
  get show_download_button() {
    return this.$$.ctx[10];
  }
  set show_download_button(e) {
    this.$$set({ show_download_button: e }), _e();
  }
  get show_minimap() {
    return this.$$.ctx[11];
  }
  set show_minimap(e) {
    this.$$set({ show_minimap: e }), _e();
  }
  get container() {
    return this.$$.ctx[12];
  }
  set container(e) {
    this.$$set({ container: e }), _e();
  }
  get scale() {
    return this.$$.ctx[13];
  }
  set scale(e) {
    this.$$set({ scale: e }), _e();
  }
  get min_width() {
    return this.$$.ctx[14];
  }
  set min_width(e) {
    this.$$set({ min_width: e }), _e();
  }
  get loading_status() {
    return this.$$.ctx[1];
  }
  set loading_status(e) {
    this.$$set({ loading_status: e }), _e();
  }
  get autoplay() {
    return this.$$.ctx[23];
  }
  set autoplay(e) {
    this.$$set({ autoplay: e }), _e();
  }
  get waveform_options() {
    return this.$$.ctx[15];
  }
  set waveform_options(e) {
    this.$$set({ waveform_options: e }), _e();
  }
  get pending() {
    return this.$$.ctx[16];
  }
  set pending(e) {
    this.$$set({ pending: e }), _e();
  }
  get streaming() {
    return this.$$.ctx[17];
  }
  set streaming(e) {
    this.$$set({ streaming: e }), _e();
  }
  get gradio() {
    return this.$$.ctx[18];
  }
  set gradio(e) {
    this.$$set({ gradio: e }), _e();
  }
}
const {
  SvelteComponent: wv,
  append: yv,
  attr: kv,
  detach: Cv,
  element: Sv,
  init: Ev,
  insert: Dv,
  noop: ga,
  safe_not_equal: Rv,
  set_data: Mv,
  text: Lv,
  toggle_class: Pn
} = window.__gradio__svelte__internal;
function Ov(i) {
  let e, t;
  return {
    c() {
      e = Sv("div"), t = Lv(
        /*value*/
        i[0]
      ), kv(e, "class", "svelte-1gecy8w"), Pn(
        e,
        "table",
        /*type*/
        i[1] === "table"
      ), Pn(
        e,
        "gallery",
        /*type*/
        i[1] === "gallery"
      ), Pn(
        e,
        "selected",
        /*selected*/
        i[2]
      );
    },
    m(n, o) {
      Dv(n, e, o), yv(e, t);
    },
    p(n, [o]) {
      o & /*value*/
      1 && Mv(
        t,
        /*value*/
        n[0]
      ), o & /*type*/
      2 && Pn(
        e,
        "table",
        /*type*/
        n[1] === "table"
      ), o & /*type*/
      2 && Pn(
        e,
        "gallery",
        /*type*/
        n[1] === "gallery"
      ), o & /*selected*/
      4 && Pn(
        e,
        "selected",
        /*selected*/
        n[2]
      );
    },
    i: ga,
    o: ga,
    d(n) {
      n && Cv(e);
    }
  };
}
function Pv(i, e, t) {
  let { value: n } = e, { type: o } = e, { selected: r = !1 } = e;
  return i.$$set = (s) => {
    "value" in s && t(0, n = s.value), "type" in s && t(1, o = s.type), "selected" in s && t(2, r = s.selected);
  }, [n, o, r];
}
class eb extends wv {
  constructor(e) {
    super(), Ev(this, e, Pv, Ov, Rv, { value: 0, type: 1, selected: 2 });
  }
}
export {
  eb as BaseExample,
  gg as BaseInteractiveAudio,
  au as BasePlayer,
  H_ as BaseStaticAudio,
  xv as default
};
