@lunora/studio 1.0.0-alpha.78 → 1.0.0-alpha.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/mount.js +1 -1
- package/dist/packem_chunks/ApiTab.js +1 -1
- package/dist/packem_chunks/AuditPanel.js +1 -1
- package/dist/packem_chunks/ExportImportPanel.js +1 -1
- package/dist/packem_chunks/FileBrowser.js +1 -1
- package/dist/packem_chunks/FunctionRunner.js +1 -1
- package/dist/packem_chunks/FunctionStatsPanel.js +1 -1
- package/dist/packem_chunks/HealthPanel.js +1 -1
- package/dist/packem_chunks/InsightsPanel.js +1 -1
- package/dist/packem_chunks/LogsPanel.js +1 -1
- package/dist/packem_chunks/MailPanel.js +1 -1
- package/dist/packem_chunks/MetricsPanel.js +1 -1
- package/dist/packem_chunks/MigrationsPanel.js +1 -1
- package/dist/packem_chunks/NotificationsPanel.js +1 -1
- package/dist/packem_chunks/PitrPanel.js +1 -1
- package/dist/packem_chunks/SchemaViewer.js +1 -1
- package/dist/packem_chunks/SecurityAdvisorPanel.js +1 -1
- package/dist/packem_chunks/SettingsPanel.js +1 -1
- package/dist/packem_chunks/SqlEditorPanel.js +1 -1
- package/dist/packem_chunks/TableEditor.js +1 -1
- package/dist/packem_chunks/agents-panel.js +1 -1
- package/dist/packem_chunks/auth-audit-panel.js +1 -1
- package/dist/packem_chunks/containers-panel.js +1 -1
- package/dist/packem_chunks/dashboards-panel.js +1 -1
- package/dist/packem_chunks/fanout-panel.js +1 -1
- package/dist/packem_chunks/flags-panel.js +1 -1
- package/dist/packem_chunks/issues-panel.js +1 -1
- package/dist/packem_chunks/kv-browser.js +1 -1
- package/dist/packem_chunks/organizations-panel.js +1 -1
- package/dist/packem_chunks/payments-panel.js +1 -1
- package/dist/packem_chunks/permissions-panel.js +1 -1
- package/dist/packem_chunks/queues-panel.js +1 -1
- package/dist/packem_chunks/rls-panel.js +1 -1
- package/dist/packem_chunks/storage-rules-panel.js +1 -1
- package/dist/packem_chunks/subscriptions-panel.js +1 -1
- package/dist/packem_chunks/traces-panel.js +1 -1
- package/dist/packem_chunks/users-panel.js +1 -1
- package/dist/packem_chunks/workflows-panel.js +1 -1
- package/dist/packem_shared/ADMIN_FUNCTIONS-CpgIo9pj.js +1 -0
- package/dist/packem_shared/{ApiDocsPanel-eJYZlylw.js → ApiDocsPanel-CjdsxN1t.js} +1 -1
- package/dist/packem_shared/{DataBrowser-B8J5lHjP.js → DataBrowser-Bfstz_au.js} +1 -1
- package/dist/packem_shared/{HomePanel-DL1HupAN.js → HomePanel-B8EFM4u3.js} +1 -1
- package/dist/packem_shared/{Studio-BWBclm_C.js → Studio-BDtS9C5g.js} +1 -1
- package/dist/packem_shared/{StudioApp-BFm73yVr.js → StudioApp-DjLzIO9E.js} +1 -1
- package/dist/packem_shared/{home-panel-B-8BCffw.js → home-panel-Cm88Nvqh.js} +1 -1
- package/dist/packem_shared/{studio-BHA7hnI3.js → studio-BmWFd-Rz.js} +1 -1
- package/dist/packem_shared/use-async-submit-DLNCqLFq.js +1 -0
- package/dist/packem_shared/use-auth-config-9S_K_W-G.js +1 -0
- package/dist/standalone/{chunk-EVN46TVV.js → chunk-2SHUN7KF.js} +1 -1
- package/dist/standalone/{chunk-C43X4M5U.js → chunk-3EXLKL6V.js} +1 -1
- package/dist/standalone/{chunk-KDOC2DP5.js → chunk-3KAERFMC.js} +1 -1
- package/dist/standalone/{chunk-GSPTEMYN.js → chunk-4XDMVUS5.js} +1 -1
- package/dist/standalone/{chunk-YD5NF6UT.js → chunk-5YWJNF5X.js} +1 -1
- package/dist/standalone/chunk-66YJ3IOZ.js +1 -0
- package/dist/standalone/{chunk-2F7G7IWQ.js → chunk-6CULAILE.js} +1 -1
- package/dist/standalone/{chunk-D7XXWV4E.js → chunk-6KHEBRBB.js} +1 -1
- package/dist/standalone/{chunk-4WLYA3XE.js → chunk-6WCIFGDW.js} +1 -1
- package/dist/standalone/{chunk-OHKRN65U.js → chunk-7RG3AKPY.js} +1 -1
- package/dist/standalone/{chunk-65OTWFS3.js → chunk-A2FPLOMJ.js} +1 -1
- package/dist/standalone/chunk-AADILRJW.js +14 -0
- package/dist/standalone/chunk-AADXUXZO.js +1 -0
- package/dist/standalone/{chunk-L7N7F3DA.js → chunk-ARI4JTIH.js} +1 -1
- package/dist/standalone/chunk-AVZGVZZ7.js +1 -0
- package/dist/standalone/{chunk-5U2THBI7.js → chunk-BDO4J5AP.js} +1 -1
- package/dist/standalone/{chunk-XSD4Y6SQ.js → chunk-BMQJ4CAO.js} +1 -1
- package/dist/standalone/{chunk-5L2MD6F6.js → chunk-CMUP7HPS.js} +1 -1
- package/dist/standalone/{chunk-QGKAJTQQ.js → chunk-CP7AUUOU.js} +1 -1
- package/dist/standalone/{chunk-UIS34ZPB.js → chunk-DX3RMFQU.js} +1 -1
- package/dist/standalone/{chunk-5OWIOACV.js → chunk-E2CJUP53.js} +1 -1
- package/dist/standalone/{chunk-FGTK44LR.js → chunk-EIT7ERYE.js} +1 -1
- package/dist/standalone/{chunk-35II7U25.js → chunk-EN2QAEO4.js} +1 -1
- package/dist/standalone/{chunk-QVEHPYA5.js → chunk-FLYO3XY5.js} +1 -1
- package/dist/standalone/{chunk-DVOBKIUX.js → chunk-FWCKM2CU.js} +1 -1
- package/dist/standalone/{chunk-VPAXCQ2Y.js → chunk-GITJXQOS.js} +1 -1
- package/dist/standalone/{chunk-SA3MDZC3.js → chunk-GP6IRITM.js} +1 -1
- package/dist/standalone/{chunk-VGHSEUEX.js → chunk-GXU3ATKS.js} +1 -1
- package/dist/standalone/{chunk-FPLGBHY4.js → chunk-H5Y5NQPL.js} +1 -1
- package/dist/standalone/{chunk-34UVAASH.js → chunk-HALNNKTC.js} +1 -1
- package/dist/standalone/{chunk-UNUU7CJJ.js → chunk-HK4OVYG3.js} +1 -1
- package/dist/standalone/{chunk-ZNNAGR6N.js → chunk-HQEMYD2K.js} +1 -1
- package/dist/standalone/{chunk-F6GOKFMU.js → chunk-HYT2ZUNP.js} +2 -2
- package/dist/standalone/{chunk-7RXOPYR5.js → chunk-I4WGRDL2.js} +1 -1
- package/dist/standalone/{chunk-P24JBHEZ.js → chunk-ISZSYNTI.js} +1 -1
- package/dist/standalone/chunk-JWG3VRGB.js +1 -0
- package/dist/standalone/{chunk-RAA2RGG6.js → chunk-KDYNM3GV.js} +1 -1
- package/dist/standalone/{chunk-T2JIUFOD.js → chunk-KP6JQSH2.js} +1 -1
- package/dist/standalone/{chunk-IDNNI63H.js → chunk-LSEZN2ZL.js} +1 -1
- package/dist/standalone/{chunk-LJDP7NRB.js → chunk-LU3GW7HI.js} +1 -1
- package/dist/standalone/chunk-MVGE3JJN.js +1 -0
- package/dist/standalone/chunk-MXSHWB3M.js +1 -0
- package/dist/standalone/{chunk-BEH5N5ZA.js → chunk-NG6LYBPJ.js} +1 -1
- package/dist/standalone/{chunk-HP2UCWND.js → chunk-NL2DZKFI.js} +1 -1
- package/dist/standalone/{chunk-EXFBIISG.js → chunk-OGVCXKRL.js} +1 -1
- package/dist/standalone/{chunk-EKRN4ZQM.js → chunk-OPC233PZ.js} +1 -1
- package/dist/standalone/{chunk-TLHJRWNK.js → chunk-P4CWOYFL.js} +1 -1
- package/dist/standalone/{chunk-QLJJ5YYZ.js → chunk-PRJ4RJDU.js} +1 -1
- package/dist/standalone/{chunk-XEDU5FO4.js → chunk-PUY3YDXI.js} +1 -1
- package/dist/standalone/{chunk-FGTABSAK.js → chunk-QZMR6MUG.js} +1 -1
- package/dist/standalone/{chunk-F5QWLENA.js → chunk-W6TE2I2D.js} +1 -1
- package/dist/standalone/{chunk-PF7V3G2Z.js → chunk-WCWYSOCN.js} +1 -1
- package/dist/standalone/{chunk-BNUJ7QMG.js → chunk-WEO3YVP6.js} +1 -1
- package/dist/standalone/{chunk-6DWCIIHE.js → chunk-XIZNYKOD.js} +1 -1
- package/dist/standalone/{chunk-3FUFEZ65.js → chunk-XS6Q6GGV.js} +1 -1
- package/dist/standalone/{chunk-XQBTNJUQ.js → chunk-Y3CQDULJ.js} +1 -1
- package/dist/standalone/{chunk-7J5N6DGQ.js → chunk-YCRMVBPW.js} +1 -1
- package/dist/standalone/{chunk-H7NIIBHH.js → chunk-Z2JPEI2V.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/dist/styles.css +1 -1
- package/package.json +6 -6
- package/dist/packem_shared/ADMIN_FUNCTIONS-BYNSbBVE.js +0 -1
- package/dist/packem_shared/use-async-submit-H68GHPz8.js +0 -1
- package/dist/standalone/chunk-3QRTYSSX.js +0 -1
- package/dist/standalone/chunk-B43FTQJ7.js +0 -1
- package/dist/standalone/chunk-GXZAXNZI.js +0 -1
- package/dist/standalone/chunk-LE56LPNH.js +0 -13
- package/dist/standalone/chunk-PWWHP76O.js +0 -1
- package/dist/standalone/chunk-YI3WYUXK.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as ze}from"./chunk-
|
|
1
|
+
import{a as ze}from"./chunk-I4WGRDL2.js";import{a as _e}from"./chunk-LLXFYRGQ.js";import{a as Ae}from"./chunk-5RF4QDDA.js";import"./chunk-XQGANNLS.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import"./chunk-ESVP44Y3.js";import"./chunk-KYF2E5CJ.js";import"./chunk-7YEFOSPH.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-WCWYSOCN.js";import"./chunk-4UOFSGUS.js";import"./chunk-ILNELDFC.js";import"./chunk-7LQWFOEU.js";import"./chunk-T6VMSOBB.js";import{a as Le}from"./chunk-XXQUMVWH.js";import{a as Re,b as Te,c as Oe,d as xe,e as De,f as Me}from"./chunk-MIQTKZAR.js";import"./chunk-QBWRC5YX.js";import{a as Ee}from"./chunk-LFXFP4IF.js";import{b as Ie}from"./chunk-GRL5MG3Z.js";import{d as oe,e as he,f as fe}from"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as le}from"./chunk-AADXUXZO.js";import{f as be}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{d as K,f as ne,g as re,h as Se,m as X}from"./chunk-4CGALXS3.js";import"./chunk-AADILRJW.js";import{a as s,e as pe,f as Et,g as Lt,h as Rt,j as te}from"./chunk-3XIESWL4.js";var Y=pe(Lt(),1);var E=pe(Et(),1);var r=pe(Rt(),1);var Tt=["ORDER BY","GROUP BY","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN","EXPLAIN QUERY PLAN","SELECT","DISTINCT","FROM","WHERE","HAVING","LIMIT","OFFSET","JOIN","ON","AND","OR","AS","ASC","DESC","WITH","UNION","EXPLAIN"],Ot=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],se=String.fromCodePoint(0),Dt=new RegExp(`${se}${String.raw`(\d+)`}${se}`,"gu"),Mt=Tt.map(l=>({pattern:new RegExp(String.raw`\b${l.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:l})),_t=Ot.map(l=>({pattern:new RegExp(String.raw`\s+${l.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
|
|
2
2
|
${l}`})),At=s(l=>{let e=[],t=l.replaceAll(/'(?:[^']|'')*'/gu,n=>(e.push(n),`${se}${(e.length-1).toString()}${se}`)).replaceAll(/\s+/gu," ").trim();for(let{pattern:n,replacement:o}of Mt)t=t.replaceAll(n,o);for(let{pattern:n,replacement:o}of _t)t=t.replaceAll(n,o);return t=t.replaceAll(Dt,(n,o)=>e[Number(o)]??""),t},"_t"),zt=["AND","ASC","AS","BY","COUNT","DESC","DISTINCT","EXPLAIN","FROM","GROUP","HAVING","INNER","JOIN","LEFT","LIKE","LIMIT","NOT","NULL","OFFSET","ON","ORDER","OR","QUERY","SELECT","WHERE","WITH"],Wt=new Set(["AND","BY","HAVING","ON","OR","SELECT","WHERE"]),$t=/[\w$]/,Be=s(l=>l!==void 0&&$t.test(l),"Te"),je=s(l=>{let e=l.length;for(;e>0&&Be(l[e-1]);)e-=1;return l.slice(e)},"Le"),He=s((l,e)=>{let t=e;for(;t>0&&Be(l[t-1]);)t-=1;return{end:e,start:t,text:l.slice(t,e)}},"Re"),We=s((l,e)=>{let t=l.slice(0,e).trimEnd();return t.endsWith(".")||Wt.has(je(t).toUpperCase())},"Ce"),Bt=s((l,e)=>{let t=l.slice(0,e);if(!t.endsWith("."))return;let n=je(t.slice(0,-1));return n===""?void 0:n},"Bt"),Ne=s((l,e)=>l.toLowerCase().startsWith(e.toLowerCase()),"ge"),$e=s((l,e,t,n)=>{let o=[];for(let a of l)if(Ne(a,e)&&(o.push(n(a)),o.length>=t))break;return o},"Se"),jt=s((l,e,t)=>{let n=new Map;for(let[o,a]of Object.entries(l.columns))for(let d of a)if(Ne(d,e)&&!n.has(d)&&(n.set(d,o),n.size>=t))return[...n].map(([p,c])=>({detail:c,kind:"column",label:p}));return[...n].map(([o,a])=>({detail:a,kind:"column",label:o}))},"Wt"),Ht=s((l,e,t)=>{let n=He(l,e),o=Bt(l,n.start);if(o!==void 0){let c=t.columns[o]??t.columns[o.toLowerCase()]??[];return $e(c,n.text,8,m=>({detail:o,kind:"column",label:m}))}if(n.text===""&&!We(l,n.start))return[];let a=$e(t.tables,n.text,8,c=>({kind:"table",label:c})),d=jt(t,n.text,8),p=zt.filter(c=>n.text!==""&&Ne(c,n.text)&&c.toLowerCase()!==n.text.toLowerCase()).map(c=>({kind:"keyword",label:c}));return(We(l,n.start)?[...d,...a,...p]:[...a,...d,...p]).slice(0,8)},"Ft"),Ft=s((l,e,t)=>{let n=He(l,e),o=l.slice(0,n.start)+t.label+l.slice(n.end);return{caret:n.start+t.label.length,value:o}},"Ht"),Pt=["boxSizing","borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textTransform","width","wordSpacing"],Jt=s((l,e)=>{let t=globalThis.getComputedStyle(l),n=globalThis.document.createElement("div"),{style:o}=n;o.position="absolute",o.visibility="hidden",o.whiteSpace="pre-wrap",o.overflowWrap="break-word";for(let c of Pt)o[c]=t[c];n.textContent=l.value.slice(0,Math.max(0,e));let a=globalThis.document.createElement("span");a.textContent=l.value.slice(Math.max(0,e))||".",n.append(a),globalThis.document.body.append(n);let d=a.offsetLeft-l.scrollLeft,p=a.offsetTop-l.scrollTop;return n.remove(),{left:d,top:p}},"Ut"),Ut=s((l,e,t)=>{let n=(0,Y.c)(13),[o,a]=(0,E.useState)(null),d;n[0]!==l||n[1]!==e?(d=s((y,v)=>{let N=Ht(y,v,l);if(N.length===0){a(null);return}let f=e.current,{left:C,top:q}=f===null?{left:0,top:0}:Jt(f,v);a(L=>L!==null&&L.active===0&&L.left===C&&L.top===q&&L.suggestions.length===N.length&&L.suggestions.every((S,M)=>{let O=N.at(M);return S.kind===O?.kind&&S.label===O.label&&S.detail===O.detail})?L:{active:0,left:C,suggestions:N,top:q})},"c"),n[0]=l,n[1]=e,n[2]=d):d=n[2];let p=d,c;n[3]===Symbol.for("react.memo_cache_sentinel")?(c=s(()=>{a(null)},"i"),n[3]=c):c=n[3];let m=c,k;n[4]===Symbol.for("react.memo_cache_sentinel")?(k=s(y=>{a(v=>{if(v===null)return v;let N=v.suggestions.length,f=(v.active+y+N)%N;return{...v,active:f}})},"N"),n[4]=k):k=n[4];let g=k,x;n[5]!==t||n[6]!==o||n[7]!==e?(x=s(()=>{let y=e.current;if(o===null||y===null)return!1;let v=o.suggestions[o.active];if(v===void 0)return!1;let N=Ft(y.value,y.selectionStart,v);return t(N.value),a(null),requestAnimationFrame(()=>{let f=e.current;f!==null&&(f.focus(),f.setSelectionRange(N.caret,N.caret))}),!0},"h"),n[5]=t,n[6]=o,n[7]=e,n[8]=x):x=n[8];let b=x,u;return n[9]!==b||n[10]!==p||n[11]!==o?(u={close:m,commit:b,move:g,refresh:p,state:o},n[9]=b,n[10]=p,n[11]=o,n[12]=u):u=n[12],u},"Jt"),Yt={column:"column",keyword:"keyword",table:"table"},Kt=20,Gt=s(l=>{let e=(0,Y.c)(17),{listboxId:t,onPick:n,state:o}=l,a=K(),d;e[0]!==o?(d=o===null?void 0:{left:o.left,top:o.top+Kt},e[0]=o,e[1]=d):d=e[1];let p=d;if(o===null)return null;let c;if(e[2]!==t||e[3]!==n||e[4]!==o.active||e[5]!==o.suggestions||e[6]!==a){let k;e[8]!==t||e[9]!==n||e[10]!==o.active||e[11]!==a?(k=s((g,x)=>(0,r.jsxs)("li",{"aria-selected":x===o.active,className:te("flex cursor-pointer items-center gap-2 px-2 py-1 text-[13px]",x===o.active?"bg-accent text-accent-foreground":"text-foreground"),"data-testid":"sql-autocomplete-item",id:`${t}-opt-${x.toString()}`,onMouseDown:s(b=>{b.preventDefault(),n(x)},"onMouseDown"),role:"option",children:[(0,r.jsx)("span",{className:"truncate font-mono",children:g.label}),g.detail!==void 0&&(0,r.jsx)("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:g.detail}),(0,r.jsx)("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:a(Yt[g.kind])})]},`${g.kind}:${g.label}`),"N"),e[8]=t,e[9]=n,e[10]=o.active,e[11]=a,e[12]=k):k=e[12],c=o.suggestions.map(k),e[2]=t,e[3]=n,e[4]=o.active,e[5]=o.suggestions,e[6]=a,e[7]=c}else c=e[7];let m;return e[13]!==t||e[14]!==p||e[15]!==c?(m=(0,r.jsx)("ul",{className:"absolute z-30 max-h-56 w-72 overflow-auto rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-autocomplete",id:t,role:"listbox",style:p,children:c}),e[13]=t,e[14]=p,e[15]=c,e[16]=m):m=e[16],m},"Vt"),Fe=[{label:"List tables",sql:"SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name;"},{label:"Table row count",sql:"SELECT COUNT(*) AS rows FROM messages;"},{label:"Recent rows",sql:"SELECT id, _creationTime, __doc__ FROM messages ORDER BY _creationTime DESC LIMIT 50;"},{label:"Index list",sql:"SELECT name, tbl_name FROM sqlite_master WHERE type = 'index' ORDER BY tbl_name;"}],Vt=s(l=>{let e=(0,Y.c)(29),{active:t,onDelete:n,onSelect:o,query:a}=l,d=K(),p;e[0]!==o||e[1]!==a.id?(p=s(()=>{o(a.id)},"m"),e[0]=o,e[1]=a.id,e[2]=p):p=e[2];let c=p,m;e[3]!==n||e[4]!==a.id?(m=s(S=>{S.stopPropagation(),n(a.id)},"u"),e[3]=n,e[4]=a.id,e[5]=m):m=e[5];let k=m,g=t?"bg-sidebar-accent font-medium text-foreground":"text-muted-foreground",x;e[6]!==g?(x=te("flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] outline-none transition-colors hover:bg-sidebar-accent focus-visible:bg-sidebar-accent",g),e[6]=g,e[7]=x):x=e[7];let b=`sql-query-${a.id}`,u;e[8]===Symbol.for("react.memo_cache_sentinel")?(u=(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M4 6h16M4 12h10M4 18h7"})}),e[8]=u):u=e[8];let y;e[9]!==a.name?(y=(0,r.jsx)("span",{className:"truncate",children:a.name}),e[9]=a.name,e[10]=y):y=e[10];let v;e[11]!==t||e[12]!==c||e[13]!==x||e[14]!==b||e[15]!==y?(v=(0,r.jsxs)("button",{"aria-pressed":t,className:x,"data-testid":b,onClick:c,type:"button",children:[u,y]}),e[11]=t,e[12]=c,e[13]=x,e[14]=b,e[15]=y,e[16]=v):v=e[16];let N;e[17]!==d?(N=d("Delete query"),e[17]=d,e[18]=N):N=e[18];let f;e[19]!==d?(f=d("Delete query"),e[19]=d,e[20]=f):f=e[20];let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C=(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[21]=C):C=e[21];let q;e[22]!==k||e[23]!==f||e[24]!==N?(q=(0,r.jsx)("button",{"aria-label":N,className:"me-1 hidden size-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive group-hover/q:flex",onClick:k,title:f,type:"button",children:C}),e[22]=k,e[23]=f,e[24]=N,e[25]=q):q=e[25];let L;return e[26]!==q||e[27]!==v?(L=(0,r.jsxs)("li",{className:"group/q flex items-center",children:[v,q]}),e[26]=q,e[27]=v,e[28]=L):L=e[28],L},"Gt"),Xt=s(l=>{let e=(0,Y.c)(58),{activeId:t,history:n,listRef:o,onClearHistory:a,onDelete:d,onLoadHistory:p,onLoadTemplate:c,onNew:m,onSearchChange:k,onSelect:g,queries:x,search:b}=l,u=K(),y;if(e[0]!==x||e[1]!==b){let I=b.trim().toLowerCase();y=I===""?[...x]:x.filter(T=>T.name.toLowerCase().includes(I)),e[0]=x,e[1]=b,e[2]=y}else y=e[2];let v=y,N;e[3]!==u?(N=u("Search queries\u2026"),e[3]=u,e[4]=N):N=e[4];let f;e[5]!==k||e[6]!==b||e[7]!==N?(f=(0,r.jsx)("input",{className:"h-8 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"sql-search",onChange:k,placeholder:N,type:"text",value:b}),e[5]=k,e[6]=b,e[7]=N,e[8]=f):f=e[8];let C;e[9]!==u?(C=u("New query"),e[9]=u,e[10]=C):C=e[10];let q;e[11]!==u?(q=u("New query"),e[11]=u,e[12]=q):q=e[12];let L;e[13]===Symbol.for("react.memo_cache_sentinel")?(L=(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M12 5v14M5 12h14"})}),e[13]=L):L=e[13];let S;e[14]!==m||e[15]!==C||e[16]!==q?(S=(0,r.jsx)("button",{"aria-label":C,className:"flex size-8 shrink-0 items-center justify-center rounded-md border border-border text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-new",onClick:m,title:q,type:"button",children:L}),e[14]=m,e[15]=C,e[16]=q,e[17]=S):S=e[17];let M;e[18]!==f||e[19]!==S?(M=(0,r.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border p-2",children:[f,S]}),e[18]=f,e[19]=S,e[20]=M):M=e[20];let O;e[21]!==u?(O=u("Private"),e[21]=u,e[22]=O):O=e[22];let _;e[23]!==O?(_=(0,r.jsx)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:O}),e[23]=O,e[24]=_):_=e[24];let A;e[25]!==t||e[26]!==v||e[27]!==o||e[28]!==d||e[29]!==g||e[30]!==u?(A=v.length===0?(0,r.jsx)("p",{className:"px-1 py-2 text-xs text-muted-foreground","data-testid":"sql-private-empty",children:u("No saved queries yet \u2014 they save to this browser as you type.")}):(0,r.jsx)("ul",{className:"flex flex-col gap-px","data-testid":"sql-private",ref:o,children:v.map(I=>(0,r.jsx)(Vt,{active:t===I.id,onDelete:d,onSelect:g,query:I},I.id))}),e[25]=t,e[26]=v,e[27]=o,e[28]=d,e[29]=g,e[30]=u,e[31]=A):A=e[31];let W;e[32]!==_||e[33]!==A?(W=(0,r.jsxs)("div",{children:[_,A]}),e[32]=_,e[33]=A,e[34]=W):W=e[34];let $;e[35]!==u?($=u("Reference"),e[35]=u,e[36]=$):$=e[36];let P;e[37]!==$?(P=(0,r.jsx)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:$}),e[37]=$,e[38]=P):P=e[38];let H;e[39]!==c?(H=Fe.map(I=>(0,r.jsx)("li",{children:(0,r.jsxs)("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:bg-sidebar-accent","data-sql":I.sql,onClick:c,type:"button",children:[(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M7 4h7l4 4v12H7zM14 4v4h4"})}),I.label]})},I.label)),e[39]=c,e[40]=H):H=e[40];let z;e[41]!==H?(z=(0,r.jsx)("ul",{className:"flex flex-col gap-px",children:H}),e[41]=H,e[42]=z):z=e[42];let R;e[43]!==P||e[44]!==z?(R=(0,r.jsxs)("div",{children:[P,z]}),e[43]=P,e[44]=z,e[45]=R):R=e[45];let D;e[46]!==n||e[47]!==a||e[48]!==p||e[49]!==u?(D=n.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-1 pb-1",children:[(0,r.jsx)("p",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:u("History")}),(0,r.jsx)("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"sql-history-clear",onClick:a,type:"button",children:u("Clear history")})]}),(0,r.jsx)("ul",{className:"flex flex-col gap-px","data-testid":"sql-history",children:n.map(I=>(0,r.jsx)("li",{children:(0,r.jsxs)("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:bg-sidebar-accent","data-sql":I.sql,"data-testid":"sql-history-item",onClick:p,title:I.sql,type:"button",children:[(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M12 8v4l3 2M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18Z"})}),(0,r.jsx)("span",{className:"truncate font-mono",children:I.sql})]})},`${I.at.toString()}:${I.sql}`))})]}),e[46]=n,e[47]=a,e[48]=p,e[49]=u,e[50]=D):D=e[50];let B;e[51]!==W||e[52]!==R||e[53]!==D?(B=(0,r.jsxs)("div",{className:"flex flex-1 flex-col gap-4 overflow-y-auto p-2",children:[W,R,D]}),e[51]=W,e[52]=R,e[53]=D,e[54]=B):B=e[54];let j;return e[55]!==B||e[56]!==M?(j=(0,r.jsxs)("aside",{className:"flex h-full w-64 shrink-0 flex-col border-e border-border bg-sidebar",children:[M,B]}),e[55]=B,e[56]=M,e[57]=j):j=e[57],j},"Qt"),Qt=ne(le.listTables),Zt=ne(le.readTablePage),en=s(l=>{let e=(0,Y.c)(16),t=be(),n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],e[0]=n):n=e[0];let[o,a]=(0,E.useState)(n),d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d={},e[1]=d):d=e[1];let[p,c]=(0,E.useState)(d),m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=new Set,e[2]=m):m=e[2];let k=(0,E.useRef)(m),g,x;e[3]!==t||e[4]!==l?(g=s(()=>{let f={cancelled:!1};return X((async()=>{try{let C=await t.query(Qt,{},re(l));f.cancelled||(a(C.map(nn)),c({}),k.current=new Set)}catch{f.cancelled||(a([]),c({}),k.current=new Set)}})()),()=>{f.cancelled=!0}},"x"),x=[t,l],e[3]=t,e[4]=l,e[5]=g,e[6]=x):(g=e[5],x=e[6]),(0,E.useEffect)(g,x);let b;e[7]!==t||e[8]!==l?(b=s(f=>{k.current.has(f)||(k.current.add(f),X((async()=>{try{let C=await t.query(Zt,{limit:1,offset:0,table:f},re(l));c(q=>({...q,[f]:C.columns}))}catch{k.current.delete(f)}})()))},"p"),e[7]=t,e[8]=l,e[9]=b):b=e[9];let u=b,y;e[10]!==p||e[11]!==o?(y={columns:p,tables:o},e[10]=p,e[11]=o,e[12]=y):y=e[12];let v=y,N;return e[13]!==u||e[14]!==v?(N={probe:u,schema:v},e[13]=u,e[14]=v,e[15]=N):N=e[15],N},"en"),ge=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,tn=s(l=>{let e=new Set;ge.lastIndex=0;let t=ge.exec(l);for(;t!==null;)e.add(t[1]??t[2]),t=ge.exec(l);return[...e]},"tn");function nn(l){return l.name}s(nn,"nn");var rn="lunora-studio-sql-tabs",ln="lunora-studio-sql-active-tab",ye=12,Q=s((l="",e="")=>({activeId:null,id:fe("tab"),name:e,sql:l}),"Q"),on=s(()=>he(ln,""),"on"),sn=s(l=>{let[e,t]=oe(rn),[n,o]=on(),a=(0,E.useRef)(null);e.length===0&&a.current===null&&(a.current=l()),(0,E.useEffect)(()=>{if(e.length===0&&a.current!==null){let p=a.current;t([p])}},[t,e.length]);let d=e.length===0&&a.current!==null?[a.current]:e;return{activeId:d.some(p=>p.id===n)?n:d[0]?.id??"",setActiveId:o,setTabs:t,tabs:d}},"sn"),Pe=s(l=>l.activeId===null&&l.sql.trim()!=="","De"),an=s((l,e)=>[...l,e].slice(-ye),"an"),cn=s((l,e,t)=>{let n=l.findIndex(a=>a.id===e);if(n===-1)return{activeId:l[0]?.id??"",tabs:[...l]};let o=l.filter(a=>a.id!==e);if(o.length===0){let a=t();return{activeId:a.id,tabs:[a]}}return{activeId:o[Math.min(n,o.length-1)].id,tabs:o}},"cn"),dn=s((l,e)=>{let t=l.filter(n=>n.id===e);return t.length===0?{activeId:l[0]?.id??"",tabs:[...l]}:{activeId:e,tabs:t}},"dn"),un=s((l,e,t)=>{let n=l.findIndex(a=>a.id===e);if(n===-1)return{activeId:t,tabs:[...l]};let o=l.slice(0,n+1);return{activeId:o.some(a=>a.id===t)?t:e,tabs:o}},"un"),mn=s(l=>{let e=l();return{activeId:e.id,tabs:[e]}},"mn"),pn=s((l,e,t)=>{if(l==="others")return e.filter(n=>n.id!==t);if(l==="right"){let n=e.findIndex(o=>o.id===t);return n===-1?[]:e.slice(n+1)}return[...e]},"pn"),bn=s((l,e)=>l.trim()===""?e:(l.split(`
|
|
3
3
|
`)[0]??l).slice(0,24),"fn"),hn=s(l=>{let e=(0,Y.c)(14),{initial:t,onCancel:n,onCommit:o,placeholder:a,testId:d}=l,p=K(),c=gn,m;e[0]!==o?(m=s(y=>{o(y.currentTarget.value.trim())},"u"),e[0]=o,e[1]=m):m=e[1];let k=m,g;e[2]!==n||e[3]!==o?(g=s(y=>{y.key==="Enter"?o(y.currentTarget.value.trim()):y.key==="Escape"&&n()},"x"),e[2]=n,e[3]=o,e[4]=g):g=e[4];let x=g,b;e[5]!==p?(b=p("Tab title"),e[5]=p,e[6]=b):b=e[6];let u;return e[7]!==t||e[8]!==k||e[9]!==x||e[10]!==a||e[11]!==b||e[12]!==d?(u=(0,r.jsx)("input",{"aria-label":b,className:"w-40 rounded border border-ring bg-background px-1 py-0.5 text-xs outline-none","data-testid":d,defaultValue:t,onBlur:k,onKeyDown:x,placeholder:a,ref:c,type:"text"}),e[7]=t,e[8]=k,e[9]=x,e[10]=a,e[11]=b,e[12]=d,e[13]=u):u=e[13],u},"bn"),fn=s(l=>{let e=(0,Y.c)(29),{idBase:t,onDiscard:n,onKeep:o}=l,a=K(),d=`sql-tab-close-prompt-${t}`,p;e[0]!==a?(p=a("Discard?"),e[0]=a,e[1]=p):p=e[1];let c;e[2]!==p?(c=(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground",children:p}),e[2]=p,e[3]=c):c=e[3];let m;e[4]!==a?(m=a("Discard changes"),e[4]=a,e[5]=m):m=e[5];let k=`sql-tab-close-confirm-${t}`,g;e[6]!==a?(g=a("Discard changes"),e[6]=a,e[7]=g):g=e[7];let x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M5 13l4 4L19 7"})}),e[8]=x):x=e[8];let b;e[9]!==n||e[10]!==m||e[11]!==k||e[12]!==g?(b=(0,r.jsx)("button",{"aria-label":m,className:"flex size-5 items-center justify-center rounded text-destructive hover:bg-destructive/10","data-testid":k,onClick:n,title:g,type:"button",children:x}),e[9]=n,e[10]=m,e[11]=k,e[12]=g,e[13]=b):b=e[13];let u;e[14]!==a?(u=a("Keep editing"),e[14]=a,e[15]=u):u=e[15];let y=`sql-tab-close-cancel-${t}`,v;e[16]!==a?(v=a("Keep editing"),e[16]=a,e[17]=v):v=e[17];let N;e[18]===Symbol.for("react.memo_cache_sentinel")?(N=(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})}),e[18]=N):N=e[18];let f;e[19]!==o||e[20]!==y||e[21]!==v||e[22]!==u?(f=(0,r.jsx)("button",{"aria-label":u,className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent","data-testid":y,onClick:o,title:v,type:"button",children:N}),e[19]=o,e[20]=y,e[21]=v,e[22]=u,e[23]=f):f=e[23];let C;return e[24]!==d||e[25]!==f||e[26]!==c||e[27]!==b?(C=(0,r.jsxs)("span",{className:"flex shrink-0 items-center gap-1","data-testid":d,role:"group",children:[c,b,f]}),e[24]=d,e[25]=f,e[26]=c,e[27]=b,e[28]=C):C=e[28],C},"hn"),xn=s(l=>{let e=(0,Y.c)(47),{active:t,canClose:n,onClose:o,onMenu:a,onRename:d,onSelect:p,tab:c}=l,m=K(),[k,g]=(0,E.useState)(!1),[x,b]=(0,E.useState)(!1),u;e[0]!==a||e[1]!==c.id?(u=s(F=>{a(c.id,F)},"d"),e[0]=a,e[1]=c.id,e[2]=u):u=e[2];let y=u,v;e[3]!==p||e[4]!==c.id?(v=s(()=>{p(c.id)},"g"),e[3]=p,e[4]=c.id,e[5]=v):v=e[5];let N=v,f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=s(()=>{g(!0)},"b"),e[6]=f):f=e[6];let C=f,q;e[7]!==o||e[8]!==c?(q=s(F=>{F.stopPropagation(),Pe(c)?b(!0):o(c.id)},"q"),e[7]=o,e[8]=c,e[9]=q):q=e[9];let L=q,S;e[10]!==o||e[11]!==c.id?(S=s(F=>{F.stopPropagation(),b(!1),o(c.id)},"S"),e[10]=o,e[11]=c.id,e[12]=S):S=e[12];let M=S,O;e[13]===Symbol.for("react.memo_cache_sentinel")?(O=s(F=>{F.stopPropagation(),b(!1)},"L"),e[13]=O):O=e[13];let _=O,A;e[14]!==d||e[15]!==c.id?(A=s(F=>{d(c.id,F),g(!1)},"M"),e[14]=d,e[15]=c.id,e[16]=A):A=e[16];let W=A,$;e[17]===Symbol.for("react.memo_cache_sentinel")?($=s(()=>{g(!1)},"z"),e[17]=$):$=e[17];let P=$,H;e[18]!==c.name?(H=c.name.trim(),e[18]=c.name,e[19]=H):H=e[19];let z=H,R;e[20]!==m||e[21]!==c.sql?(R=bn(c.sql,m("Untitled")),e[20]=m,e[21]=c.sql,e[22]=R):R=e[22];let D=R,B=t?"bg-background text-foreground":"bg-muted/40 text-muted-foreground hover:text-foreground",j;e[23]!==B?(j=te("group/tab flex shrink-0 items-center gap-1 border-e border-border ps-3 pe-1.5 text-xs",B),e[23]=B,e[24]=j):j=e[24];let I=`sql-tab-${c.id}`,T;e[25]!==t||e[26]!==W||e[27]!==z||e[28]!==D||e[29]!==k||e[30]!==N||e[31]!==m||e[32]!==c.id?(T=k?(0,r.jsx)(hn,{initial:z,onCancel:P,onCommit:W,placeholder:D,testId:`sql-tab-rename-${c.id}`}):(0,r.jsx)("button",{"aria-pressed":t,className:"max-w-40 truncate py-1.5 outline-none","data-testid":`sql-tab-select-${c.id}`,onClick:N,onDoubleClick:C,title:m("Double-click to rename"),type:"button",children:z===""?D:z}),e[25]=t,e[26]=W,e[27]=z,e[28]=D,e[29]=k,e[30]=N,e[31]=m,e[32]=c.id,e[33]=T):T=e[33];let J;e[34]!==n||e[35]!==M||e[36]!==x||e[37]!==L||e[38]!==m||e[39]!==c.id?(J=n&&(x?(0,r.jsx)(fn,{idBase:c.id,onDiscard:M,onKeep:_}):(0,r.jsx)("button",{"aria-label":m("Close tab"),className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive","data-testid":`sql-tab-close-${c.id}`,onClick:L,title:m("Close tab"),type:"button",children:(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})})})),e[34]=n,e[35]=M,e[36]=x,e[37]=L,e[38]=m,e[39]=c.id,e[40]=J):J=e[40];let V;return e[41]!==y||e[42]!==j||e[43]!==I||e[44]!==T||e[45]!==J?(V=(0,r.jsxs)("div",{className:j,"data-testid":I,onContextMenu:y,children:[T,J]}),e[41]=y,e[42]=j,e[43]=I,e[44]=T,e[45]=J,e[46]=V):V=e[46],V},"xn");function gn(l){l?.focus(),l?.select()}s(gn,"gn");var vn=ne(le.runSql),yn="lunora-studio-sql-queries",Nn="lunora-studio-sql-history",kn="lunora-studio-sql-split-view",wn=25,qn={minWidth:"2.75rem",paddingInline:"0.5rem"},ve={error:null,pane:"results",result:null},Cn=s(l=>{let e=(0,Y.c)(16),{result:t}=l;if(t.columns.length===0){let c=t.rowCount===0?"0 rows":"",m;return e[0]!==c?(m=(0,r.jsx)("p",{className:"p-4 text-sm text-muted-foreground",children:c}),e[0]=c,e[1]=m):m=e[1],m}let n;e[2]!==t.columns?(n=t.columns.map(Sn),e[2]=t.columns,e[3]=n):n=e[3];let o;e[4]!==n?(o=(0,r.jsx)(Te,{className:"sticky top-0 z-10 bg-muted",children:(0,r.jsx)(xe,{children:n})}),e[4]=n,e[5]=o):o=e[5];let a;if(e[6]!==t.columns||e[7]!==t.rows){let c;e[9]!==t.columns?(c=s((m,k)=>(0,r.jsx)(xe,{"data-testid":"sql-row",children:t.columns.map(g=>(0,r.jsx)(Me,{className:"max-w-md truncate font-mono text-xs",children:(0,r.jsx)(_e,{value:m[g]})},g))},k),"i"),e[9]=t.columns,e[10]=c):c=e[10],a=t.rows.map(c),e[6]=t.columns,e[7]=t.rows,e[8]=a}else a=e[8];let d;e[11]!==a?(d=(0,r.jsx)(Oe,{children:a}),e[11]=a,e[12]=d):d=e[12];let p;return e[13]!==o||e[14]!==d?(p=(0,r.jsxs)(Re,{"data-testid":"sql-rows",children:[o,d]}),e[13]=o,e[14]=d,e[15]=p):p=e[15],p},"Cn"),Bn=s(({initialShardKey:l})=>{let e=be(),t=K(),[n,o]=oe(yn),[a,d]=oe(Nn),[p,c]=(0,E.useState)(""),m=s(()=>Q(Fe[0]?.sql??""),"u"),{activeId:k,setActiveId:g,setTabs:x,tabs:b}=sn(m),[u,y]=(0,E.useState)({}),[v,N]=(0,E.useState)(l??""),[f,C]=(0,E.useState)(!1),[q,L]=he(kn,!1),[S,M]=(0,E.useState)(null),[O,_]=(0,E.useState)(null),A=(0,E.useRef)(null),W=(0,E.useRef)(null),$=(0,E.useRef)(null),P=(0,E.useId)(),{probe:H,schema:z}=en(v),R=b.find(i=>i.id===k)??b[0]??Q(),D=R.sql,{activeId:B}=R,j=u[R.id]??ve,{error:I,result:T}=j,J=j.pane,V=s(i=>{x(h=>h.map(w=>w.id===R.id?{...w,...i}:w))},"G"),F=s(i=>{y(h=>{let w=h[R.id]??ve;return{...h,[R.id]:{error:i.error,pane:i.pane??w.pane,result:i.result}}})},"F"),ke=s(i=>{y(h=>{let w=h[R.id]??ve;return{...h,[R.id]:{...w,pane:i}}})},"ve"),ie=s(i=>{V({sql:i}),B!==null&&o(h=>h.map(w=>w.id===B?{...w,sql:i}:w))},"re"),Je=Ut(z,W,ie),{close:ae,commit:we,move:ce,refresh:Z,state:G}=Je,Ue=s(i=>{ce(i-(G?.active??0)),we()},"_e");(0,E.useEffect)(()=>{let i=W.current;i!==null&&i===document.activeElement&&Z(i.value,i.selectionStart)},[Z,z]);let Ye=s(i=>{d(h=>h[0]?.sql===i?h:[{at:Date.now(),sql:i},...h.filter(w=>w.sql!==i)].slice(0,wn))},"Ae"),de=s(async i=>{if(D.trim()==="")return;C(!0);let h=i==="explain"?`EXPLAIN QUERY PLAN ${D}`:D;try{let w=await e.query(vn,{sql:h},re(v));F({error:null,pane:i,result:w}),Ie(v),Ye(h)}catch(w){F({error:Se(w),pane:i,result:null})}finally{C(!1)}},"se"),Ke=s(()=>{X(de("results"))},"ze"),Ge=s(i=>{let{selectionStart:h,value:w}=i.target;ie(w);for(let U of tn(w))H(U);Z(w,h)},"je"),Ve=s(i=>{let h=i.currentTarget;Z(h.value,h.selectionStart)},"Be"),Xe=s(i=>{if(G!==null){if(i.key==="ArrowDown"){i.preventDefault(),ce(1);return}if(i.key==="ArrowUp"){i.preventDefault(),ce(-1);return}if(i.key==="Escape"){i.preventDefault(),ae();return}if((i.key==="Enter"||i.key==="Tab")&&!i.metaKey&&!i.ctrlKey&&we()){i.preventDefault();return}}(i.metaKey||i.ctrlKey)&&i.key==="Enter"&&(i.preventDefault(),X(de(J)))},"We"),Qe=s(()=>{requestAnimationFrame(()=>{ae()})},"Fe"),Ze=s(i=>{A.current!==null&&(A.current.scrollTop=i.currentTarget.scrollTop)},"He"),ee=s((i,h)=>{x(w=>w.map(U=>U.id===R.id?{...U,activeId:h,sql:i}:U)),F({error:null,result:null})},"te"),et=s(()=>{let i={id:fe("q"),name:t("Untitled query"),sql:""};o(h=>[i,...h]),ee("",i.id)},"Pe"),tt=s(i=>{let h=n.find(w=>w.id===i);h!==void 0&&(ee(h.sql,i),$.current?.querySelector(`[data-testid="sql-query-${i}"]`)?.scrollIntoView({block:"nearest"}))},"Ue"),nt=s(i=>{o(h=>h.filter(w=>w.id!==i)),x(h=>h.map(w=>w.activeId===i?{...w,activeId:null}:w))},"Je"),rt=s(i=>{ee(i.currentTarget.dataset.sql??"",null)},"Ke"),lt=s(i=>{ee(i.currentTarget.dataset.sql??"",null)},"Ye"),ot=s(()=>{d([])},"Ve"),st=s(()=>{ie(At(D))},"Ge"),it=s(()=>{if(b.length>=ye)return;let i=Q();x(h=>an(h,i)),g(i.id)},"Qe"),qe=s(i=>{M(null),_(null),x(i.tabs),g(i.activeId);let h=new Set(i.tabs.map(w=>w.id));y(w=>Object.fromEntries(Object.entries(w).filter(([U])=>h.has(U))))},"Ne"),at=s(i=>{qe(cn(b,i,Q))},"Xe"),Ce=s((i,h)=>{qe(i==="others"?dn(b,h):i==="right"?un(b,h,k):mn(Q))},"ke"),ue=s(i=>{S!==null&&(pn(i,b,S.id).some(h=>Pe(h))?_(i):Ce(i,S.id))},"ie"),ct=s((i,h)=>{h.preventDefault(),_(null),M({id:i,x:h.clientX,y:h.clientY})},"Ze"),dt=s(()=>{M(null),_(null)},"et"),ut=s(i=>{i.preventDefault(),M(null),_(null)},"tt"),mt=s(()=>{ue("others")},"nt"),pt=s(()=>{ue("right")},"rt"),bt=s(()=>{ue("all")},"lt"),ht=s(()=>{S!==null&&O!==null&&Ce(O,S.id),_(null)},"ot"),ft=s(()=>{_(null)},"st"),xt=S===null?void 0:{left:S.x,top:S.y},gt=s(i=>{ae(),g(i)},"at"),vt=s((i,h)=>{x(w=>w.map(U=>U.id===i?{...U,name:h}:U))},"ct"),yt=s(()=>{ke("results")},"dt"),Nt=s(()=>{X(de("explain"))},"ut"),kt=s(()=>{ke("chart")},"mt"),wt=s(()=>{L(!q)},"pt"),qt=D.split(`
|
|
4
4
|
`).length,Ct=s(i=>{c(i.target.value)},"bt"),me=s(i=>`border-b-2 px-3 py-2 text-sm outline-none transition-colors ${i?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,"ae"),St=q?"flex min-h-0 flex-1 flex-row":"flex min-h-0 flex-1 flex-col",It=q?"flex w-2/5 min-h-0 min-w-0 shrink-0 flex-col border-s border-border":"flex h-2/5 min-h-0 shrink-0 flex-col border-t border-border";return(0,r.jsxs)("div",{className:"flex h-full min-w-0","data-testid":"lunora-sql-editor",children:[(0,r.jsx)(Xt,{activeId:B,history:a,listRef:$,onClearHistory:ot,onDelete:nt,onLoadHistory:lt,onLoadTemplate:rt,onNew:et,onSearchChange:Ct,onSelect:tt,queries:n,search:p}),(0,r.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col",children:[(0,r.jsxs)("div",{className:"flex shrink-0 items-stretch overflow-x-auto border-b border-border bg-muted/30","data-testid":"sql-tab-strip",role:"tablist",children:[b.map(i=>(0,r.jsx)(xn,{active:i.id===R.id,canClose:b.length>1,onClose:at,onMenu:ct,onRename:vt,onSelect:gt,tab:i},i.id)),(0,r.jsx)("button",{"aria-label":t("New tab"),className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-add",disabled:b.length>=ye,onClick:it,title:t("New tab"),type:"button",children:(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M12 5v14M5 12h14"})})})]}),S!==null&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 z-40","data-testid":"sql-tab-menu-backdrop",onClick:dt,onContextMenu:ut,role:"presentation"}),(0,r.jsx)("div",{className:"fixed z-50 min-w-44 rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-tab-menu",role:"menu",style:xt,children:O===null?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-menu-close-others",disabled:b.length<=1,onClick:mt,role:"menuitem",type:"button",children:t("Close other tabs")}),(0,r.jsx)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-menu-close-right",disabled:b.findIndex(i=>i.id===S.id)>=b.length-1,onClick:pt,role:"menuitem",type:"button",children:t("Close tabs to the right")}),(0,r.jsx)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-close-all",onClick:bt,role:"menuitem",type:"button",children:t("Close all tabs")})]}):(0,r.jsxs)("div",{className:"px-3 py-1.5","data-testid":"sql-tab-menu-confirm",children:[(0,r.jsx)("p",{className:"pb-1.5 text-xs text-muted-foreground",children:t("Discard unsaved tabs?")}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("button",{className:"rounded px-2 py-1 text-xs font-medium text-destructive outline-none hover:bg-destructive/10 focus-visible:bg-destructive/10","data-testid":"sql-tab-menu-confirm-discard",onClick:ht,type:"button",children:t("Discard")}),(0,r.jsx)("button",{className:"rounded px-2 py-1 text-xs text-muted-foreground outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-confirm-cancel",onClick:ft,type:"button",children:t("Cancel")})]})]})})]}),(0,r.jsxs)("div",{className:St,children:[(0,r.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1",children:[(0,r.jsx)("div",{"aria-hidden":"true",className:"shrink-0 select-none overflow-hidden border-e border-border bg-muted/30 py-3 text-end font-mono text-xs leading-5 text-muted-foreground/60",ref:A,style:qn,children:Array.from({length:qt},(i,h)=>(0,r.jsx)("div",{children:h+1},h))}),(0,r.jsxs)("div",{className:"relative min-w-0 flex-1",children:[(0,r.jsx)("textarea",{"aria-activedescendant":G===null?void 0:`${P}-opt-${G.active.toString()}`,"aria-autocomplete":"list","aria-controls":G===null?void 0:P,"aria-expanded":G!==null,"aria-label":t("SQL query"),className:"size-full resize-none bg-background p-3 font-mono text-xs leading-5 outline-none","data-testid":"sql-input",onBlur:Qe,onChange:Ge,onKeyDown:Xe,onScroll:Ze,onSelect:Ve,placeholder:"SELECT * FROM \u2026",ref:W,role:"combobox",spellCheck:!1,value:D}),(0,r.jsx)(Gt,{listboxId:P,onPick:Ue,state:G})]})]}),(0,r.jsxs)("div",{className:It,children:[(0,r.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pe-2",children:[(0,r.jsx)("button",{className:me(J==="results"),"data-testid":"sql-tab-results",onClick:yt,type:"button",children:t("Results")}),(0,r.jsx)("button",{className:me(J==="chart"),"data-testid":"sql-tab-chart",onClick:kt,type:"button",children:t("Chart")}),(0,r.jsx)("button",{className:me(J==="explain"),"data-testid":"sql-tab-explain",onClick:Nt,type:"button",children:t("Explain")}),(0,r.jsxs)("div",{className:"ms-auto flex items-center gap-2",children:[(0,r.jsx)("button",{"aria-label":t("Split editor and results"),"aria-pressed":q,className:`inline-flex items-center rounded-md border border-border px-2 py-1.5 outline-none transition-colors hover:bg-accent focus-visible:bg-accent ${q?"bg-accent text-foreground":"text-muted-foreground"}`,"data-testid":"sql-split-toggle",onClick:wt,title:t("Split editor and results"),type:"button",children:(0,r.jsxs)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:[(0,r.jsx)("rect",{height:"16",rx:"2",width:"18",x:"3",y:"4"}),(0,r.jsx)("path",{d:"M12 4v16"})]})}),T!==null&&T.columns.length>0&&(0,r.jsx)(Ae,{columns:T.columns,name:"query-result",rows:T.rows}),(0,r.jsx)("button",{className:"inline-flex items-center rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-format",disabled:f,onClick:st,type:"button",children:t("Format")}),(0,r.jsx)(Ee,{onChange:N,testId:"sql-shard-input",value:v}),(0,r.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-run",disabled:f,onClick:Ke,type:"button",children:[t(f?"Running\u2026":"Run"),(0,r.jsx)("kbd",{className:"rounded border border-primary-foreground/30 px-1 font-sans text-[10px]",children:"\u2318\u21B5"})]})]})]}),(0,r.jsxs)("div",{className:"min-h-0 flex-1 overflow-auto",children:[I!==null&&(0,r.jsx)(Le,{className:"m-3 font-mono text-xs",testId:"sql-error",variant:"destructive",children:I}),I===null&&T===null&&(0,r.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-empty",children:t("Click Run to execute your query.")}),I===null&&T!==null&&(0,r.jsxs)("div",{"data-testid":"sql-result",children:[J==="chart"?(0,r.jsx)(ze,{result:T}):(0,r.jsx)(Cn,{result:T}),(0,r.jsx)("p",{className:"border-t border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"sql-count",children:T.truncated?t("Showing the first {max} of {count} rows.",{count:T.rowCount,max:T.rows.length}):t("{count} rows",{count:T.rowCount})})]})]})]})]})]})]})},"Hn");function Sn(l){return(0,r.jsx)(De,{children:l},l)}s(Sn,"Sn");export{Bn as SqlEditorPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as v}from"./chunk-
|
|
1
|
+
import{a as v}from"./chunk-HK4OVYG3.js";import"./chunk-XXQUMVWH.js";import{b as $}from"./chunk-BMQJ4CAO.js";import{a as A,b as I,c as j,d as x,e as n,f as c}from"./chunk-MIQTKZAR.js";import{a as k,e as S}from"./chunk-UZERI5YC.js";import{b as y}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as R}from"./chunk-AADXUXZO.js";import"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as w}from"./chunk-XQCVZAGU.js";import{d as b}from"./chunk-4CGALXS3.js";import"./chunk-AADILRJW.js";import{a as f,e as N,g as E,h as _}from"./chunk-3XIESWL4.js";var T=N(E(),1);var r=N(_(),1);var D=f((e,t)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[t],"C"),C={delete:2,list:3,read:0,write:1},K=f(e=>[...e].toSorted((t,a)=>t.bucket.localeCompare(a.bucket)||C[t.on]-C[a.on]||(t.prefix??"").localeCompare(a.prefix??"")),"T"),W=f(()=>{let e=(0,T.c)(14),t=b(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let{data:l,error:i,errorSource:d}=$(R.storageRules,a),h=l!==void 0,m;if(e[1]!==l||e[2]!==i||e[3]!==d||e[4]!==h||e[5]!==t){let g=K(Array.isArray(l?.rules)?l.rules:[]),u;e[7]!==i||e[8]!==d?(u=i!==null&&(0,r.jsx)(v,{error:d,testId:"storage-rules-error"}),e[7]=i,e[8]=d,e[9]=u):u=e[9];let o;e[10]!==t?(o=t("Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only."),e[10]=t,e[11]=o):o=e[11];let p;e[12]!==o?(p=(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:o}),e[12]=o,e[13]=p):p=e[13],m=(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[u,p,h&&g.length===0?(0,r.jsx)(w,{description:t("No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix."),testId:"storage-rules-empty",title:t("No storage rules defined")}):(0,r.jsx)(k,{className:"overflow-hidden py-0",children:(0,r.jsx)(S,{className:"px-0",children:(0,r.jsxs)(A,{"data-testid":"storage-rules-table",children:[(0,r.jsx)(I,{children:(0,r.jsxs)(x,{children:[(0,r.jsx)(n,{children:t("Bucket")}),(0,r.jsx)(n,{children:t("Operation")}),(0,r.jsx)(n,{children:t("Key prefix")}),(0,r.jsx)(n,{children:t("Guarded by")})]})}),(0,r.jsx)(j,{children:g.map(s=>(0,r.jsxs)(x,{"data-testid":`storage-rule-${s.bucket}-${s.on}-${s.prefix??""}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:s.bucket}),(0,r.jsx)(c,{children:(0,r.jsx)(y,{variant:"secondary",children:D(t,s.on)})}),(0,r.jsx)(c,{className:"font-mono text-xs",children:s.prefix??(0,r.jsx)("span",{className:"text-muted-foreground",children:t("(whole bucket)")})}),(0,r.jsx)(c,{className:"font-mono text-xs text-muted-foreground",children:s.procedure})]},`${s.bucket}:${s.on}:${s.prefix??""}:${s.procedure}`))})]})})})]}),e[1]=l,e[2]=i,e[3]=d,e[4]=h,e[5]=t,e[6]=m}else m=e[6];return m},"U");export{W as StorageRulesPanel};
|