@lunora/studio 1.0.0-alpha.113 → 1.0.0-alpha.115
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/mount.js +1 -1
- package/dist/packem_chunks/AdvisorHealthPanel.js +1 -1
- package/dist/packem_chunks/ApiTab.js +1 -1
- package/dist/packem_chunks/AuditPanel.js +1 -1
- package/dist/packem_chunks/DeploymentHealthPanel.js +1 -1
- package/dist/packem_chunks/ExportImportPanel.js +1 -1
- package/dist/packem_chunks/FileBrowser.js +1 -1
- package/dist/packem_chunks/FunctionRunner.js +1 -1
- package/dist/packem_chunks/FunctionStatsPanel.js +1 -1
- package/dist/packem_chunks/HealthPanel.js +1 -1
- package/dist/packem_chunks/InsightsPanel.js +1 -1
- package/dist/packem_chunks/LogsPanel.js +1 -1
- package/dist/packem_chunks/MailPanel.js +1 -1
- package/dist/packem_chunks/MetricsPanel.js +1 -1
- package/dist/packem_chunks/NotificationsPanel.js +1 -1
- package/dist/packem_chunks/PitrPanel.js +1 -1
- package/dist/packem_chunks/SchemaViewer.js +1 -1
- package/dist/packem_chunks/SecurityAdvisorPanel.js +1 -1
- package/dist/packem_chunks/SettingsPanel.js +1 -1
- package/dist/packem_chunks/SqlEditorPanel.js +1 -1
- package/dist/packem_chunks/TableEditor.js +1 -1
- package/dist/packem_chunks/agents-panel.js +1 -1
- package/dist/packem_chunks/analytics-panel.js +1 -1
- package/dist/packem_chunks/auth-audit-panel.js +1 -1
- package/dist/packem_chunks/auth-config-panel.js +1 -1
- package/dist/packem_chunks/auth-sessions-panel.js +1 -1
- package/dist/packem_chunks/containers-panel.js +1 -1
- package/dist/packem_chunks/dashboards-panel.js +1 -1
- package/dist/packem_chunks/evals-panel.js +1 -1
- package/dist/packem_chunks/fanout-panel.js +1 -1
- package/dist/packem_chunks/flags-panel.js +1 -1
- package/dist/packem_chunks/issues-panel.js +1 -1
- package/dist/packem_chunks/kv-browser.js +1 -1
- package/dist/packem_chunks/log-drains-panel.js +1 -1
- package/dist/packem_chunks/migrations-route.js +1 -1
- package/dist/packem_chunks/organizations-panel.js +1 -1
- package/dist/packem_chunks/payments-panel.js +1 -1
- package/dist/packem_chunks/permissions-panel.js +1 -1
- package/dist/packem_chunks/queues-panel.js +1 -1
- package/dist/packem_chunks/rls-panel.js +1 -1
- package/dist/packem_chunks/schedule-panel.js +1 -1
- package/dist/packem_chunks/storage-rules-panel.js +1 -1
- package/dist/packem_chunks/subscriptions-panel.js +1 -1
- package/dist/packem_chunks/sync-client-panel.js +1 -1
- package/dist/packem_chunks/traces-panel.js +1 -1
- package/dist/packem_chunks/users-panel.js +1 -1
- package/dist/packem_chunks/vector-browser.js +1 -1
- package/dist/packem_chunks/workflows-panel.js +1 -1
- package/dist/packem_shared/{ApiDocsPanel-BL5lMig5.js → ApiDocsPanel-C_dZt4ve.js} +1 -1
- package/dist/packem_shared/{ApiReferencePanel-CkCFMCBb.js → ApiReferencePanel-6W_QfOlv.js} +1 -1
- package/dist/packem_shared/{CommandPalette-B5yLEABs.js → CommandPalette-BAiOc1hT.js} +1 -1
- package/dist/packem_shared/{DataBrowser-BnDIFN-S.js → DataBrowser-CrkvQAMf.js} +1 -1
- package/dist/packem_shared/{GlobalDataBrowser-DusjXzRF.js → GlobalDataBrowser-BHFgEqMl.js} +1 -1
- package/dist/packem_shared/{HomePanel-BcaHVBJh.js → HomePanel-B8U_LJkK.js} +1 -1
- package/dist/packem_shared/{MigrationsPanel-CCOENX4X.js → MigrationsPanel-CW4MNUa4.js} +1 -1
- package/dist/packem_shared/{OpenRpcReferencePanel-21OWMH45.js → OpenRpcReferencePanel-Cx-qwpZW.js} +1 -1
- package/dist/packem_shared/{ScheduledJobs-CiO3eXgI.js → ScheduledJobs-DRmOKtDa.js} +1 -1
- package/dist/packem_shared/Studio-k_HuJZYW.js +1 -0
- package/dist/packem_shared/{StudioApp-DCdbsciH.js → StudioApp-CWpwayvp.js} +1 -1
- package/dist/packem_shared/{advisor-view-C1KFTXSH.js → advisor-view-CqCG22DB.js} +1 -1
- package/dist/packem_shared/{data-grid-BFTQnkXq.js → data-grid-pjv4t5Yi.js} +1 -1
- package/dist/packem_shared/{error-alert-TYdKetJd.js → error-alert-CKqB2CiN.js} +1 -1
- package/dist/packem_shared/{grid-features-C_yXlMc_.js → grid-features-3wfN2PeE.js} +4 -4
- package/dist/packem_shared/{home-panel-BiJHXeDC.js → home-panel-DywiFhDs.js} +1 -1
- package/dist/packem_shared/{internal-CwaF9YNk.js → internal-7bgd8inO.js} +1 -1
- package/dist/packem_shared/{log-line-UnE93Ovi.js → log-line-D0XBZaDn.js} +1 -1
- package/dist/packem_shared/{recording-client-CKn4-vUx.js → recording-client-BPY8sYUl.js} +1 -1
- package/dist/packem_shared/{reference-view-CUIDzLf0.js → reference-view-DhxnzBtf.js} +1 -1
- package/dist/packem_shared/{result-chart-Ca3YLzt8.js → result-chart-Q-gVLi4_.js} +1 -1
- package/dist/packem_shared/{schema-diagram-DHD13TjS.js → schema-diagram-CPcjPZj3.js} +1 -1
- package/dist/packem_shared/{studio-B3eEcBK0.js → studio-BFvT56qK.js} +1 -1
- package/dist/packem_shared/{table-list-sidebar-Bluzd1_2.js → table-list-sidebar-BCxqrZ0s.js} +1 -1
- package/dist/packem_shared/{use-admin-query-P0RJrjsD.js → use-admin-query-DV9xmFl8.js} +1 -1
- package/dist/packem_shared/{use-async-submit-DdLd0MdK.js → use-async-submit-C9xXjXWX.js} +1 -1
- package/dist/packem_shared/{use-auth-config-z3KRWAqD.js → use-auth-config-DIAyVsa3.js} +1 -1
- package/dist/packem_shared/{use-open-trace-4tIa0SXZ.js → use-open-trace-IfIlKEWd.js} +1 -1
- package/dist/packem_shared/{use-sql-assistant-CP90nLLh.js → use-sql-assistant-DFO2i-n-.js} +1 -1
- package/dist/standalone/chunk-22WJHOC4.js +11 -0
- package/dist/standalone/{chunk-ZN6KUP3O.js → chunk-2CHFHPR3.js} +1 -1
- package/dist/standalone/{chunk-OG57FC7W.js → chunk-2EJQ7SPV.js} +1 -1
- package/dist/standalone/{chunk-FSWPREH3.js → chunk-2Q7HAFRK.js} +1 -1
- package/dist/standalone/{chunk-44WNSIGQ.js → chunk-2UIT2HC2.js} +1 -1
- package/dist/standalone/{chunk-YUWMB6EV.js → chunk-2UWKGSEA.js} +1 -1
- package/dist/standalone/{chunk-ZQLIKKIY.js → chunk-3IXTF53Q.js} +1 -1
- package/dist/standalone/{chunk-J6MNOKO5.js → chunk-44FJEOAY.js} +1 -1
- package/dist/standalone/{chunk-26VREVWU.js → chunk-5XMZP64Z.js} +1 -1
- package/dist/standalone/{chunk-45YWYMD5.js → chunk-6MRGARL5.js} +1 -1
- package/dist/standalone/{chunk-3F5I435D.js → chunk-6UOC4ZJL.js} +1 -1
- package/dist/standalone/{chunk-FBAZHG35.js → chunk-6ZSAMAYN.js} +1 -1
- package/dist/standalone/{chunk-BORG7WUC.js → chunk-7IQT5M4O.js} +1 -1
- package/dist/standalone/{chunk-KQIHXYE6.js → chunk-7TFEJVX4.js} +1 -1
- package/dist/standalone/{chunk-3QB5JI32.js → chunk-7W6TQTW7.js} +1 -1
- package/dist/standalone/{chunk-4MAJFNON.js → chunk-A7WKYEQ4.js} +1 -1
- package/dist/standalone/chunk-AG265V66.js +1 -0
- package/dist/standalone/{chunk-6SAAMM4S.js → chunk-BE76GAFE.js} +1 -1
- package/dist/standalone/{chunk-6ZPTNC34.js → chunk-BKM6PMSO.js} +1 -1
- package/dist/standalone/{chunk-D7DUQS2Y.js → chunk-CE7WVPLK.js} +1 -1
- package/dist/standalone/{chunk-MSFUDXBA.js → chunk-D4HJ2VM2.js} +1 -1
- package/dist/standalone/{chunk-FLCK2WWQ.js → chunk-DC5AAWSA.js} +1 -1
- package/dist/standalone/{chunk-6NJAHOGO.js → chunk-DEGERMXH.js} +1 -1
- package/dist/standalone/{chunk-JURAVSE7.js → chunk-E6P2ERQV.js} +1 -1
- package/dist/standalone/{chunk-TLPWZ5NI.js → chunk-EQSVW6LZ.js} +1 -1
- package/dist/standalone/{chunk-T2LDA6WP.js → chunk-FCEPVFIJ.js} +1 -1
- package/dist/standalone/chunk-FEEZPSMA.js +1 -0
- package/dist/standalone/{chunk-25OIGX2A.js → chunk-FEW2WNS7.js} +1 -1
- package/dist/standalone/{chunk-KFZ37KQP.js → chunk-FRSTZO5P.js} +1 -1
- package/dist/standalone/{chunk-X6Q5DWLZ.js → chunk-GKHUQDVI.js} +1 -1
- package/dist/standalone/{chunk-SL5R7WBN.js → chunk-H2WBIULE.js} +1 -1
- package/dist/standalone/{chunk-WIG3HCUJ.js → chunk-H3M57MCN.js} +1 -1
- package/dist/standalone/{chunk-UIF57LBO.js → chunk-H4SLAZAN.js} +1 -1
- package/dist/standalone/{chunk-6FWN26RH.js → chunk-HLEXBOCL.js} +1 -1
- package/dist/standalone/{chunk-QZ55OWAB.js → chunk-HLHO5AHK.js} +1 -1
- package/dist/standalone/{chunk-MOUI44OT.js → chunk-INLHZKCS.js} +1 -1
- package/dist/standalone/{chunk-L7CJ5PGH.js → chunk-JACBQWRB.js} +1 -1
- package/dist/standalone/{chunk-YS7HEZC2.js → chunk-KEMHRM53.js} +1 -1
- package/dist/standalone/{chunk-GIRZD3UB.js → chunk-KOH52XKG.js} +1 -1
- package/dist/standalone/{chunk-C5E5PLJT.js → chunk-LDVDE3LE.js} +1 -1
- package/dist/standalone/{chunk-3RYEUXY2.js → chunk-LFEDP3Y6.js} +1 -1
- package/dist/standalone/{chunk-V6QPVFDL.js → chunk-MG7VPUFA.js} +1 -1
- package/dist/standalone/{chunk-OE4KGVJW.js → chunk-MLYZZD5C.js} +1 -1
- package/dist/standalone/{chunk-WHRG6S5P.js → chunk-NSR345ID.js} +1 -1
- package/dist/standalone/{chunk-IWNVQHF7.js → chunk-OAXOITHK.js} +1 -1
- package/dist/standalone/chunk-OQS4HFKC.js +1 -0
- package/dist/standalone/{chunk-XGIG4EDG.js → chunk-OTZRXUHF.js} +1 -1
- package/dist/standalone/{chunk-PJDKRUWT.js → chunk-PNLUMMXO.js} +1 -1
- package/dist/standalone/{chunk-AOE75NAT.js → chunk-Q2G22JHG.js} +1 -1
- package/dist/standalone/{chunk-BELLXCN7.js → chunk-RUIWLLAI.js} +1 -1
- package/dist/standalone/{chunk-S77D4SHR.js → chunk-RVQRXKRJ.js} +1 -1
- package/dist/standalone/{chunk-JVAYDDMK.js → chunk-SCXAZ74Y.js} +1 -1
- package/dist/standalone/{chunk-2DC6F7NH.js → chunk-SLOB2B2T.js} +1 -1
- package/dist/standalone/{chunk-LT4XQDD2.js → chunk-SM764GPA.js} +1 -1
- package/dist/standalone/{chunk-5T7KRUPX.js → chunk-U2KBAKZ6.js} +1 -1
- package/dist/standalone/chunk-U7J3LXJ4.js +6 -0
- package/dist/standalone/{chunk-KEKIGANB.js → chunk-UCA5MYCL.js} +1 -1
- package/dist/standalone/{chunk-GPP4VSUO.js → chunk-UJXKS27L.js} +1 -1
- package/dist/standalone/{chunk-C7E4I7JZ.js → chunk-UKIDHICQ.js} +1 -1
- package/dist/standalone/{chunk-5NRQIDQA.js → chunk-V2KCESII.js} +1 -1
- package/dist/standalone/{chunk-OOBJFXYB.js → chunk-W5CYX66B.js} +1 -1
- package/dist/standalone/{chunk-2BDM6HNL.js → chunk-WSNFV7ZW.js} +1 -1
- package/dist/standalone/{chunk-OLQWBGKT.js → chunk-YYFHDYYT.js} +1 -1
- package/dist/standalone/{chunk-PHHMPYEP.js → chunk-ZHDCWHRT.js} +1 -1
- package/dist/standalone/{chunk-CEPMQS24.js → chunk-ZIHYXKQJ.js} +1 -1
- package/dist/standalone/{chunk-DL3UOEWN.js → chunk-ZIYO55T2.js} +1 -1
- package/dist/standalone/{chunk-6JGXSMKV.js → chunk-ZNNKKJRT.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +5 -5
- package/dist/packem_shared/Studio-CHmLCjBR.js +0 -1
- package/dist/standalone/chunk-GZMBMNL3.js +0 -6
- package/dist/standalone/chunk-RBUVNO22.js +0 -1
- package/dist/standalone/chunk-SMKRXJUC.js +0 -1
- package/dist/standalone/chunk-T6HLABZW.js +0 -1
- package/dist/standalone/chunk-TBXK3FKP.js +0 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Qe}from"./chunk-XGIG4EDG.js";import{a as Me,b as Re}from"./chunk-7SROZWKL.js";import"./chunk-AECDJKXB.js";import"./chunk-CN2AINNY.js";import"./chunk-CP4ZFBVW.js";import{a as we}from"./chunk-NXXGISFB.js";import"./chunk-EDHW2EEG.js";import"./chunk-ZSOLGJFC.js";import"./chunk-DUDQV6XJ.js";import"./chunk-VZCS5GXZ.js";import"./chunk-DKSLOJDQ.js";import"./chunk-JV7KTJPY.js";import{a as He}from"./chunk-CKTKI4IY.js";import{a as Xe}from"./chunk-6FWN26RH.js";import{b as Je}from"./chunk-P52BY657.js";import{e as Ue}from"./chunk-4YTSKL4R.js";import"./chunk-VNTEQQPP.js";import{P as Ae}from"./chunk-AOAJGSYZ.js";import"./chunk-INQICZYC.js";import"./chunk-TFMQSCGC.js";import{a as me}from"./chunk-BWEXJENB.js";import"./chunk-74ASA4WU.js";import"./chunk-XQS7KSHL.js";import{b as ze}from"./chunk-SPDZUX4P.js";import"./chunk-7PIHTTND.js";import{a as je}from"./chunk-VDW32UET.js";import{f as Ve}from"./chunk-TBXK3FKP.js";import"./chunk-RCZTUWG3.js";import{a as We}from"./chunk-UANVABQG.js";import{a as qe,b as Pe,c as Ge,d as Ke,e as Le}from"./chunk-IYWVSMAY.js";import{d as Fe,f as Ee,g as $e,h as Oe,o as ue}from"./chunk-6ZPTNC34.js";import"./chunk-VYW2PAWC.js";import{a as r,d as Be,e as at,f as nt,g as st,i as De}from"./chunk-R5ZTCHCE.js";var Ce=Be(nt(),1);var x=Be(at(),1);var t=Be(st(),1);var rt=Ee(je.listTables),ot=Ee(je.listTableIndexes),it=Ee(je.readTablePage),dt=Ee(je.describeTables),ct={},Ye=[],mt=r(s=>{let e=(0,Ce.c)(74),{initialShardKey:u,initialTable:n}=s,l=Ve(),[a,m]=(0,x.useState)("graph"),{queryShardKey:c,setShardKey:d,shardKey:g}=He(u),[o,p]=(0,x.useState)(""),[i,v]=(0,x.useState)(null),[b,P]=(0,x.useState)(null),_;e[0]===Symbol.for("react.memo_cache_sentinel")?(_={},e[0]=_):_=e[0];let[L,y]=(0,x.useState)(_),G;e[1]===Symbol.for("react.memo_cache_sentinel")?(G={},e[1]=G):G=e[1];let[E,M]=(0,x.useState)(G),[S,C]=(0,x.useState)(null),F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F={},e[2]=F):F=e[2];let[$,he]=(0,x.useState)(F),Q;e[3]===Symbol.for("react.memo_cache_sentinel")?(Q={},e[3]=Q):Q=e[3];let[I,K]=(0,x.useState)(Q),[k,pe]=(0,x.useState)(null),[B,oe]=(0,x.useState)(null),Y;e[4]===Symbol.for("react.memo_cache_sentinel")?(Y={},e[4]=Y):Y=e[4];let[W,xe]=(0,x.useState)(Y),[J,ie]=(0,x.useState)(null),ve;e[5]!==l?(ve=r(async h=>{P(null);try{let w=await l.query(rt,{},$e(h));Je(h),v(w),y({}),M({}),C(null),he(N=>Object.fromEntries(Object.entries(N).filter(q=>{let[A]=q;return A!==h}))),K(N=>Object.fromEntries(Object.entries(N).filter(q=>{let[A]=q;return A!==h})))}catch(w){let N=w;v(null),P(Oe(N))}},"ve"),e[5]=l,e[6]=ve):ve=e[6];let O=ve,Z;e[7]!==l?(Z=r(async()=>{oe(null);try{pe(await l.listGlobalTables())}catch(h){let w=h;pe(null),oe(Oe(w))}},"Z"),e[7]=l,e[8]=Z):Z=e[8];let ee=Z,de,D;e[9]!==c||e[10]!==O||e[11]!==ee?(de=r(()=>{ue(O(c)),ue(ee())},"de"),D=[O,ee,c],e[9]=c,e[10]=O,e[11]=ee,e[12]=de,e[13]=D):(de=e[12],D=e[13]),(0,x.useEffect)(de,D);let te;e[14]!==l||e[15]!==L||e[16]!==S||e[17]!==c?(te=r(async h=>{if(S===h){C(null);return}C(h);let w=`${c}:${h}`;if(L[w]!==void 0)return;let[N,q]=await Promise.allSettled([l.query(it,{limit:1,offset:0,table:h},$e(c)),l.query(ot,{table:h},$e(c))]);N.status==="fulfilled"?y(A=>({...A,[w]:N.value.columns})):P(Oe(N.reason)),q.status==="fulfilled"&&M(A=>({...A,[w]:q.value.indexes}))},"te"),e[14]=l,e[15]=L,e[16]=S,e[17]=c,e[18]=te):te=e[18];let j=te,ye;e[19]!==l||e[20]!==W||e[21]!==J?(ye=r(async h=>{if(J===h){ie(null);return}if(ie(h),W[h]===void 0)try{let w=await l.readGlobalTablePage({limit:1,offset:0,table:h});xe(N=>({...N,[h]:w.columns}))}catch(w){oe(Oe(w))}},"ye"),e[19]=l,e[20]=W,e[21]=J,e[22]=ye):ye=e[22];let ce=ye,be=(0,x.useRef)(void 0),R,X;e[23]!==n||e[24]!==i||e[25]!==j?(R=r(()=>{n===void 0||i===null||be.current===n||i.some(h=>h.name===n)&&(be.current=n,ue(j(n)))},"K"),X=[n,i,j],e[23]=n,e[24]=i,e[25]=j,e[26]=R,e[27]=X):(R=e[26],X=e[27]),(0,x.useEffect)(R,X);let V;e[28]!==l?(V=r(async(h,w,N)=>{let[q,A]=await Promise.all([Promise.allSettled([l.query(dt,{tables:[...w,...N]},$e(h))]),Promise.all(N.map(async T=>{let ge=await Promise.allSettled([l.readGlobalTablePage({limit:1,offset:0,table:T})]),Ie=ge[0].status==="fulfilled"?ge[0].value:void 0;return{columns:Ie?.columns??[],refs:Ie?.refs??{},table:T}}))]),Te=q[0].status==="fulfilled"?q[0].value?.columnsByTable??{}:{},Se=q[0].status==="rejected",_e=new Map(A.map(ut)),ke=[...w,...N].map(T=>{let ge=Te[T]??[];return[T,ge.length>0?ge:_e.get(T)??[]]});he(T=>({...T,[h]:Object.fromEntries(ke)})),K(T=>({...T,[h]:Se}))},"U"),e[28]=l,e[29]=V):V=e[29];let le=V,U,ae;e[30]!==B||e[31]!==k||e[32]!==le||e[33]!==c||e[34]!==$||e[35]!==i||e[36]!==a?(U=r(()=>{a!=="graph"||i===null||k===null&&B===null||$[c]!==void 0||ue(le(c,i.map(ht),(k??[]).map(pt)))},"V"),ae=[a,i,k,B,c,$,le],e[30]=B,e[31]=k,e[32]=le,e[33]=c,e[34]=$,e[35]=i,e[36]=a,e[37]=U,e[38]=ae):(U=e[37],ae=e[38]),(0,x.useEffect)(U,ae);let z=$[c]??ct,ne;if(e[39]!==z||e[40]!==k||e[41]!==i){let h;e[43]!==z?(h=r(A=>({columns:z[A.name]??Ye,name:A.name,tier:"shard"}),"u"),e[43]=z,e[44]=h):h=e[44];let w=(i??[]).map(h),N;e[45]!==z?(N=r(A=>({columns:z[A.name]??Ye,name:A.name,tier:"global"}),"x"),e[45]=z,e[46]=N):N=e[46];let q=(k??[]).map(N);ne=[...w,...q],e[39]=z,e[40]=k,e[41]=i,e[42]=ne}else ne=e[42];let se=ne,f;if(e[47]!==o||e[48]!==i){let h=o.trim().toLowerCase();f=(i??[]).filter(w=>w.name.toLowerCase().includes(h)),e[47]=o,e[48]=i,e[49]=f}else f=e[49];let re=f,H;if(e[50]!==k||e[51]!==o){let h=o.trim().toLowerCase();H=(k??[]).filter(w=>w.name.toLowerCase().includes(h)),e[50]=k,e[51]=o,e[52]=H}else H=e[52];let Ne=H,fe;return e[53]!==L||e[54]!==se||e[55]!==b||e[56]!==S||e[57]!==Ne||e[58]!==re||e[59]!==W||e[60]!==B||e[61]!==J||e[62]!==k||e[63]!==E||e[64]!==O||e[65]!==d||e[66]!==I||e[67]!==g||e[68]!==o||e[69]!==i||e[70]!==j||e[71]!==ce||e[72]!==a?(fe={columns:L,diagramTables:se,error:b,expanded:S,filteredGlobalTables:Ne,filteredTables:re,globalColumns:W,globalError:B,globalExpanded:J,globalTables:k,indexes:E,refresh:O,setShardKey:d,setTableFilter:p,setView:m,shardColumnsError:I,shardKey:g,tableFilter:o,tables:i,toggle:j,toggleGlobal:ce,view:a},e[53]=L,e[54]=se,e[55]=b,e[56]=S,e[57]=Ne,e[58]=re,e[59]=W,e[60]=B,e[61]=J,e[62]=k,e[63]=E,e[64]=O,e[65]=d,e[66]=I,e[67]=g,e[68]=o,e[69]=i,e[70]=j,e[71]=ce,e[72]=a,e[73]=fe):fe=e[73],fe},"ct");function ut(s){let{columns:e,refs:u,table:n}=s;return[n,e.map(l=>{let a=u[l];return a===void 0?{name:l,optional:!1,type:""}:{name:l,optional:!1,ref:a,type:"id"}})]}r(ut,"mt");function ht(s){return s.name}r(ht,"ut");function pt(s){return s.name}r(pt,"ft");var bt="/__lunora/schema-edit",ft=r(async s=>{let e=await fetch(bt,{body:JSON.stringify(s),headers:{"Content-Type":"application/json","X-Lunora-Studio":"1"},method:"POST"}),u=await e.json();return u.needsMigration===!0?{kind:"needs-migration",message:u.message??"This edit needs a migration."}:e.ok&&u.tables!==void 0?{diagnostics:u.diagnostics??[],kind:"ok",tables:u.tables}:{kind:"error",message:u.error??`schema edit failed (${String(e.status)})`}},"pt"),gt=r(s=>{let e=(0,Ce.c)(32),{hasTables:u,mode:n,onAddColumn:l,onAddIndex:a,onAddTable:m,onDestructive:c}=s,d=Fe(),g=n==="addTable"?"default":"outline",o;e[0]!==d?(o=d("Add table"),e[0]=d,e[1]=o):o=e[1];let p;e[2]!==m||e[3]!==g||e[4]!==o?(p=(0,t.jsx)(me,{"data-testid":"sc-editor-add-table",onClick:m,size:"xs",type:"button",variant:g,children:o}),e[2]=m,e[3]=g,e[4]=o,e[5]=p):p=e[5];let i=!u,v=n==="addColumn"?"default":"outline",b;e[6]!==d?(b=d("Add column"),e[6]=d,e[7]=b):b=e[7];let P;e[8]!==l||e[9]!==i||e[10]!==v||e[11]!==b?(P=(0,t.jsx)(me,{"data-testid":"sc-editor-add-column",disabled:i,onClick:l,size:"xs",type:"button",variant:v,children:b}),e[8]=l,e[9]=i,e[10]=v,e[11]=b,e[12]=P):P=e[12];let _=!u,L=n==="addIndex"?"default":"outline",y;e[13]!==d?(y=d("Add index"),e[13]=d,e[14]=y):y=e[14];let G;e[15]!==a||e[16]!==y||e[17]!==_||e[18]!==L?(G=(0,t.jsx)(me,{"data-testid":"sc-editor-add-index",disabled:_,onClick:a,size:"xs",type:"button",variant:L,children:y}),e[15]=a,e[16]=y,e[17]=_,e[18]=L,e[19]=G):G=e[19];let E=!u,M=n==="destructive"?"default":"ghost",S;e[20]!==d?(S=d("Rename / drop / change type\u2026"),e[20]=d,e[21]=S):S=e[21];let C;e[22]!==c||e[23]!==E||e[24]!==M||e[25]!==S?(C=(0,t.jsx)(me,{"data-testid":"sc-editor-destructive",disabled:E,onClick:c,size:"xs",type:"button",variant:M,children:S}),e[22]=c,e[23]=E,e[24]=M,e[25]=S,e[26]=C):C=e[26];let F;return e[27]!==G||e[28]!==C||e[29]!==p||e[30]!==P?(F=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[p,P,G,C]}),e[27]=G,e[28]=C,e[29]=p,e[30]=P,e[31]=F):F=e[31],F},"gt"),xt=r(s=>{let e=(0,Ce.c)(28),{onOpenMigrations:u,result:n}=s,l=Fe();if(n===null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[0]=o):o=e[0],o}if(n.kind==="error"){let o;return e[1]!==n.message?(o=(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:n.message}),e[1]=n.message,e[2]=o):o=e[2],o}if(n.kind==="needs-migration"){let o;e[3]!==n.message||e[4]!==l?(o=n.message===""?l("This edit changes stored data and must go through a migration. Review the migration before applying."):n.message,e[3]=n.message,e[4]=l,e[5]=o):o=e[5];let p;e[6]!==o?(p=(0,t.jsx)("p",{className:"text-sm text-warning",role:"alert",children:o}),e[6]=o,e[7]=p):p=e[7];let i;e[8]!==l?(i=l("Open Migrations"),e[8]=l,e[9]=i):i=e[9];let v;e[10]!==u||e[11]!==i?(v=(0,t.jsx)(me,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:u,size:"xs",type:"button",variant:"outline",children:i}),e[10]=u,e[11]=i,e[12]=v):v=e[12];let b;return e[13]!==p||e[14]!==v?(b=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[p,v]}),e[13]=p,e[14]=v,e[15]=b):b=e[15],b}if(n.diagnostics.length===0){let o;return e[16]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[16]=o):o=e[16],o}let a;e[17]!==l?(a=l("Codegen reported diagnostics:"),e[17]=l,e[18]=a):a=e[18];let m;e[19]!==a?(m=(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:a}),e[19]=a,e[20]=m):m=e[20];let c;e[21]!==n.diagnostics?(c=n.diagnostics.map(vt),e[21]=n.diagnostics,e[22]=c):c=e[22];let d;e[23]!==c?(d=(0,t.jsx)("ul",{className:"flex flex-col gap-0.5",children:c}),e[23]=c,e[24]=d):d=e[24];let g;return e[25]!==m||e[26]!==d?(g=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[m,d]}),e[25]=m,e[26]=d,e[27]=g):g=e[27],g},"bt");function vt(s){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:s},s)}r(vt,"xt");var yt=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.int64()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],Nt="v.string()",Ct=r(s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),"Ct"),wt=r(s=>{let e=(0,Ce.c)(83),{onApplied:u,tableNames:n}=s,l=Fe(),a=Ue(),[m,c]=(0,x.useState)(null),[d,g]=(0,x.useState)(!1),[o,p]=(0,x.useState)(null),[i,v]=(0,x.useState)(""),[b,P]=(0,x.useState)(""),[_,L]=(0,x.useState)(Nt),[y,G]=(0,x.useState)(n[0]??""),[E,M]=(0,x.useState)(""),[S,C]=(0,x.useState)(""),[F,$]=(0,x.useState)(!1),he;e[0]===Symbol.for("react.memo_cache_sentinel")?(he=r(()=>{c(null),v(""),P(""),M(""),C(""),$(!1)},"me"),e[0]=he):he=e[0];let Q=he,I;e[1]!==u?(I=r(async T=>{g(!0),p(null);try{let ge=await ft(T);p(ge),ge.kind==="ok"&&(u(ge.tables),Q())}catch(ge){let Ie=ge;p({kind:"error",message:Ie instanceof Error?Ie.message:String(Ie)})}g(!1)},"I"),e[1]=u,e[2]=I):I=e[2];let K=I,k;e[3]!==K||e[4]!==i?(k=r(()=>{ue(K({kind:"addTable",table:i.trim()}))},"_"),e[3]=K,e[4]=i,e[5]=k):k=e[5];let pe=k,B;e[6]!==b||e[7]!==K||e[8]!==y||e[9]!==_?(B=r(()=>{ue(K({column:b.trim(),kind:"addOptionalColumn",table:y,validator:_}))},"j"),e[6]=b,e[7]=K,e[8]=y,e[9]=_,e[10]=B):B=e[10];let oe=B,Y;e[11]!==S||e[12]!==E||e[13]!==K||e[14]!==y||e[15]!==F?(Y=r(()=>{ue(K({fields:Ct(S),kind:"addIndex",name:E.trim(),table:y,unique:F}))},"Q"),e[11]=S,e[12]=E,e[13]=K,e[14]=y,e[15]=F,e[16]=Y):Y=e[16];let W=Y,xe;e[17]===Symbol.for("react.memo_cache_sentinel")?(xe=r(()=>{p(null),c("addTable")},"xe"),e[17]=xe):xe=e[17];let J=xe,ie;e[18]===Symbol.for("react.memo_cache_sentinel")?(ie=r(()=>{p(null),c("addColumn")},"re"),e[18]=ie):ie=e[18];let ve=ie,O;e[19]===Symbol.for("react.memo_cache_sentinel")?(O=r(()=>{p(null),c("addIndex")},"O"),e[19]=O):O=e[19];let Z=O,ee;e[20]!==l?(ee=r(()=>{c("destructive"),p({kind:"needs-migration",message:l("This edit changes stored data and must go through a migration. Review the migration before applying.")})},"ee"),e[20]=l,e[21]=ee):ee=e[21];let de=ee,D;e[22]===Symbol.for("react.memo_cache_sentinel")?(D=r(T=>{v(T.target.value)},"R"),e[22]=D):D=e[22];let te=D,j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=r(T=>{P(T.target.value)},"M"),e[23]=j):j=e[23];let ye=j,ce;e[24]===Symbol.for("react.memo_cache_sentinel")?(ce=r(T=>{L(T.target.value)},"ce"),e[24]=ce):ce=e[24];let be=ce,R;e[25]===Symbol.for("react.memo_cache_sentinel")?(R=r(T=>{G(T.target.value)},"K"),e[25]=R):R=e[25];let X=R,V;e[26]===Symbol.for("react.memo_cache_sentinel")?(V=r(T=>{M(T.target.value)},"U"),e[26]=V):V=e[26];let le=V,U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=r(T=>{C(T.target.value)},"V"),e[27]=U):U=e[27];let ae=U,z;e[28]===Symbol.for("react.memo_cache_sentinel")?(z=r(T=>{$(T.target.checked)},"$"),e[28]=z):z=e[28];let ne=z,se;e[29]!==a?(se=r(()=>{ue(a({to:"/migrations"}))},"ne"),e[29]=a,e[30]=se):se=e[30];let f=se,re;e[31]!==l?(re=l("Edit schema"),e[31]=l,e[32]=re):re=e[32];let H;e[33]!==re?(H=(0,t.jsx)(Ge,{children:re}),e[33]=re,e[34]=H):H=e[34];let Ne;e[35]!==l?(Ne=l("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=l,e[36]=Ne):Ne=e[36];let fe;e[37]!==Ne?(fe=(0,t.jsx)(Ke,{children:Ne}),e[37]=Ne,e[38]=fe):fe=e[38];let h;e[39]!==H||e[40]!==fe?(h=(0,t.jsxs)(Pe,{children:[H,fe]}),e[39]=H,e[40]=fe,e[41]=h):h=e[41];let w=n.length>0,N;e[42]!==m||e[43]!==de||e[44]!==w?(N=(0,t.jsx)(gt,{hasTables:w,mode:m,onAddColumn:ve,onAddIndex:Z,onAddTable:J,onDestructive:de}),e[42]=m,e[43]=de,e[44]=w,e[45]=N):N=e[45];let q;e[46]!==d||e[47]!==m||e[48]!==pe||e[49]!==l||e[50]!==i?(q=m==="addTable"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-table-name",children:l("Table name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:te,value:i})]}),(0,t.jsx)(me,{"data-testid":"sc-editor-table-apply",disabled:d||i.trim()==="",onClick:pe,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[46]=d,e[47]=m,e[48]=pe,e[49]=l,e[50]=i,e[51]=q):q=e[51];let A;e[52]!==d||e[53]!==b||e[54]!==m||e[55]!==oe||e[56]!==l||e[57]!==n||e[58]!==y||e[59]!==_?(A=m==="addColumn"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-table",id:"sc-editor-column-table",onChange:X,value:y,children:n.map(Tt)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-name",children:l("Column name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:ye,value:b})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-type",children:l("Column type")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-type",id:"sc-editor-column-type",onChange:be,value:_,children:yt.map(St)})]}),(0,t.jsx)("span",{className:"text-[11px] text-muted-foreground",children:l("Optional")}),(0,t.jsx)(me,{"data-testid":"sc-editor-column-apply",disabled:d||b.trim()===""||y==="",onClick:oe,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[52]=d,e[53]=b,e[54]=m,e[55]=oe,e[56]=l,e[57]=n,e[58]=y,e[59]=_,e[60]=A):A=e[60];let Te;e[61]!==d||e[62]!==S||e[63]!==E||e[64]!==m||e[65]!==W||e[66]!==l||e[67]!==n||e[68]!==y||e[69]!==F?(Te=m==="addIndex"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-index-table",id:"sc-editor-index-table",onChange:X,value:y,children:n.map(_t)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-name",children:l("Index name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:le,value:E})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-fields",children:l("Index fields (comma-separated)")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:ae,value:S})]}),(0,t.jsxs)(we,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[(0,t.jsx)("input",{checked:F,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:ne,type:"checkbox"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:l("Unique")})]}),(0,t.jsx)(me,{"data-testid":"sc-editor-index-apply",disabled:d||E.trim()===""||S.trim()==="",onClick:W,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[61]=d,e[62]=S,e[63]=E,e[64]=m,e[65]=W,e[66]=l,e[67]=n,e[68]=y,e[69]=F,e[70]=Te):Te=e[70];let Se;e[71]!==f||e[72]!==o?(Se=(0,t.jsx)(xt,{onOpenMigrations:f,result:o}),e[71]=f,e[72]=o,e[73]=Se):Se=e[73];let _e;e[74]!==N||e[75]!==q||e[76]!==A||e[77]!==Te||e[78]!==Se?(_e=(0,t.jsxs)(Le,{children:[N,q,A,Te,Se]}),e[74]=N,e[75]=q,e[76]=A,e[77]=Te,e[78]=Se,e[79]=_e):_e=e[79];let ke;return e[80]!==h||e[81]!==_e?(ke=(0,t.jsxs)(qe,{"data-testid":"sc-editor",size:"sm",children:[h,_e]}),e[80]=h,e[81]=_e,e[82]=ke):ke=e[82],ke},"Nt");function Tt(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(Tt,"Tt");function St(s){return(0,t.jsx)("option",{value:s.validator,children:s.label},s.validator)}r(St,"St");function _t(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(_t,"wt");var Ze=[],kt=r(s=>{let e=(0,Ce.c)(5),{open:u}=s,n=u&&"rotate-90",l;e[0]!==n?(l=De("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",n),e[0]=n,e[1]=l):l=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[2]=a):a=e[2];let m;return e[3]!==l?(m=(0,t.jsx)("svg",{"aria-hidden":"true",className:l,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:a}),e[3]=l,e[4]=m):m=e[4],m},"_t"),et=r(s=>{let e=(0,Ce.c)(20),{children:u,expanded:n,name:l,onToggle:a,rowCount:m,rowTestId:c,toggleTestId:d}=s,g;e[0]!==n?(g=(0,t.jsx)(kt,{open:n}),e[0]=n,e[1]=g):g=e[1];let o;e[2]!==l?(o=(0,t.jsx)("span",{className:"truncate font-mono text-xs text-foreground",title:l,children:l}),e[2]=l,e[3]=o):o=e[3];let p;e[4]!==m?(p=(0,t.jsxs)("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",m,")"]}),e[4]=m,e[5]=p):p=e[5];let i;e[6]!==n||e[7]!==a||e[8]!==g||e[9]!==o||e[10]!==p||e[11]!==d?(i=(0,t.jsxs)("button",{"aria-expanded":n,className:"flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40","data-testid":d,onClick:a,type:"button",children:[g,o," ",p]}),e[6]=n,e[7]=a,e[8]=g,e[9]=o,e[10]=p,e[11]=d,e[12]=i):i=e[12];let v;e[13]!==u||e[14]!==n?(v=n&&(0,t.jsx)("div",{className:"px-3 pb-3 ps-8",children:u}),e[13]=u,e[14]=n,e[15]=v):v=e[15];let b;return e[16]!==c||e[17]!==i||e[18]!==v?(b=(0,t.jsxs)("li",{className:"border-t border-border/60 first:border-t-0","data-testid":c,children:[i,v]}),e[16]=c,e[17]=i,e[18]=v,e[19]=b):b=e[19],b},"Ye"),tt=r(s=>{let e=(0,Ce.c)(5),{columns:u,testId:n}=s,l;e[0]!==u?(l=u.map(At),e[0]=u,e[1]=l):l=e[1];let a;return e[2]!==l||e[3]!==n?(a=(0,t.jsx)("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":n,children:l}),e[2]=l,e[3]=n,e[4]=a):a=e[4],a},"He"),It=r(s=>{let e=(0,Ce.c)(10),{heading:u,indexes:n,testId:l}=s,a;e[0]!==u?(a=(0,t.jsx)("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:u}),e[0]=u,e[1]=a):a=e[1];let m;e[2]!==n?(m=n.map(Ft),e[2]=n,e[3]=m):m=e[3];let c;e[4]!==m||e[5]!==l?(c=(0,t.jsx)("ul",{className:"flex flex-col gap-1","data-testid":l,children:m}),e[4]=m,e[5]=l,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=(0,t.jsxs)("div",{className:"pt-3",children:[a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d},"Et"),lt=r(s=>De("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",s?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"Xe"),Xt=r(s=>{let e=(0,Ce.c)(85),{initialShardKey:u,initialTable:n,schemaEditable:l}=s,a=Fe(),m;e[0]!==u||e[1]!==n?(m={initialShardKey:u,initialTable:n},e[0]=u,e[1]=n,e[2]=m):m=e[2];let{columns:c,diagramTables:d,error:g,expanded:o,filteredGlobalTables:p,filteredTables:i,globalColumns:v,globalError:b,globalExpanded:P,globalTables:_,indexes:L,refresh:y,setShardKey:G,setTableFilter:E,setView:M,shardColumnsError:S,shardKey:C,tableFilter:F,tables:$,toggle:he,toggleGlobal:Q,view:I}=mt(m),K;e[3]!==M?(K=r(()=>{M("list")},"q"),e[3]=M,e[4]=K):K=e[4];let k=K,pe;e[5]!==M?(pe=r(()=>{M("graph")},"ue"),e[5]=M,e[6]=pe):pe=e[6];let B=pe,oe;e[7]!==E?(oe=r(f=>{E(f.target.value)},"ie"),e[7]=E,e[8]=oe):oe=e[8];let Y=oe,W;e[9]!==y||e[10]!==C?(W=r(f=>{ue(y(C))},"Y"),e[9]=y,e[10]=C,e[11]=W):W=e[11];let xe=W,J;e[12]!==$?(J=$??[],e[12]=$,e[13]=J):J=e[13];let ie;e[14]!==J?(ie=J.map(zt),e[14]=J,e[15]=ie):ie=e[15];let ve=ie,O;e[16]!==G||e[17]!==C?(O=(0,t.jsx)(Xe,{onChange:G,testId:"sc-shard-input",value:C}),e[16]=G,e[17]=C,e[18]=O):O=e[18];let Z;e[19]!==a?(Z=a("Schema view"),e[19]=a,e[20]=Z):Z=e[20];let ee=I==="graph",de=I==="graph",D;e[21]!==de?(D=lt(de),e[21]=de,e[22]=D):D=e[22];let te;e[23]!==a?(te=a("Graph"),e[23]=a,e[24]=te):te=e[24];let j;e[25]!==B||e[26]!==ee||e[27]!==D||e[28]!==te?(j=(0,t.jsx)("button",{"aria-selected":ee,className:D,"data-testid":"sc-view-graph",onClick:B,role:"tab",type:"button",children:te}),e[25]=B,e[26]=ee,e[27]=D,e[28]=te,e[29]=j):j=e[29];let ye=I==="list",ce=I==="list",be;e[30]!==ce?(be=lt(ce),e[30]=ce,e[31]=be):be=e[31];let R;e[32]!==a?(R=a("Table list"),e[32]=a,e[33]=R):R=e[33];let X;e[34]!==k||e[35]!==ye||e[36]!==be||e[37]!==R?(X=(0,t.jsx)("button",{"aria-selected":ye,className:be,"data-testid":"sc-view-list",onClick:k,role:"tab",type:"button",children:R}),e[34]=k,e[35]=ye,e[36]=be,e[37]=R,e[38]=X):X=e[38];let V;e[39]!==j||e[40]!==X||e[41]!==Z?(V=(0,t.jsxs)("div",{"aria-label":Z,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[j,X]}),e[39]=j,e[40]=X,e[41]=Z,e[42]=V):V=e[42];let le;e[43]!==V||e[44]!==O?(le=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[O,V]}),e[43]=V,e[44]=O,e[45]=le):le=e[45];let U;e[46]!==xe||e[47]!==l||e[48]!==ve?(U=l===!0&&(0,t.jsx)(wt,{onApplied:xe,tableNames:ve}),e[46]=xe,e[47]=l,e[48]=ve,e[49]=U):U=e[49];let ae;e[50]!==Y||e[51]!==a||e[52]!==F||e[53]!==I?(ae=I==="list"&&(0,t.jsx)(Ae,{"aria-label":a("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:Y,placeholder:a("Filter tables"),value:F}),e[50]=Y,e[51]=a,e[52]=F,e[53]=I,e[54]=ae):ae=e[54];let z;e[55]!==d||e[56]!==g||e[57]!==b||e[58]!==S||e[59]!==C||e[60]!==I?(z=I==="graph"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),b!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:b}),(0,t.jsx)(Qe,{columnsError:S[C]===!0,tables:d,testIdPrefix:"sc-graph"})]}),e[55]=d,e[56]=g,e[57]=b,e[58]=S,e[59]=C,e[60]=I,e[61]=z):z=e[61];let ne;e[62]!==c||e[63]!==g||e[64]!==o||e[65]!==p||e[66]!==i||e[67]!==v||e[68]!==b||e[69]!==P||e[70]!==_||e[71]!==L||e[72]!==C||e[73]!==a||e[74]!==$||e[75]!==he||e[76]!==Q||e[77]!==I?(ne=I==="list"&&(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)(qe,{"data-testid":"sc-shard-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Re,{tier:"shard"}),(0,t.jsx)(Ge,{children:a("Shard tables")}),$!==null&&(0,t.jsx)(ze,{className:"ms-auto tabular-nums",variant:"outline",children:i.length})]}),(0,t.jsx)(Ke,{children:Me.shard.hint})]}),(0,t.jsxs)(Le,{children:[g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),$!==null&&$.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:a("No tables in this shard.")}),$!==null&&$.length>0&&i.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:a("No tables match your filter.")}),i.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:i.map(f=>{let re=`${C}:${f.name}`,H=L[re]??[];return(0,t.jsxs)(et,{expanded:o===f.name,name:f.name,onToggle:r(()=>{ue(he(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-table-${f.name}`,toggleTestId:`sc-toggle-${f.name}`,children:[(0,t.jsx)(tt,{columns:c[re]??Ze,testId:`sc-columns-${f.name}`}),H.length>0&&(0,t.jsx)(It,{heading:a("Indexes"),indexes:H,testId:`sc-indexes-${f.name}`})]},f.name)})})]})]}),(0,t.jsxs)(qe,{"data-testid":"sc-global-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Re,{tier:"global"}),(0,t.jsx)(Ge,{children:a("Global tables (D1)")}),_!==null&&(0,t.jsx)(ze,{className:"ms-auto tabular-nums",variant:"outline",children:p.length})]}),(0,t.jsx)(Ke,{children:Me.global.hint})]}),(0,t.jsxs)(Le,{children:[b!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:b}),_!==null&&_.length===0&&(0,t.jsx)(We,{description:Me.global.hint,testId:"sc-global-empty",title:a("No global tables.")}),_!==null&&_.length>0&&p.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:a("No tables match your filter.")}),p.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:p.map(f=>(0,t.jsx)(et,{expanded:P===f.name,name:f.name,onToggle:r(()=>{ue(Q(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-global-table-${f.name}`,toggleTestId:`sc-global-toggle-${f.name}`,children:(0,t.jsx)(tt,{columns:v[f.name]??Ze,testId:`sc-global-columns-${f.name}`})},f.name))})]})]})]}),e[62]=c,e[63]=g,e[64]=o,e[65]=p,e[66]=i,e[67]=v,e[68]=b,e[69]=P,e[70]=_,e[71]=L,e[72]=C,e[73]=a,e[74]=$,e[75]=he,e[76]=Q,e[77]=I,e[78]=ne):ne=e[78];let se;return e[79]!==le||e[80]!==U||e[81]!==ae||e[82]!==z||e[83]!==ne?(se=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[le,U,ae,z,ne]}),e[79]=le,e[80]=U,e[81]=ae,e[82]=z,e[83]=ne,e[84]=se):se=e[84],se},"Wt");function At(s){return(0,t.jsx)("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:s},s)}r(At,"It");function Ft(s){return(0,t.jsxs)("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[(0,t.jsx)("span",{className:"font-mono",children:s.name}),(0,t.jsx)(ze,{variant:"outline",children:s.type}),s.unique===!0&&(0,t.jsx)(ze,{variant:"secondary",children:"unique"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:s.fields.join(", ")})]},`${s.type}:${s.name}`)}r(Ft,"kt");function zt(s){return s.name}r(zt,"At");export{Xt as SchemaViewer};
|
|
1
|
+
import{a as Qe}from"./chunk-OTZRXUHF.js";import{a as Me,b as Re}from"./chunk-7SROZWKL.js";import"./chunk-AECDJKXB.js";import"./chunk-CN2AINNY.js";import"./chunk-CP4ZFBVW.js";import{a as we}from"./chunk-NXXGISFB.js";import"./chunk-EDHW2EEG.js";import"./chunk-ZSOLGJFC.js";import"./chunk-DUDQV6XJ.js";import"./chunk-VZCS5GXZ.js";import"./chunk-DKSLOJDQ.js";import"./chunk-JV7KTJPY.js";import{a as He}from"./chunk-CKTKI4IY.js";import{a as Xe}from"./chunk-HLEXBOCL.js";import{b as Je}from"./chunk-P52BY657.js";import{e as Ue}from"./chunk-4YTSKL4R.js";import"./chunk-VNTEQQPP.js";import{P as Ae}from"./chunk-AOAJGSYZ.js";import"./chunk-INQICZYC.js";import"./chunk-TFMQSCGC.js";import{a as me}from"./chunk-BWEXJENB.js";import"./chunk-74ASA4WU.js";import"./chunk-XQS7KSHL.js";import{b as ze}from"./chunk-SPDZUX4P.js";import"./chunk-7PIHTTND.js";import{a as je}from"./chunk-VDW32UET.js";import{f as Ve}from"./chunk-22WJHOC4.js";import"./chunk-RCZTUWG3.js";import{a as We}from"./chunk-UANVABQG.js";import{a as qe,b as Pe,c as Ge,d as Ke,e as Le}from"./chunk-IYWVSMAY.js";import{d as Fe,f as Ee,g as $e,h as Oe,o as ue}from"./chunk-BKM6PMSO.js";import"./chunk-VYW2PAWC.js";import{a as r,d as Be,e as at,f as nt,g as st,i as De}from"./chunk-R5ZTCHCE.js";var Ce=Be(nt(),1);var x=Be(at(),1);var t=Be(st(),1);var rt=Ee(je.listTables),ot=Ee(je.listTableIndexes),it=Ee(je.readTablePage),dt=Ee(je.describeTables),ct={},Ye=[],mt=r(s=>{let e=(0,Ce.c)(74),{initialShardKey:u,initialTable:n}=s,l=Ve(),[a,m]=(0,x.useState)("graph"),{queryShardKey:c,setShardKey:d,shardKey:g}=He(u),[o,p]=(0,x.useState)(""),[i,v]=(0,x.useState)(null),[b,P]=(0,x.useState)(null),_;e[0]===Symbol.for("react.memo_cache_sentinel")?(_={},e[0]=_):_=e[0];let[L,y]=(0,x.useState)(_),G;e[1]===Symbol.for("react.memo_cache_sentinel")?(G={},e[1]=G):G=e[1];let[E,M]=(0,x.useState)(G),[S,C]=(0,x.useState)(null),F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F={},e[2]=F):F=e[2];let[$,he]=(0,x.useState)(F),Q;e[3]===Symbol.for("react.memo_cache_sentinel")?(Q={},e[3]=Q):Q=e[3];let[I,K]=(0,x.useState)(Q),[k,pe]=(0,x.useState)(null),[B,oe]=(0,x.useState)(null),Y;e[4]===Symbol.for("react.memo_cache_sentinel")?(Y={},e[4]=Y):Y=e[4];let[W,xe]=(0,x.useState)(Y),[J,ie]=(0,x.useState)(null),ve;e[5]!==l?(ve=r(async h=>{P(null);try{let w=await l.query(rt,{},$e(h));Je(h),v(w),y({}),M({}),C(null),he(N=>Object.fromEntries(Object.entries(N).filter(q=>{let[A]=q;return A!==h}))),K(N=>Object.fromEntries(Object.entries(N).filter(q=>{let[A]=q;return A!==h})))}catch(w){let N=w;v(null),P(Oe(N))}},"ve"),e[5]=l,e[6]=ve):ve=e[6];let O=ve,Z;e[7]!==l?(Z=r(async()=>{oe(null);try{pe(await l.listGlobalTables())}catch(h){let w=h;pe(null),oe(Oe(w))}},"Z"),e[7]=l,e[8]=Z):Z=e[8];let ee=Z,de,D;e[9]!==c||e[10]!==O||e[11]!==ee?(de=r(()=>{ue(O(c)),ue(ee())},"de"),D=[O,ee,c],e[9]=c,e[10]=O,e[11]=ee,e[12]=de,e[13]=D):(de=e[12],D=e[13]),(0,x.useEffect)(de,D);let te;e[14]!==l||e[15]!==L||e[16]!==S||e[17]!==c?(te=r(async h=>{if(S===h){C(null);return}C(h);let w=`${c}:${h}`;if(L[w]!==void 0)return;let[N,q]=await Promise.allSettled([l.query(it,{limit:1,offset:0,table:h},$e(c)),l.query(ot,{table:h},$e(c))]);N.status==="fulfilled"?y(A=>({...A,[w]:N.value.columns})):P(Oe(N.reason)),q.status==="fulfilled"&&M(A=>({...A,[w]:q.value.indexes}))},"te"),e[14]=l,e[15]=L,e[16]=S,e[17]=c,e[18]=te):te=e[18];let j=te,ye;e[19]!==l||e[20]!==W||e[21]!==J?(ye=r(async h=>{if(J===h){ie(null);return}if(ie(h),W[h]===void 0)try{let w=await l.readGlobalTablePage({limit:1,offset:0,table:h});xe(N=>({...N,[h]:w.columns}))}catch(w){oe(Oe(w))}},"ye"),e[19]=l,e[20]=W,e[21]=J,e[22]=ye):ye=e[22];let ce=ye,be=(0,x.useRef)(void 0),R,X;e[23]!==n||e[24]!==i||e[25]!==j?(R=r(()=>{n===void 0||i===null||be.current===n||i.some(h=>h.name===n)&&(be.current=n,ue(j(n)))},"K"),X=[n,i,j],e[23]=n,e[24]=i,e[25]=j,e[26]=R,e[27]=X):(R=e[26],X=e[27]),(0,x.useEffect)(R,X);let V;e[28]!==l?(V=r(async(h,w,N)=>{let[q,A]=await Promise.all([Promise.allSettled([l.query(dt,{tables:[...w,...N]},$e(h))]),Promise.all(N.map(async T=>{let ge=await Promise.allSettled([l.readGlobalTablePage({limit:1,offset:0,table:T})]),Ie=ge[0].status==="fulfilled"?ge[0].value:void 0;return{columns:Ie?.columns??[],refs:Ie?.refs??{},table:T}}))]),Te=q[0].status==="fulfilled"?q[0].value?.columnsByTable??{}:{},Se=q[0].status==="rejected",_e=new Map(A.map(ut)),ke=[...w,...N].map(T=>{let ge=Te[T]??[];return[T,ge.length>0?ge:_e.get(T)??[]]});he(T=>({...T,[h]:Object.fromEntries(ke)})),K(T=>({...T,[h]:Se}))},"U"),e[28]=l,e[29]=V):V=e[29];let le=V,U,ae;e[30]!==B||e[31]!==k||e[32]!==le||e[33]!==c||e[34]!==$||e[35]!==i||e[36]!==a?(U=r(()=>{a!=="graph"||i===null||k===null&&B===null||$[c]!==void 0||ue(le(c,i.map(ht),(k??[]).map(pt)))},"V"),ae=[a,i,k,B,c,$,le],e[30]=B,e[31]=k,e[32]=le,e[33]=c,e[34]=$,e[35]=i,e[36]=a,e[37]=U,e[38]=ae):(U=e[37],ae=e[38]),(0,x.useEffect)(U,ae);let z=$[c]??ct,ne;if(e[39]!==z||e[40]!==k||e[41]!==i){let h;e[43]!==z?(h=r(A=>({columns:z[A.name]??Ye,name:A.name,tier:"shard"}),"u"),e[43]=z,e[44]=h):h=e[44];let w=(i??[]).map(h),N;e[45]!==z?(N=r(A=>({columns:z[A.name]??Ye,name:A.name,tier:"global"}),"x"),e[45]=z,e[46]=N):N=e[46];let q=(k??[]).map(N);ne=[...w,...q],e[39]=z,e[40]=k,e[41]=i,e[42]=ne}else ne=e[42];let se=ne,f;if(e[47]!==o||e[48]!==i){let h=o.trim().toLowerCase();f=(i??[]).filter(w=>w.name.toLowerCase().includes(h)),e[47]=o,e[48]=i,e[49]=f}else f=e[49];let re=f,H;if(e[50]!==k||e[51]!==o){let h=o.trim().toLowerCase();H=(k??[]).filter(w=>w.name.toLowerCase().includes(h)),e[50]=k,e[51]=o,e[52]=H}else H=e[52];let Ne=H,fe;return e[53]!==L||e[54]!==se||e[55]!==b||e[56]!==S||e[57]!==Ne||e[58]!==re||e[59]!==W||e[60]!==B||e[61]!==J||e[62]!==k||e[63]!==E||e[64]!==O||e[65]!==d||e[66]!==I||e[67]!==g||e[68]!==o||e[69]!==i||e[70]!==j||e[71]!==ce||e[72]!==a?(fe={columns:L,diagramTables:se,error:b,expanded:S,filteredGlobalTables:Ne,filteredTables:re,globalColumns:W,globalError:B,globalExpanded:J,globalTables:k,indexes:E,refresh:O,setShardKey:d,setTableFilter:p,setView:m,shardColumnsError:I,shardKey:g,tableFilter:o,tables:i,toggle:j,toggleGlobal:ce,view:a},e[53]=L,e[54]=se,e[55]=b,e[56]=S,e[57]=Ne,e[58]=re,e[59]=W,e[60]=B,e[61]=J,e[62]=k,e[63]=E,e[64]=O,e[65]=d,e[66]=I,e[67]=g,e[68]=o,e[69]=i,e[70]=j,e[71]=ce,e[72]=a,e[73]=fe):fe=e[73],fe},"ct");function ut(s){let{columns:e,refs:u,table:n}=s;return[n,e.map(l=>{let a=u[l];return a===void 0?{name:l,optional:!1,type:""}:{name:l,optional:!1,ref:a,type:"id"}})]}r(ut,"mt");function ht(s){return s.name}r(ht,"ut");function pt(s){return s.name}r(pt,"ft");var bt="/__lunora/schema-edit",ft=r(async s=>{let e=await fetch(bt,{body:JSON.stringify(s),headers:{"Content-Type":"application/json","X-Lunora-Studio":"1"},method:"POST"}),u=await e.json();return u.needsMigration===!0?{kind:"needs-migration",message:u.message??"This edit needs a migration."}:e.ok&&u.tables!==void 0?{diagnostics:u.diagnostics??[],kind:"ok",tables:u.tables}:{kind:"error",message:u.error??`schema edit failed (${String(e.status)})`}},"pt"),gt=r(s=>{let e=(0,Ce.c)(32),{hasTables:u,mode:n,onAddColumn:l,onAddIndex:a,onAddTable:m,onDestructive:c}=s,d=Fe(),g=n==="addTable"?"default":"outline",o;e[0]!==d?(o=d("Add table"),e[0]=d,e[1]=o):o=e[1];let p;e[2]!==m||e[3]!==g||e[4]!==o?(p=(0,t.jsx)(me,{"data-testid":"sc-editor-add-table",onClick:m,size:"xs",type:"button",variant:g,children:o}),e[2]=m,e[3]=g,e[4]=o,e[5]=p):p=e[5];let i=!u,v=n==="addColumn"?"default":"outline",b;e[6]!==d?(b=d("Add column"),e[6]=d,e[7]=b):b=e[7];let P;e[8]!==l||e[9]!==i||e[10]!==v||e[11]!==b?(P=(0,t.jsx)(me,{"data-testid":"sc-editor-add-column",disabled:i,onClick:l,size:"xs",type:"button",variant:v,children:b}),e[8]=l,e[9]=i,e[10]=v,e[11]=b,e[12]=P):P=e[12];let _=!u,L=n==="addIndex"?"default":"outline",y;e[13]!==d?(y=d("Add index"),e[13]=d,e[14]=y):y=e[14];let G;e[15]!==a||e[16]!==y||e[17]!==_||e[18]!==L?(G=(0,t.jsx)(me,{"data-testid":"sc-editor-add-index",disabled:_,onClick:a,size:"xs",type:"button",variant:L,children:y}),e[15]=a,e[16]=y,e[17]=_,e[18]=L,e[19]=G):G=e[19];let E=!u,M=n==="destructive"?"default":"ghost",S;e[20]!==d?(S=d("Rename / drop / change type\u2026"),e[20]=d,e[21]=S):S=e[21];let C;e[22]!==c||e[23]!==E||e[24]!==M||e[25]!==S?(C=(0,t.jsx)(me,{"data-testid":"sc-editor-destructive",disabled:E,onClick:c,size:"xs",type:"button",variant:M,children:S}),e[22]=c,e[23]=E,e[24]=M,e[25]=S,e[26]=C):C=e[26];let F;return e[27]!==G||e[28]!==C||e[29]!==p||e[30]!==P?(F=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[p,P,G,C]}),e[27]=G,e[28]=C,e[29]=p,e[30]=P,e[31]=F):F=e[31],F},"gt"),xt=r(s=>{let e=(0,Ce.c)(28),{onOpenMigrations:u,result:n}=s,l=Fe();if(n===null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[0]=o):o=e[0],o}if(n.kind==="error"){let o;return e[1]!==n.message?(o=(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:n.message}),e[1]=n.message,e[2]=o):o=e[2],o}if(n.kind==="needs-migration"){let o;e[3]!==n.message||e[4]!==l?(o=n.message===""?l("This edit changes stored data and must go through a migration. Review the migration before applying."):n.message,e[3]=n.message,e[4]=l,e[5]=o):o=e[5];let p;e[6]!==o?(p=(0,t.jsx)("p",{className:"text-sm text-warning",role:"alert",children:o}),e[6]=o,e[7]=p):p=e[7];let i;e[8]!==l?(i=l("Open Migrations"),e[8]=l,e[9]=i):i=e[9];let v;e[10]!==u||e[11]!==i?(v=(0,t.jsx)(me,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:u,size:"xs",type:"button",variant:"outline",children:i}),e[10]=u,e[11]=i,e[12]=v):v=e[12];let b;return e[13]!==p||e[14]!==v?(b=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[p,v]}),e[13]=p,e[14]=v,e[15]=b):b=e[15],b}if(n.diagnostics.length===0){let o;return e[16]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[16]=o):o=e[16],o}let a;e[17]!==l?(a=l("Codegen reported diagnostics:"),e[17]=l,e[18]=a):a=e[18];let m;e[19]!==a?(m=(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:a}),e[19]=a,e[20]=m):m=e[20];let c;e[21]!==n.diagnostics?(c=n.diagnostics.map(vt),e[21]=n.diagnostics,e[22]=c):c=e[22];let d;e[23]!==c?(d=(0,t.jsx)("ul",{className:"flex flex-col gap-0.5",children:c}),e[23]=c,e[24]=d):d=e[24];let g;return e[25]!==m||e[26]!==d?(g=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[m,d]}),e[25]=m,e[26]=d,e[27]=g):g=e[27],g},"bt");function vt(s){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:s},s)}r(vt,"xt");var yt=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.int64()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],Nt="v.string()",Ct=r(s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),"Ct"),wt=r(s=>{let e=(0,Ce.c)(83),{onApplied:u,tableNames:n}=s,l=Fe(),a=Ue(),[m,c]=(0,x.useState)(null),[d,g]=(0,x.useState)(!1),[o,p]=(0,x.useState)(null),[i,v]=(0,x.useState)(""),[b,P]=(0,x.useState)(""),[_,L]=(0,x.useState)(Nt),[y,G]=(0,x.useState)(n[0]??""),[E,M]=(0,x.useState)(""),[S,C]=(0,x.useState)(""),[F,$]=(0,x.useState)(!1),he;e[0]===Symbol.for("react.memo_cache_sentinel")?(he=r(()=>{c(null),v(""),P(""),M(""),C(""),$(!1)},"me"),e[0]=he):he=e[0];let Q=he,I;e[1]!==u?(I=r(async T=>{g(!0),p(null);try{let ge=await ft(T);p(ge),ge.kind==="ok"&&(u(ge.tables),Q())}catch(ge){let Ie=ge;p({kind:"error",message:Ie instanceof Error?Ie.message:String(Ie)})}g(!1)},"I"),e[1]=u,e[2]=I):I=e[2];let K=I,k;e[3]!==K||e[4]!==i?(k=r(()=>{ue(K({kind:"addTable",table:i.trim()}))},"_"),e[3]=K,e[4]=i,e[5]=k):k=e[5];let pe=k,B;e[6]!==b||e[7]!==K||e[8]!==y||e[9]!==_?(B=r(()=>{ue(K({column:b.trim(),kind:"addOptionalColumn",table:y,validator:_}))},"j"),e[6]=b,e[7]=K,e[8]=y,e[9]=_,e[10]=B):B=e[10];let oe=B,Y;e[11]!==S||e[12]!==E||e[13]!==K||e[14]!==y||e[15]!==F?(Y=r(()=>{ue(K({fields:Ct(S),kind:"addIndex",name:E.trim(),table:y,unique:F}))},"Q"),e[11]=S,e[12]=E,e[13]=K,e[14]=y,e[15]=F,e[16]=Y):Y=e[16];let W=Y,xe;e[17]===Symbol.for("react.memo_cache_sentinel")?(xe=r(()=>{p(null),c("addTable")},"xe"),e[17]=xe):xe=e[17];let J=xe,ie;e[18]===Symbol.for("react.memo_cache_sentinel")?(ie=r(()=>{p(null),c("addColumn")},"re"),e[18]=ie):ie=e[18];let ve=ie,O;e[19]===Symbol.for("react.memo_cache_sentinel")?(O=r(()=>{p(null),c("addIndex")},"O"),e[19]=O):O=e[19];let Z=O,ee;e[20]!==l?(ee=r(()=>{c("destructive"),p({kind:"needs-migration",message:l("This edit changes stored data and must go through a migration. Review the migration before applying.")})},"ee"),e[20]=l,e[21]=ee):ee=e[21];let de=ee,D;e[22]===Symbol.for("react.memo_cache_sentinel")?(D=r(T=>{v(T.target.value)},"R"),e[22]=D):D=e[22];let te=D,j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=r(T=>{P(T.target.value)},"M"),e[23]=j):j=e[23];let ye=j,ce;e[24]===Symbol.for("react.memo_cache_sentinel")?(ce=r(T=>{L(T.target.value)},"ce"),e[24]=ce):ce=e[24];let be=ce,R;e[25]===Symbol.for("react.memo_cache_sentinel")?(R=r(T=>{G(T.target.value)},"K"),e[25]=R):R=e[25];let X=R,V;e[26]===Symbol.for("react.memo_cache_sentinel")?(V=r(T=>{M(T.target.value)},"U"),e[26]=V):V=e[26];let le=V,U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=r(T=>{C(T.target.value)},"V"),e[27]=U):U=e[27];let ae=U,z;e[28]===Symbol.for("react.memo_cache_sentinel")?(z=r(T=>{$(T.target.checked)},"$"),e[28]=z):z=e[28];let ne=z,se;e[29]!==a?(se=r(()=>{ue(a({to:"/migrations"}))},"ne"),e[29]=a,e[30]=se):se=e[30];let f=se,re;e[31]!==l?(re=l("Edit schema"),e[31]=l,e[32]=re):re=e[32];let H;e[33]!==re?(H=(0,t.jsx)(Ge,{children:re}),e[33]=re,e[34]=H):H=e[34];let Ne;e[35]!==l?(Ne=l("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=l,e[36]=Ne):Ne=e[36];let fe;e[37]!==Ne?(fe=(0,t.jsx)(Ke,{children:Ne}),e[37]=Ne,e[38]=fe):fe=e[38];let h;e[39]!==H||e[40]!==fe?(h=(0,t.jsxs)(Pe,{children:[H,fe]}),e[39]=H,e[40]=fe,e[41]=h):h=e[41];let w=n.length>0,N;e[42]!==m||e[43]!==de||e[44]!==w?(N=(0,t.jsx)(gt,{hasTables:w,mode:m,onAddColumn:ve,onAddIndex:Z,onAddTable:J,onDestructive:de}),e[42]=m,e[43]=de,e[44]=w,e[45]=N):N=e[45];let q;e[46]!==d||e[47]!==m||e[48]!==pe||e[49]!==l||e[50]!==i?(q=m==="addTable"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-table-name",children:l("Table name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:te,value:i})]}),(0,t.jsx)(me,{"data-testid":"sc-editor-table-apply",disabled:d||i.trim()==="",onClick:pe,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[46]=d,e[47]=m,e[48]=pe,e[49]=l,e[50]=i,e[51]=q):q=e[51];let A;e[52]!==d||e[53]!==b||e[54]!==m||e[55]!==oe||e[56]!==l||e[57]!==n||e[58]!==y||e[59]!==_?(A=m==="addColumn"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-table",id:"sc-editor-column-table",onChange:X,value:y,children:n.map(Tt)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-name",children:l("Column name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:ye,value:b})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-type",children:l("Column type")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-type",id:"sc-editor-column-type",onChange:be,value:_,children:yt.map(St)})]}),(0,t.jsx)("span",{className:"text-[11px] text-muted-foreground",children:l("Optional")}),(0,t.jsx)(me,{"data-testid":"sc-editor-column-apply",disabled:d||b.trim()===""||y==="",onClick:oe,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[52]=d,e[53]=b,e[54]=m,e[55]=oe,e[56]=l,e[57]=n,e[58]=y,e[59]=_,e[60]=A):A=e[60];let Te;e[61]!==d||e[62]!==S||e[63]!==E||e[64]!==m||e[65]!==W||e[66]!==l||e[67]!==n||e[68]!==y||e[69]!==F?(Te=m==="addIndex"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-index-table",id:"sc-editor-index-table",onChange:X,value:y,children:n.map(_t)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-name",children:l("Index name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:le,value:E})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-fields",children:l("Index fields (comma-separated)")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:ae,value:S})]}),(0,t.jsxs)(we,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[(0,t.jsx)("input",{checked:F,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:ne,type:"checkbox"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:l("Unique")})]}),(0,t.jsx)(me,{"data-testid":"sc-editor-index-apply",disabled:d||E.trim()===""||S.trim()==="",onClick:W,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[61]=d,e[62]=S,e[63]=E,e[64]=m,e[65]=W,e[66]=l,e[67]=n,e[68]=y,e[69]=F,e[70]=Te):Te=e[70];let Se;e[71]!==f||e[72]!==o?(Se=(0,t.jsx)(xt,{onOpenMigrations:f,result:o}),e[71]=f,e[72]=o,e[73]=Se):Se=e[73];let _e;e[74]!==N||e[75]!==q||e[76]!==A||e[77]!==Te||e[78]!==Se?(_e=(0,t.jsxs)(Le,{children:[N,q,A,Te,Se]}),e[74]=N,e[75]=q,e[76]=A,e[77]=Te,e[78]=Se,e[79]=_e):_e=e[79];let ke;return e[80]!==h||e[81]!==_e?(ke=(0,t.jsxs)(qe,{"data-testid":"sc-editor",size:"sm",children:[h,_e]}),e[80]=h,e[81]=_e,e[82]=ke):ke=e[82],ke},"Nt");function Tt(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(Tt,"Tt");function St(s){return(0,t.jsx)("option",{value:s.validator,children:s.label},s.validator)}r(St,"St");function _t(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(_t,"wt");var Ze=[],kt=r(s=>{let e=(0,Ce.c)(5),{open:u}=s,n=u&&"rotate-90",l;e[0]!==n?(l=De("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",n),e[0]=n,e[1]=l):l=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[2]=a):a=e[2];let m;return e[3]!==l?(m=(0,t.jsx)("svg",{"aria-hidden":"true",className:l,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:a}),e[3]=l,e[4]=m):m=e[4],m},"_t"),et=r(s=>{let e=(0,Ce.c)(20),{children:u,expanded:n,name:l,onToggle:a,rowCount:m,rowTestId:c,toggleTestId:d}=s,g;e[0]!==n?(g=(0,t.jsx)(kt,{open:n}),e[0]=n,e[1]=g):g=e[1];let o;e[2]!==l?(o=(0,t.jsx)("span",{className:"truncate font-mono text-xs text-foreground",title:l,children:l}),e[2]=l,e[3]=o):o=e[3];let p;e[4]!==m?(p=(0,t.jsxs)("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",m,")"]}),e[4]=m,e[5]=p):p=e[5];let i;e[6]!==n||e[7]!==a||e[8]!==g||e[9]!==o||e[10]!==p||e[11]!==d?(i=(0,t.jsxs)("button",{"aria-expanded":n,className:"flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40","data-testid":d,onClick:a,type:"button",children:[g,o," ",p]}),e[6]=n,e[7]=a,e[8]=g,e[9]=o,e[10]=p,e[11]=d,e[12]=i):i=e[12];let v;e[13]!==u||e[14]!==n?(v=n&&(0,t.jsx)("div",{className:"px-3 pb-3 ps-8",children:u}),e[13]=u,e[14]=n,e[15]=v):v=e[15];let b;return e[16]!==c||e[17]!==i||e[18]!==v?(b=(0,t.jsxs)("li",{className:"border-t border-border/60 first:border-t-0","data-testid":c,children:[i,v]}),e[16]=c,e[17]=i,e[18]=v,e[19]=b):b=e[19],b},"Ye"),tt=r(s=>{let e=(0,Ce.c)(5),{columns:u,testId:n}=s,l;e[0]!==u?(l=u.map(At),e[0]=u,e[1]=l):l=e[1];let a;return e[2]!==l||e[3]!==n?(a=(0,t.jsx)("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":n,children:l}),e[2]=l,e[3]=n,e[4]=a):a=e[4],a},"He"),It=r(s=>{let e=(0,Ce.c)(10),{heading:u,indexes:n,testId:l}=s,a;e[0]!==u?(a=(0,t.jsx)("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:u}),e[0]=u,e[1]=a):a=e[1];let m;e[2]!==n?(m=n.map(Ft),e[2]=n,e[3]=m):m=e[3];let c;e[4]!==m||e[5]!==l?(c=(0,t.jsx)("ul",{className:"flex flex-col gap-1","data-testid":l,children:m}),e[4]=m,e[5]=l,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=(0,t.jsxs)("div",{className:"pt-3",children:[a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d},"Et"),lt=r(s=>De("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",s?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"Xe"),Xt=r(s=>{let e=(0,Ce.c)(85),{initialShardKey:u,initialTable:n,schemaEditable:l}=s,a=Fe(),m;e[0]!==u||e[1]!==n?(m={initialShardKey:u,initialTable:n},e[0]=u,e[1]=n,e[2]=m):m=e[2];let{columns:c,diagramTables:d,error:g,expanded:o,filteredGlobalTables:p,filteredTables:i,globalColumns:v,globalError:b,globalExpanded:P,globalTables:_,indexes:L,refresh:y,setShardKey:G,setTableFilter:E,setView:M,shardColumnsError:S,shardKey:C,tableFilter:F,tables:$,toggle:he,toggleGlobal:Q,view:I}=mt(m),K;e[3]!==M?(K=r(()=>{M("list")},"q"),e[3]=M,e[4]=K):K=e[4];let k=K,pe;e[5]!==M?(pe=r(()=>{M("graph")},"ue"),e[5]=M,e[6]=pe):pe=e[6];let B=pe,oe;e[7]!==E?(oe=r(f=>{E(f.target.value)},"ie"),e[7]=E,e[8]=oe):oe=e[8];let Y=oe,W;e[9]!==y||e[10]!==C?(W=r(f=>{ue(y(C))},"Y"),e[9]=y,e[10]=C,e[11]=W):W=e[11];let xe=W,J;e[12]!==$?(J=$??[],e[12]=$,e[13]=J):J=e[13];let ie;e[14]!==J?(ie=J.map(zt),e[14]=J,e[15]=ie):ie=e[15];let ve=ie,O;e[16]!==G||e[17]!==C?(O=(0,t.jsx)(Xe,{onChange:G,testId:"sc-shard-input",value:C}),e[16]=G,e[17]=C,e[18]=O):O=e[18];let Z;e[19]!==a?(Z=a("Schema view"),e[19]=a,e[20]=Z):Z=e[20];let ee=I==="graph",de=I==="graph",D;e[21]!==de?(D=lt(de),e[21]=de,e[22]=D):D=e[22];let te;e[23]!==a?(te=a("Graph"),e[23]=a,e[24]=te):te=e[24];let j;e[25]!==B||e[26]!==ee||e[27]!==D||e[28]!==te?(j=(0,t.jsx)("button",{"aria-selected":ee,className:D,"data-testid":"sc-view-graph",onClick:B,role:"tab",type:"button",children:te}),e[25]=B,e[26]=ee,e[27]=D,e[28]=te,e[29]=j):j=e[29];let ye=I==="list",ce=I==="list",be;e[30]!==ce?(be=lt(ce),e[30]=ce,e[31]=be):be=e[31];let R;e[32]!==a?(R=a("Table list"),e[32]=a,e[33]=R):R=e[33];let X;e[34]!==k||e[35]!==ye||e[36]!==be||e[37]!==R?(X=(0,t.jsx)("button",{"aria-selected":ye,className:be,"data-testid":"sc-view-list",onClick:k,role:"tab",type:"button",children:R}),e[34]=k,e[35]=ye,e[36]=be,e[37]=R,e[38]=X):X=e[38];let V;e[39]!==j||e[40]!==X||e[41]!==Z?(V=(0,t.jsxs)("div",{"aria-label":Z,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[j,X]}),e[39]=j,e[40]=X,e[41]=Z,e[42]=V):V=e[42];let le;e[43]!==V||e[44]!==O?(le=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[O,V]}),e[43]=V,e[44]=O,e[45]=le):le=e[45];let U;e[46]!==xe||e[47]!==l||e[48]!==ve?(U=l===!0&&(0,t.jsx)(wt,{onApplied:xe,tableNames:ve}),e[46]=xe,e[47]=l,e[48]=ve,e[49]=U):U=e[49];let ae;e[50]!==Y||e[51]!==a||e[52]!==F||e[53]!==I?(ae=I==="list"&&(0,t.jsx)(Ae,{"aria-label":a("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:Y,placeholder:a("Filter tables"),value:F}),e[50]=Y,e[51]=a,e[52]=F,e[53]=I,e[54]=ae):ae=e[54];let z;e[55]!==d||e[56]!==g||e[57]!==b||e[58]!==S||e[59]!==C||e[60]!==I?(z=I==="graph"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),b!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:b}),(0,t.jsx)(Qe,{columnsError:S[C]===!0,tables:d,testIdPrefix:"sc-graph"})]}),e[55]=d,e[56]=g,e[57]=b,e[58]=S,e[59]=C,e[60]=I,e[61]=z):z=e[61];let ne;e[62]!==c||e[63]!==g||e[64]!==o||e[65]!==p||e[66]!==i||e[67]!==v||e[68]!==b||e[69]!==P||e[70]!==_||e[71]!==L||e[72]!==C||e[73]!==a||e[74]!==$||e[75]!==he||e[76]!==Q||e[77]!==I?(ne=I==="list"&&(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)(qe,{"data-testid":"sc-shard-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Re,{tier:"shard"}),(0,t.jsx)(Ge,{children:a("Shard tables")}),$!==null&&(0,t.jsx)(ze,{className:"ms-auto tabular-nums",variant:"outline",children:i.length})]}),(0,t.jsx)(Ke,{children:Me.shard.hint})]}),(0,t.jsxs)(Le,{children:[g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),$!==null&&$.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:a("No tables in this shard.")}),$!==null&&$.length>0&&i.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:a("No tables match your filter.")}),i.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:i.map(f=>{let re=`${C}:${f.name}`,H=L[re]??[];return(0,t.jsxs)(et,{expanded:o===f.name,name:f.name,onToggle:r(()=>{ue(he(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-table-${f.name}`,toggleTestId:`sc-toggle-${f.name}`,children:[(0,t.jsx)(tt,{columns:c[re]??Ze,testId:`sc-columns-${f.name}`}),H.length>0&&(0,t.jsx)(It,{heading:a("Indexes"),indexes:H,testId:`sc-indexes-${f.name}`})]},f.name)})})]})]}),(0,t.jsxs)(qe,{"data-testid":"sc-global-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Re,{tier:"global"}),(0,t.jsx)(Ge,{children:a("Global tables (D1)")}),_!==null&&(0,t.jsx)(ze,{className:"ms-auto tabular-nums",variant:"outline",children:p.length})]}),(0,t.jsx)(Ke,{children:Me.global.hint})]}),(0,t.jsxs)(Le,{children:[b!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:b}),_!==null&&_.length===0&&(0,t.jsx)(We,{description:Me.global.hint,testId:"sc-global-empty",title:a("No global tables.")}),_!==null&&_.length>0&&p.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:a("No tables match your filter.")}),p.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:p.map(f=>(0,t.jsx)(et,{expanded:P===f.name,name:f.name,onToggle:r(()=>{ue(Q(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-global-table-${f.name}`,toggleTestId:`sc-global-toggle-${f.name}`,children:(0,t.jsx)(tt,{columns:v[f.name]??Ze,testId:`sc-global-columns-${f.name}`})},f.name))})]})]})]}),e[62]=c,e[63]=g,e[64]=o,e[65]=p,e[66]=i,e[67]=v,e[68]=b,e[69]=P,e[70]=_,e[71]=L,e[72]=C,e[73]=a,e[74]=$,e[75]=he,e[76]=Q,e[77]=I,e[78]=ne):ne=e[78];let se;return e[79]!==le||e[80]!==U||e[81]!==ae||e[82]!==z||e[83]!==ne?(se=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[le,U,ae,z,ne]}),e[79]=le,e[80]=U,e[81]=ae,e[82]=z,e[83]=ne,e[84]=se):se=e[84],se},"Wt");function At(s){return(0,t.jsx)("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:s},s)}r(At,"It");function Ft(s){return(0,t.jsxs)("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[(0,t.jsx)("span",{className:"font-mono",children:s.name}),(0,t.jsx)(ze,{variant:"outline",children:s.type}),s.unique===!0&&(0,t.jsx)(ze,{variant:"secondary",children:"unique"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:s.fields.join(", ")})]},`${s.type}:${s.name}`)}r(Ft,"kt");function zt(s){return s.name}r(zt,"At");export{Xt as SchemaViewer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as $}from"./chunk-
|
|
1
|
+
import{a as $}from"./chunk-OQS4HFKC.js";import{a as b}from"./chunk-H4SLAZAN.js";import"./chunk-PZ4QDWTI.js";import"./chunk-DC5AAWSA.js";import"./chunk-F7JOSNAT.js";import{a as u}from"./chunk-VDW32UET.js";import{c as p}from"./chunk-2UWKGSEA.js";import"./chunk-22WJHOC4.js";import"./chunk-RCZTUWG3.js";import{a as y,b as w,c as j,d as h,e as c,f as i}from"./chunk-L4EZAHCD.js";import{a as d,e as l}from"./chunk-IYWVSMAY.js";import{d as k}from"./chunk-BKM6PMSO.js";import"./chunk-VYW2PAWC.js";import{a as o,d as I,g as T,i as x}from"./chunk-R5ZTCHCE.js";var e=I(T(),1);var m={clean:"text-emerald-600 dark:text-emerald-400",exempt:"text-muted-foreground",failing:"text-red-600 dark:text-red-400",warned:"text-amber-600 dark:text-amber-400"},A={"at-risk":"text-red-600 dark:text-red-400",excellent:"text-emerald-600 dark:text-emerald-400",good:"text-emerald-600 dark:text-emerald-400","needs-work":"text-amber-600 dark:text-amber-400"},C=o((r,a)=>`exempt: ${r.exemptReason===void 0||r.exemptReason===""?a:r.exemptReason}`,"E"),E=o(r=>r.toSorted((a,n)=>a.coverage==="clean"&&n.coverage!=="clean"?1:n.coverage==="clean"&&a.coverage!=="clean"?-1:a.score-n.score),"S"),Y=o(({testId:r="advisor-health"})=>{let a=k(),n=p(u.getAdvisories,{},{live:!0}),g=p(u.getAdvisorProcedures,{},{live:!0}),f=n.data?.advisories??null,N=g.data?.procedures??null,t=f===null||N===null?null:$(N,f),v=g.error??n.error;if(v!==null)return(0,e.jsx)(b,{error:v,testId:`${r}-error`});if(t===null)return(0,e.jsx)(d,{children:(0,e.jsx)(l,{className:"py-8 text-center text-muted-foreground","data-testid":`${r}-loading`,children:a("Loading\u2026")})});let R=E(t.procedures);return(0,e.jsxs)("div",{className:"space-y-4","data-testid":r,children:[(0,e.jsx)(d,{children:(0,e.jsxs)(l,{className:"flex flex-wrap items-baseline gap-x-6 gap-y-2 py-6",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:x("text-4xl font-semibold tabular-nums",A[t.grade]),"data-testid":`${r}-score`,children:t.score}),(0,e.jsx)("span",{className:"text-muted-foreground text-lg",children:"/100"})]}),(0,e.jsx)("span",{className:x("text-sm font-medium uppercase tracking-wide",A[t.grade]),"data-testid":`${r}-grade`,children:t.grade}),(0,e.jsxs)("div",{className:"text-muted-foreground flex gap-4 text-sm tabular-nums","data-testid":`${r}-summary`,children:[(0,e.jsxs)("span",{className:m.clean,children:[t.summary.clean," ",a("clean")]}),(0,e.jsxs)("span",{className:m.warned,children:[t.summary.warned," ",a("warned")]}),(0,e.jsxs)("span",{className:m.failing,children:[t.summary.failing," ",a("failing")]}),(0,e.jsxs)("span",{className:m.exempt,children:[t.summary.exempt," ",a("exempt")]})]})]})}),t.project.checks.length>0&&(0,e.jsx)(d,{children:(0,e.jsxs)(l,{className:"py-4 text-sm","data-testid":`${r}-project`,children:[(0,e.jsxs)("span",{className:"font-medium",children:[a("Schema & config")," ",t.project.score,"/100"]}),(0,e.jsxs)("span",{className:"text-muted-foreground",children:[" \u2014 ",t.project.checks.map(s=>s.name).join(", ")]})]})}),(0,e.jsx)(d,{children:(0,e.jsx)(l,{className:"p-0",children:(0,e.jsxs)(y,{children:[(0,e.jsx)(w,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(c,{className:"w-20",children:a("Score")}),(0,e.jsx)(c,{children:a("Procedure")}),(0,e.jsx)(c,{className:"w-32",children:a("Kind")}),(0,e.jsx)(c,{children:a("Rules fired")})]})}),(0,e.jsx)(j,{children:R.map(s=>(0,e.jsxs)(h,{"data-testid":`${r}-row`,children:[(0,e.jsx)(i,{className:x("tabular-nums font-medium",m[s.coverage]),children:s.coverage==="exempt"?"\u2014":s.score}),(0,e.jsx)(i,{className:"font-mono text-xs",children:s.id}),(0,e.jsxs)(i,{className:"text-muted-foreground text-xs",children:[s.visibility," ",s.kind,s.sensitivity.level==="high"&&(0,e.jsx)("span",{className:"ml-1 text-amber-600 dark:text-amber-400",children:a("sensitive")})]}),(0,e.jsx)(i,{className:"text-muted-foreground text-xs",children:s.coverage==="exempt"?C(s,a("no reason given")):s.checks.map(S=>S.name).join(", ")})]},s.id))})]})})})]})},"Y");export{Y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as x}from"./chunk-VDW32UET.js";import{c as S}from"./chunk-
|
|
1
|
+
import{a as x}from"./chunk-VDW32UET.js";import{c as S}from"./chunk-2UWKGSEA.js";import{f as q}from"./chunk-22WJHOC4.js";import{d as _,f as g,g as y,m as C}from"./chunk-BKM6PMSO.js";import{a as u,d as w,e as L,f as T,g as F}from"./chunk-R5ZTCHCE.js";var v=w(L(),1);var j={},A=g(x.aiGenerateSql),I=g(x.aiTableFilter),O=g(x.aiChartConfig),R=u(s=>{let e=q(),[i,d]=(0,v.useState)({}),[n,r]=(0,v.useState)({}),a=S(x.aiAvailable,j,{shardKey:s}),[f,l]=(0,v.useState)(!1),b=f||a.data?.available===!1,p=u(t=>{d(o=>({...o,[t]:!0})),r(o=>({...o,[t]:void 0}))},"i"),h=u((t,o)=>{d(c=>({...c,[t]:!1})),o!==void 0&&r(c=>({...c,[t]:o})),o==="no-ai-binding"&&l(!0)},"a");return{generate:u(async(t,o)=>{p("sql");try{let{result:c}=await e.query(A,{failedError:o?.error,failedSql:o?.sql,prompt:t},y(s));return h("sql",c.degraded?c.reason:void 0),c.degraded?void 0:c.sql}catch{h("sql","ai-error");return}},"generate"),inferChart:u(async t=>{p("chart");try{let{result:o}=await e.query(O,t,y(s));return h("chart",o.degraded?o.reason:void 0),o.degraded?void 0:o.chart}catch{h("chart","ai-error");return}},"inferChart"),pending:u(t=>i[t]===!0,"pending"),reason:u(t=>n[t],"reason"),suggestFilter:u(async(t,o)=>{p("filter");try{let{result:c}=await e.query(I,{prompt:t,table:o},y(s));return h("filter",c.degraded?c.reason:void 0),c.degraded?void 0:c.clauses}catch{h("filter","ai-error");return}},"suggestFilter"),unavailable:b}},"w");var N=w(T(),1);var m=w(F(),1);var G=u((s,e)=>{if(e==="")return[{match:!1,offset:0,text:s}];let i=[],d=s.toLowerCase(),n=e.toLowerCase(),r=0;for(let a=d.indexOf(n);a!==-1;a=d.indexOf(n,r))a>r&&i.push({match:!1,offset:r,text:s.slice(r,a)}),i.push({match:!0,offset:a,text:s.slice(a,a+e.length)}),r=a+e.length;return r<s.length&&i.push({match:!1,offset:r,text:s.slice(r)}),i},"N"),U=u(s=>{let e=(0,N.c)(9),{highlight:i,value:d}=s;if(d==null){let l;return e[0]===Symbol.for("react.memo_cache_sentinel")?(l=(0,m.jsx)("span",{className:"text-muted-foreground/50 italic",children:"NULL"}),e[0]=l):l=e[0],l}let n,r,a;if(e[1]!==i||e[2]!==d){a=Symbol.for("react.early_return_sentinel");e:{let l=C(d);if(i===void 0||i===""){a=(0,m.jsx)("span",{title:l,children:l});break e}n=l,r=G(l,i).map(z)}e[1]=i,e[2]=d,e[3]=n,e[4]=r,e[5]=a}else n=e[3],r=e[4],a=e[5];if(a!==Symbol.for("react.early_return_sentinel"))return a;let f;return e[6]!==n||e[7]!==r?(f=(0,m.jsx)("span",{title:n,children:r}),e[6]=n,e[7]=r,e[8]=f):f=e[8],f},"v"),Q=u(s=>{let e=(0,N.c)(22),{columns:i,rows:d}=s,n=_(),r;e[0]!==n?(r=n("Field"),e[0]=n,e[1]=r):r=e[1];let a;e[2]!==r?(a=(0,m.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:r}),e[2]=r,e[3]=a):a=e[3];let f;if(e[4]!==d||e[5]!==n){let t;e[7]!==n?(t=u((o,c)=>(0,m.jsx)("th",{className:"border-b border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase tabular-nums text-muted-foreground",children:n("Row {n}",{n:c+1})},c),"c"),e[7]=n,e[8]=t):t=e[8],f=d.map(t),e[4]=d,e[5]=n,e[6]=f}else f=e[6];let l;e[9]!==a||e[10]!==f?(l=(0,m.jsx)("thead",{className:"sticky top-0 z-10 bg-muted",children:(0,m.jsxs)("tr",{children:[a,f]})}),e[9]=a,e[10]=f,e[11]=l):l=e[11];let b;if(e[12]!==i||e[13]!==d){let t;e[15]!==d?(t=u(o=>(0,m.jsxs)("tr",{className:"hover:bg-muted/40",children:[(0,m.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono font-medium whitespace-nowrap",scope:"row",children:o}),d.map((c,k)=>(0,m.jsx)("td",{className:"max-w-md truncate border-b border-border px-3 py-1.5 font-mono",children:(0,m.jsx)(U,{value:c[o]})},k))]},o),"c"),e[15]=d,e[16]=t):t=e[16],b=i.map(t),e[12]=i,e[13]=d,e[14]=b}else b=e[14];let p;e[17]!==b?(p=(0,m.jsx)("tbody",{children:b}),e[17]=b,e[18]=p):p=e[18];let h;return e[19]!==l||e[20]!==p?(h=(0,m.jsx)("div",{className:"min-h-0 flex-1 overflow-auto","data-testid":"db-transposed",children:(0,m.jsxs)("table",{className:"border-collapse text-xs",children:[l,p]})}),e[19]=l,e[20]=p,e[21]=h):h=e[21],h},"T"),V=u(({children:s,layout:e="card",testId:i})=>(0,m.jsx)("div",{className:e==="fill"?"flex min-h-0 flex-1 flex-col overflow-hidden border-t border-border":"overflow-x-auto border border-border bg-card","data-testid":i,children:s}),"j");function z(s){return(0,m.jsx)("mark",{className:s.match?"rounded-sm bg-warning/40 text-foreground":"bg-transparent text-inherit",children:s.text},s.offset)}u(z,"_");export{R as a,U as b,Q as c,V as d};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as nt}from"./chunk-TNKECJW4.js";import{e as Ve}from"./chunk-4YTSKL4R.js";import{a as Ue}from"./chunk-BWEXJENB.js";import{b as Fe}from"./chunk-SPDZUX4P.js";import{a as D}from"./chunk-VDW32UET.js";import{c as ke}from"./chunk-
|
|
1
|
+
import{a as nt}from"./chunk-TNKECJW4.js";import{e as Ve}from"./chunk-4YTSKL4R.js";import{a as Ue}from"./chunk-BWEXJENB.js";import{b as Fe}from"./chunk-SPDZUX4P.js";import{a as D}from"./chunk-VDW32UET.js";import{c as ke}from"./chunk-2UWKGSEA.js";import{f as Ee}from"./chunk-22WJHOC4.js";import{a as Ye}from"./chunk-UANVABQG.js";import{a as T,e as He}from"./chunk-IYWVSMAY.js";import{d as $,f as Qe,g as Xe,l as et,o as Se,p as tt,q as at}from"./chunk-BKM6PMSO.js";import{a as m,d as Be,e as ct,f as dt,g as mt,i as We}from"./chunk-R5ZTCHCE.js";var S=Be(dt(),1);var I=Be(ct(),1);var n=Be(mt(),1);var ut=Qe(D.studioFeatures),it={analytics:!0,auth:!0,containers:!0,flags:!0,kv:!0,mail:!0,notifications:!0,payments:!0,queues:!0,scheduler:!0,storage:!0,vectors:!0,workflows:!0},pt=m(t=>{if(t===null||typeof t!="object")return it;let e=t,s=m(a=>typeof e[a]=="boolean"?e[a]:!0,"n");return{analytics:s("analytics"),auth:s("auth"),containers:s("containers"),flags:s("flags"),kv:s("kv"),mail:s("mail"),notifications:s("notifications"),payments:s("payments"),queues:s("queues"),scheduler:s("scheduler"),storage:s("storage"),vectors:s("vectors"),workflows:s("workflows")}},"mt"),ft=m(()=>{let t=(0,S.c)(3),e=Ee(),[s,a]=(0,I.useState)(it),r,l;return t[0]!==e?(r=m(()=>{Se((async()=>{try{a(pt(await e.query(ut,{},Xe(""))))}catch{}})())},"a"),l=[e],t[0]=e,t[1]=r,t[2]=l):(r=t[1],l=t[2]),(0,I.useEffect)(r,l),s},"ft"),ht=m(()=>{let t=(0,S.c)(1),e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.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,n.jsx)("path",{d:"m9 6 6 6-6 6",strokeLinecap:"round",strokeLinejoin:"round"})}),t[0]=e):e=t[0],e},"pt"),gt=m(t=>{let e=(0,S.c)(24),{group:s}=t,a=$(),r=Ve(),l;e[0]!==s.tab||e[1]!==r?(l=m(()=>{Se(r({to:`/${s.tab}`}))},"r"),e[0]=s.tab,e[1]=r,e[2]=l):l=e[2];let o=l,i=s.bindings.length,c;e[3]!==s.label?(c=(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:s.label}),e[3]=s.label,e[4]=c):c=e[4];let p;e[5]===Symbol.for("react.memo_cache_sentinel")?(p=(0,n.jsx)(ht,{}),e[5]=p):p=e[5];let d;e[6]!==c?(d=(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[c,p]}),e[6]=c,e[7]=d):d=e[7];let f;e[8]!==i||e[9]!==a?(f=i===1?a("1 binding"):a("{count} bindings",{count:i}),e[8]=i,e[9]=a,e[10]=f):f=e[10];let u;e[11]!==f?(u=(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:f}),e[11]=f,e[12]=u):u=e[12];let h;e[13]!==i||e[14]!==s.bindings?(h=i>0&&(0,n.jsx)("div",{className:"flex flex-wrap gap-1.5",children:s.bindings.map(yt)}),e[13]=i,e[14]=s.bindings,e[15]=h):h=e[15];let g;e[16]!==d||e[17]!==u||e[18]!==h?(g=(0,n.jsxs)(He,{className:"flex flex-col gap-2 py-4",children:[d,u,h]}),e[16]=d,e[17]=u,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==s.testId||e[21]!==o||e[22]!==g?(x=(0,n.jsx)(T,{className:"cursor-pointer gap-0 py-0 transition-colors hover:bg-muted/40","data-testid":s.testId,onClick:o,children:g}),e[20]=s.testId,e[21]=o,e[22]=g,e[23]=x):x=e[23],x},"ht"),st=["kv","files","vectors"],xt=m((t,e)=>[...t.filter(s=>s.tab!==e.tab),e].toSorted((s,a)=>st.indexOf(s.tab)-st.indexOf(a.tab)),"gt"),bt=m(()=>{let t=(0,S.c)(19),e=Ee(),s=ft(),a=$(),r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=[],t[0]=r):r=t[0];let[l,o]=(0,I.useState)(r),i,c;if(t[1]!==e||t[2]!==s.kv||t[3]!==s.storage||t[4]!==s.vectors||t[5]!==a?(i=m(()=>{let g={cancelled:!1},x=[{enabled:s.kv,label:a("KV Namespaces"),load:m(async()=>(await e.listKvNamespaces()).map(vt),"load"),tab:"kv",testId:"home-binding-kv"},{enabled:s.storage,label:a("R2 Buckets"),load:m(()=>e.listStorageBuckets(),"load"),tab:"files",testId:"home-binding-r2"},{enabled:s.vectors,label:a("Vectorize Indexes"),load:m(async()=>(await e.listVectorIndexes()).map(Nt),"load"),tab:"vectors",testId:"home-binding-vectors"}];for(let b of x)b.enabled&&Se((async()=>{try{let y=await b.load();if(!g.cancelled){let k={bindings:y,label:b.label,tab:b.tab,testId:b.testId};o(M=>xt(M,k))}}catch{}})());return()=>{g.cancelled=!0}},"i"),c=[e,s.kv,s.storage,s.vectors,a],t[1]=e,t[2]=s.kv,t[3]=s.storage,t[4]=s.vectors,t[5]=a,t[6]=i,t[7]=c):(i=t[6],c=t[7]),(0,I.useEffect)(i,c),l.length===0)return null;let p;t[8]!==a?(p=a("Bindings"),t[8]=a,t[9]=p):p=t[9];let d;t[10]!==p?(d=(0,n.jsx)("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:p}),t[10]=p,t[11]=d):d=t[11];let f;t[12]!==l?(f=l.map(_t),t[12]=l,t[13]=f):f=t[13];let u;t[14]!==f?(u=(0,n.jsx)("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:f}),t[14]=f,t[15]=u):u=t[15];let h;return t[16]!==d||t[17]!==u?(h=(0,n.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"home-bindings",children:[d,u]}),t[16]=d,t[17]=u,t[18]=h):h=t[18],h},"xt");function yt(t){return(0,n.jsx)(Fe,{variant:"secondary",children:t},t)}m(yt,"bt");function vt(t){return t.binding}m(vt,"yt");function Nt(t){return t.name}m(Nt,"vt");function _t(t){return(0,n.jsx)(gt,{group:t},t.tab)}m(_t,"Nt");var St=[{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"}],kt=m(t=>JSON.stringify({mcpServers:{lunora:{args:["-y","@lunora/mcp"],command:"npx",env:{LUNORA_ADMIN_TOKEN:"<your-admin-token>",LUNORA_URL:t}}}},null,2),"St"),wt=m(t=>{let e=St.map(s=>`- ${s.name} \u2014 ${s.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"),Lt=1500,Ct=m(()=>{let t=(0,S.c)(35),e=$(),s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=tt(),t[0]=s):s=t[0];let a=s,[r,l]=(0,I.useState)(null),o,i;t[1]!==r?(o=m(()=>{if(r===null)return;let A=globalThis.setTimeout(()=>{l(null)},Lt);return()=>{globalThis.clearTimeout(A)}},"o"),i=[r],t[1]=r,t[2]=o,t[3]=i):(o=t[2],i=t[3]),(0,I.useEffect)(o,i);let c;t[4]===Symbol.for("react.memo_cache_sentinel")?(c=m((A,j)=>{at(j)&&l(A)},"c"),t[4]=c):c=t[4];let p=c,d;t[5]===Symbol.for("react.memo_cache_sentinel")?(d=m(()=>{p("config",kt(a))},"d"),t[5]=d):d=t[5];let f=d,u;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=m(()=>{p("prompt",wt(a))},"u"),t[6]=u):u=t[6];let h=u,g;t[7]!==e?(g=e("Connect an AI agent"),t[7]=e,t[8]=g):g=t[8];let x;t[9]!==g?(x=(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:g}),t[9]=g,t[10]=x):x=t[10];let b;t[11]!==e?(b=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[11]=e,t[12]=b):b=t[12];let y;t[13]!==b?(y=(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:b}),t[13]=b,t[14]=y):y=t[14];let k;t[15]!==x||t[16]!==y?(k=(0,n.jsxs)("div",{className:"flex flex-col gap-1.5 p-4",children:[x,y]}),t[15]=x,t[16]=y,t[17]=k):k=t[17];let M;t[18]===Symbol.for("react.memo_cache_sentinel")?(M=(0,n.jsx)("code",{className:"font-mono text-xs text-muted-foreground","data-testid":"home-connect-agent-command",children:"npx -y @lunora/mcp"}),t[18]=M):M=t[18];let w;t[19]!==r||t[20]!==e?(w=e(r==="config"?"Copied":"Copy MCP config"),t[19]=r,t[20]=e,t[21]=w):w=t[21];let v;t[22]!==w?(v=(0,n.jsx)(Ue,{"data-testid":"home-connect-agent-copy-config",onClick:f,size:"xs",variant:"outline",children:w}),t[22]=w,t[23]=v):v=t[23];let L;t[24]!==r||t[25]!==e?(L=e(r==="prompt"?"Copied":"Copy agent prompt"),t[24]=r,t[25]=e,t[26]=L):L=t[26];let C;t[27]!==L?(C=(0,n.jsx)(Ue,{"data-testid":"home-connect-agent-copy-prompt",onClick:h,size:"xs",variant:"outline",children:L}),t[27]=L,t[28]=C):C=t[28];let N;t[29]!==v||t[30]!==C?(N=(0,n.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border bg-muted/50 px-4 py-3",children:[M,(0,n.jsxs)("div",{className:"flex flex-wrap gap-2",children:[v,C]})]}),t[29]=v,t[30]=C,t[31]=N):N=t[31];let _;return t[32]!==k||t[33]!==N?(_=(0,n.jsxs)(T,{className:"gap-0 py-0","data-testid":"home-connect-agent",children:[k,N]}),t[32]=k,t[33]=N,t[34]=_):_=t[34],_},"wt"),It=(0,I.lazy)(()=>import("./chunk-MGC6PRMV.js")),Ze=m(t=>{if(t<1e3)return`${String(Math.round(t))}ms`;let e=t>=1e4?0:1;return`${(t/1e3).toFixed(e)}s`},"qe"),Mt=m((t,e)=>{let s=Math.max(0,Math.round((e-t)/1e3));if(s<60)return`${String(s)}s ago`;let a=Math.round(s/60);if(a<60)return`${String(a)}m ago`;let r=Math.round(a/60);return r<24?`${String(r)}h ago`:`${String(Math.round(r/24))}d ago`},"At"),rt=m((t,e)=>{if(t===void 0||t.length===0)return[];let s=new Map;for(let a of t)s.set(a.bucketMs,(s.get(a.bucketMs)??0)+a[e]);return[...s.entries()].toSorted(([a],[r])=>a-r).map(([,a])=>a)},"Qe"),lt=m((t,e=!0)=>{if(t.length<4)return null;let s=Math.floor(t.length/2),a=t.slice(0,s).reduce((o,i)=>o+i,0),r=t.slice(s).reduce((o,i)=>o+i,0);if(a===0)return null;let l=(r-a)/a*100;return{positive:e?l>=0:l<=0,text:`${l>=0?"+":""}${l.toFixed(1)}%`}},"He"),Re=m(t=>{let e=(0,S.c)(24),{delta:s,footer:a,label:r,trend:l,unit:o,value:i}=t,c=$(),p;e[0]!==r?(p=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r}),e[0]=r,e[1]=p):p=e[1];let d;e[2]!==i?(d=(0,n.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:i}),e[2]=i,e[3]=d):d=e[3];let f;e[4]!==o?(f=o!==void 0&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=f):f=e[5];let u;e[6]!==d||e[7]!==f?(u=(0,n.jsxs)("span",{className:"flex items-baseline gap-1.5",children:[d,f]}),e[6]=d,e[7]=f,e[8]=u):u=e[8];let h;e[9]!==l?(h=l!==void 0&&(0,n.jsx)(I.Suspense,{fallback:(0,n.jsx)("div",{"aria-hidden":"true",className:"h-8 w-28"}),children:(0,n.jsx)(It,{data:l})}),e[9]=l,e[10]=h):h=e[10];let g;e[11]!==u||e[12]!==h?(g=(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[u,h]}),e[11]=u,e[12]=h,e[13]=g):g=e[13];let x;e[14]!==p||e[15]!==g?(x=(0,n.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[p,g]}),e[14]=p,e[15]=g,e[16]=x):x=e[16];let b;e[17]!==s||e[18]!==a||e[19]!==c?(b=s==null?a!=null&&(0,n.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:a}):(0,n.jsxs)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px]",children:[(0,n.jsx)("span",{className:We("font-semibold",s.positive?"text-success":"text-destructive"),children:s.text})," ",(0,n.jsx)("span",{className:"text-muted-foreground",children:c("vs. prev.")})]}),e[17]=s,e[18]=a,e[19]=c,e[20]=b):b=e[20];let y;return e[21]!==x||e[22]!==b?(y=(0,n.jsxs)(T,{className:"justify-between gap-0 py-0",children:[x,b]}),e[21]=x,e[22]=b,e[23]=y):y=e[23],y},"Re"),At=m(()=>{let t=(0,S.c)(1),e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.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,n.jsx)("path",{d:"m9 6 6 6-6 6"})}),t[0]=e):e=t[0],e},"Lt"),Je=m(t=>{let e=(0,S.c)(7),{command:s,label:a}=t,r;e[0]!==a?(r=(0,n.jsx)("div",{className:"p-4",children:(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:a})}),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==s?(l=(0,n.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5",children:(0,n.jsx)("code",{className:"font-mono text-xs text-muted-foreground",children:s})}),e[2]=s,e[3]=l):l=e[3];let o;return e[4]!==r||e[5]!==l?(o=(0,n.jsxs)(T,{className:"justify-between gap-0 py-0",children:[r,l]}),e[4]=r,e[5]=l,e[6]=o):o=e[6],o},"Fe"),ot=m(t=>{let e=(0,S.c)(18),{count:s,onView:a,testId:r,title:l}=t,o=$(),i;e[0]!==l?(i=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=i):i=e[1];let c;e[2]!==s||e[3]!==o?(c=s===null?(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:o("No data yet")}):(0,n.jsx)(Fe,{variant:s>0?"destructive":"success",children:s>0?s:o("All clear")}),e[2]=s,e[3]=o,e[4]=c):c=e[4];let p;e[5]!==i||e[6]!==c?(p=(0,n.jsxs)("div",{className:"flex items-start justify-between gap-2 p-4",children:[i,c]}),e[5]=i,e[6]=c,e[7]=p):p=e[7];let d;e[8]!==o?(d=o("View"),e[8]=o,e[9]=d):d=e[9];let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=(0,n.jsx)(At,{}),e[10]=f):f=e[10];let u;e[11]!==a||e[12]!==d?(u=(0,n.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:a,type:"button",children:[d,f]}),e[11]=a,e[12]=d,e[13]=u):u=e[13];let h;return e[14]!==p||e[15]!==u||e[16]!==r?(h=(0,n.jsxs)(T,{className:"justify-between gap-0 py-0","data-testid":r,children:[p,u]}),e[14]=p,e[15]=u,e[16]=r,e[17]=h):h=e[17],h},"Ge"),$t=m(t=>{let e=(0,S.c)(7),{functions:s}=t,a=$(),r;if(e[0]!==s||e[1]!==a){let l=[...s].toSorted(Rt).slice(0,5),o;e[3]!==a?(o=a("Top functions"),e[3]=a,e[4]=o):o=e[4];let i;e[5]!==o?(i=(0,n.jsx)("div",{className:"border-b border-border px-4 py-3",children:(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o})}),e[5]=o,e[6]=i):i=e[6],r=(0,n.jsxs)(T,{className:"gap-0 py-0","data-testid":"home-top-functions",children:[i,l.length===0?(0,n.jsx)("p",{className:"px-4 py-8 text-center text-xs text-muted-foreground",children:a("No functions called yet.")}):(0,n.jsxs)("div",{className:"divide-y divide-border",children:[(0,n.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,n.jsx)("span",{children:a("Function")}),(0,n.jsx)("span",{className:"text-end",children:a("Calls")}),(0,n.jsx)("span",{className:"w-12 text-end",children:a("Avg")}),(0,n.jsx)("span",{className:"w-8 text-end",children:a("Err")})]}),l.map(qt)]})]}),e[0]=s,e[1]=a,e[2]=r}else r=e[2];return r},"Mt"),jt=m(t=>{let e=(0,S.c)(26),{subs:s}=t,a=$(),r;e[0]!==a?(r=a("Live connections"),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==r?(l=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r}),e[2]=r,e[3]=l):l=e[3];let o=s?.totalConnections??0,i;e[4]!==o?(i=o.toLocaleString(),e[4]=o,e[5]=i):i=e[5];let c;e[6]!==i?(c=(0,n.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:i}),e[6]=i,e[7]=c):c=e[7];let p;e[8]!==a?(p=a("sockets"),e[8]=a,e[9]=p):p=e[9];let d;e[10]!==p?(d=(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:p}),e[10]=p,e[11]=d):d=e[11];let f;e[12]!==c||e[13]!==d?(f=(0,n.jsxs)("span",{className:"flex items-baseline gap-1.5",children:[c,d]}),e[12]=c,e[13]=d,e[14]=f):f=e[14];let u=s?.totalSubscriptions??0,h;e[15]!==u?(h=u.toLocaleString(),e[15]=u,e[16]=h):h=e[16];let g;e[17]!==a?(g=a("active subscriptions"),e[17]=a,e[18]=g):g=e[18];let x;e[19]!==h||e[20]!==g?(x=(0,n.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]!==f?(b=(0,n.jsx)(T,{"data-testid":"home-live-connections",children:(0,n.jsxs)(He,{className:"flex flex-col gap-2.5 py-4",children:[l,f,x]})}),e[22]=x,e[23]=l,e[24]=f,e[25]=b):b=e[25],b},"It"),Tt=m(t=>{let e=(0,S.c)(7),{entries:s}=t,a=$(),r;if(e[0]!==s||e[1]!==a){let l=Date.now(),o;e[3]!==a?(o=a("Recent activity"),e[3]=a,e[4]=o):o=e[4];let i;e[5]!==o?(i=(0,n.jsx)("div",{className:"border-b border-border px-4 py-3",children:(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o})}),e[5]=o,e[6]=i):i=e[6],r=(0,n.jsxs)(T,{className:"gap-0 py-0","data-testid":"home-recent-activity",children:[i,s.length===0?(0,n.jsx)("p",{className:"px-4 py-8 text-center text-xs text-muted-foreground",children:a("No recent activity.")}):(0,n.jsx)("ul",{className:"divide-y divide-border",children:s.slice(0,5).map(c=>(0,n.jsxs)("li",{className:"flex items-center justify-between gap-3 px-4 py-2 text-[13px]",children:[(0,n.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,n.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-muted-foreground/40"}),(0,n.jsxs)("span",{className:"truncate text-foreground",children:[c.op,c.table!==void 0&&(0,n.jsxs)("span",{className:"text-muted-foreground",children:[" \xB7 ",c.table,c.id===void 0?"":`#${c.id}`]})]})]}),(0,n.jsx)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:Mt(c.ts,l)})]},c.seq))})]}),e[0]=s,e[1]=a,e[2]=r}else r=e[2];return r},"Tt"),Ot=m(t=>{let e=t.reduce((s,a)=>s+a.calls,0);return e===0?null:t.reduce((s,a)=>s+a.totalDurationMs,0)/e},"Ot"),Gt=m(t=>{let e=(0,S.c)(151),{initialShardKey:s}=t,a=$(),r=Ve(),l=s??"",o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={},e[0]=o):o=e[0];let i;e[1]!==l?(i={shardKey:l},e[1]=l,e[2]=i):i=e[2];let c=ke(D.getMetrics,o,i),p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p={},e[3]=p):p=e[3];let d;e[4]!==l?(d={shardKey:l},e[4]=l,e[5]=d):d=e[5];let f=ke(D.getFunctionStats,p,d),u,h;e[6]===Symbol.for("react.memo_cache_sentinel")?(u={},h={shardKey:""},e[6]=u,e[7]=h):(u=e[6],h=e[7]);let g=ke(D.getSecurityAudit,u,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 y=ke(D.listSubscriptions,x,b),k;e[11]===Symbol.for("react.memo_cache_sentinel")?(k={},e[11]=k):k=e[11];let M;e[12]!==l?(M={shardKey:l},e[12]=l,e[13]=M):M=e[13];let w=ke(D.getAuditLog,k,M),v=c.data??null,L,C,N,_,A,j,P,O,R,B,E,V,q,K,W,F,U,H;if(e[14]!==w.data||e[15]!==g.data||e[16]!==v||e[17]!==c.data||e[18]!==r||e[19]!==f.data||e[20]!==y.data||e[21]!==a){_=Array.isArray(f.data?.functions)?f.data.functions:[],P=y.data??null;let Ie;e[40]!==w.data?(Ie=Array.isArray(w.data?.entries)?w.data.entries:[],e[40]=w.data,e[41]=Ie):Ie=e[41],C=Ie,A=c.data===void 0||f.data===void 0?null:nt(v,_).length,j=Array.isArray(g.data?.findings)?g.data.findings.length:null;let Me;e[42]!==r?(Me=m(()=>{Se(r({to:"/security"}))},"Ae"),e[42]=r,e[43]=Me):Me=e[43],H=Me;let Ae;e[44]!==r?(Ae=m(()=>{Se(r({to:"/insights"}))},"Le"),e[44]=r,e[45]=Ae):Ae=e[45],U=Ae;let $e=rt(v?.history,"calls"),je=rt(v?.history,"errors"),Ge=Ot(_),Te=Math.max(0,..._.map(Kt)),z=v?.cache,Oe;e[46]!==z?(Oe=z!=null&&z.hits+z.misses>0?Math.round(z.hits/(z.hits+z.misses)*100):null,e[46]=z,e[47]=Oe):Oe=e[47],N=Oe,W="flex flex-col gap-6",F="lunora-home",E="grid gap-3 sm:grid-cols-2 xl:grid-cols-4",V="home-health";let Ke=lt($e),ye;e[48]!==a?(ye=a("Requests"),e[48]=a,e[49]=ye):ye=e[49];let ze=v?.requests??0,ve;e[50]!==ze?(ve=ze.toLocaleString(),e[50]=ze,e[51]=ve):ve=e[51],e[52]!==$e||e[53]!==Ke||e[54]!==ye||e[55]!==ve?(q=(0,n.jsx)(Re,{delta:Ke,label:ye,trend:$e,value:ve}),e[52]=$e,e[53]=Ke,e[54]=ye,e[55]=ve,e[56]=q):q=e[56];let De=lt(je,!1),Ne;e[57]!==a?(Ne=a("Errors"),e[57]=a,e[58]=Ne):Ne=e[58];let Pe=v?.errors??0,_e;e[59]!==Pe?(_e=Pe.toLocaleString(),e[59]=Pe,e[60]=_e):_e=e[60],e[61]!==je||e[62]!==De||e[63]!==Ne||e[64]!==_e?(K=(0,n.jsx)(Re,{delta:De,label:Ne,trend:je,value:_e}),e[61]=je,e[62]=De,e[63]=Ne,e[64]=_e,e[65]=K):K=e[65],L=Re,e[66]!==Te||e[67]!==a?(O=Te>0?`${a("max")} ${Ze(Te)}`:void 0,e[66]=Te,e[67]=a,e[68]=O):O=e[68],e[69]!==a?(R=a("Avg latency"),e[69]=a,e[70]=R):R=e[70],B=Ge===null?"\u2014":Ze(Ge),e[14]=w.data,e[15]=g.data,e[16]=v,e[17]=c.data,e[18]=r,e[19]=f.data,e[20]=y.data,e[21]=a,e[22]=L,e[23]=C,e[24]=N,e[25]=_,e[26]=A,e[27]=j,e[28]=P,e[29]=O,e[30]=R,e[31]=B,e[32]=E,e[33]=V,e[34]=q,e[35]=K,e[36]=W,e[37]=F,e[38]=U,e[39]=H}else L=e[22],C=e[23],N=e[24],_=e[25],A=e[26],j=e[27],P=e[28],O=e[29],R=e[30],B=e[31],E=e[32],V=e[33],q=e[34],K=e[35],W=e[36],F=e[37],U=e[38],H=e[39];let J;e[71]!==L||e[72]!==O||e[73]!==R||e[74]!==B?(J=(0,n.jsx)(L,{footer:O,label:R,value:B}),e[71]=L,e[72]=O,e[73]=R,e[74]=B,e[75]=J):J=e[75];let Z;e[76]!==N||e[77]!==a?(Z=N===null?void 0:`${String(N)}% ${a("cache hit")}`,e[76]=N,e[77]=a,e[78]=Z):Z=e[78];let G;e[79]!==a?(G=a("Database size"),e[79]=a,e[80]=G):G=e[80];let qe=v?.databaseSize??null,Y;e[81]!==qe?(Y=et(qe),e[81]=qe,e[82]=Y):Y=e[82];let Q;e[83]!==Z||e[84]!==G||e[85]!==Y?(Q=(0,n.jsx)(Re,{footer:Z,label:G,value:Y}),e[83]=Z,e[84]=G,e[85]=Y,e[86]=Q):Q=e[86];let X;e[87]!==E||e[88]!==V||e[89]!==q||e[90]!==K||e[91]!==J||e[92]!==Q?(X=(0,n.jsxs)("div",{className:E,"data-testid":V,children:[q,K,J,Q]}),e[87]=E,e[88]=V,e[89]=q,e[90]=K,e[91]=J,e[92]=Q,e[93]=X):X=e[93];let we;e[94]===Symbol.for("react.memo_cache_sentinel")?(we=(0,n.jsx)(bt,{}),e[94]=we):we=e[94];let ee;e[95]!==_?(ee=(0,n.jsx)("div",{className:"lg:col-span-2",children:(0,n.jsx)($t,{functions:_})}),e[95]=_,e[96]=ee):ee=e[96];let te;e[97]!==P?(te=(0,n.jsx)(jt,{subs:P}),e[97]=P,e[98]=te):te=e[98];let ae;e[99]!==C?(ae=(0,n.jsx)(Tt,{entries:C}),e[99]=C,e[100]=ae):ae=e[100];let ne;e[101]!==te||e[102]!==ae?(ne=(0,n.jsxs)("div",{className:"flex flex-col gap-3",children:[te,ae]}),e[101]=te,e[102]=ae,e[103]=ne):ne=e[103];let se;e[104]!==ee||e[105]!==ne?(se=(0,n.jsxs)("div",{className:"grid gap-3 lg:grid-cols-3",children:[ee,ne]}),e[104]=ee,e[105]=ne,e[106]=se):se=e[106];let re;e[107]!==a?(re=a("Advisors"),e[107]=a,e[108]=re):re=e[108];let le;e[109]!==re?(le=(0,n.jsx)("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:re}),e[109]=re,e[110]=le):le=e[110];let oe;e[111]!==A||e[112]!==j||e[113]!==a||e[114]!==U||e[115]!==H?(oe=j===0&&A===0?(0,n.jsx)(Ye,{description:a("No security or performance issues detected."),icon:(0,n.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,n.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,n.jsx)("path",{d:"m9 12 2 2 4-4"})]}),testId:"home-advisors-clear",title:a("No issues found")}):(0,n.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,n.jsx)(ot,{count:j,onView:H,testId:"home-security",title:a("Security findings")}),(0,n.jsx)(ot,{count:A,onView:U,testId:"home-performance",title:a("Performance issues")})]}),e[111]=A,e[112]=j,e[113]=a,e[114]=U,e[115]=H,e[116]=oe):oe=e[116];let ie;e[117]!==le||e[118]!==oe?(ie=(0,n.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"home-advisors",children:[le,oe]}),e[117]=le,e[118]=oe,e[119]=ie):ie=e[119];let ce;e[120]!==a?(ce=a("Get connected"),e[120]=a,e[121]=ce):ce=e[121];let de;e[122]!==ce?(de=(0,n.jsx)("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:ce}),e[122]=ce,e[123]=de):de=e[123];let me;e[124]!==a?(me=a("Client SDK"),e[124]=a,e[125]=me):me=e[125];let ue;e[126]!==me?(ue=(0,n.jsx)(Je,{command:"npm i @lunora/client",label:me}),e[126]=me,e[127]=ue):ue=e[127];let pe;e[128]!==a?(pe=a("React"),e[128]=a,e[129]=pe):pe=e[129];let fe;e[130]!==pe?(fe=(0,n.jsx)(Je,{command:"npm i @lunora/react",label:pe}),e[130]=pe,e[131]=fe):fe=e[131];let he;e[132]!==a?(he=a("CLI"),e[132]=a,e[133]=he):he=e[133];let ge;e[134]!==he?(ge=(0,n.jsx)(Je,{command:"lunora dev",label:he}),e[134]=he,e[135]=ge):ge=e[135];let xe;e[136]!==ue||e[137]!==fe||e[138]!==ge?(xe=(0,n.jsxs)("div",{className:"grid gap-3 sm:grid-cols-3",children:[ue,fe,ge]}),e[136]=ue,e[137]=fe,e[138]=ge,e[139]=xe):xe=e[139];let Le;e[140]===Symbol.for("react.memo_cache_sentinel")?(Le=(0,n.jsx)(Ct,{}),e[140]=Le):Le=e[140];let be;e[141]!==de||e[142]!==xe?(be=(0,n.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"home-get-connected",children:[de,xe,Le]}),e[141]=de,e[142]=xe,e[143]=be):be=e[143];let Ce;return e[144]!==W||e[145]!==F||e[146]!==X||e[147]!==se||e[148]!==ie||e[149]!==be?(Ce=(0,n.jsxs)("div",{className:W,"data-testid":F,children:[X,we,se,ie,be]}),e[144]=W,e[145]=F,e[146]=X,e[147]=se,e[148]=ie,e[149]=be,e[150]=Ce):Ce=e[150],Ce},"Zt");function Rt(t,e){return e.calls-t.calls}m(Rt,"Rt");function qt(t){return(0,n.jsxs)("div",{className:"grid grid-cols-[1fr_auto_auto_auto] items-center gap-4 px-4 py-2 text-[13px]",children:[(0,n.jsx)("span",{className:"truncate font-mono text-xs text-foreground",children:t.path}),(0,n.jsx)("span",{className:"text-end tabular-nums",children:t.calls.toLocaleString()}),(0,n.jsx)("span",{className:"w-12 text-end tabular-nums text-muted-foreground",children:Ze(t.calls>0?t.totalDurationMs/t.calls:0)}),(0,n.jsx)("span",{className:We("w-8 text-end tabular-nums",t.errors>0?"text-destructive":"text-muted-foreground"),children:t.errors})]},t.path)}m(qt,"Et");function Kt(t){return t.maxDurationMs}m(Kt,"jt");export{ft as a,Gt as b};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as Ee}from"./chunk-
|
|
1
|
+
import{b as Ee}from"./chunk-U7J3LXJ4.js";import{c as Oe}from"./chunk-W2JBKQNU.js";import"./chunk-AECDJKXB.js";import"./chunk-CN2AINNY.js";import"./chunk-CP4ZFBVW.js";import{a as ye}from"./chunk-NIX2QSSN.js";import"./chunk-5JLIP2HH.js";import{a as Le}from"./chunk-WUW4ZHRL.js";import"./chunk-EDHW2EEG.js";import"./chunk-ZSOLGJFC.js";import"./chunk-DUDQV6XJ.js";import"./chunk-VZCS5GXZ.js";import"./chunk-DKSLOJDQ.js";import{a as _e}from"./chunk-2EJQ7SPV.js";import{a as Te}from"./chunk-HLEXBOCL.js";import"./chunk-P52BY657.js";import"./chunk-VNTEQQPP.js";import{P as Ce}from"./chunk-AOAJGSYZ.js";import"./chunk-INQICZYC.js";import"./chunk-TFMQSCGC.js";import{a as re}from"./chunk-BWEXJENB.js";import"./chunk-74ASA4WU.js";import"./chunk-XQS7KSHL.js";import{b as ae}from"./chunk-SPDZUX4P.js";import"./chunk-7PIHTTND.js";import{a as be}from"./chunk-VDW32UET.js";import{f as Se}from"./chunk-22WJHOC4.js";import"./chunk-RCZTUWG3.js";import{a as me}from"./chunk-UANVABQG.js";import{a as Ke,b as $e,c as Fe,d as ie,e as ne,f as ee}from"./chunk-L4EZAHCD.js";import{a as je,e as ze}from"./chunk-IYWVSMAY.js";import{d as Ne,f as fe,g as ge,h as Q,l as pe,o as V,q as De}from"./chunk-BKM6PMSO.js";import"./chunk-VYW2PAWC.js";import{a as g,d as he,e as ft,f as gt,g as pt}from"./chunk-R5ZTCHCE.js";var B=he(gt(),1),j=he(ft(),1);var n=he(pt(),1);var Me=g((d,e,t)=>{let{onCopy:r,onDelete:s,onDownload:o,onToggleSelect:i}=t,c=g(()=>{r(d.key)},"a"),l=g(()=>{o(d.key)},"n"),u=g(()=>{s(d.key)},"d"),m=g(()=>{i(d.key)},"h");return{copy:c,download:l,name:d.key.slice(e.length),remove:u,toggle:m}},"$e"),Be=g(d=>{let e=(0,B.c)(31),{busy:t,buttonClassName:r,copied:s,objectKey:o,onCopy:i,onDelete:c,onDownload:l,t:u}=d,m=`storage-copy-${o}`,h;e[0]!==s||e[1]!==u?(h=u(s?"Copied":"Copy URL"),e[0]=s,e[1]=u,e[2]=h):h=e[2];let f;e[3]!==t||e[4]!==r||e[5]!==i||e[6]!==m||e[7]!==h?(f=(0,n.jsx)(re,{className:r,"data-testid":m,disabled:t,onClick:i,size:"sm",type:"button",variant:"ghost",children:h}),e[3]=t,e[4]=r,e[5]=i,e[6]=m,e[7]=h,e[8]=f):f=e[8];let w=`storage-download-${o}`,a;e[9]!==u?(a=u("Download"),e[9]=u,e[10]=a):a=e[10];let k;e[11]!==t||e[12]!==r||e[13]!==l||e[14]!==w||e[15]!==a?(k=(0,n.jsx)(re,{className:r,"data-testid":w,disabled:t,onClick:l,size:"sm",type:"button",variant:"ghost",children:a}),e[11]=t,e[12]=r,e[13]=l,e[14]=w,e[15]=a,e[16]=k):k=e[16];let N;e[17]!==u?(N=u("Delete object?"),e[17]=u,e[18]=N):N=e[18];let x=`storage-delete-${o}`,b;e[19]!==u?(b=u("Delete"),e[19]=u,e[20]=b):b=e[20];let v;e[21]!==t||e[22]!==c||e[23]!==N||e[24]!==x||e[25]!==b?(v=(0,n.jsx)(_e,{confirmLabel:N,disabled:t,onConfirm:c,testId:x,children:b}),e[21]=t,e[22]=c,e[23]=N,e[24]=x,e[25]=b,e[26]=v):v=e[26];let y;return e[27]!==v||e[28]!==f||e[29]!==k?(y=(0,n.jsxs)(n.Fragment,{children:[f,k,v]}),e[27]=v,e[28]=f,e[29]=k,e[30]=y):y=e[30],y},"Fe"),Ae=g(d=>{let e=(0,B.c)(14),{objectKey:t,references:r,t:s}=d;if(r===void 0)return null;if(r.length===0){let m=`storage-orphan-${t}`,h;e[0]!==s?(h=s("Orphan"),e[0]=s,e[1]=h):h=e[1];let f;return e[2]!==m||e[3]!==h?(f=(0,n.jsx)(ae,{"data-testid":m,variant:"warning",children:h}),e[2]=m,e[3]=h,e[4]=f):f=e[4],f}let o;e[5]!==r?(o=r.map(bt).join(`
|
|
2
2
|
`),e[5]=r,e[6]=o):o=e[6];let i=o,c=`storage-refs-${t}`,l;e[7]!==r.length||e[8]!==s?(l=r.length===1?s("1 record"):s("{count} records",{count:r.length}),e[7]=r.length,e[8]=s,e[9]=l):l=e[9];let u;return e[10]!==i||e[11]!==c||e[12]!==l?(u=(0,n.jsx)(ae,{"data-testid":c,title:i,variant:"secondary",children:l}),e[10]=i,e[11]=c,e[12]=l,e[13]=u):u=e[13],u},"Re"),Pe=g(d=>{let e=(0,B.c)(7),{objectKey:t,onToggle:r,selected:s,t:o}=d,i;e[0]!==o?(i=o("Select row"),e[0]=o,e[1]=i):i=e[1];let c=`storage-select-${t}`,l;return e[2]!==r||e[3]!==s||e[4]!==i||e[5]!==c?(l=(0,n.jsx)(ye,{"aria-label":i,checked:s,"data-testid":c,onCheckedChange:r}),e[2]=r,e[3]=s,e[4]=i,e[5]=c,e[6]=l):l=e[6],l},"ze");function bt(d){return`${d.table}\xB7${d.id}`}g(bt,"yt");var yt=g(d=>{let e=(0,B.c)(10),{colSpan:t,name:r,onEnter:s}=d,o;e[0]!==r||e[1]!==s?(o=g(()=>{s(r)},"l"),e[0]=r,e[1]=s,e[2]=o):o=e[2];let i=o,c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=(0,n.jsx)("svg",{"aria-hidden":"true",className:"size-4 text-muted-foreground",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,n.jsx)("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"})}),e[3]=c):c=e[3];let l;e[4]!==i||e[5]!==r?(l=(0,n.jsxs)("button",{className:"inline-flex items-center gap-2 font-mono text-xs outline-none hover:text-foreground focus-visible:text-foreground","data-testid":"fb-folder",onClick:i,type:"button",children:[c,r]}),e[4]=i,e[5]=r,e[6]=l):l=e[6];let u;return e[7]!==t||e[8]!==l?(u=(0,n.jsx)(ie,{children:(0,n.jsx)(ee,{colSpan:t,children:l})}),e[7]=t,e[8]=l,e[9]=u):u=e[9],u},"xt"),xt=g(d=>{let e=(0,B.c)(37),{busy:t,copiedKey:r,handlers:s,object:o,prefix:i,references:c,selected:l,showReferences:u,t:m}=d,h;e[0]!==s||e[1]!==o||e[2]!==i?(h=Me(o,i,s),e[0]=s,e[1]=o,e[2]=i,e[3]=h):h=e[3];let{copy:f,download:w,name:a,remove:k,toggle:N}=h,x;e[4]!==o.key||e[5]!==l||e[6]!==m||e[7]!==N?(x=(0,n.jsx)(ee,{className:"w-8",children:(0,n.jsx)(Pe,{objectKey:o.key,onToggle:N,selected:l,t:m})}),e[4]=o.key,e[5]=l,e[6]=m,e[7]=N,e[8]=x):x=e[8];let b;e[9]!==a?(b=(0,n.jsx)(ee,{className:"font-mono text-xs",children:a}),e[9]=a,e[10]=b):b=e[10];let v;e[11]!==o.size?(v=pe(o.size),e[11]=o.size,e[12]=v):v=e[12];let y;e[13]!==v?(y=(0,n.jsx)(ee,{className:"tabular-nums text-muted-foreground",children:v}),e[13]=v,e[14]=y):y=e[14];let z=o.httpMetadata?.contentType??"",S;e[15]!==z?(S=(0,n.jsx)(ee,{children:z}),e[15]=z,e[16]=S):S=e[16];let C;e[17]!==o.key||e[18]!==c||e[19]!==u||e[20]!==m?(C=u&&(0,n.jsx)(ee,{children:(0,n.jsx)(Ae,{objectKey:o.key,references:c,t:m})}),e[17]=o.key,e[18]=c,e[19]=u,e[20]=m,e[21]=C):C=e[21];let K=r===o.key,D;e[22]!==t||e[23]!==f||e[24]!==w||e[25]!==o.key||e[26]!==k||e[27]!==m||e[28]!==K?(D=(0,n.jsx)(ee,{className:"text-right",children:(0,n.jsx)("span",{className:"inline-flex items-center gap-1",children:(0,n.jsx)(Be,{busy:t,copied:K,objectKey:o.key,onCopy:f,onDelete:k,onDownload:w,t:m})})}),e[22]=t,e[23]=f,e[24]=w,e[25]=o.key,e[26]=k,e[27]=m,e[28]=K,e[29]=D):D=e[29];let F;return e[30]!==D||e[31]!==x||e[32]!==b||e[33]!==y||e[34]!==S||e[35]!==C?(F=(0,n.jsxs)(ie,{"data-testid":"fb-row",children:[x,b,y,S,C,D]}),e[30]=D,e[31]=x,e[32]=b,e[33]=y,e[34]=S,e[35]=C,e[36]=F):F=e[36],F},"vt"),vt=g(d=>{let e=(0,B.c)(65),{allSelected:t,busy:r,copiedKey:s,files:o,folders:i,handlers:c,onEnterFolder:l,prefix:u,references:m,selected:h,showReferences:f,someSelected:w,t:a,toggleSelectAll:k}=d,N;e[0]!==a?(N=a("Select all rows"),e[0]=a,e[1]=N):N=e[1];let x;e[2]!==t||e[3]!==w||e[4]!==N||e[5]!==k?(x=(0,n.jsx)(ne,{className:"w-8",children:(0,n.jsx)(ye,{"aria-label":N,checked:t,"data-testid":"storage-select-all",indeterminate:w,onCheckedChange:k})}),e[2]=t,e[3]=w,e[4]=N,e[5]=k,e[6]=x):x=e[6];let b;e[7]!==a?(b=a("key"),e[7]=a,e[8]=b):b=e[8];let v;e[9]!==b?(v=(0,n.jsx)(ne,{children:b}),e[9]=b,e[10]=v):v=e[10];let y;e[11]!==a?(y=a("size"),e[11]=a,e[12]=y):y=e[12];let z;e[13]!==y?(z=(0,n.jsx)(ne,{children:y}),e[13]=y,e[14]=z):z=e[14];let S;e[15]!==a?(S=a("content-type"),e[15]=a,e[16]=S):S=e[16];let C;e[17]!==S?(C=(0,n.jsx)(ne,{children:S}),e[17]=S,e[18]=C):C=e[18];let K;e[19]!==f||e[20]!==a?(K=f&&(0,n.jsx)(ne,{children:a("used by")}),e[19]=f,e[20]=a,e[21]=K):K=e[21];let D;e[22]!==a?(D=a("Actions"),e[22]=a,e[23]=D):D=e[23];let F;e[24]!==D?(F=(0,n.jsx)(ne,{"aria-label":D}),e[24]=D,e[25]=F):F=e[25];let $;e[26]!==F||e[27]!==x||e[28]!==v||e[29]!==z||e[30]!==C||e[31]!==K?($=(0,n.jsx)($e,{children:(0,n.jsxs)(ie,{children:[x,v,z,C,K,F]})}),e[26]=F,e[27]=x,e[28]=v,e[29]=z,e[30]=C,e[31]=K,e[32]=$):$=e[32];let _;if(e[33]!==i||e[34]!==l||e[35]!==f){let L;e[37]!==l||e[38]!==f?(L=g(O=>(0,n.jsx)(yt,{colSpan:f?6:5,name:O,onEnter:l},O),"D"),e[37]=l,e[38]=f,e[39]=L):L=e[39],_=i.map(L),e[33]=i,e[34]=l,e[35]=f,e[36]=_}else _=e[36];let I;if(e[40]!==r||e[41]!==s||e[42]!==o||e[43]!==c||e[44]!==u||e[45]!==m||e[46]!==h||e[47]!==f||e[48]!==a){let L;e[50]!==r||e[51]!==s||e[52]!==c||e[53]!==u||e[54]!==m||e[55]!==h||e[56]!==f||e[57]!==a?(L=g(O=>(0,n.jsx)(xt,{busy:r,copiedKey:s,handlers:c,object:O,prefix:u,references:m[O.key],selected:h.has(O.key),showReferences:f,t:a},O.key),"D"),e[50]=r,e[51]=s,e[52]=c,e[53]=u,e[54]=m,e[55]=h,e[56]=f,e[57]=a,e[58]=L):L=e[58],I=o.map(L),e[40]=r,e[41]=s,e[42]=o,e[43]=c,e[44]=u,e[45]=m,e[46]=h,e[47]=f,e[48]=a,e[49]=I}else I=e[49];let E;e[59]!==_||e[60]!==I?(E=(0,n.jsxs)(Fe,{children:[_,I]}),e[59]=_,e[60]=I,e[61]=E):E=e[61];let U;return e[62]!==$||e[63]!==E?(U=(0,n.jsx)(je,{className:"overflow-hidden py-0",children:(0,n.jsx)(ze,{className:"px-0",children:(0,n.jsxs)(Ke,{"data-testid":"fb-table",children:[$,E]})})}),e[62]=$,e[63]=E,e[64]=U):U=e[64],U},"kt"),kt=[{label:"15m",seconds:900},{label:"1h",seconds:3600},{label:"24h",seconds:86400},{label:"7d",seconds:604800}],wt=3600,Ie=g((d,e)=>{if(e==="size")return d.size;if(e==="type")return d.httpMetadata?.contentType??"";if(e==="date"){if(d.uploaded===void 0)return 0;let t=new Date(d.uploaded).getTime();return Number.isNaN(t)?0:t}return e.startsWith("tag:")?d.customMetadata?.[e.slice(4)]??"":d.key},"ve"),St=g((d,e,t)=>{let r=t==="desc"?-1:1;return d.toSorted((s,o)=>{let i=Ie(s,e),c=Ie(o,e);return(typeof i=="number"&&typeof c=="number"?i-c:String(i).localeCompare(String(c)))*r})},"Ct"),Nt=g((d,e)=>{let t=new Set,r=[];for(let s of d){let o=s.key.slice(e.length),i=o.indexOf("/");i===-1?r.push(s):t.add(o.slice(0,i+1))}return{files:r,folders:[...t].toSorted((s,o)=>s.localeCompare(o))}},"Nt"),Ct=g(d=>{let e=(0,B.c)(59),{bucket:t,buckets:r,busy:s,draftPrefix:o,expiry:i,fileInputRef:c,onBucketChange:l,onExpiryChange:u,onFileChange:m,onList:h,onPrefixChange:f,onUploadClick:w,t:a}=d,k;e[0]!==f?(k=g(P=>{f(P.target.value)},"v"),e[0]=f,e[1]=k):k=e[1];let N=k,x;e[2]!==l?(x=g(P=>{l(P.target.value)},"y"),e[2]=l,e[3]=x):x=e[3];let b=x,v;e[4]!==u?(v=g(P=>{u(Number.parseInt(P.target.value,10))},"x"),e[4]=u,e[5]=v):v=e[5];let y=v,z;e[6]!==t||e[7]!==r||e[8]!==b||e[9]!==a?(z=r.length>0&&(0,n.jsx)("select",{"aria-label":a("Bucket"),className:"h-8 rounded-md border border-border bg-background px-1 outline-none focus-visible:border-ring","data-testid":"fb-bucket",onChange:b,value:t,children:r.map(zt)}),e[6]=t,e[7]=r,e[8]=b,e[9]=a,e[10]=z):z=e[10];let S;e[11]!==a?(S=a("Key prefix"),e[11]=a,e[12]=S):S=e[12];let C;e[13]!==a?(C=a("key prefix (optional)"),e[13]=a,e[14]=C):C=e[14];let K;e[15]!==o||e[16]!==N||e[17]!==S||e[18]!==C?(K=(0,n.jsx)(Ce,{"aria-label":S,className:"h-8 w-64 max-w-full","data-testid":"fb-prefix-input",onChange:N,placeholder:C,value:o}),e[15]=o,e[16]=N,e[17]=S,e[18]=C,e[19]=K):K=e[19];let D;e[20]!==a?(D=a("List"),e[20]=a,e[21]=D):D=e[21];let F;e[22]!==s||e[23]!==h||e[24]!==D?(F=(0,n.jsx)(re,{"data-testid":"fb-list",disabled:s,onClick:h,size:"sm",type:"button",children:D}),e[22]=s,e[23]=h,e[24]=D,e[25]=F):F=e[25];let $;e[26]!==s||e[27]!==a?($=a(s?"Uploading\u2026":"Upload"),e[26]=s,e[27]=a,e[28]=$):$=e[28];let _;e[29]!==s||e[30]!==w||e[31]!==$?(_=(0,n.jsx)(re,{"data-testid":"storage-upload",disabled:s,onClick:w,size:"sm",type:"button",variant:"outline",children:$}),e[29]=s,e[30]=w,e[31]=$,e[32]=_):_=e[32];let I;e[33]!==c||e[34]!==m?(I=(0,n.jsx)("input",{className:"hidden","data-testid":"storage-file-input",onChange:m,ref:c,type:"file"}),e[33]=c,e[34]=m,e[35]=I):I=e[35];let E;e[36]!==a?(E=a("Link expiry"),e[36]=a,e[37]=E):E=e[37];let U;e[38]!==a?(U=kt.map(P=>(0,n.jsx)("option",{value:P.seconds,children:a(P.label)},P.seconds)),e[38]=a,e[39]=U):U=e[39];let L;e[40]!==i||e[41]!==y||e[42]!==U?(L=(0,n.jsx)("select",{className:"h-8 rounded-md border border-border bg-background px-1 tabular-nums outline-none focus-visible:border-ring","data-testid":"storage-expiry",id:"storage-expiry",onChange:y,value:i,children:U}),e[40]=i,e[41]=y,e[42]=U,e[43]=L):L=e[43];let O;e[44]!==E||e[45]!==L?(O=(0,n.jsxs)("label",{className:"ml-auto flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"storage-expiry",children:[E,L]}),e[44]=E,e[45]=L,e[46]=O):O=e[46];let M;e[47]!==a?(M=a("Open in Cloudflare"),e[47]=a,e[48]=M):M=e[48];let A;e[49]!==M?(A=(0,n.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"fb-cf-link",href:Oe,rel:"noreferrer",target:"_blank",children:M}),e[49]=M,e[50]=A):A=e[50];let W;return e[51]!==_||e[52]!==I||e[53]!==O||e[54]!==A||e[55]!==z||e[56]!==K||e[57]!==F?(W=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[z,K,F,_,I,O,A]}),e[51]=_,e[52]=I,e[53]=O,e[54]=A,e[55]=z,e[56]=K,e[57]=F,e[58]=W):W=e[58],W},"Tt"),jt=g(d=>{let e=(0,B.c)(66),{onSortKeyChange:t,onThumbSizeChange:r,showGrid:s,showList:o,sortDirection:i,sortKey:c,t:l,tagKeys:u,thumbSize:m,toggleSortDirection:h,view:f}=d,w;e[0]!==t?(w=g(G=>{t(G.target.value)},"k"),e[0]=t,e[1]=w):w=e[1];let a=w,k;e[2]!==r?(k=g(G=>{r(Number.parseInt(G.target.value,10))},"v"),e[2]=r,e[3]=k):k=e[3];let N=k,x=f==="list",b;e[4]!==l?(b=l("List"),e[4]=l,e[5]=b):b=e[5];let v;e[6]!==o||e[7]!==x||e[8]!==b?(v=(0,n.jsx)("button",{"aria-pressed":x,className:"px-2 py-1 outline-none transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:text-accent-foreground","data-testid":"fb-view-list",onClick:o,type:"button",children:b}),e[6]=o,e[7]=x,e[8]=b,e[9]=v):v=e[9];let y=f==="grid",z;e[10]!==l?(z=l("Grid"),e[10]=l,e[11]=z):z=e[11];let S;e[12]!==s||e[13]!==y||e[14]!==z?(S=(0,n.jsx)("button",{"aria-pressed":y,className:"border-s border-border px-2 py-1 outline-none transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:text-accent-foreground","data-testid":"fb-view-grid",onClick:s,type:"button",children:z}),e[12]=s,e[13]=y,e[14]=z,e[15]=S):S=e[15];let C;e[16]!==v||e[17]!==S?(C=(0,n.jsxs)("div",{className:"inline-flex overflow-hidden rounded-md border border-border",children:[v,S]}),e[16]=v,e[17]=S,e[18]=C):C=e[18];let K;e[19]!==l?(K=l("Sort"),e[19]=l,e[20]=K):K=e[20];let D;e[21]!==l?(D=l("Name"),e[21]=l,e[22]=D):D=e[22];let F;e[23]!==D?(F=(0,n.jsx)("option",{value:"name",children:D}),e[23]=D,e[24]=F):F=e[24];let $;e[25]!==l?($=l("size"),e[25]=l,e[26]=$):$=e[26];let _;e[27]!==$?(_=(0,n.jsx)("option",{value:"size",children:$}),e[27]=$,e[28]=_):_=e[28];let I;e[29]!==l?(I=l("Type"),e[29]=l,e[30]=I):I=e[30];let E;e[31]!==I?(E=(0,n.jsx)("option",{value:"type",children:I}),e[31]=I,e[32]=E):E=e[32];let U;e[33]!==l?(U=l("Modified"),e[33]=l,e[34]=U):U=e[34];let L;e[35]!==U?(L=(0,n.jsx)("option",{value:"date",children:U}),e[35]=U,e[36]=L):L=e[36];let O;e[37]!==u?(O=u.map(Dt),e[37]=u,e[38]=O):O=e[38];let M;e[39]!==a||e[40]!==c||e[41]!==F||e[42]!==_||e[43]!==E||e[44]!==L||e[45]!==O?(M=(0,n.jsxs)("select",{className:"h-8 rounded-md border border-border bg-background px-1 outline-none focus-visible:border-ring","data-testid":"fb-sort",id:"fb-sort",onChange:a,value:c,children:[F,_,E,L,O]}),e[39]=a,e[40]=c,e[41]=F,e[42]=_,e[43]=E,e[44]=L,e[45]=O,e[46]=M):M=e[46];let A;e[47]!==K||e[48]!==M?(A=(0,n.jsxs)("label",{className:"flex items-center gap-1.5 text-muted-foreground",htmlFor:"fb-sort",children:[K,M]}),e[47]=K,e[48]=M,e[49]=A):A=e[49];let W;e[50]!==l?(W=l("Toggle sort direction"),e[50]=l,e[51]=W):W=e[51];let P=i==="asc"?"\u2191":"\u2193",H;e[52]!==W||e[53]!==P||e[54]!==h?(H=(0,n.jsx)("button",{"aria-label":W,className:"flex size-8 items-center justify-center rounded-md border border-border tabular-nums outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"fb-sort-dir",onClick:h,type:"button",children:P}),e[52]=W,e[53]=P,e[54]=h,e[55]=H):H=e[55];let J;e[56]!==N||e[57]!==l||e[58]!==m||e[59]!==f?(J=f==="grid"&&(0,n.jsxs)("label",{className:"ml-auto flex items-center gap-1.5 text-muted-foreground",htmlFor:"fb-thumb-size",children:[l("Thumbnail size"),(0,n.jsx)("input",{className:"accent-primary","data-testid":"fb-thumb-size",id:"fb-thumb-size",max:240,min:80,onChange:N,step:8,type:"range",value:m})]}),e[56]=N,e[57]=l,e[58]=m,e[59]=f,e[60]=J):J=e[60];let oe;return e[61]!==A||e[62]!==H||e[63]!==J||e[64]!==C?(oe=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs","data-testid":"fb-controls",children:[C,A,H,J]}),e[61]=A,e[62]=H,e[63]=J,e[64]=C,e[65]=oe):oe=e[65],oe},"_t");function zt(d){return(0,n.jsx)("option",{value:d,children:d},d)}g(zt,"Et");function Dt(d){return(0,n.jsx)("option",{value:`tag:${d}`,children:d},d)}g(Dt,"$t");var Tt=/\.(?:avif|bmp|gif|ico|jpe?g|png|svg|webp)$/iu,Kt=g(d=>(d.httpMetadata?.contentType??"").startsWith("image/")||Tt.test(d.key),"Rt"),$t=g(()=>{let d=(0,B.c)(1),e;return d[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("svg",{"aria-hidden":"true",className:"size-8 text-muted-foreground/60",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.4,viewBox:"0 0 24 24",children:(0,n.jsx)("path",{d:"M7 3h7l5 5v13a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Zm7 0v5h5"})}),d[0]=e):e=d[0],e},"zt"),Ft=g(d=>{let e=(0,B.c)(13),{object:t,resolveUrl:r}=d,[s,o]=(0,j.useState)(null),[i,c]=(0,j.useState)(!1),l;e[0]!==t?(l=Kt(t),e[0]=t,e[1]=l):l=e[1];let u=l,m,h;e[2]!==u||e[3]!==t.key||e[4]!==r?(m=g(()=>{if(!u)return;let k={cancelled:!1};return V((async()=>{try{let N=await r(t.key);k.cancelled||o(N)}catch{k.cancelled||c(!0)}})()),()=>{k.cancelled=!0}},"h"),h=[u,t.key,r],e[2]=u,e[3]=t.key,e[4]=r,e[5]=m,e[6]=h):(m=e[5],h=e[6]),(0,j.useEffect)(m,h);let f;e[7]===Symbol.for("react.memo_cache_sentinel")?(f=g(()=>{c(!0)},"m"),e[7]=f):f=e[7];let w=f,a;return e[8]!==i||e[9]!==u||e[10]!==t.key||e[11]!==s?(a=(0,n.jsx)("div",{className:"flex aspect-square w-full items-center justify-center overflow-hidden rounded-md border border-border bg-muted/30",children:u&&s!==null&&!i?(0,n.jsx)("img",{alt:t.key,className:"size-full object-cover",loading:"lazy",onError:w,src:s}):(0,n.jsx)($t,{})}),e[8]=i,e[9]=u,e[10]=t.key,e[11]=s,e[12]=a):a=e[12],a},"Dt"),_t=g(d=>{let e=(0,B.c)(42),{busy:t,copiedKey:r,handlers:s,object:o,prefix:i,references:c,resolveUrl:l,selected:u,showReferences:m,t:h}=d,f;e[0]!==s||e[1]!==o||e[2]!==i?(f=Me(o,i,s),e[0]=s,e[1]=o,e[2]=i,e[3]=f):f=e[3];let{copy:w,download:a,name:k,remove:N,toggle:x}=f,b;e[4]!==o||e[5]!==l?(b=(0,n.jsx)(Ft,{object:o,resolveUrl:l}),e[4]=o,e[5]=l,e[6]=b):b=e[6];let v;e[7]!==o.key||e[8]!==u||e[9]!==h||e[10]!==x?(v=(0,n.jsx)("span",{className:"absolute left-1.5 top-1.5 rounded bg-background/80 p-0.5",children:(0,n.jsx)(Pe,{objectKey:o.key,onToggle:x,selected:u,t:h})}),e[7]=o.key,e[8]=u,e[9]=h,e[10]=x,e[11]=v):v=e[11];let y;e[12]!==b||e[13]!==v?(y=(0,n.jsxs)("div",{className:"relative",children:[b,v]}),e[12]=b,e[13]=v,e[14]=y):y=e[14];let z;e[15]!==k?(z=(0,n.jsx)("p",{className:"truncate font-mono text-xs",title:k,children:k}),e[15]=k,e[16]=z):z=e[16];let S;e[17]!==o.size?(S=pe(o.size),e[17]=o.size,e[18]=S):S=e[18];let C;e[19]!==S?(C=(0,n.jsx)("p",{className:"text-[11px] tabular-nums text-muted-foreground",children:S}),e[19]=S,e[20]=C):C=e[20];let K;e[21]!==o.key||e[22]!==c||e[23]!==m||e[24]!==h?(K=m&&(0,n.jsx)("div",{className:"mt-1",children:(0,n.jsx)(Ae,{objectKey:o.key,references:c,t:h})}),e[21]=o.key,e[22]=c,e[23]=m,e[24]=h,e[25]=K):K=e[25];let D;e[26]!==z||e[27]!==C||e[28]!==K?(D=(0,n.jsxs)("div",{className:"min-w-0",children:[z,C,K]}),e[26]=z,e[27]=C,e[28]=K,e[29]=D):D=e[29];let F=r===o.key,$;e[30]!==t||e[31]!==w||e[32]!==a||e[33]!==o.key||e[34]!==N||e[35]!==h||e[36]!==F?($=(0,n.jsx)("div",{className:"flex items-center gap-1",children:(0,n.jsx)(Be,{busy:t,buttonClassName:"h-7 px-2 text-xs",copied:F,objectKey:o.key,onCopy:w,onDelete:N,onDownload:a,t:h})}),e[30]=t,e[31]=w,e[32]=a,e[33]=o.key,e[34]=N,e[35]=h,e[36]=F,e[37]=$):$=e[37];let _;return e[38]!==$||e[39]!==y||e[40]!==D?(_=(0,n.jsxs)("div",{className:"flex flex-col gap-1.5","data-testid":"fb-tile",children:[y,D,$]}),e[38]=$,e[39]=y,e[40]=D,e[41]=_):_=e[41],_},"jt"),Lt=g(d=>{let e=(0,B.c)(9),{name:t,onEnter:r}=d,s;e[0]!==t||e[1]!==r?(s=g(()=>{r(t)},"o"),e[0]=t,e[1]=r,e[2]=s):s=e[2];let o=s,i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=(0,n.jsx)("span",{className:"flex aspect-square w-full items-center justify-center rounded-md border border-border bg-muted/30 transition-colors hover:bg-accent",children:(0,n.jsx)("svg",{"aria-hidden":"true",className:"size-10 text-muted-foreground",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.4,viewBox:"0 0 24 24",children:(0,n.jsx)("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"})})}),e[3]=i):i=e[3];let c;e[4]!==t?(c=(0,n.jsx)("span",{className:"truncate font-mono text-xs",title:t,children:t}),e[4]=t,e[5]=c):c=e[5];let l;return e[6]!==o||e[7]!==c?(l=(0,n.jsxs)("button",{className:"flex flex-col gap-1.5 text-left outline-none","data-testid":"fb-folder",onClick:o,type:"button",children:[i,c]}),e[6]=o,e[7]=c,e[8]=l):l=e[8],l},"Kt"),Et=g(d=>{let e=(0,B.c)(34),{busy:t,copiedKey:r,files:s,folders:o,handlers:i,onEnterFolder:c,prefix:l,references:u,resolveUrl:m,selected:h,showReferences:f,size:w,t:a}=d,k;e[0]!==w?(k=w.toString(),e[0]=w,e[1]=k):k=e[1];let N=`repeat(auto-fill, minmax(${k}px, 1fr))`,x;e[2]!==N?(x={gridTemplateColumns:N},e[2]=N,e[3]=x):x=e[3];let b=x,v;if(e[4]!==o||e[5]!==c){let S;e[7]!==c?(S=g(C=>(0,n.jsx)(Lt,{name:C,onEnter:c},C),"S"),e[7]=c,e[8]=S):S=e[8],v=o.map(S),e[4]=o,e[5]=c,e[6]=v}else v=e[6];let y;if(e[9]!==t||e[10]!==r||e[11]!==s||e[12]!==i||e[13]!==l||e[14]!==u||e[15]!==m||e[16]!==h||e[17]!==f||e[18]!==a){let S;e[20]!==t||e[21]!==r||e[22]!==i||e[23]!==l||e[24]!==u||e[25]!==m||e[26]!==h||e[27]!==f||e[28]!==a?(S=g(C=>(0,n.jsx)(_t,{busy:t,copiedKey:r,handlers:i,object:C,prefix:l,references:u[C.key],resolveUrl:m,selected:h.has(C.key),showReferences:f,t:a},C.key),"S"),e[20]=t,e[21]=r,e[22]=i,e[23]=l,e[24]=u,e[25]=m,e[26]=h,e[27]=f,e[28]=a,e[29]=S):S=e[29],y=s.map(S),e[9]=t,e[10]=r,e[11]=s,e[12]=i,e[13]=l,e[14]=u,e[15]=m,e[16]=h,e[17]=f,e[18]=a,e[19]=y}else y=e[19];let z;return e[30]!==b||e[31]!==v||e[32]!==y?(z=(0,n.jsxs)("div",{className:"grid gap-4","data-testid":"fb-gallery",style:b,children:[v,y]}),e[30]=b,e[31]=v,e[32]=y,e[33]=z):z=e[33],z},"Bt"),Ot=g(d=>{let e=(0,B.c)(23),{reference:t,t:r}=d,s=`fb-dangling-${t.table}-${t.id}-${t.column}`,o=`${t.table}\xB7${t.id}`,i;e[0]!==o?(i=(0,n.jsx)(ae,{variant:"secondary",children:o}),e[0]=o,e[1]=i):i=e[1];let c;e[2]!==t.column?(c=(0,n.jsx)("span",{className:"text-muted-foreground",children:t.column}),e[2]=t.column,e[3]=c):c=e[3];let l;e[4]!==r?(l=r("\u2192"),e[4]=r,e[5]=l):l=e[5];let u;e[6]!==l?(u=(0,n.jsx)("span",{className:"text-muted-foreground/60",children:l}),e[6]=l,e[7]=u):u=e[7];let m;e[8]!==t.key?(m=(0,n.jsx)("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-foreground",children:t.key}),e[8]=t.key,e[9]=m):m=e[9];let h;e[10]!==i||e[11]!==c||e[12]!==u||e[13]!==m?(h=(0,n.jsxs)("span",{className:"flex flex-wrap items-center gap-1.5",children:[i,c,u,m]}),e[10]=i,e[11]=c,e[12]=u,e[13]=m,e[14]=h):h=e[14];let f;e[15]!==r?(f=r("Missing object"),e[15]=r,e[16]=f):f=e[16];let w;e[17]!==f?(w=(0,n.jsx)(ae,{className:"border-destructive/40 text-destructive",variant:"outline",children:f}),e[17]=f,e[18]=w):w=e[18];let a;return e[19]!==s||e[20]!==w||e[21]!==h?(a=(0,n.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-border/60 px-3 py-2 text-xs","data-testid":s,children:[h,w]}),e[19]=s,e[20]=w,e[21]=h,e[22]=a):a=e[22],a},"Lt"),It=g(d=>{let e=(0,B.c)(37),{busy:t,onCheck:r,references:s,t:o,truncated:i}=d,c;e[0]!==o?(c=o("Integrity"),e[0]=o,e[1]=c):c=e[1];let l;e[2]!==c?(l=(0,n.jsx)("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:c}),e[2]=c,e[3]=l):l=e[3];let u;e[4]!==o?(u=o("Orphaned objects"),e[4]=o,e[5]=u):u=e[5];let m;e[6]!==u?(m=(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:u}),e[6]=u,e[7]=m):m=e[7];let h;e[8]!==o?(h=o("Find records whose file reference points at an object the bucket no longer has."),e[8]=o,e[9]=h):h=e[9];let f;e[10]!==h?(f=(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:h}),e[10]=h,e[11]=f):f=e[11];let w;e[12]!==l||e[13]!==m||e[14]!==f?(w=(0,n.jsxs)("div",{className:"flex flex-col gap-1",children:[l,m,f]}),e[12]=l,e[13]=m,e[14]=f,e[15]=w):w=e[15];let a;e[16]!==t||e[17]!==o?(a=o(t?"Checking\u2026":"Check for orphans"),e[16]=t,e[17]=o,e[18]=a):a=e[18];let k;e[19]!==t||e[20]!==r||e[21]!==a?(k=(0,n.jsx)(re,{"data-testid":"fb-orphans-check",disabled:t,onClick:r,size:"sm",type:"button",variant:"outline",children:a}),e[19]=t,e[20]=r,e[21]=a,e[22]=k):k=e[22];let N;e[23]!==w||e[24]!==k?(N=(0,n.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[w,k]}),e[23]=w,e[24]=k,e[25]=N):N=e[25];let x;e[26]!==s?.length||e[27]!==o?(x=s?.length===0&&(0,n.jsx)(me,{description:o("Every record's file reference points at an object that exists in the bucket."),testId:"fb-orphans-empty",title:o("No dangling references.")}),e[26]=s?.length,e[27]=o,e[28]=x):x=e[28];let b;e[29]!==s||e[30]!==o||e[31]!==i?(b=s!==void 0&&s.length>0&&(0,n.jsxs)(n.Fragment,{children:[i&&(0,n.jsx)("p",{className:"text-xs text-warning","data-testid":"fb-orphans-truncated",children:o("Showing the first {count} dangling references \u2014 the scan was truncated.",{count:s.length})}),(0,n.jsx)("ul",{className:"flex flex-col gap-1.5","data-testid":"fb-orphans-list",children:s.map(y=>(0,n.jsx)(Ot,{reference:y,t:o},`${y.table}\xB7${y.id}\xB7${y.column}`))})]}),e[29]=s,e[30]=o,e[31]=i,e[32]=b):b=e[32];let v;return e[33]!==N||e[34]!==x||e[35]!==b?(v=(0,n.jsxs)("section",{className:"flex flex-col gap-2 rounded-lg border border-border/60 p-3","data-testid":"fb-orphans",children:[N,x,b]}),e[33]=N,e[34]=x,e[35]=b,e[36]=v):v=e[36],v},"It"),Rt=g(function(d,e){let t=(0,B.c)(18),r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=new Set,t[0]=r):r=t[0];let[s,o]=(0,j.useState)(r),i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=g(x=>{o(b=>{let v=new Set(b);return v.has(x)?v.delete(x):v.add(x),v})},"c"),t[1]=i):i=t[1];let c=i,l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l=g(()=>{o(new Set)},"n"),t[2]=l):l=t[2];let u=l,m,h,f;if(t[3]!==d||t[4]!==e||t[5]!==s){let x;t[9]!==e?(x=g(b=>e(b),"y"),t[9]=e,t[10]=x):x=t[10],h=d.map(x),m=h.length>0&&h.every(b=>s.has(b)),f=!m&&h.some(b=>s.has(b)),t[3]=d,t[4]=e,t[5]=s,t[6]=m,t[7]=h,t[8]=f}else m=t[6],h=t[7],f=t[8];let w=f,a;t[11]!==h?(a=g(()=>{o(x=>h.every(b=>x.has(b))?new Set:new Set(h))},"i"),t[11]=h,t[12]=a):a=t[12];let k=a,N;return t[13]!==m||t[14]!==s||t[15]!==w||t[16]!==k?(N={allSelected:m,clear:u,selected:s,someSelected:w,toggle:c,toggleAll:k},t[13]=m,t[14]=s,t[15]=w,t[16]=k,t[17]=N):N=t[17],N},"Ot"),Ut=fe(be.storageReferences),Mt=fe(be.storageOrphans),Re=1e4,Bt=1e3,At=3600,Pt=g((d,e)=>{if(!("document"in globalThis))return;let t=globalThis.document.createElement("a");t.href=d,t.download=e,t.rel="noopener",globalThis.document.body.append(t),t.click(),t.remove()},"Ht"),Vt=g(d=>d.key,"Pt"),Wt=g(({initialPrefix:d,pageSize:e})=>{let t=Se(),[r,s]=(0,j.useState)(d??""),[o,i]=(0,j.useState)(d??""),[c,l]=(0,j.useState)(wt),[u,m]=(0,j.useState)("list"),[h,f]=(0,j.useState)(128),[w,a]=(0,j.useState)("name"),[k,N]=(0,j.useState)("asc"),[x,b]=(0,j.useState)(void 0),[v,y]=(0,j.useState)(void 0),[z,S]=(0,j.useState)(!1),[C,K]=(0,j.useState)(void 0),[D,F]=(0,j.useState)(void 0),[$,_]=(0,j.useState)(""),[I,E]=(0,j.useState)({}),[U,L]=(0,j.useState)(!1),[O,M]=(0,j.useState)(void 0),[A,W]=(0,j.useState)(!1),[P,H]=(0,j.useState)(!1),[J,oe]=(0,j.useState)([]),[G,xe]=(0,j.useState)(""),le=(0,j.useRef)(0),X=(0,j.useRef)(0);(0,j.useEffect)(()=>{let p={cancelled:!1};return V((async()=>{try{let T=await t.listStorageBuckets();if(!p.cancelled){oe(T);let[R]=T;R!==void 0&&xe(q=>q===""?R:q)}}catch{}})()),()=>{p.cancelled=!0}},[t]);let Z=(0,j.useMemo)(()=>({list:g(p=>t.listStorageObjects({...p,bucket:G}),"list"),remove:g(p=>t.deleteStorageObject(p,{bucket:G}),"remove"),signedUrl:g((p,T)=>t.signedStorageUrl(p,{...T,bucket:G}),"signedUrl"),upload:g(p=>t.uploadStorageObject({...p,bucket:G}),"upload")}),[G,t]),Y=(0,j.useCallback)(async(p,T,R)=>{le.current+=1;let q=le.current;y(void 0),S(!0);try{let te=await Z.list({cursor:T,limit:e,prefix:p});if(q!==le.current)return;b(we=>R&&we!==void 0?[...we,...te.objects]:te.objects),F(te.cursor)}catch(te){if(q!==le.current)return;R||b(void 0),y(Q(te))}finally{q===le.current&&S(!1)}},[e,Z]);(0,j.useEffect)(()=>{V(Y(d??"",void 0,!1))},[Y,d]);let Ve=(x?.length??0)<=e;Le(()=>{V(Y(r,void 0,!1))},Ve);let{files:de,folders:We}=Nt(x??[],r),He=(0,j.useMemo)(()=>{let p=new Set;for(let T of de)for(let R of Object.keys(T.customMetadata??{}))p.add(R);return[...p].toSorted((T,R)=>T.localeCompare(R))},[de]),ce=St(de,w,k),ue=(0,j.useMemo)(()=>[...new Set(ce.map(p=>p.key))].toSorted((p,T)=>p.localeCompare(T)).join(`
|
|
3
3
|
`),[ce]);(0,j.useEffect)(()=>{let p=ue===""?[]:ue.split(`
|
|
4
4
|
`);if(p.length===0){E({});return}let T={current:!0};return V((async()=>{try{let R=await t.query(Ut,{keys:p},ge($));T.current&&(E(R.references??{}),L(Object.keys(R.storageColumns??{}).length>0))}catch{T.current&&(E({}),L(!1))}})()),()=>{T.current=!1}},[t,ue,$]);let{allSelected:qe,clear:se,selected:ve,someSelected:Ge,toggle:Ze,toggleAll:Ye}=Rt(ce,Vt),Je=g(()=>{s(o),se(),V(Y(o,void 0,!1))},"Ae"),Xe=g(()=>{V(Y(r,D,!0))},"Ue"),ke=g(p=>{s(p),i(p),se(),V(Y(p,void 0,!1))},"ye"),Qe=g(p=>{ke(`${r}${p}`)},"Me"),et=g(p=>Z.signedUrl(p,{expiresInSeconds:At}),"Ge"),tt=g(()=>{m("list")},"He"),rt=g(()=>{m("grid")},"Pe"),nt=g(p=>{a(p)},"qe"),ot=g(()=>{N(p=>p==="asc"?"desc":"asc")},"Ve"),lt=g(p=>{f(p)},"We"),st=g(p=>{l(p)},"Ze"),at=g(()=>{y(void 0),S(!0),V((async()=>{try{for(let p of ve)await Z.remove(p);await Y(r,void 0,!1),se()}catch(p){y(Q(p))}S(!1)})())},"Xe"),ct=g(p=>{y(void 0),V((async()=>{try{let T=await Z.signedUrl(p,{expiresInSeconds:c});De(T)&&K(p)}catch(T){y(Q(T))}})())},"Ye"),it=g(p=>{y(void 0),V((async()=>{try{let T=await Z.signedUrl(p,{expiresInSeconds:c}),R=p.slice(p.lastIndexOf("/")+1)||p;Pt(T,R)}catch(T){y(Q(T))}})())},"Je");(0,j.useEffect)(()=>{if(C===void 0)return;let p=globalThis.setTimeout(()=>{K(void 0)},2e3);return()=>{globalThis.clearTimeout(p)}},[C]);let dt=g(p=>{y(void 0),S(!0),V((async()=>{try{await Z.remove(p),await Y(r,void 0,!1)}catch(T){y(Q(T))}S(!1)})())},"Qe"),ut=g(p=>{let T=`${r}${p.name}`;y(void 0),S(!0),V((async()=>{try{let R=await p.arrayBuffer();await Z.upload({body:R,contentType:p.type===""?void 0:p.type,key:T}),await Y(r,void 0,!1)}catch(R){y(Q(R))}S(!1)})())},"et");(0,j.useEffect)(()=>{X.current+=1,M(void 0),H(!1)},[$]);let ht=g(()=>{X.current+=1;let p=X.current;y(void 0),W(!0),V((async()=>{try{let T=[],R;do{let q=await Z.list({cursor:R,limit:Bt});for(let te of q.objects)T.push(te.key);R=T.length>=Re?void 0:q.cursor}while(R!==void 0);if(T.length>=Re)p===X.current&&(M([]),H(!0));else{let q=await t.query(Mt,{liveKeys:T},ge($));p===X.current&&(M(q.references??[]),H(q.truncated===!0))}}catch(T){p===X.current&&(M([]),H(!1),y(Q(T)))}p===X.current&&W(!1)})())},"tt"),mt=g(p=>{le.current+=1,X.current+=1,xe(p),s(d??""),i(d??""),b(void 0),M(void 0),H(!1),se()},"st");return{allSelected:qe,bucket:G,buckets:J,bulkDelete:at,busy:z,checkOrphans:ht,clearSelection:se,copiedKey:C,danglingBusy:A,danglingReferences:O,danglingTruncated:P,draftPrefix:o,enterFolder:Qe,error:v,expiry:c,files:ce,folders:We,hasObjects:x!==void 0&&x.length>0,hasStorageColumns:U,listFirst:Je,loaded:x!==void 0,loadMore:Xe,navigate:ke,nextCursor:D,onCopy:ct,onDelete:dt,onDownload:it,onExpiryChange:st,onFile:ut,onSortKeyChange:nt,onThumbSizeChange:lt,prefix:r,referenceShard:$,references:I,resolveUrl:et,selectBucket:mt,selected:ve,setDraftPrefix:i,setReferenceShard:_,showGrid:rt,showList:tt,someSelected:Ge,sortDirection:k,sortKey:w,tagKeys:He,thumbSize:h,toggleSelect:Ze,toggleSelectAll:Ye,toggleSortDirection:ot,view:u}},"qt"),Ht=100,Ue=g(d=>{let e=(0,B.c)(6),{label:t,onNavigate:r,target:s}=d,o;e[0]!==r||e[1]!==s?(o=g(()=>{r(s)},"l"),e[0]=r,e[1]=s,e[2]=o):o=e[2];let i=o,c;return e[3]!==i||e[4]!==t?(c=(0,n.jsx)("button",{className:"rounded px-1 text-muted-foreground outline-none hover:text-foreground focus-visible:text-foreground",onClick:i,type:"button",children:t}),e[3]=i,e[4]=t,e[5]=c):c=e[5],c},"Se"),qt=g(d=>{let e=(0,B.c)(11),{onNavigate:t,prefix:r,t:s}=d,o;if(e[0]!==t||e[1]!==r||e[2]!==s){let i=r.split("/").filter(Gt),c;e[4]!==s?(c=s("Folder path"),e[4]=s,e[5]=c):c=e[5];let l;e[6]!==s?(l=s("root"),e[6]=s,e[7]=l):l=e[7];let u;e[8]!==t||e[9]!==l?(u=(0,n.jsx)(Ue,{label:l,onNavigate:t,target:""}),e[8]=t,e[9]=l,e[10]=u):u=e[10],o=(0,n.jsxs)("nav",{"aria-label":c,className:"flex flex-wrap items-center gap-0.5 text-xs","data-testid":"fb-breadcrumbs",children:[u,i.map((m,h)=>(0,n.jsxs)("span",{className:"flex items-center gap-0.5",children:[(0,n.jsx)("span",{className:"text-muted-foreground/50",children:"/"}),(0,n.jsx)(Ue,{label:m,onNavigate:t,target:`${i.slice(0,h+1).join("/")}/`})]},`${m}-${h.toString()}`))]}),e[0]=t,e[1]=r,e[2]=s,e[3]=o}else o=e[3];return o},"Wt"),ur=g(({initialPrefix:d,pageSize:e=Ht})=>{let t=Ne(),r=Wt({initialPrefix:d,pageSize:e}),s=(0,j.useRef)(null),{onCopy:o,onDelete:i,onDownload:c,onFile:l,toggleSelect:u}=r,m={onCopy:o,onDelete:i,onDownload:c,onToggleSelect:u},h=g(()=>{s.current?.click()},"u"),f=g(a=>{let k=a.target,N=k.files?.[0];k.value="",N&&l(N)},"m"),w=r.loaded&&!r.hasObjects;return(0,n.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-file-browser",children:[(0,n.jsx)(Ct,{bucket:r.bucket,buckets:r.buckets,busy:r.busy,draftPrefix:r.draftPrefix,expiry:r.expiry,fileInputRef:s,onBucketChange:r.selectBucket,onExpiryChange:r.onExpiryChange,onFileChange:f,onList:r.listFirst,onPrefixChange:r.setDraftPrefix,onUploadClick:h,t}),r.loaded&&(0,n.jsx)(qt,{onNavigate:r.navigate,prefix:r.prefix,t}),r.hasObjects&&(0,n.jsx)(jt,{onSortKeyChange:r.onSortKeyChange,onThumbSizeChange:r.onThumbSizeChange,showGrid:r.showGrid,showList:r.showList,sortDirection:r.sortDirection,sortKey:r.sortKey,t,tagKeys:r.tagKeys,thumbSize:r.thumbSize,toggleSortDirection:r.toggleSortDirection,view:r.view}),r.hasStorageColumns&&(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"fb-references-shard",children:[(0,n.jsx)("label",{className:"text-xs text-muted-foreground",htmlFor:"fb-reference-shard-input",children:t("References shard")}),(0,n.jsx)(Te,{id:"fb-reference-shard-input",onChange:r.setReferenceShard,testId:"fb-reference-shard-input",value:r.referenceShard}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:t("Which shard's records are checked for references to these files. Empty = root shard.")})]}),r.hasStorageColumns&&(0,n.jsx)(It,{busy:r.danglingBusy,onCheck:r.checkOrphans,references:r.danglingReferences,t,truncated:r.danglingTruncated}),r.selected.size>0&&(0,n.jsx)(Ee,{count:r.selected.size,editable:!0,onClear:r.clearSelection,onDelete:r.bulkDelete}),r.error!==void 0&&(0,n.jsx)("p",{className:"text-sm text-destructive","data-testid":"storage-error",role:"alert",children:r.error}),w&&(0,n.jsx)(me,{description:t("Objects you upload to your R2 buckets will appear here."),icon:(0,n.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,n.jsx)("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"}),(0,n.jsx)("path",{d:"M12 11v5m-2.5-2.5h5"})]}),testId:"fb-empty",title:t("No objects.")}),r.hasObjects&&r.view==="list"&&(0,n.jsx)(vt,{allSelected:r.allSelected,busy:r.busy,copiedKey:r.copiedKey,files:r.files,folders:r.folders,handlers:m,onEnterFolder:r.enterFolder,prefix:r.prefix,references:r.references,selected:r.selected,showReferences:r.hasStorageColumns,someSelected:r.someSelected,t,toggleSelectAll:r.toggleSelectAll}),r.hasObjects&&r.view==="grid"&&(0,n.jsx)(Et,{busy:r.busy,copiedKey:r.copiedKey,files:r.files,folders:r.folders,handlers:m,onEnterFolder:r.enterFolder,prefix:r.prefix,references:r.references,resolveUrl:r.resolveUrl,selected:r.selected,showReferences:r.hasStorageColumns,size:r.thumbSize,t}),r.nextCursor!==void 0&&(0,n.jsx)("div",{children:(0,n.jsx)(re,{"data-testid":"fb-next",disabled:r.busy,onClick:r.loadMore,size:"sm",type:"button",variant:"outline",children:t("Load more")})})]})},"ps");function Gt(d){return d!==""}g(Gt,"Zt");export{ur as FileBrowser};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as E}from"./chunk-WUW4ZHRL.js";import{a as w}from"./chunk-BWEXJENB.js";import"./chunk-74ASA4WU.js";import"./chunk-XQS7KSHL.js";import"./chunk-7PIHTTND.js";import{b as T}from"./chunk-
|
|
1
|
+
import{a as E}from"./chunk-WUW4ZHRL.js";import{a as w}from"./chunk-BWEXJENB.js";import"./chunk-74ASA4WU.js";import"./chunk-XQS7KSHL.js";import"./chunk-7PIHTTND.js";import{b as T}from"./chunk-2UWKGSEA.js";import{f as A}from"./chunk-22WJHOC4.js";import"./chunk-RCZTUWG3.js";import{a as j}from"./chunk-UANVABQG.js";import{a as _,b as $,c as C,d as g,e as o,f as l}from"./chunk-L4EZAHCD.js";import{a as I,e as S}from"./chunk-IYWVSMAY.js";import{d as k,o as B,s as R}from"./chunk-BKM6PMSO.js";import"./chunk-VYW2PAWC.js";import{a as h,d as y,f as K,g as L}from"./chunk-R5ZTCHCE.js";var H=y(K(),1);var s=y(L(),1);var z=200,U=h(()=>{let e=(0,H.c)(21),n=A(),t=k(),u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=["lunora-auth-sessions",z],e[0]=u):u=e[0];let p;e[1]!==n?(p=h(()=>n.listAuthSessions({limit:z}),"u"),e[1]=n,e[2]=p):p=e[2];let a=T(u,p),{error:f}=a,i=a.data?.rows??null,x;e[3]!==a?(x=h(()=>{a.refetch()},"p"),e[3]=a,e[4]=x):x=e[4],E(x,!0);let N;e[5]!==n||e[6]!==a?(N=h(r=>{B((async()=>{await n.revokeAuthSession({sessionId:r}),a.refetch()})())},"x"),e[5]=n,e[6]=a,e[7]=N):N=e[7];let v=N,d;e[8]!==f?(d=f!==null&&(0,s.jsx)("p",{className:"text-sm text-destructive","data-testid":"auth-sessions-error",role:"alert",children:f}),e[8]=f,e[9]=d):d=e[9];let c;e[10]!==i||e[11]!==t?(c=i!==null&&i.length===0&&(0,s.jsx)(j,{testId:"auth-sessions-empty",title:t("No active sessions.")}),e[10]=i,e[11]=t,e[12]=c):c=e[12];let m;e[13]!==v||e[14]!==i||e[15]!==t?(m=i!==null&&i.length>0&&(0,s.jsx)(I,{className:"overflow-hidden py-0",children:(0,s.jsx)(S,{className:"px-0",children:(0,s.jsxs)(_,{"data-testid":"auth-sessions-table",children:[(0,s.jsx)($,{children:(0,s.jsxs)(g,{children:[(0,s.jsx)(o,{children:t("user")}),(0,s.jsx)(o,{children:t("expires")}),(0,s.jsx)(o,{children:t("ip")}),(0,s.jsx)(o,{children:t("user agent")}),(0,s.jsx)(o,{children:t("impersonated by")}),(0,s.jsx)(o,{"aria-label":t("Actions")})]})}),(0,s.jsx)(C,{children:i.map(r=>(0,s.jsxs)(g,{"data-testid":`auth-session-${r.id}`,children:[(0,s.jsx)(l,{className:"font-mono text-xs",children:r.userId}),(0,s.jsx)(l,{className:"text-muted-foreground tabular-nums",children:R(r.expiresAt)}),(0,s.jsx)(l,{children:r.ipAddress??""}),(0,s.jsx)(l,{className:"max-w-40 truncate",children:r.userAgent??""}),(0,s.jsx)(l,{className:"font-mono text-xs",children:r.impersonatedBy??""}),(0,s.jsx)(l,{children:(0,s.jsx)(w,{"data-testid":`auth-session-revoke-${r.id}`,onClick:h(()=>{v(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Revoke")})})]},r.id))})]})})}),e[13]=v,e[14]=i,e[15]=t,e[16]=m):m=e[16];let b;return e[17]!==d||e[18]!==c||e[19]!==m?(b=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"auth-sessions",children:[d,c,m]}),e[17]=d,e[18]=c,e[19]=m,e[20]=b):b=e[20],b},"K");export{U as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as u,o as f}from"./chunk-
|
|
1
|
+
import{h as u,o as f}from"./chunk-BKM6PMSO.js";import{a as s,d as l,e as h,f as S}from"./chunk-R5ZTCHCE.js";var i=l(S(),1),c=l(h(),1);var g=s(()=>{let t=(0,i.c)(4),[a,n]=(0,c.useState)(!1),[e,m]=(0,c.useState)(null),r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=s(p=>{f((async()=>{n(!0),m(null);try{await p()}catch(b){m(u(b))}n(!1)})())},"e"),t[0]=r):r=t[0];let y=r,o;return t[1]!==a||t[2]!==e?(o={busy:a,error:e,run:y},t[1]=a,t[2]=e,t[3]=o):o=t[3],o},"g");export{g as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as me}from"./chunk-W2JBKQNU.js";import{P as ne}from"./chunk-AOAJGSYZ.js";import"./chunk-TFMQSCGC.js";import{a as ee}from"./chunk-BWEXJENB.js";import"./chunk-74ASA4WU.js";import"./chunk-XQS7KSHL.js";import"./chunk-7PIHTTND.js";import"./chunk-RCZTUWG3.js";import{a as te,e as se}from"./chunk-IYWVSMAY.js";import{d as Z,h as ie,o as de,q as ce}from"./chunk-
|
|
1
|
+
import{a as me}from"./chunk-W2JBKQNU.js";import{P as ne}from"./chunk-AOAJGSYZ.js";import"./chunk-TFMQSCGC.js";import{a as ee}from"./chunk-BWEXJENB.js";import"./chunk-74ASA4WU.js";import"./chunk-XQS7KSHL.js";import"./chunk-7PIHTTND.js";import"./chunk-RCZTUWG3.js";import{a as te,e as se}from"./chunk-IYWVSMAY.js";import{d as Z,h as ie,o as de,q as ce}from"./chunk-BKM6PMSO.js";import{a as h,d as Y,e as ge,f as xe,g as ye}from"./chunk-R5ZTCHCE.js";var re=Y(xe(),1),H=Y(ge(),1);var s=Y(ye(),1);var be=h(e=>{let t=(0,re.c)(23),{destination:r}=e,f=Z(),g;t[0]!==r.snippet?(g=h(()=>{ce(r.snippet)},"g"),t[0]=r.snippet,t[1]=g):g=t[1];let m=g,a;t[2]!==r.title?(a=(0,s.jsx)("h4",{className:"text-sm font-semibold",children:r.title}),t[2]=r.title,t[3]=a):a=t[3];let o;t[4]!==r.description?(o=(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:r.description}),t[4]=r.description,t[5]=o):o=t[5];let d;t[6]!==a||t[7]!==o?(d=(0,s.jsxs)("div",{children:[a,o]}),t[6]=a,t[7]=o,t[8]=d):d=t[8];let E=`drain-copy-${r.id}`,l;t[9]!==f?(l=f("Copy"),t[9]=f,t[10]=l):l=t[10];let n;t[11]!==m||t[12]!==E||t[13]!==l?(n=(0,s.jsx)(ee,{"data-testid":E,onClick:m,size:"sm",variant:"outline",children:l}),t[11]=m,t[12]=E,t[13]=l,t[14]=n):n=t[14];let i;t[15]!==d||t[16]!==n?(i=(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[d,n]}),t[15]=d,t[16]=n,t[17]=i):i=t[17];let c;t[18]!==r.snippet?(c=(0,s.jsx)("pre",{className:"mt-2 overflow-x-auto rounded bg-muted p-2 font-mono text-xs",children:r.snippet}),t[18]=r.snippet,t[19]=c):c=t[19];let x;return t[20]!==i||t[21]!==c?(x=(0,s.jsx)(te,{className:"py-0","data-testid":"drain-card",children:(0,s.jsxs)(se,{className:"p-3",children:[i,c]})}),t[20]=i,t[21]=c,t[22]=x):x=t[22],x},"he"),Te=h(()=>{let e=(0,re.c)(88),t=Z(),r;e[0]!==t?(r=t("Stream every request log to R2, a SIEM, or a third-party log service."),e[0]=t,e[1]=r):r=e[1];let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f=["{",' "logpush": true',"}"],e[2]=f):f=e[2];let g=f.join(`
|
|
2
2
|
`),m;e[3]!==t?(m=t("Logpush"),e[3]=t,e[4]=m):m=e[4];let a;e[5]!==r||e[6]!==m?(a={description:r,id:"logpush",snippet:g,title:m},e[5]=r,e[6]=m,e[7]=a):a=e[7];let o;e[8]!==t?(o=t("Send logs programmatically to a Worker for custom capture and forwarding."),e[8]=t,e[9]=o):o=e[9];let d;e[10]===Symbol.for("react.memo_cache_sentinel")?(d=["{",' "tail_consumers": [{ "service": "my-log-forwarder" }]',"}"],e[10]=d):d=e[10];let E=d.join(`
|
|
3
3
|
`),l;e[11]!==t?(l=t("Tail Workers"),e[11]=t,e[12]=l):l=e[12];let n;e[13]!==o||e[14]!==l?(n={description:o,id:"tail-worker",snippet:E,title:l},e[13]=o,e[14]=l,e[15]=n):n=e[15];let i;e[16]!==t?(i=t("Retain and query recent request logs directly in Cloudflare's dashboard."),e[16]=t,e[17]=i):i=e[17];let c;e[18]===Symbol.for("react.memo_cache_sentinel")?(c=["{",' "observability": { "enabled": true }',"}"],e[18]=c):c=e[18];let x=c.join(`
|
|
4
4
|
`),y;e[19]!==t?(y=t("Workers Logs"),e[19]=t,e[20]=y):y=e[20];let b;e[21]!==i||e[22]!==y?(b={description:i,id:"workers-logs",snippet:x,title:y},e[21]=i,e[22]=y,e[23]=b):b=e[23];let J;e[24]!==b||e[25]!==a||e[26]!==n?(J=[a,n,b],e[24]=b,e[25]=a,e[26]=n,e[27]=J):J=e[27];let Q=J,[p,pe]=(0,H.useState)(""),[k,ae]=(0,H.useState)(!1),[u,K]=(0,H.useState)(null),$;if(e[28]!==t||e[29]!==p){let V=h(async()=>{let oe=p.trim();if(oe==="")return;let le="fetch"in globalThis?globalThis.fetch:void 0;if(le===void 0){K({kind:"error",message:t("fetch is unavailable in this environment.")});return}let fe={durationMs:12,function:"messages:list",outcome:"ok",shard:"root",source:"lunora",tablesRead:["messages"],tablesWritten:[],ts:new Date().toISOString(),type:"request"};ae(!0),K(null);let he=performance.now();try{let X=await le(oe,{body:JSON.stringify(fe),headers:{"Content-Type":"application/json"},method:"POST"});K({kind:"success",latencyMs:Math.round(performance.now()-he),status:X.status})}catch(X){K({kind:"error",message:ie(X)})}ae(!1)},"H");$=h(()=>{de(V())},"z"),e[28]=t,e[29]=p,e[30]=$}else $=e[30];let U=$,A;e[31]===Symbol.for("react.memo_cache_sentinel")?(A=h(V=>{pe(V.target.value)},"J"),e[31]=A):A=e[31];let ue=A,v;e[32]!==t?(v=t("Open in Cloudflare"),e[32]=t,e[33]=v):v=e[33];let w;e[34]!==v?(w=(0,s.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,s.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"drain-cf-link",href:me,rel:"noreferrer",target:"_blank",children:v})}),e[34]=v,e[35]=w):w=e[35];let N;e[36]!==t?(N=t("Lunora does not ship logs itself \u2014 forwarding is handled by Cloudflare. Configure a destination below, then test your collector."),e[36]=t,e[37]=N):N=e[37];let S;e[38]!==N?(S=(0,s.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"drain-readonly-note",children:N}),e[38]=N,e[39]=S):S=e[39];let C;e[40]!==t?(C=t("Cloudflare destinations"),e[40]=t,e[41]=C):C=e[41];let _;e[42]!==C?(_=(0,s.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:C}),e[42]=C,e[43]=_):_=e[43];let T;e[44]!==Q?(T=Q.map(ke),e[44]=Q,e[45]=T):T=e[45];let j;e[46]!==_||e[47]!==T?(j=(0,s.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"drain-destinations",children:[_,T]}),e[46]=_,e[47]=T,e[48]=j):j=e[48];let q;e[49]!==t?(q=t("Webhook test"),e[49]=t,e[50]=q):q=e[50];let M;e[51]!==q?(M=(0,s.jsx)("h3",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:q}),e[51]=q,e[52]=M):M=e[52];let O;e[53]!==t?(O=t("POST a sample Lunora request-log envelope to your collector to confirm it is reachable."),e[53]=t,e[54]=O):O=e[54];let W;e[55]!==O?(W=(0,s.jsx)("p",{className:"mb-2 text-sm text-muted-foreground",children:O}),e[55]=O,e[56]=W):W=e[56];let L;e[57]!==t?(L=t("https://example.com/logs"),e[57]=t,e[58]=L):L=e[58];let I;e[59]!==L||e[60]!==p?(I=(0,s.jsx)(ne,{className:"min-w-[20rem] flex-1","data-testid":"drain-webhook-url",onChange:ue,placeholder:L,type:"url",value:p}),e[59]=L,e[60]=p,e[61]=I):I=e[61];let R;e[62]!==k||e[63]!==p?(R=k||p.trim()==="",e[62]=k,e[63]=p,e[64]=R):R=e[64];let D;e[65]!==k||e[66]!==t?(D=t(k?"Sending\u2026":"Send test event"),e[65]=k,e[66]=t,e[67]=D):D=e[67];let F;e[68]!==U||e[69]!==R||e[70]!==D?(F=(0,s.jsx)(ee,{"data-testid":"drain-webhook-test",disabled:R,onClick:U,children:D}),e[68]=U,e[69]=R,e[70]=D,e[71]=F):F=e[71];let P;e[72]!==I||e[73]!==F?(P=(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[I,F]}),e[72]=I,e[73]=F,e[74]=P):P=e[74];let z;e[75]!==u||e[76]!==t?(z=u!==null&&(0,s.jsx)("p",{className:u.kind==="success"?"mt-2 text-sm text-muted-foreground":"mt-2 text-sm text-destructive","data-testid":"drain-webhook-result",role:u.kind==="error"?"alert":void 0,children:u.kind==="success"?t("Delivered \u2014 status {status} in {latency}ms",{latency:u.latencyMs,status:u.status}):t("Failed: {message}",{message:u.message})}),e[75]=u,e[76]=t,e[77]=z):z=e[77];let B;e[78]!==M||e[79]!==W||e[80]!==P||e[81]!==z?(B=(0,s.jsx)(te,{className:"py-0",children:(0,s.jsx)(se,{className:"p-3",children:(0,s.jsxs)("section",{"data-testid":"drain-webhook",children:[M,W,P,z]})})}),e[78]=M,e[79]=W,e[80]=P,e[81]=z,e[82]=B):B=e[82];let G;return e[83]!==w||e[84]!==S||e[85]!==j||e[86]!==B?(G=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"log-drains",children:[w,S,j,B]}),e[83]=w,e[84]=S,e[85]=j,e[86]=B,e[87]=G):G=e[87],G},"Te");function ke(e){return(0,s.jsx)(be,{destination:e},e.id)}h(ke,"ge");export{Te as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as me}from"./chunk-EYGF6TQS.js";import{a as $}from"./chunk-IWOZGUI2.js";import{a as ue}from"./chunk-JURAVSE7.js";import"./chunk-APRVSWBH.js";import"./chunk-JV7KTJPY.js";import"./chunk-DPNEFSEC.js";import{a as de}from"./chunk-P52BY657.js";import"./chunk-VNTEQQPP.js";import"./chunk-INQICZYC.js";import"./chunk-TFMQSCGC.js";import{b as D}from"./chunk-SPDZUX4P.js";import"./chunk-7PIHTTND.js";import"./chunk-F7JOSNAT.js";import{a as M}from"./chunk-VDW32UET.js";import{c as ce}from"./chunk-YUWMB6EV.js";import{f as ne,g as oe}from"./chunk-TBXK3FKP.js";import"./chunk-RCZTUWG3.js";import{a as A}from"./chunk-IYWVSMAY.js";import{d as T,f as j,g as Q,h as W,o as _,r as ie}from"./chunk-6ZPTNC34.js";import"./chunk-VYW2PAWC.js";import{a as h,d as I,e as Ee,f as ae,g as le,i as E}from"./chunk-R5ZTCHCE.js";var Y=I(ae(),1);var f=I(Ee(),1);var fe=I(ae(),1);var B=I(le(),1);var Me={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive"},pe=h(()=>{let t=(0,fe.c)(16),e=T(),a=oe(),s;e:switch(a){case"connected":{let o;t[0]!==e?(o=e("Connected"),t[0]=e,t[1]=o):o=t[1],s=o;break e}case"connecting":{let o;t[2]!==e?(o=e("Connecting\u2026"),t[2]=e,t[3]=o):o=t[3],s=o;break e}case"idle":{let o;t[4]!==e?(o=e("Idle"),t[4]=e,t[5]=o):o=t[5],s=o;break e}case"offline":{let o;t[6]!==e?(o=e("Offline"),t[6]=e,t[7]=o):o=t[7],s=o;break e}default:s=a}let l=Me[a],c;t[8]!==l?(c=E("size-2 rounded-full",l),t[8]=l,t[9]=c):c=t[9];let i;t[10]!==c?(i=(0,B.jsx)("span",{"aria-hidden":"true",className:c}),t[10]=c,t[11]=i):i=t[11];let n;return t[12]!==a||t[13]!==i||t[14]!==s?(n=(0,B.jsxs)("span",{"aria-live":"polite",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground","data-status":a,"data-testid":"dash-connection",role:"status",children:[i,s]}),t[12]=a,t[13]=i,t[14]=s,t[15]=n):n=t[15],n},"T");var r=I(le(),1);var Ae={crit:"destructive",ok:"secondary",warn:"default"},U=h((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"P"),X=h((t,e,a)=>Number.isNaN(t)?"ok":t>=a?"crit":t>=e?"warn":"ok","Q"),xe=.01,ve=.05,je=h(t=>{let e=(0,Y.c)(36),{errorCount:a,logsError:s,topErrors:l,worstFunctions:c}=t,i=T(),n;e[0]!==i?(n=i("Functions by error rate"),e[0]=i,e[1]=n):n=e[1];let o;e[2]!==n?(o=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n})}),e[2]=n,e[3]=o):o=e[3];let p;e[4]!==i||e[5]!==c?(p=c.length===0?(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:i("No function activity yet.")}):(0,r.jsx)("ul",{className:"divide-y divide-border",children:c.map(w=>(0,r.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:w.path}),(0,r.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[(0,r.jsx)("span",{className:"tabular-nums text-muted-foreground",children:i("{count} calls",{count:w.calls.toString()})}),(0,r.jsx)(D,{variant:Ae[X(w.errors/w.calls,xe,ve)],children:U(w.errors,w.calls)})]})]},w.path))}),e[4]=i,e[5]=c,e[6]=p):p=e[6];let g;e[7]!==o||e[8]!==p?(g=(0,r.jsxs)(A,{className:"gap-0 py-0","data-testid":"hl-functions",children:[o,p]}),e[7]=o,e[8]=p,e[9]=g):g=e[9];let b;e[10]!==i?(b=i("Recent errors"),e[10]=i,e[11]=b):b=e[11];let d;e[12]!==b?(d=(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:b}),e[12]=b,e[13]=d):d=e[13];let u=a>0?"destructive":"outline",x;e[14]!==a||e[15]!==u?(x=(0,r.jsx)(D,{"data-testid":"hl-error-count",variant:u,children:a}),e[14]=a,e[15]=u,e[16]=x):x=e[16];let v;e[17]!==d||e[18]!==x?(v=(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[d,x]}),e[17]=d,e[18]=x,e[19]=v):v=e[19];let k;e[20]!==s?(k=s!==null&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:s}),e[20]=s,e[21]=k):k=e[21];let S;e[22]!==s||e[23]!==i||e[24]!==l.length?(S=s===null&&l.length===0&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:i("No recent errors.")}),e[22]=s,e[23]=i,e[24]=l.length,e[25]=S):S=e[25];let q;e[26]!==l?(q=l.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:l.map(Ce)}),e[26]=l,e[27]=q):q=e[27];let N;e[28]!==k||e[29]!==S||e[30]!==q||e[31]!==v?(N=(0,r.jsxs)(A,{className:"gap-0 py-0",children:[v,k,S,q]}),e[28]=k,e[29]=S,e[30]=q,e[31]=v,e[32]=N):N=e[32];let y;return e[33]!==N||e[34]!==g?(y=(0,r.jsxs)("div",{className:"grid gap-3 lg:grid-cols-2",children:[g,N]}),e[33]=N,e[34]=g,e[35]=y):y=e[35],y},"ye");function Ce(t,e){return(0,r.jsxs)("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)("time",{className:"shrink-0 text-muted-foreground",children:ie(t.timestamp)}),t.functionPath!==void 0&&(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:t.functionPath})]}),(0,r.jsx)("span",{className:"text-destructive",children:t.message})]},`${t.timestamp.toString()}-${e.toString()}`)}h(Ce,"Te");var he={completed:0,failed:2,in_progress:1},Ie=h(t=>{let e=0,a=0,s=0,l=0,c=!1,i=[];for(let{metrics:n}of t){if(n===null){l+=1;continue}s+=1,e+=n.requests,a+=n.errors,i.push(...n.history??[]),c||=n.historyTruncated===!0}return{errors:a,failed:l,history:i,historyTruncated:c,reachable:s,requests:e}},"Ae"),Te=h(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.path);if(l===void 0){e.set(s.path,{...s});continue}l.calls+=s.calls,l.errors+=s.errors,l.totalDurationMs+=s.totalDurationMs,l.scans=(l.scans??0)+(s.scans??0),l.maxDurationMs=Math.max(l.maxDurationMs,s.maxDurationMs),l.lastCalledAt=Math.max(l.lastCalledAt,s.lastCalledAt),(s.lastErrorAt??0)>(l.lastErrorAt??0)&&(l.lastErrorAt=s.lastErrorAt,l.lastErrorMessage=s.lastErrorMessage)}return[...e.values()]},"ke"),De=h(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.id);if(l===void 0){e.set(s.id,s);continue}let c=he[s.status]-he[l.status];(c>0||c===0&&(s.updatedAt??0)>(l.updatedAt??0))&&e.set(s.id,s)}return[...e.values()]},"Re"),Pe=j(M.getAuthMetrics),Fe=j(M.getFunctionStats),Le=j(M.getLogs),Re=j(M.getMetrics),ze=j(M.migrationStatus),Oe=5,ge=2e3,_e=5,$e=.1,Be=.3,He=1,Ue=50,Ge=h((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","Pe"),Ke=h(t=>{let e=new Map;for(let s of t??[]){let l=e.get(s.bucketMs)??{calls:0,errors:0};l.calls+=s.calls,l.errors+=s.errors,e.set(s.bucketMs,l)}let a=[...e.entries()].toSorted((s,l)=>s[0]-l[0]);return{errors:a.map(([,s])=>s.errors),requests:a.map(([,s])=>s.calls)}},"Ge"),Ve=h(t=>{let e=0,a=0;for(let l of t)l.status==="failed"?e+=1:l.status==="in_progress"&&(a+=1);let s="ok";return e>0?s="crit":a>0&&(s="warn"),{failed:e,level:s,running:a}},"Ve"),Je=h((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"Be"),be={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},Ne={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},Qe={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},We=h(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","Ke"),H=h(t=>{let e=(0,Y.c)(19),{chart:a,label:s,level:l,testId:c,value:i}=t,n=be[l],o;e[0]!==n?(o=E("size-1.5 shrink-0 rounded-full",n),e[0]=n,e[1]=o):o=e[1];let p;e[2]!==o?(p=(0,r.jsx)("span",{"aria-hidden":"true",className:o}),e[2]=o,e[3]=p):p=e[3];let g;e[4]!==s||e[5]!==p?(g=(0,r.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[p,s]}),e[4]=s,e[5]=p,e[6]=g):g=e[6];let b=Ne[l],d;e[7]!==b?(d=E("truncate text-2xl font-semibold tabular-nums",b),e[7]=b,e[8]=d):d=e[8];let u;e[9]!==d||e[10]!==c||e[11]!==i?(u=(0,r.jsx)("span",{className:d,"data-testid":c,children:i}),e[9]=d,e[10]=c,e[11]=i,e[12]=u):u=e[12];let x;e[13]!==a||e[14]!==u?(x=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[u,a]}),e[13]=a,e[14]=u,e[15]=x):x=e[15];let v;return e[16]!==g||e[17]!==x?(v=(0,r.jsx)(A,{className:"gap-0 py-0",children:(0,r.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[g,x]})}),e[16]=g,e[17]=x,e[18]=v):v=e[18],v},"U"),Xe=h(async(t,e,a)=>{let s=await Promise.all(a.map(d=>{let u=Q(d);return Promise.allSettled([t.query(Re,{},u),t.query(Fe,{},u),t.query(ze,{},u)])})),l=Q(e),c=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[i,n,o]=await Promise.allSettled([t.query(Le,{},l),t.query(Pe,{},l),c]),p=s.map(([d,u,x])=>({functions:u.status==="fulfilled"?u.value.functions:[],metrics:d.status==="fulfilled"?d.value:null,migrations:x.status==="fulfilled"?x.value.migrations:[]})),g=Ie(p),b=s[0]?.[0];return{auth:n.status==="fulfilled"?n.value:null,entries:i.status==="fulfilled"?i.value.entries:[],functions:Te(p.map(d=>d.functions)),logsError:i.status==="rejected"?W(i.reason):null,metricsError:g.reachable===0&&b?.status==="rejected"?W(b.reason):null,migrations:De(p.map(d=>d.migrations)),scheduler:o.status==="fulfilled"?o.value:null,totals:g}},"$e"),Ye=h(t=>{let e=t?.history??[];return{attempts:e.map(a=>a.attempts),failures:e.map(a=>a.failures)}},"ze"),xt=h(({initialShardKey:t})=>{let e=ne(),a=T(),[s,l]=(0,f.useState)([]),[c,i]=(0,f.useState)(null),[n,o]=(0,f.useState)(null),[p,g]=(0,f.useState)(null),[b,d]=(0,f.useState)([]),[u,x]=(0,f.useState)(null),[v,k]=(0,f.useState)(null),[S,q]=(0,f.useState)([]),[N]=(0,f.useState)(de),y=(0,f.useRef)(!1),w=(0,f.useRef)(!0);(0,f.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]);let P=t??"",F=(0,f.useCallback)(async()=>{if(y.current)return;y.current=!0;let m=await Xe(e,P,me(P,N));if(!w.current){y.current=!1;return}o(m.totals),g(m.metricsError),d(m.functions),q(m.migrations),l(m.entries),i(m.logsError),x(m.auth),k(m.scheduler),y.current=!1},[e,N,P]);(0,f.useEffect)(()=>{_(F())},[F]);let G=(0,f.useRef)(0),C=(0,f.useRef)(null),we=h(()=>{let m=Date.now()-G.current;if(m>=ge){G.current=Date.now(),_(F());return}C.current===null&&(C.current=setTimeout(()=>{C.current=null,G.current=Date.now(),_(F())},ge-m))},"ue");(0,f.useEffect)(()=>()=>{C.current!==null&&clearTimeout(C.current)},[]);let{data:Z,liveError:ye}=ce(M.getMetrics,{},{live:!0,shardKey:P});(0,f.useEffect)(()=>{Z!==void 0&&we()},[Z]);let ee=s.filter(m=>m.level==="error"),ke=ee.slice(0,Oe),L=Ke(n?.history),te=Ye(u),Se=b.filter(m=>m.calls>0).toSorted((m,J)=>J.errors/J.calls-m.errors/m.calls||J.calls-m.calls).slice(0,_e),K=Ve(S),qe=n===null||n.requests===0?0:n.errors/n.requests,V=X(qe,xe,ve),re=u===null?"ok":X(u.failureRate,$e,Be),se=v===null?"ok":Ge(v.backlog,He,Ue),R=We([V,re,se,K.level]),z,O;return R==="crit"?(z=a("Critical"),O=a("One or more service levels are breached.")):R==="warn"?(z=a("Degraded"),O=a("Some service levels need attention.")):(z=a("All systems healthy"),O=a("All service levels are within target.")),(0,r.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[(0,r.jsxs)(A,{className:"gap-0 py-0",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:E("flex size-10 shrink-0 items-center justify-center rounded-full",Qe[R]),children:(0,r.jsx)("span",{className:E("size-3 rounded-full",be[R])})}),(0,r.jsxs)("div",{className:"grid leading-tight",children:[(0,r.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:z}),(0,r.jsx)("span",{className:"text-[13px] text-muted-foreground",children:O})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Requests")}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[L.requests.length>=2&&(0,r.jsx)($,{ariaLabel:a("Requests over time"),className:"h-6 w-20 text-foreground",series:L.requests,testId:"hl-spark-requests"}),(0,r.jsx)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:(n?.requests??0).toString()})]})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Error rate")}),(0,r.jsx)("div",{className:E("text-lg font-semibold tabular-nums",Ne[V]),"data-testid":"hl-error-rate",children:n===null?"\u2014":U(n.errors,n.requests)})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(pe,{}),(0,r.jsx)(ue,{message:ye,prefix:"hl"})]})]})]}),p!==null&&(0,r.jsx)("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:p}),p===null&&n?.historyTruncated===!0&&(0,r.jsx)("div",{className:"border-t border-border bg-warning/5 px-4 py-2 text-sm text-muted-foreground","data-testid":"hl-history-truncated",children:a("Showing a partial request/error history \u2014 one or more shards have more data than the trend chart can display.")})]}),(0,r.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[(0,r.jsx)(H,{chart:L.errors.length>=2?(0,r.jsx)($,{ariaLabel:a("Errors over time"),className:"h-7 w-20 text-destructive",series:L.errors,testId:"hl-spark-errors"}):void 0,label:a("Error rate"),level:V,testId:"hl-slo-errorrate",value:n===null?"\u2014":U(n.errors,n.requests)}),(0,r.jsx)(H,{chart:te.failures.length>=2?(0,r.jsx)($,{ariaLabel:a("Auth failures over time"),className:"h-7 w-20 text-destructive",series:te.failures,testId:"hl-spark-auth"}):void 0,label:a("Auth failures"),level:re,testId:"hl-slo-auth",value:u===null?"\u2014":U(u.failures,u.attempts)}),(0,r.jsx)(H,{label:a("Scheduler backlog"),level:se,testId:"hl-slo-backlog",value:v===null?"\u2014":v.backlog.toString()}),(0,r.jsx)(H,{label:a("Migrations"),level:K.level,testId:"hl-slo-migrations",value:Je(K,a)})]}),(0,r.jsx)(je,{errorCount:ee.length,logsError:c,topErrors:ke,worstFunctions:Se}),(0,r.jsxs)(A,{className:"gap-0 py-0",children:[(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Shards seen")}),(0,r.jsx)(D,{"data-testid":"hl-shard-count",variant:"outline",children:N.length})]}),N.length>0&&(0,r.jsx)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:N.map(m=>(0,r.jsx)("li",{"data-testid":"hl-shard",children:(0,r.jsx)(D,{variant:"secondary",children:m})},m))})]})]})},"ut");export{xt as HealthPanel};
|
|
1
|
+
import{b as me}from"./chunk-EYGF6TQS.js";import{a as $}from"./chunk-IWOZGUI2.js";import{a as ue}from"./chunk-E6P2ERQV.js";import"./chunk-APRVSWBH.js";import"./chunk-JV7KTJPY.js";import"./chunk-DPNEFSEC.js";import{a as de}from"./chunk-P52BY657.js";import"./chunk-VNTEQQPP.js";import"./chunk-INQICZYC.js";import"./chunk-TFMQSCGC.js";import{b as D}from"./chunk-SPDZUX4P.js";import"./chunk-7PIHTTND.js";import"./chunk-F7JOSNAT.js";import{a as M}from"./chunk-VDW32UET.js";import{c as ce}from"./chunk-2UWKGSEA.js";import{f as ne,g as oe}from"./chunk-22WJHOC4.js";import"./chunk-RCZTUWG3.js";import{a as A}from"./chunk-IYWVSMAY.js";import{d as T,f as j,g as Q,h as W,o as _,s as ie}from"./chunk-BKM6PMSO.js";import"./chunk-VYW2PAWC.js";import{a as h,d as I,e as Ee,f as ae,g as le,i as E}from"./chunk-R5ZTCHCE.js";var Y=I(ae(),1);var f=I(Ee(),1);var fe=I(ae(),1);var B=I(le(),1);var Me={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive"},pe=h(()=>{let t=(0,fe.c)(16),e=T(),a=oe(),s;e:switch(a){case"connected":{let o;t[0]!==e?(o=e("Connected"),t[0]=e,t[1]=o):o=t[1],s=o;break e}case"connecting":{let o;t[2]!==e?(o=e("Connecting\u2026"),t[2]=e,t[3]=o):o=t[3],s=o;break e}case"idle":{let o;t[4]!==e?(o=e("Idle"),t[4]=e,t[5]=o):o=t[5],s=o;break e}case"offline":{let o;t[6]!==e?(o=e("Offline"),t[6]=e,t[7]=o):o=t[7],s=o;break e}default:s=a}let l=Me[a],c;t[8]!==l?(c=E("size-2 rounded-full",l),t[8]=l,t[9]=c):c=t[9];let i;t[10]!==c?(i=(0,B.jsx)("span",{"aria-hidden":"true",className:c}),t[10]=c,t[11]=i):i=t[11];let n;return t[12]!==a||t[13]!==i||t[14]!==s?(n=(0,B.jsxs)("span",{"aria-live":"polite",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground","data-status":a,"data-testid":"dash-connection",role:"status",children:[i,s]}),t[12]=a,t[13]=i,t[14]=s,t[15]=n):n=t[15],n},"T");var r=I(le(),1);var Ae={crit:"destructive",ok:"secondary",warn:"default"},U=h((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"P"),X=h((t,e,a)=>Number.isNaN(t)?"ok":t>=a?"crit":t>=e?"warn":"ok","Q"),xe=.01,ve=.05,je=h(t=>{let e=(0,Y.c)(36),{errorCount:a,logsError:s,topErrors:l,worstFunctions:c}=t,i=T(),n;e[0]!==i?(n=i("Functions by error rate"),e[0]=i,e[1]=n):n=e[1];let o;e[2]!==n?(o=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n})}),e[2]=n,e[3]=o):o=e[3];let p;e[4]!==i||e[5]!==c?(p=c.length===0?(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:i("No function activity yet.")}):(0,r.jsx)("ul",{className:"divide-y divide-border",children:c.map(w=>(0,r.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:w.path}),(0,r.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[(0,r.jsx)("span",{className:"tabular-nums text-muted-foreground",children:i("{count} calls",{count:w.calls.toString()})}),(0,r.jsx)(D,{variant:Ae[X(w.errors/w.calls,xe,ve)],children:U(w.errors,w.calls)})]})]},w.path))}),e[4]=i,e[5]=c,e[6]=p):p=e[6];let g;e[7]!==o||e[8]!==p?(g=(0,r.jsxs)(A,{className:"gap-0 py-0","data-testid":"hl-functions",children:[o,p]}),e[7]=o,e[8]=p,e[9]=g):g=e[9];let b;e[10]!==i?(b=i("Recent errors"),e[10]=i,e[11]=b):b=e[11];let d;e[12]!==b?(d=(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:b}),e[12]=b,e[13]=d):d=e[13];let u=a>0?"destructive":"outline",x;e[14]!==a||e[15]!==u?(x=(0,r.jsx)(D,{"data-testid":"hl-error-count",variant:u,children:a}),e[14]=a,e[15]=u,e[16]=x):x=e[16];let v;e[17]!==d||e[18]!==x?(v=(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[d,x]}),e[17]=d,e[18]=x,e[19]=v):v=e[19];let k;e[20]!==s?(k=s!==null&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:s}),e[20]=s,e[21]=k):k=e[21];let S;e[22]!==s||e[23]!==i||e[24]!==l.length?(S=s===null&&l.length===0&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:i("No recent errors.")}),e[22]=s,e[23]=i,e[24]=l.length,e[25]=S):S=e[25];let q;e[26]!==l?(q=l.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:l.map(Ce)}),e[26]=l,e[27]=q):q=e[27];let N;e[28]!==k||e[29]!==S||e[30]!==q||e[31]!==v?(N=(0,r.jsxs)(A,{className:"gap-0 py-0",children:[v,k,S,q]}),e[28]=k,e[29]=S,e[30]=q,e[31]=v,e[32]=N):N=e[32];let y;return e[33]!==N||e[34]!==g?(y=(0,r.jsxs)("div",{className:"grid gap-3 lg:grid-cols-2",children:[g,N]}),e[33]=N,e[34]=g,e[35]=y):y=e[35],y},"ye");function Ce(t,e){return(0,r.jsxs)("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)("time",{className:"shrink-0 text-muted-foreground",children:ie(t.timestamp)}),t.functionPath!==void 0&&(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:t.functionPath})]}),(0,r.jsx)("span",{className:"text-destructive",children:t.message})]},`${t.timestamp.toString()}-${e.toString()}`)}h(Ce,"Te");var he={completed:0,failed:2,in_progress:1},Ie=h(t=>{let e=0,a=0,s=0,l=0,c=!1,i=[];for(let{metrics:n}of t){if(n===null){l+=1;continue}s+=1,e+=n.requests,a+=n.errors,i.push(...n.history??[]),c||=n.historyTruncated===!0}return{errors:a,failed:l,history:i,historyTruncated:c,reachable:s,requests:e}},"Ae"),Te=h(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.path);if(l===void 0){e.set(s.path,{...s});continue}l.calls+=s.calls,l.errors+=s.errors,l.totalDurationMs+=s.totalDurationMs,l.scans=(l.scans??0)+(s.scans??0),l.maxDurationMs=Math.max(l.maxDurationMs,s.maxDurationMs),l.lastCalledAt=Math.max(l.lastCalledAt,s.lastCalledAt),(s.lastErrorAt??0)>(l.lastErrorAt??0)&&(l.lastErrorAt=s.lastErrorAt,l.lastErrorMessage=s.lastErrorMessage)}return[...e.values()]},"ke"),De=h(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.id);if(l===void 0){e.set(s.id,s);continue}let c=he[s.status]-he[l.status];(c>0||c===0&&(s.updatedAt??0)>(l.updatedAt??0))&&e.set(s.id,s)}return[...e.values()]},"Re"),Pe=j(M.getAuthMetrics),Fe=j(M.getFunctionStats),Le=j(M.getLogs),Re=j(M.getMetrics),ze=j(M.migrationStatus),Oe=5,ge=2e3,_e=5,$e=.1,Be=.3,He=1,Ue=50,Ge=h((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","Pe"),Ke=h(t=>{let e=new Map;for(let s of t??[]){let l=e.get(s.bucketMs)??{calls:0,errors:0};l.calls+=s.calls,l.errors+=s.errors,e.set(s.bucketMs,l)}let a=[...e.entries()].toSorted((s,l)=>s[0]-l[0]);return{errors:a.map(([,s])=>s.errors),requests:a.map(([,s])=>s.calls)}},"Ge"),Ve=h(t=>{let e=0,a=0;for(let l of t)l.status==="failed"?e+=1:l.status==="in_progress"&&(a+=1);let s="ok";return e>0?s="crit":a>0&&(s="warn"),{failed:e,level:s,running:a}},"Ve"),Je=h((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"Be"),be={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},Ne={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},Qe={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},We=h(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","Ke"),H=h(t=>{let e=(0,Y.c)(19),{chart:a,label:s,level:l,testId:c,value:i}=t,n=be[l],o;e[0]!==n?(o=E("size-1.5 shrink-0 rounded-full",n),e[0]=n,e[1]=o):o=e[1];let p;e[2]!==o?(p=(0,r.jsx)("span",{"aria-hidden":"true",className:o}),e[2]=o,e[3]=p):p=e[3];let g;e[4]!==s||e[5]!==p?(g=(0,r.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[p,s]}),e[4]=s,e[5]=p,e[6]=g):g=e[6];let b=Ne[l],d;e[7]!==b?(d=E("truncate text-2xl font-semibold tabular-nums",b),e[7]=b,e[8]=d):d=e[8];let u;e[9]!==d||e[10]!==c||e[11]!==i?(u=(0,r.jsx)("span",{className:d,"data-testid":c,children:i}),e[9]=d,e[10]=c,e[11]=i,e[12]=u):u=e[12];let x;e[13]!==a||e[14]!==u?(x=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[u,a]}),e[13]=a,e[14]=u,e[15]=x):x=e[15];let v;return e[16]!==g||e[17]!==x?(v=(0,r.jsx)(A,{className:"gap-0 py-0",children:(0,r.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[g,x]})}),e[16]=g,e[17]=x,e[18]=v):v=e[18],v},"U"),Xe=h(async(t,e,a)=>{let s=await Promise.all(a.map(d=>{let u=Q(d);return Promise.allSettled([t.query(Re,{},u),t.query(Fe,{},u),t.query(ze,{},u)])})),l=Q(e),c=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[i,n,o]=await Promise.allSettled([t.query(Le,{},l),t.query(Pe,{},l),c]),p=s.map(([d,u,x])=>({functions:u.status==="fulfilled"?u.value.functions:[],metrics:d.status==="fulfilled"?d.value:null,migrations:x.status==="fulfilled"?x.value.migrations:[]})),g=Ie(p),b=s[0]?.[0];return{auth:n.status==="fulfilled"?n.value:null,entries:i.status==="fulfilled"?i.value.entries:[],functions:Te(p.map(d=>d.functions)),logsError:i.status==="rejected"?W(i.reason):null,metricsError:g.reachable===0&&b?.status==="rejected"?W(b.reason):null,migrations:De(p.map(d=>d.migrations)),scheduler:o.status==="fulfilled"?o.value:null,totals:g}},"$e"),Ye=h(t=>{let e=t?.history??[];return{attempts:e.map(a=>a.attempts),failures:e.map(a=>a.failures)}},"ze"),xt=h(({initialShardKey:t})=>{let e=ne(),a=T(),[s,l]=(0,f.useState)([]),[c,i]=(0,f.useState)(null),[n,o]=(0,f.useState)(null),[p,g]=(0,f.useState)(null),[b,d]=(0,f.useState)([]),[u,x]=(0,f.useState)(null),[v,k]=(0,f.useState)(null),[S,q]=(0,f.useState)([]),[N]=(0,f.useState)(de),y=(0,f.useRef)(!1),w=(0,f.useRef)(!0);(0,f.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]);let P=t??"",F=(0,f.useCallback)(async()=>{if(y.current)return;y.current=!0;let m=await Xe(e,P,me(P,N));if(!w.current){y.current=!1;return}o(m.totals),g(m.metricsError),d(m.functions),q(m.migrations),l(m.entries),i(m.logsError),x(m.auth),k(m.scheduler),y.current=!1},[e,N,P]);(0,f.useEffect)(()=>{_(F())},[F]);let G=(0,f.useRef)(0),C=(0,f.useRef)(null),we=h(()=>{let m=Date.now()-G.current;if(m>=ge){G.current=Date.now(),_(F());return}C.current===null&&(C.current=setTimeout(()=>{C.current=null,G.current=Date.now(),_(F())},ge-m))},"ue");(0,f.useEffect)(()=>()=>{C.current!==null&&clearTimeout(C.current)},[]);let{data:Z,liveError:ye}=ce(M.getMetrics,{},{live:!0,shardKey:P});(0,f.useEffect)(()=>{Z!==void 0&&we()},[Z]);let ee=s.filter(m=>m.level==="error"),ke=ee.slice(0,Oe),L=Ke(n?.history),te=Ye(u),Se=b.filter(m=>m.calls>0).toSorted((m,J)=>J.errors/J.calls-m.errors/m.calls||J.calls-m.calls).slice(0,_e),K=Ve(S),qe=n===null||n.requests===0?0:n.errors/n.requests,V=X(qe,xe,ve),re=u===null?"ok":X(u.failureRate,$e,Be),se=v===null?"ok":Ge(v.backlog,He,Ue),R=We([V,re,se,K.level]),z,O;return R==="crit"?(z=a("Critical"),O=a("One or more service levels are breached.")):R==="warn"?(z=a("Degraded"),O=a("Some service levels need attention.")):(z=a("All systems healthy"),O=a("All service levels are within target.")),(0,r.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[(0,r.jsxs)(A,{className:"gap-0 py-0",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:E("flex size-10 shrink-0 items-center justify-center rounded-full",Qe[R]),children:(0,r.jsx)("span",{className:E("size-3 rounded-full",be[R])})}),(0,r.jsxs)("div",{className:"grid leading-tight",children:[(0,r.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:z}),(0,r.jsx)("span",{className:"text-[13px] text-muted-foreground",children:O})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Requests")}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[L.requests.length>=2&&(0,r.jsx)($,{ariaLabel:a("Requests over time"),className:"h-6 w-20 text-foreground",series:L.requests,testId:"hl-spark-requests"}),(0,r.jsx)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:(n?.requests??0).toString()})]})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Error rate")}),(0,r.jsx)("div",{className:E("text-lg font-semibold tabular-nums",Ne[V]),"data-testid":"hl-error-rate",children:n===null?"\u2014":U(n.errors,n.requests)})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(pe,{}),(0,r.jsx)(ue,{message:ye,prefix:"hl"})]})]})]}),p!==null&&(0,r.jsx)("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:p}),p===null&&n?.historyTruncated===!0&&(0,r.jsx)("div",{className:"border-t border-border bg-warning/5 px-4 py-2 text-sm text-muted-foreground","data-testid":"hl-history-truncated",children:a("Showing a partial request/error history \u2014 one or more shards have more data than the trend chart can display.")})]}),(0,r.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[(0,r.jsx)(H,{chart:L.errors.length>=2?(0,r.jsx)($,{ariaLabel:a("Errors over time"),className:"h-7 w-20 text-destructive",series:L.errors,testId:"hl-spark-errors"}):void 0,label:a("Error rate"),level:V,testId:"hl-slo-errorrate",value:n===null?"\u2014":U(n.errors,n.requests)}),(0,r.jsx)(H,{chart:te.failures.length>=2?(0,r.jsx)($,{ariaLabel:a("Auth failures over time"),className:"h-7 w-20 text-destructive",series:te.failures,testId:"hl-spark-auth"}):void 0,label:a("Auth failures"),level:re,testId:"hl-slo-auth",value:u===null?"\u2014":U(u.failures,u.attempts)}),(0,r.jsx)(H,{label:a("Scheduler backlog"),level:se,testId:"hl-slo-backlog",value:v===null?"\u2014":v.backlog.toString()}),(0,r.jsx)(H,{label:a("Migrations"),level:K.level,testId:"hl-slo-migrations",value:Je(K,a)})]}),(0,r.jsx)(je,{errorCount:ee.length,logsError:c,topErrors:ke,worstFunctions:Se}),(0,r.jsxs)(A,{className:"gap-0 py-0",children:[(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Shards seen")}),(0,r.jsx)(D,{"data-testid":"hl-shard-count",variant:"outline",children:N.length})]}),N.length>0&&(0,r.jsx)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:N.map(m=>(0,r.jsx)("li",{"data-testid":"hl-shard",children:(0,r.jsx)(D,{variant:"secondary",children:m})},m))})]})]})},"ut");export{xt as HealthPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as c}from"./chunk-INBA3473.js";import{e}from"./chunk-4YTSKL4R.js";import{o as m}from"./chunk-
|
|
1
|
+
import{a as c}from"./chunk-INBA3473.js";import{e}from"./chunk-4YTSKL4R.js";import{o as m}from"./chunk-BKM6PMSO.js";import{a as s,d as p,f as n}from"./chunk-R5ZTCHCE.js";var f=p(n(),1);var h=s(r=>{let t=(0,f.c)(3),a=e(),o;return t[0]!==a||t[1]!==r?(o=s(i=>{c({shardKey:r,traceId:i}),m(a({to:"/traces"}))},"e"),t[0]=a,t[1]=r,t[2]=o):o=t[2],o},"u");export{h as a};
|