const {
  SvelteComponent: Wo,
  append: Zi,
  attr: di,
  create_component: Vo,
  destroy_component: qo,
  detach: Yo,
  element: br,
  init: Zo,
  insert: Qo,
  mount_component: Jo,
  safe_not_equal: Ko,
  set_data: $o,
  space: es,
  text: ts,
  toggle_class: Ge,
  transition_in: is,
  transition_out: ns
} = window.__gradio__svelte__internal;
function rs(t) {
  let e, i, n, r, a, o;
  return n = new /*Icon*/
  t[1]({}), {
    c() {
      e = br("label"), i = br("span"), Vo(n.$$.fragment), r = es(), a = ts(
        /*label*/
        t[0]
      ), di(i, "class", "svelte-9gxdi0"), di(e, "for", ""), di(e, "data-testid", "block-label"), di(e, "class", "svelte-9gxdi0"), Ge(e, "hide", !/*show_label*/
      t[2]), Ge(e, "sr-only", !/*show_label*/
      t[2]), Ge(
        e,
        "float",
        /*float*/
        t[4]
      ), Ge(
        e,
        "hide-label",
        /*disable*/
        t[3]
      );
    },
    m(s, l) {
      Qo(s, e, l), Zi(e, i), Jo(n, i, null), Zi(e, r), Zi(e, a), o = !0;
    },
    p(s, [l]) {
      (!o || l & /*label*/
      1) && $o(
        a,
        /*label*/
        s[0]
      ), (!o || l & /*show_label*/
      4) && Ge(e, "hide", !/*show_label*/
      s[2]), (!o || l & /*show_label*/
      4) && Ge(e, "sr-only", !/*show_label*/
      s[2]), (!o || l & /*float*/
      16) && Ge(
        e,
        "float",
        /*float*/
        s[4]
      ), (!o || l & /*disable*/
      8) && Ge(
        e,
        "hide-label",
        /*disable*/
        s[3]
      );
    },
    i(s) {
      o || (is(n.$$.fragment, s), o = !0);
    },
    o(s) {
      ns(n.$$.fragment, s), o = !1;
    },
    d(s) {
      s && Yo(e), qo(n);
    }
  };
}
function as(t, e, i) {
  let { label: n = null } = e, { Icon: r } = e, { show_label: a = !0 } = e, { disable: o = !1 } = e, { float: s = !0 } = e;
  return t.$$set = (l) => {
    "label" in l && i(0, n = l.label), "Icon" in l && i(1, r = l.Icon), "show_label" in l && i(2, a = l.show_label), "disable" in l && i(3, o = l.disable), "float" in l && i(4, s = l.float);
  }, [n, r, a, o, s];
}
class os extends Wo {
  constructor(e) {
    super(), Zo(this, e, as, rs, Ko, {
      label: 0,
      Icon: 1,
      show_label: 2,
      disable: 3,
      float: 4
    });
  }
}
const {
  SvelteComponent: ss,
  append: Tn,
  attr: it,
  bubble: ls,
  create_component: hs,
  destroy_component: us,
  detach: ja,
  element: Sn,
  init: cs,
  insert: Xa,
  listen: fs,
  mount_component: ds,
  safe_not_equal: ms,
  set_data: _s,
  space: ps,
  text: gs,
  toggle_class: ze,
  transition_in: bs,
  transition_out: vs
} = window.__gradio__svelte__internal;
function vr(t) {
  let e, i;
  return {
    c() {
      e = Sn("span"), i = gs(
        /*label*/
        t[1]
      ), it(e, "class", "svelte-xtz2g8");
    },
    m(n, r) {
      Xa(n, e, r), Tn(e, i);
    },
    p(n, r) {
      r & /*label*/
      2 && _s(
        i,
        /*label*/
        n[1]
      );
    },
    d(n) {
      n && ja(e);
    }
  };
}
function ws(t) {
  let e, i, n, r, a, o, s, l = (
    /*show_label*/
    t[2] && vr(t)
  );
  return r = new /*Icon*/
  t[0]({}), {
    c() {
      e = Sn("button"), l && l.c(), i = ps(), n = Sn("div"), hs(r.$$.fragment), it(n, "class", "svelte-xtz2g8"), ze(
        n,
        "small",
        /*size*/
        t[4] === "small"
      ), ze(
        n,
        "large",
        /*size*/
        t[4] === "large"
      ), it(
        e,
        "aria-label",
        /*label*/
        t[1]
      ), it(
        e,
        "title",
        /*label*/
        t[1]
      ), it(e, "class", "svelte-xtz2g8"), ze(
        e,
        "pending",
        /*pending*/
        t[3]
      ), ze(
        e,
        "padded",
        /*padded*/
        t[5]
      );
    },
    m(h, u) {
      Xa(h, e, u), l && l.m(e, null), Tn(e, i), Tn(e, n), ds(r, n, null), a = !0, o || (s = fs(
        e,
        "click",
        /*click_handler*/
        t[6]
      ), o = !0);
    },
    p(h, [u]) {
      /*show_label*/
      h[2] ? l ? l.p(h, u) : (l = vr(h), l.c(), l.m(e, i)) : l && (l.d(1), l = null), (!a || u & /*size*/
      16) && ze(
        n,
        "small",
        /*size*/
        h[4] === "small"
      ), (!a || u & /*size*/
      16) && ze(
        n,
        "large",
        /*size*/
        h[4] === "large"
      ), (!a || u & /*label*/
      2) && it(
        e,
        "aria-label",
        /*label*/
        h[1]
      ), (!a || u & /*label*/
      2) && it(
        e,
        "title",
        /*label*/
        h[1]
      ), (!a || u & /*pending*/
      8) && ze(
        e,
        "pending",
        /*pending*/
        h[3]
      ), (!a || u & /*padded*/
      32) && ze(
        e,
        "padded",
        /*padded*/
        h[5]
      );
    },
    i(h) {
      a || (bs(r.$$.fragment, h), a = !0);
    },
    o(h) {
      vs(r.$$.fragment, h), a = !1;
    },
    d(h) {
      h && ja(e), l && l.d(), us(r), o = !1, s();
    }
  };
}
function ys(t, e, i) {
  let { Icon: n } = e, { label: r = "" } = e, { show_label: a = !1 } = e, { pending: o = !1 } = e, { size: s = "small" } = e, { padded: l = !0 } = e;
  function h(u) {
    ls.call(this, t, u);
  }
  return t.$$set = (u) => {
    "Icon" in u && i(0, n = u.Icon), "label" in u && i(1, r = u.label), "show_label" in u && i(2, a = u.show_label), "pending" in u && i(3, o = u.pending), "size" in u && i(4, s = u.size), "padded" in u && i(5, l = u.padded);
  }, [n, r, a, o, s, l, h];
}
class nt extends ss {
  constructor(e) {
    super(), cs(this, e, ys, ws, ms, {
      Icon: 0,
      label: 1,
      show_label: 2,
      pending: 3,
      size: 4,
      padded: 5
    });
  }
}
const {
  SvelteComponent: Es,
  append: wr,
  attr: Ze,
  detach: ks,
  init: Ts,
  insert: Ss,
  noop: Qi,
  safe_not_equal: Cs,
  svg_element: Ji
} = window.__gradio__svelte__internal;
function Ms(t) {
  let e, i, n;
  return {
    c() {
      e = Ji("svg"), i = Ji("path"), n = Ji("path"), Ze(i, "d", "M28.828 3.172a4.094 4.094 0 0 0-5.656 0L4.05 22.292A6.954 6.954 0 0 0 2 27.242V30h2.756a6.952 6.952 0 0 0 4.95-2.05L28.828 8.829a3.999 3.999 0 0 0 0-5.657zM10.91 18.26l2.829 2.829l-2.122 2.121l-2.828-2.828zm-2.619 8.276A4.966 4.966 0 0 1 4.756 28H4v-.759a4.967 4.967 0 0 1 1.464-3.535l1.91-1.91l2.829 2.828zM27.415 7.414l-12.261 12.26l-2.829-2.828l12.262-12.26a2.047 2.047 0 0 1 2.828 0a2 2 0 0 1 0 2.828z"), Ze(i, "fill", "currentColor"), Ze(n, "d", "M6.5 15a3.5 3.5 0 0 1-2.475-5.974l3.5-3.5a1.502 1.502 0 0 0 0-2.121a1.537 1.537 0 0 0-2.121 0L3.415 5.394L2 3.98l1.99-1.988a3.585 3.585 0 0 1 4.95 0a3.504 3.504 0 0 1 0 4.949L5.439 10.44a1.502 1.502 0 0 0 0 2.121a1.537 1.537 0 0 0 2.122 0l4.024-4.024L13 9.95l-4.025 4.024A3.475 3.475 0 0 1 6.5 15z"), Ze(n, "fill", "currentColor"), Ze(e, "width", "100%"), Ze(e, "height", "100%"), Ze(e, "viewBox", "0 0 32 32");
    },
    m(r, a) {
      Ss(r, e, a), wr(e, i), wr(e, n);
    },
    p: Qi,
    i: Qi,
    o: Qi,
    d(r) {
      r && ks(e);
    }
  };
}
class As extends Es {
  constructor(e) {
    super(), Ts(this, e, null, Ms, Cs, {});
  }
}
const {
  SvelteComponent: Os,
  append: yr,
  attr: fe,
  detach: Ds,
  init: Bs,
  insert: Hs,
  noop: Ki,
  safe_not_equal: Is,
  svg_element: $i
} = window.__gradio__svelte__internal;
function Ns(t) {
  let e, i, n;
  return {
    c() {
      e = $i("svg"), i = $i("path"), n = $i("circle"), fe(i, "d", "M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"), fe(n, "cx", "12"), fe(n, "cy", "13"), fe(n, "r", "4"), fe(e, "xmlns", "http://www.w3.org/2000/svg"), fe(e, "width", "100%"), fe(e, "height", "100%"), fe(e, "viewBox", "0 0 24 24"), fe(e, "fill", "none"), fe(e, "stroke", "currentColor"), fe(e, "stroke-width", "1.5"), fe(e, "stroke-linecap", "round"), fe(e, "stroke-linejoin", "round"), fe(e, "class", "feather feather-camera");
    },
    m(r, a) {
      Hs(r, e, a), yr(e, i), yr(e, n);
    },
    p: Ki,
    i: Ki,
    o: Ki,
    d(r) {
      r && Ds(e);
    }
  };
}
class Rs extends Os {
  constructor(e) {
    super(), Bs(this, e, null, Ns, Is, {});
  }
}
const {
  SvelteComponent: xs,
  append: Ps,
  attr: _e,
  detach: Ls,
  init: Us,
  insert: Gs,
  noop: en,
  safe_not_equal: zs,
  svg_element: Er
} = window.__gradio__svelte__internal;
function Fs(t) {
  let e, i;
  return {
    c() {
      e = Er("svg"), i = Er("circle"), _e(i, "cx", "12"), _e(i, "cy", "12"), _e(i, "r", "10"), _e(e, "xmlns", "http://www.w3.org/2000/svg"), _e(e, "width", "100%"), _e(e, "height", "100%"), _e(e, "viewBox", "0 0 24 24"), _e(e, "fill", "red"), _e(e, "stroke", "red"), _e(e, "stroke-width", "1.5"), _e(e, "stroke-linecap", "round"), _e(e, "stroke-linejoin", "round"), _e(e, "class", "feather feather-circle");
    },
    m(n, r) {
      Gs(n, e, r), Ps(e, i);
    },
    p: en,
    i: en,
    o: en,
    d(n) {
      n && Ls(e);
    }
  };
}
class js extends xs {
  constructor(e) {
    super(), Us(this, e, null, Fs, zs, {});
  }
}
const {
  SvelteComponent: Xs,
  append: tn,
  attr: Se,
  detach: Ws,
  init: Vs,
  insert: qs,
  noop: nn,
  safe_not_equal: Ys,
  set_style: De,
  svg_element: mi
} = window.__gradio__svelte__internal;
function Zs(t) {
  let e, i, n, r;
  return {
    c() {
      e = mi("svg"), i = mi("g"), n = mi("path"), r = mi("path"), Se(n, "d", "M18,6L6.087,17.913"), De(n, "fill", "none"), De(n, "fill-rule", "nonzero"), De(n, "stroke-width", "2px"), Se(i, "transform", "matrix(1.14096,-0.140958,-0.140958,1.14096,-0.0559523,0.0559523)"), Se(r, "d", "M4.364,4.364L19.636,19.636"), De(r, "fill", "none"), De(r, "fill-rule", "nonzero"), De(r, "stroke-width", "2px"), Se(e, "width", "100%"), Se(e, "height", "100%"), Se(e, "viewBox", "0 0 24 24"), Se(e, "version", "1.1"), Se(e, "xmlns", "http://www.w3.org/2000/svg"), Se(e, "xmlns:xlink", "http://www.w3.org/1999/xlink"), Se(e, "xml:space", "preserve"), Se(e, "stroke", "currentColor"), De(e, "fill-rule", "evenodd"), De(e, "clip-rule", "evenodd"), De(e, "stroke-linecap", "round"), De(e, "stroke-linejoin", "round");
    },
    m(a, o) {
      qs(a, e, o), tn(e, i), tn(i, n), tn(e, r);
    },
    p: nn,
    i: nn,
    o: nn,
    d(a) {
      a && Ws(e);
    }
  };
}
class Wa extends Xs {
  constructor(e) {
    super(), Vs(this, e, null, Zs, Ys, {});
  }
}
const {
  SvelteComponent: Qs,
  append: ct,
  attr: z,
  detach: Js,
  init: Ks,
  insert: $s,
  noop: rn,
  safe_not_equal: el,
  svg_element: Qe
} = window.__gradio__svelte__internal;
function tl(t) {
  let e, i, n, r, a, o, s;
  return {
    c() {
      e = Qe("svg"), i = Qe("circle"), n = Qe("circle"), r = Qe("circle"), a = Qe("circle"), o = Qe("circle"), s = Qe("path"), z(i, "cx", "10"), z(i, "cy", "12"), z(i, "r", "2"), z(i, "fill", "currentColor"), z(n, "cx", "16"), z(n, "cy", "9"), z(n, "r", "2"), z(n, "fill", "currentColor"), z(r, "cx", "22"), z(r, "cy", "12"), z(r, "r", "2"), z(r, "fill", "currentColor"), z(a, "cx", "23"), z(a, "cy", "18"), z(a, "r", "2"), z(a, "fill", "currentColor"), z(o, "cx", "19"), z(o, "cy", "23"), z(o, "r", "2"), z(o, "fill", "currentColor"), z(s, "fill", "currentColor"), z(s, "d", "M16.54 2A14 14 0 0 0 2 16a4.82 4.82 0 0 0 6.09 4.65l1.12-.31a3 3 0 0 1 3.79 2.9V27a3 3 0 0 0 3 3a14 14 0 0 0 14-14.54A14.05 14.05 0 0 0 16.54 2Zm8.11 22.31A11.93 11.93 0 0 1 16 28a1 1 0 0 1-1-1v-3.76a5 5 0 0 0-5-5a5.07 5.07 0 0 0-1.33.18l-1.12.31A2.82 2.82 0 0 1 4 16A12 12 0 0 1 16.47 4A12.18 12.18 0 0 1 28 15.53a11.89 11.89 0 0 1-3.35 8.79Z"), z(e, "width", "100%"), z(e, "height", "100%"), z(e, "viewBox", "0 0 32 32");
    },
    m(l, h) {
      $s(l, e, h), ct(e, i), ct(e, n), ct(e, r), ct(e, a), ct(e, o), ct(e, s);
    },
    p: rn,
    i: rn,
    o: rn,
    d(l) {
      l && Js(e);
    }
  };
}
class il extends Qs {
  constructor(e) {
    super(), Ks(this, e, null, tl, el, {});
  }
}
const {
  SvelteComponent: nl,
  append: rl,
  attr: Ce,
  detach: al,
  init: ol,
  insert: sl,
  noop: an,
  safe_not_equal: ll,
  svg_element: kr
} = window.__gradio__svelte__internal;
function hl(t) {
  let e, i;
  return {
    c() {
      e = kr("svg"), i = kr("path"), Ce(i, "d", "M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"), 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-edit-2");
    },
    m(n, r) {
      sl(n, e, r), rl(e, i);
    },
    p: an,
    i: an,
    o: an,
    d(n) {
      n && al(e);
    }
  };
}
class ul extends nl {
  constructor(e) {
    super(), ol(this, e, null, hl, ll, {});
  }
}
const {
  SvelteComponent: cl,
  append: fl,
  attr: ft,
  detach: dl,
  init: ml,
  insert: _l,
  noop: on,
  safe_not_equal: pl,
  svg_element: Tr
} = window.__gradio__svelte__internal;
function gl(t) {
  let e, i;
  return {
    c() {
      e = Tr("svg"), i = Tr("path"), ft(i, "fill", "currentColor"), ft(i, "d", "M7 27h23v2H7zm20.38-16.49l-7.93-7.92a2 2 0 0 0-2.83 0l-14 14a2 2 0 0 0 0 2.83L7.13 24h9.59l10.66-10.66a2 2 0 0 0 0-2.83zM15.89 22H8l-4-4l6.31-6.31l7.93 7.92zm3.76-3.76l-7.92-7.93L18 4l8 7.93z"), ft(e, "xmlns", "http://www.w3.org/2000/svg"), ft(e, "width", "100%"), ft(e, "height", "100%"), ft(e, "viewBox", "0 0 32 32");
    },
    m(n, r) {
      _l(n, e, r), fl(e, i);
    },
    p: on,
    i: on,
    o: on,
    d(n) {
      n && dl(e);
    }
  };
}
class bl extends cl {
  constructor(e) {
    super(), ml(this, e, null, gl, pl, {});
  }
}
const {
  SvelteComponent: vl,
  append: sn,
  attr: J,
  detach: wl,
  init: yl,
  insert: El,
  noop: ln,
  safe_not_equal: kl,
  svg_element: _i
} = window.__gradio__svelte__internal;
function Tl(t) {
  let e, i, n, r;
  return {
    c() {
      e = _i("svg"), i = _i("rect"), n = _i("circle"), r = _i("polyline"), J(i, "x", "3"), J(i, "y", "3"), J(i, "width", "18"), J(i, "height", "18"), J(i, "rx", "2"), J(i, "ry", "2"), J(n, "cx", "8.5"), J(n, "cy", "8.5"), J(n, "r", "1.5"), J(r, "points", "21 15 16 10 5 21"), J(e, "xmlns", "http://www.w3.org/2000/svg"), J(e, "width", "100%"), J(e, "height", "100%"), J(e, "viewBox", "0 0 24 24"), J(e, "fill", "none"), J(e, "stroke", "currentColor"), J(e, "stroke-width", "1.5"), J(e, "stroke-linecap", "round"), J(e, "stroke-linejoin", "round"), J(e, "class", "feather feather-image");
    },
    m(a, o) {
      El(a, e, o), sn(e, i), sn(e, n), sn(e, r);
    },
    p: ln,
    i: ln,
    o: ln,
    d(a) {
      a && wl(e);
    }
  };
}
class Sr extends vl {
  constructor(e) {
    super(), yl(this, e, null, Tl, kl, {});
  }
}
const {
  SvelteComponent: Sl,
  append: Cl,
  attr: Me,
  detach: Ml,
  init: Al,
  insert: Ol,
  noop: hn,
  safe_not_equal: Dl,
  svg_element: Cr
} = window.__gradio__svelte__internal;
function Bl(t) {
  let e, i;
  return {
    c() {
      e = Cr("svg"), i = Cr("path"), Me(i, "d", "M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"), 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", "1.5"), Me(e, "stroke-linecap", "round"), Me(e, "stroke-linejoin", "round"), Me(e, "class", "feather feather-edit-2");
    },
    m(n, r) {
      Ol(n, e, r), Cl(e, i);
    },
    p: hn,
    i: hn,
    o: hn,
    d(n) {
      n && Ml(e);
    }
  };
}
let Mr = class extends Sl {
  constructor(e) {
    super(), Al(this, e, null, Bl, Dl, {});
  }
};
const {
  SvelteComponent: Hl,
  append: Il,
  attr: le,
  detach: Nl,
  init: Rl,
  insert: xl,
  noop: un,
  safe_not_equal: Pl,
  svg_element: Ar
} = window.__gradio__svelte__internal;
function Ll(t) {
  let e, i;
  return {
    c() {
      e = Ar("svg"), i = Ar("rect"), le(i, "x", "3"), le(i, "y", "3"), le(i, "width", "18"), le(i, "height", "18"), le(i, "rx", "2"), le(i, "ry", "2"), le(e, "xmlns", "http://www.w3.org/2000/svg"), le(e, "width", "100%"), le(e, "height", "100%"), le(e, "viewBox", "0 0 24 24"), le(e, "fill", "red"), le(e, "stroke", "red"), le(e, "stroke-width", "1.5"), le(e, "stroke-linecap", "round"), le(e, "stroke-linejoin", "round"), le(e, "class", "feather feather-square");
    },
    m(n, r) {
      xl(n, e, r), Il(e, i);
    },
    p: un,
    i: un,
    o: un,
    d(n) {
      n && Nl(e);
    }
  };
}
class Ul extends Hl {
  constructor(e) {
    super(), Rl(this, e, null, Ll, Pl, {});
  }
}
const {
  SvelteComponent: Gl,
  append: Or,
  attr: we,
  detach: zl,
  init: Fl,
  insert: jl,
  noop: cn,
  safe_not_equal: Xl,
  svg_element: fn
} = window.__gradio__svelte__internal;
function Wl(t) {
  let e, i, n;
  return {
    c() {
      e = fn("svg"), i = fn("polyline"), n = fn("path"), we(i, "points", "1 4 1 10 7 10"), we(n, "d", "M3.51 15a9 9 0 1 0 2.13-9.36L1 10"), we(e, "xmlns", "http://www.w3.org/2000/svg"), we(e, "width", "100%"), we(e, "height", "100%"), we(e, "viewBox", "0 0 24 24"), we(e, "fill", "none"), we(e, "stroke", "currentColor"), we(e, "stroke-width", "2"), we(e, "stroke-linecap", "round"), we(e, "stroke-linejoin", "round"), we(e, "class", "feather feather-rotate-ccw");
    },
    m(r, a) {
      jl(r, e, a), Or(e, i), Or(e, n);
    },
    p: cn,
    i: cn,
    o: cn,
    d(r) {
      r && zl(e);
    }
  };
}
class Vl extends Gl {
  constructor(e) {
    super(), Fl(this, e, null, Wl, Xl, {});
  }
}
const ql = [
  { 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 }
], Dr = {
  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"
  }
};
ql.reduce(
  (t, { color: e, primary: i, secondary: n }) => ({
    ...t,
    [e]: {
      primary: Dr[e][i],
      secondary: Dr[e][n]
    }
  }),
  {}
);
/*!
 * Cropper.js v1.6.1
 * https://fengyuanchen.github.io/cropperjs
 *
 * Copyright 2015-present Chen Fengyuan
 * Released under the MIT license
 *
 * Date: 2023-09-17T03:44:19.860Z
 */
function Br(t, e) {
  var i = Object.keys(t);
  if (Object.getOwnPropertySymbols) {
    var n = Object.getOwnPropertySymbols(t);
    e && (n = n.filter(function(r) {
      return Object.getOwnPropertyDescriptor(t, r).enumerable;
    })), i.push.apply(i, n);
  }
  return i;
}
function Va(t) {
  for (var e = 1; e < arguments.length; e++) {
    var i = arguments[e] != null ? arguments[e] : {};
    e % 2 ? Br(Object(i), !0).forEach(function(n) {
      Ql(t, n, i[n]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(i)) : Br(Object(i)).forEach(function(n) {
      Object.defineProperty(t, n, Object.getOwnPropertyDescriptor(i, n));
    });
  }
  return t;
}
function Cn(t) {
  "@babel/helpers - typeof";
  return Cn = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
    return typeof e;
  } : function(e) {
    return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
  }, Cn(t);
}
function Yl(t, e) {
  if (!(t instanceof e))
    throw new TypeError("Cannot call a class as a function");
}
function Hr(t, e) {
  for (var i = 0; i < e.length; i++) {
    var n = e[i];
    n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(t, Ya(n.key), n);
  }
}
function Zl(t, e, i) {
  return e && Hr(t.prototype, e), i && Hr(t, i), Object.defineProperty(t, "prototype", {
    writable: !1
  }), t;
}
function Ql(t, e, i) {
  return e = Ya(e), e in t ? Object.defineProperty(t, e, {
    value: i,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : t[e] = i, t;
}
function qa(t) {
  return Jl(t) || Kl(t) || $l(t) || eh();
}
function Jl(t) {
  if (Array.isArray(t))
    return Mn(t);
}
function Kl(t) {
  if (typeof Symbol < "u" && t[Symbol.iterator] != null || t["@@iterator"] != null)
    return Array.from(t);
}
function $l(t, e) {
  if (t) {
    if (typeof t == "string")
      return Mn(t, e);
    var i = Object.prototype.toString.call(t).slice(8, -1);
    if (i === "Object" && t.constructor && (i = t.constructor.name), i === "Map" || i === "Set")
      return Array.from(t);
    if (i === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))
      return Mn(t, e);
  }
}
function Mn(t, e) {
  (e == null || e > t.length) && (e = t.length);
  for (var i = 0, n = new Array(e); i < e; i++)
    n[i] = t[i];
  return n;
}
function eh() {
  throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
function th(t, e) {
  if (typeof t != "object" || t === null)
    return t;
  var i = t[Symbol.toPrimitive];
  if (i !== void 0) {
    var n = i.call(t, e || "default");
    if (typeof n != "object")
      return n;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return (e === "string" ? String : Number)(t);
}
function Ya(t) {
  var e = th(t, "string");
  return typeof e == "symbol" ? e : String(e);
}
var Ni = typeof window < "u" && typeof window.document < "u", Ne = Ni ? window : {}, Jn = Ni && Ne.document.documentElement ? "ontouchstart" in Ne.document.documentElement : !1, Kn = Ni ? "PointerEvent" in Ne : !1, X = "cropper", $n = "all", Za = "crop", Qa = "move", Ja = "zoom", Je = "e", Ke = "w", dt = "s", Fe = "n", Lt = "ne", Ut = "nw", Gt = "se", zt = "sw", An = "".concat(X, "-crop"), Ir = "".concat(X, "-disabled"), me = "".concat(X, "-hidden"), Nr = "".concat(X, "-hide"), ih = "".concat(X, "-invisible"), Ci = "".concat(X, "-modal"), On = "".concat(X, "-move"), qt = "".concat(X, "Action"), pi = "".concat(X, "Preview"), er = "crop", Ka = "move", $a = "none", Dn = "crop", Bn = "cropend", Hn = "cropmove", In = "cropstart", Rr = "dblclick", nh = Jn ? "touchstart" : "mousedown", rh = Jn ? "touchmove" : "mousemove", ah = Jn ? "touchend touchcancel" : "mouseup", xr = Kn ? "pointerdown" : nh, Pr = Kn ? "pointermove" : rh, Lr = Kn ? "pointerup pointercancel" : ah, Ur = "ready", Gr = "resize", zr = "wheel", Nn = "zoom", Fr = "image/jpeg", oh = /^e|w|s|n|se|sw|ne|nw|all|crop|move|zoom$/, sh = /^data:/, lh = /^data:image\/jpeg;base64,/, hh = /^img|canvas$/i, eo = 200, to = 100, jr = {
  // Define the view mode of the cropper
  viewMode: 0,
  // 0, 1, 2, 3
  // Define the dragging mode of the cropper
  dragMode: er,
  // 'crop', 'move' or 'none'
  // Define the initial aspect ratio of the crop box
  initialAspectRatio: NaN,
  // Define the aspect ratio of the crop box
  aspectRatio: NaN,
  // An object with the previous cropping result data
  data: null,
  // A selector for adding extra containers to preview
  preview: "",
  // Re-render the cropper when resize the window
  responsive: !0,
  // Restore the cropped area after resize the window
  restore: !0,
  // Check if the current image is a cross-origin image
  checkCrossOrigin: !0,
  // Check the current image's Exif Orientation information
  checkOrientation: !0,
  // Show the black modal
  modal: !0,
  // Show the dashed lines for guiding
  guides: !0,
  // Show the center indicator for guiding
  center: !0,
  // Show the white modal to highlight the crop box
  highlight: !0,
  // Show the grid background
  background: !0,
  // Enable to crop the image automatically when initialize
  autoCrop: !0,
  // Define the percentage of automatic cropping area when initializes
  autoCropArea: 0.8,
  // Enable to move the image
  movable: !0,
  // Enable to rotate the image
  rotatable: !0,
  // Enable to scale the image
  scalable: !0,
  // Enable to zoom the image
  zoomable: !0,
  // Enable to zoom the image by dragging touch
  zoomOnTouch: !0,
  // Enable to zoom the image by wheeling mouse
  zoomOnWheel: !0,
  // Define zoom ratio when zoom the image by wheeling mouse
  wheelZoomRatio: 0.1,
  // Enable to move the crop box
  cropBoxMovable: !0,
  // Enable to resize the crop box
  cropBoxResizable: !0,
  // Toggle drag mode between "crop" and "move" when click twice on the cropper
  toggleDragModeOnDblclick: !0,
  // Size limitation
  minCanvasWidth: 0,
  minCanvasHeight: 0,
  minCropBoxWidth: 0,
  minCropBoxHeight: 0,
  minContainerWidth: eo,
  minContainerHeight: to,
  // Shortcuts of events
  ready: null,
  cropstart: null,
  cropmove: null,
  cropend: null,
  crop: null,
  zoom: null
}, uh = '<div class="cropper-container" touch-action="none"><div class="cropper-wrap-box"><div class="cropper-canvas"></div></div><div class="cropper-drag-box"></div><div class="cropper-crop-box"><span class="cropper-view-box"></span><span class="cropper-dashed dashed-h"></span><span class="cropper-dashed dashed-v"></span><span class="cropper-center"></span><span class="cropper-face"></span><span class="cropper-line line-e" data-cropper-action="e"></span><span class="cropper-line line-n" data-cropper-action="n"></span><span class="cropper-line line-w" data-cropper-action="w"></span><span class="cropper-line line-s" data-cropper-action="s"></span><span class="cropper-point point-e" data-cropper-action="e"></span><span class="cropper-point point-n" data-cropper-action="n"></span><span class="cropper-point point-w" data-cropper-action="w"></span><span class="cropper-point point-s" data-cropper-action="s"></span><span class="cropper-point point-ne" data-cropper-action="ne"></span><span class="cropper-point point-nw" data-cropper-action="nw"></span><span class="cropper-point point-sw" data-cropper-action="sw"></span><span class="cropper-point point-se" data-cropper-action="se"></span></div></div>', ch = Number.isNaN || Ne.isNaN;
function A(t) {
  return typeof t == "number" && !ch(t);
}
var Xr = function(e) {
  return e > 0 && e < 1 / 0;
};
function dn(t) {
  return typeof t > "u";
}
function rt(t) {
  return Cn(t) === "object" && t !== null;
}
var fh = Object.prototype.hasOwnProperty;
function bt(t) {
  if (!rt(t))
    return !1;
  try {
    var e = t.constructor, i = e.prototype;
    return e && i && fh.call(i, "isPrototypeOf");
  } catch {
    return !1;
  }
}
function de(t) {
  return typeof t == "function";
}
var dh = Array.prototype.slice;
function io(t) {
  return Array.from ? Array.from(t) : dh.call(t);
}
function $(t, e) {
  return t && de(e) && (Array.isArray(t) || A(t.length) ? io(t).forEach(function(i, n) {
    e.call(t, i, n, t);
  }) : rt(t) && Object.keys(t).forEach(function(i) {
    e.call(t, t[i], i, t);
  })), t;
}
var V = Object.assign || function(e) {
  for (var i = arguments.length, n = new Array(i > 1 ? i - 1 : 0), r = 1; r < i; r++)
    n[r - 1] = arguments[r];
  return rt(e) && n.length > 0 && n.forEach(function(a) {
    rt(a) && Object.keys(a).forEach(function(o) {
      e[o] = a[o];
    });
  }), e;
}, mh = /\.\d*(?:0|9){12}\d*$/;
function wt(t) {
  var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1e11;
  return mh.test(t) ? Math.round(t * e) / e : t;
}
var _h = /^width|height|left|top|marginLeft|marginTop$/;
function je(t, e) {
  var i = t.style;
  $(e, function(n, r) {
    _h.test(r) && A(n) && (n = "".concat(n, "px")), i[r] = n;
  });
}
function ph(t, e) {
  return t.classList ? t.classList.contains(e) : t.className.indexOf(e) > -1;
}
function ie(t, e) {
  if (e) {
    if (A(t.length)) {
      $(t, function(n) {
        ie(n, e);
      });
      return;
    }
    if (t.classList) {
      t.classList.add(e);
      return;
    }
    var i = t.className.trim();
    i ? i.indexOf(e) < 0 && (t.className = "".concat(i, " ").concat(e)) : t.className = e;
  }
}
function He(t, e) {
  if (e) {
    if (A(t.length)) {
      $(t, function(i) {
        He(i, e);
      });
      return;
    }
    if (t.classList) {
      t.classList.remove(e);
      return;
    }
    t.className.indexOf(e) >= 0 && (t.className = t.className.replace(e, ""));
  }
}
function vt(t, e, i) {
  if (e) {
    if (A(t.length)) {
      $(t, function(n) {
        vt(n, e, i);
      });
      return;
    }
    i ? ie(t, e) : He(t, e);
  }
}
var gh = /([a-z\d])([A-Z])/g;
function tr(t) {
  return t.replace(gh, "$1-$2").toLowerCase();
}
function Rn(t, e) {
  return rt(t[e]) ? t[e] : t.dataset ? t.dataset[e] : t.getAttribute("data-".concat(tr(e)));
}
function Yt(t, e, i) {
  rt(i) ? t[e] = i : t.dataset ? t.dataset[e] = i : t.setAttribute("data-".concat(tr(e)), i);
}
function bh(t, e) {
  if (rt(t[e]))
    try {
      delete t[e];
    } catch {
      t[e] = void 0;
    }
  else if (t.dataset)
    try {
      delete t.dataset[e];
    } catch {
      t.dataset[e] = void 0;
    }
  else
    t.removeAttribute("data-".concat(tr(e)));
}
var no = /\s\s*/, ro = function() {
  var t = !1;
  if (Ni) {
    var e = !1, i = function() {
    }, n = Object.defineProperty({}, "once", {
      get: function() {
        return t = !0, e;
      },
      /**
       * This setter can fix a `TypeError` in strict mode
       * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Getter_only}
       * @param {boolean} value - The value to set
       */
      set: function(a) {
        e = a;
      }
    });
    Ne.addEventListener("test", i, n), Ne.removeEventListener("test", i, n);
  }
  return t;
}();
function Ae(t, e, i) {
  var n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {}, r = i;
  e.trim().split(no).forEach(function(a) {
    if (!ro) {
      var o = t.listeners;
      o && o[a] && o[a][i] && (r = o[a][i], delete o[a][i], Object.keys(o[a]).length === 0 && delete o[a], Object.keys(o).length === 0 && delete t.listeners);
    }
    t.removeEventListener(a, r, n);
  });
}
function Ee(t, e, i) {
  var n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {}, r = i;
  e.trim().split(no).forEach(function(a) {
    if (n.once && !ro) {
      var o = t.listeners, s = o === void 0 ? {} : o;
      r = function() {
        delete s[a][i], t.removeEventListener(a, r, n);
        for (var h = arguments.length, u = new Array(h), f = 0; f < h; f++)
          u[f] = arguments[f];
        i.apply(t, u);
      }, s[a] || (s[a] = {}), s[a][i] && t.removeEventListener(a, s[a][i], n), s[a][i] = r, t.listeners = s;
    }
    t.addEventListener(a, r, n);
  });
}
function yt(t, e, i) {
  var n;
  return de(Event) && de(CustomEvent) ? n = new CustomEvent(e, {
    detail: i,
    bubbles: !0,
    cancelable: !0
  }) : (n = document.createEvent("CustomEvent"), n.initCustomEvent(e, !0, !0, i)), t.dispatchEvent(n);
}
function ao(t) {
  var e = t.getBoundingClientRect();
  return {
    left: e.left + (window.pageXOffset - document.documentElement.clientLeft),
    top: e.top + (window.pageYOffset - document.documentElement.clientTop)
  };
}
var mn = Ne.location, vh = /^(\w+:)\/\/([^:/?#]*):?(\d*)/i;
function Wr(t) {
  var e = t.match(vh);
  return e !== null && (e[1] !== mn.protocol || e[2] !== mn.hostname || e[3] !== mn.port);
}
function Vr(t) {
  var e = "timestamp=".concat((/* @__PURE__ */ new Date()).getTime());
  return t + (t.indexOf("?") === -1 ? "?" : "&") + e;
}
function Vt(t) {
  var e = t.rotate, i = t.scaleX, n = t.scaleY, r = t.translateX, a = t.translateY, o = [];
  A(r) && r !== 0 && o.push("translateX(".concat(r, "px)")), A(a) && a !== 0 && o.push("translateY(".concat(a, "px)")), A(e) && e !== 0 && o.push("rotate(".concat(e, "deg)")), A(i) && i !== 1 && o.push("scaleX(".concat(i, ")")), A(n) && n !== 1 && o.push("scaleY(".concat(n, ")"));
  var s = o.length ? o.join(" ") : "none";
  return {
    WebkitTransform: s,
    msTransform: s,
    transform: s
  };
}
function wh(t) {
  var e = Va({}, t), i = 0;
  return $(t, function(n, r) {
    delete e[r], $(e, function(a) {
      var o = Math.abs(n.startX - a.startX), s = Math.abs(n.startY - a.startY), l = Math.abs(n.endX - a.endX), h = Math.abs(n.endY - a.endY), u = Math.sqrt(o * o + s * s), f = Math.sqrt(l * l + h * h), c = (f - u) / u;
      Math.abs(c) > Math.abs(i) && (i = c);
    });
  }), i;
}
function gi(t, e) {
  var i = t.pageX, n = t.pageY, r = {
    endX: i,
    endY: n
  };
  return e ? r : Va({
    startX: i,
    startY: n
  }, r);
}
function yh(t) {
  var e = 0, i = 0, n = 0;
  return $(t, function(r) {
    var a = r.startX, o = r.startY;
    e += a, i += o, n += 1;
  }), e /= n, i /= n, {
    pageX: e,
    pageY: i
  };
}
function Xe(t) {
  var e = t.aspectRatio, i = t.height, n = t.width, r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "contain", a = Xr(n), o = Xr(i);
  if (a && o) {
    var s = i * e;
    r === "contain" && s > n || r === "cover" && s < n ? i = n / e : n = i * e;
  } else
    a ? i = n / e : o && (n = i * e);
  return {
    width: n,
    height: i
  };
}
function Eh(t) {
  var e = t.width, i = t.height, n = t.degree;
  if (n = Math.abs(n) % 180, n === 90)
    return {
      width: i,
      height: e
    };
  var r = n % 90 * Math.PI / 180, a = Math.sin(r), o = Math.cos(r), s = e * o + i * a, l = e * a + i * o;
  return n > 90 ? {
    width: l,
    height: s
  } : {
    width: s,
    height: l
  };
}
function kh(t, e, i, n) {
  var r = e.aspectRatio, a = e.naturalWidth, o = e.naturalHeight, s = e.rotate, l = s === void 0 ? 0 : s, h = e.scaleX, u = h === void 0 ? 1 : h, f = e.scaleY, c = f === void 0 ? 1 : f, d = i.aspectRatio, m = i.naturalWidth, p = i.naturalHeight, v = n.fillColor, k = v === void 0 ? "transparent" : v, T = n.imageSmoothingEnabled, S = T === void 0 ? !0 : T, I = n.imageSmoothingQuality, w = I === void 0 ? "low" : I, _ = n.maxWidth, E = _ === void 0 ? 1 / 0 : _, O = n.maxHeight, G = O === void 0 ? 1 / 0 : O, Z = n.minWidth, oe = Z === void 0 ? 0 : Z, se = n.minHeight, y = se === void 0 ? 0 : se, D = document.createElement("canvas"), F = D.getContext("2d"), Q = Xe({
    aspectRatio: d,
    width: E,
    height: G
  }), q = Xe({
    aspectRatio: d,
    width: oe,
    height: y
  }, "cover"), Y = Math.min(Q.width, Math.max(q.width, m)), ue = Math.min(Q.height, Math.max(q.height, p)), Le = Xe({
    aspectRatio: r,
    width: E,
    height: G
  }), Te = Xe({
    aspectRatio: r,
    width: oe,
    height: y
  }, "cover"), Ue = Math.min(Le.width, Math.max(Te.width, a)), st = Math.min(Le.height, Math.max(Te.height, o)), lt = [-Ue / 2, -st / 2, Ue, st];
  return D.width = wt(Y), D.height = wt(ue), F.fillStyle = k, F.fillRect(0, 0, Y, ue), F.save(), F.translate(Y / 2, ue / 2), F.rotate(l * Math.PI / 180), F.scale(u, c), F.imageSmoothingEnabled = S, F.imageSmoothingQuality = w, F.drawImage.apply(F, [t].concat(qa(lt.map(function(xt) {
    return Math.floor(wt(xt));
  })))), F.restore(), D;
}
var oo = String.fromCharCode;
function Th(t, e, i) {
  var n = "";
  i += e;
  for (var r = e; r < i; r += 1)
    n += oo(t.getUint8(r));
  return n;
}
var Sh = /^data:.*,/;
function Ch(t) {
  var e = t.replace(Sh, ""), i = atob(e), n = new ArrayBuffer(i.length), r = new Uint8Array(n);
  return $(r, function(a, o) {
    r[o] = i.charCodeAt(o);
  }), n;
}
function Mh(t, e) {
  for (var i = [], n = 8192, r = new Uint8Array(t); r.length > 0; )
    i.push(oo.apply(null, io(r.subarray(0, n)))), r = r.subarray(n);
  return "data:".concat(e, ";base64,").concat(btoa(i.join("")));
}
function Ah(t) {
  var e = new DataView(t), i;
  try {
    var n, r, a;
    if (e.getUint8(0) === 255 && e.getUint8(1) === 216)
      for (var o = e.byteLength, s = 2; s + 1 < o; ) {
        if (e.getUint8(s) === 255 && e.getUint8(s + 1) === 225) {
          r = s;
          break;
        }
        s += 1;
      }
    if (r) {
      var l = r + 4, h = r + 10;
      if (Th(e, l, 4) === "Exif") {
        var u = e.getUint16(h);
        if (n = u === 18761, (n || u === 19789) && e.getUint16(h + 2, n) === 42) {
          var f = e.getUint32(h + 4, n);
          f >= 8 && (a = h + f);
        }
      }
    }
    if (a) {
      var c = e.getUint16(a, n), d, m;
      for (m = 0; m < c; m += 1)
        if (d = a + m * 12 + 2, e.getUint16(d, n) === 274) {
          d += 8, i = e.getUint16(d, n), e.setUint16(d, 1, n);
          break;
        }
    }
  } catch {
    i = 1;
  }
  return i;
}
function Oh(t) {
  var e = 0, i = 1, n = 1;
  switch (t) {
    case 2:
      i = -1;
      break;
    case 3:
      e = -180;
      break;
    case 4:
      n = -1;
      break;
    case 5:
      e = 90, n = -1;
      break;
    case 6:
      e = 90;
      break;
    case 7:
      e = 90, i = -1;
      break;
    case 8:
      e = -90;
      break;
  }
  return {
    rotate: e,
    scaleX: i,
    scaleY: n
  };
}
var Dh = {
  render: function() {
    this.initContainer(), this.initCanvas(), this.initCropBox(), this.renderCanvas(), this.cropped && this.renderCropBox();
  },
  initContainer: function() {
    var e = this.element, i = this.options, n = this.container, r = this.cropper, a = Number(i.minContainerWidth), o = Number(i.minContainerHeight);
    ie(r, me), He(e, me);
    var s = {
      width: Math.max(n.offsetWidth, a >= 0 ? a : eo),
      height: Math.max(n.offsetHeight, o >= 0 ? o : to)
    };
    this.containerData = s, je(r, {
      width: s.width,
      height: s.height
    }), ie(e, me), He(r, me);
  },
  // Canvas (image wrapper)
  initCanvas: function() {
    var e = this.containerData, i = this.imageData, n = this.options.viewMode, r = Math.abs(i.rotate) % 180 === 90, a = r ? i.naturalHeight : i.naturalWidth, o = r ? i.naturalWidth : i.naturalHeight, s = a / o, l = e.width, h = e.height;
    e.height * s > e.width ? n === 3 ? l = e.height * s : h = e.width / s : n === 3 ? h = e.width / s : l = e.height * s;
    var u = {
      aspectRatio: s,
      naturalWidth: a,
      naturalHeight: o,
      width: l,
      height: h
    };
    this.canvasData = u, this.limited = n === 1 || n === 2, this.limitCanvas(!0, !0), u.width = Math.min(Math.max(u.width, u.minWidth), u.maxWidth), u.height = Math.min(Math.max(u.height, u.minHeight), u.maxHeight), u.left = (e.width - u.width) / 2, u.top = (e.height - u.height) / 2, u.oldLeft = u.left, u.oldTop = u.top, this.initialCanvasData = V({}, u);
  },
  limitCanvas: function(e, i) {
    var n = this.options, r = this.containerData, a = this.canvasData, o = this.cropBoxData, s = n.viewMode, l = a.aspectRatio, h = this.cropped && o;
    if (e) {
      var u = Number(n.minCanvasWidth) || 0, f = Number(n.minCanvasHeight) || 0;
      s > 1 ? (u = Math.max(u, r.width), f = Math.max(f, r.height), s === 3 && (f * l > u ? u = f * l : f = u / l)) : s > 0 && (u ? u = Math.max(u, h ? o.width : 0) : f ? f = Math.max(f, h ? o.height : 0) : h && (u = o.width, f = o.height, f * l > u ? u = f * l : f = u / l));
      var c = Xe({
        aspectRatio: l,
        width: u,
        height: f
      });
      u = c.width, f = c.height, a.minWidth = u, a.minHeight = f, a.maxWidth = 1 / 0, a.maxHeight = 1 / 0;
    }
    if (i)
      if (s > (h ? 0 : 1)) {
        var d = r.width - a.width, m = r.height - a.height;
        a.minLeft = Math.min(0, d), a.minTop = Math.min(0, m), a.maxLeft = Math.max(0, d), a.maxTop = Math.max(0, m), h && this.limited && (a.minLeft = Math.min(o.left, o.left + (o.width - a.width)), a.minTop = Math.min(o.top, o.top + (o.height - a.height)), a.maxLeft = o.left, a.maxTop = o.top, s === 2 && (a.width >= r.width && (a.minLeft = Math.min(0, d), a.maxLeft = Math.max(0, d)), a.height >= r.height && (a.minTop = Math.min(0, m), a.maxTop = Math.max(0, m))));
      } else
        a.minLeft = -a.width, a.minTop = -a.height, a.maxLeft = r.width, a.maxTop = r.height;
  },
  renderCanvas: function(e, i) {
    var n = this.canvasData, r = this.imageData;
    if (i) {
      var a = Eh({
        width: r.naturalWidth * Math.abs(r.scaleX || 1),
        height: r.naturalHeight * Math.abs(r.scaleY || 1),
        degree: r.rotate || 0
      }), o = a.width, s = a.height, l = n.width * (o / n.naturalWidth), h = n.height * (s / n.naturalHeight);
      n.left -= (l - n.width) / 2, n.top -= (h - n.height) / 2, n.width = l, n.height = h, n.aspectRatio = o / s, n.naturalWidth = o, n.naturalHeight = s, this.limitCanvas(!0, !1);
    }
    (n.width > n.maxWidth || n.width < n.minWidth) && (n.left = n.oldLeft), (n.height > n.maxHeight || n.height < n.minHeight) && (n.top = n.oldTop), n.width = Math.min(Math.max(n.width, n.minWidth), n.maxWidth), n.height = Math.min(Math.max(n.height, n.minHeight), n.maxHeight), this.limitCanvas(!1, !0), n.left = Math.min(Math.max(n.left, n.minLeft), n.maxLeft), n.top = Math.min(Math.max(n.top, n.minTop), n.maxTop), n.oldLeft = n.left, n.oldTop = n.top, je(this.canvas, V({
      width: n.width,
      height: n.height
    }, Vt({
      translateX: n.left,
      translateY: n.top
    }))), this.renderImage(e), this.cropped && this.limited && this.limitCropBox(!0, !0);
  },
  renderImage: function(e) {
    var i = this.canvasData, n = this.imageData, r = n.naturalWidth * (i.width / i.naturalWidth), a = n.naturalHeight * (i.height / i.naturalHeight);
    V(n, {
      width: r,
      height: a,
      left: (i.width - r) / 2,
      top: (i.height - a) / 2
    }), je(this.image, V({
      width: n.width,
      height: n.height
    }, Vt(V({
      translateX: n.left,
      translateY: n.top
    }, n)))), e && this.output();
  },
  initCropBox: function() {
    var e = this.options, i = this.canvasData, n = e.aspectRatio || e.initialAspectRatio, r = Number(e.autoCropArea) || 0.8, a = {
      width: i.width,
      height: i.height
    };
    n && (i.height * n > i.width ? a.height = a.width / n : a.width = a.height * n), this.cropBoxData = a, this.limitCropBox(!0, !0), a.width = Math.min(Math.max(a.width, a.minWidth), a.maxWidth), a.height = Math.min(Math.max(a.height, a.minHeight), a.maxHeight), a.width = Math.max(a.minWidth, a.width * r), a.height = Math.max(a.minHeight, a.height * r), a.left = i.left + (i.width - a.width) / 2, a.top = i.top + (i.height - a.height) / 2, a.oldLeft = a.left, a.oldTop = a.top, this.initialCropBoxData = V({}, a);
  },
  limitCropBox: function(e, i) {
    var n = this.options, r = this.containerData, a = this.canvasData, o = this.cropBoxData, s = this.limited, l = n.aspectRatio;
    if (e) {
      var h = Number(n.minCropBoxWidth) || 0, u = Number(n.minCropBoxHeight) || 0, f = s ? Math.min(r.width, a.width, a.width + a.left, r.width - a.left) : r.width, c = s ? Math.min(r.height, a.height, a.height + a.top, r.height - a.top) : r.height;
      h = Math.min(h, r.width), u = Math.min(u, r.height), l && (h && u ? u * l > h ? u = h / l : h = u * l : h ? u = h / l : u && (h = u * l), c * l > f ? c = f / l : f = c * l), o.minWidth = Math.min(h, f), o.minHeight = Math.min(u, c), o.maxWidth = f, o.maxHeight = c;
    }
    i && (s ? (o.minLeft = Math.max(0, a.left), o.minTop = Math.max(0, a.top), o.maxLeft = Math.min(r.width, a.left + a.width) - o.width, o.maxTop = Math.min(r.height, a.top + a.height) - o.height) : (o.minLeft = 0, o.minTop = 0, o.maxLeft = r.width - o.width, o.maxTop = r.height - o.height));
  },
  renderCropBox: function() {
    var e = this.options, i = this.containerData, n = this.cropBoxData;
    (n.width > n.maxWidth || n.width < n.minWidth) && (n.left = n.oldLeft), (n.height > n.maxHeight || n.height < n.minHeight) && (n.top = n.oldTop), n.width = Math.min(Math.max(n.width, n.minWidth), n.maxWidth), n.height = Math.min(Math.max(n.height, n.minHeight), n.maxHeight), this.limitCropBox(!1, !0), n.left = Math.min(Math.max(n.left, n.minLeft), n.maxLeft), n.top = Math.min(Math.max(n.top, n.minTop), n.maxTop), n.oldLeft = n.left, n.oldTop = n.top, e.movable && e.cropBoxMovable && Yt(this.face, qt, n.width >= i.width && n.height >= i.height ? Qa : $n), je(this.cropBox, V({
      width: n.width,
      height: n.height
    }, Vt({
      translateX: n.left,
      translateY: n.top
    }))), this.cropped && this.limited && this.limitCanvas(!0, !0), this.disabled || this.output();
  },
  output: function() {
    this.preview(), yt(this.element, Dn, this.getData());
  }
}, Bh = {
  initPreview: function() {
    var e = this.element, i = this.crossOrigin, n = this.options.preview, r = i ? this.crossOriginUrl : this.url, a = e.alt || "The image to preview", o = document.createElement("img");
    if (i && (o.crossOrigin = i), o.src = r, o.alt = a, this.viewBox.appendChild(o), this.viewBoxImage = o, !!n) {
      var s = n;
      typeof n == "string" ? s = e.ownerDocument.querySelectorAll(n) : n.querySelector && (s = [n]), this.previews = s, $(s, function(l) {
        var h = document.createElement("img");
        Yt(l, pi, {
          width: l.offsetWidth,
          height: l.offsetHeight,
          html: l.innerHTML
        }), i && (h.crossOrigin = i), h.src = r, h.alt = a, h.style.cssText = 'display:block;width:100%;height:auto;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;image-orientation:0deg!important;"', l.innerHTML = "", l.appendChild(h);
      });
    }
  },
  resetPreview: function() {
    $(this.previews, function(e) {
      var i = Rn(e, pi);
      je(e, {
        width: i.width,
        height: i.height
      }), e.innerHTML = i.html, bh(e, pi);
    });
  },
  preview: function() {
    var e = this.imageData, i = this.canvasData, n = this.cropBoxData, r = n.width, a = n.height, o = e.width, s = e.height, l = n.left - i.left - e.left, h = n.top - i.top - e.top;
    !this.cropped || this.disabled || (je(this.viewBoxImage, V({
      width: o,
      height: s
    }, Vt(V({
      translateX: -l,
      translateY: -h
    }, e)))), $(this.previews, function(u) {
      var f = Rn(u, pi), c = f.width, d = f.height, m = c, p = d, v = 1;
      r && (v = c / r, p = a * v), a && p > d && (v = d / a, m = r * v, p = d), je(u, {
        width: m,
        height: p
      }), je(u.getElementsByTagName("img")[0], V({
        width: o * v,
        height: s * v
      }, Vt(V({
        translateX: -l * v,
        translateY: -h * v
      }, e))));
    }));
  }
}, Hh = {
  bind: function() {
    var e = this.element, i = this.options, n = this.cropper;
    de(i.cropstart) && Ee(e, In, i.cropstart), de(i.cropmove) && Ee(e, Hn, i.cropmove), de(i.cropend) && Ee(e, Bn, i.cropend), de(i.crop) && Ee(e, Dn, i.crop), de(i.zoom) && Ee(e, Nn, i.zoom), Ee(n, xr, this.onCropStart = this.cropStart.bind(this)), i.zoomable && i.zoomOnWheel && Ee(n, zr, this.onWheel = this.wheel.bind(this), {
      passive: !1,
      capture: !0
    }), i.toggleDragModeOnDblclick && Ee(n, Rr, this.onDblclick = this.dblclick.bind(this)), Ee(e.ownerDocument, Pr, this.onCropMove = this.cropMove.bind(this)), Ee(e.ownerDocument, Lr, this.onCropEnd = this.cropEnd.bind(this)), i.responsive && Ee(window, Gr, this.onResize = this.resize.bind(this));
  },
  unbind: function() {
    var e = this.element, i = this.options, n = this.cropper;
    de(i.cropstart) && Ae(e, In, i.cropstart), de(i.cropmove) && Ae(e, Hn, i.cropmove), de(i.cropend) && Ae(e, Bn, i.cropend), de(i.crop) && Ae(e, Dn, i.crop), de(i.zoom) && Ae(e, Nn, i.zoom), Ae(n, xr, this.onCropStart), i.zoomable && i.zoomOnWheel && Ae(n, zr, this.onWheel, {
      passive: !1,
      capture: !0
    }), i.toggleDragModeOnDblclick && Ae(n, Rr, this.onDblclick), Ae(e.ownerDocument, Pr, this.onCropMove), Ae(e.ownerDocument, Lr, this.onCropEnd), i.responsive && Ae(window, Gr, this.onResize);
  }
}, Ih = {
  resize: function() {
    if (!this.disabled) {
      var e = this.options, i = this.container, n = this.containerData, r = i.offsetWidth / n.width, a = i.offsetHeight / n.height, o = Math.abs(r - 1) > Math.abs(a - 1) ? r : a;
      if (o !== 1) {
        var s, l;
        e.restore && (s = this.getCanvasData(), l = this.getCropBoxData()), this.render(), e.restore && (this.setCanvasData($(s, function(h, u) {
          s[u] = h * o;
        })), this.setCropBoxData($(l, function(h, u) {
          l[u] = h * o;
        })));
      }
    }
  },
  dblclick: function() {
    this.disabled || this.options.dragMode === $a || this.setDragMode(ph(this.dragBox, An) ? Ka : er);
  },
  wheel: function(e) {
    var i = this, n = Number(this.options.wheelZoomRatio) || 0.1, r = 1;
    this.disabled || (e.preventDefault(), !this.wheeling && (this.wheeling = !0, setTimeout(function() {
      i.wheeling = !1;
    }, 50), e.deltaY ? r = e.deltaY > 0 ? 1 : -1 : e.wheelDelta ? r = -e.wheelDelta / 120 : e.detail && (r = e.detail > 0 ? 1 : -1), this.zoom(-r * n, e)));
  },
  cropStart: function(e) {
    var i = e.buttons, n = e.button;
    if (!(this.disabled || (e.type === "mousedown" || e.type === "pointerdown" && e.pointerType === "mouse") && // No primary button (Usually the left button)
    (A(i) && i !== 1 || A(n) && n !== 0 || e.ctrlKey))) {
      var r = this.options, a = this.pointers, o;
      e.changedTouches ? $(e.changedTouches, function(s) {
        a[s.identifier] = gi(s);
      }) : a[e.pointerId || 0] = gi(e), Object.keys(a).length > 1 && r.zoomable && r.zoomOnTouch ? o = Ja : o = Rn(e.target, qt), oh.test(o) && yt(this.element, In, {
        originalEvent: e,
        action: o
      }) !== !1 && (e.preventDefault(), this.action = o, this.cropping = !1, o === Za && (this.cropping = !0, ie(this.dragBox, Ci)));
    }
  },
  cropMove: function(e) {
    var i = this.action;
    if (!(this.disabled || !i)) {
      var n = this.pointers;
      e.preventDefault(), yt(this.element, Hn, {
        originalEvent: e,
        action: i
      }) !== !1 && (e.changedTouches ? $(e.changedTouches, function(r) {
        V(n[r.identifier] || {}, gi(r, !0));
      }) : V(n[e.pointerId || 0] || {}, gi(e, !0)), this.change(e));
    }
  },
  cropEnd: function(e) {
    if (!this.disabled) {
      var i = this.action, n = this.pointers;
      e.changedTouches ? $(e.changedTouches, function(r) {
        delete n[r.identifier];
      }) : delete n[e.pointerId || 0], i && (e.preventDefault(), Object.keys(n).length || (this.action = ""), this.cropping && (this.cropping = !1, vt(this.dragBox, Ci, this.cropped && this.options.modal)), yt(this.element, Bn, {
        originalEvent: e,
        action: i
      }));
    }
  }
}, Nh = {
  change: function(e) {
    var i = this.options, n = this.canvasData, r = this.containerData, a = this.cropBoxData, o = this.pointers, s = this.action, l = i.aspectRatio, h = a.left, u = a.top, f = a.width, c = a.height, d = h + f, m = u + c, p = 0, v = 0, k = r.width, T = r.height, S = !0, I;
    !l && e.shiftKey && (l = f && c ? f / c : 1), this.limited && (p = a.minLeft, v = a.minTop, k = p + Math.min(r.width, n.width, n.left + n.width), T = v + Math.min(r.height, n.height, n.top + n.height));
    var w = o[Object.keys(o)[0]], _ = {
      x: w.endX - w.startX,
      y: w.endY - w.startY
    }, E = function(G) {
      switch (G) {
        case Je:
          d + _.x > k && (_.x = k - d);
          break;
        case Ke:
          h + _.x < p && (_.x = p - h);
          break;
        case Fe:
          u + _.y < v && (_.y = v - u);
          break;
        case dt:
          m + _.y > T && (_.y = T - m);
          break;
      }
    };
    switch (s) {
      case $n:
        h += _.x, u += _.y;
        break;
      case Je:
        if (_.x >= 0 && (d >= k || l && (u <= v || m >= T))) {
          S = !1;
          break;
        }
        E(Je), f += _.x, f < 0 && (s = Ke, f = -f, h -= f), l && (c = f / l, u += (a.height - c) / 2);
        break;
      case Fe:
        if (_.y <= 0 && (u <= v || l && (h <= p || d >= k))) {
          S = !1;
          break;
        }
        E(Fe), c -= _.y, u += _.y, c < 0 && (s = dt, c = -c, u -= c), l && (f = c * l, h += (a.width - f) / 2);
        break;
      case Ke:
        if (_.x <= 0 && (h <= p || l && (u <= v || m >= T))) {
          S = !1;
          break;
        }
        E(Ke), f -= _.x, h += _.x, f < 0 && (s = Je, f = -f, h -= f), l && (c = f / l, u += (a.height - c) / 2);
        break;
      case dt:
        if (_.y >= 0 && (m >= T || l && (h <= p || d >= k))) {
          S = !1;
          break;
        }
        E(dt), c += _.y, c < 0 && (s = Fe, c = -c, u -= c), l && (f = c * l, h += (a.width - f) / 2);
        break;
      case Lt:
        if (l) {
          if (_.y <= 0 && (u <= v || d >= k)) {
            S = !1;
            break;
          }
          E(Fe), c -= _.y, u += _.y, f = c * l;
        } else
          E(Fe), E(Je), _.x >= 0 ? d < k ? f += _.x : _.y <= 0 && u <= v && (S = !1) : f += _.x, _.y <= 0 ? u > v && (c -= _.y, u += _.y) : (c -= _.y, u += _.y);
        f < 0 && c < 0 ? (s = zt, c = -c, f = -f, u -= c, h -= f) : f < 0 ? (s = Ut, f = -f, h -= f) : c < 0 && (s = Gt, c = -c, u -= c);
        break;
      case Ut:
        if (l) {
          if (_.y <= 0 && (u <= v || h <= p)) {
            S = !1;
            break;
          }
          E(Fe), c -= _.y, u += _.y, f = c * l, h += a.width - f;
        } else
          E(Fe), E(Ke), _.x <= 0 ? h > p ? (f -= _.x, h += _.x) : _.y <= 0 && u <= v && (S = !1) : (f -= _.x, h += _.x), _.y <= 0 ? u > v && (c -= _.y, u += _.y) : (c -= _.y, u += _.y);
        f < 0 && c < 0 ? (s = Gt, c = -c, f = -f, u -= c, h -= f) : f < 0 ? (s = Lt, f = -f, h -= f) : c < 0 && (s = zt, c = -c, u -= c);
        break;
      case zt:
        if (l) {
          if (_.x <= 0 && (h <= p || m >= T)) {
            S = !1;
            break;
          }
          E(Ke), f -= _.x, h += _.x, c = f / l;
        } else
          E(dt), E(Ke), _.x <= 0 ? h > p ? (f -= _.x, h += _.x) : _.y >= 0 && m >= T && (S = !1) : (f -= _.x, h += _.x), _.y >= 0 ? m < T && (c += _.y) : c += _.y;
        f < 0 && c < 0 ? (s = Lt, c = -c, f = -f, u -= c, h -= f) : f < 0 ? (s = Gt, f = -f, h -= f) : c < 0 && (s = Ut, c = -c, u -= c);
        break;
      case Gt:
        if (l) {
          if (_.x >= 0 && (d >= k || m >= T)) {
            S = !1;
            break;
          }
          E(Je), f += _.x, c = f / l;
        } else
          E(dt), E(Je), _.x >= 0 ? d < k ? f += _.x : _.y >= 0 && m >= T && (S = !1) : f += _.x, _.y >= 0 ? m < T && (c += _.y) : c += _.y;
        f < 0 && c < 0 ? (s = Ut, c = -c, f = -f, u -= c, h -= f) : f < 0 ? (s = zt, f = -f, h -= f) : c < 0 && (s = Lt, c = -c, u -= c);
        break;
      case Qa:
        this.move(_.x, _.y), S = !1;
        break;
      case Ja:
        this.zoom(wh(o), e), S = !1;
        break;
      case Za:
        if (!_.x || !_.y) {
          S = !1;
          break;
        }
        I = ao(this.cropper), h = w.startX - I.left, u = w.startY - I.top, f = a.minWidth, c = a.minHeight, _.x > 0 ? s = _.y > 0 ? Gt : Lt : _.x < 0 && (h -= f, s = _.y > 0 ? zt : Ut), _.y < 0 && (u -= c), this.cropped || (He(this.cropBox, me), this.cropped = !0, this.limited && this.limitCropBox(!0, !0));
        break;
    }
    S && (a.width = f, a.height = c, a.left = h, a.top = u, this.action = s, this.renderCropBox()), $(o, function(O) {
      O.startX = O.endX, O.startY = O.endY;
    });
  }
}, Rh = {
  // Show the crop box manually
  crop: function() {
    return this.ready && !this.cropped && !this.disabled && (this.cropped = !0, this.limitCropBox(!0, !0), this.options.modal && ie(this.dragBox, Ci), He(this.cropBox, me), this.setCropBoxData(this.initialCropBoxData)), this;
  },
  // Reset the image and crop box to their initial states
  reset: function() {
    return this.ready && !this.disabled && (this.imageData = V({}, this.initialImageData), this.canvasData = V({}, this.initialCanvasData), this.cropBoxData = V({}, this.initialCropBoxData), this.renderCanvas(), this.cropped && this.renderCropBox()), this;
  },
  // Clear the crop box
  clear: function() {
    return this.cropped && !this.disabled && (V(this.cropBoxData, {
      left: 0,
      top: 0,
      width: 0,
      height: 0
    }), this.cropped = !1, this.renderCropBox(), this.limitCanvas(!0, !0), this.renderCanvas(), He(this.dragBox, Ci), ie(this.cropBox, me)), this;
  },
  /**
   * Replace the image's src and rebuild the cropper
   * @param {string} url - The new URL.
   * @param {boolean} [hasSameSize] - Indicate if the new image has the same size as the old one.
   * @returns {Cropper} this
   */
  replace: function(e) {
    var i = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
    return !this.disabled && e && (this.isImg && (this.element.src = e), i ? (this.url = e, this.image.src = e, this.ready && (this.viewBoxImage.src = e, $(this.previews, function(n) {
      n.getElementsByTagName("img")[0].src = e;
    }))) : (this.isImg && (this.replaced = !0), this.options.data = null, this.uncreate(), this.load(e))), this;
  },
  // Enable (unfreeze) the cropper
  enable: function() {
    return this.ready && this.disabled && (this.disabled = !1, He(this.cropper, Ir)), this;
  },
  // Disable (freeze) the cropper
  disable: function() {
    return this.ready && !this.disabled && (this.disabled = !0, ie(this.cropper, Ir)), this;
  },
  /**
   * Destroy the cropper and remove the instance from the image
   * @returns {Cropper} this
   */
  destroy: function() {
    var e = this.element;
    return e[X] ? (e[X] = void 0, this.isImg && this.replaced && (e.src = this.originalUrl), this.uncreate(), this) : this;
  },
  /**
   * Move the canvas with relative offsets
   * @param {number} offsetX - The relative offset distance on the x-axis.
   * @param {number} [offsetY=offsetX] - The relative offset distance on the y-axis.
   * @returns {Cropper} this
   */
  move: function(e) {
    var i = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : e, n = this.canvasData, r = n.left, a = n.top;
    return this.moveTo(dn(e) ? e : r + Number(e), dn(i) ? i : a + Number(i));
  },
  /**
   * Move the canvas to an absolute point
   * @param {number} x - The x-axis coordinate.
   * @param {number} [y=x] - The y-axis coordinate.
   * @returns {Cropper} this
   */
  moveTo: function(e) {
    var i = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : e, n = this.canvasData, r = !1;
    return e = Number(e), i = Number(i), this.ready && !this.disabled && this.options.movable && (A(e) && (n.left = e, r = !0), A(i) && (n.top = i, r = !0), r && this.renderCanvas(!0)), this;
  },
  /**
   * Zoom the canvas with a relative ratio
   * @param {number} ratio - The target ratio.
   * @param {Event} _originalEvent - The original event if any.
   * @returns {Cropper} this
   */
  zoom: function(e, i) {
    var n = this.canvasData;
    return e = Number(e), e < 0 ? e = 1 / (1 - e) : e = 1 + e, this.zoomTo(n.width * e / n.naturalWidth, null, i);
  },
  /**
   * Zoom the canvas to an absolute ratio
   * @param {number} ratio - The target ratio.
   * @param {Object} pivot - The zoom pivot point coordinate.
   * @param {Event} _originalEvent - The original event if any.
   * @returns {Cropper} this
   */
  zoomTo: function(e, i, n) {
    var r = this.options, a = this.canvasData, o = a.width, s = a.height, l = a.naturalWidth, h = a.naturalHeight;
    if (e = Number(e), e >= 0 && this.ready && !this.disabled && r.zoomable) {
      var u = l * e, f = h * e;
      if (yt(this.element, Nn, {
        ratio: e,
        oldRatio: o / l,
        originalEvent: n
      }) === !1)
        return this;
      if (n) {
        var c = this.pointers, d = ao(this.cropper), m = c && Object.keys(c).length ? yh(c) : {
          pageX: n.pageX,
          pageY: n.pageY
        };
        a.left -= (u - o) * ((m.pageX - d.left - a.left) / o), a.top -= (f - s) * ((m.pageY - d.top - a.top) / s);
      } else
        bt(i) && A(i.x) && A(i.y) ? (a.left -= (u - o) * ((i.x - a.left) / o), a.top -= (f - s) * ((i.y - a.top) / s)) : (a.left -= (u - o) / 2, a.top -= (f - s) / 2);
      a.width = u, a.height = f, this.renderCanvas(!0);
    }
    return this;
  },
  /**
   * Rotate the canvas with a relative degree
   * @param {number} degree - The rotate degree.
   * @returns {Cropper} this
   */
  rotate: function(e) {
    return this.rotateTo((this.imageData.rotate || 0) + Number(e));
  },
  /**
   * Rotate the canvas to an absolute degree
   * @param {number} degree - The rotate degree.
   * @returns {Cropper} this
   */
  rotateTo: function(e) {
    return e = Number(e), A(e) && this.ready && !this.disabled && this.options.rotatable && (this.imageData.rotate = e % 360, this.renderCanvas(!0, !0)), this;
  },
  /**
   * Scale the image on the x-axis.
   * @param {number} scaleX - The scale ratio on the x-axis.
   * @returns {Cropper} this
   */
  scaleX: function(e) {
    var i = this.imageData.scaleY;
    return this.scale(e, A(i) ? i : 1);
  },
  /**
   * Scale the image on the y-axis.
   * @param {number} scaleY - The scale ratio on the y-axis.
   * @returns {Cropper} this
   */
  scaleY: function(e) {
    var i = this.imageData.scaleX;
    return this.scale(A(i) ? i : 1, e);
  },
  /**
   * Scale the image
   * @param {number} scaleX - The scale ratio on the x-axis.
   * @param {number} [scaleY=scaleX] - The scale ratio on the y-axis.
   * @returns {Cropper} this
   */
  scale: function(e) {
    var i = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : e, n = this.imageData, r = !1;
    return e = Number(e), i = Number(i), this.ready && !this.disabled && this.options.scalable && (A(e) && (n.scaleX = e, r = !0), A(i) && (n.scaleY = i, r = !0), r && this.renderCanvas(!0, !0)), this;
  },
  /**
   * Get the cropped area position and size data (base on the original image)
   * @param {boolean} [rounded=false] - Indicate if round the data values or not.
   * @returns {Object} The result cropped data.
   */
  getData: function() {
    var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !1, i = this.options, n = this.imageData, r = this.canvasData, a = this.cropBoxData, o;
    if (this.ready && this.cropped) {
      o = {
        x: a.left - r.left,
        y: a.top - r.top,
        width: a.width,
        height: a.height
      };
      var s = n.width / n.naturalWidth;
      if ($(o, function(u, f) {
        o[f] = u / s;
      }), e) {
        var l = Math.round(o.y + o.height), h = Math.round(o.x + o.width);
        o.x = Math.round(o.x), o.y = Math.round(o.y), o.width = h - o.x, o.height = l - o.y;
      }
    } else
      o = {
        x: 0,
        y: 0,
        width: 0,
        height: 0
      };
    return i.rotatable && (o.rotate = n.rotate || 0), i.scalable && (o.scaleX = n.scaleX || 1, o.scaleY = n.scaleY || 1), o;
  },
  /**
   * Set the cropped area position and size with new data
   * @param {Object} data - The new data.
   * @returns {Cropper} this
   */
  setData: function(e) {
    var i = this.options, n = this.imageData, r = this.canvasData, a = {};
    if (this.ready && !this.disabled && bt(e)) {
      var o = !1;
      i.rotatable && A(e.rotate) && e.rotate !== n.rotate && (n.rotate = e.rotate, o = !0), i.scalable && (A(e.scaleX) && e.scaleX !== n.scaleX && (n.scaleX = e.scaleX, o = !0), A(e.scaleY) && e.scaleY !== n.scaleY && (n.scaleY = e.scaleY, o = !0)), o && this.renderCanvas(!0, !0);
      var s = n.width / n.naturalWidth;
      A(e.x) && (a.left = e.x * s + r.left), A(e.y) && (a.top = e.y * s + r.top), A(e.width) && (a.width = e.width * s), A(e.height) && (a.height = e.height * s), this.setCropBoxData(a);
    }
    return this;
  },
  /**
   * Get the container size data.
   * @returns {Object} The result container data.
   */
  getContainerData: function() {
    return this.ready ? V({}, this.containerData) : {};
  },
  /**
   * Get the image position and size data.
   * @returns {Object} The result image data.
   */
  getImageData: function() {
    return this.sized ? V({}, this.imageData) : {};
  },
  /**
   * Get the canvas position and size data.
   * @returns {Object} The result canvas data.
   */
  getCanvasData: function() {
    var e = this.canvasData, i = {};
    return this.ready && $(["left", "top", "width", "height", "naturalWidth", "naturalHeight"], function(n) {
      i[n] = e[n];
    }), i;
  },
  /**
   * Set the canvas position and size with new data.
   * @param {Object} data - The new canvas data.
   * @returns {Cropper} this
   */
  setCanvasData: function(e) {
    var i = this.canvasData, n = i.aspectRatio;
    return this.ready && !this.disabled && bt(e) && (A(e.left) && (i.left = e.left), A(e.top) && (i.top = e.top), A(e.width) ? (i.width = e.width, i.height = e.width / n) : A(e.height) && (i.height = e.height, i.width = e.height * n), this.renderCanvas(!0)), this;
  },
  /**
   * Get the crop box position and size data.
   * @returns {Object} The result crop box data.
   */
  getCropBoxData: function() {
    var e = this.cropBoxData, i;
    return this.ready && this.cropped && (i = {
      left: e.left,
      top: e.top,
      width: e.width,
      height: e.height
    }), i || {};
  },
  /**
   * Set the crop box position and size with new data.
   * @param {Object} data - The new crop box data.
   * @returns {Cropper} this
   */
  setCropBoxData: function(e) {
    var i = this.cropBoxData, n = this.options.aspectRatio, r, a;
    return this.ready && this.cropped && !this.disabled && bt(e) && (A(e.left) && (i.left = e.left), A(e.top) && (i.top = e.top), A(e.width) && e.width !== i.width && (r = !0, i.width = e.width), A(e.height) && e.height !== i.height && (a = !0, i.height = e.height), n && (r ? i.height = i.width / n : a && (i.width = i.height * n)), this.renderCropBox()), this;
  },
  /**
   * Get a canvas drawn the cropped image.
   * @param {Object} [options={}] - The config options.
   * @returns {HTMLCanvasElement} - The result canvas.
   */
  getCroppedCanvas: function() {
    var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
    if (!this.ready || !window.HTMLCanvasElement)
      return null;
    var i = this.canvasData, n = kh(this.image, this.imageData, i, e);
    if (!this.cropped)
      return n;
    var r = this.getData(e.rounded), a = r.x, o = r.y, s = r.width, l = r.height, h = n.width / Math.floor(i.naturalWidth);
    h !== 1 && (a *= h, o *= h, s *= h, l *= h);
    var u = s / l, f = Xe({
      aspectRatio: u,
      width: e.maxWidth || 1 / 0,
      height: e.maxHeight || 1 / 0
    }), c = Xe({
      aspectRatio: u,
      width: e.minWidth || 0,
      height: e.minHeight || 0
    }, "cover"), d = Xe({
      aspectRatio: u,
      width: e.width || (h !== 1 ? n.width : s),
      height: e.height || (h !== 1 ? n.height : l)
    }), m = d.width, p = d.height;
    m = Math.min(f.width, Math.max(c.width, m)), p = Math.min(f.height, Math.max(c.height, p));
    var v = document.createElement("canvas"), k = v.getContext("2d");
    v.width = wt(m), v.height = wt(p), k.fillStyle = e.fillColor || "transparent", k.fillRect(0, 0, m, p);
    var T = e.imageSmoothingEnabled, S = T === void 0 ? !0 : T, I = e.imageSmoothingQuality;
    k.imageSmoothingEnabled = S, I && (k.imageSmoothingQuality = I);
    var w = n.width, _ = n.height, E = a, O = o, G, Z, oe, se, y, D;
    E <= -s || E > w ? (E = 0, G = 0, oe = 0, y = 0) : E <= 0 ? (oe = -E, E = 0, G = Math.min(w, s + E), y = G) : E <= w && (oe = 0, G = Math.min(s, w - E), y = G), G <= 0 || O <= -l || O > _ ? (O = 0, Z = 0, se = 0, D = 0) : O <= 0 ? (se = -O, O = 0, Z = Math.min(_, l + O), D = Z) : O <= _ && (se = 0, Z = Math.min(l, _ - O), D = Z);
    var F = [E, O, G, Z];
    if (y > 0 && D > 0) {
      var Q = m / s;
      F.push(oe * Q, se * Q, y * Q, D * Q);
    }
    return k.drawImage.apply(k, [n].concat(qa(F.map(function(q) {
      return Math.floor(wt(q));
    })))), v;
  },
  /**
   * Change the aspect ratio of the crop box.
   * @param {number} aspectRatio - The new aspect ratio.
   * @returns {Cropper} this
   */
  setAspectRatio: function(e) {
    var i = this.options;
    return !this.disabled && !dn(e) && (i.aspectRatio = Math.max(0, e) || NaN, this.ready && (this.initCropBox(), this.cropped && this.renderCropBox())), this;
  },
  /**
   * Change the drag mode.
   * @param {string} mode - The new drag mode.
   * @returns {Cropper} this
   */
  setDragMode: function(e) {
    var i = this.options, n = this.dragBox, r = this.face;
    if (this.ready && !this.disabled) {
      var a = e === er, o = i.movable && e === Ka;
      e = a || o ? e : $a, i.dragMode = e, Yt(n, qt, e), vt(n, An, a), vt(n, On, o), i.cropBoxMovable || (Yt(r, qt, e), vt(r, An, a), vt(r, On, o));
    }
    return this;
  }
}, xh = Ne.Cropper, so = /* @__PURE__ */ function() {
  function t(e) {
    var i = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
    if (Yl(this, t), !e || !hh.test(e.tagName))
      throw new Error("The first argument is required and must be an <img> or <canvas> element.");
    this.element = e, this.options = V({}, jr, bt(i) && i), this.cropped = !1, this.disabled = !1, this.pointers = {}, this.ready = !1, this.reloading = !1, this.replaced = !1, this.sized = !1, this.sizing = !1, this.init();
  }
  return Zl(t, [{
    key: "init",
    value: function() {
      var i = this.element, n = i.tagName.toLowerCase(), r;
      if (!i[X]) {
        if (i[X] = this, n === "img") {
          if (this.isImg = !0, r = i.getAttribute("src") || "", this.originalUrl = r, !r)
            return;
          r = i.src;
        } else
          n === "canvas" && window.HTMLCanvasElement && (r = i.toDataURL());
        this.load(r);
      }
    }
  }, {
    key: "load",
    value: function(i) {
      var n = this;
      if (i) {
        this.url = i, this.imageData = {};
        var r = this.element, a = this.options;
        if (!a.rotatable && !a.scalable && (a.checkOrientation = !1), !a.checkOrientation || !window.ArrayBuffer) {
          this.clone();
          return;
        }
        if (sh.test(i)) {
          lh.test(i) ? this.read(Ch(i)) : this.clone();
          return;
        }
        var o = new XMLHttpRequest(), s = this.clone.bind(this);
        this.reloading = !0, this.xhr = o, o.onabort = s, o.onerror = s, o.ontimeout = s, o.onprogress = function() {
          o.getResponseHeader("content-type") !== Fr && o.abort();
        }, o.onload = function() {
          n.read(o.response);
        }, o.onloadend = function() {
          n.reloading = !1, n.xhr = null;
        }, a.checkCrossOrigin && Wr(i) && r.crossOrigin && (i = Vr(i)), o.open("GET", i, !0), o.responseType = "arraybuffer", o.withCredentials = r.crossOrigin === "use-credentials", o.send();
      }
    }
  }, {
    key: "read",
    value: function(i) {
      var n = this.options, r = this.imageData, a = Ah(i), o = 0, s = 1, l = 1;
      if (a > 1) {
        this.url = Mh(i, Fr);
        var h = Oh(a);
        o = h.rotate, s = h.scaleX, l = h.scaleY;
      }
      n.rotatable && (r.rotate = o), n.scalable && (r.scaleX = s, r.scaleY = l), this.clone();
    }
  }, {
    key: "clone",
    value: function() {
      var i = this.element, n = this.url, r = i.crossOrigin, a = n;
      this.options.checkCrossOrigin && Wr(n) && (r || (r = "anonymous"), a = Vr(n)), this.crossOrigin = r, this.crossOriginUrl = a;
      var o = document.createElement("img");
      r && (o.crossOrigin = r), o.src = a || n, o.alt = i.alt || "The image to crop", this.image = o, o.onload = this.start.bind(this), o.onerror = this.stop.bind(this), ie(o, Nr), i.parentNode.insertBefore(o, i.nextSibling);
    }
  }, {
    key: "start",
    value: function() {
      var i = this, n = this.image;
      n.onload = null, n.onerror = null, this.sizing = !0;
      var r = Ne.navigator && /(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(Ne.navigator.userAgent), a = function(h, u) {
        V(i.imageData, {
          naturalWidth: h,
          naturalHeight: u,
          aspectRatio: h / u
        }), i.initialImageData = V({}, i.imageData), i.sizing = !1, i.sized = !0, i.build();
      };
      if (n.naturalWidth && !r) {
        a(n.naturalWidth, n.naturalHeight);
        return;
      }
      var o = document.createElement("img"), s = document.body || document.documentElement;
      this.sizingImage = o, o.onload = function() {
        a(o.width, o.height), r || s.removeChild(o);
      }, o.src = n.src, r || (o.style.cssText = "left:0;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;opacity:0;position:absolute;top:0;z-index:-1;", s.appendChild(o));
    }
  }, {
    key: "stop",
    value: function() {
      var i = this.image;
      i.onload = null, i.onerror = null, i.parentNode.removeChild(i), this.image = null;
    }
  }, {
    key: "build",
    value: function() {
      if (!(!this.sized || this.ready)) {
        var i = this.element, n = this.options, r = this.image, a = i.parentNode, o = document.createElement("div");
        o.innerHTML = uh;
        var s = o.querySelector(".".concat(X, "-container")), l = s.querySelector(".".concat(X, "-canvas")), h = s.querySelector(".".concat(X, "-drag-box")), u = s.querySelector(".".concat(X, "-crop-box")), f = u.querySelector(".".concat(X, "-face"));
        this.container = a, this.cropper = s, this.canvas = l, this.dragBox = h, this.cropBox = u, this.viewBox = s.querySelector(".".concat(X, "-view-box")), this.face = f, l.appendChild(r), ie(i, me), a.insertBefore(s, i.nextSibling), He(r, Nr), this.initPreview(), this.bind(), n.initialAspectRatio = Math.max(0, n.initialAspectRatio) || NaN, n.aspectRatio = Math.max(0, n.aspectRatio) || NaN, n.viewMode = Math.max(0, Math.min(3, Math.round(n.viewMode))) || 0, ie(u, me), n.guides || ie(u.getElementsByClassName("".concat(X, "-dashed")), me), n.center || ie(u.getElementsByClassName("".concat(X, "-center")), me), n.background && ie(s, "".concat(X, "-bg")), n.highlight || ie(f, ih), n.cropBoxMovable && (ie(f, On), Yt(f, qt, $n)), n.cropBoxResizable || (ie(u.getElementsByClassName("".concat(X, "-line")), me), ie(u.getElementsByClassName("".concat(X, "-point")), me)), this.render(), this.ready = !0, this.setDragMode(n.dragMode), n.autoCrop && this.crop(), this.setData(n.data), de(n.ready) && Ee(i, Ur, n.ready, {
          once: !0
        }), yt(i, Ur);
      }
    }
  }, {
    key: "unbuild",
    value: function() {
      if (this.ready) {
        this.ready = !1, this.unbind(), this.resetPreview();
        var i = this.cropper.parentNode;
        i && i.removeChild(this.cropper), He(this.element, me);
      }
    }
  }, {
    key: "uncreate",
    value: function() {
      this.ready ? (this.unbuild(), this.ready = !1, this.cropped = !1) : this.sizing ? (this.sizingImage.onload = null, this.sizing = !1, this.sized = !1) : this.reloading ? (this.xhr.onabort = null, this.xhr.abort()) : this.image && this.stop();
    }
    /**
     * Get the no conflict cropper class.
     * @returns {Cropper} The cropper class.
     */
  }], [{
    key: "noConflict",
    value: function() {
      return window.Cropper = xh, t;
    }
    /**
     * Change the default options.
     * @param {Object} options - The new default options.
     */
  }, {
    key: "setDefaults",
    value: function(i) {
      V(jr, bt(i) && i);
    }
  }]), t;
}();
V(so.prototype, Dh, Bh, Hh, Ih, Nh, Rh);
const {
  SvelteComponent: Ph,
  attr: _n,
  binding_callbacks: Lh,
  detach: Uh,
  element: Gh,
  flush: zh,
  init: Fh,
  insert: jh,
  noop: qr,
  safe_not_equal: Xh,
  src_url_equal: Yr
} = window.__gradio__svelte__internal, { onMount: Pd, createEventDispatcher: Wh } = window.__gradio__svelte__internal;
function Vh(t) {
  let e, i;
  return {
    c() {
      e = Gh("img"), Yr(e.src, i = /*image*/
      t[0]) || _n(e, "src", i), _n(e, "alt", "");
    },
    m(n, r) {
      jh(n, e, r), t[4](e);
    },
    p(n, [r]) {
      r & /*image*/
      1 && !Yr(e.src, i = /*image*/
      n[0]) && _n(e, "src", i);
    },
    i: qr,
    o: qr,
    d(n) {
      n && Uh(e), t[4](null);
    }
  };
}
function qh(t, e, i) {
  let { image: n } = e, r;
  const a = Wh();
  let o;
  function s() {
    o.destroy();
  }
  function l() {
    o && s(), o = new so(
      r,
      {
        autoCropArea: 1,
        cropend() {
          const u = o.getCroppedCanvas().toDataURL();
          a("crop", u);
        }
      }
    ), a("crop", n);
  }
  function h(u) {
    Lh[u ? "unshift" : "push"](() => {
      r = u, i(1, r);
    });
  }
  return t.$$set = (u) => {
    "image" in u && i(0, n = u.image);
  }, [n, r, s, l, h];
}
class lo extends Ph {
  constructor(e) {
    super(), Fh(this, e, qh, Vh, Xh, { image: 0, destroy: 2, create: 3 });
  }
  get image() {
    return this.$$.ctx[0];
  }
  set image(e) {
    this.$$set({ image: e }), zh();
  }
  get destroy() {
    return this.$$.ctx[2];
  }
  get create() {
    return this.$$.ctx[3];
  }
}
function Et() {
}
const Yh = (t) => t;
function Zh(t) {
  return t();
}
function Qh(t) {
  t.forEach(Zh);
}
function Jh(t) {
  return typeof t == "function";
}
function Kh(t, e) {
  return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
}
function $h(t, ...e) {
  if (t == null) {
    for (const n of e)
      n(void 0);
    return Et;
  }
  const i = t.subscribe(...e);
  return i.unsubscribe ? () => i.unsubscribe() : i;
}
function Zr(t, { delay: e = 0, duration: i = 400, easing: n = Yh } = {}) {
  const r = +getComputedStyle(t).opacity;
  return {
    delay: e,
    duration: i,
    easing: n,
    css: (a) => `opacity: ${a * r}`
  };
}
const mt = [];
function eu(t, e) {
  return {
    subscribe: Ri(t, e).subscribe
  };
}
function Ri(t, e = Et) {
  let i;
  const n = /* @__PURE__ */ new Set();
  function r(s) {
    if (Kh(t, s) && (t = s, i)) {
      const l = !mt.length;
      for (const h of n)
        h[1](), mt.push(h, t);
      if (l) {
        for (let h = 0; h < mt.length; h += 2)
          mt[h][0](mt[h + 1]);
        mt.length = 0;
      }
    }
  }
  function a(s) {
    r(s(t));
  }
  function o(s, l = Et) {
    const h = [s, l];
    return n.add(h), n.size === 1 && (i = e(r, a) || Et), s(t), () => {
      n.delete(h), n.size === 0 && i && (i(), i = null);
    };
  }
  return { set: r, update: a, subscribe: o };
}
function Dt(t, e, i) {
  const n = !Array.isArray(t), r = n ? [t] : t;
  if (!r.every(Boolean))
    throw new Error("derived() expects stores as input, got a falsy value");
  const a = e.length < 2;
  return eu(i, (o, s) => {
    let l = !1;
    const h = [];
    let u = 0, f = Et;
    const c = () => {
      if (u)
        return;
      f();
      const m = e(n ? h[0] : h, o, s);
      a ? o(m) : f = Jh(m) ? m : Et;
    }, d = r.map(
      (m, p) => $h(
        m,
        (v) => {
          h[p] = v, u &= ~(1 << p), l && c();
        },
        () => {
          u |= 1 << p;
        }
      )
    );
    return l = !0, c(), function() {
      Qh(d), f(), l = !1;
    };
  });
}
class Qr {
  /**
   *
   * @param {number} x
   * @param {number} y
   */
  constructor(e, i) {
    this.x = e, this.y = i;
  }
}
class Jr extends Qr {
  /**
   * Update the x and y values
   *
   * @param {Point} point
   */
  update(e) {
    this.x = e.x, this.y = e.y;
  }
  /**
   * Move the point to another position using an angle and distance
   *
   * @param {number} angle The angle in radians
   * @param {number} distance How much the point should be moved
   */
  moveByAngle(e, i) {
    const n = e + Math.PI / 2;
    this.x = this.x + Math.sin(n) * i, this.y = this.y - Math.cos(n) * i;
  }
  /**
   * Check if this point is the same as another point
   *
   * @param {Point} point
   * @returns {boolean}
   */
  equalsTo(e) {
    return this.x === e.x && this.y === e.y;
  }
  /**
   * Get the difference for x and y axis to another point
   *
   * @param {Point} point
   * @returns {Point}
   */
  getDifferenceTo(e) {
    return new Qr(this.x - e.x, this.y - e.y);
  }
  /**
   * Calculate distance to another point
   *
   * @param {Point} point
   * @returns {Point}
   */
  getDistanceTo(e) {
    const i = this.getDifferenceTo(e);
    return Math.sqrt(Math.pow(i.x, 2) + Math.pow(i.y, 2));
  }
  /**
   * Calculate the angle to another point
   *
   * @param {Point} point
   * @returns {Point}
   */
  getAngleTo(e) {
    const i = this.getDifferenceTo(e);
    return Math.atan2(i.y, i.x);
  }
  /**
   * Return a simple object with x and y properties
   *
   * @returns {object}
   */
  toObject() {
    return {
      x: this.x,
      y: this.y
    };
  }
}
const tu = 30;
class iu {
  /**
   * constructor
   *
   * @param {object} settings
   * @param {number} settings.radius The radius for the lazy area
   * @param {boolean} settings.enabled
   */
  constructor({ radius: e = tu, enabled: i = !0, initialPoint: n = { x: 0, y: 0 } } = {}) {
    this.radius = e, this._isEnabled = i, this.pointer = new Jr(n.x, n.y), this.brush = new Jr(n.x, n.y), this.angle = 0, this.distance = 0, this._hasMoved = !1;
  }
  /**
   * Enable lazy brush calculations.
   *
   */
  enable() {
    this._isEnabled = !0;
  }
  /**
   * Disable lazy brush calculations.
   *
   */
  disable() {
    this._isEnabled = !1;
  }
  /**
   * @returns {boolean}
   */
  isEnabled() {
    return this._isEnabled;
  }
  /**
   * Update the radius
   *
   * @param {number} radius
   */
  setRadius(e) {
    this.radius = e;
  }
  /**
   * Return the current radius
   *
   * @returns {number}
   */
  getRadius() {
    return this.radius;
  }
  /**
   * Return the brush coordinates as a simple object
   *
   * @returns {object}
   */
  getBrushCoordinates() {
    return this.brush.toObject();
  }
  /**
   * Return the pointer coordinates as a simple object
   *
   * @returns {object}
   */
  getPointerCoordinates() {
    return this.pointer.toObject();
  }
  /**
   * Return the brush as a LazyPoint
   *
   * @returns {LazyPoint}
   */
  getBrush() {
    return this.brush;
  }
  /**
   * Return the pointer as a LazyPoint
   *
   * @returns {LazyPoint}
   */
  getPointer() {
    return this.pointer;
  }
  /**
   * Return the angle between pointer and brush
   *
   * @returns {number} Angle in radians
   */
  getAngle() {
    return this.angle;
  }
  /**
   * Return the distance between pointer and brush
   *
   * @returns {number} Distance in pixels
   */
  getDistance() {
    return this.distance;
  }
  /**
   * Return if the previous update has moved the brush.
   *
   * @returns {boolean} Whether the brush moved previously.
   */
  brushHasMoved() {
    return this._hasMoved;
  }
  /**
   * Updates the pointer point and calculates the new brush point.
   *
   * @param {Point} newPointerPoint
   * @param {Object} options
   * @param {Boolean} options.both Force update pointer and brush
   * @returns {Boolean} Whether any of the two points changed
   */
  update(e, { both: i = !1 } = {}) {
    return this._hasMoved = !1, this.pointer.equalsTo(e) && !i ? !1 : (this.pointer.update(e), i ? (this._hasMoved = !0, this.brush.update(e), !0) : (this._isEnabled ? (this.distance = this.pointer.getDistanceTo(this.brush), this.angle = this.pointer.getAngleTo(this.brush), this.distance > this.radius && (this.brush.moveByAngle(this.angle, this.distance - this.radius), this._hasMoved = !0)) : (this.distance = 0, this.angle = 0, this.brush.update(e), this._hasMoved = !0), !0));
  }
}
var ho = function() {
  if (typeof Map < "u")
    return Map;
  function t(e, i) {
    var n = -1;
    return e.some(function(r, a) {
      return r[0] === i ? (n = a, !0) : !1;
    }), n;
  }
  return (
    /** @class */
    function() {
      function e() {
        this.__entries__ = [];
      }
      return Object.defineProperty(e.prototype, "size", {
        /**
         * @returns {boolean}
         */
        get: function() {
          return this.__entries__.length;
        },
        enumerable: !0,
        configurable: !0
      }), e.prototype.get = function(i) {
        var n = t(this.__entries__, i), r = this.__entries__[n];
        return r && r[1];
      }, e.prototype.set = function(i, n) {
        var r = t(this.__entries__, i);
        ~r ? this.__entries__[r][1] = n : this.__entries__.push([i, n]);
      }, e.prototype.delete = function(i) {
        var n = this.__entries__, r = t(n, i);
        ~r && n.splice(r, 1);
      }, e.prototype.has = function(i) {
        return !!~t(this.__entries__, i);
      }, e.prototype.clear = function() {
        this.__entries__.splice(0);
      }, e.prototype.forEach = function(i, n) {
        n === void 0 && (n = null);
        for (var r = 0, a = this.__entries__; r < a.length; r++) {
          var o = a[r];
          i.call(n, o[1], o[0]);
        }
      }, e;
    }()
  );
}(), xn = typeof window < "u" && typeof document < "u" && window.document === document, Mi = function() {
  return typeof global < "u" && global.Math === Math ? global : typeof self < "u" && self.Math === Math ? self : typeof window < "u" && window.Math === Math ? window : Function("return this")();
}(), nu = function() {
  return typeof requestAnimationFrame == "function" ? requestAnimationFrame.bind(Mi) : function(t) {
    return setTimeout(function() {
      return t(Date.now());
    }, 1e3 / 60);
  };
}(), ru = 2;
function au(t, e) {
  var i = !1, n = !1, r = 0;
  function a() {
    i && (i = !1, t()), n && s();
  }
  function o() {
    nu(a);
  }
  function s() {
    var l = Date.now();
    if (i) {
      if (l - r < ru)
        return;
      n = !0;
    } else
      i = !0, n = !1, setTimeout(o, e);
    r = l;
  }
  return s;
}
var ou = 20, su = ["top", "right", "bottom", "left", "width", "height", "size", "weight"], lu = typeof MutationObserver < "u", hu = (
  /** @class */
  function() {
    function t() {
      this.connected_ = !1, this.mutationEventsAdded_ = !1, this.mutationsObserver_ = null, this.observers_ = [], this.onTransitionEnd_ = this.onTransitionEnd_.bind(this), this.refresh = au(this.refresh.bind(this), ou);
    }
    return t.prototype.addObserver = function(e) {
      ~this.observers_.indexOf(e) || this.observers_.push(e), this.connected_ || this.connect_();
    }, t.prototype.removeObserver = function(e) {
      var i = this.observers_, n = i.indexOf(e);
      ~n && i.splice(n, 1), !i.length && this.connected_ && this.disconnect_();
    }, t.prototype.refresh = function() {
      var e = this.updateObservers_();
      e && this.refresh();
    }, t.prototype.updateObservers_ = function() {
      var e = this.observers_.filter(function(i) {
        return i.gatherActive(), i.hasActive();
      });
      return e.forEach(function(i) {
        return i.broadcastActive();
      }), e.length > 0;
    }, t.prototype.connect_ = function() {
      !xn || this.connected_ || (document.addEventListener("transitionend", this.onTransitionEnd_), window.addEventListener("resize", this.refresh), lu ? (this.mutationsObserver_ = new MutationObserver(this.refresh), this.mutationsObserver_.observe(document, {
        attributes: !0,
        childList: !0,
        characterData: !0,
        subtree: !0
      })) : (document.addEventListener("DOMSubtreeModified", this.refresh), this.mutationEventsAdded_ = !0), this.connected_ = !0);
    }, t.prototype.disconnect_ = function() {
      !xn || !this.connected_ || (document.removeEventListener("transitionend", this.onTransitionEnd_), window.removeEventListener("resize", this.refresh), this.mutationsObserver_ && this.mutationsObserver_.disconnect(), this.mutationEventsAdded_ && document.removeEventListener("DOMSubtreeModified", this.refresh), this.mutationsObserver_ = null, this.mutationEventsAdded_ = !1, this.connected_ = !1);
    }, t.prototype.onTransitionEnd_ = function(e) {
      var i = e.propertyName, n = i === void 0 ? "" : i, r = su.some(function(a) {
        return !!~n.indexOf(a);
      });
      r && this.refresh();
    }, t.getInstance = function() {
      return this.instance_ || (this.instance_ = new t()), this.instance_;
    }, t.instance_ = null, t;
  }()
), uo = function(t, e) {
  for (var i = 0, n = Object.keys(e); i < n.length; i++) {
    var r = n[i];
    Object.defineProperty(t, r, {
      value: e[r],
      enumerable: !1,
      writable: !1,
      configurable: !0
    });
  }
  return t;
}, kt = function(t) {
  var e = t && t.ownerDocument && t.ownerDocument.defaultView;
  return e || Mi;
}, co = xi(0, 0, 0, 0);
function Ai(t) {
  return parseFloat(t) || 0;
}
function Kr(t) {
  for (var e = [], i = 1; i < arguments.length; i++)
    e[i - 1] = arguments[i];
  return e.reduce(function(n, r) {
    var a = t["border-" + r + "-width"];
    return n + Ai(a);
  }, 0);
}
function uu(t) {
  for (var e = ["top", "right", "bottom", "left"], i = {}, n = 0, r = e; n < r.length; n++) {
    var a = r[n], o = t["padding-" + a];
    i[a] = Ai(o);
  }
  return i;
}
function cu(t) {
  var e = t.getBBox();
  return xi(0, 0, e.width, e.height);
}
function fu(t) {
  var e = t.clientWidth, i = t.clientHeight;
  if (!e && !i)
    return co;
  var n = kt(t).getComputedStyle(t), r = uu(n), a = r.left + r.right, o = r.top + r.bottom, s = Ai(n.width), l = Ai(n.height);
  if (n.boxSizing === "border-box" && (Math.round(s + a) !== e && (s -= Kr(n, "left", "right") + a), Math.round(l + o) !== i && (l -= Kr(n, "top", "bottom") + o)), !mu(t)) {
    var h = Math.round(s + a) - e, u = Math.round(l + o) - i;
    Math.abs(h) !== 1 && (s -= h), Math.abs(u) !== 1 && (l -= u);
  }
  return xi(r.left, r.top, s, l);
}
var du = function() {
  return typeof SVGGraphicsElement < "u" ? function(t) {
    return t instanceof kt(t).SVGGraphicsElement;
  } : function(t) {
    return t instanceof kt(t).SVGElement && typeof t.getBBox == "function";
  };
}();
function mu(t) {
  return t === kt(t).document.documentElement;
}
function _u(t) {
  return xn ? du(t) ? cu(t) : fu(t) : co;
}
function pu(t) {
  var e = t.x, i = t.y, n = t.width, r = t.height, a = typeof DOMRectReadOnly < "u" ? DOMRectReadOnly : Object, o = Object.create(a.prototype);
  return uo(o, {
    x: e,
    y: i,
    width: n,
    height: r,
    top: i,
    right: e + n,
    bottom: r + i,
    left: e
  }), o;
}
function xi(t, e, i, n) {
  return { x: t, y: e, width: i, height: n };
}
var gu = (
  /** @class */
  function() {
    function t(e) {
      this.broadcastWidth = 0, this.broadcastHeight = 0, this.contentRect_ = xi(0, 0, 0, 0), this.target = e;
    }
    return t.prototype.isActive = function() {
      var e = _u(this.target);
      return this.contentRect_ = e, e.width !== this.broadcastWidth || e.height !== this.broadcastHeight;
    }, t.prototype.broadcastRect = function() {
      var e = this.contentRect_;
      return this.broadcastWidth = e.width, this.broadcastHeight = e.height, e;
    }, t;
  }()
), bu = (
  /** @class */
  function() {
    function t(e, i) {
      var n = pu(i);
      uo(this, { target: e, contentRect: n });
    }
    return t;
  }()
), vu = (
  /** @class */
  function() {
    function t(e, i, n) {
      if (this.activeObservations_ = [], this.observations_ = new ho(), typeof e != "function")
        throw new TypeError("The callback provided as parameter 1 is not a function.");
      this.callback_ = e, this.controller_ = i, this.callbackCtx_ = n;
    }
    return t.prototype.observe = function(e) {
      if (!arguments.length)
        throw new TypeError("1 argument required, but only 0 present.");
      if (!(typeof Element > "u" || !(Element instanceof Object))) {
        if (!(e instanceof kt(e).Element))
          throw new TypeError('parameter 1 is not of type "Element".');
        var i = this.observations_;
        i.has(e) || (i.set(e, new gu(e)), this.controller_.addObserver(this), this.controller_.refresh());
      }
    }, t.prototype.unobserve = function(e) {
      if (!arguments.length)
        throw new TypeError("1 argument required, but only 0 present.");
      if (!(typeof Element > "u" || !(Element instanceof Object))) {
        if (!(e instanceof kt(e).Element))
          throw new TypeError('parameter 1 is not of type "Element".');
        var i = this.observations_;
        i.has(e) && (i.delete(e), i.size || this.controller_.removeObserver(this));
      }
    }, t.prototype.disconnect = function() {
      this.clearActive(), this.observations_.clear(), this.controller_.removeObserver(this);
    }, t.prototype.gatherActive = function() {
      var e = this;
      this.clearActive(), this.observations_.forEach(function(i) {
        i.isActive() && e.activeObservations_.push(i);
      });
    }, t.prototype.broadcastActive = function() {
      if (this.hasActive()) {
        var e = this.callbackCtx_, i = this.activeObservations_.map(function(n) {
          return new bu(n.target, n.broadcastRect());
        });
        this.callback_.call(e, i, e), this.clearActive();
      }
    }, t.prototype.clearActive = function() {
      this.activeObservations_.splice(0);
    }, t.prototype.hasActive = function() {
      return this.activeObservations_.length > 0;
    }, t;
  }()
), fo = typeof WeakMap < "u" ? /* @__PURE__ */ new WeakMap() : new ho(), mo = (
  /** @class */
  function() {
    function t(e) {
      if (!(this instanceof t))
        throw new TypeError("Cannot call a class as a function.");
      if (!arguments.length)
        throw new TypeError("1 argument required, but only 0 present.");
      var i = hu.getInstance(), n = new vu(e, i, this);
      fo.set(this, n);
    }
    return t;
  }()
);
[
  "observe",
  "unobserve",
  "disconnect"
].forEach(function(t) {
  mo.prototype[t] = function() {
    var e;
    return (e = fo.get(this))[t].apply(e, arguments);
  };
});
var wu = function() {
  return typeof Mi.ResizeObserver < "u" ? Mi.ResizeObserver : mo;
}();
const {
  SvelteComponent: yu,
  add_iframe_resize_listener: Eu,
  add_render_callback: _o,
  append: ku,
  attr: Oi,
  binding_callbacks: $r,
  bubble: Tu,
  check_outros: Su,
  create_bidirectional_transition: ea,
  destroy_each: Cu,
  detach: ir,
  element: nr,
  ensure_array_like: ta,
  group_outros: Mu,
  init: Au,
  insert: rr,
  listen: Be,
  run_all: Ou,
  safe_not_equal: Du,
  set_style: ia,
  space: Bu,
  stop_propagation: Hu,
  toggle_class: bi,
  transition_in: pn,
  transition_out: na
} = window.__gradio__svelte__internal, { onMount: Iu, onDestroy: Nu, createEventDispatcher: Ru, tick: gn } = window.__gradio__svelte__internal;
function ra(t, e, i) {
  const n = t.slice();
  return n[61] = e[i].name, n[62] = e[i].zIndex, n[63] = e[i].opacity, n[64] = e, n[65] = i, n;
}
function aa(t) {
  let e, i, n;
  return {
    c() {
      e = nr("div"), e.textContent = "Start drawing", Oi(e, "class", "start-prompt svelte-14l85k0");
    },
    m(r, a) {
      rr(r, e, a), n = !0;
    },
    i(r) {
      n || (r && _o(() => {
        n && (i || (i = ea(e, Zr, { duration: 50 }, !0)), i.run(1));
      }), n = !0);
    },
    o(r) {
      r && (i || (i = ea(e, Zr, { duration: 50 }, !1)), i.run(0)), n = !1;
    },
    d(r) {
      r && ir(e), r && i && i.end();
    }
  };
}
function oa(t) {
  let e, i = (
    /*name*/
    t[61]
  ), n, r;
  const a = () => (
    /*canvas_1_binding*/
    t[31](e, i)
  ), o = () => (
    /*canvas_1_binding*/
    t[31](null, i)
  );
  return {
    c() {
      e = nr("canvas"), Oi(
        e,
        "key",
        /*name*/
        t[61]
      ), ia(
        e,
        "z-index",
        /*zIndex*/
        t[62]
      ), Oi(e, "class", "svelte-14l85k0"), bi(
        e,
        "lr",
        /*add_lr_border*/
        t[5]
      ), bi(e, "tb", !/*add_lr_border*/
      t[5]), ia(
        e,
        "opacity",
        /*opacity*/
        t[63]
      );
    },
    m(s, l) {
      rr(s, e, l), a(), n || (r = [
        Be(
          e,
          "mousedown",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_start*/
            t[7]
          ) : void 0
        ),
        Be(
          e,
          "mousemove",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_move*/
            t[8]
          ) : void 0
        ),
        Be(
          e,
          "mouseup",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_end*/
            t[9]
          ) : void 0
        ),
        Be(
          e,
          "mouseout",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_end*/
            t[9]
          ) : void 0
        ),
        Be(
          e,
          "blur",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_end*/
            t[9]
          ) : void 0
        ),
        Be(
          e,
          "touchstart",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_start*/
            t[7]
          ) : void 0
        ),
        Be(
          e,
          "touchmove",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_move*/
            t[8]
          ) : void 0
        ),
        Be(
          e,
          "touchend",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_end*/
            t[9]
          ) : void 0
        ),
        Be(
          e,
          "touchcancel",
          /*name*/
          t[61] === "interface" ? (
            /*handle_draw_end*/
            t[9]
          ) : void 0
        ),
        Be(e, "click", Hu(
          /*click_handler*/
          t[30]
        ))
      ], n = !0);
    },
    p(s, l) {
      t = s, i !== /*name*/
      t[61] && (o(), i = /*name*/
      t[61], a()), l[0] & /*add_lr_border*/
      32 && bi(
        e,
        "lr",
        /*add_lr_border*/
        t[5]
      ), l[0] & /*add_lr_border*/
      32 && bi(e, "tb", !/*add_lr_border*/
      t[5]);
    },
    d(s) {
      s && ir(e), o(), n = !1, Ou(r);
    }
  };
}
function xu(t) {
  let e, i, n, r = (
    /*line_count*/
    t[4] === 0 && aa()
  ), a = ta(
    /*canvas_types*/
    t[6]
  ), o = [];
  for (let s = 0; s < a.length; s += 1)
    o[s] = oa(ra(t, a, s));
  return {
    c() {
      e = nr("div"), r && r.c(), i = Bu();
      for (let s = 0; s < o.length; s += 1)
        o[s].c();
      Oi(e, "class", "wrap svelte-14l85k0"), _o(() => (
        /*div_elementresize_handler*/
        t[33].call(e)
      ));
    },
    m(s, l) {
      rr(s, e, l), r && r.m(e, null), ku(e, i);
      for (let h = 0; h < o.length; h += 1)
        o[h] && o[h].m(e, null);
      t[32](e), n = Eu(
        e,
        /*div_elementresize_handler*/
        t[33].bind(e)
      );
    },
    p(s, l) {
      if (/*line_count*/
      s[4] === 0 ? r ? l[0] & /*line_count*/
      16 && pn(r, 1) : (r = aa(), r.c(), pn(r, 1), r.m(e, i)) : r && (Mu(), na(r, 1, 1, () => {
        r = null;
      }), Su()), l[0] & /*canvas_types, canvas, add_lr_border, handle_draw_start, handle_draw_move, handle_draw_end*/
      993) {
        a = ta(
          /*canvas_types*/
          s[6]
        );
        let h;
        for (h = 0; h < a.length; h += 1) {
          const u = ra(s, a, h);
          o[h] ? o[h].p(u, l) : (o[h] = oa(u), o[h].c(), o[h].m(e, null));
        }
        for (; h < o.length; h += 1)
          o[h].d(1);
        o.length = a.length;
      }
    },
    i(s) {
      pn(r);
    },
    o(s) {
      na(r);
    },
    d(s) {
      s && ir(e), r && r.d(), Cu(o, s), t[32](null), n();
    }
  };
}
let Pu = "#aaa";
function Lu(t, e) {
  return {
    x: t.x + (e.x - t.x) / 2,
    y: t.y + (e.y - t.y) / 2
  };
}
function Uu(t, e, i) {
  let n;
  const r = Ru();
  let { value: a } = e, { value_img: o } = e, { mode: s = "sketch" } = e, { brush_color: l = "#0b0f19" } = e, { brush_radius: h } = e, { mask_opacity: u = 0.7 } = e, { source: f } = e, { width: c = 400 } = e, { height: d = 200 } = e, { container_height: m = 200 } = e, { shape: p } = e, v, k = c, T = d, S;
  const I = [
    { name: "interface", zIndex: 15 },
    {
      name: "mask",
      zIndex: 13,
      opacity: u
    },
    { name: "drawing", zIndex: 11 },
    { name: "temp", zIndex: 12 }
  ];
  let w = {}, _ = {}, E = [], O = [], G = !0, Z = !0, oe = !1, se = !1, y = null, D = null, F = null, Q = 0;
  function q() {
    if (!p) {
      _.temp.drawImage(o, 0, 0, c, d);
      return;
    }
    let g = o.naturalWidth, C = o.naturalHeight;
    const R = p[0] / p[1], te = g / C;
    let j = 0, ce = 0;
    R < te ? (g = p[1] * te, C = p[1], j = (p[0] - g) / 2) : R > te ? (g = p[0], C = p[0] / te, ce = (p[1] - C) / 2) : (j = 0, ce = 0, g = p[0], C = p[1]), _.temp.drawImage(o, j, ce, g, C);
  }
  Iu(async () => {
    Object.keys(w).forEach((g) => {
      i(27, _[g] = w[g].getContext("2d"), _);
    }), await gn(), o && (o.addEventListener("load", (g) => {
      f === "webcam" ? (_.temp.save(), _.temp.translate(c, 0), _.temp.scale(-1, 1), _.temp.drawImage(o, 0, 0), _.temp.restore()) : q(), _.drawing.drawImage(w.temp, 0, 0, c, d), Re();
    }), setTimeout(
      () => {
        f === "webcam" ? (_.temp.save(), _.temp.translate(c, 0), _.temp.scale(-1, 1), _.temp.drawImage(o, 0, 0), _.temp.restore()) : q(), _.drawing.drawImage(w.temp, 0, 0, c, d), Ue({ lines: O.slice() }), Re();
      },
      100
    )), i(29, y = new iu({
      radius: h * 0.05,
      enabled: !0,
      initialPoint: { x: c / 2, y: d / 2 }
    })), F = new wu((g, C, ...R) => {
      ri();
    }), F.observe(D), Pt(), i(25, v = !0), requestAnimationFrame(() => {
      Y(), requestAnimationFrame(() => {
        Ye();
      });
    });
  });
  function Y() {
    const g = c / 2, C = d / 2;
    y.update({ x: g, y: C }, { both: !0 }), y.update({ x: g, y: C }, { both: !1 }), G = !0, Z = !0;
  }
  Nu(() => {
    i(25, v = !1), F.unobserve(D);
  });
  function ue(g) {
    ui(), o && (f === "webcam" ? (_.temp.save(), _.temp.translate(c, 0), _.temp.scale(-1, 1), _.temp.drawImage(o, 0, 0), _.temp.restore()) : q(), (!O || !O.length) && _.drawing.drawImage(w.temp, 0, 0, c, d)), Ue({ lines: g }), i(4, Q = g.length), i(28, O = g), _.drawing.drawImage(w.temp, 0, 0, c, d), O.length == 0 && r("clear");
  }
  function Le() {
    ue([]), Re();
  }
  function Te() {
    const g = O.slice(0, -1);
    ue(g), Re();
  }
  let Ue = ({ lines: g }) => {
    g.forEach((C) => {
      const { points: R, brush_color: te, brush_radius: j } = C;
      si({
        points: R,
        brush_color: te,
        brush_radius: j,
        mask: s === "mask"
      });
    }), hi(), s === "mask" && li();
  }, st = (g) => {
    g.preventDefault(), se = !0;
    const { x: C, y: R } = ai(g);
    g.touches && g.touches.length > 0 && y.update({ x: C, y: R }, { both: !0 }), oi(C, R), i(4, Q += 1);
  }, lt = (g) => {
    g.preventDefault();
    const { x: C, y: R } = ai(g);
    oi(C, R);
  }, xt = (g) => {
    g.preventDefault(), lt(g), oe = !1, se = !1, hi(), s === "mask" && li();
  }, ei = 0, ti = 0, ii = 0, ni = !1, ri = async () => {
    if (p && D) {
      const R = D == null ? void 0 : D.getBoundingClientRect(), te = p[0] / p[1], j = R.width / R.height;
      i(5, ni = te < j);
    }
    if (c === ei && d === ti && ii === m)
      return;
    const g = { width: c, height: d }, C = {
      height: m,
      width: m * (g.width / g.height)
    };
    await Promise.all([
      ht(w.interface, g, C),
      ht(w.drawing, g, C),
      ht(w.temp, g, C),
      ht(w.mask, g, C, !1)
    ]), h || i(10, h = 20 * (g.width / C.width)), Pt({ once: !0 }), setTimeout(
      () => {
        ti = d, ei = c, ii = m;
      },
      10
    ), await gn(), Ye();
  }, ht = async (g, C, R, te = !0) => {
    if (!v)
      return;
    await gn();
    const j = window.devicePixelRatio || 1;
    g.width = C.width * (te ? j : 1), g.height = C.height * (te ? j : 1);
    const ce = g.getContext("2d");
    te && ce.scale(j, j), g.style.width = `${R.width}px`, g.style.height = `${R.height}px`;
  }, ai = (g) => {
    const C = w.interface.getBoundingClientRect();
    let R = g.clientX, te = g.clientY;
    return g.changedTouches && g.changedTouches.length > 0 && (R = g.changedTouches[0].clientX, te = g.changedTouches[0].clientY), {
      x: (R - C.left) / C.width * c,
      y: (te - C.top) / C.height * d
    };
  }, oi = (g, C) => {
    y.update({ x: g, y: C });
    const R = !y.isEnabled();
    (se && !oe || R && se) && (oe = !0, E.push(y.brush.toObject())), oe && (E.push(y.brush.toObject()), si({
      points: E,
      brush_color: l,
      brush_radius: h,
      mask: s === "mask"
    })), G = !0;
  }, si = ({ points: g, brush_color: C, brush_radius: R, mask: te }) => {
    if (!g || g.length < 2)
      return;
    let j = te ? _.mask : _.temp;
    j.lineJoin = "round", j.lineCap = "round", j.strokeStyle = C, j.lineWidth = R;
    let ce = g[0], ut = g[1];
    j.moveTo(ut.x, ut.y), j.beginPath();
    for (var b = 1, Oe = g.length; b < Oe; b++) {
      var fi = Lu(ce, ut);
      j.quadraticCurveTo(ce.x, ce.y, fi.x, fi.y), ce = g[b], ut = g[b + 1];
    }
    j.lineTo(ce.x, ce.y), j.stroke();
  }, li = () => {
    E.length < 1 || (E.length = 0, Re());
  }, hi = () => {
    E.length < 1 || (O.push({
      points: E.slice(),
      brush_color: l,
      brush_radius: h
    }), s !== "mask" && (E.length = 0), _.drawing.drawImage(w.temp, 0, 0, c, d), Re());
  }, Re = () => {
    const g = ci();
    r("change", g);
  };
  function Ye() {
    return i(28, O = []), ui(), i(4, Q = 0), !0;
  }
  function ui() {
    Z = !0, _.temp.clearRect(0, 0, c, d), i(27, _.temp.fillStyle = s === "mask" ? "transparent" : "#FFFFFF", _), _.temp.fillRect(0, 0, c, d), s === "mask" && _.mask.clearRect(0, 0, w.mask.width, w.mask.height);
  }
  let Pt = ({ once: g = !1 } = {}) => {
    if (G || Z) {
      const C = y.getPointerCoordinates(), R = y.getBrushCoordinates();
      Xi(_.interface, C, R), G = !1, Z = !1;
    }
    g || window.requestAnimationFrame(() => {
      Pt();
    });
  }, Xi = (g, C, R) => {
    g.clearRect(0, 0, c, d), g.beginPath(), g.fillStyle = l, g.arc(R.x, R.y, h / 2, 0, Math.PI * 2, !0), g.fill(), g.beginPath(), g.fillStyle = Pu, g.arc(R.x, R.y, n, 0, Math.PI * 2, !0), g.fill();
  };
  function ci() {
    return s === "mask" ? w.mask.toDataURL("image/png") : w.drawing.toDataURL("image/jpg");
  }
  function Wi(g) {
    Tu.call(this, t, g);
  }
  function Vi(g, C) {
    $r[g ? "unshift" : "push"](() => {
      w[C] = g, i(0, w);
    });
  }
  function qi(g) {
    $r[g ? "unshift" : "push"](() => {
      D = g, i(3, D);
    });
  }
  function Yi() {
    k = this.offsetWidth, T = this.offsetHeight, i(1, k), i(2, T);
  }
  return t.$$set = (g) => {
    "value" in g && i(13, a = g.value), "value_img" in g && i(14, o = g.value_img), "mode" in g && i(15, s = g.mode), "brush_color" in g && i(16, l = g.brush_color), "brush_radius" in g && i(10, h = g.brush_radius), "mask_opacity" in g && i(17, u = g.mask_opacity), "source" in g && i(18, f = g.source), "width" in g && i(11, c = g.width), "height" in g && i(12, d = g.height), "container_height" in g && i(19, m = g.container_height), "shape" in g && i(20, p = g.shape);
  }, t.$$.update = () => {
    t.$$.dirty[0] & /*shape, width, height*/
    1054720 && p && (c || d) && (i(11, c = p[0]), i(12, d = p[1])), t.$$.dirty[0] & /*mounted, value*/
    33562624 && v && !a && Ye(), t.$$.dirty[0] & /*mounted, value_img, last_value_img, source, ctx, width, canvas, height, lines*/
    503601153 && v && o !== S && (i(26, S = o), Ye(), setTimeout(
      () => {
        f === "webcam" ? (_.temp.save(), _.temp.translate(c, 0), _.temp.scale(-1, 1), _.temp.drawImage(o, 0, 0), _.temp.restore()) : q(), _.drawing.drawImage(w.temp, 0, 0, c, d), Ue({ lines: O.slice() }), Re();
      },
      50
    )), t.$$.dirty[0] & /*lazy, brush_radius*/
    536871936 && y && (Y(), y.setRadius(h * 0.05)), t.$$.dirty[0] & /*width, height*/
    6144 && (c || d) && ri(), t.$$.dirty[0] & /*brush_radius*/
    1024 && (n = h * 0.075);
  }, [
    w,
    k,
    T,
    D,
    Q,
    ni,
    I,
    st,
    lt,
    xt,
    h,
    c,
    d,
    a,
    o,
    s,
    l,
    u,
    f,
    m,
    p,
    Le,
    Te,
    Ye,
    ci,
    v,
    S,
    _,
    O,
    y,
    Wi,
    Vi,
    qi,
    Yi
  ];
}
class ar extends yu {
  constructor(e) {
    super(), Au(
      this,
      e,
      Uu,
      xu,
      Du,
      {
        value: 13,
        value_img: 14,
        mode: 15,
        brush_color: 16,
        brush_radius: 10,
        mask_opacity: 17,
        source: 18,
        width: 11,
        height: 12,
        container_height: 19,
        shape: 20,
        clear_mask: 21,
        undo: 22,
        clear: 23,
        get_image_data: 24
      },
      null,
      [-1, -1, -1]
    );
  }
  get clear_mask() {
    return this.$$.ctx[21];
  }
  get undo() {
    return this.$$.ctx[22];
  }
  get clear() {
    return this.$$.ctx[23];
  }
  get get_image_data() {
    return this.$$.ctx[24];
  }
}
function Gu(t) {
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
}
var zu = function(e) {
  return Fu(e) && !ju(e);
};
function Fu(t) {
  return !!t && typeof t == "object";
}
function ju(t) {
  var e = Object.prototype.toString.call(t);
  return e === "[object RegExp]" || e === "[object Date]" || Vu(t);
}
var Xu = typeof Symbol == "function" && Symbol.for, Wu = Xu ? Symbol.for("react.element") : 60103;
function Vu(t) {
  return t.$$typeof === Wu;
}
function qu(t) {
  return Array.isArray(t) ? [] : {};
}
function Zt(t, e) {
  return e.clone !== !1 && e.isMergeableObject(t) ? Tt(qu(t), t, e) : t;
}
function Yu(t, e, i) {
  return t.concat(e).map(function(n) {
    return Zt(n, i);
  });
}
function Zu(t, e) {
  if (!e.customMerge)
    return Tt;
  var i = e.customMerge(t);
  return typeof i == "function" ? i : Tt;
}
function Qu(t) {
  return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(t).filter(function(e) {
    return Object.propertyIsEnumerable.call(t, e);
  }) : [];
}
function sa(t) {
  return Object.keys(t).concat(Qu(t));
}
function po(t, e) {
  try {
    return e in t;
  } catch {
    return !1;
  }
}
function Ju(t, e) {
  return po(t, e) && !(Object.hasOwnProperty.call(t, e) && Object.propertyIsEnumerable.call(t, e));
}
function Ku(t, e, i) {
  var n = {};
  return i.isMergeableObject(t) && sa(t).forEach(function(r) {
    n[r] = Zt(t[r], i);
  }), sa(e).forEach(function(r) {
    Ju(t, r) || (po(t, r) && i.isMergeableObject(e[r]) ? n[r] = Zu(r, i)(t[r], e[r], i) : n[r] = Zt(e[r], i));
  }), n;
}
function Tt(t, e, i) {
  i = i || {}, i.arrayMerge = i.arrayMerge || Yu, i.isMergeableObject = i.isMergeableObject || zu, i.cloneUnlessOtherwiseSpecified = Zt;
  var n = Array.isArray(e), r = Array.isArray(t), a = n === r;
  return a ? n ? i.arrayMerge(t, e, i) : Ku(t, e, i) : Zt(e, i);
}
Tt.all = function(e, i) {
  if (!Array.isArray(e))
    throw new Error("first argument should be an array");
  return e.reduce(function(n, r) {
    return Tt(n, r, i);
  }, {});
};
var $u = Tt, ec = $u;
const tc = /* @__PURE__ */ Gu(ec);
var Pn = function(t, e) {
  return Pn = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(i, n) {
    i.__proto__ = n;
  } || function(i, n) {
    for (var r in n)
      Object.prototype.hasOwnProperty.call(n, r) && (i[r] = n[r]);
  }, Pn(t, e);
};
function Pi(t, e) {
  if (typeof e != "function" && e !== null)
    throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
  Pn(t, e);
  function i() {
    this.constructor = t;
  }
  t.prototype = e === null ? Object.create(e) : (i.prototype = e.prototype, new i());
}
var x = function() {
  return x = Object.assign || function(e) {
    for (var i, n = 1, r = arguments.length; n < r; n++) {
      i = arguments[n];
      for (var a in i)
        Object.prototype.hasOwnProperty.call(i, a) && (e[a] = i[a]);
    }
    return e;
  }, x.apply(this, arguments);
};
function bn(t, e, i) {
  if (i || arguments.length === 2)
    for (var n = 0, r = e.length, a; n < r; n++)
      (a || !(n in e)) && (a || (a = Array.prototype.slice.call(e, 0, n)), a[n] = e[n]);
  return t.concat(a || Array.prototype.slice.call(e));
}
var B;
(function(t) {
  t[t.EXPECT_ARGUMENT_CLOSING_BRACE = 1] = "EXPECT_ARGUMENT_CLOSING_BRACE", t[t.EMPTY_ARGUMENT = 2] = "EMPTY_ARGUMENT", t[t.MALFORMED_ARGUMENT = 3] = "MALFORMED_ARGUMENT", t[t.EXPECT_ARGUMENT_TYPE = 4] = "EXPECT_ARGUMENT_TYPE", t[t.INVALID_ARGUMENT_TYPE = 5] = "INVALID_ARGUMENT_TYPE", t[t.EXPECT_ARGUMENT_STYLE = 6] = "EXPECT_ARGUMENT_STYLE", t[t.INVALID_NUMBER_SKELETON = 7] = "INVALID_NUMBER_SKELETON", t[t.INVALID_DATE_TIME_SKELETON = 8] = "INVALID_DATE_TIME_SKELETON", t[t.EXPECT_NUMBER_SKELETON = 9] = "EXPECT_NUMBER_SKELETON", t[t.EXPECT_DATE_TIME_SKELETON = 10] = "EXPECT_DATE_TIME_SKELETON", t[t.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE = 11] = "UNCLOSED_QUOTE_IN_ARGUMENT_STYLE", t[t.EXPECT_SELECT_ARGUMENT_OPTIONS = 12] = "EXPECT_SELECT_ARGUMENT_OPTIONS", t[t.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE = 13] = "EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE", t[t.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE = 14] = "INVALID_PLURAL_ARGUMENT_OFFSET_VALUE", t[t.EXPECT_SELECT_ARGUMENT_SELECTOR = 15] = "EXPECT_SELECT_ARGUMENT_SELECTOR", t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR = 16] = "EXPECT_PLURAL_ARGUMENT_SELECTOR", t[t.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT = 17] = "EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT", t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT = 18] = "EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT", t[t.INVALID_PLURAL_ARGUMENT_SELECTOR = 19] = "INVALID_PLURAL_ARGUMENT_SELECTOR", t[t.DUPLICATE_PLURAL_ARGUMENT_SELECTOR = 20] = "DUPLICATE_PLURAL_ARGUMENT_SELECTOR", t[t.DUPLICATE_SELECT_ARGUMENT_SELECTOR = 21] = "DUPLICATE_SELECT_ARGUMENT_SELECTOR", t[t.MISSING_OTHER_CLAUSE = 22] = "MISSING_OTHER_CLAUSE", t[t.INVALID_TAG = 23] = "INVALID_TAG", t[t.INVALID_TAG_NAME = 25] = "INVALID_TAG_NAME", t[t.UNMATCHED_CLOSING_TAG = 26] = "UNMATCHED_CLOSING_TAG", t[t.UNCLOSED_TAG = 27] = "UNCLOSED_TAG";
})(B || (B = {}));
var W;
(function(t) {
  t[t.literal = 0] = "literal", t[t.argument = 1] = "argument", t[t.number = 2] = "number", t[t.date = 3] = "date", t[t.time = 4] = "time", t[t.select = 5] = "select", t[t.plural = 6] = "plural", t[t.pound = 7] = "pound", t[t.tag = 8] = "tag";
})(W || (W = {}));
var St;
(function(t) {
  t[t.number = 0] = "number", t[t.dateTime = 1] = "dateTime";
})(St || (St = {}));
function la(t) {
  return t.type === W.literal;
}
function ic(t) {
  return t.type === W.argument;
}
function go(t) {
  return t.type === W.number;
}
function bo(t) {
  return t.type === W.date;
}
function vo(t) {
  return t.type === W.time;
}
function wo(t) {
  return t.type === W.select;
}
function yo(t) {
  return t.type === W.plural;
}
function nc(t) {
  return t.type === W.pound;
}
function Eo(t) {
  return t.type === W.tag;
}
function ko(t) {
  return !!(t && typeof t == "object" && t.type === St.number);
}
function Ln(t) {
  return !!(t && typeof t == "object" && t.type === St.dateTime);
}
var To = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/, rc = /(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;
function ac(t) {
  var e = {};
  return t.replace(rc, function(i) {
    var n = i.length;
    switch (i[0]) {
      case "G":
        e.era = n === 4 ? "long" : n === 5 ? "narrow" : "short";
        break;
      case "y":
        e.year = n === 2 ? "2-digit" : "numeric";
        break;
      case "Y":
      case "u":
      case "U":
      case "r":
        throw new RangeError("`Y/u/U/r` (year) patterns are not supported, use `y` instead");
      case "q":
      case "Q":
        throw new RangeError("`q/Q` (quarter) patterns are not supported");
      case "M":
      case "L":
        e.month = ["numeric", "2-digit", "short", "long", "narrow"][n - 1];
        break;
      case "w":
      case "W":
        throw new RangeError("`w/W` (week) patterns are not supported");
      case "d":
        e.day = ["numeric", "2-digit"][n - 1];
        break;
      case "D":
      case "F":
      case "g":
        throw new RangeError("`D/F/g` (day) patterns are not supported, use `d` instead");
      case "E":
        e.weekday = n === 4 ? "short" : n === 5 ? "narrow" : "short";
        break;
      case "e":
        if (n < 4)
          throw new RangeError("`e..eee` (weekday) patterns are not supported");
        e.weekday = ["short", "long", "narrow", "short"][n - 4];
        break;
      case "c":
        if (n < 4)
          throw new RangeError("`c..ccc` (weekday) patterns are not supported");
        e.weekday = ["short", "long", "narrow", "short"][n - 4];
        break;
      case "a":
        e.hour12 = !0;
        break;
      case "b":
      case "B":
        throw new RangeError("`b/B` (period) patterns are not supported, use `a` instead");
      case "h":
        e.hourCycle = "h12", e.hour = ["numeric", "2-digit"][n - 1];
        break;
      case "H":
        e.hourCycle = "h23", e.hour = ["numeric", "2-digit"][n - 1];
        break;
      case "K":
        e.hourCycle = "h11", e.hour = ["numeric", "2-digit"][n - 1];
        break;
      case "k":
        e.hourCycle = "h24", e.hour = ["numeric", "2-digit"][n - 1];
        break;
      case "j":
      case "J":
      case "C":
        throw new RangeError("`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead");
      case "m":
        e.minute = ["numeric", "2-digit"][n - 1];
        break;
      case "s":
        e.second = ["numeric", "2-digit"][n - 1];
        break;
      case "S":
      case "A":
        throw new RangeError("`S/A` (second) patterns are not supported, use `s` instead");
      case "z":
        e.timeZoneName = n < 4 ? "short" : "long";
        break;
      case "Z":
      case "O":
      case "v":
      case "V":
      case "X":
      case "x":
        throw new RangeError("`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead");
    }
    return "";
  }), e;
}
var oc = /[\t-\r \x85\u200E\u200F\u2028\u2029]/i;
function sc(t) {
  if (t.length === 0)
    throw new Error("Number skeleton cannot be empty");
  for (var e = t.split(oc).filter(function(c) {
    return c.length > 0;
  }), i = [], n = 0, r = e; n < r.length; n++) {
    var a = r[n], o = a.split("/");
    if (o.length === 0)
      throw new Error("Invalid number skeleton");
    for (var s = o[0], l = o.slice(1), h = 0, u = l; h < u.length; h++) {
      var f = u[h];
      if (f.length === 0)
        throw new Error("Invalid number skeleton");
    }
    i.push({ stem: s, options: l });
  }
  return i;
}
function lc(t) {
  return t.replace(/^(.*?)-/, "");
}
var ha = /^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g, So = /^(@+)?(\+|#+)?[rs]?$/g, hc = /(\*)(0+)|(#+)(0+)|(0+)/g, Co = /^(0+)$/;
function ua(t) {
  var e = {};
  return t[t.length - 1] === "r" ? e.roundingPriority = "morePrecision" : t[t.length - 1] === "s" && (e.roundingPriority = "lessPrecision"), t.replace(So, function(i, n, r) {
    return typeof r != "string" ? (e.minimumSignificantDigits = n.length, e.maximumSignificantDigits = n.length) : r === "+" ? e.minimumSignificantDigits = n.length : n[0] === "#" ? e.maximumSignificantDigits = n.length : (e.minimumSignificantDigits = n.length, e.maximumSignificantDigits = n.length + (typeof r == "string" ? r.length : 0)), "";
  }), e;
}
function Mo(t) {
  switch (t) {
    case "sign-auto":
      return {
        signDisplay: "auto"
      };
    case "sign-accounting":
    case "()":
      return {
        currencySign: "accounting"
      };
    case "sign-always":
    case "+!":
      return {
        signDisplay: "always"
      };
    case "sign-accounting-always":
    case "()!":
      return {
        signDisplay: "always",
        currencySign: "accounting"
      };
    case "sign-except-zero":
    case "+?":
      return {
        signDisplay: "exceptZero"
      };
    case "sign-accounting-except-zero":
    case "()?":
      return {
        signDisplay: "exceptZero",
        currencySign: "accounting"
      };
    case "sign-never":
    case "+_":
      return {
        signDisplay: "never"
      };
  }
}
function uc(t) {
  var e;
  if (t[0] === "E" && t[1] === "E" ? (e = {
    notation: "engineering"
  }, t = t.slice(2)) : t[0] === "E" && (e = {
    notation: "scientific"
  }, t = t.slice(1)), e) {
    var i = t.slice(0, 2);
    if (i === "+!" ? (e.signDisplay = "always", t = t.slice(2)) : i === "+?" && (e.signDisplay = "exceptZero", t = t.slice(2)), !Co.test(t))
      throw new Error("Malformed concise eng/scientific notation");
    e.minimumIntegerDigits = t.length;
  }
  return e;
}
function ca(t) {
  var e = {}, i = Mo(t);
  return i || e;
}
function cc(t) {
  for (var e = {}, i = 0, n = t; i < n.length; i++) {
    var r = n[i];
    switch (r.stem) {
      case "percent":
      case "%":
        e.style = "percent";
        continue;
      case "%x100":
        e.style = "percent", e.scale = 100;
        continue;
      case "currency":
        e.style = "currency", e.currency = r.options[0];
        continue;
      case "group-off":
      case ",_":
        e.useGrouping = !1;
        continue;
      case "precision-integer":
      case ".":
        e.maximumFractionDigits = 0;
        continue;
      case "measure-unit":
      case "unit":
        e.style = "unit", e.unit = lc(r.options[0]);
        continue;
      case "compact-short":
      case "K":
        e.notation = "compact", e.compactDisplay = "short";
        continue;
      case "compact-long":
      case "KK":
        e.notation = "compact", e.compactDisplay = "long";
        continue;
      case "scientific":
        e = x(x(x({}, e), { notation: "scientific" }), r.options.reduce(function(l, h) {
          return x(x({}, l), ca(h));
        }, {}));
        continue;
      case "engineering":
        e = x(x(x({}, e), { notation: "engineering" }), r.options.reduce(function(l, h) {
          return x(x({}, l), ca(h));
        }, {}));
        continue;
      case "notation-simple":
        e.notation = "standard";
        continue;
      case "unit-width-narrow":
        e.currencyDisplay = "narrowSymbol", e.unitDisplay = "narrow";
        continue;
      case "unit-width-short":
        e.currencyDisplay = "code", e.unitDisplay = "short";
        continue;
      case "unit-width-full-name":
        e.currencyDisplay = "name", e.unitDisplay = "long";
        continue;
      case "unit-width-iso-code":
        e.currencyDisplay = "symbol";
        continue;
      case "scale":
        e.scale = parseFloat(r.options[0]);
        continue;
      case "integer-width":
        if (r.options.length > 1)
          throw new RangeError("integer-width stems only accept a single optional option");
        r.options[0].replace(hc, function(l, h, u, f, c, d) {
          if (h)
            e.minimumIntegerDigits = u.length;
          else {
            if (f && c)
              throw new Error("We currently do not support maximum integer digits");
            if (d)
              throw new Error("We currently do not support exact integer digits");
          }
          return "";
        });
        continue;
    }
    if (Co.test(r.stem)) {
      e.minimumIntegerDigits = r.stem.length;
      continue;
    }
    if (ha.test(r.stem)) {
      if (r.options.length > 1)
        throw new RangeError("Fraction-precision stems only accept a single optional option");
      r.stem.replace(ha, function(l, h, u, f, c, d) {
        return u === "*" ? e.minimumFractionDigits = h.length : f && f[0] === "#" ? e.maximumFractionDigits = f.length : c && d ? (e.minimumFractionDigits = c.length, e.maximumFractionDigits = c.length + d.length) : (e.minimumFractionDigits = h.length, e.maximumFractionDigits = h.length), "";
      });
      var a = r.options[0];
      a === "w" ? e = x(x({}, e), { trailingZeroDisplay: "stripIfInteger" }) : a && (e = x(x({}, e), ua(a)));
      continue;
    }
    if (So.test(r.stem)) {
      e = x(x({}, e), ua(r.stem));
      continue;
    }
    var o = Mo(r.stem);
    o && (e = x(x({}, e), o));
    var s = uc(r.stem);
    s && (e = x(x({}, e), s));
  }
  return e;
}
var vi = {
  AX: [
    "H"
  ],
  BQ: [
    "H"
  ],
  CP: [
    "H"
  ],
  CZ: [
    "H"
  ],
  DK: [
    "H"
  ],
  FI: [
    "H"
  ],
  ID: [
    "H"
  ],
  IS: [
    "H"
  ],
  ML: [
    "H"
  ],
  NE: [
    "H"
  ],
  RU: [
    "H"
  ],
  SE: [
    "H"
  ],
  SJ: [
    "H"
  ],
  SK: [
    "H"
  ],
  AS: [
    "h",
    "H"
  ],
  BT: [
    "h",
    "H"
  ],
  DJ: [
    "h",
    "H"
  ],
  ER: [
    "h",
    "H"
  ],
  GH: [
    "h",
    "H"
  ],
  IN: [
    "h",
    "H"
  ],
  LS: [
    "h",
    "H"
  ],
  PG: [
    "h",
    "H"
  ],
  PW: [
    "h",
    "H"
  ],
  SO: [
    "h",
    "H"
  ],
  TO: [
    "h",
    "H"
  ],
  VU: [
    "h",
    "H"
  ],
  WS: [
    "h",
    "H"
  ],
  "001": [
    "H",
    "h"
  ],
  AL: [
    "h",
    "H",
    "hB"
  ],
  TD: [
    "h",
    "H",
    "hB"
  ],
  "ca-ES": [
    "H",
    "h",
    "hB"
  ],
  CF: [
    "H",
    "h",
    "hB"
  ],
  CM: [
    "H",
    "h",
    "hB"
  ],
  "fr-CA": [
    "H",
    "h",
    "hB"
  ],
  "gl-ES": [
    "H",
    "h",
    "hB"
  ],
  "it-CH": [
    "H",
    "h",
    "hB"
  ],
  "it-IT": [
    "H",
    "h",
    "hB"
  ],
  LU: [
    "H",
    "h",
    "hB"
  ],
  NP: [
    "H",
    "h",
    "hB"
  ],
  PF: [
    "H",
    "h",
    "hB"
  ],
  SC: [
    "H",
    "h",
    "hB"
  ],
  SM: [
    "H",
    "h",
    "hB"
  ],
  SN: [
    "H",
    "h",
    "hB"
  ],
  TF: [
    "H",
    "h",
    "hB"
  ],
  VA: [
    "H",
    "h",
    "hB"
  ],
  CY: [
    "h",
    "H",
    "hb",
    "hB"
  ],
  GR: [
    "h",
    "H",
    "hb",
    "hB"
  ],
  CO: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  DO: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  KP: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  KR: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  NA: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  PA: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  PR: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  VE: [
    "h",
    "H",
    "hB",
    "hb"
  ],
  AC: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  AI: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  BW: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  BZ: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  CC: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  CK: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  CX: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  DG: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  FK: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  GB: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  GG: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  GI: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  IE: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  IM: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  IO: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  JE: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  LT: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  MK: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  MN: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  MS: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  NF: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  NG: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  NR: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  NU: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  PN: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  SH: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  SX: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  TA: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  ZA: [
    "H",
    "h",
    "hb",
    "hB"
  ],
  "af-ZA": [
    "H",
    "h",
    "hB",
    "hb"
  ],
  AR: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  CL: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  CR: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  CU: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  EA: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  "es-BO": [
    "H",
    "h",
    "hB",
    "hb"
  ],
  "es-BR": [
    "H",
    "h",
    "hB",
    "hb"
  ],
  "es-EC": [
    "H",
    "h",
    "hB",
    "hb"
  ],
  "es-ES": [
    "H",
    "h",
    "hB",
    "hb"
  ],
  "es-GQ": [
    "H",
    "h",
    "hB",
    "hb"
  ],
  "es-PE": [
    "H",
    "h",
    "hB",
    "hb"
  ],
  GT: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  HN: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  IC: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  KG: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  KM: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  LK: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  MA: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  MX: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  NI: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  PY: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  SV: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  UY: [
    "H",
    "h",
    "hB",
    "hb"
  ],
  JP: [
    "H",
    "h",
    "K"
  ],
  AD: [
    "H",
    "hB"
  ],
  AM: [
    "H",
    "hB"
  ],
  AO: [
    "H",
    "hB"
  ],
  AT: [
    "H",
    "hB"
  ],
  AW: [
    "H",
    "hB"
  ],
  BE: [
    "H",
    "hB"
  ],
  BF: [
    "H",
    "hB"
  ],
  BJ: [
    "H",
    "hB"
  ],
  BL: [
    "H",
    "hB"
  ],
  BR: [
    "H",
    "hB"
  ],
  CG: [
    "H",
    "hB"
  ],
  CI: [
    "H",
    "hB"
  ],
  CV: [
    "H",
    "hB"
  ],
  DE: [
    "H",
    "hB"
  ],
  EE: [
    "H",
    "hB"
  ],
  FR: [
    "H",
    "hB"
  ],
  GA: [
    "H",
    "hB"
  ],
  GF: [
    "H",
    "hB"
  ],
  GN: [
    "H",
    "hB"
  ],
  GP: [
    "H",
    "hB"
  ],
  GW: [
    "H",
    "hB"
  ],
  HR: [
    "H",
    "hB"
  ],
  IL: [
    "H",
    "hB"
  ],
  IT: [
    "H",
    "hB"
  ],
  KZ: [
    "H",
    "hB"
  ],
  MC: [
    "H",
    "hB"
  ],
  MD: [
    "H",
    "hB"
  ],
  MF: [
    "H",
    "hB"
  ],
  MQ: [
    "H",
    "hB"
  ],
  MZ: [
    "H",
    "hB"
  ],
  NC: [
    "H",
    "hB"
  ],
  NL: [
    "H",
    "hB"
  ],
  PM: [
    "H",
    "hB"
  ],
  PT: [
    "H",
    "hB"
  ],
  RE: [
    "H",
    "hB"
  ],
  RO: [
    "H",
    "hB"
  ],
  SI: [
    "H",
    "hB"
  ],
  SR: [
    "H",
    "hB"
  ],
  ST: [
    "H",
    "hB"
  ],
  TG: [
    "H",
    "hB"
  ],
  TR: [
    "H",
    "hB"
  ],
  WF: [
    "H",
    "hB"
  ],
  YT: [
    "H",
    "hB"
  ],
  BD: [
    "h",
    "hB",
    "H"
  ],
  PK: [
    "h",
    "hB",
    "H"
  ],
  AZ: [
    "H",
    "hB",
    "h"
  ],
  BA: [
    "H",
    "hB",
    "h"
  ],
  BG: [
    "H",
    "hB",
    "h"
  ],
  CH: [
    "H",
    "hB",
    "h"
  ],
  GE: [
    "H",
    "hB",
    "h"
  ],
  LI: [
    "H",
    "hB",
    "h"
  ],
  ME: [
    "H",
    "hB",
    "h"
  ],
  RS: [
    "H",
    "hB",
    "h"
  ],
  UA: [
    "H",
    "hB",
    "h"
  ],
  UZ: [
    "H",
    "hB",
    "h"
  ],
  XK: [
    "H",
    "hB",
    "h"
  ],
  AG: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  AU: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  BB: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  BM: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  BS: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  CA: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  DM: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  "en-001": [
    "h",
    "hb",
    "H",
    "hB"
  ],
  FJ: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  FM: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  GD: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  GM: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  GU: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  GY: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  JM: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  KI: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  KN: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  KY: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  LC: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  LR: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  MH: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  MP: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  MW: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  NZ: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  SB: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  SG: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  SL: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  SS: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  SZ: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  TC: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  TT: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  UM: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  US: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  VC: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  VG: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  VI: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  ZM: [
    "h",
    "hb",
    "H",
    "hB"
  ],
  BO: [
    "H",
    "hB",
    "h",
    "hb"
  ],
  EC: [
    "H",
    "hB",
    "h",
    "hb"
  ],
  ES: [
    "H",
    "hB",
    "h",
    "hb"
  ],
  GQ: [
    "H",
    "hB",
    "h",
    "hb"
  ],
  PE: [
    "H",
    "hB",
    "h",
    "hb"
  ],
  AE: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  "ar-001": [
    "h",
    "hB",
    "hb",
    "H"
  ],
  BH: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  DZ: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  EG: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  EH: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  HK: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  IQ: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  JO: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  KW: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  LB: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  LY: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  MO: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  MR: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  OM: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  PH: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  PS: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  QA: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  SA: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  SD: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  SY: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  TN: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  YE: [
    "h",
    "hB",
    "hb",
    "H"
  ],
  AF: [
    "H",
    "hb",
    "hB",
    "h"
  ],
  LA: [
    "H",
    "hb",
    "hB",
    "h"
  ],
  CN: [
    "H",
    "hB",
    "hb",
    "h"
  ],
  LV: [
    "H",
    "hB",
    "hb",
    "h"
  ],
  TL: [
    "H",
    "hB",
    "hb",
    "h"
  ],
  "zu-ZA": [
    "H",
    "hB",
    "hb",
    "h"
  ],
  CD: [
    "hB",
    "H"
  ],
  IR: [
    "hB",
    "H"
  ],
  "hi-IN": [
    "hB",
    "h",
    "H"
  ],
  "kn-IN": [
    "hB",
    "h",
    "H"
  ],
  "ml-IN": [
    "hB",
    "h",
    "H"
  ],
  "te-IN": [
    "hB",
    "h",
    "H"
  ],
  KH: [
    "hB",
    "h",
    "H",
    "hb"
  ],
  "ta-IN": [
    "hB",
    "h",
    "hb",
    "H"
  ],
  BN: [
    "hb",
    "hB",
    "h",
    "H"
  ],
  MY: [
    "hb",
    "hB",
    "h",
    "H"
  ],
  ET: [
    "hB",
    "hb",
    "h",
    "H"
  ],
  "gu-IN": [
    "hB",
    "hb",
    "h",
    "H"
  ],
  "mr-IN": [
    "hB",
    "hb",
    "h",
    "H"
  ],
  "pa-IN": [
    "hB",
    "hb",
    "h",
    "H"
  ],
  TW: [
    "hB",
    "hb",
    "h",
    "H"
  ],
  KE: [
    "hB",
    "hb",
    "H",
    "h"
  ],
  MM: [
    "hB",
    "hb",
    "H",
    "h"
  ],
  TZ: [
    "hB",
    "hb",
    "H",
    "h"
  ],
  UG: [
    "hB",
    "hb",
    "H",
    "h"
  ]
};
function fc(t, e) {
  for (var i = "", n = 0; n < t.length; n++) {
    var r = t.charAt(n);
    if (r === "j") {
      for (var a = 0; n + 1 < t.length && t.charAt(n + 1) === r; )
        a++, n++;
      var o = 1 + (a & 1), s = a < 2 ? 1 : 3 + (a >> 1), l = "a", h = dc(e);
      for ((h == "H" || h == "k") && (s = 0); s-- > 0; )
        i += l;
      for (; o-- > 0; )
        i = h + i;
    } else
      r === "J" ? i += "H" : i += r;
  }
  return i;
}
function dc(t) {
  var e = t.hourCycle;
  if (e === void 0 && // @ts-ignore hourCycle(s) is not identified yet
  t.hourCycles && // @ts-ignore
  t.hourCycles.length && (e = t.hourCycles[0]), e)
    switch (e) {
      case "h24":
        return "k";
      case "h23":
        return "H";
      case "h12":
        return "h";
      case "h11":
        return "K";
      default:
        throw new Error("Invalid hourCycle");
    }
  var i = t.language, n;
  i !== "root" && (n = t.maximize().region);
  var r = vi[n || ""] || vi[i || ""] || vi["".concat(i, "-001")] || vi["001"];
  return r[0];
}
var vn, mc = new RegExp("^".concat(To.source, "*")), _c = new RegExp("".concat(To.source, "*$"));
function N(t, e) {
  return { start: t, end: e };
}
var pc = !!String.prototype.startsWith, gc = !!String.fromCodePoint, bc = !!Object.fromEntries, vc = !!String.prototype.codePointAt, wc = !!String.prototype.trimStart, yc = !!String.prototype.trimEnd, Ec = !!Number.isSafeInteger, kc = Ec ? Number.isSafeInteger : function(t) {
  return typeof t == "number" && isFinite(t) && Math.floor(t) === t && Math.abs(t) <= 9007199254740991;
}, Un = !0;
try {
  var Tc = Oo("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
  Un = ((vn = Tc.exec("a")) === null || vn === void 0 ? void 0 : vn[0]) === "a";
} catch {
  Un = !1;
}
var fa = pc ? (
  // Native
  function(e, i, n) {
    return e.startsWith(i, n);
  }
) : (
  // For IE11
  function(e, i, n) {
    return e.slice(n, n + i.length) === i;
  }
), Gn = gc ? String.fromCodePoint : (
  // IE11
  function() {
    for (var e = [], i = 0; i < arguments.length; i++)
      e[i] = arguments[i];
    for (var n = "", r = e.length, a = 0, o; r > a; ) {
      if (o = e[a++], o > 1114111)
        throw RangeError(o + " is not a valid code point");
      n += o < 65536 ? String.fromCharCode(o) : String.fromCharCode(((o -= 65536) >> 10) + 55296, o % 1024 + 56320);
    }
    return n;
  }
), da = (
  // native
  bc ? Object.fromEntries : (
    // Ponyfill
    function(e) {
      for (var i = {}, n = 0, r = e; n < r.length; n++) {
        var a = r[n], o = a[0], s = a[1];
        i[o] = s;
      }
      return i;
    }
  )
), Ao = vc ? (
  // Native
  function(e, i) {
    return e.codePointAt(i);
  }
) : (
  // IE 11
  function(e, i) {
    var n = e.length;
    if (!(i < 0 || i >= n)) {
      var r = e.charCodeAt(i), a;
      return r < 55296 || r > 56319 || i + 1 === n || (a = e.charCodeAt(i + 1)) < 56320 || a > 57343 ? r : (r - 55296 << 10) + (a - 56320) + 65536;
    }
  }
), Sc = wc ? (
  // Native
  function(e) {
    return e.trimStart();
  }
) : (
  // Ponyfill
  function(e) {
    return e.replace(mc, "");
  }
), Cc = yc ? (
  // Native
  function(e) {
    return e.trimEnd();
  }
) : (
  // Ponyfill
  function(e) {
    return e.replace(_c, "");
  }
);
function Oo(t, e) {
  return new RegExp(t, e);
}
var zn;
if (Un) {
  var ma = Oo("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
  zn = function(e, i) {
    var n;
    ma.lastIndex = i;
    var r = ma.exec(e);
    return (n = r[1]) !== null && n !== void 0 ? n : "";
  };
} else
  zn = function(e, i) {
    for (var n = []; ; ) {
      var r = Ao(e, i);
      if (r === void 0 || Do(r) || Dc(r))
        break;
      n.push(r), i += r >= 65536 ? 2 : 1;
    }
    return Gn.apply(void 0, n);
  };
var Mc = (
  /** @class */
  function() {
    function t(e, i) {
      i === void 0 && (i = {}), this.message = e, this.position = { offset: 0, line: 1, column: 1 }, this.ignoreTag = !!i.ignoreTag, this.locale = i.locale, this.requiresOtherClause = !!i.requiresOtherClause, this.shouldParseSkeletons = !!i.shouldParseSkeletons;
    }
    return t.prototype.parse = function() {
      if (this.offset() !== 0)
        throw Error("parser can only be used once");
      return this.parseMessage(0, "", !1);
    }, t.prototype.parseMessage = function(e, i, n) {
      for (var r = []; !this.isEOF(); ) {
        var a = this.char();
        if (a === 123) {
          var o = this.parseArgument(e, n);
          if (o.err)
            return o;
          r.push(o.val);
        } else {
          if (a === 125 && e > 0)
            break;
          if (a === 35 && (i === "plural" || i === "selectordinal")) {
            var s = this.clonePosition();
            this.bump(), r.push({
              type: W.pound,
              location: N(s, this.clonePosition())
            });
          } else if (a === 60 && !this.ignoreTag && this.peek() === 47) {
            if (n)
              break;
            return this.error(B.UNMATCHED_CLOSING_TAG, N(this.clonePosition(), this.clonePosition()));
          } else if (a === 60 && !this.ignoreTag && Fn(this.peek() || 0)) {
            var o = this.parseTag(e, i);
            if (o.err)
              return o;
            r.push(o.val);
          } else {
            var o = this.parseLiteral(e, i);
            if (o.err)
              return o;
            r.push(o.val);
          }
        }
      }
      return { val: r, err: null };
    }, t.prototype.parseTag = function(e, i) {
      var n = this.clonePosition();
      this.bump();
      var r = this.parseTagName();
      if (this.bumpSpace(), this.bumpIf("/>"))
        return {
          val: {
            type: W.literal,
            value: "<".concat(r, "/>"),
            location: N(n, this.clonePosition())
          },
          err: null
        };
      if (this.bumpIf(">")) {
        var a = this.parseMessage(e + 1, i, !0);
        if (a.err)
          return a;
        var o = a.val, s = this.clonePosition();
        if (this.bumpIf("</")) {
          if (this.isEOF() || !Fn(this.char()))
            return this.error(B.INVALID_TAG, N(s, this.clonePosition()));
          var l = this.clonePosition(), h = this.parseTagName();
          return r !== h ? this.error(B.UNMATCHED_CLOSING_TAG, N(l, this.clonePosition())) : (this.bumpSpace(), this.bumpIf(">") ? {
            val: {
              type: W.tag,
              value: r,
              children: o,
              location: N(n, this.clonePosition())
            },
            err: null
          } : this.error(B.INVALID_TAG, N(s, this.clonePosition())));
        } else
          return this.error(B.UNCLOSED_TAG, N(n, this.clonePosition()));
      } else
        return this.error(B.INVALID_TAG, N(n, this.clonePosition()));
    }, t.prototype.parseTagName = function() {
      var e = this.offset();
      for (this.bump(); !this.isEOF() && Oc(this.char()); )
        this.bump();
      return this.message.slice(e, this.offset());
    }, t.prototype.parseLiteral = function(e, i) {
      for (var n = this.clonePosition(), r = ""; ; ) {
        var a = this.tryParseQuote(i);
        if (a) {
          r += a;
          continue;
        }
        var o = this.tryParseUnquoted(e, i);
        if (o) {
          r += o;
          continue;
        }
        var s = this.tryParseLeftAngleBracket();
        if (s) {
          r += s;
          continue;
        }
        break;
      }
      var l = N(n, this.clonePosition());
      return {
        val: { type: W.literal, value: r, location: l },
        err: null
      };
    }, t.prototype.tryParseLeftAngleBracket = function() {
      return !this.isEOF() && this.char() === 60 && (this.ignoreTag || // If at the opening tag or closing tag position, bail.
      !Ac(this.peek() || 0)) ? (this.bump(), "<") : null;
    }, t.prototype.tryParseQuote = function(e) {
      if (this.isEOF() || this.char() !== 39)
        return null;
      switch (this.peek()) {
        case 39:
          return this.bump(), this.bump(), "'";
        case 123:
        case 60:
        case 62:
        case 125:
          break;
        case 35:
          if (e === "plural" || e === "selectordinal")
            break;
          return null;
        default:
          return null;
      }
      this.bump();
      var i = [this.char()];
      for (this.bump(); !this.isEOF(); ) {
        var n = this.char();
        if (n === 39)
          if (this.peek() === 39)
            i.push(39), this.bump();
          else {
            this.bump();
            break;
          }
        else
          i.push(n);
        this.bump();
      }
      return Gn.apply(void 0, i);
    }, t.prototype.tryParseUnquoted = function(e, i) {
      if (this.isEOF())
        return null;
      var n = this.char();
      return n === 60 || n === 123 || n === 35 && (i === "plural" || i === "selectordinal") || n === 125 && e > 0 ? null : (this.bump(), Gn(n));
    }, t.prototype.parseArgument = function(e, i) {
      var n = this.clonePosition();
      if (this.bump(), this.bumpSpace(), this.isEOF())
        return this.error(B.EXPECT_ARGUMENT_CLOSING_BRACE, N(n, this.clonePosition()));
      if (this.char() === 125)
        return this.bump(), this.error(B.EMPTY_ARGUMENT, N(n, this.clonePosition()));
      var r = this.parseIdentifierIfPossible().value;
      if (!r)
        return this.error(B.MALFORMED_ARGUMENT, N(n, this.clonePosition()));
      if (this.bumpSpace(), this.isEOF())
        return this.error(B.EXPECT_ARGUMENT_CLOSING_BRACE, N(n, this.clonePosition()));
      switch (this.char()) {
        case 125:
          return this.bump(), {
            val: {
              type: W.argument,
              // value does not include the opening and closing braces.
              value: r,
              location: N(n, this.clonePosition())
            },
            err: null
          };
        case 44:
          return this.bump(), this.bumpSpace(), this.isEOF() ? this.error(B.EXPECT_ARGUMENT_CLOSING_BRACE, N(n, this.clonePosition())) : this.parseArgumentOptions(e, i, r, n);
        default:
          return this.error(B.MALFORMED_ARGUMENT, N(n, this.clonePosition()));
      }
    }, t.prototype.parseIdentifierIfPossible = function() {
      var e = this.clonePosition(), i = this.offset(), n = zn(this.message, i), r = i + n.length;
      this.bumpTo(r);
      var a = this.clonePosition(), o = N(e, a);
      return { value: n, location: o };
    }, t.prototype.parseArgumentOptions = function(e, i, n, r) {
      var a, o = this.clonePosition(), s = this.parseIdentifierIfPossible().value, l = this.clonePosition();
      switch (s) {
        case "":
          return this.error(B.EXPECT_ARGUMENT_TYPE, N(o, l));
        case "number":
        case "date":
        case "time": {
          this.bumpSpace();
          var h = null;
          if (this.bumpIf(",")) {
            this.bumpSpace();
            var u = this.clonePosition(), f = this.parseSimpleArgStyleIfPossible();
            if (f.err)
              return f;
            var c = Cc(f.val);
            if (c.length === 0)
              return this.error(B.EXPECT_ARGUMENT_STYLE, N(this.clonePosition(), this.clonePosition()));
            var d = N(u, this.clonePosition());
            h = { style: c, styleLocation: d };
          }
          var m = this.tryParseArgumentClose(r);
          if (m.err)
            return m;
          var p = N(r, this.clonePosition());
          if (h && fa(h == null ? void 0 : h.style, "::", 0)) {
            var v = Sc(h.style.slice(2));
            if (s === "number") {
              var f = this.parseNumberSkeletonFromString(v, h.styleLocation);
              return f.err ? f : {
                val: { type: W.number, value: n, location: p, style: f.val },
                err: null
              };
            } else {
              if (v.length === 0)
                return this.error(B.EXPECT_DATE_TIME_SKELETON, p);
              var k = v;
              this.locale && (k = fc(v, this.locale));
              var c = {
                type: St.dateTime,
                pattern: k,
                location: h.styleLocation,
                parsedOptions: this.shouldParseSkeletons ? ac(k) : {}
              }, T = s === "date" ? W.date : W.time;
              return {
                val: { type: T, value: n, location: p, style: c },
                err: null
              };
            }
          }
          return {
            val: {
              type: s === "number" ? W.number : s === "date" ? W.date : W.time,
              value: n,
              location: p,
              style: (a = h == null ? void 0 : h.style) !== null && a !== void 0 ? a : null
            },
            err: null
          };
        }
        case "plural":
        case "selectordinal":
        case "select": {
          var S = this.clonePosition();
          if (this.bumpSpace(), !this.bumpIf(","))
            return this.error(B.EXPECT_SELECT_ARGUMENT_OPTIONS, N(S, x({}, S)));
          this.bumpSpace();
          var I = this.parseIdentifierIfPossible(), w = 0;
          if (s !== "select" && I.value === "offset") {
            if (!this.bumpIf(":"))
              return this.error(B.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, N(this.clonePosition(), this.clonePosition()));
            this.bumpSpace();
            var f = this.tryParseDecimalInteger(B.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, B.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);
            if (f.err)
              return f;
            this.bumpSpace(), I = this.parseIdentifierIfPossible(), w = f.val;
          }
          var _ = this.tryParsePluralOrSelectOptions(e, s, i, I);
          if (_.err)
            return _;
          var m = this.tryParseArgumentClose(r);
          if (m.err)
            return m;
          var E = N(r, this.clonePosition());
          return s === "select" ? {
            val: {
              type: W.select,
              value: n,
              options: da(_.val),
              location: E
            },
            err: null
          } : {
            val: {
              type: W.plural,
              value: n,
              options: da(_.val),
              offset: w,
              pluralType: s === "plural" ? "cardinal" : "ordinal",
              location: E
            },
            err: null
          };
        }
        default:
          return this.error(B.INVALID_ARGUMENT_TYPE, N(o, l));
      }
    }, t.prototype.tryParseArgumentClose = function(e) {
      return this.isEOF() || this.char() !== 125 ? this.error(B.EXPECT_ARGUMENT_CLOSING_BRACE, N(e, this.clonePosition())) : (this.bump(), { val: !0, err: null });
    }, t.prototype.parseSimpleArgStyleIfPossible = function() {
      for (var e = 0, i = this.clonePosition(); !this.isEOF(); ) {
        var n = this.char();
        switch (n) {
          case 39: {
            this.bump();
            var r = this.clonePosition();
            if (!this.bumpUntil("'"))
              return this.error(B.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE, N(r, this.clonePosition()));
            this.bump();
            break;
          }
          case 123: {
            e += 1, this.bump();
            break;
          }
          case 125: {
            if (e > 0)
              e -= 1;
            else
              return {
                val: this.message.slice(i.offset, this.offset()),
                err: null
              };
            break;
          }
          default:
            this.bump();
            break;
        }
      }
      return {
        val: this.message.slice(i.offset, this.offset()),
        err: null
      };
    }, t.prototype.parseNumberSkeletonFromString = function(e, i) {
      var n = [];
      try {
        n = sc(e);
      } catch {
        return this.error(B.INVALID_NUMBER_SKELETON, i);
      }
      return {
        val: {
          type: St.number,
          tokens: n,
          location: i,
          parsedOptions: this.shouldParseSkeletons ? cc(n) : {}
        },
        err: null
      };
    }, t.prototype.tryParsePluralOrSelectOptions = function(e, i, n, r) {
      for (var a, o = !1, s = [], l = /* @__PURE__ */ new Set(), h = r.value, u = r.location; ; ) {
        if (h.length === 0) {
          var f = this.clonePosition();
          if (i !== "select" && this.bumpIf("=")) {
            var c = this.tryParseDecimalInteger(B.EXPECT_PLURAL_ARGUMENT_SELECTOR, B.INVALID_PLURAL_ARGUMENT_SELECTOR);
            if (c.err)
              return c;
            u = N(f, this.clonePosition()), h = this.message.slice(f.offset, this.offset());
          } else
            break;
        }
        if (l.has(h))
          return this.error(i === "select" ? B.DUPLICATE_SELECT_ARGUMENT_SELECTOR : B.DUPLICATE_PLURAL_ARGUMENT_SELECTOR, u);
        h === "other" && (o = !0), this.bumpSpace();
        var d = this.clonePosition();
        if (!this.bumpIf("{"))
          return this.error(i === "select" ? B.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT : B.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT, N(this.clonePosition(), this.clonePosition()));
        var m = this.parseMessage(e + 1, i, n);
        if (m.err)
          return m;
        var p = this.tryParseArgumentClose(d);
        if (p.err)
          return p;
        s.push([
          h,
          {
            value: m.val,
            location: N(d, this.clonePosition())
          }
        ]), l.add(h), this.bumpSpace(), a = this.parseIdentifierIfPossible(), h = a.value, u = a.location;
      }
      return s.length === 0 ? this.error(i === "select" ? B.EXPECT_SELECT_ARGUMENT_SELECTOR : B.EXPECT_PLURAL_ARGUMENT_SELECTOR, N(this.clonePosition(), this.clonePosition())) : this.requiresOtherClause && !o ? this.error(B.MISSING_OTHER_CLAUSE, N(this.clonePosition(), this.clonePosition())) : { val: s, err: null };
    }, t.prototype.tryParseDecimalInteger = function(e, i) {
      var n = 1, r = this.clonePosition();
      this.bumpIf("+") || this.bumpIf("-") && (n = -1);
      for (var a = !1, o = 0; !this.isEOF(); ) {
        var s = this.char();
        if (s >= 48 && s <= 57)
          a = !0, o = o * 10 + (s - 48), this.bump();
        else
          break;
      }
      var l = N(r, this.clonePosition());
      return a ? (o *= n, kc(o) ? { val: o, err: null } : this.error(i, l)) : this.error(e, l);
    }, t.prototype.offset = function() {
      return this.position.offset;
    }, t.prototype.isEOF = function() {
      return this.offset() === this.message.length;
    }, t.prototype.clonePosition = function() {
      return {
        offset: this.position.offset,
        line: this.position.line,
        column: this.position.column
      };
    }, t.prototype.char = function() {
      var e = this.position.offset;
      if (e >= this.message.length)
        throw Error("out of bound");
      var i = Ao(this.message, e);
      if (i === void 0)
        throw Error("Offset ".concat(e, " is at invalid UTF-16 code unit boundary"));
      return i;
    }, t.prototype.error = function(e, i) {
      return {
        val: null,
        err: {
          kind: e,
          message: this.message,
          location: i
        }
      };
    }, t.prototype.bump = function() {
      if (!this.isEOF()) {
        var e = this.char();
        e === 10 ? (this.position.line += 1, this.position.column = 1, this.position.offset += 1) : (this.position.column += 1, this.position.offset += e < 65536 ? 1 : 2);
      }
    }, t.prototype.bumpIf = function(e) {
      if (fa(this.message, e, this.offset())) {
        for (var i = 0; i < e.length; i++)
          this.bump();
        return !0;
      }
      return !1;
    }, t.prototype.bumpUntil = function(e) {
      var i = this.offset(), n = this.message.indexOf(e, i);
      return n >= 0 ? (this.bumpTo(n), !0) : (this.bumpTo(this.message.length), !1);
    }, t.prototype.bumpTo = function(e) {
      if (this.offset() > e)
        throw Error("targetOffset ".concat(e, " must be greater than or equal to the current offset ").concat(this.offset()));
      for (e = Math.min(e, this.message.length); ; ) {
        var i = this.offset();
        if (i === e)
          break;
        if (i > e)
          throw Error("targetOffset ".concat(e, " is at invalid UTF-16 code unit boundary"));
        if (this.bump(), this.isEOF())
          break;
      }
    }, t.prototype.bumpSpace = function() {
      for (; !this.isEOF() && Do(this.char()); )
        this.bump();
    }, t.prototype.peek = function() {
      if (this.isEOF())
        return null;
      var e = this.char(), i = this.offset(), n = this.message.charCodeAt(i + (e >= 65536 ? 2 : 1));
      return n ?? null;
    }, t;
  }()
);
function Fn(t) {
  return t >= 97 && t <= 122 || t >= 65 && t <= 90;
}
function Ac(t) {
  return Fn(t) || t === 47;
}
function Oc(t) {
  return t === 45 || t === 46 || t >= 48 && t <= 57 || t === 95 || t >= 97 && t <= 122 || t >= 65 && t <= 90 || t == 183 || t >= 192 && t <= 214 || t >= 216 && t <= 246 || t >= 248 && t <= 893 || t >= 895 && t <= 8191 || t >= 8204 && t <= 8205 || t >= 8255 && t <= 8256 || t >= 8304 && t <= 8591 || t >= 11264 && t <= 12271 || t >= 12289 && t <= 55295 || t >= 63744 && t <= 64975 || t >= 65008 && t <= 65533 || t >= 65536 && t <= 983039;
}
function Do(t) {
  return t >= 9 && t <= 13 || t === 32 || t === 133 || t >= 8206 && t <= 8207 || t === 8232 || t === 8233;
}
function Dc(t) {
  return t >= 33 && t <= 35 || t === 36 || t >= 37 && t <= 39 || t === 40 || t === 41 || t === 42 || t === 43 || t === 44 || t === 45 || t >= 46 && t <= 47 || t >= 58 && t <= 59 || t >= 60 && t <= 62 || t >= 63 && t <= 64 || t === 91 || t === 92 || t === 93 || t === 94 || t === 96 || t === 123 || t === 124 || t === 125 || t === 126 || t === 161 || t >= 162 && t <= 165 || t === 166 || t === 167 || t === 169 || t === 171 || t === 172 || t === 174 || t === 176 || t === 177 || t === 182 || t === 187 || t === 191 || t === 215 || t === 247 || t >= 8208 && t <= 8213 || t >= 8214 && t <= 8215 || t === 8216 || t === 8217 || t === 8218 || t >= 8219 && t <= 8220 || t === 8221 || t === 8222 || t === 8223 || t >= 8224 && t <= 8231 || t >= 8240 && t <= 8248 || t === 8249 || t === 8250 || t >= 8251 && t <= 8254 || t >= 8257 && t <= 8259 || t === 8260 || t === 8261 || t === 8262 || t >= 8263 && t <= 8273 || t === 8274 || t === 8275 || t >= 8277 && t <= 8286 || t >= 8592 && t <= 8596 || t >= 8597 && t <= 8601 || t >= 8602 && t <= 8603 || t >= 8604 && t <= 8607 || t === 8608 || t >= 8609 && t <= 8610 || t === 8611 || t >= 8612 && t <= 8613 || t === 8614 || t >= 8615 && t <= 8621 || t === 8622 || t >= 8623 && t <= 8653 || t >= 8654 && t <= 8655 || t >= 8656 && t <= 8657 || t === 8658 || t === 8659 || t === 8660 || t >= 8661 && t <= 8691 || t >= 8692 && t <= 8959 || t >= 8960 && t <= 8967 || t === 8968 || t === 8969 || t === 8970 || t === 8971 || t >= 8972 && t <= 8991 || t >= 8992 && t <= 8993 || t >= 8994 && t <= 9e3 || t === 9001 || t === 9002 || t >= 9003 && t <= 9083 || t === 9084 || t >= 9085 && t <= 9114 || t >= 9115 && t <= 9139 || t >= 9140 && t <= 9179 || t >= 9180 && t <= 9185 || t >= 9186 && t <= 9254 || t >= 9255 && t <= 9279 || t >= 9280 && t <= 9290 || t >= 9291 && t <= 9311 || t >= 9472 && t <= 9654 || t === 9655 || t >= 9656 && t <= 9664 || t === 9665 || t >= 9666 && t <= 9719 || t >= 9720 && t <= 9727 || t >= 9728 && t <= 9838 || t === 9839 || t >= 9840 && t <= 10087 || t === 10088 || t === 10089 || t === 10090 || t === 10091 || t === 10092 || t === 10093 || t === 10094 || t === 10095 || t === 10096 || t === 10097 || t === 10098 || t === 10099 || t === 10100 || t === 10101 || t >= 10132 && t <= 10175 || t >= 10176 && t <= 10180 || t === 10181 || t === 10182 || t >= 10183 && t <= 10213 || t === 10214 || t === 10215 || t === 10216 || t === 10217 || t === 10218 || t === 10219 || t === 10220 || t === 10221 || t === 10222 || t === 10223 || t >= 10224 && t <= 10239 || t >= 10240 && t <= 10495 || t >= 10496 && t <= 10626 || t === 10627 || t === 10628 || t === 10629 || t === 10630 || t === 10631 || t === 10632 || t === 10633 || t === 10634 || t === 10635 || t === 10636 || t === 10637 || t === 10638 || t === 10639 || t === 10640 || t === 10641 || t === 10642 || t === 10643 || t === 10644 || t === 10645 || t === 10646 || t === 10647 || t === 10648 || t >= 10649 && t <= 10711 || t === 10712 || t === 10713 || t === 10714 || t === 10715 || t >= 10716 && t <= 10747 || t === 10748 || t === 10749 || t >= 10750 && t <= 11007 || t >= 11008 && t <= 11055 || t >= 11056 && t <= 11076 || t >= 11077 && t <= 11078 || t >= 11079 && t <= 11084 || t >= 11085 && t <= 11123 || t >= 11124 && t <= 11125 || t >= 11126 && t <= 11157 || t === 11158 || t >= 11159 && t <= 11263 || t >= 11776 && t <= 11777 || t === 11778 || t === 11779 || t === 11780 || t === 11781 || t >= 11782 && t <= 11784 || t === 11785 || t === 11786 || t === 11787 || t === 11788 || t === 11789 || t >= 11790 && t <= 11798 || t === 11799 || t >= 11800 && t <= 11801 || t === 11802 || t === 11803 || t === 11804 || t === 11805 || t >= 11806 && t <= 11807 || t === 11808 || t === 11809 || t === 11810 || t === 11811 || t === 11812 || t === 11813 || t === 11814 || t === 11815 || t === 11816 || t === 11817 || t >= 11818 && t <= 11822 || t === 11823 || t >= 11824 && t <= 11833 || t >= 11834 && t <= 11835 || t >= 11836 && t <= 11839 || t === 11840 || t === 11841 || t === 11842 || t >= 11843 && t <= 11855 || t >= 11856 && t <= 11857 || t === 11858 || t >= 11859 && t <= 11903 || t >= 12289 && t <= 12291 || t === 12296 || t === 12297 || t === 12298 || t === 12299 || t === 12300 || t === 12301 || t === 12302 || t === 12303 || t === 12304 || t === 12305 || t >= 12306 && t <= 12307 || t === 12308 || t === 12309 || t === 12310 || t === 12311 || t === 12312 || t === 12313 || t === 12314 || t === 12315 || t === 12316 || t === 12317 || t >= 12318 && t <= 12319 || t === 12320 || t === 12336 || t === 64830 || t === 64831 || t >= 65093 && t <= 65094;
}
function jn(t) {
  t.forEach(function(e) {
    if (delete e.location, wo(e) || yo(e))
      for (var i in e.options)
        delete e.options[i].location, jn(e.options[i].value);
    else
      go(e) && ko(e.style) || (bo(e) || vo(e)) && Ln(e.style) ? delete e.style.location : Eo(e) && jn(e.children);
  });
}
function Bc(t, e) {
  e === void 0 && (e = {}), e = x({ shouldParseSkeletons: !0, requiresOtherClause: !0 }, e);
  var i = new Mc(t, e).parse();
  if (i.err) {
    var n = SyntaxError(B[i.err.kind]);
    throw n.location = i.err.location, n.originalMessage = i.err.message, n;
  }
  return e != null && e.captureLocation || jn(i.val), i.val;
}
function wn(t, e) {
  var i = e && e.cache ? e.cache : Pc, n = e && e.serializer ? e.serializer : xc, r = e && e.strategy ? e.strategy : Ic;
  return r(t, {
    cache: i,
    serializer: n
  });
}
function Hc(t) {
  return t == null || typeof t == "number" || typeof t == "boolean";
}
function Bo(t, e, i, n) {
  var r = Hc(n) ? n : i(n), a = e.get(r);
  return typeof a > "u" && (a = t.call(this, n), e.set(r, a)), a;
}
function Ho(t, e, i) {
  var n = Array.prototype.slice.call(arguments, 3), r = i(n), a = e.get(r);
  return typeof a > "u" && (a = t.apply(this, n), e.set(r, a)), a;
}
function or(t, e, i, n, r) {
  return i.bind(e, t, n, r);
}
function Ic(t, e) {
  var i = t.length === 1 ? Bo : Ho;
  return or(t, this, i, e.cache.create(), e.serializer);
}
function Nc(t, e) {
  return or(t, this, Ho, e.cache.create(), e.serializer);
}
function Rc(t, e) {
  return or(t, this, Bo, e.cache.create(), e.serializer);
}
var xc = function() {
  return JSON.stringify(arguments);
};
function sr() {
  this.cache = /* @__PURE__ */ Object.create(null);
}
sr.prototype.get = function(t) {
  return this.cache[t];
};
sr.prototype.set = function(t, e) {
  this.cache[t] = e;
};
var Pc = {
  create: function() {
    return new sr();
  }
}, yn = {
  variadic: Nc,
  monadic: Rc
}, Ct;
(function(t) {
  t.MISSING_VALUE = "MISSING_VALUE", t.INVALID_VALUE = "INVALID_VALUE", t.MISSING_INTL_API = "MISSING_INTL_API";
})(Ct || (Ct = {}));
var Li = (
  /** @class */
  function(t) {
    Pi(e, t);
    function e(i, n, r) {
      var a = t.call(this, i) || this;
      return a.code = n, a.originalMessage = r, a;
    }
    return e.prototype.toString = function() {
      return "[formatjs Error: ".concat(this.code, "] ").concat(this.message);
    }, e;
  }(Error)
), _a = (
  /** @class */
  function(t) {
    Pi(e, t);
    function e(i, n, r, a) {
      return t.call(this, 'Invalid values for "'.concat(i, '": "').concat(n, '". Options are "').concat(Object.keys(r).join('", "'), '"'), Ct.INVALID_VALUE, a) || this;
    }
    return e;
  }(Li)
), Lc = (
  /** @class */
  function(t) {
    Pi(e, t);
    function e(i, n, r) {
      return t.call(this, 'Value for "'.concat(i, '" must be of type ').concat(n), Ct.INVALID_VALUE, r) || this;
    }
    return e;
  }(Li)
), Uc = (
  /** @class */
  function(t) {
    Pi(e, t);
    function e(i, n) {
      return t.call(this, 'The intl string context variable "'.concat(i, '" was not provided to the string "').concat(n, '"'), Ct.MISSING_VALUE, n) || this;
    }
    return e;
  }(Li)
), he;
(function(t) {
  t[t.literal = 0] = "literal", t[t.object = 1] = "object";
})(he || (he = {}));
function Gc(t) {
  return t.length < 2 ? t : t.reduce(function(e, i) {
    var n = e[e.length - 1];
    return !n || n.type !== he.literal || i.type !== he.literal ? e.push(i) : n.value += i.value, e;
  }, []);
}
function zc(t) {
  return typeof t == "function";
}
function yi(t, e, i, n, r, a, o) {
  if (t.length === 1 && la(t[0]))
    return [
      {
        type: he.literal,
        value: t[0].value
      }
    ];
  for (var s = [], l = 0, h = t; l < h.length; l++) {
    var u = h[l];
    if (la(u)) {
      s.push({
        type: he.literal,
        value: u.value
      });
      continue;
    }
    if (nc(u)) {
      typeof a == "number" && s.push({
        type: he.literal,
        value: i.getNumberFormat(e).format(a)
      });
      continue;
    }
    var f = u.value;
    if (!(r && f in r))
      throw new Uc(f, o);
    var c = r[f];
    if (ic(u)) {
      (!c || typeof c == "string" || typeof c == "number") && (c = typeof c == "string" || typeof c == "number" ? String(c) : ""), s.push({
        type: typeof c == "string" ? he.literal : he.object,
        value: c
      });
      continue;
    }
    if (bo(u)) {
      var d = typeof u.style == "string" ? n.date[u.style] : Ln(u.style) ? u.style.parsedOptions : void 0;
      s.push({
        type: he.literal,
        value: i.getDateTimeFormat(e, d).format(c)
      });
      continue;
    }
    if (vo(u)) {
      var d = typeof u.style == "string" ? n.time[u.style] : Ln(u.style) ? u.style.parsedOptions : n.time.medium;
      s.push({
        type: he.literal,
        value: i.getDateTimeFormat(e, d).format(c)
      });
      continue;
    }
    if (go(u)) {
      var d = typeof u.style == "string" ? n.number[u.style] : ko(u.style) ? u.style.parsedOptions : void 0;
      d && d.scale && (c = c * (d.scale || 1)), s.push({
        type: he.literal,
        value: i.getNumberFormat(e, d).format(c)
      });
      continue;
    }
    if (Eo(u)) {
      var m = u.children, p = u.value, v = r[p];
      if (!zc(v))
        throw new Lc(p, "function", o);
      var k = yi(m, e, i, n, r, a), T = v(k.map(function(w) {
        return w.value;
      }));
      Array.isArray(T) || (T = [T]), s.push.apply(s, T.map(function(w) {
        return {
          type: typeof w == "string" ? he.literal : he.object,
          value: w
        };
      }));
    }
    if (wo(u)) {
      var S = u.options[c] || u.options.other;
      if (!S)
        throw new _a(u.value, c, Object.keys(u.options), o);
      s.push.apply(s, yi(S.value, e, i, n, r));
      continue;
    }
    if (yo(u)) {
      var S = u.options["=".concat(c)];
      if (!S) {
        if (!Intl.PluralRules)
          throw new Li(`Intl.PluralRules is not available in this environment.
Try polyfilling it using "@formatjs/intl-pluralrules"
`, Ct.MISSING_INTL_API, o);
        var I = i.getPluralRules(e, { type: u.pluralType }).select(c - (u.offset || 0));
        S = u.options[I] || u.options.other;
      }
      if (!S)
        throw new _a(u.value, c, Object.keys(u.options), o);
      s.push.apply(s, yi(S.value, e, i, n, r, c - (u.offset || 0)));
      continue;
    }
  }
  return Gc(s);
}
function Fc(t, e) {
  return e ? x(x(x({}, t || {}), e || {}), Object.keys(t).reduce(function(i, n) {
    return i[n] = x(x({}, t[n]), e[n] || {}), i;
  }, {})) : t;
}
function jc(t, e) {
  return e ? Object.keys(t).reduce(function(i, n) {
    return i[n] = Fc(t[n], e[n]), i;
  }, x({}, t)) : t;
}
function En(t) {
  return {
    create: function() {
      return {
        get: function(e) {
          return t[e];
        },
        set: function(e, i) {
          t[e] = i;
        }
      };
    }
  };
}
function Xc(t) {
  return t === void 0 && (t = {
    number: {},
    dateTime: {},
    pluralRules: {}
  }), {
    getNumberFormat: wn(function() {
      for (var e, i = [], n = 0; n < arguments.length; n++)
        i[n] = arguments[n];
      return new ((e = Intl.NumberFormat).bind.apply(e, bn([void 0], i, !1)))();
    }, {
      cache: En(t.number),
      strategy: yn.variadic
    }),
    getDateTimeFormat: wn(function() {
      for (var e, i = [], n = 0; n < arguments.length; n++)
        i[n] = arguments[n];
      return new ((e = Intl.DateTimeFormat).bind.apply(e, bn([void 0], i, !1)))();
    }, {
      cache: En(t.dateTime),
      strategy: yn.variadic
    }),
    getPluralRules: wn(function() {
      for (var e, i = [], n = 0; n < arguments.length; n++)
        i[n] = arguments[n];
      return new ((e = Intl.PluralRules).bind.apply(e, bn([void 0], i, !1)))();
    }, {
      cache: En(t.pluralRules),
      strategy: yn.variadic
    })
  };
}
var Wc = (
  /** @class */
  function() {
    function t(e, i, n, r) {
      var a = this;
      if (i === void 0 && (i = t.defaultLocale), this.formatterCache = {
        number: {},
        dateTime: {},
        pluralRules: {}
      }, this.format = function(o) {
        var s = a.formatToParts(o);
        if (s.length === 1)
          return s[0].value;
        var l = s.reduce(function(h, u) {
          return !h.length || u.type !== he.literal || typeof h[h.length - 1] != "string" ? h.push(u.value) : h[h.length - 1] += u.value, h;
        }, []);
        return l.length <= 1 ? l[0] || "" : l;
      }, this.formatToParts = function(o) {
        return yi(a.ast, a.locales, a.formatters, a.formats, o, void 0, a.message);
      }, this.resolvedOptions = function() {
        return {
          locale: a.resolvedLocale.toString()
        };
      }, this.getAst = function() {
        return a.ast;
      }, this.locales = i, this.resolvedLocale = t.resolveLocale(i), typeof e == "string") {
        if (this.message = e, !t.__parse)
          throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");
        this.ast = t.__parse(e, {
          ignoreTag: r == null ? void 0 : r.ignoreTag,
          locale: this.resolvedLocale
        });
      } else
        this.ast = e;
      if (!Array.isArray(this.ast))
        throw new TypeError("A message must be provided as a String or AST.");
      this.formats = jc(t.formats, n), this.formatters = r && r.formatters || Xc(this.formatterCache);
    }
    return Object.defineProperty(t, "defaultLocale", {
      get: function() {
        return t.memoizedDefaultLocale || (t.memoizedDefaultLocale = new Intl.NumberFormat().resolvedOptions().locale), t.memoizedDefaultLocale;
      },
      enumerable: !1,
      configurable: !0
    }), t.memoizedDefaultLocale = null, t.resolveLocale = function(e) {
      var i = Intl.NumberFormat.supportedLocalesOf(e);
      return i.length > 0 ? new Intl.Locale(i[0]) : new Intl.Locale(typeof e == "string" ? e : e[0]);
    }, t.__parse = Bc, t.formats = {
      number: {
        integer: {
          maximumFractionDigits: 0
        },
        currency: {
          style: "currency"
        },
        percent: {
          style: "percent"
        }
      },
      date: {
        short: {
          month: "numeric",
          day: "numeric",
          year: "2-digit"
        },
        medium: {
          month: "short",
          day: "numeric",
          year: "numeric"
        },
        long: {
          month: "long",
          day: "numeric",
          year: "numeric"
        },
        full: {
          weekday: "long",
          month: "long",
          day: "numeric",
          year: "numeric"
        }
      },
      time: {
        short: {
          hour: "numeric",
          minute: "numeric"
        },
        medium: {
          hour: "numeric",
          minute: "numeric",
          second: "numeric"
        },
        long: {
          hour: "numeric",
          minute: "numeric",
          second: "numeric",
          timeZoneName: "short"
        },
        full: {
          hour: "numeric",
          minute: "numeric",
          second: "numeric",
          timeZoneName: "short"
        }
      }
    }, t;
  }()
);
function Vc(t, e) {
  if (e == null)
    return;
  if (e in t)
    return t[e];
  const i = e.split(".");
  let n = t;
  for (let r = 0; r < i.length; r++)
    if (typeof n == "object") {
      if (r > 0) {
        const a = i.slice(r, i.length).join(".");
        if (a in n) {
          n = n[a];
          break;
        }
      }
      n = n[i[r]];
    } else
      n = void 0;
  return n;
}
const We = {}, qc = (t, e, i) => i && (e in We || (We[e] = {}), t in We[e] || (We[e][t] = i), i), Io = (t, e) => {
  if (e == null)
    return;
  if (e in We && t in We[e])
    return We[e][t];
  const i = Ui(e);
  for (let n = 0; n < i.length; n++) {
    const r = i[n], a = Zc(r, t);
    if (a)
      return qc(t, e, a);
  }
};
let lr;
const Kt = Ri({});
function Yc(t) {
  return lr[t] || null;
}
function No(t) {
  return t in lr;
}
function Zc(t, e) {
  if (!No(t))
    return null;
  const i = Yc(t);
  return Vc(i, e);
}
function Qc(t) {
  if (t == null)
    return;
  const e = Ui(t);
  for (let i = 0; i < e.length; i++) {
    const n = e[i];
    if (No(n))
      return n;
  }
}
function Jc(t, ...e) {
  delete We[t], Kt.update((i) => (i[t] = tc.all([i[t] || {}, ...e]), i));
}
Dt(
  [Kt],
  ([t]) => Object.keys(t)
);
Kt.subscribe((t) => lr = t);
const Ei = {};
function Kc(t, e) {
  Ei[t].delete(e), Ei[t].size === 0 && delete Ei[t];
}
function Ro(t) {
  return Ei[t];
}
function $c(t) {
  return Ui(t).map((e) => {
    const i = Ro(e);
    return [e, i ? [...i] : []];
  }).filter(([, e]) => e.length > 0);
}
function Xn(t) {
  return t == null ? !1 : Ui(t).some(
    (e) => {
      var i;
      return (i = Ro(e)) == null ? void 0 : i.size;
    }
  );
}
function ef(t, e) {
  return Promise.all(
    e.map((n) => (Kc(t, n), n().then((r) => r.default || r)))
  ).then((n) => Jc(t, ...n));
}
const Ft = {};
function xo(t) {
  if (!Xn(t))
    return t in Ft ? Ft[t] : Promise.resolve();
  const e = $c(t);
  return Ft[t] = Promise.all(
    e.map(
      ([i, n]) => ef(i, n)
    )
  ).then(() => {
    if (Xn(t))
      return xo(t);
    delete Ft[t];
  }), Ft[t];
}
const tf = {
  number: {
    scientific: { notation: "scientific" },
    engineering: { notation: "engineering" },
    compactLong: { notation: "compact", compactDisplay: "long" },
    compactShort: { notation: "compact", compactDisplay: "short" }
  },
  date: {
    short: { month: "numeric", day: "numeric", year: "2-digit" },
    medium: { month: "short", day: "numeric", year: "numeric" },
    long: { month: "long", day: "numeric", year: "numeric" },
    full: { weekday: "long", month: "long", day: "numeric", year: "numeric" }
  },
  time: {
    short: { hour: "numeric", minute: "numeric" },
    medium: { hour: "numeric", minute: "numeric", second: "numeric" },
    long: {
      hour: "numeric",
      minute: "numeric",
      second: "numeric",
      timeZoneName: "short"
    },
    full: {
      hour: "numeric",
      minute: "numeric",
      second: "numeric",
      timeZoneName: "short"
    }
  }
}, nf = {
  fallbackLocale: null,
  loadingDelay: 200,
  formats: tf,
  warnOnMissingMessages: !0,
  handleMissingMessage: void 0,
  ignoreTag: !0
}, rf = nf;
function Mt() {
  return rf;
}
const kn = Ri(!1);
var af = Object.defineProperty, of = Object.defineProperties, sf = Object.getOwnPropertyDescriptors, pa = Object.getOwnPropertySymbols, lf = Object.prototype.hasOwnProperty, hf = Object.prototype.propertyIsEnumerable, ga = (t, e, i) => e in t ? af(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i, uf = (t, e) => {
  for (var i in e || (e = {}))
    lf.call(e, i) && ga(t, i, e[i]);
  if (pa)
    for (var i of pa(e))
      hf.call(e, i) && ga(t, i, e[i]);
  return t;
}, cf = (t, e) => of(t, sf(e));
let Wn;
const Di = Ri(null);
function ba(t) {
  return t.split("-").map((e, i, n) => n.slice(0, i + 1).join("-")).reverse();
}
function Ui(t, e = Mt().fallbackLocale) {
  const i = ba(t);
  return e ? [.../* @__PURE__ */ new Set([...i, ...ba(e)])] : i;
}
function at() {
  return Wn ?? void 0;
}
Di.subscribe((t) => {
  Wn = t ?? void 0, typeof window < "u" && t != null && document.documentElement.setAttribute("lang", t);
});
const ff = (t) => {
  if (t && Qc(t) && Xn(t)) {
    const { loadingDelay: e } = Mt();
    let i;
    return typeof window < "u" && at() != null && e ? i = window.setTimeout(
      () => kn.set(!0),
      e
    ) : kn.set(!0), xo(t).then(() => {
      Di.set(t);
    }).finally(() => {
      clearTimeout(i), kn.set(!1);
    });
  }
  return Di.set(t);
}, $t = cf(uf({}, Di), {
  set: ff
}), Gi = (t) => {
  const e = /* @__PURE__ */ Object.create(null);
  return (n) => {
    const r = JSON.stringify(n);
    return r in e ? e[r] : e[r] = t(n);
  };
};
var df = Object.defineProperty, Bi = Object.getOwnPropertySymbols, Po = Object.prototype.hasOwnProperty, Lo = Object.prototype.propertyIsEnumerable, va = (t, e, i) => e in t ? df(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i, hr = (t, e) => {
  for (var i in e || (e = {}))
    Po.call(e, i) && va(t, i, e[i]);
  if (Bi)
    for (var i of Bi(e))
      Lo.call(e, i) && va(t, i, e[i]);
  return t;
}, Bt = (t, e) => {
  var i = {};
  for (var n in t)
    Po.call(t, n) && e.indexOf(n) < 0 && (i[n] = t[n]);
  if (t != null && Bi)
    for (var n of Bi(t))
      e.indexOf(n) < 0 && Lo.call(t, n) && (i[n] = t[n]);
  return i;
};
const Qt = (t, e) => {
  const { formats: i } = Mt();
  if (t in i && e in i[t])
    return i[t][e];
  throw new Error(`[svelte-i18n] Unknown "${e}" ${t} format.`);
}, mf = Gi(
  (t) => {
    var e = t, { locale: i, format: n } = e, r = Bt(e, ["locale", "format"]);
    if (i == null)
      throw new Error('[svelte-i18n] A "locale" must be set to format numbers');
    return n && (r = Qt("number", n)), new Intl.NumberFormat(i, r);
  }
), _f = Gi(
  (t) => {
    var e = t, { locale: i, format: n } = e, r = Bt(e, ["locale", "format"]);
    if (i == null)
      throw new Error('[svelte-i18n] A "locale" must be set to format dates');
    return n ? r = Qt("date", n) : Object.keys(r).length === 0 && (r = Qt("date", "short")), new Intl.DateTimeFormat(i, r);
  }
), pf = Gi(
  (t) => {
    var e = t, { locale: i, format: n } = e, r = Bt(e, ["locale", "format"]);
    if (i == null)
      throw new Error(
        '[svelte-i18n] A "locale" must be set to format time values'
      );
    return n ? r = Qt("time", n) : Object.keys(r).length === 0 && (r = Qt("time", "short")), new Intl.DateTimeFormat(i, r);
  }
), gf = (t = {}) => {
  var e = t, {
    locale: i = at()
  } = e, n = Bt(e, [
    "locale"
  ]);
  return mf(hr({ locale: i }, n));
}, bf = (t = {}) => {
  var e = t, {
    locale: i = at()
  } = e, n = Bt(e, [
    "locale"
  ]);
  return _f(hr({ locale: i }, n));
}, vf = (t = {}) => {
  var e = t, {
    locale: i = at()
  } = e, n = Bt(e, [
    "locale"
  ]);
  return pf(hr({ locale: i }, n));
}, wf = Gi(
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
  (t, e = at()) => new Wc(t, e, Mt().formats, {
    ignoreTag: Mt().ignoreTag
  })
), yf = (t, e = {}) => {
  var i, n, r, a;
  let o = e;
  typeof t == "object" && (o = t, t = o.id);
  const {
    values: s,
    locale: l = at(),
    default: h
  } = o;
  if (l == null)
    throw new Error(
      "[svelte-i18n] Cannot format a message without first setting the initial locale."
    );
  let u = Io(t, l);
  if (!u)
    u = (a = (r = (n = (i = Mt()).handleMissingMessage) == null ? void 0 : n.call(i, { locale: l, id: t, defaultValue: h })) != null ? r : h) != null ? a : t;
  else if (typeof u != "string")
    return console.warn(
      `[svelte-i18n] Message with id "${t}" must be of type "string", found: "${typeof u}". Gettin its value through the "$format" method is deprecated; use the "json" method instead.`
    ), u;
  if (!s)
    return u;
  let f = u;
  try {
    f = wf(u, l).format(s);
  } catch (c) {
    c instanceof Error && console.warn(
      `[svelte-i18n] Message "${t}" has syntax error:`,
      c.message
    );
  }
  return f;
}, Ef = (t, e) => vf(e).format(t), kf = (t, e) => bf(e).format(t), Tf = (t, e) => gf(e).format(t), Sf = (t, e = at()) => Io(t, e), Cf = Dt([$t, Kt], () => yf);
Dt([$t], () => Ef);
Dt([$t], () => kf);
Dt([$t], () => Tf);
Dt([$t, Kt], () => Sf);
const {
  SvelteComponent: Mf,
  append: wa,
  attr: At,
  binding_callbacks: Af,
  check_outros: ur,
  component_subscribe: Of,
  create_component: cr,
  destroy_component: fr,
  detach: Ht,
  element: Ot,
  empty: Df,
  group_outros: dr,
  init: Bf,
  insert: It,
  is_function: Hf,
  listen: If,
  mount_component: mr,
  noop: Nf,
  safe_not_equal: Rf,
  space: xf,
  toggle_class: ya,
  transition_in: Ie,
  transition_out: Pe
} = window.__gradio__svelte__internal, { createEventDispatcher: Pf, onMount: Lf } = window.__gradio__svelte__internal;
function Ea(t) {
  let e, i, n, r, a, o;
  const s = [Gf, Uf], l = [];
  function h(u, f) {
    return (
      /*mode*/
      u[1] === "video" ? 0 : 1
    );
  }
  return i = h(t), n = l[i] = s[i](t), {
    c() {
      e = Ot("button"), n.c(), At(e, "class", "svelte-ji57xm");
    },
    m(u, f) {
      It(u, e, f), l[i].m(e, null), r = !0, a || (o = If(e, "click", function() {
        Hf(
          /*mode*/
          t[1] === "image" ? (
            /*take_picture*/
            t[5]
          ) : (
            /*take_recording*/
            t[6]
          )
        ) && /*mode*/
        (t[1] === "image" ? (
          /*take_picture*/
          t[5]
        ) : (
          /*take_recording*/
          t[6]
        )).apply(this, arguments);
      }), a = !0);
    },
    p(u, f) {
      t = u;
      let c = i;
      i = h(t), i === c ? l[i].p(t, f) : (dr(), Pe(l[c], 1, 1, () => {
        l[c] = null;
      }), ur(), n = l[i], n ? n.p(t, f) : (n = l[i] = s[i](t), n.c()), Ie(n, 1), n.m(e, null));
    },
    i(u) {
      r || (Ie(n), r = !0);
    },
    o(u) {
      Pe(n), r = !1;
    },
    d(u) {
      u && Ht(e), l[i].d(), a = !1, o();
    }
  };
}
function Uf(t) {
  let e, i, n;
  return i = new Rs({}), {
    c() {
      e = Ot("div"), cr(i.$$.fragment), At(e, "class", "icon svelte-ji57xm");
    },
    m(r, a) {
      It(r, e, a), mr(i, e, null), n = !0;
    },
    p: Nf,
    i(r) {
      n || (Ie(i.$$.fragment, r), n = !0);
    },
    o(r) {
      Pe(i.$$.fragment, r), n = !1;
    },
    d(r) {
      r && Ht(e), fr(i);
    }
  };
}
function Gf(t) {
  let e, i, n, r;
  const a = [Ff, zf], o = [];
  function s(l, h) {
    return (
      /*recording*/
      l[4] ? 0 : 1
    );
  }
  return e = s(t), i = o[e] = a[e](t), {
    c() {
      i.c(), n = Df();
    },
    m(l, h) {
      o[e].m(l, h), It(l, n, h), r = !0;
    },
    p(l, h) {
      let u = e;
      e = s(l), e !== u && (dr(), Pe(o[u], 1, 1, () => {
        o[u] = null;
      }), ur(), i = o[e], i || (i = o[e] = a[e](l), i.c()), Ie(i, 1), i.m(n.parentNode, n));
    },
    i(l) {
      r || (Ie(i), r = !0);
    },
    o(l) {
      Pe(i), r = !1;
    },
    d(l) {
      l && Ht(n), o[e].d(l);
    }
  };
}
function zf(t) {
  let e, i, n;
  return i = new js({}), {
    c() {
      e = Ot("div"), cr(i.$$.fragment), At(e, "class", "icon svelte-ji57xm");
    },
    m(r, a) {
      It(r, e, a), mr(i, e, null), n = !0;
    },
    i(r) {
      n || (Ie(i.$$.fragment, r), n = !0);
    },
    o(r) {
      Pe(i.$$.fragment, r), n = !1;
    },
    d(r) {
      r && Ht(e), fr(i);
    }
  };
}
function Ff(t) {
  let e, i, n;
  return i = new Ul({}), {
    c() {
      e = Ot("div"), cr(i.$$.fragment), At(e, "class", "icon svelte-ji57xm");
    },
    m(r, a) {
      It(r, e, a), mr(i, e, null), n = !0;
    },
    i(r) {
      n || (Ie(i.$$.fragment, r), n = !0);
    },
    o(r) {
      Pe(i.$$.fragment, r), n = !1;
    },
    d(r) {
      r && Ht(e), fr(i);
    }
  };
}
function jf(t) {
  let e, i, n, r, a = !/*streaming*/
  t[0] && Ea(t);
  return {
    c() {
      e = Ot("div"), i = Ot("video"), n = xf(), a && a.c(), At(i, "class", "svelte-ji57xm"), ya(
        i,
        "flip",
        /*mirror_webcam*/
        t[2]
      ), At(e, "class", "wrap svelte-ji57xm");
    },
    m(o, s) {
      It(o, e, s), wa(e, i), t[9](i), wa(e, n), a && a.m(e, null), r = !0;
    },
    p(o, [s]) {
      (!r || s & /*mirror_webcam*/
      4) && ya(
        i,
        "flip",
        /*mirror_webcam*/
        o[2]
      ), /*streaming*/
      o[0] ? a && (dr(), Pe(a, 1, 1, () => {
        a = null;
      }), ur()) : a ? (a.p(o, s), s & /*streaming*/
      1 && Ie(a, 1)) : (a = Ea(o), a.c(), Ie(a, 1), a.m(e, null));
    },
    i(o) {
      r || (Ie(a), r = !0);
    },
    o(o) {
      Pe(a), r = !1;
    },
    d(o) {
      o && Ht(e), t[9](null), a && a.d();
    }
  };
}
function Xf(t, e, i) {
  let n;
  Of(t, Cf, (w) => i(15, n = w));
  let r, a, { streaming: o = !1 } = e, { pending: s = !1 } = e, { mode: l = "image" } = e, { mirror_webcam: h } = e, { include_audio: u } = e;
  const f = Pf();
  Lf(() => a = document.createElement("canvas"));
  async function c() {
    try {
      v = await navigator.mediaDevices.getUserMedia({ video: !0, audio: u }), i(3, r.srcObject = v, r), i(3, r.muted = !0, r), r.play();
    } catch (w) {
      if (w instanceof DOMException && w.name == "NotAllowedError")
        f("error", n("image.allow_webcam_access"));
      else
        throw w;
    }
  }
  function d() {
    var w = a.getContext("2d");
    if (r.videoWidth && r.videoHeight) {
      a.width = r.videoWidth, a.height = r.videoHeight, w.drawImage(r, 0, 0, r.videoWidth, r.videoHeight);
      var _ = a.toDataURL("image/png");
      f(o ? "stream" : "capture", _);
    }
  }
  let m = !1, p = [], v, k, T;
  function S() {
    if (m) {
      T.stop();
      let w = new Blob(p, { type: k }), _ = new FileReader();
      _.onload = function(E) {
        E.target && (f("capture", {
          data: E.target.result,
          name: "sample." + k.substring(6),
          is_example: !1
        }), f("stop_recording"));
      }, _.readAsDataURL(w);
    } else {
      f("start_recording"), p = [];
      let w = ["video/webm", "video/mp4"];
      for (let _ of w)
        if (MediaRecorder.isTypeSupported(_)) {
          k = _;
          break;
        }
      if (k === null) {
        console.error("No supported MediaRecorder mimeType");
        return;
      }
      T = new MediaRecorder(v, { mimeType: k }), T.addEventListener("dataavailable", function(_) {
        p.push(_.data);
      }), T.start(200);
    }
    i(4, m = !m);
  }
  c(), o && l === "image" && window.setInterval(
    () => {
      r && !s && d();
    },
    500
  );
  function I(w) {
    Af[w ? "unshift" : "push"](() => {
      r = w, i(3, r);
    });
  }
  return t.$$set = (w) => {
    "streaming" in w && i(0, o = w.streaming), "pending" in w && i(7, s = w.pending), "mode" in w && i(1, l = w.mode), "mirror_webcam" in w && i(2, h = w.mirror_webcam), "include_audio" in w && i(8, u = w.include_audio);
  }, [
    o,
    l,
    h,
    r,
    m,
    d,
    S,
    s,
    u,
    I
  ];
}
class Wf extends Mf {
  constructor(e) {
    super(), Bf(this, e, Xf, jf, Rf, {
      streaming: 0,
      pending: 7,
      mode: 1,
      mirror_webcam: 2,
      include_audio: 8
    });
  }
}
const {
  SvelteComponent: Vf,
  append: ka,
  attr: qf,
  check_outros: Yf,
  create_component: Vn,
  destroy_component: qn,
  detach: Zf,
  element: Qf,
  group_outros: Jf,
  init: Kf,
  insert: $f,
  mount_component: Yn,
  noop: e0,
  safe_not_equal: t0,
  space: Ta,
  transition_in: gt,
  transition_out: jt
} = window.__gradio__svelte__internal, { createEventDispatcher: i0 } = window.__gradio__svelte__internal;
function Sa(t) {
  let e, i;
  return e = new nt({ props: { Icon: bl, label: "Clear" } }), e.$on(
    "click",
    /*click_handler_1*/
    t[3]
  ), {
    c() {
      Vn(e.$$.fragment);
    },
    m(n, r) {
      Yn(e, n, r), i = !0;
    },
    p: e0,
    i(n) {
      i || (gt(e.$$.fragment, n), i = !0);
    },
    o(n) {
      jt(e.$$.fragment, n), i = !1;
    },
    d(n) {
      qn(e, n);
    }
  };
}
function n0(t) {
  let e, i, n, r, a, o;
  i = new nt({ props: { Icon: Vl, label: "Undo" } }), i.$on(
    "click",
    /*click_handler*/
    t[2]
  );
  let s = (
    /*show_eraser*/
    t[0] && Sa(t)
  );
  return a = new nt({
    props: { Icon: Wa, label: "Remove Image" }
  }), a.$on(
    "click",
    /*click_handler_2*/
    t[4]
  ), {
    c() {
      e = Qf("div"), Vn(i.$$.fragment), n = Ta(), s && s.c(), r = Ta(), Vn(a.$$.fragment), qf(e, "class", "svelte-1g74h68");
    },
    m(l, h) {
      $f(l, e, h), Yn(i, e, null), ka(e, n), s && s.m(e, null), ka(e, r), Yn(a, e, null), o = !0;
    },
    p(l, [h]) {
      /*show_eraser*/
      l[0] ? s ? (s.p(l, h), h & /*show_eraser*/
      1 && gt(s, 1)) : (s = Sa(l), s.c(), gt(s, 1), s.m(e, r)) : s && (Jf(), jt(s, 1, 1, () => {
        s = null;
      }), Yf());
    },
    i(l) {
      o || (gt(i.$$.fragment, l), gt(s), gt(a.$$.fragment, l), o = !0);
    },
    o(l) {
      jt(i.$$.fragment, l), jt(s), jt(a.$$.fragment, l), o = !1;
    },
    d(l) {
      l && Zf(e), qn(i), s && s.d(), qn(a);
    }
  };
}
function r0(t, e, i) {
  const n = i0();
  let { show_eraser: r = !1 } = e;
  const a = () => n("undo"), o = (l) => {
    n("clear_mask"), l.stopPropagation();
  }, s = (l) => {
    n("remove_image"), l.stopPropagation();
  };
  return t.$$set = (l) => {
    "show_eraser" in l && i(0, r = l.show_eraser);
  }, [r, n, a, o, s];
}
class _r extends Vf {
  constructor(e) {
    super(), Kf(this, e, r0, n0, t0, { show_eraser: 0 });
  }
}
const {
  SvelteComponent: a0,
  append: ki,
  attr: pe,
  check_outros: o0,
  create_component: Uo,
  destroy_component: Go,
  detach: zi,
  element: Jt,
  group_outros: s0,
  init: l0,
  insert: Fi,
  listen: Zn,
  mount_component: zo,
  run_all: h0,
  safe_not_equal: u0,
  set_input_value: Hi,
  space: Qn,
  to_number: c0,
  transition_in: Xt,
  transition_out: Ti
} = window.__gradio__svelte__internal;
function Ca(t) {
  let e, i, n, r, a;
  return {
    c() {
      e = Jt("input"), pe(e, "aria-label", "Brush radius"), pe(e, "type", "range"), pe(e, "min", i = 0.5 * /*img_width*/
      (t[2] / /*width*/
      t[6])), pe(e, "max", n = 75 * /*img_width*/
      (t[2] / /*width*/
      t[6])), pe(e, "class", "svelte-1hdlygn");
    },
    m(o, s) {
      Fi(o, e, s), Hi(
        e,
        /*brush_radius*/
        t[0]
      ), r || (a = [
        Zn(
          e,
          "change",
          /*input_change_input_handler*/
          t[10]
        ),
        Zn(
          e,
          "input",
          /*input_change_input_handler*/
          t[10]
        )
      ], r = !0);
    },
    p(o, s) {
      s & /*img_width, width*/
      68 && i !== (i = 0.5 * /*img_width*/
      (o[2] / /*width*/
      o[6])) && pe(e, "min", i), s & /*img_width, width*/
      68 && n !== (n = 75 * /*img_width*/
      (o[2] / /*width*/
      o[6])) && pe(e, "max", n), s & /*brush_radius*/
      1 && Hi(
        e,
        /*brush_radius*/
        o[0]
      );
    },
    d(o) {
      o && zi(e), r = !1, h0(a);
    }
  };
}
function Ma(t) {
  let e, i, n, r;
  i = new nt({
    props: { Icon: il, label: "Select brush color" }
  }), i.$on(
    "click",
    /*click_handler_1*/
    t[11]
  );
  let a = (
    /*show_col*/
    t[5] && Aa(t)
  );
  return {
    c() {
      e = Jt("span"), Uo(i.$$.fragment), n = Qn(), a && a.c(), pe(e, "class", "col svelte-1hdlygn");
    },
    m(o, s) {
      Fi(o, e, s), zo(i, e, null), ki(e, n), a && a.m(e, null), r = !0;
    },
    p(o, s) {
      /*show_col*/
      o[5] ? a ? a.p(o, s) : (a = Aa(o), a.c(), a.m(e, null)) : a && (a.d(1), a = null);
    },
    i(o) {
      r || (Xt(i.$$.fragment, o), r = !0);
    },
    o(o) {
      Ti(i.$$.fragment, o), r = !1;
    },
    d(o) {
      o && zi(e), Go(i), a && a.d();
    }
  };
}
function Aa(t) {
  let e, i, n;
  return {
    c() {
      e = Jt("input"), pe(e, "aria-label", "Brush color"), pe(e, "type", "color"), pe(e, "class", "svelte-1hdlygn");
    },
    m(r, a) {
      Fi(r, e, a), Hi(
        e,
        /*brush_color*/
        t[1]
      ), i || (n = Zn(
        e,
        "input",
        /*input_input_handler*/
        t[12]
      ), i = !0);
    },
    p(r, a) {
      a & /*brush_color*/
      2 && Hi(
        e,
        /*brush_color*/
        r[1]
      );
    },
    d(r) {
      r && zi(e), i = !1, n();
    }
  };
}
function f0(t) {
  let e, i, n, r, a, o;
  n = new nt({
    props: { Icon: As, label: "Use brush" }
  }), n.$on(
    "click",
    /*click_handler*/
    t[9]
  );
  let s = (
    /*show_size*/
    t[4] && Ca(t)
  ), l = (
    /*mode*/
    t[3] !== "mask" && Ma(t)
  );
  return {
    c() {
      e = Jt("div"), i = Jt("span"), Uo(n.$$.fragment), r = Qn(), s && s.c(), a = Qn(), l && l.c(), pe(i, "class", "brush svelte-1hdlygn"), pe(e, "class", "wrap svelte-1hdlygn");
    },
    m(h, u) {
      Fi(h, e, u), ki(e, i), zo(n, i, null), ki(i, r), s && s.m(i, null), ki(e, a), l && l.m(e, null), o = !0;
    },
    p(h, [u]) {
      /*show_size*/
      h[4] ? s ? s.p(h, u) : (s = Ca(h), s.c(), s.m(i, null)) : s && (s.d(1), s = null), /*mode*/
      h[3] !== "mask" ? l ? (l.p(h, u), u & /*mode*/
      8 && Xt(l, 1)) : (l = Ma(h), l.c(), Xt(l, 1), l.m(e, null)) : l && (s0(), Ti(l, 1, 1, () => {
        l = null;
      }), o0());
    },
    i(h) {
      o || (Xt(n.$$.fragment, h), Xt(l), o = !0);
    },
    o(h) {
      Ti(n.$$.fragment, h), Ti(l), o = !1;
    },
    d(h) {
      h && zi(e), Go(n), s && s.d(), l && l.d();
    }
  };
}
function d0(t, e, i) {
  let n, r = !1, a = !1, { brush_radius: o = 20 } = e, { brush_color: s = "#000" } = e, { container_height: l } = e, { img_width: h } = e, { img_height: u } = e, { mode: f = "other" } = e;
  const c = () => i(4, r = !r);
  function d() {
    o = c0(this.value), i(0, o);
  }
  const m = () => i(5, a = !a);
  function p() {
    s = this.value, i(1, s);
  }
  return t.$$set = (v) => {
    "brush_radius" in v && i(0, o = v.brush_radius), "brush_color" in v && i(1, s = v.brush_color), "container_height" in v && i(7, l = v.container_height), "img_width" in v && i(2, h = v.img_width), "img_height" in v && i(8, u = v.img_height), "mode" in v && i(3, f = v.mode);
  }, t.$$.update = () => {
    t.$$.dirty & /*container_height, img_width, img_height*/
    388 && i(6, n = l * (h / u));
  }, [
    o,
    s,
    h,
    f,
    r,
    a,
    n,
    l,
    u,
    c,
    d,
    m,
    p
  ];
}
class pr extends a0 {
  constructor(e) {
    super(), l0(this, e, d0, f0, u0, {
      brush_radius: 0,
      brush_color: 1,
      container_height: 7,
      img_width: 2,
      img_height: 8,
      mode: 3
    });
  }
}
const m0 = (t) => {
  const e = new FileReader();
  return e.readAsDataURL(t), new Promise((i) => {
    e.onloadend = () => {
      i(e.result);
    };
  });
}, _0 = (t) => {
  let e = t.currentTarget;
  const i = e.getBoundingClientRect(), n = e.naturalWidth / i.width, r = e.naturalHeight / i.height;
  if (n > r) {
    const s = e.naturalHeight / n, l = (i.height - s) / 2;
    var a = Math.round((t.clientX - i.left) * n), o = Math.round((t.clientY - i.top - l) * n);
  } else {
    const s = e.naturalWidth / r, l = (i.width - s) / 2;
    var a = Math.round((t.clientX - i.left - l) * r), o = Math.round((t.clientY - i.top) * r);
  }
  return a < 0 || a >= e.naturalWidth || o < 0 || o >= e.naturalHeight ? null : [a, o];
};
const {
  SvelteComponent: p0,
  append: Oa,
  attr: xe,
  binding_callbacks: g0,
  bubble: $e,
  create_slot: b0,
  detach: v0,
  element: Da,
  get_all_dirty_from_scope: w0,
  get_slot_changes: y0,
  init: E0,
  insert: k0,
  listen: ye,
  prevent_default: et,
  run_all: T0,
  safe_not_equal: S0,
  space: C0,
  stop_propagation: tt,
  toggle_class: _t,
  transition_in: M0,
  transition_out: A0,
  update_slot_base: O0
} = window.__gradio__svelte__internal, { createEventDispatcher: D0 } = window.__gradio__svelte__internal;
function B0(t) {
  let e, i, n, r, a, o, s, l, h;
  const u = (
    /*#slots*/
    t[15].default
  ), f = b0(
    u,
    t,
    /*$$scope*/
    t[14],
    null
  );
  return {
    c() {
      e = Da("div"), f && f.c(), i = C0(), n = Da("input"), xe(n, "type", "file"), xe(
        n,
        "accept",
        /*filetype*/
        t[0]
      ), n.multiple = r = /*file_count*/
      t[4] === "multiple" || void 0, xe(n, "webkitdirectory", a = /*file_count*/
      t[4] === "directory" || void 0), xe(n, "mozdirectory", o = /*file_count*/
      t[4] === "directory" || void 0), xe(n, "class", "svelte-1h87ywf"), xe(e, "class", "svelte-1h87ywf"), _t(
        e,
        "center",
        /*center*/
        t[2]
      ), _t(
        e,
        "boundedheight",
        /*boundedheight*/
        t[1]
      ), _t(
        e,
        "flex",
        /*flex*/
        t[3]
      );
    },
    m(c, d) {
      k0(c, e, d), f && f.m(e, null), Oa(e, i), Oa(e, n), t[23](n), s = !0, l || (h = [
        ye(
          n,
          "change",
          /*loadFilesFromUpload*/
          t[8]
        ),
        ye(e, "drag", tt(et(
          /*drag_handler*/
          t[16]
        ))),
        ye(e, "dragstart", tt(et(
          /*dragstart_handler*/
          t[17]
        ))),
        ye(e, "dragend", tt(et(
          /*dragend_handler*/
          t[18]
        ))),
        ye(e, "dragover", tt(et(
          /*dragover_handler*/
          t[19]
        ))),
        ye(e, "dragenter", tt(et(
          /*dragenter_handler*/
          t[20]
        ))),
        ye(e, "dragleave", tt(et(
          /*dragleave_handler*/
          t[21]
        ))),
        ye(e, "drop", tt(et(
          /*drop_handler*/
          t[22]
        ))),
        ye(
          e,
          "click",
          /*openFileUpload*/
          t[7]
        ),
        ye(
          e,
          "drop",
          /*loadFilesFromDrop*/
          t[9]
        ),
        ye(
          e,
          "dragenter",
          /*updateDragging*/
          t[6]
        ),
        ye(
          e,
          "dragleave",
          /*updateDragging*/
          t[6]
        )
      ], l = !0);
    },
    p(c, [d]) {
      f && f.p && (!s || d & /*$$scope*/
      16384) && O0(
        f,
        u,
        c,
        /*$$scope*/
        c[14],
        s ? y0(
          u,
          /*$$scope*/
          c[14],
          d,
          null
        ) : w0(
          /*$$scope*/
          c[14]
        ),
        null
      ), (!s || d & /*filetype*/
      1) && xe(
        n,
        "accept",
        /*filetype*/
        c[0]
      ), (!s || d & /*file_count*/
      16 && r !== (r = /*file_count*/
      c[4] === "multiple" || void 0)) && (n.multiple = r), (!s || d & /*file_count*/
      16 && a !== (a = /*file_count*/
      c[4] === "directory" || void 0)) && xe(n, "webkitdirectory", a), (!s || d & /*file_count*/
      16 && o !== (o = /*file_count*/
      c[4] === "directory" || void 0)) && xe(n, "mozdirectory", o), (!s || d & /*center*/
      4) && _t(
        e,
        "center",
        /*center*/
        c[2]
      ), (!s || d & /*boundedheight*/
      2) && _t(
        e,
        "boundedheight",
        /*boundedheight*/
        c[1]
      ), (!s || d & /*flex*/
      8) && _t(
        e,
        "flex",
        /*flex*/
        c[3]
      );
    },
    i(c) {
      s || (M0(f, c), s = !0);
    },
    o(c) {
      A0(f, c), s = !1;
    },
    d(c) {
      c && v0(e), f && f.d(c), t[23](null), l = !1, T0(h);
    }
  };
}
function H0(t) {
  let e, i = t[0], n = 1;
  for (; n < t.length; ) {
    const r = t[n], a = t[n + 1];
    if (n += 2, (r === "optionalAccess" || r === "optionalCall") && i == null)
      return;
    r === "access" || r === "optionalAccess" ? (e = i, i = a(i)) : (r === "call" || r === "optionalCall") && (i = a((...o) => i.call(e, ...o)), e = void 0);
  }
  return i;
}
function I0(t, e, i) {
  let { $$slots: n = {}, $$scope: r } = e, { filetype: a = null } = e, { include_file_metadata: o = !0 } = e, { dragging: s = !1 } = e, { boundedheight: l = !0 } = e, { center: h = !0 } = e, { flex: u = !0 } = e, { file_count: f = "single" } = e, { disable_click: c = !1 } = e, { parse_to_data_url: d = !0 } = e, m;
  const p = D0();
  function v() {
    i(10, s = !s);
  }
  function k() {
    c || (i(5, m.value = "", m), m.click());
  }
  async function T(y) {
    let D = Array.from(y);
    if (!(!y.length || !window.FileReader)) {
      if (f === "single" && (D = [y[0]]), o)
        var F = D.map((Y) => ({ name: Y.name, size: Y.size }));
      var Q = [], q = [];
      d ? q = await Promise.all(D.map((Y) => m0(Y))) : q = D, o ? d ? Q = q.map((Y, ue) => ({ data: Y, ...F[ue] })) : Q = q.map((Y, ue) => ({
        data: "",
        blob: Y,
        ...F[ue]
      })) : Q = q, p("load", f === "single" ? Q[0] : Q);
    }
  }
  async function S(y) {
    const D = y.target;
    D.files && await T(D.files);
  }
  async function I(y) {
    i(10, s = !1), H0([y, "access", (D) => D.dataTransfer, "optionalAccess", (D) => D.files]) && await T(y.dataTransfer.files);
  }
  function w(y) {
    $e.call(this, t, y);
  }
  function _(y) {
    $e.call(this, t, y);
  }
  function E(y) {
    $e.call(this, t, y);
  }
  function O(y) {
    $e.call(this, t, y);
  }
  function G(y) {
    $e.call(this, t, y);
  }
  function Z(y) {
    $e.call(this, t, y);
  }
  function oe(y) {
    $e.call(this, t, y);
  }
  function se(y) {
    g0[y ? "unshift" : "push"](() => {
      m = y, i(5, m);
    });
  }
  return t.$$set = (y) => {
    "filetype" in y && i(0, a = y.filetype), "include_file_metadata" in y && i(11, o = y.include_file_metadata), "dragging" in y && i(10, s = y.dragging), "boundedheight" in y && i(1, l = y.boundedheight), "center" in y && i(2, h = y.center), "flex" in y && i(3, u = y.flex), "file_count" in y && i(4, f = y.file_count), "disable_click" in y && i(12, c = y.disable_click), "parse_to_data_url" in y && i(13, d = y.parse_to_data_url), "$$scope" in y && i(14, r = y.$$scope);
  }, [
    a,
    l,
    h,
    u,
    f,
    m,
    v,
    k,
    S,
    I,
    s,
    o,
    c,
    d,
    r,
    n,
    w,
    _,
    E,
    O,
    G,
    Z,
    oe,
    se
  ];
}
class N0 extends p0 {
  constructor(e) {
    super(), E0(this, e, I0, B0, S0, {
      filetype: 0,
      include_file_metadata: 11,
      dragging: 10,
      boundedheight: 1,
      center: 2,
      flex: 3,
      file_count: 4,
      disable_click: 12,
      parse_to_data_url: 13
    });
  }
}
const {
  SvelteComponent: R0,
  append: x0,
  attr: P0,
  check_outros: L0,
  create_component: Fo,
  destroy_component: jo,
  detach: U0,
  element: G0,
  group_outros: z0,
  init: F0,
  insert: j0,
  mount_component: Xo,
  safe_not_equal: X0,
  set_style: Ba,
  space: W0,
  toggle_class: Ha,
  transition_in: Wt,
  transition_out: Si
} = window.__gradio__svelte__internal, { createEventDispatcher: V0 } = window.__gradio__svelte__internal;
function Ia(t) {
  let e, i;
  return e = new nt({
    props: {
      Icon: ul,
      label: (
        /*i18n*/
        t[2]("common.edit")
      )
    }
  }), e.$on(
    "click",
    /*click_handler*/
    t[4]
  ), {
    c() {
      Fo(e.$$.fragment);
    },
    m(n, r) {
      Xo(e, n, r), i = !0;
    },
    p(n, r) {
      const a = {};
      r & /*i18n*/
      4 && (a.label = /*i18n*/
      n[2]("common.edit")), e.$set(a);
    },
    i(n) {
      i || (Wt(e.$$.fragment, n), i = !0);
    },
    o(n) {
      Si(e.$$.fragment, n), i = !1;
    },
    d(n) {
      jo(e, n);
    }
  };
}
function q0(t) {
  let e, i, n, r, a = (
    /*editable*/
    t[0] && Ia(t)
  );
  return n = new nt({
    props: {
      Icon: Wa,
      label: (
        /*i18n*/
        t[2]("common.clear")
      )
    }
  }), n.$on(
    "click",
    /*click_handler_1*/
    t[5]
  ), {
    c() {
      e = G0("div"), a && a.c(), i = W0(), Fo(n.$$.fragment), P0(e, "class", "svelte-1wj0ocy"), Ha(e, "not-absolute", !/*absolute*/
      t[1]), Ba(
        e,
        "position",
        /*absolute*/
        t[1] ? "absolute" : "static"
      );
    },
    m(o, s) {
      j0(o, e, s), a && a.m(e, null), x0(e, i), Xo(n, e, null), r = !0;
    },
    p(o, [s]) {
      /*editable*/
      o[0] ? a ? (a.p(o, s), s & /*editable*/
      1 && Wt(a, 1)) : (a = Ia(o), a.c(), Wt(a, 1), a.m(e, i)) : a && (z0(), Si(a, 1, 1, () => {
        a = null;
      }), L0());
      const l = {};
      s & /*i18n*/
      4 && (l.label = /*i18n*/
      o[2]("common.clear")), n.$set(l), (!r || s & /*absolute*/
      2) && Ha(e, "not-absolute", !/*absolute*/
      o[1]), s & /*absolute*/
      2 && Ba(
        e,
        "position",
        /*absolute*/
        o[1] ? "absolute" : "static"
      );
    },
    i(o) {
      r || (Wt(a), Wt(n.$$.fragment, o), r = !0);
    },
    o(o) {
      Si(a), Si(n.$$.fragment, o), r = !1;
    },
    d(o) {
      o && U0(e), a && a.d(), jo(n);
    }
  };
}
function Y0(t, e, i) {
  let { editable: n = !1 } = e, { absolute: r = !0 } = e, { i18n: a } = e;
  const o = V0(), s = () => o("edit"), l = (h) => {
    o("clear"), h.stopPropagation();
  };
  return t.$$set = (h) => {
    "editable" in h && i(0, n = h.editable), "absolute" in h && i(1, r = h.absolute), "i18n" in h && i(2, a = h.i18n);
  }, [n, r, a, o, s, l];
}
class ji extends R0 {
  constructor(e) {
    super(), F0(this, e, Y0, q0, X0, { editable: 0, absolute: 1, i18n: 2 });
  }
}
const {
  SvelteComponent: Z0,
  add_flush_callback: ge,
  add_iframe_resize_listener: Q0,
  add_render_callback: J0,
  attr: P,
  bind: be,
  binding_callbacks: K,
  bubble: Na,
  check_outros: Ve,
  create_component: ne,
  create_slot: K0,
  destroy_component: re,
  detach: L,
  element: ot,
  empty: Nt,
  get_all_dirty_from_scope: $0,
  get_slot_changes: ed,
  group_outros: qe,
  init: td,
  insert: U,
  listen: Rt,
  mount_component: ae,
  noop: Ii,
  safe_not_equal: gr,
  space: ve,
  src_url_equal: ke,
  toggle_class: ee,
  transition_in: M,
  transition_out: H,
  update_slot_base: id
} = window.__gradio__svelte__internal, { createEventDispatcher: nd, tick: wi, onMount: rd } = window.__gradio__svelte__internal;
function ad(t) {
  let e, i, n, r;
  return {
    c() {
      e = ot("img"), ke(e.src, i = /*value*/
      t[0].back) || P(e, "src", i), P(e, "alt", ""), P(e, "class", "svelte-14sn87y"), ee(
        e,
        "webcam",
        /*source*/
        t[6] === "webcam" && /*mirror_webcam*/
        t[10]
      ), ee(
        e,
        "selectable",
        /*selectable*/
        t[12]
      );
    },
    m(a, o) {
      U(a, e, o), n || (r = Rt(
        e,
        "click",
        /*handle_click*/
        t[32]
      ), n = !0);
    },
    p(a, o) {
      o[0] & /*value*/
      1 && !ke(e.src, i = /*value*/
      a[0].back) && P(e, "src", i), o[0] & /*source, mirror_webcam*/
      1088 && ee(
        e,
        "webcam",
        /*source*/
        a[6] === "webcam" && /*mirror_webcam*/
        a[10]
      ), o[0] & /*selectable*/
      4096 && ee(
        e,
        "selectable",
        /*selectable*/
        a[12]
      );
    },
    i: Ii,
    o: Ii,
    d(a) {
      a && L(e), n = !1, r();
    }
  };
}
function od(t) {
  let e = (
    /*static_image*/
    t[25]
  ), i, n, r, a = Ra(t), o = (
    /*img_width*/
    t[19] > 0 && xa(t)
  );
  return {
    c() {
      a.c(), i = ve(), o && o.c(), n = Nt();
    },
    m(s, l) {
      a.m(s, l), U(s, i, l), o && o.m(s, l), U(s, n, l), r = !0;
    },
    p(s, l) {
      l[0] & /*static_image*/
      33554432 && gr(e, e = /*static_image*/
      s[25]) ? (a.d(1), a = Ra(s), a.c(), a.m(i.parentNode, i)) : a.p(s, l), /*img_width*/
      s[19] > 0 ? o ? (o.p(s, l), l[0] & /*img_width*/
      524288 && M(o, 1)) : (o = xa(s), o.c(), M(o, 1), o.m(n.parentNode, n)) : o && (qe(), H(o, 1, 1, () => {
        o = null;
      }), Ve());
    },
    i(s) {
      r || (M(o), r = !0);
    },
    o(s) {
      H(o), r = !1;
    },
    d(s) {
      s && (L(i), L(n)), a.d(s), o && o.d(s);
    }
  };
}
function sd(t) {
  let e, i, n, r, a, o, s;
  return e = new ji({
    props: { i18n: (
      /*i18n*/
      t[14]
    ), editable: !0 }
  }), e.$on(
    "edit",
    /*edit_handler_1*/
    t[56]
  ), e.$on(
    "clear",
    /*handle_clear*/
    t[27]
  ), {
    c() {
      ne(e.$$.fragment), i = ve(), n = ot("img"), ke(n.src, r = /*value*/
      t[0].back) || P(n, "src", r), P(n, "alt", ""), P(n, "class", "svelte-14sn87y"), ee(
        n,
        "selectable",
        /*selectable*/
        t[12]
      ), ee(
        n,
        "webcam",
        /*source*/
        t[6] === "webcam" && /*mirror_webcam*/
        t[10]
      );
    },
    m(l, h) {
      ae(e, l, h), U(l, i, h), U(l, n, h), a = !0, o || (s = Rt(
        n,
        "click",
        /*handle_click*/
        t[32]
      ), o = !0);
    },
    p(l, h) {
      const u = {};
      h[0] & /*i18n*/
      16384 && (u.i18n = /*i18n*/
      l[14]), e.$set(u), (!a || h[0] & /*value*/
      1 && !ke(n.src, r = /*value*/
      l[0].back)) && P(n, "src", r), (!a || h[0] & /*selectable*/
      4096) && ee(
        n,
        "selectable",
        /*selectable*/
        l[12]
      ), (!a || h[0] & /*source, mirror_webcam*/
      1088) && ee(
        n,
        "webcam",
        /*source*/
        l[6] === "webcam" && /*mirror_webcam*/
        l[10]
      );
    },
    i(l) {
      a || (M(e.$$.fragment, l), a = !0);
    },
    o(l) {
      H(e.$$.fragment, l), a = !1;
    },
    d(l) {
      l && (L(i), L(n)), re(e, l), o = !1, s();
    }
  };
}
function ld(t) {
  let e, i, n, r, a = { image: (
    /*value*/
    t[0].back
  ) };
  return e = new lo({ props: a }), t[54](e), e.$on(
    "crop",
    /*handle_save*/
    t[28]
  ), n = new ji({ props: { i18n: (
    /*i18n*/
    t[14]
  ) } }), n.$on(
    "clear",
    /*clear_handler_1*/
    t[55]
  ), {
    c() {
      ne(e.$$.fragment), i = ve(), ne(n.$$.fragment);
    },
    m(o, s) {
      ae(e, o, s), U(o, i, s), ae(n, o, s), r = !0;
    },
    p(o, s) {
      const l = {};
      s[0] & /*value*/
      1 && (l.image = /*value*/
      o[0].back), e.$set(l);
      const h = {};
      s[0] & /*i18n*/
      16384 && (h.i18n = /*i18n*/
      o[14]), n.$set(h);
    },
    i(o) {
      r || (M(e.$$.fragment, o), M(n.$$.fragment, o), r = !0);
    },
    o(o) {
      H(e.$$.fragment, o), H(n.$$.fragment, o), r = !1;
    },
    d(o) {
      o && L(i), t[54](null), re(e, o), re(n, o);
    }
  };
}
function hd(t) {
  let e, i, n = (
    /*source*/
    t[6] === "webcam" && !/*static_image*/
    t[25] && La(t)
  );
  return {
    c() {
      n && n.c(), e = Nt();
    },
    m(r, a) {
      n && n.m(r, a), U(r, e, a), i = !0;
    },
    p(r, a) {
      /*source*/
      r[6] === "webcam" && !/*static_image*/
      r[25] ? n ? (n.p(r, a), a[0] & /*source, static_image*/
      33554496 && M(n, 1)) : (n = La(r), n.c(), M(n, 1), n.m(e.parentNode, e)) : n && (qe(), H(n, 1, 1, () => {
        n = null;
      }), Ve());
    },
    i(r) {
      i || (M(n), i = !0);
    },
    o(r) {
      H(n), i = !1;
    },
    d(r) {
      r && L(e), n && n.d(r);
    }
  };
}
function ud(t) {
  var c;
  let e, i, n, r, a, o, s;
  e = new _r({}), e.$on(
    "undo",
    /*undo_handler_1*/
    t[46]
  ), e.$on(
    "remove_image",
    /*handle_sketch_clear*/
    t[30]
  );
  let l = (
    /*tool*/
    t[1] === "color-sketch" && Ua(t)
  );
  function h(d) {
    t[49](d);
  }
  function u(d) {
    t[50](d);
  }
  let f = {
    value: (
      /*value*/
      (c = t[0]) == null ? void 0 : c.back
    ),
    mode: (
      /*mode*/
      t[21]
    ),
    width: (
      /*img_width*/
      t[19] || /*max_width*/
      t[24]
    ),
    height: (
      /*img_height*/
      t[18] || /*max_height*/
      t[23]
    ),
    container_height: (
      /*container_height*/
      t[20] || /*max_height*/
      t[23]
    ),
    shape: (
      /*shape*/
      t[7]
    )
  };
  return (
    /*brush_radius*/
    t[2] !== void 0 && (f.brush_radius = /*brush_radius*/
    t[2]), /*brush_color*/
    t[3] !== void 0 && (f.brush_color = /*brush_color*/
    t[3]), r = new ar({ props: f }), K.push(() => be(r, "brush_radius", h)), K.push(() => be(r, "brush_color", u)), t[51](r), r.$on(
      "change",
      /*handle_save*/
      t[28]
    ), r.$on(
      "clear",
      /*handle_sketch_clear*/
      t[30]
    ), {
      c() {
        ne(e.$$.fragment), i = ve(), l && l.c(), n = ve(), ne(r.$$.fragment);
      },
      m(d, m) {
        ae(e, d, m), U(d, i, m), l && l.m(d, m), U(d, n, m), ae(r, d, m), s = !0;
      },
      p(d, m) {
        var v;
        /*tool*/
        d[1] === "color-sketch" ? l ? (l.p(d, m), m[0] & /*tool*/
        2 && M(l, 1)) : (l = Ua(d), l.c(), M(l, 1), l.m(n.parentNode, n)) : l && (qe(), H(l, 1, 1, () => {
          l = null;
        }), Ve());
        const p = {};
        m[0] & /*value*/
        1 && (p.value = /*value*/
        (v = d[0]) == null ? void 0 : v.back), m[0] & /*mode*/
        2097152 && (p.mode = /*mode*/
        d[21]), m[0] & /*img_width, max_width*/
        17301504 && (p.width = /*img_width*/
        d[19] || /*max_width*/
        d[24]), m[0] & /*img_height, max_height*/
        8650752 && (p.height = /*img_height*/
        d[18] || /*max_height*/
        d[23]), m[0] & /*container_height, max_height*/
        9437184 && (p.container_height = /*container_height*/
        d[20] || /*max_height*/
        d[23]), m[0] & /*shape*/
        128 && (p.shape = /*shape*/
        d[7]), !a && m[0] & /*brush_radius*/
        4 && (a = !0, p.brush_radius = /*brush_radius*/
        d[2], ge(() => a = !1)), !o && m[0] & /*brush_color*/
        8 && (o = !0, p.brush_color = /*brush_color*/
        d[3], ge(() => o = !1)), r.$set(p);
      },
      i(d) {
        s || (M(e.$$.fragment, d), M(l), M(r.$$.fragment, d), s = !0);
      },
      o(d) {
        H(e.$$.fragment, d), H(l), H(r.$$.fragment, d), s = !1;
      },
      d(d) {
        d && (L(i), L(n)), re(e, d), l && l.d(d), t[51](null), re(r, d);
      }
    }
  );
}
function cd(t) {
  let e, i, n;
  function r(o) {
    t[44](o);
  }
  let a = {
    filetype: "image/*",
    root: (
      /*root*/
      t[13]
    ),
    include_file_metadata: !1,
    disable_click: !!/*value*/
    t[0],
    $$slots: { default: [gd] },
    $$scope: { ctx: t }
  };
  return (
    /*dragging*/
    t[16] !== void 0 && (a.dragging = /*dragging*/
    t[16]), e = new N0({ props: a }), K.push(() => be(e, "dragging", r)), e.$on(
      "load",
      /*handle_upload*/
      t[26]
    ), e.$on(
      "error",
      /*error_handler*/
      t[45]
    ), {
      c() {
        ne(e.$$.fragment);
      },
      m(o, s) {
        ae(e, o, s), n = !0;
      },
      p(o, s) {
        const l = {};
        s[0] & /*root*/
        8192 && (l.root = /*root*/
        o[13]), s[0] & /*value*/
        1 && (l.disable_click = !!/*value*/
        o[0]), s[0] & /*value, static_image, streaming, i18n, tool, cropper, source, mirror_webcam, selectable, container_height, max_height, img_width, max_width, img_height, mode, brush_radius, brush_color, value_img, sketch, mask_opacity, shape*/
        67034575 | s[2] & /*$$scope*/
        8 && (l.$$scope = { dirty: s, ctx: o }), !i && s[0] & /*dragging*/
        65536 && (i = !0, l.dragging = /*dragging*/
        o[16], ge(() => i = !1)), e.$set(l);
      },
      i(o) {
        n || (M(e.$$.fragment, o), n = !0);
      },
      o(o) {
        H(e.$$.fragment, o), n = !1;
      },
      d(o) {
        re(e, o);
      }
    }
  );
}
function Ra(t) {
  let e, i, n, r;
  return {
    c() {
      e = ot("img"), P(e, "class", "absolute-img svelte-14sn87y"), ke(e.src, i = /*static_image*/
      t[25] || /*value*/
      t[0].back) || P(e, "src", i), P(e, "alt", ""), ee(
        e,
        "webcam",
        /*source*/
        t[6] === "webcam" && /*mirror_webcam*/
        t[10]
      );
    },
    m(a, o) {
      U(a, e, o), t[57](e), n || (r = Rt(
        e,
        "load",
        /*handle_image_load*/
        t[29]
      ), n = !0);
    },
    p(a, o) {
      o[0] & /*static_image, value*/
      33554433 && !ke(e.src, i = /*static_image*/
      a[25] || /*value*/
      a[0].back) && P(e, "src", i), o[0] & /*source, mirror_webcam*/
      1088 && ee(
        e,
        "webcam",
        /*source*/
        a[6] === "webcam" && /*mirror_webcam*/
        a[10]
      );
    },
    d(a) {
      a && L(e), t[57](null), n = !1, r();
    }
  };
}
function xa(t) {
  let e, i, n, r, a, o, s, l;
  function h(d) {
    t[59](d);
  }
  function u(d) {
    t[60](d);
  }
  let f = {
    value: (
      /*value*/
      t[0].back
    ),
    mode: (
      /*mode*/
      t[21]
    ),
    width: (
      /*img_width*/
      t[19] || /*max_width*/
      t[24]
    ),
    height: (
      /*img_height*/
      t[18] || /*max_height*/
      t[23]
    ),
    container_height: (
      /*container_height*/
      t[20] || /*max_height*/
      t[23]
    ),
    value_img: (
      /*value_img*/
      t[22]
    ),
    source: (
      /*source*/
      t[6]
    )
  };
  /*brush_radius*/
  t[2] !== void 0 && (f.brush_radius = /*brush_radius*/
  t[2]), /*brush_color*/
  t[3] !== void 0 && (f.brush_color = /*brush_color*/
  t[3]), e = new ar({ props: f }), t[58](e), K.push(() => be(e, "brush_radius", h)), K.push(() => be(e, "brush_color", u)), e.$on(
    "change",
    /*handle_save*/
    t[28]
  ), a = new _r({}), a.$on(
    "undo",
    /*undo_handler_2*/
    t[61]
  ), a.$on(
    "remove_image",
    /*handle_sketch_clear*/
    t[30]
  );
  let c = (
    /*tool*/
    (t[1] === "color-sketch" || /*tool*/
    t[1] === "sketch") && Pa(t)
  );
  return {
    c() {
      ne(e.$$.fragment), r = ve(), ne(a.$$.fragment), o = ve(), c && c.c(), s = Nt();
    },
    m(d, m) {
      ae(e, d, m), U(d, r, m), ae(a, d, m), U(d, o, m), c && c.m(d, m), U(d, s, m), l = !0;
    },
    p(d, m) {
      const p = {};
      m[0] & /*value*/
      1 && (p.value = /*value*/
      d[0].back), m[0] & /*mode*/
      2097152 && (p.mode = /*mode*/
      d[21]), m[0] & /*img_width, max_width*/
      17301504 && (p.width = /*img_width*/
      d[19] || /*max_width*/
      d[24]), m[0] & /*img_height, max_height*/
      8650752 && (p.height = /*img_height*/
      d[18] || /*max_height*/
      d[23]), m[0] & /*container_height, max_height*/
      9437184 && (p.container_height = /*container_height*/
      d[20] || /*max_height*/
      d[23]), m[0] & /*value_img*/
      4194304 && (p.value_img = /*value_img*/
      d[22]), m[0] & /*source*/
      64 && (p.source = /*source*/
      d[6]), !i && m[0] & /*brush_radius*/
      4 && (i = !0, p.brush_radius = /*brush_radius*/
      d[2], ge(() => i = !1)), !n && m[0] & /*brush_color*/
      8 && (n = !0, p.brush_color = /*brush_color*/
      d[3], ge(() => n = !1)), e.$set(p), /*tool*/
      d[1] === "color-sketch" || /*tool*/
      d[1] === "sketch" ? c ? (c.p(d, m), m[0] & /*tool*/
      2 && M(c, 1)) : (c = Pa(d), c.c(), M(c, 1), c.m(s.parentNode, s)) : c && (qe(), H(c, 1, 1, () => {
        c = null;
      }), Ve());
    },
    i(d) {
      l || (M(e.$$.fragment, d), M(a.$$.fragment, d), M(c), l = !0);
    },
    o(d) {
      H(e.$$.fragment, d), H(a.$$.fragment, d), H(c), l = !1;
    },
    d(d) {
      d && (L(r), L(o), L(s)), t[58](null), re(e, d), re(a, d), c && c.d(d);
    }
  };
}
function Pa(t) {
  let e, i, n, r;
  function a(l) {
    t[62](l);
  }
  function o(l) {
    t[63](l);
  }
  let s = {
    container_height: (
      /*container_height*/
      t[20] || /*max_height*/
      t[23]
    ),
    img_width: (
      /*img_width*/
      t[19] || /*max_width*/
      t[24]
    ),
    img_height: (
      /*img_height*/
      t[18] || /*max_height*/
      t[23]
    ),
    mode: (
      /*mode*/
      t[21]
    )
  };
  return (
    /*brush_radius*/
    t[2] !== void 0 && (s.brush_radius = /*brush_radius*/
    t[2]), /*brush_color*/
    t[3] !== void 0 && (s.brush_color = /*brush_color*/
    t[3]), e = new pr({ props: s }), K.push(() => be(e, "brush_radius", a)), K.push(() => be(e, "brush_color", o)), {
      c() {
        ne(e.$$.fragment);
      },
      m(l, h) {
        ae(e, l, h), r = !0;
      },
      p(l, h) {
        const u = {};
        h[0] & /*container_height, max_height*/
        9437184 && (u.container_height = /*container_height*/
        l[20] || /*max_height*/
        l[23]), h[0] & /*img_width, max_width*/
        17301504 && (u.img_width = /*img_width*/
        l[19] || /*max_width*/
        l[24]), h[0] & /*img_height, max_height*/
        8650752 && (u.img_height = /*img_height*/
        l[18] || /*max_height*/
        l[23]), h[0] & /*mode*/
        2097152 && (u.mode = /*mode*/
        l[21]), !i && h[0] & /*brush_radius*/
        4 && (i = !0, u.brush_radius = /*brush_radius*/
        l[2], ge(() => i = !1)), !n && h[0] & /*brush_color*/
        8 && (n = !0, u.brush_color = /*brush_color*/
        l[3], ge(() => n = !1)), e.$set(u);
      },
      i(l) {
        r || (M(e.$$.fragment, l), r = !0);
      },
      o(l) {
        H(e.$$.fragment, l), r = !1;
      },
      d(l) {
        re(e, l);
      }
    }
  );
}
function La(t) {
  let e, i;
  return e = new Wf({
    props: {
      streaming: (
        /*streaming*/
        t[8]
      ),
      pending: (
        /*pending*/
        t[9]
      ),
      mirror_webcam: (
        /*mirror_webcam*/
        t[10]
      )
    }
  }), e.$on(
    "capture",
    /*capture_handler*/
    t[52]
  ), e.$on(
    "stream",
    /*handle_save*/
    t[28]
  ), e.$on(
    "error",
    /*error_handler_1*/
    t[53]
  ), {
    c() {
      ne(e.$$.fragment);
    },
    m(n, r) {
      ae(e, n, r), i = !0;
    },
    p(n, r) {
      const a = {};
      r[0] & /*streaming*/
      256 && (a.streaming = /*streaming*/
      n[8]), r[0] & /*pending*/
      512 && (a.pending = /*pending*/
      n[9]), r[0] & /*mirror_webcam*/
      1024 && (a.mirror_webcam = /*mirror_webcam*/
      n[10]), e.$set(a);
    },
    i(n) {
      i || (M(e.$$.fragment, n), i = !0);
    },
    o(n) {
      H(e.$$.fragment, n), i = !1;
    },
    d(n) {
      re(e, n);
    }
  };
}
function Ua(t) {
  let e, i, n, r;
  function a(l) {
    t[47](l);
  }
  function o(l) {
    t[48](l);
  }
  let s = {
    container_height: (
      /*container_height*/
      t[20] || /*max_height*/
      t[23]
    ),
    img_width: (
      /*img_width*/
      t[19] || /*max_width*/
      t[24]
    ),
    img_height: (
      /*img_height*/
      t[18] || /*max_height*/
      t[23]
    )
  };
  return (
    /*brush_radius*/
    t[2] !== void 0 && (s.brush_radius = /*brush_radius*/
    t[2]), /*brush_color*/
    t[3] !== void 0 && (s.brush_color = /*brush_color*/
    t[3]), e = new pr({ props: s }), K.push(() => be(e, "brush_radius", a)), K.push(() => be(e, "brush_color", o)), {
      c() {
        ne(e.$$.fragment);
      },
      m(l, h) {
        ae(e, l, h), r = !0;
      },
      p(l, h) {
        const u = {};
        h[0] & /*container_height, max_height*/
        9437184 && (u.container_height = /*container_height*/
        l[20] || /*max_height*/
        l[23]), h[0] & /*img_width, max_width*/
        17301504 && (u.img_width = /*img_width*/
        l[19] || /*max_width*/
        l[24]), h[0] & /*img_height, max_height*/
        8650752 && (u.img_height = /*img_height*/
        l[18] || /*max_height*/
        l[23]), !i && h[0] & /*brush_radius*/
        4 && (i = !0, u.brush_radius = /*brush_radius*/
        l[2], ge(() => i = !1)), !n && h[0] & /*brush_color*/
        8 && (n = !0, u.brush_color = /*brush_color*/
        l[3], ge(() => n = !1)), e.$set(u);
      },
      i(l) {
        r || (M(e.$$.fragment, l), r = !0);
      },
      o(l) {
        H(e.$$.fragment, l), r = !1;
      },
      d(l) {
        re(e, l);
      }
    }
  );
}
function fd(t) {
  let e, i, n, r;
  return {
    c() {
      e = ot("img"), ke(e.src, i = /*value*/
      t[0].back) || P(e, "src", i), P(e, "alt", "hello"), P(e, "class", "svelte-14sn87y"), ee(
        e,
        "webcam",
        /*source*/
        t[6] === "webcam" && /*mirror_webcam*/
        t[10]
      ), ee(
        e,
        "selectable",
        /*selectable*/
        t[12]
      );
    },
    m(a, o) {
      U(a, e, o), n || (r = Rt(
        e,
        "click",
        /*handle_click*/
        t[32]
      ), n = !0);
    },
    p(a, o) {
      o[0] & /*value*/
      1 && !ke(e.src, i = /*value*/
      a[0].back) && P(e, "src", i), o[0] & /*source, mirror_webcam*/
      1088 && ee(
        e,
        "webcam",
        /*source*/
        a[6] === "webcam" && /*mirror_webcam*/
        a[10]
      ), o[0] & /*selectable*/
      4096 && ee(
        e,
        "selectable",
        /*selectable*/
        a[12]
      );
    },
    i: Ii,
    o: Ii,
    d(a) {
      a && L(e), n = !1, r();
    }
  };
}
function dd(t) {
  let e = (
    /*static_image*/
    t[25]
  ), i, n, r, a = Ga(t), o = (
    /*img_width*/
    t[19] > 0 && za(t)
  );
  return {
    c() {
      a.c(), i = ve(), o && o.c(), n = Nt();
    },
    m(s, l) {
      a.m(s, l), U(s, i, l), o && o.m(s, l), U(s, n, l), r = !0;
    },
    p(s, l) {
      l[0] & /*static_image*/
      33554432 && gr(e, e = /*static_image*/
      s[25]) ? (a.d(1), a = Ga(s), a.c(), a.m(i.parentNode, i)) : a.p(s, l), /*img_width*/
      s[19] > 0 ? o ? (o.p(s, l), l[0] & /*img_width*/
      524288 && M(o, 1)) : (o = za(s), o.c(), M(o, 1), o.m(n.parentNode, n)) : o && (qe(), H(o, 1, 1, () => {
        o = null;
      }), Ve());
    },
    i(s) {
      r || (M(o), r = !0);
    },
    o(s) {
      H(o), r = !1;
    },
    d(s) {
      s && (L(i), L(n)), a.d(s), o && o.d(s);
    }
  };
}
function md(t) {
  let e, i, n, r, a, o, s;
  return e = new ji({
    props: { i18n: (
      /*i18n*/
      t[14]
    ), editable: !0 }
  }), e.$on(
    "edit",
    /*edit_handler*/
    t[36]
  ), e.$on(
    "clear",
    /*handle_clear*/
    t[27]
  ), {
    c() {
      ne(e.$$.fragment), i = ve(), n = ot("img"), ke(n.src, r = /*value*/
      t[0].back) || P(n, "src", r), P(n, "alt", ""), P(n, "class", "svelte-14sn87y"), ee(
        n,
        "scale-x-[-1]",
        /*source*/
        t[6] === "webcam" && /*mirror_webcam*/
        t[10]
      ), ee(
        n,
        "selectable",
        /*selectable*/
        t[12]
      );
    },
    m(l, h) {
      ae(e, l, h), U(l, i, h), U(l, n, h), a = !0, o || (s = Rt(
        n,
        "click",
        /*handle_click*/
        t[32]
      ), o = !0);
    },
    p(l, h) {
      const u = {};
      h[0] & /*i18n*/
      16384 && (u.i18n = /*i18n*/
      l[14]), e.$set(u), (!a || h[0] & /*value*/
      1 && !ke(n.src, r = /*value*/
      l[0].back)) && P(n, "src", r), (!a || h[0] & /*source, mirror_webcam*/
      1088) && ee(
        n,
        "scale-x-[-1]",
        /*source*/
        l[6] === "webcam" && /*mirror_webcam*/
        l[10]
      ), (!a || h[0] & /*selectable*/
      4096) && ee(
        n,
        "selectable",
        /*selectable*/
        l[12]
      );
    },
    i(l) {
      a || (M(e.$$.fragment, l), a = !0);
    },
    o(l) {
      H(e.$$.fragment, l), a = !1;
    },
    d(l) {
      l && (L(i), L(n)), re(e, l), o = !1, s();
    }
  };
}
function _d(t) {
  let e, i, n, r, a = { image: (
    /*value*/
    t[0].back
  ) };
  return e = new lo({ props: a }), t[34](e), e.$on(
    "crop",
    /*handle_save*/
    t[28]
  ), n = new ji({ props: { i18n: (
    /*i18n*/
    t[14]
  ) } }), n.$on(
    "clear",
    /*clear_handler*/
    t[35]
  ), {
    c() {
      ne(e.$$.fragment), i = ve(), ne(n.$$.fragment);
    },
    m(o, s) {
      ae(e, o, s), U(o, i, s), ae(n, o, s), r = !0;
    },
    p(o, s) {
      const l = {};
      s[0] & /*value*/
      1 && (l.image = /*value*/
      o[0].back), e.$set(l);
      const h = {};
      s[0] & /*i18n*/
      16384 && (h.i18n = /*i18n*/
      o[14]), n.$set(h);
    },
    i(o) {
      r || (M(e.$$.fragment, o), M(n.$$.fragment, o), r = !0);
    },
    o(o) {
      H(e.$$.fragment, o), H(n.$$.fragment, o), r = !1;
    },
    d(o) {
      o && L(i), t[34](null), re(e, o), re(n, o);
    }
  };
}
function pd(t) {
  let e;
  const i = (
    /*#slots*/
    t[33].default
  ), n = K0(
    i,
    t,
    /*$$scope*/
    t[65],
    null
  );
  return {
    c() {
      n && n.c();
    },
    m(r, a) {
      n && n.m(r, a), e = !0;
    },
    p(r, a) {
      n && n.p && (!e || a[2] & /*$$scope*/
      8) && id(
        n,
        i,
        r,
        /*$$scope*/
        r[65],
        e ? ed(
          i,
          /*$$scope*/
          r[65],
          a,
          null
        ) : $0(
          /*$$scope*/
          r[65]
        ),
        null
      );
    },
    i(r) {
      e || (M(n, r), e = !0);
    },
    o(r) {
      H(n, r), e = !1;
    },
    d(r) {
      n && n.d(r);
    }
  };
}
function Ga(t) {
  let e, i, n, r;
  return {
    c() {
      e = ot("img"), P(e, "class", "absolute-img svelte-14sn87y"), ke(e.src, i = /*static_image*/
      t[25] || /*value*/
      t[0].back) || P(e, "src", i), P(e, "alt", ""), ee(
        e,
        "webcam",
        /*source*/
        t[6] === "webcam" && /*mirror_webcam*/
        t[10]
      );
    },
    m(a, o) {
      U(a, e, o), t[37](e), n || (r = Rt(
        e,
        "load",
        /*handle_image_load*/
        t[29]
      ), n = !0);
    },
    p(a, o) {
      o[0] & /*static_image, value*/
      33554433 && !ke(e.src, i = /*static_image*/
      a[25] || /*value*/
      a[0].back) && P(e, "src", i), o[0] & /*source, mirror_webcam*/
      1088 && ee(
        e,
        "webcam",
        /*source*/
        a[6] === "webcam" && /*mirror_webcam*/
        a[10]
      );
    },
    d(a) {
      a && L(e), t[37](null), n = !1, r();
    }
  };
}
function za(t) {
  var d;
  let e, i, n, r, a, o, s, l;
  function h(m) {
    t[39](m);
  }
  function u(m) {
    t[40](m);
  }
  let f = {
    value: (
      /*value*/
      (d = t[0]) == null ? void 0 : d.back
    ),
    mask_opacity: (
      /*mask_opacity*/
      t[11]
    ),
    mode: (
      /*mode*/
      t[21]
    ),
    width: (
      /*img_width*/
      t[19] || /*max_width*/
      t[24]
    ),
    height: (
      /*img_height*/
      t[18] || /*max_height*/
      t[23]
    ),
    container_height: (
      /*container_height*/
      t[20] || /*max_height*/
      t[23]
    ),
    value_img: (
      /*value_img*/
      t[22]
    ),
    source: (
      /*source*/
      t[6]
    ),
    shape: (
      /*shape*/
      t[7]
    )
  };
  /*brush_radius*/
  t[2] !== void 0 && (f.brush_radius = /*brush_radius*/
  t[2]), /*brush_color*/
  t[3] !== void 0 && (f.brush_color = /*brush_color*/
  t[3]), e = new ar({ props: f }), t[38](e), K.push(() => be(e, "brush_radius", h)), K.push(() => be(e, "brush_color", u)), e.$on(
    "change",
    /*handle_save*/
    t[28]
  ), a = new _r({
    props: { show_eraser: (
      /*value_img*/
      t[22]
    ) }
  }), a.$on(
    "undo",
    /*undo_handler*/
    t[41]
  ), a.$on(
    "clear_mask",
    /*handle_mask_clear*/
    t[31]
  ), a.$on(
    "remove_image",
    /*handle_sketch_clear*/
    t[30]
  );
  let c = (
    /*tool*/
    (t[1] === "color-sketch" || /*tool*/
    t[1] === "sketch") && Fa(t)
  );
  return {
    c() {
      ne(e.$$.fragment), r = ve(), ne(a.$$.fragment), o = ve(), c && c.c(), s = Nt();
    },
    m(m, p) {
      ae(e, m, p), U(m, r, p), ae(a, m, p), U(m, o, p), c && c.m(m, p), U(m, s, p), l = !0;
    },
    p(m, p) {
      var T;
      const v = {};
      p[0] & /*value*/
      1 && (v.value = /*value*/
      (T = m[0]) == null ? void 0 : T.back), p[0] & /*mask_opacity*/
      2048 && (v.mask_opacity = /*mask_opacity*/
      m[11]), p[0] & /*mode*/
      2097152 && (v.mode = /*mode*/
      m[21]), p[0] & /*img_width, max_width*/
      17301504 && (v.width = /*img_width*/
      m[19] || /*max_width*/
      m[24]), p[0] & /*img_height, max_height*/
      8650752 && (v.height = /*img_height*/
      m[18] || /*max_height*/
      m[23]), p[0] & /*container_height, max_height*/
      9437184 && (v.container_height = /*container_height*/
      m[20] || /*max_height*/
      m[23]), p[0] & /*value_img*/
      4194304 && (v.value_img = /*value_img*/
      m[22]), p[0] & /*source*/
      64 && (v.source = /*source*/
      m[6]), p[0] & /*shape*/
      128 && (v.shape = /*shape*/
      m[7]), !i && p[0] & /*brush_radius*/
      4 && (i = !0, v.brush_radius = /*brush_radius*/
      m[2], ge(() => i = !1)), !n && p[0] & /*brush_color*/
      8 && (n = !0, v.brush_color = /*brush_color*/
      m[3], ge(() => n = !1)), e.$set(v);
      const k = {};
      p[0] & /*value_img*/
      4194304 && (k.show_eraser = /*value_img*/
      m[22]), a.$set(k), /*tool*/
      m[1] === "color-sketch" || /*tool*/
      m[1] === "sketch" ? c ? (c.p(m, p), p[0] & /*tool*/
      2 && M(c, 1)) : (c = Fa(m), c.c(), M(c, 1), c.m(s.parentNode, s)) : c && (qe(), H(c, 1, 1, () => {
        c = null;
      }), Ve());
    },
    i(m) {
      l || (M(e.$$.fragment, m), M(a.$$.fragment, m), M(c), l = !0);
    },
    o(m) {
      H(e.$$.fragment, m), H(a.$$.fragment, m), H(c), l = !1;
    },
    d(m) {
      m && (L(r), L(o), L(s)), t[38](null), re(e, m), re(a, m), c && c.d(m);
    }
  };
}
function Fa(t) {
  let e, i, n, r;
  function a(l) {
    t[42](l);
  }
  function o(l) {
    t[43](l);
  }
  let s = {
    container_height: (
      /*container_height*/
      t[20] || /*max_height*/
      t[23]
    ),
    img_width: (
      /*img_width*/
      t[19] || /*max_width*/
      t[24]
    ),
    img_height: (
      /*img_height*/
      t[18] || /*max_height*/
      t[23]
    ),
    mode: (
      /*mode*/
      t[21]
    )
  };
  return (
    /*brush_radius*/
    t[2] !== void 0 && (s.brush_radius = /*brush_radius*/
    t[2]), /*brush_color*/
    t[3] !== void 0 && (s.brush_color = /*brush_color*/
    t[3]), e = new pr({ props: s }), K.push(() => be(e, "brush_radius", a)), K.push(() => be(e, "brush_color", o)), {
      c() {
        ne(e.$$.fragment);
      },
      m(l, h) {
        ae(e, l, h), r = !0;
      },
      p(l, h) {
        const u = {};
        h[0] & /*container_height, max_height*/
        9437184 && (u.container_height = /*container_height*/
        l[20] || /*max_height*/
        l[23]), h[0] & /*img_width, max_width*/
        17301504 && (u.img_width = /*img_width*/
        l[19] || /*max_width*/
        l[24]), h[0] & /*img_height, max_height*/
        8650752 && (u.img_height = /*img_height*/
        l[18] || /*max_height*/
        l[23]), h[0] & /*mode*/
        2097152 && (u.mode = /*mode*/
        l[21]), !i && h[0] & /*brush_radius*/
        4 && (i = !0, u.brush_radius = /*brush_radius*/
        l[2], ge(() => i = !1)), !n && h[0] & /*brush_color*/
        8 && (n = !0, u.brush_color = /*brush_color*/
        l[3], ge(() => n = !1)), e.$set(u);
      },
      i(l) {
        r || (M(e.$$.fragment, l), r = !0);
      },
      o(l) {
        H(e.$$.fragment, l), r = !1;
      },
      d(l) {
        re(e, l);
      }
    }
  );
}
function gd(t) {
  let e, i, n, r;
  const a = [
    pd,
    _d,
    md,
    dd,
    fd
  ], o = [];
  function s(l, h) {
    return (
      /*value*/
      l[0] === null && !/*static_image*/
      l[25] || /*streaming*/
      l[8] ? 0 : (
        /*tool*/
        l[1] === "select" ? 1 : (
          /*tool*/
          l[1] === "editor" ? 2 : (
            /*tool*/
            (l[1] === "sketch" || /*tool*/
            l[1] === "color-sketch") && /*value*/
            (l[0] !== null || /*static_image*/
            l[25]) ? 3 : 4
          )
        )
      )
    );
  }
  return e = s(t), i = o[e] = a[e](t), {
    c() {
      i.c(), n = Nt();
    },
    m(l, h) {
      o[e].m(l, h), U(l, n, h), r = !0;
    },
    p(l, h) {
      let u = e;
      e = s(l), e === u ? o[e].p(l, h) : (qe(), H(o[u], 1, 1, () => {
        o[u] = null;
      }), Ve(), i = o[e], i ? i.p(l, h) : (i = o[e] = a[e](l), i.c()), M(i, 1), i.m(n.parentNode, n));
    },
    i(l) {
      r || (M(i), r = !0);
    },
    o(l) {
      H(i), r = !1;
    },
    d(l) {
      l && L(n), o[e].d(l);
    }
  };
}
function bd(t) {
  let e, i, n, r, a, o, s;
  e = new os({
    props: {
      show_label: (
        /*show_label*/
        t[5]
      ),
      Icon: (
        /*source*/
        t[6] === "canvas" ? Mr : Sr
      ),
      label: (
        /*label*/
        t[4] || /*source*/
        (t[6] === "canvas" ? "Sketch" : "Image")
      )
    }
  });
  const l = [
    cd,
    ud,
    hd,
    ld,
    sd,
    od,
    ad
  ], h = [];
  function u(f, c) {
    return (
      /*source*/
      f[6] === "upload" ? 0 : (
        /*source*/
        f[6] === "canvas" ? 1 : (
          /*value*/
          f[0] === null && !/*static_image*/
          f[25] || /*streaming*/
          f[8] ? 2 : (
            /*tool*/
            f[1] === "select" ? 3 : (
              /*tool*/
              f[1] === "editor" ? 4 : (
                /*tool*/
                (f[1] === "sketch" || /*tool*/
                f[1] === "color-sketch") && /*value*/
                (f[0] !== null || /*static_image*/
                f[25]) ? 5 : 6
              )
            )
          )
        )
      )
    );
  }
  return r = u(t), a = h[r] = l[r](t), {
    c() {
      ne(e.$$.fragment), i = ve(), n = ot("div"), a.c(), P(n, "data-testid", "image"), P(n, "class", "image-container svelte-14sn87y"), J0(() => (
        /*div_elementresize_handler*/
        t[64].call(n)
      ));
    },
    m(f, c) {
      ae(e, f, c), U(f, i, c), U(f, n, c), h[r].m(n, null), o = Q0(
        n,
        /*div_elementresize_handler*/
        t[64].bind(n)
      ), s = !0;
    },
    p(f, c) {
      const d = {};
      c[0] & /*show_label*/
      32 && (d.show_label = /*show_label*/
      f[5]), c[0] & /*source*/
      64 && (d.Icon = /*source*/
      f[6] === "canvas" ? Mr : Sr), c[0] & /*label, source*/
      80 && (d.label = /*label*/
      f[4] || /*source*/
      (f[6] === "canvas" ? "Sketch" : "Image")), e.$set(d);
      let m = r;
      r = u(f), r === m ? h[r].p(f, c) : (qe(), H(h[m], 1, 1, () => {
        h[m] = null;
      }), Ve(), a = h[r], a ? a.p(f, c) : (a = h[r] = l[r](f), a.c()), M(a, 1), a.m(n, null));
    },
    i(f) {
      s || (M(e.$$.fragment, f), M(a), s = !0);
    },
    o(f) {
      H(e.$$.fragment, f), H(a), s = !1;
    },
    d(f) {
      f && (L(i), L(n)), re(e, f), h[r].d(), o();
    }
  };
}
function vd(t) {
  let e, i = t[0], n = 1;
  for (; n < t.length; ) {
    const r = t[n], a = t[n + 1];
    if (n += 2, (r === "optionalAccess" || r === "optionalCall") && i == null)
      return;
    r === "access" || r === "optionalAccess" ? (e = i, i = a(i)) : (r === "call" || r === "optionalCall") && (i = a((...o) => i.call(e, ...o)), e = void 0);
  }
  return i;
}
function wd(t, e, i) {
  let { $$slots: n = {}, $$scope: r } = e, { value: a } = e, { label: o = void 0 } = e, { show_label: s } = e, { source: l = "upload" } = e, { tool: h = "editor" } = e, { shape: u } = e, { streaming: f = !1 } = e, { pending: c = !1 } = e, { mirror_webcam: d } = e, { brush_radius: m } = e, { brush_color: p = "#000000" } = e, { mask_opacity: v } = e, { selectable: k = !1 } = e, { root: T } = e, { i18n: S } = e, I, w;
  function _({ detail: b }) {
    h === "color-sketch" ? i(25, Te = b) : i(0, a = { back: b, mask: null }), G("upload", b);
  }
  function E({ detail: b }) {
    i(0, a = null), i(25, Te = void 0), G("clear");
  }
  async function O({ detail: b }, Oe) {
    q === "mask" && !(l === "webcam" && Oe) ? i(0, a = {
      back: vd([a, "optionalAccess", (fi) => fi.back]) || null,
      mask: b
    }) : i(0, a = { back: b, mask: null }), await wi(), G(f ? "stream" : "edit");
  }
  const G = nd();
  let Z = !1;
  function oe(b) {
    const Oe = b.currentTarget;
    i(19, F = Oe.naturalWidth), i(18, D = Oe.naturalHeight), i(20, Q = Oe.getBoundingClientRect().height);
  }
  async function se() {
    I.clear(), await wi(), i(0, a = null), i(25, Te = void 0);
  }
  async function y() {
    I.clear_mask(), await wi();
  }
  let D = 0, F = 0, Q = 0, q, Y, ue, Le, Te;
  rd(async () => {
    h === "color-sketch" && a && (i(25, Te = a.back), await wi(), oe({ currentTarget: Y }));
  });
  function Ue(b) {
    let Oe = _0(b);
    Oe && G("select", { index: Oe, value: null });
  }
  function st(b) {
    K[b ? "unshift" : "push"](() => {
      w = b, i(15, w), i(0, a);
    });
  }
  const lt = (b) => (E(b), i(1, h = "editor")), xt = () => i(1, h = "select");
  function ei(b) {
    K[b ? "unshift" : "push"](() => {
      Y = b, i(22, Y);
    });
  }
  function ti(b) {
    K[b ? "unshift" : "push"](() => {
      I = b, i(17, I);
    });
  }
  function ii(b) {
    m = b, i(2, m);
  }
  function ni(b) {
    p = b, i(3, p);
  }
  const ri = () => I.undo();
  function ht(b) {
    m = b, i(2, m);
  }
  function ai(b) {
    p = b, i(3, p);
  }
  function oi(b) {
    Z = b, i(16, Z);
  }
  function si(b) {
    Na.call(this, t, b);
  }
  const li = () => I.undo();
  function hi(b) {
    m = b, i(2, m);
  }
  function Re(b) {
    p = b, i(3, p);
  }
  function Ye(b) {
    m = b, i(2, m);
  }
  function ui(b) {
    p = b, i(3, p);
  }
  function Pt(b) {
    K[b ? "unshift" : "push"](() => {
      I = b, i(17, I);
    });
  }
  const Xi = (b) => h === "color-sketch" ? _(b) : O(b, !0);
  function ci(b) {
    Na.call(this, t, b);
  }
  function Wi(b) {
    K[b ? "unshift" : "push"](() => {
      w = b, i(15, w), i(0, a);
    });
  }
  const Vi = (b) => (E(b), i(1, h = "editor")), qi = () => i(1, h = "select");
  function Yi(b) {
    K[b ? "unshift" : "push"](() => {
      Y = b, i(22, Y);
    });
  }
  function g(b) {
    K[b ? "unshift" : "push"](() => {
      I = b, i(17, I);
    });
  }
  function C(b) {
    m = b, i(2, m);
  }
  function R(b) {
    p = b, i(3, p);
  }
  const te = () => I.undo();
  function j(b) {
    m = b, i(2, m);
  }
  function ce(b) {
    p = b, i(3, p);
  }
  function ut() {
    ue = this.offsetHeight, Le = this.offsetWidth, i(23, ue), i(24, Le);
  }
  return t.$$set = (b) => {
    "value" in b && i(0, a = b.value), "label" in b && i(4, o = b.label), "show_label" in b && i(5, s = b.show_label), "source" in b && i(6, l = b.source), "tool" in b && i(1, h = b.tool), "shape" in b && i(7, u = b.shape), "streaming" in b && i(8, f = b.streaming), "pending" in b && i(9, c = b.pending), "mirror_webcam" in b && i(10, d = b.mirror_webcam), "brush_radius" in b && i(2, m = b.brush_radius), "brush_color" in b && i(3, p = b.brush_color), "mask_opacity" in b && i(11, v = b.mask_opacity), "selectable" in b && i(12, k = b.selectable), "root" in b && i(13, T = b.root), "i18n" in b && i(14, S = b.i18n), "$$scope" in b && i(65, r = b.$$scope);
  }, t.$$.update = () => {
    t.$$.dirty[0] & /*dragging*/
    65536 && G("drag", Z), t.$$.dirty[0] & /*source, tool*/
    66 && (l === "canvas" && h === "sketch" ? i(21, q = "bw-sketch") : h === "color-sketch" ? i(21, q = "color-sketch") : (l === "upload" || l === "webcam") && h === "sketch" ? i(21, q = "mask") : i(21, q = "editor")), t.$$.dirty[0] & /*value*/
    1 && (a === null || a.back === null && a.mask === null) && i(25, Te = void 0), t.$$.dirty[0] & /*cropper, value*/
    32769 && w && (a ? (i(15, w.image = a.back, w), w.create()) : w.destroy());
  }, [
    a,
    h,
    m,
    p,
    o,
    s,
    l,
    u,
    f,
    c,
    d,
    v,
    k,
    T,
    S,
    w,
    Z,
    I,
    D,
    F,
    Q,
    q,
    Y,
    ue,
    Le,
    Te,
    _,
    E,
    O,
    oe,
    se,
    y,
    Ue,
    n,
    st,
    lt,
    xt,
    ei,
    ti,
    ii,
    ni,
    ri,
    ht,
    ai,
    oi,
    si,
    li,
    hi,
    Re,
    Ye,
    ui,
    Pt,
    Xi,
    ci,
    Wi,
    Vi,
    qi,
    Yi,
    g,
    C,
    R,
    te,
    j,
    ce,
    ut,
    r
  ];
}
class yd extends Z0 {
  constructor(e) {
    super(), td(
      this,
      e,
      wd,
      bd,
      gr,
      {
        value: 0,
        label: 4,
        show_label: 5,
        source: 6,
        tool: 1,
        shape: 7,
        streaming: 8,
        pending: 9,
        mirror_webcam: 10,
        brush_radius: 2,
        brush_color: 3,
        mask_opacity: 11,
        selectable: 12,
        root: 13,
        i18n: 14
      },
      null,
      [-1, -1, -1]
    );
  }
}
const {
  SvelteComponent: Ed,
  attr: kd,
  create_component: Td,
  destroy_component: Sd,
  detach: Cd,
  element: Md,
  init: Ad,
  insert: Od,
  mount_component: Dd,
  safe_not_equal: Bd,
  toggle_class: pt,
  transition_in: Hd,
  transition_out: Id
} = window.__gradio__svelte__internal;
function Nd(t) {
  let e, i, n;
  return i = new yd({
    props: {
      src: (
        /*samples_dir*/
        t[1] + /*value*/
        t[0]
      ),
      alt: ""
    }
  }), {
    c() {
      e = Md("div"), Td(i.$$.fragment), kd(e, "class", "container svelte-1iqucjz"), pt(
        e,
        "table",
        /*type*/
        t[2] === "table"
      ), pt(
        e,
        "gallery",
        /*type*/
        t[2] === "gallery"
      ), pt(
        e,
        "selected",
        /*selected*/
        t[3]
      );
    },
    m(r, a) {
      Od(r, e, a), Dd(i, e, null), n = !0;
    },
    p(r, [a]) {
      const o = {};
      a & /*samples_dir, value*/
      3 && (o.src = /*samples_dir*/
      r[1] + /*value*/
      r[0]), i.$set(o), (!n || a & /*type*/
      4) && pt(
        e,
        "table",
        /*type*/
        r[2] === "table"
      ), (!n || a & /*type*/
      4) && pt(
        e,
        "gallery",
        /*type*/
        r[2] === "gallery"
      ), (!n || a & /*selected*/
      8) && pt(
        e,
        "selected",
        /*selected*/
        r[3]
      );
    },
    i(r) {
      n || (Hd(i.$$.fragment, r), n = !0);
    },
    o(r) {
      Id(i.$$.fragment, r), n = !1;
    },
    d(r) {
      r && Cd(e), Sd(i);
    }
  };
}
function Rd(t, e, i) {
  let { value: n } = e, { samples_dir: r } = e, { type: a } = e, { selected: o = !1 } = e;
  return t.$$set = (s) => {
    "value" in s && i(0, n = s.value), "samples_dir" in s && i(1, r = s.samples_dir), "type" in s && i(2, a = s.type), "selected" in s && i(3, o = s.selected);
  }, [n, r, a, o];
}
class Ld extends Ed {
  constructor(e) {
    super(), Ad(this, e, Rd, Nd, Bd, {
      value: 0,
      samples_dir: 1,
      type: 2,
      selected: 3
    });
  }
}
export {
  Ld as default
};
