@universe-platform/ui 0.1.0-beta.67 → 0.1.0-beta.68

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
@@ -60,12 +60,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
60
60
  // src/index.ts
61
61
  var src_exports = {};
62
62
  __export(src_exports, {
63
+ BOOLEAN_BUTTON_FALSE_ID: () => BOOLEAN_BUTTON_FALSE_ID,
64
+ BOOLEAN_BUTTON_TRUE_ID: () => BOOLEAN_BUTTON_TRUE_ID,
63
65
  COLUMN_CAPABILITIES: () => COLUMN_CAPABILITIES,
64
66
  COLUMN_DEFAULT_INPUT_CONFIG: () => COLUMN_DEFAULT_INPUT_CONFIG,
65
67
  COLUMN_TYPES: () => COLUMN_TYPES,
66
68
  COLUMN_TYPE_LABELS: () => COLUMN_TYPE_LABELS,
67
69
  ColumnHeaderTitle: () => ColumnHeaderTitle,
68
70
  CreateTemplateModal: () => CreateTemplateModal,
71
+ DEFAULT_BOOLEAN_FALSE_LABEL: () => DEFAULT_BOOLEAN_FALSE_LABEL,
72
+ DEFAULT_BOOLEAN_TRUE_LABEL: () => DEFAULT_BOOLEAN_TRUE_LABEL,
69
73
  DEFAULT_FILTER_COLUMN_TYPES: () => DEFAULT_FILTER_COLUMN_TYPES,
70
74
  DEFAULT_PLACEMENT_STATUS_COLORS: () => DEFAULT_PLACEMENT_STATUS_COLORS,
71
75
  DatePickerCell: () => DatePickerCell,
@@ -139,6 +143,7 @@ __export(src_exports, {
139
143
  formatTimeInput: () => formatTimeInput,
140
144
  formatTimeIso: () => formatTimeIso,
141
145
  generateWhatsAppLink: () => generateWhatsAppLink,
146
+ getBooleanButtonLabels: () => getBooleanButtonLabels,
142
147
  getColumnDefaultFilter: () => getColumnDefaultFilter,
143
148
  getDefaultFilterColumns: () => getDefaultFilterColumns,
144
149
  getDeterministicPastelBadge: () => getDeterministicPastelBadge,
@@ -156,6 +161,7 @@ __export(src_exports, {
156
161
  hasConsecutiveVariables: () => hasConsecutiveVariables,
157
162
  hasFloatingVariables: () => hasFloatingVariables,
158
163
  hasInsufficientContextBetweenVariables: () => hasInsufficientContextBetweenVariables,
164
+ isBooleanButtonsColumn: () => isBooleanButtonsColumn,
159
165
  isDuplicateTemplate: () => isDuplicateTemplate,
160
166
  isDuplicateTemplateName: () => isDuplicateTemplateName,
161
167
  isPerRecordSourceColumn: () => isPerRecordSourceColumn,
@@ -1509,12 +1515,31 @@ function renameCopyTarget(col, oldName, newName) {
1509
1515
 
1510
1516
  // ../shared/src/relationButtons.ts
1511
1517
  var RELATION_BUTTON_COUNTS_ACTION = "FETCH_RELATION_BUTTON_COUNTS";
1518
+ var BOOLEAN_BUTTON_TRUE_ID = "true";
1519
+ var BOOLEAN_BUTTON_FALSE_ID = "false";
1520
+ var DEFAULT_BOOLEAN_TRUE_LABEL = "\u05DB\u05DF";
1521
+ var DEFAULT_BOOLEAN_FALSE_LABEL = "\u05DC\u05D0";
1512
1522
  function isRelationButtonsColumn(col) {
1513
1523
  var _a, _b;
1514
1524
  return !!col && String(col.type).toUpperCase() === "RELATION" && ((_a = col.config) == null ? void 0 : _a.showAsButtons) === true && !!((_b = col.config) == null ? void 0 : _b.referencedTableId);
1515
1525
  }
1526
+ function isBooleanButtonsColumn(col) {
1527
+ var _a;
1528
+ return !!col && String(col.type).toUpperCase() === "BOOLEAN" && ((_a = col.config) == null ? void 0 : _a.showAsButtons) === true;
1529
+ }
1530
+ function getBooleanButtonLabels(col) {
1531
+ var _a, _b, _c, _d;
1532
+ const t = String((_b = (_a = col == null ? void 0 : col.config) == null ? void 0 : _a.buttonsTrueLabel) != null ? _b : "").trim();
1533
+ const f = String((_d = (_c = col == null ? void 0 : col.config) == null ? void 0 : _c.buttonsFalseLabel) != null ? _d : "").trim();
1534
+ return {
1535
+ trueLabel: t || DEFAULT_BOOLEAN_TRUE_LABEL,
1536
+ falseLabel: f || DEFAULT_BOOLEAN_FALSE_LABEL
1537
+ };
1538
+ }
1516
1539
  function getRelationButtonColumns(columns) {
1517
- return (columns || []).filter((c) => isRelationButtonsColumn(c) && c.name !== "_id");
1540
+ return (columns || []).filter(
1541
+ (c) => (isRelationButtonsColumn(c) || isBooleanButtonsColumn(c)) && c.name !== "_id"
1542
+ );
1518
1543
  }
1519
1544
 
1520
1545
  // ../shared/src/defaultFilters.ts
@@ -1717,7 +1742,7 @@ function buildIfExpression(columns, conds, joiner, thenVal, elseVal) {
1717
1742
  }
1718
1743
 
1719
1744
  // src/components/TableBlock/TableBlockClient.tsx
1720
- var import_react19 = __toESM(require("react"));
1745
+ var import_react20 = __toESM(require("react"));
1721
1746
 
1722
1747
  // src/hooks/useToast.ts
1723
1748
  var import_react2 = require("react");
@@ -7364,68 +7389,139 @@ function RelationFilterPopover({
7364
7389
  }
7365
7390
 
7366
7391
  // src/components/TableBlock/RelationButtonsBar.tsx
7367
- var import_react17 = require("react");
7392
+ var import_react18 = require("react");
7368
7393
 
7369
7394
  // src/components/TableBlock/RelationButtonsView.tsx
7395
+ var import_react17 = require("react");
7370
7396
  var import_jsx_runtime15 = require("react/jsx-runtime");
7371
- function RelationButtonsView({ groups, onSelect, disabled, stacked = false }) {
7397
+ var MIN_GROUP_WIDTH = 140;
7398
+ function RelationButtonsView({
7399
+ groups,
7400
+ onSelect,
7401
+ disabled,
7402
+ stacked = false,
7403
+ widths,
7404
+ onResize,
7405
+ onResizeEnd
7406
+ }) {
7407
+ const containerRef = (0, import_react17.useRef)(null);
7408
+ const dragRef = (0, import_react17.useRef)(null);
7409
+ const resizable = !stacked && !!onResize;
7372
7410
  const visible = groups.filter((g) => g.options.length > 0);
7373
7411
  if (visible.length === 0) return null;
7374
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: `grid grid-cols-1 gap-2.5 ${stacked ? "" : "md:grid-cols-2"}`, children: visible.map((group) => {
7375
- const titleIsDuplicate = group.options.some(
7376
- (opt) => opt.label.trim() === group.title.trim()
7377
- );
7378
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
7379
- "div",
7380
- {
7381
- className: "bg-white border border-slate-200 rounded-xl px-3 py-2.5 shadow-2xs",
7382
- children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-wrap items-end gap-x-2 gap-y-2.5", children: [
7383
- !titleIsDuplicate && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
7384
- "span",
7385
- {
7386
- className: "self-end h-8 inline-flex items-center text-xs font-bold text-slate-800 max-w-[10rem] truncate",
7387
- title: group.title,
7388
- children: group.title
7389
- }
7390
- ),
7391
- group.options.map((opt) => {
7392
- const active = group.activeId === opt.id;
7393
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-col items-center gap-0.5", children: [
7394
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
7395
- "span",
7396
- {
7397
- className: `text-[11px] font-bold leading-none ${active ? "text-indigo-700" : "text-slate-500"}`,
7398
- children: opt.count
7399
- }
7400
- ),
7401
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
7402
- "button",
7412
+ const handlePointerDown = (e, key) => {
7413
+ var _a, _b;
7414
+ if (!onResize) return;
7415
+ e.preventDefault();
7416
+ const box = e.currentTarget.parentElement;
7417
+ const rtl = getComputedStyle(box).direction === "rtl";
7418
+ dragRef.current = {
7419
+ key,
7420
+ startX: e.clientX,
7421
+ startWidth: box.getBoundingClientRect().width,
7422
+ // הידית בקצה הסופי של המתחם: ב-RTL זה הצד השמאלי (גרירה שמאלה מגדילה), ב-LTR הצד הימני
7423
+ sign: rtl ? -1 : 1,
7424
+ max: (_b = (_a = containerRef.current) == null ? void 0 : _a.clientWidth) != null ? _b : 4e3
7425
+ };
7426
+ e.currentTarget.setPointerCapture(e.pointerId);
7427
+ };
7428
+ const handlePointerMove = (e) => {
7429
+ const d = dragRef.current;
7430
+ if (!d || !onResize) return;
7431
+ const next = d.startWidth + (e.clientX - d.startX) * d.sign;
7432
+ const clamped = Math.max(MIN_GROUP_WIDTH, Math.min(d.max, next));
7433
+ onResize(d.key, Math.round(clamped));
7434
+ };
7435
+ const handlePointerUp = () => {
7436
+ if (!dragRef.current) return;
7437
+ dragRef.current = null;
7438
+ onResizeEnd == null ? void 0 : onResizeEnd();
7439
+ };
7440
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
7441
+ "div",
7442
+ {
7443
+ ref: containerRef,
7444
+ className: `flex gap-2.5 ${stacked ? "flex-col" : "flex-wrap items-start"}`,
7445
+ children: visible.map((group) => {
7446
+ const titleIsDuplicate = group.options.some(
7447
+ (opt) => opt.label.trim() === group.title.trim()
7448
+ );
7449
+ const customWidth = resizable ? widths == null ? void 0 : widths[group.key] : void 0;
7450
+ const sizeClass = stacked ? "w-full" : customWidth ? "" : "w-full md:w-[calc(50%_-_5px)]";
7451
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
7452
+ "div",
7453
+ {
7454
+ style: customWidth ? { width: customWidth, maxWidth: "100%" } : void 0,
7455
+ className: `relative min-w-0 bg-white border border-slate-200 rounded-xl px-3 py-2.5 shadow-2xs ${sizeClass}`,
7456
+ children: [
7457
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-wrap items-end gap-x-2 gap-y-2.5", children: [
7458
+ !titleIsDuplicate && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
7459
+ "span",
7460
+ {
7461
+ className: "self-end h-8 inline-flex items-center text-xs font-bold text-slate-800 max-w-[10rem] truncate",
7462
+ title: group.title,
7463
+ children: group.title
7464
+ }
7465
+ ),
7466
+ group.options.map((opt) => {
7467
+ const active = group.activeId === opt.id;
7468
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-col items-center gap-0.5", children: [
7469
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
7470
+ "span",
7471
+ {
7472
+ className: `text-[11px] font-bold leading-none ${active ? "text-indigo-700" : "text-slate-500"}`,
7473
+ children: opt.count
7474
+ }
7475
+ ),
7476
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
7477
+ "button",
7478
+ {
7479
+ type: "button",
7480
+ disabled,
7481
+ onClick: () => onSelect(group.key, active ? void 0 : opt.id),
7482
+ title: active ? "\u05DC\u05D7\u05E5 \u05DC\u05D1\u05D9\u05D8\u05D5\u05DC \u05D4\u05E1\u05D9\u05E0\u05D5\u05DF" : `\u05E1\u05E0\u05DF \u05DC\u05E4\u05D9: ${opt.label}`,
7483
+ "aria-pressed": active,
7484
+ className: `px-3 h-8 rounded-md border text-xs font-semibold whitespace-nowrap shadow-2xs transition-colors cursor-pointer disabled:opacity-50 disabled:pointer-events-none ${active ? "bg-indigo-600 border-indigo-600 text-white hover:bg-indigo-700" : "bg-white border-slate-300 text-slate-700 hover:bg-slate-50 hover:border-slate-400"}`,
7485
+ children: opt.label
7486
+ }
7487
+ )
7488
+ ] }, opt.id);
7489
+ }),
7490
+ group.activeId ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
7491
+ "button",
7492
+ {
7493
+ type: "button",
7494
+ onClick: () => onSelect(group.key, void 0),
7495
+ className: "self-end h-8 inline-flex items-center px-1 text-[11px] font-semibold text-rose-600 hover:text-rose-700 hover:underline cursor-pointer shrink-0 whitespace-nowrap",
7496
+ children: "\u05E0\u05E7\u05D4 \u05E1\u05D9\u05E0\u05D5\u05DF"
7497
+ }
7498
+ ) : null
7499
+ ] }),
7500
+ resizable && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
7501
+ "div",
7403
7502
  {
7404
- type: "button",
7405
- disabled,
7406
- onClick: () => onSelect(group.key, active ? void 0 : opt.id),
7407
- title: active ? "\u05DC\u05D7\u05E5 \u05DC\u05D1\u05D9\u05D8\u05D5\u05DC \u05D4\u05E1\u05D9\u05E0\u05D5\u05DF" : `\u05E1\u05E0\u05DF \u05DC\u05E4\u05D9: ${opt.label}`,
7408
- "aria-pressed": active,
7409
- className: `px-3 h-8 rounded-md border text-xs font-semibold whitespace-nowrap shadow-2xs transition-colors cursor-pointer disabled:opacity-50 disabled:pointer-events-none ${active ? "bg-indigo-600 border-indigo-600 text-white hover:bg-indigo-700" : "bg-white border-slate-300 text-slate-700 hover:bg-slate-50 hover:border-slate-400"}`,
7410
- children: opt.label
7503
+ role: "separator",
7504
+ "aria-orientation": "vertical",
7505
+ title: "\u05D2\u05E8\u05D5\u05E8 \u05DC\u05E9\u05D9\u05E0\u05D5\u05D9 \u05D4\u05E8\u05D5\u05D7\u05D1 (\u05DC\u05D7\u05D9\u05E6\u05D4 \u05DB\u05E4\u05D5\u05DC\u05D4 \u05DC\u05D0\u05D9\u05E4\u05D5\u05E1)",
7506
+ onPointerDown: (e) => handlePointerDown(e, group.key),
7507
+ onPointerMove: handlePointerMove,
7508
+ onPointerUp: handlePointerUp,
7509
+ onPointerCancel: handlePointerUp,
7510
+ onDoubleClick: () => {
7511
+ onResize == null ? void 0 : onResize(group.key, void 0);
7512
+ onResizeEnd == null ? void 0 : onResizeEnd();
7513
+ },
7514
+ className: "group/handle absolute top-0 bottom-0 end-0 w-2.5 cursor-col-resize touch-none z-10 flex items-center justify-center",
7515
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "h-8 w-0.5 rounded-full bg-slate-300 group-hover/handle:bg-brand transition-colors" })
7411
7516
  }
7412
7517
  )
7413
- ] }, opt.id);
7414
- }),
7415
- group.activeId ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
7416
- "button",
7417
- {
7418
- type: "button",
7419
- onClick: () => onSelect(group.key, void 0),
7420
- className: "self-end h-8 inline-flex items-center px-1 text-[11px] font-semibold text-rose-600 hover:text-rose-700 hover:underline cursor-pointer shrink-0 whitespace-nowrap",
7421
- children: "\u05E0\u05E7\u05D4 \u05E1\u05D9\u05E0\u05D5\u05DF"
7422
- }
7423
- ) : null
7424
- ] })
7425
- },
7426
- group.key
7427
- );
7428
- }) });
7518
+ ]
7519
+ },
7520
+ group.key
7521
+ );
7522
+ })
7523
+ }
7524
+ );
7429
7525
  }
7430
7526
 
7431
7527
  // src/components/TableBlock/RelationButtonsBar.tsx
@@ -7444,13 +7540,44 @@ function RelationButtonsBar({
7444
7540
  refreshToken,
7445
7541
  disabled
7446
7542
  }) {
7447
- const buttonCols = (0, import_react17.useMemo)(() => getRelationButtonColumns(columns), [columns]);
7448
- const colsKey = (0, import_react17.useMemo)(() => buttonCols.map((c) => c.name).join("|"), [buttonCols]);
7449
- const [counts, setCounts] = (0, import_react17.useState)({});
7450
- const requestIdRef = (0, import_react17.useRef)(0);
7451
- const actionRef = (0, import_react17.useRef)(executeAction);
7543
+ const buttonCols = (0, import_react18.useMemo)(() => getRelationButtonColumns(columns), [columns]);
7544
+ const colsKey = (0, import_react18.useMemo)(() => buttonCols.map((c) => c.name).join("|"), [buttonCols]);
7545
+ const [counts, setCounts] = (0, import_react18.useState)({});
7546
+ const requestIdRef = (0, import_react18.useRef)(0);
7547
+ const actionRef = (0, import_react18.useRef)(executeAction);
7452
7548
  actionRef.current = executeAction;
7453
- (0, import_react17.useEffect)(() => {
7549
+ const widthsStorageKey = tableId ? `relation_buttons_widths_${tableId}` : "";
7550
+ const [widths, setWidths] = (0, import_react18.useState)({});
7551
+ const widthsRef = (0, import_react18.useRef)({});
7552
+ widthsRef.current = widths;
7553
+ (0, import_react18.useEffect)(() => {
7554
+ if (typeof window === "undefined" || !widthsStorageKey) return;
7555
+ try {
7556
+ const saved = localStorage.getItem(widthsStorageKey);
7557
+ setWidths(saved ? JSON.parse(saved) : {});
7558
+ } catch (e) {
7559
+ console.error(`Failed to load relation button widths for key "${widthsStorageKey}":`, e);
7560
+ }
7561
+ }, [widthsStorageKey]);
7562
+ const handleResize = (0, import_react18.useCallback)((colName, width) => {
7563
+ setWidths((prev) => {
7564
+ const next = __spreadValues({}, prev);
7565
+ if (width === void 0) delete next[colName];
7566
+ else next[colName] = width;
7567
+ return next;
7568
+ });
7569
+ }, []);
7570
+ const handleResizeEnd = (0, import_react18.useCallback)(() => {
7571
+ if (typeof window === "undefined" || !widthsStorageKey) return;
7572
+ setTimeout(() => {
7573
+ try {
7574
+ localStorage.setItem(widthsStorageKey, JSON.stringify(widthsRef.current));
7575
+ } catch (e) {
7576
+ console.error(`Failed to save relation button widths for key "${widthsStorageKey}":`, e);
7577
+ }
7578
+ }, 0);
7579
+ }, [widthsStorageKey]);
7580
+ (0, import_react18.useEffect)(() => {
7454
7581
  if (!colsKey || !tableId || !actionRef.current) return;
7455
7582
  const myId = ++requestIdRef.current;
7456
7583
  const timer = setTimeout(() => {
@@ -7461,10 +7588,15 @@ function RelationButtonsBar({
7461
7588
  }, 250);
7462
7589
  return () => clearTimeout(timer);
7463
7590
  }, [colsKey, tableId, refreshToken]);
7464
- const groups = (0, import_react17.useMemo)(
7591
+ const groups = (0, import_react18.useMemo)(
7465
7592
  () => buttonCols.map((col) => {
7466
7593
  const v = columnFilters == null ? void 0 : columnFilters[col.name];
7467
- const activeId = Array.isArray(v) && v.length === 1 ? String(v[0]) : null;
7594
+ let activeId = null;
7595
+ if (isBooleanButtonsColumn(col)) {
7596
+ activeId = v === "true" || v === "false" ? v : null;
7597
+ } else {
7598
+ activeId = Array.isArray(v) && v.length === 1 ? String(v[0]) : null;
7599
+ }
7468
7600
  return {
7469
7601
  key: col.name,
7470
7602
  title: col.name,
@@ -7474,6 +7606,19 @@ function RelationButtonsBar({
7474
7606
  }),
7475
7607
  [buttonCols, counts, columnFilters]
7476
7608
  );
7609
+ const handleSelect = (0, import_react18.useCallback)(
7610
+ (colName, id) => {
7611
+ const col = buttonCols.find((c) => c.name === colName);
7612
+ if (id === void 0) {
7613
+ onApplyFilter(colName, void 0);
7614
+ } else if (isBooleanButtonsColumn(col)) {
7615
+ onApplyFilter(colName, id);
7616
+ } else {
7617
+ onApplyFilter(colName, [id]);
7618
+ }
7619
+ },
7620
+ [buttonCols, onApplyFilter]
7621
+ );
7477
7622
  if (buttonCols.length === 0 || groups.every((g) => g.options.length === 0)) return null;
7478
7623
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
7479
7624
  "div",
@@ -7485,7 +7630,10 @@ function RelationButtonsBar({
7485
7630
  {
7486
7631
  groups,
7487
7632
  disabled,
7488
- onSelect: (colName, id) => onApplyFilter(colName, id ? [id] : void 0)
7633
+ onSelect: handleSelect,
7634
+ widths,
7635
+ onResize: handleResize,
7636
+ onResizeEnd: handleResizeEnd
7489
7637
  }
7490
7638
  )
7491
7639
  }
@@ -7493,7 +7641,7 @@ function RelationButtonsBar({
7493
7641
  }
7494
7642
 
7495
7643
  // src/components/TableBlock/useDefaultColumnFilters.ts
7496
- var import_react18 = require("react");
7644
+ var import_react19 = require("react");
7497
7645
  var RESOLVE_TIMEOUT_MS = 8e3;
7498
7646
  function unwrap2(res) {
7499
7647
  const body = (res == null ? void 0 : res.data) && typeof res.data === "object" && !Array.isArray(res.data) ? res.data : res;
@@ -7502,13 +7650,13 @@ function unwrap2(res) {
7502
7650
  }
7503
7651
  function useDefaultColumnFilters({ columns, tableId, executeAction, onResolved }) {
7504
7652
  const hasDefaults = getDefaultFilterColumns(columns).length > 0;
7505
- const [ready, setReady] = (0, import_react18.useState)(() => !hasDefaults);
7506
- const doneRef = (0, import_react18.useRef)(false);
7507
- const onResolvedRef = (0, import_react18.useRef)(onResolved);
7653
+ const [ready, setReady] = (0, import_react19.useState)(() => !hasDefaults);
7654
+ const doneRef = (0, import_react19.useRef)(false);
7655
+ const onResolvedRef = (0, import_react19.useRef)(onResolved);
7508
7656
  onResolvedRef.current = onResolved;
7509
- const actionRef = (0, import_react18.useRef)(executeAction);
7657
+ const actionRef = (0, import_react19.useRef)(executeAction);
7510
7658
  actionRef.current = executeAction;
7511
- (0, import_react18.useEffect)(() => {
7659
+ (0, import_react19.useEffect)(() => {
7512
7660
  if (doneRef.current || !hasDefaults) return;
7513
7661
  doneRef.current = true;
7514
7662
  const exec = actionRef.current;
@@ -7565,10 +7713,10 @@ function TableBlockClient({
7565
7713
  renderRowExtra
7566
7714
  }) {
7567
7715
  const { showError, addToast } = useToast();
7568
- const [isExporting, setIsExporting] = (0, import_react19.useState)(false);
7569
- const [isExportMenuOpen, setIsExportMenuOpen] = (0, import_react19.useState)(false);
7570
- const exportMenuRef = (0, import_react19.useRef)(null);
7571
- (0, import_react19.useEffect)(() => {
7716
+ const [isExporting, setIsExporting] = (0, import_react20.useState)(false);
7717
+ const [isExportMenuOpen, setIsExportMenuOpen] = (0, import_react20.useState)(false);
7718
+ const exportMenuRef = (0, import_react20.useRef)(null);
7719
+ (0, import_react20.useEffect)(() => {
7572
7720
  if (!isExportMenuOpen) return;
7573
7721
  const handleClickOutside = (e) => {
7574
7722
  if (exportMenuRef.current && !exportMenuRef.current.contains(e.target)) {
@@ -7603,18 +7751,18 @@ function TableBlockClient({
7603
7751
  return calculateMinColumnWidth(colName, false, col == null ? void 0 : col.type);
7604
7752
  }
7605
7753
  });
7606
- const executeActionRef = (0, import_react19.useRef)(executeAction);
7607
- (0, import_react19.useEffect)(() => {
7754
+ const executeActionRef = (0, import_react20.useRef)(executeAction);
7755
+ (0, import_react20.useEffect)(() => {
7608
7756
  executeActionRef.current = executeAction;
7609
7757
  }, [executeAction]);
7610
- const [isMounted, setIsMounted] = (0, import_react19.useState)(false);
7611
- const [isInitialLoading, setIsInitialLoading] = (0, import_react19.useState)(true);
7612
- const [page, setPage] = (0, import_react19.useState)(1);
7613
- const [limit, setLimit] = (0, import_react19.useState)(50);
7614
- const [totalRecords, setTotalRecords] = (0, import_react19.useState)(0);
7615
- const [totalPages, setTotalPages] = (0, import_react19.useState)(1);
7616
- const [showSummary, setShowSummary] = (0, import_react19.useState)(false);
7617
- (0, import_react19.useEffect)(() => {
7758
+ const [isMounted, setIsMounted] = (0, import_react20.useState)(false);
7759
+ const [isInitialLoading, setIsInitialLoading] = (0, import_react20.useState)(true);
7760
+ const [page, setPage] = (0, import_react20.useState)(1);
7761
+ const [limit, setLimit] = (0, import_react20.useState)(50);
7762
+ const [totalRecords, setTotalRecords] = (0, import_react20.useState)(0);
7763
+ const [totalPages, setTotalPages] = (0, import_react20.useState)(1);
7764
+ const [showSummary, setShowSummary] = (0, import_react20.useState)(false);
7765
+ (0, import_react20.useEffect)(() => {
7618
7766
  if (typeof window !== "undefined") {
7619
7767
  const savedSummary = localStorage.getItem(`table_summary_${tableKey}`);
7620
7768
  if (savedSummary !== null) {
@@ -7663,7 +7811,7 @@ function TableBlockClient({
7663
7811
  return __spreadProps(__spreadValues({}, row), { id: String(row.id || ""), data: rowData });
7664
7812
  });
7665
7813
  };
7666
- const mergeColumnDefs = (0, import_react19.useCallback)((existingCols, incomingCols) => {
7814
+ const mergeColumnDefs = (0, import_react20.useCallback)((existingCols, incomingCols) => {
7667
7815
  if (!incomingCols || incomingCols.length === 0) return existingCols || [];
7668
7816
  if (!existingCols || existingCols.length === 0) return incomingCols;
7669
7817
  const existingMap = new Map(existingCols.map((c) => [c.name, c]));
@@ -7683,18 +7831,18 @@ function TableBlockClient({
7683
7831
  return ((_a = a.order) != null ? _a : 0) - ((_b = b.order) != null ? _b : 0);
7684
7832
  });
7685
7833
  }, []);
7686
- const [localColumns, setLocalColumns] = (0, import_react19.useState)(() => (schema == null ? void 0 : schema.columns) || []);
7687
- (0, import_react19.useEffect)(() => {
7834
+ const [localColumns, setLocalColumns] = (0, import_react20.useState)(() => (schema == null ? void 0 : schema.columns) || []);
7835
+ (0, import_react20.useEffect)(() => {
7688
7836
  if ((schema == null ? void 0 : schema.columns) && schema.columns.length > 0) {
7689
7837
  setLocalColumns((prev) => mergeColumnDefs(prev, schema.columns));
7690
7838
  }
7691
7839
  }, [schema == null ? void 0 : schema.columns, mergeColumnDefs]);
7692
- const [dirty, setDirty] = (0, import_react19.useState)({ added: [], modified: {}, deleted: [] });
7693
- const dirtyRef = (0, import_react19.useRef)(dirty);
7694
- (0, import_react19.useEffect)(() => {
7840
+ const [dirty, setDirty] = (0, import_react20.useState)({ added: [], modified: {}, deleted: [] });
7841
+ const dirtyRef = (0, import_react20.useRef)(dirty);
7842
+ (0, import_react20.useEffect)(() => {
7695
7843
  dirtyRef.current = dirty;
7696
7844
  }, [dirty]);
7697
- const mergeWithDirty = (0, import_react19.useCallback)((baseRecords) => {
7845
+ const mergeWithDirty = (0, import_react20.useCallback)((baseRecords) => {
7698
7846
  const { added, modified, deleted } = dirtyRef.current;
7699
7847
  const nonDeleted = (baseRecords || []).filter((r) => !deleted.includes(r.id));
7700
7848
  const modifiedRecords = nonDeleted.map((r) => {
@@ -7707,8 +7855,8 @@ function TableBlockClient({
7707
7855
  const uniqueAdded = added.filter((r) => !baseIds.has(r.id));
7708
7856
  return [...uniqueAdded, ...modifiedRecords];
7709
7857
  }, []);
7710
- const [data, setData] = (0, import_react19.useState)(() => normalizeRecords(initialRecords));
7711
- const [serverRecords, setServerRecords] = (0, import_react19.useState)(() => normalizeRecords(initialRecords));
7858
+ const [data, setData] = (0, import_react20.useState)(() => normalizeRecords(initialRecords));
7859
+ const [serverRecords, setServerRecords] = (0, import_react20.useState)(() => normalizeRecords(initialRecords));
7712
7860
  const filteredData = data;
7713
7861
  const isEqualValues = (a, b) => {
7714
7862
  if (a === b) return true;
@@ -7720,30 +7868,30 @@ function TableBlockClient({
7720
7868
  }
7721
7869
  return false;
7722
7870
  };
7723
- const [baseRecordsMap, setBaseRecordsMap] = (0, import_react19.useState)(() => {
7871
+ const [baseRecordsMap, setBaseRecordsMap] = (0, import_react20.useState)(() => {
7724
7872
  const map = /* @__PURE__ */ new Map();
7725
7873
  (normalizeRecords(initialRecords) || []).forEach((r) => map.set(r.id, __spreadValues({}, r.data)));
7726
7874
  return map;
7727
7875
  });
7728
- (0, import_react19.useEffect)(() => {
7876
+ (0, import_react20.useEffect)(() => {
7729
7877
  if (initialRecords && initialRecords.length > 0) {
7730
7878
  const map = /* @__PURE__ */ new Map();
7731
7879
  (normalizeRecords(initialRecords) || []).forEach((r) => map.set(r.id, __spreadValues({}, r.data)));
7732
7880
  setBaseRecordsMap(map);
7733
7881
  }
7734
7882
  }, [initialRecords]);
7735
- const [searchQuery, setSearchQuery] = (0, import_react19.useState)("");
7736
- const [columnFilters, setColumnFilters] = (0, import_react19.useState)({});
7737
- const [activeSearchCol, setActiveSearchCol] = (0, import_react19.useState)(null);
7738
- const activeSearchRef = (0, import_react19.useRef)(null);
7739
- const [activeRelationCol, setActiveRelationCol] = (0, import_react19.useState)(null);
7740
- const [relationTriggerRect, setRelationTriggerRect] = (0, import_react19.useState)(null);
7741
- const filterButtonRefs = (0, import_react19.useRef)({});
7742
- const [relationOptions, setRelationOptions] = (0, import_react19.useState)({});
7743
- const [relationFilterOptions, setRelationFilterOptions] = (0, import_react19.useState)({});
7744
- const [loadingFilterCol, setLoadingFilterCol] = (0, import_react19.useState)(null);
7745
- const relationDictionaryRef = (0, import_react19.useRef)({});
7746
- const mergeRelationOptions = (0, import_react19.useCallback)((colName, newOptions) => {
7883
+ const [searchQuery, setSearchQuery] = (0, import_react20.useState)("");
7884
+ const [columnFilters, setColumnFilters] = (0, import_react20.useState)({});
7885
+ const [activeSearchCol, setActiveSearchCol] = (0, import_react20.useState)(null);
7886
+ const activeSearchRef = (0, import_react20.useRef)(null);
7887
+ const [activeRelationCol, setActiveRelationCol] = (0, import_react20.useState)(null);
7888
+ const [relationTriggerRect, setRelationTriggerRect] = (0, import_react20.useState)(null);
7889
+ const filterButtonRefs = (0, import_react20.useRef)({});
7890
+ const [relationOptions, setRelationOptions] = (0, import_react20.useState)({});
7891
+ const [relationFilterOptions, setRelationFilterOptions] = (0, import_react20.useState)({});
7892
+ const [loadingFilterCol, setLoadingFilterCol] = (0, import_react20.useState)(null);
7893
+ const relationDictionaryRef = (0, import_react20.useRef)({});
7894
+ const mergeRelationOptions = (0, import_react20.useCallback)((colName, newOptions) => {
7747
7895
  if (!Array.isArray(newOptions) || newOptions.length === 0) return;
7748
7896
  if (!relationDictionaryRef.current[colName]) {
7749
7897
  relationDictionaryRef.current[colName] = /* @__PURE__ */ new Map();
@@ -7766,7 +7914,7 @@ function TableBlockClient({
7766
7914
  }));
7767
7915
  }
7768
7916
  }, []);
7769
- (0, import_react19.useEffect)(() => {
7917
+ (0, import_react20.useEffect)(() => {
7770
7918
  if (!activeSearchCol) return;
7771
7919
  const handleMouseDown = (e) => {
7772
7920
  if (activeSearchRef.current && !activeSearchRef.current.contains(e.target)) {
@@ -7778,7 +7926,7 @@ function TableBlockClient({
7778
7926
  document.removeEventListener("mousedown", handleMouseDown);
7779
7927
  };
7780
7928
  }, [activeSearchCol]);
7781
- const filtersKey = (0, import_react19.useMemo)(() => {
7929
+ const filtersKey = (0, import_react20.useMemo)(() => {
7782
7930
  const active = {};
7783
7931
  Object.entries(columnFilters).forEach(([k, v]) => {
7784
7932
  if (Array.isArray(v) && v.length > 0) active[k] = v;
@@ -7793,24 +7941,24 @@ function TableBlockClient({
7793
7941
  executeAction,
7794
7942
  onResolved: (resolved) => setColumnFilters((prev) => __spreadValues(__spreadValues({}, resolved), prev))
7795
7943
  });
7796
- const [debouncedSearch, setDebouncedSearch] = (0, import_react19.useState)(searchQuery);
7797
- (0, import_react19.useEffect)(() => {
7944
+ const [debouncedSearch, setDebouncedSearch] = (0, import_react20.useState)(searchQuery);
7945
+ (0, import_react20.useEffect)(() => {
7798
7946
  const timer = setTimeout(() => {
7799
7947
  setDebouncedSearch(searchQuery.trim());
7800
7948
  }, 300);
7801
7949
  return () => clearTimeout(timer);
7802
7950
  }, [searchQuery]);
7803
- const isSearchMountedRef = (0, import_react19.useRef)(false);
7804
- (0, import_react19.useEffect)(() => {
7951
+ const isSearchMountedRef = (0, import_react20.useRef)(false);
7952
+ (0, import_react20.useEffect)(() => {
7805
7953
  if (!isSearchMountedRef.current) {
7806
7954
  isSearchMountedRef.current = true;
7807
7955
  return;
7808
7956
  }
7809
7957
  setPage(1);
7810
7958
  }, [debouncedSearch]);
7811
- const [isFetching, setIsFetching] = (0, import_react19.useState)(false);
7812
- const fetchRequestIdRef = (0, import_react19.useRef)(0);
7813
- const fetchTableData = (0, import_react19.useCallback)((targetPage, targetLimit, targetSearch, targetFiltersKey) => {
7959
+ const [isFetching, setIsFetching] = (0, import_react20.useState)(false);
7960
+ const fetchRequestIdRef = (0, import_react20.useRef)(0);
7961
+ const fetchTableData = (0, import_react20.useCallback)((targetPage, targetLimit, targetSearch, targetFiltersKey) => {
7814
7962
  const tableId = (schema == null ? void 0 : schema.tableMetaId) || (schema == null ? void 0 : schema.tableId) || (schema == null ? void 0 : schema.id);
7815
7963
  const action = executeActionRef.current;
7816
7964
  if (!tableId || !action) {
@@ -7934,11 +8082,11 @@ function TableBlockClient({
7934
8082
  }
7935
8083
  });
7936
8084
  }, [schema == null ? void 0 : schema.tableMetaId, schema == null ? void 0 : schema.tableId, schema == null ? void 0 : schema.id, mergeColumnDefs, mergeWithDirty, mergeRelationOptions]);
7937
- (0, import_react19.useEffect)(() => {
8085
+ (0, import_react20.useEffect)(() => {
7938
8086
  if (!defaultFiltersReady) return;
7939
8087
  fetchTableData(page, limit, debouncedSearch, filtersKey);
7940
8088
  }, [page, limit, debouncedSearch, filtersKey, fetchTableData, defaultFiltersReady]);
7941
- (0, import_react19.useEffect)(() => {
8089
+ (0, import_react20.useEffect)(() => {
7942
8090
  if (initialRecords && defaultFiltersReady) {
7943
8091
  const norm2 = normalizeRecords(initialRecords);
7944
8092
  setServerRecords(norm2);
@@ -8001,10 +8149,10 @@ function TableBlockClient({
8001
8149
  }
8002
8150
  }
8003
8151
  }, [initialRecords, mergeWithDirty, debouncedSearch, columnFilters, fetchTableData, page, limit, filtersKey, defaultFiltersReady]);
8004
- const refetchTableData = (0, import_react19.useCallback)(() => {
8152
+ const refetchTableData = (0, import_react20.useCallback)(() => {
8005
8153
  return fetchTableData(page, limit, debouncedSearch, filtersKey);
8006
8154
  }, [page, limit, debouncedSearch, filtersKey, fetchTableData]);
8007
- const handleApplyColumnFilter = (0, import_react19.useCallback)((colName, nextVal) => {
8155
+ const handleApplyColumnFilter = (0, import_react20.useCallback)((colName, nextVal) => {
8008
8156
  setColumnFilters((prev) => {
8009
8157
  const next = __spreadValues({}, prev);
8010
8158
  if (nextVal === void 0 || Array.isArray(nextVal) && nextVal.length === 0 || typeof nextVal === "string" && !nextVal.trim() || typeof nextVal === "object" && "values" in nextVal && Array.isArray(nextVal.values) && nextVal.values.length === 0) {
@@ -8029,9 +8177,9 @@ function TableBlockClient({
8029
8177
  const handleNextPage = () => {
8030
8178
  setPage((prev) => Math.min(totalPages, prev + 1));
8031
8179
  };
8032
- const [selectedIds, setSelectedIds] = (0, import_react19.useState)(/* @__PURE__ */ new Set());
8033
- const isExternalSyncRef = (0, import_react19.useRef)(false);
8034
- (0, import_react19.useEffect)(() => {
8180
+ const [selectedIds, setSelectedIds] = (0, import_react20.useState)(/* @__PURE__ */ new Set());
8181
+ const isExternalSyncRef = (0, import_react20.useRef)(false);
8182
+ (0, import_react20.useEffect)(() => {
8035
8183
  if (selectedRowIds !== void 0) {
8036
8184
  const nextSet = new Set(selectedRowIds);
8037
8185
  setSelectedIds((prev) => {
@@ -8043,8 +8191,8 @@ function TableBlockClient({
8043
8191
  });
8044
8192
  }
8045
8193
  }, [selectedRowIds]);
8046
- const isFirstSelectionChangeRef = (0, import_react19.useRef)(true);
8047
- (0, import_react19.useEffect)(() => {
8194
+ const isFirstSelectionChangeRef = (0, import_react20.useRef)(true);
8195
+ (0, import_react20.useEffect)(() => {
8048
8196
  if (isFirstSelectionChangeRef.current) {
8049
8197
  isFirstSelectionChangeRef.current = false;
8050
8198
  if (selectedIds.size === 0) return;
@@ -8055,13 +8203,13 @@ function TableBlockClient({
8055
8203
  }
8056
8204
  onSelectionChange == null ? void 0 : onSelectionChange(Array.from(selectedIds));
8057
8205
  }, [selectedIds, onSelectionChange]);
8058
- const [pendingDeletions, setPendingDeletions] = (0, import_react19.useState)([]);
8059
- const [isSaving, setIsSaving] = (0, import_react19.useState)(false);
8206
+ const [pendingDeletions, setPendingDeletions] = (0, import_react20.useState)([]);
8207
+ const [isSaving, setIsSaving] = (0, import_react20.useState)(false);
8060
8208
  const isUpdatingActive = Boolean(isUpdating || isSaving);
8061
- const [isSaveSuccess, setIsSaveSuccess] = (0, import_react19.useState)(false);
8062
- const [expandedRowIds, setExpandedRowIds] = (0, import_react19.useState)(/* @__PURE__ */ new Set());
8063
- const schemaColsString = (0, import_react19.useMemo)(() => JSON.stringify(localColumns || []), [localColumns]);
8064
- const refetchRelation = (0, import_react19.useCallback)(async (colName, params) => {
8209
+ const [isSaveSuccess, setIsSaveSuccess] = (0, import_react20.useState)(false);
8210
+ const [expandedRowIds, setExpandedRowIds] = (0, import_react20.useState)(/* @__PURE__ */ new Set());
8211
+ const schemaColsString = (0, import_react20.useMemo)(() => JSON.stringify(localColumns || []), [localColumns]);
8212
+ const refetchRelation = (0, import_react20.useCallback)(async (colName, params) => {
8065
8213
  var _a, _b, _c, _d, _e, _f, _g;
8066
8214
  let parsedCols = [];
8067
8215
  try {
@@ -8100,7 +8248,7 @@ function TableBlockClient({
8100
8248
  }
8101
8249
  return [];
8102
8250
  }, [schemaColsString, executeAction, mergeRelationOptions]);
8103
- const fetchRelationFilterOptions = (0, import_react19.useCallback)(async (colName) => {
8251
+ const fetchRelationFilterOptions = (0, import_react20.useCallback)(async (colName) => {
8104
8252
  var _a;
8105
8253
  let parsedCols = [];
8106
8254
  try {
@@ -8136,8 +8284,8 @@ function TableBlockClient({
8136
8284
  setLoadingFilterCol(null);
8137
8285
  }
8138
8286
  }, [schemaColsString, schema == null ? void 0 : schema.tableMetaId, schema == null ? void 0 : schema.tableId, schema == null ? void 0 : schema.id, executeAction, mergeRelationOptions]);
8139
- const requestedRelationIdsRef = (0, import_react19.useRef)({});
8140
- (0, import_react19.useEffect)(() => {
8287
+ const requestedRelationIdsRef = (0, import_react20.useRef)({});
8288
+ (0, import_react20.useEffect)(() => {
8141
8289
  if (!executeAction || !data || data.length === 0) return;
8142
8290
  let parsedCols = [];
8143
8291
  try {
@@ -8190,7 +8338,7 @@ function TableBlockClient({
8190
8338
  }
8191
8339
  });
8192
8340
  }, [data, schemaColsString, executeAction, relationOptions, mergeRelationOptions]);
8193
- (0, import_react19.useEffect)(() => {
8341
+ (0, import_react20.useEffect)(() => {
8194
8342
  let parsedCols = [];
8195
8343
  try {
8196
8344
  parsedCols = JSON.parse(schemaColsString);
@@ -8204,7 +8352,7 @@ function TableBlockClient({
8204
8352
  refetchRelation(col.name);
8205
8353
  });
8206
8354
  }, [schemaColsString, refetchRelation]);
8207
- const normalizedColumns = (0, import_react19.useMemo)(() => {
8355
+ const normalizedColumns = (0, import_react20.useMemo)(() => {
8208
8356
  return (localColumns || []).map((col, idx) => {
8209
8357
  const isRequired = col.isRequired === true || String(col.isRequired) === "true";
8210
8358
  const isUnique = col.isUnique === true || String(col.isUnique) === "true";
@@ -8218,17 +8366,17 @@ function TableBlockClient({
8218
8366
  return ((_a = a.order) != null ? _a : 0) - ((_b = b.order) != null ? _b : 0);
8219
8367
  });
8220
8368
  }, [localColumns]);
8221
- const filteredColumns = (0, import_react19.useMemo)(() => {
8369
+ const filteredColumns = (0, import_react20.useMemo)(() => {
8222
8370
  const systemFields = ["_id", "createdAt", "updatedAt", "orgId", "tableId"];
8223
8371
  return normalizedColumns.filter((col) => !systemFields.includes(col.name) && !col.isHidden);
8224
8372
  }, [normalizedColumns]);
8225
- const customizableColumns = (0, import_react19.useMemo)(() => {
8373
+ const customizableColumns = (0, import_react20.useMemo)(() => {
8226
8374
  const systemFields = ["_id", "createdAt", "updatedAt", "orgId", "tableId"];
8227
8375
  return normalizedColumns.filter((col) => !systemFields.includes(col.name));
8228
8376
  }, [normalizedColumns]);
8229
- const [isColumnsDropdownOpen, setIsColumnsDropdownOpen] = (0, import_react19.useState)(false);
8230
- const dropdownRef = (0, import_react19.useRef)(null);
8231
- (0, import_react19.useEffect)(() => {
8377
+ const [isColumnsDropdownOpen, setIsColumnsDropdownOpen] = (0, import_react20.useState)(false);
8378
+ const dropdownRef = (0, import_react20.useRef)(null);
8379
+ (0, import_react20.useEffect)(() => {
8232
8380
  const handleClickOutside = (e) => {
8233
8381
  if (dropdownRef.current && !dropdownRef.current.contains(e.target)) {
8234
8382
  setIsColumnsDropdownOpen(false);
@@ -8470,7 +8618,7 @@ function TableBlockClient({
8470
8618
  setData((prev) => [newRow, ...prev]);
8471
8619
  setDirty((prev) => __spreadProps(__spreadValues({}, prev), { added: [newRow, ...prev.added] }));
8472
8620
  };
8473
- const handleCellChange = (0, import_react19.useCallback)((rowId, colName, value) => {
8621
+ const handleCellChange = (0, import_react20.useCallback)((rowId, colName, value) => {
8474
8622
  setData((prev) => prev.map(
8475
8623
  (row) => row.id === rowId ? __spreadProps(__spreadValues({}, row), { data: __spreadProps(__spreadValues({}, row.data), { [colName]: value }) }) : row
8476
8624
  ));
@@ -8503,13 +8651,13 @@ function TableBlockClient({
8503
8651
  });
8504
8652
  }, [baseRecordsMap]);
8505
8653
  const handleCellChangeWithCopy = useRelationCopyHandler({ columns: localColumns, handleCellChange });
8506
- const triggerSaveSuccess = (0, import_react19.useCallback)(() => {
8654
+ const triggerSaveSuccess = (0, import_react20.useCallback)(() => {
8507
8655
  setIsSaveSuccess(true);
8508
8656
  setTimeout(() => {
8509
8657
  setIsSaveSuccess(false);
8510
8658
  }, 2500);
8511
8659
  }, []);
8512
- const handleQuietCellChange = (0, import_react19.useCallback)((rowId, colName, value) => {
8660
+ const handleQuietCellChange = (0, import_react20.useCallback)((rowId, colName, value) => {
8513
8661
  setData((prev) => prev.map(
8514
8662
  (row) => row.id === rowId ? __spreadProps(__spreadValues({}, row), { data: __spreadProps(__spreadValues({}, row.data), { [colName]: value }) }) : row
8515
8663
  ));
@@ -8533,12 +8681,12 @@ function TableBlockClient({
8533
8681
  });
8534
8682
  }
8535
8683
  }, []);
8536
- const toggleSelectAll = (0, import_react19.useCallback)((checked) => {
8684
+ const toggleSelectAll = (0, import_react20.useCallback)((checked) => {
8537
8685
  onRowToggle == null ? void 0 : onRowToggle("ALL", checked);
8538
8686
  const next = checked ? new Set(filteredData.map((r) => r.id)) : /* @__PURE__ */ new Set();
8539
8687
  setSelectedIds(next);
8540
8688
  }, [filteredData, onRowToggle]);
8541
- const toggleSelectRow = (0, import_react19.useCallback)((rowId, checked) => {
8689
+ const toggleSelectRow = (0, import_react20.useCallback)((rowId, checked) => {
8542
8690
  onRowToggle == null ? void 0 : onRowToggle(rowId, checked);
8543
8691
  setSelectedIds((prev) => {
8544
8692
  const next = new Set(prev);
@@ -8547,7 +8695,7 @@ function TableBlockClient({
8547
8695
  return next;
8548
8696
  });
8549
8697
  }, [onRowToggle]);
8550
- const handleToggleExpand = (0, import_react19.useCallback)((rowId) => {
8698
+ const handleToggleExpand = (0, import_react20.useCallback)((rowId) => {
8551
8699
  setExpandedRowIds((prev) => {
8552
8700
  const next = new Set(prev);
8553
8701
  if (next.has(rowId)) next.delete(rowId);
@@ -8555,7 +8703,7 @@ function TableBlockClient({
8555
8703
  return next;
8556
8704
  });
8557
8705
  }, []);
8558
- const handleMarkForDeletion = (0, import_react19.useCallback)((fileId) => {
8706
+ const handleMarkForDeletion = (0, import_react20.useCallback)((fileId) => {
8559
8707
  setPendingDeletions((prev) => [...prev, fileId]);
8560
8708
  }, []);
8561
8709
  const handleDeleteSelected = () => {
@@ -8784,7 +8932,7 @@ function TableBlockClient({
8784
8932
  setIsSaving(false);
8785
8933
  }
8786
8934
  };
8787
- const getRowRelationLabels = (0, import_react19.useCallback)((rowVal, col) => {
8935
+ const getRowRelationLabels = (0, import_react20.useCallback)((rowVal, col) => {
8788
8936
  const ids = normalizeRelationValue(rowVal);
8789
8937
  if (ids.length === 0) return [];
8790
8938
  const options = relationOptions[col.name] || [];
@@ -8803,7 +8951,7 @@ function TableBlockClient({
8803
8951
  return "";
8804
8952
  }).filter(Boolean);
8805
8953
  }, [relationOptions]);
8806
- const getUniqueRelationOptions = (0, import_react19.useCallback)((col) => {
8954
+ const getUniqueRelationOptions = (0, import_react20.useCallback)((col) => {
8807
8955
  if (relationFilterOptions[col.name]) {
8808
8956
  return relationFilterOptions[col.name];
8809
8957
  }
@@ -8853,7 +9001,7 @@ function TableBlockClient({
8853
9001
  }
8854
9002
  return col.type === "CURRENCY" ? getCurrencySymbol((_c = col.config) == null ? void 0 : _c.currencySymbol) : "";
8855
9003
  };
8856
- const columnTotals = (0, import_react19.useMemo)(() => {
9004
+ const columnTotals = (0, import_react20.useMemo)(() => {
8857
9005
  const totals = {};
8858
9006
  if (!showSummary) return totals;
8859
9007
  filteredColumns.forEach((col) => {
@@ -9603,7 +9751,7 @@ function ExpandedSubTables({
9603
9751
  context
9604
9752
  }) {
9605
9753
  var _a;
9606
- const [activeTab, setActiveTab] = (0, import_react19.useState)((_a = subTableColumns[0]) == null ? void 0 : _a.name);
9754
+ const [activeTab, setActiveTab] = (0, import_react20.useState)((_a = subTableColumns[0]) == null ? void 0 : _a.name);
9607
9755
  if (subTableColumns.length === 0) return null;
9608
9756
  if (subTableColumns.length === 1) {
9609
9757
  const stCol = subTableColumns[0];
@@ -9644,7 +9792,7 @@ function ExpandedSubTables({
9644
9792
  ) })
9645
9793
  ] }) });
9646
9794
  }
9647
- var TableRow = import_react19.default.memo(function TableRow2({
9795
+ var TableRow = import_react20.default.memo(function TableRow2({
9648
9796
  row,
9649
9797
  isSelected,
9650
9798
  rowStatus,
@@ -9677,7 +9825,7 @@ var TableRow = import_react19.default.memo(function TableRow2({
9677
9825
  renderRowExtra
9678
9826
  }) {
9679
9827
  const lockedCopyTargets = getRelationCopyLockedTargets(schema == null ? void 0 : schema.columns);
9680
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react19.default.Fragment, { children: [
9828
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react20.default.Fragment, { children: [
9681
9829
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("tr", { className: `transition-colors group hover:bg-blue-50 ${isSelected ? "bg-blue-50" : ""}`, children: [
9682
9830
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("td", { className: "border-b border-l border-slate-200 p-1.5 text-center bg-white group-hover:bg-transparent", style: { width: 80, minWidth: 80, maxWidth: 80 }, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center justify-center gap-1.5", children: [
9683
9831
  rowStatus && (() => {
@@ -9829,7 +9977,7 @@ var TableRow = import_react19.default.memo(function TableRow2({
9829
9977
  });
9830
9978
 
9831
9979
  // src/components/TableBlock/formTracking/FormTrackingTableBlock.tsx
9832
- var import_react20 = require("react");
9980
+ var import_react21 = require("react");
9833
9981
 
9834
9982
  // src/components/TableBlock/formTracking/formTracking.types.ts
9835
9983
  function getFormTrackingConfig(settings) {
@@ -9870,9 +10018,9 @@ function FormTrackingTableBlock(props) {
9870
10018
  const config = getFormTrackingConfig(settings);
9871
10019
  const { addToast, showError } = useToast();
9872
10020
  const tableId = (settings == null ? void 0 : settings.tableMetaId) || (settings == null ? void 0 : settings.tableId) || (settings == null ? void 0 : settings.id);
9873
- const [sentOverrides, setSentOverrides] = (0, import_react20.useState)({});
9874
- const [busyKey, setBusyKey] = (0, import_react20.useState)(null);
9875
- const copyLink = (0, import_react20.useCallback)(
10021
+ const [sentOverrides, setSentOverrides] = (0, import_react21.useState)({});
10022
+ const [busyKey, setBusyKey] = (0, import_react21.useState)(null);
10023
+ const copyLink = (0, import_react21.useCallback)(
9876
10024
  async (rowId, step) => {
9877
10025
  if (!executeAction || !tableId) return;
9878
10026
  setBusyKey(`${rowId}|${step.formId}|link`);
@@ -9898,7 +10046,7 @@ function FormTrackingTableBlock(props) {
9898
10046
  },
9899
10047
  [executeAction, tableId, addToast, showError]
9900
10048
  );
9901
- const setSent = (0, import_react20.useCallback)(
10049
+ const setSent = (0, import_react21.useCallback)(
9902
10050
  async (rowId, step, value) => {
9903
10051
  if (!executeAction || !tableId || !step.sentColumn) return;
9904
10052
  setBusyKey(`${rowId}|${step.formId}|sent`);
@@ -9920,7 +10068,7 @@ function FormTrackingTableBlock(props) {
9920
10068
  );
9921
10069
  const firstFormStep = config == null ? void 0 : config.steps.find((s) => s.kind === "create");
9922
10070
  const firstFormUrl = firstFormStep && tableId ? `${getPlatformOrigin()}/embed/form/${tableId}?form=${firstFormStep.formId}` : "";
9923
- const copyFirstFormLink = (0, import_react20.useCallback)(async () => {
10071
+ const copyFirstFormLink = (0, import_react21.useCallback)(async () => {
9924
10072
  if (!firstFormUrl) return;
9925
10073
  try {
9926
10074
  await navigator.clipboard.writeText(firstFormUrl);
@@ -9929,7 +10077,7 @@ function FormTrackingTableBlock(props) {
9929
10077
  window.prompt(`\u05D4\u05E7\u05D9\u05E9\u05D5\u05E8 \u05DC"${firstFormStep == null ? void 0 : firstFormStep.label}" - \u05D4\u05E2\u05EA\u05E7 \u05D9\u05D3\u05E0\u05D9\u05EA:`, firstFormUrl);
9930
10078
  }
9931
10079
  }, [firstFormUrl, firstFormStep, addToast]);
9932
- const renderRowExtra = (0, import_react20.useCallback)(
10080
+ const renderRowExtra = (0, import_react21.useCallback)(
9933
10081
  (row) => {
9934
10082
  var _a;
9935
10083
  if (!config) return null;
@@ -10017,13 +10165,13 @@ function TableBlock(props) {
10017
10165
  }
10018
10166
 
10019
10167
  // src/components/PlacementBlock/PlacementBlock.tsx
10020
- var import_react23 = require("react");
10168
+ var import_react24 = require("react");
10021
10169
  var import_ag_grid_react = require("ag-grid-react");
10022
10170
  var import_ag_grid_community = require("ag-grid-community");
10023
10171
  var import_lucide_react10 = require("lucide-react");
10024
10172
 
10025
10173
  // src/components/PlacementBlock/PlacementSettings.tsx
10026
- var import_react21 = __toESM(require("react"));
10174
+ var import_react22 = __toESM(require("react"));
10027
10175
 
10028
10176
  // src/components/PlacementBlock/placementColumns.ts
10029
10177
  var RELATION_SEP = "::";
@@ -10145,7 +10293,7 @@ var SummaryRow = ({ label, value, hint }) => /* @__PURE__ */ (0, import_jsx_runt
10145
10293
  ] });
10146
10294
  var PlacementStatusEditor = ({ config, onChange }) => {
10147
10295
  var _a;
10148
- const radioName = `placement-default-status-${import_react21.default.useId()}`;
10296
+ const radioName = `placement-default-status-${import_react22.default.useId()}`;
10149
10297
  const statuses = ((_a = config.statusColors) == null ? void 0 : _a.length) ? config.statusColors : DEFAULT_PLACEMENT_STATUS_COLORS;
10150
10298
  const defaultStatusId = resolveDefaultStatusId(statuses, config.defaultReturnStatusId);
10151
10299
  const setStatuses = (next, defId = defaultStatusId) => {
@@ -10416,7 +10564,7 @@ var PlacementSettings = ({ config, onChange, tables }) => {
10416
10564
  };
10417
10565
 
10418
10566
  // src/components/PlacementBlock/PlacementRelationButtons.tsx
10419
- var import_react22 = require("react");
10567
+ var import_react23 = require("react");
10420
10568
  var import_jsx_runtime21 = require("react/jsx-runtime");
10421
10569
  var GROUP_COLORS = [
10422
10570
  { title: "bg-blue-600 text-white", active: "bg-blue-600 border-blue-600 text-white hover:bg-blue-700", count: "text-blue-700" },
@@ -10438,7 +10586,7 @@ var PlacementRelationButtons = ({
10438
10586
  relationOptions,
10439
10587
  className = ""
10440
10588
  }) => {
10441
- const groups = (0, import_react22.useMemo)(() => {
10589
+ const groups = (0, import_react23.useMemo)(() => {
10442
10590
  const activeEntries = Object.entries(filters).filter(([, v]) => v !== void 0 && v !== null && v !== "");
10443
10591
  return (columnNames || []).map((colName) => {
10444
10592
  var _a, _b, _c, _d;
@@ -10628,7 +10776,7 @@ var CheckHeader = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div"
10628
10776
  }
10629
10777
  ) });
10630
10778
  var RelationFilterHeader = (props) => {
10631
- const btnRef = (0, import_react23.useRef)(null);
10779
+ const btnRef = (0, import_react24.useRef)(null);
10632
10780
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex flex-col items-center justify-center w-full min-w-0 leading-tight select-none", title: props.displayName, children: [
10633
10781
  /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
10634
10782
  "button",
@@ -10655,20 +10803,20 @@ var RelationFilterHeader = (props) => {
10655
10803
  var PlacementBlock = (props) => {
10656
10804
  var _a, _b;
10657
10805
  const { executeAction, fetchSourceData, fetchTargetData, updateAssignment, className = "" } = props;
10658
- const config = (0, import_react23.useMemo)(() => {
10806
+ const config = (0, import_react24.useMemo)(() => {
10659
10807
  var _a2, _b2, _c;
10660
10808
  const raw = (_a2 = props.config) != null ? _a2 : props.settings;
10661
10809
  if (!raw) return void 0;
10662
10810
  return ((_b2 = raw.config) == null ? void 0 : _b2.sourceTableId) || ((_c = raw.config) == null ? void 0 : _c.targetTableId) ? raw.config : raw;
10663
10811
  }, [props.config, props.settings]);
10664
- const statuses = (0, import_react23.useMemo)(
10812
+ const statuses = (0, import_react24.useMemo)(
10665
10813
  () => {
10666
10814
  var _a2;
10667
10815
  return ((_a2 = config == null ? void 0 : config.statusColors) == null ? void 0 : _a2.length) ? config.statusColors : DEFAULT_PLACEMENT_STATUS_COLORS;
10668
10816
  },
10669
10817
  [config == null ? void 0 : config.statusColors]
10670
10818
  );
10671
- const defaultStatusId = (0, import_react23.useMemo)(
10819
+ const defaultStatusId = (0, import_react24.useMemo)(
10672
10820
  () => resolveDefaultStatusId(statuses, config == null ? void 0 : config.defaultReturnStatusId),
10673
10821
  [statuses, config == null ? void 0 : config.defaultReturnStatusId]
10674
10822
  );
@@ -10676,31 +10824,31 @@ var PlacementBlock = (props) => {
10676
10824
  const targetTableId = config == null ? void 0 : config.targetTableId;
10677
10825
  const displayField = (config == null ? void 0 : config.sourceDisplayFieldId) || "name";
10678
10826
  const assignmentField = config == null ? void 0 : config.targetAssignmentFieldId;
10679
- const executeActionRef = (0, import_react23.useRef)(executeAction);
10827
+ const executeActionRef = (0, import_react24.useRef)(executeAction);
10680
10828
  executeActionRef.current = executeAction;
10681
- const legacyRef = (0, import_react23.useRef)({ fetchSourceData, fetchTargetData, updateAssignment });
10829
+ const legacyRef = (0, import_react24.useRef)({ fetchSourceData, fetchTargetData, updateAssignment });
10682
10830
  legacyRef.current = { fetchSourceData, fetchTargetData, updateAssignment };
10683
- const [sourceRows, setSourceRows] = (0, import_react23.useState)([]);
10684
- const [sourceColumns, setSourceColumns] = (0, import_react23.useState)([]);
10685
- const [sourceRelOptions, setSourceRelOptions] = (0, import_react23.useState)({});
10686
- const [sourceRelFilters, setSourceRelFilters] = (0, import_react23.useState)({});
10687
- const [targetRows, setTargetRows] = (0, import_react23.useState)([]);
10688
- const [targetColumns, setTargetColumns] = (0, import_react23.useState)([]);
10689
- const [targetRelOptions, setTargetRelOptions] = (0, import_react23.useState)({});
10690
- const [selectedTargetId, setSelectedTargetId] = (0, import_react23.useState)("");
10691
- const [candidateIds, setCandidateIds] = (0, import_react23.useState)([]);
10692
- const [checkedIds, setCheckedIds] = (0, import_react23.useState)([]);
10693
- const [isSaving, setIsSaving] = (0, import_react23.useState)(false);
10694
- const [sourceSearch, setSourceSearch] = (0, import_react23.useState)("");
10695
- const [candidateSearch, setCandidateSearch] = (0, import_react23.useState)("");
10696
- const [statusMap, setStatusMap] = (0, import_react23.useState)({});
10697
- const [isLoading, setIsLoading] = (0, import_react23.useState)(false);
10698
- const [loadError, setLoadError] = (0, import_react23.useState)(null);
10699
- const [saveError, setSaveError] = (0, import_react23.useState)(null);
10700
- const [colFilters, setColFilters] = (0, import_react23.useState)({ source: {}, cand: {} });
10701
- const [filterPopover, setFilterPopover] = (0, import_react23.useState)(null);
10702
- const [targetFilters, setTargetFilters] = (0, import_react23.useState)({});
10703
- const loadTable = (0, import_react23.useCallback)(async (tableId, kind) => {
10831
+ const [sourceRows, setSourceRows] = (0, import_react24.useState)([]);
10832
+ const [sourceColumns, setSourceColumns] = (0, import_react24.useState)([]);
10833
+ const [sourceRelOptions, setSourceRelOptions] = (0, import_react24.useState)({});
10834
+ const [sourceRelFilters, setSourceRelFilters] = (0, import_react24.useState)({});
10835
+ const [targetRows, setTargetRows] = (0, import_react24.useState)([]);
10836
+ const [targetColumns, setTargetColumns] = (0, import_react24.useState)([]);
10837
+ const [targetRelOptions, setTargetRelOptions] = (0, import_react24.useState)({});
10838
+ const [selectedTargetId, setSelectedTargetId] = (0, import_react24.useState)("");
10839
+ const [candidateIds, setCandidateIds] = (0, import_react24.useState)([]);
10840
+ const [checkedIds, setCheckedIds] = (0, import_react24.useState)([]);
10841
+ const [isSaving, setIsSaving] = (0, import_react24.useState)(false);
10842
+ const [sourceSearch, setSourceSearch] = (0, import_react24.useState)("");
10843
+ const [candidateSearch, setCandidateSearch] = (0, import_react24.useState)("");
10844
+ const [statusMap, setStatusMap] = (0, import_react24.useState)({});
10845
+ const [isLoading, setIsLoading] = (0, import_react24.useState)(false);
10846
+ const [loadError, setLoadError] = (0, import_react24.useState)(null);
10847
+ const [saveError, setSaveError] = (0, import_react24.useState)(null);
10848
+ const [colFilters, setColFilters] = (0, import_react24.useState)({ source: {}, cand: {} });
10849
+ const [filterPopover, setFilterPopover] = (0, import_react24.useState)(null);
10850
+ const [targetFilters, setTargetFilters] = (0, import_react24.useState)({});
10851
+ const loadTable = (0, import_react24.useCallback)(async (tableId, kind) => {
10704
10852
  const exec = executeActionRef.current;
10705
10853
  if (exec) {
10706
10854
  const res = await exec("FETCH_TABLE_DATA", { tableId, tableMetaId: tableId, limit: FETCH_LIMIT, skip: 0 });
@@ -10713,7 +10861,7 @@ var PlacementBlock = (props) => {
10713
10861
  }
10714
10862
  throw new Error("executeAction \u05DC\u05D0 \u05D4\u05D5\u05E2\u05D1\u05E8 \u05DC\u05E8\u05DB\u05D9\u05D1 \u05D4\u05E9\u05D9\u05D1\u05D5\u05E5");
10715
10863
  }, []);
10716
- (0, import_react23.useEffect)(() => {
10864
+ (0, import_react24.useEffect)(() => {
10717
10865
  if (!sourceTableId || !targetTableId) return;
10718
10866
  let cancelled = false;
10719
10867
  (async () => {
@@ -10741,7 +10889,7 @@ var PlacementBlock = (props) => {
10741
10889
  cancelled = true;
10742
10890
  };
10743
10891
  }, [sourceTableId, targetTableId, loadTable]);
10744
- const displayValue = (0, import_react23.useCallback)((col, val) => {
10892
+ const displayValue = (0, import_react24.useCallback)((col, val) => {
10745
10893
  var _a2, _b2, _c, _d, _e;
10746
10894
  let text2 = cellText(val);
10747
10895
  if (text2 && /^[a-fA-F0-9]{24}$/.test(text2)) {
@@ -10761,7 +10909,7 @@ var PlacementBlock = (props) => {
10761
10909
  }
10762
10910
  return text2;
10763
10911
  }, [targetRelOptions, targetRows, sourceRows]);
10764
- const relationLabelMaps = (0, import_react23.useMemo)(() => {
10912
+ const relationLabelMaps = (0, import_react24.useMemo)(() => {
10765
10913
  const maps = {};
10766
10914
  Object.entries(sourceRelOptions || {}).forEach(([colName, opts]) => {
10767
10915
  const m = /* @__PURE__ */ new Map();
@@ -10774,7 +10922,7 @@ var PlacementBlock = (props) => {
10774
10922
  });
10775
10923
  return maps;
10776
10924
  }, [sourceRelOptions]);
10777
- const relationLabelsOf = (0, import_react23.useCallback)((row, colName) => {
10925
+ const relationLabelsOf = (0, import_react24.useCallback)((row, colName) => {
10778
10926
  var _a2;
10779
10927
  const map = relationLabelMaps[colName];
10780
10928
  const ids = normalizeRelationValue((_a2 = row.data) == null ? void 0 : _a2[colName]);
@@ -10783,7 +10931,7 @@ var PlacementBlock = (props) => {
10783
10931
  const txt = cellText(readColumnValue(row.data, colName));
10784
10932
  return txt && !/^[a-fA-F0-9]{24}$/.test(txt) ? txt.split(", ").filter(Boolean) : [];
10785
10933
  }, [relationLabelMaps]);
10786
- const rowPassesColFilters = (0, import_react23.useCallback)((row, filters) => {
10934
+ const rowPassesColFilters = (0, import_react24.useCallback)((row, filters) => {
10787
10935
  return Object.entries(filters).every(([colName, f]) => {
10788
10936
  if (!f) return true;
10789
10937
  const labels = relationLabelsOf(row, colName);
@@ -10792,7 +10940,7 @@ var PlacementBlock = (props) => {
10792
10940
  return true;
10793
10941
  });
10794
10942
  }, [relationLabelsOf]);
10795
- const setColFilter = (0, import_react23.useCallback)((grid, colName, payload) => {
10943
+ const setColFilter = (0, import_react24.useCallback)((grid, colName, payload) => {
10796
10944
  setColFilters((prev) => {
10797
10945
  const next = __spreadValues({}, prev[grid]);
10798
10946
  if (payload === void 0) delete next[colName];
@@ -10800,11 +10948,11 @@ var PlacementBlock = (props) => {
10800
10948
  return __spreadProps(__spreadValues({}, prev), { [grid]: next });
10801
10949
  });
10802
10950
  }, []);
10803
- const openColFilter = (0, import_react23.useCallback)((grid, colName, rect) => {
10951
+ const openColFilter = (0, import_react24.useCallback)((grid, colName, rect) => {
10804
10952
  setFilterPopover((cur) => cur && cur.grid === grid && cur.colName === colName ? null : { grid, colName, rect });
10805
10953
  }, []);
10806
- const closeColFilter = (0, import_react23.useCallback)(() => setFilterPopover(null), []);
10807
- const filterColumns = (0, import_react23.useMemo)(() => {
10954
+ const closeColFilter = (0, import_react24.useCallback)(() => setFilterPopover(null), []);
10955
+ const filterColumns = (0, import_react24.useMemo)(() => {
10808
10956
  const definedFilters = (config == null ? void 0 : config.filterFields) || [];
10809
10957
  const legacyFilters = [config == null ? void 0 : config.targetFilterField1Id, config == null ? void 0 : config.targetFilterField2Id].filter(Boolean);
10810
10958
  const fieldsToUse = definedFilters.length > 0 ? definedFilters : legacyFilters;
@@ -10830,7 +10978,7 @@ var PlacementBlock = (props) => {
10830
10978
  return targetColumns.filter((c) => isUserColumn(c) && c.name !== assignmentField && !["id", "_id", "id_", "statusId"].includes(c.name)).slice(0, 3);
10831
10979
  }, [targetColumns, assignmentField, config]);
10832
10980
  const rawSelectorField = (config == null ? void 0 : config.targetSelectorFieldId) || (config == null ? void 0 : config.targetDisplayFieldId) || ((_a = filterColumns[0]) == null ? void 0 : _a.name) || "";
10833
- const selectorField = (0, import_react23.useMemo)(() => {
10981
+ const selectorField = (0, import_react24.useMemo)(() => {
10834
10982
  const { relationColumn } = parseColumnRef(rawSelectorField);
10835
10983
  if (relationColumn && !targetColumns.some((c) => c.name === rawSelectorField) && targetColumns.some((c) => {
10836
10984
  var _a2;
@@ -10840,7 +10988,7 @@ var PlacementBlock = (props) => {
10840
10988
  }
10841
10989
  return rawSelectorField;
10842
10990
  }, [rawSelectorField, targetColumns]);
10843
- const filteredTargetRows = (0, import_react23.useMemo)(() => {
10991
+ const filteredTargetRows = (0, import_react24.useMemo)(() => {
10844
10992
  return targetRows.filter((r) => {
10845
10993
  return filterColumns.every((col) => {
10846
10994
  const filterVal = targetFilters[col.name];
@@ -10849,7 +10997,7 @@ var PlacementBlock = (props) => {
10849
10997
  });
10850
10998
  });
10851
10999
  }, [targetRows, targetFilters, filterColumns, displayValue]);
10852
- (0, import_react23.useEffect)(() => {
11000
+ (0, import_react24.useEffect)(() => {
10853
11001
  if (filteredTargetRows.length > 0) {
10854
11002
  if (!selectedTargetId || !filteredTargetRows.some((r) => r.id === selectedTargetId)) {
10855
11003
  setSelectedTargetId(filteredTargetRows[0].id);
@@ -10858,8 +11006,8 @@ var PlacementBlock = (props) => {
10858
11006
  setSelectedTargetId("");
10859
11007
  }
10860
11008
  }, [filteredTargetRows, selectedTargetId]);
10861
- const appliedDefaultsKeyRef = (0, import_react23.useRef)("");
10862
- (0, import_react23.useEffect)(() => {
11009
+ const appliedDefaultsKeyRef = (0, import_react24.useRef)("");
11010
+ (0, import_react24.useEffect)(() => {
10863
11011
  const defaults = config == null ? void 0 : config.targetFilterDefaults;
10864
11012
  if (isLoading || !defaults || targetRows.length === 0 || targetColumns.length === 0) return;
10865
11013
  const key = `${targetTableId}|${JSON.stringify(defaults)}`;
@@ -10874,11 +11022,11 @@ var PlacementBlock = (props) => {
10874
11022
  });
10875
11023
  if (Object.keys(resolved).length > 0) setTargetFilters((prev) => __spreadValues(__spreadValues({}, resolved), prev));
10876
11024
  }, [config, isLoading, targetRows, targetColumns, targetTableId, displayValue]);
10877
- const assignmentColumn = (0, import_react23.useMemo)(() => targetColumns.find((c) => c.name === assignmentField), [targetColumns, assignmentField]);
11025
+ const assignmentColumn = (0, import_react24.useMemo)(() => targetColumns.find((c) => c.name === assignmentField), [targetColumns, assignmentField]);
10878
11026
  const isRelationField = ((_b = assignmentColumn == null ? void 0 : assignmentColumn.type) == null ? void 0 : _b.toUpperCase()) === "RELATION";
10879
11027
  const assignmentLabel = (assignmentColumn == null ? void 0 : assignmentColumn.label) || (assignmentColumn == null ? void 0 : assignmentColumn.name) || assignmentField || "";
10880
- const nameOf = (0, import_react23.useCallback)((row) => cellText(readColumnValue(row.data, displayField)) || "\u05DC\u05DC\u05D0 \u05E9\u05DD", [displayField]);
10881
- const assignedIds = (0, import_react23.useMemo)(() => {
11028
+ const nameOf = (0, import_react24.useCallback)((row) => cellText(readColumnValue(row.data, displayField)) || "\u05DC\u05DC\u05D0 \u05E9\u05DD", [displayField]);
11029
+ const assignedIds = (0, import_react24.useMemo)(() => {
10882
11030
  var _a2;
10883
11031
  const target = targetRows.find((r) => r.id === selectedTargetId);
10884
11032
  if (!target || !assignmentField) return [];
@@ -10892,36 +11040,36 @@ var PlacementBlock = (props) => {
10892
11040
  }).filter((id) => !!id && sourceRows.some((s) => s.id === id));
10893
11041
  return Array.from(new Set(ids));
10894
11042
  }, [selectedTargetId, targetRows, sourceRows, assignmentField, isRelationField, nameOf]);
10895
- const assignedIdsRef = (0, import_react23.useRef)(assignedIds);
11043
+ const assignedIdsRef = (0, import_react24.useRef)(assignedIds);
10896
11044
  assignedIdsRef.current = assignedIds;
10897
- (0, import_react23.useEffect)(() => {
11045
+ (0, import_react24.useEffect)(() => {
10898
11046
  setCandidateIds(assignedIdsRef.current);
10899
11047
  setCheckedIds(assignedIdsRef.current);
10900
11048
  }, [selectedTargetId, sourceRows]);
10901
- const toGridRow = (0, import_react23.useCallback)((r, checked = false) => __spreadProps(__spreadValues({}, r.data), { id: r.id, __label: nameOf(r), __checked: checked, statusId: statusMap[r.id] || defaultStatusId }), [nameOf, statusMap, defaultStatusId]);
10902
- const candidateRows = (0, import_react23.useMemo)(() => candidateIds.map((id) => sourceRows.find((r) => r.id === id)).filter((r) => !!r), [candidateIds, sourceRows]);
10903
- const candidateGridData = (0, import_react23.useMemo)(() => {
11049
+ const toGridRow = (0, import_react24.useCallback)((r, checked = false) => __spreadProps(__spreadValues({}, r.data), { id: r.id, __label: nameOf(r), __checked: checked, statusId: statusMap[r.id] || defaultStatusId }), [nameOf, statusMap, defaultStatusId]);
11050
+ const candidateRows = (0, import_react24.useMemo)(() => candidateIds.map((id) => sourceRows.find((r) => r.id === id)).filter((r) => !!r), [candidateIds, sourceRows]);
11051
+ const candidateGridData = (0, import_react24.useMemo)(() => {
10904
11052
  const checked = new Set(checkedIds);
10905
11053
  return candidateRows.filter((r) => rowPassesColFilters(r, colFilters.cand)).map((r) => toGridRow(r, checked.has(r.id)));
10906
11054
  }, [candidateRows, checkedIds, toGridRow, rowPassesColFilters, colFilters.cand]);
10907
- const availableRows = (0, import_react23.useMemo)(() => {
11055
+ const availableRows = (0, import_react24.useMemo)(() => {
10908
11056
  const set = new Set(candidateIds);
10909
11057
  return sourceRows.filter((r) => !set.has(r.id));
10910
11058
  }, [candidateIds, sourceRows]);
10911
- const relationButtonColumns = (0, import_react23.useMemo)(() => {
11059
+ const relationButtonColumns = (0, import_react24.useMemo)(() => {
10912
11060
  const wanted = Array.isArray(config == null ? void 0 : config.relationButtonColumns) ? config.relationButtonColumns : [];
10913
11061
  return wanted.filter((name) => sourceColumns.some((c) => (c == null ? void 0 : c.name) === name && String(c == null ? void 0 : c.type).toUpperCase() === "RELATION"));
10914
11062
  }, [config, sourceColumns]);
10915
11063
  const hasRelationButtons = relationButtonColumns.length > 0;
10916
- const handleRelationFilterChange = (0, import_react23.useCallback)((colName, id) => {
11064
+ const handleRelationFilterChange = (0, import_react24.useCallback)((colName, id) => {
10917
11065
  setSourceRelFilters((prev) => __spreadProps(__spreadValues({}, prev), { [colName]: id }));
10918
11066
  }, []);
10919
- const availableGridData = (0, import_react23.useMemo)(() => {
11067
+ const availableGridData = (0, import_react24.useMemo)(() => {
10920
11068
  const active = Object.entries(sourceRelFilters).filter(([name, v]) => !!v && relationButtonColumns.includes(name));
10921
11069
  const byButtons = active.length === 0 ? availableRows : availableRows.filter((r) => active.every(([name, v]) => rowMatchesRelationFilter(r, name, v)));
10922
11070
  return byButtons.filter((r) => rowPassesColFilters(r, colFilters.source)).map((r) => toGridRow(r));
10923
11071
  }, [availableRows, sourceRelFilters, relationButtonColumns, toGridRow, rowPassesColFilters, colFilters.source]);
10924
- const persistAssignment = (0, import_react23.useCallback)(async (nextIds) => {
11072
+ const persistAssignment = (0, import_react24.useCallback)(async (nextIds) => {
10925
11073
  const exec = executeActionRef.current;
10926
11074
  if (exec && targetTableId && assignmentField && selectedTargetId) {
10927
11075
  const value = isRelationField ? nextIds : nextIds.map((id) => sourceRows.find((r) => r.id === id)).filter((r) => !!r).map(nameOf).join(", ");
@@ -10933,33 +11081,33 @@ var PlacementBlock = (props) => {
10933
11081
  for (const id of nextIds.filter((i) => !assignedIds.includes(i))) await legacyRef.current.updateAssignment(selectedTargetId, id);
10934
11082
  }
10935
11083
  }, [targetTableId, assignmentField, selectedTargetId, isRelationField, sourceRows, nameOf, assignedIds]);
10936
- const moveToCandidates = (0, import_react23.useCallback)((id) => {
11084
+ const moveToCandidates = (0, import_react24.useCallback)((id) => {
10937
11085
  setCandidateIds((prev) => prev.includes(id) ? prev : [...prev, id]);
10938
11086
  }, []);
10939
- const moveToSource = (0, import_react23.useCallback)((id) => {
11087
+ const moveToSource = (0, import_react24.useCallback)((id) => {
10940
11088
  setCandidateIds((prev) => prev.filter((x) => x !== id));
10941
11089
  setCheckedIds((prev) => prev.filter((x) => x !== id));
10942
11090
  setStatusMap((prev) => __spreadProps(__spreadValues({}, prev), { [id]: defaultStatusId }));
10943
11091
  }, [defaultStatusId]);
10944
- const moveToCandidatesRef = (0, import_react23.useRef)(moveToCandidates);
11092
+ const moveToCandidatesRef = (0, import_react24.useRef)(moveToCandidates);
10945
11093
  moveToCandidatesRef.current = moveToCandidates;
10946
- const moveToSourceRef = (0, import_react23.useRef)(moveToSource);
11094
+ const moveToSourceRef = (0, import_react24.useRef)(moveToSource);
10947
11095
  moveToSourceRef.current = moveToSource;
10948
- const toggleChecked = (0, import_react23.useCallback)((id) => {
11096
+ const toggleChecked = (0, import_react24.useCallback)((id) => {
10949
11097
  setCheckedIds((prev) => prev.includes(id) ? prev.filter((x) => x !== id) : [...prev, id]);
10950
11098
  }, []);
10951
11099
  const allChecked = candidateIds.length > 0 && candidateIds.every((id) => checkedIds.includes(id));
10952
11100
  const someChecked = candidateIds.some((id) => checkedIds.includes(id));
10953
- const toggleAll = (0, import_react23.useCallback)(() => {
11101
+ const toggleAll = (0, import_react24.useCallback)(() => {
10954
11102
  setCheckedIds(allChecked ? [] : [...candidateIds]);
10955
11103
  }, [allChecked, candidateIds]);
10956
- const returnAll = (0, import_react23.useCallback)(() => {
11104
+ const returnAll = (0, import_react24.useCallback)(() => {
10957
11105
  setCandidateIds([]);
10958
11106
  setCheckedIds([]);
10959
11107
  }, []);
10960
- const checkedCandidates = (0, import_react23.useMemo)(() => candidateIds.filter((id) => checkedIds.includes(id)), [candidateIds, checkedIds]);
11108
+ const checkedCandidates = (0, import_react24.useMemo)(() => candidateIds.filter((id) => checkedIds.includes(id)), [candidateIds, checkedIds]);
10961
11109
  const isDirty = checkedCandidates.length !== assignedIds.length || checkedCandidates.some((id) => !assignedIds.includes(id));
10962
- const submitAssignment = (0, import_react23.useCallback)(async () => {
11110
+ const submitAssignment = (0, import_react24.useCallback)(async () => {
10963
11111
  if (!selectedTargetId) {
10964
11112
  alert("\u05D0\u05E0\u05D0 \u05D1\u05D7\u05E8 \u05E7\u05D5\u05D3\u05DD \u05E8\u05E9\u05D5\u05DE\u05EA \u05D9\u05E2\u05D3 \u05DC\u05E4\u05E0\u05D9 \u05D4\u05E9\u05D9\u05D1\u05D5\u05E5");
10965
11113
  return;
@@ -10975,14 +11123,14 @@ var PlacementBlock = (props) => {
10975
11123
  setIsSaving(false);
10976
11124
  }
10977
11125
  }, [selectedTargetId, persistAssignment, checkedCandidates]);
10978
- const cycleStatus = (0, import_react23.useCallback)((recordId) => {
11126
+ const cycleStatus = (0, import_react24.useCallback)((recordId) => {
10979
11127
  setStatusMap((prev) => {
10980
11128
  const current = prev[recordId] || defaultStatusId;
10981
11129
  const idx = statuses.findIndex((c) => c.id === current);
10982
11130
  return __spreadProps(__spreadValues({}, prev), { [recordId]: statuses[(idx + 1) % statuses.length].id });
10983
11131
  });
10984
11132
  }, [statuses, defaultStatusId]);
10985
- const cancelAssignment = (0, import_react23.useCallback)(async () => {
11133
+ const cancelAssignment = (0, import_react24.useCallback)(async () => {
10986
11134
  if (!selectedTargetId || assignedIds.length === 0) return;
10987
11135
  if (!window.confirm(`\u05DC\u05D1\u05D8\u05DC \u05D0\u05EA \u05D4\u05E9\u05D9\u05D1\u05D5\u05E5 \u05D5\u05DC\u05DE\u05D7\u05D5\u05E7 \u05D0\u05EA \u05D4\u05E0\u05EA\u05D5\u05DF \u05DE\u05E9\u05D3\u05D4 "${assignmentLabel}"?`)) return;
10988
11136
  const removed = new Set(assignedIds);
@@ -10998,7 +11146,7 @@ var PlacementBlock = (props) => {
10998
11146
  setIsSaving(false);
10999
11147
  }
11000
11148
  }, [selectedTargetId, assignedIds, assignmentLabel, persistAssignment]);
11001
- const makeColDefs = (0, import_react23.useCallback)((columns, fallbackName, grid, withCheckbox = false) => {
11149
+ const makeColDefs = (0, import_react24.useCallback)((columns, fallbackName, grid, withCheckbox = false) => {
11002
11150
  const gridFilters = colFilters[grid];
11003
11151
  const defs = [];
11004
11152
  if (withCheckbox) {
@@ -11043,36 +11191,36 @@ var PlacementBlock = (props) => {
11043
11191
  return defs;
11044
11192
  }, [cycleStatus, statuses, defaultStatusId, displayField, displayValue, toggleChecked, toggleAll, allChecked, someChecked, colFilters, openColFilter]);
11045
11193
  const sourceHeader = displayField === "name" ? "\u05E9\u05DD" : columnRefLabel(displayField);
11046
- const sourceColDefs = (0, import_react23.useMemo)(() => makeColDefs(sourceColumns, sourceHeader, "source"), [makeColDefs, sourceColumns, sourceHeader]);
11047
- const candidateColDefs = (0, import_react23.useMemo)(() => makeColDefs(sourceColumns, sourceHeader, "cand", true), [makeColDefs, sourceColumns, sourceHeader]);
11048
- const defaultColDef = (0, import_react23.useMemo)(() => ({ resizable: true }), []);
11194
+ const sourceColDefs = (0, import_react24.useMemo)(() => makeColDefs(sourceColumns, sourceHeader, "source"), [makeColDefs, sourceColumns, sourceHeader]);
11195
+ const candidateColDefs = (0, import_react24.useMemo)(() => makeColDefs(sourceColumns, sourceHeader, "cand", true), [makeColDefs, sourceColumns, sourceHeader]);
11196
+ const defaultColDef = (0, import_react24.useMemo)(() => ({ resizable: true }), []);
11049
11197
  const scrollableColIds = (defs) => defs.filter((d) => !d.pinned).map((d) => {
11050
11198
  var _a2;
11051
11199
  return (_a2 = d.colId) != null ? _a2 : d.field;
11052
11200
  }).filter(Boolean);
11053
- const expandColumns = (0, import_react23.useCallback)((api) => {
11201
+ const expandColumns = (0, import_react24.useCallback)((api) => {
11054
11202
  api == null ? void 0 : api.sizeColumnsToFit();
11055
11203
  }, []);
11056
- const shrinkColumns = (0, import_react23.useCallback)((api, defs) => {
11204
+ const shrinkColumns = (0, import_react24.useCallback)((api, defs) => {
11057
11205
  api == null ? void 0 : api.autoSizeColumns(scrollableColIds(defs));
11058
11206
  }, []);
11059
- const popoverOptions = (0, import_react23.useMemo)(() => {
11207
+ const popoverOptions = (0, import_react24.useMemo)(() => {
11060
11208
  if (!filterPopover) return [];
11061
11209
  const rows = filterPopover.grid === "source" ? availableRows : candidateRows;
11062
11210
  const set = /* @__PURE__ */ new Set();
11063
11211
  rows.forEach((r) => relationLabelsOf(r, filterPopover.colName).forEach((l) => set.add(l)));
11064
11212
  return Array.from(set).sort((a, b) => a.localeCompare(b, "he")).map((label) => ({ id: label, label }));
11065
11213
  }, [filterPopover, availableRows, candidateRows, relationLabelsOf]);
11066
- const popoverColumn = (0, import_react23.useMemo)(
11214
+ const popoverColumn = (0, import_react24.useMemo)(
11067
11215
  () => filterPopover ? sourceColumns.find((c) => c.name === filterPopover.colName) : void 0,
11068
11216
  [filterPopover, sourceColumns]
11069
11217
  );
11070
- const getRowId = (0, import_react23.useCallback)((p) => p.data.id, []);
11071
- const sourceContainerRef = (0, import_react23.useRef)(null);
11072
- const assignedContainerRef = (0, import_react23.useRef)(null);
11073
- const [sourceApi, setSourceApi] = (0, import_react23.useState)(null);
11074
- const [assignedApi, setAssignedApi] = (0, import_react23.useState)(null);
11075
- (0, import_react23.useEffect)(() => {
11218
+ const getRowId = (0, import_react24.useCallback)((p) => p.data.id, []);
11219
+ const sourceContainerRef = (0, import_react24.useRef)(null);
11220
+ const assignedContainerRef = (0, import_react24.useRef)(null);
11221
+ const [sourceApi, setSourceApi] = (0, import_react24.useState)(null);
11222
+ const [assignedApi, setAssignedApi] = (0, import_react24.useState)(null);
11223
+ (0, import_react24.useEffect)(() => {
11076
11224
  if (!sourceApi || !assignedApi) return;
11077
11225
  const toAssigned = { getContainer: () => assignedContainerRef.current, onDragStop: (p) => {
11078
11226
  var _a2, _b2;
@@ -11095,20 +11243,20 @@ var PlacementBlock = (props) => {
11095
11243
  }
11096
11244
  };
11097
11245
  }, [sourceApi, assignedApi]);
11098
- const selectorLabel = (0, import_react23.useMemo)(() => {
11246
+ const selectorLabel = (0, import_react24.useMemo)(() => {
11099
11247
  const col = targetColumns.find((c) => c.name === selectorField || c.id === selectorField);
11100
11248
  return (col == null ? void 0 : col.label) || columnRefLabel(selectorField) || "\u05D1\u05D7\u05D9\u05E8\u05EA \u05E8\u05E9\u05D5\u05DE\u05D4 \u05DC\u05E9\u05D9\u05D1\u05D5\u05E5";
11101
11249
  }, [targetColumns, selectorField]);
11102
- const assignedText = (0, import_react23.useMemo)(
11250
+ const assignedText = (0, import_react24.useMemo)(
11103
11251
  () => assignedIds.map((id) => sourceRows.find((r) => r.id === id)).filter((r) => !!r).map(nameOf).join(", "),
11104
11252
  [assignedIds, sourceRows, nameOf]
11105
11253
  );
11106
11254
  const activeTarget = targetRows.find((r) => r.id === selectedTargetId);
11107
- const targetLabel = (0, import_react23.useCallback)((r) => {
11255
+ const targetLabel = (0, import_react24.useCallback)((r) => {
11108
11256
  const col = targetColumns.find((c) => c.name === selectorField || c.id === selectorField);
11109
11257
  return displayValue(col || { name: selectorField }, readColumnValue(r.data, selectorField)) || "\u05DC\u05DC\u05D0 \u05E9\u05DD";
11110
11258
  }, [selectorField, targetColumns, displayValue]);
11111
- const previewColumns = (0, import_react23.useMemo)(() => targetColumns.filter((c) => isUserColumn(c) && c.name !== assignmentField && !["id", "_id", "id_", "statusId"].includes(c.name)), [targetColumns, assignmentField]);
11259
+ const previewColumns = (0, import_react24.useMemo)(() => targetColumns.filter((c) => isUserColumn(c) && c.name !== assignmentField && !["id", "_id", "id_", "statusId"].includes(c.name)), [targetColumns, assignmentField]);
11112
11260
  if (!config || !sourceTableId || !targetTableId) {
11113
11261
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "p-4 text-xs text-slate-500 border border-dashed border-slate-300 rounded-xl", dir: "rtl", children: "\u05E8\u05DB\u05D9\u05D1 \u05D4\u05E9\u05D9\u05D1\u05D5\u05E5 \u05DC\u05D0 \u05D4\u05D5\u05D2\u05D3\u05E8 (\u05D7\u05E1\u05E8\u05D5\u05EA \u05D8\u05D1\u05DC\u05EA \u05DE\u05E7\u05D5\u05E8 / \u05D8\u05D1\u05DC\u05EA \u05D9\u05E2\u05D3)." });
11114
11262
  }
@@ -11271,7 +11419,7 @@ var PlacementBlock = (props) => {
11271
11419
  };
11272
11420
 
11273
11421
  // src/components/PaymentReportsBlock/PaymentReportsBlock.tsx
11274
- var import_react29 = require("react");
11422
+ var import_react30 = require("react");
11275
11423
 
11276
11424
  // src/components/PaymentReportsBlock/PaymentReportsBlock.types.ts
11277
11425
  var PAYMENT_REPORTS_REQUIRED = [
@@ -11470,7 +11618,7 @@ function displayCell(item, col, relationOptions, symbol) {
11470
11618
  }
11471
11619
 
11472
11620
  // src/components/PaymentReportsBlock/UnpaidReportsTab.tsx
11473
- var import_react25 = require("react");
11621
+ var import_react26 = require("react");
11474
11622
  var import_ag_grid_react2 = require("ag-grid-react");
11475
11623
  var import_ag_grid_community2 = require("ag-grid-community");
11476
11624
 
@@ -11530,9 +11678,9 @@ var ConfirmModal = ({ title, message, confirmLabel, danger, busy, onConfirm, onC
11530
11678
  );
11531
11679
 
11532
11680
  // src/components/PaymentReportsBlock/useGridColumnWidths.ts
11533
- var import_react24 = require("react");
11681
+ var import_react25 = require("react");
11534
11682
  function useGridColumnWidths(storageKey) {
11535
- const [widths, setWidths] = (0, import_react24.useState)(() => {
11683
+ const [widths, setWidths] = (0, import_react25.useState)(() => {
11536
11684
  if (typeof window === "undefined") return {};
11537
11685
  try {
11538
11686
  return JSON.parse(localStorage.getItem(storageKey) || "{}") || {};
@@ -11540,7 +11688,7 @@ function useGridColumnWidths(storageKey) {
11540
11688
  return {};
11541
11689
  }
11542
11690
  });
11543
- const onColumnResized = (0, import_react24.useCallback)(
11691
+ const onColumnResized = (0, import_react25.useCallback)(
11544
11692
  (e) => {
11545
11693
  var _a;
11546
11694
  if (!e.finished || e.source !== "uiColumnResized" || !((_a = e.columns) == null ? void 0 : _a.length)) return;
@@ -11556,7 +11704,7 @@ function useGridColumnWidths(storageKey) {
11556
11704
  },
11557
11705
  [storageKey]
11558
11706
  );
11559
- const applyWidths = (0, import_react24.useCallback)(
11707
+ const applyWidths = (0, import_react25.useCallback)(
11560
11708
  (defs) => defs.map((d) => {
11561
11709
  const w = d.colId ? widths[d.colId] : void 0;
11562
11710
  return w ? __spreadProps(__spreadValues({}, d), { width: w, flex: 0 }) : d;
@@ -11598,18 +11746,18 @@ var UnpaidReportsTab = ({
11598
11746
  handlers
11599
11747
  }) => {
11600
11748
  var _a;
11601
- const apiRef = (0, import_react25.useRef)(null);
11749
+ const apiRef = (0, import_react26.useRef)(null);
11602
11750
  const { onColumnResized, applyWidths } = useGridColumnWidths(`payment-reports:${config.reportsTableId}:unpaid`);
11603
- const [selectedIds, setSelectedIds] = (0, import_react25.useState)([]);
11604
- const [confirmOpen, setConfirmOpen] = (0, import_react25.useState)(false);
11605
- const [paying, setPaying] = (0, import_react25.useState)(false);
11606
- const displayCols = (0, import_react25.useMemo)(() => {
11751
+ const [selectedIds, setSelectedIds] = (0, import_react26.useState)([]);
11752
+ const [confirmOpen, setConfirmOpen] = (0, import_react26.useState)(false);
11753
+ const [paying, setPaying] = (0, import_react26.useState)(false);
11754
+ const displayCols = (0, import_react26.useMemo)(() => {
11607
11755
  var _a2;
11608
11756
  const byName = new Map(columns.filter(isUserColumn2).map((c) => [c.name, c]));
11609
11757
  const wanted = ((_a2 = config.reportDisplayColumns) == null ? void 0 : _a2.length) ? config.reportDisplayColumns : Array.from(byName.keys());
11610
11758
  return wanted.filter((n) => n !== config.reportPaymentColumn && n !== config.reportReporterColumn).map((n) => byName.get(n)).filter(Boolean);
11611
11759
  }, [columns, config.reportDisplayColumns, config.reportPaymentColumn, config.reportReporterColumn]);
11612
- const colDefs = (0, import_react25.useMemo)(() => {
11760
+ const colDefs = (0, import_react26.useMemo)(() => {
11613
11761
  const defs = [
11614
11762
  { headerName: "\u05DE\u05D3\u05D5\u05D5\u05D7", colId: "__reporter", minWidth: 140, valueGetter: (p) => {
11615
11763
  var _a2;
@@ -11669,14 +11817,14 @@ var UnpaidReportsTab = ({
11669
11817
  }
11670
11818
  return defs;
11671
11819
  }, [displayCols, canEdit, symbol, relationOptions, showPaid, paymentLabels, handlers]);
11672
- const finalColDefs = (0, import_react25.useMemo)(() => applyWidths(colDefs), [applyWidths, colDefs]);
11673
- const unpaid = (0, import_react25.useMemo)(() => reports.filter((r) => !r.paymentId), [reports]);
11674
- const totals = (0, import_react25.useMemo)(() => {
11820
+ const finalColDefs = (0, import_react26.useMemo)(() => applyWidths(colDefs), [applyWidths, colDefs]);
11821
+ const unpaid = (0, import_react26.useMemo)(() => reports.filter((r) => !r.paymentId), [reports]);
11822
+ const totals = (0, import_react26.useMemo)(() => {
11675
11823
  const amount = unpaid.reduce((s, r) => s + r.amount, 0);
11676
11824
  const qty = unpaid.reduce((s, r) => s + r.qty, 0);
11677
11825
  return { count: unpaid.length, amount, qty, avg: qty > 0 ? amount / qty : 0 };
11678
11826
  }, [unpaid]);
11679
- const selected = (0, import_react25.useMemo)(
11827
+ const selected = (0, import_react26.useMemo)(
11680
11828
  () => unpaid.filter((r) => selectedIds.includes(r.id)),
11681
11829
  [unpaid, selectedIds]
11682
11830
  );
@@ -11795,16 +11943,16 @@ var UnpaidReportsTab = ({
11795
11943
  };
11796
11944
 
11797
11945
  // src/components/PaymentReportsBlock/PaymentsGrid.tsx
11798
- var import_react27 = require("react");
11946
+ var import_react28 = require("react");
11799
11947
  var import_ag_grid_react3 = require("ag-grid-react");
11800
11948
  var import_ag_grid_community3 = require("ag-grid-community");
11801
11949
 
11802
11950
  // src/components/PaymentReportsBlock/ProofCell.tsx
11803
- var import_react26 = require("react");
11951
+ var import_react27 = require("react");
11804
11952
  var import_jsx_runtime25 = require("react/jsx-runtime");
11805
11953
  var ProofCell = ({ files, editable, onUpload, onRemove }) => {
11806
- const inputRef = (0, import_react26.useRef)(null);
11807
- const [busy, setBusy] = (0, import_react26.useState)(false);
11954
+ const inputRef = (0, import_react27.useRef)(null);
11955
+ const [busy, setBusy] = (0, import_react27.useState)(false);
11808
11956
  const file = files[0];
11809
11957
  const href = (file == null ? void 0 : file.fileUrl) || (file == null ? void 0 : file.url);
11810
11958
  const handleFile = async (e) => {
@@ -11867,8 +12015,8 @@ var ProofRenderer = (p) => p.data ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx
11867
12015
  }
11868
12016
  ) : null;
11869
12017
  var ReceiptRenderer = (p) => {
11870
- const [date, setDate] = (0, import_react27.useState)(todayIso());
11871
- const [busy, setBusy] = (0, import_react27.useState)(false);
12018
+ const [date, setDate] = (0, import_react28.useState)(todayIso());
12019
+ const [busy, setBusy] = (0, import_react28.useState)(false);
11872
12020
  if (!p.data) return null;
11873
12021
  const id = p.data.id;
11874
12022
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex items-center gap-2 h-full", children: [
@@ -11936,7 +12084,7 @@ var ActionsRenderer = (p) => {
11936
12084
  };
11937
12085
  var PaymentsGrid = ({ mode, config, symbol, canEdit, payments, search, handlers }) => {
11938
12086
  const { onColumnResized, applyWidths } = useGridColumnWidths(`payment-reports:${config.paymentsTableId}:${mode}`);
11939
- const colDefs = (0, import_react27.useMemo)(() => {
12087
+ const colDefs = (0, import_react28.useMemo)(() => {
11940
12088
  const defs = [
11941
12089
  { headerName: "\u05DE\u05D3\u05D5\u05D5\u05D7", colId: "__reporter", minWidth: 140, valueGetter: (p) => {
11942
12090
  var _a;
@@ -12005,8 +12153,8 @@ var PaymentsGrid = ({ mode, config, symbol, canEdit, payments, search, handlers
12005
12153
  });
12006
12154
  return defs;
12007
12155
  }, [mode, config.paymentProofColumn, symbol, canEdit, handlers]);
12008
- const finalColDefs = (0, import_react27.useMemo)(() => applyWidths(colDefs), [applyWidths, colDefs]);
12009
- const total = (0, import_react27.useMemo)(() => payments.reduce((s, p) => s + p.total, 0), [payments]);
12156
+ const finalColDefs = (0, import_react28.useMemo)(() => applyWidths(colDefs), [applyWidths, colDefs]);
12157
+ const total = (0, import_react28.useMemo)(() => payments.reduce((s, p) => s + p.total, 0), [payments]);
12010
12158
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex flex-col gap-3", children: [
12011
12159
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "ag-theme-quartz w-full", style: { height: 480 }, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
12012
12160
  import_ag_grid_react3.AgGridReact,
@@ -12044,11 +12192,11 @@ var import_jsx_runtime28 = require("react/jsx-runtime");
12044
12192
  var ReceiptsTab = (props) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(PaymentsGrid, __spreadValues({ mode: "received" }, props));
12045
12193
 
12046
12194
  // src/components/PaymentReportsBlock/PaymentDetailsModal.tsx
12047
- var import_react28 = require("react");
12195
+ var import_react29 = require("react");
12048
12196
  var import_jsx_runtime29 = require("react/jsx-runtime");
12049
12197
  var isUserColumn3 = (c) => !!(c == null ? void 0 : c.name) && c.name !== "_id" && c.name !== "id" && !c.isHidden;
12050
12198
  var PaymentDetailsModal = ({ payment, config, symbol, columns, relationOptions, onClose }) => {
12051
- const cols = (0, import_react28.useMemo)(() => {
12199
+ const cols = (0, import_react29.useMemo)(() => {
12052
12200
  var _a;
12053
12201
  const byName = new Map(columns.filter(isUserColumn3).map((c) => [c.name, c]));
12054
12202
  const wanted = ((_a = config.reportDisplayColumns) == null ? void 0 : _a.length) ? config.reportDisplayColumns : Array.from(byName.keys());
@@ -12217,7 +12365,7 @@ var EMPTY = { rows: [], columns: [], relationOptions: {} };
12217
12365
  var PaymentReportsBlock = (props) => {
12218
12366
  const { executeAction, orgId, role, readOnly, permissions, className } = props;
12219
12367
  const { addToast } = useToast();
12220
- const config = (0, import_react29.useMemo)(() => {
12368
+ const config = (0, import_react30.useMemo)(() => {
12221
12369
  var _a, _b;
12222
12370
  const raw = (_a = props.config) != null ? _a : props.settings;
12223
12371
  if (!raw) return void 0;
@@ -12226,20 +12374,20 @@ var PaymentReportsBlock = (props) => {
12226
12374
  const missing = missingPaymentReportsFields(config);
12227
12375
  const symbol = (config == null ? void 0 : config.currencySymbol) || "\u20AA";
12228
12376
  const canEdit = !readOnly && ((permissions == null ? void 0 : permissions.canUpdate) !== void 0 ? !!permissions.canUpdate : role ? role === "OWNER" || role === "EDITOR" : true);
12229
- const [tab, setTab] = (0, import_react29.useState)("unpaid");
12230
- const [month, setMonth] = (0, import_react29.useState)("");
12231
- const [search, setSearch] = (0, import_react29.useState)("");
12232
- const [showPaid, setShowPaid] = (0, import_react29.useState)(false);
12233
- const [reportsRes, setReportsRes] = (0, import_react29.useState)(EMPTY);
12234
- const [paymentsRes, setPaymentsRes] = (0, import_react29.useState)(EMPTY);
12235
- const [loading, setLoading] = (0, import_react29.useState)(true);
12236
- const [error, setError] = (0, import_react29.useState)(null);
12237
- const [details, setDetails] = (0, import_react29.useState)(null);
12238
- const [confirm, setConfirm] = (0, import_react29.useState)(null);
12239
- const [confirmBusy, setConfirmBusy] = (0, import_react29.useState)(false);
12240
- const toastOk = (0, import_react29.useCallback)((message) => addToast({ type: "success", message }), [addToast]);
12241
- const toastErr = (0, import_react29.useCallback)((e) => addToast({ type: "error", message: (e == null ? void 0 : e.message) || String(e) }), [addToast]);
12242
- const load = (0, import_react29.useCallback)(
12377
+ const [tab, setTab] = (0, import_react30.useState)("unpaid");
12378
+ const [month, setMonth] = (0, import_react30.useState)("");
12379
+ const [search, setSearch] = (0, import_react30.useState)("");
12380
+ const [showPaid, setShowPaid] = (0, import_react30.useState)(false);
12381
+ const [reportsRes, setReportsRes] = (0, import_react30.useState)(EMPTY);
12382
+ const [paymentsRes, setPaymentsRes] = (0, import_react30.useState)(EMPTY);
12383
+ const [loading, setLoading] = (0, import_react30.useState)(true);
12384
+ const [error, setError] = (0, import_react30.useState)(null);
12385
+ const [details, setDetails] = (0, import_react30.useState)(null);
12386
+ const [confirm, setConfirm] = (0, import_react30.useState)(null);
12387
+ const [confirmBusy, setConfirmBusy] = (0, import_react30.useState)(false);
12388
+ const toastOk = (0, import_react30.useCallback)((message) => addToast({ type: "success", message }), [addToast]);
12389
+ const toastErr = (0, import_react30.useCallback)((e) => addToast({ type: "error", message: (e == null ? void 0 : e.message) || String(e) }), [addToast]);
12390
+ const load = (0, import_react30.useCallback)(
12243
12391
  async (silent = false) => {
12244
12392
  if (!config || missing.length) return;
12245
12393
  if (!silent) setLoading(true);
@@ -12260,32 +12408,32 @@ var PaymentReportsBlock = (props) => {
12260
12408
  // eslint-disable-next-line react-hooks/exhaustive-deps
12261
12409
  [config == null ? void 0 : config.reportsTableId, config == null ? void 0 : config.paymentsTableId, missing.length, executeAction]
12262
12410
  );
12263
- (0, import_react29.useEffect)(() => {
12411
+ (0, import_react30.useEffect)(() => {
12264
12412
  load();
12265
12413
  }, [load]);
12266
- const model = (0, import_react29.useMemo)(
12414
+ const model = (0, import_react30.useMemo)(
12267
12415
  () => config && !missing.length ? buildModel(config, reportsRes, paymentsRes) : { reports: [], payments: [] },
12268
12416
  [config, missing.length, reportsRes, paymentsRes]
12269
12417
  );
12270
- const months = (0, import_react29.useMemo)(() => {
12418
+ const months = (0, import_react30.useMemo)(() => {
12271
12419
  const set = /* @__PURE__ */ new Set();
12272
12420
  model.reports.forEach((r) => r.month && set.add(r.month));
12273
12421
  return Array.from(set).sort().reverse();
12274
12422
  }, [model.reports]);
12275
- const reportsInMonth = (0, import_react29.useMemo)(
12423
+ const reportsInMonth = (0, import_react30.useMemo)(
12276
12424
  () => model.reports.filter((r) => (!month || r.month === month) && (showPaid || !r.paymentId)),
12277
12425
  [model.reports, month, showPaid]
12278
12426
  );
12279
- const pendingPayments = (0, import_react29.useMemo)(
12427
+ const pendingPayments = (0, import_react30.useMemo)(
12280
12428
  () => model.payments.filter((p) => !p.receiptDate && (!month || p.months.includes(month))),
12281
12429
  [model.payments, month]
12282
12430
  );
12283
- const receivedPayments = (0, import_react29.useMemo)(
12431
+ const receivedPayments = (0, import_react30.useMemo)(
12284
12432
  () => model.payments.filter((p) => !!p.receiptDate && (!month || p.months.includes(month))),
12285
12433
  [model.payments, month]
12286
12434
  );
12287
12435
  const unpaidCount = model.reports.filter((r) => !r.paymentId).length;
12288
- const paymentLabels = (0, import_react29.useMemo)(() => {
12436
+ const paymentLabels = (0, import_react30.useMemo)(() => {
12289
12437
  const m = {};
12290
12438
  model.payments.forEach((p) => {
12291
12439
  m[p.id] = `${p.receiptDate ? "\u05D4\u05EA\u05E7\u05D1\u05DC" : "\u05E9\u05D5\u05DC\u05DD"} \xB7 ${formatMoney(p.total, symbol)}`;
@@ -12293,7 +12441,7 @@ var PaymentReportsBlock = (props) => {
12293
12441
  return m;
12294
12442
  }, [model.payments, symbol]);
12295
12443
  const base = { reportsTableId: config == null ? void 0 : config.reportsTableId, paymentsTableId: config == null ? void 0 : config.paymentsTableId };
12296
- const handlers = (0, import_react29.useRef)(null);
12444
+ const handlers = (0, import_react30.useRef)(null);
12297
12445
  handlers.current = {
12298
12446
  onPay: async (reportIds) => {
12299
12447
  var _a;
@@ -12483,11 +12631,11 @@ var PaymentReportsBlock = (props) => {
12483
12631
  };
12484
12632
 
12485
12633
  // src/components/WhatsAppComponent/WhatsAppComponent.tsx
12486
- var import_react35 = __toESM(require("react"));
12634
+ var import_react36 = __toESM(require("react"));
12487
12635
  var import_lucide_react17 = require("lucide-react");
12488
12636
 
12489
12637
  // src/components/WhatsAppComponent/CreateTemplateModal.tsx
12490
- var import_react30 = require("react");
12638
+ var import_react31 = require("react");
12491
12639
  var import_lucide_react11 = require("lucide-react");
12492
12640
  var import_emoji_picker_react = __toESM(require("emoji-picker-react"));
12493
12641
 
@@ -12617,26 +12765,26 @@ function CreateTemplateModal({
12617
12765
  executeAction,
12618
12766
  orgId
12619
12767
  }) {
12620
- const [templateName, setTemplateName] = (0, import_react30.useState)("");
12621
- const [language, setLanguage] = (0, import_react30.useState)("he");
12622
- const [category, setCategory] = (0, import_react30.useState)("MARKETING");
12623
- const [bodyText, setBodyText] = (0, import_react30.useState)("");
12624
- const [variableSamples, setVariableSamples] = (0, import_react30.useState)({});
12625
- const [hasFileHeader, setHasFileHeader] = (0, import_react30.useState)(false);
12626
- const [selectedFile, setSelectedFile] = (0, import_react30.useState)(null);
12627
- const [fileBase64, setFileBase64] = (0, import_react30.useState)("");
12628
- const [buttons, setButtons] = (0, import_react30.useState)([]);
12629
- const [isAddButtonOpen, setIsAddButtonOpen] = (0, import_react30.useState)(false);
12630
- const addButtonDropdownRef = (0, import_react30.useRef)(null);
12631
- const [isSubmitting, setIsSubmitting] = (0, import_react30.useState)(false);
12632
- const [submittingStep, setSubmittingStep] = (0, import_react30.useState)("");
12633
- const [submitError, setSubmitError] = (0, import_react30.useState)(null);
12634
- const [fileError, setFileError] = (0, import_react30.useState)(null);
12635
- const textareaRef = (0, import_react30.useRef)(null);
12636
- const fileInputRef = (0, import_react30.useRef)(null);
12637
- const emojiPickerRef = (0, import_react30.useRef)(null);
12638
- const [isEmojiPickerOpen, setIsEmojiPickerOpen] = (0, import_react30.useState)(false);
12639
- (0, import_react30.useEffect)(() => {
12768
+ const [templateName, setTemplateName] = (0, import_react31.useState)("");
12769
+ const [language, setLanguage] = (0, import_react31.useState)("he");
12770
+ const [category, setCategory] = (0, import_react31.useState)("MARKETING");
12771
+ const [bodyText, setBodyText] = (0, import_react31.useState)("");
12772
+ const [variableSamples, setVariableSamples] = (0, import_react31.useState)({});
12773
+ const [hasFileHeader, setHasFileHeader] = (0, import_react31.useState)(false);
12774
+ const [selectedFile, setSelectedFile] = (0, import_react31.useState)(null);
12775
+ const [fileBase64, setFileBase64] = (0, import_react31.useState)("");
12776
+ const [buttons, setButtons] = (0, import_react31.useState)([]);
12777
+ const [isAddButtonOpen, setIsAddButtonOpen] = (0, import_react31.useState)(false);
12778
+ const addButtonDropdownRef = (0, import_react31.useRef)(null);
12779
+ const [isSubmitting, setIsSubmitting] = (0, import_react31.useState)(false);
12780
+ const [submittingStep, setSubmittingStep] = (0, import_react31.useState)("");
12781
+ const [submitError, setSubmitError] = (0, import_react31.useState)(null);
12782
+ const [fileError, setFileError] = (0, import_react31.useState)(null);
12783
+ const textareaRef = (0, import_react31.useRef)(null);
12784
+ const fileInputRef = (0, import_react31.useRef)(null);
12785
+ const emojiPickerRef = (0, import_react31.useRef)(null);
12786
+ const [isEmojiPickerOpen, setIsEmojiPickerOpen] = (0, import_react31.useState)(false);
12787
+ (0, import_react31.useEffect)(() => {
12640
12788
  function handleClickOutside(event) {
12641
12789
  if (emojiPickerRef.current && !emojiPickerRef.current.contains(event.target)) {
12642
12790
  setIsEmojiPickerOpen(false);
@@ -12660,7 +12808,7 @@ function CreateTemplateModal({
12660
12808
  document.removeEventListener("keydown", handleKeyDown2);
12661
12809
  };
12662
12810
  }, [isEmojiPickerOpen, isAddButtonOpen]);
12663
- (0, import_react30.useEffect)(() => {
12811
+ (0, import_react31.useEffect)(() => {
12664
12812
  if (isOpen) {
12665
12813
  setTemplateName("");
12666
12814
  setLanguage("he");
@@ -12679,10 +12827,10 @@ function CreateTemplateModal({
12679
12827
  setIsEmojiPickerOpen(false);
12680
12828
  }
12681
12829
  }, [isOpen]);
12682
- const uniqueVariables = (0, import_react30.useMemo)(() => {
12830
+ const uniqueVariables = (0, import_react31.useMemo)(() => {
12683
12831
  return extractUniqueVariableIndices(bodyText);
12684
12832
  }, [bodyText]);
12685
- (0, import_react30.useEffect)(() => {
12833
+ (0, import_react31.useEffect)(() => {
12686
12834
  setVariableSamples((prev) => {
12687
12835
  const next = {};
12688
12836
  uniqueVariables.forEach((idx) => {
@@ -12693,7 +12841,7 @@ function CreateTemplateModal({
12693
12841
  }, [uniqueVariables]);
12694
12842
  const isNameEmpty = templateName.trim().length === 0;
12695
12843
  const isNamePatternValid = isValidTemplateName(templateName);
12696
- const isNameDuplicate = (0, import_react30.useMemo)(() => {
12844
+ const isNameDuplicate = (0, import_react31.useMemo)(() => {
12697
12845
  const trimmedName = templateName.trim().toLowerCase();
12698
12846
  if (!trimmedName) return false;
12699
12847
  if (existingTemplates && existingTemplates.length > 0) {
@@ -12703,9 +12851,9 @@ function CreateTemplateModal({
12703
12851
  }
12704
12852
  return isDuplicateTemplateName(trimmedName, existingTemplateNames, language);
12705
12853
  }, [templateName, language, existingTemplates, existingTemplateNames]);
12706
- const ratioInfo = (0, import_react30.useMemo)(() => validateWordToVariableRatio(bodyText), [bodyText]);
12707
- const seqInfo = (0, import_react30.useMemo)(() => validateSequentialVariables(bodyText), [bodyText]);
12708
- const validationResult = (0, import_react30.useMemo)(() => {
12854
+ const ratioInfo = (0, import_react31.useMemo)(() => validateWordToVariableRatio(bodyText), [bodyText]);
12855
+ const seqInfo = (0, import_react31.useMemo)(() => validateSequentialVariables(bodyText), [bodyText]);
12856
+ const validationResult = (0, import_react31.useMemo)(() => {
12709
12857
  return validateWhatsAppTemplate({
12710
12858
  name: templateName,
12711
12859
  language,
@@ -13699,7 +13847,7 @@ function CreateTemplateModal({
13699
13847
  }
13700
13848
 
13701
13849
  // src/components/WhatsAppComponent/hooks/useWhatsAppState.ts
13702
- var import_react31 = require("react");
13850
+ var import_react32 = require("react");
13703
13851
 
13704
13852
  // src/components/WhatsAppComponent/utils/recipientEngine.ts
13705
13853
  var STORAGE_KEY_TEST_PHONE = "whatsapp_test_phone";
@@ -15004,29 +15152,29 @@ function useWhatsAppState(props) {
15004
15152
  data: injectedData
15005
15153
  } = props;
15006
15154
  const orgId = props.orgId || props.organizationId || (settings == null ? void 0 : settings.orgId) || (settings == null ? void 0 : settings.organizationId) || (injectedData == null ? void 0 : injectedData.orgId) || (injectedData == null ? void 0 : injectedData.organizationId);
15007
- const [tableColumns2, setTableColumns] = (0, import_react31.useState)(() => {
15155
+ const [tableColumns2, setTableColumns] = (0, import_react32.useState)(() => {
15008
15156
  return Array.isArray(settings == null ? void 0 : settings.columns) ? settings.columns : [];
15009
15157
  });
15010
- const [rawRecords, setRawRecords] = (0, import_react31.useState)(() => {
15158
+ const [rawRecords, setRawRecords] = (0, import_react32.useState)(() => {
15011
15159
  if (Array.isArray(injectedData)) return injectedData;
15012
15160
  if (Array.isArray(injectedData == null ? void 0 : injectedData.records)) return injectedData.records;
15013
15161
  return [];
15014
15162
  });
15015
- const [relationOptions, setRelationOptions] = (0, import_react31.useState)(() => {
15163
+ const [relationOptions, setRelationOptions] = (0, import_react32.useState)(() => {
15016
15164
  return (injectedData == null ? void 0 : injectedData.relationOptions) || {};
15017
15165
  });
15018
- const [isLoadingTableData, setIsLoadingTableData] = (0, import_react31.useState)(() => Boolean(settings == null ? void 0 : settings.tableMetaId));
15019
- const [activeSubtableScans, setActiveSubtableScans] = (0, import_react31.useState)(0);
15020
- const [tableError, setTableError] = (0, import_react31.useState)(null);
15021
- const [filters, setFilters] = (0, import_react31.useState)({});
15022
- const [selectedRowIds, setSelectedRowIds] = (0, import_react31.useState)([]);
15023
- const [autoSelectCount, setAutoSelectCount] = (0, import_react31.useState)(null);
15024
- const isAutoSelectingRef = (0, import_react31.useRef)(false);
15025
- const isManualOverrideRef = (0, import_react31.useRef)(false);
15026
- const prevAutoSelectCountRef = (0, import_react31.useRef)(null);
15027
- const fetchedTableIdsRef = (0, import_react31.useRef)(/* @__PURE__ */ new Set());
15028
- const fullyFetchedRelationKeysRef = (0, import_react31.useRef)(/* @__PURE__ */ new Set());
15029
- const loadTableData = (0, import_react31.useCallback)(async () => {
15166
+ const [isLoadingTableData, setIsLoadingTableData] = (0, import_react32.useState)(() => Boolean(settings == null ? void 0 : settings.tableMetaId));
15167
+ const [activeSubtableScans, setActiveSubtableScans] = (0, import_react32.useState)(0);
15168
+ const [tableError, setTableError] = (0, import_react32.useState)(null);
15169
+ const [filters, setFilters] = (0, import_react32.useState)({});
15170
+ const [selectedRowIds, setSelectedRowIds] = (0, import_react32.useState)([]);
15171
+ const [autoSelectCount, setAutoSelectCount] = (0, import_react32.useState)(null);
15172
+ const isAutoSelectingRef = (0, import_react32.useRef)(false);
15173
+ const isManualOverrideRef = (0, import_react32.useRef)(false);
15174
+ const prevAutoSelectCountRef = (0, import_react32.useRef)(null);
15175
+ const fetchedTableIdsRef = (0, import_react32.useRef)(/* @__PURE__ */ new Set());
15176
+ const fullyFetchedRelationKeysRef = (0, import_react32.useRef)(/* @__PURE__ */ new Set());
15177
+ const loadTableData = (0, import_react32.useCallback)(async () => {
15030
15178
  var _a2;
15031
15179
  const tableId = (settings == null ? void 0 : settings.tableMetaId) || (injectedData == null ? void 0 : injectedData.tableMetaId) || (injectedData == null ? void 0 : injectedData.tableId);
15032
15180
  if (!tableId || !executeAction) return;
@@ -15093,10 +15241,10 @@ function useWhatsAppState(props) {
15093
15241
  executeAction,
15094
15242
  orgId
15095
15243
  ]);
15096
- (0, import_react31.useEffect)(() => {
15244
+ (0, import_react32.useEffect)(() => {
15097
15245
  loadTableData();
15098
15246
  }, [loadTableData]);
15099
- const filterableColumns = (0, import_react31.useMemo)(() => {
15247
+ const filterableColumns = (0, import_react32.useMemo)(() => {
15100
15248
  return (tableColumns2 || []).filter((col) => {
15101
15249
  var _a2;
15102
15250
  if (!col || col.name === "_id" || col.id === "_id") return false;
@@ -15104,15 +15252,15 @@ function useWhatsAppState(props) {
15104
15252
  return type === "RELATION" || type === "BOOLEAN";
15105
15253
  });
15106
15254
  }, [tableColumns2]);
15107
- const [referencedTableSchemas, setReferencedTableSchemas] = (0, import_react31.useState)({});
15108
- const subtableCols = (0, import_react31.useMemo)(() => {
15255
+ const [referencedTableSchemas, setReferencedTableSchemas] = (0, import_react32.useState)({});
15256
+ const subtableCols = (0, import_react32.useMemo)(() => {
15109
15257
  return (tableColumns2 || []).filter((col) => {
15110
15258
  var _a2;
15111
15259
  const type = (_a2 = col.type) == null ? void 0 : _a2.toUpperCase();
15112
15260
  return type === "RELATION" || type === "SUB_TABLE" || type === "SUBTABLE";
15113
15261
  });
15114
15262
  }, [tableColumns2]);
15115
- (0, import_react31.useEffect)(() => {
15263
+ (0, import_react32.useEffect)(() => {
15116
15264
  if (!executeAction) return;
15117
15265
  const unrequestedCols = subtableCols.filter((col) => {
15118
15266
  var _a2;
@@ -15158,20 +15306,20 @@ function useWhatsAppState(props) {
15158
15306
  const isScanningPhoneColumns = Boolean(
15159
15307
  isLoadingTableData || activeSubtableScans > 0 || tableColumns2.length === 0 && Boolean(settings == null ? void 0 : settings.tableMetaId)
15160
15308
  );
15161
- const targetPhoneOptions = (0, import_react31.useMemo)(() => {
15309
+ const targetPhoneOptions = (0, import_react32.useMemo)(() => {
15162
15310
  const cols = tableColumns2 && tableColumns2.length > 0 ? tableColumns2 : Array.isArray(settings == null ? void 0 : settings.columns) ? settings.columns : [];
15163
15311
  return scanTargetPhoneOptions(cols, referencedTableSchemas);
15164
15312
  }, [tableColumns2, settings == null ? void 0 : settings.columns, referencedTableSchemas]);
15165
- const phoneColumns = (0, import_react31.useMemo)(() => {
15313
+ const phoneColumns = (0, import_react32.useMemo)(() => {
15166
15314
  return targetPhoneOptions.map((opt) => ({ name: opt.label, id: opt.id, type: "PHONE" }));
15167
15315
  }, [targetPhoneOptions]);
15168
- const [phoneColumnId, setPhoneColumnId] = (0, import_react31.useState)("");
15169
- const [subtableFilterColumn, setSubtableFilterColumn] = (0, import_react31.useState)("");
15170
- const [subtableFilterValue, setSubtableFilterValue] = (0, import_react31.useState)("");
15171
- const [subtableSendLimit, setSubtableSendLimit] = (0, import_react31.useState)(
15316
+ const [phoneColumnId, setPhoneColumnId] = (0, import_react32.useState)("");
15317
+ const [subtableFilterColumn, setSubtableFilterColumn] = (0, import_react32.useState)("");
15318
+ const [subtableFilterValue, setSubtableFilterValue] = (0, import_react32.useState)("");
15319
+ const [subtableSendLimit, setSubtableSendLimit] = (0, import_react32.useState)(
15172
15320
  (settings == null ? void 0 : settings.subtableSendLimit) || "PRIMARY"
15173
15321
  );
15174
- (0, import_react31.useEffect)(() => {
15322
+ (0, import_react32.useEffect)(() => {
15175
15323
  if (targetPhoneOptions.length > 0) {
15176
15324
  const isValid = targetPhoneOptions.some(
15177
15325
  (opt) => opt.id === phoneColumnId || opt.columnName === phoneColumnId
@@ -15183,13 +15331,13 @@ function useWhatsAppState(props) {
15183
15331
  setPhoneColumnId("");
15184
15332
  }
15185
15333
  }, [targetPhoneOptions, phoneColumnId]);
15186
- const selectedPhoneOption = (0, import_react31.useMemo)(() => {
15334
+ const selectedPhoneOption = (0, import_react32.useMemo)(() => {
15187
15335
  if (!phoneColumnId) return targetPhoneOptions[0] || null;
15188
15336
  return targetPhoneOptions.find(
15189
15337
  (opt) => opt.id === phoneColumnId || opt.columnName === phoneColumnId
15190
15338
  ) || targetPhoneOptions[0] || null;
15191
15339
  }, [targetPhoneOptions, phoneColumnId]);
15192
- const subtableFilterableColumns = (0, import_react31.useMemo)(() => {
15340
+ const subtableFilterableColumns = (0, import_react32.useMemo)(() => {
15193
15341
  var _a2, _b2, _c;
15194
15342
  if (!selectedPhoneOption || selectedPhoneOption.type !== "SUBTABLE") {
15195
15343
  return [];
@@ -15208,14 +15356,14 @@ function useWhatsAppState(props) {
15208
15356
  return type === "BOOLEAN" || type === "RELATION";
15209
15357
  });
15210
15358
  }, [selectedPhoneOption, referencedTableSchemas, tableColumns2]);
15211
- const selectedSubtableFilterCol = (0, import_react31.useMemo)(() => {
15359
+ const selectedSubtableFilterCol = (0, import_react32.useMemo)(() => {
15212
15360
  return subtableFilterableColumns.find((c) => c.name === subtableFilterColumn);
15213
15361
  }, [subtableFilterableColumns, subtableFilterColumn]);
15214
- const [enablePostSendAction, setEnablePostSendAction] = (0, import_react31.useState)(false);
15215
- const [postSendActionColumn, setPostSendActionColumn] = (0, import_react31.useState)("");
15216
- const [postSendActionValue, setPostSendActionValue] = (0, import_react31.useState)("");
15217
- const [postSendActionTargetType, setPostSendActionTargetType] = (0, import_react31.useState)("MAIN");
15218
- const postSendActionTargetOptions = (0, import_react31.useMemo)(() => {
15362
+ const [enablePostSendAction, setEnablePostSendAction] = (0, import_react32.useState)(false);
15363
+ const [postSendActionColumn, setPostSendActionColumn] = (0, import_react32.useState)("");
15364
+ const [postSendActionValue, setPostSendActionValue] = (0, import_react32.useState)("");
15365
+ const [postSendActionTargetType, setPostSendActionTargetType] = (0, import_react32.useState)("MAIN");
15366
+ const postSendActionTargetOptions = (0, import_react32.useMemo)(() => {
15219
15367
  var _a2, _b2, _c;
15220
15368
  const options = [];
15221
15369
  (tableColumns2 || []).forEach((col) => {
@@ -15260,14 +15408,14 @@ function useWhatsAppState(props) {
15260
15408
  }
15261
15409
  return options;
15262
15410
  }, [tableColumns2, selectedPhoneOption, referencedTableSchemas]);
15263
- const selectedPostSendOption = (0, import_react31.useMemo)(() => {
15411
+ const selectedPostSendOption = (0, import_react32.useMemo)(() => {
15264
15412
  return postSendActionTargetOptions.find(
15265
15413
  (opt) => opt.id === postSendActionColumn || opt.columnName === postSendActionColumn
15266
15414
  );
15267
15415
  }, [postSendActionTargetOptions, postSendActionColumn]);
15268
15416
  const selectedPostSendCol = selectedPostSendOption;
15269
- const [isTestPromptOpen, setIsTestPromptOpen] = (0, import_react31.useState)(false);
15270
- const [testPhoneNumber, setTestPhoneNumber] = (0, import_react31.useState)(() => {
15417
+ const [isTestPromptOpen, setIsTestPromptOpen] = (0, import_react32.useState)(false);
15418
+ const [testPhoneNumber, setTestPhoneNumber] = (0, import_react32.useState)(() => {
15271
15419
  if (typeof window !== "undefined") {
15272
15420
  try {
15273
15421
  return localStorage.getItem(STORAGE_KEY_TEST_PHONE) || "";
@@ -15277,10 +15425,10 @@ function useWhatsAppState(props) {
15277
15425
  }
15278
15426
  return "";
15279
15427
  });
15280
- const [testFeedback, setTestFeedback] = (0, import_react31.useState)(null);
15281
- const [isSendingTest, setIsSendingTest] = (0, import_react31.useState)(false);
15282
- const [isSendingBroadcast, setIsSendingBroadcast] = (0, import_react31.useState)(false);
15283
- const [broadcastProgress, setBroadcastProgress] = (0, import_react31.useState)({
15428
+ const [testFeedback, setTestFeedback] = (0, import_react32.useState)(null);
15429
+ const [isSendingTest, setIsSendingTest] = (0, import_react32.useState)(false);
15430
+ const [isSendingBroadcast, setIsSendingBroadcast] = (0, import_react32.useState)(false);
15431
+ const [broadcastProgress, setBroadcastProgress] = (0, import_react32.useState)({
15284
15432
  current: 0,
15285
15433
  total: 0,
15286
15434
  successful: 0,
@@ -15288,12 +15436,12 @@ function useWhatsAppState(props) {
15288
15436
  skipped: 0,
15289
15437
  percent: 0
15290
15438
  });
15291
- const [broadcastSummary, setBroadcastSummary] = (0, import_react31.useState)(null);
15292
- const [rowStatusMap, setRowStatusMap] = (0, import_react31.useState)({});
15293
- const clearBroadcastSummary = (0, import_react31.useCallback)(() => {
15439
+ const [broadcastSummary, setBroadcastSummary] = (0, import_react32.useState)(null);
15440
+ const [rowStatusMap, setRowStatusMap] = (0, import_react32.useState)({});
15441
+ const clearBroadcastSummary = (0, import_react32.useCallback)(() => {
15294
15442
  setBroadcastSummary(null);
15295
15443
  }, []);
15296
- const handleTestPhoneChange = (0, import_react31.useCallback)((val) => {
15444
+ const handleTestPhoneChange = (0, import_react32.useCallback)((val) => {
15297
15445
  setTestPhoneNumber(val);
15298
15446
  if (typeof window !== "undefined") {
15299
15447
  try {
@@ -15303,7 +15451,7 @@ function useWhatsAppState(props) {
15303
15451
  }
15304
15452
  }
15305
15453
  }, []);
15306
- const getRelationOptionsForCol = (0, import_react31.useCallback)(
15454
+ const getRelationOptionsForCol = (0, import_react32.useCallback)(
15307
15455
  (colName, parentColName) => {
15308
15456
  var _a2, _b2, _c, _d;
15309
15457
  if (parentColName) {
@@ -15346,7 +15494,7 @@ function useWhatsAppState(props) {
15346
15494
  },
15347
15495
  [relationOptions, subtableFilterableColumns, postSendActionTargetOptions, tableColumns2, filterableColumns]
15348
15496
  );
15349
- (0, import_react31.useEffect)(() => {
15497
+ (0, import_react32.useEffect)(() => {
15350
15498
  var _a2, _b2, _c, _d, _e;
15351
15499
  if (!executeAction) return;
15352
15500
  const targets = [];
@@ -15440,7 +15588,7 @@ function useWhatsAppState(props) {
15440
15588
  }
15441
15589
  });
15442
15590
  }, [filterableColumns, selectedPhoneOption, referencedTableSchemas, tableColumns2, executeAction, selectedPostSendOption, orgId]);
15443
- (0, import_react31.useEffect)(() => {
15591
+ (0, import_react32.useEffect)(() => {
15444
15592
  var _a2, _b2, _c;
15445
15593
  if (!executeAction || !selectedSubtableFilterCol) return;
15446
15594
  if (((_a2 = selectedSubtableFilterCol.type) == null ? void 0 : _a2.toUpperCase()) !== "RELATION") return;
@@ -15491,7 +15639,7 @@ function useWhatsAppState(props) {
15491
15639
  }
15492
15640
  })();
15493
15641
  }, [selectedSubtableFilterCol, selectedPhoneOption, executeAction, orgId]);
15494
- (0, import_react31.useEffect)(() => {
15642
+ (0, import_react32.useEffect)(() => {
15495
15643
  var _a2, _b2;
15496
15644
  if (!executeAction || !selectedPostSendOption) return;
15497
15645
  if (selectedPostSendOption.type !== "RELATION") return;
@@ -15544,7 +15692,7 @@ function useWhatsAppState(props) {
15544
15692
  }
15545
15693
  })();
15546
15694
  }, [selectedPostSendOption, executeAction, orgId]);
15547
- const filteredRecords = (0, import_react31.useMemo)(() => {
15695
+ const filteredRecords = (0, import_react32.useMemo)(() => {
15548
15696
  const activeEntries = Object.entries(filters).filter(
15549
15697
  ([_, val]) => val !== void 0 && val !== null && val !== ""
15550
15698
  );
@@ -15576,7 +15724,7 @@ function useWhatsAppState(props) {
15576
15724
  });
15577
15725
  }, [rawRecords, filters, filterableColumns]);
15578
15726
  const filteredData = filteredRecords;
15579
- (0, import_react31.useEffect)(() => {
15727
+ (0, import_react32.useEffect)(() => {
15580
15728
  if (autoSelectCount !== null && autoSelectCount > 0) {
15581
15729
  isAutoSelectingRef.current = true;
15582
15730
  const sliced = filteredData.slice(0, autoSelectCount);
@@ -15594,7 +15742,7 @@ function useWhatsAppState(props) {
15594
15742
  isManualOverrideRef.current = false;
15595
15743
  prevAutoSelectCountRef.current = autoSelectCount;
15596
15744
  }, [autoSelectCount, filteredData]);
15597
- const embeddedTableExecuteAction = (0, import_react31.useCallback)(async (actionType, payload) => {
15745
+ const embeddedTableExecuteAction = (0, import_react32.useCallback)(async (actionType, payload) => {
15598
15746
  if (actionType === "FETCH_TABLE_DATA") {
15599
15747
  const colFilters = (payload == null ? void 0 : payload.columnFilters) || (payload == null ? void 0 : payload.filters);
15600
15748
  const searchQuery = payload == null ? void 0 : payload.search;
@@ -15637,10 +15785,10 @@ function useWhatsAppState(props) {
15637
15785
  const handleClearFilters = () => {
15638
15786
  setFilters({});
15639
15787
  };
15640
- const activeFiltersCount = (0, import_react31.useMemo)(() => {
15788
+ const activeFiltersCount = (0, import_react32.useMemo)(() => {
15641
15789
  return Object.values(filters).filter((v) => v !== "").length;
15642
15790
  }, [filters]);
15643
- const handleSelectionChange = (0, import_react31.useCallback)((selectedIds) => {
15791
+ const handleSelectionChange = (0, import_react32.useCallback)((selectedIds) => {
15644
15792
  setSelectedRowIds((prev) => {
15645
15793
  if (prev.length === selectedIds.length && prev.every((id, idx) => id === selectedIds[idx])) {
15646
15794
  return prev;
@@ -15654,13 +15802,13 @@ function useWhatsAppState(props) {
15654
15802
  return selectedIds;
15655
15803
  });
15656
15804
  }, [autoSelectCount]);
15657
- const handleRowToggle = (0, import_react31.useCallback)((rowId, checked) => {
15805
+ const handleRowToggle = (0, import_react32.useCallback)((rowId, checked) => {
15658
15806
  if (autoSelectCount !== null && autoSelectCount > 0) {
15659
15807
  isManualOverrideRef.current = true;
15660
15808
  setAutoSelectCount(null);
15661
15809
  }
15662
15810
  }, [autoSelectCount]);
15663
- const toggleRowSelection = (0, import_react31.useCallback)((rowId, checked) => {
15811
+ const toggleRowSelection = (0, import_react32.useCallback)((rowId, checked) => {
15664
15812
  if (autoSelectCount !== null && autoSelectCount > 0) {
15665
15813
  isManualOverrideRef.current = true;
15666
15814
  setAutoSelectCount(null);
@@ -15676,15 +15824,15 @@ function useWhatsAppState(props) {
15676
15824
  return prev;
15677
15825
  });
15678
15826
  }, [autoSelectCount]);
15679
- const [templates, setTemplates] = (0, import_react31.useState)([]);
15680
- const [selectedTemplateId, setSelectedTemplateId] = (0, import_react31.useState)(null);
15681
- const [isLoading, setIsLoading] = (0, import_react31.useState)(true);
15682
- const [fetchError, setFetchError] = (0, import_react31.useState)(null);
15683
- const [isModalOpen, setIsModalOpen] = (0, import_react31.useState)(false);
15684
- const [isDropdownOpen, setIsDropdownOpen] = (0, import_react31.useState)(false);
15685
- const [isDeleting, setIsDeleting] = (0, import_react31.useState)(false);
15686
- const [feedback, setFeedback] = (0, import_react31.useState)(null);
15687
- const loadTemplates = (0, import_react31.useCallback)(async () => {
15827
+ const [templates, setTemplates] = (0, import_react32.useState)([]);
15828
+ const [selectedTemplateId, setSelectedTemplateId] = (0, import_react32.useState)(null);
15829
+ const [isLoading, setIsLoading] = (0, import_react32.useState)(true);
15830
+ const [fetchError, setFetchError] = (0, import_react32.useState)(null);
15831
+ const [isModalOpen, setIsModalOpen] = (0, import_react32.useState)(false);
15832
+ const [isDropdownOpen, setIsDropdownOpen] = (0, import_react32.useState)(false);
15833
+ const [isDeleting, setIsDeleting] = (0, import_react32.useState)(false);
15834
+ const [feedback, setFeedback] = (0, import_react32.useState)(null);
15835
+ const loadTemplates = (0, import_react32.useCallback)(async () => {
15688
15836
  var _a2, _b2;
15689
15837
  if (!executeAction) {
15690
15838
  setIsLoading(false);
@@ -15736,13 +15884,13 @@ function useWhatsAppState(props) {
15736
15884
  setIsLoading(false);
15737
15885
  }
15738
15886
  }, [executeAction, orgId]);
15739
- (0, import_react31.useEffect)(() => {
15887
+ (0, import_react32.useEffect)(() => {
15740
15888
  loadTemplates();
15741
15889
  }, [loadTemplates]);
15742
- const selectedTemplate = (0, import_react31.useMemo)(() => {
15890
+ const selectedTemplate = (0, import_react32.useMemo)(() => {
15743
15891
  return templates.find((t) => t.id === selectedTemplateId) || null;
15744
15892
  }, [templates, selectedTemplateId]);
15745
- const templateBodyText = (0, import_react31.useMemo)(() => {
15893
+ const templateBodyText = (0, import_react32.useMemo)(() => {
15746
15894
  if (!(selectedTemplate == null ? void 0 : selectedTemplate.components)) return "";
15747
15895
  const bodyComp = selectedTemplate.components.find(
15748
15896
  (c) => {
@@ -15752,7 +15900,7 @@ function useWhatsAppState(props) {
15752
15900
  );
15753
15901
  return (bodyComp == null ? void 0 : bodyComp.text) || "";
15754
15902
  }, [selectedTemplate]);
15755
- const templateHeaderComp = (0, import_react31.useMemo)(() => {
15903
+ const templateHeaderComp = (0, import_react32.useMemo)(() => {
15756
15904
  if (!(selectedTemplate == null ? void 0 : selectedTemplate.components)) return null;
15757
15905
  return selectedTemplate.components.find(
15758
15906
  (c) => {
@@ -15761,8 +15909,8 @@ function useWhatsAppState(props) {
15761
15909
  }
15762
15910
  ) || null;
15763
15911
  }, [selectedTemplate]);
15764
- const [headerMediaUrl, setHeaderMediaUrl] = (0, import_react31.useState)("");
15765
- (0, import_react31.useEffect)(() => {
15912
+ const [headerMediaUrl, setHeaderMediaUrl] = (0, import_react32.useState)("");
15913
+ (0, import_react32.useEffect)(() => {
15766
15914
  if (!templateHeaderComp) {
15767
15915
  setHeaderMediaUrl("");
15768
15916
  return;
@@ -15779,7 +15927,7 @@ function useWhatsAppState(props) {
15779
15927
  setHeaderMediaUrl("");
15780
15928
  }
15781
15929
  }, [templateHeaderComp, selectedTemplate == null ? void 0 : selectedTemplate.name]);
15782
- const handleHeaderMediaUrlChange = (0, import_react31.useCallback)(
15930
+ const handleHeaderMediaUrlChange = (0, import_react32.useCallback)(
15783
15931
  (newUrl) => {
15784
15932
  setHeaderMediaUrl(newUrl);
15785
15933
  if ((selectedTemplate == null ? void 0 : selectedTemplate.name) && typeof window !== "undefined") {
@@ -15798,7 +15946,7 @@ function useWhatsAppState(props) {
15798
15946
  },
15799
15947
  [selectedTemplate == null ? void 0 : selectedTemplate.name]
15800
15948
  );
15801
- const handleResetHeaderMediaUrl = (0, import_react31.useCallback)(() => {
15949
+ const handleResetHeaderMediaUrl = (0, import_react32.useCallback)(() => {
15802
15950
  if ((selectedTemplate == null ? void 0 : selectedTemplate.name) && typeof window !== "undefined") {
15803
15951
  try {
15804
15952
  localStorage.removeItem(`whatsapp_template_media_${selectedTemplate.name}`);
@@ -15812,8 +15960,8 @@ function useWhatsAppState(props) {
15812
15960
  );
15813
15961
  setHeaderMediaUrl(defaultUrl || "");
15814
15962
  }, [templateHeaderComp, selectedTemplate == null ? void 0 : selectedTemplate.name]);
15815
- const [isUploadingMedia, setIsUploadingMedia] = (0, import_react31.useState)(false);
15816
- const handleFileUpload = (0, import_react31.useCallback)(
15963
+ const [isUploadingMedia, setIsUploadingMedia] = (0, import_react32.useState)(false);
15964
+ const handleFileUpload = (0, import_react32.useCallback)(
15817
15965
  async (file, templateName) => {
15818
15966
  const tplName = templateName || (selectedTemplate == null ? void 0 : selectedTemplate.name) || "";
15819
15967
  if (!file) return;
@@ -15854,14 +16002,14 @@ function useWhatsAppState(props) {
15854
16002
  },
15855
16003
  [selectedTemplate == null ? void 0 : selectedTemplate.name]
15856
16004
  );
15857
- const templateVariables = (0, import_react31.useMemo)(() => {
16005
+ const templateVariables = (0, import_react32.useMemo)(() => {
15858
16006
  return extractTemplateVariables(selectedTemplate);
15859
16007
  }, [selectedTemplate]);
15860
- const [variableMapping, setVariableMapping] = (0, import_react31.useState)({});
15861
- (0, import_react31.useEffect)(() => {
16008
+ const [variableMapping, setVariableMapping] = (0, import_react32.useState)({});
16009
+ (0, import_react32.useEffect)(() => {
15862
16010
  setVariableMapping({});
15863
16011
  }, [selectedTemplateId]);
15864
- const textableColumnOptions = (0, import_react31.useMemo)(() => {
16012
+ const textableColumnOptions = (0, import_react32.useMemo)(() => {
15865
16013
  return getTextableColumnOptions({
15866
16014
  tableColumns: tableColumns2,
15867
16015
  selectedPhoneOption,
@@ -15887,7 +16035,7 @@ function useWhatsAppState(props) {
15887
16035
  });
15888
16036
  });
15889
16037
  };
15890
- const existingTemplateNames = (0, import_react31.useMemo)(() => {
16038
+ const existingTemplateNames = (0, import_react32.useMemo)(() => {
15891
16039
  return templates.map((t) => t.name);
15892
16040
  }, [templates]);
15893
16041
  const handleDeleteTemplate = async () => {
@@ -15934,14 +16082,14 @@ function useWhatsAppState(props) {
15934
16082
  postSendActionColumn,
15935
16083
  postSendActionValue
15936
16084
  );
15937
- const isStaticVariableMissing = (0, import_react31.useMemo)(() => {
16085
+ const isStaticVariableMissing = (0, import_react32.useMemo)(() => {
15938
16086
  return isStaticVariableIncomplete(templateVariables, variableMapping);
15939
16087
  }, [templateVariables, variableMapping]);
15940
- const currentRecords = (0, import_react31.useMemo)(() => {
16088
+ const currentRecords = (0, import_react32.useMemo)(() => {
15941
16089
  var _a2;
15942
16090
  return rawRecords && rawRecords.length > 0 ? rawRecords : Array.isArray(props.data) ? props.data : Array.isArray((_a2 = props.data) == null ? void 0 : _a2.records) ? props.data.records : [];
15943
16091
  }, [rawRecords, props.data]);
15944
- const preparedRecipients = (0, import_react31.useMemo)(() => {
16092
+ const preparedRecipients = (0, import_react32.useMemo)(() => {
15945
16093
  return prepareRecipients({
15946
16094
  selectedIds: selectedRowIds,
15947
16095
  records: currentRecords,
@@ -15961,7 +16109,7 @@ function useWhatsAppState(props) {
15961
16109
  selectedSubtableFilterCol
15962
16110
  ]);
15963
16111
  const finalRecipientCount = preparedRecipients.length;
15964
- const validMainRowsCount = (0, import_react31.useMemo)(() => {
16112
+ const validMainRowsCount = (0, import_react32.useMemo)(() => {
15965
16113
  const rowIdSet = new Set(
15966
16114
  preparedRecipients.map((r) => r.mainRowId).filter(Boolean)
15967
16115
  );
@@ -16070,7 +16218,7 @@ function useWhatsAppState(props) {
16070
16218
  setIsSendingTest(false);
16071
16219
  }
16072
16220
  };
16073
- const handleSendMessages = (0, import_react31.useCallback)(async () => {
16221
+ const handleSendMessages = (0, import_react32.useCallback)(async () => {
16074
16222
  var _a2, _b2;
16075
16223
  if (isSendDisabled || isSendingBroadcast) return;
16076
16224
  const recipients = preparedRecipients;
@@ -16376,7 +16524,7 @@ function useWhatsAppState(props) {
16376
16524
  }
16377
16525
 
16378
16526
  // src/components/WhatsAppComponent/ui/TemplateSelectionBlock.tsx
16379
- var import_react32 = require("react");
16527
+ var import_react33 = require("react");
16380
16528
  var import_lucide_react12 = require("lucide-react");
16381
16529
  var import_jsx_runtime33 = require("react/jsx-runtime");
16382
16530
  function TemplateSelectionBlock({
@@ -16404,7 +16552,7 @@ function TemplateSelectionBlock({
16404
16552
  isUploadingMedia = false,
16405
16553
  handleFileUpload
16406
16554
  }) {
16407
- const fileInputRef = (0, import_react32.useRef)(null);
16555
+ const fileInputRef = (0, import_react33.useRef)(null);
16408
16556
  return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "col-span-12 lg:col-span-5 min-h-[26rem] h-full flex flex-col bg-slate-50/70 border border-slate-200 rounded-2xl p-3.5 relative", children: [
16409
16557
  /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "space-y-1.5 shrink-0", children: [
16410
16558
  /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex items-center justify-between pb-1.5 border-b border-slate-200/70 shrink-0 gap-2", children: [
@@ -17356,19 +17504,19 @@ function SettingsAndActionsBlock({
17356
17504
  }
17357
17505
 
17358
17506
  // src/components/WhatsAppComponent/inbox/useInboxState.ts
17359
- var import_react33 = require("react");
17507
+ var import_react34 = require("react");
17360
17508
  function useInboxState(orgId, actions) {
17361
- const [conversations, setConversations] = (0, import_react33.useState)([]);
17362
- const [activeConversationId, setActiveConversationId] = (0, import_react33.useState)(null);
17363
- const [messages, setMessages] = (0, import_react33.useState)([]);
17364
- const [isLoading, setIsLoading] = (0, import_react33.useState)(false);
17365
- const [isSending, setIsSending] = (0, import_react33.useState)(false);
17366
- const [error, setError] = (0, import_react33.useState)(null);
17367
- const actionsRef = (0, import_react33.useRef)(actions);
17368
- (0, import_react33.useEffect)(() => {
17509
+ const [conversations, setConversations] = (0, import_react34.useState)([]);
17510
+ const [activeConversationId, setActiveConversationId] = (0, import_react34.useState)(null);
17511
+ const [messages, setMessages] = (0, import_react34.useState)([]);
17512
+ const [isLoading, setIsLoading] = (0, import_react34.useState)(false);
17513
+ const [isSending, setIsSending] = (0, import_react34.useState)(false);
17514
+ const [error, setError] = (0, import_react34.useState)(null);
17515
+ const actionsRef = (0, import_react34.useRef)(actions);
17516
+ (0, import_react34.useEffect)(() => {
17369
17517
  actionsRef.current = actions;
17370
17518
  });
17371
- const fetchConversations = (0, import_react33.useCallback)(async () => {
17519
+ const fetchConversations = (0, import_react34.useCallback)(async () => {
17372
17520
  if (!orgId) return;
17373
17521
  const res = await actionsRef.current.getConversations(orgId);
17374
17522
  if (res.success && res.data) {
@@ -17377,7 +17525,7 @@ function useInboxState(orgId, actions) {
17377
17525
  setError(res.error);
17378
17526
  }
17379
17527
  }, [orgId]);
17380
- const fetchMessages = (0, import_react33.useCallback)(async (conversationId, silent = false) => {
17528
+ const fetchMessages = (0, import_react34.useCallback)(async (conversationId, silent = false) => {
17381
17529
  if (!silent) setIsLoading(true);
17382
17530
  const res = await actionsRef.current.getMessages(conversationId);
17383
17531
  if (res.success && res.data) {
@@ -17390,7 +17538,7 @@ function useInboxState(orgId, actions) {
17390
17538
  }
17391
17539
  if (!silent) setIsLoading(false);
17392
17540
  }, []);
17393
- (0, import_react33.useEffect)(() => {
17541
+ (0, import_react34.useEffect)(() => {
17394
17542
  fetchConversations();
17395
17543
  const interval = setInterval(() => {
17396
17544
  fetchConversations();
@@ -17489,17 +17637,17 @@ function ConversationList({ conversations, activeId, onSelect }) {
17489
17637
  }
17490
17638
 
17491
17639
  // src/components/WhatsAppComponent/inbox/ChatWindow.tsx
17492
- var import_react34 = require("react");
17640
+ var import_react35 = require("react");
17493
17641
  var import_lucide_react16 = require("lucide-react");
17494
17642
  var import_jsx_runtime37 = require("react/jsx-runtime");
17495
17643
  function ChatWindow({ activeConversation, messages, isLoading, isSending, onSendMessage }) {
17496
- const [inputText, setInputText] = (0, import_react34.useState)("");
17497
- const messagesTopRef = (0, import_react34.useRef)(null);
17644
+ const [inputText, setInputText] = (0, import_react35.useState)("");
17645
+ const messagesTopRef = (0, import_react35.useRef)(null);
17498
17646
  const scrollToTop = () => {
17499
17647
  var _a;
17500
17648
  (_a = messagesTopRef.current) == null ? void 0 : _a.scrollIntoView({ behavior: "smooth" });
17501
17649
  };
17502
- (0, import_react34.useEffect)(() => {
17650
+ (0, import_react35.useEffect)(() => {
17503
17651
  scrollToTop();
17504
17652
  }, [messages.length, activeConversation == null ? void 0 : activeConversation.id]);
17505
17653
  const handleSend = (e) => {
@@ -17615,7 +17763,7 @@ function WhatsAppComponent(props) {
17615
17763
  var _a;
17616
17764
  const { className = "", settings, orgId, componentId, executeAction } = props;
17617
17765
  const state = useWhatsAppState(props);
17618
- const [activeTab, setActiveTab] = import_react35.default.useState("broadcast");
17766
+ const [activeTab, setActiveTab] = import_react36.default.useState("broadcast");
17619
17767
  return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
17620
17768
  "div",
17621
17769
  {
@@ -18020,12 +18168,12 @@ function WhatsAppComponent(props) {
18020
18168
  }
18021
18169
 
18022
18170
  // src/components/FormBlock/FormBlock.tsx
18023
- var import_react36 = require("react");
18171
+ var import_react37 = require("react");
18024
18172
  var import_lucide_react18 = require("lucide-react");
18025
18173
  var import_jsx_runtime40 = require("react/jsx-runtime");
18026
18174
 
18027
18175
  // src/components/FormBlock/StyledFormBlock.tsx
18028
- var import_react37 = require("react");
18176
+ var import_react38 = require("react");
18029
18177
  var import_lucide_react19 = require("lucide-react");
18030
18178
 
18031
18179
  // src/components/FormBlock/formDesign.ts
@@ -18283,28 +18431,28 @@ function StyledFormBlock({
18283
18431
  recordId
18284
18432
  }) {
18285
18433
  const { showError, addToast } = useToast();
18286
- const uid = "fdz" + (0, import_react37.useId)().replace(/[^a-zA-Z0-9]/g, "");
18434
+ const uid = "fdz" + (0, import_react38.useId)().replace(/[^a-zA-Z0-9]/g, "");
18287
18435
  const design = schema == null ? void 0 : schema.design;
18288
18436
  const d = resolveFormDesign(design);
18289
18437
  const t = d.tokens;
18290
- const [formData, setFormData] = (0, import_react37.useState)(initialValues || {});
18291
- const [isSubmitting, setIsSubmitting] = (0, import_react37.useState)(false);
18292
- const [isSubmitted, setIsSubmitted] = (0, import_react37.useState)(false);
18293
- const [formError, setFormError] = (0, import_react37.useState)(null);
18294
- const [missingNames, setMissingNames] = (0, import_react37.useState)([]);
18295
- const errorRef = (0, import_react37.useRef)(null);
18296
- const [columns, setColumns] = (0, import_react37.useState)((schema == null ? void 0 : schema.columns) || []);
18297
- const [isLoadingSchema, setIsLoadingSchema] = (0, import_react37.useState)(false);
18298
- const [dragName, setDragName] = (0, import_react37.useState)(null);
18299
- const [drop, setDrop] = (0, import_react37.useState)(null);
18300
- const [resizing, setResizing] = (0, import_react37.useState)(null);
18301
- const resizeRef = (0, import_react37.useRef)(null);
18302
- const gridRef = (0, import_react37.useRef)(null);
18303
- const relationDictRef = (0, import_react37.useRef)({});
18304
- const relationRequestedRef = (0, import_react37.useRef)(/* @__PURE__ */ new Set());
18305
- const [, bumpRelationLabels] = (0, import_react37.useState)(0);
18438
+ const [formData, setFormData] = (0, import_react38.useState)(initialValues || {});
18439
+ const [isSubmitting, setIsSubmitting] = (0, import_react38.useState)(false);
18440
+ const [isSubmitted, setIsSubmitted] = (0, import_react38.useState)(false);
18441
+ const [formError, setFormError] = (0, import_react38.useState)(null);
18442
+ const [missingNames, setMissingNames] = (0, import_react38.useState)([]);
18443
+ const errorRef = (0, import_react38.useRef)(null);
18444
+ const [columns, setColumns] = (0, import_react38.useState)((schema == null ? void 0 : schema.columns) || []);
18445
+ const [isLoadingSchema, setIsLoadingSchema] = (0, import_react38.useState)(false);
18446
+ const [dragName, setDragName] = (0, import_react38.useState)(null);
18447
+ const [drop, setDrop] = (0, import_react38.useState)(null);
18448
+ const [resizing, setResizing] = (0, import_react38.useState)(null);
18449
+ const resizeRef = (0, import_react38.useRef)(null);
18450
+ const gridRef = (0, import_react38.useRef)(null);
18451
+ const relationDictRef = (0, import_react38.useRef)({});
18452
+ const relationRequestedRef = (0, import_react38.useRef)(/* @__PURE__ */ new Set());
18453
+ const [, bumpRelationLabels] = (0, import_react38.useState)(0);
18306
18454
  const targetTableId = (schema == null ? void 0 : schema.tableMetaId) || (schema == null ? void 0 : schema.tableId) || (schema == null ? void 0 : schema.id);
18307
- (0, import_react37.useEffect)(() => {
18455
+ (0, import_react38.useEffect)(() => {
18308
18456
  let isMounted = true;
18309
18457
  if ((!(schema == null ? void 0 : schema.columns) || schema.columns.length === 0) && targetTableId && executeAction && !previewMode) {
18310
18458
  setIsLoadingSchema(true);
@@ -18323,13 +18471,13 @@ function StyledFormBlock({
18323
18471
  isMounted = false;
18324
18472
  };
18325
18473
  }, [schema == null ? void 0 : schema.columns, targetTableId]);
18326
- (0, import_react37.useEffect)(() => {
18474
+ (0, import_react38.useEffect)(() => {
18327
18475
  if (submitMode === "update" || previewMode || !columns || columns.length === 0) return;
18328
18476
  const defaults = buildDefaultValues(columns);
18329
18477
  if (Object.keys(defaults).length === 0) return;
18330
18478
  setFormData((prev) => __spreadValues(__spreadValues({}, defaults), prev));
18331
18479
  }, [columns, submitMode, previewMode]);
18332
- (0, import_react37.useEffect)(() => {
18480
+ (0, import_react38.useEffect)(() => {
18333
18481
  if (previewMode || !executeAction || !columns) return;
18334
18482
  for (const col of columns) {
18335
18483
  if ((col.type || "").toUpperCase() !== "RELATION") continue;
@@ -18882,7 +19030,7 @@ function StyledFormBlock({
18882
19030
  }
18883
19031
 
18884
19032
  // src/themes/ThemeScope.tsx
18885
- var React30 = __toESM(require("react"));
19033
+ var React31 = __toESM(require("react"));
18886
19034
  var import_jsx_runtime42 = require("react/jsx-runtime");
18887
19035
  var UNIVERSE_THEME_IDS = ["classic", "clean", "ocean", "warm"];
18888
19036
  function resolveUniverseTheme(value) {
@@ -18893,7 +19041,7 @@ function withThemeScope(Component) {
18893
19041
  var _a, _b, _c;
18894
19042
  const p = props;
18895
19043
  const theme = resolveUniverseTheme((_c = (_a = p.settings) == null ? void 0 : _a.theme) != null ? _c : (_b = p.config) == null ? void 0 : _b.theme);
18896
- return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { "data-theme": theme, style: { display: "contents" }, children: React30.createElement(Component, props) });
19044
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { "data-theme": theme, style: { display: "contents" }, children: React31.createElement(Component, props) });
18897
19045
  }
18898
19046
  ThemeScoped.displayName = `ThemeScoped(${Component.displayName || Component.name || "Component"})`;
18899
19047
  return ThemeScoped;
@@ -18909,12 +19057,16 @@ var UNIVERSE_COMPONENTS = {
18909
19057
  };
18910
19058
  // Annotate the CommonJS export names for ESM import in node:
18911
19059
  0 && (module.exports = {
19060
+ BOOLEAN_BUTTON_FALSE_ID,
19061
+ BOOLEAN_BUTTON_TRUE_ID,
18912
19062
  COLUMN_CAPABILITIES,
18913
19063
  COLUMN_DEFAULT_INPUT_CONFIG,
18914
19064
  COLUMN_TYPES,
18915
19065
  COLUMN_TYPE_LABELS,
18916
19066
  ColumnHeaderTitle,
18917
19067
  CreateTemplateModal,
19068
+ DEFAULT_BOOLEAN_FALSE_LABEL,
19069
+ DEFAULT_BOOLEAN_TRUE_LABEL,
18918
19070
  DEFAULT_FILTER_COLUMN_TYPES,
18919
19071
  DEFAULT_PLACEMENT_STATUS_COLORS,
18920
19072
  DatePickerCell,
@@ -18988,6 +19140,7 @@ var UNIVERSE_COMPONENTS = {
18988
19140
  formatTimeInput,
18989
19141
  formatTimeIso,
18990
19142
  generateWhatsAppLink,
19143
+ getBooleanButtonLabels,
18991
19144
  getColumnDefaultFilter,
18992
19145
  getDefaultFilterColumns,
18993
19146
  getDeterministicPastelBadge,
@@ -19005,6 +19158,7 @@ var UNIVERSE_COMPONENTS = {
19005
19158
  hasConsecutiveVariables,
19006
19159
  hasFloatingVariables,
19007
19160
  hasInsufficientContextBetweenVariables,
19161
+ isBooleanButtonsColumn,
19008
19162
  isDuplicateTemplate,
19009
19163
  isDuplicateTemplateName,
19010
19164
  isPerRecordSourceColumn,