@lambda-development/erp-core 1.2.2 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { jsx as t, jsxs as r, Fragment as ke } from "react/jsx-runtime";
2
2
  import { useState as w, useEffect as se, useCallback as Ve, useContext as Dn, createContext as Pn, useRef as me, useMemo as ye, useId as La, useLayoutEffect as jn, StrictMode as $r } from "react";
3
3
  import { createRoot as Vr } from "react-dom/client";
4
4
  import { useQueryClient as We, useQuery as ge, useMutation as xe, QueryClientProvider as Ur, QueryClient as Kr } from "@tanstack/react-query";
5
- import { NavLink as en, useLocation as Ct, useNavigate as Ue, Outlet as jr, Navigate as Et, Link as Ce, useSearchParams as Lt, useParams as bt, createBrowserRouter as Wr, RouterProvider as Gr } from "react-router-dom";
5
+ import { NavLink as en, useLocation as Ct, useNavigate as Ue, Outlet as jr, Navigate as Et, Link as Ce, useSearchParams as Lt, useParams as vt, createBrowserRouter as Wr, RouterProvider as Gr } from "react-router-dom";
6
6
  import { useTranslation as re, initReactI18next as Hr } from "react-i18next";
7
7
  import { BookOpen as Qr, ShoppingCart as Oa, CreditCard as Yr, FileText as Tn, Package as Fa, BarChart3 as Jr, CalendarRange as Zr, Database as Xr, Settings as ei, MessageCircle as Ma, ChevronDown as St, ChevronRight as Ot, Plus as za, Trash2 as qa, LineChart as ti, X as Rn, Bell as ni, RotateCcw as ai, Check as In, ArrowLeft as ri, TrendingUp as ii, ArrowDownRight as si, ArrowUpRight as oi, Wallet as li, Receipt as Wn, ChevronLeft as ci, Info as di, Search as Gn, Filter as ui, SlidersHorizontal as $a, ChevronUp as Va, ChevronsUpDown as Ua, Plug as Ka, ShieldCheck as ja, FileUp as mi, Loader2 as xn, CheckCircle2 as kn, AlertTriangle as pi, RefreshCw as hi, Undo2 as gi, Monitor as fi, Terminal as yi, Code2 as bi, Copy as vi } from "lucide-react";
8
8
  import { createColumnHelper as Wa, useReactTable as Ga, getCoreRowModel as Ha, flexRender as Yt } from "@tanstack/react-table";
@@ -504,10 +504,10 @@ function Ri({ children: e }) {
504
504
  }, Ne.onmessage = (Se) => {
505
505
  var Xe;
506
506
  try {
507
- const Z = JSON.parse(Se.data), gt = typeof Z.request_id == "string" ? Z.request_id : null, Le = typeof Z.type == "string" ? Z.type : null, X = typeof Z.session_id == "string" ? Z.session_id : null;
508
- if (gt) {
509
- const ee = W.current.get(gt);
510
- ee && (Le === "error" ? (W.current.delete(gt), ee.reject(new Error(String(Z.content || "Request failed.")))) : Le === ee.expectedType && (W.current.delete(gt), ee.resolve(Z)));
507
+ const Z = JSON.parse(Se.data), ft = typeof Z.request_id == "string" ? Z.request_id : null, Le = typeof Z.type == "string" ? Z.type : null, X = typeof Z.session_id == "string" ? Z.session_id : null;
508
+ if (ft) {
509
+ const ee = W.current.get(ft);
510
+ ee && (Le === "error" ? (W.current.delete(ft), ee.reject(new Error(String(Z.content || "Request failed.")))) : Le === ee.expectedType && (W.current.delete(ft), ee.resolve(Z)));
511
511
  }
512
512
  if (Le === "sessions_list") {
513
513
  const ee = Array.isArray(Z.sessions) ? Z.sessions : [];
@@ -711,7 +711,7 @@ function Ri({ children: e }) {
711
711
  return;
712
712
  }
713
713
  if (Le === "error") {
714
- if (gt)
714
+ if (ft)
715
715
  return;
716
716
  X && (z(X, !1), F(X, (ee) => [
717
717
  ...ee.filter((ce) => ce.type !== "thinking"),
@@ -857,7 +857,7 @@ function Ri({ children: e }) {
857
857
  }
858
858
  );
859
859
  }
860
- function vt() {
860
+ function xt() {
861
861
  const e = Dn(er);
862
862
  if (!e)
863
863
  throw new Error("useChat must be used within ChatProvider.");
@@ -1065,7 +1065,7 @@ function On() {
1065
1065
  function Li() {
1066
1066
  return ir().prompt;
1067
1067
  }
1068
- const yt = [
1068
+ const bt = [
1069
1069
  {
1070
1070
  label: "Introduction",
1071
1071
  icon: /* @__PURE__ */ t(Qr, { className: "h-4 w-4" }),
@@ -1165,19 +1165,19 @@ const yt = [
1165
1165
  }
1166
1166
  ];
1167
1167
  function Oi() {
1168
- return yt;
1168
+ return bt;
1169
1169
  }
1170
1170
  function md(e, n) {
1171
- const a = yt.findIndex((i) => i.label === e.label);
1171
+ const a = bt.findIndex((i) => i.label === e.label);
1172
1172
  if (a >= 0) {
1173
- yt[a] = e;
1173
+ bt[a] = e;
1174
1174
  return;
1175
1175
  }
1176
- (n == null ? void 0 : n.index) != null ? yt.splice(n.index, 0, e) : yt.push(e);
1176
+ (n == null ? void 0 : n.index) != null ? bt.splice(n.index, 0, e) : bt.push(e);
1177
1177
  }
1178
1178
  function pd(e, n) {
1179
- const a = yt.find((i) => i.label === e);
1180
- a ? a.items.push(n) : yt.push({ label: e, icon: null, items: [n] });
1179
+ const a = bt.find((i) => i.label === e);
1180
+ a ? a.items.push(n) : bt.push({ label: e, icon: null, items: [n] });
1181
1181
  }
1182
1182
  let wn = { appName: "Lambda ERP" };
1183
1183
  function hd(e) {
@@ -1229,7 +1229,7 @@ const Mn = {
1229
1229
  "Custom Analytics": "bg-indigo-300 text-indigo-950 ring-2 ring-inset ring-indigo-100"
1230
1230
  };
1231
1231
  function Fi() {
1232
- const [e, n] = Fn("chats"), a = Ct(), i = Ue(), { t: o } = re(), { sessions: s, createSession: l, deleteSession: c } = vt(), h = async () => {
1232
+ const [e, n] = Fn("chats"), a = Ct(), i = Ue(), { t: o } = re(), { sessions: s, createSession: l, deleteSession: c } = xt(), h = async () => {
1233
1233
  try {
1234
1234
  const g = await l();
1235
1235
  i(`/chat/${g.id}`);
@@ -1307,7 +1307,7 @@ function zn() {
1307
1307
  );
1308
1308
  }
1309
1309
  function Mi() {
1310
- const [e, n, a] = Fn("custom-analytics"), i = Ct(), o = Ue(), s = We(), { t: l } = re(), { navigationFlash: c, sessions: h, createSession: d } = vt(), g = (c == null ? void 0 : c.group) === "Custom Analytics", m = Mn["Custom Analytics"], { data: x } = ge({
1310
+ const [e, n, a] = Fn("custom-analytics"), i = Ct(), o = Ue(), s = We(), { t: l } = re(), { navigationFlash: c, sessions: h, createSession: d } = xt(), g = (c == null ? void 0 : c.group) === "Custom Analytics", m = Mn["Custom Analytics"], { data: x } = ge({
1311
1311
  queryKey: ["runtime-drafts"],
1312
1312
  queryFn: () => M.listRuntimeDrafts(),
1313
1313
  staleTime: 3e4
@@ -1397,7 +1397,7 @@ function Mi() {
1397
1397
  ] });
1398
1398
  }
1399
1399
  function zi({ group: e }) {
1400
- const [n, a] = Fn(e.label), { t: i } = re(), { navigationFlash: o } = vt(), s = (o == null ? void 0 : o.group) === e.label, l = Mn[e.label] ?? "bg-blue-300 text-blue-950 ring-2 ring-inset ring-blue-100";
1400
+ const [n, a] = Fn(e.label), { t: i } = re(), { navigationFlash: o } = xt(), s = (o == null ? void 0 : o.group) === e.label, l = Mn[e.label] ?? "bg-blue-300 text-blue-950 ring-2 ring-inset ring-blue-100";
1401
1401
  return /* @__PURE__ */ r("div", { children: [
1402
1402
  /* @__PURE__ */ r(
1403
1403
  "button",
@@ -1820,7 +1820,7 @@ function Gi() {
1820
1820
  return /* @__PURE__ */ t(Ei, { children: /* @__PURE__ */ t(Ri, { children: /* @__PURE__ */ t(Hi, {}) }) });
1821
1821
  }
1822
1822
  function Hi() {
1823
- const { pathname: e } = Ct(), n = Ue(), { user: a, logout: i } = Ge(), { navigationFlash: o } = vt(), { t: s, i18n: l } = re(), { settings: c } = tn();
1823
+ const { pathname: e } = Ct(), n = Ue(), { user: a, logout: i } = Ge(), { navigationFlash: o } = xt(), { t: s, i18n: l } = re(), { settings: c } = tn();
1824
1824
  se(() => {
1825
1825
  const b = c.language;
1826
1826
  b && b !== (l.language || "").split("-")[0] && l.changeLanguage(b);
@@ -3575,7 +3575,7 @@ function oa(e, n) {
3575
3575
  }
3576
3576
  function la() {
3577
3577
  var ie, be;
3578
- const { doctype: e, name: n } = bt(), a = Ue(), i = We(), { t: o } = re(), s = mr(e ?? ""), l = !n;
3578
+ const { doctype: e, name: n } = vt(), a = Ue(), i = We(), { t: o } = re(), s = mr(e ?? ""), l = !n;
3579
3579
  Me(l ? (s == null ? void 0 : s.label) ?? null : n ?? (s == null ? void 0 : s.label) ?? null);
3580
3580
  const [c, h] = w({}), [d, g] = w(!1), { data: m, isLoading: x } = ge({
3581
3581
  queryKey: ["document", e, n],
@@ -3870,7 +3870,7 @@ function Jt({
3870
3870
  ] })
3871
3871
  ] });
3872
3872
  }
3873
- const Nt = "__contains";
3873
+ const wt = "__contains";
3874
3874
  function ps(e, n) {
3875
3875
  const a = /(?:^|\s)([A-Za-z_][\w-]*):(?:"([^"]*)"?|([^\s]*))$/.exec(e);
3876
3876
  if (!a) return null;
@@ -3887,10 +3887,10 @@ function hs(e, n) {
3887
3887
  return e.slice(0, n.start).trim().replace(/\s+/g, " ");
3888
3888
  }
3889
3889
  function gr(e) {
3890
- return e.contains ? `${e.name}${Nt}` : e.name;
3890
+ return e.contains ? `${e.name}${wt}` : e.name;
3891
3891
  }
3892
3892
  function fr(e) {
3893
- return e.contains ? e.name : `${e.name}${Nt}`;
3893
+ return e.contains ? e.name : `${e.name}${wt}`;
3894
3894
  }
3895
3895
  function gs(e, n) {
3896
3896
  const a = new Map(n.map((h) => [h.name, h])), i = {}, o = [], s = /(?:^|\s)([A-Za-z_][\w-]*):(?:"([^"]*)"|([^\s]+))/g;
@@ -3928,7 +3928,7 @@ function yr({
3928
3928
  const { t: g } = re(), m = me(null), x = me(null), [k, b] = w(!1), [f, A] = w(!1), [C, v] = w({ field: "", value: "" }), p = ye(() => ps(n, i), [n, i]), y = n.trimEnd().split(/\s+/).pop() ?? "", _ = f || p || y.includes(":") ? "" : y.toLowerCase(), N = ye(() => i.filter(
3929
3929
  (H) => !_ || H.name.toLowerCase().includes(_) || H.label.toLowerCase().includes(_)
3930
3930
  ).sort((H, oe) => {
3931
- const ue = o[H.name] || o[`${H.name}${Nt}`] ? 1 : 0, we = o[oe.name] || o[`${oe.name}${Nt}`] ? 1 : 0;
3931
+ const ue = o[H.name] || o[`${H.name}${wt}`] ? 1 : 0, we = o[oe.name] || o[`${oe.name}${wt}`] ? 1 : 0;
3932
3932
  if (ue !== we) return we - ue;
3933
3933
  const ve = H.suggestOnEmpty ? 1 : 0, _e = oe.suggestOnEmpty ? 1 : 0;
3934
3934
  return ve !== _e ? _e - ve : H.label.localeCompare(oe.label);
@@ -3983,7 +3983,7 @@ function yr({
3983
3983
  const I = gs(n, i);
3984
3984
  l(I.text, I.updates), I.text !== n && a(I.text), A(!1), b(!1);
3985
3985
  }, z = Object.entries(o).filter(([, I]) => I !== "").map(([I, H]) => {
3986
- const oe = I.endsWith(Nt) ? I.slice(0, -Nt.length) : I;
3986
+ const oe = I.endsWith(wt) ? I.slice(0, -wt.length) : I;
3987
3987
  return { key: I, fieldName: oe, filterValue: H };
3988
3988
  }).filter(({ fieldName: I }) => !h.includes(I)).map(({ key: I, fieldName: H, filterValue: oe }) => ({
3989
3989
  key: I,
@@ -4278,7 +4278,7 @@ function xs(e) {
4278
4278
  return n === "customer" ? "customer" : n === "supplier" ? "supplier" : null;
4279
4279
  }
4280
4280
  function ks() {
4281
- const { t: e } = re(), n = Je(), { doctype: a } = bt(), i = mr(a ?? ""), o = Ct();
4281
+ const { t: e } = re(), n = Je(), { doctype: a } = vt(), i = mr(a ?? ""), o = Ct();
4282
4282
  Me((i == null ? void 0 : i.label) ?? a ?? null);
4283
4283
  const s = (i == null ? void 0 : i.listFilters) ?? [], l = ye(() => {
4284
4284
  const D = new URLSearchParams(o.search), U = {}, S = /* @__PURE__ */ new Set(["q", "page", "per_page", "from", "to", "discarded", "order_by", "order"]);
@@ -4727,7 +4727,7 @@ const Vt = () => ({
4727
4727
  }), Ns = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
4728
4728
  function ga() {
4729
4729
  var K;
4730
- const { name: e } = bt(), n = !e, a = Ue(), i = We(), { t: o } = re();
4730
+ const { name: e } = vt(), n = !e, a = Ue(), i = We(), { t: o } = re();
4731
4731
  Me(o("titles.proposal"));
4732
4732
  const s = (u, F) => o(u, { defaultValue: F }), l = On(), [c, h] = w({
4733
4733
  title: "Offerte",
@@ -4998,7 +4998,7 @@ const kr = {
4998
4998
  };
4999
4999
  function Ss() {
5000
5000
  var Be;
5001
- const { type: e } = bt(), n = Ue(), a = Ct(), i = xr(e ?? ""), o = (i == null ? void 0 : i.label) ?? ws[e ?? ""] ?? e ?? "";
5001
+ const { type: e } = vt(), n = Ue(), a = Ct(), i = xr(e ?? ""), o = (i == null ? void 0 : i.label) ?? ws[e ?? ""] ?? e ?? "";
5002
5002
  Me(o || null);
5003
5003
  const { t: s } = re(), l = (Be = a.state) == null ? void 0 : Be.notice, [c] = he("per_page", 50), [h] = he("page", 1), [d] = he("include_disabled", ""), g = h - 1, m = lt(), x = (j) => m({ page: j === 0 ? null : j + 1 }), k = (j) => m({ per_page: j, page: null }), b = (j) => m({ include_disabled: j ? "1" : null, page: null }), { settings: f, setSetting: A } = tn(), [C] = he("order_by", ""), [v] = he("order", ""), [p, y] = (f[`sort.master:${e}`] || "").split(":"), _ = C || p || "", N = (C ? v : y) || "asc", $ = (j) => {
5004
5004
  const ae = _ === j ? N === "desc" ? "asc" : "desc" : fa(j) ? "desc" : "asc";
@@ -5295,7 +5295,7 @@ const _s = {
5295
5295
  }, ya = /* @__PURE__ */ new Set(["customer", "supplier", "item", "warehouse"]);
5296
5296
  function ba() {
5297
5297
  var P, R, K;
5298
- const { type: e, name: n } = bt(), a = Ue(), i = We(), { t: o } = re(), s = !n || n === "new", l = xr(e ?? ""), c = (l == null ? void 0 : l.label) ?? _s[e ?? ""] ?? e ?? "", h = o(`masters.${e}.one`, { defaultValue: c }), d = (l == null ? void 0 : l.fields) ?? kr[e ?? ""] ?? [], g = (u) => o(`fields.${u.label}`, { defaultValue: u.label }), [m, x] = w({}), { data: k, isLoading: b } = ge({
5298
+ const { type: e, name: n } = vt(), a = Ue(), i = We(), { t: o } = re(), s = !n || n === "new", l = xr(e ?? ""), c = (l == null ? void 0 : l.label) ?? _s[e ?? ""] ?? e ?? "", h = o(`masters.${e}.one`, { defaultValue: c }), d = (l == null ? void 0 : l.fields) ?? kr[e ?? ""] ?? [], g = (u) => o(`fields.${u.label}`, { defaultValue: u.label }), [m, x] = w({}), { data: k, isLoading: b } = ge({
5299
5299
  queryKey: ["master", e, n],
5300
5300
  queryFn: () => M.getMaster(e, n),
5301
5301
  enabled: !!e && !!n && !s
@@ -6337,7 +6337,7 @@ function Zs() {
6337
6337
  const wr = Zs();
6338
6338
  function Xs() {
6339
6339
  Me("Analytics");
6340
- const e = Ue(), { sessions: n, createSession: a } = vt(), [i] = he("report_id", ""), [o] = he("metric", ""), [s] = he("group_by", ""), [l] = he("from", ""), [c] = he("to", ""), [h] = he("company", ""), [d, g] = w(wr), [m, x] = w([]), [k, b] = w(null), [f, A] = w(""), [C, v] = w(!1), [p, y] = w(!1), [_, N] = w(""), $ = me(""), O = me(""), T = me(0), W = ye(() => !o || !s ? "" : JSON.stringify(ao({
6340
+ const e = Ue(), { sessions: n, createSession: a } = xt(), [i] = he("report_id", ""), [o] = he("metric", ""), [s] = he("group_by", ""), [l] = he("from", ""), [c] = he("to", ""), [h] = he("company", ""), [d, g] = w(wr), [m, x] = w([]), [k, b] = w(null), [f, A] = w(""), [C, v] = w(!1), [p, y] = w(!1), [_, N] = w(""), $ = me(""), O = me(""), T = me(0), W = ye(() => !o || !s ? "" : JSON.stringify(ao({
6341
6341
  metric: o,
6342
6342
  groupBy: s,
6343
6343
  fromDate: l || void 0,
@@ -6590,7 +6590,7 @@ function no(e) {
6590
6590
  function ao(e) {
6591
6591
  const n = `${ro(e.metric)} by ${to(e.groupBy)}`;
6592
6592
  if (e.metric === "sales_revenue")
6593
- return kt({
6593
+ return Nt({
6594
6594
  title: n,
6595
6595
  dataset: e.groupBy === "item" ? "sales_invoice_lines" : "sales_invoices",
6596
6596
  requestName: "rows",
@@ -6606,7 +6606,7 @@ function ao(e) {
6606
6606
  chartType: e.groupBy === "customer" || e.groupBy === "item" ? "bar" : "line"
6607
6607
  });
6608
6608
  if (e.metric === "sales_returns")
6609
- return kt({
6609
+ return Nt({
6610
6610
  title: n,
6611
6611
  dataset: "sales_invoices",
6612
6612
  requestName: "rows",
@@ -6622,7 +6622,7 @@ function ao(e) {
6622
6622
  chartType: e.groupBy === "customer" ? "bar" : "line"
6623
6623
  });
6624
6624
  if (e.metric === "purchases")
6625
- return kt({
6625
+ return Nt({
6626
6626
  title: n,
6627
6627
  dataset: e.groupBy === "item" ? "purchase_invoice_lines" : "purchase_invoices",
6628
6628
  requestName: "rows",
@@ -6639,7 +6639,7 @@ function ao(e) {
6639
6639
  });
6640
6640
  if (e.metric === "payments_received" || e.metric === "payments_made") {
6641
6641
  const a = e.metric === "payments_received";
6642
- return kt({
6642
+ return Nt({
6643
6643
  title: n,
6644
6644
  dataset: "payments",
6645
6645
  requestName: "rows",
@@ -6658,7 +6658,7 @@ function ao(e) {
6658
6658
  }
6659
6659
  if (e.metric === "outstanding_ar" || e.metric === "outstanding_ap") {
6660
6660
  const a = e.metric === "outstanding_ar", i = a ? "ar_open_items" : "ap_open_items", o = a ? "customer" : "supplier", s = "outstanding_amount";
6661
- return kt({
6661
+ return Nt({
6662
6662
  title: n,
6663
6663
  dataset: i,
6664
6664
  requestName: "rows",
@@ -6673,7 +6673,7 @@ function ao(e) {
6673
6673
  chartType: "bar"
6674
6674
  });
6675
6675
  }
6676
- return e.metric === "stock_value" ? kt({
6676
+ return e.metric === "stock_value" ? Nt({
6677
6677
  title: n,
6678
6678
  dataset: "stock_balances",
6679
6679
  requestName: "rows",
@@ -6687,7 +6687,7 @@ function ao(e) {
6687
6687
  chartType: "bar"
6688
6688
  }) : JSON.parse(wr);
6689
6689
  }
6690
- function kt(e) {
6690
+ function Nt(e) {
6691
6691
  const n = Object.fromEntries(Object.entries(e.filters).filter(([, i]) => i !== void 0)), a = ["month", "quarter", "year"].includes(e.groupBy);
6692
6692
  return {
6693
6693
  title: e.title,
@@ -7287,7 +7287,7 @@ const yo = [
7287
7287
  }
7288
7288
  ];
7289
7289
  function Ar() {
7290
- const e = Ue(), { sessions: n, createSession: a } = vt();
7290
+ const e = Ue(), { sessions: n, createSession: a } = xt();
7291
7291
  return async (i) => {
7292
7292
  var s;
7293
7293
  let o = ((s = n[0]) == null ? void 0 : s.id) || "";
@@ -7682,7 +7682,7 @@ function Ca(e) {
7682
7682
  }
7683
7683
  function Sa() {
7684
7684
  var Kn;
7685
- const { t: e } = re(), { sessionId: n } = bt(), a = Ue(), i = Ct(), [o] = Lt(), s = o.get("demo") === "1", [l, c] = w(""), [h, d] = w(""), [g, m] = w([]), [x, k] = w(""), [b, f] = w(!1), [A, C] = w("idle"), v = me(null), p = me(null), y = me([]), {
7685
+ const { t: e } = re(), { sessionId: n } = vt(), a = Ue(), i = Ct(), [o] = Lt(), s = o.get("demo") === "1", [l, c] = w(""), [h, d] = w(""), [g, m] = w([]), [x, k] = w(""), [b, f] = w(!1), [A, C] = w("idle"), v = me(null), p = me(null), y = me([]), {
7686
7686
  sessions: _,
7687
7687
  connectionStatus: N,
7688
7688
  connectionVersion: $,
@@ -7699,7 +7699,7 @@ function Sa() {
7699
7699
  isThinking: I,
7700
7700
  getDemoStatus: H,
7701
7701
  getDemoTypingCue: oe
7702
- } = vt(), ue = me(null), we = me(null), ve = me(null), _e = me(null), [E, ie] = w(0), be = me(!1), q = me(null), ne = me(0), ze = me(!0), Te = me(null), je = me(!1), He = me(null), Ze = u(n), it = (Kn = _.find((L) => L.id === n)) == null ? void 0 : Kn.title;
7702
+ } = xt(), ue = me(null), we = me(null), ve = me(null), _e = me(null), [E, ie] = w(0), be = me(!1), q = me(null), ne = me(0), ze = me(!0), Te = me(null), je = me(!1), He = me(null), Ze = u(n), it = (Kn = _.find((L) => L.id === n)) == null ? void 0 : Kn.title;
7703
7703
  Me(it || null);
7704
7704
  const Be = N === "connected", j = I(n), ae = H(n), De = oe(n), D = s || ae === "running", U = F(n), S = z(n), B = Ze[Ze.length - 1], G = B ? `${B.type}:${B.timestamp || ""}:${B.content}` : "empty", le = Ve(() => {
7705
7705
  je.current = !0, He.current !== null && window.clearTimeout(He.current), He.current = window.setTimeout(() => {
@@ -7778,7 +7778,7 @@ function Sa() {
7778
7778
  return (L = ve.current) == null ? void 0 : L.focus();
7779
7779
  }, 50), be.current = j;
7780
7780
  }, [j, Be]);
7781
- function gt(L) {
7781
+ function ft(L) {
7782
7782
  if (je.current) return;
7783
7783
  const te = L.currentTarget, fe = te.scrollHeight - te.scrollTop - te.clientHeight;
7784
7784
  ze.current = fe < 80;
@@ -7799,7 +7799,7 @@ function Sa() {
7799
7799
  if (!De || !n || X.current === De.seq) return;
7800
7800
  X.current = De.seq;
7801
7801
  const L = n, te = De.content, fe = te.length > 0 ? Math.max(8, De.typingMs / te.length) : 0, Re = De.seq, Ie = ++ne.current;
7802
- async function xt() {
7802
+ async function kt() {
7803
7803
  c("");
7804
7804
  for (const dt of te) {
7805
7805
  if (Ie !== ne.current) return;
@@ -7807,7 +7807,7 @@ function Sa() {
7807
7807
  }
7808
7808
  Ie === ne.current && Le.current(L, Re);
7809
7809
  }
7810
- xt();
7810
+ kt();
7811
7811
  }, [De, n]), se(() => {
7812
7812
  ae === "complete" && (ne.current += 1, c(""));
7813
7813
  }, [ae]);
@@ -7822,8 +7822,8 @@ function Sa() {
7822
7822
  k(`Maximum ${yn} attachments per message.`);
7823
7823
  break;
7824
7824
  }
7825
- const xt = Ie.name.includes(".") ? Ie.name.split(".").pop().toLowerCase() : "";
7826
- if (!Co.has(Ie.type) && !So.has(xt)) {
7825
+ const kt = Ie.name.includes(".") ? Ie.name.split(".").pop().toLowerCase() : "";
7826
+ if (!Co.has(Ie.type) && !So.has(kt)) {
7827
7827
  k(`Unsupported file type: ${Ie.type || Ie.name}`);
7828
7828
  continue;
7829
7829
  }
@@ -7832,14 +7832,14 @@ function Sa() {
7832
7832
  continue;
7833
7833
  }
7834
7834
  const dt = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, nt = Ie.type.startsWith("image/") ? URL.createObjectURL(Ie) : void 0, rn = { localId: dt, file: Ie, previewUrl: nt, uploading: !0 };
7835
- Re.push(rn), M.uploadChatAttachment(n, Ie).then((ft) => {
7835
+ Re.push(rn), M.uploadChatAttachment(n, Ie).then((yt) => {
7836
7836
  m(
7837
7837
  (Ft) => Ft.map(
7838
- (_t) => _t.localId === dt ? { ..._t, uploading: !1, uploadedId: ft.id } : _t
7838
+ (_t) => _t.localId === dt ? { ..._t, uploading: !1, uploadedId: yt.id } : _t
7839
7839
  )
7840
- ), ft.warning && k(`"${Ie.name}": ${ft.warning}`);
7841
- }).catch((ft) => {
7842
- const Ft = (ft == null ? void 0 : ft.message) || "Upload failed";
7840
+ ), yt.warning && k(`"${Ie.name}": ${yt.warning}`);
7841
+ }).catch((yt) => {
7842
+ const Ft = (yt == null ? void 0 : yt.message) || "Upload failed";
7843
7843
  k(`"${Ie.name}": ${Ft}`), m(
7844
7844
  (_t) => _t.map(
7845
7845
  (sn) => sn.localId === dt ? { ...sn, uploading: !1, error: Ft } : sn
@@ -7909,10 +7909,10 @@ function Sa() {
7909
7909
  C("idle");
7910
7910
  return;
7911
7911
  }
7912
- const Re = te.mimeType || ((dt = fe[0]) == null ? void 0 : dt.type) || "audio/webm", Ie = new Blob(fe, { type: Re }), xt = (Re.split(";")[0].split("/")[1] || "webm").toLowerCase();
7912
+ const Re = te.mimeType || ((dt = fe[0]) == null ? void 0 : dt.type) || "audio/webm", Ie = new Blob(fe, { type: Re }), kt = (Re.split(";")[0].split("/")[1] || "webm").toLowerCase();
7913
7913
  C("transcribing");
7914
7914
  try {
7915
- const nt = await _o(Ie), rn = await K(nt, xt, n);
7915
+ const nt = await _o(Ie), rn = await K(nt, kt, n);
7916
7916
  Fr(rn);
7917
7917
  } catch (nt) {
7918
7918
  k(nt instanceof Error ? nt.message : e("chat.transcribeFailed"));
@@ -7942,7 +7942,7 @@ function Sa() {
7942
7942
  {
7943
7943
  ref: ue,
7944
7944
  className: "absolute inset-0 overflow-y-auto px-4 py-6",
7945
- onScroll: gt,
7945
+ onScroll: ft,
7946
7946
  children: /* @__PURE__ */ r(
7947
7947
  "div",
7948
7948
  {
@@ -8213,7 +8213,7 @@ function To({
8213
8213
  scope: "col",
8214
8214
  className: "border-b border-line px-3 py-2 font-semibold text-fg",
8215
8215
  style: { textAlign: a[o] || "left" },
8216
- children: wt(i)
8216
+ children: gt(i)
8217
8217
  },
8218
8218
  o
8219
8219
  )) }) }),
@@ -8222,7 +8222,7 @@ function To({
8222
8222
  {
8223
8223
  className: "px-3 py-2 align-top text-fg",
8224
8224
  style: { textAlign: a[l] || "left" },
8225
- children: wt(i[l] || "")
8225
+ children: gt(i[l] || "")
8226
8226
  },
8227
8227
  l
8228
8228
  )) }, o)) })
@@ -8260,54 +8260,55 @@ function Ro({ content: e }) {
8260
8260
  h < n.length ? Kt(n[h]) : null
8261
8261
  );
8262
8262
  if (c && d && c.length === d.length) {
8263
- const g = [];
8264
- let m = h, x = h + 1;
8265
- for (; x < n.length; ) {
8266
- if (n[x].trim() === "") {
8267
- let b = x + 1;
8268
- for (; b < n.length && n[b].trim() === ""; ) b += 1;
8269
- const f = b < n.length ? Kt(n[b]) : null;
8270
- if (f && f.length === c.length && !bn(f)) {
8271
- x = b;
8263
+ const m = [];
8264
+ let x = h, k = h + 1;
8265
+ for (; k < n.length; ) {
8266
+ if (n[k].trim() === "") {
8267
+ let f = k + 1;
8268
+ for (; f < n.length && n[f].trim() === ""; ) f += 1;
8269
+ const A = f < n.length ? Kt(n[f]) : null;
8270
+ if (A && A.length === c.length && !bn(A)) {
8271
+ k = f;
8272
8272
  continue;
8273
8273
  }
8274
8274
  break;
8275
8275
  }
8276
- const k = Kt(n[x]);
8277
- if (!k || k.length !== c.length || bn(k)) break;
8278
- g.push(k), m = x, x += 1;
8276
+ const b = Kt(n[k]);
8277
+ if (!b || b.length !== c.length || bn(b)) break;
8278
+ m.push(b), x = k, k += 1;
8279
8279
  }
8280
8280
  a.push(
8281
8281
  /* @__PURE__ */ t(
8282
8282
  To,
8283
8283
  {
8284
8284
  header: c,
8285
- rows: g,
8285
+ rows: m,
8286
8286
  alignments: d
8287
8287
  },
8288
8288
  `table-${s}`
8289
8289
  )
8290
- ), s = m;
8290
+ ), s = x;
8291
8291
  continue;
8292
8292
  }
8293
- if (l.startsWith("### "))
8293
+ const g = l.match(/^(#{1,6})\s+(.*)$/);
8294
+ if (g && g[1].length >= 3)
8294
8295
  a.push(
8295
- /* @__PURE__ */ t("h4", { className: "mt-3 mb-1 font-semibold", children: l.slice(4) }, s)
8296
+ /* @__PURE__ */ t("h4", { className: "mt-3 mb-1 font-semibold", children: gt(g[2]) }, s)
8296
8297
  );
8297
- else if (l.startsWith("## "))
8298
+ else if (g)
8298
8299
  a.push(
8299
- /* @__PURE__ */ t("h3", { className: "mt-3 mb-1 text-base font-semibold", children: l.slice(3) }, s)
8300
+ /* @__PURE__ */ t("h3", { className: "mt-3 mb-1 text-base font-semibold", children: gt(g[2]) }, s)
8300
8301
  );
8301
8302
  else if (/^\s*[-*•]\s+/.test(l)) {
8302
- const g = l.replace(/^\s*[-*•]\s+/, "");
8303
+ const m = l.replace(/^\s*[-*•]\s+/, "");
8303
8304
  a.push(
8304
8305
  /* @__PURE__ */ r("div", { className: "ml-3 flex gap-1", children: [
8305
8306
  /* @__PURE__ */ t("span", { className: "text-fg-muted", children: "•" }),
8306
- /* @__PURE__ */ t("span", { children: wt(g) })
8307
+ /* @__PURE__ */ t("span", { children: gt(m) })
8307
8308
  ] }, s)
8308
8309
  );
8309
8310
  } else l.trim() === "" ? a.push(/* @__PURE__ */ t("div", { className: "h-2" }, s)) : a.push(
8310
- /* @__PURE__ */ t("p", { className: "leading-relaxed", children: wt(l) }, s)
8311
+ /* @__PURE__ */ t("p", { className: "leading-relaxed", children: gt(l) }, s)
8311
8312
  );
8312
8313
  }
8313
8314
  return /* @__PURE__ */ t("div", { children: a });
@@ -8327,14 +8328,14 @@ function Dr(e, n, a) {
8327
8328
  );
8328
8329
  }
8329
8330
  const Io = /(https?:\/\/[^\s)\]}"'<>]+|\/(?:reports|app|masters|admin|chat|setup|tutorial)[^\s)\]}"'<>]*)/g;
8330
- function wt(e) {
8331
+ function gt(e) {
8331
8332
  return e.split(/(\[[^\]]+\]\([^)]+\)|\*\*[^*]+?\*\*|`[^`]+`)/g).flatMap((a, i) => {
8332
8333
  const o = a.match(/^\[([^\]]+)\]\(([^)]+)\)$/);
8333
8334
  if (o) {
8334
8335
  const [, s, l] = o;
8335
- return Dr(l, wt(s), i);
8336
+ return Dr(l, gt(s), i);
8336
8337
  }
8337
- return a.startsWith("**") && a.endsWith("**") && a.length > 4 ? /* @__PURE__ */ t("strong", { className: "font-semibold", children: wt(a.slice(2, -2)) }, i) : a.startsWith("`") && a.endsWith("`") ? /* @__PURE__ */ t(
8338
+ return a.startsWith("**") && a.endsWith("**") && a.length > 4 ? /* @__PURE__ */ t("strong", { className: "font-semibold", children: gt(a.slice(2, -2)) }, i) : a.startsWith("`") && a.endsWith("`") ? /* @__PURE__ */ t(
8338
8339
  "code",
8339
8340
  {
8340
8341
  className: "rounded bg-gray-200 px-1 py-0.5 text-xs font-mono",
@@ -10815,7 +10816,7 @@ function Qc() {
10815
10816
  ];
10816
10817
  }
10817
10818
  function Yc({ slug: e, parentSlug: n, linkField: a }) {
10818
- const { name: i = "" } = bt(), o = Ue();
10819
+ const { name: i = "" } = vt(), o = Ue();
10819
10820
  return se(() => {
10820
10821
  let s = !0;
10821
10822
  return M.getDocument(e, i).then((l) => {