zidane-gui 9.1.16 → 9.1.17
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/out/main/index.js +851 -59
- package/out/preload/index.mjs +31 -2
- package/out/renderer/assets/{43YPWK3Q-DqQmzBPu.js → 43YPWK3Q-1wyGHRhG.js} +8 -8
- package/out/renderer/assets/{45MVAN6X-CYP7xDN8.js → 45MVAN6X-CCX59Sl8.js} +7 -7
- package/out/renderer/assets/{46GJKBLZ-Co9yrG8W.js → 46GJKBLZ-BfO42B_T.js} +12 -12
- package/out/renderer/assets/{63WH7YNF-JjkWKCFV.js → 63WH7YNF-CML8-yHW.js} +10 -10
- package/out/renderer/assets/{6DDU7VKX-BbtUMWO4.js → 6DDU7VKX-CYg_yoLw.js} +8 -8
- package/out/renderer/assets/{CLQLV5VT-Ba6obVJu.js → CLQLV5VT-Bg0M-SGs.js} +8 -8
- package/out/renderer/assets/{CUSPXG5M-BeHLB3vL.js → CUSPXG5M-CsYKrsuv.js} +8 -8
- package/out/renderer/assets/{CodeEditor-DAvsCy4c.js → CodeEditor-mxUtgGJl.js} +5 -5
- package/out/renderer/assets/{ComposerEditor-CmebUdQf.js → ComposerEditor-CzlLgqm3.js} +6 -6
- package/out/renderer/assets/{D3L7O4X2-Bz5JjvM3.js → D3L7O4X2-DUIFiQQs.js} +6 -6
- package/out/renderer/assets/{D5TW5CPZ-COD7XA6N.js → D5TW5CPZ-B5G-YYi_.js} +1 -1
- package/out/renderer/assets/{DiffsTab-Cg5SMPpy.js → DiffsTab-DTkod12Z.js} +12 -12
- package/out/renderer/assets/{EGADTWYV-DnX4xYm9.js → EGADTWYV-C5ja_Lm2.js} +7 -7
- package/out/renderer/assets/{EOJSJZXM-C1MKUH-z.js → EOJSJZXM-Dda_vMqK.js} +10 -10
- package/out/renderer/assets/{EditorWorkers-BfFVQ69E.js → EditorWorkers-4yw3sh7s.js} +9 -8
- package/out/renderer/assets/{FileIcon-acads6Ac.js → FileIcon-DlpPG4Tv.js} +1 -1
- package/out/renderer/assets/{FilesTab-RbqMfCrC.js → FilesTab-DwqtloUX.js} +337 -36
- package/out/renderer/assets/{G2OEIG6X-Dtesfr7X.js → G2OEIG6X-8IWIlJoy.js} +7 -7
- package/out/renderer/assets/{GXJ2T77W-BkncFrMb.js → GXJ2T77W-K_AYpQU1.js} +8 -8
- package/out/renderer/assets/{HX3UMAK7-DyzWjT_c.js → HX3UMAK7-CXREbgl0.js} +7 -7
- package/out/renderer/assets/{IU7WZTP6-C4qRhHoM.js → IU7WZTP6-DxZaf96h.js} +1 -1
- package/out/renderer/assets/{J5J2NR2G-2GjekDt4.js → J5J2NR2G-DvD4FXRy.js} +6 -6
- package/out/renderer/assets/{JRCWTJEL-Dto8Fjzi.js → JRCWTJEL-Dl83Hlzn.js} +5 -5
- package/out/renderer/assets/{KHUP5TOH-DWatm9RV.js → KHUP5TOH-CsVBjKaO.js} +1 -1
- package/out/renderer/assets/{L74FQTH5-YWQWDmAR.js → L74FQTH5-DWSyibfN.js} +6 -6
- package/out/renderer/assets/{LAV4ZXOS-BDeemsOt.js → LAV4ZXOS-DCtpD44i.js} +8 -8
- package/out/renderer/assets/{LBIZYCRR-CuJZ9kCp.js → LBIZYCRR-DpNXkUqg.js} +9 -9
- package/out/renderer/assets/{LFFXNLRS-CYLYOq-d.js → LFFXNLRS-CfnB3vZl.js} +5 -5
- package/out/renderer/assets/{LLLWOAQD-B6r0O-b8.js → LLLWOAQD-BOJG2YQq.js} +1 -1
- package/out/renderer/assets/{LTYQZ5U5-C6Vwu29l.js → LTYQZ5U5-Dw9W0QpI.js} +8 -8
- package/out/renderer/assets/{NDSCUZ25-D49aLwGZ.js → NDSCUZ25-B7bWy0v0.js} +2 -2
- package/out/renderer/assets/{NMN3IKWL-CmFbUlVt.js → NMN3IKWL-YWUccb3M.js} +11 -11
- package/out/renderer/assets/{NMUA3R2D-BmYN27sp.js → NMUA3R2D-PM0msfx1.js} +9 -9
- package/out/renderer/assets/{NY5A6PPW-CFmWX6Y1.js → NY5A6PPW-BiV0tPIy.js} +5 -5
- package/out/renderer/assets/{OHJ2EJXK-BkSNlV9q.js → OHJ2EJXK-B1XaNGkt.js} +1 -1
- package/out/renderer/assets/{OU2GIT2H-Df8P_VMV.js → OU2GIT2H-CnRIS6XL.js} +6 -6
- package/out/renderer/assets/{PDMLSE6I-B1fxTWPk.js → PDMLSE6I-D2L4rd2W.js} +2 -2
- package/out/renderer/assets/{PJ7X32S5-jmIr_WuS.js → PJ7X32S5-BDIGjA8B.js} +7 -7
- package/out/renderer/assets/{RLLQ44NJ-Bk5ATCRc.js → RLLQ44NJ-Du6_4Ch9.js} +9 -9
- package/out/renderer/assets/{S6DWMCK5-ru17f61y.js → S6DWMCK5-BCek3BK9.js} +10 -10
- package/out/renderer/assets/{STIOTUT7-D3W8oemx.js → STIOTUT7-Di8tUtxD.js} +8 -8
- package/out/renderer/assets/{SXSLPWUD-BP8ObIM3.js → SXSLPWUD-CUkLp4Fg.js} +2 -2
- package/out/renderer/assets/{TR4WJQGX-DwQDLHm2.js → TR4WJQGX-DghxArE6.js} +1 -1
- package/out/renderer/assets/TranscriptViews-D-F4TCT7.js +28 -0
- package/out/renderer/assets/{UWRPUF3N-BefBSoyh.js → UWRPUF3N-qS1g5ho1.js} +1 -1
- package/out/renderer/assets/{VSWIZJ7B-QwUQICP_.js → VSWIZJ7B-BKZhRmsN.js} +1 -1
- package/out/renderer/assets/ViewBlock-BcCbp_nS.js +1536 -0
- package/out/renderer/assets/ViewCharts-DuQAWU2F.js +6350 -0
- package/out/renderer/assets/ViewCustom-D5CeSx32.js +240 -0
- package/out/renderer/assets/ViewExtension-q6W__eQm.js +74 -0
- package/out/renderer/assets/ViewInputs-BwIsKHHk.js +407 -0
- package/out/renderer/assets/ViewMcpApp-BJxpfIUe.js +607 -0
- package/out/renderer/assets/ViewTables-D7FxVTon.js +284 -0
- package/out/renderer/assets/{WM7NR6YK-CRccSJmx.js → WM7NR6YK-BCt1dKcj.js} +6 -6
- package/out/renderer/assets/{WXKV2YEK-AiJtxeS-.js → WXKV2YEK-C1EL6EKw.js} +5 -5
- package/out/renderer/assets/{XLHPVVFU-CISC9r_V.js → XLHPVVFU-BN2wXqoc.js} +1 -1
- package/out/renderer/assets/{YNX532HU-CY_1HOiG.js → YNX532HU-BtmHcbvF.js} +7 -7
- package/out/renderer/assets/{YUPSMAUO-Cv2Ryk3Q.js → YUPSMAUO-CyZdB_Cb.js} +1 -1
- package/out/renderer/assets/{ZFRCZTLK-xOx-Cqik.js → ZFRCZTLK-aAZ7jHr_.js} +8 -8
- package/out/renderer/assets/{ZZDR4CN3-CDsCY6PX.js → ZZDR4CN3-BdJdxId6.js} +6 -6
- package/out/renderer/assets/{core-Drnj1qQL.js → core-CPNc3zNs.js} +1 -1
- package/out/renderer/assets/{core-Cst33ux7.js → core-CZ6gd8oJ.js} +2414 -435
- package/out/renderer/assets/{file-tabs--M9K6eWf.js → file-tabs-CgISplTF.js} +10 -9
- package/out/renderer/assets/ghostty-vt-CC3key_8.wasm +0 -0
- package/out/renderer/assets/{ghostty-web-DsF2lzXq.js → ghostty-web-DoJg8mwQ.js} +3 -3
- package/out/renderer/assets/{hastToHtml-AUrFnNH_.js → hastToHtml-Lx-c_BvK.js} +1 -1
- package/out/renderer/assets/heic-to-AUnw0rrk.js +57 -0
- package/out/renderer/assets/{highlights-BWQ-BGwF.js → highlights-BkRUNyAa.js} +7 -7
- package/out/renderer/assets/{highlights-D9DV-gLr.js → highlights-DqzA57PQ.js} +4 -4
- package/out/renderer/assets/{index-DcoAavzj.js → index-2ScxmF2I.js} +336 -195
- package/out/renderer/assets/{index-DhpOdP7M.js → index-CF84dbuf.js} +1 -1
- package/out/renderer/assets/input-preview-DTTTULd2.js +5 -0
- package/out/renderer/assets/{kit-BRekmBoz.js → kit-CjkT3Ius.js} +10084 -6109
- package/out/renderer/assets/{langs-CC8eNbvY.js → langs-CDfkqznm.js} +3 -3
- package/out/renderer/assets/{lazy-DtE8TmIe.js → lazy-BrSdiwQa.js} +3 -3
- package/out/renderer/assets/{loader-BWgWjzVT.js → loader-D2zAtI-u.js} +3 -3
- package/out/renderer/assets/{pierre-theme-DkKyEYzW.js → pierre-theme-BuOZsexm.js} +9 -9
- package/out/renderer/assets/{shiki-CahOMWmD.js → shiki-Dfvytwwf.js} +8 -8
- package/out/renderer/assets/{stream-tokenizer-CtslDDLQ.js → stream-tokenizer-BVf54Cm5.js} +2 -2
- package/out/renderer/assets/{index-C5y0Nb6N.css → styles-BsuQ5hRd.css} +641 -20
- package/out/renderer/assets/theme-watch-0b-hqR9T.js +37 -0
- package/out/renderer/assets/{themes-BVPDzAaq.js → themes-DByaI0Ud.js} +6 -6
- package/out/renderer/assets/{useDetachCleanup-1eMIugni.js → useDetachCleanup-Dn-cfZgC.js} +4 -4
- package/out/renderer/assets/{useFolderChanges-Cqv3OcO_.js → useFolderChanges-Dh2Z47jL.js} +10 -8
- package/out/renderer/assets/{vendor-BpwX-s_O.js → vendor-CadCDYU0.js} +1 -1
- package/out/renderer/assets/{vendor-editor-Cx3SvGyZ.js → vendor-editor-BJIeGzeh.js} +2 -2
- package/out/renderer/assets/{vendor-motion-BgQeucLF.js → vendor-motion-u3N9isCo.js} +1 -1
- package/out/renderer/assets/{vendor-react-bPTwWURR.js → vendor-react-BSxSjatM.js} +5 -4
- package/out/renderer/assets/view-preview-B7F51KZx.js +375 -0
- package/out/renderer/assets/zoom-reset-BfXcQTFh.js +13 -0
- package/out/renderer/index.html +8 -8
- package/out/renderer/view-preview.html +23 -0
- package/package.json +2 -2
|
@@ -0,0 +1,1536 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ViewCharts-DuQAWU2F.js","./vendor-react-BSxSjatM.js","./kit-CjkT3Ius.js","./vendor-motion-u3N9isCo.js","./core-CZ6gd8oJ.js","./vendor-CadCDYU0.js","./vendor-D_E2rLzO.css","./vendor-editor-BJIeGzeh.js","./ViewTables-D7FxVTon.js","./ViewInputs-BwIsKHHk.js","./input-preview-DTTTULd2.js","./ViewCustom-D5CeSx32.js","./theme-watch-0b-hqR9T.js","./ViewMcpApp-BJxpfIUe.js","./ViewExtension-q6W__eQm.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import { r as reactExports, j as jsxRuntimeExports } from "./vendor-react-BSxSjatM.js";
|
|
3
|
+
import { eJ as VIEW_STATE_LIMITS, eK as sliderRange, eL as snapSlider, eM as controlOptions, eN as MCP_APP_NODE_TYPE, a0 as computeLineDiff, eO as VIEW_FALLBACK_TYPE, _ as __vitePreload, eP as compareChange, eB as nodePathOf, eQ as statChange, eI as VIEW_PREVIEW_GLOBAL, eR as viewRefreshEvery, C as ageStep } from "./core-CZ6gd8oJ.js";
|
|
4
|
+
import { ap as scrollRootOf, h as useViewsLabels, aq as useSettings, ar as numberFormats, d as useLabels, w as withUnit, i as isCompact, as as viewStateOf, W as INPUT_CLASS, at as ToggleSwitch, aj as Segmented, au as fillThemeVars, av as DiffLines, aw as HighlightedCode, ax as Callout, ay as Steps, az as KeyValue, aA as StatRow, t as Raised, N as Notice, aB as useViewsCustomCode, u as useViewsHost, v as viewLink, R as RoutedLink, aC as lazyPart, aD as Delta, aE as Checklist, aF as Breakdown, aG as Compare, aH as Tabs, aI as Accordion, aJ as viewImageKind, aK as Progress, aL as trueMinus, aM as Stat, Y as useOptionalModal, a3 as ViewsScopeContext, a2 as ViewsProvider, aN as LabelsProvider, aO as ModalShell, aP as useNearViewport, aQ as viewVersion, aR as viewRecordsOf, aS as heightFor, aT as viewReadsRefs, I as IconButton, aU as withHeight, aV as useMinuteTick, aW as relativeTime, a as useViewsMeta, aX as viewById, aY as streamFence } from "./kit-CjkT3Ius.js";
|
|
5
|
+
const VIEW_FRAME_NAME_MAX = 80;
|
|
6
|
+
function viewFrameName(title, alt) {
|
|
7
|
+
const line = title.trim() || (alt.split("\n").find((part) => part.trim() !== "") ?? "");
|
|
8
|
+
const plain = line.replace(/\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/^\s*(?:#{1,6}|>|[-*+])\s+/, "").replace(/\*\*|__|~~|[*`]/g, "").replace(/\s+/g, " ").trim();
|
|
9
|
+
if (!plain) return void 0;
|
|
10
|
+
if (plain.length <= VIEW_FRAME_NAME_MAX) return plain;
|
|
11
|
+
const cut = plain.slice(0, VIEW_FRAME_NAME_MAX - 1);
|
|
12
|
+
const space = cut.lastIndexOf(" ");
|
|
13
|
+
const words = space > VIEW_FRAME_NAME_MAX / 2 ? cut.slice(0, space) : cut;
|
|
14
|
+
return `${words.replace(/[\s,;:.\-]+$/, "")}…`;
|
|
15
|
+
}
|
|
16
|
+
const PARK_MARGIN = "3000px 0px";
|
|
17
|
+
const presence = /* @__PURE__ */ new Map();
|
|
18
|
+
const presenceObservers = /* @__PURE__ */ new WeakMap();
|
|
19
|
+
function presenceObserver(margin, root) {
|
|
20
|
+
const key = root ?? document;
|
|
21
|
+
let byMargin = presenceObservers.get(key);
|
|
22
|
+
if (!byMargin) presenceObservers.set(key, byMargin = /* @__PURE__ */ new Map());
|
|
23
|
+
const hit = byMargin.get(margin);
|
|
24
|
+
if (hit) return hit;
|
|
25
|
+
const io = new IntersectionObserver(
|
|
26
|
+
(entries) => {
|
|
27
|
+
for (const entry of entries) presence.get(entry.target)?.(entry.isIntersecting);
|
|
28
|
+
},
|
|
29
|
+
{ root, rootMargin: margin }
|
|
30
|
+
);
|
|
31
|
+
byMargin.set(margin, io);
|
|
32
|
+
return io;
|
|
33
|
+
}
|
|
34
|
+
function useViewportPresence(ref, margin = PARK_MARGIN) {
|
|
35
|
+
const [inView, setInView] = reactExports.useState(true);
|
|
36
|
+
reactExports.useEffect(() => {
|
|
37
|
+
const el = ref.current;
|
|
38
|
+
if (!el || typeof IntersectionObserver === "undefined") return void 0;
|
|
39
|
+
const io = presenceObserver(margin, scrollRootOf(el));
|
|
40
|
+
presence.set(el, setInView);
|
|
41
|
+
io.observe(el);
|
|
42
|
+
return () => {
|
|
43
|
+
presence.delete(el);
|
|
44
|
+
io.unobserve(el);
|
|
45
|
+
};
|
|
46
|
+
}, [ref, margin]);
|
|
47
|
+
return inView;
|
|
48
|
+
}
|
|
49
|
+
const sizes = /* @__PURE__ */ new Map();
|
|
50
|
+
let resize = null;
|
|
51
|
+
function observeSize(el, onSize) {
|
|
52
|
+
if (typeof ResizeObserver === "undefined") return () => {
|
|
53
|
+
};
|
|
54
|
+
resize ??= new ResizeObserver((entries) => {
|
|
55
|
+
for (const entry of entries) {
|
|
56
|
+
const box = entry.borderBoxSize?.[0];
|
|
57
|
+
const width = box ? box.inlineSize : entry.contentRect.width;
|
|
58
|
+
const height = box ? box.blockSize : entry.contentRect.height;
|
|
59
|
+
sizes.get(entry.target)?.(width, height);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
sizes.set(el, onSize);
|
|
63
|
+
resize.observe(el);
|
|
64
|
+
return () => {
|
|
65
|
+
sizes.delete(el);
|
|
66
|
+
resize?.unobserve(el);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const AUTO_REFRESH_MARGIN = "200px 0px";
|
|
70
|
+
function subscribeActive(onChange) {
|
|
71
|
+
window.addEventListener("focus", onChange);
|
|
72
|
+
window.addEventListener("blur", onChange);
|
|
73
|
+
document.addEventListener("visibilitychange", onChange);
|
|
74
|
+
return () => {
|
|
75
|
+
window.removeEventListener("focus", onChange);
|
|
76
|
+
window.removeEventListener("blur", onChange);
|
|
77
|
+
document.removeEventListener("visibilitychange", onChange);
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const windowActive = () => document.visibilityState === "visible" && document.hasFocus();
|
|
81
|
+
const serverActive = () => false;
|
|
82
|
+
function useWindowActive() {
|
|
83
|
+
return reactExports.useSyncExternalStore(subscribeActive, windowActive, serverActive);
|
|
84
|
+
}
|
|
85
|
+
function ViewAutoRefresh({ every, frame, refresh }) {
|
|
86
|
+
const labels = useViewsLabels();
|
|
87
|
+
const { settings } = useSettings();
|
|
88
|
+
const near = useViewportPresence(frame, AUTO_REFRESH_MARGIN);
|
|
89
|
+
const active = useWindowActive();
|
|
90
|
+
const [stopped, setStopped] = reactExports.useState(false);
|
|
91
|
+
const on = settings.viewsLiveData === true && near && active && !stopped;
|
|
92
|
+
const latest = reactExports.useRef(refresh);
|
|
93
|
+
reactExports.useEffect(() => {
|
|
94
|
+
latest.current = refresh;
|
|
95
|
+
});
|
|
96
|
+
reactExports.useEffect(() => {
|
|
97
|
+
if (!on) return void 0;
|
|
98
|
+
let busy = false;
|
|
99
|
+
const timer = setInterval(() => {
|
|
100
|
+
if (busy) return;
|
|
101
|
+
busy = true;
|
|
102
|
+
void latest.current().then((ok) => {
|
|
103
|
+
busy = false;
|
|
104
|
+
if (!ok) setStopped(true);
|
|
105
|
+
});
|
|
106
|
+
}, every * 1e3);
|
|
107
|
+
return () => clearInterval(timer);
|
|
108
|
+
}, [on, every]);
|
|
109
|
+
if (!on) return null;
|
|
110
|
+
const label = labels.viewLive(every);
|
|
111
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
112
|
+
"span",
|
|
113
|
+
{
|
|
114
|
+
role: "img",
|
|
115
|
+
"aria-label": label,
|
|
116
|
+
title: label,
|
|
117
|
+
"data-zg-view-live": "",
|
|
118
|
+
className: "shrink-0 size-1.5 mx-1 rounded-full bg-zg-success"
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
const ViewExpandedContext = reactExports.createContext(false);
|
|
123
|
+
function useViewExpanded() {
|
|
124
|
+
return reactExports.useContext(ViewExpandedContext);
|
|
125
|
+
}
|
|
126
|
+
const str = (value) => typeof value === "string" ? value : typeof value === "number" ? String(value) : void 0;
|
|
127
|
+
const num = (value) => {
|
|
128
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
129
|
+
if (typeof value === "string" && value.trim() !== "" && Number.isFinite(Number(value))) return Number(value);
|
|
130
|
+
return void 0;
|
|
131
|
+
};
|
|
132
|
+
const bool = (value) => value === true || value === "true";
|
|
133
|
+
const arr = (value) => Array.isArray(value) ? value : [];
|
|
134
|
+
function oneOf(value, options, fallback) {
|
|
135
|
+
return typeof value === "string" && options.includes(value) ? value : fallback;
|
|
136
|
+
}
|
|
137
|
+
function useViewNumbers() {
|
|
138
|
+
return numberFormats(useLabels().numberLocale);
|
|
139
|
+
}
|
|
140
|
+
function formatterOf(format, nf = numberFormats()) {
|
|
141
|
+
if (format === "compact") return (v) => nf.compact(v);
|
|
142
|
+
if (format === "percent") return (v) => nf.percent(v);
|
|
143
|
+
if (format === "number") return (v) => nf.number(v);
|
|
144
|
+
return void 0;
|
|
145
|
+
}
|
|
146
|
+
function cellText(value, format, unit, nf = numberFormats()) {
|
|
147
|
+
if (value === null || value === void 0) return "";
|
|
148
|
+
if (typeof value === "number") {
|
|
149
|
+
const text = (formatterOf(format, nf) ?? ((v) => nf.number(v)))(value);
|
|
150
|
+
return withUnit(text, unit, isCompact(text));
|
|
151
|
+
}
|
|
152
|
+
if (typeof value === "boolean") return String(value);
|
|
153
|
+
if (typeof value === "string") return withUnit(value, unit);
|
|
154
|
+
return "";
|
|
155
|
+
}
|
|
156
|
+
const ViewStateContext = reactExports.createContext(null);
|
|
157
|
+
const VIEW_CONTROL_NODES = /* @__PURE__ */ new Set(["Segmented", "Select", "Slider", "Toggle", "Search"]);
|
|
158
|
+
const keyOf = (value) => JSON.stringify(value ?? null);
|
|
159
|
+
const noSubscribe$1 = () => () => {
|
|
160
|
+
};
|
|
161
|
+
const nothing$1 = () => void 0;
|
|
162
|
+
function useViewState(host, sessionId, view, version, original) {
|
|
163
|
+
const controller = reactExports.useMemo(
|
|
164
|
+
() => view?.states?.vars.length ? viewStateOf(host, sessionId, view, version) : null,
|
|
165
|
+
[host, sessionId, view, version]
|
|
166
|
+
);
|
|
167
|
+
const snapshot = reactExports.useSyncExternalStore(
|
|
168
|
+
controller ? controller.subscribe : noSubscribe$1,
|
|
169
|
+
controller ? controller.get : nothing$1,
|
|
170
|
+
controller ? controller.get : nothing$1
|
|
171
|
+
);
|
|
172
|
+
const scope = reactExports.useMemo(
|
|
173
|
+
() => controller && snapshot ? { values: snapshot.values, set: controller.set, live: snapshot.live && !original } : null,
|
|
174
|
+
[controller, snapshot, original]
|
|
175
|
+
);
|
|
176
|
+
return { tree: snapshot?.tree, scope, waiting: snapshot?.waiting === true, error: snapshot?.error };
|
|
177
|
+
}
|
|
178
|
+
function useBound(node, fallback) {
|
|
179
|
+
const scope = reactExports.useContext(ViewStateContext);
|
|
180
|
+
const bind = str(node.props.bind) ?? "";
|
|
181
|
+
const known = scope !== null && Object.hasOwn(scope.values, bind);
|
|
182
|
+
return {
|
|
183
|
+
value: known ? scope.values[bind] : fallback,
|
|
184
|
+
set: (value) => scope?.set(bind, value),
|
|
185
|
+
live: scope?.live === true && known
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function Row({ label, children }) {
|
|
189
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "zg-view-control", "data-zg-view-control": "", children: [
|
|
190
|
+
label ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-zg-label text-[var(--zg-text-muted)]", children: label }) : null,
|
|
191
|
+
children
|
|
192
|
+
] });
|
|
193
|
+
}
|
|
194
|
+
function SegmentedControl({ node }) {
|
|
195
|
+
const labels = useViewsLabels();
|
|
196
|
+
const options = controlOptions(node);
|
|
197
|
+
const { value, set, live } = useBound(node, options[0]?.value ?? null);
|
|
198
|
+
const label = str(node.props.label);
|
|
199
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(Row, { label, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
200
|
+
Segmented,
|
|
201
|
+
{
|
|
202
|
+
size: "sm",
|
|
203
|
+
value: keyOf(value),
|
|
204
|
+
onChange: (key) => set(JSON.parse(key)),
|
|
205
|
+
ariaLabel: label ?? labels.viewStateControl,
|
|
206
|
+
className: "max-w-full overflow-x-auto",
|
|
207
|
+
options: options.map((o) => ({ value: keyOf(o.value), label: o.label, disabled: !live }))
|
|
208
|
+
}
|
|
209
|
+
) });
|
|
210
|
+
}
|
|
211
|
+
function SelectControl({ node }) {
|
|
212
|
+
const labels = useViewsLabels();
|
|
213
|
+
const options = controlOptions(node);
|
|
214
|
+
const { value, set, live } = useBound(node, options[0]?.value ?? null);
|
|
215
|
+
const label = str(node.props.label);
|
|
216
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(Row, { label, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
217
|
+
"select",
|
|
218
|
+
{
|
|
219
|
+
className: `${INPUT_CLASS} !w-auto max-w-full`,
|
|
220
|
+
"aria-label": label ?? labels.viewStateControl,
|
|
221
|
+
value: keyOf(value),
|
|
222
|
+
disabled: !live,
|
|
223
|
+
onChange: (e) => set(JSON.parse(e.target.value)),
|
|
224
|
+
children: options.map((o) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: keyOf(o.value), children: o.label }, keyOf(o.value)))
|
|
225
|
+
}
|
|
226
|
+
) });
|
|
227
|
+
}
|
|
228
|
+
function SliderControl({ node }) {
|
|
229
|
+
const labels = useViewsLabels();
|
|
230
|
+
const range = sliderRange(node.props);
|
|
231
|
+
const { value, set, live } = useBound(node, range?.min ?? 0);
|
|
232
|
+
if (!range) return null;
|
|
233
|
+
const label = str(node.props.label);
|
|
234
|
+
const unit = str(node.props.unit);
|
|
235
|
+
const current = typeof value === "number" ? value : range.min;
|
|
236
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(Row, { label, children: [
|
|
237
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
238
|
+
"input",
|
|
239
|
+
{
|
|
240
|
+
type: "range",
|
|
241
|
+
className: "zg-range w-40 max-w-full",
|
|
242
|
+
min: range.min,
|
|
243
|
+
max: range.max,
|
|
244
|
+
step: range.step,
|
|
245
|
+
value: current,
|
|
246
|
+
disabled: !live,
|
|
247
|
+
"aria-label": label ?? labels.viewStateControl,
|
|
248
|
+
onChange: (e) => set(snapSlider(Number(e.target.value), range))
|
|
249
|
+
}
|
|
250
|
+
),
|
|
251
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "zg-meta tabular-nums", children: unit ? `${current} ${unit}` : String(current) })
|
|
252
|
+
] });
|
|
253
|
+
}
|
|
254
|
+
function ToggleControl({ node }) {
|
|
255
|
+
const labels = useViewsLabels();
|
|
256
|
+
const { value, set, live } = useBound(node, false);
|
|
257
|
+
const label = str(node.props.label);
|
|
258
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "zg-view-control", "data-zg-view-control": "", children: [
|
|
259
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
260
|
+
ToggleSwitch,
|
|
261
|
+
{
|
|
262
|
+
on: value === true,
|
|
263
|
+
onChange: (on) => set(on),
|
|
264
|
+
label: label ?? labels.viewStateControl,
|
|
265
|
+
disabled: !live
|
|
266
|
+
}
|
|
267
|
+
),
|
|
268
|
+
label ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-zg-ui text-[var(--zg-text)]", children: label }) : null
|
|
269
|
+
] });
|
|
270
|
+
}
|
|
271
|
+
function SearchControl({ node }) {
|
|
272
|
+
const labels = useViewsLabels();
|
|
273
|
+
const { value, set, live } = useBound(node, "");
|
|
274
|
+
const text = typeof value === "string" ? value : "";
|
|
275
|
+
const label = str(node.props.label);
|
|
276
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(Row, { label, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
277
|
+
"input",
|
|
278
|
+
{
|
|
279
|
+
type: "search",
|
|
280
|
+
className: `${INPUT_CLASS} !w-56 max-w-full`,
|
|
281
|
+
value: text,
|
|
282
|
+
maxLength: VIEW_STATE_LIMITS.searchChars,
|
|
283
|
+
placeholder: str(node.props.placeholder) ?? labels.viewStateSearch,
|
|
284
|
+
"aria-label": label ?? str(node.props.placeholder) ?? labels.viewStateSearch,
|
|
285
|
+
disabled: !live,
|
|
286
|
+
onChange: (e) => set(e.target.value.slice(0, VIEW_STATE_LIMITS.searchChars))
|
|
287
|
+
}
|
|
288
|
+
) });
|
|
289
|
+
}
|
|
290
|
+
const ViewControl = reactExports.memo(function ViewControl2({ node }) {
|
|
291
|
+
switch (node.type) {
|
|
292
|
+
case "Segmented":
|
|
293
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(SegmentedControl, { node });
|
|
294
|
+
case "Select":
|
|
295
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(SelectControl, { node });
|
|
296
|
+
case "Slider":
|
|
297
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(SliderControl, { node });
|
|
298
|
+
case "Toggle":
|
|
299
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(ToggleControl, { node });
|
|
300
|
+
default:
|
|
301
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(SearchControl, { node });
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
const TONES = ["neutral", "info", "success", "warning", "danger"];
|
|
305
|
+
const BADGE_TONE = {
|
|
306
|
+
neutral: "zg-raised border text-[var(--zg-text-muted)]",
|
|
307
|
+
info: "bg-zg-info/15 text-zg-info",
|
|
308
|
+
success: "bg-zg-success/15 text-zg-success",
|
|
309
|
+
warning: "bg-zg-warn/15 text-zg-warn",
|
|
310
|
+
danger: "bg-zg-danger/15 text-zg-danger"
|
|
311
|
+
};
|
|
312
|
+
const STATUS_WORDS = Object.fromEntries([
|
|
313
|
+
...[
|
|
314
|
+
"paid",
|
|
315
|
+
"passed",
|
|
316
|
+
"pass",
|
|
317
|
+
"ok",
|
|
318
|
+
"success",
|
|
319
|
+
"succeeded",
|
|
320
|
+
"done",
|
|
321
|
+
"complete",
|
|
322
|
+
"completed",
|
|
323
|
+
"healthy",
|
|
324
|
+
"active",
|
|
325
|
+
"merged",
|
|
326
|
+
"shipped",
|
|
327
|
+
"delivered",
|
|
328
|
+
"resolved",
|
|
329
|
+
"approved"
|
|
330
|
+
].map((w) => [w, "success"]),
|
|
331
|
+
...[
|
|
332
|
+
"pending",
|
|
333
|
+
"queued",
|
|
334
|
+
"waiting",
|
|
335
|
+
"running",
|
|
336
|
+
"in progress",
|
|
337
|
+
"degraded",
|
|
338
|
+
"partial",
|
|
339
|
+
"review",
|
|
340
|
+
"in review",
|
|
341
|
+
"draft",
|
|
342
|
+
"on hold"
|
|
343
|
+
].map((w) => [w, "warning"]),
|
|
344
|
+
...[
|
|
345
|
+
"failed",
|
|
346
|
+
"fail",
|
|
347
|
+
"error",
|
|
348
|
+
"refunded",
|
|
349
|
+
"cancelled",
|
|
350
|
+
"canceled",
|
|
351
|
+
"rejected",
|
|
352
|
+
"expired",
|
|
353
|
+
"blocked",
|
|
354
|
+
"overdue",
|
|
355
|
+
"declined",
|
|
356
|
+
"down"
|
|
357
|
+
].map((w) => [w, "danger"]),
|
|
358
|
+
...["skipped", "unknown", "closed", "archived"].map((w) => [w, "neutral"])
|
|
359
|
+
]);
|
|
360
|
+
function statusTones(values) {
|
|
361
|
+
const distinct = new Set(values);
|
|
362
|
+
if (distinct.size < 2 || distinct.size > 8) return void 0;
|
|
363
|
+
const tones = /* @__PURE__ */ new Map();
|
|
364
|
+
for (const value of distinct) {
|
|
365
|
+
const tone = typeof value === "string" ? STATUS_WORDS[value.trim().toLowerCase()] : void 0;
|
|
366
|
+
if (!tone) return void 0;
|
|
367
|
+
tones.set(value, tone);
|
|
368
|
+
}
|
|
369
|
+
return new Set(tones.values()).size >= 2 ? tones : void 0;
|
|
370
|
+
}
|
|
371
|
+
const TEXT_TONE$1 = {
|
|
372
|
+
neutral: "text-[var(--zg-text-muted)]",
|
|
373
|
+
info: "text-zg-info",
|
|
374
|
+
success: "text-zg-success",
|
|
375
|
+
warning: "text-zg-warn",
|
|
376
|
+
danger: "text-zg-danger"
|
|
377
|
+
};
|
|
378
|
+
function BoolMark({ value }) {
|
|
379
|
+
const labels = useViewsLabels();
|
|
380
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
381
|
+
"span",
|
|
382
|
+
{
|
|
383
|
+
role: "img",
|
|
384
|
+
"aria-label": value ? labels.viewYes : labels.viewNo,
|
|
385
|
+
"data-zg-view-bool": value ? "true" : "false",
|
|
386
|
+
className: `inline-block align-[-0.125em] ${value ? "i-ph-check-bold text-zg-success" : "i-ph-minus text-[var(--zg-text-subtle)]"}`
|
|
387
|
+
}
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
function boolText(text) {
|
|
391
|
+
const word = text.trim();
|
|
392
|
+
return word === "true" ? true : word === "false" ? false : void 0;
|
|
393
|
+
}
|
|
394
|
+
const themeListeners = /* @__PURE__ */ new Set();
|
|
395
|
+
let themeObserver = null;
|
|
396
|
+
let themeVersion = 0;
|
|
397
|
+
function subscribeTheme(onChange) {
|
|
398
|
+
themeListeners.add(onChange);
|
|
399
|
+
if (!themeObserver && typeof MutationObserver !== "undefined") {
|
|
400
|
+
themeObserver = new MutationObserver(() => {
|
|
401
|
+
themeVersion++;
|
|
402
|
+
for (const listener of [...themeListeners]) listener();
|
|
403
|
+
});
|
|
404
|
+
themeObserver.observe(document.documentElement, {
|
|
405
|
+
attributes: true,
|
|
406
|
+
attributeFilter: ["style", "class", "data-theme", "data-appearance", "data-contrast"]
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
return () => {
|
|
410
|
+
themeListeners.delete(onChange);
|
|
411
|
+
if (themeListeners.size === 0 && themeObserver) {
|
|
412
|
+
themeObserver.disconnect();
|
|
413
|
+
themeObserver = null;
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
const getThemeVersion = () => themeVersion;
|
|
418
|
+
const SvgImage = reactExports.memo(function SvgImage2({ markup }) {
|
|
419
|
+
const labels = useViewsLabels();
|
|
420
|
+
const theme = reactExports.useSyncExternalStore(subscribeTheme, getThemeVersion, getThemeVersion);
|
|
421
|
+
const ref = reactExports.useRef(null);
|
|
422
|
+
const [src, setSrc] = reactExports.useState(null);
|
|
423
|
+
reactExports.useEffect(() => {
|
|
424
|
+
const root = getComputedStyle(document.documentElement);
|
|
425
|
+
const color = ref.current && getComputedStyle(ref.current).color || root.getPropertyValue("--zg-text");
|
|
426
|
+
const filled = fillThemeVars(markup, (name) => root.getPropertyValue(name), color);
|
|
427
|
+
if (typeof URL.createObjectURL !== "function") {
|
|
428
|
+
setSrc(`data:image/svg+xml;charset=utf-8,${encodeURIComponent(filled)}`);
|
|
429
|
+
return void 0;
|
|
430
|
+
}
|
|
431
|
+
const url = URL.createObjectURL(new Blob([filled], { type: "image/svg+xml" }));
|
|
432
|
+
setSrc(url);
|
|
433
|
+
return () => {
|
|
434
|
+
URL.revokeObjectURL(url);
|
|
435
|
+
};
|
|
436
|
+
}, [markup, theme]);
|
|
437
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { ref, className: "block max-w-full", children: src ? /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src, alt: labels.viewDrawing, className: "block max-w-full h-auto", draggable: false }) : null });
|
|
438
|
+
});
|
|
439
|
+
const ScopeContext = reactExports.createContext({});
|
|
440
|
+
function appIsLight() {
|
|
441
|
+
if (typeof document === "undefined") return false;
|
|
442
|
+
const scheme = getComputedStyle(document.documentElement).colorScheme ?? "";
|
|
443
|
+
return /\blight\b/.test(scheme) && !/\bdark\b/.test(scheme);
|
|
444
|
+
}
|
|
445
|
+
function customShotOf(scope, node) {
|
|
446
|
+
if (!scope?.customShots) return void 0;
|
|
447
|
+
const path = nodePathOf(scope.tree, node);
|
|
448
|
+
const shot = path ? scope.customShots[path.join(".")] : void 0;
|
|
449
|
+
if (!shot) return void 0;
|
|
450
|
+
return appIsLight() ? shot.light ?? shot.dark : shot.dark ?? shot.light;
|
|
451
|
+
}
|
|
452
|
+
const CustomScopeContext = reactExports.createContext(null);
|
|
453
|
+
const ChartPart = lazyPart(
|
|
454
|
+
() => __vitePreload(() => import("./ViewCharts-DuQAWU2F.js"), true ? __vite__mapDeps([0,1,2,3,4,5,6,7]) : void 0, import.meta.url).then((m) => m.ViewChart)
|
|
455
|
+
);
|
|
456
|
+
const NO_LAYOUT = { lead: null, mainChart: null, progressCounts: /* @__PURE__ */ new Set() };
|
|
457
|
+
const ANSWER_TYPES = /* @__PURE__ */ new Set(["StatRow", "Stat", "Headline"]);
|
|
458
|
+
const LayoutContext = reactExports.createContext(NO_LAYOUT);
|
|
459
|
+
const LEAD_TYPES = /* @__PURE__ */ new Set(["Stat", "Progress", "Trend", "Headline"]);
|
|
460
|
+
const MAIN_CHART_TYPES = /* @__PURE__ */ new Set(["BarChart", "LineChart", "AreaChart", "ScatterChart", "Trend"]);
|
|
461
|
+
function isBlank(node) {
|
|
462
|
+
return typeof node === "string" && node.trim() === "";
|
|
463
|
+
}
|
|
464
|
+
function viewLayoutOf(nodes) {
|
|
465
|
+
const parts = nodes.filter((node) => !isBlank(node) && typeof node !== "string");
|
|
466
|
+
let lead = null;
|
|
467
|
+
const firstOf = (list) => {
|
|
468
|
+
const first2 = list.find(
|
|
469
|
+
(node) => typeof node !== "string" && node.type !== "Heading" && !VIEW_CONTROL_NODES.has(node.type)
|
|
470
|
+
);
|
|
471
|
+
return first2?.type === "Stack" ? firstOf(first2.children) : first2;
|
|
472
|
+
};
|
|
473
|
+
const first = firstOf(parts);
|
|
474
|
+
if (first && LEAD_TYPES.has(first.type)) lead = first;
|
|
475
|
+
let mainChart = null;
|
|
476
|
+
const progressCounts = /* @__PURE__ */ new Set();
|
|
477
|
+
let headline = null;
|
|
478
|
+
const walk = (node, inGrid) => {
|
|
479
|
+
if (typeof node === "string") return;
|
|
480
|
+
if (node.type === "Headline" && !headline) headline = node;
|
|
481
|
+
if (!mainChart && !inGrid && MAIN_CHART_TYPES.has(node.type)) mainChart = node;
|
|
482
|
+
if (node.type === "Progress" && typeof node.props.value === "number")
|
|
483
|
+
progressCounts.add(`${node.props.value}/${typeof node.props.max === "number" ? node.props.max : 100}`);
|
|
484
|
+
for (const child of node.children) walk(child, inGrid || node.type === "Grid" || node.type === "StatRow");
|
|
485
|
+
};
|
|
486
|
+
for (const node of parts) walk(node, false);
|
|
487
|
+
if (headline) lead = headline;
|
|
488
|
+
const answered = headline !== null || first !== void 0 && ANSWER_TYPES.has(first.type);
|
|
489
|
+
return { lead, mainChart, progressCounts, ...answered ? { answered } : {} };
|
|
490
|
+
}
|
|
491
|
+
const TablePart = lazyPart(() => __vitePreload(() => import("./ViewTables-D7FxVTon.js"), true ? __vite__mapDeps([8,1,2,3,4,5,6,7]) : void 0, import.meta.url).then((m) => m.ViewTable));
|
|
492
|
+
const InputPart = lazyPart(
|
|
493
|
+
() => __vitePreload(() => import("./ViewInputs-BwIsKHHk.js"), true ? __vite__mapDeps([9,1,4,5,6,2,3,7,10]) : void 0, import.meta.url).then((m) => m.ViewInput)
|
|
494
|
+
);
|
|
495
|
+
function InputNode({ node }) {
|
|
496
|
+
const scope = reactExports.useContext(CustomScopeContext);
|
|
497
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx(PartSkeleton, {}), children: /* @__PURE__ */ jsxRuntimeExports.jsx(InputPart, { node, scope }) });
|
|
498
|
+
}
|
|
499
|
+
const CustomPart = lazyPart(
|
|
500
|
+
() => __vitePreload(() => import("./ViewCustom-D5CeSx32.js"), true ? __vite__mapDeps([11,1,4,5,6,2,3,7,12]) : void 0, import.meta.url).then((m) => m.CustomFrameView)
|
|
501
|
+
);
|
|
502
|
+
const McpAppPart = lazyPart(
|
|
503
|
+
() => __vitePreload(() => import("./ViewMcpApp-BJxpfIUe.js"), true ? __vite__mapDeps([13,1,4,5,6,2,3,7,12,11]) : void 0, import.meta.url).then((m) => m.McpAppFrameView)
|
|
504
|
+
);
|
|
505
|
+
const DiagramPart = lazyPart(
|
|
506
|
+
() => __vitePreload(() => import("./kit-CjkT3Ius.js").then((n) => n.i1), true ? __vite__mapDeps([2,1,3,4,5,6,7]) : void 0, import.meta.url).then((m) => m.MermaidDiagram)
|
|
507
|
+
);
|
|
508
|
+
const ExtensionPart = lazyPart(
|
|
509
|
+
() => __vitePreload(() => import("./ViewExtension-q6W__eQm.js"), true ? __vite__mapDeps([14,1,4,5,6,2,3,7]) : void 0, import.meta.url).then((m) => m.ExtensionViewNode)
|
|
510
|
+
);
|
|
511
|
+
const CHART_TYPES = /* @__PURE__ */ new Set(["BarChart", "LineChart", "AreaChart", "ScatterChart", "Sparkline", "Trend"]);
|
|
512
|
+
const INPUT_TYPES = /* @__PURE__ */ new Set(["Choice", "Form", "Action"]);
|
|
513
|
+
const GAP = { none: "gap-0", small: "gap-2", medium: "gap-4", large: "gap-6" };
|
|
514
|
+
const GAPS = ["none", "small", "medium", "large"];
|
|
515
|
+
const ALIGN = { start: "items-start", center: "items-center", end: "items-end", stretch: "items-stretch" };
|
|
516
|
+
const TEXT_TONE = {
|
|
517
|
+
default: "text-[var(--zg-text)]",
|
|
518
|
+
muted: "text-[var(--zg-text-muted)]",
|
|
519
|
+
info: "text-zg-info",
|
|
520
|
+
success: "text-zg-success",
|
|
521
|
+
warning: "text-zg-warn",
|
|
522
|
+
danger: "text-zg-danger"
|
|
523
|
+
};
|
|
524
|
+
const HEADING = [
|
|
525
|
+
"text-zg-body leading-5 font-semibold",
|
|
526
|
+
"text-zg-body leading-5 font-semibold",
|
|
527
|
+
"text-zg-ui leading-5 font-semibold",
|
|
528
|
+
"text-zg-ui leading-5 font-medium"
|
|
529
|
+
];
|
|
530
|
+
function textOf$1(children) {
|
|
531
|
+
return children.map((child) => typeof child === "string" ? child : textOf$1(child.children)).join("");
|
|
532
|
+
}
|
|
533
|
+
function PartSkeleton({ height = 48, label }) {
|
|
534
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
535
|
+
"div",
|
|
536
|
+
{
|
|
537
|
+
role: label ? "status" : void 0,
|
|
538
|
+
"aria-label": label,
|
|
539
|
+
className: "zg-view-skeleton rounded-zg-md",
|
|
540
|
+
style: { height },
|
|
541
|
+
"data-zg-view-skeleton": ""
|
|
542
|
+
}
|
|
543
|
+
);
|
|
544
|
+
}
|
|
545
|
+
function headingSays(node, title) {
|
|
546
|
+
if (!title || !node || typeof node === "string" || node.type !== "Heading") return false;
|
|
547
|
+
const text = textOf$1(node.children).replace(/\s+/g, " ").trim();
|
|
548
|
+
return text === title || title.endsWith("…") && text.startsWith(title.slice(0, -1));
|
|
549
|
+
}
|
|
550
|
+
const ViewNodes = reactExports.memo(function ViewNodes2({ nodes, scope, custom, frameTitle }) {
|
|
551
|
+
const skipFirst = headingSays(nodes[0], frameTitle);
|
|
552
|
+
const lead = reactExports.useMemo(() => {
|
|
553
|
+
const node = nodes[0];
|
|
554
|
+
if (skipFirst || !node || typeof node === "string" || node.type !== "Stack") return node;
|
|
555
|
+
const at = node.children.findIndex((child) => !isBlank(child));
|
|
556
|
+
return at >= 0 && headingSays(node.children[at], frameTitle) ? { ...node, children: node.children.map((child, i) => i === at ? "" : child) } : node;
|
|
557
|
+
}, [nodes, skipFirst, frameTitle]);
|
|
558
|
+
const layout = reactExports.useMemo(() => viewLayoutOf(nodes), [nodes]);
|
|
559
|
+
let body = /* @__PURE__ */ jsxRuntimeExports.jsx(LayoutContext.Provider, { value: layout, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-6 min-w-0", "data-zg-view-nodes": "", children: nodes.map(
|
|
560
|
+
(node, i) => i === 0 ? skipFirst ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(ViewNodeView, { node: lead }, i) : /* @__PURE__ */ jsxRuntimeExports.jsx(ViewNodeView, { node }, i)
|
|
561
|
+
) }) });
|
|
562
|
+
if (custom) body = /* @__PURE__ */ jsxRuntimeExports.jsx(CustomScopeContext.Provider, { value: custom, children: body });
|
|
563
|
+
return scope ? /* @__PURE__ */ jsxRuntimeExports.jsx(ScopeContext.Provider, { value: scope, children: body }) : body;
|
|
564
|
+
});
|
|
565
|
+
function Children({ nodes }) {
|
|
566
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: nodes.map((node, i) => /* @__PURE__ */ jsxRuntimeExports.jsx(ViewNodeView, { node }, i)) });
|
|
567
|
+
}
|
|
568
|
+
function ViewLink({ href, children }) {
|
|
569
|
+
const labels = useViewsLabels();
|
|
570
|
+
const url = viewLink(href);
|
|
571
|
+
if (!url) return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children });
|
|
572
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
573
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
574
|
+
RoutedLink,
|
|
575
|
+
{
|
|
576
|
+
href: url.href,
|
|
577
|
+
source: "transcript",
|
|
578
|
+
className: "text-[var(--zg-accent)] hover:text-[var(--zg-accent-hover)] underline underline-offset-2",
|
|
579
|
+
children
|
|
580
|
+
}
|
|
581
|
+
),
|
|
582
|
+
" ",
|
|
583
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "zg-meta", children: labels.viewLinkDomain(url.hostname) })
|
|
584
|
+
] });
|
|
585
|
+
}
|
|
586
|
+
function ViewImage({ source, alt }) {
|
|
587
|
+
const labels = useViewsLabels();
|
|
588
|
+
const host = useViewsHost();
|
|
589
|
+
const scope = reactExports.useContext(CustomScopeContext);
|
|
590
|
+
const kind = viewImageKind(source);
|
|
591
|
+
const inlined = kind && kind !== "data" ? scope?.images?.[source] : void 0;
|
|
592
|
+
const ask = kind && kind !== "data" && !inlined && host?.image && scope ? source : null;
|
|
593
|
+
const sessionId = scope?.sessionId;
|
|
594
|
+
const [read, setRead] = reactExports.useState(null);
|
|
595
|
+
reactExports.useEffect(() => {
|
|
596
|
+
if (!ask || !sessionId || !host?.image) return void 0;
|
|
597
|
+
let live = true;
|
|
598
|
+
void host.image(sessionId, ask).then((url2) => {
|
|
599
|
+
if (live) setRead({ source: ask, url: url2 });
|
|
600
|
+
});
|
|
601
|
+
return () => {
|
|
602
|
+
live = false;
|
|
603
|
+
};
|
|
604
|
+
}, [ask, sessionId, host]);
|
|
605
|
+
const url = kind === "data" ? source : inlined ?? (read && read.source === ask ? read.url : null);
|
|
606
|
+
if (!url) return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-zg-label text-[var(--zg-text-muted)]", children: labels.viewImageHidden(alt) });
|
|
607
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: url, alt, className: "block max-w-full h-auto rounded-zg-sm", draggable: false });
|
|
608
|
+
}
|
|
609
|
+
function patchLines(patch) {
|
|
610
|
+
const lines = [];
|
|
611
|
+
for (const line of patch.split("\n")) {
|
|
612
|
+
if (/^(?:---|\+\+\+|@@|diff |index )/.test(line)) continue;
|
|
613
|
+
if (line.startsWith("+")) lines.push({ op: "add", text: line.slice(1) });
|
|
614
|
+
else if (line.startsWith("-")) lines.push({ op: "remove", text: line.slice(1) });
|
|
615
|
+
else lines.push({ op: "context", text: line.startsWith(" ") ? line.slice(1) : line });
|
|
616
|
+
}
|
|
617
|
+
return lines;
|
|
618
|
+
}
|
|
619
|
+
function Title({ text }) {
|
|
620
|
+
return text ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-zg-body leading-5 font-semibold text-[var(--zg-text)] mb-2", children: text }) : null;
|
|
621
|
+
}
|
|
622
|
+
function UnknownNode({ node }) {
|
|
623
|
+
const labels = useViewsLabels();
|
|
624
|
+
const name = node.type === VIEW_FALLBACK_TYPE ? str(node.props.name) ?? node.type : node.type;
|
|
625
|
+
const alt = str(node.props.alt);
|
|
626
|
+
if (node.type === VIEW_FALLBACK_TYPE && node.props.reason === "invalid") {
|
|
627
|
+
const problem = str(node.props.problem);
|
|
628
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-zg-view-invalid": name, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Notice, { tone: "warning", compact: true, ...problem ? { detail: problem } : {}, children: labels.viewInvalid(name) }) });
|
|
629
|
+
}
|
|
630
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "zg-view-unknown rounded-zg-md px-3 py-2 flex flex-col gap-1", "data-zg-view-unknown": name, children: [
|
|
631
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-zg-label text-[var(--zg-text-muted)]", children: labels.viewUnknown(name) }),
|
|
632
|
+
node.children.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-zg-ui", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Children, { nodes: node.children }) }) : null,
|
|
633
|
+
alt ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-zg-label text-[var(--zg-text-muted)]", children: alt }) : null
|
|
634
|
+
] });
|
|
635
|
+
}
|
|
636
|
+
function PlacedNode({ node }) {
|
|
637
|
+
const { placed } = reactExports.useContext(ScopeContext);
|
|
638
|
+
const labels = useViewsLabels();
|
|
639
|
+
const ref = str(node.props.ref) ?? "";
|
|
640
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: placed ? placed(ref) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-zg-label text-[var(--zg-text-muted)]", children: labels.viewMissingRef(ref) }) });
|
|
641
|
+
}
|
|
642
|
+
function CustomStatic({ p, note }) {
|
|
643
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(Raised, { radius: "md", className: "px-3 py-2 flex flex-col gap-1", "data-zg-view-custom": "static", children: [
|
|
644
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-zg-ui font-medium", children: str(p.title) }),
|
|
645
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-zg-ui text-[var(--zg-text-muted)]", children: str(p.alt) }),
|
|
646
|
+
note ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-zg-label text-[var(--zg-text-muted)]", children: note }) : null
|
|
647
|
+
] });
|
|
648
|
+
}
|
|
649
|
+
function CustomShotImage({ p, url, note }) {
|
|
650
|
+
const labels = useViewsLabels();
|
|
651
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2 min-w-0", "data-zg-view-custom": "shot", children: [
|
|
652
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
653
|
+
"img",
|
|
654
|
+
{
|
|
655
|
+
src: url,
|
|
656
|
+
alt: labels.viewCustomSnapshot(str(p.title) ?? ""),
|
|
657
|
+
className: "block max-w-full h-auto rounded-zg-md",
|
|
658
|
+
draggable: false
|
|
659
|
+
}
|
|
660
|
+
),
|
|
661
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "sr-only", children: str(p.alt) }),
|
|
662
|
+
note ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-zg-label text-[var(--zg-text-muted)]", children: note }) : null
|
|
663
|
+
] });
|
|
664
|
+
}
|
|
665
|
+
function McpAppNode({ node }) {
|
|
666
|
+
const labels = useViewsLabels();
|
|
667
|
+
const on = useViewsCustomCode();
|
|
668
|
+
const host = useViewsHost();
|
|
669
|
+
const scope = reactExports.useContext(CustomScopeContext);
|
|
670
|
+
const p = node.props;
|
|
671
|
+
if (!on) return /* @__PURE__ */ jsxRuntimeExports.jsx(CustomStatic, { p, note: labels.viewMcpAppOff });
|
|
672
|
+
if (!host?.customFrame || !host.appRequest) return /* @__PURE__ */ jsxRuntimeExports.jsx(CustomStatic, { p, note: labels.viewMcpAppUnsupported });
|
|
673
|
+
if (!scope) return /* @__PURE__ */ jsxRuntimeExports.jsx(CustomStatic, { p, note: labels.viewPending });
|
|
674
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx(CustomStatic, { p }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(McpAppPart, { node, scope }) });
|
|
675
|
+
}
|
|
676
|
+
function CustomNode({ node }) {
|
|
677
|
+
const labels = useViewsLabels();
|
|
678
|
+
const on = useViewsCustomCode();
|
|
679
|
+
const host = useViewsHost();
|
|
680
|
+
const scope = reactExports.useContext(CustomScopeContext);
|
|
681
|
+
const p = node.props;
|
|
682
|
+
const shot = !on || !host?.customFrame ? customShotOf(scope, node) : void 0;
|
|
683
|
+
if (shot && !host?.customFrame) return /* @__PURE__ */ jsxRuntimeExports.jsx(CustomShotImage, { p, url: shot });
|
|
684
|
+
if (!on)
|
|
685
|
+
return shot ? /* @__PURE__ */ jsxRuntimeExports.jsx(CustomShotImage, { p, url: shot, note: labels.viewCustomOff }) : /* @__PURE__ */ jsxRuntimeExports.jsx(CustomStatic, { p, note: labels.viewCustomOff });
|
|
686
|
+
if (!host?.customFrame) return /* @__PURE__ */ jsxRuntimeExports.jsx(CustomStatic, { p, note: labels.viewCustomUnsupported });
|
|
687
|
+
const stored = customShotOf(scope, node);
|
|
688
|
+
if (!scope) return /* @__PURE__ */ jsxRuntimeExports.jsx(CustomStatic, { p, note: labels.viewPending });
|
|
689
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: stored ? /* @__PURE__ */ jsxRuntimeExports.jsx(CustomShotImage, { p, url: stored }) : /* @__PURE__ */ jsxRuntimeExports.jsx(CustomStatic, { p }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(CustomPart, { node, scope }) });
|
|
690
|
+
}
|
|
691
|
+
function ExtensionNode({ node }) {
|
|
692
|
+
const scope = reactExports.useContext(CustomScopeContext);
|
|
693
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
694
|
+
reactExports.Suspense,
|
|
695
|
+
{
|
|
696
|
+
fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-zg-ui whitespace-pre-wrap min-w-0", "data-zg-view-extension": node.type, children: node.alt ?? "" }),
|
|
697
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(ExtensionPart, { node, scope })
|
|
698
|
+
}
|
|
699
|
+
);
|
|
700
|
+
}
|
|
701
|
+
function deltaFormat(format, unit, nf) {
|
|
702
|
+
if (!format && !unit) return void 0;
|
|
703
|
+
return (abs) => {
|
|
704
|
+
const text = format ? format(abs) : nf.number(abs, 1);
|
|
705
|
+
return withUnit(text, unit, isCompact(text));
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
function groupDigits(text, nf) {
|
|
709
|
+
return text.replace(/(?<![\w.,\-/#])\d{5,}(?![\w.,])/g, (digits) => nf.number(Number(digits)));
|
|
710
|
+
}
|
|
711
|
+
function StatNode({ p, headline = false }) {
|
|
712
|
+
const nf = useViewNumbers();
|
|
713
|
+
const raw = p.value;
|
|
714
|
+
const text = str(raw) ?? "";
|
|
715
|
+
const bare = typeof raw === "string" && /^-?\d{4,}(?:\.\d+)?$/.test(text.trim()) ? Number(text) : void 0;
|
|
716
|
+
const unit = str(p.unit);
|
|
717
|
+
const amount = typeof raw === "number" ? raw : bare;
|
|
718
|
+
const cents = amount !== void 0 && !Number.isInteger(amount) && /^[$€£¥₹]$/.test(unit?.trim() ?? "");
|
|
719
|
+
const value = amount !== void 0 ? trueMinus(cents ? nf.number(amount, 2, true) : nf.number(amount)) : trueMinus(text);
|
|
720
|
+
const change = statChange(p);
|
|
721
|
+
const delta = change?.delta;
|
|
722
|
+
const format = formatterOf(change?.format, nf);
|
|
723
|
+
const trend = arr(p.trend).filter((v) => typeof v === "number");
|
|
724
|
+
const goodWhen = oneOf(p.goodWhen, ["up", "down", "neutral"], "up");
|
|
725
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
726
|
+
Stat,
|
|
727
|
+
{
|
|
728
|
+
tone: oneOf(p.tone, TONES, "neutral"),
|
|
729
|
+
size: headline ? "headline" : "stat",
|
|
730
|
+
label: str(p.label) ?? "",
|
|
731
|
+
value: (
|
|
732
|
+
// A word unit (tokens, ms) reads as a quieter word after the big number; a sign ($, %) sticks to it.
|
|
733
|
+
unit && /[a-z]/i.test(unit) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
734
|
+
value,
|
|
735
|
+
" ",
|
|
736
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-zg-ui font-normal text-[var(--zg-text-muted)]", "data-zg-stat-unit": "", children: unit })
|
|
737
|
+
] }) : withUnit(value, unit, isCompact(value))
|
|
738
|
+
),
|
|
739
|
+
sub: str(p.sub) || trend.length > 1 ? /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "flex flex-col gap-1", children: [
|
|
740
|
+
str(p.sub) ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: groupDigits(str(p.sub), nf) }) : null,
|
|
741
|
+
trend.length > 1 ? /* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx(PartSkeleton, { height: 24 }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChartPart, { node: { type: "Sparkline", props: { values: trend }, children: [] } }) }) : null
|
|
742
|
+
] }) : void 0,
|
|
743
|
+
delta: delta !== void 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx(Delta, { value: delta, ...format ? { format } : {}, good: goodWhen === "neutral" ? "none" : goodWhen }) : void 0
|
|
744
|
+
}
|
|
745
|
+
);
|
|
746
|
+
}
|
|
747
|
+
function DeltaNode({ p }) {
|
|
748
|
+
const nf = useViewNumbers();
|
|
749
|
+
const value = num(p.value) ?? 0;
|
|
750
|
+
const format = deltaFormat(formatterOf(p.format, nf), str(p.unit), nf);
|
|
751
|
+
const goodWhen = oneOf(p.goodWhen, ["up", "down", "neutral"], "up");
|
|
752
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(Delta, { value, ...format ? { format } : {}, good: goodWhen === "neutral" ? "none" : goodWhen });
|
|
753
|
+
}
|
|
754
|
+
function CellText({ value }) {
|
|
755
|
+
const nf = useViewNumbers();
|
|
756
|
+
if (typeof value === "boolean") return /* @__PURE__ */ jsxRuntimeExports.jsx(BoolMark, { value });
|
|
757
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: cellText(value, void 0, void 0, nf) });
|
|
758
|
+
}
|
|
759
|
+
function CompareNode({ p }) {
|
|
760
|
+
const nf = useViewNumbers();
|
|
761
|
+
const format = formatterOf(p.format, nf);
|
|
762
|
+
const goodWhen = oneOf(p.goodWhen, ["up", "down"], "down");
|
|
763
|
+
const given = num(p.noise);
|
|
764
|
+
const noise = given !== void 0 && given >= 0 ? given : void 0;
|
|
765
|
+
const rows = arr(p.rows).flatMap((row) => {
|
|
766
|
+
if (!Array.isArray(row) || row.length < 3) return [];
|
|
767
|
+
const before = num(row[1]);
|
|
768
|
+
const after = num(row[2]);
|
|
769
|
+
if (before === void 0 || after === void 0) return [];
|
|
770
|
+
return [{ label: str(row[0]) ?? "", before, after, ...compareChange(before, after, goodWhen, noise) }];
|
|
771
|
+
});
|
|
772
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
773
|
+
Compare,
|
|
774
|
+
{
|
|
775
|
+
rows,
|
|
776
|
+
goodWhen,
|
|
777
|
+
...str(p.title) ? { title: str(p.title) } : {},
|
|
778
|
+
...str(p.unit) ? { unit: str(p.unit) } : {},
|
|
779
|
+
...format ? { format } : {},
|
|
780
|
+
...str(p.before) ? { before: str(p.before) } : {},
|
|
781
|
+
...str(p.after) ? { after: str(p.after) } : {},
|
|
782
|
+
mode: p.mode === "table" ? "table" : "bars"
|
|
783
|
+
}
|
|
784
|
+
);
|
|
785
|
+
}
|
|
786
|
+
function BreakdownNode({ p }) {
|
|
787
|
+
const nf = useViewNumbers();
|
|
788
|
+
const format = formatterOf(p.format, nf);
|
|
789
|
+
const parts = arr(p.parts).flatMap((part) => {
|
|
790
|
+
if (!Array.isArray(part) || part.length < 2) return [];
|
|
791
|
+
const value = num(part[1]);
|
|
792
|
+
return value === void 0 ? [] : [[str(part[0]) ?? "", value]];
|
|
793
|
+
});
|
|
794
|
+
const total = num(p.total);
|
|
795
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
796
|
+
Breakdown,
|
|
797
|
+
{
|
|
798
|
+
parts,
|
|
799
|
+
...str(p.title) ? { title: str(p.title) } : {},
|
|
800
|
+
...str(p.unit) ? { unit: str(p.unit) } : {},
|
|
801
|
+
...format ? { format } : {},
|
|
802
|
+
...total !== void 0 ? { total } : {},
|
|
803
|
+
...str(p.highlight) !== void 0 ? { highlight: str(p.highlight) } : {},
|
|
804
|
+
...num(p.top) !== void 0 ? { top: num(p.top) } : {},
|
|
805
|
+
mode: p.mode === "stacked" ? "stacked" : "bars"
|
|
806
|
+
}
|
|
807
|
+
);
|
|
808
|
+
}
|
|
809
|
+
function ProgressNode({ p, headline = false }) {
|
|
810
|
+
const nf = useViewNumbers();
|
|
811
|
+
const format = formatterOf(p.format, nf);
|
|
812
|
+
const max = num(p.max);
|
|
813
|
+
const threshold = num(p.threshold);
|
|
814
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
815
|
+
Progress,
|
|
816
|
+
{
|
|
817
|
+
value: num(p.value) ?? 0,
|
|
818
|
+
tone: oneOf(p.tone, TONES, "neutral"),
|
|
819
|
+
size: headline ? "headline" : "stat",
|
|
820
|
+
...threshold !== void 0 ? { threshold } : {},
|
|
821
|
+
...max !== void 0 && max > 0 ? { max } : {},
|
|
822
|
+
...str(p.label) ? { label: str(p.label) } : {},
|
|
823
|
+
...str(p.unit) ? { unit: str(p.unit) } : {},
|
|
824
|
+
...format ? { format } : {}
|
|
825
|
+
}
|
|
826
|
+
);
|
|
827
|
+
}
|
|
828
|
+
function ChecklistNode({ p }) {
|
|
829
|
+
const groups = arr(p.groups).flatMap((group) => {
|
|
830
|
+
if (!group || typeof group !== "object" || Array.isArray(group)) return [];
|
|
831
|
+
const items = arr(group.items).flatMap((item) => {
|
|
832
|
+
if (!item || typeof item !== "object" || Array.isArray(item)) return [];
|
|
833
|
+
const note = str(item.note);
|
|
834
|
+
return [
|
|
835
|
+
{
|
|
836
|
+
label: str(item.label) ?? "",
|
|
837
|
+
status: oneOf(item.status, ["done", "failed", "pending"], "pending"),
|
|
838
|
+
...note ? { note } : {}
|
|
839
|
+
}
|
|
840
|
+
];
|
|
841
|
+
});
|
|
842
|
+
return [{ label: str(group.label) ?? "", items }];
|
|
843
|
+
});
|
|
844
|
+
const { progressCounts } = reactExports.useContext(LayoutContext);
|
|
845
|
+
const all = groups.flatMap((group) => group.items);
|
|
846
|
+
const said = progressCounts.has(`${all.filter((item) => item.status === "done").length}/${all.length}`);
|
|
847
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
848
|
+
Checklist,
|
|
849
|
+
{
|
|
850
|
+
groups,
|
|
851
|
+
summary: !said,
|
|
852
|
+
...str(p.title) ? { title: str(p.title) } : {},
|
|
853
|
+
...str(p.groupLabel) ? { groupLabel: str(p.groupLabel) } : {}
|
|
854
|
+
}
|
|
855
|
+
);
|
|
856
|
+
}
|
|
857
|
+
function DiagramNode({ p }) {
|
|
858
|
+
const source = str(p.source) ?? "";
|
|
859
|
+
const still = typeof window !== "undefined" && VIEW_PREVIEW_GLOBAL in window;
|
|
860
|
+
const highlight = arr(p.highlight).flatMap((id) => typeof id === "string" && id ? [id] : []);
|
|
861
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0", "data-zg-view-diagram": "", children: [
|
|
862
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Title, { text: str(p.title) }),
|
|
863
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx(PartSkeleton, { height: 160 }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(DiagramPart, { code: source, view: true, still, ...highlight.length > 0 ? { highlight } : {} }) })
|
|
864
|
+
] });
|
|
865
|
+
}
|
|
866
|
+
function PanelsNode({ node }) {
|
|
867
|
+
const panels = node.children.filter((child) => typeof child !== "string" || child.trim() !== "");
|
|
868
|
+
const items = arr(node.props.items).map((item, i) => {
|
|
869
|
+
const o = item && typeof item === "object" && !Array.isArray(item) ? item : {};
|
|
870
|
+
const child = panels[i];
|
|
871
|
+
return {
|
|
872
|
+
id: String(i),
|
|
873
|
+
title: str(o.title) ?? "",
|
|
874
|
+
label: str(o.label) ?? "",
|
|
875
|
+
open: bool(o.open),
|
|
876
|
+
content: child === void 0 ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(ViewNodeView, { node: child })
|
|
877
|
+
};
|
|
878
|
+
});
|
|
879
|
+
if (node.type === "Tabs") return /* @__PURE__ */ jsxRuntimeExports.jsx(Tabs, { items: items.map(({ id, label, content }) => ({ id, label, content })) });
|
|
880
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
881
|
+
Accordion,
|
|
882
|
+
{
|
|
883
|
+
items: items.map(({ id, title, open, content }) => ({
|
|
884
|
+
id,
|
|
885
|
+
title,
|
|
886
|
+
content,
|
|
887
|
+
...open ? { defaultOpen: true } : {}
|
|
888
|
+
}))
|
|
889
|
+
}
|
|
890
|
+
);
|
|
891
|
+
}
|
|
892
|
+
const WIDE_TYPES = /* @__PURE__ */ new Set([
|
|
893
|
+
"BarChart",
|
|
894
|
+
"LineChart",
|
|
895
|
+
"AreaChart",
|
|
896
|
+
"ScatterChart",
|
|
897
|
+
"Trend",
|
|
898
|
+
"Panel",
|
|
899
|
+
"Table",
|
|
900
|
+
"Compare",
|
|
901
|
+
"Breakdown",
|
|
902
|
+
"Diagram"
|
|
903
|
+
]);
|
|
904
|
+
function ChartNode({ node }) {
|
|
905
|
+
const { mainChart, lead, answered } = reactExports.useContext(LayoutContext);
|
|
906
|
+
const main = mainChart === node;
|
|
907
|
+
const quiet = node.type === "Trend" && answered === true && lead !== node;
|
|
908
|
+
const fallback = num(node.props.height) ?? (node.type === "Sparkline" ? 24 : main ? 270 : 210);
|
|
909
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx(PartSkeleton, { height: fallback }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
910
|
+
ChartPart,
|
|
911
|
+
{
|
|
912
|
+
node,
|
|
913
|
+
...main ? { main: true } : {},
|
|
914
|
+
...lead === node ? { headline: true } : {},
|
|
915
|
+
...quiet ? { quiet: true } : {}
|
|
916
|
+
}
|
|
917
|
+
) });
|
|
918
|
+
}
|
|
919
|
+
function LeadNode({ node }) {
|
|
920
|
+
const { lead } = reactExports.useContext(LayoutContext);
|
|
921
|
+
const headline = lead === node;
|
|
922
|
+
return node.type === "Progress" ? /* @__PURE__ */ jsxRuntimeExports.jsx(ProgressNode, { p: node.props, headline }) : /* @__PURE__ */ jsxRuntimeExports.jsx(StatNode, { p: node.props, headline });
|
|
923
|
+
}
|
|
924
|
+
function HeadlineNode({ p, nodes }) {
|
|
925
|
+
const answer = textOf$1(nodes).trim();
|
|
926
|
+
const { sub, ...figure } = p;
|
|
927
|
+
const context = str(sub);
|
|
928
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col min-w-0", "data-zg-view-headline": "", children: [
|
|
929
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(StatNode, { p: { ...figure, label: p.label ?? "" }, headline: true }),
|
|
930
|
+
answer ? /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "m-0 mt-2 max-w-[65ch] text-zg-body leading-5 text-[var(--zg-text)]", "data-zg-headline-answer": "", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Children, { nodes }) }) : null,
|
|
931
|
+
context ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
932
|
+
"p",
|
|
933
|
+
{
|
|
934
|
+
className: "m-0 mt-1 max-w-[65ch] text-zg-label leading-4 text-[var(--zg-text-muted)]",
|
|
935
|
+
"data-zg-headline-sub": "",
|
|
936
|
+
children: context
|
|
937
|
+
}
|
|
938
|
+
) : null
|
|
939
|
+
] });
|
|
940
|
+
}
|
|
941
|
+
const InTileContext = reactExports.createContext(false);
|
|
942
|
+
function PanelNode({ node }) {
|
|
943
|
+
const p = node.props;
|
|
944
|
+
const title = str(p.title);
|
|
945
|
+
const caption = str(p.caption);
|
|
946
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
947
|
+
"section",
|
|
948
|
+
{
|
|
949
|
+
className: "zg-tile flex flex-col min-w-0 p-4",
|
|
950
|
+
style: p.span === "full" ? { gridColumn: "1 / -1" } : void 0,
|
|
951
|
+
"aria-label": title,
|
|
952
|
+
"data-zg-view-panel": "",
|
|
953
|
+
children: [
|
|
954
|
+
title || caption ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1 mb-2 min-w-0", children: [
|
|
955
|
+
title ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-zg-body leading-5 font-semibold text-[var(--zg-text)] truncate", children: title }) : null,
|
|
956
|
+
caption ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-zg-label leading-4 text-[var(--zg-text-muted)]", children: caption }) : null
|
|
957
|
+
] }) : null,
|
|
958
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-4 min-w-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx(InTileContext.Provider, { value: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Children, { nodes: node.children }) }) })
|
|
959
|
+
]
|
|
960
|
+
}
|
|
961
|
+
);
|
|
962
|
+
}
|
|
963
|
+
const ViewNodeView = reactExports.memo(function ViewNodeView2({ node }) {
|
|
964
|
+
const inTile = reactExports.useContext(InTileContext);
|
|
965
|
+
if (typeof node === "string") return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "whitespace-pre-wrap", children: node });
|
|
966
|
+
const p = node.props;
|
|
967
|
+
if (CHART_TYPES.has(node.type)) return /* @__PURE__ */ jsxRuntimeExports.jsx(ChartNode, { node });
|
|
968
|
+
if (INPUT_TYPES.has(node.type)) return /* @__PURE__ */ jsxRuntimeExports.jsx(InputNode, { node });
|
|
969
|
+
if (node.type === "State") return null;
|
|
970
|
+
if (VIEW_CONTROL_NODES.has(node.type)) return /* @__PURE__ */ jsxRuntimeExports.jsx(ViewControl, { node });
|
|
971
|
+
if (node.type.includes(".")) return /* @__PURE__ */ jsxRuntimeExports.jsx(ExtensionNode, { node });
|
|
972
|
+
switch (node.type) {
|
|
973
|
+
case "Stack": {
|
|
974
|
+
const horizontal = p.direction === "horizontal";
|
|
975
|
+
const gap = GAP[oneOf(p.gap, GAPS, "medium")];
|
|
976
|
+
const align = ALIGN[oneOf(p.align, ["start", "center", "end", "stretch"], horizontal ? "center" : "stretch")];
|
|
977
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
978
|
+
"div",
|
|
979
|
+
{
|
|
980
|
+
className: `flex min-w-0 ${horizontal ? "flex-row" : "flex-col"} ${bool(p.wrap) ? "flex-wrap" : ""} ${gap} ${align}`,
|
|
981
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Children, { nodes: node.children })
|
|
982
|
+
}
|
|
983
|
+
);
|
|
984
|
+
}
|
|
985
|
+
case "Grid": {
|
|
986
|
+
const columns = Math.min(6, Math.max(1, Math.round(num(p.columns) ?? 2)));
|
|
987
|
+
const wide = node.children.some((child) => typeof child !== "string" && WIDE_TYPES.has(child.type));
|
|
988
|
+
const least = wide ? "22.5rem" : "8rem";
|
|
989
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
990
|
+
"div",
|
|
991
|
+
{
|
|
992
|
+
className: `grid min-w-0 ${GAP[oneOf(p.gap, GAPS, wide ? "large" : "medium")]}`,
|
|
993
|
+
style: {
|
|
994
|
+
gridTemplateColumns: `repeat(auto-fit, minmax(min(100%, max(${least}, calc(100% / ${columns} - 1.5rem))), 1fr))`
|
|
995
|
+
},
|
|
996
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Children, { nodes: node.children })
|
|
997
|
+
}
|
|
998
|
+
);
|
|
999
|
+
}
|
|
1000
|
+
case "Panel":
|
|
1001
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(PanelNode, { node });
|
|
1002
|
+
case "Headline":
|
|
1003
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(HeadlineNode, { p, nodes: node.children });
|
|
1004
|
+
case "Box": {
|
|
1005
|
+
const tone = oneOf(p.tone, TONES, "neutral");
|
|
1006
|
+
const inner = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
1007
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Title, { text: str(p.title) }),
|
|
1008
|
+
p.image !== void 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx(ViewImage, { source: p.image, alt: str(p.imageAlt) ?? "" }) : null,
|
|
1009
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-2 min-w-0 text-zg-ui", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Children, { nodes: node.children }) })
|
|
1010
|
+
] });
|
|
1011
|
+
return tone === "neutral" ? /* @__PURE__ */ jsxRuntimeExports.jsx(Raised, { radius: "md", className: "px-4 py-3 min-w-0", children: inner }) : (
|
|
1012
|
+
// A toned box is flat beside a bar of its tone: a wash over a whole block is too loud.
|
|
1013
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "zg-callout-bar pl-3 py-0.5 min-w-0", "data-tone": tone, children: inner })
|
|
1014
|
+
);
|
|
1015
|
+
}
|
|
1016
|
+
case "Text": {
|
|
1017
|
+
const tone = TEXT_TONE[oneOf(p.tone, ["default", "muted", "info", "success", "warning", "danger"], "default")];
|
|
1018
|
+
const size = { small: "text-zg-label", medium: "text-zg-body", large: "text-zg-title" }[oneOf(p.size, ["small", "medium", "large"], "medium")];
|
|
1019
|
+
const said = boolText(textOf$1(node.children));
|
|
1020
|
+
const content = said === void 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx(Children, { nodes: node.children }) : /* @__PURE__ */ jsxRuntimeExports.jsx(BoolMark, { value: said });
|
|
1021
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1022
|
+
"p",
|
|
1023
|
+
{
|
|
1024
|
+
className: `m-0 whitespace-pre-wrap break-words ${tone} ${size} ${p.weight === "bold" ? "font-semibold" : ""} ${bool(p.mono) ? "font-mono" : ""}`,
|
|
1025
|
+
children: typeof p.href === "string" ? /* @__PURE__ */ jsxRuntimeExports.jsx(ViewLink, { href: p.href, children: content }) : content
|
|
1026
|
+
}
|
|
1027
|
+
);
|
|
1028
|
+
}
|
|
1029
|
+
case "Heading": {
|
|
1030
|
+
const level = Math.min(4, Math.max(1, Math.round(num(p.level) ?? 2)));
|
|
1031
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { role: "heading", "aria-level": level + 1, className: `m-0 text-[var(--zg-text)] ${HEADING[level - 1]}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Children, { nodes: node.children }) });
|
|
1032
|
+
}
|
|
1033
|
+
case "Divider": {
|
|
1034
|
+
const label = str(p.label);
|
|
1035
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { role: "separator", className: "flex items-center gap-2", children: [
|
|
1036
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "flex-1 border-t border-[var(--zg-hairline)]" }),
|
|
1037
|
+
label ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-zg-label text-[var(--zg-text-muted)]", children: label }) : null,
|
|
1038
|
+
label ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "flex-1 border-t border-[var(--zg-hairline)]" }) : null
|
|
1039
|
+
] });
|
|
1040
|
+
}
|
|
1041
|
+
case "Tabs":
|
|
1042
|
+
case "Accordion":
|
|
1043
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(PanelsNode, { node });
|
|
1044
|
+
case "StatRow":
|
|
1045
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(StatRow, { tiles: !inTile, children: node.children.filter((child) => typeof child !== "string" || child.trim() !== "").map((child, i) => /* @__PURE__ */ jsxRuntimeExports.jsx(ViewNodeView2, { node: child }, i)) });
|
|
1046
|
+
case "Compare":
|
|
1047
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(CompareNode, { p });
|
|
1048
|
+
case "Breakdown":
|
|
1049
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(BreakdownNode, { p });
|
|
1050
|
+
case "Progress":
|
|
1051
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(LeadNode, { node });
|
|
1052
|
+
case "Checklist":
|
|
1053
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(ChecklistNode, { p });
|
|
1054
|
+
case "Diagram":
|
|
1055
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(DiagramNode, { p });
|
|
1056
|
+
case "Stat":
|
|
1057
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(LeadNode, { node });
|
|
1058
|
+
case "Delta":
|
|
1059
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(DeltaNode, { p });
|
|
1060
|
+
case "KeyValue": {
|
|
1061
|
+
const items = arr(p.rows).flatMap(
|
|
1062
|
+
(row, i) => Array.isArray(row) ? [{ id: String(i), label: str(row[0]) ?? "", value: /* @__PURE__ */ jsxRuntimeExports.jsx(CellText, { value: row[1] }) }] : []
|
|
1063
|
+
);
|
|
1064
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0", children: [
|
|
1065
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Title, { text: str(p.title) }),
|
|
1066
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(KeyValue, { items, size: "ui" })
|
|
1067
|
+
] });
|
|
1068
|
+
}
|
|
1069
|
+
case "Table":
|
|
1070
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx(PartSkeleton, { height: 120 }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(TablePart, { node }) });
|
|
1071
|
+
case "Steps": {
|
|
1072
|
+
const items = arr(p.items).flatMap((item, i) => {
|
|
1073
|
+
if (!item || typeof item !== "object" || Array.isArray(item)) return [];
|
|
1074
|
+
const status = oneOf(item.status, ["done", "active", "pending", "failed", "skipped"], "pending");
|
|
1075
|
+
return [
|
|
1076
|
+
{
|
|
1077
|
+
id: String(i),
|
|
1078
|
+
title: str(item.title) ?? "",
|
|
1079
|
+
...str(item.detail) ? { detail: str(item.detail) } : {},
|
|
1080
|
+
status
|
|
1081
|
+
}
|
|
1082
|
+
];
|
|
1083
|
+
});
|
|
1084
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(Steps, { items });
|
|
1085
|
+
}
|
|
1086
|
+
case "Callout":
|
|
1087
|
+
return (
|
|
1088
|
+
// Flat: the view's frame is already the box.
|
|
1089
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Callout, { tone: oneOf(p.tone, TONES, "neutral"), variant: "bar", title: str(p.title), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Children, { nodes: node.children }) })
|
|
1090
|
+
);
|
|
1091
|
+
case "Badge": {
|
|
1092
|
+
const tone = oneOf(p.tone, TONES, "neutral");
|
|
1093
|
+
const badge = /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `inline-flex items-center rounded-full px-1.5 text-zg-meta font-medium ${BADGE_TONE[tone]}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Children, { nodes: node.children }) });
|
|
1094
|
+
return typeof p.href === "string" ? /* @__PURE__ */ jsxRuntimeExports.jsx(ViewLink, { href: p.href, children: badge }) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: badge });
|
|
1095
|
+
}
|
|
1096
|
+
case "Code":
|
|
1097
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0", children: [
|
|
1098
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Title, { text: str(p.title) }),
|
|
1099
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(HighlightedCode, { code: str(p.code) ?? textOf$1(node.children), language: str(p.language) ?? "plaintext" })
|
|
1100
|
+
] });
|
|
1101
|
+
case "Diff": {
|
|
1102
|
+
const patch = str(p.patch);
|
|
1103
|
+
const lines = patch !== void 0 ? patchLines(patch) : computeLineDiff(str(p.before) ?? "", str(p.after) ?? "");
|
|
1104
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0", children: [
|
|
1105
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Title, { text: str(p.title) }),
|
|
1106
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(DiffLines, { lines, maxHeight: 360, className: "rounded-zg-md" })
|
|
1107
|
+
] });
|
|
1108
|
+
}
|
|
1109
|
+
case "Refresh":
|
|
1110
|
+
return null;
|
|
1111
|
+
case "View":
|
|
1112
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(PlacedNode, { node });
|
|
1113
|
+
case "Custom":
|
|
1114
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(CustomNode, { node });
|
|
1115
|
+
case MCP_APP_NODE_TYPE:
|
|
1116
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(McpAppNode, { node });
|
|
1117
|
+
case "svg":
|
|
1118
|
+
return typeof p.markup === "string" ? /* @__PURE__ */ jsxRuntimeExports.jsx(SvgImage, { markup: p.markup }) : /* @__PURE__ */ jsxRuntimeExports.jsx(UnknownNode, { node });
|
|
1119
|
+
default:
|
|
1120
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(UnknownNode, { node });
|
|
1121
|
+
}
|
|
1122
|
+
});
|
|
1123
|
+
function ExpandedStateNodes({ content, stored }) {
|
|
1124
|
+
const host = useViewsHost();
|
|
1125
|
+
const { sessionId, view, version, original } = stored;
|
|
1126
|
+
const state = useViewState(host, sessionId, view, version, original);
|
|
1127
|
+
const tree = original ? view.original : state.tree ?? view.tree;
|
|
1128
|
+
const custom = reactExports.useMemo(
|
|
1129
|
+
() => ({ sessionId, viewId: view.id, tree, original }),
|
|
1130
|
+
[sessionId, view.id, tree, original]
|
|
1131
|
+
);
|
|
1132
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1133
|
+
"div",
|
|
1134
|
+
{
|
|
1135
|
+
className: "zg-view-body min-w-0",
|
|
1136
|
+
"data-zg-view-waiting": state.waiting ? "" : void 0,
|
|
1137
|
+
"aria-busy": state.waiting || void 0,
|
|
1138
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(ViewStateContext.Provider, { value: state.scope, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1139
|
+
ViewNodes,
|
|
1140
|
+
{
|
|
1141
|
+
nodes: tree.children,
|
|
1142
|
+
...content.frameTitle ? { frameTitle: content.frameTitle } : {},
|
|
1143
|
+
...content.scope ? { scope: content.scope } : {},
|
|
1144
|
+
custom
|
|
1145
|
+
}
|
|
1146
|
+
) })
|
|
1147
|
+
}
|
|
1148
|
+
);
|
|
1149
|
+
}
|
|
1150
|
+
function useExpandView(id) {
|
|
1151
|
+
const modal = useOptionalModal();
|
|
1152
|
+
const host = useViewsHost();
|
|
1153
|
+
const scope = reactExports.useContext(ViewsScopeContext);
|
|
1154
|
+
const labels = useLabels();
|
|
1155
|
+
const open = reactExports.useCallback(
|
|
1156
|
+
(content) => {
|
|
1157
|
+
if (!modal) return;
|
|
1158
|
+
const key = `view:${id}`;
|
|
1159
|
+
let body = /* @__PURE__ */ jsxRuntimeExports.jsx(ViewExpandedContext.Provider, { value: true, children: content.stored ? /* @__PURE__ */ jsxRuntimeExports.jsx(ExpandedStateNodes, { content, stored: content.stored }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1160
|
+
ViewNodes,
|
|
1161
|
+
{
|
|
1162
|
+
nodes: content.tree.children,
|
|
1163
|
+
...content.frameTitle ? { frameTitle: content.frameTitle } : {},
|
|
1164
|
+
...content.scope ? { scope: content.scope } : {},
|
|
1165
|
+
...content.custom ? { custom: content.custom } : {}
|
|
1166
|
+
}
|
|
1167
|
+
) });
|
|
1168
|
+
body = /* @__PURE__ */ jsxRuntimeExports.jsx(ViewsScopeContext.Provider, { value: scope, children: body });
|
|
1169
|
+
if (host) body = /* @__PURE__ */ jsxRuntimeExports.jsx(ViewsProvider, { host, children: body });
|
|
1170
|
+
modal.open(
|
|
1171
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(LabelsProvider, { labels, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ModalShell, { title: content.title, size: "xxlarge", onClose: () => modal.close(key), children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "min-w-0", "data-zg-view-expanded": id, children: body }) }) }),
|
|
1172
|
+
{ id: key }
|
|
1173
|
+
);
|
|
1174
|
+
},
|
|
1175
|
+
[modal, host, scope, labels, id]
|
|
1176
|
+
);
|
|
1177
|
+
return modal ? open : null;
|
|
1178
|
+
}
|
|
1179
|
+
const DEFAULT_HEIGHT = 160;
|
|
1180
|
+
const HEIGHTS_DEBOUNCE_MS = 500;
|
|
1181
|
+
const MAX_DEPTH = 2;
|
|
1182
|
+
let lastWidth = 720;
|
|
1183
|
+
const noSubscribe = () => () => {
|
|
1184
|
+
};
|
|
1185
|
+
const nothing = () => void 0;
|
|
1186
|
+
function useViewRecord(host, sessionId, id, version, enabled) {
|
|
1187
|
+
const records = host ? viewRecordsOf(host) : null;
|
|
1188
|
+
const subscribe = reactExports.useCallback(
|
|
1189
|
+
(onChange) => records ? records.subscribe(sessionId, id, version, onChange) : () => {
|
|
1190
|
+
},
|
|
1191
|
+
[records, sessionId, id, version]
|
|
1192
|
+
);
|
|
1193
|
+
const get = reactExports.useCallback(() => records?.peek(sessionId, id, version), [records, sessionId, id, version]);
|
|
1194
|
+
const state = reactExports.useSyncExternalStore(
|
|
1195
|
+
records ? subscribe : noSubscribe,
|
|
1196
|
+
records ? get : nothing,
|
|
1197
|
+
records ? get : nothing
|
|
1198
|
+
);
|
|
1199
|
+
const missing = state === void 0;
|
|
1200
|
+
reactExports.useEffect(() => {
|
|
1201
|
+
if (enabled && missing) records?.load(sessionId, id, version);
|
|
1202
|
+
}, [enabled, missing, records, sessionId, id, version]);
|
|
1203
|
+
return state;
|
|
1204
|
+
}
|
|
1205
|
+
function errorDetail(error) {
|
|
1206
|
+
return "message" in error ? error.message : void 0;
|
|
1207
|
+
}
|
|
1208
|
+
function ViewFrame({
|
|
1209
|
+
title,
|
|
1210
|
+
header,
|
|
1211
|
+
children,
|
|
1212
|
+
frameRef,
|
|
1213
|
+
id,
|
|
1214
|
+
cornerControls = false
|
|
1215
|
+
}) {
|
|
1216
|
+
const labels = useViewsLabels();
|
|
1217
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1218
|
+
"div",
|
|
1219
|
+
{
|
|
1220
|
+
ref: frameRef,
|
|
1221
|
+
role: "figure",
|
|
1222
|
+
"aria-label": title ? labels.viewFrame(title) : labels.viewUntitled,
|
|
1223
|
+
"data-zg-view": id ?? "",
|
|
1224
|
+
className: `group relative zg-view zg-tray rounded-zg-lg my-2 p-4 flex flex-col gap-2 ${cornerControls ? "pt-8" : ""}`,
|
|
1225
|
+
children: [
|
|
1226
|
+
header,
|
|
1227
|
+
children
|
|
1228
|
+
]
|
|
1229
|
+
}
|
|
1230
|
+
);
|
|
1231
|
+
}
|
|
1232
|
+
function useRefreshedText(at) {
|
|
1233
|
+
const labels = useViewsLabels();
|
|
1234
|
+
useMinuteTick();
|
|
1235
|
+
if (at === void 0) return void 0;
|
|
1236
|
+
const now = Date.now();
|
|
1237
|
+
const when = relativeTime(at, now);
|
|
1238
|
+
return ageStep(at, now, 7).kind === "duration" ? labels.viewRefreshedAgo(when) : labels.viewRefreshedAt(when);
|
|
1239
|
+
}
|
|
1240
|
+
function textOf(children) {
|
|
1241
|
+
return children.map((child) => typeof child === "string" ? child : textOf(child.children)).join("").trim();
|
|
1242
|
+
}
|
|
1243
|
+
function showsTitle(tree, title) {
|
|
1244
|
+
if (!tree || title === "") return false;
|
|
1245
|
+
const shows = (children) => children.some((node) => {
|
|
1246
|
+
if (typeof node === "string" || node.type === "Heading") return false;
|
|
1247
|
+
const p = node.props;
|
|
1248
|
+
if (p.title === title || p.caption === title || node.type === "Stat" && p.label === title) return true;
|
|
1249
|
+
if ((node.type === "Text" || node.type === "Callout") && textOf(node.children) === title) return true;
|
|
1250
|
+
return shows(node.children);
|
|
1251
|
+
});
|
|
1252
|
+
return shows(tree.children);
|
|
1253
|
+
}
|
|
1254
|
+
const sameMeta = (a, b) => a.sessionId === b.sessionId && a.meta.id === b.meta.id && viewVersion(a.meta) === viewVersion(b.meta) && a.meta.hasErrors === b.meta.hasErrors && a.meta.title === b.meta.title && a.meta.alt === b.meta.alt;
|
|
1255
|
+
const StoredViewBlock = reactExports.memo(function StoredViewBlock2({ sessionId, meta }) {
|
|
1256
|
+
const host = useViewsHost();
|
|
1257
|
+
const labels = useViewsLabels();
|
|
1258
|
+
const frame = reactExports.useRef(null);
|
|
1259
|
+
const body = reactExports.useRef(null);
|
|
1260
|
+
const near = useNearViewport(frame);
|
|
1261
|
+
const present = useViewportPresence(frame);
|
|
1262
|
+
const version = viewVersion(meta);
|
|
1263
|
+
const record = useViewRecord(host, sessionId, meta.id, version, near);
|
|
1264
|
+
const [width, setWidth] = reactExports.useState(lastWidth);
|
|
1265
|
+
const widthRef = reactExports.useRef(width);
|
|
1266
|
+
const [measured, setMeasured] = reactExports.useState(null);
|
|
1267
|
+
const [original, setOriginal] = reactExports.useState(false);
|
|
1268
|
+
const [busy, setBusy] = reactExports.useState(false);
|
|
1269
|
+
const [refreshError, setRefreshError] = reactExports.useState(null);
|
|
1270
|
+
const heights = reactExports.useRef(meta.heights);
|
|
1271
|
+
const shown = record?.status === "ready" ? { view: record.view, version } : record?.status === "failed" || record?.status === "missing" || !host ? void 0 : viewRecordsOf(host).latest(sessionId, meta.id);
|
|
1272
|
+
const view = shown?.view;
|
|
1273
|
+
const state = useViewState(host, sessionId, view, shown?.version ?? version, original);
|
|
1274
|
+
const drawn = near && present && view !== void 0;
|
|
1275
|
+
const reserved = measured ?? heightFor(meta.heights, width) ?? DEFAULT_HEIGHT;
|
|
1276
|
+
reactExports.useEffect(() => {
|
|
1277
|
+
const el = frame.current;
|
|
1278
|
+
if (!el) return void 0;
|
|
1279
|
+
return observeSize(el, (w) => {
|
|
1280
|
+
lastWidth = w;
|
|
1281
|
+
widthRef.current = w;
|
|
1282
|
+
setWidth(w);
|
|
1283
|
+
});
|
|
1284
|
+
}, []);
|
|
1285
|
+
const setHeights = host?.setHeights;
|
|
1286
|
+
reactExports.useEffect(() => {
|
|
1287
|
+
const el = body.current;
|
|
1288
|
+
if (!drawn || !el) return void 0;
|
|
1289
|
+
let timer;
|
|
1290
|
+
const stop = observeSize(el, (_, h) => {
|
|
1291
|
+
if (h <= 0) return;
|
|
1292
|
+
setMeasured(h);
|
|
1293
|
+
if (!setHeights) return;
|
|
1294
|
+
clearTimeout(timer);
|
|
1295
|
+
timer = setTimeout(() => {
|
|
1296
|
+
const next = withHeight(heights.current, widthRef.current, h);
|
|
1297
|
+
if (!next) return;
|
|
1298
|
+
heights.current = next;
|
|
1299
|
+
void setHeights(sessionId, meta.id, next);
|
|
1300
|
+
}, HEIGHTS_DEBOUNCE_MS);
|
|
1301
|
+
});
|
|
1302
|
+
return () => {
|
|
1303
|
+
stop();
|
|
1304
|
+
clearTimeout(timer);
|
|
1305
|
+
};
|
|
1306
|
+
}, [drawn, setHeights, sessionId, meta.id]);
|
|
1307
|
+
const title = viewFrameName(meta.title, meta.alt);
|
|
1308
|
+
const refresh = host?.refresh && view && viewReadsRefs(view) ? host.refresh : void 0;
|
|
1309
|
+
const onRefresh = async () => {
|
|
1310
|
+
if (!refresh) return false;
|
|
1311
|
+
setBusy(true);
|
|
1312
|
+
setRefreshError(null);
|
|
1313
|
+
const result = await refresh(sessionId, meta.id);
|
|
1314
|
+
setBusy(false);
|
|
1315
|
+
if (!result.ok) setRefreshError(result.error);
|
|
1316
|
+
return result.ok;
|
|
1317
|
+
};
|
|
1318
|
+
const every = refresh && view && !original ? viewRefreshEvery(view.tree) : void 0;
|
|
1319
|
+
const live = every !== void 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx(ViewAutoRefresh, { every, frame, refresh: onRefresh }) : null;
|
|
1320
|
+
const errors = view ? view.errors.filter((error) => error.level === "error") : [];
|
|
1321
|
+
const scope = useScope(sessionId, 0);
|
|
1322
|
+
const shownTree = view ? original ? view.original : state.tree ?? view.tree : void 0;
|
|
1323
|
+
const stateValues = state.scope?.values;
|
|
1324
|
+
const custom = reactExports.useMemo(
|
|
1325
|
+
() => shownTree && view ? customScope(sessionId, meta.id, view, shownTree, original, stateValues) : void 0,
|
|
1326
|
+
[shownTree, sessionId, meta.id, original, view, stateValues]
|
|
1327
|
+
);
|
|
1328
|
+
const refreshedText = useRefreshedText(meta.refreshedAt);
|
|
1329
|
+
const titled = meta.title !== "" && !showsTitle(shownTree, meta.title);
|
|
1330
|
+
const reveal = `transition-opacity ${original ? "" : "opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`;
|
|
1331
|
+
const tip = (label) => refreshedText ? `${label}. ${refreshedText}` : label;
|
|
1332
|
+
const historyButton = meta.refreshedAt !== void 0 && view ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1333
|
+
IconButton,
|
|
1334
|
+
{
|
|
1335
|
+
size: "sm",
|
|
1336
|
+
icon: "i-ph-clock-counter-clockwise",
|
|
1337
|
+
active: original,
|
|
1338
|
+
"aria-pressed": original,
|
|
1339
|
+
label: original ? labels.viewShowLatest : labels.viewShowOriginal,
|
|
1340
|
+
title: tip(original ? labels.viewShowLatest : labels.viewShowOriginal),
|
|
1341
|
+
onClick: () => setOriginal((on) => !on)
|
|
1342
|
+
}
|
|
1343
|
+
) : null;
|
|
1344
|
+
const refreshButton = refresh ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1345
|
+
IconButton,
|
|
1346
|
+
{
|
|
1347
|
+
size: "sm",
|
|
1348
|
+
icon: busy ? "i-ph-arrow-clockwise animate-spin" : "i-ph-arrow-clockwise",
|
|
1349
|
+
disabled: busy,
|
|
1350
|
+
label: busy ? labels.viewRefreshing : labels.viewRefresh,
|
|
1351
|
+
title: tip(busy ? labels.viewRefreshing : labels.viewRefresh),
|
|
1352
|
+
onClick: () => void onRefresh()
|
|
1353
|
+
}
|
|
1354
|
+
) : null;
|
|
1355
|
+
const expand = useExpandView(meta.id);
|
|
1356
|
+
const expandButton = expand && shownTree ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1357
|
+
IconButton,
|
|
1358
|
+
{
|
|
1359
|
+
size: "sm",
|
|
1360
|
+
icon: "i-ph-arrows-out-simple",
|
|
1361
|
+
label: labels.viewExpand,
|
|
1362
|
+
title: labels.viewExpand,
|
|
1363
|
+
onClick: () => expand({
|
|
1364
|
+
title: title ?? labels.viewUntitled,
|
|
1365
|
+
frameTitle: meta.title,
|
|
1366
|
+
tree: shownTree,
|
|
1367
|
+
scope,
|
|
1368
|
+
...custom ? { custom } : {},
|
|
1369
|
+
...view ? { stored: { sessionId, view, version, original } } : {}
|
|
1370
|
+
})
|
|
1371
|
+
}
|
|
1372
|
+
) : null;
|
|
1373
|
+
const controls = historyButton || refreshButton || expandButton ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
1374
|
+
live,
|
|
1375
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `flex items-center gap-0.5 shrink-0 ${reveal}`, "data-zg-view-controls": "", children: [
|
|
1376
|
+
historyButton,
|
|
1377
|
+
refreshButton,
|
|
1378
|
+
expandButton
|
|
1379
|
+
] })
|
|
1380
|
+
] }) : null;
|
|
1381
|
+
const gapControls = historyButton !== null || refreshButton !== null;
|
|
1382
|
+
const header = titled ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 min-w-0 min-h-6 -my-0.5", "data-zg-view-head": "", children: [
|
|
1383
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 min-w-0 text-zg-body leading-5 font-semibold text-[var(--zg-text)] truncate", children: meta.title }),
|
|
1384
|
+
controls
|
|
1385
|
+
] }) : controls ? (
|
|
1386
|
+
// No title row: the buttons sit in the frame's top gap, so they never cover a legend or a chart.
|
|
1387
|
+
// Full screen alone keeps no gap: it shows on hover only, on a raised chip over the corner.
|
|
1388
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1389
|
+
"div",
|
|
1390
|
+
{
|
|
1391
|
+
className: `absolute top-1 right-1.5 z-1 flex items-center${gapControls ? "" : ` zg-raised rounded-zg-md ${reveal}`}`,
|
|
1392
|
+
children: controls
|
|
1393
|
+
}
|
|
1394
|
+
)
|
|
1395
|
+
) : null;
|
|
1396
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(ViewFrame, { title, header, frameRef: frame, id: meta.id, cornerControls: !titled && gapControls, children: [
|
|
1397
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1398
|
+
"div",
|
|
1399
|
+
{
|
|
1400
|
+
ref: body,
|
|
1401
|
+
className: "zg-view-body min-w-0",
|
|
1402
|
+
style: drawn ? void 0 : { height: reserved },
|
|
1403
|
+
"data-zg-view-body": drawn ? "drawn" : "waiting",
|
|
1404
|
+
"data-zg-view-waiting": state.waiting ? "" : void 0,
|
|
1405
|
+
"aria-busy": state.waiting || void 0,
|
|
1406
|
+
children: drawn ? /* @__PURE__ */ jsxRuntimeExports.jsx(ViewStateContext.Provider, { value: state.scope, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1407
|
+
ViewNodes,
|
|
1408
|
+
{
|
|
1409
|
+
nodes: (shownTree ?? view.tree).children,
|
|
1410
|
+
scope,
|
|
1411
|
+
frameTitle: meta.title,
|
|
1412
|
+
...custom ? { custom } : {}
|
|
1413
|
+
},
|
|
1414
|
+
`${meta.id}:${original}`
|
|
1415
|
+
) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "m-0 text-zg-label text-[var(--zg-text-muted)] overflow-hidden h-full", children: meta.alt })
|
|
1416
|
+
}
|
|
1417
|
+
),
|
|
1418
|
+
drawn ? /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "sr-only", children: meta.alt }) : null,
|
|
1419
|
+
record?.status === "failed" ? /* @__PURE__ */ jsxRuntimeExports.jsx(Notice, { tone: "error", compact: true, ...errorDetail(record.error) ? { detail: errorDetail(record.error) } : {}, children: labels.viewLoadFailed }) : null,
|
|
1420
|
+
errors.length > 0 || meta.hasErrors && !view ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1421
|
+
Notice,
|
|
1422
|
+
{
|
|
1423
|
+
tone: "error",
|
|
1424
|
+
compact: true,
|
|
1425
|
+
...errors.length > 0 ? { detail: errors.map((error) => error.message).join("\n") } : {},
|
|
1426
|
+
children: labels.viewErrors
|
|
1427
|
+
}
|
|
1428
|
+
) : null,
|
|
1429
|
+
state.error && !original ? /* @__PURE__ */ jsxRuntimeExports.jsx(Notice, { tone: "error", compact: true, ...errorDetail(state.error) ? { detail: errorDetail(state.error) } : {}, children: state.error.code === "unsupported" ? labels.viewStateUnsupported : labels.viewStateFailed }) : null,
|
|
1430
|
+
refreshError ? /* @__PURE__ */ jsxRuntimeExports.jsx(Notice, { tone: "error", compact: true, ...errorDetail(refreshError) ? { detail: errorDetail(refreshError) } : {}, children: refreshError.code === "unsupported" ? labels.viewRefreshUnsupported : labels.viewRefreshFailed }) : null
|
|
1431
|
+
] });
|
|
1432
|
+
}, sameMeta);
|
|
1433
|
+
function customScope(sessionId, viewId, view, tree, original, values) {
|
|
1434
|
+
return {
|
|
1435
|
+
sessionId,
|
|
1436
|
+
viewId,
|
|
1437
|
+
tree,
|
|
1438
|
+
original,
|
|
1439
|
+
...view.images ? { images: view.images } : {},
|
|
1440
|
+
...view.customShots && tree === view.tree ? { customShots: view.customShots } : {},
|
|
1441
|
+
...values && !original && tree !== view.tree ? { state: values } : {}
|
|
1442
|
+
};
|
|
1443
|
+
}
|
|
1444
|
+
function useScope(sessionId, depth) {
|
|
1445
|
+
const [scope] = reactExports.useState(
|
|
1446
|
+
() => sessionId && depth < MAX_DEPTH ? { placed: (ref) => /* @__PURE__ */ jsxRuntimeExports.jsx(PlacedViewTree, { sessionId, id: ref, depth: depth + 1 }) } : void 0
|
|
1447
|
+
);
|
|
1448
|
+
return scope;
|
|
1449
|
+
}
|
|
1450
|
+
function PlacedViewTree({ sessionId, id, depth }) {
|
|
1451
|
+
const host = useViewsHost();
|
|
1452
|
+
const labels = useViewsLabels();
|
|
1453
|
+
const meta = useViewsMeta(host, sessionId);
|
|
1454
|
+
const found = meta ? viewById(meta.views, id) : void 0;
|
|
1455
|
+
const version = found ? viewVersion(found) : 0;
|
|
1456
|
+
const record = useViewRecord(host, sessionId, id, version, found !== void 0);
|
|
1457
|
+
const scope = useScope(sessionId, depth);
|
|
1458
|
+
const view = record?.status === "ready" ? record.view : void 0;
|
|
1459
|
+
const state = useViewState(host, sessionId, view, version, false);
|
|
1460
|
+
const tree = view ? state.tree ?? view.tree : void 0;
|
|
1461
|
+
const stateValues = state.scope?.values;
|
|
1462
|
+
const custom = reactExports.useMemo(
|
|
1463
|
+
() => tree && view ? customScope(sessionId, id, view, tree, false, stateValues) : void 0,
|
|
1464
|
+
[tree, sessionId, id, view, stateValues]
|
|
1465
|
+
);
|
|
1466
|
+
if (!found)
|
|
1467
|
+
return meta?.loaded ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-zg-label text-[var(--zg-text-muted)]", children: labels.viewMissingRef(id) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(PartSkeleton, {});
|
|
1468
|
+
if (!tree || !custom) return /* @__PURE__ */ jsxRuntimeExports.jsx(PartSkeleton, { height: heightFor(found.heights, lastWidth) ?? 48 });
|
|
1469
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1470
|
+
"div",
|
|
1471
|
+
{
|
|
1472
|
+
className: "zg-view-body min-w-0",
|
|
1473
|
+
"data-zg-view-waiting": state.waiting ? "" : void 0,
|
|
1474
|
+
"aria-busy": state.waiting || void 0,
|
|
1475
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(ViewStateContext.Provider, { value: state.scope, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ViewNodes, { nodes: tree.children, scope, custom }) })
|
|
1476
|
+
}
|
|
1477
|
+
);
|
|
1478
|
+
}
|
|
1479
|
+
const CHART_PARTS = /* @__PURE__ */ new Set(["BarChart", "LineChart", "AreaChart", "ScatterChart"]);
|
|
1480
|
+
function pendingHeight(part) {
|
|
1481
|
+
if (CHART_PARTS.has(part.name)) return 200;
|
|
1482
|
+
if (part.name === "Table") return 120;
|
|
1483
|
+
return 48;
|
|
1484
|
+
}
|
|
1485
|
+
function StreamedViewBlock({ parseKey, code, streaming, sessionId }) {
|
|
1486
|
+
const labels = useViewsLabels();
|
|
1487
|
+
const [shown, setShown] = reactExports.useState(() => {
|
|
1488
|
+
return streamFence(parseKey, code, !streaming);
|
|
1489
|
+
});
|
|
1490
|
+
const latest = reactExports.useRef({ parseKey, code, streaming });
|
|
1491
|
+
const frame = reactExports.useRef(0);
|
|
1492
|
+
reactExports.useEffect(() => {
|
|
1493
|
+
latest.current = { parseKey, code, streaming };
|
|
1494
|
+
if (frame.current) return;
|
|
1495
|
+
frame.current = requestAnimationFrame(() => {
|
|
1496
|
+
frame.current = 0;
|
|
1497
|
+
const now = latest.current;
|
|
1498
|
+
setShown(streamFence(now.parseKey, now.code, !now.streaming));
|
|
1499
|
+
});
|
|
1500
|
+
}, [parseKey, code, streaming]);
|
|
1501
|
+
reactExports.useEffect(() => () => cancelAnimationFrame(frame.current), []);
|
|
1502
|
+
const scope = useScope(sessionId, 0);
|
|
1503
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(ViewFrame, { title: void 0, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-3 min-w-0", children: shown.parts.map(
|
|
1504
|
+
(part, i) => part.kind === "node" ? /* @__PURE__ */ jsxRuntimeExports.jsx(ScopedNode, { node: part.node, scope }, i) : /* @__PURE__ */ jsxRuntimeExports.jsx(PartSkeleton, { height: pendingHeight(part), label: labels.viewPending }, i)
|
|
1505
|
+
) }) });
|
|
1506
|
+
}
|
|
1507
|
+
const ScopedNode = reactExports.memo(function ScopedNode2({
|
|
1508
|
+
node,
|
|
1509
|
+
scope
|
|
1510
|
+
}) {
|
|
1511
|
+
return scope ? /* @__PURE__ */ jsxRuntimeExports.jsx(ViewNodes, { nodes: [node], scope }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ViewNodeView, { node });
|
|
1512
|
+
});
|
|
1513
|
+
export {
|
|
1514
|
+
BoolMark as B,
|
|
1515
|
+
CustomStatic as C,
|
|
1516
|
+
StoredViewBlock as S,
|
|
1517
|
+
TONES as T,
|
|
1518
|
+
ViewStateContext as V,
|
|
1519
|
+
StreamedViewBlock as a,
|
|
1520
|
+
arr as b,
|
|
1521
|
+
statusTones as c,
|
|
1522
|
+
TEXT_TONE$1 as d,
|
|
1523
|
+
cellText as e,
|
|
1524
|
+
BADGE_TONE as f,
|
|
1525
|
+
useViewportPresence as g,
|
|
1526
|
+
useViewExpanded as h,
|
|
1527
|
+
customShotOf as i,
|
|
1528
|
+
ViewNodes as j,
|
|
1529
|
+
useExpandView as k,
|
|
1530
|
+
observeSize as l,
|
|
1531
|
+
formatterOf as m,
|
|
1532
|
+
num as n,
|
|
1533
|
+
oneOf as o,
|
|
1534
|
+
str as s,
|
|
1535
|
+
useViewNumbers as u
|
|
1536
|
+
};
|