@lunora/studio 1.0.0-alpha.8 → 1.0.0-alpha.80
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/LICENSE.md +6 -0
- package/dist/index.d.ts +777 -780
- package/dist/index.js +1 -41
- package/dist/mount.d.ts +10 -10
- package/dist/mount.js +1 -26
- package/dist/packem_chunks/ApiTab.js +1 -0
- package/dist/packem_chunks/AuditPanel.js +1 -0
- package/dist/packem_chunks/DeploymentHealthPanel.js +1 -0
- package/dist/packem_chunks/ExportImportPanel.js +3 -0
- package/dist/packem_chunks/FileBrowser.js +4 -0
- package/dist/packem_chunks/FunctionRunner.js +1 -0
- package/dist/packem_chunks/FunctionStatsPanel.js +1 -0
- package/dist/packem_chunks/HealthPanel.js +1 -0
- package/dist/packem_chunks/InsightsPanel.js +1 -0
- package/dist/packem_chunks/LogsPanel.js +1 -0
- package/dist/packem_chunks/MailPanel.js +2 -0
- package/dist/packem_chunks/MetricsPanel.js +1 -0
- package/dist/packem_chunks/NotificationsPanel.js +1 -0
- package/dist/packem_chunks/PitrPanel.js +1 -0
- package/dist/packem_chunks/SchemaViewer.js +1 -0
- package/dist/packem_chunks/SecurityAdvisorPanel.js +1 -0
- package/dist/packem_chunks/SettingsPanel.js +1 -0
- package/dist/packem_chunks/SqlEditorPanel.js +6 -0
- package/dist/packem_chunks/TableEditor.js +1 -0
- package/dist/packem_chunks/agents-panel.js +1 -0
- package/dist/packem_chunks/analytics-panel.js +1 -0
- package/dist/packem_chunks/auth-audit-panel.js +1 -0
- package/dist/packem_chunks/auth-config-panel.js +1 -0
- package/dist/packem_chunks/auth-sessions-panel.js +1 -0
- package/dist/packem_chunks/containers-panel.js +1 -0
- package/dist/packem_chunks/dashboards-panel.js +1 -0
- package/dist/packem_chunks/fanout-panel.js +1 -0
- package/dist/packem_chunks/flags-panel.js +1 -0
- package/dist/packem_chunks/issues-panel.js +1 -0
- package/dist/packem_chunks/kv-browser.js +1 -0
- package/dist/packem_chunks/log-drains-panel.js +4 -0
- package/dist/packem_chunks/migrations-route.js +1 -0
- package/dist/packem_chunks/organizations-panel.js +1 -0
- package/dist/packem_chunks/payments-panel.js +1 -0
- package/dist/packem_chunks/permissions-panel.js +1 -0
- package/dist/packem_chunks/queues-panel.js +1 -0
- package/dist/packem_chunks/rls-panel.js +1 -0
- package/dist/packem_chunks/schedule-panel.js +1 -0
- package/dist/packem_chunks/sparkline.js +1 -0
- package/dist/packem_chunks/storage-rules-panel.js +1 -0
- package/dist/packem_chunks/subscriptions-panel.js +1 -0
- package/dist/packem_chunks/sync-client-panel.js +1 -0
- package/dist/packem_chunks/traces-panel.js +1 -0
- package/dist/packem_chunks/users-panel.js +1 -0
- package/dist/packem_chunks/vector-browser.js +1 -0
- package/dist/packem_chunks/workflows-panel.js +1 -0
- package/dist/packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js +1 -0
- package/dist/packem_shared/ApiDocsPanel-DfUQ1ZAF.js +2 -0
- package/dist/packem_shared/ApiReferencePanel-9q8BbJl-.js +1 -0
- package/dist/packem_shared/CommandPalette--SQwfTW1.js +1 -0
- package/dist/packem_shared/ConfirmButton-CTL3f3kr.js +1 -0
- package/dist/packem_shared/ConnectionBadge-DOk0CQWo.js +1 -0
- package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js +1 -0
- package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-B-hcFVoi.js +1 -0
- package/dist/packem_shared/DEFAULT_LOCALE-BZ4NojpD.js +1 -0
- package/dist/packem_shared/DataBrowser-CuRlztBz.js +1 -0
- package/dist/packem_shared/DataFilters-B26ZeqBZ.js +1 -0
- package/dist/packem_shared/ErrorBoundary-DvzYskH7.js +1 -0
- package/dist/packem_shared/GlobalDataBrowser-DB-vQ2_H.js +1 -0
- package/dist/packem_shared/HomePanel-Dcs4a3Ax.js +1 -0
- package/dist/packem_shared/MigrationsPanel-C2OnsqRb.js +1 -0
- package/dist/packem_shared/OpenRpcReferencePanel-qOZcWXMs.js +1 -0
- package/dist/packem_shared/STUDIO_ROOT_CLASS-C6MccdVk.js +1 -0
- package/dist/packem_shared/ScheduledJobs-D8kBZWBu.js +1 -0
- package/dist/packem_shared/ShardInput-BVn2iCU0.js +1 -0
- package/dist/packem_shared/Studio-B26_pT8J.js +1 -0
- package/dist/packem_shared/StudioApp-bXhJeLlZ.js +1 -0
- package/dist/packem_shared/StudioI18nProvider-CZ5h4nrV.js +1 -0
- package/dist/packem_shared/advisor-view-Pa8HLtBv.js +1 -0
- package/dist/packem_shared/aggregateMetrics-BNfajLa2.js +1 -0
- package/dist/packem_shared/alert-CVcOFuDR.js +1 -0
- package/dist/packem_shared/app.d-DW7yZsfu.d.ts +252 -0
- package/dist/packem_shared/badge-BbuuAio7.js +1 -0
- package/dist/packem_shared/bar-chart-DraN_srt.js +9 -0
- package/dist/packem_shared/browser-storage-xjTyMKY0.js +1 -0
- package/dist/packem_shared/button-BkCrNcAs.js +1 -0
- package/dist/packem_shared/card-CIDGUN6K.js +1 -0
- package/dist/packem_shared/cf-links-gbDy51nR.js +1 -0
- package/dist/packem_shared/checkbox-StT4Gob6.js +1 -0
- package/dist/packem_shared/data-grid-DcxyIXwG.js +1 -0
- package/dist/packem_shared/data-view-params-ClrV7XgF.js +1 -0
- package/dist/packem_shared/dropdown-menu-C3RQ_HlW.js +2 -0
- package/dist/packem_shared/empty-state-Cg7t_8qu.js +1 -0
- package/dist/packem_shared/error-alert-t6cpEi0z.js +1 -0
- package/dist/packem_shared/grid-features-jnrD0SpX.js +6 -0
- package/dist/packem_shared/home-panel-CU6MWLHG.js +3 -0
- package/dist/packem_shared/input-JHu63lTv.js +1 -0
- package/dist/packem_shared/internal-BSIsQVC6.js +2 -0
- package/dist/packem_shared/label-6uP1obNF.js +1 -0
- package/dist/packem_shared/live-status-CmuRLFKf.js +1 -0
- package/dist/packem_shared/log-fields-CoL3hsIQ.js +1 -0
- package/dist/packem_shared/modal-shell-CUwwWC2o.js +1 -0
- package/dist/packem_shared/operation-console-provider-BMJNtiyB.js +1 -0
- package/dist/packem_shared/recording-client-DRAZEmzE.js +1 -0
- package/dist/packem_shared/reference-view-DnYYWr7I.js +12 -0
- package/dist/packem_shared/result-chart-DzJOVsaw.js +1 -0
- package/dist/packem_shared/schema-diagram-cg-bz_VL.js +2 -0
- package/dist/packem_shared/scroll-area-DTEq6Jec.js +2 -0
- package/dist/packem_shared/select-Bul-DeII.js +2 -0
- package/dist/packem_shared/shard-history-DMEW5VBE.js +1 -0
- package/dist/packem_shared/skeleton-C1wQ9M5t.js +1 -0
- package/dist/packem_shared/sparkline-CgjeUU2I.js +1 -0
- package/dist/packem_shared/storage-tier-DznqOf-q.js +1 -0
- package/dist/packem_shared/studio-q-C-acL7.js +2 -0
- package/dist/packem_shared/table-DdJBrClo.js +2 -0
- package/dist/packem_shared/table-list-sidebar-BFkSQwlB.js +1 -0
- package/dist/packem_shared/textarea-Bu2-jKAs.js +1 -0
- package/dist/packem_shared/trace-handoff-Dw7mwjxu.js +1 -0
- package/dist/packem_shared/use-admin-query-QJ-ibl5u.js +1 -0
- package/dist/packem_shared/use-async-submit-q3ymBJkD.js +1 -0
- package/dist/packem_shared/use-auth-config-BObBpdsi.js +1 -0
- package/dist/packem_shared/use-sql-assistant-CHEu2-Rk.js +1 -0
- package/dist/packem_shared/useDebounced-Ihdiid_k.js +1 -0
- package/dist/packem_shared/utils-bhneXptQ.js +1 -0
- package/dist/packem_shared/virtual-rect-1o1veP7R.js +1 -0
- package/dist/standalone/chunk-2GA4SHO7.js +1 -0
- package/dist/standalone/chunk-2OUPA2WJ.js +1 -0
- package/dist/standalone/chunk-2PJNAWB3.js +1 -0
- package/dist/standalone/chunk-2VDFV5TD.js +1 -0
- package/dist/standalone/chunk-2WOIRKEI.js +1 -0
- package/dist/standalone/chunk-33CL6OHR.js +1 -0
- package/dist/standalone/chunk-34D36UCW.js +1 -0
- package/dist/standalone/chunk-3C3CG7ZK.js +1 -0
- package/dist/standalone/chunk-3O3HAXW7.js +1 -0
- package/dist/standalone/chunk-3STOIE7Q.js +1 -0
- package/dist/standalone/chunk-3XIESWL4.js +1 -0
- package/dist/standalone/chunk-4UOFSGUS.js +1 -0
- package/dist/standalone/chunk-53WEPGUD.js +1 -0
- package/dist/standalone/chunk-54MMVNPT.js +1 -0
- package/dist/standalone/chunk-5CVJS7ON.js +1 -0
- package/dist/standalone/chunk-5Y3QLNWX.js +1 -0
- package/dist/standalone/chunk-6IKEW5LG.js +1 -0
- package/dist/standalone/chunk-6LNCYDZO.js +1 -0
- package/dist/standalone/chunk-6NY7SPDL.js +1 -0
- package/dist/standalone/chunk-6PNPIW6I.js +2 -0
- package/dist/standalone/chunk-6ST5ECQA.js +1 -0
- package/dist/standalone/chunk-6VAKZALJ.js +1 -0
- package/dist/standalone/chunk-6YI4WJO4.js +1 -0
- package/dist/standalone/chunk-6YTSSIEJ.js +3 -0
- package/dist/standalone/chunk-7LWMHTJ3.js +1 -0
- package/dist/standalone/chunk-7QIFDWQV.js +1 -0
- package/dist/standalone/chunk-7T7UOTYK.js +1 -0
- package/dist/standalone/chunk-A74VSSA2.js +4 -0
- package/dist/standalone/chunk-AADILRJW.js +14 -0
- package/dist/standalone/chunk-AVAC26HJ.js +1 -0
- package/dist/standalone/chunk-BGBLQ563.js +1 -0
- package/dist/standalone/chunk-CCVXYYPJ.js +1 -0
- package/dist/standalone/chunk-CFPZYHPY.js +2 -0
- package/dist/standalone/chunk-CT5MMH4O.js +1 -0
- package/dist/standalone/chunk-CTNB2KIA.js +1 -0
- package/dist/standalone/chunk-CU55Y5TV.js +62 -0
- package/dist/standalone/chunk-D2RKH6JK.js +1 -0
- package/dist/standalone/chunk-E3NMX2VU.js +4 -0
- package/dist/standalone/chunk-EN2QAEO4.js +11 -0
- package/dist/standalone/chunk-ESVP44Y3.js +1 -0
- package/dist/standalone/chunk-FNPJ7GJZ.js +1 -0
- package/dist/standalone/chunk-FOBRNWBG.js +3 -0
- package/dist/standalone/chunk-FXCBF4XT.js +1 -0
- package/dist/standalone/chunk-G6PSMGLD.js +1 -0
- package/dist/standalone/chunk-GAX5IZYG.js +8 -0
- package/dist/standalone/chunk-GB6U2BPU.js +1 -0
- package/dist/standalone/chunk-GEDMLM4A.js +6 -0
- package/dist/standalone/chunk-GMR677FL.js +1 -0
- package/dist/standalone/chunk-GRL5MG3Z.js +1 -0
- package/dist/standalone/chunk-GXSZH7VJ.js +13 -0
- package/dist/standalone/chunk-GYKVBKT5.js +1 -0
- package/dist/standalone/chunk-H6YOWRFB.js +1 -0
- package/dist/standalone/chunk-HJ3E4YF5.js +1 -0
- package/dist/standalone/chunk-HJD2YUQS.js +1 -0
- package/dist/standalone/chunk-HPFLBYRI.js +1 -0
- package/dist/standalone/chunk-IC4L6G56.js +1 -0
- package/dist/standalone/chunk-IHQC7J35.js +1 -0
- package/dist/standalone/chunk-ILNELDFC.js +1 -0
- package/dist/standalone/chunk-IVFHIQOT.js +1 -0
- package/dist/standalone/chunk-JLOWAJRR.js +1 -0
- package/dist/standalone/chunk-JN2Y24PY.js +1 -0
- package/dist/standalone/chunk-JRMMYIAF.js +1 -0
- package/dist/standalone/chunk-KC44QCN6.js +1 -0
- package/dist/standalone/chunk-KJB7YAKB.js +1 -0
- package/dist/standalone/chunk-KLQYC6CC.js +1 -0
- package/dist/standalone/chunk-KUVMORDQ.js +1 -0
- package/dist/standalone/chunk-KZ3ALMMP.js +1 -0
- package/dist/standalone/chunk-L7R74G63.js +1 -0
- package/dist/standalone/chunk-LEDWUPXM.js +1 -0
- package/dist/standalone/chunk-LFKCLLPT.js +1 -0
- package/dist/standalone/chunk-MIQTKZAR.js +1 -0
- package/dist/standalone/chunk-OG4N2XHD.js +19 -0
- package/dist/standalone/chunk-OY2RVUZL.js +1 -0
- package/dist/standalone/chunk-P4YLIBCN.js +1 -0
- package/dist/standalone/chunk-PZVU2QMX.js +1 -0
- package/dist/standalone/chunk-Q7O6B7WC.js +1 -0
- package/dist/standalone/chunk-QBWRC5YX.js +1 -0
- package/dist/standalone/chunk-QLQADHFE.js +1 -0
- package/dist/standalone/chunk-QWGT25SE.js +1 -0
- package/dist/standalone/chunk-QXXIJAD5.js +1 -0
- package/dist/standalone/chunk-QZGTH6WH.js +1 -0
- package/dist/standalone/chunk-RJP3WBZ4.js +1 -0
- package/dist/standalone/chunk-RNL6BSFM.js +1 -0
- package/dist/standalone/chunk-RNRJKBY3.js +4 -0
- package/dist/standalone/chunk-RQ7AFLIV.js +1 -0
- package/dist/standalone/chunk-S252DAFP.js +1 -0
- package/dist/standalone/chunk-S2VVR7HI.js +1 -0
- package/dist/standalone/chunk-SD4BERSA.js +1 -0
- package/dist/standalone/chunk-SFDOII3B.js +1 -0
- package/dist/standalone/chunk-SKHEGARW.js +1 -0
- package/dist/standalone/chunk-SKW6J4VW.js +1 -0
- package/dist/standalone/chunk-SMIESS7P.js +1 -0
- package/dist/standalone/chunk-T6VMSOBB.js +1 -0
- package/dist/standalone/chunk-T7IUZIF4.js +1 -0
- package/dist/standalone/chunk-THIXMMZD.js +1 -0
- package/dist/standalone/chunk-TTGOOYLF.js +1 -0
- package/dist/standalone/chunk-U6TNNM5U.js +1 -0
- package/dist/standalone/chunk-UZERI5YC.js +1 -0
- package/dist/standalone/chunk-V53KNYRN.js +1 -0
- package/dist/standalone/chunk-VHWOCPRK.js +1 -0
- package/dist/standalone/chunk-W6SAOXGH.js +6 -0
- package/dist/standalone/chunk-WBYSSCV2.js +1 -0
- package/dist/standalone/chunk-X665E2HU.js +1 -0
- package/dist/standalone/chunk-XBDKZZ67.js +1 -0
- package/dist/standalone/chunk-XDAT7LHC.js +1 -0
- package/dist/standalone/chunk-XQCVZAGU.js +1 -0
- package/dist/standalone/chunk-XS5LDR52.js +1 -0
- package/dist/standalone/chunk-XXQUMVWH.js +1 -0
- package/dist/standalone/chunk-Y5Y7DHFW.js +1 -0
- package/dist/standalone/chunk-YJYTMQJI.js +1 -0
- package/dist/standalone/chunk-Z2V42P7J.js +1 -0
- package/dist/standalone/chunk-ZJGP6EKR.js +1 -0
- package/dist/standalone/studio.js +9 -356
- package/dist/styles.css +2 -2
- package/package.json +16 -14
- package/dist/packem_shared/ADMIN_FUNCTIONS-DjXgvJb6.js +0 -46
- package/dist/packem_shared/ApiDocsPanel-yVSGHK3H.js +0 -842
- package/dist/packem_shared/ApiReferencePanel-1vubqG5s.js +0 -229
- package/dist/packem_shared/ApiTab-rwttyQ1-.js +0 -251
- package/dist/packem_shared/AuditPanel-BqXZAsu_.js +0 -212
- package/dist/packem_shared/CommandPalette-BtgkBzZI.js +0 -373
- package/dist/packem_shared/ConfirmButton-C2eVi2Qv.js +0 -59
- package/dist/packem_shared/ConnectionBadge-B2DDM2Tn.js +0 -111
- package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-Vxwaxx51.js +0 -50
- package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-DjF0h-gA.js +0 -89
- package/dist/packem_shared/DEFAULT_LOCALE-CiX4W7Kr.js +0 -27
- package/dist/packem_shared/DataBrowser-Ck_7QwNK.js +0 -4542
- package/dist/packem_shared/DataFilters-FNquMaiu.js +0 -249
- package/dist/packem_shared/ErrorBoundary-BzAApI7J.js +0 -66
- package/dist/packem_shared/ExportImportPanel-Dq6rj0tI.js +0 -193
- package/dist/packem_shared/FileBrowser-0pCpdKPE.js +0 -2932
- package/dist/packem_shared/FunctionRunner-7NH3KcTg.js +0 -343
- package/dist/packem_shared/FunctionStatsPanel-Cn_EBpDy.js +0 -432
- package/dist/packem_shared/GlobalDataBrowser-BTEmGrph.js +0 -318
- package/dist/packem_shared/HealthPanel-CQ4LzVET.js +0 -640
- package/dist/packem_shared/HomePanel-CP0lN1eF.js +0 -1273
- package/dist/packem_shared/InsightsPanel-DzNtoz7k.js +0 -423
- package/dist/packem_shared/LogsPanel-C3W0mabf.js +0 -839
- package/dist/packem_shared/MailPanel-CoEfWkCh.js +0 -447
- package/dist/packem_shared/MetricsPanel-CujtUfpl.js +0 -1625
- package/dist/packem_shared/MigrationsPanel-RX5qIFSr.js +0 -246
- package/dist/packem_shared/OpenRpcReferencePanel-vbcYbv3V.js +0 -191
- package/dist/packem_shared/PitrPanel-LJGNP_IX.js +0 -252
- package/dist/packem_shared/STUDIO_ROOT_CLASS-D12gX2dV.js +0 -3
- package/dist/packem_shared/ScheduledJobs-CabfKbyM.js +0 -159
- package/dist/packem_shared/SchemaViewer-Bam6ylvw.js +0 -2512
- package/dist/packem_shared/SecurityAdvisorPanel-DHr_bI38.js +0 -79
- package/dist/packem_shared/SettingsPanel-CBXQpYQA.js +0 -176
- package/dist/packem_shared/ShardInput-gx_DZXXn.js +0 -107
- package/dist/packem_shared/SqlEditorPanel-D5wMIxcg.js +0 -13
- package/dist/packem_shared/Studio-DkgODWD3.js +0 -33
- package/dist/packem_shared/StudioApp-ColQCvC_.js +0 -657
- package/dist/packem_shared/StudioI18nProvider-B-tDCZIi.js +0 -48
- package/dist/packem_shared/TableEditor-B8K5nUna.js +0 -371
- package/dist/packem_shared/advisor-view-CGcfMiPq.js +0 -159
- package/dist/packem_shared/aggregateMetrics-D4nUHEKU.js +0 -108
- package/dist/packem_shared/app.d-Nbhpihxv.d.ts +0 -300
- package/dist/packem_shared/badge-B2PKA1-5.js +0 -49
- package/dist/packem_shared/bar-chart-CzJAgqkp.js +0 -3245
- package/dist/packem_shared/button-BhsN2uZH.js +0 -49
- package/dist/packem_shared/card-DURq3ElK.js +0 -175
- package/dist/packem_shared/cf-links-2cktDedA.js +0 -8
- package/dist/packem_shared/checkbox-UNkzAxl-.js +0 -63
- package/dist/packem_shared/data-grid-B5CaV3wS.js +0 -183
- package/dist/packem_shared/dropdown-menu-WY4B_eJO.js +0 -280
- package/dist/packem_shared/empty-state-DY_oe0k6.js +0 -98
- package/dist/packem_shared/grid-features-CzUfqgsM.js +0 -840
- package/dist/packem_shared/input-XH4r1Pt1.js +0 -53
- package/dist/packem_shared/internal-rXJEAhXS.js +0 -68
- package/dist/packem_shared/label-D8ykjn5J.js +0 -46
- package/dist/packem_shared/live-status-FZ0psC1z.js +0 -44
- package/dist/packem_shared/reference-view-B4E49Lip.js +0 -2180
- package/dist/packem_shared/shard-history-DyebH1R5.js +0 -38
- package/dist/packem_shared/sparkline-10dG-_f0.js +0 -93
- package/dist/packem_shared/sql-editor-panel-Smfl_FDF.js +0 -2562
- package/dist/packem_shared/storage-tier-CL98eOvn.js +0 -85
- package/dist/packem_shared/studio-Be28OqIx.js +0 -10413
- package/dist/packem_shared/table-_RzNvy3R.js +0 -246
- package/dist/packem_shared/table-list-sidebar-Bg7uzbvC.js +0 -832
- package/dist/packem_shared/textarea-D3gaCU_-.js +0 -46
- package/dist/packem_shared/use-live-admin-Dq6g3daN.js +0 -73
- package/dist/packem_shared/use-live-shard-seed-Cuk3dnH0.js +0 -76
- package/dist/packem_shared/useDebounced-Dxncpg6z.js +0 -32
- package/dist/packem_shared/utils-B05Dmz_H.js +0 -8
- package/dist/packem_shared/virtual-rect-CVMUskSm.js +0 -10
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as Xe}from"react/compiler-runtime";import{useLunora as It}from"@lunora/react";import{useState as g,useEffect as it,useRef as $t}from"react";import{ShardInput as zt}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as gt,d as dt}from"../packem_shared/storage-tier-DznqOf-q.js";import{g as nt}from"../packem_shared/badge-BbuuAio7.js";import{f as ct,m as mt,n as ut,u as ht,c as pt}from"../packem_shared/card-CIDGUN6K.js";import{E as At}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as We}from"../packem_shared/input-JHu63lTv.js";import Ot from"../packem_shared/useDebounced-Ihdiid_k.js";import{useT as wt}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as st}from"../packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js";import{f as Z,d as lt,b as at,g as rt}from"../packem_shared/internal-BSIsQVC6.js";import{r as jt}from"../packem_shared/shard-history-DMEW5VBE.js";import{c as kt}from"../packem_shared/utils-bhneXptQ.js";import{S as Ft}from"../packem_shared/schema-diagram-cg-bz_VL.js";import{useNavigate as qt}from"@tanstack/react-router";import{u as X}from"../packem_shared/button-BkCrNcAs.js";import{p as ze}from"../packem_shared/label-6uP1obNF.js";import{jsx as l,jsxs as c}from"react/jsx-runtime";const Et="/__lunora/schema-edit",Pt=async s=>{const e=await fetch(Et,{body:JSON.stringify(s),headers:{"Content-Type":"application/json","X-Lunora-Studio":"1"},method:"POST"}),u=await e.json();return u.needsMigration===!0?{kind:"needs-migration",message:u.message??"This edit needs a migration."}:e.ok&&u.tables!==void 0?{diagnostics:u.diagnostics??[],kind:"ok",tables:u.tables}:{kind:"error",message:u.error??`schema edit failed (${String(e.status)})`}},Lt=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.int64()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],Gt="v.string()",Dt=s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),Mt=s=>{const e=Xe(116),{onApplied:u,tableNames:o}=s,t=wt(),r=qt(),[n,m]=g(null),[p,i]=g(!1),[y,f]=g(null),[w,d]=g(""),[C,G]=g(""),[Q,Le]=g(Gt),[N,Ye]=g(o[0]??""),[q,Ge]=g(""),[W,ce]=g(""),[Y,Ae]=g(!1);let ee;e[0]===Symbol.for("react.memo_cache_sentinel")?(ee=()=>{m(null),d(""),G(""),Ge(""),ce(""),Ae(!1)},e[0]=ee):ee=e[0];const Oe=ee;let me;e[1]!==u?(me=async v=>{i(!0),f(null);try{const P=await Pt(v);f(P),P.kind==="ok"&&(u(P.tables),Oe())}catch(P){const ie=P;f({kind:"error",message:ie instanceof Error?ie.message:String(ie)})}i(!1)},e[1]=u,e[2]=me):me=e[2];const S=me;let je;e[3]!==S||e[4]!==w?(je=()=>{Z(S({kind:"addTable",table:w.trim()}))},e[3]=S,e[4]=w,e[5]=je):je=e[5];const x=je;let Fe;e[6]!==C||e[7]!==S||e[8]!==N||e[9]!==Q?(Fe=()=>{Z(S({column:C.trim(),kind:"addOptionalColumn",table:N,validator:Q}))},e[6]=C,e[7]=S,e[8]=N,e[9]=Q,e[10]=Fe):Fe=e[10];const k=Fe;let ke;e[11]!==W||e[12]!==q||e[13]!==S||e[14]!==N||e[15]!==Y?(ke=()=>{Z(S({fields:Dt(W),kind:"addIndex",name:q.trim(),table:N,unique:Y}))},e[11]=W,e[12]=q,e[13]=S,e[14]=N,e[15]=Y,e[16]=ke):ke=e[16];const Ce=ke;let D;e[17]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{f(null),m("addTable")},e[17]=D):D=e[17];const ot=D;let M;e[18]===Symbol.for("react.memo_cache_sentinel")?(M=()=>{f(null),m("addColumn")},e[18]=M):M=e[18];const et=M;let ue;e[19]===Symbol.for("react.memo_cache_sentinel")?(ue=()=>{f(null),m("addIndex")},e[19]=ue):ue=e[19];const he=ue;let pe;e[20]!==t?(pe=()=>{m("destructive"),f({kind:"needs-migration",message:t("This edit changes stored data and must go through a migration. Review the migration before applying.")})},e[20]=t,e[21]=pe):pe=e[21];const _e=pe;let fe;e[22]===Symbol.for("react.memo_cache_sentinel")?(fe=v=>{d(v.target.value)},e[22]=fe):fe=e[22];const De=fe;let ge;e[23]===Symbol.for("react.memo_cache_sentinel")?(ge=v=>{G(v.target.value)},e[23]=ge):ge=e[23];const Me=ge;let be;e[24]===Symbol.for("react.memo_cache_sentinel")?(be=v=>{Le(v.target.value)},e[24]=be):be=e[24];const xe=be;let ve;e[25]===Symbol.for("react.memo_cache_sentinel")?(ve=v=>{Ye(v.target.value)},e[25]=ve):ve=e[25];const Re=ve;let qe;e[26]===Symbol.for("react.memo_cache_sentinel")?(qe=v=>{Ge(v.target.value)},e[26]=qe):qe=e[26];const Be=qe;let ye;e[27]===Symbol.for("react.memo_cache_sentinel")?(ye=v=>{ce(v.target.value)},e[27]=ye):ye=e[27];const Ue=ye;let Ne;e[28]===Symbol.for("react.memo_cache_sentinel")?(Ne=v=>{Ae(v.target.checked)},e[28]=Ne):Ne=e[28];const Ve=Ne;let we;e[29]!==r?(we=()=>{Z(r({to:"/migrations"}))},e[29]=r,e[30]=we):we=e[30];const E=we;let R;e[31]!==t?(R=t("Edit schema"),e[31]=t,e[32]=R):R=e[32];let te;e[33]!==R?(te=l(ct,{children:R}),e[33]=R,e[34]=te):te=e[34];let B;e[35]!==t?(B=t("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=t,e[36]=B):B=e[36];let T;e[37]!==B?(T=l(mt,{children:B}),e[37]=B,e[38]=T):T=e[38];let U;e[39]!==te||e[40]!==T?(U=c(ut,{children:[te,T]}),e[39]=te,e[40]=T,e[41]=U):U=e[41];const le=n==="addTable"?"default":"outline";let V;e[42]!==t?(V=t("Add table"),e[42]=t,e[43]=V):V=e[43];let Se;e[44]!==le||e[45]!==V?(Se=l(X,{"data-testid":"sc-editor-add-table",onClick:ot,size:"xs",type:"button",variant:le,children:V}),e[44]=le,e[45]=V,e[46]=Se):Se=e[46];const Te=o.length===0,Ze=n==="addColumn"?"default":"outline";let K;e[47]!==t?(K=t("Add column"),e[47]=t,e[48]=K):K=e[48];let Ie;e[49]!==Te||e[50]!==Ze||e[51]!==K?(Ie=l(X,{"data-testid":"sc-editor-add-column",disabled:Te,onClick:et,size:"xs",type:"button",variant:Ze,children:K}),e[49]=Te,e[50]=Ze,e[51]=K,e[52]=Ie):Ie=e[52];const $e=o.length===0,Ee=n==="addIndex"?"default":"outline";let I;e[53]!==t?(I=t("Add index"),e[53]=t,e[54]=I):I=e[54];let H;e[55]!==$e||e[56]!==Ee||e[57]!==I?(H=l(X,{"data-testid":"sc-editor-add-index",disabled:$e,onClick:he,size:"xs",type:"button",variant:Ee,children:I}),e[55]=$e,e[56]=Ee,e[57]=I,e[58]=H):H=e[58];const Pe=o.length===0,ae=n==="destructive"?"default":"ghost";let $;e[59]!==t?($=t("Rename / drop / change type…"),e[59]=t,e[60]=$):$=e[60];let ne;e[61]!==_e||e[62]!==Pe||e[63]!==ae||e[64]!==$?(ne=l(X,{"data-testid":"sc-editor-destructive",disabled:Pe,onClick:_e,size:"xs",type:"button",variant:ae,children:$}),e[61]=_e,e[62]=Pe,e[63]=ae,e[64]=$,e[65]=ne):ne=e[65];let se;e[66]!==Se||e[67]!==Ie||e[68]!==H||e[69]!==ne?(se=c("div",{className:"flex flex-wrap gap-2",children:[Se,Ie,H,ne]}),e[66]=Se,e[67]=Ie,e[68]=H,e[69]=ne,e[70]=se):se=e[70];let z;e[71]!==p||e[72]!==n||e[73]!==x||e[74]!==t||e[75]!==w?(z=n==="addTable"&&c("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[c("div",{className:"flex flex-col gap-1 text-xs",children:[l(ze,{htmlFor:"sc-editor-table-name",children:t("Table name")}),l(We,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:De,value:w})]}),l(X,{"data-testid":"sc-editor-table-apply",disabled:p||w.trim()==="",onClick:x,size:"xs",type:"button",children:t(p?"Applying…":"Apply")}),l(X,{onClick:Oe,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[71]=p,e[72]=n,e[73]=x,e[74]=t,e[75]=w,e[76]=z):z=e[76];let A;e[77]!==p||e[78]!==C||e[79]!==n||e[80]!==k||e[81]!==t||e[82]!==o||e[83]!==N||e[84]!==Q?(A=n==="addColumn"&&c("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[c("div",{className:"flex flex-col gap-1 text-xs",children:[l(ze,{htmlFor:"sc-editor-column-table",children:t("Table name")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-table",id:"sc-editor-column-table",onChange:Re,value:N,children:o.map(Rt)})]}),c("div",{className:"flex flex-col gap-1 text-xs",children:[l(ze,{htmlFor:"sc-editor-column-name",children:t("Column name")}),l(We,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:Me,value:C})]}),c("div",{className:"flex flex-col gap-1 text-xs",children:[l(ze,{htmlFor:"sc-editor-column-type",children:t("Column type")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-type",id:"sc-editor-column-type",onChange:xe,value:Q,children:Lt.map(Bt)})]}),l("span",{className:"text-[11px] text-muted-foreground",children:t("Optional")}),l(X,{"data-testid":"sc-editor-column-apply",disabled:p||C.trim()===""||N==="",onClick:k,size:"xs",type:"button",children:t(p?"Applying…":"Apply")}),l(X,{onClick:Oe,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[77]=p,e[78]=C,e[79]=n,e[80]=k,e[81]=t,e[82]=o,e[83]=N,e[84]=Q,e[85]=A):A=e[85];let O;e[86]!==p||e[87]!==W||e[88]!==q||e[89]!==n||e[90]!==Ce||e[91]!==t||e[92]!==o||e[93]!==N||e[94]!==Y?(O=n==="addIndex"&&c("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[c("div",{className:"flex flex-col gap-1 text-xs",children:[l(ze,{htmlFor:"sc-editor-index-table",children:t("Table name")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-index-table",id:"sc-editor-index-table",onChange:Re,value:N,children:o.map(Ut)})]}),c("div",{className:"flex flex-col gap-1 text-xs",children:[l(ze,{htmlFor:"sc-editor-index-name",children:t("Index name")}),l(We,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:Be,value:q})]}),c("div",{className:"flex flex-col gap-1 text-xs",children:[l(ze,{htmlFor:"sc-editor-index-fields",children:t("Index fields (comma-separated)")}),l(We,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:Ue,value:W})]}),c(ze,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[l("input",{checked:Y,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:Ve,type:"checkbox"}),l("span",{className:"text-muted-foreground",children:t("Unique")})]}),l(X,{"data-testid":"sc-editor-index-apply",disabled:p||q.trim()===""||W.trim()==="",onClick:Ce,size:"xs",type:"button",children:t(p?"Applying…":"Apply")}),l(X,{onClick:Oe,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[86]=p,e[87]=W,e[88]=q,e[89]=n,e[90]=Ce,e[91]=t,e[92]=o,e[93]=N,e[94]=Y,e[95]=O):O=e[95];let re;e[96]!==y?(re=y?.kind==="error"&&l("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:y.message}),e[96]=y,e[97]=re):re=e[97];let oe;e[98]!==E||e[99]!==y?.kind||e[100]!==t?(oe=y?.kind==="needs-migration"&&c("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[l("p",{className:"text-sm text-warning",role:"alert",children:t("This edit changes stored data and must go through a migration. Review the migration before applying.")}),l(X,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:E,size:"xs",type:"button",variant:"outline",children:t("Open Migrations")})]}),e[98]=E,e[99]=y?.kind,e[100]=t,e[101]=oe):oe=e[101];let j;e[102]!==y||e[103]!==t?(j=y?.kind==="ok"&&y.diagnostics.length>0&&c("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[l("p",{className:"text-sm text-destructive",role:"alert",children:t("Codegen reported diagnostics:")}),l("ul",{className:"flex flex-col gap-0.5",children:y.diagnostics.map(Vt)})]}),e[102]=y,e[103]=t,e[104]=j):j=e[104];let F;e[105]!==se||e[106]!==z||e[107]!==A||e[108]!==O||e[109]!==re||e[110]!==oe||e[111]!==j?(F=c(ht,{children:[se,z,A,O,re,oe,j]}),e[105]=se,e[106]=z,e[107]=A,e[108]=O,e[109]=re,e[110]=oe,e[111]=j,e[112]=F):F=e[112];let J;return e[113]!==U||e[114]!==F?(J=c(pt,{"data-testid":"sc-editor",size:"sm",children:[U,F]}),e[113]=U,e[114]=F,e[115]=J):J=e[115],J};function Rt(s){return l("option",{value:s,children:s},s)}function Bt(s){return l("option",{value:s.validator,children:s.label},s.validator)}function Ut(s){return l("option",{value:s,children:s},s)}function Vt(s){return l("li",{className:"font-mono text-[11px] text-destructive",children:s},s)}const Kt=rt(st.listTables),Ht=rt(st.listTableIndexes),Jt=rt(st.readTablePage),Xt=rt(st.describeTables),Zt={},bt=[],xt=[],Qt=s=>{const e=Xe(5),{open:u}=s,o=u&&"rotate-90";let t;e[0]!==o?(t=kt("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",o),e[0]=o,e[1]=t):t=e[1];let r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=l("path",{d:"m9 6 6 6-6 6"}),e[2]=r):r=e[2];let n;return e[3]!==t?(n=l("svg",{"aria-hidden":"true",className:t,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:r}),e[3]=t,e[4]=n):n=e[4],n},vt=s=>{const e=Xe(20),{children:u,expanded:o,name:t,onToggle:r,rowCount:n,rowTestId:m,toggleTestId:p}=s;let i;e[0]!==o?(i=l(Qt,{open:o}),e[0]=o,e[1]=i):i=e[1];let y;e[2]!==t?(y=l("span",{className:"truncate font-mono text-xs text-foreground",title:t,children:t}),e[2]=t,e[3]=y):y=e[3];let f;e[4]!==n?(f=c("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",n,")"]}),e[4]=n,e[5]=f):f=e[5];let w;e[6]!==o||e[7]!==r||e[8]!==i||e[9]!==y||e[10]!==f||e[11]!==p?(w=c("button",{"aria-expanded":o,className:"flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40","data-testid":p,onClick:r,type:"button",children:[i,y," ",f]}),e[6]=o,e[7]=r,e[8]=i,e[9]=y,e[10]=f,e[11]=p,e[12]=w):w=e[12];let d;e[13]!==u||e[14]!==o?(d=o&&l("div",{className:"px-3 pb-3 ps-8",children:u}),e[13]=u,e[14]=o,e[15]=d):d=e[15];let C;return e[16]!==m||e[17]!==w||e[18]!==d?(C=c("li",{className:"border-t border-border/60 first:border-t-0","data-testid":m,children:[w,d]}),e[16]=m,e[17]=w,e[18]=d,e[19]=C):C=e[19],C},yt=s=>{const e=Xe(5),{columns:u,testId:o}=s;let t;e[0]!==u?(t=u.map(Yt),e[0]=u,e[1]=t):t=e[1];let r;return e[2]!==t||e[3]!==o?(r=l("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":o,children:t}),e[2]=t,e[3]=o,e[4]=r):r=e[4],r},Wt=s=>{const e=Xe(10),{heading:u,indexes:o,testId:t}=s;let r;e[0]!==u?(r=l("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:u}),e[0]=u,e[1]=r):r=e[1];let n;e[2]!==o?(n=o.map(el),e[2]=o,e[3]=n):n=e[3];let m;e[4]!==n||e[5]!==t?(m=l("ul",{className:"flex flex-col gap-1","data-testid":t,children:n}),e[4]=n,e[5]=t,e[6]=m):m=e[6];let p;return e[7]!==r||e[8]!==m?(p=c("div",{className:"pt-3",children:[r,m]}),e[7]=r,e[8]=m,e[9]=p):p=e[9],p},Nt=s=>kt("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",s?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),_l=s=>{const e=Xe(130),{initialShardKey:u,initialTable:o,schemaEditable:t}=s,r=It(),n=wt(),[m,p]=g("graph"),[i,y]=g(u??""),[f,w]=g(""),[d,C]=g(null),[G,Q]=g(null);let Le;e[0]===Symbol.for("react.memo_cache_sentinel")?(Le={},e[0]=Le):Le=e[0];const[N,Ye]=g(Le);let q;e[1]===Symbol.for("react.memo_cache_sentinel")?(q={},e[1]=q):q=e[1];const[Ge,W]=g(q),[ce,Y]=g(null);let Ae;e[2]===Symbol.for("react.memo_cache_sentinel")?(Ae={},e[2]=Ae):Ae=e[2];const[ee,Oe]=g(Ae);let me;e[3]===Symbol.for("react.memo_cache_sentinel")?(me={},e[3]=me):me=e[3];const[S,je]=g(me),[x,Fe]=g(null),[k,ke]=g(null);let Ce;e[4]===Symbol.for("react.memo_cache_sentinel")?(Ce={},e[4]=Ce):Ce=e[4];const[D,ot]=g(Ce),[M,et]=g(null);let ue;e[5]!==r?(ue=async a=>{Q(null);try{const h=await r.query(Kt,{},lt(a));jt(a),C(h),Ye({}),W({}),Y(null),Oe(b=>Object.fromEntries(Object.entries(b).filter(L=>{const[_]=L;return _!==a}))),je(b=>Object.fromEntries(Object.entries(b).filter(L=>{const[_]=L;return _!==a})))}catch(h){const b=h;C(null),Q(at(b))}},e[5]=r,e[6]=ue):ue=e[6];const he=ue;let pe;e[7]!==r?(pe=async()=>{ke(null);try{Fe(await r.listGlobalTables())}catch(a){const h=a;Fe(null),ke(at(h))}},e[7]=r,e[8]=pe):pe=e[8];const _e=pe;let fe;e[9]!==i?(fe=i.trim(),e[9]=i,e[10]=fe):fe=e[10];const De=Ot(fe,400);let ge,Me;e[11]!==De||e[12]!==he||e[13]!==_e?(Me=()=>{Z(he(De)),Z(_e())},ge=[he,_e,De],e[11]=De,e[12]=he,e[13]=_e,e[14]=ge,e[15]=Me):(ge=e[14],Me=e[15]),it(Me,ge);let be;e[16]!==r||e[17]!==N||e[18]!==ce||e[19]!==i?(be=async a=>{if(ce===a){Y(null);return}Y(a);const h=`${i}:${a}`;if(N[h]!==void 0)return;const[b,L]=await Promise.allSettled([r.query(Jt,{limit:1,offset:0,table:a},lt(i)),r.query(Ht,{table:a},lt(i))]);b.status==="fulfilled"?Ye(_=>({..._,[h]:b.value.columns})):Q(at(b.reason)),L.status==="fulfilled"&&W(_=>({..._,[h]:L.value.indexes}))},e[16]=r,e[17]=N,e[18]=ce,e[19]=i,e[20]=be):be=e[20];const xe=be;let ve;e[21]!==r||e[22]!==D||e[23]!==M?(ve=async a=>{if(M===a){et(null);return}if(et(a),D[a]===void 0)try{const h=await r.readGlobalTablePage({limit:1,offset:0,table:a});ot(b=>({...b,[a]:h.columns}))}catch(h){ke(at(h))}},e[21]=r,e[22]=D,e[23]=M,e[24]=ve):ve=e[24];const Re=ve,qe=$t(void 0);let Be,ye;e[25]!==o||e[26]!==d||e[27]!==xe?(Be=()=>{o===void 0||d===null||qe.current===o||d.some(a=>a.name===o)&&(qe.current=o,Z(xe(o)))},ye=[o,d,xe],e[25]=o,e[26]=d,e[27]=xe,e[28]=Be,e[29]=ye):(Be=e[28],ye=e[29]),it(Be,ye);let Ue;e[30]!==r?(Ue=async(a,h,b)=>{const[L,_]=await Promise.all([Promise.allSettled([r.query(Xt,{tables:[...h,...b]},lt(a))]),Promise.all(b.map(async de=>{const Qe=await Promise.allSettled([r.readGlobalTablePage({limit:1,offset:0,table:de})]),ft=Qe[0].status==="fulfilled"?Qe[0].value:void 0;return{columns:ft?.columns??[],refs:ft?.refs??{},table:de}}))]),Ct=L[0].status==="fulfilled"?L[0].value?.columnsByTable??{}:{},_t=L[0].status==="rejected",St=new Map(_.map(tl)),Tt=[...h,...b].map(de=>{const Qe=Ct[de]??[];return[de,Qe.length>0?Qe:St.get(de)??[]]});Oe(de=>({...de,[a]:Object.fromEntries(Tt)})),je(de=>({...de,[a]:_t}))},e[30]=r,e[31]=Ue):Ue=e[31];const Ne=Ue;let Ve,we;e[32]!==k||e[33]!==x||e[34]!==Ne||e[35]!==ee||e[36]!==i||e[37]!==d||e[38]!==m?(Ve=()=>{m!=="graph"||d===null||x===null&&k===null||ee[i]!==void 0||Z(Ne(i,d.map(ll),(x??[]).map(al)))},we=[m,d,x,k,i,ee,Ne],e[32]=k,e[33]=x,e[34]=Ne,e[35]=ee,e[36]=i,e[37]=d,e[38]=m,e[39]=Ve,e[40]=we):(Ve=e[39],we=e[40]),it(Ve,we);const E=ee[i]??Zt;let R;if(e[41]!==E||e[42]!==x||e[43]!==d){let a;e[45]!==E?(a=_=>({columns:E[_.name]??xt,name:_.name,tier:"shard"}),e[45]=E,e[46]=a):a=e[46];const h=(d??[]).map(a);let b;e[47]!==E?(b=_=>({columns:E[_.name]??xt,name:_.name,tier:"global"}),e[47]=E,e[48]=b):b=e[48];const L=(x??[]).map(b);R=[...h,...L],e[41]=E,e[42]=x,e[43]=d,e[44]=R}else R=e[44];const te=R;let B;if(e[49]!==f||e[50]!==d){const a=f.trim().toLowerCase();B=(d??[]).filter(h=>h.name.toLowerCase().includes(a)),e[49]=f,e[50]=d,e[51]=B}else B=e[51];const T=B;let U;if(e[52]!==x||e[53]!==f){const a=f.trim().toLowerCase();U=(x??[]).filter(h=>h.name.toLowerCase().includes(a)),e[52]=x,e[53]=f,e[54]=U}else U=e[54];const le=U;let V;e[55]===Symbol.for("react.memo_cache_sentinel")?(V=()=>{p("list")},e[55]=V):V=e[55];const Se=V;let Te;e[56]===Symbol.for("react.memo_cache_sentinel")?(Te=()=>{p("graph")},e[56]=Te):Te=e[56];const Ze=Te;let K;e[57]===Symbol.for("react.memo_cache_sentinel")?(K=a=>{w(a.target.value)},e[57]=K):K=e[57];const Ie=K;let $e;e[58]!==he||e[59]!==i?($e=a=>{Z(he(i))},e[58]=he,e[59]=i,e[60]=$e):$e=e[60];const Ee=$e;let I;e[61]!==d?(I=d??[],e[61]=d,e[62]=I):I=e[62];let H;e[63]!==I?(H=I.map(nl),e[63]=I,e[64]=H):H=e[64];const Pe=H;let ae;e[65]!==i?(ae=l(zt,{onChange:y,testId:"sc-shard-input",value:i}),e[65]=i,e[66]=ae):ae=e[66];let $;e[67]!==n?($=n("Schema view"),e[67]=n,e[68]=$):$=e[68];const ne=m==="graph",se=m==="graph";let z;e[69]!==se?(z=Nt(se),e[69]=se,e[70]=z):z=e[70];let A;e[71]!==n?(A=n("Graph"),e[71]=n,e[72]=A):A=e[72];let O;e[73]!==ne||e[74]!==z||e[75]!==A?(O=l("button",{"aria-selected":ne,className:z,"data-testid":"sc-view-graph",onClick:Ze,role:"tab",type:"button",children:A}),e[73]=ne,e[74]=z,e[75]=A,e[76]=O):O=e[76];const re=m==="list",oe=m==="list";let j;e[77]!==oe?(j=Nt(oe),e[77]=oe,e[78]=j):j=e[78];let F;e[79]!==n?(F=n("Table list"),e[79]=n,e[80]=F):F=e[80];let J;e[81]!==re||e[82]!==j||e[83]!==F?(J=l("button",{"aria-selected":re,className:j,"data-testid":"sc-view-list",onClick:Se,role:"tab",type:"button",children:F}),e[81]=re,e[82]=j,e[83]=F,e[84]=J):J=e[84];let v;e[85]!==$||e[86]!==O||e[87]!==J?(v=c("div",{"aria-label":$,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[O,J]}),e[85]=$,e[86]=O,e[87]=J,e[88]=v):v=e[88];let P;e[89]!==ae||e[90]!==v?(P=c("div",{className:"flex flex-wrap items-center gap-3",children:[ae,v]}),e[89]=ae,e[90]=v,e[91]=P):P=e[91];let ie;e[92]!==Ee||e[93]!==t||e[94]!==Pe?(ie=t===!0&&l(Mt,{onApplied:Ee,tableNames:Pe}),e[92]=Ee,e[93]=t,e[94]=Pe,e[95]=ie):ie=e[95];let Ke;e[96]!==n||e[97]!==f||e[98]!==m?(Ke=m==="list"&&l(We,{"aria-label":n("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:Ie,placeholder:n("Filter tables"),value:f}),e[96]=n,e[97]=f,e[98]=m,e[99]=Ke):Ke=e[99];let He;e[100]!==te||e[101]!==G||e[102]!==k||e[103]!==S||e[104]!==i||e[105]!==m?(He=m==="graph"&&c("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[G!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:G}),k!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:k}),l(Ft,{columnsError:S[i]===!0,tables:te,testIdPrefix:"sc-graph"})]}),e[100]=te,e[101]=G,e[102]=k,e[103]=S,e[104]=i,e[105]=m,e[106]=He):He=e[106];let Je;e[107]!==N||e[108]!==G||e[109]!==ce||e[110]!==le||e[111]!==T||e[112]!==D||e[113]!==k||e[114]!==M||e[115]!==x||e[116]!==Ge||e[117]!==i||e[118]!==n||e[119]!==d||e[120]!==xe||e[121]!==Re||e[122]!==m?(Je=m==="list"&&c("div",{className:"flex flex-col gap-4",children:[c(pt,{"data-testid":"sc-shard-section",size:"sm",children:[c(ut,{children:[c("div",{className:"flex items-center gap-2",children:[l(gt,{tier:"shard"}),l(ct,{children:n("Shard tables")}),d!==null&&l(nt,{className:"ms-auto tabular-nums",variant:"outline",children:T.length})]}),l(mt,{children:dt.shard.hint})]}),c(ht,{children:[G!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:G}),d!==null&&d.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:n("No tables in this shard.")}),d!==null&&d.length>0&&T.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:n("No tables match your filter.")}),T.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:T.map(a=>{const h=`${i}:${a.name}`,b=Ge[h]??[];return c(vt,{expanded:ce===a.name,name:a.name,onToggle:()=>{Z(xe(a.name))},rowCount:a.rowCount,rowTestId:`sc-table-${a.name}`,toggleTestId:`sc-toggle-${a.name}`,children:[l(yt,{columns:N[h]??bt,testId:`sc-columns-${a.name}`}),b.length>0&&l(Wt,{heading:n("Indexes"),indexes:b,testId:`sc-indexes-${a.name}`})]},a.name)})})]})]}),c(pt,{"data-testid":"sc-global-section",size:"sm",children:[c(ut,{children:[c("div",{className:"flex items-center gap-2",children:[l(gt,{tier:"global"}),l(ct,{children:n("Global tables (D1)")}),x!==null&&l(nt,{className:"ms-auto tabular-nums",variant:"outline",children:le.length})]}),l(mt,{children:dt.global.hint})]}),c(ht,{children:[k!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:k}),x!==null&&x.length===0&&l(At,{description:dt.global.hint,testId:"sc-global-empty",title:n("No global tables.")}),x!==null&&x.length>0&&le.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:n("No tables match your filter.")}),le.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:le.map(a=>l(vt,{expanded:M===a.name,name:a.name,onToggle:()=>{Z(Re(a.name))},rowCount:a.rowCount,rowTestId:`sc-global-table-${a.name}`,toggleTestId:`sc-global-toggle-${a.name}`,children:l(yt,{columns:D[a.name]??bt,testId:`sc-global-columns-${a.name}`})},a.name))})]})]})]}),e[107]=N,e[108]=G,e[109]=ce,e[110]=le,e[111]=T,e[112]=D,e[113]=k,e[114]=M,e[115]=x,e[116]=Ge,e[117]=i,e[118]=n,e[119]=d,e[120]=xe,e[121]=Re,e[122]=m,e[123]=Je):Je=e[123];let tt;return e[124]!==P||e[125]!==ie||e[126]!==Ke||e[127]!==He||e[128]!==Je?(tt=c("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[P,ie,Ke,He,Je]}),e[124]=P,e[125]=ie,e[126]=Ke,e[127]=He,e[128]=Je,e[129]=tt):tt=e[129],tt};function Yt(s){return l("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:s},s)}function el(s){return c("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[l("span",{className:"font-mono",children:s.name}),l(nt,{variant:"outline",children:s.type}),s.unique===!0&&l(nt,{variant:"secondary",children:"unique"}),l("span",{className:"text-muted-foreground",children:s.fields.join(", ")})]},`${s.type}:${s.name}`)}function tl(s){const{columns:e,refs:u,table:o}=s;return[o,e.map(t=>{const r=u[t];return r===void 0?{name:t,optional:!1,type:""}:{name:t,optional:!1,ref:r,type:"id"}})]}function ll(s){return s.name}function al(s){return s.name}function nl(s){return s.name}export{_l as SchemaViewer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as u}from"react/compiler-runtime";import{N as m}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as h}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as f}from"../packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js";import{A as g}from"../packem_shared/advisor-view-Pa8HLtBv.js";import{jsx as p}from"react/jsx-runtime";const R=(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],k=e=>Array.isArray(e.findings)?e.findings:[],S=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],A=(e,s)=>({"admin-token-weak":e("Your admin token is {length} characters — 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 — 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 — 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],N=()=>{const e=u(8),s=h();let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={},e[0]=t):t=e[0];const{data:i,error:n,errorSource:d}=m(f.getSecurityAudit,t);let a;if(e[1]!==i||e[2]!==s){const l=i===void 0?null:k(i);a=l===null?null:l.map(r=>({description:A(s,r),entity:S(r),issueType:R(s,r),key:r.kind,level:r.level})),e[1]=i,e[2]=s,e[3]=a}else a=e[3];const c=a;let o;return e[4]!==n||e[5]!==d||e[6]!==c?(o=p(g,{error:n,errorSource:d,rows:c,testId:"lunora-security-advisor"}),e[4]=n,e[5]=d,e[6]=c,e[7]=o):o=e[7],o};export{N as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as O}from"react/compiler-runtime";import{E as A}from"../packem_shared/error-alert-t6cpEi0z.js";import{g as K}from"../packem_shared/badge-BbuuAio7.js";import{c as I,u as L}from"../packem_shared/card-CIDGUN6K.js";import{n as j,d as F,m as C,p as T,f as V,u as U}from"../packem_shared/table-DdJBrClo.js";import{N as W}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as q}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as z}from"../packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js";import{a as M}from"../packem_shared/cf-links-gbDy51nR.js";import{jsx as t,jsxs as m}from"react/jsx-runtime";const P={binding:"outline",secret:"destructive",var:"secondary"},B=(r,e)=>{if(r===void 0)return[];const c=[];return r.workerUrl!==void 0&&c.push({label:e("URL"),value:r.workerUrl}),r.environment!==void 0&&c.push({label:e("Environment"),value:r.environment}),r.deploymentId!==void 0&&c.push({label:e("Deployment"),value:r.deploymentId}),r.versionTag!==void 0&&c.push({label:e("Version"),value:r.versionTag}),c},le=r=>{const e=O(52),{initialShardKey:c}=r,n=q();let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={},e[0]=w):w=e[0];const _=c??"";let $;e[1]!==_?($={shardKey:_},e[1]=_,e[2]=$):$=e[2];const{data:l,error:s,errorSource:k,isLoading:R}=W(z.getSettings,w,$);let a,p,u,d,o,i,h;if(e[3]!==s||e[4]!==k||e[5]!==l?.deploy||e[6]!==l?.settings||e[7]!==n){const D=B(l?.deploy,n);let S;e[15]!==l?.settings?(S=l?.settings??[],e[15]=l?.settings,e[16]=S):S=e[16],a=S,p="flex flex-col gap-4",u="lunora-settings";let N;e[17]!==n?(N=n("Open in Cloudflare"),e[17]=n,e[18]=N):N=e[18],e[19]!==N?(d=t("div",{className:"flex flex-wrap items-center gap-3",children:t("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:M,rel:"noreferrer",target:"_blank",children:N})}),e[19]=N,e[20]=d):d=e[20];let b;e[21]!==n?(b=n("View-only — values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=n,e[22]=b):b=e[22],e[23]!==b?(o=t("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:b}),e[23]=b,e[24]=o):o=e[24],e[25]!==s||e[26]!==k?(i=s!==null&&t(A,{error:k,testId:"set-error"}),e[25]=s,e[26]=k,e[27]=i):i=e[27],h=D.length>0&&m(I,{className:"py-0","data-testid":"set-deploy",children:[t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Deployment")})}),t(L,{className:"py-3",children:t("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:D.map(G)})})]}),e[3]=s,e[4]=k,e[5]=l?.deploy,e[6]=l?.settings,e[7]=n,e[8]=a,e[9]=p,e[10]=u,e[11]=d,e[12]=o,e[13]=i,e[14]=h}else a=e[8],p=e[9],u=e[10],d=e[11],o=e[12],i=e[13],h=e[14];let f;e[28]!==n?(f=n("Environment & bindings"),e[28]=n,e[29]=f):f=e[29];let g;e[30]!==f?(g=t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:f})}),e[30]=f,e[31]=g):g=e[31];let x;e[32]!==s||e[33]!==R||e[34]!==a.length||e[35]!==n?(x=s===null&&!R&&a.length===0&&t("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:n("No environment variables or bindings.")}),e[32]=s,e[33]=R,e[34]=a.length,e[35]=n,e[36]=x):x=e[36];let v;e[37]!==a||e[38]!==n?(v=a.length>0&&t(L,{className:"px-0 py-0",children:m(j,{"data-testid":"set-table",children:[t(F,{children:m(C,{children:[t(T,{children:n("name")}),t(T,{children:n("kind")}),t(T,{children:n("value")})]})}),t(V,{children:a.map(H)})]})}),e[37]=a,e[38]=n,e[39]=v):v=e[39];let y;e[40]!==g||e[41]!==x||e[42]!==v?(y=m(I,{className:"py-0",children:[g,x,v]}),e[40]=g,e[41]=x,e[42]=v,e[43]=y):y=e[43];let E;return e[44]!==y||e[45]!==p||e[46]!==u||e[47]!==d||e[48]!==o||e[49]!==i||e[50]!==h?(E=m("div",{className:p,"data-testid":u,children:[d,o,i,h,y]}),e[44]=y,e[45]=p,e[46]=u,e[47]=d,e[48]=o,e[49]=i,e[50]=h,e[51]=E):E=e[51],E};function G(r){return m("div",{className:"contents","data-testid":"set-deploy-row",children:[t("dt",{className:"text-muted-foreground",children:r.label}),t("dd",{className:"truncate font-mono text-xs",title:r.value,children:r.value})]},r.label)}function H(r){return m(C,{"data-testid":"set-row",children:[t(U,{className:"font-mono text-xs font-medium",children:r.name}),t(U,{children:t(K,{variant:P[r.kind],children:r.bindingType??r.kind})}),t(U,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:r.value??t("span",{className:"text-muted-foreground",children:"—"})})]},r.name)}export{le as SettingsPanel};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{c as J}from"react/compiler-runtime";import{useLunora as ul}from"@lunora/react";import{useState as Q,useMemo as fl,useCallback as Dl,useEffect as An,useRef as Dt,useId as Al}from"react";import{I as zl}from"../packem_shared/result-chart-DzJOVsaw.js";import{ShardInput as jl}from"../packem_shared/ShardInput-BVn2iCU0.js";import{A as Bl}from"../packem_shared/alert-CVcOFuDR.js";import{d as Wl,m as hl,f as Fl,n as Pl,p as Hl,u as Ul}from"../packem_shared/table-DdJBrClo.js";import{useT as se}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as zn}from"../packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js";import{u as cl,n as yl,b as wl}from"../packem_shared/browser-storage-xjTyMKY0.js";import{d as Mn,f as fe,g as jn,b as pl}from"../packem_shared/internal-BSIsQVC6.js";import{r as Yl}from"../packem_shared/shard-history-DMEW5VBE.js";import{g as Kl}from"../packem_shared/data-grid-DcxyIXwG.js";import{K as Ql}from"../packem_shared/grid-features-jnrD0SpX.js";import{k as Jl}from"../packem_shared/use-sql-assistant-CHEu2-Rk.js";import Gl from"../packem_shared/useDebounced-Ihdiid_k.js";import{u as Vl}from"../packem_shared/input-JHu63lTv.js";import{c as ve}from"../packem_shared/utils-bhneXptQ.js";import{jsx as i,jsxs as $,Fragment as bl}from"react/jsx-runtime";const Nl="p-3 font-mono text-xs leading-5 whitespace-pre-wrap break-words",Xl=(r,e)=>{const l=[];for(const t of r){if(t.offset===void 0||t.length===void 0||t.length<=0)continue;const o=Math.max(0,Math.min(t.offset,e)),a=Math.max(o,Math.min(t.offset+t.length,e));o!==a&&l.push({end:a,severity:t.severity,start:o})}l.sort((t,o)=>t.start-o.start);const n=[];for(const t of l)t.start>=(n.at(-1)?.end??0)&&n.push(t);return n},Zl=["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"],er=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],Dn=String.fromCodePoint(0),tr=new RegExp(`${Dn}${String.raw`(\d+)`}${Dn}`,"gu"),nr=Zl.map(r=>({pattern:new RegExp(String.raw`\b${r.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:r})),lr=er.map(r=>({pattern:new RegExp(String.raw`\s+${r.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
|
|
2
|
+
${r}`})),rr=r=>{const e=[];let l=r.replaceAll(/'(?:[^']|'')*'/gu,n=>(e.push(n),`${Dn}${(e.length-1).toString()}${Dn}`)).replaceAll(/\s+/gu," ").trim();for(const{pattern:n,replacement:t}of nr)l=l.replaceAll(n,t);for(const{pattern:n,replacement:t}of lr)l=l.replaceAll(n,t);return l=l.replaceAll(tr,(n,t)=>e[Number(t)]??""),l},or=/^(?:explain\s+(?:query\s+plan\s+)?)?(?:select|with)\b/iu,sr=/\b(?:alter|attach|create|delete|detach|drop|insert|pragma|reindex|replace|truncate|update|vacuum)\b/iu,ar=/^\w+/u,ir=/;\s*$/u,cr=/\s/u,dr=(r,e)=>{let l=e+2;for(;l<r.length&&r[l]!==`
|
|
3
|
+
`;)l+=1;return l},ur=(r,e)=>{const l=r.indexOf("*/",e+2);return l===-1?-1:l+2},mr=r=>{let e=0;for(;e<r.length;){const l=r[e];if(l!==void 0&&cr.test(l))e+=1;else if(l==="-"&&r[e+1]==="-")e=dr(r,e);else if(l==="/"&&r[e+1]==="*"){const n=ur(r,e);if(n===-1)break;e=n}else break}return e},fr=r=>{const e=mr(r),l=r.slice(e).trimEnd();if(l==="")return{code:"SQL_EMPTY",message:"the query is empty"};const n=l.replace(ir,""),t=n.indexOf(";");if(t!==-1)return{code:"SQL_MULTIPLE_STATEMENTS",length:1,message:"only a single statement may be run",offset:e+t};const o="the SQL editor is read-only — only SELECT / WITH / EXPLAIN queries are allowed";if(!or.test(n))return{code:"SQL_NOT_READONLY",length:ar.exec(n)?.[0].length??1,message:o,offset:e};const a=sr.exec(n);if(a!==null)return{code:"SQL_NOT_READONLY",length:a[0].length,message:`${o} (\`${a[0].toUpperCase()}\` is not allowed)`,offset:e+a.index}},hr=/\b(?:from|join)\s+([a-z_][\w$]*)(?:\s+(?:as\s+)?([a-z_][\w$]*))?/giu,pr=/(?:\bwith\s+(?:recursive\s+)?|,\s*)([a-z_][\w$]*)\s+as\s*\(/giu,br=new Set(["cross","full","group","having","inner","join","left","limit","offset","on","order","right","union","using","where","window"]),gr=/[^\n]/gu,xr=(r,e)=>{const l=r[e];if(l==="'"){let n=e+1;for(;n<r.length&&r[n]!=="'";)n+=1;return Math.min(n+1,r.length)}if(l==="-"&&r[e+1]==="-"){const n=r.indexOf(`
|
|
4
|
+
`,e);return n===-1?r.length:n}if(l==="/"&&r[e+1]==="*"){const n=r.indexOf("*/",e+2);return n===-1?r.length:n+2}return-1},vr=r=>{let e="",l=0;for(;l<r.length;){const n=xr(r,l);n===-1?(e+=r.slice(l,l+1),l+=1):(e+=r.slice(l,n).replaceAll(gr," "),l=n)}return e},yr=r=>{const e=new Set;for(const l of r.matchAll(pr))e.add((l[1]??"").toLowerCase());return e},wr=(r,e)=>{const l=new Map;for(const n of r.matchAll(hr)){const t=(n[1]??"").toLowerCase(),o=(n[2]??"").toLowerCase();e.has(t)&&(l.set(t,t),o!==""&&!br.has(o)&&l.set(o,t))}return l},kl=(r,e)=>{const l=vr(r),n=new Set(e.map(t=>t.toLowerCase()));return{ctes:yr(l),masked:l,targets:wr(l,n)}},Nr=/^(?:__lunora|sqlite_)/iu,kr=/\b(?:from|join)\s+([a-z_][\w$]*)/giu,Sr=/\b([a-z_][\w$]*)\.([a-z_][\w$]*)/giu,qr=new Set(["cross","full","group","having","inner","join","lateral","left","limit","offset","order","right","select","union","where","window"]),$r=(r,e,l)=>{const n=[];for(const t of r.matchAll(kr)){const o=t[1]??"",a=o.toLowerCase();!e.has(a)&&!l.has(a)&&!qr.has(a)&&!Nr.test(o)&&n.push({length:o.length,message:`unknown table \`${o}\``,offset:t.index+t[0].length-o.length,severity:"error",source:"schema"})}return n},Cr=(r,e,l)=>{const n=[],t=new Map;for(const[o,a]of Object.entries(e.columns))t.set(o.toLowerCase(),new Set(a.map(m=>m.toLowerCase())));for(const o of r.matchAll(Sr)){const a=(o[1]??"").toLowerCase(),m=o[2]??"",s=l.get(a),c=s===void 0?void 0:t.get(s);c!==void 0&&!c.has(m.toLowerCase())&&n.push({length:m.length,message:`\`${s??""}\` has no column \`${m}\``,offset:o.index+o[0].length-m.length,severity:"error",source:"schema"})}return n},Lr=(r,e)=>{if(r.trim()==="")return[];const l=fr(r);if(l!==void 0)return l.code==="SQL_EMPTY"?[]:[{length:l.length,message:l.message,offset:l.offset,severity:"error",source:"gate"}];const{ctes:n,masked:t,targets:o}=kl(r,e.tables),a=new Set(e.tables.map(m=>m.toLowerCase()));return[...$r(t,a,n),...Cr(t,e,o)]},Er=jn(zn.lintSql),_r=600,Ir=(r,e,l)=>{const n=ul(),[t,o]=Q([]),a=fl(()=>Lr(r,e),[r,e]),m=Gl(r,_r),s=a.some(b=>b.source==="gate")||m.trim()==="",c=Dl(async b=>{try{const h=await n.query(Er,{sql:m},Mn(l));b.cancelled||o(h.diagnostics??[])}catch{b.cancelled||o([])}},[n,m,l]);An(()=>{if(s){o([]);return}const b={cancelled:!1};return fe(c(b)),()=>{b.cancelled=!0}},[c,s]);const p=m===r;return fl(()=>p?[...a,...t]:a,[a,t,p])},Tr=r=>r==="unsafe-response"?"The model returned a statement that is not read-only, so it was discarded.":r==="empty-response"?"The model returned nothing usable.":"The model could not be reached.",Rr=r=>{const e=J(51),{assistant:l,failed:n,onGenerated:t}=r,o=se(),[a,m]=Q("");if(l.unavailable)return null;let s;e[0]!==l?(s=l.pending("sql"),e[0]=l,e[1]=s):s=e[1];const c=s;let p;if(e[2]!==l||e[3]!==n||e[4]!==t||e[5]!==c||e[6]!==a||e[7]!==o){const b=l.reason("sql");let h;e[9]!==l||e[10]!==n||e[11]!==t||e[12]!==a?(h=L=>{const D=a.trim();D===""&&!L||fe((async()=>{const z=await l.generate(D===""?"fix the failing statement":D,L?n:void 0);z!==void 0&&t(z)})())},e[9]=l,e[10]=n,e[11]=t,e[12]=a,e[13]=h):h=e[13];const f=h;let d;e[14]!==o?(d=o("Describe the query you want"),e[14]=o,e[15]=d):d=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=L=>{m(L.target.value)},e[16]=w):w=e[16];let y;e[17]!==f?(y=L=>{L.key==="Enter"&&(L.preventDefault(),f(!1))},e[17]=f,e[18]=y):y=e[18];let v;e[19]!==o?(v=o("Describe the query you want"),e[19]=o,e[20]=v):v=e[20];let g;e[21]!==c||e[22]!==a||e[23]!==d||e[24]!==y||e[25]!==v?(g=i(Vl,{"aria-label":d,className:"h-7 flex-1 text-xs","data-testid":"sql-assistant-prompt",disabled:c,onChange:w,onKeyDown:y,placeholder:v,value:a}),e[21]=c,e[22]=a,e[23]=d,e[24]=y,e[25]=v,e[26]=g):g=e[26];const E=c&&"opacity-60";let k;e[27]!==E?(k=ve("rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",E),e[27]=E,e[28]=k):k=e[28];let C;e[29]!==c||e[30]!==a?(C=c||a.trim()==="",e[29]=c,e[30]=a,e[31]=C):C=e[31];let q;e[32]!==f?(q=()=>{f(!1)},e[32]=f,e[33]=q):q=e[33];let O;e[34]!==c||e[35]!==o?(O=o(c?"Thinking…":"Draft SQL"),e[34]=c,e[35]=o,e[36]=O):O=e[36];let N;e[37]!==k||e[38]!==C||e[39]!==q||e[40]!==O?(N=i("button",{className:k,"data-testid":"sql-assistant-generate",disabled:C,onClick:q,type:"button",children:O}),e[37]=k,e[38]=C,e[39]=q,e[40]=O,e[41]=N):N=e[41];let M;e[42]!==n||e[43]!==c||e[44]!==f||e[45]!==o?(M=n!==void 0&&i("button",{className:"rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-assistant-fix",disabled:c,onClick:()=>{f(!0)},type:"button",children:o("Fix this")}),e[42]=n,e[43]=c,e[44]=f,e[45]=o,e[46]=M):M=e[46];let R;e[47]!==N||e[48]!==M||e[49]!==g?(R=$("div",{className:"flex items-center gap-2",children:[g,N,M]}),e[47]=N,e[48]=M,e[49]=g,e[50]=R):R=e[50],p=$("div",{className:"flex flex-col gap-1 border-b border-border px-3 py-2","data-testid":"sql-assistant",children:[R,b!==void 0&&i("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-assistant-reason",role:"status",children:Tr(b)})]}),e[2]=l,e[3]=n,e[4]=t,e[5]=c,e[6]=a,e[7]=o,e[8]=p}else p=e[8];return p},Rn=8,Or=["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"],Mr=new Set(["AND","BY","HAVING","ON","OR","SELECT","WHERE"]),Dr=/[\w$]/,Sl=r=>r!==void 0&&Dr.test(r),ql=r=>{let e=r.length;for(;e>0&&Sl(r[e-1]);)e-=1;return r.slice(e)},$l=(r,e)=>{let l=e;for(;l>0&&Sl(r[l-1]);)l-=1;return{end:e,start:l,text:r.slice(l,e)}},gl=(r,e)=>{const l=r.slice(0,e).trimEnd();return l.endsWith(".")||Mr.has(ql(l).toUpperCase())},Ar=(r,e,l)=>{const n=r.slice(0,e);if(!n.endsWith("."))return;const t=ql(n.slice(0,-1));if(t!=="")return kl(r,l).targets.get(t.toLowerCase())??t},ml=(r,e)=>r.toLowerCase().startsWith(e.toLowerCase()),xl=(r,e,l,n)=>{const t=[];for(const o of r)if(ml(o,e)&&(t.push(n(o)),t.length>=l))break;return t},zr=(r,e,l)=>{const n=new Map;for(const[t,o]of Object.entries(r.columns))for(const a of o)if(ml(a,e)&&!n.has(a)&&(n.set(a,t),n.size>=l))return[...n].map(([m,s])=>({detail:s,kind:"column",label:m}));return[...n].map(([t,o])=>({detail:o,kind:"column",label:t}))},jr=(r,e,l)=>{const n=$l(r,e),t=Ar(r,n.start,l.tables);if(t!==void 0){const s=l.columns[t]??l.columns[t.toLowerCase()]??[];return xl(s,n.text,Rn,c=>({detail:t,kind:"column",label:c}))}if(n.text===""&&!gl(r,n.start))return[];const o=xl(l.tables,n.text,Rn,s=>({kind:"table",label:s})),a=zr(l,n.text,Rn),m=Or.flatMap(s=>n.text!==""&&ml(s,n.text)&&s.toLowerCase()!==n.text.toLowerCase()?[{kind:"keyword",label:s}]:[]);return(gl(r,n.start)?[...a,...o,...m]:[...o,...a,...m]).slice(0,Rn)},Br=(r,e,l)=>{const n=$l(r,e),t=r.slice(0,n.start)+l.label+r.slice(n.end);return{caret:n.start+l.label.length,value:t}},Wr=["boxSizing","borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textTransform","width","wordSpacing"],Fr=(r,e)=>{const l=globalThis.getComputedStyle(r),n=globalThis.document.createElement("div"),{style:t}=n;t.position="absolute",t.visibility="hidden",t.whiteSpace="pre-wrap",t.overflowWrap="break-word";for(const s of Wr)t[s]=l[s];n.textContent=r.value.slice(0,Math.max(0,e));const o=globalThis.document.createElement("span");o.textContent=r.value.slice(Math.max(0,e))||".",n.append(o),globalThis.document.body.append(n);const a=o.offsetLeft-r.scrollLeft,m=o.offsetTop-r.scrollTop;return n.remove(),{left:a,top:m}},Pr=(r,e,l)=>{const n=J(13),[t,o]=Q(null);let a;n[0]!==r||n[1]!==e?(a=(w,y)=>{const v=jr(w,y,r);if(v.length===0){o(null);return}const g=e.current,{left:E,top:k}=g===null?{left:0,top:0}:Fr(g,y);o(C=>C!==null&&C.active===0&&C.left===E&&C.top===k&&C.suggestions.length===v.length&&C.suggestions.every((q,O)=>{const N=v.at(O);return q.kind===N?.kind&&q.label===N.label&&q.detail===N.detail})?C:{active:0,left:E,suggestions:v,top:k})},n[0]=r,n[1]=e,n[2]=a):a=n[2];const m=a;let s;n[3]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{o(null)},n[3]=s):s=n[3];const c=s;let p;n[4]===Symbol.for("react.memo_cache_sentinel")?(p=w=>{o(y=>{if(y===null)return y;const v=y.suggestions.length,g=(y.active+w+v)%v;return{...y,active:g}})},n[4]=p):p=n[4];const b=p;let h;n[5]!==l||n[6]!==t||n[7]!==e?(h=()=>{const w=e.current;if(t===null||w===null)return!1;const y=t.suggestions[t.active];if(y===void 0)return!1;const v=Br(w.value,w.selectionStart,y);return l(v.value),o(null),requestAnimationFrame(()=>{const g=e.current;g!==null&&(g.focus(),g.setSelectionRange(v.caret,v.caret))}),!0},n[5]=l,n[6]=t,n[7]=e,n[8]=h):h=n[8];const f=h;let d;return n[9]!==f||n[10]!==m||n[11]!==t?(d={close:c,commit:f,move:b,refresh:m,state:t},n[9]=f,n[10]=m,n[11]=t,n[12]=d):d=n[12],d},Hr={column:"column",keyword:"keyword",table:"table"},Ur=20,Yr=r=>{const e=J(17),{listboxId:l,onPick:n,state:t}=r,o=se();let a;e[0]!==t?(a=t===null?void 0:{left:t.left,top:t.top+Ur},e[0]=t,e[1]=a):a=e[1];const m=a;if(t===null)return null;let s;if(e[2]!==l||e[3]!==n||e[4]!==t.active||e[5]!==t.suggestions||e[6]!==o){let p;e[8]!==l||e[9]!==n||e[10]!==t.active||e[11]!==o?(p=(b,h)=>$("li",{"aria-selected":h===t.active,className:ve("flex cursor-pointer items-center gap-2 px-2 py-1 text-[13px]",h===t.active?"bg-accent text-accent-foreground":"text-foreground"),"data-testid":"sql-autocomplete-item",id:`${l}-opt-${h.toString()}`,onMouseDown:f=>{f.preventDefault(),n(h)},role:"option",children:[i("span",{className:"truncate font-mono",children:b.label}),b.detail!==void 0&&i("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:b.detail}),i("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:o(Hr[b.kind])})]},`${b.kind}:${b.label}`),e[8]=l,e[9]=n,e[10]=t.active,e[11]=o,e[12]=p):p=e[12],s=t.suggestions.map(p),e[2]=l,e[3]=n,e[4]=t.active,e[5]=t.suggestions,e[6]=o,e[7]=s}else s=e[7];let c;return e[13]!==l||e[14]!==m||e[15]!==s?(c=i("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:l,role:"listbox",style:m,children:s}),e[13]=l,e[14]=m,e[15]=s,e[16]=c):c=e[16],c},Kr=r=>{const e=J(8),{diagnostics:l,draft:n,scrollRef:t}=r;let o,a;if(e[0]!==l||e[1]!==n){a=Symbol.for("react.early_return_sentinel");e:{const c=Xl(l,n.length);if(c.length===0){a=null;break e}o=[];let p=0;for(const[b,h]of c.entries())h.start>p&&o.push(n.slice(p,h.start)),o.push(i("span",{className:ve("decoration-wavy underline underline-offset-4",h.severity==="error"?"decoration-destructive":"decoration-amber-500"),children:n.slice(h.start,h.end)},`${h.start.toString()}-${b.toString()}`)),p=h.end;o.push(n.slice(p))}e[0]=l,e[1]=n,e[2]=o,e[3]=a}else o=e[2],a=e[3];if(a!==Symbol.for("react.early_return_sentinel"))return a;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=ve("pointer-events-none absolute inset-0 overflow-hidden text-transparent",Nl),e[4]=m):m=e[4];let s;return e[5]!==o||e[6]!==t?(s=i("div",{"aria-hidden":"true",className:m,"data-testid":"sql-diagnostics-overlay",ref:t,children:o}),e[5]=o,e[6]=t,e[7]=s):s=e[7],s},Qr={gate:"read-only",plan:"plan",schema:"schema",syntax:"syntax"},Jr=r=>{const e=J(10),{diagnostics:l,onSelect:n}=r,t=se();if(l.length===0)return null;let o;e[0]!==t?(o=t("SQL problems"),e[0]=t,e[1]=o):o=e[1];let a;if(e[2]!==l||e[3]!==n){let s;e[5]!==n?(s=(c,p)=>i("li",{children:$("button",{className:"flex w-full items-start gap-2 px-3 py-1 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-problem",onClick:()=>{n(c)},type:"button",children:[i("span",{className:ve("mt-px shrink-0 rounded px-1 font-mono text-[10px] uppercase",c.severity==="error"?"bg-destructive/15 text-destructive":"bg-amber-500/15 text-amber-600"),children:Qr[c.source]}),i("span",{className:"min-w-0 text-muted-foreground",children:c.message})]})},`${c.source}-${(c.offset??p).toString()}-${p.toString()}`),e[5]=n,e[6]=s):s=e[6],a=l.map(s),e[2]=l,e[3]=n,e[4]=a}else a=e[4];let m;return e[7]!==o||e[8]!==a?(m=i("ul",{"aria-label":o,className:"max-h-24 shrink-0 overflow-y-auto border-t border-border bg-muted/30","data-testid":"sql-problems",children:a}),e[7]=o,e[8]=a,e[9]=m):m=e[9],m},Cl=[{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;"}],Gr=r=>{const e=J(29),{active:l,onDelete:n,onSelect:t,query:o}=r,a=se();let m;e[0]!==t||e[1]!==o.id?(m=()=>{t(o.id)},e[0]=t,e[1]=o.id,e[2]=m):m=e[2];const s=m;let c;e[3]!==n||e[4]!==o.id?(c=q=>{q.stopPropagation(),n(o.id)},e[3]=n,e[4]=o.id,e[5]=c):c=e[5];const p=c,b=l?"bg-sidebar-accent font-medium text-foreground":"text-muted-foreground";let h;e[6]!==b?(h=ve("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",b),e[6]=b,e[7]=h):h=e[7];const f=`sql-query-${o.id}`;let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=i("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:i("path",{d:"M4 6h16M4 12h10M4 18h7"})}),e[8]=d):d=e[8];let w;e[9]!==o.name?(w=i("span",{className:"truncate",children:o.name}),e[9]=o.name,e[10]=w):w=e[10];let y;e[11]!==l||e[12]!==s||e[13]!==h||e[14]!==f||e[15]!==w?(y=$("button",{"aria-pressed":l,className:h,"data-testid":f,onClick:s,type:"button",children:[d,w]}),e[11]=l,e[12]=s,e[13]=h,e[14]=f,e[15]=w,e[16]=y):y=e[16];let v;e[17]!==a?(v=a("Delete query"),e[17]=a,e[18]=v):v=e[18];let g;e[19]!==a?(g=a("Delete query"),e[19]=a,e[20]=g):g=e[20];let E;e[21]===Symbol.for("react.memo_cache_sentinel")?(E=i("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:i("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[21]=E):E=e[21];let k;e[22]!==p||e[23]!==g||e[24]!==v?(k=i("button",{"aria-label":v,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:p,title:g,type:"button",children:E}),e[22]=p,e[23]=g,e[24]=v,e[25]=k):k=e[25];let C;return e[26]!==k||e[27]!==y?(C=$("li",{className:"group/q flex items-center",children:[y,k]}),e[26]=k,e[27]=y,e[28]=C):C=e[28],C},Vr=(r,e)=>{const l=e.trim().toLowerCase();return l===""?[...r]:r.filter(n=>n.name.toLowerCase().includes(l))},Xr=r=>{const e=J(60),{activeId:l,history:n,listRef:t,onClearHistory:o,onDelete:a,onLoadHistory:m,onLoadTemplate:s,onNew:c,onSearchChange:p,onSelect:b,queries:h,search:f}=r,d=se();let w,y,v,g;if(e[0]!==l||e[1]!==t||e[2]!==a||e[3]!==c||e[4]!==p||e[5]!==b||e[6]!==h||e[7]!==f||e[8]!==d){const L=Vr(h,f);y="flex h-full w-64 shrink-0 flex-col border-e border-border bg-sidebar";let D;e[13]!==d?(D=d("Search queries…"),e[13]=d,e[14]=D):D=e[14];let z;e[15]!==p||e[16]!==f||e[17]!==D?(z=i("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:p,placeholder:D,type:"text",value:f}),e[15]=p,e[16]=f,e[17]=D,e[18]=z):z=e[18];let j;e[19]!==d?(j=d("New query"),e[19]=d,e[20]=j):j=e[20];let U;e[21]!==d?(U=d("New query"),e[21]=d,e[22]=U):U=e[22];let A;e[23]===Symbol.for("react.memo_cache_sentinel")?(A=i("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:i("path",{d:"M12 5v14M5 12h14"})}),e[23]=A):A=e[23];let Y;e[24]!==c||e[25]!==j||e[26]!==U?(Y=i("button",{"aria-label":j,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:c,title:U,type:"button",children:A}),e[24]=c,e[25]=j,e[26]=U,e[27]=Y):Y=e[27],e[28]!==Y||e[29]!==z?(v=$("div",{className:"flex shrink-0 items-center gap-2 border-b border-border p-2",children:[z,Y]}),e[28]=Y,e[29]=z,e[30]=v):v=e[30],w="flex flex-1 flex-col gap-4 overflow-y-auto p-2";let B;e[31]!==d?(B=d("Private"),e[31]=d,e[32]=B):B=e[32];let W;e[33]!==B?(W=i("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:B}),e[33]=B,e[34]=W):W=e[34],g=$("div",{children:[W,L.length===0?i("p",{className:"px-1 py-2 text-xs text-muted-foreground","data-testid":"sql-private-empty",children:d("No saved queries yet — they save to this browser as you type.")}):i("ul",{className:"flex flex-col gap-px","data-testid":"sql-private",ref:t,children:L.map(_=>i(Gr,{active:l===_.id,onDelete:a,onSelect:b,query:_},_.id))})]}),e[0]=l,e[1]=t,e[2]=a,e[3]=c,e[4]=p,e[5]=b,e[6]=h,e[7]=f,e[8]=d,e[9]=w,e[10]=y,e[11]=v,e[12]=g}else w=e[9],y=e[10],v=e[11],g=e[12];let E;e[35]!==d?(E=d("Reference"),e[35]=d,e[36]=E):E=e[36];let k;e[37]!==E?(k=i("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:E}),e[37]=E,e[38]=k):k=e[38];let C;e[39]!==s?(C=Cl.map(L=>i("li",{children:$("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":L.sql,onClick:s,type:"button",children:[i("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:i("path",{d:"M7 4h7l4 4v12H7zM14 4v4h4"})}),L.label]})},L.label)),e[39]=s,e[40]=C):C=e[40];let q;e[41]!==C?(q=i("ul",{className:"flex flex-col gap-px",children:C}),e[41]=C,e[42]=q):q=e[42];let O;e[43]!==k||e[44]!==q?(O=$("div",{children:[k,q]}),e[43]=k,e[44]=q,e[45]=O):O=e[45];let N;e[46]!==n||e[47]!==o||e[48]!==m||e[49]!==d?(N=n.length>0&&$("div",{children:[$("div",{className:"flex items-center justify-between px-1 pb-1",children:[i("p",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d("History")}),i("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:o,type:"button",children:d("Clear history")})]}),i("ul",{className:"flex flex-col gap-px","data-testid":"sql-history",children:n.map(L=>i("li",{children:$("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":L.sql,"data-testid":"sql-history-item",onClick:m,title:L.sql,type:"button",children:[i("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:i("path",{d:"M12 8v4l3 2M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18Z"})}),i("span",{className:"truncate font-mono",children:L.sql})]})},`${L.at.toString()}:${L.sql}`))})]}),e[46]=n,e[47]=o,e[48]=m,e[49]=d,e[50]=N):N=e[50];let M;e[51]!==w||e[52]!==N||e[53]!==g||e[54]!==O?(M=$("div",{className:w,children:[g,O,N]}),e[51]=w,e[52]=N,e[53]=g,e[54]=O,e[55]=M):M=e[55];let R;return e[56]!==M||e[57]!==y||e[58]!==v?(R=$("aside",{className:y,children:[v,M]}),e[56]=M,e[57]=y,e[58]=v,e[59]=R):R=e[59],R},Zr=jn(zn.listTables),eo=jn(zn.readTablePage),to=r=>{const e=J(16),l=ul();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],e[0]=n):n=e[0];const[t,o]=Q(n);let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a={},e[1]=a):a=e[1];const[m,s]=Q(a);let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=new Set,e[2]=c):c=e[2];const p=Dt(c);let b,h;e[3]!==l||e[4]!==r?(b=()=>{const g={cancelled:!1};return fe((async()=>{try{const E=await l.query(Zr,{},Mn(r));g.cancelled||(o(E.map(lo)),s({}),p.current=new Set)}catch{g.cancelled||(o([]),s({}),p.current=new Set)}})()),()=>{g.cancelled=!0}},h=[l,r],e[3]=l,e[4]=r,e[5]=b,e[6]=h):(b=e[5],h=e[6]),An(b,h);let f;e[7]!==l||e[8]!==r?(f=g=>{p.current.has(g)||(p.current.add(g),fe((async()=>{try{const E=await l.query(eo,{limit:1,offset:0,table:g},Mn(r));s(k=>({...k,[g]:E.columns}))}catch{p.current.delete(g)}})()))},e[7]=l,e[8]=r,e[9]=f):f=e[9];const d=f;let w;e[10]!==m||e[11]!==t?(w={columns:m,tables:t},e[10]=m,e[11]=t,e[12]=w):w=e[12];const y=w;let v;return e[13]!==d||e[14]!==y?(v={probe:d,schema:y},e[13]=d,e[14]=y,e[15]=v):v=e[15],v},il=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,no=r=>{const e=new Set;il.lastIndex=0;let l=il.exec(r);for(;l!==null;)e.add(l[1]??l[2]),l=il.exec(r);return[...e]};function lo(r){return r.name}const ro="lunora-studio-sql-tabs",oo="lunora-studio-sql-active-tab",dl=12,At=(r="",e="")=>({activeId:null,id:yl("tab"),name:e,sql:r}),so=()=>wl(oo,""),ao=r=>{const e=J(16),[l,n]=cl(ro),[t,o]=so(),[a]=Q(r);let m,s;e[0]!==a||e[1]!==n||e[2]!==l.length?(m=()=>{l.length===0&&n([a])},s=[a,n,l.length],e[0]=a,e[1]=n,e[2]=l.length,e[3]=m,e[4]=s):(m=e[3],s=e[4]),An(m,s);let c;e[5]!==a||e[6]!==l?(c=l.length===0?[a]:l,e[5]=a,e[6]=l,e[7]=c):c=e[7];const p=c;let b;e[8]!==t||e[9]!==p?(b=p.some(d=>d.id===t)?t:p[0]?.id??"",e[8]=t,e[9]=p,e[10]=b):b=e[10];const h=b;let f;return e[11]!==h||e[12]!==o||e[13]!==n||e[14]!==p?(f={activeId:h,setActiveId:o,setTabs:n,tabs:p},e[11]=h,e[12]=o,e[13]=n,e[14]=p,e[15]=f):f=e[15],f},Ll=r=>r.activeId===null&&r.sql.trim()!=="",io=(r,e)=>[...r,e].slice(-dl),co=(r,e,l)=>{const n=r.findIndex(o=>o.id===e);if(n===-1)return{activeId:r[0]?.id??"",tabs:[...r]};const t=r.filter(o=>o.id!==e);if(t.length===0){const o=l();return{activeId:o.id,tabs:[o]}}return{activeId:t[Math.min(n,t.length-1)].id,tabs:t}},uo=(r,e)=>{const l=r.filter(n=>n.id===e);return l.length===0?{activeId:r[0]?.id??"",tabs:[...r]}:{activeId:e,tabs:l}},mo=(r,e,l)=>{const n=r.findIndex(o=>o.id===e);if(n===-1)return{activeId:l,tabs:[...r]};const t=r.slice(0,n+1);return{activeId:t.some(o=>o.id===l)?l:e,tabs:t}},fo=r=>{const e=r();return{activeId:e.id,tabs:[e]}},ho=(r,e,l)=>{if(r==="others")return e.filter(n=>n.id!==l);if(r==="right"){const n=e.findIndex(t=>t.id===l);return n===-1?[]:e.slice(n+1)}return[...e]},po=(r,e)=>r.trim()===""?e:(r.split(`
|
|
5
|
+
`)[0]??r).slice(0,24),bo=r=>{r?.focus(),r?.select()},go=r=>{const e=J(14),{initial:l,onCancel:n,onCommit:t,placeholder:o,testId:a}=r,m=se();let s;e[0]!==t?(s=d=>{t(d.currentTarget.value.trim())},e[0]=t,e[1]=s):s=e[1];const c=s;let p;e[2]!==n||e[3]!==t?(p=d=>{d.key==="Enter"?t(d.currentTarget.value.trim()):d.key==="Escape"&&n()},e[2]=n,e[3]=t,e[4]=p):p=e[4];const b=p;let h;e[5]!==m?(h=m("Tab title"),e[5]=m,e[6]=h):h=e[6];let f;return e[7]!==l||e[8]!==c||e[9]!==b||e[10]!==o||e[11]!==h||e[12]!==a?(f=i("input",{"aria-label":h,className:"w-40 rounded border border-ring bg-background px-1 py-0.5 text-xs outline-none","data-testid":a,defaultValue:l,onBlur:c,onKeyDown:b,placeholder:o,ref:bo,type:"text"}),e[7]=l,e[8]=c,e[9]=b,e[10]=o,e[11]=h,e[12]=a,e[13]=f):f=e[13],f},xo=r=>{const e=J(29),{idBase:l,onDiscard:n,onKeep:t}=r,o=se(),a=`sql-tab-close-prompt-${l}`;let m;e[0]!==o?(m=o("Discard?"),e[0]=o,e[1]=m):m=e[1];let s;e[2]!==m?(s=i("span",{className:"text-[11px] text-muted-foreground",children:m}),e[2]=m,e[3]=s):s=e[3];let c;e[4]!==o?(c=o("Discard changes"),e[4]=o,e[5]=c):c=e[5];const p=`sql-tab-close-confirm-${l}`;let b;e[6]!==o?(b=o("Discard changes"),e[6]=o,e[7]=b):b=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=i("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:i("path",{d:"M5 13l4 4L19 7"})}),e[8]=h):h=e[8];let f;e[9]!==n||e[10]!==c||e[11]!==p||e[12]!==b?(f=i("button",{"aria-label":c,className:"flex size-5 items-center justify-center rounded text-destructive hover:bg-destructive/10","data-testid":p,onClick:n,title:b,type:"button",children:h}),e[9]=n,e[10]=c,e[11]=p,e[12]=b,e[13]=f):f=e[13];let d;e[14]!==o?(d=o("Keep editing"),e[14]=o,e[15]=d):d=e[15];const w=`sql-tab-close-cancel-${l}`;let y;e[16]!==o?(y=o("Keep editing"),e[16]=o,e[17]=y):y=e[17];let v;e[18]===Symbol.for("react.memo_cache_sentinel")?(v=i("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:i("path",{d:"M6 6l12 12M18 6 6 18"})}),e[18]=v):v=e[18];let g;e[19]!==t||e[20]!==w||e[21]!==y||e[22]!==d?(g=i("button",{"aria-label":d,className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent","data-testid":w,onClick:t,title:y,type:"button",children:v}),e[19]=t,e[20]=w,e[21]=y,e[22]=d,e[23]=g):g=e[23];let E;return e[24]!==a||e[25]!==g||e[26]!==s||e[27]!==f?(E=$("span",{className:"flex shrink-0 items-center gap-1","data-testid":a,role:"group",children:[s,f,g]}),e[24]=a,e[25]=g,e[26]=s,e[27]=f,e[28]=E):E=e[28],E},vo=r=>{const e=J(47),{active:l,canClose:n,onClose:t,onMenu:o,onRename:a,onSelect:m,tab:s}=r,c=se(),[p,b]=Q(!1),[h,f]=Q(!1);let d;e[0]!==o||e[1]!==s.id?(d=G=>{o(s.id,G)},e[0]=o,e[1]=s.id,e[2]=d):d=e[2];const w=d;let y;e[3]!==m||e[4]!==s.id?(y=()=>{m(s.id)},e[3]=m,e[4]=s.id,e[5]=y):y=e[5];const v=y;let g;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{b(!0)},e[6]=g):g=e[6];const E=g;let k;e[7]!==t||e[8]!==s?(k=G=>{G.stopPropagation(),Ll(s)?f(!0):t(s.id)},e[7]=t,e[8]=s,e[9]=k):k=e[9];const C=k;let q;e[10]!==t||e[11]!==s.id?(q=G=>{G.stopPropagation(),f(!1),t(s.id)},e[10]=t,e[11]=s.id,e[12]=q):q=e[12];const O=q;let N;e[13]===Symbol.for("react.memo_cache_sentinel")?(N=G=>{G.stopPropagation(),f(!1)},e[13]=N):N=e[13];const M=N;let R;e[14]!==a||e[15]!==s.id?(R=G=>{a(s.id,G),b(!1)},e[14]=a,e[15]=s.id,e[16]=R):R=e[16];const L=R;let D;e[17]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{b(!1)},e[17]=D):D=e[17];const z=D;let j;e[18]!==s.name?(j=s.name.trim(),e[18]=s.name,e[19]=j):j=e[19];const U=j;let A;e[20]!==c||e[21]!==s.sql?(A=po(s.sql,c("Untitled")),e[20]=c,e[21]=s.sql,e[22]=A):A=e[22];const Y=A,B=l?"bg-background text-foreground":"bg-muted/40 text-muted-foreground hover:text-foreground";let W;e[23]!==B?(W=ve("group/tab flex shrink-0 items-center gap-1 border-e border-border ps-3 pe-1.5 text-xs",B),e[23]=B,e[24]=W):W=e[24];const _=`sql-tab-${s.id}`;let T;e[25]!==l||e[26]!==L||e[27]!==U||e[28]!==Y||e[29]!==p||e[30]!==v||e[31]!==c||e[32]!==s.id?(T=p?i(go,{initial:U,onCancel:z,onCommit:L,placeholder:Y,testId:`sql-tab-rename-${s.id}`}):i("button",{"aria-pressed":l,className:"max-w-40 truncate py-1.5 outline-none","data-testid":`sql-tab-select-${s.id}`,onClick:v,onDoubleClick:E,title:c("Double-click to rename"),type:"button",children:U===""?Y:U}),e[25]=l,e[26]=L,e[27]=U,e[28]=Y,e[29]=p,e[30]=v,e[31]=c,e[32]=s.id,e[33]=T):T=e[33];let F;e[34]!==n||e[35]!==O||e[36]!==h||e[37]!==C||e[38]!==c||e[39]!==s.id?(F=n&&(h?i(xo,{idBase:s.id,onDiscard:O,onKeep:M}):i("button",{"aria-label":c("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-${s.id}`,onClick:C,title:c("Close tab"),type:"button",children:i("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:i("path",{d:"M6 6l12 12M18 6 6 18"})})})),e[34]=n,e[35]=O,e[36]=h,e[37]=C,e[38]=c,e[39]=s.id,e[40]=F):F=e[40];let he;return e[41]!==w||e[42]!==W||e[43]!==_||e[44]!==T||e[45]!==F?(he=$("div",{className:W,"data-testid":_,onContextMenu:w,children:[T,F]}),e[41]=w,e[42]=W,e[43]=_,e[44]=T,e[45]=F,e[46]=he):he=e[46],he},yo=jn(zn.runSql),wo="lunora-studio-sql-queries",No="lunora-studio-sql-history",ko="lunora-studio-sql-split-view",So=25,qo={minWidth:"2.75rem",paddingInline:"0.5rem"},vl={error:null,pane:"results",result:null},$o=r=>{const e=J(16),{result:l}=r;if(l.columns.length===0){const s=l.rowCount===0?"0 rows":"";let c;return e[0]!==s?(c=i("p",{className:"p-4 text-sm text-muted-foreground",children:s}),e[0]=s,e[1]=c):c=e[1],c}let n;e[2]!==l.columns?(n=l.columns.map(Lo),e[2]=l.columns,e[3]=n):n=e[3];let t;e[4]!==n?(t=i(Wl,{className:"sticky top-0 z-10 bg-muted",children:i(hl,{children:n})}),e[4]=n,e[5]=t):t=e[5];let o;if(e[6]!==l.columns||e[7]!==l.rows){let s;e[9]!==l.columns?(s=(c,p)=>i(hl,{"data-testid":"sql-row",children:l.columns.map(b=>i(Ul,{className:"max-w-md truncate font-mono text-xs",children:i(Kl,{value:c[b]})},b))},p),e[9]=l.columns,e[10]=s):s=e[10],o=l.rows.map(s),e[6]=l.columns,e[7]=l.rows,e[8]=o}else o=e[8];let a;e[11]!==o?(a=i(Fl,{children:o}),e[11]=o,e[12]=a):a=e[12];let m;return e[13]!==t||e[14]!==a?(m=$(Pl,{"data-testid":"sql-rows",children:[t,a]}),e[13]=t,e[14]=a,e[15]=m):m=e[15],m},On=r=>`border-b-2 px-3 py-2 text-sm outline-none transition-colors ${r?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,Co=()=>At(Cl[0]?.sql??""),Vo=r=>{const e=J(368),{initialShardKey:l}=r,n=ul(),t=se(),[o,a]=cl(wo),[m,s]=cl(No),[c,p]=Q(""),{activeId:b,setActiveId:h,setTabs:f,tabs:d}=ao(Co);let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={},e[0]=w):w=e[0];const[y,v]=Q(w),[g,E]=Q(l??""),[k,C]=Q(!1),[q,O]=wl(ko,!1),[N,M]=Q(null),[R,L]=Q(null),D=Dt(null),z=Dt(null),j=Dt(null),U=Dt(null),A=Al(),{probe:Y,schema:B}=to(g);let W;e[1]!==b||e[2]!==d?(W=d.find(u=>u.id===b)??d[0]??At(),e[1]=b,e[2]=d,e[3]=W):W=e[3];const _=W,T=_.sql,{activeId:F}=_,he=y[_.id]??vl,{chart:G,error:ne,failed:kt,result:I}=he,X=he.pane;let zt;e[4]!==_.id||e[5]!==f?(zt=u=>{f(x=>x.map(S=>S.id===_.id?{...S,...u}:S))},e[4]=_.id,e[5]=f,e[6]=zt):zt=e[6];const Bn=zt;let jt;e[7]!==_.id?(jt=u=>{v(x=>{const S=x[_.id]??vl;return{...x,[_.id]:{...S,...u}}})},e[7]=_.id,e[8]=jt):jt=e[8];const P=jt;let Bt;e[9]!==F||e[10]!==Bn||e[11]!==a?(Bt=u=>{Bn({sql:u}),F!==null&&a(x=>x.map(S=>S.id===F?{...S,sql:u}:S))},e[9]=F,e[10]=Bn,e[11]=a,e[12]=Bt):Bt=e[12];const Z=Bt,ye=Ir(T,B,g),V=Jl(g);let Wt;e[13]!==V||e[14]!==P||e[15]!==I?(Wt=()=>{I!==null&&fe((async()=>{const u=await V.inferChart({columns:I.columns,rowCount:I.rowCount,types:Object.fromEntries(I.columns.map(x=>[x,typeof(I.rows[0]?.[x]??"")]))});P({chart:u})})())},e[13]=V,e[14]=P,e[15]=I,e[16]=Wt):Wt=e[16];const Wn=Wt,El=Pr(B,j,Z),{close:le,commit:we,move:pe,refresh:ee,state:K}=El;let Ft;e[17]!==K?.active||e[18]!==we||e[19]!==pe?(Ft=u=>{pe(u-(K?.active??0)),we()},e[17]=K?.active,e[18]=we,e[19]=pe,e[20]=Ft):Ft=e[20];const Fn=Ft;let Pt;e[21]!==ee?(Pt=()=>{const u=j.current;u!==null&&u===document.activeElement&&ee(u.value,u.selectionStart)},e[21]=ee,e[22]=Pt):Pt=e[22];let Ht;e[23]!==ee||e[24]!==B?(Ht=[ee,B],e[23]=ee,e[24]=B,e[25]=Ht):Ht=e[25],An(Pt,Ht);let Ut;e[26]!==s?(Ut=u=>{s(x=>x[0]?.sql===u?x:[{at:Date.now(),sql:u},...x.filter(S=>S.sql!==u)].slice(0,So))},e[26]=s,e[27]=Ut):Ut=e[27];const Pn=Ut;let Yt;e[28]!==n||e[29]!==T||e[30]!==P||e[31]!==Pn||e[32]!==g?(Yt=async u=>{if(T.trim()==="")return;C(!0);const x=u==="explain"?`EXPLAIN QUERY PLAN ${T}`:T;try{const S=await n.query(yo,{sql:x},Mn(g));P({chart:void 0,error:null,failed:void 0,pane:u,result:S}),Yl(g),Pn(x)}catch(S){const H=S;P({chart:void 0,error:pl(H),failed:{error:pl(H),sql:x},pane:u,result:null})}C(!1)},e[28]=n,e[29]=T,e[30]=P,e[31]=Pn,e[32]=g,e[33]=Yt):Yt=e[33];const re=Yt;let Kt;e[34]!==re?(Kt=()=>{fe(re("results"))},e[34]=re,e[35]=Kt):Kt=e[35];const Hn=Kt;let Qt;e[36]!==Y||e[37]!==ee||e[38]!==Z?(Qt=u=>{const{selectionStart:x,value:S}=u.target;Z(S);for(const H of no(S))Y(H);ee(S,x)},e[36]=Y,e[37]=ee,e[38]=Z,e[39]=Qt):Qt=e[39];const Un=Qt;let Jt;e[40]!==ee?(Jt=u=>{const x=u.currentTarget;ee(x.value,x.selectionStart)},e[40]=ee,e[41]=Jt):Jt=e[41];const Yn=Jt;let Gt;e[42]!==K||e[43]!==le||e[44]!==we||e[45]!==pe||e[46]!==re||e[47]!==X?(Gt=u=>{if(K!==null){if(u.key==="ArrowDown"){u.preventDefault(),pe(1);return}if(u.key==="ArrowUp"){u.preventDefault(),pe(-1);return}if(u.key==="Escape"){u.preventDefault(),le();return}if((u.key==="Enter"||u.key==="Tab")&&!u.metaKey&&!u.ctrlKey&&we()){u.preventDefault();return}}(u.metaKey||u.ctrlKey)&&u.key==="Enter"&&(u.preventDefault(),fe(re(X)))},e[42]=K,e[43]=le,e[44]=we,e[45]=pe,e[46]=re,e[47]=X,e[48]=Gt):Gt=e[48];const Kn=Gt;let Vt;e[49]!==le?(Vt=()=>{requestAnimationFrame(()=>{le()})},e[49]=le,e[50]=Vt):Vt=e[50];const Qn=Vt;let Xt;e[51]===Symbol.for("react.memo_cache_sentinel")?(Xt=u=>{const{scrollLeft:x,scrollTop:S}=u.currentTarget;D.current!==null&&(D.current.scrollTop=S),z.current!==null&&(z.current.scrollTop=S,z.current.scrollLeft=x)},e[51]=Xt):Xt=e[51];const _l=Xt;let Zt;e[52]===Symbol.for("react.memo_cache_sentinel")?(Zt=u=>{const x=j.current;x===null||u.offset===void 0||(x.focus(),x.setSelectionRange(u.offset,u.offset+(u.length??0)))},e[52]=Zt):Zt=e[52];const Il=Zt;let en;e[53]!==_.id||e[54]!==P||e[55]!==f?(en=(u,x)=>{f(S=>S.map(H=>H.id===_.id?{...H,activeId:x,sql:u}:H)),P({chart:void 0,error:null,failed:void 0,result:null})},e[53]=_.id,e[54]=P,e[55]=f,e[56]=en):en=e[56];const te=en;let tn;e[57]!==te||e[58]!==a||e[59]!==t?(tn=()=>{const u={id:yl("q"),name:t("Untitled query"),sql:""};a(x=>[u,...x]),te("",u.id)},e[57]=te,e[58]=a,e[59]=t,e[60]=tn):tn=e[60];const St=tn;let nn;e[61]!==te||e[62]!==o?(nn=u=>{const x=o.find(S=>S.id===u);x!==void 0&&(te(x.sql,u),U.current?.querySelector(`[data-testid="sql-query-${u}"]`)?.scrollIntoView({block:"nearest"}))},e[61]=te,e[62]=o,e[63]=nn):nn=e[63];const qt=nn;let ln;e[64]!==a||e[65]!==f?(ln=u=>{a(x=>x.filter(S=>S.id!==u)),f(x=>x.map(S=>S.activeId===u?{...S,activeId:null}:S))},e[64]=a,e[65]=f,e[66]=ln):ln=e[66];const $t=ln;let rn;e[67]!==te?(rn=u=>{te(u.currentTarget.dataset.sql??"",null)},e[67]=te,e[68]=rn):rn=e[68];const Ct=rn;let on;e[69]!==te?(on=u=>{te(u.currentTarget.dataset.sql??"",null)},e[69]=te,e[70]=on):on=e[70];const Lt=on;let sn;e[71]!==s?(sn=()=>{s([])},e[71]=s,e[72]=sn):sn=e[72];const Et=sn;let an;e[73]!==T||e[74]!==Z?(an=()=>{Z(rr(T))},e[73]=T,e[74]=Z,e[75]=an):an=e[75];const Jn=an;let cn;e[76]!==h||e[77]!==f||e[78]!==d.length?(cn=()=>{if(d.length>=dl)return;const u=At();f(x=>io(x,u)),h(u.id)},e[76]=h,e[77]=f,e[78]=d.length,e[79]=cn):cn=e[79];const _t=cn;let dn;e[80]!==h||e[81]!==f?(dn=u=>{M(null),L(null),f(u.tabs),h(u.activeId);const x=new Set(u.tabs.map(Eo));v(S=>Object.fromEntries(Object.entries(S).filter(H=>{const[ue]=H;return x.has(ue)})))},e[80]=h,e[81]=f,e[82]=dn):dn=e[82];const Ne=dn;let un;e[83]!==Ne||e[84]!==d?(un=u=>{Ne(co(d,u,At))},e[83]=Ne,e[84]=d,e[85]=un):un=e[85];const be=un;let mn;e[86]!==b||e[87]!==Ne||e[88]!==d?(mn=(u,x)=>{Ne(u==="others"?uo(d,x):u==="right"?mo(d,x,b):fo(At))},e[86]=b,e[87]=Ne,e[88]=d,e[89]=mn):mn=e[89];const ke=mn;let fn;e[90]!==ke||e[91]!==N||e[92]!==d?(fn=u=>{N!==null&&(ho(u,d,N.id).some(_o)?L(u):ke(u,N.id))},e[90]=ke,e[91]=N,e[92]=d,e[93]=fn):fn=e[93];const oe=fn;let hn;e[94]===Symbol.for("react.memo_cache_sentinel")?(hn=(u,x)=>{x.preventDefault(),L(null),M({id:u,x:x.clientX,y:x.clientY})},e[94]=hn):hn=e[94];const Tl=hn;let pn;e[95]===Symbol.for("react.memo_cache_sentinel")?(pn=()=>{M(null),L(null)},e[95]=pn):pn=e[95];const Rl=pn;let bn;e[96]===Symbol.for("react.memo_cache_sentinel")?(bn=u=>{u.preventDefault(),M(null),L(null)},e[96]=bn):bn=e[96];const Ol=bn;let gn;e[97]!==oe?(gn=()=>{oe("others")},e[97]=oe,e[98]=gn):gn=e[98];const It=gn;let xn;e[99]!==oe?(xn=()=>{oe("right")},e[99]=oe,e[100]=xn):xn=e[100];const Tt=xn;let vn;e[101]!==oe?(vn=()=>{oe("all")},e[101]=oe,e[102]=vn):vn=e[102];const Rt=vn;let yn;e[103]!==ke||e[104]!==R||e[105]!==N?(yn=()=>{N!==null&&R!==null&&ke(R,N.id),L(null)},e[103]=ke,e[104]=R,e[105]=N,e[106]=yn):yn=e[106];const Ot=yn;let wn;e[107]===Symbol.for("react.memo_cache_sentinel")?(wn=()=>{L(null)},e[107]=wn):wn=e[107];const Ml=wn;let Nn;e[108]!==N?(Nn=N===null?void 0:{left:N.x,top:N.y},e[108]=N,e[109]=Nn):Nn=e[109];const Mt=Nn;let kn;e[110]!==le||e[111]!==h?(kn=u=>{le(),h(u)},e[110]=le,e[111]=h,e[112]=kn):kn=e[112];const ge=kn;let Sn;e[113]!==f?(Sn=(u,x)=>{f(S=>S.map(H=>H.id===u?{...H,name:x}:H))},e[113]=f,e[114]=Sn):Sn=e[114];const xe=Sn;let qn;e[115]!==P?(qn=()=>{P({pane:"results"})},e[115]=P,e[116]=qn):qn=e[116];const Gn=qn;let $n;e[117]!==re?($n=()=>{fe(re("explain"))},e[117]=re,e[118]=$n):$n=e[118];const Vn=$n;let Cn;e[119]!==P?(Cn=()=>{P({pane:"chart"})},e[119]=P,e[120]=Cn):Cn=e[120];const Xn=Cn;let Ln;e[121]!==O||e[122]!==q?(Ln=()=>{O(!q)},e[121]=O,e[122]=q,e[123]=Ln):Ln=e[123];const Zn=Ln;let Se,qe,$e,Ce,Le,Ee,_e,Ie,ae,Te,Re,ie,ce,Oe,Me,de;if(e[124]!==F||e[125]!==_.id||e[126]!==_t||e[127]!==V||e[128]!==Et||e[129]!==be||e[130]!==Ot||e[131]!==$t||e[132]!==T||e[133]!==kt||e[134]!==m||e[135]!==Lt||e[136]!==Ct||e[137]!==St||e[138]!==Rt||e[139]!==It||e[140]!==Tt||e[141]!==R||e[142]!==o||e[143]!==xe||e[144]!==c||e[145]!==qt||e[146]!==ge||e[147]!==Z||e[148]!==q||e[149]!==t||e[150]!==N||e[151]!==Mt||e[152]!==d){const u=T.split(`
|
|
6
|
+
`).length;let x;e[169]===Symbol.for("react.memo_cache_sentinel")?(x=me=>{p(me.target.value)},e[169]=x):x=e[169];const S=x,H=q?"flex min-h-0 flex-1 flex-row":"flex min-h-0 flex-1 flex-col";Se=q?"flex w-2/5 min-h-0 min-w-0 shrink-0 flex-col border-s border-border":"flex h-2/5 min-h-0 shrink-0 flex-col border-t border-border",Oe="flex h-full min-w-0",Me="lunora-sql-editor",e[170]!==F||e[171]!==Et||e[172]!==$t||e[173]!==m||e[174]!==Lt||e[175]!==Ct||e[176]!==St||e[177]!==o||e[178]!==c||e[179]!==qt?(de=i(Xr,{activeId:F,history:m,listRef:U,onClearHistory:Et,onDelete:$t,onLoadHistory:Lt,onLoadTemplate:Ct,onNew:St,onSearchChange:S,onSelect:qt,queries:o,search:c}),e[170]=F,e[171]=Et,e[172]=$t,e[173]=m,e[174]=Lt,e[175]=Ct,e[176]=St,e[177]=o,e[178]=c,e[179]=qt,e[180]=de):de=e[180],Re="flex min-w-0 flex-1 flex-col";let ue;if(e[181]!==_.id||e[182]!==be||e[183]!==xe||e[184]!==ge||e[185]!==d){let me;e[187]!==_.id||e[188]!==be||e[189]!==xe||e[190]!==ge||e[191]!==d.length?(me=al=>i(vo,{active:al.id===_.id,canClose:d.length>1,onClose:be,onMenu:Tl,onRename:xe,onSelect:ge,tab:al},al.id),e[187]=_.id,e[188]=be,e[189]=xe,e[190]=ge,e[191]=d.length,e[192]=me):me=e[192],ue=d.map(me),e[181]=_.id,e[182]=be,e[183]=xe,e[184]=ge,e[185]=d,e[186]=ue}else ue=e[186];let yt;e[193]!==t?(yt=t("New tab"),e[193]=t,e[194]=yt):yt=e[194];const sl=d.length>=dl;let wt;e[195]!==t?(wt=t("New tab"),e[195]=t,e[196]=wt):wt=e[196];let Tn;e[197]===Symbol.for("react.memo_cache_sentinel")?(Tn=i("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:i("path",{d:"M12 5v14M5 12h14"})}),e[197]=Tn):Tn=e[197];let Nt;e[198]!==_t||e[199]!==yt||e[200]!==sl||e[201]!==wt?(Nt=i("button",{"aria-label":yt,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:sl,onClick:_t,title:wt,type:"button",children:Tn}),e[198]=_t,e[199]=yt,e[200]=sl,e[201]=wt,e[202]=Nt):Nt=e[202],e[203]!==ue||e[204]!==Nt?(ie=$("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:[ue,Nt]}),e[203]=ue,e[204]=Nt,e[205]=ie):ie=e[205],e[206]!==Ot||e[207]!==Rt||e[208]!==It||e[209]!==Tt||e[210]!==R||e[211]!==t||e[212]!==N||e[213]!==Mt||e[214]!==d?(ce=N!==null&&$(bl,{children:[i("div",{className:"fixed inset-0 z-40","data-testid":"sql-tab-menu-backdrop",onClick:Rl,onContextMenu:Ol,role:"presentation"}),i("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:Mt,children:R===null?$(bl,{children:[i("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:d.length<=1,onClick:It,role:"menuitem",type:"button",children:t("Close other tabs")}),i("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:d.findIndex(me=>me.id===N.id)>=d.length-1,onClick:Tt,role:"menuitem",type:"button",children:t("Close tabs to the right")}),i("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:Rt,role:"menuitem",type:"button",children:t("Close all tabs")})]}):$("div",{className:"px-3 py-1.5","data-testid":"sql-tab-menu-confirm",children:[i("p",{className:"pb-1.5 text-xs text-muted-foreground",children:t("Discard unsaved tabs?")}),$("div",{className:"flex items-center gap-1.5",children:[i("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:Ot,type:"button",children:t("Discard")}),i("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:Ml,type:"button",children:t("Cancel")})]})]})})]}),e[206]=Ot,e[207]=Rt,e[208]=It,e[209]=Tt,e[210]=R,e[211]=t,e[212]=N,e[213]=Mt,e[214]=d,e[215]=ce):ce=e[215],Te=H,Ie="flex min-h-0 min-w-0 flex-1 flex-col",e[216]!==V||e[217]!==kt||e[218]!==Z?(ae=i(Rr,{assistant:V,failed:kt,onGenerated:Z}),e[216]=V,e[217]=kt,e[218]=Z,e[219]=ae):ae=e[219],_e="flex min-h-0 min-w-0 flex-1",qe="true",$e="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",Ce=D,Le=qo,Ee=Array.from({length:u},Io),e[124]=F,e[125]=_.id,e[126]=_t,e[127]=V,e[128]=Et,e[129]=be,e[130]=Ot,e[131]=$t,e[132]=T,e[133]=kt,e[134]=m,e[135]=Lt,e[136]=Ct,e[137]=St,e[138]=Rt,e[139]=It,e[140]=Tt,e[141]=R,e[142]=o,e[143]=xe,e[144]=c,e[145]=qt,e[146]=ge,e[147]=Z,e[148]=q,e[149]=t,e[150]=N,e[151]=Mt,e[152]=d,e[153]=Se,e[154]=qe,e[155]=$e,e[156]=Ce,e[157]=Le,e[158]=Ee,e[159]=_e,e[160]=Ie,e[161]=ae,e[162]=Te,e[163]=Re,e[164]=ie,e[165]=ce,e[166]=Oe,e[167]=Me,e[168]=de}else Se=e[153],qe=e[154],$e=e[155],Ce=e[156],Le=e[157],Ee=e[158],_e=e[159],Ie=e[160],ae=e[161],Te=e[162],Re=e[163],ie=e[164],ce=e[165],Oe=e[166],Me=e[167],de=e[168];let De;e[220]!==qe||e[221]!==$e||e[222]!==Ce||e[223]!==Le||e[224]!==Ee?(De=i("div",{"aria-hidden":qe,className:$e,ref:Ce,style:Le,children:Ee}),e[220]=qe,e[221]=$e,e[222]=Ce,e[223]=Le,e[224]=Ee,e[225]=De):De=e[225];let Ae;e[226]!==ye||e[227]!==T?(Ae=i(Kr,{diagnostics:ye,draft:T,scrollRef:z}),e[226]=ye,e[227]=T,e[228]=Ae):Ae=e[228];let ze;e[229]!==K||e[230]!==A?(ze=K===null?void 0:`${A}-opt-${K.active.toString()}`,e[229]=K,e[230]=A,e[231]=ze):ze=e[231];const el=K===null?void 0:A,tl=K!==null;let je;e[232]!==t?(je=t("SQL query"),e[232]=t,e[233]=je):je=e[233];let Be;e[234]!==T||e[235]!==Un||e[236]!==Qn||e[237]!==Kn||e[238]!==Yn||e[239]!==ze||e[240]!==el||e[241]!==tl||e[242]!==je?(Be=i("textarea",{"aria-activedescendant":ze,"aria-autocomplete":"list","aria-controls":el,"aria-expanded":tl,"aria-label":je,className:`relative size-full resize-none bg-transparent outline-none ${Nl}`,"data-testid":"sql-input",onBlur:Qn,onChange:Un,onKeyDown:Kn,onScroll:_l,onSelect:Yn,placeholder:"SELECT * FROM …",ref:j,role:"combobox",spellCheck:!1,value:T}),e[234]=T,e[235]=Un,e[236]=Qn,e[237]=Kn,e[238]=Yn,e[239]=ze,e[240]=el,e[241]=tl,e[242]=je,e[243]=Be):Be=e[243];let We;e[244]!==K||e[245]!==A||e[246]!==Fn?(We=i(Yr,{listboxId:A,onPick:Fn,state:K}),e[244]=K,e[245]=A,e[246]=Fn,e[247]=We):We=e[247];let Fe;e[248]!==Ae||e[249]!==Be||e[250]!==We?(Fe=$("div",{className:"relative min-w-0 flex-1 bg-background",children:[Ae,Be,We]}),e[248]=Ae,e[249]=Be,e[250]=We,e[251]=Fe):Fe=e[251];let Pe;e[252]!==_e||e[253]!==De||e[254]!==Fe?(Pe=$("div",{className:_e,children:[De,Fe]}),e[252]=_e,e[253]=De,e[254]=Fe,e[255]=Pe):Pe=e[255];let He;e[256]!==ye?(He=i(Jr,{diagnostics:ye,onSelect:Il}),e[256]=ye,e[257]=He):He=e[257];let Ue;e[258]!==Ie||e[259]!==ae||e[260]!==Pe||e[261]!==He?(Ue=$("div",{className:Ie,children:[ae,Pe,He]}),e[258]=Ie,e[259]=ae,e[260]=Pe,e[261]=He,e[262]=Ue):Ue=e[262];const nl=X==="results";let Ye;e[263]!==nl?(Ye=On(nl),e[263]=nl,e[264]=Ye):Ye=e[264];let Ke;e[265]!==t?(Ke=t("Results"),e[265]=t,e[266]=Ke):Ke=e[266];let Qe;e[267]!==Gn||e[268]!==Ye||e[269]!==Ke?(Qe=i("button",{className:Ye,"data-testid":"sql-tab-results",onClick:Gn,type:"button",children:Ke}),e[267]=Gn,e[268]=Ye,e[269]=Ke,e[270]=Qe):Qe=e[270];const ll=X==="chart";let Je;e[271]!==ll?(Je=On(ll),e[271]=ll,e[272]=Je):Je=e[272];let Ge;e[273]!==t?(Ge=t("Chart"),e[273]=t,e[274]=Ge):Ge=e[274];let Ve;e[275]!==Xn||e[276]!==Je||e[277]!==Ge?(Ve=i("button",{className:Je,"data-testid":"sql-tab-chart",onClick:Xn,type:"button",children:Ge}),e[275]=Xn,e[276]=Je,e[277]=Ge,e[278]=Ve):Ve=e[278];let Xe;e[279]!==V||e[280]!==Wn||e[281]!==I||e[282]!==t||e[283]!==X?(Xe=!V.unavailable&&X==="chart"&&I!==null&&i("button",{className:On(!1),"data-testid":"sql-infer-chart",disabled:V.pending("chart"),onClick:Wn,type:"button",children:V.pending("chart")?t("Thinking…"):t("Suggest chart")}),e[279]=V,e[280]=Wn,e[281]=I,e[282]=t,e[283]=X,e[284]=Xe):Xe=e[284];const rl=X==="explain";let Ze;e[285]!==rl?(Ze=On(rl),e[285]=rl,e[286]=Ze):Ze=e[286];let et;e[287]!==t?(et=t("Explain"),e[287]=t,e[288]=et):et=e[288];let tt;e[289]!==Vn||e[290]!==Ze||e[291]!==et?(tt=i("button",{className:Ze,"data-testid":"sql-tab-explain",onClick:Vn,type:"button",children:et}),e[289]=Vn,e[290]=Ze,e[291]=et,e[292]=tt):tt=e[292];let nt;e[293]!==t?(nt=t("Split editor and results"),e[293]=t,e[294]=nt):nt=e[294];const ol=`inline-flex items-center rounded-md border border-border px-2 py-1.5 outline-none transition-colors hover:bg-accent focus-visible:bg-accent ${q?"bg-accent text-foreground":"text-muted-foreground"}`;let lt;e[295]!==t?(lt=t("Split editor and results"),e[295]=t,e[296]=lt):lt=e[296];let En;e[297]===Symbol.for("react.memo_cache_sentinel")?(En=$("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:[i("rect",{height:"16",rx:"2",width:"18",x:"3",y:"4"}),i("path",{d:"M12 4v16"})]}),e[297]=En):En=e[297];let rt;e[298]!==q||e[299]!==nt||e[300]!==ol||e[301]!==lt||e[302]!==Zn?(rt=i("button",{"aria-label":nt,"aria-pressed":q,className:ol,"data-testid":"sql-split-toggle",onClick:Zn,title:lt,type:"button",children:En}),e[298]=q,e[299]=nt,e[300]=ol,e[301]=lt,e[302]=Zn,e[303]=rt):rt=e[303];let ot;e[304]!==I?(ot=I!==null&&I.columns.length>0&&i(Ql,{columns:I.columns,name:"query-result",rows:I.rows}),e[304]=I,e[305]=ot):ot=e[305];let st;e[306]!==t?(st=t("Format"),e[306]=t,e[307]=st):st=e[307];let at;e[308]!==Jn||e[309]!==k||e[310]!==st?(at=i("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:k,onClick:Jn,type:"button",children:st}),e[308]=Jn,e[309]=k,e[310]=st,e[311]=at):at=e[311];let it;e[312]!==g?(it=i(jl,{onChange:E,testId:"sql-shard-input",value:g}),e[312]=g,e[313]=it):it=e[313];let ct;e[314]!==k||e[315]!==t?(ct=t(k?"Running…":"Run"),e[314]=k,e[315]=t,e[316]=ct):ct=e[316];let _n;e[317]===Symbol.for("react.memo_cache_sentinel")?(_n=i("kbd",{className:"rounded border border-primary-foreground/30 px-1 font-sans text-[10px]",children:"⌘↵"}),e[317]=_n):_n=e[317];let dt;e[318]!==Hn||e[319]!==k||e[320]!==ct?(dt=$("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:k,onClick:Hn,type:"button",children:[ct,_n]}),e[318]=Hn,e[319]=k,e[320]=ct,e[321]=dt):dt=e[321];let ut;e[322]!==rt||e[323]!==ot||e[324]!==at||e[325]!==it||e[326]!==dt?(ut=$("div",{className:"ms-auto flex items-center gap-2",children:[rt,ot,at,it,dt]}),e[322]=rt,e[323]=ot,e[324]=at,e[325]=it,e[326]=dt,e[327]=ut):ut=e[327];let mt;e[328]!==Qe||e[329]!==Ve||e[330]!==Xe||e[331]!==tt||e[332]!==ut?(mt=$("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pe-2",children:[Qe,Ve,Xe,tt,ut]}),e[328]=Qe,e[329]=Ve,e[330]=Xe,e[331]=tt,e[332]=ut,e[333]=mt):mt=e[333];let ft;e[334]!==ne?(ft=ne!==null&&i(Bl,{className:"m-3 font-mono text-xs",testId:"sql-error",variant:"destructive",children:ne}),e[334]=ne,e[335]=ft):ft=e[335];let ht;e[336]!==ne||e[337]!==I||e[338]!==t?(ht=ne===null&&I===null&&i("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-empty",children:t("Click Run to execute your query.")}),e[336]=ne,e[337]=I,e[338]=t,e[339]=ht):ht=e[339];let pt;e[340]!==ne||e[341]!==G||e[342]!==I||e[343]!==t||e[344]!==X?(pt=ne===null&&I!==null&&$("div",{"data-testid":"sql-result",children:[X==="chart"?i(zl,{axes:G,result:I}):i($o,{result:I}),i("p",{className:"border-t border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"sql-count",children:I.truncated?t("Showing the first {max} of {count} rows.",{count:I.rowCount,max:I.rows.length}):t("{count} rows",{count:I.rowCount})})]}),e[340]=ne,e[341]=G,e[342]=I,e[343]=t,e[344]=X,e[345]=pt):pt=e[345];let bt;e[346]!==ft||e[347]!==ht||e[348]!==pt?(bt=$("div",{className:"min-h-0 flex-1 overflow-auto",children:[ft,ht,pt]}),e[346]=ft,e[347]=ht,e[348]=pt,e[349]=bt):bt=e[349];let gt;e[350]!==Se||e[351]!==mt||e[352]!==bt?(gt=$("div",{className:Se,children:[mt,bt]}),e[350]=Se,e[351]=mt,e[352]=bt,e[353]=gt):gt=e[353];let xt;e[354]!==gt||e[355]!==Te||e[356]!==Ue?(xt=$("div",{className:Te,children:[Ue,gt]}),e[354]=gt,e[355]=Te,e[356]=Ue,e[357]=xt):xt=e[357];let vt;e[358]!==xt||e[359]!==Re||e[360]!==ie||e[361]!==ce?(vt=$("div",{className:Re,children:[ie,ce,xt]}),e[358]=xt,e[359]=Re,e[360]=ie,e[361]=ce,e[362]=vt):vt=e[362];let In;return e[363]!==vt||e[364]!==Oe||e[365]!==Me||e[366]!==de?(In=$("div",{className:Oe,"data-testid":Me,children:[de,vt]}),e[363]=vt,e[364]=Oe,e[365]=Me,e[366]=de,e[367]=In):In=e[367],In};function Lo(r){return i(Hl,{children:r},r)}function Eo(r){return r.id}function _o(r){return Ll(r)}function Io(r,e){return i("div",{children:e+1},e)}export{Vo as SqlEditorPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as G}from"react/compiler-runtime";import{useLunora as L}from"@lunora/react";import{useNavigate as Q,useRouter as q,useSearch as J}from"@tanstack/react-router";import{useState as N,useEffect as $}from"react";import{d as S}from"../packem_shared/storage-tier-DznqOf-q.js";import{i as K}from"../packem_shared/table-list-sidebar-BFkSQwlB.js";import{useT as P}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{s as _,d as B}from"../packem_shared/data-view-params-ClrV7XgF.js";import{f}from"../packem_shared/internal-BSIsQVC6.js";import{l as z,s as O}from"../packem_shared/browser-storage-xjTyMKY0.js";import{DataBrowser as R}from"../packem_shared/DataBrowser-CuRlztBz.js";import{GlobalDataBrowser as H}from"../packem_shared/GlobalDataBrowser-DB-vQ2_H.js";import{jsx as v,jsxs as C}from"react/jsx-runtime";const j="lunora-studio-saved-queries",I=50,M=r=>r!==null&&typeof r=="object"&&typeof r.name=="string"&&typeof r.view=="object"&&r.view!==null,w=()=>z(j).filter(M),k=r=>{O(j,r)},U=(r,e)=>{const l=r.trim();if(l==="")return w();const o=[{name:l,view:e},...w().filter(u=>u.name!==l)].slice(0,I);return k(o),o},W=r=>{const e=w().filter(l=>l.name!==r);return k(e),e},X=r=>{const e=G(15),{onChange:l,tier:o}=r,u=P();let d;e[0]!==l?(d=y=>{l(y.target.value)},e[0]=l,e[1]=d):d=e[1];const s=d;let h;e[2]!==u?(h=u("Storage tier"),e[2]=u,e[3]=h):h=e[3];let n;e[4]!==h?(n=v("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:h}),e[4]=h,e[5]=n):n=e[5];const m=S[o];let i,g;e[6]===Symbol.for("react.memo_cache_sentinel")?(i=v("option",{value:"shard",children:S.shard.label}),g=v("option",{value:"global",children:S.global.label}),e[6]=i,e[7]=g):(i=e[6],g=e[7]);let c;e[8]!==s||e[9]!==m.title||e[10]!==o?(c=C("select",{className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm outline-none focus-visible:border-ring","data-testid":"table-editor-schema",id:"table-editor-schema",onChange:s,title:m.title,value:o,children:[i,g]}),e[8]=s,e[9]=m.title,e[10]=o,e[11]=c):c=e[11];let b;return e[12]!==n||e[13]!==c?(b=C("label",{className:"flex w-full flex-col gap-1",htmlFor:"table-editor-schema",children:[n,c]}),e[12]=n,e[13]=c,e[14]=b):b=e[14],b},Y=()=>{try{f(globalThis.navigator.clipboard.writeText(globalThis.location.href))}catch{}},me=({editable:r=!1,initialShardKey:e})=>{const l=L(),o=Q(),u=q(),d=J({strict:!1}),s=_(d),h=K(d),n=()=>u.state.location.pathname.split("/").findLast(Boolean)==="data",m=s.tier??"shard",i=s.table,[g,c]=N(()=>w()),[b,y]=N(()=>new Set);$(()=>{f((async()=>{try{const t=await l.listGlobalTables();y(new Set(t.map(a=>a.name)))}catch{}})())},[l]),$(()=>{m==="shard"&&i!==void 0&&b.has(i)&&f(o({replace:!0,search:t=>({...t,schema:"global"}),to:"/data"}))},[b,o,i,m]);const D=t=>{f(o({search:a=>({...a,schema:t==="global"?"global":void 0,table:void 0}),to:"/data"}))},T=(t,a)=>{n()&&f(o({search:p=>({schema:p.schema,search:a?.search,shard:p.shard,table:t}),to:"/data"}))},V=t=>{f(o({search:a=>({...a,schema:"global",table:t}),to:"/data"}))},A=t=>{const a=B(t),{current:p}=h;(p.filters??void 0)===a.filters&&(p.order??void 0)===a.order&&(p.search??void 0)===a.search&&(p.shard??void 0)===a.shard||!n()||f(o({replace:!0,search:F=>({...F,filters:a.filters,order:a.order,search:a.search,shard:a.shard}),to:"/data"}))},E={onApplyQuery:t=>{const a=B(t.view);f(o({search:()=>({filters:a.filters,order:a.order,schema:a.schema,search:a.search,shard:a.shard,table:a.table}),to:"/data"}))},onCopyLink:Y,onDeleteQuery:t=>{c(W(t))},onSaveQuery:(t,a)=>{c(U(t,a))},saved:g},x=v(X,{onChange:D,tier:m});return m==="global"?v(H,{initialTable:i,onSelectTable:T,schemaSwitch:x}):v(R,{editable:r,globalTableNames:b,initialFilters:s.filters,initialOrderBy:s.orderBy,initialPins:d.pins,initialSearch:s.search,initialShardKey:s.shard??e,onNavigateToGlobal:V,onSelectTable:T,onViewChange:A,queryBar:E,schemaSwitch:x,tableParam:i})};export{me as TableEditor};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useState as J}from"react";import{E as S}from"../packem_shared/error-alert-t6cpEi0z.js";import{g as C}from"../packem_shared/badge-BbuuAio7.js";import{u as j}from"../packem_shared/button-BkCrNcAs.js";import{c as I,u as K}from"../packem_shared/card-CIDGUN6K.js";import{E}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as q,d as U,m as g,p as o,f as _,u as i}from"../packem_shared/table-DdJBrClo.js";import{N as y}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as R}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as N}from"../packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js";import{i as V}from"../packem_shared/internal-BSIsQVC6.js";import{jsx as e,jsxs as n}from"react/jsx-runtime";const M="agent_threads",W="agent_messages",X=100,Y=250,Z={},Q={filters:[],limit:X,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:M},d=(s,t)=>{const a=s[t];return typeof a=="string"?a:void 0},b=(s,t)=>{const a=s[t];return typeof a=="number"?a:void 0},z=s=>{const{usage:t}=s;if(t===null||typeof t!="object")return;const{totalTokens:a}=t;return typeof a=="number"?a:void 0},ee=s=>{const{toolCalls:t}=s;return Array.isArray(t)?t.map(a=>a!==null&&typeof a=="object"?a.name:void 0).filter(a=>typeof a=="string"):[]},te=s=>{switch(s){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},ae=s=>{switch(s){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},pe=({initialShardKey:s=""})=>{const t=R(),[a,w]=J(void 0),{data:p}=y(N.listTables,Z,{live:!0,shardKey:s}),P=p!==void 0,m=Array.isArray(p)&&p.some(r=>r.name===M),{data:A,error:B,errorSource:D,liveError:L}=y(N.readTablePage,Q,{enabled:m,live:!0,shardKey:s}),O={filters:[{column:"threadKey",operator:"eq",value:a??""}],limit:Y,offset:0,orderBy:{column:"seq",direction:"asc"},skipCount:!0,table:W},{data:$,error:F,errorSource:G}=y(N.readTablePage,O,{enabled:m&&a!==void 0,live:!0,shardKey:s}),f=Array.isArray(A?.rows)?A.rows:[],k=Array.isArray($?.rows)?$.rows:[],T=f.find(r=>d(r,"key")===a);let u;return P&&!m?u=e(E,{description:t("No @lunora/agent tables found in this deployment. Add lunora/agents.ts with defineAgent(...) and merge the agent schema extension to run durable AI agents."),testId:"agents-unconfigured",title:t("No agents configured")}):m&&f.length===0?u=e(E,{description:t("No agent has run yet. Start a run with ctx.agents.<name>.run(...) and its thread appears here."),testId:"agents-empty",title:t("No agent threads yet")}):u=n("div",{className:"flex flex-col gap-6",children:[e(I,{className:"overflow-hidden py-0",children:e(K,{className:"px-0",children:n(q,{"data-testid":"agents-threads-table",children:[e(U,{children:n(g,{children:[e(o,{children:t("Agent")}),e(o,{children:t("Key")}),e(o,{children:t("Status")}),e(o,{children:t("Messages")}),e(o,{children:t("Tokens")}),e(o,{children:t("Updated")}),e(o,{"aria-label":t("Actions")})]})}),e(_,{children:f.map(r=>{const l=d(r,"key")??"",c=d(r,"status"),h=z(r);return n(g,{"data-active":l===a?"":void 0,"data-testid":`agents-thread-${l}`,children:[e(i,{className:"font-mono text-xs",children:d(r,"agent")??"—"}),e(i,{className:"font-mono text-xs text-muted-foreground",children:l}),e(i,{children:e(C,{"data-testid":`agents-thread-status-${l}`,variant:te(c),children:c??"—"})}),e(i,{className:"tabular-nums",children:b(r,"messageCount")??"—"}),e(i,{className:"tabular-nums text-muted-foreground",children:h??"—"}),e(i,{className:"text-muted-foreground tabular-nums",children:V(b(r,"updatedAt"),"—")}),e(i,{className:"text-right",children:e(j,{"data-testid":`agents-thread-open-${l}`,onClick:()=>{w(l)},size:"sm",type:"button",variant:"outline",children:t("Timeline")})})]},l)})})]})})}),F!==null&&e(S,{error:G,testId:"agents-messages-error"}),a!==void 0&&e(I,{className:"overflow-hidden py-0","data-testid":"agents-thread-detail",children:n(K,{className:"flex flex-col gap-3 px-4 py-3",children:[n("div",{className:"flex items-center justify-between gap-2",children:[n("span",{className:"font-mono text-xs",children:[t("Timeline")," · ",a,T!==void 0&&n("span",{className:"text-muted-foreground",children:[" · ",t("Usage"),": ",z(T)??0," ",t("Tokens")]})]}),e(j,{"data-testid":"agents-thread-detail-close",onClick:()=>{w(void 0)},size:"xs",type:"button",variant:"ghost",children:t("Close")})]}),k.length===0?e("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")}):n(q,{"data-testid":"agents-messages-table",children:[e(U,{children:n(g,{children:[e(o,{children:t("Role")}),e(o,{children:t("Content")}),e(o,{children:t("Tool")}),e(o,{children:t("Approval")})]})}),e(_,{children:k.map((r,l)=>{const c=d(r,"role")??"—",h=ee(r),H=d(r,"toolName"),x=d(r,"status"),v=b(r,"seq")??l;return n(g,{"data-testid":`agents-message-${String(v)}`,children:[e(i,{className:"font-mono text-xs align-top text-muted-foreground",children:c}),e(i,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:d(r,"content")??"—"}),e(i,{className:"font-mono text-xs align-top text-muted-foreground",children:H??(h.length>0?h.join(", "):"—")}),e(i,{className:"align-top",children:x===void 0?e("span",{className:"text-xs text-muted-foreground",children:"—"}):e(C,{"data-testid":`agents-message-approval-${String(v)}`,variant:ae(x),children:x})})]},d(r,"messageKey")??`${c}:${String(v)}`)})})]})]})})]}),n("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[B!==null&&e(S,{error:D,testId:"agents-error"}),e("p",{className:"text-sm text-muted-foreground",children:t("Agents run as durable workflows. Each run persists a thread of assistant and tool messages; select a thread to inspect its timeline, tool calls, approvals, and token usage.")}),L!==void 0&&e("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"agents-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")}),u]})};export{pe as AgentsPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as k}from"react/compiler-runtime";import{createAnalyticsSqlClient as C}from"@lunora/bindings/analytics";import{useState as L,useMemo as v,useCallback as O,useEffect as I}from"react";import{c as N}from"../packem_shared/card-CIDGUN6K.js";import{E as T}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as M,d as _,m as x,f as q,u as D,p as $}from"../packem_shared/table-DdJBrClo.js";import{useT as R}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{b as Y,f as w,h as B}from"../packem_shared/internal-BSIsQVC6.js";import{jsx as n,jsxs as E}from"react/jsx-runtime";const F="ANALYTICS",b=[{key:"volume",sql:a=>`SELECT blob2 AS fn, count() AS calls FROM ${a} WHERE blob1 = 'function_call' GROUP BY fn ORDER BY calls DESC LIMIT 25`,title:"Request volume per function"},{key:"latency",sql:a=>`SELECT blob2 AS fn, quantileWeighted(0.50)(double1, _sample_interval) AS p50, quantileWeighted(0.95)(double1, _sample_interval) AS p95 FROM ${a} WHERE blob1 = 'function_call' GROUP BY fn ORDER BY p95 DESC LIMIT 25`,title:"Latency p50 / p95 per function"},{key:"hotShards",sql:a=>`SELECT blob3 AS shard, count() AS calls FROM ${a} WHERE blob1 = 'function_call' GROUP BY shard ORDER BY calls DESC LIMIT 25`,title:"Hot shards"}],W={error:null,loading:!0,result:null},U=a=>{const e=k(27),{state:y,title:u}=a,c=R(),{error:r,loading:t,result:o}=y,l=`analytics-panel-${u}`;let s;e[0]!==c||e[1]!==u?(s=c(u),e[0]=c,e[1]=u,e[2]=s):s=e[2];let i;e[3]!==s?(i=n("header",{className:"border-b border-border px-4 py-3",children:n("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s})}),e[3]=s,e[4]=i):i=e[4];let d;e[5]!==t||e[6]!==c?(d=t&&n("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"analytics-loading",children:c("Loading…")}),e[5]=t,e[6]=c,e[7]=d):d=e[7];let m;e[8]!==r||e[9]!==t?(m=!t&&r!==null&&n("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"analytics-error",role:"alert",children:r}),e[8]=r,e[9]=t,e[10]=m):m=e[10];let p;e[11]!==r||e[12]!==t||e[13]!==o||e[14]!==c?(p=!t&&r===null&&o!==null&&o.rows.length===0&&n("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"analytics-empty-rows",children:c("No data points yet.")}),e[11]=r,e[12]=t,e[13]=o,e[14]=c,e[15]=p):p=e[15];let f;e[16]!==r||e[17]!==t||e[18]!==o?(f=!t&&r===null&&o!==null&&o.rows.length>0&&E(M,{children:[n(_,{children:n(x,{children:o.columns.map(H)})}),n(q,{children:o.rows.map((S,A)=>n(x,{children:o.columns.map(g=>n(D,{className:"font-mono text-xs",children:B(S[g.name])},g.name))},A))})]}),e[16]=r,e[17]=t,e[18]=o,e[19]=f):f=e[19];let h;return e[20]!==l||e[21]!==i||e[22]!==d||e[23]!==m||e[24]!==p||e[25]!==f?(h=E(N,{className:"gap-0 py-0","data-testid":l,children:[i,d,m,p,f]}),e[20]=l,e[21]=i,e[22]=d,e[23]=m,e[24]=p,e[25]=f,e[26]=h):h=e[26],h},Z=({config:a,dataset:e=F,runQuery:y}={})=>{const u=R(),[c,r]=L({}),t=v(()=>{if(y!==void 0)return y;if(a===void 0)return null;const l=C({accountId:a.accountId,apiToken:a.apiToken});return s=>l.query(s)},[a,y]),o=O(async l=>{if(t!==null)for(const s of b){if(l.cancelled)return;r(i=>({...i,[s.key]:{error:null,loading:!0,result:null}}));try{const i=await t(s.sql(e));l.cancelled||r(d=>({...d,[s.key]:{error:null,loading:!1,result:i}}))}catch(i){l.cancelled||r(d=>({...d,[s.key]:{error:Y(i),loading:!1,result:null}}))}}},[t,e]);return I(()=>{const l={cancelled:!1};return w(o(l)),()=>{l.cancelled=!0}},[o]),t===null?n(T,{description:u("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN (Analytics Read) in your .dev.vars to enable usage panels."),icon:n("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:n("path",{d:"M5 20V10m6.5 10V4M18 20v-7M3 20h18"})}),testId:"analytics-not-configured",title:u("Analytics is not configured.")}):n("div",{className:"flex flex-col gap-4","data-testid":"lunora-analytics-panel",children:b.map(l=>n(U,{state:c[l.key]??W,title:l.title},l.key))})};function H(a){return n($,{children:a.name},a.name)}export{Z as AnalyticsPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as P}from"react/compiler-runtime";import{useState as k}from"react";import{E as q}from"../packem_shared/error-alert-t6cpEi0z.js";import{g as _}from"../packem_shared/badge-BbuuAio7.js";import{u as z}from"../packem_shared/button-BkCrNcAs.js";import{c as D,u as H}from"../packem_shared/card-CIDGUN6K.js";import{E as M}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as O}from"../packem_shared/input-JHu63lTv.js";import{n as R,d as U,m as T,p as w,f as W,u as $}from"../packem_shared/table-DdJBrClo.js";import{N as B}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as J}from"../packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js";import{i as K}from"../packem_shared/internal-BSIsQVC6.js";import{jsx as r,jsxs as i}from"react/jsx-runtime";const ce=()=>{const e=P(39),t=G(),[l,j]=k("");let y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={},e[0]=y):y=e[0];const{data:b,error:s,errorSource:E,isLoading:S,refetch:A}=B(J.getAuthAuditLog,y);let C;if(e[1]!==b?.entries||e[2]!==l){const a=b?.entries??[],x=l.trim().toLowerCase();C=x===""?a:a.filter(N=>N.event.toLowerCase().includes(x)||(N.actorId??"").toLowerCase().includes(x)||(N.actorEmail??"").toLowerCase().includes(x)||(N.ip??"").toLowerCase().includes(x)||N.outcome.toLowerCase().includes(x)),e[1]=b?.entries,e[2]=l,e[3]=C}else C=e[3];const o=C;let I;e[4]===Symbol.for("react.memo_cache_sentinel")?(I=a=>{j(a.target.value)},e[4]=I):I=e[4];const F=I;let n;e[5]!==t?(n=t("Filter security events"),e[5]=t,e[6]=n):n=e[6];let c;e[7]!==t?(c=t("filter event, actor, IP"),e[7]=t,e[8]=c):c=e[8];let d;e[9]!==l||e[10]!==n||e[11]!==c?(d=r(O,{"aria-label":n,className:"h-8 w-56","data-testid":"aa-search",onChange:F,placeholder:c,value:l}),e[9]=l,e[10]=n,e[11]=c,e[12]=d):d=e[12];let m;e[13]!==A?(m=()=>{A()},e[13]=A,e[14]=m):m=e[14];let u;e[15]!==t?(u=t("Refresh"),e[15]=t,e[16]=u):u=e[16];let h;e[17]!==m||e[18]!==u?(h=r(z,{"data-testid":"aa-refresh",onClick:m,size:"xs",type:"button",variant:"ghost",children:u}),e[17]=m,e[18]=u,e[19]=h):h=e[19];let f;e[20]!==d||e[21]!==h?(f=i("div",{className:"flex flex-wrap items-center gap-2",children:[d,h]}),e[20]=d,e[21]=h,e[22]=f):f=e[22];let p;e[23]!==s||e[24]!==E?(p=s!==null&&r(q,{error:E,testId:"aa-error"}),e[23]=s,e[24]=E,e[25]=p):p=e[25];let g;e[26]!==s||e[27]!==o.length||e[28]!==S||e[29]!==t?(g=s===null&&!S&&o.length===0&&r(M,{description:t("Authentication and security events are recorded here."),testId:"aa-empty",title:t("No security events.")}),e[26]=s,e[27]=o.length,e[28]=S,e[29]=t,e[30]=g):g=e[30];let v;e[31]!==o||e[32]!==t?(v=o.length>0&&r(D,{className:"overflow-hidden py-0",children:r(H,{className:"max-h-[30rem] overflow-auto px-0",children:i(R,{"data-testid":"aa-table",children:[r(U,{children:i(T,{children:[r(w,{children:t("time")}),r(w,{children:t("event")}),r(w,{children:t("actor")}),r(w,{children:t("ip / user agent")}),r(w,{children:t("outcome")})]})}),r(W,{children:o.map(a=>i(T,{"data-testid":"aa-row",children:[r($,{className:"text-muted-foreground tabular-nums",children:K(a.ts,"—")}),r($,{children:r(_,{variant:"secondary",children:a.event})}),r($,{className:"max-w-[24ch] truncate font-mono text-xs",title:a.actorId??void 0,children:a.actorEmail??a.actorId??r("span",{className:"text-muted-foreground",children:"—"})}),i($,{className:"max-w-[28ch] truncate text-xs text-muted-foreground",title:a.userAgent??void 0,children:[a.ip??r("span",{className:"text-muted-foreground",children:"—"}),a.userAgent!==void 0&&i("span",{className:"ml-1 opacity-70",children:["· ",a.userAgent]})]}),r($,{children:r(_,{variant:a.outcome==="failure"?"destructive":"outline",children:t(a.outcome)})})]},a.seq))})]})})}),e[31]=o,e[32]=t,e[33]=v):v=e[33];let L;return e[34]!==p||e[35]!==g||e[36]!==v||e[37]!==f?(L=i("div",{className:"flex flex-col gap-4","data-testid":"lunora-auth-audit",children:[f,p,g,v]}),e[34]=p,e[35]=g,e[36]=v,e[37]=f,e[38]=L):L=e[38],L};export{ce as AuthAuditPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as N}from"react/compiler-runtime";import{useLunora as $}from"@lunora/react";import{g as x}from"../packem_shared/badge-BbuuAio7.js";import{c as w,u as I}from"../packem_shared/card-CIDGUN6K.js";import{O as S}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as A}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{jsx as t,jsxs as o,Fragment as y}from"react/jsx-runtime";const j=[{key:"accounts",label:"Accounts"},{key:"admin",label:"Admin"},{key:"organization",label:"Organizations"},{key:"passkey",label:"Passkeys"},{key:"twoFactor",label:"Two-factor"}],v=e=>{if(e===void 0)return"—";const i=[[86400,"d"],[3600,"h"],[60,"m"]];for(const[a,d]of i)if(e>=a&&e%a===0)return`${String(e/a)}${d}`;return`${String(e)}s`},h=e=>{const i=N(8),{children:a,heading:d,testId:s}=e;let l;i[0]!==d?(l=t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d})}),i[0]=d,i[1]=l):l=i[1];let n;i[2]!==a?(n=t(I,{className:"p-3",children:a}),i[2]=a,i[3]=n):n=i[3];let u;return i[4]!==l||i[5]!==n||i[6]!==s?(u=o(w,{className:"gap-0 py-0","data-testid":s,children:[l,n]}),i[4]=l,i[5]=n,i[6]=s,i[7]=u):u=i[7],u},c=e=>{const i=N(7),{label:a,value:d}=e;let s;i[0]!==a?(s=t("span",{className:"text-sm",children:a}),i[0]=a,i[1]=s):s=i[1];let l;i[2]!==d?(l=t("span",{className:"text-sm text-muted-foreground tabular-nums",children:d}),i[2]=d,i[3]=l):l=i[3];let n;return i[4]!==s||i[5]!==l?(n=o("div",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs",children:[s,l]}),i[4]=s,i[5]=l,i[6]=n):n=i[6],n},M=()=>{const e=N(20),i=$(),a=A();let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=["lunora-auth-config"],e[0]=d):d=e[0];let s;e[1]!==i?(s=()=>i.getAuthConfig(),e[1]=i,e[2]=s):s=e[2];const{data:l,error:n}=S(d,s);let u;e[3]!==a?(u=r=>t(x,{variant:r?"success":"outline",children:a(r?"Enabled":"Disabled")}),e[3]=a,e[4]=u):u=e[4];const m=u;let g;e[5]!==n?(g=n!==null&&t("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"auth-config-error",role:"alert",children:n}),e[5]=n,e[6]=g):g=e[6];let p;e[7]!==l||e[8]!==n||e[9]!==a?(p=n===null&&l===void 0&&t("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"auth-config-loading",children:a("Loading auth configuration…")}),e[7]=l,e[8]=n,e[9]=a,e[10]=p):p=e[10];let f;e[11]!==l||e[12]!==n||e[13]!==m||e[14]!==a?(f=n===null&&l!==void 0&&o(y,{children:[t(h,{heading:a("Enabled capabilities"),testId:"auth-config-capabilities",children:t("ul",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:j.map(r=>{const k=l.capabilities[r.key];return o("li",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs","data-testid":`auth-config-cap-${r.key}`,children:[t("span",{className:"text-sm",children:a(r.label)}),m(k)]},r.key)})})}),t(h,{heading:a("Plugins"),testId:"auth-config-plugins",children:l.plugins.length===0?t("p",{className:"text-sm text-muted-foreground",children:a("No plugins enabled.")}):t("div",{className:"flex flex-wrap gap-2",children:l.plugins.map(P)})}),t(h,{heading:a("Sign-in methods"),testId:"auth-config-signin",children:o("div",{className:"flex flex-col gap-2",children:[t(c,{label:a("Email & password"),value:m(l.emailAndPassword)}),t(c,{label:a("Social providers"),value:l.socialProviders.length===0?a("None"):t("span",{className:"flex flex-wrap justify-end gap-1",children:l.socialProviders.map(z)})})]})}),l.organization.enabled&&t(h,{heading:a("Organizations"),testId:"auth-config-org",children:o("div",{className:"flex flex-col gap-2",children:[t(c,{label:a("Teams"),value:m(l.organization.teams)}),t(c,{label:a("Custom roles"),value:m(l.organization.roles)})]})}),t(h,{heading:a("Session policy"),testId:"auth-config-session",children:o("div",{className:"flex flex-col gap-2",children:[t(c,{label:a("Expires in"),value:v(l.session.expiresIn)}),t(c,{label:a("Refresh after"),value:v(l.session.updateAge)}),t(c,{label:a("Fresh window"),value:v(l.session.freshAge)}),t(c,{label:a("Cookie cache"),value:m(l.session.cookieCache===!0)})]})}),t(h,{heading:a("Rate limit"),testId:"auth-config-ratelimit",children:o("div",{className:"flex flex-col gap-2",children:[t(c,{label:a("Status"),value:m(l.rateLimit.enabled)}),l.rateLimit.enabled&&o(y,{children:[t(c,{label:a("Max requests"),value:l.rateLimit.max??"—"}),t(c,{label:a("Window"),value:v(l.rateLimit.window)})]})]})}),l.userFields.length>0&&t(h,{heading:a("Plugin user fields"),testId:"auth-config-user-fields",children:t("ul",{className:"flex flex-col gap-2",children:l.userFields.map(r=>o("li",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs","data-testid":`auth-config-user-field-${r.name}`,children:[o("span",{className:"flex flex-col",children:[t("span",{className:"font-mono text-xs",children:r.name}),r.plugin!==void 0&&t("span",{className:"text-[11px] text-muted-foreground",children:r.plugin})]}),o("span",{className:"flex items-center gap-1",children:[t(x,{variant:"outline",children:r.type}),r.required&&t(x,{variant:"secondary",children:a("required")}),r.unique&&t(x,{variant:"secondary",children:a("unique")})]})]},r.name))})}),t(w,{className:"gap-0 py-0",children:t("p",{className:"px-4 py-3 text-xs text-muted-foreground","data-testid":"auth-config-note",children:a("OAuth providers, email templates, and rate limits are configured at deploy time in the better-auth setup and aren't editable here. See the Mail tab for email output.")})})]}),e[11]=l,e[12]=n,e[13]=m,e[14]=a,e[15]=f):f=e[15];let b;return e[16]!==g||e[17]!==p||e[18]!==f?(b=o("div",{className:"flex flex-col gap-4","data-testid":"auth-config",children:[g,p,f]}),e[16]=g,e[17]=p,e[18]=f,e[19]=b):b=e[19],b};function P(e){return t(x,{"data-testid":`auth-config-plugin-${e}`,variant:"outline",children:e},e)}function z(e){return t(x,{"data-testid":`auth-config-provider-${e}`,variant:"outline",children:e},e)}export{M as AuthConfigPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as y}from"react/compiler-runtime";import{useLunora as b}from"@lunora/react";import{u as S}from"../packem_shared/button-BkCrNcAs.js";import{c as k,u as w}from"../packem_shared/card-CIDGUN6K.js";import{E as I}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as j,d as E,m as g,p as c,f as R,u as m}from"../packem_shared/table-DdJBrClo.js";import{O as T}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useAutoRefresh as _}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{useT as z}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{i as B,f as C}from"../packem_shared/internal-BSIsQVC6.js";import{jsx as s,jsxs as A}from"react/jsx-runtime";const v=200,Q=()=>{const e=y(21),a=b(),t=z();let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=["lunora-auth-sessions",v],e[0]=h):h=e[0];let u;e[1]!==a?(u=()=>a.listAuthSessions({limit:v}),e[1]=a,e[2]=u):u=e[2];const o=T(h,u),{error:p}=o,r=o.data?.rows??null;let f;e[3]!==o?(f=()=>{o.refetch()},e[3]=o,e[4]=f):f=e[4],_(f,!0);let x;e[5]!==a||e[6]!==o?(x=i=>{C((async()=>{await a.revokeAuthSession({sessionId:i}),o.refetch()})())},e[5]=a,e[6]=o,e[7]=x):x=e[7];const N=x;let n;e[8]!==p?(n=p!==null&&s("p",{className:"text-sm text-destructive","data-testid":"auth-sessions-error",role:"alert",children:p}),e[8]=p,e[9]=n):n=e[9];let l;e[10]!==r||e[11]!==t?(l=r!==null&&r.length===0&&s(I,{testId:"auth-sessions-empty",title:t("No active sessions.")}),e[10]=r,e[11]=t,e[12]=l):l=e[12];let d;e[13]!==N||e[14]!==r||e[15]!==t?(d=r!==null&&r.length>0&&s(k,{className:"overflow-hidden py-0",children:s(w,{className:"px-0",children:A(j,{"data-testid":"auth-sessions-table",children:[s(E,{children:A(g,{children:[s(c,{children:t("user")}),s(c,{children:t("expires")}),s(c,{children:t("ip")}),s(c,{children:t("user agent")}),s(c,{children:t("impersonated by")}),s(c,{"aria-label":t("Actions")})]})}),s(R,{children:r.map(i=>A(g,{"data-testid":`auth-session-${i.id}`,children:[s(m,{className:"font-mono text-xs",children:i.userId}),s(m,{className:"text-muted-foreground tabular-nums",children:B(i.expiresAt)}),s(m,{children:i.ipAddress??""}),s(m,{className:"max-w-40 truncate",children:i.userAgent??""}),s(m,{className:"font-mono text-xs",children:i.impersonatedBy??""}),s(m,{children:s(S,{"data-testid":`auth-session-revoke-${i.id}`,onClick:()=>{N(i.id)},size:"xs",type:"button",variant:"ghost",children:t("Revoke")})})]},i.id))})]})})}),e[13]=N,e[14]=r,e[15]=t,e[16]=d):d=e[16];let $;return e[17]!==n||e[18]!==l||e[19]!==d?($=A("div",{className:"flex flex-col gap-4","data-testid":"auth-sessions",children:[n,l,d]}),e[17]=n,e[18]=l,e[19]=d,e[20]=$):$=e[20],$};export{Q as AuthSessionsPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as $}from"react/compiler-runtime";import{L as w}from"../packem_shared/live-status-CmuRLFKf.js";import{g as C}from"../packem_shared/badge-BbuuAio7.js";import{c as S,u as b}from"../packem_shared/card-CIDGUN6K.js";import{E}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as I,d as L,m as y,p as l,f as D,u as m}from"../packem_shared/table-DdJBrClo.js";import{N as k}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as A}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as O}from"../packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js";import{jsx as n,jsxs as h}from"react/jsx-runtime";const N="container:",T={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},_=e=>{const t=e.indexOf(":");if(t===-1)return{event:e.trim()};const r=e.slice(t+1).trim(),a=e.slice(0,t).trim();return r===""?{event:a}:{detail:r,event:a}},j=e=>{const t=new Map;for(const r of e){const a=r.functionPath??"";if(!a.startsWith(N))continue;const i=a.slice(N.length);if(i==="")continue;const s=JSON.stringify([i,r.instance??""]),o=t.get(s);if(o!==void 0&&o.timestamp>=r.timestamp)continue;const{detail:p,event:c}=_(r.message);t.set(s,{detail:p,event:c,exitCode:r.exitCode,instance:r.instance,level:r.level,name:i,state:T[c]??"unknown",timestamp:r.timestamp})}return[...t.values()].toSorted((r,a)=>r.name.localeCompare(a.name)||(r.instance??"").localeCompare(a.instance??""))},M={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},P=e=>{const{entries:t}=e??{};return Array.isArray(t)?t:[]},H=()=>{const e=$(19),t=A();let r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},a={live:!0,shardKey:""},e[0]=r,e[1]=a):(r=e[0],a=e[1]);const{data:i,error:s,liveError:o}=k(O.getLogs,r,a),p=i!==void 0;let c;if(e[2]!==i||e[3]!==s||e[4]!==o||e[5]!==p||e[6]!==t){const g=j(P(i));let x;e[8]!==s?(x=s!==null&&n("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:s}),e[8]=s,e[9]=x):x=e[9];let d;e[10]!==t?(d=t("Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per instance — ports and health checks aren't carried in that stream."),e[10]=t,e[11]=d):d=e[11];let u;e[12]!==d?(u=n("p",{className:"text-sm text-muted-foreground",children:d}),e[12]=d,e[13]=u):u=e[13];let f;e[14]!==o?(f=n(w,{message:o,prefix:"containers"}),e[14]=o,e[15]=f):f=e[15];let v;e[16]!==u||e[17]!==f?(v=h("div",{className:"flex flex-wrap items-center gap-2",children:[u,f]}),e[16]=u,e[17]=f,e[18]=v):v=e[18],c=h("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[x,v,p&&g.length===0?n(E,{description:t("No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error."),testId:"containers-empty",title:t("No container activity")}):n(S,{className:"overflow-hidden py-0",children:n(b,{className:"px-0",children:h(I,{"data-testid":"containers-table",children:[n(L,{children:h(y,{children:[n(l,{children:t("Container")}),n(l,{children:t("Instance")}),n(l,{children:t("State")}),n(l,{children:t("Last event")}),n(l,{children:t("Detail")}),n(l,{children:t("Exit")}),n(l,{children:t("When")})]})}),n(D,{children:g.map(W)})]})})})]}),e[2]=i,e[3]=s,e[4]=o,e[5]=p,e[6]=t,e[7]=c}else c=e[7];return c};function W(e){return h(y,{"data-testid":`containers-row-${e.name}${e.instance===void 0?"":`-${e.instance}`}`,children:[n(m,{className:"font-mono text-xs",children:e.name}),n(m,{className:"max-w-40 truncate font-mono text-xs text-muted-foreground",title:e.instance,children:e.instance??"—"}),n(m,{children:n(C,{variant:M[e.state],children:e.state})}),n(m,{className:"font-mono text-xs text-muted-foreground",children:e.event}),n(m,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"—"}),n(m,{className:"font-mono text-xs tabular-nums text-muted-foreground",children:e.exitCode??"—"}),n(m,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]},`${e.name}/${e.instance??""}`)}export{H as ContainersPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as j}from"react/compiler-runtime";import{useState as z,useEffect as V}from"react";import{I as B}from"../packem_shared/result-chart-DzJOVsaw.js";import{A as D}from"../packem_shared/alert-CVcOFuDR.js";import{u as I}from"../packem_shared/button-BkCrNcAs.js";import{c as F,u as Q,f as U,n as Z}from"../packem_shared/card-CIDGUN6K.js";import{E as H}from"../packem_shared/empty-state-Cg7t_8qu.js";import{useT as T}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{u as J,n as P}from"../packem_shared/browser-storage-xjTyMKY0.js";import{useLunora as X}from"@lunora/react";import{ADMIN_FUNCTIONS as G}from"../packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js";import{d as Y,b as ee,f as te,g as le}from"../packem_shared/internal-BSIsQVC6.js";import{jsx as m,jsxs as _}from"react/jsx-runtime";const de=le(G.runSql),re=(A,e)=>{const t=j(11),c=X(),[l,d]=z(void 0),[s,r]=z(void 0),[a,$]=z(!0);let n;t[0]!==c||t[1]!==e||t[2]!==A?(n=async u=>{$(!0);try{const C=await c.query(de,{sql:A},Y(e));u.cancelled||(d(C),r(void 0))}catch(C){const E=C;u.cancelled||(d(void 0),r(ee(E)))}u.cancelled||$(!1)},t[0]=c,t[1]=e,t[2]=A,t[3]=n):n=t[3];const k=n;let y,S;t[4]!==k?(y=()=>{const u={cancelled:!1};return te(k(u)),()=>{u.cancelled=!0}},S=[k],t[4]=k,t[5]=y,t[6]=S):(y=t[5],S=t[6]),V(y,S);let h;return t[7]!==s||t[8]!==a||t[9]!==l?(h={error:s,loading:a,result:l},t[7]=s,t[8]=a,t[9]=l,t[10]=h):h=t[10],h},se="lunora-studio-dashboards",O={shardKey:"",sql:"",title:""},ie=A=>{const e=j(54),{onEdit:t,onRemove:c,widget:l}=A,d=T(),{error:s,loading:r,result:a}=re(l.sql,l.shardKey??"");let $;e[0]!==t||e[1]!==l.id?($=()=>{t(l.id)},e[0]=t,e[1]=l.id,e[2]=$):$=e[2];const n=$;let k;e[3]!==c||e[4]!==l.id?(k=()=>{c(l.id)},e[3]=c,e[4]=l.id,e[5]=k):k=e[5];const y=k,S=`dashboards-widget-${l.id}`;let h;e[6]!==l.title?(h=m(U,{className:"min-w-0 truncate",title:l.title,children:l.title}),e[6]=l.title,e[7]=h):h=e[7];let u;e[8]!==d?(u=d("Edit widget"),e[8]=d,e[9]=u):u=e[9];const C=`dashboards-widget-edit-${l.id}`;let E;e[10]!==d?(E=d("Edit widget"),e[10]=d,e[11]=E):E=e[11];let K;e[12]===Symbol.for("react.memo_cache_sentinel")?(K=m("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:m("path",{d:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"})}),e[12]=K):K=e[12];let N;e[13]!==n||e[14]!==u||e[15]!==C||e[16]!==E?(N=m(I,{"aria-label":u,"data-testid":C,onClick:n,size:"icon-xs",title:E,type:"button",variant:"ghost",children:K}),e[13]=n,e[14]=u,e[15]=C,e[16]=E,e[17]=N):N=e[17];let x;e[18]!==d?(x=d("Remove widget"),e[18]=d,e[19]=x):x=e[19];const R=`dashboards-widget-remove-${l.id}`;let g;e[20]!==d?(g=d("Remove widget"),e[20]=d,e[21]=g):g=e[21];let w;e[22]===Symbol.for("react.memo_cache_sentinel")?(w=m("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:m("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[22]=w):w=e[22];let f;e[23]!==y||e[24]!==x||e[25]!==R||e[26]!==g?(f=m(I,{"aria-label":x,"data-testid":R,onClick:y,size:"icon-xs",title:g,type:"button",variant:"ghost",children:w}),e[23]=y,e[24]=x,e[25]=R,e[26]=g,e[27]=f):f=e[27];let b;e[28]!==f||e[29]!==N?(b=_("div",{className:"flex shrink-0 items-center gap-1",children:[N,f]}),e[28]=f,e[29]=N,e[30]=b):b=e[30];let p;e[31]!==b||e[32]!==h?(p=_(Z,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[h,b]}),e[31]=b,e[32]=h,e[33]=p):p=e[33];let v;e[34]!==s||e[35]!==l.id?(v=s!==void 0&&m(D,{className:"font-mono text-xs",testId:`dashboards-widget-error-${l.id}`,variant:"destructive",children:s}),e[34]=s,e[35]=l.id,e[36]=v):v=e[36];let L;e[37]!==s||e[38]!==r||e[39]!==a||e[40]!==d||e[41]!==l.id?(L=s===void 0&&r&&a===void 0&&m("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${l.id}`,children:d("Running…")}),e[37]=s,e[38]=r,e[39]=a,e[40]=d,e[41]=l.id,e[42]=L):L=e[42];let i;e[43]!==s||e[44]!==a?(i=s===void 0&&a!==void 0&&m(B,{result:a}),e[43]=s,e[44]=a,e[45]=i):i=e[45];let o;e[46]!==v||e[47]!==L||e[48]!==i?(o=_(Q,{className:"min-h-32 py-2",children:[v,L,i]}),e[46]=v,e[47]=L,e[48]=i,e[49]=o):o=e[49];let q;return e[50]!==p||e[51]!==o||e[52]!==S?(q=_(F,{"data-testid":S,children:[p,o]}),e[50]=p,e[51]=o,e[52]=S,e[53]=q):q=e[53],q},ae=A=>{const e=j(58),{draft:t,editing:c,onCancel:l,onChange:d,onSubmit:s}=A,r=T();let a;e[0]!==t||e[1]!==d?(a=M=>{d({...t,title:M.target.value})},e[0]=t,e[1]=d,e[2]=a):a=e[2];const $=a;let n;e[3]!==t||e[4]!==d?(n=M=>{d({...t,sql:M.target.value})},e[3]=t,e[4]=d,e[5]=n):n=e[5];const k=n;let y;e[6]!==t||e[7]!==d?(y=M=>{d({...t,shardKey:M.target.value})},e[6]=t,e[7]=d,e[8]=y):y=e[8];const S=y;let h;e[9]!==s?(h=()=>{s()},e[9]=s,e[10]=h):h=e[10];const u=h;let C;e[11]!==t.sql||e[12]!==t.title?(C=t.title.trim()!==""&&t.sql.trim()!=="",e[11]=t.sql,e[12]=t.title,e[13]=C):C=e[13];const E=C;let K;e[14]!==r?(K=r("Widget title"),e[14]=r,e[15]=K):K=e[15];let N;e[16]!==r?(N=r("Widget title"),e[16]=r,e[17]=N):N=e[17];let x;e[18]!==t.title||e[19]!==$||e[20]!==K||e[21]!==N?(x=m("input",{"aria-label":K,className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-title",onChange:$,placeholder:N,type:"text",value:t.title}),e[18]=t.title,e[19]=$,e[20]=K,e[21]=N,e[22]=x):x=e[22];let R;e[23]!==r?(R=r("SQL query"),e[23]=r,e[24]=R):R=e[24];let g;e[25]!==t.sql||e[26]!==k||e[27]!==R?(g=m("textarea",{"aria-label":R,className:"min-h-24 resize-y rounded-md border border-border bg-background p-2 font-mono text-xs leading-5 outline-none focus-visible:border-ring","data-testid":"dashboards-form-sql",onChange:k,placeholder:"SELECT author, COUNT(*) AS messages FROM …",spellCheck:!1,value:t.sql}),e[25]=t.sql,e[26]=k,e[27]=R,e[28]=g):g=e[28];let w;e[29]!==r?(w=r("Shard key (optional)"),e[29]=r,e[30]=w):w=e[30];let f;e[31]!==r?(f=r("Shard key (optional)"),e[31]=r,e[32]=f):f=e[32];let b;e[33]!==t.shardKey||e[34]!==S||e[35]!==w||e[36]!==f?(b=m("input",{"aria-label":w,className:"h-8 rounded-md border border-border bg-background px-2 font-mono text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-shard",onChange:S,placeholder:f,type:"text",value:t.shardKey}),e[33]=t.shardKey,e[34]=S,e[35]=w,e[36]=f,e[37]=b):b=e[37];let p;e[38]!==r?(p=r("Cancel"),e[38]=r,e[39]=p):p=e[39];let v;e[40]!==l||e[41]!==p?(v=m(I,{"data-testid":"dashboards-form-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:p}),e[40]=l,e[41]=p,e[42]=v):v=e[42];const L=!E;let i;e[43]!==c||e[44]!==r?(i=r(c?"Save widget":"Add widget"),e[43]=c,e[44]=r,e[45]=i):i=e[45];let o;e[46]!==u||e[47]!==L||e[48]!==i?(o=m(I,{"data-testid":"dashboards-form-save",disabled:L,onClick:u,size:"sm",type:"button",children:i}),e[46]=u,e[47]=L,e[48]=i,e[49]=o):o=e[49];let q;e[50]!==v||e[51]!==o?(q=_("div",{className:"flex items-center justify-end gap-2",children:[v,o]}),e[50]=v,e[51]=o,e[52]=q):q=e[52];let W;return e[53]!==g||e[54]!==b||e[55]!==q||e[56]!==x?(W=m(F,{"data-testid":"dashboards-form",children:_(Q,{className:"flex flex-col gap-3 py-4",children:[x,g,b,q]})}),e[53]=g,e[54]=b,e[55]=q,e[56]=x,e[57]=W):W=e[57],W},we=A=>{const e=j(39),{initialShardKey:t}=A,c=T(),[l,d]=J(se),[s,r]=z(O),[a,$]=z(null),[n,k]=z(!1);let y;e[0]!==t?(y=()=>{$(null),r({...O,shardKey:t??""}),k(!0)},e[0]=t,e[1]=y):y=e[1];const S=y;let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{k(!1),$(null),r(O)},e[2]=h):h=e[2];const u=h;let C;e[3]!==l?(C=i=>{const o=l.find(q=>q.id===i);o!==void 0&&($(i),r({shardKey:o.shardKey??"",sql:o.sql,title:o.title}),k(!0))},e[3]=l,e[4]=C):C=e[4];const E=C;let K;e[5]!==d?(K=i=>{d(o=>o.filter(q=>q.id!==i))},e[5]=d,e[6]=K):K=e[6];const N=K;let x;e[7]!==s.shardKey||e[8]!==s.sql||e[9]!==s.title||e[10]!==a||e[11]!==d?(x=()=>{const i=s.title.trim(),o=s.sql.trim();if(i===""||o==="")return;const q=s.shardKey.trim();d(a===null?W=>[...W,{id:P("w"),shardKey:q,sql:o,title:i}]:W=>W.map(M=>M.id===a?{...M,shardKey:q,sql:o,title:i}:M)),u()},e[7]=s.shardKey,e[8]=s.sql,e[9]=s.title,e[10]=a,e[11]=d,e[12]=x):x=e[12];const R=x;let g;e[13]!==c?(g=c("Chart widgets backed by saved read-only SQL queries."),e[13]=c,e[14]=g):g=e[14];let w;e[15]!==g?(w=m("p",{className:"text-sm text-muted-foreground",children:g}),e[15]=g,e[16]=w):w=e[16];let f;e[17]!==n||e[18]!==S||e[19]!==c?(f=!n&&m(I,{"data-testid":"dashboards-add",onClick:S,size:"sm",type:"button",children:c("Add widget")}),e[17]=n,e[18]=S,e[19]=c,e[20]=f):f=e[20];let b;e[21]!==w||e[22]!==f?(b=_("div",{className:"flex items-center justify-between",children:[w,f]}),e[21]=w,e[22]=f,e[23]=b):b=e[23];let p;e[24]!==s||e[25]!==a||e[26]!==n||e[27]!==R?(p=n&&m(ae,{draft:s,editing:a!==null,onCancel:u,onChange:r,onSubmit:R}),e[24]=s,e[25]=a,e[26]=n,e[27]=R,e[28]=p):p=e[28];let v;e[29]!==n||e[30]!==E||e[31]!==N||e[32]!==c||e[33]!==l?(v=l.length===0&&!n?m(H,{description:c("Add a widget to chart a saved SQL query on this browser."),testId:"dashboards-empty",title:c("No widgets yet")}):m("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:l.map(i=>m(ie,{onEdit:E,onRemove:N,widget:i},i.id))}),e[29]=n,e[30]=E,e[31]=N,e[32]=c,e[33]=l,e[34]=v):v=e[34];let L;return e[35]!==p||e[36]!==v||e[37]!==b?(L=_("div",{className:"flex flex-col gap-4","data-testid":"lunora-dashboards",children:[b,p,v]}),e[35]=p,e[36]=v,e[37]=b,e[38]=L):L=e[38],L};export{we as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as P}from"react/compiler-runtime";import{useState as A}from"react";import{E as K}from"../packem_shared/error-alert-t6cpEi0z.js";import{ShardInput as L}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as M}from"../packem_shared/badge-BbuuAio7.js";import{c as _}from"../packem_shared/card-CIDGUN6K.js";import{E as W}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as B,d as H,m as j,p as T,f as O,u as D}from"../packem_shared/table-DdJBrClo.js";import{N as U}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useAutoRefresh as V}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import X from"../packem_shared/useDebounced-Ihdiid_k.js";import{useT as Y}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as q}from"../packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js";import{jsx as s,jsxs as x,Fragment as z}from"react/jsx-runtime";const E=i=>`${i.toString()} ms`,G=i=>i.totalConnections===0&&i.shapePoke.passes===0&&i.whisper.passes===0,R=i=>{const e=P(8),{label:r,testId:t,value:l}=i;let o;e[0]!==r?(o=s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r}),e[0]=r,e[1]=o):o=e[1];let n;e[2]!==t||e[3]!==l?(n=s("span",{className:"truncate text-2xl font-semibold tabular-nums text-foreground","data-testid":t,children:l}),e[2]=t,e[3]=l,e[4]=n):n=e[4];let h;return e[5]!==o||e[6]!==n?(h=s(_,{className:"gap-0 py-0",children:x("div",{className:"flex flex-col gap-2.5 p-4",children:[o,n]})}),e[5]=o,e[6]=n,e[7]=h):h=e[7],h},F=i=>{const e=P(48),{counters:r,includeTiming:t,prefix:l,t:o,title:n}=i,h=`${l}-section`;let g;e[0]!==n?(g=s("h3",{className:"text-sm font-medium text-foreground",children:n}),e[0]=n,e[1]=g):g=e[1];const N=`${l}-stats`;let a;e[2]!==o?(a=o("Passes"),e[2]=o,e[3]=a):a=e[3];const c=`${l}-passes`;let v;e[4]!==r.passes||e[5]!==a||e[6]!==c?(v=s(R,{label:a,testId:c,value:r.passes}),e[4]=r.passes,e[5]=a,e[6]=c,e[7]=v):v=e[7];let $;e[8]!==o?($=o("Sockets iterated"),e[8]=o,e[9]=$):$=e[9];const I=`${l}-iterated`;let d;e[10]!==r.socketsIterated||e[11]!==$||e[12]!==I?(d=s(R,{label:$,testId:I,value:r.socketsIterated}),e[10]=r.socketsIterated,e[11]=$,e[12]=I,e[13]=d):d=e[13];let m;e[14]!==o?(m=o("Delivered"),e[14]=o,e[15]=m):m=e[15];const y=`${l}-delivered`;let u;e[16]!==r.socketsDelivered||e[17]!==m||e[18]!==y?(u=s(R,{label:m,testId:y,value:r.socketsDelivered}),e[16]=r.socketsDelivered,e[17]=m,e[18]=y,e[19]=u):u=e[19];let p;e[20]!==o?(p=o("Peak width"),e[20]=o,e[21]=p):p=e[21];const b=`${l}-peak`;let f;e[22]!==r.peakSocketsIterated||e[23]!==p||e[24]!==b?(f=s(R,{label:p,testId:b,value:r.peakSocketsIterated}),e[22]=r.peakSocketsIterated,e[23]=p,e[24]=b,e[25]=f):f=e[25];let k;e[26]!==r.totalMs||e[27]!==t||e[28]!==l||e[29]!==o?(k=t&&s(R,{label:o("Total time"),testId:`${l}-total-ms`,value:E(r.totalMs)}),e[26]=r.totalMs,e[27]=t,e[28]=l,e[29]=o,e[30]=k):k=e[30];let S;e[31]!==r.maxMs||e[32]!==t||e[33]!==l||e[34]!==o?(S=t&&s(R,{label:o("Max time"),testId:`${l}-max-ms`,value:E(r.maxMs)}),e[31]=r.maxMs,e[32]=t,e[33]=l,e[34]=o,e[35]=S):S=e[35];let C;e[36]!==u||e[37]!==f||e[38]!==k||e[39]!==S||e[40]!==N||e[41]!==v||e[42]!==d?(C=x("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":N,children:[v,d,u,f,k,S]}),e[36]=u,e[37]=f,e[38]=k,e[39]=S,e[40]=N,e[41]=v,e[42]=d,e[43]=C):C=e[43];let w;return e[44]!==h||e[45]!==C||e[46]!==g?(w=x("section",{className:"flex flex-col gap-2","data-testid":h,children:[g,C]}),e[44]=h,e[45]=C,e[46]=g,e[47]=w):w=e[47],w},ue=i=>{const e=P(32),{initialShardKey:r}=i,t=Y(),[l,o]=A(r??"");let n;e[0]!==l?(n=l.trim(),e[0]=l,e[1]=n):n=e[1];const h=X(n,400);let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g={},e[2]=g):g=e[2];let N;e[3]!==h?(N={keepPreviousData:!0,shardKey:h},e[3]=h,e[4]=N):N=e[4];const{data:a,error:c,errorSource:v,refetch:$}=U(q.getFanoutMetrics,g,N);V($,!0);let I;e[5]!==a?(I=a!==void 0&&G(a),e[5]=a,e[6]=I):I=e[6];const d=I;let m;e[7]!==l?(m=s(L,{onChange:o,testId:"fanout-shard-input",value:l}),e[7]=l,e[8]=m):m=e[8];let y;e[9]!==a||e[10]!==t?(y=a!==void 0&&x("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"fanout-count",children:[a.promoted&&s(M,{"data-testid":"fanout-promoted",variant:a.relayCount>=a.maxRelays?"destructive":"default",children:a.relayCount>=a.maxRelays?t("auto-scaled: {relayCount}/{maxRelays} relays (at ceiling)",{maxRelays:a.maxRelays,relayCount:a.relayCount}):t("auto-scaled: {relayCount}/{maxRelays} relays",{maxRelays:a.maxRelays,relayCount:a.relayCount})}),s(M,{variant:"secondary",children:t("{count} connections",{count:a.totalConnections})}),s(M,{variant:"secondary",children:t("peak {count} subscribers",{count:a.peakSubscribers})})]}),e[9]=a,e[10]=t,e[11]=y):y=e[11];let u;e[12]!==m||e[13]!==y?(u=x("div",{className:"flex flex-wrap items-center gap-2",children:[m,y]}),e[12]=m,e[13]=y,e[14]=u):u=e[14];let p;e[15]!==c||e[16]!==v?(p=c!==null&&s(K,{error:v,testId:"fanout-error"}),e[15]=c,e[16]=v,e[17]=p):p=e[17];let b;e[18]!==c||e[19]!==d||e[20]!==t?(b=c===null&&d&&s(W,{description:t("Realtime fan-out cost and per-topic subscriber counts for this shard."),icon:s("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:s("path",{d:"M4 12h4l3 7 4-14 3 7h2"})}),testId:"fanout-empty",title:t("No fan-out activity yet.")}),e[18]=c,e[19]=d,e[20]=t,e[21]=b):b=e[21];let f;e[22]!==c||e[23]!==d||e[24]!==a||e[25]!==t?(f=c===null&&a!==void 0&&!d&&x(z,{children:[a.topics.length>0&&x("section",{className:"flex flex-col gap-2","data-testid":"fanout-topics-section",children:[s("h3",{className:"text-sm font-medium text-foreground",children:t("Hot topics")}),s(_,{className:"overflow-hidden py-0",children:x(B,{"data-testid":"fanout-topics-table",children:[s(H,{children:x(j,{children:[s(T,{children:t("Topic")}),s(T,{children:t("Kind")}),s(T,{className:"text-right",children:t("Subscribers")})]})}),s(O,{children:a.topics.map(J)})]})})]}),x("section",{className:"flex flex-col gap-3","data-testid":"fanout-cost",children:[s("h2",{className:"text-sm font-medium text-muted-foreground",children:t("Fan-out cost since this instance woke")}),s(F,{counters:a.shapePoke,includeTiming:!0,prefix:"fanout-poke",t,title:t("Shape pokes")}),s(F,{counters:a.whisper,includeTiming:!1,prefix:"fanout-whisper",t,title:t("Whisper broadcasts")})]})]}),e[22]=c,e[23]=d,e[24]=a,e[25]=t,e[26]=f):f=e[26];let k;return e[27]!==f||e[28]!==u||e[29]!==p||e[30]!==b?(k=x("div",{className:"flex flex-col gap-4","data-testid":"fanout-panel",children:[u,p,b,f]}),e[27]=f,e[28]=u,e[29]=p,e[30]=b,e[31]=k):k=e[31],k};function J(i){return x(j,{"data-testid":"fanout-topic-row",children:[s(D,{className:"font-mono text-xs",children:i.topic}),s(D,{children:s(M,{variant:"outline",children:i.kind})}),s(D,{className:"text-right font-medium tabular-nums",children:i.subscribers})]},`${i.kind}:${i.topic}`)}export{ue as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useState as $}from"react";import{E as k}from"../packem_shared/error-alert-t6cpEi0z.js";import{g as w}from"../packem_shared/badge-BbuuAio7.js";import{c as A,u as F}from"../packem_shared/card-CIDGUN6K.js";import{E as u}from"../packem_shared/empty-state-Cg7t_8qu.js";import{p as O}from"../packem_shared/label-6uP1obNF.js";import{n as T,d as C,m as p,p as l,f as j,u as n}from"../packem_shared/table-DdJBrClo.js";import{l as E}from"../packem_shared/textarea-Bu2-jKAs.js";import{N as I}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as J}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as K}from"../packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js";import{jsx as e,jsxs as i}from"react/jsx-runtime";const L=a=>{const t=a.trim();if(t.length===0)return{context:void 0,error:null};try{const o=JSON.parse(t);return o===null||typeof o!="object"||Array.isArray(o)?{context:void 0,error:"Targeting context must be a JSON object."}:{context:o,error:null}}catch{return{context:void 0,error:"Targeting context is not valid JSON."}}},V='{ "targetingKey": "user-123", "plan": "premium" }',_=a=>a.type==="object"?JSON.stringify(a.value):String(a.value),X=({initialShardKey:a=""})=>{const t=J(),[o,h]=$(""),{context:c,error:f}=L(o),x=c===void 0?{}:{context:c},{data:s,error:v,errorSource:y,liveError:N}=I(K.listFlags,x,{live:!0,shardKey:a}),g=s!==void 0,b=s?.configured??!1,m=Array.isArray(s?.flags)?[...s.flags].toSorted((r,S)=>r.key.localeCompare(S.key)):[];let d;return g&&!b?d=e(u,{description:t("No @lunora/flags provider is wired in this deployment. Add lunora/flags.ts with defineFlags({ provider }) to gate code paths on feature flags."),testId:"flags-unconfigured",title:t("No flags provider configured")}):g&&m.length===0?d=e(u,{description:t('A flags provider is configured, but no handler reads a flag yet. Call ctx.flags.boolean("key", false) in a query, mutation, or action.'),testId:"flags-empty",title:t("No flags read")}):d=e(A,{className:"overflow-hidden py-0",children:e(F,{className:"px-0",children:i(T,{"data-testid":"flags-table",children:[e(C,{children:i(p,{children:[e(l,{children:t("Key")}),e(l,{children:t("Type")}),e(l,{children:t("Value")}),e(l,{children:t("Reason")}),e(l,{children:t("Variant")})]})}),e(j,{children:m.map(r=>i(p,{"data-testid":`flags-row-${r.key}`,children:[e(n,{className:"font-mono text-xs",children:r.key}),e(n,{className:"font-mono text-xs text-muted-foreground",children:r.type}),e(n,{className:"font-mono text-xs",children:_(r)}),e(n,{children:r.errorCode===void 0?e("span",{className:"font-mono text-xs text-muted-foreground",children:r.reason??"—"}):e(w,{"data-testid":`flags-error-${r.key}`,variant:"destructive",children:r.errorCode})}),e(n,{className:"font-mono text-xs text-muted-foreground",children:r.variant??"—"})]},r.key))})]})})}),i("div",{className:"flex flex-col gap-6","data-testid":"lunora-flags-panel",children:[v!==null&&e(k,{error:y,testId:"flags-error"}),e("p",{className:"text-sm text-muted-foreground",children:t('Feature flags are read in code with ctx.flags.<type>("key", default). They evaluate through the OpenFeature provider configured in lunora/flags.ts; edit the targeting context below to see how each flag resolves for a given audience.')}),i("div",{className:"flex flex-col gap-2",children:[e(O,{htmlFor:"flags-targeting-context",children:t("Targeting context (JSON)")}),e(E,{className:"font-mono text-xs","data-testid":"flags-context-input",id:"flags-targeting-context",onChange:r=>{h(r.target.value)},placeholder:V,rows:3,value:o}),f!==null&&e("p",{className:"text-xs text-destructive","data-testid":"flags-context-error",role:"alert",children:t(f)}),N!==void 0&&e("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"flags-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")})]}),d]})};export{X as FlagsPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as xe}from"react/compiler-runtime";import{findIssueSolution as Ie,flattenHint as Se}from"@lunora/errors";import{useLunora as $e}from"@lunora/react";import{useState as re}from"react";import{L as ke}from"../packem_shared/live-status-CmuRLFKf.js";import{ShardInput as Me}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as ge}from"../packem_shared/badge-BbuuAio7.js";import{u as oe}from"../packem_shared/button-BkCrNcAs.js";import{c as Ae,u as Ce}from"../packem_shared/card-CIDGUN6K.js";import{E as Te}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as _e}from"../packem_shared/input-JHu63lTv.js";import{N as Ee,y as Ke,_ as Le,k as be,w as Re}from"../packem_shared/select-Bul-DeII.js";import{n as ze,d as Fe,m as ve,p as q,f as Ve,u as j}from"../packem_shared/table-DdJBrClo.js";import{N as We}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{u as je}from"../packem_shared/use-async-submit-q3ymBJkD.js";import qe from"../packem_shared/useDebounced-Ihdiid_k.js";import{useT as ye}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as le}from"../packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js";import{i as De,f as ne,g as de,d as we,b as Oe}from"../packem_shared/internal-BSIsQVC6.js";import{jsx as s,jsxs as I,Fragment as Be}from"react/jsx-runtime";const fe="none",Ge=["all","open","resolved","ignored"],Ue=["critical","high","medium","low"],He=de(le.resolveIssue),Je=de(le.ignoreIssue),Ne=de(le.assignIssue),Pe=de(le.setIssueSeverity),Qe=de(le.explainIssue),Xe=n=>Array.isArray(n?.issues)?n.issues:[],Ye=n=>n==="resolved"?"success":n==="ignored"?"secondary":"warning",Ze=n=>n==="critical"?"destructive":n==="high"?"warning":n==="medium"?"info":"secondary",et=n=>{const e=xe(44),{expanded:o,issue:t,shardKey:S}=n,i=$e(),l=ye(),[a,C]=re(void 0),{busy:T,error:_,run:F}=je();let E;e[0]!==i||e[1]!==t||e[2]!==F||e[3]!==S?(E=()=>{C(void 0),F(async()=>{const g={culprit:t.culprit,sampleMessage:t.sampleMessage,title:t.title},w=await i.query(Qe,g,we(S));C(w)})},e[0]=i,e[1]=t,e[2]=F,e[3]=S,e[4]=E):E=e[4];const K=E;if(!o)return null;let d;if(e[5]!==t.sampleMessage){const g=Ie(t.sampleMessage);d=g===void 0?void 0:Se(g.body),e[5]=t.sampleMessage,e[6]=d}else d=e[6];const M=d,L=`issues-detail-${t.hash}`;let h;e[7]!==t.sampleMessage?(h=s("p",{className:"whitespace-pre-wrap font-mono text-xs text-muted-foreground",children:t.sampleMessage}),e[7]=t.sampleMessage,e[8]=h):h=e[8];let f;e[9]!==l?(f=l("Suggested fix"),e[9]=l,e[10]=f):f=e[10];let v;e[11]!==f?(v=s("div",{className:"text-xs font-medium text-muted-foreground",children:f}),e[11]=f,e[12]=v):v=e[12];let N;e[13]!==M||e[14]!==t.hash||e[15]!==l?(N=M===void 0?s("p",{className:"mt-1 text-sm text-muted-foreground","data-testid":`issues-hint-empty-${t.hash}`,children:l("No known fix for this error yet.")}):s("p",{className:"mt-1 whitespace-pre-wrap text-sm","data-testid":`issues-hint-${t.hash}`,children:M}),e[13]=M,e[14]=t.hash,e[15]=l,e[16]=N):N=e[16];let c;e[17]!==v||e[18]!==N?(c=I("div",{children:[v,N]}),e[17]=v,e[18]=N,e[19]=c):c=e[19];const A=`issues-explain-${t.hash}`;let u;e[20]!==T||e[21]!==l?(u=l(T?"Explaining…":"Explain in plain language"),e[20]=T,e[21]=l,e[22]=u):u=e[22];let $;e[23]!==T||e[24]!==K||e[25]!==u||e[26]!==A?($=s("div",{children:s(oe,{"data-testid":A,disabled:T,onClick:K,size:"sm",type:"button",variant:"outline",children:u})}),e[23]=T,e[24]=K,e[25]=u,e[26]=A,e[27]=$):$=e[27];let m;e[28]!==_||e[29]!==t.hash?(m=_!==null&&s("p",{className:"text-xs text-destructive","data-testid":`issues-explain-error-${t.hash}`,role:"alert",children:_}),e[28]=_,e[29]=t.hash,e[30]=m):m=e[30];let x;e[31]!==a||e[32]!==t.hash||e[33]!==l?(x=a!==void 0&&(a.degraded?s("p",{className:"text-xs text-muted-foreground","data-testid":`issues-degraded-${t.hash}`,children:a.reason==="no-ai-binding"?l("No AI binding is configured. Wire an AI binding to enable plain-language explanations — the suggested fix above is always available."):l("The AI model could not explain this error right now. The suggested fix above still applies.")}):I("div",{"data-testid":`issues-explanation-${t.hash}`,children:[s("div",{className:"text-xs font-medium text-muted-foreground",children:l("AI explanation")}),s("p",{className:"mt-1 whitespace-pre-wrap text-sm",children:a.explanation}),a.groundedId===void 0&&s("p",{className:"mt-1 text-xs text-muted-foreground","data-testid":`issues-ungrounded-${t.hash}`,children:l("No catalog fix matched this error, so this explanation is the model's own reading of the message. Verify before acting on it.")}),s("p",{className:"mt-1 text-[0.7rem] text-muted-foreground",children:l("Generated by {model}",{model:a.model})})]})),e[31]=a,e[32]=t.hash,e[33]=l,e[34]=x):x=e[34];let p;e[35]!==$||e[36]!==m||e[37]!==x||e[38]!==h||e[39]!==c?(p=s(j,{className:"bg-muted/30",colSpan:7,children:I("div",{className:"flex flex-col gap-3 py-1",children:[h,c,$,m,x]})}),e[35]=$,e[36]=m,e[37]=x,e[38]=h,e[39]=c,e[40]=p):p=e[40];let b;return e[41]!==p||e[42]!==L?(b=s(ve,{"data-testid":L,children:p}),e[41]=p,e[42]=L,e[43]=b):b=e[43],b},tt=n=>{const e=xe(119),{busy:o,issue:t,rowError:S,runTriage:i,shardKey:l}=n,a=ye(),[C,T]=re(!1);let _;e[0]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{T(st)},e[0]=_):_=e[0];const F=_;let E;e[1]!==t.hash||e[2]!==i?(E=ie=>{const ce=ie===null||ie===fe?null:ie;ne(i(t.hash,Pe,{severity:ce}))},e[1]=t.hash,e[2]=i,e[3]=E):E=e[3];const K=E;let d;e[4]!==t.hash||e[5]!==i?(d=ie=>{if(ie.key!=="Enter")return;const ce=ie.currentTarget.value.trim();ne(i(t.hash,Ne,{assignee:ce===""?null:ce}))},e[4]=t.hash,e[5]=i,e[6]=d):d=e[6];const M=d,L=`issues-row-${t.hash}`;let h;e[7]!==a?(h=a("Toggle issue details"),e[7]=a,e[8]=h):h=e[8];const f=`issues-toggle-${t.hash}`,v=`mt-1 size-3 shrink-0 text-muted-foreground transition-transform ${C?"rotate-90":""}`;let N;e[9]===Symbol.for("react.memo_cache_sentinel")?(N=s("path",{d:"m9 6 6 6-6 6"}),e[9]=N):N=e[9];let c;e[10]!==v?(c=s("svg",{"aria-hidden":"true",className:v,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:N}),e[10]=v,e[11]=c):c=e[11];let A;e[12]!==t.title?(A=s("span",{className:"block truncate font-medium",title:t.title,children:t.title}),e[12]=t.title,e[13]=A):A=e[13];let u;e[14]!==t.culprit?(u=s("span",{className:"block truncate font-mono text-xs text-muted-foreground",title:t.culprit,children:t.culprit}),e[14]=t.culprit,e[15]=u):u=e[15];let $;e[16]!==A||e[17]!==u?($=I("span",{className:"min-w-0",children:[A,u]}),e[16]=A,e[17]=u,e[18]=$):$=e[18];let m;e[19]!==C||e[20]!==$||e[21]!==h||e[22]!==f||e[23]!==c?(m=I("button",{"aria-expanded":C,"aria-label":h,className:"flex w-full items-start gap-2 text-left","data-testid":f,onClick:F,type:"button",children:[c,$]}),e[19]=C,e[20]=$,e[21]=h,e[22]=f,e[23]=c,e[24]=m):m=e[24];let x;e[25]!==t.hash||e[26]!==S?(x=S!==void 0&&s("p",{className:"mt-1 text-xs text-destructive","data-testid":`issues-action-error-${t.hash}`,role:"alert",children:S}),e[25]=t.hash,e[26]=S,e[27]=x):x=e[27];let p;e[28]!==m||e[29]!==x?(p=I(j,{className:"max-w-80",children:[m,x]}),e[28]=m,e[29]=x,e[30]=p):p=e[30];const b=`issues-status-${t.hash}`;let g;e[31]!==t.status?(g=Ye(t.status),e[31]=t.status,e[32]=g):g=e[32];let w;e[33]!==t.status||e[34]!==b||e[35]!==g?(w=s(j,{children:s(ge,{"data-testid":b,variant:g,children:t.status})}),e[33]=t.status,e[34]=b,e[35]=g,e[36]=w):w=e[36];const z=t.severity??fe;let R;e[37]!==a?(R=a("Set severity"),e[37]=a,e[38]=R):R=e[38];const r=`issues-severity-${t.hash}`;let V;e[39]!==a?(V=a("—"),e[39]=a,e[40]=V):V=e[40];let W;e[41]!==t.severity||e[42]!==a?(W=t.severity===void 0?s("span",{className:"text-muted-foreground",children:a("—")}):s(ge,{variant:Ze(t.severity),children:t.severity}),e[41]=t.severity,e[42]=a,e[43]=W):W=e[43];let y;e[44]!==V||e[45]!==W?(y=s(Ee,{placeholder:V,children:W}),e[44]=V,e[45]=W,e[46]=y):y=e[46];let k;e[47]!==R||e[48]!==r||e[49]!==y?(k=s(Ke,{"aria-label":R,className:"h-7 w-[110px]","data-testid":r,children:y}),e[47]=R,e[48]=r,e[49]=y,e[50]=k):k=e[50];let D;e[51]===Symbol.for("react.memo_cache_sentinel")?(D=Ue.map(at),e[51]=D):D=e[51];let O;e[52]!==a?(O=a("Clear"),e[52]=a,e[53]=O):O=e[53];let B;e[54]!==O?(B=I(Le,{children:[D,s(be,{value:fe,children:O})]}),e[54]=O,e[55]=B):B=e[55];let G;e[56]!==o||e[57]!==K||e[58]!==z||e[59]!==k||e[60]!==B?(G=s(j,{children:I(Re,{disabled:o,onValueChange:K,value:z,children:[k,B]})}),e[56]=o,e[57]=K,e[58]=z,e[59]=k,e[60]=B,e[61]=G):G=e[61];let U;e[62]!==a?(U=a("Assignee"),e[62]=a,e[63]=U):U=e[63];const ue=`issues-assignee-${t.hash}`,me=t.assignee??"",pe=t.assignee??"";let H;e[64]!==a?(H=a("Unassigned"),e[64]=a,e[65]=H):H=e[65];let J;e[66]!==o||e[67]!==M||e[68]!==U||e[69]!==ue||e[70]!==me||e[71]!==pe||e[72]!==H?(J=s(j,{children:s(_e,{"aria-label":U,className:"h-7 w-32","data-testid":ue,defaultValue:me,disabled:o,onKeyDown:M,placeholder:H},pe)}),e[66]=o,e[67]=M,e[68]=U,e[69]=ue,e[70]=me,e[71]=pe,e[72]=H,e[73]=J):J=e[73];let P;e[74]!==t.count?(P=s(j,{className:"text-right",children:s(ge,{variant:"secondary",children:t.count})}),e[74]=t.count,e[75]=P):P=e[75];let Q;e[76]!==t.lastSeen?(Q=De(t.lastSeen),e[76]=t.lastSeen,e[77]=Q):Q=e[77];let X;e[78]!==Q?(X=s(j,{className:"text-xs tabular-nums text-muted-foreground",children:Q}),e[78]=Q,e[79]=X):X=e[79];let Y;e[80]!==o||e[81]!==t.hash||e[82]!==t.status||e[83]!==i||e[84]!==a?(Y=t.status!=="resolved"&&s(oe,{"data-testid":`issues-resolve-${t.hash}`,disabled:o,onClick:()=>{ne(i(t.hash,He,{}))},size:"xs",variant:"outline",children:a("Resolve")}),e[80]=o,e[81]=t.hash,e[82]=t.status,e[83]=i,e[84]=a,e[85]=Y):Y=e[85];let Z;e[86]!==o||e[87]!==t.hash||e[88]!==t.status||e[89]!==i||e[90]!==a?(Z=t.status!=="ignored"&&s(oe,{"data-testid":`issues-ignore-${t.hash}`,disabled:o,onClick:()=>{ne(i(t.hash,Je,{}))},size:"xs",variant:"ghost",children:a("Ignore")}),e[86]=o,e[87]=t.hash,e[88]=t.status,e[89]=i,e[90]=a,e[91]=Z):Z=e[91];let ee;e[92]!==o||e[93]!==t.assignee||e[94]!==t.hash||e[95]!==t.status||e[96]!==i||e[97]!==a?(ee=t.status!=="open"&&s(oe,{"data-testid":`issues-reopen-${t.hash}`,disabled:o,onClick:()=>{ne(i(t.hash,Ne,{assignee:t.assignee??null}))},size:"xs",variant:"ghost",children:a("Reopen")}),e[92]=o,e[93]=t.assignee,e[94]=t.hash,e[95]=t.status,e[96]=i,e[97]=a,e[98]=ee):ee=e[98];let te;e[99]!==Y||e[100]!==Z||e[101]!==ee?(te=s(j,{className:"text-right",children:I("div",{className:"flex justify-end gap-1",children:[Y,Z,ee]})}),e[99]=Y,e[100]=Z,e[101]=ee,e[102]=te):te=e[102];let se;e[103]!==p||e[104]!==w||e[105]!==G||e[106]!==J||e[107]!==P||e[108]!==X||e[109]!==L||e[110]!==te?(se=I(ve,{"data-testid":L,children:[p,w,G,J,P,X,te]}),e[103]=p,e[104]=w,e[105]=G,e[106]=J,e[107]=P,e[108]=X,e[109]=L,e[110]=te,e[111]=se):se=e[111];let ae;e[112]!==C||e[113]!==t||e[114]!==l?(ae=s(et,{expanded:C,issue:t,shardKey:l},t.sampleMessage),e[112]=C,e[113]=t,e[114]=l,e[115]=ae):ae=e[115];let he;return e[116]!==se||e[117]!==ae?(he=I(Be,{children:[se,ae]}),e[116]=se,e[117]=ae,e[118]=he):he=e[118],he},kt=n=>{const e=xe(38),{initialShardKey:o}=n,t=ye(),S=$e(),[i,l]=re(o??""),[a,C]=re("all"),[T,_]=re(it),[F,E]=re(rt);let K;e[0]!==i?(K=i.trim(),e[0]=i,e[1]=K):K=e[1];const d=qe(K,400);let M;e[2]!==a?(M=a==="all"?{}:{status:a},e[2]=a,e[3]=M):M=e[3];let L;e[4]!==d?(L={live:!0,shardKey:d},e[4]=d,e[5]=L):L=e[5];const{data:h,error:f,liveError:v}=We(le.getIssues,M,L),N=h!==void 0;let c;if(e[6]!==F||e[7]!==T||e[8]!==S||e[9]!==h||e[10]!==d||e[11]!==f||e[12]!==v||e[13]!==N||e[14]!==i||e[15]!==a||e[16]!==t){const A=Xe(h);let u;e[18]!==S||e[19]!==d?(u=async(r,V,W)=>{E(y=>{if(!y.has(r))return y;const k=new Map(y);return k.delete(r),k}),_(y=>new Set(y).add(r));try{await S.query(V,{...W,hash:r},we(d))}catch(y){const k=Oe(y);E(D=>new Map(D).set(r,k))}_(y=>{const k=new Set(y);return k.delete(r),k})},e[18]=S,e[19]=d,e[20]=u):u=e[20];const $=u;let m;e[21]!==t?(m=r=>t(r==="all"?"All":r==="open"?"Open":r==="resolved"?"Resolved":"Ignored"),e[21]=t,e[22]=m):m=e[22];const x=m;let p;e[23]!==f?(p=f!==null&&s("p",{className:"text-sm text-destructive","data-testid":"issues-error",role:"alert",children:f}),e[23]=f,e[24]=p):p=e[24];let b;e[25]!==i?(b=s(Me,{onChange:l,testId:"issues-shard-input",value:i}),e[25]=i,e[26]=b):b=e[26];let g;e[27]!==v?(g=s(ke,{message:v,prefix:"issues"}),e[27]=v,e[28]=g):g=e[28];let w;e[29]!==a||e[30]!==x?(w=Ge.map(r=>s(oe,{"data-active":a===r?"":void 0,"data-testid":`issues-filter-${r}`,onClick:()=>{C(r)},size:"xs",variant:a===r?"default":"outline",children:x(r)},r)),e[29]=a,e[30]=x,e[31]=w):w=e[31];let z;e[32]!==w?(z=s("div",{className:"ms-auto flex items-center gap-1","data-testid":"issues-status-filter",role:"group",children:w}),e[32]=w,e[33]=z):z=e[33];let R;e[34]!==z||e[35]!==b||e[36]!==g?(R=I("div",{className:"flex flex-wrap items-center gap-2",children:[b,g,z]}),e[34]=z,e[35]=b,e[36]=g,e[37]=R):R=e[37],c=I("div",{className:"flex flex-col gap-6","data-testid":"lunora-issues-panel",children:[p,R,N&&A.length===0?s(Te,{description:t("No grouped errors yet. When a function throws or a container crashes, matching errors fold into a single issue here."),testId:"issues-empty",title:t("No issues")}):s(Ae,{className:"overflow-hidden py-0",children:s(Ce,{className:"px-0",children:I(ze,{"data-testid":"issues-table",children:[s(Fe,{children:I(ve,{children:[s(q,{children:t("Issue")}),s(q,{children:t("Status")}),s(q,{children:t("Severity")}),s(q,{children:t("Assignee")}),s(q,{className:"text-right",children:t("Events")}),s(q,{children:t("Last seen")}),s(q,{className:"text-right",children:t("Actions")})]})}),s(Ve,{children:A.map(r=>s(tt,{busy:T.has(r.hash),issue:r,rowError:F.get(r.hash),runTriage:$,shardKey:d},r.hash))})]})})})]}),e[6]=F,e[7]=T,e[8]=S,e[9]=h,e[10]=d,e[11]=f,e[12]=v,e[13]=N,e[14]=i,e[15]=a,e[16]=t,e[17]=c}else c=e[17];return c};function st(n){return!n}function at(n){return s(be,{value:n,children:n},n)}function it(){return new Set}function rt(){return new Map}export{kt as IssuesPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useLunora as ee}from"@lunora/react";import{useState as Z,useReducer as ae,useEffect as le}from"react";import{c as ve,u as pe}from"../packem_shared/card-CIDGUN6K.js";import{E as Fe}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as ye,d as he,m as X,p as Y,f as ke,u as Q}from"../packem_shared/table-DdJBrClo.js";import{useT as q}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{f as z,b as H,k as Ke,c as ne}from"../packem_shared/internal-BSIsQVC6.js";import{u as B}from"../packem_shared/button-BkCrNcAs.js";import{f as de}from"../packem_shared/checkbox-StT4Gob6.js";import{u as re}from"../packem_shared/input-JHu63lTv.js";import{g as se,c as ie,N as oe,v as ce}from"../packem_shared/studio-q-C-acL7.js";import{c as te}from"react/compiler-runtime";import{p as G}from"../packem_shared/label-6uP1obNF.js";import{l as be}from"../packem_shared/textarea-Bu2-jKAs.js";import{N as Ee,y as Ve,k as Me,_ as Te,w as Ie}from"../packem_shared/select-Bul-DeII.js";import{jsx as r,jsxs as $,Fragment as fe}from"react/jsx-runtime";import{g as Oe}from"../packem_shared/badge-BbuuAio7.js";const _e=l=>{const e=l.trim();if(e==="")return;const d=Number(e);return Number.isFinite(d)&&d>0?Math.floor(d):void 0},Je=l=>l===void 0?"—":new Date(l*1e3).toISOString(),De=l=>new TextEncoder().encode(l).length,ge=l=>{if(l.trim()!=="")try{return JSON.stringify(JSON.parse(l),void 0,2)}catch{return}},xe=l=>{if(l.trim()==="")return!0;try{return JSON.parse(l),!0}catch{return!1}},Ne=[{key:"seconds",seconds:1},{key:"minutes",seconds:60},{key:"hours",seconds:3600},{key:"days",seconds:86400}],ue=(l,e)=>{const d=l.trim();if(d==="")return"";const c=Number(d),s=Ne.find(m=>m.key===e)?.seconds??1;return Number.isFinite(c)&&c>0?String(Math.round(c*s)):d},Ce=l=>{const e=l.trim();if(e==="")return!0;const d=Number(e);return Number.isInteger(d)&&d>=60},we=(l,e,d,c)=>{const s=_e(l.ttl);return{expiration:s===void 0?c:void 0,expirationTtl:s,key:e,metadata:l.metadata.trim()===""?void 0:JSON.parse(l.metadata),namespace:d,value:l.value}},$e=l=>{const e=te(60),{helper:d,id:c,invalid:s,onChange:m,testId:i}=l,t=q(),[a,v]=Z(""),[o,g]=Z("seconds");let b;e[0]!==m||e[1]!==o?(b=f=>{v(f.target.value),m(ue(f.target.value,o))},e[0]=m,e[1]=o,e[2]=b):b=e[2];const I=b;let E;e[3]!==a||e[4]!==m?(E=f=>{f!==null&&(g(f),m(ue(a,f)))},e[3]=a,e[4]=m,e[5]=E):E=e[5];const O=E;let p;e[6]!==t?(p=t("days"),e[6]=t,e[7]=p):p=e[7];let u;e[8]!==t?(u=t("hours"),e[8]=t,e[9]=u):u=e[9];let y;e[10]!==t?(y=t("minutes"),e[10]=t,e[11]=y):y=e[11];let x;e[12]!==t?(x=t("seconds"),e[12]=t,e[13]=x):x=e[13];let N;e[14]!==p||e[15]!==u||e[16]!==y||e[17]!==x?(N={days:p,hours:u,minutes:y,seconds:x},e[14]=p,e[15]=u,e[16]=y,e[17]=x,e[18]=N):N=e[18];const C=N;let k;e[19]!==t?(k=t("Expires after"),e[19]=t,e[20]=k):k=e[20];let w;e[21]!==c||e[22]!==k?(w=r(G,{className:"text-xs",htmlFor:c,children:k}),e[21]=c,e[22]=k,e[23]=w):w=e[23];let K;e[24]!==t?(K=t("No expiration"),e[24]=t,e[25]=K):K=e[25];let J;e[26]!==a||e[27]!==c||e[28]!==s||e[29]!==I||e[30]!==K||e[31]!==i?(J=r(re,{"aria-invalid":s,className:"flex-1","data-testid":i,id:c,inputMode:"numeric",onChange:I,placeholder:K,value:a}),e[26]=a,e[27]=c,e[28]=s,e[29]=I,e[30]=K,e[31]=i,e[32]=J):J=e[32];let V;e[33]!==t?(V=t("TTL unit"),e[33]=t,e[34]=V):V=e[34];const L=`${i}-unit`;let D;e[35]===Symbol.for("react.memo_cache_sentinel")?(D=r(Ee,{}),e[35]=D):D=e[35];let M;e[36]!==V||e[37]!==L?(M=r(Ve,{"aria-label":V,className:"w-[7.5rem]","data-testid":L,children:D}),e[36]=V,e[37]=L,e[38]=M):M=e[38];let n;e[39]!==C?(n=Ne.map(f=>r(Me,{value:f.key,children:C[f.key]},f.key)),e[39]=C,e[40]=n):n=e[40];let h;e[41]!==n?(h=r(Te,{children:n}),e[41]=n,e[42]=h):h=e[42];let S;e[43]!==O||e[44]!==M||e[45]!==h||e[46]!==o?(S=$(Ie,{onValueChange:O,value:o,children:[M,h]}),e[43]=O,e[44]=M,e[45]=h,e[46]=o,e[47]=S):S=e[47];let T;e[48]!==J||e[49]!==S?(T=$("div",{className:"flex gap-2",children:[J,S]}),e[48]=J,e[49]=S,e[50]=T):T=e[50];let F;e[51]!==d||e[52]!==s||e[53]!==t||e[54]!==i?(F=s?r("p",{className:"text-xs text-destructive","data-testid":`${i}-invalid`,children:t("TTL must be at least 60 seconds.")}):d!==void 0&&r("p",{className:"text-xs text-muted-foreground",children:d}),e[51]=d,e[52]=s,e[53]=t,e[54]=i,e[55]=F):F=e[55];let _;return e[56]!==T||e[57]!==F||e[58]!==w?(_=$("div",{className:"mb-3 grid gap-1",children:[w,T,F]}),e[56]=T,e[57]=F,e[58]=w,e[59]=_):_=e[59],_},Se=l=>{const e=te(36),{id:d,invalidTestId:c,onChange:s,testId:m,valid:i,value:t}=l,a=q();let v;e[0]!==t?(v=ge(t),e[0]=t,e[1]=v):v=e[1];const o=v;let g;e[2]!==a?(g=a("Metadata (JSON)"),e[2]=a,e[3]=g):g=e[3];let b;e[4]!==d||e[5]!==g?(b=r(G,{className:"text-xs",htmlFor:d,children:g}),e[4]=d,e[5]=g,e[6]=b):b=e[6];const I=`${m}-format`,E=o===void 0;let O;e[7]!==o||e[8]!==s?(O=()=>{o!==void 0&&s(o)},e[7]=o,e[8]=s,e[9]=O):O=e[9];let p;e[10]!==a?(p=a("Format JSON"),e[10]=a,e[11]=p):p=e[11];let u;e[12]!==I||e[13]!==E||e[14]!==O||e[15]!==p?(u=r(B,{"data-testid":I,disabled:E,onClick:O,size:"sm",variant:"outline",children:p}),e[12]=I,e[13]=E,e[14]=O,e[15]=p,e[16]=u):u=e[16];let y;e[17]!==b||e[18]!==u?(y=$("div",{className:"flex items-center justify-between gap-2",children:[b,u]}),e[17]=b,e[18]=u,e[19]=y):y=e[19];const x=!i;let N;e[20]!==s?(N=K=>{s(K.target.value)},e[20]=s,e[21]=N):N=e[21];let C;e[22]!==d||e[23]!==x||e[24]!==N||e[25]!==m||e[26]!==t?(C=r(be,{"aria-invalid":x,className:"min-h-[4rem] font-mono text-xs","data-testid":m,id:d,onChange:N,value:t}),e[22]=d,e[23]=x,e[24]=N,e[25]=m,e[26]=t,e[27]=C):C=e[27];let k;e[28]!==c||e[29]!==a||e[30]!==i?(k=!i&&r("p",{className:"text-xs text-destructive","data-testid":c,children:a("Metadata must be valid JSON.")}),e[28]=c,e[29]=a,e[30]=i,e[31]=k):k=e[31];let w;return e[32]!==C||e[33]!==k||e[34]!==y?(w=$("div",{className:"mb-3 grid gap-1",children:[y,C,k]}),e[32]=C,e[33]=k,e[34]=y,e[35]=w):w=e[35],w},Le={busy:!1,error:null,metadata:"",name:"",ttl:"",value:""},Be=(l,e)=>{switch(e.type){case"setField":return{...l,[e.field]:e.value};case"submitFailed":return{...l,busy:!1,error:e.error};case"submitStart":return{...l,busy:!0,error:null};default:return l}},Pe=l=>{const e=te(73),{namespace:d,onCancel:c,onCreated:s}=l,m=ee(),i=q(),[t,a]=ae(Be,Le);let v;e[0]!==t.metadata?(v=xe(t.metadata),e[0]=t.metadata,e[1]=v):v=e[1];const o=v;let g;e[2]!==t.ttl?(g=Ce(t.ttl),e[2]=t.ttl,e[3]=g):g=e[3];const b=g;let I;e[4]!==o||e[5]!==t.busy||e[6]!==t.name||e[7]!==b?(I=t.name.trim()!==""&&o&&b&&!t.busy,e[4]=o,e[5]=t.busy,e[6]=t.name,e[7]=b,e[8]=I):I=e[8];const E=I;let O;e[9]!==E||e[10]!==m||e[11]!==d||e[12]!==s||e[13]!==t.metadata||e[14]!==t.name||e[15]!==t.ttl||e[16]!==t.value?(O=()=>{E&&(a({type:"submitStart"}),z((async()=>{try{await m.putKvValue(we({metadata:t.metadata,ttl:t.ttl,value:t.value},t.name,d)),s()}catch(j){a({error:H(j),type:"submitFailed"})}})()))},e[9]=E,e[10]=m,e[11]=d,e[12]=s,e[13]=t.metadata,e[14]=t.name,e[15]=t.ttl,e[16]=t.value,e[17]=O):O=e[17];const p=O;let u;e[18]!==i?(u=i("Key name"),e[18]=i,e[19]=u):u=e[19];let y;e[20]!==u?(y=r(G,{className:"text-xs",htmlFor:"kv-create-name",children:u}),e[20]=u,e[21]=y):y=e[21];let x;e[22]===Symbol.for("react.memo_cache_sentinel")?(x=j=>{a({field:"name",type:"setField",value:j.target.value})},e[22]=x):x=e[22];let N;e[23]!==i?(N=i("Key name"),e[23]=i,e[24]=N):N=e[24];let C;e[25]!==t.name||e[26]!==N?(C=r(re,{autoFocus:!0,"data-testid":"kv-create-name",id:"kv-create-name",onChange:x,placeholder:N,value:t.name}),e[25]=t.name,e[26]=N,e[27]=C):C=e[27];let k;e[28]!==y||e[29]!==C?(k=$("div",{className:"grid gap-1",children:[y,C]}),e[28]=y,e[29]=C,e[30]=k):k=e[30];let w;e[31]!==i?(w=i("Value"),e[31]=i,e[32]=w):w=e[32];let K;e[33]!==w?(K=r(G,{className:"text-xs",htmlFor:"kv-create-value",children:w}),e[33]=w,e[34]=K):K=e[34];let J;e[35]===Symbol.for("react.memo_cache_sentinel")?(J=j=>{a({field:"value",type:"setField",value:j.target.value})},e[35]=J):J=e[35];let V;e[36]!==t.value?(V=r(be,{className:"min-h-[6rem] font-mono text-xs","data-testid":"kv-create-value",id:"kv-create-value",onChange:J,value:t.value}),e[36]=t.value,e[37]=V):V=e[37];let L;e[38]!==K||e[39]!==V?(L=$("div",{className:"grid gap-1",children:[K,V]}),e[38]=K,e[39]=V,e[40]=L):L=e[40];const D=!b;let M;e[41]===Symbol.for("react.memo_cache_sentinel")?(M=j=>{a({field:"ttl",type:"setField",value:j})},e[41]=M):M=e[41];let n;e[42]!==D?(n=r($e,{id:"kv-create-ttl",invalid:D,onChange:M,testId:"kv-create-ttl"}),e[42]=D,e[43]=n):n=e[43];let h;e[44]===Symbol.for("react.memo_cache_sentinel")?(h=j=>{a({field:"metadata",type:"setField",value:j})},e[44]=h):h=e[44];let S;e[45]!==o||e[46]!==t.metadata?(S=r(Se,{id:"kv-create-metadata",invalidTestId:"kv-create-metadata-invalid",onChange:h,testId:"kv-create-metadata",valid:o,value:t.metadata}),e[45]=o,e[46]=t.metadata,e[47]=S):S=e[47];const T=!E;let F;e[48]!==t.busy||e[49]!==i?(F=t.busy?i("Creating…"):i("Create key"),e[48]=t.busy,e[49]=i,e[50]=F):F=e[50];let _;e[51]!==p||e[52]!==T||e[53]!==F?(_=r(B,{"data-testid":"kv-create-submit",disabled:T,onClick:p,children:F}),e[51]=p,e[52]=T,e[53]=F,e[54]=_):_=e[54];const f=t.busy;let P;e[55]!==i?(P=i("Cancel"),e[55]=i,e[56]=P):P=e[56];let A;e[57]!==c||e[58]!==t.busy||e[59]!==P?(A=r(B,{"data-testid":"kv-create-cancel",disabled:f,onClick:c,variant:"outline",children:P}),e[57]=c,e[58]=t.busy,e[59]=P,e[60]=A):A=e[60];let R;e[61]!==_||e[62]!==A?(R=$("div",{className:"flex flex-wrap gap-2",children:[_,A]}),e[61]=_,e[62]=A,e[63]=R):R=e[63];let U;e[64]!==t.error?(U=t.error!==null&&r("p",{className:"text-sm text-destructive","data-testid":"kv-create-error",role:"alert",children:t.error}),e[64]=t.error,e[65]=U):U=e[65];let W;return e[66]!==k||e[67]!==L||e[68]!==n||e[69]!==S||e[70]!==R||e[71]!==U?(W=$("div",{className:"grid gap-3 px-4 pb-4","data-testid":"kv-create-form",children:[k,L,n,S,R,U]}),e[66]=k,e[67]=L,e[68]=n,e[69]=S,e[70]=R,e[71]=U,e[72]=W):W=e[72],W},je={busy:"",editedMetadata:"",editedTtl:"",editedValue:"",loadError:null,loading:!0,value:null,writeError:null},Ae=(l,e)=>{switch(e.type){case"deleteStart":return{...l,busy:"deleting",writeError:null};case"editMetadata":return{...l,editedMetadata:e.value};case"editTtl":return{...l,editedTtl:e.value};case"editValue":return{...l,editedValue:e.value};case"loaded":return{...l,editedMetadata:e.metadata===null||e.metadata===void 0?"":JSON.stringify(e.metadata,null,2),editedValue:e.value??"",loading:!1,value:e.value};case"loadFailed":return{...l,loadError:e.error,loading:!1};case"saveOk":return{...l,busy:"",value:l.editedValue};case"saveStart":return{...l,busy:"saving",writeError:null};case"writeFailed":return{...l,busy:"",writeError:e.error};default:return l}},ze=l=>{const e=te(67),{expiration:d,keyName:c,namespace:s,onDeleted:m}=l,i=ee(),t=q(),[a,v]=ae(Ae,je);let o,g;e[0]!==i||e[1]!==c||e[2]!==s?(o=()=>{const f={cancelled:!1};return z((async()=>{try{const P=await i.getKvValue({key:c,namespace:s});f.cancelled||v({metadata:P.metadata,type:"loaded",value:P.value})}catch(P){const A=P;f.cancelled||v({error:H(A),type:"loadFailed"})}})()),()=>{f.cancelled=!0}},g=[i,s,c],e[0]=i,e[1]=c,e[2]=s,e[3]=o,e[4]=g):(o=e[3],g=e[4]),le(o,g);let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=f=>{v({type:"editValue",value:f.target.value})},e[5]=b):b=e[5];const I=b;let E;e[6]===Symbol.for("react.memo_cache_sentinel")?(E=f=>{v({type:"editMetadata",value:f})},e[6]=E):E=e[6];const O=E;let p;e[7]!==a.editedValue?(p=ge(a.editedValue),e[7]=a.editedValue,e[8]=p):p=e[8];const u=p;let y;e[9]!==a.editedMetadata?(y=xe(a.editedMetadata),e[9]=a.editedMetadata,e[10]=y):y=e[10];const x=y;let N;e[11]!==a.editedTtl?(N=Ce(a.editedTtl),e[11]=a.editedTtl,e[12]=N):N=e[12];const C=N;let k;e[13]!==u?(k=()=>{u!==void 0&&v({type:"editValue",value:u})},e[13]=u,e[14]=k):k=e[14];const w=k;let K;e[15]!==i||e[16]!==d||e[17]!==c||e[18]!==x||e[19]!==s||e[20]!==a.editedMetadata||e[21]!==a.editedTtl||e[22]!==a.editedValue||e[23]!==t?(K=()=>{if(!x){v({error:t("Metadata must be valid JSON."),type:"writeFailed"});return}v({type:"saveStart"}),z((async()=>{try{await i.putKvValue(we({metadata:a.editedMetadata,ttl:a.editedTtl,value:a.editedValue},c,s,d)),v({type:"saveOk"})}catch(f){v({error:H(f),type:"writeFailed"})}})())},e[15]=i,e[16]=d,e[17]=c,e[18]=x,e[19]=s,e[20]=a.editedMetadata,e[21]=a.editedTtl,e[22]=a.editedValue,e[23]=t,e[24]=K):K=e[24];const J=K;let V;e[25]!==i||e[26]!==c||e[27]!==s||e[28]!==m?(V=()=>{v({type:"deleteStart"}),z((async()=>{try{await i.deleteKvKey({key:c,namespace:s}),m(c)}catch(f){v({error:H(f),type:"writeFailed"})}})())},e[25]=i,e[26]=c,e[27]=s,e[28]=m,e[29]=V):V=e[29];const L=V;let D;e[30]!==c?(D=()=>{ne(c)},e[30]=c,e[31]=D):D=e[31];let M;e[32]!==t?(M=t("Copy key"),e[32]=t,e[33]=M):M=e[33];let n;e[34]!==D||e[35]!==M?(n=r("div",{className:"mb-2 flex justify-end",children:r(B,{"data-testid":"kv-copy-key-btn",onClick:D,size:"sm",variant:"outline",children:M})}),e[34]=D,e[35]=M,e[36]=n):n=e[36];let h;e[37]!==a.loadError?(h=a.loadError!==null&&r("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-value-error",role:"alert",children:a.loadError}),e[37]=a.loadError,e[38]=h):h=e[38];let S;e[39]!==a.loading||e[40]!==t?(S=a.loading&&r("p",{className:"text-sm text-muted-foreground","data-testid":"kv-value-loading",children:t("Loading…")}),e[39]=a.loading,e[40]=t,e[41]=S):S=e[41];let T;e[42]!==u||e[43]!==x||e[44]!==L||e[45]!==w||e[46]!==J||e[47]!==a.busy||e[48]!==a.editedMetadata||e[49]!==a.editedValue||e[50]!==a.loading||e[51]!==a.value||e[52]!==a.writeError||e[53]!==t||e[54]!==C?(T=!a.loading&&a.value!==null&&$(fe,{children:[$("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[r(G,{className:"text-xs",htmlFor:"kv-value-editor",children:t("Value")}),u!==void 0&&r(Oe,{variant:"secondary",children:t("JSON")}),r("span",{className:"ml-auto text-xs tabular-nums text-muted-foreground","data-testid":"kv-value-size",children:Ke(De(a.editedValue))})]}),r("textarea",{"aria-label":t("KV value"),className:"mb-2 min-h-[8rem] w-full rounded border border-border bg-muted/30 p-2 font-mono text-xs","data-testid":"kv-value-editor",id:"kv-value-editor",onChange:I,value:a.editedValue}),$("div",{className:"mb-3 flex flex-wrap gap-2",children:[r(B,{"data-testid":"kv-format-btn",disabled:u===void 0,onClick:w,size:"sm",variant:"outline",children:t("Format JSON")}),r(B,{"data-testid":"kv-copy-value-btn",onClick:()=>{ne(a.editedValue)},size:"sm",variant:"outline",children:t("Copy value")})]}),r($e,{helper:t("Leave blank to keep the current expiration."),id:"kv-ttl-input",invalid:!C,onChange:f=>{v({type:"editTtl",value:f})},testId:"kv-ttl-input"}),r(Se,{id:"kv-metadata-editor",invalidTestId:"kv-metadata-invalid",onChange:O,testId:"kv-metadata-editor",valid:x,value:a.editedMetadata}),$("div",{className:"flex flex-wrap gap-2",children:[r(B,{"data-testid":"kv-save-btn",disabled:a.busy!==""||!x||!C,onClick:J,children:a.busy==="saving"?t("Saving…"):t("Save")}),r(B,{"data-testid":"kv-delete-btn",disabled:a.busy!=="",onClick:L,variant:"destructive",children:a.busy==="deleting"?t("Deleting…"):t("Delete")})]}),a.writeError!==null&&r("p",{className:"mt-2 text-sm text-destructive","data-testid":"kv-save-error",role:"alert",children:a.writeError})]}),e[42]=u,e[43]=x,e[44]=L,e[45]=w,e[46]=J,e[47]=a.busy,e[48]=a.editedMetadata,e[49]=a.editedValue,e[50]=a.loading,e[51]=a.value,e[52]=a.writeError,e[53]=t,e[54]=C,e[55]=T):T=e[55];let F;e[56]!==a.loadError||e[57]!==a.loading||e[58]!==a.value||e[59]!==t?(F=!a.loading&&a.value===null&&a.loadError===null&&r("p",{className:"text-sm text-muted-foreground","data-testid":"kv-absent",children:t("Key is absent or has no value.")}),e[56]=a.loadError,e[57]=a.loading,e[58]=a.value,e[59]=t,e[60]=F):F=e[60];let _;return e[61]!==n||e[62]!==h||e[63]!==S||e[64]!==T||e[65]!==F?(_=$("div",{className:"px-4 pb-4","data-testid":"kv-value-section",children:[n,h,S,T,F]}),e[61]=n,e[62]=h,e[63]=S,e[64]=T,e[65]=F,e[66]=_):_=e[66],_},me=100,He={appliedPrefix:"",bulk:[],bulkBusy:!1,bulkError:null,cursor:null,keys:null,listComplete:!1,loadError:null,loading:!1,prefixInput:"",reloadNonce:0,selectedKey:null},Re=(l,e)=>{switch(e.type){case"appendPage":return{...l,cursor:e.cursor,keys:[...l.keys??[],...e.keys],listComplete:e.listComplete,loading:!1};case"applyFilter":return{...l,appliedPrefix:l.prefixInput,bulk:[],bulkError:null,cursor:null,keys:null,listComplete:!1,selectedKey:null};case"bulkDeleted":{const d=new Set(e.deleted);return{...l,bulk:l.bulk.filter(c=>!d.has(c)),bulkBusy:!1,bulkError:e.error,keys:l.keys===null?null:l.keys.filter(c=>!d.has(c.name)),selectedKey:l.selectedKey!==null&&d.has(l.selectedKey)?null:l.selectedKey}}case"bulkDeleteStart":return{...l,bulkBusy:!0,bulkError:null};case"firstPage":return{...l,cursor:e.cursor,keys:e.keys,listComplete:e.listComplete,loading:!1};case"keyDeleted":return{...l,bulk:l.bulk.filter(d=>d!==e.name),keys:l.keys===null?null:l.keys.filter(d=>d.name!==e.name),selectedKey:null};case"loadFailed":return{...l,loadError:e.error,loading:!1};case"loadStart":return{...l,loadError:null,loading:!0};case"prefixInput":return{...l,prefixInput:e.value};case"reload":return{...l,bulk:[],bulkError:null,reloadNonce:l.reloadNonce+1,selectedKey:null};case"selectKey":return{...l,selectedKey:e.name};case"toggleAllBulk":return{...l,bulk:e.names};case"toggleBulk":return{...l,bulk:l.bulk.includes(e.name)?l.bulk.filter(d=>d!==e.name):[...l.bulk,e.name]};default:return l}},Ue=({namespace:l})=>{const e=ee(),d=q(),[c,s]=ae(Re,He),{appliedPrefix:m,bulk:i,bulkBusy:t,bulkError:a,cursor:v,keys:o,listComplete:g,loadError:b,loading:I,prefixInput:E,reloadNonce:O,selectedKey:p}=c,[u,y]=Z(!1);le(()=>{const n={cancelled:!1};return z((async()=>{s({type:"loadStart"});try{const h=await e.listKvKeys({limit:me,namespace:l,prefix:m===""?void 0:m});n.cancelled||s({cursor:h.cursor??null,keys:h.keys,listComplete:h.listComplete,type:"firstPage"})}catch(h){n.cancelled||s({error:H(h),type:"loadFailed"})}})()),()=>{n.cancelled=!0}},[e,l,m,O]);const x=n=>{s({type:"prefixInput",value:n.target.value})},N=()=>{s({type:"applyFilter"})},C=n=>{s({name:n.currentTarget.dataset.key??null,type:"selectKey"})},k=()=>{v!==null&&(s({type:"loadStart"}),z((async()=>{try{const n=await e.listKvKeys({cursor:v,limit:me,namespace:l,prefix:m===""?void 0:m});s({cursor:n.cursor??null,keys:n.keys,listComplete:n.listComplete,type:"appendPage"})}catch(n){s({error:H(n),type:"loadFailed"})}})()))},w=n=>{s({name:n,type:"keyDeleted"})},K=n=>{s({name:n,type:"toggleBulk"})},J=n=>{s({names:n&&o!==null?o.map(h=>h.name):[],type:"toggleAllBulk"})},V=()=>{if(i.length===0)return;const n=[...i];s({type:"bulkDeleteStart"}),z((async()=>{const h=await Promise.allSettled(n.map(F=>e.deleteKvKey({key:F,namespace:l}))),S=n.filter((F,_)=>h[_]?.status==="fulfilled"),T=n.length-S.length;s({deleted:S,error:T>0?d("Failed to delete {count} keys.",{count:T}):null,type:"bulkDeleted"})})())},L=()=>{y(!1),s({type:"reload"})},D=o!==null&&o.length>0&&i.length===o.length,M=new Set(i);return $(fe,{children:[$("section",{className:"border border-border bg-card p-3","data-testid":"kv-keys-section",children:[$("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[r(re,{"aria-label":d("Filter keys by prefix"),className:"min-w-[16rem] flex-1","data-testid":"kv-prefix-input",onChange:x,placeholder:d("Filter by prefix…"),value:E}),r(B,{"data-testid":"kv-filter-btn",disabled:I,onClick:N,children:d("Filter")}),r(B,{"data-testid":"kv-new-key-btn",onClick:()=>{y(n=>!n)},variant:"outline",children:d("New key")}),i.length>0&&r(B,{"data-testid":"kv-bulk-delete-btn",disabled:t,onClick:V,variant:"destructive",children:t?d("Deleting…"):d("Delete {count}",{count:i.length})})]}),a!==null&&r("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-bulk-error",role:"alert",children:a}),b!==null&&r("p",{className:"text-sm text-destructive","data-testid":"kv-keys-error",role:"alert",children:b}),o!==null&&o.length===0&&!I&&r("p",{className:"text-sm text-muted-foreground","data-testid":"kv-no-keys",children:d("No keys.")}),o!==null&&o.length>0&&r(ve,{className:"overflow-hidden py-0",children:r(pe,{className:"px-0",children:$(ye,{"data-testid":"kv-key-table",children:[r(he,{children:$(X,{children:[r(Y,{className:"w-10",children:r(de,{"aria-label":d("Select all"),checked:D,"data-testid":"kv-select-all",onCheckedChange:J})}),r(Y,{children:d("Key")}),r(Y,{children:d("Expiration")})]})}),r(ke,{children:o.map(n=>$(X,{className:n.name===p?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-key":n.name,"data-testid":`kv-key-row-${n.name}`,onClick:C,children:[r(Q,{onClick:h=>{h.stopPropagation()},children:r(de,{"aria-label":d("Select {name}",{name:n.name}),checked:M.has(n.name),"data-testid":`kv-select-${n.name}`,onCheckedChange:()=>{K(n.name)}})}),r(Q,{className:"font-mono text-xs",children:n.name}),r(Q,{className:"tabular-nums text-xs",children:Je(n.expiration)})]},n.name))})]})})}),!g&&v!==null&&r("div",{className:"mt-2",children:r(B,{"data-testid":"kv-load-more",disabled:I,onClick:k,variant:"outline",children:d(I?"Loading…":"Load more")})})]}),r(se,{onOpenChange:n=>{n||y(!1)},open:u,children:$(ie,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-create-sheet",side:"right",children:[r(oe,{children:r(ce,{children:d("New key")})}),r(Pe,{namespace:l,onCancel:()=>{y(!1)},onCreated:L})]})}),r(se,{onOpenChange:n=>{n||s({name:null,type:"selectKey"})},open:p!==null,children:$(ie,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-editor-sheet",side:"right",children:[r(oe,{children:r(ce,{className:"truncate font-mono text-xs",children:p})}),p!==null&&r(ze,{expiration:o?.find(n=>n.name===p)?.expiration,keyName:p,namespace:l,onDeleted:w},`${l}:${p}`)]})})]})},ct=({loadNamespaces:l}={})=>{const e=ee(),d=q(),[c,s]=Z(null),[m,i]=Z(null),[t,a]=Z(null);le(()=>{const o={cancelled:!1};return z((async()=>{try{const g=await(l??(()=>e.listKvNamespaces()))();o.cancelled||(s(g),i(null),a(b=>b??g[0]?.binding??null))}catch(g){o.cancelled||(s(null),i(H(g)))}})()),()=>{o.cancelled=!0}},[e,l]);const v=o=>{a(o.currentTarget.dataset.ns??null)};return $("div",{className:"flex flex-col gap-4","data-testid":"lunora-kv-browser",children:[m!==null&&r("p",{className:"text-sm text-destructive","data-testid":"kv-ns-error",role:"alert",children:m}),c!==null&&c.length===0&&r(Fe,{description:d("Add a kv_namespaces binding to wrangler.jsonc — it appears here automatically, no wiring needed."),icon:r("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:r("path",{d:"M5 5h14v4H5V5Zm0 5h14v4H5v-4Zm0 5h14v4H5v-4Z"})}),testId:"kv-empty",title:d("No KV namespaces.")}),c!==null&&c.length>0&&r(ve,{className:"overflow-hidden py-0",children:r(pe,{className:"px-0",children:$(ye,{"data-testid":"kv-namespace-table",children:[r(he,{children:r(X,{children:r(Y,{children:d("Namespace")})})}),r(ke,{children:c.map(o=>r(X,{className:o.binding===t?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-ns":o.binding,"data-testid":`kv-ns-row-${o.binding}`,onClick:v,children:r(Q,{className:"font-mono text-xs",children:o.binding})},o.binding))})]})})}),t!==null&&r(Ue,{namespace:t},t)]})};export{ct as KvBrowser};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{c as te}from"react/compiler-runtime";import{useState as X}from"react";import{u as se}from"../packem_shared/button-BkCrNcAs.js";import{c as re,u as oe}from"../packem_shared/card-CIDGUN6K.js";import{u as ce}from"../packem_shared/input-JHu63lTv.js";import{useT as ae}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{b as me}from"../packem_shared/cf-links-gbDy51nR.js";import{c as pe,f as ue,b as fe}from"../packem_shared/internal-BSIsQVC6.js";import{jsx as r,jsxs as h}from"react/jsx-runtime";const he=e=>{const t=te(23),{destination:s}=e,f=ae();let g;t[0]!==s.snippet?(g=()=>{pe(s.snippet)},t[0]=s.snippet,t[1]=g):g=t[1];const m=g;let o;t[2]!==s.title?(o=r("h4",{className:"text-sm font-semibold",children:s.title}),t[2]=s.title,t[3]=o):o=t[3];let a;t[4]!==s.description?(a=r("p",{className:"text-sm text-muted-foreground",children:s.description}),t[4]=s.description,t[5]=a):a=t[5];let d;t[6]!==o||t[7]!==a?(d=h("div",{children:[o,a]}),t[6]=o,t[7]=a,t[8]=d):d=t[8];const F=`drain-copy-${s.id}`;let l;t[9]!==f?(l=f("Copy"),t[9]=f,t[10]=l):l=t[10];let n;t[11]!==m||t[12]!==F||t[13]!==l?(n=r(se,{"data-testid":F,onClick:m,size:"sm",variant:"outline",children:l}),t[11]=m,t[12]=F,t[13]=l,t[14]=n):n=t[14];let i;t[15]!==d||t[16]!==n?(i=h("div",{className:"flex items-start justify-between gap-3",children:[d,n]}),t[15]=d,t[16]=n,t[17]=i):i=t[17];let c;t[18]!==s.snippet?(c=r("pre",{className:"mt-2 overflow-x-auto rounded bg-muted p-2 font-mono text-xs",children:s.snippet}),t[18]=s.snippet,t[19]=c):c=t[19];let x;return t[20]!==i||t[21]!==c?(x=r(re,{className:"py-0","data-testid":"drain-card",children:h(oe,{className:"p-3",children:[i,c]})}),t[20]=i,t[21]=c,t[22]=x):x=t[22],x},_e=()=>{const e=te(88),t=ae();let s;e[0]!==t?(s=t("Stream every request log to R2, a SIEM, or a third-party log service."),e[0]=t,e[1]=s):s=e[1];let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f=["{",' "logpush": true',"}"],e[2]=f):f=e[2];const g=f.join(`
|
|
2
|
+
`);let m;e[3]!==t?(m=t("Logpush"),e[3]=t,e[4]=m):m=e[4];let o;e[5]!==s||e[6]!==m?(o={description:s,id:"logpush",snippet:g,title:m},e[5]=s,e[6]=m,e[7]=o):o=e[7];let a;e[8]!==t?(a=t("Send logs programmatically to a Worker for custom capture and forwarding."),e[8]=t,e[9]=a):a=e[9];let d;e[10]===Symbol.for("react.memo_cache_sentinel")?(d=["{",' "tail_consumers": [{ "service": "my-log-forwarder" }]',"}"],e[10]=d):d=e[10];const F=d.join(`
|
|
3
|
+
`);let l;e[11]!==t?(l=t("Tail Workers"),e[11]=t,e[12]=l):l=e[12];let n;e[13]!==a||e[14]!==l?(n={description:a,id:"tail-worker",snippet:F,title:l},e[13]=a,e[14]=l,e[15]=n):n=e[15];let i;e[16]!==t?(i=t("Retain and query recent request logs directly in Cloudflare's dashboard."),e[16]=t,e[17]=i):i=e[17];let c;e[18]===Symbol.for("react.memo_cache_sentinel")?(c=["{",' "observability": { "enabled": true }',"}"],e[18]=c):c=e[18];const x=c.join(`
|
|
4
|
+
`);let y;e[19]!==t?(y=t("Workers Logs"),e[19]=t,e[20]=y):y=e[20];let b;e[21]!==i||e[22]!==y?(b={description:i,id:"workers-logs",snippet:x,title:y},e[21]=i,e[22]=y,e[23]=b):b=e[23];let P;e[24]!==b||e[25]!==o||e[26]!==n?(P=[o,n,b],e[24]=b,e[25]=o,e[26]=n,e[27]=P):P=e[27];const V=P,[p,le]=X(""),[k,Z]=X(!1),[u,U]=X(null);let z;if(e[28]!==t||e[29]!==p){const G=async()=>{const Q=p.trim();if(Q==="")return;const ee="fetch"in globalThis?globalThis.fetch:void 0;if(ee===void 0){U({kind:"error",message:t("fetch is unavailable in this environment.")});return}const ie={durationMs:12,function:"messages:list",outcome:"ok",shard:"root",source:"lunora",tablesRead:["messages"],tablesWritten:[],ts:new Date().toISOString(),type:"request"};Z(!0),U(null);const de=performance.now();try{const H=await ee(Q,{body:JSON.stringify(ie),headers:{"Content-Type":"application/json"},method:"POST"});U({kind:"success",latencyMs:Math.round(performance.now()-de),status:H.status})}catch(H){U({kind:"error",message:fe(H)})}Z(!1)};z=()=>{ue(G())},e[28]=t,e[29]=p,e[30]=z}else z=e[30];const Y=z;let J;e[31]===Symbol.for("react.memo_cache_sentinel")?(J=G=>{le(G.target.value)},e[31]=J):J=e[31];const ne=J;let v;e[32]!==t?(v=t("Open in Cloudflare"),e[32]=t,e[33]=v):v=e[33];let w;e[34]!==v?(w=r("div",{className:"flex flex-wrap items-center gap-3",children:r("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"drain-cf-link",href:me,rel:"noreferrer",target:"_blank",children:v})}),e[34]=v,e[35]=w):w=e[35];let N;e[36]!==t?(N=t("Lunora does not ship logs itself — forwarding is handled by Cloudflare. Configure a destination below, then test your collector."),e[36]=t,e[37]=N):N=e[37];let S;e[38]!==N?(S=r("p",{className:"text-sm text-muted-foreground","data-testid":"drain-readonly-note",children:N}),e[38]=N,e[39]=S):S=e[39];let C;e[40]!==t?(C=t("Cloudflare destinations"),e[40]=t,e[41]=C):C=e[41];let _;e[42]!==C?(_=r("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:C}),e[42]=C,e[43]=_):_=e[43];let L;e[44]!==V?(L=V.map(ge),e[44]=V,e[45]=L):L=e[45];let T;e[46]!==_||e[47]!==L?(T=h("section",{className:"flex flex-col gap-3","data-testid":"drain-destinations",children:[_,L]}),e[46]=_,e[47]=L,e[48]=T):T=e[48];let $;e[49]!==t?($=t("Webhook test"),e[49]=t,e[50]=$):$=e[50];let j;e[51]!==$?(j=r("h3",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:$}),e[51]=$,e[52]=j):j=e[52];let O;e[53]!==t?(O=t("POST a sample Lunora request-log envelope to your collector to confirm it is reachable."),e[53]=t,e[54]=O):O=e[54];let M;e[55]!==O?(M=r("p",{className:"mb-2 text-sm text-muted-foreground",children:O}),e[55]=O,e[56]=M):M=e[56];let R;e[57]!==t?(R=t("https://example.com/logs"),e[57]=t,e[58]=R):R=e[58];let q;e[59]!==R||e[60]!==p?(q=r(ce,{className:"min-w-[20rem] flex-1","data-testid":"drain-webhook-url",onChange:ne,placeholder:R,type:"url",value:p}),e[59]=R,e[60]=p,e[61]=q):q=e[61];let W;e[62]!==k||e[63]!==p?(W=k||p.trim()==="",e[62]=k,e[63]=p,e[64]=W):W=e[64];let D;e[65]!==k||e[66]!==t?(D=t(k?"Sending…":"Send test event"),e[65]=k,e[66]=t,e[67]=D):D=e[67];let I;e[68]!==Y||e[69]!==W||e[70]!==D?(I=r(se,{"data-testid":"drain-webhook-test",disabled:W,onClick:Y,children:D}),e[68]=Y,e[69]=W,e[70]=D,e[71]=I):I=e[71];let A;e[72]!==q||e[73]!==I?(A=h("div",{className:"flex flex-wrap items-center gap-2",children:[q,I]}),e[72]=q,e[73]=I,e[74]=A):A=e[74];let B;e[75]!==u||e[76]!==t?(B=u!==null&&r("p",{className:u.kind==="success"?"mt-2 text-sm text-muted-foreground":"mt-2 text-sm text-destructive","data-testid":"drain-webhook-result",role:u.kind==="error"?"alert":void 0,children:u.kind==="success"?t("Delivered — status {status} in {latency}ms",{latency:u.latencyMs,status:u.status}):t("Failed: {message}",{message:u.message})}),e[75]=u,e[76]=t,e[77]=B):B=e[77];let E;e[78]!==j||e[79]!==M||e[80]!==A||e[81]!==B?(E=r(re,{className:"py-0",children:r(oe,{className:"p-3",children:h("section",{"data-testid":"drain-webhook",children:[j,M,A,B]})})}),e[78]=j,e[79]=M,e[80]=A,e[81]=B,e[82]=E):E=e[82];let K;return e[83]!==w||e[84]!==S||e[85]!==T||e[86]!==E?(K=h("div",{className:"flex flex-col gap-4","data-testid":"log-drains",children:[w,S,T,E]}),e[83]=w,e[84]=S,e[85]=T,e[86]=E,e[87]=K):K=e[87],K};function ge(e){return r(he,{destination:e},e.id)}export{_e as LogDrainsPanel};
|