@universe-platform/ui 0.1.0-beta.66 → 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,19 +60,28 @@ 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,
72
76
  DynamicFiltersBlock: () => DynamicFiltersBlock,
77
+ EMPTY_IF_CONDITION: () => EMPTY_IF_CONDITION,
73
78
  FORMULA_COLUMN_TYPE: () => FORMULA_COLUMN_TYPE,
79
+ FORMULA_FUNCTION_GROUPS: () => FORMULA_FUNCTION_GROUPS,
80
+ FORMULA_OPERATOR_GROUPS: () => FORMULA_OPERATOR_GROUPS,
74
81
  FORMULA_SOURCE_TYPES: () => FORMULA_SOURCE_TYPES,
82
+ FORMULA_TYPE_LABELS: () => FORMULA_TYPE_LABELS,
75
83
  LinkPickerCell: () => LinkPickerCell,
84
+ MAX_FILTER_CONDITIONS: () => MAX_FILTER_CONDITIONS,
76
85
  NON_TEXT_TYPES: () => NON_TEXT_TYPES,
77
86
  PASTEL_PALETTES: () => PASTEL_PALETTES,
78
87
  PAYMENT_REPORTS_ACTIONS: () => PAYMENT_REPORTS_ACTIONS,
@@ -108,6 +117,8 @@ __export(src_exports, {
108
117
  applyFormulaColumns: () => applyFormulaColumns,
109
118
  applyRelationCopy: () => applyRelationCopy,
110
119
  buildColumnOptions: () => buildColumnOptions,
120
+ buildIfConditionExpression: () => buildIfConditionExpression,
121
+ buildIfExpression: () => buildIfExpression,
111
122
  buildRelationCopyPatch: () => buildRelationCopyPatch,
112
123
  buildRelationRef: () => buildRelationRef,
113
124
  calculateMinColumnWidth: () => calculateMinColumnWidth,
@@ -117,11 +128,14 @@ __export(src_exports, {
117
128
  columnRefLabel: () => columnRefLabel,
118
129
  computeFormulaValue: () => computeFormulaValue,
119
130
  describePerRecordFormula: () => describePerRecordFormula,
131
+ describeRefFilter: () => describeRefFilter,
120
132
  enrichRowsWithRelations: () => enrichRowsWithRelations,
121
133
  evaluateFormula: () => evaluateFormula,
122
134
  extractFormulaFields: () => extractFormulaFields,
123
135
  extractUniqueVariableIndices: () => extractUniqueVariableIndices,
124
136
  extractVariableIndices: () => extractVariableIndices,
137
+ filterKindOfType: () => filterKindOfType,
138
+ filterSignature: () => filterSignature,
125
139
  findVariableAtPosition: () => findVariableAtPosition,
126
140
  formatConflictCellValue: () => formatConflictCellValue,
127
141
  formatFileSize: () => formatFileSize,
@@ -129,10 +143,13 @@ __export(src_exports, {
129
143
  formatTimeInput: () => formatTimeInput,
130
144
  formatTimeIso: () => formatTimeIso,
131
145
  generateWhatsAppLink: () => generateWhatsAppLink,
146
+ getBooleanButtonLabels: () => getBooleanButtonLabels,
132
147
  getColumnDefaultFilter: () => getColumnDefaultFilter,
133
148
  getDefaultFilterColumns: () => getDefaultFilterColumns,
134
149
  getDeterministicPastelBadge: () => getDeterministicPastelBadge,
135
150
  getEligibleCopyTargets: () => getEligibleCopyTargets,
151
+ getFilterOps: () => getFilterOps,
152
+ getIfConditionOps: () => getIfConditionOps,
136
153
  getNextVariableIndex: () => getNextVariableIndex,
137
154
  getRelationButtonColumns: () => getRelationButtonColumns,
138
155
  getRelationCopyLockedTargets: () => getRelationCopyLockedTargets,
@@ -144,6 +161,7 @@ __export(src_exports, {
144
161
  hasConsecutiveVariables: () => hasConsecutiveVariables,
145
162
  hasFloatingVariables: () => hasFloatingVariables,
146
163
  hasInsufficientContextBetweenVariables: () => hasInsufficientContextBetweenVariables,
164
+ isBooleanButtonsColumn: () => isBooleanButtonsColumn,
147
165
  isDuplicateTemplate: () => isDuplicateTemplate,
148
166
  isDuplicateTemplateName: () => isDuplicateTemplateName,
149
167
  isPerRecordSourceColumn: () => isPerRecordSourceColumn,
@@ -157,6 +175,7 @@ __export(src_exports, {
157
175
  isValidTemplateName: () => isValidTemplateName,
158
176
  isWordToken: () => isWordToken,
159
177
  makeCellRefKey: () => makeCellRefKey,
178
+ matchesRefFilter: () => matchesRefFilter,
160
179
  measureTextWidth: () => measureTextWidth,
161
180
  missingPaymentReportsFields: () => missingPaymentReportsFields,
162
181
  normalizePerRecordFormula: () => normalizePerRecordFormula,
@@ -176,6 +195,7 @@ __export(src_exports, {
176
195
  resolveUniverseTheme: () => resolveUniverseTheme,
177
196
  sanitizeDefaultFilter: () => sanitizeDefaultFilter,
178
197
  sanitizePhoneNumber: () => sanitizePhoneNumber,
198
+ sanitizeRefFilter: () => sanitizeRefFilter,
179
199
  sanitizeTemplateNameInput: () => sanitizeTemplateNameInput,
180
200
  seamlessVariableEngine: () => seamlessVariableEngine,
181
201
  splitHeaderTitle: () => splitHeaderTitle,
@@ -881,6 +901,187 @@ function formatFileSize(bytes) {
881
901
  return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + " " + sizes[i];
882
902
  }
883
903
 
904
+ // ../shared/src/formulaFilters.ts
905
+ var MAX_FILTER_CONDITIONS = 5;
906
+ var MAX_VALUE_LENGTH = 200;
907
+ function filterKindOfType(type) {
908
+ const t = String(type || "").toUpperCase();
909
+ if (t === "NUMBER" || t === "CURRENCY") return "number";
910
+ if (t === "DATE") return "date";
911
+ if (t === "BOOLEAN") return "boolean";
912
+ if (t === "RELATION") return "relation";
913
+ return "text";
914
+ }
915
+ var op = (id, label, needsValue = true) => ({ id, label, needsValue });
916
+ var EMPTY_OPS = [op("empty", "\u05E8\u05D9\u05E7", false), op("notempty", "\u05DC\u05D0 \u05E8\u05D9\u05E7", false)];
917
+ var OPS_BY_KIND = {
918
+ text: [
919
+ op("eq", "\u05E9\u05D5\u05D5\u05D4 \u05DC"),
920
+ op("ne", "\u05E9\u05D5\u05E0\u05D4 \u05DE"),
921
+ op("contains", "\u05DE\u05DB\u05D9\u05DC"),
922
+ op("notcontains", "\u05DC\u05D0 \u05DE\u05DB\u05D9\u05DC"),
923
+ op("starts", "\u05DE\u05EA\u05D7\u05D9\u05DC \u05D1"),
924
+ op("ends", "\u05DE\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1"),
925
+ op("in", "\u05D0\u05D7\u05D3 \u05DE\u05EA\u05D5\u05DA (\u05DE\u05D5\u05E4\u05E8\u05D3\u05D9\u05DD \u05D1\u05E4\u05E1\u05D9\u05E7)"),
926
+ ...EMPTY_OPS
927
+ ],
928
+ relation: [
929
+ op("eq", "\u05E9\u05D5\u05D5\u05D4 \u05DC"),
930
+ op("ne", "\u05E9\u05D5\u05E0\u05D4 \u05DE"),
931
+ op("contains", "\u05DE\u05DB\u05D9\u05DC"),
932
+ op("in", "\u05D0\u05D7\u05D3 \u05DE\u05EA\u05D5\u05DA (\u05DE\u05D5\u05E4\u05E8\u05D3\u05D9\u05DD \u05D1\u05E4\u05E1\u05D9\u05E7)"),
933
+ ...EMPTY_OPS
934
+ ],
935
+ number: [
936
+ op("eq", "\u05E9\u05D5\u05D5\u05D4 \u05DC"),
937
+ op("ne", "\u05E9\u05D5\u05E0\u05D4 \u05DE"),
938
+ op("gt", "\u05D2\u05D3\u05D5\u05DC \u05DE"),
939
+ op("lt", "\u05E7\u05D8\u05DF \u05DE"),
940
+ op("ge", "\u05D2\u05D3\u05D5\u05DC \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC"),
941
+ op("le", "\u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC"),
942
+ ...EMPTY_OPS
943
+ ],
944
+ date: [
945
+ op("eq", "\u05D1\u05EA\u05D0\u05E8\u05D9\u05DA"),
946
+ op("ne", "\u05DC\u05D0 \u05D1\u05EA\u05D0\u05E8\u05D9\u05DA"),
947
+ op("gt", "\u05D0\u05D7\u05E8\u05D9"),
948
+ op("lt", "\u05DC\u05E4\u05E0\u05D9"),
949
+ op("ge", "\u05D1\u05EA\u05D0\u05E8\u05D9\u05DA \u05D0\u05D5 \u05D0\u05D7\u05E8\u05D9\u05D5"),
950
+ op("le", "\u05D1\u05EA\u05D0\u05E8\u05D9\u05DA \u05D0\u05D5 \u05DC\u05E4\u05E0\u05D9\u05D5"),
951
+ ...EMPTY_OPS
952
+ ],
953
+ boolean: [op("yes", "\u05DE\u05E1\u05D5\u05DE\u05DF (\u05DB\u05DF)", false), op("no", "\u05DC\u05D0 \u05DE\u05E1\u05D5\u05DE\u05DF (\u05DC\u05D0)", false)]
954
+ };
955
+ var getFilterOps = (type) => OPS_BY_KIND[filterKindOfType(type)];
956
+ var ALL_OPS = new Set(Object.values(OPS_BY_KIND).flat().map((o) => o.id));
957
+ var NEEDS_VALUE = new Map(Object.values(OPS_BY_KIND).flat().map((o) => [o.id, o.needsValue]));
958
+ function sanitizeRefFilter(raw) {
959
+ if (!raw || typeof raw !== "object") return null;
960
+ const r = raw;
961
+ if (!Array.isArray(r.conditions)) return null;
962
+ const conditions = [];
963
+ for (const c of r.conditions.slice(0, MAX_FILTER_CONDITIONS)) {
964
+ if (!c || typeof c !== "object") continue;
965
+ const field = typeof c.field === "string" ? c.field.trim().slice(0, MAX_VALUE_LENGTH) : "";
966
+ const opId = typeof c.op === "string" ? c.op : "";
967
+ if (!field || !ALL_OPS.has(opId)) continue;
968
+ const needs = NEEDS_VALUE.get(opId) === true;
969
+ const value = typeof c.value === "string" ? c.value.trim().slice(0, MAX_VALUE_LENGTH) : typeof c.value === "number" ? String(c.value) : "";
970
+ if (needs && value === "") continue;
971
+ conditions.push({ field, op: opId, value: needs ? value : "" });
972
+ }
973
+ if (conditions.length === 0) return null;
974
+ return { join: r.join === "OR" ? "OR" : "AND", conditions };
975
+ }
976
+ function filterSignature(f) {
977
+ var _a;
978
+ if (!f || !((_a = f.conditions) == null ? void 0 : _a.length)) return "";
979
+ return `${f.join}:${f.conditions.map((c) => `${c.field}${c.op}${c.value}`).join("")}`;
980
+ }
981
+ var SHORT_LABELS = {
982
+ eq: "=",
983
+ ne: "\u2260",
984
+ gt: ">",
985
+ lt: "<",
986
+ ge: "\u2265",
987
+ le: "\u2264",
988
+ contains: "\u05DE\u05DB\u05D9\u05DC",
989
+ notcontains: "\u05DC\u05D0 \u05DE\u05DB\u05D9\u05DC",
990
+ starts: "\u05DE\u05EA\u05D7\u05D9\u05DC \u05D1",
991
+ ends: "\u05DE\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1",
992
+ in: "\u05D0\u05D7\u05D3 \u05DE\u05EA\u05D5\u05DA",
993
+ empty: "\u05E8\u05D9\u05E7",
994
+ notempty: "\u05DC\u05D0 \u05E8\u05D9\u05E7",
995
+ yes: "\u05DE\u05E1\u05D5\u05DE\u05DF",
996
+ no: "\u05DC\u05D0 \u05DE\u05E1\u05D5\u05DE\u05DF"
997
+ };
998
+ function describeRefFilter(f) {
999
+ var _a;
1000
+ if (!f || !((_a = f.conditions) == null ? void 0 : _a.length)) return "";
1001
+ const sep = f.join === "OR" ? " \u05D0\u05D5 " : " \u05D5\u05D2\u05DD ";
1002
+ return f.conditions.map((c) => {
1003
+ const needs = NEEDS_VALUE.get(c.op) === true;
1004
+ return needs ? `${c.field} ${SHORT_LABELS[c.op]} ${c.value}` : `${c.field} ${SHORT_LABELS[c.op]}`;
1005
+ }).join(sep);
1006
+ }
1007
+ var norm = (x) => String(x != null ? x : "").trim().toLowerCase();
1008
+ var isBlankValue = (x) => x === null || x === void 0 || typeof x === "string" && x.trim() === "" || Array.isArray(x) && x.every(isBlankValue);
1009
+ var isoDate = (x) => typeof x === "string" && /^\d{4}-\d{2}-\d{2}/.test(x.trim()) ? x.trim().slice(0, 10) : null;
1010
+ var numOf = (x) => {
1011
+ if (typeof x === "number") return Number.isFinite(x) ? x : null;
1012
+ if (typeof x === "string" && x.trim() !== "") {
1013
+ const n = Number(x);
1014
+ return Number.isFinite(n) ? n : null;
1015
+ }
1016
+ return null;
1017
+ };
1018
+ function compare(l, r) {
1019
+ const ld = isoDate(l), rd = isoDate(r);
1020
+ if (ld && rd) return ld < rd ? -1 : ld > rd ? 1 : 0;
1021
+ const ln = numOf(l), rn = numOf(r);
1022
+ if (ln !== null && rn !== null) return ln < rn ? -1 : ln > rn ? 1 : 0;
1023
+ const a = norm(l), b = norm(r);
1024
+ return a < b ? -1 : a > b ? 1 : 0;
1025
+ }
1026
+ var NEGATED = { ne: "eq", notcontains: "contains" };
1027
+ function matchSingle(opId, v, target) {
1028
+ switch (opId) {
1029
+ case "eq":
1030
+ return !isBlankValue(v) && compare(v, target) === 0;
1031
+ case "ne":
1032
+ return isBlankValue(v) || compare(v, target) !== 0;
1033
+ case "contains":
1034
+ return norm(v).includes(norm(target));
1035
+ case "notcontains":
1036
+ return !norm(v).includes(norm(target));
1037
+ case "starts":
1038
+ return norm(v).startsWith(norm(target));
1039
+ case "ends":
1040
+ return norm(v).endsWith(norm(target));
1041
+ case "in": {
1042
+ const list = target.split(",").map(norm).filter(Boolean);
1043
+ return list.includes(norm(v));
1044
+ }
1045
+ case "gt":
1046
+ return !isBlankValue(v) && compare(v, target) > 0;
1047
+ case "lt":
1048
+ return !isBlankValue(v) && compare(v, target) < 0;
1049
+ case "ge":
1050
+ return !isBlankValue(v) && compare(v, target) >= 0;
1051
+ case "le":
1052
+ return !isBlankValue(v) && compare(v, target) <= 0;
1053
+ case "empty":
1054
+ return isBlankValue(v);
1055
+ case "notempty":
1056
+ return !isBlankValue(v);
1057
+ case "yes": {
1058
+ if (v === true) return true;
1059
+ if (typeof v === "number") return v !== 0;
1060
+ return ["true", "1", "yes", "\u05DB\u05DF"].includes(norm(v));
1061
+ }
1062
+ case "no":
1063
+ return !matchSingle("yes", v, target);
1064
+ default:
1065
+ return false;
1066
+ }
1067
+ }
1068
+ function matchCondition(c, raw) {
1069
+ if (c.op === "empty") return isBlankValue(raw);
1070
+ if (c.op === "notempty") return !isBlankValue(raw);
1071
+ if (Array.isArray(raw)) {
1072
+ const positive = NEGATED[c.op];
1073
+ if (positive) return !raw.some((item) => matchSingle(positive, item, c.value));
1074
+ return raw.some((item) => matchSingle(c.op, item, c.value));
1075
+ }
1076
+ return matchSingle(c.op, raw, c.value);
1077
+ }
1078
+ function matchesRefFilter(filter, getValue) {
1079
+ var _a;
1080
+ if (!filter || !((_a = filter.conditions) == null ? void 0 : _a.length)) return true;
1081
+ const test = (c) => matchCondition(c, getValue(c.field));
1082
+ return filter.join === "OR" ? filter.conditions.some(test) : filter.conditions.every(test);
1083
+ }
1084
+
884
1085
  // ../shared/src/formula.ts
885
1086
  var FORMULA_COLUMN_TYPE = "FORMULA";
886
1087
  var FORMULA_SOURCE_TYPES = ["NUMBER", "CURRENCY", "STRING", "BOOLEAN", "DATE", "TIME", "PHONE"];
@@ -907,7 +1108,10 @@ function makeCellRefKey(existing, field, agg) {
907
1108
  for (let n = 2; (existing || []).some((r) => r.key === key); n++) key = `${base} (${n})`;
908
1109
  return key;
909
1110
  }
910
- var perRecordRefValueKey = (r) => `ref:${r.tableId}::${r.agg ? "" : r.recordId || ""}::${r.field}::${r.agg || ""}`;
1111
+ var perRecordRefValueKey = (r) => {
1112
+ const sig = r.agg ? filterSignature(r.filter) : "";
1113
+ return `ref:${r.tableId}::${r.agg ? "" : r.recordId || ""}::${r.field}::${r.agg || ""}${sig ? `::${sig}` : ""}`;
1114
+ };
911
1115
  function sanitizeRefs(raw) {
912
1116
  var _a, _b, _c, _d;
913
1117
  if (!Array.isArray(raw)) return [];
@@ -920,15 +1124,16 @@ function sanitizeRefs(raw) {
920
1124
  const field = typeof r.field === "string" ? r.field : "";
921
1125
  if (!key.startsWith("@") || seen.has(key) || !tableId || !field) continue;
922
1126
  const agg = PER_RECORD_SOURCE_AGGS.includes(r.agg) ? r.agg : void 0;
1127
+ const filter = agg ? sanitizeRefFilter(r.filter) : null;
923
1128
  seen.add(key);
924
- out.push(__spreadValues({
1129
+ out.push(__spreadValues(__spreadValues({
925
1130
  key,
926
1131
  tableId,
927
1132
  tableName: String((_b = r.tableName) != null ? _b : "").slice(0, 200),
928
1133
  recordId: agg ? "" : String((_c = r.recordId) != null ? _c : ""),
929
1134
  recordLabel: agg ? "" : String((_d = r.recordLabel) != null ? _d : "").slice(0, 200),
930
1135
  field
931
- }, agg ? { agg } : {}));
1136
+ }, agg ? { agg } : {}), filter ? { filter } : {}));
932
1137
  }
933
1138
  return out;
934
1139
  }
@@ -955,7 +1160,8 @@ function describePerRecordFormula(f) {
955
1160
  if (!f) return "";
956
1161
  let text2 = f.expression;
957
1162
  for (const r of f.refs) {
958
- const path = r.agg ? `${PER_RECORD_AGG_LABELS[r.agg]} ${r.tableName} \u203A ${r.field}` : `${r.tableName} \u203A ${r.recordLabel || "\u05E8\u05E9\u05D5\u05DE\u05D4"} \u203A ${r.field}`;
1163
+ const filterText = r.agg ? describeRefFilter(r.filter) : "";
1164
+ const path = r.agg ? `${PER_RECORD_AGG_LABELS[r.agg]} ${r.tableName} \u203A ${r.field}${filterText ? ` [${filterText}]` : ""}` : `${r.tableName} \u203A ${r.recordLabel || "\u05E8\u05E9\u05D5\u05DE\u05D4"} \u203A ${r.field}`;
959
1165
  text2 = text2.split(`{${r.key}}`).join(`[${path}]`);
960
1166
  }
961
1167
  return text2;
@@ -1005,10 +1211,10 @@ function tokenize(src) {
1005
1211
  i += id[0].length;
1006
1212
  continue;
1007
1213
  }
1008
- const op = /^(>=|<=|<>|[-+*/%(),<>=&])/.exec(rest);
1009
- if (op) {
1010
- toks.push({ k: "op", v: op[0] });
1011
- i += op[0].length;
1214
+ const op2 = /^(>=|<=|<>|[-+*/%(),<>=&])/.exec(rest);
1215
+ if (op2) {
1216
+ toks.push({ k: "op", v: op2[0] });
1217
+ i += op2[0].length;
1012
1218
  continue;
1013
1219
  }
1014
1220
  throw new Error(`\u05EA\u05D5 \u05DC\u05D0 \u05DE\u05D5\u05DB\u05E8 \u05D1\u05E0\u05D5\u05E1\u05D7\u05D4: ${c}`);
@@ -1022,7 +1228,7 @@ var toNum = (x) => {
1022
1228
  };
1023
1229
  var isBlank = (x) => x === null || x === void 0 || x === "";
1024
1230
  var isNumLike = (x) => typeof x === "number" || typeof x === "string" && x.trim() !== "" && Number.isFinite(Number(x));
1025
- var isoDate = (x) => typeof x === "string" && /^\d{4}-\d{2}-\d{2}/.test(x) ? x.slice(0, 10) : null;
1231
+ var isoDate2 = (x) => typeof x === "string" && /^\d{4}-\d{2}-\d{2}/.test(x) ? x.slice(0, 10) : null;
1026
1232
  var truthy = (x) => {
1027
1233
  if (x === null || x === "") return false;
1028
1234
  if (typeof x === "number") return x !== 0 && !Number.isNaN(x);
@@ -1031,7 +1237,7 @@ var truthy = (x) => {
1031
1237
  };
1032
1238
  var text = (x) => String(x != null ? x : "").trim().toLowerCase();
1033
1239
  function compareValues(l, r) {
1034
- const ld = isoDate(l), rd = isoDate(r);
1240
+ const ld = isoDate2(l), rd = isoDate2(r);
1035
1241
  if (ld && rd) return ld < rd ? -1 : ld > rd ? 1 : 0;
1036
1242
  if ((isNumLike(l) || isBlank(l)) && (isNumLike(r) || isBlank(r))) {
1037
1243
  const a2 = toNum(l), b2 = toNum(r);
@@ -1072,9 +1278,9 @@ function evaluateFormula(expr, getField) {
1072
1278
  function parseExpr() {
1073
1279
  let l = parseConcat();
1074
1280
  while (isOp(">", "<", ">=", "<=", "=", "<>")) {
1075
- const op = eat().v, r = parseConcat();
1281
+ const op2 = eat().v, r = parseConcat();
1076
1282
  const c = compareValues(l, r);
1077
- l = (op === ">" ? c > 0 : op === "<" ? c < 0 : op === ">=" ? c >= 0 : op === "<=" ? c <= 0 : op === "=" ? c === 0 : c !== 0) ? 1 : 0;
1283
+ l = (op2 === ">" ? c > 0 : op2 === "<" ? c < 0 : op2 === ">=" ? c >= 0 : op2 === "<=" ? c <= 0 : op2 === "=" ? c === 0 : c !== 0) ? 1 : 0;
1078
1284
  }
1079
1285
  return l;
1080
1286
  }
@@ -1090,17 +1296,17 @@ function evaluateFormula(expr, getField) {
1090
1296
  function parseAdd() {
1091
1297
  let l = parseMul();
1092
1298
  while (isOp("+", "-")) {
1093
- const op = eat().v, r = parseMul();
1094
- l = op === "+" ? toNum(l) + toNum(r) : toNum(l) - toNum(r);
1299
+ const op2 = eat().v, r = parseMul();
1300
+ l = op2 === "+" ? toNum(l) + toNum(r) : toNum(l) - toNum(r);
1095
1301
  }
1096
1302
  return l;
1097
1303
  }
1098
1304
  function parseMul() {
1099
1305
  let l = parseUnary();
1100
1306
  while (isOp("*", "/", "%")) {
1101
- const op = eat().v, r = parseUnary();
1307
+ const op2 = eat().v, r = parseUnary();
1102
1308
  const a = toNum(l), b = toNum(r);
1103
- l = op === "*" ? a * b : op === "/" ? a / b : a % b;
1309
+ l = op2 === "*" ? a * b : op2 === "/" ? a / b : a % b;
1104
1310
  }
1105
1311
  return l;
1106
1312
  }
@@ -1184,7 +1390,7 @@ function evaluateFormula(expr, getField) {
1184
1390
  case "ISEMPTY":
1185
1391
  return isBlank(args[0]) ? 1 : 0;
1186
1392
  case "DAYS": {
1187
- const a = isoDate(args[0]), b = isoDate(args[1]);
1393
+ const a = isoDate2(args[0]), b = isoDate2(args[1]);
1188
1394
  return a && b ? Math.round((dayNumber(a) - dayNumber(b)) / 864e5) : null;
1189
1395
  }
1190
1396
  default:
@@ -1309,12 +1515,31 @@ function renameCopyTarget(col, oldName, newName) {
1309
1515
 
1310
1516
  // ../shared/src/relationButtons.ts
1311
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";
1312
1522
  function isRelationButtonsColumn(col) {
1313
1523
  var _a, _b;
1314
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);
1315
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
+ }
1316
1539
  function getRelationButtonColumns(columns) {
1317
- return (columns || []).filter((c) => isRelationButtonsColumn(c) && c.name !== "_id");
1540
+ return (columns || []).filter(
1541
+ (c) => (isRelationButtonsColumn(c) || isBooleanButtonsColumn(c)) && c.name !== "_id"
1542
+ );
1318
1543
  }
1319
1544
 
1320
1545
  // ../shared/src/defaultFilters.ts
@@ -1366,8 +1591,158 @@ function cleanPlacementFilterDefaults(defaults, allowedKeys) {
1366
1591
  return Object.keys(out).length > 0 ? out : void 0;
1367
1592
  }
1368
1593
 
1594
+ // ../shared/src/formulaBuilder.ts
1595
+ var FORMULA_TYPE_LABELS = {
1596
+ NUMBER: "\u05DE\u05E1\u05E4\u05E8",
1597
+ CURRENCY: "\u05DE\u05D8\u05D1\u05E2",
1598
+ STRING: "\u05D8\u05E7\u05E1\u05D8",
1599
+ PHONE: "\u05D8\u05DC\u05E4\u05D5\u05DF",
1600
+ TIME: "\u05E9\u05E2\u05D4",
1601
+ DATE: "\u05EA\u05D0\u05E8\u05D9\u05DA",
1602
+ BOOLEAN: "\u05DB\u05DF/\u05DC\u05D0"
1603
+ };
1604
+ var FORMULA_OPERATOR_GROUPS = [
1605
+ {
1606
+ label: "\u05D7\u05E9\u05D1\u05D5\u05DF",
1607
+ items: [
1608
+ { label: "+ \u05D7\u05D9\u05D1\u05D5\u05E8", insert: " + " },
1609
+ { label: "- \u05D7\u05D9\u05E1\u05D5\u05E8", insert: " - " },
1610
+ { label: "* \u05DB\u05E4\u05DC", insert: " * " },
1611
+ { label: "/ \u05D7\u05D9\u05DC\u05D5\u05E7", insert: " / " },
1612
+ { label: "% \u05E9\u05D0\u05E8\u05D9\u05EA", insert: " % " }
1613
+ ]
1614
+ },
1615
+ {
1616
+ label: "\u05D4\u05E9\u05D5\u05D5\u05D0\u05D4",
1617
+ items: [
1618
+ { label: "= \u05E9\u05D5\u05D5\u05D4", insert: " = " },
1619
+ { label: "<> \u05E9\u05D5\u05E0\u05D4", insert: " <> " },
1620
+ { label: "> \u05D2\u05D3\u05D5\u05DC \u05DE", insert: " > " },
1621
+ { label: "< \u05E7\u05D8\u05DF \u05DE", insert: " < " },
1622
+ { label: ">= \u05D2\u05D3\u05D5\u05DC \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4", insert: " >= " },
1623
+ { label: "<= \u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4", insert: " <= " }
1624
+ ]
1625
+ },
1626
+ { label: "\u05D8\u05E7\u05E1\u05D8", items: [{ label: "& \u05D7\u05D9\u05D1\u05D5\u05E8 \u05D8\u05E7\u05E1\u05D8\u05D9\u05DD", insert: " & " }] },
1627
+ {
1628
+ label: "\u05E1\u05D9\u05DE\u05E0\u05D9\u05DD",
1629
+ items: [
1630
+ { label: "( \u05E4\u05EA\u05D9\u05D7\u05EA \u05E1\u05D5\u05D2\u05E8\u05D9\u05D9\u05DD", insert: "(" },
1631
+ { label: ") \u05E1\u05D2\u05D9\u05E8\u05EA \u05E1\u05D5\u05D2\u05E8\u05D9\u05D9\u05DD", insert: ")" },
1632
+ { label: ", \u05E4\u05E1\u05D9\u05E7 (\u05D1\u05D9\u05DF \u05E4\u05E8\u05DE\u05D8\u05E8\u05D9\u05DD)", insert: ", " }
1633
+ ]
1634
+ }
1635
+ ];
1636
+ var FORMULA_FUNCTION_GROUPS = [
1637
+ {
1638
+ label: "\u05EA\u05E0\u05D0\u05D9\u05DD \u05D5\u05DC\u05D5\u05D2\u05D9\u05E7\u05D4",
1639
+ items: [
1640
+ { label: "\u05D0\u05DD... \u05D0\u05D6... \u05D0\u05D7\u05E8\u05EA (IF)", template: "IF(, , )" },
1641
+ { label: "\u05D5\u05D2\u05DD (AND)", template: "AND(, )" },
1642
+ { label: "\u05D0\u05D5 (OR)", template: "OR(, )" },
1643
+ { label: "\u05DC\u05D0 (NOT)", template: "NOT()" },
1644
+ { label: "\u05D4\u05D0\u05DD \u05E8\u05D9\u05E7 (ISEMPTY)", template: "ISEMPTY()" }
1645
+ ]
1646
+ },
1647
+ {
1648
+ label: "\u05D8\u05E7\u05E1\u05D8",
1649
+ items: [
1650
+ { label: "\u05DE\u05DB\u05D9\u05DC \u05D8\u05E7\u05E1\u05D8 (CONTAINS)", template: 'CONTAINS(, "")' },
1651
+ { label: "\u05DE\u05EA\u05D7\u05D9\u05DC \u05D1 (STARTSWITH)", template: 'STARTSWITH(, "")' },
1652
+ { label: "\u05DE\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 (ENDSWITH)", template: 'ENDSWITH(, "")' }
1653
+ ]
1654
+ },
1655
+ {
1656
+ label: "\u05DE\u05E1\u05E4\u05E8\u05D9\u05DD",
1657
+ items: [
1658
+ { label: "\u05E2\u05D9\u05D2\u05D5\u05DC (ROUND)", template: "ROUND(, 2)" },
1659
+ { label: "\u05DE\u05D9\u05E0\u05D9\u05DE\u05D5\u05DD (MIN)", template: "MIN(, )" },
1660
+ { label: "\u05DE\u05E7\u05E1\u05D9\u05DE\u05D5\u05DD (MAX)", template: "MAX(, )" },
1661
+ { label: "\u05E2\u05E8\u05DA \u05DE\u05D5\u05D7\u05DC\u05D8 (ABS)", template: "ABS()" }
1662
+ ]
1663
+ },
1664
+ {
1665
+ label: "\u05EA\u05D0\u05E8\u05D9\u05DB\u05D9\u05DD",
1666
+ items: [{ label: "\u05D4\u05E4\u05E8\u05E9 \u05D9\u05DE\u05D9\u05DD (DAYS: \u05E1\u05D5\u05E3, \u05D4\u05EA\u05D7\u05DC\u05D4)", template: "DAYS(, )" }]
1667
+ }
1668
+ ];
1669
+ var NUMBER_RE = /^-?\d+(\.\d+)?$/;
1670
+ var isFieldRef = (s) => s.startsWith("{") && s.endsWith("}");
1671
+ var quote = (s) => `"${s.replace(/"/g, "")}"`;
1672
+ var literal = (raw, forceText) => {
1673
+ const v = raw.trim();
1674
+ if (isFieldRef(v)) return v;
1675
+ if (!forceText && NUMBER_RE.test(v)) return v;
1676
+ return quote(v);
1677
+ };
1678
+ var operand = (raw) => {
1679
+ const v = raw.trim();
1680
+ if (v === "") return '""';
1681
+ if (isFieldRef(v) || NUMBER_RE.test(v)) return v;
1682
+ return quote(v);
1683
+ };
1684
+ var cmp = (id, label, sym) => ({
1685
+ id,
1686
+ label,
1687
+ needsValue: true,
1688
+ build: (f, v, t) => `${f} ${sym} ${literal(v, t)}`
1689
+ });
1690
+ var EMPTY_OPS2 = [
1691
+ { id: "empty", label: "\u05E8\u05D9\u05E7", needsValue: false, build: (f) => `ISEMPTY(${f})` },
1692
+ { id: "notempty", label: "\u05DC\u05D0 \u05E8\u05D9\u05E7", needsValue: false, build: (f) => `NOT(ISEMPTY(${f}))` }
1693
+ ];
1694
+ var NUMBER_OPS = [
1695
+ cmp("eq", "\u05E9\u05D5\u05D5\u05D4 \u05DC", "="),
1696
+ cmp("ne", "\u05E9\u05D5\u05E0\u05D4 \u05DE", "<>"),
1697
+ cmp("gt", "\u05D2\u05D3\u05D5\u05DC \u05DE", ">"),
1698
+ cmp("lt", "\u05E7\u05D8\u05DF \u05DE", "<"),
1699
+ cmp("ge", "\u05D2\u05D3\u05D5\u05DC \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC", ">="),
1700
+ cmp("le", "\u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC", "<="),
1701
+ ...EMPTY_OPS2
1702
+ ];
1703
+ var DATE_OPS = [
1704
+ cmp("eq", "\u05D1\u05EA\u05D0\u05E8\u05D9\u05DA", "="),
1705
+ cmp("ne", "\u05DC\u05D0 \u05D1\u05EA\u05D0\u05E8\u05D9\u05DA", "<>"),
1706
+ cmp("gt", "\u05D0\u05D7\u05E8\u05D9", ">"),
1707
+ cmp("lt", "\u05DC\u05E4\u05E0\u05D9", "<"),
1708
+ cmp("ge", "\u05D1\u05EA\u05D0\u05E8\u05D9\u05DA \u05D0\u05D5 \u05D0\u05D7\u05E8\u05D9\u05D5", ">="),
1709
+ cmp("le", "\u05D1\u05EA\u05D0\u05E8\u05D9\u05DA \u05D0\u05D5 \u05DC\u05E4\u05E0\u05D9\u05D5", "<="),
1710
+ ...EMPTY_OPS2
1711
+ ];
1712
+ var TEXT_OPS = [
1713
+ cmp("eq", "\u05E9\u05D5\u05D5\u05D4 \u05DC", "="),
1714
+ cmp("ne", "\u05E9\u05D5\u05E0\u05D4 \u05DE", "<>"),
1715
+ { id: "contains", label: "\u05DE\u05DB\u05D9\u05DC", needsValue: true, build: (f, v) => `CONTAINS(${f}, ${literal(v, true)})` },
1716
+ { id: "starts", label: "\u05DE\u05EA\u05D7\u05D9\u05DC \u05D1", needsValue: true, build: (f, v) => `STARTSWITH(${f}, ${literal(v, true)})` },
1717
+ { id: "ends", label: "\u05DE\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1", needsValue: true, build: (f, v) => `ENDSWITH(${f}, ${literal(v, true)})` },
1718
+ ...EMPTY_OPS2
1719
+ ];
1720
+ var BOOL_OPS = [
1721
+ { id: "yes", label: "\u05DE\u05E1\u05D5\u05DE\u05DF (\u05DB\u05DF)", needsValue: false, build: (f) => `${f} = 1` },
1722
+ { id: "no", label: "\u05DC\u05D0 \u05DE\u05E1\u05D5\u05DE\u05DF (\u05DC\u05D0)", needsValue: false, build: (f) => `${f} = 0` }
1723
+ ];
1724
+ var opsOf = (type) => type === "NUMBER" || type === "CURRENCY" ? NUMBER_OPS : type === "DATE" ? DATE_OPS : type === "BOOLEAN" ? BOOL_OPS : TEXT_OPS;
1725
+ var isTextual = (type) => !(type === "NUMBER" || type === "CURRENCY");
1726
+ var EMPTY_IF_CONDITION = { field: "", op: "", value: "" };
1727
+ var getIfConditionOps = (type) => opsOf(type).map(({ id, label, needsValue }) => ({ id, label, needsValue }));
1728
+ function buildIfConditionExpression(columns, c) {
1729
+ const col = columns.find((x) => x.name === c.field);
1730
+ if (!col) return null;
1731
+ const op2 = opsOf(col.type).find((o) => o.id === c.op);
1732
+ if (!op2) return null;
1733
+ if (op2.needsValue && !c.value.trim()) return null;
1734
+ return op2.build(`{${col.name}}`, c.value.trim(), isTextual(col.type));
1735
+ }
1736
+ function buildIfExpression(columns, conds, joiner, thenVal, elseVal) {
1737
+ const parts = conds.map((c) => buildIfConditionExpression(columns, c));
1738
+ if (parts.some((p) => p === null)) return { error: "\u05D9\u05E9 \u05DC\u05D4\u05E9\u05DC\u05D9\u05DD \u05D1\u05DB\u05DC \u05EA\u05E0\u05D0\u05D9: \u05E9\u05D3\u05D4, \u05E4\u05E2\u05D5\u05DC\u05D4 \u05D5\u05E2\u05E8\u05DA" };
1739
+ const condText = parts.length === 1 ? parts[0] : `${joiner}(${parts.join(", ")})`;
1740
+ if (thenVal === void 0 || elseVal === void 0) return { expression: condText };
1741
+ return { expression: `IF(${condText}, ${operand(thenVal)}, ${operand(elseVal)})` };
1742
+ }
1743
+
1369
1744
  // src/components/TableBlock/TableBlockClient.tsx
1370
- var import_react19 = __toESM(require("react"));
1745
+ var import_react20 = __toESM(require("react"));
1371
1746
 
1372
1747
  // src/hooks/useToast.ts
1373
1748
  var import_react2 = require("react");
@@ -4025,6 +4400,8 @@ var NUMERIC = ["NUMBER", "CURRENCY"];
4025
4400
  var OPS = ["+", "-", "*", "/", "(", ")"];
4026
4401
  var selCls = "w-full px-2 py-1 border border-slate-300 rounded text-sm bg-white";
4027
4402
  var lblCls = "block text-[11px] text-slate-600 mb-0.5";
4403
+ var smallBtn = "px-2 py-1 text-xs rounded border border-slate-300 bg-white hover:bg-slate-100";
4404
+ var typeLabel = (t) => FORMULA_TYPE_LABELS[t] || (t === "RELATION" ? "\u05E7\u05E9\u05E8" : t === "FORMULA" ? "\u05E0\u05D5\u05E1\u05D7\u05D4" : t);
4028
4405
  var RecordPicker = ({ tableId, executeAction, value, onPick }) => {
4029
4406
  const [q, setQ] = (0, import_react9.useState)("");
4030
4407
  const [options, setOptions] = (0, import_react9.useState)([]);
@@ -4072,7 +4449,88 @@ var RecordPicker = ({ tableId, executeAction, value, onPick }) => {
4072
4449
  )
4073
4450
  ] });
4074
4451
  };
4075
- var CellFormulaEditor = ({ initial, rowFields, context, anchor, onApply, onClear, onClose }) => {
4452
+ var FilterEditor = ({ columns, conds, join, onChange }) => {
4453
+ const update = (i, patch) => onChange(conds.map((c, idx) => idx === i ? __spreadValues(__spreadValues({}, c), patch) : c), join);
4454
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "space-y-1.5 pt-1.5 border-t border-slate-200", children: [
4455
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { className: lblCls, children: "\u05E1\u05D9\u05E0\u05D5\u05DF: \u05DC\u05E1\u05DB\u05DD \u05E8\u05E7 \u05E8\u05E9\u05D5\u05DE\u05D5\u05EA \u05E9\u05E2\u05D5\u05DE\u05D3\u05D5\u05EA \u05D1\u05EA\u05E0\u05D0\u05D9 (\u05DC\u05D0 \u05D7\u05D5\u05D1\u05D4)" }),
4456
+ conds.map((c, i) => {
4457
+ const col = columns.find((x) => x.name === c.field);
4458
+ const ops = col ? getFilterOps(col.type) : [];
4459
+ const op2 = ops.find((o) => o.id === c.op);
4460
+ const kind = filterKindOfType(col == null ? void 0 : col.type);
4461
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "space-y-1 p-1.5 rounded bg-white border border-slate-200", children: [
4462
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex items-center justify-between", children: [
4463
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "text-[11px] font-medium text-slate-600", children: i === 0 ? "\u05E8\u05E7 \u05D0\u05DD" : join === "AND" ? "\u05D5\u05D2\u05DD" : "\u05D0\u05D5" }),
4464
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
4465
+ "button",
4466
+ {
4467
+ type: "button",
4468
+ className: "text-[11px] text-rose-600 hover:underline",
4469
+ onClick: () => onChange(conds.filter((_, idx) => idx !== i), join),
4470
+ children: "\u05D4\u05E1\u05E8"
4471
+ }
4472
+ )
4473
+ ] }),
4474
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
4475
+ "select",
4476
+ {
4477
+ className: selCls,
4478
+ value: c.field,
4479
+ onChange: (e) => update(i, { field: e.target.value, op: "", value: "" }),
4480
+ children: [
4481
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "", children: "-- \u05D1\u05D7\u05E8 \u05E9\u05D3\u05D4 --" }),
4482
+ columns.map((x) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("option", { value: x.name, children: [
4483
+ x.name,
4484
+ " (",
4485
+ typeLabel(x.type),
4486
+ ")"
4487
+ ] }, x.name))
4488
+ ]
4489
+ }
4490
+ ),
4491
+ col && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("select", { className: selCls, value: c.op, onChange: (e) => update(i, { op: e.target.value, value: "" }), children: [
4492
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "", children: "-- \u05D1\u05D7\u05E8 \u05E4\u05E2\u05D5\u05DC\u05D4 --" }),
4493
+ ops.map((o) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: o.id, children: o.label }, o.id))
4494
+ ] }),
4495
+ (op2 == null ? void 0 : op2.needsValue) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
4496
+ "input",
4497
+ {
4498
+ className: selCls,
4499
+ type: kind === "date" ? "date" : "text",
4500
+ value: c.value,
4501
+ onChange: (e) => update(i, { value: e.target.value }),
4502
+ placeholder: kind === "relation" ? "\u05D4\u05E2\u05E8\u05DA \u05DB\u05E4\u05D9 \u05E9\u05DE\u05D5\u05E6\u05D2 \u05D1\u05D8\u05D1\u05DC\u05D4" : "\u05E2\u05E8\u05DA \u05DC\u05D4\u05E9\u05D5\u05D5\u05D0\u05D4"
4503
+ }
4504
+ )
4505
+ ] }, i);
4506
+ }),
4507
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex items-center gap-2", children: [
4508
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
4509
+ "button",
4510
+ {
4511
+ type: "button",
4512
+ disabled: conds.length >= MAX_FILTER_CONDITIONS,
4513
+ className: smallBtn,
4514
+ onClick: () => onChange([...conds, { field: "", op: "", value: "" }], join),
4515
+ children: "+ \u05D4\u05D5\u05E1\u05E3 \u05EA\u05E0\u05D0\u05D9 \u05E1\u05D9\u05E0\u05D5\u05DF"
4516
+ }
4517
+ ),
4518
+ conds.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
4519
+ "select",
4520
+ {
4521
+ className: "px-2 py-1 border border-slate-300 rounded text-xs bg-white",
4522
+ value: join,
4523
+ onChange: (e) => onChange(conds, e.target.value),
4524
+ children: [
4525
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "AND", children: "\u05DB\u05DC \u05D4\u05EA\u05E0\u05D0\u05D9\u05DD (\u05D5\u05D2\u05DD)" }),
4526
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "OR", children: "\u05DC\u05E4\u05D7\u05D5\u05EA \u05D0\u05D7\u05D3 (\u05D0\u05D5)" })
4527
+ ]
4528
+ }
4529
+ )
4530
+ ] })
4531
+ ] });
4532
+ };
4533
+ var CellFormulaEditor = ({ initial, rowColumns, context, anchor, onApply, onClear, onClose }) => {
4076
4534
  const executeAction = context == null ? void 0 : context.executeAction;
4077
4535
  const taRef = (0, import_react9.useRef)(null);
4078
4536
  const [expression, setExpression] = (0, import_react9.useState)((initial == null ? void 0 : initial.expression) || "");
@@ -4085,6 +4543,13 @@ var CellFormulaEditor = ({ initial, rowFields, context, anchor, onApply, onClear
4085
4543
  const [rec, setRec] = (0, import_react9.useState)({ id: "", label: "" });
4086
4544
  const [fld, setFld] = (0, import_react9.useState)("");
4087
4545
  const [agg, setAgg] = (0, import_react9.useState)("SUM");
4546
+ const [fConds, setFConds] = (0, import_react9.useState)([]);
4547
+ const [fJoin, setFJoin] = (0, import_react9.useState)("AND");
4548
+ const [ifConds, setIfConds] = (0, import_react9.useState)([__spreadValues({}, EMPTY_IF_CONDITION)]);
4549
+ const [ifJoin, setIfJoin] = (0, import_react9.useState)("AND");
4550
+ const [thenVal, setThenVal] = (0, import_react9.useState)("");
4551
+ const [elseVal, setElseVal] = (0, import_react9.useState)("");
4552
+ const [builderError, setBuilderError] = (0, import_react9.useState)("");
4088
4553
  (0, import_react9.useEffect)(() => {
4089
4554
  (async () => {
4090
4555
  var _a, _b;
@@ -4099,8 +4564,11 @@ var CellFormulaEditor = ({ initial, rowFields, context, anchor, onApply, onClear
4099
4564
  })();
4100
4565
  }, [executeAction]);
4101
4566
  const table = tables == null ? void 0 : tables.find((t) => t.id === tId);
4102
- const tableFields = ((table == null ? void 0 : table.columns) || []).filter((c) => panel === "agg" ? NUMERIC.includes(c.type) : true);
4103
- const insert = (text2) => {
4567
+ const valueFields = ((table == null ? void 0 : table.columns) || []).filter(
4568
+ (c) => FORMULA_SOURCE_TYPES.includes(c.type) && (panel === "agg" ? NUMERIC.includes(c.type) : true)
4569
+ );
4570
+ const rowFieldNames = (0, import_react9.useMemo)(() => rowColumns.map((c) => c.name), [rowColumns]);
4571
+ const insert = (text2, caret) => {
4104
4572
  var _a, _b;
4105
4573
  const el = taRef.current;
4106
4574
  const s = (_a = el == null ? void 0 : el.selectionStart) != null ? _a : expression.length;
@@ -4108,38 +4576,53 @@ var CellFormulaEditor = ({ initial, rowFields, context, anchor, onApply, onClear
4108
4576
  const next = expression.slice(0, s) + text2 + expression.slice(e);
4109
4577
  setExpression(next);
4110
4578
  setError("");
4579
+ const pos = s + (caret != null ? caret : text2.length);
4111
4580
  requestAnimationFrame(() => {
4112
4581
  el == null ? void 0 : el.focus();
4113
- const p = s + text2.length;
4114
- el == null ? void 0 : el.setSelectionRange(p, p);
4582
+ el == null ? void 0 : el.setSelectionRange(pos, pos);
4115
4583
  });
4116
4584
  };
4585
+ const readFilter = () => {
4586
+ const started = fConds.filter((c) => c.field || c.op || c.value);
4587
+ const filter = sanitizeRefFilter({ join: fJoin, conditions: started });
4588
+ const incomplete = started.length > 0 && (!filter || filter.conditions.length !== started.length);
4589
+ return { filter, incomplete };
4590
+ };
4117
4591
  const addRef = () => {
4118
4592
  if (!table || !fld) return;
4119
4593
  if (panel === "cell" && !rec.id) return;
4120
4594
  const isAgg = panel === "agg";
4121
- const same = refs.find((r) => r.tableId === table.id && r.field === fld && (isAgg ? r.agg === agg : !r.agg && r.recordId === rec.id));
4595
+ const { filter, incomplete } = isAgg ? readFilter() : { filter: null, incomplete: false };
4596
+ if (incomplete) {
4597
+ setError("\u05D9\u05E9 \u05DC\u05D4\u05E9\u05DC\u05D9\u05DD \u05D1\u05DB\u05DC \u05EA\u05E0\u05D0\u05D9 \u05E1\u05D9\u05E0\u05D5\u05DF: \u05E9\u05D3\u05D4, \u05E4\u05E2\u05D5\u05DC\u05D4 \u05D5\u05E2\u05E8\u05DA (\u05D0\u05D5 \u05DC\u05D4\u05E1\u05D9\u05E8 \u05D0\u05D5\u05EA\u05D5)");
4598
+ return;
4599
+ }
4600
+ const sig = filterSignature(filter);
4601
+ const same = refs.find((r) => r.tableId === table.id && r.field === fld && (isAgg ? r.agg === agg && filterSignature(r.filter) === sig : !r.agg && r.recordId === rec.id));
4122
4602
  let key;
4123
4603
  if (same) key = same.key;
4124
4604
  else {
4125
4605
  key = makeCellRefKey(refs, fld, isAgg ? agg : void 0);
4126
- setRefs((prev) => [...prev, __spreadValues({
4606
+ setRefs((prev) => [...prev, __spreadValues(__spreadValues({
4127
4607
  key,
4128
4608
  tableId: table.id,
4129
4609
  tableName: table.name,
4130
4610
  recordId: isAgg ? "" : rec.id,
4131
4611
  recordLabel: isAgg ? "" : rec.label,
4132
4612
  field: fld
4133
- }, isAgg ? { agg } : {})]);
4613
+ }, isAgg ? { agg } : {}), isAgg && filter ? { filter } : {})]);
4134
4614
  }
4135
4615
  insert(`{${key}}`);
4616
+ setError("");
4136
4617
  setPanel("");
4137
4618
  setFld("");
4619
+ setFConds([]);
4138
4620
  };
4139
4621
  const used = (0, import_react9.useMemo)(() => new Set(extractFormulaFields(expression)), [expression]);
4140
4622
  const usedRefs = refs.filter((r) => used.has(r.key));
4623
+ const live = expression.trim() ? validateFormula(expression, [...rowFieldNames, ...refs.map((r) => r.key)]) : null;
4141
4624
  const apply = () => {
4142
- const err = validateFormula(expression, [...rowFields, ...refs.map((r) => r.key)]);
4625
+ const err = validateFormula(expression, [...rowFieldNames, ...refs.map((r) => r.key)]);
4143
4626
  if (err) {
4144
4627
  setError(err);
4145
4628
  return;
@@ -4151,7 +4634,28 @@ var CellFormulaEditor = ({ initial, rowFields, context, anchor, onApply, onClear
4151
4634
  setTId("");
4152
4635
  setFld("");
4153
4636
  setRec({ id: "", label: "" });
4637
+ setFConds([]);
4638
+ setError("");
4154
4639
  };
4640
+ const updateIfCond = (i, patch) => setIfConds((prev) => prev.map((c, idx) => idx === i ? __spreadValues(__spreadValues({}, c), patch) : c));
4641
+ const insertBuilt = (withIf) => {
4642
+ const res = withIf ? buildIfExpression(rowColumns, ifConds, ifJoin, thenVal, elseVal) : buildIfExpression(rowColumns, ifConds, ifJoin);
4643
+ if ("error" in res) {
4644
+ setBuilderError(res.error);
4645
+ return;
4646
+ }
4647
+ setBuilderError("");
4648
+ insert(res.expression);
4649
+ };
4650
+ const rowFieldOptions = /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
4651
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "", children: rowColumns.length === 0 ? "-- \u05D0\u05D9\u05DF \u05E9\u05D3\u05D5\u05EA \u05DE\u05EA\u05D0\u05D9\u05DE\u05D9\u05DD \u05D1\u05D8\u05D1\u05DC\u05D4 \u05D4\u05D6\u05D5 --" : "-- \u05D1\u05D7\u05E8 \u05E9\u05D3\u05D4 --" }),
4652
+ rowColumns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("option", { value: c.name, children: [
4653
+ c.name,
4654
+ " (",
4655
+ typeLabel(c.type),
4656
+ ")"
4657
+ ] }, c.name))
4658
+ ] });
4155
4659
  return (0, import_react_dom3.createPortal)(
4156
4660
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
4157
4661
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "fixed inset-0 z-[9998]", onClick: onClose }),
@@ -4159,7 +4663,7 @@ var CellFormulaEditor = ({ initial, rowFields, context, anchor, onApply, onClear
4159
4663
  "div",
4160
4664
  {
4161
4665
  dir: "rtl",
4162
- className: "fixed z-[9999] w-[340px] max-h-[80vh] overflow-auto p-3 bg-white border border-slate-200 rounded-lg shadow-xl space-y-2",
4666
+ className: "fixed z-[9999] w-[380px] max-h-[85vh] overflow-auto p-3 bg-white border border-slate-200 rounded-lg shadow-xl space-y-2",
4163
4667
  style: { top: anchor.top, left: anchor.left },
4164
4668
  children: [
4165
4669
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "text-sm font-semibold text-slate-700", children: "\u05E0\u05D5\u05E1\u05D7\u05D4 \u05DC\u05EA\u05D0" }),
@@ -4168,7 +4672,7 @@ var CellFormulaEditor = ({ initial, rowFields, context, anchor, onApply, onClear
4168
4672
  {
4169
4673
  ref: taRef,
4170
4674
  dir: "ltr",
4171
- rows: 2,
4675
+ rows: 3,
4172
4676
  value: expression,
4173
4677
  onChange: (e) => {
4174
4678
  setExpression(e.target.value);
@@ -4178,6 +4682,7 @@ var CellFormulaEditor = ({ initial, rowFields, context, anchor, onApply, onClear
4178
4682
  className: "w-full px-2 py-1.5 border border-slate-300 rounded text-sm font-mono bg-white"
4179
4683
  }
4180
4684
  ),
4685
+ live && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "text-[11px] text-rose-500", children: live }),
4181
4686
  usedRefs.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "flex flex-wrap gap-1", children: usedRefs.map((r) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
4182
4687
  "span",
4183
4688
  {
@@ -4189,11 +4694,55 @@ var CellFormulaEditor = ({ initial, rowFields, context, anchor, onApply, onClear
4189
4694
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "text-slate-400", children: [
4190
4695
  "\xB7 ",
4191
4696
  r.tableName
4697
+ ] }),
4698
+ r.filter && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "text-amber-600", children: [
4699
+ " \xB7 ",
4700
+ describeRefFilter(r.filter)
4192
4701
  ] })
4193
4702
  ]
4194
4703
  },
4195
4704
  r.key
4196
4705
  )) }),
4706
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "grid grid-cols-3 gap-1.5", children: [
4707
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
4708
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { className: lblCls, children: "\u05D4\u05D5\u05E1\u05E3 \u05E9\u05D3\u05D4" }),
4709
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
4710
+ "select",
4711
+ {
4712
+ className: selCls,
4713
+ value: "",
4714
+ disabled: rowColumns.length === 0,
4715
+ onChange: (e) => e.target.value && insert(`{${e.target.value}}`),
4716
+ children: rowFieldOptions
4717
+ }
4718
+ )
4719
+ ] }),
4720
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
4721
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { className: lblCls, children: "\u05D4\u05D5\u05E1\u05E3 \u05D0\u05D5\u05E4\u05E8\u05D8\u05D5\u05E8" }),
4722
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("select", { className: selCls, value: "", onChange: (e) => e.target.value && insert(e.target.value), children: [
4723
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "", children: "-- \u05D1\u05D7\u05E8 --" }),
4724
+ FORMULA_OPERATOR_GROUPS.map((g) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("optgroup", { label: g.label, children: g.items.map((it) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: it.insert, children: it.label }, it.label)) }, g.label))
4725
+ ] })
4726
+ ] }),
4727
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
4728
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { className: lblCls, children: "\u05D4\u05D5\u05E1\u05E3 \u05E4\u05D5\u05E0\u05E7\u05E6\u05D9\u05D4" }),
4729
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
4730
+ "select",
4731
+ {
4732
+ className: selCls,
4733
+ value: "",
4734
+ onChange: (e) => {
4735
+ const tpl = e.target.value;
4736
+ if (tpl) insert(tpl, tpl.indexOf("(") + 1);
4737
+ },
4738
+ children: [
4739
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "", children: "-- \u05D1\u05D7\u05E8 --" }),
4740
+ FORMULA_FUNCTION_GROUPS.map((g) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("optgroup", { label: g.label, children: g.items.map((it) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: it.template, children: it.label }, it.label)) }, g.label))
4741
+ ]
4742
+ }
4743
+ )
4744
+ ] })
4745
+ ] }),
4197
4746
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "flex items-center gap-1", style: { direction: "ltr" }, children: OPS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
4198
4747
  "button",
4199
4748
  {
@@ -4204,13 +4753,6 @@ var CellFormulaEditor = ({ initial, rowFields, context, anchor, onApply, onClear
4204
4753
  },
4205
4754
  o
4206
4755
  )) }),
4207
- rowFields.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
4208
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { className: lblCls, children: "\u05E9\u05D3\u05D4 \u05DE\u05D0\u05D5\u05EA\u05D4 \u05E9\u05D5\u05E8\u05D4" }),
4209
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("select", { className: selCls, value: "", onChange: (e) => e.target.value && insert(`{${e.target.value}}`), children: [
4210
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "", children: "-- \u05D4\u05D5\u05E1\u05E3 \u05E9\u05D3\u05D4 --" }),
4211
- rowFields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: f, children: f }, f))
4212
- ] })
4213
- ] }),
4214
4756
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex gap-1.5", children: [
4215
4757
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
4216
4758
  "button",
@@ -4237,14 +4779,23 @@ var CellFormulaEditor = ({ initial, rowFields, context, anchor, onApply, onClear
4237
4779
  tables && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
4238
4780
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
4239
4781
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { className: lblCls, children: "\u05D8\u05D1\u05DC\u05D4" }),
4240
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("select", { className: selCls, value: tId, onChange: (e) => {
4241
- setTId(e.target.value);
4242
- setFld("");
4243
- setRec({ id: "", label: "" });
4244
- }, children: [
4245
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "", children: "-- \u05D1\u05D7\u05E8 \u05D8\u05D1\u05DC\u05D4 --" }),
4246
- tables.filter((t) => panel === "cell" || t.columns.some((c) => NUMERIC.includes(c.type))).map((t) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: t.id, children: t.name }, t.id))
4247
- ] })
4782
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
4783
+ "select",
4784
+ {
4785
+ className: selCls,
4786
+ value: tId,
4787
+ onChange: (e) => {
4788
+ setTId(e.target.value);
4789
+ setFld("");
4790
+ setRec({ id: "", label: "" });
4791
+ setFConds([]);
4792
+ },
4793
+ children: [
4794
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "", children: "-- \u05D1\u05D7\u05E8 \u05D8\u05D1\u05DC\u05D4 --" }),
4795
+ tables.filter((t) => panel === "cell" || t.columns.some((c) => NUMERIC.includes(c.type))).map((t) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: t.id, children: t.name }, t.id))
4796
+ ]
4797
+ }
4798
+ )
4248
4799
  ] }),
4249
4800
  panel === "cell" && tId && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
4250
4801
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { className: lblCls, children: "\u05E8\u05E9\u05D5\u05DE\u05D4" }),
@@ -4262,13 +4813,26 @@ var CellFormulaEditor = ({ initial, rowFields, context, anchor, onApply, onClear
4262
4813
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { className: lblCls, children: "\u05E2\u05DE\u05D5\u05D3\u05D4" }),
4263
4814
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("select", { className: selCls, value: fld, onChange: (e) => setFld(e.target.value), children: [
4264
4815
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "", children: "-- \u05D1\u05D7\u05E8 \u05E2\u05DE\u05D5\u05D3\u05D4 --" }),
4265
- tableFields.filter((c) => FORMULA_SOURCE_TYPES.includes(c.type)).map((c) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: c.name, children: c.name }, c.name))
4816
+ valueFields.map((c) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: c.name, children: c.name }, c.name))
4266
4817
  ] })
4267
4818
  ] }),
4268
4819
  panel === "agg" && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
4269
4820
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { className: lblCls, children: "\u05E4\u05E2\u05D5\u05DC\u05D4" }),
4270
4821
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("select", { className: selCls, value: agg, onChange: (e) => setAgg(e.target.value), children: PER_RECORD_SOURCE_AGGS.map((a) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: a, children: PER_RECORD_AGG_LABELS[a] }, a)) })
4271
4822
  ] }),
4823
+ panel === "agg" && table && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
4824
+ FilterEditor,
4825
+ {
4826
+ columns: table.columns.filter((c) => !String(c.name).startsWith("_")),
4827
+ conds: fConds,
4828
+ join: fJoin,
4829
+ onChange: (c, j) => {
4830
+ setFConds(c);
4831
+ setFJoin(j);
4832
+ setError("");
4833
+ }
4834
+ }
4835
+ ),
4272
4836
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
4273
4837
  "button",
4274
4838
  {
@@ -4281,6 +4845,138 @@ var CellFormulaEditor = ({ initial, rowFields, context, anchor, onApply, onClear
4281
4845
  )
4282
4846
  ] })
4283
4847
  ] }),
4848
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("details", { className: "rounded border border-slate-200 bg-white", children: [
4849
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("summary", { className: "cursor-pointer select-none px-2 py-1.5 text-xs font-semibold text-slate-700", children: "\u05D1\u05D5\u05E0\u05D4 \u05EA\u05E0\u05D0\u05D9 (\u05D0\u05DD... \u05D0\u05D6... \u05D0\u05D7\u05E8\u05EA)" }),
4850
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "p-2 space-y-2 border-t border-slate-200", children: [
4851
+ ifConds.map((c, i) => {
4852
+ const col = rowColumns.find((x) => x.name === c.field);
4853
+ const ops = col ? getIfConditionOps(col.type) : [];
4854
+ const op2 = ops.find((o) => o.id === c.op);
4855
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "space-y-1.5 p-2 rounded bg-slate-50 border border-slate-200", children: [
4856
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex items-center justify-between", children: [
4857
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "text-[11px] font-medium text-slate-600", children: i === 0 ? "\u05D0\u05DD" : ifJoin === "AND" ? "\u05D5\u05D2\u05DD" : "\u05D0\u05D5" }),
4858
+ ifConds.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
4859
+ "button",
4860
+ {
4861
+ type: "button",
4862
+ className: "text-[11px] text-rose-600 hover:underline",
4863
+ onClick: () => setIfConds((prev) => prev.filter((_, idx) => idx !== i)),
4864
+ children: "\u05D4\u05E1\u05E8 \u05EA\u05E0\u05D0\u05D9"
4865
+ }
4866
+ )
4867
+ ] }),
4868
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
4869
+ "select",
4870
+ {
4871
+ className: selCls,
4872
+ value: c.field,
4873
+ onChange: (e) => updateIfCond(i, { field: e.target.value, op: "", value: "" }),
4874
+ children: rowFieldOptions
4875
+ }
4876
+ ),
4877
+ col && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("select", { className: selCls, value: c.op, onChange: (e) => updateIfCond(i, { op: e.target.value, value: "" }), children: [
4878
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "", children: "-- \u05D1\u05D7\u05E8 \u05E4\u05E2\u05D5\u05DC\u05D4 --" }),
4879
+ ops.map((o) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: o.id, children: o.label }, o.id))
4880
+ ] }),
4881
+ (op2 == null ? void 0 : op2.needsValue) && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "grid grid-cols-2 gap-1.5", children: [
4882
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
4883
+ "input",
4884
+ {
4885
+ type: (col == null ? void 0 : col.type) === "DATE" ? "date" : "text",
4886
+ value: c.value,
4887
+ onChange: (e) => updateIfCond(i, { value: e.target.value }),
4888
+ placeholder: "\u05E2\u05E8\u05DA \u05DC\u05D4\u05E9\u05D5\u05D5\u05D0\u05D4",
4889
+ className: selCls
4890
+ }
4891
+ ),
4892
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
4893
+ "select",
4894
+ {
4895
+ className: selCls,
4896
+ value: "",
4897
+ onChange: (e) => e.target.value && updateIfCond(i, { value: `{${e.target.value}}` }),
4898
+ children: [
4899
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "", children: "...\u05D0\u05D5 \u05E9\u05D3\u05D4 \u05D0\u05D7\u05E8" }),
4900
+ rowColumns.filter((s) => s.name !== c.field).map((s) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: s.name, children: s.name }, s.name))
4901
+ ]
4902
+ }
4903
+ )
4904
+ ] })
4905
+ ] }, i);
4906
+ }),
4907
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex items-center gap-2", children: [
4908
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
4909
+ "button",
4910
+ {
4911
+ type: "button",
4912
+ disabled: ifConds.length >= 5,
4913
+ className: smallBtn,
4914
+ onClick: () => setIfConds((prev) => [...prev, __spreadValues({}, EMPTY_IF_CONDITION)]),
4915
+ children: "+ \u05D4\u05D5\u05E1\u05E3 \u05EA\u05E0\u05D0\u05D9"
4916
+ }
4917
+ ),
4918
+ ifConds.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
4919
+ "select",
4920
+ {
4921
+ className: "px-2 py-1 border border-slate-300 rounded text-xs bg-white",
4922
+ value: ifJoin,
4923
+ onChange: (e) => setIfJoin(e.target.value),
4924
+ children: [
4925
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "AND", children: "\u05DB\u05DC \u05D4\u05EA\u05E0\u05D0\u05D9\u05DD (\u05D5\u05D2\u05DD)" }),
4926
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "OR", children: "\u05DC\u05E4\u05D7\u05D5\u05EA \u05D0\u05D7\u05D3 (\u05D0\u05D5)" })
4927
+ ]
4928
+ }
4929
+ )
4930
+ ] }),
4931
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "grid grid-cols-2 gap-2", children: [
4932
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
4933
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { className: lblCls, children: "\u05D0\u05DD \u05D4\u05EA\u05E0\u05D0\u05D9 \u05DE\u05EA\u05E7\u05D9\u05D9\u05DD, \u05D4\u05EA\u05D5\u05E6\u05D0\u05D4:" }),
4934
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("input", { value: thenVal, onChange: (e) => setThenVal(e.target.value), placeholder: "\u05DE\u05E1\u05E4\u05E8, \u05D8\u05E7\u05E1\u05D8 \u05D0\u05D5 \u05E9\u05D3\u05D4", className: selCls }),
4935
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
4936
+ "select",
4937
+ {
4938
+ className: `${selCls} mt-1`,
4939
+ value: "",
4940
+ onChange: (e) => e.target.value && setThenVal(`{${e.target.value}}`),
4941
+ children: [
4942
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "", children: "...\u05D0\u05D5 \u05E9\u05D3\u05D4" }),
4943
+ rowColumns.map((s) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: s.name, children: s.name }, s.name))
4944
+ ]
4945
+ }
4946
+ )
4947
+ ] }),
4948
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
4949
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { className: lblCls, children: "\u05D0\u05D7\u05E8\u05EA, \u05D4\u05EA\u05D5\u05E6\u05D0\u05D4:" }),
4950
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("input", { value: elseVal, onChange: (e) => setElseVal(e.target.value), placeholder: "\u05DE\u05E1\u05E4\u05E8, \u05D8\u05E7\u05E1\u05D8 \u05D0\u05D5 \u05E9\u05D3\u05D4", className: selCls }),
4951
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
4952
+ "select",
4953
+ {
4954
+ className: `${selCls} mt-1`,
4955
+ value: "",
4956
+ onChange: (e) => e.target.value && setElseVal(`{${e.target.value}}`),
4957
+ children: [
4958
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "", children: "...\u05D0\u05D5 \u05E9\u05D3\u05D4" }),
4959
+ rowColumns.map((s) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: s.name, children: s.name }, s.name))
4960
+ ]
4961
+ }
4962
+ )
4963
+ ] })
4964
+ ] }),
4965
+ builderError && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "text-[11px] text-rose-500", children: builderError }),
4966
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex flex-wrap gap-2", children: [
4967
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
4968
+ "button",
4969
+ {
4970
+ type: "button",
4971
+ onClick: () => insertBuilt(true),
4972
+ className: "px-3 py-1.5 text-xs rounded bg-slate-800 text-white hover:bg-slate-700",
4973
+ children: "\u05D4\u05D5\u05E1\u05E3 \u05EA\u05E0\u05D0\u05D9 IF \u05DC\u05E0\u05D5\u05E1\u05D7\u05D4"
4974
+ }
4975
+ ),
4976
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", onClick: () => insertBuilt(false), className: smallBtn, children: "\u05D4\u05D5\u05E1\u05E3 \u05E8\u05E7 \u05D0\u05EA \u05D4\u05EA\u05E0\u05D0\u05D9" })
4977
+ ] })
4978
+ ] })
4979
+ ] }),
4284
4980
  error && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "text-xs text-red-600", children: error }),
4285
4981
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex gap-2 pt-1", children: [
4286
4982
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
@@ -4328,16 +5024,16 @@ var PerRecordSourceCell = ({ value, column, onChange, readOnly, context }) => {
4328
5024
  const btnRef = (0, import_react9.useRef)(null);
4329
5025
  const [open, setOpen] = (0, import_react9.useState)(false);
4330
5026
  const [pos, setPos] = (0, import_react9.useState)({ top: 0, left: 0 });
4331
- const rowFields = (0, import_react9.useMemo)(() => {
5027
+ const rowColumns = (0, import_react9.useMemo)(() => {
4332
5028
  const cols = Array.isArray(context == null ? void 0 : context.columns) ? context.columns : [];
4333
- return cols.filter((c) => (c == null ? void 0 : c.name) && c.name !== column.name && !String(c.name).startsWith("_") && FORMULA_SOURCE_TYPES.includes(String(c.type).toUpperCase())).map((c) => c.name);
5029
+ return cols.filter((c) => (c == null ? void 0 : c.name) && c.name !== column.name && !String(c.name).startsWith("_") && FORMULA_SOURCE_TYPES.includes(String(c.type).toUpperCase())).map((c) => ({ name: c.name, type: String(c.type).toUpperCase() }));
4334
5030
  }, [context == null ? void 0 : context.columns, column.name]);
4335
5031
  const openEditor = () => {
4336
5032
  var _a2;
4337
5033
  const r = (_a2 = btnRef.current) == null ? void 0 : _a2.getBoundingClientRect();
4338
5034
  if (r) {
4339
- const left = Math.max(8, Math.min(r.left, window.innerWidth - 356));
4340
- const top = Math.min(r.bottom + 4, Math.max(8, window.innerHeight - 420));
5035
+ const left = Math.max(8, Math.min(r.left, window.innerWidth - 396));
5036
+ const top = Math.min(r.bottom + 4, Math.max(8, window.innerHeight - 440));
4341
5037
  setPos({ top, left });
4342
5038
  }
4343
5039
  setOpen(true);
@@ -4360,7 +5056,7 @@ var PerRecordSourceCell = ({ value, column, onChange, readOnly, context }) => {
4360
5056
  CellFormulaEditor,
4361
5057
  {
4362
5058
  initial: current,
4363
- rowFields,
5059
+ rowColumns,
4364
5060
  context,
4365
5061
  anchor: pos,
4366
5062
  onClose: () => setOpen(false),
@@ -6693,68 +7389,139 @@ function RelationFilterPopover({
6693
7389
  }
6694
7390
 
6695
7391
  // src/components/TableBlock/RelationButtonsBar.tsx
6696
- var import_react17 = require("react");
7392
+ var import_react18 = require("react");
6697
7393
 
6698
7394
  // src/components/TableBlock/RelationButtonsView.tsx
7395
+ var import_react17 = require("react");
6699
7396
  var import_jsx_runtime15 = require("react/jsx-runtime");
6700
- 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;
6701
7410
  const visible = groups.filter((g) => g.options.length > 0);
6702
7411
  if (visible.length === 0) return null;
6703
- 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) => {
6704
- const titleIsDuplicate = group.options.some(
6705
- (opt) => opt.label.trim() === group.title.trim()
6706
- );
6707
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
6708
- "div",
6709
- {
6710
- className: "bg-white border border-slate-200 rounded-xl px-3 py-2.5 shadow-2xs",
6711
- children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-wrap items-end gap-x-2 gap-y-2.5", children: [
6712
- !titleIsDuplicate && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
6713
- "span",
6714
- {
6715
- className: "self-end h-8 inline-flex items-center text-xs font-bold text-slate-800 max-w-[10rem] truncate",
6716
- title: group.title,
6717
- children: group.title
6718
- }
6719
- ),
6720
- group.options.map((opt) => {
6721
- const active = group.activeId === opt.id;
6722
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-col items-center gap-0.5", children: [
6723
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
6724
- "span",
6725
- {
6726
- className: `text-[11px] font-bold leading-none ${active ? "text-indigo-700" : "text-slate-500"}`,
6727
- children: opt.count
6728
- }
6729
- ),
6730
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
6731
- "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",
6732
7502
  {
6733
- type: "button",
6734
- disabled,
6735
- onClick: () => onSelect(group.key, active ? void 0 : opt.id),
6736
- 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}`,
6737
- "aria-pressed": active,
6738
- 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"}`,
6739
- 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" })
6740
7516
  }
6741
7517
  )
6742
- ] }, opt.id);
6743
- }),
6744
- group.activeId ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
6745
- "button",
6746
- {
6747
- type: "button",
6748
- onClick: () => onSelect(group.key, void 0),
6749
- 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",
6750
- children: "\u05E0\u05E7\u05D4 \u05E1\u05D9\u05E0\u05D5\u05DF"
6751
- }
6752
- ) : null
6753
- ] })
6754
- },
6755
- group.key
6756
- );
6757
- }) });
7518
+ ]
7519
+ },
7520
+ group.key
7521
+ );
7522
+ })
7523
+ }
7524
+ );
6758
7525
  }
6759
7526
 
6760
7527
  // src/components/TableBlock/RelationButtonsBar.tsx
@@ -6773,13 +7540,44 @@ function RelationButtonsBar({
6773
7540
  refreshToken,
6774
7541
  disabled
6775
7542
  }) {
6776
- const buttonCols = (0, import_react17.useMemo)(() => getRelationButtonColumns(columns), [columns]);
6777
- const colsKey = (0, import_react17.useMemo)(() => buttonCols.map((c) => c.name).join("|"), [buttonCols]);
6778
- const [counts, setCounts] = (0, import_react17.useState)({});
6779
- const requestIdRef = (0, import_react17.useRef)(0);
6780
- 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);
6781
7548
  actionRef.current = executeAction;
6782
- (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)(() => {
6783
7581
  if (!colsKey || !tableId || !actionRef.current) return;
6784
7582
  const myId = ++requestIdRef.current;
6785
7583
  const timer = setTimeout(() => {
@@ -6790,10 +7588,15 @@ function RelationButtonsBar({
6790
7588
  }, 250);
6791
7589
  return () => clearTimeout(timer);
6792
7590
  }, [colsKey, tableId, refreshToken]);
6793
- const groups = (0, import_react17.useMemo)(
7591
+ const groups = (0, import_react18.useMemo)(
6794
7592
  () => buttonCols.map((col) => {
6795
7593
  const v = columnFilters == null ? void 0 : columnFilters[col.name];
6796
- 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
+ }
6797
7600
  return {
6798
7601
  key: col.name,
6799
7602
  title: col.name,
@@ -6803,6 +7606,19 @@ function RelationButtonsBar({
6803
7606
  }),
6804
7607
  [buttonCols, counts, columnFilters]
6805
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
+ );
6806
7622
  if (buttonCols.length === 0 || groups.every((g) => g.options.length === 0)) return null;
6807
7623
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
6808
7624
  "div",
@@ -6814,7 +7630,10 @@ function RelationButtonsBar({
6814
7630
  {
6815
7631
  groups,
6816
7632
  disabled,
6817
- onSelect: (colName, id) => onApplyFilter(colName, id ? [id] : void 0)
7633
+ onSelect: handleSelect,
7634
+ widths,
7635
+ onResize: handleResize,
7636
+ onResizeEnd: handleResizeEnd
6818
7637
  }
6819
7638
  )
6820
7639
  }
@@ -6822,7 +7641,7 @@ function RelationButtonsBar({
6822
7641
  }
6823
7642
 
6824
7643
  // src/components/TableBlock/useDefaultColumnFilters.ts
6825
- var import_react18 = require("react");
7644
+ var import_react19 = require("react");
6826
7645
  var RESOLVE_TIMEOUT_MS = 8e3;
6827
7646
  function unwrap2(res) {
6828
7647
  const body = (res == null ? void 0 : res.data) && typeof res.data === "object" && !Array.isArray(res.data) ? res.data : res;
@@ -6831,13 +7650,13 @@ function unwrap2(res) {
6831
7650
  }
6832
7651
  function useDefaultColumnFilters({ columns, tableId, executeAction, onResolved }) {
6833
7652
  const hasDefaults = getDefaultFilterColumns(columns).length > 0;
6834
- const [ready, setReady] = (0, import_react18.useState)(() => !hasDefaults);
6835
- const doneRef = (0, import_react18.useRef)(false);
6836
- 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);
6837
7656
  onResolvedRef.current = onResolved;
6838
- const actionRef = (0, import_react18.useRef)(executeAction);
7657
+ const actionRef = (0, import_react19.useRef)(executeAction);
6839
7658
  actionRef.current = executeAction;
6840
- (0, import_react18.useEffect)(() => {
7659
+ (0, import_react19.useEffect)(() => {
6841
7660
  if (doneRef.current || !hasDefaults) return;
6842
7661
  doneRef.current = true;
6843
7662
  const exec = actionRef.current;
@@ -6894,10 +7713,10 @@ function TableBlockClient({
6894
7713
  renderRowExtra
6895
7714
  }) {
6896
7715
  const { showError, addToast } = useToast();
6897
- const [isExporting, setIsExporting] = (0, import_react19.useState)(false);
6898
- const [isExportMenuOpen, setIsExportMenuOpen] = (0, import_react19.useState)(false);
6899
- const exportMenuRef = (0, import_react19.useRef)(null);
6900
- (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)(() => {
6901
7720
  if (!isExportMenuOpen) return;
6902
7721
  const handleClickOutside = (e) => {
6903
7722
  if (exportMenuRef.current && !exportMenuRef.current.contains(e.target)) {
@@ -6932,18 +7751,18 @@ function TableBlockClient({
6932
7751
  return calculateMinColumnWidth(colName, false, col == null ? void 0 : col.type);
6933
7752
  }
6934
7753
  });
6935
- const executeActionRef = (0, import_react19.useRef)(executeAction);
6936
- (0, import_react19.useEffect)(() => {
7754
+ const executeActionRef = (0, import_react20.useRef)(executeAction);
7755
+ (0, import_react20.useEffect)(() => {
6937
7756
  executeActionRef.current = executeAction;
6938
7757
  }, [executeAction]);
6939
- const [isMounted, setIsMounted] = (0, import_react19.useState)(false);
6940
- const [isInitialLoading, setIsInitialLoading] = (0, import_react19.useState)(true);
6941
- const [page, setPage] = (0, import_react19.useState)(1);
6942
- const [limit, setLimit] = (0, import_react19.useState)(50);
6943
- const [totalRecords, setTotalRecords] = (0, import_react19.useState)(0);
6944
- const [totalPages, setTotalPages] = (0, import_react19.useState)(1);
6945
- const [showSummary, setShowSummary] = (0, import_react19.useState)(false);
6946
- (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)(() => {
6947
7766
  if (typeof window !== "undefined") {
6948
7767
  const savedSummary = localStorage.getItem(`table_summary_${tableKey}`);
6949
7768
  if (savedSummary !== null) {
@@ -6992,7 +7811,7 @@ function TableBlockClient({
6992
7811
  return __spreadProps(__spreadValues({}, row), { id: String(row.id || ""), data: rowData });
6993
7812
  });
6994
7813
  };
6995
- const mergeColumnDefs = (0, import_react19.useCallback)((existingCols, incomingCols) => {
7814
+ const mergeColumnDefs = (0, import_react20.useCallback)((existingCols, incomingCols) => {
6996
7815
  if (!incomingCols || incomingCols.length === 0) return existingCols || [];
6997
7816
  if (!existingCols || existingCols.length === 0) return incomingCols;
6998
7817
  const existingMap = new Map(existingCols.map((c) => [c.name, c]));
@@ -7012,18 +7831,18 @@ function TableBlockClient({
7012
7831
  return ((_a = a.order) != null ? _a : 0) - ((_b = b.order) != null ? _b : 0);
7013
7832
  });
7014
7833
  }, []);
7015
- const [localColumns, setLocalColumns] = (0, import_react19.useState)(() => (schema == null ? void 0 : schema.columns) || []);
7016
- (0, import_react19.useEffect)(() => {
7834
+ const [localColumns, setLocalColumns] = (0, import_react20.useState)(() => (schema == null ? void 0 : schema.columns) || []);
7835
+ (0, import_react20.useEffect)(() => {
7017
7836
  if ((schema == null ? void 0 : schema.columns) && schema.columns.length > 0) {
7018
7837
  setLocalColumns((prev) => mergeColumnDefs(prev, schema.columns));
7019
7838
  }
7020
7839
  }, [schema == null ? void 0 : schema.columns, mergeColumnDefs]);
7021
- const [dirty, setDirty] = (0, import_react19.useState)({ added: [], modified: {}, deleted: [] });
7022
- const dirtyRef = (0, import_react19.useRef)(dirty);
7023
- (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)(() => {
7024
7843
  dirtyRef.current = dirty;
7025
7844
  }, [dirty]);
7026
- const mergeWithDirty = (0, import_react19.useCallback)((baseRecords) => {
7845
+ const mergeWithDirty = (0, import_react20.useCallback)((baseRecords) => {
7027
7846
  const { added, modified, deleted } = dirtyRef.current;
7028
7847
  const nonDeleted = (baseRecords || []).filter((r) => !deleted.includes(r.id));
7029
7848
  const modifiedRecords = nonDeleted.map((r) => {
@@ -7036,8 +7855,8 @@ function TableBlockClient({
7036
7855
  const uniqueAdded = added.filter((r) => !baseIds.has(r.id));
7037
7856
  return [...uniqueAdded, ...modifiedRecords];
7038
7857
  }, []);
7039
- const [data, setData] = (0, import_react19.useState)(() => normalizeRecords(initialRecords));
7040
- 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));
7041
7860
  const filteredData = data;
7042
7861
  const isEqualValues = (a, b) => {
7043
7862
  if (a === b) return true;
@@ -7049,30 +7868,30 @@ function TableBlockClient({
7049
7868
  }
7050
7869
  return false;
7051
7870
  };
7052
- const [baseRecordsMap, setBaseRecordsMap] = (0, import_react19.useState)(() => {
7871
+ const [baseRecordsMap, setBaseRecordsMap] = (0, import_react20.useState)(() => {
7053
7872
  const map = /* @__PURE__ */ new Map();
7054
7873
  (normalizeRecords(initialRecords) || []).forEach((r) => map.set(r.id, __spreadValues({}, r.data)));
7055
7874
  return map;
7056
7875
  });
7057
- (0, import_react19.useEffect)(() => {
7876
+ (0, import_react20.useEffect)(() => {
7058
7877
  if (initialRecords && initialRecords.length > 0) {
7059
7878
  const map = /* @__PURE__ */ new Map();
7060
7879
  (normalizeRecords(initialRecords) || []).forEach((r) => map.set(r.id, __spreadValues({}, r.data)));
7061
7880
  setBaseRecordsMap(map);
7062
7881
  }
7063
7882
  }, [initialRecords]);
7064
- const [searchQuery, setSearchQuery] = (0, import_react19.useState)("");
7065
- const [columnFilters, setColumnFilters] = (0, import_react19.useState)({});
7066
- const [activeSearchCol, setActiveSearchCol] = (0, import_react19.useState)(null);
7067
- const activeSearchRef = (0, import_react19.useRef)(null);
7068
- const [activeRelationCol, setActiveRelationCol] = (0, import_react19.useState)(null);
7069
- const [relationTriggerRect, setRelationTriggerRect] = (0, import_react19.useState)(null);
7070
- const filterButtonRefs = (0, import_react19.useRef)({});
7071
- const [relationOptions, setRelationOptions] = (0, import_react19.useState)({});
7072
- const [relationFilterOptions, setRelationFilterOptions] = (0, import_react19.useState)({});
7073
- const [loadingFilterCol, setLoadingFilterCol] = (0, import_react19.useState)(null);
7074
- const relationDictionaryRef = (0, import_react19.useRef)({});
7075
- 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) => {
7076
7895
  if (!Array.isArray(newOptions) || newOptions.length === 0) return;
7077
7896
  if (!relationDictionaryRef.current[colName]) {
7078
7897
  relationDictionaryRef.current[colName] = /* @__PURE__ */ new Map();
@@ -7095,7 +7914,7 @@ function TableBlockClient({
7095
7914
  }));
7096
7915
  }
7097
7916
  }, []);
7098
- (0, import_react19.useEffect)(() => {
7917
+ (0, import_react20.useEffect)(() => {
7099
7918
  if (!activeSearchCol) return;
7100
7919
  const handleMouseDown = (e) => {
7101
7920
  if (activeSearchRef.current && !activeSearchRef.current.contains(e.target)) {
@@ -7107,7 +7926,7 @@ function TableBlockClient({
7107
7926
  document.removeEventListener("mousedown", handleMouseDown);
7108
7927
  };
7109
7928
  }, [activeSearchCol]);
7110
- const filtersKey = (0, import_react19.useMemo)(() => {
7929
+ const filtersKey = (0, import_react20.useMemo)(() => {
7111
7930
  const active = {};
7112
7931
  Object.entries(columnFilters).forEach(([k, v]) => {
7113
7932
  if (Array.isArray(v) && v.length > 0) active[k] = v;
@@ -7122,24 +7941,24 @@ function TableBlockClient({
7122
7941
  executeAction,
7123
7942
  onResolved: (resolved) => setColumnFilters((prev) => __spreadValues(__spreadValues({}, resolved), prev))
7124
7943
  });
7125
- const [debouncedSearch, setDebouncedSearch] = (0, import_react19.useState)(searchQuery);
7126
- (0, import_react19.useEffect)(() => {
7944
+ const [debouncedSearch, setDebouncedSearch] = (0, import_react20.useState)(searchQuery);
7945
+ (0, import_react20.useEffect)(() => {
7127
7946
  const timer = setTimeout(() => {
7128
7947
  setDebouncedSearch(searchQuery.trim());
7129
7948
  }, 300);
7130
7949
  return () => clearTimeout(timer);
7131
7950
  }, [searchQuery]);
7132
- const isSearchMountedRef = (0, import_react19.useRef)(false);
7133
- (0, import_react19.useEffect)(() => {
7951
+ const isSearchMountedRef = (0, import_react20.useRef)(false);
7952
+ (0, import_react20.useEffect)(() => {
7134
7953
  if (!isSearchMountedRef.current) {
7135
7954
  isSearchMountedRef.current = true;
7136
7955
  return;
7137
7956
  }
7138
7957
  setPage(1);
7139
7958
  }, [debouncedSearch]);
7140
- const [isFetching, setIsFetching] = (0, import_react19.useState)(false);
7141
- const fetchRequestIdRef = (0, import_react19.useRef)(0);
7142
- 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) => {
7143
7962
  const tableId = (schema == null ? void 0 : schema.tableMetaId) || (schema == null ? void 0 : schema.tableId) || (schema == null ? void 0 : schema.id);
7144
7963
  const action = executeActionRef.current;
7145
7964
  if (!tableId || !action) {
@@ -7228,12 +8047,12 @@ function TableBlockClient({
7228
8047
  setLocalColumns((prev) => mergeColumnDefs(prev, res.schema.columns));
7229
8048
  }
7230
8049
  if (res.records && Array.isArray(res.records)) {
7231
- const norm = normalizeRecords(res.records);
8050
+ const norm2 = normalizeRecords(res.records);
7232
8051
  const map = /* @__PURE__ */ new Map();
7233
- norm.forEach((r) => map.set(r.id, __spreadValues({}, r.data)));
8052
+ norm2.forEach((r) => map.set(r.id, __spreadValues({}, r.data)));
7234
8053
  setBaseRecordsMap(map);
7235
- setServerRecords(norm);
7236
- setData(mergeWithDirty(norm));
8054
+ setServerRecords(norm2);
8055
+ setData(mergeWithDirty(norm2));
7237
8056
  }
7238
8057
  if (res.meta) {
7239
8058
  const total = typeof res.meta.totalRecords === "number" ? res.meta.totalRecords : 0;
@@ -7263,19 +8082,19 @@ function TableBlockClient({
7263
8082
  }
7264
8083
  });
7265
8084
  }, [schema == null ? void 0 : schema.tableMetaId, schema == null ? void 0 : schema.tableId, schema == null ? void 0 : schema.id, mergeColumnDefs, mergeWithDirty, mergeRelationOptions]);
7266
- (0, import_react19.useEffect)(() => {
8085
+ (0, import_react20.useEffect)(() => {
7267
8086
  if (!defaultFiltersReady) return;
7268
8087
  fetchTableData(page, limit, debouncedSearch, filtersKey);
7269
8088
  }, [page, limit, debouncedSearch, filtersKey, fetchTableData, defaultFiltersReady]);
7270
- (0, import_react19.useEffect)(() => {
8089
+ (0, import_react20.useEffect)(() => {
7271
8090
  if (initialRecords && defaultFiltersReady) {
7272
- const norm = normalizeRecords(initialRecords);
7273
- setServerRecords(norm);
8091
+ const norm2 = normalizeRecords(initialRecords);
8092
+ setServerRecords(norm2);
7274
8093
  const hasActiveFilters = Boolean(debouncedSearch) || Object.keys(columnFilters).length > 0;
7275
8094
  if (hasActiveFilters && executeActionRef.current) {
7276
8095
  fetchTableData(page, limit, debouncedSearch, filtersKey);
7277
8096
  } else if (hasActiveFilters) {
7278
- let locallyFiltered = norm;
8097
+ let locallyFiltered = norm2;
7279
8098
  if (debouncedSearch) {
7280
8099
  const q = debouncedSearch.toLowerCase();
7281
8100
  locallyFiltered = locallyFiltered.filter(
@@ -7326,14 +8145,14 @@ function TableBlockClient({
7326
8145
  }
7327
8146
  setData(mergeWithDirty(locallyFiltered));
7328
8147
  } else {
7329
- setData(mergeWithDirty(norm));
8148
+ setData(mergeWithDirty(norm2));
7330
8149
  }
7331
8150
  }
7332
8151
  }, [initialRecords, mergeWithDirty, debouncedSearch, columnFilters, fetchTableData, page, limit, filtersKey, defaultFiltersReady]);
7333
- const refetchTableData = (0, import_react19.useCallback)(() => {
8152
+ const refetchTableData = (0, import_react20.useCallback)(() => {
7334
8153
  return fetchTableData(page, limit, debouncedSearch, filtersKey);
7335
8154
  }, [page, limit, debouncedSearch, filtersKey, fetchTableData]);
7336
- const handleApplyColumnFilter = (0, import_react19.useCallback)((colName, nextVal) => {
8155
+ const handleApplyColumnFilter = (0, import_react20.useCallback)((colName, nextVal) => {
7337
8156
  setColumnFilters((prev) => {
7338
8157
  const next = __spreadValues({}, prev);
7339
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) {
@@ -7358,9 +8177,9 @@ function TableBlockClient({
7358
8177
  const handleNextPage = () => {
7359
8178
  setPage((prev) => Math.min(totalPages, prev + 1));
7360
8179
  };
7361
- const [selectedIds, setSelectedIds] = (0, import_react19.useState)(/* @__PURE__ */ new Set());
7362
- const isExternalSyncRef = (0, import_react19.useRef)(false);
7363
- (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)(() => {
7364
8183
  if (selectedRowIds !== void 0) {
7365
8184
  const nextSet = new Set(selectedRowIds);
7366
8185
  setSelectedIds((prev) => {
@@ -7372,8 +8191,8 @@ function TableBlockClient({
7372
8191
  });
7373
8192
  }
7374
8193
  }, [selectedRowIds]);
7375
- const isFirstSelectionChangeRef = (0, import_react19.useRef)(true);
7376
- (0, import_react19.useEffect)(() => {
8194
+ const isFirstSelectionChangeRef = (0, import_react20.useRef)(true);
8195
+ (0, import_react20.useEffect)(() => {
7377
8196
  if (isFirstSelectionChangeRef.current) {
7378
8197
  isFirstSelectionChangeRef.current = false;
7379
8198
  if (selectedIds.size === 0) return;
@@ -7384,13 +8203,13 @@ function TableBlockClient({
7384
8203
  }
7385
8204
  onSelectionChange == null ? void 0 : onSelectionChange(Array.from(selectedIds));
7386
8205
  }, [selectedIds, onSelectionChange]);
7387
- const [pendingDeletions, setPendingDeletions] = (0, import_react19.useState)([]);
7388
- 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);
7389
8208
  const isUpdatingActive = Boolean(isUpdating || isSaving);
7390
- const [isSaveSuccess, setIsSaveSuccess] = (0, import_react19.useState)(false);
7391
- const [expandedRowIds, setExpandedRowIds] = (0, import_react19.useState)(/* @__PURE__ */ new Set());
7392
- const schemaColsString = (0, import_react19.useMemo)(() => JSON.stringify(localColumns || []), [localColumns]);
7393
- 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) => {
7394
8213
  var _a, _b, _c, _d, _e, _f, _g;
7395
8214
  let parsedCols = [];
7396
8215
  try {
@@ -7429,7 +8248,7 @@ function TableBlockClient({
7429
8248
  }
7430
8249
  return [];
7431
8250
  }, [schemaColsString, executeAction, mergeRelationOptions]);
7432
- const fetchRelationFilterOptions = (0, import_react19.useCallback)(async (colName) => {
8251
+ const fetchRelationFilterOptions = (0, import_react20.useCallback)(async (colName) => {
7433
8252
  var _a;
7434
8253
  let parsedCols = [];
7435
8254
  try {
@@ -7465,8 +8284,8 @@ function TableBlockClient({
7465
8284
  setLoadingFilterCol(null);
7466
8285
  }
7467
8286
  }, [schemaColsString, schema == null ? void 0 : schema.tableMetaId, schema == null ? void 0 : schema.tableId, schema == null ? void 0 : schema.id, executeAction, mergeRelationOptions]);
7468
- const requestedRelationIdsRef = (0, import_react19.useRef)({});
7469
- (0, import_react19.useEffect)(() => {
8287
+ const requestedRelationIdsRef = (0, import_react20.useRef)({});
8288
+ (0, import_react20.useEffect)(() => {
7470
8289
  if (!executeAction || !data || data.length === 0) return;
7471
8290
  let parsedCols = [];
7472
8291
  try {
@@ -7519,7 +8338,7 @@ function TableBlockClient({
7519
8338
  }
7520
8339
  });
7521
8340
  }, [data, schemaColsString, executeAction, relationOptions, mergeRelationOptions]);
7522
- (0, import_react19.useEffect)(() => {
8341
+ (0, import_react20.useEffect)(() => {
7523
8342
  let parsedCols = [];
7524
8343
  try {
7525
8344
  parsedCols = JSON.parse(schemaColsString);
@@ -7533,7 +8352,7 @@ function TableBlockClient({
7533
8352
  refetchRelation(col.name);
7534
8353
  });
7535
8354
  }, [schemaColsString, refetchRelation]);
7536
- const normalizedColumns = (0, import_react19.useMemo)(() => {
8355
+ const normalizedColumns = (0, import_react20.useMemo)(() => {
7537
8356
  return (localColumns || []).map((col, idx) => {
7538
8357
  const isRequired = col.isRequired === true || String(col.isRequired) === "true";
7539
8358
  const isUnique = col.isUnique === true || String(col.isUnique) === "true";
@@ -7547,17 +8366,17 @@ function TableBlockClient({
7547
8366
  return ((_a = a.order) != null ? _a : 0) - ((_b = b.order) != null ? _b : 0);
7548
8367
  });
7549
8368
  }, [localColumns]);
7550
- const filteredColumns = (0, import_react19.useMemo)(() => {
8369
+ const filteredColumns = (0, import_react20.useMemo)(() => {
7551
8370
  const systemFields = ["_id", "createdAt", "updatedAt", "orgId", "tableId"];
7552
8371
  return normalizedColumns.filter((col) => !systemFields.includes(col.name) && !col.isHidden);
7553
8372
  }, [normalizedColumns]);
7554
- const customizableColumns = (0, import_react19.useMemo)(() => {
8373
+ const customizableColumns = (0, import_react20.useMemo)(() => {
7555
8374
  const systemFields = ["_id", "createdAt", "updatedAt", "orgId", "tableId"];
7556
8375
  return normalizedColumns.filter((col) => !systemFields.includes(col.name));
7557
8376
  }, [normalizedColumns]);
7558
- const [isColumnsDropdownOpen, setIsColumnsDropdownOpen] = (0, import_react19.useState)(false);
7559
- const dropdownRef = (0, import_react19.useRef)(null);
7560
- (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)(() => {
7561
8380
  const handleClickOutside = (e) => {
7562
8381
  if (dropdownRef.current && !dropdownRef.current.contains(e.target)) {
7563
8382
  setIsColumnsDropdownOpen(false);
@@ -7799,7 +8618,7 @@ function TableBlockClient({
7799
8618
  setData((prev) => [newRow, ...prev]);
7800
8619
  setDirty((prev) => __spreadProps(__spreadValues({}, prev), { added: [newRow, ...prev.added] }));
7801
8620
  };
7802
- const handleCellChange = (0, import_react19.useCallback)((rowId, colName, value) => {
8621
+ const handleCellChange = (0, import_react20.useCallback)((rowId, colName, value) => {
7803
8622
  setData((prev) => prev.map(
7804
8623
  (row) => row.id === rowId ? __spreadProps(__spreadValues({}, row), { data: __spreadProps(__spreadValues({}, row.data), { [colName]: value }) }) : row
7805
8624
  ));
@@ -7832,13 +8651,13 @@ function TableBlockClient({
7832
8651
  });
7833
8652
  }, [baseRecordsMap]);
7834
8653
  const handleCellChangeWithCopy = useRelationCopyHandler({ columns: localColumns, handleCellChange });
7835
- const triggerSaveSuccess = (0, import_react19.useCallback)(() => {
8654
+ const triggerSaveSuccess = (0, import_react20.useCallback)(() => {
7836
8655
  setIsSaveSuccess(true);
7837
8656
  setTimeout(() => {
7838
8657
  setIsSaveSuccess(false);
7839
8658
  }, 2500);
7840
8659
  }, []);
7841
- const handleQuietCellChange = (0, import_react19.useCallback)((rowId, colName, value) => {
8660
+ const handleQuietCellChange = (0, import_react20.useCallback)((rowId, colName, value) => {
7842
8661
  setData((prev) => prev.map(
7843
8662
  (row) => row.id === rowId ? __spreadProps(__spreadValues({}, row), { data: __spreadProps(__spreadValues({}, row.data), { [colName]: value }) }) : row
7844
8663
  ));
@@ -7862,12 +8681,12 @@ function TableBlockClient({
7862
8681
  });
7863
8682
  }
7864
8683
  }, []);
7865
- const toggleSelectAll = (0, import_react19.useCallback)((checked) => {
8684
+ const toggleSelectAll = (0, import_react20.useCallback)((checked) => {
7866
8685
  onRowToggle == null ? void 0 : onRowToggle("ALL", checked);
7867
8686
  const next = checked ? new Set(filteredData.map((r) => r.id)) : /* @__PURE__ */ new Set();
7868
8687
  setSelectedIds(next);
7869
8688
  }, [filteredData, onRowToggle]);
7870
- const toggleSelectRow = (0, import_react19.useCallback)((rowId, checked) => {
8689
+ const toggleSelectRow = (0, import_react20.useCallback)((rowId, checked) => {
7871
8690
  onRowToggle == null ? void 0 : onRowToggle(rowId, checked);
7872
8691
  setSelectedIds((prev) => {
7873
8692
  const next = new Set(prev);
@@ -7876,7 +8695,7 @@ function TableBlockClient({
7876
8695
  return next;
7877
8696
  });
7878
8697
  }, [onRowToggle]);
7879
- const handleToggleExpand = (0, import_react19.useCallback)((rowId) => {
8698
+ const handleToggleExpand = (0, import_react20.useCallback)((rowId) => {
7880
8699
  setExpandedRowIds((prev) => {
7881
8700
  const next = new Set(prev);
7882
8701
  if (next.has(rowId)) next.delete(rowId);
@@ -7884,7 +8703,7 @@ function TableBlockClient({
7884
8703
  return next;
7885
8704
  });
7886
8705
  }, []);
7887
- const handleMarkForDeletion = (0, import_react19.useCallback)((fileId) => {
8706
+ const handleMarkForDeletion = (0, import_react20.useCallback)((fileId) => {
7888
8707
  setPendingDeletions((prev) => [...prev, fileId]);
7889
8708
  }, []);
7890
8709
  const handleDeleteSelected = () => {
@@ -8113,7 +8932,7 @@ function TableBlockClient({
8113
8932
  setIsSaving(false);
8114
8933
  }
8115
8934
  };
8116
- const getRowRelationLabels = (0, import_react19.useCallback)((rowVal, col) => {
8935
+ const getRowRelationLabels = (0, import_react20.useCallback)((rowVal, col) => {
8117
8936
  const ids = normalizeRelationValue(rowVal);
8118
8937
  if (ids.length === 0) return [];
8119
8938
  const options = relationOptions[col.name] || [];
@@ -8132,7 +8951,7 @@ function TableBlockClient({
8132
8951
  return "";
8133
8952
  }).filter(Boolean);
8134
8953
  }, [relationOptions]);
8135
- const getUniqueRelationOptions = (0, import_react19.useCallback)((col) => {
8954
+ const getUniqueRelationOptions = (0, import_react20.useCallback)((col) => {
8136
8955
  if (relationFilterOptions[col.name]) {
8137
8956
  return relationFilterOptions[col.name];
8138
8957
  }
@@ -8182,7 +9001,7 @@ function TableBlockClient({
8182
9001
  }
8183
9002
  return col.type === "CURRENCY" ? getCurrencySymbol((_c = col.config) == null ? void 0 : _c.currencySymbol) : "";
8184
9003
  };
8185
- const columnTotals = (0, import_react19.useMemo)(() => {
9004
+ const columnTotals = (0, import_react20.useMemo)(() => {
8186
9005
  const totals = {};
8187
9006
  if (!showSummary) return totals;
8188
9007
  filteredColumns.forEach((col) => {
@@ -8932,7 +9751,7 @@ function ExpandedSubTables({
8932
9751
  context
8933
9752
  }) {
8934
9753
  var _a;
8935
- 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);
8936
9755
  if (subTableColumns.length === 0) return null;
8937
9756
  if (subTableColumns.length === 1) {
8938
9757
  const stCol = subTableColumns[0];
@@ -8973,7 +9792,7 @@ function ExpandedSubTables({
8973
9792
  ) })
8974
9793
  ] }) });
8975
9794
  }
8976
- var TableRow = import_react19.default.memo(function TableRow2({
9795
+ var TableRow = import_react20.default.memo(function TableRow2({
8977
9796
  row,
8978
9797
  isSelected,
8979
9798
  rowStatus,
@@ -9006,7 +9825,7 @@ var TableRow = import_react19.default.memo(function TableRow2({
9006
9825
  renderRowExtra
9007
9826
  }) {
9008
9827
  const lockedCopyTargets = getRelationCopyLockedTargets(schema == null ? void 0 : schema.columns);
9009
- 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: [
9010
9829
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("tr", { className: `transition-colors group hover:bg-blue-50 ${isSelected ? "bg-blue-50" : ""}`, children: [
9011
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: [
9012
9831
  rowStatus && (() => {
@@ -9158,7 +9977,7 @@ var TableRow = import_react19.default.memo(function TableRow2({
9158
9977
  });
9159
9978
 
9160
9979
  // src/components/TableBlock/formTracking/FormTrackingTableBlock.tsx
9161
- var import_react20 = require("react");
9980
+ var import_react21 = require("react");
9162
9981
 
9163
9982
  // src/components/TableBlock/formTracking/formTracking.types.ts
9164
9983
  function getFormTrackingConfig(settings) {
@@ -9199,9 +10018,9 @@ function FormTrackingTableBlock(props) {
9199
10018
  const config = getFormTrackingConfig(settings);
9200
10019
  const { addToast, showError } = useToast();
9201
10020
  const tableId = (settings == null ? void 0 : settings.tableMetaId) || (settings == null ? void 0 : settings.tableId) || (settings == null ? void 0 : settings.id);
9202
- const [sentOverrides, setSentOverrides] = (0, import_react20.useState)({});
9203
- const [busyKey, setBusyKey] = (0, import_react20.useState)(null);
9204
- 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)(
9205
10024
  async (rowId, step) => {
9206
10025
  if (!executeAction || !tableId) return;
9207
10026
  setBusyKey(`${rowId}|${step.formId}|link`);
@@ -9227,7 +10046,7 @@ function FormTrackingTableBlock(props) {
9227
10046
  },
9228
10047
  [executeAction, tableId, addToast, showError]
9229
10048
  );
9230
- const setSent = (0, import_react20.useCallback)(
10049
+ const setSent = (0, import_react21.useCallback)(
9231
10050
  async (rowId, step, value) => {
9232
10051
  if (!executeAction || !tableId || !step.sentColumn) return;
9233
10052
  setBusyKey(`${rowId}|${step.formId}|sent`);
@@ -9249,7 +10068,7 @@ function FormTrackingTableBlock(props) {
9249
10068
  );
9250
10069
  const firstFormStep = config == null ? void 0 : config.steps.find((s) => s.kind === "create");
9251
10070
  const firstFormUrl = firstFormStep && tableId ? `${getPlatformOrigin()}/embed/form/${tableId}?form=${firstFormStep.formId}` : "";
9252
- const copyFirstFormLink = (0, import_react20.useCallback)(async () => {
10071
+ const copyFirstFormLink = (0, import_react21.useCallback)(async () => {
9253
10072
  if (!firstFormUrl) return;
9254
10073
  try {
9255
10074
  await navigator.clipboard.writeText(firstFormUrl);
@@ -9258,7 +10077,7 @@ function FormTrackingTableBlock(props) {
9258
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);
9259
10078
  }
9260
10079
  }, [firstFormUrl, firstFormStep, addToast]);
9261
- const renderRowExtra = (0, import_react20.useCallback)(
10080
+ const renderRowExtra = (0, import_react21.useCallback)(
9262
10081
  (row) => {
9263
10082
  var _a;
9264
10083
  if (!config) return null;
@@ -9346,13 +10165,13 @@ function TableBlock(props) {
9346
10165
  }
9347
10166
 
9348
10167
  // src/components/PlacementBlock/PlacementBlock.tsx
9349
- var import_react23 = require("react");
10168
+ var import_react24 = require("react");
9350
10169
  var import_ag_grid_react = require("ag-grid-react");
9351
10170
  var import_ag_grid_community = require("ag-grid-community");
9352
10171
  var import_lucide_react10 = require("lucide-react");
9353
10172
 
9354
10173
  // src/components/PlacementBlock/PlacementSettings.tsx
9355
- var import_react21 = __toESM(require("react"));
10174
+ var import_react22 = __toESM(require("react"));
9356
10175
 
9357
10176
  // src/components/PlacementBlock/placementColumns.ts
9358
10177
  var RELATION_SEP = "::";
@@ -9474,7 +10293,7 @@ var SummaryRow = ({ label, value, hint }) => /* @__PURE__ */ (0, import_jsx_runt
9474
10293
  ] });
9475
10294
  var PlacementStatusEditor = ({ config, onChange }) => {
9476
10295
  var _a;
9477
- const radioName = `placement-default-status-${import_react21.default.useId()}`;
10296
+ const radioName = `placement-default-status-${import_react22.default.useId()}`;
9478
10297
  const statuses = ((_a = config.statusColors) == null ? void 0 : _a.length) ? config.statusColors : DEFAULT_PLACEMENT_STATUS_COLORS;
9479
10298
  const defaultStatusId = resolveDefaultStatusId(statuses, config.defaultReturnStatusId);
9480
10299
  const setStatuses = (next, defId = defaultStatusId) => {
@@ -9745,7 +10564,7 @@ var PlacementSettings = ({ config, onChange, tables }) => {
9745
10564
  };
9746
10565
 
9747
10566
  // src/components/PlacementBlock/PlacementRelationButtons.tsx
9748
- var import_react22 = require("react");
10567
+ var import_react23 = require("react");
9749
10568
  var import_jsx_runtime21 = require("react/jsx-runtime");
9750
10569
  var GROUP_COLORS = [
9751
10570
  { title: "bg-blue-600 text-white", active: "bg-blue-600 border-blue-600 text-white hover:bg-blue-700", count: "text-blue-700" },
@@ -9767,7 +10586,7 @@ var PlacementRelationButtons = ({
9767
10586
  relationOptions,
9768
10587
  className = ""
9769
10588
  }) => {
9770
- const groups = (0, import_react22.useMemo)(() => {
10589
+ const groups = (0, import_react23.useMemo)(() => {
9771
10590
  const activeEntries = Object.entries(filters).filter(([, v]) => v !== void 0 && v !== null && v !== "");
9772
10591
  return (columnNames || []).map((colName) => {
9773
10592
  var _a, _b, _c, _d;
@@ -9957,7 +10776,7 @@ var CheckHeader = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div"
9957
10776
  }
9958
10777
  ) });
9959
10778
  var RelationFilterHeader = (props) => {
9960
- const btnRef = (0, import_react23.useRef)(null);
10779
+ const btnRef = (0, import_react24.useRef)(null);
9961
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: [
9962
10781
  /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
9963
10782
  "button",
@@ -9984,20 +10803,20 @@ var RelationFilterHeader = (props) => {
9984
10803
  var PlacementBlock = (props) => {
9985
10804
  var _a, _b;
9986
10805
  const { executeAction, fetchSourceData, fetchTargetData, updateAssignment, className = "" } = props;
9987
- const config = (0, import_react23.useMemo)(() => {
10806
+ const config = (0, import_react24.useMemo)(() => {
9988
10807
  var _a2, _b2, _c;
9989
10808
  const raw = (_a2 = props.config) != null ? _a2 : props.settings;
9990
10809
  if (!raw) return void 0;
9991
10810
  return ((_b2 = raw.config) == null ? void 0 : _b2.sourceTableId) || ((_c = raw.config) == null ? void 0 : _c.targetTableId) ? raw.config : raw;
9992
10811
  }, [props.config, props.settings]);
9993
- const statuses = (0, import_react23.useMemo)(
10812
+ const statuses = (0, import_react24.useMemo)(
9994
10813
  () => {
9995
10814
  var _a2;
9996
10815
  return ((_a2 = config == null ? void 0 : config.statusColors) == null ? void 0 : _a2.length) ? config.statusColors : DEFAULT_PLACEMENT_STATUS_COLORS;
9997
10816
  },
9998
10817
  [config == null ? void 0 : config.statusColors]
9999
10818
  );
10000
- const defaultStatusId = (0, import_react23.useMemo)(
10819
+ const defaultStatusId = (0, import_react24.useMemo)(
10001
10820
  () => resolveDefaultStatusId(statuses, config == null ? void 0 : config.defaultReturnStatusId),
10002
10821
  [statuses, config == null ? void 0 : config.defaultReturnStatusId]
10003
10822
  );
@@ -10005,31 +10824,31 @@ var PlacementBlock = (props) => {
10005
10824
  const targetTableId = config == null ? void 0 : config.targetTableId;
10006
10825
  const displayField = (config == null ? void 0 : config.sourceDisplayFieldId) || "name";
10007
10826
  const assignmentField = config == null ? void 0 : config.targetAssignmentFieldId;
10008
- const executeActionRef = (0, import_react23.useRef)(executeAction);
10827
+ const executeActionRef = (0, import_react24.useRef)(executeAction);
10009
10828
  executeActionRef.current = executeAction;
10010
- const legacyRef = (0, import_react23.useRef)({ fetchSourceData, fetchTargetData, updateAssignment });
10829
+ const legacyRef = (0, import_react24.useRef)({ fetchSourceData, fetchTargetData, updateAssignment });
10011
10830
  legacyRef.current = { fetchSourceData, fetchTargetData, updateAssignment };
10012
- const [sourceRows, setSourceRows] = (0, import_react23.useState)([]);
10013
- const [sourceColumns, setSourceColumns] = (0, import_react23.useState)([]);
10014
- const [sourceRelOptions, setSourceRelOptions] = (0, import_react23.useState)({});
10015
- const [sourceRelFilters, setSourceRelFilters] = (0, import_react23.useState)({});
10016
- const [targetRows, setTargetRows] = (0, import_react23.useState)([]);
10017
- const [targetColumns, setTargetColumns] = (0, import_react23.useState)([]);
10018
- const [targetRelOptions, setTargetRelOptions] = (0, import_react23.useState)({});
10019
- const [selectedTargetId, setSelectedTargetId] = (0, import_react23.useState)("");
10020
- const [candidateIds, setCandidateIds] = (0, import_react23.useState)([]);
10021
- const [checkedIds, setCheckedIds] = (0, import_react23.useState)([]);
10022
- const [isSaving, setIsSaving] = (0, import_react23.useState)(false);
10023
- const [sourceSearch, setSourceSearch] = (0, import_react23.useState)("");
10024
- const [candidateSearch, setCandidateSearch] = (0, import_react23.useState)("");
10025
- const [statusMap, setStatusMap] = (0, import_react23.useState)({});
10026
- const [isLoading, setIsLoading] = (0, import_react23.useState)(false);
10027
- const [loadError, setLoadError] = (0, import_react23.useState)(null);
10028
- const [saveError, setSaveError] = (0, import_react23.useState)(null);
10029
- const [colFilters, setColFilters] = (0, import_react23.useState)({ source: {}, cand: {} });
10030
- const [filterPopover, setFilterPopover] = (0, import_react23.useState)(null);
10031
- const [targetFilters, setTargetFilters] = (0, import_react23.useState)({});
10032
- 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) => {
10033
10852
  const exec = executeActionRef.current;
10034
10853
  if (exec) {
10035
10854
  const res = await exec("FETCH_TABLE_DATA", { tableId, tableMetaId: tableId, limit: FETCH_LIMIT, skip: 0 });
@@ -10042,7 +10861,7 @@ var PlacementBlock = (props) => {
10042
10861
  }
10043
10862
  throw new Error("executeAction \u05DC\u05D0 \u05D4\u05D5\u05E2\u05D1\u05E8 \u05DC\u05E8\u05DB\u05D9\u05D1 \u05D4\u05E9\u05D9\u05D1\u05D5\u05E5");
10044
10863
  }, []);
10045
- (0, import_react23.useEffect)(() => {
10864
+ (0, import_react24.useEffect)(() => {
10046
10865
  if (!sourceTableId || !targetTableId) return;
10047
10866
  let cancelled = false;
10048
10867
  (async () => {
@@ -10070,7 +10889,7 @@ var PlacementBlock = (props) => {
10070
10889
  cancelled = true;
10071
10890
  };
10072
10891
  }, [sourceTableId, targetTableId, loadTable]);
10073
- const displayValue = (0, import_react23.useCallback)((col, val) => {
10892
+ const displayValue = (0, import_react24.useCallback)((col, val) => {
10074
10893
  var _a2, _b2, _c, _d, _e;
10075
10894
  let text2 = cellText(val);
10076
10895
  if (text2 && /^[a-fA-F0-9]{24}$/.test(text2)) {
@@ -10090,7 +10909,7 @@ var PlacementBlock = (props) => {
10090
10909
  }
10091
10910
  return text2;
10092
10911
  }, [targetRelOptions, targetRows, sourceRows]);
10093
- const relationLabelMaps = (0, import_react23.useMemo)(() => {
10912
+ const relationLabelMaps = (0, import_react24.useMemo)(() => {
10094
10913
  const maps = {};
10095
10914
  Object.entries(sourceRelOptions || {}).forEach(([colName, opts]) => {
10096
10915
  const m = /* @__PURE__ */ new Map();
@@ -10103,7 +10922,7 @@ var PlacementBlock = (props) => {
10103
10922
  });
10104
10923
  return maps;
10105
10924
  }, [sourceRelOptions]);
10106
- const relationLabelsOf = (0, import_react23.useCallback)((row, colName) => {
10925
+ const relationLabelsOf = (0, import_react24.useCallback)((row, colName) => {
10107
10926
  var _a2;
10108
10927
  const map = relationLabelMaps[colName];
10109
10928
  const ids = normalizeRelationValue((_a2 = row.data) == null ? void 0 : _a2[colName]);
@@ -10112,7 +10931,7 @@ var PlacementBlock = (props) => {
10112
10931
  const txt = cellText(readColumnValue(row.data, colName));
10113
10932
  return txt && !/^[a-fA-F0-9]{24}$/.test(txt) ? txt.split(", ").filter(Boolean) : [];
10114
10933
  }, [relationLabelMaps]);
10115
- const rowPassesColFilters = (0, import_react23.useCallback)((row, filters) => {
10934
+ const rowPassesColFilters = (0, import_react24.useCallback)((row, filters) => {
10116
10935
  return Object.entries(filters).every(([colName, f]) => {
10117
10936
  if (!f) return true;
10118
10937
  const labels = relationLabelsOf(row, colName);
@@ -10121,7 +10940,7 @@ var PlacementBlock = (props) => {
10121
10940
  return true;
10122
10941
  });
10123
10942
  }, [relationLabelsOf]);
10124
- const setColFilter = (0, import_react23.useCallback)((grid, colName, payload) => {
10943
+ const setColFilter = (0, import_react24.useCallback)((grid, colName, payload) => {
10125
10944
  setColFilters((prev) => {
10126
10945
  const next = __spreadValues({}, prev[grid]);
10127
10946
  if (payload === void 0) delete next[colName];
@@ -10129,11 +10948,11 @@ var PlacementBlock = (props) => {
10129
10948
  return __spreadProps(__spreadValues({}, prev), { [grid]: next });
10130
10949
  });
10131
10950
  }, []);
10132
- const openColFilter = (0, import_react23.useCallback)((grid, colName, rect) => {
10951
+ const openColFilter = (0, import_react24.useCallback)((grid, colName, rect) => {
10133
10952
  setFilterPopover((cur) => cur && cur.grid === grid && cur.colName === colName ? null : { grid, colName, rect });
10134
10953
  }, []);
10135
- const closeColFilter = (0, import_react23.useCallback)(() => setFilterPopover(null), []);
10136
- const filterColumns = (0, import_react23.useMemo)(() => {
10954
+ const closeColFilter = (0, import_react24.useCallback)(() => setFilterPopover(null), []);
10955
+ const filterColumns = (0, import_react24.useMemo)(() => {
10137
10956
  const definedFilters = (config == null ? void 0 : config.filterFields) || [];
10138
10957
  const legacyFilters = [config == null ? void 0 : config.targetFilterField1Id, config == null ? void 0 : config.targetFilterField2Id].filter(Boolean);
10139
10958
  const fieldsToUse = definedFilters.length > 0 ? definedFilters : legacyFilters;
@@ -10159,7 +10978,7 @@ var PlacementBlock = (props) => {
10159
10978
  return targetColumns.filter((c) => isUserColumn(c) && c.name !== assignmentField && !["id", "_id", "id_", "statusId"].includes(c.name)).slice(0, 3);
10160
10979
  }, [targetColumns, assignmentField, config]);
10161
10980
  const rawSelectorField = (config == null ? void 0 : config.targetSelectorFieldId) || (config == null ? void 0 : config.targetDisplayFieldId) || ((_a = filterColumns[0]) == null ? void 0 : _a.name) || "";
10162
- const selectorField = (0, import_react23.useMemo)(() => {
10981
+ const selectorField = (0, import_react24.useMemo)(() => {
10163
10982
  const { relationColumn } = parseColumnRef(rawSelectorField);
10164
10983
  if (relationColumn && !targetColumns.some((c) => c.name === rawSelectorField) && targetColumns.some((c) => {
10165
10984
  var _a2;
@@ -10169,7 +10988,7 @@ var PlacementBlock = (props) => {
10169
10988
  }
10170
10989
  return rawSelectorField;
10171
10990
  }, [rawSelectorField, targetColumns]);
10172
- const filteredTargetRows = (0, import_react23.useMemo)(() => {
10991
+ const filteredTargetRows = (0, import_react24.useMemo)(() => {
10173
10992
  return targetRows.filter((r) => {
10174
10993
  return filterColumns.every((col) => {
10175
10994
  const filterVal = targetFilters[col.name];
@@ -10178,7 +10997,7 @@ var PlacementBlock = (props) => {
10178
10997
  });
10179
10998
  });
10180
10999
  }, [targetRows, targetFilters, filterColumns, displayValue]);
10181
- (0, import_react23.useEffect)(() => {
11000
+ (0, import_react24.useEffect)(() => {
10182
11001
  if (filteredTargetRows.length > 0) {
10183
11002
  if (!selectedTargetId || !filteredTargetRows.some((r) => r.id === selectedTargetId)) {
10184
11003
  setSelectedTargetId(filteredTargetRows[0].id);
@@ -10187,8 +11006,8 @@ var PlacementBlock = (props) => {
10187
11006
  setSelectedTargetId("");
10188
11007
  }
10189
11008
  }, [filteredTargetRows, selectedTargetId]);
10190
- const appliedDefaultsKeyRef = (0, import_react23.useRef)("");
10191
- (0, import_react23.useEffect)(() => {
11009
+ const appliedDefaultsKeyRef = (0, import_react24.useRef)("");
11010
+ (0, import_react24.useEffect)(() => {
10192
11011
  const defaults = config == null ? void 0 : config.targetFilterDefaults;
10193
11012
  if (isLoading || !defaults || targetRows.length === 0 || targetColumns.length === 0) return;
10194
11013
  const key = `${targetTableId}|${JSON.stringify(defaults)}`;
@@ -10203,11 +11022,11 @@ var PlacementBlock = (props) => {
10203
11022
  });
10204
11023
  if (Object.keys(resolved).length > 0) setTargetFilters((prev) => __spreadValues(__spreadValues({}, resolved), prev));
10205
11024
  }, [config, isLoading, targetRows, targetColumns, targetTableId, displayValue]);
10206
- 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]);
10207
11026
  const isRelationField = ((_b = assignmentColumn == null ? void 0 : assignmentColumn.type) == null ? void 0 : _b.toUpperCase()) === "RELATION";
10208
11027
  const assignmentLabel = (assignmentColumn == null ? void 0 : assignmentColumn.label) || (assignmentColumn == null ? void 0 : assignmentColumn.name) || assignmentField || "";
10209
- const nameOf = (0, import_react23.useCallback)((row) => cellText(readColumnValue(row.data, displayField)) || "\u05DC\u05DC\u05D0 \u05E9\u05DD", [displayField]);
10210
- 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)(() => {
10211
11030
  var _a2;
10212
11031
  const target = targetRows.find((r) => r.id === selectedTargetId);
10213
11032
  if (!target || !assignmentField) return [];
@@ -10221,36 +11040,36 @@ var PlacementBlock = (props) => {
10221
11040
  }).filter((id) => !!id && sourceRows.some((s) => s.id === id));
10222
11041
  return Array.from(new Set(ids));
10223
11042
  }, [selectedTargetId, targetRows, sourceRows, assignmentField, isRelationField, nameOf]);
10224
- const assignedIdsRef = (0, import_react23.useRef)(assignedIds);
11043
+ const assignedIdsRef = (0, import_react24.useRef)(assignedIds);
10225
11044
  assignedIdsRef.current = assignedIds;
10226
- (0, import_react23.useEffect)(() => {
11045
+ (0, import_react24.useEffect)(() => {
10227
11046
  setCandidateIds(assignedIdsRef.current);
10228
11047
  setCheckedIds(assignedIdsRef.current);
10229
11048
  }, [selectedTargetId, sourceRows]);
10230
- 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]);
10231
- const candidateRows = (0, import_react23.useMemo)(() => candidateIds.map((id) => sourceRows.find((r) => r.id === id)).filter((r) => !!r), [candidateIds, sourceRows]);
10232
- 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)(() => {
10233
11052
  const checked = new Set(checkedIds);
10234
11053
  return candidateRows.filter((r) => rowPassesColFilters(r, colFilters.cand)).map((r) => toGridRow(r, checked.has(r.id)));
10235
11054
  }, [candidateRows, checkedIds, toGridRow, rowPassesColFilters, colFilters.cand]);
10236
- const availableRows = (0, import_react23.useMemo)(() => {
11055
+ const availableRows = (0, import_react24.useMemo)(() => {
10237
11056
  const set = new Set(candidateIds);
10238
11057
  return sourceRows.filter((r) => !set.has(r.id));
10239
11058
  }, [candidateIds, sourceRows]);
10240
- const relationButtonColumns = (0, import_react23.useMemo)(() => {
11059
+ const relationButtonColumns = (0, import_react24.useMemo)(() => {
10241
11060
  const wanted = Array.isArray(config == null ? void 0 : config.relationButtonColumns) ? config.relationButtonColumns : [];
10242
11061
  return wanted.filter((name) => sourceColumns.some((c) => (c == null ? void 0 : c.name) === name && String(c == null ? void 0 : c.type).toUpperCase() === "RELATION"));
10243
11062
  }, [config, sourceColumns]);
10244
11063
  const hasRelationButtons = relationButtonColumns.length > 0;
10245
- const handleRelationFilterChange = (0, import_react23.useCallback)((colName, id) => {
11064
+ const handleRelationFilterChange = (0, import_react24.useCallback)((colName, id) => {
10246
11065
  setSourceRelFilters((prev) => __spreadProps(__spreadValues({}, prev), { [colName]: id }));
10247
11066
  }, []);
10248
- const availableGridData = (0, import_react23.useMemo)(() => {
11067
+ const availableGridData = (0, import_react24.useMemo)(() => {
10249
11068
  const active = Object.entries(sourceRelFilters).filter(([name, v]) => !!v && relationButtonColumns.includes(name));
10250
11069
  const byButtons = active.length === 0 ? availableRows : availableRows.filter((r) => active.every(([name, v]) => rowMatchesRelationFilter(r, name, v)));
10251
11070
  return byButtons.filter((r) => rowPassesColFilters(r, colFilters.source)).map((r) => toGridRow(r));
10252
11071
  }, [availableRows, sourceRelFilters, relationButtonColumns, toGridRow, rowPassesColFilters, colFilters.source]);
10253
- const persistAssignment = (0, import_react23.useCallback)(async (nextIds) => {
11072
+ const persistAssignment = (0, import_react24.useCallback)(async (nextIds) => {
10254
11073
  const exec = executeActionRef.current;
10255
11074
  if (exec && targetTableId && assignmentField && selectedTargetId) {
10256
11075
  const value = isRelationField ? nextIds : nextIds.map((id) => sourceRows.find((r) => r.id === id)).filter((r) => !!r).map(nameOf).join(", ");
@@ -10262,33 +11081,33 @@ var PlacementBlock = (props) => {
10262
11081
  for (const id of nextIds.filter((i) => !assignedIds.includes(i))) await legacyRef.current.updateAssignment(selectedTargetId, id);
10263
11082
  }
10264
11083
  }, [targetTableId, assignmentField, selectedTargetId, isRelationField, sourceRows, nameOf, assignedIds]);
10265
- const moveToCandidates = (0, import_react23.useCallback)((id) => {
11084
+ const moveToCandidates = (0, import_react24.useCallback)((id) => {
10266
11085
  setCandidateIds((prev) => prev.includes(id) ? prev : [...prev, id]);
10267
11086
  }, []);
10268
- const moveToSource = (0, import_react23.useCallback)((id) => {
11087
+ const moveToSource = (0, import_react24.useCallback)((id) => {
10269
11088
  setCandidateIds((prev) => prev.filter((x) => x !== id));
10270
11089
  setCheckedIds((prev) => prev.filter((x) => x !== id));
10271
11090
  setStatusMap((prev) => __spreadProps(__spreadValues({}, prev), { [id]: defaultStatusId }));
10272
11091
  }, [defaultStatusId]);
10273
- const moveToCandidatesRef = (0, import_react23.useRef)(moveToCandidates);
11092
+ const moveToCandidatesRef = (0, import_react24.useRef)(moveToCandidates);
10274
11093
  moveToCandidatesRef.current = moveToCandidates;
10275
- const moveToSourceRef = (0, import_react23.useRef)(moveToSource);
11094
+ const moveToSourceRef = (0, import_react24.useRef)(moveToSource);
10276
11095
  moveToSourceRef.current = moveToSource;
10277
- const toggleChecked = (0, import_react23.useCallback)((id) => {
11096
+ const toggleChecked = (0, import_react24.useCallback)((id) => {
10278
11097
  setCheckedIds((prev) => prev.includes(id) ? prev.filter((x) => x !== id) : [...prev, id]);
10279
11098
  }, []);
10280
11099
  const allChecked = candidateIds.length > 0 && candidateIds.every((id) => checkedIds.includes(id));
10281
11100
  const someChecked = candidateIds.some((id) => checkedIds.includes(id));
10282
- const toggleAll = (0, import_react23.useCallback)(() => {
11101
+ const toggleAll = (0, import_react24.useCallback)(() => {
10283
11102
  setCheckedIds(allChecked ? [] : [...candidateIds]);
10284
11103
  }, [allChecked, candidateIds]);
10285
- const returnAll = (0, import_react23.useCallback)(() => {
11104
+ const returnAll = (0, import_react24.useCallback)(() => {
10286
11105
  setCandidateIds([]);
10287
11106
  setCheckedIds([]);
10288
11107
  }, []);
10289
- 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]);
10290
11109
  const isDirty = checkedCandidates.length !== assignedIds.length || checkedCandidates.some((id) => !assignedIds.includes(id));
10291
- const submitAssignment = (0, import_react23.useCallback)(async () => {
11110
+ const submitAssignment = (0, import_react24.useCallback)(async () => {
10292
11111
  if (!selectedTargetId) {
10293
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");
10294
11113
  return;
@@ -10304,14 +11123,14 @@ var PlacementBlock = (props) => {
10304
11123
  setIsSaving(false);
10305
11124
  }
10306
11125
  }, [selectedTargetId, persistAssignment, checkedCandidates]);
10307
- const cycleStatus = (0, import_react23.useCallback)((recordId) => {
11126
+ const cycleStatus = (0, import_react24.useCallback)((recordId) => {
10308
11127
  setStatusMap((prev) => {
10309
11128
  const current = prev[recordId] || defaultStatusId;
10310
11129
  const idx = statuses.findIndex((c) => c.id === current);
10311
11130
  return __spreadProps(__spreadValues({}, prev), { [recordId]: statuses[(idx + 1) % statuses.length].id });
10312
11131
  });
10313
11132
  }, [statuses, defaultStatusId]);
10314
- const cancelAssignment = (0, import_react23.useCallback)(async () => {
11133
+ const cancelAssignment = (0, import_react24.useCallback)(async () => {
10315
11134
  if (!selectedTargetId || assignedIds.length === 0) return;
10316
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;
10317
11136
  const removed = new Set(assignedIds);
@@ -10327,7 +11146,7 @@ var PlacementBlock = (props) => {
10327
11146
  setIsSaving(false);
10328
11147
  }
10329
11148
  }, [selectedTargetId, assignedIds, assignmentLabel, persistAssignment]);
10330
- const makeColDefs = (0, import_react23.useCallback)((columns, fallbackName, grid, withCheckbox = false) => {
11149
+ const makeColDefs = (0, import_react24.useCallback)((columns, fallbackName, grid, withCheckbox = false) => {
10331
11150
  const gridFilters = colFilters[grid];
10332
11151
  const defs = [];
10333
11152
  if (withCheckbox) {
@@ -10372,36 +11191,36 @@ var PlacementBlock = (props) => {
10372
11191
  return defs;
10373
11192
  }, [cycleStatus, statuses, defaultStatusId, displayField, displayValue, toggleChecked, toggleAll, allChecked, someChecked, colFilters, openColFilter]);
10374
11193
  const sourceHeader = displayField === "name" ? "\u05E9\u05DD" : columnRefLabel(displayField);
10375
- const sourceColDefs = (0, import_react23.useMemo)(() => makeColDefs(sourceColumns, sourceHeader, "source"), [makeColDefs, sourceColumns, sourceHeader]);
10376
- const candidateColDefs = (0, import_react23.useMemo)(() => makeColDefs(sourceColumns, sourceHeader, "cand", true), [makeColDefs, sourceColumns, sourceHeader]);
10377
- 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 }), []);
10378
11197
  const scrollableColIds = (defs) => defs.filter((d) => !d.pinned).map((d) => {
10379
11198
  var _a2;
10380
11199
  return (_a2 = d.colId) != null ? _a2 : d.field;
10381
11200
  }).filter(Boolean);
10382
- const expandColumns = (0, import_react23.useCallback)((api) => {
11201
+ const expandColumns = (0, import_react24.useCallback)((api) => {
10383
11202
  api == null ? void 0 : api.sizeColumnsToFit();
10384
11203
  }, []);
10385
- const shrinkColumns = (0, import_react23.useCallback)((api, defs) => {
11204
+ const shrinkColumns = (0, import_react24.useCallback)((api, defs) => {
10386
11205
  api == null ? void 0 : api.autoSizeColumns(scrollableColIds(defs));
10387
11206
  }, []);
10388
- const popoverOptions = (0, import_react23.useMemo)(() => {
11207
+ const popoverOptions = (0, import_react24.useMemo)(() => {
10389
11208
  if (!filterPopover) return [];
10390
11209
  const rows = filterPopover.grid === "source" ? availableRows : candidateRows;
10391
11210
  const set = /* @__PURE__ */ new Set();
10392
11211
  rows.forEach((r) => relationLabelsOf(r, filterPopover.colName).forEach((l) => set.add(l)));
10393
11212
  return Array.from(set).sort((a, b) => a.localeCompare(b, "he")).map((label) => ({ id: label, label }));
10394
11213
  }, [filterPopover, availableRows, candidateRows, relationLabelsOf]);
10395
- const popoverColumn = (0, import_react23.useMemo)(
11214
+ const popoverColumn = (0, import_react24.useMemo)(
10396
11215
  () => filterPopover ? sourceColumns.find((c) => c.name === filterPopover.colName) : void 0,
10397
11216
  [filterPopover, sourceColumns]
10398
11217
  );
10399
- const getRowId = (0, import_react23.useCallback)((p) => p.data.id, []);
10400
- const sourceContainerRef = (0, import_react23.useRef)(null);
10401
- const assignedContainerRef = (0, import_react23.useRef)(null);
10402
- const [sourceApi, setSourceApi] = (0, import_react23.useState)(null);
10403
- const [assignedApi, setAssignedApi] = (0, import_react23.useState)(null);
10404
- (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)(() => {
10405
11224
  if (!sourceApi || !assignedApi) return;
10406
11225
  const toAssigned = { getContainer: () => assignedContainerRef.current, onDragStop: (p) => {
10407
11226
  var _a2, _b2;
@@ -10424,20 +11243,20 @@ var PlacementBlock = (props) => {
10424
11243
  }
10425
11244
  };
10426
11245
  }, [sourceApi, assignedApi]);
10427
- const selectorLabel = (0, import_react23.useMemo)(() => {
11246
+ const selectorLabel = (0, import_react24.useMemo)(() => {
10428
11247
  const col = targetColumns.find((c) => c.name === selectorField || c.id === selectorField);
10429
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";
10430
11249
  }, [targetColumns, selectorField]);
10431
- const assignedText = (0, import_react23.useMemo)(
11250
+ const assignedText = (0, import_react24.useMemo)(
10432
11251
  () => assignedIds.map((id) => sourceRows.find((r) => r.id === id)).filter((r) => !!r).map(nameOf).join(", "),
10433
11252
  [assignedIds, sourceRows, nameOf]
10434
11253
  );
10435
11254
  const activeTarget = targetRows.find((r) => r.id === selectedTargetId);
10436
- const targetLabel = (0, import_react23.useCallback)((r) => {
11255
+ const targetLabel = (0, import_react24.useCallback)((r) => {
10437
11256
  const col = targetColumns.find((c) => c.name === selectorField || c.id === selectorField);
10438
11257
  return displayValue(col || { name: selectorField }, readColumnValue(r.data, selectorField)) || "\u05DC\u05DC\u05D0 \u05E9\u05DD";
10439
11258
  }, [selectorField, targetColumns, displayValue]);
10440
- 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]);
10441
11260
  if (!config || !sourceTableId || !targetTableId) {
10442
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)." });
10443
11262
  }
@@ -10600,7 +11419,7 @@ var PlacementBlock = (props) => {
10600
11419
  };
10601
11420
 
10602
11421
  // src/components/PaymentReportsBlock/PaymentReportsBlock.tsx
10603
- var import_react29 = require("react");
11422
+ var import_react30 = require("react");
10604
11423
 
10605
11424
  // src/components/PaymentReportsBlock/PaymentReportsBlock.types.ts
10606
11425
  var PAYMENT_REPORTS_REQUIRED = [
@@ -10799,7 +11618,7 @@ function displayCell(item, col, relationOptions, symbol) {
10799
11618
  }
10800
11619
 
10801
11620
  // src/components/PaymentReportsBlock/UnpaidReportsTab.tsx
10802
- var import_react25 = require("react");
11621
+ var import_react26 = require("react");
10803
11622
  var import_ag_grid_react2 = require("ag-grid-react");
10804
11623
  var import_ag_grid_community2 = require("ag-grid-community");
10805
11624
 
@@ -10859,9 +11678,9 @@ var ConfirmModal = ({ title, message, confirmLabel, danger, busy, onConfirm, onC
10859
11678
  );
10860
11679
 
10861
11680
  // src/components/PaymentReportsBlock/useGridColumnWidths.ts
10862
- var import_react24 = require("react");
11681
+ var import_react25 = require("react");
10863
11682
  function useGridColumnWidths(storageKey) {
10864
- const [widths, setWidths] = (0, import_react24.useState)(() => {
11683
+ const [widths, setWidths] = (0, import_react25.useState)(() => {
10865
11684
  if (typeof window === "undefined") return {};
10866
11685
  try {
10867
11686
  return JSON.parse(localStorage.getItem(storageKey) || "{}") || {};
@@ -10869,7 +11688,7 @@ function useGridColumnWidths(storageKey) {
10869
11688
  return {};
10870
11689
  }
10871
11690
  });
10872
- const onColumnResized = (0, import_react24.useCallback)(
11691
+ const onColumnResized = (0, import_react25.useCallback)(
10873
11692
  (e) => {
10874
11693
  var _a;
10875
11694
  if (!e.finished || e.source !== "uiColumnResized" || !((_a = e.columns) == null ? void 0 : _a.length)) return;
@@ -10885,7 +11704,7 @@ function useGridColumnWidths(storageKey) {
10885
11704
  },
10886
11705
  [storageKey]
10887
11706
  );
10888
- const applyWidths = (0, import_react24.useCallback)(
11707
+ const applyWidths = (0, import_react25.useCallback)(
10889
11708
  (defs) => defs.map((d) => {
10890
11709
  const w = d.colId ? widths[d.colId] : void 0;
10891
11710
  return w ? __spreadProps(__spreadValues({}, d), { width: w, flex: 0 }) : d;
@@ -10927,18 +11746,18 @@ var UnpaidReportsTab = ({
10927
11746
  handlers
10928
11747
  }) => {
10929
11748
  var _a;
10930
- const apiRef = (0, import_react25.useRef)(null);
11749
+ const apiRef = (0, import_react26.useRef)(null);
10931
11750
  const { onColumnResized, applyWidths } = useGridColumnWidths(`payment-reports:${config.reportsTableId}:unpaid`);
10932
- const [selectedIds, setSelectedIds] = (0, import_react25.useState)([]);
10933
- const [confirmOpen, setConfirmOpen] = (0, import_react25.useState)(false);
10934
- const [paying, setPaying] = (0, import_react25.useState)(false);
10935
- 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)(() => {
10936
11755
  var _a2;
10937
11756
  const byName = new Map(columns.filter(isUserColumn2).map((c) => [c.name, c]));
10938
11757
  const wanted = ((_a2 = config.reportDisplayColumns) == null ? void 0 : _a2.length) ? config.reportDisplayColumns : Array.from(byName.keys());
10939
11758
  return wanted.filter((n) => n !== config.reportPaymentColumn && n !== config.reportReporterColumn).map((n) => byName.get(n)).filter(Boolean);
10940
11759
  }, [columns, config.reportDisplayColumns, config.reportPaymentColumn, config.reportReporterColumn]);
10941
- const colDefs = (0, import_react25.useMemo)(() => {
11760
+ const colDefs = (0, import_react26.useMemo)(() => {
10942
11761
  const defs = [
10943
11762
  { headerName: "\u05DE\u05D3\u05D5\u05D5\u05D7", colId: "__reporter", minWidth: 140, valueGetter: (p) => {
10944
11763
  var _a2;
@@ -10998,14 +11817,14 @@ var UnpaidReportsTab = ({
10998
11817
  }
10999
11818
  return defs;
11000
11819
  }, [displayCols, canEdit, symbol, relationOptions, showPaid, paymentLabels, handlers]);
11001
- const finalColDefs = (0, import_react25.useMemo)(() => applyWidths(colDefs), [applyWidths, colDefs]);
11002
- const unpaid = (0, import_react25.useMemo)(() => reports.filter((r) => !r.paymentId), [reports]);
11003
- 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)(() => {
11004
11823
  const amount = unpaid.reduce((s, r) => s + r.amount, 0);
11005
11824
  const qty = unpaid.reduce((s, r) => s + r.qty, 0);
11006
11825
  return { count: unpaid.length, amount, qty, avg: qty > 0 ? amount / qty : 0 };
11007
11826
  }, [unpaid]);
11008
- const selected = (0, import_react25.useMemo)(
11827
+ const selected = (0, import_react26.useMemo)(
11009
11828
  () => unpaid.filter((r) => selectedIds.includes(r.id)),
11010
11829
  [unpaid, selectedIds]
11011
11830
  );
@@ -11124,16 +11943,16 @@ var UnpaidReportsTab = ({
11124
11943
  };
11125
11944
 
11126
11945
  // src/components/PaymentReportsBlock/PaymentsGrid.tsx
11127
- var import_react27 = require("react");
11946
+ var import_react28 = require("react");
11128
11947
  var import_ag_grid_react3 = require("ag-grid-react");
11129
11948
  var import_ag_grid_community3 = require("ag-grid-community");
11130
11949
 
11131
11950
  // src/components/PaymentReportsBlock/ProofCell.tsx
11132
- var import_react26 = require("react");
11951
+ var import_react27 = require("react");
11133
11952
  var import_jsx_runtime25 = require("react/jsx-runtime");
11134
11953
  var ProofCell = ({ files, editable, onUpload, onRemove }) => {
11135
- const inputRef = (0, import_react26.useRef)(null);
11136
- 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);
11137
11956
  const file = files[0];
11138
11957
  const href = (file == null ? void 0 : file.fileUrl) || (file == null ? void 0 : file.url);
11139
11958
  const handleFile = async (e) => {
@@ -11196,8 +12015,8 @@ var ProofRenderer = (p) => p.data ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx
11196
12015
  }
11197
12016
  ) : null;
11198
12017
  var ReceiptRenderer = (p) => {
11199
- const [date, setDate] = (0, import_react27.useState)(todayIso());
11200
- 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);
11201
12020
  if (!p.data) return null;
11202
12021
  const id = p.data.id;
11203
12022
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex items-center gap-2 h-full", children: [
@@ -11265,7 +12084,7 @@ var ActionsRenderer = (p) => {
11265
12084
  };
11266
12085
  var PaymentsGrid = ({ mode, config, symbol, canEdit, payments, search, handlers }) => {
11267
12086
  const { onColumnResized, applyWidths } = useGridColumnWidths(`payment-reports:${config.paymentsTableId}:${mode}`);
11268
- const colDefs = (0, import_react27.useMemo)(() => {
12087
+ const colDefs = (0, import_react28.useMemo)(() => {
11269
12088
  const defs = [
11270
12089
  { headerName: "\u05DE\u05D3\u05D5\u05D5\u05D7", colId: "__reporter", minWidth: 140, valueGetter: (p) => {
11271
12090
  var _a;
@@ -11334,8 +12153,8 @@ var PaymentsGrid = ({ mode, config, symbol, canEdit, payments, search, handlers
11334
12153
  });
11335
12154
  return defs;
11336
12155
  }, [mode, config.paymentProofColumn, symbol, canEdit, handlers]);
11337
- const finalColDefs = (0, import_react27.useMemo)(() => applyWidths(colDefs), [applyWidths, colDefs]);
11338
- 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]);
11339
12158
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex flex-col gap-3", children: [
11340
12159
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "ag-theme-quartz w-full", style: { height: 480 }, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
11341
12160
  import_ag_grid_react3.AgGridReact,
@@ -11373,11 +12192,11 @@ var import_jsx_runtime28 = require("react/jsx-runtime");
11373
12192
  var ReceiptsTab = (props) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(PaymentsGrid, __spreadValues({ mode: "received" }, props));
11374
12193
 
11375
12194
  // src/components/PaymentReportsBlock/PaymentDetailsModal.tsx
11376
- var import_react28 = require("react");
12195
+ var import_react29 = require("react");
11377
12196
  var import_jsx_runtime29 = require("react/jsx-runtime");
11378
12197
  var isUserColumn3 = (c) => !!(c == null ? void 0 : c.name) && c.name !== "_id" && c.name !== "id" && !c.isHidden;
11379
12198
  var PaymentDetailsModal = ({ payment, config, symbol, columns, relationOptions, onClose }) => {
11380
- const cols = (0, import_react28.useMemo)(() => {
12199
+ const cols = (0, import_react29.useMemo)(() => {
11381
12200
  var _a;
11382
12201
  const byName = new Map(columns.filter(isUserColumn3).map((c) => [c.name, c]));
11383
12202
  const wanted = ((_a = config.reportDisplayColumns) == null ? void 0 : _a.length) ? config.reportDisplayColumns : Array.from(byName.keys());
@@ -11546,7 +12365,7 @@ var EMPTY = { rows: [], columns: [], relationOptions: {} };
11546
12365
  var PaymentReportsBlock = (props) => {
11547
12366
  const { executeAction, orgId, role, readOnly, permissions, className } = props;
11548
12367
  const { addToast } = useToast();
11549
- const config = (0, import_react29.useMemo)(() => {
12368
+ const config = (0, import_react30.useMemo)(() => {
11550
12369
  var _a, _b;
11551
12370
  const raw = (_a = props.config) != null ? _a : props.settings;
11552
12371
  if (!raw) return void 0;
@@ -11555,20 +12374,20 @@ var PaymentReportsBlock = (props) => {
11555
12374
  const missing = missingPaymentReportsFields(config);
11556
12375
  const symbol = (config == null ? void 0 : config.currencySymbol) || "\u20AA";
11557
12376
  const canEdit = !readOnly && ((permissions == null ? void 0 : permissions.canUpdate) !== void 0 ? !!permissions.canUpdate : role ? role === "OWNER" || role === "EDITOR" : true);
11558
- const [tab, setTab] = (0, import_react29.useState)("unpaid");
11559
- const [month, setMonth] = (0, import_react29.useState)("");
11560
- const [search, setSearch] = (0, import_react29.useState)("");
11561
- const [showPaid, setShowPaid] = (0, import_react29.useState)(false);
11562
- const [reportsRes, setReportsRes] = (0, import_react29.useState)(EMPTY);
11563
- const [paymentsRes, setPaymentsRes] = (0, import_react29.useState)(EMPTY);
11564
- const [loading, setLoading] = (0, import_react29.useState)(true);
11565
- const [error, setError] = (0, import_react29.useState)(null);
11566
- const [details, setDetails] = (0, import_react29.useState)(null);
11567
- const [confirm, setConfirm] = (0, import_react29.useState)(null);
11568
- const [confirmBusy, setConfirmBusy] = (0, import_react29.useState)(false);
11569
- const toastOk = (0, import_react29.useCallback)((message) => addToast({ type: "success", message }), [addToast]);
11570
- const toastErr = (0, import_react29.useCallback)((e) => addToast({ type: "error", message: (e == null ? void 0 : e.message) || String(e) }), [addToast]);
11571
- 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)(
11572
12391
  async (silent = false) => {
11573
12392
  if (!config || missing.length) return;
11574
12393
  if (!silent) setLoading(true);
@@ -11589,32 +12408,32 @@ var PaymentReportsBlock = (props) => {
11589
12408
  // eslint-disable-next-line react-hooks/exhaustive-deps
11590
12409
  [config == null ? void 0 : config.reportsTableId, config == null ? void 0 : config.paymentsTableId, missing.length, executeAction]
11591
12410
  );
11592
- (0, import_react29.useEffect)(() => {
12411
+ (0, import_react30.useEffect)(() => {
11593
12412
  load();
11594
12413
  }, [load]);
11595
- const model = (0, import_react29.useMemo)(
12414
+ const model = (0, import_react30.useMemo)(
11596
12415
  () => config && !missing.length ? buildModel(config, reportsRes, paymentsRes) : { reports: [], payments: [] },
11597
12416
  [config, missing.length, reportsRes, paymentsRes]
11598
12417
  );
11599
- const months = (0, import_react29.useMemo)(() => {
12418
+ const months = (0, import_react30.useMemo)(() => {
11600
12419
  const set = /* @__PURE__ */ new Set();
11601
12420
  model.reports.forEach((r) => r.month && set.add(r.month));
11602
12421
  return Array.from(set).sort().reverse();
11603
12422
  }, [model.reports]);
11604
- const reportsInMonth = (0, import_react29.useMemo)(
12423
+ const reportsInMonth = (0, import_react30.useMemo)(
11605
12424
  () => model.reports.filter((r) => (!month || r.month === month) && (showPaid || !r.paymentId)),
11606
12425
  [model.reports, month, showPaid]
11607
12426
  );
11608
- const pendingPayments = (0, import_react29.useMemo)(
12427
+ const pendingPayments = (0, import_react30.useMemo)(
11609
12428
  () => model.payments.filter((p) => !p.receiptDate && (!month || p.months.includes(month))),
11610
12429
  [model.payments, month]
11611
12430
  );
11612
- const receivedPayments = (0, import_react29.useMemo)(
12431
+ const receivedPayments = (0, import_react30.useMemo)(
11613
12432
  () => model.payments.filter((p) => !!p.receiptDate && (!month || p.months.includes(month))),
11614
12433
  [model.payments, month]
11615
12434
  );
11616
12435
  const unpaidCount = model.reports.filter((r) => !r.paymentId).length;
11617
- const paymentLabels = (0, import_react29.useMemo)(() => {
12436
+ const paymentLabels = (0, import_react30.useMemo)(() => {
11618
12437
  const m = {};
11619
12438
  model.payments.forEach((p) => {
11620
12439
  m[p.id] = `${p.receiptDate ? "\u05D4\u05EA\u05E7\u05D1\u05DC" : "\u05E9\u05D5\u05DC\u05DD"} \xB7 ${formatMoney(p.total, symbol)}`;
@@ -11622,7 +12441,7 @@ var PaymentReportsBlock = (props) => {
11622
12441
  return m;
11623
12442
  }, [model.payments, symbol]);
11624
12443
  const base = { reportsTableId: config == null ? void 0 : config.reportsTableId, paymentsTableId: config == null ? void 0 : config.paymentsTableId };
11625
- const handlers = (0, import_react29.useRef)(null);
12444
+ const handlers = (0, import_react30.useRef)(null);
11626
12445
  handlers.current = {
11627
12446
  onPay: async (reportIds) => {
11628
12447
  var _a;
@@ -11812,11 +12631,11 @@ var PaymentReportsBlock = (props) => {
11812
12631
  };
11813
12632
 
11814
12633
  // src/components/WhatsAppComponent/WhatsAppComponent.tsx
11815
- var import_react35 = __toESM(require("react"));
12634
+ var import_react36 = __toESM(require("react"));
11816
12635
  var import_lucide_react17 = require("lucide-react");
11817
12636
 
11818
12637
  // src/components/WhatsAppComponent/CreateTemplateModal.tsx
11819
- var import_react30 = require("react");
12638
+ var import_react31 = require("react");
11820
12639
  var import_lucide_react11 = require("lucide-react");
11821
12640
  var import_emoji_picker_react = __toESM(require("emoji-picker-react"));
11822
12641
 
@@ -11946,26 +12765,26 @@ function CreateTemplateModal({
11946
12765
  executeAction,
11947
12766
  orgId
11948
12767
  }) {
11949
- const [templateName, setTemplateName] = (0, import_react30.useState)("");
11950
- const [language, setLanguage] = (0, import_react30.useState)("he");
11951
- const [category, setCategory] = (0, import_react30.useState)("MARKETING");
11952
- const [bodyText, setBodyText] = (0, import_react30.useState)("");
11953
- const [variableSamples, setVariableSamples] = (0, import_react30.useState)({});
11954
- const [hasFileHeader, setHasFileHeader] = (0, import_react30.useState)(false);
11955
- const [selectedFile, setSelectedFile] = (0, import_react30.useState)(null);
11956
- const [fileBase64, setFileBase64] = (0, import_react30.useState)("");
11957
- const [buttons, setButtons] = (0, import_react30.useState)([]);
11958
- const [isAddButtonOpen, setIsAddButtonOpen] = (0, import_react30.useState)(false);
11959
- const addButtonDropdownRef = (0, import_react30.useRef)(null);
11960
- const [isSubmitting, setIsSubmitting] = (0, import_react30.useState)(false);
11961
- const [submittingStep, setSubmittingStep] = (0, import_react30.useState)("");
11962
- const [submitError, setSubmitError] = (0, import_react30.useState)(null);
11963
- const [fileError, setFileError] = (0, import_react30.useState)(null);
11964
- const textareaRef = (0, import_react30.useRef)(null);
11965
- const fileInputRef = (0, import_react30.useRef)(null);
11966
- const emojiPickerRef = (0, import_react30.useRef)(null);
11967
- const [isEmojiPickerOpen, setIsEmojiPickerOpen] = (0, import_react30.useState)(false);
11968
- (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)(() => {
11969
12788
  function handleClickOutside(event) {
11970
12789
  if (emojiPickerRef.current && !emojiPickerRef.current.contains(event.target)) {
11971
12790
  setIsEmojiPickerOpen(false);
@@ -11989,7 +12808,7 @@ function CreateTemplateModal({
11989
12808
  document.removeEventListener("keydown", handleKeyDown2);
11990
12809
  };
11991
12810
  }, [isEmojiPickerOpen, isAddButtonOpen]);
11992
- (0, import_react30.useEffect)(() => {
12811
+ (0, import_react31.useEffect)(() => {
11993
12812
  if (isOpen) {
11994
12813
  setTemplateName("");
11995
12814
  setLanguage("he");
@@ -12008,10 +12827,10 @@ function CreateTemplateModal({
12008
12827
  setIsEmojiPickerOpen(false);
12009
12828
  }
12010
12829
  }, [isOpen]);
12011
- const uniqueVariables = (0, import_react30.useMemo)(() => {
12830
+ const uniqueVariables = (0, import_react31.useMemo)(() => {
12012
12831
  return extractUniqueVariableIndices(bodyText);
12013
12832
  }, [bodyText]);
12014
- (0, import_react30.useEffect)(() => {
12833
+ (0, import_react31.useEffect)(() => {
12015
12834
  setVariableSamples((prev) => {
12016
12835
  const next = {};
12017
12836
  uniqueVariables.forEach((idx) => {
@@ -12022,7 +12841,7 @@ function CreateTemplateModal({
12022
12841
  }, [uniqueVariables]);
12023
12842
  const isNameEmpty = templateName.trim().length === 0;
12024
12843
  const isNamePatternValid = isValidTemplateName(templateName);
12025
- const isNameDuplicate = (0, import_react30.useMemo)(() => {
12844
+ const isNameDuplicate = (0, import_react31.useMemo)(() => {
12026
12845
  const trimmedName = templateName.trim().toLowerCase();
12027
12846
  if (!trimmedName) return false;
12028
12847
  if (existingTemplates && existingTemplates.length > 0) {
@@ -12032,9 +12851,9 @@ function CreateTemplateModal({
12032
12851
  }
12033
12852
  return isDuplicateTemplateName(trimmedName, existingTemplateNames, language);
12034
12853
  }, [templateName, language, existingTemplates, existingTemplateNames]);
12035
- const ratioInfo = (0, import_react30.useMemo)(() => validateWordToVariableRatio(bodyText), [bodyText]);
12036
- const seqInfo = (0, import_react30.useMemo)(() => validateSequentialVariables(bodyText), [bodyText]);
12037
- 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)(() => {
12038
12857
  return validateWhatsAppTemplate({
12039
12858
  name: templateName,
12040
12859
  language,
@@ -13028,7 +13847,7 @@ function CreateTemplateModal({
13028
13847
  }
13029
13848
 
13030
13849
  // src/components/WhatsAppComponent/hooks/useWhatsAppState.ts
13031
- var import_react31 = require("react");
13850
+ var import_react32 = require("react");
13032
13851
 
13033
13852
  // src/components/WhatsAppComponent/utils/recipientEngine.ts
13034
13853
  var STORAGE_KEY_TEST_PHONE = "whatsapp_test_phone";
@@ -14333,29 +15152,29 @@ function useWhatsAppState(props) {
14333
15152
  data: injectedData
14334
15153
  } = props;
14335
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);
14336
- const [tableColumns2, setTableColumns] = (0, import_react31.useState)(() => {
15155
+ const [tableColumns2, setTableColumns] = (0, import_react32.useState)(() => {
14337
15156
  return Array.isArray(settings == null ? void 0 : settings.columns) ? settings.columns : [];
14338
15157
  });
14339
- const [rawRecords, setRawRecords] = (0, import_react31.useState)(() => {
15158
+ const [rawRecords, setRawRecords] = (0, import_react32.useState)(() => {
14340
15159
  if (Array.isArray(injectedData)) return injectedData;
14341
15160
  if (Array.isArray(injectedData == null ? void 0 : injectedData.records)) return injectedData.records;
14342
15161
  return [];
14343
15162
  });
14344
- const [relationOptions, setRelationOptions] = (0, import_react31.useState)(() => {
15163
+ const [relationOptions, setRelationOptions] = (0, import_react32.useState)(() => {
14345
15164
  return (injectedData == null ? void 0 : injectedData.relationOptions) || {};
14346
15165
  });
14347
- const [isLoadingTableData, setIsLoadingTableData] = (0, import_react31.useState)(() => Boolean(settings == null ? void 0 : settings.tableMetaId));
14348
- const [activeSubtableScans, setActiveSubtableScans] = (0, import_react31.useState)(0);
14349
- const [tableError, setTableError] = (0, import_react31.useState)(null);
14350
- const [filters, setFilters] = (0, import_react31.useState)({});
14351
- const [selectedRowIds, setSelectedRowIds] = (0, import_react31.useState)([]);
14352
- const [autoSelectCount, setAutoSelectCount] = (0, import_react31.useState)(null);
14353
- const isAutoSelectingRef = (0, import_react31.useRef)(false);
14354
- const isManualOverrideRef = (0, import_react31.useRef)(false);
14355
- const prevAutoSelectCountRef = (0, import_react31.useRef)(null);
14356
- const fetchedTableIdsRef = (0, import_react31.useRef)(/* @__PURE__ */ new Set());
14357
- const fullyFetchedRelationKeysRef = (0, import_react31.useRef)(/* @__PURE__ */ new Set());
14358
- 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 () => {
14359
15178
  var _a2;
14360
15179
  const tableId = (settings == null ? void 0 : settings.tableMetaId) || (injectedData == null ? void 0 : injectedData.tableMetaId) || (injectedData == null ? void 0 : injectedData.tableId);
14361
15180
  if (!tableId || !executeAction) return;
@@ -14422,10 +15241,10 @@ function useWhatsAppState(props) {
14422
15241
  executeAction,
14423
15242
  orgId
14424
15243
  ]);
14425
- (0, import_react31.useEffect)(() => {
15244
+ (0, import_react32.useEffect)(() => {
14426
15245
  loadTableData();
14427
15246
  }, [loadTableData]);
14428
- const filterableColumns = (0, import_react31.useMemo)(() => {
15247
+ const filterableColumns = (0, import_react32.useMemo)(() => {
14429
15248
  return (tableColumns2 || []).filter((col) => {
14430
15249
  var _a2;
14431
15250
  if (!col || col.name === "_id" || col.id === "_id") return false;
@@ -14433,15 +15252,15 @@ function useWhatsAppState(props) {
14433
15252
  return type === "RELATION" || type === "BOOLEAN";
14434
15253
  });
14435
15254
  }, [tableColumns2]);
14436
- const [referencedTableSchemas, setReferencedTableSchemas] = (0, import_react31.useState)({});
14437
- const subtableCols = (0, import_react31.useMemo)(() => {
15255
+ const [referencedTableSchemas, setReferencedTableSchemas] = (0, import_react32.useState)({});
15256
+ const subtableCols = (0, import_react32.useMemo)(() => {
14438
15257
  return (tableColumns2 || []).filter((col) => {
14439
15258
  var _a2;
14440
15259
  const type = (_a2 = col.type) == null ? void 0 : _a2.toUpperCase();
14441
15260
  return type === "RELATION" || type === "SUB_TABLE" || type === "SUBTABLE";
14442
15261
  });
14443
15262
  }, [tableColumns2]);
14444
- (0, import_react31.useEffect)(() => {
15263
+ (0, import_react32.useEffect)(() => {
14445
15264
  if (!executeAction) return;
14446
15265
  const unrequestedCols = subtableCols.filter((col) => {
14447
15266
  var _a2;
@@ -14487,20 +15306,20 @@ function useWhatsAppState(props) {
14487
15306
  const isScanningPhoneColumns = Boolean(
14488
15307
  isLoadingTableData || activeSubtableScans > 0 || tableColumns2.length === 0 && Boolean(settings == null ? void 0 : settings.tableMetaId)
14489
15308
  );
14490
- const targetPhoneOptions = (0, import_react31.useMemo)(() => {
15309
+ const targetPhoneOptions = (0, import_react32.useMemo)(() => {
14491
15310
  const cols = tableColumns2 && tableColumns2.length > 0 ? tableColumns2 : Array.isArray(settings == null ? void 0 : settings.columns) ? settings.columns : [];
14492
15311
  return scanTargetPhoneOptions(cols, referencedTableSchemas);
14493
15312
  }, [tableColumns2, settings == null ? void 0 : settings.columns, referencedTableSchemas]);
14494
- const phoneColumns = (0, import_react31.useMemo)(() => {
15313
+ const phoneColumns = (0, import_react32.useMemo)(() => {
14495
15314
  return targetPhoneOptions.map((opt) => ({ name: opt.label, id: opt.id, type: "PHONE" }));
14496
15315
  }, [targetPhoneOptions]);
14497
- const [phoneColumnId, setPhoneColumnId] = (0, import_react31.useState)("");
14498
- const [subtableFilterColumn, setSubtableFilterColumn] = (0, import_react31.useState)("");
14499
- const [subtableFilterValue, setSubtableFilterValue] = (0, import_react31.useState)("");
14500
- 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)(
14501
15320
  (settings == null ? void 0 : settings.subtableSendLimit) || "PRIMARY"
14502
15321
  );
14503
- (0, import_react31.useEffect)(() => {
15322
+ (0, import_react32.useEffect)(() => {
14504
15323
  if (targetPhoneOptions.length > 0) {
14505
15324
  const isValid = targetPhoneOptions.some(
14506
15325
  (opt) => opt.id === phoneColumnId || opt.columnName === phoneColumnId
@@ -14512,13 +15331,13 @@ function useWhatsAppState(props) {
14512
15331
  setPhoneColumnId("");
14513
15332
  }
14514
15333
  }, [targetPhoneOptions, phoneColumnId]);
14515
- const selectedPhoneOption = (0, import_react31.useMemo)(() => {
15334
+ const selectedPhoneOption = (0, import_react32.useMemo)(() => {
14516
15335
  if (!phoneColumnId) return targetPhoneOptions[0] || null;
14517
15336
  return targetPhoneOptions.find(
14518
15337
  (opt) => opt.id === phoneColumnId || opt.columnName === phoneColumnId
14519
15338
  ) || targetPhoneOptions[0] || null;
14520
15339
  }, [targetPhoneOptions, phoneColumnId]);
14521
- const subtableFilterableColumns = (0, import_react31.useMemo)(() => {
15340
+ const subtableFilterableColumns = (0, import_react32.useMemo)(() => {
14522
15341
  var _a2, _b2, _c;
14523
15342
  if (!selectedPhoneOption || selectedPhoneOption.type !== "SUBTABLE") {
14524
15343
  return [];
@@ -14537,14 +15356,14 @@ function useWhatsAppState(props) {
14537
15356
  return type === "BOOLEAN" || type === "RELATION";
14538
15357
  });
14539
15358
  }, [selectedPhoneOption, referencedTableSchemas, tableColumns2]);
14540
- const selectedSubtableFilterCol = (0, import_react31.useMemo)(() => {
15359
+ const selectedSubtableFilterCol = (0, import_react32.useMemo)(() => {
14541
15360
  return subtableFilterableColumns.find((c) => c.name === subtableFilterColumn);
14542
15361
  }, [subtableFilterableColumns, subtableFilterColumn]);
14543
- const [enablePostSendAction, setEnablePostSendAction] = (0, import_react31.useState)(false);
14544
- const [postSendActionColumn, setPostSendActionColumn] = (0, import_react31.useState)("");
14545
- const [postSendActionValue, setPostSendActionValue] = (0, import_react31.useState)("");
14546
- const [postSendActionTargetType, setPostSendActionTargetType] = (0, import_react31.useState)("MAIN");
14547
- 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)(() => {
14548
15367
  var _a2, _b2, _c;
14549
15368
  const options = [];
14550
15369
  (tableColumns2 || []).forEach((col) => {
@@ -14589,14 +15408,14 @@ function useWhatsAppState(props) {
14589
15408
  }
14590
15409
  return options;
14591
15410
  }, [tableColumns2, selectedPhoneOption, referencedTableSchemas]);
14592
- const selectedPostSendOption = (0, import_react31.useMemo)(() => {
15411
+ const selectedPostSendOption = (0, import_react32.useMemo)(() => {
14593
15412
  return postSendActionTargetOptions.find(
14594
15413
  (opt) => opt.id === postSendActionColumn || opt.columnName === postSendActionColumn
14595
15414
  );
14596
15415
  }, [postSendActionTargetOptions, postSendActionColumn]);
14597
15416
  const selectedPostSendCol = selectedPostSendOption;
14598
- const [isTestPromptOpen, setIsTestPromptOpen] = (0, import_react31.useState)(false);
14599
- const [testPhoneNumber, setTestPhoneNumber] = (0, import_react31.useState)(() => {
15417
+ const [isTestPromptOpen, setIsTestPromptOpen] = (0, import_react32.useState)(false);
15418
+ const [testPhoneNumber, setTestPhoneNumber] = (0, import_react32.useState)(() => {
14600
15419
  if (typeof window !== "undefined") {
14601
15420
  try {
14602
15421
  return localStorage.getItem(STORAGE_KEY_TEST_PHONE) || "";
@@ -14606,10 +15425,10 @@ function useWhatsAppState(props) {
14606
15425
  }
14607
15426
  return "";
14608
15427
  });
14609
- const [testFeedback, setTestFeedback] = (0, import_react31.useState)(null);
14610
- const [isSendingTest, setIsSendingTest] = (0, import_react31.useState)(false);
14611
- const [isSendingBroadcast, setIsSendingBroadcast] = (0, import_react31.useState)(false);
14612
- 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)({
14613
15432
  current: 0,
14614
15433
  total: 0,
14615
15434
  successful: 0,
@@ -14617,12 +15436,12 @@ function useWhatsAppState(props) {
14617
15436
  skipped: 0,
14618
15437
  percent: 0
14619
15438
  });
14620
- const [broadcastSummary, setBroadcastSummary] = (0, import_react31.useState)(null);
14621
- const [rowStatusMap, setRowStatusMap] = (0, import_react31.useState)({});
14622
- 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)(() => {
14623
15442
  setBroadcastSummary(null);
14624
15443
  }, []);
14625
- const handleTestPhoneChange = (0, import_react31.useCallback)((val) => {
15444
+ const handleTestPhoneChange = (0, import_react32.useCallback)((val) => {
14626
15445
  setTestPhoneNumber(val);
14627
15446
  if (typeof window !== "undefined") {
14628
15447
  try {
@@ -14632,7 +15451,7 @@ function useWhatsAppState(props) {
14632
15451
  }
14633
15452
  }
14634
15453
  }, []);
14635
- const getRelationOptionsForCol = (0, import_react31.useCallback)(
15454
+ const getRelationOptionsForCol = (0, import_react32.useCallback)(
14636
15455
  (colName, parentColName) => {
14637
15456
  var _a2, _b2, _c, _d;
14638
15457
  if (parentColName) {
@@ -14675,7 +15494,7 @@ function useWhatsAppState(props) {
14675
15494
  },
14676
15495
  [relationOptions, subtableFilterableColumns, postSendActionTargetOptions, tableColumns2, filterableColumns]
14677
15496
  );
14678
- (0, import_react31.useEffect)(() => {
15497
+ (0, import_react32.useEffect)(() => {
14679
15498
  var _a2, _b2, _c, _d, _e;
14680
15499
  if (!executeAction) return;
14681
15500
  const targets = [];
@@ -14769,7 +15588,7 @@ function useWhatsAppState(props) {
14769
15588
  }
14770
15589
  });
14771
15590
  }, [filterableColumns, selectedPhoneOption, referencedTableSchemas, tableColumns2, executeAction, selectedPostSendOption, orgId]);
14772
- (0, import_react31.useEffect)(() => {
15591
+ (0, import_react32.useEffect)(() => {
14773
15592
  var _a2, _b2, _c;
14774
15593
  if (!executeAction || !selectedSubtableFilterCol) return;
14775
15594
  if (((_a2 = selectedSubtableFilterCol.type) == null ? void 0 : _a2.toUpperCase()) !== "RELATION") return;
@@ -14820,7 +15639,7 @@ function useWhatsAppState(props) {
14820
15639
  }
14821
15640
  })();
14822
15641
  }, [selectedSubtableFilterCol, selectedPhoneOption, executeAction, orgId]);
14823
- (0, import_react31.useEffect)(() => {
15642
+ (0, import_react32.useEffect)(() => {
14824
15643
  var _a2, _b2;
14825
15644
  if (!executeAction || !selectedPostSendOption) return;
14826
15645
  if (selectedPostSendOption.type !== "RELATION") return;
@@ -14873,7 +15692,7 @@ function useWhatsAppState(props) {
14873
15692
  }
14874
15693
  })();
14875
15694
  }, [selectedPostSendOption, executeAction, orgId]);
14876
- const filteredRecords = (0, import_react31.useMemo)(() => {
15695
+ const filteredRecords = (0, import_react32.useMemo)(() => {
14877
15696
  const activeEntries = Object.entries(filters).filter(
14878
15697
  ([_, val]) => val !== void 0 && val !== null && val !== ""
14879
15698
  );
@@ -14905,7 +15724,7 @@ function useWhatsAppState(props) {
14905
15724
  });
14906
15725
  }, [rawRecords, filters, filterableColumns]);
14907
15726
  const filteredData = filteredRecords;
14908
- (0, import_react31.useEffect)(() => {
15727
+ (0, import_react32.useEffect)(() => {
14909
15728
  if (autoSelectCount !== null && autoSelectCount > 0) {
14910
15729
  isAutoSelectingRef.current = true;
14911
15730
  const sliced = filteredData.slice(0, autoSelectCount);
@@ -14923,7 +15742,7 @@ function useWhatsAppState(props) {
14923
15742
  isManualOverrideRef.current = false;
14924
15743
  prevAutoSelectCountRef.current = autoSelectCount;
14925
15744
  }, [autoSelectCount, filteredData]);
14926
- const embeddedTableExecuteAction = (0, import_react31.useCallback)(async (actionType, payload) => {
15745
+ const embeddedTableExecuteAction = (0, import_react32.useCallback)(async (actionType, payload) => {
14927
15746
  if (actionType === "FETCH_TABLE_DATA") {
14928
15747
  const colFilters = (payload == null ? void 0 : payload.columnFilters) || (payload == null ? void 0 : payload.filters);
14929
15748
  const searchQuery = payload == null ? void 0 : payload.search;
@@ -14966,10 +15785,10 @@ function useWhatsAppState(props) {
14966
15785
  const handleClearFilters = () => {
14967
15786
  setFilters({});
14968
15787
  };
14969
- const activeFiltersCount = (0, import_react31.useMemo)(() => {
15788
+ const activeFiltersCount = (0, import_react32.useMemo)(() => {
14970
15789
  return Object.values(filters).filter((v) => v !== "").length;
14971
15790
  }, [filters]);
14972
- const handleSelectionChange = (0, import_react31.useCallback)((selectedIds) => {
15791
+ const handleSelectionChange = (0, import_react32.useCallback)((selectedIds) => {
14973
15792
  setSelectedRowIds((prev) => {
14974
15793
  if (prev.length === selectedIds.length && prev.every((id, idx) => id === selectedIds[idx])) {
14975
15794
  return prev;
@@ -14983,13 +15802,13 @@ function useWhatsAppState(props) {
14983
15802
  return selectedIds;
14984
15803
  });
14985
15804
  }, [autoSelectCount]);
14986
- const handleRowToggle = (0, import_react31.useCallback)((rowId, checked) => {
15805
+ const handleRowToggle = (0, import_react32.useCallback)((rowId, checked) => {
14987
15806
  if (autoSelectCount !== null && autoSelectCount > 0) {
14988
15807
  isManualOverrideRef.current = true;
14989
15808
  setAutoSelectCount(null);
14990
15809
  }
14991
15810
  }, [autoSelectCount]);
14992
- const toggleRowSelection = (0, import_react31.useCallback)((rowId, checked) => {
15811
+ const toggleRowSelection = (0, import_react32.useCallback)((rowId, checked) => {
14993
15812
  if (autoSelectCount !== null && autoSelectCount > 0) {
14994
15813
  isManualOverrideRef.current = true;
14995
15814
  setAutoSelectCount(null);
@@ -15005,15 +15824,15 @@ function useWhatsAppState(props) {
15005
15824
  return prev;
15006
15825
  });
15007
15826
  }, [autoSelectCount]);
15008
- const [templates, setTemplates] = (0, import_react31.useState)([]);
15009
- const [selectedTemplateId, setSelectedTemplateId] = (0, import_react31.useState)(null);
15010
- const [isLoading, setIsLoading] = (0, import_react31.useState)(true);
15011
- const [fetchError, setFetchError] = (0, import_react31.useState)(null);
15012
- const [isModalOpen, setIsModalOpen] = (0, import_react31.useState)(false);
15013
- const [isDropdownOpen, setIsDropdownOpen] = (0, import_react31.useState)(false);
15014
- const [isDeleting, setIsDeleting] = (0, import_react31.useState)(false);
15015
- const [feedback, setFeedback] = (0, import_react31.useState)(null);
15016
- 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 () => {
15017
15836
  var _a2, _b2;
15018
15837
  if (!executeAction) {
15019
15838
  setIsLoading(false);
@@ -15065,13 +15884,13 @@ function useWhatsAppState(props) {
15065
15884
  setIsLoading(false);
15066
15885
  }
15067
15886
  }, [executeAction, orgId]);
15068
- (0, import_react31.useEffect)(() => {
15887
+ (0, import_react32.useEffect)(() => {
15069
15888
  loadTemplates();
15070
15889
  }, [loadTemplates]);
15071
- const selectedTemplate = (0, import_react31.useMemo)(() => {
15890
+ const selectedTemplate = (0, import_react32.useMemo)(() => {
15072
15891
  return templates.find((t) => t.id === selectedTemplateId) || null;
15073
15892
  }, [templates, selectedTemplateId]);
15074
- const templateBodyText = (0, import_react31.useMemo)(() => {
15893
+ const templateBodyText = (0, import_react32.useMemo)(() => {
15075
15894
  if (!(selectedTemplate == null ? void 0 : selectedTemplate.components)) return "";
15076
15895
  const bodyComp = selectedTemplate.components.find(
15077
15896
  (c) => {
@@ -15081,7 +15900,7 @@ function useWhatsAppState(props) {
15081
15900
  );
15082
15901
  return (bodyComp == null ? void 0 : bodyComp.text) || "";
15083
15902
  }, [selectedTemplate]);
15084
- const templateHeaderComp = (0, import_react31.useMemo)(() => {
15903
+ const templateHeaderComp = (0, import_react32.useMemo)(() => {
15085
15904
  if (!(selectedTemplate == null ? void 0 : selectedTemplate.components)) return null;
15086
15905
  return selectedTemplate.components.find(
15087
15906
  (c) => {
@@ -15090,8 +15909,8 @@ function useWhatsAppState(props) {
15090
15909
  }
15091
15910
  ) || null;
15092
15911
  }, [selectedTemplate]);
15093
- const [headerMediaUrl, setHeaderMediaUrl] = (0, import_react31.useState)("");
15094
- (0, import_react31.useEffect)(() => {
15912
+ const [headerMediaUrl, setHeaderMediaUrl] = (0, import_react32.useState)("");
15913
+ (0, import_react32.useEffect)(() => {
15095
15914
  if (!templateHeaderComp) {
15096
15915
  setHeaderMediaUrl("");
15097
15916
  return;
@@ -15108,7 +15927,7 @@ function useWhatsAppState(props) {
15108
15927
  setHeaderMediaUrl("");
15109
15928
  }
15110
15929
  }, [templateHeaderComp, selectedTemplate == null ? void 0 : selectedTemplate.name]);
15111
- const handleHeaderMediaUrlChange = (0, import_react31.useCallback)(
15930
+ const handleHeaderMediaUrlChange = (0, import_react32.useCallback)(
15112
15931
  (newUrl) => {
15113
15932
  setHeaderMediaUrl(newUrl);
15114
15933
  if ((selectedTemplate == null ? void 0 : selectedTemplate.name) && typeof window !== "undefined") {
@@ -15127,7 +15946,7 @@ function useWhatsAppState(props) {
15127
15946
  },
15128
15947
  [selectedTemplate == null ? void 0 : selectedTemplate.name]
15129
15948
  );
15130
- const handleResetHeaderMediaUrl = (0, import_react31.useCallback)(() => {
15949
+ const handleResetHeaderMediaUrl = (0, import_react32.useCallback)(() => {
15131
15950
  if ((selectedTemplate == null ? void 0 : selectedTemplate.name) && typeof window !== "undefined") {
15132
15951
  try {
15133
15952
  localStorage.removeItem(`whatsapp_template_media_${selectedTemplate.name}`);
@@ -15141,8 +15960,8 @@ function useWhatsAppState(props) {
15141
15960
  );
15142
15961
  setHeaderMediaUrl(defaultUrl || "");
15143
15962
  }, [templateHeaderComp, selectedTemplate == null ? void 0 : selectedTemplate.name]);
15144
- const [isUploadingMedia, setIsUploadingMedia] = (0, import_react31.useState)(false);
15145
- const handleFileUpload = (0, import_react31.useCallback)(
15963
+ const [isUploadingMedia, setIsUploadingMedia] = (0, import_react32.useState)(false);
15964
+ const handleFileUpload = (0, import_react32.useCallback)(
15146
15965
  async (file, templateName) => {
15147
15966
  const tplName = templateName || (selectedTemplate == null ? void 0 : selectedTemplate.name) || "";
15148
15967
  if (!file) return;
@@ -15183,14 +16002,14 @@ function useWhatsAppState(props) {
15183
16002
  },
15184
16003
  [selectedTemplate == null ? void 0 : selectedTemplate.name]
15185
16004
  );
15186
- const templateVariables = (0, import_react31.useMemo)(() => {
16005
+ const templateVariables = (0, import_react32.useMemo)(() => {
15187
16006
  return extractTemplateVariables(selectedTemplate);
15188
16007
  }, [selectedTemplate]);
15189
- const [variableMapping, setVariableMapping] = (0, import_react31.useState)({});
15190
- (0, import_react31.useEffect)(() => {
16008
+ const [variableMapping, setVariableMapping] = (0, import_react32.useState)({});
16009
+ (0, import_react32.useEffect)(() => {
15191
16010
  setVariableMapping({});
15192
16011
  }, [selectedTemplateId]);
15193
- const textableColumnOptions = (0, import_react31.useMemo)(() => {
16012
+ const textableColumnOptions = (0, import_react32.useMemo)(() => {
15194
16013
  return getTextableColumnOptions({
15195
16014
  tableColumns: tableColumns2,
15196
16015
  selectedPhoneOption,
@@ -15216,7 +16035,7 @@ function useWhatsAppState(props) {
15216
16035
  });
15217
16036
  });
15218
16037
  };
15219
- const existingTemplateNames = (0, import_react31.useMemo)(() => {
16038
+ const existingTemplateNames = (0, import_react32.useMemo)(() => {
15220
16039
  return templates.map((t) => t.name);
15221
16040
  }, [templates]);
15222
16041
  const handleDeleteTemplate = async () => {
@@ -15263,14 +16082,14 @@ function useWhatsAppState(props) {
15263
16082
  postSendActionColumn,
15264
16083
  postSendActionValue
15265
16084
  );
15266
- const isStaticVariableMissing = (0, import_react31.useMemo)(() => {
16085
+ const isStaticVariableMissing = (0, import_react32.useMemo)(() => {
15267
16086
  return isStaticVariableIncomplete(templateVariables, variableMapping);
15268
16087
  }, [templateVariables, variableMapping]);
15269
- const currentRecords = (0, import_react31.useMemo)(() => {
16088
+ const currentRecords = (0, import_react32.useMemo)(() => {
15270
16089
  var _a2;
15271
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 : [];
15272
16091
  }, [rawRecords, props.data]);
15273
- const preparedRecipients = (0, import_react31.useMemo)(() => {
16092
+ const preparedRecipients = (0, import_react32.useMemo)(() => {
15274
16093
  return prepareRecipients({
15275
16094
  selectedIds: selectedRowIds,
15276
16095
  records: currentRecords,
@@ -15290,7 +16109,7 @@ function useWhatsAppState(props) {
15290
16109
  selectedSubtableFilterCol
15291
16110
  ]);
15292
16111
  const finalRecipientCount = preparedRecipients.length;
15293
- const validMainRowsCount = (0, import_react31.useMemo)(() => {
16112
+ const validMainRowsCount = (0, import_react32.useMemo)(() => {
15294
16113
  const rowIdSet = new Set(
15295
16114
  preparedRecipients.map((r) => r.mainRowId).filter(Boolean)
15296
16115
  );
@@ -15399,7 +16218,7 @@ function useWhatsAppState(props) {
15399
16218
  setIsSendingTest(false);
15400
16219
  }
15401
16220
  };
15402
- const handleSendMessages = (0, import_react31.useCallback)(async () => {
16221
+ const handleSendMessages = (0, import_react32.useCallback)(async () => {
15403
16222
  var _a2, _b2;
15404
16223
  if (isSendDisabled || isSendingBroadcast) return;
15405
16224
  const recipients = preparedRecipients;
@@ -15705,7 +16524,7 @@ function useWhatsAppState(props) {
15705
16524
  }
15706
16525
 
15707
16526
  // src/components/WhatsAppComponent/ui/TemplateSelectionBlock.tsx
15708
- var import_react32 = require("react");
16527
+ var import_react33 = require("react");
15709
16528
  var import_lucide_react12 = require("lucide-react");
15710
16529
  var import_jsx_runtime33 = require("react/jsx-runtime");
15711
16530
  function TemplateSelectionBlock({
@@ -15733,7 +16552,7 @@ function TemplateSelectionBlock({
15733
16552
  isUploadingMedia = false,
15734
16553
  handleFileUpload
15735
16554
  }) {
15736
- const fileInputRef = (0, import_react32.useRef)(null);
16555
+ const fileInputRef = (0, import_react33.useRef)(null);
15737
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: [
15738
16557
  /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "space-y-1.5 shrink-0", children: [
15739
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: [
@@ -16685,19 +17504,19 @@ function SettingsAndActionsBlock({
16685
17504
  }
16686
17505
 
16687
17506
  // src/components/WhatsAppComponent/inbox/useInboxState.ts
16688
- var import_react33 = require("react");
17507
+ var import_react34 = require("react");
16689
17508
  function useInboxState(orgId, actions) {
16690
- const [conversations, setConversations] = (0, import_react33.useState)([]);
16691
- const [activeConversationId, setActiveConversationId] = (0, import_react33.useState)(null);
16692
- const [messages, setMessages] = (0, import_react33.useState)([]);
16693
- const [isLoading, setIsLoading] = (0, import_react33.useState)(false);
16694
- const [isSending, setIsSending] = (0, import_react33.useState)(false);
16695
- const [error, setError] = (0, import_react33.useState)(null);
16696
- const actionsRef = (0, import_react33.useRef)(actions);
16697
- (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)(() => {
16698
17517
  actionsRef.current = actions;
16699
17518
  });
16700
- const fetchConversations = (0, import_react33.useCallback)(async () => {
17519
+ const fetchConversations = (0, import_react34.useCallback)(async () => {
16701
17520
  if (!orgId) return;
16702
17521
  const res = await actionsRef.current.getConversations(orgId);
16703
17522
  if (res.success && res.data) {
@@ -16706,7 +17525,7 @@ function useInboxState(orgId, actions) {
16706
17525
  setError(res.error);
16707
17526
  }
16708
17527
  }, [orgId]);
16709
- const fetchMessages = (0, import_react33.useCallback)(async (conversationId, silent = false) => {
17528
+ const fetchMessages = (0, import_react34.useCallback)(async (conversationId, silent = false) => {
16710
17529
  if (!silent) setIsLoading(true);
16711
17530
  const res = await actionsRef.current.getMessages(conversationId);
16712
17531
  if (res.success && res.data) {
@@ -16719,7 +17538,7 @@ function useInboxState(orgId, actions) {
16719
17538
  }
16720
17539
  if (!silent) setIsLoading(false);
16721
17540
  }, []);
16722
- (0, import_react33.useEffect)(() => {
17541
+ (0, import_react34.useEffect)(() => {
16723
17542
  fetchConversations();
16724
17543
  const interval = setInterval(() => {
16725
17544
  fetchConversations();
@@ -16818,17 +17637,17 @@ function ConversationList({ conversations, activeId, onSelect }) {
16818
17637
  }
16819
17638
 
16820
17639
  // src/components/WhatsAppComponent/inbox/ChatWindow.tsx
16821
- var import_react34 = require("react");
17640
+ var import_react35 = require("react");
16822
17641
  var import_lucide_react16 = require("lucide-react");
16823
17642
  var import_jsx_runtime37 = require("react/jsx-runtime");
16824
17643
  function ChatWindow({ activeConversation, messages, isLoading, isSending, onSendMessage }) {
16825
- const [inputText, setInputText] = (0, import_react34.useState)("");
16826
- const messagesTopRef = (0, import_react34.useRef)(null);
17644
+ const [inputText, setInputText] = (0, import_react35.useState)("");
17645
+ const messagesTopRef = (0, import_react35.useRef)(null);
16827
17646
  const scrollToTop = () => {
16828
17647
  var _a;
16829
17648
  (_a = messagesTopRef.current) == null ? void 0 : _a.scrollIntoView({ behavior: "smooth" });
16830
17649
  };
16831
- (0, import_react34.useEffect)(() => {
17650
+ (0, import_react35.useEffect)(() => {
16832
17651
  scrollToTop();
16833
17652
  }, [messages.length, activeConversation == null ? void 0 : activeConversation.id]);
16834
17653
  const handleSend = (e) => {
@@ -16944,7 +17763,7 @@ function WhatsAppComponent(props) {
16944
17763
  var _a;
16945
17764
  const { className = "", settings, orgId, componentId, executeAction } = props;
16946
17765
  const state = useWhatsAppState(props);
16947
- const [activeTab, setActiveTab] = import_react35.default.useState("broadcast");
17766
+ const [activeTab, setActiveTab] = import_react36.default.useState("broadcast");
16948
17767
  return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
16949
17768
  "div",
16950
17769
  {
@@ -17349,12 +18168,12 @@ function WhatsAppComponent(props) {
17349
18168
  }
17350
18169
 
17351
18170
  // src/components/FormBlock/FormBlock.tsx
17352
- var import_react36 = require("react");
18171
+ var import_react37 = require("react");
17353
18172
  var import_lucide_react18 = require("lucide-react");
17354
18173
  var import_jsx_runtime40 = require("react/jsx-runtime");
17355
18174
 
17356
18175
  // src/components/FormBlock/StyledFormBlock.tsx
17357
- var import_react37 = require("react");
18176
+ var import_react38 = require("react");
17358
18177
  var import_lucide_react19 = require("lucide-react");
17359
18178
 
17360
18179
  // src/components/FormBlock/formDesign.ts
@@ -17612,28 +18431,28 @@ function StyledFormBlock({
17612
18431
  recordId
17613
18432
  }) {
17614
18433
  const { showError, addToast } = useToast();
17615
- 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, "");
17616
18435
  const design = schema == null ? void 0 : schema.design;
17617
18436
  const d = resolveFormDesign(design);
17618
18437
  const t = d.tokens;
17619
- const [formData, setFormData] = (0, import_react37.useState)(initialValues || {});
17620
- const [isSubmitting, setIsSubmitting] = (0, import_react37.useState)(false);
17621
- const [isSubmitted, setIsSubmitted] = (0, import_react37.useState)(false);
17622
- const [formError, setFormError] = (0, import_react37.useState)(null);
17623
- const [missingNames, setMissingNames] = (0, import_react37.useState)([]);
17624
- const errorRef = (0, import_react37.useRef)(null);
17625
- const [columns, setColumns] = (0, import_react37.useState)((schema == null ? void 0 : schema.columns) || []);
17626
- const [isLoadingSchema, setIsLoadingSchema] = (0, import_react37.useState)(false);
17627
- const [dragName, setDragName] = (0, import_react37.useState)(null);
17628
- const [drop, setDrop] = (0, import_react37.useState)(null);
17629
- const [resizing, setResizing] = (0, import_react37.useState)(null);
17630
- const resizeRef = (0, import_react37.useRef)(null);
17631
- const gridRef = (0, import_react37.useRef)(null);
17632
- const relationDictRef = (0, import_react37.useRef)({});
17633
- const relationRequestedRef = (0, import_react37.useRef)(/* @__PURE__ */ new Set());
17634
- 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);
17635
18454
  const targetTableId = (schema == null ? void 0 : schema.tableMetaId) || (schema == null ? void 0 : schema.tableId) || (schema == null ? void 0 : schema.id);
17636
- (0, import_react37.useEffect)(() => {
18455
+ (0, import_react38.useEffect)(() => {
17637
18456
  let isMounted = true;
17638
18457
  if ((!(schema == null ? void 0 : schema.columns) || schema.columns.length === 0) && targetTableId && executeAction && !previewMode) {
17639
18458
  setIsLoadingSchema(true);
@@ -17652,13 +18471,13 @@ function StyledFormBlock({
17652
18471
  isMounted = false;
17653
18472
  };
17654
18473
  }, [schema == null ? void 0 : schema.columns, targetTableId]);
17655
- (0, import_react37.useEffect)(() => {
18474
+ (0, import_react38.useEffect)(() => {
17656
18475
  if (submitMode === "update" || previewMode || !columns || columns.length === 0) return;
17657
18476
  const defaults = buildDefaultValues(columns);
17658
18477
  if (Object.keys(defaults).length === 0) return;
17659
18478
  setFormData((prev) => __spreadValues(__spreadValues({}, defaults), prev));
17660
18479
  }, [columns, submitMode, previewMode]);
17661
- (0, import_react37.useEffect)(() => {
18480
+ (0, import_react38.useEffect)(() => {
17662
18481
  if (previewMode || !executeAction || !columns) return;
17663
18482
  for (const col of columns) {
17664
18483
  if ((col.type || "").toUpperCase() !== "RELATION") continue;
@@ -18211,7 +19030,7 @@ function StyledFormBlock({
18211
19030
  }
18212
19031
 
18213
19032
  // src/themes/ThemeScope.tsx
18214
- var React30 = __toESM(require("react"));
19033
+ var React31 = __toESM(require("react"));
18215
19034
  var import_jsx_runtime42 = require("react/jsx-runtime");
18216
19035
  var UNIVERSE_THEME_IDS = ["classic", "clean", "ocean", "warm"];
18217
19036
  function resolveUniverseTheme(value) {
@@ -18222,7 +19041,7 @@ function withThemeScope(Component) {
18222
19041
  var _a, _b, _c;
18223
19042
  const p = props;
18224
19043
  const theme = resolveUniverseTheme((_c = (_a = p.settings) == null ? void 0 : _a.theme) != null ? _c : (_b = p.config) == null ? void 0 : _b.theme);
18225
- 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) });
18226
19045
  }
18227
19046
  ThemeScoped.displayName = `ThemeScoped(${Component.displayName || Component.name || "Component"})`;
18228
19047
  return ThemeScoped;
@@ -18238,19 +19057,28 @@ var UNIVERSE_COMPONENTS = {
18238
19057
  };
18239
19058
  // Annotate the CommonJS export names for ESM import in node:
18240
19059
  0 && (module.exports = {
19060
+ BOOLEAN_BUTTON_FALSE_ID,
19061
+ BOOLEAN_BUTTON_TRUE_ID,
18241
19062
  COLUMN_CAPABILITIES,
18242
19063
  COLUMN_DEFAULT_INPUT_CONFIG,
18243
19064
  COLUMN_TYPES,
18244
19065
  COLUMN_TYPE_LABELS,
18245
19066
  ColumnHeaderTitle,
18246
19067
  CreateTemplateModal,
19068
+ DEFAULT_BOOLEAN_FALSE_LABEL,
19069
+ DEFAULT_BOOLEAN_TRUE_LABEL,
18247
19070
  DEFAULT_FILTER_COLUMN_TYPES,
18248
19071
  DEFAULT_PLACEMENT_STATUS_COLORS,
18249
19072
  DatePickerCell,
18250
19073
  DynamicFiltersBlock,
19074
+ EMPTY_IF_CONDITION,
18251
19075
  FORMULA_COLUMN_TYPE,
19076
+ FORMULA_FUNCTION_GROUPS,
19077
+ FORMULA_OPERATOR_GROUPS,
18252
19078
  FORMULA_SOURCE_TYPES,
19079
+ FORMULA_TYPE_LABELS,
18253
19080
  LinkPickerCell,
19081
+ MAX_FILTER_CONDITIONS,
18254
19082
  NON_TEXT_TYPES,
18255
19083
  PASTEL_PALETTES,
18256
19084
  PAYMENT_REPORTS_ACTIONS,
@@ -18286,6 +19114,8 @@ var UNIVERSE_COMPONENTS = {
18286
19114
  applyFormulaColumns,
18287
19115
  applyRelationCopy,
18288
19116
  buildColumnOptions,
19117
+ buildIfConditionExpression,
19118
+ buildIfExpression,
18289
19119
  buildRelationCopyPatch,
18290
19120
  buildRelationRef,
18291
19121
  calculateMinColumnWidth,
@@ -18295,11 +19125,14 @@ var UNIVERSE_COMPONENTS = {
18295
19125
  columnRefLabel,
18296
19126
  computeFormulaValue,
18297
19127
  describePerRecordFormula,
19128
+ describeRefFilter,
18298
19129
  enrichRowsWithRelations,
18299
19130
  evaluateFormula,
18300
19131
  extractFormulaFields,
18301
19132
  extractUniqueVariableIndices,
18302
19133
  extractVariableIndices,
19134
+ filterKindOfType,
19135
+ filterSignature,
18303
19136
  findVariableAtPosition,
18304
19137
  formatConflictCellValue,
18305
19138
  formatFileSize,
@@ -18307,10 +19140,13 @@ var UNIVERSE_COMPONENTS = {
18307
19140
  formatTimeInput,
18308
19141
  formatTimeIso,
18309
19142
  generateWhatsAppLink,
19143
+ getBooleanButtonLabels,
18310
19144
  getColumnDefaultFilter,
18311
19145
  getDefaultFilterColumns,
18312
19146
  getDeterministicPastelBadge,
18313
19147
  getEligibleCopyTargets,
19148
+ getFilterOps,
19149
+ getIfConditionOps,
18314
19150
  getNextVariableIndex,
18315
19151
  getRelationButtonColumns,
18316
19152
  getRelationCopyLockedTargets,
@@ -18322,6 +19158,7 @@ var UNIVERSE_COMPONENTS = {
18322
19158
  hasConsecutiveVariables,
18323
19159
  hasFloatingVariables,
18324
19160
  hasInsufficientContextBetweenVariables,
19161
+ isBooleanButtonsColumn,
18325
19162
  isDuplicateTemplate,
18326
19163
  isDuplicateTemplateName,
18327
19164
  isPerRecordSourceColumn,
@@ -18335,6 +19172,7 @@ var UNIVERSE_COMPONENTS = {
18335
19172
  isValidTemplateName,
18336
19173
  isWordToken,
18337
19174
  makeCellRefKey,
19175
+ matchesRefFilter,
18338
19176
  measureTextWidth,
18339
19177
  missingPaymentReportsFields,
18340
19178
  normalizePerRecordFormula,
@@ -18354,6 +19192,7 @@ var UNIVERSE_COMPONENTS = {
18354
19192
  resolveUniverseTheme,
18355
19193
  sanitizeDefaultFilter,
18356
19194
  sanitizePhoneNumber,
19195
+ sanitizeRefFilter,
18357
19196
  sanitizeTemplateNameInput,
18358
19197
  seamlessVariableEngine,
18359
19198
  splitHeaderTitle,