import { r as ne, j as c, a as nt, u as de, b as Re, s as $e, g as ot, c as De, f as ke, d as se, e as rt, h as Le, i as ze, k as Fe, O as Be, B as Me, l as Ie, m as Oe, n as Ae, F as st, o as it, p as at, q as lt, t as ct, v as ut, w as dt, x as mt, y as ft, z as pt, A as gt, C as ht, D as yt, T as vt, E as bt, G as ie, H as xt, I as wt, $ as Nt, K as he, J as jt, L as Ct, M as Et, N as J, P as Tt, Q as me, R as Pt, S as Q, U as _e, V as St, W as ye, X as Rt, Y as $t, Z as Dt, _ as He, a0 as kt, a1 as Lt, a2 as oe, a3 as re, a4 as ve, a5 as zt, a6 as Z, a7 as Ft, a8 as Bt, a9 as Mt, aa as It, ab as Ot, ac as At, ad as _t, ae as Ht, af as Gt, ag as Wt, ah as Ut, ai as Kt, aj as Xt, ak as Yt, al as Vt, am as Zt, an as qt } from "./index-UNZzl66r.js";
import * as _ from "react";
import { createContext as Ge, useContext as fe, forwardRef as We, useState as A, useEffect as K, useRef as H, useCallback as U, cloneElement as Ue, useMemo as Jt, Suspense as Qt } from "react";
import { l as en } from "./LexicalCollaborationContext.prod-CKLiaJe8.js";
import { _ as tn, c as nn } from "./collaboration-DFhHmKeg.js";
import { p as on } from "./LexicalNestedComposer.prod-CFblEVlp.js";
function Ke(e, t) {
  return Array.isArray(e) ? [...e].reduce(
    (n, o) => ({ ...n, ...Ke(o, t) }),
    {}
  ) : typeof e == "function" ? e(t) : e ?? {};
}
const rn = Ge({
  dir: "ltr",
  toggleDirection: () => {
  },
  setDirection: () => {
  }
});
function Xe() {
  return fe(rn);
}
function sn(e, t) {
  if (e === "rtl" && (t.includes("right") || t.includes("left"))) {
    const [n, o] = t.split("-"), i = n === "right" ? "left" : "right";
    return o === void 0 ? i : `${i}-${o}`;
  }
  return t;
}
function be(e, t, n, o) {
  return e === "center" || o === "center" ? { top: t } : e === "end" ? { bottom: n } : e === "start" ? { top: n } : {};
}
function xe(e, t, n, o, i) {
  return e === "center" || o === "center" ? { left: t } : e === "end" ? { [i === "ltr" ? "right" : "left"]: n } : e === "start" ? { [i === "ltr" ? "left" : "right"]: n } : {};
}
const an = {
  bottom: "borderTopLeftRadius",
  left: "borderTopRightRadius",
  right: "borderBottomLeftRadius",
  top: "borderBottomRightRadius"
};
function ln({
  position: e,
  arrowSize: t,
  arrowOffset: n,
  arrowRadius: o,
  arrowPosition: i,
  arrowX: m,
  arrowY: r,
  dir: f
}) {
  const [b, g = "center"] = e.split("-"), a = {
    width: ne(t),
    height: ne(t),
    transform: "rotate(45deg)",
    position: "absolute",
    [an[b]]: ne(o)
  }, l = ne(-t / 2);
  return b === "left" ? {
    ...a,
    ...be(g, r, n, i),
    right: l,
    borderLeftColor: "transparent",
    borderBottomColor: "transparent"
  } : b === "right" ? {
    ...a,
    ...be(g, r, n, i),
    left: l,
    borderRightColor: "transparent",
    borderTopColor: "transparent"
  } : b === "top" ? {
    ...a,
    ...xe(g, m, n, i, f),
    bottom: l,
    borderTopColor: "transparent",
    borderLeftColor: "transparent"
  } : b === "bottom" ? {
    ...a,
    ...xe(g, m, n, i, f),
    top: l,
    borderBottomColor: "transparent",
    borderRightColor: "transparent"
  } : {};
}
const Ye = We(
  ({
    position: e,
    arrowSize: t,
    arrowOffset: n,
    arrowRadius: o,
    arrowPosition: i,
    visible: m,
    arrowX: r,
    arrowY: f,
    style: b,
    ...g
  }, a) => {
    const { dir: l } = Xe();
    return m ? /* @__PURE__ */ c.jsx(
      "div",
      {
        ...g,
        ref: a,
        style: {
          ...b,
          ...ln({
            position: e,
            arrowSize: t,
            arrowOffset: n,
            arrowRadius: o,
            arrowPosition: i,
            dir: l,
            arrowX: r,
            arrowY: f
          })
        }
      }
    ) : null;
  }
);
Ye.displayName = "@mantine/core/FloatingArrow";
function cn({
  opened: e,
  floating: t,
  position: n,
  positionDependencies: o
}) {
  const [i, m] = A(0);
  K(() => {
    if (t.refs.reference.current && t.refs.floating.current)
      return nt(
        t.refs.reference.current,
        t.refs.floating.current,
        t.update
      );
  }, [
    t.refs.reference.current,
    t.refs.floating.current,
    e,
    i,
    n
  ]), de(() => {
    t.update();
  }, o), de(() => {
    m((r) => r + 1);
  }, [e]);
}
const un = {
  duration: 100,
  transition: "fade"
};
function dn(e, t) {
  return { ...un, ...t, ...e };
}
function mn({
  offset: e,
  position: t
}) {
  const [n, o] = A(!1), i = H(), { x: m, y: r, elements: f, refs: b, update: g, placement: a } = Re({
    placement: t,
    middleware: [
      $e({
        crossAxis: !0,
        padding: 5,
        rootBoundary: "document"
      })
    ]
  }), l = a.includes("right") ? e : t.includes("left") ? e * -1 : 0, T = a.includes("bottom") ? e : t.includes("top") ? e * -1 : 0, x = U(
    ({ clientX: w, clientY: P }) => {
      b.setPositionReference({
        getBoundingClientRect() {
          return {
            width: 0,
            height: 0,
            x: w,
            y: P,
            left: w + l,
            top: P + T,
            right: w,
            bottom: P
          };
        }
      });
    },
    [f.reference]
  );
  return K(() => {
    if (b.floating.current) {
      const w = i.current;
      w.addEventListener("mousemove", x);
      const P = ot(b.floating.current);
      return P.forEach((v) => {
        v.addEventListener("scroll", g);
      }), () => {
        w.removeEventListener("mousemove", x), P.forEach((v) => {
          v.removeEventListener("scroll", g);
        });
      };
    }
  }, [f.reference, b.floating.current, g, x, n]), { handleMouseMove: x, x: m, y: r, opened: n, setOpened: o, boundaryRef: i, floating: b.setFloating };
}
var ae = { tooltip: "m_1b3c8819", arrow: "m_f898399f" };
const fn = {
  refProp: "ref",
  withinPortal: !0,
  offset: 10,
  position: "right",
  zIndex: De("popover")
}, pn = Ie((e, { radius: t, color: n }) => ({
  tooltip: {
    "--tooltip-radius": t === void 0 ? void 0 : Oe(t),
    "--tooltip-bg": n ? Ae(n, e) : void 0,
    "--tooltip-color": n ? "var(--mantine-color-white)" : void 0
  }
})), pe = ke((e, t) => {
  const n = se("TooltipFloating", fn, e), {
    children: o,
    refProp: i,
    withinPortal: m,
    style: r,
    className: f,
    classNames: b,
    styles: g,
    unstyled: a,
    radius: l,
    color: T,
    label: x,
    offset: w,
    position: P,
    multiline: v,
    zIndex: R,
    disabled: k,
    variant: s,
    vars: E,
    portalProps: B,
    ...u
  } = n, h = rt(), d = Le({
    name: "TooltipFloating",
    props: n,
    classes: ae,
    className: f,
    style: r,
    classNames: b,
    styles: g,
    unstyled: a,
    rootSelector: "tooltip",
    vars: E,
    varsResolver: pn
  }), { handleMouseMove: N, x: D, y: j, opened: C, boundaryRef: I, floating: O, setOpened: F } = mn({
    offset: w,
    position: P
  });
  if (!ze(o))
    throw new Error(
      "[@mantine/core] Tooltip.Floating component children should be an element or a component that accepts ref, fragments, strings, numbers and other primitive values are not supported"
    );
  const z = Fe(I, o.ref, t), L = (y) => {
    var p, S;
    (S = (p = o.props).onMouseEnter) == null || S.call(p, y), N(y), F(!0);
  }, G = (y) => {
    var p, S;
    (S = (p = o.props).onMouseLeave) == null || S.call(p, y), F(!1);
  };
  return /* @__PURE__ */ c.jsxs(c.Fragment, { children: [
    /* @__PURE__ */ c.jsx(Be, { ...B, withinPortal: m, children: /* @__PURE__ */ c.jsx(
      Me,
      {
        ...u,
        ...d("tooltip", {
          style: {
            ...Ke(r, h),
            zIndex: R,
            display: !k && C ? "block" : "none",
            top: (j && Math.round(j)) ?? "",
            left: (D && Math.round(D)) ?? ""
          }
        }),
        variant: s,
        ref: O,
        mod: { multiline: v },
        children: x
      }
    ) }),
    Ue(o, {
      ...o.props,
      [i]: z,
      onMouseEnter: L,
      onMouseLeave: G
    })
  ] });
});
pe.classes = ae;
pe.displayName = "@mantine/core/TooltipFloating";
const Ve = Ge(!1), gn = Ve.Provider, hn = () => fe(Ve), yn = {
  openDelay: 0,
  closeDelay: 0
};
function Ze(e) {
  const { openDelay: t, closeDelay: n, children: o } = se("TooltipGroup", yn, e);
  return /* @__PURE__ */ c.jsx(gn, { value: !0, children: /* @__PURE__ */ c.jsx(st, { delay: { open: t, close: n }, children: o }) });
}
Ze.displayName = "@mantine/core/TooltipGroup";
function vn(e) {
  var u, h, d;
  const [t, n] = A(!1), i = typeof e.opened == "boolean" ? e.opened : t, m = hn(), r = it(), { delay: f, currentId: b, setCurrentId: g } = at(), a = U(
    (N) => {
      n(N), N && g(r);
    },
    [g, r]
  ), {
    x: l,
    y: T,
    context: x,
    refs: w,
    update: P,
    placement: v,
    middlewareData: { arrow: { x: R, y: k } = {} }
  } = Re({
    strategy: e.strategy,
    placement: e.position,
    open: i,
    onOpenChange: a,
    middleware: [
      lt(e.offset),
      $e({ padding: 8 }),
      ct(),
      ut({ element: e.arrowRef, padding: e.arrowOffset }),
      ...e.inline ? [dt()] : []
    ]
  }), { getReferenceProps: s, getFloatingProps: E } = mt([
    ft(x, {
      enabled: (u = e.events) == null ? void 0 : u.hover,
      delay: m ? f : { open: e.openDelay, close: e.closeDelay },
      mouseOnly: !((h = e.events) != null && h.touch)
    }),
    pt(x, { enabled: (d = e.events) == null ? void 0 : d.focus, visibleOnly: !0 }),
    gt(x, { role: "tooltip" }),
    // cannot be used with controlled tooltip, page jumps
    ht(x, { enabled: typeof e.opened > "u" }),
    yt(x, { id: r })
  ]);
  cn({
    opened: i,
    position: e.position,
    positionDependencies: e.positionDependencies,
    floating: { refs: w, update: P }
  }), de(() => {
    var N;
    (N = e.onPositionChange) == null || N.call(e, v);
  }, [v]);
  const B = i && b && b !== r;
  return {
    x: l,
    y: T,
    arrowX: R,
    arrowY: k,
    reference: w.setReference,
    floating: w.setFloating,
    getFloatingProps: E,
    getReferenceProps: s,
    isGroupPhase: B,
    opened: i,
    placement: v
  };
}
const we = {
  position: "top",
  refProp: "ref",
  withinPortal: !0,
  inline: !1,
  arrowSize: 4,
  arrowOffset: 5,
  arrowRadius: 0,
  arrowPosition: "side",
  offset: 5,
  transitionProps: { duration: 100, transition: "fade" },
  events: { hover: !0, focus: !1, touch: !1 },
  zIndex: De("popover"),
  positionDependencies: []
}, bn = Ie((e, { radius: t, color: n }) => ({
  tooltip: {
    "--tooltip-radius": t === void 0 ? void 0 : Oe(t),
    "--tooltip-bg": n ? Ae(n, e) : void 0,
    "--tooltip-color": n ? "var(--mantine-color-white)" : void 0
  }
})), ee = ke((e, t) => {
  const n = se("Tooltip", we, e), {
    children: o,
    position: i,
    refProp: m,
    label: r,
    openDelay: f,
    closeDelay: b,
    onPositionChange: g,
    opened: a,
    withinPortal: l,
    radius: T,
    color: x,
    classNames: w,
    styles: P,
    unstyled: v,
    style: R,
    className: k,
    withArrow: s,
    arrowSize: E,
    arrowOffset: B,
    arrowRadius: u,
    arrowPosition: h,
    offset: d,
    transitionProps: N,
    multiline: D,
    events: j,
    zIndex: C,
    disabled: I,
    positionDependencies: O,
    onClick: F,
    onMouseEnter: z,
    onMouseLeave: L,
    inline: G,
    variant: y,
    keepMounted: p,
    vars: S,
    portalProps: Y,
    mod: X,
    floatingStrategy: q,
    ...te
  } = se("Tooltip", we, n), { dir: le } = Xe(), V = H(null), M = vn({
    position: sn(le, i),
    closeDelay: b,
    openDelay: f,
    onPositionChange: g,
    opened: a,
    events: j,
    arrowRef: V,
    arrowOffset: B,
    offset: typeof d == "number" ? d + (s ? E / 2 : 0) : d,
    positionDependencies: [...O, o],
    inline: G,
    strategy: q
  }), ce = Le({
    name: "Tooltip",
    props: n,
    classes: ae,
    className: k,
    style: R,
    classNames: w,
    styles: P,
    unstyled: v,
    rootSelector: "tooltip",
    vars: S,
    varsResolver: bn
  });
  if (!ze(o))
    throw new Error(
      "[@mantine/core] Tooltip component children should be an element or a component that accepts ref, fragments, strings, numbers and other primitive values are not supported"
    );
  const et = Fe(M.reference, o.ref, t), ge = dn(N, { duration: 100, transition: "fade" });
  return /* @__PURE__ */ c.jsxs(c.Fragment, { children: [
    /* @__PURE__ */ c.jsx(Be, { ...Y, withinPortal: l, children: /* @__PURE__ */ c.jsx(
      vt,
      {
        ...ge,
        keepMounted: p,
        mounted: !I && !!M.opened,
        duration: M.isGroupPhase ? 10 : ge.duration,
        children: (tt) => /* @__PURE__ */ c.jsxs(
          Me,
          {
            ...te,
            variant: y,
            mod: [{ multiline: D }, X],
            ...M.getFloatingProps({
              ref: M.floating,
              className: ce("tooltip").className,
              style: {
                ...ce("tooltip").style,
                ...tt,
                zIndex: C,
                top: M.y ?? 0,
                left: M.x ?? 0
              }
            }),
            children: [
              r,
              /* @__PURE__ */ c.jsx(
                Ye,
                {
                  ref: V,
                  arrowX: M.arrowX,
                  arrowY: M.arrowY,
                  visible: s,
                  position: M.placement,
                  arrowSize: E,
                  arrowOffset: B,
                  arrowRadius: u,
                  arrowPosition: h,
                  ...ce("arrow")
                }
              )
            ]
          }
        )
      }
    ) }),
    Ue(
      o,
      M.getReferenceProps({
        onClick: F,
        onMouseEnter: z,
        onMouseLeave: L,
        onMouseMove: n.onMouseMove,
        onPointerDown: n.onPointerDown,
        onPointerEnter: n.onPointerEnter,
        [m]: et,
        className: bt(k, o.props.className),
        ...o.props
      })
    )
  ] });
});
ee.classes = ae;
ee.displayName = "@mantine/core/Tooltip";
ee.Floating = pe;
ee.Group = Ze;
const Ne = /* @__PURE__ */ new Map([
  [":)", ["emoji happysmile", "🙂"]],
  [":D", ["emoji veryhappysmile", "😀"]],
  [":(", ["emoji unhappysmile", "🙁"]],
  ["<3", ["emoji heart", "❤"]],
  ["🙂", ["emoji happysmile", "🙂"]],
  ["😀", ["emoji veryhappysmile", "😀"]],
  ["🙁", ["emoji unhappysmile", "🙁"]],
  ["❤", ["emoji heart", "❤"]]
]);
function xn(e) {
  const t = e.getTextContent();
  for (let n = 0; n < t.length; n++) {
    const o = Ne.get(t[n]) || Ne.get(t.slice(n, n + 2));
    if (o !== void 0) {
      const [i, m] = o;
      let r;
      n === 0 ? [r] = e.splitText(n + 2) : [, r] = e.splitText(n, n + 2);
      const f = Nt(i, m);
      return r.replace(f), f;
    }
  }
  return null;
}
function wn(e) {
  let t = e;
  for (; t !== null; ) {
    if (!t.isSimpleText())
      return;
    t = xn(t);
  }
}
function Nn(e) {
  K(() => {
    if (!e.hasNodes([xt]))
      throw new Error("EmojisPlugin: EmojiNode not registered on editor");
    return e.registerNodeTransform(wt, wn);
  }, [e]);
}
function jn() {
  const [e] = ie();
  return Nn(e), null;
}
const Cn = /(^|$|[^A-Za-zªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠࢢ-ࢬऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎↃↄⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々〆〱-〵〻〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛥꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꪀ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ﬀ-ﬆﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼＡ-Ｚａ-ｚｦ-ﾾￂ-ￇￊ-ￏￒ-ￗￚ-ￜ])(congrats|congratulations|gratuluju|gratuluji|gratulujeme|blahopřeju|blahopřeji|blahopřejeme|Til lykke|Tillykke|Glückwunsch|Gratuliere|felicitaciones|enhorabuena|paljon onnea|onnittelut|Félicitations|gratula|gratulálok|gratulálunk|congratulazioni|complimenti|おめでとう|おめでとうございます|축하해|축하해요|gratulerer|Gefeliciteerd|gratulacje|Parabéns|parabéns|felicitações|felicitări|мои поздравления|поздравляем|поздравляю|gratulujem|blahoželám|ยินดีด้วย|ขอแสดงความยินดี|tebrikler|tebrik ederim|恭喜|祝贺你|恭喜你|恭喜|恭喜|baie geluk|veels geluk|অভিনন্দন|Čestitam|Čestitke|Čestitamo|Συγχαρητήρια|Μπράβο|અભિનંદન|badhai|बधाई|अभिनंदन|Честитам|Свака част|hongera|வாழ்த்துகள்|வாழ்த்துக்கள்|అభినందనలు|അഭിനന്ദനങ്ങൾ|Chúc mừng|מזל טוב|mazel tov|mazal tov)(^|$|[^A-Za-zªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠࢢ-ࢬऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎↃↄⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々〆〱-〵〻〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛥꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꪀ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ﬀ-ﬆﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼＡ-Ｚａ-ｚｦ-ﾾￂ-ￇￊ-ￏￒ-ￗￚ-ￜ])/i;
function En() {
  const [e] = ie();
  K(() => {
    if (!e.hasNodes([he]))
      throw new Error("KeywordsPlugin: KeywordNode not registered on editor");
  }, [e]);
  const t = U((o) => jt(o.getTextContent()), []), n = U((o) => {
    const i = Cn.exec(o);
    if (i === null)
      return null;
    const m = i[2].length, r = i.index + i[1].length;
    return {
      end: r + m,
      start: r
    };
  }, []);
  return Ct(n, he, t), null;
}
const qe = Object.freeze({ "	": "\\t", "\n": "\\n" }), je = new RegExp(Object.keys(qe).join("|"), "g"), W = Object.freeze({ ancestorHasNextSibling: "|", ancestorIsLastChild: " ", hasNextSibling: "├", isLastChild: "└", selectedChar: "^", selectedLine: ">" }), Tn = [(e) => e.hasFormat("bold") && "Bold", (e) => e.hasFormat("code") && "Code", (e) => e.hasFormat("italic") && "Italic", (e) => e.hasFormat("strikethrough") && "Strikethrough", (e) => e.hasFormat("subscript") && "Subscript", (e) => e.hasFormat("superscript") && "Superscript", (e) => e.hasFormat("underline") && "Underline"], Pn = [(e) => e.hasTextFormat("bold") && "Bold", (e) => e.hasTextFormat("code") && "Code", (e) => e.hasTextFormat("italic") && "Italic", (e) => e.hasTextFormat("strikethrough") && "Strikethrough", (e) => e.hasTextFormat("subscript") && "Subscript", (e) => e.hasTextFormat("superscript") && "Superscript", (e) => e.hasTextFormat("underline") && "Underline"], Sn = [(e) => e.isDirectionless() && "Directionless", (e) => e.isUnmergeable() && "Unmergeable"], Rn = [(e) => e.isToken() && "Token", (e) => e.isSegmented() && "Segmented"];
function $n(e, t, n) {
  const o = e.getEditorState(), i = e._config, m = e._compositionKey, r = e._editable;
  if (n) {
    let g = "";
    return o.read(() => {
      g = function(a) {
        const l = document.createElement("div");
        return l.innerHTML = a.trim(), Qe(l, 0).innerHTML;
      }(Et(e));
    }), g;
  }
  let f = ` root
`;
  const b = o.read(() => {
    const g = J();
    return Je(Tt(), (a, l) => {
      const T = `(${a.getKey()})`, x = a.getType() || "", w = a.isSelected(), P = St(a) ? ` id: [ ${a.getIDs().join(", ")} ] ` : "";
      f += `${w ? W.selectedLine : " "} ${l.join(" ")} ${T} ${x} ${P} ${function(v) {
        if (ye(v)) {
          const R = v.getTextContent(), k = R.length === 0 ? "(empty)" : `"${Ce(R)}"`, s = function(E) {
            return [Ee(E), Dn(E), kn(E)].filter(Boolean).join(", ");
          }(v);
          return [k, s.length !== 0 ? `{ ${s} }` : null].filter(Boolean).join(" ").trim();
        }
        if (Rt(v)) {
          const R = v.getURL(), k = R.length === 0 ? "(empty)" : `"${Ce(R)}"`, s = function(E) {
            return [Ln(E), zn(E), Fn(E)].filter(Boolean).join(", ");
          }(v);
          return [k, s.length !== 0 ? `{ ${s} }` : null].filter(Boolean).join(" ").trim();
        }
        if ($t(v)) {
          const R = function(k) {
            let s = Pn.map((E) => E(k)).filter(Boolean).join(", ").toLocaleLowerCase();
            return s !== "" && (s = "format: " + s), s;
          }(v);
          return R !== "" ? `{ ${R} }` : "";
        }
        return "";
      }(a)}
`, f += function({ indent: v, isSelected: R, node: k, nodeKeyDisplay: s, selection: E, typeDisplay: B }) {
        if (!ye(k) || !me(E) || !R || _e(k))
          return "";
        const u = E.anchor, h = E.focus;
        if (k.getTextContent() === "" || u.getNode() === E.focus.getNode() && u.offset === h.offset)
          return "";
        const [d, N] = function(z, L) {
          const G = L.getStartEndPoints();
          if (Q(L) || G === null)
            return [-1, -1];
          const [y, p] = G, S = z.getTextContent(), Y = S.length;
          let X = -1, q = -1;
          if (y.type === "text" && p.type === "text") {
            const V = y.getNode(), M = p.getNode();
            V === M && z === V && y.offset !== p.offset ? [X, q] = y.offset < p.offset ? [y.offset, p.offset] : [p.offset, y.offset] : [X, q] = z === V ? V.isBefore(M) ? [y.offset, Y] : [0, y.offset] : z === M ? M.isBefore(V) ? [p.offset, Y] : [0, p.offset] : [0, Y];
          }
          const te = (S.slice(0, X).match(je) || []).length, le = (S.slice(X, q).match(je) || []).length;
          return [X + te, q + te + le];
        }(k, E);
        if (d === N)
          return "";
        const D = v[v.length - 1] === W.hasNextSibling ? W.ancestorHasNextSibling : W.ancestorIsLastChild, j = [...v.slice(0, v.length - 1), D], C = Array(d + 1).fill(" "), I = Array(N - d).fill(W.selectedChar), O = B.length + 3, F = Array(s.length + O).fill(" ");
        return [W.selectedLine, j.join(" "), [...F, ...C, ...I].join("")].join(" ") + `
`;
      }({ indent: l, isSelected: w, node: a, nodeKeyDisplay: T, selection: g, typeDisplay: x });
    }), g === null ? ": null" : me(g) ? function(a) {
      let l = "";
      const T = Ee(a);
      l += `: range ${T !== "" ? `{ ${T} }` : ""} ${a.style !== "" ? `{ style: ${a.style} } ` : ""}`;
      const x = a.anchor, w = a.focus, P = x.offset, v = w.offset;
      return l += `
  ├ anchor { key: ${x.key}, offset: ${P === null ? "null" : P}, type: ${x.type} }`, l += `
  └ focus { key: ${w.key}, offset: ${v === null ? "null" : v}, type: ${w.type} }`, l;
    }(g) : Pt(g) ? function(a) {
      return `: table
  └ { table: ${a.tableKey}, anchorCell: ${a.anchor.key}, focusCell: ${a.focus.key} }`;
    }(g) : function(a) {
      return Q(a) ? `: node
  └ [${Array.from(a._nodes).join(", ")}]` : "";
    }(g);
  });
  if (f += `
 selection` + b, f += `

 commands:`, t.length)
    for (const { type: g, payload: a } of t)
      f += `
  └ { type: ${g}, payload: ${a instanceof Event ? a.constructor.name : a} }`;
  else
    f += `
  └ None dispatched.`;
  return f += `

 editor:`, f += `
  └ namespace ${i.namespace}`, m !== null && (f += `
  └ compositionKey ${m}`), f += `
  └ editable ${String(r)}`, f;
}
function Je(e, t, n = []) {
  const o = e.getChildren(), i = o.length;
  o.forEach((m, r) => {
    t(m, n.concat(r === i - 1 ? W.isLastChild : W.hasNextSibling)), _e(m) && Je(m, t, n.concat(r === i - 1 ? W.ancestorIsLastChild : W.ancestorHasNextSibling));
  });
}
function Ce(e) {
  return Object.entries(qe).reduce((t, [n, o]) => t.replace(new RegExp(n, "g"), String(o)), e);
}
function Dn(e) {
  let t = Sn.map((n) => n(e)).filter(Boolean).join(", ").toLocaleLowerCase();
  return t !== "" && (t = "detail: " + t), t;
}
function kn(e) {
  let t = Rn.map((n) => n(e)).filter(Boolean).join(", ").toLocaleLowerCase();
  return t !== "" && (t = "mode: " + t), t;
}
function Ee(e) {
  let t = Tn.map((n) => n(e)).filter(Boolean).join(", ").toLocaleLowerCase();
  return t !== "" && (t = "format: " + t), t;
}
function Ln(e) {
  let t = e.getTarget();
  return t != null && (t = "target: " + t), t;
}
function zn(e) {
  let t = e.getRel();
  return t != null && (t = "rel: " + t), t;
}
function Fn(e) {
  let t = e.getTitle();
  return t != null && (t = "title: " + t), t;
}
function Qe(e, t) {
  const n = new Array(1 + t++).join("  "), o = new Array(t - 1).join("  ");
  let i;
  for (let m = 0; m < e.children.length; m++)
    i = document.createTextNode(`
` + n), e.insertBefore(i, e.children[m]), Qe(e.children[m], t), e.lastElementChild === e.children[m] && (i = document.createTextNode(`
` + o), e.appendChild(i));
  return e;
}
const Bn = We(function({ treeTypeButtonClassName: e, timeTravelButtonClassName: t, timeTravelPanelSliderClassName: n, timeTravelPanelButtonClassName: o, viewClassName: i, timeTravelPanelClassName: m, editorState: r, setEditorState: f, setEditorReadOnly: b, generateContent: g }, a) {
  const [l, T] = A([]), [x, w] = A(""), [P, v] = A(!1), [R, k] = A(!1), s = H(0), E = H(null), [B, u] = A(!1), [h, d] = A(!1), [N, D] = A(!1), j = H(), C = H(0), I = U((F) => {
    const z = ++C.current;
    g(F).then((L) => {
      z === C.current && w(L);
    }).catch((L) => {
      z === C.current && w(`Error rendering tree: ${L.message}

Stack:
${L.stack}`);
    });
  }, [g]);
  K(() => {
    !N && r._nodeMap.size > 1e3 && (d(!0), !N) || j.current !== r && (j.current = r, I(R), P || T((F) => [...F, [Date.now(), r]]));
  }, [r, I, R, N, P]);
  const O = l.length;
  return K(() => {
    if (B) {
      let F;
      const z = () => {
        const L = s.current;
        if (L === O - 1)
          return void u(!1);
        const G = l[L][0], y = l[L + 1][0];
        F = setTimeout(() => {
          s.current++;
          const p = s.current, S = E.current;
          S !== null && (S.value = String(p)), f(l[p][1]), z();
        }, y - G);
      };
      return z(), () => {
        clearTimeout(F);
      };
    }
  }, [l, B, O, f]), _.createElement("div", { className: i }, !N && h ? _.createElement("div", { style: { padding: 20 } }, _.createElement("span", { style: { marginRight: 20 } }, "Detected large EditorState, this can impact debugging performance."), _.createElement("button", { onClick: () => {
    D(!0);
  }, style: { background: "transparent", border: "1px solid white", color: "white", cursor: "pointer", padding: 5 } }, "Show full tree")) : null, N ? null : _.createElement("button", { onClick: () => (I(!R), void k(!R)), className: e, type: "button" }, R ? "Tree" : "Export DOM"), !P && (N || !h) && O > 2 && _.createElement("button", { onClick: () => {
    b(!0), s.current = O - 1, v(!0);
  }, className: t, type: "button" }, "Time Travel"), (N || !h) && _.createElement("pre", { ref: a }, x), P && (N || !h) && _.createElement("div", { className: m }, _.createElement("button", { className: o, onClick: () => {
    s.current === O - 1 && (s.current = 1), u(!B);
  }, type: "button" }, B ? "Pause" : "Play"), _.createElement("input", { className: n, ref: E, onChange: (F) => {
    const z = Number(F.target.value), L = l[z];
    L && (s.current = z, f(L[1]));
  }, type: "range", min: "1", max: O - 1 }), _.createElement("button", { className: o, onClick: () => {
    b(!1);
    const F = l.length - 1, z = l[F];
    f(z[1]);
    const L = E.current;
    L !== null && (L.value = String(F)), v(!1), u(!1);
  }, type: "button" }, "Exit")));
});
function Mn(e, t) {
  const n = /* @__PURE__ */ new Set();
  for (const [o] of e._commands)
    n.add(e.registerCommand(o, (i) => (t((m) => {
      const r = [...m];
      return r.push({ payload: i, type: o.type ? o.type : "UNKNOWN" }), r.length > 10 && r.shift(), r;
    }), !1), Dt));
  return () => n.forEach((o) => o());
}
function In(e) {
  const [t, n] = A([]);
  return K(() => Mn(e, n), [e]), Jt(() => t, [t]);
}
function On({ treeTypeButtonClassName: e, timeTravelButtonClassName: t, timeTravelPanelSliderClassName: n, timeTravelPanelButtonClassName: o, viewClassName: i, timeTravelPanelClassName: m, editor: r }) {
  const f = _.createRef(), [b, g] = A(r.getEditorState()), a = In(r);
  return K(() => He(r.registerUpdateListener(({ editorState: l }) => {
    g(l);
  }), r.registerEditableListener(() => {
    g(r.getEditorState());
  })), [r]), K(() => {
    const l = f.current;
    if (l !== null)
      return l.__lexicalEditor = r, () => {
        l.__lexicalEditor = null;
      };
  }, [r, f]), _.createElement(Bn, { treeTypeButtonClassName: e, timeTravelButtonClassName: t, timeTravelPanelSliderClassName: n, timeTravelPanelButtonClassName: o, viewClassName: i, timeTravelPanelClassName: m, setEditorReadOnly: (l) => {
    const T = r.getRootElement();
    T != null && (T.contentEditable = l ? "false" : "true");
  }, editorState: b, setEditorState: (l) => r.setEditorState(l), generateContent: async function(l) {
    return $n(r, a, l);
  }, ref: f });
}
function An() {
  const [e] = ie();
  return /* @__PURE__ */ c.jsx(
    On,
    {
      viewClassName: "tree-view-output",
      treeTypeButtonClassName: "debug-treetype-button",
      timeTravelPanelClassName: "debug-timetravel-panel",
      timeTravelButtonClassName: "debug-timetravel-button",
      timeTravelPanelSliderClassName: "debug-timetravel-panel-slider",
      timeTravelPanelButtonClassName: "debug-timetravel-panel-button",
      editor: e
    }
  );
}
function ue(e, t, n) {
  return Math.min(Math.max(e, t), n);
}
const $ = {
  east: 1,
  north: 8,
  south: 2,
  west: 4
};
function _n({
  onResizeStart: e,
  onResizeEnd: t,
  buttonRef: n,
  imageRef: o,
  maxWidth: i,
  editor: m,
  showCaption: r,
  setShowCaption: f,
  captionsEnabled: b
}) {
  const g = H(null), a = H({
    priority: "",
    value: "default"
  }), l = H({
    currentHeight: 0,
    currentWidth: 0,
    direction: 0,
    isResizing: !1,
    ratio: 0,
    startHeight: 0,
    startWidth: 0,
    startX: 0,
    startY: 0
  }), T = m.getRootElement(), x = i || (T !== null ? T.getBoundingClientRect().width - 20 : 100), w = T !== null ? T.getBoundingClientRect().height - 20 : 100, P = 100, v = 100, R = (u) => {
    const h = u === $.east || u === $.west, d = u === $.north || u === $.south, N = u & $.north && u & $.west || u & $.south && u & $.east, D = h ? "ew" : d ? "ns" : N ? "nwse" : "nesw";
    T !== null && T.style.setProperty("cursor", `${D}-resize`, "important"), document.body !== null && (document.body.style.setProperty("cursor", `${D}-resize`, "important"), a.current.value = document.body.style.getPropertyValue("-webkit-user-select"), a.current.priority = document.body.style.getPropertyPriority("-webkit-user-select"), document.body.style.setProperty("-webkit-user-select", "none", "important"));
  }, k = () => {
    T !== null && T.style.setProperty("cursor", "text"), document.body !== null && (document.body.style.setProperty("cursor", "default"), document.body.style.setProperty(
      "-webkit-user-select",
      a.current.value,
      a.current.priority
    ));
  }, s = (u, h) => {
    if (!m.isEditable())
      return;
    const d = o.current, N = g.current;
    if (d !== null && N !== null) {
      u.preventDefault();
      const { width: D, height: j } = d.getBoundingClientRect(), C = l.current;
      C.startWidth = D, C.startHeight = j, C.ratio = D / j, C.currentWidth = D, C.currentHeight = j, C.startX = u.clientX, C.startY = u.clientY, C.isResizing = !0, C.direction = h, R(h), e(), N.classList.add("image-control-wrapper--resizing"), d.style.height = `${j}px`, d.style.width = `${D}px`, document.addEventListener("pointermove", E), document.addEventListener("pointerup", B);
    }
  }, E = (u) => {
    const h = o.current, d = l.current, N = d.direction & ($.east | $.west), D = d.direction & ($.south | $.north);
    if (h !== null && d.isResizing)
      if (N && D) {
        let j = Math.floor(d.startX - u.clientX);
        j = d.direction & $.east ? -j : j;
        const C = ue(d.startWidth + j, P, x), I = C / d.ratio;
        h.style.width = `${C}px`, h.style.height = `${I}px`, d.currentHeight = I, d.currentWidth = C;
      } else if (D) {
        let j = Math.floor(d.startY - u.clientY);
        j = d.direction & $.south ? -j : j;
        const C = ue(d.startHeight + j, v, w);
        h.style.height = `${C}px`, d.currentHeight = C;
      } else {
        let j = Math.floor(d.startX - u.clientX);
        j = d.direction & $.east ? -j : j;
        const C = ue(d.startWidth + j, P, x);
        h.style.width = `${C}px`, d.currentWidth = C;
      }
  }, B = () => {
    const u = o.current, h = l.current, d = g.current;
    if (u !== null && d !== null && h.isResizing) {
      const N = h.currentWidth, D = h.currentHeight;
      h.startWidth = 0, h.startHeight = 0, h.ratio = 0, h.startX = 0, h.startY = 0, h.currentWidth = 0, h.currentHeight = 0, h.isResizing = !1, d.classList.remove("image-control-wrapper--resizing"), k(), t(N, D), document.removeEventListener("pointermove", E), document.removeEventListener("pointerup", B);
    }
  };
  return /* @__PURE__ */ c.jsxs("div", { ref: g, children: [
    /* @__PURE__ */ c.jsx(
      "div",
      {
        className: "image-resizer image-resizer-n",
        onPointerDown: (u) => {
          s(u, $.north);
        }
      }
    ),
    /* @__PURE__ */ c.jsx(
      "div",
      {
        className: "image-resizer image-resizer-ne",
        onPointerDown: (u) => {
          s(u, $.north | $.east);
        }
      }
    ),
    /* @__PURE__ */ c.jsx(
      "div",
      {
        className: "image-resizer image-resizer-e",
        onPointerDown: (u) => {
          s(u, $.east);
        }
      }
    ),
    /* @__PURE__ */ c.jsx(
      "div",
      {
        className: "image-resizer image-resizer-se",
        onPointerDown: (u) => {
          s(u, $.south | $.east);
        }
      }
    ),
    /* @__PURE__ */ c.jsx(
      "div",
      {
        className: "image-resizer image-resizer-s",
        onPointerDown: (u) => {
          s(u, $.south);
        }
      }
    ),
    /* @__PURE__ */ c.jsx(
      "div",
      {
        className: "image-resizer image-resizer-sw",
        onPointerDown: (u) => {
          s(u, $.south | $.west);
        }
      }
    ),
    /* @__PURE__ */ c.jsx(
      "div",
      {
        className: "image-resizer image-resizer-w",
        onPointerDown: (u) => {
          s(u, $.west);
        }
      }
    ),
    /* @__PURE__ */ c.jsx(
      "div",
      {
        className: "image-resizer image-resizer-nw",
        onPointerDown: (u) => {
          s(u, $.north | $.west);
        }
      }
    )
  ] });
}
const Te = /* @__PURE__ */ new Set(), Pe = qt(), Se = (e, t, n) => {
  if (!n) {
    t();
    return;
  }
  n(e, t);
};
function Hn(e) {
  if (!Te.has(e))
    throw new Promise((t) => {
      const n = new Image();
      n.src = e, n.onload = () => {
        Te.add(e), t(null);
      };
    });
}
function Gn({
  altText: e,
  className: t,
  imageRef: n,
  src: o,
  width: i,
  height: m,
  maxWidth: r
}) {
  return Hn(o), /* @__PURE__ */ c.jsx(
    "img",
    {
      className: t || void 0,
      src: o,
      alt: e,
      ref: n,
      style: {
        height: m,
        maxWidth: r,
        width: i
      },
      draggable: "false"
    }
  );
}
function Vn({
  src: e,
  altText: t,
  nodeKey: n,
  width: o,
  height: i,
  maxWidth: m,
  resizable: r,
  showCaption: f,
  caption: b,
  captionsEnabled: g,
  id: a
}) {
  const l = H(null), T = H(null), [x, w, P] = kt(n), [v, R] = A(!1), { isCollabActive: k } = en(), [s] = ie(), [E, B] = A(null), u = H(null), { fetchDeleteImage: h } = fe(Lt), d = U(
    (y) => {
      if (x && Q(J())) {
        y.preventDefault();
        const S = oe(n);
        re(S) && Se(
          S.__id,
          () => {
            s.update(() => {
              S.remove();
            });
          },
          h
        );
      }
      return !1;
    },
    [x, n]
  ), N = U(
    (y) => {
      const p = J(), S = T.current;
      if (x && Q(p) && p.getNodes().length === 1) {
        if (f)
          return ve(null), y.preventDefault(), b.focus(), !0;
        if (S !== null && S !== document.activeElement)
          return y.preventDefault(), S.focus(), !0;
      }
      return !1;
    },
    [b, x, f]
  ), D = U(
    (y) => u.current === b || T.current === y.target ? (ve(null), s.update(() => {
      w(!0);
      const p = s.getRootElement();
      p !== null && p.focus();
    }), !0) : !1,
    [b, s, w]
  ), j = U(
    (y) => {
      const p = y;
      return v ? !0 : p.target === l.current ? (p.shiftKey ? w(!x) : (P(), w(!0)), !0) : !1;
    },
    [v, x, w, P]
  ), C = U(
    (y) => {
      s.getEditorState().read(() => {
        const p = J();
        y.target.tagName === "IMG" && me(p) && p.getNodes().length === 1 && s.dispatchCommand(Pe, y);
      });
    },
    [s]
  );
  K(() => {
    let y = !0;
    const p = s.getRootElement(), S = He(
      s.registerUpdateListener(({ editorState: Y }) => {
        y && B(Y.read(() => J()));
      }),
      s.registerCommand(
        Ot,
        (Y, X) => (u.current = X, !1),
        Z
      ),
      s.registerCommand(It, j, Z),
      s.registerCommand(Pe, j, Z),
      // editor.registerCommand(
      //   DRAGSTART_COMMAND,
      //   (event) => {
      //     if (event.target === imageRef.current) {
      //       // TODO This is just a temporary workaround for FF to behave like other browsers.
      //       // Ideally, this handles drag & drop too (and all browsers).
      //       event.preventDefault();
      //       return true;
      //     }
      //     return false;
      //   },
      //   COMMAND_PRIORITY_LOW
      // ),
      s.registerCommand(Mt, d, Z),
      s.registerCommand(Bt, d, Z),
      s.registerCommand(Ft, N, Z),
      s.registerCommand(zt, D, Z)
    );
    return p == null || p.addEventListener("contextmenu", C), () => {
      y = !1, S(), p == null || p.removeEventListener("contextmenu", C);
    };
  }, [
    P,
    s,
    v,
    x,
    n,
    d,
    N,
    D,
    j,
    C,
    w
  ]);
  const I = () => {
    s.update(() => {
      const y = oe(n);
      re(y) && y.setShowCaption(!0);
    });
  }, O = (y, p) => {
    setTimeout(() => {
      R(!1);
    }, 200), s.update(() => {
      const S = oe(n);
      re(S) && S.setWidthAndHeight(y, p);
    });
  }, F = () => {
    R(!0);
  }, { historyState: z } = At(), {
    settings: { showNestedEditorTreeView: L }
  } = _t(), G = x || v;
  return /* @__PURE__ */ c.jsx(Qt, { fallback: null, children: /* @__PURE__ */ c.jsxs(c.Fragment, { children: [
    /* @__PURE__ */ c.jsxs(
      "div",
      {
        style: {
          display: "inline-block",
          position: "relative"
        },
        children: [
          x && /* @__PURE__ */ c.jsxs(c.Fragment, { children: [
            /* @__PURE__ */ c.jsx(ee, { label: "Превью", children: /* @__PURE__ */ c.jsx("a", { className: "image-show-icon", href: e, target: "_blank", rel: "noopener noreferrer", children: /* @__PURE__ */ c.jsx("i", { className: "icon image" }) }) }),
            /* @__PURE__ */ c.jsx(ee, { label: "Удалить", children: /* @__PURE__ */ c.jsx(
              "div",
              {
                className: "image-delete-icon",
                onClick: (y) => {
                  y.stopPropagation(), Se(
                    a,
                    () => {
                      s.update(() => {
                        if (J()) {
                          const p = oe(n);
                          re(p) && p.remove();
                        }
                        return !1;
                      });
                    },
                    h
                  );
                },
                children: /* @__PURE__ */ c.jsx("i", { className: "format clear" })
              }
            ) })
          ] }),
          r && Q(E) && G && /* @__PURE__ */ c.jsx(
            _n,
            {
              showCaption: f,
              setShowCaption: I,
              editor: s,
              buttonRef: T,
              imageRef: l,
              maxWidth: m,
              onResizeStart: F,
              onResizeEnd: O,
              captionsEnabled: g
            }
          ),
          /* @__PURE__ */ c.jsx(
            Gn,
            {
              className: G ? `focused ${Q(E) ? "draggable" : ""}` : null,
              src: e,
              altText: t,
              imageRef: l,
              width: o,
              height: i,
              maxWidth: m || "auto"
            }
          )
        ]
      }
    ),
    f && /* @__PURE__ */ c.jsx("div", { className: "image-caption-container", children: /* @__PURE__ */ c.jsxs(on, { initialEditor: b, children: [
      /* @__PURE__ */ c.jsx(Ht, {}),
      /* @__PURE__ */ c.jsx(Gt, {}),
      /* @__PURE__ */ c.jsx(Wt, {}),
      /* @__PURE__ */ c.jsx(jn, {}),
      /* @__PURE__ */ c.jsx(Ut, {}),
      /* @__PURE__ */ c.jsx(En, {}),
      k ? /* @__PURE__ */ c.jsx(
        tn,
        {
          id: b.getKey(),
          providerFactory: nn,
          shouldBootstrap: !0
        }
      ) : /* @__PURE__ */ c.jsx(Kt, { externalHistoryState: z }),
      /* @__PURE__ */ c.jsx(
        Xt,
        {
          contentEditable: /* @__PURE__ */ c.jsx(Yt, { className: "ImageNode__contentEditable" }),
          placeholder: /* @__PURE__ */ c.jsx(Vt, { className: "ImageNode__placeholder", children: "Enter a caption..." }),
          ErrorBoundary: Zt
        }
      ),
      L === !0 ? /* @__PURE__ */ c.jsx(An, {}) : null
    ] }) })
  ] }) });
}
export {
  Pe as RIGHT_CLICK_IMAGE_COMMAND,
  Vn as default
};
