@oneclick.dev/cms-core-modules 0.0.124 → 0.0.125
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/AppointmentListTable-CWzbwqR-.js +1 -0
- package/dist/AppointmentListTable-DoZuBstk.mjs +270 -0
- package/dist/ContentEditor-BlNbqkAz.js +324 -0
- package/dist/{ContentEditor-DX1bTQKs.mjs → ContentEditor-D754iLJS.mjs} +8074 -27026
- package/dist/{Detail-B7pe808q.mjs → Detail-BOxWQ1QQ.mjs} +2 -2
- package/dist/{Detail-B_Q7Qkuz.mjs → Detail-BfKW0uZE.mjs} +2 -2
- package/dist/Detail-DFVu2F38.mjs +11 -0
- package/dist/{Detail-t3tOcy3X.js → Detail-DJea_fCd.js} +1 -1
- package/dist/{Detail-CNiLIEh9.js → Detail-DPJacXfm.js} +1 -1
- package/dist/Detail-DSLZ7_bM.js +1 -0
- package/dist/{Detail-BESGmY7z.js → Detail-DUGThL9Y.js} +1 -1
- package/dist/{Detail-DNxAzeCs.mjs → Detail-D_LlEeHu.mjs} +2 -2
- package/dist/Overview-0hFXiuYo.js +1 -0
- package/dist/Overview-BTx5LF4J.js +1 -0
- package/dist/Overview-CCu2PHai.mjs +289 -0
- package/dist/Overview-D2u-leeO.js +1 -0
- package/dist/Overview-D_2wozCG.mjs +1733 -0
- package/dist/Overview-Dffo-zH4.mjs +11 -0
- package/dist/{TableCalculationWidget-CrqcLGfU.mjs → TableCalculationWidget-B_LFoOYm.mjs} +3 -3
- package/dist/{TableCalculationWidget-CkQPrVUd.js → TableCalculationWidget-CahOIcbk.js} +1 -1
- package/dist/TableDataWidget-BwqWFH4A.js +1 -0
- package/dist/TableDataWidget-RsVxcDsL.mjs +112 -0
- package/dist/TableOverviewCard-BPWCqo56.js +1 -0
- package/dist/{TableOverviewCard-Ci0d4o4w.mjs → TableOverviewCard-D667DDag.mjs} +113 -127
- package/dist/TableResultView.vue_vue_type_script_setup_true_lang-C3XiOXgb.js +1 -0
- package/dist/TableResultView.vue_vue_type_script_setup_true_lang-sp0TLio0.mjs +547 -0
- package/dist/{TableRowActionCard-BhdnnPaq.mjs → TableRowActionCard-BPYJ-Kjy.mjs} +95 -101
- package/dist/TableRowActionCard-Bnqj1YIe.js +1 -0
- package/dist/TableView-CwhZ9YN2.js +4 -0
- package/dist/TableView-DX9PKS8N.mjs +9673 -0
- package/dist/TemplateBuilder.vue_vue_type_script_setup_true_lang-BgDdzbLe.js +1 -0
- package/dist/TemplateBuilder.vue_vue_type_script_setup_true_lang-D85V4nrQ.mjs +2886 -0
- package/dist/cms-core-modules.css +1 -1
- package/dist/dateRangePresets-CaPVagHY.mjs +453 -0
- package/dist/dateRangePresets-gxQCiZ6c.js +1 -0
- package/dist/index-6hZ6MYY6.js +1 -0
- package/dist/index-BVmmicu3.mjs +14 -0
- package/dist/index-ChHD_1Cf.js +144 -0
- package/dist/index-CvV4nVWI.js +1 -0
- package/dist/index-DH2z0W_w.mjs +19012 -0
- package/dist/index-DZKzj48V.mjs +17 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.mjs +237 -103
- package/dist/orders-C_sz8J9b.js +1 -0
- package/dist/{orders-BfTLIm7U.mjs → orders-Cgdggzvx.mjs} +84 -84
- package/dist/server-handlers.cjs.js +1 -1
- package/dist/server-handlers.mjs +2055 -1123
- package/dist/src/appointments/chat-components/AppointmentListTable.vue.d.ts +3 -0
- package/dist/src/appointments/index.d.ts +93 -3
- package/dist/src/appointments/reservation-summary.d.ts +48 -0
- package/dist/src/appointments/server.d.ts +1 -0
- package/dist/src/appointments/tools.d.ts +93 -3
- package/dist/src/filezone/config.d.ts +31 -0
- package/dist/src/filezone/index.d.ts +43 -0
- package/dist/src/filezone/index.vue.d.ts +2 -0
- package/dist/src/filezone/metadata.d.ts +2 -0
- package/dist/src/filezone/pages/Overview.vue.d.ts +4 -0
- package/dist/src/filezone/permissions.d.ts +5 -0
- package/dist/src/filezone/routes.d.ts +5 -0
- package/dist/src/filezone/server.d.ts +36 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/mailTemplates/builder-types.d.ts +40 -0
- package/dist/src/mailTemplates/components/BlockRenderer.vue.d.ts +24 -0
- package/dist/src/mailTemplates/components/DesignPanel.vue.d.ts +13 -0
- package/dist/src/mailTemplates/components/EmailCanvas.vue.d.ts +44 -0
- package/dist/src/mailTemplates/components/RichTextEditor.vue.d.ts +10 -0
- package/dist/src/mailTemplates/components/RightSidebar.vue.d.ts +18 -0
- package/dist/src/mailTemplates/components/SettingsPanel.vue.d.ts +15 -0
- package/dist/src/mailTemplates/components/TemplateBuilder.vue.d.ts +2 -0
- package/dist/src/mailTemplates/components/TemplateList.vue.d.ts +19 -1
- package/dist/src/mailTemplates/components/rich-text.d.ts +6 -0
- package/dist/src/mailTemplates/config.d.ts +10 -4
- package/dist/src/mailTemplates/defaults.d.ts +10 -0
- package/dist/src/mailTemplates/editor-state.d.ts +21 -0
- package/dist/src/mailTemplates/index.d.ts +11 -5
- package/dist/src/mailTemplates/index.vue.d.ts +2 -4
- package/dist/src/mailTemplates/metadata.d.ts +1 -1
- package/dist/src/mailTemplates/pages/Detail.vue.d.ts +1 -13
- package/dist/src/mailTemplates/pages/Overview.vue.d.ts +1 -13
- package/dist/src/mailTemplates/server.d.ts +23 -0
- package/dist/src/server-handlers.d.ts +4 -0
- package/dist/src/table/badge-filter-utils.d.ts +8 -0
- package/dist/src/table/chat-components/TableOverviewCard.vue.d.ts +2 -7
- package/dist/src/table/chat-components/TableResultView.vue.d.ts +3 -7
- package/dist/src/table/components/TableDisplayCell.vue.d.ts +8 -0
- package/dist/src/table/components/columns/BadgeColumnSettings.vue.d.ts +9 -0
- package/dist/src/table/components/columns/ColumnColorSelect.vue.d.ts +11 -0
- package/dist/src/table/components/columns/ColumnDisplaySettings.vue.d.ts +9 -0
- package/dist/src/table/components/columns/ColumnTypeSelect.vue.d.ts +11 -0
- package/dist/src/table/components/columns/ColumnValueSourceInput.vue.d.ts +15 -0
- package/dist/src/table/components/columns/DialogTableColumnItem.vue.d.ts +8 -11
- package/dist/src/table/components/columns/ProgressColumnSettings.vue.d.ts +8 -0
- package/dist/src/table/components/stats/StatDialog.vue.d.ts +6 -10
- package/dist/src/table/components/stats/Stats.vue.d.ts +9 -15
- package/dist/src/table/composables/useTableClock.d.ts +4 -0
- package/dist/src/table/display-utils.d.ts +35 -0
- package/dist/src/table/row-value.d.ts +1 -0
- package/dist/src/table/stat-utils.d.ts +9 -0
- package/dist/src/table/tool-utils.d.ts +1 -1
- package/dist/src/table/types.d.ts +54 -1
- package/dist/src/whatsappBusiness/analytics.d.ts +4 -0
- package/dist/src/whatsappBusiness/components/AccountPanel.vue.d.ts +2 -0
- package/dist/src/whatsappBusiness/components/InsightsPanel.vue.d.ts +5 -0
- package/dist/src/whatsappBusiness/components/TemplateDialog.vue.d.ts +14 -0
- package/dist/src/whatsappBusiness/components/TemplatesPanel.vue.d.ts +5 -0
- package/dist/src/whatsappBusiness/components/presentation.d.ts +4 -0
- package/dist/src/whatsappBusiness/config.d.ts +51 -0
- package/dist/src/whatsappBusiness/connection.d.ts +77 -0
- package/dist/src/whatsappBusiness/index.d.ts +63 -0
- package/dist/src/whatsappBusiness/index.vue.d.ts +5 -0
- package/dist/src/whatsappBusiness/metadata.d.ts +2 -0
- package/dist/src/whatsappBusiness/pages/Overview.vue.d.ts +2 -0
- package/dist/src/whatsappBusiness/permissions.d.ts +5 -0
- package/dist/src/whatsappBusiness/provider.d.ts +21 -0
- package/dist/src/whatsappBusiness/routes.d.ts +5 -0
- package/dist/src/whatsappBusiness/server.d.ts +14 -0
- package/dist/src/whatsappBusiness/templates.d.ts +94 -0
- package/dist/src/whatsappBusiness/types.d.ts +162 -0
- package/dist/{tool-sandbox-DoF1PsyS.js → tool-sandbox-BSkKdH7V.js} +1 -1
- package/dist/{tool-sandbox-DdkMLkDK.mjs → tool-sandbox-DU9b1B7v.mjs} +1 -1
- package/dist/{types-ibC3-e1N.mjs → types-B5MifmeF.mjs} +339 -273
- package/dist/types-D5dgTskW.js +1 -0
- package/dist/{useTableAgentTools-D5mzGf3A.js → useTableAgentTools-BrUot49I.js} +1 -1
- package/dist/{useTableAgentTools-DcN3kYRL.mjs → useTableAgentTools-r5InEI4p.mjs} +8 -8
- package/dist/{vee-validate-zod-BQElPD0m.js → vee-validate-zod-CWZwNTWE.js} +1 -1
- package/dist/{vee-validate-zod-CN16K2x9.mjs → vee-validate-zod-D0WaDgDZ.mjs} +1 -1
- package/package.json +2 -2
- package/src/appointments/tools.ts +52 -2
- package/dist/AppointmentListTable-DZJNmTMb.mjs +0 -177
- package/dist/AppointmentListTable-Dieu9US_.js +0 -1
- package/dist/ContentEditor-BcIUumah.js +0 -467
- package/dist/Detail-Byk781b4.mjs +0 -26
- package/dist/Detail-mvSGbnFU.js +0 -1
- package/dist/Overview-BDlBCUI_.js +0 -1
- package/dist/Overview-Su8ZUbMs.mjs +0 -26
- package/dist/TableDataWidget-7qvC3Egd.js +0 -1
- package/dist/TableDataWidget-DMTSoGRO.mjs +0 -121
- package/dist/TableOverviewCard-AFq-puJs.js +0 -1
- package/dist/TableResultView.vue_vue_type_script_setup_true_lang-CBn-Oxl9.mjs +0 -534
- package/dist/TableResultView.vue_vue_type_script_setup_true_lang-C_Lv-SmJ.js +0 -1
- package/dist/TableRowActionCard-IzB6tNN-.js +0 -1
- package/dist/TableView-6mdrL3zx.js +0 -4
- package/dist/TableView-Du5nOE6R.mjs +0 -8228
- package/dist/TemplateList.vue_vue_type_script_setup_true_lang-B_AtWnHa.js +0 -1
- package/dist/TemplateList.vue_vue_type_script_setup_true_lang-Cmovy7kk.mjs +0 -40
- package/dist/dateRangePresets-B-l5b_wR.mjs +0 -48
- package/dist/dateRangePresets-CPWqst_x.js +0 -1
- package/dist/orders-DUa2PVoa.js +0 -1
- package/dist/types-BMraG1kN.js +0 -1
|
@@ -1,534 +0,0 @@
|
|
|
1
|
-
import { defineComponent as ie, computed as _, openBlock as u, createElementBlock as f, createElementVNode as L, createVNode as A, unref as w, toDisplayString as b, createCommentVNode as N, Fragment as j, renderList as O, createTextVNode as I, normalizeClass as P, createBlock as F, renderSlot as oe } from "vue";
|
|
2
|
-
import { Table2 as q, Columns3 as se, Image as Y, ExternalLink as Z, Check as X, X as G } from "lucide-vue-next";
|
|
3
|
-
const V = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
4
|
-
function $(t, e) {
|
|
5
|
-
if (!t || !e) return;
|
|
6
|
-
const i = e.split(".");
|
|
7
|
-
if (!i.some((s) => V.has(s)))
|
|
8
|
-
return Object.prototype.hasOwnProperty.call(t, e) ? t[e] : i.reduce((s, l) => s?.[l], t);
|
|
9
|
-
}
|
|
10
|
-
function Q(t) {
|
|
11
|
-
return t.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_.-]+/g, " ").replace(/\s+/g, " ").trim().replace(/\b\w/g, (e) => e.toUpperCase());
|
|
12
|
-
}
|
|
13
|
-
function ae(t, e) {
|
|
14
|
-
const i = t.toLowerCase().replace(/[_.-]/g, "");
|
|
15
|
-
if (/email$/.test(i)) return "email";
|
|
16
|
-
if (/(phone|mobile|telephone|tel)$/.test(i)) return "phone";
|
|
17
|
-
if (/(image|photo|avatar|thumbnail|logo|picture)$/.test(i)) return "image";
|
|
18
|
-
if (/(url|link|website|href)$/.test(i)) return "URL";
|
|
19
|
-
if (/(price|amount|cost|total|revenue|salary|fee)$/.test(i)) return "currency";
|
|
20
|
-
if (/(createdat|updatedat|timestamp)$/.test(i)) return "datetime";
|
|
21
|
-
if (/date$/.test(i)) return "date";
|
|
22
|
-
const s = e.filter((l) => l != null && l !== "");
|
|
23
|
-
return s.length ? s.every((l) => typeof l == "boolean") ? "boolean" : s.every((l) => typeof l == "number") ? "number" : s.every((l) => Array.isArray(l)) ? "array" : s.every((l) => typeof l == "string" && /^\d{4}-\d{2}-\d{2}(?:T|$)/.test(l)) ? s.some((l) => String(l).includes("T")) ? "datetime" : "date" : "text" : "text";
|
|
24
|
-
}
|
|
25
|
-
function Ke(t) {
|
|
26
|
-
if (t == null) return [];
|
|
27
|
-
const e = Array.isArray(t) ? t : Array.isArray(t?.data) ? t.data : Array.isArray(t?.items) ? t.items : Array.isArray(t?.rows) ? t.rows : null;
|
|
28
|
-
if (!e)
|
|
29
|
-
throw new Error("The Fetch items flow must return an array of rows.");
|
|
30
|
-
return e.map((i) => i && typeof i == "object" && !Array.isArray(i) ? i : { value: i });
|
|
31
|
-
}
|
|
32
|
-
function Pe(t) {
|
|
33
|
-
return Array.isArray(t) ? t.filter((e) => e && typeof e.property == "string" && e.property.trim()).map((e, i) => ({
|
|
34
|
-
...e,
|
|
35
|
-
id: typeof e.id == "string" ? e.id : `column-${i}`,
|
|
36
|
-
property: e.property.trim(),
|
|
37
|
-
label: typeof e.label == "string" && e.label.trim() ? e.label.trim() : Q(e.property),
|
|
38
|
-
type: typeof e.type == "string" && e.type ? e.type : "text",
|
|
39
|
-
visible: e.visible !== !1
|
|
40
|
-
})) : [];
|
|
41
|
-
}
|
|
42
|
-
function ee(t, e, i, s) {
|
|
43
|
-
if (!(!t || typeof t != "object" || Array.isArray(t) || s >= 2))
|
|
44
|
-
for (const [l, p] of Object.entries(t)) {
|
|
45
|
-
if (V.has(l)) continue;
|
|
46
|
-
const c = e ? `${e}.${l}` : l;
|
|
47
|
-
p && typeof p == "object" && !Array.isArray(p) && !(p instanceof Date) ? ee(p, c, i, s + 1) : i.add(c);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function le(t) {
|
|
51
|
-
const e = /* @__PURE__ */ new Set();
|
|
52
|
-
for (const i of t.slice(0, 10)) ee(i, "", e, 0);
|
|
53
|
-
return Array.from(e).slice(0, 40).map((i, s) => ({
|
|
54
|
-
id: `inferred-${s}`,
|
|
55
|
-
property: i,
|
|
56
|
-
label: Q(i),
|
|
57
|
-
type: ae(i, t.map((l) => $(l, i))),
|
|
58
|
-
visible: !0
|
|
59
|
-
}));
|
|
60
|
-
}
|
|
61
|
-
function W(t, e) {
|
|
62
|
-
const i = String(t || "").trim().toLocaleLowerCase();
|
|
63
|
-
return i && (e.find((s) => s.property.toLocaleLowerCase() === i) || e.find((s) => String(s.label || "").trim().toLocaleLowerCase() === i) || e.find((s) => String(s.id || "").trim().toLocaleLowerCase() === i)) || null;
|
|
64
|
-
}
|
|
65
|
-
function S(t) {
|
|
66
|
-
return t == null || t === "" || Array.isArray(t) && t.length === 0;
|
|
67
|
-
}
|
|
68
|
-
function pe(t) {
|
|
69
|
-
return typeof t == "boolean" ? t : typeof t != "string" ? null : t.toLowerCase() === "true" ? !0 : t.toLowerCase() === "false" ? !1 : null;
|
|
70
|
-
}
|
|
71
|
-
function ue(t, e) {
|
|
72
|
-
if (typeof e == "number") {
|
|
73
|
-
const i = Number(t);
|
|
74
|
-
return Number.isFinite(i) ? i : t;
|
|
75
|
-
}
|
|
76
|
-
return typeof e == "boolean" ? pe(t) ?? t : t;
|
|
77
|
-
}
|
|
78
|
-
function E(t, e) {
|
|
79
|
-
const i = ue(e, t);
|
|
80
|
-
if (typeof t == "string" && typeof i == "string")
|
|
81
|
-
return t.toLocaleLowerCase() === i.toLocaleLowerCase();
|
|
82
|
-
if (t instanceof Date) {
|
|
83
|
-
const s = new Date(i);
|
|
84
|
-
return !Number.isNaN(s.getTime()) && t.getTime() === s.getTime();
|
|
85
|
-
}
|
|
86
|
-
return Object.is(t, i);
|
|
87
|
-
}
|
|
88
|
-
function C(t) {
|
|
89
|
-
if (t instanceof Date) return t.getTime();
|
|
90
|
-
if (typeof t == "number") return t;
|
|
91
|
-
if (typeof t == "boolean") return t ? 1 : 0;
|
|
92
|
-
if (typeof t == "string") {
|
|
93
|
-
const e = t.trim(), i = Number(e);
|
|
94
|
-
if (e && Number.isFinite(i)) return i;
|
|
95
|
-
if (/^\d{4}-\d{2}-\d{2}(?:T|$)/.test(e)) {
|
|
96
|
-
const s = new Date(e).getTime();
|
|
97
|
-
if (!Number.isNaN(s)) return s;
|
|
98
|
-
}
|
|
99
|
-
return e.toLocaleLowerCase();
|
|
100
|
-
}
|
|
101
|
-
return String(t ?? "").toLocaleLowerCase();
|
|
102
|
-
}
|
|
103
|
-
function ce(t, e, i) {
|
|
104
|
-
const l = W(e.property, i)?.property || e.property, p = $(t, l), c = e.operator || "==", a = Array.isArray(e.values) ? e.values : (c === "in" || c === "notIn") && typeof e.value == "string" ? e.value.split(",").map((m) => m.trim()) : [];
|
|
105
|
-
if ([">", ">=", "<", "<="].includes(c) && (S(p) || S(e.value)))
|
|
106
|
-
return !1;
|
|
107
|
-
switch (c) {
|
|
108
|
-
case "==":
|
|
109
|
-
case "equals":
|
|
110
|
-
return E(p, e.value);
|
|
111
|
-
case "!=":
|
|
112
|
-
case "not_equals":
|
|
113
|
-
return !E(p, e.value);
|
|
114
|
-
case ">":
|
|
115
|
-
return C(p) > C(e.value);
|
|
116
|
-
case ">=":
|
|
117
|
-
return C(p) >= C(e.value);
|
|
118
|
-
case "<":
|
|
119
|
-
return C(p) < C(e.value);
|
|
120
|
-
case "<=":
|
|
121
|
-
return C(p) <= C(e.value);
|
|
122
|
-
case "contains":
|
|
123
|
-
return Array.isArray(p) ? p.some((m) => E(m, e.value)) : String(p ?? "").toLocaleLowerCase().includes(String(e.value ?? "").toLocaleLowerCase());
|
|
124
|
-
case "startsWith":
|
|
125
|
-
return String(p ?? "").toLocaleLowerCase().startsWith(String(e.value ?? "").toLocaleLowerCase());
|
|
126
|
-
case "endsWith":
|
|
127
|
-
return String(p ?? "").toLocaleLowerCase().endsWith(String(e.value ?? "").toLocaleLowerCase());
|
|
128
|
-
case "in":
|
|
129
|
-
return a.some((m) => E(p, m));
|
|
130
|
-
case "notIn":
|
|
131
|
-
return !a.some((m) => E(p, m));
|
|
132
|
-
case "isEmpty":
|
|
133
|
-
return S(p);
|
|
134
|
-
case "isNotEmpty":
|
|
135
|
-
return !S(p);
|
|
136
|
-
default:
|
|
137
|
-
throw new Error(`Unsupported table filter operator "${c}".`);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
function qe(t, e, i = []) {
|
|
141
|
-
if (!Array.isArray(e) || !e.length) return [...t];
|
|
142
|
-
for (const s of e) {
|
|
143
|
-
if (!s || typeof s.property != "string" || !s.property.trim())
|
|
144
|
-
throw new Error("Every table filter needs a property.");
|
|
145
|
-
if (i.length && !W(s.property, i))
|
|
146
|
-
throw new Error(`Unknown table filter property "${s.property}". Use a property or label reported by inspectTable.`);
|
|
147
|
-
}
|
|
148
|
-
return t.filter((s) => e.every((l) => ce(s, l, i)));
|
|
149
|
-
}
|
|
150
|
-
function Ye(t, e, i = "asc", s = []) {
|
|
151
|
-
if (!e) return [...t];
|
|
152
|
-
const l = W(e, s);
|
|
153
|
-
if (s.length && !l)
|
|
154
|
-
throw new Error(`Unknown table sort property "${e}". Use a property or label reported by inspectTable.`);
|
|
155
|
-
const p = l?.property || e, c = i === "desc" ? -1 : 1;
|
|
156
|
-
return t.map((a, m) => ({ row: a, index: m })).sort((a, m) => {
|
|
157
|
-
const x = $(a.row, p), k = $(m.row, p);
|
|
158
|
-
if (S(x) && S(k)) return a.index - m.index;
|
|
159
|
-
if (S(x)) return 1;
|
|
160
|
-
if (S(k)) return -1;
|
|
161
|
-
const T = C(x), R = C(k);
|
|
162
|
-
return T < R ? -1 * c : T > R ? 1 * c : a.index - m.index;
|
|
163
|
-
}).map((a) => a.row);
|
|
164
|
-
}
|
|
165
|
-
function Ze(t, e, i, s) {
|
|
166
|
-
return t.filter((l) => {
|
|
167
|
-
const p = $(l, e);
|
|
168
|
-
if (p == null || p === "") return !1;
|
|
169
|
-
const a = (p instanceof Date ? p : typeof p == "string" && /^\d{4}-\d{2}-\d{2}$/.test(p) ? /* @__PURE__ */ new Date(`${p}T00:00:00.000`) : new Date(p)).getTime();
|
|
170
|
-
return !Number.isNaN(a) && a >= i.getTime() && a <= s.getTime();
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
function de(t) {
|
|
174
|
-
return t === null || ["string", "number", "boolean"].includes(typeof t);
|
|
175
|
-
}
|
|
176
|
-
function Xe(t, e, i = []) {
|
|
177
|
-
const s = ["id", "_id", "uuid", "key", "email", "slug"], l = i.length ? i : le(e), p = Array.from(/* @__PURE__ */ new Set([
|
|
178
|
-
...s,
|
|
179
|
-
...l.map((m) => m.property),
|
|
180
|
-
...Object.keys(t || {})
|
|
181
|
-
])).filter((m) => !V.has(m)), c = [];
|
|
182
|
-
let a = [...e];
|
|
183
|
-
for (const m of p) {
|
|
184
|
-
const x = $(t, m);
|
|
185
|
-
if (!de(x) || x === "") continue;
|
|
186
|
-
const k = a.filter((T) => E($(T, m), x));
|
|
187
|
-
if (k.length) {
|
|
188
|
-
if (a.length === 1) return [{ property: m, value: x }];
|
|
189
|
-
if (k.length !== a.length) {
|
|
190
|
-
if (c.push({ property: m, value: x }), a = k, a.length === 1) return c;
|
|
191
|
-
if (c.length >= 3) break;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
return a.length === 1 && c.length ? c : null;
|
|
196
|
-
}
|
|
197
|
-
function Ge(t, e = 512 * 1024) {
|
|
198
|
-
const i = /* @__PURE__ */ new WeakSet(), s = JSON.stringify(t, (p, c) => {
|
|
199
|
-
if (!V.has(p)) {
|
|
200
|
-
if (typeof c == "bigint") return String(c);
|
|
201
|
-
if (c instanceof Date) return c.toISOString();
|
|
202
|
-
if (c && typeof c == "object") {
|
|
203
|
-
if (i.has(c)) return "[Circular]";
|
|
204
|
-
i.add(c);
|
|
205
|
-
}
|
|
206
|
-
return c;
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
if (s === void 0) throw new Error("The table result is not JSON serializable.");
|
|
210
|
-
const l = new TextEncoder().encode(s).byteLength;
|
|
211
|
-
if (l > e)
|
|
212
|
-
throw new Error(`The table result is too large to store (${Math.ceil(l / 1024)} KB). Narrow the query or lower the row limit.`);
|
|
213
|
-
return JSON.parse(s);
|
|
214
|
-
}
|
|
215
|
-
const fe = { class: "w-full min-w-0 overflow-hidden rounded-xl border bg-background" }, ye = {
|
|
216
|
-
key: 0,
|
|
217
|
-
class: "flex items-start gap-2.5 border-b bg-muted/30 px-3 py-2.5"
|
|
218
|
-
}, me = { class: "mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-lg bg-primary/10" }, ge = { class: "min-w-0 flex-1" }, be = {
|
|
219
|
-
key: 0,
|
|
220
|
-
class: "truncate text-xs font-semibold"
|
|
221
|
-
}, he = {
|
|
222
|
-
key: 1,
|
|
223
|
-
class: "mt-0.5 text-[11px] leading-relaxed text-muted-foreground"
|
|
224
|
-
}, xe = {
|
|
225
|
-
key: 0,
|
|
226
|
-
class: "shrink-0 rounded-full bg-muted px-2 py-0.5 text-[10px] tabular-nums text-muted-foreground"
|
|
227
|
-
}, we = {
|
|
228
|
-
key: 1,
|
|
229
|
-
class: "flex flex-col items-center px-4 py-8 text-center"
|
|
230
|
-
}, ke = { class: "text-xs text-muted-foreground" }, ve = {
|
|
231
|
-
key: 2,
|
|
232
|
-
class: "flex flex-col items-center px-4 py-8 text-center"
|
|
233
|
-
}, _e = {
|
|
234
|
-
key: 3,
|
|
235
|
-
class: "grid gap-x-5 gap-y-3 p-3 sm:grid-cols-2"
|
|
236
|
-
}, Le = { class: "mb-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground" }, Ce = ["src", "alt"], Se = {
|
|
237
|
-
key: 1,
|
|
238
|
-
class: "flex size-16 items-center justify-center rounded-lg border bg-muted/30"
|
|
239
|
-
}, Ae = ["href"], Ne = ["href"], $e = ["href"], Te = ["title"], ze = {
|
|
240
|
-
key: 4,
|
|
241
|
-
class: "overflow-x-auto"
|
|
242
|
-
}, Ee = { class: "w-full min-w-max text-left text-xs" }, Re = { class: "border-b bg-muted/30" }, De = ["src", "alt"], Ue = {
|
|
243
|
-
key: 1,
|
|
244
|
-
class: "flex size-8 items-center justify-center rounded-md border bg-muted/30"
|
|
245
|
-
}, je = ["href"], Oe = { class: "truncate" }, Fe = ["href"], Ve = ["href"], Me = ["title"], Be = {
|
|
246
|
-
key: 5,
|
|
247
|
-
class: "flex flex-wrap items-center gap-x-3 gap-y-1 border-t bg-muted/20 px-3 py-2 text-[10px] text-muted-foreground"
|
|
248
|
-
}, Ie = { key: 0 }, We = { key: 1 }, Qe = /* @__PURE__ */ ie({
|
|
249
|
-
__name: "TableResultView",
|
|
250
|
-
props: {
|
|
251
|
-
rows: { default: () => [] },
|
|
252
|
-
columns: { default: () => [] },
|
|
253
|
-
title: { default: "" },
|
|
254
|
-
description: { default: "" },
|
|
255
|
-
totalCount: { default: void 0 },
|
|
256
|
-
emptyText: { default: "No matching rows found." },
|
|
257
|
-
maxRows: { default: 20 },
|
|
258
|
-
maxColumns: { default: 12 },
|
|
259
|
-
currency: { default: "EUR" },
|
|
260
|
-
view: { default: "auto" }
|
|
261
|
-
},
|
|
262
|
-
setup(t) {
|
|
263
|
-
const e = t, i = _(() => R(e.maxRows, 1, 100, 20)), s = _(() => R(e.maxColumns, 1, 20, 12)), l = _(
|
|
264
|
-
() => (Array.isArray(e.rows) ? e.rows : []).filter((r) => r != null).map((r) => typeof r == "object" && !Array.isArray(r) ? r : { value: r })
|
|
265
|
-
), p = _(() => {
|
|
266
|
-
const r = Array.isArray(e.columns) ? e.columns : [], y = r.filter((o) => o && o.visible !== !1 && (o.property || o.key)).map((o, g) => {
|
|
267
|
-
const D = String(o.property || o.key);
|
|
268
|
-
return {
|
|
269
|
-
id: String(o.id || D || g),
|
|
270
|
-
property: D,
|
|
271
|
-
label: o.label || J(D),
|
|
272
|
-
type: o.type || H(D, l.value.map((ne) => d(ne, D)))
|
|
273
|
-
};
|
|
274
|
-
});
|
|
275
|
-
if (r.length > 0) return te(y);
|
|
276
|
-
const n = [], h = /* @__PURE__ */ new Set();
|
|
277
|
-
for (const o of l.value.slice(0, 10))
|
|
278
|
-
for (const g of Object.keys(o))
|
|
279
|
-
h.has(g) || (h.add(g), n.push(g));
|
|
280
|
-
return n.map((o) => ({
|
|
281
|
-
id: o,
|
|
282
|
-
property: o,
|
|
283
|
-
label: J(o),
|
|
284
|
-
type: H(o, l.value.map((g) => d(g, o)))
|
|
285
|
-
}));
|
|
286
|
-
}), c = _(() => p.value.slice(0, s.value)), a = _(() => l.value.slice(0, i.value)), m = _(() => Math.max(p.value.length - c.value.length, 0)), x = _(() => {
|
|
287
|
-
const r = Number(e.totalCount);
|
|
288
|
-
return Number.isFinite(r) && r >= l.value.length ? r : l.value.length;
|
|
289
|
-
}), k = _(() => Math.max(x.value - a.value.length, 0)), T = _(() => a.value.length === 1 && (e.view === "card" || e.view === "metric" || e.view === "auto" && x.value === 1));
|
|
290
|
-
function R(r, y, n, h) {
|
|
291
|
-
const o = Number(r);
|
|
292
|
-
return Number.isFinite(o) ? Math.min(Math.max(Math.floor(o), y), n) : h;
|
|
293
|
-
}
|
|
294
|
-
function te(r) {
|
|
295
|
-
const y = /* @__PURE__ */ new Set();
|
|
296
|
-
return r.filter((n) => y.has(n.property) ? !1 : (y.add(n.property), !0));
|
|
297
|
-
}
|
|
298
|
-
function d(r, y) {
|
|
299
|
-
const n = y.split(".");
|
|
300
|
-
if (!n.some((h) => ["__proto__", "constructor", "prototype"].includes(h)))
|
|
301
|
-
return Object.prototype.hasOwnProperty.call(r, y) ? r[y] : n.reduce((h, o) => h?.[o], r);
|
|
302
|
-
}
|
|
303
|
-
function J(r) {
|
|
304
|
-
return r.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_.-]+/g, " ").replace(/\s+/g, " ").trim().replace(/\b\w/g, (y) => y.toUpperCase());
|
|
305
|
-
}
|
|
306
|
-
function H(r, y) {
|
|
307
|
-
const h = r.toLowerCase().replace(/[_.-]/g, "");
|
|
308
|
-
if (/(image|photo|avatar|thumbnail|logo|picture)$/.test(h)) return "image";
|
|
309
|
-
if (/(email)$/.test(h)) return "email";
|
|
310
|
-
if (/(phone|mobile|telephone|tel)$/.test(h)) return "phone";
|
|
311
|
-
if (/(url|link|website|href)$/.test(h)) return "URL";
|
|
312
|
-
if (/(price|amount|cost|total|revenue|salary|fee)$/.test(h)) return "currency";
|
|
313
|
-
if (/(date|createdat|updatedat|timestamp)$/.test(h)) return "datetime";
|
|
314
|
-
const o = y.filter((g) => g != null && g !== "");
|
|
315
|
-
return o.length === 0 ? "text" : o.every((g) => typeof g == "boolean") ? "boolean" : o.every((g) => Array.isArray(g)) ? "array" : o.every((g) => typeof g == "number") ? "number" : o.every((g) => typeof g == "string" && /^https?:\/\//i.test(g)) ? "URL" : o.every((g) => typeof g == "string" && /^\d{4}-\d{2}-\d{2}(?:T|$)/.test(g)) ? o.some((g) => String(g).includes("T")) ? "datetime" : "date" : "text";
|
|
316
|
-
}
|
|
317
|
-
function z(r) {
|
|
318
|
-
return r == null || r === "";
|
|
319
|
-
}
|
|
320
|
-
function M(r) {
|
|
321
|
-
if (typeof r != "string") return !1;
|
|
322
|
-
try {
|
|
323
|
-
const y = new URL(r, typeof window > "u" ? "https://localhost" : window.location.origin);
|
|
324
|
-
return y.protocol === "http:" || y.protocol === "https:";
|
|
325
|
-
} catch {
|
|
326
|
-
return !1;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
function K(r) {
|
|
330
|
-
return M(r) || typeof r == "string" && /^data:image\/(?:png|jpe?g|gif|webp|avif);base64,/i.test(r);
|
|
331
|
-
}
|
|
332
|
-
function v(r, y) {
|
|
333
|
-
if (z(r)) return "—";
|
|
334
|
-
switch (y.type) {
|
|
335
|
-
case "boolean":
|
|
336
|
-
return r ? "Yes" : "No";
|
|
337
|
-
case "number": {
|
|
338
|
-
const n = Number(r);
|
|
339
|
-
return Number.isFinite(n) ? n.toLocaleString(void 0, { maximumFractionDigits: 2 }) : String(r);
|
|
340
|
-
}
|
|
341
|
-
case "currency": {
|
|
342
|
-
const n = typeof r == "number" ? r : Number(String(r).replace(",", "."));
|
|
343
|
-
if (!Number.isFinite(n)) return String(r);
|
|
344
|
-
try {
|
|
345
|
-
return new Intl.NumberFormat(void 0, { style: "currency", currency: e.currency }).format(n);
|
|
346
|
-
} catch {
|
|
347
|
-
return `${n.toLocaleString(void 0, { maximumFractionDigits: 2 })} ${e.currency}`;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
case "date":
|
|
351
|
-
case "datetime": {
|
|
352
|
-
const n = new Date(r);
|
|
353
|
-
return Number.isNaN(n.getTime()) ? String(r) : y.type === "date" ? n.toLocaleDateString() : n.toLocaleString();
|
|
354
|
-
}
|
|
355
|
-
case "array-counter":
|
|
356
|
-
return Array.isArray(r) ? String(r.length) : "0";
|
|
357
|
-
case "array":
|
|
358
|
-
return Array.isArray(r) ? B(r.map(U).join(", "), 160) : String(r);
|
|
359
|
-
case "html":
|
|
360
|
-
return B(re(String(r)), 160);
|
|
361
|
-
default:
|
|
362
|
-
return B(U(r), 180);
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
function U(r) {
|
|
366
|
-
if (z(r)) return "—";
|
|
367
|
-
if (r instanceof Date) return r.toLocaleString();
|
|
368
|
-
if (typeof r == "string") return r;
|
|
369
|
-
if (typeof r == "number" || typeof r == "boolean" || typeof r == "bigint") return String(r);
|
|
370
|
-
try {
|
|
371
|
-
return JSON.stringify(r);
|
|
372
|
-
} catch {
|
|
373
|
-
return String(r);
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
function re(r) {
|
|
377
|
-
if (typeof document > "u") return r.replace(/<[^>]*>/g, " ");
|
|
378
|
-
const y = document.createElement("div");
|
|
379
|
-
return y.innerHTML = r, y.textContent || "";
|
|
380
|
-
}
|
|
381
|
-
function B(r, y) {
|
|
382
|
-
return r.length > y ? `${r.slice(0, y - 1)}…` : r;
|
|
383
|
-
}
|
|
384
|
-
return (r, y) => (u(), f("div", fe, [
|
|
385
|
-
t.title || t.description ? (u(), f("div", ye, [
|
|
386
|
-
L("div", me, [
|
|
387
|
-
A(w(q), { class: "size-3.5 text-primary" })
|
|
388
|
-
]),
|
|
389
|
-
L("div", ge, [
|
|
390
|
-
t.title ? (u(), f("p", be, b(t.title), 1)) : N("", !0),
|
|
391
|
-
t.description ? (u(), f("p", he, b(t.description), 1)) : N("", !0)
|
|
392
|
-
]),
|
|
393
|
-
x.value > 0 ? (u(), f("span", xe, b(x.value) + " " + b(x.value === 1 ? "row" : "rows"), 1)) : N("", !0)
|
|
394
|
-
])) : N("", !0),
|
|
395
|
-
a.value.length === 0 ? (u(), f("div", we, [
|
|
396
|
-
A(w(q), { class: "mb-2 size-7 text-muted-foreground/50" }),
|
|
397
|
-
L("p", ke, b(t.emptyText), 1)
|
|
398
|
-
])) : c.value.length === 0 ? (u(), f("div", ve, [
|
|
399
|
-
A(w(se), { class: "mb-2 size-7 text-muted-foreground/50" }),
|
|
400
|
-
y[0] || (y[0] = L("p", { class: "text-xs text-muted-foreground" }, "No visible columns are configured.", -1))
|
|
401
|
-
])) : T.value ? (u(), f("div", _e, [
|
|
402
|
-
(u(!0), f(j, null, O(c.value, (n) => (u(), f("div", {
|
|
403
|
-
key: n.id,
|
|
404
|
-
class: "min-w-0"
|
|
405
|
-
}, [
|
|
406
|
-
L("p", Le, b(n.label), 1),
|
|
407
|
-
n.type === "image" && K(d(a.value[0], n.property)) ? (u(), f("img", {
|
|
408
|
-
key: 0,
|
|
409
|
-
src: d(a.value[0], n.property),
|
|
410
|
-
alt: n.label,
|
|
411
|
-
class: "size-16 rounded-lg border object-cover"
|
|
412
|
-
}, null, 8, Ce)) : n.type === "image" ? (u(), f("div", Se, [
|
|
413
|
-
A(w(Y), { class: "size-5 text-muted-foreground/50" })
|
|
414
|
-
])) : n.type === "URL" && M(d(a.value[0], n.property)) ? (u(), f("a", {
|
|
415
|
-
key: 2,
|
|
416
|
-
href: d(a.value[0], n.property),
|
|
417
|
-
target: "_blank",
|
|
418
|
-
rel: "noopener noreferrer",
|
|
419
|
-
class: "inline-flex max-w-full items-center gap-1 break-all text-xs text-primary hover:underline"
|
|
420
|
-
}, [
|
|
421
|
-
I(b(v(d(a.value[0], n.property), n)) + " ", 1),
|
|
422
|
-
A(w(Z), { class: "size-3 shrink-0" })
|
|
423
|
-
], 8, Ae)) : n.type === "email" && !z(d(a.value[0], n.property)) ? (u(), f("a", {
|
|
424
|
-
key: 3,
|
|
425
|
-
href: `mailto:${d(a.value[0], n.property)}`,
|
|
426
|
-
class: "break-all text-xs text-primary hover:underline"
|
|
427
|
-
}, b(v(d(a.value[0], n.property), n)), 9, Ne)) : n.type === "phone" && !z(d(a.value[0], n.property)) ? (u(), f("a", {
|
|
428
|
-
key: 4,
|
|
429
|
-
href: `tel:${d(a.value[0], n.property)}`,
|
|
430
|
-
class: "text-xs text-primary hover:underline"
|
|
431
|
-
}, b(v(d(a.value[0], n.property), n)), 9, $e)) : n.type === "boolean" ? (u(), f("span", {
|
|
432
|
-
key: 5,
|
|
433
|
-
class: P(["inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-medium", d(a.value[0], n.property) ? "bg-emerald-500/10 text-emerald-700 dark:text-emerald-300" : "bg-muted text-muted-foreground"])
|
|
434
|
-
}, [
|
|
435
|
-
d(a.value[0], n.property) ? (u(), F(w(X), {
|
|
436
|
-
key: 0,
|
|
437
|
-
class: "size-3"
|
|
438
|
-
})) : (u(), F(w(G), {
|
|
439
|
-
key: 1,
|
|
440
|
-
class: "size-3"
|
|
441
|
-
})),
|
|
442
|
-
I(" " + b(v(d(a.value[0], n.property), n)), 1)
|
|
443
|
-
], 2)) : (u(), f("p", {
|
|
444
|
-
key: 6,
|
|
445
|
-
class: "break-words text-xs font-medium",
|
|
446
|
-
title: U(d(a.value[0], n.property))
|
|
447
|
-
}, b(v(d(a.value[0], n.property), n)), 9, Te))
|
|
448
|
-
]))), 128))
|
|
449
|
-
])) : (u(), f("div", ze, [
|
|
450
|
-
L("table", Ee, [
|
|
451
|
-
L("thead", null, [
|
|
452
|
-
L("tr", Re, [
|
|
453
|
-
(u(!0), f(j, null, O(c.value, (n) => (u(), f("th", {
|
|
454
|
-
key: n.id,
|
|
455
|
-
class: "whitespace-nowrap px-3 py-2 text-[10px] font-medium uppercase tracking-wide text-muted-foreground"
|
|
456
|
-
}, b(n.label), 1))), 128))
|
|
457
|
-
])
|
|
458
|
-
]),
|
|
459
|
-
L("tbody", null, [
|
|
460
|
-
(u(!0), f(j, null, O(a.value, (n, h) => (u(), f("tr", {
|
|
461
|
-
key: h,
|
|
462
|
-
class: "border-b last:border-b-0 hover:bg-muted/20"
|
|
463
|
-
}, [
|
|
464
|
-
(u(!0), f(j, null, O(c.value, (o) => (u(), f("td", {
|
|
465
|
-
key: o.id,
|
|
466
|
-
class: "max-w-56 px-3 py-2 align-middle"
|
|
467
|
-
}, [
|
|
468
|
-
o.type === "image" && K(d(n, o.property)) ? (u(), f("img", {
|
|
469
|
-
key: 0,
|
|
470
|
-
src: d(n, o.property),
|
|
471
|
-
alt: o.label,
|
|
472
|
-
class: "size-8 rounded-md border object-cover"
|
|
473
|
-
}, null, 8, De)) : o.type === "image" ? (u(), f("div", Ue, [
|
|
474
|
-
A(w(Y), { class: "size-3.5 text-muted-foreground/50" })
|
|
475
|
-
])) : o.type === "URL" && M(d(n, o.property)) ? (u(), f("a", {
|
|
476
|
-
key: 2,
|
|
477
|
-
href: d(n, o.property),
|
|
478
|
-
target: "_blank",
|
|
479
|
-
rel: "noopener noreferrer",
|
|
480
|
-
class: "inline-flex max-w-48 items-center gap-1 truncate text-primary hover:underline"
|
|
481
|
-
}, [
|
|
482
|
-
L("span", Oe, b(v(d(n, o.property), o)), 1),
|
|
483
|
-
A(w(Z), { class: "size-3 shrink-0" })
|
|
484
|
-
], 8, je)) : o.type === "email" && !z(d(n, o.property)) ? (u(), f("a", {
|
|
485
|
-
key: 3,
|
|
486
|
-
href: `mailto:${d(n, o.property)}`,
|
|
487
|
-
class: "block max-w-48 truncate text-primary hover:underline"
|
|
488
|
-
}, b(v(d(n, o.property), o)), 9, Fe)) : o.type === "phone" && !z(d(n, o.property)) ? (u(), f("a", {
|
|
489
|
-
key: 4,
|
|
490
|
-
href: `tel:${d(n, o.property)}`,
|
|
491
|
-
class: "whitespace-nowrap text-primary hover:underline"
|
|
492
|
-
}, b(v(d(n, o.property), o)), 9, Ve)) : o.type === "boolean" ? (u(), f("span", {
|
|
493
|
-
key: 5,
|
|
494
|
-
class: P(["inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[10px] font-medium", d(n, o.property) ? "bg-emerald-500/10 text-emerald-700 dark:text-emerald-300" : "bg-muted text-muted-foreground"])
|
|
495
|
-
}, [
|
|
496
|
-
d(n, o.property) ? (u(), F(w(X), {
|
|
497
|
-
key: 0,
|
|
498
|
-
class: "size-2.5"
|
|
499
|
-
})) : (u(), F(w(G), {
|
|
500
|
-
key: 1,
|
|
501
|
-
class: "size-2.5"
|
|
502
|
-
})),
|
|
503
|
-
I(" " + b(v(d(n, o.property), o)), 1)
|
|
504
|
-
], 2)) : (u(), f("span", {
|
|
505
|
-
key: 6,
|
|
506
|
-
class: "block max-w-56 truncate",
|
|
507
|
-
title: U(d(n, o.property))
|
|
508
|
-
}, b(v(d(n, o.property), o)), 9, Me))
|
|
509
|
-
]))), 128))
|
|
510
|
-
]))), 128))
|
|
511
|
-
])
|
|
512
|
-
])
|
|
513
|
-
])),
|
|
514
|
-
a.value.length > 0 && (r.$slots.footer || k.value > 0 || m.value > 0) ? (u(), f("div", Be, [
|
|
515
|
-
oe(r.$slots, "footer"),
|
|
516
|
-
!r.$slots.footer && k.value > 0 ? (u(), f("span", Ie, "Showing " + b(a.value.length) + " of " + b(x.value) + " rows", 1)) : N("", !0),
|
|
517
|
-
m.value > 0 ? (u(), f("span", We, b(m.value) + " more " + b(m.value === 1 ? "column" : "columns") + " hidden", 1)) : N("", !0)
|
|
518
|
-
])) : N("", !0)
|
|
519
|
-
]));
|
|
520
|
-
}
|
|
521
|
-
});
|
|
522
|
-
export {
|
|
523
|
-
Qe as _,
|
|
524
|
-
$ as a,
|
|
525
|
-
Xe as b,
|
|
526
|
-
Ze as c,
|
|
527
|
-
qe as d,
|
|
528
|
-
Ye as e,
|
|
529
|
-
Pe as f,
|
|
530
|
-
le as i,
|
|
531
|
-
Ke as n,
|
|
532
|
-
W as r,
|
|
533
|
-
Ge as s
|
|
534
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("vue"),h=require("lucide-vue-next"),T=new Set(["__proto__","constructor","prototype"]);function v(r,t){if(!r||!t)return;const a=t.split(".");if(!a.some(s=>T.has(s)))return Object.prototype.hasOwnProperty.call(r,t)?r[t]:a.reduce((s,c)=>s?.[c],r)}function F(r){return r.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_.-]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,t=>t.toUpperCase())}function W(r,t){const a=r.toLowerCase().replace(/[_.-]/g,"");if(/email$/.test(a))return"email";if(/(phone|mobile|telephone|tel)$/.test(a))return"phone";if(/(image|photo|avatar|thumbnail|logo|picture)$/.test(a))return"image";if(/(url|link|website|href)$/.test(a))return"URL";if(/(price|amount|cost|total|revenue|salary|fee)$/.test(a))return"currency";if(/(createdat|updatedat|timestamp)$/.test(a))return"datetime";if(/date$/.test(a))return"date";const s=t.filter(c=>c!=null&&c!=="");return s.length?s.every(c=>typeof c=="boolean")?"boolean":s.every(c=>typeof c=="number")?"number":s.every(c=>Array.isArray(c))?"array":s.every(c=>typeof c=="string"&&/^\d{4}-\d{2}-\d{2}(?:T|$)/.test(c))?s.some(c=>String(c).includes("T"))?"datetime":"date":"text":"text"}function q(r){if(r==null)return[];const t=Array.isArray(r)?r:Array.isArray(r?.data)?r.data:Array.isArray(r?.items)?r.items:Array.isArray(r?.rows)?r.rows:null;if(!t)throw new Error("The Fetch items flow must return an array of rows.");return t.map(a=>a&&typeof a=="object"&&!Array.isArray(a)?a:{value:a})}function J(r){return Array.isArray(r)?r.filter(t=>t&&typeof t.property=="string"&&t.property.trim()).map((t,a)=>({...t,id:typeof t.id=="string"?t.id:`column-${a}`,property:t.property.trim(),label:typeof t.label=="string"&&t.label.trim()?t.label.trim():F(t.property),type:typeof t.type=="string"&&t.type?t.type:"text",visible:t.visible!==!1})):[]}function U(r,t,a,s){if(!(!r||typeof r!="object"||Array.isArray(r)||s>=2))for(const[c,p]of Object.entries(r)){if(T.has(c))continue;const u=t?`${t}.${c}`:c;p&&typeof p=="object"&&!Array.isArray(p)&&!(p instanceof Date)?U(p,u,a,s+1):a.add(u)}}function j(r){const t=new Set;for(const a of r.slice(0,10))U(a,"",t,0);return Array.from(t).slice(0,40).map((a,s)=>({id:`inferred-${s}`,property:a,label:F(a),type:W(a,r.map(c=>v(c,a))),visible:!0}))}function A(r,t){const a=String(r||"").trim().toLocaleLowerCase();return a&&(t.find(s=>s.property.toLocaleLowerCase()===a)||t.find(s=>String(s.label||"").trim().toLocaleLowerCase()===a)||t.find(s=>String(s.id||"").trim().toLocaleLowerCase()===a))||null}function B(r){return r==null||r===""||Array.isArray(r)&&r.length===0}function P(r){return typeof r=="boolean"?r:typeof r!="string"?null:r.toLowerCase()==="true"?!0:r.toLowerCase()==="false"?!1:null}function H(r,t){if(typeof t=="number"){const a=Number(r);return Number.isFinite(a)?a:r}return typeof t=="boolean"?P(r)??r:r}function E(r,t){const a=H(t,r);if(typeof r=="string"&&typeof a=="string")return r.toLocaleLowerCase()===a.toLocaleLowerCase();if(r instanceof Date){const s=new Date(a);return!Number.isNaN(s.getTime())&&r.getTime()===s.getTime()}return Object.is(r,a)}function w(r){if(r instanceof Date)return r.getTime();if(typeof r=="number")return r;if(typeof r=="boolean")return r?1:0;if(typeof r=="string"){const t=r.trim(),a=Number(t);if(t&&Number.isFinite(a))return a;if(/^\d{4}-\d{2}-\d{2}(?:T|$)/.test(t)){const s=new Date(t).getTime();if(!Number.isNaN(s))return s}return t.toLocaleLowerCase()}return String(r??"").toLocaleLowerCase()}function K(r,t,a){const c=A(t.property,a)?.property||t.property,p=v(r,c),u=t.operator||"==",l=Array.isArray(t.values)?t.values:(u==="in"||u==="notIn")&&typeof t.value=="string"?t.value.split(",").map(y=>y.trim()):[];if([">",">=","<","<="].includes(u)&&(B(p)||B(t.value)))return!1;switch(u){case"==":case"equals":return E(p,t.value);case"!=":case"not_equals":return!E(p,t.value);case">":return w(p)>w(t.value);case">=":return w(p)>=w(t.value);case"<":return w(p)<w(t.value);case"<=":return w(p)<=w(t.value);case"contains":return Array.isArray(p)?p.some(y=>E(y,t.value)):String(p??"").toLocaleLowerCase().includes(String(t.value??"").toLocaleLowerCase());case"startsWith":return String(p??"").toLocaleLowerCase().startsWith(String(t.value??"").toLocaleLowerCase());case"endsWith":return String(p??"").toLocaleLowerCase().endsWith(String(t.value??"").toLocaleLowerCase());case"in":return l.some(y=>E(p,y));case"notIn":return!l.some(y=>E(p,y));case"isEmpty":return B(p);case"isNotEmpty":return!B(p);default:throw new Error(`Unsupported table filter operator "${u}".`)}}function X(r,t,a=[]){if(!Array.isArray(t)||!t.length)return[...r];for(const s of t){if(!s||typeof s.property!="string"||!s.property.trim())throw new Error("Every table filter needs a property.");if(a.length&&!A(s.property,a))throw new Error(`Unknown table filter property "${s.property}". Use a property or label reported by inspectTable.`)}return r.filter(s=>t.every(c=>K(s,c,a)))}function Y(r,t,a="asc",s=[]){if(!t)return[...r];const c=A(t,s);if(s.length&&!c)throw new Error(`Unknown table sort property "${t}". Use a property or label reported by inspectTable.`);const p=c?.property||t,u=a==="desc"?-1:1;return r.map((l,y)=>({row:l,index:y})).sort((l,y)=>{const b=v(l.row,p),k=v(y.row,p);if(B(b)&&B(k))return l.index-y.index;if(B(b))return 1;if(B(k))return-1;const S=w(b),N=w(k);return S<N?-1*u:S>N?1*u:l.index-y.index}).map(l=>l.row)}function Z(r,t,a,s){return r.filter(c=>{const p=v(c,t);if(p==null||p==="")return!1;const l=(p instanceof Date?p:typeof p=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(p)?new Date(`${p}T00:00:00.000`):new Date(p)).getTime();return!Number.isNaN(l)&&l>=a.getTime()&&l<=s.getTime()})}function G(r){return r===null||["string","number","boolean"].includes(typeof r)}function Q(r,t,a=[]){const s=["id","_id","uuid","key","email","slug"],c=a.length?a:j(t),p=Array.from(new Set([...s,...c.map(y=>y.property),...Object.keys(r||{})])).filter(y=>!T.has(y)),u=[];let l=[...t];for(const y of p){const b=v(r,y);if(!G(b)||b==="")continue;const k=l.filter(S=>E(v(S,y),b));if(k.length){if(l.length===1)return[{property:y,value:b}];if(k.length!==l.length){if(u.push({property:y,value:b}),l=k,l.length===1)return u;if(u.length>=3)break}}}return l.length===1&&u.length?u:null}function ee(r,t=512*1024){const a=new WeakSet,s=JSON.stringify(r,(p,u)=>{if(!T.has(p)){if(typeof u=="bigint")return String(u);if(u instanceof Date)return u.toISOString();if(u&&typeof u=="object"){if(a.has(u))return"[Circular]";a.add(u)}return u}});if(s===void 0)throw new Error("The table result is not JSON serializable.");const c=new TextEncoder().encode(s).byteLength;if(c>t)throw new Error(`The table result is too large to store (${Math.ceil(c/1024)} KB). Narrow the query or lower the row limit.`);return JSON.parse(s)}const te={class:"w-full min-w-0 overflow-hidden rounded-xl border bg-background"},re={key:0,class:"flex items-start gap-2.5 border-b bg-muted/30 px-3 py-2.5"},ne={class:"mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-lg bg-primary/10"},oe={class:"min-w-0 flex-1"},ae={key:0,class:"truncate text-xs font-semibold"},ie={key:1,class:"mt-0.5 text-[11px] leading-relaxed text-muted-foreground"},se={key:0,class:"shrink-0 rounded-full bg-muted px-2 py-0.5 text-[10px] tabular-nums text-muted-foreground"},le={key:1,class:"flex flex-col items-center px-4 py-8 text-center"},ce={class:"text-xs text-muted-foreground"},pe={key:2,class:"flex flex-col items-center px-4 py-8 text-center"},ue={key:3,class:"grid gap-x-5 gap-y-3 p-3 sm:grid-cols-2"},de={class:"mb-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground"},fe=["src","alt"],ye={key:1,class:"flex size-16 items-center justify-center rounded-lg border bg-muted/30"},me=["href"],ge=["href"],be=["href"],he=["title"],ke={key:4,class:"overflow-x-auto"},xe={class:"w-full min-w-max text-left text-xs"},we={class:"border-b bg-muted/30"},Be=["src","alt"],ve={key:1,class:"flex size-8 items-center justify-center rounded-md border bg-muted/30"},Se=["href"],_e={class:"truncate"},Ee=["href"],Ne=["href"],Ce=["title"],Le={key:5,class:"flex flex-wrap items-center gap-x-3 gap-y-1 border-t bg-muted/20 px-3 py-2 text-[10px] text-muted-foreground"},Te={key:0},Ae={key:1},$e=e.defineComponent({__name:"TableResultView",props:{rows:{default:()=>[]},columns:{default:()=>[]},title:{default:""},description:{default:""},totalCount:{default:void 0},emptyText:{default:"No matching rows found."},maxRows:{default:20},maxColumns:{default:12},currency:{default:"EUR"},view:{default:"auto"}},setup(r){const t=r,a=e.computed(()=>N(t.maxRows,1,100,20)),s=e.computed(()=>N(t.maxColumns,1,20,12)),c=e.computed(()=>(Array.isArray(t.rows)?t.rows:[]).filter(n=>n!=null).map(n=>typeof n=="object"&&!Array.isArray(n)?n:{value:n})),p=e.computed(()=>{const n=Array.isArray(t.columns)?t.columns:[],f=n.filter(i=>i&&i.visible!==!1&&(i.property||i.key)).map((i,m)=>{const C=String(i.property||i.key);return{id:String(i.id||C||m),property:C,label:i.label||V(C),type:i.type||z(C,c.value.map(I=>d(I,C)))}});if(n.length>0)return O(f);const o=[],g=new Set;for(const i of c.value.slice(0,10))for(const m of Object.keys(i))g.has(m)||(g.add(m),o.push(m));return o.map(i=>({id:i,property:i,label:V(i),type:z(i,c.value.map(m=>d(m,i)))}))}),u=e.computed(()=>p.value.slice(0,s.value)),l=e.computed(()=>c.value.slice(0,a.value)),y=e.computed(()=>Math.max(p.value.length-u.value.length,0)),b=e.computed(()=>{const n=Number(t.totalCount);return Number.isFinite(n)&&n>=c.value.length?n:c.value.length}),k=e.computed(()=>Math.max(b.value-l.value.length,0)),S=e.computed(()=>l.value.length===1&&(t.view==="card"||t.view==="metric"||t.view==="auto"&&b.value===1));function N(n,f,o,g){const i=Number(n);return Number.isFinite(i)?Math.min(Math.max(Math.floor(i),f),o):g}function O(n){const f=new Set;return n.filter(o=>f.has(o.property)?!1:(f.add(o.property),!0))}function d(n,f){const o=f.split(".");if(!o.some(g=>["__proto__","constructor","prototype"].includes(g)))return Object.prototype.hasOwnProperty.call(n,f)?n[f]:o.reduce((g,i)=>g?.[i],n)}function V(n){return n.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_.-]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,f=>f.toUpperCase())}function z(n,f){const g=n.toLowerCase().replace(/[_.-]/g,"");if(/(image|photo|avatar|thumbnail|logo|picture)$/.test(g))return"image";if(/(email)$/.test(g))return"email";if(/(phone|mobile|telephone|tel)$/.test(g))return"phone";if(/(url|link|website|href)$/.test(g))return"URL";if(/(price|amount|cost|total|revenue|salary|fee)$/.test(g))return"currency";if(/(date|createdat|updatedat|timestamp)$/.test(g))return"datetime";const i=f.filter(m=>m!=null&&m!=="");return i.length===0?"text":i.every(m=>typeof m=="boolean")?"boolean":i.every(m=>Array.isArray(m))?"array":i.every(m=>typeof m=="number")?"number":i.every(m=>typeof m=="string"&&/^https?:\/\//i.test(m))?"URL":i.every(m=>typeof m=="string"&&/^\d{4}-\d{2}-\d{2}(?:T|$)/.test(m))?i.some(m=>String(m).includes("T"))?"datetime":"date":"text"}function _(n){return n==null||n===""}function $(n){if(typeof n!="string")return!1;try{const f=new URL(n,typeof window>"u"?"https://localhost":window.location.origin);return f.protocol==="http:"||f.protocol==="https:"}catch{return!1}}function R(n){return $(n)||typeof n=="string"&&/^data:image\/(?:png|jpe?g|gif|webp|avif);base64,/i.test(n)}function x(n,f){if(_(n))return"—";switch(f.type){case"boolean":return n?"Yes":"No";case"number":{const o=Number(n);return Number.isFinite(o)?o.toLocaleString(void 0,{maximumFractionDigits:2}):String(n)}case"currency":{const o=typeof n=="number"?n:Number(String(n).replace(",","."));if(!Number.isFinite(o))return String(n);try{return new Intl.NumberFormat(void 0,{style:"currency",currency:t.currency}).format(o)}catch{return`${o.toLocaleString(void 0,{maximumFractionDigits:2})} ${t.currency}`}}case"date":case"datetime":{const o=new Date(n);return Number.isNaN(o.getTime())?String(n):f.type==="date"?o.toLocaleDateString():o.toLocaleString()}case"array-counter":return Array.isArray(n)?String(n.length):"0";case"array":return Array.isArray(n)?D(n.map(L).join(", "),160):String(n);case"html":return D(M(String(n)),160);default:return D(L(n),180)}}function L(n){if(_(n))return"—";if(n instanceof Date)return n.toLocaleString();if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean"||typeof n=="bigint")return String(n);try{return JSON.stringify(n)}catch{return String(n)}}function M(n){if(typeof document>"u")return n.replace(/<[^>]*>/g," ");const f=document.createElement("div");return f.innerHTML=n,f.textContent||""}function D(n,f){return n.length>f?`${n.slice(0,f-1)}…`:n}return(n,f)=>(e.openBlock(),e.createElementBlock("div",te,[r.title||r.description?(e.openBlock(),e.createElementBlock("div",re,[e.createElementVNode("div",ne,[e.createVNode(e.unref(h.Table2),{class:"size-3.5 text-primary"})]),e.createElementVNode("div",oe,[r.title?(e.openBlock(),e.createElementBlock("p",ae,e.toDisplayString(r.title),1)):e.createCommentVNode("",!0),r.description?(e.openBlock(),e.createElementBlock("p",ie,e.toDisplayString(r.description),1)):e.createCommentVNode("",!0)]),b.value>0?(e.openBlock(),e.createElementBlock("span",se,e.toDisplayString(b.value)+" "+e.toDisplayString(b.value===1?"row":"rows"),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),l.value.length===0?(e.openBlock(),e.createElementBlock("div",le,[e.createVNode(e.unref(h.Table2),{class:"mb-2 size-7 text-muted-foreground/50"}),e.createElementVNode("p",ce,e.toDisplayString(r.emptyText),1)])):u.value.length===0?(e.openBlock(),e.createElementBlock("div",pe,[e.createVNode(e.unref(h.Columns3),{class:"mb-2 size-7 text-muted-foreground/50"}),f[0]||(f[0]=e.createElementVNode("p",{class:"text-xs text-muted-foreground"},"No visible columns are configured.",-1))])):S.value?(e.openBlock(),e.createElementBlock("div",ue,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(u.value,o=>(e.openBlock(),e.createElementBlock("div",{key:o.id,class:"min-w-0"},[e.createElementVNode("p",de,e.toDisplayString(o.label),1),o.type==="image"&&R(d(l.value[0],o.property))?(e.openBlock(),e.createElementBlock("img",{key:0,src:d(l.value[0],o.property),alt:o.label,class:"size-16 rounded-lg border object-cover"},null,8,fe)):o.type==="image"?(e.openBlock(),e.createElementBlock("div",ye,[e.createVNode(e.unref(h.Image),{class:"size-5 text-muted-foreground/50"})])):o.type==="URL"&&$(d(l.value[0],o.property))?(e.openBlock(),e.createElementBlock("a",{key:2,href:d(l.value[0],o.property),target:"_blank",rel:"noopener noreferrer",class:"inline-flex max-w-full items-center gap-1 break-all text-xs text-primary hover:underline"},[e.createTextVNode(e.toDisplayString(x(d(l.value[0],o.property),o))+" ",1),e.createVNode(e.unref(h.ExternalLink),{class:"size-3 shrink-0"})],8,me)):o.type==="email"&&!_(d(l.value[0],o.property))?(e.openBlock(),e.createElementBlock("a",{key:3,href:`mailto:${d(l.value[0],o.property)}`,class:"break-all text-xs text-primary hover:underline"},e.toDisplayString(x(d(l.value[0],o.property),o)),9,ge)):o.type==="phone"&&!_(d(l.value[0],o.property))?(e.openBlock(),e.createElementBlock("a",{key:4,href:`tel:${d(l.value[0],o.property)}`,class:"text-xs text-primary hover:underline"},e.toDisplayString(x(d(l.value[0],o.property),o)),9,be)):o.type==="boolean"?(e.openBlock(),e.createElementBlock("span",{key:5,class:e.normalizeClass(["inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-medium",d(l.value[0],o.property)?"bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":"bg-muted text-muted-foreground"])},[d(l.value[0],o.property)?(e.openBlock(),e.createBlock(e.unref(h.Check),{key:0,class:"size-3"})):(e.openBlock(),e.createBlock(e.unref(h.X),{key:1,class:"size-3"})),e.createTextVNode(" "+e.toDisplayString(x(d(l.value[0],o.property),o)),1)],2)):(e.openBlock(),e.createElementBlock("p",{key:6,class:"break-words text-xs font-medium",title:L(d(l.value[0],o.property))},e.toDisplayString(x(d(l.value[0],o.property),o)),9,he))]))),128))])):(e.openBlock(),e.createElementBlock("div",ke,[e.createElementVNode("table",xe,[e.createElementVNode("thead",null,[e.createElementVNode("tr",we,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(u.value,o=>(e.openBlock(),e.createElementBlock("th",{key:o.id,class:"whitespace-nowrap px-3 py-2 text-[10px] font-medium uppercase tracking-wide text-muted-foreground"},e.toDisplayString(o.label),1))),128))])]),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,(o,g)=>(e.openBlock(),e.createElementBlock("tr",{key:g,class:"border-b last:border-b-0 hover:bg-muted/20"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(u.value,i=>(e.openBlock(),e.createElementBlock("td",{key:i.id,class:"max-w-56 px-3 py-2 align-middle"},[i.type==="image"&&R(d(o,i.property))?(e.openBlock(),e.createElementBlock("img",{key:0,src:d(o,i.property),alt:i.label,class:"size-8 rounded-md border object-cover"},null,8,Be)):i.type==="image"?(e.openBlock(),e.createElementBlock("div",ve,[e.createVNode(e.unref(h.Image),{class:"size-3.5 text-muted-foreground/50"})])):i.type==="URL"&&$(d(o,i.property))?(e.openBlock(),e.createElementBlock("a",{key:2,href:d(o,i.property),target:"_blank",rel:"noopener noreferrer",class:"inline-flex max-w-48 items-center gap-1 truncate text-primary hover:underline"},[e.createElementVNode("span",_e,e.toDisplayString(x(d(o,i.property),i)),1),e.createVNode(e.unref(h.ExternalLink),{class:"size-3 shrink-0"})],8,Se)):i.type==="email"&&!_(d(o,i.property))?(e.openBlock(),e.createElementBlock("a",{key:3,href:`mailto:${d(o,i.property)}`,class:"block max-w-48 truncate text-primary hover:underline"},e.toDisplayString(x(d(o,i.property),i)),9,Ee)):i.type==="phone"&&!_(d(o,i.property))?(e.openBlock(),e.createElementBlock("a",{key:4,href:`tel:${d(o,i.property)}`,class:"whitespace-nowrap text-primary hover:underline"},e.toDisplayString(x(d(o,i.property),i)),9,Ne)):i.type==="boolean"?(e.openBlock(),e.createElementBlock("span",{key:5,class:e.normalizeClass(["inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[10px] font-medium",d(o,i.property)?"bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":"bg-muted text-muted-foreground"])},[d(o,i.property)?(e.openBlock(),e.createBlock(e.unref(h.Check),{key:0,class:"size-2.5"})):(e.openBlock(),e.createBlock(e.unref(h.X),{key:1,class:"size-2.5"})),e.createTextVNode(" "+e.toDisplayString(x(d(o,i.property),i)),1)],2)):(e.openBlock(),e.createElementBlock("span",{key:6,class:"block max-w-56 truncate",title:L(d(o,i.property))},e.toDisplayString(x(d(o,i.property),i)),9,Ce))]))),128))]))),128))])])])),l.value.length>0&&(n.$slots.footer||k.value>0||y.value>0)?(e.openBlock(),e.createElementBlock("div",Le,[e.renderSlot(n.$slots,"footer"),!n.$slots.footer&&k.value>0?(e.openBlock(),e.createElementBlock("span",Te,"Showing "+e.toDisplayString(l.value.length)+" of "+e.toDisplayString(b.value)+" rows",1)):e.createCommentVNode("",!0),y.value>0?(e.openBlock(),e.createElementBlock("span",Ae,e.toDisplayString(y.value)+" more "+e.toDisplayString(y.value===1?"column":"columns")+" hidden",1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)]))}});exports._sfc_main=$e;exports.applyLocalDateRange=Z;exports.applyTableFilters=X;exports.applyTableSort=Y;exports.buildRowReference=Q;exports.inferTableColumns=j;exports.normalizeTableColumns=J;exports.normalizeTableRows=q;exports.resolveColumn=A;exports.resolveProperty=v;exports.serializeBounded=ee;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),b=require("lucide-vue-next"),P=require("./useTableAgentTools-D5mzGf3A.js"),u=require("./TableResultView.vue_vue_type_script_setup_true_lang-C_Lv-SmJ.js"),M=require("./tool-sandbox-DoF1PsyS.js"),Z={class:"w-full"},F={key:0,class:"flex items-center gap-2 py-3 text-xs text-muted-foreground"},U={key:1,class:"rounded-xl border bg-background p-4"},X={class:"flex items-center gap-2 text-sm font-semibold text-emerald-600 dark:text-emerald-400"},G={key:2,class:"rounded-xl border bg-background p-4"},H={class:"flex items-center gap-2 text-sm font-semibold text-muted-foreground"},J={key:3,class:"flex items-start gap-2 rounded-xl border border-destructive/30 bg-destructive/5 p-3 text-xs text-destructive"},K={key:4,class:"overflow-hidden rounded-xl border bg-background"},Q={class:"border-b bg-amber-50/70 p-4 dark:bg-amber-950/20"},W={class:"flex items-start gap-3"},Y={class:"flex size-9 shrink-0 items-center justify-center rounded-lg bg-amber-500/15"},ee={class:"min-w-0"},te={class:"text-sm font-semibold"},re={key:0,class:"mt-1 text-[11px] text-muted-foreground"},le={class:"p-3"},oe={key:0,class:"mt-3 text-xs text-destructive"},ae={class:"mt-3 flex items-center gap-2"},ne=["disabled"],se=["disabled"],ce=e.defineComponent({__name:"TableRowActionCard",props:{projectSlug:{},toolName:{},instanceId:{},instanceName:{},moduleType:{},resolvedArgs:{},status:{}},emits:["submit"],setup(R,{emit:B}){const o=R,T=B,w=e.ref(!0),f=e.ref(!1),i=e.ref(null),d=e.ref("confirm"),a=e.ref(null),A=e.ref(-1),n=e.ref(null),g=e.ref([]),v=e.ref(null),_=e.ref(null),{loadRows:C,runStoredRowAction:S}=P.useTableAgentTools(o);function D(t,r){const s=t.filter(m=>m.id===r);if(s.length===1)return s[0];const c=r.trim().toLocaleLowerCase(),l=t.filter(m=>String(m.label).trim().toLocaleLowerCase()===c);if(l.length===1)return l[0];throw l.length>1?new Error(`More than one row action is named "${r}". Use its action ID.`):new Error(`No configured row action matches "${r}".`)}async function z(t,r){if(t.visible===void 0||t.visible===null||t.visible===""||t.visible===!0||t.visible==="true")return!0;if(t.visible===!1||t.visible==="false")return!1;const c=String(t.visible).trim().match(/^\{\{([\s\S]*)\}\}$/);if(!c)return!1;const l={item:{data:r}};for(const[p,h]of Object.entries(r||{}))/^[$A-Z_][0-9A-Z_$]*$/i.test(p)&&!["constructor","prototype","__proto__"].includes(p)&&(l[p]=h);return await M.runSandboxedTableCode(`const value = (${c[1]}); return value === true || value === 'true';`,l,{timeoutMs:750,maxInputBytes:1024*1024,maxOutputBytes:1024})===!0}function $(){if(o.status!=="completed")return!1;const t=o.resolvedArgs?._cachedData;return!t||typeof t!="object"||Array.isArray(t)?!1:t.executed!==!0&&t.cancelled!==!0&&typeof t.error!="string"?(i.value="The saved row-action result is unavailable.",d.value="error",w.value=!1,!0):(_.value=t,a.value=t.row||null,g.value=t.columns||u.inferTableColumns(a.value?[a.value]:[]).slice(0,8),i.value=t.error||null,d.value=t.cancelled?"cancelled":t.executed?"success":"error",w.value=!1,!0)}function y(t){let r;try{r=u.serializeBounded(t,256*1024)}catch{r={executed:t?.executed===!0,cancelled:t?.cancelled===!0,action:t?.action||null,rowReference:t?.rowReference||null,resultOmitted:"The detailed result was too large to store in chat."}}_.value=r,o.status!=="completed"&&T("submit",r)}function E(t){return Object.fromEntries(g.value.map(r=>[r.property,u.resolveProperty(t,r.property)]))}function I(){const t=String(o.resolvedArgs?.action||"").trim(),r=Array.isArray(o.resolvedArgs?.match)?o.resolvedArgs.match:[];if(!t)throw new Error("A configured row action ID or label is required.");if(!r.length)throw new Error("At least one exact row match is required before an action can run.");return{requestedAction:t,match:r}}async function N(t=!1){const{requestedAction:r,match:s}=I(),c=await C({startDate:o.resolvedArgs?.startDate,endDate:o.resolvedArgs?.endDate,dateProperty:o.resolvedArgs?.dateProperty,useDefaultDateRange:o.resolvedArgs?.useDefaultDateRange},{freshMetadata:t}),l=D(c.actions,r),m=c.rows.filter(k=>s.every(x=>{if(!x||typeof x.property!="string")return!1;const O=u.resolveColumn(x.property,c.columns)?.property||x.property;return Object.is(u.resolveProperty(k,O),x.value)}));if(m.length!==1){const k=m.length===0?"No rows match":`${m.length} rows match`;throw new Error(`${k} the supplied identity. Refine the match until it identifies exactly one row.`)}const p=m[0],h=c.sourceRows.indexOf(p);if(h<0)throw new Error("The selected row could not be mapped back to the table data.");if(!await z(l,p))throw new Error(`The "${l.label}" action is not available for this row.`);return{result:c,action:l,row:p,rowIndex:h}}function V(t){v.value=t.result,n.value=t.action,a.value=t.row,A.value=t.rowIndex;const r=t.result.columns.length?t.result.columns:u.inferTableColumns([t.row]);g.value=r.filter(s=>s.visible!==!1&&!s._remove).slice(0,8)}async function j(){if(!$()){w.value=!0,i.value=null;try{V(await N())}catch(t){i.value=t?.message||"Could not prepare the row action.",d.value="error",y({executed:!1,error:i.value,action:o.resolvedArgs?.action||null,availableActions:v.value?.actions?.map(r=>({id:r.id,label:r.label}))||[]})}finally{w.value=!1}}}async function q(){if(!(f.value||!n.value||!a.value||!v.value)){f.value=!0,i.value=null;try{V(await N(!0));const t=await S(n.value,a.value,A.value,v.value.sourceRows),r=u.buildRowReference(a.value,v.value.rows,v.value.columns);let s=null;try{s=u.serializeBounded(t.flowResult??null,64*1024)}catch{s={omitted:"The flow result was too large to store in chat."}}const c={executed:!0,cancelled:!1,action:{id:n.value.id,label:n.value.label},row:E(a.value),rowReference:r,columns:g.value.map(l=>({property:l.property,label:l.label||l.property,type:l.type||"text"})),flowResult:s,tableEffects:t.effects.map(l=>({type:l.type,index:l.index,merge:l.merge}))};d.value="success",y(c)}catch(t){i.value=t?.message||"The row action failed.",d.value="error",y({executed:!1,cancelled:!1,error:i.value,action:n.value?{id:n.value.id,label:n.value.label}:o.resolvedArgs?.action,rowReference:a.value&&v.value?u.buildRowReference(a.value,v.value.rows,v.value.columns):null})}finally{f.value=!1}}}function L(){f.value||(d.value="cancelled",y({executed:!1,cancelled:!0,action:n.value?{id:n.value.id,label:n.value.label}:o.resolvedArgs?.action,row:a.value?E(a.value):null,columns:g.value}))}return e.onMounted(j),(t,r)=>(e.openBlock(),e.createElementBlock("div",Z,[w.value?(e.openBlock(),e.createElementBlock("div",F,[e.createVNode(e.unref(b.Loader2),{class:"size-4 animate-spin"}),r[0]||(r[0]=e.createElementVNode("span",null,"Finding the row and action…",-1))])):d.value==="success"?(e.openBlock(),e.createElementBlock("div",U,[e.createElementVNode("div",X,[e.createVNode(e.unref(b.CheckCircle2),{class:"size-5"}),e.createElementVNode("span",null,e.toDisplayString(_.value?.action?.label||"Row action")+" completed",1)]),r[1]||(r[1]=e.createElementVNode("p",{class:"mt-1 text-xs text-muted-foreground"},"The table’s configured action flow finished successfully.",-1))])):d.value==="cancelled"?(e.openBlock(),e.createElementBlock("div",G,[e.createElementVNode("div",H,[e.createVNode(e.unref(b.XCircle),{class:"size-5"}),r[2]||(r[2]=e.createElementVNode("span",null,"Action cancelled",-1))]),r[3]||(r[3]=e.createElementVNode("p",{class:"mt-1 text-xs text-muted-foreground"},"No row action was run.",-1))])):d.value==="error"?(e.openBlock(),e.createElementBlock("div",J,[e.createVNode(e.unref(b.AlertTriangle),{class:"mt-0.5 size-4 shrink-0"}),e.createElementVNode("span",null,e.toDisplayString(i.value),1)])):(e.openBlock(),e.createElementBlock("div",K,[e.createElementVNode("div",Q,[e.createElementVNode("div",W,[e.createElementVNode("div",Y,[e.createVNode(e.unref(b.AlertTriangle),{class:"size-4 text-amber-600 dark:text-amber-400"})]),e.createElementVNode("div",ee,[e.createElementVNode("p",te,"Confirm “"+e.toDisplayString(n.value?.label)+"”",1),r[4]||(r[4]=e.createElementVNode("p",{class:"mt-1 text-xs text-muted-foreground"}," This runs the action flow configured on this table and may change external data. ",-1)),o.resolvedArgs?.confirmationMessage?(e.openBlock(),e.createElementBlock("p",re," Agent note: "+e.toDisplayString(o.resolvedArgs.confirmationMessage),1)):e.createCommentVNode("",!0)])])]),e.createElementVNode("div",le,[e.createVNode(u._sfc_main,{title:"Selected row",rows:a.value?[a.value]:[],columns:g.value,view:"card","max-rows":1},null,8,["rows","columns"]),i.value?(e.openBlock(),e.createElementBlock("p",oe,e.toDisplayString(i.value),1)):e.createCommentVNode("",!0),e.createElementVNode("div",ae,[e.createElementVNode("button",{type:"button",class:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-50",disabled:f.value,onClick:q},[f.value?(e.openBlock(),e.createBlock(e.unref(b.Loader2),{key:0,class:"size-3 animate-spin"})):(e.openBlock(),e.createBlock(e.unref(b.Play),{key:1,class:"size-3"})),e.createTextVNode(" "+e.toDisplayString(f.value?"Running…":`Run ${n.value?.label}`),1)],8,ne),e.createElementVNode("button",{type:"button",class:"rounded-lg border px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted disabled:opacity-50",disabled:f.value,onClick:L}," Cancel ",8,se)])])]))]))}});exports.default=ce;
|