@lunora/studio 1.0.0-alpha.350 → 1.0.0-alpha.351
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.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.mjs +1 -1
- package/dist/mount.mjs +1 -1
- package/dist/packem_chunks/AdvisorHealthPanel.mjs +1 -1
- package/dist/packem_chunks/ApiTab.mjs +1 -1
- package/dist/packem_chunks/AuditPanel.mjs +1 -1
- package/dist/packem_chunks/ExportImportPanel.mjs +8 -8
- package/dist/packem_chunks/FileBrowser.mjs +1 -1
- package/dist/packem_chunks/FunctionRunner.mjs +1 -1
- package/dist/packem_chunks/FunctionStatsPanel.mjs +1 -1
- package/dist/packem_chunks/HealthPanel.mjs +1 -1
- package/dist/packem_chunks/InsightsPanel.mjs +1 -1
- package/dist/packem_chunks/LogsPanel.mjs +1 -1
- package/dist/packem_chunks/MailPanel.mjs +1 -1
- package/dist/packem_chunks/MetricsPanel.mjs +1 -1
- package/dist/packem_chunks/NotificationsPanel.mjs +1 -1
- package/dist/packem_chunks/PitrPanel.mjs +1 -1
- package/dist/packem_chunks/SchemaViewer.mjs +1 -1
- package/dist/packem_chunks/SecurityAdvisorPanel.mjs +1 -1
- package/dist/packem_chunks/SettingsPanel.mjs +1 -1
- package/dist/packem_chunks/SqlEditorPanel.mjs +1 -1
- package/dist/packem_chunks/TableEditor.mjs +1 -1
- package/dist/packem_chunks/agents-panel.mjs +1 -1
- package/dist/packem_chunks/ai-usage-panel.mjs +1 -1
- package/dist/packem_chunks/auth-audit-panel.mjs +1 -1
- package/dist/packem_chunks/containers-panel.mjs +1 -1
- package/dist/packem_chunks/dashboards-panel.mjs +1 -1
- package/dist/packem_chunks/evals-panel.mjs +1 -1
- package/dist/packem_chunks/fanout-panel.mjs +1 -1
- package/dist/packem_chunks/flags-panel.mjs +1 -1
- package/dist/packem_chunks/issues-panel.mjs +1 -1
- package/dist/packem_chunks/kv-browser.mjs +1 -1
- package/dist/packem_chunks/migrations-route.mjs +1 -1
- package/dist/packem_chunks/payments-panel.mjs +1 -1
- package/dist/packem_chunks/permissions-panel.mjs +1 -1
- package/dist/packem_chunks/queues-panel.mjs +1 -1
- package/dist/packem_chunks/reactors-panel.mjs +1 -1
- package/dist/packem_chunks/rls-panel.mjs +1 -1
- package/dist/packem_chunks/storage-rules-panel.mjs +1 -1
- package/dist/packem_chunks/subscriptions-panel.mjs +1 -1
- package/dist/packem_chunks/traces-panel.mjs +1 -1
- package/dist/packem_chunks/workflows-panel.mjs +1 -1
- package/dist/packem_shared/{ADMIN_FUNCTIONS-B8yyk5BX.mjs → ADMIN_FUNCTIONS-4aGsMs95.mjs} +1 -1
- package/dist/packem_shared/{ApiDocsPanel-B_RaW7Br.mjs → ApiDocsPanel-E4Vr-8zW.mjs} +1 -1
- package/dist/packem_shared/{DataBrowser-Cc1qZX-4.mjs → DataBrowser-C5HbI4TH.mjs} +1 -1
- package/dist/packem_shared/{GlobalDataBrowser-Hq6gTlkb.mjs → GlobalDataBrowser-D0H2yJSl.mjs} +1 -1
- package/dist/packem_shared/{HomePanel-DeyYLVxc.mjs → HomePanel-CcYkDlR-.mjs} +1 -1
- package/dist/packem_shared/{MigrationsPanel-CMZYYcQ5.mjs → MigrationsPanel-YyCO_T-3.mjs} +1 -1
- package/dist/packem_shared/{Studio-BhTqTeGb.mjs → Studio-4vJzwwNa.mjs} +1 -1
- package/dist/packem_shared/{StudioApp-B1d0beD4.mjs → StudioApp-px2FMPDS.mjs} +1 -1
- package/dist/packem_shared/{home-panel-0XMGe1hP.mjs → home-panel-DPiMVQZ2.mjs} +1 -1
- package/dist/packem_shared/{studio-CA3ZKwVK.mjs → studio-DIUgH7k0.mjs} +1 -1
- package/dist/packem_shared/{table-list-sidebar-nA7g7uSk.mjs → table-list-sidebar-CCRB_iYz.mjs} +1 -1
- package/dist/packem_shared/{use-sql-assistant-DXnqbBs-.mjs → use-sql-assistant-BMVlguKF.mjs} +1 -1
- package/dist/standalone/{chunk-WQGT24W6.js → chunk-22O2JDWR.js} +1 -1
- package/dist/standalone/{chunk-RXVXXRYD.js → chunk-2DV455PX.js} +1 -1
- package/dist/standalone/{chunk-B7MHW3A5.js → chunk-2EMNPL3B.js} +1 -1
- package/dist/standalone/{chunk-LOV52GLG.js → chunk-35BGGOWV.js} +1 -1
- package/dist/standalone/{chunk-BTRYFPZH.js → chunk-3MQ477EE.js} +1 -1
- package/dist/standalone/{chunk-XWEDIIIT.js → chunk-453GHHZ4.js} +1 -1
- package/dist/standalone/{chunk-QAQVT4FS.js → chunk-4CITH2NU.js} +1 -1
- package/dist/standalone/{chunk-E32FS6PE.js → chunk-4EDOPHLM.js} +1 -1
- package/dist/standalone/{chunk-EDGOSJXL.js → chunk-4QRVJDM4.js} +1 -1
- package/dist/standalone/{chunk-B3AXFXAD.js → chunk-4UWYDYM5.js} +1 -1
- package/dist/standalone/{chunk-SXD6JQXF.js → chunk-57ZNR6IA.js} +1 -1
- package/dist/standalone/{chunk-R3KLR5EP.js → chunk-6DYXTEU7.js} +1 -1
- package/dist/standalone/chunk-6GPEHYCG.js +1 -0
- package/dist/standalone/{chunk-E3VSRIQU.js → chunk-6GRI2HXU.js} +1 -1
- package/dist/standalone/{chunk-7F3S5OQT.js → chunk-6QBK3Z7A.js} +1 -1
- package/dist/standalone/{chunk-4ZEL6BYL.js → chunk-6UTZXEW3.js} +1 -1
- package/dist/standalone/{chunk-CGZVMM3P.js → chunk-7EAHHRJR.js} +1 -1
- package/dist/standalone/{chunk-HOPAJ5F6.js → chunk-ACNWZIAH.js} +1 -1
- package/dist/standalone/{chunk-5J32EGHF.js → chunk-ANACHJRU.js} +1 -1
- package/dist/standalone/chunk-BAGJYLSU.js +8 -0
- package/dist/standalone/{chunk-HLAAOW33.js → chunk-BCOOULSO.js} +1 -1
- package/dist/standalone/{chunk-ZMQ6PKLN.js → chunk-BKH2NALB.js} +1 -1
- package/dist/standalone/{chunk-ZBFWT34B.js → chunk-BTOOJXUL.js} +1 -1
- package/dist/standalone/{chunk-2EL4EMYZ.js → chunk-C6FNBKCO.js} +1 -1
- package/dist/standalone/{chunk-OECMBE6Q.js → chunk-DSTNWB4N.js} +1 -1
- package/dist/standalone/{chunk-WIET27J3.js → chunk-DTW4E5AB.js} +1 -1
- package/dist/standalone/{chunk-VB6YJKPA.js → chunk-FNWRS4VQ.js} +1 -1
- package/dist/standalone/{chunk-UTX6IBA3.js → chunk-FST24UXA.js} +1 -1
- package/dist/standalone/{chunk-ZTOXQK4V.js → chunk-FXGYX2V6.js} +1 -1
- package/dist/standalone/{chunk-MFNO5BFR.js → chunk-HWTX54JM.js} +1 -1
- package/dist/standalone/{chunk-26OKWFLO.js → chunk-HZCLLEWP.js} +1 -1
- package/dist/standalone/{chunk-7AZYREIY.js → chunk-IRCUXARN.js} +1 -1
- package/dist/standalone/{chunk-W7Z35E2E.js → chunk-IVQKQBKK.js} +1 -1
- package/dist/standalone/{chunk-W2XSKODB.js → chunk-K7FZTYAY.js} +1 -1
- package/dist/standalone/{chunk-5NZWQEEJ.js → chunk-KNX3KB7E.js} +1 -1
- package/dist/standalone/{chunk-MMJTKSHL.js → chunk-LYHEBMM6.js} +1 -1
- package/dist/standalone/{chunk-BVKQA5OL.js → chunk-M2RIGPGL.js} +1 -1
- package/dist/standalone/{chunk-EOR73TZZ.js → chunk-MKVZXGJQ.js} +1 -1
- package/dist/standalone/chunk-OIDFWEJX.js +21 -0
- package/dist/standalone/{chunk-CLINNLLE.js → chunk-OJG65AG4.js} +1 -1
- package/dist/standalone/{chunk-XMEVNOCA.js → chunk-Q4N3TJPV.js} +1 -1
- package/dist/standalone/{chunk-NVHHB5EV.js → chunk-QEVFVWGC.js} +1 -1
- package/dist/standalone/{chunk-JAHK7RRJ.js → chunk-RHOQJNDW.js} +1 -1
- package/dist/standalone/{chunk-7MN724WR.js → chunk-RQDSPVVH.js} +1 -1
- package/dist/standalone/{chunk-P5GAJKDW.js → chunk-S5S2YICJ.js} +1 -1
- package/dist/standalone/{chunk-ZZAJHNZ6.js → chunk-S6JFSLBK.js} +1 -1
- package/dist/standalone/{chunk-GMW2DYFU.js → chunk-SDTHCM5H.js} +1 -1
- package/dist/standalone/{chunk-JG2C7SS2.js → chunk-SM2IQWCJ.js} +1 -1
- package/dist/standalone/{chunk-GPOSJNMV.js → chunk-T2QAOXUO.js} +1 -1
- package/dist/standalone/{chunk-2WNL74MI.js → chunk-T4VAXHRL.js} +1 -1
- package/dist/standalone/{chunk-FPIUVV7Q.js → chunk-TBDJVYCB.js} +1 -1
- package/dist/standalone/{chunk-HFYFYNSX.js → chunk-TTD7BKB6.js} +1 -1
- package/dist/standalone/{chunk-KFNDET5D.js → chunk-UCK6ITED.js} +1 -1
- package/dist/standalone/{chunk-UZIBQZ2F.js → chunk-UKKZJRJT.js} +1 -1
- package/dist/standalone/{chunk-F5LTDUMB.js → chunk-V74BXQXC.js} +1 -1
- package/dist/standalone/{chunk-2ZO7XY3Z.js → chunk-VHMA6YPT.js} +1 -1
- package/dist/standalone/{chunk-SOO2HXV6.js → chunk-W4X4J7BU.js} +1 -1
- package/dist/standalone/{chunk-S7XAAH7U.js → chunk-W6ZKEW5M.js} +1 -1
- package/dist/standalone/{chunk-D7JK65OK.js → chunk-WIYDA4XT.js} +1 -1
- package/dist/standalone/{chunk-2X6O33OX.js → chunk-X7GSROPX.js} +1 -1
- package/dist/standalone/{chunk-O3FDK56W.js → chunk-Y7SN6CTX.js} +1 -1
- package/dist/standalone/{chunk-JGMQQ3S7.js → chunk-YRQHFMEY.js} +1 -1
- package/dist/standalone/{chunk-YJ2WHOGO.js → chunk-ZKPRORLI.js} +1 -1
- package/dist/standalone/{chunk-TWMS2TMF.js → chunk-ZLSNET6H.js} +1 -1
- package/dist/standalone/{chunk-CIVMATZK.js → chunk-ZM4K2ETZ.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +5 -5
- package/dist/standalone/chunk-BHOLL76W.js +0 -8
- package/dist/standalone/chunk-GQYA5W5T.js +0 -1
- package/dist/standalone/chunk-U76DVXTR.js +0 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as we}from"react/compiler-runtime";import{ShardInput as Ze}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{S as Ke,T as Pe}from"../packem_shared/storage-tier-C2mKwYRj.mjs";import{B as Fe}from"../packem_shared/badge-r_5B4LHP.mjs";import{c as Ge,d as ze,b as Be,a as De,C as je}from"../packem_shared/card-By2O8ULa.mjs";import{E as et}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ke}from"../packem_shared/input-CXhxesPC.mjs";import{useT as Oe}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{c as Le,d as Ae,b as $e,f as Ce}from"../packem_shared/internal-BXEjuLPN.mjs";import{c as Qe}from"../packem_shared/utils-bhneXptQ.mjs";import{useState as _,useRef as Ue,useEffect as qe}from"react";import{u as tt}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{u as lt}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{ADMIN_FUNCTIONS as Me}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{r as st}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{S as at}from"../packem_shared/schema-diagram-k7cFl7Wp.mjs";import{useNavigate as nt}from"@tanstack/react-router";import{B as ye}from"../packem_shared/button-q0UYSmrn.mjs";import{L as Ee}from"../packem_shared/label-DKFzyHq6.mjs";import{jsx as l,jsxs as p,Fragment as Ve}from"react/jsx-runtime";const ot=Le(Me.listTables),it=Le(Me.listTableIndexes),rt=Le(Me.readTablePage),dt=Le(Me.describeTables),ct={},Ye=[],mt=n=>{const e=we(74),{initialShardKey:m,initialTable:a}=n,t=lt(),[s,c]=_("graph"),{queryShardKey:d,setShardKey:r,shardKey:g}=tt(m),[o,u]=_(""),[i,v]=_(null),[f,O]=_(null);let S;e[0]===Symbol.for("react.memo_cache_sentinel")?(S={},e[0]=S):S=e[0];const[G,y]=_(S);let L;e[1]===Symbol.for("react.memo_cache_sentinel")?(L={},e[1]=L):L=e[1];const[$,z]=_(L),[T,C]=_(null);let A;e[2]===Symbol.for("react.memo_cache_sentinel")?(A={},e[2]=A):A=e[2];const[F,pe]=_(A);let te;e[3]===Symbol.for("react.memo_cache_sentinel")?(te={},e[3]=te):te=e[3];const[E,M]=_(te),[w,ge]=_(null),[B,ce]=_(null);let le;e[4]===Symbol.for("react.memo_cache_sentinel")?(le={},e[4]=le):le=e[4];const[J,Ne]=_(le),[W,me]=_(null),be=Ue(0);let D;e[5]!==t?(D=async h=>{be.current=be.current+1;const x=be.current;O(null);try{const N=await t.query(ot,{},Ae(h));if(x!==be.current)return;st(h),v(N),y({}),z({}),C(null),pe(k=>Object.fromEntries(Object.entries(k).filter(I=>{const[he]=I;return he!==h}))),M(k=>Object.fromEntries(Object.entries(k).filter(I=>{const[he]=I;return he!==h})))}catch(N){const k=N;if(x!==be.current)return;v(null),O($e(k))}},e[5]=t,e[6]=D):D=e[6];const j=D;let se;e[7]!==t?(se=async()=>{ce(null);try{ge(await t.listGlobalTables())}catch(h){const x=h;ge(null),ce($e(x))}},e[7]=t,e[8]=se):se=e[8];const ue=se;let R,ae;e[9]!==d||e[10]!==j||e[11]!==ue?(R=()=>{Ce(j(d)),Ce(ue())},ae=[j,ue,d],e[9]=d,e[10]=j,e[11]=ue,e[12]=R,e[13]=ae):(R=e[12],ae=e[13]),qe(R,ae);let K;e[14]!==t||e[15]!==G||e[16]!==T||e[17]!==d?(K=async h=>{if(T===h){C(null);return}C(h);const x=`${d}:${h}`;if(G[x]!==void 0)return;const[N,k]=await Promise.allSettled([t.query(rt,{limit:1,offset:0,table:h},Ae(d)),t.query(it,{table:h},Ae(d))]);N.status==="fulfilled"?y(I=>({...I,[x]:N.value.columns})):O($e(N.reason)),k.status==="fulfilled"&&z(I=>({...I,[x]:k.value.indexes}))},e[14]=t,e[15]=G,e[16]=T,e[17]=d,e[18]=K):K=e[18];const ne=K;let oe;e[19]!==t||e[20]!==J||e[21]!==W?(oe=async h=>{if(W===h){me(null);return}if(me(h),J[h]===void 0)try{const x=await t.readGlobalTablePage({limit:1,offset:0,table:h});Ne(N=>({...N,[h]:x.columns}))}catch(x){ce($e(x))}},e[19]=t,e[20]=J,e[21]=W,e[22]=oe):oe=e[22];const fe=oe,X=Ue(void 0);let Q,U;e[23]!==a||e[24]!==i||e[25]!==ne?(Q=()=>{a===void 0||i===null||X.current===a||i.some(h=>h.name===a)&&(X.current=a,Ce(ne(a)))},U=[a,i,ne],e[23]=a,e[24]=i,e[25]=ne,e[26]=Q,e[27]=U):(Q=e[26],U=e[27]),qe(Q,U);let ie;e[28]!==t?(ie=async(h,x,N)=>{const[k,I]=await Promise.all([Promise.allSettled([t.query(dt,{tables:[...x,...N]},Ae(h))]),Promise.all(N.map(async H=>{const Se=await Promise.allSettled([t.readGlobalTablePage({limit:1,offset:0,table:H})]),Re=Se[0].status==="fulfilled"?Se[0].value:void 0;return{columns:Re?.columns??[],refs:Re?.refs??{},table:H}}))]),he=k[0].status==="fulfilled"?k[0].value?.columnsByTable??{}:{},_e=k[0].status==="rejected",Ie=new Map(I.map(ut)),q=[...x,...N].map(H=>{const Se=he[H]??[];return[H,Se.length>0?Se:Ie.get(H)??[]]});pe(H=>({...H,[h]:Object.fromEntries(q)})),M(H=>({...H,[h]:_e}))},e[28]=t,e[29]=ie):ie=e[29];const V=ie;let re,Y;e[30]!==B||e[31]!==w||e[32]!==V||e[33]!==d||e[34]!==F||e[35]!==i||e[36]!==s?(re=()=>{s!=="graph"||i===null||w===null&&B===null||F[d]!==void 0||Ce(V(d,i.map(ft),(w??[]).map(ht)))},Y=[s,i,w,B,d,F,V],e[30]=B,e[31]=w,e[32]=V,e[33]=d,e[34]=F,e[35]=i,e[36]=s,e[37]=re,e[38]=Y):(re=e[37],Y=e[38]),qe(re,Y);const P=F[d]??ct;let Z;if(e[39]!==P||e[40]!==w||e[41]!==i){let h;e[43]!==P?(h=I=>({columns:P[I.name]??Ye,name:I.name,tier:"shard"}),e[43]=P,e[44]=h):h=e[44];const x=(i??[]).map(h);let N;e[45]!==P?(N=I=>({columns:P[I.name]??Ye,name:I.name,tier:"global"}),e[45]=P,e[46]=N):N=e[46];const k=(w??[]).map(N);Z=[...x,...k],e[39]=P,e[40]=w,e[41]=i,e[42]=Z}else Z=e[42];const b=Z;let ee;if(e[47]!==o||e[48]!==i){const h=o.trim().toLowerCase();ee=(i??[]).filter(x=>x.name.toLowerCase().includes(h)),e[47]=o,e[48]=i,e[49]=ee}else ee=e[49];const de=ee;let xe;if(e[50]!==w||e[51]!==o){const h=o.trim().toLowerCase();xe=(w??[]).filter(x=>x.name.toLowerCase().includes(h)),e[50]=w,e[51]=o,e[52]=xe}else xe=e[52];const Te=xe;let ve;return e[53]!==G||e[54]!==b||e[55]!==f||e[56]!==T||e[57]!==Te||e[58]!==de||e[59]!==J||e[60]!==B||e[61]!==W||e[62]!==w||e[63]!==$||e[64]!==j||e[65]!==r||e[66]!==E||e[67]!==g||e[68]!==o||e[69]!==i||e[70]!==ne||e[71]!==fe||e[72]!==s?(ve={columns:G,diagramTables:b,error:f,expanded:T,filteredGlobalTables:Te,filteredTables:de,globalColumns:J,globalError:B,globalExpanded:W,globalTables:w,indexes:$,refresh:j,setShardKey:r,setTableFilter:u,setView:c,shardColumnsError:E,shardKey:g,tableFilter:o,tables:i,toggle:ne,toggleGlobal:fe,view:s},e[53]=G,e[54]=b,e[55]=f,e[56]=T,e[57]=Te,e[58]=de,e[59]=J,e[60]=B,e[61]=W,e[62]=w,e[63]=$,e[64]=j,e[65]=r,e[66]=E,e[67]=g,e[68]=o,e[69]=i,e[70]=ne,e[71]=fe,e[72]=s,e[73]=ve):ve=e[73],ve};function ut(n){const{columns:e,refs:m,table:a}=n;return[a,e.map(t=>{const s=m[t];return s===void 0?{name:t,optional:!1,type:""}:{name:t,optional:!1,ref:s,type:"id"}})]}function ft(n){return n.name}function ht(n){return n.name}const pt="/__lunora/schema-edit",gt=async n=>{const e=await fetch(pt,{body:JSON.stringify(n),headers:{"Content-Type":"application/json"},method:"POST"}),m=await e.json();return m.needsMigration===!0?{kind:"needs-migration",message:m.message??"This edit needs a migration."}:e.ok&&m.tables!==void 0?{diagnostics:m.diagnostics??[],kind:"ok",tables:m.tables}:{kind:"error",message:m.error??`schema edit failed (${String(e.status)})`}},bt=n=>{const e=we(32),{hasTables:m,mode:a,onAddColumn:t,onAddIndex:s,onAddTable:c,onDestructive:d}=n,r=Oe(),g=a==="addTable"?"default":"outline";let o;e[0]!==r?(o=r("Add table"),e[0]=r,e[1]=o):o=e[1];let u;e[2]!==c||e[3]!==g||e[4]!==o?(u=l(ye,{"data-testid":"sc-editor-add-table",onClick:c,size:"xs",type:"button",variant:g,children:o}),e[2]=c,e[3]=g,e[4]=o,e[5]=u):u=e[5];const i=!m,v=a==="addColumn"?"default":"outline";let f;e[6]!==r?(f=r("Add column"),e[6]=r,e[7]=f):f=e[7];let O;e[8]!==t||e[9]!==i||e[10]!==v||e[11]!==f?(O=l(ye,{"data-testid":"sc-editor-add-column",disabled:i,onClick:t,size:"xs",type:"button",variant:v,children:f}),e[8]=t,e[9]=i,e[10]=v,e[11]=f,e[12]=O):O=e[12];const S=!m,G=a==="addIndex"?"default":"outline";let y;e[13]!==r?(y=r("Add index"),e[13]=r,e[14]=y):y=e[14];let L;e[15]!==s||e[16]!==y||e[17]!==S||e[18]!==G?(L=l(ye,{"data-testid":"sc-editor-add-index",disabled:S,onClick:s,size:"xs",type:"button",variant:G,children:y}),e[15]=s,e[16]=y,e[17]=S,e[18]=G,e[19]=L):L=e[19];const $=!m,z=a==="destructive"?"default":"ghost";let T;e[20]!==r?(T=r("Rename / drop / change type…"),e[20]=r,e[21]=T):T=e[21];let C;e[22]!==d||e[23]!==$||e[24]!==z||e[25]!==T?(C=l(ye,{"data-testid":"sc-editor-destructive",disabled:$,onClick:d,size:"xs",type:"button",variant:z,children:T}),e[22]=d,e[23]=$,e[24]=z,e[25]=T,e[26]=C):C=e[26];let A;return e[27]!==L||e[28]!==C||e[29]!==u||e[30]!==O?(A=p("div",{className:"flex flex-wrap gap-2",children:[u,O,L,C]}),e[27]=L,e[28]=C,e[29]=u,e[30]=O,e[31]=A):A=e[31],A},xt=n=>{const e=we(28),{onOpenMigrations:m,result:a}=n,t=Oe();if(a===null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=l(Ve,{}),e[0]=o):o=e[0],o}if(a.kind==="error"){let o;return e[1]!==a.message?(o=l("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:a.message}),e[1]=a.message,e[2]=o):o=e[2],o}if(a.kind==="needs-migration"){let o;e[3]!==a.message||e[4]!==t?(o=a.message===""?t("This edit changes stored data and must go through a migration. Review the migration before applying."):a.message,e[3]=a.message,e[4]=t,e[5]=o):o=e[5];let u;e[6]!==o?(u=l("p",{className:"text-sm text-warning",role:"alert",children:o}),e[6]=o,e[7]=u):u=e[7];let i;e[8]!==t?(i=t("Open Migrations"),e[8]=t,e[9]=i):i=e[9];let v;e[10]!==m||e[11]!==i?(v=l(ye,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:m,size:"xs",type:"button",variant:"outline",children:i}),e[10]=m,e[11]=i,e[12]=v):v=e[12];let f;return e[13]!==u||e[14]!==v?(f=p("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[u,v]}),e[13]=u,e[14]=v,e[15]=f):f=e[15],f}if(a.diagnostics.length===0){let o;return e[16]===Symbol.for("react.memo_cache_sentinel")?(o=l(Ve,{}),e[16]=o):o=e[16],o}let s;e[17]!==t?(s=t("Codegen reported diagnostics:"),e[17]=t,e[18]=s):s=e[18];let c;e[19]!==s?(c=l("p",{className:"text-sm text-destructive",role:"alert",children:s}),e[19]=s,e[20]=c):c=e[20];let d;e[21]!==a.diagnostics?(d=a.diagnostics.map(vt),e[21]=a.diagnostics,e[22]=d):d=e[22];let r;e[23]!==d?(r=l("ul",{className:"flex flex-col gap-0.5",children:d}),e[23]=d,e[24]=r):r=e[24];let g;return e[25]!==c||e[26]!==r?(g=p("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[c,r]}),e[25]=c,e[26]=r,e[27]=g):g=e[27],g};function vt(n){return l("li",{className:"font-mono text-[11px] text-destructive",children:n},n)}const yt=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.bigint()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],Ct="v.string()",Nt=n=>n.split(",").map(e=>e.trim()).filter(e=>e!==""),Tt=n=>{const e=we(83),{onApplied:m,tableNames:a}=n,t=Oe(),s=nt(),[c,d]=_(null),[r,g]=_(!1),[o,u]=_(null),[i,v]=_(""),[f,O]=_(""),[S,G]=_(Ct),[y,L]=_(a[0]??""),[$,z]=_(""),[T,C]=_(""),[A,F]=_(!1);let pe;e[0]===Symbol.for("react.memo_cache_sentinel")?(pe=()=>{d(null),v(""),O(""),z(""),C(""),F(!1)},e[0]=pe):pe=e[0];const te=pe;let E;e[1]!==m?(E=async q=>{g(!0),u(null);try{const H=await gt(q);u(H),H.kind==="ok"&&(m(H.tables),te())}catch(H){const Se=H;u({kind:"error",message:Se instanceof Error?Se.message:String(Se)})}g(!1)},e[1]=m,e[2]=E):E=e[2];const M=E;let w;e[3]!==M||e[4]!==i?(w=()=>{Ce(M({kind:"addTable",table:i.trim()}))},e[3]=M,e[4]=i,e[5]=w):w=e[5];const ge=w;let B;e[6]!==f||e[7]!==M||e[8]!==y||e[9]!==S?(B=()=>{Ce(M({column:f.trim(),kind:"addOptionalColumn",table:y,validator:S}))},e[6]=f,e[7]=M,e[8]=y,e[9]=S,e[10]=B):B=e[10];const ce=B;let le;e[11]!==T||e[12]!==$||e[13]!==M||e[14]!==y||e[15]!==A?(le=()=>{Ce(M({fields:Nt(T),kind:"addIndex",name:$.trim(),table:y,unique:A}))},e[11]=T,e[12]=$,e[13]=M,e[14]=y,e[15]=A,e[16]=le):le=e[16];const J=le;let Ne;e[17]===Symbol.for("react.memo_cache_sentinel")?(Ne=()=>{u(null),d("addTable")},e[17]=Ne):Ne=e[17];const W=Ne;let me;e[18]===Symbol.for("react.memo_cache_sentinel")?(me=()=>{u(null),d("addColumn")},e[18]=me):me=e[18];const be=me;let D;e[19]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{u(null),d("addIndex")},e[19]=D):D=e[19];const j=D;let se;e[20]!==t?(se=()=>{d("destructive"),u({kind:"needs-migration",message:t("This edit changes stored data and must go through a migration. Review the migration before applying.")})},e[20]=t,e[21]=se):se=e[21];const ue=se;let R;e[22]===Symbol.for("react.memo_cache_sentinel")?(R=q=>{v(q.target.value)},e[22]=R):R=e[22];const ae=R;let K;e[23]===Symbol.for("react.memo_cache_sentinel")?(K=q=>{O(q.target.value)},e[23]=K):K=e[23];const ne=K;let oe;e[24]===Symbol.for("react.memo_cache_sentinel")?(oe=q=>{G(q.target.value)},e[24]=oe):oe=e[24];const fe=oe;let X;e[25]===Symbol.for("react.memo_cache_sentinel")?(X=q=>{L(q.target.value)},e[25]=X):X=e[25];const Q=X;let U;e[26]===Symbol.for("react.memo_cache_sentinel")?(U=q=>{z(q.target.value)},e[26]=U):U=e[26];const ie=U;let V;e[27]===Symbol.for("react.memo_cache_sentinel")?(V=q=>{C(q.target.value)},e[27]=V):V=e[27];const re=V;let Y;e[28]===Symbol.for("react.memo_cache_sentinel")?(Y=q=>{F(q.target.checked)},e[28]=Y):Y=e[28];const P=Y;let Z;e[29]!==s?(Z=()=>{Ce(s({to:"/migrations"}))},e[29]=s,e[30]=Z):Z=e[30];const b=Z;let ee;e[31]!==t?(ee=t("Edit schema"),e[31]=t,e[32]=ee):ee=e[32];let de;e[33]!==ee?(de=l(Ge,{children:ee}),e[33]=ee,e[34]=de):de=e[34];let xe;e[35]!==t?(xe=t("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=t,e[36]=xe):xe=e[36];let Te;e[37]!==xe?(Te=l(ze,{children:xe}),e[37]=xe,e[38]=Te):Te=e[38];let ve;e[39]!==de||e[40]!==Te?(ve=p(Be,{children:[de,Te]}),e[39]=de,e[40]=Te,e[41]=ve):ve=e[41];const h=a.length>0;let x;e[42]!==c||e[43]!==ue||e[44]!==h?(x=l(bt,{hasTables:h,mode:c,onAddColumn:be,onAddIndex:j,onAddTable:W,onDestructive:ue}),e[42]=c,e[43]=ue,e[44]=h,e[45]=x):x=e[45];let N;e[46]!==r||e[47]!==c||e[48]!==ge||e[49]!==t||e[50]!==i?(N=c==="addTable"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-table-name",children:t("Table name")}),l(ke,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:ae,value:i})]}),l(ye,{"data-testid":"sc-editor-table-apply",disabled:r||i.trim()==="",onClick:ge,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ye,{onClick:te,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[46]=r,e[47]=c,e[48]=ge,e[49]=t,e[50]=i,e[51]=N):N=e[51];let k;e[52]!==r||e[53]!==f||e[54]!==c||e[55]!==ce||e[56]!==t||e[57]!==a||e[58]!==y||e[59]!==S?(k=c==="addColumn"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-column-table",children:t("Table name")}),l("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:Q,value:y,children:a.map(St)})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-column-name",children:t("Column name")}),l(ke,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:ne,value:f})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-column-type",children:t("Column type")}),l("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:fe,value:S,children:yt.map(wt)})]}),l("span",{className:"text-[11px] text-muted-foreground",children:t("Optional")}),l(ye,{"data-testid":"sc-editor-column-apply",disabled:r||f.trim()===""||y==="",onClick:ce,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ye,{onClick:te,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[52]=r,e[53]=f,e[54]=c,e[55]=ce,e[56]=t,e[57]=a,e[58]=y,e[59]=S,e[60]=k):k=e[60];let I;e[61]!==r||e[62]!==T||e[63]!==$||e[64]!==c||e[65]!==J||e[66]!==t||e[67]!==a||e[68]!==y||e[69]!==A?(I=c==="addIndex"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-index-table",children:t("Table name")}),l("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:Q,value:y,children:a.map(_t)})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-index-name",children:t("Index name")}),l(ke,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:ie,value:$})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-index-fields",children:t("Index fields (comma-separated)")}),l(ke,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:re,value:T})]}),p(Ee,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[l("input",{checked:A,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:P,type:"checkbox"}),l("span",{className:"text-muted-foreground",children:t("Unique")})]}),l(ye,{"data-testid":"sc-editor-index-apply",disabled:r||$.trim()===""||T.trim()==="",onClick:J,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ye,{onClick:te,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[61]=r,e[62]=T,e[63]=$,e[64]=c,e[65]=J,e[66]=t,e[67]=a,e[68]=y,e[69]=A,e[70]=I):I=e[70];let he;e[71]!==b||e[72]!==o?(he=l(xt,{onOpenMigrations:b,result:o}),e[71]=b,e[72]=o,e[73]=he):he=e[73];let _e;e[74]!==x||e[75]!==N||e[76]!==k||e[77]!==I||e[78]!==he?(_e=p(De,{children:[x,N,k,I,he]}),e[74]=x,e[75]=N,e[76]=k,e[77]=I,e[78]=he,e[79]=_e):_e=e[79];let Ie;return e[80]!==ve||e[81]!==_e?(Ie=p(je,{"data-testid":"sc-editor",size:"sm",children:[ve,_e]}),e[80]=ve,e[81]=_e,e[82]=Ie):Ie=e[82],Ie};function St(n){return l("option",{value:n,children:n},n)}function wt(n){return l("option",{value:n.validator,children:n.label},n.validator)}function _t(n){return l("option",{value:n,children:n},n)}const He=[],Et=n=>{const e=we(5),{open:m}=n,a=m&&"rotate-90";let t;e[0]!==a?(t=Qe("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",a),e[0]=a,e[1]=t):t=e[1];let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=l("path",{d:"m9 6 6 6-6 6"}),e[2]=s):s=e[2];let c;return e[3]!==t?(c=l("svg",{"aria-hidden":"true",className:t,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:s}),e[3]=t,e[4]=c):c=e[4],c},Je=n=>{const e=we(20),{children:m,expanded:a,name:t,onToggle:s,rowCount:c,rowTestId:d,toggleTestId:r}=n;let g;e[0]!==a?(g=l(Et,{open:a}),e[0]=a,e[1]=g):g=e[1];let o;e[2]!==t?(o=l("span",{className:"truncate font-mono text-xs text-foreground",title:t,children:t}),e[2]=t,e[3]=o):o=e[3];let u;e[4]!==c?(u=p("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",c,")"]}),e[4]=c,e[5]=u):u=e[5];let i;e[6]!==a||e[7]!==s||e[8]!==g||e[9]!==o||e[10]!==u||e[11]!==r?(i=p("button",{"aria-expanded":a,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":r,onClick:s,type:"button",children:[g,o," ",u]}),e[6]=a,e[7]=s,e[8]=g,e[9]=o,e[10]=u,e[11]=r,e[12]=i):i=e[12];let v;e[13]!==m||e[14]!==a?(v=a&&l("div",{className:"px-3 pb-3 ps-8",children:m}),e[13]=m,e[14]=a,e[15]=v):v=e[15];let f;return e[16]!==d||e[17]!==i||e[18]!==v?(f=p("li",{className:"border-t border-border/60 first:border-t-0","data-testid":d,children:[i,v]}),e[16]=d,e[17]=i,e[18]=v,e[19]=f):f=e[19],f},We=n=>{const e=we(5),{columns:m,testId:a}=n;let t;e[0]!==m?(t=m.map(kt),e[0]=m,e[1]=t):t=e[1];let s;return e[2]!==t||e[3]!==a?(s=l("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":a,children:t}),e[2]=t,e[3]=a,e[4]=s):s=e[4],s},It=n=>{const e=we(10),{heading:m,indexes:a,testId:t}=n;let s;e[0]!==m?(s=l("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:m}),e[0]=m,e[1]=s):s=e[1];let c;e[2]!==a?(c=a.map(At),e[2]=a,e[3]=c):c=e[3];let d;e[4]!==c||e[5]!==t?(d=l("ul",{className:"flex flex-col gap-1","data-testid":t,children:c}),e[4]=c,e[5]=t,e[6]=d):d=e[6];let r;return e[7]!==s||e[8]!==d?(r=p("div",{className:"pt-3",children:[s,d]}),e[7]=s,e[8]=d,e[9]=r):r=e[9],r},Xe=n=>Qe("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",n?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),Qt=n=>{const e=we(85),{initialShardKey:m,initialTable:a,schemaEditable:t}=n,s=Oe();let c;e[0]!==m||e[1]!==a?(c={initialShardKey:m,initialTable:a},e[0]=m,e[1]=a,e[2]=c):c=e[2];const{columns:d,diagramTables:r,error:g,expanded:o,filteredGlobalTables:u,filteredTables:i,globalColumns:v,globalError:f,globalExpanded:O,globalTables:S,indexes:G,refresh:y,setShardKey:L,setTableFilter:$,setView:z,shardColumnsError:T,shardKey:C,tableFilter:A,tables:F,toggle:pe,toggleGlobal:te,view:E}=mt(c);let M;e[3]!==z?(M=()=>{z("list")},e[3]=z,e[4]=M):M=e[4];const w=M;let ge;e[5]!==z?(ge=()=>{z("graph")},e[5]=z,e[6]=ge):ge=e[6];const B=ge;let ce;e[7]!==$?(ce=b=>{$(b.target.value)},e[7]=$,e[8]=ce):ce=e[8];const le=ce;let J;e[9]!==y||e[10]!==C?(J=b=>{Ce(y(C))},e[9]=y,e[10]=C,e[11]=J):J=e[11];const Ne=J;let W;e[12]!==F?(W=F??[],e[12]=F,e[13]=W):W=e[13];let me;e[14]!==W?(me=W.map($t),e[14]=W,e[15]=me):me=e[15];const be=me;let D;e[16]!==L||e[17]!==C?(D=l(Ze,{onChange:L,testId:"sc-shard-input",value:C}),e[16]=L,e[17]=C,e[18]=D):D=e[18];let j;e[19]!==s?(j=s("Schema view"),e[19]=s,e[20]=j):j=e[20];const se=E==="graph",ue=E==="graph";let R;e[21]!==ue?(R=Xe(ue),e[21]=ue,e[22]=R):R=e[22];let ae;e[23]!==s?(ae=s("Graph"),e[23]=s,e[24]=ae):ae=e[24];let K;e[25]!==B||e[26]!==se||e[27]!==R||e[28]!==ae?(K=l("button",{"aria-selected":se,className:R,"data-testid":"sc-view-graph",onClick:B,role:"tab",type:"button",children:ae}),e[25]=B,e[26]=se,e[27]=R,e[28]=ae,e[29]=K):K=e[29];const ne=E==="list",oe=E==="list";let fe;e[30]!==oe?(fe=Xe(oe),e[30]=oe,e[31]=fe):fe=e[31];let X;e[32]!==s?(X=s("Table list"),e[32]=s,e[33]=X):X=e[33];let Q;e[34]!==w||e[35]!==ne||e[36]!==fe||e[37]!==X?(Q=l("button",{"aria-selected":ne,className:fe,"data-testid":"sc-view-list",onClick:w,role:"tab",type:"button",children:X}),e[34]=w,e[35]=ne,e[36]=fe,e[37]=X,e[38]=Q):Q=e[38];let U;e[39]!==K||e[40]!==Q||e[41]!==j?(U=p("div",{"aria-label":j,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[K,Q]}),e[39]=K,e[40]=Q,e[41]=j,e[42]=U):U=e[42];let ie;e[43]!==U||e[44]!==D?(ie=p("div",{className:"flex flex-wrap items-center gap-3",children:[D,U]}),e[43]=U,e[44]=D,e[45]=ie):ie=e[45];let V;e[46]!==Ne||e[47]!==t||e[48]!==be?(V=t===!0&&l(Tt,{onApplied:Ne,tableNames:be}),e[46]=Ne,e[47]=t,e[48]=be,e[49]=V):V=e[49];let re;e[50]!==le||e[51]!==s||e[52]!==A||e[53]!==E?(re=E==="list"&&l(ke,{"aria-label":s("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:le,placeholder:s("Filter tables"),value:A}),e[50]=le,e[51]=s,e[52]=A,e[53]=E,e[54]=re):re=e[54];let Y;e[55]!==r||e[56]!==g||e[57]!==f||e[58]!==T||e[59]!==C||e[60]!==E?(Y=E==="graph"&&p("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[g!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),f!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:f}),l(at,{columnsError:T[C]===!0,tables:r,testIdPrefix:"sc-graph"})]}),e[55]=r,e[56]=g,e[57]=f,e[58]=T,e[59]=C,e[60]=E,e[61]=Y):Y=e[61];let P;e[62]!==d||e[63]!==g||e[64]!==o||e[65]!==u||e[66]!==i||e[67]!==v||e[68]!==f||e[69]!==O||e[70]!==S||e[71]!==G||e[72]!==C||e[73]!==s||e[74]!==F||e[75]!==pe||e[76]!==te||e[77]!==E?(P=E==="list"&&p("div",{className:"flex flex-col gap-4",children:[p(je,{"data-testid":"sc-shard-section",size:"sm",children:[p(Be,{children:[p("div",{className:"flex items-center gap-2",children:[l(Ke,{tier:"shard"}),l(Ge,{children:s("Shard tables")}),F!==null&&l(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:i.length})]}),l(ze,{children:Pe.shard.hint})]}),p(De,{children:[g!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),F!==null&&F.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:s("No tables in this shard.")}),F!==null&&F.length>0&&i.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:s("No tables match your filter.")}),i.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:i.map(b=>{const ee=`${C}:${b.name}`,de=G[ee]??[];return p(Je,{expanded:o===b.name,name:b.name,onToggle:()=>{Ce(pe(b.name))},rowCount:b.rowCount,rowTestId:`sc-table-${b.name}`,toggleTestId:`sc-toggle-${b.name}`,children:[l(We,{columns:d[ee]??He,testId:`sc-columns-${b.name}`}),de.length>0&&l(It,{heading:s("Indexes"),indexes:de,testId:`sc-indexes-${b.name}`})]},b.name)})})]})]}),p(je,{"data-testid":"sc-global-section",size:"sm",children:[p(Be,{children:[p("div",{className:"flex items-center gap-2",children:[l(Ke,{tier:"global"}),l(Ge,{children:s("Global tables (D1)")}),S!==null&&l(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:u.length})]}),l(ze,{children:Pe.global.hint})]}),p(De,{children:[f!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:f}),S!==null&&S.length===0&&l(et,{description:Pe.global.hint,testId:"sc-global-empty",title:s("No global tables.")}),S!==null&&S.length>0&&u.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:s("No tables match your filter.")}),u.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:u.map(b=>l(Je,{expanded:O===b.name,name:b.name,onToggle:()=>{Ce(te(b.name))},rowCount:b.rowCount,rowTestId:`sc-global-table-${b.name}`,toggleTestId:`sc-global-toggle-${b.name}`,children:l(We,{columns:v[b.name]??He,testId:`sc-global-columns-${b.name}`})},b.name))})]})]})]}),e[62]=d,e[63]=g,e[64]=o,e[65]=u,e[66]=i,e[67]=v,e[68]=f,e[69]=O,e[70]=S,e[71]=G,e[72]=C,e[73]=s,e[74]=F,e[75]=pe,e[76]=te,e[77]=E,e[78]=P):P=e[78];let Z;return e[79]!==ie||e[80]!==V||e[81]!==re||e[82]!==Y||e[83]!==P?(Z=p("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[ie,V,re,Y,P]}),e[79]=ie,e[80]=V,e[81]=re,e[82]=Y,e[83]=P,e[84]=Z):Z=e[84],Z};function kt(n){return l("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:n},n)}function At(n){return p("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[l("span",{className:"font-mono",children:n.name}),l(Fe,{variant:"outline",children:n.type}),n.unique===!0&&l(Fe,{variant:"secondary",children:"unique"}),l("span",{className:"text-muted-foreground",children:n.fields.join(", ")})]},`${n.type}:${n.name}`)}function $t(n){return n.name}export{Qt as SchemaViewer};
|
|
1
|
+
import{c as we}from"react/compiler-runtime";import{ShardInput as Ze}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{S as Ke,T as Pe}from"../packem_shared/storage-tier-C2mKwYRj.mjs";import{B as Fe}from"../packem_shared/badge-r_5B4LHP.mjs";import{c as Ge,d as ze,b as Be,a as De,C as je}from"../packem_shared/card-By2O8ULa.mjs";import{E as et}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ke}from"../packem_shared/input-CXhxesPC.mjs";import{useT as Oe}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{c as Le,d as Ae,b as $e,f as Ce}from"../packem_shared/internal-BXEjuLPN.mjs";import{c as Qe}from"../packem_shared/utils-bhneXptQ.mjs";import{useState as _,useRef as Ue,useEffect as qe}from"react";import{u as tt}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{u as lt}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{ADMIN_FUNCTIONS as Me}from"../packem_shared/ADMIN_FUNCTIONS-4aGsMs95.mjs";import{r as st}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{S as at}from"../packem_shared/schema-diagram-k7cFl7Wp.mjs";import{useNavigate as nt}from"@tanstack/react-router";import{B as ye}from"../packem_shared/button-q0UYSmrn.mjs";import{L as Ee}from"../packem_shared/label-DKFzyHq6.mjs";import{jsx as l,jsxs as p,Fragment as Ve}from"react/jsx-runtime";const ot=Le(Me.listTables),it=Le(Me.listTableIndexes),rt=Le(Me.readTablePage),dt=Le(Me.describeTables),ct={},Ye=[],mt=n=>{const e=we(74),{initialShardKey:m,initialTable:a}=n,t=lt(),[s,c]=_("graph"),{queryShardKey:d,setShardKey:r,shardKey:g}=tt(m),[o,u]=_(""),[i,v]=_(null),[f,O]=_(null);let S;e[0]===Symbol.for("react.memo_cache_sentinel")?(S={},e[0]=S):S=e[0];const[G,y]=_(S);let L;e[1]===Symbol.for("react.memo_cache_sentinel")?(L={},e[1]=L):L=e[1];const[$,z]=_(L),[T,C]=_(null);let A;e[2]===Symbol.for("react.memo_cache_sentinel")?(A={},e[2]=A):A=e[2];const[F,pe]=_(A);let te;e[3]===Symbol.for("react.memo_cache_sentinel")?(te={},e[3]=te):te=e[3];const[E,M]=_(te),[w,ge]=_(null),[B,ce]=_(null);let le;e[4]===Symbol.for("react.memo_cache_sentinel")?(le={},e[4]=le):le=e[4];const[J,Ne]=_(le),[W,me]=_(null),be=Ue(0);let D;e[5]!==t?(D=async h=>{be.current=be.current+1;const x=be.current;O(null);try{const N=await t.query(ot,{},Ae(h));if(x!==be.current)return;st(h),v(N),y({}),z({}),C(null),pe(k=>Object.fromEntries(Object.entries(k).filter(I=>{const[he]=I;return he!==h}))),M(k=>Object.fromEntries(Object.entries(k).filter(I=>{const[he]=I;return he!==h})))}catch(N){const k=N;if(x!==be.current)return;v(null),O($e(k))}},e[5]=t,e[6]=D):D=e[6];const j=D;let se;e[7]!==t?(se=async()=>{ce(null);try{ge(await t.listGlobalTables())}catch(h){const x=h;ge(null),ce($e(x))}},e[7]=t,e[8]=se):se=e[8];const ue=se;let R,ae;e[9]!==d||e[10]!==j||e[11]!==ue?(R=()=>{Ce(j(d)),Ce(ue())},ae=[j,ue,d],e[9]=d,e[10]=j,e[11]=ue,e[12]=R,e[13]=ae):(R=e[12],ae=e[13]),qe(R,ae);let K;e[14]!==t||e[15]!==G||e[16]!==T||e[17]!==d?(K=async h=>{if(T===h){C(null);return}C(h);const x=`${d}:${h}`;if(G[x]!==void 0)return;const[N,k]=await Promise.allSettled([t.query(rt,{limit:1,offset:0,table:h},Ae(d)),t.query(it,{table:h},Ae(d))]);N.status==="fulfilled"?y(I=>({...I,[x]:N.value.columns})):O($e(N.reason)),k.status==="fulfilled"&&z(I=>({...I,[x]:k.value.indexes}))},e[14]=t,e[15]=G,e[16]=T,e[17]=d,e[18]=K):K=e[18];const ne=K;let oe;e[19]!==t||e[20]!==J||e[21]!==W?(oe=async h=>{if(W===h){me(null);return}if(me(h),J[h]===void 0)try{const x=await t.readGlobalTablePage({limit:1,offset:0,table:h});Ne(N=>({...N,[h]:x.columns}))}catch(x){ce($e(x))}},e[19]=t,e[20]=J,e[21]=W,e[22]=oe):oe=e[22];const fe=oe,X=Ue(void 0);let Q,U;e[23]!==a||e[24]!==i||e[25]!==ne?(Q=()=>{a===void 0||i===null||X.current===a||i.some(h=>h.name===a)&&(X.current=a,Ce(ne(a)))},U=[a,i,ne],e[23]=a,e[24]=i,e[25]=ne,e[26]=Q,e[27]=U):(Q=e[26],U=e[27]),qe(Q,U);let ie;e[28]!==t?(ie=async(h,x,N)=>{const[k,I]=await Promise.all([Promise.allSettled([t.query(dt,{tables:[...x,...N]},Ae(h))]),Promise.all(N.map(async H=>{const Se=await Promise.allSettled([t.readGlobalTablePage({limit:1,offset:0,table:H})]),Re=Se[0].status==="fulfilled"?Se[0].value:void 0;return{columns:Re?.columns??[],refs:Re?.refs??{},table:H}}))]),he=k[0].status==="fulfilled"?k[0].value?.columnsByTable??{}:{},_e=k[0].status==="rejected",Ie=new Map(I.map(ut)),q=[...x,...N].map(H=>{const Se=he[H]??[];return[H,Se.length>0?Se:Ie.get(H)??[]]});pe(H=>({...H,[h]:Object.fromEntries(q)})),M(H=>({...H,[h]:_e}))},e[28]=t,e[29]=ie):ie=e[29];const V=ie;let re,Y;e[30]!==B||e[31]!==w||e[32]!==V||e[33]!==d||e[34]!==F||e[35]!==i||e[36]!==s?(re=()=>{s!=="graph"||i===null||w===null&&B===null||F[d]!==void 0||Ce(V(d,i.map(ft),(w??[]).map(ht)))},Y=[s,i,w,B,d,F,V],e[30]=B,e[31]=w,e[32]=V,e[33]=d,e[34]=F,e[35]=i,e[36]=s,e[37]=re,e[38]=Y):(re=e[37],Y=e[38]),qe(re,Y);const P=F[d]??ct;let Z;if(e[39]!==P||e[40]!==w||e[41]!==i){let h;e[43]!==P?(h=I=>({columns:P[I.name]??Ye,name:I.name,tier:"shard"}),e[43]=P,e[44]=h):h=e[44];const x=(i??[]).map(h);let N;e[45]!==P?(N=I=>({columns:P[I.name]??Ye,name:I.name,tier:"global"}),e[45]=P,e[46]=N):N=e[46];const k=(w??[]).map(N);Z=[...x,...k],e[39]=P,e[40]=w,e[41]=i,e[42]=Z}else Z=e[42];const b=Z;let ee;if(e[47]!==o||e[48]!==i){const h=o.trim().toLowerCase();ee=(i??[]).filter(x=>x.name.toLowerCase().includes(h)),e[47]=o,e[48]=i,e[49]=ee}else ee=e[49];const de=ee;let xe;if(e[50]!==w||e[51]!==o){const h=o.trim().toLowerCase();xe=(w??[]).filter(x=>x.name.toLowerCase().includes(h)),e[50]=w,e[51]=o,e[52]=xe}else xe=e[52];const Te=xe;let ve;return e[53]!==G||e[54]!==b||e[55]!==f||e[56]!==T||e[57]!==Te||e[58]!==de||e[59]!==J||e[60]!==B||e[61]!==W||e[62]!==w||e[63]!==$||e[64]!==j||e[65]!==r||e[66]!==E||e[67]!==g||e[68]!==o||e[69]!==i||e[70]!==ne||e[71]!==fe||e[72]!==s?(ve={columns:G,diagramTables:b,error:f,expanded:T,filteredGlobalTables:Te,filteredTables:de,globalColumns:J,globalError:B,globalExpanded:W,globalTables:w,indexes:$,refresh:j,setShardKey:r,setTableFilter:u,setView:c,shardColumnsError:E,shardKey:g,tableFilter:o,tables:i,toggle:ne,toggleGlobal:fe,view:s},e[53]=G,e[54]=b,e[55]=f,e[56]=T,e[57]=Te,e[58]=de,e[59]=J,e[60]=B,e[61]=W,e[62]=w,e[63]=$,e[64]=j,e[65]=r,e[66]=E,e[67]=g,e[68]=o,e[69]=i,e[70]=ne,e[71]=fe,e[72]=s,e[73]=ve):ve=e[73],ve};function ut(n){const{columns:e,refs:m,table:a}=n;return[a,e.map(t=>{const s=m[t];return s===void 0?{name:t,optional:!1,type:""}:{name:t,optional:!1,ref:s,type:"id"}})]}function ft(n){return n.name}function ht(n){return n.name}const pt="/__lunora/schema-edit",gt=async n=>{const e=await fetch(pt,{body:JSON.stringify(n),headers:{"Content-Type":"application/json"},method:"POST"}),m=await e.json();return m.needsMigration===!0?{kind:"needs-migration",message:m.message??"This edit needs a migration."}:e.ok&&m.tables!==void 0?{diagnostics:m.diagnostics??[],kind:"ok",tables:m.tables}:{kind:"error",message:m.error??`schema edit failed (${String(e.status)})`}},bt=n=>{const e=we(32),{hasTables:m,mode:a,onAddColumn:t,onAddIndex:s,onAddTable:c,onDestructive:d}=n,r=Oe(),g=a==="addTable"?"default":"outline";let o;e[0]!==r?(o=r("Add table"),e[0]=r,e[1]=o):o=e[1];let u;e[2]!==c||e[3]!==g||e[4]!==o?(u=l(ye,{"data-testid":"sc-editor-add-table",onClick:c,size:"xs",type:"button",variant:g,children:o}),e[2]=c,e[3]=g,e[4]=o,e[5]=u):u=e[5];const i=!m,v=a==="addColumn"?"default":"outline";let f;e[6]!==r?(f=r("Add column"),e[6]=r,e[7]=f):f=e[7];let O;e[8]!==t||e[9]!==i||e[10]!==v||e[11]!==f?(O=l(ye,{"data-testid":"sc-editor-add-column",disabled:i,onClick:t,size:"xs",type:"button",variant:v,children:f}),e[8]=t,e[9]=i,e[10]=v,e[11]=f,e[12]=O):O=e[12];const S=!m,G=a==="addIndex"?"default":"outline";let y;e[13]!==r?(y=r("Add index"),e[13]=r,e[14]=y):y=e[14];let L;e[15]!==s||e[16]!==y||e[17]!==S||e[18]!==G?(L=l(ye,{"data-testid":"sc-editor-add-index",disabled:S,onClick:s,size:"xs",type:"button",variant:G,children:y}),e[15]=s,e[16]=y,e[17]=S,e[18]=G,e[19]=L):L=e[19];const $=!m,z=a==="destructive"?"default":"ghost";let T;e[20]!==r?(T=r("Rename / drop / change type…"),e[20]=r,e[21]=T):T=e[21];let C;e[22]!==d||e[23]!==$||e[24]!==z||e[25]!==T?(C=l(ye,{"data-testid":"sc-editor-destructive",disabled:$,onClick:d,size:"xs",type:"button",variant:z,children:T}),e[22]=d,e[23]=$,e[24]=z,e[25]=T,e[26]=C):C=e[26];let A;return e[27]!==L||e[28]!==C||e[29]!==u||e[30]!==O?(A=p("div",{className:"flex flex-wrap gap-2",children:[u,O,L,C]}),e[27]=L,e[28]=C,e[29]=u,e[30]=O,e[31]=A):A=e[31],A},xt=n=>{const e=we(28),{onOpenMigrations:m,result:a}=n,t=Oe();if(a===null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=l(Ve,{}),e[0]=o):o=e[0],o}if(a.kind==="error"){let o;return e[1]!==a.message?(o=l("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:a.message}),e[1]=a.message,e[2]=o):o=e[2],o}if(a.kind==="needs-migration"){let o;e[3]!==a.message||e[4]!==t?(o=a.message===""?t("This edit changes stored data and must go through a migration. Review the migration before applying."):a.message,e[3]=a.message,e[4]=t,e[5]=o):o=e[5];let u;e[6]!==o?(u=l("p",{className:"text-sm text-warning",role:"alert",children:o}),e[6]=o,e[7]=u):u=e[7];let i;e[8]!==t?(i=t("Open Migrations"),e[8]=t,e[9]=i):i=e[9];let v;e[10]!==m||e[11]!==i?(v=l(ye,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:m,size:"xs",type:"button",variant:"outline",children:i}),e[10]=m,e[11]=i,e[12]=v):v=e[12];let f;return e[13]!==u||e[14]!==v?(f=p("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[u,v]}),e[13]=u,e[14]=v,e[15]=f):f=e[15],f}if(a.diagnostics.length===0){let o;return e[16]===Symbol.for("react.memo_cache_sentinel")?(o=l(Ve,{}),e[16]=o):o=e[16],o}let s;e[17]!==t?(s=t("Codegen reported diagnostics:"),e[17]=t,e[18]=s):s=e[18];let c;e[19]!==s?(c=l("p",{className:"text-sm text-destructive",role:"alert",children:s}),e[19]=s,e[20]=c):c=e[20];let d;e[21]!==a.diagnostics?(d=a.diagnostics.map(vt),e[21]=a.diagnostics,e[22]=d):d=e[22];let r;e[23]!==d?(r=l("ul",{className:"flex flex-col gap-0.5",children:d}),e[23]=d,e[24]=r):r=e[24];let g;return e[25]!==c||e[26]!==r?(g=p("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[c,r]}),e[25]=c,e[26]=r,e[27]=g):g=e[27],g};function vt(n){return l("li",{className:"font-mono text-[11px] text-destructive",children:n},n)}const yt=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.bigint()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],Ct="v.string()",Nt=n=>n.split(",").map(e=>e.trim()).filter(e=>e!==""),Tt=n=>{const e=we(83),{onApplied:m,tableNames:a}=n,t=Oe(),s=nt(),[c,d]=_(null),[r,g]=_(!1),[o,u]=_(null),[i,v]=_(""),[f,O]=_(""),[S,G]=_(Ct),[y,L]=_(a[0]??""),[$,z]=_(""),[T,C]=_(""),[A,F]=_(!1);let pe;e[0]===Symbol.for("react.memo_cache_sentinel")?(pe=()=>{d(null),v(""),O(""),z(""),C(""),F(!1)},e[0]=pe):pe=e[0];const te=pe;let E;e[1]!==m?(E=async q=>{g(!0),u(null);try{const H=await gt(q);u(H),H.kind==="ok"&&(m(H.tables),te())}catch(H){const Se=H;u({kind:"error",message:Se instanceof Error?Se.message:String(Se)})}g(!1)},e[1]=m,e[2]=E):E=e[2];const M=E;let w;e[3]!==M||e[4]!==i?(w=()=>{Ce(M({kind:"addTable",table:i.trim()}))},e[3]=M,e[4]=i,e[5]=w):w=e[5];const ge=w;let B;e[6]!==f||e[7]!==M||e[8]!==y||e[9]!==S?(B=()=>{Ce(M({column:f.trim(),kind:"addOptionalColumn",table:y,validator:S}))},e[6]=f,e[7]=M,e[8]=y,e[9]=S,e[10]=B):B=e[10];const ce=B;let le;e[11]!==T||e[12]!==$||e[13]!==M||e[14]!==y||e[15]!==A?(le=()=>{Ce(M({fields:Nt(T),kind:"addIndex",name:$.trim(),table:y,unique:A}))},e[11]=T,e[12]=$,e[13]=M,e[14]=y,e[15]=A,e[16]=le):le=e[16];const J=le;let Ne;e[17]===Symbol.for("react.memo_cache_sentinel")?(Ne=()=>{u(null),d("addTable")},e[17]=Ne):Ne=e[17];const W=Ne;let me;e[18]===Symbol.for("react.memo_cache_sentinel")?(me=()=>{u(null),d("addColumn")},e[18]=me):me=e[18];const be=me;let D;e[19]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{u(null),d("addIndex")},e[19]=D):D=e[19];const j=D;let se;e[20]!==t?(se=()=>{d("destructive"),u({kind:"needs-migration",message:t("This edit changes stored data and must go through a migration. Review the migration before applying.")})},e[20]=t,e[21]=se):se=e[21];const ue=se;let R;e[22]===Symbol.for("react.memo_cache_sentinel")?(R=q=>{v(q.target.value)},e[22]=R):R=e[22];const ae=R;let K;e[23]===Symbol.for("react.memo_cache_sentinel")?(K=q=>{O(q.target.value)},e[23]=K):K=e[23];const ne=K;let oe;e[24]===Symbol.for("react.memo_cache_sentinel")?(oe=q=>{G(q.target.value)},e[24]=oe):oe=e[24];const fe=oe;let X;e[25]===Symbol.for("react.memo_cache_sentinel")?(X=q=>{L(q.target.value)},e[25]=X):X=e[25];const Q=X;let U;e[26]===Symbol.for("react.memo_cache_sentinel")?(U=q=>{z(q.target.value)},e[26]=U):U=e[26];const ie=U;let V;e[27]===Symbol.for("react.memo_cache_sentinel")?(V=q=>{C(q.target.value)},e[27]=V):V=e[27];const re=V;let Y;e[28]===Symbol.for("react.memo_cache_sentinel")?(Y=q=>{F(q.target.checked)},e[28]=Y):Y=e[28];const P=Y;let Z;e[29]!==s?(Z=()=>{Ce(s({to:"/migrations"}))},e[29]=s,e[30]=Z):Z=e[30];const b=Z;let ee;e[31]!==t?(ee=t("Edit schema"),e[31]=t,e[32]=ee):ee=e[32];let de;e[33]!==ee?(de=l(Ge,{children:ee}),e[33]=ee,e[34]=de):de=e[34];let xe;e[35]!==t?(xe=t("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=t,e[36]=xe):xe=e[36];let Te;e[37]!==xe?(Te=l(ze,{children:xe}),e[37]=xe,e[38]=Te):Te=e[38];let ve;e[39]!==de||e[40]!==Te?(ve=p(Be,{children:[de,Te]}),e[39]=de,e[40]=Te,e[41]=ve):ve=e[41];const h=a.length>0;let x;e[42]!==c||e[43]!==ue||e[44]!==h?(x=l(bt,{hasTables:h,mode:c,onAddColumn:be,onAddIndex:j,onAddTable:W,onDestructive:ue}),e[42]=c,e[43]=ue,e[44]=h,e[45]=x):x=e[45];let N;e[46]!==r||e[47]!==c||e[48]!==ge||e[49]!==t||e[50]!==i?(N=c==="addTable"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-table-name",children:t("Table name")}),l(ke,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:ae,value:i})]}),l(ye,{"data-testid":"sc-editor-table-apply",disabled:r||i.trim()==="",onClick:ge,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ye,{onClick:te,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[46]=r,e[47]=c,e[48]=ge,e[49]=t,e[50]=i,e[51]=N):N=e[51];let k;e[52]!==r||e[53]!==f||e[54]!==c||e[55]!==ce||e[56]!==t||e[57]!==a||e[58]!==y||e[59]!==S?(k=c==="addColumn"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-column-table",children:t("Table name")}),l("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:Q,value:y,children:a.map(St)})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-column-name",children:t("Column name")}),l(ke,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:ne,value:f})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-column-type",children:t("Column type")}),l("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:fe,value:S,children:yt.map(wt)})]}),l("span",{className:"text-[11px] text-muted-foreground",children:t("Optional")}),l(ye,{"data-testid":"sc-editor-column-apply",disabled:r||f.trim()===""||y==="",onClick:ce,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ye,{onClick:te,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[52]=r,e[53]=f,e[54]=c,e[55]=ce,e[56]=t,e[57]=a,e[58]=y,e[59]=S,e[60]=k):k=e[60];let I;e[61]!==r||e[62]!==T||e[63]!==$||e[64]!==c||e[65]!==J||e[66]!==t||e[67]!==a||e[68]!==y||e[69]!==A?(I=c==="addIndex"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-index-table",children:t("Table name")}),l("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:Q,value:y,children:a.map(_t)})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-index-name",children:t("Index name")}),l(ke,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:ie,value:$})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-index-fields",children:t("Index fields (comma-separated)")}),l(ke,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:re,value:T})]}),p(Ee,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[l("input",{checked:A,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:P,type:"checkbox"}),l("span",{className:"text-muted-foreground",children:t("Unique")})]}),l(ye,{"data-testid":"sc-editor-index-apply",disabled:r||$.trim()===""||T.trim()==="",onClick:J,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ye,{onClick:te,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[61]=r,e[62]=T,e[63]=$,e[64]=c,e[65]=J,e[66]=t,e[67]=a,e[68]=y,e[69]=A,e[70]=I):I=e[70];let he;e[71]!==b||e[72]!==o?(he=l(xt,{onOpenMigrations:b,result:o}),e[71]=b,e[72]=o,e[73]=he):he=e[73];let _e;e[74]!==x||e[75]!==N||e[76]!==k||e[77]!==I||e[78]!==he?(_e=p(De,{children:[x,N,k,I,he]}),e[74]=x,e[75]=N,e[76]=k,e[77]=I,e[78]=he,e[79]=_e):_e=e[79];let Ie;return e[80]!==ve||e[81]!==_e?(Ie=p(je,{"data-testid":"sc-editor",size:"sm",children:[ve,_e]}),e[80]=ve,e[81]=_e,e[82]=Ie):Ie=e[82],Ie};function St(n){return l("option",{value:n,children:n},n)}function wt(n){return l("option",{value:n.validator,children:n.label},n.validator)}function _t(n){return l("option",{value:n,children:n},n)}const He=[],Et=n=>{const e=we(5),{open:m}=n,a=m&&"rotate-90";let t;e[0]!==a?(t=Qe("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",a),e[0]=a,e[1]=t):t=e[1];let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=l("path",{d:"m9 6 6 6-6 6"}),e[2]=s):s=e[2];let c;return e[3]!==t?(c=l("svg",{"aria-hidden":"true",className:t,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:s}),e[3]=t,e[4]=c):c=e[4],c},Je=n=>{const e=we(20),{children:m,expanded:a,name:t,onToggle:s,rowCount:c,rowTestId:d,toggleTestId:r}=n;let g;e[0]!==a?(g=l(Et,{open:a}),e[0]=a,e[1]=g):g=e[1];let o;e[2]!==t?(o=l("span",{className:"truncate font-mono text-xs text-foreground",title:t,children:t}),e[2]=t,e[3]=o):o=e[3];let u;e[4]!==c?(u=p("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",c,")"]}),e[4]=c,e[5]=u):u=e[5];let i;e[6]!==a||e[7]!==s||e[8]!==g||e[9]!==o||e[10]!==u||e[11]!==r?(i=p("button",{"aria-expanded":a,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":r,onClick:s,type:"button",children:[g,o," ",u]}),e[6]=a,e[7]=s,e[8]=g,e[9]=o,e[10]=u,e[11]=r,e[12]=i):i=e[12];let v;e[13]!==m||e[14]!==a?(v=a&&l("div",{className:"px-3 pb-3 ps-8",children:m}),e[13]=m,e[14]=a,e[15]=v):v=e[15];let f;return e[16]!==d||e[17]!==i||e[18]!==v?(f=p("li",{className:"border-t border-border/60 first:border-t-0","data-testid":d,children:[i,v]}),e[16]=d,e[17]=i,e[18]=v,e[19]=f):f=e[19],f},We=n=>{const e=we(5),{columns:m,testId:a}=n;let t;e[0]!==m?(t=m.map(kt),e[0]=m,e[1]=t):t=e[1];let s;return e[2]!==t||e[3]!==a?(s=l("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":a,children:t}),e[2]=t,e[3]=a,e[4]=s):s=e[4],s},It=n=>{const e=we(10),{heading:m,indexes:a,testId:t}=n;let s;e[0]!==m?(s=l("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:m}),e[0]=m,e[1]=s):s=e[1];let c;e[2]!==a?(c=a.map(At),e[2]=a,e[3]=c):c=e[3];let d;e[4]!==c||e[5]!==t?(d=l("ul",{className:"flex flex-col gap-1","data-testid":t,children:c}),e[4]=c,e[5]=t,e[6]=d):d=e[6];let r;return e[7]!==s||e[8]!==d?(r=p("div",{className:"pt-3",children:[s,d]}),e[7]=s,e[8]=d,e[9]=r):r=e[9],r},Xe=n=>Qe("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",n?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),Qt=n=>{const e=we(85),{initialShardKey:m,initialTable:a,schemaEditable:t}=n,s=Oe();let c;e[0]!==m||e[1]!==a?(c={initialShardKey:m,initialTable:a},e[0]=m,e[1]=a,e[2]=c):c=e[2];const{columns:d,diagramTables:r,error:g,expanded:o,filteredGlobalTables:u,filteredTables:i,globalColumns:v,globalError:f,globalExpanded:O,globalTables:S,indexes:G,refresh:y,setShardKey:L,setTableFilter:$,setView:z,shardColumnsError:T,shardKey:C,tableFilter:A,tables:F,toggle:pe,toggleGlobal:te,view:E}=mt(c);let M;e[3]!==z?(M=()=>{z("list")},e[3]=z,e[4]=M):M=e[4];const w=M;let ge;e[5]!==z?(ge=()=>{z("graph")},e[5]=z,e[6]=ge):ge=e[6];const B=ge;let ce;e[7]!==$?(ce=b=>{$(b.target.value)},e[7]=$,e[8]=ce):ce=e[8];const le=ce;let J;e[9]!==y||e[10]!==C?(J=b=>{Ce(y(C))},e[9]=y,e[10]=C,e[11]=J):J=e[11];const Ne=J;let W;e[12]!==F?(W=F??[],e[12]=F,e[13]=W):W=e[13];let me;e[14]!==W?(me=W.map($t),e[14]=W,e[15]=me):me=e[15];const be=me;let D;e[16]!==L||e[17]!==C?(D=l(Ze,{onChange:L,testId:"sc-shard-input",value:C}),e[16]=L,e[17]=C,e[18]=D):D=e[18];let j;e[19]!==s?(j=s("Schema view"),e[19]=s,e[20]=j):j=e[20];const se=E==="graph",ue=E==="graph";let R;e[21]!==ue?(R=Xe(ue),e[21]=ue,e[22]=R):R=e[22];let ae;e[23]!==s?(ae=s("Graph"),e[23]=s,e[24]=ae):ae=e[24];let K;e[25]!==B||e[26]!==se||e[27]!==R||e[28]!==ae?(K=l("button",{"aria-selected":se,className:R,"data-testid":"sc-view-graph",onClick:B,role:"tab",type:"button",children:ae}),e[25]=B,e[26]=se,e[27]=R,e[28]=ae,e[29]=K):K=e[29];const ne=E==="list",oe=E==="list";let fe;e[30]!==oe?(fe=Xe(oe),e[30]=oe,e[31]=fe):fe=e[31];let X;e[32]!==s?(X=s("Table list"),e[32]=s,e[33]=X):X=e[33];let Q;e[34]!==w||e[35]!==ne||e[36]!==fe||e[37]!==X?(Q=l("button",{"aria-selected":ne,className:fe,"data-testid":"sc-view-list",onClick:w,role:"tab",type:"button",children:X}),e[34]=w,e[35]=ne,e[36]=fe,e[37]=X,e[38]=Q):Q=e[38];let U;e[39]!==K||e[40]!==Q||e[41]!==j?(U=p("div",{"aria-label":j,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[K,Q]}),e[39]=K,e[40]=Q,e[41]=j,e[42]=U):U=e[42];let ie;e[43]!==U||e[44]!==D?(ie=p("div",{className:"flex flex-wrap items-center gap-3",children:[D,U]}),e[43]=U,e[44]=D,e[45]=ie):ie=e[45];let V;e[46]!==Ne||e[47]!==t||e[48]!==be?(V=t===!0&&l(Tt,{onApplied:Ne,tableNames:be}),e[46]=Ne,e[47]=t,e[48]=be,e[49]=V):V=e[49];let re;e[50]!==le||e[51]!==s||e[52]!==A||e[53]!==E?(re=E==="list"&&l(ke,{"aria-label":s("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:le,placeholder:s("Filter tables"),value:A}),e[50]=le,e[51]=s,e[52]=A,e[53]=E,e[54]=re):re=e[54];let Y;e[55]!==r||e[56]!==g||e[57]!==f||e[58]!==T||e[59]!==C||e[60]!==E?(Y=E==="graph"&&p("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[g!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),f!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:f}),l(at,{columnsError:T[C]===!0,tables:r,testIdPrefix:"sc-graph"})]}),e[55]=r,e[56]=g,e[57]=f,e[58]=T,e[59]=C,e[60]=E,e[61]=Y):Y=e[61];let P;e[62]!==d||e[63]!==g||e[64]!==o||e[65]!==u||e[66]!==i||e[67]!==v||e[68]!==f||e[69]!==O||e[70]!==S||e[71]!==G||e[72]!==C||e[73]!==s||e[74]!==F||e[75]!==pe||e[76]!==te||e[77]!==E?(P=E==="list"&&p("div",{className:"flex flex-col gap-4",children:[p(je,{"data-testid":"sc-shard-section",size:"sm",children:[p(Be,{children:[p("div",{className:"flex items-center gap-2",children:[l(Ke,{tier:"shard"}),l(Ge,{children:s("Shard tables")}),F!==null&&l(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:i.length})]}),l(ze,{children:Pe.shard.hint})]}),p(De,{children:[g!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),F!==null&&F.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:s("No tables in this shard.")}),F!==null&&F.length>0&&i.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:s("No tables match your filter.")}),i.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:i.map(b=>{const ee=`${C}:${b.name}`,de=G[ee]??[];return p(Je,{expanded:o===b.name,name:b.name,onToggle:()=>{Ce(pe(b.name))},rowCount:b.rowCount,rowTestId:`sc-table-${b.name}`,toggleTestId:`sc-toggle-${b.name}`,children:[l(We,{columns:d[ee]??He,testId:`sc-columns-${b.name}`}),de.length>0&&l(It,{heading:s("Indexes"),indexes:de,testId:`sc-indexes-${b.name}`})]},b.name)})})]})]}),p(je,{"data-testid":"sc-global-section",size:"sm",children:[p(Be,{children:[p("div",{className:"flex items-center gap-2",children:[l(Ke,{tier:"global"}),l(Ge,{children:s("Global tables (D1)")}),S!==null&&l(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:u.length})]}),l(ze,{children:Pe.global.hint})]}),p(De,{children:[f!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:f}),S!==null&&S.length===0&&l(et,{description:Pe.global.hint,testId:"sc-global-empty",title:s("No global tables.")}),S!==null&&S.length>0&&u.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:s("No tables match your filter.")}),u.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:u.map(b=>l(Je,{expanded:O===b.name,name:b.name,onToggle:()=>{Ce(te(b.name))},rowCount:b.rowCount,rowTestId:`sc-global-table-${b.name}`,toggleTestId:`sc-global-toggle-${b.name}`,children:l(We,{columns:v[b.name]??He,testId:`sc-global-columns-${b.name}`})},b.name))})]})]})]}),e[62]=d,e[63]=g,e[64]=o,e[65]=u,e[66]=i,e[67]=v,e[68]=f,e[69]=O,e[70]=S,e[71]=G,e[72]=C,e[73]=s,e[74]=F,e[75]=pe,e[76]=te,e[77]=E,e[78]=P):P=e[78];let Z;return e[79]!==ie||e[80]!==V||e[81]!==re||e[82]!==Y||e[83]!==P?(Z=p("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[ie,V,re,Y,P]}),e[79]=ie,e[80]=V,e[81]=re,e[82]=Y,e[83]=P,e[84]=Z):Z=e[84],Z};function kt(n){return l("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:n},n)}function At(n){return p("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[l("span",{className:"font-mono",children:n.name}),l(Fe,{variant:"outline",children:n.type}),n.unique===!0&&l(Fe,{variant:"secondary",children:"unique"}),l("span",{className:"text-muted-foreground",children:n.fields.join(", ")})]},`${n.type}:${n.name}`)}function $t(n){return n.name}export{Qt as SchemaViewer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as u}from"react/compiler-runtime";import{u as h}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{useT as m}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as p}from"../packem_shared/ADMIN_FUNCTIONS-
|
|
1
|
+
import{c as u}from"react/compiler-runtime";import{u as h}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{useT as m}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as p}from"../packem_shared/ADMIN_FUNCTIONS-4aGsMs95.mjs";import{A as f}from"../packem_shared/advisor-view-fNcNYW2Q.mjs";import{jsx as R}from"react/jsx-runtime";const k=(e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("User subscriptions are ungated")})[s.kind],g=e=>Array.isArray(e.findings)?e.findings:[],S=e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],A=(e,s)=>({"admin-token-weak":e("Your admin token is {length} characters — use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters — use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed — browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: anyone who can reach the worker can open a socket and run ordinary user subscriptions. Admin subscriptions are unaffected — they need the admin token. Set it if subscribers should present a shared credential.")})[s.kind],T=()=>{const e=u(8),s=m();let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={},e[0]=t):t=e[0];const{data:i,error:o,errorSource:d}=h(p.getSecurityAudit,t);let a;if(e[1]!==i||e[2]!==s){const l=i===void 0?null:g(i);a=l===null?null:l.map(r=>({description:A(s,r),entity:S(r),issueType:k(s,r),key:r.kind,level:r.level})),e[1]=i,e[2]=s,e[3]=a}else a=e[3];const c=a;let n;return e[4]!==o||e[5]!==d||e[6]!==c?(n=R(f,{error:o,errorSource:d,rows:c,testId:"lunora-security-advisor"}),e[4]=o,e[5]=d,e[6]=c,e[7]=n):n=e[7],n};export{T as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as G}from"react/compiler-runtime";import{E as X}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{B as Y}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as M,a as P}from"../packem_shared/card-By2O8ULa.mjs";import{T as Z,a as ee,b as J,c as Q,d as te,e as W}from"../packem_shared/table-D0SBiDu-.mjs";import{u as re}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{useT as se}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as le}from"../packem_shared/ADMIN_FUNCTIONS-
|
|
1
|
+
import{c as G}from"react/compiler-runtime";import{E as X}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{B as Y}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as M,a as P}from"../packem_shared/card-By2O8ULa.mjs";import{T as Z,a as ee,b as J,c as Q,d as te,e as W}from"../packem_shared/table-D0SBiDu-.mjs";import{u as re}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{useT as se}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as le}from"../packem_shared/ADMIN_FUNCTIONS-4aGsMs95.mjs";import{C as ne}from"../packem_shared/cf-links-CBJ5SywP.mjs";import{r as ae,u as ie,s as oe}from"../packem_shared/shortcuts-B9gDaXmw.mjs";import{jsxs as d,jsx as r}from"react/jsx-runtime";const de={binding:"outline",secret:"destructive",var:"secondary"},ce=(s,e)=>{if(s===void 0)return[];const u=[];return s.workerUrl!==void 0&&u.push({label:e("URL"),value:s.workerUrl}),s.environment!==void 0&&u.push({label:e("Environment"),value:s.environment}),s.deploymentId!==void 0&&u.push({label:e("Deployment"),value:s.deploymentId}),s.versionTag!==void 0&&u.push({label:e("Version"),value:s.versionTag}),u},z=s=>{const e=G(18),{modifier:u,name:t,label:p}=s,F=ie();let b;e[0]!==t?(b=a=>{if(!["Escape","Tab"].includes(a.key)){if(a.shiftKey){a.preventDefault();return}a.preventDefault(),oe(t,a.key)}},e[0]=t,e[1]=b):b=e[1];const c=b,m=`set-shortcut-${t}`;let f;e[2]!==p?(f=r("dt",{className:"text-muted-foreground",children:p}),e[2]=p,e[3]=f):f=e[3];let h;e[4]!==u?(h=r("kbd",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:u}),e[4]=u,e[5]=h):h=e[5];const n=`set-shortcut-input-${t}`,x=F[t];let i;e[6]!==p||e[7]!==c||e[8]!==n||e[9]!==x?(i=r("input",{"aria-label":p,className:"h-7 w-12 rounded-md border border-border bg-background text-center font-mono text-xs uppercase outline-none focus-visible:border-ring","data-testid":n,onKeyDown:c,readOnly:!0,value:x}),e[6]=p,e[7]=c,e[8]=n,e[9]=x,e[10]=i):i=e[10];let l;e[11]!==h||e[12]!==i?(l=d("dd",{className:"flex items-center gap-1.5",children:[h,i]}),e[11]=h,e[12]=i,e[13]=l):l=e[13];let o;return e[14]!==m||e[15]!==f||e[16]!==l?(o=d("div",{className:"contents","data-testid":m,children:[f,l]}),e[14]=m,e[15]=f,e[16]=l,e[17]=o):o=e[17],o},Ce=s=>{const e=G(85),{initialShardKey:u}=s,t=se();let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];const F=u??"";let b;e[1]!==F?(b={shardKey:F},e[1]=F,e[2]=b):b=e[2];const{data:c,error:m,errorSource:f,isLoading:h}=re(le.getSettings,p,b);let n,x,i,l,o,a,g;if(e[3]!==m||e[4]!==f||e[5]!==c?.deploy||e[6]!==c?.settings||e[7]!==t){const q=ce(c?.deploy,t);let H;e[15]!==c?.settings?(H=c?.settings??[],e[15]=c?.settings,e[16]=H):H=e[16],n=H,x="flex flex-col gap-4",i="lunora-settings";let j;e[17]!==t?(j=t("Open in Cloudflare"),e[17]=t,e[18]=j):j=e[18],e[19]!==j?(l=r("div",{className:"flex flex-wrap items-center gap-3",children:r("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:ne,rel:"noreferrer",target:"_blank",children:j})}),e[19]=j,e[20]=l):l=e[20];let B;e[21]!==t?(B=t("View-only — values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=t,e[22]=B):B=e[22],e[23]!==B?(o=r("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:B}),e[23]=B,e[24]=o):o=e[24],e[25]!==m||e[26]!==f?(a=m!==null&&r(X,{error:f,testId:"set-error"}),e[25]=m,e[26]=f,e[27]=a):a=e[27],g=q.length>0&&d(M,{className:"py-0","data-testid":"set-deploy",children:[r("header",{className:"border-b border-border px-4 py-3",children:r("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Deployment")})}),r(P,{className:"py-3",children:r("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:q.map(me)})})]}),e[3]=m,e[4]=f,e[5]=c?.deploy,e[6]=c?.settings,e[7]=t,e[8]=n,e[9]=x,e[10]=i,e[11]=l,e[12]=o,e[13]=a,e[14]=g}else n=e[8],x=e[9],i=e[10],l=e[11],o=e[12],a=e[13],g=e[14];let N;e[28]!==t?(N=t("Keyboard shortcuts"),e[28]=t,e[29]=N):N=e[29];let v;e[30]!==N?(v=r("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:N}),e[30]=N,e[31]=v):v=e[31];let y;e[32]!==t?(y=t("Reset"),e[32]=t,e[33]=y):y=e[33];let k;e[34]!==y?(k=r("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"set-shortcut-reset",onClick:ae,type:"button",children:y}),e[34]=y,e[35]=k):k=e[35];let w;e[36]!==v||e[37]!==k?(w=d("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[v,k]}),e[36]=v,e[37]=k,e[38]=w):w=e[38];let C;e[39]!==t?(C=t("Command palette"),e[39]=t,e[40]=C):C=e[40];let T;e[41]!==C?(T=r(z,{label:C,modifier:"⌘/Ctrl",name:"palette"}),e[41]=C,e[42]=T):T=e[42];let S;e[43]!==t?(S=t("Operation console"),e[43]=t,e[44]=S):S=e[44];let R;e[45]!==S?(R=r(z,{label:S,modifier:"Ctrl",name:"console"}),e[45]=S,e[46]=R):R=e[46];let _;e[47]!==T||e[48]!==R?(_=d("dl",{className:"grid grid-cols-[10rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 text-sm",children:[T,R]}),e[47]=T,e[48]=R,e[49]=_):_=e[49];let D;e[50]!==t?(D=t("Stored in this browser. Focus a box and press a key to rebind it."),e[50]=t,e[51]=D):D=e[51];let E;e[52]!==D?(E=r("p",{className:"pt-3 text-xs text-muted-foreground",children:D}),e[52]=D,e[53]=E):E=e[53];let I;e[54]!==_||e[55]!==E?(I=d(P,{className:"py-3",children:[_,E]}),e[54]=_,e[55]=E,e[56]=I):I=e[56];let K;e[57]!==w||e[58]!==I?(K=d(M,{className:"py-0","data-testid":"set-preferences",children:[w,I]}),e[57]=w,e[58]=I,e[59]=K):K=e[59];let A;e[60]!==t?(A=t("Environment & bindings"),e[60]=t,e[61]=A):A=e[61];let O;e[62]!==A?(O=r("header",{className:"border-b border-border px-4 py-3",children:r("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:A})}),e[62]=A,e[63]=O):O=e[63];let U;e[64]!==m||e[65]!==h||e[66]!==n.length||e[67]!==t?(U=m===null&&!h&&n.length===0&&r("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:t("No environment variables or bindings.")}),e[64]=m,e[65]=h,e[66]=n.length,e[67]=t,e[68]=U):U=e[68];let L;e[69]!==n||e[70]!==t?(L=n.length>0&&r(P,{className:"px-0 py-0",children:d(Z,{"data-testid":"set-table",children:[r(ee,{children:d(J,{children:[r(Q,{children:t("name")}),r(Q,{children:t("kind")}),r(Q,{children:t("value")})]})}),r(te,{children:n.map(fe)})]})}),e[69]=n,e[70]=t,e[71]=L):L=e[71];let $;e[72]!==O||e[73]!==U||e[74]!==L?($=d(M,{className:"py-0",children:[O,U,L]}),e[72]=O,e[73]=U,e[74]=L,e[75]=$):$=e[75];let V;return e[76]!==K||e[77]!==$||e[78]!==x||e[79]!==i||e[80]!==l||e[81]!==o||e[82]!==a||e[83]!==g?(V=d("div",{className:x,"data-testid":i,children:[l,o,a,g,K,$]}),e[76]=K,e[77]=$,e[78]=x,e[79]=i,e[80]=l,e[81]=o,e[82]=a,e[83]=g,e[84]=V):V=e[84],V};function me(s){return d("div",{className:"contents","data-testid":"set-deploy-row",children:[r("dt",{className:"text-muted-foreground",children:s.label}),r("dd",{className:"truncate font-mono text-xs",title:s.value,children:s.value})]},s.label)}function fe(s){return d(J,{"data-testid":"set-row",children:[r(W,{className:"font-mono text-xs font-medium",children:s.name}),r(W,{children:r(Y,{variant:de[s.kind],children:s.bindingType??s.kind})}),r(W,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:s.value??r("span",{className:"text-muted-foreground",children:"—"})})]},s.name)}export{Ce as SettingsPanel};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as X}from"react/compiler-runtime";import{useState as se,useMemo as Ae,useCallback as Xe,useEffect as me,useRef as ue,useId as Ze}from"react";import{u as Te}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{ADMIN_FUNCTIONS as we}from"../packem_shared/ADMIN_FUNCTIONS-
|
|
1
|
+
import{c as X}from"react/compiler-runtime";import{useState as se,useMemo as Ae,useCallback as Xe,useEffect as me,useRef as ue,useId as Ze}from"react";import{u as Te}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{ADMIN_FUNCTIONS as we}from"../packem_shared/ADMIN_FUNCTIONS-4aGsMs95.mjs";import{u as Ee,n as Be,b as Re,r as be,s as et}from"../packem_shared/browser-storage-BH1MxLZs.mjs";import{d as ye,f as ce,c as Ce,b as tt}from"../packem_shared/internal-BXEjuLPN.mjs";import{r as nt}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{u as st}from"../packem_shared/use-sql-assistant-BMVlguKF.mjs";import ot from"../packem_shared/useDebounced-DVeQ5-oW.mjs";import{useT as re}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{c as ie}from"../packem_shared/utils-bhneXptQ.mjs";import{jsxs as B,jsx as f,Fragment as he}from"react/jsx-runtime";import{I as Pe}from"../packem_shared/input-CXhxesPC.mjs";import{diffLines as lt}from"diff";import{S as rt,a as it}from"../packem_shared/sql-result-table-CatgdmMh.mjs";import{ShardInput as at}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{A as ct}from"../packem_shared/alert-PB5W11MM.mjs";import{E as dt}from"../packem_shared/grid-features-2c5SaBtH.mjs";const ut="x",qe=" ",ft={'"':'"',"'":"'","[":"]","`":"`"},He=(l,e)=>{let n=e+2;for(;n<l.length&&l[n]!==`
|
|
2
2
|
`;)n+=1;return n},Fe=(l,e)=>{const n=l.indexOf("*/",e+2);return n===-1?-1:n+2},We=l=>{const e=l.split("");let n=0;for(;n<l.length;){const t=l[n]??"",o=ft[t];if(t==="-"&&l[n+1]==="-"){const s=He(l,n);e.fill(qe,n,s),n=s}else if(t==="/"&&l[n+1]==="*"){const s=Fe(l,n);if(s===-1)return;e.fill(qe,n,s),n=s}else if(o!==void 0){let s=n+1;for(;s<l.length;)if(l[s]!==o)s+=1;else if(o!=="]"&&l[s+1]===o)s+=2;else break;if(s>=l.length)return;e.fill(ut,n,s+1),n=s+1}else n+=1}for(let t=0;t<l.length;t+=1)l[t]===`
|
|
3
3
|
`&&(e[t]=`
|
|
4
4
|
`);return e.join("")},mt=/^(?:explain\s+(?:query\s+plan\s+)?)?(?:select|with)\b/iu,pt=/\b(?:alter|attach|create|delete|detach|drop|insert|pragma|reindex|truncate|update|vacuum)\b|\breplace\b(?!\s*\()/iu,ht=/^\w+/u,bt=/;\s*$/u,gt=/\s/u,Ke=l=>{let e=0;for(;e<l.length;){const n=l[e];if(n!==void 0&>.test(n))e+=1;else if(n==="-"&&l[e+1]==="-")e=He(l,e);else if(n==="/"&&l[e+1]==="*"){const t=Fe(l,e);if(t===-1)break;e=t}else break}return e},xt=l=>{const e=Ke(l),n=l.slice(e).trimEnd();if(n==="")return{code:"SQL_EMPTY",message:"the query is empty"};const o=(We(n)??n).replace(bt,""),s=n.slice(0,o.length),r=o.indexOf(";");if(r!==-1)return{code:"SQL_MULTIPLE_STATEMENTS",length:1,message:"only a single statement may be run",offset:e+r};const c="the SQL editor is read-only — only SELECT / WITH / EXPLAIN queries are allowed";if(!mt.test(s))return{code:"SQL_NOT_READONLY",length:ht.exec(s)?.[0].length??1,message:c,offset:e};const a=pt.exec(s);if(a!==null)return{code:"SQL_NOT_READONLY",length:a[0].length,message:`${c} (\`${a[0].toUpperCase()}\` is not allowed)`,offset:e+a.index}},vt=/^explain\b/iu,yt=l=>vt.test(l.slice(Ke(l)))?l:`EXPLAIN QUERY PLAN ${l}`,ke=(l,e)=>{const n=l.trim();if(n==="")return[];const t=e+l.indexOf(n),o=xt(n);return o?.code==="SQL_EMPTY"?[]:[o===void 0?{offset:t,sql:n}:{offset:t,rejection:o,sql:n}]},ze=l=>{const e=We(l);if(e===void 0)return ke(l,0);const n=[];let t=0;for(let o=0;o<=e.length;o+=1)o!==e.length&&e[o]!==";"||(n.push(...ke(l.slice(t,o),t)),t=o+1);return n},St=["ORDER BY","GROUP BY","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN","EXPLAIN QUERY PLAN","SELECT","DISTINCT","FROM","WHERE","HAVING","LIMIT","OFFSET","JOIN","ON","AND","OR","AS","ASC","DESC","WITH","UNION","EXPLAIN"],wt=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],Se=String.fromCodePoint(0),Ct=new RegExp(`${Se}${String.raw`(\d+)`}${Se}`,"gu"),Nt=St.map(l=>({pattern:new RegExp(String.raw`\b${l.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:l})),Et=wt.map(l=>({pattern:new RegExp(String.raw`\s+${l.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as k}from"react/compiler-runtime";import{useNavigate as F,useRouter as M,useSearch as P}from"@tanstack/react-router";import{useState as Q,useEffect as A}from"react";import{T as w}from"../packem_shared/storage-tier-C2mKwYRj.mjs";import{u as q}from"../packem_shared/use-mirrored-ref-CVDf2z1M.mjs";import{u as J}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as K}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{s as L,d as D}from"../packem_shared/data-view-params-C-_G-biH.mjs";import{f as m}from"../packem_shared/internal-BXEjuLPN.mjs";import{l as O,s as I}from"../packem_shared/browser-storage-BH1MxLZs.mjs";import{DataBrowser as X}from"../packem_shared/DataBrowser-
|
|
1
|
+
import{c as k}from"react/compiler-runtime";import{useNavigate as F,useRouter as M,useSearch as P}from"@tanstack/react-router";import{useState as Q,useEffect as A}from"react";import{T as w}from"../packem_shared/storage-tier-C2mKwYRj.mjs";import{u as q}from"../packem_shared/use-mirrored-ref-CVDf2z1M.mjs";import{u as J}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as K}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{s as L,d as D}from"../packem_shared/data-view-params-C-_G-biH.mjs";import{f as m}from"../packem_shared/internal-BXEjuLPN.mjs";import{l as O,s as I}from"../packem_shared/browser-storage-BH1MxLZs.mjs";import{DataBrowser as X}from"../packem_shared/DataBrowser-C5HbI4TH.mjs";import{GlobalDataBrowser as Y}from"../packem_shared/GlobalDataBrowser-D0H2yJSl.mjs";import{jsx as v,jsxs as E}from"react/jsx-runtime";const N="lunora-studio-saved-queries",$=50,z=r=>r!==null&&typeof r=="object"&&typeof r.name=="string"&&typeof r.view=="object"&&r.view!==null,y=()=>O(N).filter(z),B=r=>{I(N,r)},H=(r,e)=>{const l=r.trim();if(l==="")return y();const n=[{name:l,view:e},...y().filter(o=>o.name!==l)].slice(0,$);return B(n),n},U=r=>{const e=y().filter(l=>l.name!==r);return B(e),e},W=r=>{const e=k(15),{onChange:l,tier:n}=r,o=K();let p;e[0]!==l?(p=S=>{l(S.target.value)},e[0]=l,e[1]=p):p=e[1];const u=p;let s;e[2]!==o?(s=o("Storage tier"),e[2]=o,e[3]=s):s=e[3];let d;e[4]!==s?(d=v("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:s}),e[4]=s,e[5]=d):d=e[5];const g=w[n];let c,i;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=v("option",{value:"shard",children:w.shard.label}),i=v("option",{value:"global",children:w.global.label}),e[6]=c,e[7]=i):(c=e[6],i=e[7]);let h;e[8]!==u||e[9]!==g.title||e[10]!==n?(h=E("select",{className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm outline-none focus-visible:border-ring","data-testid":"table-editor-schema",id:"table-editor-schema",onChange:u,title:g.title,value:n,children:[c,i]}),e[8]=u,e[9]=g.title,e[10]=n,e[11]=h):h=e[11];let f;return e[12]!==d||e[13]!==h?(f=E("label",{className:"flex w-full flex-col gap-1",htmlFor:"table-editor-schema",children:[d,h]}),e[12]=d,e[13]=h,e[14]=f):f=e[14],f},Z=()=>{try{m(globalThis.navigator.clipboard.writeText(globalThis.location.href))}catch{}},ge=({canGenerateRows:r=!1,editable:e=!1,initialShardKey:l})=>{const n=J(),o=F(),p=M(),u=P({strict:!1}),s=L(u),d=q(u),g=()=>p.state.location.pathname.split("/").findLast(Boolean)==="data",c=s.tier??"shard",i=s.table,[h,f]=Q(()=>y()),[S,C]=Q(()=>new Set);A(()=>{m((async()=>{try{const a=await n.listGlobalTables();C(new Set(a.map(t=>t.name)))}catch{}})())},[n]),A(()=>{c==="shard"&&i!==void 0&&S.has(i)&&m(o({replace:!0,search:a=>({...a,schema:"global"}),to:"/data"}))},[S,o,i,c]);const R=a=>{m(o({search:t=>({...t,schema:a==="global"?"global":void 0,table:void 0}),to:"/data"}))},T=(a,t)=>{g()&&m(o({search:b=>({schema:b.schema,search:t?.search,shard:b.shard,table:a}),to:"/data"}))},G=a=>{m(o({search:t=>({...t,schema:"global",table:a}),to:"/data"}))},_=a=>{const t=D(a),{current:b}=d;(b.filters??void 0)===t.filters&&(b.order??void 0)===t.order&&(b.search??void 0)===t.search&&(b.shard??void 0)===t.shard||!g()||m(o({replace:!0,search:V=>({...V,filters:t.filters,order:t.order,search:t.search,shard:t.shard}),to:"/data"}))},j={onApplyQuery:a=>{const t=D(a.view);m(o({search:()=>({filters:t.filters,order:t.order,schema:t.schema,search:t.search,shard:t.shard,table:t.table}),to:"/data"}))},onCopyLink:Z,onDeleteQuery:a=>{f(U(a))},onSaveQuery:(a,t)=>{f(H(a,t))},saved:h},x=v(W,{onChange:R,tier:c});return c==="global"?v(Y,{initialTable:i,onSelectTable:T,schemaSwitch:x}):v(X,{canGenerateRows:r,editable:e,globalTableNames:S,initialFilters:s.filters,initialOrderBy:s.orderBy,initialPins:u.pins,initialSearch:s.search,initialShardKey:s.shard??l,onNavigateToGlobal:G,onSelectTable:T,onViewChange:_,queryBar:j,schemaSwitch:x,tableParam:i})};export{ge as TableEditor};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as te}from"react/compiler-runtime";import{useState as ae}from"react";import{E as q}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{B as A}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as $}from"../packem_shared/button-q0UYSmrn.mjs";import{C as M,a as j}from"../packem_shared/card-By2O8ULa.mjs";import{E as K}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as L,a as P,b as f,c as o,d as U,e as d}from"../packem_shared/table-D0SBiDu-.mjs";import{u as x}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as v}from"../packem_shared/ADMIN_FUNCTIONS-
|
|
1
|
+
import{c as te}from"react/compiler-runtime";import{useState as ae}from"react";import{E as q}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{B as A}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as $}from"../packem_shared/button-q0UYSmrn.mjs";import{C as M,a as j}from"../packem_shared/card-By2O8ULa.mjs";import{E as K}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as L,a as P,b as f,c as o,d as U,e as d}from"../packem_shared/table-D0SBiDu-.mjs";import{u as x}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as v}from"../packem_shared/ADMIN_FUNCTIONS-4aGsMs95.mjs";import{h as se}from"../packem_shared/internal-BXEjuLPN.mjs";import{jsx as e,jsxs as l}from"react/jsx-runtime";const Q="agent_threads",re="agent_messages",D="agent_run_queue",_=100,y=250,ne={},oe={filters:[],limit:_,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:Q},c=(r,t)=>{const a=r[t];return typeof a=="string"?a:void 0},E=(r,t)=>{const a=r[t];return typeof a=="number"?a:void 0},H=r=>{const{usage:t}=r;if(t===null||typeof t!="object")return;const{totalTokens:a}=t;return typeof a=="number"?a:void 0},de=r=>{const{toolCalls:t}=r;return Array.isArray(t)?t.map(a=>a!==null&&typeof a=="object"?a.name:void 0).filter(a=>typeof a=="string"):[]},le=r=>{switch(r){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},ie=r=>{switch(r){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},ce=r=>{const t=te(3),{fetched:a}=r,u=G();let i;return t[0]!==a||t[1]!==u?(i=a<=y?null:e("p",{className:"text-xs text-muted-foreground","data-testid":"agents-messages-truncated",children:u("Showing the latest {count} messages; older ones are not shown.",{count:y})}),t[0]=a,t[1]=u,t[2]=i):i=t[2],i},Ee=({initialShardKey:r=""})=>{const t=G(),[a,u]=ae(void 0),{data:i}=x(v.listTables,ne,{live:!0,shardKey:r}),z=i!==void 0,h=Array.isArray(i)&&i.some(s=>s.name===Q),O=Array.isArray(i)&&i.some(s=>s.name===D),{data:S,error:V,errorSource:F,liveError:J}=x(v.readTablePage,oe,{enabled:h,live:!0,shardKey:r}),W={filters:[{column:"threadKey",operator:"eq",value:a??""}],limit:y+1,offset:0,orderBy:{column:"seq",direction:"desc"},skipCount:!0,table:re},{data:w}=x(v.readTablePage,{limit:_,offset:0,orderBy:{column:"position",direction:"asc"},skipCount:!0,table:D},{enabled:O,live:!0,shardKey:r}),{data:k,error:X,errorSource:Y}=x(v.readTablePage,W,{enabled:h&&a!==void 0,live:!0,shardKey:r}),b=Array.isArray(S?.rows)?S.rows:[],Z=Array.isArray(w?.rows)?w.rows:[],C=s=>Z.filter(n=>c(n,"threadKey")===s).length,B=Array.isArray(k?.rows)?k.rows:[],I=B.slice(0,y).toReversed(),R=b.find(s=>c(s,"key")===a);let g;return z&&!h?g=e(K,{description:t("No @lunora/agent tables found in this deployment. Add lunora/agents.ts with defineAgent(...) and merge the agent schema extension to run durable AI agents."),testId:"agents-unconfigured",title:t("No agents configured")}):h&&b.length===0?g=e(K,{description:t("No agent has run yet. Start a run with ctx.agents.<name>.run(...) and its thread appears here."),testId:"agents-empty",title:t("No agent threads yet")}):g=l("div",{className:"flex flex-col gap-6",children:[e(M,{className:"overflow-hidden py-0",children:e(j,{className:"px-0",children:l(L,{"data-testid":"agents-threads-table",children:[e(P,{children:l(f,{children:[e(o,{children:t("Agent")}),e(o,{children:t("Key")}),e(o,{children:t("Status")}),e(o,{children:t("Queued")}),e(o,{children:t("Messages")}),e(o,{children:t("Tokens")}),e(o,{children:t("Updated")}),e(o,{"aria-label":t("Actions")})]})}),e(U,{children:b.map(s=>{const n=c(s,"key")??"",m=c(s,"status"),p=H(s);return l(f,{"data-active":n===a?"":void 0,"data-testid":`agents-thread-${n}`,children:[e(d,{className:"font-mono text-xs",children:c(s,"agent")??"—"}),e(d,{className:"font-mono text-xs text-muted-foreground",children:n}),e(d,{children:e(A,{"data-testid":`agents-thread-status-${n}`,variant:le(m),children:m??"—"})}),e(d,{className:"tabular-nums",children:C(n)===0?e("span",{className:"text-muted-foreground",children:"—"}):e(A,{"data-testid":`agents-thread-queued-${n}`,variant:"warning",children:C(n)})}),e(d,{className:"tabular-nums",children:E(s,"messageCount")??"—"}),e(d,{className:"tabular-nums text-muted-foreground",children:p??"—"}),e(d,{className:"text-muted-foreground tabular-nums",children:se(E(s,"updatedAt"),"—")}),e(d,{className:"text-right",children:e($,{"data-testid":`agents-thread-open-${n}`,onClick:()=>{u(n)},size:"sm",type:"button",variant:"outline",children:t("Timeline")})})]},n)})})]})})}),X!==null&&e(q,{error:Y,testId:"agents-messages-error"}),a!==void 0&&e(M,{className:"overflow-hidden py-0","data-testid":"agents-thread-detail",children:l(j,{className:"flex flex-col gap-3 px-4 py-3",children:[l("div",{className:"flex items-center justify-between gap-2",children:[l("span",{className:"font-mono text-xs",children:[t("Timeline")," · ",a,R!==void 0&&l("span",{className:"text-muted-foreground",children:[" · ",t("Usage"),": ",H(R)??0," ",t("Tokens")]})]}),e($,{"data-testid":"agents-thread-detail-close",onClick:()=>{u(void 0)},size:"xs",type:"button",variant:"ghost",children:t("Close")})]}),e(ce,{fetched:B.length}),I.length===0?e("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")}):l(L,{"data-testid":"agents-messages-table",children:[e(P,{children:l(f,{children:[e(o,{children:t("Role")}),e(o,{children:t("Content")}),e(o,{children:t("Tool")}),e(o,{children:t("Approval")})]})}),e(U,{children:I.map((s,n)=>{const m=c(s,"role")??"—",p=de(s),ee=c(s,"toolName"),N=c(s,"status"),T=E(s,"seq")??n;return l(f,{"data-testid":`agents-message-${String(T)}`,children:[e(d,{className:"font-mono text-xs align-top text-muted-foreground",children:m}),e(d,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:c(s,"content")??"—"}),e(d,{className:"font-mono text-xs align-top text-muted-foreground",children:ee??(p.length>0?p.join(", "):"—")}),e(d,{className:"align-top",children:N===void 0?e("span",{className:"text-xs text-muted-foreground",children:"—"}):e(A,{"data-testid":`agents-message-approval-${String(T)}`,variant:ie(N),children:N})})]},c(s,"messageKey")??`${m}:${String(T)}`)})})]})]})})]}),l("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[V!==null&&e(q,{error:F,testId:"agents-error"}),e("p",{className:"text-sm text-muted-foreground",children:t("Agents run as durable workflows. Each run persists a thread of assistant and tool messages; select a thread to inspect its timeline, tool calls, approvals, and token usage.")}),J!==void 0&&e("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"agents-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")}),g]})};export{Ee as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as E}from"react/compiler-runtime";import{E as de}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{ShardInput as ue}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{S as K}from"../packem_shared/stat-card-BAv73QtB.mjs";import{B}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as D,a as me,b as te,c as se}from"../packem_shared/card-By2O8ULa.mjs";import{E as pe}from"../packem_shared/empty-state-D7jEML_T.mjs";import{c as _,a as oe,b as R,e as M,d as ne,T as re}from"../packem_shared/table-D0SBiDu-.mjs";import{u as X}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{u as fe}from"../packem_shared/use-open-trace-B_0LbTD7.mjs";import{u as he}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as w}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as z}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as Te}from"../packem_shared/internal-BXEjuLPN.mjs";import{f as $,a as O}from"../packem_shared/metrics-format-1sNGG47R.mjs";import{S as ve}from"../packem_shared/sparkline-B_sPPO_8.mjs";import{jsx as r,jsxs as I,Fragment as ke}from"react/jsx-runtime";const H="gen_ai.usage.input_tokens",W="gen_ai.usage.output_tokens",j="gen_ai.usage.cost",ie="gen_ai.request.model",ye="lunora.usage.cost.source",Ce=new Set(["ai.embed","ai.generate","ai.stream"]),G=6e4,be=1440,le="unknown",q=()=>({calls:0,estimatedCost:0,inputTokens:0,outputTokens:0,providerCost:0}),J=(o,e)=>{const s=o?.[e];return typeof s=="string"&&s!==""?s:void 0},L=(o,e)=>{const s=o?.[e];return typeof s=="number"&&Number.isFinite(s)?s:void 0},Q=o=>J(o,ye)==="provider"?"provider":"estimated",Y=(o,e)=>o.reduce((s,n)=>s+e(n),0),F=o=>o.providerCost+o.estimatedCost,ae=o=>o.estimatedCost>0?o.providerCost>0?"mixed":"estimated":o.providerCost>0?"provider":"none",ce=(o,e)=>({calls:o.calls+e.calls,estimatedCost:o.estimatedCost+e.estimatedCost,inputTokens:o.inputTokens+e.inputTokens,outputTokens:o.outputTokens+e.outputTokens,providerCost:o.providerCost+e.providerCost}),ge=o=>{const e=q();let s=0,n=0,t=0;for(const c of o){const l=Y(c.points,a=>a.sum),i=Y(c.points,a=>a.count);c.name===H?(e.inputTokens+=l,s+=i):c.name===W?(e.outputTokens+=l,n+=i):(t+=i,Q(c.attributes)==="provider"?e.providerCost+=l:e.estimatedCost+=l)}return e.calls=Math.max(s,n,t),e},Ne=(o,e)=>F(e)-F(o)||e.inputTokens+e.outputTokens-(o.inputTokens+o.outputTokens)||o.key.localeCompare(e.key),Z=(o,e)=>{const s=new Map;for(const n of o){const t=e(n);s.set(t,{key:t,...ce(s.get(t)??q(),n)})}return[...s.values()].toSorted(Ne)},xe=o=>(o?.series??[]).filter(e=>e.name===H||e.name===W||e.name===j),Se=o=>J(o.attributes,ie)??le,Ie=o=>{const e=new Map;for(const s of o){const n=Se(s),t=JSON.stringify([s.functionPath,n]),c=e.get(t)??{functionPath:s.functionPath,model:n,series:[]};c.series.push(s),e.set(t,c)}return[...e.values()].map(({functionPath:s,model:n,series:t})=>({functionPath:s,model:n,...ge(t)}))},_e=o=>{const e=new Map;for(const i of o){if(i.name!==j)continue;const a=Q(i.attributes)==="provider";for(const u of i.points){const m=e.get(u.bucketMs)??{bucketMs:u.bucketMs,estimatedCost:0,providerCost:0};a?m.providerCost+=u.sum:m.estimatedCost+=u.sum,e.set(u.bucketMs,m)}}const s=[...e.keys()].toSorted((i,a)=>i-a),n=s[0],t=s.at(-1);if(n===void 0||t===void 0)return[];const c=Math.max(n,t-(be-1)*G),l=[];for(let i=c;i<=t;i+=G)l.push(e.get(i)??{bucketMs:i,estimatedCost:0,providerCost:0});return l},Me=o=>{const e=[];for(const s of o)for(const n of s.spans){if(!Ce.has(n.name))continue;const{attributes:t}=n,c=L(t,j),l=L(t,H),i=L(t,W);e.push({...c===void 0?{}:{cost:c,costSource:Q(t)},functionPath:s.functionPath,...l===void 0?{}:{inputTokens:l},model:J(t,ie)??le,ok:n.ok,...i===void 0?{}:{outputTokens:i},startTs:s.startTs+n.offsetMs,streaming:n.name==="ai.stream",traceId:s.traceId})}return e.toSorted((s,n)=>n.startTs-s.startTs)},Oe=o=>o.map(e=>{const s=e.cost??0;return{calls:1,estimatedCost:e.costSource==="provider"?0:s,functionPath:e.functionPath,inputTokens:e.inputTokens??0,model:e.model,outputTokens:e.outputTokens??0,providerCost:e.costSource==="provider"?s:0}}),Ae=(o,e)=>{const s=xe(o),n=Me(e),t=s.length>0,c=t?Ie(s):Oe(n);let l=q(),i="none";for(const a of c)l=ce(l,a);return t?i="history":n.length>0&&(i="live"),{byFunction:Z(c,a=>a.functionPath),byModel:Z(c,a=>a.model),calls:n,source:i,totals:l,trend:t?_e(s):[]}},Ee=o=>Array.isArray(o?.traces)?o.traces:[],we=25,V=o=>{const e=E(16),{provenance:s,value:n}=o,t=w();if(s==="none"){let m;return e[0]===Symbol.for("react.memo_cache_sentinel")?(m=r("span",{className:"text-muted-foreground",children:"—"}),e[0]=m):m=e[0],m}let c;e[1]!==s||e[2]!==n?(c=s==="provider"?$(n):`~${$(n)}`,e[1]=s,e[2]=n,e[3]=c):c=e[3];let l;e[4]!==c?(l=r("span",{className:"tabular-nums",children:c}),e[4]=c,e[5]=l):l=e[5];let i;e[6]!==s||e[7]!==t?(i=s==="estimated"?r(B,{title:t("Derived from a price table, not reported by the provider."),variant:"warning",children:t("Estimated")}):null,e[6]=s,e[7]=t,e[8]=i):i=e[8];let a;e[9]!==s||e[10]!==t?(a=s==="mixed"?r(B,{title:t("Includes cost derived from a price table, not reported by the provider."),variant:"warning",children:t("Partly estimated")}):null,e[9]=s,e[10]=t,e[11]=a):a=e[11];let u;return e[12]!==l||e[13]!==i||e[14]!==a?(u=I("span",{className:"inline-flex items-center gap-2",children:[l,i,a]}),e[12]=l,e[13]=i,e[14]=a,e[15]=u):u=e[15],u},ee=o=>{const e=E(40),{keyLabel:s,rows:n,testId:t,title:c}=o,l=w();let i;e[0]!==c?(i=r(te,{className:"px-4 py-3",children:r(se,{children:c})}),e[0]=c,e[1]=i):i=e[1];let a;e[2]!==s?(a=r(_,{children:s}),e[2]=s,e[3]=a):a=e[3];let u;e[4]!==l?(u=l("Calls"),e[4]=l,e[5]=u):u=e[5];let m;e[6]!==u?(m=r(_,{className:"text-end",children:u}),e[6]=u,e[7]=m):m=e[7];let T;e[8]!==l?(T=l("Input tokens"),e[8]=l,e[9]=T):T=e[9];let v;e[10]!==T?(v=r(_,{className:"text-end",children:T}),e[10]=T,e[11]=v):v=e[11];let k;e[12]!==l?(k=l("Output tokens"),e[12]=l,e[13]=k):k=e[13];let C;e[14]!==k?(C=r(_,{className:"text-end",children:k}),e[14]=k,e[15]=C):C=e[15];let y;e[16]!==l?(y=l("Cost"),e[16]=l,e[17]=y):y=e[17];let d;e[18]!==y?(d=r(_,{className:"text-end",children:y}),e[18]=y,e[19]=d):d=e[19];let b;e[20]!==d||e[21]!==a||e[22]!==m||e[23]!==v||e[24]!==C?(b=r(oe,{children:I(R,{children:[a,m,v,C,d]})}),e[20]=d,e[21]=a,e[22]=m,e[23]=v,e[24]=C,e[25]=b):b=e[25];let p;if(e[26]!==n||e[27]!==t){let x;e[29]!==t?(x=S=>I(R,{"data-testid":`${t}-row`,children:[r(M,{className:"max-w-[280px] truncate font-mono",title:S.key,children:S.key}),r(M,{className:"text-end tabular-nums",children:O(S.calls)}),r(M,{className:"text-end tabular-nums",children:O(S.inputTokens)}),r(M,{className:"text-end tabular-nums",children:O(S.outputTokens)}),r(M,{className:"text-end",children:r(V,{provenance:ae(S),value:F(S)})})]},S.key),e[29]=t,e[30]=x):x=e[30],p=n.map(x),e[26]=n,e[27]=t,e[28]=p}else p=e[28];let f;e[31]!==p?(f=r(ne,{children:p}),e[31]=p,e[32]=f):f=e[32];let h;e[33]!==b||e[34]!==f?(h=I(re,{children:[b,f]}),e[33]=b,e[34]=f,e[35]=h):h=e[35];let g;return e[36]!==i||e[37]!==h||e[38]!==t?(g=I(D,{className:"gap-0 py-0","data-testid":t,children:[i,h]}),e[36]=i,e[37]=h,e[38]=t,e[39]=g):g=e[39],g},Pe=o=>{const e=E(55),{calls:s,onOpenTrace:n}=o,t=w();let c;e[0]!==t?(c=t("Recent calls"),e[0]=t,e[1]=c):c=e[1];let l;e[2]!==c?(l=r(te,{className:"px-4 py-3",children:r(se,{children:c})}),e[2]=c,e[3]=l):l=e[3];let i;e[4]!==t?(i=t("When"),e[4]=t,e[5]=i):i=e[5];let a;e[6]!==i?(a=r(_,{children:i}),e[6]=i,e[7]=a):a=e[7];let u;e[8]!==t?(u=t("Function"),e[8]=t,e[9]=u):u=e[9];let m;e[10]!==u?(m=r(_,{children:u}),e[10]=u,e[11]=m):m=e[11];let T;e[12]!==t?(T=t("Model"),e[12]=t,e[13]=T):T=e[13];let v;e[14]!==T?(v=r(_,{children:T}),e[14]=T,e[15]=v):v=e[15];let k;e[16]!==t?(k=t("Input tokens"),e[16]=t,e[17]=k):k=e[17];let C;e[18]!==k?(C=r(_,{className:"text-end",children:k}),e[18]=k,e[19]=C):C=e[19];let y;e[20]!==t?(y=t("Output tokens"),e[20]=t,e[21]=y):y=e[21];let d;e[22]!==y?(d=r(_,{className:"text-end",children:y}),e[22]=y,e[23]=d):d=e[23];let b;e[24]!==t?(b=t("Cost"),e[24]=t,e[25]=b):b=e[25];let p;e[26]!==b?(p=r(_,{className:"text-end",children:b}),e[26]=b,e[27]=p):p=e[27];let f;e[28]!==t?(f=t("Trace"),e[28]=t,e[29]=f):f=e[29];let h;e[30]!==f?(h=r(_,{children:f}),e[30]=f,e[31]=h):h=e[31];let g;e[32]!==C||e[33]!==d||e[34]!==p||e[35]!==h||e[36]!==a||e[37]!==m||e[38]!==v?(g=r(oe,{children:I(R,{children:[a,m,v,C,d,p,h]})}),e[32]=C,e[33]=d,e[34]=p,e[35]=h,e[36]=a,e[37]=m,e[38]=v,e[39]=g):g=e[39];let x;if(e[40]!==s||e[41]!==n||e[42]!==t){let U;e[44]!==n||e[45]!==t?(U=N=>I(R,{"data-testid":"ai-call",children:[r(M,{className:"font-mono text-muted-foreground",children:Te(N.startTs)}),r(M,{className:"font-mono",children:I("span",{className:"inline-flex items-center gap-2",children:[N.functionPath,N.streaming?r(B,{variant:"outline",children:t("stream")}):null,N.ok?null:r(B,{variant:"destructive",children:t("failed")})]})}),r(M,{className:"max-w-[240px] truncate font-mono",title:N.model,children:N.model}),r(M,{className:"text-end tabular-nums",children:N.inputTokens===void 0?"—":O(N.inputTokens)}),r(M,{className:"text-end tabular-nums",children:N.outputTokens===void 0?"—":O(N.outputTokens)}),r(M,{className:"text-end",children:r(V,{provenance:N.cost===void 0?"none":N.costSource??"estimated",value:N.cost??0})}),r(M,{children:r("button",{className:"font-mono text-muted-foreground underline-offset-2 hover:underline",onClick:()=>{n(N.traceId)},title:t("Open the trace {trace}",{trace:N.traceId}),type:"button",children:N.traceId.slice(0,8)})})]},`${N.traceId}:${N.startTs.toString()}:${N.model}`),e[44]=n,e[45]=t,e[46]=U):U=e[46],x=s.slice(0,we).map(U),e[40]=s,e[41]=n,e[42]=t,e[43]=x}else x=e[43];let S;e[47]!==x?(S=r(ne,{children:x}),e[47]=x,e[48]=S):S=e[48];let A;e[49]!==g||e[50]!==S?(A=I(re,{children:[g,S]}),e[49]=g,e[50]=S,e[51]=A):A=e[51];let P;return e[52]!==l||e[53]!==A?(P=I(D,{className:"gap-0 py-0","data-testid":"ai-calls",children:[l,A]}),e[52]=l,e[53]=A,e[54]=P):P=e[54],P},Ue=o=>{const e=E(48),{totals:s,trend:n}=o,t=w();let c;e[0]!==s?(c=ae(s),e[0]=s,e[1]=c):c=e[1];const l=c;let i;e[2]!==t||e[3]!==n?(i=n.length>=2?r(ve,{ariaLabel:t("Cost per minute"),className:"h-7 w-24",series:n,testId:"ai-trend"}):void 0,e[2]=t,e[3]=n,e[4]=i):i=e[4];let a;e[5]!==l||e[6]!==t||e[7]!==s.estimatedCost||e[8]!==s.providerCost?(a=l==="none"?t("No cost reported"):r("span",{"data-testid":"ai-cost-split",children:t("{provider} provider-reported · {estimated} estimated",{estimated:$(s.estimatedCost),provider:$(s.providerCost)})}),e[5]=l,e[6]=t,e[7]=s.estimatedCost,e[8]=s.providerCost,e[9]=a):a=e[9];let u;e[10]!==t?(u=t("Total cost"),e[10]=t,e[11]=u):u=e[11];let m;e[12]!==s?(m=F(s),e[12]=s,e[13]=m):m=e[13];let T;e[14]!==l||e[15]!==m?(T=r(V,{provenance:l,value:m}),e[14]=l,e[15]=m,e[16]=T):T=e[16];let v;e[17]!==i||e[18]!==a||e[19]!==u||e[20]!==T?(v=r(K,{chart:i,footer:a,label:u,testId:"ai-total-cost",value:T}),e[17]=i,e[18]=a,e[19]=u,e[20]=T,e[21]=v):v=e[21];let k;e[22]!==t?(k=t("Input tokens"),e[22]=t,e[23]=k):k=e[23];let C;e[24]!==s.inputTokens?(C=O(s.inputTokens),e[24]=s.inputTokens,e[25]=C):C=e[25];let y;e[26]!==k||e[27]!==C?(y=r(K,{label:k,testId:"ai-input-tokens",value:C}),e[26]=k,e[27]=C,e[28]=y):y=e[28];let d;e[29]!==t?(d=t("Output tokens"),e[29]=t,e[30]=d):d=e[30];let b;e[31]!==s.outputTokens?(b=O(s.outputTokens),e[31]=s.outputTokens,e[32]=b):b=e[32];let p;e[33]!==d||e[34]!==b?(p=r(K,{label:d,testId:"ai-output-tokens",value:b}),e[33]=d,e[34]=b,e[35]=p):p=e[35];let f;e[36]!==t?(f=t("Calls"),e[36]=t,e[37]=f):f=e[37];let h;e[38]!==s.calls?(h=O(s.calls),e[38]=s.calls,e[39]=h):h=e[39];let g;e[40]!==f||e[41]!==h?(g=r(K,{label:f,testId:"ai-calls-total",value:h}),e[40]=f,e[41]=h,e[42]=g):g=e[42];let x;return e[43]!==y||e[44]!==p||e[45]!==g||e[46]!==v?(x=I("dl",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"ai-totals",children:[v,y,p,g]}),e[43]=y,e[44]=p,e[45]=g,e[46]=v,e[47]=x):x=e[47],x},Ze=o=>{const e=E(28),{initialShardKey:s}=o,n=w(),{queryShardKey:t,setShardKey:c,shardKey:l}=he(s),i=fe(t);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let u;e[1]!==t?(u={live:!0,shardKey:t},e[1]=t,e[2]=u):u=e[2];const{data:m,error:T}=X(z.getTraces,a,u);let v;e[3]===Symbol.for("react.memo_cache_sentinel")?(v={},e[3]=v):v=e[3];let k;e[4]!==t?(k={live:!0,shardKey:t},e[4]=t,e[5]=k):k=e[5];const{data:C}=X(z.getMetricHistory,v,k);let y,d;e[6]!==m||e[7]!==C?(d=Ae(C,Ee(m)),y=d.trend.map(Ke),e[6]=m,e[7]=C,e[8]=y,e[9]=d):(y=e[8],d=e[9]);const b=y;let p;e[10]!==c||e[11]!==l?(p=r(ue,{onChange:c,testId:"ai-shard-input",value:l}),e[10]=c,e[11]=l,e[12]=p):p=e[12];let f;e[13]!==T?(f=T===null?null:r(de,{error:T,testId:"ai-error"}),e[13]=T,e[14]=f):f=e[14];let h;e[15]!==i||e[16]!==n||e[17]!==b||e[18]!==d.byFunction||e[19]!==d.byModel||e[20]!==d.calls||e[21]!==d.source||e[22]!==d.totals?(h=d.source==="none"?r(pe,{description:n("Spend shows up here once an action calls ctx.ai.model(...) — tokens and cost per function and per model."),testId:"ai-empty",title:n("No AI usage recorded")}):I(ke,{children:[d.source==="live"?r("p",{className:"text-xs text-muted-foreground","data-testid":"ai-live-only",children:n("No durable history yet — these totals come from the live trace ring and reset when the shard hibernates.")}):r("p",{className:"text-xs text-muted-foreground","data-testid":"ai-window",children:n("Totals cover the retained metric history (up to the last 24 hours).")}),r(Ue,{totals:d.totals,trend:b}),I("div",{className:"grid gap-3 xl:grid-cols-2",children:[r(ee,{keyLabel:n("Function"),rows:d.byFunction,testId:"ai-by-function",title:n("By function")}),r(ee,{keyLabel:n("Model"),rows:d.byModel,testId:"ai-by-model",title:n("By model")})]}),d.calls.length===0?r(D,{children:r(me,{className:"p-4 text-xs text-muted-foreground","data-testid":"ai-no-calls",children:n("No recent calls in the live trace ring — it empties when the shard hibernates.")})}):r(Pe,{calls:d.calls,onOpenTrace:i})]}),e[15]=i,e[16]=n,e[17]=b,e[18]=d.byFunction,e[19]=d.byModel,e[20]=d.calls,e[21]=d.source,e[22]=d.totals,e[23]=h):h=e[23];let g;return e[24]!==p||e[25]!==f||e[26]!==h?(g=I("section",{className:"flex flex-col gap-4","data-testid":"ai-panel",children:[p,f,h]}),e[24]=p,e[25]=f,e[26]=h,e[27]=g):g=e[27],g};function Ke(o){return o.providerCost+o.estimatedCost}export{Ze as default};
|
|
1
|
+
import{c as E}from"react/compiler-runtime";import{E as de}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{ShardInput as ue}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{S as K}from"../packem_shared/stat-card-BAv73QtB.mjs";import{B}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as D,a as me,b as te,c as se}from"../packem_shared/card-By2O8ULa.mjs";import{E as pe}from"../packem_shared/empty-state-D7jEML_T.mjs";import{c as _,a as oe,b as R,e as M,d as ne,T as re}from"../packem_shared/table-D0SBiDu-.mjs";import{u as X}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{u as fe}from"../packem_shared/use-open-trace-B_0LbTD7.mjs";import{u as he}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as w}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as z}from"../packem_shared/ADMIN_FUNCTIONS-4aGsMs95.mjs";import{h as Te}from"../packem_shared/internal-BXEjuLPN.mjs";import{f as $,a as O}from"../packem_shared/metrics-format-1sNGG47R.mjs";import{S as ve}from"../packem_shared/sparkline-B_sPPO_8.mjs";import{jsx as r,jsxs as I,Fragment as ke}from"react/jsx-runtime";const H="gen_ai.usage.input_tokens",W="gen_ai.usage.output_tokens",j="gen_ai.usage.cost",ie="gen_ai.request.model",ye="lunora.usage.cost.source",Ce=new Set(["ai.embed","ai.generate","ai.stream"]),G=6e4,be=1440,le="unknown",q=()=>({calls:0,estimatedCost:0,inputTokens:0,outputTokens:0,providerCost:0}),J=(o,e)=>{const s=o?.[e];return typeof s=="string"&&s!==""?s:void 0},L=(o,e)=>{const s=o?.[e];return typeof s=="number"&&Number.isFinite(s)?s:void 0},Q=o=>J(o,ye)==="provider"?"provider":"estimated",Y=(o,e)=>o.reduce((s,n)=>s+e(n),0),F=o=>o.providerCost+o.estimatedCost,ae=o=>o.estimatedCost>0?o.providerCost>0?"mixed":"estimated":o.providerCost>0?"provider":"none",ce=(o,e)=>({calls:o.calls+e.calls,estimatedCost:o.estimatedCost+e.estimatedCost,inputTokens:o.inputTokens+e.inputTokens,outputTokens:o.outputTokens+e.outputTokens,providerCost:o.providerCost+e.providerCost}),ge=o=>{const e=q();let s=0,n=0,t=0;for(const c of o){const l=Y(c.points,a=>a.sum),i=Y(c.points,a=>a.count);c.name===H?(e.inputTokens+=l,s+=i):c.name===W?(e.outputTokens+=l,n+=i):(t+=i,Q(c.attributes)==="provider"?e.providerCost+=l:e.estimatedCost+=l)}return e.calls=Math.max(s,n,t),e},Ne=(o,e)=>F(e)-F(o)||e.inputTokens+e.outputTokens-(o.inputTokens+o.outputTokens)||o.key.localeCompare(e.key),Z=(o,e)=>{const s=new Map;for(const n of o){const t=e(n);s.set(t,{key:t,...ce(s.get(t)??q(),n)})}return[...s.values()].toSorted(Ne)},xe=o=>(o?.series??[]).filter(e=>e.name===H||e.name===W||e.name===j),Se=o=>J(o.attributes,ie)??le,Ie=o=>{const e=new Map;for(const s of o){const n=Se(s),t=JSON.stringify([s.functionPath,n]),c=e.get(t)??{functionPath:s.functionPath,model:n,series:[]};c.series.push(s),e.set(t,c)}return[...e.values()].map(({functionPath:s,model:n,series:t})=>({functionPath:s,model:n,...ge(t)}))},_e=o=>{const e=new Map;for(const i of o){if(i.name!==j)continue;const a=Q(i.attributes)==="provider";for(const u of i.points){const m=e.get(u.bucketMs)??{bucketMs:u.bucketMs,estimatedCost:0,providerCost:0};a?m.providerCost+=u.sum:m.estimatedCost+=u.sum,e.set(u.bucketMs,m)}}const s=[...e.keys()].toSorted((i,a)=>i-a),n=s[0],t=s.at(-1);if(n===void 0||t===void 0)return[];const c=Math.max(n,t-(be-1)*G),l=[];for(let i=c;i<=t;i+=G)l.push(e.get(i)??{bucketMs:i,estimatedCost:0,providerCost:0});return l},Me=o=>{const e=[];for(const s of o)for(const n of s.spans){if(!Ce.has(n.name))continue;const{attributes:t}=n,c=L(t,j),l=L(t,H),i=L(t,W);e.push({...c===void 0?{}:{cost:c,costSource:Q(t)},functionPath:s.functionPath,...l===void 0?{}:{inputTokens:l},model:J(t,ie)??le,ok:n.ok,...i===void 0?{}:{outputTokens:i},startTs:s.startTs+n.offsetMs,streaming:n.name==="ai.stream",traceId:s.traceId})}return e.toSorted((s,n)=>n.startTs-s.startTs)},Oe=o=>o.map(e=>{const s=e.cost??0;return{calls:1,estimatedCost:e.costSource==="provider"?0:s,functionPath:e.functionPath,inputTokens:e.inputTokens??0,model:e.model,outputTokens:e.outputTokens??0,providerCost:e.costSource==="provider"?s:0}}),Ae=(o,e)=>{const s=xe(o),n=Me(e),t=s.length>0,c=t?Ie(s):Oe(n);let l=q(),i="none";for(const a of c)l=ce(l,a);return t?i="history":n.length>0&&(i="live"),{byFunction:Z(c,a=>a.functionPath),byModel:Z(c,a=>a.model),calls:n,source:i,totals:l,trend:t?_e(s):[]}},Ee=o=>Array.isArray(o?.traces)?o.traces:[],we=25,V=o=>{const e=E(16),{provenance:s,value:n}=o,t=w();if(s==="none"){let m;return e[0]===Symbol.for("react.memo_cache_sentinel")?(m=r("span",{className:"text-muted-foreground",children:"—"}),e[0]=m):m=e[0],m}let c;e[1]!==s||e[2]!==n?(c=s==="provider"?$(n):`~${$(n)}`,e[1]=s,e[2]=n,e[3]=c):c=e[3];let l;e[4]!==c?(l=r("span",{className:"tabular-nums",children:c}),e[4]=c,e[5]=l):l=e[5];let i;e[6]!==s||e[7]!==t?(i=s==="estimated"?r(B,{title:t("Derived from a price table, not reported by the provider."),variant:"warning",children:t("Estimated")}):null,e[6]=s,e[7]=t,e[8]=i):i=e[8];let a;e[9]!==s||e[10]!==t?(a=s==="mixed"?r(B,{title:t("Includes cost derived from a price table, not reported by the provider."),variant:"warning",children:t("Partly estimated")}):null,e[9]=s,e[10]=t,e[11]=a):a=e[11];let u;return e[12]!==l||e[13]!==i||e[14]!==a?(u=I("span",{className:"inline-flex items-center gap-2",children:[l,i,a]}),e[12]=l,e[13]=i,e[14]=a,e[15]=u):u=e[15],u},ee=o=>{const e=E(40),{keyLabel:s,rows:n,testId:t,title:c}=o,l=w();let i;e[0]!==c?(i=r(te,{className:"px-4 py-3",children:r(se,{children:c})}),e[0]=c,e[1]=i):i=e[1];let a;e[2]!==s?(a=r(_,{children:s}),e[2]=s,e[3]=a):a=e[3];let u;e[4]!==l?(u=l("Calls"),e[4]=l,e[5]=u):u=e[5];let m;e[6]!==u?(m=r(_,{className:"text-end",children:u}),e[6]=u,e[7]=m):m=e[7];let T;e[8]!==l?(T=l("Input tokens"),e[8]=l,e[9]=T):T=e[9];let v;e[10]!==T?(v=r(_,{className:"text-end",children:T}),e[10]=T,e[11]=v):v=e[11];let k;e[12]!==l?(k=l("Output tokens"),e[12]=l,e[13]=k):k=e[13];let C;e[14]!==k?(C=r(_,{className:"text-end",children:k}),e[14]=k,e[15]=C):C=e[15];let y;e[16]!==l?(y=l("Cost"),e[16]=l,e[17]=y):y=e[17];let d;e[18]!==y?(d=r(_,{className:"text-end",children:y}),e[18]=y,e[19]=d):d=e[19];let b;e[20]!==d||e[21]!==a||e[22]!==m||e[23]!==v||e[24]!==C?(b=r(oe,{children:I(R,{children:[a,m,v,C,d]})}),e[20]=d,e[21]=a,e[22]=m,e[23]=v,e[24]=C,e[25]=b):b=e[25];let p;if(e[26]!==n||e[27]!==t){let x;e[29]!==t?(x=S=>I(R,{"data-testid":`${t}-row`,children:[r(M,{className:"max-w-[280px] truncate font-mono",title:S.key,children:S.key}),r(M,{className:"text-end tabular-nums",children:O(S.calls)}),r(M,{className:"text-end tabular-nums",children:O(S.inputTokens)}),r(M,{className:"text-end tabular-nums",children:O(S.outputTokens)}),r(M,{className:"text-end",children:r(V,{provenance:ae(S),value:F(S)})})]},S.key),e[29]=t,e[30]=x):x=e[30],p=n.map(x),e[26]=n,e[27]=t,e[28]=p}else p=e[28];let f;e[31]!==p?(f=r(ne,{children:p}),e[31]=p,e[32]=f):f=e[32];let h;e[33]!==b||e[34]!==f?(h=I(re,{children:[b,f]}),e[33]=b,e[34]=f,e[35]=h):h=e[35];let g;return e[36]!==i||e[37]!==h||e[38]!==t?(g=I(D,{className:"gap-0 py-0","data-testid":t,children:[i,h]}),e[36]=i,e[37]=h,e[38]=t,e[39]=g):g=e[39],g},Pe=o=>{const e=E(55),{calls:s,onOpenTrace:n}=o,t=w();let c;e[0]!==t?(c=t("Recent calls"),e[0]=t,e[1]=c):c=e[1];let l;e[2]!==c?(l=r(te,{className:"px-4 py-3",children:r(se,{children:c})}),e[2]=c,e[3]=l):l=e[3];let i;e[4]!==t?(i=t("When"),e[4]=t,e[5]=i):i=e[5];let a;e[6]!==i?(a=r(_,{children:i}),e[6]=i,e[7]=a):a=e[7];let u;e[8]!==t?(u=t("Function"),e[8]=t,e[9]=u):u=e[9];let m;e[10]!==u?(m=r(_,{children:u}),e[10]=u,e[11]=m):m=e[11];let T;e[12]!==t?(T=t("Model"),e[12]=t,e[13]=T):T=e[13];let v;e[14]!==T?(v=r(_,{children:T}),e[14]=T,e[15]=v):v=e[15];let k;e[16]!==t?(k=t("Input tokens"),e[16]=t,e[17]=k):k=e[17];let C;e[18]!==k?(C=r(_,{className:"text-end",children:k}),e[18]=k,e[19]=C):C=e[19];let y;e[20]!==t?(y=t("Output tokens"),e[20]=t,e[21]=y):y=e[21];let d;e[22]!==y?(d=r(_,{className:"text-end",children:y}),e[22]=y,e[23]=d):d=e[23];let b;e[24]!==t?(b=t("Cost"),e[24]=t,e[25]=b):b=e[25];let p;e[26]!==b?(p=r(_,{className:"text-end",children:b}),e[26]=b,e[27]=p):p=e[27];let f;e[28]!==t?(f=t("Trace"),e[28]=t,e[29]=f):f=e[29];let h;e[30]!==f?(h=r(_,{children:f}),e[30]=f,e[31]=h):h=e[31];let g;e[32]!==C||e[33]!==d||e[34]!==p||e[35]!==h||e[36]!==a||e[37]!==m||e[38]!==v?(g=r(oe,{children:I(R,{children:[a,m,v,C,d,p,h]})}),e[32]=C,e[33]=d,e[34]=p,e[35]=h,e[36]=a,e[37]=m,e[38]=v,e[39]=g):g=e[39];let x;if(e[40]!==s||e[41]!==n||e[42]!==t){let U;e[44]!==n||e[45]!==t?(U=N=>I(R,{"data-testid":"ai-call",children:[r(M,{className:"font-mono text-muted-foreground",children:Te(N.startTs)}),r(M,{className:"font-mono",children:I("span",{className:"inline-flex items-center gap-2",children:[N.functionPath,N.streaming?r(B,{variant:"outline",children:t("stream")}):null,N.ok?null:r(B,{variant:"destructive",children:t("failed")})]})}),r(M,{className:"max-w-[240px] truncate font-mono",title:N.model,children:N.model}),r(M,{className:"text-end tabular-nums",children:N.inputTokens===void 0?"—":O(N.inputTokens)}),r(M,{className:"text-end tabular-nums",children:N.outputTokens===void 0?"—":O(N.outputTokens)}),r(M,{className:"text-end",children:r(V,{provenance:N.cost===void 0?"none":N.costSource??"estimated",value:N.cost??0})}),r(M,{children:r("button",{className:"font-mono text-muted-foreground underline-offset-2 hover:underline",onClick:()=>{n(N.traceId)},title:t("Open the trace {trace}",{trace:N.traceId}),type:"button",children:N.traceId.slice(0,8)})})]},`${N.traceId}:${N.startTs.toString()}:${N.model}`),e[44]=n,e[45]=t,e[46]=U):U=e[46],x=s.slice(0,we).map(U),e[40]=s,e[41]=n,e[42]=t,e[43]=x}else x=e[43];let S;e[47]!==x?(S=r(ne,{children:x}),e[47]=x,e[48]=S):S=e[48];let A;e[49]!==g||e[50]!==S?(A=I(re,{children:[g,S]}),e[49]=g,e[50]=S,e[51]=A):A=e[51];let P;return e[52]!==l||e[53]!==A?(P=I(D,{className:"gap-0 py-0","data-testid":"ai-calls",children:[l,A]}),e[52]=l,e[53]=A,e[54]=P):P=e[54],P},Ue=o=>{const e=E(48),{totals:s,trend:n}=o,t=w();let c;e[0]!==s?(c=ae(s),e[0]=s,e[1]=c):c=e[1];const l=c;let i;e[2]!==t||e[3]!==n?(i=n.length>=2?r(ve,{ariaLabel:t("Cost per minute"),className:"h-7 w-24",series:n,testId:"ai-trend"}):void 0,e[2]=t,e[3]=n,e[4]=i):i=e[4];let a;e[5]!==l||e[6]!==t||e[7]!==s.estimatedCost||e[8]!==s.providerCost?(a=l==="none"?t("No cost reported"):r("span",{"data-testid":"ai-cost-split",children:t("{provider} provider-reported · {estimated} estimated",{estimated:$(s.estimatedCost),provider:$(s.providerCost)})}),e[5]=l,e[6]=t,e[7]=s.estimatedCost,e[8]=s.providerCost,e[9]=a):a=e[9];let u;e[10]!==t?(u=t("Total cost"),e[10]=t,e[11]=u):u=e[11];let m;e[12]!==s?(m=F(s),e[12]=s,e[13]=m):m=e[13];let T;e[14]!==l||e[15]!==m?(T=r(V,{provenance:l,value:m}),e[14]=l,e[15]=m,e[16]=T):T=e[16];let v;e[17]!==i||e[18]!==a||e[19]!==u||e[20]!==T?(v=r(K,{chart:i,footer:a,label:u,testId:"ai-total-cost",value:T}),e[17]=i,e[18]=a,e[19]=u,e[20]=T,e[21]=v):v=e[21];let k;e[22]!==t?(k=t("Input tokens"),e[22]=t,e[23]=k):k=e[23];let C;e[24]!==s.inputTokens?(C=O(s.inputTokens),e[24]=s.inputTokens,e[25]=C):C=e[25];let y;e[26]!==k||e[27]!==C?(y=r(K,{label:k,testId:"ai-input-tokens",value:C}),e[26]=k,e[27]=C,e[28]=y):y=e[28];let d;e[29]!==t?(d=t("Output tokens"),e[29]=t,e[30]=d):d=e[30];let b;e[31]!==s.outputTokens?(b=O(s.outputTokens),e[31]=s.outputTokens,e[32]=b):b=e[32];let p;e[33]!==d||e[34]!==b?(p=r(K,{label:d,testId:"ai-output-tokens",value:b}),e[33]=d,e[34]=b,e[35]=p):p=e[35];let f;e[36]!==t?(f=t("Calls"),e[36]=t,e[37]=f):f=e[37];let h;e[38]!==s.calls?(h=O(s.calls),e[38]=s.calls,e[39]=h):h=e[39];let g;e[40]!==f||e[41]!==h?(g=r(K,{label:f,testId:"ai-calls-total",value:h}),e[40]=f,e[41]=h,e[42]=g):g=e[42];let x;return e[43]!==y||e[44]!==p||e[45]!==g||e[46]!==v?(x=I("dl",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"ai-totals",children:[v,y,p,g]}),e[43]=y,e[44]=p,e[45]=g,e[46]=v,e[47]=x):x=e[47],x},Ze=o=>{const e=E(28),{initialShardKey:s}=o,n=w(),{queryShardKey:t,setShardKey:c,shardKey:l}=he(s),i=fe(t);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let u;e[1]!==t?(u={live:!0,shardKey:t},e[1]=t,e[2]=u):u=e[2];const{data:m,error:T}=X(z.getTraces,a,u);let v;e[3]===Symbol.for("react.memo_cache_sentinel")?(v={},e[3]=v):v=e[3];let k;e[4]!==t?(k={live:!0,shardKey:t},e[4]=t,e[5]=k):k=e[5];const{data:C}=X(z.getMetricHistory,v,k);let y,d;e[6]!==m||e[7]!==C?(d=Ae(C,Ee(m)),y=d.trend.map(Ke),e[6]=m,e[7]=C,e[8]=y,e[9]=d):(y=e[8],d=e[9]);const b=y;let p;e[10]!==c||e[11]!==l?(p=r(ue,{onChange:c,testId:"ai-shard-input",value:l}),e[10]=c,e[11]=l,e[12]=p):p=e[12];let f;e[13]!==T?(f=T===null?null:r(de,{error:T,testId:"ai-error"}),e[13]=T,e[14]=f):f=e[14];let h;e[15]!==i||e[16]!==n||e[17]!==b||e[18]!==d.byFunction||e[19]!==d.byModel||e[20]!==d.calls||e[21]!==d.source||e[22]!==d.totals?(h=d.source==="none"?r(pe,{description:n("Spend shows up here once an action calls ctx.ai.model(...) — tokens and cost per function and per model."),testId:"ai-empty",title:n("No AI usage recorded")}):I(ke,{children:[d.source==="live"?r("p",{className:"text-xs text-muted-foreground","data-testid":"ai-live-only",children:n("No durable history yet — these totals come from the live trace ring and reset when the shard hibernates.")}):r("p",{className:"text-xs text-muted-foreground","data-testid":"ai-window",children:n("Totals cover the retained metric history (up to the last 24 hours).")}),r(Ue,{totals:d.totals,trend:b}),I("div",{className:"grid gap-3 xl:grid-cols-2",children:[r(ee,{keyLabel:n("Function"),rows:d.byFunction,testId:"ai-by-function",title:n("By function")}),r(ee,{keyLabel:n("Model"),rows:d.byModel,testId:"ai-by-model",title:n("By model")})]}),d.calls.length===0?r(D,{children:r(me,{className:"p-4 text-xs text-muted-foreground","data-testid":"ai-no-calls",children:n("No recent calls in the live trace ring — it empties when the shard hibernates.")})}):r(Pe,{calls:d.calls,onOpenTrace:i})]}),e[15]=i,e[16]=n,e[17]=b,e[18]=d.byFunction,e[19]=d.byModel,e[20]=d.calls,e[21]=d.source,e[22]=d.totals,e[23]=h):h=e[23];let g;return e[24]!==p||e[25]!==f||e[26]!==h?(g=I("section",{className:"flex flex-col gap-4","data-testid":"ai-panel",children:[p,f,h]}),e[24]=p,e[25]=f,e[26]=h,e[27]=g):g=e[27],g};function Ke(o){return o.providerCost+o.estimatedCost}export{Ze as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as R}from"react/compiler-runtime";import{useState as k}from"react";import{E as q}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{B as j}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as z}from"../packem_shared/button-q0UYSmrn.mjs";import{C as D,a as M}from"../packem_shared/card-By2O8ULa.mjs";import{E as O}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as Q}from"../packem_shared/input-CXhxesPC.mjs";import{T as U,a as $,b as F,c as N,d as G,e as w}from"../packem_shared/table-D0SBiDu-.mjs";import{u as J}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{useT as K}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as V}from"../packem_shared/ADMIN_FUNCTIONS-
|
|
1
|
+
import{c as R}from"react/compiler-runtime";import{useState as k}from"react";import{E as q}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{B as j}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as z}from"../packem_shared/button-q0UYSmrn.mjs";import{C as D,a as M}from"../packem_shared/card-By2O8ULa.mjs";import{E as O}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as Q}from"../packem_shared/input-CXhxesPC.mjs";import{T as U,a as $,b as F,c as N,d as G,e as w}from"../packem_shared/table-D0SBiDu-.mjs";import{u as J}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{useT as K}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as V}from"../packem_shared/ADMIN_FUNCTIONS-4aGsMs95.mjs";import{h as W}from"../packem_shared/internal-BXEjuLPN.mjs";import{jsx as a,jsxs as l}from"react/jsx-runtime";const ne=()=>{const e=R(39),t=K(),[o,H]=k("");let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const{data:L,error:i,errorSource:S,isLoading:E,refetch:B}=J(V.getAuthAuditLog,b);let A;if(e[1]!==L?.entries||e[2]!==o){const r=L?.entries??[],x=o.trim().toLowerCase();A=x===""?r:r.filter(C=>C.event.toLowerCase().includes(x)||(C.actorId??"").toLowerCase().includes(x)||(C.actorEmail??"").toLowerCase().includes(x)||(C.ip??"").toLowerCase().includes(x)||C.outcome.toLowerCase().includes(x)),e[1]=L?.entries,e[2]=o,e[3]=A}else A=e[3];const s=A;let I;e[4]===Symbol.for("react.memo_cache_sentinel")?(I=r=>{H(r.target.value)},e[4]=I):I=e[4];const P=I;let c;e[5]!==t?(c=t("Filter security events"),e[5]=t,e[6]=c):c=e[6];let n;e[7]!==t?(n=t("filter event, actor, IP"),e[7]=t,e[8]=n):n=e[8];let d;e[9]!==o||e[10]!==c||e[11]!==n?(d=a(Q,{"aria-label":c,className:"h-8 w-56","data-testid":"aa-search",onChange:P,placeholder:n,value:o}),e[9]=o,e[10]=c,e[11]=n,e[12]=d):d=e[12];let m;e[13]!==B?(m=()=>{B()},e[13]=B,e[14]=m):m=e[14];let u;e[15]!==t?(u=t("Refresh"),e[15]=t,e[16]=u):u=e[16];let h;e[17]!==m||e[18]!==u?(h=a(z,{"data-testid":"aa-refresh",onClick:m,size:"xs",type:"button",variant:"ghost",children:u}),e[17]=m,e[18]=u,e[19]=h):h=e[19];let f;e[20]!==d||e[21]!==h?(f=l("div",{className:"flex flex-wrap items-center gap-2",children:[d,h]}),e[20]=d,e[21]=h,e[22]=f):f=e[22];let p;e[23]!==i||e[24]!==S?(p=i!==null&&a(q,{error:S,testId:"aa-error"}),e[23]=i,e[24]=S,e[25]=p):p=e[25];let g;e[26]!==i||e[27]!==s.length||e[28]!==E||e[29]!==t?(g=i===null&&!E&&s.length===0&&a(O,{description:t("Authentication and security events are recorded here."),testId:"aa-empty",title:t("No security events.")}),e[26]=i,e[27]=s.length,e[28]=E,e[29]=t,e[30]=g):g=e[30];let v;e[31]!==s||e[32]!==t?(v=s.length>0&&a(D,{className:"overflow-hidden py-0",children:a(M,{className:"max-h-[30rem] overflow-auto px-0",children:l(U,{"data-testid":"aa-table",children:[a($,{children:l(F,{children:[a(N,{children:t("time")}),a(N,{children:t("event")}),a(N,{children:t("actor")}),a(N,{children:t("ip / user agent")}),a(N,{children:t("outcome")})]})}),a(G,{children:s.map(r=>l(F,{"data-testid":"aa-row",children:[a(w,{className:"text-muted-foreground tabular-nums",children:W(r.ts,"—")}),a(w,{children:a(j,{variant:"secondary",children:r.event})}),a(w,{className:"max-w-[24ch] truncate font-mono text-xs",title:r.actorId??void 0,children:r.actorEmail??r.actorId??a("span",{className:"text-muted-foreground",children:"—"})}),l(w,{className:"max-w-[28ch] truncate text-xs text-muted-foreground",title:r.userAgent??void 0,children:[r.ip??a("span",{className:"text-muted-foreground",children:"—"}),r.userAgent!==void 0&&l("span",{className:"ml-1 opacity-70",children:["· ",r.userAgent]})]}),a(w,{children:a(j,{variant:r.outcome==="failure"?"destructive":"outline",children:t(r.outcome)})})]},r.seq))})]})})}),e[31]=s,e[32]=t,e[33]=v):v=e[33];let T;return e[34]!==p||e[35]!==g||e[36]!==v||e[37]!==f?(T=l("div",{className:"flex flex-col gap-4","data-testid":"lunora-auth-audit",children:[f,p,g,v]}),e[34]=p,e[35]=g,e[36]=v,e[37]=f,e[38]=T):T=e[38],T};export{ne as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as C}from"react/compiler-runtime";import{L as T}from"../packem_shared/live-status-D1GasNsH.mjs";import{B as b}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as E,a as A}from"../packem_shared/card-By2O8ULa.mjs";import{E as I}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as S,a as _,b as y,c as l,d as L,e as d}from"../packem_shared/table-D0SBiDu-.mjs";import{u as O}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{useT as $}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as k}from"../packem_shared/ADMIN_FUNCTIONS-
|
|
1
|
+
import{c as C}from"react/compiler-runtime";import{L as T}from"../packem_shared/live-status-D1GasNsH.mjs";import{B as b}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as E,a as A}from"../packem_shared/card-By2O8ULa.mjs";import{E as I}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as S,a as _,b as y,c as l,d as L,e as d}from"../packem_shared/table-D0SBiDu-.mjs";import{u as O}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{useT as $}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as k}from"../packem_shared/ADMIN_FUNCTIONS-4aGsMs95.mjs";import{jsxs as h,jsx as n}from"react/jsx-runtime";const g="container:",R={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},B=e=>{const t=e.indexOf(":");if(t===-1)return{event:e.trim()};const a=e.slice(t+1).trim(),s=e.slice(0,t).trim();return a===""?{event:s}:{detail:a,event:s}},D=e=>{const t=new Map;for(const a of e){const s=a.functionPath??"";if(!s.startsWith(g))continue;const i=s.slice(g.length);if(i==="")continue;const r=JSON.stringify([i,a.instance??""]),o=t.get(r);if(o!==void 0&&o.timestamp>=a.timestamp)continue;const{detail:u,event:c}=B(a.message);t.set(r,{detail:u,event:c,exitCode:a.exitCode,instance:a.instance,level:a.level,name:i,state:R[c]??"unknown",timestamp:a.timestamp})}return[...t.values()].toSorted((a,s)=>a.name.localeCompare(s.name)||(a.instance??"").localeCompare(s.instance??""))},M={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},P=e=>{const{entries:t}=e??{};return Array.isArray(t)?t:[]},q=()=>{const e=C(19),t=$();let a,s;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},s={live:!0,shardKey:""},e[0]=a,e[1]=s):(a=e[0],s=e[1]);const{data:i,error:r,liveError:o}=O(k.getLogs,a,s),u=i!==void 0;let c;if(e[2]!==i||e[3]!==r||e[4]!==o||e[5]!==u||e[6]!==t){const N=D(P(i));let x;e[8]!==r?(x=r!==null&&n("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:r}),e[8]=r,e[9]=x):x=e[9];let m;e[10]!==t?(m=t("Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per instance — ports and health checks aren't carried in that stream."),e[10]=t,e[11]=m):m=e[11];let f;e[12]!==m?(f=n("p",{className:"text-sm text-muted-foreground",children:m}),e[12]=m,e[13]=f):f=e[13];let p;e[14]!==o?(p=n(T,{message:o,prefix:"containers"}),e[14]=o,e[15]=p):p=e[15];let v;e[16]!==f||e[17]!==p?(v=h("div",{className:"flex flex-wrap items-center gap-2",children:[f,p]}),e[16]=f,e[17]=p,e[18]=v):v=e[18],c=h("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[x,v,u&&N.length===0?n(I,{description:t("No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error."),testId:"containers-empty",title:t("No container activity")}):n(E,{className:"overflow-hidden py-0",children:n(A,{className:"px-0",children:h(S,{"data-testid":"containers-table",children:[n(_,{children:h(y,{children:[n(l,{children:t("Container")}),n(l,{children:t("Instance")}),n(l,{children:t("State")}),n(l,{children:t("Last event")}),n(l,{children:t("Detail")}),n(l,{children:t("Exit")}),n(l,{children:t("When")})]})}),n(L,{children:N.map(j)})]})})})]}),e[2]=i,e[3]=r,e[4]=o,e[5]=u,e[6]=t,e[7]=c}else c=e[7];return c};function j(e){return h(y,{"data-testid":`containers-row-${e.name}${e.instance===void 0?"":`-${e.instance}`}`,children:[n(d,{className:"font-mono text-xs",children:e.name}),n(d,{className:"max-w-40 truncate font-mono text-xs text-muted-foreground",title:e.instance,children:e.instance??"—"}),n(d,{children:n(b,{variant:M[e.state],children:e.state})}),n(d,{className:"font-mono text-xs text-muted-foreground",children:e.event}),n(d,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"—"}),n(d,{className:"font-mono text-xs tabular-nums text-muted-foreground",children:e.exitCode??"—"}),n(d,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]},`${e.name}/${e.instance??""}`)}export{q as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as J}from"react/compiler-runtime";import{useState as X,useEffect as fe,useRef as ue}from"react";import{A as ne}from"../packem_shared/alert-PB5W11MM.mjs";import{B as Y}from"../packem_shared/button-q0UYSmrn.mjs";import{c as he,b as ge,a as re,C as ae}from"../packem_shared/card-By2O8ULa.mjs";import{E as me}from"../packem_shared/empty-state-D7jEML_T.mjs";import{useT as te}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{u as be,n as ve}from"../packem_shared/browser-storage-BH1MxLZs.mjs";import{c as pe,d as xe,b as Ce,f as de,l as ke}from"../packem_shared/internal-BXEjuLPN.mjs";import{u as ye}from"../packem_shared/use-sql-assistant-DXnqbBs-.mjs";import{S as we,a as Se}from"../packem_shared/sql-result-table-CatgdmMh.mjs";import{u as Ne}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{ADMIN_FUNCTIONS as Ke}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsx as d,jsxs as Z}from"react/jsx-runtime";const Re=pe(Ke.runSql),Le=(b,e)=>{const t=J(11),n=Ne(),[r,s]=X(void 0),[a,o]=X(void 0),[c,v]=X(!0);let h;t[0]!==n||t[1]!==e||t[2]!==b?(h=async f=>{v(!0);try{const y=await n.query(Re,{sql:b},xe(e));f.cancelled||(s(y),o(void 0))}catch(y){const x=y;f.cancelled||(s(void 0),o(Ce(x)))}f.cancelled||v(!1)},t[0]=n,t[1]=e,t[2]=b,t[3]=h):h=t[3];const i=h;let l,g;t[4]!==i?(l=()=>{const f={cancelled:!1};return de(i(f)),()=>{f.cancelled=!0}},g=[i],t[4]=i,t[5]=l,t[6]=g):(l=t[5],g=t[6]),fe(l,g);let N;return t[7]!==a||t[8]!==c||t[9]!==r?(N={error:a,loading:c,result:r},t[7]=a,t[8]=c,t[9]=r,t[10]=N):N=t[10],N},Me=b=>{b.preventDefault()},le=b=>b.kind??"chart",ce=b=>{const e=J(80),{actions:t,children:n,draggedRef:r,first:s,last:a,onEdit:o,onMove:c,onRemove:v,onReorder:h,widget:i}=b,l=te();let g;e[0]!==c||e[1]!==i.id?(g=()=>{c(i.id,-1)},e[0]=c,e[1]=i.id,e[2]=g):g=e[2];const N=g;let f;e[3]!==c||e[4]!==i.id?(f=()=>{c(i.id,1)},e[3]=c,e[4]=i.id,e[5]=f):f=e[5];const y=f;let x;e[6]!==o||e[7]!==i.id?(x=()=>{o(i.id)},e[6]=o,e[7]=i.id,e[8]=x):x=e[8];const q=x;let O;e[9]!==v||e[10]!==i.id?(O=()=>{v(i.id)},e[9]=v,e[10]=i.id,e[11]=O):O=e[11];const E=O;let z;e[12]!==r||e[13]!==i.id?(z=()=>{r.current=i.id},e[12]=r,e[13]=i.id,e[14]=z):z=e[14];const C=z;let K;e[15]!==r||e[16]!==h||e[17]!==i.id?(K=()=>{const se=r.current;r.current=null,se!==null&&se!==i.id&&h(se,i.id)},e[15]=r,e[16]=h,e[17]=i.id,e[18]=K):K=e[18];const W=K,S=`dashboards-widget-${i.id}`;let k;e[19]!==i.title?(k=d(he,{className:"min-w-0 cursor-grab truncate",title:i.title,children:i.title}),e[19]=i.title,e[20]=k):k=e[20];let w;e[21]!==l?(w=l("Move widget up"),e[21]=l,e[22]=w):w=e[22];const _=`dashboards-move-up-${i.id}`;let Q;e[23]!==l?(Q=l("Move widget up"),e[23]=l,e[24]=Q):Q=e[24];let B;e[25]===Symbol.for("react.memo_cache_sentinel")?(B=d("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:d("path",{d:"m6 15 6-6 6 6"})}),e[25]=B):B=e[25];let I;e[26]!==s||e[27]!==N||e[28]!==_||e[29]!==Q||e[30]!==w?(I=d(Y,{"aria-label":w,"data-testid":_,disabled:s,onClick:N,size:"icon-xs",title:Q,type:"button",variant:"ghost",children:B}),e[26]=s,e[27]=N,e[28]=_,e[29]=Q,e[30]=w,e[31]=I):I=e[31];let R;e[32]!==l?(R=l("Move widget down"),e[32]=l,e[33]=R):R=e[33];const $=`dashboards-move-down-${i.id}`;let L;e[34]!==l?(L=l("Move widget down"),e[34]=l,e[35]=L):L=e[35];let A;e[36]===Symbol.for("react.memo_cache_sentinel")?(A=d("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:d("path",{d:"m6 9 6 6 6-6"})}),e[36]=A):A=e[36];let M;e[37]!==a||e[38]!==y||e[39]!==R||e[40]!==$||e[41]!==L?(M=d(Y,{"aria-label":R,"data-testid":$,disabled:a,onClick:y,size:"icon-xs",title:L,type:"button",variant:"ghost",children:A}),e[37]=a,e[38]=y,e[39]=R,e[40]=$,e[41]=L,e[42]=M):M=e[42];let D;e[43]!==l?(D=l("Edit widget"),e[43]=l,e[44]=D):D=e[44];const j=`dashboards-widget-edit-${i.id}`;let T;e[45]!==l?(T=l("Edit widget"),e[45]=l,e[46]=T):T=e[46];let p;e[47]===Symbol.for("react.memo_cache_sentinel")?(p=d("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:d("path",{d:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"})}),e[47]=p):p=e[47];let m;e[48]!==q||e[49]!==D||e[50]!==j||e[51]!==T?(m=d(Y,{"aria-label":D,"data-testid":j,onClick:q,size:"icon-xs",title:T,type:"button",variant:"ghost",children:p}),e[48]=q,e[49]=D,e[50]=j,e[51]=T,e[52]=m):m=e[52];let u;e[53]!==l?(u=l("Remove widget"),e[53]=l,e[54]=u):u=e[54];const F=`dashboards-widget-remove-${i.id}`;let U;e[55]!==l?(U=l("Remove widget"),e[55]=l,e[56]=U):U=e[56];let V;e[57]===Symbol.for("react.memo_cache_sentinel")?(V=d("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:d("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[57]=V):V=e[57];let H;e[58]!==E||e[59]!==u||e[60]!==F||e[61]!==U?(H=d(Y,{"aria-label":u,"data-testid":F,onClick:E,size:"icon-xs",title:U,type:"button",variant:"ghost",children:V}),e[58]=E,e[59]=u,e[60]=F,e[61]=U,e[62]=H):H=e[62];let P;e[63]!==t||e[64]!==I||e[65]!==M||e[66]!==m||e[67]!==H?(P=Z("div",{className:"flex shrink-0 items-center gap-1",children:[t,I,M,m,H]}),e[63]=t,e[64]=I,e[65]=M,e[66]=m,e[67]=H,e[68]=P):P=e[68];let G;e[69]!==P||e[70]!==k?(G=Z(ge,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[k,P]}),e[69]=P,e[70]=k,e[71]=G):G=e[71];let ee;e[72]!==n?(ee=d(re,{className:"min-h-32 py-2",children:n}),e[72]=n,e[73]=ee):ee=e[73];let ie;return e[74]!==C||e[75]!==W||e[76]!==G||e[77]!==ee||e[78]!==S?(ie=Z(ae,{"data-testid":S,draggable:!0,onDragOver:Me,onDragStart:C,onDrop:W,children:[G,ee]}),e[74]=C,e[75]=W,e[76]=G,e[77]=ee,e[78]=S,e[79]=ie):ie=e[79],ie},qe=b=>{const e=J(10),{result:t}=b,n=te(),r=t.columns[0],s=r===void 0?void 0:t.rows[0]?.[r];let a;e[0]!==s||e[1]!==n?(a=s===void 0?n("—"):ke(s),e[0]=s,e[1]=n,e[2]=a):a=e[2];let o;e[3]!==a?(o=d("p",{className:"truncate font-mono text-3xl font-semibold text-foreground",children:a}),e[3]=a,e[4]=o):o=e[4];let c;e[5]!==r?(c=r!==void 0&&d("p",{className:"truncate text-xs text-muted-foreground",children:r}),e[5]=r,e[6]=c):c=e[6];let v;return e[7]!==o||e[8]!==c?(v=Z("div",{className:"flex h-full flex-col justify-center gap-1 p-4","data-testid":"dashboards-kpi",children:[o,c]}),e[7]=o,e[8]=c,e[9]=v):v=e[9],v},Ee=b=>{const e=J(12),{draggedRef:t,first:n,last:r,onEdit:s,onMove:a,onRemove:o,onReorder:c,widget:v}=b,h=v.text??"";let i;e[0]!==h?(i=d("p",{className:"p-2 text-sm whitespace-pre-wrap text-muted-foreground","data-testid":"dashboards-text",children:h}),e[0]=h,e[1]=i):i=e[1];let l;return e[2]!==t||e[3]!==n||e[4]!==r||e[5]!==s||e[6]!==a||e[7]!==o||e[8]!==c||e[9]!==i||e[10]!==v?(l=d(ce,{draggedRef:t,first:n,last:r,onEdit:s,onMove:a,onRemove:o,onReorder:c,widget:v,children:i}),e[2]=t,e[3]=n,e[4]=r,e[5]=s,e[6]=a,e[7]=o,e[8]=c,e[9]=i,e[10]=v,e[11]=l):l=e[11],l},Ae=b=>{const e=J(52),{draggedRef:t,first:n,inferring:r,last:s,onEdit:a,onMove:o,onRemove:c,onReorder:v,onSuggest:h,widget:i}=b,l=te(),{error:g,loading:N,result:f}=Le(i.sql,i.shardKey??"");let y;e[0]!==i?(y=le(i),e[0]=i,e[1]=y):y=e[1];const x=y;let q;e[2]!==h||e[3]!==f||e[4]!==i.id?(q=()=>{f!==void 0&&h?.(i.id,f)},e[2]=h,e[3]=f,e[4]=i.id,e[5]=q):q=e[5];const O=q;let E;e[6]!==r||e[7]!==x||e[8]!==h||e[9]!==O||e[10]!==f||e[11]!==l||e[12]!==i.id?(E=x==="chart"&&h!==void 0&&f!==void 0?d(Y,{"aria-label":l("Suggest chart"),"data-testid":`dashboards-widget-suggest-${i.id}`,disabled:r,onClick:O,size:"icon-xs",title:l(r?"Suggesting…":"Suggest chart"),type:"button",variant:"ghost",children:d("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:d("path",{d:"m12 3 1.9 4.6L18.5 9.5 13.9 11.4 12 16l-1.9-4.6L5.5 9.5l4.6-1.9L12 3ZM18 15l.9 2.1 2.1.9-2.1.9L18 21l-.9-2.1-2.1-.9 2.1-.9L18 15Z"})})}):void 0,e[6]=r,e[7]=x,e[8]=h,e[9]=O,e[10]=f,e[11]=l,e[12]=i.id,e[13]=E):E=e[13];const z=E;let C;e[14]!==g||e[15]!==i.id?(C=g!==void 0&&d(ne,{className:"font-mono text-xs",testId:`dashboards-widget-error-${i.id}`,variant:"destructive",children:g}),e[14]=g,e[15]=i.id,e[16]=C):C=e[16];let K;e[17]!==g||e[18]!==N||e[19]!==f||e[20]!==l||e[21]!==i.id?(K=g===void 0&&N&&f===void 0&&d("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${i.id}`,children:l("Running…")}),e[17]=g,e[18]=N,e[19]=f,e[20]=l,e[21]=i.id,e[22]=K):K=e[22];let W;e[23]!==g||e[24]!==x||e[25]!==f||e[26]!==i.chartAxes||e[27]!==i.chartKind?(W=g===void 0&&f!==void 0&&x==="chart"&&d(we,{axes:i.chartAxes,kind:i.chartKind,result:f}),e[23]=g,e[24]=x,e[25]=f,e[26]=i.chartAxes,e[27]=i.chartKind,e[28]=W):W=e[28];let S;e[29]!==g||e[30]!==x||e[31]!==f?(S=g===void 0&&f!==void 0&&x==="kpi"&&d(qe,{result:f}),e[29]=g,e[30]=x,e[31]=f,e[32]=S):S=e[32];let k;e[33]!==g||e[34]!==x||e[35]!==f?(k=g===void 0&&f!==void 0&&x==="table"&&d("div",{className:"max-h-72 overflow-auto",children:d(Se,{result:f})}),e[33]=g,e[34]=x,e[35]=f,e[36]=k):k=e[36];let w;return e[37]!==t||e[38]!==n||e[39]!==s||e[40]!==a||e[41]!==o||e[42]!==c||e[43]!==v||e[44]!==z||e[45]!==C||e[46]!==K||e[47]!==W||e[48]!==S||e[49]!==k||e[50]!==i?(w=Z(ce,{actions:z,draggedRef:t,first:n,last:s,onEdit:a,onMove:o,onRemove:c,onReorder:v,widget:i,children:[C,K,W,S,k]}),e[37]=t,e[38]=n,e[39]=s,e[40]=a,e[41]=o,e[42]=c,e[43]=v,e[44]=z,e[45]=C,e[46]=K,e[47]=W,e[48]=S,e[49]=k,e[50]=i,e[51]=w):w=e[51],w},Te=b=>{const e=J(11),{draggedRef:t,first:n,inferring:r,last:s,onEdit:a,onMove:o,onRemove:c,onReorder:v,onSuggest:h,widget:i}=b;let l;return e[0]!==t||e[1]!==n||e[2]!==r||e[3]!==s||e[4]!==a||e[5]!==o||e[6]!==c||e[7]!==v||e[8]!==h||e[9]!==i?(l=le(i)==="text"?d(Ee,{draggedRef:t,first:n,last:s,onEdit:a,onMove:o,onRemove:c,onReorder:v,widget:i}):d(Ae,{draggedRef:t,first:n,inferring:r,last:s,onEdit:a,onMove:o,onRemove:c,onReorder:v,onSuggest:h,widget:i}),e[0]=t,e[1]=n,e[2]=r,e[3]=s,e[4]=a,e[5]=o,e[6]=c,e[7]=v,e[8]=h,e[9]=i,e[10]=l):l=e[10],l},We=["bar","line","area"],Ie=["chart","kpi","table","text"],$e="lunora-studio-dashboards",oe={chartKind:"bar",kind:"chart",shardKey:"",sql:"",text:"",title:""},De=(b,e)=>t=>t.map(n=>n.id===b?{...n,chartAxes:e,chartKind:e.kind}:n),je=(b,e)=>t=>{const n=t.find(a=>a.id===b),r=t.filter(a=>a.id!==b),s=r.findIndex(a=>a.id===e);return n===void 0||s===-1?t:[...r.slice(0,s),n,...r.slice(s)]},ze=(b,e)=>e(b==="line"?"Line":b==="area"?"Area":"Bar"),Be=(b,e)=>e(b==="kpi"?"Single value":b==="table"?"Table":b==="text"?"Text":"Chart"),Fe=b=>{const e=J(82),{draft:t,editing:n,onCancel:r,onChange:s,onSubmit:a}=b,o=te();let c;e[0]!==t||e[1]!==s?(c=u=>{s({...t,title:u.target.value})},e[0]=t,e[1]=s,e[2]=c):c=e[2];const v=c;let h;e[3]!==t||e[4]!==s?(h=u=>{s({...t,sql:u.target.value})},e[3]=t,e[4]=s,e[5]=h):h=e[5];const i=h;let l;e[6]!==t||e[7]!==s?(l=u=>{s({...t,text:u.target.value})},e[6]=t,e[7]=s,e[8]=l):l=e[8];const g=l;let N;e[9]!==t||e[10]!==s?(N=u=>{s({...t,shardKey:u.target.value})},e[9]=t,e[10]=s,e[11]=N):N=e[11];const f=N;let y;e[12]!==t||e[13]!==s?(y=u=>{s({...t,chartKind:u.target.value})},e[12]=t,e[13]=s,e[14]=y):y=e[14];const x=y;let q;e[15]!==t||e[16]!==s?(q=u=>{s({...t,kind:u.target.value})},e[15]=t,e[16]=s,e[17]=q):q=e[17];const O=q;let E;e[18]!==a?(E=()=>{a()},e[18]=a,e[19]=E):E=e[19];const z=E,C=t.kind==="text";let K;e[20]!==t.sql||e[21]!==t.text||e[22]!==t.title||e[23]!==C?(K=t.title.trim()!==""&&(C?t.text.trim()!=="":t.sql.trim()!==""),e[20]=t.sql,e[21]=t.text,e[22]=t.title,e[23]=C,e[24]=K):K=e[24];const W=K;let S;e[25]!==o?(S=o("Widget title"),e[25]=o,e[26]=S):S=e[26];let k;e[27]!==o?(k=o("Widget title"),e[27]=o,e[28]=k):k=e[28];let w;e[29]!==t.title||e[30]!==v||e[31]!==k||e[32]!==S?(w=d("input",{"aria-label":S,className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-title",onChange:v,placeholder:k,type:"text",value:t.title}),e[29]=t.title,e[30]=v,e[31]=k,e[32]=S,e[33]=w):w=e[33];let _;e[34]!==o?(_=o("Widget type"),e[34]=o,e[35]=_):_=e[35];const Q=t.kind;let B;e[36]!==o?(B=Ie.map(u=>d("option",{value:u,children:Be(u,o)},u)),e[36]=o,e[37]=B):B=e[37];let I;e[38]!==t.kind||e[39]!==O||e[40]!==_||e[41]!==B?(I=d("select",{"aria-label":_,className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-widget-kind",onChange:O,value:Q,children:B}),e[38]=t.kind,e[39]=O,e[40]=_,e[41]=B,e[42]=I):I=e[42];let R;e[43]!==t.sql||e[44]!==t.text||e[45]!==C||e[46]!==i||e[47]!==g||e[48]!==o?(R=C?d("textarea",{"aria-label":o("Text"),className:"min-h-24 resize-y rounded-md border border-border bg-background p-2 text-xs leading-5 outline-none focus-visible:border-ring","data-testid":"dashboards-form-text",onChange:g,placeholder:o("Notes for whoever reads this dashboard."),value:t.text}):d("textarea",{"aria-label":o("SQL query"),className:"min-h-24 resize-y rounded-md border border-border bg-background p-2 font-mono text-xs leading-5 outline-none focus-visible:border-ring","data-testid":"dashboards-form-sql",onChange:i,placeholder:"SELECT author, COUNT(*) AS messages FROM …",spellCheck:!1,value:t.sql}),e[43]=t.sql,e[44]=t.text,e[45]=C,e[46]=i,e[47]=g,e[48]=o,e[49]=R):R=e[49];let $;e[50]!==t.chartKind||e[51]!==t.kind||e[52]!==x||e[53]!==o?($=t.kind==="chart"&&d("select",{"aria-label":o("Chart type"),className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-kind",onChange:x,value:t.chartKind,children:We.map(u=>d("option",{value:u,children:ze(u,o)},u))}),e[50]=t.chartKind,e[51]=t.kind,e[52]=x,e[53]=o,e[54]=$):$=e[54];let L;e[55]!==t.shardKey||e[56]!==C||e[57]!==f||e[58]!==o?(L=!C&&d("input",{"aria-label":o("Shard key (optional)"),className:"h-8 rounded-md border border-border bg-background px-2 font-mono text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-shard",onChange:f,placeholder:o("Shard key (optional)"),type:"text",value:t.shardKey}),e[55]=t.shardKey,e[56]=C,e[57]=f,e[58]=o,e[59]=L):L=e[59];let A;e[60]!==o?(A=o("Cancel"),e[60]=o,e[61]=A):A=e[61];let M;e[62]!==r||e[63]!==A?(M=d(Y,{"data-testid":"dashboards-form-cancel",onClick:r,size:"sm",type:"button",variant:"outline",children:A}),e[62]=r,e[63]=A,e[64]=M):M=e[64];const D=!W;let j;e[65]!==n||e[66]!==o?(j=o(n?"Save widget":"Add widget"),e[65]=n,e[66]=o,e[67]=j):j=e[67];let T;e[68]!==z||e[69]!==D||e[70]!==j?(T=d(Y,{"data-testid":"dashboards-form-save",disabled:D,onClick:z,size:"sm",type:"button",children:j}),e[68]=z,e[69]=D,e[70]=j,e[71]=T):T=e[71];let p;e[72]!==M||e[73]!==T?(p=Z("div",{className:"flex items-center justify-end gap-2",children:[M,T]}),e[72]=M,e[73]=T,e[74]=p):p=e[74];let m;return e[75]!==w||e[76]!==I||e[77]!==R||e[78]!==$||e[79]!==L||e[80]!==p?(m=d(ae,{"data-testid":"dashboards-form",children:Z(re,{className:"flex flex-col gap-3 py-4",children:[w,I,R,$,L,p]})}),e[75]=w,e[76]=I,e[77]=R,e[78]=$,e[79]=L,e[80]=p,e[81]=m):m=e[81],m},it=b=>{const e=J(53),{initialShardKey:t}=b,n=te(),[r,s]=be($e),[a,o]=X(oe),[c,v]=X(null),[h,i]=X(!1),l=ye(t??""),[g,N]=X(null),f=ue(null);let y;e[0]!==t?(y=()=>{v(null),o({...oe,shardKey:t??""}),i(!0)},e[0]=t,e[1]=y):y=e[1];const x=y;let q;e[2]===Symbol.for("react.memo_cache_sentinel")?(q=()=>{i(!1),v(null),o(oe)},e[2]=q):q=e[2];const O=q;let E;e[3]!==r?(E=p=>{const m=r.find(u=>u.id===p);m!==void 0&&(v(p),o({chartKind:m.chartKind??"bar",kind:le(m),shardKey:m.shardKey??"",sql:m.sql,text:m.text??"",title:m.title}),i(!0))},e[3]=r,e[4]=E):E=e[4];const z=E;let C;e[5]!==l||e[6]!==s?(C=(p,m)=>{N(p),de((async()=>{const F=await l.inferChart({columns:m.columns,rowCount:m.rowCount});F!==void 0&&s(De(p,F))})().finally(()=>{N(F=>F===p?null:F)}))},e[5]=l,e[6]=s,e[7]=C):C=e[7];const K=C;let W;e[8]!==s?(W=p=>{s(m=>m.filter(u=>u.id!==p))},e[8]=s,e[9]=W):W=e[9];const S=W;let k;e[10]!==s?(k=(p,m)=>{s(je(p,m))},e[10]=s,e[11]=k):k=e[11];const w=k;let _;e[12]!==s?(_=(p,m)=>{s(u=>{const F=u.findIndex(G=>G.id===p),U=F+m;if(F===-1||U<0||U>=u.length)return u;const V=[...u],H=V[F],P=V[U];return H===void 0||P===void 0?u:(V[F]=P,V[U]=H,V)})},e[12]=s,e[13]=_):_=e[13];const Q=_;let B;e[14]!==a||e[15]!==c||e[16]!==s?(B=()=>{const p=a.title.trim(),m=a.sql.trim(),u=a.text.trim(),{chartKind:F,kind:U}=a;if(p===""||(U==="text"?u==="":m===""))return;const V={chartKind:F,kind:U,shardKey:a.shardKey.trim(),sql:m,text:u,title:p};s(c===null?H=>[...H,{...V,id:ve("w")}]:H=>H.map(P=>P.id===c?{...P,...V}:P)),O()},e[14]=a,e[15]=c,e[16]=s,e[17]=B):B=e[17];const I=B;let R;e[18]!==n?(R=n("Charts, values, tables, and notes. Drag a tile to reorder."),e[18]=n,e[19]=R):R=e[19];let $;e[20]!==R?($=d("p",{className:"text-sm text-muted-foreground",children:R}),e[20]=R,e[21]=$):$=e[21];let L;e[22]!==h||e[23]!==x||e[24]!==n?(L=!h&&d(Y,{"data-testid":"dashboards-add",onClick:x,size:"sm",type:"button",children:n("Add widget")}),e[22]=h,e[23]=x,e[24]=n,e[25]=L):L=e[25];let A;e[26]!==$||e[27]!==L?(A=Z("div",{className:"flex items-center justify-between",children:[$,L]}),e[26]=$,e[27]=L,e[28]=A):A=e[28];let M;e[29]!==l||e[30]!==n?(M=l.reason("chart")!==void 0&&d(ne,{className:"text-xs",testId:"dashboards-suggest-error",variant:"destructive",children:n("Could not suggest a chart for that result.")}),e[29]=l,e[30]=n,e[31]=M):M=e[31];let D;e[32]!==a||e[33]!==c||e[34]!==h||e[35]!==I?(D=h&&d(Fe,{draft:a,editing:c!==null,onCancel:O,onChange:o,onSubmit:I}),e[32]=a,e[33]=c,e[34]=h,e[35]=I,e[36]=D):D=e[36];let j;e[37]!==l.unavailable||e[38]!==h||e[39]!==g||e[40]!==z||e[41]!==Q||e[42]!==S||e[43]!==w||e[44]!==K||e[45]!==n||e[46]!==r?(j=r.length===0&&!h?d(me,{description:n("Add a chart, a single value, a table, or a note. Everything is saved on this browser."),testId:"dashboards-empty",title:n("No widgets yet")}):d("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:r.map((p,m)=>d(Te,{draggedRef:f,first:m===0,inferring:g===p.id,last:m===r.length-1,onEdit:z,onMove:Q,onRemove:S,onReorder:w,onSuggest:l.unavailable?void 0:K,widget:p},p.id))}),e[37]=l.unavailable,e[38]=h,e[39]=g,e[40]=z,e[41]=Q,e[42]=S,e[43]=w,e[44]=K,e[45]=n,e[46]=r,e[47]=j):j=e[47];let T;return e[48]!==A||e[49]!==M||e[50]!==D||e[51]!==j?(T=Z("div",{className:"flex flex-col gap-4","data-testid":"lunora-dashboards",children:[A,M,D,j]}),e[48]=A,e[49]=M,e[50]=D,e[51]=j,e[52]=T):T=e[52],T};export{it as default};
|
|
1
|
+
import{c as J}from"react/compiler-runtime";import{useState as X,useEffect as fe,useRef as ue}from"react";import{A as ne}from"../packem_shared/alert-PB5W11MM.mjs";import{B as Y}from"../packem_shared/button-q0UYSmrn.mjs";import{c as he,b as ge,a as re,C as ae}from"../packem_shared/card-By2O8ULa.mjs";import{E as me}from"../packem_shared/empty-state-D7jEML_T.mjs";import{useT as te}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{u as be,n as ve}from"../packem_shared/browser-storage-BH1MxLZs.mjs";import{c as pe,d as xe,b as Ce,f as de,l as ke}from"../packem_shared/internal-BXEjuLPN.mjs";import{u as ye}from"../packem_shared/use-sql-assistant-BMVlguKF.mjs";import{S as we,a as Se}from"../packem_shared/sql-result-table-CatgdmMh.mjs";import{u as Ne}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{ADMIN_FUNCTIONS as Ke}from"../packem_shared/ADMIN_FUNCTIONS-4aGsMs95.mjs";import{jsx as d,jsxs as Z}from"react/jsx-runtime";const Re=pe(Ke.runSql),Le=(b,e)=>{const t=J(11),n=Ne(),[r,s]=X(void 0),[a,o]=X(void 0),[c,v]=X(!0);let h;t[0]!==n||t[1]!==e||t[2]!==b?(h=async f=>{v(!0);try{const y=await n.query(Re,{sql:b},xe(e));f.cancelled||(s(y),o(void 0))}catch(y){const x=y;f.cancelled||(s(void 0),o(Ce(x)))}f.cancelled||v(!1)},t[0]=n,t[1]=e,t[2]=b,t[3]=h):h=t[3];const i=h;let l,g;t[4]!==i?(l=()=>{const f={cancelled:!1};return de(i(f)),()=>{f.cancelled=!0}},g=[i],t[4]=i,t[5]=l,t[6]=g):(l=t[5],g=t[6]),fe(l,g);let N;return t[7]!==a||t[8]!==c||t[9]!==r?(N={error:a,loading:c,result:r},t[7]=a,t[8]=c,t[9]=r,t[10]=N):N=t[10],N},Me=b=>{b.preventDefault()},le=b=>b.kind??"chart",ce=b=>{const e=J(80),{actions:t,children:n,draggedRef:r,first:s,last:a,onEdit:o,onMove:c,onRemove:v,onReorder:h,widget:i}=b,l=te();let g;e[0]!==c||e[1]!==i.id?(g=()=>{c(i.id,-1)},e[0]=c,e[1]=i.id,e[2]=g):g=e[2];const N=g;let f;e[3]!==c||e[4]!==i.id?(f=()=>{c(i.id,1)},e[3]=c,e[4]=i.id,e[5]=f):f=e[5];const y=f;let x;e[6]!==o||e[7]!==i.id?(x=()=>{o(i.id)},e[6]=o,e[7]=i.id,e[8]=x):x=e[8];const q=x;let O;e[9]!==v||e[10]!==i.id?(O=()=>{v(i.id)},e[9]=v,e[10]=i.id,e[11]=O):O=e[11];const E=O;let z;e[12]!==r||e[13]!==i.id?(z=()=>{r.current=i.id},e[12]=r,e[13]=i.id,e[14]=z):z=e[14];const C=z;let K;e[15]!==r||e[16]!==h||e[17]!==i.id?(K=()=>{const se=r.current;r.current=null,se!==null&&se!==i.id&&h(se,i.id)},e[15]=r,e[16]=h,e[17]=i.id,e[18]=K):K=e[18];const W=K,S=`dashboards-widget-${i.id}`;let k;e[19]!==i.title?(k=d(he,{className:"min-w-0 cursor-grab truncate",title:i.title,children:i.title}),e[19]=i.title,e[20]=k):k=e[20];let w;e[21]!==l?(w=l("Move widget up"),e[21]=l,e[22]=w):w=e[22];const _=`dashboards-move-up-${i.id}`;let Q;e[23]!==l?(Q=l("Move widget up"),e[23]=l,e[24]=Q):Q=e[24];let B;e[25]===Symbol.for("react.memo_cache_sentinel")?(B=d("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:d("path",{d:"m6 15 6-6 6 6"})}),e[25]=B):B=e[25];let I;e[26]!==s||e[27]!==N||e[28]!==_||e[29]!==Q||e[30]!==w?(I=d(Y,{"aria-label":w,"data-testid":_,disabled:s,onClick:N,size:"icon-xs",title:Q,type:"button",variant:"ghost",children:B}),e[26]=s,e[27]=N,e[28]=_,e[29]=Q,e[30]=w,e[31]=I):I=e[31];let R;e[32]!==l?(R=l("Move widget down"),e[32]=l,e[33]=R):R=e[33];const $=`dashboards-move-down-${i.id}`;let L;e[34]!==l?(L=l("Move widget down"),e[34]=l,e[35]=L):L=e[35];let A;e[36]===Symbol.for("react.memo_cache_sentinel")?(A=d("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:d("path",{d:"m6 9 6 6 6-6"})}),e[36]=A):A=e[36];let M;e[37]!==a||e[38]!==y||e[39]!==R||e[40]!==$||e[41]!==L?(M=d(Y,{"aria-label":R,"data-testid":$,disabled:a,onClick:y,size:"icon-xs",title:L,type:"button",variant:"ghost",children:A}),e[37]=a,e[38]=y,e[39]=R,e[40]=$,e[41]=L,e[42]=M):M=e[42];let D;e[43]!==l?(D=l("Edit widget"),e[43]=l,e[44]=D):D=e[44];const j=`dashboards-widget-edit-${i.id}`;let T;e[45]!==l?(T=l("Edit widget"),e[45]=l,e[46]=T):T=e[46];let p;e[47]===Symbol.for("react.memo_cache_sentinel")?(p=d("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:d("path",{d:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"})}),e[47]=p):p=e[47];let m;e[48]!==q||e[49]!==D||e[50]!==j||e[51]!==T?(m=d(Y,{"aria-label":D,"data-testid":j,onClick:q,size:"icon-xs",title:T,type:"button",variant:"ghost",children:p}),e[48]=q,e[49]=D,e[50]=j,e[51]=T,e[52]=m):m=e[52];let u;e[53]!==l?(u=l("Remove widget"),e[53]=l,e[54]=u):u=e[54];const F=`dashboards-widget-remove-${i.id}`;let U;e[55]!==l?(U=l("Remove widget"),e[55]=l,e[56]=U):U=e[56];let V;e[57]===Symbol.for("react.memo_cache_sentinel")?(V=d("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:d("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[57]=V):V=e[57];let H;e[58]!==E||e[59]!==u||e[60]!==F||e[61]!==U?(H=d(Y,{"aria-label":u,"data-testid":F,onClick:E,size:"icon-xs",title:U,type:"button",variant:"ghost",children:V}),e[58]=E,e[59]=u,e[60]=F,e[61]=U,e[62]=H):H=e[62];let P;e[63]!==t||e[64]!==I||e[65]!==M||e[66]!==m||e[67]!==H?(P=Z("div",{className:"flex shrink-0 items-center gap-1",children:[t,I,M,m,H]}),e[63]=t,e[64]=I,e[65]=M,e[66]=m,e[67]=H,e[68]=P):P=e[68];let G;e[69]!==P||e[70]!==k?(G=Z(ge,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[k,P]}),e[69]=P,e[70]=k,e[71]=G):G=e[71];let ee;e[72]!==n?(ee=d(re,{className:"min-h-32 py-2",children:n}),e[72]=n,e[73]=ee):ee=e[73];let ie;return e[74]!==C||e[75]!==W||e[76]!==G||e[77]!==ee||e[78]!==S?(ie=Z(ae,{"data-testid":S,draggable:!0,onDragOver:Me,onDragStart:C,onDrop:W,children:[G,ee]}),e[74]=C,e[75]=W,e[76]=G,e[77]=ee,e[78]=S,e[79]=ie):ie=e[79],ie},qe=b=>{const e=J(10),{result:t}=b,n=te(),r=t.columns[0],s=r===void 0?void 0:t.rows[0]?.[r];let a;e[0]!==s||e[1]!==n?(a=s===void 0?n("—"):ke(s),e[0]=s,e[1]=n,e[2]=a):a=e[2];let o;e[3]!==a?(o=d("p",{className:"truncate font-mono text-3xl font-semibold text-foreground",children:a}),e[3]=a,e[4]=o):o=e[4];let c;e[5]!==r?(c=r!==void 0&&d("p",{className:"truncate text-xs text-muted-foreground",children:r}),e[5]=r,e[6]=c):c=e[6];let v;return e[7]!==o||e[8]!==c?(v=Z("div",{className:"flex h-full flex-col justify-center gap-1 p-4","data-testid":"dashboards-kpi",children:[o,c]}),e[7]=o,e[8]=c,e[9]=v):v=e[9],v},Ee=b=>{const e=J(12),{draggedRef:t,first:n,last:r,onEdit:s,onMove:a,onRemove:o,onReorder:c,widget:v}=b,h=v.text??"";let i;e[0]!==h?(i=d("p",{className:"p-2 text-sm whitespace-pre-wrap text-muted-foreground","data-testid":"dashboards-text",children:h}),e[0]=h,e[1]=i):i=e[1];let l;return e[2]!==t||e[3]!==n||e[4]!==r||e[5]!==s||e[6]!==a||e[7]!==o||e[8]!==c||e[9]!==i||e[10]!==v?(l=d(ce,{draggedRef:t,first:n,last:r,onEdit:s,onMove:a,onRemove:o,onReorder:c,widget:v,children:i}),e[2]=t,e[3]=n,e[4]=r,e[5]=s,e[6]=a,e[7]=o,e[8]=c,e[9]=i,e[10]=v,e[11]=l):l=e[11],l},Ae=b=>{const e=J(52),{draggedRef:t,first:n,inferring:r,last:s,onEdit:a,onMove:o,onRemove:c,onReorder:v,onSuggest:h,widget:i}=b,l=te(),{error:g,loading:N,result:f}=Le(i.sql,i.shardKey??"");let y;e[0]!==i?(y=le(i),e[0]=i,e[1]=y):y=e[1];const x=y;let q;e[2]!==h||e[3]!==f||e[4]!==i.id?(q=()=>{f!==void 0&&h?.(i.id,f)},e[2]=h,e[3]=f,e[4]=i.id,e[5]=q):q=e[5];const O=q;let E;e[6]!==r||e[7]!==x||e[8]!==h||e[9]!==O||e[10]!==f||e[11]!==l||e[12]!==i.id?(E=x==="chart"&&h!==void 0&&f!==void 0?d(Y,{"aria-label":l("Suggest chart"),"data-testid":`dashboards-widget-suggest-${i.id}`,disabled:r,onClick:O,size:"icon-xs",title:l(r?"Suggesting…":"Suggest chart"),type:"button",variant:"ghost",children:d("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:d("path",{d:"m12 3 1.9 4.6L18.5 9.5 13.9 11.4 12 16l-1.9-4.6L5.5 9.5l4.6-1.9L12 3ZM18 15l.9 2.1 2.1.9-2.1.9L18 21l-.9-2.1-2.1-.9 2.1-.9L18 15Z"})})}):void 0,e[6]=r,e[7]=x,e[8]=h,e[9]=O,e[10]=f,e[11]=l,e[12]=i.id,e[13]=E):E=e[13];const z=E;let C;e[14]!==g||e[15]!==i.id?(C=g!==void 0&&d(ne,{className:"font-mono text-xs",testId:`dashboards-widget-error-${i.id}`,variant:"destructive",children:g}),e[14]=g,e[15]=i.id,e[16]=C):C=e[16];let K;e[17]!==g||e[18]!==N||e[19]!==f||e[20]!==l||e[21]!==i.id?(K=g===void 0&&N&&f===void 0&&d("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${i.id}`,children:l("Running…")}),e[17]=g,e[18]=N,e[19]=f,e[20]=l,e[21]=i.id,e[22]=K):K=e[22];let W;e[23]!==g||e[24]!==x||e[25]!==f||e[26]!==i.chartAxes||e[27]!==i.chartKind?(W=g===void 0&&f!==void 0&&x==="chart"&&d(we,{axes:i.chartAxes,kind:i.chartKind,result:f}),e[23]=g,e[24]=x,e[25]=f,e[26]=i.chartAxes,e[27]=i.chartKind,e[28]=W):W=e[28];let S;e[29]!==g||e[30]!==x||e[31]!==f?(S=g===void 0&&f!==void 0&&x==="kpi"&&d(qe,{result:f}),e[29]=g,e[30]=x,e[31]=f,e[32]=S):S=e[32];let k;e[33]!==g||e[34]!==x||e[35]!==f?(k=g===void 0&&f!==void 0&&x==="table"&&d("div",{className:"max-h-72 overflow-auto",children:d(Se,{result:f})}),e[33]=g,e[34]=x,e[35]=f,e[36]=k):k=e[36];let w;return e[37]!==t||e[38]!==n||e[39]!==s||e[40]!==a||e[41]!==o||e[42]!==c||e[43]!==v||e[44]!==z||e[45]!==C||e[46]!==K||e[47]!==W||e[48]!==S||e[49]!==k||e[50]!==i?(w=Z(ce,{actions:z,draggedRef:t,first:n,last:s,onEdit:a,onMove:o,onRemove:c,onReorder:v,widget:i,children:[C,K,W,S,k]}),e[37]=t,e[38]=n,e[39]=s,e[40]=a,e[41]=o,e[42]=c,e[43]=v,e[44]=z,e[45]=C,e[46]=K,e[47]=W,e[48]=S,e[49]=k,e[50]=i,e[51]=w):w=e[51],w},Te=b=>{const e=J(11),{draggedRef:t,first:n,inferring:r,last:s,onEdit:a,onMove:o,onRemove:c,onReorder:v,onSuggest:h,widget:i}=b;let l;return e[0]!==t||e[1]!==n||e[2]!==r||e[3]!==s||e[4]!==a||e[5]!==o||e[6]!==c||e[7]!==v||e[8]!==h||e[9]!==i?(l=le(i)==="text"?d(Ee,{draggedRef:t,first:n,last:s,onEdit:a,onMove:o,onRemove:c,onReorder:v,widget:i}):d(Ae,{draggedRef:t,first:n,inferring:r,last:s,onEdit:a,onMove:o,onRemove:c,onReorder:v,onSuggest:h,widget:i}),e[0]=t,e[1]=n,e[2]=r,e[3]=s,e[4]=a,e[5]=o,e[6]=c,e[7]=v,e[8]=h,e[9]=i,e[10]=l):l=e[10],l},We=["bar","line","area"],Ie=["chart","kpi","table","text"],$e="lunora-studio-dashboards",oe={chartKind:"bar",kind:"chart",shardKey:"",sql:"",text:"",title:""},De=(b,e)=>t=>t.map(n=>n.id===b?{...n,chartAxes:e,chartKind:e.kind}:n),je=(b,e)=>t=>{const n=t.find(a=>a.id===b),r=t.filter(a=>a.id!==b),s=r.findIndex(a=>a.id===e);return n===void 0||s===-1?t:[...r.slice(0,s),n,...r.slice(s)]},ze=(b,e)=>e(b==="line"?"Line":b==="area"?"Area":"Bar"),Be=(b,e)=>e(b==="kpi"?"Single value":b==="table"?"Table":b==="text"?"Text":"Chart"),Fe=b=>{const e=J(82),{draft:t,editing:n,onCancel:r,onChange:s,onSubmit:a}=b,o=te();let c;e[0]!==t||e[1]!==s?(c=u=>{s({...t,title:u.target.value})},e[0]=t,e[1]=s,e[2]=c):c=e[2];const v=c;let h;e[3]!==t||e[4]!==s?(h=u=>{s({...t,sql:u.target.value})},e[3]=t,e[4]=s,e[5]=h):h=e[5];const i=h;let l;e[6]!==t||e[7]!==s?(l=u=>{s({...t,text:u.target.value})},e[6]=t,e[7]=s,e[8]=l):l=e[8];const g=l;let N;e[9]!==t||e[10]!==s?(N=u=>{s({...t,shardKey:u.target.value})},e[9]=t,e[10]=s,e[11]=N):N=e[11];const f=N;let y;e[12]!==t||e[13]!==s?(y=u=>{s({...t,chartKind:u.target.value})},e[12]=t,e[13]=s,e[14]=y):y=e[14];const x=y;let q;e[15]!==t||e[16]!==s?(q=u=>{s({...t,kind:u.target.value})},e[15]=t,e[16]=s,e[17]=q):q=e[17];const O=q;let E;e[18]!==a?(E=()=>{a()},e[18]=a,e[19]=E):E=e[19];const z=E,C=t.kind==="text";let K;e[20]!==t.sql||e[21]!==t.text||e[22]!==t.title||e[23]!==C?(K=t.title.trim()!==""&&(C?t.text.trim()!=="":t.sql.trim()!==""),e[20]=t.sql,e[21]=t.text,e[22]=t.title,e[23]=C,e[24]=K):K=e[24];const W=K;let S;e[25]!==o?(S=o("Widget title"),e[25]=o,e[26]=S):S=e[26];let k;e[27]!==o?(k=o("Widget title"),e[27]=o,e[28]=k):k=e[28];let w;e[29]!==t.title||e[30]!==v||e[31]!==k||e[32]!==S?(w=d("input",{"aria-label":S,className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-title",onChange:v,placeholder:k,type:"text",value:t.title}),e[29]=t.title,e[30]=v,e[31]=k,e[32]=S,e[33]=w):w=e[33];let _;e[34]!==o?(_=o("Widget type"),e[34]=o,e[35]=_):_=e[35];const Q=t.kind;let B;e[36]!==o?(B=Ie.map(u=>d("option",{value:u,children:Be(u,o)},u)),e[36]=o,e[37]=B):B=e[37];let I;e[38]!==t.kind||e[39]!==O||e[40]!==_||e[41]!==B?(I=d("select",{"aria-label":_,className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-widget-kind",onChange:O,value:Q,children:B}),e[38]=t.kind,e[39]=O,e[40]=_,e[41]=B,e[42]=I):I=e[42];let R;e[43]!==t.sql||e[44]!==t.text||e[45]!==C||e[46]!==i||e[47]!==g||e[48]!==o?(R=C?d("textarea",{"aria-label":o("Text"),className:"min-h-24 resize-y rounded-md border border-border bg-background p-2 text-xs leading-5 outline-none focus-visible:border-ring","data-testid":"dashboards-form-text",onChange:g,placeholder:o("Notes for whoever reads this dashboard."),value:t.text}):d("textarea",{"aria-label":o("SQL query"),className:"min-h-24 resize-y rounded-md border border-border bg-background p-2 font-mono text-xs leading-5 outline-none focus-visible:border-ring","data-testid":"dashboards-form-sql",onChange:i,placeholder:"SELECT author, COUNT(*) AS messages FROM …",spellCheck:!1,value:t.sql}),e[43]=t.sql,e[44]=t.text,e[45]=C,e[46]=i,e[47]=g,e[48]=o,e[49]=R):R=e[49];let $;e[50]!==t.chartKind||e[51]!==t.kind||e[52]!==x||e[53]!==o?($=t.kind==="chart"&&d("select",{"aria-label":o("Chart type"),className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-kind",onChange:x,value:t.chartKind,children:We.map(u=>d("option",{value:u,children:ze(u,o)},u))}),e[50]=t.chartKind,e[51]=t.kind,e[52]=x,e[53]=o,e[54]=$):$=e[54];let L;e[55]!==t.shardKey||e[56]!==C||e[57]!==f||e[58]!==o?(L=!C&&d("input",{"aria-label":o("Shard key (optional)"),className:"h-8 rounded-md border border-border bg-background px-2 font-mono text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-shard",onChange:f,placeholder:o("Shard key (optional)"),type:"text",value:t.shardKey}),e[55]=t.shardKey,e[56]=C,e[57]=f,e[58]=o,e[59]=L):L=e[59];let A;e[60]!==o?(A=o("Cancel"),e[60]=o,e[61]=A):A=e[61];let M;e[62]!==r||e[63]!==A?(M=d(Y,{"data-testid":"dashboards-form-cancel",onClick:r,size:"sm",type:"button",variant:"outline",children:A}),e[62]=r,e[63]=A,e[64]=M):M=e[64];const D=!W;let j;e[65]!==n||e[66]!==o?(j=o(n?"Save widget":"Add widget"),e[65]=n,e[66]=o,e[67]=j):j=e[67];let T;e[68]!==z||e[69]!==D||e[70]!==j?(T=d(Y,{"data-testid":"dashboards-form-save",disabled:D,onClick:z,size:"sm",type:"button",children:j}),e[68]=z,e[69]=D,e[70]=j,e[71]=T):T=e[71];let p;e[72]!==M||e[73]!==T?(p=Z("div",{className:"flex items-center justify-end gap-2",children:[M,T]}),e[72]=M,e[73]=T,e[74]=p):p=e[74];let m;return e[75]!==w||e[76]!==I||e[77]!==R||e[78]!==$||e[79]!==L||e[80]!==p?(m=d(ae,{"data-testid":"dashboards-form",children:Z(re,{className:"flex flex-col gap-3 py-4",children:[w,I,R,$,L,p]})}),e[75]=w,e[76]=I,e[77]=R,e[78]=$,e[79]=L,e[80]=p,e[81]=m):m=e[81],m},it=b=>{const e=J(53),{initialShardKey:t}=b,n=te(),[r,s]=be($e),[a,o]=X(oe),[c,v]=X(null),[h,i]=X(!1),l=ye(t??""),[g,N]=X(null),f=ue(null);let y;e[0]!==t?(y=()=>{v(null),o({...oe,shardKey:t??""}),i(!0)},e[0]=t,e[1]=y):y=e[1];const x=y;let q;e[2]===Symbol.for("react.memo_cache_sentinel")?(q=()=>{i(!1),v(null),o(oe)},e[2]=q):q=e[2];const O=q;let E;e[3]!==r?(E=p=>{const m=r.find(u=>u.id===p);m!==void 0&&(v(p),o({chartKind:m.chartKind??"bar",kind:le(m),shardKey:m.shardKey??"",sql:m.sql,text:m.text??"",title:m.title}),i(!0))},e[3]=r,e[4]=E):E=e[4];const z=E;let C;e[5]!==l||e[6]!==s?(C=(p,m)=>{N(p),de((async()=>{const F=await l.inferChart({columns:m.columns,rowCount:m.rowCount});F!==void 0&&s(De(p,F))})().finally(()=>{N(F=>F===p?null:F)}))},e[5]=l,e[6]=s,e[7]=C):C=e[7];const K=C;let W;e[8]!==s?(W=p=>{s(m=>m.filter(u=>u.id!==p))},e[8]=s,e[9]=W):W=e[9];const S=W;let k;e[10]!==s?(k=(p,m)=>{s(je(p,m))},e[10]=s,e[11]=k):k=e[11];const w=k;let _;e[12]!==s?(_=(p,m)=>{s(u=>{const F=u.findIndex(G=>G.id===p),U=F+m;if(F===-1||U<0||U>=u.length)return u;const V=[...u],H=V[F],P=V[U];return H===void 0||P===void 0?u:(V[F]=P,V[U]=H,V)})},e[12]=s,e[13]=_):_=e[13];const Q=_;let B;e[14]!==a||e[15]!==c||e[16]!==s?(B=()=>{const p=a.title.trim(),m=a.sql.trim(),u=a.text.trim(),{chartKind:F,kind:U}=a;if(p===""||(U==="text"?u==="":m===""))return;const V={chartKind:F,kind:U,shardKey:a.shardKey.trim(),sql:m,text:u,title:p};s(c===null?H=>[...H,{...V,id:ve("w")}]:H=>H.map(P=>P.id===c?{...P,...V}:P)),O()},e[14]=a,e[15]=c,e[16]=s,e[17]=B):B=e[17];const I=B;let R;e[18]!==n?(R=n("Charts, values, tables, and notes. Drag a tile to reorder."),e[18]=n,e[19]=R):R=e[19];let $;e[20]!==R?($=d("p",{className:"text-sm text-muted-foreground",children:R}),e[20]=R,e[21]=$):$=e[21];let L;e[22]!==h||e[23]!==x||e[24]!==n?(L=!h&&d(Y,{"data-testid":"dashboards-add",onClick:x,size:"sm",type:"button",children:n("Add widget")}),e[22]=h,e[23]=x,e[24]=n,e[25]=L):L=e[25];let A;e[26]!==$||e[27]!==L?(A=Z("div",{className:"flex items-center justify-between",children:[$,L]}),e[26]=$,e[27]=L,e[28]=A):A=e[28];let M;e[29]!==l||e[30]!==n?(M=l.reason("chart")!==void 0&&d(ne,{className:"text-xs",testId:"dashboards-suggest-error",variant:"destructive",children:n("Could not suggest a chart for that result.")}),e[29]=l,e[30]=n,e[31]=M):M=e[31];let D;e[32]!==a||e[33]!==c||e[34]!==h||e[35]!==I?(D=h&&d(Fe,{draft:a,editing:c!==null,onCancel:O,onChange:o,onSubmit:I}),e[32]=a,e[33]=c,e[34]=h,e[35]=I,e[36]=D):D=e[36];let j;e[37]!==l.unavailable||e[38]!==h||e[39]!==g||e[40]!==z||e[41]!==Q||e[42]!==S||e[43]!==w||e[44]!==K||e[45]!==n||e[46]!==r?(j=r.length===0&&!h?d(me,{description:n("Add a chart, a single value, a table, or a note. Everything is saved on this browser."),testId:"dashboards-empty",title:n("No widgets yet")}):d("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:r.map((p,m)=>d(Te,{draggedRef:f,first:m===0,inferring:g===p.id,last:m===r.length-1,onEdit:z,onMove:Q,onRemove:S,onReorder:w,onSuggest:l.unavailable?void 0:K,widget:p},p.id))}),e[37]=l.unavailable,e[38]=h,e[39]=g,e[40]=z,e[41]=Q,e[42]=S,e[43]=w,e[44]=K,e[45]=n,e[46]=r,e[47]=j):j=e[47];let T;return e[48]!==A||e[49]!==M||e[50]!==D||e[51]!==j?(T=Z("div",{className:"flex flex-col gap-4","data-testid":"lunora-dashboards",children:[A,M,D,j]}),e[48]=A,e[49]=M,e[50]=D,e[51]=j,e[52]=T):T=e[52],T};export{it as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as I}from"react/compiler-runtime";import{E as K}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{ShardInput as O}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{B as w}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as M,a as $}from"../packem_shared/card-By2O8ULa.mjs";import{E as j}from"../packem_shared/empty-state-D7jEML_T.mjs";import{u as T}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{u as A}from"../packem_shared/use-open-trace-B_0LbTD7.mjs";import{u as k}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as C}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as E}from"../packem_shared/ADMIN_FUNCTIONS-
|
|
1
|
+
import{c as I}from"react/compiler-runtime";import{E as K}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{ShardInput as O}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{B as w}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as M,a as $}from"../packem_shared/card-By2O8ULa.mjs";import{E as j}from"../packem_shared/empty-state-D7jEML_T.mjs";import{u as T}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{u as A}from"../packem_shared/use-open-trace-B_0LbTD7.mjs";import{u as k}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as C}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as E}from"../packem_shared/ADMIN_FUNCTIONS-4aGsMs95.mjs";import{h as R}from"../packem_shared/internal-BXEjuLPN.mjs";import{S as B}from"../packem_shared/sparkline-B_sPPO_8.mjs";import{jsxs as g,jsx as c}from"react/jsx-runtime";const F=n=>n.length===0?void 0:{max:Math.max(...n),mean:n.reduce((e,t)=>e+t,0)/n.length,min:Math.min(...n)},_=/^gen_ai\.evaluation\.(.+)\.score$/u,q=n=>{const e=[];for(const t of n)for(const r of t.spans)for(const[a,l]of Object.entries(r.attributes??{})){const o=_.exec(a);if(!o||typeof l!="number")continue;const m=o[1],i=r.attributes?.[`gen_ai.evaluation.${m}.label`];e.push({...typeof i=="string"?{label:i}:{},name:m,score:l,spanName:r.name,startTs:t.startTs+r.offsetMs,traceId:t.traceId})}return e.toSorted((t,r)=>r.startTs-t.startTs)},D=n=>{const e=[];for(const t of n?.series??[]){const r=_.exec(t.name);r&&e.push({name:r[1],points:t.points})}return e},H=(n,e)=>{const t=new Set([...n.map(a=>a.name),...e.map(a=>a.name)]),r=[];for(const a of t){const l=n.filter(s=>s.name===a),o=e.find(s=>s.name===a)?.points??[],m=o.at(-1)?.last??l[0]?.score,i=o.length>0?{max:Math.max(...o.map(s=>s.max)),mean:o.reduce((s,d)=>s+d.sum,0)/o.reduce((s,d)=>s+d.count,0),min:Math.min(...o.map(s=>s.min))}:F(l.map(s=>s.score));r.push({...m===void 0?{}:{latest:m},...i,name:a,points:o,runs:l})}return r.toSorted((a,l)=>a.name.localeCompare(l.name))},L=n=>Array.isArray(n?.traces)?n.traces:[],y=n=>n===void 0?"—":n.toFixed(2),P=n=>{const e=I(34),{card:t,onOpenTrace:r}=n,a=C();let l;e[0]!==t.name?(l=c("h3",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"ev-name",children:t.name}),e[0]=t.name,e[1]=l):l=e[1];let o;e[2]!==t.latest?(o=y(t.latest),e[2]=t.latest,e[3]=o):o=e[3];let m;e[4]!==o?(m=c("span",{className:"font-mono text-lg text-foreground","data-testid":"ev-latest",children:o}),e[4]=o,e[5]=m):m=e[5];let i;e[6]!==l||e[7]!==m?(i=g("div",{className:"flex items-baseline justify-between gap-3",children:[l,m]}),e[6]=l,e[7]=m,e[8]=i):i=e[8];let s;e[9]!==t.max||e[10]!==t.mean||e[11]!==t.min||e[12]!==a?(s=a("min {min} · mean {mean} · max {max}",{max:y(t.max),mean:y(t.mean),min:y(t.min)}),e[9]=t.max,e[10]=t.mean,e[11]=t.min,e[12]=a,e[13]=s):s=e[13];let d;e[14]!==s?(d=c("p",{className:"font-mono text-xs text-muted-foreground","data-testid":"ev-summary",children:s}),e[14]=s,e[15]=d):d=e[15];let f;e[16]!==t.name||e[17]!==t.points||e[18]!==a?(f=t.points.length>1?c(B,{ariaLabel:a("Score trend for {name}",{name:t.name}),className:"h-10 w-full",series:t.points.map(Q),testId:"ev-trend"}):c("p",{className:"text-xs text-muted-foreground","data-testid":"ev-no-trend",children:a("No durable history yet — pass ctx.metrics to recordEvaluation to chart a trend.")}),e[16]=t.name,e[17]=t.points,e[18]=a,e[19]=f):f=e[19];let u;if(e[20]!==t.runs||e[21]!==r||e[22]!==a){let x;e[24]!==r||e[25]!==a?(x=p=>g("div",{className:"flex items-center justify-between gap-2 font-mono text-xs","data-testid":"ev-run",children:[g("span",{className:"truncate text-muted-foreground",children:[R(p.startTs)," · ",p.spanName]}),g("span",{className:"flex items-center gap-2",children:[p.label===void 0?null:c(w,{variant:"outline",children:p.label}),c("span",{className:"text-foreground",children:y(p.score)}),r===void 0?null:c("button",{className:"text-muted-foreground underline-offset-2 hover:underline",onClick:()=>{r(p.traceId)},title:a("Open the trace {trace}",{trace:p.traceId}),type:"button",children:p.traceId.slice(0,8)})]})]},`${p.traceId}:${p.spanName}`),e[24]=r,e[25]=a,e[26]=x):x=e[26],u=t.runs.slice(0,5).map(x),e[20]=t.runs,e[21]=r,e[22]=a,e[23]=u}else u=e[23];let h;e[27]!==u?(h=c("div",{className:"flex flex-col gap-1",children:u}),e[27]=u,e[28]=h):h=e[28];let v;return e[29]!==i||e[30]!==d||e[31]!==f||e[32]!==h?(v=c(M,{"data-testid":"ev-card",children:g($,{className:"flex flex-col gap-3 p-4",children:[i,d,f,h]})}),e[29]=i,e[30]=d,e[31]=f,e[32]=h,e[33]=v):v=e[33],v},re=n=>{const e=I(19),{initialShardKey:t}=n,r=C(),{queryShardKey:a,setShardKey:l,shardKey:o}=k(t),m=A(a);let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];let s;e[1]!==a?(s={live:!0,shardKey:a},e[1]=a,e[2]=s):s=e[2];const{data:d,error:f}=T(E.getTraces,i,s);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u={},e[3]=u):u=e[3];let h;e[4]!==a?(h={live:!0,shardKey:a},e[4]=a,e[5]=h):h=e[5];const{data:v}=T(E.getMetricHistory,u,h);let x;if(e[6]!==d||e[7]!==f||e[8]!==v||e[9]!==m||e[10]!==l||e[11]!==o||e[12]!==r){const p=H(q(L(d)),D(v));let N;e[14]!==l||e[15]!==o?(N=c(O,{onChange:l,testId:"ev-shard-input",value:o}),e[14]=l,e[15]=o,e[16]=N):N=e[16];let b;e[17]!==f?(b=f===null?null:c(K,{error:f,testId:"ev-error"}),e[17]=f,e[18]=b):b=e[18],x=g("section",{className:"flex flex-col gap-4","data-testid":"ev-panel",children:[N,b,p.length===0?c(j,{description:r("Call recordEvaluation from a graded run and its score shows up here."),testId:"ev-empty",title:r("No evals recorded")}):c("div",{className:"grid gap-3 md:grid-cols-2",children:p.map(S=>c(P,{card:S,onOpenTrace:m},S.name))})]}),e[6]=d,e[7]=f,e[8]=v,e[9]=m,e[10]=l,e[11]=o,e[12]=r,e[13]=x}else x=e[13];return x};function Q(n){return n.last}export{re as default};
|