@lunora/studio 1.0.0-alpha.378 → 1.0.0-alpha.379
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/LICENSE.md +201 -104
- package/README.md +3 -3
- package/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/packem_chunks/LogsPanel.mjs +1 -1
- package/dist/packem_chunks/MetricsPanel.mjs +1 -1
- package/dist/packem_chunks/NotificationsPanel.mjs +1 -1
- package/dist/packem_chunks/traces-panel.mjs +1 -1
- package/dist/packem_shared/log-fields-CV-9O0nh.mjs +8 -0
- package/dist/packem_shared/{log-line-DnvvQnY5.mjs → log-line-CYJQf6P-.mjs} +1 -1
- package/dist/standalone/{chunk-NOJMUWHR.js → chunk-26Y4MNET.js} +1 -1
- package/dist/standalone/{chunk-MFVL3BKJ.js → chunk-2JV4BRZM.js} +1 -1
- package/dist/standalone/{chunk-YU67D2FL.js → chunk-2VGEXP5J.js} +1 -1
- package/dist/standalone/{chunk-2Q66YTBU.js → chunk-2X6PKSX3.js} +1 -1
- package/dist/standalone/chunk-323KPWNK.js +1 -0
- package/dist/standalone/{chunk-FBG5SSXS.js → chunk-34RW2S7B.js} +1 -1
- package/dist/standalone/{chunk-2RL5YVB7.js → chunk-3TPV2LT4.js} +1 -1
- package/dist/standalone/{chunk-APTQ5BDE.js → chunk-3VY2JXUG.js} +1 -1
- package/dist/standalone/{chunk-3RZB5QXH.js → chunk-4PGWRKGR.js} +1 -1
- package/dist/standalone/{chunk-R6B5XFEW.js → chunk-4QHOCKKK.js} +1 -1
- package/dist/standalone/{chunk-LDWYV63L.js → chunk-4TMXSFYX.js} +1 -1
- package/dist/standalone/{chunk-UA7DC3LX.js → chunk-4UMUJTD2.js} +1 -1
- package/dist/standalone/{chunk-A6E46F3B.js → chunk-5JP3QEKB.js} +1 -1
- package/dist/standalone/{chunk-FXZ6GEUP.js → chunk-5SCMOA55.js} +1 -1
- package/dist/standalone/{chunk-O65MHZCA.js → chunk-5UBZVLHV.js} +1 -1
- package/dist/standalone/{chunk-F32O6VAS.js → chunk-5YAKHHWZ.js} +1 -1
- package/dist/standalone/{chunk-ZBP4ZBS6.js → chunk-6BZNUPWO.js} +1 -1
- package/dist/standalone/{chunk-ASSIQ4W7.js → chunk-6C5FR3EZ.js} +1 -1
- package/dist/standalone/{chunk-27YLJQRE.js → chunk-6I7FRZA3.js} +1 -1
- package/dist/standalone/{chunk-F2EGC6HE.js → chunk-6M3EQLUP.js} +1 -1
- package/dist/standalone/{chunk-YV6YBDCS.js → chunk-6ZMVAF2O.js} +1 -1
- package/dist/standalone/{chunk-MSZMSG3J.js → chunk-7BNAY62O.js} +1 -1
- package/dist/standalone/{chunk-6DKBHMBL.js → chunk-7LXTCC2A.js} +1 -1
- package/dist/standalone/{chunk-BMGCCYQL.js → chunk-7M5KSH56.js} +1 -1
- package/dist/standalone/{chunk-4YENBZSS.js → chunk-7VZFX5O4.js} +1 -1
- package/dist/standalone/{chunk-CXAPSZF2.js → chunk-AB7ELB6H.js} +1 -1
- package/dist/standalone/{chunk-KMEDIMYZ.js → chunk-AUF7N5CE.js} +1 -1
- package/dist/standalone/{chunk-JAY3ZKY6.js → chunk-AUGN55ZM.js} +1 -1
- package/dist/standalone/{chunk-FXSY2FCG.js → chunk-B2GQMLO3.js} +1 -1
- package/dist/standalone/{chunk-KEICHBPK.js → chunk-BFL76ZWW.js} +1 -1
- package/dist/standalone/{chunk-UL5GMSAW.js → chunk-C6ZJHEQT.js} +1 -1
- package/dist/standalone/{chunk-FPRVR763.js → chunk-CUUNHCMD.js} +1 -1
- package/dist/standalone/{chunk-KFDOGDD2.js → chunk-CYL7MEO2.js} +1 -1
- package/dist/standalone/{chunk-D5VO54BI.js → chunk-DM63RG6O.js} +1 -1
- package/dist/standalone/{chunk-JLPBW5EC.js → chunk-DR4FUUVD.js} +1 -1
- package/dist/standalone/{chunk-IIIAOQ22.js → chunk-DXX7OLWZ.js} +1 -1
- package/dist/standalone/{chunk-A5HJXHD2.js → chunk-E4XUNAKO.js} +1 -1
- package/dist/standalone/{chunk-V4D77Q45.js → chunk-EH3PU4PH.js} +1 -1
- package/dist/standalone/{chunk-2SWWUGUK.js → chunk-EYF7TFVA.js} +1 -1
- package/dist/standalone/{chunk-3PRGO2WY.js → chunk-FGUHYMGU.js} +1 -1
- package/dist/standalone/{chunk-R55GP52Y.js → chunk-FLMIY73E.js} +1 -1
- package/dist/standalone/{chunk-FNE6FFFN.js → chunk-FZLWUX7L.js} +1 -1
- package/dist/standalone/{chunk-N5A7KU32.js → chunk-FZSNE2IP.js} +1 -1
- package/dist/standalone/{chunk-J76P372V.js → chunk-GXKHIVIJ.js} +1 -1
- package/dist/standalone/{chunk-DQWEVUGA.js → chunk-HROJA6UV.js} +1 -1
- package/dist/standalone/{chunk-VY5KDMVO.js → chunk-I63W47HC.js} +1 -1
- package/dist/standalone/{chunk-A5INOAIL.js → chunk-IGIBOJJG.js} +1 -1
- package/dist/standalone/{chunk-4XNMLHOA.js → chunk-IKI4VXGN.js} +1 -1
- package/dist/standalone/{chunk-UVMD7C4J.js → chunk-IXBHUFDE.js} +1 -1
- package/dist/standalone/{chunk-SHTZR3TU.js → chunk-IYJF4GU7.js} +1 -1
- package/dist/standalone/{chunk-O5NP5MVG.js → chunk-IZQESKL2.js} +1 -1
- package/dist/standalone/chunk-JEKJEGBJ.js +33 -0
- package/dist/standalone/{chunk-ZK2HQFGQ.js → chunk-JO3JBEGB.js} +1 -1
- package/dist/standalone/{chunk-CB22PV3X.js → chunk-JXGB4QDO.js} +1 -1
- package/dist/standalone/{chunk-4I23RURI.js → chunk-KCIVTT2F.js} +1 -1
- package/dist/standalone/{chunk-UEM26EYR.js → chunk-KLS5BVVO.js} +1 -1
- package/dist/standalone/{chunk-NIGA74BG.js → chunk-KMNBBIIS.js} +1 -1
- package/dist/standalone/{chunk-X26D3KTK.js → chunk-KN4GQKJS.js} +1 -1
- package/dist/standalone/{chunk-IO3TEFOW.js → chunk-KNGEOOIV.js} +1 -1
- package/dist/standalone/{chunk-F5DCBRCJ.js → chunk-KY5SWGWS.js} +1 -1
- package/dist/standalone/{chunk-AKC4XWCD.js → chunk-L62S7I64.js} +1 -1
- package/dist/standalone/{chunk-CX2T7TTB.js → chunk-LH2SSK4J.js} +1 -1
- package/dist/standalone/chunk-LJLNIVUA.js +8 -0
- package/dist/standalone/{chunk-SZCXVIVT.js → chunk-LMGNMZUF.js} +1 -1
- package/dist/standalone/{chunk-ELXPUNSN.js → chunk-LUUXWTIY.js} +1 -1
- package/dist/standalone/{chunk-EA3RERQQ.js → chunk-M4GISIVK.js} +1 -1
- package/dist/standalone/{chunk-BR2A4DYH.js → chunk-MT3SPV45.js} +1 -1
- package/dist/standalone/{chunk-QEQGGAZQ.js → chunk-MUQCBR27.js} +1 -1
- package/dist/standalone/{chunk-6EPIINAW.js → chunk-N7ZOD63M.js} +1 -1
- package/dist/standalone/{chunk-BOYBN3TE.js → chunk-NHBHBDXG.js} +1 -1
- package/dist/standalone/{chunk-5G2OOLMF.js → chunk-O3NLXHWS.js} +1 -1
- package/dist/standalone/{chunk-UCOKDCSX.js → chunk-O3YJ437V.js} +1 -1
- package/dist/standalone/{chunk-W46UJQN7.js → chunk-OFTGFFZO.js} +1 -1
- package/dist/standalone/{chunk-W5LH6U6X.js → chunk-OOUGEUZ4.js} +1 -1
- package/dist/standalone/{chunk-SAV5V3DG.js → chunk-OW7PWUF6.js} +1 -1
- package/dist/standalone/{chunk-TU2IB3GT.js → chunk-P3QC3BR5.js} +1 -1
- package/dist/standalone/{chunk-NSPPZR3Q.js → chunk-PZIS5JIG.js} +1 -1
- package/dist/standalone/{chunk-VONBNFUJ.js → chunk-Q2AOMTCB.js} +1 -1
- package/dist/standalone/{chunk-H5AOMWTU.js → chunk-QFHYWVOO.js} +1 -1
- package/dist/standalone/{chunk-PLONGJJL.js → chunk-QUYKKLCH.js} +1 -1
- package/dist/standalone/{chunk-HNNAMZHQ.js → chunk-R7MTF7SJ.js} +1 -1
- package/dist/standalone/{chunk-PKOFJJA2.js → chunk-S2VF3IDK.js} +1 -1
- package/dist/standalone/{chunk-FFQISGOB.js → chunk-S2WOKV7Y.js} +1 -1
- package/dist/standalone/{chunk-6IECLZ2U.js → chunk-SCHOGXPE.js} +1 -1
- package/dist/standalone/{chunk-ZF4WXT7S.js → chunk-SD5JCGIU.js} +1 -1
- package/dist/standalone/{chunk-J7M7G2BA.js → chunk-UDGBH3IC.js} +1 -1
- package/dist/standalone/{chunk-66PQJM66.js → chunk-W7DGN5TF.js} +1 -1
- package/dist/standalone/{chunk-TOBQK3ZF.js → chunk-X7YDONJY.js} +1 -1
- package/dist/standalone/{chunk-TRJMN2YI.js → chunk-YCQ7ZPBP.js} +1 -1
- package/dist/standalone/{chunk-FGEN2V4E.js → chunk-YCRGSQOQ.js} +1 -1
- package/dist/standalone/{chunk-7MQI2RNF.js → chunk-YECCEZZT.js} +1 -1
- package/dist/standalone/{chunk-77PKR3WU.js → chunk-YIXBY57R.js} +1 -1
- package/dist/standalone/{chunk-SBY32RYL.js → chunk-YJOQFRGE.js} +1 -1
- package/dist/standalone/{chunk-3OVNOP65.js → chunk-YM56MNAN.js} +1 -1
- package/dist/standalone/{chunk-BMS6CAKT.js → chunk-YSJ6AQXN.js} +1 -1
- package/dist/standalone/{chunk-YZUJTBSJ.js → chunk-Z2373QYM.js} +1 -1
- package/dist/standalone/{chunk-YIOJWQ3G.js → chunk-ZLGK7CDZ.js} +1 -1
- package/dist/standalone/{chunk-FOURRGSO.js → chunk-ZVTDYI5T.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +2 -2
- package/dist/packem_shared/log-fields-PjFFEqv0.mjs +0 -8
- package/dist/standalone/chunk-4S7ZIMWI.js +0 -33
- package/dist/standalone/chunk-BEC2C3JD.js +0 -1
- package/dist/standalone/chunk-DKEK4ZO6.js +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Re,b as Pe,c as qe}from"./chunk-2SWWUGUK.js";import{b as Ie,c as Te}from"./chunk-DKEK4ZO6.js";import{a as Se}from"./chunk-66PQJM66.js";import"./chunk-QLZGKBOW.js";import{a as de}from"./chunk-R6NJ4ER6.js";import{a as Le}from"./chunk-W7CLOQOU.js";import{c as ke}from"./chunk-MHZNDDGI.js";import{a as Ce}from"./chunk-J7M7G2BA.js";import{a as ie}from"./chunk-DRHZZ7IN.js";import{a as be}from"./chunk-2KTN53PK.js";import{a as ve}from"./chunk-5G2OOLMF.js";import{b as fe}from"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import{i as z}from"./chunk-A5INOAIL.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as pe}from"./chunk-SZCXVIVT.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as J}from"./chunk-X26D3KTK.js";import{b as ne}from"./chunk-TRJMN2YI.js";import"./chunk-L27FKJTG.js";import{a as xe}from"./chunk-UA7DC3LX.js";import"./chunk-KFDOGDD2.js";import{a as ye,b as we,c as Ne,d as se,e as D,f as B}from"./chunk-3OVNOP65.js";import"./chunk-UVMD7C4J.js";import"./chunk-FXSY2FCG.js";import"./chunk-EOFWXI3T.js";import{a as oe}from"./chunk-LYVYUTQY.js";import{c as le}from"./chunk-AKC4XWCD.js";import{n as ge}from"./chunk-SAV5V3DG.js";import"./chunk-ZPQBVYNN.js";import{B as j,j as re,k as he,s as ae,x as W}from"./chunk-4S7ZIMWI.js";import"./chunk-PDBW6GTJ.js";import{a as Ue}from"./chunk-A6TVTNKO.js";import{a as $e,b as je}from"./chunk-ADABTCDI.js";import{a as v,d as te}from"./chunk-5PEAXTYQ.js";var K=te(Ue(),1);var q=te($e(),1);var r=te(je(),1);var ue=["trace","debug","log","info","warn","error","fatal"],ze="LOG_ARCHIVE_NOT_CONFIGURED",De={cursor:void 0,error:null,generation:0,loading:!1,notConfigured:!1,rows:null},Be=v((i,e)=>{switch(e.type){case"append":return{...i,cursor:e.cursor,error:null,loading:!1,rows:[...i.rows??[],...e.rows]};case"failed":return{...i,cursor:void 0,error:e.message,loading:!1,notConfigured:!1,rows:null};case"loaded":return{cursor:e.cursor,error:null,generation:i.generation+1,loading:!1,notConfigured:!1,rows:e.rows};case"loading":return{...i,error:null,loading:!0,notConfigured:!1};case"notConfigured":return{...i,cursor:void 0,error:null,loading:!1,notConfigured:!0,rows:null};case"pageFailed":return{...i,error:e.message,loading:!1};default:return i}},"ze"),We=v(i=>{let e=(0,K.c)(36),{row:t}=i,s;e[0]!==t.fields?(s=Ie(t.fields),e[0]=t.fields,e[1]=s):s=e[1];let n=s,o=`lg-archive-row-${String(t.ts)}`,c;e[2]!==t.ts?(c=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=c):c=e[3];let p;e[4]!==c?(p=(0,r.jsx)(B,{className:"tabular-nums whitespace-nowrap text-xs text-muted-foreground",children:c}),e[4]=c,e[5]=p):p=e[5];let m=Re[t.level],d;e[6]!==t.level||e[7]!==m?(d=(0,r.jsx)(B,{children:(0,r.jsx)(ne,{variant:m,children:t.level})}),e[6]=t.level,e[7]=m,e[8]=d):d=e[8];let a;e[9]!==t.functionPath?(a=(0,r.jsx)(B,{className:"font-mono text-xs",children:t.functionPath}),e[9]=t.functionPath,e[10]=a):a=e[10];let h;e[11]!==t.message?(h=(0,r.jsx)("div",{className:"truncate",title:t.message,children:t.message}),e[11]=t.message,e[12]=h):h=e[12];let l;e[13]!==n.text?(l=n.text!==""&&(0,r.jsx)("div",{className:"truncate font-mono text-[11px] text-muted-foreground",title:n.text,children:n.text}),e[13]=n.text,e[14]=l):l=e[14];let g;e[15]!==n.errors?(g=n.errors.length>0&&(0,r.jsx)(Pe,{errors:n.errors}),e[15]=n.errors,e[16]=g):g=e[16];let u;e[17]!==g||e[18]!==h||e[19]!==l?(u=(0,r.jsxs)(B,{className:"max-w-md",children:[h,l,g]}),e[17]=g,e[18]=h,e[19]=l,e[20]=u):u=e[20];let x=t.traceId??"\u2014",f;e[21]!==x?(f=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:x}),e[21]=x,e[22]=f):f=e[22];let C=t.shardKey??"\u2014",y;e[23]!==C?(y=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:C}),e[23]=C,e[24]=y):y=e[24];let w=t.userId??"\u2014",k;e[25]!==w?(k=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:w}),e[25]=w,e[26]=k):k=e[26];let L;return e[27]!==u||e[28]!==f||e[29]!==y||e[30]!==k||e[31]!==o||e[32]!==p||e[33]!==d||e[34]!==a?(L=(0,r.jsxs)(se,{"data-testid":o,children:[p,d,a,u,f,y,k]}),e[27]=u,e[28]=f,e[29]=y,e[30]=k,e[31]=o,e[32]=p,e[33]=d,e[34]=a,e[35]=L):L=e[35],L},"Ge"),Ve=v(({shardKey:i})=>{let e=ge(),t=j(),[s,n]=(0,q.useState)(""),[o,c]=(0,q.useState)(""),[p,m]=(0,q.useState)(""),[{cursor:d,error:a,generation:h,loading:l,notConfigured:g,rows:u},x]=(0,q.useReducer)(Be,De),f=ie(s.trim(),400),C=ie(o.trim(),400),y={...f===""?{}:{functionPathPrefix:f},...p===""?{}:{minLevel:p},...i===""?{}:{shardKey:i},...C===""?{}:{userId:C}},w=JSON.stringify(y),k=(0,q.useRef)(w);(0,q.useEffect)(()=>{let b={cancelled:!1};return k.current=w,ae((async()=>{x({type:"loading"});try{let N=await e.queryLogArchive(y);b.cancelled||x({cursor:N.nextCursor,rows:N.rows,type:"loaded"})}catch(N){b.cancelled||x(he(N)===ze?{type:"notConfigured"}:{message:re(N),type:"failed"})}})()),()=>{b.cancelled=!0}},[e,w]);let L=v(async()=>{if(d===void 0)return;let b=w;x({type:"loading"});try{let N=await e.queryLogArchive({...y,cursor:d});k.current===b&&x({cursor:N.nextCursor,rows:N.rows,type:"append"})}catch(N){k.current===b&&x({message:re(N),type:"pageFailed"})}},"N"),S=v(b=>{n(b.target.value)},"I"),T=v(b=>{c(b.target.value)},"T"),R=v(b=>{m(b.target.value)},"R"),P=v(()=>{ae(L())},"k");return g?(0,r.jsx)(J,{action:(0,r.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline",href:de,rel:"noreferrer",target:"_blank",children:t("Open in Cloudflare")}),description:t("Wire pipelineLogSink to a Cloudflare Pipeline \u2192 R2 Data Catalog table and set R2_SQL_ACCOUNT_ID, R2_SQL_TOKEN, R2_SQL_BUCKET to browse the durable log archive here."),testId:"lg-archive-not-configured",title:t("Log archive not configured")}):(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lg-archive",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(z,{"aria-label":t("Function path prefix"),className:"h-8 w-48","data-testid":"lg-archive-path",onChange:S,placeholder:t("function path\u2026"),value:s}),(0,r.jsx)(z,{"aria-label":t("User id"),className:"h-8 w-40","data-testid":"lg-archive-user",onChange:T,placeholder:t("user id\u2026"),value:o}),(0,r.jsxs)("select",{"aria-label":t("Minimum level"),className:"h-8 rounded-md border border-border bg-background px-2 text-sm","data-testid":"lg-archive-min-level",onChange:R,value:p,children:[(0,r.jsx)("option",{value:"",children:t("min level")}),ue.map(b=>(0,r.jsx)("option",{value:b,children:b},b))]})]}),a!==null&&(0,r.jsx)("p",{className:"text-sm text-destructive","data-testid":"lg-archive-error",role:"alert",children:a}),l&&u===null&&a===null&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"lg-archive-loading",children:t("Loading\u2026")}),u!==null&&u.length===0&&(0,r.jsx)(J,{description:t("No archived logs match these filters. The durable archive fills as pipelineLogSink flushes records to R2."),testId:"lg-archive-empty",title:t("No archived logs.")}),u!==null&&u.length>0&&(0,r.jsx)("div",{className:"overflow-hidden rounded-xl border border-border shadow-xs",children:(0,r.jsxs)(ye,{"data-testid":"lg-archive-table",children:[(0,r.jsx)(we,{children:(0,r.jsxs)(se,{children:[(0,r.jsx)(D,{children:t("Time")}),(0,r.jsx)(D,{children:t("Level")}),(0,r.jsx)(D,{children:t("Function")}),(0,r.jsx)(D,{children:t("Message")}),(0,r.jsx)(D,{children:t("Trace")}),(0,r.jsx)(D,{children:t("Shard")}),(0,r.jsx)(D,{children:t("User")})]})}),(0,r.jsx)(Ne,{children:u.map((b,N)=>(0,r.jsx)(We,{row:b},`${String(h)}:${String(b.ts)}-${String(N)}`))})]})}),d!==void 0&&(0,r.jsx)("div",{children:(0,r.jsx)(pe,{"data-testid":"lg-archive-more",disabled:l,onClick:P,size:"sm",variant:"outline",children:t(l?"Loading\u2026":"Load more")})})]})},"He"),Qe=v(i=>{let e=(0,K.c)(11),{level:t,onToggle:s,selected:n}=i,o;e[0]!==t||e[1]!==s?(o=v(()=>{s(t)},"o"),e[0]=t,e[1]=s,e[2]=o):o=e[2];let c=o,p=n?"border-border bg-muted font-medium":"border-input text-muted-foreground",m;e[3]!==p?(m=W("rounded-md border px-2 py-1 text-xs",p),e[3]=p,e[4]=m):m=e[4];let d=`logs-level-${t}`,a;return e[5]!==t||e[6]!==c||e[7]!==n||e[8]!==m||e[9]!==d?(a=(0,r.jsx)("button",{"aria-pressed":n,className:m,"data-testid":d,onClick:c,type:"button",children:t}),e[5]=t,e[6]=c,e[7]=n,e[8]=m,e[9]=d,e[10]=a):a=e[10],a},"We"),Ye=v(i=>{let e=(0,K.c)(68),{levelFilter:t,onLogPathChange:s,onSearchChange:n,onTimeRangeChange:o,onToggleLevel:c,onToggleSummary:p,pathFilter:m,search:d,showSummary:a,timeRange:h}=i,l=j(),g;e[0]!==l?(g=l("Search messages"),e[0]=l,e[1]=g):g=e[1];let u;e[2]!==l?(u=l("search message"),e[2]=l,e[3]=u):u=e[3];let x;e[4]!==n||e[5]!==d||e[6]!==g||e[7]!==u?(x=(0,r.jsx)(z,{"aria-label":g,className:"h-8 w-48","data-testid":"lg-search",onChange:n,placeholder:u,value:d}),e[4]=n,e[5]=d,e[6]=g,e[7]=u,e[8]=x):x=e[8];let f;e[9]!==l?(f=l("Function path"),e[9]=l,e[10]=f):f=e[10];let C;e[11]!==l?(C=l("filter path"),e[11]=l,e[12]=C):C=e[12];let y;e[13]!==s||e[14]!==m||e[15]!==f||e[16]!==C?(y=(0,r.jsx)(z,{"aria-label":f,className:"h-8 w-40","data-testid":"logs-path-filter",onChange:s,placeholder:C,value:m}),e[13]=s,e[14]=m,e[15]=f,e[16]=C,e[17]=y):y=e[17];let w;e[18]!==l?(w=l("Level filter"),e[18]=l,e[19]=w):w=e[19];let k;e[20]!==t||e[21]!==c?(k=ue.map(Q=>(0,r.jsx)(Qe,{level:Q,onToggle:c,selected:t.has(Q)},Q)),e[20]=t,e[21]=c,e[22]=k):k=e[22];let L;e[23]!==w||e[24]!==k?(L=(0,r.jsx)("div",{"aria-label":w,className:"inline-flex items-center gap-1","data-testid":"logs-level-filter",role:"group",children:k}),e[23]=w,e[24]=k,e[25]=L):L=e[25];let S;e[26]!==l?(S=l("Time range"),e[26]=l,e[27]=S):S=e[27];let T;e[28]!==l?(T=l("All time"),e[28]=l,e[29]=T):T=e[29];let R;e[30]!==T?(R=(0,r.jsx)("option",{value:"all",children:T}),e[30]=T,e[31]=R):R=e[31];let P;e[32]!==l?(P=l("Last 5m"),e[32]=l,e[33]=P):P=e[33];let b;e[34]!==P?(b=(0,r.jsx)("option",{value:"5m",children:P}),e[34]=P,e[35]=b):b=e[35];let N;e[36]!==l?(N=l("Last 15m"),e[36]=l,e[37]=N):N=e[37];let F;e[38]!==N?(F=(0,r.jsx)("option",{value:"15m",children:N}),e[38]=N,e[39]=F):F=e[39];let E;e[40]!==l?(E=l("Last hour"),e[40]=l,e[41]=E):E=e[41];let O;e[42]!==E?(O=(0,r.jsx)("option",{value:"1h",children:E}),e[42]=E,e[43]=O):O=e[43];let M;e[44]!==o||e[45]!==S||e[46]!==R||e[47]!==b||e[48]!==F||e[49]!==O||e[50]!==h?(M=(0,r.jsxs)("select",{"aria-label":S,className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"logs-time-range",onChange:o,value:h,children:[R,b,F,O]}),e[44]=o,e[45]=S,e[46]=R,e[47]=b,e[48]=F,e[49]=O,e[50]=h,e[51]=M):M=e[51];let V=a?"border-border bg-muted font-medium":"border-input text-muted-foreground",_;e[52]!==V?(_=W("h-8 rounded-md border px-3 text-sm",V),e[52]=V,e[53]=_):_=e[53];let U;e[54]!==a||e[55]!==l?(U=l(a?"List":"Summary"),e[54]=a,e[55]=l,e[56]=U):U=e[56];let A;e[57]!==p||e[58]!==a||e[59]!==_||e[60]!==U?(A=(0,r.jsx)("button",{"aria-pressed":a,className:_,"data-testid":"logs-summary-toggle",onClick:p,type:"button",children:U}),e[57]=p,e[58]=a,e[59]=_,e[60]=U,e[61]=A):A=e[61];let $;return e[62]!==M||e[63]!==A||e[64]!==x||e[65]!==y||e[66]!==L?($=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[x,y,L,M,A]}),e[62]=M,e[63]=A,e[64]=x,e[65]=y,e[66]=L,e[67]=$):$=e[67],$},"Ye"),Ge=v(i=>{let e=(0,K.c)(53),{onOutcomeChange:t,onPathChange:s,onTableChange:n,onUserChange:o,outcomeFilter:c,pathPrefix:p,tableFilter:m,userIdFilter:d}=i,a=j(),h;e[0]!==a?(h=a("Function path"),e[0]=a,e[1]=h):h=e[1];let l;e[2]!==a?(l=a("file:function"),e[2]=a,e[3]=l):l=e[3];let g;e[4]!==s||e[5]!==p||e[6]!==h||e[7]!==l?(g=(0,r.jsx)(z,{"aria-label":h,className:"h-8 w-44","data-testid":"lg-req-path",onChange:s,placeholder:l,value:p}),e[4]=s,e[5]=p,e[6]=h,e[7]=l,e[8]=g):g=e[8];let u;e[9]!==a?(u=a("User id"),e[9]=a,e[10]=u):u=e[10];let x;e[11]!==a?(x=a("userId"),e[11]=a,e[12]=x):x=e[12];let f;e[13]!==o||e[14]!==u||e[15]!==x||e[16]!==d?(f=(0,r.jsx)(z,{"aria-label":u,className:"h-8 w-32","data-testid":"lg-req-user",onChange:o,placeholder:x,value:d}),e[13]=o,e[14]=u,e[15]=x,e[16]=d,e[17]=f):f=e[17];let C;e[18]!==a?(C=a("Table touched"),e[18]=a,e[19]=C):C=e[19];let y;e[20]!==a?(y=a("table"),e[20]=a,e[21]=y):y=e[21];let w;e[22]!==n||e[23]!==C||e[24]!==y||e[25]!==m?(w=(0,r.jsx)(z,{"aria-label":C,className:"h-8 w-32","data-testid":"lg-req-table",onChange:n,placeholder:y,value:m}),e[22]=n,e[23]=C,e[24]=y,e[25]=m,e[26]=w):w=e[26];let k;e[27]!==a?(k=a("Outcome filter"),e[27]=a,e[28]=k):k=e[28];let L;e[29]!==a?(L=a("all"),e[29]=a,e[30]=L):L=e[30];let S;e[31]!==L?(S=(0,r.jsx)("option",{value:"all",children:L}),e[31]=L,e[32]=S):S=e[32];let T;e[33]!==a?(T=a("ok"),e[33]=a,e[34]=T):T=e[34];let R;e[35]!==T?(R=(0,r.jsx)("option",{value:"ok",children:T}),e[35]=T,e[36]=R):R=e[36];let P;e[37]!==a?(P=a("error"),e[37]=a,e[38]=P):P=e[38];let b;e[39]!==P?(b=(0,r.jsx)("option",{value:"error",children:P}),e[39]=P,e[40]=b):b=e[40];let N;e[41]!==t||e[42]!==c||e[43]!==k||e[44]!==S||e[45]!==R||e[46]!==b?(N=(0,r.jsxs)("select",{"aria-label":k,className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"lg-req-outcome",onChange:t,value:c,children:[S,R,b]}),e[41]=t,e[42]=c,e[43]=k,e[44]=S,e[45]=R,e[46]=b,e[47]=N):N=e[47];let F;return e[48]!==N||e[49]!==g||e[50]!==f||e[51]!==w?(F=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[g,f,w,N]}),e[48]=N,e[49]=g,e[50]=f,e[51]=w,e[52]=F):F=e[52],F},"je"),Oe=v(i=>{let e=(0,K.c)(7),{bucket:t}=i,s;e[0]!==t.key?(s=(0,r.jsx)("span",{className:"truncate text-muted-foreground",role:"gridcell",children:t.key}),e[0]=t.key,e[1]=s):s=e[1];let n;e[2]!==t.count?(n=(0,r.jsx)("span",{className:"shrink-0 tabular-nums",role:"gridcell",children:t.count}),e[2]=t.count,e[3]=n):n=e[3];let o;return e[4]!==s||e[5]!==n?(o=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-4 px-3 py-1 font-mono text-xs","data-testid":"logs-summary-row",role:"row",children:[s,n]}),e[4]=s,e[5]=n,e[6]=o):o=e[6],o},"pe"),He=v(i=>{let e=(0,K.c)(31),{summary:t}=i,s=j(),n;e[0]!==t.total||e[1]!==s?(n=s("{count} entries",{count:t.total}),e[0]=t.total,e[1]=s,e[2]=n):n=e[2];let o;e[3]!==n?(o=(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"logs-summary-total",children:n}),e[3]=n,e[4]=o):o=e[4];let c;e[5]!==s?(c=s("By level"),e[5]=s,e[6]=c):c=e[6];let p;e[7]!==c?(p=(0,r.jsx)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:c}),e[7]=c,e[8]=p):p=e[8];let m;e[9]!==t.byLevel?(m=t.byLevel.map(Je),e[9]=t.byLevel,e[10]=m):m=e[10];let d;e[11]!==m?(d=(0,r.jsx)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-levels",role:"grid",children:m}),e[11]=m,e[12]=d):d=e[12];let a;e[13]!==p||e[14]!==d?(a=(0,r.jsxs)("div",{children:[p,d]}),e[13]=p,e[14]=d,e[15]=a):a=e[15];let h;e[16]!==s?(h=s("By function"),e[16]=s,e[17]=h):h=e[17];let l;e[18]!==h?(l=(0,r.jsx)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h}),e[18]=h,e[19]=l):l=e[19];let g;e[20]!==t.byPath?(g=t.byPath.map(Xe),e[20]=t.byPath,e[21]=g):g=e[21];let u;e[22]!==g?(u=(0,r.jsx)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-paths",role:"grid",children:g}),e[22]=g,e[23]=u):u=e[23];let x;e[24]!==u||e[25]!==l?(x=(0,r.jsxs)("div",{children:[l,u]}),e[24]=u,e[25]=l,e[26]=x):x=e[26];let f;return e[27]!==x||e[28]!==o||e[29]!==a?(f=(0,r.jsxs)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"logs-summary",children:[o,a,x]}),e[27]=x,e[28]=o,e[29]=a,e[30]=f):f=e[30],f},"Je");function Je(i){return(0,r.jsx)(Oe,{bucket:i},i.key)}v(Je,"Xe");function Xe(i){return(0,r.jsx)(Oe,{bucket:i},i.key)}v(Xe,"Ze");var Ze=v(i=>{let e=(0,K.c)(46),{liveError:t,onShardKeyChange:s,onShowArchive:n,onShowErrors:o,onShowRequests:c,shardKey:p,view:m}=i,d=j(),a=m==="requests",h=m==="requests"?"bg-muted font-medium":"text-muted-foreground",l;e[0]!==h?(l=W("px-3 py-1 text-sm",h),e[0]=h,e[1]=l):l=e[1];let g;e[2]!==d?(g=d("Requests"),e[2]=d,e[3]=g):g=e[3];let u;e[4]!==c||e[5]!==a||e[6]!==l||e[7]!==g?(u=(0,r.jsx)("button",{"aria-selected":a,className:l,"data-testid":"lg-view-requests",onClick:c,role:"tab",type:"button",children:g}),e[4]=c,e[5]=a,e[6]=l,e[7]=g,e[8]=u):u=e[8];let x=m==="errors",f=m==="errors"?"bg-muted font-medium":"text-muted-foreground",C;e[9]!==f?(C=W("px-3 py-1 text-sm",f),e[9]=f,e[10]=C):C=e[10];let y;e[11]!==d?(y=d("Errors"),e[11]=d,e[12]=y):y=e[12];let w;e[13]!==o||e[14]!==x||e[15]!==C||e[16]!==y?(w=(0,r.jsx)("button",{"aria-selected":x,className:C,"data-testid":"lg-view-errors",onClick:o,role:"tab",type:"button",children:y}),e[13]=o,e[14]=x,e[15]=C,e[16]=y,e[17]=w):w=e[17];let k=m==="archive",L=m==="archive"?"bg-muted font-medium":"text-muted-foreground",S;e[18]!==L?(S=W("px-3 py-1 text-sm",L),e[18]=L,e[19]=S):S=e[19];let T;e[20]!==d?(T=d("Archive"),e[20]=d,e[21]=T):T=e[21];let R;e[22]!==n||e[23]!==k||e[24]!==S||e[25]!==T?(R=(0,r.jsx)("button",{"aria-selected":k,className:S,"data-testid":"lg-view-archive",onClick:n,role:"tab",type:"button",children:T}),e[22]=n,e[23]=k,e[24]=S,e[25]=T,e[26]=R):R=e[26];let P;e[27]!==w||e[28]!==R||e[29]!==u?(P=(0,r.jsxs)("div",{className:"inline-flex overflow-hidden rounded-lg border border-border",role:"tablist",children:[u,w,R]}),e[27]=w,e[28]=R,e[29]=u,e[30]=P):P=e[30];let b;e[31]!==s||e[32]!==p?(b=(0,r.jsx)(ve,{onChange:s,testId:"lg-shard-input",value:p}),e[31]=s,e[32]=p,e[33]=b):b=e[33];let N;e[34]!==t||e[35]!==m?(N=m!=="archive"&&(0,r.jsx)(Ce,{message:t,prefix:"lg"}),e[34]=t,e[35]=m,e[36]=N):N=e[36];let F;e[37]!==d?(F=d("Open in Cloudflare"),e[37]=d,e[38]=F):F=e[38];let E;e[39]!==F?(E=(0,r.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"lg-cf-link",href:de,rel:"noreferrer",target:"_blank",children:F}),e[39]=F,e[40]=E):E=e[40];let O;return e[41]!==P||e[42]!==b||e[43]!==N||e[44]!==E?(O=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[P,b,N,E]}),e[41]=P,e[42]=b,e[43]=N,e[44]=E,e[45]=O):O=e[45],O},"et"),ce=400,et=36,tt={height:ce,overflow:"auto"},Ke={left:0,position:"absolute",top:0,width:"100%"},rt={error:"destructive",ok:"secondary"},Me=v(i=>{let e=(0,K.c)(6),{onOpenTrace:t,traceId:s}=i,n=j(),o;e[0]!==t||e[1]!==n||e[2]!==s?(o=s===void 0?null:(0,r.jsx)("button",{className:"text-primary underline-offset-2 hover:underline","data-testid":"lg-trace-link",onClick:v(()=>{t(s)},"onClick"),type:"button",children:n("Trace")}),e[0]=t,e[1]=n,e[2]=s,e[3]=o):o=e[3];let c;return e[4]!==o?(c=(0,r.jsx)("span",{className:"w-16 shrink-0 text-right",role:"gridcell",children:o}),e[4]=o,e[5]=c):c=e[5],c},"be"),at=v(i=>{let e=(0,K.c)(13),{entry:t,index:s,measureRef:n,onOpenTrace:o,start:c}=i,p=`translateY(${String(c)}px)`,m;e[0]!==p?(m={...Ke,transform:p},e[0]=p,e[1]=m):m=e[1];let d=m,a;e[2]!==t?(a=(0,r.jsx)(qe,{entry:t}),e[2]=t,e[3]=a):a=e[3];let h;e[4]!==t.traceId||e[5]!==o?(h=(0,r.jsx)(Me,{onOpenTrace:o,traceId:t.traceId}),e[4]=t.traceId,e[5]=o,e[6]=h):h=e[6];let l;return e[7]!==s||e[8]!==n||e[9]!==d||e[10]!==a||e[11]!==h?(l=(0,r.jsxs)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":s,"data-testid":"lg-row",ref:n,role:"row",style:d,children:[a,h]}),e[7]=s,e[8]=n,e[9]=d,e[10]=a,e[11]=h,e[12]=l):l=e[12],l},"lt"),Fe=v(i=>i.length===0?"\u2014":i.join(", "),"ce"),lt=v(i=>{let e=(0,K.c)(41),{entry:t,index:s,measureRef:n,onOpenTrace:o,start:c}=i,p=`translateY(${String(c)}px)`,m;e[0]!==p?(m={...Ke,transform:p},e[0]=p,e[1]=m):m=e[1];let d=m,a;e[2]!==t.ts?(a=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=a):a=e[3];let h;e[4]!==a?(h=(0,r.jsx)("span",{className:"w-40 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:a}),e[4]=a,e[5]=h):h=e[5];let l=rt[t.outcome],g;e[6]!==t.outcome||e[7]!==l?(g=(0,r.jsx)("span",{className:"w-16 shrink-0",role:"gridcell",children:(0,r.jsx)(ne,{variant:l,children:t.outcome})}),e[6]=t.outcome,e[7]=l,e[8]=g):g=e[8];let u;e[9]!==t.functionPath?(u=(0,r.jsx)("span",{className:"w-44 shrink-0 truncate",role:"gridcell",title:t.functionPath,children:t.functionPath}),e[9]=t.functionPath,e[10]=u):u=e[10];let x=t.shardKey??"\u2014",f;e[11]!==x?(f=(0,r.jsx)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:x}),e[11]=x,e[12]=f):f=e[12];let C=t.userId??"\u2014",y;e[13]!==C?(y=(0,r.jsx)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:C}),e[13]=C,e[14]=y):y=e[14];let w;e[15]!==t.durationMs?(w=Math.round(t.durationMs),e[15]=t.durationMs,e[16]=w):w=e[16];let k=`${String(w)}ms`,L;e[17]!==k?(L=(0,r.jsx)("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:k}),e[17]=k,e[18]=L):L=e[18];let S;e[19]!==t.errorMessage||e[20]!==t.outcome||e[21]!==t.tablesRead||e[22]!==t.tablesWritten?(S=t.outcome==="error"&&t.errorMessage!==void 0?t.errorMessage:`r:${Fe(t.tablesRead)} \xB7 w:${Fe(t.tablesWritten)}`,e[19]=t.errorMessage,e[20]=t.outcome,e[21]=t.tablesRead,e[22]=t.tablesWritten,e[23]=S):S=e[23];let T;e[24]!==S?(T=(0,r.jsx)("span",{className:"flex-1 truncate text-muted-foreground",role:"gridcell",children:S}),e[24]=S,e[25]=T):T=e[25];let R;e[26]!==t.traceId||e[27]!==o?(R=(0,r.jsx)(Me,{onOpenTrace:o,traceId:t.traceId}),e[26]=t.traceId,e[27]=o,e[28]=R):R=e[28];let P;return e[29]!==s||e[30]!==n||e[31]!==d||e[32]!==y||e[33]!==L||e[34]!==T||e[35]!==R||e[36]!==h||e[37]!==g||e[38]!==u||e[39]!==f?(P=(0,r.jsxs)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":s,"data-testid":"lg-req-row",ref:n,role:"row",style:d,children:[h,g,u,f,y,L,T,R]}),e[29]=s,e[30]=n,e[31]=d,e[32]=y,e[33]=L,e[34]=T,e[35]=R,e[36]=h,e[37]=g,e[38]=u,e[39]=f,e[40]=P):P=e[40],P},"ot"),Ee=v(i=>{let{entries:e}=i??{};return Array.isArray(e)?e:[]},"de"),ot=v(i=>{let e={};return i.functionPathPrefix.trim()!==""&&(e.functionPathPrefix=i.functionPathPrefix.trim()),i.userId.trim()!==""&&(e.userId=i.userId.trim()),i.tableTouched.trim()!==""&&(e.tableTouched=i.tableTouched.trim()),(i.outcome==="ok"||i.outcome==="error")&&(e.outcome=i.outcome),e},"nt"),nt={"5m":300*1e3,"15m":900*1e3,"1h":3600*1e3},st=v((i,e)=>{let t=e.search.trim().toLowerCase(),s=e.path.trim().toLowerCase(),n=e.range==="all"?Number.NEGATIVE_INFINITY:e.now-nt[e.range];return i.filter(o=>e.levels.size>0&&!e.levels.has(o.level)||o.timestamp<n||s!==""&&!(o.functionPath??"").toLowerCase().includes(s)?!1:t===""||o.message.toLowerCase().includes(t)||Te(o.fields).toLowerCase().includes(t))},"it"),it="\u2014",dt=v(i=>{let e=new Map,t=new Map;for(let o of i){e.set(o.level,(e.get(o.level)??0)+1);let c=o.functionPath??it;t.set(c,(t.get(c)??0)+1)}let s=ue.filter(o=>e.has(o)).map(o=>({count:e.get(o)??0,key:o})),n=[...t.entries()].map(([o,c])=>({count:c,key:o})).toSorted((o,c)=>c.count===o.count?o.key.localeCompare(c.key):c.count-o.count);return{byLevel:s,byPath:n,total:i.length}},"dt"),Et=v(({initialShardKey:i})=>{let e=j(),[t,s]=(0,q.useState)("requests"),{queryShardKey:n,setShardKey:o,shardKey:c}=be(i),[p,m]=(0,q.useState)(""),[d,a]=(0,q.useState)(()=>new Set),[h,l]=(0,q.useState)(""),[g,u]=(0,q.useState)("all"),[x,f]=(0,q.useState)(!1),[C,y]=(0,q.useState)(""),[w,k]=(0,q.useState)(""),[L,S]=(0,q.useState)(""),[T,R]=(0,q.useState)("all"),P=ot({functionPathPrefix:C,outcome:T,tableTouched:L,userId:w}),b=le(oe.getRequestLog,P,{enabled:t==="requests",live:!0,shardKey:n}),N=le(oe.getLogs,{},{enabled:t==="errors",live:!0,shardKey:n}),F=t==="requests"?b:N,{error:E,errorSource:O,isLoading:M,liveError:V}=F,_=Se(n),U=Ee(N.data),A=Ee(b.data);(0,q.useEffect)(()=>{F.data!==void 0&&fe(n)},[F.data,n]);let $=st(U,{levels:d,now:Date.now(),path:h,range:g,search:p}),Q=dt($),X=t==="requests"?A.length:$.length,Z=t==="errors"&&x,Y=(0,q.useMemo)(()=>E!==null?"error":X===0?M?Z?"summary":"list":"empty":Z?"summary":"list",[X,M,E,Z]),me=(0,q.useRef)(null),G=ke({count:X,estimateSize:v(()=>et,"estimateSize"),getItemKey:v(I=>t==="errors"?$[I]?.id??I:I,"getItemKey"),getScrollElement:v(()=>me.current,"getScrollElement"),initialRect:{height:ce,width:800},observeElementRect:v((I,ee)=>Le(I,ee,ce),"observeElementRect"),overscan:8}),_e=G.getVirtualItems(),Ae={height:G.getTotalSize(),position:"relative",width:"100%"};return(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-logs",children:[(0,r.jsx)(Ze,{liveError:V,onShardKeyChange:o,onShowArchive:v(()=>{s("archive"),f(!1)},"onShowArchive"),onShowErrors:v(()=>{s("errors"),f(!1)},"onShowErrors"),onShowRequests:v(()=>{s("requests"),f(!1)},"onShowRequests"),shardKey:c,view:t}),t==="errors"&&(0,r.jsx)(Ye,{levelFilter:d,onLogPathChange:v(I=>{l(I.target.value)},"onLogPathChange"),onSearchChange:v(I=>{m(I.target.value)},"onSearchChange"),onTimeRangeChange:v(I=>{u(I.target.value)},"onTimeRangeChange"),onToggleLevel:v(I=>{a(ee=>{let H=new Set(ee);return H.has(I)?H.delete(I):H.add(I),H})},"onToggleLevel"),onToggleSummary:v(()=>{f(I=>!I)},"onToggleSummary"),pathFilter:h,search:p,showSummary:x,timeRange:g}),t==="requests"&&(0,r.jsx)(Ge,{onOutcomeChange:v(I=>{R(I.target.value)},"onOutcomeChange"),onPathChange:v(I=>{y(I.target.value)},"onPathChange"),onTableChange:v(I=>{S(I.target.value)},"onTableChange"),onUserChange:v(I=>{k(I.target.value)},"onUserChange"),outcomeFilter:T,pathPrefix:C,tableFilter:L,userIdFilter:w}),t==="archive"?(0,r.jsx)(Ve,{shardKey:n}):(0,r.jsxs)(r.Fragment,{children:[Y==="error"&&(0,r.jsx)(xe,{error:O,shardKey:n,testId:"lg-error"}),Y==="empty"&&(0,r.jsx)(J,{description:e("Function and request logs for this shard show up here as your app handles traffic."),icon:(0,r.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M4 5h16M4 12h16M4 19h10"})}),testId:"lg-empty",title:e("No logs.")}),Y==="summary"&&(0,r.jsx)(He,{summary:Q}),Y==="list"&&(0,r.jsx)("div",{className:"rounded-xl border border-border shadow-xs","data-testid":"lg-scroll",ref:me,style:tt,children:(0,r.jsx)("div",{"aria-label":e("Recent logs"),"data-testid":"lg-table",role:"grid",style:Ae,children:_e.map(I=>t==="requests"?(0,r.jsx)(lt,{entry:A[I.index],index:I.index,measureRef:G.measureElement,onOpenTrace:_,start:I.start},I.key):(0,r.jsx)(at,{entry:$[I.index],index:I.index,measureRef:G.measureElement,onOpenTrace:_,start:I.start},I.key))})})]})]})},"jt");export{Et as LogsPanel,st as filterLogs,dt as summarizeLogs};
|
|
1
|
+
import{a as Re,b as Pe,c as qe}from"./chunk-EYF7TFVA.js";import{b as Ie,c as Te}from"./chunk-LJLNIVUA.js";import{a as Se}from"./chunk-W7DGN5TF.js";import"./chunk-QLZGKBOW.js";import{a as de}from"./chunk-R6NJ4ER6.js";import{a as Le}from"./chunk-W7CLOQOU.js";import{c as ke}from"./chunk-MHZNDDGI.js";import{a as Ce}from"./chunk-UDGBH3IC.js";import{a as ie}from"./chunk-DRHZZ7IN.js";import{a as be}from"./chunk-2KTN53PK.js";import{a as ve}from"./chunk-O3NLXHWS.js";import{b as fe}from"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import{i as z}from"./chunk-IGIBOJJG.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as pe}from"./chunk-LMGNMZUF.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as J}from"./chunk-KN4GQKJS.js";import{b as ne}from"./chunk-YCQ7ZPBP.js";import"./chunk-L27FKJTG.js";import{a as xe}from"./chunk-4UMUJTD2.js";import"./chunk-CYL7MEO2.js";import{a as ye,b as we,c as Ne,d as se,e as D,f as B}from"./chunk-YM56MNAN.js";import"./chunk-IXBHUFDE.js";import"./chunk-B2GQMLO3.js";import"./chunk-EOFWXI3T.js";import{a as oe}from"./chunk-LYVYUTQY.js";import{c as le}from"./chunk-L62S7I64.js";import{n as ge}from"./chunk-OW7PWUF6.js";import"./chunk-ZPQBVYNN.js";import{B as j,j as re,k as he,s as ae,x as W}from"./chunk-JEKJEGBJ.js";import"./chunk-PDBW6GTJ.js";import{a as Ue}from"./chunk-A6TVTNKO.js";import{a as $e,b as je}from"./chunk-ADABTCDI.js";import{a as v,d as te}from"./chunk-5PEAXTYQ.js";var K=te(Ue(),1);var q=te($e(),1);var r=te(je(),1);var ue=["trace","debug","log","info","warn","error","fatal"],ze="LOG_ARCHIVE_NOT_CONFIGURED",De={cursor:void 0,error:null,generation:0,loading:!1,notConfigured:!1,rows:null},Be=v((i,e)=>{switch(e.type){case"append":return{...i,cursor:e.cursor,error:null,loading:!1,rows:[...i.rows??[],...e.rows]};case"failed":return{...i,cursor:void 0,error:e.message,loading:!1,notConfigured:!1,rows:null};case"loaded":return{cursor:e.cursor,error:null,generation:i.generation+1,loading:!1,notConfigured:!1,rows:e.rows};case"loading":return{...i,error:null,loading:!0,notConfigured:!1};case"notConfigured":return{...i,cursor:void 0,error:null,loading:!1,notConfigured:!0,rows:null};case"pageFailed":return{...i,error:e.message,loading:!1};default:return i}},"ze"),We=v(i=>{let e=(0,K.c)(36),{row:t}=i,s;e[0]!==t.fields?(s=Ie(t.fields),e[0]=t.fields,e[1]=s):s=e[1];let n=s,o=`lg-archive-row-${String(t.ts)}`,c;e[2]!==t.ts?(c=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=c):c=e[3];let p;e[4]!==c?(p=(0,r.jsx)(B,{className:"tabular-nums whitespace-nowrap text-xs text-muted-foreground",children:c}),e[4]=c,e[5]=p):p=e[5];let m=Re[t.level],d;e[6]!==t.level||e[7]!==m?(d=(0,r.jsx)(B,{children:(0,r.jsx)(ne,{variant:m,children:t.level})}),e[6]=t.level,e[7]=m,e[8]=d):d=e[8];let a;e[9]!==t.functionPath?(a=(0,r.jsx)(B,{className:"font-mono text-xs",children:t.functionPath}),e[9]=t.functionPath,e[10]=a):a=e[10];let h;e[11]!==t.message?(h=(0,r.jsx)("div",{className:"truncate",title:t.message,children:t.message}),e[11]=t.message,e[12]=h):h=e[12];let l;e[13]!==n.text?(l=n.text!==""&&(0,r.jsx)("div",{className:"truncate font-mono text-[11px] text-muted-foreground",title:n.text,children:n.text}),e[13]=n.text,e[14]=l):l=e[14];let g;e[15]!==n.errors?(g=n.errors.length>0&&(0,r.jsx)(Pe,{errors:n.errors}),e[15]=n.errors,e[16]=g):g=e[16];let u;e[17]!==g||e[18]!==h||e[19]!==l?(u=(0,r.jsxs)(B,{className:"max-w-md",children:[h,l,g]}),e[17]=g,e[18]=h,e[19]=l,e[20]=u):u=e[20];let x=t.traceId??"\u2014",f;e[21]!==x?(f=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:x}),e[21]=x,e[22]=f):f=e[22];let C=t.shardKey??"\u2014",y;e[23]!==C?(y=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:C}),e[23]=C,e[24]=y):y=e[24];let w=t.userId??"\u2014",k;e[25]!==w?(k=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:w}),e[25]=w,e[26]=k):k=e[26];let L;return e[27]!==u||e[28]!==f||e[29]!==y||e[30]!==k||e[31]!==o||e[32]!==p||e[33]!==d||e[34]!==a?(L=(0,r.jsxs)(se,{"data-testid":o,children:[p,d,a,u,f,y,k]}),e[27]=u,e[28]=f,e[29]=y,e[30]=k,e[31]=o,e[32]=p,e[33]=d,e[34]=a,e[35]=L):L=e[35],L},"Ge"),Ve=v(({shardKey:i})=>{let e=ge(),t=j(),[s,n]=(0,q.useState)(""),[o,c]=(0,q.useState)(""),[p,m]=(0,q.useState)(""),[{cursor:d,error:a,generation:h,loading:l,notConfigured:g,rows:u},x]=(0,q.useReducer)(Be,De),f=ie(s.trim(),400),C=ie(o.trim(),400),y={...f===""?{}:{functionPathPrefix:f},...p===""?{}:{minLevel:p},...i===""?{}:{shardKey:i},...C===""?{}:{userId:C}},w=JSON.stringify(y),k=(0,q.useRef)(w);(0,q.useEffect)(()=>{let b={cancelled:!1};return k.current=w,ae((async()=>{x({type:"loading"});try{let N=await e.queryLogArchive(y);b.cancelled||x({cursor:N.nextCursor,rows:N.rows,type:"loaded"})}catch(N){b.cancelled||x(he(N)===ze?{type:"notConfigured"}:{message:re(N),type:"failed"})}})()),()=>{b.cancelled=!0}},[e,w]);let L=v(async()=>{if(d===void 0)return;let b=w;x({type:"loading"});try{let N=await e.queryLogArchive({...y,cursor:d});k.current===b&&x({cursor:N.nextCursor,rows:N.rows,type:"append"})}catch(N){k.current===b&&x({message:re(N),type:"pageFailed"})}},"N"),S=v(b=>{n(b.target.value)},"I"),T=v(b=>{c(b.target.value)},"T"),R=v(b=>{m(b.target.value)},"R"),P=v(()=>{ae(L())},"k");return g?(0,r.jsx)(J,{action:(0,r.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline",href:de,rel:"noreferrer",target:"_blank",children:t("Open in Cloudflare")}),description:t("Wire pipelineLogSink to a Cloudflare Pipeline \u2192 R2 Data Catalog table and set R2_SQL_ACCOUNT_ID, R2_SQL_TOKEN, R2_SQL_BUCKET to browse the durable log archive here."),testId:"lg-archive-not-configured",title:t("Log archive not configured")}):(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lg-archive",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(z,{"aria-label":t("Function path prefix"),className:"h-8 w-48","data-testid":"lg-archive-path",onChange:S,placeholder:t("function path\u2026"),value:s}),(0,r.jsx)(z,{"aria-label":t("User id"),className:"h-8 w-40","data-testid":"lg-archive-user",onChange:T,placeholder:t("user id\u2026"),value:o}),(0,r.jsxs)("select",{"aria-label":t("Minimum level"),className:"h-8 rounded-md border border-border bg-background px-2 text-sm","data-testid":"lg-archive-min-level",onChange:R,value:p,children:[(0,r.jsx)("option",{value:"",children:t("min level")}),ue.map(b=>(0,r.jsx)("option",{value:b,children:b},b))]})]}),a!==null&&(0,r.jsx)("p",{className:"text-sm text-destructive","data-testid":"lg-archive-error",role:"alert",children:a}),l&&u===null&&a===null&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"lg-archive-loading",children:t("Loading\u2026")}),u!==null&&u.length===0&&(0,r.jsx)(J,{description:t("No archived logs match these filters. The durable archive fills as pipelineLogSink flushes records to R2."),testId:"lg-archive-empty",title:t("No archived logs.")}),u!==null&&u.length>0&&(0,r.jsx)("div",{className:"overflow-hidden rounded-xl border border-border shadow-xs",children:(0,r.jsxs)(ye,{"data-testid":"lg-archive-table",children:[(0,r.jsx)(we,{children:(0,r.jsxs)(se,{children:[(0,r.jsx)(D,{children:t("Time")}),(0,r.jsx)(D,{children:t("Level")}),(0,r.jsx)(D,{children:t("Function")}),(0,r.jsx)(D,{children:t("Message")}),(0,r.jsx)(D,{children:t("Trace")}),(0,r.jsx)(D,{children:t("Shard")}),(0,r.jsx)(D,{children:t("User")})]})}),(0,r.jsx)(Ne,{children:u.map((b,N)=>(0,r.jsx)(We,{row:b},`${String(h)}:${String(b.ts)}-${String(N)}`))})]})}),d!==void 0&&(0,r.jsx)("div",{children:(0,r.jsx)(pe,{"data-testid":"lg-archive-more",disabled:l,onClick:P,size:"sm",variant:"outline",children:t(l?"Loading\u2026":"Load more")})})]})},"He"),Qe=v(i=>{let e=(0,K.c)(11),{level:t,onToggle:s,selected:n}=i,o;e[0]!==t||e[1]!==s?(o=v(()=>{s(t)},"o"),e[0]=t,e[1]=s,e[2]=o):o=e[2];let c=o,p=n?"border-border bg-muted font-medium":"border-input text-muted-foreground",m;e[3]!==p?(m=W("rounded-md border px-2 py-1 text-xs",p),e[3]=p,e[4]=m):m=e[4];let d=`logs-level-${t}`,a;return e[5]!==t||e[6]!==c||e[7]!==n||e[8]!==m||e[9]!==d?(a=(0,r.jsx)("button",{"aria-pressed":n,className:m,"data-testid":d,onClick:c,type:"button",children:t}),e[5]=t,e[6]=c,e[7]=n,e[8]=m,e[9]=d,e[10]=a):a=e[10],a},"We"),Ye=v(i=>{let e=(0,K.c)(68),{levelFilter:t,onLogPathChange:s,onSearchChange:n,onTimeRangeChange:o,onToggleLevel:c,onToggleSummary:p,pathFilter:m,search:d,showSummary:a,timeRange:h}=i,l=j(),g;e[0]!==l?(g=l("Search messages"),e[0]=l,e[1]=g):g=e[1];let u;e[2]!==l?(u=l("search message"),e[2]=l,e[3]=u):u=e[3];let x;e[4]!==n||e[5]!==d||e[6]!==g||e[7]!==u?(x=(0,r.jsx)(z,{"aria-label":g,className:"h-8 w-48","data-testid":"lg-search",onChange:n,placeholder:u,value:d}),e[4]=n,e[5]=d,e[6]=g,e[7]=u,e[8]=x):x=e[8];let f;e[9]!==l?(f=l("Function path"),e[9]=l,e[10]=f):f=e[10];let C;e[11]!==l?(C=l("filter path"),e[11]=l,e[12]=C):C=e[12];let y;e[13]!==s||e[14]!==m||e[15]!==f||e[16]!==C?(y=(0,r.jsx)(z,{"aria-label":f,className:"h-8 w-40","data-testid":"logs-path-filter",onChange:s,placeholder:C,value:m}),e[13]=s,e[14]=m,e[15]=f,e[16]=C,e[17]=y):y=e[17];let w;e[18]!==l?(w=l("Level filter"),e[18]=l,e[19]=w):w=e[19];let k;e[20]!==t||e[21]!==c?(k=ue.map(Q=>(0,r.jsx)(Qe,{level:Q,onToggle:c,selected:t.has(Q)},Q)),e[20]=t,e[21]=c,e[22]=k):k=e[22];let L;e[23]!==w||e[24]!==k?(L=(0,r.jsx)("div",{"aria-label":w,className:"inline-flex items-center gap-1","data-testid":"logs-level-filter",role:"group",children:k}),e[23]=w,e[24]=k,e[25]=L):L=e[25];let S;e[26]!==l?(S=l("Time range"),e[26]=l,e[27]=S):S=e[27];let T;e[28]!==l?(T=l("All time"),e[28]=l,e[29]=T):T=e[29];let R;e[30]!==T?(R=(0,r.jsx)("option",{value:"all",children:T}),e[30]=T,e[31]=R):R=e[31];let P;e[32]!==l?(P=l("Last 5m"),e[32]=l,e[33]=P):P=e[33];let b;e[34]!==P?(b=(0,r.jsx)("option",{value:"5m",children:P}),e[34]=P,e[35]=b):b=e[35];let N;e[36]!==l?(N=l("Last 15m"),e[36]=l,e[37]=N):N=e[37];let F;e[38]!==N?(F=(0,r.jsx)("option",{value:"15m",children:N}),e[38]=N,e[39]=F):F=e[39];let E;e[40]!==l?(E=l("Last hour"),e[40]=l,e[41]=E):E=e[41];let O;e[42]!==E?(O=(0,r.jsx)("option",{value:"1h",children:E}),e[42]=E,e[43]=O):O=e[43];let M;e[44]!==o||e[45]!==S||e[46]!==R||e[47]!==b||e[48]!==F||e[49]!==O||e[50]!==h?(M=(0,r.jsxs)("select",{"aria-label":S,className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"logs-time-range",onChange:o,value:h,children:[R,b,F,O]}),e[44]=o,e[45]=S,e[46]=R,e[47]=b,e[48]=F,e[49]=O,e[50]=h,e[51]=M):M=e[51];let V=a?"border-border bg-muted font-medium":"border-input text-muted-foreground",_;e[52]!==V?(_=W("h-8 rounded-md border px-3 text-sm",V),e[52]=V,e[53]=_):_=e[53];let U;e[54]!==a||e[55]!==l?(U=l(a?"List":"Summary"),e[54]=a,e[55]=l,e[56]=U):U=e[56];let A;e[57]!==p||e[58]!==a||e[59]!==_||e[60]!==U?(A=(0,r.jsx)("button",{"aria-pressed":a,className:_,"data-testid":"logs-summary-toggle",onClick:p,type:"button",children:U}),e[57]=p,e[58]=a,e[59]=_,e[60]=U,e[61]=A):A=e[61];let $;return e[62]!==M||e[63]!==A||e[64]!==x||e[65]!==y||e[66]!==L?($=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[x,y,L,M,A]}),e[62]=M,e[63]=A,e[64]=x,e[65]=y,e[66]=L,e[67]=$):$=e[67],$},"Ye"),Ge=v(i=>{let e=(0,K.c)(53),{onOutcomeChange:t,onPathChange:s,onTableChange:n,onUserChange:o,outcomeFilter:c,pathPrefix:p,tableFilter:m,userIdFilter:d}=i,a=j(),h;e[0]!==a?(h=a("Function path"),e[0]=a,e[1]=h):h=e[1];let l;e[2]!==a?(l=a("file:function"),e[2]=a,e[3]=l):l=e[3];let g;e[4]!==s||e[5]!==p||e[6]!==h||e[7]!==l?(g=(0,r.jsx)(z,{"aria-label":h,className:"h-8 w-44","data-testid":"lg-req-path",onChange:s,placeholder:l,value:p}),e[4]=s,e[5]=p,e[6]=h,e[7]=l,e[8]=g):g=e[8];let u;e[9]!==a?(u=a("User id"),e[9]=a,e[10]=u):u=e[10];let x;e[11]!==a?(x=a("userId"),e[11]=a,e[12]=x):x=e[12];let f;e[13]!==o||e[14]!==u||e[15]!==x||e[16]!==d?(f=(0,r.jsx)(z,{"aria-label":u,className:"h-8 w-32","data-testid":"lg-req-user",onChange:o,placeholder:x,value:d}),e[13]=o,e[14]=u,e[15]=x,e[16]=d,e[17]=f):f=e[17];let C;e[18]!==a?(C=a("Table touched"),e[18]=a,e[19]=C):C=e[19];let y;e[20]!==a?(y=a("table"),e[20]=a,e[21]=y):y=e[21];let w;e[22]!==n||e[23]!==C||e[24]!==y||e[25]!==m?(w=(0,r.jsx)(z,{"aria-label":C,className:"h-8 w-32","data-testid":"lg-req-table",onChange:n,placeholder:y,value:m}),e[22]=n,e[23]=C,e[24]=y,e[25]=m,e[26]=w):w=e[26];let k;e[27]!==a?(k=a("Outcome filter"),e[27]=a,e[28]=k):k=e[28];let L;e[29]!==a?(L=a("all"),e[29]=a,e[30]=L):L=e[30];let S;e[31]!==L?(S=(0,r.jsx)("option",{value:"all",children:L}),e[31]=L,e[32]=S):S=e[32];let T;e[33]!==a?(T=a("ok"),e[33]=a,e[34]=T):T=e[34];let R;e[35]!==T?(R=(0,r.jsx)("option",{value:"ok",children:T}),e[35]=T,e[36]=R):R=e[36];let P;e[37]!==a?(P=a("error"),e[37]=a,e[38]=P):P=e[38];let b;e[39]!==P?(b=(0,r.jsx)("option",{value:"error",children:P}),e[39]=P,e[40]=b):b=e[40];let N;e[41]!==t||e[42]!==c||e[43]!==k||e[44]!==S||e[45]!==R||e[46]!==b?(N=(0,r.jsxs)("select",{"aria-label":k,className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"lg-req-outcome",onChange:t,value:c,children:[S,R,b]}),e[41]=t,e[42]=c,e[43]=k,e[44]=S,e[45]=R,e[46]=b,e[47]=N):N=e[47];let F;return e[48]!==N||e[49]!==g||e[50]!==f||e[51]!==w?(F=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[g,f,w,N]}),e[48]=N,e[49]=g,e[50]=f,e[51]=w,e[52]=F):F=e[52],F},"je"),Oe=v(i=>{let e=(0,K.c)(7),{bucket:t}=i,s;e[0]!==t.key?(s=(0,r.jsx)("span",{className:"truncate text-muted-foreground",role:"gridcell",children:t.key}),e[0]=t.key,e[1]=s):s=e[1];let n;e[2]!==t.count?(n=(0,r.jsx)("span",{className:"shrink-0 tabular-nums",role:"gridcell",children:t.count}),e[2]=t.count,e[3]=n):n=e[3];let o;return e[4]!==s||e[5]!==n?(o=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-4 px-3 py-1 font-mono text-xs","data-testid":"logs-summary-row",role:"row",children:[s,n]}),e[4]=s,e[5]=n,e[6]=o):o=e[6],o},"pe"),He=v(i=>{let e=(0,K.c)(31),{summary:t}=i,s=j(),n;e[0]!==t.total||e[1]!==s?(n=s("{count} entries",{count:t.total}),e[0]=t.total,e[1]=s,e[2]=n):n=e[2];let o;e[3]!==n?(o=(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"logs-summary-total",children:n}),e[3]=n,e[4]=o):o=e[4];let c;e[5]!==s?(c=s("By level"),e[5]=s,e[6]=c):c=e[6];let p;e[7]!==c?(p=(0,r.jsx)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:c}),e[7]=c,e[8]=p):p=e[8];let m;e[9]!==t.byLevel?(m=t.byLevel.map(Je),e[9]=t.byLevel,e[10]=m):m=e[10];let d;e[11]!==m?(d=(0,r.jsx)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-levels",role:"grid",children:m}),e[11]=m,e[12]=d):d=e[12];let a;e[13]!==p||e[14]!==d?(a=(0,r.jsxs)("div",{children:[p,d]}),e[13]=p,e[14]=d,e[15]=a):a=e[15];let h;e[16]!==s?(h=s("By function"),e[16]=s,e[17]=h):h=e[17];let l;e[18]!==h?(l=(0,r.jsx)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h}),e[18]=h,e[19]=l):l=e[19];let g;e[20]!==t.byPath?(g=t.byPath.map(Xe),e[20]=t.byPath,e[21]=g):g=e[21];let u;e[22]!==g?(u=(0,r.jsx)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-paths",role:"grid",children:g}),e[22]=g,e[23]=u):u=e[23];let x;e[24]!==u||e[25]!==l?(x=(0,r.jsxs)("div",{children:[l,u]}),e[24]=u,e[25]=l,e[26]=x):x=e[26];let f;return e[27]!==x||e[28]!==o||e[29]!==a?(f=(0,r.jsxs)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"logs-summary",children:[o,a,x]}),e[27]=x,e[28]=o,e[29]=a,e[30]=f):f=e[30],f},"Je");function Je(i){return(0,r.jsx)(Oe,{bucket:i},i.key)}v(Je,"Xe");function Xe(i){return(0,r.jsx)(Oe,{bucket:i},i.key)}v(Xe,"Ze");var Ze=v(i=>{let e=(0,K.c)(46),{liveError:t,onShardKeyChange:s,onShowArchive:n,onShowErrors:o,onShowRequests:c,shardKey:p,view:m}=i,d=j(),a=m==="requests",h=m==="requests"?"bg-muted font-medium":"text-muted-foreground",l;e[0]!==h?(l=W("px-3 py-1 text-sm",h),e[0]=h,e[1]=l):l=e[1];let g;e[2]!==d?(g=d("Requests"),e[2]=d,e[3]=g):g=e[3];let u;e[4]!==c||e[5]!==a||e[6]!==l||e[7]!==g?(u=(0,r.jsx)("button",{"aria-selected":a,className:l,"data-testid":"lg-view-requests",onClick:c,role:"tab",type:"button",children:g}),e[4]=c,e[5]=a,e[6]=l,e[7]=g,e[8]=u):u=e[8];let x=m==="errors",f=m==="errors"?"bg-muted font-medium":"text-muted-foreground",C;e[9]!==f?(C=W("px-3 py-1 text-sm",f),e[9]=f,e[10]=C):C=e[10];let y;e[11]!==d?(y=d("Errors"),e[11]=d,e[12]=y):y=e[12];let w;e[13]!==o||e[14]!==x||e[15]!==C||e[16]!==y?(w=(0,r.jsx)("button",{"aria-selected":x,className:C,"data-testid":"lg-view-errors",onClick:o,role:"tab",type:"button",children:y}),e[13]=o,e[14]=x,e[15]=C,e[16]=y,e[17]=w):w=e[17];let k=m==="archive",L=m==="archive"?"bg-muted font-medium":"text-muted-foreground",S;e[18]!==L?(S=W("px-3 py-1 text-sm",L),e[18]=L,e[19]=S):S=e[19];let T;e[20]!==d?(T=d("Archive"),e[20]=d,e[21]=T):T=e[21];let R;e[22]!==n||e[23]!==k||e[24]!==S||e[25]!==T?(R=(0,r.jsx)("button",{"aria-selected":k,className:S,"data-testid":"lg-view-archive",onClick:n,role:"tab",type:"button",children:T}),e[22]=n,e[23]=k,e[24]=S,e[25]=T,e[26]=R):R=e[26];let P;e[27]!==w||e[28]!==R||e[29]!==u?(P=(0,r.jsxs)("div",{className:"inline-flex overflow-hidden rounded-lg border border-border",role:"tablist",children:[u,w,R]}),e[27]=w,e[28]=R,e[29]=u,e[30]=P):P=e[30];let b;e[31]!==s||e[32]!==p?(b=(0,r.jsx)(ve,{onChange:s,testId:"lg-shard-input",value:p}),e[31]=s,e[32]=p,e[33]=b):b=e[33];let N;e[34]!==t||e[35]!==m?(N=m!=="archive"&&(0,r.jsx)(Ce,{message:t,prefix:"lg"}),e[34]=t,e[35]=m,e[36]=N):N=e[36];let F;e[37]!==d?(F=d("Open in Cloudflare"),e[37]=d,e[38]=F):F=e[38];let E;e[39]!==F?(E=(0,r.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"lg-cf-link",href:de,rel:"noreferrer",target:"_blank",children:F}),e[39]=F,e[40]=E):E=e[40];let O;return e[41]!==P||e[42]!==b||e[43]!==N||e[44]!==E?(O=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[P,b,N,E]}),e[41]=P,e[42]=b,e[43]=N,e[44]=E,e[45]=O):O=e[45],O},"et"),ce=400,et=36,tt={height:ce,overflow:"auto"},Ke={left:0,position:"absolute",top:0,width:"100%"},rt={error:"destructive",ok:"secondary"},Me=v(i=>{let e=(0,K.c)(6),{onOpenTrace:t,traceId:s}=i,n=j(),o;e[0]!==t||e[1]!==n||e[2]!==s?(o=s===void 0?null:(0,r.jsx)("button",{className:"text-primary underline-offset-2 hover:underline","data-testid":"lg-trace-link",onClick:v(()=>{t(s)},"onClick"),type:"button",children:n("Trace")}),e[0]=t,e[1]=n,e[2]=s,e[3]=o):o=e[3];let c;return e[4]!==o?(c=(0,r.jsx)("span",{className:"w-16 shrink-0 text-right",role:"gridcell",children:o}),e[4]=o,e[5]=c):c=e[5],c},"be"),at=v(i=>{let e=(0,K.c)(13),{entry:t,index:s,measureRef:n,onOpenTrace:o,start:c}=i,p=`translateY(${String(c)}px)`,m;e[0]!==p?(m={...Ke,transform:p},e[0]=p,e[1]=m):m=e[1];let d=m,a;e[2]!==t?(a=(0,r.jsx)(qe,{entry:t}),e[2]=t,e[3]=a):a=e[3];let h;e[4]!==t.traceId||e[5]!==o?(h=(0,r.jsx)(Me,{onOpenTrace:o,traceId:t.traceId}),e[4]=t.traceId,e[5]=o,e[6]=h):h=e[6];let l;return e[7]!==s||e[8]!==n||e[9]!==d||e[10]!==a||e[11]!==h?(l=(0,r.jsxs)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":s,"data-testid":"lg-row",ref:n,role:"row",style:d,children:[a,h]}),e[7]=s,e[8]=n,e[9]=d,e[10]=a,e[11]=h,e[12]=l):l=e[12],l},"lt"),Fe=v(i=>i.length===0?"\u2014":i.join(", "),"ce"),lt=v(i=>{let e=(0,K.c)(41),{entry:t,index:s,measureRef:n,onOpenTrace:o,start:c}=i,p=`translateY(${String(c)}px)`,m;e[0]!==p?(m={...Ke,transform:p},e[0]=p,e[1]=m):m=e[1];let d=m,a;e[2]!==t.ts?(a=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=a):a=e[3];let h;e[4]!==a?(h=(0,r.jsx)("span",{className:"w-40 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:a}),e[4]=a,e[5]=h):h=e[5];let l=rt[t.outcome],g;e[6]!==t.outcome||e[7]!==l?(g=(0,r.jsx)("span",{className:"w-16 shrink-0",role:"gridcell",children:(0,r.jsx)(ne,{variant:l,children:t.outcome})}),e[6]=t.outcome,e[7]=l,e[8]=g):g=e[8];let u;e[9]!==t.functionPath?(u=(0,r.jsx)("span",{className:"w-44 shrink-0 truncate",role:"gridcell",title:t.functionPath,children:t.functionPath}),e[9]=t.functionPath,e[10]=u):u=e[10];let x=t.shardKey??"\u2014",f;e[11]!==x?(f=(0,r.jsx)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:x}),e[11]=x,e[12]=f):f=e[12];let C=t.userId??"\u2014",y;e[13]!==C?(y=(0,r.jsx)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:C}),e[13]=C,e[14]=y):y=e[14];let w;e[15]!==t.durationMs?(w=Math.round(t.durationMs),e[15]=t.durationMs,e[16]=w):w=e[16];let k=`${String(w)}ms`,L;e[17]!==k?(L=(0,r.jsx)("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:k}),e[17]=k,e[18]=L):L=e[18];let S;e[19]!==t.errorMessage||e[20]!==t.outcome||e[21]!==t.tablesRead||e[22]!==t.tablesWritten?(S=t.outcome==="error"&&t.errorMessage!==void 0?t.errorMessage:`r:${Fe(t.tablesRead)} \xB7 w:${Fe(t.tablesWritten)}`,e[19]=t.errorMessage,e[20]=t.outcome,e[21]=t.tablesRead,e[22]=t.tablesWritten,e[23]=S):S=e[23];let T;e[24]!==S?(T=(0,r.jsx)("span",{className:"flex-1 truncate text-muted-foreground",role:"gridcell",children:S}),e[24]=S,e[25]=T):T=e[25];let R;e[26]!==t.traceId||e[27]!==o?(R=(0,r.jsx)(Me,{onOpenTrace:o,traceId:t.traceId}),e[26]=t.traceId,e[27]=o,e[28]=R):R=e[28];let P;return e[29]!==s||e[30]!==n||e[31]!==d||e[32]!==y||e[33]!==L||e[34]!==T||e[35]!==R||e[36]!==h||e[37]!==g||e[38]!==u||e[39]!==f?(P=(0,r.jsxs)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":s,"data-testid":"lg-req-row",ref:n,role:"row",style:d,children:[h,g,u,f,y,L,T,R]}),e[29]=s,e[30]=n,e[31]=d,e[32]=y,e[33]=L,e[34]=T,e[35]=R,e[36]=h,e[37]=g,e[38]=u,e[39]=f,e[40]=P):P=e[40],P},"ot"),Ee=v(i=>{let{entries:e}=i??{};return Array.isArray(e)?e:[]},"de"),ot=v(i=>{let e={};return i.functionPathPrefix.trim()!==""&&(e.functionPathPrefix=i.functionPathPrefix.trim()),i.userId.trim()!==""&&(e.userId=i.userId.trim()),i.tableTouched.trim()!==""&&(e.tableTouched=i.tableTouched.trim()),(i.outcome==="ok"||i.outcome==="error")&&(e.outcome=i.outcome),e},"nt"),nt={"5m":300*1e3,"15m":900*1e3,"1h":3600*1e3},st=v((i,e)=>{let t=e.search.trim().toLowerCase(),s=e.path.trim().toLowerCase(),n=e.range==="all"?Number.NEGATIVE_INFINITY:e.now-nt[e.range];return i.filter(o=>e.levels.size>0&&!e.levels.has(o.level)||o.timestamp<n||s!==""&&!(o.functionPath??"").toLowerCase().includes(s)?!1:t===""||o.message.toLowerCase().includes(t)||Te(o.fields).toLowerCase().includes(t))},"it"),it="\u2014",dt=v(i=>{let e=new Map,t=new Map;for(let o of i){e.set(o.level,(e.get(o.level)??0)+1);let c=o.functionPath??it;t.set(c,(t.get(c)??0)+1)}let s=ue.filter(o=>e.has(o)).map(o=>({count:e.get(o)??0,key:o})),n=[...t.entries()].map(([o,c])=>({count:c,key:o})).toSorted((o,c)=>c.count===o.count?o.key.localeCompare(c.key):c.count-o.count);return{byLevel:s,byPath:n,total:i.length}},"dt"),Et=v(({initialShardKey:i})=>{let e=j(),[t,s]=(0,q.useState)("requests"),{queryShardKey:n,setShardKey:o,shardKey:c}=be(i),[p,m]=(0,q.useState)(""),[d,a]=(0,q.useState)(()=>new Set),[h,l]=(0,q.useState)(""),[g,u]=(0,q.useState)("all"),[x,f]=(0,q.useState)(!1),[C,y]=(0,q.useState)(""),[w,k]=(0,q.useState)(""),[L,S]=(0,q.useState)(""),[T,R]=(0,q.useState)("all"),P=ot({functionPathPrefix:C,outcome:T,tableTouched:L,userId:w}),b=le(oe.getRequestLog,P,{enabled:t==="requests",live:!0,shardKey:n}),N=le(oe.getLogs,{},{enabled:t==="errors",live:!0,shardKey:n}),F=t==="requests"?b:N,{error:E,errorSource:O,isLoading:M,liveError:V}=F,_=Se(n),U=Ee(N.data),A=Ee(b.data);(0,q.useEffect)(()=>{F.data!==void 0&&fe(n)},[F.data,n]);let $=st(U,{levels:d,now:Date.now(),path:h,range:g,search:p}),Q=dt($),X=t==="requests"?A.length:$.length,Z=t==="errors"&&x,Y=(0,q.useMemo)(()=>E!==null?"error":X===0?M?Z?"summary":"list":"empty":Z?"summary":"list",[X,M,E,Z]),me=(0,q.useRef)(null),G=ke({count:X,estimateSize:v(()=>et,"estimateSize"),getItemKey:v(I=>t==="errors"?$[I]?.id??I:I,"getItemKey"),getScrollElement:v(()=>me.current,"getScrollElement"),initialRect:{height:ce,width:800},observeElementRect:v((I,ee)=>Le(I,ee,ce),"observeElementRect"),overscan:8}),_e=G.getVirtualItems(),Ae={height:G.getTotalSize(),position:"relative",width:"100%"};return(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-logs",children:[(0,r.jsx)(Ze,{liveError:V,onShardKeyChange:o,onShowArchive:v(()=>{s("archive"),f(!1)},"onShowArchive"),onShowErrors:v(()=>{s("errors"),f(!1)},"onShowErrors"),onShowRequests:v(()=>{s("requests"),f(!1)},"onShowRequests"),shardKey:c,view:t}),t==="errors"&&(0,r.jsx)(Ye,{levelFilter:d,onLogPathChange:v(I=>{l(I.target.value)},"onLogPathChange"),onSearchChange:v(I=>{m(I.target.value)},"onSearchChange"),onTimeRangeChange:v(I=>{u(I.target.value)},"onTimeRangeChange"),onToggleLevel:v(I=>{a(ee=>{let H=new Set(ee);return H.has(I)?H.delete(I):H.add(I),H})},"onToggleLevel"),onToggleSummary:v(()=>{f(I=>!I)},"onToggleSummary"),pathFilter:h,search:p,showSummary:x,timeRange:g}),t==="requests"&&(0,r.jsx)(Ge,{onOutcomeChange:v(I=>{R(I.target.value)},"onOutcomeChange"),onPathChange:v(I=>{y(I.target.value)},"onPathChange"),onTableChange:v(I=>{S(I.target.value)},"onTableChange"),onUserChange:v(I=>{k(I.target.value)},"onUserChange"),outcomeFilter:T,pathPrefix:C,tableFilter:L,userIdFilter:w}),t==="archive"?(0,r.jsx)(Ve,{shardKey:n}):(0,r.jsxs)(r.Fragment,{children:[Y==="error"&&(0,r.jsx)(xe,{error:O,shardKey:n,testId:"lg-error"}),Y==="empty"&&(0,r.jsx)(J,{description:e("Function and request logs for this shard show up here as your app handles traffic."),icon:(0,r.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M4 5h16M4 12h16M4 19h10"})}),testId:"lg-empty",title:e("No logs.")}),Y==="summary"&&(0,r.jsx)(He,{summary:Q}),Y==="list"&&(0,r.jsx)("div",{className:"rounded-xl border border-border shadow-xs","data-testid":"lg-scroll",ref:me,style:tt,children:(0,r.jsx)("div",{"aria-label":e("Recent logs"),"data-testid":"lg-table",role:"grid",style:Ae,children:_e.map(I=>t==="requests"?(0,r.jsx)(lt,{entry:A[I.index],index:I.index,measureRef:G.measureElement,onOpenTrace:_,start:I.start},I.key):(0,r.jsx)(at,{entry:$[I.index],index:I.index,measureRef:G.measureElement,onOpenTrace:_,start:I.start},I.key))})})]})]})},"jt");export{Et as LogsPanel,st as filterLogs,dt as summarizeLogs};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as H}from"./chunk-
|
|
1
|
+
import{a as H}from"./chunk-CYL7MEO2.js";import{a as B}from"./chunk-IXBHUFDE.js";import{b as _}from"./chunk-B2GQMLO3.js";import{b as z}from"./chunk-EOFWXI3T.js";import{B as $,e as D,j as E,m as S,n as W}from"./chunk-JEKJEGBJ.js";import{a as F}from"./chunk-A6TVTNKO.js";import{b as G}from"./chunk-ADABTCDI.js";import{a as I,d as O}from"./chunk-5PEAXTYQ.js";var M=O(F(),1);var o=O(G(),1);var ee=I(U=>{let e=(0,M.c)(51),{className:T,error:t,shardKey:j,testId:K}=U,s=$(),r=z(),v=_(),V=v!==void 0&&!v.unavailable,l,c,a,m,d,u,p,i,n,h;if(e[0]!==v||e[1]!==T||e[2]!==t||e[3]!==r||e[4]!==j||e[5]!==s||e[6]!==K){let y=S(t),w;e[17]!==t?(w=W(t),e[17]=t,e[18]=w):w=e[18],a=w;let N;e[19]!==t?(N=B(t),e[19]=t,e[20]=N):N=e[20];let q=N,A=t?.why,C;e[21]!==r||e[22]!==q?(C=I(()=>{r?.openConsole({errorsOnly:!0,seq:q})},"C"),e[21]=r,e[22]=q,e[23]=C):C=e[23],m=C,c=I(()=>{let Z=y===void 0?"":`
|
|
2
2
|
|
|
3
3
|
${s("The studio suggested: {hint}",{hint:D(y)})}`;v?.openAssistant({ask:s(`The studio reported this error:
|
|
4
4
|
{message}{detail}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Ze}from"./chunk-FXZ6GEUP.js";import{a as Me,b as Re}from"./chunk-JNWK5MJC.js";import{a as ke}from"./chunk-FOURRGSO.js";import"./chunk-FPRVR763.js";import"./chunk-Y2YLTUMD.js";import"./chunk-YU67D2FL.js";import"./chunk-LMCBMC2V.js";import"./chunk-QF743FSL.js";import"./chunk-IQ5CIBXJ.js";import"./chunk-YNCZVYCO.js";import"./chunk-OWRWDDJT.js";import"./chunk-QHVUXMRV.js";import"./chunk-2NUCBQFU.js";import{a as Ye}from"./chunk-2KTN53PK.js";import{a as Xe}from"./chunk-5G2OOLMF.js";import{b as We}from"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import{i as Ue}from"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import{i as Ae}from"./chunk-A5INOAIL.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as be}from"./chunk-SZCXVIVT.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as Qe}from"./chunk-X26D3KTK.js";import{b as je}from"./chunk-TRJMN2YI.js";import"./chunk-L27FKJTG.js";import{a as $e}from"./chunk-LYVYUTQY.js";import{a as qe,b as Ge,c as Ke,d as Pe,e as Le}from"./chunk-CB22PV3X.js";import{n as Je}from"./chunk-SAV5V3DG.js";import"./chunk-ZPQBVYNN.js";import{B as Oe,h as ze,i as Ee,j as Fe,s as ge,x as De}from"./chunk-4S7ZIMWI.js";import"./chunk-PDBW6GTJ.js";import{a as st}from"./chunk-A6TVTNKO.js";import{a as nt,b as rt}from"./chunk-ADABTCDI.js";import{a as r,d as Be}from"./chunk-5PEAXTYQ.js";var we=Be(st(),1);var x=Be(nt(),1);var t=Be(rt(),1);var ot=ze($e.listTables),it=ze($e.listTableIndexes),dt=ze($e.readTablePage),ct=ze($e.describeTables),mt={},He=[],ut=r(s=>{let e=(0,we.c)(74),{initialShardKey:u,initialTable:n}=s,l=Je(),[a,m]=(0,x.useState)("graph"),{queryShardKey:c,setShardKey:d,shardKey:b}=Ye(u),[o,h]=(0,x.useState)(""),[i,y]=(0,x.useState)(null),[p,$]=(0,x.useState)(null),S;e[0]===Symbol.for("react.memo_cache_sentinel")?(S={},e[0]=S):S=e[0];let[K,N]=(0,x.useState)(S),O;e[1]===Symbol.for("react.memo_cache_sentinel")?(O={},e[1]=O):O=e[1];let[E,P]=(0,x.useState)(O),[T,C]=(0,x.useState)(null),z;e[2]===Symbol.for("react.memo_cache_sentinel")?(z={},e[2]=z):z=e[2];let[F,fe]=(0,x.useState)(z),te;e[3]===Symbol.for("react.memo_cache_sentinel")?(te={},e[3]=te):te=e[3];let[_,j]=(0,x.useState)(te),[k,xe]=(0,x.useState)(null),[L,ce]=(0,x.useState)(null),le;e[4]===Symbol.for("react.memo_cache_sentinel")?(le={},e[4]=le):le=e[4];let[W,Ce]=(0,x.useState)(le),[X,me]=(0,x.useState)(null),ve=(0,x.useRef)(0),M;e[5]!==l?(M=r(async g=>{ve.current=ve.current+1;let v=ve.current;$(null);try{let w=await l.query(ot,{},Ee(g));if(v!==ve.current)return;We(g),y(w),N({}),P({}),C(null),fe(A=>Object.fromEntries(Object.entries(A).filter(I=>{let[pe]=I;return pe!==g}))),j(A=>Object.fromEntries(Object.entries(A).filter(I=>{let[pe]=I;return pe!==g})))}catch(w){let A=w;if(v!==ve.current)return;y(null),$(Fe(A))}},"D"),e[5]=l,e[6]=M):M=e[6];let B=M,ae;e[7]!==l?(ae=r(async()=>{ce(null);try{xe(await l.listGlobalTables())}catch(g){let v=g;xe(null),ce(Fe(v))}},"se"),e[7]=l,e[8]=ae):ae=e[8];let ue=ae,D,ne;e[9]!==c||e[10]!==B||e[11]!==ue?(D=r(()=>{ge(B(c)),ge(ue())},"R"),ne=[B,ue,c],e[9]=c,e[10]=B,e[11]=ue,e[12]=D,e[13]=ne):(D=e[12],ne=e[13]),(0,x.useEffect)(D,ne);let R;e[14]!==l||e[15]!==K||e[16]!==T||e[17]!==c?(R=r(async g=>{if(T===g){C(null);return}C(g);let v=`${c}:${g}`;if(K[v]!==void 0)return;let[w,A]=await Promise.allSettled([l.query(dt,{limit:1,offset:0,table:g},Ee(c)),l.query(it,{table:g},Ee(c))]);w.status==="fulfilled"?N(I=>({...I,[v]:w.value.columns})):$(Fe(w.reason)),A.status==="fulfilled"&&P(I=>({...I,[v]:A.value.indexes}))},"K"),e[14]=l,e[15]=K,e[16]=T,e[17]=c,e[18]=R):R=e[18];let se=R,re;e[19]!==l||e[20]!==W||e[21]!==X?(re=r(async g=>{if(X===g){me(null);return}if(me(g),W[g]===void 0)try{let v=await l.readGlobalTablePage({limit:1,offset:0,table:g});Ce(w=>({...w,[g]:v.columns}))}catch(v){ce(Fe(v))}},"oe"),e[19]=l,e[20]=W,e[21]=X,e[22]=re):re=e[22];let he=re,Y=(0,x.useRef)(void 0),Z,V;e[23]!==n||e[24]!==i||e[25]!==se?(Z=r(()=>{n===void 0||i===null||Y.current===n||i.some(g=>g.name===n)&&(Y.current=n,ge(se(n)))},"Q"),V=[n,i,se],e[23]=n,e[24]=i,e[25]=se,e[26]=Z,e[27]=V):(Z=e[26],V=e[27]),(0,x.useEffect)(Z,V);let oe;e[28]!==l?(oe=r(async(g,v,w)=>{let[A,I]=await Promise.all([Promise.allSettled([l.query(ct,{tables:[...v,...w]},Ee(g))]),Promise.all(w.map(async Q=>{let Se=await Promise.allSettled([l.readGlobalTablePage({limit:1,offset:0,table:Q})]),Ve=Se[0].status==="fulfilled"?Se[0].value:void 0;return{columns:Ve?.columns??[],refs:Ve?.refs??{},table:Q}}))]),pe=A[0].status==="fulfilled"?A[0].value?.columnsByTable??{}:{},_e=A[0].status==="rejected",Ie=new Map(I.map(ht)),G=[...v,...w].map(Q=>{let Se=pe[Q]??[];return[Q,Se.length>0?Se:Ie.get(Q)??[]]});fe(Q=>({...Q,[g]:Object.fromEntries(G)})),j(Q=>({...Q,[g]:_e}))},"ie"),e[28]=l,e[29]=oe):oe=e[29];let U=oe,ie,J;e[30]!==L||e[31]!==k||e[32]!==U||e[33]!==c||e[34]!==F||e[35]!==i||e[36]!==a?(ie=r(()=>{a!=="graph"||i===null||k===null&&L===null||F[c]!==void 0||ge(U(c,i.map(pt),(k??[]).map(gt)))},"re"),J=[a,i,k,L,c,F,U],e[30]=L,e[31]=k,e[32]=U,e[33]=c,e[34]=F,e[35]=i,e[36]=a,e[37]=ie,e[38]=J):(ie=e[37],J=e[38]),(0,x.useEffect)(ie,J);let q=F[c]??mt,H;if(e[39]!==q||e[40]!==k||e[41]!==i){let g;e[43]!==q?(g=r(I=>({columns:q[I.name]??He,name:I.name,tier:"shard"}),"h"),e[43]=q,e[44]=g):g=e[44];let v=(i??[]).map(g),w;e[45]!==q?(w=r(I=>({columns:q[I.name]??He,name:I.name,tier:"global"}),"N"),e[45]=q,e[46]=w):w=e[46];let A=(k??[]).map(w);H=[...v,...A],e[39]=q,e[40]=k,e[41]=i,e[42]=H}else H=e[42];let f=H,ee;if(e[47]!==o||e[48]!==i){let g=o.trim().toLowerCase();ee=(i??[]).filter(v=>v.name.toLowerCase().includes(g)),e[47]=o,e[48]=i,e[49]=ee}else ee=e[49];let de=ee,ye;if(e[50]!==k||e[51]!==o){let g=o.trim().toLowerCase();ye=(k??[]).filter(v=>v.name.toLowerCase().includes(g)),e[50]=k,e[51]=o,e[52]=ye}else ye=e[52];let Te=ye,Ne;return e[53]!==K||e[54]!==f||e[55]!==p||e[56]!==T||e[57]!==Te||e[58]!==de||e[59]!==W||e[60]!==L||e[61]!==X||e[62]!==k||e[63]!==E||e[64]!==B||e[65]!==d||e[66]!==_||e[67]!==b||e[68]!==o||e[69]!==i||e[70]!==se||e[71]!==he||e[72]!==a?(Ne={columns:K,diagramTables:f,error:p,expanded:T,filteredGlobalTables:Te,filteredTables:de,globalColumns:W,globalError:L,globalExpanded:X,globalTables:k,indexes:E,refresh:B,setShardKey:d,setTableFilter:h,setView:m,shardColumnsError:_,shardKey:b,tableFilter:o,tables:i,toggle:se,toggleGlobal:he,view:a},e[53]=K,e[54]=f,e[55]=p,e[56]=T,e[57]=Te,e[58]=de,e[59]=W,e[60]=L,e[61]=X,e[62]=k,e[63]=E,e[64]=B,e[65]=d,e[66]=_,e[67]=b,e[68]=o,e[69]=i,e[70]=se,e[71]=he,e[72]=a,e[73]=Ne):Ne=e[73],Ne},"mt");function ht(s){let{columns:e,refs:u,table:n}=s;return[n,e.map(l=>{let a=u[l];return a===void 0?{name:l,optional:!1,type:""}:{name:l,optional:!1,ref:a,type:"id"}})]}r(ht,"ut");function pt(s){return s.name}r(pt,"ft");function gt(s){return s.name}r(gt,"ht");var bt="/__lunora/schema-edit",ft=r(async s=>{let e=await fetch(bt,{body:JSON.stringify(s),headers:{"Content-Type":"application/json"},method:"POST"}),u=await e.json();return u.needsMigration===!0?{kind:"needs-migration",message:u.message??"This edit needs a migration."}:e.ok&&u.tables!==void 0?{diagnostics:u.diagnostics??[],kind:"ok",tables:u.tables}:{kind:"error",message:u.error??`schema edit failed (${String(e.status)})`}},"gt"),xt=r(s=>{let e=(0,we.c)(32),{hasTables:u,mode:n,onAddColumn:l,onAddIndex:a,onAddTable:m,onDestructive:c}=s,d=Oe(),b=n==="addTable"?"default":"outline",o;e[0]!==d?(o=d("Add table"),e[0]=d,e[1]=o):o=e[1];let h;e[2]!==m||e[3]!==b||e[4]!==o?(h=(0,t.jsx)(be,{"data-testid":"sc-editor-add-table",onClick:m,size:"xs",type:"button",variant:b,children:o}),e[2]=m,e[3]=b,e[4]=o,e[5]=h):h=e[5];let i=!u,y=n==="addColumn"?"default":"outline",p;e[6]!==d?(p=d("Add column"),e[6]=d,e[7]=p):p=e[7];let $;e[8]!==l||e[9]!==i||e[10]!==y||e[11]!==p?($=(0,t.jsx)(be,{"data-testid":"sc-editor-add-column",disabled:i,onClick:l,size:"xs",type:"button",variant:y,children:p}),e[8]=l,e[9]=i,e[10]=y,e[11]=p,e[12]=$):$=e[12];let S=!u,K=n==="addIndex"?"default":"outline",N;e[13]!==d?(N=d("Add index"),e[13]=d,e[14]=N):N=e[14];let O;e[15]!==a||e[16]!==N||e[17]!==S||e[18]!==K?(O=(0,t.jsx)(be,{"data-testid":"sc-editor-add-index",disabled:S,onClick:a,size:"xs",type:"button",variant:K,children:N}),e[15]=a,e[16]=N,e[17]=S,e[18]=K,e[19]=O):O=e[19];let E=!u,P=n==="destructive"?"default":"ghost",T;e[20]!==d?(T=d("Rename / drop / change type\u2026"),e[20]=d,e[21]=T):T=e[21];let C;e[22]!==c||e[23]!==E||e[24]!==P||e[25]!==T?(C=(0,t.jsx)(be,{"data-testid":"sc-editor-destructive",disabled:E,onClick:c,size:"xs",type:"button",variant:P,children:T}),e[22]=c,e[23]=E,e[24]=P,e[25]=T,e[26]=C):C=e[26];let z;return e[27]!==O||e[28]!==C||e[29]!==h||e[30]!==$?(z=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[h,$,O,C]}),e[27]=O,e[28]=C,e[29]=h,e[30]=$,e[31]=z):z=e[31],z},"bt"),vt=r(s=>{let e=(0,we.c)(28),{onOpenMigrations:u,result:n}=s,l=Oe();if(n===null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[0]=o):o=e[0],o}if(n.kind==="error"){let o;return e[1]!==n.message?(o=(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:n.message}),e[1]=n.message,e[2]=o):o=e[2],o}if(n.kind==="needs-migration"){let o;e[3]!==n.message||e[4]!==l?(o=n.message===""?l("This edit changes stored data and must go through a migration. Review the migration before applying."):n.message,e[3]=n.message,e[4]=l,e[5]=o):o=e[5];let h;e[6]!==o?(h=(0,t.jsx)("p",{className:"text-sm text-warning",role:"alert",children:o}),e[6]=o,e[7]=h):h=e[7];let i;e[8]!==l?(i=l("Open Migrations"),e[8]=l,e[9]=i):i=e[9];let y;e[10]!==u||e[11]!==i?(y=(0,t.jsx)(be,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:u,size:"xs",type:"button",variant:"outline",children:i}),e[10]=u,e[11]=i,e[12]=y):y=e[12];let p;return e[13]!==h||e[14]!==y?(p=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[h,y]}),e[13]=h,e[14]=y,e[15]=p):p=e[15],p}if(n.diagnostics.length===0){let o;return e[16]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[16]=o):o=e[16],o}let a;e[17]!==l?(a=l("Codegen reported diagnostics:"),e[17]=l,e[18]=a):a=e[18];let m;e[19]!==a?(m=(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:a}),e[19]=a,e[20]=m):m=e[20];let c;e[21]!==n.diagnostics?(c=n.diagnostics.map(yt),e[21]=n.diagnostics,e[22]=c):c=e[22];let d;e[23]!==c?(d=(0,t.jsx)("ul",{className:"flex flex-col gap-0.5",children:c}),e[23]=c,e[24]=d):d=e[24];let b;return e[25]!==m||e[26]!==d?(b=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[m,d]}),e[25]=m,e[26]=d,e[27]=b):b=e[27],b},"xt");function yt(s){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:s},s)}r(yt,"vt");var Nt=[{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()",Tt=r(s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),"Nt"),wt=r(s=>{let e=(0,we.c)(83),{onApplied:u,tableNames:n}=s,l=Oe(),a=Ue(),[m,c]=(0,x.useState)(null),[d,b]=(0,x.useState)(!1),[o,h]=(0,x.useState)(null),[i,y]=(0,x.useState)(""),[p,$]=(0,x.useState)(""),[S,K]=(0,x.useState)(Ct),[N,O]=(0,x.useState)(n[0]??""),[E,P]=(0,x.useState)(""),[T,C]=(0,x.useState)(""),[z,F]=(0,x.useState)(!1),fe;e[0]===Symbol.for("react.memo_cache_sentinel")?(fe=r(()=>{c(null),y(""),$(""),P(""),C(""),F(!1)},"pe"),e[0]=fe):fe=e[0];let te=fe,_;e[1]!==u?(_=r(async G=>{b(!0),h(null);try{let Q=await ft(G);h(Q),Q.kind==="ok"&&(u(Q.tables),te())}catch(Q){let Se=Q;h({kind:"error",message:Se instanceof Error?Se.message:String(Se)})}b(!1)},"E"),e[1]=u,e[2]=_):_=e[2];let j=_,k;e[3]!==j||e[4]!==i?(k=r(()=>{ge(j({kind:"addTable",table:i.trim()}))},"w"),e[3]=j,e[4]=i,e[5]=k):k=e[5];let xe=k,L;e[6]!==p||e[7]!==j||e[8]!==N||e[9]!==S?(L=r(()=>{ge(j({column:p.trim(),kind:"addOptionalColumn",table:N,validator:S}))},"B"),e[6]=p,e[7]=j,e[8]=N,e[9]=S,e[10]=L):L=e[10];let ce=L,le;e[11]!==T||e[12]!==E||e[13]!==j||e[14]!==N||e[15]!==z?(le=r(()=>{ge(j({fields:Tt(T),kind:"addIndex",name:E.trim(),table:N,unique:z}))},"le"),e[11]=T,e[12]=E,e[13]=j,e[14]=N,e[15]=z,e[16]=le):le=e[16];let W=le,Ce;e[17]===Symbol.for("react.memo_cache_sentinel")?(Ce=r(()=>{h(null),c("addTable")},"Ne"),e[17]=Ce):Ce=e[17];let X=Ce,me;e[18]===Symbol.for("react.memo_cache_sentinel")?(me=r(()=>{h(null),c("addColumn")},"me"),e[18]=me):me=e[18];let ve=me,M;e[19]===Symbol.for("react.memo_cache_sentinel")?(M=r(()=>{h(null),c("addIndex")},"D"),e[19]=M):M=e[19];let B=M,ae;e[20]!==l?(ae=r(()=>{c("destructive"),h({kind:"needs-migration",message:l("This edit changes stored data and must go through a migration. Review the migration before applying.")})},"se"),e[20]=l,e[21]=ae):ae=e[21];let ue=ae,D;e[22]===Symbol.for("react.memo_cache_sentinel")?(D=r(G=>{y(G.target.value)},"R"),e[22]=D):D=e[22];let ne=D,R;e[23]===Symbol.for("react.memo_cache_sentinel")?(R=r(G=>{$(G.target.value)},"K"),e[23]=R):R=e[23];let se=R,re;e[24]===Symbol.for("react.memo_cache_sentinel")?(re=r(G=>{K(G.target.value)},"oe"),e[24]=re):re=e[24];let he=re,Y;e[25]===Symbol.for("react.memo_cache_sentinel")?(Y=r(G=>{O(G.target.value)},"X"),e[25]=Y):Y=e[25];let Z=Y,V;e[26]===Symbol.for("react.memo_cache_sentinel")?(V=r(G=>{P(G.target.value)},"U"),e[26]=V):V=e[26];let oe=V,U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=r(G=>{C(G.target.value)},"V"),e[27]=U):U=e[27];let ie=U,J;e[28]===Symbol.for("react.memo_cache_sentinel")?(J=r(G=>{F(G.target.checked)},"Y"),e[28]=J):J=e[28];let q=J,H;e[29]!==a?(H=r(()=>{ge(a({to:"/migrations"}))},"Z"),e[29]=a,e[30]=H):H=e[30];let f=H,ee;e[31]!==l?(ee=l("Edit schema"),e[31]=l,e[32]=ee):ee=e[32];let de;e[33]!==ee?(de=(0,t.jsx)(Ke,{children:ee}),e[33]=ee,e[34]=de):de=e[34];let ye;e[35]!==l?(ye=l("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=l,e[36]=ye):ye=e[36];let Te;e[37]!==ye?(Te=(0,t.jsx)(Pe,{children:ye}),e[37]=ye,e[38]=Te):Te=e[38];let Ne;e[39]!==de||e[40]!==Te?(Ne=(0,t.jsxs)(Ge,{children:[de,Te]}),e[39]=de,e[40]=Te,e[41]=Ne):Ne=e[41];let g=n.length>0,v;e[42]!==m||e[43]!==ue||e[44]!==g?(v=(0,t.jsx)(xt,{hasTables:g,mode:m,onAddColumn:ve,onAddIndex:B,onAddTable:X,onDestructive:ue}),e[42]=m,e[43]=ue,e[44]=g,e[45]=v):v=e[45];let w;e[46]!==d||e[47]!==m||e[48]!==xe||e[49]!==l||e[50]!==i?(w=m==="addTable"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(ke,{htmlFor:"sc-editor-table-name",children:l("Table name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:ne,value:i})]}),(0,t.jsx)(be,{"data-testid":"sc-editor-table-apply",disabled:d||i.trim()==="",onClick:xe,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(be,{onClick:te,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[46]=d,e[47]=m,e[48]=xe,e[49]=l,e[50]=i,e[51]=w):w=e[51];let A;e[52]!==d||e[53]!==p||e[54]!==m||e[55]!==ce||e[56]!==l||e[57]!==n||e[58]!==N||e[59]!==S?(A=m==="addColumn"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(ke,{htmlFor:"sc-editor-column-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-table",id:"sc-editor-column-table",onChange:Z,value:N,children:n.map(St)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(ke,{htmlFor:"sc-editor-column-name",children:l("Column name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:se,value:p})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(ke,{htmlFor:"sc-editor-column-type",children:l("Column type")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-type",id:"sc-editor-column-type",onChange:he,value:S,children:Nt.map(kt)})]}),(0,t.jsx)("span",{className:"text-[11px] text-muted-foreground",children:l("Optional")}),(0,t.jsx)(be,{"data-testid":"sc-editor-column-apply",disabled:d||p.trim()===""||N==="",onClick:ce,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(be,{onClick:te,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[52]=d,e[53]=p,e[54]=m,e[55]=ce,e[56]=l,e[57]=n,e[58]=N,e[59]=S,e[60]=A):A=e[60];let I;e[61]!==d||e[62]!==T||e[63]!==E||e[64]!==m||e[65]!==W||e[66]!==l||e[67]!==n||e[68]!==N||e[69]!==z?(I=m==="addIndex"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(ke,{htmlFor:"sc-editor-index-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-index-table",id:"sc-editor-index-table",onChange:Z,value:N,children:n.map(_t)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(ke,{htmlFor:"sc-editor-index-name",children:l("Index name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:oe,value:E})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(ke,{htmlFor:"sc-editor-index-fields",children:l("Index fields (comma-separated)")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:ie,value:T})]}),(0,t.jsxs)(ke,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[(0,t.jsx)("input",{checked:z,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:q,type:"checkbox"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:l("Unique")})]}),(0,t.jsx)(be,{"data-testid":"sc-editor-index-apply",disabled:d||E.trim()===""||T.trim()==="",onClick:W,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(be,{onClick:te,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[61]=d,e[62]=T,e[63]=E,e[64]=m,e[65]=W,e[66]=l,e[67]=n,e[68]=N,e[69]=z,e[70]=I):I=e[70];let pe;e[71]!==f||e[72]!==o?(pe=(0,t.jsx)(vt,{onOpenMigrations:f,result:o}),e[71]=f,e[72]=o,e[73]=pe):pe=e[73];let _e;e[74]!==v||e[75]!==w||e[76]!==A||e[77]!==I||e[78]!==pe?(_e=(0,t.jsxs)(Le,{children:[v,w,A,I,pe]}),e[74]=v,e[75]=w,e[76]=A,e[77]=I,e[78]=pe,e[79]=_e):_e=e[79];let Ie;return e[80]!==Ne||e[81]!==_e?(Ie=(0,t.jsxs)(qe,{"data-testid":"sc-editor",size:"sm",children:[Ne,_e]}),e[80]=Ne,e[81]=_e,e[82]=Ie):Ie=e[82],Ie},"Tt");function St(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(St,"St");function kt(s){return(0,t.jsx)("option",{value:s.validator,children:s.label},s.validator)}r(kt,"wt");function _t(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(_t,"_t");var et=[],It=r(s=>{let e=(0,we.c)(5),{open:u}=s,n=u&&"rotate-90",l;e[0]!==n?(l=De("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",n),e[0]=n,e[1]=l):l=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[2]=a):a=e[2];let m;return e[3]!==l?(m=(0,t.jsx)("svg",{"aria-hidden":"true",className:l,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:a}),e[3]=l,e[4]=m):m=e[4],m},"Et"),tt=r(s=>{let e=(0,we.c)(20),{children:u,expanded:n,name:l,onToggle:a,rowCount:m,rowTestId:c,toggleTestId:d}=s,b;e[0]!==n?(b=(0,t.jsx)(It,{open:n}),e[0]=n,e[1]=b):b=e[1];let o;e[2]!==l?(o=(0,t.jsx)("span",{className:"truncate font-mono text-xs text-foreground",title:l,children:l}),e[2]=l,e[3]=o):o=e[3];let h;e[4]!==m?(h=(0,t.jsxs)("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",m,")"]}),e[4]=m,e[5]=h):h=e[5];let i;e[6]!==n||e[7]!==a||e[8]!==b||e[9]!==o||e[10]!==h||e[11]!==d?(i=(0,t.jsxs)("button",{"aria-expanded":n,className:"flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40","data-testid":d,onClick:a,type:"button",children:[b,o," ",h]}),e[6]=n,e[7]=a,e[8]=b,e[9]=o,e[10]=h,e[11]=d,e[12]=i):i=e[12];let y;e[13]!==u||e[14]!==n?(y=n&&(0,t.jsx)("div",{className:"px-3 pb-3 ps-8",children:u}),e[13]=u,e[14]=n,e[15]=y):y=e[15];let p;return e[16]!==c||e[17]!==i||e[18]!==y?(p=(0,t.jsxs)("li",{className:"border-t border-border/60 first:border-t-0","data-testid":c,children:[i,y]}),e[16]=c,e[17]=i,e[18]=y,e[19]=p):p=e[19],p},"Je"),lt=r(s=>{let e=(0,we.c)(5),{columns:u,testId:n}=s,l;e[0]!==u?(l=u.map(zt),e[0]=u,e[1]=l):l=e[1];let a;return e[2]!==l||e[3]!==n?(a=(0,t.jsx)("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":n,children:l}),e[2]=l,e[3]=n,e[4]=a):a=e[4],a},"We"),At=r(s=>{let e=(0,we.c)(10),{heading:u,indexes:n,testId:l}=s,a;e[0]!==u?(a=(0,t.jsx)("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:u}),e[0]=u,e[1]=a):a=e[1];let m;e[2]!==n?(m=n.map(Et),e[2]=n,e[3]=m):m=e[3];let c;e[4]!==m||e[5]!==l?(c=(0,t.jsx)("ul",{className:"flex flex-col gap-1","data-testid":l,children:m}),e[4]=m,e[5]=l,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=(0,t.jsxs)("div",{className:"pt-3",children:[a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d},"It"),at=r(s=>De("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",s?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"Xe"),Xt=r(s=>{let e=(0,we.c)(85),{initialShardKey:u,initialTable:n,schemaEditable:l}=s,a=Oe(),m;e[0]!==u||e[1]!==n?(m={initialShardKey:u,initialTable:n},e[0]=u,e[1]=n,e[2]=m):m=e[2];let{columns:c,diagramTables:d,error:b,expanded:o,filteredGlobalTables:h,filteredTables:i,globalColumns:y,globalError:p,globalExpanded:$,globalTables:S,indexes:K,refresh:N,setShardKey:O,setTableFilter:E,setView:P,shardColumnsError:T,shardKey:C,tableFilter:z,tables:F,toggle:fe,toggleGlobal:te,view:_}=ut(m),j;e[3]!==P?(j=r(()=>{P("list")},"M"),e[3]=P,e[4]=j):j=e[4];let k=j,xe;e[5]!==P?(xe=r(()=>{P("graph")},"ge"),e[5]=P,e[6]=xe):xe=e[6];let L=xe,ce;e[7]!==E?(ce=r(f=>{E(f.target.value)},"ce"),e[7]=E,e[8]=ce):ce=e[8];let le=ce,W;e[9]!==N||e[10]!==C?(W=r(f=>{ge(N(C))},"J"),e[9]=N,e[10]=C,e[11]=W):W=e[11];let Ce=W,X;e[12]!==F?(X=F??[],e[12]=F,e[13]=X):X=e[13];let me;e[14]!==X?(me=X.map(Ft),e[14]=X,e[15]=me):me=e[15];let ve=me,M;e[16]!==O||e[17]!==C?(M=(0,t.jsx)(Xe,{onChange:O,testId:"sc-shard-input",value:C}),e[16]=O,e[17]=C,e[18]=M):M=e[18];let B;e[19]!==a?(B=a("Schema view"),e[19]=a,e[20]=B):B=e[20];let ae=_==="graph",ue=_==="graph",D;e[21]!==ue?(D=at(ue),e[21]=ue,e[22]=D):D=e[22];let ne;e[23]!==a?(ne=a("Graph"),e[23]=a,e[24]=ne):ne=e[24];let R;e[25]!==L||e[26]!==ae||e[27]!==D||e[28]!==ne?(R=(0,t.jsx)("button",{"aria-selected":ae,className:D,"data-testid":"sc-view-graph",onClick:L,role:"tab",type:"button",children:ne}),e[25]=L,e[26]=ae,e[27]=D,e[28]=ne,e[29]=R):R=e[29];let se=_==="list",re=_==="list",he;e[30]!==re?(he=at(re),e[30]=re,e[31]=he):he=e[31];let Y;e[32]!==a?(Y=a("Table list"),e[32]=a,e[33]=Y):Y=e[33];let Z;e[34]!==k||e[35]!==se||e[36]!==he||e[37]!==Y?(Z=(0,t.jsx)("button",{"aria-selected":se,className:he,"data-testid":"sc-view-list",onClick:k,role:"tab",type:"button",children:Y}),e[34]=k,e[35]=se,e[36]=he,e[37]=Y,e[38]=Z):Z=e[38];let V;e[39]!==R||e[40]!==Z||e[41]!==B?(V=(0,t.jsxs)("div",{"aria-label":B,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[R,Z]}),e[39]=R,e[40]=Z,e[41]=B,e[42]=V):V=e[42];let oe;e[43]!==V||e[44]!==M?(oe=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[M,V]}),e[43]=V,e[44]=M,e[45]=oe):oe=e[45];let U;e[46]!==Ce||e[47]!==l||e[48]!==ve?(U=l===!0&&(0,t.jsx)(wt,{onApplied:Ce,tableNames:ve}),e[46]=Ce,e[47]=l,e[48]=ve,e[49]=U):U=e[49];let ie;e[50]!==le||e[51]!==a||e[52]!==z||e[53]!==_?(ie=_==="list"&&(0,t.jsx)(Ae,{"aria-label":a("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:le,placeholder:a("Filter tables"),value:z}),e[50]=le,e[51]=a,e[52]=z,e[53]=_,e[54]=ie):ie=e[54];let J;e[55]!==d||e[56]!==b||e[57]!==p||e[58]!==T||e[59]!==C||e[60]!==_?(J=_==="graph"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[b!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:b}),p!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),(0,t.jsx)(Ze,{columnsError:T[C]===!0,tables:d,testIdPrefix:"sc-graph"})]}),e[55]=d,e[56]=b,e[57]=p,e[58]=T,e[59]=C,e[60]=_,e[61]=J):J=e[61];let q;e[62]!==c||e[63]!==b||e[64]!==o||e[65]!==h||e[66]!==i||e[67]!==y||e[68]!==p||e[69]!==$||e[70]!==S||e[71]!==K||e[72]!==C||e[73]!==a||e[74]!==F||e[75]!==fe||e[76]!==te||e[77]!==_?(q=_==="list"&&(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)(qe,{"data-testid":"sc-shard-section",size:"sm",children:[(0,t.jsxs)(Ge,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Re,{tier:"shard"}),(0,t.jsx)(Ke,{children:a("Shard tables")}),F!==null&&(0,t.jsx)(je,{className:"ms-auto tabular-nums",variant:"outline",children:i.length})]}),(0,t.jsx)(Pe,{children:Me.shard.hint})]}),(0,t.jsxs)(Le,{children:[b!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:b}),F!==null&&F.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:a("No tables in this shard.")}),F!==null&&F.length>0&&i.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:a("No tables match your filter.")}),i.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:i.map(f=>{let ee=`${C}:${f.name}`,de=K[ee]??[];return(0,t.jsxs)(tt,{expanded:o===f.name,name:f.name,onToggle:r(()=>{ge(fe(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-table-${f.name}`,toggleTestId:`sc-toggle-${f.name}`,children:[(0,t.jsx)(lt,{columns:c[ee]??et,testId:`sc-columns-${f.name}`}),de.length>0&&(0,t.jsx)(At,{heading:a("Indexes"),indexes:de,testId:`sc-indexes-${f.name}`})]},f.name)})})]})]}),(0,t.jsxs)(qe,{"data-testid":"sc-global-section",size:"sm",children:[(0,t.jsxs)(Ge,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Re,{tier:"global"}),(0,t.jsx)(Ke,{children:a("Global tables (D1)")}),S!==null&&(0,t.jsx)(je,{className:"ms-auto tabular-nums",variant:"outline",children:h.length})]}),(0,t.jsx)(Pe,{children:Me.global.hint})]}),(0,t.jsxs)(Le,{children:[p!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),S!==null&&S.length===0&&(0,t.jsx)(Qe,{description:Me.global.hint,testId:"sc-global-empty",title:a("No global tables.")}),S!==null&&S.length>0&&h.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:a("No tables match your filter.")}),h.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:h.map(f=>(0,t.jsx)(tt,{expanded:$===f.name,name:f.name,onToggle:r(()=>{ge(te(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-global-table-${f.name}`,toggleTestId:`sc-global-toggle-${f.name}`,children:(0,t.jsx)(lt,{columns:y[f.name]??et,testId:`sc-global-columns-${f.name}`})},f.name))})]})]})]}),e[62]=c,e[63]=b,e[64]=o,e[65]=h,e[66]=i,e[67]=y,e[68]=p,e[69]=$,e[70]=S,e[71]=K,e[72]=C,e[73]=a,e[74]=F,e[75]=fe,e[76]=te,e[77]=_,e[78]=q):q=e[78];let H;return e[79]!==oe||e[80]!==U||e[81]!==ie||e[82]!==J||e[83]!==q?(H=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[oe,U,ie,J,q]}),e[79]=oe,e[80]=U,e[81]=ie,e[82]=J,e[83]=q,e[84]=H):H=e[84],H},"Qt");function zt(s){return(0,t.jsx)("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:s},s)}r(zt,"kt");function Et(s){return(0,t.jsxs)("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[(0,t.jsx)("span",{className:"font-mono",children:s.name}),(0,t.jsx)(je,{variant:"outline",children:s.type}),s.unique===!0&&(0,t.jsx)(je,{variant:"secondary",children:"unique"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:s.fields.join(", ")})]},`${s.type}:${s.name}`)}r(Et,"At");function Ft(s){return s.name}r(Ft,"$t");export{Xt as SchemaViewer};
|
|
1
|
+
import{a as Ze}from"./chunk-5SCMOA55.js";import{a as Me,b as Re}from"./chunk-JNWK5MJC.js";import{a as ke}from"./chunk-ZVTDYI5T.js";import"./chunk-CUUNHCMD.js";import"./chunk-Y2YLTUMD.js";import"./chunk-2VGEXP5J.js";import"./chunk-LMCBMC2V.js";import"./chunk-QF743FSL.js";import"./chunk-IQ5CIBXJ.js";import"./chunk-YNCZVYCO.js";import"./chunk-OWRWDDJT.js";import"./chunk-QHVUXMRV.js";import"./chunk-2NUCBQFU.js";import{a as Ye}from"./chunk-2KTN53PK.js";import{a as Xe}from"./chunk-O3NLXHWS.js";import{b as We}from"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import{i as Ue}from"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import{i as Ae}from"./chunk-IGIBOJJG.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as be}from"./chunk-LMGNMZUF.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as Qe}from"./chunk-KN4GQKJS.js";import{b as je}from"./chunk-YCQ7ZPBP.js";import"./chunk-L27FKJTG.js";import{a as $e}from"./chunk-LYVYUTQY.js";import{a as qe,b as Ge,c as Ke,d as Pe,e as Le}from"./chunk-JXGB4QDO.js";import{n as Je}from"./chunk-OW7PWUF6.js";import"./chunk-ZPQBVYNN.js";import{B as Oe,h as ze,i as Ee,j as Fe,s as ge,x as De}from"./chunk-JEKJEGBJ.js";import"./chunk-PDBW6GTJ.js";import{a as st}from"./chunk-A6TVTNKO.js";import{a as nt,b as rt}from"./chunk-ADABTCDI.js";import{a as r,d as Be}from"./chunk-5PEAXTYQ.js";var we=Be(st(),1);var x=Be(nt(),1);var t=Be(rt(),1);var ot=ze($e.listTables),it=ze($e.listTableIndexes),dt=ze($e.readTablePage),ct=ze($e.describeTables),mt={},He=[],ut=r(s=>{let e=(0,we.c)(74),{initialShardKey:u,initialTable:n}=s,l=Je(),[a,m]=(0,x.useState)("graph"),{queryShardKey:c,setShardKey:d,shardKey:b}=Ye(u),[o,h]=(0,x.useState)(""),[i,y]=(0,x.useState)(null),[p,$]=(0,x.useState)(null),S;e[0]===Symbol.for("react.memo_cache_sentinel")?(S={},e[0]=S):S=e[0];let[K,N]=(0,x.useState)(S),O;e[1]===Symbol.for("react.memo_cache_sentinel")?(O={},e[1]=O):O=e[1];let[E,P]=(0,x.useState)(O),[T,C]=(0,x.useState)(null),z;e[2]===Symbol.for("react.memo_cache_sentinel")?(z={},e[2]=z):z=e[2];let[F,fe]=(0,x.useState)(z),te;e[3]===Symbol.for("react.memo_cache_sentinel")?(te={},e[3]=te):te=e[3];let[_,j]=(0,x.useState)(te),[k,xe]=(0,x.useState)(null),[L,ce]=(0,x.useState)(null),le;e[4]===Symbol.for("react.memo_cache_sentinel")?(le={},e[4]=le):le=e[4];let[W,Ce]=(0,x.useState)(le),[X,me]=(0,x.useState)(null),ve=(0,x.useRef)(0),M;e[5]!==l?(M=r(async g=>{ve.current=ve.current+1;let v=ve.current;$(null);try{let w=await l.query(ot,{},Ee(g));if(v!==ve.current)return;We(g),y(w),N({}),P({}),C(null),fe(A=>Object.fromEntries(Object.entries(A).filter(I=>{let[pe]=I;return pe!==g}))),j(A=>Object.fromEntries(Object.entries(A).filter(I=>{let[pe]=I;return pe!==g})))}catch(w){let A=w;if(v!==ve.current)return;y(null),$(Fe(A))}},"D"),e[5]=l,e[6]=M):M=e[6];let B=M,ae;e[7]!==l?(ae=r(async()=>{ce(null);try{xe(await l.listGlobalTables())}catch(g){let v=g;xe(null),ce(Fe(v))}},"se"),e[7]=l,e[8]=ae):ae=e[8];let ue=ae,D,ne;e[9]!==c||e[10]!==B||e[11]!==ue?(D=r(()=>{ge(B(c)),ge(ue())},"R"),ne=[B,ue,c],e[9]=c,e[10]=B,e[11]=ue,e[12]=D,e[13]=ne):(D=e[12],ne=e[13]),(0,x.useEffect)(D,ne);let R;e[14]!==l||e[15]!==K||e[16]!==T||e[17]!==c?(R=r(async g=>{if(T===g){C(null);return}C(g);let v=`${c}:${g}`;if(K[v]!==void 0)return;let[w,A]=await Promise.allSettled([l.query(dt,{limit:1,offset:0,table:g},Ee(c)),l.query(it,{table:g},Ee(c))]);w.status==="fulfilled"?N(I=>({...I,[v]:w.value.columns})):$(Fe(w.reason)),A.status==="fulfilled"&&P(I=>({...I,[v]:A.value.indexes}))},"K"),e[14]=l,e[15]=K,e[16]=T,e[17]=c,e[18]=R):R=e[18];let se=R,re;e[19]!==l||e[20]!==W||e[21]!==X?(re=r(async g=>{if(X===g){me(null);return}if(me(g),W[g]===void 0)try{let v=await l.readGlobalTablePage({limit:1,offset:0,table:g});Ce(w=>({...w,[g]:v.columns}))}catch(v){ce(Fe(v))}},"oe"),e[19]=l,e[20]=W,e[21]=X,e[22]=re):re=e[22];let he=re,Y=(0,x.useRef)(void 0),Z,V;e[23]!==n||e[24]!==i||e[25]!==se?(Z=r(()=>{n===void 0||i===null||Y.current===n||i.some(g=>g.name===n)&&(Y.current=n,ge(se(n)))},"Q"),V=[n,i,se],e[23]=n,e[24]=i,e[25]=se,e[26]=Z,e[27]=V):(Z=e[26],V=e[27]),(0,x.useEffect)(Z,V);let oe;e[28]!==l?(oe=r(async(g,v,w)=>{let[A,I]=await Promise.all([Promise.allSettled([l.query(ct,{tables:[...v,...w]},Ee(g))]),Promise.all(w.map(async Q=>{let Se=await Promise.allSettled([l.readGlobalTablePage({limit:1,offset:0,table:Q})]),Ve=Se[0].status==="fulfilled"?Se[0].value:void 0;return{columns:Ve?.columns??[],refs:Ve?.refs??{},table:Q}}))]),pe=A[0].status==="fulfilled"?A[0].value?.columnsByTable??{}:{},_e=A[0].status==="rejected",Ie=new Map(I.map(ht)),G=[...v,...w].map(Q=>{let Se=pe[Q]??[];return[Q,Se.length>0?Se:Ie.get(Q)??[]]});fe(Q=>({...Q,[g]:Object.fromEntries(G)})),j(Q=>({...Q,[g]:_e}))},"ie"),e[28]=l,e[29]=oe):oe=e[29];let U=oe,ie,J;e[30]!==L||e[31]!==k||e[32]!==U||e[33]!==c||e[34]!==F||e[35]!==i||e[36]!==a?(ie=r(()=>{a!=="graph"||i===null||k===null&&L===null||F[c]!==void 0||ge(U(c,i.map(pt),(k??[]).map(gt)))},"re"),J=[a,i,k,L,c,F,U],e[30]=L,e[31]=k,e[32]=U,e[33]=c,e[34]=F,e[35]=i,e[36]=a,e[37]=ie,e[38]=J):(ie=e[37],J=e[38]),(0,x.useEffect)(ie,J);let q=F[c]??mt,H;if(e[39]!==q||e[40]!==k||e[41]!==i){let g;e[43]!==q?(g=r(I=>({columns:q[I.name]??He,name:I.name,tier:"shard"}),"h"),e[43]=q,e[44]=g):g=e[44];let v=(i??[]).map(g),w;e[45]!==q?(w=r(I=>({columns:q[I.name]??He,name:I.name,tier:"global"}),"N"),e[45]=q,e[46]=w):w=e[46];let A=(k??[]).map(w);H=[...v,...A],e[39]=q,e[40]=k,e[41]=i,e[42]=H}else H=e[42];let f=H,ee;if(e[47]!==o||e[48]!==i){let g=o.trim().toLowerCase();ee=(i??[]).filter(v=>v.name.toLowerCase().includes(g)),e[47]=o,e[48]=i,e[49]=ee}else ee=e[49];let de=ee,ye;if(e[50]!==k||e[51]!==o){let g=o.trim().toLowerCase();ye=(k??[]).filter(v=>v.name.toLowerCase().includes(g)),e[50]=k,e[51]=o,e[52]=ye}else ye=e[52];let Te=ye,Ne;return e[53]!==K||e[54]!==f||e[55]!==p||e[56]!==T||e[57]!==Te||e[58]!==de||e[59]!==W||e[60]!==L||e[61]!==X||e[62]!==k||e[63]!==E||e[64]!==B||e[65]!==d||e[66]!==_||e[67]!==b||e[68]!==o||e[69]!==i||e[70]!==se||e[71]!==he||e[72]!==a?(Ne={columns:K,diagramTables:f,error:p,expanded:T,filteredGlobalTables:Te,filteredTables:de,globalColumns:W,globalError:L,globalExpanded:X,globalTables:k,indexes:E,refresh:B,setShardKey:d,setTableFilter:h,setView:m,shardColumnsError:_,shardKey:b,tableFilter:o,tables:i,toggle:se,toggleGlobal:he,view:a},e[53]=K,e[54]=f,e[55]=p,e[56]=T,e[57]=Te,e[58]=de,e[59]=W,e[60]=L,e[61]=X,e[62]=k,e[63]=E,e[64]=B,e[65]=d,e[66]=_,e[67]=b,e[68]=o,e[69]=i,e[70]=se,e[71]=he,e[72]=a,e[73]=Ne):Ne=e[73],Ne},"mt");function ht(s){let{columns:e,refs:u,table:n}=s;return[n,e.map(l=>{let a=u[l];return a===void 0?{name:l,optional:!1,type:""}:{name:l,optional:!1,ref:a,type:"id"}})]}r(ht,"ut");function pt(s){return s.name}r(pt,"ft");function gt(s){return s.name}r(gt,"ht");var bt="/__lunora/schema-edit",ft=r(async s=>{let e=await fetch(bt,{body:JSON.stringify(s),headers:{"Content-Type":"application/json"},method:"POST"}),u=await e.json();return u.needsMigration===!0?{kind:"needs-migration",message:u.message??"This edit needs a migration."}:e.ok&&u.tables!==void 0?{diagnostics:u.diagnostics??[],kind:"ok",tables:u.tables}:{kind:"error",message:u.error??`schema edit failed (${String(e.status)})`}},"gt"),xt=r(s=>{let e=(0,we.c)(32),{hasTables:u,mode:n,onAddColumn:l,onAddIndex:a,onAddTable:m,onDestructive:c}=s,d=Oe(),b=n==="addTable"?"default":"outline",o;e[0]!==d?(o=d("Add table"),e[0]=d,e[1]=o):o=e[1];let h;e[2]!==m||e[3]!==b||e[4]!==o?(h=(0,t.jsx)(be,{"data-testid":"sc-editor-add-table",onClick:m,size:"xs",type:"button",variant:b,children:o}),e[2]=m,e[3]=b,e[4]=o,e[5]=h):h=e[5];let i=!u,y=n==="addColumn"?"default":"outline",p;e[6]!==d?(p=d("Add column"),e[6]=d,e[7]=p):p=e[7];let $;e[8]!==l||e[9]!==i||e[10]!==y||e[11]!==p?($=(0,t.jsx)(be,{"data-testid":"sc-editor-add-column",disabled:i,onClick:l,size:"xs",type:"button",variant:y,children:p}),e[8]=l,e[9]=i,e[10]=y,e[11]=p,e[12]=$):$=e[12];let S=!u,K=n==="addIndex"?"default":"outline",N;e[13]!==d?(N=d("Add index"),e[13]=d,e[14]=N):N=e[14];let O;e[15]!==a||e[16]!==N||e[17]!==S||e[18]!==K?(O=(0,t.jsx)(be,{"data-testid":"sc-editor-add-index",disabled:S,onClick:a,size:"xs",type:"button",variant:K,children:N}),e[15]=a,e[16]=N,e[17]=S,e[18]=K,e[19]=O):O=e[19];let E=!u,P=n==="destructive"?"default":"ghost",T;e[20]!==d?(T=d("Rename / drop / change type\u2026"),e[20]=d,e[21]=T):T=e[21];let C;e[22]!==c||e[23]!==E||e[24]!==P||e[25]!==T?(C=(0,t.jsx)(be,{"data-testid":"sc-editor-destructive",disabled:E,onClick:c,size:"xs",type:"button",variant:P,children:T}),e[22]=c,e[23]=E,e[24]=P,e[25]=T,e[26]=C):C=e[26];let z;return e[27]!==O||e[28]!==C||e[29]!==h||e[30]!==$?(z=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[h,$,O,C]}),e[27]=O,e[28]=C,e[29]=h,e[30]=$,e[31]=z):z=e[31],z},"bt"),vt=r(s=>{let e=(0,we.c)(28),{onOpenMigrations:u,result:n}=s,l=Oe();if(n===null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[0]=o):o=e[0],o}if(n.kind==="error"){let o;return e[1]!==n.message?(o=(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:n.message}),e[1]=n.message,e[2]=o):o=e[2],o}if(n.kind==="needs-migration"){let o;e[3]!==n.message||e[4]!==l?(o=n.message===""?l("This edit changes stored data and must go through a migration. Review the migration before applying."):n.message,e[3]=n.message,e[4]=l,e[5]=o):o=e[5];let h;e[6]!==o?(h=(0,t.jsx)("p",{className:"text-sm text-warning",role:"alert",children:o}),e[6]=o,e[7]=h):h=e[7];let i;e[8]!==l?(i=l("Open Migrations"),e[8]=l,e[9]=i):i=e[9];let y;e[10]!==u||e[11]!==i?(y=(0,t.jsx)(be,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:u,size:"xs",type:"button",variant:"outline",children:i}),e[10]=u,e[11]=i,e[12]=y):y=e[12];let p;return e[13]!==h||e[14]!==y?(p=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[h,y]}),e[13]=h,e[14]=y,e[15]=p):p=e[15],p}if(n.diagnostics.length===0){let o;return e[16]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[16]=o):o=e[16],o}let a;e[17]!==l?(a=l("Codegen reported diagnostics:"),e[17]=l,e[18]=a):a=e[18];let m;e[19]!==a?(m=(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:a}),e[19]=a,e[20]=m):m=e[20];let c;e[21]!==n.diagnostics?(c=n.diagnostics.map(yt),e[21]=n.diagnostics,e[22]=c):c=e[22];let d;e[23]!==c?(d=(0,t.jsx)("ul",{className:"flex flex-col gap-0.5",children:c}),e[23]=c,e[24]=d):d=e[24];let b;return e[25]!==m||e[26]!==d?(b=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[m,d]}),e[25]=m,e[26]=d,e[27]=b):b=e[27],b},"xt");function yt(s){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:s},s)}r(yt,"vt");var Nt=[{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()",Tt=r(s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),"Nt"),wt=r(s=>{let e=(0,we.c)(83),{onApplied:u,tableNames:n}=s,l=Oe(),a=Ue(),[m,c]=(0,x.useState)(null),[d,b]=(0,x.useState)(!1),[o,h]=(0,x.useState)(null),[i,y]=(0,x.useState)(""),[p,$]=(0,x.useState)(""),[S,K]=(0,x.useState)(Ct),[N,O]=(0,x.useState)(n[0]??""),[E,P]=(0,x.useState)(""),[T,C]=(0,x.useState)(""),[z,F]=(0,x.useState)(!1),fe;e[0]===Symbol.for("react.memo_cache_sentinel")?(fe=r(()=>{c(null),y(""),$(""),P(""),C(""),F(!1)},"pe"),e[0]=fe):fe=e[0];let te=fe,_;e[1]!==u?(_=r(async G=>{b(!0),h(null);try{let Q=await ft(G);h(Q),Q.kind==="ok"&&(u(Q.tables),te())}catch(Q){let Se=Q;h({kind:"error",message:Se instanceof Error?Se.message:String(Se)})}b(!1)},"E"),e[1]=u,e[2]=_):_=e[2];let j=_,k;e[3]!==j||e[4]!==i?(k=r(()=>{ge(j({kind:"addTable",table:i.trim()}))},"w"),e[3]=j,e[4]=i,e[5]=k):k=e[5];let xe=k,L;e[6]!==p||e[7]!==j||e[8]!==N||e[9]!==S?(L=r(()=>{ge(j({column:p.trim(),kind:"addOptionalColumn",table:N,validator:S}))},"B"),e[6]=p,e[7]=j,e[8]=N,e[9]=S,e[10]=L):L=e[10];let ce=L,le;e[11]!==T||e[12]!==E||e[13]!==j||e[14]!==N||e[15]!==z?(le=r(()=>{ge(j({fields:Tt(T),kind:"addIndex",name:E.trim(),table:N,unique:z}))},"le"),e[11]=T,e[12]=E,e[13]=j,e[14]=N,e[15]=z,e[16]=le):le=e[16];let W=le,Ce;e[17]===Symbol.for("react.memo_cache_sentinel")?(Ce=r(()=>{h(null),c("addTable")},"Ne"),e[17]=Ce):Ce=e[17];let X=Ce,me;e[18]===Symbol.for("react.memo_cache_sentinel")?(me=r(()=>{h(null),c("addColumn")},"me"),e[18]=me):me=e[18];let ve=me,M;e[19]===Symbol.for("react.memo_cache_sentinel")?(M=r(()=>{h(null),c("addIndex")},"D"),e[19]=M):M=e[19];let B=M,ae;e[20]!==l?(ae=r(()=>{c("destructive"),h({kind:"needs-migration",message:l("This edit changes stored data and must go through a migration. Review the migration before applying.")})},"se"),e[20]=l,e[21]=ae):ae=e[21];let ue=ae,D;e[22]===Symbol.for("react.memo_cache_sentinel")?(D=r(G=>{y(G.target.value)},"R"),e[22]=D):D=e[22];let ne=D,R;e[23]===Symbol.for("react.memo_cache_sentinel")?(R=r(G=>{$(G.target.value)},"K"),e[23]=R):R=e[23];let se=R,re;e[24]===Symbol.for("react.memo_cache_sentinel")?(re=r(G=>{K(G.target.value)},"oe"),e[24]=re):re=e[24];let he=re,Y;e[25]===Symbol.for("react.memo_cache_sentinel")?(Y=r(G=>{O(G.target.value)},"X"),e[25]=Y):Y=e[25];let Z=Y,V;e[26]===Symbol.for("react.memo_cache_sentinel")?(V=r(G=>{P(G.target.value)},"U"),e[26]=V):V=e[26];let oe=V,U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=r(G=>{C(G.target.value)},"V"),e[27]=U):U=e[27];let ie=U,J;e[28]===Symbol.for("react.memo_cache_sentinel")?(J=r(G=>{F(G.target.checked)},"Y"),e[28]=J):J=e[28];let q=J,H;e[29]!==a?(H=r(()=>{ge(a({to:"/migrations"}))},"Z"),e[29]=a,e[30]=H):H=e[30];let f=H,ee;e[31]!==l?(ee=l("Edit schema"),e[31]=l,e[32]=ee):ee=e[32];let de;e[33]!==ee?(de=(0,t.jsx)(Ke,{children:ee}),e[33]=ee,e[34]=de):de=e[34];let ye;e[35]!==l?(ye=l("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=l,e[36]=ye):ye=e[36];let Te;e[37]!==ye?(Te=(0,t.jsx)(Pe,{children:ye}),e[37]=ye,e[38]=Te):Te=e[38];let Ne;e[39]!==de||e[40]!==Te?(Ne=(0,t.jsxs)(Ge,{children:[de,Te]}),e[39]=de,e[40]=Te,e[41]=Ne):Ne=e[41];let g=n.length>0,v;e[42]!==m||e[43]!==ue||e[44]!==g?(v=(0,t.jsx)(xt,{hasTables:g,mode:m,onAddColumn:ve,onAddIndex:B,onAddTable:X,onDestructive:ue}),e[42]=m,e[43]=ue,e[44]=g,e[45]=v):v=e[45];let w;e[46]!==d||e[47]!==m||e[48]!==xe||e[49]!==l||e[50]!==i?(w=m==="addTable"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(ke,{htmlFor:"sc-editor-table-name",children:l("Table name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:ne,value:i})]}),(0,t.jsx)(be,{"data-testid":"sc-editor-table-apply",disabled:d||i.trim()==="",onClick:xe,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(be,{onClick:te,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[46]=d,e[47]=m,e[48]=xe,e[49]=l,e[50]=i,e[51]=w):w=e[51];let A;e[52]!==d||e[53]!==p||e[54]!==m||e[55]!==ce||e[56]!==l||e[57]!==n||e[58]!==N||e[59]!==S?(A=m==="addColumn"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(ke,{htmlFor:"sc-editor-column-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-table",id:"sc-editor-column-table",onChange:Z,value:N,children:n.map(St)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(ke,{htmlFor:"sc-editor-column-name",children:l("Column name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:se,value:p})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(ke,{htmlFor:"sc-editor-column-type",children:l("Column type")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-type",id:"sc-editor-column-type",onChange:he,value:S,children:Nt.map(kt)})]}),(0,t.jsx)("span",{className:"text-[11px] text-muted-foreground",children:l("Optional")}),(0,t.jsx)(be,{"data-testid":"sc-editor-column-apply",disabled:d||p.trim()===""||N==="",onClick:ce,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(be,{onClick:te,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[52]=d,e[53]=p,e[54]=m,e[55]=ce,e[56]=l,e[57]=n,e[58]=N,e[59]=S,e[60]=A):A=e[60];let I;e[61]!==d||e[62]!==T||e[63]!==E||e[64]!==m||e[65]!==W||e[66]!==l||e[67]!==n||e[68]!==N||e[69]!==z?(I=m==="addIndex"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(ke,{htmlFor:"sc-editor-index-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-index-table",id:"sc-editor-index-table",onChange:Z,value:N,children:n.map(_t)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(ke,{htmlFor:"sc-editor-index-name",children:l("Index name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:oe,value:E})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(ke,{htmlFor:"sc-editor-index-fields",children:l("Index fields (comma-separated)")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:ie,value:T})]}),(0,t.jsxs)(ke,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[(0,t.jsx)("input",{checked:z,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:q,type:"checkbox"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:l("Unique")})]}),(0,t.jsx)(be,{"data-testid":"sc-editor-index-apply",disabled:d||E.trim()===""||T.trim()==="",onClick:W,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(be,{onClick:te,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[61]=d,e[62]=T,e[63]=E,e[64]=m,e[65]=W,e[66]=l,e[67]=n,e[68]=N,e[69]=z,e[70]=I):I=e[70];let pe;e[71]!==f||e[72]!==o?(pe=(0,t.jsx)(vt,{onOpenMigrations:f,result:o}),e[71]=f,e[72]=o,e[73]=pe):pe=e[73];let _e;e[74]!==v||e[75]!==w||e[76]!==A||e[77]!==I||e[78]!==pe?(_e=(0,t.jsxs)(Le,{children:[v,w,A,I,pe]}),e[74]=v,e[75]=w,e[76]=A,e[77]=I,e[78]=pe,e[79]=_e):_e=e[79];let Ie;return e[80]!==Ne||e[81]!==_e?(Ie=(0,t.jsxs)(qe,{"data-testid":"sc-editor",size:"sm",children:[Ne,_e]}),e[80]=Ne,e[81]=_e,e[82]=Ie):Ie=e[82],Ie},"Tt");function St(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(St,"St");function kt(s){return(0,t.jsx)("option",{value:s.validator,children:s.label},s.validator)}r(kt,"wt");function _t(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(_t,"_t");var et=[],It=r(s=>{let e=(0,we.c)(5),{open:u}=s,n=u&&"rotate-90",l;e[0]!==n?(l=De("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",n),e[0]=n,e[1]=l):l=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[2]=a):a=e[2];let m;return e[3]!==l?(m=(0,t.jsx)("svg",{"aria-hidden":"true",className:l,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:a}),e[3]=l,e[4]=m):m=e[4],m},"Et"),tt=r(s=>{let e=(0,we.c)(20),{children:u,expanded:n,name:l,onToggle:a,rowCount:m,rowTestId:c,toggleTestId:d}=s,b;e[0]!==n?(b=(0,t.jsx)(It,{open:n}),e[0]=n,e[1]=b):b=e[1];let o;e[2]!==l?(o=(0,t.jsx)("span",{className:"truncate font-mono text-xs text-foreground",title:l,children:l}),e[2]=l,e[3]=o):o=e[3];let h;e[4]!==m?(h=(0,t.jsxs)("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",m,")"]}),e[4]=m,e[5]=h):h=e[5];let i;e[6]!==n||e[7]!==a||e[8]!==b||e[9]!==o||e[10]!==h||e[11]!==d?(i=(0,t.jsxs)("button",{"aria-expanded":n,className:"flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40","data-testid":d,onClick:a,type:"button",children:[b,o," ",h]}),e[6]=n,e[7]=a,e[8]=b,e[9]=o,e[10]=h,e[11]=d,e[12]=i):i=e[12];let y;e[13]!==u||e[14]!==n?(y=n&&(0,t.jsx)("div",{className:"px-3 pb-3 ps-8",children:u}),e[13]=u,e[14]=n,e[15]=y):y=e[15];let p;return e[16]!==c||e[17]!==i||e[18]!==y?(p=(0,t.jsxs)("li",{className:"border-t border-border/60 first:border-t-0","data-testid":c,children:[i,y]}),e[16]=c,e[17]=i,e[18]=y,e[19]=p):p=e[19],p},"Je"),lt=r(s=>{let e=(0,we.c)(5),{columns:u,testId:n}=s,l;e[0]!==u?(l=u.map(zt),e[0]=u,e[1]=l):l=e[1];let a;return e[2]!==l||e[3]!==n?(a=(0,t.jsx)("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":n,children:l}),e[2]=l,e[3]=n,e[4]=a):a=e[4],a},"We"),At=r(s=>{let e=(0,we.c)(10),{heading:u,indexes:n,testId:l}=s,a;e[0]!==u?(a=(0,t.jsx)("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:u}),e[0]=u,e[1]=a):a=e[1];let m;e[2]!==n?(m=n.map(Et),e[2]=n,e[3]=m):m=e[3];let c;e[4]!==m||e[5]!==l?(c=(0,t.jsx)("ul",{className:"flex flex-col gap-1","data-testid":l,children:m}),e[4]=m,e[5]=l,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=(0,t.jsxs)("div",{className:"pt-3",children:[a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d},"It"),at=r(s=>De("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",s?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"Xe"),Xt=r(s=>{let e=(0,we.c)(85),{initialShardKey:u,initialTable:n,schemaEditable:l}=s,a=Oe(),m;e[0]!==u||e[1]!==n?(m={initialShardKey:u,initialTable:n},e[0]=u,e[1]=n,e[2]=m):m=e[2];let{columns:c,diagramTables:d,error:b,expanded:o,filteredGlobalTables:h,filteredTables:i,globalColumns:y,globalError:p,globalExpanded:$,globalTables:S,indexes:K,refresh:N,setShardKey:O,setTableFilter:E,setView:P,shardColumnsError:T,shardKey:C,tableFilter:z,tables:F,toggle:fe,toggleGlobal:te,view:_}=ut(m),j;e[3]!==P?(j=r(()=>{P("list")},"M"),e[3]=P,e[4]=j):j=e[4];let k=j,xe;e[5]!==P?(xe=r(()=>{P("graph")},"ge"),e[5]=P,e[6]=xe):xe=e[6];let L=xe,ce;e[7]!==E?(ce=r(f=>{E(f.target.value)},"ce"),e[7]=E,e[8]=ce):ce=e[8];let le=ce,W;e[9]!==N||e[10]!==C?(W=r(f=>{ge(N(C))},"J"),e[9]=N,e[10]=C,e[11]=W):W=e[11];let Ce=W,X;e[12]!==F?(X=F??[],e[12]=F,e[13]=X):X=e[13];let me;e[14]!==X?(me=X.map(Ft),e[14]=X,e[15]=me):me=e[15];let ve=me,M;e[16]!==O||e[17]!==C?(M=(0,t.jsx)(Xe,{onChange:O,testId:"sc-shard-input",value:C}),e[16]=O,e[17]=C,e[18]=M):M=e[18];let B;e[19]!==a?(B=a("Schema view"),e[19]=a,e[20]=B):B=e[20];let ae=_==="graph",ue=_==="graph",D;e[21]!==ue?(D=at(ue),e[21]=ue,e[22]=D):D=e[22];let ne;e[23]!==a?(ne=a("Graph"),e[23]=a,e[24]=ne):ne=e[24];let R;e[25]!==L||e[26]!==ae||e[27]!==D||e[28]!==ne?(R=(0,t.jsx)("button",{"aria-selected":ae,className:D,"data-testid":"sc-view-graph",onClick:L,role:"tab",type:"button",children:ne}),e[25]=L,e[26]=ae,e[27]=D,e[28]=ne,e[29]=R):R=e[29];let se=_==="list",re=_==="list",he;e[30]!==re?(he=at(re),e[30]=re,e[31]=he):he=e[31];let Y;e[32]!==a?(Y=a("Table list"),e[32]=a,e[33]=Y):Y=e[33];let Z;e[34]!==k||e[35]!==se||e[36]!==he||e[37]!==Y?(Z=(0,t.jsx)("button",{"aria-selected":se,className:he,"data-testid":"sc-view-list",onClick:k,role:"tab",type:"button",children:Y}),e[34]=k,e[35]=se,e[36]=he,e[37]=Y,e[38]=Z):Z=e[38];let V;e[39]!==R||e[40]!==Z||e[41]!==B?(V=(0,t.jsxs)("div",{"aria-label":B,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[R,Z]}),e[39]=R,e[40]=Z,e[41]=B,e[42]=V):V=e[42];let oe;e[43]!==V||e[44]!==M?(oe=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[M,V]}),e[43]=V,e[44]=M,e[45]=oe):oe=e[45];let U;e[46]!==Ce||e[47]!==l||e[48]!==ve?(U=l===!0&&(0,t.jsx)(wt,{onApplied:Ce,tableNames:ve}),e[46]=Ce,e[47]=l,e[48]=ve,e[49]=U):U=e[49];let ie;e[50]!==le||e[51]!==a||e[52]!==z||e[53]!==_?(ie=_==="list"&&(0,t.jsx)(Ae,{"aria-label":a("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:le,placeholder:a("Filter tables"),value:z}),e[50]=le,e[51]=a,e[52]=z,e[53]=_,e[54]=ie):ie=e[54];let J;e[55]!==d||e[56]!==b||e[57]!==p||e[58]!==T||e[59]!==C||e[60]!==_?(J=_==="graph"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[b!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:b}),p!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),(0,t.jsx)(Ze,{columnsError:T[C]===!0,tables:d,testIdPrefix:"sc-graph"})]}),e[55]=d,e[56]=b,e[57]=p,e[58]=T,e[59]=C,e[60]=_,e[61]=J):J=e[61];let q;e[62]!==c||e[63]!==b||e[64]!==o||e[65]!==h||e[66]!==i||e[67]!==y||e[68]!==p||e[69]!==$||e[70]!==S||e[71]!==K||e[72]!==C||e[73]!==a||e[74]!==F||e[75]!==fe||e[76]!==te||e[77]!==_?(q=_==="list"&&(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)(qe,{"data-testid":"sc-shard-section",size:"sm",children:[(0,t.jsxs)(Ge,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Re,{tier:"shard"}),(0,t.jsx)(Ke,{children:a("Shard tables")}),F!==null&&(0,t.jsx)(je,{className:"ms-auto tabular-nums",variant:"outline",children:i.length})]}),(0,t.jsx)(Pe,{children:Me.shard.hint})]}),(0,t.jsxs)(Le,{children:[b!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:b}),F!==null&&F.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:a("No tables in this shard.")}),F!==null&&F.length>0&&i.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:a("No tables match your filter.")}),i.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:i.map(f=>{let ee=`${C}:${f.name}`,de=K[ee]??[];return(0,t.jsxs)(tt,{expanded:o===f.name,name:f.name,onToggle:r(()=>{ge(fe(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-table-${f.name}`,toggleTestId:`sc-toggle-${f.name}`,children:[(0,t.jsx)(lt,{columns:c[ee]??et,testId:`sc-columns-${f.name}`}),de.length>0&&(0,t.jsx)(At,{heading:a("Indexes"),indexes:de,testId:`sc-indexes-${f.name}`})]},f.name)})})]})]}),(0,t.jsxs)(qe,{"data-testid":"sc-global-section",size:"sm",children:[(0,t.jsxs)(Ge,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Re,{tier:"global"}),(0,t.jsx)(Ke,{children:a("Global tables (D1)")}),S!==null&&(0,t.jsx)(je,{className:"ms-auto tabular-nums",variant:"outline",children:h.length})]}),(0,t.jsx)(Pe,{children:Me.global.hint})]}),(0,t.jsxs)(Le,{children:[p!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),S!==null&&S.length===0&&(0,t.jsx)(Qe,{description:Me.global.hint,testId:"sc-global-empty",title:a("No global tables.")}),S!==null&&S.length>0&&h.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:a("No tables match your filter.")}),h.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:h.map(f=>(0,t.jsx)(tt,{expanded:$===f.name,name:f.name,onToggle:r(()=>{ge(te(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-global-table-${f.name}`,toggleTestId:`sc-global-toggle-${f.name}`,children:(0,t.jsx)(lt,{columns:y[f.name]??et,testId:`sc-global-columns-${f.name}`})},f.name))})]})]})]}),e[62]=c,e[63]=b,e[64]=o,e[65]=h,e[66]=i,e[67]=y,e[68]=p,e[69]=$,e[70]=S,e[71]=K,e[72]=C,e[73]=a,e[74]=F,e[75]=fe,e[76]=te,e[77]=_,e[78]=q):q=e[78];let H;return e[79]!==oe||e[80]!==U||e[81]!==ie||e[82]!==J||e[83]!==q?(H=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[oe,U,ie,J,q]}),e[79]=oe,e[80]=U,e[81]=ie,e[82]=J,e[83]=q,e[84]=H):H=e[84],H},"Qt");function zt(s){return(0,t.jsx)("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:s},s)}r(zt,"kt");function Et(s){return(0,t.jsxs)("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[(0,t.jsx)("span",{className:"font-mono",children:s.name}),(0,t.jsx)(je,{variant:"outline",children:s.type}),s.unique===!0&&(0,t.jsx)(je,{variant:"secondary",children:"unique"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:s.fields.join(", ")})]},`${s.type}:${s.name}`)}r(Et,"At");function Ft(s){return s.name}r(Ft,"$t");export{Xt as SchemaViewer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as y,b as D}from"./chunk-JNWK5MJC.js";import{a as _,b as z,c as j,d as E,e as B,f as H,g as L,h as V,i as O,j as T,k as Z,l as q}from"./chunk-FPRVR763.js";import{i as I}from"./chunk-A5INOAIL.js";import{a as k}from"./chunk-SZCXVIVT.js";import{b as w}from"./chunk-TRJMN2YI.js";import{B as $,s as P,x as N}from"./chunk-4S7ZIMWI.js";import{a as se}from"./chunk-A6TVTNKO.js";import{a as le,b as de}from"./chunk-ADABTCDI.js";import{a as u,d as S}from"./chunk-5PEAXTYQ.js";var v=S(se(),1);var b=S(le(),1);var s=S(de(),1);function ie(a){let e=(0,v.c)(10),t,n,r;e[0]!==a?({className:t,selected:r,...n}=a,e[0]=a,e[1]=t,e[2]=n,e[3]=r):(t=e[1],n=e[2],r=e[3]);let l=r===!0?"":void 0,o;e[4]!==t?(o=N("rounded-md border border-border bg-card text-card-foreground shadow-sm transition-colors","data-[selected]:border-ring data-[selected]:ring-[3px] data-[selected]:ring-ring/30",t),e[4]=t,e[5]=o):o=e[5];let d;return e[6]!==n||e[7]!==l||e[8]!==o?(d=(0,s.jsx)("div",{"data-slot":"base-node","data-selected":l,className:o,...n}),e[6]=n,e[7]=l,e[8]=o,e[9]=d):d=e[9],d}u(ie,"ie");function ce(a){let e=(0,v.c)(8),t,n;e[0]!==a?({className:t,...n}=a,e[0]=a,e[1]=t,e[2]=n):(t=e[1],n=e[2]);let r;e[3]!==t?(r=N("flex items-center gap-2 rounded-t-md bg-muted/50 px-3 py-1.5",t),e[3]=t,e[4]=r):r=e[4];let l;return e[5]!==n||e[6]!==r?(l=(0,s.jsx)("div",{"data-slot":"base-node-header",className:r,...n}),e[5]=n,e[6]=r,e[7]=l):l=e[7],l}u(ce,"ce");function me(a){let e=(0,v.c)(8),t,n;e[0]!==a?({className:t,...n}=a,e[0]=a,e[1]=t,e[2]=n):(t=e[1],n=e[2]);let r;e[3]!==t?(r=N("flex flex-col",t),e[3]=t,e[4]=r):r=e[4];let l;return e[5]!==n||e[6]!==r?(l=(0,s.jsx)("div",{"data-slot":"base-node-content",className:r,...n}),e[5]=n,e[6]=r,e[7]=l):l=e[7],l}u(me,"de");var ue=3,fe=u((a,e,t)=>{let n=e?a:a.slice(0,ue),r=n.map(o=>JSON.stringify(o)).join(" | "),l=a.length-n.length;return l>0?`${r} ${t("+{count} more",{count:l})}`:r},"fe"),J=u((a,e,t)=>{let n=a.enumValues??[],r=n.length===0?a.type:fe(n,e,t),l=a.ref===void 0?r:`${r} \u2192 ${a.ref}`;return a.optional===!0?`${l}?`:l},"H"),pe=u(a=>{let e=(0,v.c)(23),{data:t,selected:n}=a,r=$(),l;e[0]!==t.label||e[1]!==t.loadError||e[2]!==r?(l=t.loadError===!0?(0,s.jsx)("span",{className:"px-3 py-1.5 text-xs text-destructive","data-testid":`sd-node-${t.label}-error`,children:r("Columns unavailable")}):(0,s.jsx)("span",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:"\u2014"}),e[0]=t.label,e[1]=t.loadError,e[2]=r,e[3]=l):l=e[3];let o=l,d=`sd-node-${t.label}`,c;e[4]!==t.label?(c=(0,s.jsx)("span",{className:"truncate font-mono text-xs font-semibold",title:t.label,children:t.label}),e[4]=t.label,e[5]=c):c=e[5];let m;e[6]!==t.tier?(m=(0,s.jsx)("span",{className:"ms-auto",children:(0,s.jsx)(D,{tier:t.tier})}),e[6]=t.tier,e[7]=m):m=e[7];let i;e[8]!==c||e[9]!==m?(i=(0,s.jsxs)(ce,{children:[c,m]}),e[8]=c,e[9]=m,e[10]=i):i=e[10];let f;e[11]!==t.columns||e[12]!==t.label||e[13]!==o||e[14]!==r?(f=t.columns.length===0?o:t.columns.map(h=>(0,s.jsxs)("div",{className:N("relative flex items-center gap-2 border-t border-border px-3 py-1.5 text-xs first:border-t-0",h.pk===!0&&"bg-muted/30"),"data-testid":`sd-col-${t.label}-${h.name}`,children:[(0,s.jsx)(E,{className:"!h-2 !w-2 !-left-1 !border-border !bg-muted-foreground/70",id:h.name,isConnectable:!1,position:_.Left,type:"target"}),(0,s.jsx)("span",{className:"truncate font-mono",title:h.name,children:h.name}),h.pk===!0&&(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"secondary",children:"PK"}),h.ref!==void 0&&(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"outline",children:"FK"}),(0,s.jsx)("span",{className:"ms-auto truncate text-muted-foreground",title:J(h,!0,r),children:J(h,!1,r)}),(0,s.jsx)(E,{className:"!h-2 !w-2 !-right-1 !border-border !bg-muted-foreground/70",id:h.name,isConnectable:!1,position:_.Right,type:"source"})]},h.name)),e[11]=t.columns,e[12]=t.label,e[13]=o,e[14]=r,e[15]=f):f=e[15];let p;e[16]!==f?(p=(0,s.jsx)(me,{children:f}),e[16]=f,e[17]=p):p=e[17];let x;return e[18]!==n||e[19]!==d||e[20]!==i||e[21]!==p?(x=(0,s.jsxs)(ie,{className:"w-64 overflow-hidden","data-testid":d,selected:n,children:[i,p]}),e[18]=n,e[19]=d,e[20]=i,e[21]=p,e[22]=x):x=e[22],x},"ue"),G=256,Q=112,W=36,M=24,he=480,be=1.4,ge=u(a=>{let e=Math.max(1,Math.round(Math.sqrt(be*a/(G+Q))));return Math.max(he,a/e)},"ge"),xe=38,Ne=28,A=u(a=>xe+Math.max(1,a)*Ne,"B"),ye=u((a,e)=>{let t=new Map;for(let o of a)t.set(o,[]);for(let o of e)o.to!==o.from&&t.has(o.from)&&t.has(o.to)&&t.get(o.from)?.push(o.to);let n=new Map,r=new Set,l=u(o=>{let d=n.get(o);if(d!==void 0)return d;if(r.has(o))return 0;r.add(o);let c=0;for(let m of t.get(o)??[])c=Math.max(c,l(m)+1);return r.delete(o),n.set(o,c),c},"r");for(let o of a)l(o);return n},"Ne"),ve=u((a,e,t)=>{let n=ye(a,e),r=new Map;for(let m of a){let i=n.get(m)??0,f=r.get(i);f===void 0?r.set(i,[m]):f.push(m)}let l=a.reduce((m,i)=>m+A(t.get(i)??0)+W,0),o=ge(l),d=[],c=0;for(let m of[...r.keys()].toSorted((i,f)=>i-f)){let i=0,f=M;for(let p of r.get(m)??[]){let x=A(t.get(p)??0);f>M&&f+x>o&&(i+=1,f=M),d.push({name:p,x:M+(c+i)*(G+Q),y:f}),f+=x+W}c+=i+1}return d},"ye"),we={databaseSchema:pe},U={backgroundColor:y.shard.color},X={backgroundColor:y.global.color},$e={global:!0,shard:!0},Me={},Ce=u(a=>{let e=a.find(t=>t.pk===!0)?.name;return e!==void 0?e:a.some(t=>t.name==="_id")?"_id":a.some(t=>t.name==="id")?"id":a[0]?.name??"_id"},"_e"),Y=u(a=>a.flatMap(e=>e.columns.filter(t=>t.ref!==void 0).map(t=>({column:t.name,from:e.name,to:t.ref}))),"K"),Se=u((a,e,t)=>{let n=a.map(d=>d.name),r=new Map(a.map(d=>[d.name,d.columns.length])),l=ve(n,Y(a),r),o=new Map(a.map(d=>[d.name,d]));return l.flatMap(({name:d,x:c,y:m})=>{let i=o.get(d);return i===void 0?[]:[{className:t[d],data:{columns:i.columns,label:d,loadError:e,tier:i.tier},id:d,position:{x:c,y:m},type:"databaseSchema"}]})},"we"),ke=u(a=>{let e=new Map(a.map(t=>[t.name,t.columns]));return Y(a).flatMap(t=>{let n=e.get(t.to)??[],r=e.get(t.from)??[],l=Ce(n);return!n.some(o=>o.name===l)||!r.some(o=>o.name===t.column)?[]:[{id:`${t.from}.${t.column}->${t.to}`,source:t.to,sourceHandle:l,target:t.from,targetHandle:t.column}]})},"Me"),_e=u(()=>{let a=(0,v.c)(15),e=$(),t;a[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:U}),y.shard.label]}),a[0]=t):t=a[0];let n;a[1]===Symbol.for("react.memo_cache_sentinel")?(n=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:X}),y.global.label]}),a[1]=n):n=a[1];let r;a[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"secondary",children:"PK"}),a[2]=r):r=a[2];let l;a[3]!==e?(l=e("Primary key"),a[3]=e,a[4]=l):l=a[4];let o;a[5]!==l?(o=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[r,l]}),a[5]=l,a[6]=o):o=a[6];let d;a[7]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"outline",children:"FK"}),a[7]=d):d=a[7];let c;a[8]!==e?(c=e("Foreign key"),a[8]=e,a[9]=c):c=a[9];let m;a[10]!==c?(m=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[d,c]}),a[10]=c,a[11]=m):m=a[11];let i;return a[12]!==o||a[13]!==m?(i=(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 rounded-xl border border-border bg-card/95 px-2.5 py-1.5 text-[11px] text-muted-foreground shadow-xs",children:[t,n,o,m]}),a[12]=o,a[13]=m,a[14]=i):i=a[14],i},"Ce"),ze=12,Ee=u(a=>{let e=(0,v.c)(9),{containerRef:t,seedKey:n}=a,r=V(),{fitView:l}=j(),o;e[0]!==t||e[1]!==l||e[2]!==r?(o=u(()=>{if(!r)return;let c=u(()=>{P(l({duration:0,maxZoom:1.6,padding:.14}))},"d");c();let m=t.current;if(m===null)return;let i=new ResizeObserver(()=>{c()});return i.observe(m),()=>{i.disconnect()}},"a"),e[0]=t,e[1]=l,e[2]=r,e[3]=o):o=e[3];let d;return e[4]!==t||e[5]!==l||e[6]!==r||e[7]!==n?(d=[t,l,r,n],e[4]=t,e[5]=l,e[6]=r,e[7]=n,e[8]=d):d=e[8],(0,b.useEffect)(o,d),null},"Te"),Ve=u(({columnsError:a,fill:e=!1,nodeClasses:t,tables:n,testIdPrefix:r})=>{let l=$(),[o,d]=(0,b.useState)($e),[c,m]=(0,b.useState)(""),i=(0,b.useMemo)(()=>{let g=c.trim().toLowerCase();return n.filter(K=>o[K.tier]&&K.name.toLowerCase().includes(g))},[n,o,c]),f=(0,b.useMemo)(()=>Se(i,a??!1,t??Me),[i,a,t]),p=(0,b.useMemo)(()=>ke(i),[i]),x=i.map(g=>g.name).join(","),[h,R,ee]=H(f),[te,F,ae]=L(p),C=(0,b.useRef)(null);(0,b.useEffect)(()=>{R(f)},[f,R]),(0,b.useEffect)(()=>{F(p)},[p,F]);let re=u(g=>{m(g.target.value)},"V"),oe=u(()=>{d(g=>({...g,shard:!g.shard}))},"W"),ne=u(()=>{d(g=>({...g,global:!g.global}))},"Y");return n.length===0?(0,s.jsx)("section",{className:"flex flex-col gap-2","data-testid":`${r}-section`,children:(0,s.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":`${r}-empty`,children:l("No tables to graph.")})}):(0,s.jsx)("section",{className:N("flex flex-col",e&&"min-h-0 flex-1"),"data-testid":`${r}-section`,children:(0,s.jsx)("div",{className:N("w-full overflow-hidden border border-border bg-muted/20",e?"min-h-0 flex-1":"h-[560px]"),"data-testid":`${r}-canvas`,ref:C,children:(0,s.jsxs)(B,{edges:te,elementsSelectable:!0,fitView:!0,minZoom:.2,nodes:h,nodesConnectable:!1,nodeTypes:we,onEdgesChange:ae,onNodesChange:ee,children:[(0,s.jsx)(O,{}),(0,s.jsx)(z,{position:"top-left",children:(0,s.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card/95 p-2 shadow-xs",children:[(0,s.jsx)(I,{"aria-label":l("Find table\u2026"),className:"h-7 w-44 text-xs","data-testid":`${r}-find`,onChange:re,placeholder:l("Find table\u2026"),value:c}),(0,s.jsxs)("div",{"aria-label":l("Storage tiers"),className:"flex items-center gap-1.5",role:"group",children:[(0,s.jsxs)(k,{"aria-pressed":o.shard,className:"gap-1.5","data-testid":`${r}-tier-shard`,onClick:oe,size:"xs",type:"button",variant:o.shard?"default":"outline",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:U}),y.shard.label]}),(0,s.jsxs)(k,{"aria-pressed":o.global,className:"gap-1.5","data-testid":`${r}-tier-global`,onClick:ne,size:"xs",type:"button",variant:o.global?"default":"outline",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:X}),y.global.label]})]})]})}),(0,s.jsx)(z,{position:"bottom-center",children:(0,s.jsx)(_e,{})}),(0,s.jsx)(T,{showInteractive:!1}),i.length>ze&&(0,s.jsx)(Z,{className:"!border !border-border !bg-card",maskColor:"var(--color-muted)",nodeColor:"var(--color-muted-foreground)",nodeStrokeWidth:0,pannable:!0,zoomable:!0}),(0,s.jsx)(q,{containerRef:C,filenameBase:`${r}-schema-diagram`,testIdPrefix:r}),(0,s.jsx)(Ee,{containerRef:C,seedKey:x})]})})})},"Ke");export{Ve as a};
|
|
1
|
+
import{a as y,b as D}from"./chunk-JNWK5MJC.js";import{a as _,b as z,c as j,d as E,e as B,f as H,g as L,h as V,i as O,j as T,k as Z,l as q}from"./chunk-CUUNHCMD.js";import{i as I}from"./chunk-IGIBOJJG.js";import{a as k}from"./chunk-LMGNMZUF.js";import{b as w}from"./chunk-YCQ7ZPBP.js";import{B as $,s as P,x as N}from"./chunk-JEKJEGBJ.js";import{a as se}from"./chunk-A6TVTNKO.js";import{a as le,b as de}from"./chunk-ADABTCDI.js";import{a as u,d as S}from"./chunk-5PEAXTYQ.js";var v=S(se(),1);var b=S(le(),1);var s=S(de(),1);function ie(a){let e=(0,v.c)(10),t,n,r;e[0]!==a?({className:t,selected:r,...n}=a,e[0]=a,e[1]=t,e[2]=n,e[3]=r):(t=e[1],n=e[2],r=e[3]);let l=r===!0?"":void 0,o;e[4]!==t?(o=N("rounded-md border border-border bg-card text-card-foreground shadow-sm transition-colors","data-[selected]:border-ring data-[selected]:ring-[3px] data-[selected]:ring-ring/30",t),e[4]=t,e[5]=o):o=e[5];let d;return e[6]!==n||e[7]!==l||e[8]!==o?(d=(0,s.jsx)("div",{"data-slot":"base-node","data-selected":l,className:o,...n}),e[6]=n,e[7]=l,e[8]=o,e[9]=d):d=e[9],d}u(ie,"ie");function ce(a){let e=(0,v.c)(8),t,n;e[0]!==a?({className:t,...n}=a,e[0]=a,e[1]=t,e[2]=n):(t=e[1],n=e[2]);let r;e[3]!==t?(r=N("flex items-center gap-2 rounded-t-md bg-muted/50 px-3 py-1.5",t),e[3]=t,e[4]=r):r=e[4];let l;return e[5]!==n||e[6]!==r?(l=(0,s.jsx)("div",{"data-slot":"base-node-header",className:r,...n}),e[5]=n,e[6]=r,e[7]=l):l=e[7],l}u(ce,"ce");function me(a){let e=(0,v.c)(8),t,n;e[0]!==a?({className:t,...n}=a,e[0]=a,e[1]=t,e[2]=n):(t=e[1],n=e[2]);let r;e[3]!==t?(r=N("flex flex-col",t),e[3]=t,e[4]=r):r=e[4];let l;return e[5]!==n||e[6]!==r?(l=(0,s.jsx)("div",{"data-slot":"base-node-content",className:r,...n}),e[5]=n,e[6]=r,e[7]=l):l=e[7],l}u(me,"de");var ue=3,fe=u((a,e,t)=>{let n=e?a:a.slice(0,ue),r=n.map(o=>JSON.stringify(o)).join(" | "),l=a.length-n.length;return l>0?`${r} ${t("+{count} more",{count:l})}`:r},"fe"),J=u((a,e,t)=>{let n=a.enumValues??[],r=n.length===0?a.type:fe(n,e,t),l=a.ref===void 0?r:`${r} \u2192 ${a.ref}`;return a.optional===!0?`${l}?`:l},"H"),pe=u(a=>{let e=(0,v.c)(23),{data:t,selected:n}=a,r=$(),l;e[0]!==t.label||e[1]!==t.loadError||e[2]!==r?(l=t.loadError===!0?(0,s.jsx)("span",{className:"px-3 py-1.5 text-xs text-destructive","data-testid":`sd-node-${t.label}-error`,children:r("Columns unavailable")}):(0,s.jsx)("span",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:"\u2014"}),e[0]=t.label,e[1]=t.loadError,e[2]=r,e[3]=l):l=e[3];let o=l,d=`sd-node-${t.label}`,c;e[4]!==t.label?(c=(0,s.jsx)("span",{className:"truncate font-mono text-xs font-semibold",title:t.label,children:t.label}),e[4]=t.label,e[5]=c):c=e[5];let m;e[6]!==t.tier?(m=(0,s.jsx)("span",{className:"ms-auto",children:(0,s.jsx)(D,{tier:t.tier})}),e[6]=t.tier,e[7]=m):m=e[7];let i;e[8]!==c||e[9]!==m?(i=(0,s.jsxs)(ce,{children:[c,m]}),e[8]=c,e[9]=m,e[10]=i):i=e[10];let f;e[11]!==t.columns||e[12]!==t.label||e[13]!==o||e[14]!==r?(f=t.columns.length===0?o:t.columns.map(h=>(0,s.jsxs)("div",{className:N("relative flex items-center gap-2 border-t border-border px-3 py-1.5 text-xs first:border-t-0",h.pk===!0&&"bg-muted/30"),"data-testid":`sd-col-${t.label}-${h.name}`,children:[(0,s.jsx)(E,{className:"!h-2 !w-2 !-left-1 !border-border !bg-muted-foreground/70",id:h.name,isConnectable:!1,position:_.Left,type:"target"}),(0,s.jsx)("span",{className:"truncate font-mono",title:h.name,children:h.name}),h.pk===!0&&(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"secondary",children:"PK"}),h.ref!==void 0&&(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"outline",children:"FK"}),(0,s.jsx)("span",{className:"ms-auto truncate text-muted-foreground",title:J(h,!0,r),children:J(h,!1,r)}),(0,s.jsx)(E,{className:"!h-2 !w-2 !-right-1 !border-border !bg-muted-foreground/70",id:h.name,isConnectable:!1,position:_.Right,type:"source"})]},h.name)),e[11]=t.columns,e[12]=t.label,e[13]=o,e[14]=r,e[15]=f):f=e[15];let p;e[16]!==f?(p=(0,s.jsx)(me,{children:f}),e[16]=f,e[17]=p):p=e[17];let x;return e[18]!==n||e[19]!==d||e[20]!==i||e[21]!==p?(x=(0,s.jsxs)(ie,{className:"w-64 overflow-hidden","data-testid":d,selected:n,children:[i,p]}),e[18]=n,e[19]=d,e[20]=i,e[21]=p,e[22]=x):x=e[22],x},"ue"),G=256,Q=112,W=36,M=24,he=480,be=1.4,ge=u(a=>{let e=Math.max(1,Math.round(Math.sqrt(be*a/(G+Q))));return Math.max(he,a/e)},"ge"),xe=38,Ne=28,A=u(a=>xe+Math.max(1,a)*Ne,"B"),ye=u((a,e)=>{let t=new Map;for(let o of a)t.set(o,[]);for(let o of e)o.to!==o.from&&t.has(o.from)&&t.has(o.to)&&t.get(o.from)?.push(o.to);let n=new Map,r=new Set,l=u(o=>{let d=n.get(o);if(d!==void 0)return d;if(r.has(o))return 0;r.add(o);let c=0;for(let m of t.get(o)??[])c=Math.max(c,l(m)+1);return r.delete(o),n.set(o,c),c},"r");for(let o of a)l(o);return n},"Ne"),ve=u((a,e,t)=>{let n=ye(a,e),r=new Map;for(let m of a){let i=n.get(m)??0,f=r.get(i);f===void 0?r.set(i,[m]):f.push(m)}let l=a.reduce((m,i)=>m+A(t.get(i)??0)+W,0),o=ge(l),d=[],c=0;for(let m of[...r.keys()].toSorted((i,f)=>i-f)){let i=0,f=M;for(let p of r.get(m)??[]){let x=A(t.get(p)??0);f>M&&f+x>o&&(i+=1,f=M),d.push({name:p,x:M+(c+i)*(G+Q),y:f}),f+=x+W}c+=i+1}return d},"ye"),we={databaseSchema:pe},U={backgroundColor:y.shard.color},X={backgroundColor:y.global.color},$e={global:!0,shard:!0},Me={},Ce=u(a=>{let e=a.find(t=>t.pk===!0)?.name;return e!==void 0?e:a.some(t=>t.name==="_id")?"_id":a.some(t=>t.name==="id")?"id":a[0]?.name??"_id"},"_e"),Y=u(a=>a.flatMap(e=>e.columns.filter(t=>t.ref!==void 0).map(t=>({column:t.name,from:e.name,to:t.ref}))),"K"),Se=u((a,e,t)=>{let n=a.map(d=>d.name),r=new Map(a.map(d=>[d.name,d.columns.length])),l=ve(n,Y(a),r),o=new Map(a.map(d=>[d.name,d]));return l.flatMap(({name:d,x:c,y:m})=>{let i=o.get(d);return i===void 0?[]:[{className:t[d],data:{columns:i.columns,label:d,loadError:e,tier:i.tier},id:d,position:{x:c,y:m},type:"databaseSchema"}]})},"we"),ke=u(a=>{let e=new Map(a.map(t=>[t.name,t.columns]));return Y(a).flatMap(t=>{let n=e.get(t.to)??[],r=e.get(t.from)??[],l=Ce(n);return!n.some(o=>o.name===l)||!r.some(o=>o.name===t.column)?[]:[{id:`${t.from}.${t.column}->${t.to}`,source:t.to,sourceHandle:l,target:t.from,targetHandle:t.column}]})},"Me"),_e=u(()=>{let a=(0,v.c)(15),e=$(),t;a[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:U}),y.shard.label]}),a[0]=t):t=a[0];let n;a[1]===Symbol.for("react.memo_cache_sentinel")?(n=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:X}),y.global.label]}),a[1]=n):n=a[1];let r;a[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"secondary",children:"PK"}),a[2]=r):r=a[2];let l;a[3]!==e?(l=e("Primary key"),a[3]=e,a[4]=l):l=a[4];let o;a[5]!==l?(o=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[r,l]}),a[5]=l,a[6]=o):o=a[6];let d;a[7]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"outline",children:"FK"}),a[7]=d):d=a[7];let c;a[8]!==e?(c=e("Foreign key"),a[8]=e,a[9]=c):c=a[9];let m;a[10]!==c?(m=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[d,c]}),a[10]=c,a[11]=m):m=a[11];let i;return a[12]!==o||a[13]!==m?(i=(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 rounded-xl border border-border bg-card/95 px-2.5 py-1.5 text-[11px] text-muted-foreground shadow-xs",children:[t,n,o,m]}),a[12]=o,a[13]=m,a[14]=i):i=a[14],i},"Ce"),ze=12,Ee=u(a=>{let e=(0,v.c)(9),{containerRef:t,seedKey:n}=a,r=V(),{fitView:l}=j(),o;e[0]!==t||e[1]!==l||e[2]!==r?(o=u(()=>{if(!r)return;let c=u(()=>{P(l({duration:0,maxZoom:1.6,padding:.14}))},"d");c();let m=t.current;if(m===null)return;let i=new ResizeObserver(()=>{c()});return i.observe(m),()=>{i.disconnect()}},"a"),e[0]=t,e[1]=l,e[2]=r,e[3]=o):o=e[3];let d;return e[4]!==t||e[5]!==l||e[6]!==r||e[7]!==n?(d=[t,l,r,n],e[4]=t,e[5]=l,e[6]=r,e[7]=n,e[8]=d):d=e[8],(0,b.useEffect)(o,d),null},"Te"),Ve=u(({columnsError:a,fill:e=!1,nodeClasses:t,tables:n,testIdPrefix:r})=>{let l=$(),[o,d]=(0,b.useState)($e),[c,m]=(0,b.useState)(""),i=(0,b.useMemo)(()=>{let g=c.trim().toLowerCase();return n.filter(K=>o[K.tier]&&K.name.toLowerCase().includes(g))},[n,o,c]),f=(0,b.useMemo)(()=>Se(i,a??!1,t??Me),[i,a,t]),p=(0,b.useMemo)(()=>ke(i),[i]),x=i.map(g=>g.name).join(","),[h,R,ee]=H(f),[te,F,ae]=L(p),C=(0,b.useRef)(null);(0,b.useEffect)(()=>{R(f)},[f,R]),(0,b.useEffect)(()=>{F(p)},[p,F]);let re=u(g=>{m(g.target.value)},"V"),oe=u(()=>{d(g=>({...g,shard:!g.shard}))},"W"),ne=u(()=>{d(g=>({...g,global:!g.global}))},"Y");return n.length===0?(0,s.jsx)("section",{className:"flex flex-col gap-2","data-testid":`${r}-section`,children:(0,s.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":`${r}-empty`,children:l("No tables to graph.")})}):(0,s.jsx)("section",{className:N("flex flex-col",e&&"min-h-0 flex-1"),"data-testid":`${r}-section`,children:(0,s.jsx)("div",{className:N("w-full overflow-hidden border border-border bg-muted/20",e?"min-h-0 flex-1":"h-[560px]"),"data-testid":`${r}-canvas`,ref:C,children:(0,s.jsxs)(B,{edges:te,elementsSelectable:!0,fitView:!0,minZoom:.2,nodes:h,nodesConnectable:!1,nodeTypes:we,onEdgesChange:ae,onNodesChange:ee,children:[(0,s.jsx)(O,{}),(0,s.jsx)(z,{position:"top-left",children:(0,s.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card/95 p-2 shadow-xs",children:[(0,s.jsx)(I,{"aria-label":l("Find table\u2026"),className:"h-7 w-44 text-xs","data-testid":`${r}-find`,onChange:re,placeholder:l("Find table\u2026"),value:c}),(0,s.jsxs)("div",{"aria-label":l("Storage tiers"),className:"flex items-center gap-1.5",role:"group",children:[(0,s.jsxs)(k,{"aria-pressed":o.shard,className:"gap-1.5","data-testid":`${r}-tier-shard`,onClick:oe,size:"xs",type:"button",variant:o.shard?"default":"outline",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:U}),y.shard.label]}),(0,s.jsxs)(k,{"aria-pressed":o.global,className:"gap-1.5","data-testid":`${r}-tier-global`,onClick:ne,size:"xs",type:"button",variant:o.global?"default":"outline",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:X}),y.global.label]})]})]})}),(0,s.jsx)(z,{position:"bottom-center",children:(0,s.jsx)(_e,{})}),(0,s.jsx)(T,{showInteractive:!1}),i.length>ze&&(0,s.jsx)(Z,{className:"!border !border-border !bg-card",maskColor:"var(--color-muted)",nodeColor:"var(--color-muted-foreground)",nodeStrokeWidth:0,pannable:!0,zoomable:!0}),(0,s.jsx)(q,{containerRef:C,filenameBase:`${r}-schema-diagram`,testIdPrefix:r}),(0,s.jsx)(Ee,{containerRef:C,seedKey:x})]})})})},"Ke");export{Ve as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as Ke}from"./chunk-R6NJ4ER6.js";import{a as Ie,b as De,c as Oe}from"./chunk-AFLNQEZ5.js";import{a as Ee}from"./chunk-V4D77Q45.js";import"./chunk-4KPATTV6.js";import{i as we}from"./chunk-A5INOAIL.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as ke}from"./chunk-SZCXVIVT.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{b as _e}from"./chunk-TRJMN2YI.js";import"./chunk-L27FKJTG.js";import{a as je}from"./chunk-UA7DC3LX.js";import"./chunk-KFDOGDD2.js";import{a as Se,b as Te,c as Ce,d as ie,e as M,f as W}from"./chunk-3OVNOP65.js";import"./chunk-UVMD7C4J.js";import"./chunk-FXSY2FCG.js";import"./chunk-EOFWXI3T.js";import{a as ve}from"./chunk-LYVYUTQY.js";import{c as ye}from"./chunk-AKC4XWCD.js";import{a as le,e as oe}from"./chunk-CB22PV3X.js";import{n as Ae}from"./chunk-SAV5V3DG.js";import"./chunk-ZPQBVYNN.js";import{B as xe,j as pe,s as he,w as fe}from"./chunk-4S7ZIMWI.js";import"./chunk-PDBW6GTJ.js";import{a as ze}from"./chunk-A6TVTNKO.js";import{a as Ue,b as Pe}from"./chunk-ADABTCDI.js";import{a as b,d as Ne}from"./chunk-5PEAXTYQ.js";var ce=Ne(ze(),1);var I=Ne(Ue(),1);var a=Ne(Pe(),1);var Le=["disabled","schema","schema_and_log","schema_and_log_and_data"],$e={describeTables:"schema",readAdvisors:"schema",readLogs:"schema_and_log",readPolicies:"schema",runSql:"schema_and_log_and_data"},Be=864e5,qe=b(()=>{let t=(0,ce.c)(67),e=Ae(),r=xe(),n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],t[0]=n):n=t[0];let g;t[1]!==e?(g={owner:e,tokens:n},t[1]=e,t[2]=g):g=t[2];let[h,N]=(0,I.useState)(g),x=h.owner===e?h.tokens:[],[c,m]=(0,I.useState)(null),[p,o]=(0,I.useState)(null);p!==null&&p.owner!==e&&o(null);let d=p?.owner===e?p.token:null,[l,i]=(0,I.useState)(""),[s,u]=(0,I.useState)(""),[_,k]=(0,I.useState)(null),D=_===e,v=(0,I.useRef)(0),w=(0,I.useRef)(e),O,j;t[3]!==e?(O=b(()=>{w.current=e},"D"),j=[e],t[3]=e,t[4]=O,t[5]=j):(O=t[4],j=t[5]),(0,I.useEffect)(O,j);let K;t[6]!==e?(K=b(async()=>{if(w.current!==e)return;v.current=v.current+1;let f=v.current;try{let E=await e.listAdminTokens();f===v.current&&(N({owner:e,tokens:E}),m(null))}catch(E){let de=E;f===v.current&&m(pe(de))}},"L"),t[6]=e,t[7]=K):K=t[7];let y=K,L,R;t[8]!==y?(L=b(()=>{he(y())},"O"),R=[y],t[8]=y,t[9]=L,t[10]=R):(L=t[9],R=t[10]),(0,I.useEffect)(L,R);let U;t[11]!==e||t[12]!==d||t[13]!==D||t[14]!==s||t[15]!==l||t[16]!==y?(U=b(f=>{if(f.preventDefault(),D||d!==null)return;k(e);let E=e,de=s===""?void 0:Date.now()+Number(s)*Be;he((async()=>{try{let se=await E.createAdminToken({expiresAt:de,name:l.trim()});w.current===E&&(o({owner:E,token:se}),i(""),u(""),await y())}catch(se){m(pe(se))}k(se=>se===E?null:se)})())},"K"),t[11]=e,t[12]=d,t[13]=D,t[14]=s,t[15]=l,t[16]=y,t[17]=U):U=t[17];let B=U,H=b(f=>{he((async()=>{try{await e.revokeAdminToken(f),o(E=>E?.token.name===f?null:E),await y()}catch(E){let de=E;await y(),w.current===e&&m(pe(de))}})())},"q"),q=le,G="py-0",J="set-admin-tokens",S;t[18]!==r?(S=r("Admin tokens"),t[18]=r,t[19]=S):S=t[19];let T;t[20]!==S?(T=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:S})}),t[20]=S,t[21]=T):T=t[21];let F=oe,Q="flex flex-col gap-3 py-3",C;t[22]!==r?(C=r("Named tokens use the admin API but cannot manage tokens or open admin WebSockets. A revoked token is refused within 30 seconds."),t[22]=r,t[23]=C):C=t[23];let z;t[24]!==C?(z=(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:C}),t[24]=C,t[25]=z):z=t[25];let V;t[26]!==c?(V=c!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"set-admin-tokens-error",role:"alert",children:c}),t[26]=c,t[27]=V):V=t[27];let P;t[28]!==d||t[29]!==r?(P=d!==null&&(0,a.jsxs)("div",{className:"rounded-md border border-border p-3 text-xs","data-testid":"set-admin-token-created",role:"status",children:[(0,a.jsx)("p",{className:"pb-1 text-muted-foreground",children:r("Copy this token now. It is not shown again.")}),(0,a.jsx)("code",{className:"font-mono break-all select-all",children:d.token}),(0,a.jsx)("div",{className:"pt-2",children:(0,a.jsx)(ke,{"data-testid":"set-admin-token-dismiss",onClick:b(()=>{o(null)},"onClick"),size:"xs",variant:"outline",children:r("Dismiss")})})]}),t[28]=d,t[29]=r,t[30]=P):P=t[30];let A;t[31]!==r?(A=r("Token name"),t[31]=r,t[32]=A):A=t[32];let $;t[33]===Symbol.for("react.memo_cache_sentinel")?($=b(f=>{i(f.target.value)},"B"),t[33]=$):$=t[33];let X;t[34]!==l||t[35]!==A?(X=(0,a.jsx)(we,{"aria-label":A,className:"w-48","data-testid":"set-admin-token-name",onChange:$,pattern:"[a-z0-9][a-z0-9_\\-]{0,63}",placeholder:"ci-deploy",required:!0,value:l}),t[34]=l,t[35]=A,t[36]=X):X=t[36];let Y;t[37]!==r?(Y=r("Expires in days (optional)"),t[37]=r,t[38]=Y):Y=t[38];let me;t[39]===Symbol.for("react.memo_cache_sentinel")?(me=b(f=>{u(f.target.value)},"de"),t[39]=me):me=t[39];let Z;t[40]!==r?(Z=r("Expires in days (optional)"),t[40]=r,t[41]=Z):Z=t[41];let ee;t[42]!==s||t[43]!==Y||t[44]!==Z?(ee=(0,a.jsx)(we,{"aria-label":Y,className:"w-40",min:1,onChange:me,placeholder:Z,type:"number",value:s}),t[42]=s,t[43]=Y,t[44]=Z,t[45]=ee):ee=t[45];let be=D||d!==null,te;t[46]!==r?(te=r("Create token"),t[46]=r,t[47]=te):te=t[47];let ae;t[48]!==be||t[49]!==te?(ae=(0,a.jsx)(ke,{"data-testid":"set-admin-token-create",disabled:be,size:"sm",type:"submit",children:te}),t[48]=be,t[49]=te,t[50]=ae):ae=t[50];let ne;t[51]!==B||t[52]!==X||t[53]!==ee||t[54]!==ae?(ne=(0,a.jsxs)("form",{className:"flex flex-wrap items-end gap-2",onSubmit:B,children:[X,ee,ae]}),t[51]=B,t[52]=X,t[53]=ee,t[54]=ae,t[55]=ne):ne=t[55];let ge=x.length>0&&(0,a.jsxs)(Se,{"data-testid":"set-admin-tokens-table",children:[(0,a.jsx)(Te,{children:(0,a.jsxs)(ie,{children:[(0,a.jsx)(M,{children:r("name")}),(0,a.jsx)(M,{children:r("Created")}),(0,a.jsx)(M,{children:r("Last used")}),(0,a.jsx)(M,{children:r("Expires")}),(0,a.jsx)(M,{})]})}),(0,a.jsx)(Ce,{children:x.map(f=>(0,a.jsxs)(ie,{"data-testid":"set-admin-token-row",children:[(0,a.jsxs)(W,{className:"font-mono text-xs",children:[f.name,f.revoked===!0&&(0,a.jsx)("span",{className:"pl-2 text-destructive",children:r("Revoked")})]}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.createdAt)}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.lastUsedAt,"\u2014")}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.expiresAt,r("Never"))}),(0,a.jsx)(W,{children:(0,a.jsx)(Ee,{onConfirm:b(()=>{H(f.name)},"onConfirm"),testId:`set-admin-token-revoke-${f.name}`,children:r("Revoke")})})]},f.name))})]}),re;t[56]!==F||t[57]!==z||t[58]!==V||t[59]!==P||t[60]!==ne||t[61]!==ge?(re=(0,a.jsxs)(F,{className:Q,children:[z,V,P,ne,ge]}),t[56]=F,t[57]=z,t[58]=V,t[59]=P,t[60]=ne,t[61]=ge,t[62]=re):re=t[62];let ue;return t[63]!==q||t[64]!==T||t[65]!==re?(ue=(0,a.jsxs)(q,{className:G,"data-testid":J,children:[T,re]}),t[63]=q,t[64]=T,t[65]=re,t[66]=ue):ue=t[66],ue},"Fe"),Fe={binding:"outline",secret:"destructive",var:"secondary"},Ve=b((t,e)=>{if(t===void 0)return[];let r=[];return t.workerUrl!==void 0&&r.push({label:e("URL"),value:t.workerUrl}),t.environment!==void 0&&r.push({label:e("Environment"),value:t.environment}),t.deploymentId!==void 0&&r.push({label:e("Deployment"),value:t.deploymentId}),t.versionTag!==void 0&&r.push({label:e("Version"),value:t.versionTag}),r},"Pe"),Me={disabled:"The assistant is off. Nothing about this deployment is sent to a model.",schema:"Table and column names.",schema_and_log:"Table and column names, plus recent log lines.",schema_and_log_and_data:"Table and column names, log lines, and rows read with SELECT."},We=b(t=>{let e=[];for(let[r,n]of Object.entries($e))n===t&&e.push(r);return e},"qe"),He=b(()=>{let t=(0,ce.c)(29),e=xe(),r,n;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={},n={shardKey:""},t[0]=r,t[1]=n):(r=t[0],n=t[1]);let{data:g}=ye(ve.aiAvailable,r,n),h=g?.level,N;t[2]!==h?(N=h===void 0?-1:Le.indexOf(h),t[2]=h,t[3]=N):N=t[3];let x=N,c;t[4]!==e?(c=e("AI assistant data sharing"),t[4]=e,t[5]=c):c=t[5];let m;t[6]!==c?(m=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:c}),t[6]=c,t[7]=m):m=t[7];let p;t[8]!==h?(p=h!==void 0&&(0,a.jsx)(_e,{"data-testid":"set-ai-level",variant:h==="disabled"?"outline":"secondary",children:h}),t[8]=h,t[9]=p):p=t[9];let o;t[10]!==m||t[11]!==p?(o=(0,a.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[m,p]}),t[10]=m,t[11]=p,t[12]=o):o=t[12];let d;t[13]!==x||t[14]!==h||t[15]!==e?(d=Le.map((k,D)=>{let v=x>=D,w=We(k);return(0,a.jsxs)("li",{className:v?"flex flex-col gap-0.5":"flex flex-col gap-0.5 opacity-50","data-granted":String(v),"data-testid":`set-ai-tier-${k}`,children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"font-mono text-xs",children:k}),k===h&&(0,a.jsx)("span",{className:"text-[11px] text-primary",children:e("current")})]}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:e(Me[k])}),w.length>0&&(0,a.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:w.join(", ")})]},k)}),t[13]=x,t[14]=h,t[15]=e,t[16]=d):d=t[16];let l;t[17]!==d?(l=(0,a.jsx)("ul",{className:"flex flex-col gap-1.5 text-sm",children:d}),t[17]=d,t[18]=l):l=t[18];let i;t[19]!==e?(i=e("Set LUNORA_AI_OPT_IN in wrangler.jsonc and redeploy to change this. The Studio can read this level but never raise it."),t[19]=e,t[20]=i):i=t[20];let s;t[21]!==i?(s=(0,a.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"set-ai-howto",children:i}),t[21]=i,t[22]=s):s=t[22];let u;t[23]!==s||t[24]!==l?(u=(0,a.jsxs)(oe,{className:"flex flex-col gap-3 py-3",children:[l,s]}),t[23]=s,t[24]=l,t[25]=u):u=t[25];let _;return t[26]!==u||t[27]!==o?(_=(0,a.jsxs)(le,{className:"py-0","data-testid":"set-ai-sharing",children:[o,u]}),t[26]=u,t[27]=o,t[28]=_):_=t[28],_},"ze"),Re=b(t=>{let e=(0,ce.c)(18),{modifier:r,name:n,label:g}=t,h=Ie(),N;e[0]!==n?(N=b(u=>{if(!["Escape","Tab"].includes(u.key)){if(u.shiftKey){u.preventDefault();return}u.preventDefault(),De(n,u.key)}},"N"),e[0]=n,e[1]=N):N=e[1];let x=N,c=`set-shortcut-${n}`,m;e[2]!==g?(m=(0,a.jsx)("dt",{className:"text-muted-foreground",children:g}),e[2]=g,e[3]=m):m=e[3];let p;e[4]!==r?(p=(0,a.jsx)("kbd",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:r}),e[4]=r,e[5]=p):p=e[5];let o=`set-shortcut-input-${n}`,d=h[n],l;e[6]!==g||e[7]!==x||e[8]!==o||e[9]!==d?(l=(0,a.jsx)("input",{"aria-label":g,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":o,onKeyDown:x,readOnly:!0,value:d}),e[6]=g,e[7]=x,e[8]=o,e[9]=d,e[10]=l):l=e[10];let i;e[11]!==p||e[12]!==l?(i=(0,a.jsxs)("dd",{className:"flex items-center gap-1.5",children:[p,l]}),e[11]=p,e[12]=l,e[13]=i):i=e[13];let s;return e[14]!==c||e[15]!==m||e[16]!==i?(s=(0,a.jsxs)("div",{className:"contents","data-testid":c,children:[m,i]}),e[14]=c,e[15]=m,e[16]=i,e[17]=s):s=e[17],s},"we"),ct=b(t=>{let e=(0,ce.c)(87),{initialShardKey:r}=t,n=xe(),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={},e[0]=g):g=e[0];let h=r??"",N;e[1]!==h?(N={shardKey:h},e[1]=h,e[2]=N):N=e[2];let{data:x,error:c,errorSource:m,isLoading:p}=ye(ve.getSettings,g,N),o,d,l,i,s,u,_;if(e[3]!==c||e[4]!==m||e[5]!==x?.deploy||e[6]!==x?.settings||e[7]!==n){let V=Ve(x?.deploy,n),P;e[15]!==x?.settings?(P=x?.settings??[],e[15]=x?.settings,e[16]=P):P=e[16],o=P,d="flex flex-col gap-4",l="lunora-settings";let A;e[17]!==n?(A=n("Open in Cloudflare"),e[17]=n,e[18]=A):A=e[18],e[19]!==A?(i=(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,a.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:Ke,rel:"noreferrer",target:"_blank",children:A})}),e[19]=A,e[20]=i):i=e[20];let $;e[21]!==n?($=n("View-only \u2014 values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=n,e[22]=$):$=e[22],e[23]!==$?(s=(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:$}),e[23]=$,e[24]=s):s=e[24],e[25]!==c||e[26]!==m?(u=c!==null&&(0,a.jsx)(je,{error:m,testId:"set-error"}),e[25]=c,e[26]=m,e[27]=u):u=e[27],_=V.length>0&&(0,a.jsxs)(le,{className:"py-0","data-testid":"set-deploy",children:[(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Deployment")})}),(0,a.jsx)(oe,{className:"py-3",children:(0,a.jsx)("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:V.map(Ge)})})]}),e[3]=c,e[4]=m,e[5]=x?.deploy,e[6]=x?.settings,e[7]=n,e[8]=o,e[9]=d,e[10]=l,e[11]=i,e[12]=s,e[13]=u,e[14]=_}else o=e[8],d=e[9],l=e[10],i=e[11],s=e[12],u=e[13],_=e[14];let k,D;e[28]===Symbol.for("react.memo_cache_sentinel")?(k=(0,a.jsx)(He,{}),D=(0,a.jsx)(qe,{}),e[28]=k,e[29]=D):(k=e[28],D=e[29]);let v;e[30]!==n?(v=n("Keyboard shortcuts"),e[30]=n,e[31]=v):v=e[31];let w;e[32]!==v?(w=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v}),e[32]=v,e[33]=w):w=e[33];let O;e[34]!==n?(O=n("Reset"),e[34]=n,e[35]=O):O=e[35];let j;e[36]!==O?(j=(0,a.jsx)("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:Oe,type:"button",children:O}),e[36]=O,e[37]=j):j=e[37];let K;e[38]!==w||e[39]!==j?(K=(0,a.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[w,j]}),e[38]=w,e[39]=j,e[40]=K):K=e[40];let y;e[41]!==n?(y=n("Command palette"),e[41]=n,e[42]=y):y=e[42];let L;e[43]!==y?(L=(0,a.jsx)(Re,{label:y,modifier:"\u2318/Ctrl",name:"palette"}),e[43]=y,e[44]=L):L=e[44];let R;e[45]!==n?(R=n("Operation console"),e[45]=n,e[46]=R):R=e[46];let U;e[47]!==R?(U=(0,a.jsx)(Re,{label:R,modifier:"Ctrl",name:"console"}),e[47]=R,e[48]=U):U=e[48];let B;e[49]!==L||e[50]!==U?(B=(0,a.jsxs)("dl",{className:"grid grid-cols-[10rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 text-sm",children:[L,U]}),e[49]=L,e[50]=U,e[51]=B):B=e[51];let H;e[52]!==n?(H=n("Stored in this browser. Focus a box and press a key to rebind it."),e[52]=n,e[53]=H):H=e[53];let q;e[54]!==H?(q=(0,a.jsx)("p",{className:"pt-3 text-xs text-muted-foreground",children:H}),e[54]=H,e[55]=q):q=e[55];let G;e[56]!==B||e[57]!==q?(G=(0,a.jsxs)(oe,{className:"py-3",children:[B,q]}),e[56]=B,e[57]=q,e[58]=G):G=e[58];let J;e[59]!==K||e[60]!==G?(J=(0,a.jsxs)(le,{className:"py-0","data-testid":"set-preferences",children:[K,G]}),e[59]=K,e[60]=G,e[61]=J):J=e[61];let S;e[62]!==n?(S=n("Environment & bindings"),e[62]=n,e[63]=S):S=e[63];let T;e[64]!==S?(T=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:S})}),e[64]=S,e[65]=T):T=e[65];let F;e[66]!==c||e[67]!==p||e[68]!==o.length||e[69]!==n?(F=c===null&&!p&&o.length===0&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:n("No environment variables or bindings.")}),e[66]=c,e[67]=p,e[68]=o.length,e[69]=n,e[70]=F):F=e[70];let Q;e[71]!==o||e[72]!==n?(Q=o.length>0&&(0,a.jsx)(oe,{className:"px-0 py-0",children:(0,a.jsxs)(Se,{"data-testid":"set-table",children:[(0,a.jsx)(Te,{children:(0,a.jsxs)(ie,{children:[(0,a.jsx)(M,{children:n("name")}),(0,a.jsx)(M,{children:n("kind")}),(0,a.jsx)(M,{children:n("value")})]})}),(0,a.jsx)(Ce,{children:o.map(Je)})]})}),e[71]=o,e[72]=n,e[73]=Q):Q=e[73];let C;e[74]!==T||e[75]!==F||e[76]!==Q?(C=(0,a.jsxs)(le,{className:"py-0",children:[T,F,Q]}),e[74]=T,e[75]=F,e[76]=Q,e[77]=C):C=e[77];let z;return e[78]!==J||e[79]!==C||e[80]!==d||e[81]!==l||e[82]!==i||e[83]!==s||e[84]!==u||e[85]!==_?(z=(0,a.jsxs)("div",{className:d,"data-testid":l,children:[i,s,u,_,k,D,J,C]}),e[78]=J,e[79]=C,e[80]=d,e[81]=l,e[82]=i,e[83]=s,e[84]=u,e[85]=_,e[86]=z):z=e[86],z},"ft");function Ge(t){return(0,a.jsxs)("div",{className:"contents","data-testid":"set-deploy-row",children:[(0,a.jsx)("dt",{className:"text-muted-foreground",children:t.label}),(0,a.jsx)("dd",{className:"truncate font-mono text-xs",title:t.value,children:t.value})]},t.label)}b(Ge,"He");function Je(t){return(0,a.jsxs)(ie,{"data-testid":"set-row",children:[(0,a.jsx)(W,{className:"font-mono text-xs font-medium",children:t.name}),(0,a.jsx)(W,{children:(0,a.jsx)(_e,{variant:Fe[t.kind],children:t.bindingType??t.kind})}),(0,a.jsx)(W,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:t.value??(0,a.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},t.name)}b(Je,"We");export{ct as SettingsPanel};
|
|
1
|
+
import{b as Ke}from"./chunk-R6NJ4ER6.js";import{a as Ie,b as De,c as Oe}from"./chunk-AFLNQEZ5.js";import{a as Ee}from"./chunk-EH3PU4PH.js";import"./chunk-4KPATTV6.js";import{i as we}from"./chunk-IGIBOJJG.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as ke}from"./chunk-LMGNMZUF.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{b as _e}from"./chunk-YCQ7ZPBP.js";import"./chunk-L27FKJTG.js";import{a as je}from"./chunk-4UMUJTD2.js";import"./chunk-CYL7MEO2.js";import{a as Se,b as Te,c as Ce,d as ie,e as M,f as W}from"./chunk-YM56MNAN.js";import"./chunk-IXBHUFDE.js";import"./chunk-B2GQMLO3.js";import"./chunk-EOFWXI3T.js";import{a as ve}from"./chunk-LYVYUTQY.js";import{c as ye}from"./chunk-L62S7I64.js";import{a as le,e as oe}from"./chunk-JXGB4QDO.js";import{n as Ae}from"./chunk-OW7PWUF6.js";import"./chunk-ZPQBVYNN.js";import{B as xe,j as pe,s as he,w as fe}from"./chunk-JEKJEGBJ.js";import"./chunk-PDBW6GTJ.js";import{a as ze}from"./chunk-A6TVTNKO.js";import{a as Ue,b as Pe}from"./chunk-ADABTCDI.js";import{a as b,d as Ne}from"./chunk-5PEAXTYQ.js";var ce=Ne(ze(),1);var I=Ne(Ue(),1);var a=Ne(Pe(),1);var Le=["disabled","schema","schema_and_log","schema_and_log_and_data"],$e={describeTables:"schema",readAdvisors:"schema",readLogs:"schema_and_log",readPolicies:"schema",runSql:"schema_and_log_and_data"},Be=864e5,qe=b(()=>{let t=(0,ce.c)(67),e=Ae(),r=xe(),n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],t[0]=n):n=t[0];let g;t[1]!==e?(g={owner:e,tokens:n},t[1]=e,t[2]=g):g=t[2];let[h,N]=(0,I.useState)(g),x=h.owner===e?h.tokens:[],[c,m]=(0,I.useState)(null),[p,o]=(0,I.useState)(null);p!==null&&p.owner!==e&&o(null);let d=p?.owner===e?p.token:null,[l,i]=(0,I.useState)(""),[s,u]=(0,I.useState)(""),[_,k]=(0,I.useState)(null),D=_===e,v=(0,I.useRef)(0),w=(0,I.useRef)(e),O,j;t[3]!==e?(O=b(()=>{w.current=e},"D"),j=[e],t[3]=e,t[4]=O,t[5]=j):(O=t[4],j=t[5]),(0,I.useEffect)(O,j);let K;t[6]!==e?(K=b(async()=>{if(w.current!==e)return;v.current=v.current+1;let f=v.current;try{let E=await e.listAdminTokens();f===v.current&&(N({owner:e,tokens:E}),m(null))}catch(E){let de=E;f===v.current&&m(pe(de))}},"L"),t[6]=e,t[7]=K):K=t[7];let y=K,L,R;t[8]!==y?(L=b(()=>{he(y())},"O"),R=[y],t[8]=y,t[9]=L,t[10]=R):(L=t[9],R=t[10]),(0,I.useEffect)(L,R);let U;t[11]!==e||t[12]!==d||t[13]!==D||t[14]!==s||t[15]!==l||t[16]!==y?(U=b(f=>{if(f.preventDefault(),D||d!==null)return;k(e);let E=e,de=s===""?void 0:Date.now()+Number(s)*Be;he((async()=>{try{let se=await E.createAdminToken({expiresAt:de,name:l.trim()});w.current===E&&(o({owner:E,token:se}),i(""),u(""),await y())}catch(se){m(pe(se))}k(se=>se===E?null:se)})())},"K"),t[11]=e,t[12]=d,t[13]=D,t[14]=s,t[15]=l,t[16]=y,t[17]=U):U=t[17];let B=U,H=b(f=>{he((async()=>{try{await e.revokeAdminToken(f),o(E=>E?.token.name===f?null:E),await y()}catch(E){let de=E;await y(),w.current===e&&m(pe(de))}})())},"q"),q=le,G="py-0",J="set-admin-tokens",S;t[18]!==r?(S=r("Admin tokens"),t[18]=r,t[19]=S):S=t[19];let T;t[20]!==S?(T=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:S})}),t[20]=S,t[21]=T):T=t[21];let F=oe,Q="flex flex-col gap-3 py-3",C;t[22]!==r?(C=r("Named tokens use the admin API but cannot manage tokens or open admin WebSockets. A revoked token is refused within 30 seconds."),t[22]=r,t[23]=C):C=t[23];let z;t[24]!==C?(z=(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:C}),t[24]=C,t[25]=z):z=t[25];let V;t[26]!==c?(V=c!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"set-admin-tokens-error",role:"alert",children:c}),t[26]=c,t[27]=V):V=t[27];let P;t[28]!==d||t[29]!==r?(P=d!==null&&(0,a.jsxs)("div",{className:"rounded-md border border-border p-3 text-xs","data-testid":"set-admin-token-created",role:"status",children:[(0,a.jsx)("p",{className:"pb-1 text-muted-foreground",children:r("Copy this token now. It is not shown again.")}),(0,a.jsx)("code",{className:"font-mono break-all select-all",children:d.token}),(0,a.jsx)("div",{className:"pt-2",children:(0,a.jsx)(ke,{"data-testid":"set-admin-token-dismiss",onClick:b(()=>{o(null)},"onClick"),size:"xs",variant:"outline",children:r("Dismiss")})})]}),t[28]=d,t[29]=r,t[30]=P):P=t[30];let A;t[31]!==r?(A=r("Token name"),t[31]=r,t[32]=A):A=t[32];let $;t[33]===Symbol.for("react.memo_cache_sentinel")?($=b(f=>{i(f.target.value)},"B"),t[33]=$):$=t[33];let X;t[34]!==l||t[35]!==A?(X=(0,a.jsx)(we,{"aria-label":A,className:"w-48","data-testid":"set-admin-token-name",onChange:$,pattern:"[a-z0-9][a-z0-9_\\-]{0,63}",placeholder:"ci-deploy",required:!0,value:l}),t[34]=l,t[35]=A,t[36]=X):X=t[36];let Y;t[37]!==r?(Y=r("Expires in days (optional)"),t[37]=r,t[38]=Y):Y=t[38];let me;t[39]===Symbol.for("react.memo_cache_sentinel")?(me=b(f=>{u(f.target.value)},"de"),t[39]=me):me=t[39];let Z;t[40]!==r?(Z=r("Expires in days (optional)"),t[40]=r,t[41]=Z):Z=t[41];let ee;t[42]!==s||t[43]!==Y||t[44]!==Z?(ee=(0,a.jsx)(we,{"aria-label":Y,className:"w-40",min:1,onChange:me,placeholder:Z,type:"number",value:s}),t[42]=s,t[43]=Y,t[44]=Z,t[45]=ee):ee=t[45];let be=D||d!==null,te;t[46]!==r?(te=r("Create token"),t[46]=r,t[47]=te):te=t[47];let ae;t[48]!==be||t[49]!==te?(ae=(0,a.jsx)(ke,{"data-testid":"set-admin-token-create",disabled:be,size:"sm",type:"submit",children:te}),t[48]=be,t[49]=te,t[50]=ae):ae=t[50];let ne;t[51]!==B||t[52]!==X||t[53]!==ee||t[54]!==ae?(ne=(0,a.jsxs)("form",{className:"flex flex-wrap items-end gap-2",onSubmit:B,children:[X,ee,ae]}),t[51]=B,t[52]=X,t[53]=ee,t[54]=ae,t[55]=ne):ne=t[55];let ge=x.length>0&&(0,a.jsxs)(Se,{"data-testid":"set-admin-tokens-table",children:[(0,a.jsx)(Te,{children:(0,a.jsxs)(ie,{children:[(0,a.jsx)(M,{children:r("name")}),(0,a.jsx)(M,{children:r("Created")}),(0,a.jsx)(M,{children:r("Last used")}),(0,a.jsx)(M,{children:r("Expires")}),(0,a.jsx)(M,{})]})}),(0,a.jsx)(Ce,{children:x.map(f=>(0,a.jsxs)(ie,{"data-testid":"set-admin-token-row",children:[(0,a.jsxs)(W,{className:"font-mono text-xs",children:[f.name,f.revoked===!0&&(0,a.jsx)("span",{className:"pl-2 text-destructive",children:r("Revoked")})]}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.createdAt)}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.lastUsedAt,"\u2014")}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.expiresAt,r("Never"))}),(0,a.jsx)(W,{children:(0,a.jsx)(Ee,{onConfirm:b(()=>{H(f.name)},"onConfirm"),testId:`set-admin-token-revoke-${f.name}`,children:r("Revoke")})})]},f.name))})]}),re;t[56]!==F||t[57]!==z||t[58]!==V||t[59]!==P||t[60]!==ne||t[61]!==ge?(re=(0,a.jsxs)(F,{className:Q,children:[z,V,P,ne,ge]}),t[56]=F,t[57]=z,t[58]=V,t[59]=P,t[60]=ne,t[61]=ge,t[62]=re):re=t[62];let ue;return t[63]!==q||t[64]!==T||t[65]!==re?(ue=(0,a.jsxs)(q,{className:G,"data-testid":J,children:[T,re]}),t[63]=q,t[64]=T,t[65]=re,t[66]=ue):ue=t[66],ue},"Fe"),Fe={binding:"outline",secret:"destructive",var:"secondary"},Ve=b((t,e)=>{if(t===void 0)return[];let r=[];return t.workerUrl!==void 0&&r.push({label:e("URL"),value:t.workerUrl}),t.environment!==void 0&&r.push({label:e("Environment"),value:t.environment}),t.deploymentId!==void 0&&r.push({label:e("Deployment"),value:t.deploymentId}),t.versionTag!==void 0&&r.push({label:e("Version"),value:t.versionTag}),r},"Pe"),Me={disabled:"The assistant is off. Nothing about this deployment is sent to a model.",schema:"Table and column names.",schema_and_log:"Table and column names, plus recent log lines.",schema_and_log_and_data:"Table and column names, log lines, and rows read with SELECT."},We=b(t=>{let e=[];for(let[r,n]of Object.entries($e))n===t&&e.push(r);return e},"qe"),He=b(()=>{let t=(0,ce.c)(29),e=xe(),r,n;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={},n={shardKey:""},t[0]=r,t[1]=n):(r=t[0],n=t[1]);let{data:g}=ye(ve.aiAvailable,r,n),h=g?.level,N;t[2]!==h?(N=h===void 0?-1:Le.indexOf(h),t[2]=h,t[3]=N):N=t[3];let x=N,c;t[4]!==e?(c=e("AI assistant data sharing"),t[4]=e,t[5]=c):c=t[5];let m;t[6]!==c?(m=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:c}),t[6]=c,t[7]=m):m=t[7];let p;t[8]!==h?(p=h!==void 0&&(0,a.jsx)(_e,{"data-testid":"set-ai-level",variant:h==="disabled"?"outline":"secondary",children:h}),t[8]=h,t[9]=p):p=t[9];let o;t[10]!==m||t[11]!==p?(o=(0,a.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[m,p]}),t[10]=m,t[11]=p,t[12]=o):o=t[12];let d;t[13]!==x||t[14]!==h||t[15]!==e?(d=Le.map((k,D)=>{let v=x>=D,w=We(k);return(0,a.jsxs)("li",{className:v?"flex flex-col gap-0.5":"flex flex-col gap-0.5 opacity-50","data-granted":String(v),"data-testid":`set-ai-tier-${k}`,children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"font-mono text-xs",children:k}),k===h&&(0,a.jsx)("span",{className:"text-[11px] text-primary",children:e("current")})]}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:e(Me[k])}),w.length>0&&(0,a.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:w.join(", ")})]},k)}),t[13]=x,t[14]=h,t[15]=e,t[16]=d):d=t[16];let l;t[17]!==d?(l=(0,a.jsx)("ul",{className:"flex flex-col gap-1.5 text-sm",children:d}),t[17]=d,t[18]=l):l=t[18];let i;t[19]!==e?(i=e("Set LUNORA_AI_OPT_IN in wrangler.jsonc and redeploy to change this. The Studio can read this level but never raise it."),t[19]=e,t[20]=i):i=t[20];let s;t[21]!==i?(s=(0,a.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"set-ai-howto",children:i}),t[21]=i,t[22]=s):s=t[22];let u;t[23]!==s||t[24]!==l?(u=(0,a.jsxs)(oe,{className:"flex flex-col gap-3 py-3",children:[l,s]}),t[23]=s,t[24]=l,t[25]=u):u=t[25];let _;return t[26]!==u||t[27]!==o?(_=(0,a.jsxs)(le,{className:"py-0","data-testid":"set-ai-sharing",children:[o,u]}),t[26]=u,t[27]=o,t[28]=_):_=t[28],_},"ze"),Re=b(t=>{let e=(0,ce.c)(18),{modifier:r,name:n,label:g}=t,h=Ie(),N;e[0]!==n?(N=b(u=>{if(!["Escape","Tab"].includes(u.key)){if(u.shiftKey){u.preventDefault();return}u.preventDefault(),De(n,u.key)}},"N"),e[0]=n,e[1]=N):N=e[1];let x=N,c=`set-shortcut-${n}`,m;e[2]!==g?(m=(0,a.jsx)("dt",{className:"text-muted-foreground",children:g}),e[2]=g,e[3]=m):m=e[3];let p;e[4]!==r?(p=(0,a.jsx)("kbd",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:r}),e[4]=r,e[5]=p):p=e[5];let o=`set-shortcut-input-${n}`,d=h[n],l;e[6]!==g||e[7]!==x||e[8]!==o||e[9]!==d?(l=(0,a.jsx)("input",{"aria-label":g,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":o,onKeyDown:x,readOnly:!0,value:d}),e[6]=g,e[7]=x,e[8]=o,e[9]=d,e[10]=l):l=e[10];let i;e[11]!==p||e[12]!==l?(i=(0,a.jsxs)("dd",{className:"flex items-center gap-1.5",children:[p,l]}),e[11]=p,e[12]=l,e[13]=i):i=e[13];let s;return e[14]!==c||e[15]!==m||e[16]!==i?(s=(0,a.jsxs)("div",{className:"contents","data-testid":c,children:[m,i]}),e[14]=c,e[15]=m,e[16]=i,e[17]=s):s=e[17],s},"we"),ct=b(t=>{let e=(0,ce.c)(87),{initialShardKey:r}=t,n=xe(),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={},e[0]=g):g=e[0];let h=r??"",N;e[1]!==h?(N={shardKey:h},e[1]=h,e[2]=N):N=e[2];let{data:x,error:c,errorSource:m,isLoading:p}=ye(ve.getSettings,g,N),o,d,l,i,s,u,_;if(e[3]!==c||e[4]!==m||e[5]!==x?.deploy||e[6]!==x?.settings||e[7]!==n){let V=Ve(x?.deploy,n),P;e[15]!==x?.settings?(P=x?.settings??[],e[15]=x?.settings,e[16]=P):P=e[16],o=P,d="flex flex-col gap-4",l="lunora-settings";let A;e[17]!==n?(A=n("Open in Cloudflare"),e[17]=n,e[18]=A):A=e[18],e[19]!==A?(i=(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,a.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:Ke,rel:"noreferrer",target:"_blank",children:A})}),e[19]=A,e[20]=i):i=e[20];let $;e[21]!==n?($=n("View-only \u2014 values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=n,e[22]=$):$=e[22],e[23]!==$?(s=(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:$}),e[23]=$,e[24]=s):s=e[24],e[25]!==c||e[26]!==m?(u=c!==null&&(0,a.jsx)(je,{error:m,testId:"set-error"}),e[25]=c,e[26]=m,e[27]=u):u=e[27],_=V.length>0&&(0,a.jsxs)(le,{className:"py-0","data-testid":"set-deploy",children:[(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Deployment")})}),(0,a.jsx)(oe,{className:"py-3",children:(0,a.jsx)("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:V.map(Ge)})})]}),e[3]=c,e[4]=m,e[5]=x?.deploy,e[6]=x?.settings,e[7]=n,e[8]=o,e[9]=d,e[10]=l,e[11]=i,e[12]=s,e[13]=u,e[14]=_}else o=e[8],d=e[9],l=e[10],i=e[11],s=e[12],u=e[13],_=e[14];let k,D;e[28]===Symbol.for("react.memo_cache_sentinel")?(k=(0,a.jsx)(He,{}),D=(0,a.jsx)(qe,{}),e[28]=k,e[29]=D):(k=e[28],D=e[29]);let v;e[30]!==n?(v=n("Keyboard shortcuts"),e[30]=n,e[31]=v):v=e[31];let w;e[32]!==v?(w=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v}),e[32]=v,e[33]=w):w=e[33];let O;e[34]!==n?(O=n("Reset"),e[34]=n,e[35]=O):O=e[35];let j;e[36]!==O?(j=(0,a.jsx)("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:Oe,type:"button",children:O}),e[36]=O,e[37]=j):j=e[37];let K;e[38]!==w||e[39]!==j?(K=(0,a.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[w,j]}),e[38]=w,e[39]=j,e[40]=K):K=e[40];let y;e[41]!==n?(y=n("Command palette"),e[41]=n,e[42]=y):y=e[42];let L;e[43]!==y?(L=(0,a.jsx)(Re,{label:y,modifier:"\u2318/Ctrl",name:"palette"}),e[43]=y,e[44]=L):L=e[44];let R;e[45]!==n?(R=n("Operation console"),e[45]=n,e[46]=R):R=e[46];let U;e[47]!==R?(U=(0,a.jsx)(Re,{label:R,modifier:"Ctrl",name:"console"}),e[47]=R,e[48]=U):U=e[48];let B;e[49]!==L||e[50]!==U?(B=(0,a.jsxs)("dl",{className:"grid grid-cols-[10rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 text-sm",children:[L,U]}),e[49]=L,e[50]=U,e[51]=B):B=e[51];let H;e[52]!==n?(H=n("Stored in this browser. Focus a box and press a key to rebind it."),e[52]=n,e[53]=H):H=e[53];let q;e[54]!==H?(q=(0,a.jsx)("p",{className:"pt-3 text-xs text-muted-foreground",children:H}),e[54]=H,e[55]=q):q=e[55];let G;e[56]!==B||e[57]!==q?(G=(0,a.jsxs)(oe,{className:"py-3",children:[B,q]}),e[56]=B,e[57]=q,e[58]=G):G=e[58];let J;e[59]!==K||e[60]!==G?(J=(0,a.jsxs)(le,{className:"py-0","data-testid":"set-preferences",children:[K,G]}),e[59]=K,e[60]=G,e[61]=J):J=e[61];let S;e[62]!==n?(S=n("Environment & bindings"),e[62]=n,e[63]=S):S=e[63];let T;e[64]!==S?(T=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:S})}),e[64]=S,e[65]=T):T=e[65];let F;e[66]!==c||e[67]!==p||e[68]!==o.length||e[69]!==n?(F=c===null&&!p&&o.length===0&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:n("No environment variables or bindings.")}),e[66]=c,e[67]=p,e[68]=o.length,e[69]=n,e[70]=F):F=e[70];let Q;e[71]!==o||e[72]!==n?(Q=o.length>0&&(0,a.jsx)(oe,{className:"px-0 py-0",children:(0,a.jsxs)(Se,{"data-testid":"set-table",children:[(0,a.jsx)(Te,{children:(0,a.jsxs)(ie,{children:[(0,a.jsx)(M,{children:n("name")}),(0,a.jsx)(M,{children:n("kind")}),(0,a.jsx)(M,{children:n("value")})]})}),(0,a.jsx)(Ce,{children:o.map(Je)})]})}),e[71]=o,e[72]=n,e[73]=Q):Q=e[73];let C;e[74]!==T||e[75]!==F||e[76]!==Q?(C=(0,a.jsxs)(le,{className:"py-0",children:[T,F,Q]}),e[74]=T,e[75]=F,e[76]=Q,e[77]=C):C=e[77];let z;return e[78]!==J||e[79]!==C||e[80]!==d||e[81]!==l||e[82]!==i||e[83]!==s||e[84]!==u||e[85]!==_?(z=(0,a.jsxs)("div",{className:d,"data-testid":l,children:[i,s,u,_,k,D,J,C]}),e[78]=J,e[79]=C,e[80]=d,e[81]=l,e[82]=i,e[83]=s,e[84]=u,e[85]=_,e[86]=z):z=e[86],z},"ft");function Ge(t){return(0,a.jsxs)("div",{className:"contents","data-testid":"set-deploy-row",children:[(0,a.jsx)("dt",{className:"text-muted-foreground",children:t.label}),(0,a.jsx)("dd",{className:"truncate font-mono text-xs",title:t.value,children:t.value})]},t.label)}b(Ge,"He");function Je(t){return(0,a.jsxs)(ie,{"data-testid":"set-row",children:[(0,a.jsx)(W,{className:"font-mono text-xs font-medium",children:t.name}),(0,a.jsx)(W,{children:(0,a.jsx)(_e,{variant:Fe[t.kind],children:t.bindingType??t.kind})}),(0,a.jsx)(W,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:t.value??(0,a.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},t.name)}b(Je,"We");export{ct as SettingsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as u,s as f}from"./chunk-
|
|
1
|
+
import{j as u,s as f}from"./chunk-JEKJEGBJ.js";import{a as S}from"./chunk-A6TVTNKO.js";import{a as h}from"./chunk-ADABTCDI.js";import{a as s,d as l}from"./chunk-5PEAXTYQ.js";var i=l(S(),1),c=l(h(),1);var g=s(()=>{let t=(0,i.c)(4),[a,n]=(0,c.useState)(!1),[e,m]=(0,c.useState)(null),r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=s(p=>{f((async()=>{n(!0),m(null);try{await p()}catch(b){m(u(b))}n(!1)})())},"e"),t[0]=r):r=t[0];let y=r,o;return t[1]!==a||t[2]!==e?(o={busy:a,error:e,run:y},t[1]=a,t[2]=e,t[3]=o):o=t[3],o},"g");export{g as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as L,d as W,e as $,f as q,h as D,i as F,j as H,k as A,l as S,m as I,n as J,o as M,p as P}from"./chunk-
|
|
1
|
+
import{c as L,d as W,e as $,f as q,h as D,i as F,j as H,k as A,l as S,m as I,n as J,o as M,p as P}from"./chunk-MT3SPV45.js";import{a as O}from"./chunk-KCIVTT2F.js";import{a as X,b as z,c as B,d as K,e as E,f as G}from"./chunk-YM56MNAN.js";import{B as C,r as j}from"./chunk-JEKJEGBJ.js";import{a as U}from"./chunk-A6TVTNKO.js";import{b as V}from"./chunk-ADABTCDI.js";import{a as f,d as T}from"./chunk-5PEAXTYQ.js";var N=T(U(),1);var t=T(V(),1);var _=50,R={value:{colors:{dark:["var(--chart-1)"],light:["var(--chart-1)"]},label:"value"}},Q=f(r=>{let a=r.columns.find(e=>r.rows.length>0&&r.rows.every(n=>typeof n[e]=="number"))??null;return{label:r.columns.find(e=>e!==a)??null,value:a}},"D"),Y=f(r=>{let a=(0,N.c)(3),{data:e,kind:n}=r,l;return a[0]!==e||a[1]!==n?(l=(0,t.jsx)(H,{className:"h-full w-full",config:R,children:n==="area"?(0,t.jsxs)(F,{data:e,children:[(0,t.jsx)(L,{vertical:!1}),(0,t.jsx)(q,{axisLine:!1,dataKey:"label",tickLine:!1}),(0,t.jsx)(S,{content:(0,t.jsx)(A,{})}),(0,t.jsx)($,{dataKey:"value",fill:"var(--color-value-0)",fillOpacity:.2,stroke:"var(--color-value-0)",type:"monotone"})]}):(0,t.jsxs)(D,{data:e,children:[(0,t.jsx)(L,{vertical:!1}),(0,t.jsx)(q,{axisLine:!1,dataKey:"label",tickLine:!1}),(0,t.jsx)(S,{content:(0,t.jsx)(A,{})}),(0,t.jsx)(W,{dataKey:"value",dot:!1,stroke:"var(--color-value-0)",strokeWidth:2,type:"monotone"})]})}),a[0]=e,a[1]=n,a[2]=l):l=a[2],l},"J"),na=f(r=>{let a=(0,N.c)(21),{axes:e,kind:n,result:l}=r,u=C(),o;a[0]!==l?(o=Q(l),a[0]=l,a[1]=o):o=a[1];let d=o,m;a[2]!==l.columns?(m=new Set(l.columns),a[2]=l.columns,a[3]=m):m=a[3];let s=m,c=e!==void 0&&s.has(e.x)?e.x:d.label,p;a[4]!==e?.y||a[5]!==s?(p=e?.y.find(i=>s.has(i)),a[4]=e?.y,a[5]=s,a[6]=p):p=a[6];let x=p,y=x??d.value,b;a[7]!==c||a[8]!==l.rows||a[9]!==y?(b=y===null?[]:l.rows.slice(0,_).map((i,w)=>({label:c===null?`#${(w+1).toString()}`:j(i[c]),value:Number(i[y])||0})),a[7]=c,a[8]=l.rows,a[9]=y,a[10]=b):b=a[10];let k=b;if(y===null){let i;a[11]!==u?(i=u("No numeric column to chart."),a[11]=u,a[12]=i):i=a[12];let w;return a[13]!==i?(w=(0,t.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-chart-empty",children:i}),a[13]=i,a[14]=w):w=a[14],w}let h=n??(e!==void 0&&x!==void 0?e.kind:"bar"),v;a[15]!==k||a[16]!==h?(v=h==="bar"?(0,t.jsxs)(I,{className:"h-full w-full",config:R,data:k,children:[(0,t.jsx)(M,{dataKey:"label"}),(0,t.jsx)(J,{dataKey:"value"}),(0,t.jsx)(P,{})]}):(0,t.jsx)(Y,{data:k,kind:h}),a[15]=k,a[16]=h,a[17]=v):v=a[17];let g;return a[18]!==h||a[19]!==v?(g=(0,t.jsx)("div",{className:"h-80 w-full p-3","data-chart-kind":h,"data-testid":"sql-chart",children:v}),a[18]=h,a[19]=v,a[20]=g):g=a[20],g},"oe"),oa=f(r=>{let a=(0,N.c)(19),{result:e}=r,n=C();if(e.columns.length===0){let s;a[0]!==e.rowCount||a[1]!==n?(s=n("{count} rows",{count:e.rowCount}),a[0]=e.rowCount,a[1]=n,a[2]=s):s=a[2];let c;return a[3]!==s?(c=(0,t.jsx)("p",{className:"p-4 text-sm text-muted-foreground",children:s}),a[3]=s,a[4]=c):c=a[4],c}let l;a[5]!==e.columns?(l=e.columns.map(Z),a[5]=e.columns,a[6]=l):l=a[6];let u;a[7]!==l?(u=(0,t.jsx)(z,{className:"sticky top-0 z-10 bg-muted",children:(0,t.jsx)(K,{children:l})}),a[7]=l,a[8]=u):u=a[8];let o;if(a[9]!==e.columns||a[10]!==e.rows){let s;a[12]!==e.columns?(s=f((c,p)=>(0,t.jsx)(K,{"data-testid":"sql-row",children:e.columns.map(x=>(0,t.jsx)(G,{className:"max-w-md truncate font-mono text-xs",children:(0,t.jsx)(O,{value:c[x]})},x))},p),"s"),a[12]=e.columns,a[13]=s):s=a[13],o=e.rows.map(s),a[9]=e.columns,a[10]=e.rows,a[11]=o}else o=a[11];let d;a[14]!==o?(d=(0,t.jsx)(B,{children:o}),a[14]=o,a[15]=d):d=a[15];let m;return a[16]!==u||a[17]!==d?(m=(0,t.jsxs)(X,{"data-testid":"sql-rows",children:[u,d]}),a[16]=u,a[17]=d,a[18]=m):m=a[18],m},"ne");function Z(r){return(0,t.jsx)(E,{children:r},r)}f(Z,"P");export{na as a,oa as b};
|