var F = Object.defineProperty, H = Object.defineProperties;
var X = Object.getOwnPropertyDescriptors;
var _ = Object.getOwnPropertySymbols;
var y = Object.prototype.hasOwnProperty, P = Object.prototype.propertyIsEnumerable;
var w = (e, n, o) => n in e ? F(e, n, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[n] = o, s = (e, n) => {
  for (var o in n || (n = {}))
    y.call(n, o) && w(e, o, n[o]);
  if (_)
    for (var o of _(n))
      P.call(n, o) && w(e, o, n[o]);
  return e;
}, u = (e, n) => H(e, X(n));
var m = (e, n) => {
  var o = {};
  for (var r in e)
    y.call(e, r) && n.indexOf(r) < 0 && (o[r] = e[r]);
  if (e != null && _)
    for (var r of _(e))
      n.indexOf(r) < 0 && P.call(e, r) && (o[r] = e[r]);
  return o;
};
import { c as j, ar as W, as as Z, au as M, aw as V } from "./main-CxoAwMiG.js";
import * as c from "react";
import q from "react";
import { j as K, k as Y, l as I, P as J, m as Q, o as ee, G as te, q as ne, r as oe, s as re, t as ae, v as se, S as ce, w as ie, x as ue, y as de } from "./TalkLoading-CJtNYhDp.js";
import { jsx as i, jsxs as N, Fragment as le } from "react/jsx-runtime";
const pe = [
  ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
  ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
], qe = j("x", pe);
var v = "ContextMenu", [xe] = V(v, [
  I
]), f = I(), [me, S] = xe(v), T = (e) => {
  const { __scopeContextMenu: n, children: o, onOpenChange: r, open: a, dir: t, modal: l = !0 } = e, h = c.useRef(!1);
  {
    const g = c.useRef(!1);
    c.useEffect(() => {
      a === !0 && !h.current && !g.current && (g.current = !0, console.warn(
        "ContextMenu: The `open` prop has been set to `true` before the user has interacted with the trigger, so its position is indeterminate. This is likely unintended and will result in the menu being anchored to the top-left corner of the viewport."
      ));
    }, [a]);
  }
  const [p, x] = W({
    prop: a,
    defaultProp: !1,
    onChange: r,
    caller: v
  }), d = f(n);
  return /* @__PURE__ */ i(
    me,
    {
      scope: n,
      open: p,
      onOpenChange: x,
      modal: l,
      hasInteractedRef: h,
      children: /* @__PURE__ */ i(K, u(s({}, d), { dir: t, open: p, onOpenChange: x, modal: l, children: o }))
    }
  );
};
T.displayName = v;
var A = "ContextMenuTrigger", O = c.forwardRef(
  (e, n) => {
    const E = e, { __scopeContextMenu: o, disabled: r = !1 } = E, a = m(E, ["__scopeContextMenu", "disabled"]), t = S(A, o), l = f(o), h = c.useRef({ x: 0, y: 0 }), p = c.useRef({
      getBoundingClientRect: () => DOMRect.fromRect(s({ width: 0, height: 0 }, h.current))
    }), x = c.useRef(0), d = c.useCallback(
      () => window.clearTimeout(x.current),
      []
    ), g = (C) => {
      t.hasInteractedRef.current = !0, h.current = { x: C.clientX, y: C.clientY }, t.onOpenChange(!0);
    };
    return c.useEffect(() => d, [d]), c.useEffect(() => {
      r && d();
    }, [r, d]), /* @__PURE__ */ N(le, { children: [
      /* @__PURE__ */ i(Y, u(s({}, l), { virtualRef: p })),
      /* @__PURE__ */ i(
        Z.span,
        u(s({
          "data-state": t.open ? "open" : "closed",
          "data-disabled": r ? "" : void 0
        }, a), {
          ref: n,
          style: s({ WebkitTouchCallout: "none" }, e.style),
          onContextMenu: r ? e.onContextMenu : M(e.onContextMenu, (C) => {
            d(), g(C), C.preventDefault();
          }),
          onPointerDown: r ? e.onPointerDown : M(
            e.onPointerDown,
            R((C) => {
              d(), t.open && t.onOpenChange(!1), x.current = window.setTimeout(() => g(C), 700);
            })
          ),
          onPointerMove: r ? e.onPointerMove : M(e.onPointerMove, R(d)),
          onPointerCancel: r ? e.onPointerCancel : M(e.onPointerCancel, R(d)),
          onPointerUp: r ? e.onPointerUp : M(e.onPointerUp, R(d))
        })
      )
    ] });
  }
);
O.displayName = A;
var fe = "ContextMenuPortal", G = (e) => {
  const a = e, { __scopeContextMenu: n } = a, o = m(a, ["__scopeContextMenu"]), r = f(n);
  return /* @__PURE__ */ i(J, s(s({}, r), o));
};
G.displayName = fe;
var U = "ContextMenuContent", k = c.forwardRef(
  (e, n) => {
    const h = e, { __scopeContextMenu: o } = h, r = m(h, ["__scopeContextMenu"]), a = S(U, o), t = f(o), l = c.useRef(!1);
    return /* @__PURE__ */ i(
      Q,
      u(s(s({}, t), r), {
        ref: n,
        side: "right",
        sideOffset: 2,
        align: "start",
        onCloseAutoFocus: (p) => {
          var x;
          (x = e.onCloseAutoFocus) == null || x.call(e, p), !p.defaultPrevented && l.current && p.preventDefault(), l.current = !1;
        },
        onInteractOutside: (p) => {
          var x;
          (x = e.onInteractOutside) == null || x.call(e, p), !p.defaultPrevented && !a.modal && (l.current = !0);
        },
        style: u(s({}, e.style), {
          "--radix-context-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
          "--radix-context-menu-content-available-width": "var(--radix-popper-available-width)",
          "--radix-context-menu-content-available-height": "var(--radix-popper-available-height)",
          "--radix-context-menu-trigger-width": "var(--radix-popper-anchor-width)",
          "--radix-context-menu-trigger-height": "var(--radix-popper-anchor-height)"
        })
      })
    );
  }
);
k.displayName = U;
var he = "ContextMenuGroup", Ce = c.forwardRef(
  (e, n) => {
    const t = e, { __scopeContextMenu: o } = t, r = m(t, ["__scopeContextMenu"]), a = f(o);
    return /* @__PURE__ */ i(te, u(s(s({}, a), r), { ref: n }));
  }
);
Ce.displayName = he;
var ge = "ContextMenuLabel", Me = c.forwardRef(
  (e, n) => {
    const t = e, { __scopeContextMenu: o } = t, r = m(t, ["__scopeContextMenu"]), a = f(o);
    return /* @__PURE__ */ i(ne, u(s(s({}, a), r), { ref: n }));
  }
);
Me.displayName = ge;
var _e = "ContextMenuItem", L = c.forwardRef(
  (e, n) => {
    const t = e, { __scopeContextMenu: o } = t, r = m(t, ["__scopeContextMenu"]), a = f(o);
    return /* @__PURE__ */ i(ee, u(s(s({}, a), r), { ref: n }));
  }
);
L.displayName = _e;
var Re = "ContextMenuCheckboxItem", ve = c.forwardRef((e, n) => {
  const t = e, { __scopeContextMenu: o } = t, r = m(t, ["__scopeContextMenu"]), a = f(o);
  return /* @__PURE__ */ i(oe, u(s(s({}, a), r), { ref: n }));
});
ve.displayName = Re;
var Ne = "ContextMenuRadioGroup", Ee = c.forwardRef((e, n) => {
  const t = e, { __scopeContextMenu: o } = t, r = m(t, ["__scopeContextMenu"]), a = f(o);
  return /* @__PURE__ */ i(re, u(s(s({}, a), r), { ref: n }));
});
Ee.displayName = Ne;
var we = "ContextMenuRadioItem", ye = c.forwardRef((e, n) => {
  const t = e, { __scopeContextMenu: o } = t, r = m(t, ["__scopeContextMenu"]), a = f(o);
  return /* @__PURE__ */ i(ae, u(s(s({}, a), r), { ref: n }));
});
ye.displayName = we;
var Pe = "ContextMenuItemIndicator", be = c.forwardRef((e, n) => {
  const t = e, { __scopeContextMenu: o } = t, r = m(t, ["__scopeContextMenu"]), a = f(o);
  return /* @__PURE__ */ i(se, u(s(s({}, a), r), { ref: n }));
});
be.displayName = Pe;
var Ie = "ContextMenuSeparator", Se = c.forwardRef((e, n) => {
  const t = e, { __scopeContextMenu: o } = t, r = m(t, ["__scopeContextMenu"]), a = f(o);
  return /* @__PURE__ */ i(ce, u(s(s({}, a), r), { ref: n }));
});
Se.displayName = Ie;
var Te = "ContextMenuArrow", Ae = c.forwardRef(
  (e, n) => {
    const t = e, { __scopeContextMenu: o } = t, r = m(t, ["__scopeContextMenu"]), a = f(o);
    return /* @__PURE__ */ i(ie, u(s(s({}, a), r), { ref: n }));
  }
);
Ae.displayName = Te;
var Oe = "ContextMenuSubTrigger", Ge = c.forwardRef((e, n) => {
  const t = e, { __scopeContextMenu: o } = t, r = m(t, ["__scopeContextMenu"]), a = f(o);
  return /* @__PURE__ */ i(ue, u(s(s({}, a), r), { ref: n }));
});
Ge.displayName = Oe;
var Ue = "ContextMenuSubContent", ke = c.forwardRef((e, n) => {
  const t = e, { __scopeContextMenu: o } = t, r = m(t, ["__scopeContextMenu"]), a = f(o);
  return /* @__PURE__ */ i(
    de,
    u(s(s({}, a), r), {
      ref: n,
      style: u(s({}, e.style), {
        "--radix-context-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
        "--radix-context-menu-content-available-width": "var(--radix-popper-available-width)",
        "--radix-context-menu-content-available-height": "var(--radix-popper-available-height)",
        "--radix-context-menu-trigger-width": "var(--radix-popper-anchor-width)",
        "--radix-context-menu-trigger-height": "var(--radix-popper-anchor-height)"
      })
    })
  );
});
ke.displayName = Ue;
function R(e) {
  return (n) => n.pointerType !== "mouse" ? e(n) : void 0;
}
var Ke = T, Ye = O, Je = G, Qe = k, et = L;
const $ = /(https?:\/\/[^\s<>"']*|https?:\/\/(?:(?:\d{1,3}\.){3}\d{1,3}|(?:[\da-z](?:[\da-z-]{0,61}[\da-z])?\.)+[\da-z]{2,})(?::\d{1,5})?(?:\/[^\s<>"']*)?(?:\?[^\s<>"']*)?(?:#[^\s<>"']*)?|(?:[\da-z](?:[\da-z-]{0,61}[\da-z])?\.)+(?:ir|com|org|net)(?:[^\s<>"']*)?(?:\/[^\s<>"']*)?(?::\d{1,5})?(?:\/[^\s<>"']*)?(?:\?[^\s<>"']*)?(?:#[^\s<>"']*)?)[.,!?\u060C،؛؟]?/giu, Le = /(^|\s+)(@[A-Za-z0-9._-]{1,70})(?![A-Za-z0-9._-])/g, b = new RegExp($.source, "i"), $e = /#([A-Za-z0-9_0-9\u0600-\u06FF.-]{1,64})/g, z = /\*\*([^\n*][^\n]*?)\*\*/g, D = /__(.*?)__/g, ze = /`(.*?)`/g, De = /```(.*?)/g, B = /~~(.*?)~~/g, Be = /(^|[^0-9۰-۹])((?:\+98|0098|98|0)?[\s-]*[9۹](?:[\s-]*[0-9۰-۹]){9})(?![0-9۰-۹])/g, Fe = /[0-9۰-۹]+(?:[.-][0-9۰-۹]+)*/g;
function tt(e) {
  var a;
  const n = [];
  let o = 0;
  const r = [
    // { re: RE_EMAIL, type: "email" as const },
    { re: z, type: "bold" },
    { re: B, type: "line-through" },
    { re: D, type: "italic" },
    { re: Le, type: "mention" },
    { re: $e, type: "hashtag" },
    { re: Be, type: "phone" },
    { re: Fe, type: "number" },
    { re: $, type: "url" }
  ].map(({ re: t, type: l }) => ({
    re: t,
    type: l,
    match: t.exec(e)
  }));
  for (; ; ) {
    let t = null;
    for (const d of r)
      d.match && (!t || d.match.index < t.index) && (t = {
        index: d.match.index,
        source: d,
        match: d.match
      });
    if (!t)
      break;
    if (t.index < o) {
      t.source.match = t.source.re.exec(e);
      continue;
    }
    t.index > o && n.push({
      type: "text",
      raw: e.slice(o, t.index)
    });
    const { source: l, match: h } = t, p = h[0], x = ["italic", "bold", "line-through"].includes(l.type) ? h[1] : void 0;
    l.type === "url" && h.index === 2 || (((a = n[n.length - 1]) == null ? void 0 : a.raw.trim().replace("@", "")) !== p && n.push({
      type: l.type,
      raw: p,
      content: x,
      isUrl: x ? b.test(x) : !1
    }), o = t.index + p.length), l.match = l.re.exec(e);
  }
  return o < e.length && n.push({
    type: "text",
    raw: e.slice(o),
    isUrl: e.slice(o) ? b.test(e.slice(o)) : !1
  }), n;
}
function nt(e) {
  return e.replace(De, "<code>$1</code>").replace(ze, "<code>$1</code>").replace(z, "<strong class='font-bold'>$1</strong>").replace(D, "<em>$1</em>").replace(B, "<s>$1</s>");
}
function ot(e) {
  return e ? e.replace(/<strong\b[^>]*>([\s\S]*?)<\/strong>/gi, "**$1**").replace(/<em\b[^>]*>([\s\S]*?)<\/em>/gi, "__$1__").replace(/<s\b[^>]*>([\s\S]*?)<\/s>/gi, "~~$1~~").replace(/<code\b[^>]*>([\s\S]*?)<\/code>/gi, "`$1`") : "";
}
const He = ({ size: e = 12 }) => /* @__PURE__ */ N("div", { className: "flex items-center gap-1  text-xs   ", children: [
  /* @__PURE__ */ i(
    "span",
    {
      className: `text-[var(--color-accent)] font-bold text-[${e}px] truncate`,
      children: "در حال نوشتن"
    }
  ),
  /* @__PURE__ */ N("span", { className: "text-gray-400", children: [
    /* @__PURE__ */ i("span", { className: "typing-dot", children: "." }),
    /* @__PURE__ */ i("span", { className: "typing-dot", children: "." }),
    /* @__PURE__ */ i("span", { className: "typing-dot", children: "." })
  ] })
] }), rt = q.memo(He);
export {
  Qe as C,
  et as I,
  Je as P,
  Ke as R,
  rt as T,
  qe as X,
  Ye as a,
  ot as b,
  nt as s,
  tt as t
};
