@lunora/studio 1.0.0-alpha.85 → 1.0.0-alpha.87

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 (145) hide show
  1. package/dist/index.d.ts +18 -3
  2. package/dist/index.js +1 -1
  3. package/dist/mount.js +1 -1
  4. package/dist/packem_chunks/AdvisorHealthPanel.js +1 -1
  5. package/dist/packem_chunks/ApiTab.js +1 -1
  6. package/dist/packem_chunks/AuditPanel.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 +6 -6
  22. package/dist/packem_chunks/TableEditor.js +1 -1
  23. package/dist/packem_chunks/agents-panel.js +1 -1
  24. package/dist/packem_chunks/auth-audit-panel.js +1 -1
  25. package/dist/packem_chunks/containers-panel.js +1 -1
  26. package/dist/packem_chunks/dashboards-panel.js +1 -1
  27. package/dist/packem_chunks/fanout-panel.js +1 -1
  28. package/dist/packem_chunks/flags-panel.js +1 -1
  29. package/dist/packem_chunks/issues-panel.js +1 -1
  30. package/dist/packem_chunks/kv-browser.js +1 -1
  31. package/dist/packem_chunks/migrations-route.js +1 -1
  32. package/dist/packem_chunks/payments-panel.js +1 -1
  33. package/dist/packem_chunks/permissions-panel.js +1 -1
  34. package/dist/packem_chunks/queues-panel.js +1 -1
  35. package/dist/packem_chunks/rls-panel.js +1 -1
  36. package/dist/packem_chunks/storage-rules-panel.js +1 -1
  37. package/dist/packem_chunks/subscriptions-panel.js +1 -1
  38. package/dist/packem_chunks/traces-panel.js +1 -1
  39. package/dist/packem_chunks/users-panel.js +1 -1
  40. package/dist/packem_chunks/workflows-panel.js +1 -1
  41. package/dist/packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js +1 -0
  42. package/dist/packem_shared/{ApiDocsPanel-fYS9NiLg.js → ApiDocsPanel-DLMeLZ5-.js} +1 -1
  43. package/dist/packem_shared/DataBrowser-CZZ_WkJ-.js +1 -0
  44. package/dist/packem_shared/{GlobalDataBrowser-CSttudUx.js → GlobalDataBrowser-DpkjHfDg.js} +1 -1
  45. package/dist/packem_shared/{HomePanel-BYsfMhKh.js → HomePanel-3baDsDBU.js} +1 -1
  46. package/dist/packem_shared/MigrationsPanel-dygzHUvg.js +1 -0
  47. package/dist/packem_shared/{Studio-Ba9x0dG_.js → Studio-forQt-PC.js} +1 -1
  48. package/dist/packem_shared/{StudioApp-B_PRdg4h.js → StudioApp-B1AWsBzi.js} +1 -1
  49. package/dist/packem_shared/{home-panel-B60-5YfI.js → home-panel-CeeqqV0z.js} +1 -1
  50. package/dist/packem_shared/{studio-CPuoAmjh.js → studio-BtC7WPbz.js} +1 -1
  51. package/dist/packem_shared/table-list-sidebar-D9Bd4qgi.js +1 -0
  52. package/dist/packem_shared/use-shard-key-B2JtNa5m.js +1 -0
  53. package/dist/packem_shared/{use-sql-assistant-BLG9unQN.js → use-sql-assistant-C6dl2_Ty.js} +1 -1
  54. package/dist/packem_shared/useDebounced-CU-uftxO.js +1 -0
  55. package/dist/standalone/chunk-2VWWXVWK.js +1 -0
  56. package/dist/standalone/chunk-3CWGJYBB.js +1 -0
  57. package/dist/standalone/{chunk-52OYJHM7.js → chunk-4JIOFDMR.js} +1 -1
  58. package/dist/standalone/{chunk-MN64D74P.js → chunk-4LCY5XUR.js} +1 -1
  59. package/dist/standalone/{chunk-JE3WK77V.js → chunk-5KRD6F67.js} +1 -1
  60. package/dist/standalone/{chunk-RC3H4OP3.js → chunk-5X4OZ7OD.js} +1 -1
  61. package/dist/standalone/{chunk-TO45V3L6.js → chunk-6MGI5IN6.js} +1 -1
  62. package/dist/standalone/{chunk-HJR42BJY.js → chunk-7DNDRUMZ.js} +1 -1
  63. package/dist/standalone/chunk-7FO57AZY.js +1 -0
  64. package/dist/standalone/{chunk-YNBIW2GN.js → chunk-B5S6GSUC.js} +1 -1
  65. package/dist/standalone/{chunk-QZ6TCNWR.js → chunk-B5UFGO4E.js} +1 -1
  66. package/dist/standalone/{chunk-RFBU5RZI.js → chunk-BDNDSBYM.js} +1 -1
  67. package/dist/standalone/{chunk-QS4IFAFJ.js → chunk-CLNB7I3O.js} +1 -1
  68. package/dist/standalone/{chunk-QSFKPGK4.js → chunk-D3JTCLSF.js} +1 -1
  69. package/dist/standalone/chunk-DABW4OOI.js +1 -0
  70. package/dist/standalone/{chunk-SPT3KPV7.js → chunk-EAIUBZA5.js} +1 -1
  71. package/dist/standalone/{chunk-FUBR2PAD.js → chunk-EJ2CHD4G.js} +1 -1
  72. package/dist/standalone/chunk-EVTCXQ5D.js +1 -0
  73. package/dist/standalone/{chunk-OLM62NLS.js → chunk-EWDLYYJM.js} +1 -1
  74. package/dist/standalone/{chunk-ZOX6X2DL.js → chunk-F7NVC7YK.js} +1 -1
  75. package/dist/standalone/chunk-FURI47Z2.js +1 -0
  76. package/dist/standalone/chunk-FW75RYZU.js +1 -0
  77. package/dist/standalone/chunk-GE5WTIWX.js +1 -0
  78. package/dist/standalone/{chunk-BAAU4OTI.js → chunk-GZS3ORGS.js} +1 -1
  79. package/dist/standalone/chunk-HYCMT2V5.js +1 -0
  80. package/dist/standalone/{chunk-5YADKLAQ.js → chunk-IAKPXGTQ.js} +1 -1
  81. package/dist/standalone/chunk-IVCIG5J7.js +4 -0
  82. package/dist/standalone/chunk-KJIBL5D4.js +1 -0
  83. package/dist/standalone/chunk-L4RW5BFD.js +1 -0
  84. package/dist/standalone/{chunk-PWTURL56.js → chunk-LYRAWNV7.js} +1 -1
  85. package/dist/standalone/chunk-MIFLRBVS.js +11 -0
  86. package/dist/standalone/{chunk-OOL3FV6A.js → chunk-MV4A2PAK.js} +1 -1
  87. package/dist/standalone/{chunk-347H2BQO.js → chunk-NBUBAW3V.js} +1 -1
  88. package/dist/standalone/{chunk-232MBXB2.js → chunk-NCWUTRZB.js} +1 -1
  89. package/dist/standalone/{chunk-D67BVBQW.js → chunk-NMLCYY4H.js} +1 -1
  90. package/dist/standalone/{chunk-MDHUWMFD.js → chunk-OOWHAURL.js} +1 -1
  91. package/dist/standalone/{chunk-UOQ24BAY.js → chunk-ORVR33FM.js} +1 -1
  92. package/dist/standalone/{chunk-7AG3T4DK.js → chunk-OUCGTB3Y.js} +2 -2
  93. package/dist/standalone/chunk-PDMZITZZ.js +1 -0
  94. package/dist/standalone/{chunk-VORDESEQ.js → chunk-PNAVAJAF.js} +1 -1
  95. package/dist/standalone/{chunk-LVJ5IHEU.js → chunk-QJTGO4JG.js} +1 -1
  96. package/dist/standalone/{chunk-EDOMDMVI.js → chunk-QP7IQOKF.js} +1 -1
  97. package/dist/standalone/chunk-QXDMHM2V.js +1 -0
  98. package/dist/standalone/{chunk-VKEJTZY7.js → chunk-S2CXYDNT.js} +1 -1
  99. package/dist/standalone/{chunk-AQKXMWNF.js → chunk-S3DWUXGY.js} +1 -1
  100. package/dist/standalone/{chunk-YSMJN36P.js → chunk-SJZQPIZB.js} +1 -1
  101. package/dist/standalone/{chunk-ETZYJL7Z.js → chunk-SMEW3ZTU.js} +1 -1
  102. package/dist/standalone/chunk-SNK7TOOO.js +6 -0
  103. package/dist/standalone/{chunk-QI25LTPH.js → chunk-T2Q7I3V2.js} +1 -1
  104. package/dist/standalone/{chunk-ESKVOZLC.js → chunk-T3CGXSXO.js} +1 -1
  105. package/dist/standalone/{chunk-YGKR536O.js → chunk-TS6346VY.js} +1 -1
  106. package/dist/standalone/{chunk-ENBTOX7N.js → chunk-TVGKSIIW.js} +1 -1
  107. package/dist/standalone/{chunk-U5IIRHZ6.js → chunk-UNVK2VZP.js} +1 -1
  108. package/dist/standalone/{chunk-U44CWN7H.js → chunk-UR3X4K4T.js} +1 -1
  109. package/dist/standalone/chunk-VDW32UET.js +1 -0
  110. package/dist/standalone/chunk-VQK34A2H.js +1 -0
  111. package/dist/standalone/{chunk-MBVSXVTV.js → chunk-WPUINKEO.js} +1 -1
  112. package/dist/standalone/chunk-XNGYYOLS.js +14 -0
  113. package/dist/standalone/{chunk-2SC3EG5Y.js → chunk-XR7RBXKA.js} +1 -1
  114. package/dist/standalone/{chunk-KNHWIHC7.js → chunk-XZN645UJ.js} +1 -1
  115. package/dist/standalone/chunk-YFJXQUPW.js +1 -0
  116. package/dist/standalone/chunk-YKAO3JNJ.js +1 -0
  117. package/dist/standalone/{chunk-AHVDZWB3.js → chunk-YRYEZHOJ.js} +1 -1
  118. package/dist/standalone/{chunk-TIR6CWHO.js → chunk-ZCFDQW4U.js} +1 -1
  119. package/dist/standalone/studio.js +1 -1
  120. package/package.json +6 -6
  121. package/dist/packem_shared/ADMIN_FUNCTIONS-CZESgd10.js +0 -1
  122. package/dist/packem_shared/DataBrowser-C4J4gVUu.js +0 -1
  123. package/dist/packem_shared/MigrationsPanel-2JbQ2HwG.js +0 -1
  124. package/dist/packem_shared/table-list-sidebar-BRv3hTLX.js +0 -1
  125. package/dist/packem_shared/useDebounced-Ihdiid_k.js +0 -1
  126. package/dist/standalone/chunk-22LOWEEC.js +0 -1
  127. package/dist/standalone/chunk-2EJADIPC.js +0 -1
  128. package/dist/standalone/chunk-4I2TBTZS.js +0 -1
  129. package/dist/standalone/chunk-6IEBRNDW.js +0 -1
  130. package/dist/standalone/chunk-D3FRQZ4X.js +0 -1
  131. package/dist/standalone/chunk-ERMTJYQF.js +0 -1
  132. package/dist/standalone/chunk-JAT5ZBQK.js +0 -1
  133. package/dist/standalone/chunk-JOFD43OI.js +0 -1
  134. package/dist/standalone/chunk-LFKCLLPT.js +0 -1
  135. package/dist/standalone/chunk-MLULN4R2.js +0 -1
  136. package/dist/standalone/chunk-MUGKOGZG.js +0 -1
  137. package/dist/standalone/chunk-NPKNFZUW.js +0 -6
  138. package/dist/standalone/chunk-OV63HVE4.js +0 -4
  139. package/dist/standalone/chunk-QFJRZR4U.js +0 -1
  140. package/dist/standalone/chunk-QNRAMF4X.js +0 -1
  141. package/dist/standalone/chunk-QNUWWC3N.js +0 -14
  142. package/dist/standalone/chunk-S67SBGB3.js +0 -1
  143. package/dist/standalone/chunk-SHD2IWQI.js +0 -1
  144. package/dist/standalone/chunk-SKFZXESP.js +0 -1
  145. package/dist/standalone/chunk-UBR4KB6K.js +0 -11
@@ -1 +1 @@
1
- import{b as D,c as g,d as P,f as k}from"./chunk-UBR4KB6K.js";import{f as v,g as S,h as T,m as q}from"./chunk-OG4N2XHD.js";import{a as i,e as A,f as $,g as M}from"./chunk-3XIESWL4.js";var I=A(M(),1);var f=A($(),1);var l=i(e=>typeof e=="string"?e===""?void 0:e:typeof e=="number"||typeof e=="boolean"?String(e):void 0,"u"),h=i(e=>e.filter(r=>r!==void 0).join(" "),"d"),Q={deleteRows:i(e=>h([l(e.table),Array.isArray(e.ids)?`${String(e.ids.length)} rows`:void 0]),"deleteRows"),facetColumn:i(e=>h([l(e.table),l(e.column)]),"facetColumn"),lintSql:i(()=>"sql","lintSql"),readTablePage:i(e=>h([l(e.table),Array.isArray(e.filters)&&e.filters.length>0?`${String(e.filters.length)} filters`:void 0,typeof e.search=="string"&&e.search!==""?"search":void 0,typeof e.limit=="number"?`limit ${String(e.limit)}`:void 0]),"readTablePage"),runMigration:i(e=>h([l(e.id),l(e.direction),e.dryRun===!0?"dry-run":void 0]),"runMigration"),runSql:i(e=>typeof e.sql=="string"?`${String(e.sql.length)} chars`:"","runSql"),schemaVersion:i(e=>typeof e.hash=="string"?e.hash.slice(0,8):"","schemaVersion"),writeRow:i(e=>h([l(e.table),"1 row"]),"writeRow")},E="__lunora_admin__:",C=i((e,r)=>{let s=e.startsWith(E)?e.slice(E.length):e,t=Q[s];if(t!==void 0)return t(r);let n=Object.keys(r);return n.length===0?"":n.join(", ")},"N"),L=i(e=>{if(Array.isArray(e))return e.length;if(!(typeof e!="object"||e===null)){for(let r of Object.values(e))if(Array.isArray(r))return r.length}},"K"),w=class{static{i(this,"L")}entries=[];listeners=new Set;nextSeq=1;getSnapshot=i(()=>this.entries,"getSnapshot");subscribe=i(r=>(this.listeners.add(r),()=>{this.listeners.delete(r)}),"subscribe");start(r,s,t){return this.append(r,s,t,"call","pending")}startSubscription(r,s,t){return this.append(r,s,t,"subscription","live")}recordPush(r){if(this.listeners.size===0){let s=this.entries.find(t=>t.seq===r);s!==void 0&&(s.pushes=(s.pushes??0)+1);return}this.patch(r,s=>({...s,pushes:(s.pushes??0)+1}))}failSubscription(r,s){this.patch(r,t=>({...t,error:s,status:"error"}))}endSubscription(r){this.patch(r,s=>s.status==="error"?s:{...s,durationMs:Date.now()-s.startedAt,status:"closed"})}lastErrorSeq(){return this.entries.findLast(r=>r.status==="error")?.seq}settle(r,s){this.patch(r,t=>({...t,durationMs:Date.now()-t.startedAt,...s.error===void 0?{resultCount:L(s.result),status:"ok"}:{error:s.error,status:"error"}}))}clear(){this.entries=[],this.emit()}append(r,s,t,n,a){let o=this.nextSeq;this.nextSeq+=1;let d={functionPath:r,kind:n,seq:o,shardKey:t,startedAt:Date.now(),status:a,summary:C(r,s),...n==="subscription"?{pushes:0}:{}},u=[...this.entries,d];return this.entries=u.length>300?u.slice(u.length-300):u,this.emit(),o}patch(r,s){let t=this.entries.findIndex(n=>n.seq===r);t!==-1&&(this.entries=this.entries.with(t,s(this.entries[t])),this.emit())}emit(){for(let r of this.listeners)r()}},p=new w,_=i((e,r,s)=>["lunora-admin",e,r,s.trim()],"q");function R(e,r,s={}){let{enabled:t=!0,keepPreviousData:n=!1,staleTime:a=0}=s,o=P({enabled:t,queryFn:r,placeholderData:n?D:void 0,queryKey:e,staleTime:a});return{data:o.data,error:o.error?T(o.error):o.error,errorSource:o.error??void 0,isLoading:o.isLoading,liveError:void 0,refetch:i(()=>{q(o.refetch())},"refetch")}}i(R,"M");function V(e,r,s={}){let t=k(),n=g(),{enabled:a=!0,keepPreviousData:o=!1,live:d=!1,shardKey:u="",staleTime:j}=s,m=_(e,r,u),x=R(m,()=>t.query(v(e),r,S(u)),{enabled:a,keepPreviousData:o,staleTime:j??(d?Number.POSITIVE_INFINITY:0)}),[N,y]=(0,f.useState)(void 0),O=JSON.stringify(m);return(0,f.useEffect)(()=>{if(!a||!d)return;y(void 0);let b=p.startSubscription(e,r,u),K=t.subscribe(v(e),r,c=>{p.recordPush(b),y(void 0),n.setQueryData(m,c)},{...S(u),onError:i(c=>{p.failSubscription(b,c.message),y(c.message)},"onError")});return()=>{p.endSubscription(b),K()}},[O,a,d]),{...x,liveError:a&&d?N:void 0}}i(V,"z");var U=i(()=>{let e=(0,I.c)(2),r=g(),s;return e[0]!==r?(s=i((t,n,a)=>{let o=n===void 0?["lunora-admin",t]:_(t,n,a??"");q(r.invalidateQueries({queryKey:o}))},"e"),e[0]=r,e[1]=s):s=e[1],s},"J");export{p as a,R as b,V as c,U as d};
1
+ import{b as D,c as g,d as P,f as k}from"./chunk-MIFLRBVS.js";import{f as v,g as S,h as T,m as q}from"./chunk-OG4N2XHD.js";import{a as i,e as A,f as $,g as M}from"./chunk-3XIESWL4.js";var I=A(M(),1);var f=A($(),1);var l=i(e=>typeof e=="string"?e===""?void 0:e:typeof e=="number"||typeof e=="boolean"?String(e):void 0,"u"),h=i(e=>e.filter(r=>r!==void 0).join(" "),"d"),Q={deleteRows:i(e=>h([l(e.table),Array.isArray(e.ids)?`${String(e.ids.length)} rows`:void 0]),"deleteRows"),facetColumn:i(e=>h([l(e.table),l(e.column)]),"facetColumn"),lintSql:i(()=>"sql","lintSql"),readTablePage:i(e=>h([l(e.table),Array.isArray(e.filters)&&e.filters.length>0?`${String(e.filters.length)} filters`:void 0,typeof e.search=="string"&&e.search!==""?"search":void 0,typeof e.limit=="number"?`limit ${String(e.limit)}`:void 0]),"readTablePage"),runMigration:i(e=>h([l(e.id),l(e.direction),e.dryRun===!0?"dry-run":void 0]),"runMigration"),runSql:i(e=>typeof e.sql=="string"?`${String(e.sql.length)} chars`:"","runSql"),schemaVersion:i(e=>typeof e.hash=="string"?e.hash.slice(0,8):"","schemaVersion"),writeRow:i(e=>h([l(e.table),"1 row"]),"writeRow")},E="__lunora_admin__:",C=i((e,r)=>{let s=e.startsWith(E)?e.slice(E.length):e,t=Q[s];if(t!==void 0)return t(r);let n=Object.keys(r);return n.length===0?"":n.join(", ")},"N"),L=i(e=>{if(Array.isArray(e))return e.length;if(!(typeof e!="object"||e===null)){for(let r of Object.values(e))if(Array.isArray(r))return r.length}},"K"),w=class{static{i(this,"L")}entries=[];listeners=new Set;nextSeq=1;getSnapshot=i(()=>this.entries,"getSnapshot");subscribe=i(r=>(this.listeners.add(r),()=>{this.listeners.delete(r)}),"subscribe");start(r,s,t){return this.append(r,s,t,"call","pending")}startSubscription(r,s,t){return this.append(r,s,t,"subscription","live")}recordPush(r){if(this.listeners.size===0){let s=this.entries.find(t=>t.seq===r);s!==void 0&&(s.pushes=(s.pushes??0)+1);return}this.patch(r,s=>({...s,pushes:(s.pushes??0)+1}))}failSubscription(r,s){this.patch(r,t=>({...t,error:s,status:"error"}))}endSubscription(r){this.patch(r,s=>s.status==="error"?s:{...s,durationMs:Date.now()-s.startedAt,status:"closed"})}lastErrorSeq(){return this.entries.findLast(r=>r.status==="error")?.seq}settle(r,s){this.patch(r,t=>({...t,durationMs:Date.now()-t.startedAt,...s.error===void 0?{resultCount:L(s.result),status:"ok"}:{error:s.error,status:"error"}}))}clear(){this.entries=[],this.emit()}append(r,s,t,n,a){let o=this.nextSeq;this.nextSeq+=1;let d={functionPath:r,kind:n,seq:o,shardKey:t,startedAt:Date.now(),status:a,summary:C(r,s),...n==="subscription"?{pushes:0}:{}},u=[...this.entries,d];return this.entries=u.length>300?u.slice(u.length-300):u,this.emit(),o}patch(r,s){let t=this.entries.findIndex(n=>n.seq===r);t!==-1&&(this.entries=this.entries.with(t,s(this.entries[t])),this.emit())}emit(){for(let r of this.listeners)r()}},p=new w,_=i((e,r,s)=>["lunora-admin",e,r,s.trim()],"q");function R(e,r,s={}){let{enabled:t=!0,keepPreviousData:n=!1,staleTime:a=0}=s,o=P({enabled:t,queryFn:r,placeholderData:n?D:void 0,queryKey:e,staleTime:a});return{data:o.data,error:o.error?T(o.error):o.error,errorSource:o.error??void 0,isLoading:o.isLoading,liveError:void 0,refetch:i(()=>{q(o.refetch())},"refetch")}}i(R,"M");function V(e,r,s={}){let t=k(),n=g(),{enabled:a=!0,keepPreviousData:o=!1,live:d=!1,shardKey:u="",staleTime:j}=s,m=_(e,r,u),x=R(m,()=>t.query(v(e),r,S(u)),{enabled:a,keepPreviousData:o,staleTime:j??(d?Number.POSITIVE_INFINITY:0)}),[N,y]=(0,f.useState)(void 0),O=JSON.stringify(m);return(0,f.useEffect)(()=>{if(!a||!d)return;y(void 0);let b=p.startSubscription(e,r,u),K=t.subscribe(v(e),r,c=>{p.recordPush(b),y(void 0),n.setQueryData(m,c)},{...S(u),onError:i(c=>{p.failSubscription(b,c.message),y(c.message)},"onError")});return()=>{p.endSubscription(b),K()}},[O,a,d]),{...x,liveError:a&&d?N:void 0}}i(V,"z");var U=i(()=>{let e=(0,I.c)(2),r=g(),s;return e[0]!==r?(s=i((t,n,a)=>{let o=n===void 0?["lunora-admin",t]:_(t,n,a??"");q(r.invalidateQueries({queryKey:o}))},"e"),e[0]=r,e[1]=s):s=e[1],s},"J");export{p as a,R as b,V as c,U as d};
@@ -1 +1 @@
1
- import{a as H}from"./chunk-54MMVNPT.js";import{a as G}from"./chunk-QXXIJAD5.js";import{c as ee}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as Z}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{b as E}from"./chunk-YGKR536O.js";import{f as _}from"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as W}from"./chunk-XQCVZAGU.js";import{a as K,b as V,c as z,d as M,e as u,f}from"./chunk-MIQTKZAR.js";import{a as B,e as D}from"./chunk-UZERI5YC.js";import{d as A,h as O,m as T,q as X}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as c,e as R,f as oe,g as re,h as ae}from"./chunk-3XIESWL4.js";var U=R(re(),1),Y=R(oe(),1);var t=R(ae(),1);var se=R(re(),1);var Q=R(oe(),1);var h=R(ae(),1);var ie=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","Q"),le=c(a=>a.toSorted((e,i)=>e.scheduledFor-i.scheduledFor),"A"),ce=c((a,e,i)=>e!==void 0?e:i===void 0?d=>a.cancelScheduledJob(d):void 0,"U"),de=c(a=>{let e=(0,se.c)(16),{cancelJob:i,loadJobs:d}=a===void 0?{}:a,p=_(),r=A(),l=d===void 0,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-scheduled-jobs"],e[0]=o):o=e[0];let N=E(o,async()=>{let g=await(d??(()=>p.listScheduledJobs()))();return le(g)}),[b,n]=(0,Q.useState)(void 0),[s,m]=(0,Q.useState)(void 0),k,w;e[1]!==p||e[2]!==l?(k=c(()=>{if(l)return p.subscribeScheduledJobs(g=>{m(void 0),n(le(g))})},"v"),w=[l,p],e[1]=p,e[2]=l,e[3]=k,e[4]=w):(k=e[3],w=e[4]),(0,Q.useEffect)(k,w);let x;e[5]!==N?(x=c(()=>{N.refetch()},"j"),e[5]=N,e[6]=x):x=e[6],H(x,!l);let J=ce(p,i,d),v=b??N.data,j=s??N.error,q=c(async g=>{if(J!==void 0){m(void 0);try{await J(g),l||N.refetch()}catch(P){m(O(P))}}},"k"),I="flex flex-col gap-3",F="lunora-scheduled-jobs",C;e[7]!==j?(C=j!==null&&(0,h.jsx)("p",{className:"text-sm text-destructive","data-testid":"sj-error",role:"alert",children:j}),e[7]=j,e[8]=C):C=e[8];let S;e[9]!==v?.length||e[10]!==r?(S=v?.length===0&&(0,h.jsx)(W,{description:r("Jobs queued with runAfter / runAt will appear here."),icon:(0,h.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,h.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,h.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"sj-empty",title:r("No scheduled jobs.")}),e[9]=v?.length,e[10]=r,e[11]=S):S=e[11];let $=v!==void 0&&v.length>0&&(0,h.jsx)(B,{className:"overflow-hidden py-0",children:(0,h.jsx)(D,{className:"px-0",children:(0,h.jsxs)(K,{"data-testid":"sj-table",children:[(0,h.jsx)(V,{children:(0,h.jsxs)(M,{children:[(0,h.jsx)(u,{children:r("function")}),(0,h.jsx)(u,{children:r("scheduled for")}),(0,h.jsx)(u,{children:r("pool")}),(0,h.jsx)(u,{children:r("attempts")}),(0,h.jsx)(u,{children:r("shard")}),(0,h.jsx)(u,{children:r("id")}),J!==void 0&&(0,h.jsx)(u,{"aria-label":r("Actions")})]})}),(0,h.jsx)(z,{children:v.map(g=>(0,h.jsxs)(M,{"data-testid":`sj-row-${g.id}`,children:[(0,h.jsx)(f,{className:"font-mono text-xs",children:g.functionPath}),(0,h.jsx)(f,{className:"text-muted-foreground tabular-nums",children:ie(g.scheduledFor)}),(0,h.jsx)(f,{className:"font-mono text-xs",children:g.pool??""}),(0,h.jsx)(f,{className:"tabular-nums",children:g.attempts??0}),(0,h.jsx)(f,{children:g.shardKey??""}),(0,h.jsx)(f,{className:"font-mono text-xs",children:g.id}),J!==void 0&&(0,h.jsx)(f,{className:"text-right",children:(0,h.jsx)(G,{confirmLabel:r("Cancel job?"),onConfirm:c(()=>{T(q(g.id))},"onConfirm"),testId:`sj-cancel-${g.id}`,children:r("Cancel")})})]},g.id))})]})})}),y;return e[12]!==$||e[13]!==C||e[14]!==S?(y=(0,h.jsxs)("div",{className:I,"data-testid":F,children:[C,S,$]}),e[12]=$,e[13]=C,e[14]=S,e[15]=y):y=e[15],y},"me");var he={kind:"idle"},me=c((a,e,i)=>i!==void 0?i:e===void 0?d=>a.runCronJob(d):void 0,"oe"),ue=c(({loadCronJobs:a,runCronJob:e}={})=>{let i=_(),d=A(),[p,r]=(0,Y.useState)({}),l=E(["lunora-cron-jobs",a?"custom":"default"],()=>(a??(()=>i.getCronJobs()))()),{data:o,error:N}=l,b=me(i,a,e),n=c(async s=>{if(b!==void 0){r(m=>({...m,[s]:{kind:"running"}}));try{await b(s),r(m=>({...m,[s]:{kind:"ok"}})),l.refetch()}catch(m){r(k=>({...k,[s]:{kind:"error",message:O(m)}}))}}},"i");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[N!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:N}),o?.length===0&&(0,t.jsx)(W,{description:d("Triggers declared with the cronJobs() builder appear here."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,t.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:d("No cron triggers.")}),o!==void 0&&o.length>0&&(0,t.jsx)(B,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"cron-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(u,{children:d("name")}),(0,t.jsx)(u,{children:d("schedule")}),(0,t.jsx)(u,{children:d("target")}),(0,t.jsx)(u,{children:d("shard")}),b!==void 0&&(0,t.jsx)(u,{"aria-label":d("Actions")})]})}),(0,t.jsx)(z,{children:o.map(s=>{let m=p[s.name]??he;return(0,t.jsxs)(M,{"data-testid":`cron-row-${s.name}`,children:[(0,t.jsx)(f,{children:s.name}),(0,t.jsx)(f,{className:"font-mono text-xs tabular-nums",children:s.cron}),(0,t.jsx)(f,{children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[s.workflow===void 0?(0,t.jsx)(Z,{variant:"outline",children:d("function")}):(0,t.jsx)(Z,{variant:"secondary",children:d("workflow")}),(0,t.jsx)("span",{className:"font-mono text-xs",children:s.workflow??s.functionPath})]})}),(0,t.jsx)(f,{children:s.shardKey??""}),b!==void 0&&(0,t.jsx)(f,{className:"text-right",children:(0,t.jsxs)("span",{className:"flex items-center justify-end gap-2",children:[m.kind==="ok"&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${s.name}`,children:d("ran")}),m.kind==="error"&&(0,t.jsx)("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${s.name}`,role:"alert",children:m.message}),(0,t.jsx)(G,{confirmLabel:d("Run now?"),disabled:m.kind==="running",onConfirm:c(()=>{T(n(s.name))},"onConfirm"),testId:`cron-run-${s.name}`,children:m.kind==="running"?d("Running\u2026"):d("Run now")})]})})]},`${s.cron}:${s.name}`)})})]})})})]})},"le"),fe=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","re"),pe=c(a=>{let e=(0,U.c)(34),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadJobs:d,removeJob:p,retryJob:r}=i,l=_(),o=A(),N;e[2]===Symbol.for("react.memo_cache_sentinel")?(N=["lunora-dead-jobs"],e[2]=N):N=e[2];let b;e[3]!==l||e[4]!==d?(b=c(async()=>(await(d??(()=>l.listDeadJobs()))()).toSorted(ve),"h"),e[3]=l,e[4]=d,e[5]=b):b=e[5];let n=E(N,b),s=n.data,[m,k]=(0,Y.useState)(void 0),w=n.error??m,x=d===void 0,J;e[6]!==l||e[7]!==x||e[8]!==r?(J=r??(x?L=>l.retryDeadJob(L):void 0),e[6]=l,e[7]=x,e[8]=r,e[9]=J):J=e[9];let v=J,j;e[10]!==l||e[11]!==x||e[12]!==p?(j=p??(x?L=>l.removeDeadJob(L):void 0),e[10]=l,e[11]=x,e[12]=p,e[13]=j):j=e[13];let q=j,I;e[14]!==n?(I=c(()=>{n.refetch()},"J"),e[14]=n,e[15]=I):I=e[15],H(I,!0);let F;e[16]!==n?(F=c(async L=>{k(void 0);try{await L,n.refetch()}catch(ne){k(O(ne))}},"j"),e[16]=n,e[17]=F):F=e[17];let C=F,S=v!==void 0||q!==void 0,$;e[18]!==w?($=w!==void 0&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:w}),e[18]=w,e[19]=$):$=e[19];let y;e[20]!==s?.length||e[21]!==o?(y=s?.length===0&&(0,t.jsx)(W,{description:o("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:o("No dead-letter jobs.")}),e[20]=s?.length,e[21]=o,e[22]=y):y=e[22];let g;e[23]!==C||e[24]!==S||e[25]!==s||e[26]!==q||e[27]!==v||e[28]!==o?(g=s!==void 0&&s.length>0&&(0,t.jsx)(B,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"dlq-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(u,{children:o("function")}),(0,t.jsx)(u,{children:o("attempts")}),(0,t.jsx)(u,{children:o("last tried")}),(0,t.jsx)(u,{children:o("pool")}),(0,t.jsx)(u,{children:o("shard")}),(0,t.jsx)(u,{children:o("id")}),S&&(0,t.jsx)(u,{"aria-label":o("Actions")})]})}),(0,t.jsx)(z,{children:s.map(L=>(0,t.jsxs)(M,{"data-testid":`dlq-row-${L.id}`,children:[(0,t.jsx)(f,{className:"font-mono text-xs",children:L.functionPath}),(0,t.jsx)(f,{className:"tabular-nums",children:L.attempts??0}),(0,t.jsx)(f,{className:"text-muted-foreground tabular-nums",children:fe(L.scheduledFor)}),(0,t.jsx)(f,{className:"font-mono text-xs",children:L.pool??""}),(0,t.jsx)(f,{children:L.shardKey??""}),(0,t.jsx)(f,{className:"font-mono text-xs",children:L.id}),S&&(0,t.jsx)(f,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1.5",children:[v!==void 0&&(0,t.jsx)(ee,{"data-testid":`dlq-retry-${L.id}`,onClick:c(()=>{T(C(v(L.id)))},"onClick"),size:"sm",type:"button",variant:"outline",children:o("Retry")}),q!==void 0&&(0,t.jsx)(G,{confirmLabel:o("Drop job?"),onConfirm:c(()=>{T(C(q(L.id)))},"onConfirm"),testId:`dlq-remove-${L.id}`,children:o("Drop")})]})})]},L.id))})]})})}),e[23]=C,e[24]=S,e[25]=s,e[26]=q,e[27]=v,e[28]=o,e[29]=g):g=e[29];let P;return e[30]!==g||e[31]!==$||e[32]!==y?(P=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[$,y,g]}),e[30]=g,e[31]=$,e[32]=y,e[33]=P):P=e[33],P},"ne");function ve(a,e){return(e.attempts??0)-(a.attempts??0)}c(ve,"ae");var te=c(a=>{let e=(0,U.c)(8),{label:i,testId:d,value:p}=a,r;e[0]!==i?(r=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:i}),e[0]=i,e[1]=r):r=e[1];let l;e[2]!==d||e[3]!==p?(l=(0,t.jsx)("span",{className:"text-2xl font-semibold tabular-nums","data-testid":d,children:p}),e[2]=d,e[3]=p,e[4]=l):l=e[4];let o;return e[5]!==r||e[6]!==l?(o=(0,t.jsx)(B,{className:"flex-1 py-0",children:(0,t.jsxs)(D,{className:"flex flex-col gap-1 p-4",children:[r,l]})}),e[5]=r,e[6]=l,e[7]=o):o=e[7],o},"F"),be=c(a=>{let e=(0,U.c)(25),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadStatus:d}=i,p=_(),r=A(),l=d===void 0,o;e[2]!==l?(o=["lunora-scheduler-status",l],e[2]=l,e[3]=o):o=e[3];let N;e[4]!==p||e[5]!==d?(N=c(async()=>{let j=await(d??(()=>p.schedulerStatus()))();return{...j,pools:j.pools.toSorted(xe)}},"k"),e[4]=p,e[5]=d,e[6]=N):N=e[6];let b=E(o,N),{data:n,error:s}=b,m;e[7]!==b?(m=c(()=>{b.refetch()},"s"),e[7]=b,e[8]=m):m=e[8],H(m,!0);let k;e[9]!==s?(k=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:s}),e[9]=s,e[10]=k):k=e[10];let w;e[11]!==n||e[12]!==r?(w=n!==void 0&&(0,t.jsxs)("div",{className:"flex gap-3","data-testid":"pools-totals",children:[(0,t.jsx)(te,{label:r("backlog"),testId:"pools-backlog",value:n.backlog}),(0,t.jsx)(te,{label:r("in flight"),testId:"pools-inflight",value:n.inFlight}),(0,t.jsx)(te,{label:r("pools"),testId:"pools-count",value:n.pools.length})]}),e[11]=n,e[12]=r,e[13]=w):w=e[13];let x;e[14]!==n?.pools.length||e[15]!==r?(x=n?.pools.length===0&&(0,t.jsx)(W,{description:r("Pools created with createWorkpool appear here once they have activity."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:r("No workpools.")}),e[14]=n?.pools.length,e[15]=r,e[16]=x):x=e[16];let J;e[17]!==n||e[18]!==r?(J=n!==void 0&&n.pools.length>0&&(0,t.jsx)(B,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"pools-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(u,{children:r("pool")}),(0,t.jsx)(u,{children:r("queued")}),(0,t.jsx)(u,{children:r("in flight")}),(0,t.jsx)(u,{children:r("max concurrency")})]})}),(0,t.jsx)(z,{children:n.pools.map(ge)})]})})}),e[17]=n,e[18]=r,e[19]=J):J=e[19];let v;return e[20]!==k||e[21]!==w||e[22]!==x||e[23]!==J?(v=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[k,w,x,J]}),e[20]=k,e[21]=w,e[22]=x,e[23]=J,e[24]=v):v=e[24],v},"de");function xe(a,e){return e.queued-a.queued}c(xe,"ie");function ge(a){return(0,t.jsxs)(M,{"data-testid":`pools-row-${a.name}`,children:[(0,t.jsx)(f,{className:"font-mono text-xs",children:a.name}),(0,t.jsx)(f,{className:"tabular-nums",children:a.queued}),(0,t.jsxs)(f,{className:"tabular-nums",children:[a.inFlight," / ",a.maxConcurrency]}),(0,t.jsx)(f,{className:"tabular-nums",children:a.maxConcurrency})]},a.name)}c(ge,"se");var Ne=["jobs","dead","pools","cron"],Ve=c(a=>{let e=(0,U.c)(41),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadCronJobs:d,scheduledCancel:p,scheduledLoad:r}=i,l=A(),[o,N]=(0,Y.useState)("jobs"),b;e[2]!==l?(b=l("Cron triggers"),e[2]=l,e[3]=b):b=e[3];let n;e[4]!==l?(n=l("Dead letter"),e[4]=l,e[5]=n):n=e[5];let s;e[6]!==l?(s=l("Scheduled jobs"),e[6]=l,e[7]=s):s=e[7];let m;e[8]!==l?(m=l("Pools"),e[8]=l,e[9]=m):m=e[9];let k;e[10]!==b||e[11]!==n||e[12]!==s||e[13]!==m?(k={cron:b,dead:n,jobs:s,pools:m},e[10]=b,e[11]=n,e[12]=s,e[13]=m,e[14]=k):k=e[14];let w=k,x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=c(y=>{N(y.currentTarget.dataset.view)},"u"),e[15]=x):x=e[15];let J=x,v;e[16]!==l?(v=l("Schedule view"),e[16]=l,e[17]=v):v=e[17];let j;e[18]!==o||e[19]!==w?(j=Ne.map(y=>(0,t.jsx)(ee,{"aria-selected":o===y,"data-testid":`schedule-view-${y}`,"data-view":y,onClick:J,role:"tab",size:"sm",type:"button",variant:o===y?"default":"outline",children:w[y]},y)),e[18]=o,e[19]=w,e[20]=j):j=e[20];let q;e[21]!==v||e[22]!==j?(q=(0,t.jsx)("div",{"aria-label":v,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:j}),e[21]=v,e[22]=j,e[23]=q):q=e[23];let I;e[24]!==p||e[25]!==r||e[26]!==o?(I=o==="jobs"&&(0,t.jsx)(de,{cancelJob:p,loadJobs:r}),e[24]=p,e[25]=r,e[26]=o,e[27]=I):I=e[27];let F;e[28]!==o?(F=o==="dead"&&(0,t.jsx)(pe,{}),e[28]=o,e[29]=F):F=e[29];let C;e[30]!==o?(C=o==="pools"&&(0,t.jsx)(be,{}),e[30]=o,e[31]=C):C=e[31];let S;e[32]!==d||e[33]!==o?(S=o==="cron"&&(0,t.jsx)(ue,{loadCronJobs:d}),e[32]=d,e[33]=o,e[34]=S):S=e[34];let $;return e[35]!==q||e[36]!==I||e[37]!==F||e[38]!==C||e[39]!==S?($=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[q,I,F,C,S]}),e[35]=q,e[36]=I,e[37]=F,e[38]=C,e[39]=S,e[40]=$):$=e[40],$},"Je");export{Ve as SchedulePanel};
1
+ import{a as H}from"./chunk-54MMVNPT.js";import{a as G}from"./chunk-QXXIJAD5.js";import{c as ee}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as Z}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{b as E}from"./chunk-TS6346VY.js";import{f as _}from"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as W}from"./chunk-XQCVZAGU.js";import{a as K,b as V,c as z,d as M,e as u,f}from"./chunk-MIQTKZAR.js";import{a as B,e as D}from"./chunk-UZERI5YC.js";import{d as A,h as O,m as T,q as X}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as c,e as R,f as oe,g as re,h as ae}from"./chunk-3XIESWL4.js";var U=R(re(),1),Y=R(oe(),1);var t=R(ae(),1);var se=R(re(),1);var Q=R(oe(),1);var h=R(ae(),1);var ie=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","Q"),le=c(a=>a.toSorted((e,i)=>e.scheduledFor-i.scheduledFor),"A"),ce=c((a,e,i)=>e!==void 0?e:i===void 0?d=>a.cancelScheduledJob(d):void 0,"U"),de=c(a=>{let e=(0,se.c)(16),{cancelJob:i,loadJobs:d}=a===void 0?{}:a,p=_(),r=A(),l=d===void 0,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-scheduled-jobs"],e[0]=o):o=e[0];let N=E(o,async()=>{let g=await(d??(()=>p.listScheduledJobs()))();return le(g)}),[b,n]=(0,Q.useState)(void 0),[s,m]=(0,Q.useState)(void 0),k,w;e[1]!==p||e[2]!==l?(k=c(()=>{if(l)return p.subscribeScheduledJobs(g=>{m(void 0),n(le(g))})},"v"),w=[l,p],e[1]=p,e[2]=l,e[3]=k,e[4]=w):(k=e[3],w=e[4]),(0,Q.useEffect)(k,w);let x;e[5]!==N?(x=c(()=>{N.refetch()},"j"),e[5]=N,e[6]=x):x=e[6],H(x,!l);let J=ce(p,i,d),v=b??N.data,j=s??N.error,q=c(async g=>{if(J!==void 0){m(void 0);try{await J(g),l||N.refetch()}catch(P){m(O(P))}}},"k"),I="flex flex-col gap-3",F="lunora-scheduled-jobs",C;e[7]!==j?(C=j!==null&&(0,h.jsx)("p",{className:"text-sm text-destructive","data-testid":"sj-error",role:"alert",children:j}),e[7]=j,e[8]=C):C=e[8];let S;e[9]!==v?.length||e[10]!==r?(S=v?.length===0&&(0,h.jsx)(W,{description:r("Jobs queued with runAfter / runAt will appear here."),icon:(0,h.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,h.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,h.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"sj-empty",title:r("No scheduled jobs.")}),e[9]=v?.length,e[10]=r,e[11]=S):S=e[11];let $=v!==void 0&&v.length>0&&(0,h.jsx)(B,{className:"overflow-hidden py-0",children:(0,h.jsx)(D,{className:"px-0",children:(0,h.jsxs)(K,{"data-testid":"sj-table",children:[(0,h.jsx)(V,{children:(0,h.jsxs)(M,{children:[(0,h.jsx)(u,{children:r("function")}),(0,h.jsx)(u,{children:r("scheduled for")}),(0,h.jsx)(u,{children:r("pool")}),(0,h.jsx)(u,{children:r("attempts")}),(0,h.jsx)(u,{children:r("shard")}),(0,h.jsx)(u,{children:r("id")}),J!==void 0&&(0,h.jsx)(u,{"aria-label":r("Actions")})]})}),(0,h.jsx)(z,{children:v.map(g=>(0,h.jsxs)(M,{"data-testid":`sj-row-${g.id}`,children:[(0,h.jsx)(f,{className:"font-mono text-xs",children:g.functionPath}),(0,h.jsx)(f,{className:"text-muted-foreground tabular-nums",children:ie(g.scheduledFor)}),(0,h.jsx)(f,{className:"font-mono text-xs",children:g.pool??""}),(0,h.jsx)(f,{className:"tabular-nums",children:g.attempts??0}),(0,h.jsx)(f,{children:g.shardKey??""}),(0,h.jsx)(f,{className:"font-mono text-xs",children:g.id}),J!==void 0&&(0,h.jsx)(f,{className:"text-right",children:(0,h.jsx)(G,{confirmLabel:r("Cancel job?"),onConfirm:c(()=>{T(q(g.id))},"onConfirm"),testId:`sj-cancel-${g.id}`,children:r("Cancel")})})]},g.id))})]})})}),y;return e[12]!==$||e[13]!==C||e[14]!==S?(y=(0,h.jsxs)("div",{className:I,"data-testid":F,children:[C,S,$]}),e[12]=$,e[13]=C,e[14]=S,e[15]=y):y=e[15],y},"me");var he={kind:"idle"},me=c((a,e,i)=>i!==void 0?i:e===void 0?d=>a.runCronJob(d):void 0,"oe"),ue=c(({loadCronJobs:a,runCronJob:e}={})=>{let i=_(),d=A(),[p,r]=(0,Y.useState)({}),l=E(["lunora-cron-jobs",a?"custom":"default"],()=>(a??(()=>i.getCronJobs()))()),{data:o,error:N}=l,b=me(i,a,e),n=c(async s=>{if(b!==void 0){r(m=>({...m,[s]:{kind:"running"}}));try{await b(s),r(m=>({...m,[s]:{kind:"ok"}})),l.refetch()}catch(m){r(k=>({...k,[s]:{kind:"error",message:O(m)}}))}}},"i");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[N!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:N}),o?.length===0&&(0,t.jsx)(W,{description:d("Triggers declared with the cronJobs() builder appear here."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,t.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:d("No cron triggers.")}),o!==void 0&&o.length>0&&(0,t.jsx)(B,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"cron-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(u,{children:d("name")}),(0,t.jsx)(u,{children:d("schedule")}),(0,t.jsx)(u,{children:d("target")}),(0,t.jsx)(u,{children:d("shard")}),b!==void 0&&(0,t.jsx)(u,{"aria-label":d("Actions")})]})}),(0,t.jsx)(z,{children:o.map(s=>{let m=p[s.name]??he;return(0,t.jsxs)(M,{"data-testid":`cron-row-${s.name}`,children:[(0,t.jsx)(f,{children:s.name}),(0,t.jsx)(f,{className:"font-mono text-xs tabular-nums",children:s.cron}),(0,t.jsx)(f,{children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[s.workflow===void 0?(0,t.jsx)(Z,{variant:"outline",children:d("function")}):(0,t.jsx)(Z,{variant:"secondary",children:d("workflow")}),(0,t.jsx)("span",{className:"font-mono text-xs",children:s.workflow??s.functionPath})]})}),(0,t.jsx)(f,{children:s.shardKey??""}),b!==void 0&&(0,t.jsx)(f,{className:"text-right",children:(0,t.jsxs)("span",{className:"flex items-center justify-end gap-2",children:[m.kind==="ok"&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${s.name}`,children:d("ran")}),m.kind==="error"&&(0,t.jsx)("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${s.name}`,role:"alert",children:m.message}),(0,t.jsx)(G,{confirmLabel:d("Run now?"),disabled:m.kind==="running",onConfirm:c(()=>{T(n(s.name))},"onConfirm"),testId:`cron-run-${s.name}`,children:m.kind==="running"?d("Running\u2026"):d("Run now")})]})})]},`${s.cron}:${s.name}`)})})]})})})]})},"le"),fe=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","re"),pe=c(a=>{let e=(0,U.c)(34),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadJobs:d,removeJob:p,retryJob:r}=i,l=_(),o=A(),N;e[2]===Symbol.for("react.memo_cache_sentinel")?(N=["lunora-dead-jobs"],e[2]=N):N=e[2];let b;e[3]!==l||e[4]!==d?(b=c(async()=>(await(d??(()=>l.listDeadJobs()))()).toSorted(ve),"h"),e[3]=l,e[4]=d,e[5]=b):b=e[5];let n=E(N,b),s=n.data,[m,k]=(0,Y.useState)(void 0),w=n.error??m,x=d===void 0,J;e[6]!==l||e[7]!==x||e[8]!==r?(J=r??(x?L=>l.retryDeadJob(L):void 0),e[6]=l,e[7]=x,e[8]=r,e[9]=J):J=e[9];let v=J,j;e[10]!==l||e[11]!==x||e[12]!==p?(j=p??(x?L=>l.removeDeadJob(L):void 0),e[10]=l,e[11]=x,e[12]=p,e[13]=j):j=e[13];let q=j,I;e[14]!==n?(I=c(()=>{n.refetch()},"J"),e[14]=n,e[15]=I):I=e[15],H(I,!0);let F;e[16]!==n?(F=c(async L=>{k(void 0);try{await L,n.refetch()}catch(ne){k(O(ne))}},"j"),e[16]=n,e[17]=F):F=e[17];let C=F,S=v!==void 0||q!==void 0,$;e[18]!==w?($=w!==void 0&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:w}),e[18]=w,e[19]=$):$=e[19];let y;e[20]!==s?.length||e[21]!==o?(y=s?.length===0&&(0,t.jsx)(W,{description:o("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:o("No dead-letter jobs.")}),e[20]=s?.length,e[21]=o,e[22]=y):y=e[22];let g;e[23]!==C||e[24]!==S||e[25]!==s||e[26]!==q||e[27]!==v||e[28]!==o?(g=s!==void 0&&s.length>0&&(0,t.jsx)(B,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"dlq-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(u,{children:o("function")}),(0,t.jsx)(u,{children:o("attempts")}),(0,t.jsx)(u,{children:o("last tried")}),(0,t.jsx)(u,{children:o("pool")}),(0,t.jsx)(u,{children:o("shard")}),(0,t.jsx)(u,{children:o("id")}),S&&(0,t.jsx)(u,{"aria-label":o("Actions")})]})}),(0,t.jsx)(z,{children:s.map(L=>(0,t.jsxs)(M,{"data-testid":`dlq-row-${L.id}`,children:[(0,t.jsx)(f,{className:"font-mono text-xs",children:L.functionPath}),(0,t.jsx)(f,{className:"tabular-nums",children:L.attempts??0}),(0,t.jsx)(f,{className:"text-muted-foreground tabular-nums",children:fe(L.scheduledFor)}),(0,t.jsx)(f,{className:"font-mono text-xs",children:L.pool??""}),(0,t.jsx)(f,{children:L.shardKey??""}),(0,t.jsx)(f,{className:"font-mono text-xs",children:L.id}),S&&(0,t.jsx)(f,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1.5",children:[v!==void 0&&(0,t.jsx)(ee,{"data-testid":`dlq-retry-${L.id}`,onClick:c(()=>{T(C(v(L.id)))},"onClick"),size:"sm",type:"button",variant:"outline",children:o("Retry")}),q!==void 0&&(0,t.jsx)(G,{confirmLabel:o("Drop job?"),onConfirm:c(()=>{T(C(q(L.id)))},"onConfirm"),testId:`dlq-remove-${L.id}`,children:o("Drop")})]})})]},L.id))})]})})}),e[23]=C,e[24]=S,e[25]=s,e[26]=q,e[27]=v,e[28]=o,e[29]=g):g=e[29];let P;return e[30]!==g||e[31]!==$||e[32]!==y?(P=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[$,y,g]}),e[30]=g,e[31]=$,e[32]=y,e[33]=P):P=e[33],P},"ne");function ve(a,e){return(e.attempts??0)-(a.attempts??0)}c(ve,"ae");var te=c(a=>{let e=(0,U.c)(8),{label:i,testId:d,value:p}=a,r;e[0]!==i?(r=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:i}),e[0]=i,e[1]=r):r=e[1];let l;e[2]!==d||e[3]!==p?(l=(0,t.jsx)("span",{className:"text-2xl font-semibold tabular-nums","data-testid":d,children:p}),e[2]=d,e[3]=p,e[4]=l):l=e[4];let o;return e[5]!==r||e[6]!==l?(o=(0,t.jsx)(B,{className:"flex-1 py-0",children:(0,t.jsxs)(D,{className:"flex flex-col gap-1 p-4",children:[r,l]})}),e[5]=r,e[6]=l,e[7]=o):o=e[7],o},"F"),be=c(a=>{let e=(0,U.c)(25),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadStatus:d}=i,p=_(),r=A(),l=d===void 0,o;e[2]!==l?(o=["lunora-scheduler-status",l],e[2]=l,e[3]=o):o=e[3];let N;e[4]!==p||e[5]!==d?(N=c(async()=>{let j=await(d??(()=>p.schedulerStatus()))();return{...j,pools:j.pools.toSorted(xe)}},"k"),e[4]=p,e[5]=d,e[6]=N):N=e[6];let b=E(o,N),{data:n,error:s}=b,m;e[7]!==b?(m=c(()=>{b.refetch()},"s"),e[7]=b,e[8]=m):m=e[8],H(m,!0);let k;e[9]!==s?(k=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:s}),e[9]=s,e[10]=k):k=e[10];let w;e[11]!==n||e[12]!==r?(w=n!==void 0&&(0,t.jsxs)("div",{className:"flex gap-3","data-testid":"pools-totals",children:[(0,t.jsx)(te,{label:r("backlog"),testId:"pools-backlog",value:n.backlog}),(0,t.jsx)(te,{label:r("in flight"),testId:"pools-inflight",value:n.inFlight}),(0,t.jsx)(te,{label:r("pools"),testId:"pools-count",value:n.pools.length})]}),e[11]=n,e[12]=r,e[13]=w):w=e[13];let x;e[14]!==n?.pools.length||e[15]!==r?(x=n?.pools.length===0&&(0,t.jsx)(W,{description:r("Pools created with createWorkpool appear here once they have activity."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:r("No workpools.")}),e[14]=n?.pools.length,e[15]=r,e[16]=x):x=e[16];let J;e[17]!==n||e[18]!==r?(J=n!==void 0&&n.pools.length>0&&(0,t.jsx)(B,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"pools-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(u,{children:r("pool")}),(0,t.jsx)(u,{children:r("queued")}),(0,t.jsx)(u,{children:r("in flight")}),(0,t.jsx)(u,{children:r("max concurrency")})]})}),(0,t.jsx)(z,{children:n.pools.map(ge)})]})})}),e[17]=n,e[18]=r,e[19]=J):J=e[19];let v;return e[20]!==k||e[21]!==w||e[22]!==x||e[23]!==J?(v=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[k,w,x,J]}),e[20]=k,e[21]=w,e[22]=x,e[23]=J,e[24]=v):v=e[24],v},"de");function xe(a,e){return e.queued-a.queued}c(xe,"ie");function ge(a){return(0,t.jsxs)(M,{"data-testid":`pools-row-${a.name}`,children:[(0,t.jsx)(f,{className:"font-mono text-xs",children:a.name}),(0,t.jsx)(f,{className:"tabular-nums",children:a.queued}),(0,t.jsxs)(f,{className:"tabular-nums",children:[a.inFlight," / ",a.maxConcurrency]}),(0,t.jsx)(f,{className:"tabular-nums",children:a.maxConcurrency})]},a.name)}c(ge,"se");var Ne=["jobs","dead","pools","cron"],Ve=c(a=>{let e=(0,U.c)(41),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadCronJobs:d,scheduledCancel:p,scheduledLoad:r}=i,l=A(),[o,N]=(0,Y.useState)("jobs"),b;e[2]!==l?(b=l("Cron triggers"),e[2]=l,e[3]=b):b=e[3];let n;e[4]!==l?(n=l("Dead letter"),e[4]=l,e[5]=n):n=e[5];let s;e[6]!==l?(s=l("Scheduled jobs"),e[6]=l,e[7]=s):s=e[7];let m;e[8]!==l?(m=l("Pools"),e[8]=l,e[9]=m):m=e[9];let k;e[10]!==b||e[11]!==n||e[12]!==s||e[13]!==m?(k={cron:b,dead:n,jobs:s,pools:m},e[10]=b,e[11]=n,e[12]=s,e[13]=m,e[14]=k):k=e[14];let w=k,x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=c(y=>{N(y.currentTarget.dataset.view)},"u"),e[15]=x):x=e[15];let J=x,v;e[16]!==l?(v=l("Schedule view"),e[16]=l,e[17]=v):v=e[17];let j;e[18]!==o||e[19]!==w?(j=Ne.map(y=>(0,t.jsx)(ee,{"aria-selected":o===y,"data-testid":`schedule-view-${y}`,"data-view":y,onClick:J,role:"tab",size:"sm",type:"button",variant:o===y?"default":"outline",children:w[y]},y)),e[18]=o,e[19]=w,e[20]=j):j=e[20];let q;e[21]!==v||e[22]!==j?(q=(0,t.jsx)("div",{"aria-label":v,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:j}),e[21]=v,e[22]=j,e[23]=q):q=e[23];let I;e[24]!==p||e[25]!==r||e[26]!==o?(I=o==="jobs"&&(0,t.jsx)(de,{cancelJob:p,loadJobs:r}),e[24]=p,e[25]=r,e[26]=o,e[27]=I):I=e[27];let F;e[28]!==o?(F=o==="dead"&&(0,t.jsx)(pe,{}),e[28]=o,e[29]=F):F=e[29];let C;e[30]!==o?(C=o==="pools"&&(0,t.jsx)(be,{}),e[30]=o,e[31]=C):C=e[31];let S;e[32]!==d||e[33]!==o?(S=o==="cron"&&(0,t.jsx)(ue,{loadCronJobs:d}),e[32]=d,e[33]=o,e[34]=S):S=e[34];let $;return e[35]!==q||e[36]!==I||e[37]!==F||e[38]!==C||e[39]!==S?($=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[q,I,F,C,S]}),e[35]=q,e[36]=I,e[37]=F,e[38]=C,e[39]=S,e[40]=$):$=e[40],$},"Je");export{Ve as SchedulePanel};
@@ -1,4 +1,4 @@
1
- import{a as Pe}from"./chunk-V53KNYRN.js";import{a as he}from"./chunk-5Y3QLNWX.js";import{d as Ne,f as ke,g as we,k as oe}from"./chunk-QBWRC5YX.js";import{a as Q}from"./chunk-HPFLBYRI.js";import{a as Oe}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as ye}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as U}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as ve}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as Ie}from"./chunk-ERMTJYQF.js";import{f as H}from"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as B}from"./chunk-XQCVZAGU.js";import{d as E,e as Se,f as se,g as ie,h as le,m as $e,o as ae}from"./chunk-OG4N2XHD.js";import{c as be}from"./chunk-QNUWWC3N.js";import{a as u,e as K,f as ue,g as te,h as re,j as fe}from"./chunk-3XIESWL4.js";var Fe=K(te(),1),ge=K(ue(),1);var Z=K(te(),1);var X=K(ue(),1);var T=K(re(),1);var Ve=se(Ie.listTables),Qe=["react","client","cli"],Xe=!1,Ze={action:"action",mutation:"mutation",query:"query"},_e=u(t=>{let e=t.indexOf(":");return e===-1?{file:"",fn:t}:{file:t.slice(0,e),fn:t.slice(e+1)}},"J"),Ce=u(({file:t,fn:e,kind:a})=>`await client.${Ze[a]}(api.${t}.${e}, { /* args */ });`,"U"),Ye=u(t=>{let e=`api.${t.file}.${t.fn}`;switch(t.kind){case"action":return Ce(t);case"mutation":return`const ${t.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},"re"),et=u(({file:t,fn:e})=>`lunora run ${t}:${e} --args '{ }'`,"se"),tt=u(t=>["// Read rows",`const rows = await ctx.db.query("${t}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${t}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${t}">;`,`type RowId = Id<"${t}">;`].join(`
1
+ import{a as Pe}from"./chunk-V53KNYRN.js";import{a as he}from"./chunk-5Y3QLNWX.js";import{d as Ne,f as ke,g as we,k as oe}from"./chunk-QBWRC5YX.js";import{a as Q}from"./chunk-HPFLBYRI.js";import{a as Oe}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as ye}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as U}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as ve}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as Ie}from"./chunk-VDW32UET.js";import{f as H}from"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as B}from"./chunk-XQCVZAGU.js";import{d as E,e as Se,f as se,g as ie,h as le,m as $e,o as ae}from"./chunk-OG4N2XHD.js";import{c as be}from"./chunk-XNGYYOLS.js";import{a as u,e as K,f as ue,g as te,h as re,j as fe}from"./chunk-3XIESWL4.js";var Fe=K(te(),1),ge=K(ue(),1);var Z=K(te(),1);var X=K(ue(),1);var T=K(re(),1);var Ve=se(Ie.listTables),Qe=["react","client","cli"],Xe=!1,Ze={action:"action",mutation:"mutation",query:"query"},_e=u(t=>{let e=t.indexOf(":");return e===-1?{file:"",fn:t}:{file:t.slice(0,e),fn:t.slice(e+1)}},"J"),Ce=u(({file:t,fn:e,kind:a})=>`await client.${Ze[a]}(api.${t}.${e}, { /* args */ });`,"U"),Ye=u(t=>{let e=`api.${t.file}.${t.fn}`;switch(t.kind){case"action":return Ce(t);case"mutation":return`const ${t.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},"re"),et=u(({file:t,fn:e})=>`lunora run ${t}:${e} --args '{ }'`,"se"),tt=u(t=>["// Read rows",`const rows = await ctx.db.query("${t}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${t}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${t}">;`,`type RowId = Id<"${t}">;`].join(`
2
2
  `),"de"),rt=u((t,e)=>{switch(t){case"cli":return et(e);case"client":return Ce(e);default:return Ye(e)}},"ce"),Te=u(t=>{let e=(0,Z.c)(19),{code:a,label:r,testId:n}=t,s=E(),o;e[0]!==a?(o=u(()=>{ae(a)},"s"),e[0]=a,e[1]=o):o=e[1];let i=o,d;e[2]!==r?(d=(0,T.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:r}),e[2]=r,e[3]=d):d=e[3];let m=`${n}-copy`,l;e[4]!==s?(l=s("Copy"),e[4]=s,e[5]=l):l=e[5];let c;e[6]!==i||e[7]!==m||e[8]!==l?(c=(0,T.jsx)(U,{"data-testid":m,onClick:i,size:"xs",type:"button",variant:"ghost",children:l}),e[6]=i,e[7]=m,e[8]=l,e[9]=c):c=e[9];let f;e[10]!==d||e[11]!==c?(f=(0,T.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[d,c]}),e[10]=d,e[11]=c,e[12]=f):f=e[12];let x;e[13]!==a||e[14]!==n?(x=(0,T.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":n,children:a}),e[13]=a,e[14]=n,e[15]=x):x=e[15];let h;return e[16]!==f||e[17]!==x?(h=(0,T.jsxs)("div",{className:"flex flex-col gap-1.5",children:[f,x]}),e[16]=f,e[17]=x,e[18]=h):h=e[18],h},"V"),at=u(t=>{let e=(0,Z.c)(50),{file:a,fn:r,kind:n}=t,s=E(),[o,i]=(0,X.useState)("react"),d,m,l;if(e[0]!==a||e[1]!==r||e[2]!==n||e[3]!==s||e[4]!==o){let $={file:a,fn:r,kind:n},S;e[8]!==s?(S=s("CLI"),e[8]=s,e[9]=S):S=e[9];let C;e[10]!==s?(C=s("Client"),e[10]=s,e[11]=C):C=e[11];let A;e[12]!==s?(A=s("React"),e[12]=s,e[13]=A):A=e[13];let M;e[14]!==S||e[15]!==C||e[16]!==A?(M={cli:S,client:C,react:A},e[14]=S,e[15]=C,e[16]=A,e[17]=M):M=e[17],l=M;let _;e[18]===Symbol.for("react.memo_cache_sentinel")?(_=u(J=>{i(J.currentTarget.dataset.tab)},"D"),e[18]=_):_=e[18],d=_,m=rt(o,$),e[0]=a,e[1]=r,e[2]=n,e[3]=s,e[4]=o,e[5]=d,e[6]=m,e[7]=l}else d=e[5],m=e[6],l=e[7];let c=m,f=n==="action"&&o==="react"&&!Xe,x=`api.${a}.${r}`,h;e[19]!==x?(h=(0,T.jsx)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-fn-title",children:x}),e[19]=x,e[20]=h):h=e[20];let b;e[21]!==n||e[22]!==s?(b=s("Call this {kind} from your app.",{kind:n}),e[21]=n,e[22]=s,e[23]=b):b=e[23];let y;e[24]!==b?(y=(0,T.jsx)("p",{className:"text-xs text-muted-foreground",children:b}),e[24]=b,e[25]=y):y=e[25];let N;e[26]!==h||e[27]!==y?(N=(0,T.jsxs)("div",{children:[h,y]}),e[26]=h,e[27]=y,e[28]=N):N=e[28];let v;e[29]!==s?(v=s("Snippet flavour"),e[29]=s,e[30]=v):v=e[30];let g;e[31]!==d||e[32]!==o||e[33]!==l?(g=Qe.map($=>(0,T.jsx)(U,{"aria-selected":o===$,"data-tab":$,"data-testid":`api-tab-${$}`,onClick:d,role:"tab",size:"xs",type:"button",variant:o===$?"default":"outline",children:l[$]},$)),e[31]=d,e[32]=o,e[33]=l,e[34]=g):g=e[34];let k;e[35]!==v||e[36]!==g?(k=(0,T.jsx)("div",{"aria-label":v,className:"flex gap-1.5","data-testid":"api-tabs",role:"tablist",children:g}),e[35]=v,e[36]=g,e[37]=k):k=e[37];let O=l[o],P=`api-snippet-${o}`,w;e[38]!==c||e[39]!==O||e[40]!==P?(w=(0,T.jsx)(Te,{code:c,label:O,testId:P}),e[38]=c,e[39]=O,e[40]=P,e[41]=w):w=e[41];let I;e[42]!==f||e[43]!==s?(I=f&&(0,T.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"api-action-note",children:s("Actions have no React hook \u2014 call them through the client.")}),e[42]=f,e[43]=s,e[44]=I):I=e[44];let j;return e[45]!==w||e[46]!==I||e[47]!==N||e[48]!==k?(j=(0,T.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"api-fn-doc",children:[N,k,w,I]}),e[45]=w,e[46]=I,e[47]=N,e[48]=k,e[49]=j):j=e[49],j},"pe"),nt=u(t=>{let e=(0,Z.c)(19),{name:a}=t,r=E(),n;e[0]!==a?(n=tt(a),e[0]=a,e[1]=n):n=e[1];let s=n,o;e[2]!==a?(o=(0,T.jsx)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-table-title",children:a}),e[2]=a,e[3]=o):o=e[3];let i;e[4]!==r?(i=r("Read and write this table through the typed data model."),e[4]=r,e[5]=i):i=e[5];let d;e[6]!==i?(d=(0,T.jsx)("p",{className:"text-xs text-muted-foreground",children:i}),e[6]=i,e[7]=d):d=e[7];let m;e[8]!==o||e[9]!==d?(m=(0,T.jsxs)("div",{children:[o,d]}),e[8]=o,e[9]=d,e[10]=m):m=e[10];let l;e[11]!==r?(l=r("Data model"),e[11]=r,e[12]=l):l=e[12];let c;e[13]!==s||e[14]!==l?(c=(0,T.jsx)(Te,{code:s,label:l,testId:"api-snippet-table"}),e[13]=s,e[14]=l,e[15]=c):c=e[15];let f;return e[16]!==m||e[17]!==c?(f=(0,T.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"api-table-doc",children:[m,c]}),e[16]=m,e[17]=c,e[18]=f):f=e[18],f},"fe"),je=u(t=>{let e=(0,Z.c)(8),{active:a,label:r,onSelect:n,testId:s,value:o}=t,i;e[0]!==n||e[1]!==o?(i=u(()=>{n(o)},"u"),e[0]=n,e[1]=o,e[2]=i):i=e[2];let d=i,m=a?"page":void 0,l;return e[3]!==r||e[4]!==d||e[5]!==m||e[6]!==s?(l=(0,T.jsx)("button",{"aria-current":m,className:"w-full truncate rounded-md px-2 py-1 text-start font-mono text-xs text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-testid":s,onClick:d,type:"button",children:r}),e[3]=r,e[4]=d,e[5]=m,e[6]=s,e[7]=l):l=e[7],l},"G"),ot=u(t=>{let e=new Map;for(let a of t){let{file:r,fn:n}=_e(a.path),s=e.get(r)??[];s.push({fn:n,kind:a.kind,path:a.path}),e.set(r,s)}return[...e.entries()].map(([a,r])=>({file:a,items:r.toSorted((n,s)=>n.fn.localeCompare(s.fn))})).toSorted((a,r)=>a.file.localeCompare(r.file))},"me"),Ae=u(t=>{let e=(0,Z.c)(58),{functions:a,initialShardKey:r}=t,n=E(),s=H(),[o,i]=(0,X.useState)(null),[d,m]=(0,X.useState)(null),l,c;e[0]!==s||e[1]!==r?(l=u(()=>{let M=!1;return s.query(Ve,{},ie(r??"")).then(_=>(M||i(_),_)).catch(()=>{M||i([])}),()=>{M=!0}},"r"),c=[s,r],e[0]=s,e[1]=r,e[2]=l,e[3]=c):(l=e[2],c=e[3]),(0,X.useEffect)(l,c);let f,x,h,b,y,N,v,g,k,O;if(e[4]!==a||e[5]!==d||e[6]!==n||e[7]!==o){let M=a??[],_=ot(M),J=(o??[]).map(st).toSorted(it),R;e[18]===Symbol.for("react.memo_cache_sentinel")?(R=u(z=>{m({kind:"fn",path:z})},"F"),e[18]=R):R=e[18];let D=R,V;e[19]===Symbol.for("react.memo_cache_sentinel")?(V=u(z=>{m({kind:"table",name:z})},"H"),e[19]=V):V=e[19];let Ge=V;x=d?.kind==="fn"?M.find(z=>z.path===d.path):void 0,f=M.length>0||J.length>0,h=x===void 0?void 0:_e(x.path),k="grid min-h-0 gap-6 md:grid-cols-[16rem_minmax(0,1fr)]",O="lunora-api-docs",e[20]!==n?(b=n("API resources"),e[20]=n,e[21]=b):b=e[21],y="flex flex-col gap-4 overflow-y-auto",N="api-rail";let ne;e[22]!==d||e[23]!==n?(ne=u(z=>(0,T.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,T.jsx)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:z.file||n("(root)")}),z.items.map(ee=>(0,T.jsx)(je,{active:d?.kind==="fn"&&d.path===ee.path,label:ee.fn,onSelect:D,testId:`api-rail-fn-${ee.path}`,value:ee.path},ee.path))]},z.file),"K"),e[22]=d,e[23]=n,e[24]=ne):ne=e[24],v=_.map(ne),g=J.length>0&&(0,T.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,T.jsx)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Tables")}),J.map(z=>(0,T.jsx)(je,{active:d?.kind==="table"&&d.name===z,label:z,onSelect:Ge,testId:`api-rail-table-${z}`,value:z},z))]}),e[4]=a,e[5]=d,e[6]=n,e[7]=o,e[8]=f,e[9]=x,e[10]=h,e[11]=b,e[12]=y,e[13]=N,e[14]=v,e[15]=g,e[16]=k,e[17]=O}else f=e[8],x=e[9],h=e[10],b=e[11],y=e[12],N=e[13],v=e[14],g=e[15],k=e[16],O=e[17];let P;e[25]!==f||e[26]!==n?(P=!f&&(0,T.jsx)("p",{className:"px-2 text-xs text-muted-foreground","data-testid":"api-rail-empty",children:n("No functions or tables to document yet.")}),e[25]=f,e[26]=n,e[27]=P):P=e[27];let w;e[28]!==P||e[29]!==b||e[30]!==y||e[31]!==N||e[32]!==v||e[33]!==g?(w=(0,T.jsxs)("nav",{"aria-label":b,className:y,"data-testid":N,children:[v,g,P]}),e[28]=P,e[29]=b,e[30]=y,e[31]=N,e[32]=v,e[33]=g,e[34]=w):w=e[34];let I;e[35]!==d||e[36]!==n?(I=d===null&&(0,T.jsx)(B,{description:n("Select a function or table to see how to call it from your app."),testId:"api-empty",title:n("API usage snippets")}),e[35]=d,e[36]=n,e[37]=I):I=e[37];let j;e[38]!==d?.kind||e[39]!==x||e[40]!==h?(j=d?.kind==="fn"&&x!==void 0&&h!==void 0&&(0,T.jsx)(at,{file:h.file,fn:h.fn,kind:x.kind},x.path),e[38]=d?.kind,e[39]=x,e[40]=h,e[41]=j):j=e[41];let $;e[42]!==d?.kind||e[43]!==x||e[44]!==n?($=d?.kind==="fn"&&x===void 0&&(0,T.jsx)(B,{testId:"api-empty",title:n("API usage snippets")}),e[42]=d?.kind,e[43]=x,e[44]=n,e[45]=$):$=e[45];let S;e[46]!==d?(S=d?.kind==="table"&&(0,T.jsx)(nt,{name:d.name}),e[46]=d,e[47]=S):S=e[47];let C;e[48]!==I||e[49]!==j||e[50]!==$||e[51]!==S?(C=(0,T.jsxs)("div",{className:"min-w-0",children:[I,j,$,S]}),e[48]=I,e[49]=j,e[50]=$,e[51]=S,e[52]=C):C=e[52];let A;return e[53]!==w||e[54]!==C||e[55]!==k||e[56]!==O?(A=(0,T.jsxs)("div",{className:k,"data-testid":O,children:[w,C]}),e[53]=w,e[54]=C,e[55]=k,e[56]=O,e[57]=A):A=e[57],A},"Se");function st(t){return t.name}u(st,"ue");function it(t,e){return t.localeCompare(e)}u(it,"he");var We=K(te(),1);var q=K(te(),1),L=K(ue(),1);var p=K(re(),1);var pe=u(function(t,e,a){let r=(0,q.c)(10),n;r[0]===Symbol.for("react.memo_cache_sentinel")?(n={kind:"loading"},r[0]=n):n=r[0];let[s,o]=(0,L.useState)(n),i,d;r[1]!==a||r[2]!==e||r[3]!==t?(i=u(()=>{if(t!==void 0)return;let l=!1;return e().then(c=>(l||o(a(c)),c)).catch(c=>{l||o({kind:"error",message:le(c)})}),()=>{l=!0}},"l"),d=[a,e,t],r[1]=a,r[2]=e,r[3]=t,r[4]=i,r[5]=d):(i=r[4],d=r[5]),(0,L.useEffect)(i,d);let m;return r[6]!==a||r[7]!==s||r[8]!==t?(m=t===void 0?s:a(t),r[6]=a,r[7]=s,r[8]=t,r[9]=m):m=r[9],m},"gt"),lt=u(t=>typeof t=="number"?"number":typeof t=="boolean"?"boolean":"string","$e"),Re=u(t=>{if(t.enum!==void 0&&t.enum.length>0)return t.enum;if(t.anyOf!==void 0&&t.anyOf.length>0&&t.anyOf.every(e=>e.const!==void 0))return t.anyOf.map(e=>e.const)},"X"),ce=u(t=>t===void 0?"any":t.const!==void 0?JSON.stringify(t.const):t.enum!==void 0&&t.enum.length>0?t.enum.map(e=>JSON.stringify(e)).join(" | "):t.anyOf!==void 0&&t.anyOf.length>0?t.anyOf.map(e=>ce(e)).join(" | "):t.type==="array"?`array<${ce(t.items)}>`:t.type??"any","B"),dt=u(t=>{let e=Re(t);return e!==void 0?t.type??lt(e[0]):ce(t)},"ke"),ct=u(t=>{let e=Re(t);return e===void 0?void 0:e.map(a=>JSON.stringify(a)).join(" | ")},"Se"),pt=u(t=>{let e=[];t.minimum!==void 0?e.push(`${String(t.minimum)} \u2264`):t.exclusiveMinimum!==void 0&&e.push(`${String(t.exclusiveMinimum)} <`);let a=e.length>0;e.push("value"),t.maximum!==void 0?e.push(`\u2264 ${String(t.maximum)}`):t.exclusiveMaximum!==void 0&&e.push(`< ${String(t.exclusiveMaximum)}`);let r=e.length>(a?2:1);return a||r?e.join(" "):void 0},"we"),mt=u(t=>{if(t.type==="object"&&t.properties!==void 0)return t;if(t.type==="array"&&t.items?.type==="object"&&t.items.properties!==void 0)return t.items},"Oe"),Y=u(t=>{if(t===void 0)return null;if(t.const!==void 0)return t.const;if(t.enum!==void 0&&t.enum.length>0)return t.enum[0];if(t.anyOf!==void 0&&t.anyOf.length>0)return Y(t.anyOf[0]);switch(t.type){case"array":return[];case"boolean":return!1;case"number":return 0;case"object":{let e={};for(let[a,r]of Object.entries(t.properties??{}))e[a]=Y(r);return e}case"string":return"";default:return null}},"q"),de=u(t=>{let e=(0,q.c)(7),{label:a,value:r}=t,n;e[0]!==a?(n=(0,p.jsx)("span",{className:"text-muted-foreground",children:a}),e[0]=a,e[1]=n):n=e[1];let s;e[2]!==r?(s=(0,p.jsx)("span",{className:"text-foreground",children:r}),e[2]=r,e[3]=s):s=e[3];let o;return e[4]!==n||e[5]!==s?(o=(0,p.jsxs)("span",{className:"inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 font-mono text-[10px]",children:[n,s]}),e[4]=n,e[5]=s,e[6]=o):o=e[6],o},"W"),ut=u(t=>{let e=(0,q.c)(40),{name:a,required:r,schema:n}=t,s=E(),o;e[0]!==n?(o=pt(n),e[0]=n,e[1]=o):o=e[1];let i=o,d;e[2]!==n?(d=ct(n),e[2]=n,e[3]=d):d=e[3];let m=d,l=n["x-lunora-table"],c=n.format!==void 0||i!==void 0||m!==void 0||l!==void 0,f;e[4]!==n?(f=mt(n),e[4]=n,e[5]=f):f=e[5];let x=f,h=r?"*":"?",b;e[6]!==h?(b=(0,p.jsx)("span",{className:"text-muted-foreground",children:h}),e[6]=h,e[7]=b):b=e[7];let y;e[8]!==a||e[9]!==b?(y=(0,p.jsxs)("span",{className:"font-mono text-foreground",children:[a,b]}),e[8]=a,e[9]=b,e[10]=y):y=e[10];let N;e[11]!==n?(N=dt(n),e[11]=n,e[12]=N):N=e[12];let v;e[13]!==N?(v=(0,p.jsx)("span",{className:"font-mono text-muted-foreground",children:N}),e[13]=N,e[14]=v):v=e[14];let g;e[15]!==y||e[16]!==v?(g=(0,p.jsxs)("div",{className:"flex items-baseline gap-2",children:[y,v]}),e[15]=y,e[16]=v,e[17]=g):g=e[17];let k;e[18]!==n.description?(k=n.description!==void 0&&(0,p.jsx)("p",{className:"max-w-prose text-muted-foreground",children:n.description}),e[18]=n.description,e[19]=k):k=e[19];let O;e[20]!==c||e[21]!==i||e[22]!==l||e[23]!==n.format||e[24]!==s||e[25]!==m?(O=c&&(0,p.jsxs)("div",{className:"flex flex-wrap gap-1",children:[n.format!==void 0&&(0,p.jsx)(de,{label:s("Format"),value:n.format}),i!==void 0&&(0,p.jsx)(de,{label:s("Range"),value:i}),m!==void 0&&(0,p.jsx)(de,{label:s("Value in"),value:m}),l!==void 0&&(0,p.jsx)(de,{label:s("relation"),value:l})]}),e[20]=c,e[21]=i,e[22]=l,e[23]=n.format,e[24]=s,e[25]=m,e[26]=O):O=e[26];let P;e[27]!==k||e[28]!==O||e[29]!==g?(P=(0,p.jsxs)("div",{className:"flex flex-col gap-1 py-2",children:[g,k,O]}),e[27]=k,e[28]=O,e[29]=g,e[30]=P):P=e[30];let w=P;if(x===void 0){let S;return e[31]!==w?(S=(0,p.jsx)("div",{className:"border-b border-border/50 last:border-b-0",children:w}),e[31]=w,e[32]=S):S=e[32],S}let I;e[33]!==w?(I=(0,p.jsx)("summary",{className:"cursor-pointer marker:text-muted-foreground",children:w}),e[33]=w,e[34]=I):I=e[34];let j;e[35]!==x?(j=(0,p.jsx)("div",{className:"mb-2 ml-2 border-l border-border pl-3",children:(0,p.jsx)(Je,{schema:x})}),e[35]=x,e[36]=j):j=e[36];let $;return e[37]!==I||e[38]!==j?($=(0,p.jsxs)("details",{className:"border-b border-border/50 last:border-b-0",children:[I,j]}),e[37]=I,e[38]=j,e[39]=$):$=e[39],$},"je"),Je=u(t=>{let e=(0,q.c)(7),{schema:a}=t,r;e[0]!==a.required?(r=new Set(a.required),e[0]=a.required,e[1]=r):r=e[1];let n=r,s;e[2]!==a.properties?(s=Object.entries(a.properties??{}),e[2]=a.properties,e[3]=s):s=e[3];let o=s,i;return e[4]!==n||e[5]!==o?(i=(0,p.jsx)("div",{className:"flex flex-col",children:o.map(d=>{let[m,l]=d;return(0,p.jsx)(ut,{name:m,required:n.has(m),schema:l},m)})}),e[4]=n,e[5]=o,e[6]=i):i=e[6],i},"Y"),Me=u(t=>{let e=(0,q.c)(10),{schema:a,testId:r}=t;if(a?.type!=="object"||Object.keys(a.properties??{}).length===0){let o;e[0]!==a?(o=ce(a),e[0]=a,e[1]=o):o=e[1];let i;return e[2]!==o||e[3]!==r?(i=(0,p.jsx)("p",{className:"font-mono text-xs text-muted-foreground","data-testid":r,children:o}),e[2]=o,e[3]=r,e[4]=i):i=e[4],i}let n;e[5]!==a?(n=(0,p.jsx)(Je,{schema:a}),e[5]=a,e[6]=n):n=e[6];let s;return e[7]!==n||e[8]!==r?(s=(0,p.jsx)("div",{className:"text-xs","data-testid":r,children:n}),e[7]=n,e[8]=r,e[9]=s):s=e[9],s},"G"),ft=["curl","javascript","lunora"],ht={lunora:"Lunora",curl:"cURL",javascript:"JavaScript"},xt=u(t=>`api.${t.replaceAll(/[/:]/g,".")}`,"Pe"),gt=u(t=>{let e=Y(t.argsSchema)??{};return t.functionPath===void 0?e:{args:e,functionPath:t.functionPath}},"Te"),bt=u((t,e,a)=>{let r=`${a}${e.httpPath}`,n=JSON.stringify(gt(e),void 0,2),s=JSON.stringify(Y(e.argsSchema)??{},void 0,2);switch(t){case"curl":{let o=e.method!=="GET"&&e.method!=="HEAD",i=[`curl -X ${e.method} ${JSON.stringify(r)}`];return o&&i.push(' -H "Content-Type: application/json"',` -d '${n}'`),i.join(` \\
3
3
  `)}case"lunora":return e.functionPath===void 0?`await fetch(${JSON.stringify(e.httpPath)}, { method: ${JSON.stringify(e.method)} });`:`import { useLunora } from "@lunora/react";
4
4
  import { api } from "./_generated/api";
@@ -1 +1 @@
1
- import{a as N}from"./chunk-AHVDZWB3.js";import{a as v,b as w,c as y,d,e as c,f as i}from"./chunk-MIQTKZAR.js";import{a as x,e as b}from"./chunk-UZERI5YC.js";import{d as h}from"./chunk-OG4N2XHD.js";import{a as s,e as p,f as R,h as T,j as g}from"./chunk-3XIESWL4.js";var $=p(R(),1);var e=p(T(),1);var S={ERROR:"error",INFO:"info",WARN:"warning"},G=s(r=>{let n=typeof r.metadata.table=="string"?r.metadata.table:void 0;return{description:`${r.detail} ${r.remediation}`,entity:n,issueType:r.title,key:r.cacheKey,level:S[r.level]}},"q"),j=["error","warning","info"],A={error:"bg-destructive",info:"bg-info",warning:"bg-warning"},O=s((r,n)=>({error:r("Errors"),info:r("Info"),warning:r("Warnings")})[n],"R"),W=s((r,n,o)=>({error:r("{count} errors",{count:o}),info:r("{count} suggestions",{count:o}),warning:r("{count} warnings",{count:o})})[n],"O"),q=s((r,n)=>({error:r("No errors detected"),info:r("No suggestions"),warning:r("No warnings detected")})[n],"S"),z=s(r=>{let n={error:0,info:0,warning:0};for(let o of r??[])n[o.level]+=1;return n},"j"),H=s(({error:r=null,errorSource:n,rows:o,testId:l,toolbar:u})=>{let a=h(),[m,k]=(0,$.useState)("error"),E=z(o),f=(o??[]).filter(t=>t.level===m),I=s(t=>{k(t.currentTarget.dataset.level)},"h");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":l,children:[(0,e.jsx)("div",{className:"flex border-b border-border",role:"tablist",children:j.map(t=>(0,e.jsxs)("button",{"aria-selected":m===t,className:"flex min-w-32 flex-col gap-0.5 border-b-2 border-transparent px-4 py-2 text-start outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 aria-selected:border-foreground","data-level":t,"data-testid":`${l}-tab-${t}`,onClick:I,role:"tab",type:"button",children:[(0,e.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[(0,e.jsx)("span",{"aria-hidden":"true",className:g("size-2 rounded-sm",A[t])}),O(a,t)]}),(0,e.jsx)("span",{className:"ps-4 text-xs text-muted-foreground",children:W(a,t,E[t])})]},t))}),u!==void 0&&(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:u}),r!==null&&(0,e.jsx)(N,{error:n??r,testId:`${l}-error`}),(0,e.jsx)(x,{className:"overflow-hidden py-0",children:(0,e.jsx)(b,{className:"px-0",children:(0,e.jsxs)(v,{children:[(0,e.jsx)(w,{children:(0,e.jsxs)(d,{children:[(0,e.jsx)(c,{children:a("Issue type")}),(0,e.jsx)(c,{children:a("Entity/item")}),(0,e.jsx)(c,{children:a("Description")})]})}),(0,e.jsx)(y,{children:f.length===0?(0,e.jsx)(d,{children:(0,e.jsxs)(i,{className:"h-40 text-center align-middle text-muted-foreground",colSpan:3,"data-testid":`${l}-empty`,children:[(0,e.jsx)("span",{className:"block text-sm font-medium text-foreground",children:q(a,m)}),(0,e.jsx)("span",{className:"block text-sm",children:a("Nothing to report for this deployment.")})]})}):f.map(t=>(0,e.jsxs)(d,{children:[(0,e.jsx)(i,{className:"font-medium text-foreground",children:t.issueType}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.entity??"\u2014"}),(0,e.jsxs)(i,{className:"text-muted-foreground",children:[(0,e.jsx)("span",{children:t.description}),t.action!==void 0&&(0,e.jsx)("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:t.action})]})]},t.key))})]})})})]})},"B");export{G as a,H as b};
1
+ import{a as N}from"./chunk-YRYEZHOJ.js";import{a as v,b as w,c as y,d,e as c,f as i}from"./chunk-MIQTKZAR.js";import{a as x,e as b}from"./chunk-UZERI5YC.js";import{d as h}from"./chunk-OG4N2XHD.js";import{a as s,e as p,f as R,h as T,j as g}from"./chunk-3XIESWL4.js";var $=p(R(),1);var e=p(T(),1);var S={ERROR:"error",INFO:"info",WARN:"warning"},G=s(r=>{let n=typeof r.metadata.table=="string"?r.metadata.table:void 0;return{description:`${r.detail} ${r.remediation}`,entity:n,issueType:r.title,key:r.cacheKey,level:S[r.level]}},"q"),j=["error","warning","info"],A={error:"bg-destructive",info:"bg-info",warning:"bg-warning"},O=s((r,n)=>({error:r("Errors"),info:r("Info"),warning:r("Warnings")})[n],"R"),W=s((r,n,o)=>({error:r("{count} errors",{count:o}),info:r("{count} suggestions",{count:o}),warning:r("{count} warnings",{count:o})})[n],"O"),q=s((r,n)=>({error:r("No errors detected"),info:r("No suggestions"),warning:r("No warnings detected")})[n],"S"),z=s(r=>{let n={error:0,info:0,warning:0};for(let o of r??[])n[o.level]+=1;return n},"j"),H=s(({error:r=null,errorSource:n,rows:o,testId:l,toolbar:u})=>{let a=h(),[m,k]=(0,$.useState)("error"),E=z(o),f=(o??[]).filter(t=>t.level===m),I=s(t=>{k(t.currentTarget.dataset.level)},"h");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":l,children:[(0,e.jsx)("div",{className:"flex border-b border-border",role:"tablist",children:j.map(t=>(0,e.jsxs)("button",{"aria-selected":m===t,className:"flex min-w-32 flex-col gap-0.5 border-b-2 border-transparent px-4 py-2 text-start outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 aria-selected:border-foreground","data-level":t,"data-testid":`${l}-tab-${t}`,onClick:I,role:"tab",type:"button",children:[(0,e.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[(0,e.jsx)("span",{"aria-hidden":"true",className:g("size-2 rounded-sm",A[t])}),O(a,t)]}),(0,e.jsx)("span",{className:"ps-4 text-xs text-muted-foreground",children:W(a,t,E[t])})]},t))}),u!==void 0&&(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:u}),r!==null&&(0,e.jsx)(N,{error:n??r,testId:`${l}-error`}),(0,e.jsx)(x,{className:"overflow-hidden py-0",children:(0,e.jsx)(b,{className:"px-0",children:(0,e.jsxs)(v,{children:[(0,e.jsx)(w,{children:(0,e.jsxs)(d,{children:[(0,e.jsx)(c,{children:a("Issue type")}),(0,e.jsx)(c,{children:a("Entity/item")}),(0,e.jsx)(c,{children:a("Description")})]})}),(0,e.jsx)(y,{children:f.length===0?(0,e.jsx)(d,{children:(0,e.jsxs)(i,{className:"h-40 text-center align-middle text-muted-foreground",colSpan:3,"data-testid":`${l}-empty`,children:[(0,e.jsx)("span",{className:"block text-sm font-medium text-foreground",children:q(a,m)}),(0,e.jsx)("span",{className:"block text-sm",children:a("Nothing to report for this deployment.")})]})}):f.map(t=>(0,e.jsxs)(d,{children:[(0,e.jsx)(i,{className:"font-medium text-foreground",children:t.issueType}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.entity??"\u2014"}),(0,e.jsxs)(i,{className:"text-muted-foreground",children:[(0,e.jsx)("span",{children:t.description}),t.action!==void 0&&(0,e.jsx)("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:t.action})]})]},t.key))})]})})})]})},"B");export{G as a,H as b};
@@ -0,0 +1 @@
1
+ var _={aiAvailable:"__lunora_admin__:aiAvailable",aiChartConfig:"__lunora_admin__:aiChartConfig",aiGenerateSql:"__lunora_admin__:aiGenerateSql",aiTableFilter:"__lunora_admin__:aiTableFilter",assignIssue:"__lunora_admin__:assignIssue",backRelationCounts:"__lunora_admin__:backRelationCounts",clearCapturedMail:"__lunora_admin__:clearCapturedMail",clearQueueMessages:"__lunora_admin__:clearQueueMessages",clearTable:"__lunora_admin__:clearTable",createWorkflowInstance:"__lunora_admin__:createWorkflowInstance",deleteRows:"__lunora_admin__:deleteRows",describeTable:"__lunora_admin__:describeTable",describeTables:"__lunora_admin__:describeTables",explainIssue:"__lunora_admin__:explainIssue",exportShard:"__lunora_admin__:exportShard",facetColumn:"__lunora_admin__:facetColumn",getAdvisories:"__lunora_admin__:getAdvisories",getAdvisorProcedures:"__lunora_admin__:getAdvisorProcedures",getAuditLog:"__lunora_admin__:getAuditLog",getAuthAuditLog:"__lunora_admin__:getAuthAuditLog",getAuthMetrics:"__lunora_admin__:getAuthMetrics",getCapturedMail:"__lunora_admin__:getCapturedMail",getFanoutMetrics:"__lunora_admin__:getFanoutMetrics",getFunctionStats:"__lunora_admin__:getFunctionStats",getIssues:"__lunora_admin__:getIssues",lintSql:"__lunora_admin__:lintSql",listFlags:"__lunora_admin__:listFlags",listPushSubscriptions:"__lunora_admin__:listPushSubscriptions",listQueues:"__lunora_admin__:listQueues",listSubscriptions:"__lunora_admin__:listSubscriptions",listTableIndexes:"__lunora_admin__:listTableIndexes",listTablesIndexes:"__lunora_admin__:listTablesIndexes",listWorkflows:"__lunora_admin__:listWorkflows",getLogs:"__lunora_admin__:getLogs",getMetricHistory:"__lunora_admin__:getMetricHistory",getMetricSeries:"__lunora_admin__:getMetricSeries",getMetrics:"__lunora_admin__:getMetrics",getPitrBookmark:"__lunora_admin__:getPitrBookmark",getQueryInsights:"__lunora_admin__:getQueryInsights",getQueueMessages:"__lunora_admin__:getQueueMessages",getRequestLog:"__lunora_admin__:getRequestLog",getSecurityAudit:"__lunora_admin__:getSecurityAudit",getSettings:"__lunora_admin__:getSettings",getTraces:"__lunora_admin__:getTraces",getWorkflowInstanceStatus:"__lunora_admin__:getWorkflowInstanceStatus",ignoreIssue:"__lunora_admin__:ignoreIssue",importShard:"__lunora_admin__:importShard",listTables:"__lunora_admin__:listTables",maskPolicies:"__lunora_admin__:maskPolicies",migrationStatus:"__lunora_admin__:migrationStatus",pitrRestore:"__lunora_admin__:pitrRestore",readTablePage:"__lunora_admin__:readTablePage",replayQueueMessage:"__lunora_admin__:replayQueueMessage",resolveIssue:"__lunora_admin__:resolveIssue",rlsPolicies:"__lunora_admin__:rlsPolicies",schemaHistory:"__lunora_admin__:schemaHistory",schemaVersion:"__lunora_admin__:schemaVersion",runAs:"__lunora_admin__:runAs",runMigration:"__lunora_admin__:runMigration",runSql:"__lunora_admin__:runSql",sendQueueMessage:"__lunora_admin__:sendQueueMessage",sendTestMail:"__lunora_admin__:sendTestMail",setIssueSeverity:"__lunora_admin__:setIssueSeverity",storageOrphans:"__lunora_admin__:storageOrphans",storageReferences:"__lunora_admin__:storageReferences",storageRules:"__lunora_admin__:storageRules",studioFeatures:"__lunora_admin__:studioFeatures",writeRow:"__lunora_admin__:writeRow"};export{_ as a};
@@ -0,0 +1 @@
1
+ import{a as X}from"./chunk-QWGT25SE.js";import{a as Le}from"./chunk-ZJGP6EKR.js";import{b as Se}from"./chunk-AVAC26HJ.js";import{a as de}from"./chunk-XF2B7P5A.js";import{a as Ce}from"./chunk-CTNB2KIA.js";import{a as ie}from"./chunk-FURI47Z2.js";import{a as be}from"./chunk-3CWGJYBB.js";import{a as ve}from"./chunk-X665E2HU.js";import{b as pe}from"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as D}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as ge}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as J}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as xe}from"./chunk-YRYEZHOJ.js";import"./chunk-XXQUMVWH.js";import"./chunk-PNAVAJAF.js";import"./chunk-QLQADHFE.js";import{a as se}from"./chunk-VDW32UET.js";import{c as oe}from"./chunk-TS6346VY.js";import{f as he}from"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as Z}from"./chunk-XQCVZAGU.js";import{a as ye,b as we,c as Ne,d as ne,e as U,f as z}from"./chunk-MIQTKZAR.js";import{d as B,h as le,i as fe,m as ae}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as N,e as re,f as Ee,g as Ke,h as Me,j as G}from"./chunk-3XIESWL4.js";var _=re(Ke(),1);var T=re(Ee(),1);var r=re(Me(),1);var ue=["trace","debug","log","info","warn","error","fatal"],_e="LOG_ARCHIVE_NOT_CONFIGURED",Re={debug:"secondary",error:"destructive",fatal:"destructive",info:"outline",log:"outline",trace:"outline",warn:"secondary"},$e={cursor:void 0,error:null,loading:!1,notConfigured:!1,rows:null},Ae=N((c,e)=>{switch(e.type){case"append":return{...c,cursor:e.cursor,error:null,loading:!1,rows:[...c.rows??[],...e.rows]};case"failed":return{cursor:void 0,error:e.message,loading:!1,notConfigured:!1,rows:null};case"loaded":return{cursor:e.cursor,error:null,loading:!1,notConfigured:!1,rows:e.rows};case"loading":return{...c,error:null,loading:!0,notConfigured:!1};case"notConfigured":return{cursor:void 0,error:null,loading:!1,notConfigured:!0,rows:null};case"pageFailed":return{...c,error:e.message,loading:!1};default:return c}},"Ke"),Oe=N(c=>{let e=(0,_.c)(33),{row:t}=c,s;e[0]!==t.fields?(s=X(t.fields),e[0]=t.fields,e[1]=s):s=e[1];let i=s,o=`lg-archive-row-${String(t.ts)}`,m;e[2]!==t.ts?(m=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=m):m=e[3];let p;e[4]!==m?(p=(0,r.jsx)(z,{className:"tabular-nums whitespace-nowrap text-xs text-muted-foreground",children:m}),e[4]=m,e[5]=p):p=e[5];let f=Re[t.level],n;e[6]!==t.level||e[7]!==f?(n=(0,r.jsx)(z,{children:(0,r.jsx)(J,{variant:f,children:t.level})}),e[6]=t.level,e[7]=f,e[8]=n):n=e[8];let l;e[9]!==t.functionPath?(l=(0,r.jsx)(z,{className:"font-mono text-xs",children:t.functionPath}),e[9]=t.functionPath,e[10]=l):l=e[10];let v;e[11]!==t.message?(v=(0,r.jsx)("div",{className:"truncate",title:t.message,children:t.message}),e[11]=t.message,e[12]=v):v=e[12];let a;e[13]!==i?(a=i!==""&&(0,r.jsx)("div",{className:"truncate font-mono text-[11px] text-muted-foreground",title:i,children:i}),e[13]=i,e[14]=a):a=e[14];let d;e[15]!==v||e[16]!==a?(d=(0,r.jsxs)(z,{className:"max-w-md",children:[v,a]}),e[15]=v,e[16]=a,e[17]=d):d=e[17];let u=t.traceId??"\u2014",h;e[18]!==u?(h=(0,r.jsx)(z,{className:"font-mono text-[11px] text-muted-foreground",children:u}),e[18]=u,e[19]=h):h=e[19];let b=t.shardKey??"\u2014",g;e[20]!==b?(g=(0,r.jsx)(z,{className:"font-mono text-[11px] text-muted-foreground",children:b}),e[20]=b,e[21]=g):g=e[21];let x=t.userId??"\u2014",y;e[22]!==x?(y=(0,r.jsx)(z,{className:"font-mono text-[11px] text-muted-foreground",children:x}),e[22]=x,e[23]=y):y=e[23];let S;return e[24]!==d||e[25]!==h||e[26]!==g||e[27]!==y||e[28]!==o||e[29]!==p||e[30]!==n||e[31]!==l?(S=(0,r.jsxs)(ne,{"data-testid":o,children:[p,n,l,d,h,g,y]}),e[24]=d,e[25]=h,e[26]=g,e[27]=y,e[28]=o,e[29]=p,e[30]=n,e[31]=l,e[32]=S):S=e[32],S},"Ue"),De=N(({shardKey:c})=>{let e=he(),t=B(),[s,i]=(0,T.useState)(""),[o,m]=(0,T.useState)(""),[p,f]=(0,T.useState)(""),[{cursor:n,error:l,loading:v,notConfigured:a,rows:d},u]=(0,T.useReducer)(Ae,$e),h=ie(s.trim(),400),b=ie(o.trim(),400),g={...h===""?{}:{functionPathPrefix:h},...p===""?{}:{minLevel:p},...c===""?{}:{shardKey:c},...b===""?{}:{userId:b}},x=JSON.stringify(g),y=(0,T.useRef)(x);(0,T.useEffect)(()=>{let w={cancelled:!1};return y.current=x,ae((async()=>{u({type:"loading"});try{let C=await e.queryLogArchive(g);w.cancelled||u({cursor:C.nextCursor,rows:C.rows,type:"loaded"})}catch(C){w.cancelled||u(fe(C)===_e?{type:"notConfigured"}:{message:le(C),type:"failed"})}})()),()=>{w.cancelled=!0}},[e,x]);let S=N(async()=>{if(n===void 0)return;let w=x;u({type:"loading"});try{let C=await e.queryLogArchive({...g,cursor:n});y.current===w&&u({cursor:C.nextCursor,rows:C.rows,type:"append"})}catch(C){y.current===w&&u({message:le(C),type:"pageFailed"})}},"C"),R=N(w=>{i(w.target.value)},"$"),L=N(w=>{m(w.target.value)},"L"),k=N(w=>{f(w.target.value)},"S"),I=N(()=>{ae(S())},"R");return a?(0,r.jsx)(Z,{action:(0,r.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline",href:de,rel:"noreferrer",target:"_blank",children:t("Open in Cloudflare")}),description:t("Wire pipelineLogSink to a Cloudflare Pipeline \u2192 R2 Data Catalog table and set R2_SQL_ACCOUNT_ID, R2_SQL_TOKEN, R2_SQL_BUCKET to browse the durable log archive here."),testId:"lg-archive-not-configured",title:t("Log archive not configured")}):(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lg-archive",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(D,{"aria-label":t("Function path prefix"),className:"h-8 w-48","data-testid":"lg-archive-path",onChange:R,placeholder:t("function path\u2026"),value:s}),(0,r.jsx)(D,{"aria-label":t("User id"),className:"h-8 w-40","data-testid":"lg-archive-user",onChange:L,placeholder:t("user id\u2026"),value:o}),(0,r.jsxs)("select",{"aria-label":t("Minimum level"),className:"h-8 rounded-md border border-border bg-background px-2 text-sm","data-testid":"lg-archive-min-level",onChange:k,value:p,children:[(0,r.jsx)("option",{value:"",children:t("min level")}),ue.map(w=>(0,r.jsx)("option",{value:w,children:w},w))]})]}),l!==null&&(0,r.jsx)("p",{className:"text-sm text-destructive","data-testid":"lg-archive-error",role:"alert",children:l}),v&&d===null&&l===null&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"lg-archive-loading",children:t("Loading\u2026")}),d!==null&&d.length===0&&(0,r.jsx)(Z,{description:t("No archived logs match these filters. The durable archive fills as pipelineLogSink flushes records to R2."),testId:"lg-archive-empty",title:t("No archived logs.")}),d!==null&&d.length>0&&(0,r.jsx)("div",{className:"overflow-hidden rounded-xl border border-border shadow-xs",children:(0,r.jsxs)(ye,{"data-testid":"lg-archive-table",children:[(0,r.jsx)(we,{children:(0,r.jsxs)(ne,{children:[(0,r.jsx)(U,{children:t("Time")}),(0,r.jsx)(U,{children:t("Level")}),(0,r.jsx)(U,{children:t("Function")}),(0,r.jsx)(U,{children:t("Message")}),(0,r.jsx)(U,{children:t("Trace")}),(0,r.jsx)(U,{children:t("Shard")}),(0,r.jsx)(U,{children:t("User")})]})}),(0,r.jsx)(Ne,{children:d.map((w,C)=>(0,r.jsx)(Oe,{row:w},`${String(w.ts)}-${String(C)}`))})]})}),n!==void 0&&(0,r.jsx)("div",{children:(0,r.jsx)(ge,{"data-testid":"lg-archive-more",disabled:v,onClick:I,size:"sm",variant:"outline",children:t(v?"Loading\u2026":"Load more")})})]})},"De"),Ue=N(c=>{let e=(0,_.c)(11),{level:t,onToggle:s,selected:i}=c,o;e[0]!==t||e[1]!==s?(o=N(()=>{s(t)},"o"),e[0]=t,e[1]=s,e[2]=o):o=e[2];let m=o,p=i?"border-border bg-muted font-medium":"border-input text-muted-foreground",f;e[3]!==p?(f=G("rounded-md border px-2 py-1 text-xs",p),e[3]=p,e[4]=f):f=e[4];let n=`logs-level-${t}`,l;return e[5]!==t||e[6]!==m||e[7]!==i||e[8]!==f||e[9]!==n?(l=(0,r.jsx)("button",{"aria-pressed":i,className:f,"data-testid":n,onClick:m,type:"button",children:t}),e[5]=t,e[6]=m,e[7]=i,e[8]=f,e[9]=n,e[10]=l):l=e[10],l},"Ve"),ze=N(c=>{let e=(0,_.c)(68),{levelFilter:t,onLogPathChange:s,onSearchChange:i,onTimeRangeChange:o,onToggleLevel:m,onToggleSummary:p,pathFilter:f,search:n,showSummary:l,timeRange:v}=c,a=B(),d;e[0]!==a?(d=a("Search messages"),e[0]=a,e[1]=d):d=e[1];let u;e[2]!==a?(u=a("search message"),e[2]=a,e[3]=u):u=e[3];let h;e[4]!==i||e[5]!==n||e[6]!==d||e[7]!==u?(h=(0,r.jsx)(D,{"aria-label":d,className:"h-8 w-48","data-testid":"lg-search",onChange:i,placeholder:u,value:n}),e[4]=i,e[5]=n,e[6]=d,e[7]=u,e[8]=h):h=e[8];let b;e[9]!==a?(b=a("Function path"),e[9]=a,e[10]=b):b=e[10];let g;e[11]!==a?(g=a("filter path"),e[11]=a,e[12]=g):g=e[12];let x;e[13]!==s||e[14]!==f||e[15]!==b||e[16]!==g?(x=(0,r.jsx)(D,{"aria-label":b,className:"h-8 w-40","data-testid":"logs-path-filter",onChange:s,placeholder:g,value:f}),e[13]=s,e[14]=f,e[15]=b,e[16]=g,e[17]=x):x=e[17];let y;e[18]!==a?(y=a("Level filter"),e[18]=a,e[19]=y):y=e[19];let S;e[20]!==t||e[21]!==m?(S=ue.map(j=>(0,r.jsx)(Ue,{level:j,onToggle:m,selected:t.has(j)},j)),e[20]=t,e[21]=m,e[22]=S):S=e[22];let R;e[23]!==y||e[24]!==S?(R=(0,r.jsx)("div",{"aria-label":y,className:"inline-flex items-center gap-1","data-testid":"logs-level-filter",role:"group",children:S}),e[23]=y,e[24]=S,e[25]=R):R=e[25];let L;e[26]!==a?(L=a("Time range"),e[26]=a,e[27]=L):L=e[27];let k;e[28]!==a?(k=a("All time"),e[28]=a,e[29]=k):k=e[29];let I;e[30]!==k?(I=(0,r.jsx)("option",{value:"all",children:k}),e[30]=k,e[31]=I):I=e[31];let w;e[32]!==a?(w=a("Last 5m"),e[32]=a,e[33]=w):w=e[33];let C;e[34]!==w?(C=(0,r.jsx)("option",{value:"5m",children:w}),e[34]=w,e[35]=C):C=e[35];let q;e[36]!==a?(q=a("Last 15m"),e[36]=a,e[37]=q):q=e[37];let F;e[38]!==q?(F=(0,r.jsx)("option",{value:"15m",children:q}),e[38]=q,e[39]=F):F=e[39];let E;e[40]!==a?(E=a("Last hour"),e[40]=a,e[41]=E):E=e[41];let K;e[42]!==E?(K=(0,r.jsx)("option",{value:"1h",children:E}),e[42]=E,e[43]=K):K=e[43];let $;e[44]!==o||e[45]!==L||e[46]!==I||e[47]!==C||e[48]!==F||e[49]!==K||e[50]!==v?($=(0,r.jsxs)("select",{"aria-label":L,className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"logs-time-range",onChange:o,value:v,children:[I,C,F,K]}),e[44]=o,e[45]=L,e[46]=I,e[47]=C,e[48]=F,e[49]=K,e[50]=v,e[51]=$):$=e[51];let V=l?"border-border bg-muted font-medium":"border-input text-muted-foreground",O;e[52]!==V?(O=G("h-8 rounded-md border px-3 text-sm",V),e[52]=V,e[53]=O):O=e[53];let A;e[54]!==l||e[55]!==a?(A=a(l?"List":"Summary"),e[54]=l,e[55]=a,e[56]=A):A=e[56];let M;e[57]!==p||e[58]!==l||e[59]!==O||e[60]!==A?(M=(0,r.jsx)("button",{"aria-pressed":l,className:O,"data-testid":"logs-summary-toggle",onClick:p,type:"button",children:A}),e[57]=p,e[58]=l,e[59]=O,e[60]=A,e[61]=M):M=e[61];let W;return e[62]!==$||e[63]!==M||e[64]!==h||e[65]!==x||e[66]!==R?(W=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[h,x,R,$,M]}),e[62]=$,e[63]=M,e[64]=h,e[65]=x,e[66]=R,e[67]=W):W=e[67],W},"je"),je=N(c=>{let e=(0,_.c)(53),{onOutcomeChange:t,onPathChange:s,onTableChange:i,onUserChange:o,outcomeFilter:m,pathPrefix:p,tableFilter:f,userIdFilter:n}=c,l=B(),v;e[0]!==l?(v=l("Function path"),e[0]=l,e[1]=v):v=e[1];let a;e[2]!==l?(a=l("file:function"),e[2]=l,e[3]=a):a=e[3];let d;e[4]!==s||e[5]!==p||e[6]!==v||e[7]!==a?(d=(0,r.jsx)(D,{"aria-label":v,className:"h-8 w-44","data-testid":"lg-req-path",onChange:s,placeholder:a,value:p}),e[4]=s,e[5]=p,e[6]=v,e[7]=a,e[8]=d):d=e[8];let u;e[9]!==l?(u=l("User id"),e[9]=l,e[10]=u):u=e[10];let h;e[11]!==l?(h=l("userId"),e[11]=l,e[12]=h):h=e[12];let b;e[13]!==o||e[14]!==u||e[15]!==h||e[16]!==n?(b=(0,r.jsx)(D,{"aria-label":u,className:"h-8 w-32","data-testid":"lg-req-user",onChange:o,placeholder:h,value:n}),e[13]=o,e[14]=u,e[15]=h,e[16]=n,e[17]=b):b=e[17];let g;e[18]!==l?(g=l("Table touched"),e[18]=l,e[19]=g):g=e[19];let x;e[20]!==l?(x=l("table"),e[20]=l,e[21]=x):x=e[21];let y;e[22]!==i||e[23]!==g||e[24]!==x||e[25]!==f?(y=(0,r.jsx)(D,{"aria-label":g,className:"h-8 w-32","data-testid":"lg-req-table",onChange:i,placeholder:x,value:f}),e[22]=i,e[23]=g,e[24]=x,e[25]=f,e[26]=y):y=e[26];let S;e[27]!==l?(S=l("Outcome filter"),e[27]=l,e[28]=S):S=e[28];let R;e[29]!==l?(R=l("all"),e[29]=l,e[30]=R):R=e[30];let L;e[31]!==R?(L=(0,r.jsx)("option",{value:"all",children:R}),e[31]=R,e[32]=L):L=e[32];let k;e[33]!==l?(k=l("ok"),e[33]=l,e[34]=k):k=e[34];let I;e[35]!==k?(I=(0,r.jsx)("option",{value:"ok",children:k}),e[35]=k,e[36]=I):I=e[36];let w;e[37]!==l?(w=l("error"),e[37]=l,e[38]=w):w=e[38];let C;e[39]!==w?(C=(0,r.jsx)("option",{value:"error",children:w}),e[39]=w,e[40]=C):C=e[40];let q;e[41]!==t||e[42]!==m||e[43]!==S||e[44]!==L||e[45]!==I||e[46]!==C?(q=(0,r.jsxs)("select",{"aria-label":S,className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"lg-req-outcome",onChange:t,value:m,children:[L,I,C]}),e[41]=t,e[42]=m,e[43]=S,e[44]=L,e[45]=I,e[46]=C,e[47]=q):q=e[47];let F;return e[48]!==q||e[49]!==d||e[50]!==b||e[51]!==y?(F=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[d,b,y,q]}),e[48]=q,e[49]=d,e[50]=b,e[51]=y,e[52]=F):F=e[52],F},"Be"),Ie=N(c=>{let e=(0,_.c)(7),{bucket:t}=c,s;e[0]!==t.key?(s=(0,r.jsx)("span",{className:"truncate text-muted-foreground",role:"gridcell",children:t.key}),e[0]=t.key,e[1]=s):s=e[1];let i;e[2]!==t.count?(i=(0,r.jsx)("span",{className:"shrink-0 tabular-nums",role:"gridcell",children:t.count}),e[2]=t.count,e[3]=i):i=e[3];let o;return e[4]!==s||e[5]!==i?(o=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-4 px-3 py-1 font-mono text-xs","data-testid":"logs-summary-row",role:"row",children:[s,i]}),e[4]=s,e[5]=i,e[6]=o):o=e[6],o},"ve"),Be=N(c=>{let e=(0,_.c)(31),{summary:t}=c,s=B(),i;e[0]!==t.total||e[1]!==s?(i=s("{count} entries",{count:t.total}),e[0]=t.total,e[1]=s,e[2]=i):i=e[2];let o;e[3]!==i?(o=(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"logs-summary-total",children:i}),e[3]=i,e[4]=o):o=e[4];let m;e[5]!==s?(m=s("By level"),e[5]=s,e[6]=m):m=e[6];let p;e[7]!==m?(p=(0,r.jsx)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:m}),e[7]=m,e[8]=p):p=e[8];let f;e[9]!==t.byLevel?(f=t.byLevel.map(We),e[9]=t.byLevel,e[10]=f):f=e[10];let n;e[11]!==f?(n=(0,r.jsx)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-levels",role:"grid",children:f}),e[11]=f,e[12]=n):n=e[12];let l;e[13]!==p||e[14]!==n?(l=(0,r.jsxs)("div",{children:[p,n]}),e[13]=p,e[14]=n,e[15]=l):l=e[15];let v;e[16]!==s?(v=s("By function"),e[16]=s,e[17]=v):v=e[17];let a;e[18]!==v?(a=(0,r.jsx)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v}),e[18]=v,e[19]=a):a=e[19];let d;e[20]!==t.byPath?(d=t.byPath.map(Ge),e[20]=t.byPath,e[21]=d):d=e[21];let u;e[22]!==d?(u=(0,r.jsx)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-paths",role:"grid",children:d}),e[22]=d,e[23]=u):u=e[23];let h;e[24]!==u||e[25]!==a?(h=(0,r.jsxs)("div",{children:[a,u]}),e[24]=u,e[25]=a,e[26]=h):h=e[26];let b;return e[27]!==h||e[28]!==o||e[29]!==l?(b=(0,r.jsxs)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"logs-summary",children:[o,l,h]}),e[27]=h,e[28]=o,e[29]=l,e[30]=b):b=e[30],b},"ze");function We(c){return(0,r.jsx)(Ie,{bucket:c},c.key)}N(We,"Ge");function Ge(c){return(0,r.jsx)(Ie,{bucket:c},c.key)}N(Ge,"We");var Ve=N(c=>{let e=(0,_.c)(46),{liveError:t,onShardKeyChange:s,onShowArchive:i,onShowErrors:o,onShowRequests:m,shardKey:p,view:f}=c,n=B(),l=f==="requests",v=f==="requests"?"bg-muted font-medium":"text-muted-foreground",a;e[0]!==v?(a=G("px-3 py-1 text-sm",v),e[0]=v,e[1]=a):a=e[1];let d;e[2]!==n?(d=n("Requests"),e[2]=n,e[3]=d):d=e[3];let u;e[4]!==m||e[5]!==l||e[6]!==a||e[7]!==d?(u=(0,r.jsx)("button",{"aria-selected":l,className:a,"data-testid":"lg-view-requests",onClick:m,role:"tab",type:"button",children:d}),e[4]=m,e[5]=l,e[6]=a,e[7]=d,e[8]=u):u=e[8];let h=f==="errors",b=f==="errors"?"bg-muted font-medium":"text-muted-foreground",g;e[9]!==b?(g=G("px-3 py-1 text-sm",b),e[9]=b,e[10]=g):g=e[10];let x;e[11]!==n?(x=n("Errors"),e[11]=n,e[12]=x):x=e[12];let y;e[13]!==o||e[14]!==h||e[15]!==g||e[16]!==x?(y=(0,r.jsx)("button",{"aria-selected":h,className:g,"data-testid":"lg-view-errors",onClick:o,role:"tab",type:"button",children:x}),e[13]=o,e[14]=h,e[15]=g,e[16]=x,e[17]=y):y=e[17];let S=f==="archive",R=f==="archive"?"bg-muted font-medium":"text-muted-foreground",L;e[18]!==R?(L=G("px-3 py-1 text-sm",R),e[18]=R,e[19]=L):L=e[19];let k;e[20]!==n?(k=n("Archive"),e[20]=n,e[21]=k):k=e[21];let I;e[22]!==i||e[23]!==S||e[24]!==L||e[25]!==k?(I=(0,r.jsx)("button",{"aria-selected":S,className:L,"data-testid":"lg-view-archive",onClick:i,role:"tab",type:"button",children:k}),e[22]=i,e[23]=S,e[24]=L,e[25]=k,e[26]=I):I=e[26];let w;e[27]!==y||e[28]!==I||e[29]!==u?(w=(0,r.jsxs)("div",{className:"inline-flex overflow-hidden rounded-lg border border-border",role:"tablist",children:[u,y,I]}),e[27]=y,e[28]=I,e[29]=u,e[30]=w):w=e[30];let C;e[31]!==s||e[32]!==p?(C=(0,r.jsx)(ve,{onChange:s,testId:"lg-shard-input",value:p}),e[31]=s,e[32]=p,e[33]=C):C=e[33];let q;e[34]!==t||e[35]!==f?(q=f!=="archive"&&(0,r.jsx)(Ce,{message:t,prefix:"lg"}),e[34]=t,e[35]=f,e[36]=q):q=e[36];let F;e[37]!==n?(F=n("Open in Cloudflare"),e[37]=n,e[38]=F):F=e[38];let E;e[39]!==F?(E=(0,r.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"lg-cf-link",href:de,rel:"noreferrer",target:"_blank",children:F}),e[39]=F,e[40]=E):E=e[40];let K;return e[41]!==w||e[42]!==C||e[43]!==q||e[44]!==E?(K=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[w,C,q,E]}),e[41]=w,e[42]=C,e[43]=q,e[44]=E,e[45]=K):K=e[45],K},"Qe"),ce=400,Qe=36,Ye={height:ce,overflow:"auto"},Te={left:0,position:"absolute",top:0,width:"100%"},He={error:"destructive",ok:"secondary"},Je=N(c=>{let e=(0,_.c)(26),{entry:t,index:s,measureRef:i,start:o}=c,m=`translateY(${String(o)}px)`,p;e[0]!==m?(p={...Te,transform:m},e[0]=m,e[1]=p):p=e[1];let f=p,n;e[2]!==t.fields?(n=X(t.fields),e[2]=t.fields,e[3]=n):n=e[3];let l=n,v;e[4]!==t.timestamp?(v=new Date(t.timestamp).toLocaleString(),e[4]=t.timestamp,e[5]=v):v=e[5];let a;e[6]!==v?(a=(0,r.jsx)("span",{className:"w-44 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:v}),e[6]=v,e[7]=a):a=e[7];let d=Re[t.level],u;e[8]!==t.level||e[9]!==d?(u=(0,r.jsx)("span",{className:"w-20 shrink-0",role:"gridcell",children:(0,r.jsx)(J,{variant:d,children:t.level})}),e[8]=t.level,e[9]=d,e[10]=u):u=e[10];let h=t.functionPath??"\u2014",b;e[11]!==h?(b=(0,r.jsx)("span",{className:"w-48 shrink-0 truncate text-muted-foreground",role:"gridcell",children:h}),e[11]=h,e[12]=b):b=e[12];let g;e[13]!==l?(g=l===""?null:(0,r.jsx)("span",{className:"ml-2 text-muted-foreground","data-testid":"lg-fields",children:l}),e[13]=l,e[14]=g):g=e[14];let x;e[15]!==t.message||e[16]!==g?(x=(0,r.jsxs)("span",{className:"flex-1 truncate",role:"gridcell",children:[t.message,g]}),e[15]=t.message,e[16]=g,e[17]=x):x=e[17];let y;return e[18]!==s||e[19]!==i||e[20]!==f||e[21]!==x||e[22]!==a||e[23]!==u||e[24]!==b?(y=(0,r.jsxs)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":s,"data-testid":"lg-row",ref:i,role:"row",style:f,children:[a,u,b,x]}),e[18]=s,e[19]=i,e[20]=f,e[21]=x,e[22]=a,e[23]=u,e[24]=b,e[25]=y):y=e[25],y},"Xe"),ke=N(c=>c.length===0?"\u2014":c.join(", "),"ce"),Ze=N(c=>{let e=(0,_.c)(37),{entry:t,index:s,measureRef:i,start:o}=c,m=`translateY(${String(o)}px)`,p;e[0]!==m?(p={...Te,transform:m},e[0]=m,e[1]=p):p=e[1];let f=p,n;e[2]!==t.ts?(n=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=n):n=e[3];let l;e[4]!==n?(l=(0,r.jsx)("span",{className:"w-40 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:n}),e[4]=n,e[5]=l):l=e[5];let v=He[t.outcome],a;e[6]!==t.outcome||e[7]!==v?(a=(0,r.jsx)("span",{className:"w-16 shrink-0",role:"gridcell",children:(0,r.jsx)(J,{variant:v,children:t.outcome})}),e[6]=t.outcome,e[7]=v,e[8]=a):a=e[8];let d;e[9]!==t.functionPath?(d=(0,r.jsx)("span",{className:"w-44 shrink-0 truncate",role:"gridcell",title:t.functionPath,children:t.functionPath}),e[9]=t.functionPath,e[10]=d):d=e[10];let u=t.shardKey??"\u2014",h;e[11]!==u?(h=(0,r.jsx)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:u}),e[11]=u,e[12]=h):h=e[12];let b=t.userId??"\u2014",g;e[13]!==b?(g=(0,r.jsx)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:b}),e[13]=b,e[14]=g):g=e[14];let x;e[15]!==t.durationMs?(x=Math.round(t.durationMs),e[15]=t.durationMs,e[16]=x):x=e[16];let y=`${String(x)}ms`,S;e[17]!==y?(S=(0,r.jsx)("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:y}),e[17]=y,e[18]=S):S=e[18];let R;e[19]!==t.errorMessage||e[20]!==t.outcome||e[21]!==t.tablesRead||e[22]!==t.tablesWritten?(R=t.outcome==="error"&&t.errorMessage!==void 0?t.errorMessage:`r:${ke(t.tablesRead)} \xB7 w:${ke(t.tablesWritten)}`,e[19]=t.errorMessage,e[20]=t.outcome,e[21]=t.tablesRead,e[22]=t.tablesWritten,e[23]=R):R=e[23];let L;e[24]!==R?(L=(0,r.jsx)("span",{className:"flex-1 truncate text-muted-foreground",role:"gridcell",children:R}),e[24]=R,e[25]=L):L=e[25];let k;return e[26]!==s||e[27]!==i||e[28]!==f||e[29]!==g||e[30]!==S||e[31]!==L||e[32]!==l||e[33]!==a||e[34]!==d||e[35]!==h?(k=(0,r.jsxs)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":s,"data-testid":"lg-req-row",ref:i,role:"row",style:f,children:[l,a,d,h,g,S,L]}),e[26]=s,e[27]=i,e[28]=f,e[29]=g,e[30]=S,e[31]=L,e[32]=l,e[33]=a,e[34]=d,e[35]=h,e[36]=k):k=e[36],k},"Ze"),Pe=N(c=>{let{entries:e}=c??{};return Array.isArray(e)?e:[]},"ue"),Xe=N(c=>{let e={};return c.functionPathPrefix.trim()!==""&&(e.functionPathPrefix=c.functionPathPrefix.trim()),c.userId.trim()!==""&&(e.userId=c.userId.trim()),c.tableTouched.trim()!==""&&(e.tableTouched=c.tableTouched.trim()),(c.outcome==="ok"||c.outcome==="error")&&(e.outcome=c.outcome),e},"et"),et={"5m":300*1e3,"15m":900*1e3,"1h":3600*1e3},tt=N((c,e)=>{let t=e.search.trim().toLowerCase(),s=e.path.trim().toLowerCase(),i=e.range==="all"?Number.NEGATIVE_INFINITY:e.now-et[e.range];return c.filter(o=>e.levels.size>0&&!e.levels.has(o.level)||o.timestamp<i||s!==""&&!(o.functionPath??"").toLowerCase().includes(s)?!1:t===""||o.message.toLowerCase().includes(t)||X(o.fields).toLowerCase().includes(t))},"rt"),rt="\u2014",lt=N(c=>{let e=new Map,t=new Map;for(let o of c){e.set(o.level,(e.get(o.level)??0)+1);let m=o.functionPath??rt;t.set(m,(t.get(m)??0)+1)}let s=ue.filter(o=>e.has(o)).map(o=>({count:e.get(o)??0,key:o})),i=[...t.entries()].map(([o,m])=>({count:m,key:o})).toSorted((o,m)=>m.count===o.count?o.key.localeCompare(m.key):m.count-o.count);return{byLevel:s,byPath:i,total:c.length}},"at"),Lt=N(({initialShardKey:c})=>{let e=B(),[t,s]=(0,T.useState)("requests"),{queryShardKey:i,setShardKey:o,shardKey:m}=be(c),[p,f]=(0,T.useState)(""),[n,l]=(0,T.useState)(()=>new Set),[v,a]=(0,T.useState)(""),[d,u]=(0,T.useState)("all"),[h,b]=(0,T.useState)(!1),[g,x]=(0,T.useState)(""),[y,S]=(0,T.useState)(""),[R,L]=(0,T.useState)(""),[k,I]=(0,T.useState)("all"),w=Xe({functionPathPrefix:g,outcome:k,tableTouched:R,userId:y}),C=oe(se.getRequestLog,w,{enabled:t==="requests",live:!0,shardKey:i}),q=oe(se.getLogs,{},{enabled:t==="errors",live:!0,shardKey:i}),F=t==="requests"?C:q,{error:E,errorSource:K,isLoading:$,liveError:V}=F,O=Pe(q.data),A=Pe(C.data);(0,T.useEffect)(()=>{F.data!==void 0&&pe(i)},[F.data,i]);let M=tt(O,{levels:n,now:Date.now(),path:v,range:d,search:p}),W=lt(M),j=t==="requests"?A.length:M.length,ee=t==="errors"&&h,Q=(0,T.useMemo)(()=>E!==null?"error":j===0?$?ee?"summary":"list":"empty":ee?"summary":"list",[j,$,E,ee]),me=(0,T.useRef)(null),Y=Se({count:j,estimateSize:N(()=>Qe,"estimateSize"),getScrollElement:N(()=>me.current,"getScrollElement"),initialRect:{height:ce,width:800},observeElementRect:N((P,te)=>Le(P,te,ce),"observeElementRect"),overscan:8}),qe=Y.getVirtualItems(),Fe={height:Y.getTotalSize(),position:"relative",width:"100%"};return(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-logs",children:[(0,r.jsx)(Ve,{liveError:V,onShardKeyChange:o,onShowArchive:N(()=>{s("archive"),b(!1)},"onShowArchive"),onShowErrors:N(()=>{s("errors"),b(!1)},"onShowErrors"),onShowRequests:N(()=>{s("requests"),b(!1)},"onShowRequests"),shardKey:m,view:t}),t==="errors"&&(0,r.jsx)(ze,{levelFilter:n,onLogPathChange:N(P=>{a(P.target.value)},"onLogPathChange"),onSearchChange:N(P=>{f(P.target.value)},"onSearchChange"),onTimeRangeChange:N(P=>{u(P.target.value)},"onTimeRangeChange"),onToggleLevel:N(P=>{l(te=>{let H=new Set(te);return H.has(P)?H.delete(P):H.add(P),H})},"onToggleLevel"),onToggleSummary:N(()=>{b(P=>!P)},"onToggleSummary"),pathFilter:v,search:p,showSummary:h,timeRange:d}),t==="requests"&&(0,r.jsx)(je,{onOutcomeChange:N(P=>{I(P.target.value)},"onOutcomeChange"),onPathChange:N(P=>{x(P.target.value)},"onPathChange"),onTableChange:N(P=>{L(P.target.value)},"onTableChange"),onUserChange:N(P=>{S(P.target.value)},"onUserChange"),outcomeFilter:k,pathPrefix:g,tableFilter:R,userIdFilter:y}),t==="archive"?(0,r.jsx)(De,{shardKey:i}):(0,r.jsxs)(r.Fragment,{children:[Q==="error"&&(0,r.jsx)(xe,{error:K,testId:"lg-error"}),Q==="empty"&&(0,r.jsx)(Z,{description:e("Function and request logs for this shard show up here as your app handles traffic."),icon:(0,r.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M4 5h16M4 12h16M4 19h10"})}),testId:"lg-empty",title:e("No logs.")}),Q==="summary"&&(0,r.jsx)(Be,{summary:W}),Q==="list"&&(0,r.jsx)("div",{className:"rounded-xl border border-border shadow-xs","data-testid":"lg-scroll",ref:me,style:Ye,children:(0,r.jsx)("div",{"aria-label":e("Recent logs"),"data-testid":"lg-table",role:"grid",style:Fe,children:qe.map(P=>t==="requests"?(0,r.jsx)(Ze,{entry:A[P.index],index:P.index,measureRef:Y.measureElement,start:P.start},P.key):(0,r.jsx)(Je,{entry:M[P.index],index:P.index,measureRef:Y.measureElement,start:P.start},P.key))})})]})]})},"Pt");export{Lt as LogsPanel,tt as filterLogs,lt as summarizeLogs};
@@ -1 +1 @@
1
- import{R as Q}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as W}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{f as F}from"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as Z}from"./chunk-XQCVZAGU.js";import{a as q,b as L,c as B,d as f,e as c,f as d}from"./chunk-MIQTKZAR.js";import{a as I,e as j}from"./chunk-UZERI5YC.js";import{d as K,h as S,l as $,m as V}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as h,e as C,f as R,g as P,h as U}from"./chunk-3XIESWL4.js";var A=C(P(),1);var n=C(R(),1);var e=C(U(),1);var X=10,g=h(v=>{let l=(0,A.c)(7),{label:m,value:a}=v,r;l[0]!==m?(r=(0,e.jsx)("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:m}),l[0]=m,l[1]=r):r=l[1];let p=a??"\u2014",s;l[2]!==p?(s=(0,e.jsx)("span",{className:"font-mono text-sm",children:p}),l[2]=p,l[3]=s):s=l[3];let u;return l[4]!==r||l[5]!==s?(u=(0,e.jsxs)("div",{className:"flex flex-col gap-0.5",children:[r,s]}),l[4]=r,l[5]=s,l[6]=u):u=l[6],u},"g"),se=h(({loadIndexes:v,runQuery:l}={})=>{let m=F(),a=K(),[r,p]=(0,n.useState)(null),[s,u]=(0,n.useState)(null),[N,E]=(0,n.useState)(null),[b,D]=(0,n.useState)(""),[x,y]=(0,n.useState)(null),[M,w]=(0,n.useState)(null),[T,z]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let t={cancelled:!1};return V((async()=>{try{let i=await(v??(()=>m.listVectorIndexes()))();t.cancelled||(p(i),u(null),E(k=>k??i[0]?.name??null))}catch(i){t.cancelled||(p(null),u(S(i)))}})()),()=>{t.cancelled=!0}},[m,v]);let o=r?.find(t=>t.name===N)??null,G=h(t=>{E(t.currentTarget.dataset.index??null),y(null),w(null)},"K"),H=h(t=>{D(t.target.value)},"T"),J=h(async()=>{let t=b.trim();if(!(N===null||t==="")){z(!0),w(null);try{let i=await(l??(k=>m.queryVectorIndex(k)))({name:N,text:t,topK:X});y(i)}catch(i){y(null),w(S(i))}z(!1)}},"Z"),O=h(()=>{V(J())},"z");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-vector-browser",children:[s!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"vector-error",role:"alert",children:s}),r!==null&&r.length===0&&(0,e.jsx)(Z,{description:a("Indexes declared with .vectorize() or defineVectorIndex() appear here."),icon:(0,e.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsx)("path",{d:"M4 7l8-4 8 4-8 4-8-4Zm0 5 8 4 8-4M4 17l8 4 8-4"})}),testId:"vector-empty",title:a("No vector indexes.")}),r!==null&&r.length>0&&(0,e.jsx)(I,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(q,{"data-testid":"vector-table",children:[(0,e.jsx)(L,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(c,{children:a("name")}),(0,e.jsx)(c,{children:a("table")}),(0,e.jsx)(c,{children:a("dimensions")}),(0,e.jsx)(c,{children:a("metric")}),(0,e.jsx)(c,{children:a("vectors")})]})}),(0,e.jsx)(B,{children:r.map(t=>(0,e.jsxs)(f,{className:t.name===N?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-index":t.name,"data-testid":`vector-row-${t.name}`,onClick:G,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:t.name}),(0,e.jsx)(d,{className:"font-mono text-xs",children:t.table}),(0,e.jsx)(d,{className:"tabular-nums",children:t.dimensions??"\u2014"}),(0,e.jsx)(d,{children:t.metric??"\u2014"}),(0,e.jsx)(d,{className:"tabular-nums",children:t.vectorsCount??"\u2014"})]},t.name))})]})})}),o!==null&&(0,e.jsxs)("section",{className:"border border-border bg-card p-3","data-testid":"vector-detail",children:[(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[(0,e.jsx)(g,{label:a("field"),value:o.field}),(0,e.jsx)(g,{label:a("dimensions"),value:o.dimensions}),(0,e.jsx)(g,{label:a("metric"),value:o.metric}),(0,e.jsx)(g,{label:a("vectors"),value:o.vectorsCount})]}),o.metadata!==void 0&&o.metadata.length>0&&(0,e.jsxs)("p",{className:"mt-3 text-xs text-muted-foreground","data-testid":"vector-metadata",children:[a("metadata"),": ",(0,e.jsx)("span",{className:"font-mono",children:o.metadata.join(", ")})]}),(0,e.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,e.jsx)(Q,{className:"min-w-[18rem] flex-1","data-testid":"vector-query-input",onChange:H,placeholder:a("Search by similarity\u2026"),value:b}),(0,e.jsx)(W,{"data-testid":"vector-search",disabled:T||b.trim()==="",onClick:O,children:a(T?"Searching\u2026":"Search")})]}),M!==null&&(0,e.jsx)("p",{className:"mt-2 text-sm text-destructive","data-testid":"vector-query-error",role:"alert",children:M}),x!==null&&x.length===0&&(0,e.jsx)("p",{className:"mt-2 text-sm text-muted-foreground","data-testid":"vector-no-matches",children:a("No matches.")}),x!==null&&x.length>0&&(0,e.jsx)(I,{className:"mt-3 overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(q,{"data-testid":"vector-matches",children:[(0,e.jsx)(L,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(c,{children:a("id")}),(0,e.jsx)(c,{children:a("score")}),(0,e.jsx)(c,{children:a("metadata")})]})}),(0,e.jsx)(B,{children:x.map(t=>(0,e.jsxs)(f,{"data-testid":`vector-match-${t.id}`,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:t.id}),(0,e.jsx)(d,{className:"tabular-nums",children:t.score.toFixed(4)}),(0,e.jsx)(d,{className:"max-w-md truncate font-mono text-xs",children:t.metadata===void 0?"\u2014":$(t.metadata)})]},t.id))})]})})})]})]})},"ce");export{se as VectorBrowser};
1
+ import{R as Q}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as W}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{f as F}from"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as Z}from"./chunk-XQCVZAGU.js";import{a as q,b as L,c as B,d as f,e as c,f as d}from"./chunk-MIQTKZAR.js";import{a as I,e as j}from"./chunk-UZERI5YC.js";import{d as K,h as S,l as $,m as V}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as h,e as C,f as R,g as P,h as U}from"./chunk-3XIESWL4.js";var A=C(P(),1);var n=C(R(),1);var e=C(U(),1);var X=10,g=h(v=>{let l=(0,A.c)(7),{label:m,value:a}=v,r;l[0]!==m?(r=(0,e.jsx)("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:m}),l[0]=m,l[1]=r):r=l[1];let p=a??"\u2014",s;l[2]!==p?(s=(0,e.jsx)("span",{className:"font-mono text-sm",children:p}),l[2]=p,l[3]=s):s=l[3];let u;return l[4]!==r||l[5]!==s?(u=(0,e.jsxs)("div",{className:"flex flex-col gap-0.5",children:[r,s]}),l[4]=r,l[5]=s,l[6]=u):u=l[6],u},"g"),se=h(({loadIndexes:v,runQuery:l}={})=>{let m=F(),a=K(),[r,p]=(0,n.useState)(null),[s,u]=(0,n.useState)(null),[N,E]=(0,n.useState)(null),[b,D]=(0,n.useState)(""),[x,y]=(0,n.useState)(null),[M,w]=(0,n.useState)(null),[T,z]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let t={cancelled:!1};return V((async()=>{try{let i=await(v??(()=>m.listVectorIndexes()))();t.cancelled||(p(i),u(null),E(k=>k??i[0]?.name??null))}catch(i){t.cancelled||(p(null),u(S(i)))}})()),()=>{t.cancelled=!0}},[m,v]);let o=r?.find(t=>t.name===N)??null,G=h(t=>{E(t.currentTarget.dataset.index??null),y(null),w(null)},"K"),H=h(t=>{D(t.target.value)},"T"),J=h(async()=>{let t=b.trim();if(!(N===null||t==="")){z(!0),w(null);try{let i=await(l??(k=>m.queryVectorIndex(k)))({name:N,text:t,topK:X});y(i)}catch(i){y(null),w(S(i))}z(!1)}},"Z"),O=h(()=>{V(J())},"z");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-vector-browser",children:[s!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"vector-error",role:"alert",children:s}),r!==null&&r.length===0&&(0,e.jsx)(Z,{description:a("Indexes declared with .vectorize() or defineVectorIndex() appear here."),icon:(0,e.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsx)("path",{d:"M4 7l8-4 8 4-8 4-8-4Zm0 5 8 4 8-4M4 17l8 4 8-4"})}),testId:"vector-empty",title:a("No vector indexes.")}),r!==null&&r.length>0&&(0,e.jsx)(I,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(q,{"data-testid":"vector-table",children:[(0,e.jsx)(L,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(c,{children:a("name")}),(0,e.jsx)(c,{children:a("table")}),(0,e.jsx)(c,{children:a("dimensions")}),(0,e.jsx)(c,{children:a("metric")}),(0,e.jsx)(c,{children:a("vectors")})]})}),(0,e.jsx)(B,{children:r.map(t=>(0,e.jsxs)(f,{className:t.name===N?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-index":t.name,"data-testid":`vector-row-${t.name}`,onClick:G,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:t.name}),(0,e.jsx)(d,{className:"font-mono text-xs",children:t.table}),(0,e.jsx)(d,{className:"tabular-nums",children:t.dimensions??"\u2014"}),(0,e.jsx)(d,{children:t.metric??"\u2014"}),(0,e.jsx)(d,{className:"tabular-nums",children:t.vectorsCount??"\u2014"})]},t.name))})]})})}),o!==null&&(0,e.jsxs)("section",{className:"border border-border bg-card p-3","data-testid":"vector-detail",children:[(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[(0,e.jsx)(g,{label:a("field"),value:o.field}),(0,e.jsx)(g,{label:a("dimensions"),value:o.dimensions}),(0,e.jsx)(g,{label:a("metric"),value:o.metric}),(0,e.jsx)(g,{label:a("vectors"),value:o.vectorsCount})]}),o.metadata!==void 0&&o.metadata.length>0&&(0,e.jsxs)("p",{className:"mt-3 text-xs text-muted-foreground","data-testid":"vector-metadata",children:[a("metadata"),": ",(0,e.jsx)("span",{className:"font-mono",children:o.metadata.join(", ")})]}),(0,e.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,e.jsx)(Q,{className:"min-w-[18rem] flex-1","data-testid":"vector-query-input",onChange:H,placeholder:a("Search by similarity\u2026"),value:b}),(0,e.jsx)(W,{"data-testid":"vector-search",disabled:T||b.trim()==="",onClick:O,children:a(T?"Searching\u2026":"Search")})]}),M!==null&&(0,e.jsx)("p",{className:"mt-2 text-sm text-destructive","data-testid":"vector-query-error",role:"alert",children:M}),x!==null&&x.length===0&&(0,e.jsx)("p",{className:"mt-2 text-sm text-muted-foreground","data-testid":"vector-no-matches",children:a("No matches.")}),x!==null&&x.length>0&&(0,e.jsx)(I,{className:"mt-3 overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(q,{"data-testid":"vector-matches",children:[(0,e.jsx)(L,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(c,{children:a("id")}),(0,e.jsx)(c,{children:a("score")}),(0,e.jsx)(c,{children:a("metadata")})]})}),(0,e.jsx)(B,{children:x.map(t=>(0,e.jsxs)(f,{"data-testid":`vector-match-${t.id}`,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:t.id}),(0,e.jsx)(d,{className:"tabular-nums",children:t.score.toFixed(4)}),(0,e.jsx)(d,{className:"max-w-md truncate font-mono text-xs",children:t.metadata===void 0?"\u2014":$(t.metadata)})]},t.id))})]})})})]})]})},"ce");export{se as VectorBrowser};
@@ -0,0 +1,14 @@
1
+ import{a}from"./chunk-3XIESWL4.js";var s="https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/",n="https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-1xxx-errors/",l={BAD_REQUEST:{status:400,title:"Bad request"},UNAUTHORIZED:{status:401,title:"Unauthorized"},FORBIDDEN:{status:403,title:"Forbidden"},NOT_FOUND:{status:404,title:"Not found"},CONFLICT:{hint:["Another write changed this row while your mutation was running (optimistic concurrency conflict).","","Re-read the row and retry the mutation with the fresh value. Lunora serializes a DO's mutations, so a persistent conflict usually means the handler conflicts **with itself** (e.g. a trigger or cascade touching the same row) \u2014 split that work rather than adding a retry loop."],status:409,title:"Conflict"},NOT_UNIQUE:{hint:["`.unique()` matched more than one document \u2014 it expects the query to identify at most one row.","","- If several matches are legitimate, use `.first()` (take one) or `.collect()` (take all) instead.","- Otherwise tighten the query (e.g. filter on a unique/indexed field) so it can only match one row."],status:400,title:"Query matched more than one document"},VALIDATION_ERROR:{status:400,title:"Validation failed"},TOO_MANY_REQUESTS:{status:429,title:"Too many requests"},UNPROCESSABLE:{status:422,title:"Unprocessable"},NOT_IMPLEMENTED:{status:501,title:"Not implemented"},FUNCTION_NOT_FOUND:{status:404,title:"Function not found"},METHOD_NOT_ALLOWED:{status:405,title:"Method not allowed"},PAYLOAD_TOO_LARGE:{status:413,title:"Payload too large"},INTERNAL:{internal:!0,status:500,title:"Internal error"},INTERNAL_SERVER_ERROR:{internal:!0,status:500,title:"Internal error"},RPC_FAILED:{internal:!0,status:500,title:"Internal error"},COUNT_RLS_UNSUPPORTED:{status:422,title:"count() is unsupported under an RLS policy"},MASK_UNSUPPORTED:{status:422,title:"Aggregation over a masked column is unsupported"},RELATION_PREDICATE_UNSUPPORTED:{status:422,title:"Relation predicate is unsupported in a write policy"},RLS_REQUIRED:{hint:["This table is secure-by-default: it has no `.public()` marker and no RLS policy resolved for the caller, so the read fails closed.","","Add a read policy with `.rls(...)`, or mark the table `.public()` if it is intentionally world-readable."],status:403,title:"RLS policy required"},RUN_DEPTH_EXCEEDED:{internal:!0,status:500,title:"Run depth exceeded"},TRANSACTION_LIMIT_EXCEEDED:{hint:["A single mutation may only read and write a bounded amount before it is stopped.","","Narrow the read with an index (`.withIndex(...)`) instead of scanning the table, or split the write across several mutations \u2014 for a large backfill use `defineMigration` + `lunora migrate up`, which batches and checkpoints for you.","","The ceilings are deliberately conservative \u2014 they exist to stop one request taking down the whole shard. A deployment that genuinely needs bigger transactions can raise them by overriding the `transactionLimits()` seam on its generated shard class."],status:413,title:"Transaction limit exceeded"},MIGRATION_NOT_FOUND:{status:404,title:"Data migration not found"},UNKNOWN_TABLE:{status:404,title:"Unknown table"},GLOBAL_TABLE_NOT_EDITABLE:{status:400,title:"Global table is not editable"},SHARD_ERROR:{status:503,title:"Shard error"},SHARD_UNAVAILABLE:{status:503,title:"Shard unavailable"},OFFLINE_IDENTITY_CHANGED:{status:409,title:"Offline identity changed"},CODEGEN_DIAGNOSTIC:{status:500,title:"Codegen diagnostic"},SCHEMA_SNAPSHOT_PARSE:{status:500,title:"Schema snapshot parse error"},ENV_INVALID:{internal:!0,status:500,title:"Invalid environment"},AUTH_HEADERS_MISSING:{internal:!0,status:500,title:"Auth headers missing"},EMAIL_DOMAIN_BLOCKED:{hint:["This address's domain is on the disposable/throwaway blocklist (or your configured deny-list).","","Sign up with a permanent mailbox. To tune the policy, pass `blockDisposable` / `allowDomains` / `denyDomains` to `emailGate(...)` (`@lunora/auth/email-guard`)."],status:400,title:"Email domain not allowed"},EMAIL_UNDELIVERABLE:{hint:["The address's domain publishes no MX (or fallback A/AAAA) records, so it can't receive mail.","","Check for a typo in the domain. MX verification is opt-in (`mx: true`) and needs DNS \u2014 leave it off on the edge path if DNS is unavailable."],status:400,title:"Email domain cannot receive mail"},ANALYTICS_SQL_ERROR:{status:502,title:"Analytics Engine SQL API error"},R2_SQL_ERROR:{status:502,title:"R2 SQL API error"},WORKFLOWS_REST_ERROR:{status:502,title:"Cloudflare Workflows REST API error"},ADMIN_FORBIDDEN:{status:403,title:"Admin access forbidden"},ADMIN_TOKEN_NOT_CONFIGURED:{status:400,title:"Admin token not configured"},AUTH_NOT_CONFIGURED:{status:400,title:"Auth admin not configured"},AUTH_OP_NOT_SUPPORTED:{status:400,title:"Auth admin operation not supported"},BACKUP_NOT_CONFIGURED:{status:500,title:"Scheduled backup not configured"},CRON_JOBS_NOT_CONFIGURED:{status:400,title:"Cron jobs not configured"},CRON_JOB_NOT_FOUND:{status:404,title:"Cron job not found"},EXPORT_TAP_NOT_CONFIGURED:{status:400,title:"Export tap not configured"},FUNCTIONS_NOT_CONFIGURED:{status:400,title:"Functions registry not configured"},GLOBALS_NOT_CONFIGURED:{status:400,title:"Global-table introspector not configured"},KV_NOT_CONFIGURED:{status:400,title:"KV introspector not configured"},MIGRATION_ID_REQUIRED:{status:400,title:"Migration id required"},PITR_UNAVAILABLE:{status:409,title:"Point-in-time recovery unavailable"},SCHEDULER_NOT_CONFIGURED:{status:400,title:"Scheduler not configured"},STORAGE_DELETE_NOT_CONFIGURED:{status:400,title:"Storage delete not configured"},STORAGE_NOT_CONFIGURED:{status:400,title:"Storage not configured"},STORAGE_UPLOAD_NOT_CONFIGURED:{status:400,title:"Storage upload not configured"},STORAGE_URL_NOT_CONFIGURED:{status:400,title:"Storage signed URL not configured"},VECTORS_NOT_CONFIGURED:{status:400,title:"Vector index introspector not configured"},VECTOR_QUERY_UNSUPPORTED:{status:400,title:"Vector index querying not enabled"},WORKFLOWS_NOT_CONFIGURED:{status:501,title:"Workflows not configured"},AUTH_AUDIT_NOT_CONFIGURED:{status:400,title:"Auth audit reader not configured"},AUTH_AUDIT_READ_FAILED:{internal:!0,status:500,title:"Auth audit read failed"},CRON_EXPR_INVALID:{status:500,title:"Invalid cron expression"},CRON_EXPR_NOT_STATIC:{status:500,title:"Cron expression is not statically analyzable"},CRON_JOB_FAILED:{internal:!0,status:500,title:"Cron job failed"},CRON_NAME_NOT_STATIC:{status:500,title:"Cron job name is not statically analyzable"},CRON_NON_STATIC_FN:{status:500,title:"Cron function reference is not statically analyzable"},CRON_NON_STATIC_VALUE:{status:500,title:"Cron value is not statically analyzable"},CRON_SCHEDULE_INVALID:{status:500,title:"Invalid cron schedule"},CRON_SCHEDULE_NOT_STATIC:{status:500,title:"Cron schedule is not statically analyzable"},DUPLICATE_CRON_NAME:{status:500,title:"Duplicate cron job name"},DUPLICATE_AGENT_BINDING:{status:500,title:"Duplicate agent binding"},DUPLICATE_AGENT_CLASS:{status:500,title:"Duplicate agent generated class name"},DUPLICATE_AGENT_NAME:{status:500,title:"Duplicate agent name"},DUPLICATE_MIGRATION_ID:{status:500,title:"Duplicate migration id"},DUPLICATE_QUEUE_BINDING:{status:500,title:"Duplicate queue binding"},DUPLICATE_QUEUE_NAME:{status:500,title:"Duplicate queue name"},DUPLICATE_WORKFLOW_CLASS:{status:500,title:"Duplicate workflow generated class name"},MIGRATION_ID_NOT_STATIC:{status:500,title:"Migration id is not statically analyzable"},NAMESPACE_COLLISION:{status:500,title:"Function namespace collision"},BAD_ROW:{status:400,title:"Malformed import row"},BAD_SUBSCRIPTION_ARGS:{status:400,title:"Invalid subscription arguments"},BATCH_LIMIT_EXCEEDED:{status:400,title:"Batch limit exceeded"},CROSS_SHARD_RANK_UNSUPPORTED:{status:400,title:"Cross-shard rank() is unsupported"},FORBIDDEN_FANOUT:{status:403,title:"Fan-out forbidden"},FORBIDDEN_ORIGIN:{status:403,title:"Origin forbidden"},FORBIDDEN_SHARD:{status:403,title:"Shard access forbidden"},GLOBAL_NOT_CONFIGURED:{status:400,title:"Global table import not configured"},INVALID_INPUT:{status:400,title:"Invalid input"},RATE_LIMITED:{status:429,title:"Rate limited"},SERVICE_UNAVAILABLE:{status:503,title:"Service unavailable"},SHAPE_CROSS_SHARD_JOIN:{status:400,title:"Shape cross-shard join is unsupported"},UNAUTHENTICATED:{status:401,title:"Unauthenticated"},UNKNOWN_COLUMN:{status:404,title:"Unknown column"},EXPIRED:{status:404,title:"Session expired"},NESTED_TRANSACTION:{internal:!0,status:500,title:"Nested transaction"},OUT_OF_ORDER:{status:409,title:"Out-of-order mutation"},SHAPE_GLOBAL_TOO_LARGE:{status:413,title:"Global shape too large"},SHAPE_NOT_FOUND:{status:404,title:"Shape not found"},SQL_UNAVAILABLE:{internal:!0,status:500,title:"SQL storage unavailable"},TOKEN_EXPIRED:{status:401,title:"Authentication token expired"},TOO_MANY_STREAMS:{status:429,title:"Too many streams"},UNKNOWN_ADMIN_OP:{status:404,title:"Unknown admin operation"},SOCKET_TAG_BUDGET_EXCEEDED:{status:400,title:"Socket tag budget exceeded"},RELAY_CANNOT_SEED:{status:500,title:"Relay cannot seed"},RELAY_MISCONFIGURED:{status:500,title:"Relay misconfigured"},RELAY_SEED_FAILED:{status:502,title:"Relay seed failed"},MISCONFIGURED:{internal:!0,status:500,title:"Worker misconfigured"},LUNORA_RUNTIME_UNAVAILABLE:{status:500,title:"Lunora runtime unavailable"},INTERNAL_ERROR:{internal:!0,status:500,title:"Internal error"},BROWSER_TIMEOUT:{status:504,title:"Browser operation timed out"},CLIENT_CLOSED:{status:400,title:"Client is closed"},HTTP_STREAM_BAD_CHUNK:{status:502,title:"Malformed HTTP stream chunk"},HTTP_STREAM_INTERRUPTED:{status:502,title:"HTTP stream interrupted"},HTTP_STREAM_MISSING_PARAM:{status:400,title:"HTTP stream missing path parameter"},HTTP_STREAM_NO_BODY:{status:502,title:"HTTP stream response has no body"},HTTP_STREAM_STATUS:{status:502,title:"HTTP stream request failed"},HTTP_STREAM_TRANSPORT:{status:502,title:"HTTP stream transport error"},STREAM_BACKPRESSURE:{status:429,title:"Stream backpressure"},STREAM_DISCONNECTED:{status:503,title:"Stream disconnected"},STREAM_QUEUE_OVERFLOW:{status:429,title:"Stream queue overflow"},UNKNOWN_MUTATION_FN:{status:404,title:"Unknown mutation function"}},f=a(e=>Object.hasOwn(l,e)?l[e]:void 0,"h");var m=[{body:["Lunora codegen couldn't find a schema to generate from.","","Create `lunora/schema.ts` exporting a `defineSchema(...)` call:","","```ts",'import { defineSchema, defineTable, v } from "@lunora/server";',"","export default defineSchema({"," messages: defineTable({ body: v.string() }),","});","```","","Or run `lunora init` to scaffold Lunora (a sample `lunora/schema.ts` included) into your app."].join(`
2
+ `),header:"No Lunora schema found",id:"lunora-schema-missing",test:a(e=>e.includes("defineSchema() not found")||e.includes("schema.ts not found at"),"test")},{body:["`defineSchema(...)` must be called with an **inline object literal** mapping table names to `defineTable(...)`:","","```ts","export default defineSchema({"," todos: defineTable({ title: v.string(), done: v.boolean() }),","});","```","","Codegen reads the schema statically, so it can't follow a variable or a spread \u2014 pass the object literal directly."].join(`
3
+ `),header:"`defineSchema()` needs an inline object literal",id:"lunora-schema-not-object-literal",test:a(e=>e.includes("defineSchema() expects an object literal"),"test")},{body:["This table name collides with a built-in `ctx.db` member, so the generated client can't expose it.","","Rename the table to anything that isn't a reserved name (the error lists them) \u2014 e.g. `userAccounts` instead of `insert`."].join(`
4
+ `),header:"Table name is reserved",id:"lunora-table-reserved",test:a(e=>e.includes("is reserved")&&e.includes("ctx.db"),"test")},{body:["Two tables resolve to the same name \u2014 usually a base table and a schema **extension** both defining it.","","Rename one of them, or drop the duplicate from the extension. Each table name must be unique across `defineSchema(...)` and every `.extend(...)`."].join(`
5
+ `),header:"Duplicate table name",id:"lunora-table-duplicate",test:a(e=>e.includes("already exists")&&e.includes(".extend("),"test")},{body:['`.jurisdiction(...)` accepts only a **string literal** of `"eu"`, `"us"`, or `"fedramp"`:',"","```ts",'defineSchema({ /* \u2026 */ }).jurisdiction("eu");',"```"].join(`
6
+ `),header:"Invalid `.jurisdiction(...)` value",id:"lunora-jurisdiction",test:a(e=>e.includes("unknown jurisdiction")||e.includes("jurisdiction")&&e.includes('"eu", "us", or "fedramp"'),"test")},{body:["The `unique` flag on an index must be a **literal** `true` or `false`, not a computed value \u2014 codegen needs to read it statically:","","```ts",'defineTable({ email: v.string() }).index("by_email", ["email"], { unique: true });',"```"].join(`
7
+ `),header:"`unique` must be a literal",id:"lunora-unique-literal",test:a(e=>e.includes("must be a literal")&&e.includes("unique"),"test")},{body:["A declared container/workflow class isn't re-exported by your worker entry, so `wrangler deploy` would reject it.","","Add the generated re-export shown in the error to your worker entry (e.g. `src/index.ts`):","","```ts",'export * from "./lunora/_generated/containers";',"```"].join(`
8
+ `),header:"Binding not exported by your worker entry",id:"lunora-worker-entry-export-gap",test:a(e=>e.includes("not exported by your worker entry"),"test")},{body:["A row with the same value already exists in a `unique` index.","","- If you meant to upsert, use `ctx.db.<table>().upsert(...)` (or `.patch(...)` an existing row) instead of `.insert(...)`.",`- Otherwise pick a value that isn't already taken, and consider surfacing a friendly "already exists" message to the user.`].join(`
9
+ `),header:"Unique constraint violation",id:"lunora-runtime-unique",test:a(e=>e.includes("unique constraint violation on"),"test")},{body:l.CONFLICT.hint.join(`
10
+ `),header:"Optimistic concurrency conflict",id:"lunora-runtime-occ",test:a(e=>e.includes("optimistic concurrency conflict"),"test")}],u=[{causes:"the origin returned an empty, unknown, or malformed response Cloudflare couldn't interpret (often an origin crash or an oversized response header)",code:"520",docsUrl:s,family:"5xx",fix:"check your origin's logs for a crash, ensure it returns a valid HTTP response, and keep response headers under the size limit",summary:"Cloudflare got an unknown/empty response from your origin web server.",title:"Web server returns an unknown error"},{causes:"the origin refused the connection \u2014 the web server is down, or a firewall is blocking Cloudflare's IP ranges",code:"521",docsUrl:s,family:"5xx",fix:"confirm the origin process is running and allowlist Cloudflare's published IP ranges in your firewall/security groups",summary:"Cloudflare could not connect to your origin because it refused the connection.",title:"Web server is down"},{causes:"Cloudflare could not establish a TCP connection to the origin in time \u2014 the origin is overloaded, a firewall is dropping packets, or the origin IP is wrong",code:"522",docsUrl:s,family:"5xx",fix:"verify the origin is reachable and not overloaded, and that the DNS record points at the correct origin IP",summary:"The connection to your origin timed out before it was established.",title:"Connection timed out"},{causes:"Cloudflare cannot route to the origin at all \u2014 a bad DNS record, an origin IP that changed, or invalid routing",code:"523",docsUrl:s,family:"5xx",fix:"verify the DNS A/AAAA record points at a reachable origin IP and that no upstream network is blocking Cloudflare",summary:"Cloudflare could not reach your origin server.",title:"Origin is unreachable"},{causes:"Cloudflare made a TCP connection but the origin did not return an HTTP response within 100 seconds \u2014 a slow handler or long-running request",code:"524",docsUrl:s,family:"5xx",fix:"speed up the slow origin handler, or move long work off the request path into a background job (a Durable Object, Queue, or Workflow)",summary:"Cloudflare connected to your origin but it did not respond in time.",title:"A timeout occurred"},{causes:"the TLS handshake between Cloudflare and the origin failed \u2014 a missing/invalid origin certificate, or a cipher/SNI mismatch under Full (Strict) SSL",code:"525",docsUrl:s,family:"5xx",fix:"install a valid certificate on the origin and align your Cloudflare SSL/TLS mode with the origin's certificate setup",summary:"The SSL handshake with your origin failed.",title:"SSL handshake failed"},{causes:"Cloudflare could not validate the origin's certificate under Full (Strict) SSL \u2014 it is expired, self-signed, or issued for the wrong hostname",code:"526",docsUrl:s,family:"5xx",fix:"install a valid, publicly-trusted certificate on the origin (or use a Cloudflare Origin CA cert), matching the request hostname",summary:"Cloudflare could not validate your origin's SSL certificate.",title:"Invalid SSL certificate"},{causes:"a DNS record points at a Cloudflare IP or another prohibited address instead of your real origin",code:"1000",docsUrl:n,family:"1xxx",fix:"point the DNS record at your real origin IP, not a Cloudflare-owned or loopback address",summary:"DNS points to a prohibited IP.",title:"DNS points to prohibited IP"},{causes:"Cloudflare could not resolve the requested hostname \u2014 a Worker fetched an unresolvable host, or a DNS record is misconfigured",code:"1001",docsUrl:n,family:"1xxx",fix:"check the hostname you're requesting and the DNS records for the zone resolve to a valid origin",summary:"Cloudflare could not resolve the origin DNS.",title:"DNS resolution error"},{causes:"a Worker or DNS record targets a restricted IP (for example a Cloudflare-owned or loopback address)",code:"1002",docsUrl:n,family:"1xxx",fix:"change the Worker fetch target or DNS record to a valid, non-restricted origin address",summary:"DNS points to a prohibited IP (Worker/restricted).",title:"DNS points to a prohibited IP"},{causes:"the visitor's IP was blocked by an IP Access Rule, WAF rule, or security configuration on the zone",code:"1006",docsUrl:n,family:"1xxx",fix:"review the zone's Firewall/WAF and IP Access Rules to see why the address was banned, and adjust if it was blocked in error",summary:"Access denied: the visitor's IP has been banned.",title:"Access denied: your IP has been banned"},{causes:"your Worker threw an unhandled JavaScript exception during the request",code:"1101",docsUrl:n,family:"1xxx",fix:"reproduce with `wrangler tail` (or the Workers Logs / Studio Logs panel) to get the stack trace, then handle the throwing code path",summary:"A Worker threw a JavaScript exception.",title:"Worker threw a JavaScript exception"},{causes:"the Worker used more CPU time than a single invocation is allowed \u2014 usually a hot loop or heavy synchronous work",code:"1102",docsUrl:n,family:"1xxx",fix:"reduce per-request CPU (optimize hot loops, avoid heavy synchronous work) or offload the heavy work to a Durable Object, Queue, or Workflow",summary:"A Worker exceeded its CPU-time resource limit.",title:"Worker exceeded resource limits"}],d=a(e=>e!==void 0&&e>="0"&&e<="9","l"),T=a((e,t)=>{for(let o=e.indexOf(t);o!==-1;o=e.indexOf(t,o+t.length))if(!d(e[o-1])&&!d(e[o+t.length]))return!0;return!1},"m"),O=a((e,t)=>{for(let o of[`error ${t}`,`error: ${t}`])for(let i=e.indexOf(o);i!==-1;i=e.indexOf(o,i+o.length))if(!d(e[i+o.length]))return!0;return!1},"_"),N=/error|cloudflare/iu,h=a(e=>({body:[e.summary,"",`**Likely cause:** ${e.causes}.`,"",`**Fix:** ${e.fix}.`,"",`See [Cloudflare's ${e.family} error docs](${e.docsUrl}).`].join(`
11
+ `),header:`Cloudflare Error ${e.code}: ${e.title}`,id:`cloudflare-error-${e.code}`}),"c"),E=a(e=>{if(!N.test(e))return;let t=e.toLowerCase(),o=t.includes("error"),i=t.includes("cloudflare");if(o){for(let r of u)if(O(t,r.code))return h(r)}if(i){for(let r of u)if(T(t,r.code))return h(r)}},"T"),A=a(e=>(typeof e=="string"?e:e.join(`
12
+ `)).split(`
13
+ `).filter(t=>!t.startsWith("```")).join(`
14
+ `).replaceAll(/\*\*(.+?)\*\*/gu,"$1").replaceAll(/`([^`]+)`/gu,"$1"),"A"),_=a(e=>{for(let t of m)if(t.test(e))return{body:t.body,header:t.header,id:t.id}},"u"),S=a(e=>_(e)??E(e),"O");var c=class extends Error{static{a(this,"c")}type="VisulimaError";hint;title;loc;code;status;docsUrl;data;constructor(t,o,i={}){let r=f(t);super(o??t,i.cause===void 0?void 0:{cause:i.cause}),this.name=i.name??"LunoraError",this.hint=i.hint??r?.hint,this.title=i.title??r?.title,this.loc=i.location,this.code=t,this.status=i.status??r?.status??500,this.docsUrl=i.docsUrl??r?.docsUrl,this.data=i.data}};export{A as a,S as b,c};
@@ -1 +1 @@
1
- import{c as k,d as S,e as T,f as w,h as X,i as B,j as E,k as L,l as g,m as G,n as I,o as O,p as W}from"./chunk-AQKXMWNF.js";import{d as j,l as q}from"./chunk-OG4N2XHD.js";import{a as x,e as C,g as F,h as H}from"./chunk-3XIESWL4.js";var K=C(F(),1);var e=C(H(),1);var R=50,$={value:{colors:{dark:["var(--chart-1)"],light:["var(--chart-1)"]},label:"value"}},z=x(o=>{let a=o.columns.find(t=>o.rows.length>0&&o.rows.every(l=>typeof l[t]=="number"))??null;return{label:o.columns.find(t=>t!==a)??null,value:a}},"I"),D=x(o=>{let a=(0,K.c)(3),{data:t,kind:l}=o,s;return a[0]!==t||a[1]!==l?(s=(0,e.jsx)(E,{className:"h-full w-full",config:$,children:l==="area"?(0,e.jsxs)(B,{data:t,children:[(0,e.jsx)(k,{vertical:!1}),(0,e.jsx)(w,{axisLine:!1,dataKey:"label",tickLine:!1}),(0,e.jsx)(g,{content:(0,e.jsx)(L,{})}),(0,e.jsx)(T,{dataKey:"value",fill:"var(--color-value-0)",fillOpacity:.2,stroke:"var(--color-value-0)",type:"monotone"})]}):(0,e.jsxs)(X,{data:t,children:[(0,e.jsx)(k,{vertical:!1}),(0,e.jsx)(w,{axisLine:!1,dataKey:"label",tickLine:!1}),(0,e.jsx)(g,{content:(0,e.jsx)(L,{})}),(0,e.jsx)(S,{dataKey:"value",dot:!1,stroke:"var(--color-value-0)",strokeWidth:2,type:"monotone"})]})}),a[0]=t,a[1]=l,a[2]=s):s=a[2],s},"W"),U=x(o=>{let a=(0,K.c)(21),{axes:t,result:l}=o,s=j(),u;a[0]!==l?(u=z(l),a[0]=l,a[1]=u):u=a[1];let N=u,m;a[2]!==l.columns?(m=new Set(l.columns),a[2]=l.columns,a[3]=m):m=a[3];let h=m,v=t!==void 0&&h.has(t.x)?t.x:N.label,f;a[4]!==t?.y||a[5]!==h?(f=t?.y.find(r=>h.has(r)),a[4]=t?.y,a[5]=h,a[6]=f):f=a[6];let A=f,d=A??N.value,p;a[7]!==v||a[8]!==l.rows||a[9]!==d?(p=d===null?[]:l.rows.slice(0,R).map((r,c)=>({label:v===null?`#${(c+1).toString()}`:q(r[v]),value:Number(r[d])||0})),a[7]=v,a[8]=l.rows,a[9]=d,a[10]=p):p=a[10];let y=p;if(d===null){let r;a[11]!==s?(r=s("No numeric column to chart."),a[11]=s,a[12]=r):r=a[12];let c;return a[13]!==r?(c=(0,e.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-chart-empty",children:r}),a[13]=r,a[14]=c):c=a[14],c}let n=t!==void 0&&A!==void 0?t.kind:"bar",i;a[15]!==y||a[16]!==n?(i=n==="bar"?(0,e.jsxs)(G,{className:"h-full w-full",config:$,data:y,children:[(0,e.jsx)(O,{dataKey:"label"}),(0,e.jsx)(I,{dataKey:"value"}),(0,e.jsx)(W,{})]}):(0,e.jsx)(D,{data:y,kind:n}),a[15]=y,a[16]=n,a[17]=i):i=a[17];let b;return a[18]!==n||a[19]!==i?(b=(0,e.jsx)("div",{className:"h-80 w-full p-3","data-chart-kind":n,"data-testid":"sql-chart",children:i}),a[18]=n,a[19]=i,a[20]=b):b=a[20],b},"R");export{U as a};
1
+ import{c as k,d as S,e as T,f as w,h as X,i as B,j as E,k as L,l as g,m as G,n as I,o as O,p as W}from"./chunk-S3DWUXGY.js";import{d as j,l as q}from"./chunk-OG4N2XHD.js";import{a as x,e as C,g as F,h as H}from"./chunk-3XIESWL4.js";var K=C(F(),1);var e=C(H(),1);var R=50,$={value:{colors:{dark:["var(--chart-1)"],light:["var(--chart-1)"]},label:"value"}},z=x(o=>{let a=o.columns.find(t=>o.rows.length>0&&o.rows.every(l=>typeof l[t]=="number"))??null;return{label:o.columns.find(t=>t!==a)??null,value:a}},"I"),D=x(o=>{let a=(0,K.c)(3),{data:t,kind:l}=o,s;return a[0]!==t||a[1]!==l?(s=(0,e.jsx)(E,{className:"h-full w-full",config:$,children:l==="area"?(0,e.jsxs)(B,{data:t,children:[(0,e.jsx)(k,{vertical:!1}),(0,e.jsx)(w,{axisLine:!1,dataKey:"label",tickLine:!1}),(0,e.jsx)(g,{content:(0,e.jsx)(L,{})}),(0,e.jsx)(T,{dataKey:"value",fill:"var(--color-value-0)",fillOpacity:.2,stroke:"var(--color-value-0)",type:"monotone"})]}):(0,e.jsxs)(X,{data:t,children:[(0,e.jsx)(k,{vertical:!1}),(0,e.jsx)(w,{axisLine:!1,dataKey:"label",tickLine:!1}),(0,e.jsx)(g,{content:(0,e.jsx)(L,{})}),(0,e.jsx)(S,{dataKey:"value",dot:!1,stroke:"var(--color-value-0)",strokeWidth:2,type:"monotone"})]})}),a[0]=t,a[1]=l,a[2]=s):s=a[2],s},"W"),U=x(o=>{let a=(0,K.c)(21),{axes:t,result:l}=o,s=j(),u;a[0]!==l?(u=z(l),a[0]=l,a[1]=u):u=a[1];let N=u,m;a[2]!==l.columns?(m=new Set(l.columns),a[2]=l.columns,a[3]=m):m=a[3];let h=m,v=t!==void 0&&h.has(t.x)?t.x:N.label,f;a[4]!==t?.y||a[5]!==h?(f=t?.y.find(r=>h.has(r)),a[4]=t?.y,a[5]=h,a[6]=f):f=a[6];let A=f,d=A??N.value,p;a[7]!==v||a[8]!==l.rows||a[9]!==d?(p=d===null?[]:l.rows.slice(0,R).map((r,c)=>({label:v===null?`#${(c+1).toString()}`:q(r[v]),value:Number(r[d])||0})),a[7]=v,a[8]=l.rows,a[9]=d,a[10]=p):p=a[10];let y=p;if(d===null){let r;a[11]!==s?(r=s("No numeric column to chart."),a[11]=s,a[12]=r):r=a[12];let c;return a[13]!==r?(c=(0,e.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-chart-empty",children:r}),a[13]=r,a[14]=c):c=a[14],c}let n=t!==void 0&&A!==void 0?t.kind:"bar",i;a[15]!==y||a[16]!==n?(i=n==="bar"?(0,e.jsxs)(G,{className:"h-full w-full",config:$,data:y,children:[(0,e.jsx)(O,{dataKey:"label"}),(0,e.jsx)(I,{dataKey:"value"}),(0,e.jsx)(W,{})]}):(0,e.jsx)(D,{data:y,kind:n}),a[15]=y,a[16]=n,a[17]=i):i=a[17];let b;return a[18]!==n||a[19]!==i?(b=(0,e.jsx)("div",{className:"h-80 w-full p-3","data-chart-kind":n,"data-testid":"sql-chart",children:i}),a[18]=n,a[19]=i,a[20]=b):b=a[20],b},"R");export{U as a};
@@ -1 +1 @@
1
- import{a as R}from"./chunk-54MMVNPT.js";import{a as E}from"./chunk-7AG3T4DK.js";import"./chunk-SFDOII3B.js";import"./chunk-SMIESS7P.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as x}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as T}from"./chunk-AHVDZWB3.js";import"./chunk-XXQUMVWH.js";import"./chunk-VORDESEQ.js";import"./chunk-QLQADHFE.js";import{a as v}from"./chunk-ERMTJYQF.js";import{c as b}from"./chunk-YGKR536O.js";import"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as w}from"./chunk-XQCVZAGU.js";import{a as A,b as j,c as I,d as g,e as c,f as a}from"./chunk-MIQTKZAR.js";import{a as y,e as N}from"./chunk-UZERI5YC.js";import{d as _,q as S}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as m,e as M,h as G}from"./chunk-3XIESWL4.js";var e=M(G(),1);var H=["subscriptions","events"],L={},k=new Set(["active","trialing"]),U=new Set(["past_due","unpaid"]),n=m((s,t)=>{if(s[t]!==void 0)return s[t];let p=s.__doc__;if(typeof p=="string")try{let o=JSON.parse(p);if(o!==null&&typeof o=="object"&&!Array.isArray(o))return o[t]}catch{}},"s"),i=m(s=>typeof s=="string"?s:typeof s=="number"||typeof s=="bigint"||typeof s=="boolean"?String(s):"","i"),$=m(s=>k.has(s)?"default":U.has(s)?"destructive":"outline","J"),te=m(({limit:s=100})=>{let t=_(),p=E(),{data:o}=b(v.listTables,L,{live:!0}),D=o!==void 0,O=Array.isArray(o)&&H.every(r=>o.some(l=>l.name===r)),f=p.payments&&O,d=b(v.readTablePage,{filters:[],limit:s,offset:0,orderBy:[],search:"",table:"subscriptions"},{enabled:f}),h=b(v.readTablePage,{filters:[],limit:25,offset:0,orderBy:[],search:"",table:"events"},{enabled:f});R(()=>{f&&(d.refetch(),h.refetch())},!0);let u=d.data?.rows??[],B=h.data?.rows??[],C=d.error??h.error,F=d.error===null?h.errorSource:d.errorSource,P=u.filter(r=>k.has(i(n(r,"state")))).length,J=B.toSorted((r,l)=>Number(n(l,"processedAt")??0)-Number(n(r,"processedAt")??0));return D&&!f?(0,e.jsx)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:(0,e.jsx)(w,{description:t("No @lunora/payment tables found in this deployment. Declare the store tables (subscriptions, events, \u2026) in lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:t("No payments configured")})}):(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[(0,e.jsx)("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:(0,e.jsxs)(y,{className:"justify-between gap-0 py-0",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Subscriptions")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:P}),(0,e.jsx)(x,{variant:"default",children:t("{count} active",{count:P})})]})]}),(0,e.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:t("{total} total",{total:u.length})})]})}),C===null?void 0:(0,e.jsx)(T,{error:F}),u.length===0&&!d.isLoading?(0,e.jsx)(w,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(y,{className:"overflow-hidden py-0",children:(0,e.jsx)(N,{className:"px-0",children:(0,e.jsxs)(A,{children:[(0,e.jsx)(j,{children:(0,e.jsxs)(g,{children:[(0,e.jsx)(c,{children:t("Provider")}),(0,e.jsx)(c,{children:t("Reference")}),(0,e.jsx)(c,{children:t("Plan")}),(0,e.jsx)(c,{children:t("State")}),(0,e.jsx)(c,{children:t("Renews")})]})}),(0,e.jsx)(I,{children:u.map(r=>{let l=i(n(r,"state"));return(0,e.jsxs)(g,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(a,{children:i(n(r,"provider"))}),(0,e.jsx)(a,{children:i(n(r,"referenceId"))}),(0,e.jsx)(a,{children:i(n(r,"priceId"))}),(0,e.jsx)(a,{children:(0,e.jsx)(x,{variant:$(l),children:l})}),(0,e.jsx)(a,{children:S(n(r,"currentPeriodEnd"))})]},i(n(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(y,{className:"overflow-hidden py-0",children:[(0,e.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Recent webhook events")})}),(0,e.jsx)(N,{className:"px-0",children:(0,e.jsx)(A,{children:(0,e.jsx)(I,{children:J.map(r=>(0,e.jsxs)(g,{"data-testid":"payment-event-row",children:[(0,e.jsx)(a,{children:i(n(r,"provider"))}),(0,e.jsx)(a,{className:"font-medium",children:i(n(r,"type"))}),(0,e.jsx)(a,{className:"text-muted-foreground",children:i(n(r,"providerEventId"))}),(0,e.jsx)(a,{children:S(n(r,"processedAt"))})]},i(n(r,"providerEventId"))))})})})]})]})},"re");export{te as PaymentsPanel};
1
+ import{a as R}from"./chunk-54MMVNPT.js";import{a as E}from"./chunk-OUCGTB3Y.js";import"./chunk-SFDOII3B.js";import"./chunk-SMIESS7P.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as x}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as T}from"./chunk-YRYEZHOJ.js";import"./chunk-XXQUMVWH.js";import"./chunk-PNAVAJAF.js";import"./chunk-QLQADHFE.js";import{a as v}from"./chunk-VDW32UET.js";import{c as b}from"./chunk-TS6346VY.js";import"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as w}from"./chunk-XQCVZAGU.js";import{a as A,b as j,c as I,d as g,e as c,f as a}from"./chunk-MIQTKZAR.js";import{a as y,e as N}from"./chunk-UZERI5YC.js";import{d as _,q as S}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as m,e as M,h as G}from"./chunk-3XIESWL4.js";var e=M(G(),1);var H=["subscriptions","events"],L={},k=new Set(["active","trialing"]),U=new Set(["past_due","unpaid"]),n=m((s,t)=>{if(s[t]!==void 0)return s[t];let p=s.__doc__;if(typeof p=="string")try{let o=JSON.parse(p);if(o!==null&&typeof o=="object"&&!Array.isArray(o))return o[t]}catch{}},"s"),i=m(s=>typeof s=="string"?s:typeof s=="number"||typeof s=="bigint"||typeof s=="boolean"?String(s):"","i"),$=m(s=>k.has(s)?"default":U.has(s)?"destructive":"outline","J"),te=m(({limit:s=100})=>{let t=_(),p=E(),{data:o}=b(v.listTables,L,{live:!0}),D=o!==void 0,O=Array.isArray(o)&&H.every(r=>o.some(l=>l.name===r)),f=p.payments&&O,d=b(v.readTablePage,{filters:[],limit:s,offset:0,orderBy:[],search:"",table:"subscriptions"},{enabled:f}),h=b(v.readTablePage,{filters:[],limit:25,offset:0,orderBy:[],search:"",table:"events"},{enabled:f});R(()=>{f&&(d.refetch(),h.refetch())},!0);let u=d.data?.rows??[],B=h.data?.rows??[],C=d.error??h.error,F=d.error===null?h.errorSource:d.errorSource,P=u.filter(r=>k.has(i(n(r,"state")))).length,J=B.toSorted((r,l)=>Number(n(l,"processedAt")??0)-Number(n(r,"processedAt")??0));return D&&!f?(0,e.jsx)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:(0,e.jsx)(w,{description:t("No @lunora/payment tables found in this deployment. Declare the store tables (subscriptions, events, \u2026) in lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:t("No payments configured")})}):(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[(0,e.jsx)("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:(0,e.jsxs)(y,{className:"justify-between gap-0 py-0",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Subscriptions")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:P}),(0,e.jsx)(x,{variant:"default",children:t("{count} active",{count:P})})]})]}),(0,e.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:t("{total} total",{total:u.length})})]})}),C===null?void 0:(0,e.jsx)(T,{error:F}),u.length===0&&!d.isLoading?(0,e.jsx)(w,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(y,{className:"overflow-hidden py-0",children:(0,e.jsx)(N,{className:"px-0",children:(0,e.jsxs)(A,{children:[(0,e.jsx)(j,{children:(0,e.jsxs)(g,{children:[(0,e.jsx)(c,{children:t("Provider")}),(0,e.jsx)(c,{children:t("Reference")}),(0,e.jsx)(c,{children:t("Plan")}),(0,e.jsx)(c,{children:t("State")}),(0,e.jsx)(c,{children:t("Renews")})]})}),(0,e.jsx)(I,{children:u.map(r=>{let l=i(n(r,"state"));return(0,e.jsxs)(g,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(a,{children:i(n(r,"provider"))}),(0,e.jsx)(a,{children:i(n(r,"referenceId"))}),(0,e.jsx)(a,{children:i(n(r,"priceId"))}),(0,e.jsx)(a,{children:(0,e.jsx)(x,{variant:$(l),children:l})}),(0,e.jsx)(a,{children:S(n(r,"currentPeriodEnd"))})]},i(n(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(y,{className:"overflow-hidden py-0",children:[(0,e.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Recent webhook events")})}),(0,e.jsx)(N,{className:"px-0",children:(0,e.jsx)(A,{children:(0,e.jsx)(I,{children:J.map(r=>(0,e.jsxs)(g,{"data-testid":"payment-event-row",children:[(0,e.jsx)(a,{children:i(n(r,"provider"))}),(0,e.jsx)(a,{className:"font-medium",children:i(n(r,"type"))}),(0,e.jsx)(a,{className:"text-muted-foreground",children:i(n(r,"providerEventId"))}),(0,e.jsx)(a,{children:S(n(r,"processedAt"))})]},i(n(r,"providerEventId"))))})})})]})]})},"re");export{te as PaymentsPanel};
@@ -0,0 +1 @@
1
+ import{a as O,b as B}from"./chunk-AVAC26HJ.js";import{a as F}from"./chunk-CTNB2KIA.js";import{a as j}from"./chunk-3CWGJYBB.js";import{a as V}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as C}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as L}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as z}from"./chunk-YRYEZHOJ.js";import"./chunk-XXQUMVWH.js";import"./chunk-PNAVAJAF.js";import"./chunk-QLQADHFE.js";import{a as R}from"./chunk-VDW32UET.js";import{c as M}from"./chunk-TS6346VY.js";import"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as K}from"./chunk-XQCVZAGU.js";import{a as A,b as T,c as q,d as p,e as n,f as d}from"./chunk-MIQTKZAR.js";import{a as I,e as E}from"./chunk-UZERI5YC.js";import{d as b,q as k}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as i,e as y,f as ee,h as te}from"./chunk-3XIESWL4.js";var o=y(ee(),1);var e=y(te(),1);var D=80,re=i(s=>{if(s===void 0)return"";let t=JSON.stringify(s);return t.length>D?`${t.slice(0,D)}\u2026`:t},"te"),ae=41,J=480,H=5,ie=i((s,t)=>O(s,l=>{t(l.height>0?l:{height:J,width:l.width})}),"ae"),Ne=i(({initialShardKey:s})=>{let t=b(),{queryShardKey:l,setShardKey:P,shardKey:U}=j(s),[c,W]=(0,o.useState)(""),{data:f,error:g,errorSource:Z,isLoading:_,liveError:$}=M(R.getAuditLog,{},{live:!0,shardKey:l}),h=(0,o.useMemo)(()=>f?.entries??[],[f]),m=(0,o.useMemo)(()=>{let a=c.trim().toLowerCase();return a===""?h:h.filter(r=>r.op.toLowerCase().includes(a)||(r.table??"").toLowerCase().includes(a)||(r.id??"").toLowerCase().includes(a))},[h,c]),x=(0,o.useRef)(null),v=B({count:m.length,estimateSize:i(()=>ae,"estimateSize"),getScrollElement:i(()=>x.current,"getScrollElement"),initialRect:{height:J,width:800},observeElementRect:ie,overscan:8}),u=v.getVirtualItems(),G=v.getTotalSize(),N=u[0]?.start??0,w=G-(u.at(-1)?.end??0),Q={height:N},X={height:w},Y=i(a=>{W(a.target.value)},"k");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-audit",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(V,{onChange:P,testId:"au-shard-input",value:U}),(0,e.jsx)(F,{message:$,prefix:"au"}),(0,e.jsx)(C,{"aria-label":t("Filter audit log"),className:"h-8 w-48","data-testid":"au-search",onChange:Y,placeholder:t("filter op, table, id"),value:c})]}),g!==null&&(0,e.jsx)(z,{error:Z,testId:"au-error"}),g===null&&!_&&m.length===0&&(0,e.jsx)(K,{description:t("State-changing admin operations are recorded here."),icon:(0,e.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsx)("path",{d:"M8 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2h-2M9 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V3Zm-1 9h8m-8 4h5"})}),testId:"au-empty",title:t("No audit entries.")}),m.length>0&&(0,e.jsx)(I,{className:"overflow-hidden py-0",children:(0,e.jsx)(E,{className:"max-h-[30rem] overflow-auto px-0",ref:x,children:(0,e.jsxs)(A,{"data-testid":"au-table",children:[(0,e.jsx)(T,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(n,{children:t("time")}),(0,e.jsx)(n,{children:t("op")}),(0,e.jsx)(n,{children:t("table")}),(0,e.jsx)(n,{children:t("id")}),(0,e.jsx)(n,{children:t("detail")})]})}),(0,e.jsxs)(q,{children:[N>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:Q})}),u.map(a=>{let r=m[a.index],S=re(r.detail);return(0,e.jsxs)(p,{"data-testid":"au-row",children:[(0,e.jsx)(d,{className:"text-muted-foreground tabular-nums",children:k(r.ts,"\u2014")}),(0,e.jsx)(d,{children:(0,e.jsx)(L,{variant:"secondary",children:r.op})}),(0,e.jsx)(d,{className:"font-medium",children:r.table??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(d,{className:"max-w-[20ch] truncate font-mono text-xs",children:r.id??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(d,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:S||void 0,children:S||(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},r.seq)}),w>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:X})})]})]})})})]})},"we");export{Ne as AuditPanel};
@@ -0,0 +1 @@
1
+ import{a as N}from"./chunk-EQZTSISX.js";import{a as z}from"./chunk-54MMVNPT.js";import{a as q}from"./chunk-3CWGJYBB.js";import{a as W}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as R}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as B}from"./chunk-YRYEZHOJ.js";import"./chunk-XXQUMVWH.js";import"./chunk-PNAVAJAF.js";import"./chunk-QLQADHFE.js";import{a as L}from"./chunk-VDW32UET.js";import{c as E}from"./chunk-TS6346VY.js";import"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as A}from"./chunk-XQCVZAGU.js";import{a as H,b as O,c as U,d as K,e as T,f as D}from"./chunk-MIQTKZAR.js";import{a as _}from"./chunk-UZERI5YC.js";import{d as j}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as M,e as F,g as V,h as X}from"./chunk-3XIESWL4.js";var P=F(V(),1);var t=F(X(),1);var G=M(n=>`${n.toString()} ms`,"D"),Q=M(n=>n.totalConnections===0&&n.shapePoke.passes===0&&n.whisper.passes===0,"z"),J=M(n=>{let e=(0,P.c)(48),{counters:r,includeTiming:s,prefix:l,t:o,title:b}=n,k=`${l}-section`,p;e[0]!==b?(p=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:b}),e[0]=b,e[1]=p):p=e[1];let a=`${l}-stats`,i;e[2]!==o?(i=o("Passes"),e[2]=o,e[3]=i):i=e[3];let I=`${l}-passes`,v;e[4]!==r.passes||e[5]!==i||e[6]!==I?(v=(0,t.jsx)(N,{label:i,testId:I,value:r.passes}),e[4]=r.passes,e[5]=i,e[6]=I,e[7]=v):v=e[7];let h;e[8]!==o?(h=o("Sockets iterated"),e[8]=o,e[9]=h):h=e[9];let x=`${l}-iterated`,c;e[10]!==r.socketsIterated||e[11]!==h||e[12]!==x?(c=(0,t.jsx)(N,{label:h,testId:x,value:r.socketsIterated}),e[10]=r.socketsIterated,e[11]=h,e[12]=x,e[13]=c):c=e[13];let d;e[14]!==o?(d=o("Delivered"),e[14]=o,e[15]=d):d=e[15];let y=`${l}-delivered`,m;e[16]!==r.socketsDelivered||e[17]!==d||e[18]!==y?(m=(0,t.jsx)(N,{label:d,testId:y,value:r.socketsDelivered}),e[16]=r.socketsDelivered,e[17]=d,e[18]=y,e[19]=m):m=e[19];let u;e[20]!==o?(u=o("Peak width"),e[20]=o,e[21]=u):u=e[21];let g=`${l}-peak`,f;e[22]!==r.peakSocketsIterated||e[23]!==u||e[24]!==g?(f=(0,t.jsx)(N,{label:u,testId:g,value:r.peakSocketsIterated}),e[22]=r.peakSocketsIterated,e[23]=u,e[24]=g,e[25]=f):f=e[25];let S;e[26]!==r.totalMs||e[27]!==s||e[28]!==l||e[29]!==o?(S=s&&(0,t.jsx)(N,{label:o("Total time"),testId:`${l}-total-ms`,value:G(r.totalMs)}),e[26]=r.totalMs,e[27]=s,e[28]=l,e[29]=o,e[30]=S):S=e[30];let C;e[31]!==r.maxMs||e[32]!==s||e[33]!==l||e[34]!==o?(C=s&&(0,t.jsx)(N,{label:o("Max time"),testId:`${l}-max-ms`,value:G(r.maxMs)}),e[31]=r.maxMs,e[32]=s,e[33]=l,e[34]=o,e[35]=C):C=e[35];let $;e[36]!==m||e[37]!==f||e[38]!==S||e[39]!==C||e[40]!==a||e[41]!==v||e[42]!==c?($=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":a,children:[v,c,m,f,S,C]}),e[36]=m,e[37]=f,e[38]=S,e[39]=C,e[40]=a,e[41]=v,e[42]=c,e[43]=$):$=e[43];let w;return e[44]!==k||e[45]!==$||e[46]!==p?(w=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":k,children:[p,$]}),e[44]=k,e[45]=$,e[46]=p,e[47]=w):w=e[47],w},"F"),me=M(n=>{let e=(0,P.c)(31),{initialShardKey:r}=n,s=j(),{queryShardKey:l,setShardKey:o,shardKey:b}=q(r),k;e[0]===Symbol.for("react.memo_cache_sentinel")?(k={},e[0]=k):k=e[0];let p;e[1]!==l?(p={keepPreviousData:!0,shardKey:l},e[1]=l,e[2]=p):p=e[2];let{data:a,error:i,errorSource:I,refetch:v}=E(L.getFanoutMetrics,k,p);z(v,!0);let h;e[3]!==a?(h=a!==void 0&&Q(a),e[3]=a,e[4]=h):h=e[4];let x=h,c;e[5]!==o||e[6]!==b?(c=(0,t.jsx)(W,{onChange:o,testId:"fanout-shard-input",value:b}),e[5]=o,e[6]=b,e[7]=c):c=e[7];let d;e[8]!==a||e[9]!==s?(d=a!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"fanout-count",children:[a.promoted&&(0,t.jsx)(R,{"data-testid":"fanout-promoted",variant:a.relayCount>=a.maxRelays?"destructive":"default",children:a.relayCount>=a.maxRelays?s("auto-scaled: {relayCount}/{maxRelays} relays (at ceiling)",{maxRelays:a.maxRelays,relayCount:a.relayCount}):s("auto-scaled: {relayCount}/{maxRelays} relays",{maxRelays:a.maxRelays,relayCount:a.relayCount})}),(0,t.jsx)(R,{variant:"secondary",children:s("{count} connections",{count:a.totalConnections})}),(0,t.jsx)(R,{variant:"secondary",children:s("peak {count} subscribers",{count:a.peakSubscribers})})]}),e[8]=a,e[9]=s,e[10]=d):d=e[10];let y;e[11]!==c||e[12]!==d?(y=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,d]}),e[11]=c,e[12]=d,e[13]=y):y=e[13];let m;e[14]!==i||e[15]!==I?(m=i!==null&&(0,t.jsx)(B,{error:I,testId:"fanout-error"}),e[14]=i,e[15]=I,e[16]=m):m=e[16];let u;e[17]!==i||e[18]!==x||e[19]!==s?(u=i===null&&x&&(0,t.jsx)(A,{description:s("Realtime fan-out cost and per-topic subscriber counts for this shard."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M4 12h4l3 7 4-14 3 7h2"})}),testId:"fanout-empty",title:s("No fan-out activity yet.")}),e[17]=i,e[18]=x,e[19]=s,e[20]=u):u=e[20];let g;e[21]!==i||e[22]!==x||e[23]!==a||e[24]!==s?(g=i===null&&a!==void 0&&!x&&(0,t.jsxs)(t.Fragment,{children:[a.topics.length>0&&(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-topics-section",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:s("Hot topics")}),(0,t.jsx)(_,{className:"overflow-hidden py-0",children:(0,t.jsxs)(H,{"data-testid":"fanout-topics-table",children:[(0,t.jsx)(O,{children:(0,t.jsxs)(K,{children:[(0,t.jsx)(T,{children:s("Topic")}),(0,t.jsx)(T,{children:s("Kind")}),(0,t.jsx)(T,{className:"text-right",children:s("Subscribers")})]})}),(0,t.jsx)(U,{children:a.topics.map(Y)})]})})]}),(0,t.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"fanout-cost",children:[(0,t.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:s("Fan-out cost since this instance woke")}),(0,t.jsx)(J,{counters:a.shapePoke,includeTiming:!0,prefix:"fanout-poke",t:s,title:s("Shape pokes")}),(0,t.jsx)(J,{counters:a.whisper,includeTiming:!1,prefix:"fanout-whisper",t:s,title:s("Whisper broadcasts")})]})]}),e[21]=i,e[22]=x,e[23]=a,e[24]=s,e[25]=g):g=e[25];let f;return e[26]!==y||e[27]!==m||e[28]!==u||e[29]!==g?(f=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"fanout-panel",children:[y,m,u,g]}),e[26]=y,e[27]=m,e[28]=u,e[29]=g,e[30]=f):f=e[30],f},"me");function Y(n){return(0,t.jsxs)(K,{"data-testid":"fanout-topic-row",children:[(0,t.jsx)(D,{className:"font-mono text-xs",children:n.topic}),(0,t.jsx)(D,{children:(0,t.jsx)(R,{variant:"outline",children:n.kind})}),(0,t.jsx)(D,{className:"text-right font-medium tabular-nums",children:n.subscribers})]},`${n.kind}:${n.topic}`)}M(Y,"G");export{me as default};
@@ -1 +1 @@
1
- import{a as D}from"./chunk-XXQUMVWH.js";import{a as O}from"./chunk-VORDESEQ.js";import{b as q}from"./chunk-QLQADHFE.js";import{d as A,h as C,j as E,k as H}from"./chunk-OG4N2XHD.js";import{a as V}from"./chunk-QNUWWC3N.js";import{a as y,e as I,g as T,h as _}from"./chunk-3XIESWL4.js";var G=I(T(),1);var i=I(_(),1);var L=y(S=>{let e=(0,G.c)(38),{className:w,error:t,testId:N}=S,g=A(),r=q(),l,s,n,a,c,m,o,d;if(e[0]!==w||e[1]!==t||e[2]!==r||e[3]!==N){let j=E(t),h;e[12]!==t?(h=H(t),e[12]=t,e[13]=h):h=e[13],s=h;let x;e[14]!==t?(x=O(t),e[14]=t,e[15]=x):x=e[15];let k=x,v;e[16]!==r||e[17]!==k?(v=y(()=>{r?.openConsole({errorsOnly:!0,seq:k})},"x"),e[16]=r,e[17]=k,e[18]=v):v=e[18],n=v,l=D,a=w,c=N,m="destructive";let u;e[19]!==t?(u=C(t),e[19]=t,e[20]=u):u=e[20],e[21]!==u?(o=(0,i.jsx)("p",{className:"font-medium",children:u}),e[21]=u,e[22]=o):o=e[22],d=j===void 0?null:(0,i.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-xs opacity-90",children:V(j)}),e[0]=w,e[1]=t,e[2]=r,e[3]=N,e[4]=l,e[5]=s,e[6]=n,e[7]=a,e[8]=c,e[9]=m,e[10]=o,e[11]=d}else l=e[4],s=e[5],n=e[6],a=e[7],c=e[8],m=e[9],o=e[10],d=e[11];let p;e[23]!==s?(p=s===void 0?null:(0,i.jsx)("a",{"aria-label":"View documentation for this error",className:"mt-1 inline-block text-xs underline",href:s,rel:"noreferrer",target:"_blank",children:"View error docs"}),e[23]=s,e[24]=p):p=e[24];let f;e[25]!==r||e[26]!==n||e[27]!==g?(f=r===void 0?null:(0,i.jsx)("button",{className:"mt-1 block text-xs underline outline-none focus-visible:ring-1 focus-visible:ring-ring","data-testid":"error-show-in-console",onClick:n,type:"button",children:g("Show in console")}),e[25]=r,e[26]=n,e[27]=g,e[28]=f):f=e[28];let b;return e[29]!==l||e[30]!==a||e[31]!==c||e[32]!==m||e[33]!==o||e[34]!==d||e[35]!==p||e[36]!==f?(b=(0,i.jsxs)(l,{className:a,testId:c,variant:m,children:[o,d,p,f]}),e[29]=l,e[30]=a,e[31]=c,e[32]=m,e[33]=o,e[34]=d,e[35]=p,e[36]=f,e[37]=b):b=e[37],b},"G");export{L as a};
1
+ import{a as D}from"./chunk-XXQUMVWH.js";import{a as O}from"./chunk-PNAVAJAF.js";import{b as q}from"./chunk-QLQADHFE.js";import{d as A,h as C,j as E,k as H}from"./chunk-OG4N2XHD.js";import{a as V}from"./chunk-XNGYYOLS.js";import{a as y,e as I,g as T,h as _}from"./chunk-3XIESWL4.js";var G=I(T(),1);var i=I(_(),1);var L=y(S=>{let e=(0,G.c)(38),{className:w,error:t,testId:N}=S,g=A(),r=q(),l,s,n,a,c,m,o,d;if(e[0]!==w||e[1]!==t||e[2]!==r||e[3]!==N){let j=E(t),h;e[12]!==t?(h=H(t),e[12]=t,e[13]=h):h=e[13],s=h;let x;e[14]!==t?(x=O(t),e[14]=t,e[15]=x):x=e[15];let k=x,v;e[16]!==r||e[17]!==k?(v=y(()=>{r?.openConsole({errorsOnly:!0,seq:k})},"x"),e[16]=r,e[17]=k,e[18]=v):v=e[18],n=v,l=D,a=w,c=N,m="destructive";let u;e[19]!==t?(u=C(t),e[19]=t,e[20]=u):u=e[20],e[21]!==u?(o=(0,i.jsx)("p",{className:"font-medium",children:u}),e[21]=u,e[22]=o):o=e[22],d=j===void 0?null:(0,i.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-xs opacity-90",children:V(j)}),e[0]=w,e[1]=t,e[2]=r,e[3]=N,e[4]=l,e[5]=s,e[6]=n,e[7]=a,e[8]=c,e[9]=m,e[10]=o,e[11]=d}else l=e[4],s=e[5],n=e[6],a=e[7],c=e[8],m=e[9],o=e[10],d=e[11];let p;e[23]!==s?(p=s===void 0?null:(0,i.jsx)("a",{"aria-label":"View documentation for this error",className:"mt-1 inline-block text-xs underline",href:s,rel:"noreferrer",target:"_blank",children:"View error docs"}),e[23]=s,e[24]=p):p=e[24];let f;e[25]!==r||e[26]!==n||e[27]!==g?(f=r===void 0?null:(0,i.jsx)("button",{className:"mt-1 block text-xs underline outline-none focus-visible:ring-1 focus-visible:ring-ring","data-testid":"error-show-in-console",onClick:n,type:"button",children:g("Show in console")}),e[25]=r,e[26]=n,e[27]=g,e[28]=f):f=e[28];let b;return e[29]!==l||e[30]!==a||e[31]!==c||e[32]!==m||e[33]!==o||e[34]!==d||e[35]!==p||e[36]!==f?(b=(0,i.jsxs)(l,{className:a,testId:c,variant:m,children:[o,d,p,f]}),e[29]=l,e[30]=a,e[31]=c,e[32]=m,e[33]=o,e[34]=d,e[35]=p,e[36]=f,e[37]=b):b=e[37],b},"G");export{L as a};
@@ -1 +1 @@
1
- import{a as de}from"./chunk-2SC3EG5Y.js";import"./chunk-AQKXMWNF.js";import"./chunk-4UOFSGUS.js";import"./chunk-ILNELDFC.js";import{d as Y,f as ee}from"./chunk-7T7UOTYK.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as T}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as te}from"./chunk-XXQUMVWH.js";import{a as X}from"./chunk-ERMTJYQF.js";import{f as F}from"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as H}from"./chunk-XQCVZAGU.js";import{a as Q,b as U,c as D,e as V}from"./chunk-UZERI5YC.js";import{d as A,f as Z,g as G,h as J,m as P}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as k,e as O,f as ae,g as le,h as se}from"./chunk-3XIESWL4.js";var W=O(le(),1),I=O(ae(),1);var s=O(se(),1);var re=Z(X.runSql),ie=k((_,e)=>{let t=(0,W.c)(11),m=F(),[d,a]=(0,I.useState)(void 0),[r,l]=(0,I.useState)(void 0),[o,E]=(0,I.useState)(!0),c;t[0]!==m||t[1]!==e||t[2]!==_?(c=k(async u=>{E(!0);try{let N=await m.query(re,{sql:_},G(e));u.cancelled||(a(N),l(void 0))}catch(N){let $=N;u.cancelled||(a(void 0),l(J($)))}u.cancelled||E(!1)},"n"),t[0]=m,t[1]=e,t[2]=_,t[3]=c):c=t[3];let C=c,y,K;t[4]!==C?(y=k(()=>{let u={cancelled:!1};return P(C(u)),()=>{u.cancelled=!0}},"y"),K=[C],t[4]=C,t[5]=y,t[6]=K):(y=t[5],K=t[6]),(0,I.useEffect)(y,K);let h;return t[7]!==r||t[8]!==o||t[9]!==d?(h={error:r,loading:o,result:d},t[7]=r,t[8]=o,t[9]=d,t[10]=h):h=t[10],h},"re"),oe="lunora-studio-dashboards",B={shardKey:"",sql:"",title:""},ne=k(_=>{let e=(0,W.c)(54),{onEdit:t,onRemove:m,widget:d}=_,a=A(),{error:r,loading:l,result:o}=ie(d.sql,d.shardKey??""),E;e[0]!==t||e[1]!==d.id?(E=k(()=>{t(d.id)},"$"),e[0]=t,e[1]=d.id,e[2]=E):E=e[2];let c=E,C;e[3]!==m||e[4]!==d.id?(C=k(()=>{m(d.id)},"k"),e[3]=m,e[4]=d.id,e[5]=C):C=e[5];let y=C,K=`dashboards-widget-${d.id}`,h;e[6]!==d.title?(h=(0,s.jsx)(D,{className:"min-w-0 truncate",title:d.title,children:d.title}),e[6]=d.title,e[7]=h):h=e[7];let u;e[8]!==a?(u=a("Edit widget"),e[8]=a,e[9]=u):u=e[9];let N=`dashboards-widget-edit-${d.id}`,$;e[10]!==a?($=a("Edit widget"),e[10]=a,e[11]=$):$=e[11];let L;e[12]===Symbol.for("react.memo_cache_sentinel")?(L=(0,s.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"})}),e[12]=L):L=e[12];let S;e[13]!==c||e[14]!==u||e[15]!==N||e[16]!==$?(S=(0,s.jsx)(T,{"aria-label":u,"data-testid":N,onClick:c,size:"icon-xs",title:$,type:"button",variant:"ghost",children:L}),e[13]=c,e[14]=u,e[15]=N,e[16]=$,e[17]=S):S=e[17];let x;e[18]!==a?(x=a("Remove widget"),e[18]=a,e[19]=x):x=e[19];let j=`dashboards-widget-remove-${d.id}`,g;e[20]!==a?(g=a("Remove widget"),e[20]=a,e[21]=g):g=e[21];let w;e[22]===Symbol.for("react.memo_cache_sentinel")?(w=(0,s.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[22]=w):w=e[22];let b;e[23]!==y||e[24]!==x||e[25]!==j||e[26]!==g?(b=(0,s.jsx)(T,{"aria-label":x,"data-testid":j,onClick:y,size:"icon-xs",title:g,type:"button",variant:"ghost",children:w}),e[23]=y,e[24]=x,e[25]=j,e[26]=g,e[27]=b):b=e[27];let f;e[28]!==b||e[29]!==S?(f=(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[S,b]}),e[28]=b,e[29]=S,e[30]=f):f=e[30];let p;e[31]!==f||e[32]!==h?(p=(0,s.jsxs)(U,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[h,f]}),e[31]=f,e[32]=h,e[33]=p):p=e[33];let v;e[34]!==r||e[35]!==d.id?(v=r!==void 0&&(0,s.jsx)(te,{className:"font-mono text-xs",testId:`dashboards-widget-error-${d.id}`,variant:"destructive",children:r}),e[34]=r,e[35]=d.id,e[36]=v):v=e[36];let R;e[37]!==r||e[38]!==l||e[39]!==o||e[40]!==a||e[41]!==d.id?(R=r===void 0&&l&&o===void 0&&(0,s.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${d.id}`,children:a("Running\u2026")}),e[37]=r,e[38]=l,e[39]=o,e[40]=a,e[41]=d.id,e[42]=R):R=e[42];let i;e[43]!==r||e[44]!==o?(i=r===void 0&&o!==void 0&&(0,s.jsx)(de,{result:o}),e[43]=r,e[44]=o,e[45]=i):i=e[45];let n;e[46]!==v||e[47]!==R||e[48]!==i?(n=(0,s.jsxs)(V,{className:"min-h-32 py-2",children:[v,R,i]}),e[46]=v,e[47]=R,e[48]=i,e[49]=n):n=e[49];let q;return e[50]!==p||e[51]!==n||e[52]!==K?(q=(0,s.jsxs)(Q,{"data-testid":K,children:[p,n]}),e[50]=p,e[51]=n,e[52]=K,e[53]=q):q=e[53],q},"ie"),ce=k(_=>{let e=(0,W.c)(58),{draft:t,editing:m,onCancel:d,onChange:a,onSubmit:r}=_,l=A(),o;e[0]!==t||e[1]!==a?(o=k(z=>{a({...t,title:z.target.value})},"a"),e[0]=t,e[1]=a,e[2]=o):o=e[2];let E=o,c;e[3]!==t||e[4]!==a?(c=k(z=>{a({...t,sql:z.target.value})},"n"),e[3]=t,e[4]=a,e[5]=c):c=e[5];let C=c,y;e[6]!==t||e[7]!==a?(y=k(z=>{a({...t,shardKey:z.target.value})},"y"),e[6]=t,e[7]=a,e[8]=y):y=e[8];let K=y,h;e[9]!==r?(h=k(()=>{r()},"h"),e[9]=r,e[10]=h):h=e[10];let u=h,N;e[11]!==t.sql||e[12]!==t.title?(N=t.title.trim()!==""&&t.sql.trim()!=="",e[11]=t.sql,e[12]=t.title,e[13]=N):N=e[13];let $=N,L;e[14]!==l?(L=l("Widget title"),e[14]=l,e[15]=L):L=e[15];let S;e[16]!==l?(S=l("Widget title"),e[16]=l,e[17]=S):S=e[17];let x;e[18]!==t.title||e[19]!==E||e[20]!==L||e[21]!==S?(x=(0,s.jsx)("input",{"aria-label":L,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:E,placeholder:S,type:"text",value:t.title}),e[18]=t.title,e[19]=E,e[20]=L,e[21]=S,e[22]=x):x=e[22];let j;e[23]!==l?(j=l("SQL query"),e[23]=l,e[24]=j):j=e[24];let g;e[25]!==t.sql||e[26]!==C||e[27]!==j?(g=(0,s.jsx)("textarea",{"aria-label":j,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:C,placeholder:"SELECT author, COUNT(*) AS messages FROM \u2026",spellCheck:!1,value:t.sql}),e[25]=t.sql,e[26]=C,e[27]=j,e[28]=g):g=e[28];let w;e[29]!==l?(w=l("Shard key (optional)"),e[29]=l,e[30]=w):w=e[30];let b;e[31]!==l?(b=l("Shard key (optional)"),e[31]=l,e[32]=b):b=e[32];let f;e[33]!==t.shardKey||e[34]!==K||e[35]!==w||e[36]!==b?(f=(0,s.jsx)("input",{"aria-label":w,className:"h-8 rounded-md border border-border bg-background px-2 font-mono text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-shard",onChange:K,placeholder:b,type:"text",value:t.shardKey}),e[33]=t.shardKey,e[34]=K,e[35]=w,e[36]=b,e[37]=f):f=e[37];let p;e[38]!==l?(p=l("Cancel"),e[38]=l,e[39]=p):p=e[39];let v;e[40]!==d||e[41]!==p?(v=(0,s.jsx)(T,{"data-testid":"dashboards-form-cancel",onClick:d,size:"sm",type:"button",variant:"outline",children:p}),e[40]=d,e[41]=p,e[42]=v):v=e[42];let R=!$,i;e[43]!==m||e[44]!==l?(i=l(m?"Save widget":"Add widget"),e[43]=m,e[44]=l,e[45]=i):i=e[45];let n;e[46]!==u||e[47]!==R||e[48]!==i?(n=(0,s.jsx)(T,{"data-testid":"dashboards-form-save",disabled:R,onClick:u,size:"sm",type:"button",children:i}),e[46]=u,e[47]=R,e[48]=i,e[49]=n):n=e[49];let q;e[50]!==v||e[51]!==n?(q=(0,s.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[v,n]}),e[50]=v,e[51]=n,e[52]=q):q=e[52];let M;return e[53]!==g||e[54]!==f||e[55]!==q||e[56]!==x?(M=(0,s.jsx)(Q,{"data-testid":"dashboards-form",children:(0,s.jsxs)(V,{className:"flex flex-col gap-3 py-4",children:[x,g,f,q]})}),e[53]=g,e[54]=f,e[55]=q,e[56]=x,e[57]=M):M=e[57],M},"ae"),we=k(_=>{let e=(0,W.c)(39),{initialShardKey:t}=_,m=A(),[d,a]=Y(oe),[r,l]=(0,I.useState)(B),[o,E]=(0,I.useState)(null),[c,C]=(0,I.useState)(!1),y;e[0]!==t?(y=k(()=>{E(null),l({...B,shardKey:t??""}),C(!0)},"y"),e[0]=t,e[1]=y):y=e[1];let K=y,h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=k(()=>{C(!1),E(null),l(B)},"h"),e[2]=h):h=e[2];let u=h,N;e[3]!==d?(N=k(i=>{let n=d.find(q=>q.id===i);n!==void 0&&(E(i),l({shardKey:n.shardKey??"",sql:n.sql,title:n.title}),C(!0))},"C"),e[3]=d,e[4]=N):N=e[4];let $=N,L;e[5]!==a?(L=k(i=>{a(n=>n.filter(q=>q.id!==i))},"K"),e[5]=a,e[6]=L):L=e[6];let S=L,x;e[7]!==r.shardKey||e[8]!==r.sql||e[9]!==r.title||e[10]!==o||e[11]!==a?(x=k(()=>{let i=r.title.trim(),n=r.sql.trim();if(i===""||n==="")return;let q=r.shardKey.trim();a(o===null?M=>[...M,{id:ee("w"),shardKey:q,sql:n,title:i}]:M=>M.map(z=>z.id===o?{...z,shardKey:q,sql:n,title:i}:z)),u()},"x"),e[7]=r.shardKey,e[8]=r.sql,e[9]=r.title,e[10]=o,e[11]=a,e[12]=x):x=e[12];let j=x,g;e[13]!==m?(g=m("Chart widgets backed by saved read-only SQL queries."),e[13]=m,e[14]=g):g=e[14];let w;e[15]!==g?(w=(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:g}),e[15]=g,e[16]=w):w=e[16];let b;e[17]!==c||e[18]!==K||e[19]!==m?(b=!c&&(0,s.jsx)(T,{"data-testid":"dashboards-add",onClick:K,size:"sm",type:"button",children:m("Add widget")}),e[17]=c,e[18]=K,e[19]=m,e[20]=b):b=e[20];let f;e[21]!==w||e[22]!==b?(f=(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[w,b]}),e[21]=w,e[22]=b,e[23]=f):f=e[23];let p;e[24]!==r||e[25]!==o||e[26]!==c||e[27]!==j?(p=c&&(0,s.jsx)(ce,{draft:r,editing:o!==null,onCancel:u,onChange:l,onSubmit:j}),e[24]=r,e[25]=o,e[26]=c,e[27]=j,e[28]=p):p=e[28];let v;e[29]!==c||e[30]!==$||e[31]!==S||e[32]!==m||e[33]!==d?(v=d.length===0&&!c?(0,s.jsx)(H,{description:m("Add a widget to chart a saved SQL query on this browser."),testId:"dashboards-empty",title:m("No widgets yet")}):(0,s.jsx)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:d.map(i=>(0,s.jsx)(ne,{onEdit:$,onRemove:S,widget:i},i.id))}),e[29]=c,e[30]=$,e[31]=S,e[32]=m,e[33]=d,e[34]=v):v=e[34];let R;return e[35]!==p||e[36]!==v||e[37]!==f?(R=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-dashboards",children:[f,p,v]}),e[35]=p,e[36]=v,e[37]=f,e[38]=R):R=e[38],R},"we");export{we as default};
1
+ import{a as de}from"./chunk-XR7RBXKA.js";import"./chunk-S3DWUXGY.js";import"./chunk-4UOFSGUS.js";import"./chunk-ILNELDFC.js";import{d as Y,f as ee}from"./chunk-7T7UOTYK.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as T}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as te}from"./chunk-XXQUMVWH.js";import{a as X}from"./chunk-VDW32UET.js";import{f as F}from"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as H}from"./chunk-XQCVZAGU.js";import{a as Q,b as U,c as D,e as V}from"./chunk-UZERI5YC.js";import{d as A,f as Z,g as G,h as J,m as P}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as k,e as O,f as ae,g as le,h as se}from"./chunk-3XIESWL4.js";var W=O(le(),1),I=O(ae(),1);var s=O(se(),1);var re=Z(X.runSql),ie=k((_,e)=>{let t=(0,W.c)(11),m=F(),[d,a]=(0,I.useState)(void 0),[r,l]=(0,I.useState)(void 0),[o,E]=(0,I.useState)(!0),c;t[0]!==m||t[1]!==e||t[2]!==_?(c=k(async u=>{E(!0);try{let N=await m.query(re,{sql:_},G(e));u.cancelled||(a(N),l(void 0))}catch(N){let $=N;u.cancelled||(a(void 0),l(J($)))}u.cancelled||E(!1)},"n"),t[0]=m,t[1]=e,t[2]=_,t[3]=c):c=t[3];let C=c,y,K;t[4]!==C?(y=k(()=>{let u={cancelled:!1};return P(C(u)),()=>{u.cancelled=!0}},"y"),K=[C],t[4]=C,t[5]=y,t[6]=K):(y=t[5],K=t[6]),(0,I.useEffect)(y,K);let h;return t[7]!==r||t[8]!==o||t[9]!==d?(h={error:r,loading:o,result:d},t[7]=r,t[8]=o,t[9]=d,t[10]=h):h=t[10],h},"re"),oe="lunora-studio-dashboards",B={shardKey:"",sql:"",title:""},ne=k(_=>{let e=(0,W.c)(54),{onEdit:t,onRemove:m,widget:d}=_,a=A(),{error:r,loading:l,result:o}=ie(d.sql,d.shardKey??""),E;e[0]!==t||e[1]!==d.id?(E=k(()=>{t(d.id)},"$"),e[0]=t,e[1]=d.id,e[2]=E):E=e[2];let c=E,C;e[3]!==m||e[4]!==d.id?(C=k(()=>{m(d.id)},"k"),e[3]=m,e[4]=d.id,e[5]=C):C=e[5];let y=C,K=`dashboards-widget-${d.id}`,h;e[6]!==d.title?(h=(0,s.jsx)(D,{className:"min-w-0 truncate",title:d.title,children:d.title}),e[6]=d.title,e[7]=h):h=e[7];let u;e[8]!==a?(u=a("Edit widget"),e[8]=a,e[9]=u):u=e[9];let N=`dashboards-widget-edit-${d.id}`,$;e[10]!==a?($=a("Edit widget"),e[10]=a,e[11]=$):$=e[11];let L;e[12]===Symbol.for("react.memo_cache_sentinel")?(L=(0,s.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"})}),e[12]=L):L=e[12];let S;e[13]!==c||e[14]!==u||e[15]!==N||e[16]!==$?(S=(0,s.jsx)(T,{"aria-label":u,"data-testid":N,onClick:c,size:"icon-xs",title:$,type:"button",variant:"ghost",children:L}),e[13]=c,e[14]=u,e[15]=N,e[16]=$,e[17]=S):S=e[17];let x;e[18]!==a?(x=a("Remove widget"),e[18]=a,e[19]=x):x=e[19];let j=`dashboards-widget-remove-${d.id}`,g;e[20]!==a?(g=a("Remove widget"),e[20]=a,e[21]=g):g=e[21];let w;e[22]===Symbol.for("react.memo_cache_sentinel")?(w=(0,s.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[22]=w):w=e[22];let b;e[23]!==y||e[24]!==x||e[25]!==j||e[26]!==g?(b=(0,s.jsx)(T,{"aria-label":x,"data-testid":j,onClick:y,size:"icon-xs",title:g,type:"button",variant:"ghost",children:w}),e[23]=y,e[24]=x,e[25]=j,e[26]=g,e[27]=b):b=e[27];let f;e[28]!==b||e[29]!==S?(f=(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[S,b]}),e[28]=b,e[29]=S,e[30]=f):f=e[30];let p;e[31]!==f||e[32]!==h?(p=(0,s.jsxs)(U,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[h,f]}),e[31]=f,e[32]=h,e[33]=p):p=e[33];let v;e[34]!==r||e[35]!==d.id?(v=r!==void 0&&(0,s.jsx)(te,{className:"font-mono text-xs",testId:`dashboards-widget-error-${d.id}`,variant:"destructive",children:r}),e[34]=r,e[35]=d.id,e[36]=v):v=e[36];let R;e[37]!==r||e[38]!==l||e[39]!==o||e[40]!==a||e[41]!==d.id?(R=r===void 0&&l&&o===void 0&&(0,s.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${d.id}`,children:a("Running\u2026")}),e[37]=r,e[38]=l,e[39]=o,e[40]=a,e[41]=d.id,e[42]=R):R=e[42];let i;e[43]!==r||e[44]!==o?(i=r===void 0&&o!==void 0&&(0,s.jsx)(de,{result:o}),e[43]=r,e[44]=o,e[45]=i):i=e[45];let n;e[46]!==v||e[47]!==R||e[48]!==i?(n=(0,s.jsxs)(V,{className:"min-h-32 py-2",children:[v,R,i]}),e[46]=v,e[47]=R,e[48]=i,e[49]=n):n=e[49];let q;return e[50]!==p||e[51]!==n||e[52]!==K?(q=(0,s.jsxs)(Q,{"data-testid":K,children:[p,n]}),e[50]=p,e[51]=n,e[52]=K,e[53]=q):q=e[53],q},"ie"),ce=k(_=>{let e=(0,W.c)(58),{draft:t,editing:m,onCancel:d,onChange:a,onSubmit:r}=_,l=A(),o;e[0]!==t||e[1]!==a?(o=k(z=>{a({...t,title:z.target.value})},"a"),e[0]=t,e[1]=a,e[2]=o):o=e[2];let E=o,c;e[3]!==t||e[4]!==a?(c=k(z=>{a({...t,sql:z.target.value})},"n"),e[3]=t,e[4]=a,e[5]=c):c=e[5];let C=c,y;e[6]!==t||e[7]!==a?(y=k(z=>{a({...t,shardKey:z.target.value})},"y"),e[6]=t,e[7]=a,e[8]=y):y=e[8];let K=y,h;e[9]!==r?(h=k(()=>{r()},"h"),e[9]=r,e[10]=h):h=e[10];let u=h,N;e[11]!==t.sql||e[12]!==t.title?(N=t.title.trim()!==""&&t.sql.trim()!=="",e[11]=t.sql,e[12]=t.title,e[13]=N):N=e[13];let $=N,L;e[14]!==l?(L=l("Widget title"),e[14]=l,e[15]=L):L=e[15];let S;e[16]!==l?(S=l("Widget title"),e[16]=l,e[17]=S):S=e[17];let x;e[18]!==t.title||e[19]!==E||e[20]!==L||e[21]!==S?(x=(0,s.jsx)("input",{"aria-label":L,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:E,placeholder:S,type:"text",value:t.title}),e[18]=t.title,e[19]=E,e[20]=L,e[21]=S,e[22]=x):x=e[22];let j;e[23]!==l?(j=l("SQL query"),e[23]=l,e[24]=j):j=e[24];let g;e[25]!==t.sql||e[26]!==C||e[27]!==j?(g=(0,s.jsx)("textarea",{"aria-label":j,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:C,placeholder:"SELECT author, COUNT(*) AS messages FROM \u2026",spellCheck:!1,value:t.sql}),e[25]=t.sql,e[26]=C,e[27]=j,e[28]=g):g=e[28];let w;e[29]!==l?(w=l("Shard key (optional)"),e[29]=l,e[30]=w):w=e[30];let b;e[31]!==l?(b=l("Shard key (optional)"),e[31]=l,e[32]=b):b=e[32];let f;e[33]!==t.shardKey||e[34]!==K||e[35]!==w||e[36]!==b?(f=(0,s.jsx)("input",{"aria-label":w,className:"h-8 rounded-md border border-border bg-background px-2 font-mono text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-shard",onChange:K,placeholder:b,type:"text",value:t.shardKey}),e[33]=t.shardKey,e[34]=K,e[35]=w,e[36]=b,e[37]=f):f=e[37];let p;e[38]!==l?(p=l("Cancel"),e[38]=l,e[39]=p):p=e[39];let v;e[40]!==d||e[41]!==p?(v=(0,s.jsx)(T,{"data-testid":"dashboards-form-cancel",onClick:d,size:"sm",type:"button",variant:"outline",children:p}),e[40]=d,e[41]=p,e[42]=v):v=e[42];let R=!$,i;e[43]!==m||e[44]!==l?(i=l(m?"Save widget":"Add widget"),e[43]=m,e[44]=l,e[45]=i):i=e[45];let n;e[46]!==u||e[47]!==R||e[48]!==i?(n=(0,s.jsx)(T,{"data-testid":"dashboards-form-save",disabled:R,onClick:u,size:"sm",type:"button",children:i}),e[46]=u,e[47]=R,e[48]=i,e[49]=n):n=e[49];let q;e[50]!==v||e[51]!==n?(q=(0,s.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[v,n]}),e[50]=v,e[51]=n,e[52]=q):q=e[52];let M;return e[53]!==g||e[54]!==f||e[55]!==q||e[56]!==x?(M=(0,s.jsx)(Q,{"data-testid":"dashboards-form",children:(0,s.jsxs)(V,{className:"flex flex-col gap-3 py-4",children:[x,g,f,q]})}),e[53]=g,e[54]=f,e[55]=q,e[56]=x,e[57]=M):M=e[57],M},"ae"),we=k(_=>{let e=(0,W.c)(39),{initialShardKey:t}=_,m=A(),[d,a]=Y(oe),[r,l]=(0,I.useState)(B),[o,E]=(0,I.useState)(null),[c,C]=(0,I.useState)(!1),y;e[0]!==t?(y=k(()=>{E(null),l({...B,shardKey:t??""}),C(!0)},"y"),e[0]=t,e[1]=y):y=e[1];let K=y,h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=k(()=>{C(!1),E(null),l(B)},"h"),e[2]=h):h=e[2];let u=h,N;e[3]!==d?(N=k(i=>{let n=d.find(q=>q.id===i);n!==void 0&&(E(i),l({shardKey:n.shardKey??"",sql:n.sql,title:n.title}),C(!0))},"C"),e[3]=d,e[4]=N):N=e[4];let $=N,L;e[5]!==a?(L=k(i=>{a(n=>n.filter(q=>q.id!==i))},"K"),e[5]=a,e[6]=L):L=e[6];let S=L,x;e[7]!==r.shardKey||e[8]!==r.sql||e[9]!==r.title||e[10]!==o||e[11]!==a?(x=k(()=>{let i=r.title.trim(),n=r.sql.trim();if(i===""||n==="")return;let q=r.shardKey.trim();a(o===null?M=>[...M,{id:ee("w"),shardKey:q,sql:n,title:i}]:M=>M.map(z=>z.id===o?{...z,shardKey:q,sql:n,title:i}:z)),u()},"x"),e[7]=r.shardKey,e[8]=r.sql,e[9]=r.title,e[10]=o,e[11]=a,e[12]=x):x=e[12];let j=x,g;e[13]!==m?(g=m("Chart widgets backed by saved read-only SQL queries."),e[13]=m,e[14]=g):g=e[14];let w;e[15]!==g?(w=(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:g}),e[15]=g,e[16]=w):w=e[16];let b;e[17]!==c||e[18]!==K||e[19]!==m?(b=!c&&(0,s.jsx)(T,{"data-testid":"dashboards-add",onClick:K,size:"sm",type:"button",children:m("Add widget")}),e[17]=c,e[18]=K,e[19]=m,e[20]=b):b=e[20];let f;e[21]!==w||e[22]!==b?(f=(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[w,b]}),e[21]=w,e[22]=b,e[23]=f):f=e[23];let p;e[24]!==r||e[25]!==o||e[26]!==c||e[27]!==j?(p=c&&(0,s.jsx)(ce,{draft:r,editing:o!==null,onCancel:u,onChange:l,onSubmit:j}),e[24]=r,e[25]=o,e[26]=c,e[27]=j,e[28]=p):p=e[28];let v;e[29]!==c||e[30]!==$||e[31]!==S||e[32]!==m||e[33]!==d?(v=d.length===0&&!c?(0,s.jsx)(H,{description:m("Add a widget to chart a saved SQL query on this browser."),testId:"dashboards-empty",title:m("No widgets yet")}):(0,s.jsx)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:d.map(i=>(0,s.jsx)(ne,{onEdit:$,onRemove:S,widget:i},i.id))}),e[29]=c,e[30]=$,e[31]=S,e[32]=m,e[33]=d,e[34]=v):v=e[34];let R;return e[35]!==p||e[36]!==v||e[37]!==f?(R=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-dashboards",children:[f,p,v]}),e[35]=p,e[36]=v,e[37]=f,e[38]=R):R=e[38],R},"we");export{we as default};