@lunora/studio 1.0.0-alpha.113 → 1.0.0-alpha.115

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.
Files changed (153) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/mount.js +1 -1
  3. package/dist/packem_chunks/AdvisorHealthPanel.js +1 -1
  4. package/dist/packem_chunks/ApiTab.js +1 -1
  5. package/dist/packem_chunks/AuditPanel.js +1 -1
  6. package/dist/packem_chunks/DeploymentHealthPanel.js +1 -1
  7. package/dist/packem_chunks/ExportImportPanel.js +1 -1
  8. package/dist/packem_chunks/FileBrowser.js +1 -1
  9. package/dist/packem_chunks/FunctionRunner.js +1 -1
  10. package/dist/packem_chunks/FunctionStatsPanel.js +1 -1
  11. package/dist/packem_chunks/HealthPanel.js +1 -1
  12. package/dist/packem_chunks/InsightsPanel.js +1 -1
  13. package/dist/packem_chunks/LogsPanel.js +1 -1
  14. package/dist/packem_chunks/MailPanel.js +1 -1
  15. package/dist/packem_chunks/MetricsPanel.js +1 -1
  16. package/dist/packem_chunks/NotificationsPanel.js +1 -1
  17. package/dist/packem_chunks/PitrPanel.js +1 -1
  18. package/dist/packem_chunks/SchemaViewer.js +1 -1
  19. package/dist/packem_chunks/SecurityAdvisorPanel.js +1 -1
  20. package/dist/packem_chunks/SettingsPanel.js +1 -1
  21. package/dist/packem_chunks/SqlEditorPanel.js +1 -1
  22. package/dist/packem_chunks/TableEditor.js +1 -1
  23. package/dist/packem_chunks/agents-panel.js +1 -1
  24. package/dist/packem_chunks/analytics-panel.js +1 -1
  25. package/dist/packem_chunks/auth-audit-panel.js +1 -1
  26. package/dist/packem_chunks/auth-config-panel.js +1 -1
  27. package/dist/packem_chunks/auth-sessions-panel.js +1 -1
  28. package/dist/packem_chunks/containers-panel.js +1 -1
  29. package/dist/packem_chunks/dashboards-panel.js +1 -1
  30. package/dist/packem_chunks/evals-panel.js +1 -1
  31. package/dist/packem_chunks/fanout-panel.js +1 -1
  32. package/dist/packem_chunks/flags-panel.js +1 -1
  33. package/dist/packem_chunks/issues-panel.js +1 -1
  34. package/dist/packem_chunks/kv-browser.js +1 -1
  35. package/dist/packem_chunks/log-drains-panel.js +1 -1
  36. package/dist/packem_chunks/migrations-route.js +1 -1
  37. package/dist/packem_chunks/organizations-panel.js +1 -1
  38. package/dist/packem_chunks/payments-panel.js +1 -1
  39. package/dist/packem_chunks/permissions-panel.js +1 -1
  40. package/dist/packem_chunks/queues-panel.js +1 -1
  41. package/dist/packem_chunks/rls-panel.js +1 -1
  42. package/dist/packem_chunks/schedule-panel.js +1 -1
  43. package/dist/packem_chunks/storage-rules-panel.js +1 -1
  44. package/dist/packem_chunks/subscriptions-panel.js +1 -1
  45. package/dist/packem_chunks/sync-client-panel.js +1 -1
  46. package/dist/packem_chunks/traces-panel.js +1 -1
  47. package/dist/packem_chunks/users-panel.js +1 -1
  48. package/dist/packem_chunks/vector-browser.js +1 -1
  49. package/dist/packem_chunks/workflows-panel.js +1 -1
  50. package/dist/packem_shared/{ApiDocsPanel-BL5lMig5.js → ApiDocsPanel-C_dZt4ve.js} +1 -1
  51. package/dist/packem_shared/{ApiReferencePanel-CkCFMCBb.js → ApiReferencePanel-6W_QfOlv.js} +1 -1
  52. package/dist/packem_shared/{CommandPalette-B5yLEABs.js → CommandPalette-BAiOc1hT.js} +1 -1
  53. package/dist/packem_shared/{DataBrowser-BnDIFN-S.js → DataBrowser-CrkvQAMf.js} +1 -1
  54. package/dist/packem_shared/{GlobalDataBrowser-DusjXzRF.js → GlobalDataBrowser-BHFgEqMl.js} +1 -1
  55. package/dist/packem_shared/{HomePanel-BcaHVBJh.js → HomePanel-B8U_LJkK.js} +1 -1
  56. package/dist/packem_shared/{MigrationsPanel-CCOENX4X.js → MigrationsPanel-CW4MNUa4.js} +1 -1
  57. package/dist/packem_shared/{OpenRpcReferencePanel-21OWMH45.js → OpenRpcReferencePanel-Cx-qwpZW.js} +1 -1
  58. package/dist/packem_shared/{ScheduledJobs-CiO3eXgI.js → ScheduledJobs-DRmOKtDa.js} +1 -1
  59. package/dist/packem_shared/Studio-k_HuJZYW.js +1 -0
  60. package/dist/packem_shared/{StudioApp-DCdbsciH.js → StudioApp-CWpwayvp.js} +1 -1
  61. package/dist/packem_shared/{advisor-view-C1KFTXSH.js → advisor-view-CqCG22DB.js} +1 -1
  62. package/dist/packem_shared/{data-grid-BFTQnkXq.js → data-grid-pjv4t5Yi.js} +1 -1
  63. package/dist/packem_shared/{error-alert-TYdKetJd.js → error-alert-CKqB2CiN.js} +1 -1
  64. package/dist/packem_shared/{grid-features-C_yXlMc_.js → grid-features-3wfN2PeE.js} +4 -4
  65. package/dist/packem_shared/{home-panel-BiJHXeDC.js → home-panel-DywiFhDs.js} +1 -1
  66. package/dist/packem_shared/{internal-CwaF9YNk.js → internal-7bgd8inO.js} +1 -1
  67. package/dist/packem_shared/{log-line-UnE93Ovi.js → log-line-D0XBZaDn.js} +1 -1
  68. package/dist/packem_shared/{recording-client-CKn4-vUx.js → recording-client-BPY8sYUl.js} +1 -1
  69. package/dist/packem_shared/{reference-view-CUIDzLf0.js → reference-view-DhxnzBtf.js} +1 -1
  70. package/dist/packem_shared/{result-chart-Ca3YLzt8.js → result-chart-Q-gVLi4_.js} +1 -1
  71. package/dist/packem_shared/{schema-diagram-DHD13TjS.js → schema-diagram-CPcjPZj3.js} +1 -1
  72. package/dist/packem_shared/{studio-B3eEcBK0.js → studio-BFvT56qK.js} +1 -1
  73. package/dist/packem_shared/{table-list-sidebar-Bluzd1_2.js → table-list-sidebar-BCxqrZ0s.js} +1 -1
  74. package/dist/packem_shared/{use-admin-query-P0RJrjsD.js → use-admin-query-DV9xmFl8.js} +1 -1
  75. package/dist/packem_shared/{use-async-submit-DdLd0MdK.js → use-async-submit-C9xXjXWX.js} +1 -1
  76. package/dist/packem_shared/{use-auth-config-z3KRWAqD.js → use-auth-config-DIAyVsa3.js} +1 -1
  77. package/dist/packem_shared/{use-open-trace-4tIa0SXZ.js → use-open-trace-IfIlKEWd.js} +1 -1
  78. package/dist/packem_shared/{use-sql-assistant-CP90nLLh.js → use-sql-assistant-DFO2i-n-.js} +1 -1
  79. package/dist/standalone/chunk-22WJHOC4.js +11 -0
  80. package/dist/standalone/{chunk-ZN6KUP3O.js → chunk-2CHFHPR3.js} +1 -1
  81. package/dist/standalone/{chunk-OG57FC7W.js → chunk-2EJQ7SPV.js} +1 -1
  82. package/dist/standalone/{chunk-FSWPREH3.js → chunk-2Q7HAFRK.js} +1 -1
  83. package/dist/standalone/{chunk-44WNSIGQ.js → chunk-2UIT2HC2.js} +1 -1
  84. package/dist/standalone/{chunk-YUWMB6EV.js → chunk-2UWKGSEA.js} +1 -1
  85. package/dist/standalone/{chunk-ZQLIKKIY.js → chunk-3IXTF53Q.js} +1 -1
  86. package/dist/standalone/{chunk-J6MNOKO5.js → chunk-44FJEOAY.js} +1 -1
  87. package/dist/standalone/{chunk-26VREVWU.js → chunk-5XMZP64Z.js} +1 -1
  88. package/dist/standalone/{chunk-45YWYMD5.js → chunk-6MRGARL5.js} +1 -1
  89. package/dist/standalone/{chunk-3F5I435D.js → chunk-6UOC4ZJL.js} +1 -1
  90. package/dist/standalone/{chunk-FBAZHG35.js → chunk-6ZSAMAYN.js} +1 -1
  91. package/dist/standalone/{chunk-BORG7WUC.js → chunk-7IQT5M4O.js} +1 -1
  92. package/dist/standalone/{chunk-KQIHXYE6.js → chunk-7TFEJVX4.js} +1 -1
  93. package/dist/standalone/{chunk-3QB5JI32.js → chunk-7W6TQTW7.js} +1 -1
  94. package/dist/standalone/{chunk-4MAJFNON.js → chunk-A7WKYEQ4.js} +1 -1
  95. package/dist/standalone/chunk-AG265V66.js +1 -0
  96. package/dist/standalone/{chunk-6SAAMM4S.js → chunk-BE76GAFE.js} +1 -1
  97. package/dist/standalone/{chunk-6ZPTNC34.js → chunk-BKM6PMSO.js} +1 -1
  98. package/dist/standalone/{chunk-D7DUQS2Y.js → chunk-CE7WVPLK.js} +1 -1
  99. package/dist/standalone/{chunk-MSFUDXBA.js → chunk-D4HJ2VM2.js} +1 -1
  100. package/dist/standalone/{chunk-FLCK2WWQ.js → chunk-DC5AAWSA.js} +1 -1
  101. package/dist/standalone/{chunk-6NJAHOGO.js → chunk-DEGERMXH.js} +1 -1
  102. package/dist/standalone/{chunk-JURAVSE7.js → chunk-E6P2ERQV.js} +1 -1
  103. package/dist/standalone/{chunk-TLPWZ5NI.js → chunk-EQSVW6LZ.js} +1 -1
  104. package/dist/standalone/{chunk-T2LDA6WP.js → chunk-FCEPVFIJ.js} +1 -1
  105. package/dist/standalone/chunk-FEEZPSMA.js +1 -0
  106. package/dist/standalone/{chunk-25OIGX2A.js → chunk-FEW2WNS7.js} +1 -1
  107. package/dist/standalone/{chunk-KFZ37KQP.js → chunk-FRSTZO5P.js} +1 -1
  108. package/dist/standalone/{chunk-X6Q5DWLZ.js → chunk-GKHUQDVI.js} +1 -1
  109. package/dist/standalone/{chunk-SL5R7WBN.js → chunk-H2WBIULE.js} +1 -1
  110. package/dist/standalone/{chunk-WIG3HCUJ.js → chunk-H3M57MCN.js} +1 -1
  111. package/dist/standalone/{chunk-UIF57LBO.js → chunk-H4SLAZAN.js} +1 -1
  112. package/dist/standalone/{chunk-6FWN26RH.js → chunk-HLEXBOCL.js} +1 -1
  113. package/dist/standalone/{chunk-QZ55OWAB.js → chunk-HLHO5AHK.js} +1 -1
  114. package/dist/standalone/{chunk-MOUI44OT.js → chunk-INLHZKCS.js} +1 -1
  115. package/dist/standalone/{chunk-L7CJ5PGH.js → chunk-JACBQWRB.js} +1 -1
  116. package/dist/standalone/{chunk-YS7HEZC2.js → chunk-KEMHRM53.js} +1 -1
  117. package/dist/standalone/{chunk-GIRZD3UB.js → chunk-KOH52XKG.js} +1 -1
  118. package/dist/standalone/{chunk-C5E5PLJT.js → chunk-LDVDE3LE.js} +1 -1
  119. package/dist/standalone/{chunk-3RYEUXY2.js → chunk-LFEDP3Y6.js} +1 -1
  120. package/dist/standalone/{chunk-V6QPVFDL.js → chunk-MG7VPUFA.js} +1 -1
  121. package/dist/standalone/{chunk-OE4KGVJW.js → chunk-MLYZZD5C.js} +1 -1
  122. package/dist/standalone/{chunk-WHRG6S5P.js → chunk-NSR345ID.js} +1 -1
  123. package/dist/standalone/{chunk-IWNVQHF7.js → chunk-OAXOITHK.js} +1 -1
  124. package/dist/standalone/chunk-OQS4HFKC.js +1 -0
  125. package/dist/standalone/{chunk-XGIG4EDG.js → chunk-OTZRXUHF.js} +1 -1
  126. package/dist/standalone/{chunk-PJDKRUWT.js → chunk-PNLUMMXO.js} +1 -1
  127. package/dist/standalone/{chunk-AOE75NAT.js → chunk-Q2G22JHG.js} +1 -1
  128. package/dist/standalone/{chunk-BELLXCN7.js → chunk-RUIWLLAI.js} +1 -1
  129. package/dist/standalone/{chunk-S77D4SHR.js → chunk-RVQRXKRJ.js} +1 -1
  130. package/dist/standalone/{chunk-JVAYDDMK.js → chunk-SCXAZ74Y.js} +1 -1
  131. package/dist/standalone/{chunk-2DC6F7NH.js → chunk-SLOB2B2T.js} +1 -1
  132. package/dist/standalone/{chunk-LT4XQDD2.js → chunk-SM764GPA.js} +1 -1
  133. package/dist/standalone/{chunk-5T7KRUPX.js → chunk-U2KBAKZ6.js} +1 -1
  134. package/dist/standalone/chunk-U7J3LXJ4.js +6 -0
  135. package/dist/standalone/{chunk-KEKIGANB.js → chunk-UCA5MYCL.js} +1 -1
  136. package/dist/standalone/{chunk-GPP4VSUO.js → chunk-UJXKS27L.js} +1 -1
  137. package/dist/standalone/{chunk-C7E4I7JZ.js → chunk-UKIDHICQ.js} +1 -1
  138. package/dist/standalone/{chunk-5NRQIDQA.js → chunk-V2KCESII.js} +1 -1
  139. package/dist/standalone/{chunk-OOBJFXYB.js → chunk-W5CYX66B.js} +1 -1
  140. package/dist/standalone/{chunk-2BDM6HNL.js → chunk-WSNFV7ZW.js} +1 -1
  141. package/dist/standalone/{chunk-OLQWBGKT.js → chunk-YYFHDYYT.js} +1 -1
  142. package/dist/standalone/{chunk-PHHMPYEP.js → chunk-ZHDCWHRT.js} +1 -1
  143. package/dist/standalone/{chunk-CEPMQS24.js → chunk-ZIHYXKQJ.js} +1 -1
  144. package/dist/standalone/{chunk-DL3UOEWN.js → chunk-ZIYO55T2.js} +1 -1
  145. package/dist/standalone/{chunk-6JGXSMKV.js → chunk-ZNNKKJRT.js} +1 -1
  146. package/dist/standalone/studio.js +1 -1
  147. package/package.json +5 -5
  148. package/dist/packem_shared/Studio-CHmLCjBR.js +0 -1
  149. package/dist/standalone/chunk-GZMBMNL3.js +0 -6
  150. package/dist/standalone/chunk-RBUVNO22.js +0 -1
  151. package/dist/standalone/chunk-SMKRXJUC.js +0 -1
  152. package/dist/standalone/chunk-T6HLABZW.js +0 -1
  153. package/dist/standalone/chunk-TBXK3FKP.js +0 -11
@@ -1 +1 @@
1
- import{c as u}from"react/compiler-runtime";import{u as m}from"../packem_shared/use-admin-query-P0RJrjsD.js";import{useT as h}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as p}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{A as R}from"../packem_shared/advisor-view-C1KFTXSH.js";import{jsx as g}from"react/jsx-runtime";const f=(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],y=()=>{const e=u(8),s=h();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];const{data:r,error:n,errorSource:d}=m(p.getSecurityAudit,i);let a;if(e[1]!==r||e[2]!==s){const l=r===void 0?null:k(r);a=l===null?null:l.map(t=>({description:A(s,t),entity:S(t),issueType:f(s,t),key:t.kind,level:t.level})),e[1]=r,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=g(R,{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{y as default};
1
+ import{c as u}from"react/compiler-runtime";import{u as m}from"../packem_shared/use-admin-query-DV9xmFl8.js";import{useT as h}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as p}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{A as R}from"../packem_shared/advisor-view-CqCG22DB.js";import{jsx as g}from"react/jsx-runtime";const f=(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],y=()=>{const e=u(8),s=h();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];const{data:r,error:n,errorSource:d}=m(p.getSecurityAudit,i);let a;if(e[1]!==r||e[2]!==s){const l=r===void 0?null:k(r);a=l===null?null:l.map(t=>({description:A(s,t),entity:S(t),issueType:f(s,t),key:t.kind,level:t.level})),e[1]=r,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=g(R,{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{y as default};
@@ -1 +1 @@
1
- import{c as K}from"react/compiler-runtime";import{E as O}from"../packem_shared/error-alert-TYdKetJd.js";import{B}from"../packem_shared/badge-cAk9Di1Q.js";import{C as D,a as U}from"../packem_shared/card-BGlQzQY-.js";import{T as V,a as j,b as L,c as I,d as F,e as S}from"../packem_shared/table-BMsuYFhk.js";import{u as H}from"../packem_shared/use-admin-query-P0RJrjsD.js";import{useT as M}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as P}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{C as Q}from"../packem_shared/cf-links-CBJ5SywP.js";import{jsxs as c,jsx as t}from"react/jsx-runtime";const W={binding:"outline",secret:"destructive",var:"secondary"},$=(r,e)=>{if(r===void 0)return[];const m=[];return r.workerUrl!==void 0&&m.push({label:e("URL"),value:r.workerUrl}),r.environment!==void 0&&m.push({label:e("Environment"),value:r.environment}),r.deploymentId!==void 0&&m.push({label:e("Deployment"),value:r.deploymentId}),r.versionTag!==void 0&&m.push({label:e("Version"),value:r.versionTag}),m},ne=r=>{const e=K(52),{initialShardKey:m}=r,s=M();let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={},e[0]=w):w=e[0];const R=m??"";let k;e[1]!==R?(k={shardKey:R},e[1]=R,e[2]=k):k=e[2];const{data:n,error:a,errorSource:T,isLoading:E}=H(P.getSettings,w,k);let l,f,u,i,o,d,p;if(e[3]!==a||e[4]!==T||e[5]!==n?.deploy||e[6]!==n?.settings||e[7]!==s){const A=$(n?.deploy,s);let _;e[15]!==n?.settings?(_=n?.settings??[],e[15]=n?.settings,e[16]=_):_=e[16],l=_,f="flex flex-col gap-4",u="lunora-settings";let N;e[17]!==s?(N=s("Open in Cloudflare"),e[17]=s,e[18]=N):N=e[18],e[19]!==N?(i=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:Q,rel:"noreferrer",target:"_blank",children:N})}),e[19]=N,e[20]=i):i=e[20];let y;e[21]!==s?(y=s("View-only — values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=s,e[22]=y):y=e[22],e[23]!==y?(o=t("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:y}),e[23]=y,e[24]=o):o=e[24],e[25]!==a||e[26]!==T?(d=a!==null&&t(O,{error:T,testId:"set-error"}),e[25]=a,e[26]=T,e[27]=d):d=e[27],p=A.length>0&&c(D,{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:s("Deployment")})}),t(U,{className:"py-3",children:t("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:A.map(q)})})]}),e[3]=a,e[4]=T,e[5]=n?.deploy,e[6]=n?.settings,e[7]=s,e[8]=l,e[9]=f,e[10]=u,e[11]=i,e[12]=o,e[13]=d,e[14]=p}else l=e[8],f=e[9],u=e[10],i=e[11],o=e[12],d=e[13],p=e[14];let h;e[28]!==s?(h=s("Environment & bindings"),e[28]=s,e[29]=h):h=e[29];let g;e[30]!==h?(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:h})}),e[30]=h,e[31]=g):g=e[31];let x;e[32]!==a||e[33]!==E||e[34]!==l.length||e[35]!==s?(x=a===null&&!E&&l.length===0&&t("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:s("No environment variables or bindings.")}),e[32]=a,e[33]=E,e[34]=l.length,e[35]=s,e[36]=x):x=e[36];let b;e[37]!==l||e[38]!==s?(b=l.length>0&&t(U,{className:"px-0 py-0",children:c(V,{"data-testid":"set-table",children:[t(j,{children:c(L,{children:[t(I,{children:s("name")}),t(I,{children:s("kind")}),t(I,{children:s("value")})]})}),t(F,{children:l.map(z)})]})}),e[37]=l,e[38]=s,e[39]=b):b=e[39];let v;e[40]!==g||e[41]!==x||e[42]!==b?(v=c(D,{className:"py-0",children:[g,x,b]}),e[40]=g,e[41]=x,e[42]=b,e[43]=v):v=e[43];let C;return e[44]!==v||e[45]!==f||e[46]!==u||e[47]!==i||e[48]!==o||e[49]!==d||e[50]!==p?(C=c("div",{className:f,"data-testid":u,children:[i,o,d,p,v]}),e[44]=v,e[45]=f,e[46]=u,e[47]=i,e[48]=o,e[49]=d,e[50]=p,e[51]=C):C=e[51],C};function q(r){return c("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 z(r){return c(L,{"data-testid":"set-row",children:[t(S,{className:"font-mono text-xs font-medium",children:r.name}),t(S,{children:t(B,{variant:W[r.kind],children:r.bindingType??r.kind})}),t(S,{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{ne as SettingsPanel};
1
+ import{c as K}from"react/compiler-runtime";import{E as O}from"../packem_shared/error-alert-CKqB2CiN.js";import{B}from"../packem_shared/badge-cAk9Di1Q.js";import{C as D,a as U}from"../packem_shared/card-BGlQzQY-.js";import{T as V,a as j,b as L,c as I,d as F,e as S}from"../packem_shared/table-BMsuYFhk.js";import{u as H}from"../packem_shared/use-admin-query-DV9xmFl8.js";import{useT as M}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as P}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{C as Q}from"../packem_shared/cf-links-CBJ5SywP.js";import{jsxs as c,jsx as t}from"react/jsx-runtime";const W={binding:"outline",secret:"destructive",var:"secondary"},$=(r,e)=>{if(r===void 0)return[];const m=[];return r.workerUrl!==void 0&&m.push({label:e("URL"),value:r.workerUrl}),r.environment!==void 0&&m.push({label:e("Environment"),value:r.environment}),r.deploymentId!==void 0&&m.push({label:e("Deployment"),value:r.deploymentId}),r.versionTag!==void 0&&m.push({label:e("Version"),value:r.versionTag}),m},ne=r=>{const e=K(52),{initialShardKey:m}=r,s=M();let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={},e[0]=w):w=e[0];const R=m??"";let k;e[1]!==R?(k={shardKey:R},e[1]=R,e[2]=k):k=e[2];const{data:n,error:a,errorSource:T,isLoading:E}=H(P.getSettings,w,k);let l,f,u,i,o,d,p;if(e[3]!==a||e[4]!==T||e[5]!==n?.deploy||e[6]!==n?.settings||e[7]!==s){const A=$(n?.deploy,s);let _;e[15]!==n?.settings?(_=n?.settings??[],e[15]=n?.settings,e[16]=_):_=e[16],l=_,f="flex flex-col gap-4",u="lunora-settings";let N;e[17]!==s?(N=s("Open in Cloudflare"),e[17]=s,e[18]=N):N=e[18],e[19]!==N?(i=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:Q,rel:"noreferrer",target:"_blank",children:N})}),e[19]=N,e[20]=i):i=e[20];let y;e[21]!==s?(y=s("View-only — values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=s,e[22]=y):y=e[22],e[23]!==y?(o=t("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:y}),e[23]=y,e[24]=o):o=e[24],e[25]!==a||e[26]!==T?(d=a!==null&&t(O,{error:T,testId:"set-error"}),e[25]=a,e[26]=T,e[27]=d):d=e[27],p=A.length>0&&c(D,{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:s("Deployment")})}),t(U,{className:"py-3",children:t("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:A.map(q)})})]}),e[3]=a,e[4]=T,e[5]=n?.deploy,e[6]=n?.settings,e[7]=s,e[8]=l,e[9]=f,e[10]=u,e[11]=i,e[12]=o,e[13]=d,e[14]=p}else l=e[8],f=e[9],u=e[10],i=e[11],o=e[12],d=e[13],p=e[14];let h;e[28]!==s?(h=s("Environment & bindings"),e[28]=s,e[29]=h):h=e[29];let g;e[30]!==h?(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:h})}),e[30]=h,e[31]=g):g=e[31];let x;e[32]!==a||e[33]!==E||e[34]!==l.length||e[35]!==s?(x=a===null&&!E&&l.length===0&&t("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:s("No environment variables or bindings.")}),e[32]=a,e[33]=E,e[34]=l.length,e[35]=s,e[36]=x):x=e[36];let b;e[37]!==l||e[38]!==s?(b=l.length>0&&t(U,{className:"px-0 py-0",children:c(V,{"data-testid":"set-table",children:[t(j,{children:c(L,{children:[t(I,{children:s("name")}),t(I,{children:s("kind")}),t(I,{children:s("value")})]})}),t(F,{children:l.map(z)})]})}),e[37]=l,e[38]=s,e[39]=b):b=e[39];let v;e[40]!==g||e[41]!==x||e[42]!==b?(v=c(D,{className:"py-0",children:[g,x,b]}),e[40]=g,e[41]=x,e[42]=b,e[43]=v):v=e[43];let C;return e[44]!==v||e[45]!==f||e[46]!==u||e[47]!==i||e[48]!==o||e[49]!==d||e[50]!==p?(C=c("div",{className:f,"data-testid":u,children:[i,o,d,p,v]}),e[44]=v,e[45]=f,e[46]=u,e[47]=i,e[48]=o,e[49]=d,e[50]=p,e[51]=C):C=e[51],C};function q(r){return c("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 z(r){return c(L,{"data-testid":"set-row",children:[t(S,{className:"font-mono text-xs font-medium",children:r.name}),t(S,{children:t(B,{variant:W[r.kind],children:r.bindingType??r.kind})}),t(S,{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{ne as SettingsPanel};
@@ -1,4 +1,4 @@
1
- import{c as Y}from"react/compiler-runtime";import{useLunora as Oe}from"@lunora/react";import{useState as oe,useMemo as Be,useCallback as Ze,useEffect as Ee,useRef as Se,useId as et}from"react";import{ADMIN_FUNCTIONS as Re}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{u as _e,n as ze,b as Ue}from"../packem_shared/browser-storage-Br_bLeBt.js";import{d as Te,f as ce,c as Le,b as Pe}from"../packem_shared/internal-CwaF9YNk.js";import{r as tt}from"../packem_shared/shard-history-QcjcMnCA.js";import{u as nt}from"../packem_shared/use-sql-assistant-CP90nLLh.js";import st from"../packem_shared/useDebounced-DVeQ5-oW.js";import{useT as le}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{c as ue}from"../packem_shared/utils-bhneXptQ.js";import{jsxs as $,jsx as f,Fragment as qe}from"react/jsx-runtime";import{I as ot}from"../packem_shared/input-CY5W3wzv.js";import{S as lt}from"../packem_shared/result-chart-Ca3YLzt8.js";import{ShardInput as rt}from"../packem_shared/ShardInput-XumEzeT0.js";import{A as it}from"../packem_shared/alert-C2SEhYS9.js";import{E as at}from"../packem_shared/grid-features-C_yXlMc_.js";import{c as ct,a as dt,b as He,e as ut,d as ft,T as mt}from"../packem_shared/table-BMsuYFhk.js";import{C as ht}from"../packem_shared/data-grid-BFTQnkXq.js";const pt=["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"],bt=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],ke=String.fromCodePoint(0),gt=new RegExp(`${ke}${String.raw`(\d+)`}${ke}`,"gu"),xt=pt.map(l=>({pattern:new RegExp(String.raw`\b${l.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:l})),yt=bt.map(l=>({pattern:new RegExp(String.raw`\s+${l.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
1
+ import{c as Y}from"react/compiler-runtime";import{useLunora as Oe}from"@lunora/react";import{useState as oe,useMemo as Be,useCallback as Ze,useEffect as Ee,useRef as Se,useId as et}from"react";import{ADMIN_FUNCTIONS as Re}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{u as _e,n as ze,b as Ue}from"../packem_shared/browser-storage-Br_bLeBt.js";import{d as Te,f as ce,c as Le,b as Pe}from"../packem_shared/internal-7bgd8inO.js";import{r as tt}from"../packem_shared/shard-history-QcjcMnCA.js";import{u as nt}from"../packem_shared/use-sql-assistant-DFO2i-n-.js";import st from"../packem_shared/useDebounced-DVeQ5-oW.js";import{useT as le}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{c as ue}from"../packem_shared/utils-bhneXptQ.js";import{jsxs as $,jsx as f,Fragment as qe}from"react/jsx-runtime";import{I as ot}from"../packem_shared/input-CY5W3wzv.js";import{S as lt}from"../packem_shared/result-chart-Q-gVLi4_.js";import{ShardInput as rt}from"../packem_shared/ShardInput-XumEzeT0.js";import{A as it}from"../packem_shared/alert-C2SEhYS9.js";import{E as at}from"../packem_shared/grid-features-3wfN2PeE.js";import{c as ct,a as dt,b as He,e as ut,d as ft,T as mt}from"../packem_shared/table-BMsuYFhk.js";import{C as ht}from"../packem_shared/data-grid-pjv4t5Yi.js";const pt=["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"],bt=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],ke=String.fromCodePoint(0),gt=new RegExp(`${ke}${String.raw`(\d+)`}${ke}`,"gu"),xt=pt.map(l=>({pattern:new RegExp(String.raw`\b${l.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:l})),yt=bt.map(l=>({pattern:new RegExp(String.raw`\s+${l.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
2
2
  ${l}`})),vt=l=>{const e=[];let t=l.replaceAll(/'(?:[^']|'')*'/gu,o=>(e.push(o),`${ke}${(e.length-1).toString()}${ke}`)).replaceAll(/\s+/gu," ").trim();for(const{pattern:o,replacement:s}of xt)t=t.replaceAll(o,s);for(const{pattern:o,replacement:s}of yt)t=t.replaceAll(o,s);return t=t.replaceAll(gt,(o,s)=>e[Number(s)]??""),t},St=/^(?:explain\s+(?:query\s+plan\s+)?)?(?:select|with)\b/iu,wt=/\b(?:alter|attach|create|delete|detach|drop|insert|pragma|reindex|replace|truncate|update|vacuum)\b/iu,Ct=/^\w+/u,Nt=/;\s*$/u,Tt=/\s/u,kt=(l,e)=>{let n=e+2;for(;n<l.length&&l[n]!==`
3
3
  `;)n+=1;return n},Et=(l,e)=>{const n=l.indexOf("*/",e+2);return n===-1?-1:n+2},Rt=l=>{let e=0;for(;e<l.length;){const n=l[e];if(n!==void 0&&Tt.test(n))e+=1;else if(n==="-"&&l[e+1]==="-")e=kt(l,e);else if(n==="/"&&l[e+1]==="*"){const t=Et(l,e);if(t===-1)break;e=t}else break}return e},Lt=l=>{const e=Rt(l),n=l.slice(e).trimEnd();if(n==="")return{code:"SQL_EMPTY",message:"the query is empty"};const t=n.replace(Nt,""),o=t.indexOf(";");if(o!==-1)return{code:"SQL_MULTIPLE_STATEMENTS",length:1,message:"only a single statement may be run",offset:e+o};const s="the SQL editor is read-only — only SELECT / WITH / EXPLAIN queries are allowed";if(!St.test(t))return{code:"SQL_NOT_READONLY",length:Ct.exec(t)?.[0].length??1,message:s,offset:e};const r=wt.exec(t);if(r!==null)return{code:"SQL_NOT_READONLY",length:r[0].length,message:`${s} (\`${r[0].toUpperCase()}\` is not allowed)`,offset:e+r.index}},It=/\b(?:from|join)\s+([a-z_][\w$]*)(?:\s+(?:as\s+)?([a-z_][\w$]*))?/giu,qt=/(?:\bwith\s+(?:recursive\s+)?|,\s*)([a-z_][\w$]*)\s+as\s*\(/giu,At=new Set(["cross","full","group","having","inner","join","left","limit","offset","on","order","right","union","using","where","window"]),_t=/[^\n]/gu,Ot=(l,e)=>{const n=l[e];if(n==="'"){let t=e+1;for(;t<l.length&&l[t]!=="'";)t+=1;return Math.min(t+1,l.length)}if(n==="-"&&l[e+1]==="-"){const t=l.indexOf(`
4
4
  `,e);return t===-1?l.length:t}if(n==="/"&&l[e+1]==="*"){const t=l.indexOf("*/",e+2);return t===-1?l.length:t+2}return-1},Dt=l=>{let e="",n=0;for(;n<l.length;){const t=Ot(l,n);t===-1?(e+=l.slice(n,n+1),n+=1):(e+=l.slice(n,t).replaceAll(_t," "),n=t)}return e},Mt=l=>{const e=new Set;for(const n of l.matchAll(qt))e.add((n[1]??"").toLowerCase());return e},$t=(l,e)=>{const n=new Map;for(const t of l.matchAll(It)){const o=(t[1]??"").toLowerCase(),s=(t[2]??"").toLowerCase();e.has(o)&&(n.set(o,o),s!==""&&!At.has(s)&&n.set(s,o))}return n},Ye=(l,e)=>{const n=Dt(l),t=new Set(e.map(o=>o.toLowerCase()));return{ctes:Mt(n),masked:n,targets:$t(n,t)}},Bt=/^(?:__lunora|sqlite_)/iu,Pt=/\b(?:from|join)\s+([a-z_][\w$]*)/giu,Ht=/\b([a-z_][\w$]*)\.([a-z_][\w$]*)/giu,Wt=new Set(["cross","full","group","having","inner","join","lateral","left","limit","offset","order","right","select","union","where","window"]),Ft=(l,e,n)=>{const t=[];for(const o of l.matchAll(Pt)){const s=o[1]??"",r=s.toLowerCase();!e.has(r)&&!n.has(r)&&!Wt.has(r)&&!Bt.test(s)&&t.push({length:s.length,message:`unknown table \`${s}\``,offset:o.index+o[0].length-s.length,severity:"error",source:"schema"})}return t},Qt=(l,e,n)=>{const t=[],o=new Map;for(const[s,r]of Object.entries(e.columns))o.set(s.toLowerCase(),new Set(r.map(d=>d.toLowerCase())));for(const s of l.matchAll(Ht)){const r=(s[1]??"").toLowerCase(),d=s[2]??"",a=n.get(r),i=a===void 0?void 0:o.get(a);i!==void 0&&!i.has(d.toLowerCase())&&t.push({length:d.length,message:`\`${a??""}\` has no column \`${d}\``,offset:s.index+s[0].length-d.length,severity:"error",source:"schema"})}return t},zt=(l,e)=>{if(l.trim()==="")return[];const n=Lt(l);if(n!==void 0)return n.code==="SQL_EMPTY"?[]:[{length:n.length,message:n.message,offset:n.offset,severity:"error",source:"gate"}];const{ctes:t,masked:o,targets:s}=Ye(l,e.tables),r=new Set(e.tables.map(d=>d.toLowerCase()));return[...Ft(o,r,t),...Qt(o,e,s)]},Ut=Le(Re.lintSql),Yt=600,jt=(l,e,n)=>{const t=Oe(),[o,s]=oe([]),r=Be(()=>zt(l,e),[l,e]),d=st(l,Yt),i=r.some(u=>u.source==="gate")||d.trim()==="",m=Ze(async u=>{try{const x=await t.query(Ut,{sql:d},Te(n));u.cancelled||s(x.diagnostics??[])}catch{u.cancelled||s([])}},[t,d,n]);Ee(()=>{if(i){s([]);return}const u={cancelled:!1};return ce(m(u)),()=>{u.cancelled=!0}},[m,i]);const b=d===l;return Be(()=>b?[...r,...o]:r,[r,o,b])},Ce=8,Kt=["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"],Gt=new Set(["AND","BY","HAVING","ON","OR","SELECT","WHERE"]),Vt=/[\w$]/,je=l=>l!==void 0&&Vt.test(l),Ke=l=>{let e=l.length;for(;e>0&&je(l[e-1]);)e-=1;return l.slice(e)},Ge=(l,e)=>{let n=e;for(;n>0&&je(l[n-1]);)n-=1;return{end:e,start:n,text:l.slice(n,e)}},We=(l,e)=>{const n=l.slice(0,e).trimEnd();return n.endsWith(".")||Gt.has(Ke(n).toUpperCase())},Jt=(l,e,n)=>{const t=l.slice(0,e);if(!t.endsWith("."))return;const o=Ke(t.slice(0,-1));if(o!=="")return Ye(l,n).targets.get(o.toLowerCase())??o},De=(l,e)=>l.toLowerCase().startsWith(e.toLowerCase()),Fe=(l,e,n,t)=>{const o=[];for(const s of l)if(De(s,e)&&(o.push(t(s)),o.length>=n))break;return o},Xt=(l,e,n)=>{const t=new Map;for(const[o,s]of Object.entries(l.columns))for(const r of s)if(De(r,e)&&!t.has(r)&&(t.set(r,o),t.size>=n))return[...t].map(([d,a])=>({detail:a,kind:"column",label:d}));return[...t].map(([o,s])=>({detail:s,kind:"column",label:o}))},Zt=(l,e,n)=>{const t=Ge(l,e),o=Jt(l,t.start,n.tables);if(o!==void 0){const i=n.columns[o]??n.columns[o.toLowerCase()]??[];return Fe(i,t.text,Ce,m=>({detail:o,kind:"column",label:m}))}if(t.text===""&&!We(l,t.start))return[];const s=Fe(n.tables,t.text,Ce,i=>({kind:"table",label:i})),r=Xt(n,t.text,Ce),d=Kt.flatMap(i=>t.text!==""&&De(i,t.text)&&i.toLowerCase()!==t.text.toLowerCase()?[{kind:"keyword",label:i}]:[]);return(We(l,t.start)?[...r,...s,...d]:[...s,...r,...d]).slice(0,Ce)},en=(l,e,n)=>{const t=Ge(l,e),o=l.slice(0,t.start)+n.label+l.slice(t.end);return{caret:t.start+n.label.length,value:o}},tn=["boxSizing","borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textTransform","width","wordSpacing"],nn=(l,e)=>{const n=globalThis.getComputedStyle(l),t=globalThis.document.createElement("div"),{style:o}=t;o.position="absolute",o.visibility="hidden",o.whiteSpace="pre-wrap",o.overflowWrap="break-word";for(const a of tn)o[a]=n[a];t.textContent=l.value.slice(0,Math.max(0,e));const s=globalThis.document.createElement("span");s.textContent=l.value.slice(Math.max(0,e))||".",t.append(s),globalThis.document.body.append(t);const r=s.offsetLeft-l.scrollLeft,d=s.offsetTop-l.scrollTop;return t.remove(),{left:r,top:d}},sn=(l,e,n)=>{const t=Y(16),[o,s]=oe(null);let r;t[0]!==l||t[1]!==e?(r=(v,p)=>{const h=Zt(v,p,l);if(h.length===0){s(null);return}const S=e.current,{left:w,top:C}=S===null?{left:0,top:0}:nn(S,p);s(T=>T!==null&&T.active===0&&T.left===w&&T.top===C&&T.suggestions.length===h.length&&T.suggestions.every((R,I)=>{const N=h.at(I);return R.kind===N?.kind&&R.label===N.label&&R.detail===N.detail})?T:{active:0,left:w,suggestions:h,top:C})},t[0]=l,t[1]=e,t[2]=r):r=t[2];const d=r;let a;t[3]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{s(null)},t[3]=a):a=t[3];const i=a;let m;t[4]===Symbol.for("react.memo_cache_sentinel")?(m=v=>{s(p=>{if(p===null)return p;const h=p.suggestions.length,S=(p.active+v+h)%h;return{...p,active:S}})},t[4]=m):m=t[4];const b=m;let u;t[5]!==n||t[6]!==o||t[7]!==e?(u=v=>{const p=e.current;if(o===null||p===null)return!1;const h=o.suggestions[v??o.active];if(h===void 0)return!1;const S=en(p.value,p.selectionStart,h);return n(S.value),s(null),requestAnimationFrame(()=>{const w=e.current;w!==null&&(w.focus(),w.setSelectionRange(S.caret,S.caret))}),!0},t[5]=n,t[6]=o,t[7]=e,t[8]=u):u=t[8];const x=u;let c;t[9]!==x?(c=()=>x(),t[9]=x,t[10]=c):c=t[10];const g=c;let y;return t[11]!==g||t[12]!==x||t[13]!==d||t[14]!==o?(y={close:i,commit:g,commitAt:x,move:b,refresh:d,state:o},t[11]=g,t[12]=x,t[13]=d,t[14]=o,t[15]=y):y=t[15],y},on={column:"column",keyword:"keyword",table:"table"},ln=20,rn=l=>{const e=Y(17),{listboxId:n,onPick:t,state:o}=l,s=le();let r;e[0]!==o?(r=o===null?void 0:{left:o.left,top:o.top+ln},e[0]=o,e[1]=r):r=e[1];const d=r;if(o===null)return null;let a;if(e[2]!==n||e[3]!==t||e[4]!==o.active||e[5]!==o.suggestions||e[6]!==s){let m;e[8]!==n||e[9]!==t||e[10]!==o.active||e[11]!==s?(m=(b,u)=>$("li",{"aria-selected":u===o.active,className:ue("flex cursor-pointer items-center gap-2 px-2 py-1 text-[13px]",u===o.active?"bg-accent text-accent-foreground":"text-foreground"),"data-testid":"sql-autocomplete-item",id:`${n}-opt-${u.toString()}`,onMouseDown:x=>{x.preventDefault(),t(u)},role:"option",children:[f("span",{className:"truncate font-mono",children:b.label}),b.detail!==void 0&&f("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:b.detail}),f("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:s(on[b.kind])})]},`${b.kind}:${b.label}`),e[8]=n,e[9]=t,e[10]=o.active,e[11]=s,e[12]=m):m=e[12],a=o.suggestions.map(m),e[2]=n,e[3]=t,e[4]=o.active,e[5]=o.suggestions,e[6]=s,e[7]=a}else a=e[7];let i;return e[13]!==n||e[14]!==d||e[15]!==a?(i=f("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:n,role:"listbox",style:d,children:a}),e[13]=n,e[14]=d,e[15]=a,e[16]=i):i=e[16],i},an=Le(Re.listTables),cn=Le(Re.readTablePage),dn=l=>{const e=Y(16),n=Oe();let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];const[o,s]=oe(t);let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r={},e[1]=r):r=e[1];const[d,a]=oe(r);let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=new Set,e[2]=i):i=e[2];const m=Se(i);let b,u;e[3]!==n||e[4]!==l?(b=()=>{const p={cancelled:!1};return ce((async()=>{try{const S=await n.query(an,{},Te(l));p.cancelled||(s(S.map(fn)),a({}),m.current=new Set)}catch{p.cancelled||(s([]),a({}),m.current=new Set)}})()),()=>{p.cancelled=!0}},u=[n,l],e[3]=n,e[4]=l,e[5]=b,e[6]=u):(b=e[5],u=e[6]),Ee(b,u);let x;e[7]!==n||e[8]!==l?(x=p=>{if(m.current.has(p))return;m.current.add(p),ce((async()=>{try{const S=await n.query(cn,{limit:1,offset:0,table:p},Te(l));a(w=>({...w,[p]:S.columns}))}catch{m.current.delete(p)}})())},e[7]=n,e[8]=l,e[9]=x):x=e[9];const c=x;let g;e[10]!==d||e[11]!==o?(g={columns:d,tables:o},e[10]=d,e[11]=o,e[12]=g):g=e[12];const y=g;let v;return e[13]!==c||e[14]!==y?(v={probe:c,schema:y},e[13]=c,e[14]=y,e[15]=v):v=e[15],v},Ae=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,un=l=>{const e=new Set;Ae.lastIndex=0;let n=Ae.exec(l);for(;n!==null;)e.add(n[1]??n[2]),n=Ae.exec(l);return[...e]};function fn(l){return l.name}const mn=l=>{const e=Y(34),{onSubmit:n,probe:t,schema:o,setDraft:s}=l,r=et(),d=Se(null),a=Se(null),i=Se(null),m=sn(o,i,s),{close:b,commit:u,commitAt:x,move:c,refresh:g,state:y}=m;let v;e[0]!==x?(v=E=>{x(E)},e[0]=x,e[1]=v):v=e[1];const p=v;let h;e[2]!==g?(h=()=>{const E=i.current;E!==null&&E===document.activeElement&&g(E.value,E.selectionStart)},e[2]=g,e[3]=h):h=e[3];let S;e[4]!==g||e[5]!==o?(S=[g,o],e[4]=g,e[5]=o,e[6]=S):S=e[6],Ee(h,S);let w;e[7]!==t||e[8]!==g||e[9]!==s?(w=E=>{const{selectionStart:B,value:F}=E.target;s(F);for(const W of un(F))t(W);g(F,B)},e[7]=t,e[8]=g,e[9]=s,e[10]=w):w=e[10];const C=w;let T;e[11]!==g?(T=E=>{const B=E.currentTarget;g(B.value,B.selectionStart)},e[11]=g,e[12]=T):T=e[12];const L=T;let R;e[13]!==y||e[14]!==b||e[15]!==u||e[16]!==c||e[17]!==n?(R=E=>{if(y!==null){if(E.key==="ArrowDown"){E.preventDefault(),c(1);return}if(E.key==="ArrowUp"){E.preventDefault(),c(-1);return}if(E.key==="Escape"){E.preventDefault(),b();return}if((E.key==="Enter"||E.key==="Tab")&&!E.metaKey&&!E.ctrlKey&&u()){E.preventDefault();return}}(E.metaKey||E.ctrlKey)&&E.key==="Enter"&&(E.preventDefault(),n())},e[13]=y,e[14]=b,e[15]=u,e[16]=c,e[17]=n,e[18]=R):R=e[18];const I=R;let N;e[19]!==b?(N=()=>{requestAnimationFrame(()=>{b()})},e[19]=b,e[20]=N):N=e[20];const _=N;let O;e[21]===Symbol.for("react.memo_cache_sentinel")?(O=E=>{const{scrollLeft:B,scrollTop:F}=E.currentTarget;d.current!==null&&(d.current.scrollTop=F),a.current!==null&&(a.current.scrollTop=F,a.current.scrollLeft=B)},e[21]=O):O=e[21];const A=O;let k;e[22]===Symbol.for("react.memo_cache_sentinel")?(k=E=>{const B=i.current;B===null||E.offset===void 0||(B.focus(),B.setSelectionRange(E.offset,E.offset+(E.length??0)))},e[22]=k):k=e[22];const q=k;let M;e[23]!==C||e[24]!==_||e[25]!==I||e[26]!==L?(M={onBlur:_,onChange:C,onKeyDown:I,onScroll:A,onSelect:L},e[23]=C,e[24]=_,e[25]=I,e[26]=L,e[27]=M):M=e[27];let D;return e[28]!==y||e[29]!==b||e[30]!==r||e[31]!==p||e[32]!==M?(D={autocompleteState:y,closeAutocomplete:b,handlers:M,listboxId:r,onPickSuggestion:p,editorRef:i,gutterRef:d,overlayRef:a,revealDiagnostic:q},e[28]=y,e[29]=b,e[30]=r,e[31]=p,e[32]=M,e[33]=D):D=e[33],D},hn="lunora-studio-sql-tabs",pn="lunora-studio-sql-active-tab",Me=12,ve=(l="",e="")=>({activeId:null,id:ze("tab"),name:e,sql:l}),bn=()=>Ue(pn,""),gn=l=>{const e=Y(16),[n,t]=_e(hn),[o,s]=bn(),[r]=oe(l);let d,a;e[0]!==r||e[1]!==t||e[2]!==n.length?(d=()=>{n.length===0&&t([r])},a=[r,t,n.length],e[0]=r,e[1]=t,e[2]=n.length,e[3]=d,e[4]=a):(d=e[3],a=e[4]),Ee(d,a);let i;e[5]!==r||e[6]!==n?(i=n.length===0?[r]:n,e[5]=r,e[6]=n,e[7]=i):i=e[7];const m=i;let b;e[8]!==o||e[9]!==m?(b=m.some(c=>c.id===o)?o:m[0]?.id??"",e[8]=o,e[9]=m,e[10]=b):b=e[10];const u=b;let x;return e[11]!==u||e[12]!==s||e[13]!==t||e[14]!==m?(x={activeId:u,setActiveId:s,setTabs:t,tabs:m},e[11]=u,e[12]=s,e[13]=t,e[14]=m,e[15]=x):x=e[15],x},Ve=l=>l.activeId===null&&l.sql.trim()!=="",xn=(l,e)=>[...l,e].slice(-Me),yn=(l,e,n)=>{const t=l.findIndex(r=>r.id===e);if(t===-1)return{activeId:l[0]?.id??"",tabs:[...l]};const o=l.filter(r=>r.id!==e);if(o.length===0){const r=n();return{activeId:r.id,tabs:[r]}}return{activeId:o[Math.min(t,o.length-1)].id,tabs:o}},vn=(l,e)=>{const n=l.filter(t=>t.id===e);return n.length===0?{activeId:l[0]?.id??"",tabs:[...l]}:{activeId:e,tabs:n}},Sn=(l,e,n)=>{const t=l.findIndex(s=>s.id===e);if(t===-1)return{activeId:n,tabs:[...l]};const o=l.slice(0,t+1);return{activeId:o.some(s=>s.id===n)?n:e,tabs:o}},wn=l=>{const e=l();return{activeId:e.id,tabs:[e]}},Cn=(l,e,n)=>{if(l==="others")return e.filter(t=>t.id!==n);if(l==="right"){const t=e.findIndex(o=>o.id===n);return t===-1?[]:e.slice(t+1)}return[...e]},Qe={error:null,pane:"results",result:null,running:!1},Nn=l=>{const e=Y(66),{activeId:n,setActiveId:t,setTabs:o,tabs:s}=gn(l);let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},e[0]=r):r=e[0];const[d,a]=oe(r),[i,m]=oe(null),[b,u]=oe(null);let x;e[1]!==n||e[2]!==s?(x=s.find(H=>H.id===n)??s[0]??ve(),e[1]=n,e[2]=s,e[3]=x):x=e[3];const c=x,g=d[c.id]??Qe;let y;e[4]!==c.id||e[5]!==o?(y=H=>{o(z=>z.map(j=>j.id===c.id?{...j,...H}:j))},e[4]=c.id,e[5]=o,e[6]=y):y=e[6];const v=y;let p;e[7]!==c.id?(p=H=>{a(z=>{const j=z[c.id]??Qe;return{...z,[c.id]:{...j,...H}}})},e[7]=c.id,e[8]=p):p=e[8];const h=p;let S;e[9]!==t||e[10]!==o||e[11]!==s.length?(S=()=>{if(s.length>=Me)return;const H=ve();o(z=>xn(z,H)),t(H.id)},e[9]=t,e[10]=o,e[11]=s.length,e[12]=S):S=e[12];const w=S;let C;e[13]!==t||e[14]!==o?(C=H=>{m(null),u(null),o(H.tabs),t(H.activeId);const z=new Set(H.tabs.map(Tn));a(j=>Object.fromEntries(Object.entries(j).filter(ie=>{const[ye]=ie;return z.has(ye)})))},e[13]=t,e[14]=o,e[15]=C):C=e[15];const T=C;let L;e[16]!==T||e[17]!==s?(L=H=>{T(yn(s,H,ve))},e[16]=T,e[17]=s,e[18]=L):L=e[18];const R=L;let I;e[19]!==n||e[20]!==T||e[21]!==s?(I=(H,z)=>{T(H==="others"?vn(s,z):H==="right"?Sn(s,z,n):wn(ve))},e[19]=n,e[20]=T,e[21]=s,e[22]=I):I=e[22];const N=I;let _;e[23]!==N||e[24]!==i||e[25]!==s?(_=H=>{i!==null&&(Cn(H,s,i.id).some(kn)?u(H):N(H,i.id))},e[23]=N,e[24]=i,e[25]=s,e[26]=_):_=e[26];const O=_;let A;e[27]===Symbol.for("react.memo_cache_sentinel")?(A=(H,z)=>{z.preventDefault(),u(null),m({id:H,x:z.clientX,y:z.clientY})},e[27]=A):A=e[27];const k=A;let q;e[28]===Symbol.for("react.memo_cache_sentinel")?(q=()=>{m(null),u(null)},e[28]=q):q=e[28];const M=q;let D;e[29]===Symbol.for("react.memo_cache_sentinel")?(D=H=>{H.preventDefault(),m(null),u(null)},e[29]=D):D=e[29];const E=D;let B;e[30]!==O?(B=()=>{O("others")},e[30]=O,e[31]=B):B=e[31];const F=B;let W;e[32]!==O?(W=()=>{O("right")},e[32]=O,e[33]=W):W=e[33];const U=W;let Q;e[34]!==O?(Q=()=>{O("all")},e[34]=O,e[35]=Q):Q=e[35];const K=Q;let G;e[36]!==N||e[37]!==b||e[38]!==i?(G=()=>{i!==null&&b!==null&&N(b,i.id),u(null)},e[36]=N,e[37]=b,e[38]=i,e[39]=G):G=e[39];const P=G;let V;e[40]===Symbol.for("react.memo_cache_sentinel")?(V=()=>{u(null)},e[40]=V):V=e[40];const ne=V;let J;e[41]!==i?(J=i===null?void 0:{left:i.x,top:i.y},e[41]=i,e[42]=J):J=e[42];const X=J;let Z;e[43]!==o?(Z=H=>{o(z=>z.map(j=>j.activeId===H?{...j,activeId:null}:j))},e[43]=o,e[44]=Z):Z=e[44];const ee=Z;let te;e[45]!==o?(te=(H,z)=>{o(j=>j.map(ie=>ie.id===H?{...ie,name:z}:ie))},e[45]=o,e[46]=te):te=e[46];const se=te;let ae;return e[47]!==c||e[48]!==n||e[49]!==w||e[50]!==R||e[51]!==P||e[52]!==K||e[53]!==F||e[54]!==U||e[55]!==g||e[56]!==h||e[57]!==v||e[58]!==b||e[59]!==se||e[60]!==t||e[61]!==i||e[62]!==X||e[63]!==s||e[64]!==ee?(ae={activeTab:c,activeTabId:n,addEditorTab:w,cancelBulk:ne,closeEditorTab:R,closeTabMenu:M,confirmBulk:P,menuStyle:X,onBackdropContextMenu:E,onCloseAll:K,onCloseOthers:F,onCloseToRight:U,openTabMenu:k,output:g,patchActiveOutput:h,patchActiveTab:v,pendingBulk:b,renameTab:se,setActiveTabId:t,tabMenu:i,tabs:s,unlinkQuery:ee},e[47]=c,e[48]=n,e[49]=w,e[50]=R,e[51]=P,e[52]=K,e[53]=F,e[54]=U,e[55]=g,e[56]=h,e[57]=v,e[58]=b,e[59]=se,e[60]=t,e[61]=i,e[62]=X,e[63]=s,e[64]=ee,e[65]=ae):ae=e[65],ae};function Tn(l){return l.id}function kn(l){return Ve(l)}const En="lunora-studio-sql-queries",Rn="lunora-studio-sql-history",Ln=25,In=l=>{const e=Y(33),{loadIntoActiveTab:n,unlinkQuery:t}=l,o=le(),[s,r]=_e(En),[d,a]=_e(Rn),[i,m]=oe(""),b=Se(null);let u;e[0]!==a?(u=k=>{a(q=>q[0]?.sql===k?q:[{at:Date.now(),sql:k},...q.filter(D=>D.sql!==k)].slice(0,Ln))},e[0]=a,e[1]=u):u=e[1];const x=u;let c;e[2]!==n||e[3]!==r||e[4]!==o?(c=()=>{const k={id:ze("q"),name:o("Untitled query"),sql:""};r(q=>[k,...q]),n("",k.id)},e[2]=n,e[3]=r,e[4]=o,e[5]=c):c=e[5];const g=c;let y;e[6]!==n||e[7]!==s?(y=k=>{const q=s.find(M=>M.id===k);q!==void 0&&(n(q.sql,k),b.current?.querySelector(`[data-testid="sql-query-${k}"]`)?.scrollIntoView({block:"nearest"}))},e[6]=n,e[7]=s,e[8]=y):y=e[8];const v=y;let p;e[9]!==r||e[10]!==t?(p=k=>{r(q=>q.filter(M=>M.id!==k)),t(k)},e[9]=r,e[10]=t,e[11]=p):p=e[11];const h=p;let S;e[12]!==n?(S=k=>{n(k.currentTarget.dataset.sql??"",null)},e[12]=n,e[13]=S):S=e[13];const w=S;let C;e[14]!==n?(C=k=>{n(k.currentTarget.dataset.sql??"",null)},e[14]=n,e[15]=C):C=e[15];const T=C;let L;e[16]!==a?(L=()=>{a([])},e[16]=a,e[17]=L):L=e[17];const R=L;let I;e[18]===Symbol.for("react.memo_cache_sentinel")?(I=k=>{m(k.target.value)},e[18]=I):I=e[18];const N=I;let _;e[19]!==r?(_=(k,q)=>{r(M=>M.map(D=>D.id===k?{...D,sql:q}:D))},e[19]=r,e[20]=_):_=e[20];const O=_;let A;return e[21]!==R||e[22]!==h||e[23]!==d||e[24]!==T||e[25]!==w||e[26]!==g||e[27]!==s||e[28]!==x||e[29]!==i||e[30]!==v||e[31]!==O?(A={clearHistory:R,deleteQuery:h,history:d,listRef:b,loadFromHistory:T,loadTemplate:w,newQuery:g,onSearchChange:N,queries:s,recordHistory:x,search:i,selectQuery:v,updateQuerySql:O},e[21]=R,e[22]=h,e[23]=d,e[24]=T,e[25]=w,e[26]=g,e[27]=s,e[28]=x,e[29]=i,e[30]=v,e[31]=O,e[32]=A):A=e[32],A},Je="p-3 font-mono text-xs leading-5 whitespace-pre-wrap break-words",qn=(l,e)=>{const n=[];for(const o of l){if(o.offset===void 0||o.length===void 0||o.length<=0)continue;const s=Math.max(0,Math.min(o.offset,e)),r=Math.max(s,Math.min(o.offset+o.length,e));s!==r&&n.push({end:r,severity:o.severity,start:s})}n.sort((o,s)=>o.start-s.start);const t=[];for(const o of n)o.start>=(t.at(-1)?.end??0)&&t.push(o);return t},An=l=>l==="unsafe-response"?"The model returned a statement that is not read-only, so it was discarded.":l==="empty-response"?"The model returned nothing usable.":"The model could not be reached.",_n=l=>{const e=Y(51),{assistant:n,failed:t,onGenerated:o}=l,s=le(),[r,d]=oe("");if(n.unavailable)return null;let a;e[0]!==n?(a=n.pending("sql"),e[0]=n,e[1]=a):a=e[1];const i=a;let m;if(e[2]!==n||e[3]!==t||e[4]!==o||e[5]!==i||e[6]!==r||e[7]!==s){const b=n.reason("sql");let u;e[9]!==n||e[10]!==t||e[11]!==o||e[12]!==r?(u=N=>{const _=r.trim();if(_===""&&!N)return;ce((async()=>{const A=await n.generate(_===""?"fix the failing statement":_,N?t:void 0);A!==void 0&&o(A)})())},e[9]=n,e[10]=t,e[11]=o,e[12]=r,e[13]=u):u=e[13];const x=u;let c;e[14]!==s?(c=s("Describe the query you want"),e[14]=s,e[15]=c):c=e[15];let g;e[16]===Symbol.for("react.memo_cache_sentinel")?(g=N=>{d(N.target.value)},e[16]=g):g=e[16];let y;e[17]!==x?(y=N=>{N.key==="Enter"&&(N.preventDefault(),x(!1))},e[17]=x,e[18]=y):y=e[18];let v;e[19]!==s?(v=s("Describe the query you want"),e[19]=s,e[20]=v):v=e[20];let p;e[21]!==i||e[22]!==r||e[23]!==c||e[24]!==y||e[25]!==v?(p=f(ot,{"aria-label":c,className:"h-7 flex-1 text-xs","data-testid":"sql-assistant-prompt",disabled:i,onChange:g,onKeyDown:y,placeholder:v,value:r}),e[21]=i,e[22]=r,e[23]=c,e[24]=y,e[25]=v,e[26]=p):p=e[26];const h=i&&"opacity-60";let S;e[27]!==h?(S=ue("rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",h),e[27]=h,e[28]=S):S=e[28];let w;e[29]!==i||e[30]!==r?(w=i||r.trim()==="",e[29]=i,e[30]=r,e[31]=w):w=e[31];let C;e[32]!==x?(C=()=>{x(!1)},e[32]=x,e[33]=C):C=e[33];let T;e[34]!==i||e[35]!==s?(T=s(i?"Thinking…":"Draft SQL"),e[34]=i,e[35]=s,e[36]=T):T=e[36];let L;e[37]!==S||e[38]!==w||e[39]!==C||e[40]!==T?(L=f("button",{className:S,"data-testid":"sql-assistant-generate",disabled:w,onClick:C,type:"button",children:T}),e[37]=S,e[38]=w,e[39]=C,e[40]=T,e[41]=L):L=e[41];let R;e[42]!==t||e[43]!==i||e[44]!==x||e[45]!==s?(R=t!==void 0&&f("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:i,onClick:()=>{x(!0)},type:"button",children:s("Fix this")}),e[42]=t,e[43]=i,e[44]=x,e[45]=s,e[46]=R):R=e[46];let I;e[47]!==L||e[48]!==R||e[49]!==p?(I=$("div",{className:"flex items-center gap-2",children:[p,L,R]}),e[47]=L,e[48]=R,e[49]=p,e[50]=I):I=e[50],m=$("div",{className:"flex flex-col gap-1 border-b border-border px-3 py-2","data-testid":"sql-assistant",children:[I,b!==void 0&&f("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-assistant-reason",role:"status",children:An(b)})]}),e[2]=n,e[3]=t,e[4]=o,e[5]=i,e[6]=r,e[7]=s,e[8]=m}else m=e[8];return m},On=l=>{const e=Y(8),{diagnostics:n,draft:t,scrollRef:o}=l;let s,r;if(e[0]!==n||e[1]!==t){r=Symbol.for("react.early_return_sentinel");e:{const i=qn(n,t.length);if(i.length===0){r=null;break e}s=[];let m=0;for(const[b,u]of i.entries())u.start>m&&s.push(t.slice(m,u.start)),s.push(f("span",{className:ue("decoration-wavy underline underline-offset-4",u.severity==="error"?"decoration-destructive":"decoration-amber-500"),children:t.slice(u.start,u.end)},`${u.start.toString()}-${b.toString()}`)),m=u.end;s.push(t.slice(m))}e[0]=n,e[1]=t,e[2]=s,e[3]=r}else s=e[2],r=e[3];if(r!==Symbol.for("react.early_return_sentinel"))return r;let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=ue("pointer-events-none absolute inset-0 overflow-hidden text-transparent",Je),e[4]=d):d=e[4];let a;return e[5]!==s||e[6]!==o?(a=f("div",{"aria-hidden":"true",className:d,"data-testid":"sql-diagnostics-overlay",ref:o,children:s}),e[5]=s,e[6]=o,e[7]=a):a=e[7],a},Dn={gate:"read-only",plan:"plan",schema:"schema",syntax:"syntax"},Mn=l=>{const e=Y(10),{diagnostics:n,onSelect:t}=l,o=le();if(n.length===0)return null;let s;e[0]!==o?(s=o("SQL problems"),e[0]=o,e[1]=s):s=e[1];let r;if(e[2]!==n||e[3]!==t){let a;e[5]!==t?(a=(i,m)=>f("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:()=>{t(i)},type:"button",children:[f("span",{className:ue("mt-px shrink-0 rounded px-1 font-mono text-[10px] uppercase",i.severity==="error"?"bg-destructive/15 text-destructive":"bg-amber-500/15 text-amber-600"),children:Dn[i.source]}),f("span",{className:"min-w-0 text-muted-foreground",children:i.message})]})},`${i.source}-${(i.offset??m).toString()}-${m.toString()}`),e[5]=t,e[6]=a):a=e[6],r=n.map(a),e[2]=n,e[3]=t,e[4]=r}else r=e[4];let d;return e[7]!==s||e[8]!==r?(d=f("ul",{"aria-label":s,className:"max-h-24 shrink-0 overflow-y-auto border-t border-border bg-muted/30","data-testid":"sql-problems",children:r}),e[7]=s,e[8]=r,e[9]=d):d=e[9],d},$n={minWidth:"2.75rem",paddingInline:"0.5rem"},Bn=l=>{const e=Y(64),{assistant:n,autocomplete:t,diagnostics:o,draft:s,failed:r,handlers:d,editorRef:a,gutterRef:i,listboxId:m,onGenerated:b,onPickSuggestion:u,onRevealDiagnostic:x,overlayRef:c}=l,g=le();let y,v,p,h,S,w,C,T;if(e[0]!==n||e[1]!==s||e[2]!==r||e[3]!==i||e[4]!==b){const B=s.split(`
@@ -1 +1 @@
1
- import{c as V}from"react/compiler-runtime";import{useLunora as k}from"@lunora/react";import{useNavigate as F,useRouter as L,useSearch as M}from"@tanstack/react-router";import{useState as Q,useEffect as A}from"react";import{T as w}from"../packem_shared/storage-tier-C2mKwYRj.js";import{u as P}from"../packem_shared/table-list-sidebar-Bluzd1_2.js";import{useT as q}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{s as J,d as D}from"../packem_shared/data-view-params-qoSTqjAj.js";import{f}from"../packem_shared/internal-CwaF9YNk.js";import{l as K,s as O}from"../packem_shared/browser-storage-Br_bLeBt.js";import{DataBrowser as I}from"../packem_shared/DataBrowser-BnDIFN-S.js";import{GlobalDataBrowser as X}from"../packem_shared/GlobalDataBrowser-DusjXzRF.js";import{jsx as v,jsxs as E}from"react/jsx-runtime";const N="lunora-studio-saved-queries",Y=50,$=r=>r!==null&&typeof r=="object"&&typeof r.name=="string"&&typeof r.view=="object"&&r.view!==null,S=()=>K(N).filter($),B=r=>{O(N,r)},z=(r,e)=>{const s=r.trim();if(s==="")return S();const o=[{name:s,view:e},...S().filter(b=>b.name!==s)].slice(0,Y);return B(o),o},H=r=>{const e=S().filter(s=>s.name!==r);return B(e),e},U=r=>{const e=V(15),{onChange:s,tier:o}=r,b=q();let d;e[0]!==s?(d=y=>{s(y.target.value)},e[0]=s,e[1]=d):d=e[1];const l=d;let h;e[2]!==b?(h=b("Storage tier"),e[2]=b,e[3]=h):h=e[3];let i;e[4]!==h?(i=v("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:h}),e[4]=h,e[5]=i):i=e[5];const m=w[o];let n,g;e[6]===Symbol.for("react.memo_cache_sentinel")?(n=v("option",{value:"shard",children:w.shard.label}),g=v("option",{value:"global",children:w.global.label}),e[6]=n,e[7]=g):(n=e[6],g=e[7]);let c;e[8]!==l||e[9]!==m.title||e[10]!==o?(c=E("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:l,title:m.title,value:o,children:[n,g]}),e[8]=l,e[9]=m.title,e[10]=o,e[11]=c):c=e[11];let u;return e[12]!==i||e[13]!==c?(u=E("label",{className:"flex w-full flex-col gap-1",htmlFor:"table-editor-schema",children:[i,c]}),e[12]=i,e[13]=c,e[14]=u):u=e[14],u},W=()=>{try{f(globalThis.navigator.clipboard.writeText(globalThis.location.href))}catch{}},pe=({editable:r=!1,initialShardKey:e})=>{const s=k(),o=F(),b=L(),d=M({strict:!1}),l=J(d),h=P(d),i=()=>b.state.location.pathname.split("/").findLast(Boolean)==="data",m=l.tier??"shard",n=l.table,[g,c]=Q(()=>S()),[u,y]=Q(()=>new Set);A(()=>{f((async()=>{try{const a=await s.listGlobalTables();y(new Set(a.map(t=>t.name)))}catch{}})())},[s]),A(()=>{m==="shard"&&n!==void 0&&u.has(n)&&f(o({replace:!0,search:a=>({...a,schema:"global"}),to:"/data"}))},[u,o,n,m]);const R=a=>{f(o({search:t=>({...t,schema:a==="global"?"global":void 0,table:void 0}),to:"/data"}))},T=(a,t)=>{i()&&f(o({search:p=>({schema:p.schema,search:t?.search,shard:p.shard,table:a}),to:"/data"}))},C=a=>{f(o({search:t=>({...t,schema:"global",table:a}),to:"/data"}))},G=a=>{const t=D(a),{current:p}=h;(p.filters??void 0)===t.filters&&(p.order??void 0)===t.order&&(p.search??void 0)===t.search&&(p.shard??void 0)===t.shard||!i()||f(o({replace:!0,search:j=>({...j,filters:t.filters,order:t.order,search:t.search,shard:t.shard}),to:"/data"}))},_={onApplyQuery:a=>{const t=D(a.view);f(o({search:()=>({filters:t.filters,order:t.order,schema:t.schema,search:t.search,shard:t.shard,table:t.table}),to:"/data"}))},onCopyLink:W,onDeleteQuery:a=>{c(H(a))},onSaveQuery:(a,t)=>{c(z(a,t))},saved:g},x=v(U,{onChange:R,tier:m});return m==="global"?v(X,{initialTable:n,onSelectTable:T,schemaSwitch:x}):v(I,{editable:r,globalTableNames:u,initialFilters:l.filters,initialOrderBy:l.orderBy,initialPins:d.pins,initialSearch:l.search,initialShardKey:l.shard??e,onNavigateToGlobal:C,onSelectTable:T,onViewChange:G,queryBar:_,schemaSwitch:x,tableParam:n})};export{pe as TableEditor};
1
+ import{c as V}from"react/compiler-runtime";import{useLunora as k}from"@lunora/react";import{useNavigate as F,useRouter as L,useSearch as M}from"@tanstack/react-router";import{useState as Q,useEffect as A}from"react";import{T as w}from"../packem_shared/storage-tier-C2mKwYRj.js";import{u as P}from"../packem_shared/table-list-sidebar-BCxqrZ0s.js";import{useT as q}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{s as J,d as D}from"../packem_shared/data-view-params-qoSTqjAj.js";import{f}from"../packem_shared/internal-7bgd8inO.js";import{l as K,s as O}from"../packem_shared/browser-storage-Br_bLeBt.js";import{DataBrowser as I}from"../packem_shared/DataBrowser-CrkvQAMf.js";import{GlobalDataBrowser as X}from"../packem_shared/GlobalDataBrowser-BHFgEqMl.js";import{jsx as v,jsxs as E}from"react/jsx-runtime";const N="lunora-studio-saved-queries",Y=50,$=r=>r!==null&&typeof r=="object"&&typeof r.name=="string"&&typeof r.view=="object"&&r.view!==null,S=()=>K(N).filter($),B=r=>{O(N,r)},z=(r,e)=>{const s=r.trim();if(s==="")return S();const o=[{name:s,view:e},...S().filter(b=>b.name!==s)].slice(0,Y);return B(o),o},H=r=>{const e=S().filter(s=>s.name!==r);return B(e),e},U=r=>{const e=V(15),{onChange:s,tier:o}=r,b=q();let d;e[0]!==s?(d=y=>{s(y.target.value)},e[0]=s,e[1]=d):d=e[1];const l=d;let h;e[2]!==b?(h=b("Storage tier"),e[2]=b,e[3]=h):h=e[3];let i;e[4]!==h?(i=v("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:h}),e[4]=h,e[5]=i):i=e[5];const m=w[o];let n,g;e[6]===Symbol.for("react.memo_cache_sentinel")?(n=v("option",{value:"shard",children:w.shard.label}),g=v("option",{value:"global",children:w.global.label}),e[6]=n,e[7]=g):(n=e[6],g=e[7]);let c;e[8]!==l||e[9]!==m.title||e[10]!==o?(c=E("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:l,title:m.title,value:o,children:[n,g]}),e[8]=l,e[9]=m.title,e[10]=o,e[11]=c):c=e[11];let u;return e[12]!==i||e[13]!==c?(u=E("label",{className:"flex w-full flex-col gap-1",htmlFor:"table-editor-schema",children:[i,c]}),e[12]=i,e[13]=c,e[14]=u):u=e[14],u},W=()=>{try{f(globalThis.navigator.clipboard.writeText(globalThis.location.href))}catch{}},pe=({editable:r=!1,initialShardKey:e})=>{const s=k(),o=F(),b=L(),d=M({strict:!1}),l=J(d),h=P(d),i=()=>b.state.location.pathname.split("/").findLast(Boolean)==="data",m=l.tier??"shard",n=l.table,[g,c]=Q(()=>S()),[u,y]=Q(()=>new Set);A(()=>{f((async()=>{try{const a=await s.listGlobalTables();y(new Set(a.map(t=>t.name)))}catch{}})())},[s]),A(()=>{m==="shard"&&n!==void 0&&u.has(n)&&f(o({replace:!0,search:a=>({...a,schema:"global"}),to:"/data"}))},[u,o,n,m]);const R=a=>{f(o({search:t=>({...t,schema:a==="global"?"global":void 0,table:void 0}),to:"/data"}))},T=(a,t)=>{i()&&f(o({search:p=>({schema:p.schema,search:t?.search,shard:p.shard,table:a}),to:"/data"}))},C=a=>{f(o({search:t=>({...t,schema:"global",table:a}),to:"/data"}))},G=a=>{const t=D(a),{current:p}=h;(p.filters??void 0)===t.filters&&(p.order??void 0)===t.order&&(p.search??void 0)===t.search&&(p.shard??void 0)===t.shard||!i()||f(o({replace:!0,search:j=>({...j,filters:t.filters,order:t.order,search:t.search,shard:t.shard}),to:"/data"}))},_={onApplyQuery:a=>{const t=D(a.view);f(o({search:()=>({filters:t.filters,order:t.order,schema:t.schema,search:t.search,shard:t.shard,table:t.table}),to:"/data"}))},onCopyLink:W,onDeleteQuery:a=>{c(H(a))},onSaveQuery:(a,t)=>{c(z(a,t))},saved:g},x=v(U,{onChange:R,tier:m});return m==="global"?v(X,{initialTable:n,onSelectTable:T,schemaSwitch:x}):v(I,{editable:r,globalTableNames:u,initialFilters:l.filters,initialOrderBy:l.orderBy,initialPins:d.pins,initialSearch:l.search,initialShardKey:l.shard??e,onNavigateToGlobal:C,onSelectTable:T,onViewChange:G,queryBar:_,schemaSwitch:x,tableParam:n})};export{pe as TableEditor};
@@ -1 +1 @@
1
- import{useState as Y}from"react";import{E as I}from"../packem_shared/error-alert-TYdKetJd.js";import{B as N}from"../packem_shared/badge-cAk9Di1Q.js";import{B as q}from"../packem_shared/button-BOPLD1un.js";import{C as R,a as $}from"../packem_shared/card-BGlQzQY-.js";import{E as j}from"../packem_shared/empty-state-B939z6K2.js";import{T as K,a as L,b as p,c as o,d as P,e as d}from"../packem_shared/table-BMsuYFhk.js";import{u as f}from"../packem_shared/use-admin-query-P0RJrjsD.js";import{useT as Z}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as x}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as ee}from"../packem_shared/internal-CwaF9YNk.js";import{jsx as e,jsxs as l}from"react/jsx-runtime";const D="agent_threads",te="agent_messages",M="agent_run_queue",H=100,ae=250,se={},re={filters:[],limit:H,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:D},i=(r,t)=>{const s=r[t];return typeof s=="string"?s:void 0},A=(r,t)=>{const s=r[t];return typeof s=="number"?s:void 0},U=r=>{const{usage:t}=r;if(t===null||typeof t!="object")return;const{totalTokens:s}=t;return typeof s=="number"?s:void 0},ne=r=>{const{toolCalls:t}=r;return Array.isArray(t)?t.map(s=>s!==null&&typeof s=="object"?s.name:void 0).filter(s=>typeof s=="string"):[]},oe=r=>{switch(r){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},de=r=>{switch(r){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},be=({initialShardKey:r=""})=>{const t=Z(),[s,T]=Y(void 0),{data:c}=f(x.listTables,se,{live:!0,shardKey:r}),G=c!==void 0,m=Array.isArray(c)&&c.some(a=>a.name===D),Q=Array.isArray(c)&&c.some(a=>a.name===M),{data:E,error:_,errorSource:z,liveError:O}=f(x.readTablePage,re,{enabled:m,live:!0,shardKey:r}),V={filters:[{column:"threadKey",operator:"eq",value:s??""}],limit:ae,offset:0,orderBy:{column:"seq",direction:"asc"},skipCount:!0,table:te},{data:S}=f(x.readTablePage,{limit:H,offset:0,orderBy:{column:"position",direction:"asc"},skipCount:!0,table:M},{enabled:Q,live:!0,shardKey:r}),{data:k,error:F,errorSource:J}=f(x.readTablePage,V,{enabled:m&&s!==void 0,live:!0,shardKey:r}),v=Array.isArray(E?.rows)?E.rows:[],W=Array.isArray(S?.rows)?S.rows:[],w=a=>W.filter(n=>i(n,"threadKey")===a).length,C=Array.isArray(k?.rows)?k.rows:[],B=v.find(a=>i(a,"key")===s);let h;return G&&!m?h=e(j,{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&&v.length===0?h=e(j,{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")}):h=l("div",{className:"flex flex-col gap-6",children:[e(R,{className:"overflow-hidden py-0",children:e($,{className:"px-0",children:l(K,{"data-testid":"agents-threads-table",children:[e(L,{children:l(p,{children:[e(o,{children:t("Agent")}),e(o,{children:t("Key")}),e(o,{children:t("Status")}),e(o,{children:t("Queued")}),e(o,{children:t("Messages")}),e(o,{children:t("Tokens")}),e(o,{children:t("Updated")}),e(o,{"aria-label":t("Actions")})]})}),e(P,{children:v.map(a=>{const n=i(a,"key")??"",u=i(a,"status"),g=U(a);return l(p,{"data-active":n===s?"":void 0,"data-testid":`agents-thread-${n}`,children:[e(d,{className:"font-mono text-xs",children:i(a,"agent")??"—"}),e(d,{className:"font-mono text-xs text-muted-foreground",children:n}),e(d,{children:e(N,{"data-testid":`agents-thread-status-${n}`,variant:oe(u),children:u??"—"})}),e(d,{className:"tabular-nums",children:w(n)===0?e("span",{className:"text-muted-foreground",children:"—"}):e(N,{"data-testid":`agents-thread-queued-${n}`,variant:"warning",children:w(n)})}),e(d,{className:"tabular-nums",children:A(a,"messageCount")??"—"}),e(d,{className:"tabular-nums text-muted-foreground",children:g??"—"}),e(d,{className:"text-muted-foreground tabular-nums",children:ee(A(a,"updatedAt"),"—")}),e(d,{className:"text-right",children:e(q,{"data-testid":`agents-thread-open-${n}`,onClick:()=>{T(n)},size:"sm",type:"button",variant:"outline",children:t("Timeline")})})]},n)})})]})})}),F!==null&&e(I,{error:J,testId:"agents-messages-error"}),s!==void 0&&e(R,{className:"overflow-hidden py-0","data-testid":"agents-thread-detail",children:l($,{className:"flex flex-col gap-3 px-4 py-3",children:[l("div",{className:"flex items-center justify-between gap-2",children:[l("span",{className:"font-mono text-xs",children:[t("Timeline")," · ",s,B!==void 0&&l("span",{className:"text-muted-foreground",children:[" · ",t("Usage"),": ",U(B)??0," ",t("Tokens")]})]}),e(q,{"data-testid":"agents-thread-detail-close",onClick:()=>{T(void 0)},size:"xs",type:"button",variant:"ghost",children:t("Close")})]}),C.length===0?e("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")}):l(K,{"data-testid":"agents-messages-table",children:[e(L,{children:l(p,{children:[e(o,{children:t("Role")}),e(o,{children:t("Content")}),e(o,{children:t("Tool")}),e(o,{children:t("Approval")})]})}),e(P,{children:C.map((a,n)=>{const u=i(a,"role")??"—",g=ne(a),X=i(a,"toolName"),y=i(a,"status"),b=A(a,"seq")??n;return l(p,{"data-testid":`agents-message-${String(b)}`,children:[e(d,{className:"font-mono text-xs align-top text-muted-foreground",children:u}),e(d,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:i(a,"content")??"—"}),e(d,{className:"font-mono text-xs align-top text-muted-foreground",children:X??(g.length>0?g.join(", "):"—")}),e(d,{className:"align-top",children:y===void 0?e("span",{className:"text-xs text-muted-foreground",children:"—"}):e(N,{"data-testid":`agents-message-approval-${String(b)}`,variant:de(y),children:y})})]},i(a,"messageKey")??`${u}:${String(b)}`)})})]})]})})]}),l("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[_!==null&&e(I,{error:z,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.")}),O!==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.")}),h]})};export{be as default};
1
+ import{useState as Y}from"react";import{E as I}from"../packem_shared/error-alert-CKqB2CiN.js";import{B as N}from"../packem_shared/badge-cAk9Di1Q.js";import{B as q}from"../packem_shared/button-BOPLD1un.js";import{C as R,a as $}from"../packem_shared/card-BGlQzQY-.js";import{E as j}from"../packem_shared/empty-state-B939z6K2.js";import{T as K,a as L,b as p,c as o,d as P,e as d}from"../packem_shared/table-BMsuYFhk.js";import{u as f}from"../packem_shared/use-admin-query-DV9xmFl8.js";import{useT as Z}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as x}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as ee}from"../packem_shared/internal-7bgd8inO.js";import{jsx as e,jsxs as l}from"react/jsx-runtime";const D="agent_threads",te="agent_messages",M="agent_run_queue",H=100,ae=250,se={},re={filters:[],limit:H,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:D},i=(r,t)=>{const s=r[t];return typeof s=="string"?s:void 0},A=(r,t)=>{const s=r[t];return typeof s=="number"?s:void 0},U=r=>{const{usage:t}=r;if(t===null||typeof t!="object")return;const{totalTokens:s}=t;return typeof s=="number"?s:void 0},ne=r=>{const{toolCalls:t}=r;return Array.isArray(t)?t.map(s=>s!==null&&typeof s=="object"?s.name:void 0).filter(s=>typeof s=="string"):[]},oe=r=>{switch(r){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},de=r=>{switch(r){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},be=({initialShardKey:r=""})=>{const t=Z(),[s,T]=Y(void 0),{data:c}=f(x.listTables,se,{live:!0,shardKey:r}),G=c!==void 0,m=Array.isArray(c)&&c.some(a=>a.name===D),Q=Array.isArray(c)&&c.some(a=>a.name===M),{data:E,error:_,errorSource:z,liveError:O}=f(x.readTablePage,re,{enabled:m,live:!0,shardKey:r}),V={filters:[{column:"threadKey",operator:"eq",value:s??""}],limit:ae,offset:0,orderBy:{column:"seq",direction:"asc"},skipCount:!0,table:te},{data:S}=f(x.readTablePage,{limit:H,offset:0,orderBy:{column:"position",direction:"asc"},skipCount:!0,table:M},{enabled:Q,live:!0,shardKey:r}),{data:k,error:F,errorSource:J}=f(x.readTablePage,V,{enabled:m&&s!==void 0,live:!0,shardKey:r}),v=Array.isArray(E?.rows)?E.rows:[],W=Array.isArray(S?.rows)?S.rows:[],w=a=>W.filter(n=>i(n,"threadKey")===a).length,C=Array.isArray(k?.rows)?k.rows:[],B=v.find(a=>i(a,"key")===s);let h;return G&&!m?h=e(j,{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&&v.length===0?h=e(j,{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")}):h=l("div",{className:"flex flex-col gap-6",children:[e(R,{className:"overflow-hidden py-0",children:e($,{className:"px-0",children:l(K,{"data-testid":"agents-threads-table",children:[e(L,{children:l(p,{children:[e(o,{children:t("Agent")}),e(o,{children:t("Key")}),e(o,{children:t("Status")}),e(o,{children:t("Queued")}),e(o,{children:t("Messages")}),e(o,{children:t("Tokens")}),e(o,{children:t("Updated")}),e(o,{"aria-label":t("Actions")})]})}),e(P,{children:v.map(a=>{const n=i(a,"key")??"",u=i(a,"status"),g=U(a);return l(p,{"data-active":n===s?"":void 0,"data-testid":`agents-thread-${n}`,children:[e(d,{className:"font-mono text-xs",children:i(a,"agent")??"—"}),e(d,{className:"font-mono text-xs text-muted-foreground",children:n}),e(d,{children:e(N,{"data-testid":`agents-thread-status-${n}`,variant:oe(u),children:u??"—"})}),e(d,{className:"tabular-nums",children:w(n)===0?e("span",{className:"text-muted-foreground",children:"—"}):e(N,{"data-testid":`agents-thread-queued-${n}`,variant:"warning",children:w(n)})}),e(d,{className:"tabular-nums",children:A(a,"messageCount")??"—"}),e(d,{className:"tabular-nums text-muted-foreground",children:g??"—"}),e(d,{className:"text-muted-foreground tabular-nums",children:ee(A(a,"updatedAt"),"—")}),e(d,{className:"text-right",children:e(q,{"data-testid":`agents-thread-open-${n}`,onClick:()=>{T(n)},size:"sm",type:"button",variant:"outline",children:t("Timeline")})})]},n)})})]})})}),F!==null&&e(I,{error:J,testId:"agents-messages-error"}),s!==void 0&&e(R,{className:"overflow-hidden py-0","data-testid":"agents-thread-detail",children:l($,{className:"flex flex-col gap-3 px-4 py-3",children:[l("div",{className:"flex items-center justify-between gap-2",children:[l("span",{className:"font-mono text-xs",children:[t("Timeline")," · ",s,B!==void 0&&l("span",{className:"text-muted-foreground",children:[" · ",t("Usage"),": ",U(B)??0," ",t("Tokens")]})]}),e(q,{"data-testid":"agents-thread-detail-close",onClick:()=>{T(void 0)},size:"xs",type:"button",variant:"ghost",children:t("Close")})]}),C.length===0?e("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")}):l(K,{"data-testid":"agents-messages-table",children:[e(L,{children:l(p,{children:[e(o,{children:t("Role")}),e(o,{children:t("Content")}),e(o,{children:t("Tool")}),e(o,{children:t("Approval")})]})}),e(P,{children:C.map((a,n)=>{const u=i(a,"role")??"—",g=ne(a),X=i(a,"toolName"),y=i(a,"status"),b=A(a,"seq")??n;return l(p,{"data-testid":`agents-message-${String(b)}`,children:[e(d,{className:"font-mono text-xs align-top text-muted-foreground",children:u}),e(d,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:i(a,"content")??"—"}),e(d,{className:"font-mono text-xs align-top text-muted-foreground",children:X??(g.length>0?g.join(", "):"—")}),e(d,{className:"align-top",children:y===void 0?e("span",{className:"text-xs text-muted-foreground",children:"—"}):e(N,{"data-testid":`agents-message-approval-${String(b)}`,variant:de(y),children:y})})]},i(a,"messageKey")??`${u}:${String(b)}`)})})]})]})})]}),l("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[_!==null&&e(I,{error:z,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.")}),O!==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.")}),h]})};export{be as default};
@@ -1 +1 @@
1
- import{c as g}from"react/compiler-runtime";import{createAnalyticsSqlClient as L}from"@lunora/bindings/analytics";import{useState as C,useMemo as I,useCallback as k,useEffect as N}from"react";import{C as _}from"../packem_shared/card-BGlQzQY-.js";import{E as v}from"../packem_shared/empty-state-B939z6K2.js";import{T as O,a as D,b,d as M,e as q,c as w}from"../packem_shared/table-BMsuYFhk.js";import{useT as x}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{b as B,f as P,h as U}from"../packem_shared/internal-CwaF9YNk.js";import{jsx as n,jsxs as A}from"react/jsx-runtime";const F="ANALYTICS",T=[{key:"volume",sql:r=>`SELECT blob2 AS fn, count() AS calls FROM ${r} WHERE blob1 = 'function_call' GROUP BY fn ORDER BY calls DESC LIMIT 25`,title:"Request volume per function"},{key:"latency",sql:r=>`SELECT blob2 AS fn, quantileWeighted(0.50)(double1, _sample_interval) AS p50, quantileWeighted(0.95)(double1, _sample_interval) AS p95 FROM ${r} WHERE blob1 = 'function_call' GROUP BY fn ORDER BY p95 DESC LIMIT 25`,title:"Latency p50 / p95 per function"},{key:"hotShards",sql:r=>`SELECT blob3 AS shard, count() AS calls FROM ${r} WHERE blob1 = 'function_call' GROUP BY shard ORDER BY calls DESC LIMIT 25`,title:"Hot shards"}],Y={error:null,loading:!0,result:null},H=r=>{const e=g(27),{state:h,title:u}=r,c=x(),{error:a,loading:t,result:s}=h,l=`analytics-panel-${u}`;let o;e[0]!==c||e[1]!==u?(o=c(u),e[0]=c,e[1]=u,e[2]=o):o=e[2];let i;e[3]!==o?(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:o})}),e[3]=o,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]!==a||e[9]!==t?(m=!t&&a!==null&&n("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"analytics-error",role:"alert",children:a}),e[8]=a,e[9]=t,e[10]=m):m=e[10];let p;e[11]!==a||e[12]!==t||e[13]!==s||e[14]!==c?(p=!t&&a===null&&s!==null&&s.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]=a,e[12]=t,e[13]=s,e[14]=c,e[15]=p):p=e[15];let f;e[16]!==a||e[17]!==t||e[18]!==s?(f=!t&&a===null&&s!==null&&s.rows.length>0&&A(O,{children:[n(D,{children:n(b,{children:s.columns.map(W)})}),n(M,{children:s.rows.map((S,R)=>n(b,{children:s.columns.map(E=>n(q,{className:"font-mono text-xs",children:U(S[E.name])},E.name))},R))})]}),e[16]=a,e[17]=t,e[18]=s,e[19]=f):f=e[19];let y;return e[20]!==l||e[21]!==i||e[22]!==d||e[23]!==m||e[24]!==p||e[25]!==f?(y=A(_,{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]=y):y=e[26],y},Q=({config:r,dataset:e=F,runQuery:h}={})=>{const u=x(),[c,a]=C({}),t=I(()=>{if(h!==void 0)return h;if(r===void 0)return null;const l=L({accountId:r.accountId,apiToken:r.apiToken});return o=>l.query(o)},[r,h]),s=k(async l=>{if(t!==null)for(const o of T){if(l.cancelled)return;a(i=>({...i,[o.key]:{error:null,loading:!0,result:null}}));try{const i=await t(o.sql(e));l.cancelled||a(d=>({...d,[o.key]:{error:null,loading:!1,result:i}}))}catch(i){l.cancelled||a(d=>({...d,[o.key]:{error:B(i),loading:!1,result:null}}))}}},[t,e]);return N(()=>{const l={cancelled:!1};return P(s(l)),()=>{l.cancelled=!0}},[s]),t===null?n(v,{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:T.map(l=>n(H,{state:c[l.key]??Y,title:l.title},l.key))})};function W(r){return n(w,{children:r.name},r.name)}export{Q as AnalyticsPanel};
1
+ import{c as g}from"react/compiler-runtime";import{createAnalyticsSqlClient as L}from"@lunora/bindings/analytics";import{useState as C,useMemo as I,useCallback as k,useEffect as N}from"react";import{C as _}from"../packem_shared/card-BGlQzQY-.js";import{E as v}from"../packem_shared/empty-state-B939z6K2.js";import{T as O,a as D,b,d as M,e as q,c as w}from"../packem_shared/table-BMsuYFhk.js";import{useT as x}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{b as B,f as P,h as U}from"../packem_shared/internal-7bgd8inO.js";import{jsx as n,jsxs as A}from"react/jsx-runtime";const F="ANALYTICS",T=[{key:"volume",sql:r=>`SELECT blob2 AS fn, count() AS calls FROM ${r} WHERE blob1 = 'function_call' GROUP BY fn ORDER BY calls DESC LIMIT 25`,title:"Request volume per function"},{key:"latency",sql:r=>`SELECT blob2 AS fn, quantileWeighted(0.50)(double1, _sample_interval) AS p50, quantileWeighted(0.95)(double1, _sample_interval) AS p95 FROM ${r} WHERE blob1 = 'function_call' GROUP BY fn ORDER BY p95 DESC LIMIT 25`,title:"Latency p50 / p95 per function"},{key:"hotShards",sql:r=>`SELECT blob3 AS shard, count() AS calls FROM ${r} WHERE blob1 = 'function_call' GROUP BY shard ORDER BY calls DESC LIMIT 25`,title:"Hot shards"}],Y={error:null,loading:!0,result:null},H=r=>{const e=g(27),{state:h,title:u}=r,c=x(),{error:a,loading:t,result:s}=h,l=`analytics-panel-${u}`;let o;e[0]!==c||e[1]!==u?(o=c(u),e[0]=c,e[1]=u,e[2]=o):o=e[2];let i;e[3]!==o?(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:o})}),e[3]=o,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]!==a||e[9]!==t?(m=!t&&a!==null&&n("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"analytics-error",role:"alert",children:a}),e[8]=a,e[9]=t,e[10]=m):m=e[10];let p;e[11]!==a||e[12]!==t||e[13]!==s||e[14]!==c?(p=!t&&a===null&&s!==null&&s.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]=a,e[12]=t,e[13]=s,e[14]=c,e[15]=p):p=e[15];let f;e[16]!==a||e[17]!==t||e[18]!==s?(f=!t&&a===null&&s!==null&&s.rows.length>0&&A(O,{children:[n(D,{children:n(b,{children:s.columns.map(W)})}),n(M,{children:s.rows.map((S,R)=>n(b,{children:s.columns.map(E=>n(q,{className:"font-mono text-xs",children:U(S[E.name])},E.name))},R))})]}),e[16]=a,e[17]=t,e[18]=s,e[19]=f):f=e[19];let y;return e[20]!==l||e[21]!==i||e[22]!==d||e[23]!==m||e[24]!==p||e[25]!==f?(y=A(_,{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]=y):y=e[26],y},Q=({config:r,dataset:e=F,runQuery:h}={})=>{const u=x(),[c,a]=C({}),t=I(()=>{if(h!==void 0)return h;if(r===void 0)return null;const l=L({accountId:r.accountId,apiToken:r.apiToken});return o=>l.query(o)},[r,h]),s=k(async l=>{if(t!==null)for(const o of T){if(l.cancelled)return;a(i=>({...i,[o.key]:{error:null,loading:!0,result:null}}));try{const i=await t(o.sql(e));l.cancelled||a(d=>({...d,[o.key]:{error:null,loading:!1,result:i}}))}catch(i){l.cancelled||a(d=>({...d,[o.key]:{error:B(i),loading:!1,result:null}}))}}},[t,e]);return N(()=>{const l={cancelled:!1};return P(s(l)),()=>{l.cancelled=!0}},[s]),t===null?n(v,{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:T.map(l=>n(H,{state:c[l.key]??Y,title:l.title},l.key))})};function W(r){return n(w,{children:r.name},r.name)}export{Q as AnalyticsPanel};
@@ -1 +1 @@
1
- import{c as R}from"react/compiler-runtime";import{useState as k}from"react";import{E as q}from"../packem_shared/error-alert-TYdKetJd.js";import{B as j}from"../packem_shared/badge-cAk9Di1Q.js";import{B as z}from"../packem_shared/button-BOPLD1un.js";import{C as D,a as M}from"../packem_shared/card-BGlQzQY-.js";import{E as O}from"../packem_shared/empty-state-B939z6K2.js";import{I as Q}from"../packem_shared/input-CY5W3wzv.js";import{T as U,a as $,b as F,c as N,d as G,e as w}from"../packem_shared/table-BMsuYFhk.js";import{u as J}from"../packem_shared/use-admin-query-P0RJrjsD.js";import{useT as K}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as V}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as W}from"../packem_shared/internal-CwaF9YNk.js";import{jsx as a,jsxs as l}from"react/jsx-runtime";const ne=()=>{const e=R(39),t=K(),[o,H]=k("");let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const{data:L,error:i,errorSource:S,isLoading:E,refetch:B}=J(V.getAuthAuditLog,b);let A;if(e[1]!==L?.entries||e[2]!==o){const r=L?.entries??[],x=o.trim().toLowerCase();A=x===""?r:r.filter(C=>C.event.toLowerCase().includes(x)||(C.actorId??"").toLowerCase().includes(x)||(C.actorEmail??"").toLowerCase().includes(x)||(C.ip??"").toLowerCase().includes(x)||C.outcome.toLowerCase().includes(x)),e[1]=L?.entries,e[2]=o,e[3]=A}else A=e[3];const s=A;let I;e[4]===Symbol.for("react.memo_cache_sentinel")?(I=r=>{H(r.target.value)},e[4]=I):I=e[4];const P=I;let c;e[5]!==t?(c=t("Filter security events"),e[5]=t,e[6]=c):c=e[6];let n;e[7]!==t?(n=t("filter event, actor, IP"),e[7]=t,e[8]=n):n=e[8];let d;e[9]!==o||e[10]!==c||e[11]!==n?(d=a(Q,{"aria-label":c,className:"h-8 w-56","data-testid":"aa-search",onChange:P,placeholder:n,value:o}),e[9]=o,e[10]=c,e[11]=n,e[12]=d):d=e[12];let m;e[13]!==B?(m=()=>{B()},e[13]=B,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=a(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=l("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]!==i||e[24]!==S?(p=i!==null&&a(q,{error:S,testId:"aa-error"}),e[23]=i,e[24]=S,e[25]=p):p=e[25];let g;e[26]!==i||e[27]!==s.length||e[28]!==E||e[29]!==t?(g=i===null&&!E&&s.length===0&&a(O,{description:t("Authentication and security events are recorded here."),testId:"aa-empty",title:t("No security events.")}),e[26]=i,e[27]=s.length,e[28]=E,e[29]=t,e[30]=g):g=e[30];let v;e[31]!==s||e[32]!==t?(v=s.length>0&&a(D,{className:"overflow-hidden py-0",children:a(M,{className:"max-h-[30rem] overflow-auto px-0",children:l(U,{"data-testid":"aa-table",children:[a($,{children:l(F,{children:[a(N,{children:t("time")}),a(N,{children:t("event")}),a(N,{children:t("actor")}),a(N,{children:t("ip / user agent")}),a(N,{children:t("outcome")})]})}),a(G,{children:s.map(r=>l(F,{"data-testid":"aa-row",children:[a(w,{className:"text-muted-foreground tabular-nums",children:W(r.ts,"—")}),a(w,{children:a(j,{variant:"secondary",children:r.event})}),a(w,{className:"max-w-[24ch] truncate font-mono text-xs",title:r.actorId??void 0,children:r.actorEmail??r.actorId??a("span",{className:"text-muted-foreground",children:"—"})}),l(w,{className:"max-w-[28ch] truncate text-xs text-muted-foreground",title:r.userAgent??void 0,children:[r.ip??a("span",{className:"text-muted-foreground",children:"—"}),r.userAgent!==void 0&&l("span",{className:"ml-1 opacity-70",children:["· ",r.userAgent]})]}),a(w,{children:a(j,{variant:r.outcome==="failure"?"destructive":"outline",children:t(r.outcome)})})]},r.seq))})]})})}),e[31]=s,e[32]=t,e[33]=v):v=e[33];let T;return e[34]!==p||e[35]!==g||e[36]!==v||e[37]!==f?(T=l("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]=T):T=e[38],T};export{ne as default};
1
+ import{c as R}from"react/compiler-runtime";import{useState as k}from"react";import{E as q}from"../packem_shared/error-alert-CKqB2CiN.js";import{B as j}from"../packem_shared/badge-cAk9Di1Q.js";import{B as z}from"../packem_shared/button-BOPLD1un.js";import{C as D,a as M}from"../packem_shared/card-BGlQzQY-.js";import{E as O}from"../packem_shared/empty-state-B939z6K2.js";import{I as Q}from"../packem_shared/input-CY5W3wzv.js";import{T as U,a as $,b as F,c as N,d as G,e as w}from"../packem_shared/table-BMsuYFhk.js";import{u as J}from"../packem_shared/use-admin-query-DV9xmFl8.js";import{useT as K}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as V}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as W}from"../packem_shared/internal-7bgd8inO.js";import{jsx as a,jsxs as l}from"react/jsx-runtime";const ne=()=>{const e=R(39),t=K(),[o,H]=k("");let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const{data:L,error:i,errorSource:S,isLoading:E,refetch:B}=J(V.getAuthAuditLog,b);let A;if(e[1]!==L?.entries||e[2]!==o){const r=L?.entries??[],x=o.trim().toLowerCase();A=x===""?r:r.filter(C=>C.event.toLowerCase().includes(x)||(C.actorId??"").toLowerCase().includes(x)||(C.actorEmail??"").toLowerCase().includes(x)||(C.ip??"").toLowerCase().includes(x)||C.outcome.toLowerCase().includes(x)),e[1]=L?.entries,e[2]=o,e[3]=A}else A=e[3];const s=A;let I;e[4]===Symbol.for("react.memo_cache_sentinel")?(I=r=>{H(r.target.value)},e[4]=I):I=e[4];const P=I;let c;e[5]!==t?(c=t("Filter security events"),e[5]=t,e[6]=c):c=e[6];let n;e[7]!==t?(n=t("filter event, actor, IP"),e[7]=t,e[8]=n):n=e[8];let d;e[9]!==o||e[10]!==c||e[11]!==n?(d=a(Q,{"aria-label":c,className:"h-8 w-56","data-testid":"aa-search",onChange:P,placeholder:n,value:o}),e[9]=o,e[10]=c,e[11]=n,e[12]=d):d=e[12];let m;e[13]!==B?(m=()=>{B()},e[13]=B,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=a(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=l("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]!==i||e[24]!==S?(p=i!==null&&a(q,{error:S,testId:"aa-error"}),e[23]=i,e[24]=S,e[25]=p):p=e[25];let g;e[26]!==i||e[27]!==s.length||e[28]!==E||e[29]!==t?(g=i===null&&!E&&s.length===0&&a(O,{description:t("Authentication and security events are recorded here."),testId:"aa-empty",title:t("No security events.")}),e[26]=i,e[27]=s.length,e[28]=E,e[29]=t,e[30]=g):g=e[30];let v;e[31]!==s||e[32]!==t?(v=s.length>0&&a(D,{className:"overflow-hidden py-0",children:a(M,{className:"max-h-[30rem] overflow-auto px-0",children:l(U,{"data-testid":"aa-table",children:[a($,{children:l(F,{children:[a(N,{children:t("time")}),a(N,{children:t("event")}),a(N,{children:t("actor")}),a(N,{children:t("ip / user agent")}),a(N,{children:t("outcome")})]})}),a(G,{children:s.map(r=>l(F,{"data-testid":"aa-row",children:[a(w,{className:"text-muted-foreground tabular-nums",children:W(r.ts,"—")}),a(w,{children:a(j,{variant:"secondary",children:r.event})}),a(w,{className:"max-w-[24ch] truncate font-mono text-xs",title:r.actorId??void 0,children:r.actorEmail??r.actorId??a("span",{className:"text-muted-foreground",children:"—"})}),l(w,{className:"max-w-[28ch] truncate text-xs text-muted-foreground",title:r.userAgent??void 0,children:[r.ip??a("span",{className:"text-muted-foreground",children:"—"}),r.userAgent!==void 0&&l("span",{className:"ml-1 opacity-70",children:["· ",r.userAgent]})]}),a(w,{children:a(j,{variant:r.outcome==="failure"?"destructive":"outline",children:t(r.outcome)})})]},r.seq))})]})})}),e[31]=s,e[32]=t,e[33]=v):v=e[33];let T;return e[34]!==p||e[35]!==g||e[36]!==v||e[37]!==f?(T=l("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]=T):T=e[38],T};export{ne as default};
@@ -1 +1 @@
1
- import{c as N}from"react/compiler-runtime";import{useLunora as C}from"@lunora/react";import{B as x}from"../packem_shared/badge-cAk9Di1Q.js";import{C as w,a as I}from"../packem_shared/card-BGlQzQY-.js";import{b as A}from"../packem_shared/use-admin-query-P0RJrjsD.js";import{useT as $}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{jsx as t,jsxs as d,Fragment as y}from"react/jsx-runtime";const S=[{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,o]of i)if(e>=a&&e%a===0)return`${String(e/a)}${o}`;return`${String(e)}s`},h=e=>{const i=N(8),{children:a,heading:o,testId:r}=e;let l;i[0]!==o?(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:o})}),i[0]=o,i[1]=l):l=i[1];let s;i[2]!==a?(s=t(I,{className:"p-3",children:a}),i[2]=a,i[3]=s):s=i[3];let u;return i[4]!==l||i[5]!==s||i[6]!==r?(u=d(w,{className:"gap-0 py-0","data-testid":r,children:[l,s]}),i[4]=l,i[5]=s,i[6]=r,i[7]=u):u=i[7],u},c=e=>{const i=N(7),{label:a,value:o}=e;let r;i[0]!==a?(r=t("span",{className:"text-sm",children:a}),i[0]=a,i[1]=r):r=i[1];let l;i[2]!==o?(l=t("span",{className:"text-sm text-muted-foreground tabular-nums",children:o}),i[2]=o,i[3]=l):l=i[3];let s;return i[4]!==r||i[5]!==l?(s=d("div",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs",children:[r,l]}),i[4]=r,i[5]=l,i[6]=s):s=i[6],s},O=()=>{const e=N(20),i=C(),a=$();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-auth-config"],e[0]=o):o=e[0];let r;e[1]!==i?(r=()=>i.getAuthConfig(),e[1]=i,e[2]=r):r=e[2];const{data:l,error:s}=A(o,r);let u;e[3]!==a?(u=n=>t(x,{variant:n?"success":"outline",children:a(n?"Enabled":"Disabled")}),e[3]=a,e[4]=u):u=e[4];const m=u;let f;e[5]!==s?(f=s!==null&&t("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"auth-config-error",role:"alert",children:s}),e[5]=s,e[6]=f):f=e[6];let g;e[7]!==l||e[8]!==s||e[9]!==a?(g=s===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]=s,e[9]=a,e[10]=g):g=e[10];let p;e[11]!==l||e[12]!==s||e[13]!==m||e[14]!==a?(p=s===null&&l!==void 0&&d(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:S.map(n=>{const k=l.capabilities[n.key];return d("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-${n.key}`,children:[t("span",{className:"text-sm",children:a(n.label)}),m(k)]},n.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:d("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:d("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:d("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:d("div",{className:"flex flex-col gap-2",children:[t(c,{label:a("Status"),value:m(l.rateLimit.enabled)}),l.rateLimit.enabled&&d(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(n=>d("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-${n.name}`,children:[d("span",{className:"flex flex-col",children:[t("span",{className:"font-mono text-xs",children:n.name}),n.plugin!==void 0&&t("span",{className:"text-[11px] text-muted-foreground",children:n.plugin})]}),d("span",{className:"flex items-center gap-1",children:[t(x,{variant:"outline",children:n.type}),n.required&&t(x,{variant:"secondary",children:a("required")}),n.unique&&t(x,{variant:"secondary",children:a("unique")})]})]},n.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]=s,e[13]=m,e[14]=a,e[15]=p):p=e[15];let b;return e[16]!==f||e[17]!==g||e[18]!==p?(b=d("div",{className:"flex flex-col gap-4","data-testid":"auth-config",children:[f,g,p]}),e[16]=f,e[17]=g,e[18]=p,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{O as default};
1
+ import{c as N}from"react/compiler-runtime";import{useLunora as C}from"@lunora/react";import{B as x}from"../packem_shared/badge-cAk9Di1Q.js";import{C as w,a as I}from"../packem_shared/card-BGlQzQY-.js";import{b as A}from"../packem_shared/use-admin-query-DV9xmFl8.js";import{useT as $}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{jsx as t,jsxs as d,Fragment as y}from"react/jsx-runtime";const S=[{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,o]of i)if(e>=a&&e%a===0)return`${String(e/a)}${o}`;return`${String(e)}s`},h=e=>{const i=N(8),{children:a,heading:o,testId:r}=e;let l;i[0]!==o?(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:o})}),i[0]=o,i[1]=l):l=i[1];let s;i[2]!==a?(s=t(I,{className:"p-3",children:a}),i[2]=a,i[3]=s):s=i[3];let u;return i[4]!==l||i[5]!==s||i[6]!==r?(u=d(w,{className:"gap-0 py-0","data-testid":r,children:[l,s]}),i[4]=l,i[5]=s,i[6]=r,i[7]=u):u=i[7],u},c=e=>{const i=N(7),{label:a,value:o}=e;let r;i[0]!==a?(r=t("span",{className:"text-sm",children:a}),i[0]=a,i[1]=r):r=i[1];let l;i[2]!==o?(l=t("span",{className:"text-sm text-muted-foreground tabular-nums",children:o}),i[2]=o,i[3]=l):l=i[3];let s;return i[4]!==r||i[5]!==l?(s=d("div",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs",children:[r,l]}),i[4]=r,i[5]=l,i[6]=s):s=i[6],s},O=()=>{const e=N(20),i=C(),a=$();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-auth-config"],e[0]=o):o=e[0];let r;e[1]!==i?(r=()=>i.getAuthConfig(),e[1]=i,e[2]=r):r=e[2];const{data:l,error:s}=A(o,r);let u;e[3]!==a?(u=n=>t(x,{variant:n?"success":"outline",children:a(n?"Enabled":"Disabled")}),e[3]=a,e[4]=u):u=e[4];const m=u;let f;e[5]!==s?(f=s!==null&&t("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"auth-config-error",role:"alert",children:s}),e[5]=s,e[6]=f):f=e[6];let g;e[7]!==l||e[8]!==s||e[9]!==a?(g=s===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]=s,e[9]=a,e[10]=g):g=e[10];let p;e[11]!==l||e[12]!==s||e[13]!==m||e[14]!==a?(p=s===null&&l!==void 0&&d(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:S.map(n=>{const k=l.capabilities[n.key];return d("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-${n.key}`,children:[t("span",{className:"text-sm",children:a(n.label)}),m(k)]},n.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:d("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:d("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:d("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:d("div",{className:"flex flex-col gap-2",children:[t(c,{label:a("Status"),value:m(l.rateLimit.enabled)}),l.rateLimit.enabled&&d(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(n=>d("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-${n.name}`,children:[d("span",{className:"flex flex-col",children:[t("span",{className:"font-mono text-xs",children:n.name}),n.plugin!==void 0&&t("span",{className:"text-[11px] text-muted-foreground",children:n.plugin})]}),d("span",{className:"flex items-center gap-1",children:[t(x,{variant:"outline",children:n.type}),n.required&&t(x,{variant:"secondary",children:a("required")}),n.unique&&t(x,{variant:"secondary",children:a("unique")})]})]},n.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]=s,e[13]=m,e[14]=a,e[15]=p):p=e[15];let b;return e[16]!==f||e[17]!==g||e[18]!==p?(b=d("div",{className:"flex flex-col gap-4","data-testid":"auth-config",children:[f,g,p]}),e[16]=f,e[17]=g,e[18]=p,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{O as default};
@@ -1 +1 @@
1
- import{c as A}from"react/compiler-runtime";import{useLunora as g}from"@lunora/react";import{B as S}from"../packem_shared/button-BOPLD1un.js";import{C,a as k}from"../packem_shared/card-BGlQzQY-.js";import{E as w}from"../packem_shared/empty-state-B939z6K2.js";import{T as I,a as B,b as T,c,d as R,e as m}from"../packem_shared/table-BMsuYFhk.js";import{b as E}from"../packem_shared/use-admin-query-P0RJrjsD.js";import{useAutoRefresh as _}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.js";import{useT as $}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{i as j,f as H}from"../packem_shared/internal-CwaF9YNk.js";import{jsx as t,jsxs as y}from"react/jsx-runtime";const v=200,K=()=>{const e=A(21),i=g(),s=$();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]!==i?(u=()=>i.listAuthSessions({limit:v}),e[1]=i,e[2]=u):u=e[2];const l=E(h,u),{error:f}=l,r=l.data?.rows??null;let p;e[3]!==l?(p=()=>{l.refetch()},e[3]=l,e[4]=p):p=e[4],_(p,!0);let x;e[5]!==i||e[6]!==l?(x=a=>{H((async()=>{await i.revokeAuthSession({sessionId:a}),l.refetch()})())},e[5]=i,e[6]=l,e[7]=x):x=e[7];const N=x;let o;e[8]!==f?(o=f!==null&&t("p",{className:"text-sm text-destructive","data-testid":"auth-sessions-error",role:"alert",children:f}),e[8]=f,e[9]=o):o=e[9];let n;e[10]!==r||e[11]!==s?(n=r!==null&&r.length===0&&t(w,{testId:"auth-sessions-empty",title:s("No active sessions.")}),e[10]=r,e[11]=s,e[12]=n):n=e[12];let d;e[13]!==N||e[14]!==r||e[15]!==s?(d=r!==null&&r.length>0&&t(C,{className:"overflow-hidden py-0",children:t(k,{className:"px-0",children:y(I,{"data-testid":"auth-sessions-table",children:[t(B,{children:y(T,{children:[t(c,{children:s("user")}),t(c,{children:s("expires")}),t(c,{children:s("ip")}),t(c,{children:s("user agent")}),t(c,{children:s("impersonated by")}),t(c,{"aria-label":s("Actions")})]})}),t(R,{children:r.map(a=>y(T,{"data-testid":`auth-session-${a.id}`,children:[t(m,{className:"font-mono text-xs",children:a.userId}),t(m,{className:"text-muted-foreground tabular-nums",children:j(a.expiresAt)}),t(m,{children:a.ipAddress??""}),t(m,{className:"max-w-40 truncate",children:a.userAgent??""}),t(m,{className:"font-mono text-xs",children:a.impersonatedBy??""}),t(m,{children:t(S,{"data-testid":`auth-session-revoke-${a.id}`,onClick:()=>{N(a.id)},size:"xs",type:"button",variant:"ghost",children:s("Revoke")})})]},a.id))})]})})}),e[13]=N,e[14]=r,e[15]=s,e[16]=d):d=e[16];let b;return e[17]!==o||e[18]!==n||e[19]!==d?(b=y("div",{className:"flex flex-col gap-4","data-testid":"auth-sessions",children:[o,n,d]}),e[17]=o,e[18]=n,e[19]=d,e[20]=b):b=e[20],b};export{K as default};
1
+ import{c as A}from"react/compiler-runtime";import{useLunora as g}from"@lunora/react";import{B as S}from"../packem_shared/button-BOPLD1un.js";import{C,a as k}from"../packem_shared/card-BGlQzQY-.js";import{E as w}from"../packem_shared/empty-state-B939z6K2.js";import{T as I,a as B,b as T,c,d as R,e as m}from"../packem_shared/table-BMsuYFhk.js";import{b as E}from"../packem_shared/use-admin-query-DV9xmFl8.js";import{useAutoRefresh as _}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.js";import{useT as $}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{i as j,f as H}from"../packem_shared/internal-7bgd8inO.js";import{jsx as t,jsxs as y}from"react/jsx-runtime";const v=200,K=()=>{const e=A(21),i=g(),s=$();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]!==i?(u=()=>i.listAuthSessions({limit:v}),e[1]=i,e[2]=u):u=e[2];const l=E(h,u),{error:f}=l,r=l.data?.rows??null;let p;e[3]!==l?(p=()=>{l.refetch()},e[3]=l,e[4]=p):p=e[4],_(p,!0);let x;e[5]!==i||e[6]!==l?(x=a=>{H((async()=>{await i.revokeAuthSession({sessionId:a}),l.refetch()})())},e[5]=i,e[6]=l,e[7]=x):x=e[7];const N=x;let o;e[8]!==f?(o=f!==null&&t("p",{className:"text-sm text-destructive","data-testid":"auth-sessions-error",role:"alert",children:f}),e[8]=f,e[9]=o):o=e[9];let n;e[10]!==r||e[11]!==s?(n=r!==null&&r.length===0&&t(w,{testId:"auth-sessions-empty",title:s("No active sessions.")}),e[10]=r,e[11]=s,e[12]=n):n=e[12];let d;e[13]!==N||e[14]!==r||e[15]!==s?(d=r!==null&&r.length>0&&t(C,{className:"overflow-hidden py-0",children:t(k,{className:"px-0",children:y(I,{"data-testid":"auth-sessions-table",children:[t(B,{children:y(T,{children:[t(c,{children:s("user")}),t(c,{children:s("expires")}),t(c,{children:s("ip")}),t(c,{children:s("user agent")}),t(c,{children:s("impersonated by")}),t(c,{"aria-label":s("Actions")})]})}),t(R,{children:r.map(a=>y(T,{"data-testid":`auth-session-${a.id}`,children:[t(m,{className:"font-mono text-xs",children:a.userId}),t(m,{className:"text-muted-foreground tabular-nums",children:j(a.expiresAt)}),t(m,{children:a.ipAddress??""}),t(m,{className:"max-w-40 truncate",children:a.userAgent??""}),t(m,{className:"font-mono text-xs",children:a.impersonatedBy??""}),t(m,{children:t(S,{"data-testid":`auth-session-revoke-${a.id}`,onClick:()=>{N(a.id)},size:"xs",type:"button",variant:"ghost",children:s("Revoke")})})]},a.id))})]})})}),e[13]=N,e[14]=r,e[15]=s,e[16]=d):d=e[16];let b;return e[17]!==o||e[18]!==n||e[19]!==d?(b=y("div",{className:"flex flex-col gap-4","data-testid":"auth-sessions",children:[o,n,d]}),e[17]=o,e[18]=n,e[19]=d,e[20]=b):b=e[20],b};export{K as default};
@@ -1 +1 @@
1
- import{c as C}from"react/compiler-runtime";import{L as T}from"../packem_shared/live-status-Bf7rR8o8.js";import{B as b}from"../packem_shared/badge-cAk9Di1Q.js";import{C as E,a as A}from"../packem_shared/card-BGlQzQY-.js";import{E as I}from"../packem_shared/empty-state-B939z6K2.js";import{T as S,a as _,b as y,c as l,d as L,e as d}from"../packem_shared/table-BMsuYFhk.js";import{u as O}from"../packem_shared/use-admin-query-P0RJrjsD.js";import{useT as $}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as k}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{jsxs as h,jsx as n}from"react/jsx-runtime";const g="container:",R={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},B=e=>{const t=e.indexOf(":");if(t===-1)return{event:e.trim()};const a=e.slice(t+1).trim(),s=e.slice(0,t).trim();return a===""?{event:s}:{detail:a,event:s}},D=e=>{const t=new Map;for(const a of e){const s=a.functionPath??"";if(!s.startsWith(g))continue;const i=s.slice(g.length);if(i==="")continue;const r=JSON.stringify([i,a.instance??""]),o=t.get(r);if(o!==void 0&&o.timestamp>=a.timestamp)continue;const{detail:u,event:c}=B(a.message);t.set(r,{detail:u,event:c,exitCode:a.exitCode,instance:a.instance,level:a.level,name:i,state:R[c]??"unknown",timestamp:a.timestamp})}return[...t.values()].toSorted((a,s)=>a.name.localeCompare(s.name)||(a.instance??"").localeCompare(s.instance??""))},M={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},P=e=>{const{entries:t}=e??{};return Array.isArray(t)?t:[]},q=()=>{const e=C(19),t=$();let a,s;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},s={live:!0,shardKey:""},e[0]=a,e[1]=s):(a=e[0],s=e[1]);const{data:i,error:r,liveError:o}=O(k.getLogs,a,s),u=i!==void 0;let c;if(e[2]!==i||e[3]!==r||e[4]!==o||e[5]!==u||e[6]!==t){const N=D(P(i));let x;e[8]!==r?(x=r!==null&&n("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:r}),e[8]=r,e[9]=x):x=e[9];let m;e[10]!==t?(m=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]=m):m=e[11];let f;e[12]!==m?(f=n("p",{className:"text-sm text-muted-foreground",children:m}),e[12]=m,e[13]=f):f=e[13];let p;e[14]!==o?(p=n(T,{message:o,prefix:"containers"}),e[14]=o,e[15]=p):p=e[15];let v;e[16]!==f||e[17]!==p?(v=h("div",{className:"flex flex-wrap items-center gap-2",children:[f,p]}),e[16]=f,e[17]=p,e[18]=v):v=e[18],c=h("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[x,v,u&&N.length===0?n(I,{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(E,{className:"overflow-hidden py-0",children:n(A,{className:"px-0",children:h(S,{"data-testid":"containers-table",children:[n(_,{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(L,{children:N.map(j)})]})})})]}),e[2]=i,e[3]=r,e[4]=o,e[5]=u,e[6]=t,e[7]=c}else c=e[7];return c};function j(e){return h(y,{"data-testid":`containers-row-${e.name}${e.instance===void 0?"":`-${e.instance}`}`,children:[n(d,{className:"font-mono text-xs",children:e.name}),n(d,{className:"max-w-40 truncate font-mono text-xs text-muted-foreground",title:e.instance,children:e.instance??"—"}),n(d,{children:n(b,{variant:M[e.state],children:e.state})}),n(d,{className:"font-mono text-xs text-muted-foreground",children:e.event}),n(d,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"—"}),n(d,{className:"font-mono text-xs tabular-nums text-muted-foreground",children:e.exitCode??"—"}),n(d,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]},`${e.name}/${e.instance??""}`)}export{q as default};
1
+ import{c as C}from"react/compiler-runtime";import{L as T}from"../packem_shared/live-status-Bf7rR8o8.js";import{B as b}from"../packem_shared/badge-cAk9Di1Q.js";import{C as E,a as A}from"../packem_shared/card-BGlQzQY-.js";import{E as I}from"../packem_shared/empty-state-B939z6K2.js";import{T as S,a as _,b as y,c as l,d as L,e as d}from"../packem_shared/table-BMsuYFhk.js";import{u as O}from"../packem_shared/use-admin-query-DV9xmFl8.js";import{useT as $}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as k}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{jsxs as h,jsx as n}from"react/jsx-runtime";const g="container:",R={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},B=e=>{const t=e.indexOf(":");if(t===-1)return{event:e.trim()};const a=e.slice(t+1).trim(),s=e.slice(0,t).trim();return a===""?{event:s}:{detail:a,event:s}},D=e=>{const t=new Map;for(const a of e){const s=a.functionPath??"";if(!s.startsWith(g))continue;const i=s.slice(g.length);if(i==="")continue;const r=JSON.stringify([i,a.instance??""]),o=t.get(r);if(o!==void 0&&o.timestamp>=a.timestamp)continue;const{detail:u,event:c}=B(a.message);t.set(r,{detail:u,event:c,exitCode:a.exitCode,instance:a.instance,level:a.level,name:i,state:R[c]??"unknown",timestamp:a.timestamp})}return[...t.values()].toSorted((a,s)=>a.name.localeCompare(s.name)||(a.instance??"").localeCompare(s.instance??""))},M={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},P=e=>{const{entries:t}=e??{};return Array.isArray(t)?t:[]},q=()=>{const e=C(19),t=$();let a,s;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},s={live:!0,shardKey:""},e[0]=a,e[1]=s):(a=e[0],s=e[1]);const{data:i,error:r,liveError:o}=O(k.getLogs,a,s),u=i!==void 0;let c;if(e[2]!==i||e[3]!==r||e[4]!==o||e[5]!==u||e[6]!==t){const N=D(P(i));let x;e[8]!==r?(x=r!==null&&n("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:r}),e[8]=r,e[9]=x):x=e[9];let m;e[10]!==t?(m=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]=m):m=e[11];let f;e[12]!==m?(f=n("p",{className:"text-sm text-muted-foreground",children:m}),e[12]=m,e[13]=f):f=e[13];let p;e[14]!==o?(p=n(T,{message:o,prefix:"containers"}),e[14]=o,e[15]=p):p=e[15];let v;e[16]!==f||e[17]!==p?(v=h("div",{className:"flex flex-wrap items-center gap-2",children:[f,p]}),e[16]=f,e[17]=p,e[18]=v):v=e[18],c=h("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[x,v,u&&N.length===0?n(I,{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(E,{className:"overflow-hidden py-0",children:n(A,{className:"px-0",children:h(S,{"data-testid":"containers-table",children:[n(_,{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(L,{children:N.map(j)})]})})})]}),e[2]=i,e[3]=r,e[4]=o,e[5]=u,e[6]=t,e[7]=c}else c=e[7];return c};function j(e){return h(y,{"data-testid":`containers-row-${e.name}${e.instance===void 0?"":`-${e.instance}`}`,children:[n(d,{className:"font-mono text-xs",children:e.name}),n(d,{className:"max-w-40 truncate font-mono text-xs text-muted-foreground",title:e.instance,children:e.instance??"—"}),n(d,{children:n(b,{variant:M[e.state],children:e.state})}),n(d,{className:"font-mono text-xs text-muted-foreground",children:e.event}),n(d,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"—"}),n(d,{className:"font-mono text-xs tabular-nums text-muted-foreground",children:e.exitCode??"—"}),n(d,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]},`${e.name}/${e.instance??""}`)}export{q as default};
@@ -1 +1 @@
1
- import{c as I}from"react/compiler-runtime";import{useState as j,useEffect as D}from"react";import{S as Q}from"../packem_shared/result-chart-Ca3YLzt8.js";import{A as P}from"../packem_shared/alert-C2SEhYS9.js";import{B as F}from"../packem_shared/button-BOPLD1un.js";import{b as U,c as V,a as z,C as B}from"../packem_shared/card-BGlQzQY-.js";import{E as H}from"../packem_shared/empty-state-B939z6K2.js";import{useT as W}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{u as Y,n as G}from"../packem_shared/browser-storage-Br_bLeBt.js";import{useLunora as Z}from"@lunora/react";import{ADMIN_FUNCTIONS as J}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{c as X,d as ee,b as te,f as se}from"../packem_shared/internal-CwaF9YNk.js";import{jsx as f,jsxs as $}from"react/jsx-runtime";const ie=X(J.runSql),le=(M,e)=>{const t=I(11),c=Z(),[s,i]=j(void 0),[o,l]=j(void 0),[d,L]=j(!0);let n;t[0]!==c||t[1]!==e||t[2]!==M?(n=async h=>{L(!0);try{const k=await c.query(ie,{sql:M},ee(e));h.cancelled||(i(k),l(void 0))}catch(k){const K=k;h.cancelled||(i(void 0),l(te(K)))}h.cancelled||L(!1)},t[0]=c,t[1]=e,t[2]=M,t[3]=n):n=t[3];const w=n;let y,N;t[4]!==w?(y=()=>{const h={cancelled:!1};return se(w(h)),()=>{h.cancelled=!0}},N=[w],t[4]=w,t[5]=y,t[6]=N):(y=t[5],N=t[6]),D(y,N);let m;return t[7]!==o||t[8]!==d||t[9]!==s?(m={error:o,loading:d,result:s},t[7]=o,t[8]=d,t[9]=s,t[10]=m):m=t[10],m},oe="lunora-studio-dashboards",O={shardKey:"",sql:"",title:""},re=M=>{const e=I(54),{onEdit:t,onRemove:c,widget:s}=M,i=W(),{error:o,loading:l,result:d}=le(s.sql,s.shardKey??"");let L;e[0]!==t||e[1]!==s.id?(L=()=>{t(s.id)},e[0]=t,e[1]=s.id,e[2]=L):L=e[2];const n=L;let w;e[3]!==c||e[4]!==s.id?(w=()=>{c(s.id)},e[3]=c,e[4]=s.id,e[5]=w):w=e[5];const y=w,N=`dashboards-widget-${s.id}`;let m;e[6]!==s.title?(m=f(U,{className:"min-w-0 truncate",title:s.title,children:s.title}),e[6]=s.title,e[7]=m):m=e[7];let h;e[8]!==i?(h=i("Edit widget"),e[8]=i,e[9]=h):h=e[9];const k=`dashboards-widget-edit-${s.id}`;let K;e[10]!==i?(K=i("Edit widget"),e[10]=i,e[11]=K):K=e[11];let E;e[12]===Symbol.for("react.memo_cache_sentinel")?(E=f("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:f("path",{d:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"})}),e[12]=E):E=e[12];let q;e[13]!==n||e[14]!==h||e[15]!==k||e[16]!==K?(q=f(F,{"aria-label":h,"data-testid":k,onClick:n,size:"icon-xs",title:K,type:"button",variant:"ghost",children:E}),e[13]=n,e[14]=h,e[15]=k,e[16]=K,e[17]=q):q=e[17];let x;e[18]!==i?(x=i("Remove widget"),e[18]=i,e[19]=x):x=e[19];const A=`dashboards-widget-remove-${s.id}`;let u;e[20]!==i?(u=i("Remove widget"),e[20]=i,e[21]=u):u=e[21];let C;e[22]===Symbol.for("react.memo_cache_sentinel")?(C=f("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:f("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[22]=C):C=e[22];let g;e[23]!==y||e[24]!==x||e[25]!==A||e[26]!==u?(g=f(F,{"aria-label":x,"data-testid":A,onClick:y,size:"icon-xs",title:u,type:"button",variant:"ghost",children:C}),e[23]=y,e[24]=x,e[25]=A,e[26]=u,e[27]=g):g=e[27];let b;e[28]!==g||e[29]!==q?(b=$("div",{className:"flex shrink-0 items-center gap-1",children:[q,g]}),e[28]=g,e[29]=q,e[30]=b):b=e[30];let p;e[31]!==b||e[32]!==m?(p=$(V,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[m,b]}),e[31]=b,e[32]=m,e[33]=p):p=e[33];let v;e[34]!==o||e[35]!==s.id?(v=o!==void 0&&f(P,{className:"font-mono text-xs",testId:`dashboards-widget-error-${s.id}`,variant:"destructive",children:o}),e[34]=o,e[35]=s.id,e[36]=v):v=e[36];let R;e[37]!==o||e[38]!==l||e[39]!==d||e[40]!==i||e[41]!==s.id?(R=o===void 0&&l&&d===void 0&&f("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${s.id}`,children:i("Running…")}),e[37]=o,e[38]=l,e[39]=d,e[40]=i,e[41]=s.id,e[42]=R):R=e[42];let r;e[43]!==o||e[44]!==d?(r=o===void 0&&d!==void 0&&f(Q,{result:d}),e[43]=o,e[44]=d,e[45]=r):r=e[45];let a;e[46]!==v||e[47]!==R||e[48]!==r?(a=$(z,{className:"min-h-32 py-2",children:[v,R,r]}),e[46]=v,e[47]=R,e[48]=r,e[49]=a):a=e[49];let S;return e[50]!==p||e[51]!==a||e[52]!==N?(S=$(B,{"data-testid":N,children:[p,a]}),e[50]=p,e[51]=a,e[52]=N,e[53]=S):S=e[53],S},de=M=>{const e=I(58),{draft:t,editing:c,onCancel:s,onChange:i,onSubmit:o}=M,l=W();let d;e[0]!==t||e[1]!==i?(d=T=>{i({...t,title:T.target.value})},e[0]=t,e[1]=i,e[2]=d):d=e[2];const L=d;let n;e[3]!==t||e[4]!==i?(n=T=>{i({...t,sql:T.target.value})},e[3]=t,e[4]=i,e[5]=n):n=e[5];const w=n;let y;e[6]!==t||e[7]!==i?(y=T=>{i({...t,shardKey:T.target.value})},e[6]=t,e[7]=i,e[8]=y):y=e[8];const N=y;let m;e[9]!==o?(m=()=>{o()},e[9]=o,e[10]=m):m=e[10];const h=m;let k;e[11]!==t.sql||e[12]!==t.title?(k=t.title.trim()!==""&&t.sql.trim()!=="",e[11]=t.sql,e[12]=t.title,e[13]=k):k=e[13];const K=k;let E;e[14]!==l?(E=l("Widget title"),e[14]=l,e[15]=E):E=e[15];let q;e[16]!==l?(q=l("Widget title"),e[16]=l,e[17]=q):q=e[17];let x;e[18]!==t.title||e[19]!==L||e[20]!==E||e[21]!==q?(x=f("input",{"aria-label":E,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:L,placeholder:q,type:"text",value:t.title}),e[18]=t.title,e[19]=L,e[20]=E,e[21]=q,e[22]=x):x=e[22];let A;e[23]!==l?(A=l("SQL query"),e[23]=l,e[24]=A):A=e[24];let u;e[25]!==t.sql||e[26]!==w||e[27]!==A?(u=f("textarea",{"aria-label":A,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:w,placeholder:"SELECT author, COUNT(*) AS messages FROM …",spellCheck:!1,value:t.sql}),e[25]=t.sql,e[26]=w,e[27]=A,e[28]=u):u=e[28];let C;e[29]!==l?(C=l("Shard key (optional)"),e[29]=l,e[30]=C):C=e[30];let g;e[31]!==l?(g=l("Shard key (optional)"),e[31]=l,e[32]=g):g=e[32];let b;e[33]!==t.shardKey||e[34]!==N||e[35]!==C||e[36]!==g?(b=f("input",{"aria-label":C,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:N,placeholder:g,type:"text",value:t.shardKey}),e[33]=t.shardKey,e[34]=N,e[35]=C,e[36]=g,e[37]=b):b=e[37];let p;e[38]!==l?(p=l("Cancel"),e[38]=l,e[39]=p):p=e[39];let v;e[40]!==s||e[41]!==p?(v=f(F,{"data-testid":"dashboards-form-cancel",onClick:s,size:"sm",type:"button",variant:"outline",children:p}),e[40]=s,e[41]=p,e[42]=v):v=e[42];const R=!K;let r;e[43]!==c||e[44]!==l?(r=l(c?"Save widget":"Add widget"),e[43]=c,e[44]=l,e[45]=r):r=e[45];let a;e[46]!==h||e[47]!==R||e[48]!==r?(a=f(F,{"data-testid":"dashboards-form-save",disabled:R,onClick:h,size:"sm",type:"button",children:r}),e[46]=h,e[47]=R,e[48]=r,e[49]=a):a=e[49];let S;e[50]!==v||e[51]!==a?(S=$("div",{className:"flex items-center justify-end gap-2",children:[v,a]}),e[50]=v,e[51]=a,e[52]=S):S=e[52];let _;return e[53]!==u||e[54]!==b||e[55]!==S||e[56]!==x?(_=f(B,{"data-testid":"dashboards-form",children:$(z,{className:"flex flex-col gap-3 py-4",children:[x,u,b,S]})}),e[53]=u,e[54]=b,e[55]=S,e[56]=x,e[57]=_):_=e[57],_},Ce=M=>{const e=I(39),{initialShardKey:t}=M,c=W(),[s,i]=Y(oe),[o,l]=j(O),[d,L]=j(null),[n,w]=j(!1);let y;e[0]!==t?(y=()=>{L(null),l({...O,shardKey:t??""}),w(!0)},e[0]=t,e[1]=y):y=e[1];const N=y;let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{w(!1),L(null),l(O)},e[2]=m):m=e[2];const h=m;let k;e[3]!==s?(k=r=>{const a=s.find(S=>S.id===r);a!==void 0&&(L(r),l({shardKey:a.shardKey??"",sql:a.sql,title:a.title}),w(!0))},e[3]=s,e[4]=k):k=e[4];const K=k;let E;e[5]!==i?(E=r=>{i(a=>a.filter(S=>S.id!==r))},e[5]=i,e[6]=E):E=e[6];const q=E;let x;e[7]!==o.shardKey||e[8]!==o.sql||e[9]!==o.title||e[10]!==d||e[11]!==i?(x=()=>{const r=o.title.trim(),a=o.sql.trim();if(r===""||a==="")return;const S=o.shardKey.trim();i(d===null?_=>[..._,{id:G("w"),shardKey:S,sql:a,title:r}]:_=>_.map(T=>T.id===d?{...T,shardKey:S,sql:a,title:r}:T)),h()},e[7]=o.shardKey,e[8]=o.sql,e[9]=o.title,e[10]=d,e[11]=i,e[12]=x):x=e[12];const A=x;let u;e[13]!==c?(u=c("Chart widgets backed by saved read-only SQL queries."),e[13]=c,e[14]=u):u=e[14];let C;e[15]!==u?(C=f("p",{className:"text-sm text-muted-foreground",children:u}),e[15]=u,e[16]=C):C=e[16];let g;e[17]!==n||e[18]!==N||e[19]!==c?(g=!n&&f(F,{"data-testid":"dashboards-add",onClick:N,size:"sm",type:"button",children:c("Add widget")}),e[17]=n,e[18]=N,e[19]=c,e[20]=g):g=e[20];let b;e[21]!==C||e[22]!==g?(b=$("div",{className:"flex items-center justify-between",children:[C,g]}),e[21]=C,e[22]=g,e[23]=b):b=e[23];let p;e[24]!==o||e[25]!==d||e[26]!==n||e[27]!==A?(p=n&&f(de,{draft:o,editing:d!==null,onCancel:h,onChange:l,onSubmit:A}),e[24]=o,e[25]=d,e[26]=n,e[27]=A,e[28]=p):p=e[28];let v;e[29]!==n||e[30]!==K||e[31]!==q||e[32]!==c||e[33]!==s?(v=s.length===0&&!n?f(H,{description:c("Add a widget to chart a saved SQL query on this browser."),testId:"dashboards-empty",title:c("No widgets yet")}):f("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:s.map(r=>f(re,{onEdit:K,onRemove:q,widget:r},r.id))}),e[29]=n,e[30]=K,e[31]=q,e[32]=c,e[33]=s,e[34]=v):v=e[34];let R;return e[35]!==p||e[36]!==v||e[37]!==b?(R=$("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]=R):R=e[38],R};export{Ce as default};
1
+ import{c as I}from"react/compiler-runtime";import{useState as j,useEffect as D}from"react";import{S as Q}from"../packem_shared/result-chart-Q-gVLi4_.js";import{A as P}from"../packem_shared/alert-C2SEhYS9.js";import{B as F}from"../packem_shared/button-BOPLD1un.js";import{b as U,c as V,a as z,C as B}from"../packem_shared/card-BGlQzQY-.js";import{E as H}from"../packem_shared/empty-state-B939z6K2.js";import{useT as W}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{u as Y,n as G}from"../packem_shared/browser-storage-Br_bLeBt.js";import{useLunora as Z}from"@lunora/react";import{ADMIN_FUNCTIONS as J}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{c as X,d as ee,b as te,f as se}from"../packem_shared/internal-7bgd8inO.js";import{jsx as f,jsxs as $}from"react/jsx-runtime";const ie=X(J.runSql),le=(M,e)=>{const t=I(11),c=Z(),[s,i]=j(void 0),[o,l]=j(void 0),[d,L]=j(!0);let n;t[0]!==c||t[1]!==e||t[2]!==M?(n=async h=>{L(!0);try{const k=await c.query(ie,{sql:M},ee(e));h.cancelled||(i(k),l(void 0))}catch(k){const K=k;h.cancelled||(i(void 0),l(te(K)))}h.cancelled||L(!1)},t[0]=c,t[1]=e,t[2]=M,t[3]=n):n=t[3];const w=n;let y,N;t[4]!==w?(y=()=>{const h={cancelled:!1};return se(w(h)),()=>{h.cancelled=!0}},N=[w],t[4]=w,t[5]=y,t[6]=N):(y=t[5],N=t[6]),D(y,N);let m;return t[7]!==o||t[8]!==d||t[9]!==s?(m={error:o,loading:d,result:s},t[7]=o,t[8]=d,t[9]=s,t[10]=m):m=t[10],m},oe="lunora-studio-dashboards",O={shardKey:"",sql:"",title:""},re=M=>{const e=I(54),{onEdit:t,onRemove:c,widget:s}=M,i=W(),{error:o,loading:l,result:d}=le(s.sql,s.shardKey??"");let L;e[0]!==t||e[1]!==s.id?(L=()=>{t(s.id)},e[0]=t,e[1]=s.id,e[2]=L):L=e[2];const n=L;let w;e[3]!==c||e[4]!==s.id?(w=()=>{c(s.id)},e[3]=c,e[4]=s.id,e[5]=w):w=e[5];const y=w,N=`dashboards-widget-${s.id}`;let m;e[6]!==s.title?(m=f(U,{className:"min-w-0 truncate",title:s.title,children:s.title}),e[6]=s.title,e[7]=m):m=e[7];let h;e[8]!==i?(h=i("Edit widget"),e[8]=i,e[9]=h):h=e[9];const k=`dashboards-widget-edit-${s.id}`;let K;e[10]!==i?(K=i("Edit widget"),e[10]=i,e[11]=K):K=e[11];let E;e[12]===Symbol.for("react.memo_cache_sentinel")?(E=f("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:f("path",{d:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"})}),e[12]=E):E=e[12];let q;e[13]!==n||e[14]!==h||e[15]!==k||e[16]!==K?(q=f(F,{"aria-label":h,"data-testid":k,onClick:n,size:"icon-xs",title:K,type:"button",variant:"ghost",children:E}),e[13]=n,e[14]=h,e[15]=k,e[16]=K,e[17]=q):q=e[17];let x;e[18]!==i?(x=i("Remove widget"),e[18]=i,e[19]=x):x=e[19];const A=`dashboards-widget-remove-${s.id}`;let u;e[20]!==i?(u=i("Remove widget"),e[20]=i,e[21]=u):u=e[21];let C;e[22]===Symbol.for("react.memo_cache_sentinel")?(C=f("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:f("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[22]=C):C=e[22];let g;e[23]!==y||e[24]!==x||e[25]!==A||e[26]!==u?(g=f(F,{"aria-label":x,"data-testid":A,onClick:y,size:"icon-xs",title:u,type:"button",variant:"ghost",children:C}),e[23]=y,e[24]=x,e[25]=A,e[26]=u,e[27]=g):g=e[27];let b;e[28]!==g||e[29]!==q?(b=$("div",{className:"flex shrink-0 items-center gap-1",children:[q,g]}),e[28]=g,e[29]=q,e[30]=b):b=e[30];let p;e[31]!==b||e[32]!==m?(p=$(V,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[m,b]}),e[31]=b,e[32]=m,e[33]=p):p=e[33];let v;e[34]!==o||e[35]!==s.id?(v=o!==void 0&&f(P,{className:"font-mono text-xs",testId:`dashboards-widget-error-${s.id}`,variant:"destructive",children:o}),e[34]=o,e[35]=s.id,e[36]=v):v=e[36];let R;e[37]!==o||e[38]!==l||e[39]!==d||e[40]!==i||e[41]!==s.id?(R=o===void 0&&l&&d===void 0&&f("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${s.id}`,children:i("Running…")}),e[37]=o,e[38]=l,e[39]=d,e[40]=i,e[41]=s.id,e[42]=R):R=e[42];let r;e[43]!==o||e[44]!==d?(r=o===void 0&&d!==void 0&&f(Q,{result:d}),e[43]=o,e[44]=d,e[45]=r):r=e[45];let a;e[46]!==v||e[47]!==R||e[48]!==r?(a=$(z,{className:"min-h-32 py-2",children:[v,R,r]}),e[46]=v,e[47]=R,e[48]=r,e[49]=a):a=e[49];let S;return e[50]!==p||e[51]!==a||e[52]!==N?(S=$(B,{"data-testid":N,children:[p,a]}),e[50]=p,e[51]=a,e[52]=N,e[53]=S):S=e[53],S},de=M=>{const e=I(58),{draft:t,editing:c,onCancel:s,onChange:i,onSubmit:o}=M,l=W();let d;e[0]!==t||e[1]!==i?(d=T=>{i({...t,title:T.target.value})},e[0]=t,e[1]=i,e[2]=d):d=e[2];const L=d;let n;e[3]!==t||e[4]!==i?(n=T=>{i({...t,sql:T.target.value})},e[3]=t,e[4]=i,e[5]=n):n=e[5];const w=n;let y;e[6]!==t||e[7]!==i?(y=T=>{i({...t,shardKey:T.target.value})},e[6]=t,e[7]=i,e[8]=y):y=e[8];const N=y;let m;e[9]!==o?(m=()=>{o()},e[9]=o,e[10]=m):m=e[10];const h=m;let k;e[11]!==t.sql||e[12]!==t.title?(k=t.title.trim()!==""&&t.sql.trim()!=="",e[11]=t.sql,e[12]=t.title,e[13]=k):k=e[13];const K=k;let E;e[14]!==l?(E=l("Widget title"),e[14]=l,e[15]=E):E=e[15];let q;e[16]!==l?(q=l("Widget title"),e[16]=l,e[17]=q):q=e[17];let x;e[18]!==t.title||e[19]!==L||e[20]!==E||e[21]!==q?(x=f("input",{"aria-label":E,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:L,placeholder:q,type:"text",value:t.title}),e[18]=t.title,e[19]=L,e[20]=E,e[21]=q,e[22]=x):x=e[22];let A;e[23]!==l?(A=l("SQL query"),e[23]=l,e[24]=A):A=e[24];let u;e[25]!==t.sql||e[26]!==w||e[27]!==A?(u=f("textarea",{"aria-label":A,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:w,placeholder:"SELECT author, COUNT(*) AS messages FROM …",spellCheck:!1,value:t.sql}),e[25]=t.sql,e[26]=w,e[27]=A,e[28]=u):u=e[28];let C;e[29]!==l?(C=l("Shard key (optional)"),e[29]=l,e[30]=C):C=e[30];let g;e[31]!==l?(g=l("Shard key (optional)"),e[31]=l,e[32]=g):g=e[32];let b;e[33]!==t.shardKey||e[34]!==N||e[35]!==C||e[36]!==g?(b=f("input",{"aria-label":C,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:N,placeholder:g,type:"text",value:t.shardKey}),e[33]=t.shardKey,e[34]=N,e[35]=C,e[36]=g,e[37]=b):b=e[37];let p;e[38]!==l?(p=l("Cancel"),e[38]=l,e[39]=p):p=e[39];let v;e[40]!==s||e[41]!==p?(v=f(F,{"data-testid":"dashboards-form-cancel",onClick:s,size:"sm",type:"button",variant:"outline",children:p}),e[40]=s,e[41]=p,e[42]=v):v=e[42];const R=!K;let r;e[43]!==c||e[44]!==l?(r=l(c?"Save widget":"Add widget"),e[43]=c,e[44]=l,e[45]=r):r=e[45];let a;e[46]!==h||e[47]!==R||e[48]!==r?(a=f(F,{"data-testid":"dashboards-form-save",disabled:R,onClick:h,size:"sm",type:"button",children:r}),e[46]=h,e[47]=R,e[48]=r,e[49]=a):a=e[49];let S;e[50]!==v||e[51]!==a?(S=$("div",{className:"flex items-center justify-end gap-2",children:[v,a]}),e[50]=v,e[51]=a,e[52]=S):S=e[52];let _;return e[53]!==u||e[54]!==b||e[55]!==S||e[56]!==x?(_=f(B,{"data-testid":"dashboards-form",children:$(z,{className:"flex flex-col gap-3 py-4",children:[x,u,b,S]})}),e[53]=u,e[54]=b,e[55]=S,e[56]=x,e[57]=_):_=e[57],_},Ce=M=>{const e=I(39),{initialShardKey:t}=M,c=W(),[s,i]=Y(oe),[o,l]=j(O),[d,L]=j(null),[n,w]=j(!1);let y;e[0]!==t?(y=()=>{L(null),l({...O,shardKey:t??""}),w(!0)},e[0]=t,e[1]=y):y=e[1];const N=y;let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{w(!1),L(null),l(O)},e[2]=m):m=e[2];const h=m;let k;e[3]!==s?(k=r=>{const a=s.find(S=>S.id===r);a!==void 0&&(L(r),l({shardKey:a.shardKey??"",sql:a.sql,title:a.title}),w(!0))},e[3]=s,e[4]=k):k=e[4];const K=k;let E;e[5]!==i?(E=r=>{i(a=>a.filter(S=>S.id!==r))},e[5]=i,e[6]=E):E=e[6];const q=E;let x;e[7]!==o.shardKey||e[8]!==o.sql||e[9]!==o.title||e[10]!==d||e[11]!==i?(x=()=>{const r=o.title.trim(),a=o.sql.trim();if(r===""||a==="")return;const S=o.shardKey.trim();i(d===null?_=>[..._,{id:G("w"),shardKey:S,sql:a,title:r}]:_=>_.map(T=>T.id===d?{...T,shardKey:S,sql:a,title:r}:T)),h()},e[7]=o.shardKey,e[8]=o.sql,e[9]=o.title,e[10]=d,e[11]=i,e[12]=x):x=e[12];const A=x;let u;e[13]!==c?(u=c("Chart widgets backed by saved read-only SQL queries."),e[13]=c,e[14]=u):u=e[14];let C;e[15]!==u?(C=f("p",{className:"text-sm text-muted-foreground",children:u}),e[15]=u,e[16]=C):C=e[16];let g;e[17]!==n||e[18]!==N||e[19]!==c?(g=!n&&f(F,{"data-testid":"dashboards-add",onClick:N,size:"sm",type:"button",children:c("Add widget")}),e[17]=n,e[18]=N,e[19]=c,e[20]=g):g=e[20];let b;e[21]!==C||e[22]!==g?(b=$("div",{className:"flex items-center justify-between",children:[C,g]}),e[21]=C,e[22]=g,e[23]=b):b=e[23];let p;e[24]!==o||e[25]!==d||e[26]!==n||e[27]!==A?(p=n&&f(de,{draft:o,editing:d!==null,onCancel:h,onChange:l,onSubmit:A}),e[24]=o,e[25]=d,e[26]=n,e[27]=A,e[28]=p):p=e[28];let v;e[29]!==n||e[30]!==K||e[31]!==q||e[32]!==c||e[33]!==s?(v=s.length===0&&!n?f(H,{description:c("Add a widget to chart a saved SQL query on this browser."),testId:"dashboards-empty",title:c("No widgets yet")}):f("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:s.map(r=>f(re,{onEdit:K,onRemove:q,widget:r},r.id))}),e[29]=n,e[30]=K,e[31]=q,e[32]=c,e[33]=s,e[34]=v):v=e[34];let R;return e[35]!==p||e[36]!==v||e[37]!==b?(R=$("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]=R):R=e[38],R};export{Ce as default};
@@ -1 +1 @@
1
- import{c as I}from"react/compiler-runtime";import{E as K}from"../packem_shared/error-alert-TYdKetJd.js";import{ShardInput as O}from"../packem_shared/ShardInput-XumEzeT0.js";import{B as w}from"../packem_shared/badge-cAk9Di1Q.js";import{C as M,a as $}from"../packem_shared/card-BGlQzQY-.js";import{E as j}from"../packem_shared/empty-state-B939z6K2.js";import{u as T}from"../packem_shared/use-admin-query-P0RJrjsD.js";import{u as A}from"../packem_shared/use-open-trace-4tIa0SXZ.js";import{u as k}from"../packem_shared/use-shard-key-BsP3o5wT.js";import{useT as C}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as E}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as R}from"../packem_shared/internal-CwaF9YNk.js";import{S as B}from"../packem_shared/sparkline-BreIqzDO.js";import{jsxs as g,jsx as c}from"react/jsx-runtime";const F=n=>n.length===0?void 0:{max:Math.max(...n),mean:n.reduce((e,t)=>e+t,0)/n.length,min:Math.min(...n)},_=/^gen_ai\.evaluation\.(.+)\.score$/u,q=n=>{const e=[];for(const t of n)for(const r of t.spans)for(const[a,l]of Object.entries(r.attributes??{})){const o=_.exec(a);if(!o||typeof l!="number")continue;const i=o[1],m=r.attributes?.[`gen_ai.evaluation.${i}.label`];e.push({...typeof m=="string"?{label:m}:{},name:i,score:l,spanName:r.name,startTs:t.startTs+r.offsetMs,traceId:t.traceId})}return e.toSorted((t,r)=>r.startTs-t.startTs)},D=n=>{const e=[];for(const t of n?.series??[]){const r=_.exec(t.name);r&&e.push({name:r[1],points:t.points})}return e},H=(n,e)=>{const t=new Set([...n.map(a=>a.name),...e.map(a=>a.name)]),r=[];for(const a of t){const l=n.filter(s=>s.name===a),o=e.find(s=>s.name===a)?.points??[],i=o.at(-1)?.last??l[0]?.score,m=o.length>0?{max:Math.max(...o.map(s=>s.max)),mean:o.reduce((s,d)=>s+d.sum,0)/o.reduce((s,d)=>s+d.count,0),min:Math.min(...o.map(s=>s.min))}:F(l.map(s=>s.score));r.push({...i===void 0?{}:{latest:i},...m,name:a,points:o,runs:l})}return r.toSorted((a,l)=>a.name.localeCompare(l.name))},L=n=>Array.isArray(n?.traces)?n.traces:[],y=n=>n===void 0?"—":n.toFixed(2),P=n=>{const e=I(34),{card:t,onOpenTrace:r}=n,a=C();let l;e[0]!==t.name?(l=c("h3",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"ev-name",children:t.name}),e[0]=t.name,e[1]=l):l=e[1];let o;e[2]!==t.latest?(o=y(t.latest),e[2]=t.latest,e[3]=o):o=e[3];let i;e[4]!==o?(i=c("span",{className:"font-mono text-lg text-foreground","data-testid":"ev-latest",children:o}),e[4]=o,e[5]=i):i=e[5];let m;e[6]!==l||e[7]!==i?(m=g("div",{className:"flex items-baseline justify-between gap-3",children:[l,i]}),e[6]=l,e[7]=i,e[8]=m):m=e[8];let s;e[9]!==t.max||e[10]!==t.mean||e[11]!==t.min||e[12]!==a?(s=a("min {min} · mean {mean} · max {max}",{max:y(t.max),mean:y(t.mean),min:y(t.min)}),e[9]=t.max,e[10]=t.mean,e[11]=t.min,e[12]=a,e[13]=s):s=e[13];let d;e[14]!==s?(d=c("p",{className:"font-mono text-xs text-muted-foreground","data-testid":"ev-summary",children:s}),e[14]=s,e[15]=d):d=e[15];let f;e[16]!==t.name||e[17]!==t.points||e[18]!==a?(f=t.points.length>1?c(B,{ariaLabel:a("Score trend for {name}",{name:t.name}),className:"h-10 w-full",series:t.points.map(Q),testId:"ev-trend"}):c("p",{className:"text-xs text-muted-foreground","data-testid":"ev-no-trend",children:a("No durable history yet — pass ctx.metrics to recordEvaluation to chart a trend.")}),e[16]=t.name,e[17]=t.points,e[18]=a,e[19]=f):f=e[19];let u;if(e[20]!==t.runs||e[21]!==r||e[22]!==a){let x;e[24]!==r||e[25]!==a?(x=p=>g("div",{className:"flex items-center justify-between gap-2 font-mono text-xs","data-testid":"ev-run",children:[g("span",{className:"truncate text-muted-foreground",children:[R(p.startTs)," · ",p.spanName]}),g("span",{className:"flex items-center gap-2",children:[p.label===void 0?null:c(w,{variant:"outline",children:p.label}),c("span",{className:"text-foreground",children:y(p.score)}),r===void 0?null:c("button",{className:"text-muted-foreground underline-offset-2 hover:underline",onClick:()=>{r(p.traceId)},title:a("Open the trace {trace}",{trace:p.traceId}),type:"button",children:p.traceId.slice(0,8)})]})]},`${p.traceId}:${p.spanName}`),e[24]=r,e[25]=a,e[26]=x):x=e[26],u=t.runs.slice(0,5).map(x),e[20]=t.runs,e[21]=r,e[22]=a,e[23]=u}else u=e[23];let h;e[27]!==u?(h=c("div",{className:"flex flex-col gap-1",children:u}),e[27]=u,e[28]=h):h=e[28];let v;return e[29]!==m||e[30]!==d||e[31]!==f||e[32]!==h?(v=c(M,{"data-testid":"ev-card",children:g($,{className:"flex flex-col gap-3 p-4",children:[m,d,f,h]})}),e[29]=m,e[30]=d,e[31]=f,e[32]=h,e[33]=v):v=e[33],v},re=n=>{const e=I(19),{initialShardKey:t}=n,r=C(),{queryShardKey:a,setShardKey:l,shardKey:o}=k(t),i=A(a);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={},e[0]=m):m=e[0];let s;e[1]!==a?(s={live:!0,shardKey:a},e[1]=a,e[2]=s):s=e[2];const{data:d,error:f}=T(E.getTraces,m,s);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u={},e[3]=u):u=e[3];let h;e[4]!==a?(h={live:!0,shardKey:a},e[4]=a,e[5]=h):h=e[5];const{data:v}=T(E.getMetricHistory,u,h);let x;if(e[6]!==d||e[7]!==f||e[8]!==v||e[9]!==i||e[10]!==l||e[11]!==o||e[12]!==r){const p=H(q(L(d)),D(v));let N;e[14]!==l||e[15]!==o?(N=c(O,{onChange:l,testId:"ev-shard-input",value:o}),e[14]=l,e[15]=o,e[16]=N):N=e[16];let b;e[17]!==f?(b=f===null?null:c(K,{error:f,testId:"ev-error"}),e[17]=f,e[18]=b):b=e[18],x=g("section",{className:"flex flex-col gap-4","data-testid":"ev-panel",children:[N,b,p.length===0?c(j,{description:r("Call recordEvaluation from a graded run and its score shows up here."),testId:"ev-empty",title:r("No evals recorded")}):c("div",{className:"grid gap-3 md:grid-cols-2",children:p.map(S=>c(P,{card:S,onOpenTrace:i},S.name))})]}),e[6]=d,e[7]=f,e[8]=v,e[9]=i,e[10]=l,e[11]=o,e[12]=r,e[13]=x}else x=e[13];return x};function Q(n){return n.last}export{re as default};
1
+ import{c as I}from"react/compiler-runtime";import{E as K}from"../packem_shared/error-alert-CKqB2CiN.js";import{ShardInput as O}from"../packem_shared/ShardInput-XumEzeT0.js";import{B as w}from"../packem_shared/badge-cAk9Di1Q.js";import{C as M,a as $}from"../packem_shared/card-BGlQzQY-.js";import{E as j}from"../packem_shared/empty-state-B939z6K2.js";import{u as T}from"../packem_shared/use-admin-query-DV9xmFl8.js";import{u as A}from"../packem_shared/use-open-trace-IfIlKEWd.js";import{u as k}from"../packem_shared/use-shard-key-BsP3o5wT.js";import{useT as C}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as E}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as R}from"../packem_shared/internal-7bgd8inO.js";import{S as B}from"../packem_shared/sparkline-BreIqzDO.js";import{jsxs as g,jsx as c}from"react/jsx-runtime";const F=n=>n.length===0?void 0:{max:Math.max(...n),mean:n.reduce((e,t)=>e+t,0)/n.length,min:Math.min(...n)},_=/^gen_ai\.evaluation\.(.+)\.score$/u,q=n=>{const e=[];for(const t of n)for(const r of t.spans)for(const[a,l]of Object.entries(r.attributes??{})){const o=_.exec(a);if(!o||typeof l!="number")continue;const i=o[1],m=r.attributes?.[`gen_ai.evaluation.${i}.label`];e.push({...typeof m=="string"?{label:m}:{},name:i,score:l,spanName:r.name,startTs:t.startTs+r.offsetMs,traceId:t.traceId})}return e.toSorted((t,r)=>r.startTs-t.startTs)},D=n=>{const e=[];for(const t of n?.series??[]){const r=_.exec(t.name);r&&e.push({name:r[1],points:t.points})}return e},H=(n,e)=>{const t=new Set([...n.map(a=>a.name),...e.map(a=>a.name)]),r=[];for(const a of t){const l=n.filter(s=>s.name===a),o=e.find(s=>s.name===a)?.points??[],i=o.at(-1)?.last??l[0]?.score,m=o.length>0?{max:Math.max(...o.map(s=>s.max)),mean:o.reduce((s,d)=>s+d.sum,0)/o.reduce((s,d)=>s+d.count,0),min:Math.min(...o.map(s=>s.min))}:F(l.map(s=>s.score));r.push({...i===void 0?{}:{latest:i},...m,name:a,points:o,runs:l})}return r.toSorted((a,l)=>a.name.localeCompare(l.name))},L=n=>Array.isArray(n?.traces)?n.traces:[],y=n=>n===void 0?"—":n.toFixed(2),P=n=>{const e=I(34),{card:t,onOpenTrace:r}=n,a=C();let l;e[0]!==t.name?(l=c("h3",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"ev-name",children:t.name}),e[0]=t.name,e[1]=l):l=e[1];let o;e[2]!==t.latest?(o=y(t.latest),e[2]=t.latest,e[3]=o):o=e[3];let i;e[4]!==o?(i=c("span",{className:"font-mono text-lg text-foreground","data-testid":"ev-latest",children:o}),e[4]=o,e[5]=i):i=e[5];let m;e[6]!==l||e[7]!==i?(m=g("div",{className:"flex items-baseline justify-between gap-3",children:[l,i]}),e[6]=l,e[7]=i,e[8]=m):m=e[8];let s;e[9]!==t.max||e[10]!==t.mean||e[11]!==t.min||e[12]!==a?(s=a("min {min} · mean {mean} · max {max}",{max:y(t.max),mean:y(t.mean),min:y(t.min)}),e[9]=t.max,e[10]=t.mean,e[11]=t.min,e[12]=a,e[13]=s):s=e[13];let d;e[14]!==s?(d=c("p",{className:"font-mono text-xs text-muted-foreground","data-testid":"ev-summary",children:s}),e[14]=s,e[15]=d):d=e[15];let f;e[16]!==t.name||e[17]!==t.points||e[18]!==a?(f=t.points.length>1?c(B,{ariaLabel:a("Score trend for {name}",{name:t.name}),className:"h-10 w-full",series:t.points.map(Q),testId:"ev-trend"}):c("p",{className:"text-xs text-muted-foreground","data-testid":"ev-no-trend",children:a("No durable history yet — pass ctx.metrics to recordEvaluation to chart a trend.")}),e[16]=t.name,e[17]=t.points,e[18]=a,e[19]=f):f=e[19];let u;if(e[20]!==t.runs||e[21]!==r||e[22]!==a){let x;e[24]!==r||e[25]!==a?(x=p=>g("div",{className:"flex items-center justify-between gap-2 font-mono text-xs","data-testid":"ev-run",children:[g("span",{className:"truncate text-muted-foreground",children:[R(p.startTs)," · ",p.spanName]}),g("span",{className:"flex items-center gap-2",children:[p.label===void 0?null:c(w,{variant:"outline",children:p.label}),c("span",{className:"text-foreground",children:y(p.score)}),r===void 0?null:c("button",{className:"text-muted-foreground underline-offset-2 hover:underline",onClick:()=>{r(p.traceId)},title:a("Open the trace {trace}",{trace:p.traceId}),type:"button",children:p.traceId.slice(0,8)})]})]},`${p.traceId}:${p.spanName}`),e[24]=r,e[25]=a,e[26]=x):x=e[26],u=t.runs.slice(0,5).map(x),e[20]=t.runs,e[21]=r,e[22]=a,e[23]=u}else u=e[23];let h;e[27]!==u?(h=c("div",{className:"flex flex-col gap-1",children:u}),e[27]=u,e[28]=h):h=e[28];let v;return e[29]!==m||e[30]!==d||e[31]!==f||e[32]!==h?(v=c(M,{"data-testid":"ev-card",children:g($,{className:"flex flex-col gap-3 p-4",children:[m,d,f,h]})}),e[29]=m,e[30]=d,e[31]=f,e[32]=h,e[33]=v):v=e[33],v},re=n=>{const e=I(19),{initialShardKey:t}=n,r=C(),{queryShardKey:a,setShardKey:l,shardKey:o}=k(t),i=A(a);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={},e[0]=m):m=e[0];let s;e[1]!==a?(s={live:!0,shardKey:a},e[1]=a,e[2]=s):s=e[2];const{data:d,error:f}=T(E.getTraces,m,s);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u={},e[3]=u):u=e[3];let h;e[4]!==a?(h={live:!0,shardKey:a},e[4]=a,e[5]=h):h=e[5];const{data:v}=T(E.getMetricHistory,u,h);let x;if(e[6]!==d||e[7]!==f||e[8]!==v||e[9]!==i||e[10]!==l||e[11]!==o||e[12]!==r){const p=H(q(L(d)),D(v));let N;e[14]!==l||e[15]!==o?(N=c(O,{onChange:l,testId:"ev-shard-input",value:o}),e[14]=l,e[15]=o,e[16]=N):N=e[16];let b;e[17]!==f?(b=f===null?null:c(K,{error:f,testId:"ev-error"}),e[17]=f,e[18]=b):b=e[18],x=g("section",{className:"flex flex-col gap-4","data-testid":"ev-panel",children:[N,b,p.length===0?c(j,{description:r("Call recordEvaluation from a graded run and its score shows up here."),testId:"ev-empty",title:r("No evals recorded")}):c("div",{className:"grid gap-3 md:grid-cols-2",children:p.map(S=>c(P,{card:S,onOpenTrace:i},S.name))})]}),e[6]=d,e[7]=f,e[8]=v,e[9]=i,e[10]=l,e[11]=o,e[12]=r,e[13]=x}else x=e[13];return x};function Q(n){return n.last}export{re as default};
@@ -1 +1 @@
1
- import{c as F}from"react/compiler-runtime";import{E as B}from"../packem_shared/error-alert-TYdKetJd.js";import{ShardInput as E}from"../packem_shared/ShardInput-XumEzeT0.js";import{S as $}from"../packem_shared/stat-card-B9uIvAHg.js";import{B as R}from"../packem_shared/badge-cAk9Di1Q.js";import{C as _}from"../packem_shared/card-BGlQzQY-.js";import{E as j}from"../packem_shared/empty-state-B939z6K2.js";import{T as H,a as L,b as A,c as w,d as W,e as K}from"../packem_shared/table-BMsuYFhk.js";import{u as q}from"../packem_shared/use-admin-query-P0RJrjsD.js";import{useAutoRefresh as O}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.js";import{u as Q}from"../packem_shared/use-shard-key-BsP3o5wT.js";import{useT as U}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as z}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{jsxs as x,jsx as s,Fragment as G}from"react/jsx-runtime";const P=n=>`${n.toString()} ms`,J=n=>n.totalConnections===0&&n.shapePoke.passes===0&&n.whisper.passes===0,D=n=>{const e=F(48),{counters:o,includeTiming:a,prefix:r,t:l,title:I}=n,v=`${r}-section`;let f;e[0]!==I?(f=s("h3",{className:"text-sm font-medium text-foreground",children:I}),e[0]=I,e[1]=f):f=e[1];const t=`${r}-stats`;let i;e[2]!==l?(i=l("Passes"),e[2]=l,e[3]=i):i=e[3];const S=`${r}-passes`;let b;e[4]!==o.passes||e[5]!==i||e[6]!==S?(b=s($,{label:i,testId:S,value:o.passes}),e[4]=o.passes,e[5]=i,e[6]=S,e[7]=b):b=e[7];let p;e[8]!==l?(p=l("Sockets iterated"),e[8]=l,e[9]=p):p=e[9];const y=`${r}-iterated`;let c;e[10]!==o.socketsIterated||e[11]!==p||e[12]!==y?(c=s($,{label:p,testId:y,value:o.socketsIterated}),e[10]=o.socketsIterated,e[11]=p,e[12]=y,e[13]=c):c=e[13];let d;e[14]!==l?(d=l("Delivered"),e[14]=l,e[15]=d):d=e[15];const k=`${r}-delivered`;let u;e[16]!==o.socketsDelivered||e[17]!==d||e[18]!==k?(u=s($,{label:d,testId:k,value:o.socketsDelivered}),e[16]=o.socketsDelivered,e[17]=d,e[18]=k,e[19]=u):u=e[19];let m;e[20]!==l?(m=l("Peak width"),e[20]=l,e[21]=m):m=e[21];const g=`${r}-peak`;let h;e[22]!==o.peakSocketsIterated||e[23]!==m||e[24]!==g?(h=s($,{label:m,testId:g,value:o.peakSocketsIterated}),e[22]=o.peakSocketsIterated,e[23]=m,e[24]=g,e[25]=h):h=e[25];let C;e[26]!==o.totalMs||e[27]!==a||e[28]!==r||e[29]!==l?(C=a&&s($,{label:l("Total time"),testId:`${r}-total-ms`,value:P(o.totalMs)}),e[26]=o.totalMs,e[27]=a,e[28]=r,e[29]=l,e[30]=C):C=e[30];let N;e[31]!==o.maxMs||e[32]!==a||e[33]!==r||e[34]!==l?(N=a&&s($,{label:l("Max time"),testId:`${r}-max-ms`,value:P(o.maxMs)}),e[31]=o.maxMs,e[32]=a,e[33]=r,e[34]=l,e[35]=N):N=e[35];let T;e[36]!==u||e[37]!==h||e[38]!==C||e[39]!==N||e[40]!==t||e[41]!==b||e[42]!==c?(T=x("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":t,children:[b,c,u,h,C,N]}),e[36]=u,e[37]=h,e[38]=C,e[39]=N,e[40]=t,e[41]=b,e[42]=c,e[43]=T):T=e[43];let M;return e[44]!==v||e[45]!==T||e[46]!==f?(M=x("section",{className:"flex flex-col gap-2","data-testid":v,children:[f,T]}),e[44]=v,e[45]=T,e[46]=f,e[47]=M):M=e[47],M},ue=n=>{const e=F(31),{initialShardKey:o}=n,a=U(),{queryShardKey:r,setShardKey:l,shardKey:I}=Q(o);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={},e[0]=v):v=e[0];let f;e[1]!==r?(f={keepPreviousData:!0,shardKey:r},e[1]=r,e[2]=f):f=e[2];const{data:t,error:i,errorSource:S,refetch:b}=q(z.getFanoutMetrics,v,f);O(b,!0);let p;e[3]!==t?(p=t!==void 0&&J(t),e[3]=t,e[4]=p):p=e[4];const y=p;let c;e[5]!==l||e[6]!==I?(c=s(E,{onChange:l,testId:"fanout-shard-input",value:I}),e[5]=l,e[6]=I,e[7]=c):c=e[7];let d;e[8]!==t||e[9]!==a?(d=t!==void 0&&x("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"fanout-count",children:[t.promoted&&s(R,{"data-testid":"fanout-promoted",variant:t.relayCount>=t.maxRelays?"destructive":"default",children:t.relayCount>=t.maxRelays?a("auto-scaled: {relayCount}/{maxRelays} relays (at ceiling)",{maxRelays:t.maxRelays,relayCount:t.relayCount}):a("auto-scaled: {relayCount}/{maxRelays} relays",{maxRelays:t.maxRelays,relayCount:t.relayCount})}),s(R,{variant:"secondary",children:a("{count} connections",{count:t.totalConnections})}),s(R,{variant:"secondary",children:a("peak {count} subscribers",{count:t.peakSubscribers})})]}),e[8]=t,e[9]=a,e[10]=d):d=e[10];let k;e[11]!==c||e[12]!==d?(k=x("div",{className:"flex flex-wrap items-center gap-2",children:[c,d]}),e[11]=c,e[12]=d,e[13]=k):k=e[13];let u;e[14]!==i||e[15]!==S?(u=i!==null&&s(B,{error:S,testId:"fanout-error"}),e[14]=i,e[15]=S,e[16]=u):u=e[16];let m;e[17]!==i||e[18]!==y||e[19]!==a?(m=i===null&&y&&s(j,{description:a("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:a("No fan-out activity yet.")}),e[17]=i,e[18]=y,e[19]=a,e[20]=m):m=e[20];let g;e[21]!==i||e[22]!==y||e[23]!==t||e[24]!==a?(g=i===null&&t!==void 0&&!y&&x(G,{children:[t.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:a("Hot topics")}),s(_,{className:"overflow-hidden py-0",children:x(H,{"data-testid":"fanout-topics-table",children:[s(L,{children:x(A,{children:[s(w,{children:a("Topic")}),s(w,{children:a("Kind")}),s(w,{className:"text-right",children:a("Subscribers")})]})}),s(W,{children:t.topics.map(V)})]})})]}),x("section",{className:"flex flex-col gap-3","data-testid":"fanout-cost",children:[s("h2",{className:"text-sm font-medium text-muted-foreground",children:a("Fan-out cost since this instance woke")}),s(D,{counters:t.shapePoke,includeTiming:!0,prefix:"fanout-poke",t:a,title:a("Shape pokes")}),s(D,{counters:t.whisper,includeTiming:!1,prefix:"fanout-whisper",t:a,title:a("Whisper broadcasts")})]})]}),e[21]=i,e[22]=y,e[23]=t,e[24]=a,e[25]=g):g=e[25];let h;return e[26]!==k||e[27]!==u||e[28]!==m||e[29]!==g?(h=x("div",{className:"flex flex-col gap-4","data-testid":"fanout-panel",children:[k,u,m,g]}),e[26]=k,e[27]=u,e[28]=m,e[29]=g,e[30]=h):h=e[30],h};function V(n){return x(A,{"data-testid":"fanout-topic-row",children:[s(K,{className:"font-mono text-xs",children:n.topic}),s(K,{children:s(R,{variant:"outline",children:n.kind})}),s(K,{className:"text-right font-medium tabular-nums",children:n.subscribers})]},`${n.kind}:${n.topic}`)}export{ue as default};
1
+ import{c as F}from"react/compiler-runtime";import{E as B}from"../packem_shared/error-alert-CKqB2CiN.js";import{ShardInput as E}from"../packem_shared/ShardInput-XumEzeT0.js";import{S as $}from"../packem_shared/stat-card-B9uIvAHg.js";import{B as R}from"../packem_shared/badge-cAk9Di1Q.js";import{C as _}from"../packem_shared/card-BGlQzQY-.js";import{E as j}from"../packem_shared/empty-state-B939z6K2.js";import{T as H,a as L,b as A,c as w,d as W,e as K}from"../packem_shared/table-BMsuYFhk.js";import{u as q}from"../packem_shared/use-admin-query-DV9xmFl8.js";import{useAutoRefresh as O}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.js";import{u as Q}from"../packem_shared/use-shard-key-BsP3o5wT.js";import{useT as U}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as z}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{jsxs as x,jsx as s,Fragment as G}from"react/jsx-runtime";const P=n=>`${n.toString()} ms`,J=n=>n.totalConnections===0&&n.shapePoke.passes===0&&n.whisper.passes===0,D=n=>{const e=F(48),{counters:o,includeTiming:a,prefix:r,t:l,title:I}=n,v=`${r}-section`;let f;e[0]!==I?(f=s("h3",{className:"text-sm font-medium text-foreground",children:I}),e[0]=I,e[1]=f):f=e[1];const t=`${r}-stats`;let i;e[2]!==l?(i=l("Passes"),e[2]=l,e[3]=i):i=e[3];const S=`${r}-passes`;let b;e[4]!==o.passes||e[5]!==i||e[6]!==S?(b=s($,{label:i,testId:S,value:o.passes}),e[4]=o.passes,e[5]=i,e[6]=S,e[7]=b):b=e[7];let p;e[8]!==l?(p=l("Sockets iterated"),e[8]=l,e[9]=p):p=e[9];const y=`${r}-iterated`;let c;e[10]!==o.socketsIterated||e[11]!==p||e[12]!==y?(c=s($,{label:p,testId:y,value:o.socketsIterated}),e[10]=o.socketsIterated,e[11]=p,e[12]=y,e[13]=c):c=e[13];let d;e[14]!==l?(d=l("Delivered"),e[14]=l,e[15]=d):d=e[15];const k=`${r}-delivered`;let u;e[16]!==o.socketsDelivered||e[17]!==d||e[18]!==k?(u=s($,{label:d,testId:k,value:o.socketsDelivered}),e[16]=o.socketsDelivered,e[17]=d,e[18]=k,e[19]=u):u=e[19];let m;e[20]!==l?(m=l("Peak width"),e[20]=l,e[21]=m):m=e[21];const g=`${r}-peak`;let h;e[22]!==o.peakSocketsIterated||e[23]!==m||e[24]!==g?(h=s($,{label:m,testId:g,value:o.peakSocketsIterated}),e[22]=o.peakSocketsIterated,e[23]=m,e[24]=g,e[25]=h):h=e[25];let C;e[26]!==o.totalMs||e[27]!==a||e[28]!==r||e[29]!==l?(C=a&&s($,{label:l("Total time"),testId:`${r}-total-ms`,value:P(o.totalMs)}),e[26]=o.totalMs,e[27]=a,e[28]=r,e[29]=l,e[30]=C):C=e[30];let N;e[31]!==o.maxMs||e[32]!==a||e[33]!==r||e[34]!==l?(N=a&&s($,{label:l("Max time"),testId:`${r}-max-ms`,value:P(o.maxMs)}),e[31]=o.maxMs,e[32]=a,e[33]=r,e[34]=l,e[35]=N):N=e[35];let T;e[36]!==u||e[37]!==h||e[38]!==C||e[39]!==N||e[40]!==t||e[41]!==b||e[42]!==c?(T=x("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":t,children:[b,c,u,h,C,N]}),e[36]=u,e[37]=h,e[38]=C,e[39]=N,e[40]=t,e[41]=b,e[42]=c,e[43]=T):T=e[43];let M;return e[44]!==v||e[45]!==T||e[46]!==f?(M=x("section",{className:"flex flex-col gap-2","data-testid":v,children:[f,T]}),e[44]=v,e[45]=T,e[46]=f,e[47]=M):M=e[47],M},ue=n=>{const e=F(31),{initialShardKey:o}=n,a=U(),{queryShardKey:r,setShardKey:l,shardKey:I}=Q(o);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={},e[0]=v):v=e[0];let f;e[1]!==r?(f={keepPreviousData:!0,shardKey:r},e[1]=r,e[2]=f):f=e[2];const{data:t,error:i,errorSource:S,refetch:b}=q(z.getFanoutMetrics,v,f);O(b,!0);let p;e[3]!==t?(p=t!==void 0&&J(t),e[3]=t,e[4]=p):p=e[4];const y=p;let c;e[5]!==l||e[6]!==I?(c=s(E,{onChange:l,testId:"fanout-shard-input",value:I}),e[5]=l,e[6]=I,e[7]=c):c=e[7];let d;e[8]!==t||e[9]!==a?(d=t!==void 0&&x("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"fanout-count",children:[t.promoted&&s(R,{"data-testid":"fanout-promoted",variant:t.relayCount>=t.maxRelays?"destructive":"default",children:t.relayCount>=t.maxRelays?a("auto-scaled: {relayCount}/{maxRelays} relays (at ceiling)",{maxRelays:t.maxRelays,relayCount:t.relayCount}):a("auto-scaled: {relayCount}/{maxRelays} relays",{maxRelays:t.maxRelays,relayCount:t.relayCount})}),s(R,{variant:"secondary",children:a("{count} connections",{count:t.totalConnections})}),s(R,{variant:"secondary",children:a("peak {count} subscribers",{count:t.peakSubscribers})})]}),e[8]=t,e[9]=a,e[10]=d):d=e[10];let k;e[11]!==c||e[12]!==d?(k=x("div",{className:"flex flex-wrap items-center gap-2",children:[c,d]}),e[11]=c,e[12]=d,e[13]=k):k=e[13];let u;e[14]!==i||e[15]!==S?(u=i!==null&&s(B,{error:S,testId:"fanout-error"}),e[14]=i,e[15]=S,e[16]=u):u=e[16];let m;e[17]!==i||e[18]!==y||e[19]!==a?(m=i===null&&y&&s(j,{description:a("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:a("No fan-out activity yet.")}),e[17]=i,e[18]=y,e[19]=a,e[20]=m):m=e[20];let g;e[21]!==i||e[22]!==y||e[23]!==t||e[24]!==a?(g=i===null&&t!==void 0&&!y&&x(G,{children:[t.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:a("Hot topics")}),s(_,{className:"overflow-hidden py-0",children:x(H,{"data-testid":"fanout-topics-table",children:[s(L,{children:x(A,{children:[s(w,{children:a("Topic")}),s(w,{children:a("Kind")}),s(w,{className:"text-right",children:a("Subscribers")})]})}),s(W,{children:t.topics.map(V)})]})})]}),x("section",{className:"flex flex-col gap-3","data-testid":"fanout-cost",children:[s("h2",{className:"text-sm font-medium text-muted-foreground",children:a("Fan-out cost since this instance woke")}),s(D,{counters:t.shapePoke,includeTiming:!0,prefix:"fanout-poke",t:a,title:a("Shape pokes")}),s(D,{counters:t.whisper,includeTiming:!1,prefix:"fanout-whisper",t:a,title:a("Whisper broadcasts")})]})]}),e[21]=i,e[22]=y,e[23]=t,e[24]=a,e[25]=g):g=e[25];let h;return e[26]!==k||e[27]!==u||e[28]!==m||e[29]!==g?(h=x("div",{className:"flex flex-col gap-4","data-testid":"fanout-panel",children:[k,u,m,g]}),e[26]=k,e[27]=u,e[28]=m,e[29]=g,e[30]=h):h=e[30],h};function V(n){return x(A,{"data-testid":"fanout-topic-row",children:[s(K,{className:"font-mono text-xs",children:n.topic}),s(K,{children:s(R,{variant:"outline",children:n.kind})}),s(K,{className:"text-right font-medium tabular-nums",children:n.subscribers})]},`${n.kind}:${n.topic}`)}export{ue as default};
@@ -1 +1 @@
1
- import{useState as C}from"react";import{E as S}from"../packem_shared/error-alert-TYdKetJd.js";import{B as w}from"../packem_shared/badge-cAk9Di1Q.js";import{C as A,a as k}from"../packem_shared/card-BGlQzQY-.js";import{E as g}from"../packem_shared/empty-state-B939z6K2.js";import{L as E}from"../packem_shared/label-BOUo-DP0.js";import{T as O,a as F,b as x,c as s,d as j,e as n}from"../packem_shared/table-BMsuYFhk.js";import{T as I}from"../packem_shared/textarea-DpO3i-Qo.js";import{u as J}from"../packem_shared/use-admin-query-P0RJrjsD.js";import{useT as L}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as B}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{jsx as e,jsxs as l}from"react/jsx-runtime";const H=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."}}},K='{ "targetingKey": "user-123", "plan": "premium" }',R=a=>a.type==="object"?JSON.stringify(a.value):String(a.value),W=({initialShardKey:a=""})=>{const t=L(),[o,p]=C(""),{context:c,error:f}=H(o),h=c===void 0?{}:{context:c},{data:i,error:y,errorSource:v,liveError:N}=J(B.listFlags,h,{live:!0,shardKey:a}),m=i!==void 0,b=i?.configured??!1,u=Array.isArray(i?.flags)?[...i.flags].toSorted((r,T)=>r.key.localeCompare(T.key)):[];let d;return m&&!b?d=e(g,{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")}):m&&u.length===0?d=e(g,{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(k,{className:"px-0",children:l(O,{"data-testid":"flags-table",children:[e(F,{children:l(x,{children:[e(s,{children:t("Key")}),e(s,{children:t("Type")}),e(s,{children:t("Value")}),e(s,{children:t("Reason")}),e(s,{children:t("Variant")})]})}),e(j,{children:u.map(r=>l(x,{"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(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))})]})})}),l("div",{className:"flex flex-col gap-6","data-testid":"lunora-flags-panel",children:[y!==null&&e(S,{error:v,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.')}),l("div",{className:"flex flex-col gap-2",children:[e(E,{htmlFor:"flags-targeting-context",children:t("Targeting context (JSON)")}),e(I,{className:"font-mono text-xs","data-testid":"flags-context-input",id:"flags-targeting-context",onChange:r=>{p(r.target.value)},placeholder:K,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{W as default};
1
+ import{useState as C}from"react";import{E as S}from"../packem_shared/error-alert-CKqB2CiN.js";import{B as w}from"../packem_shared/badge-cAk9Di1Q.js";import{C as A,a as k}from"../packem_shared/card-BGlQzQY-.js";import{E as g}from"../packem_shared/empty-state-B939z6K2.js";import{L as E}from"../packem_shared/label-BOUo-DP0.js";import{T as O,a as F,b as x,c as s,d as j,e as n}from"../packem_shared/table-BMsuYFhk.js";import{T as I}from"../packem_shared/textarea-DpO3i-Qo.js";import{u as J}from"../packem_shared/use-admin-query-DV9xmFl8.js";import{useT as L}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as B}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{jsx as e,jsxs as l}from"react/jsx-runtime";const H=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."}}},K='{ "targetingKey": "user-123", "plan": "premium" }',R=a=>a.type==="object"?JSON.stringify(a.value):String(a.value),W=({initialShardKey:a=""})=>{const t=L(),[o,p]=C(""),{context:c,error:f}=H(o),h=c===void 0?{}:{context:c},{data:i,error:y,errorSource:v,liveError:N}=J(B.listFlags,h,{live:!0,shardKey:a}),m=i!==void 0,b=i?.configured??!1,u=Array.isArray(i?.flags)?[...i.flags].toSorted((r,T)=>r.key.localeCompare(T.key)):[];let d;return m&&!b?d=e(g,{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")}):m&&u.length===0?d=e(g,{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(k,{className:"px-0",children:l(O,{"data-testid":"flags-table",children:[e(F,{children:l(x,{children:[e(s,{children:t("Key")}),e(s,{children:t("Type")}),e(s,{children:t("Value")}),e(s,{children:t("Reason")}),e(s,{children:t("Variant")})]})}),e(j,{children:u.map(r=>l(x,{"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(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))})]})})}),l("div",{className:"flex flex-col gap-6","data-testid":"lunora-flags-panel",children:[y!==null&&e(S,{error:v,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.')}),l("div",{className:"flex flex-col gap-2",children:[e(E,{htmlFor:"flags-targeting-context",children:t("Targeting context (JSON)")}),e(I,{className:"font-mono text-xs","data-testid":"flags-context-input",id:"flags-targeting-context",onChange:r=>{p(r.target.value)},placeholder:K,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{W as default};
@@ -1 +1 @@
1
- import{c as xe}from"react/compiler-runtime";import{findIssueSolution as we,flattenHint as Ee}from"@lunora/errors";import{useLunora as Ne}from"@lunora/react";import{useState as ne}from"react";import{L as Te}from"../packem_shared/live-status-Bf7rR8o8.js";import{ShardInput as $e}from"../packem_shared/ShardInput-XumEzeT0.js";import{B as pe}from"../packem_shared/badge-cAk9Di1Q.js";import{B as oe}from"../packem_shared/button-BOPLD1un.js";import{C as Ae,a as Ce}from"../packem_shared/card-BGlQzQY-.js";import{E as _e}from"../packem_shared/empty-state-B939z6K2.js";import{I as ke}from"../packem_shared/input-CY5W3wzv.js";import{S as Me,a as Re,b as Ke,c as be,d as Le}from"../packem_shared/select-BPISLTcv.js";import{T as Ve,a as Oe,b as ye,c as F,d as Ue,e as B}from"../packem_shared/table-BMsuYFhk.js";import{u as Be}from"../packem_shared/use-admin-query-P0RJrjsD.js";import{u as Fe}from"../packem_shared/use-async-submit-DdLd0MdK.js";import{u as ze}from"../packem_shared/use-shard-key-BsP3o5wT.js";import{useT as ve}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as ie}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as He,f as re,c as de,d as Ie,b as je}from"../packem_shared/internal-CwaF9YNk.js";import{jsx as s,jsxs as w,Fragment as De}from"react/jsx-runtime";const ge="none",qe=["all","open","resolved","ignored"],Ge=["critical","high","medium","low"],Pe=de(ie.resolveIssue),We=de(ie.ignoreIssue),Se=de(ie.assignIssue),Ye=de(ie.setIssueSeverity),Qe=de(ie.explainIssue),Xe=n=>Array.isArray(n?.issues)?n.issues:[],Je=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:h,issue:t,shardKey:E}=n,i=Ne(),r=ve(),[a,o]=ne(void 0),{busy:R,error:A,run:L}=Fe();let C;e[0]!==i||e[1]!==t||e[2]!==L||e[3]!==E?(C=()=>{o(void 0),L(async()=>{const f={culprit:t.culprit,sampleMessage:t.sampleMessage,title:t.title},I=await i.query(Qe,f,Ie(E));o(I)})},e[0]=i,e[1]=t,e[2]=L,e[3]=E,e[4]=C):C=e[4];const K=C;if(!h)return null;let T;if(e[5]!==t.sampleMessage){const f=we(t.sampleMessage);T=f===void 0?void 0:Ee(f.body),e[5]=t.sampleMessage,e[6]=T}else T=e[6];const _=T,M=`issues-detail-${t.hash}`;let d;e[7]!==t.sampleMessage?(d=s("p",{className:"whitespace-pre-wrap font-mono text-xs text-muted-foreground",children:t.sampleMessage}),e[7]=t.sampleMessage,e[8]=d):d=e[8];let g;e[9]!==r?(g=r("Suggested fix"),e[9]=r,e[10]=g):g=e[10];let $;e[11]!==g?($=s("div",{className:"text-xs font-medium text-muted-foreground",children:g}),e[11]=g,e[12]=$):$=e[12];let x;e[13]!==_||e[14]!==t.hash||e[15]!==r?(x=_===void 0?s("p",{className:"mt-1 text-sm text-muted-foreground","data-testid":`issues-hint-empty-${t.hash}`,children:r("No known fix for this error yet.")}):s("p",{className:"mt-1 whitespace-pre-wrap text-sm","data-testid":`issues-hint-${t.hash}`,children:_}),e[13]=_,e[14]=t.hash,e[15]=r,e[16]=x):x=e[16];let y;e[17]!==$||e[18]!==x?(y=w("div",{children:[$,x]}),e[17]=$,e[18]=x,e[19]=y):y=e[19];const S=`issues-explain-${t.hash}`;let N;e[20]!==R||e[21]!==r?(N=r(R?"Explaining…":"Explain in plain language"),e[20]=R,e[21]=r,e[22]=N):N=e[22];let u;e[23]!==R||e[24]!==K||e[25]!==N||e[26]!==S?(u=s("div",{children:s(oe,{"data-testid":S,disabled:R,onClick:K,size:"sm",type:"button",variant:"outline",children:N})}),e[23]=R,e[24]=K,e[25]=N,e[26]=S,e[27]=u):u=e[27];let p;e[28]!==A||e[29]!==t.hash?(p=A!==null&&s("p",{className:"text-xs text-destructive","data-testid":`issues-explain-error-${t.hash}`,role:"alert",children:A}),e[28]=A,e[29]=t.hash,e[30]=p):p=e[30];let m;e[31]!==a||e[32]!==t.hash||e[33]!==r?(m=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"?r("No AI binding is configured. Wire an AI binding to enable plain-language explanations — the suggested fix above is always available."):r("The AI model could not explain this error right now. The suggested fix above still applies.")}):w("div",{"data-testid":`issues-explanation-${t.hash}`,children:[s("div",{className:"text-xs font-medium text-muted-foreground",children:r("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:r("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:r("Generated by {model}",{model:a.model})})]})),e[31]=a,e[32]=t.hash,e[33]=r,e[34]=m):m=e[34];let c;e[35]!==u||e[36]!==p||e[37]!==m||e[38]!==d||e[39]!==y?(c=s(B,{className:"bg-muted/30",colSpan:7,children:w("div",{className:"flex flex-col gap-3 py-1",children:[d,y,u,p,m]})}),e[35]=u,e[36]=p,e[37]=m,e[38]=d,e[39]=y,e[40]=c):c=e[40];let b;return e[41]!==c||e[42]!==M?(b=s(ye,{"data-testid":M,children:c}),e[41]=c,e[42]=M,e[43]=b):b=e[43],b},tt=n=>{const e=xe(119),{busy:h,issue:t,rowError:E,runTriage:i,shardKey:r}=n,a=ve(),[o,R]=ne(!1);let A;e[0]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{R(st)},e[0]=A):A=e[0];const L=A;let C;e[1]!==t.hash||e[2]!==i?(C=ae=>{const he=ae===null||ae===ge?null:ae;re(i(t.hash,Ye,{severity:he}))},e[1]=t.hash,e[2]=i,e[3]=C):C=e[3];const K=C;let T;e[4]!==t.hash||e[5]!==i?(T=ae=>{if(ae.key!=="Enter")return;const he=ae.currentTarget.value.trim();re(i(t.hash,Se,{assignee:he===""?null:he}))},e[4]=t.hash,e[5]=i,e[6]=T):T=e[6];const _=T,M=`issues-row-${t.hash}`;let d;e[7]!==a?(d=a("Toggle issue details"),e[7]=a,e[8]=d):d=e[8];const g=`issues-toggle-${t.hash}`,$=`mt-1 size-3 shrink-0 text-muted-foreground transition-transform ${o?"rotate-90":""}`;let x;e[9]===Symbol.for("react.memo_cache_sentinel")?(x=s("path",{d:"m9 6 6 6-6 6"}),e[9]=x):x=e[9];let y;e[10]!==$?(y=s("svg",{"aria-hidden":"true",className:$,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:x}),e[10]=$,e[11]=y):y=e[11];let S;e[12]!==t.title?(S=s("span",{className:"block truncate font-medium",title:t.title,children:t.title}),e[12]=t.title,e[13]=S):S=e[13];let N;e[14]!==t.culprit?(N=s("span",{className:"block truncate font-mono text-xs text-muted-foreground",title:t.culprit,children:t.culprit}),e[14]=t.culprit,e[15]=N):N=e[15];let u;e[16]!==S||e[17]!==N?(u=w("span",{className:"min-w-0",children:[S,N]}),e[16]=S,e[17]=N,e[18]=u):u=e[18];let p;e[19]!==o||e[20]!==u||e[21]!==d||e[22]!==g||e[23]!==y?(p=w("button",{"aria-expanded":o,"aria-label":d,className:"flex w-full items-start gap-2 text-left","data-testid":g,onClick:L,type:"button",children:[y,u]}),e[19]=o,e[20]=u,e[21]=d,e[22]=g,e[23]=y,e[24]=p):p=e[24];let m;e[25]!==t.hash||e[26]!==E?(m=E!==void 0&&s("p",{className:"mt-1 text-xs text-destructive","data-testid":`issues-action-error-${t.hash}`,role:"alert",children:E}),e[25]=t.hash,e[26]=E,e[27]=m):m=e[27];let c;e[28]!==p||e[29]!==m?(c=w(B,{className:"max-w-80",children:[p,m]}),e[28]=p,e[29]=m,e[30]=c):c=e[30];const b=`issues-status-${t.hash}`;let f;e[31]!==t.status?(f=Je(t.status),e[31]=t.status,e[32]=f):f=e[32];let I;e[33]!==t.status||e[34]!==b||e[35]!==f?(I=s(B,{children:s(pe,{"data-testid":b,variant:f,children:t.status})}),e[33]=t.status,e[34]=b,e[35]=f,e[36]=I):I=e[36];const V=t.severity??ge;let l;e[37]!==a?(l=a("Set severity"),e[37]=a,e[38]=l):l=e[38];const le=`issues-severity-${t.hash}`;let O;e[39]!==a?(O=a("—"),e[39]=a,e[40]=O):O=e[40];let v;e[41]!==t.severity||e[42]!==a?(v=t.severity===void 0?s("span",{className:"text-muted-foreground",children:a("—")}):s(pe,{variant:Ze(t.severity),children:t.severity}),e[41]=t.severity,e[42]=a,e[43]=v):v=e[43];let k;e[44]!==O||e[45]!==v?(k=s(Me,{placeholder:O,children:v}),e[44]=O,e[45]=v,e[46]=k):k=e[46];let U;e[47]!==l||e[48]!==le||e[49]!==k?(U=s(Re,{"aria-label":l,className:"h-7 w-[110px]","data-testid":le,children:k}),e[47]=l,e[48]=le,e[49]=k,e[50]=U):U=e[50];let z;e[51]===Symbol.for("react.memo_cache_sentinel")?(z=Ge.map(at),e[51]=z):z=e[51];let H;e[52]!==a?(H=a("Clear"),e[52]=a,e[53]=H):H=e[53];let j;e[54]!==H?(j=w(Ke,{children:[z,s(be,{value:ge,children:H})]}),e[54]=H,e[55]=j):j=e[55];let D;e[56]!==h||e[57]!==K||e[58]!==V||e[59]!==U||e[60]!==j?(D=s(B,{children:w(Le,{disabled:h,onValueChange:K,value:V,children:[U,j]})}),e[56]=h,e[57]=K,e[58]=V,e[59]=U,e[60]=j,e[61]=D):D=e[61];let q;e[62]!==a?(q=a("Assignee"),e[62]=a,e[63]=q):q=e[63];const ue=`issues-assignee-${t.hash}`,me=t.assignee??"",fe=t.assignee??"";let G;e[64]!==a?(G=a("Unassigned"),e[64]=a,e[65]=G):G=e[65];let P;e[66]!==h||e[67]!==_||e[68]!==q||e[69]!==ue||e[70]!==me||e[71]!==fe||e[72]!==G?(P=s(B,{children:s(ke,{"aria-label":q,className:"h-7 w-32","data-testid":ue,defaultValue:me,disabled:h,onKeyDown:_,placeholder:G},fe)}),e[66]=h,e[67]=_,e[68]=q,e[69]=ue,e[70]=me,e[71]=fe,e[72]=G,e[73]=P):P=e[73];let W;e[74]!==t.count?(W=s(B,{className:"text-right",children:s(pe,{variant:"secondary",children:t.count})}),e[74]=t.count,e[75]=W):W=e[75];let Y;e[76]!==t.lastSeen?(Y=He(t.lastSeen),e[76]=t.lastSeen,e[77]=Y):Y=e[77];let Q;e[78]!==Y?(Q=s(B,{className:"text-xs tabular-nums text-muted-foreground",children:Y}),e[78]=Y,e[79]=Q):Q=e[79];let X;e[80]!==h||e[81]!==t.hash||e[82]!==t.status||e[83]!==i||e[84]!==a?(X=t.status!=="resolved"&&s(oe,{"data-testid":`issues-resolve-${t.hash}`,disabled:h,onClick:()=>{re(i(t.hash,Pe,{}))},size:"xs",variant:"outline",children:a("Resolve")}),e[80]=h,e[81]=t.hash,e[82]=t.status,e[83]=i,e[84]=a,e[85]=X):X=e[85];let J;e[86]!==h||e[87]!==t.hash||e[88]!==t.status||e[89]!==i||e[90]!==a?(J=t.status!=="ignored"&&s(oe,{"data-testid":`issues-ignore-${t.hash}`,disabled:h,onClick:()=>{re(i(t.hash,We,{}))},size:"xs",variant:"ghost",children:a("Ignore")}),e[86]=h,e[87]=t.hash,e[88]=t.status,e[89]=i,e[90]=a,e[91]=J):J=e[91];let Z;e[92]!==h||e[93]!==t.assignee||e[94]!==t.hash||e[95]!==t.status||e[96]!==i||e[97]!==a?(Z=t.status!=="open"&&s(oe,{"data-testid":`issues-reopen-${t.hash}`,disabled:h,onClick:()=>{re(i(t.hash,Se,{assignee:t.assignee??null}))},size:"xs",variant:"ghost",children:a("Reopen")}),e[92]=h,e[93]=t.assignee,e[94]=t.hash,e[95]=t.status,e[96]=i,e[97]=a,e[98]=Z):Z=e[98];let ee;e[99]!==X||e[100]!==J||e[101]!==Z?(ee=s(B,{className:"text-right",children:w("div",{className:"flex justify-end gap-1",children:[X,J,Z]})}),e[99]=X,e[100]=J,e[101]=Z,e[102]=ee):ee=e[102];let te;e[103]!==c||e[104]!==I||e[105]!==D||e[106]!==P||e[107]!==W||e[108]!==Q||e[109]!==M||e[110]!==ee?(te=w(ye,{"data-testid":M,children:[c,I,D,P,W,Q,ee]}),e[103]=c,e[104]=I,e[105]=D,e[106]=P,e[107]=W,e[108]=Q,e[109]=M,e[110]=ee,e[111]=te):te=e[111];let se;e[112]!==o||e[113]!==t||e[114]!==r?(se=s(et,{expanded:o,issue:t,shardKey:r},t.sampleMessage),e[112]=o,e[113]=t,e[114]=r,e[115]=se):se=e[115];let ce;return e[116]!==te||e[117]!==se?(ce=w(De,{children:[te,se]}),e[116]=te,e[117]=se,e[118]=ce):ce=e[118],ce},Tt=n=>{const e=xe(38),{initialShardKey:h}=n,t=ve(),E=Ne(),{queryShardKey:i,setShardKey:r,shardKey:a}=ze(h),[o,R]=ne("all"),[A,L]=ne(it),[C,K]=ne(lt);let T;e[0]!==o?(T=o==="all"?{}:{status:o},e[0]=o,e[1]=T):T=e[1];let _;e[2]!==i?(_={live:!0,shardKey:i},e[2]=i,e[3]=_):_=e[3];const{data:M,error:d,liveError:g}=Be(ie.getIssues,T,_),$=M!==void 0;let x;if(e[4]!==C||e[5]!==A||e[6]!==E||e[7]!==M||e[8]!==d||e[9]!==g||e[10]!==$||e[11]!==i||e[12]!==r||e[13]!==a||e[14]!==o||e[15]!==t){const y=Xe(M);let S;e[17]!==E||e[18]!==i?(S=async(l,le,O)=>{K(v=>{if(!v.has(l))return v;const k=new Map(v);return k.delete(l),k}),L(v=>new Set(v).add(l));try{await E.query(le,{...O,hash:l},Ie(i))}catch(v){const U=je(v);K(z=>new Map(z).set(l,U))}L(v=>{const k=new Set(v);return k.delete(l),k})},e[17]=E,e[18]=i,e[19]=S):S=e[19];const N=S;let u;e[20]!==t?(u=l=>t(l==="all"?"All":l==="open"?"Open":l==="resolved"?"Resolved":"Ignored"),e[20]=t,e[21]=u):u=e[21];const p=u;let m;e[22]!==d?(m=d!==null&&s("p",{className:"text-sm text-destructive","data-testid":"issues-error",role:"alert",children:d}),e[22]=d,e[23]=m):m=e[23];let c;e[24]!==r||e[25]!==a?(c=s($e,{onChange:r,testId:"issues-shard-input",value:a}),e[24]=r,e[25]=a,e[26]=c):c=e[26];let b;e[27]!==g?(b=s(Te,{message:g,prefix:"issues"}),e[27]=g,e[28]=b):b=e[28];let f;e[29]!==o||e[30]!==p?(f=qe.map(l=>s(oe,{"data-active":o===l?"":void 0,"data-testid":`issues-filter-${l}`,onClick:()=>{R(l)},size:"xs",variant:o===l?"default":"outline",children:p(l)},l)),e[29]=o,e[30]=p,e[31]=f):f=e[31];let I;e[32]!==f?(I=s("div",{className:"ms-auto flex items-center gap-1","data-testid":"issues-status-filter",role:"group",children:f}),e[32]=f,e[33]=I):I=e[33];let V;e[34]!==I||e[35]!==c||e[36]!==b?(V=w("div",{className:"flex flex-wrap items-center gap-2",children:[c,b,I]}),e[34]=I,e[35]=c,e[36]=b,e[37]=V):V=e[37],x=w("div",{className:"flex flex-col gap-6","data-testid":"lunora-issues-panel",children:[m,V,$&&y.length===0?s(_e,{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:w(Ve,{"data-testid":"issues-table",children:[s(Oe,{children:w(ye,{children:[s(F,{children:t("Issue")}),s(F,{children:t("Status")}),s(F,{children:t("Severity")}),s(F,{children:t("Assignee")}),s(F,{className:"text-right",children:t("Events")}),s(F,{children:t("Last seen")}),s(F,{className:"text-right",children:t("Actions")})]})}),s(Ue,{children:y.map(l=>s(tt,{busy:A.has(l.hash),issue:l,rowError:C.get(l.hash),runTriage:N,shardKey:i},l.hash))})]})})})]}),e[4]=C,e[5]=A,e[6]=E,e[7]=M,e[8]=d,e[9]=g,e[10]=$,e[11]=i,e[12]=r,e[13]=a,e[14]=o,e[15]=t,e[16]=x}else x=e[16];return x};function st(n){return!n}function at(n){return s(be,{value:n,children:n},n)}function it(){return new Set}function lt(){return new Map}export{Tt as default};
1
+ import{c as xe}from"react/compiler-runtime";import{findIssueSolution as we,flattenHint as Ee}from"@lunora/errors";import{useLunora as Ne}from"@lunora/react";import{useState as ne}from"react";import{L as Te}from"../packem_shared/live-status-Bf7rR8o8.js";import{ShardInput as $e}from"../packem_shared/ShardInput-XumEzeT0.js";import{B as pe}from"../packem_shared/badge-cAk9Di1Q.js";import{B as oe}from"../packem_shared/button-BOPLD1un.js";import{C as Ae,a as Ce}from"../packem_shared/card-BGlQzQY-.js";import{E as _e}from"../packem_shared/empty-state-B939z6K2.js";import{I as ke}from"../packem_shared/input-CY5W3wzv.js";import{S as Me,a as Re,b as Ke,c as be,d as Le}from"../packem_shared/select-BPISLTcv.js";import{T as Ve,a as Oe,b as ye,c as F,d as Ue,e as B}from"../packem_shared/table-BMsuYFhk.js";import{u as Be}from"../packem_shared/use-admin-query-DV9xmFl8.js";import{u as Fe}from"../packem_shared/use-async-submit-C9xXjXWX.js";import{u as ze}from"../packem_shared/use-shard-key-BsP3o5wT.js";import{useT as ve}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as ie}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as He,f as re,c as de,d as Ie,b as je}from"../packem_shared/internal-7bgd8inO.js";import{jsx as s,jsxs as w,Fragment as De}from"react/jsx-runtime";const ge="none",qe=["all","open","resolved","ignored"],Ge=["critical","high","medium","low"],Pe=de(ie.resolveIssue),We=de(ie.ignoreIssue),Se=de(ie.assignIssue),Ye=de(ie.setIssueSeverity),Qe=de(ie.explainIssue),Xe=n=>Array.isArray(n?.issues)?n.issues:[],Je=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:h,issue:t,shardKey:E}=n,i=Ne(),r=ve(),[a,o]=ne(void 0),{busy:R,error:A,run:L}=Fe();let C;e[0]!==i||e[1]!==t||e[2]!==L||e[3]!==E?(C=()=>{o(void 0),L(async()=>{const f={culprit:t.culprit,sampleMessage:t.sampleMessage,title:t.title},I=await i.query(Qe,f,Ie(E));o(I)})},e[0]=i,e[1]=t,e[2]=L,e[3]=E,e[4]=C):C=e[4];const K=C;if(!h)return null;let T;if(e[5]!==t.sampleMessage){const f=we(t.sampleMessage);T=f===void 0?void 0:Ee(f.body),e[5]=t.sampleMessage,e[6]=T}else T=e[6];const _=T,M=`issues-detail-${t.hash}`;let d;e[7]!==t.sampleMessage?(d=s("p",{className:"whitespace-pre-wrap font-mono text-xs text-muted-foreground",children:t.sampleMessage}),e[7]=t.sampleMessage,e[8]=d):d=e[8];let g;e[9]!==r?(g=r("Suggested fix"),e[9]=r,e[10]=g):g=e[10];let $;e[11]!==g?($=s("div",{className:"text-xs font-medium text-muted-foreground",children:g}),e[11]=g,e[12]=$):$=e[12];let x;e[13]!==_||e[14]!==t.hash||e[15]!==r?(x=_===void 0?s("p",{className:"mt-1 text-sm text-muted-foreground","data-testid":`issues-hint-empty-${t.hash}`,children:r("No known fix for this error yet.")}):s("p",{className:"mt-1 whitespace-pre-wrap text-sm","data-testid":`issues-hint-${t.hash}`,children:_}),e[13]=_,e[14]=t.hash,e[15]=r,e[16]=x):x=e[16];let y;e[17]!==$||e[18]!==x?(y=w("div",{children:[$,x]}),e[17]=$,e[18]=x,e[19]=y):y=e[19];const S=`issues-explain-${t.hash}`;let N;e[20]!==R||e[21]!==r?(N=r(R?"Explaining…":"Explain in plain language"),e[20]=R,e[21]=r,e[22]=N):N=e[22];let u;e[23]!==R||e[24]!==K||e[25]!==N||e[26]!==S?(u=s("div",{children:s(oe,{"data-testid":S,disabled:R,onClick:K,size:"sm",type:"button",variant:"outline",children:N})}),e[23]=R,e[24]=K,e[25]=N,e[26]=S,e[27]=u):u=e[27];let p;e[28]!==A||e[29]!==t.hash?(p=A!==null&&s("p",{className:"text-xs text-destructive","data-testid":`issues-explain-error-${t.hash}`,role:"alert",children:A}),e[28]=A,e[29]=t.hash,e[30]=p):p=e[30];let m;e[31]!==a||e[32]!==t.hash||e[33]!==r?(m=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"?r("No AI binding is configured. Wire an AI binding to enable plain-language explanations — the suggested fix above is always available."):r("The AI model could not explain this error right now. The suggested fix above still applies.")}):w("div",{"data-testid":`issues-explanation-${t.hash}`,children:[s("div",{className:"text-xs font-medium text-muted-foreground",children:r("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:r("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:r("Generated by {model}",{model:a.model})})]})),e[31]=a,e[32]=t.hash,e[33]=r,e[34]=m):m=e[34];let c;e[35]!==u||e[36]!==p||e[37]!==m||e[38]!==d||e[39]!==y?(c=s(B,{className:"bg-muted/30",colSpan:7,children:w("div",{className:"flex flex-col gap-3 py-1",children:[d,y,u,p,m]})}),e[35]=u,e[36]=p,e[37]=m,e[38]=d,e[39]=y,e[40]=c):c=e[40];let b;return e[41]!==c||e[42]!==M?(b=s(ye,{"data-testid":M,children:c}),e[41]=c,e[42]=M,e[43]=b):b=e[43],b},tt=n=>{const e=xe(119),{busy:h,issue:t,rowError:E,runTriage:i,shardKey:r}=n,a=ve(),[o,R]=ne(!1);let A;e[0]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{R(st)},e[0]=A):A=e[0];const L=A;let C;e[1]!==t.hash||e[2]!==i?(C=ae=>{const he=ae===null||ae===ge?null:ae;re(i(t.hash,Ye,{severity:he}))},e[1]=t.hash,e[2]=i,e[3]=C):C=e[3];const K=C;let T;e[4]!==t.hash||e[5]!==i?(T=ae=>{if(ae.key!=="Enter")return;const he=ae.currentTarget.value.trim();re(i(t.hash,Se,{assignee:he===""?null:he}))},e[4]=t.hash,e[5]=i,e[6]=T):T=e[6];const _=T,M=`issues-row-${t.hash}`;let d;e[7]!==a?(d=a("Toggle issue details"),e[7]=a,e[8]=d):d=e[8];const g=`issues-toggle-${t.hash}`,$=`mt-1 size-3 shrink-0 text-muted-foreground transition-transform ${o?"rotate-90":""}`;let x;e[9]===Symbol.for("react.memo_cache_sentinel")?(x=s("path",{d:"m9 6 6 6-6 6"}),e[9]=x):x=e[9];let y;e[10]!==$?(y=s("svg",{"aria-hidden":"true",className:$,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:x}),e[10]=$,e[11]=y):y=e[11];let S;e[12]!==t.title?(S=s("span",{className:"block truncate font-medium",title:t.title,children:t.title}),e[12]=t.title,e[13]=S):S=e[13];let N;e[14]!==t.culprit?(N=s("span",{className:"block truncate font-mono text-xs text-muted-foreground",title:t.culprit,children:t.culprit}),e[14]=t.culprit,e[15]=N):N=e[15];let u;e[16]!==S||e[17]!==N?(u=w("span",{className:"min-w-0",children:[S,N]}),e[16]=S,e[17]=N,e[18]=u):u=e[18];let p;e[19]!==o||e[20]!==u||e[21]!==d||e[22]!==g||e[23]!==y?(p=w("button",{"aria-expanded":o,"aria-label":d,className:"flex w-full items-start gap-2 text-left","data-testid":g,onClick:L,type:"button",children:[y,u]}),e[19]=o,e[20]=u,e[21]=d,e[22]=g,e[23]=y,e[24]=p):p=e[24];let m;e[25]!==t.hash||e[26]!==E?(m=E!==void 0&&s("p",{className:"mt-1 text-xs text-destructive","data-testid":`issues-action-error-${t.hash}`,role:"alert",children:E}),e[25]=t.hash,e[26]=E,e[27]=m):m=e[27];let c;e[28]!==p||e[29]!==m?(c=w(B,{className:"max-w-80",children:[p,m]}),e[28]=p,e[29]=m,e[30]=c):c=e[30];const b=`issues-status-${t.hash}`;let f;e[31]!==t.status?(f=Je(t.status),e[31]=t.status,e[32]=f):f=e[32];let I;e[33]!==t.status||e[34]!==b||e[35]!==f?(I=s(B,{children:s(pe,{"data-testid":b,variant:f,children:t.status})}),e[33]=t.status,e[34]=b,e[35]=f,e[36]=I):I=e[36];const V=t.severity??ge;let l;e[37]!==a?(l=a("Set severity"),e[37]=a,e[38]=l):l=e[38];const le=`issues-severity-${t.hash}`;let O;e[39]!==a?(O=a("—"),e[39]=a,e[40]=O):O=e[40];let v;e[41]!==t.severity||e[42]!==a?(v=t.severity===void 0?s("span",{className:"text-muted-foreground",children:a("—")}):s(pe,{variant:Ze(t.severity),children:t.severity}),e[41]=t.severity,e[42]=a,e[43]=v):v=e[43];let k;e[44]!==O||e[45]!==v?(k=s(Me,{placeholder:O,children:v}),e[44]=O,e[45]=v,e[46]=k):k=e[46];let U;e[47]!==l||e[48]!==le||e[49]!==k?(U=s(Re,{"aria-label":l,className:"h-7 w-[110px]","data-testid":le,children:k}),e[47]=l,e[48]=le,e[49]=k,e[50]=U):U=e[50];let z;e[51]===Symbol.for("react.memo_cache_sentinel")?(z=Ge.map(at),e[51]=z):z=e[51];let H;e[52]!==a?(H=a("Clear"),e[52]=a,e[53]=H):H=e[53];let j;e[54]!==H?(j=w(Ke,{children:[z,s(be,{value:ge,children:H})]}),e[54]=H,e[55]=j):j=e[55];let D;e[56]!==h||e[57]!==K||e[58]!==V||e[59]!==U||e[60]!==j?(D=s(B,{children:w(Le,{disabled:h,onValueChange:K,value:V,children:[U,j]})}),e[56]=h,e[57]=K,e[58]=V,e[59]=U,e[60]=j,e[61]=D):D=e[61];let q;e[62]!==a?(q=a("Assignee"),e[62]=a,e[63]=q):q=e[63];const ue=`issues-assignee-${t.hash}`,me=t.assignee??"",fe=t.assignee??"";let G;e[64]!==a?(G=a("Unassigned"),e[64]=a,e[65]=G):G=e[65];let P;e[66]!==h||e[67]!==_||e[68]!==q||e[69]!==ue||e[70]!==me||e[71]!==fe||e[72]!==G?(P=s(B,{children:s(ke,{"aria-label":q,className:"h-7 w-32","data-testid":ue,defaultValue:me,disabled:h,onKeyDown:_,placeholder:G},fe)}),e[66]=h,e[67]=_,e[68]=q,e[69]=ue,e[70]=me,e[71]=fe,e[72]=G,e[73]=P):P=e[73];let W;e[74]!==t.count?(W=s(B,{className:"text-right",children:s(pe,{variant:"secondary",children:t.count})}),e[74]=t.count,e[75]=W):W=e[75];let Y;e[76]!==t.lastSeen?(Y=He(t.lastSeen),e[76]=t.lastSeen,e[77]=Y):Y=e[77];let Q;e[78]!==Y?(Q=s(B,{className:"text-xs tabular-nums text-muted-foreground",children:Y}),e[78]=Y,e[79]=Q):Q=e[79];let X;e[80]!==h||e[81]!==t.hash||e[82]!==t.status||e[83]!==i||e[84]!==a?(X=t.status!=="resolved"&&s(oe,{"data-testid":`issues-resolve-${t.hash}`,disabled:h,onClick:()=>{re(i(t.hash,Pe,{}))},size:"xs",variant:"outline",children:a("Resolve")}),e[80]=h,e[81]=t.hash,e[82]=t.status,e[83]=i,e[84]=a,e[85]=X):X=e[85];let J;e[86]!==h||e[87]!==t.hash||e[88]!==t.status||e[89]!==i||e[90]!==a?(J=t.status!=="ignored"&&s(oe,{"data-testid":`issues-ignore-${t.hash}`,disabled:h,onClick:()=>{re(i(t.hash,We,{}))},size:"xs",variant:"ghost",children:a("Ignore")}),e[86]=h,e[87]=t.hash,e[88]=t.status,e[89]=i,e[90]=a,e[91]=J):J=e[91];let Z;e[92]!==h||e[93]!==t.assignee||e[94]!==t.hash||e[95]!==t.status||e[96]!==i||e[97]!==a?(Z=t.status!=="open"&&s(oe,{"data-testid":`issues-reopen-${t.hash}`,disabled:h,onClick:()=>{re(i(t.hash,Se,{assignee:t.assignee??null}))},size:"xs",variant:"ghost",children:a("Reopen")}),e[92]=h,e[93]=t.assignee,e[94]=t.hash,e[95]=t.status,e[96]=i,e[97]=a,e[98]=Z):Z=e[98];let ee;e[99]!==X||e[100]!==J||e[101]!==Z?(ee=s(B,{className:"text-right",children:w("div",{className:"flex justify-end gap-1",children:[X,J,Z]})}),e[99]=X,e[100]=J,e[101]=Z,e[102]=ee):ee=e[102];let te;e[103]!==c||e[104]!==I||e[105]!==D||e[106]!==P||e[107]!==W||e[108]!==Q||e[109]!==M||e[110]!==ee?(te=w(ye,{"data-testid":M,children:[c,I,D,P,W,Q,ee]}),e[103]=c,e[104]=I,e[105]=D,e[106]=P,e[107]=W,e[108]=Q,e[109]=M,e[110]=ee,e[111]=te):te=e[111];let se;e[112]!==o||e[113]!==t||e[114]!==r?(se=s(et,{expanded:o,issue:t,shardKey:r},t.sampleMessage),e[112]=o,e[113]=t,e[114]=r,e[115]=se):se=e[115];let ce;return e[116]!==te||e[117]!==se?(ce=w(De,{children:[te,se]}),e[116]=te,e[117]=se,e[118]=ce):ce=e[118],ce},Tt=n=>{const e=xe(38),{initialShardKey:h}=n,t=ve(),E=Ne(),{queryShardKey:i,setShardKey:r,shardKey:a}=ze(h),[o,R]=ne("all"),[A,L]=ne(it),[C,K]=ne(lt);let T;e[0]!==o?(T=o==="all"?{}:{status:o},e[0]=o,e[1]=T):T=e[1];let _;e[2]!==i?(_={live:!0,shardKey:i},e[2]=i,e[3]=_):_=e[3];const{data:M,error:d,liveError:g}=Be(ie.getIssues,T,_),$=M!==void 0;let x;if(e[4]!==C||e[5]!==A||e[6]!==E||e[7]!==M||e[8]!==d||e[9]!==g||e[10]!==$||e[11]!==i||e[12]!==r||e[13]!==a||e[14]!==o||e[15]!==t){const y=Xe(M);let S;e[17]!==E||e[18]!==i?(S=async(l,le,O)=>{K(v=>{if(!v.has(l))return v;const k=new Map(v);return k.delete(l),k}),L(v=>new Set(v).add(l));try{await E.query(le,{...O,hash:l},Ie(i))}catch(v){const U=je(v);K(z=>new Map(z).set(l,U))}L(v=>{const k=new Set(v);return k.delete(l),k})},e[17]=E,e[18]=i,e[19]=S):S=e[19];const N=S;let u;e[20]!==t?(u=l=>t(l==="all"?"All":l==="open"?"Open":l==="resolved"?"Resolved":"Ignored"),e[20]=t,e[21]=u):u=e[21];const p=u;let m;e[22]!==d?(m=d!==null&&s("p",{className:"text-sm text-destructive","data-testid":"issues-error",role:"alert",children:d}),e[22]=d,e[23]=m):m=e[23];let c;e[24]!==r||e[25]!==a?(c=s($e,{onChange:r,testId:"issues-shard-input",value:a}),e[24]=r,e[25]=a,e[26]=c):c=e[26];let b;e[27]!==g?(b=s(Te,{message:g,prefix:"issues"}),e[27]=g,e[28]=b):b=e[28];let f;e[29]!==o||e[30]!==p?(f=qe.map(l=>s(oe,{"data-active":o===l?"":void 0,"data-testid":`issues-filter-${l}`,onClick:()=>{R(l)},size:"xs",variant:o===l?"default":"outline",children:p(l)},l)),e[29]=o,e[30]=p,e[31]=f):f=e[31];let I;e[32]!==f?(I=s("div",{className:"ms-auto flex items-center gap-1","data-testid":"issues-status-filter",role:"group",children:f}),e[32]=f,e[33]=I):I=e[33];let V;e[34]!==I||e[35]!==c||e[36]!==b?(V=w("div",{className:"flex flex-wrap items-center gap-2",children:[c,b,I]}),e[34]=I,e[35]=c,e[36]=b,e[37]=V):V=e[37],x=w("div",{className:"flex flex-col gap-6","data-testid":"lunora-issues-panel",children:[m,V,$&&y.length===0?s(_e,{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:w(Ve,{"data-testid":"issues-table",children:[s(Oe,{children:w(ye,{children:[s(F,{children:t("Issue")}),s(F,{children:t("Status")}),s(F,{children:t("Severity")}),s(F,{children:t("Assignee")}),s(F,{className:"text-right",children:t("Events")}),s(F,{children:t("Last seen")}),s(F,{className:"text-right",children:t("Actions")})]})}),s(Ue,{children:y.map(l=>s(tt,{busy:A.has(l.hash),issue:l,rowError:C.get(l.hash),runTriage:N,shardKey:i},l.hash))})]})})})]}),e[4]=C,e[5]=A,e[6]=E,e[7]=M,e[8]=d,e[9]=g,e[10]=$,e[11]=i,e[12]=r,e[13]=a,e[14]=o,e[15]=t,e[16]=x}else x=e[16];return x};function st(n){return!n}function at(n){return s(be,{value:n,children:n},n)}function it(){return new Set}function lt(){return new Map}export{Tt as default};