@lunora/studio 1.0.0-alpha.3 → 1.0.0-alpha.30
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/__assets__/package-og.svg +1 -1
- package/dist/index.d.ts +29 -18
- package/dist/index.js +29 -29
- package/dist/mount.d.ts +1 -1
- package/dist/mount.js +1 -1
- package/dist/{packem_shared/ApiTab-W3no0KOj.js → packem_chunks/ApiTab.js} +5 -5
- package/dist/{packem_shared/AuditPanel-Bq4o_IqT.js → packem_chunks/AuditPanel.js} +24 -36
- package/dist/{packem_shared/ExportImportPanel-dxY56TDF.js → packem_chunks/ExportImportPanel.js} +13 -9
- package/dist/{packem_shared/FileBrowser-Dhy4zES8.js → packem_chunks/FileBrowser.js} +15 -15
- package/dist/{packem_shared/FunctionRunner--fQJRPAD.js → packem_chunks/FunctionRunner.js} +10 -10
- package/dist/{packem_shared/FunctionStatsPanel-BjRUA_G3.js → packem_chunks/FunctionStatsPanel.js} +147 -204
- package/dist/{packem_shared/HealthPanel-PxclMWmA.js → packem_chunks/HealthPanel.js} +37 -29
- package/dist/{packem_shared/InsightsPanel-CWS_C-xW.js → packem_chunks/InsightsPanel.js} +107 -69
- package/dist/{packem_shared/LogsPanel-CTW8CFcM.js → packem_chunks/LogsPanel.js} +41 -53
- package/dist/{packem_shared/MailPanel-BwkvfIHF.js → packem_chunks/MailPanel.js} +37 -44
- package/dist/{packem_shared/MetricsPanel-BLuOhZQ4.js → packem_chunks/MetricsPanel.js} +41 -322
- package/dist/{packem_shared/MigrationsPanel-DT3lnwHF.js → packem_chunks/MigrationsPanel.js} +39 -46
- package/dist/{packem_shared/PitrPanel-CdErL7EJ.js → packem_chunks/PitrPanel.js} +9 -9
- package/dist/{packem_shared/SchemaViewer-LJDcmNIO.js → packem_chunks/SchemaViewer.js} +15 -15
- package/dist/{packem_shared/SecurityAdvisorPanel-C_ETsPih.js → packem_chunks/SecurityAdvisorPanel.js} +44 -31
- package/dist/packem_chunks/SettingsPanel.js +390 -0
- package/dist/{packem_shared/sql-editor-panel-BFRpzj6r.js → packem_chunks/SqlEditorPanel.js} +12 -252
- package/dist/{packem_shared/TableEditor-ChfUOZec.js → packem_chunks/TableEditor.js} +10 -68
- package/dist/packem_chunks/analytics-panel.js +261 -0
- package/dist/packem_chunks/auth-config-panel.js +179 -0
- package/dist/packem_chunks/auth-sessions-panel.js +175 -0
- package/dist/packem_chunks/dashboards-panel.js +779 -0
- package/dist/packem_chunks/fanout-panel.js +481 -0
- package/dist/packem_chunks/flags-panel.js +176 -0
- package/dist/packem_chunks/kv-browser.js +1896 -0
- package/dist/packem_chunks/log-drains-panel.js +273 -0
- package/dist/packem_chunks/organizations-panel.js +670 -0
- package/dist/packem_chunks/payments-panel.js +185 -0
- package/dist/packem_chunks/permissions-panel.js +804 -0
- package/dist/packem_chunks/queues-panel.js +147 -0
- package/dist/packem_chunks/rls-panel.js +313 -0
- package/dist/packem_chunks/schedule-panel.js +831 -0
- package/dist/packem_chunks/sparkline.js +79 -0
- package/dist/packem_chunks/storage-rules-panel.js +138 -0
- package/dist/packem_chunks/subscriptions-panel.js +236 -0
- package/dist/packem_chunks/users-panel.js +1265 -0
- package/dist/packem_chunks/vector-browser.js +281 -0
- package/dist/packem_chunks/workflows-panel.js +562 -0
- package/dist/packem_shared/{ADMIN_FUNCTIONS-DmBqMZ-z.js → ADMIN_FUNCTIONS-CdaxLGkE.js} +3 -0
- package/dist/packem_shared/{ApiDocsPanel-C5-yJ1p7.js → ApiDocsPanel-B6u_wnz-.js} +2 -2
- package/dist/packem_shared/{ApiReferencePanel-1vubqG5s.js → ApiReferencePanel-Drz4UO0a.js} +2 -1
- package/dist/packem_shared/{CommandPalette-BtgkBzZI.js → CommandPalette-B5BertvU.js} +1 -1
- package/dist/packem_shared/{DataBrowser-CtBe1So9.js → DataBrowser-ANTHLWWh.js} +198 -247
- package/dist/packem_shared/{GlobalDataBrowser-BTEmGrph.js → GlobalDataBrowser-CjgTG_wa.js} +37 -66
- package/dist/packem_shared/HomePanel-c2FodE9t.js +14 -0
- package/dist/packem_shared/{OpenRpcReferencePanel-vbcYbv3V.js → OpenRpcReferencePanel-CspFdbUT.js} +2 -1
- package/dist/packem_shared/{ScheduledJobs-CabfKbyM.js → ScheduledJobs-BEJXtsBn.js} +163 -60
- package/dist/packem_shared/Studio-CVTtA_sB.js +16 -0
- package/dist/packem_shared/{StudioApp-CHOZA-z-.js → StudioApp-BSYV2fz6.js} +277 -3
- package/dist/packem_shared/{advisor-view-CGcfMiPq.js → advisor-view-DzqyvUU3.js} +1 -1
- package/dist/packem_shared/{app.d-CCmwDEVs.d.ts → app.d-B6MyY_al.d.ts} +1 -1
- package/dist/packem_shared/{bar-chart-CzJAgqkp.js → bar-chart-Bb__F5-u.js} +1 -1
- package/dist/packem_shared/browser-storage-d03UsV7v.js +249 -0
- package/dist/packem_shared/{cf-links-2cktDedA.js → cf-links-BZfRdxSE.js} +1 -1
- package/dist/packem_shared/{data-grid-B5CaV3wS.js → data-grid-Dsg6nRjo.js} +1 -1
- package/dist/packem_shared/data-view-params-Cd6yRVbv.js +96 -0
- package/dist/packem_shared/{grid-features-CzUfqgsM.js → grid-features-D7nNzBYm.js} +4 -99
- package/dist/packem_shared/{HomePanel-Cw16stjq.js → home-panel-aOR_drVv.js} +833 -469
- package/dist/packem_shared/{internal-rXJEAhXS.js → internal-FcNZ3beb.js} +1 -1
- package/dist/packem_shared/modal-shell-hyaJvIJ6.js +100 -0
- package/dist/packem_shared/{reference-view-B4E49Lip.js → reference-view-Doy1XlQq.js} +4 -44
- package/dist/packem_shared/select-UkNYCT3s.js +273 -0
- package/dist/packem_shared/skeleton-CGhL0p20.js +45 -0
- package/dist/packem_shared/{sparkline-10dG-_f0.js → sparkline-KgMPHS4u.js} +1 -1
- package/dist/packem_shared/studio-dMTJ-kRR.js +3987 -0
- package/dist/packem_shared/{table-_RzNvy3R.js → table-DsCa9Qp9.js} +1 -1
- package/dist/packem_shared/{table-list-sidebar-Bg7uzbvC.js → table-list-sidebar-VMo0ftxD.js} +1 -1
- package/dist/packem_shared/use-admin-query-BViPA3US.js +105 -0
- package/dist/packem_shared/use-auth-capabilities-BHkoBnbZ.js +32 -0
- package/dist/standalone/chunk-2DS7JLWL.js +13 -0
- package/dist/standalone/chunk-2K47A3P6.js +1 -0
- package/dist/standalone/chunk-2NGUNNGW.js +1 -0
- package/dist/standalone/chunk-2PDQ4KZ6.js +1 -0
- package/dist/standalone/chunk-3BP4BTLR.js +4 -0
- package/dist/standalone/chunk-3OA7PECS.js +6 -0
- package/dist/standalone/chunk-4QHKBC77.js +1 -0
- package/dist/standalone/chunk-57LYXHXH.js +1 -0
- package/dist/standalone/chunk-5NSZVXCS.js +1 -0
- package/dist/standalone/chunk-5OIBXYZM.js +1 -0
- package/dist/standalone/chunk-63XKJQTQ.js +1 -0
- package/dist/standalone/chunk-6RC6L33K.js +4 -0
- package/dist/standalone/chunk-6VTGE3WJ.js +1 -0
- package/dist/standalone/chunk-7PBZKXYA.js +1 -0
- package/dist/standalone/chunk-7POIIWC5.js +3 -0
- package/dist/standalone/chunk-7RYIQKZA.js +1 -0
- package/dist/standalone/chunk-7TJJXVSE.js +1 -0
- package/dist/standalone/chunk-AB6QGMBF.js +1 -0
- package/dist/standalone/chunk-AHILM3ZP.js +1 -0
- package/dist/standalone/chunk-AQGOX5DK.js +1 -0
- package/dist/standalone/chunk-ASLGNHAX.js +1 -0
- package/dist/standalone/chunk-BHTPZS7L.js +4 -0
- package/dist/standalone/chunk-BJGBHGK3.js +1 -0
- package/dist/standalone/chunk-D7HKX4DI.js +1 -0
- package/dist/standalone/chunk-DGWTR4G7.js +1 -0
- package/dist/standalone/chunk-DSX53PBM.js +1 -0
- package/dist/standalone/chunk-DV2MNASX.js +1 -0
- package/dist/standalone/chunk-DWDILV2E.js +1 -0
- package/dist/standalone/chunk-E7AVZZKO.js +1 -0
- package/dist/standalone/chunk-EGJX34WM.js +1 -0
- package/dist/standalone/chunk-FCR3HKFV.js +1 -0
- package/dist/standalone/chunk-FKO3HO6I.js +4 -0
- package/dist/standalone/chunk-FQKNJSRA.js +76 -0
- package/dist/standalone/chunk-G2TFEWEQ.js +4 -0
- package/dist/standalone/chunk-GABMIICA.js +1 -0
- package/dist/standalone/chunk-GTM65MVX.js +1 -0
- package/dist/standalone/chunk-GZXPPJVK.js +1 -0
- package/dist/standalone/chunk-HFBRE65A.js +1 -0
- package/dist/standalone/chunk-HFMQNUBC.js +1 -0
- package/dist/standalone/chunk-HG7Q5B3H.js +1 -0
- package/dist/standalone/chunk-HTQL7AXU.js +1 -0
- package/dist/standalone/chunk-HV7G6DFP.js +5 -0
- package/dist/standalone/chunk-ITLLHEVG.js +1 -0
- package/dist/standalone/chunk-J6J54MBP.js +1 -0
- package/dist/standalone/chunk-JSEXCW5Q.js +1 -0
- package/dist/standalone/chunk-KEGAWN6Y.js +1 -0
- package/dist/standalone/chunk-KG3QTFWE.js +1 -0
- package/dist/standalone/chunk-KGS7KM4A.js +2 -0
- package/dist/standalone/chunk-KODWGUAB.js +1 -0
- package/dist/standalone/chunk-KZ6INM5M.js +1 -0
- package/dist/standalone/chunk-MGFEVTRI.js +1 -0
- package/dist/standalone/chunk-N2QDG3MW.js +1 -0
- package/dist/standalone/chunk-N4JI6VQD.js +1 -0
- package/dist/standalone/chunk-NNISYDNI.js +1 -0
- package/dist/standalone/chunk-O4PXDNR3.js +1 -0
- package/dist/standalone/chunk-O77VNUFD.js +1 -0
- package/dist/standalone/chunk-OD2POGPJ.js +1 -0
- package/dist/standalone/chunk-OXCK3ZUG.js +1 -0
- package/dist/standalone/chunk-P7DSVO4U.js +1 -0
- package/dist/standalone/chunk-PKAM3N5C.js +1 -0
- package/dist/standalone/chunk-QGXGBHQO.js +1 -0
- package/dist/standalone/chunk-QHA3TAEJ.js +1 -0
- package/dist/standalone/chunk-QQWC62X7.js +1 -0
- package/dist/standalone/chunk-RMYA7NAH.js +1 -0
- package/dist/standalone/chunk-RRCPZMC2.js +22 -0
- package/dist/standalone/chunk-S53RUBW5.js +1 -0
- package/dist/standalone/chunk-SB4GT6PK.js +1 -0
- package/dist/standalone/chunk-SEU5V7I6.js +1 -0
- package/dist/standalone/chunk-SHIOUDOT.js +1 -0
- package/dist/standalone/chunk-SIDRSX7Y.js +1 -0
- package/dist/standalone/chunk-SVR644RF.js +1 -0
- package/dist/standalone/chunk-TAD43CG5.js +1 -0
- package/dist/standalone/chunk-TBMYIZIO.js +1 -0
- package/dist/standalone/chunk-TICVNLPM.js +1 -0
- package/dist/standalone/chunk-TQ36RWOP.js +1 -0
- package/dist/standalone/chunk-UGMRUEBU.js +1 -0
- package/dist/standalone/chunk-UII66UVF.js +1 -0
- package/dist/standalone/chunk-VJPQUBN6.js +8 -0
- package/dist/standalone/chunk-VLXV72QE.js +1 -0
- package/dist/standalone/chunk-VMJKJWG6.js +1 -0
- package/dist/standalone/chunk-VPDPN5RR.js +2 -0
- package/dist/standalone/chunk-VSEGZA3J.js +1 -0
- package/dist/standalone/chunk-VXBZQIGY.js +4 -0
- package/dist/standalone/chunk-W7PCVQTE.js +1 -0
- package/dist/standalone/chunk-XLILSHPE.js +1 -0
- package/dist/standalone/chunk-XURNGQSS.js +1 -0
- package/dist/standalone/chunk-YJGANMU7.js +18 -0
- package/dist/standalone/chunk-YQQJ4N6U.js +1 -0
- package/dist/standalone/chunk-ZH7UES4T.js +2 -0
- package/dist/standalone/chunk-ZPUO7FNI.js +1 -0
- package/dist/standalone/chunk-ZQCVDXDL.js +1 -0
- package/dist/standalone/studio.js +104 -246
- package/dist/styles.css +1 -1
- package/package.json +13 -12
- package/dist/packem_shared/SettingsPanel-C0uLRf5P.js +0 -176
- package/dist/packem_shared/SqlEditorPanel-CguV7otm.js +0 -13
- package/dist/packem_shared/Studio-DFWAlcuf.js +0 -33
- package/dist/packem_shared/studio-Bj8psK1c.js +0 -10303
- package/dist/packem_shared/use-live-admin-Dq6g3daN.js +0 -73
- package/dist/packem_shared/use-live-shard-seed-Cuk3dnH0.js +0 -76
|
@@ -32,7 +32,7 @@ function Table(t0) {
|
|
|
32
32
|
if ($[5] !== props || $[6] !== t1) {
|
|
33
33
|
t2 = /* @__PURE__ */ jsxDEV("div", {
|
|
34
34
|
"data-slot": "table-container",
|
|
35
|
-
className: "relative w-full overflow-x-auto",
|
|
35
|
+
className: "relative w-full overflow-x-auto overflow-y-clip",
|
|
36
36
|
children: /* @__PURE__ */ jsxDEV("table", {
|
|
37
37
|
"data-slot": "table",
|
|
38
38
|
className: t1,
|
package/dist/packem_shared/{table-list-sidebar-Bg7uzbvC.js → table-list-sidebar-VMo0ftxD.js}
RENAMED
|
@@ -2,7 +2,7 @@ import { c } from 'react/compiler-runtime';
|
|
|
2
2
|
import { useT } from './DEFAULT_LOCALE-CiX4W7Kr.js';
|
|
3
3
|
import { jsxDEV } from 'react/jsx-dev-runtime';
|
|
4
4
|
import { useState, useRef, useMemo } from 'react';
|
|
5
|
-
import { f as fireAndForget, e as errorMessage } from './internal-
|
|
5
|
+
import { f as fireAndForget, e as errorMessage } from './internal-FcNZ3beb.js';
|
|
6
6
|
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
7
7
|
import { c as cn } from './utils-B05Dmz_H.js';
|
|
8
8
|
import { f as flooredRectObserver } from './virtual-rect-CVMUskSm.js';
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { c } from 'react/compiler-runtime';
|
|
2
|
+
import { useLunora } from '@lunora/react';
|
|
3
|
+
import { useQueryClient, useQuery, keepPreviousData } from '@tanstack/react-query';
|
|
4
|
+
import { useState, useEffect } from 'react';
|
|
5
|
+
import { a as adminRef, c as callOptions, f as fireAndForget, e as errorMessage } from './internal-FcNZ3beb.js';
|
|
6
|
+
|
|
7
|
+
const adminQueryKey = (path, args, shardKey) => ["lunora-admin", path, args, shardKey.trim()];
|
|
8
|
+
const RPC_LOOP_WINDOW_MS = 1e3;
|
|
9
|
+
const RPC_LOOP_THRESHOLD = 25;
|
|
10
|
+
const rpcCallTimes = /* @__PURE__ */ new Map();
|
|
11
|
+
const noteQueryFetch = (key) => {
|
|
12
|
+
const now = Date.now();
|
|
13
|
+
const recent = (rpcCallTimes.get(key) ?? []).filter((time) => now - time < RPC_LOOP_WINDOW_MS);
|
|
14
|
+
recent.push(now);
|
|
15
|
+
rpcCallTimes.set(key, recent);
|
|
16
|
+
if (recent.length === RPC_LOOP_THRESHOLD) {
|
|
17
|
+
console.error(`[lunora-studio] possible request loop: ${key} fired ${String(RPC_LOOP_THRESHOLD)}× in <1s — a render/effect is re-issuing this read unbounded.`);
|
|
18
|
+
console.trace("[lunora-studio] request-loop call site");
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
function useClientQuery(queryKey, queryFunction, options = {}) {
|
|
22
|
+
const {
|
|
23
|
+
enabled = true,
|
|
24
|
+
keepPreviousData: keepPreviousData$1 = false,
|
|
25
|
+
staleTime = 0
|
|
26
|
+
} = options;
|
|
27
|
+
const trackedQueryFunction = () => {
|
|
28
|
+
noteQueryFetch(JSON.stringify(queryKey));
|
|
29
|
+
return queryFunction();
|
|
30
|
+
} ;
|
|
31
|
+
const query = useQuery({
|
|
32
|
+
enabled,
|
|
33
|
+
queryFn: trackedQueryFunction,
|
|
34
|
+
placeholderData: keepPreviousData$1 ? keepPreviousData : void 0,
|
|
35
|
+
queryKey,
|
|
36
|
+
staleTime
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
data: query.data,
|
|
40
|
+
error: query.error ? errorMessage(query.error) : query.error,
|
|
41
|
+
isLoading: query.isLoading,
|
|
42
|
+
liveError: void 0,
|
|
43
|
+
refetch: () => {
|
|
44
|
+
fireAndForget(query.refetch());
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function useAdminQuery(path, args, options = {}) {
|
|
49
|
+
const client = useLunora();
|
|
50
|
+
const queryClient = useQueryClient();
|
|
51
|
+
const {
|
|
52
|
+
enabled = true,
|
|
53
|
+
keepPreviousData = false,
|
|
54
|
+
live = false,
|
|
55
|
+
shardKey = "",
|
|
56
|
+
staleTime
|
|
57
|
+
} = options;
|
|
58
|
+
const queryKey = adminQueryKey(path, args, shardKey);
|
|
59
|
+
const base = useClientQuery(queryKey, () => client.query(adminRef(path), args, callOptions(shardKey)), {
|
|
60
|
+
enabled,
|
|
61
|
+
keepPreviousData,
|
|
62
|
+
staleTime: staleTime ?? (live ? Number.POSITIVE_INFINITY : 0)
|
|
63
|
+
});
|
|
64
|
+
const [liveError, setLiveError] = useState(void 0);
|
|
65
|
+
const keySignature = JSON.stringify(queryKey);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (!enabled || !live) {
|
|
68
|
+
return void 0;
|
|
69
|
+
}
|
|
70
|
+
setLiveError(void 0);
|
|
71
|
+
return client.subscribe(adminRef(path), args, (value) => {
|
|
72
|
+
setLiveError(void 0);
|
|
73
|
+
queryClient.setQueryData(queryKey, value);
|
|
74
|
+
}, {
|
|
75
|
+
...callOptions(shardKey),
|
|
76
|
+
onError: (error) => {
|
|
77
|
+
setLiveError(error.message);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}, [keySignature, enabled, live]);
|
|
81
|
+
return {
|
|
82
|
+
...base,
|
|
83
|
+
liveError: enabled && live ? liveError : void 0
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const useInvalidateAdmin = () => {
|
|
87
|
+
const $ = c(2);
|
|
88
|
+
const queryClient = useQueryClient();
|
|
89
|
+
let t0;
|
|
90
|
+
if ($[0] !== queryClient) {
|
|
91
|
+
t0 = (path, args, shardKey) => {
|
|
92
|
+
const queryKey = args === void 0 ? ["lunora-admin", path] : adminQueryKey(path, args, shardKey ?? "");
|
|
93
|
+
fireAndForget(queryClient.invalidateQueries({
|
|
94
|
+
queryKey
|
|
95
|
+
}));
|
|
96
|
+
};
|
|
97
|
+
$[0] = queryClient;
|
|
98
|
+
$[1] = t0;
|
|
99
|
+
} else {
|
|
100
|
+
t0 = $[1];
|
|
101
|
+
}
|
|
102
|
+
return t0;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export { useClientQuery as a, useInvalidateAdmin as b, useAdminQuery as u };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useLunora } from '@lunora/react';
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
import { f as fireAndForget } from './internal-FcNZ3beb.js';
|
|
4
|
+
|
|
5
|
+
const DEFAULT_CAPABILITIES = {
|
|
6
|
+
accounts: true,
|
|
7
|
+
admin: true,
|
|
8
|
+
organization: false,
|
|
9
|
+
passkey: false,
|
|
10
|
+
twoFactor: false
|
|
11
|
+
};
|
|
12
|
+
const useAuthCapabilities = () => {
|
|
13
|
+
const client = useLunora();
|
|
14
|
+
const [capabilities, setCapabilities] = useState(DEFAULT_CAPABILITIES);
|
|
15
|
+
const [ready, setReady] = useState(false);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
fireAndForget((async () => {
|
|
18
|
+
try {
|
|
19
|
+
setCapabilities(await client.getAuthCapabilities());
|
|
20
|
+
} catch {
|
|
21
|
+
} finally {
|
|
22
|
+
setReady(true);
|
|
23
|
+
}
|
|
24
|
+
})());
|
|
25
|
+
}, [client]);
|
|
26
|
+
return {
|
|
27
|
+
capabilities,
|
|
28
|
+
ready
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { useAuthCapabilities as u };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{a as Ce}from"./chunk-VLXV72QE.js";import{a as xe}from"./chunk-JSEXCW5Q.js";import{a as X}from"./chunk-KZ6INM5M.js";import{d as ke,f as we,g as Oe,k as ae}from"./chunk-4QHKBC77.js";import{a as Te}from"./chunk-RMYA7NAH.js";import"./chunk-TBMYIZIO.js";import{R as Se}from"./chunk-BHTPZS7L.js";import{c as H}from"./chunk-YQQJ4N6U.js";import"./chunk-TICVNLPM.js";import"./chunk-HV7G6DFP.js";import{a as Ie}from"./chunk-AQGOX5DK.js";import{a as W}from"./chunk-TAD43CG5.js";import{b as Ne}from"./chunk-O4PXDNR3.js";import"./chunk-ZH7UES4T.js";import{f as G}from"./chunk-KODWGUAB.js";import"./chunk-3OA7PECS.js";import{d as M,e as le,f as de,g as ce,i as $e,j as re}from"./chunk-YJGANMU7.js";import{a as p,e as q,f as he,g as oe,h as ne,j as ge}from"./chunk-RRCPZMC2.js";var Ge=q(oe(),1),ye=q(he(),1);var ee=q(oe(),1);var Z=q(he(),1);var L=q(ne(),1);var Ue=le(Ie.listTables),Ye=["react","client","cli"],Qe=!1,Xe={action:"action",mutation:"mutation",query:"query"},Pe=p(t=>{let e=t.indexOf(":");return e===-1?{file:"",fn:t}:{file:t.slice(0,e),fn:t.slice(e+1)}},"splitPath"),Re=p(({file:t,fn:e,kind:o})=>`await client.${Xe[o]}(api.${t}.${e}, { /* args */ });`,"buildClientSnippet"),Ze=p(t=>{let e=`api.${t.file}.${t.fn}`;switch(t.kind){case"action":return Re(t);case"mutation":return`const ${t.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},"buildReactSnippet"),et=p(({file:t,fn:e})=>`lunora run ${t}:${e} --args '{ }'`,"buildCliSnippet"),tt=p(t=>["// Read rows",`const rows = await ctx.db.query("${t}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${t}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${t}">;`,`type RowId = Id<"${t}">;`].join(`
|
|
2
|
+
`),"buildTableSnippet"),st=p((t,e)=>{switch(t){case"cli":return et(e);case"client":return Re(e);default:return Ze(e)}},"snippetForTab"),Ee=p(t=>{let e=(0,ee.c)(19),{code:o,label:s,testId:n}=t,r=M(),l;e[0]!==o?(l=p(()=>{re(o)},"t1"),e[0]=o,e[1]=l):l=e[1];let i=l,d;e[2]!==s?(d=(0,L.jsxDEV)("span",{className:"text-xs font-medium text-muted-foreground",children:s},void 0,!1),e[2]=s,e[3]=d):d=e[3];let c=`${n}-copy`,m;e[4]!==r?(m=r("Copy"),e[4]=r,e[5]=m):m=e[5];let a;e[6]!==i||e[7]!==c||e[8]!==m?(a=(0,L.jsxDEV)(H,{"data-testid":c,onClick:i,size:"xs",type:"button",variant:"ghost",children:m},void 0,!1),e[6]=i,e[7]=c,e[8]=m,e[9]=a):a=e[9];let u;e[10]!==d||e[11]!==a?(u=(0,L.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[d,a]},void 0,!0),e[10]=d,e[11]=a,e[12]=u):u=e[12];let v;e[13]!==o||e[14]!==n?(v=(0,L.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":n,children:o},void 0,!1),e[13]=o,e[14]=n,e[15]=v):v=e[15];let k;return e[16]!==u||e[17]!==v?(k=(0,L.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[u,v]},void 0,!0),e[16]=u,e[17]=v,e[18]=k):k=e[18],k},"SnippetBlock"),ot=p(t=>{let e=(0,ee.c)(50),{file:o,fn:s,kind:n}=t,r=M(),[l,i]=(0,Z.useState)("react"),d,c,m;if(e[0]!==o||e[1]!==s||e[2]!==n||e[3]!==r||e[4]!==l){let T={file:o,fn:s,kind:n},I;e[8]!==r?(I=r("CLI"),e[8]=r,e[9]=I):I=e[9];let A;e[10]!==r?(A=r("Client"),e[10]=r,e[11]=A):A=e[11];let E;e[12]!==r?(E=r("React"),e[12]=r,e[13]=E):E=e[13];let j;e[14]!==I||e[15]!==A||e[16]!==E?(j={cli:I,client:A,react:E},e[14]=I,e[15]=A,e[16]=E,e[17]=j):j=e[17],m=j;let R;e[18]===Symbol.for("react.memo_cache_sentinel")?(R=p(B=>{i(B.currentTarget.dataset.tab)},"t62"),e[18]=R):R=e[18],d=R,c=st(l,T),e[0]=o,e[1]=s,e[2]=n,e[3]=r,e[4]=l,e[5]=d,e[6]=c,e[7]=m}else d=e[5],c=e[6],m=e[7];let a=c,u=n==="action"&&l==="react"&&!Qe,v=`api.${o}.${s}`,k;e[19]!==v?(k=(0,L.jsxDEV)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-fn-title",children:v},void 0,!1),e[19]=v,e[20]=k):k=e[20];let O;e[21]!==n||e[22]!==r?(O=r("Call this {kind} from your app.",{kind:n}),e[21]=n,e[22]=r,e[23]=O):O=e[23];let h;e[24]!==O?(h=(0,L.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:O},void 0,!1),e[24]=O,e[25]=h):h=e[25];let g;e[26]!==k||e[27]!==h?(g=(0,L.jsxDEV)("div",{children:[k,h]},void 0,!0),e[26]=k,e[27]=h,e[28]=g):g=e[28];let x;e[29]!==r?(x=r("Snippet flavour"),e[29]=r,e[30]=x):x=e[30];let b;e[31]!==d||e[32]!==l||e[33]!==m?(b=Ye.map(T=>(0,L.jsxDEV)(H,{"aria-selected":l===T,"data-tab":T,"data-testid":`api-tab-${T}`,onClick:d,role:"tab",size:"xs",type:"button",variant:l===T?"default":"outline",children:m[T]},T,!1)),e[31]=d,e[32]=l,e[33]=m,e[34]=b):b=e[34];let S;e[35]!==x||e[36]!==b?(S=(0,L.jsxDEV)("div",{"aria-label":x,className:"flex gap-1.5","data-testid":"api-tabs",role:"tablist",children:b},void 0,!1),e[35]=x,e[36]=b,e[37]=S):S=e[37];let y=m[l],$=`api-snippet-${l}`,N;e[38]!==a||e[39]!==y||e[40]!==$?(N=(0,L.jsxDEV)(Ee,{code:a,label:y,testId:$},void 0,!1),e[38]=a,e[39]=y,e[40]=$,e[41]=N):N=e[41];let w;e[42]!==u||e[43]!==r?(w=u&&(0,L.jsxDEV)("p",{className:"text-xs text-muted-foreground","data-testid":"api-action-note",children:r("Actions have no React hook \u2014 call them through the client.")},void 0,!1),e[42]=u,e[43]=r,e[44]=w):w=e[44];let C;return e[45]!==N||e[46]!==w||e[47]!==g||e[48]!==S?(C=(0,L.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"api-fn-doc",children:[g,S,N,w]},void 0,!0),e[45]=N,e[46]=w,e[47]=g,e[48]=S,e[49]=C):C=e[49],C},"FunctionDoc"),nt=p(t=>{let e=(0,ee.c)(19),{name:o}=t,s=M(),n;e[0]!==o?(n=tt(o),e[0]=o,e[1]=n):n=e[1];let r=n,l;e[2]!==o?(l=(0,L.jsxDEV)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-table-title",children:o},void 0,!1),e[2]=o,e[3]=l):l=e[3];let i;e[4]!==s?(i=s("Read and write this table through the typed data model."),e[4]=s,e[5]=i):i=e[5];let d;e[6]!==i?(d=(0,L.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:i},void 0,!1),e[6]=i,e[7]=d):d=e[7];let c;e[8]!==l||e[9]!==d?(c=(0,L.jsxDEV)("div",{children:[l,d]},void 0,!0),e[8]=l,e[9]=d,e[10]=c):c=e[10];let m;e[11]!==s?(m=s("Data model"),e[11]=s,e[12]=m):m=e[12];let a;e[13]!==r||e[14]!==m?(a=(0,L.jsxDEV)(Ee,{code:r,label:m,testId:"api-snippet-table"},void 0,!1),e[13]=r,e[14]=m,e[15]=a):a=e[15];let u;return e[16]!==c||e[17]!==a?(u=(0,L.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"api-table-doc",children:[c,a]},void 0,!0),e[16]=c,e[17]=a,e[18]=u):u=e[18],u},"TableDoc"),Ae=p(t=>{let e=(0,ee.c)(8),{active:o,label:s,onSelect:n,testId:r,value:l}=t,i;e[0]!==n||e[1]!==l?(i=p(()=>{n(l)},"t1"),e[0]=n,e[1]=l,e[2]=i):i=e[2];let d=i,c=o?"page":void 0,m;return e[3]!==s||e[4]!==d||e[5]!==c||e[6]!==r?(m=(0,L.jsxDEV)("button",{"aria-current":c,className:"w-full truncate rounded-md px-2 py-1 text-start font-mono text-xs text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-testid":r,onClick:d,type:"button",children:s},void 0,!1),e[3]=s,e[4]=d,e[5]=c,e[6]=r,e[7]=m):m=e[7],m},"RailButton"),_e=p(t=>{let e=(0,ee.c)(67),{functions:o,initialShardKey:s}=t,n=M(),r=G(),[l,i]=(0,Z.useState)(null),[d,c]=(0,Z.useState)(null),m,a;e[0]!==r||e[1]!==s?(m=p(()=>{let _=!1;return r.query(Ue,{},de(s??"")).then(D=>(_||i(D),D)).catch(()=>{_||i([])}),()=>{_=!0}},"t1"),a=[r,s],e[0]=r,e[1]=s,e[2]=m,e[3]=a):(m=e[2],a=e[3]),(0,Z.useEffect)(m,a);let u;e[4]!==o?(u=o??[],e[4]=o,e[5]=u):u=e[5];let v=u,k;if(e[6]!==v){let _=new Map;for(let D of v){let{file:V,fn:U}=Pe(D.path),ie=_.get(V)??[];ie.push({fn:U,kind:D.kind,path:D.path}),_.set(V,ie)}k=[..._.entries()].map(it).toSorted(at),e[6]=v,e[7]=k}else k=e[7];let O=k,h,g,x,b,S,y,$,N,w,C;if(e[8]!==v||e[9]!==O||e[10]!==d||e[11]!==n||e[12]!==l){let _=(l??[]).map(lt).toSorted(dt),D;e[23]===Symbol.for("react.memo_cache_sentinel")?(D=p(F=>{c({kind:"fn",path:F})},"t122"),e[23]=D):D=e[23];let V=D,U;e[24]===Symbol.for("react.memo_cache_sentinel")?(U=p(F=>{c({kind:"table",name:F})},"t132"),e[24]=U):U=e[24];let ie=U;if(g=d?.kind==="fn"?v.find(F=>F.path===d.path):void 0,h=v.length>0||_.length>0,x=g===void 0?void 0:Pe(g.path),b="grid min-h-0 gap-6 md:grid-cols-[16rem_minmax(0,1fr)]",S="lunora-api-docs",e[25]!==n?(y=n("API resources"),e[25]=n,e[26]=y):y=e[26],$="flex flex-col gap-4 overflow-y-auto",N="api-rail",e[27]!==O||e[28]!==d||e[29]!==n){let F;e[31]!==d||e[32]!==n?(F=p(ve=>(0,L.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,L.jsxDEV)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:ve.file||n("(root)")},void 0,!1),ve.items.map(se=>(0,L.jsxDEV)(Ae,{active:d?.kind==="fn"&&d.path===se.path,label:se.fn,onSelect:V,testId:`api-rail-fn-${se.path}`,value:se.path},se.path,!1))]},ve.file,!0),"t142"),e[31]=d,e[32]=n,e[33]=F):F=e[33],w=O.map(F),e[27]=O,e[28]=d,e[29]=n,e[30]=w}else w=e[30];C=_.length>0&&(0,L.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,L.jsxDEV)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Tables")},void 0,!1),_.map(F=>(0,L.jsxDEV)(Ae,{active:d?.kind==="table"&&d.name===F,label:F,onSelect:ie,testId:`api-rail-table-${F}`,value:F},F,!1))]},void 0,!0),e[8]=v,e[9]=O,e[10]=d,e[11]=n,e[12]=l,e[13]=h,e[14]=g,e[15]=x,e[16]=b,e[17]=S,e[18]=y,e[19]=$,e[20]=N,e[21]=w,e[22]=C}else h=e[13],g=e[14],x=e[15],b=e[16],S=e[17],y=e[18],$=e[19],N=e[20],w=e[21],C=e[22];let T;e[34]!==h||e[35]!==n?(T=!h&&(0,L.jsxDEV)("p",{className:"px-2 text-xs text-muted-foreground","data-testid":"api-rail-empty",children:n("No functions or tables to document yet.")},void 0,!1),e[34]=h,e[35]=n,e[36]=T):T=e[36];let I;e[37]!==T||e[38]!==y||e[39]!==$||e[40]!==N||e[41]!==w||e[42]!==C?(I=(0,L.jsxDEV)("nav",{"aria-label":y,className:$,"data-testid":N,children:[w,C,T]},void 0,!0),e[37]=T,e[38]=y,e[39]=$,e[40]=N,e[41]=w,e[42]=C,e[43]=I):I=e[43];let A;e[44]!==d||e[45]!==n?(A=d===null&&(0,L.jsxDEV)(W,{description:n("Select a function or table to see how to call it from your app."),testId:"api-empty",title:n("API usage snippets")},void 0,!1),e[44]=d,e[45]=n,e[46]=A):A=e[46];let E;e[47]!==d?.kind||e[48]!==g||e[49]!==x?(E=d?.kind==="fn"&&g!==void 0&&x!==void 0&&(0,L.jsxDEV)(ot,{file:x.file,fn:x.fn,kind:g.kind},g.path,!1),e[47]=d?.kind,e[48]=g,e[49]=x,e[50]=E):E=e[50];let j;e[51]!==d?.kind||e[52]!==g||e[53]!==n?(j=d?.kind==="fn"&&g===void 0&&(0,L.jsxDEV)(W,{testId:"api-empty",title:n("API usage snippets")},void 0,!1),e[51]=d?.kind,e[52]=g,e[53]=n,e[54]=j):j=e[54];let R;e[55]!==d?(R=d?.kind==="table"&&(0,L.jsxDEV)(nt,{name:d.name},void 0,!1),e[55]=d,e[56]=R):R=e[56];let B;e[57]!==A||e[58]!==E||e[59]!==j||e[60]!==R?(B=(0,L.jsxDEV)("div",{className:"min-w-0",children:[A,E,j,R]},void 0,!0),e[57]=A,e[58]=E,e[59]=j,e[60]=R,e[61]=B):B=e[61];let P;return e[62]!==b||e[63]!==S||e[64]!==I||e[65]!==B?(P=(0,L.jsxDEV)("div",{className:b,"data-testid":S,children:[I,B]},void 0,!0),e[62]=b,e[63]=S,e[64]=I,e[65]=B,e[66]=P):P=e[66],P},"ApiDocsPanel");function rt(t,e){return t.fn.localeCompare(e.fn)}p(rt,"_temp");function it(t){let[e,o]=t;return{file:e,items:o.toSorted(rt)}}p(it,"_temp2");function at(t,e){return t.file.localeCompare(e.file)}p(at,"_temp3");function lt(t){return t.name}p(lt,"_temp4");function dt(t,e){return t.localeCompare(e)}p(dt,"_temp5");var qe=q(oe(),1);var J=q(oe(),1),K=q(he(),1);var f=q(ne(),1);var ue=p(function(t,e,o){let s=(0,J.c)(10),n;s[0]===Symbol.for("react.memo_cache_sentinel")?(n={kind:"loading"},s[0]=n):n=s[0];let[r,l]=(0,K.useState)(n),i,d;s[1]!==o||s[2]!==e||s[3]!==t?(i=p(()=>{if(t!==void 0)return;let m=!1;return e().then(a=>(m||l(o(a)),a)).catch(a=>{m||l({kind:"error",message:ce(a)})}),()=>{m=!0}},"t1"),d=[o,e,t],s[1]=o,s[2]=e,s[3]=t,s[4]=i,s[5]=d):(i=s[4],d=s[5]),(0,K.useEffect)(i,d);let c;return s[6]!==o||s[7]!==r||s[8]!==t?(c=t===void 0?r:o(t),s[6]=o,s[7]=r,s[8]=t,s[9]=c):c=s[9],c},"useAdminSpec"),ct=p(t=>typeof t=="number"?"number":typeof t=="boolean"?"boolean":"string","scalarOf"),Le=p(t=>{if(t.enum!==void 0&&t.enum.length>0)return t.enum;if(t.anyOf!==void 0&&t.anyOf.length>0&&t.anyOf.every(e=>e.const!==void 0))return t.anyOf.map(e=>e.const)},"enumValues"),pe=p(t=>t===void 0?"any":t.const!==void 0?JSON.stringify(t.const):t.enum!==void 0&&t.enum.length>0?t.enum.map(e=>JSON.stringify(e)).join(" | "):t.anyOf!==void 0&&t.anyOf.length>0?t.anyOf.map(e=>pe(e)).join(" | "):t.type==="array"?`array<${pe(t.items)}>`:t.type??"any","typeLabel"),ft=p(t=>{let e=Le(t);return e!==void 0?t.type??ct(e[0]):pe(t)},"fieldTypeLabel"),pt=p(t=>{let e=Le(t);return e===void 0?void 0:e.map(o=>JSON.stringify(o)).join(" | ")},"valueInText"),ut=p(t=>{let e=[];t.minimum!==void 0?e.push(`${String(t.minimum)} \u2264`):t.exclusiveMinimum!==void 0&&e.push(`${String(t.exclusiveMinimum)} <`);let o=e.length>0;e.push("value"),t.maximum!==void 0?e.push(`\u2264 ${String(t.maximum)}`):t.exclusiveMaximum!==void 0&&e.push(`< ${String(t.exclusiveMaximum)}`);let s=e.length>(o?2:1);return o||s?e.join(" "):void 0},"rangeText"),mt=p(t=>{if(t.type==="object"&&t.properties!==void 0)return t;if(t.type==="array"&&t.items?.type==="object"&&t.items.properties!==void 0)return t.items},"childObject"),te=p(t=>{if(t===void 0)return null;if(t.const!==void 0)return t.const;if(t.enum!==void 0&&t.enum.length>0)return t.enum[0];if(t.anyOf!==void 0&&t.anyOf.length>0)return te(t.anyOf[0]);switch(t.type){case"array":return[];case"boolean":return!1;case"number":return 0;case"object":{let e={};for(let[o,s]of Object.entries(t.properties??{}))e[o]=te(s);return e}case"string":return"";default:return null}},"exampleForSchema"),fe=p(t=>{let e=(0,J.c)(7),{label:o,value:s}=t,n;e[0]!==o?(n=(0,f.jsxDEV)("span",{className:"text-muted-foreground",children:o},void 0,!1),e[0]=o,e[1]=n):n=e[1];let r;e[2]!==s?(r=(0,f.jsxDEV)("span",{className:"text-foreground",children:s},void 0,!1),e[2]=s,e[3]=r):r=e[3];let l;return e[4]!==n||e[5]!==r?(l=(0,f.jsxDEV)("span",{className:"inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 font-mono text-[10px]",children:[n,r]},void 0,!0),e[4]=n,e[5]=r,e[6]=l):l=e[6],l},"Badge"),vt=p(t=>{let e=(0,J.c)(40),{name:o,required:s,schema:n}=t,r=M(),l;e[0]!==n?(l=ut(n),e[0]=n,e[1]=l):l=e[1];let i=l,d;e[2]!==n?(d=pt(n),e[2]=n,e[3]=d):d=e[3];let c=d,m=n["x-lunora-table"],a=n.format!==void 0||i!==void 0||c!==void 0||m!==void 0,u;e[4]!==n?(u=mt(n),e[4]=n,e[5]=u):u=e[5];let v=u,k=s?"*":"?",O;e[6]!==k?(O=(0,f.jsxDEV)("span",{className:"text-muted-foreground",children:k},void 0,!1),e[6]=k,e[7]=O):O=e[7];let h;e[8]!==o||e[9]!==O?(h=(0,f.jsxDEV)("span",{className:"font-mono text-foreground",children:[o,O]},void 0,!0),e[8]=o,e[9]=O,e[10]=h):h=e[10];let g;e[11]!==n?(g=ft(n),e[11]=n,e[12]=g):g=e[12];let x;e[13]!==g?(x=(0,f.jsxDEV)("span",{className:"font-mono text-muted-foreground",children:g},void 0,!1),e[13]=g,e[14]=x):x=e[14];let b;e[15]!==h||e[16]!==x?(b=(0,f.jsxDEV)("div",{className:"flex items-baseline gap-2",children:[h,x]},void 0,!0),e[15]=h,e[16]=x,e[17]=b):b=e[17];let S;e[18]!==n.description?(S=n.description!==void 0&&(0,f.jsxDEV)("p",{className:"max-w-prose text-muted-foreground",children:n.description},void 0,!1),e[18]=n.description,e[19]=S):S=e[19];let y;e[20]!==a||e[21]!==i||e[22]!==m||e[23]!==n.format||e[24]!==r||e[25]!==c?(y=a&&(0,f.jsxDEV)("div",{className:"flex flex-wrap gap-1",children:[n.format!==void 0&&(0,f.jsxDEV)(fe,{label:r("Format"),value:n.format},void 0,!1),i!==void 0&&(0,f.jsxDEV)(fe,{label:r("Range"),value:i},void 0,!1),c!==void 0&&(0,f.jsxDEV)(fe,{label:r("Value in"),value:c},void 0,!1),m!==void 0&&(0,f.jsxDEV)(fe,{label:r("relation"),value:m},void 0,!1)]},void 0,!0),e[20]=a,e[21]=i,e[22]=m,e[23]=n.format,e[24]=r,e[25]=c,e[26]=y):y=e[26];let $;e[27]!==S||e[28]!==y||e[29]!==b?($=(0,f.jsxDEV)("div",{className:"flex flex-col gap-1 py-2",children:[b,S,y]},void 0,!0),e[27]=S,e[28]=y,e[29]=b,e[30]=$):$=e[30];let N=$;if(v===void 0){let I;return e[31]!==N?(I=(0,f.jsxDEV)("div",{className:"border-b border-border/50 last:border-b-0",children:N},void 0,!1),e[31]=N,e[32]=I):I=e[32],I}let w;e[33]!==N?(w=(0,f.jsxDEV)("summary",{className:"cursor-pointer marker:text-muted-foreground",children:N},void 0,!1),e[33]=N,e[34]=w):w=e[34];let C;e[35]!==v?(C=(0,f.jsxDEV)("div",{className:"mb-2 ml-2 border-l border-border pl-3",children:(0,f.jsxDEV)(De,{schema:v},void 0,!1)},void 0,!1),e[35]=v,e[36]=C):C=e[36];let T;return e[37]!==w||e[38]!==C?(T=(0,f.jsxDEV)("details",{className:"border-b border-border/50 last:border-b-0",children:[w,C]},void 0,!0),e[37]=w,e[38]=C,e[39]=T):T=e[39],T},"FieldRow"),De=p(t=>{let e=(0,J.c)(7),{schema:o}=t,s;e[0]!==o.required?(s=new Set(o.required),e[0]=o.required,e[1]=s):s=e[1];let n=s,r;e[2]!==o.properties?(r=Object.entries(o.properties??{}),e[2]=o.properties,e[3]=r):r=e[3];let l=r,i;return e[4]!==n||e[5]!==l?(i=(0,f.jsxDEV)("div",{className:"flex flex-col",children:l.map(d=>{let[c,m]=d;return(0,f.jsxDEV)(vt,{name:c,required:n.has(c),schema:m},c,!1)})},void 0,!1),e[4]=n,e[5]=l,e[6]=i):i=e[6],i},"SchemaFields"),je=p(t=>{let e=(0,J.c)(10),{schema:o,testId:s}=t;if(o?.type!=="object"||Object.keys(o.properties??{}).length===0){let l;e[0]!==o?(l=pe(o),e[0]=o,e[1]=l):l=e[1];let i;return e[2]!==l||e[3]!==s?(i=(0,f.jsxDEV)("p",{className:"font-mono text-xs text-muted-foreground","data-testid":s,children:l},void 0,!1),e[2]=l,e[3]=s,e[4]=i):i=e[4],i}let n;e[5]!==o?(n=(0,f.jsxDEV)(De,{schema:o},void 0,!1),e[5]=o,e[6]=n):n=e[6];let r;return e[7]!==n||e[8]!==s?(r=(0,f.jsxDEV)("div",{className:"text-xs","data-testid":s,children:n},void 0,!1),e[7]=n,e[8]=s,e[9]=r):r=e[9],r},"SchemaTable"),ht=["curl","javascript","lunora"],gt={lunora:"Lunora",curl:"cURL",javascript:"JavaScript"},xt=p(t=>`api.${t.replaceAll(/[/:]/g,".")}`,"apiReferenceOf"),bt=p(t=>{let e=te(t.argsSchema)??{};return t.functionPath===void 0?e:{args:e,functionPath:t.functionPath}},"requestBody"),yt=p((t,e,o)=>{let s=`${o}${e.httpPath}`,n=JSON.stringify(bt(e),void 0,2),r=JSON.stringify(te(e.argsSchema)??{},void 0,2);switch(t){case"curl":{let l=e.method!=="GET"&&e.method!=="HEAD",i=[`curl -X ${e.method} ${JSON.stringify(s)}`];return l&&i.push(' -H "Content-Type: application/json"',` -d '${n}'`),i.join(` \\
|
|
3
|
+
`)}case"lunora":return e.functionPath===void 0?`await fetch(${JSON.stringify(e.httpPath)}, { method: ${JSON.stringify(e.method)} });`:`import { useLunora } from "@lunora/react";
|
|
4
|
+
import { api } from "./_generated/api";
|
|
5
|
+
|
|
6
|
+
const client = useLunora();
|
|
7
|
+
await client.${e.kind??"query"}(${xt(e.functionPath)}, ${r});`;default:{let i=e.method!=="GET"&&e.method!=="HEAD"?`{
|
|
8
|
+
method: ${JSON.stringify(e.method)},
|
|
9
|
+
headers: { "Content-Type": "application/json" },
|
|
10
|
+
body: JSON.stringify(${n}),
|
|
11
|
+
}`:`{ method: ${JSON.stringify(e.method)} }`;return`const response = await fetch(${JSON.stringify(s)}, ${i});
|
|
12
|
+
const data = await response.json();`}}},"sampleSource"),Nt=p(t=>{let e=(0,J.c)(24),{operation:o,server:s}=t,n=M(),[r,l]=(0,K.useState)("curl"),i;e[0]!==o||e[1]!==r||e[2]!==s?(i=yt(r,o,s),e[0]=o,e[1]=r,e[2]=s,e[3]=i):i=e[3];let d=i,c;e[4]!==d?(c=p(()=>{re(d)},"t2"),e[4]=d,e[5]=c):c=e[5];let m=c,a;e[6]===Symbol.for("react.memo_cache_sentinel")?(a=p(S=>{l(S.currentTarget.dataset.sample)},"t3"),e[6]=a):a=e[6];let u=a,v;e[7]!==r?(v=ht.map(S=>(0,f.jsxDEV)("button",{"aria-selected":r===S,className:"rounded px-2 py-0.5 text-xs text-muted-foreground transition-colors hover:text-foreground aria-selected:bg-muted aria-selected:font-medium aria-selected:text-foreground","data-sample":S,"data-testid":`api-sample-${S}`,onClick:u,role:"tab",type:"button",children:gt[S]},S,!1)),e[7]=r,e[8]=v):v=e[8];let k;e[9]!==v?(k=(0,f.jsxDEV)("div",{className:"flex gap-1",role:"tablist",children:v},void 0,!1),e[9]=v,e[10]=k):k=e[10];let O;e[11]!==n?(O=n("Copy"),e[11]=n,e[12]=O):O=e[12];let h;e[13]!==m||e[14]!==O?(h=(0,f.jsxDEV)(H,{"data-testid":"api-sample-copy",onClick:m,size:"xs",type:"button",variant:"ghost",children:O},void 0,!1),e[13]=m,e[14]=O,e[15]=h):h=e[15];let g;e[16]!==k||e[17]!==h?(g=(0,f.jsxDEV)("div",{className:"flex items-center justify-between gap-2 border-b border-border px-3 py-2",children:[k,h]},void 0,!0),e[16]=k,e[17]=h,e[18]=g):g=e[18];let x;e[19]!==d?(x=(0,f.jsxDEV)("pre",{className:"overflow-auto px-3 pb-3 font-mono text-xs","data-testid":"api-sample-source",children:d},void 0,!1),e[19]=d,e[20]=x):x=e[20];let b;return e[21]!==g||e[22]!==x?(b=(0,f.jsxDEV)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card","data-testid":"api-code-samples",children:[g,x]},void 0,!0),e[21]=g,e[22]=x,e[23]=b):b=e[23],b},"CodeSamples"),St={blue:"text-info",emerald:"text-success",neutral:"text-muted-foreground",orange:"text-warning",red:"text-destructive",violet:"text-royal-amethyst"},kt=p(t=>{switch(t.toUpperCase()){case"DELETE":return"red";case"GET":return"emerald";case"PATCH":return"orange";case"POST":return"blue";case"PUT":return"orange";default:return"neutral"}},"methodTone"),wt=p(t=>{switch(t){case"action":return"violet";case"mutation":return"orange";case"query":return"emerald";default:return"neutral"}},"kindTone"),be=p(t=>{let e=(0,J.c)(7),{kind:o,method:s,testId:n}=t,r;e[0]!==o||e[1]!==s?(r=o??s.toUpperCase(),e[0]=o,e[1]=s,e[2]=r):r=e[2];let l=r,i=o===void 0?kt(s):wt(o),d=`${St[i]} font-mono text-[10px] tracking-wide uppercase`,c;return e[3]!==l||e[4]!==d||e[5]!==n?(c=(0,f.jsxDEV)(Ne,{className:d,"data-testid":n,variant:"ghost",children:l},void 0,!1),e[3]=l,e[4]=d,e[5]=n,e[6]=c):c=e[6],c},"MethodBadge"),Me=p(t=>t.startsWith("2")?"text-emerald-600 dark:text-emerald-400":t==="default"||t.startsWith("4")||t.startsWith("5")?"text-red-600 dark:text-red-400":"text-muted-foreground","statusToneClass"),Ke=p(t=>t.startsWith("2")?"bg-emerald-500":t==="default"||t.startsWith("4")||t.startsWith("5")?"bg-red-500":"bg-muted-foreground","statusDotClass"),Ot=p(t=>JSON.stringify(te(t.argsSchema)??{},void 0,2),"seedArgs"),Fe=(0,K.createContext)(null),Je=p(()=>{let t=(0,K.use)(Fe);if(t===null)throw new Error("useOperationRun must be used within an OperationRunProvider");return t},"useOperationRun"),$t=p(({children:t,operation:e})=>{let o=M(),s=G(),[n,r]=(0,K.useState)(()=>Ot(e)),[l,i]=(0,K.useState)(""),[d,c]=(0,K.useState)("idle"),[m,a]=(0,K.useState)(void 0),[u,v]=(0,K.useState)(null),[k,O]=(0,K.useState)(null),h=p(async()=>{let b;try{b=n.trim()===""?{}:JSON.parse(n)}catch(y){c("error"),a(void 0),O(null),v(o("Invalid JSON args: {message}",{message:ce(y)}));return}c("running"),v(null);let S=performance.now();try{let y;if(e.functionPath===void 0){let $=e.method!=="GET"&&e.method!=="HEAD",w=await(await fetch(e.httpPath,{body:$?JSON.stringify(b):void 0,headers:$?{"content-type":"application/json"}:void 0,method:e.method})).text();try{y=JSON.parse(w)}catch{y=w}}else{let $=le(e.functionPath),N=de(l);switch(e.kind){case"action":{y=await s.action($,b,N);break}case"mutation":{y=await s.mutation($,b,N);break}default:y=await s.query($,b,N)}}a(y),O(Math.round(performance.now()-S)),c("success")}catch(y){a(void 0),O(Math.round(performance.now()-S)),v(ce(y)),c("error")}},"send");return(0,f.jsxDEV)(Fe,{value:{argsText:n,durationMs:k,error:u,operation:e,response:m,send:p(()=>{$e(h())},"onSend"),setArgsText:r,setShardKey:i,shardKey:l,status:d},children:t},void 0,!1)},"OperationRunProvider"),It=p(()=>{let t=(0,J.c)(48),e=M(),{argsText:o,operation:s,send:n,setArgsText:r,setShardKey:l,shardKey:i,status:d}=Je(),c;t[0]!==r?(c=p(R=>{r(R.target.value)},"t0"),t[0]=r,t[1]=c):c=t[1];let m=c,a;t[2]!==n?(a=p(R=>{R.key==="Enter"&&(R.metaKey||R.ctrlKey)&&(R.preventDefault(),n())},"t1"),t[2]=n,t[3]=a):a=t[3];let u=a,v=d==="running",k;t[4]!==s.kind||t[5]!==s.method?(k=(0,f.jsxDEV)(be,{kind:s.kind,method:s.method,testId:"api-try-method"},void 0,!1),t[4]=s.kind,t[5]=s.method,t[6]=k):k=t[6];let O=s.functionPath??s.httpPath,h;t[7]!==O?(h=(0,f.jsxDEV)("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",children:O},void 0,!1),t[7]=O,t[8]=h):h=t[8];let g=v?"animate-pulse":void 0,x;t[9]!==g?(x=(0,f.jsxDEV)(ae,{className:g,icon:Oe,strokeWidth:2},void 0,!1),t[9]=g,t[10]=x):x=t[10];let b;t[11]!==v||t[12]!==e?(b=e(v?"Sending\u2026":"Send"),t[11]=v,t[12]=e,t[13]=b):b=t[13];let S;t[14]!==v||t[15]!==n||t[16]!==x||t[17]!==b?(S=(0,f.jsxDEV)(H,{"data-testid":"api-try-send",disabled:v,onClick:n,size:"sm",type:"button",children:[x,b]},void 0,!0),t[14]=v,t[15]=n,t[16]=x,t[17]=b,t[18]=S):S=t[18];let y;t[19]!==k||t[20]!==h||t[21]!==S?(y=(0,f.jsxDEV)("div",{className:"flex items-center gap-2 border-b border-border bg-muted px-3 py-2",children:[k,h,S]},void 0,!0),t[19]=k,t[20]=h,t[21]=S,t[22]=y):y=t[22];let $;t[23]!==e?($=e("Arguments (JSON)"),t[23]=e,t[24]=$):$=t[24];let N;t[25]!==$?(N=(0,f.jsxDEV)(xe,{htmlFor:"api-try-args",children:$},void 0,!1),t[25]=$,t[26]=N):N=t[26];let w;t[27]!==o?(w=o.split(`
|
|
13
|
+
`),t[27]=o,t[28]=w):w=t[28];let C=Math.min(12,Math.max(3,w.length)),T;t[29]!==o||t[30]!==m||t[31]!==u||t[32]!==C?(T=(0,f.jsxDEV)(Ce,{className:"font-mono text-xs","data-testid":"api-try-args",id:"api-try-args",onChange:m,onKeyDown:u,rows:C,spellCheck:!1,value:o},void 0,!1),t[29]=o,t[30]=m,t[31]=u,t[32]=C,t[33]=T):T=t[33];let I;t[34]!==N||t[35]!==T?(I=(0,f.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[N,T]},void 0,!0),t[34]=N,t[35]=T,t[36]=I):I=t[36];let A;t[37]!==s.functionPath||t[38]!==l||t[39]!==i||t[40]!==e?(A=s.functionPath!==void 0&&(0,f.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,f.jsxDEV)(xe,{htmlFor:"shard-input",children:e("Shard key (optional)")},void 0,!1),(0,f.jsxDEV)(Te,{id:"shard-input",onChange:l,testId:"shard-input",value:i},void 0,!1)]},void 0,!0),t[37]=s.functionPath,t[38]=l,t[39]=i,t[40]=e,t[41]=A):A=t[41];let E;t[42]!==I||t[43]!==A?(E=(0,f.jsxDEV)("div",{className:"flex flex-col gap-3 p-3",children:[I,A]},void 0,!0),t[42]=I,t[43]=A,t[44]=E):E=t[44];let j;return t[45]!==E||t[46]!==y?(j=(0,f.jsxDEV)("div",{className:"overflow-hidden rounded-xl border border-border bg-card","data-testid":"api-try-it",children:[y,E]},void 0,!0),t[45]=E,t[46]=y,t[47]=j):j=t[47],j},"TryIt"),Tt=p(t=>{let e=(0,J.c)(51),{operation:o}=t,s=M(),n=`api-operation-${o.operationId}`,r=o.key,l;e[0]!==o.kind||e[1]!==o.method?(l=(0,f.jsxDEV)(be,{kind:o.kind,method:o.method,testId:"api-operation-method"},void 0,!1),e[0]=o.kind,e[1]=o.method,e[2]=l):l=e[2];let i=o.functionPath??o.httpPath,d;e[3]!==i?(d=(0,f.jsxDEV)("code",{className:"truncate font-mono text-xs text-muted-foreground",children:i},void 0,!1),e[3]=i,e[4]=d):d=e[4];let c;e[5]!==l||e[6]!==d?(c=(0,f.jsxDEV)("div",{className:"flex items-center gap-2",children:[l,d]},void 0,!0),e[5]=l,e[6]=d,e[7]=c):c=e[7];let m;e[8]!==o.title?(m=(0,f.jsxDEV)("h1",{className:"text-lg font-semibold text-foreground","data-testid":"api-operation-title",children:o.title},void 0,!1),e[8]=o.title,e[9]=m):m=e[9];let a;e[10]!==o.description?(a=o.description!==void 0&&(0,f.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:o.description},void 0,!1),e[10]=o.description,e[11]=a):a=e[11];let u;e[12]!==c||e[13]!==m||e[14]!==a?(u=(0,f.jsxDEV)("header",{className:"sticky top-0 z-10 -mx-6 -mt-6 flex flex-col gap-2 border-b border-border bg-background px-6 pt-6 pb-3",children:[c,m,a]},void 0,!0),e[12]=c,e[13]=m,e[14]=a,e[15]=u):u=e[15];let v;e[16]!==s?(v=s("Try it"),e[16]=s,e[17]=v):v=e[17];let k;e[18]!==v?(k=(0,f.jsxDEV)("h2",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v},void 0,!1),e[18]=v,e[19]=k):k=e[19];let O;e[20]===Symbol.for("react.memo_cache_sentinel")?(O=(0,f.jsxDEV)(It,{},void 0,!1),e[20]=O):O=e[20];let h;e[21]!==k?(h=(0,f.jsxDEV)("section",{className:"flex flex-col gap-2",children:[k,O]},void 0,!0),e[21]=k,e[22]=h):h=e[22];let g;e[23]!==s?(g=s("Request arguments"),e[23]=s,e[24]=g):g=e[24];let x;e[25]!==g?(x=(0,f.jsxDEV)("h2",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:g},void 0,!1),e[25]=g,e[26]=x):x=e[26];let b;e[27]!==o.argsSchema?(b=(0,f.jsxDEV)(je,{schema:o.argsSchema,testId:"api-operation-args"},void 0,!1),e[27]=o.argsSchema,e[28]=b):b=e[28];let S;e[29]!==x||e[30]!==b?(S=(0,f.jsxDEV)("section",{className:"flex flex-col gap-2",children:[x,b]},void 0,!0),e[29]=x,e[30]=b,e[31]=S):S=e[31];let y;e[32]!==s?(y=s("Response body"),e[32]=s,e[33]=y):y=e[33];let $;e[34]!==y?($=(0,f.jsxDEV)("h2",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y},void 0,!1),e[34]=y,e[35]=$):$=e[35];let N;if(e[36]!==o.responses||e[37]!==s){let T;e[39]!==s?(T=p(I=>(0,f.jsxDEV)("div",{className:"flex flex-col gap-1.5 rounded-xl border border-border bg-card p-3",children:[(0,f.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[(0,f.jsxDEV)("span",{className:`inline-flex items-center gap-1.5 font-mono text-xs font-semibold ${Me(I.status)}`,children:[(0,f.jsxDEV)("span",{className:`size-1.5 rounded-full ${Ke(I.status)}`},void 0,!1),I.status]},void 0,!0),I.schema!==void 0&&(0,f.jsxDEV)("span",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground",children:s("application/json")},void 0,!1)]},void 0,!0),I.description!==void 0&&(0,f.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:I.description},void 0,!1),I.schema!==void 0&&(0,f.jsxDEV)(je,{schema:I.schema,testId:`api-response-${I.status}`},void 0,!1)]},I.status,!0),"t212"),e[39]=s,e[40]=T):T=e[40],N=o.responses.map(T),e[36]=o.responses,e[37]=s,e[38]=N}else N=e[38];let w;e[41]!==$||e[42]!==N?(w=(0,f.jsxDEV)("section",{className:"flex flex-col gap-3",children:[$,N]},void 0,!0),e[41]=$,e[42]=N,e[43]=w):w=e[43];let C;return e[44]!==o.key||e[45]!==n||e[46]!==h||e[47]!==S||e[48]!==w||e[49]!==u?(C=(0,f.jsxDEV)("div",{className:"flex flex-col gap-6 duration-200 animate-in fade-in-0 slide-in-from-bottom-1","data-testid":n,children:[u,h,S,w]},r,!0),e[44]=o.key,e[45]=n,e[46]=h,e[47]=S,e[48]=w,e[49]=u,e[50]=C):C=e[50],C},"OperationView"),Ct={boolean:"text-royal-amethyst",key:"text-sky-sapphire",number:"text-warning",plain:"",string:"text-success"},Pt=/"(?:[^"\\]|\\.)*"|\b(?:true|false|null)\b|-?\d+(?:\.\d+)?/g,At=/^\s*:/,Rt=p((t,e,o)=>o.startsWith('"')?At.test(t.slice(e))?"key":"string":o==="true"||o==="false"||o==="null"?"boolean":"number","classify"),Et=p(t=>{let e=[],o=0;for(let s of t.matchAll(Pt)){let{index:n}=s,r=s[0],l=n+r.length;n>o&&e.push({kind:"plain",start:o,text:t.slice(o,n)}),e.push({kind:Rt(t,l,r),start:n,text:r}),o=l}return o<t.length&&e.push({kind:"plain",start:o,text:t.slice(o)}),e},"tokenize"),_t=p(t=>{let e=(0,J.c)(4),{code:o}=t,s;e[0]!==o?(s=Et(o).map(jt),e[0]=o,e[1]=s):s=e[1];let n;return e[2]!==s?(n=(0,f.jsxDEV)(f.Fragment,{children:s},void 0,!1),e[2]=s,e[3]=n):n=e[3],n},"JsonHighlight");function jt(t){return(0,f.jsxDEV)("span",{className:Ct[t.kind],children:t.text},t.start,!1)}p(jt,"_temp$1");var Be="__live__",Bt=p(t=>t.schema===void 0?"":JSON.stringify(te(t.schema),void 0,2),"exampleBody"),Lt=p((t,e,o)=>o?t??"":e===void 0?"":JSON.stringify(e,void 0,2),"liveBody"),Dt=p(t=>{let e=(0,J.c)(18),{active:o,running:s,showError:n}=t,r=M();if(s){let a;e[0]!==r?(a=r("Sending\u2026"),e[0]=r,e[1]=a):a=e[1];let u;return e[2]!==a?(u=(0,f.jsxDEV)("p",{className:"px-3 py-3 text-xs text-muted-foreground","data-testid":"api-response-running",children:a},void 0,!1),e[2]=a,e[3]=u):u=e[3],u}if(o===void 0||o.body===""){let a;e[4]!==o?.live||e[5]!==r?(a=o?.live===!0?r("Send a request to see the response."):r("No example for this response."),e[4]=o?.live,e[5]=r,e[6]=a):a=e[6];let u;return e[7]!==a?(u=(0,f.jsxDEV)("p",{className:"px-3 py-3 text-xs text-muted-foreground","data-testid":"api-response-idle",children:a},void 0,!1),e[7]=a,e[8]=u):u=e[8],u}let l=n&&"text-destructive",i;e[9]!==l?(i=ge("max-h-[28rem] overflow-auto px-3 py-3 font-mono text-xs",l),e[9]=l,e[10]=i):i=e[10];let d=n?"api-response-error":"api-response-body",c;e[11]!==o.body||e[12]!==n?(c=n?o.body:(0,f.jsxDEV)(_t,{code:o.body},void 0,!1),e[11]=o.body,e[12]=n,e[13]=c):c=e[13];let m;return e[14]!==i||e[15]!==d||e[16]!==c?(m=(0,f.jsxDEV)("pre",{className:i,"data-testid":d,children:c},void 0,!1),e[14]=i,e[15]=d,e[16]=c,e[17]=m):m=e[17],m},"ResponseBody"),Mt=p(()=>{let t=(0,J.c)(67),e=M(),{durationMs:o,error:s,operation:n,response:r,status:l}=Je(),i=l==="running",d=l==="error",c=l==="success"||d,m;if(t[0]!==o||t[1]!==s||t[2]!==d||t[3]!==n.responses||t[4]!==c||t[5]!==r||t[6]!==e){e:{let B=n.responses.map(Kt);if(!c){m=B;break e}let P;t[8]!==s||t[9]!==d||t[10]!==r?(P=Lt(s,r,d),t[8]=s,t[9]=d,t[10]=r,t[11]=P):P=t[11];let _;t[12]!==e?(_=e("Live"),t[12]=e,t[13]=_):_=t[13];let D=d?"error":"200",V;t[14]!==o||t[15]!==P||t[16]!==_||t[17]!==D?(V={body:P,durationMs:o,id:Be,label:_,live:!0,status:D},t[14]=o,t[15]=P,t[16]=_,t[17]=D,t[18]=V):V=t[18],m=[V,...B]}t[0]=o,t[1]=s,t[2]=d,t[3]=n.responses,t[4]=c,t[5]=r,t[6]=e,t[7]=m}else m=t[7];let a=m,u;t[19]!==c||t[20]!==a?(u=c?Be:a.find(Ft)?.id??a[0]?.id??"",t[19]=c,t[20]=a,t[21]=u):u=t[21];let v=u,[k,O]=(0,K.useState)(null),h,g,x,b,S,y,$,N,w,C;if(t[22]!==v||t[23]!==k||t[24]!==e||t[25]!==a){h=a.find(D=>D.id===(k??v))??a[0];let B;t[36]===Symbol.for("react.memo_cache_sentinel")?(B=p(D=>{let{id:V}=D.currentTarget.dataset;V!==void 0&&O(V)},"t82"),t[36]=B):B=t[36],x=B,g=p(()=>{h!==void 0&&re(h.body)},"onCopy");let P=h?.live===!0?h.durationMs:null;b=h?.live===!0&&h.status==="error",w="flex min-h-0 flex-col rounded-xl border border-border bg-card",C="api-response-panel",$="flex items-center justify-between gap-2 border-b border-border px-3 py-2";let _;t[37]!==e?(_=e("Response"),t[37]=e,t[38]=_):_=t[38],t[39]!==_?(N=(0,f.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:_},void 0,!1),t[39]=_,t[40]=N):N=t[40],S="flex items-center gap-2",y=P!==null&&(0,f.jsxDEV)("span",{className:"font-mono text-[10px] text-muted-foreground",children:e("{ms} ms",{ms:P})},void 0,!1),t[22]=v,t[23]=k,t[24]=e,t[25]=a,t[26]=h,t[27]=g,t[28]=x,t[29]=b,t[30]=S,t[31]=y,t[32]=$,t[33]=N,t[34]=w,t[35]=C}else h=t[26],g=t[27],x=t[28],b=t[29],S=t[30],y=t[31],$=t[32],N=t[33],w=t[34],C=t[35];let T;t[41]!==h||t[42]!==g||t[43]!==e?(T=h!==void 0&&h.body!==""&&(0,f.jsxDEV)(H,{"aria-label":e("Copy"),"data-testid":"api-response-copy",onClick:g,size:"icon-xs",type:"button",variant:"ghost",children:(0,f.jsxDEV)(ae,{icon:ke,strokeWidth:2},void 0,!1)},void 0,!1),t[41]=h,t[42]=g,t[43]=e,t[44]=T):T=t[44];let I;t[45]!==S||t[46]!==y||t[47]!==T?(I=(0,f.jsxDEV)("div",{className:S,children:[y,T]},void 0,!0),t[45]=S,t[46]=y,t[47]=T,t[48]=I):I=t[48];let A;t[49]!==$||t[50]!==N||t[51]!==I?(A=(0,f.jsxDEV)("div",{className:$,children:[N,I]},void 0,!0),t[49]=$,t[50]=N,t[51]=I,t[52]=A):A=t[52];let E;t[53]!==h?.id||t[54]!==x||t[55]!==a?(E=a.length>0&&(0,f.jsxDEV)("div",{className:"flex gap-1 overflow-x-auto border-b border-border px-2 py-1.5",role:"tablist",children:a.map(B=>{let P=B.id===h?.id;return(0,f.jsxDEV)("button",{"aria-selected":P,className:ge("inline-flex items-center gap-1.5 rounded px-2 py-0.5 font-mono text-xs transition-colors hover:text-foreground aria-selected:bg-muted aria-selected:font-medium",P?Me(B.status):"text-muted-foreground"),"data-id":B.id,"data-testid":B.live?"api-response-tab-live":`api-response-tab-${B.status}`,onClick:x,role:"tab",type:"button",children:[(0,f.jsxDEV)("span",{className:`size-1.5 rounded-full ${Ke(B.status)}`},void 0,!1),B.label]},B.id,!0)})},void 0,!1),t[53]=h?.id,t[54]=x,t[55]=a,t[56]=E):E=t[56];let j;t[57]!==h||t[58]!==i||t[59]!==b?(j=(0,f.jsxDEV)(Dt,{active:h,running:i,showError:b},void 0,!1),t[57]=h,t[58]=i,t[59]=b,t[60]=j):j=t[60];let R;return t[61]!==A||t[62]!==E||t[63]!==j||t[64]!==w||t[65]!==C?(R=(0,f.jsxDEV)("div",{className:w,"data-testid":C,children:[A,E,j]},void 0,!0),t[61]=A,t[62]=E,t[63]=j,t[64]=w,t[65]=C,t[66]=R):R=t[66],R},"ResponsePanel");function Kt(t){return{body:Bt(t),durationMs:null,id:t.status,label:t.status,live:!1,status:t.status}}p(Kt,"_temp");function Ft(t){return t.status.startsWith("2")}p(Ft,"_temp2");var Jt=p((t,e)=>{let o=e.trim().toLowerCase();return o===""?t:t.map(s=>({...s,operations:s.operations.filter(n=>`${n.summary} ${n.operationId}`.toLowerCase().includes(o))})).filter(s=>s.operations.length>0)},"filterGroups"),me=p(t=>{let e=(0,J.c)(53),{model:o}=t,s=M(),n=o.groups[0]?.operations[0]?.key??"",[r,l]=(0,K.useState)(n),[i,d]=(0,K.useState)(""),c;e[0]!==n||e[1]!==o.operationByKey||e[2]!==r?(c=o.operationByKey.get(r)??o.operationByKey.get(n),e[0]=n,e[1]=o.operationByKey,e[2]=r,e[3]=c):c=e[3];let m=c,a,u,v,k,O,h,g,x,b,S;if(e[4]!==i||e[5]!==o.groups||e[6]!==o.server||e[7]!==m?.key||e[8]!==s){a=Jt(o.groups,i);let T;e[19]===Symbol.for("react.memo_cache_sentinel")?(T=p(P=>{let{key:_}=P.currentTarget.dataset;_!==void 0&&l(_)},"t102"),e[19]=T):T=e[19];let I=T,A;e[20]===Symbol.for("react.memo_cache_sentinel")?(A=p(P=>{d(P.target.value)},"t112"),e[20]=A):A=e[20];let E=A;u=o.server??"",b="grid min-h-0 flex-1 grid-cols-1 overflow-hidden lg:grid-cols-[16rem_minmax(0,1fr)_22rem]",S="api-reference",e[21]!==s?(O=s("API operations"),e[21]=s,e[22]=O):O=e[22],h="flex min-h-0 flex-col overflow-y-auto border-r border-border",g="api-reference-nav";let j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=(0,f.jsxDEV)(ae,{className:"pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-muted-foreground",icon:we,strokeWidth:2},void 0,!1),e[23]=j):j=e[23];let R;e[24]!==s?(R=s("Filter operations"),e[24]=s,e[25]=R):R=e[25],e[26]!==i||e[27]!==R?(x=(0,f.jsxDEV)("div",{className:"sticky top-0 z-10 border-b border-border bg-sidebar p-2",children:(0,f.jsxDEV)("div",{className:"relative",children:[j,(0,f.jsxDEV)(Se,{className:"h-7 pl-7","data-testid":"api-filter",onChange:E,placeholder:R,value:i},void 0,!1)]},void 0,!0)},void 0,!1),e[26]=i,e[27]=R,e[28]=x):x=e[28],v="flex flex-col gap-4 p-2";let B;e[29]!==m?.key||e[30]!==s?(B=p(P=>(0,f.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,f.jsxDEV)("div",{className:"flex items-center justify-between px-2",children:[(0,f.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:P.name||s("(root)")},void 0,!1),(0,f.jsxDEV)("span",{className:"font-mono text-[10px] text-muted-foreground/70",children:P.operations.length},void 0,!1)]},void 0,!0),P.operations.map(_=>{let D=_.key===m?.key;return(0,f.jsxDEV)("button",{"aria-current":D?"page":void 0,className:"flex items-center justify-between gap-2 rounded-md border-l-2 border-transparent px-2 py-1 text-start text-xs text-muted-foreground transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground aria-[current=page]:border-primary aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-key":_.key,"data-testid":`api-nav-${_.operationId}`,onClick:I,type:"button",children:[(0,f.jsxDEV)("span",{className:"truncate",children:_.summary},void 0,!1),(0,f.jsxDEV)(be,{kind:_.kind,method:_.method},void 0,!1)]},_.key,!0)})]},P.name,!0),"t142"),e[29]=m?.key,e[30]=s,e[31]=B):B=e[31],k=a.map(B),e[4]=i,e[5]=o.groups,e[6]=o.server,e[7]=m?.key,e[8]=s,e[9]=a,e[10]=u,e[11]=v,e[12]=k,e[13]=O,e[14]=h,e[15]=g,e[16]=x,e[17]=b,e[18]=S}else a=e[9],u=e[10],v=e[11],k=e[12],O=e[13],h=e[14],g=e[15],x=e[16],b=e[17],S=e[18];let y;e[32]!==a.length||e[33]!==s?(y=a.length===0&&(0,f.jsxDEV)("p",{className:"px-2 py-1 text-xs text-muted-foreground","data-testid":"api-nav-empty",children:s("No operations match your filter.")},void 0,!1),e[32]=a.length,e[33]=s,e[34]=y):y=e[34];let $;e[35]!==y||e[36]!==v||e[37]!==k?($=(0,f.jsxDEV)("div",{className:v,children:[k,y]},void 0,!0),e[35]=y,e[36]=v,e[37]=k,e[38]=$):$=e[38];let N;e[39]!==$||e[40]!==O||e[41]!==h||e[42]!==g||e[43]!==x?(N=(0,f.jsxDEV)("nav",{"aria-label":O,className:h,"data-testid":g,children:[x,$]},void 0,!0),e[39]=$,e[40]=O,e[41]=h,e[42]=g,e[43]=x,e[44]=N):N=e[44];let w;e[45]!==m||e[46]!==u?(w=m===void 0?(0,f.jsxDEV)("div",{className:"lg:col-span-2"},void 0,!1):(0,f.jsxDEV)($t,{operation:m,children:[(0,f.jsxDEV)("div",{className:"min-w-0 overflow-y-auto p-6","data-testid":"api-reference-main",children:(0,f.jsxDEV)(Tt,{operation:m},void 0,!1)},void 0,!1),(0,f.jsxDEV)("aside",{className:"flex min-w-0 flex-col gap-4 overflow-y-auto border-border p-4 lg:border-l","data-testid":"api-reference-aside",children:[(0,f.jsxDEV)(Nt,{operation:m,server:u},void 0,!1),(0,f.jsxDEV)(Mt,{},void 0,!1)]},void 0,!0)]},m.key,!0),e[45]=m,e[46]=u,e[47]=w):w=e[47];let C;return e[48]!==N||e[49]!==w||e[50]!==b||e[51]!==S?(C=(0,f.jsxDEV)("div",{className:b,"data-testid":S,children:[N,w]},void 0,!0),e[48]=N,e[49]=w,e[50]=b,e[51]=S,e[52]=C):C=e[52],C},"ReferenceView");var Y=q(ne(),1);var qt=["get","post","put","patch","delete","head","options","trace"],Ve=p(t=>t?.content?.["application/json"]?.schema,"jsonSchemaOf"),Vt=p((t,e)=>Object.entries(t.responses??{}).map(([o,s])=>{let n=s.$ref?.replace("#/components/responses/",""),r=n===void 0?s:e.components?.responses?.[n]??s;return{description:r.description,schema:Ve(r),status:o}}),"buildResponses"),zt=p((t,e,o,s,n)=>{let r=Ve(s.requestBody),l=r?.properties?.functionPath?.const,i=typeof l=="string"?l:void 0,d=i===void 0?r:r?.properties?.args,c=s.operationId??`${o} ${e}`;return{argsSchema:d,description:s.description,functionPath:i,httpPath:e,key:t,kind:s["x-lunora-function-kind"],method:o.toUpperCase(),operationId:c,requestSchema:r,responses:Vt(s,n),summary:s.summary??c,tags:s.tags??[],title:s.summary??c}},"flattenOperation"),Ht=p(t=>{let e=[];for(let[o,s]of Object.entries(t.paths??{})){let n=o.includes("#")?o.slice(0,o.indexOf("#")):o;for(let r of qt){let l=s[r];l!==void 0&&e.push(zt(o,n,r,l,t))}}return e},"collectOperations"),Wt=p(t=>{let e=t??{},o=Ht(e),s=new Map((e.tags??[]).map(i=>[i.name,i.description])),n=new Set,r=[],l=p(i=>{if(n.has(i))return;n.add(i);let d=o.filter(c=>(c.tags[0]??"")===i);d.length>0&&r.push({description:s.get(i),name:i,operations:d})},"pushGroup");for(let i of e.tags??[])l(i.name);for(let i of o)l(i.tags[0]??"");return{groups:r,operationByKey:new Map(o.map(i=>[i.key,i])),server:e.servers?.[0]?.url,title:e.info?.title??"API reference",version:e.info?.version}},"parseOpenApi"),Gt=p(t=>{let{paths:e}=t;return e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0},"isEmptySpec"),Ut=p(t=>{let e=t;return Gt(e)?{kind:"empty"}:{kind:"ready",spec:e}},"classifySpec"),ze=p(t=>{let e=(0,qe.c)(23),{spec:o}=t,s=M(),n=G(),r;e[0]!==n?(r=p(()=>n.fetchOpenApi(),"t1"),e[0]=n,e[1]=r):r=e[1];let i=ue(o,r,Ut),d;e[2]!==i.kind||e[3]!==i.spec?(d=i.kind==="ready"?Wt(i.spec):void 0,e[2]=i.kind,e[3]=i.spec,e[4]=d):d=e[4];let c=d;if(i.kind==="loading"){let a;return e[5]===Symbol.for("react.memo_cache_sentinel")?(a=(0,Y.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"api-reference-loading",children:[(0,Y.jsxDEV)(X,{className:"h-8 w-48"},void 0,!1),(0,Y.jsxDEV)(X,{className:"h-64 w-full"},void 0,!1)]},void 0,!0),e[5]=a):a=e[5],a}if(i.kind==="error"){let a;e[6]!==i.message||e[7]!==s?(a=s("Couldn't load the OpenAPI spec: {message}",{message:i.message}),e[6]=i.message,e[7]=s,e[8]=a):a=e[8];let u;e[9]!==s?(u=s("API reference unavailable"),e[9]=s,e[10]=u):u=e[10];let v;return e[11]!==a||e[12]!==u?(v=(0,Y.jsxDEV)(W,{description:a,testId:"api-reference-error",title:u},void 0,!1),e[11]=a,e[12]=u,e[13]=v):v=e[13],v}if(i.kind==="empty"||c===void 0){let a;e[14]!==s?(a=s("Run `lunora codegen` and wire `_generated/openapi.json` to the worker to render the API reference here."),e[14]=s,e[15]=a):a=e[15];let u;e[16]!==s?(u=s("No OpenAPI spec configured"),e[16]=s,e[17]=u):u=e[17];let v;return e[18]!==a||e[19]!==u?(v=(0,Y.jsxDEV)(W,{description:a,testId:"api-reference-empty",title:u},void 0,!1),e[18]=a,e[19]=u,e[20]=v):v=e[20],v}let m;return e[21]!==c?(m=(0,Y.jsxDEV)(me,{model:c},void 0,!1),e[21]=c,e[22]=m):m=e[22],m},"ApiReferencePanel");var He=q(oe(),1);var Q=q(ne(),1);var Yt=p(t=>(t.params??[]).find(e=>e.name==="args")??(t.params??[])[0],"argsParameterOf"),Qt=p(t=>t["x-tags"]?.[0]?.name??(t.name.includes(":")?t.name.slice(0,t.name.indexOf(":")):""),"namespaceOf"),Xt=p(t=>{let e=Yt(t)?.schema;return{argsSchema:e,description:t.description,functionPath:t.name,httpPath:"/_lunora/rpc",key:t.name,kind:t["x-lunora-function-kind"],method:"POST",operationId:t.name,requestSchema:e,responses:[{description:t.result?.name,schema:t.result?.schema,status:"200"}],summary:t.summary??t.name,tags:[Qt(t)],title:t.summary??t.name}},"toOperation"),Zt=p(t=>{let e=t??{},o=(e.methods??[]).map(r=>Xt(r)),s=new Map;for(let r of o){let l=r.tags[0]??"",i=s.get(l)??[];i.push(r),s.set(l,i)}return{groups:[...s.entries()].map(([r,l])=>({name:r,operations:l.toSorted((i,d)=>i.operationId.localeCompare(d.operationId))})).toSorted((r,l)=>r.name.localeCompare(l.name)),operationByKey:new Map(o.map(r=>[r.key,r])),title:e.info?.title??"API reference",version:e.info?.version}},"parseOpenRpc"),es=p(t=>t.methods===void 0||t.methods.length===0,"isEmptyDocument"),ts=p(t=>{let e=t;return es(e)?{kind:"empty"}:{kind:"ready",spec:e}},"classifyDocument"),We=p(t=>{let e=(0,He.c)(23),{spec:o}=t,s=M(),n=G(),r;e[0]!==n?(r=p(()=>n.fetchOpenRpc(),"t1"),e[0]=n,e[1]=r):r=e[1];let i=ue(o,r,ts),d;e[2]!==i.kind||e[3]!==i.spec?(d=i.kind==="ready"?Zt(i.spec):void 0,e[2]=i.kind,e[3]=i.spec,e[4]=d):d=e[4];let c=d;if(i.kind==="loading"){let a;return e[5]===Symbol.for("react.memo_cache_sentinel")?(a=(0,Q.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"openrpc-reference-loading",children:[(0,Q.jsxDEV)(X,{className:"h-8 w-48"},void 0,!1),(0,Q.jsxDEV)(X,{className:"h-64 w-full"},void 0,!1)]},void 0,!0),e[5]=a):a=e[5],a}if(i.kind==="error"){let a;e[6]!==i.message||e[7]!==s?(a=s("Couldn't load the OpenRPC spec: {message}",{message:i.message}),e[6]=i.message,e[7]=s,e[8]=a):a=e[8];let u;e[9]!==s?(u=s("API reference unavailable"),e[9]=s,e[10]=u):u=e[10];let v;return e[11]!==a||e[12]!==u?(v=(0,Q.jsxDEV)(W,{description:a,testId:"openrpc-reference-error",title:u},void 0,!1),e[11]=a,e[12]=u,e[13]=v):v=e[13],v}if(i.kind==="empty"||c===void 0){let a;e[14]!==s?(a=s("Run `lunora codegen --api-spec openrpc` and wire `_generated/openrpc.json` to the worker to render the OpenRPC reference here."),e[14]=s,e[15]=a):a=e[15];let u;e[16]!==s?(u=s("No OpenRPC spec configured"),e[16]=s,e[17]=u):u=e[17];let v;return e[18]!==a||e[19]!==u?(v=(0,Q.jsxDEV)(W,{description:a,testId:"openrpc-reference-empty",title:u},void 0,!1),e[18]=a,e[19]=u,e[20]=v):v=e[20],v}let m;return e[21]!==c?(m=(0,Q.jsxDEV)(me,{model:c},void 0,!1),e[21]=c,e[22]=m):m=e[22],m},"OpenRpcReferencePanel");var z=q(ne(),1);var ss=["reference","snippets"],os=["openapi","openrpc"],zs=p(t=>{let e=(0,Ge.c)(51),{functions:o,initialShardKey:s,openApiSpec:n,openRpcSpec:r}=t,l=M(),[i,d]=(0,ye.useState)("reference"),[c,m]=(0,ye.useState)("openapi"),a;e[0]!==l?(a=l("Reference"),e[0]=l,e[1]=a):a=e[1];let u;e[2]!==l?(u=l("Snippets"),e[2]=l,e[3]=u):u=e[3];let v;e[4]!==a||e[5]!==u?(v={reference:a,snippets:u},e[4]=a,e[5]=u,e[6]=v):v=e[6];let k=v,O;e[7]!==l?(O=l("OpenAPI"),e[7]=l,e[8]=O):O=e[8];let h;e[9]!==l?(h=l("OpenRPC"),e[9]=l,e[10]=h):h=e[10];let g;e[11]!==O||e[12]!==h?(g={openapi:O,openrpc:h},e[11]=O,e[12]=h,e[13]=g):g=e[13];let x=g,b;e[14]===Symbol.for("react.memo_cache_sentinel")?(b=p(P=>{d(P.currentTarget.dataset.view)},"t7"),e[14]=b):b=e[14];let S=b,y;e[15]===Symbol.for("react.memo_cache_sentinel")?(y=p(P=>{m(P.currentTarget.dataset.format)},"t8"),e[15]=y):y=e[15];let $=y,N;e[16]!==l?(N=l("API view"),e[16]=l,e[17]=N):N=e[17];let w;e[18]!==i||e[19]!==k?(w=ss.map(P=>(0,z.jsxDEV)(H,{"aria-selected":i===P,"data-testid":`api-view-${P}`,"data-view":P,onClick:S,role:"tab",size:"sm",type:"button",variant:i===P?"default":"outline",children:k[P]},P,!1)),e[18]=i,e[19]=k,e[20]=w):w=e[20];let C;e[21]!==w||e[22]!==N?(C=(0,z.jsxDEV)("div",{"aria-label":N,className:"flex gap-1.5","data-testid":"api-view-toggle",role:"tablist",children:w},void 0,!1),e[21]=w,e[22]=N,e[23]=C):C=e[23];let T;e[24]!==c||e[25]!==x||e[26]!==l||e[27]!==i?(T=i==="reference"&&(0,z.jsxDEV)("div",{"aria-label":l("API spec format"),className:"flex gap-1.5","data-testid":"api-format-toggle",role:"tablist",children:os.map(P=>(0,z.jsxDEV)(H,{"aria-selected":c===P,"data-format":P,"data-testid":`api-format-${P}`,onClick:$,role:"tab",size:"sm",type:"button",variant:c===P?"default":"outline",children:x[P]},P,!1))},void 0,!1),e[24]=c,e[25]=x,e[26]=l,e[27]=i,e[28]=T):T=e[28];let I;e[29]!==C||e[30]!==T?(I=(0,z.jsxDEV)("div",{className:"flex shrink-0 flex-wrap items-center gap-3 border-b border-border px-6 py-3",children:[C,T]},void 0,!0),e[29]=C,e[30]=T,e[31]=I):I=e[31];let A;e[32]!==o||e[33]!==s||e[34]!==i?(A=i==="snippets"&&(0,z.jsxDEV)("div",{className:"min-h-0 flex-1 overflow-y-auto p-6",children:(0,z.jsxDEV)(_e,{functions:o,initialShardKey:s},void 0,!1)},void 0,!1),e[32]=o,e[33]=s,e[34]=i,e[35]=A):A=e[35];let E;e[36]!==c||e[37]!==n||e[38]!==i?(E=i==="reference"&&c==="openapi"&&(0,z.jsxDEV)(ze,{spec:n},void 0,!1),e[36]=c,e[37]=n,e[38]=i,e[39]=E):E=e[39];let j;e[40]!==c||e[41]!==r||e[42]!==i?(j=i==="reference"&&c==="openrpc"&&(0,z.jsxDEV)(We,{spec:r},void 0,!1),e[40]=c,e[41]=r,e[42]=i,e[43]=j):j=e[43];let R;e[44]!==A||e[45]!==E||e[46]!==j?(R=(0,z.jsxDEV)("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[A,E,j]},void 0,!0),e[44]=A,e[45]=E,e[46]=j,e[47]=R):R=e[47];let B;return e[48]!==I||e[49]!==R?(B=(0,z.jsxDEV)("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"lunora-api-tab",children:[I,R]},void 0,!0),e[48]=I,e[49]=R,e[50]=B):B=e[50],B},"ApiTab");export{zs as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as r,e as i,f as p,g as l}from"./chunk-RRCPZMC2.js";var u=i(l(),1),n=i(p(),1);var D=r(function(e,d){let t=(0,u.c)(4),o=d===void 0?300:d,[f,m]=(0,n.useState)(e),s,c;return t[0]!==o||t[1]!==e?(s=r(()=>{let b=setTimeout(()=>{m(e)},o);return()=>{clearTimeout(b)}},"t1"),c=[e,o],t[0]=o,t[1]=e,t[2]=s,t[3]=c):(s=t[2],c=t[3]),(0,n.useEffect)(s,c),f},"useDebounced");export{D as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as i,e as n,g as c,h as p}from"./chunk-RRCPZMC2.js";var b=n(c(),1),d=n(p(),1);var S={alignItems:"center",border:"1px solid",borderRadius:4,display:"inline-flex",fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:11,fontWeight:400,gap:6,letterSpacing:"0.06em",lineHeight:1.4,padding:"1px 8px",textTransform:"uppercase"},g={borderRadius:"50%",display:"inline-block",height:7,width:7},h=i((r,e,a,t)=>({badgeStyle:{...S,borderColor:r,color:r},color:r,dotStyle:{...g,backgroundColor:r},hint:t,label:e,title:a}),"makeTier"),y={global:h("var(--royal-amethyst)","Global \xB7 D1","Global table \u2014 a single D1 table shared across all shards","Declared .global() and stored once in Cloudflare D1, shared across every shard and tenant. Auth tables (user, session, \u2026) live here too."),shard:h("var(--sky-sapphire)","Shard-local","Shard-local table \u2014 per-shard SQLite inside a Durable Object","Stored per shard key in a Durable Object's SQLite (.shardBy(...)). You are viewing one shard at a time \u2014 change the shard key to inspect another.")},m=i(r=>{let e=(0,b.c)(9),{tier:a}=r,t=y[a],o=`storage-tier-${a}`,l;e[0]!==t.dotStyle?(l=(0,d.jsxDEV)("span",{"aria-hidden":"true",style:t.dotStyle},void 0,!1),e[0]=t.dotStyle,e[1]=l):l=e[1];let s;return e[2]!==t.badgeStyle||e[3]!==t.label||e[4]!==t.title||e[5]!==o||e[6]!==l||e[7]!==a?(s=(0,d.jsxDEV)("span",{"data-testid":o,"data-tier":a,style:t.badgeStyle,title:t.title,children:[l,t.label]},void 0,!0),e[2]=t.badgeStyle,e[3]=t.label,e[4]=t.title,e[5]=o,e[6]=l,e[7]=a,e[8]=s):s=e[8],s},"StorageTierBadge");export{y as a,m as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as q,b as B,c as V,d as p,e as d,f as n}from"./chunk-GTM65MVX.js";import{R as $}from"./chunk-BHTPZS7L.js";import{c as A}from"./chunk-YQQJ4N6U.js";import"./chunk-TICVNLPM.js";import"./chunk-HV7G6DFP.js";import{a as H}from"./chunk-TAD43CG5.js";import{a as S,e as k}from"./chunk-SEU5V7I6.js";import"./chunk-ZH7UES4T.js";import{f as F}from"./chunk-KODWGUAB.js";import"./chunk-3OA7PECS.js";import{d as Q,g as E,h as K,i as I}from"./chunk-YJGANMU7.js";import{a as f,e as C,f as Z,g as G,h as J}from"./chunk-RRCPZMC2.js";var z=C(G(),1);var s=C(Z(),1);var e=C(J(),1);var X=10,g=f(x=>{let l=(0,z.c)(7),{label:m,value:a}=x,r;l[0]!==m?(r=(0,e.jsxDEV)("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:m},void 0,!1),l[0]=m,l[1]=r):r=l[1];let v=a??"\u2014",o;l[2]!==v?(o=(0,e.jsxDEV)("span",{className:"font-mono text-sm",children:v},void 0,!1),l[2]=v,l[3]=o):o=l[3];let u;return l[4]!==r||l[5]!==o?(u=(0,e.jsxDEV)("div",{className:"flex flex-col gap-0.5",children:[r,o]},void 0,!0),l[4]=r,l[5]=o,l[6]=u):u=l[6],u},"Detail"),oe=f(({loadIndexes:x,runQuery:l}={})=>{let m=F(),a=Q(),[r,v]=(0,s.useState)(null),[o,u]=(0,s.useState)(null),[b,L]=(0,s.useState)(null),[N,O]=(0,s.useState)(""),[h,y]=(0,s.useState)(null),[M,w]=(0,s.useState)(null),[j,D]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let t={cancelled:!1};return I((async()=>{try{let c=await(x??(()=>m.listVectorIndexes()))();t.cancelled||(v(c),u(null),L(T=>T??c[0]?.name??null))}catch(c){t.cancelled||(v(null),u(E(c)))}})()),()=>{t.cancelled=!0}},[m,x]);let i=r?.find(t=>t.name===b)??null,P=f(t=>{L(t.currentTarget.dataset.index??null),y(null),w(null)},"onSelect"),R=f(t=>{O(t.target.value)},"onQueryTextChange"),U=f(async()=>{let t=N.trim();if(!(b===null||t==="")){D(!0),w(null);try{let c=await(l??(T=>m.queryVectorIndex(T)))({name:b,text:t,topK:X});y(c)}catch(c){y(null),w(E(c))}finally{D(!1)}}},"search"),W=f(()=>{I(U())},"onSearch");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-vector-browser",children:[o!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"vector-error",role:"alert",children:o},void 0,!1),r!==null&&r.length===0&&(0,e.jsxDEV)(H,{description:a("Indexes declared with .vectorize() or defineVectorIndex() appear here."),icon:(0,e.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsxDEV)("path",{d:"M4 7l8-4 8 4-8 4-8-4Zm0 5 8 4 8-4M4 17l8 4 8-4"},void 0,!1)},void 0,!1),testId:"vector-empty",title:a("No vector indexes.")},void 0,!1),r!==null&&r.length>0&&(0,e.jsxDEV)(S,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(k,{className:"px-0",children:(0,e.jsxDEV)(q,{"data-testid":"vector-table",children:[(0,e.jsxDEV)(B,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(d,{children:a("name")},void 0,!1),(0,e.jsxDEV)(d,{children:a("table")},void 0,!1),(0,e.jsxDEV)(d,{children:a("dimensions")},void 0,!1),(0,e.jsxDEV)(d,{children:a("metric")},void 0,!1),(0,e.jsxDEV)(d,{children:a("vectors")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(V,{children:r.map(t=>(0,e.jsxDEV)(p,{className:t.name===b?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-index":t.name,"data-testid":`vector-row-${t.name}`,onClick:P,children:[(0,e.jsxDEV)(n,{className:"font-mono text-xs",children:t.name},void 0,!1),(0,e.jsxDEV)(n,{className:"font-mono text-xs",children:t.table},void 0,!1),(0,e.jsxDEV)(n,{className:"tabular-nums",children:t.dimensions??"\u2014"},void 0,!1),(0,e.jsxDEV)(n,{children:t.metric??"\u2014"},void 0,!1),(0,e.jsxDEV)(n,{className:"tabular-nums",children:t.vectorsCount??"\u2014"},void 0,!1)]},t.name,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),i!==null&&(0,e.jsxDEV)("section",{className:"border border-border bg-card p-3","data-testid":"vector-detail",children:[(0,e.jsxDEV)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[(0,e.jsxDEV)(g,{label:a("field"),value:i.field},void 0,!1),(0,e.jsxDEV)(g,{label:a("dimensions"),value:i.dimensions},void 0,!1),(0,e.jsxDEV)(g,{label:a("metric"),value:i.metric},void 0,!1),(0,e.jsxDEV)(g,{label:a("vectors"),value:i.vectorsCount},void 0,!1)]},void 0,!0),i.metadata!==void 0&&i.metadata.length>0&&(0,e.jsxDEV)("p",{className:"mt-3 text-xs text-muted-foreground","data-testid":"vector-metadata",children:[a("metadata"),": ",(0,e.jsxDEV)("span",{className:"font-mono",children:i.metadata.join(", ")},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,e.jsxDEV)($,{className:"min-w-[18rem] flex-1","data-testid":"vector-query-input",onChange:R,placeholder:a("Search by similarity\u2026"),value:N},void 0,!1),(0,e.jsxDEV)(A,{"data-testid":"vector-search",disabled:j||N.trim()==="",onClick:W,children:a(j?"Searching\u2026":"Search")},void 0,!1)]},void 0,!0),M!==null&&(0,e.jsxDEV)("p",{className:"mt-2 text-sm text-destructive","data-testid":"vector-query-error",role:"alert",children:M},void 0,!1),h!==null&&h.length===0&&(0,e.jsxDEV)("p",{className:"mt-2 text-sm text-muted-foreground","data-testid":"vector-no-matches",children:a("No matches.")},void 0,!1),h!==null&&h.length>0&&(0,e.jsxDEV)(S,{className:"mt-3 overflow-hidden py-0",children:(0,e.jsxDEV)(k,{className:"px-0",children:(0,e.jsxDEV)(q,{"data-testid":"vector-matches",children:[(0,e.jsxDEV)(B,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(d,{children:a("id")},void 0,!1),(0,e.jsxDEV)(d,{children:a("score")},void 0,!1),(0,e.jsxDEV)(d,{children:a("metadata")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(V,{children:h.map(t=>(0,e.jsxDEV)(p,{"data-testid":`vector-match-${t.id}`,children:[(0,e.jsxDEV)(n,{className:"font-mono text-xs",children:t.id},void 0,!1),(0,e.jsxDEV)(n,{className:"tabular-nums",children:t.score.toFixed(4)},void 0,!1),(0,e.jsxDEV)(n,{className:"max-w-md truncate font-mono text-xs",children:t.metadata===void 0?"\u2014":K(t.metadata)},void 0,!1)]},t.id,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0)]},void 0,!0)},"VectorBrowser");export{oe as VectorBrowser};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{a as Me,b as De,c as X,d as ve}from"./chunk-KG3QTFWE.js";import{a as Ae}from"./chunk-XURNGQSS.js";import{a as Oe}from"./chunk-KGS7KM4A.js";import"./chunk-7PBZKXYA.js";import"./chunk-6VTGE3WJ.js";import"./chunk-UGMRUEBU.js";import"./chunk-AHILM3ZP.js";import"./chunk-ITLLHEVG.js";import"./chunk-NNISYDNI.js";import"./chunk-5OIBXYZM.js";import"./chunk-FQKNJSRA.js";import"./chunk-BJGBHGK3.js";import"./chunk-UII66UVF.js";import"./chunk-OD2POGPJ.js";import"./chunk-KEGAWN6Y.js";import{a as Ee,b as qe,c as Ie,d as he,e as Re,f as Le}from"./chunk-GTM65MVX.js";import"./chunk-4QHKBC77.js";import{a as we}from"./chunk-RMYA7NAH.js";import{b as ke}from"./chunk-TBMYIZIO.js";import"./chunk-BHTPZS7L.js";import"./chunk-YQQJ4N6U.js";import"./chunk-TICVNLPM.js";import"./chunk-HV7G6DFP.js";import{a as re}from"./chunk-AQGOX5DK.js";import"./chunk-ZH7UES4T.js";import{f as be}from"./chunk-KODWGUAB.js";import"./chunk-3OA7PECS.js";import{d as G,e as se,f as le,g as Te,i as V}from"./chunk-YJGANMU7.js";import{a as r,e as pe,f as Ct,g as Tt,h as kt,j as ne}from"./chunk-RRCPZMC2.js";var Y=pe(Tt(),1);var q=pe(Ct(),1);var s=pe(kt(),1);var wt=["ORDER BY","GROUP BY","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN","EXPLAIN QUERY PLAN","SELECT","DISTINCT","FROM","WHERE","HAVING","LIMIT","OFFSET","JOIN","ON","AND","OR","AS","ASC","DESC","WITH","UNION","EXPLAIN"],Et=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],ae=String.fromCodePoint(0),qt=new RegExp(`${ae}${String.raw`(\d+)`}${ae}`,"gu"),It=wt.map(n=>({pattern:new RegExp(String.raw`\b${n.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:n})),Rt=Et.map(n=>({pattern:new RegExp(String.raw`\s+${n.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
|
|
2
|
+
${n}`})),Lt=r(n=>{let e=[],t=n.replaceAll(/'(?:[^']|'')*'/gu,l=>(e.push(l),`${ae}${(e.length-1).toString()}${ae}`)).replaceAll(/\s+/gu," ").trim();for(let{pattern:l,replacement:a}of It)t=t.replaceAll(l,a);for(let{pattern:l,replacement:a}of Rt)t=t.replaceAll(l,a);return t=t.replaceAll(qt,(l,a)=>e[Number(a)]??""),t},"formatSql"),ie=8,At=["AND","ASC","AS","BY","COUNT","DESC","DISTINCT","EXPLAIN","FROM","GROUP","HAVING","INNER","JOIN","LEFT","LIKE","LIMIT","NOT","NULL","OFFSET","ON","ORDER","OR","QUERY","SELECT","WHERE","WITH"],Ot=new Set(["AND","BY","HAVING","ON","OR","SELECT","WHERE"]),Mt=/[\w$]/,Pe=r(n=>n!==void 0&&Mt.test(n),"isWordChar"),_e=r(n=>{let e=n.length;for(;e>0&&Pe(n[e-1]);)e-=1;return n.slice(e)},"trailingWord"),He=r((n,e)=>{let o=e;for(;o>0&&Pe(n[o-1]);)o-=1;return{end:e,start:o,text:n.slice(o,e)}},"tokenAt"),$e=r((n,e)=>{let o=n.slice(0,e).trimEnd();return o.endsWith(".")||Ot.has(_e(o).toUpperCase())},"prefersColumns"),Dt=r((n,e)=>{let o=n.slice(0,e);if(!o.endsWith("."))return;let t=_e(o.slice(0,-1));return t===""?void 0:t},"qualifierTable"),Ne=r((n,e)=>n.toLowerCase().startsWith(e.toLowerCase()),"matches"),Be=r((n,e,o,t)=>{let l=[];for(let a of n)if(Ne(a,e)&&(l.push(t(a)),l.length>=o))break;return l},"takeMatches"),$t=r((n,e,o)=>{let t=new Map;for(let[l,a]of Object.entries(n.columns))for(let d of a)if(Ne(d,e)&&!t.has(d)&&(t.set(d,l),t.size>=o))return[...t].map(([m,c])=>({detail:c,kind:"column",label:m}));return[...t].map(([l,a])=>({detail:a,kind:"column",label:l}))},"takeColumnMatches"),Bt=r((n,e,o)=>{let t=He(n,e),l=Dt(n,t.start);if(l!==void 0){let u=o.columns[l]??o.columns[l.toLowerCase()]??[];return Be(u,t.text,ie,y=>({detail:l,kind:"column",label:y}))}if(t.text===""&&!$e(n,t.start))return[];let a=Be(o.tables,t.text,ie,u=>({kind:"table",label:u})),d=$t(o,t.text,ie),m=At.filter(u=>t.text!==""&&Ne(u,t.text)&&u.toLowerCase()!==t.text.toLowerCase()).map(u=>({kind:"keyword",label:u}));return($e(n,t.start)?[...d,...a,...m]:[...a,...d,...m]).slice(0,ie)},"suggestionsFor"),Pt=r((n,e,o)=>{let t=He(n,e),l=n.slice(0,t.start)+o.label+n.slice(t.end);return{caret:t.start+o.label.length,value:l}},"acceptSuggestion"),_t=["boxSizing","borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textTransform","width","wordSpacing"],Ht=r((n,e)=>{let o=globalThis.getComputedStyle(n),t=globalThis.document.createElement("div"),{style:l}=t;l.position="absolute",l.visibility="hidden",l.whiteSpace="pre-wrap",l.overflowWrap="break-word";for(let c of _t)l[c]=o[c];t.textContent=n.value.slice(0,Math.max(0,e));let a=globalThis.document.createElement("span");a.textContent=n.value.slice(Math.max(0,e))||".",t.append(a),globalThis.document.body.append(t);let d=a.offsetLeft-n.scrollLeft,m=a.offsetTop-n.scrollTop;return t.remove(),{left:d,top:m}},"caretOffset"),Wt=r((n,e,o)=>{let t=(0,Y.c)(13),[l,a]=(0,q.useState)(null),d;t[0]!==n||t[1]!==e?(d=r((N,x)=>{let S=Bt(N,x,n);if(S.length===0){a(null);return}let h=e.current,{left:w,top:T}=h===null?{left:0,top:0}:Ht(h,x);a({active:0,left:w,suggestions:S,top:T})},"t0"),t[0]=n,t[1]=e,t[2]=d):d=t[2];let m=d,c;t[3]===Symbol.for("react.memo_cache_sentinel")?(c=r(()=>{a(null)},"t1"),t[3]=c):c=t[3];let u=c,y;t[4]===Symbol.for("react.memo_cache_sentinel")?(y=r(N=>{a(x=>{if(x===null)return x;let S=x.suggestions.length,h=(x.active+N+S)%S;return{...x,active:h}})},"t2"),t[4]=y):y=t[4];let g=y,v;t[5]!==o||t[6]!==l||t[7]!==e?(v=r(()=>{let N=e.current;if(l===null||N===null)return!1;let x=l.suggestions[l.active];if(x===void 0)return!1;let S=Pt(N.value,N.selectionStart,x);return o(S.value),a(null),requestAnimationFrame(()=>{let h=e.current;h!==null&&(h.focus(),h.setSelectionRange(S.caret,S.caret))}),!0},"t3"),t[5]=o,t[6]=l,t[7]=e,t[8]=v):v=t[8];let p=v,f;return t[9]!==p||t[10]!==m||t[11]!==l?(f={close:u,commit:p,move:g,refresh:m,state:l},t[9]=p,t[10]=m,t[11]=l,t[12]=f):f=t[12],f},"useSqlAutocomplete"),Ft={column:"column",keyword:"keyword",table:"table"},zt=20,Ut=r(n=>{let e=(0,Y.c)(17),{listboxId:o,onPick:t,state:l}=n,a=G(),d;e[0]!==l?(d=l===null?void 0:{left:l.left,top:l.top+zt},e[0]=l,e[1]=d):d=e[1];let m=d;if(l===null)return null;let c;if(e[2]!==o||e[3]!==t||e[4]!==l.active||e[5]!==l.suggestions||e[6]!==a){let y;e[8]!==o||e[9]!==t||e[10]!==l.active||e[11]!==a?(y=r((g,v)=>(0,s.jsxDEV)("li",{"aria-selected":v===l.active,className:ne("flex cursor-pointer items-center gap-2 px-2 py-1 text-[13px]",v===l.active?"bg-accent text-accent-foreground":"text-foreground"),"data-testid":"sql-autocomplete-item",id:`${o}-opt-${v.toString()}`,onMouseDown:r(p=>{p.preventDefault(),t(v)},"onMouseDown"),role:"option",children:[(0,s.jsxDEV)("span",{className:"truncate font-mono",children:g.label},void 0,!1),g.detail!==void 0&&(0,s.jsxDEV)("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:g.detail},void 0,!1),(0,s.jsxDEV)("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:a(Ft[g.kind])},void 0,!1)]},`${g.kind}:${g.label}`,!0),"t32"),e[8]=o,e[9]=t,e[10]=l.active,e[11]=a,e[12]=y):y=e[12],c=l.suggestions.map(y),e[2]=o,e[3]=t,e[4]=l.active,e[5]=l.suggestions,e[6]=a,e[7]=c}else c=e[7];let u;return e[13]!==o||e[14]!==m||e[15]!==c?(u=(0,s.jsxDEV)("ul",{className:"absolute z-30 max-h-56 w-72 overflow-auto rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-autocomplete",id:o,role:"listbox",style:m,children:c},void 0,!1),e[13]=o,e[14]=m,e[15]=c,e[16]=u):u=e[16],u},"AutocompletePopover"),We=[{label:"List tables",sql:"SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name;"},{label:"Table row count",sql:"SELECT COUNT(*) AS rows FROM messages;"},{label:"Recent rows",sql:"SELECT id, _creationTime, __doc__ FROM messages ORDER BY _creationTime DESC LIMIT 50;"},{label:"Index list",sql:"SELECT name, tbl_name FROM sqlite_master WHERE type = 'index' ORDER BY tbl_name;"}],Yt=r(n=>{let e=(0,Y.c)(29),{active:o,onDelete:t,onSelect:l,query:a}=n,d=G(),m;e[0]!==l||e[1]!==a.id?(m=r(()=>{l(a.id)},"t1"),e[0]=l,e[1]=a.id,e[2]=m):m=e[2];let c=m,u;e[3]!==t||e[4]!==a.id?(u=r(O=>{O.stopPropagation(),t(a.id)},"t2"),e[3]=t,e[4]=a.id,e[5]=u):u=e[5];let y=u,g=o?"bg-sidebar-accent font-medium text-foreground":"text-muted-foreground",v;e[6]!==g?(v=ne("flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] outline-none transition-colors hover:bg-sidebar-accent focus-visible:bg-sidebar-accent",g),e[6]=g,e[7]=v):v=e[7];let p=`sql-query-${a.id}`,f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=(0,s.jsxDEV)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,s.jsxDEV)("path",{d:"M4 6h16M4 12h10M4 18h7"},void 0,!1)},void 0,!1),e[8]=f):f=e[8];let N;e[9]!==a.name?(N=(0,s.jsxDEV)("span",{className:"truncate",children:a.name},void 0,!1),e[9]=a.name,e[10]=N):N=e[10];let x;e[11]!==o||e[12]!==c||e[13]!==v||e[14]!==p||e[15]!==N?(x=(0,s.jsxDEV)("button",{"aria-pressed":o,className:v,"data-testid":p,onClick:c,type:"button",children:[f,N]},void 0,!0),e[11]=o,e[12]=c,e[13]=v,e[14]=p,e[15]=N,e[16]=x):x=e[16];let S;e[17]!==d?(S=d("Delete query"),e[17]=d,e[18]=S):S=e[18];let h;e[19]!==d?(h=d("Delete query"),e[19]=d,e[20]=h):h=e[20];let w;e[21]===Symbol.for("react.memo_cache_sentinel")?(w=(0,s.jsxDEV)("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,s.jsxDEV)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"},void 0,!1)},void 0,!1),e[21]=w):w=e[21];let T;e[22]!==y||e[23]!==h||e[24]!==S?(T=(0,s.jsxDEV)("button",{"aria-label":S,className:"me-1 hidden size-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive group-hover/q:flex",onClick:y,title:h,type:"button",children:w},void 0,!1),e[22]=y,e[23]=h,e[24]=S,e[25]=T):T=e[25];let R;return e[26]!==T||e[27]!==x?(R=(0,s.jsxDEV)("li",{className:"group/q flex items-center",children:[x,T]},void 0,!0),e[26]=T,e[27]=x,e[28]=R):R=e[28],R},"QueryRow"),jt=r(n=>{let e=(0,Y.c)(58),{activeId:o,history:t,listRef:l,onClearHistory:a,onDelete:d,onLoadHistory:m,onLoadTemplate:c,onNew:u,onSearchChange:y,onSelect:g,queries:v,search:p}=n,f=G(),N;if(e[0]!==v||e[1]!==p){let k=p.trim().toLowerCase();N=k===""?[...v]:v.filter(j=>j.name.toLowerCase().includes(k)),e[0]=v,e[1]=p,e[2]=N}else N=e[2];let x=N,S;e[3]!==f?(S=f("Search queries\u2026"),e[3]=f,e[4]=S):S=e[4];let h;e[5]!==y||e[6]!==p||e[7]!==S?(h=(0,s.jsxDEV)("input",{className:"h-8 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"sql-search",onChange:y,placeholder:S,type:"text",value:p},void 0,!1),e[5]=y,e[6]=p,e[7]=S,e[8]=h):h=e[8];let w;e[9]!==f?(w=f("New query"),e[9]=f,e[10]=w):w=e[10];let T;e[11]!==f?(T=f("New query"),e[11]=f,e[12]=T):T=e[12];let R;e[13]===Symbol.for("react.memo_cache_sentinel")?(R=(0,s.jsxDEV)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:(0,s.jsxDEV)("path",{d:"M12 5v14M5 12h14"},void 0,!1)},void 0,!1),e[13]=R):R=e[13];let O;e[14]!==u||e[15]!==w||e[16]!==T?(O=(0,s.jsxDEV)("button",{"aria-label":w,className:"flex size-8 shrink-0 items-center justify-center rounded-md border border-border text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-new",onClick:u,title:T,type:"button",children:R},void 0,!1),e[14]=u,e[15]=w,e[16]=T,e[17]=O):O=e[17];let A;e[18]!==h||e[19]!==O?(A=(0,s.jsxDEV)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border p-2",children:[h,O]},void 0,!0),e[18]=h,e[19]=O,e[20]=A):A=e[20];let M;e[21]!==f?(M=f("Private"),e[21]=f,e[22]=M):M=e[22];let z;e[23]!==M?(z=(0,s.jsxDEV)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:M},void 0,!1),e[23]=M,e[24]=z):z=e[24];let B;e[25]!==o||e[26]!==x||e[27]!==l||e[28]!==d||e[29]!==g||e[30]!==f?(B=x.length===0?(0,s.jsxDEV)("p",{className:"px-1 py-2 text-xs text-muted-foreground","data-testid":"sql-private-empty",children:f("No saved queries yet \u2014 they save to this browser as you type.")},void 0,!1):(0,s.jsxDEV)("ul",{className:"flex flex-col gap-px","data-testid":"sql-private",ref:l,children:x.map(k=>(0,s.jsxDEV)(Yt,{active:o===k.id,onDelete:d,onSelect:g,query:k},k.id,!1))},void 0,!1),e[25]=o,e[26]=x,e[27]=l,e[28]=d,e[29]=g,e[30]=f,e[31]=B):B=e[31];let P;e[32]!==z||e[33]!==B?(P=(0,s.jsxDEV)("div",{children:[z,B]},void 0,!0),e[32]=z,e[33]=B,e[34]=P):P=e[34];let H;e[35]!==f?(H=f("Reference"),e[35]=f,e[36]=H):H=e[36];let U;e[37]!==H?(U=(0,s.jsxDEV)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:H},void 0,!1),e[37]=H,e[38]=U):U=e[38];let I;e[39]!==c?(I=We.map(k=>(0,s.jsxDEV)("li",{children:(0,s.jsxDEV)("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:bg-sidebar-accent","data-sql":k.sql,onClick:c,type:"button",children:[(0,s.jsxDEV)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,s.jsxDEV)("path",{d:"M7 4h7l4 4v12H7zM14 4v4h4"},void 0,!1)},void 0,!1),k.label]},void 0,!0)},k.label,!1)),e[39]=c,e[40]=I):I=e[40];let L;e[41]!==I?(L=(0,s.jsxDEV)("ul",{className:"flex flex-col gap-px",children:I},void 0,!1),e[41]=I,e[42]=L):L=e[42];let D;e[43]!==U||e[44]!==L?(D=(0,s.jsxDEV)("div",{children:[U,L]},void 0,!0),e[43]=U,e[44]=L,e[45]=D):D=e[45];let _;e[46]!==t||e[47]!==a||e[48]!==m||e[49]!==f?(_=t.length>0&&(0,s.jsxDEV)("div",{children:[(0,s.jsxDEV)("div",{className:"flex items-center justify-between px-1 pb-1",children:[(0,s.jsxDEV)("p",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:f("History")},void 0,!1),(0,s.jsxDEV)("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"sql-history-clear",onClick:a,type:"button",children:f("Clear history")},void 0,!1)]},void 0,!0),(0,s.jsxDEV)("ul",{className:"flex flex-col gap-px","data-testid":"sql-history",children:t.map(k=>(0,s.jsxDEV)("li",{children:(0,s.jsxDEV)("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:bg-sidebar-accent","data-sql":k.sql,"data-testid":"sql-history-item",onClick:m,title:k.sql,type:"button",children:[(0,s.jsxDEV)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,s.jsxDEV)("path",{d:"M12 8v4l3 2M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18Z"},void 0,!1)},void 0,!1),(0,s.jsxDEV)("span",{className:"truncate font-mono",children:k.sql},void 0,!1)]},void 0,!0)},`${k.at.toString()}:${k.sql}`,!1))},void 0,!1)]},void 0,!0),e[46]=t,e[47]=a,e[48]=m,e[49]=f,e[50]=_):_=e[50];let $;e[51]!==P||e[52]!==D||e[53]!==_?($=(0,s.jsxDEV)("div",{className:"flex flex-1 flex-col gap-4 overflow-y-auto p-2",children:[P,D,_]},void 0,!0),e[51]=P,e[52]=D,e[53]=_,e[54]=$):$=e[54];let E;return e[55]!==$||e[56]!==A?(E=(0,s.jsxDEV)("aside",{className:"flex h-full w-64 shrink-0 flex-col border-e border-border bg-sidebar",children:[A,$]},void 0,!0),e[55]=$,e[56]=A,e[57]=E):E=e[57],E},"SqlQuerySidebar"),Kt=se(re.listTables),Gt=se(re.readTablePage),Jt=r(n=>{let e=(0,Y.c)(16),o=be(),t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];let[l,a]=(0,q.useState)(t),d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d={},e[1]=d):d=e[1];let[m,c]=(0,q.useState)(d),u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,e[2]=u):u=e[2];let y=(0,q.useRef)(u),g,v;e[3]!==o||e[4]!==n?(g=r(()=>{let h={cancelled:!1};return V(r(async()=>{try{let T=await o.query(Kt,{},le(n));h.cancelled||(a(T.map(Vt)),c({}),y.current=new Set)}catch{h.cancelled||(a([]),c({}),y.current=new Set)}},"load")()),()=>{h.cancelled=!0}},"t3"),v=[o,n],e[3]=o,e[4]=n,e[5]=g,e[6]=v):(g=e[5],v=e[6]),(0,q.useEffect)(g,v);let p;e[7]!==o||e[8]!==n?(p=r(h=>{if(y.current.has(h))return;y.current.add(h),V(r(async()=>{try{let T=await o.query(Gt,{limit:1,offset:0,table:h},le(n));c(R=>({...R,[h]:T.columns}))}catch{y.current.delete(h)}},"fetchColumns")())},"t5"),e[7]=o,e[8]=n,e[9]=p):p=e[9];let f=p,N;e[10]!==m||e[11]!==l?(N={columns:m,tables:l},e[10]=m,e[11]=l,e[12]=N):N=e[12];let x=N,S;return e[13]!==f||e[14]!==x?(S={probe:f,schema:x},e[13]=f,e[14]=x,e[15]=S):S=e[15],S},"useSqlSchema"),ge=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,Qt=r(n=>{let e=new Set;ge.lastIndex=0;let o=ge.exec(n);for(;o!==null;)e.add(o[1]??o[2]),o=ge.exec(n);return[...e]},"referencedTables");function Vt(n){return n.name}r(Vt,"_temp$2");var Xt="lunora-studio-sql-tabs",Zt="lunora-studio-sql-active-tab",ye=12,Z=r((n="",e="")=>({activeId:null,id:ve("tab"),name:e,sql:n}),"makeTab"),eo=r(()=>{let n=(0,Y.c)(5),[e,o]=X(Zt),t;n[0]!==o?(t=r(m=>{o(c=>{let u=c[0]??"";return[typeof m=="function"?m(u):m]})},"t0"),n[0]=o,n[1]=t):t=n[1];let l=t,a=e[0]??"",d;return n[2]!==l||n[3]!==a?(d=[a,l],n[2]=l,n[3]=a,n[4]=d):d=n[4],d},"usePersistedActive"),to=r(n=>{let[e,o]=X(Xt),[t,l]=eo(),a=(0,q.useRef)(null);e.length===0&&a.current===null&&(a.current=n()),(0,q.useEffect)(()=>{if(e.length===0&&a.current!==null){let c=a.current;o([c])}},[o,e.length]);let d=e.length===0&&a.current!==null?[a.current]:e;return{activeId:d.some(c=>c.id===t)?t:d[0]?.id??"",setActiveId:l,setTabs:o,tabs:d}},"usePersistedTabs"),Fe=r(n=>n.activeId===null&&n.sql.trim()!=="","isDirty"),oo=r((n,e)=>[...n,e].slice(-ye),"addTab"),no=r((n,e,o)=>{let t=n.findIndex(d=>d.id===e);if(t===-1)return{activeId:n[0]?.id??"",tabs:[...n]};let l=n.filter(d=>d.id!==e);if(l.length===0){let d=o();return{activeId:d.id,tabs:[d]}}return{activeId:l[Math.min(t,l.length-1)].id,tabs:l}},"closeTab"),so=r((n,e)=>{let o=n.filter(t=>t.id===e);return o.length===0?{activeId:n[0]?.id??"",tabs:[...n]}:{activeId:e,tabs:o}},"closeOtherTabs"),lo=r((n,e,o)=>{let t=n.findIndex(a=>a.id===e);if(t===-1)return{activeId:o,tabs:[...n]};let l=n.slice(0,t+1);return{activeId:l.some(a=>a.id===o)?o:e,tabs:l}},"closeTabsToRight"),ro=r(n=>{let e=n();return{activeId:e.id,tabs:[e]}},"closeAllTabs"),io=r((n,e,o)=>{if(n==="others")return e.filter(t=>t.id!==o);if(n==="right"){let t=e.findIndex(l=>l.id===o);return t===-1?[]:e.slice(t+1)}return[...e]},"tabsClosedBy"),ao=r((n,e)=>n.trim()===""?e:(n.split(`
|
|
3
|
+
`)[0]??n).slice(0,24),"derivedTabLabel"),co=r(n=>{let e=(0,Y.c)(14),{initial:o,onCancel:t,onCommit:l,placeholder:a,testId:d}=n,m=G(),c=mo,u;e[0]!==l?(u=r(N=>{l(N.currentTarget.value.trim())},"t1"),e[0]=l,e[1]=u):u=e[1];let y=u,g;e[2]!==t||e[3]!==l?(g=r(N=>{N.key==="Enter"?l(N.currentTarget.value.trim()):N.key==="Escape"&&t()},"t2"),e[2]=t,e[3]=l,e[4]=g):g=e[4];let v=g,p;e[5]!==m?(p=m("Tab title"),e[5]=m,e[6]=p):p=e[6];let f;return e[7]!==o||e[8]!==y||e[9]!==v||e[10]!==a||e[11]!==p||e[12]!==d?(f=(0,s.jsxDEV)("input",{"aria-label":p,className:"w-40 rounded border border-ring bg-background px-1 py-0.5 text-xs outline-none","data-testid":d,defaultValue:o,onBlur:y,onKeyDown:v,placeholder:a,ref:c,type:"text"},void 0,!1),e[7]=o,e[8]=y,e[9]=v,e[10]=a,e[11]=p,e[12]=d,e[13]=f):f=e[13],f},"TabRenameInput"),uo=r(n=>{let e=(0,Y.c)(29),{idBase:o,onDiscard:t,onKeep:l}=n,a=G(),d=`sql-tab-close-prompt-${o}`,m;e[0]!==a?(m=a("Discard?"),e[0]=a,e[1]=m):m=e[1];let c;e[2]!==m?(c=(0,s.jsxDEV)("span",{className:"text-[11px] text-muted-foreground",children:m},void 0,!1),e[2]=m,e[3]=c):c=e[3];let u;e[4]!==a?(u=a("Discard changes"),e[4]=a,e[5]=u):u=e[5];let y=`sql-tab-close-confirm-${o}`,g;e[6]!==a?(g=a("Discard changes"),e[6]=a,e[7]=g):g=e[7];let v;e[8]===Symbol.for("react.memo_cache_sentinel")?(v=(0,s.jsxDEV)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:(0,s.jsxDEV)("path",{d:"M5 13l4 4L19 7"},void 0,!1)},void 0,!1),e[8]=v):v=e[8];let p;e[9]!==t||e[10]!==u||e[11]!==y||e[12]!==g?(p=(0,s.jsxDEV)("button",{"aria-label":u,className:"flex size-5 items-center justify-center rounded text-destructive hover:bg-destructive/10","data-testid":y,onClick:t,title:g,type:"button",children:v},void 0,!1),e[9]=t,e[10]=u,e[11]=y,e[12]=g,e[13]=p):p=e[13];let f;e[14]!==a?(f=a("Keep editing"),e[14]=a,e[15]=f):f=e[15];let N=`sql-tab-close-cancel-${o}`,x;e[16]!==a?(x=a("Keep editing"),e[16]=a,e[17]=x):x=e[17];let S;e[18]===Symbol.for("react.memo_cache_sentinel")?(S=(0,s.jsxDEV)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:(0,s.jsxDEV)("path",{d:"M6 6l12 12M18 6 6 18"},void 0,!1)},void 0,!1),e[18]=S):S=e[18];let h;e[19]!==l||e[20]!==N||e[21]!==x||e[22]!==f?(h=(0,s.jsxDEV)("button",{"aria-label":f,className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent","data-testid":N,onClick:l,title:x,type:"button",children:S},void 0,!1),e[19]=l,e[20]=N,e[21]=x,e[22]=f,e[23]=h):h=e[23];let w;return e[24]!==d||e[25]!==h||e[26]!==c||e[27]!==p?(w=(0,s.jsxDEV)("span",{className:"flex shrink-0 items-center gap-1","data-testid":d,role:"group",children:[c,p,h]},void 0,!0),e[24]=d,e[25]=h,e[26]=c,e[27]=p,e[28]=w):w=e[28],w},"TabCloseConfirm"),fo=r(n=>{let e=(0,Y.c)(47),{active:o,canClose:t,onClose:l,onMenu:a,onRename:d,onSelect:m,tab:c}=n,u=G(),[y,g]=(0,q.useState)(!1),[v,p]=(0,q.useState)(!1),f;e[0]!==a||e[1]!==c.id?(f=r(W=>{a(c.id,W)},"t1"),e[0]=a,e[1]=c.id,e[2]=f):f=e[2];let N=f,x;e[3]!==m||e[4]!==c.id?(x=r(()=>{m(c.id)},"t2"),e[3]=m,e[4]=c.id,e[5]=x):x=e[5];let S=x,h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=r(()=>{g(!0)},"t3"),e[6]=h):h=e[6];let w=h,T;e[7]!==l||e[8]!==c?(T=r(W=>{W.stopPropagation(),Fe(c)?p(!0):l(c.id)},"t4"),e[7]=l,e[8]=c,e[9]=T):T=e[9];let R=T,O;e[10]!==l||e[11]!==c.id?(O=r(W=>{W.stopPropagation(),p(!1),l(c.id)},"t5"),e[10]=l,e[11]=c.id,e[12]=O):O=e[12];let A=O,M;e[13]===Symbol.for("react.memo_cache_sentinel")?(M=r(W=>{W.stopPropagation(),p(!1)},"t6"),e[13]=M):M=e[13];let z=M,B;e[14]!==d||e[15]!==c.id?(B=r(W=>{d(c.id,W),g(!1)},"t7"),e[14]=d,e[15]=c.id,e[16]=B):B=e[16];let P=B,H;e[17]===Symbol.for("react.memo_cache_sentinel")?(H=r(()=>{g(!1)},"t8"),e[17]=H):H=e[17];let U=H,I;e[18]!==c.name?(I=c.name.trim(),e[18]=c.name,e[19]=I):I=e[19];let L=I,D;e[20]!==u||e[21]!==c.sql?(D=ao(c.sql,u("Untitled")),e[20]=u,e[21]=c.sql,e[22]=D):D=e[22];let _=D,$=o?"bg-background text-foreground":"bg-muted/40 text-muted-foreground hover:text-foreground",E;e[23]!==$?(E=ne("group/tab flex shrink-0 items-center gap-1 border-e border-border ps-3 pe-1.5 text-xs",$),e[23]=$,e[24]=E):E=e[24];let k=`sql-tab-${c.id}`,j;e[25]!==o||e[26]!==P||e[27]!==L||e[28]!==_||e[29]!==y||e[30]!==S||e[31]!==u||e[32]!==c.id?(j=y?(0,s.jsxDEV)(co,{initial:L,onCancel:U,onCommit:P,placeholder:_,testId:`sql-tab-rename-${c.id}`},void 0,!1):(0,s.jsxDEV)("button",{"aria-pressed":o,className:"max-w-40 truncate py-1.5 outline-none","data-testid":`sql-tab-select-${c.id}`,onClick:S,onDoubleClick:w,title:u("Double-click to rename"),type:"button",children:L===""?_:L},void 0,!1),e[25]=o,e[26]=P,e[27]=L,e[28]=_,e[29]=y,e[30]=S,e[31]=u,e[32]=c.id,e[33]=j):j=e[33];let K;e[34]!==t||e[35]!==A||e[36]!==v||e[37]!==R||e[38]!==u||e[39]!==c.id?(K=t&&(v?(0,s.jsxDEV)(uo,{idBase:c.id,onDiscard:A,onKeep:z},void 0,!1):(0,s.jsxDEV)("button",{"aria-label":u("Close tab"),className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive","data-testid":`sql-tab-close-${c.id}`,onClick:R,title:u("Close tab"),type:"button",children:(0,s.jsxDEV)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:(0,s.jsxDEV)("path",{d:"M6 6l12 12M18 6 6 18"},void 0,!1)},void 0,!1)},void 0,!1)),e[34]=t,e[35]=A,e[36]=v,e[37]=R,e[38]=u,e[39]=c.id,e[40]=K):K=e[40];let J;return e[41]!==N||e[42]!==E||e[43]!==k||e[44]!==j||e[45]!==K?(J=(0,s.jsxDEV)("div",{className:E,"data-testid":k,onContextMenu:N,children:[j,K]},void 0,!0),e[41]=N,e[42]=E,e[43]=k,e[44]=j,e[45]=K,e[46]=J):J=e[46],J},"TabButton");function mo(n){n?.focus(),n?.select()}r(mo,"_temp$1");var po=se(re.runSql),bo="lunora-studio-sql-queries",ho="lunora-studio-sql-history",vo=25,go={minWidth:"2.75rem",paddingInline:"0.5rem"},xe={error:null,pane:"results",result:null},xo=r(n=>{let e=(0,Y.c)(16),{result:o}=n;if(o.columns.length===0){let c=o.rowCount===0?"0 rows":"",u;return e[0]!==c?(u=(0,s.jsxDEV)("p",{className:"p-4 text-sm text-muted-foreground",children:c},void 0,!1),e[0]=c,e[1]=u):u=e[1],u}let t;e[2]!==o.columns?(t=o.columns.map(yo),e[2]=o.columns,e[3]=t):t=e[3];let l;e[4]!==t?(l=(0,s.jsxDEV)(qe,{className:"sticky top-0 z-10 bg-muted",children:(0,s.jsxDEV)(he,{children:t},void 0,!1)},void 0,!1),e[4]=t,e[5]=l):l=e[5];let a;if(e[6]!==o.columns||e[7]!==o.rows){let c;e[9]!==o.columns?(c=r((u,y)=>(0,s.jsxDEV)(he,{"data-testid":"sql-row",children:o.columns.map(g=>(0,s.jsxDEV)(Le,{className:"max-w-md truncate font-mono text-xs",children:(0,s.jsxDEV)(Ae,{value:u[g]},void 0,!1)},g,!1))},y,!1),"t42"),e[9]=o.columns,e[10]=c):c=e[10],a=o.rows.map(c),e[6]=o.columns,e[7]=o.rows,e[8]=a}else a=e[8];let d;e[11]!==a?(d=(0,s.jsxDEV)(Ie,{children:a},void 0,!1),e[11]=a,e[12]=d):d=e[12];let m;return e[13]!==l||e[14]!==d?(m=(0,s.jsxDEV)(Ee,{"data-testid":"sql-rows",children:[l,d]},void 0,!0),e[13]=l,e[14]=d,e[15]=m):m=e[15],m},"SqlResultTable"),Ao=r(({initialShardKey:n})=>{let e=be(),o=G(),[t,l]=X(bo),[a,d]=X(ho),[m,c]=(0,q.useState)(""),u=r(()=>Z(We[0]?.sql??""),"seedTab"),{activeId:y,setActiveId:g,setTabs:v,tabs:p}=to(u),[f,N]=(0,q.useState)({}),[x,S]=(0,q.useState)(n??""),[h,w]=(0,q.useState)(!1),[T,R]=(0,q.useState)(null),[O,A]=(0,q.useState)(null),M=(0,q.useRef)(null),z=(0,q.useRef)(null),B=(0,q.useRef)(null),P=(0,q.useId)(),{probe:H,schema:U}=Jt(x),I=p.find(i=>i.id===y)??p[0]??Z(),L=I.sql,{activeId:D}=I,_=f[I.id]??xe,{error:$,result:E}=_,k=_.pane,j=r(i=>{v(b=>b.map(C=>C.id===I.id?{...C,...i}:C))},"patchActiveTab"),K=r(i=>{N(b=>{let C=b[I.id]??xe;return{...b,[I.id]:{error:i.error,pane:i.pane??C.pane,result:i.result}}})},"setActiveOutput"),J=r(i=>{N(b=>{let C=b[I.id]??xe;return{...b,[I.id]:{...C,pane:i}}})},"setActivePane"),W=r(i=>{j({sql:i}),D!==null&&l(b=>b.map(C=>C.id===D?{...C,sql:i}:C))},"setDraft"),ze=Wt(U,z,W),{close:ce,commit:Se,move:de,refresh:ee,state:Q}=ze,Ue=r(i=>{de(i-(Q?.active??0)),Se()},"onPickSuggestion");(0,q.useEffect)(()=>{let i=z.current;i!==null&&i===document.activeElement&&ee(i.value,i.selectionStart)},[ee,U]);let Ye=r(i=>{d(b=>b[0]?.sql===i?b:[{at:Date.now(),sql:i},...b.filter(F=>F.sql!==i)].slice(0,vo))},"recordHistory"),ue=r(async i=>{if(L.trim()==="")return;w(!0);let b=i==="explain"?`EXPLAIN QUERY PLAN ${L}`:L;try{let C=await e.query(po,{sql:b},le(x));K({error:null,pane:i,result:C}),ke(x),Ye(b)}catch(C){K({error:Te(C),pane:i,result:null})}finally{w(!1)}},"run"),je=r(()=>{V(ue("results"))},"onRun"),Ke=r(i=>{let{selectionStart:b,value:C}=i.target;W(C);for(let F of Qt(C))H(F);ee(C,b)},"onDraftChange"),Ge=r(i=>{let b=i.currentTarget;ee(b.value,b.selectionStart)},"onEditorSelect"),Je=r(i=>{if(Q!==null){if(i.key==="ArrowDown"){i.preventDefault(),de(1);return}if(i.key==="ArrowUp"){i.preventDefault(),de(-1);return}if(i.key==="Escape"){i.preventDefault(),ce();return}if((i.key==="Enter"||i.key==="Tab")&&!i.metaKey&&!i.ctrlKey&&Se()){i.preventDefault();return}}(i.metaKey||i.ctrlKey)&&i.key==="Enter"&&(i.preventDefault(),V(ue(k)))},"onEditorKeyDown"),Qe=r(()=>{requestAnimationFrame(()=>{ce()})},"onEditorBlur"),Ve=r(i=>{M.current!==null&&(M.current.scrollTop=i.currentTarget.scrollTop)},"onEditorScroll"),te=r((i,b)=>{v(C=>C.map(F=>F.id===I.id?{...F,activeId:b,sql:i}:F)),K({error:null,result:null})},"loadIntoActiveTab"),Xe=r(()=>{let i={id:ve("q"),name:o("Untitled query"),sql:""};l(b=>[i,...b]),te("",i.id)},"newQuery"),Ze=r(i=>{let b=t.find(C=>C.id===i);b!==void 0&&(te(b.sql,i),B.current?.querySelector(`[data-testid="sql-query-${i}"]`)?.scrollIntoView({block:"nearest"}))},"selectQuery"),et=r(i=>{l(b=>b.filter(C=>C.id!==i)),v(b=>b.map(C=>C.activeId===i?{...C,activeId:null}:C))},"deleteQuery"),tt=r(i=>{te(i.currentTarget.dataset.sql??"",null)},"loadTemplate"),ot=r(i=>{te(i.currentTarget.dataset.sql??"",null)},"loadFromHistory"),nt=r(()=>{d([])},"clearHistory"),st=r(()=>{W(Lt(L))},"formatDraft"),lt=r(()=>{if(p.length>=ye)return;let i=Z();v(b=>oo(b,i)),g(i.id)},"addEditorTab"),oe=r(i=>{R(null),A(null),v(i.tabs),g(i.activeId);let b=new Set(i.tabs.map(C=>C.id));N(C=>Object.fromEntries(Object.entries(C).filter(([F])=>b.has(F))))},"commitTabs"),rt=r(i=>{oe(no(p,i,Z))},"closeEditorTab"),Ce=r((i,b)=>{oe(i==="others"?so(p,b):i==="right"?lo(p,b,y):ro(Z))},"applyBulk"),fe=r(i=>{T!==null&&(io(i,p,T.id).some(b=>Fe(b))?A(i):Ce(i,T.id))},"requestBulk"),it=r((i,b)=>{b.preventDefault(),A(null),R({id:i,x:b.clientX,y:b.clientY})},"openTabMenu"),at=r(()=>{R(null),A(null)},"closeTabMenu"),ct=r(i=>{i.preventDefault(),R(null),A(null)},"onBackdropContextMenu"),dt=r(()=>{fe("others")},"onCloseOthers"),ut=r(()=>{fe("right")},"onCloseToRight"),ft=r(()=>{fe("all")},"onCloseAll"),mt=r(()=>{T!==null&&O!==null&&Ce(O,T.id),A(null)},"confirmBulk"),pt=r(()=>{A(null)},"cancelBulk"),bt=T===null?void 0:{left:T.x,top:T.y},ht=r(i=>{ce(),g(i)},"selectTab"),vt=r((i,b)=>{v(C=>C.map(F=>F.id===i?{...F,name:b}:F))},"renameTab"),gt=r(()=>{J("results")},"showResults"),xt=r(()=>{V(ue("explain"))},"showExplain"),yt=r(()=>{J("chart")},"showChart"),Nt=L.split(`
|
|
4
|
+
`).length,St=r(i=>{c(i.target.value)},"onSearchChange"),me=r(i=>`border-b-2 px-3 py-2 text-sm outline-none transition-colors ${i?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,"tabClass");return(0,s.jsxDEV)("div",{className:"flex h-full min-w-0","data-testid":"lunora-sql-editor",children:[(0,s.jsxDEV)(jt,{activeId:D,history:a,listRef:B,onClearHistory:nt,onDelete:et,onLoadHistory:ot,onLoadTemplate:tt,onNew:Xe,onSearchChange:St,onSelect:Ze,queries:t,search:m},void 0,!1),(0,s.jsxDEV)("div",{className:"flex min-w-0 flex-1 flex-col",children:[(0,s.jsxDEV)("div",{className:"flex shrink-0 items-stretch overflow-x-auto border-b border-border bg-muted/30","data-testid":"sql-tab-strip",role:"tablist",children:[p.map(i=>(0,s.jsxDEV)(fo,{active:i.id===I.id,canClose:p.length>1,onClose:rt,onMenu:it,onRename:vt,onSelect:ht,tab:i},i.id,!1)),(0,s.jsxDEV)("button",{"aria-label":o("New tab"),className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-add",disabled:p.length>=ye,onClick:lt,title:o("New tab"),type:"button",children:(0,s.jsxDEV)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:(0,s.jsxDEV)("path",{d:"M12 5v14M5 12h14"},void 0,!1)},void 0,!1)},void 0,!1)]},void 0,!0),T!==null&&(0,s.jsxDEV)(s.Fragment,{children:[(0,s.jsxDEV)("div",{className:"fixed inset-0 z-40","data-testid":"sql-tab-menu-backdrop",onClick:at,onContextMenu:ct,role:"presentation"},void 0,!1),(0,s.jsxDEV)("div",{className:"fixed z-50 min-w-44 rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-tab-menu",role:"menu",style:bt,children:O===null?(0,s.jsxDEV)(s.Fragment,{children:[(0,s.jsxDEV)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-menu-close-others",disabled:p.length<=1,onClick:dt,role:"menuitem",type:"button",children:o("Close other tabs")},void 0,!1),(0,s.jsxDEV)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-menu-close-right",disabled:p.findIndex(i=>i.id===T.id)>=p.length-1,onClick:ut,role:"menuitem",type:"button",children:o("Close tabs to the right")},void 0,!1),(0,s.jsxDEV)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-close-all",onClick:ft,role:"menuitem",type:"button",children:o("Close all tabs")},void 0,!1)]},void 0,!0):(0,s.jsxDEV)("div",{className:"px-3 py-1.5","data-testid":"sql-tab-menu-confirm",children:[(0,s.jsxDEV)("p",{className:"pb-1.5 text-xs text-muted-foreground",children:o("Discard unsaved tabs?")},void 0,!1),(0,s.jsxDEV)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsxDEV)("button",{className:"rounded px-2 py-1 text-xs font-medium text-destructive outline-none hover:bg-destructive/10 focus-visible:bg-destructive/10","data-testid":"sql-tab-menu-confirm-discard",onClick:mt,type:"button",children:o("Discard")},void 0,!1),(0,s.jsxDEV)("button",{className:"rounded px-2 py-1 text-xs text-muted-foreground outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-confirm-cancel",onClick:pt,type:"button",children:o("Cancel")},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1)]},void 0,!0),(0,s.jsxDEV)("div",{className:"flex min-h-0 flex-1",children:[(0,s.jsxDEV)("div",{"aria-hidden":"true",className:"shrink-0 select-none overflow-hidden border-e border-border bg-muted/30 py-3 text-end font-mono text-xs leading-5 text-muted-foreground/60",ref:M,style:go,children:Array.from({length:Nt},(i,b)=>(0,s.jsxDEV)("div",{children:b+1},b,!1))},void 0,!1),(0,s.jsxDEV)("div",{className:"relative min-w-0 flex-1",children:[(0,s.jsxDEV)("textarea",{"aria-activedescendant":Q===null?void 0:`${P}-opt-${Q.active.toString()}`,"aria-autocomplete":"list","aria-controls":Q===null?void 0:P,"aria-expanded":Q!==null,"aria-label":o("SQL query"),className:"size-full resize-none bg-background p-3 font-mono text-xs leading-5 outline-none","data-testid":"sql-input",onBlur:Qe,onChange:Ke,onKeyDown:Je,onScroll:Ve,onSelect:Ge,placeholder:"SELECT * FROM \u2026",ref:z,role:"combobox",spellCheck:!1,value:L},void 0,!1),(0,s.jsxDEV)(Ut,{listboxId:P,onPick:Ue,state:Q},void 0,!1)]},void 0,!0)]},void 0,!0),(0,s.jsxDEV)("div",{className:"flex h-2/5 min-h-0 shrink-0 flex-col border-t border-border",children:[(0,s.jsxDEV)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pe-2",children:[(0,s.jsxDEV)("button",{className:me(k==="results"),"data-testid":"sql-tab-results",onClick:gt,type:"button",children:o("Results")},void 0,!1),(0,s.jsxDEV)("button",{className:me(k==="chart"),"data-testid":"sql-tab-chart",onClick:yt,type:"button",children:o("Chart")},void 0,!1),(0,s.jsxDEV)("button",{className:me(k==="explain"),"data-testid":"sql-tab-explain",onClick:xt,type:"button",children:o("Explain")},void 0,!1),(0,s.jsxDEV)("div",{className:"ms-auto flex items-center gap-2",children:[E!==null&&E.columns.length>0&&(0,s.jsxDEV)(Oe,{columns:E.columns,name:"query-result",rows:E.rows},void 0,!1),(0,s.jsxDEV)("button",{className:"inline-flex items-center rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-format",disabled:h,onClick:st,type:"button",children:o("Format")},void 0,!1),(0,s.jsxDEV)(we,{onChange:S,testId:"sql-shard-input",value:x},void 0,!1),(0,s.jsxDEV)("button",{className:"inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-run",disabled:h,onClick:je,type:"button",children:[o(h?"Running\u2026":"Run"),(0,s.jsxDEV)("kbd",{className:"rounded border border-primary-foreground/30 px-1 font-sans text-[10px]",children:"\u2318\u21B5"},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0),(0,s.jsxDEV)("div",{className:"min-h-0 flex-1 overflow-auto",children:[$!==null&&(0,s.jsxDEV)(De,{className:"m-3 font-mono text-xs",testId:"sql-error",variant:"destructive",children:$},void 0,!1),$===null&&E===null&&(0,s.jsxDEV)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-empty",children:o("Click Run to execute your query.")},void 0,!1),$===null&&E!==null&&(0,s.jsxDEV)("div",{"data-testid":"sql-result",children:[k==="chart"?(0,s.jsxDEV)(Me,{result:E},void 0,!1):(0,s.jsxDEV)(xo,{result:E},void 0,!1),(0,s.jsxDEV)("p",{className:"border-t border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"sql-count",children:E.truncated?o("Showing the first {max} of {count} rows.",{count:E.rowCount,max:E.rows.length}):o("{count} rows",{count:E.rowCount})},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0)]},void 0,!0)]},void 0,!0)},"SqlEditorPanel");function yo(n){return(0,s.jsxDEV)(Re,{children:n},n,!1)}r(yo,"_temp");export{Ao as SqlEditorPanel};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{a as o,c as N,f as Q}from"./chunk-RRCPZMC2.js";var C=N(i=>{"use strict";(function(){function l(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===B?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case m:return"Fragment";case U:return"Profiler";case L:return"StrictMode";case G:return"Suspense";case X:return"SuspenseList";case K:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case W:return"Portal";case V:return e.displayName||"Context";case M:return(e._context.displayName||"Context")+".Consumer";case z:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case q:return r=e.displayName||null,r!==null?r:l(e.type)||"Memo";case d:r=e._payload,e=e._init;try{return l(e(r))}catch{}}return null}o(l,"getComponentNameFromType");function p(e){return""+e}o(p,"testStringCoercion");function v(e){try{p(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,n=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",n),p(e)}}o(v,"checkKeyStringCoercion");function f(e){if(e===m)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===d)return"<...>";try{var r=l(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}o(f,"getTaskName");function Y(){var e=b.A;return e===null?null:e.getOwner()}o(Y,"getOwner");function R(){return Error("react-stack-top-frame")}o(R,"UnknownOwner");function I(e){if(A.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}o(I,"hasValidKey");function D(e,r){function t(){S||(S=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}o(t,"warnAboutAccessingKey"),t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}o(D,"defineKeyPropWarningGetter");function $(){var e=l(this.type);return w[e]||(w[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}o($,"elementRefGetterWithDeprecationWarning");function F(e,r,t,n,u,_){var a=t.ref;return e={$$typeof:y,type:e,key:r,props:t,_owner:n},(a!==void 0?a:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:$}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:u}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:_}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}o(F,"ReactElement");function O(e,r,t,n,u,_){var a=r.children;if(a!==void 0)if(n)if(H(a)){for(n=0;n<a.length;n++)k(a[n]);Object.freeze&&Object.freeze(a)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else k(a);if(A.call(r,"key")){a=l(e);var c=Object.keys(r).filter(function(Z){return Z!=="key"});n=0<c.length?"{key: someKey, "+c.join(": ..., ")+": ...}":"{key: someKey}",h[a+n]||(c=0<c.length?"{"+c.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
|
+
let props = %s;
|
|
3
|
+
<%s {...props} />
|
|
4
|
+
React keys must be passed directly to JSX without using spread:
|
|
5
|
+
let props = %s;
|
|
6
|
+
<%s key={someKey} {...props} />`,n,a,c,a),h[a+n]=!0)}if(a=null,t!==void 0&&(v(t),a=""+t),I(r)&&(v(r.key),a=""+r.key),"key"in r){t={};for(var T in r)T!=="key"&&(t[T]=r[T])}else t=r;return a&&D(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),F(e,a,t,Y(),u,_)}o(O,"jsxDEVImpl");function k(e){g(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===d&&(e._payload.status==="fulfilled"?g(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}o(k,"validateChildKeys");function g(e){return typeof e=="object"&&e!==null&&e.$$typeof===y}o(g,"isValidElement");var s=Q(),y=Symbol.for("react.transitional.element"),W=Symbol.for("react.portal"),m=Symbol.for("react.fragment"),L=Symbol.for("react.strict_mode"),U=Symbol.for("react.profiler"),M=Symbol.for("react.consumer"),V=Symbol.for("react.context"),z=Symbol.for("react.forward_ref"),G=Symbol.for("react.suspense"),X=Symbol.for("react.suspense_list"),q=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),K=Symbol.for("react.activity"),B=Symbol.for("react.client.reference"),b=s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A=Object.prototype.hasOwnProperty,H=Array.isArray,E=console.createTask?console.createTask:function(){return null};s={react_stack_bottom_frame:o(function(e){return e()},"react_stack_bottom_frame")};var S,w={},P=s.react_stack_bottom_frame.bind(s,R)(),j=E(f(R)),h={};i.Fragment=m,i.jsx=function(e,r,t){var n=1e4>b.recentlyCreatedOwnerStacks++;return O(e,r,t,!1,n?Error("react-stack-top-frame"):P,n?E(f(e)):j)},i.jsxs=function(e,r,t){var n=1e4>b.recentlyCreatedOwnerStacks++;return O(e,r,t,!0,n?Error("react-stack-top-frame"):P,n?E(f(e)):j)}})()});var J=N((te,x)=>{"use strict";x.exports=C()});export{J as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as v,f as U}from"./chunk-RRCPZMC2.js";var s=[["path",{d:"M2.99969 17.0002C2.99969 17.9302 2.99969 18.3952 3.10192 18.7767C3.37932 19.8119 4.18796 20.6206 5.22324 20.898C5.60474 21.0002 6.06972 21.0002 6.99969 21.0002L16.9997 21.0002C17.9297 21.0002 18.3947 21.0002 18.7762 20.898C19.8114 20.6206 20.6201 19.8119 20.8975 18.7767C20.9997 18.3952 20.9997 17.9302 20.9997 17.0002",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",key:"0"}],["path",{d:"M16.4998 11.5002C16.4998 11.5002 13.1856 16.0002 11.9997 16.0002C10.8139 16.0002 7.49976 11.5002 7.49976 11.5002M11.9997 15.0002V3.00016",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",key:"1"}]];var a=[["path",{d:"M18 9.00005C18 9.00005 13.5811 15 12 15C10.4188 15 6 9 6 9",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",key:"0"}]];var o=[["path",{d:"M17.9998 15C17.9998 15 13.5809 9.00001 11.9998 9C10.4187 8.99999 5.99985 15 5.99985 15",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",key:"0"}]];var r=[["path",{d:"M18 6L6.00081 17.9992M17.9992 18L6 6.00085",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",key:"0"}]];var e=[["path",{d:"M9 15C9 12.1716 9 10.7574 9.87868 9.87868C10.7574 9 12.1716 9 15 9L16 9C18.8284 9 20.2426 9 21.1213 9.87868C22 10.7574 22 12.1716 22 15V16C22 18.8284 22 20.2426 21.1213 21.1213C20.2426 22 18.8284 22 16 22H15C12.1716 22 10.7574 22 9.87868 21.1213C9 20.2426 9 18.8284 9 16L9 15Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",key:"0"}],["path",{d:"M16.9999 9C16.9975 6.04291 16.9528 4.51121 16.092 3.46243C15.9258 3.25989 15.7401 3.07418 15.5376 2.90796C14.4312 2 12.7875 2 9.5 2C6.21252 2 4.56878 2 3.46243 2.90796C3.25989 3.07417 3.07418 3.25989 2.90796 3.46243C2 4.56878 2 6.21252 2 9.5C2 12.7875 2 14.4312 2.90796 15.5376C3.07417 15.7401 3.25989 15.9258 3.46243 16.092C4.51121 16.9528 6.04291 16.9975 9 16.9999",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",key:"1"}]];var f=[["path",{d:"M17 17L21 21",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",key:"0"}],["path",{d:"M19 11C19 6.58172 15.4183 3 11 3C6.58172 3 3 6.58172 3 11C3 15.4183 6.58172 19 11 19C15.4183 19 19 15.4183 19 11Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",key:"1"}]];var S=[["path",{d:"M21.0477 3.05293C18.8697 0.707363 2.48648 6.4532 2.50001 8.551C2.51535 10.9299 8.89809 11.6617 10.6672 12.1581C11.7311 12.4565 12.016 12.7625 12.2613 13.8781C13.3723 18.9305 13.9301 21.4435 15.2014 21.4996C17.2278 21.5892 23.1733 5.342 21.0477 3.05293Z",stroke:"currentColor",strokeWidth:"1.5",key:"0"}],["path",{d:"M11.4999 12.5L14.9999 9",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",key:"1"}]];var m=[["path",{d:"M2 12C2 8.31087 2 6.4663 2.81382 5.15877C3.1149 4.67502 3.48891 4.25427 3.91891 3.91554C5.08116 3 6.72077 3 10 3H14C17.2792 3 18.9188 3 20.0811 3.91554C20.5111 4.25427 20.8851 4.67502 21.1862 5.15877C22 6.4663 22 8.31087 22 12C22 15.6891 22 17.5337 21.1862 18.8412C20.8851 19.325 20.5111 19.7457 20.0811 20.0845C18.9188 21 17.2792 21 14 21H10C6.72077 21 5.08116 21 3.91891 20.0845C3.48891 19.7457 3.1149 19.325 2.81382 18.8412C2 17.5337 2 15.6891 2 12Z",stroke:"currentColor",strokeWidth:"1.5",key:"0"}],["path",{d:"M9.5 3L9.5 21",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:"1.5",key:"1"}],["path",{d:"M5 7H6M5 10H6",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",key:"2"}]];var h=[["path",{d:"M5 14L8.5 17.5L19 6.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",key:"0"}]];var k=[["path",{d:"M18 14C18 14 13.5811 19 12 19C10.4188 19 6 14 6 14",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",key:"0"}],["path",{d:"M18 9.99996C18 9.99996 13.5811 5.00001 12 5C10.4188 4.99999 6 10 6 10",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",key:"1"}]];var n=v(U(),1),H={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none"},A=(0,n.forwardRef)(({color:u="currentColor",size:d=24,strokeWidth:c,absoluteStrokeWidth:B=!1,className:w="",altIcon:F,showAlt:M=!1,icon:L,primaryColor:I,secondaryColor:i,disableSecondaryOpacity:P=!1,...D},T)=>{let x=c!==void 0?B?Number(c)*24/Number(d):c:void 0,C=x!==void 0?{strokeWidth:x,stroke:"currentColor"}:{},R={ref:T,...H,width:d,height:d,color:I||u,className:w,...C,...D},y=[...M&&F?F:L].sort(([,p],[,t])=>{let l=p.opacity!==void 0;return t.opacity!==void 0?1:l?-1:0}).map(([p,t])=>{let l=t.opacity!==void 0,g=l&&!P?t.opacity:void 0,b=i?{...t.stroke!==void 0?{stroke:l?i:I||u}:{fill:l?i:I||u}}:{};return(0,n.createElement)(p,{...t,...C,...b,opacity:g,key:t.key})});return(0,n.createElement)("svg",R,y)});A.displayName="HugeiconsIcon";export{a,o as b,r as c,e as d,s as e,f,S as g,m as h,h as i,k as j,A as k};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as R}from"./chunk-AB6QGMBF.js";import"./chunk-GTM65MVX.js";import{a as p}from"./chunk-AQGOX5DK.js";import{b as h}from"./chunk-FCR3HKFV.js";import"./chunk-SEU5V7I6.js";import"./chunk-KODWGUAB.js";import"./chunk-3OA7PECS.js";import{d as m}from"./chunk-YJGANMU7.js";import{a as i,e as u,g as k,h as S}from"./chunk-RRCPZMC2.js";var f=u(k(),1);var g=u(S(),1);var A=i((e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("Live admin subscriptions are ungated")})[s.kind],"findingTitle"),_=i(e=>Array.isArray(e.findings)?e.findings:[],"toFindings"),E=i(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"findingEntity"),w=i((e,s)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: live admin subscriptions need no credential. Set it to gate them like the HTTP admin RPCs.")})[s.kind],"findingDetail"),N=i(()=>{let e=(0,f.c)(7),s=m(),r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},e[0]=r):r=e[0];let{data:a,error:d}=h(p.getSecurityAudit,r),o;if(e[1]!==a||e[2]!==s){let l=a===void 0?null:_(a);o=l===null?null:l.map(t=>({description:w(s,t),entity:E(t),issueType:A(s,t),key:t.kind,level:t.level})),e[1]=a,e[2]=s,e[3]=o}else o=e[3];let c=o,n;return e[4]!==d||e[5]!==c?(n=(0,g.jsxDEV)(R,{error:d,rows:c,testId:"lunora-security-advisor"},void 0,!1),e[4]=d,e[5]=c,e[6]=n):n=e[6],n},"SecurityAdvisorPanel");export{N as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{l as we,m as Ke,ma as je}from"./chunk-NNISYDNI.js";import{i as Ge,k as He}from"./chunk-4QHKBC77.js";import{D as Me,I as Se,K as Ve,L as De,M as Le,N as Oe,O as Te,P as Fe,Q as _e,a as $,b as Ie,c as Ne,e as F,f as Be}from"./chunk-BHTPZS7L.js";import{b as Ae}from"./chunk-YQQJ4N6U.js";import{a as T,e as ce}from"./chunk-TICVNLPM.js";import{a as ve,c as Re,d as Ee,g as de,i as Pe,j as W}from"./chunk-ZH7UES4T.js";import{a as vt}from"./chunk-3OA7PECS.js";import{a as i,d as Ct,e as k,f as O,g as yt,h as Rt,j as ye}from"./chunk-RRCPZMC2.js";var Je=k(yt(),1);var w={};Ct(w,{Indicator:()=>fe,Root:()=>ue});var u=k(O(),1);function Ue(t){if(!t)return null;for(let e of t.elements){let n=e.tagName;if(n==="BUTTON"||n==="INPUT"){let o=e;if(o.type==="submit")return o}}return null}i(Ue,"getDefaultFormSubmitter");var qe=k(O(),1);var le=(function(t){return t.checked="data-checked",t.unchecked="data-unchecked",t.indeterminate="data-indeterminate",t.disabled="data-disabled",t.readonly="data-readonly",t.required="data-required",t.valid="data-valid",t.invalid="data-invalid",t.touched="data-touched",t.dirty="data-dirty",t.filled="data-filled",t.focused="data-focused",t})({});function z(t){return qe.useMemo(()=>({checked(e){return t.indeterminate?{}:e?{[le.checked]:""}:{[le.unchecked]:""}},...$}),[t.indeterminate])}i(z,"useStateAttributesMapping");var We=k(O(),1);function $e(t,e,n,o=!0,a){let[f,p]=We.useState(),M=F(a?`${a}-label`:void 0),b=t??e??f;return T(()=>{let g=t||e||!o?void 0:Et(n.current,M);f!==g&&p(g)}),b}i($e,"useAriaLabelledBy");function Et(t,e){let n=Pt(t);if(n)return!n.id&&e&&(n.id=e),n.id||void 0}i(Et,"getAriaLabelledBy");function Pt(t){if(!t)return;let e=t.parentElement;if(e&&e.tagName==="LABEL")return e;let n=t.id;if(n){let a=t.nextElementSibling;if(a&&a.htmlFor===n)return a}let o=t.labels;return o&&o[0]}i(Pt,"findAssociatedLabel");var J=k(O(),1);var X=J.createContext(void 0);X.displayName="CheckboxRootContext";function ze(){let t=J.useContext(X);if(t===void 0)throw new Error("Base UI: CheckboxRootContext is missing. Checkbox parts must be placed within <Checkbox.Root>.");return t}i(ze,"useCheckboxRootContext");var _=k(vt(),1);var It="data-parent",ue=u.forwardRef(i(function(e,n){let{checked:o,className:a,defaultChecked:f=!1,"aria-labelledby":p,disabled:M=!1,form:b,id:g,indeterminate:S=!1,inputRef:Z,name:K,onCheckedChange:A,parent:m=!1,readOnly:R=!1,render:pe,required:E=!1,uncheckedValue:j,value:G,nativeButton:H=!1,style:Nt,...Xe}=e,{clearErrors:Ye}=Ne(),{disabled:Qe,name:Ze,setDirty:et,setFilled:ee,setFocused:me,setTouched:tt,state:he,validationMode:rt,validityData:nt,validation:ot}=Ie(),it=Me(),{labelId:at,controlId:st,registerControlId:P,getDescriptionProps:be}=Be(),s=_e(),V=s?.parent,D=V&&s.allValues,c=Qe||it.disabled||s?.disabled||M,I=Ze??K,d=G??I,ge=F(),dt=F(),x=st;D?x=m?dt:`${V.id}-${d}`:g&&(x=g);let te={};D&&(m?te=s.parent.getParentProps():d&&(te=s.parent.getChildProps(d)));let{checked:ke=o,indeterminate:ct=S,onCheckedChange:lt,...ut}=te,N=s?.value,xe=s?.setValue,Ce=s?.defaultValue,re=u.useRef(null),U=Re(()=>Symbol("checkbox-control")),ne=u.useRef(!1),{getButtonProps:ft,buttonRef:pt}=Ae({disabled:c,native:H}),B=s?.validation??ot,[l,mt]=Le({controlled:d&&N&&!m?N.includes(d):ke,default:d&&Ce&&!m?Ce.includes(d):f,name:"Checkbox",state:"checked"}),oe=D?!!ke:l,L=D&&ct||S;T(()=>{P!==de&&(ne.current=!0,P(U.current,x))},[x,P,U]),u.useEffect(()=>{let r=U.current;return()=>{!ne.current||P===de||(ne.current=!1,P(r,void 0))}},[P,U]),Oe(re,ge,l,void 0,!s&&!c,K);let C=u.useRef(null),ht=Ee(Z,C,B.inputRef,B.registerInput),bt=$e(p,at,C,!H,x??void 0);T(()=>{C.current&&(C.current.indeterminate=L,l&&ee(!0))},[l,L,ee]),je(l,()=>{s||(Ye(I),ee(l),et(l!==nt.initialValue),B.change(l))});let gt=ve({checked:l,disabled:c,form:b,name:m?void 0:I,id:H?void 0:x??void 0,required:E,ref:ht,style:I?Ke:we,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(r){if(r.nativeEvent.defaultPrevented)return;if(R){r.preventDefault();return}let h=r.currentTarget.checked,y=Fe(Te.none,r.nativeEvent);if(A?.(h,y),!y.isCanceled&&(lt?.(h,y),!y.isCanceled&&(mt(h),d&&N&&xe&&!m&&!D))){let v=h?[...N,d]:N.filter(q=>q!==d);xe(v,y)}},onFocus(){re.current?.focus()}},G!==void 0?{value:(s?l&&G:G)||""}:Pe,be,r=>B.getValidationProps(c,r));u.useEffect(()=>{if(!V||!d)return;let r=V.disabledStatesRef.current;return r.set(d,c),()=>{r.delete(d)}},[V,c,d]);let ie=u.useMemo(()=>({...he,checked:oe,disabled:c,readOnly:R,required:E,indeterminate:L}),[he,oe,c,R,E,L]),kt=z(ie),xt=W("span",e,{state:ie,ref:[pt,re,n,s?.registerControlRef],props:[{id:H?x??void 0:ge,role:"checkbox","aria-checked":L?"mixed":oe,"aria-readonly":R||void 0,"aria-required":E||void 0,"aria-labelledby":bt,[It]:m?"":void 0,onFocus(){c||me(!0)},onBlur(){let r=C.current;r&&(tt(!0),me(!1),rt==="onBlur"&&B.commit(s?N:r.checked))},onKeyDown(r){if(r.key!=="Enter"||(r.preventBaseUIHandler(),r.defaultPrevented))return;let h=C.current?.form??null,y=r.currentTarget,v=r.nativeEvent,q=r.preventDefault,ae=v.preventDefault,se=!1;r.preventDefault=()=>{se=!0,q.call(r)},v.preventDefault=()=>{se=!0,ae.call(v)},ae.call(v),ce(y).queueMicrotask(()=>{r.preventDefault=q,v.preventDefault=ae,se||Ue(h)?.click()})},onClick(r){if(R||c)return;r.preventDefault();let h=C.current;h&&h.dispatchEvent(new(ce(h)).PointerEvent("click",{bubbles:!0,shiftKey:r.shiftKey,ctrlKey:r.ctrlKey,altKey:r.altKey,metaKey:r.metaKey}))}},Xe,ut,ft,be,r=>B.getValidationProps(c,r)],stateAttributesMapping:kt});return(0,_.jsxs)(X.Provider,{value:ie,children:[xt,!l&&!s&&I&&!m&&j!==void 0&&(0,_.jsx)("input",{type:"hidden",form:b,name:I,value:j,disabled:c}),(0,_.jsx)("input",{...gt,suppressHydrationWarning:!0})]})},"CheckboxRoot"));ue.displayName="CheckboxRoot";var Y=k(O(),1);var fe=Y.forwardRef(i(function(e,n){let{render:o,className:a,style:f,keepMounted:p=!1,...M}=e,b=ze(),g=b.checked||b.indeterminate,{mounted:S,transitionStatus:Z,setMounted:K}=De(g),A=Y.useRef(null),m={...b,transitionStatus:Z};Ve({open:g,ref:A,onComplete(){g||K(!1)}});let pe={...z(b),...Se,...$},E=p||S,j=W("span",e,{ref:[n,A],state:m,stateAttributesMapping:pe,props:M});return E?j:null},"CheckboxIndicator"));fe.displayName="CheckboxIndicator";var Q=k(Rt(),1);function Sr(t){let e=(0,Je.c)(9),n,o;e[0]!==t?({className:n,...o}=t,e[0]=t,e[1]=n,e[2]=o):(n=e[1],o=e[2]);let a;e[3]!==n?(a=ye("peer relative flex size-4 shrink-0 items-center justify-center rounded-md border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-1 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary",n),e[3]=n,e[4]=a):a=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=(0,Q.jsxDEV)(w.Indicator,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none [&>svg]:size-3.5",children:(0,Q.jsxDEV)(He,{icon:Ge,strokeWidth:2},void 0,!1)},void 0,!1),e[5]=f):f=e[5];let p;return e[6]!==o||e[7]!==a?(p=(0,Q.jsxDEV)(w.Root,{"data-slot":"checkbox",className:a,...o,children:f},void 0,!1),e[6]=o,e[7]=a,e[8]=p):p=e[8],p}i(Sr,"Checkbox");export{Sr as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,e as s,f as d}from"./chunk-RRCPZMC2.js";function u(n,o,r,c){return n.addEventListener(o,r,c),()=>{n.removeEventListener(o,r,c)}}e(u,"addEventListener");var t=s(d(),1);var i=t.createContext(void 0);i.displayName="DirectionContext";function f(){return t.useContext(i)?.direction??"ltr"}e(f,"useDirection");export{u as a,f as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as $,b as F,c as D,d as p,e as l,f as i}from"./chunk-GTM65MVX.js";import{a as se}from"./chunk-VLXV72QE.js";import{R as te}from"./chunk-BHTPZS7L.js";import{c as T}from"./chunk-YQQJ4N6U.js";import"./chunk-TICVNLPM.js";import"./chunk-HV7G6DFP.js";import{a as K}from"./chunk-AQGOX5DK.js";import{a as B}from"./chunk-TAD43CG5.js";import{b as ae}from"./chunk-FCR3HKFV.js";import{a as R,e as _}from"./chunk-SEU5V7I6.js";import"./chunk-ZH7UES4T.js";import{f as Q}from"./chunk-KODWGUAB.js";import"./chunk-3OA7PECS.js";import{d as V,e as X,f as Y,g as E,i as W}from"./chunk-YJGANMU7.js";import{a as r,e as ee,f as re,h as le}from"./chunk-RRCPZMC2.js";var n=ee(re(),1);var e=ee(le(),1);var ie=["queued","running","paused","waiting","complete","errored","terminated"],ne=["pause","resume","terminate"],de="WORKFLOWS_NOT_CONFIGURED",ce=r(c=>typeof c=="object"&&c!==null&&c.code===de,"isNotConfigured"),fe=r(c=>{let s=c.error??c.output;if(s===void 0)return"\u2014";try{return JSON.stringify(s)}catch{return"(unserializable)"}},"formatStepPayload"),ue=r(({loadDetail:c,loadInstances:s,readOnly:y,runAction:L,workflowName:v})=>{let A=Q(),o=V(),[x,N]=(0,n.useState)(null),[k,I]=(0,n.useState)(null),[w,P]=(0,n.useState)(""),[g,h]=(0,n.useState)(null),[U,S]=(0,n.useState)(!1),[z,J]=(0,n.useState)(null),m=c??(a=>A.getWorkflowInstance(a)),O=y?void 0:L??(s===void 0?a=>A.setWorkflowInstanceStatus(a):void 0),j=r(async()=>{h(null),S(!1);let a=w===""?void 0:w;try{if(s===void 0){let d=await A.listWorkflowInstances({name:v,status:a});if(d.configured===!1){N(null),S(!0);return}N(d.instances);return}N(await s({name:v,status:a}))}catch(d){N(null),ce(d)?S(!0):h(E(d))}},"load");(0,n.useEffect)(()=>{I(null),W(j())},[v,w]);let G=r(async a=>{h(null);try{I(await m({id:a,name:v}))}catch(d){h(E(d))}},"openDetail"),H=r(async(a,d)=>{if(O!==void 0){J(a),h(null);try{await O({action:d,id:a,name:v}),await j()}catch(M){h(E(M))}finally{J(null)}}},"act");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[(0,e.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxDEV)("h3",{className:"text-sm font-medium",children:o("Instance history")},void 0,!1),(0,e.jsxDEV)("select",{"aria-label":o("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:r(a=>{P(a.target.value)},"onChange"),value:w,children:[(0,e.jsxDEV)("option",{value:"",children:o("All statuses")},void 0,!1),ie.map(a=>(0,e.jsxDEV)("option",{value:a,children:a},a,!1))]},void 0,!0)]},void 0,!0),g!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:g},void 0,!1),U&&(0,e.jsxDEV)(B,{description:o("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:o("Workflow inspection not configured")},void 0,!1),!U&&x!==null&&x.length===0&&(0,e.jsxDEV)(B,{description:o("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:o("No instances")},void 0,!1),x!==null&&x.length>0&&(0,e.jsxDEV)(R,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(_,{className:"px-0",children:(0,e.jsxDEV)($,{"data-testid":"workflow-instances-table",children:[(0,e.jsxDEV)(F,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(l,{children:o("Instance id")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Status")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Created")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Ended")},void 0,!1),(0,e.jsxDEV)(l,{"aria-label":o("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(D,{children:x.map(a=>(0,e.jsxDEV)(p,{"data-testid":`workflow-instance-${a.id}`,children:[(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:a.id},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:a.status},void 0,!1),(0,e.jsxDEV)(i,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"text-right",children:(0,e.jsxDEV)("div",{className:"flex justify-end gap-1.5",children:[(0,e.jsxDEV)(T,{"data-testid":`workflow-instance-steps-${a.id}`,onClick:r(()=>{W(G(a.id))},"onClick"),size:"sm",type:"button",variant:"outline",children:o("Steps")},void 0,!1),O!==void 0&&ne.map(d=>(0,e.jsxDEV)(T,{"data-testid":`workflow-instance-${d}-${a.id}`,disabled:z===a.id,onClick:r(()=>{W(H(a.id,d))},"onClick"),size:"sm",type:"button",variant:"ghost",children:o(d)},d,!1))]},void 0,!0)},void 0,!1)]},a.id,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),k!==null&&(0,e.jsxDEV)(R,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:(0,e.jsxDEV)(_,{className:"flex flex-col gap-2 px-4 py-3",children:[(0,e.jsxDEV)("div",{className:"flex items-center justify-between",children:[(0,e.jsxDEV)("span",{className:"font-mono text-xs",children:[o("Steps")," \xB7 ",k.id]},void 0,!0),(0,e.jsxDEV)(T,{"data-testid":"workflow-instance-detail-close",onClick:r(()=>{I(null)},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Close")},void 0,!1)]},void 0,!0),k.steps.length===0?(0,e.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:o("This instance has no recorded steps yet.")},void 0,!1):(0,e.jsxDEV)($,{"data-testid":"workflow-instance-steps",children:[(0,e.jsxDEV)(F,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(l,{children:o("Step")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Type")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Attempts")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Started")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Output")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(D,{children:k.steps.map((a,d)=>(0,e.jsxDEV)(p,{"data-testid":`workflow-step-${String(d)}`,children:[(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:a.name},void 0,!1),(0,e.jsxDEV)(i,{className:"text-xs text-muted-foreground",children:a.type??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"tabular-nums",children:a.attempts??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"text-muted-foreground tabular-nums",children:a.start??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:fe(a)},void 0,!1)]},`${a.name}:${String(d)}`,!0))},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1)]},void 0,!0)},"WorkflowInstanceHistory"),me=X(K.createWorkflowInstance),ve=X(K.getWorkflowInstanceStatus),he=r(c=>{if(c.error)return`${c.error.name}: ${c.error.message}`;if(c.output===void 0)return"\u2014";try{return JSON.stringify(c.output)}catch{return"(unserializable)"}},"formatPayload"),Oe=r(()=>{let c=Q(),s=V(),{data:y,error:L}=ae(K.listWorkflows,{}),[v,A]=(0,n.useState)(""),[o,x]=(0,n.useState)(""),[N,k]=(0,n.useState)(""),[I,w]=(0,n.useState)(!1),[P,g]=(0,n.useState)(null),[h,U]=(0,n.useState)([]),[S,z]=(0,n.useState)(null),J=y!==void 0,m=(0,n.useMemo)(()=>Array.isArray(y?.workflows)?[...y.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],[y]),C=(0,n.useMemo)(()=>m.some(t=>t.exportName===v)?v:m[0]?.exportName??"",[m,v]),q=(0,n.useMemo)(()=>m.find(t=>t.exportName===C),[m,C]),O=r(t=>{U(u=>{let f=u.filter(b=>!(b.exportName===t.exportName&&b.id===t.id));return[t,...f]})},"upsertInstance"),j=r(async()=>{let t=C;if(t==="")return;let u,f=N.trim();if(f!=="")try{u=JSON.parse(f)}catch{g(s("Params must be valid JSON"));return}w(!0),g(null);try{let b=o.trim(),Z=await c.query(me,{exportName:t,id:b===""?void 0:b,params:u},Y(""));O({exportName:t,id:Z.id,status:Z.status}),x("")}catch(b){g(E(b))}finally{w(!1)}},"start"),G=r(()=>{W(j())},"startInstance"),H=r(async(t,u)=>{z(u);try{let f=await c.query(ve,{exportName:t,id:u},Y(""));O({error:f.error,exportName:t,id:f.id,output:f.output,status:f.status})}catch(f){g(E(f))}finally{z(null)}},"refreshInstance"),a=r(t=>{A(t.target.value)},"onSelectedExportChange"),d=r(t=>{x(t.target.value)},"onInstanceIdChange"),M=r(t=>{k(t.target.value)},"onParamsChange"),oe=r(t=>{let{export:u,id:f}=t.currentTarget.dataset;u!==void 0&&f!==void 0&&W(H(u,f))},"onRefreshClick");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[L!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:L},void 0,!1),(0,e.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:s("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")},void 0,!1),J&&m.length===0?(0,e.jsxDEV)(B,{description:s("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:s("No workflows defined")},void 0,!1):(0,e.jsxDEV)(R,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(_,{className:"px-0",children:(0,e.jsxDEV)($,{"data-testid":"workflows-table",children:[(0,e.jsxDEV)(F,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(l,{children:s("Export")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Name")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Class")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Binding")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(D,{children:m.map(t=>(0,e.jsxDEV)(p,{"data-testid":`workflows-row-${t.exportName}`,children:[(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:t.exportName},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:t.name},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:t.className},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:t.binding},void 0,!1)]},t.exportName,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),m.length>0&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[(0,e.jsxDEV)("h3",{className:"text-sm font-medium",children:s("Start instance")},void 0,!1),P!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:P},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxDEV)("select",{"aria-label":s("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:a,value:C,children:m.map(t=>(0,e.jsxDEV)("option",{value:t.exportName,children:t.exportName},t.exportName,!1))},void 0,!1),(0,e.jsxDEV)(te,{"aria-label":s("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:d,placeholder:s("Instance id (optional)"),value:o},void 0,!1),(0,e.jsxDEV)(T,{"data-testid":"workflows-start-button",disabled:I||C==="",onClick:G,children:s(I?"Starting\u2026":"Start instance")},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(se,{"aria-label":s("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:M,placeholder:s("Params (JSON, optional)"),value:N},void 0,!1)]},void 0,!0),h.length>0&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[(0,e.jsxDEV)("h3",{className:"text-sm font-medium",children:s("Instances")},void 0,!1),(0,e.jsxDEV)(R,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(_,{className:"px-0",children:(0,e.jsxDEV)($,{"data-testid":"workflows-instances-table",children:[(0,e.jsxDEV)(F,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(l,{children:s("Workflow")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Instance id")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Status")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Output")},void 0,!1),(0,e.jsxDEV)(l,{},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(D,{children:h.map(t=>(0,e.jsxDEV)(p,{"data-testid":`workflows-instance-${t.id}`,children:[(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:t.exportName},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:t.id},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:t.status},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:he(t)},void 0,!1),(0,e.jsxDEV)(i,{children:(0,e.jsxDEV)(T,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:S===t.id,onClick:oe,size:"xs",variant:"outline",children:S===t.id?s("Refreshing\u2026"):s("Refresh")},void 0,!1)},void 0,!1)]},`${t.exportName}:${t.id}`,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0),q!==void 0&&(0,e.jsxDEV)(ue,{workflowName:q.name},void 0,!1)]},void 0,!0)},"WorkflowsPanel");export{Oe as default};
|