@lunora/studio 1.0.0-alpha.362 → 1.0.0-alpha.363

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 (64) hide show
  1. package/dist/standalone/{chunk-J6XQKD2F.js → chunk-32V7XGNC.js} +1 -1
  2. package/dist/standalone/{chunk-Q2J73V2C.js → chunk-4L55URI5.js} +1 -1
  3. package/dist/standalone/{chunk-FBDIQ67D.js → chunk-4N76XUNG.js} +1 -1
  4. package/dist/standalone/{chunk-6KE7ILEZ.js → chunk-53XKGQEE.js} +1 -1
  5. package/dist/standalone/{chunk-7KJCRT4B.js → chunk-5QUTVSHM.js} +1 -1
  6. package/dist/standalone/{chunk-MJTVTUNI.js → chunk-5RX5CQSU.js} +1 -1
  7. package/dist/standalone/{chunk-ZG3IUVQ2.js → chunk-5Z2U4KBN.js} +1 -1
  8. package/dist/standalone/{chunk-ZKEYRU5C.js → chunk-75TRPM7O.js} +1 -1
  9. package/dist/standalone/{chunk-GC3GKGWD.js → chunk-7MLX5CGD.js} +1 -1
  10. package/dist/standalone/{chunk-BO5NNWMO.js → chunk-7TQ7BZ67.js} +1 -1
  11. package/dist/standalone/{chunk-H7BQUL7D.js → chunk-AD5J2ANS.js} +1 -1
  12. package/dist/standalone/{chunk-COLSZPCE.js → chunk-ALR4VAUE.js} +1 -1
  13. package/dist/standalone/{chunk-5EWIOOBI.js → chunk-AXE2SDRU.js} +1 -1
  14. package/dist/standalone/{chunk-JENPPZFV.js → chunk-BAEIW3YS.js} +1 -1
  15. package/dist/standalone/{chunk-BX7TFVCC.js → chunk-BBDTJG2K.js} +1 -1
  16. package/dist/standalone/{chunk-ZFQ253FX.js → chunk-BI6MZHZJ.js} +1 -1
  17. package/dist/standalone/{chunk-EE2COWFF.js → chunk-CP7QNLR4.js} +1 -1
  18. package/dist/standalone/{chunk-OP4QEV27.js → chunk-D57B4MFK.js} +1 -1
  19. package/dist/standalone/{chunk-53CGUTRT.js → chunk-DZFXH55R.js} +1 -1
  20. package/dist/standalone/{chunk-J3BZWYJQ.js → chunk-EPWCW2DF.js} +1 -1
  21. package/dist/standalone/{chunk-PAZKX7I6.js → chunk-FJLRSFTE.js} +1 -1
  22. package/dist/standalone/{chunk-L26RMC2W.js → chunk-FVCBNFQW.js} +1 -1
  23. package/dist/standalone/{chunk-UW6QNC74.js → chunk-GVQPNM3T.js} +1 -1
  24. package/dist/standalone/{chunk-7WV3EPE6.js → chunk-H3EIPYRZ.js} +1 -1
  25. package/dist/standalone/{chunk-HCCQTUHS.js → chunk-H5TMLWIS.js} +1 -1
  26. package/dist/standalone/{chunk-LPFUEJZ4.js → chunk-HBG6SSE2.js} +1 -1
  27. package/dist/standalone/{chunk-5O7ICPWV.js → chunk-HC2B7SXW.js} +1 -1
  28. package/dist/standalone/{chunk-IDZLHZIA.js → chunk-HGCOTYPV.js} +1 -1
  29. package/dist/standalone/{chunk-Q2KL457J.js → chunk-HLHMHCXS.js} +1 -1
  30. package/dist/standalone/{chunk-WADY55J2.js → chunk-HSF2DCJ2.js} +1 -1
  31. package/dist/standalone/{chunk-QEFLZBT7.js → chunk-I3SSF2T6.js} +1 -1
  32. package/dist/standalone/{chunk-ALQHMFOC.js → chunk-I5QX75DE.js} +1 -1
  33. package/dist/standalone/{chunk-JCRFMCNP.js → chunk-ICHZ2IBL.js} +1 -1
  34. package/dist/standalone/{chunk-E2FFHKGI.js → chunk-IG5VD7R7.js} +1 -1
  35. package/dist/standalone/{chunk-ABMHWBYA.js → chunk-KKMQUBYH.js} +1 -1
  36. package/dist/standalone/{chunk-AEU3EF4T.js → chunk-LDHJRHPZ.js} +1 -1
  37. package/dist/standalone/{chunk-X54WR7FF.js → chunk-MNYDT3RH.js} +1 -1
  38. package/dist/standalone/{chunk-OPIMGKWU.js → chunk-MT4ICMXJ.js} +1 -1
  39. package/dist/standalone/{chunk-N7WQJPOM.js → chunk-MXJTD2OX.js} +1 -1
  40. package/dist/standalone/{chunk-WCWP4EAW.js → chunk-OZAOWE7T.js} +1 -1
  41. package/dist/standalone/{chunk-GVZ3VFGG.js → chunk-Q3IA6HPX.js} +1 -1
  42. package/dist/standalone/{chunk-3RZD6VJ7.js → chunk-RBIVXSXT.js} +1 -1
  43. package/dist/standalone/{chunk-JHTL3QHW.js → chunk-SDDEOSQB.js} +1 -1
  44. package/dist/standalone/chunk-SHHGIT7M.js +7 -0
  45. package/dist/standalone/{chunk-Z57KMMOK.js → chunk-SVQWZPO4.js} +1 -1
  46. package/dist/standalone/{chunk-YX2N5PJW.js → chunk-TEMI7MVE.js} +1 -1
  47. package/dist/standalone/{chunk-VHPTPEZ4.js → chunk-U5MPNEM2.js} +1 -1
  48. package/dist/standalone/{chunk-5NIQHOPN.js → chunk-ULQNADMJ.js} +1 -1
  49. package/dist/standalone/{chunk-66LYVBXB.js → chunk-UPPNZ6MI.js} +1 -1
  50. package/dist/standalone/{chunk-ZSLKFLWE.js → chunk-UTQLJKHH.js} +1 -1
  51. package/dist/standalone/{chunk-FQEZUQ36.js → chunk-UVG3ZISC.js} +1 -1
  52. package/dist/standalone/{chunk-2FTGLXYA.js → chunk-VQDTA4P6.js} +1 -1
  53. package/dist/standalone/{chunk-7O5SGABV.js → chunk-WLHQ4FKC.js} +1 -1
  54. package/dist/standalone/{chunk-XWWQIAF6.js → chunk-XPFVUAPX.js} +1 -1
  55. package/dist/standalone/{chunk-NF2Q75WM.js → chunk-Y3IGTWUE.js} +1 -1
  56. package/dist/standalone/{chunk-J6FR2B77.js → chunk-Y64STA6O.js} +1 -1
  57. package/dist/standalone/{chunk-IUGNIG6L.js → chunk-YEXTJUKQ.js} +1 -1
  58. package/dist/standalone/{chunk-RE7GRXBM.js → chunk-YFTPHGS2.js} +1 -1
  59. package/dist/standalone/{chunk-EXFERMUT.js → chunk-Z64BZNPS.js} +1 -1
  60. package/dist/standalone/{chunk-TMWKF4XM.js → chunk-Z6VILGGP.js} +1 -1
  61. package/dist/standalone/{chunk-MQTI3STP.js → chunk-ZBOB33BA.js} +1 -1
  62. package/dist/standalone/studio.js +1 -1
  63. package/package.json +3 -3
  64. package/dist/standalone/chunk-FACXM2UB.js +0 -7
@@ -1,3 +1,3 @@
1
- import{a as at}from"./chunk-DA2CAFXI.js";import{i as Ee}from"./chunk-RTS5G3ET.js";import{a as Fe}from"./chunk-V3BE427M.js";import{a as nt}from"./chunk-RCXNYW7P.js";import{b as We}from"./chunk-UQA2AJGI.js";import{a as D}from"./chunk-2W4UO5BC.js";import{c as _e}from"./chunk-FBDIQ67D.js";import{a as j,e as Ue}from"./chunk-OK2QU2EV.js";import{m as Te}from"./chunk-FACXM2UB.js";import{B as $,h as Ze,i as Qe,o as Xe,s as Ne,u as et,v as tt,x as Ve}from"./chunk-GNI37YCV.js";import{a as mt}from"./chunk-GWNGVKLG.js";import{a as dt,b as ut}from"./chunk-6G3E4PJ2.js";import{a as c,d as ze}from"./chunk-5PEAXTYQ.js";var _=ze(mt(),1);var B=ze(dt(),1);var a=ze(ut(),1);var pt=Ze(D.studioFeatures),Ge={analytics:!0,auth:!0,containers:!0,flags:!0,kv:!0,mail:!0,notifications:!0,payments:!0,privacy:!0,queues:!0,scheduler:!0,storage:!0,vectors:!0,workflows:!0},ft=c(t=>{if(t===null||typeof t!="object")return;let{id:e,name:r,unsupported:n}=t;if(!(typeof e!="string"||typeof r!="string"||!Array.isArray(n)))return{id:e,name:r,unsupported:n.filter(s=>typeof s=="string")}},"ut"),ht=c(t=>{if(t===null||typeof t!="object")return Ge;let e=t,r=c(n=>typeof e[n]=="boolean"?e[n]:!0,"n");return{analytics:r("analytics"),auth:r("auth"),containers:r("containers"),flags:r("flags"),kv:r("kv"),mail:r("mail"),notifications:r("notifications"),payments:r("payments"),privacy:r("privacy"),platform:ft(e.platform),queues:r("queues"),scheduler:r("scheduler"),storage:r("storage"),vectors:r("vectors"),workflows:r("workflows")}},"mt"),gt={...Ge,settled:!1},xt=c(()=>{let t=(0,_.c)(3),e=Te(),[r,n]=(0,B.useState)(void 0),s,l;return t[0]!==e?(s=c(()=>{let i=new AbortController;return Ne((async()=>{let o;try{o={...ht(await e.query(pt,{},Qe(""))),settled:!0}}catch{o={...Ge,settled:!0}}i.signal.aborted||n({client:e,features:o})})()),()=>{i.abort()}},"l"),l=[e],t[0]=e,t[1]=s,t[2]=l):(s=t[1],l=t[2]),(0,B.useEffect)(s,l),r?.client===e?r.features:gt},"pt"),bt=c(()=>{let t=(0,_.c)(1),e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,a.jsx)("svg",{"aria-hidden":"true",className:"size-4 text-muted-foreground",fill:"none",stroke:"currentColor",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"m9 6 6 6-6 6",strokeLinecap:"round",strokeLinejoin:"round"})}),t[0]=e):e=t[0],e},"ht"),yt=c(t=>{let e=(0,_.c)(24),{group:r}=t,n=$(),s=Ee(),l;e[0]!==r.tab||e[1]!==s?(l=c(()=>{Ne(s({to:`/${r.tab}`}))},"r"),e[0]=r.tab,e[1]=s,e[2]=l):l=e[2];let i=l,o=r.bindings.length,d;e[3]!==r.label?(d=(0,a.jsx)("span",{className:"text-sm font-medium text-foreground",children:r.label}),e[3]=r.label,e[4]=d):d=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=(0,a.jsx)(bt,{}),e[5]=u):u=e[5];let p;e[6]!==d?(p=(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[d,u]}),e[6]=d,e[7]=p):p=e[7];let m;e[8]!==o||e[9]!==n?(m=o===1?n("1 binding"):n("{count} bindings",{count:o}),e[8]=o,e[9]=n,e[10]=m):m=e[10];let f;e[11]!==m?(f=(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:m}),e[11]=m,e[12]=f):f=e[12];let h;e[13]!==o||e[14]!==r.bindings?(h=o>0&&(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5",children:r.bindings.map(_t)}),e[13]=o,e[14]=r.bindings,e[15]=h):h=e[15];let g;e[16]!==p||e[17]!==f||e[18]!==h?(g=(0,a.jsxs)(Ue,{className:"flex flex-col gap-2 py-4",children:[p,f,h]}),e[16]=p,e[17]=f,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==r.testId||e[21]!==i||e[22]!==g?(x=(0,a.jsx)(j,{className:"cursor-pointer gap-0 py-0 transition-colors hover:bg-muted/40","data-testid":r.testId,onClick:i,children:g}),e[20]=r.testId,e[21]=i,e[22]=g,e[23]=x):x=e[23],x},"gt"),rt=["kv","files","vectors"],vt=c((t,e)=>[...t.filter(r=>r.tab!==e.tab),e].toSorted((r,n)=>rt.indexOf(r.tab)-rt.indexOf(n.tab)),"xt"),Nt=c(()=>{let t=(0,_.c)(19),e=Te(),r=xt(),n=$(),s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=[],t[0]=s):s=t[0];let[l,i]=(0,B.useState)(s),o,d;if(t[1]!==e||t[2]!==r.kv||t[3]!==r.storage||t[4]!==r.vectors||t[5]!==n?(o=c(()=>{let g={cancelled:!1},x=[{enabled:r.kv,label:n("KV Namespaces"),load:c(async()=>(await e.listKvNamespaces()).map(wt),"load"),tab:"kv",testId:"home-binding-kv"},{enabled:r.storage,label:n("R2 Buckets"),load:c(()=>e.listStorageBuckets(),"load"),tab:"files",testId:"home-binding-r2"},{enabled:r.vectors,label:n("Vectorize Indexes"),load:c(async()=>(await e.listVectorIndexes()).map(kt),"load"),tab:"vectors",testId:"home-binding-vectors"}];for(let b of x)b.enabled&&Ne((async()=>{try{let v=await b.load();if(!g.cancelled){let w={bindings:v,label:b.label,tab:b.tab,testId:b.testId};i(k=>vt(k,w))}}catch{}})());return()=>{g.cancelled=!0}},"o"),d=[e,r.kv,r.storage,r.vectors,n],t[1]=e,t[2]=r.kv,t[3]=r.storage,t[4]=r.vectors,t[5]=n,t[6]=o,t[7]=d):(o=t[6],d=t[7]),(0,B.useEffect)(o,d),l.length===0)return null;let u;t[8]!==n?(u=n("Bindings"),t[8]=n,t[9]=u):u=t[9];let p;t[10]!==u?(p=(0,a.jsx)("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:u}),t[10]=u,t[11]=p):p=t[11];let m;t[12]!==l?(m=l.map(St),t[12]=l,t[13]=m):m=t[13];let f;t[14]!==m?(f=(0,a.jsx)("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:m}),t[14]=m,t[15]=f):f=t[15];let h;return t[16]!==p||t[17]!==f?(h=(0,a.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"home-bindings",children:[p,f]}),t[16]=p,t[17]=f,t[18]=h):h=t[18],h},"bt");function _t(t){return(0,a.jsx)(We,{variant:"secondary",children:t},t)}c(_t,"yt");function wt(t){return t.binding}c(wt,"vt");function kt(t){return t.name}c(kt,"Nt");function St(t){return(0,a.jsx)(yt,{group:t},t.tab)}c(St,"_t");var Mt=[{name:"lunora_list_functions",summary:"list every query, mutation, and action with its path"},{name:"lunora_list_tables",summary:"list the schema's tables"},{name:"lunora_get_function_schema",summary:"read a function's argument JSON Schema before calling it"},{name:"lunora_run_query",summary:"run a read-only query"},{name:"lunora_run_mutation",summary:"run a mutation \u2014 writes; only when LUNORA_MCP_ALLOW_WRITES is set"},{name:"lunora_run_action",summary:"run an action \u2014 writes/effects; only when LUNORA_MCP_ALLOW_WRITES is set"}],At=c(t=>JSON.stringify({mcpServers:{lunora:{args:["-y","@lunora/mcp"],command:"npx",env:{LUNORA_ADMIN_TOKEN:"<your-admin-token>",LUNORA_URL:t}}}},null,2),"wt"),Ct=c(t=>{let e=Mt.map(r=>`- ${r.name} \u2014 ${r.summary}`).join(`
1
+ import{a as at}from"./chunk-DA2CAFXI.js";import{i as Ee}from"./chunk-RTS5G3ET.js";import{a as Fe}from"./chunk-V3BE427M.js";import{a as nt}from"./chunk-RCXNYW7P.js";import{b as We}from"./chunk-UQA2AJGI.js";import{a as D}from"./chunk-2W4UO5BC.js";import{c as _e}from"./chunk-4N76XUNG.js";import{a as j,e as Ue}from"./chunk-OK2QU2EV.js";import{m as Te}from"./chunk-SHHGIT7M.js";import{B as $,h as Ze,i as Qe,o as Xe,s as Ne,u as et,v as tt,x as Ve}from"./chunk-GNI37YCV.js";import{a as mt}from"./chunk-GWNGVKLG.js";import{a as dt,b as ut}from"./chunk-6G3E4PJ2.js";import{a as c,d as ze}from"./chunk-5PEAXTYQ.js";var _=ze(mt(),1);var B=ze(dt(),1);var a=ze(ut(),1);var pt=Ze(D.studioFeatures),Ge={analytics:!0,auth:!0,containers:!0,flags:!0,kv:!0,mail:!0,notifications:!0,payments:!0,privacy:!0,queues:!0,scheduler:!0,storage:!0,vectors:!0,workflows:!0},ft=c(t=>{if(t===null||typeof t!="object")return;let{id:e,name:r,unsupported:n}=t;if(!(typeof e!="string"||typeof r!="string"||!Array.isArray(n)))return{id:e,name:r,unsupported:n.filter(s=>typeof s=="string")}},"ut"),ht=c(t=>{if(t===null||typeof t!="object")return Ge;let e=t,r=c(n=>typeof e[n]=="boolean"?e[n]:!0,"n");return{analytics:r("analytics"),auth:r("auth"),containers:r("containers"),flags:r("flags"),kv:r("kv"),mail:r("mail"),notifications:r("notifications"),payments:r("payments"),privacy:r("privacy"),platform:ft(e.platform),queues:r("queues"),scheduler:r("scheduler"),storage:r("storage"),vectors:r("vectors"),workflows:r("workflows")}},"mt"),gt={...Ge,settled:!1},xt=c(()=>{let t=(0,_.c)(3),e=Te(),[r,n]=(0,B.useState)(void 0),s,l;return t[0]!==e?(s=c(()=>{let i=new AbortController;return Ne((async()=>{let o;try{o={...ht(await e.query(pt,{},Qe(""))),settled:!0}}catch{o={...Ge,settled:!0}}i.signal.aborted||n({client:e,features:o})})()),()=>{i.abort()}},"l"),l=[e],t[0]=e,t[1]=s,t[2]=l):(s=t[1],l=t[2]),(0,B.useEffect)(s,l),r?.client===e?r.features:gt},"pt"),bt=c(()=>{let t=(0,_.c)(1),e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,a.jsx)("svg",{"aria-hidden":"true",className:"size-4 text-muted-foreground",fill:"none",stroke:"currentColor",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"m9 6 6 6-6 6",strokeLinecap:"round",strokeLinejoin:"round"})}),t[0]=e):e=t[0],e},"ht"),yt=c(t=>{let e=(0,_.c)(24),{group:r}=t,n=$(),s=Ee(),l;e[0]!==r.tab||e[1]!==s?(l=c(()=>{Ne(s({to:`/${r.tab}`}))},"r"),e[0]=r.tab,e[1]=s,e[2]=l):l=e[2];let i=l,o=r.bindings.length,d;e[3]!==r.label?(d=(0,a.jsx)("span",{className:"text-sm font-medium text-foreground",children:r.label}),e[3]=r.label,e[4]=d):d=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=(0,a.jsx)(bt,{}),e[5]=u):u=e[5];let p;e[6]!==d?(p=(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[d,u]}),e[6]=d,e[7]=p):p=e[7];let m;e[8]!==o||e[9]!==n?(m=o===1?n("1 binding"):n("{count} bindings",{count:o}),e[8]=o,e[9]=n,e[10]=m):m=e[10];let f;e[11]!==m?(f=(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:m}),e[11]=m,e[12]=f):f=e[12];let h;e[13]!==o||e[14]!==r.bindings?(h=o>0&&(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5",children:r.bindings.map(_t)}),e[13]=o,e[14]=r.bindings,e[15]=h):h=e[15];let g;e[16]!==p||e[17]!==f||e[18]!==h?(g=(0,a.jsxs)(Ue,{className:"flex flex-col gap-2 py-4",children:[p,f,h]}),e[16]=p,e[17]=f,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==r.testId||e[21]!==i||e[22]!==g?(x=(0,a.jsx)(j,{className:"cursor-pointer gap-0 py-0 transition-colors hover:bg-muted/40","data-testid":r.testId,onClick:i,children:g}),e[20]=r.testId,e[21]=i,e[22]=g,e[23]=x):x=e[23],x},"gt"),rt=["kv","files","vectors"],vt=c((t,e)=>[...t.filter(r=>r.tab!==e.tab),e].toSorted((r,n)=>rt.indexOf(r.tab)-rt.indexOf(n.tab)),"xt"),Nt=c(()=>{let t=(0,_.c)(19),e=Te(),r=xt(),n=$(),s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=[],t[0]=s):s=t[0];let[l,i]=(0,B.useState)(s),o,d;if(t[1]!==e||t[2]!==r.kv||t[3]!==r.storage||t[4]!==r.vectors||t[5]!==n?(o=c(()=>{let g={cancelled:!1},x=[{enabled:r.kv,label:n("KV Namespaces"),load:c(async()=>(await e.listKvNamespaces()).map(wt),"load"),tab:"kv",testId:"home-binding-kv"},{enabled:r.storage,label:n("R2 Buckets"),load:c(()=>e.listStorageBuckets(),"load"),tab:"files",testId:"home-binding-r2"},{enabled:r.vectors,label:n("Vectorize Indexes"),load:c(async()=>(await e.listVectorIndexes()).map(kt),"load"),tab:"vectors",testId:"home-binding-vectors"}];for(let b of x)b.enabled&&Ne((async()=>{try{let v=await b.load();if(!g.cancelled){let w={bindings:v,label:b.label,tab:b.tab,testId:b.testId};i(k=>vt(k,w))}}catch{}})());return()=>{g.cancelled=!0}},"o"),d=[e,r.kv,r.storage,r.vectors,n],t[1]=e,t[2]=r.kv,t[3]=r.storage,t[4]=r.vectors,t[5]=n,t[6]=o,t[7]=d):(o=t[6],d=t[7]),(0,B.useEffect)(o,d),l.length===0)return null;let u;t[8]!==n?(u=n("Bindings"),t[8]=n,t[9]=u):u=t[9];let p;t[10]!==u?(p=(0,a.jsx)("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:u}),t[10]=u,t[11]=p):p=t[11];let m;t[12]!==l?(m=l.map(St),t[12]=l,t[13]=m):m=t[13];let f;t[14]!==m?(f=(0,a.jsx)("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:m}),t[14]=m,t[15]=f):f=t[15];let h;return t[16]!==p||t[17]!==f?(h=(0,a.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"home-bindings",children:[p,f]}),t[16]=p,t[17]=f,t[18]=h):h=t[18],h},"bt");function _t(t){return(0,a.jsx)(We,{variant:"secondary",children:t},t)}c(_t,"yt");function wt(t){return t.binding}c(wt,"vt");function kt(t){return t.name}c(kt,"Nt");function St(t){return(0,a.jsx)(yt,{group:t},t.tab)}c(St,"_t");var Mt=[{name:"lunora_list_functions",summary:"list every query, mutation, and action with its path"},{name:"lunora_list_tables",summary:"list the schema's tables"},{name:"lunora_get_function_schema",summary:"read a function's argument JSON Schema before calling it"},{name:"lunora_run_query",summary:"run a read-only query"},{name:"lunora_run_mutation",summary:"run a mutation \u2014 writes; only when LUNORA_MCP_ALLOW_WRITES is set"},{name:"lunora_run_action",summary:"run an action \u2014 writes/effects; only when LUNORA_MCP_ALLOW_WRITES is set"}],At=c(t=>JSON.stringify({mcpServers:{lunora:{args:["-y","@lunora/mcp"],command:"npx",env:{LUNORA_ADMIN_TOKEN:"<your-admin-token>",LUNORA_URL:t}}}},null,2),"wt"),Ct=c(t=>{let e=Mt.map(r=>`- ${r.name} \u2014 ${r.summary}`).join(`
2
2
  `);return[`You have a Lunora MCP server connected to the deployment at ${t}.`,"It exposes this backend's functions and schema so you can inspect and operate it:",e,"",`Start by calling lunora_list_functions and lunora_list_tables to learn what exists, then lunora_get_function_schema before any run call. The full HTTP API is also documented at ${t}/_lunora/admin/openapi (that endpoint needs the same admin token the MCP server is configured with).`].join(`
3
3
  `)},"kt"),It=1500,Lt=c(()=>{let t=(0,_.c)(40),e=$(),{url:r}=Te(),n;t[0]!==r?(n=et(r),t[0]=r,t[1]=n):n=t[1];let s=n,[l,i]=(0,B.useState)(null),o,d;t[2]!==l?(o=c(()=>{if(l===null)return;let L=globalThis.setTimeout(()=>{i(null)},It);return()=>{globalThis.clearTimeout(L)}},"o"),d=[l],t[2]=l,t[3]=o,t[4]=d):(o=t[3],d=t[4]),(0,B.useEffect)(o,d);let u;t[5]===Symbol.for("react.memo_cache_sentinel")?(u=c((L,T)=>{tt(T)&&i(L)},"u"),t[5]=u):u=t[5];let p=u,m;t[6]!==s?(m=c(()=>{p("config",At(s))},"d"),t[6]=s,t[7]=m):m=t[7];let f=m,h;t[8]!==s?(h=c(()=>{p("prompt",Ct(s))},"p"),t[8]=s,t[9]=h):h=t[9];let g=h,x;t[10]!==e?(x=e("Connect an AI agent"),t[10]=e,t[11]=x):x=t[11];let b;t[12]!==x?(b=(0,a.jsx)("span",{className:"text-sm font-medium text-foreground",children:x}),t[12]=x,t[13]=b):b=t[13];let v;t[14]!==e?(v=e("Drive this deployment from an AI agent over the Model Context Protocol \u2014 it can list functions and tables, read schemas, and run read-only queries. Writes stay off unless you opt in."),t[14]=e,t[15]=v):v=t[15];let w;t[16]!==v?(w=(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:v}),t[16]=v,t[17]=w):w=t[17];let k;t[18]!==b||t[19]!==w?(k=(0,a.jsxs)("div",{className:"flex flex-col gap-1.5 p-4",children:[b,w]}),t[18]=b,t[19]=w,t[20]=k):k=t[20];let I;t[21]===Symbol.for("react.memo_cache_sentinel")?(I=(0,a.jsx)("code",{className:"font-mono text-xs text-muted-foreground","data-testid":"home-connect-agent-command",children:"npx -y @lunora/mcp"}),t[21]=I):I=t[21];let y;t[22]!==l||t[23]!==e?(y=e(l==="config"?"Copied":"Copy MCP config"),t[22]=l,t[23]=e,t[24]=y):y=t[24];let S;t[25]!==f||t[26]!==y?(S=(0,a.jsx)(Fe,{"data-testid":"home-connect-agent-copy-config",onClick:f,size:"xs",variant:"outline",children:y}),t[25]=f,t[26]=y,t[27]=S):S=t[27];let M;t[28]!==l||t[29]!==e?(M=e(l==="prompt"?"Copied":"Copy agent prompt"),t[28]=l,t[29]=e,t[30]=M):M=t[30];let A;t[31]!==g||t[32]!==M?(A=(0,a.jsx)(Fe,{"data-testid":"home-connect-agent-copy-prompt",onClick:g,size:"xs",variant:"outline",children:M}),t[31]=g,t[32]=M,t[33]=A):A=t[33];let N;t[34]!==S||t[35]!==A?(N=(0,a.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border bg-muted/50 px-4 py-3",children:[I,(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[S,A]})]}),t[34]=S,t[35]=A,t[36]=N):N=t[36];let C;return t[37]!==k||t[38]!==N?(C=(0,a.jsxs)(j,{className:"gap-0 py-0","data-testid":"home-connect-agent",children:[k,N]}),t[37]=k,t[38]=N,t[39]=C):C=t[39],C},"At"),$t=112,st=32,Oe=5,lt=1,jt=3,Tt=c(t=>{let e=t.slice(-16),r=Math.max(0,...e),n=st-Oe*2,s=($t-Oe*2)/e.length;return e.map((l,i)=>{let o=r>0?Math.max(0,l)/r*n:0;return{height:Math.max(0,o-jt),width:Math.max(0,s-lt*2),x:Oe+i*s+lt,y:st-Oe-o}})},"It"),Ot=c(t=>{let e=(0,_.c)(4),{data:r}=t,n;e[0]!==r?(n=Tt(r).map(qt),e[0]=r,e[1]=n):n=e[1];let s;return e[2]!==n?(s=(0,a.jsx)("svg",{"aria-hidden":"true",className:"h-8 w-28 fill-foreground","data-testid":"home-sparkline",viewBox:"0 0 112 32",children:n}),e[2]=n,e[3]=s):s=e[3],s},"Tt");function qt(t){return(0,a.jsx)("rect",{height:t.height,rx:2,width:t.width,x:t.x,y:t.y},t.x)}c(qt,"Lt");var Rt=3,Kt=c((t,e)=>{if(e==null)return t("cache not enabled");let r=e.hits+e.misses;return r===0?t("no cache traffic yet"):`${Math.round(e.hits/r*100).toString()}% ${t("cache hit")}`},"Rt"),Je=c(t=>{if(t<1e3)return`${String(Math.round(t))}ms`;let e=t>=1e4?0:1;return`${(t/1e3).toFixed(e)}s`},"Fe"),Bt=c((t,e)=>{let r=Math.max(0,Math.round((e-t)/1e3));if(r<60)return`${String(r)}s ago`;let n=Math.round(r/60);if(n<60)return`${String(n)}m ago`;let s=Math.round(n/60);return s<24?`${String(s)}h ago`:`${String(Math.round(s/24))}d ago`},"Et"),ot=c((t,e)=>{if(t===void 0||t.length===0)return[];let r=new Map;for(let n of t)r.set(n.bucketMs,(r.get(n.bucketMs)??0)+n[e]);return[...r.entries()].toSorted(([n],[s])=>n-s).map(([,n])=>n)},"Je"),it=c((t,e=!0)=>{if(t.length<4)return null;let r=Math.floor(t.length/2),n=t.slice(0,r).reduce((i,o)=>i+o,0),s=t.slice(r).reduce((i,o)=>i+o,0);if(n===0)return null;let l=(s-n)/n*100;return{positive:e?l>=0:l<=0,text:`${l>=0?"+":""}${l.toFixed(1)}%`}},"Ye"),qe=c(t=>{let e=(0,_.c)(24),{delta:r,footer:n,label:s,trend:l,unit:i,value:o}=t,d=$(),u;e[0]!==s?(u=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s}),e[0]=s,e[1]=u):u=e[1];let p;e[2]!==o?(p=(0,a.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:o}),e[2]=o,e[3]=p):p=e[3];let m;e[4]!==i?(m=i!==void 0&&(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:i}),e[4]=i,e[5]=m):m=e[5];let f;e[6]!==p||e[7]!==m?(f=(0,a.jsxs)("span",{className:"flex items-baseline gap-1.5",children:[p,m]}),e[6]=p,e[7]=m,e[8]=f):f=e[8];let h;e[9]!==l?(h=l!==void 0&&l.length>=Rt&&(0,a.jsx)(Ot,{data:l}),e[9]=l,e[10]=h):h=e[10];let g;e[11]!==f||e[12]!==h?(g=(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[f,h]}),e[11]=f,e[12]=h,e[13]=g):g=e[13];let x;e[14]!==u||e[15]!==g?(x=(0,a.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[u,g]}),e[14]=u,e[15]=g,e[16]=x):x=e[16];let b;e[17]!==r||e[18]!==n||e[19]!==d?(b=r==null?n!=null&&(0,a.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:n}):(0,a.jsxs)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px]",children:[(0,a.jsx)("span",{className:Ve("font-semibold",r.positive?"text-success":"text-destructive"),children:r.text})," ",(0,a.jsx)("span",{className:"text-muted-foreground",children:d("vs. prev.")})]}),e[17]=r,e[18]=n,e[19]=d,e[20]=b):b=e[20];let v;return e[21]!==x||e[22]!==b?(v=(0,a.jsxs)(j,{className:"justify-between gap-0 py-0",children:[x,b]}),e[21]=x,e[22]=b,e[23]=v):v=e[23],v},"Oe"),Dt=c(()=>{let t=(0,_.c)(1),e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,a.jsx)("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"m9 6 6 6-6 6"})}),t[0]=e):e=t[0],e},"Bt"),He=c(t=>{let e=(0,_.c)(7),{command:r,label:n}=t,s;e[0]!==n?(s=(0,a.jsx)("div",{className:"p-4",children:(0,a.jsx)("span",{className:"text-sm font-medium text-foreground",children:n})}),e[0]=n,e[1]=s):s=e[1];let l;e[2]!==r?(l=(0,a.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5",children:(0,a.jsx)("code",{className:"font-mono text-xs text-muted-foreground",children:r})}),e[2]=r,e[3]=l):l=e[3];let i;return e[4]!==s||e[5]!==l?(i=(0,a.jsxs)(j,{className:"justify-between gap-0 py-0",children:[s,l]}),e[4]=s,e[5]=l,e[6]=i):i=e[6],i},"je"),ct=c(t=>{let e=(0,_.c)(18),{count:r,onView:n,testId:s,title:l}=t,i=$(),o;e[0]!==l?(o=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=o):o=e[1];let d;e[2]!==r||e[3]!==i?(d=r===null?(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:i("No data yet")}):(0,a.jsx)(We,{variant:r>0?"destructive":"success",children:r>0?r:i("All clear")}),e[2]=r,e[3]=i,e[4]=d):d=e[4];let u;e[5]!==o||e[6]!==d?(u=(0,a.jsxs)("div",{className:"flex items-start justify-between gap-2 p-4",children:[o,d]}),e[5]=o,e[6]=d,e[7]=u):u=e[7];let p;e[8]!==i?(p=i("View"),e[8]=i,e[9]=p):p=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=(0,a.jsx)(Dt,{}),e[10]=m):m=e[10];let f;e[11]!==n||e[12]!==p?(f=(0,a.jsxs)("button",{className:"flex items-center gap-1 border-t border-border bg-muted/50 px-4 py-2.5 text-[12px] font-medium text-foreground outline-none transition-colors hover:bg-muted focus-visible:bg-muted",onClick:n,type:"button",children:[p,m]}),e[11]=n,e[12]=p,e[13]=f):f=e[13];let h;return e[14]!==u||e[15]!==f||e[16]!==s?(h=(0,a.jsxs)(j,{className:"justify-between gap-0 py-0","data-testid":s,children:[u,f]}),e[14]=u,e[15]=f,e[16]=s,e[17]=h):h=e[17],h},"Ze"),Pt=c(t=>{let e=(0,_.c)(7),{functions:r}=t,n=$(),s;if(e[0]!==r||e[1]!==n){let l=[...r].toSorted(Wt).slice(0,5),i;e[3]!==n?(i=n("Top functions"),e[3]=n,e[4]=i):i=e[4];let o;e[5]!==i?(o=(0,a.jsx)("div",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i})}),e[5]=i,e[6]=o):o=e[6],s=(0,a.jsxs)(j,{className:"gap-0 py-0","data-testid":"home-top-functions",children:[o,l.length===0?(0,a.jsx)("p",{className:"px-4 py-8 text-center text-xs text-muted-foreground",children:n("No functions called yet.")}):(0,a.jsxs)("div",{className:"divide-y divide-border",children:[(0,a.jsxs)("div",{className:"grid grid-cols-[1fr_auto_auto_auto] gap-4 px-4 py-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:[(0,a.jsx)("span",{children:n("Function")}),(0,a.jsx)("span",{className:"text-end",children:n("Calls")}),(0,a.jsx)("span",{className:"w-12 text-end",children:n("Avg")}),(0,a.jsx)("span",{className:"w-8 text-end",children:n("Err")})]}),l.map(Ft)]})]}),e[0]=r,e[1]=n,e[2]=s}else s=e[2];return s},"Pt"),zt=c(t=>{let e=(0,_.c)(26),{subs:r}=t,n=$(),s;e[0]!==n?(s=n("Live connections"),e[0]=n,e[1]=s):s=e[1];let l;e[2]!==s?(l=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s}),e[2]=s,e[3]=l):l=e[3];let i=r?.totalConnections??0,o;e[4]!==i?(o=i.toLocaleString(),e[4]=i,e[5]=o):o=e[5];let d;e[6]!==o?(d=(0,a.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:o}),e[6]=o,e[7]=d):d=e[7];let u;e[8]!==n?(u=n("sockets"),e[8]=n,e[9]=u):u=e[9];let p;e[10]!==u?(p=(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:u}),e[10]=u,e[11]=p):p=e[11];let m;e[12]!==d||e[13]!==p?(m=(0,a.jsxs)("span",{className:"flex items-baseline gap-1.5",children:[d,p]}),e[12]=d,e[13]=p,e[14]=m):m=e[14];let f=r?.totalSubscriptions??0,h;e[15]!==f?(h=f.toLocaleString(),e[15]=f,e[16]=h):h=e[16];let g;e[17]!==n?(g=n("active subscriptions"),e[17]=n,e[18]=g):g=e[18];let x;e[19]!==h||e[20]!==g?(x=(0,a.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:[h," ",g]}),e[19]=h,e[20]=g,e[21]=x):x=e[21];let b;return e[22]!==x||e[23]!==l||e[24]!==m?(b=(0,a.jsx)(j,{"data-testid":"home-live-connections",children:(0,a.jsxs)(Ue,{className:"flex flex-col gap-2.5 py-4",children:[l,m,x]})}),e[22]=x,e[23]=l,e[24]=m,e[25]=b):b=e[25],b},"Dt"),Et=c(t=>{let e=(0,_.c)(7),{entries:r}=t,n=$(),s;if(e[0]!==r||e[1]!==n){let l=Date.now(),i;e[3]!==n?(i=n("Recent activity"),e[3]=n,e[4]=i):i=e[4];let o;e[5]!==i?(o=(0,a.jsx)("div",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i})}),e[5]=i,e[6]=o):o=e[6],s=(0,a.jsxs)(j,{className:"gap-0 py-0","data-testid":"home-recent-activity",children:[o,r.length===0?(0,a.jsx)("p",{className:"px-4 py-8 text-center text-xs text-muted-foreground",children:n("No recent activity.")}):(0,a.jsx)("ul",{className:"divide-y divide-border",children:r.slice(0,5).map(d=>(0,a.jsxs)("li",{className:"flex items-center justify-between gap-3 px-4 py-2 text-[13px]",children:[(0,a.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-muted-foreground/40"}),(0,a.jsxs)("span",{className:"truncate text-foreground",children:[d.op,d.table!==void 0&&(0,a.jsxs)("span",{className:"text-muted-foreground",children:[" \xB7 ",d.table,d.id===void 0?"":`#${d.id}`]})]})]}),(0,a.jsx)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:Bt(d.ts,l)})]},d.seq))})]}),e[0]=r,e[1]=n,e[2]=s}else s=e[2];return s},"jt"),Vt=c(t=>{let e=t.reduce((r,n)=>r+n.calls,0);return e===0?null:t.reduce((r,n)=>r+n.totalDurationMs,0)/e},"Ft"),sn=c(t=>{let e=(0,_.c)(149),{initialShardKey:r}=t,n=$(),s=Ee(),l=r??"",i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];let o;e[1]!==l?(o={shardKey:l},e[1]=l,e[2]=o):o=e[2];let d=_e(D.getMetrics,i,o),u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u={},e[3]=u):u=e[3];let p;e[4]!==l?(p={shardKey:l},e[4]=l,e[5]=p):p=e[5];let m=_e(D.getFunctionStats,u,p),f,h;e[6]===Symbol.for("react.memo_cache_sentinel")?(f={},h={shardKey:""},e[6]=f,e[7]=h):(f=e[6],h=e[7]);let g=_e(D.getSecurityAudit,f,h),x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x={},e[8]=x):x=e[8];let b;e[9]!==l?(b={shardKey:l},e[9]=l,e[10]=b):b=e[10];let v=_e(D.listSubscriptions,x,b),w;e[11]===Symbol.for("react.memo_cache_sentinel")?(w={},e[11]=w):w=e[11];let k;e[12]!==l?(k={shardKey:l},e[12]=l,e[13]=k):k=e[13];let I=_e(D.getAuditLog,w,k),y=d.data??null,S,M,A,N,C,L,T,O,q,P,z,E,R,K,V,W,F,U;if(e[14]!==I.data||e[15]!==g.data||e[16]!==y||e[17]!==d.data||e[18]!==s||e[19]!==m.data||e[20]!==v.data||e[21]!==n){N=Array.isArray(m.data?.functions)?m.data.functions:[],T=v.data??null;let Me;e[40]!==I.data?(Me=Array.isArray(I.data?.entries)?I.data.entries:[],e[40]=I.data,e[41]=Me):Me=e[41],M=Me,C=d.data===void 0||m.data===void 0?null:at(y,N).length,L=Array.isArray(g.data?.findings)?g.data.findings.length:null;let Ae;e[42]!==s?(Ae=c(()=>{Ne(s({to:"/security"}))},"Ce"),e[42]=s,e[43]=Ae):Ae=e[43],U=Ae;let Ce;e[44]!==s?(Ce=c(()=>{Ne(s({to:"/insights"}))},"Ae"),e[44]=s,e[45]=Ce):Ce=e[45],F=Ce;let Ie=ot(y?.history,"calls"),Le=ot(y?.history,"errors"),Ye=Vt(N),$e=Math.max(0,...N.map(Ut)),je;e[46]!==y||e[47]!==n?(je=y===null?void 0:Kt(n,y.cache),e[46]=y,e[47]=n,e[48]=je):je=e[48],A=je,V="flex flex-col gap-6",W="lunora-home",z="grid gap-3 sm:grid-cols-2 xl:grid-cols-4",E="home-health";let Ke=it(Ie),xe;e[49]!==n?(xe=n("Requests"),e[49]=n,e[50]=xe):xe=e[50];let Be=y?.requests??0,be;e[51]!==Be?(be=Be.toLocaleString(),e[51]=Be,e[52]=be):be=e[52],e[53]!==Ie||e[54]!==Ke||e[55]!==xe||e[56]!==be?(R=(0,a.jsx)(qe,{delta:Ke,label:xe,trend:Ie,value:be}),e[53]=Ie,e[54]=Ke,e[55]=xe,e[56]=be,e[57]=R):R=e[57];let De=it(Le,!1),ye;e[58]!==n?(ye=n("Errors"),e[58]=n,e[59]=ye):ye=e[59];let Pe=y?.errors??0,ve;e[60]!==Pe?(ve=Pe.toLocaleString(),e[60]=Pe,e[61]=ve):ve=e[61],e[62]!==Le||e[63]!==De||e[64]!==ye||e[65]!==ve?(K=(0,a.jsx)(qe,{delta:De,label:ye,trend:Le,value:ve}),e[62]=Le,e[63]=De,e[64]=ye,e[65]=ve,e[66]=K):K=e[66],S=qe,e[67]!==$e||e[68]!==n?(O=$e>0?`${n("max")} ${Je($e)}`:void 0,e[67]=$e,e[68]=n,e[69]=O):O=e[69],e[70]!==n?(q=n("Avg latency"),e[70]=n,e[71]=q):q=e[71],P=Ye===null?"\u2014":Je(Ye),e[14]=I.data,e[15]=g.data,e[16]=y,e[17]=d.data,e[18]=s,e[19]=m.data,e[20]=v.data,e[21]=n,e[22]=S,e[23]=M,e[24]=A,e[25]=N,e[26]=C,e[27]=L,e[28]=T,e[29]=O,e[30]=q,e[31]=P,e[32]=z,e[33]=E,e[34]=R,e[35]=K,e[36]=V,e[37]=W,e[38]=F,e[39]=U}else S=e[22],M=e[23],A=e[24],N=e[25],C=e[26],L=e[27],T=e[28],O=e[29],q=e[30],P=e[31],z=e[32],E=e[33],R=e[34],K=e[35],V=e[36],W=e[37],F=e[38],U=e[39];let H;e[72]!==S||e[73]!==O||e[74]!==q||e[75]!==P?(H=(0,a.jsx)(S,{footer:O,label:q,value:P}),e[72]=S,e[73]=O,e[74]=q,e[75]=P,e[76]=H):H=e[76];let J;e[77]!==n?(J=n("Database size"),e[77]=n,e[78]=J):J=e[78];let Re=y?.databaseSize??null,G;e[79]!==Re?(G=Xe(Re),e[79]=Re,e[80]=G):G=e[80];let Y;e[81]!==A||e[82]!==J||e[83]!==G?(Y=(0,a.jsx)(qe,{footer:A,label:J,value:G}),e[81]=A,e[82]=J,e[83]=G,e[84]=Y):Y=e[84];let Z;e[85]!==z||e[86]!==E||e[87]!==R||e[88]!==K||e[89]!==H||e[90]!==Y?(Z=(0,a.jsxs)("div",{className:z,"data-testid":E,children:[R,K,H,Y]}),e[85]=z,e[86]=E,e[87]=R,e[88]=K,e[89]=H,e[90]=Y,e[91]=Z):Z=e[91];let we;e[92]===Symbol.for("react.memo_cache_sentinel")?(we=(0,a.jsx)(Nt,{}),e[92]=we):we=e[92];let Q;e[93]!==N?(Q=(0,a.jsx)("div",{className:"lg:col-span-2",children:(0,a.jsx)(Pt,{functions:N})}),e[93]=N,e[94]=Q):Q=e[94];let X;e[95]!==T?(X=(0,a.jsx)(zt,{subs:T}),e[95]=T,e[96]=X):X=e[96];let ee;e[97]!==M?(ee=(0,a.jsx)(Et,{entries:M}),e[97]=M,e[98]=ee):ee=e[98];let te;e[99]!==X||e[100]!==ee?(te=(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[X,ee]}),e[99]=X,e[100]=ee,e[101]=te):te=e[101];let ne;e[102]!==Q||e[103]!==te?(ne=(0,a.jsxs)("div",{className:"grid gap-3 lg:grid-cols-3",children:[Q,te]}),e[102]=Q,e[103]=te,e[104]=ne):ne=e[104];let ae;e[105]!==n?(ae=n("Advisors"),e[105]=n,e[106]=ae):ae=e[106];let re;e[107]!==ae?(re=(0,a.jsx)("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:ae}),e[107]=ae,e[108]=re):re=e[108];let se;e[109]!==C||e[110]!==L||e[111]!==n||e[112]!==F||e[113]!==U?(se=L===0&&C===0?(0,a.jsx)(nt,{description:n("No security or performance issues detected."),icon:(0,a.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,a.jsx)("path",{d:"M12 3 4 6v5c0 5 3.4 8.5 8 10 4.6-1.5 8-5 8-10V6l-8-3Z"}),(0,a.jsx)("path",{d:"m9 12 2 2 4-4"})]}),testId:"home-advisors-clear",title:n("No issues found")}):(0,a.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,a.jsx)(ct,{count:L,onView:U,testId:"home-security",title:n("Security findings")}),(0,a.jsx)(ct,{count:C,onView:F,testId:"home-performance",title:n("Performance issues")})]}),e[109]=C,e[110]=L,e[111]=n,e[112]=F,e[113]=U,e[114]=se):se=e[114];let le;e[115]!==re||e[116]!==se?(le=(0,a.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"home-advisors",children:[re,se]}),e[115]=re,e[116]=se,e[117]=le):le=e[117];let oe;e[118]!==n?(oe=n("Get connected"),e[118]=n,e[119]=oe):oe=e[119];let ie;e[120]!==oe?(ie=(0,a.jsx)("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:oe}),e[120]=oe,e[121]=ie):ie=e[121];let ce;e[122]!==n?(ce=n("Client SDK"),e[122]=n,e[123]=ce):ce=e[123];let de;e[124]!==ce?(de=(0,a.jsx)(He,{command:"npm i @lunora/client",label:ce}),e[124]=ce,e[125]=de):de=e[125];let me;e[126]!==n?(me=n("React"),e[126]=n,e[127]=me):me=e[127];let ue;e[128]!==me?(ue=(0,a.jsx)(He,{command:"npm i @lunora/react",label:me}),e[128]=me,e[129]=ue):ue=e[129];let pe;e[130]!==n?(pe=n("CLI"),e[130]=n,e[131]=pe):pe=e[131];let fe;e[132]!==pe?(fe=(0,a.jsx)(He,{command:"lunora dev",label:pe}),e[132]=pe,e[133]=fe):fe=e[133];let he;e[134]!==de||e[135]!==ue||e[136]!==fe?(he=(0,a.jsxs)("div",{className:"grid gap-3 sm:grid-cols-3",children:[de,ue,fe]}),e[134]=de,e[135]=ue,e[136]=fe,e[137]=he):he=e[137];let ke;e[138]===Symbol.for("react.memo_cache_sentinel")?(ke=(0,a.jsx)(Lt,{}),e[138]=ke):ke=e[138];let ge;e[139]!==ie||e[140]!==he?(ge=(0,a.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"home-get-connected",children:[ie,he,ke]}),e[139]=ie,e[140]=he,e[141]=ge):ge=e[141];let Se;return e[142]!==V||e[143]!==W||e[144]!==Z||e[145]!==ne||e[146]!==le||e[147]!==ge?(Se=(0,a.jsxs)("div",{className:V,"data-testid":W,children:[Z,we,ne,le,ge]}),e[142]=V,e[143]=W,e[144]=Z,e[145]=ne,e[146]=le,e[147]=ge,e[148]=Se):Se=e[148],Se},"as");function Wt(t,e){return e.calls-t.calls}c(Wt,"Ut");function Ft(t){return(0,a.jsxs)("div",{className:"grid grid-cols-[1fr_auto_auto_auto] items-center gap-4 px-4 py-2 text-[13px]",children:[(0,a.jsx)("span",{className:"truncate font-mono text-xs text-foreground",children:t.path}),(0,a.jsx)("span",{className:"text-end tabular-nums",children:t.calls.toLocaleString()}),(0,a.jsx)("span",{className:"w-12 text-end tabular-nums text-muted-foreground",children:Je(t.calls>0?t.totalDurationMs/t.calls:0)}),(0,a.jsx)("span",{className:Ve("w-8 text-end tabular-nums",t.errors>0?"text-destructive":"text-muted-foreground"),children:t.errors})]},t.path)}c(Ft,"qt");function Ut(t){return t.maxDurationMs}c(Ut,"Kt");export{xt as a,sn as b};
@@ -1 +1 @@
1
- import{a as D}from"./chunk-J3BZWYJQ.js";import{a as k}from"./chunk-MJTVTUNI.js";import"./chunk-DA2CAFXI.js";import"./chunk-RTS5G3ET.js";import"./chunk-QRA7AKYO.js";import"./chunk-V3BE427M.js";import"./chunk-CKEQX655.js";import"./chunk-UD5REVU2.js";import{a as I}from"./chunk-RCXNYW7P.js";import{b as w}from"./chunk-UQA2AJGI.js";import"./chunk-T3ZCW3RG.js";import{a as B}from"./chunk-IUGNIG6L.js";import"./chunk-LSEUUZN4.js";import{a as A,b as C,c as P,d as b,e as l,f as n}from"./chunk-7QEZ2SFW.js";import"./chunk-WCWP4EAW.js";import"./chunk-BX7TFVCC.js";import"./chunk-4PI2OSSP.js";import{a as u}from"./chunk-2W4UO5BC.js";import{c as p}from"./chunk-FBDIQ67D.js";import{a as v,e as S}from"./chunk-OK2QU2EV.js";import{j as R}from"./chunk-FACXM2UB.js";import"./chunk-ZPQBVYNN.js";import{B as j,w as N}from"./chunk-GNI37YCV.js";import"./chunk-PDBW6GTJ.js";import"./chunk-GWNGVKLG.js";import{b as Q}from"./chunk-6G3E4PJ2.js";import{a as m,d as H}from"./chunk-5PEAXTYQ.js";var e=H(Q(),1);var _="payment_subscriptions",O="payment_events",V=[_,O],Y={},E=new Set(["active","trialing"]),z=new Set(["past_due","unpaid"]),s=m((a,t)=>{if(a[t]!==void 0)return a[t];let h=a.__doc__;return typeof h=="string"?R(h)?.[t]:void 0},"a"),o=m(a=>typeof a=="string"?a:typeof a=="number"||typeof a=="bigint"||typeof a=="boolean"?String(a):"","s"),J=m(a=>E.has(a)?"default":z.has(a)?"destructive":"outline","q"),ie=m(({limit:a=100})=>{let t=j(),h=k(),{data:x}=p(u.listTables,Y,{live:!0}),F=x!==void 0,L=Array.isArray(x)&&V.every(r=>x.some(d=>d.name===r)),c=h.payments&&L,i=p(u.readTablePage,{filters:[],limit:a,offset:0,orderBy:{column:"updatedAt",direction:"desc"},search:"",table:_},{enabled:c}),f=p(u.readTablePage,{filters:[],limit:25,offset:0,orderBy:{column:"processedAt",direction:"desc"},search:"",table:O},{enabled:c}),g=p(u.facetColumn,{column:"state",table:_},{enabled:c});D(()=>{if(c)return Promise.all([i.poll(),f.poll(),g.poll()])},!0);let y=i.data?.rows??[],M=f.data?.rows??[],U=i.error??f.error,q=i.error===null?f.errorSource:i.errorSource,G=i.data?.total??y.length,T=g.data?.values===void 0?y.filter(r=>E.has(o(s(r,"state")))).length:g.data.values.reduce((r,d)=>r+(E.has(o(d.value))?d.count:0),0);return F&&!c?(0,e.jsx)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:(0,e.jsx)(I,{description:t("No @lunora/payment tables found in this deployment. Add `.extend(paymentExtension)` to 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)(v,{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:T}),(0,e.jsx)(w,{variant:"default",children:t("{count} active",{count:T})})]})]}),(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:G})})]})}),U===null?void 0:(0,e.jsx)(B,{error:q}),y.length===0&&!i.isLoading?(0,e.jsx)(I,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(v,{className:"overflow-hidden py-0",children:(0,e.jsx)(S,{className:"px-0",children:(0,e.jsxs)(A,{children:[(0,e.jsx)(C,{children:(0,e.jsxs)(b,{children:[(0,e.jsx)(l,{children:t("Provider")}),(0,e.jsx)(l,{children:t("Reference")}),(0,e.jsx)(l,{children:t("Plan")}),(0,e.jsx)(l,{children:t("State")}),(0,e.jsx)(l,{children:t("Renews")})]})}),(0,e.jsx)(P,{children:y.map(r=>{let d=o(s(r,"state"));return(0,e.jsxs)(b,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(n,{children:o(s(r,"provider"))}),(0,e.jsx)(n,{children:o(s(r,"referenceId"))}),(0,e.jsx)(n,{children:o(s(r,"priceId"))}),(0,e.jsx)(n,{children:(0,e.jsx)(w,{variant:J(d),children:d})}),(0,e.jsx)(n,{children:N(s(r,"currentPeriodEnd"))})]},o(s(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(v,{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)(S,{className:"px-0",children:(0,e.jsx)(A,{children:(0,e.jsx)(P,{children:M.map(r=>(0,e.jsxs)(b,{"data-testid":"payment-event-row",children:[(0,e.jsx)(n,{children:o(s(r,"provider"))}),(0,e.jsx)(n,{className:"font-medium",children:o(s(r,"type"))}),(0,e.jsx)(n,{className:"text-muted-foreground",children:o(s(r,"providerEventId"))}),(0,e.jsx)(n,{children:N(s(r,"processedAt"))})]},o(s(r,"providerEventId"))))})})})]})]})},"oe");export{ie as PaymentsPanel};
1
+ import{a as D}from"./chunk-EPWCW2DF.js";import{a as k}from"./chunk-5RX5CQSU.js";import"./chunk-DA2CAFXI.js";import"./chunk-RTS5G3ET.js";import"./chunk-QRA7AKYO.js";import"./chunk-V3BE427M.js";import"./chunk-CKEQX655.js";import"./chunk-UD5REVU2.js";import{a as I}from"./chunk-RCXNYW7P.js";import{b as w}from"./chunk-UQA2AJGI.js";import"./chunk-T3ZCW3RG.js";import{a as B}from"./chunk-YEXTJUKQ.js";import"./chunk-LSEUUZN4.js";import{a as A,b as C,c as P,d as b,e as l,f as n}from"./chunk-7QEZ2SFW.js";import"./chunk-OZAOWE7T.js";import"./chunk-BBDTJG2K.js";import"./chunk-4PI2OSSP.js";import{a as u}from"./chunk-2W4UO5BC.js";import{c as p}from"./chunk-4N76XUNG.js";import{a as v,e as S}from"./chunk-OK2QU2EV.js";import{e as R}from"./chunk-SHHGIT7M.js";import"./chunk-ZPQBVYNN.js";import{B as j,w as N}from"./chunk-GNI37YCV.js";import"./chunk-PDBW6GTJ.js";import"./chunk-GWNGVKLG.js";import{b as Q}from"./chunk-6G3E4PJ2.js";import{a as m,d as H}from"./chunk-5PEAXTYQ.js";var e=H(Q(),1);var _="payment_subscriptions",O="payment_events",V=[_,O],Y={},E=new Set(["active","trialing"]),z=new Set(["past_due","unpaid"]),s=m((a,t)=>{if(a[t]!==void 0)return a[t];let h=a.__doc__;return typeof h=="string"?R(h)?.[t]:void 0},"a"),o=m(a=>typeof a=="string"?a:typeof a=="number"||typeof a=="bigint"||typeof a=="boolean"?String(a):"","s"),J=m(a=>E.has(a)?"default":z.has(a)?"destructive":"outline","q"),ie=m(({limit:a=100})=>{let t=j(),h=k(),{data:x}=p(u.listTables,Y,{live:!0}),F=x!==void 0,L=Array.isArray(x)&&V.every(r=>x.some(d=>d.name===r)),c=h.payments&&L,i=p(u.readTablePage,{filters:[],limit:a,offset:0,orderBy:{column:"updatedAt",direction:"desc"},search:"",table:_},{enabled:c}),f=p(u.readTablePage,{filters:[],limit:25,offset:0,orderBy:{column:"processedAt",direction:"desc"},search:"",table:O},{enabled:c}),g=p(u.facetColumn,{column:"state",table:_},{enabled:c});D(()=>{if(c)return Promise.all([i.poll(),f.poll(),g.poll()])},!0);let y=i.data?.rows??[],M=f.data?.rows??[],U=i.error??f.error,q=i.error===null?f.errorSource:i.errorSource,G=i.data?.total??y.length,T=g.data?.values===void 0?y.filter(r=>E.has(o(s(r,"state")))).length:g.data.values.reduce((r,d)=>r+(E.has(o(d.value))?d.count:0),0);return F&&!c?(0,e.jsx)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:(0,e.jsx)(I,{description:t("No @lunora/payment tables found in this deployment. Add `.extend(paymentExtension)` to 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)(v,{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:T}),(0,e.jsx)(w,{variant:"default",children:t("{count} active",{count:T})})]})]}),(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:G})})]})}),U===null?void 0:(0,e.jsx)(B,{error:q}),y.length===0&&!i.isLoading?(0,e.jsx)(I,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(v,{className:"overflow-hidden py-0",children:(0,e.jsx)(S,{className:"px-0",children:(0,e.jsxs)(A,{children:[(0,e.jsx)(C,{children:(0,e.jsxs)(b,{children:[(0,e.jsx)(l,{children:t("Provider")}),(0,e.jsx)(l,{children:t("Reference")}),(0,e.jsx)(l,{children:t("Plan")}),(0,e.jsx)(l,{children:t("State")}),(0,e.jsx)(l,{children:t("Renews")})]})}),(0,e.jsx)(P,{children:y.map(r=>{let d=o(s(r,"state"));return(0,e.jsxs)(b,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(n,{children:o(s(r,"provider"))}),(0,e.jsx)(n,{children:o(s(r,"referenceId"))}),(0,e.jsx)(n,{children:o(s(r,"priceId"))}),(0,e.jsx)(n,{children:(0,e.jsx)(w,{variant:J(d),children:d})}),(0,e.jsx)(n,{children:N(s(r,"currentPeriodEnd"))})]},o(s(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(v,{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)(S,{className:"px-0",children:(0,e.jsx)(A,{children:(0,e.jsx)(P,{children:M.map(r=>(0,e.jsxs)(b,{"data-testid":"payment-event-row",children:[(0,e.jsx)(n,{children:o(s(r,"provider"))}),(0,e.jsx)(n,{className:"font-medium",children:o(s(r,"type"))}),(0,e.jsx)(n,{className:"text-muted-foreground",children:o(s(r,"providerEventId"))}),(0,e.jsx)(n,{children:N(s(r,"processedAt"))})]},o(s(r,"providerEventId"))))})})})]})]})},"oe");export{ie as PaymentsPanel};
@@ -1 +1 @@
1
- import{a as v}from"./chunk-SR6CPTRT.js";import{a as Q}from"./chunk-J3BZWYJQ.js";import{a as L}from"./chunk-J45HAKBU.js";import{a as G}from"./chunk-FHLODLBC.js";import"./chunk-3D67ZJRW.js";import"./chunk-ZSWW2UGP.js";import"./chunk-IHGRWY3Y.js";import"./chunk-OWRKSQPE.js";import"./chunk-4EPW63HS.js";import"./chunk-UD5REVU2.js";import{a as E}from"./chunk-RCXNYW7P.js";import{b as $}from"./chunk-UQA2AJGI.js";import"./chunk-T3ZCW3RG.js";import{a as W}from"./chunk-IUGNIG6L.js";import"./chunk-LSEUUZN4.js";import{a as q,b as H,c as O,d as D,e as T,f as K}from"./chunk-7QEZ2SFW.js";import"./chunk-WCWP4EAW.js";import"./chunk-BX7TFVCC.js";import"./chunk-4PI2OSSP.js";import{a as _}from"./chunk-2W4UO5BC.js";import{c as j}from"./chunk-FBDIQ67D.js";import{a as B}from"./chunk-OK2QU2EV.js";import"./chunk-FACXM2UB.js";import"./chunk-ZPQBVYNN.js";import{B as A}from"./chunk-GNI37YCV.js";import"./chunk-PDBW6GTJ.js";import{a as J}from"./chunk-GWNGVKLG.js";import{b as V}from"./chunk-6G3E4PJ2.js";import{a as S,d as F}from"./chunk-5PEAXTYQ.js";var R=F(J(),1);var t=F(V(),1);var U=S(c=>`${c.toString()} ms`,"D"),X=S(c=>c.totalConnections===0&&c.shapePoke.passes===0&&c.whisper.passes===0&&c.shapeProbe.run===0&&c.shapeProbe.served===0&&c.globalPoll.drains===0&&c.globalPoll.pairsSkipped===0,"J"),z=S(c=>{let e=(0,R.c)(48),{counters:o,includeTiming:a,prefix:r,t:l,title:u}=c,d=`${r}-section`,n;e[0]!==u?(n=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:u}),e[0]=u,e[1]=n):n=e[1];let s=`${r}-stats`,i;e[2]!==l?(i=l("Passes"),e[2]=l,e[3]=i):i=e[3];let m=`${r}-passes`,I;e[4]!==o.passes||e[5]!==i||e[6]!==m?(I=(0,t.jsx)(v,{label:i,testId:m,value:o.passes}),e[4]=o.passes,e[5]=i,e[6]=m,e[7]=I):I=e[7];let g;e[8]!==l?(g=l("Sockets iterated"),e[8]=l,e[9]=g):g=e[9];let k=`${r}-iterated`,p;e[10]!==o.socketsIterated||e[11]!==g||e[12]!==k?(p=(0,t.jsx)(v,{label:g,testId:k,value:o.socketsIterated}),e[10]=o.socketsIterated,e[11]=g,e[12]=k,e[13]=p):p=e[13];let f;e[14]!==l?(f=l("Delivered"),e[14]=l,e[15]=f):f=e[15];let y=`${r}-delivered`,h;e[16]!==o.socketsDelivered||e[17]!==f||e[18]!==y?(h=(0,t.jsx)(v,{label:f,testId:y,value:o.socketsDelivered}),e[16]=o.socketsDelivered,e[17]=f,e[18]=y,e[19]=h):h=e[19];let x;e[20]!==l?(x=l("Peak width"),e[20]=l,e[21]=x):x=e[21];let N=`${r}-peak`,b;e[22]!==o.peakSocketsIterated||e[23]!==x||e[24]!==N?(b=(0,t.jsx)(v,{label:x,testId:N,value:o.peakSocketsIterated}),e[22]=o.peakSocketsIterated,e[23]=x,e[24]=N,e[25]=b):b=e[25];let C;e[26]!==o.totalMs||e[27]!==a||e[28]!==r||e[29]!==l?(C=a&&(0,t.jsx)(v,{label:l("Total time"),testId:`${r}-total-ms`,value:U(o.totalMs)}),e[26]=o.totalMs,e[27]=a,e[28]=r,e[29]=l,e[30]=C):C=e[30];let P;e[31]!==o.maxMs||e[32]!==a||e[33]!==r||e[34]!==l?(P=a&&(0,t.jsx)(v,{label:l("Max time"),testId:`${r}-max-ms`,value:U(o.maxMs)}),e[31]=o.maxMs,e[32]=a,e[33]=r,e[34]=l,e[35]=P):P=e[35];let M;e[36]!==h||e[37]!==b||e[38]!==C||e[39]!==P||e[40]!==s||e[41]!==I||e[42]!==p?(M=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":s,children:[I,p,h,b,C,P]}),e[36]=h,e[37]=b,e[38]=C,e[39]=P,e[40]=s,e[41]=I,e[42]=p,e[43]=M):M=e[43];let w;return e[44]!==d||e[45]!==M||e[46]!==n?(w=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":d,children:[n,M]}),e[44]=d,e[45]=M,e[46]=n,e[47]=w):w=e[47],w},"F"),Y=S(c=>{let e=(0,R.c)(20),{counters:o,t:a}=c,r;e[0]!==a?(r=a("Membership probes"),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==r?(l=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:r}),e[2]=r,e[3]=l):l=e[3];let u;e[4]!==a?(u=a("Queries run"),e[4]=a,e[5]=u):u=e[5];let d;e[6]!==o.run||e[7]!==u?(d=(0,t.jsx)(v,{label:u,testId:"fanout-probe-run",value:o.run}),e[6]=o.run,e[7]=u,e[8]=d):d=e[8];let n;e[9]!==a?(n=a("Shared from cache"),e[9]=a,e[10]=n):n=e[10];let s;e[11]!==o.served||e[12]!==n?(s=(0,t.jsx)(v,{label:n,testId:"fanout-probe-served",value:o.served}),e[11]=o.served,e[12]=n,e[13]=s):s=e[13];let i;e[14]!==d||e[15]!==s?(i=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"fanout-probe-stats",children:[d,s]}),e[14]=d,e[15]=s,e[16]=i):i=e[16];let m;return e[17]!==l||e[18]!==i?(m=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-probe-section",children:[l,i]}),e[17]=l,e[18]=i,e[19]=m):m=e[19],m},"V"),Z=S(c=>{let e=(0,R.c)(20),{counters:o,t:a}=c,r;e[0]!==a?(r=a("Global shape polls"),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==r?(l=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:r}),e[2]=r,e[3]=l):l=e[3];let u;e[4]!==a?(u=a("Global reads"),e[4]=a,e[5]=u):u=e[5];let d;e[6]!==o.drains||e[7]!==u?(d=(0,t.jsx)(v,{label:u,testId:"fanout-global-poll-drains",value:o.drains}),e[6]=o.drains,e[7]=u,e[8]=d):d=e[8];let n;e[9]!==a?(n=a("Pairs skipped"),e[9]=a,e[10]=n):n=e[10];let s;e[11]!==o.pairsSkipped||e[12]!==n?(s=(0,t.jsx)(v,{label:n,testId:"fanout-global-poll-pairs-skipped",value:o.pairsSkipped}),e[11]=o.pairsSkipped,e[12]=n,e[13]=s):s=e[13];let i;e[14]!==d||e[15]!==s?(i=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"fanout-global-poll-stats",children:[d,s]}),e[14]=d,e[15]=s,e[16]=i):i=e[16];let m;return e[17]!==l||e[18]!==i?(m=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-global-poll-section",children:[l,i]}),e[17]=l,e[18]=i,e[19]=m):m=e[19],m},"X"),pe=S(c=>{let e=(0,R.c)(32),{initialShardKey:o}=c,a=A(),{queryShardKey:r,setShardKey:l,shardKey:u}=L(o),d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={},e[0]=d):d=e[0];let n;e[1]!==r?(n={keepPreviousData:!0,shardKey:r},e[1]=r,e[2]=n):n=e[2];let{data:s,error:i,errorSource:m,poll:I}=j(_.getFanoutMetrics,d,n);Q(I,!0);let g;e[3]!==s?(g=s!==void 0&&X(s),e[3]=s,e[4]=g):g=e[4];let k=g,p;e[5]!==l||e[6]!==u?(p=(0,t.jsx)(G,{onChange:l,testId:"fanout-shard-input",value:u}),e[5]=l,e[6]=u,e[7]=p):p=e[7];let f;e[8]!==s||e[9]!==a?(f=s!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"fanout-count",children:[s.promoted&&(0,t.jsx)($,{"data-testid":"fanout-promoted",variant:s.relayCount>=s.maxRelays?"destructive":"default",children:s.relayCount>=s.maxRelays?a("auto-scaled: {relayCount}/{maxRelays} relays (at ceiling)",{maxRelays:s.maxRelays,relayCount:s.relayCount}):a("auto-scaled: {relayCount}/{maxRelays} relays",{maxRelays:s.maxRelays,relayCount:s.relayCount})}),(0,t.jsx)($,{variant:"secondary",children:a("{count} connections",{count:s.totalConnections})}),(0,t.jsx)($,{variant:"secondary",children:a("peak {count} subscribers",{count:s.peakSubscribers})})]}),e[8]=s,e[9]=a,e[10]=f):f=e[10];let y;e[11]!==p||e[12]!==f?(y=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[p,f]}),e[11]=p,e[12]=f,e[13]=y):y=e[13];let h;e[14]!==i||e[15]!==m||e[16]!==r?(h=i!==null&&(0,t.jsx)(W,{error:m,shardKey:r,testId:"fanout-error"}),e[14]=i,e[15]=m,e[16]=r,e[17]=h):h=e[17];let x;e[18]!==i||e[19]!==k||e[20]!==a?(x=i===null&&k&&(0,t.jsx)(E,{description:a("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:a("No fan-out activity yet.")}),e[18]=i,e[19]=k,e[20]=a,e[21]=x):x=e[21];let N;e[22]!==i||e[23]!==k||e[24]!==s||e[25]!==a?(N=i===null&&s!==void 0&&!k&&(0,t.jsxs)(t.Fragment,{children:[s.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:a("Hot topics")}),(0,t.jsx)(B,{className:"overflow-hidden py-0",children:(0,t.jsxs)(q,{"data-testid":"fanout-topics-table",children:[(0,t.jsx)(H,{children:(0,t.jsxs)(D,{children:[(0,t.jsx)(T,{children:a("Topic")}),(0,t.jsx)(T,{children:a("Kind")}),(0,t.jsx)(T,{className:"text-right",children:a("Subscribers")})]})}),(0,t.jsx)(O,{children:s.topics.map(ee)})]})})]}),(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:a("Fan-out cost since this instance woke")}),(0,t.jsx)(z,{counters:s.shapePoke,includeTiming:!0,prefix:"fanout-poke",t:a,title:a("Shape pokes")}),(0,t.jsx)(z,{counters:s.whisper,includeTiming:!1,prefix:"fanout-whisper",t:a,title:a("Whisper broadcasts")}),(0,t.jsx)(Y,{counters:s.shapeProbe,t:a}),(0,t.jsx)(Z,{counters:s.globalPoll,t:a})]})]}),e[22]=i,e[23]=k,e[24]=s,e[25]=a,e[26]=N):N=e[26];let b;return e[27]!==y||e[28]!==h||e[29]!==x||e[30]!==N?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"fanout-panel",children:[y,h,x,N]}),e[27]=y,e[28]=h,e[29]=x,e[30]=N,e[31]=b):b=e[31],b},"me");function ee(c){return(0,t.jsxs)(D,{"data-testid":"fanout-topic-row",children:[(0,t.jsx)(K,{className:"font-mono text-xs",children:c.topic}),(0,t.jsx)(K,{children:(0,t.jsx)($,{variant:"outline",children:c.kind})}),(0,t.jsx)(K,{className:"text-right font-medium tabular-nums",children:c.subscribers})]},`${c.kind}:${c.topic}`)}S(ee,"Y");export{pe as default};
1
+ import{a as v}from"./chunk-SR6CPTRT.js";import{a as Q}from"./chunk-EPWCW2DF.js";import{a as L}from"./chunk-J45HAKBU.js";import{a as G}from"./chunk-FHLODLBC.js";import"./chunk-3D67ZJRW.js";import"./chunk-ZSWW2UGP.js";import"./chunk-IHGRWY3Y.js";import"./chunk-OWRKSQPE.js";import"./chunk-4EPW63HS.js";import"./chunk-UD5REVU2.js";import{a as E}from"./chunk-RCXNYW7P.js";import{b as $}from"./chunk-UQA2AJGI.js";import"./chunk-T3ZCW3RG.js";import{a as W}from"./chunk-YEXTJUKQ.js";import"./chunk-LSEUUZN4.js";import{a as q,b as H,c as O,d as D,e as T,f as K}from"./chunk-7QEZ2SFW.js";import"./chunk-OZAOWE7T.js";import"./chunk-BBDTJG2K.js";import"./chunk-4PI2OSSP.js";import{a as _}from"./chunk-2W4UO5BC.js";import{c as j}from"./chunk-4N76XUNG.js";import{a as B}from"./chunk-OK2QU2EV.js";import"./chunk-SHHGIT7M.js";import"./chunk-ZPQBVYNN.js";import{B as A}from"./chunk-GNI37YCV.js";import"./chunk-PDBW6GTJ.js";import{a as J}from"./chunk-GWNGVKLG.js";import{b as V}from"./chunk-6G3E4PJ2.js";import{a as S,d as F}from"./chunk-5PEAXTYQ.js";var R=F(J(),1);var t=F(V(),1);var U=S(c=>`${c.toString()} ms`,"D"),X=S(c=>c.totalConnections===0&&c.shapePoke.passes===0&&c.whisper.passes===0&&c.shapeProbe.run===0&&c.shapeProbe.served===0&&c.globalPoll.drains===0&&c.globalPoll.pairsSkipped===0,"J"),z=S(c=>{let e=(0,R.c)(48),{counters:o,includeTiming:a,prefix:r,t:l,title:u}=c,d=`${r}-section`,n;e[0]!==u?(n=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:u}),e[0]=u,e[1]=n):n=e[1];let s=`${r}-stats`,i;e[2]!==l?(i=l("Passes"),e[2]=l,e[3]=i):i=e[3];let m=`${r}-passes`,I;e[4]!==o.passes||e[5]!==i||e[6]!==m?(I=(0,t.jsx)(v,{label:i,testId:m,value:o.passes}),e[4]=o.passes,e[5]=i,e[6]=m,e[7]=I):I=e[7];let g;e[8]!==l?(g=l("Sockets iterated"),e[8]=l,e[9]=g):g=e[9];let k=`${r}-iterated`,p;e[10]!==o.socketsIterated||e[11]!==g||e[12]!==k?(p=(0,t.jsx)(v,{label:g,testId:k,value:o.socketsIterated}),e[10]=o.socketsIterated,e[11]=g,e[12]=k,e[13]=p):p=e[13];let f;e[14]!==l?(f=l("Delivered"),e[14]=l,e[15]=f):f=e[15];let y=`${r}-delivered`,h;e[16]!==o.socketsDelivered||e[17]!==f||e[18]!==y?(h=(0,t.jsx)(v,{label:f,testId:y,value:o.socketsDelivered}),e[16]=o.socketsDelivered,e[17]=f,e[18]=y,e[19]=h):h=e[19];let x;e[20]!==l?(x=l("Peak width"),e[20]=l,e[21]=x):x=e[21];let N=`${r}-peak`,b;e[22]!==o.peakSocketsIterated||e[23]!==x||e[24]!==N?(b=(0,t.jsx)(v,{label:x,testId:N,value:o.peakSocketsIterated}),e[22]=o.peakSocketsIterated,e[23]=x,e[24]=N,e[25]=b):b=e[25];let C;e[26]!==o.totalMs||e[27]!==a||e[28]!==r||e[29]!==l?(C=a&&(0,t.jsx)(v,{label:l("Total time"),testId:`${r}-total-ms`,value:U(o.totalMs)}),e[26]=o.totalMs,e[27]=a,e[28]=r,e[29]=l,e[30]=C):C=e[30];let P;e[31]!==o.maxMs||e[32]!==a||e[33]!==r||e[34]!==l?(P=a&&(0,t.jsx)(v,{label:l("Max time"),testId:`${r}-max-ms`,value:U(o.maxMs)}),e[31]=o.maxMs,e[32]=a,e[33]=r,e[34]=l,e[35]=P):P=e[35];let M;e[36]!==h||e[37]!==b||e[38]!==C||e[39]!==P||e[40]!==s||e[41]!==I||e[42]!==p?(M=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":s,children:[I,p,h,b,C,P]}),e[36]=h,e[37]=b,e[38]=C,e[39]=P,e[40]=s,e[41]=I,e[42]=p,e[43]=M):M=e[43];let w;return e[44]!==d||e[45]!==M||e[46]!==n?(w=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":d,children:[n,M]}),e[44]=d,e[45]=M,e[46]=n,e[47]=w):w=e[47],w},"F"),Y=S(c=>{let e=(0,R.c)(20),{counters:o,t:a}=c,r;e[0]!==a?(r=a("Membership probes"),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==r?(l=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:r}),e[2]=r,e[3]=l):l=e[3];let u;e[4]!==a?(u=a("Queries run"),e[4]=a,e[5]=u):u=e[5];let d;e[6]!==o.run||e[7]!==u?(d=(0,t.jsx)(v,{label:u,testId:"fanout-probe-run",value:o.run}),e[6]=o.run,e[7]=u,e[8]=d):d=e[8];let n;e[9]!==a?(n=a("Shared from cache"),e[9]=a,e[10]=n):n=e[10];let s;e[11]!==o.served||e[12]!==n?(s=(0,t.jsx)(v,{label:n,testId:"fanout-probe-served",value:o.served}),e[11]=o.served,e[12]=n,e[13]=s):s=e[13];let i;e[14]!==d||e[15]!==s?(i=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"fanout-probe-stats",children:[d,s]}),e[14]=d,e[15]=s,e[16]=i):i=e[16];let m;return e[17]!==l||e[18]!==i?(m=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-probe-section",children:[l,i]}),e[17]=l,e[18]=i,e[19]=m):m=e[19],m},"V"),Z=S(c=>{let e=(0,R.c)(20),{counters:o,t:a}=c,r;e[0]!==a?(r=a("Global shape polls"),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==r?(l=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:r}),e[2]=r,e[3]=l):l=e[3];let u;e[4]!==a?(u=a("Global reads"),e[4]=a,e[5]=u):u=e[5];let d;e[6]!==o.drains||e[7]!==u?(d=(0,t.jsx)(v,{label:u,testId:"fanout-global-poll-drains",value:o.drains}),e[6]=o.drains,e[7]=u,e[8]=d):d=e[8];let n;e[9]!==a?(n=a("Pairs skipped"),e[9]=a,e[10]=n):n=e[10];let s;e[11]!==o.pairsSkipped||e[12]!==n?(s=(0,t.jsx)(v,{label:n,testId:"fanout-global-poll-pairs-skipped",value:o.pairsSkipped}),e[11]=o.pairsSkipped,e[12]=n,e[13]=s):s=e[13];let i;e[14]!==d||e[15]!==s?(i=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"fanout-global-poll-stats",children:[d,s]}),e[14]=d,e[15]=s,e[16]=i):i=e[16];let m;return e[17]!==l||e[18]!==i?(m=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-global-poll-section",children:[l,i]}),e[17]=l,e[18]=i,e[19]=m):m=e[19],m},"X"),pe=S(c=>{let e=(0,R.c)(32),{initialShardKey:o}=c,a=A(),{queryShardKey:r,setShardKey:l,shardKey:u}=L(o),d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={},e[0]=d):d=e[0];let n;e[1]!==r?(n={keepPreviousData:!0,shardKey:r},e[1]=r,e[2]=n):n=e[2];let{data:s,error:i,errorSource:m,poll:I}=j(_.getFanoutMetrics,d,n);Q(I,!0);let g;e[3]!==s?(g=s!==void 0&&X(s),e[3]=s,e[4]=g):g=e[4];let k=g,p;e[5]!==l||e[6]!==u?(p=(0,t.jsx)(G,{onChange:l,testId:"fanout-shard-input",value:u}),e[5]=l,e[6]=u,e[7]=p):p=e[7];let f;e[8]!==s||e[9]!==a?(f=s!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"fanout-count",children:[s.promoted&&(0,t.jsx)($,{"data-testid":"fanout-promoted",variant:s.relayCount>=s.maxRelays?"destructive":"default",children:s.relayCount>=s.maxRelays?a("auto-scaled: {relayCount}/{maxRelays} relays (at ceiling)",{maxRelays:s.maxRelays,relayCount:s.relayCount}):a("auto-scaled: {relayCount}/{maxRelays} relays",{maxRelays:s.maxRelays,relayCount:s.relayCount})}),(0,t.jsx)($,{variant:"secondary",children:a("{count} connections",{count:s.totalConnections})}),(0,t.jsx)($,{variant:"secondary",children:a("peak {count} subscribers",{count:s.peakSubscribers})})]}),e[8]=s,e[9]=a,e[10]=f):f=e[10];let y;e[11]!==p||e[12]!==f?(y=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[p,f]}),e[11]=p,e[12]=f,e[13]=y):y=e[13];let h;e[14]!==i||e[15]!==m||e[16]!==r?(h=i!==null&&(0,t.jsx)(W,{error:m,shardKey:r,testId:"fanout-error"}),e[14]=i,e[15]=m,e[16]=r,e[17]=h):h=e[17];let x;e[18]!==i||e[19]!==k||e[20]!==a?(x=i===null&&k&&(0,t.jsx)(E,{description:a("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:a("No fan-out activity yet.")}),e[18]=i,e[19]=k,e[20]=a,e[21]=x):x=e[21];let N;e[22]!==i||e[23]!==k||e[24]!==s||e[25]!==a?(N=i===null&&s!==void 0&&!k&&(0,t.jsxs)(t.Fragment,{children:[s.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:a("Hot topics")}),(0,t.jsx)(B,{className:"overflow-hidden py-0",children:(0,t.jsxs)(q,{"data-testid":"fanout-topics-table",children:[(0,t.jsx)(H,{children:(0,t.jsxs)(D,{children:[(0,t.jsx)(T,{children:a("Topic")}),(0,t.jsx)(T,{children:a("Kind")}),(0,t.jsx)(T,{className:"text-right",children:a("Subscribers")})]})}),(0,t.jsx)(O,{children:s.topics.map(ee)})]})})]}),(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:a("Fan-out cost since this instance woke")}),(0,t.jsx)(z,{counters:s.shapePoke,includeTiming:!0,prefix:"fanout-poke",t:a,title:a("Shape pokes")}),(0,t.jsx)(z,{counters:s.whisper,includeTiming:!1,prefix:"fanout-whisper",t:a,title:a("Whisper broadcasts")}),(0,t.jsx)(Y,{counters:s.shapeProbe,t:a}),(0,t.jsx)(Z,{counters:s.globalPoll,t:a})]})]}),e[22]=i,e[23]=k,e[24]=s,e[25]=a,e[26]=N):N=e[26];let b;return e[27]!==y||e[28]!==h||e[29]!==x||e[30]!==N?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"fanout-panel",children:[y,h,x,N]}),e[27]=y,e[28]=h,e[29]=x,e[30]=N,e[31]=b):b=e[31],b},"me");function ee(c){return(0,t.jsxs)(D,{"data-testid":"fanout-topic-row",children:[(0,t.jsx)(K,{className:"font-mono text-xs",children:c.topic}),(0,t.jsx)(K,{children:(0,t.jsx)($,{variant:"outline",children:c.kind})}),(0,t.jsx)(K,{className:"text-right font-medium tabular-nums",children:c.subscribers})]},`${c.kind}:${c.topic}`)}S(ee,"Y");export{pe as default};
@@ -1 +1 @@
1
- import{a as we}from"./chunk-PJUVJTDR.js";import{a as ve}from"./chunk-YEVTA35E.js";import{i as me}from"./chunk-IHGRWY3Y.js";import"./chunk-OWRKSQPE.js";import"./chunk-4EPW63HS.js";import{a as q}from"./chunk-V3BE427M.js";import"./chunk-CKEQX655.js";import"./chunk-UD5REVU2.js";import{a as ue}from"./chunk-RCXNYW7P.js";import"./chunk-T3ZCW3RG.js";import{a as ae,b as re,c as ne,d as j,e as h,f as p}from"./chunk-7QEZ2SFW.js";import{a as X}from"./chunk-2W4UO5BC.js";import{c as Ne}from"./chunk-FBDIQ67D.js";import{a as ee,e as te}from"./chunk-OK2QU2EV.js";import{m as ce}from"./chunk-FACXM2UB.js";import"./chunk-ZPQBVYNN.js";import{B as Y,h as ie,i as de,j as z,p as pe,s as U}from"./chunk-GNI37YCV.js";import"./chunk-PDBW6GTJ.js";import{a as be}from"./chunk-GWNGVKLG.js";import{a as ke,b as Se}from"./chunk-6G3E4PJ2.js";import{a as s,d as he}from"./chunk-5PEAXTYQ.js";var xe=he(be(),1),i=he(ke(),1);var t=he(Se(),1);var Ce=["queued","running","rollingBack","paused","waiting","complete","errored","terminated"],Oe=["pause","resume","restart","terminate"],Ie=s(l=>{let e=(0,xe.c)(7),{busy:w,id:x,onAct:N}=l,b=Y(),a;e[0]!==w||e[1]!==x||e[2]!==N||e[3]!==b?(a=Oe.map(m=>m==="restart"?(0,t.jsx)(ve,{confirmLabel:b("Restart?"),disabled:w,onConfirm:s(()=>{N(m)},"onConfirm"),testId:`workflow-instance-${m}-${x}`,children:b(m)},m):(0,t.jsx)(q,{"data-testid":`workflow-instance-${m}-${x}`,disabled:w,onClick:s(()=>{N(m)},"onClick"),size:"sm",type:"button",variant:"ghost",children:b(m)},m)),e[0]=w,e[1]=x,e[2]=N,e[3]=b,e[4]=a):a=e[4];let d;return e[5]!==a?(d=(0,t.jsx)(t.Fragment,{children:a}),e[5]=a,e[6]=d):d=e[6],d},"Ce"),$e="WORKFLOWS_NOT_CONFIGURED",We=s(l=>typeof l=="object"&&l!==null&&l.code===$e,"Oe"),Ae=s(l=>{let e=l.error??l.output;if(e===void 0)return"\u2014";try{return JSON.stringify(e,pe)}catch{return"(unserializable)"}},"Ee"),Te=s(({loadDetail:l,loadInstances:e,readOnly:w,runAction:x,workflowName:N})=>{let b=ce(),a=Y(),[d,m]=(0,i.useState)(null),[v,L]=(0,i.useState)(null),[S,B]=(0,i.useState)(""),[C,O]=(0,i.useState)(null),[F,W]=(0,i.useState)(!1),[_,R]=(0,i.useState)(null),g=(0,i.useRef)(0),y=(0,i.useRef)(0),k=(0,i.useRef)(0),A=l??(n=>b.getWorkflowInstance(n)),I=w?void 0:x??(e===void 0?n=>b.setWorkflowInstanceStatus(n):void 0),T=s(async()=>{y.current+=1;let n=y.current;O(null),W(!1);let u=S===""?void 0:S;try{if(e===void 0){let r=await b.listWorkflowInstances({name:N,status:u});if(n!==y.current)return;if(r.configured===!1){m(null),W(!0);return}m(r.instances);return}let f=await e({name:N,status:u});n===y.current&&m(f)}catch(f){if(n!==y.current)return;m(null),We(f)?W(!0):O(z(f))}},"E");(0,i.useEffect)(()=>{g.current+=1,k.current+=1,L(null),U(T())},[N,S]);let P=s(async n=>{k.current+=1;let u=k.current;O(null);try{let f=await A({id:n,name:N});u===k.current&&L(f)}catch(f){u===k.current&&O(z(f))}},"W"),E=s(()=>{k.current+=1,L(null)},"A"),J=s(async(n,u)=>{if(I===void 0)return;let f=g.current;R(n),O(null);try{await I({action:u,id:n,name:N}),f===g.current&&await T()}catch(r){O(z(r))}R(null)},"L");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("h3",{className:"text-sm font-medium",children:a("Instance history")}),(0,t.jsxs)("select",{"aria-label":a("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:s(n=>{B(n.target.value)},"onChange"),value:S,children:[(0,t.jsx)("option",{value:"",children:a("All statuses")}),Ce.map(n=>(0,t.jsx)("option",{value:n,children:n},n))]})]}),C!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:C}),F&&(0,t.jsx)(ue,{description:a("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:a("Workflow inspection not configured")}),!F&&d!==null&&d.length===0&&(0,t.jsx)(ue,{description:a("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:a("No instances")}),d!==null&&d.length>0&&(0,t.jsx)(ee,{className:"overflow-hidden py-0",children:(0,t.jsx)(te,{className:"px-0",children:(0,t.jsxs)(ae,{"data-testid":"workflow-instances-table",children:[(0,t.jsx)(re,{children:(0,t.jsxs)(j,{children:[(0,t.jsx)(h,{children:a("Instance id")}),(0,t.jsx)(h,{children:a("Status")}),(0,t.jsx)(h,{children:a("Created")}),(0,t.jsx)(h,{children:a("Ended")}),(0,t.jsx)(h,{"aria-label":a("Actions")})]})}),(0,t.jsx)(ne,{children:d.map(n=>(0,t.jsxs)(j,{"data-testid":`workflow-instance-${n.id}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:n.id}),(0,t.jsx)(p,{className:"font-mono text-xs",children:n.status}),(0,t.jsx)(p,{className:"text-muted-foreground tabular-nums",children:n.createdOn??"\u2014"}),(0,t.jsx)(p,{className:"text-muted-foreground tabular-nums",children:n.endedOn??"\u2014"}),(0,t.jsx)(p,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,t.jsx)(q,{"data-testid":`workflow-instance-steps-${n.id}`,onClick:s(()=>{U(P(n.id))},"onClick"),size:"sm",type:"button",variant:"outline",children:a("Steps")}),I!==void 0&&(0,t.jsx)(Ie,{busy:_===n.id,id:n.id,onAct:s(u=>{U(J(n.id,u))},"onAct")},N)]})})]},n.id))})]})})}),v!==null&&(0,t.jsx)(ee,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:(0,t.jsxs)(te,{className:"flex flex-col gap-2 px-4 py-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("span",{className:"font-mono text-xs",children:[a("Steps")," \xB7 ",v.id]}),(0,t.jsx)(q,{"data-testid":"workflow-instance-detail-close",onClick:E,size:"xs",type:"button",variant:"ghost",children:a("Close")})]}),v.steps.length===0?(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:a("This instance has no recorded steps yet.")}):(0,t.jsxs)(ae,{"data-testid":"workflow-instance-steps",children:[(0,t.jsx)(re,{children:(0,t.jsxs)(j,{children:[(0,t.jsx)(h,{children:a("Step")}),(0,t.jsx)(h,{children:a("Type")}),(0,t.jsx)(h,{children:a("Attempts")}),(0,t.jsx)(h,{children:a("Started")}),(0,t.jsx)(h,{children:a("Output")})]})}),(0,t.jsx)(ne,{children:v.steps.map((n,u)=>(0,t.jsxs)(j,{"data-testid":`workflow-step-${String(u)}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:n.name}),(0,t.jsx)(p,{className:"text-xs text-muted-foreground",children:n.type??"\u2014"}),(0,t.jsx)(p,{className:"tabular-nums",children:n.attempts??"\u2014"}),(0,t.jsx)(p,{className:"text-muted-foreground tabular-nums",children:n.start??"\u2014"}),(0,t.jsx)(p,{className:"font-mono text-xs text-muted-foreground",children:Ae(n)})]},`${n.name}:${String(u)}`))})]})]})})]})},"_e"),_e=ie(X.createWorkflowInstance),Ee=ie(X.getWorkflowInstanceStatus),Je=ie(X.sendWorkflowEvent),De=s(l=>{if(l.error)return`${l.error.name}: ${l.error.message}`;if(l.output===void 0)return"\u2014";try{return JSON.stringify(l.output,pe)}catch{return"(unserializable)"}},"$e"),ge=s(l=>{let e=l.trim();if(e==="")return{value:void 0};try{return{value:JSON.parse(e)}}catch{return null}},"ve"),Fe=s((l,e)=>l.some(w=>w.exportName===e)?e:l[0]?.exportName??"","Fe"),Pe=s(l=>{let e=(0,xe.c)(72),{eventTypes:w,exportName:x,onSent:N}=l,b=ce(),a=Y(),[d,m]=(0,i.useState)(""),[v,L]=(0,i.useState)(""),[S,B]=(0,i.useState)(""),[C,O]=(0,i.useState)(!1),[F,W]=(0,i.useState)(null),_;e[0]!==b||e[1]!==x||e[2]!==N||e[3]!==a||e[4]!==v?(_=s(async(D,oe)=>{try{await b.query(Je,{exportName:x,id:D,payload:oe,type:v},de(""))}catch(fe){W(z(fe));return}try{await N(x,D)}catch(fe){let ye=fe;W(`${a("Event sent, but refreshing the instance failed")}: ${z(ye)}`)}},"_"),e[0]=b,e[1]=x,e[2]=N,e[3]=a,e[4]=v,e[5]=_):_=e[5];let R=_,g;e[6]!==R||e[7]!==d||e[8]!==S||e[9]!==a?(g=s(async()=>{let D=d.trim(),oe=ge(S);if(oe===null){W(a("Payload must be valid JSON"));return}O(!0),W(null),await R(D,oe.value).finally(()=>{O(!1)})},"N"),e[6]=R,e[7]=d,e[8]=S,e[9]=a,e[10]=g):g=e[10];let y=g,k;e[11]!==a?(k=a("Send event"),e[11]=a,e[12]=k):k=e[12];let A;e[13]!==k?(A=(0,t.jsx)("h3",{className:"text-sm font-medium",children:k}),e[13]=k,e[14]=A):A=e[14];let I;e[15]!==F?(I=F!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-event-error",role:"alert",children:F}),e[15]=F,e[16]=I):I=e[16];let T;e[17]!==a?(T=a("Instance id"),e[17]=a,e[18]=T):T=e[18];let P;e[19]===Symbol.for("react.memo_cache_sentinel")?(P=s(D=>{m(D.target.value)},"O"),e[19]=P):P=e[19];let E;e[20]!==a?(E=a("Instance id"),e[20]=a,e[21]=E):E=e[21];let J;e[22]!==d||e[23]!==T||e[24]!==E?(J=(0,t.jsx)(me,{"aria-label":T,className:"max-w-48","data-testid":"workflows-event-id",onChange:P,placeholder:E,value:d}),e[22]=d,e[23]=T,e[24]=E,e[25]=J):J=e[25];let n;e[26]!==a?(n=a("Event type"),e[26]=a,e[27]=n):n=e[27];let u;e[28]===Symbol.for("react.memo_cache_sentinel")?(u=s(D=>{L(D.target.value)},"L"),e[28]=u):u=e[28];let f;e[29]!==a?(f=a("Event type"),e[29]=a,e[30]=f):f=e[30];let r;e[31]!==n||e[32]!==f||e[33]!==v?(r=(0,t.jsx)(me,{"aria-label":n,className:"max-w-48","data-testid":"workflows-event-type",list:"workflows-event-types",onChange:u,placeholder:f,value:v}),e[31]=n,e[32]=f,e[33]=v,e[34]=r):r=e[34];let c;e[35]!==w?(c=w.map(je),e[35]=w,e[36]=c):c=e[36];let o;e[37]!==c?(o=(0,t.jsx)("datalist",{"data-testid":"workflows-event-types",id:"workflows-event-types",children:c}),e[37]=c,e[38]=o):o=e[38];let $;e[39]!==x||e[40]!==d||e[41]!==C||e[42]!==v?($=C||x===""||d.trim()===""||v.trim()==="",e[39]=x,e[40]=d,e[41]=C,e[42]=v,e[43]=$):$=e[43];let K;e[44]!==y?(K=s(()=>{U(y())},"z"),e[44]=y,e[45]=K):K=e[45];let G;e[46]!==C||e[47]!==a?(G=a(C?"Sending\u2026":"Send event"),e[46]=C,e[47]=a,e[48]=G):G=e[48];let M;e[49]!==$||e[50]!==K||e[51]!==G?(M=(0,t.jsx)(q,{"data-testid":"workflows-event-button",disabled:$,onClick:K,children:G}),e[49]=$,e[50]=K,e[51]=G,e[52]=M):M=e[52];let Z;e[53]!==r||e[54]!==o||e[55]!==M||e[56]!==J?(Z=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[J,r,o,M]}),e[53]=r,e[54]=o,e[55]=M,e[56]=J,e[57]=Z):Z=e[57];let H;e[58]!==a?(H=a("Payload (JSON)"),e[58]=a,e[59]=H):H=e[59];let se;e[60]===Symbol.for("react.memo_cache_sentinel")?(se=s(D=>{B(D.target.value)},"Y"),e[60]=se):se=e[60];let Q;e[61]!==a?(Q=a("Payload (JSON, optional)"),e[61]=a,e[62]=Q):Q=e[62];let V;e[63]!==S||e[64]!==H||e[65]!==Q?(V=(0,t.jsx)(we,{"aria-label":H,className:"font-mono","data-testid":"workflows-event-payload",onChange:se,placeholder:Q,value:S}),e[63]=S,e[64]=H,e[65]=Q,e[66]=V):V=e[66];let le;return e[67]!==Z||e[68]!==V||e[69]!==A||e[70]!==I?(le=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-event",children:[A,I,Z,V]}),e[67]=Z,e[68]=V,e[69]=A,e[70]=I,e[71]=le):le=e[71],le},"Pe"),Ve=s(()=>{let l=ce(),e=Y(),{data:w,error:x}=Ne(X.listWorkflows,{}),[N,b]=(0,i.useState)(""),[a,d]=(0,i.useState)(""),[m,v]=(0,i.useState)(""),[L,S]=(0,i.useState)(!1),[B,C]=(0,i.useState)(null),[O,F]=(0,i.useState)([]),[W,_]=(0,i.useState)(null),R=w!==void 0,g=Array.isArray(w?.workflows)?[...w.workflows].toSorted((r,c)=>r.exportName.localeCompare(c.exportName)):[],y=Fe(g,N),k=g.find(r=>r.exportName===y),A=s(r=>{F(c=>{let o=c.filter($=>!($.exportName===r.exportName&&$.id===r.id));return[r,...o]})},"T"),I=s(async()=>{let r=y;if(r==="")return;let c=ge(m);if(c===null){C(e("Params must be valid JSON"));return}S(!0),C(null);try{let o=a.trim(),$=await l.query(_e,{exportName:r,id:o===""?void 0:o,params:c.value},de(""));A({exportName:r,id:$.id,status:$.status}),d("")}catch(o){C(z(o))}S(!1)},"F"),T=s(()=>{U(I())},"P"),P=s(async(r,c)=>{_(c);try{let o=await l.query(Ee,{exportName:r,id:c},de(""));A({error:o.error,exportName:r,id:o.id,output:o.output,status:o.status})}catch(o){throw _(null),o}_(null)},"O"),E=s(async(r,c)=>{try{await P(r,c)}catch(o){C(z(o))}},"E"),J=s(r=>{b(r.target.value)},"W"),n=s(r=>{d(r.target.value)},"A"),u=s(r=>{v(r.target.value)},"L"),f=s(r=>{let{export:c,id:o}=r.currentTarget.dataset;c!==void 0&&o!==void 0&&U(E(c,o))},"n");return(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[x!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:x}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),R&&g.length===0?(0,t.jsx)(ue,{description:e("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:e("No workflows defined")}):(0,t.jsx)(ee,{className:"overflow-hidden py-0",children:(0,t.jsx)(te,{className:"px-0",children:(0,t.jsxs)(ae,{"data-testid":"workflows-table",children:[(0,t.jsx)(re,{children:(0,t.jsxs)(j,{children:[(0,t.jsx)(h,{children:e("Export")}),(0,t.jsx)(h,{children:e("Name")}),(0,t.jsx)(h,{children:e("Class")})]})}),(0,t.jsx)(ne,{children:g.map(r=>(0,t.jsxs)(j,{"data-testid":`workflows-row-${r.exportName}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:r.exportName}),(0,t.jsx)(p,{className:"font-mono text-xs text-muted-foreground",children:r.name}),(0,t.jsx)(p,{className:"font-mono text-xs text-muted-foreground",children:r.className})]},r.exportName))})]})})}),g.length>0&&(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[(0,t.jsx)("h3",{className:"text-sm font-medium",children:e("Start instance")}),B!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:B}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("select",{"aria-label":e("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:J,value:y,children:g.map(r=>(0,t.jsx)("option",{value:r.exportName,children:r.exportName},r.exportName))}),(0,t.jsx)(me,{"aria-label":e("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:n,placeholder:e("Instance id (optional)"),value:a}),(0,t.jsx)(q,{"data-testid":"workflows-start-button",disabled:L||y==="",onClick:T,children:e(L?"Starting\u2026":"Start instance")})]}),(0,t.jsx)(we,{"aria-label":e("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:u,placeholder:e("Params (JSON, optional)"),value:m})]}),g.length>0&&(0,t.jsx)(Pe,{eventTypes:w?.eventTypes??[],exportName:y,onSent:P},y),O.length>0&&(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[(0,t.jsx)("h3",{className:"text-sm font-medium",children:e("Instances")}),(0,t.jsx)(ee,{className:"overflow-hidden py-0",children:(0,t.jsx)(te,{className:"px-0",children:(0,t.jsxs)(ae,{"data-testid":"workflows-instances-table",children:[(0,t.jsx)(re,{children:(0,t.jsxs)(j,{children:[(0,t.jsx)(h,{children:e("Workflow")}),(0,t.jsx)(h,{children:e("Instance id")}),(0,t.jsx)(h,{children:e("Status")}),(0,t.jsx)(h,{children:e("Output")}),(0,t.jsx)(h,{})]})}),(0,t.jsx)(ne,{children:O.map(r=>(0,t.jsxs)(j,{"data-testid":`workflows-instance-${r.id}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:r.exportName}),(0,t.jsx)(p,{className:"font-mono text-xs text-muted-foreground",children:r.id}),(0,t.jsx)(p,{className:"font-mono text-xs",children:r.status}),(0,t.jsx)(p,{className:"font-mono text-xs text-muted-foreground",children:De(r)}),(0,t.jsx)(p,{children:(0,t.jsx)(q,{"data-export":r.exportName,"data-id":r.id,"data-testid":`workflows-instance-refresh-${r.id}`,disabled:W===r.id,onClick:f,size:"xs",variant:"outline",children:W===r.id?e("Refreshing\u2026"):e("Refresh")})})]},`${r.exportName}:${r.id}`))})]})})})]}),k!==void 0&&(0,t.jsx)(Te,{workflowName:k.name})]})},"Ze");function je(l){return(0,t.jsx)("option",{value:l,children:l},l)}s(je,"De");export{Ve as default};
1
+ import{a as we}from"./chunk-PJUVJTDR.js";import{a as ve}from"./chunk-YEVTA35E.js";import{i as me}from"./chunk-IHGRWY3Y.js";import"./chunk-OWRKSQPE.js";import"./chunk-4EPW63HS.js";import{a as q}from"./chunk-V3BE427M.js";import"./chunk-CKEQX655.js";import"./chunk-UD5REVU2.js";import{a as ue}from"./chunk-RCXNYW7P.js";import"./chunk-T3ZCW3RG.js";import{a as ae,b as re,c as ne,d as j,e as h,f as p}from"./chunk-7QEZ2SFW.js";import{a as X}from"./chunk-2W4UO5BC.js";import{c as Ne}from"./chunk-4N76XUNG.js";import{a as ee,e as te}from"./chunk-OK2QU2EV.js";import{m as ce}from"./chunk-SHHGIT7M.js";import"./chunk-ZPQBVYNN.js";import{B as Y,h as ie,i as de,j as z,p as pe,s as U}from"./chunk-GNI37YCV.js";import"./chunk-PDBW6GTJ.js";import{a as be}from"./chunk-GWNGVKLG.js";import{a as ke,b as Se}from"./chunk-6G3E4PJ2.js";import{a as s,d as he}from"./chunk-5PEAXTYQ.js";var xe=he(be(),1),i=he(ke(),1);var t=he(Se(),1);var Ce=["queued","running","rollingBack","paused","waiting","complete","errored","terminated"],Oe=["pause","resume","restart","terminate"],Ie=s(l=>{let e=(0,xe.c)(7),{busy:w,id:x,onAct:N}=l,b=Y(),a;e[0]!==w||e[1]!==x||e[2]!==N||e[3]!==b?(a=Oe.map(m=>m==="restart"?(0,t.jsx)(ve,{confirmLabel:b("Restart?"),disabled:w,onConfirm:s(()=>{N(m)},"onConfirm"),testId:`workflow-instance-${m}-${x}`,children:b(m)},m):(0,t.jsx)(q,{"data-testid":`workflow-instance-${m}-${x}`,disabled:w,onClick:s(()=>{N(m)},"onClick"),size:"sm",type:"button",variant:"ghost",children:b(m)},m)),e[0]=w,e[1]=x,e[2]=N,e[3]=b,e[4]=a):a=e[4];let d;return e[5]!==a?(d=(0,t.jsx)(t.Fragment,{children:a}),e[5]=a,e[6]=d):d=e[6],d},"Ce"),$e="WORKFLOWS_NOT_CONFIGURED",We=s(l=>typeof l=="object"&&l!==null&&l.code===$e,"Oe"),Ae=s(l=>{let e=l.error??l.output;if(e===void 0)return"\u2014";try{return JSON.stringify(e,pe)}catch{return"(unserializable)"}},"Ee"),Te=s(({loadDetail:l,loadInstances:e,readOnly:w,runAction:x,workflowName:N})=>{let b=ce(),a=Y(),[d,m]=(0,i.useState)(null),[v,L]=(0,i.useState)(null),[S,B]=(0,i.useState)(""),[C,O]=(0,i.useState)(null),[F,W]=(0,i.useState)(!1),[_,R]=(0,i.useState)(null),g=(0,i.useRef)(0),y=(0,i.useRef)(0),k=(0,i.useRef)(0),A=l??(n=>b.getWorkflowInstance(n)),I=w?void 0:x??(e===void 0?n=>b.setWorkflowInstanceStatus(n):void 0),T=s(async()=>{y.current+=1;let n=y.current;O(null),W(!1);let u=S===""?void 0:S;try{if(e===void 0){let r=await b.listWorkflowInstances({name:N,status:u});if(n!==y.current)return;if(r.configured===!1){m(null),W(!0);return}m(r.instances);return}let f=await e({name:N,status:u});n===y.current&&m(f)}catch(f){if(n!==y.current)return;m(null),We(f)?W(!0):O(z(f))}},"E");(0,i.useEffect)(()=>{g.current+=1,k.current+=1,L(null),U(T())},[N,S]);let P=s(async n=>{k.current+=1;let u=k.current;O(null);try{let f=await A({id:n,name:N});u===k.current&&L(f)}catch(f){u===k.current&&O(z(f))}},"W"),E=s(()=>{k.current+=1,L(null)},"A"),J=s(async(n,u)=>{if(I===void 0)return;let f=g.current;R(n),O(null);try{await I({action:u,id:n,name:N}),f===g.current&&await T()}catch(r){O(z(r))}R(null)},"L");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("h3",{className:"text-sm font-medium",children:a("Instance history")}),(0,t.jsxs)("select",{"aria-label":a("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:s(n=>{B(n.target.value)},"onChange"),value:S,children:[(0,t.jsx)("option",{value:"",children:a("All statuses")}),Ce.map(n=>(0,t.jsx)("option",{value:n,children:n},n))]})]}),C!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:C}),F&&(0,t.jsx)(ue,{description:a("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:a("Workflow inspection not configured")}),!F&&d!==null&&d.length===0&&(0,t.jsx)(ue,{description:a("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:a("No instances")}),d!==null&&d.length>0&&(0,t.jsx)(ee,{className:"overflow-hidden py-0",children:(0,t.jsx)(te,{className:"px-0",children:(0,t.jsxs)(ae,{"data-testid":"workflow-instances-table",children:[(0,t.jsx)(re,{children:(0,t.jsxs)(j,{children:[(0,t.jsx)(h,{children:a("Instance id")}),(0,t.jsx)(h,{children:a("Status")}),(0,t.jsx)(h,{children:a("Created")}),(0,t.jsx)(h,{children:a("Ended")}),(0,t.jsx)(h,{"aria-label":a("Actions")})]})}),(0,t.jsx)(ne,{children:d.map(n=>(0,t.jsxs)(j,{"data-testid":`workflow-instance-${n.id}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:n.id}),(0,t.jsx)(p,{className:"font-mono text-xs",children:n.status}),(0,t.jsx)(p,{className:"text-muted-foreground tabular-nums",children:n.createdOn??"\u2014"}),(0,t.jsx)(p,{className:"text-muted-foreground tabular-nums",children:n.endedOn??"\u2014"}),(0,t.jsx)(p,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,t.jsx)(q,{"data-testid":`workflow-instance-steps-${n.id}`,onClick:s(()=>{U(P(n.id))},"onClick"),size:"sm",type:"button",variant:"outline",children:a("Steps")}),I!==void 0&&(0,t.jsx)(Ie,{busy:_===n.id,id:n.id,onAct:s(u=>{U(J(n.id,u))},"onAct")},N)]})})]},n.id))})]})})}),v!==null&&(0,t.jsx)(ee,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:(0,t.jsxs)(te,{className:"flex flex-col gap-2 px-4 py-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("span",{className:"font-mono text-xs",children:[a("Steps")," \xB7 ",v.id]}),(0,t.jsx)(q,{"data-testid":"workflow-instance-detail-close",onClick:E,size:"xs",type:"button",variant:"ghost",children:a("Close")})]}),v.steps.length===0?(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:a("This instance has no recorded steps yet.")}):(0,t.jsxs)(ae,{"data-testid":"workflow-instance-steps",children:[(0,t.jsx)(re,{children:(0,t.jsxs)(j,{children:[(0,t.jsx)(h,{children:a("Step")}),(0,t.jsx)(h,{children:a("Type")}),(0,t.jsx)(h,{children:a("Attempts")}),(0,t.jsx)(h,{children:a("Started")}),(0,t.jsx)(h,{children:a("Output")})]})}),(0,t.jsx)(ne,{children:v.steps.map((n,u)=>(0,t.jsxs)(j,{"data-testid":`workflow-step-${String(u)}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:n.name}),(0,t.jsx)(p,{className:"text-xs text-muted-foreground",children:n.type??"\u2014"}),(0,t.jsx)(p,{className:"tabular-nums",children:n.attempts??"\u2014"}),(0,t.jsx)(p,{className:"text-muted-foreground tabular-nums",children:n.start??"\u2014"}),(0,t.jsx)(p,{className:"font-mono text-xs text-muted-foreground",children:Ae(n)})]},`${n.name}:${String(u)}`))})]})]})})]})},"_e"),_e=ie(X.createWorkflowInstance),Ee=ie(X.getWorkflowInstanceStatus),Je=ie(X.sendWorkflowEvent),De=s(l=>{if(l.error)return`${l.error.name}: ${l.error.message}`;if(l.output===void 0)return"\u2014";try{return JSON.stringify(l.output,pe)}catch{return"(unserializable)"}},"$e"),ge=s(l=>{let e=l.trim();if(e==="")return{value:void 0};try{return{value:JSON.parse(e)}}catch{return null}},"ve"),Fe=s((l,e)=>l.some(w=>w.exportName===e)?e:l[0]?.exportName??"","Fe"),Pe=s(l=>{let e=(0,xe.c)(72),{eventTypes:w,exportName:x,onSent:N}=l,b=ce(),a=Y(),[d,m]=(0,i.useState)(""),[v,L]=(0,i.useState)(""),[S,B]=(0,i.useState)(""),[C,O]=(0,i.useState)(!1),[F,W]=(0,i.useState)(null),_;e[0]!==b||e[1]!==x||e[2]!==N||e[3]!==a||e[4]!==v?(_=s(async(D,oe)=>{try{await b.query(Je,{exportName:x,id:D,payload:oe,type:v},de(""))}catch(fe){W(z(fe));return}try{await N(x,D)}catch(fe){let ye=fe;W(`${a("Event sent, but refreshing the instance failed")}: ${z(ye)}`)}},"_"),e[0]=b,e[1]=x,e[2]=N,e[3]=a,e[4]=v,e[5]=_):_=e[5];let R=_,g;e[6]!==R||e[7]!==d||e[8]!==S||e[9]!==a?(g=s(async()=>{let D=d.trim(),oe=ge(S);if(oe===null){W(a("Payload must be valid JSON"));return}O(!0),W(null),await R(D,oe.value).finally(()=>{O(!1)})},"N"),e[6]=R,e[7]=d,e[8]=S,e[9]=a,e[10]=g):g=e[10];let y=g,k;e[11]!==a?(k=a("Send event"),e[11]=a,e[12]=k):k=e[12];let A;e[13]!==k?(A=(0,t.jsx)("h3",{className:"text-sm font-medium",children:k}),e[13]=k,e[14]=A):A=e[14];let I;e[15]!==F?(I=F!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-event-error",role:"alert",children:F}),e[15]=F,e[16]=I):I=e[16];let T;e[17]!==a?(T=a("Instance id"),e[17]=a,e[18]=T):T=e[18];let P;e[19]===Symbol.for("react.memo_cache_sentinel")?(P=s(D=>{m(D.target.value)},"O"),e[19]=P):P=e[19];let E;e[20]!==a?(E=a("Instance id"),e[20]=a,e[21]=E):E=e[21];let J;e[22]!==d||e[23]!==T||e[24]!==E?(J=(0,t.jsx)(me,{"aria-label":T,className:"max-w-48","data-testid":"workflows-event-id",onChange:P,placeholder:E,value:d}),e[22]=d,e[23]=T,e[24]=E,e[25]=J):J=e[25];let n;e[26]!==a?(n=a("Event type"),e[26]=a,e[27]=n):n=e[27];let u;e[28]===Symbol.for("react.memo_cache_sentinel")?(u=s(D=>{L(D.target.value)},"L"),e[28]=u):u=e[28];let f;e[29]!==a?(f=a("Event type"),e[29]=a,e[30]=f):f=e[30];let r;e[31]!==n||e[32]!==f||e[33]!==v?(r=(0,t.jsx)(me,{"aria-label":n,className:"max-w-48","data-testid":"workflows-event-type",list:"workflows-event-types",onChange:u,placeholder:f,value:v}),e[31]=n,e[32]=f,e[33]=v,e[34]=r):r=e[34];let c;e[35]!==w?(c=w.map(je),e[35]=w,e[36]=c):c=e[36];let o;e[37]!==c?(o=(0,t.jsx)("datalist",{"data-testid":"workflows-event-types",id:"workflows-event-types",children:c}),e[37]=c,e[38]=o):o=e[38];let $;e[39]!==x||e[40]!==d||e[41]!==C||e[42]!==v?($=C||x===""||d.trim()===""||v.trim()==="",e[39]=x,e[40]=d,e[41]=C,e[42]=v,e[43]=$):$=e[43];let K;e[44]!==y?(K=s(()=>{U(y())},"z"),e[44]=y,e[45]=K):K=e[45];let G;e[46]!==C||e[47]!==a?(G=a(C?"Sending\u2026":"Send event"),e[46]=C,e[47]=a,e[48]=G):G=e[48];let M;e[49]!==$||e[50]!==K||e[51]!==G?(M=(0,t.jsx)(q,{"data-testid":"workflows-event-button",disabled:$,onClick:K,children:G}),e[49]=$,e[50]=K,e[51]=G,e[52]=M):M=e[52];let Z;e[53]!==r||e[54]!==o||e[55]!==M||e[56]!==J?(Z=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[J,r,o,M]}),e[53]=r,e[54]=o,e[55]=M,e[56]=J,e[57]=Z):Z=e[57];let H;e[58]!==a?(H=a("Payload (JSON)"),e[58]=a,e[59]=H):H=e[59];let se;e[60]===Symbol.for("react.memo_cache_sentinel")?(se=s(D=>{B(D.target.value)},"Y"),e[60]=se):se=e[60];let Q;e[61]!==a?(Q=a("Payload (JSON, optional)"),e[61]=a,e[62]=Q):Q=e[62];let V;e[63]!==S||e[64]!==H||e[65]!==Q?(V=(0,t.jsx)(we,{"aria-label":H,className:"font-mono","data-testid":"workflows-event-payload",onChange:se,placeholder:Q,value:S}),e[63]=S,e[64]=H,e[65]=Q,e[66]=V):V=e[66];let le;return e[67]!==Z||e[68]!==V||e[69]!==A||e[70]!==I?(le=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-event",children:[A,I,Z,V]}),e[67]=Z,e[68]=V,e[69]=A,e[70]=I,e[71]=le):le=e[71],le},"Pe"),Ve=s(()=>{let l=ce(),e=Y(),{data:w,error:x}=Ne(X.listWorkflows,{}),[N,b]=(0,i.useState)(""),[a,d]=(0,i.useState)(""),[m,v]=(0,i.useState)(""),[L,S]=(0,i.useState)(!1),[B,C]=(0,i.useState)(null),[O,F]=(0,i.useState)([]),[W,_]=(0,i.useState)(null),R=w!==void 0,g=Array.isArray(w?.workflows)?[...w.workflows].toSorted((r,c)=>r.exportName.localeCompare(c.exportName)):[],y=Fe(g,N),k=g.find(r=>r.exportName===y),A=s(r=>{F(c=>{let o=c.filter($=>!($.exportName===r.exportName&&$.id===r.id));return[r,...o]})},"T"),I=s(async()=>{let r=y;if(r==="")return;let c=ge(m);if(c===null){C(e("Params must be valid JSON"));return}S(!0),C(null);try{let o=a.trim(),$=await l.query(_e,{exportName:r,id:o===""?void 0:o,params:c.value},de(""));A({exportName:r,id:$.id,status:$.status}),d("")}catch(o){C(z(o))}S(!1)},"F"),T=s(()=>{U(I())},"P"),P=s(async(r,c)=>{_(c);try{let o=await l.query(Ee,{exportName:r,id:c},de(""));A({error:o.error,exportName:r,id:o.id,output:o.output,status:o.status})}catch(o){throw _(null),o}_(null)},"O"),E=s(async(r,c)=>{try{await P(r,c)}catch(o){C(z(o))}},"E"),J=s(r=>{b(r.target.value)},"W"),n=s(r=>{d(r.target.value)},"A"),u=s(r=>{v(r.target.value)},"L"),f=s(r=>{let{export:c,id:o}=r.currentTarget.dataset;c!==void 0&&o!==void 0&&U(E(c,o))},"n");return(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[x!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:x}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),R&&g.length===0?(0,t.jsx)(ue,{description:e("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:e("No workflows defined")}):(0,t.jsx)(ee,{className:"overflow-hidden py-0",children:(0,t.jsx)(te,{className:"px-0",children:(0,t.jsxs)(ae,{"data-testid":"workflows-table",children:[(0,t.jsx)(re,{children:(0,t.jsxs)(j,{children:[(0,t.jsx)(h,{children:e("Export")}),(0,t.jsx)(h,{children:e("Name")}),(0,t.jsx)(h,{children:e("Class")})]})}),(0,t.jsx)(ne,{children:g.map(r=>(0,t.jsxs)(j,{"data-testid":`workflows-row-${r.exportName}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:r.exportName}),(0,t.jsx)(p,{className:"font-mono text-xs text-muted-foreground",children:r.name}),(0,t.jsx)(p,{className:"font-mono text-xs text-muted-foreground",children:r.className})]},r.exportName))})]})})}),g.length>0&&(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[(0,t.jsx)("h3",{className:"text-sm font-medium",children:e("Start instance")}),B!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:B}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("select",{"aria-label":e("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:J,value:y,children:g.map(r=>(0,t.jsx)("option",{value:r.exportName,children:r.exportName},r.exportName))}),(0,t.jsx)(me,{"aria-label":e("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:n,placeholder:e("Instance id (optional)"),value:a}),(0,t.jsx)(q,{"data-testid":"workflows-start-button",disabled:L||y==="",onClick:T,children:e(L?"Starting\u2026":"Start instance")})]}),(0,t.jsx)(we,{"aria-label":e("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:u,placeholder:e("Params (JSON, optional)"),value:m})]}),g.length>0&&(0,t.jsx)(Pe,{eventTypes:w?.eventTypes??[],exportName:y,onSent:P},y),O.length>0&&(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[(0,t.jsx)("h3",{className:"text-sm font-medium",children:e("Instances")}),(0,t.jsx)(ee,{className:"overflow-hidden py-0",children:(0,t.jsx)(te,{className:"px-0",children:(0,t.jsxs)(ae,{"data-testid":"workflows-instances-table",children:[(0,t.jsx)(re,{children:(0,t.jsxs)(j,{children:[(0,t.jsx)(h,{children:e("Workflow")}),(0,t.jsx)(h,{children:e("Instance id")}),(0,t.jsx)(h,{children:e("Status")}),(0,t.jsx)(h,{children:e("Output")}),(0,t.jsx)(h,{})]})}),(0,t.jsx)(ne,{children:O.map(r=>(0,t.jsxs)(j,{"data-testid":`workflows-instance-${r.id}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:r.exportName}),(0,t.jsx)(p,{className:"font-mono text-xs text-muted-foreground",children:r.id}),(0,t.jsx)(p,{className:"font-mono text-xs",children:r.status}),(0,t.jsx)(p,{className:"font-mono text-xs text-muted-foreground",children:De(r)}),(0,t.jsx)(p,{children:(0,t.jsx)(q,{"data-export":r.exportName,"data-id":r.id,"data-testid":`workflows-instance-refresh-${r.id}`,disabled:W===r.id,onClick:f,size:"xs",variant:"outline",children:W===r.id?e("Refreshing\u2026"):e("Refresh")})})]},`${r.exportName}:${r.id}`))})]})})})]}),k!==void 0&&(0,t.jsx)(Te,{workflowName:k.name})]})},"Ze");function je(l){return(0,t.jsx)("option",{value:l,children:l},l)}s(je,"De");export{Ve as default};
@@ -1 +1 @@
1
- import{a as st}from"./chunk-2NGKUO32.js";import{a as tt}from"./chunk-J3BZWYJQ.js";import"./chunk-O3AZ7JKE.js";import{a as et}from"./chunk-PJUVJTDR.js";import"./chunk-D65UVZIA.js";import{a as Ze}from"./chunk-YEVTA35E.js";import{i as Ve}from"./chunk-IHGRWY3Y.js";import"./chunk-OWRKSQPE.js";import"./chunk-4EPW63HS.js";import{a as fe}from"./chunk-V3BE427M.js";import"./chunk-CKEQX655.js";import"./chunk-UD5REVU2.js";import{a as xe}from"./chunk-RCXNYW7P.js";import{b as ge}from"./chunk-UQA2AJGI.js";import"./chunk-T3ZCW3RG.js";import{a as Ye}from"./chunk-IUGNIG6L.js";import{a as Xe}from"./chunk-LSEUUZN4.js";import{a as Re,b as _e,c as Je,d as H,e as L,f as S}from"./chunk-7QEZ2SFW.js";import"./chunk-WCWP4EAW.js";import"./chunk-BX7TFVCC.js";import"./chunk-4PI2OSSP.js";import{a as G}from"./chunk-2W4UO5BC.js";import{c as ke}from"./chunk-FBDIQ67D.js";import{a as Be,e as Oe}from"./chunk-OK2QU2EV.js";import{m as Ke}from"./chunk-FACXM2UB.js";import"./chunk-ZPQBVYNN.js";import{B as O,h as me,i as pe,j as K,p as Ge,s as he,w as He}from"./chunk-GNI37YCV.js";import"./chunk-PDBW6GTJ.js";import{a as ut}from"./chunk-GWNGVKLG.js";import{a as it,b as ct}from"./chunk-6G3E4PJ2.js";import{a as c,d as $e}from"./chunk-5PEAXTYQ.js";var $=$e(ut(),1),M=$e(it(),1);var s=$e(ct(),1);var mt=c((n,e)=>{let t=new Set(n.map(a=>a.deadLetterQueue).filter(a=>typeof a=="string"&&a!=="")),o=n.filter(a=>(a.deadLetterQueue===void 0||a.deadLetterQueue==="")&&!t.has(a.name)),r=e.filter(a=>a.deadLettered).length;return{deadLetteredCount:r,queuesWithoutDlq:o,showReliabilityWarning:o.length>0||r>0}},"ct"),We="topic:",je=c(n=>{let e=[],t=new Map;for(let o of n)o.topic===void 0?e.push(o):t.set(o.topic,[...t.get(o.topic)??[],o]);return{plain:e,topics:t}},"Be"),rt=c(n=>`${We}${n}`,"He"),pt=c((n,e)=>n.startsWith(We)?(e.get(n.slice(We.length))??[]).map(t=>t.exportName):[n],"ut"),ht=200,gt=me(G.sendQueueMessage),ft=c(async(n,e,t)=>{let o=(await Promise.allSettled(e.map(async a=>n.query(gt,a,pe(""))))).flatMap((a,l)=>a.status==="rejected"?[{exportName:e[l]?.exportName??"",message:K(a.reason)}]:[]),[r]=o;return r===void 0?null:e.length===1?r.message:t("Not sent to {failed}",{failed:o.map(a=>`${a.exportName}: ${a.message}`).join("; ")})},"ft"),xt=me(G.replayQueueMessage),yt=me(G.clearQueueMessages),at=96,Nt=c(n=>{if(n===void 0)return"\u2014";try{return JSON.stringify(n,Ge)}catch{return"[unserializable]"}},"xt"),bt=c(n=>n.length>at?`${n.slice(0,at)}\u2026`:n,"yt"),qt=c(n=>n==="error"?"destructive":n==="retry"?"outline":"secondary","bt"),vt=c((n,e)=>e(n==="messages"?"Messages":n==="send"?"Send":"Declared"),"Nt"),nt=c(n=>{let e=(0,$.c)(17),{queue:t}=n,o=`queues-row-${t.exportName}`,r;e[0]!==t.exportName?(r=(0,s.jsx)(S,{className:"font-mono text-xs",children:t.exportName}),e[0]=t.exportName,e[1]=r):r=e[1];let a;e[2]!==t.name?(a=(0,s.jsx)(S,{className:"font-mono text-xs text-muted-foreground",children:t.name}),e[2]=t.name,e[3]=a):a=e[3];let l;e[4]!==t.mode?(l=(0,s.jsx)(S,{className:"font-mono text-xs text-muted-foreground",children:t.mode}),e[4]=t.mode,e[5]=l):l=e[5];let d;e[6]!==t.binding?(d=(0,s.jsx)(S,{className:"font-mono text-xs text-muted-foreground",children:t.binding}),e[6]=t.binding,e[7]=d):d=e[7];let i=t.deadLetterQueue??"\u2014",u;e[8]!==i?(u=(0,s.jsx)(S,{className:"font-mono text-xs text-muted-foreground",children:i}),e[8]=i,e[9]=u):u=e[9];let p;return e[10]!==o||e[11]!==r||e[12]!==a||e[13]!==l||e[14]!==d||e[15]!==u?(p=(0,s.jsxs)(H,{"data-testid":o,children:[r,a,l,d,u]}),e[10]=o,e[11]=r,e[12]=a,e[13]=l,e[14]=d,e[15]=u,e[16]=p):p=e[16],p},"Ve"),St=c(n=>{let e=(0,$.c)(8),{loaded:t,queues:o}=n,r=O(),a;if(e[0]!==t||e[1]!==o||e[2]!==r){let{plain:l,topics:d}=je(o),i;e[4]!==r?(i=r("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[4]=r,e[5]=i):i=e[5];let u;e[6]!==i?(u=(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:i}),e[6]=i,e[7]=u):u=e[7],a=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[u,t&&o.length===0?(0,s.jsx)(xe,{description:r("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:r("No queues defined")}):(0,s.jsx)(Be,{className:"overflow-hidden py-0",children:(0,s.jsx)(Oe,{className:"px-0",children:(0,s.jsxs)(Re,{"data-testid":"queues-table",children:[(0,s.jsx)(_e,{children:(0,s.jsxs)(H,{children:[(0,s.jsx)(L,{children:r("Export")}),(0,s.jsx)(L,{children:r("Queue")}),(0,s.jsx)(L,{children:r("Mode")}),(0,s.jsx)(L,{children:r("Binding")}),(0,s.jsx)(L,{children:r("Dead-letter")})]})}),(0,s.jsxs)(Je,{children:[l.map(Et),[...d].map(p=>{let[f,x]=p;return(0,s.jsxs)(M.Fragment,{children:[(0,s.jsx)(H,{className:"bg-muted/40","data-testid":`queues-topic-${f}`,children:(0,s.jsx)(S,{className:"text-xs font-medium",colSpan:5,children:r("Topic {topic} \xB7 {count} subscriptions",{count:x.length,topic:f})})}),x.map(Mt)]},f)})]})]})})})]}),e[0]=t,e[1]=o,e[2]=r,e[3]=a}else a=e[3];return a},"qt"),Ct=c(n=>{let e=(0,$.c)(67),{message:t,onReplay:o,replayingId:r}=n,a=O(),l,d,i,u,p,f,x,m,h,N;if(e[0]!==t.attempts||e[1]!==t.body||e[2]!==t.deadLettered||e[3]!==t.exportName||e[4]!==t.id||e[5]!==t.messageId||e[6]!==t.outcome||e[7]!==t.queue||e[8]!==a){let R=Nt(t.body);d=H,f=`queues-message-${t.id}`;let _=t.exportName??t.queue;e[19]!==_?(x=(0,s.jsx)(S,{className:"font-mono text-xs",children:_}),e[19]=_,e[20]=x):x=e[20],e[21]!==t.messageId?(m=(0,s.jsx)(S,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:t.messageId,children:t.messageId}),e[21]=t.messageId,e[22]=m):m=e[22],e[23]!==t.attempts?(h=(0,s.jsx)(S,{className:"font-mono text-xs tabular-nums",children:t.attempts}),e[23]=t.attempts,e[24]=h):h=e[24];let k=`queues-outcome-${t.id}`,w;e[25]!==t.outcome?(w=qt(t.outcome),e[25]=t.outcome,e[26]=w):w=e[26];let T;e[27]!==t.outcome||e[28]!==k||e[29]!==w?(T=(0,s.jsx)(ge,{"data-testid":k,variant:w,children:t.outcome}),e[27]=t.outcome,e[28]=k,e[29]=w,e[30]=T):T=e[30];let I;e[31]!==t.deadLettered||e[32]!==t.id||e[33]!==a?(I=t.deadLettered&&(0,s.jsx)(ge,{"data-testid":`queues-dlq-${t.id}`,variant:"destructive",children:a("DLQ")}),e[31]=t.deadLettered,e[32]=t.id,e[33]=a,e[34]=I):I=e[34],e[35]!==T||e[36]!==I?(N=(0,s.jsx)(S,{children:(0,s.jsxs)("span",{className:"inline-flex items-center gap-1",children:[T,I]})}),e[35]=T,e[36]=I,e[37]=N):N=e[37],l=S,i="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",u=R,p=bt(R),e[0]=t.attempts,e[1]=t.body,e[2]=t.deadLettered,e[3]=t.exportName,e[4]=t.id,e[5]=t.messageId,e[6]=t.outcome,e[7]=t.queue,e[8]=a,e[9]=l,e[10]=d,e[11]=i,e[12]=u,e[13]=p,e[14]=f,e[15]=x,e[16]=m,e[17]=h,e[18]=N}else l=e[9],d=e[10],i=e[11],u=e[12],p=e[13],f=e[14],x=e[15],m=e[16],h=e[17],N=e[18];let y;e[38]!==l||e[39]!==i||e[40]!==u||e[41]!==p?(y=(0,s.jsx)(l,{className:i,title:u,children:p}),e[38]=l,e[39]=i,e[40]=u,e[41]=p,e[42]=y):y=e[42];let b;e[43]!==t.capturedAt?(b=He(t.capturedAt,"\u2014"),e[43]=t.capturedAt,e[44]=b):b=e[44];let C;e[45]!==b?(C=(0,s.jsx)(S,{className:"text-xs text-muted-foreground tabular-nums",children:b}),e[45]=b,e[46]=C):C=e[46];let q=`queues-replay-${t.id}`,v=r!==null,E;e[47]!==t.id||e[48]!==r||e[49]!==a?(E=r===t.id?a("Replaying\u2026"):a("Replay"),e[47]=t.id,e[48]=r,e[49]=a,e[50]=E):E=e[50];let A;e[51]!==t.id||e[52]!==o||e[53]!==q||e[54]!==v||e[55]!==E?(A=(0,s.jsx)(S,{children:(0,s.jsx)(fe,{"data-id":t.id,"data-testid":q,disabled:v,onClick:o,size:"xs",type:"button",variant:"outline",children:E})}),e[51]=t.id,e[52]=o,e[53]=q,e[54]=v,e[55]=E,e[56]=A):A=e[56];let D;return e[57]!==d||e[58]!==C||e[59]!==A||e[60]!==f||e[61]!==x||e[62]!==m||e[63]!==h||e[64]!==N||e[65]!==y?(D=(0,s.jsxs)(d,{"data-testid":f,children:[x,m,h,N,y,C,A]}),e[57]=d,e[58]=C,e[59]=A,e[60]=f,e[61]=x,e[62]=m,e[63]=h,e[64]=N,e[65]=y,e[66]=D):D=e[66],D},"St"),wt=c(n=>{let e=(0,$.c)(29),{hasError:t,messages:o,onClear:r,onReplay:a,replayingId:l}=n,d=O(),i;e[0]!==d?(i=d("Cloudflare Queues have no peek API, so this is what push consumers actually processed \u2014 not pending depth."),e[0]=d,e[1]=i):i=e[1];let u;e[2]!==i?(u=(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:i}),e[2]=i,e[3]=u):u=e[3];let p;e[4]!==d?(p=d("Clear the whole message log?"),e[4]=d,e[5]=p):p=e[5];let f=o.length===0,x;e[6]!==d?(x=d("Clear log"),e[6]=d,e[7]=x):x=e[7];let m;e[8]!==r||e[9]!==p||e[10]!==f||e[11]!==x?(m=(0,s.jsx)("div",{className:"ml-auto",children:(0,s.jsx)(Ze,{confirmLabel:p,disabled:f,onConfirm:r,testId:"queues-clear",children:x})}),e[8]=r,e[9]=p,e[10]=f,e[11]=x,e[12]=m):m=e[12];let h;e[13]!==o.length||e[14]!==d?(h=o.length>0&&(0,s.jsx)(ge,{"data-testid":"queues-count",variant:"secondary",children:d("{count} messages",{count:o.length})}),e[13]=o.length,e[14]=d,e[15]=h):h=e[15];let N;e[16]!==u||e[17]!==m||e[18]!==h?(N=(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[u,m,h]}),e[16]=u,e[17]=m,e[18]=h,e[19]=N):N=e[19];let y;e[20]!==t||e[21]!==o||e[22]!==a||e[23]!==l||e[24]!==d?(y=!t&&o.length===0?(0,s.jsx)(xe,{description:d("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:d("No consumed messages yet.")}):(0,s.jsx)(Be,{className:"overflow-hidden py-0",children:(0,s.jsx)(Oe,{className:"px-0",children:(0,s.jsx)(st,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:(0,s.jsxs)(Re,{"data-testid":"queues-messages-table",children:[(0,s.jsx)(_e,{children:(0,s.jsxs)(H,{children:[(0,s.jsx)(L,{children:d("Export")}),(0,s.jsx)(L,{children:d("Message")}),(0,s.jsx)(L,{children:d("Attempts")}),(0,s.jsx)(L,{children:d("Outcome")}),(0,s.jsx)(L,{children:d("Body")}),(0,s.jsx)(L,{children:d("Captured")}),(0,s.jsx)(L,{})]})}),(0,s.jsx)(Je,{children:o.map(C=>(0,s.jsx)(Ct,{message:C,onReplay:a,replayingId:l},C.id))})]})})})}),e[20]=t,e[21]=o,e[22]=a,e[23]=l,e[24]=d,e[25]=y):y=e[25];let b;return e[26]!==N||e[27]!==y?(b=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[N,y]}),e[26]=N,e[27]=y,e[28]=b):b=e[28],b},"Et"),It=c(n=>{let e=(0,$.c)(20),{batchMode:t,bodyText:o,delayText:r,onBatchModeChange:a,onBodyChange:l,onDelayChange:d,onSelectExport:i,onSend:u,queues:p,selectedExportName:f,sending:x}=n,m=O(),h;e[0]!==m?(h=m("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=m,e[1]=h):h=e[1];let N;e[2]!==h?(N=(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:h}),e[2]=h,e[3]=N):N=e[3];let y;e[4]!==t||e[5]!==o||e[6]!==r||e[7]!==a||e[8]!==l||e[9]!==d||e[10]!==i||e[11]!==u||e[12]!==p||e[13]!==f||e[14]!==x||e[15]!==m?(y=p.length===0?(0,s.jsx)(xe,{description:m("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:m("No queues to send to")}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsxs)("select",{"aria-label":m("Queue"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"queues-send-select",onChange:i,value:f,children:[p.map(At),[...je(p).topics].map(C=>{let[q,v]=C;return(0,s.jsx)("option",{value:rt(q),children:m("{topic} (topic \u2192 {count} subscriptions)",{count:v.length,topic:q})},q)})]}),(0,s.jsx)(Ve,{"aria-label":m("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:d,placeholder:m("Delay (s)"),type:"number",value:r}),(0,s.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[(0,s.jsx)("input",{checked:t,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:a,type:"checkbox"}),m("Send as batch (JSON array)")]}),(0,s.jsx)(fe,{className:"ml-auto","data-testid":"queues-send-button",disabled:x||f==="",onClick:u,type:"button",children:m(x?"Sending\u2026":"Send message")})]}),(0,s.jsx)(et,{"aria-label":m("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:l,placeholder:t?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:o})]}),e[4]=t,e[5]=o,e[6]=r,e[7]=a,e[8]=l,e[9]=d,e[10]=i,e[11]=u,e[12]=p,e[13]=f,e[14]=x,e[15]=m,e[16]=y):y=e[16];let b;return e[17]!==N||e[18]!==y?(b=(0,s.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[N,y]}),e[17]=N,e[18]=y,e[19]=b):b=e[19],b},"Tt"),Qt=c((n,e,t,o)=>{let r=null,a=n.trim();if(a!=="")try{r=JSON.parse(a)}catch{return{error:o("Body must be valid JSON.")}}let l,d=e.trim();if(d!==""){let i=Number(d);if(!Number.isFinite(i)||i<0)return{error:o("Delay must be a non-negative number of seconds.")};l=i}return t&&!Array.isArray(r)?{error:o("Batch mode needs a JSON array body \u2014 each element is enqueued as one message.")}:{body:r,delaySeconds:l}},"Ct"),Lt=c(n=>{let e=(0,$.c)(11),{deadLetteredCount:t,queuesWithoutDlq:o}=n,r=O(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=(0,s.jsx)("span",{"aria-hidden":"true",className:"text-base leading-none",children:"\u26A0"}),e[0]=a):a=e[0];let l;e[1]!==o||e[2]!==r?(l=o.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{className:"font-medium",children:r("No dead-letter queue on {queues}.",{queues:o.map(Tt).join(", ")})}),(0,s.jsx)("p",{className:"text-muted-foreground",children:r("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),e[1]=o,e[2]=r,e[3]=l):l=e[3];let d;e[4]!==t||e[5]!==o.length||e[6]!==r?(d=t>0&&(0,s.jsx)("p",{className:o.length>0?"text-muted-foreground":"font-medium",children:t===1?r("1 message was recently dead-lettered."):r("{count} messages were recently dead-lettered.",{count:t})}),e[4]=t,e[5]=o.length,e[6]=r,e[7]=d):d=e[7];let i;return e[8]!==l||e[9]!==d?(i=(0,s.jsx)(Xe,{icon:a,testId:"queues-dlq-warning",variant:"warning",children:(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[l,d]})}),e[8]=l,e[9]=d,e[10]=i):i=e[10],i},"_t"),Zt=c(n=>{let e=(0,$.c)(76),{limit:t}=n,o=t??ht,r=Ke(),a=O(),[l,d]=(0,M.useState)("declared"),[i,u]=(0,M.useState)(null),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let{data:f,error:x,errorSource:m}=ke(G.listQueues,p),h;e[1]!==o?(h={limit:o},e[1]=o,e[2]=h):h=e[2];let{data:N,error:y,errorSource:b,poll:C,refetch:q}=ke(G.getQueueMessages,h),v=Array.isArray(f?.queues)?[...f.queues].toSorted(Dt):[],E=N?.entries??[],{deadLetteredCount:A,queuesWithoutDlq:D,showReliabilityWarning:R}=mt(v,E),[_,k]=(0,M.useState)(""),[w,T]=(0,M.useState)(""),[I,ye]=(0,M.useState)(""),[B,Ne]=(0,M.useState)(!1),[be,V]=(0,M.useState)(!1),[qe,X]=(0,M.useState)(null),{topics:Y}=je(v),Fe=[...v.map($t),...[...Y.keys()].map(kt)],J=Fe.includes(_)?_:Fe[0]??"",ze=l==="messages"?y:x,ot=l==="messages"?b:m,ve=ze??i,Se=ze===null?i:ot;tt(C,l==="messages");let Z;e[3]!==B||e[4]!==w||e[5]!==r||e[6]!==I||e[7]!==q||e[8]!==J||e[9]!==V||e[10]!==a||e[11]!==Y?(Z=c(async()=>{u(null);let g=J;if(g==="")return;let Q=Qt(w,I,B,a);if("error"in Q){u(Q.error);return}let{body:Pe,delaySeconds:Ue}=Q;V(!0);let lt=pt(g,Y).map(ce=>B?{batch:Pe,delaySeconds:Ue,exportName:ce}:{body:Pe,delaySeconds:Ue,exportName:ce});try{u(await ft(r,lt,a)),q()}catch(ce){u(K(ce))}V(!1)},"K"),e[3]=B,e[4]=w,e[5]=r,e[6]=I,e[7]=q,e[8]=J,e[9]=V,e[10]=a,e[11]=Y,e[12]=Z):Z=e[12];let Ce=Z,ee;e[13]!==r||e[14]!==q||e[15]!==X?(ee=c(async g=>{u(null),X(g);try{await r.query(xt,{id:g},pe("")),q()}catch(Q){u(K(Q))}X(null)},"Z"),e[13]=r,e[14]=q,e[15]=X,e[16]=ee):ee=e[16];let we=ee,te;e[17]!==r||e[18]!==q?(te=c(async()=>{u(null);try{await r.query(yt,{},pe("")),q()}catch(g){u(K(g))}},"ee"),e[17]=r,e[18]=q,e[19]=te):te=e[19];let Ie=te,se;e[20]===Symbol.for("react.memo_cache_sentinel")?(se=c(g=>{let Q=g.currentTarget.dataset.tab;(Q==="declared"||Q==="messages"||Q==="send")&&d(Q)},"te"),e[20]=se):se=e[20];let dt=se,ae;e[21]!==k?(ae=c(g=>{k(g.currentTarget.value)},"se"),e[21]=k,e[22]=ae):ae=e[22];let Qe=ae,re;e[23]!==T?(re=c(g=>{T(g.currentTarget.value)},"re"),e[23]=T,e[24]=re):re=e[24];let Le=re,ne;e[25]!==ye?(ne=c(g=>{ye(g.currentTarget.value)},"ae"),e[25]=ye,e[26]=ne):ne=e[26];let Ee=ne,oe;e[27]!==Ne?(oe=c(g=>{Ne(g.currentTarget.checked)},"ne"),e[27]=Ne,e[28]=oe):oe=e[28];let Me=oe,de;e[29]!==Ce?(de=c(()=>{he(Ce())},"oe"),e[29]=Ce,e[30]=de):de=e[30];let Ae=de,le;e[31]!==we?(le=c(g=>{let{id:Q}=g.currentTarget.dataset;Q!==void 0&&he(we(Q))},"le"),e[31]=we,e[32]=le):le=e[32];let Te=le,ie;e[33]!==Ie?(ie=c(()=>{he(Ie())},"ie"),e[33]=Ie,e[34]=ie):ie=e[34];let De=ie,W;e[35]!==a||e[36]!==l?(W=(0,s.jsx)("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(g=>(0,s.jsx)(fe,{"aria-selected":l===g,"data-tab":g,"data-testid":`queues-tab-${g}`,onClick:dt,role:"tab",size:"sm",type:"button",variant:l===g?"secondary":"ghost",children:vt(g,a)},g))}),e[35]=a,e[36]=l,e[37]=W):W=e[37];let j;e[38]!==ve||e[39]!==Se?(j=ve!==null&&(0,s.jsx)(Ye,{error:Se,testId:"queues-error"}),e[38]=ve,e[39]=Se,e[40]=j):j=e[40];let F;e[41]!==A||e[42]!==D||e[43]!==R?(F=R&&(0,s.jsx)(Lt,{deadLetteredCount:A,queuesWithoutDlq:D}),e[41]=A,e[42]=D,e[43]=R,e[44]=F):F=e[44];let z;e[45]!==v||e[46]!==f||e[47]!==l?(z=l==="declared"&&(0,s.jsx)(St,{loaded:f!==void 0,queues:v}),e[45]=v,e[46]=f,e[47]=l,e[48]=z):z=e[48];let P;e[49]!==E||e[50]!==y||e[51]!==De||e[52]!==Te||e[53]!==qe||e[54]!==l?(P=l==="messages"&&(0,s.jsx)(wt,{hasError:y!==null,messages:E,onClear:De,onReplay:Te,replayingId:qe}),e[49]=E,e[50]=y,e[51]=De,e[52]=Te,e[53]=qe,e[54]=l,e[55]=P):P=e[55];let U;e[56]!==B||e[57]!==w||e[58]!==I||e[59]!==Me||e[60]!==Le||e[61]!==Ee||e[62]!==Qe||e[63]!==Ae||e[64]!==v||e[65]!==J||e[66]!==be||e[67]!==l?(U=l==="send"&&(0,s.jsx)(It,{batchMode:B,bodyText:w,delayText:I,onBatchModeChange:Me,onBodyChange:Le,onDelayChange:Ee,onSelectExport:Qe,onSend:Ae,queues:v,selectedExportName:J,sending:be}),e[56]=B,e[57]=w,e[58]=I,e[59]=Me,e[60]=Le,e[61]=Ee,e[62]=Qe,e[63]=Ae,e[64]=v,e[65]=J,e[66]=be,e[67]=l,e[68]=U):U=e[68];let ue;return e[69]!==W||e[70]!==j||e[71]!==F||e[72]!==z||e[73]!==P||e[74]!==U?(ue=(0,s.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-queues-panel",children:[W,j,F,z,P,U]}),e[69]=W,e[70]=j,e[71]=F,e[72]=z,e[73]=P,e[74]=U,e[75]=ue):ue=e[75],ue},"ts");function Et(n){return(0,s.jsx)(nt,{queue:n},n.exportName)}c(Et,"vt");function Mt(n){return(0,s.jsx)(nt,{queue:n},n.exportName)}c(Mt,"wt");function At(n){return(0,s.jsx)("option",{value:n.exportName,children:n.exportName},n.exportName)}c(At,"Qt");function Tt(n){return n.name}c(Tt,"At");function Dt(n,e){return n.exportName.localeCompare(e.exportName)}c(Dt,"It");function $t(n){return n.exportName}c($t,"Mt");function kt(n){return rt(n)}c(kt,"Lt");export{Zt as default};
1
+ import{a as st}from"./chunk-2NGKUO32.js";import{a as tt}from"./chunk-EPWCW2DF.js";import"./chunk-O3AZ7JKE.js";import{a as et}from"./chunk-PJUVJTDR.js";import"./chunk-D65UVZIA.js";import{a as Ze}from"./chunk-YEVTA35E.js";import{i as Ve}from"./chunk-IHGRWY3Y.js";import"./chunk-OWRKSQPE.js";import"./chunk-4EPW63HS.js";import{a as fe}from"./chunk-V3BE427M.js";import"./chunk-CKEQX655.js";import"./chunk-UD5REVU2.js";import{a as xe}from"./chunk-RCXNYW7P.js";import{b as ge}from"./chunk-UQA2AJGI.js";import"./chunk-T3ZCW3RG.js";import{a as Ye}from"./chunk-YEXTJUKQ.js";import{a as Xe}from"./chunk-LSEUUZN4.js";import{a as Re,b as _e,c as Je,d as H,e as L,f as S}from"./chunk-7QEZ2SFW.js";import"./chunk-OZAOWE7T.js";import"./chunk-BBDTJG2K.js";import"./chunk-4PI2OSSP.js";import{a as G}from"./chunk-2W4UO5BC.js";import{c as ke}from"./chunk-4N76XUNG.js";import{a as Be,e as Oe}from"./chunk-OK2QU2EV.js";import{m as Ke}from"./chunk-SHHGIT7M.js";import"./chunk-ZPQBVYNN.js";import{B as O,h as me,i as pe,j as K,p as Ge,s as he,w as He}from"./chunk-GNI37YCV.js";import"./chunk-PDBW6GTJ.js";import{a as ut}from"./chunk-GWNGVKLG.js";import{a as it,b as ct}from"./chunk-6G3E4PJ2.js";import{a as c,d as $e}from"./chunk-5PEAXTYQ.js";var $=$e(ut(),1),M=$e(it(),1);var s=$e(ct(),1);var mt=c((n,e)=>{let t=new Set(n.map(a=>a.deadLetterQueue).filter(a=>typeof a=="string"&&a!=="")),o=n.filter(a=>(a.deadLetterQueue===void 0||a.deadLetterQueue==="")&&!t.has(a.name)),r=e.filter(a=>a.deadLettered).length;return{deadLetteredCount:r,queuesWithoutDlq:o,showReliabilityWarning:o.length>0||r>0}},"ct"),We="topic:",je=c(n=>{let e=[],t=new Map;for(let o of n)o.topic===void 0?e.push(o):t.set(o.topic,[...t.get(o.topic)??[],o]);return{plain:e,topics:t}},"Be"),rt=c(n=>`${We}${n}`,"He"),pt=c((n,e)=>n.startsWith(We)?(e.get(n.slice(We.length))??[]).map(t=>t.exportName):[n],"ut"),ht=200,gt=me(G.sendQueueMessage),ft=c(async(n,e,t)=>{let o=(await Promise.allSettled(e.map(async a=>n.query(gt,a,pe(""))))).flatMap((a,l)=>a.status==="rejected"?[{exportName:e[l]?.exportName??"",message:K(a.reason)}]:[]),[r]=o;return r===void 0?null:e.length===1?r.message:t("Not sent to {failed}",{failed:o.map(a=>`${a.exportName}: ${a.message}`).join("; ")})},"ft"),xt=me(G.replayQueueMessage),yt=me(G.clearQueueMessages),at=96,Nt=c(n=>{if(n===void 0)return"\u2014";try{return JSON.stringify(n,Ge)}catch{return"[unserializable]"}},"xt"),bt=c(n=>n.length>at?`${n.slice(0,at)}\u2026`:n,"yt"),qt=c(n=>n==="error"?"destructive":n==="retry"?"outline":"secondary","bt"),vt=c((n,e)=>e(n==="messages"?"Messages":n==="send"?"Send":"Declared"),"Nt"),nt=c(n=>{let e=(0,$.c)(17),{queue:t}=n,o=`queues-row-${t.exportName}`,r;e[0]!==t.exportName?(r=(0,s.jsx)(S,{className:"font-mono text-xs",children:t.exportName}),e[0]=t.exportName,e[1]=r):r=e[1];let a;e[2]!==t.name?(a=(0,s.jsx)(S,{className:"font-mono text-xs text-muted-foreground",children:t.name}),e[2]=t.name,e[3]=a):a=e[3];let l;e[4]!==t.mode?(l=(0,s.jsx)(S,{className:"font-mono text-xs text-muted-foreground",children:t.mode}),e[4]=t.mode,e[5]=l):l=e[5];let d;e[6]!==t.binding?(d=(0,s.jsx)(S,{className:"font-mono text-xs text-muted-foreground",children:t.binding}),e[6]=t.binding,e[7]=d):d=e[7];let i=t.deadLetterQueue??"\u2014",u;e[8]!==i?(u=(0,s.jsx)(S,{className:"font-mono text-xs text-muted-foreground",children:i}),e[8]=i,e[9]=u):u=e[9];let p;return e[10]!==o||e[11]!==r||e[12]!==a||e[13]!==l||e[14]!==d||e[15]!==u?(p=(0,s.jsxs)(H,{"data-testid":o,children:[r,a,l,d,u]}),e[10]=o,e[11]=r,e[12]=a,e[13]=l,e[14]=d,e[15]=u,e[16]=p):p=e[16],p},"Ve"),St=c(n=>{let e=(0,$.c)(8),{loaded:t,queues:o}=n,r=O(),a;if(e[0]!==t||e[1]!==o||e[2]!==r){let{plain:l,topics:d}=je(o),i;e[4]!==r?(i=r("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[4]=r,e[5]=i):i=e[5];let u;e[6]!==i?(u=(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:i}),e[6]=i,e[7]=u):u=e[7],a=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[u,t&&o.length===0?(0,s.jsx)(xe,{description:r("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:r("No queues defined")}):(0,s.jsx)(Be,{className:"overflow-hidden py-0",children:(0,s.jsx)(Oe,{className:"px-0",children:(0,s.jsxs)(Re,{"data-testid":"queues-table",children:[(0,s.jsx)(_e,{children:(0,s.jsxs)(H,{children:[(0,s.jsx)(L,{children:r("Export")}),(0,s.jsx)(L,{children:r("Queue")}),(0,s.jsx)(L,{children:r("Mode")}),(0,s.jsx)(L,{children:r("Binding")}),(0,s.jsx)(L,{children:r("Dead-letter")})]})}),(0,s.jsxs)(Je,{children:[l.map(Et),[...d].map(p=>{let[f,x]=p;return(0,s.jsxs)(M.Fragment,{children:[(0,s.jsx)(H,{className:"bg-muted/40","data-testid":`queues-topic-${f}`,children:(0,s.jsx)(S,{className:"text-xs font-medium",colSpan:5,children:r("Topic {topic} \xB7 {count} subscriptions",{count:x.length,topic:f})})}),x.map(Mt)]},f)})]})]})})})]}),e[0]=t,e[1]=o,e[2]=r,e[3]=a}else a=e[3];return a},"qt"),Ct=c(n=>{let e=(0,$.c)(67),{message:t,onReplay:o,replayingId:r}=n,a=O(),l,d,i,u,p,f,x,m,h,N;if(e[0]!==t.attempts||e[1]!==t.body||e[2]!==t.deadLettered||e[3]!==t.exportName||e[4]!==t.id||e[5]!==t.messageId||e[6]!==t.outcome||e[7]!==t.queue||e[8]!==a){let R=Nt(t.body);d=H,f=`queues-message-${t.id}`;let _=t.exportName??t.queue;e[19]!==_?(x=(0,s.jsx)(S,{className:"font-mono text-xs",children:_}),e[19]=_,e[20]=x):x=e[20],e[21]!==t.messageId?(m=(0,s.jsx)(S,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:t.messageId,children:t.messageId}),e[21]=t.messageId,e[22]=m):m=e[22],e[23]!==t.attempts?(h=(0,s.jsx)(S,{className:"font-mono text-xs tabular-nums",children:t.attempts}),e[23]=t.attempts,e[24]=h):h=e[24];let k=`queues-outcome-${t.id}`,w;e[25]!==t.outcome?(w=qt(t.outcome),e[25]=t.outcome,e[26]=w):w=e[26];let T;e[27]!==t.outcome||e[28]!==k||e[29]!==w?(T=(0,s.jsx)(ge,{"data-testid":k,variant:w,children:t.outcome}),e[27]=t.outcome,e[28]=k,e[29]=w,e[30]=T):T=e[30];let I;e[31]!==t.deadLettered||e[32]!==t.id||e[33]!==a?(I=t.deadLettered&&(0,s.jsx)(ge,{"data-testid":`queues-dlq-${t.id}`,variant:"destructive",children:a("DLQ")}),e[31]=t.deadLettered,e[32]=t.id,e[33]=a,e[34]=I):I=e[34],e[35]!==T||e[36]!==I?(N=(0,s.jsx)(S,{children:(0,s.jsxs)("span",{className:"inline-flex items-center gap-1",children:[T,I]})}),e[35]=T,e[36]=I,e[37]=N):N=e[37],l=S,i="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",u=R,p=bt(R),e[0]=t.attempts,e[1]=t.body,e[2]=t.deadLettered,e[3]=t.exportName,e[4]=t.id,e[5]=t.messageId,e[6]=t.outcome,e[7]=t.queue,e[8]=a,e[9]=l,e[10]=d,e[11]=i,e[12]=u,e[13]=p,e[14]=f,e[15]=x,e[16]=m,e[17]=h,e[18]=N}else l=e[9],d=e[10],i=e[11],u=e[12],p=e[13],f=e[14],x=e[15],m=e[16],h=e[17],N=e[18];let y;e[38]!==l||e[39]!==i||e[40]!==u||e[41]!==p?(y=(0,s.jsx)(l,{className:i,title:u,children:p}),e[38]=l,e[39]=i,e[40]=u,e[41]=p,e[42]=y):y=e[42];let b;e[43]!==t.capturedAt?(b=He(t.capturedAt,"\u2014"),e[43]=t.capturedAt,e[44]=b):b=e[44];let C;e[45]!==b?(C=(0,s.jsx)(S,{className:"text-xs text-muted-foreground tabular-nums",children:b}),e[45]=b,e[46]=C):C=e[46];let q=`queues-replay-${t.id}`,v=r!==null,E;e[47]!==t.id||e[48]!==r||e[49]!==a?(E=r===t.id?a("Replaying\u2026"):a("Replay"),e[47]=t.id,e[48]=r,e[49]=a,e[50]=E):E=e[50];let A;e[51]!==t.id||e[52]!==o||e[53]!==q||e[54]!==v||e[55]!==E?(A=(0,s.jsx)(S,{children:(0,s.jsx)(fe,{"data-id":t.id,"data-testid":q,disabled:v,onClick:o,size:"xs",type:"button",variant:"outline",children:E})}),e[51]=t.id,e[52]=o,e[53]=q,e[54]=v,e[55]=E,e[56]=A):A=e[56];let D;return e[57]!==d||e[58]!==C||e[59]!==A||e[60]!==f||e[61]!==x||e[62]!==m||e[63]!==h||e[64]!==N||e[65]!==y?(D=(0,s.jsxs)(d,{"data-testid":f,children:[x,m,h,N,y,C,A]}),e[57]=d,e[58]=C,e[59]=A,e[60]=f,e[61]=x,e[62]=m,e[63]=h,e[64]=N,e[65]=y,e[66]=D):D=e[66],D},"St"),wt=c(n=>{let e=(0,$.c)(29),{hasError:t,messages:o,onClear:r,onReplay:a,replayingId:l}=n,d=O(),i;e[0]!==d?(i=d("Cloudflare Queues have no peek API, so this is what push consumers actually processed \u2014 not pending depth."),e[0]=d,e[1]=i):i=e[1];let u;e[2]!==i?(u=(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:i}),e[2]=i,e[3]=u):u=e[3];let p;e[4]!==d?(p=d("Clear the whole message log?"),e[4]=d,e[5]=p):p=e[5];let f=o.length===0,x;e[6]!==d?(x=d("Clear log"),e[6]=d,e[7]=x):x=e[7];let m;e[8]!==r||e[9]!==p||e[10]!==f||e[11]!==x?(m=(0,s.jsx)("div",{className:"ml-auto",children:(0,s.jsx)(Ze,{confirmLabel:p,disabled:f,onConfirm:r,testId:"queues-clear",children:x})}),e[8]=r,e[9]=p,e[10]=f,e[11]=x,e[12]=m):m=e[12];let h;e[13]!==o.length||e[14]!==d?(h=o.length>0&&(0,s.jsx)(ge,{"data-testid":"queues-count",variant:"secondary",children:d("{count} messages",{count:o.length})}),e[13]=o.length,e[14]=d,e[15]=h):h=e[15];let N;e[16]!==u||e[17]!==m||e[18]!==h?(N=(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[u,m,h]}),e[16]=u,e[17]=m,e[18]=h,e[19]=N):N=e[19];let y;e[20]!==t||e[21]!==o||e[22]!==a||e[23]!==l||e[24]!==d?(y=!t&&o.length===0?(0,s.jsx)(xe,{description:d("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:d("No consumed messages yet.")}):(0,s.jsx)(Be,{className:"overflow-hidden py-0",children:(0,s.jsx)(Oe,{className:"px-0",children:(0,s.jsx)(st,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:(0,s.jsxs)(Re,{"data-testid":"queues-messages-table",children:[(0,s.jsx)(_e,{children:(0,s.jsxs)(H,{children:[(0,s.jsx)(L,{children:d("Export")}),(0,s.jsx)(L,{children:d("Message")}),(0,s.jsx)(L,{children:d("Attempts")}),(0,s.jsx)(L,{children:d("Outcome")}),(0,s.jsx)(L,{children:d("Body")}),(0,s.jsx)(L,{children:d("Captured")}),(0,s.jsx)(L,{})]})}),(0,s.jsx)(Je,{children:o.map(C=>(0,s.jsx)(Ct,{message:C,onReplay:a,replayingId:l},C.id))})]})})})}),e[20]=t,e[21]=o,e[22]=a,e[23]=l,e[24]=d,e[25]=y):y=e[25];let b;return e[26]!==N||e[27]!==y?(b=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[N,y]}),e[26]=N,e[27]=y,e[28]=b):b=e[28],b},"Et"),It=c(n=>{let e=(0,$.c)(20),{batchMode:t,bodyText:o,delayText:r,onBatchModeChange:a,onBodyChange:l,onDelayChange:d,onSelectExport:i,onSend:u,queues:p,selectedExportName:f,sending:x}=n,m=O(),h;e[0]!==m?(h=m("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=m,e[1]=h):h=e[1];let N;e[2]!==h?(N=(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:h}),e[2]=h,e[3]=N):N=e[3];let y;e[4]!==t||e[5]!==o||e[6]!==r||e[7]!==a||e[8]!==l||e[9]!==d||e[10]!==i||e[11]!==u||e[12]!==p||e[13]!==f||e[14]!==x||e[15]!==m?(y=p.length===0?(0,s.jsx)(xe,{description:m("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:m("No queues to send to")}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsxs)("select",{"aria-label":m("Queue"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"queues-send-select",onChange:i,value:f,children:[p.map(At),[...je(p).topics].map(C=>{let[q,v]=C;return(0,s.jsx)("option",{value:rt(q),children:m("{topic} (topic \u2192 {count} subscriptions)",{count:v.length,topic:q})},q)})]}),(0,s.jsx)(Ve,{"aria-label":m("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:d,placeholder:m("Delay (s)"),type:"number",value:r}),(0,s.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[(0,s.jsx)("input",{checked:t,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:a,type:"checkbox"}),m("Send as batch (JSON array)")]}),(0,s.jsx)(fe,{className:"ml-auto","data-testid":"queues-send-button",disabled:x||f==="",onClick:u,type:"button",children:m(x?"Sending\u2026":"Send message")})]}),(0,s.jsx)(et,{"aria-label":m("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:l,placeholder:t?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:o})]}),e[4]=t,e[5]=o,e[6]=r,e[7]=a,e[8]=l,e[9]=d,e[10]=i,e[11]=u,e[12]=p,e[13]=f,e[14]=x,e[15]=m,e[16]=y):y=e[16];let b;return e[17]!==N||e[18]!==y?(b=(0,s.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[N,y]}),e[17]=N,e[18]=y,e[19]=b):b=e[19],b},"Tt"),Qt=c((n,e,t,o)=>{let r=null,a=n.trim();if(a!=="")try{r=JSON.parse(a)}catch{return{error:o("Body must be valid JSON.")}}let l,d=e.trim();if(d!==""){let i=Number(d);if(!Number.isFinite(i)||i<0)return{error:o("Delay must be a non-negative number of seconds.")};l=i}return t&&!Array.isArray(r)?{error:o("Batch mode needs a JSON array body \u2014 each element is enqueued as one message.")}:{body:r,delaySeconds:l}},"Ct"),Lt=c(n=>{let e=(0,$.c)(11),{deadLetteredCount:t,queuesWithoutDlq:o}=n,r=O(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=(0,s.jsx)("span",{"aria-hidden":"true",className:"text-base leading-none",children:"\u26A0"}),e[0]=a):a=e[0];let l;e[1]!==o||e[2]!==r?(l=o.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{className:"font-medium",children:r("No dead-letter queue on {queues}.",{queues:o.map(Tt).join(", ")})}),(0,s.jsx)("p",{className:"text-muted-foreground",children:r("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),e[1]=o,e[2]=r,e[3]=l):l=e[3];let d;e[4]!==t||e[5]!==o.length||e[6]!==r?(d=t>0&&(0,s.jsx)("p",{className:o.length>0?"text-muted-foreground":"font-medium",children:t===1?r("1 message was recently dead-lettered."):r("{count} messages were recently dead-lettered.",{count:t})}),e[4]=t,e[5]=o.length,e[6]=r,e[7]=d):d=e[7];let i;return e[8]!==l||e[9]!==d?(i=(0,s.jsx)(Xe,{icon:a,testId:"queues-dlq-warning",variant:"warning",children:(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[l,d]})}),e[8]=l,e[9]=d,e[10]=i):i=e[10],i},"_t"),Zt=c(n=>{let e=(0,$.c)(76),{limit:t}=n,o=t??ht,r=Ke(),a=O(),[l,d]=(0,M.useState)("declared"),[i,u]=(0,M.useState)(null),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let{data:f,error:x,errorSource:m}=ke(G.listQueues,p),h;e[1]!==o?(h={limit:o},e[1]=o,e[2]=h):h=e[2];let{data:N,error:y,errorSource:b,poll:C,refetch:q}=ke(G.getQueueMessages,h),v=Array.isArray(f?.queues)?[...f.queues].toSorted(Dt):[],E=N?.entries??[],{deadLetteredCount:A,queuesWithoutDlq:D,showReliabilityWarning:R}=mt(v,E),[_,k]=(0,M.useState)(""),[w,T]=(0,M.useState)(""),[I,ye]=(0,M.useState)(""),[B,Ne]=(0,M.useState)(!1),[be,V]=(0,M.useState)(!1),[qe,X]=(0,M.useState)(null),{topics:Y}=je(v),Fe=[...v.map($t),...[...Y.keys()].map(kt)],J=Fe.includes(_)?_:Fe[0]??"",ze=l==="messages"?y:x,ot=l==="messages"?b:m,ve=ze??i,Se=ze===null?i:ot;tt(C,l==="messages");let Z;e[3]!==B||e[4]!==w||e[5]!==r||e[6]!==I||e[7]!==q||e[8]!==J||e[9]!==V||e[10]!==a||e[11]!==Y?(Z=c(async()=>{u(null);let g=J;if(g==="")return;let Q=Qt(w,I,B,a);if("error"in Q){u(Q.error);return}let{body:Pe,delaySeconds:Ue}=Q;V(!0);let lt=pt(g,Y).map(ce=>B?{batch:Pe,delaySeconds:Ue,exportName:ce}:{body:Pe,delaySeconds:Ue,exportName:ce});try{u(await ft(r,lt,a)),q()}catch(ce){u(K(ce))}V(!1)},"K"),e[3]=B,e[4]=w,e[5]=r,e[6]=I,e[7]=q,e[8]=J,e[9]=V,e[10]=a,e[11]=Y,e[12]=Z):Z=e[12];let Ce=Z,ee;e[13]!==r||e[14]!==q||e[15]!==X?(ee=c(async g=>{u(null),X(g);try{await r.query(xt,{id:g},pe("")),q()}catch(Q){u(K(Q))}X(null)},"Z"),e[13]=r,e[14]=q,e[15]=X,e[16]=ee):ee=e[16];let we=ee,te;e[17]!==r||e[18]!==q?(te=c(async()=>{u(null);try{await r.query(yt,{},pe("")),q()}catch(g){u(K(g))}},"ee"),e[17]=r,e[18]=q,e[19]=te):te=e[19];let Ie=te,se;e[20]===Symbol.for("react.memo_cache_sentinel")?(se=c(g=>{let Q=g.currentTarget.dataset.tab;(Q==="declared"||Q==="messages"||Q==="send")&&d(Q)},"te"),e[20]=se):se=e[20];let dt=se,ae;e[21]!==k?(ae=c(g=>{k(g.currentTarget.value)},"se"),e[21]=k,e[22]=ae):ae=e[22];let Qe=ae,re;e[23]!==T?(re=c(g=>{T(g.currentTarget.value)},"re"),e[23]=T,e[24]=re):re=e[24];let Le=re,ne;e[25]!==ye?(ne=c(g=>{ye(g.currentTarget.value)},"ae"),e[25]=ye,e[26]=ne):ne=e[26];let Ee=ne,oe;e[27]!==Ne?(oe=c(g=>{Ne(g.currentTarget.checked)},"ne"),e[27]=Ne,e[28]=oe):oe=e[28];let Me=oe,de;e[29]!==Ce?(de=c(()=>{he(Ce())},"oe"),e[29]=Ce,e[30]=de):de=e[30];let Ae=de,le;e[31]!==we?(le=c(g=>{let{id:Q}=g.currentTarget.dataset;Q!==void 0&&he(we(Q))},"le"),e[31]=we,e[32]=le):le=e[32];let Te=le,ie;e[33]!==Ie?(ie=c(()=>{he(Ie())},"ie"),e[33]=Ie,e[34]=ie):ie=e[34];let De=ie,W;e[35]!==a||e[36]!==l?(W=(0,s.jsx)("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(g=>(0,s.jsx)(fe,{"aria-selected":l===g,"data-tab":g,"data-testid":`queues-tab-${g}`,onClick:dt,role:"tab",size:"sm",type:"button",variant:l===g?"secondary":"ghost",children:vt(g,a)},g))}),e[35]=a,e[36]=l,e[37]=W):W=e[37];let j;e[38]!==ve||e[39]!==Se?(j=ve!==null&&(0,s.jsx)(Ye,{error:Se,testId:"queues-error"}),e[38]=ve,e[39]=Se,e[40]=j):j=e[40];let F;e[41]!==A||e[42]!==D||e[43]!==R?(F=R&&(0,s.jsx)(Lt,{deadLetteredCount:A,queuesWithoutDlq:D}),e[41]=A,e[42]=D,e[43]=R,e[44]=F):F=e[44];let z;e[45]!==v||e[46]!==f||e[47]!==l?(z=l==="declared"&&(0,s.jsx)(St,{loaded:f!==void 0,queues:v}),e[45]=v,e[46]=f,e[47]=l,e[48]=z):z=e[48];let P;e[49]!==E||e[50]!==y||e[51]!==De||e[52]!==Te||e[53]!==qe||e[54]!==l?(P=l==="messages"&&(0,s.jsx)(wt,{hasError:y!==null,messages:E,onClear:De,onReplay:Te,replayingId:qe}),e[49]=E,e[50]=y,e[51]=De,e[52]=Te,e[53]=qe,e[54]=l,e[55]=P):P=e[55];let U;e[56]!==B||e[57]!==w||e[58]!==I||e[59]!==Me||e[60]!==Le||e[61]!==Ee||e[62]!==Qe||e[63]!==Ae||e[64]!==v||e[65]!==J||e[66]!==be||e[67]!==l?(U=l==="send"&&(0,s.jsx)(It,{batchMode:B,bodyText:w,delayText:I,onBatchModeChange:Me,onBodyChange:Le,onDelayChange:Ee,onSelectExport:Qe,onSend:Ae,queues:v,selectedExportName:J,sending:be}),e[56]=B,e[57]=w,e[58]=I,e[59]=Me,e[60]=Le,e[61]=Ee,e[62]=Qe,e[63]=Ae,e[64]=v,e[65]=J,e[66]=be,e[67]=l,e[68]=U):U=e[68];let ue;return e[69]!==W||e[70]!==j||e[71]!==F||e[72]!==z||e[73]!==P||e[74]!==U?(ue=(0,s.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-queues-panel",children:[W,j,F,z,P,U]}),e[69]=W,e[70]=j,e[71]=F,e[72]=z,e[73]=P,e[74]=U,e[75]=ue):ue=e[75],ue},"ts");function Et(n){return(0,s.jsx)(nt,{queue:n},n.exportName)}c(Et,"vt");function Mt(n){return(0,s.jsx)(nt,{queue:n},n.exportName)}c(Mt,"wt");function At(n){return(0,s.jsx)("option",{value:n.exportName,children:n.exportName},n.exportName)}c(At,"Qt");function Tt(n){return n.name}c(Tt,"At");function Dt(n,e){return n.exportName.localeCompare(e.exportName)}c(Dt,"It");function $t(n){return n.exportName}c($t,"Mt");function kt(n){return rt(n)}c(kt,"Lt");export{Zt as default};
@@ -1 +1 @@
1
- import{a as Ce,b as Re}from"./chunk-UZ2ZXB74.js";import"./chunk-5WNGRT7N.js";import"./chunk-JVP3TR3A.js";import{a as ye}from"./chunk-RE7GRXBM.js";import"./chunk-Y2YLTUMD.js";import"./chunk-BG2CJOVS.js";import{e as ke,g as we}from"./chunk-ZSWW2UGP.js";import"./chunk-QRA7AKYO.js";import"./chunk-4EPW63HS.js";import{a as X}from"./chunk-V3BE427M.js";import"./chunk-CKEQX655.js";import"./chunk-UD5REVU2.js";import{a as pe}from"./chunk-RCXNYW7P.js";import"./chunk-T3ZCW3RG.js";import{a as le}from"./chunk-LSEUUZN4.js";import"./chunk-7QEZ2SFW.js";import{a as be}from"./chunk-2W4UO5BC.js";import"./chunk-FBDIQ67D.js";import{a as ae,b as fe,c as xe,e as ne}from"./chunk-OK2QU2EV.js";import{m as ve}from"./chunk-FACXM2UB.js";import"./chunk-ZPQBVYNN.js";import{B as te,h as he,i as ue,j as ge,r as me,s as oe}from"./chunk-GNI37YCV.js";import"./chunk-PDBW6GTJ.js";import{a as Ke}from"./chunk-GWNGVKLG.js";import{a as Se,b as Me}from"./chunk-6G3E4PJ2.js";import{a as g,d as ie}from"./chunk-5PEAXTYQ.js";var Y=ie(Ke(),1),G=ie(Se(),1);var a=ie(Me(),1);var Le=he(be.runSql),qe=g((f,e)=>{let t=(0,Y.c)(11),n=ve(),[l,d]=(0,G.useState)(void 0),[s,i]=(0,G.useState)(void 0),[h,x]=(0,G.useState)(!0),m;t[0]!==n||t[1]!==e||t[2]!==f?(m=g(async u=>{x(!0);try{let C=await n.query(Le,{sql:f},ue(e));u.cancelled||(d(C),i(void 0))}catch(C){let k=C;u.cancelled||(d(void 0),i(ge(k)))}u.cancelled||x(!1)},"h"),t[0]=n,t[1]=e,t[2]=f,t[3]=m):m=t[3];let r=m,o,v;t[4]!==r?(o=g(()=>{let u={cancelled:!1};return oe(r(u)),()=>{u.cancelled=!0}},"l"),v=[r],t[4]=r,t[5]=o,t[6]=v):(o=t[5],v=t[6]),(0,G.useEffect)(o,v);let S;return t[7]!==s||t[8]!==h||t[9]!==l?(S={error:s,loading:h,result:l},t[7]=s,t[8]=h,t[9]=l,t[10]=S):S=t[10],S},"Le"),Ee=g(f=>{f.preventDefault()},"Me"),ce=g(f=>f.kind??"chart","le"),Ne=g(f=>{let e=(0,Y.c)(80),{actions:t,children:n,draggedRef:l,first:d,last:s,onEdit:i,onMove:h,onRemove:x,onReorder:m,widget:r}=f,o=te(),v;e[0]!==h||e[1]!==r.id?(v=g(()=>{h(r.id,-1)},"g"),e[0]=h,e[1]=r.id,e[2]=v):v=e[2];let S=v,u;e[3]!==h||e[4]!==r.id?(u=g(()=>{h(r.id,1)},"f"),e[3]=h,e[4]=r.id,e[5]=u):u=e[5];let C=u,k;e[6]!==i||e[7]!==r.id?(k=g(()=>{i(r.id)},"x"),e[6]=i,e[7]=r.id,e[8]=k):k=e[8];let E=k,O;e[9]!==x||e[10]!==r.id?(O=g(()=>{x(r.id)},"O"),e[9]=x,e[10]=r.id,e[11]=O):O=e[11];let j=O,T;e[12]!==l||e[13]!==r.id?(T=g(()=>{l.current=r.id},"z"),e[12]=l,e[13]=r.id,e[14]=T):T=e[14];let w=T,K;e[15]!==l||e[16]!==m||e[17]!==r.id?(K=g(()=>{let de=l.current;l.current=null,de!==null&&de!==r.id&&m(de,r.id)},"R"),e[15]=l,e[16]=m,e[17]=r.id,e[18]=K):K=e[18];let _=K,N=`dashboards-widget-${r.id}`,y;e[19]!==r.title?(y=(0,a.jsx)(xe,{className:"min-w-0 cursor-grab truncate",title:r.title,children:r.title}),e[19]=r.title,e[20]=y):y=e[20];let R;e[21]!==o?(R=o("Move widget up"),e[21]=o,e[22]=R):R=e[22];let F=`dashboards-move-up-${r.id}`,H;e[23]!==o?(H=o("Move widget up"),e[23]=o,e[24]=H):H=e[24];let D;e[25]===Symbol.for("react.memo_cache_sentinel")?(D=(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"m6 15 6-6 6 6"})}),e[25]=D):D=e[25];let W;e[26]!==d||e[27]!==S||e[28]!==F||e[29]!==H||e[30]!==R?(W=(0,a.jsx)(X,{"aria-label":R,"data-testid":F,disabled:d,onClick:S,size:"icon-xs",title:H,type:"button",variant:"ghost",children:D}),e[26]=d,e[27]=S,e[28]=F,e[29]=H,e[30]=R,e[31]=W):W=e[31];let M;e[32]!==o?(M=o("Move widget down"),e[32]=o,e[33]=M):M=e[33];let $=`dashboards-move-down-${r.id}`,L;e[34]!==o?(L=o("Move widget down"),e[34]=o,e[35]=L):L=e[35];let z;e[36]===Symbol.for("react.memo_cache_sentinel")?(z=(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"m6 9 6 6 6-6"})}),e[36]=z):z=e[36];let q;e[37]!==s||e[38]!==C||e[39]!==M||e[40]!==$||e[41]!==L?(q=(0,a.jsx)(X,{"aria-label":M,"data-testid":$,disabled:s,onClick:C,size:"icon-xs",title:L,type:"button",variant:"ghost",children:z}),e[37]=s,e[38]=C,e[39]=M,e[40]=$,e[41]=L,e[42]=q):q=e[42];let B;e[43]!==o?(B=o("Edit widget"),e[43]=o,e[44]=B):B=e[44];let I=`dashboards-widget-edit-${r.id}`,A;e[45]!==o?(A=o("Edit widget"),e[45]=o,e[46]=A):A=e[46];let p;e[47]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"})}),e[47]=p):p=e[47];let b;e[48]!==E||e[49]!==B||e[50]!==I||e[51]!==A?(b=(0,a.jsx)(X,{"aria-label":B,"data-testid":I,onClick:E,size:"icon-xs",title:A,type:"button",variant:"ghost",children:p}),e[48]=E,e[49]=B,e[50]=I,e[51]=A,e[52]=b):b=e[52];let c;e[53]!==o?(c=o("Remove widget"),e[53]=o,e[54]=c):c=e[54];let J=`dashboards-widget-remove-${r.id}`,V;e[55]!==o?(V=o("Remove widget"),e[55]=o,e[56]=V):V=e[56];let U;e[57]===Symbol.for("react.memo_cache_sentinel")?(U=(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[57]=U):U=e[57];let Q;e[58]!==j||e[59]!==c||e[60]!==J||e[61]!==V?(Q=(0,a.jsx)(X,{"aria-label":c,"data-testid":J,onClick:j,size:"icon-xs",title:V,type:"button",variant:"ghost",children:U}),e[58]=j,e[59]=c,e[60]=J,e[61]=V,e[62]=Q):Q=e[62];let Z;e[63]!==t||e[64]!==W||e[65]!==q||e[66]!==b||e[67]!==Q?(Z=(0,a.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[t,W,q,b,Q]}),e[63]=t,e[64]=W,e[65]=q,e[66]=b,e[67]=Q,e[68]=Z):Z=e[68];let P;e[69]!==Z||e[70]!==y?(P=(0,a.jsxs)(fe,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[y,Z]}),e[69]=Z,e[70]=y,e[71]=P):P=e[71];let ee;e[72]!==n?(ee=(0,a.jsx)(ne,{className:"min-h-32 py-2",children:n}),e[72]=n,e[73]=ee):ee=e[73];let re;return e[74]!==w||e[75]!==_||e[76]!==P||e[77]!==ee||e[78]!==N?(re=(0,a.jsxs)(ae,{"data-testid":N,draggable:!0,onDragOver:Ee,onDragStart:w,onDrop:_,children:[P,ee]}),e[74]=w,e[75]=_,e[76]=P,e[77]=ee,e[78]=N,e[79]=re):re=e[79],re},"ce"),je=g(f=>{let e=(0,Y.c)(10),{result:t}=f,n=te(),l=t.columns[0],d=l===void 0?void 0:t.rows[0]?.[l],s;e[0]!==d||e[1]!==n?(s=d===void 0?n("\u2014"):me(d),e[0]=d,e[1]=n,e[2]=s):s=e[2];let i;e[3]!==s?(i=(0,a.jsx)("p",{className:"truncate font-mono text-3xl font-semibold text-foreground",children:s}),e[3]=s,e[4]=i):i=e[4];let h;e[5]!==l?(h=l!==void 0&&(0,a.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:l}),e[5]=l,e[6]=h):h=e[6];let x;return e[7]!==i||e[8]!==h?(x=(0,a.jsxs)("div",{className:"flex h-full flex-col justify-center gap-1 p-4","data-testid":"dashboards-kpi",children:[i,h]}),e[7]=i,e[8]=h,e[9]=x):x=e[9],x},"Ee"),ze=g(f=>{let e=(0,Y.c)(12),{draggedRef:t,first:n,last:l,onEdit:d,onMove:s,onRemove:i,onReorder:h,widget:x}=f,m=x.text??"",r;e[0]!==m?(r=(0,a.jsx)("p",{className:"p-2 text-sm whitespace-pre-wrap text-muted-foreground","data-testid":"dashboards-text",children:m}),e[0]=m,e[1]=r):r=e[1];let o;return e[2]!==t||e[3]!==n||e[4]!==l||e[5]!==d||e[6]!==s||e[7]!==i||e[8]!==h||e[9]!==r||e[10]!==x?(o=(0,a.jsx)(Ne,{draggedRef:t,first:n,last:l,onEdit:d,onMove:s,onRemove:i,onReorder:h,widget:x,children:r}),e[2]=t,e[3]=n,e[4]=l,e[5]=d,e[6]=s,e[7]=i,e[8]=h,e[9]=r,e[10]=x,e[11]=o):o=e[11],o},"qe"),Ae=g(f=>{let e=(0,Y.c)(52),{draggedRef:t,first:n,inferring:l,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,onSuggest:m,widget:r}=f,o=te(),{error:v,loading:S,result:u}=qe(r.sql,r.shardKey??""),C;e[0]!==r?(C=ce(r),e[0]=r,e[1]=C):C=e[1];let k=C,E;e[2]!==m||e[3]!==u||e[4]!==r.id?(E=g(()=>{u!==void 0&&m?.(r.id,u)},"E"),e[2]=m,e[3]=u,e[4]=r.id,e[5]=E):E=e[5];let O=E,j;e[6]!==l||e[7]!==k||e[8]!==m||e[9]!==O||e[10]!==u||e[11]!==o||e[12]!==r.id?(j=k==="chart"&&m!==void 0&&u!==void 0?(0,a.jsx)(X,{"aria-label":o("Suggest chart"),"data-testid":`dashboards-widget-suggest-${r.id}`,disabled:l,onClick:O,size:"icon-xs",title:o(l?"Suggesting\u2026":"Suggest chart"),type:"button",variant:"ghost",children:(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"m12 3 1.9 4.6L18.5 9.5 13.9 11.4 12 16l-1.9-4.6L5.5 9.5l4.6-1.9L12 3ZM18 15l.9 2.1 2.1.9-2.1.9L18 21l-.9-2.1-2.1-.9 2.1-.9L18 15Z"})})}):void 0,e[6]=l,e[7]=k,e[8]=m,e[9]=O,e[10]=u,e[11]=o,e[12]=r.id,e[13]=j):j=e[13];let T=j,w;e[14]!==v||e[15]!==r.id?(w=v!==void 0&&(0,a.jsx)(le,{className:"font-mono text-xs",testId:`dashboards-widget-error-${r.id}`,variant:"destructive",children:v}),e[14]=v,e[15]=r.id,e[16]=w):w=e[16];let K;e[17]!==v||e[18]!==S||e[19]!==u||e[20]!==o||e[21]!==r.id?(K=v===void 0&&S&&u===void 0&&(0,a.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${r.id}`,children:o("Running\u2026")}),e[17]=v,e[18]=S,e[19]=u,e[20]=o,e[21]=r.id,e[22]=K):K=e[22];let _;e[23]!==v||e[24]!==k||e[25]!==u||e[26]!==r.chartAxes||e[27]!==r.chartKind?(_=v===void 0&&u!==void 0&&k==="chart"&&(0,a.jsx)(Ce,{axes:r.chartAxes,kind:r.chartKind,result:u}),e[23]=v,e[24]=k,e[25]=u,e[26]=r.chartAxes,e[27]=r.chartKind,e[28]=_):_=e[28];let N;e[29]!==v||e[30]!==k||e[31]!==u?(N=v===void 0&&u!==void 0&&k==="kpi"&&(0,a.jsx)(je,{result:u}),e[29]=v,e[30]=k,e[31]=u,e[32]=N):N=e[32];let y;e[33]!==v||e[34]!==k||e[35]!==u?(y=v===void 0&&u!==void 0&&k==="table"&&(0,a.jsx)("div",{className:"max-h-72 overflow-auto",children:(0,a.jsx)(Re,{result:u})}),e[33]=v,e[34]=k,e[35]=u,e[36]=y):y=e[36];let R;return e[37]!==t||e[38]!==n||e[39]!==d||e[40]!==s||e[41]!==i||e[42]!==h||e[43]!==x||e[44]!==T||e[45]!==w||e[46]!==K||e[47]!==_||e[48]!==N||e[49]!==y||e[50]!==r?(R=(0,a.jsxs)(Ne,{actions:T,draggedRef:t,first:n,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,widget:r,children:[w,K,_,N,y]}),e[37]=t,e[38]=n,e[39]=d,e[40]=s,e[41]=i,e[42]=h,e[43]=x,e[44]=T,e[45]=w,e[46]=K,e[47]=_,e[48]=N,e[49]=y,e[50]=r,e[51]=R):R=e[51],R},"Ae"),_e=g(f=>{let e=(0,Y.c)(11),{draggedRef:t,first:n,inferring:l,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,onSuggest:m,widget:r}=f,o;return e[0]!==t||e[1]!==n||e[2]!==l||e[3]!==d||e[4]!==s||e[5]!==i||e[6]!==h||e[7]!==x||e[8]!==m||e[9]!==r?(o=ce(r)==="text"?(0,a.jsx)(ze,{draggedRef:t,first:n,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,widget:r}):(0,a.jsx)(Ae,{draggedRef:t,first:n,inferring:l,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,onSuggest:m,widget:r}),e[0]=t,e[1]=n,e[2]=l,e[3]=d,e[4]=s,e[5]=i,e[6]=h,e[7]=x,e[8]=m,e[9]=r,e[10]=o):o=e[10],o},"Te"),We=["bar","line","area"],$e=["chart","kpi","table","text"],Be="lunora-studio-dashboards",se={chartKind:"bar",kind:"chart",shardKey:"",sql:"",text:"",title:""},Ie=g((f,e)=>t=>t.map(n=>n.id===f?{...n,chartAxes:e,chartKind:e.kind}:n),"De"),Te=g((f,e)=>t=>{let n=t.find(s=>s.id===f),l=t.filter(s=>s.id!==f),d=l.findIndex(s=>s.id===e);return n===void 0||d===-1?t:[...l.slice(0,d),n,...l.slice(d)]},"je"),De=g((f,e)=>e(f==="line"?"Line":f==="area"?"Area":"Bar"),"ze"),Oe=g((f,e)=>e(f==="kpi"?"Single value":f==="table"?"Table":f==="text"?"Text":"Chart"),"Be"),Fe=g(f=>{let e=(0,Y.c)(82),{draft:t,editing:n,onCancel:l,onChange:d,onSubmit:s}=f,i=te(),h;e[0]!==t||e[1]!==d?(h=g(c=>{d({...t,title:c.target.value})},"c"),e[0]=t,e[1]=d,e[2]=h):h=e[2];let x=h,m;e[3]!==t||e[4]!==d?(m=g(c=>{d({...t,sql:c.target.value})},"h"),e[3]=t,e[4]=d,e[5]=m):m=e[5];let r=m,o;e[6]!==t||e[7]!==d?(o=g(c=>{d({...t,text:c.target.value})},"l"),e[6]=t,e[7]=d,e[8]=o):o=e[8];let v=o,S;e[9]!==t||e[10]!==d?(S=g(c=>{d({...t,shardKey:c.target.value})},"N"),e[9]=t,e[10]=d,e[11]=S):S=e[11];let u=S,C;e[12]!==t||e[13]!==d?(C=g(c=>{d({...t,chartKind:c.target.value})},"y"),e[12]=t,e[13]=d,e[14]=C):C=e[14];let k=C,E;e[15]!==t||e[16]!==d?(E=g(c=>{d({...t,kind:c.target.value})},"E"),e[15]=t,e[16]=d,e[17]=E):E=e[17];let O=E,j;e[18]!==s?(j=g(()=>{s()},"q"),e[18]=s,e[19]=j):j=e[19];let T=j,w=t.kind==="text",K;e[20]!==t.sql||e[21]!==t.text||e[22]!==t.title||e[23]!==w?(K=t.title.trim()!==""&&(w?t.text.trim()!=="":t.sql.trim()!==""),e[20]=t.sql,e[21]=t.text,e[22]=t.title,e[23]=w,e[24]=K):K=e[24];let _=K,N;e[25]!==i?(N=i("Widget title"),e[25]=i,e[26]=N):N=e[26];let y;e[27]!==i?(y=i("Widget title"),e[27]=i,e[28]=y):y=e[28];let R;e[29]!==t.title||e[30]!==x||e[31]!==y||e[32]!==N?(R=(0,a.jsx)("input",{"aria-label":N,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:x,placeholder:y,type:"text",value:t.title}),e[29]=t.title,e[30]=x,e[31]=y,e[32]=N,e[33]=R):R=e[33];let F;e[34]!==i?(F=i("Widget type"),e[34]=i,e[35]=F):F=e[35];let H=t.kind,D;e[36]!==i?(D=$e.map(c=>(0,a.jsx)("option",{value:c,children:Oe(c,i)},c)),e[36]=i,e[37]=D):D=e[37];let W;e[38]!==t.kind||e[39]!==O||e[40]!==F||e[41]!==D?(W=(0,a.jsx)("select",{"aria-label":F,className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-widget-kind",onChange:O,value:H,children:D}),e[38]=t.kind,e[39]=O,e[40]=F,e[41]=D,e[42]=W):W=e[42];let M;e[43]!==t.sql||e[44]!==t.text||e[45]!==w||e[46]!==r||e[47]!==v||e[48]!==i?(M=w?(0,a.jsx)("textarea",{"aria-label":i("Text"),className:"min-h-24 resize-y rounded-md border border-border bg-background p-2 text-xs leading-5 outline-none focus-visible:border-ring","data-testid":"dashboards-form-text",onChange:v,placeholder:i("Notes for whoever reads this dashboard."),value:t.text}):(0,a.jsx)("textarea",{"aria-label":i("SQL query"),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:r,placeholder:"SELECT author, COUNT(*) AS messages FROM \u2026",spellCheck:!1,value:t.sql}),e[43]=t.sql,e[44]=t.text,e[45]=w,e[46]=r,e[47]=v,e[48]=i,e[49]=M):M=e[49];let $;e[50]!==t.chartKind||e[51]!==t.kind||e[52]!==k||e[53]!==i?($=t.kind==="chart"&&(0,a.jsx)("select",{"aria-label":i("Chart type"),className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-kind",onChange:k,value:t.chartKind,children:We.map(c=>(0,a.jsx)("option",{value:c,children:De(c,i)},c))}),e[50]=t.chartKind,e[51]=t.kind,e[52]=k,e[53]=i,e[54]=$):$=e[54];let L;e[55]!==t.shardKey||e[56]!==w||e[57]!==u||e[58]!==i?(L=!w&&(0,a.jsx)("input",{"aria-label":i("Shard key (optional)"),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:u,placeholder:i("Shard key (optional)"),type:"text",value:t.shardKey}),e[55]=t.shardKey,e[56]=w,e[57]=u,e[58]=i,e[59]=L):L=e[59];let z;e[60]!==i?(z=i("Cancel"),e[60]=i,e[61]=z):z=e[61];let q;e[62]!==l||e[63]!==z?(q=(0,a.jsx)(X,{"data-testid":"dashboards-form-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:z}),e[62]=l,e[63]=z,e[64]=q):q=e[64];let B=!_,I;e[65]!==n||e[66]!==i?(I=i(n?"Save widget":"Add widget"),e[65]=n,e[66]=i,e[67]=I):I=e[67];let A;e[68]!==T||e[69]!==B||e[70]!==I?(A=(0,a.jsx)(X,{"data-testid":"dashboards-form-save",disabled:B,onClick:T,size:"sm",type:"button",children:I}),e[68]=T,e[69]=B,e[70]=I,e[71]=A):A=e[71];let p;e[72]!==q||e[73]!==A?(p=(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[q,A]}),e[72]=q,e[73]=A,e[74]=p):p=e[74];let b;return e[75]!==R||e[76]!==W||e[77]!==M||e[78]!==$||e[79]!==L||e[80]!==p?(b=(0,a.jsx)(ae,{"data-testid":"dashboards-form",children:(0,a.jsxs)(ne,{className:"flex flex-col gap-3 py-4",children:[R,W,M,$,L,p]})}),e[75]=R,e[76]=W,e[77]=M,e[78]=$,e[79]=L,e[80]=p,e[81]=b):b=e[81],b},"Fe"),tt=g(f=>{let e=(0,Y.c)(53),{initialShardKey:t}=f,n=te(),[l,d]=ke(Be),[s,i]=(0,G.useState)(se),[h,x]=(0,G.useState)(null),[m,r]=(0,G.useState)(!1),o=ye(t??""),[v,S]=(0,G.useState)(null),u=(0,G.useRef)(null),C;e[0]!==t?(C=g(()=>{x(null),i({...se,shardKey:t??""}),r(!0)},"y"),e[0]=t,e[1]=C):C=e[1];let k=C,E;e[2]===Symbol.for("react.memo_cache_sentinel")?(E=g(()=>{r(!1),x(null),i(se)},"E"),e[2]=E):E=e[2];let O=E,j;e[3]!==l?(j=g(p=>{let b=l.find(c=>c.id===p);b!==void 0&&(x(p),i({chartKind:b.chartKind??"bar",kind:ce(b),shardKey:b.shardKey??"",sql:b.sql,text:b.text??"",title:b.title}),r(!0))},"q"),e[3]=l,e[4]=j):j=e[4];let T=j,w;e[5]!==o||e[6]!==d?(w=g((p,b)=>{S(p),oe((async()=>{let c=await o.inferChart({columns:b.columns,rowCount:b.rowCount});c!==void 0&&d(Ie(p,c))})().finally(()=>{S(c=>c===p?null:c)}))},"C"),e[5]=o,e[6]=d,e[7]=w):w=e[7];let K=w,_;e[8]!==d?(_=g(p=>{d(b=>b.filter(c=>c.id!==p))},"W"),e[8]=d,e[9]=_):_=e[9];let N=_,y;e[10]!==d?(y=g((p,b)=>{d(Te(p,b))},"k"),e[10]=d,e[11]=y):y=e[11];let R=y,F;e[12]!==d?(F=g((p,b)=>{d(c=>{let J=c.findIndex(P=>P.id===p),V=J+b;if(J===-1||V<0||V>=c.length)return c;let U=[...c],Q=U[J],Z=U[V];return Q===void 0||Z===void 0?c:(U[J]=Z,U[V]=Q,U)})},"_"),e[12]=d,e[13]=F):F=e[13];let H=F,D;e[14]!==s||e[15]!==h||e[16]!==d?(D=g(()=>{let p=s.title.trim(),b=s.sql.trim(),c=s.text.trim(),{chartKind:J,kind:V}=s;if(p===""||(V==="text"?c==="":b===""))return;let U={chartKind:J,kind:V,shardKey:s.shardKey.trim(),sql:b,text:c,title:p};d(h===null?Q=>[...Q,{...U,id:we("w")}]:Q=>Q.map(Z=>Z.id===h?{...Z,...U}:Z)),O()},"B"),e[14]=s,e[15]=h,e[16]=d,e[17]=D):D=e[17];let W=D,M;e[18]!==n?(M=n("Charts, values, tables, and notes. Drag a tile to reorder."),e[18]=n,e[19]=M):M=e[19];let $;e[20]!==M?($=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:M}),e[20]=M,e[21]=$):$=e[21];let L;e[22]!==m||e[23]!==k||e[24]!==n?(L=!m&&(0,a.jsx)(X,{"data-testid":"dashboards-add",onClick:k,size:"sm",type:"button",children:n("Add widget")}),e[22]=m,e[23]=k,e[24]=n,e[25]=L):L=e[25];let z;e[26]!==$||e[27]!==L?(z=(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[$,L]}),e[26]=$,e[27]=L,e[28]=z):z=e[28];let q;e[29]!==o||e[30]!==n?(q=o.reason("chart")!==void 0&&(0,a.jsx)(le,{className:"text-xs",testId:"dashboards-suggest-error",variant:"destructive",children:n("Could not suggest a chart for that result.")}),e[29]=o,e[30]=n,e[31]=q):q=e[31];let B;e[32]!==s||e[33]!==h||e[34]!==m||e[35]!==W?(B=m&&(0,a.jsx)(Fe,{draft:s,editing:h!==null,onCancel:O,onChange:i,onSubmit:W}),e[32]=s,e[33]=h,e[34]=m,e[35]=W,e[36]=B):B=e[36];let I;e[37]!==o.unavailable||e[38]!==m||e[39]!==v||e[40]!==T||e[41]!==H||e[42]!==N||e[43]!==R||e[44]!==K||e[45]!==n||e[46]!==l?(I=l.length===0&&!m?(0,a.jsx)(pe,{description:n("Add a chart, a single value, a table, or a note. Everything is saved on this browser."),testId:"dashboards-empty",title:n("No widgets yet")}):(0,a.jsx)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:l.map((p,b)=>(0,a.jsx)(_e,{draggedRef:u,first:b===0,inferring:v===p.id,last:b===l.length-1,onEdit:T,onMove:H,onRemove:N,onReorder:R,onSuggest:o.unavailable?void 0:K,widget:p},p.id))}),e[37]=o.unavailable,e[38]=m,e[39]=v,e[40]=T,e[41]=H,e[42]=N,e[43]=R,e[44]=K,e[45]=n,e[46]=l,e[47]=I):I=e[47];let A;return e[48]!==z||e[49]!==q||e[50]!==B||e[51]!==I?(A=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-dashboards",children:[z,q,B,I]}),e[48]=z,e[49]=q,e[50]=B,e[51]=I,e[52]=A):A=e[52],A},"it");export{tt as default};
1
+ import{a as Ce,b as Re}from"./chunk-UZ2ZXB74.js";import"./chunk-5WNGRT7N.js";import"./chunk-JVP3TR3A.js";import{a as ye}from"./chunk-YFTPHGS2.js";import"./chunk-Y2YLTUMD.js";import"./chunk-BG2CJOVS.js";import{e as ke,g as we}from"./chunk-ZSWW2UGP.js";import"./chunk-QRA7AKYO.js";import"./chunk-4EPW63HS.js";import{a as X}from"./chunk-V3BE427M.js";import"./chunk-CKEQX655.js";import"./chunk-UD5REVU2.js";import{a as pe}from"./chunk-RCXNYW7P.js";import"./chunk-T3ZCW3RG.js";import{a as le}from"./chunk-LSEUUZN4.js";import"./chunk-7QEZ2SFW.js";import{a as be}from"./chunk-2W4UO5BC.js";import"./chunk-4N76XUNG.js";import{a as ae,b as fe,c as xe,e as ne}from"./chunk-OK2QU2EV.js";import{m as ve}from"./chunk-SHHGIT7M.js";import"./chunk-ZPQBVYNN.js";import{B as te,h as he,i as ue,j as ge,r as me,s as oe}from"./chunk-GNI37YCV.js";import"./chunk-PDBW6GTJ.js";import{a as Ke}from"./chunk-GWNGVKLG.js";import{a as Se,b as Me}from"./chunk-6G3E4PJ2.js";import{a as g,d as ie}from"./chunk-5PEAXTYQ.js";var Y=ie(Ke(),1),G=ie(Se(),1);var a=ie(Me(),1);var Le=he(be.runSql),qe=g((f,e)=>{let t=(0,Y.c)(11),n=ve(),[l,d]=(0,G.useState)(void 0),[s,i]=(0,G.useState)(void 0),[h,x]=(0,G.useState)(!0),m;t[0]!==n||t[1]!==e||t[2]!==f?(m=g(async u=>{x(!0);try{let C=await n.query(Le,{sql:f},ue(e));u.cancelled||(d(C),i(void 0))}catch(C){let k=C;u.cancelled||(d(void 0),i(ge(k)))}u.cancelled||x(!1)},"h"),t[0]=n,t[1]=e,t[2]=f,t[3]=m):m=t[3];let r=m,o,v;t[4]!==r?(o=g(()=>{let u={cancelled:!1};return oe(r(u)),()=>{u.cancelled=!0}},"l"),v=[r],t[4]=r,t[5]=o,t[6]=v):(o=t[5],v=t[6]),(0,G.useEffect)(o,v);let S;return t[7]!==s||t[8]!==h||t[9]!==l?(S={error:s,loading:h,result:l},t[7]=s,t[8]=h,t[9]=l,t[10]=S):S=t[10],S},"Le"),Ee=g(f=>{f.preventDefault()},"Me"),ce=g(f=>f.kind??"chart","le"),Ne=g(f=>{let e=(0,Y.c)(80),{actions:t,children:n,draggedRef:l,first:d,last:s,onEdit:i,onMove:h,onRemove:x,onReorder:m,widget:r}=f,o=te(),v;e[0]!==h||e[1]!==r.id?(v=g(()=>{h(r.id,-1)},"g"),e[0]=h,e[1]=r.id,e[2]=v):v=e[2];let S=v,u;e[3]!==h||e[4]!==r.id?(u=g(()=>{h(r.id,1)},"f"),e[3]=h,e[4]=r.id,e[5]=u):u=e[5];let C=u,k;e[6]!==i||e[7]!==r.id?(k=g(()=>{i(r.id)},"x"),e[6]=i,e[7]=r.id,e[8]=k):k=e[8];let E=k,O;e[9]!==x||e[10]!==r.id?(O=g(()=>{x(r.id)},"O"),e[9]=x,e[10]=r.id,e[11]=O):O=e[11];let j=O,T;e[12]!==l||e[13]!==r.id?(T=g(()=>{l.current=r.id},"z"),e[12]=l,e[13]=r.id,e[14]=T):T=e[14];let w=T,K;e[15]!==l||e[16]!==m||e[17]!==r.id?(K=g(()=>{let de=l.current;l.current=null,de!==null&&de!==r.id&&m(de,r.id)},"R"),e[15]=l,e[16]=m,e[17]=r.id,e[18]=K):K=e[18];let _=K,N=`dashboards-widget-${r.id}`,y;e[19]!==r.title?(y=(0,a.jsx)(xe,{className:"min-w-0 cursor-grab truncate",title:r.title,children:r.title}),e[19]=r.title,e[20]=y):y=e[20];let R;e[21]!==o?(R=o("Move widget up"),e[21]=o,e[22]=R):R=e[22];let F=`dashboards-move-up-${r.id}`,H;e[23]!==o?(H=o("Move widget up"),e[23]=o,e[24]=H):H=e[24];let D;e[25]===Symbol.for("react.memo_cache_sentinel")?(D=(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"m6 15 6-6 6 6"})}),e[25]=D):D=e[25];let W;e[26]!==d||e[27]!==S||e[28]!==F||e[29]!==H||e[30]!==R?(W=(0,a.jsx)(X,{"aria-label":R,"data-testid":F,disabled:d,onClick:S,size:"icon-xs",title:H,type:"button",variant:"ghost",children:D}),e[26]=d,e[27]=S,e[28]=F,e[29]=H,e[30]=R,e[31]=W):W=e[31];let M;e[32]!==o?(M=o("Move widget down"),e[32]=o,e[33]=M):M=e[33];let $=`dashboards-move-down-${r.id}`,L;e[34]!==o?(L=o("Move widget down"),e[34]=o,e[35]=L):L=e[35];let z;e[36]===Symbol.for("react.memo_cache_sentinel")?(z=(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"m6 9 6 6 6-6"})}),e[36]=z):z=e[36];let q;e[37]!==s||e[38]!==C||e[39]!==M||e[40]!==$||e[41]!==L?(q=(0,a.jsx)(X,{"aria-label":M,"data-testid":$,disabled:s,onClick:C,size:"icon-xs",title:L,type:"button",variant:"ghost",children:z}),e[37]=s,e[38]=C,e[39]=M,e[40]=$,e[41]=L,e[42]=q):q=e[42];let B;e[43]!==o?(B=o("Edit widget"),e[43]=o,e[44]=B):B=e[44];let I=`dashboards-widget-edit-${r.id}`,A;e[45]!==o?(A=o("Edit widget"),e[45]=o,e[46]=A):A=e[46];let p;e[47]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"})}),e[47]=p):p=e[47];let b;e[48]!==E||e[49]!==B||e[50]!==I||e[51]!==A?(b=(0,a.jsx)(X,{"aria-label":B,"data-testid":I,onClick:E,size:"icon-xs",title:A,type:"button",variant:"ghost",children:p}),e[48]=E,e[49]=B,e[50]=I,e[51]=A,e[52]=b):b=e[52];let c;e[53]!==o?(c=o("Remove widget"),e[53]=o,e[54]=c):c=e[54];let J=`dashboards-widget-remove-${r.id}`,V;e[55]!==o?(V=o("Remove widget"),e[55]=o,e[56]=V):V=e[56];let U;e[57]===Symbol.for("react.memo_cache_sentinel")?(U=(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[57]=U):U=e[57];let Q;e[58]!==j||e[59]!==c||e[60]!==J||e[61]!==V?(Q=(0,a.jsx)(X,{"aria-label":c,"data-testid":J,onClick:j,size:"icon-xs",title:V,type:"button",variant:"ghost",children:U}),e[58]=j,e[59]=c,e[60]=J,e[61]=V,e[62]=Q):Q=e[62];let Z;e[63]!==t||e[64]!==W||e[65]!==q||e[66]!==b||e[67]!==Q?(Z=(0,a.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[t,W,q,b,Q]}),e[63]=t,e[64]=W,e[65]=q,e[66]=b,e[67]=Q,e[68]=Z):Z=e[68];let P;e[69]!==Z||e[70]!==y?(P=(0,a.jsxs)(fe,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[y,Z]}),e[69]=Z,e[70]=y,e[71]=P):P=e[71];let ee;e[72]!==n?(ee=(0,a.jsx)(ne,{className:"min-h-32 py-2",children:n}),e[72]=n,e[73]=ee):ee=e[73];let re;return e[74]!==w||e[75]!==_||e[76]!==P||e[77]!==ee||e[78]!==N?(re=(0,a.jsxs)(ae,{"data-testid":N,draggable:!0,onDragOver:Ee,onDragStart:w,onDrop:_,children:[P,ee]}),e[74]=w,e[75]=_,e[76]=P,e[77]=ee,e[78]=N,e[79]=re):re=e[79],re},"ce"),je=g(f=>{let e=(0,Y.c)(10),{result:t}=f,n=te(),l=t.columns[0],d=l===void 0?void 0:t.rows[0]?.[l],s;e[0]!==d||e[1]!==n?(s=d===void 0?n("\u2014"):me(d),e[0]=d,e[1]=n,e[2]=s):s=e[2];let i;e[3]!==s?(i=(0,a.jsx)("p",{className:"truncate font-mono text-3xl font-semibold text-foreground",children:s}),e[3]=s,e[4]=i):i=e[4];let h;e[5]!==l?(h=l!==void 0&&(0,a.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:l}),e[5]=l,e[6]=h):h=e[6];let x;return e[7]!==i||e[8]!==h?(x=(0,a.jsxs)("div",{className:"flex h-full flex-col justify-center gap-1 p-4","data-testid":"dashboards-kpi",children:[i,h]}),e[7]=i,e[8]=h,e[9]=x):x=e[9],x},"Ee"),ze=g(f=>{let e=(0,Y.c)(12),{draggedRef:t,first:n,last:l,onEdit:d,onMove:s,onRemove:i,onReorder:h,widget:x}=f,m=x.text??"",r;e[0]!==m?(r=(0,a.jsx)("p",{className:"p-2 text-sm whitespace-pre-wrap text-muted-foreground","data-testid":"dashboards-text",children:m}),e[0]=m,e[1]=r):r=e[1];let o;return e[2]!==t||e[3]!==n||e[4]!==l||e[5]!==d||e[6]!==s||e[7]!==i||e[8]!==h||e[9]!==r||e[10]!==x?(o=(0,a.jsx)(Ne,{draggedRef:t,first:n,last:l,onEdit:d,onMove:s,onRemove:i,onReorder:h,widget:x,children:r}),e[2]=t,e[3]=n,e[4]=l,e[5]=d,e[6]=s,e[7]=i,e[8]=h,e[9]=r,e[10]=x,e[11]=o):o=e[11],o},"qe"),Ae=g(f=>{let e=(0,Y.c)(52),{draggedRef:t,first:n,inferring:l,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,onSuggest:m,widget:r}=f,o=te(),{error:v,loading:S,result:u}=qe(r.sql,r.shardKey??""),C;e[0]!==r?(C=ce(r),e[0]=r,e[1]=C):C=e[1];let k=C,E;e[2]!==m||e[3]!==u||e[4]!==r.id?(E=g(()=>{u!==void 0&&m?.(r.id,u)},"E"),e[2]=m,e[3]=u,e[4]=r.id,e[5]=E):E=e[5];let O=E,j;e[6]!==l||e[7]!==k||e[8]!==m||e[9]!==O||e[10]!==u||e[11]!==o||e[12]!==r.id?(j=k==="chart"&&m!==void 0&&u!==void 0?(0,a.jsx)(X,{"aria-label":o("Suggest chart"),"data-testid":`dashboards-widget-suggest-${r.id}`,disabled:l,onClick:O,size:"icon-xs",title:o(l?"Suggesting\u2026":"Suggest chart"),type:"button",variant:"ghost",children:(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"m12 3 1.9 4.6L18.5 9.5 13.9 11.4 12 16l-1.9-4.6L5.5 9.5l4.6-1.9L12 3ZM18 15l.9 2.1 2.1.9-2.1.9L18 21l-.9-2.1-2.1-.9 2.1-.9L18 15Z"})})}):void 0,e[6]=l,e[7]=k,e[8]=m,e[9]=O,e[10]=u,e[11]=o,e[12]=r.id,e[13]=j):j=e[13];let T=j,w;e[14]!==v||e[15]!==r.id?(w=v!==void 0&&(0,a.jsx)(le,{className:"font-mono text-xs",testId:`dashboards-widget-error-${r.id}`,variant:"destructive",children:v}),e[14]=v,e[15]=r.id,e[16]=w):w=e[16];let K;e[17]!==v||e[18]!==S||e[19]!==u||e[20]!==o||e[21]!==r.id?(K=v===void 0&&S&&u===void 0&&(0,a.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${r.id}`,children:o("Running\u2026")}),e[17]=v,e[18]=S,e[19]=u,e[20]=o,e[21]=r.id,e[22]=K):K=e[22];let _;e[23]!==v||e[24]!==k||e[25]!==u||e[26]!==r.chartAxes||e[27]!==r.chartKind?(_=v===void 0&&u!==void 0&&k==="chart"&&(0,a.jsx)(Ce,{axes:r.chartAxes,kind:r.chartKind,result:u}),e[23]=v,e[24]=k,e[25]=u,e[26]=r.chartAxes,e[27]=r.chartKind,e[28]=_):_=e[28];let N;e[29]!==v||e[30]!==k||e[31]!==u?(N=v===void 0&&u!==void 0&&k==="kpi"&&(0,a.jsx)(je,{result:u}),e[29]=v,e[30]=k,e[31]=u,e[32]=N):N=e[32];let y;e[33]!==v||e[34]!==k||e[35]!==u?(y=v===void 0&&u!==void 0&&k==="table"&&(0,a.jsx)("div",{className:"max-h-72 overflow-auto",children:(0,a.jsx)(Re,{result:u})}),e[33]=v,e[34]=k,e[35]=u,e[36]=y):y=e[36];let R;return e[37]!==t||e[38]!==n||e[39]!==d||e[40]!==s||e[41]!==i||e[42]!==h||e[43]!==x||e[44]!==T||e[45]!==w||e[46]!==K||e[47]!==_||e[48]!==N||e[49]!==y||e[50]!==r?(R=(0,a.jsxs)(Ne,{actions:T,draggedRef:t,first:n,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,widget:r,children:[w,K,_,N,y]}),e[37]=t,e[38]=n,e[39]=d,e[40]=s,e[41]=i,e[42]=h,e[43]=x,e[44]=T,e[45]=w,e[46]=K,e[47]=_,e[48]=N,e[49]=y,e[50]=r,e[51]=R):R=e[51],R},"Ae"),_e=g(f=>{let e=(0,Y.c)(11),{draggedRef:t,first:n,inferring:l,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,onSuggest:m,widget:r}=f,o;return e[0]!==t||e[1]!==n||e[2]!==l||e[3]!==d||e[4]!==s||e[5]!==i||e[6]!==h||e[7]!==x||e[8]!==m||e[9]!==r?(o=ce(r)==="text"?(0,a.jsx)(ze,{draggedRef:t,first:n,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,widget:r}):(0,a.jsx)(Ae,{draggedRef:t,first:n,inferring:l,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,onSuggest:m,widget:r}),e[0]=t,e[1]=n,e[2]=l,e[3]=d,e[4]=s,e[5]=i,e[6]=h,e[7]=x,e[8]=m,e[9]=r,e[10]=o):o=e[10],o},"Te"),We=["bar","line","area"],$e=["chart","kpi","table","text"],Be="lunora-studio-dashboards",se={chartKind:"bar",kind:"chart",shardKey:"",sql:"",text:"",title:""},Ie=g((f,e)=>t=>t.map(n=>n.id===f?{...n,chartAxes:e,chartKind:e.kind}:n),"De"),Te=g((f,e)=>t=>{let n=t.find(s=>s.id===f),l=t.filter(s=>s.id!==f),d=l.findIndex(s=>s.id===e);return n===void 0||d===-1?t:[...l.slice(0,d),n,...l.slice(d)]},"je"),De=g((f,e)=>e(f==="line"?"Line":f==="area"?"Area":"Bar"),"ze"),Oe=g((f,e)=>e(f==="kpi"?"Single value":f==="table"?"Table":f==="text"?"Text":"Chart"),"Be"),Fe=g(f=>{let e=(0,Y.c)(82),{draft:t,editing:n,onCancel:l,onChange:d,onSubmit:s}=f,i=te(),h;e[0]!==t||e[1]!==d?(h=g(c=>{d({...t,title:c.target.value})},"c"),e[0]=t,e[1]=d,e[2]=h):h=e[2];let x=h,m;e[3]!==t||e[4]!==d?(m=g(c=>{d({...t,sql:c.target.value})},"h"),e[3]=t,e[4]=d,e[5]=m):m=e[5];let r=m,o;e[6]!==t||e[7]!==d?(o=g(c=>{d({...t,text:c.target.value})},"l"),e[6]=t,e[7]=d,e[8]=o):o=e[8];let v=o,S;e[9]!==t||e[10]!==d?(S=g(c=>{d({...t,shardKey:c.target.value})},"N"),e[9]=t,e[10]=d,e[11]=S):S=e[11];let u=S,C;e[12]!==t||e[13]!==d?(C=g(c=>{d({...t,chartKind:c.target.value})},"y"),e[12]=t,e[13]=d,e[14]=C):C=e[14];let k=C,E;e[15]!==t||e[16]!==d?(E=g(c=>{d({...t,kind:c.target.value})},"E"),e[15]=t,e[16]=d,e[17]=E):E=e[17];let O=E,j;e[18]!==s?(j=g(()=>{s()},"q"),e[18]=s,e[19]=j):j=e[19];let T=j,w=t.kind==="text",K;e[20]!==t.sql||e[21]!==t.text||e[22]!==t.title||e[23]!==w?(K=t.title.trim()!==""&&(w?t.text.trim()!=="":t.sql.trim()!==""),e[20]=t.sql,e[21]=t.text,e[22]=t.title,e[23]=w,e[24]=K):K=e[24];let _=K,N;e[25]!==i?(N=i("Widget title"),e[25]=i,e[26]=N):N=e[26];let y;e[27]!==i?(y=i("Widget title"),e[27]=i,e[28]=y):y=e[28];let R;e[29]!==t.title||e[30]!==x||e[31]!==y||e[32]!==N?(R=(0,a.jsx)("input",{"aria-label":N,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:x,placeholder:y,type:"text",value:t.title}),e[29]=t.title,e[30]=x,e[31]=y,e[32]=N,e[33]=R):R=e[33];let F;e[34]!==i?(F=i("Widget type"),e[34]=i,e[35]=F):F=e[35];let H=t.kind,D;e[36]!==i?(D=$e.map(c=>(0,a.jsx)("option",{value:c,children:Oe(c,i)},c)),e[36]=i,e[37]=D):D=e[37];let W;e[38]!==t.kind||e[39]!==O||e[40]!==F||e[41]!==D?(W=(0,a.jsx)("select",{"aria-label":F,className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-widget-kind",onChange:O,value:H,children:D}),e[38]=t.kind,e[39]=O,e[40]=F,e[41]=D,e[42]=W):W=e[42];let M;e[43]!==t.sql||e[44]!==t.text||e[45]!==w||e[46]!==r||e[47]!==v||e[48]!==i?(M=w?(0,a.jsx)("textarea",{"aria-label":i("Text"),className:"min-h-24 resize-y rounded-md border border-border bg-background p-2 text-xs leading-5 outline-none focus-visible:border-ring","data-testid":"dashboards-form-text",onChange:v,placeholder:i("Notes for whoever reads this dashboard."),value:t.text}):(0,a.jsx)("textarea",{"aria-label":i("SQL query"),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:r,placeholder:"SELECT author, COUNT(*) AS messages FROM \u2026",spellCheck:!1,value:t.sql}),e[43]=t.sql,e[44]=t.text,e[45]=w,e[46]=r,e[47]=v,e[48]=i,e[49]=M):M=e[49];let $;e[50]!==t.chartKind||e[51]!==t.kind||e[52]!==k||e[53]!==i?($=t.kind==="chart"&&(0,a.jsx)("select",{"aria-label":i("Chart type"),className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-kind",onChange:k,value:t.chartKind,children:We.map(c=>(0,a.jsx)("option",{value:c,children:De(c,i)},c))}),e[50]=t.chartKind,e[51]=t.kind,e[52]=k,e[53]=i,e[54]=$):$=e[54];let L;e[55]!==t.shardKey||e[56]!==w||e[57]!==u||e[58]!==i?(L=!w&&(0,a.jsx)("input",{"aria-label":i("Shard key (optional)"),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:u,placeholder:i("Shard key (optional)"),type:"text",value:t.shardKey}),e[55]=t.shardKey,e[56]=w,e[57]=u,e[58]=i,e[59]=L):L=e[59];let z;e[60]!==i?(z=i("Cancel"),e[60]=i,e[61]=z):z=e[61];let q;e[62]!==l||e[63]!==z?(q=(0,a.jsx)(X,{"data-testid":"dashboards-form-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:z}),e[62]=l,e[63]=z,e[64]=q):q=e[64];let B=!_,I;e[65]!==n||e[66]!==i?(I=i(n?"Save widget":"Add widget"),e[65]=n,e[66]=i,e[67]=I):I=e[67];let A;e[68]!==T||e[69]!==B||e[70]!==I?(A=(0,a.jsx)(X,{"data-testid":"dashboards-form-save",disabled:B,onClick:T,size:"sm",type:"button",children:I}),e[68]=T,e[69]=B,e[70]=I,e[71]=A):A=e[71];let p;e[72]!==q||e[73]!==A?(p=(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[q,A]}),e[72]=q,e[73]=A,e[74]=p):p=e[74];let b;return e[75]!==R||e[76]!==W||e[77]!==M||e[78]!==$||e[79]!==L||e[80]!==p?(b=(0,a.jsx)(ae,{"data-testid":"dashboards-form",children:(0,a.jsxs)(ne,{className:"flex flex-col gap-3 py-4",children:[R,W,M,$,L,p]})}),e[75]=R,e[76]=W,e[77]=M,e[78]=$,e[79]=L,e[80]=p,e[81]=b):b=e[81],b},"Fe"),tt=g(f=>{let e=(0,Y.c)(53),{initialShardKey:t}=f,n=te(),[l,d]=ke(Be),[s,i]=(0,G.useState)(se),[h,x]=(0,G.useState)(null),[m,r]=(0,G.useState)(!1),o=ye(t??""),[v,S]=(0,G.useState)(null),u=(0,G.useRef)(null),C;e[0]!==t?(C=g(()=>{x(null),i({...se,shardKey:t??""}),r(!0)},"y"),e[0]=t,e[1]=C):C=e[1];let k=C,E;e[2]===Symbol.for("react.memo_cache_sentinel")?(E=g(()=>{r(!1),x(null),i(se)},"E"),e[2]=E):E=e[2];let O=E,j;e[3]!==l?(j=g(p=>{let b=l.find(c=>c.id===p);b!==void 0&&(x(p),i({chartKind:b.chartKind??"bar",kind:ce(b),shardKey:b.shardKey??"",sql:b.sql,text:b.text??"",title:b.title}),r(!0))},"q"),e[3]=l,e[4]=j):j=e[4];let T=j,w;e[5]!==o||e[6]!==d?(w=g((p,b)=>{S(p),oe((async()=>{let c=await o.inferChart({columns:b.columns,rowCount:b.rowCount});c!==void 0&&d(Ie(p,c))})().finally(()=>{S(c=>c===p?null:c)}))},"C"),e[5]=o,e[6]=d,e[7]=w):w=e[7];let K=w,_;e[8]!==d?(_=g(p=>{d(b=>b.filter(c=>c.id!==p))},"W"),e[8]=d,e[9]=_):_=e[9];let N=_,y;e[10]!==d?(y=g((p,b)=>{d(Te(p,b))},"k"),e[10]=d,e[11]=y):y=e[11];let R=y,F;e[12]!==d?(F=g((p,b)=>{d(c=>{let J=c.findIndex(P=>P.id===p),V=J+b;if(J===-1||V<0||V>=c.length)return c;let U=[...c],Q=U[J],Z=U[V];return Q===void 0||Z===void 0?c:(U[J]=Z,U[V]=Q,U)})},"_"),e[12]=d,e[13]=F):F=e[13];let H=F,D;e[14]!==s||e[15]!==h||e[16]!==d?(D=g(()=>{let p=s.title.trim(),b=s.sql.trim(),c=s.text.trim(),{chartKind:J,kind:V}=s;if(p===""||(V==="text"?c==="":b===""))return;let U={chartKind:J,kind:V,shardKey:s.shardKey.trim(),sql:b,text:c,title:p};d(h===null?Q=>[...Q,{...U,id:we("w")}]:Q=>Q.map(Z=>Z.id===h?{...Z,...U}:Z)),O()},"B"),e[14]=s,e[15]=h,e[16]=d,e[17]=D):D=e[17];let W=D,M;e[18]!==n?(M=n("Charts, values, tables, and notes. Drag a tile to reorder."),e[18]=n,e[19]=M):M=e[19];let $;e[20]!==M?($=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:M}),e[20]=M,e[21]=$):$=e[21];let L;e[22]!==m||e[23]!==k||e[24]!==n?(L=!m&&(0,a.jsx)(X,{"data-testid":"dashboards-add",onClick:k,size:"sm",type:"button",children:n("Add widget")}),e[22]=m,e[23]=k,e[24]=n,e[25]=L):L=e[25];let z;e[26]!==$||e[27]!==L?(z=(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[$,L]}),e[26]=$,e[27]=L,e[28]=z):z=e[28];let q;e[29]!==o||e[30]!==n?(q=o.reason("chart")!==void 0&&(0,a.jsx)(le,{className:"text-xs",testId:"dashboards-suggest-error",variant:"destructive",children:n("Could not suggest a chart for that result.")}),e[29]=o,e[30]=n,e[31]=q):q=e[31];let B;e[32]!==s||e[33]!==h||e[34]!==m||e[35]!==W?(B=m&&(0,a.jsx)(Fe,{draft:s,editing:h!==null,onCancel:O,onChange:i,onSubmit:W}),e[32]=s,e[33]=h,e[34]=m,e[35]=W,e[36]=B):B=e[36];let I;e[37]!==o.unavailable||e[38]!==m||e[39]!==v||e[40]!==T||e[41]!==H||e[42]!==N||e[43]!==R||e[44]!==K||e[45]!==n||e[46]!==l?(I=l.length===0&&!m?(0,a.jsx)(pe,{description:n("Add a chart, a single value, a table, or a note. Everything is saved on this browser."),testId:"dashboards-empty",title:n("No widgets yet")}):(0,a.jsx)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:l.map((p,b)=>(0,a.jsx)(_e,{draggedRef:u,first:b===0,inferring:v===p.id,last:b===l.length-1,onEdit:T,onMove:H,onRemove:N,onReorder:R,onSuggest:o.unavailable?void 0:K,widget:p},p.id))}),e[37]=o.unavailable,e[38]=m,e[39]=v,e[40]=T,e[41]=H,e[42]=N,e[43]=R,e[44]=K,e[45]=n,e[46]=l,e[47]=I):I=e[47];let A;return e[48]!==z||e[49]!==q||e[50]!==B||e[51]!==I?(A=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-dashboards",children:[z,q,B,I]}),e[48]=z,e[49]=q,e[50]=B,e[51]=I,e[52]=A):A=e[52],A},"it");export{tt as default};
@@ -1 +1 @@
1
- import{i as D}from"./chunk-IHGRWY3Y.js";import"./chunk-OWRKSQPE.js";import"./chunk-4EPW63HS.js";import{a as B}from"./chunk-V3BE427M.js";import"./chunk-CKEQX655.js";import"./chunk-UD5REVU2.js";import{a as U}from"./chunk-RCXNYW7P.js";import{b as S}from"./chunk-UQA2AJGI.js";import"./chunk-T3ZCW3RG.js";import{a as q}from"./chunk-IUGNIG6L.js";import"./chunk-LSEUUZN4.js";import{a as G,b as J,c as K,d as F,e as s,f as o}from"./chunk-7QEZ2SFW.js";import"./chunk-WCWP4EAW.js";import"./chunk-BX7TFVCC.js";import"./chunk-4PI2OSSP.js";import{a as V}from"./chunk-2W4UO5BC.js";import{c as R}from"./chunk-FBDIQ67D.js";import{a as H,e as O}from"./chunk-OK2QU2EV.js";import"./chunk-FACXM2UB.js";import"./chunk-ZPQBVYNN.js";import{B as W,w as P}from"./chunk-GNI37YCV.js";import"./chunk-PDBW6GTJ.js";import{a as ae}from"./chunk-GWNGVKLG.js";import{a as re,b as ie}from"./chunk-6G3E4PJ2.js";import{a as n,d as j}from"./chunk-5PEAXTYQ.js";var X=j(ae(),1),M=j(re(),1);var t=j(ie(),1);var ne=n(e=>e==="ok"?"success":e==="failed"?"destructive":e==="expired"?"warning":"secondary","te"),Q=n(e=>e.endpoint??e.id,"M"),ve=n(()=>{let e=(0,X.c)(38),r=W(),[i,Y]=(0,M.useState)("all"),[l,Z]=(0,M.useState)(""),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={},e[0]=g):g=e[0];let{data:I,error:d,errorSource:x,isLoading:_,refetch:v}=R(V.listPushSubscriptions,g),N;if(e[1]!==I?.subscriptions||e[2]!==d||e[3]!==x||e[4]!==_||e[5]!==i||e[6]!==v||e[7]!==l||e[8]!==r){let L=I?.subscriptions??[],T=l.trim().toLowerCase(),A=L.filter(a=>i!=="all"&&a.kind!==i?!1:T===""?!0:`${Q(a)} ${a.userId??""}`.toLowerCase().includes(T)),b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=n(a=>{Z(a.target.value)},"w"),e[10]=b):b=e[10];let ee=b,w;e[11]!==v?(w=n(()=>{v()},"y"),e[11]=v,e[12]=w):w=e[12];let E=w,k;e[13]===Symbol.for("react.memo_cache_sentinel")?(k=["all","web-push","fcm"],e[13]=k):k=e[13];let te=k,c;e[14]!==i||e[15]!==r?(c=(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"nt-kind-filter",role:"tablist",children:te.map(a=>(0,t.jsx)(B,{"aria-selected":i===a,"data-testid":`nt-kind-${a}`,onClick:n(()=>{Y(a)},"onClick"),role:"tab",size:"sm",type:"button",variant:i===a?"secondary":"ghost",children:a==="all"?r("All"):a},a))}),e[14]=i,e[15]=r,e[16]=c):c=e[16];let m;e[17]!==r?(m=r("Filter devices"),e[17]=r,e[18]=m):m=e[18];let h;e[19]!==r?(h=r("filter endpoint, user"),e[19]=r,e[20]=h):h=e[20];let u;e[21]!==l||e[22]!==m||e[23]!==h?(u=(0,t.jsx)(D,{"aria-label":m,className:"h-8 w-56","data-testid":"nt-search",onChange:ee,placeholder:h,value:l}),e[21]=l,e[22]=m,e[23]=h,e[24]=u):u=e[24];let f;e[25]!==r?(f=r("Refresh"),e[25]=r,e[26]=f):f=e[26];let p;e[27]!==E||e[28]!==f?(p=(0,t.jsx)(B,{className:"ml-auto","data-testid":"nt-refresh",onClick:E,size:"sm",type:"button",variant:"outline",children:f}),e[27]=E,e[28]=f,e[29]=p):p=e[29];let $=L.length>0&&(0,t.jsx)(S,{"data-testid":"nt-count",variant:"secondary",children:r("{count} devices",{count:L.length})}),y;e[30]!==p||e[31]!==$||e[32]!==c||e[33]!==u?(y=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,u,p,$]}),e[30]=p,e[31]=$,e[32]=c,e[33]=u,e[34]=y):y=e[34];let C;e[35]!==d||e[36]!==x?(C=d!==null&&(0,t.jsx)(q,{error:x,testId:"nt-error"}),e[35]=d,e[36]=x,e[37]=C):C=e[37],N=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-notifications",children:[y,C,d===null&&!_&&A.length===0&&(0,t.jsx)(U,{description:r("Registered Web Push / FCM devices appear here. Configure lunora/notify.ts with defineNotify({ store }) and register a device with ctx.push.register(...)."),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:"M15 17h5l-1.4-1.4A2 2 0 0 1 18 14.2V11a6 6 0 0 0-4-5.7V5a2 2 0 1 0-4 0v.3A6 6 0 0 0 6 11v3.2a2 2 0 0 1-.6 1.4L4 17h5m6 0v1a3 3 0 1 1-6 0v-1m6 0H9"})}),testId:"nt-empty",title:r("No registered devices.")}),A.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(O,{className:"max-h-[30rem] overflow-auto px-0",children:(0,t.jsxs)(G,{"data-testid":"nt-table",children:[(0,t.jsx)(J,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(s,{children:r("kind")}),(0,t.jsx)(s,{children:r("endpoint")}),(0,t.jsx)(s,{children:r("user")}),(0,t.jsx)(s,{children:r("last seen")}),(0,t.jsx)(s,{children:r("status")}),(0,t.jsx)(s,{children:r("error")})]})}),(0,t.jsx)(K,{children:A.map(a=>{let z=Q(a);return(0,t.jsxs)(F,{"data-testid":"nt-row",children:[(0,t.jsx)(o,{children:(0,t.jsx)(S,{variant:"outline",children:a.kind})}),(0,t.jsx)(o,{className:"max-w-[28ch] truncate font-mono text-xs",title:z,children:z}),(0,t.jsx)(o,{className:"max-w-[16ch] truncate font-mono text-xs",children:a.userId??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,t.jsx)(o,{className:"text-muted-foreground tabular-nums",children:P(a.lastSeenAt,"\u2014")}),(0,t.jsx)(o,{children:(0,t.jsx)(S,{"data-testid":`nt-status-${a.id}`,variant:ne(a.lastStatus),children:a.lastStatus??r("n/a")})}),(0,t.jsx)(o,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",title:a.lastError??void 0,children:a.lastError??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},a.id)})})]})})})]}),e[1]=I?.subscriptions,e[2]=d,e[3]=x,e[4]=_,e[5]=i,e[6]=v,e[7]=l,e[8]=r,e[9]=N}else N=e[9];return N},"ge");export{ve as default};
1
+ import{i as D}from"./chunk-IHGRWY3Y.js";import"./chunk-OWRKSQPE.js";import"./chunk-4EPW63HS.js";import{a as B}from"./chunk-V3BE427M.js";import"./chunk-CKEQX655.js";import"./chunk-UD5REVU2.js";import{a as U}from"./chunk-RCXNYW7P.js";import{b as S}from"./chunk-UQA2AJGI.js";import"./chunk-T3ZCW3RG.js";import{a as q}from"./chunk-YEXTJUKQ.js";import"./chunk-LSEUUZN4.js";import{a as G,b as J,c as K,d as F,e as s,f as o}from"./chunk-7QEZ2SFW.js";import"./chunk-OZAOWE7T.js";import"./chunk-BBDTJG2K.js";import"./chunk-4PI2OSSP.js";import{a as V}from"./chunk-2W4UO5BC.js";import{c as R}from"./chunk-4N76XUNG.js";import{a as H,e as O}from"./chunk-OK2QU2EV.js";import"./chunk-SHHGIT7M.js";import"./chunk-ZPQBVYNN.js";import{B as W,w as P}from"./chunk-GNI37YCV.js";import"./chunk-PDBW6GTJ.js";import{a as ae}from"./chunk-GWNGVKLG.js";import{a as re,b as ie}from"./chunk-6G3E4PJ2.js";import{a as n,d as j}from"./chunk-5PEAXTYQ.js";var X=j(ae(),1),M=j(re(),1);var t=j(ie(),1);var ne=n(e=>e==="ok"?"success":e==="failed"?"destructive":e==="expired"?"warning":"secondary","te"),Q=n(e=>e.endpoint??e.id,"M"),ve=n(()=>{let e=(0,X.c)(38),r=W(),[i,Y]=(0,M.useState)("all"),[l,Z]=(0,M.useState)(""),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={},e[0]=g):g=e[0];let{data:I,error:d,errorSource:x,isLoading:_,refetch:v}=R(V.listPushSubscriptions,g),N;if(e[1]!==I?.subscriptions||e[2]!==d||e[3]!==x||e[4]!==_||e[5]!==i||e[6]!==v||e[7]!==l||e[8]!==r){let L=I?.subscriptions??[],T=l.trim().toLowerCase(),A=L.filter(a=>i!=="all"&&a.kind!==i?!1:T===""?!0:`${Q(a)} ${a.userId??""}`.toLowerCase().includes(T)),b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=n(a=>{Z(a.target.value)},"w"),e[10]=b):b=e[10];let ee=b,w;e[11]!==v?(w=n(()=>{v()},"y"),e[11]=v,e[12]=w):w=e[12];let E=w,k;e[13]===Symbol.for("react.memo_cache_sentinel")?(k=["all","web-push","fcm"],e[13]=k):k=e[13];let te=k,c;e[14]!==i||e[15]!==r?(c=(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"nt-kind-filter",role:"tablist",children:te.map(a=>(0,t.jsx)(B,{"aria-selected":i===a,"data-testid":`nt-kind-${a}`,onClick:n(()=>{Y(a)},"onClick"),role:"tab",size:"sm",type:"button",variant:i===a?"secondary":"ghost",children:a==="all"?r("All"):a},a))}),e[14]=i,e[15]=r,e[16]=c):c=e[16];let m;e[17]!==r?(m=r("Filter devices"),e[17]=r,e[18]=m):m=e[18];let h;e[19]!==r?(h=r("filter endpoint, user"),e[19]=r,e[20]=h):h=e[20];let u;e[21]!==l||e[22]!==m||e[23]!==h?(u=(0,t.jsx)(D,{"aria-label":m,className:"h-8 w-56","data-testid":"nt-search",onChange:ee,placeholder:h,value:l}),e[21]=l,e[22]=m,e[23]=h,e[24]=u):u=e[24];let f;e[25]!==r?(f=r("Refresh"),e[25]=r,e[26]=f):f=e[26];let p;e[27]!==E||e[28]!==f?(p=(0,t.jsx)(B,{className:"ml-auto","data-testid":"nt-refresh",onClick:E,size:"sm",type:"button",variant:"outline",children:f}),e[27]=E,e[28]=f,e[29]=p):p=e[29];let $=L.length>0&&(0,t.jsx)(S,{"data-testid":"nt-count",variant:"secondary",children:r("{count} devices",{count:L.length})}),y;e[30]!==p||e[31]!==$||e[32]!==c||e[33]!==u?(y=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,u,p,$]}),e[30]=p,e[31]=$,e[32]=c,e[33]=u,e[34]=y):y=e[34];let C;e[35]!==d||e[36]!==x?(C=d!==null&&(0,t.jsx)(q,{error:x,testId:"nt-error"}),e[35]=d,e[36]=x,e[37]=C):C=e[37],N=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-notifications",children:[y,C,d===null&&!_&&A.length===0&&(0,t.jsx)(U,{description:r("Registered Web Push / FCM devices appear here. Configure lunora/notify.ts with defineNotify({ store }) and register a device with ctx.push.register(...)."),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:"M15 17h5l-1.4-1.4A2 2 0 0 1 18 14.2V11a6 6 0 0 0-4-5.7V5a2 2 0 1 0-4 0v.3A6 6 0 0 0 6 11v3.2a2 2 0 0 1-.6 1.4L4 17h5m6 0v1a3 3 0 1 1-6 0v-1m6 0H9"})}),testId:"nt-empty",title:r("No registered devices.")}),A.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(O,{className:"max-h-[30rem] overflow-auto px-0",children:(0,t.jsxs)(G,{"data-testid":"nt-table",children:[(0,t.jsx)(J,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(s,{children:r("kind")}),(0,t.jsx)(s,{children:r("endpoint")}),(0,t.jsx)(s,{children:r("user")}),(0,t.jsx)(s,{children:r("last seen")}),(0,t.jsx)(s,{children:r("status")}),(0,t.jsx)(s,{children:r("error")})]})}),(0,t.jsx)(K,{children:A.map(a=>{let z=Q(a);return(0,t.jsxs)(F,{"data-testid":"nt-row",children:[(0,t.jsx)(o,{children:(0,t.jsx)(S,{variant:"outline",children:a.kind})}),(0,t.jsx)(o,{className:"max-w-[28ch] truncate font-mono text-xs",title:z,children:z}),(0,t.jsx)(o,{className:"max-w-[16ch] truncate font-mono text-xs",children:a.userId??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,t.jsx)(o,{className:"text-muted-foreground tabular-nums",children:P(a.lastSeenAt,"\u2014")}),(0,t.jsx)(o,{children:(0,t.jsx)(S,{"data-testid":`nt-status-${a.id}`,variant:ne(a.lastStatus),children:a.lastStatus??r("n/a")})}),(0,t.jsx)(o,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",title:a.lastError??void 0,children:a.lastError??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},a.id)})})]})})})]}),e[1]=I?.subscriptions,e[2]=d,e[3]=x,e[4]=_,e[5]=i,e[6]=v,e[7]=l,e[8]=r,e[9]=N}else N=e[9];return N},"ge");export{ve as default};