@lunora/studio 1.0.0-alpha.383 → 1.0.0-alpha.385

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 (77) hide show
  1. package/dist/index.d.mts +1 -1
  2. package/dist/index.d.ts +1 -1
  3. package/dist/packem_chunks/AdvisorHealthPanel.mjs +1 -1
  4. package/dist/packem_chunks/InsightsPanel.mjs +1 -1
  5. package/dist/packem_chunks/SecurityAdvisorPanel.mjs +1 -1
  6. package/dist/packem_shared/advisor-view-C6C3kmZj.mjs +5 -0
  7. package/dist/standalone/{chunk-D3MLU3PX.js → chunk-2G5OZPH5.js} +1 -1
  8. package/dist/standalone/{chunk-JPBTM43K.js → chunk-2HJOQZQ5.js} +1 -1
  9. package/dist/standalone/{chunk-I33WWIBV.js → chunk-3MU55LYE.js} +1 -1
  10. package/dist/standalone/{chunk-APYV4J3H.js → chunk-3O5KRHWI.js} +1 -1
  11. package/dist/standalone/{chunk-IPRJMLLL.js → chunk-42U2JUGB.js} +1 -1
  12. package/dist/standalone/{chunk-PUQ3LURH.js → chunk-4JR7B43V.js} +1 -1
  13. package/dist/standalone/{chunk-YNYH4P7E.js → chunk-4VF4BIOZ.js} +1 -1
  14. package/dist/standalone/{chunk-EU3IVSBQ.js → chunk-6U3PB43O.js} +1 -1
  15. package/dist/standalone/{chunk-7O6F7GJ2.js → chunk-6WNYDTK5.js} +1 -1
  16. package/dist/standalone/{chunk-Q6MWEK4M.js → chunk-7MPWIS3R.js} +1 -1
  17. package/dist/standalone/{chunk-7OMB6F3L.js → chunk-7QZQZYJT.js} +1 -1
  18. package/dist/standalone/{chunk-NIIWN6ZY.js → chunk-7THIXUEZ.js} +1 -1
  19. package/dist/standalone/{chunk-BCD7WQYW.js → chunk-B2EUIUL5.js} +1 -1
  20. package/dist/standalone/{chunk-SFZ6IAL2.js → chunk-BZ6CJVEW.js} +1 -1
  21. package/dist/standalone/{chunk-BIEYPLQZ.js → chunk-C56YDP56.js} +1 -1
  22. package/dist/standalone/{chunk-XUSA5BXI.js → chunk-CSDAZN5R.js} +1 -1
  23. package/dist/standalone/{chunk-FKY2ID3J.js → chunk-DVTU6UE5.js} +1 -1
  24. package/dist/standalone/{chunk-FYSSF7AJ.js → chunk-DZZ3N75F.js} +1 -1
  25. package/dist/standalone/{chunk-E52THCJJ.js → chunk-E6KWXZCK.js} +1 -1
  26. package/dist/standalone/chunk-EBKEYF3N.js +1 -0
  27. package/dist/standalone/{chunk-WSJTPPUQ.js → chunk-EFTLHOFA.js} +1 -1
  28. package/dist/standalone/{chunk-DKTTK2SX.js → chunk-EZ2K57JT.js} +1 -1
  29. package/dist/standalone/{chunk-5IOQXXYH.js → chunk-FFJ75IBP.js} +1 -1
  30. package/dist/standalone/{chunk-CNALVIPZ.js → chunk-FQRAKX6V.js} +1 -1
  31. package/dist/standalone/{chunk-WKRUXQXB.js → chunk-FUPX23QR.js} +1 -1
  32. package/dist/standalone/{chunk-HI3U4W6T.js → chunk-FZ6557GN.js} +1 -1
  33. package/dist/standalone/chunk-GRM43CFE.js +1 -0
  34. package/dist/standalone/{chunk-ABY6J4SX.js → chunk-GX2UAEGW.js} +1 -1
  35. package/dist/standalone/{chunk-ZO6OZV4D.js → chunk-H2ZCM66S.js} +1 -1
  36. package/dist/standalone/{chunk-PXDQGWZR.js → chunk-HJ7QDXCT.js} +1 -1
  37. package/dist/standalone/{chunk-J5SYXVIK.js → chunk-I37NPLQI.js} +1 -1
  38. package/dist/standalone/{chunk-YDDMKWPI.js → chunk-IR2MDKXQ.js} +1 -1
  39. package/dist/standalone/{chunk-N2XUTYZJ.js → chunk-ISTQIPTN.js} +1 -1
  40. package/dist/standalone/{chunk-TQH2BN2P.js → chunk-IUUXVNAP.js} +1 -1
  41. package/dist/standalone/{chunk-UN3QTZ6X.js → chunk-KE7ZGUGO.js} +1 -1
  42. package/dist/standalone/{chunk-HPTF52JF.js → chunk-KSATOQ6G.js} +1 -1
  43. package/dist/standalone/{chunk-PQB2QX4Q.js → chunk-L34AGC7Z.js} +1 -1
  44. package/dist/standalone/{chunk-Q4SE33KY.js → chunk-LL7JKFBU.js} +1 -1
  45. package/dist/standalone/chunk-LLD7TMBV.js +1 -0
  46. package/dist/standalone/{chunk-G7GMOSDG.js → chunk-LLSKRNQ5.js} +1 -1
  47. package/dist/standalone/{chunk-WDQDRE4G.js → chunk-LQJQDJNH.js} +1 -1
  48. package/dist/standalone/{chunk-OVMZ7DXR.js → chunk-LVU6W6MM.js} +1 -1
  49. package/dist/standalone/{chunk-7YHT6DLF.js → chunk-MBCU5GIY.js} +1 -1
  50. package/dist/standalone/{chunk-WEZRVKSV.js → chunk-MCDKIVLH.js} +1 -1
  51. package/dist/standalone/{chunk-2IYIVCPN.js → chunk-MIDNWFNN.js} +1 -1
  52. package/dist/standalone/{chunk-SI5L5HDG.js → chunk-MMLEHOX7.js} +1 -1
  53. package/dist/standalone/chunk-NAQILWRM.js +1 -0
  54. package/dist/standalone/{chunk-7JIVSWQM.js → chunk-O2HPBDEC.js} +1 -1
  55. package/dist/standalone/{chunk-6NZOJI3N.js → chunk-O4BQMWIN.js} +1 -1
  56. package/dist/standalone/{chunk-5CHKXJYN.js → chunk-PSBRO6JX.js} +1 -1
  57. package/dist/standalone/chunk-R3E7HYHA.js +5 -0
  58. package/dist/standalone/{chunk-V3A3775O.js → chunk-R6ZR7FZZ.js} +1 -1
  59. package/dist/standalone/chunk-UK5OOCLQ.js +7 -0
  60. package/dist/standalone/{chunk-UHF224OV.js → chunk-V6JMOE7W.js} +1 -1
  61. package/dist/standalone/{chunk-IW5TW36H.js → chunk-V7W37FDL.js} +1 -1
  62. package/dist/standalone/{chunk-PAGLAE5H.js → chunk-VLAEMGPY.js} +1 -1
  63. package/dist/standalone/{chunk-7HIZZYHW.js → chunk-WSYQMHC4.js} +1 -1
  64. package/dist/standalone/{chunk-C6NIFA7C.js → chunk-WXV3KCFJ.js} +1 -1
  65. package/dist/standalone/{chunk-6OIS24US.js → chunk-XD5CKMBE.js} +1 -1
  66. package/dist/standalone/{chunk-SBJ4LWXW.js → chunk-XWEMSCUN.js} +1 -1
  67. package/dist/standalone/{chunk-GB7MHA6L.js → chunk-YGSVIF7L.js} +1 -1
  68. package/dist/standalone/{chunk-IEOOQ2NW.js → chunk-ZYQQJ5FK.js} +1 -1
  69. package/dist/standalone/studio.js +1 -1
  70. package/package.json +3 -3
  71. package/dist/packem_shared/advisor-view-y9c2z5w1.mjs +0 -5
  72. package/dist/standalone/chunk-5KQSRLQP.js +0 -7
  73. package/dist/standalone/chunk-7VZFX5O4.js +0 -1
  74. package/dist/standalone/chunk-LFVPR2JB.js +0 -5
  75. package/dist/standalone/chunk-MT3K66QU.js +0 -1
  76. package/dist/standalone/chunk-OEHBCBV4.js +0 -1
  77. package/dist/standalone/chunk-VKX7HSAS.js +0 -1
@@ -0,0 +1 @@
1
+ import{a as ee}from"./chunk-2KTN53PK.js";import{a as Z}from"./chunk-PAFHBQFL.js";import{b as Y}from"./chunk-EDL46BPM.js";import{a as X}from"./chunk-DA2CAFXI.js";import{a as W}from"./chunk-DWNWEMQK.js";import"./chunk-4KPATTV6.js";import{i as D}from"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import"./chunk-OKZINWBB.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{b as ae,c as ne}from"./chunk-LLD7TMBV.js";import{a as j,b as te}from"./chunk-R3E7HYHA.js";import{a as V}from"./chunk-NVMQPIRS.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import"./chunk-UV6GPH2E.js";import"./chunk-L27FKJTG.js";import"./chunk-2G5OZPH5.js";import"./chunk-S7NFUY75.js";import"./chunk-J3ZEO3PJ.js";import"./chunk-IR2MDKXQ.js";import"./chunk-PSBRO6JX.js";import"./chunk-EOFWXI3T.js";import{a as I}from"./chunk-LYVYUTQY.js";import{c as A}from"./chunk-KE7ZGUGO.js";import"./chunk-TN4Z3P6S.js";import{n as Q}from"./chunk-UK5OOCLQ.js";import"./chunk-ZPQBVYNN.js";import{B as q,h as M,i as C,o as G,s as N}from"./chunk-PN7JHEYW.js";import"./chunk-PDBW6GTJ.js";import{a as me}from"./chunk-A6TVTNKO.js";import{a as he,b as pe}from"./chunk-ADABTCDI.js";import{a as l,d as _}from"./chunk-5PEAXTYQ.js";var E=_(me(),1);var c=_(he(),1);var S=_(pe(),1);var ge=l(t=>{let{suggestedIndex:e,table:n}=t;if(typeof n!="string"||n.length===0||typeof e!="object"||e===null)return!1;let{fields:a,name:r}=e;return!Array.isArray(a)||a.length===0||a.some(i=>typeof i!="string"||i.length===0)?!1:typeof r=="string"&&r.length>0},"xe"),be=l((t,e)=>`.index(${JSON.stringify(t)}, [${e.map(n=>JSON.stringify(n)).join(", ")}])`,"ge"),xe=l(t=>{let e=(0,E.c)(19),{fields:n,indexName:a,table:r,testId:i}=t,u=q(),[h,f]=(0,c.useState)(null),m;e[0]!==n||e[1]!==a?(m=l(()=>{let b=be(a,n),$="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if($===void 0){f({copied:!1,declaration:b});return}N($.writeText(b).then(()=>(f({copied:!0,declaration:b}),!0)),()=>{f({copied:!1,declaration:b})})},"m"),e[0]=n,e[1]=a,e[2]=m):m=e[2];let y=m;if(h!==null){let b;return e[3]!==h.copied||e[4]!==h.declaration||e[5]!==u||e[6]!==r||e[7]!==i?(b=h.copied?(0,S.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`${i}-applied`,children:u("Index declaration copied \u2014 add it to {table} in lunora/schema.ts.",{table:r})}):(0,S.jsxs)("span",{className:"flex flex-col gap-1 text-xs text-muted-foreground","data-testid":`${i}-manual`,children:[u("Could not reach the clipboard \u2014 add this to {table} in lunora/schema.ts:",{table:r}),(0,S.jsx)("code",{className:"font-mono break-all select-all",children:h.declaration})]}),e[3]=h.copied,e[4]=h.declaration,e[5]=u,e[6]=r,e[7]=i,e[8]=b):b=e[8],b}let T;e[9]!==u?(T=u("Copy?"),e[9]=u,e[10]=T):T=e[10];let p;e[11]!==u||e[12]!==r?(p=u("Copy index declaration for {table}",{table:r}),e[11]=u,e[12]=r,e[13]=p):p=e[13];let w;return e[14]!==y||e[15]!==T||e[16]!==p||e[17]!==i?(w=(0,S.jsx)(W,{confirmLabel:T,onConfirm:y,testId:i,children:p}),e[14]=y,e[15]=T,e[16]=p,e[17]=i,e[18]=w):w=e[18],w},"ve"),ye=l((t,e)=>{let n=new Map;for(let a of e){let r=`${a.table} ${a.index}`;n.set(r,(n.get(r)??0)+a.reads)}return t.map(a=>({index:a.index,reads:n.get(`${a.table} ${a.index}`)??0,table:a.table}))},"Se"),ve=l(t=>{let e=new Map;for(let n of t)for(let a of n.scannedTables??[])e.set(a.table,(e.get(a.table)??0)+a.scans);return[...e].map(([n,a])=>({scans:a,table:n}))},"Te"),re=l((t,e)=>e.filter(n=>n.type!=="vector"&&n.unique!==!0).map(n=>({index:n.name,table:t})),"P"),we=l(t=>{let e=ye(t.declaredIndexes??[],t.indexHits??[]),n=ve(t.functions??[]),a=t.shardTraffic??[],r=t.analyticsMetrics,i=r&&r.indexHits.length>0?r.indexHits:e,u=r&&r.tableScans.length>0?r.tableScans:n,h=r&&r.shardTraffic.length>0?r.shardTraffic:a,f=ne({indexHits:i,schema:{tables:[]},shardTraffic:h,tableScans:u},{lints:ae,source:"runtime"}),m=t.suppressHotScanTables;return(m===void 0?f:f.filter(y=>!(y.metadata.kind==="hot_scan"&&typeof y.metadata.table=="string"&&m.has(y.metadata.table)))).map(y=>j(y))},"we"),Se=M(I.listTables),Te=M(I.listTableIndexes),Ie=M(I.listTablesIndexes),B=l(t=>`${(t*100).toFixed(1)}%`,"H"),se=l(t=>`${(t/1e3).toFixed(2)}s`,"V"),$e=l(t=>{if(t.length<=1)return t[0]??"";let e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},"Ne"),ke=l((t,e)=>({"high-error-rate":t("High error rate"),"high-evictions":t("High cache eviction rate"),"high-write-contention":t("High write contention"),"low-cache-hit-rate":t("Low cache hit rate"),"missing-index":t("Missing index"),"slow-function":t("Slow function"),"storage-headroom":t("Storage headroom")})[e.kind],"ke"),ie=l((t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:B(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict \u2014 consider sharding to cut contention.",{rate:B(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:B(e.value)}),"missing-index":t("Slowest call took {duration} \u2014 it full-scanned {tables} with no index.",{duration:se(e.value),tables:$e(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:se(e.value)}),"storage-headroom":t("{size} of the 10 GiB per-shard ceiling \u2014 plan a .shardBy() migration while it still has runway.",{size:G(e.value)})})[e.kind],"U"),Ne=l(t=>{let e=(0,E.c)(10),{onJump:n,table:a}=t,r=q(),i;e[0]!==n||e[1]!==a?(i=l(()=>{n(a)},"o"),e[0]=n,e[1]=a,e[2]=i):i=e[2];let u=i,h=`in-add-index-${a}`,f;e[3]!==r||e[4]!==a?(f=r("Add index on {table}",{table:a}),e[3]=r,e[4]=a,e[5]=f):f=e[5];let m;return e[6]!==u||e[7]!==h||e[8]!==f?(m=(0,S.jsx)(V,{"data-testid":h,onClick:u,size:"sm",type:"button",variant:"outline",children:f}),e[6]=u,e[7]=h,e[8]=f,e[9]=m):m=e[9],m},"Be"),ze=l(({initialShardKey:t,loadShardTraffic:e})=>{let n=Q(),a=D(),r=q(),{queryShardKey:i,setShardKey:u,shardKey:h}=ee(t),[f,m]=(0,c.useState)(null),[y,T]=(0,c.useState)(null),p=(0,c.useRef)(""),w=A(I.getMetrics,{},{live:!0,shardKey:i}),b=A(I.getFunctionStats,{},{live:!0,shardKey:i}),$=A(I.getAdvisories,{},{live:!0,shardKey:i}),L=w.data??null,K=b.data?.functions??null,F=$.data?.advisories??null,J=w.data?.indexHits??null,O=w.error!==null&&b.error!==null?w.error:null,oe=e??(s=>n.shardTraffic(s)),le=l(async(s,x)=>{let o=s[0];if(o===void 0||o===""){p.current===x&&T(null);return}try{let g=await oe(o);if(p.current!==x)return;let d=new Map;for(let v of g.shards)d.has(v.shardKey)||d.set(v.shardKey,{requests:v.requests,shardKey:v.shardKey});T([...d.values()])}catch{p.current===x&&T(null)}},"Y"),de=l(async(s,x)=>{let o=await Promise.allSettled(s.map(async d=>[d,await n.query(Te,{table:d},C(x))])),g=[];for(let d of o)if(d.status==="fulfilled"){let[v,k]=d.value;g.push(...re(v,k.indexes))}return g},"Z"),z=(0,c.useEffectEvent)(async s=>{p.current=s;let x=[];try{let o=await n.query(Se,{},C(s));if(p.current!==s)return;Y(s),x=o.map(d=>d.name);let g=[];if(x.length>0)try{let d=await n.query(Ie,{tables:x},C(s));if(p.current!==s)return;for(let[v,k]of Object.entries(d.indexesByTable))g.push(...re(v,k))}catch{if(g=await de(x,s),p.current!==s)return}m(g)}catch{p.current===s&&m(null)}await le(x,s)});(0,c.useEffect)(()=>{N(z(i))},[i]);let ce=(0,c.useEffectEvent)(()=>{w.refetch(),b.refetch(),$.refetch(),N(z(i))});(0,c.useEffect)(()=>{let s=l(()=>{document.visibilityState==="visible"&&ce()},"r");return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s)}},[]);let U=(0,c.useCallback)(s=>{N(a({search:{table:s},to:"/schema"}))},[a]),H=(0,c.useMemo)(()=>X(L,K),[K,L]),P=(0,c.useMemo)(()=>new Set(H.filter(s=>s.kind==="missing-index").flatMap(s=>s.tables??[])),[H]),R=(0,c.useMemo)(()=>we({declaredIndexes:f??[],functions:K,indexHits:J,shardTraffic:y,suppressHotScanTables:P}),[f,K,J,P,y]),ue=(0,c.useMemo)(()=>{let s=H.map(o=>{let g=o.kind==="missing-index"?o.tables??[]:[];return{action:g.length>0?g.map(d=>(0,S.jsx)(Ne,{onJump:U,table:d},d)):void 0,description:o.message===void 0?ie(r,o):`${ie(r,o)} \u2014 ${o.message}`,entity:o.fn,issueType:ke(r,o),key:`${o.kind}:${o.fn??""}`,level:o.severity}}),x=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(F??[]).map(o=>{let g=j(o);if(x.has(o.name)&&ge(o.metadata)){let{table:d,suggestedIndex:v}=o.metadata,k=`in-apply-index-${d}-${v.name}`;return{...g,action:(0,S.jsx)(xe,{fields:v.fields,indexName:v.name,table:d,testId:k})}}return g}),...R,...s]},[F,H,U,R,r]),fe=(0,S.jsx)(Z,{onChange:u,testId:"in-shard-input",value:h});return(0,S.jsx)(te,{error:O,errorSource:O===null?void 0:w.errorSource,rows:ue,shardKey:i,testId:"lunora-insights",toolbar:fe})},"Ue");export{ze as InsightsPanel};
@@ -1,4 +1,4 @@
1
- import{a as Ie,b as Te,c as $e,d as je,e as Ee}from"./chunk-54X7HWI6.js";import"./chunk-T7UKRA6J.js";import{c as Se}from"./chunk-BWS7JUQV.js";import"./chunk-SNJ3ZOV2.js";import{a as Ce}from"./chunk-CJ2V577P.js";import"./chunk-QAETUNZX.js";import"./chunk-LMCBMC2V.js";import"./chunk-QF743FSL.js";import"./chunk-IQ5CIBXJ.js";import"./chunk-YNCZVYCO.js";import"./chunk-OWRWDDJT.js";import"./chunk-QHVUXMRV.js";import"./chunk-2NUCBQFU.js";import{a as ke}from"./chunk-PAFHBQFL.js";import{b as he}from"./chunk-EDL46BPM.js";import{a as Ne}from"./chunk-DWNWEMQK.js";import"./chunk-4KPATTV6.js";import"./chunk-N7FOBAV3.js";import"./chunk-OKZINWBB.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as se}from"./chunk-NVMQPIRS.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import"./chunk-L27FKJTG.js";import{a as Q}from"./chunk-LYVYUTQY.js";import{c as xe,d as ve}from"./chunk-UN3QTZ6X.js";import{a as pe,e as fe}from"./chunk-TN4Z3P6S.js";import{c as oe,d as be,n as ye}from"./chunk-5KQSRLQP.js";import"./chunk-ZPQBVYNN.js";import{B as re,b as Y,h as te,i as B,j as U,s as le}from"./chunk-PN7JHEYW.js";import"./chunk-PDBW6GTJ.js";import{a as Je}from"./chunk-A6TVTNKO.js";import{a as Pe,b as Ve}from"./chunk-ADABTCDI.js";import{a,d as me}from"./chunk-5PEAXTYQ.js";var ce=me(Je(),1);var E=me(Pe(),1);var m=me(Ve(),1);var We=a(t=>`${JSON.stringify({end:!0,rows:t})}
1
+ import{a as Ie,b as Te,c as $e,d as je,e as Ee}from"./chunk-54X7HWI6.js";import"./chunk-T7UKRA6J.js";import{c as Se}from"./chunk-BWS7JUQV.js";import"./chunk-SNJ3ZOV2.js";import{a as Ce}from"./chunk-CJ2V577P.js";import"./chunk-QAETUNZX.js";import"./chunk-LMCBMC2V.js";import"./chunk-QF743FSL.js";import"./chunk-IQ5CIBXJ.js";import"./chunk-YNCZVYCO.js";import"./chunk-OWRWDDJT.js";import"./chunk-QHVUXMRV.js";import"./chunk-2NUCBQFU.js";import{a as ke}from"./chunk-PAFHBQFL.js";import{b as he}from"./chunk-EDL46BPM.js";import{a as Ne}from"./chunk-DWNWEMQK.js";import"./chunk-4KPATTV6.js";import"./chunk-N7FOBAV3.js";import"./chunk-OKZINWBB.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as se}from"./chunk-NVMQPIRS.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import"./chunk-L27FKJTG.js";import{a as Q}from"./chunk-LYVYUTQY.js";import{c as xe,d as ve}from"./chunk-KE7ZGUGO.js";import{a as pe,e as fe}from"./chunk-TN4Z3P6S.js";import{c as oe,d as be,n as ye}from"./chunk-UK5OOCLQ.js";import"./chunk-ZPQBVYNN.js";import{B as re,b as Y,h as te,i as B,j as U,s as le}from"./chunk-PN7JHEYW.js";import"./chunk-PDBW6GTJ.js";import{a as Je}from"./chunk-A6TVTNKO.js";import{a as Pe,b as Ve}from"./chunk-ADABTCDI.js";import{a,d as me}from"./chunk-5PEAXTYQ.js";var ce=me(Je(),1);var E=me(Pe(),1);var m=me(Ve(),1);var We=a(t=>`${JSON.stringify({end:!0,rows:t})}
2
2
  `,"Ue"),ze=a(t=>{if(t===null||typeof t!="object"||Array.isArray(t))return;let e=t;if(!(e.end!==!0||e.table!==void 0))return typeof e.rows=="number"&&Number.isSafeInteger(e.rows)&&e.rows>=0?e.rows:Number.NaN},"Ve"),He=a(()=>{let t=0,e;return{problem:a(()=>e===void 0?'the export has no end marker: it was written before exports carried an end marker, or it was cut short. If you have checked that the file is complete, append {"end":true,"rows":N} as its last line, N being its exact row count':e===t?void 0:`the export's end marker declares ${String(e)} row(s) but ${String(t)} were read`,"problem"),read:a(r=>{if(e!==void 0)throw new Error("the export continues after its end marker");let n=ze(r);return n===void 0?(t+=1,!0):(e=n,!1)},"read")}},"Xe"),_=class extends Error{static{a(this,"Z")}problem;constructor(e){super(e.kind),this.name="CsvFormatError",this.problem=e}},Ze="\uFEFF",Ge=a(()=>{let t=[],e=1,r=!1,n=!1,o="start",l="",i=a(()=>{t.push(o==="closing"||l!==""?l:void 0),o="start",l=""},"l"),c=a(s=>{i(),t.some(p=>p!==void 0)&&s.push({cells:t,number:e}),t=[],e+=1},"c"),u=a((s,p)=>{let f=r;if(r=!1,!(f&&s===`
3
3
  `)){if(o==="quoted"){s==='"'?o="closing":l+=s;return}if(o==="closing"&&s==='"'){l+=s,o="quoted";return}if(s===","){i();return}if(s==="\r"){c(p),r=!0;return}if(s===`
4
4
  `){c(p);return}if(o==="closing")throw new _({kind:"text-after-quote",record:e});if(o==="start"&&s==='"'){o="quoted";return}o="unquoted",l+=s}},"d");return{finish:a(()=>{if(o==="quoted")throw new _({kind:"unterminated-quote",record:e});let s=[];return c(s),s},"finish"),push:a(s=>{let p=[],f=0;for(!n&&s!==""&&(n=!0,f=s.startsWith(Ze)?1:0);f<s.length;f+=1)u(s.charAt(f),p);return p},"push")}},"He"),Oe=a(async function*(t){let e=Ge();for await(let r of t)yield*e.push(r);yield*e.finish()},"be"),ie=a((t,e,r)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0})},"ne"),Ae=a(t=>{let e=[],r=new Set;return t.forEach((n,o)=>{let l=(n??"").trim();if(l==="")throw new _({column:o+1,kind:"empty-header"});if(r.has(l))throw new _({kind:"duplicate-header",name:l});r.add(l),e.push(l)}),e},"Ne"),Ke=a(({cells:t,number:e},r,n)=>{if(t.length!==r.length)throw new _({expected:r.length,found:t.length,kind:"ragged",record:e});let o={};return r.forEach((l,i)=>{let c=t[i];c!==void 0?ie(o,l,c):n.has(l)&&ie(o,l,null)}),{doc:o,record:e}},"Ce"),Qe=/^-?\d+$/u,Xe=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/iu,Ye=/^-?\d{11,}$/u,et=/^(\d{4})-(\d{2})-(\d{2})$/u,tt=/^(\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?(Z|[+-]\d{2}:\d{2})?$/u,rt=/\.(\d+)/u,nt=/[1-9]/u,ot=/^[+-]?(\d*)(?:\.(\d*))?(?:e([+-]?\d+))?$/iu,Le=a(t=>{let[,e="",r="",n="0"]=ot.exec(t)??[],o=`${e}${r}`,l=0,i=o.length;for(;l<i&&o.charAt(l)==="0";)l+=1;for(;i>l&&o.charAt(i-1)==="0";)i-=1;return l===i?{digits:"",exponent:0}:{digits:o.slice(l,i),exponent:Number(n)-r.length+(o.length-i)}},"he"),lt=a((t,e)=>{let r=Le(t),n=Le(e.toExponential());return r.digits===n.digits&&r.exponent===n.exponent?!0:r.digits!==""&&r.exponent>=0&&Number.isInteger(e)&&BigInt(r.digits)*10n**BigInt(r.exponent)===BigInt(Math.abs(e))},"rt"),st=a(t=>{let e=t.trim();if(!Xe.test(e))return;let r=Number(e);if(Number.isFinite(r))return lt(e,r)?{number:r}:{inexact:!0}},"nt"),at=a((t,e,r)=>{let n=new Date(0);return n.setUTCFullYear(t,e-1,r),n.getUTCMonth()===e-1&&n.getUTCDate()===r},"ot"),it=a((t,e,r,n)=>Number(t)<=23&&Number(e)<=59&&Number(r)<=59&&(n==="Z"||Number(n.slice(1,3))<=23&&Number(n.slice(4,6))<=59),"st"),dt=a(t=>{let[e="",r,...n]=t.split("T"),o=et.exec(e),l=r===void 0?void 0:tt.exec(r);if(o===null||n.length>0||r!==void 0&&l===null)return;let[,i="",c="",u=""]=o;if(!at(Number(i),Number(c),Number(u)))return;let[,s="0",p="0",f="0",w]=l??[];if(!it(s,p,f,w??"Z"))return;let g=rt.exec(r??"")?.[1]??"";if(nt.test(g.slice(3)))return;let x=Date.parse(l!==void 0&&w===void 0?`${t}Z`:t);return Number.isFinite(x)?x:void 0},"it"),ct=a(t=>{let e=st(t);return e===void 0?{expected:"number",kind:"rejected"}:"number"in e?{kind:"ok",value:e.number}:{expected:"number",inexact:!0,kind:"rejected"}},"lt"),ut=a(t=>{let e=t.trim(),r=dt(e);return r===void 0&&Ye.test(e)&&(r=Number(e)),r===void 0||!Number.isFinite(new Date(r).getTime())?{expected:"date",kind:"rejected"}:{kind:"ok",value:r}},"at"),mt=a(t=>{try{return oe(t),!0}catch{return!1}},"ct"),pt=a((t,e)=>{if(e==="bigint"){let r=t.trim();if(!Qe.test(r))return{expected:"bigint",kind:"rejected"};let n=BigInt(r);return mt(n)?{kind:"ok",value:n}:{expected:"bigint",kind:"rejected",tooLong:!0}}if(e==="boolean"){let r=t.trim().toLowerCase();return r==="true"||r==="false"?{kind:"ok",value:r==="true"}:{expected:"boolean",kind:"rejected"}}return e==="number"?ct(t):e==="date"||e==="timestamp"?ut(t):{kind:"ok",value:t}},"dt"),De=a(({doc:t,record:e},r)=>{let n={};for(let[o,l]of Object.entries(t)){if(l===null){ie(n,o,null);continue}let i=pt(l,r.get(o));if(i.kind==="rejected")throw new _({column:o,expected:i.expected,...i.inexact===!0&&{inexact:!0},kind:"cell-type",record:e,...i.tooLong===!0&&{tooLong:!0},value:l});ie(n,o,i.value)}return{doc:n,record:e}},"ke"),ft=a(async function*(t,e,r){let n;for await(let o of Oe(t))n===void 0?n=Ae(o.cells):yield De(Ke(o,n,r),e)},"ut"),ht=a(t=>new Set(t.filter(e=>e.nullable===!0&&!e.optional).map(e=>e.name)),"ft"),qe=a(t=>{if(t instanceof _)return t;throw t},"we"),wt=a(async(t,e,r,n)=>{let o,l,i;for await(let u of Oe(t)){if(o===void 0){try{o=Ae(u.cells)}catch(p){l=qe(p),o=[]}continue}let s;try{s=De(Ke(u,o,r),e)}catch(p){i??=qe(p);continue}n(s)}let c=l??i;if(c!==void 0)throw c},"mt"),Be=te(Q.exportShard),ne=te(Q.importShard),gt=te(Q.listTables),bt=te(Q.describeTable),yt={},xt=a(t=>t.map(e=>JSON.stringify(oe(e))).join(`
@@ -1,4 +1,4 @@
1
- import{a as je}from"./chunk-4AGOKKRZ.js";import{a as he}from"./chunk-CJ2V577P.js";import{a as le}from"./chunk-4KVCH3A4.js";import{a as V}from"./chunk-HB2FLDDU.js";import{d as Ie,f as Oe,g as $e,k as ie}from"./chunk-2NUCBQFU.js";import{a as Ce}from"./chunk-PAFHBQFL.js";import"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import{i as we}from"./chunk-OKZINWBB.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as U}from"./chunk-NVMQPIRS.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as E}from"./chunk-S3TDGFRE.js";import{b as Se}from"./chunk-UV6GPH2E.js";import"./chunk-L27FKJTG.js";import{a as ke}from"./chunk-LYVYUTQY.js";import{n as F}from"./chunk-5KQSRLQP.js";import"./chunk-ZPQBVYNN.js";import{B as M,b as be,g as ye,h as ne,i as se,j as ue,p as ve,s as Ne,v as ae,x as fe}from"./chunk-PN7JHEYW.js";import"./chunk-PDBW6GTJ.js";import{a as te}from"./chunk-A6TVTNKO.js";import{a as me,b as re}from"./chunk-ADABTCDI.js";import{a as u,d as L}from"./chunk-5PEAXTYQ.js";var Qe=L(te(),1),xe=L(me(),1);var Y=L(te(),1),X=L(me(),1);var A=L(re(),1);var Xe={action:"action",mutation:"mutation",query:"query"},Te=u(t=>{let e=t.indexOf(":");return e===-1?{file:"",fn:t}:{file:t.slice(0,e),fn:t.slice(e+1)}},"Q"),Ye=u(({file:t,fn:e,kind:a})=>`await client.${Xe[a]}(api.${t}.${e}, { /* args */ });`,"ie"),Ze=u(t=>{let e=`api.${t.file}.${t.fn}`;switch(t.kind){case"action":return`const { call: ${t.fn} } = useAction(${e});`;case"mutation":return`const ${t.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},"ne"),et=u(({file:t,fn:e})=>`lunora run ${t}:${e} --args '{ }'`,"ae"),tt=u(t=>["// Read rows",`const rows = await ctx.db.query("${t}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${t}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${t}">;`,`type RowId = Id<"${t}">;`].join(`
1
+ import{a as je}from"./chunk-4AGOKKRZ.js";import{a as he}from"./chunk-CJ2V577P.js";import{a as le}from"./chunk-4KVCH3A4.js";import{a as V}from"./chunk-HB2FLDDU.js";import{d as Ie,f as Oe,g as $e,k as ie}from"./chunk-2NUCBQFU.js";import{a as Ce}from"./chunk-PAFHBQFL.js";import"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import{i as we}from"./chunk-OKZINWBB.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as U}from"./chunk-NVMQPIRS.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as E}from"./chunk-S3TDGFRE.js";import{b as Se}from"./chunk-UV6GPH2E.js";import"./chunk-L27FKJTG.js";import{a as ke}from"./chunk-LYVYUTQY.js";import{n as F}from"./chunk-UK5OOCLQ.js";import"./chunk-ZPQBVYNN.js";import{B as M,b as be,g as ye,h as ne,i as se,j as ue,p as ve,s as Ne,v as ae,x as fe}from"./chunk-PN7JHEYW.js";import"./chunk-PDBW6GTJ.js";import{a as te}from"./chunk-A6TVTNKO.js";import{a as me,b as re}from"./chunk-ADABTCDI.js";import{a as u,d as L}from"./chunk-5PEAXTYQ.js";var Qe=L(te(),1),xe=L(me(),1);var Y=L(te(),1),X=L(me(),1);var A=L(re(),1);var Xe={action:"action",mutation:"mutation",query:"query"},Te=u(t=>{let e=t.indexOf(":");return e===-1?{file:"",fn:t}:{file:t.slice(0,e),fn:t.slice(e+1)}},"Q"),Ye=u(({file:t,fn:e,kind:a})=>`await client.${Xe[a]}(api.${t}.${e}, { /* args */ });`,"ie"),Ze=u(t=>{let e=`api.${t.file}.${t.fn}`;switch(t.kind){case"action":return`const { call: ${t.fn} } = useAction(${e});`;case"mutation":return`const ${t.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},"ne"),et=u(({file:t,fn:e})=>`lunora run ${t}:${e} --args '{ }'`,"ae"),tt=u(t=>["// Read rows",`const rows = await ctx.db.query("${t}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${t}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${t}">;`,`type RowId = Id<"${t}">;`].join(`
2
2
  `),"se"),rt=ne(ke.listTables),at=["react","client","cli"],ot=u((t,e)=>{switch(t){case"cli":return et(e);case"client":return Ye(e);default:return Ze(e)}},"re"),Ae=u(t=>{let e=(0,Y.c)(19),{code:a,label:r,testId:o}=t,s=M(),n;e[0]!==a?(n=u(()=>{ae(a)},"c"),e[0]=a,e[1]=n):n=e[1];let i=n,c;e[2]!==r?(c=(0,A.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:r}),e[2]=r,e[3]=c):c=e[3];let m=`${o}-copy`,l;e[4]!==s?(l=s("Copy"),e[4]=s,e[5]=l):l=e[5];let p;e[6]!==i||e[7]!==m||e[8]!==l?(p=(0,A.jsx)(U,{"data-testid":m,onClick:i,size:"xs",type:"button",variant:"ghost",children:l}),e[6]=i,e[7]=m,e[8]=l,e[9]=p):p=e[9];let f;e[10]!==c||e[11]!==p?(f=(0,A.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[c,p]}),e[10]=c,e[11]=p,e[12]=f):f=e[12];let h;e[13]!==a||e[14]!==o?(h=(0,A.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":o,children:a}),e[13]=a,e[14]=o,e[15]=h):h=e[15];let g;return e[16]!==f||e[17]!==h?(g=(0,A.jsxs)("div",{className:"flex flex-col gap-1.5",children:[f,h]}),e[16]=f,e[17]=h,e[18]=g):g=e[18],g},"U"),nt=u(t=>{let e=(0,Y.c)(46),{file:a,fn:r,kind:o}=t,s=M(),[n,i]=(0,X.useState)("react"),c,m,l;if(e[0]!==a||e[1]!==r||e[2]!==o||e[3]!==s||e[4]!==n){let w={file:a,fn:r,kind:o},j;e[8]!==s?(j=s("CLI"),e[8]=s,e[9]=j):j=e[9];let O;e[10]!==s?(O=s("Client"),e[10]=s,e[11]=O):O=e[11];let S;e[12]!==s?(S=s("React"),e[12]=s,e[13]=S):S=e[13];let T;e[14]!==j||e[15]!==O||e[16]!==S?(T={cli:j,client:O,react:S},e[14]=j,e[15]=O,e[16]=S,e[17]=T):T=e[17],l=T;let R;e[18]===Symbol.for("react.memo_cache_sentinel")?(R=u(_=>{i(_.currentTarget.dataset.tab)},"B"),e[18]=R):R=e[18],c=R,m=ot(n,w),e[0]=a,e[1]=r,e[2]=o,e[3]=s,e[4]=n,e[5]=c,e[6]=m,e[7]=l}else c=e[5],m=e[6],l=e[7];let p=m,f=`api.${a}.${r}`,h;e[19]!==f?(h=(0,A.jsx)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-fn-title",children:f}),e[19]=f,e[20]=h):h=e[20];let g;e[21]!==o||e[22]!==s?(g=s("Call this {kind} from your app.",{kind:o}),e[21]=o,e[22]=s,e[23]=g):g=e[23];let x;e[24]!==g?(x=(0,A.jsx)("p",{className:"text-xs text-muted-foreground",children:g}),e[24]=g,e[25]=x):x=e[25];let v;e[26]!==h||e[27]!==x?(v=(0,A.jsxs)("div",{children:[h,x]}),e[26]=h,e[27]=x,e[28]=v):v=e[28];let N;e[29]!==s?(N=s("Snippet flavour"),e[29]=s,e[30]=N):N=e[30];let y;e[31]!==c||e[32]!==n||e[33]!==l?(y=at.map(w=>(0,A.jsx)(U,{"aria-selected":n===w,"data-tab":w,"data-testid":`api-tab-${w}`,onClick:c,role:"tab",size:"xs",type:"button",variant:n===w?"default":"outline",children:l[w]},w)),e[31]=c,e[32]=n,e[33]=l,e[34]=y):y=e[34];let b;e[35]!==N||e[36]!==y?(b=(0,A.jsx)("div",{"aria-label":N,className:"flex gap-1.5","data-testid":"api-tabs",role:"tablist",children:y}),e[35]=N,e[36]=y,e[37]=b):b=e[37];let I=l[n],C=`api-snippet-${n}`,$;e[38]!==p||e[39]!==I||e[40]!==C?($=(0,A.jsx)(Ae,{code:p,label:I,testId:C}),e[38]=p,e[39]=I,e[40]=C,e[41]=$):$=e[41];let k;return e[42]!==$||e[43]!==v||e[44]!==b?(k=(0,A.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"api-fn-doc",children:[v,b,$]}),e[42]=$,e[43]=v,e[44]=b,e[45]=k):k=e[45],k},"de"),st=u(t=>{let e=(0,Y.c)(19),{name:a}=t,r=M(),o;e[0]!==a?(o=tt(a),e[0]=a,e[1]=o):o=e[1];let s=o,n;e[2]!==a?(n=(0,A.jsx)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-table-title",children:a}),e[2]=a,e[3]=n):n=e[3];let i;e[4]!==r?(i=r("Read and write this table through the typed data model."),e[4]=r,e[5]=i):i=e[5];let c;e[6]!==i?(c=(0,A.jsx)("p",{className:"text-xs text-muted-foreground",children:i}),e[6]=i,e[7]=c):c=e[7];let m;e[8]!==n||e[9]!==c?(m=(0,A.jsxs)("div",{children:[n,c]}),e[8]=n,e[9]=c,e[10]=m):m=e[10];let l;e[11]!==r?(l=r("Data model"),e[11]=r,e[12]=l):l=e[12];let p;e[13]!==s||e[14]!==l?(p=(0,A.jsx)(Ae,{code:s,label:l,testId:"api-snippet-table"}),e[13]=s,e[14]=l,e[15]=p):p=e[15];let f;return e[16]!==m||e[17]!==p?(f=(0,A.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"api-table-doc",children:[m,p]}),e[16]=m,e[17]=p,e[18]=f):f=e[18],f},"fe"),Pe=u(t=>{let e=(0,Y.c)(8),{active:a,label:r,onSelect:o,testId:s,value:n}=t,i;e[0]!==o||e[1]!==n?(i=u(()=>{o(n)},"m"),e[0]=o,e[1]=n,e[2]=i):i=e[2];let c=i,m=a?"page":void 0,l;return e[3]!==r||e[4]!==c||e[5]!==m||e[6]!==s?(l=(0,A.jsx)("button",{"aria-current":m,className:"w-full truncate rounded-md px-2 py-1 text-start font-mono text-xs text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-testid":s,onClick:c,type:"button",children:r}),e[3]=r,e[4]=c,e[5]=m,e[6]=s,e[7]=l):l=e[7],l},"G"),it=u(t=>{let e=new Map;for(let a of t){let{file:r,fn:o}=Te(a.path),s=e.get(r)??[];s.push({fn:o,kind:a.kind,path:a.path}),e.set(r,s)}return[...e.entries()].map(([a,r])=>({file:a,items:r.toSorted((o,s)=>o.fn.localeCompare(s.fn))})).toSorted((a,r)=>a.file.localeCompare(r.file))},"pe"),Re=u(t=>{let e=(0,Y.c)(58),{functions:a,initialShardKey:r}=t,o=M(),s=F(),[n,i]=(0,X.useState)(null),[c,m]=(0,X.useState)(null),l,p;e[0]!==s||e[1]!==r?(l=u(()=>{let _=!1;return s.query(rt,{},se(r??"")).then(P=>(_||i(P),P)).catch(()=>{_||i([])}),()=>{_=!0}},"o"),p=[s,r],e[0]=s,e[1]=r,e[2]=l,e[3]=p):(l=e[2],p=e[3]),(0,X.useEffect)(l,p);let f,h,g,x,v,N,y,b,I,C;if(e[4]!==a||e[5]!==c||e[6]!==o||e[7]!==n){let _=a??[],P=it(_),q=(n??[]).map(lt).toSorted(dt),J;e[18]===Symbol.for("react.memo_cache_sentinel")?(J=u(K=>{m({kind:"fn",path:K})},"P"),e[18]=J):J=e[18];let W=J,Q;e[19]===Symbol.for("react.memo_cache_sentinel")?(Q=u(K=>{m({kind:"table",name:K})},"j"),e[19]=Q):Q=e[19];let Ve=Q;h=c?.kind==="fn"?_.find(K=>K.path===c.path):void 0,f=_.length>0||q.length>0,g=h===void 0?void 0:Te(h.path),I="grid min-h-0 gap-6 md:grid-cols-[16rem_minmax(0,1fr)]",C="lunora-api-docs",e[20]!==o?(x=o("API resources"),e[20]=o,e[21]=x):x=e[21],v="flex flex-col gap-4 overflow-y-auto",N="api-rail";let oe;e[22]!==c||e[23]!==o?(oe=u(K=>(0,A.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,A.jsx)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:K.file||o("(root)")}),K.items.map(ee=>(0,A.jsx)(Pe,{active:c?.kind==="fn"&&c.path===ee.path,label:ee.fn,onSelect:W,testId:`api-rail-fn-${ee.path}`,value:ee.path},ee.path))]},K.file),"q"),e[22]=c,e[23]=o,e[24]=oe):oe=e[24],y=P.map(oe),b=q.length>0&&(0,A.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,A.jsx)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o("Tables")}),q.map(K=>(0,A.jsx)(Pe,{active:c?.kind==="table"&&c.name===K,label:K,onSelect:Ve,testId:`api-rail-table-${K}`,value:K},K))]}),e[4]=a,e[5]=c,e[6]=o,e[7]=n,e[8]=f,e[9]=h,e[10]=g,e[11]=x,e[12]=v,e[13]=N,e[14]=y,e[15]=b,e[16]=I,e[17]=C}else f=e[8],h=e[9],g=e[10],x=e[11],v=e[12],N=e[13],y=e[14],b=e[15],I=e[16],C=e[17];let $;e[25]!==f||e[26]!==o?($=!f&&(0,A.jsx)("p",{className:"px-2 text-xs text-muted-foreground","data-testid":"api-rail-empty",children:o("No functions or tables to document yet.")}),e[25]=f,e[26]=o,e[27]=$):$=e[27];let k;e[28]!==$||e[29]!==x||e[30]!==v||e[31]!==N||e[32]!==y||e[33]!==b?(k=(0,A.jsxs)("nav",{"aria-label":x,className:v,"data-testid":N,children:[y,b,$]}),e[28]=$,e[29]=x,e[30]=v,e[31]=N,e[32]=y,e[33]=b,e[34]=k):k=e[34];let w;e[35]!==c||e[36]!==o?(w=c===null&&(0,A.jsx)(E,{description:o("Select a function or table to see how to call it from your app."),testId:"api-empty",title:o("API usage snippets")}),e[35]=c,e[36]=o,e[37]=w):w=e[37];let j;e[38]!==c?.kind||e[39]!==h||e[40]!==g?(j=c?.kind==="fn"&&h!==void 0&&g!==void 0&&(0,A.jsx)(nt,{file:g.file,fn:g.fn,kind:h.kind},h.path),e[38]=c?.kind,e[39]=h,e[40]=g,e[41]=j):j=e[41];let O;e[42]!==c?.kind||e[43]!==h||e[44]!==o?(O=c?.kind==="fn"&&h===void 0&&(0,A.jsx)(E,{testId:"api-empty",title:o("API usage snippets")}),e[42]=c?.kind,e[43]=h,e[44]=o,e[45]=O):O=e[45];let S;e[46]!==c?(S=c?.kind==="table"&&(0,A.jsx)(st,{name:c.name}),e[46]=c,e[47]=S):S=e[47];let T;e[48]!==w||e[49]!==j||e[50]!==O||e[51]!==S?(T=(0,A.jsxs)("div",{className:"min-w-0",children:[w,j,O,S]}),e[48]=w,e[49]=j,e[50]=O,e[51]=S,e[52]=T):T=e[52];let R;return e[53]!==k||e[54]!==T||e[55]!==I||e[56]!==C?(R=(0,A.jsxs)("div",{className:I,"data-testid":C,children:[k,T]}),e[53]=k,e[54]=T,e[55]=I,e[56]=C,e[57]=R):R=e[57],R},"ke");function lt(t){return t.name}u(lt,"ue");function dt(t,e){return t.localeCompare(e)}u(dt,"me");var We=L(te(),1);var B=L(te(),1);var z=L(me(),1);var d=L(re(),1);var ct=u(t=>typeof t=="number"?"number":typeof t=="boolean"?"boolean":"string","we"),Me=u(t=>{if(t.enum!==void 0&&t.enum.length>0)return t.enum;if(t.anyOf!==void 0&&t.anyOf.length>0&&t.anyOf.every(e=>e.const!==void 0))return t.anyOf.map(e=>e.const)},"Q"),ce=u(t=>t===void 0?"any":t.const!==void 0?JSON.stringify(t.const):t.enum!==void 0&&t.enum.length>0?t.enum.map(e=>JSON.stringify(e)).join(" | "):t.anyOf!==void 0&&t.anyOf.length>0?t.anyOf.map(e=>ce(e)).join(" | "):t.type==="array"?`array<${ce(t.items)}>`:t.type??"any","z"),pt=u(t=>{let e=Me(t);return e!==void 0?t.type??ct(e[0]):ce(t)},"ke"),mt=u(t=>{let e=Me(t);return e===void 0?void 0:e.map(a=>JSON.stringify(a)).join(" | ")},"Oe"),ut=u(t=>{let e=[];t.minimum!==void 0?e.push(`${String(t.minimum)} \u2264`):t.exclusiveMinimum!==void 0&&e.push(`${String(t.exclusiveMinimum)} <`);let a=e.length>0;e.push("value"),t.maximum!==void 0?e.push(`\u2264 ${String(t.maximum)}`):t.exclusiveMaximum!==void 0&&e.push(`< ${String(t.exclusiveMaximum)}`);let r=e.length>(a?2:1);return a||r?e.join(" "):void 0},"$e"),ft=u(t=>{if(t.type==="object"&&t.properties!==void 0)return t;if(t.type==="array"&&t.items?.type==="object"&&t.items.properties!==void 0)return t.items},"Te"),Z=u(t=>{if(t===void 0)return null;if(t.const!==void 0)return t.const;if(t.enum!==void 0&&t.enum.length>0)return t.enum[0];if(t.anyOf!==void 0&&t.anyOf.length>0)return Z(t.anyOf[0]);switch(t.type){case"array":return[];case"boolean":return!1;case"number":return 0;case"object":{let e={};for(let[a,r]of Object.entries(t.properties??{}))e[a]=Z(r);return e}case"string":return"";default:return null}},"D"),de=u(t=>{let e=(0,B.c)(7),{label:a,value:r}=t,o;e[0]!==a?(o=(0,d.jsx)("span",{className:"text-muted-foreground",children:a}),e[0]=a,e[1]=o):o=e[1];let s;e[2]!==r?(s=(0,d.jsx)("span",{className:"text-foreground",children:r}),e[2]=r,e[3]=s):s=e[3];let n;return e[4]!==o||e[5]!==s?(n=(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 font-mono text-[10px]",children:[o,s]}),e[4]=o,e[5]=s,e[6]=n):n=e[6],n},"K"),ht=u(t=>{let e=(0,B.c)(40),{name:a,required:r,schema:o}=t,s=M(),n;e[0]!==o?(n=ut(o),e[0]=o,e[1]=n):n=e[1];let i=n,c;e[2]!==o?(c=mt(o),e[2]=o,e[3]=c):c=e[3];let m=c,l=o["x-lunora-table"],p=o.format!==void 0||i!==void 0||m!==void 0||l!==void 0,f;e[4]!==o?(f=ft(o),e[4]=o,e[5]=f):f=e[5];let h=f,g=r?"*":"?",x;e[6]!==g?(x=(0,d.jsx)("span",{className:"text-muted-foreground",children:g}),e[6]=g,e[7]=x):x=e[7];let v;e[8]!==a||e[9]!==x?(v=(0,d.jsxs)("span",{className:"font-mono text-foreground",children:[a,x]}),e[8]=a,e[9]=x,e[10]=v):v=e[10];let N;e[11]!==o?(N=pt(o),e[11]=o,e[12]=N):N=e[12];let y;e[13]!==N?(y=(0,d.jsx)("span",{className:"font-mono text-muted-foreground",children:N}),e[13]=N,e[14]=y):y=e[14];let b;e[15]!==v||e[16]!==y?(b=(0,d.jsxs)("div",{className:"flex items-baseline gap-2",children:[v,y]}),e[15]=v,e[16]=y,e[17]=b):b=e[17];let I;e[18]!==o.description?(I=o.description!==void 0&&(0,d.jsx)("p",{className:"max-w-prose text-muted-foreground",children:o.description}),e[18]=o.description,e[19]=I):I=e[19];let C;e[20]!==p||e[21]!==i||e[22]!==l||e[23]!==o.format||e[24]!==s||e[25]!==m?(C=p&&(0,d.jsxs)("div",{className:"flex flex-wrap gap-1",children:[o.format!==void 0&&(0,d.jsx)(de,{label:s("Format"),value:o.format}),i!==void 0&&(0,d.jsx)(de,{label:s("Range"),value:i}),m!==void 0&&(0,d.jsx)(de,{label:s("Value in"),value:m}),l!==void 0&&(0,d.jsx)(de,{label:s("relation"),value:l})]}),e[20]=p,e[21]=i,e[22]=l,e[23]=o.format,e[24]=s,e[25]=m,e[26]=C):C=e[26];let $;e[27]!==I||e[28]!==C||e[29]!==b?($=(0,d.jsxs)("div",{className:"flex flex-col gap-1 py-2",children:[b,I,C]}),e[27]=I,e[28]=C,e[29]=b,e[30]=$):$=e[30];let k=$;if(h===void 0){let S;return e[31]!==k?(S=(0,d.jsx)("div",{className:"border-b border-border/50 last:border-b-0",children:k}),e[31]=k,e[32]=S):S=e[32],S}let w;e[33]!==k?(w=(0,d.jsx)("summary",{className:"cursor-pointer marker:text-muted-foreground",children:k}),e[33]=k,e[34]=w):w=e[34];let j;e[35]!==h?(j=(0,d.jsx)("div",{className:"mb-2 ml-2 border-l border-border pl-3",children:(0,d.jsx)(qe,{schema:h})}),e[35]=h,e[36]=j):j=e[36];let O;return e[37]!==w||e[38]!==j?(O=(0,d.jsxs)("details",{className:"border-b border-border/50 last:border-b-0",children:[w,j]}),e[37]=w,e[38]=j,e[39]=O):O=e[39],O},"Ce"),qe=u(t=>{let e=(0,B.c)(7),{schema:a}=t,r;e[0]!==a.required?(r=new Set(a.required),e[0]=a.required,e[1]=r):r=e[1];let o=r,s;e[2]!==a.properties?(s=Object.entries(a.properties??{}),e[2]=a.properties,e[3]=s):s=e[3];let n=s,i;return e[4]!==o||e[5]!==n?(i=(0,d.jsx)("div",{className:"flex flex-col",children:n.map(c=>{let[m,l]=c;return(0,d.jsx)(ht,{name:m,required:o.has(m),schema:l},m)})}),e[4]=o,e[5]=n,e[6]=i):i=e[6],i},"Z"),_e=u(t=>{let e=(0,B.c)(10),{schema:a,testId:r}=t;if(a?.type!=="object"||Object.keys(a.properties??{}).length===0){let n;e[0]!==a?(n=ce(a),e[0]=a,e[1]=n):n=e[1];let i;return e[2]!==n||e[3]!==r?(i=(0,d.jsx)("p",{className:"font-mono text-xs text-muted-foreground","data-testid":r,children:n}),e[2]=n,e[3]=r,e[4]=i):i=e[4],i}let o;e[5]!==a?(o=(0,d.jsx)(qe,{schema:a}),e[5]=a,e[6]=o):o=e[6];let s;return e[7]!==o||e[8]!==r?(s=(0,d.jsx)("div",{className:"text-xs","data-testid":r,children:o}),e[7]=o,e[8]=r,e[9]=s):s=e[9],s},"V"),gt=["curl","javascript","lunora"],xt={lunora:"Lunora",curl:"cURL",javascript:"JavaScript"},bt=u(t=>`api.${t.replaceAll(/[/:]/g,".")}`,"je"),yt=u(t=>{let e=Z(t.argsSchema)??{};return t.functionPath===void 0?e:{args:e,functionPath:t.functionPath}},"Ae"),vt=u((t,e,a)=>{let r=`${a}${e.httpPath}`,o=JSON.stringify(yt(e),void 0,2),s=JSON.stringify(Z(e.argsSchema)??{},void 0,2);switch(t){case"curl":{let n=e.method!=="GET"&&e.method!=="HEAD",i=[`curl -X ${e.method} ${JSON.stringify(r)}`];return n&&i.push(' -H "Content-Type: application/json"',` -d '${o}'`),i.join(` \\
3
3
  `)}case"lunora":return e.functionPath===void 0?`await fetch(${JSON.stringify(e.httpPath)}, { method: ${JSON.stringify(e.method)} });`:`import { useLunora } from "@lunora/react";
4
4
  import { api } from "./_generated/api";
@@ -1 +1 @@
1
- import{a as R}from"./chunk-LYVYUTQY.js";import{c as K}from"./chunk-UN3QTZ6X.js";import{a as N}from"./chunk-A6TVTNKO.js";import{a as C,b as F}from"./chunk-ADABTCDI.js";import{a as o,d as A}from"./chunk-5PEAXTYQ.js";var b=A(N(),1),u=A(C(),1);var S=A(F(),1);var x=(0,u.createContext)(void 0),w={},T="New chat",j=o((n,s)=>({id:n,name:s?.title??T,schema:s?.schema??[],shardKey:s?.shardKey,suggestions:s?.suggestions??[],turns:[]}),"F"),D=o((n,s)=>[...n.sessions,s].slice(-10),"T"),m=o((n,s)=>{let a=`chat-${String(n.seq+1)}`;return{activeId:a,draft:s?.draft===void 0?void 0:{id:n.seq+1,text:s.draft},hasEditor:n.hasEditor,insertRequest:void 0,open:!0,pendingAsk:s?.ask===void 0?void 0:{id:n.seq+1,sessionId:a,text:s.ask},seq:n.seq+1,sessions:D(n,j(a,s))}},"f"),v=o((n,s)=>n.find(a=>a.id===s),"l"),O=o((n,s,a)=>n.map(c=>c.id===s?{...c,schema:a}:c),"D"),U=o((n,s,a)=>n.map(c=>c.id===s?{...c,schema:[],shardKey:a}:c),"O"),$=o((n,s)=>n.filter(a=>a.id!==s),"U"),E=o((n,s,a)=>n.map(c=>c.id===s?{...c,turns:a}:c),"y"),z=o(n=>{let s=(0,b.c)(16),{children:a}=n,c;s[0]===Symbol.for("react.memo_cache_sentinel")?(c={shardKey:""},s[0]=c):c=s[0];let _=K(R.aiAvailable,w,c),l;s[1]===Symbol.for("react.memo_cache_sentinel")?(l={activeId:void 0,draft:void 0,hasEditor:!1,insertRequest:void 0,open:!1,pendingAsk:void 0,seq:0,sessions:[]},s[1]=l):l=s[1];let[d,h]=(0,u.useState)(l),p;s[2]===Symbol.for("react.memo_cache_sentinel")?(p=o(()=>({close:o(()=>{h(H)},"close"),deleteChat:o(t=>{h(e=>{let i=$(e.sessions,t);return{...e,activeId:e.activeId===t?i.at(-1)?.id:e.activeId,open:i.length===0?!1:e.open,sessions:i}})},"deleteChat"),newChat:o(t=>{h(e=>m(e,t))},"newChat"),openAssistant:o(t=>{h(e=>{let i=e.activeId===void 0?void 0:v(e.sessions,e.activeId);return t?.ask!==void 0||i===void 0||(t?.shardKey??"")!==(i.shardKey??"")?m(e,t):{...e,draft:t?.draft===void 0?e.draft:{id:e.seq+1,text:t.draft},open:!0,sessions:t?.schema===void 0?e.sessions:O(e.sessions,i.id,t.schema),seq:e.seq+1}})},"openAssistant"),rebindShard:o((t,e)=>{h(i=>{let r=i.activeId===void 0?void 0:v(i.sessions,i.activeId);return!i.open||r===void 0||(r.shardKey??"")!==t||t===e?i:r.turns.length===0?{...i,sessions:U(i.sessions,r.id,e)}:m(i,{shardKey:e,title:r.name})})},"rebindShard"),requestInsert:o(t=>{h(e=>({...e,insertRequest:{id:e.seq+1,sql:t},seq:e.seq+1}))},"requestInsert"),setHasEditor:o(t=>{h(e=>e.hasEditor===t?e:{...e,hasEditor:t})},"setHasEditor"),takeInsert:o(t=>{h(e=>e.insertRequest?.id===t?{...e,insertRequest:void 0}:e)},"takeInsert"),selectChat:o(t=>{h(e=>({...e,activeId:t,open:!0}))},"selectChat"),branchFrom:o((t,e)=>{h(i=>{let r=v(i.sessions,t);if(r===void 0)return i;let y=m(i,{schema:r.schema,shardKey:r.shardKey,title:r.name});return{...y,sessions:E(y.sessions,y.activeId??"",r.turns.slice(0,e+1))}})},"branchFrom"),setTurns:o((t,e)=>{h(i=>{let r=v(i.sessions,t);return r===void 0?i:{...i,sessions:E(i.sessions,t,typeof e=="function"?e(r.turns):e)}})},"setTurns"),toggle:o(()=>{h(M)},"toggle"),truncateFrom:o((t,e)=>{h(i=>{let r=v(i.sessions,t);return r===void 0?i:{...i,sessions:E(i.sessions,t,r.turns.slice(0,e))}})},"truncateFrom"),takeAsk:o(t=>{h(e=>e.pendingAsk?.id===t?{...e,pendingAsk:void 0}:e)},"takeAsk")}),"c"),s[2]=p):p=s[2];let[I]=(0,u.useState)(p),g=_.data?.available!==!0,f;s[3]!==I||s[4]!==d.activeId||s[5]!==d.draft||s[6]!==d.hasEditor||s[7]!==d.insertRequest||s[8]!==d.open||s[9]!==d.pendingAsk||s[10]!==d.sessions||s[11]!==g?(f={...I,activeId:d.activeId,draft:d.draft,hasEditor:d.hasEditor,insertRequest:d.insertRequest,open:d.open,pendingAsk:d.pendingAsk,sessions:d.sessions,unavailable:g},s[3]=I,s[4]=d.activeId,s[5]=d.draft,s[6]=d.hasEditor,s[7]=d.insertRequest,s[8]=d.open,s[9]=d.pendingAsk,s[10]=d.sessions,s[11]=g,s[12]=f):f=s[12];let k=f,q;return s[13]!==a||s[14]!==k?(q=(0,S.jsx)(x,{value:k,children:a}),s[13]=a,s[14]=k,s[15]=q):q=s[15],q},"P"),B=o(()=>(0,u.use)(x),"Q");function H(n){return{...n,open:!1}}o(H,"$");function M(n){return!n.open&&n.activeId===void 0?m(n,void 0):{...n,open:!n.open}}o(M,"j");export{z as a,B as b};
1
+ import{a as R}from"./chunk-LYVYUTQY.js";import{c as K}from"./chunk-KE7ZGUGO.js";import{a as N}from"./chunk-A6TVTNKO.js";import{a as C,b as F}from"./chunk-ADABTCDI.js";import{a as o,d as A}from"./chunk-5PEAXTYQ.js";var b=A(N(),1),u=A(C(),1);var S=A(F(),1);var x=(0,u.createContext)(void 0),w={},T="New chat",j=o((n,s)=>({id:n,name:s?.title??T,schema:s?.schema??[],shardKey:s?.shardKey,suggestions:s?.suggestions??[],turns:[]}),"F"),D=o((n,s)=>[...n.sessions,s].slice(-10),"T"),m=o((n,s)=>{let a=`chat-${String(n.seq+1)}`;return{activeId:a,draft:s?.draft===void 0?void 0:{id:n.seq+1,text:s.draft},hasEditor:n.hasEditor,insertRequest:void 0,open:!0,pendingAsk:s?.ask===void 0?void 0:{id:n.seq+1,sessionId:a,text:s.ask},seq:n.seq+1,sessions:D(n,j(a,s))}},"f"),v=o((n,s)=>n.find(a=>a.id===s),"l"),O=o((n,s,a)=>n.map(c=>c.id===s?{...c,schema:a}:c),"D"),U=o((n,s,a)=>n.map(c=>c.id===s?{...c,schema:[],shardKey:a}:c),"O"),$=o((n,s)=>n.filter(a=>a.id!==s),"U"),E=o((n,s,a)=>n.map(c=>c.id===s?{...c,turns:a}:c),"y"),z=o(n=>{let s=(0,b.c)(16),{children:a}=n,c;s[0]===Symbol.for("react.memo_cache_sentinel")?(c={shardKey:""},s[0]=c):c=s[0];let _=K(R.aiAvailable,w,c),l;s[1]===Symbol.for("react.memo_cache_sentinel")?(l={activeId:void 0,draft:void 0,hasEditor:!1,insertRequest:void 0,open:!1,pendingAsk:void 0,seq:0,sessions:[]},s[1]=l):l=s[1];let[d,h]=(0,u.useState)(l),p;s[2]===Symbol.for("react.memo_cache_sentinel")?(p=o(()=>({close:o(()=>{h(H)},"close"),deleteChat:o(t=>{h(e=>{let i=$(e.sessions,t);return{...e,activeId:e.activeId===t?i.at(-1)?.id:e.activeId,open:i.length===0?!1:e.open,sessions:i}})},"deleteChat"),newChat:o(t=>{h(e=>m(e,t))},"newChat"),openAssistant:o(t=>{h(e=>{let i=e.activeId===void 0?void 0:v(e.sessions,e.activeId);return t?.ask!==void 0||i===void 0||(t?.shardKey??"")!==(i.shardKey??"")?m(e,t):{...e,draft:t?.draft===void 0?e.draft:{id:e.seq+1,text:t.draft},open:!0,sessions:t?.schema===void 0?e.sessions:O(e.sessions,i.id,t.schema),seq:e.seq+1}})},"openAssistant"),rebindShard:o((t,e)=>{h(i=>{let r=i.activeId===void 0?void 0:v(i.sessions,i.activeId);return!i.open||r===void 0||(r.shardKey??"")!==t||t===e?i:r.turns.length===0?{...i,sessions:U(i.sessions,r.id,e)}:m(i,{shardKey:e,title:r.name})})},"rebindShard"),requestInsert:o(t=>{h(e=>({...e,insertRequest:{id:e.seq+1,sql:t},seq:e.seq+1}))},"requestInsert"),setHasEditor:o(t=>{h(e=>e.hasEditor===t?e:{...e,hasEditor:t})},"setHasEditor"),takeInsert:o(t=>{h(e=>e.insertRequest?.id===t?{...e,insertRequest:void 0}:e)},"takeInsert"),selectChat:o(t=>{h(e=>({...e,activeId:t,open:!0}))},"selectChat"),branchFrom:o((t,e)=>{h(i=>{let r=v(i.sessions,t);if(r===void 0)return i;let y=m(i,{schema:r.schema,shardKey:r.shardKey,title:r.name});return{...y,sessions:E(y.sessions,y.activeId??"",r.turns.slice(0,e+1))}})},"branchFrom"),setTurns:o((t,e)=>{h(i=>{let r=v(i.sessions,t);return r===void 0?i:{...i,sessions:E(i.sessions,t,typeof e=="function"?e(r.turns):e)}})},"setTurns"),toggle:o(()=>{h(M)},"toggle"),truncateFrom:o((t,e)=>{h(i=>{let r=v(i.sessions,t);return r===void 0?i:{...i,sessions:E(i.sessions,t,r.turns.slice(0,e))}})},"truncateFrom"),takeAsk:o(t=>{h(e=>e.pendingAsk?.id===t?{...e,pendingAsk:void 0}:e)},"takeAsk")}),"c"),s[2]=p):p=s[2];let[I]=(0,u.useState)(p),g=_.data?.available!==!0,f;s[3]!==I||s[4]!==d.activeId||s[5]!==d.draft||s[6]!==d.hasEditor||s[7]!==d.insertRequest||s[8]!==d.open||s[9]!==d.pendingAsk||s[10]!==d.sessions||s[11]!==g?(f={...I,activeId:d.activeId,draft:d.draft,hasEditor:d.hasEditor,insertRequest:d.insertRequest,open:d.open,pendingAsk:d.pendingAsk,sessions:d.sessions,unavailable:g},s[3]=I,s[4]=d.activeId,s[5]=d.draft,s[6]=d.hasEditor,s[7]=d.insertRequest,s[8]=d.open,s[9]=d.pendingAsk,s[10]=d.sessions,s[11]=g,s[12]=f):f=s[12];let k=f,q;return s[13]!==a||s[14]!==k?(q=(0,S.jsx)(x,{value:k,children:a}),s[13]=a,s[14]=k,s[15]=q):q=s[15],q},"P"),B=o(()=>(0,u.use)(x),"Q");function H(n){return{...n,open:!1}}o(H,"$");function M(n){return!n.open&&n.activeId===void 0?m(n,void 0):{...n,open:!n.open}}o(M,"j");export{z as a,B as b};
@@ -0,0 +1,5 @@
1
+ import{b as w}from"./chunk-UV6GPH2E.js";import{a as $}from"./chunk-2G5OZPH5.js";import{a as I,b as S,c as A,d as l,e as c,f as d}from"./chunk-J3ZEO3PJ.js";import{b as v}from"./chunk-PSBRO6JX.js";import{a as T,e as k}from"./chunk-TN4Z3P6S.js";import{B as N,x as y}from"./chunk-PN7JHEYW.js";import{a as W,b as j}from"./chunk-ADABTCDI.js";import{a,d as b}from"./chunk-5PEAXTYQ.js";var E=b(W(),1);var r=b(j(),1);var O={ERROR:"error",INFO:"info",WARN:"warning"},U=a(s=>{let n=typeof s.metadata.table=="string"?s.metadata.table:void 0;return{description:`${s.detail} ${s.remediation}`,entity:n,issueType:s.title,key:s.cacheKey,level:O[s.level],...s.suppressed===void 0?{}:{suppressed:{file:s.suppressed.file,line:s.suppressed.line,reason:s.suppressed.reason}}}},"P"),B=["error","warning","info"],D={error:"bg-destructive",info:"bg-info",warning:"bg-warning"},H=a((s,n)=>({error:s("Errors"),info:s("Info"),warning:s("Warnings")})[n],"H"),L=a((s,n,i)=>({error:s("{count} errors",{count:i}),info:s("{count} suggestions",{count:i}),warning:s("{count} warnings",{count:i})})[n],"I"),z=a((s,n)=>({error:s("No errors detected"),info:s("No suggestions"),warning:s("No warnings detected")})[n],"W"),F=a(s=>{let n={error:0,info:0,warning:0};for(let i of s??[])n[i.level]+=1;return n},"j"),X=a(({error:s=null,errorSource:n,rows:i,shardKey:m,testId:o,toolbar:f})=>{let t=N(),p=v(),g=p!==void 0&&!p.unavailable,[u,R]=(0,E.useState)("error"),C=F(i),h=(i??[]).filter(e=>e.suppressed!==void 0).length,x=(i??[]).filter(e=>e.level===u),K=a(e=>{R(e.currentTarget.dataset.level)},"y");return(0,r.jsxs)("div",{className:"flex flex-col gap-3","data-testid":o,children:[(0,r.jsxs)("div",{className:"flex border-b border-border",role:"tablist",children:[B.map(e=>(0,r.jsxs)("button",{"aria-selected":u===e,className:"flex min-w-32 flex-col gap-0.5 border-b-2 border-transparent px-4 py-2 text-start outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 aria-selected:border-foreground","data-level":e,"data-testid":`${o}-tab-${e}`,onClick:K,role:"tab",type:"button",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:y("size-2 rounded-sm",D[e])}),H(t,e)]}),(0,r.jsx)("span",{className:"ps-4 text-xs text-muted-foreground",children:L(t,e,C[e])})]},e)),h>0&&(0,r.jsx)("span",{className:"ms-auto self-center px-4 text-xs text-muted-foreground","data-testid":`${o}-suppressed-count`,children:t("{count} suppressed",{count:h})})]}),f!==void 0&&(0,r.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:f}),s!==null&&(0,r.jsx)($,{error:n??s,shardKey:m,testId:`${o}-error`}),(0,r.jsx)(T,{className:"overflow-hidden py-0",children:(0,r.jsx)(k,{className:"px-0",children:(0,r.jsxs)(I,{children:[(0,r.jsx)(S,{children:(0,r.jsxs)(l,{children:[(0,r.jsx)(c,{children:t("Issue type")}),(0,r.jsx)(c,{children:t("Entity/item")}),(0,r.jsx)(c,{children:t("Description")})]})}),(0,r.jsx)(A,{children:x.length===0?(0,r.jsx)(l,{children:(0,r.jsxs)(d,{className:"h-40 text-center align-middle text-muted-foreground",colSpan:3,"data-testid":`${o}-empty`,children:[(0,r.jsx)("span",{className:"block text-sm font-medium text-foreground",children:z(t,u)}),(0,r.jsx)("span",{className:"block text-sm",children:t("Nothing to report for this deployment.")})]})}):x.map(e=>(0,r.jsxs)(l,{children:[(0,r.jsxs)(d,{className:"font-medium text-foreground",children:[e.issueType,e.suppressed!==void 0&&(0,r.jsx)(w,{className:"ms-2","data-testid":"advisor-suppressed-badge",title:e.suppressed.reason,variant:"outline",children:t("Suppressed")})]}),(0,r.jsx)(d,{className:"font-mono text-xs text-muted-foreground",children:e.entity??"\u2014"}),(0,r.jsxs)(d,{className:"text-muted-foreground",children:[(0,r.jsx)("span",{children:e.description}),e.suppressed!==void 0&&(0,r.jsx)("span",{className:"mt-1 block text-xs","data-testid":"advisor-suppressed-reason",children:t("Suppressed at {location}: {reason}",{location:`${e.suppressed.file}:${String(e.suppressed.line)}`,reason:e.suppressed.reason})}),(e.action!==void 0||g)&&(0,r.jsxs)("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[e.action,g&&(0,r.jsx)("button",{className:"text-xs underline outline-none focus-visible:ring-1 focus-visible:ring-ring","data-testid":"advisor-ask-assistant",onClick:a(()=>{p.openAssistant({ask:t(`The Lunora advisor reported: {finding}.
2
+
3
+ {description}
4
+
5
+ What does this mean for my app, and how should I fix it?`,{description:e.description,finding:e.entity===void 0?e.issueType:t("{issueType} on {entity}",{entity:e.entity,issueType:e.issueType})}),shardKey:m,suggestions:[t("How do I verify this is fixed?")],title:e.issueType})},"onClick"),type:"button",children:t("Ask the assistant")})]})]})]},e.key))})]})})})]})},"Q");export{U as a,X as b};
@@ -1 +1 @@
1
- import{a as D}from"./chunk-2LKJSQKF.js";import{a as L}from"./chunk-S3TDGFRE.js";import{b as S}from"./chunk-UV6GPH2E.js";import"./chunk-L27FKJTG.js";import{a as T,b as k,c as A,d as g,e as c,f as l}from"./chunk-J3ZEO3PJ.js";import"./chunk-EOFWXI3T.js";import{a as C}from"./chunk-LYVYUTQY.js";import{c as w}from"./chunk-UN3QTZ6X.js";import{a as I,e as $}from"./chunk-TN4Z3P6S.js";import"./chunk-5KQSRLQP.js";import"./chunk-ZPQBVYNN.js";import{B as b}from"./chunk-PN7JHEYW.js";import"./chunk-PDBW6GTJ.js";import{a as _}from"./chunk-A6TVTNKO.js";import{b as j}from"./chunk-ADABTCDI.js";import{a as f,d as y}from"./chunk-5PEAXTYQ.js";var O=y(_(),1);var t=y(j(),1);var E="container:",M={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},B=f(e=>{let n=e.indexOf(":");if(n===-1)return{event:e.trim()};let r=e.slice(n+1).trim(),a=e.slice(0,n).trim();return r===""?{event:a}:{detail:r,event:a}},"B"),P=f(e=>{let n=new Map;for(let r of e){let a=r.functionPath??"";if(!a.startsWith(E))continue;let i=a.slice(E.length);if(i==="")continue;let s=JSON.stringify([i,r.instance??""]),o=n.get(s);if(o!==void 0&&o.timestamp>=r.timestamp)continue;let{detail:p,event:d}=B(r.message);n.set(s,{detail:p,event:d,exitCode:r.exitCode,instance:r.instance,level:r.level,name:i,state:M[d]??"unknown",timestamp:r.timestamp})}return[...n.values()].toSorted((r,a)=>r.name.localeCompare(a.name)||(r.instance??"").localeCompare(a.instance??""))},"D"),W={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},q=f(e=>{let{entries:n}=e??{};return Array.isArray(n)?n:[]},"P"),V=f(()=>{let e=(0,O.c)(19),n=b(),r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},a={live:!0,shardKey:""},e[0]=r,e[1]=a):(r=e[0],a=e[1]);let{data:i,error:s,liveError:o}=w(C.getLogs,r,a),p=i!==void 0,d;if(e[2]!==i||e[3]!==s||e[4]!==o||e[5]!==p||e[6]!==n){let N=P(q(i)),x;e[8]!==s?(x=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:s}),e[8]=s,e[9]=x):x=e[9];let m;e[10]!==n?(m=n("Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per instance \u2014 ports and health checks aren't carried in that stream."),e[10]=n,e[11]=m):m=e[11];let u;e[12]!==m?(u=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:m}),e[12]=m,e[13]=u):u=e[13];let h;e[14]!==o?(h=(0,t.jsx)(D,{message:o,prefix:"containers"}),e[14]=o,e[15]=h):h=e[15];let v;e[16]!==u||e[17]!==h?(v=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[u,h]}),e[16]=u,e[17]=h,e[18]=v):v=e[18],d=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[x,v,p&&N.length===0?(0,t.jsx)(L,{description:n("No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error."),testId:"containers-empty",title:n("No container activity")}):(0,t.jsx)(I,{className:"overflow-hidden py-0",children:(0,t.jsx)($,{className:"px-0",children:(0,t.jsxs)(T,{"data-testid":"containers-table",children:[(0,t.jsx)(k,{children:(0,t.jsxs)(g,{children:[(0,t.jsx)(c,{children:n("Container")}),(0,t.jsx)(c,{children:n("Instance")}),(0,t.jsx)(c,{children:n("State")}),(0,t.jsx)(c,{children:n("Last event")}),(0,t.jsx)(c,{children:n("Detail")}),(0,t.jsx)(c,{children:n("Exit")}),(0,t.jsx)(c,{children:n("When")})]})}),(0,t.jsx)(A,{children:N.map(F)})]})})})]}),e[2]=i,e[3]=s,e[4]=o,e[5]=p,e[6]=n,e[7]=d}else d=e[7];return d},"q");function F(e){return(0,t.jsxs)(g,{"data-testid":`containers-row-${e.name}${e.instance===void 0?"":`-${e.instance}`}`,children:[(0,t.jsx)(l,{className:"font-mono text-xs",children:e.name}),(0,t.jsx)(l,{className:"max-w-40 truncate font-mono text-xs text-muted-foreground",title:e.instance,children:e.instance??"\u2014"}),(0,t.jsx)(l,{children:(0,t.jsx)(S,{variant:W[e.state],children:e.state})}),(0,t.jsx)(l,{className:"font-mono text-xs text-muted-foreground",children:e.event}),(0,t.jsx)(l,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"\u2014"}),(0,t.jsx)(l,{className:"font-mono text-xs tabular-nums text-muted-foreground",children:e.exitCode??"\u2014"}),(0,t.jsx)(l,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]},`${e.name}/${e.instance??""}`)}f(F,"j");export{V as default};
1
+ import{a as D}from"./chunk-2LKJSQKF.js";import{a as L}from"./chunk-S3TDGFRE.js";import{b as S}from"./chunk-UV6GPH2E.js";import"./chunk-L27FKJTG.js";import{a as T,b as k,c as A,d as g,e as c,f as l}from"./chunk-J3ZEO3PJ.js";import"./chunk-EOFWXI3T.js";import{a as C}from"./chunk-LYVYUTQY.js";import{c as w}from"./chunk-KE7ZGUGO.js";import{a as I,e as $}from"./chunk-TN4Z3P6S.js";import"./chunk-UK5OOCLQ.js";import"./chunk-ZPQBVYNN.js";import{B as b}from"./chunk-PN7JHEYW.js";import"./chunk-PDBW6GTJ.js";import{a as _}from"./chunk-A6TVTNKO.js";import{b as j}from"./chunk-ADABTCDI.js";import{a as f,d as y}from"./chunk-5PEAXTYQ.js";var O=y(_(),1);var t=y(j(),1);var E="container:",M={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},B=f(e=>{let n=e.indexOf(":");if(n===-1)return{event:e.trim()};let r=e.slice(n+1).trim(),a=e.slice(0,n).trim();return r===""?{event:a}:{detail:r,event:a}},"B"),P=f(e=>{let n=new Map;for(let r of e){let a=r.functionPath??"";if(!a.startsWith(E))continue;let i=a.slice(E.length);if(i==="")continue;let s=JSON.stringify([i,r.instance??""]),o=n.get(s);if(o!==void 0&&o.timestamp>=r.timestamp)continue;let{detail:p,event:d}=B(r.message);n.set(s,{detail:p,event:d,exitCode:r.exitCode,instance:r.instance,level:r.level,name:i,state:M[d]??"unknown",timestamp:r.timestamp})}return[...n.values()].toSorted((r,a)=>r.name.localeCompare(a.name)||(r.instance??"").localeCompare(a.instance??""))},"D"),W={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},q=f(e=>{let{entries:n}=e??{};return Array.isArray(n)?n:[]},"P"),V=f(()=>{let e=(0,O.c)(19),n=b(),r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},a={live:!0,shardKey:""},e[0]=r,e[1]=a):(r=e[0],a=e[1]);let{data:i,error:s,liveError:o}=w(C.getLogs,r,a),p=i!==void 0,d;if(e[2]!==i||e[3]!==s||e[4]!==o||e[5]!==p||e[6]!==n){let N=P(q(i)),x;e[8]!==s?(x=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:s}),e[8]=s,e[9]=x):x=e[9];let m;e[10]!==n?(m=n("Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per instance \u2014 ports and health checks aren't carried in that stream."),e[10]=n,e[11]=m):m=e[11];let u;e[12]!==m?(u=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:m}),e[12]=m,e[13]=u):u=e[13];let h;e[14]!==o?(h=(0,t.jsx)(D,{message:o,prefix:"containers"}),e[14]=o,e[15]=h):h=e[15];let v;e[16]!==u||e[17]!==h?(v=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[u,h]}),e[16]=u,e[17]=h,e[18]=v):v=e[18],d=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[x,v,p&&N.length===0?(0,t.jsx)(L,{description:n("No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error."),testId:"containers-empty",title:n("No container activity")}):(0,t.jsx)(I,{className:"overflow-hidden py-0",children:(0,t.jsx)($,{className:"px-0",children:(0,t.jsxs)(T,{"data-testid":"containers-table",children:[(0,t.jsx)(k,{children:(0,t.jsxs)(g,{children:[(0,t.jsx)(c,{children:n("Container")}),(0,t.jsx)(c,{children:n("Instance")}),(0,t.jsx)(c,{children:n("State")}),(0,t.jsx)(c,{children:n("Last event")}),(0,t.jsx)(c,{children:n("Detail")}),(0,t.jsx)(c,{children:n("Exit")}),(0,t.jsx)(c,{children:n("When")})]})}),(0,t.jsx)(A,{children:N.map(F)})]})})})]}),e[2]=i,e[3]=s,e[4]=o,e[5]=p,e[6]=n,e[7]=d}else d=e[7];return d},"q");function F(e){return(0,t.jsxs)(g,{"data-testid":`containers-row-${e.name}${e.instance===void 0?"":`-${e.instance}`}`,children:[(0,t.jsx)(l,{className:"font-mono text-xs",children:e.name}),(0,t.jsx)(l,{className:"max-w-40 truncate font-mono text-xs text-muted-foreground",title:e.instance,children:e.instance??"\u2014"}),(0,t.jsx)(l,{children:(0,t.jsx)(S,{variant:W[e.state],children:e.state})}),(0,t.jsx)(l,{className:"font-mono text-xs text-muted-foreground",children:e.event}),(0,t.jsx)(l,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"\u2014"}),(0,t.jsx)(l,{className:"font-mono text-xs tabular-nums text-muted-foreground",children:e.exitCode??"\u2014"}),(0,t.jsx)(l,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]},`${e.name}/${e.instance??""}`)}f(F,"j");export{V as default};