@burdenoff/microfe-bigconsole 2026.1116.1 → 2026.1117.2

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.
@@ -0,0 +1,101 @@
1
+ import { AssistantFocusInput } from '@burdenoff/fe-libs/shared/assistant/askAbout/focus';
2
+ /** One side's mapping as the dialog edits it. */
3
+ export interface SideDraft {
4
+ widgetId: string;
5
+ title: string;
6
+ keyField: string;
7
+ amountField: string;
8
+ dateField: string;
9
+ currency: string;
10
+ refundEvidenceField: string;
11
+ recordsPath: string;
12
+ /**
13
+ * True once this side's mapping is no longer new: suggestions were applied
14
+ * once, or it was restored from the viewer's saved mapping. A settled side is
15
+ * never re-guessed, so an explicit "None" (empty refund evidence) survives a
16
+ * reopen or a swap instead of being replaced by a suggested field.
17
+ */
18
+ mappingSettled: boolean;
19
+ }
20
+ export interface ReconcileDraft {
21
+ left: SideDraft;
22
+ right: SideDraft;
23
+ /** YYYY-MM */
24
+ month: string;
25
+ timezone: string;
26
+ /** 0 turns the cutoff rule off. */
27
+ cutoffWindowDays: number;
28
+ }
29
+ export interface FieldInfo {
30
+ name: string;
31
+ kind: 'NUMBER' | 'STRING' | 'DATE' | 'BOOLEAN' | 'MIXED';
32
+ restricted: boolean;
33
+ }
34
+ /** The GraphQL input, shaped like `BigConsoleKpiReconciliationInput`. */
35
+ export interface ReconcileInputVars {
36
+ left: SideInputVars;
37
+ right: SideInputVars;
38
+ periodStart: string;
39
+ periodEnd: string;
40
+ timezone: string;
41
+ cutoffWindowDays: number;
42
+ }
43
+ export interface SideInputVars {
44
+ widgetId: string;
45
+ keyField: string;
46
+ amountField: string;
47
+ dateField: string;
48
+ currency: string;
49
+ refundEvidenceField: string | null;
50
+ recordsPath: string | null;
51
+ }
52
+ /**
53
+ * Whether a card offers Reconcile. The API returns a metric card as the
54
+ * federated `KPI` type, which maps back to `kpi_card_comparison` unless the
55
+ * builder stored `_internalWidgetType`, so both are offered; the server refuses
56
+ * a genuine multi-KPI card with a reason the dialog shows (NOT_ADDITIVE).
57
+ */
58
+ export declare function canReconcileWidget(type: string, previewOnly: boolean): boolean;
59
+ /** First and last calendar day of a YYYY-MM month, or null when it is not one. */
60
+ export declare function monthPeriod(month: string): {
61
+ start: string;
62
+ end: string;
63
+ } | null;
64
+ /** The month before `now`, as YYYY-MM: the usual month to reconcile. */
65
+ export declare function previousMonth(now: Date): string;
66
+ export declare function browserTimezone(): string;
67
+ /** A card's configured prefix, read as a currency when it is a known symbol or code. */
68
+ export declare function currencyFromConfig(config: Record<string, unknown> | null | undefined): string;
69
+ /** Best-guess mapping from a card's field names. The viewer confirms or changes it. */
70
+ export declare function guessMapping(fields: FieldInfo[]): Pick<SideDraft, 'keyField' | 'amountField' | 'dateField' | 'refundEvidenceField'>;
71
+ /**
72
+ * Fill a NEW side's blank fields with suggestions, once. Returns null when
73
+ * there is nothing to do: the side is settled (restored or already suggested,
74
+ * including a confirmed "None"), or no fields are known yet.
75
+ */
76
+ export declare function applySuggestions(side: SideDraft, fields: FieldInfo[]): SideDraft | null;
77
+ /** A side restored from the viewer's saved mapping: settled, so "None" stays "None". */
78
+ export declare function restoreSavedSide(saved: SavedSide, title: string): SideDraft;
79
+ /** What is still missing before the comparison can run, or null when it is ready. */
80
+ export declare function missingForRun(draft: ReconcileDraft): string | null;
81
+ export declare function buildInput(draft: ReconcileDraft): ReconcileInputVars | null;
82
+ /** Swap the subtraction direction. */
83
+ export declare function swapSides(draft: ReconcileDraft): ReconcileDraft;
84
+ type SavedSide = Omit<SideDraft, 'title' | 'mappingSettled'>;
85
+ /** Remember the mapping the viewer confirmed for this pair of cards. */
86
+ export declare function saveDraft(draft: ReconcileDraft, storage: Pick<Storage, 'setItem'> | null): void;
87
+ /** The saved mapping for a side of this pair, if the viewer confirmed one before. */
88
+ export declare function loadSavedSide(widgetId: string, otherWidgetId: string, storage: Pick<Storage, 'getItem'> | null): {
89
+ side: SavedSide;
90
+ cutoffWindowDays: number;
91
+ } | null;
92
+ /**
93
+ * The note the assistant receives. It names the comparison and gives the exact
94
+ * input to pass to `reconcileKpiCards`, so the assistant reads the same server
95
+ * result as the dashboard instead of recomputing anything.
96
+ */
97
+ export declare function assistantFocus(input: ReconcileInputVars, labels: {
98
+ left: string;
99
+ right: string;
100
+ }, gapDisplay: string | null): AssistantFocusInput;
101
+ export {};
@@ -0,0 +1,222 @@
1
+ // src/bigconsole/components/reconcile/reconcileModel.ts
2
+ function e(e, t) {
3
+ return !t && (e === "metric_card" || e === "kpi_card_comparison");
4
+ }
5
+ var t = /^(\d{4})-(0[1-9]|1[0-2])$/;
6
+ function n(e) {
7
+ let n = t.exec(e);
8
+ if (!n) return null;
9
+ let r = Number(n[1]), i = Number(n[2]), a = new Date(Date.UTC(r, i, 0)).getUTCDate();
10
+ return {
11
+ start: `${n[1]}-${n[2]}-01`,
12
+ end: `${n[1]}-${n[2]}-${String(a).padStart(2, "0")}`
13
+ };
14
+ }
15
+ function r(e) {
16
+ let t = new Date(Date.UTC(e.getUTCFullYear(), e.getUTCMonth() - 1, 1));
17
+ return `${t.getUTCFullYear()}-${String(t.getUTCMonth() + 1).padStart(2, "0")}`;
18
+ }
19
+ function i() {
20
+ try {
21
+ return Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
22
+ } catch {
23
+ return "UTC";
24
+ }
25
+ }
26
+ function a(e) {
27
+ let t = typeof e?.prefix == "string" ? e.prefix.trim() : "", n = {
28
+ "₹": "INR",
29
+ $: "USD",
30
+ "€": "EUR",
31
+ "£": "GBP",
32
+ "¥": "JPY"
33
+ };
34
+ return n[t] ? n[t] : /^[A-Za-z]{3}$/.test(t) ? t.toUpperCase() : "";
35
+ }
36
+ var o = [
37
+ "orderid",
38
+ "orderno",
39
+ "ordernumber",
40
+ "invoiceid",
41
+ "invoiceno",
42
+ "id",
43
+ "key",
44
+ "reference",
45
+ "ref"
46
+ ], s = [
47
+ "amount",
48
+ "netamount",
49
+ "revenue",
50
+ "total",
51
+ "value",
52
+ "sales",
53
+ "gross"
54
+ ], c = [
55
+ "postingdate",
56
+ "orderdate",
57
+ "date",
58
+ "createdat",
59
+ "bookedat",
60
+ "timestamp"
61
+ ], l = [
62
+ "refundamount",
63
+ "refund",
64
+ "linkedrefund",
65
+ "refunded"
66
+ ];
67
+ function u(e, t) {
68
+ let n = e.toLowerCase().replace(/[^a-z0-9]/g, ""), r = n.split(".").pop() ?? n, i = t.indexOf(r);
69
+ if (i >= 0) return i;
70
+ let a = t.findIndex((e) => r.includes(e));
71
+ return a >= 0 ? t.length + a : Infinity;
72
+ }
73
+ function d(e, t, n) {
74
+ return e.filter((e) => !e.restricted && n.includes(e.kind)).map((e) => ({
75
+ f: e,
76
+ r: u(e.name, t)
77
+ })).filter((e) => Number.isFinite(e.r)).sort((e, t) => e.r - t.r || e.f.name.localeCompare(t.f.name))[0]?.f.name ?? "";
78
+ }
79
+ function f(e) {
80
+ return {
81
+ keyField: d(e, o, [
82
+ "STRING",
83
+ "NUMBER",
84
+ "MIXED"
85
+ ]),
86
+ amountField: d(e, s, ["NUMBER", "MIXED"]),
87
+ dateField: d(e, c, [
88
+ "DATE",
89
+ "STRING",
90
+ "NUMBER"
91
+ ]),
92
+ refundEvidenceField: d(e, l, ["NUMBER", "MIXED"])
93
+ };
94
+ }
95
+ function p(e, t) {
96
+ if (e.mappingSettled || t.length === 0) return null;
97
+ let n = f(t);
98
+ return {
99
+ ...e,
100
+ keyField: e.keyField || n.keyField,
101
+ amountField: e.amountField || n.amountField,
102
+ dateField: e.dateField || n.dateField,
103
+ refundEvidenceField: e.refundEvidenceField || n.refundEvidenceField,
104
+ mappingSettled: !0
105
+ };
106
+ }
107
+ function m(e, t) {
108
+ return {
109
+ ...e,
110
+ title: t,
111
+ mappingSettled: !0
112
+ };
113
+ }
114
+ function h(e) {
115
+ if (!e.left.widgetId || !e.right.widgetId) return "Choose a card to compare with.";
116
+ if (e.left.widgetId === e.right.widgetId) return "Choose two different cards.";
117
+ if (!n(e.month)) return "Choose a month.";
118
+ for (let t of [e.left, e.right]) {
119
+ if (!t.keyField || !t.amountField || !t.dateField) return `Confirm the key, amount and date fields for “${t.title}”.`;
120
+ if (!/^[A-Za-z]{3}$/.test(t.currency.trim())) return `Enter the currency of “${t.title}”, e.g. INR.`;
121
+ }
122
+ return null;
123
+ }
124
+ function g(e) {
125
+ return {
126
+ widgetId: e.widgetId,
127
+ keyField: e.keyField.trim(),
128
+ amountField: e.amountField.trim(),
129
+ dateField: e.dateField.trim(),
130
+ currency: e.currency.trim().toUpperCase(),
131
+ refundEvidenceField: e.refundEvidenceField.trim() || null,
132
+ recordsPath: e.recordsPath.trim() || null
133
+ };
134
+ }
135
+ function _(e) {
136
+ let t = n(e.month);
137
+ return !t || h(e) ? null : {
138
+ left: g(e.left),
139
+ right: g(e.right),
140
+ periodStart: t.start,
141
+ periodEnd: t.end,
142
+ timezone: e.timezone,
143
+ cutoffWindowDays: Math.max(0, Math.min(31, Math.floor(e.cutoffWindowDays) || 0))
144
+ };
145
+ }
146
+ function v(e) {
147
+ return {
148
+ ...e,
149
+ left: e.right,
150
+ right: e.left
151
+ };
152
+ }
153
+ var y = "bc-reconcile-v1:";
154
+ function b(e, t) {
155
+ return y + [e, t].sort((e, t) => e.localeCompare(t)).join("|");
156
+ }
157
+ function x(e, t) {
158
+ if (!t || !e.left.widgetId || !e.right.widgetId) return;
159
+ let n = ({ title: e, mappingSettled: t, ...n }) => n;
160
+ try {
161
+ t.setItem(b(e.left.widgetId, e.right.widgetId), JSON.stringify({
162
+ sides: [n(e.left), n(e.right)],
163
+ cutoffWindowDays: e.cutoffWindowDays
164
+ }));
165
+ } catch {}
166
+ }
167
+ function S(e, t, n) {
168
+ if (!n) return null;
169
+ try {
170
+ let r = n.getItem(b(e, t));
171
+ if (!r) return null;
172
+ let i = JSON.parse(r), a = i.sides?.find((t) => t.widgetId === e);
173
+ return a ? {
174
+ side: a,
175
+ cutoffWindowDays: Number(i.cutoffWindowDays) || 0
176
+ } : null;
177
+ } catch {
178
+ return null;
179
+ }
180
+ }
181
+ function C(e) {
182
+ return JSON.stringify(e);
183
+ }
184
+ function w(e, t, n) {
185
+ return {
186
+ kind: "KPI reconciliation",
187
+ label: `${t.left} − ${t.right}`,
188
+ facts: [
189
+ {
190
+ label: "How to answer",
191
+ value: "Run the read-only BigConsole query reconcileKpiCards(input) with exactly the input below. Answer only from its explanation, groups, limitations and problems; use kpiReconciliationItems(input, group) for orders. Never compute amounts or causes yourself."
192
+ },
193
+ {
194
+ label: "input.left",
195
+ value: C(e.left)
196
+ },
197
+ {
198
+ label: "input.right",
199
+ value: C(e.right)
200
+ },
201
+ {
202
+ label: "input.period",
203
+ value: JSON.stringify({
204
+ periodStart: e.periodStart,
205
+ periodEnd: e.periodEnd,
206
+ timezone: e.timezone,
207
+ cutoffWindowDays: e.cutoffWindowDays
208
+ })
209
+ },
210
+ ...n ? [{
211
+ label: "Gap shown on screen",
212
+ value: n
213
+ }] : []
214
+ ],
215
+ suggestions: [
216
+ "Why do these two cards differ?",
217
+ "Which orders are still unexplained?",
218
+ "Which differences have supporting evidence?"
219
+ ]
220
+ };
221
+ }
222
+ export { p as applySuggestions, w as assistantFocus, i as browserTimezone, _ as buildInput, e as canReconcileWidget, a as currencyFromConfig, f as guessMapping, S as loadSavedSide, h as missingForRun, n as monthPeriod, r as previousMonth, m as restoreSavedSide, x as saveDraft, v as swapSides };
@@ -43,6 +43,8 @@ export interface WidgetHeaderProps {
43
43
  onExplain?: () => void;
44
44
  /** Whether the narrative panel is currently open */
45
45
  explainOpen?: boolean;
46
+ /** Open the Reconcile dialog for this KPI card (BOFF-14093) */
47
+ onReconcile?: () => void;
46
48
  }
47
49
  export declare const WidgetHeader: FC<WidgetHeaderProps>;
48
50
  export default WidgetHeader;
@@ -3,7 +3,7 @@ import { memo as t } from "react";
3
3
  import { MessageSquare as n, Sparkles as r } from "lucide-react";
4
4
  import { jsx as i, jsxs as a } from "react/jsx-runtime";
5
5
  // src/bigconsole/components/widgets/WidgetHeader.tsx
6
- var o = t(function({ previewOnly: t = !1, widget: o, definition: c, isSelected: l, isEditMode: u, isLoading: d, isSampleData: f, timeUntilRefresh: p, hasDrilldown: m, onRefresh: h, onExportCSV: g, onExportPNG: _, onSpotOutliers: v, onDrilldown: y, onToggleComments: b, commentsOpen: x, commentCount: S = 0, onExplain: C, explainOpen: w }) {
6
+ var o = t(function({ previewOnly: t = !1, widget: o, definition: c, isSelected: l, isEditMode: u, isLoading: d, isSampleData: f, timeUntilRefresh: p, hasDrilldown: m, onRefresh: h, onExportCSV: g, onExportPNG: _, onSpotOutliers: v, onDrilldown: y, onToggleComments: b, commentsOpen: x, commentCount: S = 0, onExplain: C, explainOpen: w, onReconcile: T }) {
7
7
  return /* @__PURE__ */ a("div", {
8
8
  className: `
9
9
  flex min-w-0 items-center justify-between gap-1
@@ -151,7 +151,8 @@ var o = t(function({ previewOnly: t = !1, widget: o, definition: c, isSelected:
151
151
  onRefresh: h,
152
152
  onExportCSV: g,
153
153
  onExportPNG: _,
154
- onSpotOutliers: v
154
+ onSpotOutliers: v,
155
+ onReconcile: u ? void 0 : T
155
156
  })
156
157
  })
157
158
  ]
@@ -13,6 +13,8 @@ export interface WidgetMenuProps {
13
13
  onExportPNG?: () => void;
14
14
  /** Callback to open the read-only outlier analysis panel (BOFF-5759) */
15
15
  onSpotOutliers?: () => void;
16
+ /** Reconcile this KPI card with another card (BOFF-14093). Omitted for cards that cannot be reconciled. */
17
+ onReconcile?: () => void;
16
18
  }
17
19
  export declare const WidgetMenu: FC<WidgetMenuProps>;
18
20
  export default WidgetMenu;
@@ -8,38 +8,38 @@ import { usePermissions as c } from "@burdenoff/fe-libs/shared/providers/shell";
8
8
  import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
9
9
  import { createPortal as f } from "react-dom";
10
10
  // src/bigconsole/components/widgets/WidgetMenu.tsx
11
- var p = r(function({ widget: r, isEditMode: p, onRefresh: m, onExportCSV: h, onExportPNG: g, onSpotOutliers: _ }) {
12
- let [v, y] = s(!1), [b, x] = s({
11
+ var p = r(function({ widget: r, isEditMode: p, onRefresh: m, onExportCSV: h, onExportPNG: g, onSpotOutliers: _, onReconcile: v }) {
12
+ let [y, b] = s(!1), [x, S] = s({
13
13
  top: 0,
14
14
  left: 0
15
- }), S = o(null), C = o(null), { hasPermission: w } = c(), T = w(n.WIDGET_UPDATE), E = w(n.WIDGET_CREATE), D = w(n.WIDGET_DELETE), O = e((e) => e.selectWidget), k = e((e) => e.copyWidget), A = e((e) => e.cutWidget), j = e((e) => e.removeWidget), M = e((e) => e.openConfigPanel), { duplicateWidget: N, deleteWidget: P, refreshWidgetData: F } = t(r.pageId, r.dashboardId, { skipFetch: !0 });
15
+ }), C = o(null), w = o(null), { hasPermission: T } = c(), E = T(n.WIDGET_UPDATE), D = T(n.WIDGET_CREATE), O = T(n.WIDGET_DELETE), k = e((e) => e.selectWidget), A = e((e) => e.copyWidget), j = e((e) => e.cutWidget), M = e((e) => e.removeWidget), N = e((e) => e.openConfigPanel), { duplicateWidget: P, deleteWidget: F, refreshWidgetData: I } = t(r.pageId, r.dashboardId, { skipFetch: !0 });
16
16
  a(() => {
17
17
  let e = (e) => {
18
- S.current && !S.current.contains(e.target) && C.current && !C.current.contains(e.target) && y(!1);
18
+ C.current && !C.current.contains(e.target) && w.current && !w.current.contains(e.target) && b(!1);
19
19
  };
20
- return v && document.addEventListener("mousedown", e), () => {
20
+ return y && document.addEventListener("mousedown", e), () => {
21
21
  document.removeEventListener("mousedown", e);
22
22
  };
23
- }, [v]), a(() => {
23
+ }, [y]), a(() => {
24
24
  let e = (e) => {
25
- e.key === "Escape" && (y(!1), C.current?.focus());
25
+ e.key === "Escape" && (b(!1), w.current?.focus());
26
26
  };
27
- return v && document.addEventListener("keydown", e), () => {
27
+ return y && document.addEventListener("keydown", e), () => {
28
28
  document.removeEventListener("keydown", e);
29
29
  };
30
- }, [v]);
31
- let I = i((e) => {
32
- e.stopPropagation(), y((e) => {
33
- if (!e && C.current) {
34
- let e = C.current.getBoundingClientRect(), t = e.bottom + 4, n = e.right - 160;
35
- n + 160 > window.innerWidth - 10 && (n = window.innerWidth - 160 - 10), n < 10 && (n = 10), t + 320 > window.innerHeight - 10 && (t = e.top - 320 - 4, t < 10 && (t = 10)), x({
30
+ }, [y]);
31
+ let L = i((e) => {
32
+ e.stopPropagation(), b((e) => {
33
+ if (!e && w.current) {
34
+ let e = w.current.getBoundingClientRect(), t = e.bottom + 4, n = e.right - 160;
35
+ n + 160 > window.innerWidth - 10 && (n = window.innerWidth - 160 - 10), n < 10 && (n = 10), t + 320 > window.innerHeight - 10 && (t = e.top - 320 - 4, t < 10 && (t = 10)), S({
36
36
  top: t + window.scrollY,
37
37
  left: n + window.scrollX
38
38
  });
39
39
  }
40
40
  return !e;
41
41
  });
42
- }, []), L = [
42
+ }, []), R = [
43
43
  {
44
44
  id: "edit",
45
45
  label: "Edit Widget",
@@ -56,10 +56,10 @@ var p = r(function({ widget: r, isEditMode: p, onRefresh: m, onExportCSV: h, onE
56
56
  })
57
57
  }),
58
58
  action: () => {
59
- O(r.id), M(), y(!1);
59
+ k(r.id), N(), b(!1);
60
60
  },
61
61
  disabled: !p,
62
- permitted: T
62
+ permitted: E
63
63
  },
64
64
  {
65
65
  id: "refresh",
@@ -77,7 +77,7 @@ var p = r(function({ widget: r, isEditMode: p, onRefresh: m, onExportCSV: h, onE
77
77
  })
78
78
  }),
79
79
  action: async () => {
80
- y(!1), m ? m() : await F(r.id);
80
+ b(!1), m ? m() : await I(r.id);
81
81
  },
82
82
  disabled: !1
83
83
  },
@@ -97,10 +97,29 @@ var p = r(function({ widget: r, isEditMode: p, onRefresh: m, onExportCSV: h, onE
97
97
  })
98
98
  }),
99
99
  action: () => {
100
- y(!1), _?.();
100
+ b(!1), _?.();
101
101
  },
102
102
  disabled: !_
103
103
  },
104
+ ...v ? [{
105
+ id: "reconcile",
106
+ label: "Reconcile",
107
+ icon: /* @__PURE__ */ u("svg", {
108
+ fill: "none",
109
+ stroke: "currentColor",
110
+ viewBox: "0 0 24 24",
111
+ className: "w-4 h-4",
112
+ children: /* @__PURE__ */ u("path", {
113
+ strokeLinecap: "round",
114
+ strokeLinejoin: "round",
115
+ strokeWidth: 2,
116
+ d: "M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4"
117
+ })
118
+ }),
119
+ action: () => {
120
+ b(!1), v();
121
+ }
122
+ }] : [],
104
123
  {
105
124
  id: "exportCSV",
106
125
  label: "Export CSV",
@@ -117,7 +136,7 @@ var p = r(function({ widget: r, isEditMode: p, onRefresh: m, onExportCSV: h, onE
117
136
  })
118
137
  }),
119
138
  action: () => {
120
- y(!1), h?.();
139
+ b(!1), h?.();
121
140
  },
122
141
  disabled: !h
123
142
  },
@@ -137,7 +156,7 @@ var p = r(function({ widget: r, isEditMode: p, onRefresh: m, onExportCSV: h, onE
137
156
  })
138
157
  }),
139
158
  action: () => {
140
- y(!1), g?.();
159
+ b(!1), g?.();
141
160
  },
142
161
  disabled: !g
143
162
  },
@@ -164,10 +183,10 @@ var p = r(function({ widget: r, isEditMode: p, onRefresh: m, onExportCSV: h, onE
164
183
  })
165
184
  }),
166
185
  action: () => {
167
- k(r.id), y(!1);
186
+ A(r.id), b(!1);
168
187
  },
169
188
  disabled: !p,
170
- permitted: E
189
+ permitted: D
171
190
  },
172
191
  {
173
192
  id: "cut",
@@ -185,10 +204,10 @@ var p = r(function({ widget: r, isEditMode: p, onRefresh: m, onExportCSV: h, onE
185
204
  })
186
205
  }),
187
206
  action: () => {
188
- A(r.id), y(!1);
207
+ j(r.id), b(!1);
189
208
  },
190
209
  disabled: !p,
191
- permitted: E && T
210
+ permitted: D && E
192
211
  },
193
212
  {
194
213
  id: "duplicate",
@@ -206,17 +225,17 @@ var p = r(function({ widget: r, isEditMode: p, onRefresh: m, onExportCSV: h, onE
206
225
  })
207
226
  }),
208
227
  action: async () => {
209
- y(!1);
228
+ b(!1);
210
229
  let e = {
211
230
  x: (r.positionX ?? 0) + 1,
212
231
  y: (r.positionY ?? 0) + 1,
213
232
  width: r.positionWidth ?? 4,
214
233
  height: r.positionHeight ?? 4
215
234
  };
216
- await N(r.id, e, `${r.title} (Copy)`);
235
+ await P(r.id, e, `${r.title} (Copy)`);
217
236
  },
218
237
  disabled: !p,
219
- permitted: E
238
+ permitted: D
220
239
  },
221
240
  {
222
241
  id: "divider2",
@@ -241,34 +260,34 @@ var p = r(function({ widget: r, isEditMode: p, onRefresh: m, onExportCSV: h, onE
241
260
  })
242
261
  }),
243
262
  action: async () => {
244
- window.confirm("Are you sure you want to delete this widget?") ? (y(!1), await P(r.id) || j(r.id)) : y(!1);
263
+ window.confirm("Are you sure you want to delete this widget?") ? (b(!1), await F(r.id) || M(r.id)) : b(!1);
245
264
  },
246
265
  disabled: !p,
247
266
  destructive: !0,
248
- permitted: D
267
+ permitted: O
249
268
  }
250
- ].filter((e) => e.permitted !== !1), R = L.filter((e, t) => {
269
+ ].filter((e) => e.permitted !== !1), z = R.filter((e, t) => {
251
270
  if (!e.divider) return !0;
252
- let n = L[t - 1], r = L[t + 1];
271
+ let n = R[t - 1], r = R[t + 1];
253
272
  return n !== void 0 && r !== void 0 && !n.divider && !r.divider;
254
273
  });
255
274
  return /* @__PURE__ */ d("div", {
256
275
  className: "relative",
257
276
  children: [/* @__PURE__ */ u("button", {
258
- ref: C,
277
+ ref: w,
259
278
  type: "button",
260
- onClick: I,
279
+ onClick: L,
261
280
  className: `
262
281
  p-1.5 rounded-md
263
282
  text-text-secondary
264
283
  hover:text-text-primary
265
284
  hover:bg-bg-sunken
266
285
  transition-colors
267
- ${v ? "bg-bg-sunken" : ""}
286
+ ${y ? "bg-bg-sunken" : ""}
268
287
  `,
269
288
  title: "Widget options",
270
289
  "aria-haspopup": "menu",
271
- "aria-expanded": v,
290
+ "aria-expanded": y,
272
291
  children: /* @__PURE__ */ d("svg", {
273
292
  className: "w-4 h-4",
274
293
  fill: "currentColor",
@@ -291,18 +310,18 @@ var p = r(function({ widget: r, isEditMode: p, onRefresh: m, onExportCSV: h, onE
291
310
  })
292
311
  ]
293
312
  })
294
- }), v && f(/* @__PURE__ */ u("div", {
295
- ref: S,
313
+ }), y && f(/* @__PURE__ */ u("div", {
314
+ ref: C,
296
315
  style: {
297
316
  position: "fixed",
298
- top: b.top,
299
- left: b.left,
317
+ top: x.top,
318
+ left: x.left,
300
319
  zIndex: 99999
301
320
  },
302
321
  className: "\n min-w-[160px]\n py-1\n bg-bg-surface\n border border-border-default\n rounded-lg shadow-lg\n ",
303
322
  role: "menu",
304
323
  "aria-orientation": "vertical",
305
- children: R.map((e) => e.divider ? /* @__PURE__ */ u("div", { className: "my-1 border-t border-border-default" }, e.id) : /* @__PURE__ */ d("button", {
324
+ children: z.map((e) => e.divider ? /* @__PURE__ */ u("div", { className: "my-1 border-t border-border-default" }, e.id) : /* @__PURE__ */ d("button", {
306
325
  type: "button",
307
326
  onClick: (t) => {
308
327
  t.stopPropagation(), e.action();