@nivaro/react 0.3.24 → 0.3.25
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/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +45 -26
- package/dist/shared/components/FilePreviewLightbox.js +56 -35
- package/dist/shared/components/ItemEditForm.js +4309 -4263
- package/dist/shared/components/PageRenderer.js +63 -62
- package/dist/shared/components/RecordReadView.js +229 -229
- package/dist/shared/components/ReportView.js +123 -120
- package/dist/shared/components/ai/AiMarkdown.js +168 -148
- package/dist/shared/components/chat/RoomParts.js +120 -119
- package/dist/shared/components/chat/chat-core.js +228 -224
- package/dist/shared/components/item-edit/FieldRenderer.js +333 -333
- package/dist/shared/components/item-edit/FieldRow.js +413 -394
- package/dist/shared/components/item-edit/GroupSection.js +637 -635
- package/dist/shared/components/item-edit/InlineGridField.js +89 -90
- package/dist/shared/components/item-edit/QuickPicker.js +9 -9
- package/dist/shared/components/item-edit/RawEditSheet.js +80 -79
- package/dist/shared/components/item-edit/RowMatchPanel.js +1 -1
- package/dist/shared/components/item-edit/m2m-invalidate.js +19 -0
- package/dist/shared/components/item-edit/record-lookups.js +15 -0
- package/dist/shared/components/item-edit/render-stability.js +147 -0
- package/dist/shared/components/layout-editor/FormMapButton.js +5 -4
- package/dist/shared/lib/safe-href.js +10 -0
- package/dist/shared/lib/socket-realtime.js +107 -78
- package/package.json +6 -6
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useMemo as k, createContext as
|
|
1
|
+
import { jsx as l, jsxs as f } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as k, createContext as C, useState as S, useContext as $, Suspense as W, lazy as L } from "react";
|
|
3
3
|
import { useOptionalNivaroClient as O, useNavigation as B } from "../../context.js";
|
|
4
|
-
import { useGlossary as
|
|
5
|
-
import { cn as
|
|
4
|
+
import { useGlossary as I, glossarySegments as T } from "../../lib/glossary.js";
|
|
5
|
+
import { cn as w } from "../../lib/utils.js";
|
|
6
6
|
import { AutolinkedText as _ } from "../AutolinkedText.js";
|
|
7
|
-
import { formatsFor as j, rowsOfBlock as
|
|
8
|
-
import { useGlossaryHref as K, GlossaryMark as
|
|
7
|
+
import { formatsFor as j, rowsOfBlock as M, listOf as P, chartOf as E } from "./answer-formats.js";
|
|
8
|
+
import { useGlossaryHref as K, GlossaryMark as R } from "./GlossaryText.js";
|
|
9
9
|
function F(t) {
|
|
10
10
|
try {
|
|
11
|
-
const e = JSON.parse(t), r = e.type === "line" || e.type === "pie" ? e.type : "bar",
|
|
12
|
-
return
|
|
11
|
+
const e = JSON.parse(t), r = e.type === "line" || e.type === "pie" ? e.type : "bar", i = Array.isArray(e.data) ? e.data.map((n) => ({ label: String((n == null ? void 0 : n.label) ?? ""), value: Number(n == null ? void 0 : n.value) })).filter((n) => n.label && Number.isFinite(n.value)).slice(0, 40) : [];
|
|
12
|
+
return i.length < 2 ? null : { type: r, title: typeof e.title == "string" ? e.title : void 0, data: i };
|
|
13
13
|
} catch {
|
|
14
14
|
return null;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
const
|
|
18
|
-
function
|
|
17
|
+
const N = /^\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/;
|
|
18
|
+
function v(t) {
|
|
19
19
|
return t.trim().replace(/^\|/, "").replace(/\|$/, "").split("|").map((e) => e.trim());
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function H(t) {
|
|
22
22
|
return t.split(`
|
|
23
23
|
`).flatMap((e) => {
|
|
24
24
|
const r = e.trim();
|
|
25
|
-
return !r.startsWith("|") || !/\|\s*\|\s*[:-]{2,}/.test(r) && !/\|\s+\|\s*\S/.test(r) ? [e] : (r.match(/\|\s+\|/g) ?? []).length < 1 ? [e] : r.split(/\|\s+(?=\|)/).map((
|
|
25
|
+
return !r.startsWith("|") || !/\|\s*\|\s*[:-]{2,}/.test(r) && !/\|\s+\|\s*\S/.test(r) ? [e] : (r.match(/\|\s+\|/g) ?? []).length < 1 ? [e] : r.split(/\|\s+(?=\|)/).map((i) => i.trim().endsWith("|") ? i.trim() : `${i.trim()} |`);
|
|
26
26
|
}).join(`
|
|
27
27
|
`);
|
|
28
28
|
}
|
|
29
29
|
function G(t) {
|
|
30
|
-
const e =
|
|
30
|
+
const e = H(t.replace(/\r\n/g, `
|
|
31
31
|
`)).split(`
|
|
32
32
|
`), r = [];
|
|
33
|
-
let
|
|
33
|
+
let i = [];
|
|
34
34
|
const n = () => {
|
|
35
|
-
|
|
35
|
+
i.length && r.push({ kind: "p", text: i.join(" ") }), i = [];
|
|
36
36
|
};
|
|
37
|
-
for (let
|
|
38
|
-
const a = e[
|
|
37
|
+
for (let s = 0; s < e.length; s++) {
|
|
38
|
+
const a = e[s].trim();
|
|
39
39
|
if (a.startsWith("```")) {
|
|
40
40
|
n();
|
|
41
|
-
const
|
|
42
|
-
for (
|
|
43
|
-
const
|
|
44
|
-
`),
|
|
45
|
-
r.push(
|
|
41
|
+
const o = a.slice(3).trim().toLowerCase(), d = [];
|
|
42
|
+
for (s++; s < e.length && !e[s].trim().startsWith("```"); ) d.push(e[s++]);
|
|
43
|
+
const x = d.join(`
|
|
44
|
+
`), b = o === "chart" ? F(x) : null;
|
|
45
|
+
r.push(b ? { kind: "chart", spec: b } : { kind: "code", text: x });
|
|
46
46
|
continue;
|
|
47
47
|
}
|
|
48
48
|
if (a === "") {
|
|
@@ -54,93 +54,112 @@ function G(t) {
|
|
|
54
54
|
n(), r.push({ kind: "h", level: u[1].length, text: u[2] });
|
|
55
55
|
continue;
|
|
56
56
|
}
|
|
57
|
-
if (a.startsWith("|") &&
|
|
57
|
+
if (a.startsWith("|") && s + 1 < e.length && N.test(e[s + 1].trim())) {
|
|
58
58
|
n();
|
|
59
|
-
const
|
|
60
|
-
for (
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
const o = v(a), d = [];
|
|
60
|
+
for (s += 2; s < e.length && e[s].trim().startsWith("|"); )
|
|
61
|
+
N.test(e[s].trim()) || d.push(v(e[s])), s++;
|
|
62
|
+
s--, r.push({ kind: "table", header: o, rows: d });
|
|
63
63
|
continue;
|
|
64
64
|
}
|
|
65
|
-
const
|
|
66
|
-
if (
|
|
65
|
+
const h = /^[-*•]\s+(.*)$/.exec(a);
|
|
66
|
+
if (h) {
|
|
67
67
|
n();
|
|
68
|
-
const
|
|
69
|
-
for (;
|
|
70
|
-
const d = /^[-*•]\s+(.*)$/.exec(e[
|
|
68
|
+
const o = [h[1]];
|
|
69
|
+
for (; s + 1 < e.length; ) {
|
|
70
|
+
const d = /^[-*•]\s+(.*)$/.exec(e[s + 1].trim());
|
|
71
71
|
if (!d) break;
|
|
72
|
-
|
|
72
|
+
o.push(d[1]), s++;
|
|
73
73
|
}
|
|
74
|
-
r.push({ kind: "ul", items:
|
|
74
|
+
r.push({ kind: "ul", items: o });
|
|
75
75
|
continue;
|
|
76
76
|
}
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
77
|
+
const c = /^\d+[.)]\s+(.*)$/.exec(a);
|
|
78
|
+
if (c) {
|
|
79
79
|
n();
|
|
80
|
-
const
|
|
81
|
-
for (;
|
|
82
|
-
const d = /^\d+[.)]\s+(.*)$/.exec(e[
|
|
80
|
+
const o = [c[1]];
|
|
81
|
+
for (; s + 1 < e.length; ) {
|
|
82
|
+
const d = /^\d+[.)]\s+(.*)$/.exec(e[s + 1].trim());
|
|
83
83
|
if (!d) break;
|
|
84
|
-
|
|
84
|
+
o.push(d[1]), s++;
|
|
85
85
|
}
|
|
86
|
-
r.push({ kind: "ol", items:
|
|
86
|
+
r.push({ kind: "ol", items: o });
|
|
87
87
|
continue;
|
|
88
88
|
}
|
|
89
|
-
|
|
89
|
+
i.push(a);
|
|
90
90
|
}
|
|
91
91
|
return n(), r;
|
|
92
92
|
}
|
|
93
|
-
const
|
|
93
|
+
const D = /(\*\*[^*]+\*\*|`[^`]+`|\*[^*]+\*|\[[^\]]+\]\([^)]+\))/g;
|
|
94
94
|
function p(t, e = !1, r) {
|
|
95
|
-
const
|
|
96
|
-
let n = 0,
|
|
97
|
-
const
|
|
98
|
-
if (!(r != null && r.terms.length)) return
|
|
99
|
-
const
|
|
100
|
-
return
|
|
101
|
-
(
|
|
102
|
-
var
|
|
103
|
-
return
|
|
95
|
+
const i = [];
|
|
96
|
+
let n = 0, s = 0;
|
|
97
|
+
const m = (u) => e ? /* @__PURE__ */ l(_, { text: u, plain: !0 }, s++) : u, a = (u) => {
|
|
98
|
+
if (!(r != null && r.terms.length)) return m(u);
|
|
99
|
+
const h = T(u, r.terms, { once: r.once });
|
|
100
|
+
return h.length === 1 && !h[0].term ? m(u) : h.map(
|
|
101
|
+
(c) => {
|
|
102
|
+
var o;
|
|
103
|
+
return c.term ? /* @__PURE__ */ l(R, { term: c.term, href: (o = r.href) == null ? void 0 : o.call(r, c.term), children: c.text }, s++) : m(c.text);
|
|
104
104
|
}
|
|
105
105
|
);
|
|
106
106
|
};
|
|
107
|
-
for (const u of t.matchAll(
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
if (
|
|
112
|
-
else if (
|
|
113
|
-
|
|
114
|
-
/* @__PURE__ */
|
|
107
|
+
for (const u of t.matchAll(D)) {
|
|
108
|
+
const h = u.index ?? 0;
|
|
109
|
+
h > n && i.push(a(t.slice(n, h)));
|
|
110
|
+
const c = u[0];
|
|
111
|
+
if (c.startsWith("**")) i.push(/* @__PURE__ */ l("strong", { children: a(c.slice(2, -2)) }, s++));
|
|
112
|
+
else if (c.startsWith("`"))
|
|
113
|
+
i.push(
|
|
114
|
+
/* @__PURE__ */ l(
|
|
115
115
|
"code",
|
|
116
116
|
{
|
|
117
117
|
className: "rounded bg-black/[0.06] px-1 py-px font-mono text-[0.92em] dark:bg-white/10",
|
|
118
|
-
children:
|
|
118
|
+
children: c.slice(1, -1)
|
|
119
119
|
},
|
|
120
|
-
|
|
120
|
+
s++
|
|
121
121
|
)
|
|
122
122
|
);
|
|
123
|
-
else if (
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
} else l.push(/* @__PURE__ */ s("em", { children: o.slice(1, -1) }, i++));
|
|
139
|
-
n = m + o.length;
|
|
123
|
+
else if (c.startsWith("[")) {
|
|
124
|
+
const o = /^\[([^\]]+)\]\(([^)]+)\)$/.exec(c);
|
|
125
|
+
o && z(o[2]) ? i.push(/* @__PURE__ */ l(q, { href: o[2], label: o[1] }, s++)) : o && y(o[2]) ? i.push(/* @__PURE__ */ l(U, { href: o[2], label: o[1] }, s++)) : i.push(c);
|
|
126
|
+
} else i.push(/* @__PURE__ */ l("em", { children: c.slice(1, -1) }, s++));
|
|
127
|
+
n = h + c.length;
|
|
128
|
+
}
|
|
129
|
+
return n < t.length && i.push(a(t.slice(n))), i;
|
|
130
|
+
}
|
|
131
|
+
function y(t) {
|
|
132
|
+
if (!/^https?:\/\/\S+$/i.test(t)) return null;
|
|
133
|
+
try {
|
|
134
|
+
const e = new URL(t);
|
|
135
|
+
return e.username || e.password ? null : e.hostname || null;
|
|
136
|
+
} catch {
|
|
137
|
+
return null;
|
|
140
138
|
}
|
|
141
|
-
return n < t.length && l.push(a(t.slice(n))), l;
|
|
142
139
|
}
|
|
143
|
-
function
|
|
140
|
+
function U({ href: t, label: e }) {
|
|
141
|
+
const r = y(t) ?? "", i = e.trim() === t || e.trim() === r;
|
|
142
|
+
return /* @__PURE__ */ f(
|
|
143
|
+
"a",
|
|
144
|
+
{
|
|
145
|
+
href: t,
|
|
146
|
+
"data-ai-link": "external",
|
|
147
|
+
className: "underline underline-offset-2",
|
|
148
|
+
target: "_blank",
|
|
149
|
+
rel: "noopener noreferrer nofollow",
|
|
150
|
+
"data-tip": t,
|
|
151
|
+
children: [
|
|
152
|
+
i ? r : e,
|
|
153
|
+
!i && /* @__PURE__ */ f("span", { className: "ml-1 whitespace-nowrap text-[0.85em] opacity-70", children: [
|
|
154
|
+
"(",
|
|
155
|
+
r,
|
|
156
|
+
" ↗)"
|
|
157
|
+
] })
|
|
158
|
+
]
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
function z(t) {
|
|
144
163
|
if (!/^\/(?![\\/])/.test(t)) return !1;
|
|
145
164
|
for (let e = 0; e < t.length; e++) {
|
|
146
165
|
const r = t.charCodeAt(e);
|
|
@@ -148,49 +167,49 @@ function D(t) {
|
|
|
148
167
|
}
|
|
149
168
|
return !0;
|
|
150
169
|
}
|
|
151
|
-
function
|
|
170
|
+
function J(t, e) {
|
|
152
171
|
return e && e !== "/help-videos" && /^\/help-videos(?=[?#/]|$)/.test(t) ? `${e}${t.slice(12)}` : t;
|
|
153
172
|
}
|
|
154
|
-
function
|
|
155
|
-
const r = B(),
|
|
156
|
-
return /* @__PURE__ */
|
|
173
|
+
function q({ href: t, label: e }) {
|
|
174
|
+
const r = B(), i = J(t, r.helpVideosPath);
|
|
175
|
+
return /* @__PURE__ */ l(
|
|
157
176
|
"a",
|
|
158
177
|
{
|
|
159
|
-
href:
|
|
178
|
+
href: i,
|
|
160
179
|
"data-ai-link": "in-app",
|
|
161
180
|
className: "underline underline-offset-2",
|
|
162
181
|
onClick: (n) => {
|
|
163
|
-
n.defaultPrevented || n.button !== 0 || n.metaKey || n.ctrlKey || n.shiftKey || n.altKey || (n.preventDefault(), r.navigate(
|
|
182
|
+
n.defaultPrevented || n.button !== 0 || n.metaKey || n.ctrlKey || n.shiftKey || n.altKey || (n.preventDefault(), r.navigate(i));
|
|
164
183
|
},
|
|
165
184
|
children: e
|
|
166
185
|
}
|
|
167
186
|
);
|
|
168
187
|
}
|
|
169
|
-
function
|
|
188
|
+
function Q({
|
|
170
189
|
header: t,
|
|
171
190
|
rows: e,
|
|
172
191
|
autolink: r
|
|
173
192
|
}) {
|
|
174
|
-
const
|
|
175
|
-
return /* @__PURE__ */
|
|
176
|
-
/* @__PURE__ */
|
|
193
|
+
const i = t.length;
|
|
194
|
+
return /* @__PURE__ */ f("div", { "data-ai-table": !0, className: "my-1.5", children: [
|
|
195
|
+
/* @__PURE__ */ l("ul", { className: "flex flex-col gap-1.5 sm:hidden", children: e.map((n, s) => (
|
|
177
196
|
// biome-ignore lint/suspicious/noArrayIndexKey: static content
|
|
178
|
-
/* @__PURE__ */
|
|
197
|
+
/* @__PURE__ */ f(
|
|
179
198
|
"li",
|
|
180
199
|
{
|
|
181
200
|
className: "rounded-lg border border-black/10 bg-background/60 px-2.5 py-2 dark:border-white/10",
|
|
182
201
|
children: [
|
|
183
|
-
/* @__PURE__ */
|
|
184
|
-
n.slice(1,
|
|
185
|
-
(
|
|
202
|
+
/* @__PURE__ */ l("div", { className: "font-semibold leading-snug", children: p(n[0] ?? "", r) }),
|
|
203
|
+
n.slice(1, i).map(
|
|
204
|
+
(m, a) => m ? (
|
|
186
205
|
// biome-ignore lint/suspicious/noArrayIndexKey: static content
|
|
187
|
-
/* @__PURE__ */
|
|
206
|
+
/* @__PURE__ */ f(
|
|
188
207
|
"div",
|
|
189
208
|
{
|
|
190
209
|
className: "mt-1 grid grid-cols-[minmax(0,34%)_1fr] gap-2 text-[0.94em] leading-snug",
|
|
191
210
|
children: [
|
|
192
|
-
/* @__PURE__ */
|
|
193
|
-
/* @__PURE__ */
|
|
211
|
+
/* @__PURE__ */ l("span", { className: "text-muted-foreground", children: t[a + 1] }),
|
|
212
|
+
/* @__PURE__ */ l("span", { className: "min-w-0 break-words", children: p(m, r) })
|
|
194
213
|
]
|
|
195
214
|
},
|
|
196
215
|
a
|
|
@@ -199,31 +218,31 @@ function q({
|
|
|
199
218
|
)
|
|
200
219
|
]
|
|
201
220
|
},
|
|
202
|
-
|
|
221
|
+
s
|
|
203
222
|
)
|
|
204
223
|
)) }),
|
|
205
|
-
/* @__PURE__ */
|
|
206
|
-
/* @__PURE__ */
|
|
224
|
+
/* @__PURE__ */ l("div", { className: "hidden overflow-x-auto sm:block", children: /* @__PURE__ */ f("table", { className: "w-auto min-w-[50%] text-left", children: [
|
|
225
|
+
/* @__PURE__ */ l("thead", { children: /* @__PURE__ */ l("tr", { className: "border-b border-black/10 text-[0.85em] uppercase tracking-wide text-muted-foreground dark:border-white/10", children: t.map((n, s) => (
|
|
207
226
|
// biome-ignore lint/suspicious/noArrayIndexKey: static content
|
|
208
|
-
/* @__PURE__ */
|
|
227
|
+
/* @__PURE__ */ l("th", { className: "py-1 pr-4 font-medium", children: p(n) }, s)
|
|
209
228
|
)) }) }),
|
|
210
|
-
/* @__PURE__ */
|
|
229
|
+
/* @__PURE__ */ l("tbody", { className: "divide-y divide-black/5 dark:divide-white/10", children: e.map((n, s) => (
|
|
211
230
|
// biome-ignore lint/suspicious/noArrayIndexKey: static content
|
|
212
|
-
/* @__PURE__ */
|
|
231
|
+
/* @__PURE__ */ l("tr", { className: "align-top", children: t.map((m, a) => (
|
|
213
232
|
// biome-ignore lint/suspicious/noArrayIndexKey: static content
|
|
214
|
-
/* @__PURE__ */
|
|
215
|
-
)) },
|
|
233
|
+
/* @__PURE__ */ l("td", { className: "max-w-[28rem] py-1 pr-4", children: p(n[a] ?? "", r) }, a)
|
|
234
|
+
)) }, s)
|
|
216
235
|
)) })
|
|
217
236
|
] }) })
|
|
218
237
|
] });
|
|
219
238
|
}
|
|
220
|
-
const
|
|
221
|
-
function
|
|
222
|
-
const e =
|
|
223
|
-
return /* @__PURE__ */
|
|
224
|
-
|
|
239
|
+
const V = L(() => import("./AiChart.js").then((t) => ({ default: t.AiChart })));
|
|
240
|
+
function X({ spec: t }) {
|
|
241
|
+
const e = $(A);
|
|
242
|
+
return /* @__PURE__ */ l(
|
|
243
|
+
W,
|
|
225
244
|
{
|
|
226
|
-
fallback: /* @__PURE__ */
|
|
245
|
+
fallback: /* @__PURE__ */ l(
|
|
227
246
|
"div",
|
|
228
247
|
{
|
|
229
248
|
"data-ai-chart-loading": !0,
|
|
@@ -231,83 +250,84 @@ function U({ spec: t }) {
|
|
|
231
250
|
style: { height: t.type === "pie" ? 220 : 200 }
|
|
232
251
|
}
|
|
233
252
|
),
|
|
234
|
-
children: /* @__PURE__ */
|
|
253
|
+
children: /* @__PURE__ */ l(V, { spec: t, onPoint: e })
|
|
235
254
|
}
|
|
236
255
|
);
|
|
237
256
|
}
|
|
238
|
-
function
|
|
257
|
+
function g({ b: t, link: e, gl: r }) {
|
|
239
258
|
switch (t.kind) {
|
|
240
259
|
case "h":
|
|
241
|
-
return /* @__PURE__ */
|
|
260
|
+
return /* @__PURE__ */ l("p", { className: w("font-semibold", t.level <= 2 ? "text-[1.05em]" : ""), children: p(t.text, e, r) });
|
|
242
261
|
case "ul":
|
|
243
|
-
return /* @__PURE__ */
|
|
262
|
+
return /* @__PURE__ */ l("ul", { className: "list-disc space-y-0.5 pl-5", children: t.items.map((i, n) => (
|
|
244
263
|
// biome-ignore lint/suspicious/noArrayIndexKey: static content
|
|
245
|
-
/* @__PURE__ */
|
|
264
|
+
/* @__PURE__ */ l("li", { children: p(i, e, r) }, n)
|
|
246
265
|
)) });
|
|
247
266
|
case "ol":
|
|
248
|
-
return /* @__PURE__ */
|
|
267
|
+
return /* @__PURE__ */ l("ol", { className: "list-decimal space-y-0.5 pl-5", children: t.items.map((i, n) => (
|
|
249
268
|
// biome-ignore lint/suspicious/noArrayIndexKey: static content
|
|
250
|
-
/* @__PURE__ */
|
|
269
|
+
/* @__PURE__ */ l("li", { children: p(i, e, r) }, n)
|
|
251
270
|
)) });
|
|
252
271
|
case "code":
|
|
253
|
-
return /* @__PURE__ */
|
|
272
|
+
return /* @__PURE__ */ l("pre", { className: "overflow-x-auto rounded-md bg-black/[0.05] p-2 font-mono text-[0.9em] dark:bg-white/10", children: t.text });
|
|
254
273
|
case "table":
|
|
255
|
-
return /* @__PURE__ */
|
|
274
|
+
return /* @__PURE__ */ l(Q, { header: t.header, rows: t.rows, autolink: e });
|
|
256
275
|
case "chart":
|
|
257
|
-
return /* @__PURE__ */
|
|
276
|
+
return /* @__PURE__ */ l(X, { spec: t.spec });
|
|
258
277
|
default:
|
|
259
|
-
return /* @__PURE__ */
|
|
278
|
+
return /* @__PURE__ */ l("p", { children: p(t.text, e, r) });
|
|
260
279
|
}
|
|
261
280
|
}
|
|
262
|
-
const
|
|
263
|
-
function
|
|
264
|
-
const
|
|
265
|
-
if (n ===
|
|
266
|
-
const a =
|
|
281
|
+
const Y = { table: "Table", chart: "Chart", list: "List" };
|
|
282
|
+
function Z({ b: t, link: e, gl: r }) {
|
|
283
|
+
const i = k(() => j(t), [t]), [n, s] = S(i[0]), m = k(() => {
|
|
284
|
+
if (n === i[0]) return t;
|
|
285
|
+
const a = M(t);
|
|
267
286
|
if (!a) return t;
|
|
268
287
|
if (n === "table") return { kind: "table", header: a.header, rows: a.rows };
|
|
269
|
-
if (n === "list") return { kind: "ul", items:
|
|
270
|
-
const u =
|
|
288
|
+
if (n === "list") return { kind: "ul", items: P(a) };
|
|
289
|
+
const u = E(a);
|
|
271
290
|
return u ? { kind: "chart", spec: u } : t;
|
|
272
|
-
}, [t, n,
|
|
273
|
-
return
|
|
274
|
-
/* @__PURE__ */
|
|
291
|
+
}, [t, n, i]);
|
|
292
|
+
return i.length < 2 ? /* @__PURE__ */ l(g, { b: t, link: e, gl: r }) : /* @__PURE__ */ f("div", { "data-ai-switchable": n, children: [
|
|
293
|
+
/* @__PURE__ */ l("fieldset", { className: "mb-0.5 flex min-w-0 justify-end gap-0.5", "aria-label": "Show as", children: i.map((a) => /* @__PURE__ */ l(
|
|
275
294
|
"button",
|
|
276
295
|
{
|
|
277
296
|
type: "button",
|
|
278
|
-
onClick: () =>
|
|
297
|
+
onClick: () => s(a),
|
|
279
298
|
"aria-pressed": a === n,
|
|
280
299
|
"data-ai-format": a,
|
|
281
|
-
className:
|
|
300
|
+
className: w(
|
|
282
301
|
"rounded px-1.5 py-px text-[10.5px] font-medium transition-colors",
|
|
283
302
|
a === n ? "bg-accent text-foreground" : "text-muted-foreground hover:bg-muted hover:text-foreground"
|
|
284
303
|
),
|
|
285
|
-
children:
|
|
304
|
+
children: Y[a]
|
|
286
305
|
},
|
|
287
306
|
a
|
|
288
307
|
)) }),
|
|
289
|
-
/* @__PURE__ */
|
|
308
|
+
/* @__PURE__ */ l(g, { b: m, link: e, gl: r })
|
|
290
309
|
] });
|
|
291
310
|
}
|
|
292
|
-
const
|
|
293
|
-
function
|
|
311
|
+
const A = C(void 0);
|
|
312
|
+
function ce({
|
|
294
313
|
content: t,
|
|
295
314
|
className: e,
|
|
296
315
|
autolink: r,
|
|
297
|
-
switchable:
|
|
316
|
+
switchable: i,
|
|
298
317
|
onChartPoint: n
|
|
299
318
|
}) {
|
|
300
|
-
const
|
|
301
|
-
return /* @__PURE__ */
|
|
302
|
-
const
|
|
303
|
-
return
|
|
319
|
+
const s = k(() => G(t), [t]), m = O(), a = r ?? m != null, u = I(), h = K(), c = u.length ? { terms: u, once: /* @__PURE__ */ new Set(), href: h } : void 0;
|
|
320
|
+
return /* @__PURE__ */ l(A.Provider, { value: n, children: /* @__PURE__ */ l("div", { "data-ai-markdown": !0, className: w("space-y-1.5 [&_strong]:font-semibold", e), children: s.map((o, d) => {
|
|
321
|
+
const x = `${o.kind}-${d}`;
|
|
322
|
+
return i && ee.has(o.kind) ? /* @__PURE__ */ l(Z, { b: o, link: a, gl: c }, x) : /* @__PURE__ */ l(g, { b: o, link: a, gl: c }, x);
|
|
304
323
|
}) }) });
|
|
305
324
|
}
|
|
306
|
-
const
|
|
325
|
+
const ee = /* @__PURE__ */ new Set(["table", "chart", "ul", "ol"]);
|
|
307
326
|
export {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
327
|
+
ce as AiMarkdown,
|
|
328
|
+
y as externalHost,
|
|
329
|
+
J as inAppHref,
|
|
330
|
+
z as isSafeAppPath,
|
|
311
331
|
G as parseAiMarkdown,
|
|
312
332
|
F as parseChartSpec,
|
|
313
333
|
p as renderInline
|