@lunora/studio 1.0.0-alpha.330 → 1.0.0-alpha.332
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +26 -12
- package/dist/index.d.ts +26 -12
- package/dist/index.mjs +1 -1
- package/dist/mount.mjs +1 -1
- package/dist/packem_chunks/AdvisorHealthPanel.mjs +1 -1
- package/dist/packem_chunks/ApiTab.mjs +1 -1
- package/dist/packem_chunks/AuditPanel.mjs +1 -1
- package/dist/packem_chunks/DeploymentHealthPanel.mjs +1 -1
- package/dist/packem_chunks/ExportImportPanel.mjs +6 -3
- package/dist/packem_chunks/FileBrowser.mjs +4 -4
- package/dist/packem_chunks/FunctionRunner.mjs +1 -1
- package/dist/packem_chunks/FunctionStatsPanel.mjs +1 -1
- package/dist/packem_chunks/HealthPanel.mjs +1 -1
- package/dist/packem_chunks/InsightsPanel.mjs +1 -1
- package/dist/packem_chunks/LogsPanel.mjs +1 -1
- package/dist/packem_chunks/MailPanel.mjs +1 -1
- package/dist/packem_chunks/MetricsPanel.mjs +1 -1
- package/dist/packem_chunks/NotificationsPanel.mjs +1 -1
- package/dist/packem_chunks/PitrPanel.mjs +1 -1
- package/dist/packem_chunks/SchemaViewer.mjs +1 -1
- package/dist/packem_chunks/SecurityAdvisorPanel.mjs +1 -1
- package/dist/packem_chunks/SettingsPanel.mjs +1 -1
- package/dist/packem_chunks/SqlEditorPanel.mjs +2 -2
- package/dist/packem_chunks/TableEditor.mjs +1 -1
- package/dist/packem_chunks/agents-panel.mjs +1 -1
- package/dist/packem_chunks/ai-usage-panel.mjs +1 -1
- package/dist/packem_chunks/analytics-panel.mjs +1 -1
- package/dist/packem_chunks/architecture-panel.mjs +1 -1
- package/dist/packem_chunks/auth-audit-panel.mjs +1 -1
- package/dist/packem_chunks/auth-config-panel.mjs +1 -1
- package/dist/packem_chunks/auth-sessions-panel.mjs +1 -1
- package/dist/packem_chunks/containers-panel.mjs +1 -1
- package/dist/packem_chunks/dashboards-panel.mjs +1 -1
- package/dist/packem_chunks/evals-panel.mjs +1 -1
- package/dist/packem_chunks/fanout-panel.mjs +1 -1
- package/dist/packem_chunks/flags-panel.mjs +1 -1
- package/dist/packem_chunks/issues-panel.mjs +1 -1
- package/dist/packem_chunks/kv-browser.mjs +1 -1
- package/dist/packem_chunks/log-drains-panel.mjs +1 -1
- package/dist/packem_chunks/migrations-route.mjs +1 -1
- package/dist/packem_chunks/organizations-panel.mjs +1 -1
- package/dist/packem_chunks/payments-panel.mjs +1 -1
- package/dist/packem_chunks/permissions-panel.mjs +1 -1
- package/dist/packem_chunks/privacy-requests-panel.mjs +1 -1
- package/dist/packem_chunks/queues-panel.mjs +1 -1
- package/dist/packem_chunks/reactors-panel.mjs +1 -1
- package/dist/packem_chunks/rls-panel.mjs +1 -1
- package/dist/packem_chunks/schedule-panel.mjs +1 -1
- package/dist/packem_chunks/storage-rules-panel.mjs +1 -1
- package/dist/packem_chunks/subscriptions-panel.mjs +1 -1
- package/dist/packem_chunks/sync-client-panel.mjs +1 -1
- package/dist/packem_chunks/traces-panel.mjs +1 -1
- package/dist/packem_chunks/users-panel.mjs +1 -1
- package/dist/packem_chunks/vector-browser.mjs +1 -1
- package/dist/packem_chunks/workflows-panel.mjs +1 -1
- package/dist/packem_shared/{ApiDocsPanel-6yZaaxch.mjs → ApiDocsPanel-Py7C4ibM.mjs} +1 -1
- package/dist/packem_shared/{ApiReferencePanel-mwEK_vL7.mjs → ApiReferencePanel-DlYVADAy.mjs} +1 -1
- package/dist/packem_shared/{CommandPalette-CcTVGQvw.mjs → CommandPalette-CM1hqAOD.mjs} +1 -1
- package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-DvhNw0BI.mjs +1 -0
- package/dist/packem_shared/{DataBrowser-B6xr6S3s.mjs → DataBrowser-DxlLv5x1.mjs} +2 -2
- package/dist/packem_shared/GlobalDataBrowser-TFTQpSVj.mjs +1 -0
- package/dist/packem_shared/{HomePanel-DBUgY2yE.mjs → HomePanel-BVz2sDQ4.mjs} +1 -1
- package/dist/packem_shared/{MigrationsPanel-_H327LDl.mjs → MigrationsPanel-fUyhbt0w.mjs} +1 -1
- package/dist/packem_shared/{OpenRpcReferencePanel-DJg4AbuZ.mjs → OpenRpcReferencePanel-CPIr-u-J.mjs} +1 -1
- package/dist/packem_shared/ScheduledJobs-zSeU_6cN.mjs +1 -0
- package/dist/packem_shared/{Studio-s4EbmwaL.mjs → Studio-CNqMkRmB.mjs} +1 -1
- package/dist/packem_shared/{StudioApp-D1e2uc7_.mjs → StudioApp-BG3kyQ-I.mjs} +1 -1
- package/dist/packem_shared/{advisor-view-kg9uZT7H.mjs → advisor-view-CXiPdw4B.mjs} +1 -1
- package/dist/packem_shared/{data-grid-XIuWrWDy.mjs → data-grid-BHTuvSI7.mjs} +1 -1
- package/dist/packem_shared/{diagram-export-panel-DrYRni_b.mjs → diagram-export-panel-BMLzao0Y.mjs} +1 -1
- package/dist/packem_shared/{error-alert-Dr4RMEID.mjs → error-alert-D-ftqyo-.mjs} +1 -1
- package/dist/packem_shared/{grid-features-6mTvrzgT.mjs → grid-features-CIdZ8Dqo.mjs} +2 -2
- package/dist/packem_shared/{home-panel-CKbpgpz9.mjs → home-panel-CF-MfsnH.mjs} +1 -1
- package/dist/packem_shared/internal-BXEjuLPN.mjs +2 -0
- package/dist/packem_shared/{log-line-DP0b3YT5.mjs → log-line-BWDt_F56.mjs} +1 -1
- package/dist/packem_shared/{recording-client-BbX9ql7w.mjs → recording-client-CFBkH4uZ.mjs} +1 -1
- package/dist/packem_shared/{reference-view-DNdYDPow.mjs → reference-view-BrsL8UGn.mjs} +3 -3
- package/dist/packem_shared/{schema-diagram-DKBYRWsL.mjs → schema-diagram-LRfchcoA.mjs} +1 -1
- package/dist/packem_shared/{sql-result-table-B7g48CHO.mjs → sql-result-table-COsfUSGc.mjs} +1 -1
- package/dist/packem_shared/{studio-BTM7dITm.mjs → studio-BcHsk7mT.mjs} +1 -1
- package/dist/packem_shared/table-list-sidebar-DwqtHSHU.mjs +1 -0
- package/dist/packem_shared/{use-admin-query-B2jU5P5u.mjs → use-admin-query-I1uILsUP.mjs} +1 -1
- package/dist/packem_shared/{use-admin-spec-CISwmdXM.mjs → use-admin-spec-BdNLZbTO.mjs} +1 -1
- package/dist/packem_shared/{use-async-submit-CgvRHgaD.mjs → use-async-submit-2eBBD0-m.mjs} +1 -1
- package/dist/packem_shared/{use-auth-config-B9w5-1-p.mjs → use-auth-config-DQ8tNyBh.mjs} +1 -1
- package/dist/packem_shared/{use-open-trace-CUyoDXjN.mjs → use-open-trace-B_0LbTD7.mjs} +1 -1
- package/dist/packem_shared/{use-sql-assistant-CK6G1ycr.mjs → use-sql-assistant-DetnUyFf.mjs} +1 -1
- package/dist/standalone/chunk-22MSJQDH.js +1 -0
- package/dist/standalone/chunk-2GYGUDJS.js +2 -0
- package/dist/standalone/chunk-34HRTSIP.js +1 -0
- package/dist/standalone/{chunk-A4R7GZQS.js → chunk-3O4QTTSY.js} +3 -3
- package/dist/standalone/{chunk-X472RKFD.js → chunk-4CGBMYO3.js} +3 -3
- package/dist/standalone/chunk-4DPZVEBK.js +1 -0
- package/dist/standalone/{chunk-NA7GP6EE.js → chunk-4NSXTCPY.js} +1 -1
- package/dist/standalone/{chunk-PLVFYL6L.js → chunk-4ZPDCXIA.js} +1 -1
- package/dist/standalone/chunk-5QXC7TAH.js +1 -0
- package/dist/standalone/{chunk-C5KBRXQG.js → chunk-5XSZGYSM.js} +1 -1
- package/dist/standalone/{chunk-3RSD3XAG.js → chunk-5ZCMUHYK.js} +1 -1
- package/dist/standalone/chunk-6UKEJNM5.js +1 -0
- package/dist/standalone/{chunk-5OMZCVRF.js → chunk-74IYYDDI.js} +9 -9
- package/dist/standalone/{chunk-D6ZXOSCM.js → chunk-7FTJLXZH.js} +1 -1
- package/dist/standalone/{chunk-2EYOYWS2.js → chunk-7Q256NLI.js} +1 -1
- package/dist/standalone/{chunk-DQSV2OFA.js → chunk-AH56E26M.js} +1 -1
- package/dist/standalone/{chunk-BPBEVNUM.js → chunk-B3SX5SBI.js} +2 -2
- package/dist/standalone/{chunk-D3HPOVEQ.js → chunk-B475OGG2.js} +1 -1
- package/dist/standalone/{chunk-QBTZMN5E.js → chunk-BDAZK3QX.js} +1 -1
- package/dist/standalone/{chunk-KRVD6WPH.js → chunk-BOGUQHYU.js} +1 -1
- package/dist/standalone/{chunk-DS2DTZFS.js → chunk-CHF23IX6.js} +3 -3
- package/dist/standalone/{chunk-OU56VN3R.js → chunk-CLXX5RVY.js} +1 -1
- package/dist/standalone/{chunk-G3NIGELJ.js → chunk-E75V5AEB.js} +1 -1
- package/dist/standalone/{chunk-2PNG3QHQ.js → chunk-EFXC3EHZ.js} +1 -1
- package/dist/standalone/{chunk-S63L3TCR.js → chunk-ENRGUWYC.js} +1 -1
- package/dist/standalone/{chunk-D746I7ZX.js → chunk-EWMBX5N2.js} +1 -1
- package/dist/standalone/{chunk-ULW7I6FO.js → chunk-F4HMMGVL.js} +1 -1
- package/dist/standalone/{chunk-V3RAWH63.js → chunk-FZJY5QLO.js} +1 -1
- package/dist/standalone/{chunk-K7OJ77CA.js → chunk-G3ZNPPY3.js} +1 -1
- package/dist/standalone/{chunk-X2YHVCMH.js → chunk-GUDC24NJ.js} +1 -1
- package/dist/standalone/{chunk-FCVKROK5.js → chunk-HIJGQX6F.js} +1 -1
- package/dist/standalone/chunk-HQPW3EZF.js +6 -0
- package/dist/standalone/chunk-HXO6YGKL.js +1 -0
- package/dist/standalone/{chunk-AQFI2GWT.js → chunk-IKT6EYHN.js} +1 -1
- package/dist/standalone/{chunk-MRFJSQBZ.js → chunk-IVZT3XO6.js} +1 -1
- package/dist/standalone/chunk-J2OLAMJR.js +1 -0
- package/dist/standalone/{chunk-I5RZUA4J.js → chunk-J4BVPEXN.js} +1 -1
- package/dist/standalone/{chunk-ZBRLJQ46.js → chunk-JKOBTLQU.js} +2 -2
- package/dist/standalone/{chunk-CVPVFONU.js → chunk-JYPEPARL.js} +1 -1
- package/dist/standalone/{chunk-ZQ4C2DMJ.js → chunk-K2EHRNYW.js} +1 -1
- package/dist/standalone/{chunk-SZIEPXZM.js → chunk-K3ST3XOT.js} +1 -1
- package/dist/standalone/{chunk-PDF22AMX.js → chunk-K73JDHTM.js} +1 -1
- package/dist/standalone/{chunk-P6UD4I65.js → chunk-KDF7XOVW.js} +1 -1
- package/dist/standalone/{chunk-CYWRJGWD.js → chunk-LVCMJJQO.js} +1 -1
- package/dist/standalone/{chunk-I23ULEUU.js → chunk-LXCVA5SP.js} +1 -1
- package/dist/standalone/{chunk-WMPXMPVF.js → chunk-M45NNDDU.js} +1 -1
- package/dist/standalone/{chunk-HYKN42SO.js → chunk-MC44447W.js} +1 -1
- package/dist/standalone/{chunk-DXYCOA4Y.js → chunk-NBYAGXMZ.js} +1 -1
- package/dist/standalone/{chunk-WS7WNXF3.js → chunk-NRAAYZ4C.js} +3 -3
- package/dist/standalone/{chunk-TM5C7YPO.js → chunk-NSNRU3CH.js} +1 -1
- package/dist/standalone/{chunk-VASJTDMU.js → chunk-PSMQQV6S.js} +1 -1
- package/dist/standalone/chunk-QMECH2OK.js +1 -0
- package/dist/standalone/{chunk-PH4VNMUO.js → chunk-QMENQICE.js} +1 -1
- package/dist/standalone/{chunk-QJACMRR5.js → chunk-RC6CRS3F.js} +1 -1
- package/dist/standalone/{chunk-LXBSXLLK.js → chunk-RFRFJ6GK.js} +1 -1
- package/dist/standalone/chunk-RNVXXJBN.js +1 -0
- package/dist/standalone/{chunk-YGNPACVK.js → chunk-SHY25BCU.js} +1 -1
- package/dist/standalone/{chunk-J5NS6XO4.js → chunk-T6XTWQC2.js} +1 -1
- package/dist/standalone/{chunk-AFX6YYGP.js → chunk-TBEEPT5P.js} +1 -1
- package/dist/standalone/{chunk-74WMPCOL.js → chunk-TRUA26Q4.js} +1 -1
- package/dist/standalone/{chunk-Y57U7WES.js → chunk-U2ACS5ID.js} +1 -1
- package/dist/standalone/{chunk-2W67FQCF.js → chunk-VDC6JP4A.js} +1 -1
- package/dist/standalone/chunk-VESZYIB4.js +1 -0
- package/dist/standalone/{chunk-MCHTZFX6.js → chunk-VFAP6A6G.js} +1 -1
- package/dist/standalone/{chunk-LSEISHAB.js → chunk-VNBONC2Q.js} +1 -1
- package/dist/standalone/{chunk-OMN44W6V.js → chunk-VQRCJJXS.js} +1 -1
- package/dist/standalone/{chunk-DVX5J34S.js → chunk-W4CQMJH3.js} +1 -1
- package/dist/standalone/{chunk-6XIDYONR.js → chunk-WAJZ4QKG.js} +1 -1
- package/dist/standalone/{chunk-3CBQDJ4S.js → chunk-WDGITBC6.js} +1 -1
- package/dist/standalone/{chunk-2G3B5PAO.js → chunk-WVWCUB4S.js} +1 -1
- package/dist/standalone/{chunk-GPNP4QSZ.js → chunk-X4MAMXRE.js} +1 -1
- package/dist/standalone/chunk-X6XAMP4E.js +7 -0
- package/dist/standalone/{chunk-6B7YJY6X.js → chunk-XDWPHAV6.js} +1 -1
- package/dist/standalone/{chunk-2QXJTBVX.js → chunk-XKISL2CG.js} +1 -1
- package/dist/standalone/chunk-XVE6WFB4.js +1 -0
- package/dist/standalone/chunk-YCQP3TYK.js +5 -0
- package/dist/standalone/chunk-ZBHXISOD.js +1 -0
- package/dist/standalone/{chunk-FBGCQYRO.js → chunk-ZFW3QEVE.js} +1 -1
- package/dist/standalone/{chunk-TSNDFT5D.js → chunk-ZVXBXVS3.js} +1 -1
- package/dist/standalone/{chunk-FGVGIVB6.js → chunk-ZWLIXZWR.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/dist/styles.css +1 -1
- package/package.json +5 -5
- package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.mjs +0 -1
- package/dist/packem_shared/GlobalDataBrowser-DlBYI85g.mjs +0 -1
- package/dist/packem_shared/ScheduledJobs-CscRWLW-.mjs +0 -1
- package/dist/packem_shared/internal-S7SDbbPa.mjs +0 -2
- package/dist/packem_shared/table-list-sidebar-DcvrtBkE.mjs +0 -1
- package/dist/standalone/chunk-3ADTLIRI.js +0 -1
- package/dist/standalone/chunk-5LEVE36K.js +0 -1
- package/dist/standalone/chunk-7XYNQ3JS.js +0 -1
- package/dist/standalone/chunk-AJSSEAMP.js +0 -1
- package/dist/standalone/chunk-DSXEICMD.js +0 -1
- package/dist/standalone/chunk-GV2QZP42.js +0 -2
- package/dist/standalone/chunk-GV6O3NPO.js +0 -1
- package/dist/standalone/chunk-GXYXVKOM.js +0 -1
- package/dist/standalone/chunk-HHT7X6VO.js +0 -1
- package/dist/standalone/chunk-HKQSHNFB.js +0 -1
- package/dist/standalone/chunk-JQXA2OYK.js +0 -1
- package/dist/standalone/chunk-KXYSX2SV.js +0 -1
- package/dist/standalone/chunk-NXVOCK3P.js +0 -5
- package/dist/standalone/chunk-PAAYRW3Q.js +0 -9
- package/dist/standalone/chunk-YPY2NU35.js +0 -3
- package/dist/standalone/chunk-YQQTRX55.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as ct,b as dt}from"./chunk-
|
|
1
|
+
import{a as ct,b as dt}from"./chunk-F4HMMGVL.js";import{a as it}from"./chunk-WDGITBC6.js";import{d as at}from"./chunk-4CGBMYO3.js";import"./chunk-NQZALRU3.js";import"./chunk-OPM7ESDV.js";import"./chunk-Y3AYVFTK.js";import"./chunk-QJLHH3ET.js";import"./chunk-OYCUPD3Q.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import{a as lt}from"./chunk-IWZ7GVQO.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import"./chunk-W4CQMJH3.js";import"./chunk-AUGKHAMQ.js";import"./chunk-WJRYEML4.js";import"./chunk-LXCVA5SP.js";import{a as rt}from"./chunk-7Q256NLI.js";import{b as ot}from"./chunk-ZKJS6EBE.js";import{c as nt,d as Ne,e as De,f as Ae,g as Ke}from"./chunk-RGMVGZV4.js";import{i as Qe}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import"./chunk-BOMPSVRC.js";import{a as st}from"./chunk-NCPW7WHO.js";import{a as ke}from"./chunk-4ZEL6BYL.js";import"./chunk-ZBHXISOD.js";import{l as _e}from"./chunk-X6XAMP4E.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import"./chunk-HCTJKP5J.js";import{d as ae,f as Se,g as Ce,h as tt,q as me}from"./chunk-74IYYDDI.js";import{a,d as Fe,e as Lt,f as Rt,g as _t,i as ue}from"./chunk-I26MS5PJ.js";var Z=Fe(Rt(),1);var B=Fe(Lt(),1);var u=Fe(_t(),1);var qe=class{static{a(this,"Diff")}diff(e,n,t={}){let r;typeof t=="function"?(r=t,t={}):"callback"in t&&(r=t.callback);let o=this.castInput(e,t),l=this.castInput(n,t),i=this.removeEmpty(this.tokenize(o,t)),c=this.removeEmpty(this.tokenize(l,t));return this.diffWithOptionsObj(i,c,t,r)}diffWithOptionsObj(e,n,t,r){var o;let l=a(p=>{if(p=this.postProcess(p,t),r){setTimeout(function(){r(p)},0);return}else return p},"done"),i=n.length,c=e.length,d=1,m=i+c;t.maxEditLength!=null&&(m=Math.min(m,t.maxEditLength));let x=(o=t.timeout)!==null&&o!==void 0?o:1/0,h=Date.now()+x,v=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(v[0],n,e,0,t);if(v[0].oldPos+1>=c&&f+1>=i)return l(this.buildValues(v[0].lastComponent,n,e));let N=-1/0,b=1/0,w=a(()=>{for(let p=Math.max(N,-d);p<=Math.min(b,d);p+=2){let S,y=v[p-1],g=v[p+1];y&&(v[p-1]=void 0);let C=!1;if(g){let q=g.oldPos-p;C=g&&0<=q&&q<i}let k=y&&y.oldPos+1<c;if(!C&&!k){v[p]=void 0;continue}if(!k||C&&y.oldPos<g.oldPos?S=this.addToPath(g,!0,!1,0,t):S=this.addToPath(y,!1,!0,1,t),f=this.extractCommon(S,n,e,p,t),S.oldPos+1>=c&&f+1>=i)return l(this.buildValues(S.lastComponent,n,e))||!0;v[p]=S,S.oldPos+1>=c&&(b=Math.min(b,p-1)),f+1>=i&&(N=Math.max(N,p+1))}d++},"execEditLength");if(r)a(function p(){setTimeout(function(){if(d>m||Date.now()>h)return r(void 0);w()||p()},0)},"exec")();else for(;d<=m&&Date.now()<=h;){let p=w();if(p)return p}}addToPath(e,n,t,r,o){let l=e.lastComponent;return l&&!o.oneChangePerToken&&l.added===n&&l.removed===t?{oldPos:e.oldPos+r,lastComponent:{count:l.count+1,added:n,removed:t,previousComponent:l.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:n,removed:t,previousComponent:l}}}extractCommon(e,n,t,r,o){let l=n.length,i=t.length,c=e.oldPos,d=c-r,m=0;for(;d+1<l&&c+1<i&&this.equals(t[c+1],n[d+1],o);)d++,c++,m++,o.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return m&&!o.oneChangePerToken&&(e.lastComponent={count:m,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=c,d}equals(e,n,t){return t.comparator?t.comparator(e,n):e===n||!!t.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){let n=[];for(let t=0;t<e.length;t++)e[t]&&n.push(e[t]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,t){let r=[],o;for(;e;)r.push(e),o=e.previousComponent,delete e.previousComponent,e=o;r.reverse();let l=r.length,i=0,c=0,d=0;for(;i<l;i++){let m=r[i];if(m.removed)m.value=this.join(t.slice(d,d+m.count)),d+=m.count;else{if(!m.added&&this.useLongestToken){let x=n.slice(c,c+m.count);x=x.map(function(h,v){let f=t[d+v];return f.length>h.length?f:h}),m.value=this.join(x)}else m.value=this.join(n.slice(c,c+m.count));c+=m.count,m.added||(d+=m.count)}}return r}};var Ue=class extends qe{static{a(this,"LineDiff")}constructor(){super(...arguments),this.tokenize=Dt}equals(e,n,t){return t.ignoreWhitespace?((!t.newlineIsToken||!e.includes(`
|
|
2
2
|
`))&&(e=e.trim()),(!t.newlineIsToken||!n.includes(`
|
|
3
3
|
`))&&(n=n.trim())):t.ignoreNewlineAtEof&&!t.newlineIsToken&&(e.endsWith(`
|
|
4
4
|
`)&&(e=e.slice(0,-1)),n.endsWith(`
|
|
@@ -11,5 +11,5 @@ ${s}`})),Jt=a(s=>{let e=[],n=s.replaceAll(/'(?:[^']|'')*'/gu,t=>(e.push(t),`${$e
|
|
|
11
11
|
`,e);return t===-1?s.length:t}if(n==="/"&&s[e+1]==="*"){let t=s.indexOf("*/",e+2);return t===-1?s.length:t+2}return-1},"Xt"),tn=a(s=>{let e="",n=0;for(;n<s.length;){let t=en(s,n);t===-1?(e+=s.slice(n,n+1),n+=1):(e+=s.slice(n,t).replaceAll(Zt," "),n=t)}return e},"Zt"),nn=a(s=>{let e=new Set;for(let n of s.matchAll(Vt))e.add((n[1]??"").toLowerCase());return e},"en"),on=a((s,e)=>{let n=new Map;for(let t of s.matchAll(Yt)){let r=(t[1]??"").toLowerCase(),o=(t[2]??"").toLowerCase();e.has(r)&&(n.set(r,r),o!==""&&!Xt.has(o)&&n.set(o,r))}return n},"tn"),St=a((s,e)=>{let n=tn(s),t=new Set(e.map(r=>r.toLowerCase()));return{ctes:nn(n),masked:n,targets:on(n,t)}},"ut"),rn=/^(?:__lunora|sqlite_)/iu,sn=/\b(?:from|join)\s+([a-z_][\w$]*)/giu,ln=/\b([a-z_][\w$]*)\.([a-z_][\w$]*)/giu,an=new Set(["cross","full","group","having","inner","join","lateral","left","limit","offset","order","right","select","union","where","window"]),cn=a((s,e,n)=>{let t=[];for(let r of s.matchAll(sn)){let o=r[1]??"",l=o.toLowerCase();!e.has(l)&&!n.has(l)&&!an.has(l)&&!rn.test(o)&&t.push({length:o.length,message:`unknown table \`${o}\``,offset:r.index+r[0].length-o.length,severity:"error",source:"schema"})}return t},"rn"),dn=a((s,e,n)=>{let t=[],r=new Map;for(let[o,l]of Object.entries(e.columns))r.set(o.toLowerCase(),new Set(l.map(i=>i.toLowerCase())));for(let o of s.matchAll(ln)){let l=(o[1]??"").toLowerCase(),i=o[2]??"",c=n.get(l),d=c===void 0?void 0:r.get(c);d!==void 0&&!d.has(i.toLowerCase())&&t.push({length:i.length,message:`\`${c??""}\` has no column \`${i}\``,offset:o.index+o[0].length-i.length,severity:"error",source:"schema"})}return t},"an"),un=/(?<![\w$."])(?:"([a-z_][\w$]*)"|([a-z_][\w$]*))(?![.(])/giu,mn=/\bas\s+"?([a-z_][\w$]*)"?/giu,fn=a((s,e,n,t)=>{let r=[...new Set(n.values())],o=new Map,l=new Set;for(let d of r){for(let m of e.columns[d]??[])l.add(m.toLowerCase());for(let m of e.docFields?.[d]??[])o.set(m.toLowerCase(),m)}if(o.size===0)return[];let i=new Set([...s.matchAll(mn)].map(d=>(d[1]??"").toLowerCase())),c=[];for(let d of s.matchAll(un)){let m=d[1],x=m??d[2]??"",h=x.toLowerCase(),v=o.get(h);v===void 0||l.has(h)||i.has(h)||t.has(h)||n.has(h)||c.push({length:x.length,message:`\`${v}\` is a \`__doc__\` field, not a column \u2014 use \`json_extract(__doc__, '$.${v}')\``,offset:d.index+(m===void 0?0:1),severity:"error",source:"schema"})}return c},"un"),hn=a((s,e)=>{if(s.trim()==="")return[];let n=wt(s),t=new Set(e.tables.map(o=>o.toLowerCase())),r=[];for(let o of n){let{offset:l,rejection:i}=o;if(i!==void 0){r.push({length:i.length,message:i.message,offset:i.offset===void 0?l:l+i.offset,severity:"error",source:"gate"});continue}let{ctes:c,masked:d,targets:m}=St(o.sql,e.tables);r.push(...[...cn(d,t,c),...dn(d,e,m),...fn(d,e,m,c)].map(x=>({...x,offset:x.offset===void 0?l:l+x.offset})))}return r},"fn"),pn=Se(ke.lintSql),bn=600,gn=a((s,e,n)=>{let t=_e(),[r,o]=(0,B.useState)([]),l=(0,B.useMemo)(()=>hn(s,e),[s,e]),i=lt(s,bn),c=l.some(x=>x.source==="gate")||i.trim()==="",d=(0,B.useCallback)(async x=>{try{let h=await t.query(pn,{sql:i},Ce(n));x.cancelled||o(h.diagnostics??[])}catch{x.cancelled||o([])}},[t,i,n]);(0,B.useEffect)(()=>{if(c){o([]);return}let x={cancelled:!1};return me(d(x)),()=>{x.cancelled=!0}},[d,c]);let m=i===s;return(0,B.useMemo)(()=>m?[...l,...r]:l,[l,r,m])},"hn"),Me=8,xn=["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"],vn=new Set(["AND","BY","HAVING","ON","OR","SELECT","WHERE"]),yn=/[\w$]/,Ct=a(s=>s!==void 0&&yn.test(s),"ft"),kt=a(s=>{let e=s.length;for(;e>0&&Ct(s[e-1]);)e-=1;return s.slice(e)},"mt"),Nt=a((s,e)=>{let n=e;for(;n>0&&Ct(s[n-1]);)n-=1;return{end:e,start:n,text:s.slice(n,e)}},"pt"),ft=a((s,e)=>{let n=s.slice(0,e).trimEnd();return n.endsWith(".")||vn.has(kt(n).toUpperCase())},"et"),wn=a((s,e,n)=>{let t=s.slice(0,e);if(!t.endsWith("."))return;let r=kt(t.slice(0,-1));if(r!=="")return St(s,n).targets.get(r.toLowerCase())??r},"yn"),Ve=a((s,e)=>s.toLowerCase().startsWith(e.toLowerCase()),"Ye"),ht=a((s,e,n,t)=>{let r=[];for(let o of s)if(Ve(o,e)&&(r.push(t(o)),r.length>=n))break;return r},"tt"),Sn=a((s,e,n)=>{let t=new Map;for(let[r,o]of Object.entries(s.columns))for(let l of o)if(Ve(l,e)&&!t.has(l)&&(t.set(l,r),t.size>=n))return[...t].map(([i,c])=>({detail:c,kind:"column",label:i}));return[...t].map(([r,o])=>({detail:o,kind:"column",label:r}))},"vn"),Cn=a((s,e,n)=>{let t=Nt(s,e),r=wn(s,t.start,n.tables);if(r!==void 0){let c=n.columns[r]??n.columns[r.toLowerCase()]??[];return ht(c,t.text,Me,d=>({detail:r,kind:"column",label:d}))}if(t.text===""&&!ft(s,t.start))return[];let o=ht(n.tables,t.text,Me,c=>({kind:"table",label:c})),l=Sn(n,t.text,Me),i=xn.flatMap(c=>t.text!==""&&Ve(c,t.text)&&c.toLowerCase()!==t.text.toLowerCase()?[{kind:"keyword",label:c}]:[]);return(ft(s,t.start)?[...l,...o,...i]:[...o,...l,...i]).slice(0,Me)},"Sn"),kn=a((s,e,n)=>{let t=Nt(s,e),r=s.slice(0,t.start)+n.label+s.slice(t.end);return{caret:t.start+n.label.length,value:r}},"wn"),Nn=["boxSizing","borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textTransform","width","wordSpacing"],qn=a((s,e)=>{let n=globalThis.getComputedStyle(s),t=globalThis.document.createElement("div"),{style:r}=t;r.position="absolute",r.visibility="hidden",r.whiteSpace="pre-wrap",r.overflowWrap="break-word";for(let c of Nn)r[c]=n[c];t.textContent=s.value.slice(0,Math.max(0,e));let o=globalThis.document.createElement("span");o.textContent=s.value.slice(Math.max(0,e))||".",t.append(o),globalThis.document.body.append(t);let l=o.offsetLeft-s.scrollLeft,i=o.offsetTop-s.scrollTop;return t.remove(),{left:l,top:i}},"En"),En=a((s,e,n)=>{let t=(0,Z.c)(16),[r,o]=(0,B.useState)(null),l;t[0]!==s||t[1]!==e?(l=a((w,p)=>{let S=Cn(w,p,s);if(S.length===0){o(null);return}let y=e.current,{left:g,top:C}=y===null?{left:0,top:0}:qn(y,p);o(k=>k!==null&&k.active===0&&k.left===g&&k.top===C&&k.suggestions.length===S.length&&k.suggestions.every((q,E)=>{let T=S.at(E);return q.kind===T?.kind&&q.label===T.label&&q.detail===T.detail})?k:{active:0,left:g,suggestions:S,top:C})},"r"),t[0]=s,t[1]=e,t[2]=l):l=t[2];let i=l,c;t[3]===Symbol.for("react.memo_cache_sentinel")?(c=a(()=>{o(null)},"c"),t[3]=c):c=t[3];let d=c,m;t[4]===Symbol.for("react.memo_cache_sentinel")?(m=a(w=>{o(p=>{if(p===null)return p;let S=p.suggestions.length,y=(p.active+w+S)%S;return{...p,active:y}})},"f"),t[4]=m):m=t[4];let x=m,h;t[5]!==n||t[6]!==r||t[7]!==e?(h=a(w=>{let p=e.current;if(r===null||p===null)return!1;let S=r.suggestions[w??r.active];if(S===void 0)return!1;let y=kn(p.value,p.selectionStart,S);return n(y.value),o(null),requestAnimationFrame(()=>{let g=e.current;g!==null&&(g.focus(),g.setSelectionRange(y.caret,y.caret))}),!0},"u"),t[5]=n,t[6]=r,t[7]=e,t[8]=h):h=t[8];let v=h,f;t[9]!==v?(f=a(()=>v(),"d"),t[9]=v,t[10]=f):f=t[10];let N=f,b;return t[11]!==N||t[12]!==v||t[13]!==i||t[14]!==r?(b={close:d,commit:N,commitAt:v,move:x,refresh:i,state:r},t[11]=N,t[12]=v,t[13]=i,t[14]=r,t[15]=b):b=t[15],b},"Nn"),Tn={column:"column",keyword:"keyword",table:"table"},In=20,Ln=a(s=>{let e=(0,Z.c)(17),{listboxId:n,onPick:t,state:r}=s,o=ae(),l;e[0]!==r?(l=r===null?void 0:{left:r.left,top:r.top+In},e[0]=r,e[1]=l):l=e[1];let i=l;if(r===null)return null;let c;if(e[2]!==n||e[3]!==t||e[4]!==r.active||e[5]!==r.suggestions||e[6]!==o){let m;e[8]!==n||e[9]!==t||e[10]!==r.active||e[11]!==o?(m=a((x,h)=>(0,u.jsxs)("li",{"aria-selected":h===r.active,className:ue("flex cursor-pointer items-center gap-2 px-2 py-1 text-[13px]",h===r.active?"bg-accent text-accent-foreground":"text-foreground"),"data-testid":"sql-autocomplete-item",id:`${n}-opt-${h.toString()}`,onMouseDown:a(v=>{v.preventDefault(),t(h)},"onMouseDown"),role:"option",children:[(0,u.jsx)("span",{className:"truncate font-mono",children:x.label}),x.detail!==void 0&&(0,u.jsx)("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:x.detail}),(0,u.jsx)("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:o(Tn[x.kind])})]},`${x.kind}:${x.label}`),"f"),e[8]=n,e[9]=t,e[10]=r.active,e[11]=o,e[12]=m):m=e[12],c=r.suggestions.map(m),e[2]=n,e[3]=t,e[4]=r.active,e[5]=r.suggestions,e[6]=o,e[7]=c}else c=e[7];let d;return e[13]!==n||e[14]!==i||e[15]!==c?(d=(0,u.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:n,role:"listbox",style:i,children:c}),e[13]=n,e[14]=i,e[15]=c,e[16]=d):d=e[16],d},"Rn"),Rn=Se(ke.listTables),_n=Se(ke.readTablePage),Dn=a(s=>{let e=(0,Z.c)(18),n=_e(),t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];let[r,o]=(0,B.useState)(t),l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l={},e[1]=l):l=e[1];let[i,c]=(0,B.useState)(l),d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d={},e[2]=d):d=e[2];let[m,x]=(0,B.useState)(d),h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=new Set,e[3]=h):h=e[3];let v=(0,B.useRef)(h),f,N;e[4]!==n||e[5]!==s?(f=a(()=>{let g={cancelled:!1};return me((async()=>{try{let C=await n.query(Rn,{},Ce(s));g.cancelled||(o(C.map(Mn)),c({}),x({}),v.current=new Set)}catch{g.cancelled||(o([]),c({}),x({}),v.current=new Set)}})()),()=>{g.cancelled=!0}},"d"),N=[n,s],e[4]=n,e[5]=s,e[6]=f,e[7]=N):(f=e[6],N=e[7]),(0,B.useEffect)(f,N);let b;e[8]!==n||e[9]!==s?(b=a(g=>{v.current.has(g)||(v.current.add(g),me((async()=>{try{let C=await n.query(_n,{limit:1,offset:0,table:g},Ce(s)),{sqlColumns:k}=C;if(k===void 0){v.current.delete(g);return}let q=new Set(k),E=C.columns.filter(T=>!q.has(T));c(T=>({...T,[g]:k})),x(T=>({...T,[g]:E}))}catch{v.current.delete(g)}})()))},"m"),e[8]=n,e[9]=s,e[10]=b):b=e[10];let w=b,p;e[11]!==i||e[12]!==m||e[13]!==r?(p={columns:i,docFields:m,tables:r},e[11]=i,e[12]=m,e[13]=r,e[14]=p):p=e[14];let S=p,y;return e[15]!==w||e[16]!==S?(y={probe:w,schema:S},e[15]=w,e[16]=S,e[17]=y):y=e[17],y},"_n"),Je=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,An=a(s=>{let e=new Set;Je.lastIndex=0;let n=Je.exec(s);for(;n!==null;)e.add(n[1]??n[2]),n=Je.exec(s);return[...e]},"An");function Mn(s){return s.name}a(Mn,"qn");var On=a(s=>(s.metaKey||s.ctrlKey)&&!s.shiftKey&&!s.altKey&&s.key.toLowerCase()==="i","Dn"),Pn=a(s=>{let e=(0,Z.c)(44),{inlineEditEnabled:n,onSubmit:t,probe:r,schema:o,setDraft:l}=s,i=(0,B.useId)(),[c,d]=(0,B.useState)(null),m=(0,B.useRef)(null),x=(0,B.useRef)(null),h=(0,B.useRef)(null),v=En(o,h,l),{close:f,commit:N,commitAt:b,move:w,refresh:p,state:S}=v,y;e[0]!==b?(y=a(A=>{b(A)},"v"),e[0]=b,e[1]=y):y=e[1];let g=y,C;e[2]!==p?(C=a(()=>{let A=h.current;A!==null&&A===document.activeElement&&p(A.value,A.selectionStart)},"E"),e[2]=p,e[3]=C):C=e[3];let k;e[4]!==p||e[5]!==o?(k=[p,o],e[4]=p,e[5]=o,e[6]=k):k=e[6],(0,B.useEffect)(C,k);let q;e[7]!==r||e[8]!==p||e[9]!==l?(q=a(A=>{let{selectionStart:U,value:G}=A.target;l(G),d(null);for(let Y of An(G))r(Y);p(G,U)},"T"),e[7]=r,e[8]=p,e[9]=l,e[10]=q):q=e[10];let E=q,T;e[11]!==p?(T=a(A=>{let U=A.currentTarget;p(U.value,U.selectionStart)},"R"),e[11]=p,e[12]=T):T=e[12];let I=T,D;e[13]!==f||e[14]!==N||e[15]!==w?(D=a(A=>A.key==="ArrowDown"?(A.preventDefault(),w(1),!0):A.key==="ArrowUp"?(A.preventDefault(),w(-1),!0):A.key==="Escape"?(A.preventDefault(),f(),!0):(A.key==="Enter"||A.key==="Tab")&&!A.metaKey&&!A.ctrlKey&&N()?(A.preventDefault(),!0):!1,"_"),e[13]=f,e[14]=N,e[15]=w,e[16]=D):D=e[16];let R=D,_;e[17]!==S||e[18]!==f||e[19]!==n||e[20]!==R||e[21]!==t?(_=a(A=>{if(!(S!==null&&R(A))){if((A.metaKey||A.ctrlKey)&&A.key==="Enter"){A.preventDefault(),t();return}if(n&&On(A)){A.preventDefault(),f();let{selectionEnd:U,selectionStart:G,value:Y}=A.currentTarget,[O,oe]=G===U?[0,Y.length]:[G,U];d({end:oe,start:O,text:Y.slice(O,oe)})}}},"L"),e[17]=S,e[18]=f,e[19]=n,e[20]=R,e[21]=t,e[22]=_):_=e[22];let Q=_,j;e[23]!==f?(j=a(()=>{requestAnimationFrame(()=>{f()})},"B"),e[23]=f,e[24]=j):j=e[24];let K=j,P;e[25]===Symbol.for("react.memo_cache_sentinel")?(P=a(A=>{let{scrollLeft:U,scrollTop:G}=A.currentTarget;m.current!==null&&(m.current.scrollTop=G),x.current!==null&&(x.current.scrollTop=G,x.current.scrollLeft=U)},"M"),e[25]=P):P=e[25];let W=P,F;e[26]===Symbol.for("react.memo_cache_sentinel")?(F=a(A=>{let U=h.current;U===null||A.offset===void 0||(U.focus(),U.setSelectionRange(A.offset,A.offset+(A.length??0)))},"Q"),e[26]=F):F=e[26];let L=F,M;e[27]===Symbol.for("react.memo_cache_sentinel")?(M=a(()=>{d(null),h.current?.focus()},"D"),e[27]=M):M=e[27];let z=M,$;e[28]!==c||e[29]!==l?($=a(A=>{let U=h.current;if(c===null||U===null)return;let{end:G,start:Y,text:O}=c;if(U.value.slice(Y,G)!==O){z();return}l(U.value.slice(0,Y)+A+U.value.slice(G)),d(null),U.focus(),requestAnimationFrame(()=>{U.setSelectionRange(Y,Y+A.length)})},"$"),e[28]=c,e[29]=l,e[30]=$):$=e[30];let te=$,V;e[31]!==E||e[32]!==K||e[33]!==Q||e[34]!==I?(V={onBlur:K,onChange:E,onKeyDown:Q,onScroll:W,onSelect:I},e[31]=E,e[32]=K,e[33]=Q,e[34]=I,e[35]=V):V=e[35];let ee;return e[36]!==te||e[37]!==S||e[38]!==f||e[39]!==c||e[40]!==i||e[41]!==g||e[42]!==V?(ee={acceptInlineEdit:te,autocompleteState:S,closeAutocomplete:f,closeInlineEdit:z,inlineEdit:c,handlers:V,listboxId:i,onPickSuggestion:g,editorRef:h,gutterRef:m,overlayRef:x,revealDiagnostic:L},e[36]=te,e[37]=S,e[38]=f,e[39]=c,e[40]=i,e[41]=g,e[42]=V,e[43]=ee):ee=e[43],ee},"On"),$n="lunora-studio-sql-tabs",jn="lunora-studio-sql-active-tab",Xe=12,Ee=a((s="",e="")=>({activeId:null,id:Ke("tab"),name:e,sql:s}),"Ee"),zn=a(()=>Ae(jn,""),"Bn"),Hn=a(s=>{let e=(0,Z.c)(16),[n,t]=De($n),[r,o]=zn(),[l]=(0,B.useState)(s),i,c;e[0]!==l||e[1]!==t||e[2]!==n.length?(i=a(()=>{n.length===0&&t([l])},"i"),c=[l,t,n.length],e[0]=l,e[1]=t,e[2]=n.length,e[3]=i,e[4]=c):(i=e[3],c=e[4]),(0,B.useEffect)(i,c);let d;e[5]!==l||e[6]!==n?(d=n.length===0?[l]:n,e[5]=l,e[6]=n,e[7]=d):d=e[7];let m=d,x;e[8]!==r||e[9]!==m?(x=m.some(f=>f.id===r)?r:m[0]?.id??"",e[8]=r,e[9]=m,e[10]=x):x=e[10];let h=x,v;return e[11]!==h||e[12]!==o||e[13]!==t||e[14]!==m?(v={activeId:h,setActiveId:o,setTabs:t,tabs:m},e[11]=h,e[12]=o,e[13]=t,e[14]=m,e[15]=v):v=e[15],v},"Hn"),qt=a(s=>s.activeId===null&&s.sql.trim()!=="","ht"),Wn=a((s,e)=>[...s,e].slice(-Xe),"Pn"),Bn=a((s,e,n)=>{let t=s.findIndex(o=>o.id===e);if(t===-1)return{activeId:s[0]?.id??"",tabs:[...s]};let r=s.filter(o=>o.id!==e);if(r.length===0){let o=n();return{activeId:o.id,tabs:[o]}}return{activeId:r[Math.min(t,r.length-1)].id,tabs:r}},"Fn"),Fn=a((s,e)=>{let n=s.filter(t=>t.id===e);return n.length===0?{activeId:s[0]?.id??"",tabs:[...s]}:{activeId:e,tabs:n}},"Wn"),Qn=a((s,e,n)=>{let t=s.findIndex(o=>o.id===e);if(t===-1)return{activeId:n,tabs:[...s]};let r=s.slice(0,t+1);return{activeId:r.some(o=>o.id===n)?n:e,tabs:r}},"Kn"),Kn=a(s=>{let e=s();return{activeId:e.id,tabs:[e]}},"Qn"),Un=a((s,e,n)=>{if(s==="others")return e.filter(t=>t.id!==n);if(s==="right"){let t=e.findIndex(r=>r.id===n);return t===-1?[]:e.slice(t+1)}return[...e]},"zn"),pt={error:null,pane:"results",result:null,running:!1},Gn=a(s=>{let e=(0,Z.c)(66),{activeId:n,setActiveId:t,setTabs:r,tabs:o}=Hn(s),l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={},e[0]=l):l=e[0];let[i,c]=(0,B.useState)(l),[d,m]=(0,B.useState)(null),[x,h]=(0,B.useState)(null),v;e[1]!==n||e[2]!==o?(v=o.find(H=>H.id===n)??o[0]??Ee(),e[1]=n,e[2]=o,e[3]=v):v=e[3];let f=v,N=i[f.id]??pt,b;e[4]!==f.id||e[5]!==r?(b=a(H=>{r(J=>J.map(X=>X.id===f.id?{...X,...H}:X))},"m"),e[4]=f.id,e[5]=r,e[6]=b):b=e[6];let w=b,p;e[7]!==f.id?(p=a(H=>{c(J=>{let X=J[f.id]??pt;return{...J,[f.id]:{...X,...H}}})},"b"),e[7]=f.id,e[8]=p):p=e[8];let S=p,y;e[9]!==t||e[10]!==r||e[11]!==o.length?(y=a(()=>{if(o.length>=Xe)return;let H=Ee();r(J=>Wn(J,H)),t(H.id)},"v"),e[9]=t,e[10]=r,e[11]=o.length,e[12]=y):y=e[12];let g=y,C;e[13]!==t||e[14]!==r?(C=a(H=>{m(null),h(null),r(H.tabs),t(H.activeId);let J=new Set(H.tabs.map(Jn));c(X=>Object.fromEntries(Object.entries(X).filter(re=>{let[fe]=re;return J.has(fe)})))},"E"),e[13]=t,e[14]=r,e[15]=C):C=e[15];let k=C,q;e[16]!==k||e[17]!==o?(q=a(H=>{k(Bn(o,H,Ee))},"T"),e[16]=k,e[17]=o,e[18]=q):q=e[18];let E=q,T;e[19]!==n||e[20]!==k||e[21]!==o?(T=a((H,J)=>{k(H==="others"?Fn(o,J):H==="right"?Qn(o,J,n):Kn(Ee))},"R"),e[19]=n,e[20]=k,e[21]=o,e[22]=T):T=e[22];let I=T,D;e[23]!==I||e[24]!==d||e[25]!==o?(D=a(H=>{d!==null&&(Un(H,o,d.id).some(Yn)?h(H):I(H,d.id))},"_"),e[23]=I,e[24]=d,e[25]=o,e[26]=D):D=e[26];let R=D,_;e[27]===Symbol.for("react.memo_cache_sentinel")?(_=a((H,J)=>{J.preventDefault(),h(null),m({id:H,x:J.clientX,y:J.clientY})},"L"),e[27]=_):_=e[27];let Q=_,j;e[28]===Symbol.for("react.memo_cache_sentinel")?(j=a(()=>{m(null),h(null)},"B"),e[28]=j):j=e[28];let K=j,P;e[29]===Symbol.for("react.memo_cache_sentinel")?(P=a(H=>{H.preventDefault(),m(null),h(null)},"M"),e[29]=P):P=e[29];let W=P,F;e[30]!==R?(F=a(()=>{R("others")},"Q"),e[30]=R,e[31]=F):F=e[31];let L=F,M;e[32]!==R?(M=a(()=>{R("right")},"D"),e[32]=R,e[33]=M):M=e[33];let z=M,$;e[34]!==R?($=a(()=>{R("all")},"$"),e[34]=R,e[35]=$):$=e[35];let te=$,V;e[36]!==I||e[37]!==x||e[38]!==d?(V=a(()=>{d!==null&&x!==null&&I(x,d.id),h(null)},"J"),e[36]=I,e[37]=x,e[38]=d,e[39]=V):V=e[39];let ee=V,A;e[40]===Symbol.for("react.memo_cache_sentinel")?(A=a(()=>{h(null)},"q"),e[40]=A):A=e[40];let U=A,G;e[41]!==d?(G=d===null?void 0:{left:d.x,top:d.y},e[41]=d,e[42]=G):G=e[42];let Y=G,O;e[43]!==r?(O=a(H=>{r(J=>J.map(X=>X.activeId===H?{...X,activeId:null}:X))},"O"),e[43]=r,e[44]=O):O=e[44];let oe=O,se;e[45]!==r?(se=a((H,J)=>{r(X=>X.map(re=>re.id===H?{...re,name:J}:re))},"re"),e[45]=r,e[46]=se):se=e[46];let le=se,ie;return e[47]!==f||e[48]!==n||e[49]!==g||e[50]!==E||e[51]!==ee||e[52]!==te||e[53]!==L||e[54]!==z||e[55]!==N||e[56]!==S||e[57]!==w||e[58]!==x||e[59]!==le||e[60]!==t||e[61]!==d||e[62]!==Y||e[63]!==o||e[64]!==oe?(ie={activeTab:f,activeTabId:n,addEditorTab:g,cancelBulk:U,closeEditorTab:E,closeTabMenu:K,confirmBulk:ee,menuStyle:Y,onBackdropContextMenu:W,onCloseAll:te,onCloseOthers:L,onCloseToRight:z,openTabMenu:Q,output:N,patchActiveOutput:S,patchActiveTab:w,pendingBulk:x,renameTab:le,setActiveTabId:t,tabMenu:d,tabs:o,unlinkQuery:oe},e[47]=f,e[48]=n,e[49]=g,e[50]=E,e[51]=ee,e[52]=te,e[53]=L,e[54]=z,e[55]=N,e[56]=S,e[57]=w,e[58]=x,e[59]=le,e[60]=t,e[61]=d,e[62]=Y,e[63]=o,e[64]=oe,e[65]=ie):ie=e[65],ie},"Un");function Jn(s){return s.id}a(Jn,"jn");function Yn(s){return qt(s)}a(Yn,"Yn");var Vn="lunora-studio-sql-queries",we="lunora-studio-sql-history",Xn="lunora-studio-sql-remember-history",Zn=25,eo=a(s=>{let e=(0,Z.c)(41),{loadIntoActiveTab:n,unlinkQuery:t}=s,r=ae(),[o,l]=De(Vn),[i,c]=Ae(Xn,!1),[d,m]=De(we,i?"local":"session"),x,h;e[0]!==i?(x=a(()=>{i||Ne(we,"local")},"g"),h=[i],e[0]=i,e[1]=x,e[2]=h):(x=e[1],h=e[2]),(0,B.useEffect)(x,h);let[v,f]=(0,B.useState)(""),N=(0,B.useRef)(null),b;e[3]!==m?(b=a(L=>{m(M=>M[0]?.sql===L?M:[{at:Date.now(),sql:L},...M.filter(z=>z.sql!==L)].slice(0,Zn))},"m"),e[3]=m,e[4]=b):b=e[4];let w=b,p;e[5]!==n||e[6]!==l||e[7]!==r?(p=a(()=>{let L={id:Ke("q"),name:r("Untitled query"),sql:""};l(M=>[L,...M]),n("",L.id)},"b"),e[5]=n,e[6]=l,e[7]=r,e[8]=p):p=e[8];let S=p,y;e[9]!==n||e[10]!==o?(y=a(L=>{let M=o.find(z=>z.id===L);M!==void 0&&(n(M.sql,L),N.current?.querySelector(`[data-testid="sql-query-${L}"]`)?.scrollIntoView({block:"nearest"}))},"v"),e[9]=n,e[10]=o,e[11]=y):y=e[11];let g=y,C;e[12]!==l||e[13]!==t?(C=a(L=>{l(M=>M.filter(z=>z.id!==L)),t(L)},"E"),e[12]=l,e[13]=t,e[14]=C):C=e[14];let k=C,q;e[15]!==n?(q=a(L=>{n(L.currentTarget.dataset.sql??"",null)},"T"),e[15]=n,e[16]=q):q=e[16];let E=q,T;e[17]!==n?(T=a(L=>{n(L.currentTarget.dataset.sql??"",null)},"R"),e[17]=n,e[18]=T):T=e[18];let I=T,D;e[19]!==m?(D=a(()=>{m([]),Ne(we,"local"),Ne(we,"session")},"_"),e[19]=m,e[20]=D):D=e[20];let R=D,_;e[21]!==d||e[22]!==c?(_=a(L=>{nt(we,d,L?"local":"session"),L||Ne(we,"local"),c(L)},"L"),e[21]=d,e[22]=c,e[23]=_):_=e[23];let Q=_,j;e[24]===Symbol.for("react.memo_cache_sentinel")?(j=a(L=>{f(L.target.value)},"B"),e[24]=j):j=e[24];let K=j,P;e[25]!==l?(P=a((L,M)=>{l(z=>z.map($=>$.id===L?{...$,sql:M}:$))},"M"),e[25]=l,e[26]=P):P=e[26];let W=P,F;return e[27]!==R||e[28]!==k||e[29]!==d||e[30]!==I||e[31]!==E||e[32]!==S||e[33]!==o||e[34]!==w||e[35]!==i||e[36]!==v||e[37]!==g||e[38]!==Q||e[39]!==W?(F={clearHistory:R,deleteQuery:k,history:d,listRef:N,loadFromHistory:I,loadTemplate:E,newQuery:S,onSearchChange:K,queries:o,recordHistory:w,rememberHistory:i,search:v,selectQuery:g,setRememberHistory:Q,updateQuerySql:W},e[27]=R,e[28]=k,e[29]=d,e[30]=I,e[31]=E,e[32]=S,e[33]=o,e[34]=w,e[35]=i,e[36]=v,e[37]=g,e[38]=Q,e[39]=W,e[40]=F):F=e[40],F},"Xn"),Ze="p-3 font-mono text-xs leading-5 whitespace-pre-wrap break-words",to=a((s,e)=>{let n=[];for(let r of s){if(r.offset===void 0||r.length===void 0||r.length<=0)continue;let o=Math.max(0,Math.min(r.offset,e)),l=Math.max(o,Math.min(r.offset+r.length,e));o!==l&&n.push({end:l,severity:r.severity,start:o})}n.sort((r,o)=>r.start-o.start);let t=[];for(let r of n)r.start>=(t.at(-1)?.end??0)&&t.push(r);return t},"Zn"),Et=a((s,e)=>e(s==="unsafe-response"?"The model returned a statement that is not read-only, so it was discarded.":s==="too-long"?"The statement is too long to rewrite. Select a shorter part of it.":s==="empty-response"?"The model returned nothing usable.":"The model could not be reached."),"bt"),no=a(s=>{let e=(0,Z.c)(51),{assistant:n,failed:t,onGenerated:r}=s,o=ae(),[l,i]=(0,B.useState)("");if(n.unavailable)return null;let c;e[0]!==n?(c=n.pending("sql"),e[0]=n,e[1]=c):c=e[1];let d=c,m;if(e[2]!==n||e[3]!==t||e[4]!==r||e[5]!==d||e[6]!==l||e[7]!==o){let x=n.reason("sql"),h;e[9]!==n||e[10]!==t||e[11]!==r||e[12]!==l?(h=a(I=>{let D=l.trim();D===""&&!I||me((async()=>{let R=await n.generate(D===""?"fix the failing statement":D,I?t:void 0);R!==void 0&&r(R)})())},"u"),e[9]=n,e[10]=t,e[11]=r,e[12]=l,e[13]=h):h=e[13];let v=h,f;e[14]!==o?(f=o("Describe the query you want"),e[14]=o,e[15]=f):f=e[15];let N;e[16]===Symbol.for("react.memo_cache_sentinel")?(N=a(I=>{i(I.target.value)},"N"),e[16]=N):N=e[16];let b;e[17]!==v?(b=a(I=>{I.key==="Enter"&&(I.preventDefault(),v(!1))},"m"),e[17]=v,e[18]=b):b=e[18];let w;e[19]!==o?(w=o("Describe the query you want"),e[19]=o,e[20]=w):w=e[20];let p;e[21]!==d||e[22]!==l||e[23]!==f||e[24]!==b||e[25]!==w?(p=(0,u.jsx)(Qe,{"aria-label":f,className:"h-7 flex-1 text-xs","data-testid":"sql-assistant-prompt",disabled:d,onChange:N,onKeyDown:b,placeholder:w,value:l}),e[21]=d,e[22]=l,e[23]=f,e[24]=b,e[25]=w,e[26]=p):p=e[26];let S=d&&"opacity-60",y;e[27]!==S?(y=ue("rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",S),e[27]=S,e[28]=y):y=e[28];let g;e[29]!==d||e[30]!==l?(g=d||l.trim()==="",e[29]=d,e[30]=l,e[31]=g):g=e[31];let C;e[32]!==v?(C=a(()=>{v(!1)},"E"),e[32]=v,e[33]=C):C=e[33];let k;e[34]!==d||e[35]!==o?(k=o(d?"Thinking\u2026":"Draft SQL"),e[34]=d,e[35]=o,e[36]=k):k=e[36];let q;e[37]!==y||e[38]!==g||e[39]!==C||e[40]!==k?(q=(0,u.jsx)("button",{className:y,"data-testid":"sql-assistant-generate",disabled:g,onClick:C,type:"button",children:k}),e[37]=y,e[38]=g,e[39]=C,e[40]=k,e[41]=q):q=e[41];let E;e[42]!==t||e[43]!==d||e[44]!==v||e[45]!==o?(E=t!==void 0&&(0,u.jsx)("button",{className:"rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-assistant-fix",disabled:d,onClick:a(()=>{v(!0)},"onClick"),type:"button",children:o("Fix this")}),e[42]=t,e[43]=d,e[44]=v,e[45]=o,e[46]=E):E=e[46];let T;e[47]!==q||e[48]!==E||e[49]!==p?(T=(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[p,q,E]}),e[47]=q,e[48]=E,e[49]=p,e[50]=T):T=e[50],m=(0,u.jsxs)("div",{className:"flex flex-col gap-1 border-b border-border px-3 py-2","data-testid":"sql-assistant",children:[T,x!==void 0&&(0,u.jsx)("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-assistant-reason",role:"status",children:Et(x,o)})]}),e[2]=n,e[3]=t,e[4]=r,e[5]=d,e[6]=l,e[7]=o,e[8]=m}else m=e[8];return m},"es"),oo=a(s=>{let e=(0,Z.c)(8),{diagnostics:n,draft:t,scrollRef:r}=s,o,l;if(e[0]!==n||e[1]!==t){l=Symbol.for("react.early_return_sentinel");e:{let d=to(n,t.length);if(d.length===0){l=null;break e}o=[];let m=0;for(let[x,h]of d.entries())h.start>m&&o.push(t.slice(m,h.start)),o.push((0,u.jsx)("span",{className:ue("decoration-wavy underline underline-offset-4",h.severity==="error"?"decoration-destructive":"decoration-amber-500"),children:t.slice(h.start,h.end)},`${h.start.toString()}-${x.toString()}`)),m=h.end;o.push(t.slice(m))}e[0]=n,e[1]=t,e[2]=o,e[3]=l}else o=e[2],l=e[3];if(l!==Symbol.for("react.early_return_sentinel"))return l;let i;e[4]===Symbol.for("react.memo_cache_sentinel")?(i=ue("pointer-events-none absolute inset-0 overflow-hidden text-transparent",Ze),e[4]=i):i=e[4];let c;return e[5]!==o||e[6]!==r?(c=(0,u.jsx)("div",{"aria-hidden":"true",className:i,"data-testid":"sql-diagnostics-overlay",ref:r,children:o}),e[5]=o,e[6]=r,e[7]=c):c=e[7],c},"ts"),ro={gate:"read-only",plan:"plan",schema:"schema",syntax:"syntax"},so=a(s=>{let e=(0,Z.c)(10),{diagnostics:n,onSelect:t}=s,r=ae();if(n.length===0)return null;let o;e[0]!==r?(o=r("SQL problems"),e[0]=r,e[1]=o):o=e[1];let l;if(e[2]!==n||e[3]!==t){let c;e[5]!==t?(c=a((d,m)=>(0,u.jsx)("li",{children:(0,u.jsxs)("button",{className:"flex w-full items-start gap-2 px-3 py-1 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-problem",onClick:a(()=>{t(d)},"onClick"),type:"button",children:[(0,u.jsx)("span",{className:ue("mt-px shrink-0 rounded px-1 font-mono text-[10px] uppercase",d.severity==="error"?"bg-destructive/15 text-destructive":"bg-amber-500/15 text-amber-600"),children:ro[d.source]}),(0,u.jsx)("span",{className:"min-w-0 text-muted-foreground",children:d.message})]})},`${d.source}-${(d.offset??m).toString()}-${m.toString()}`),"c"),e[5]=t,e[6]=c):c=e[6],l=n.map(c),e[2]=n,e[3]=t,e[4]=l}else l=e[4];let i;return e[7]!==o||e[8]!==l?(i=(0,u.jsx)("ul",{"aria-label":o,className:"max-h-24 shrink-0 overflow-y-auto border-t border-border bg-muted/30","data-testid":"sql-problems",children:l}),e[7]=o,e[8]=l,e[9]=i):i=e[9],i},"ss"),lo=a(s=>(s.endsWith(`
|
|
12
12
|
`)?s.slice(0,-1):s).split(`
|
|
13
13
|
`),"os"),io=a((s,e)=>{let n=[],t=1,r=1;for(let o of Ge(s,e,{ignoreNewlineAtEof:!0}))for(let l of lo(o.value))o.added?(n.push({after:r,kind:"added",text:l}),r+=1):o.removed?(n.push({before:t,kind:"removed",text:l}),t+=1):(n.push({after:r,before:t,kind:"context",text:l}),t+=1,r+=1);return n},"ls"),ao={added:"bg-emerald-500/10 text-emerald-700 dark:text-emerald-400",context:"text-muted-foreground",removed:"bg-destructive/10 text-destructive"},co={added:"+",context:" ",removed:"-"},uo=a(s=>{let e=(0,Z.c)(11),{lines:n}=s,t=ae(),r;e[0]!==t?(r=t("Proposed edit"),e[0]=t,e[1]=r):r=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=ue("max-h-48 overflow-auto rounded-md border border-border bg-background",Ze),e[2]=o):o=e[2];let l;if(e[3]!==n||e[4]!==t){let c;e[6]!==t?(c=a(d=>(0,u.jsxs)("li",{className:ue("flex gap-2",ao[d.kind]),"data-kind":d.kind,children:[(0,u.jsx)("span",{"aria-hidden":"true",className:"shrink-0 select-none opacity-60",children:co[d.kind]}),d.kind!=="context"&&(0,u.jsx)("span",{className:"sr-only",children:d.kind==="added"?t("Added"):t("Removed")}),(0,u.jsx)("span",{className:"min-w-0",children:d.text===""?"\xA0":d.text})]},`${String(d.before)}:${String(d.after)}`),"c"),e[6]=t,e[7]=c):c=e[7],l=n.map(c),e[3]=n,e[4]=t,e[5]=l}else l=e[5];let i;return e[8]!==r||e[9]!==l?(i=(0,u.jsx)("ul",{"aria-label":r,className:o,"data-testid":"sql-inline-diff",children:l}),e[8]=r,e[9]=l,e[10]=i):i=e[10],i},"as"),Oe="rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",mo=a(s=>{let e=(0,Z.c)(41),{onAccept:n,onCancel:t,rpc:r,source:o,whole:l}=s,i=ae(),c=(0,B.useRef)(null),d=(0,B.useRef)(null),[m,x]=(0,B.useState)(""),[h,v]=(0,B.useState)(null),f,N;if(e[0]!==h?(f=a(()=>{h===null?c.current?.focus():d.current?.focus()},"d"),N=[h],e[0]=h,e[1]=f,e[2]=N):(f=e[1],N=e[2]),(0,B.useEffect)(f,N),r.unavailable)return null;let b;e[3]!==r?(b=r.pending("sql"),e[3]=r,e[4]=b):b=e[4];let w=b,p;if(e[5]!==m||e[6]!==n||e[7]!==t||e[8]!==w||e[9]!==h||e[10]!==r||e[11]!==o||e[12]!==i||e[13]!==l){let S=r.reason("sql"),y;e[15]!==m||e[16]!==r||e[17]!==o?(y=a(()=>{let R=m.trim();R===""||o.trim()===""||me((async()=>{let _=await r.rewrite(R,o);_!==void 0&&v(_)})())},"v"),e[15]=m,e[16]=r,e[17]=o,e[18]=y):y=e[18];let g=y,C;e[19]!==t?(C=a(R=>{R.key==="Escape"&&(R.preventDefault(),t())},"E"),e[19]=t,e[20]=C):C=e[20];let k=C,q;e[21]!==i||e[22]!==l?(q=i(l?"Whole query":"Selection"),e[21]=i,e[22]=l,e[23]=q):q=e[23];let E;e[24]!==q?(E=(0,u.jsx)("span",{className:"shrink-0 rounded bg-muted px-1 font-mono text-[10px] uppercase text-muted-foreground","data-testid":"sql-inline-edit-scope",children:q}),e[24]=q,e[25]=E):E=e[25];let T;e[26]!==m||e[27]!==n||e[28]!==t||e[29]!==k||e[30]!==w||e[31]!==h||e[32]!==g||e[33]!==i?(T=h===null?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Qe,{"aria-label":i("Tell the model what to change"),className:"h-7 flex-1 text-xs","data-testid":"sql-inline-edit-prompt",disabled:w,onChange:a(R=>{x(R.target.value)},"onChange"),onKeyDown:a(R=>{if(R.key==="Enter"){R.preventDefault(),g();return}k(R)},"onKeyDown"),placeholder:i("Tell the model what to change"),ref:c,value:m}),(0,u.jsx)("button",{className:ue(Oe,w&&"opacity-60"),"data-testid":"sql-inline-edit-submit",disabled:w||m.trim()==="",onClick:g,onKeyDown:k,type:"button",children:i(w?"Thinking\u2026":"Rewrite")}),(0,u.jsx)("button",{className:Oe,"data-testid":"sql-inline-edit-cancel",onClick:t,onKeyDown:k,type:"button",children:i("Cancel")})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("span",{className:"flex-1 text-xs text-muted-foreground",children:i("Proposed edit")}),(0,u.jsx)("button",{className:Oe,"data-testid":"sql-inline-edit-accept",onClick:a(()=>{n(h)},"onClick"),onKeyDown:k,ref:d,type:"button",children:i("Accept")}),(0,u.jsx)("button",{className:Oe,"data-testid":"sql-inline-edit-reject",onClick:a(()=>{v(null)},"onClick"),onKeyDown:k,type:"button",children:i("Reject")})]}),e[26]=m,e[27]=n,e[28]=t,e[29]=k,e[30]=w,e[31]=h,e[32]=g,e[33]=i,e[34]=T):T=e[34];let I;e[35]!==E||e[36]!==T?(I=(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[E,T]}),e[35]=E,e[36]=T,e[37]=I):I=e[37];let D;e[38]!==h||e[39]!==o?(D=h!==null&&(0,u.jsx)(uo,{lines:io(o,h)}),e[38]=h,e[39]=o,e[40]=D):D=e[40],p=(0,u.jsxs)("div",{className:"flex flex-col gap-1 border-b border-border bg-muted/20 px-3 py-2","data-testid":"sql-inline-edit",children:[I,D,S!==void 0&&(0,u.jsx)("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-inline-edit-reason",role:"status",children:Et(S,i)})]}),e[5]=m,e[6]=n,e[7]=t,e[8]=w,e[9]=h,e[10]=r,e[11]=o,e[12]=i,e[13]=l,e[14]=p}else p=e[14];return p},"cs"),fo={minWidth:"2.75rem",paddingInline:"0.5rem"},ho=a(s=>{let e=(0,Z.c)(75),{assistant:n,autocomplete:t,diagnostics:r,draft:o,failed:l,handlers:i,editorRef:c,gutterRef:d,inlineEdit:m,listboxId:x,onAcceptInlineEdit:h,onCancelInlineEdit:v,onGenerated:f,onPickSuggestion:N,onRevealDiagnostic:b,overlayRef:w}=s,p=ae(),S,y,g,C,k,q,E,T,I;if(e[0]!==n||e[1]!==o||e[2]!==l||e[3]!==d||e[4]!==m||e[5]!==h||e[6]!==v||e[7]!==f){let $=o.split(`
|
|
14
|
-
`).length;E="flex min-h-0 min-w-0 flex-1 flex-col",e[17]!==n||e[18]!==l||e[19]!==f?(T=(0,u.jsx)(no,{assistant:n,failed:l,onGenerated:f}),e[17]=n,e[18]=l,e[19]=f,e[20]=T):T=e[20],e[21]!==n||e[22]!==o.length||e[23]!==m||e[24]!==h||e[25]!==v?(I=m!==null&&(0,u.jsx)(mo,{onAccept:h,onCancel:v,rpc:n,source:m.text,whole:m.start===0&&m.end===o.length},`${m.start.toString()}-${m.end.toString()}`),e[21]=n,e[22]=o.length,e[23]=m,e[24]=h,e[25]=v,e[26]=I):I=e[26],q="flex min-h-0 min-w-0 flex-1",S="true",y="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",g=d,C=fo,k=Array.from({length:$},po),e[0]=n,e[1]=o,e[2]=l,e[3]=d,e[4]=m,e[5]=h,e[6]=v,e[7]=f,e[8]=S,e[9]=y,e[10]=g,e[11]=C,e[12]=k,e[13]=q,e[14]=E,e[15]=T,e[16]=I}else S=e[8],y=e[9],g=e[10],C=e[11],k=e[12],q=e[13],E=e[14],T=e[15],I=e[16];let D;e[27]!==S||e[28]!==y||e[29]!==g||e[30]!==C||e[31]!==k?(D=(0,u.jsx)("div",{"aria-hidden":S,className:y,ref:g,style:C,children:k}),e[27]=S,e[28]=y,e[29]=g,e[30]=C,e[31]=k,e[32]=D):D=e[32];let R;e[33]!==r||e[34]!==o||e[35]!==w?(R=(0,u.jsx)(oo,{diagnostics:r,draft:o,scrollRef:w}),e[33]=r,e[34]=o,e[35]=w,e[36]=R):R=e[36];let _;e[37]!==t||e[38]!==x?(_=t===null?void 0:`${x}-opt-${t.active.toString()}`,e[37]=t,e[38]=x,e[39]=_):_=e[39];let Q=t===null?void 0:x,j=t!==null,K;e[40]!==p?(K=p("SQL query"),e[40]=p,e[41]=K):K=e[41];let P;e[42]!==o||e[43]!==c||e[44]!==i.onBlur||e[45]!==i.onChange||e[46]!==i.onKeyDown||e[47]!==i.onScroll||e[48]!==i.onSelect||e[49]!==_||e[50]!==Q||e[51]!==j||e[52]!==K?(P=(0,u.jsx)("textarea",{"aria-activedescendant":_,"aria-autocomplete":"list","aria-controls":Q,"aria-expanded":j,"aria-label":K,className:`relative size-full resize-none bg-transparent outline-none ${Ze}`,"data-testid":"sql-input",onBlur:i.onBlur,onChange:i.onChange,onKeyDown:i.onKeyDown,onScroll:i.onScroll,onSelect:i.onSelect,placeholder:"SELECT * FROM \u2026",ref:c,role:"combobox",spellCheck:!1,value:o}),e[42]=o,e[43]=c,e[44]=i.onBlur,e[45]=i.onChange,e[46]=i.onKeyDown,e[47]=i.onScroll,e[48]=i.onSelect,e[49]=_,e[50]=Q,e[51]=j,e[52]=K,e[53]=P):P=e[53];let W;e[54]!==t||e[55]!==x||e[56]!==N?(W=(0,u.jsx)(Ln,{listboxId:x,onPick:N,state:t}),e[54]=t,e[55]=x,e[56]=N,e[57]=W):W=e[57];let F;e[58]!==R||e[59]!==P||e[60]!==W?(F=(0,u.jsxs)("div",{className:"relative min-w-0 flex-1 bg-background",children:[R,P,W]}),e[58]=R,e[59]=P,e[60]=W,e[61]=F):F=e[61];let L;e[62]!==D||e[63]!==F||e[64]!==q?(L=(0,u.jsxs)("div",{className:q,children:[D,F]}),e[62]=D,e[63]=F,e[64]=q,e[65]=L):L=e[65];let M;e[66]!==r||e[67]!==b?(M=(0,u.jsx)(so,{diagnostics:r,onSelect:b}),e[66]=r,e[67]=b,e[68]=M):M=e[68];let z;return e[69]!==L||e[70]!==M||e[71]!==E||e[72]!==T||e[73]!==I?(z=(0,u.jsxs)("div",{className:E,children:[T,I,L,M]}),e[69]=L,e[70]=M,e[71]=E,e[72]=T,e[73]=I,e[74]=z):z=e[74],z},"us");function po(s,e){return(0,u.jsx)("div",{children:e+1},e)}a(po,"fs");var Tt=[{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;"}],bo=a(s=>{let e=(0,Z.c)(29),{active:n,onDelete:t,onSelect:r,query:o}=s,l=ae(),i;e[0]!==r||e[1]!==o.id?(i=a(()=>{r(o.id)},"i"),e[0]=r,e[1]=o.id,e[2]=i):i=e[2];let c=i,d;e[3]!==t||e[4]!==o.id?(d=a(C=>{C.stopPropagation(),t(o.id)},"a"),e[3]=t,e[4]=o.id,e[5]=d):d=e[5];let m=d,x=n?"bg-sidebar-accent font-medium text-foreground":"text-muted-foreground",h;e[6]!==x?(h=ue("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",x),e[6]=x,e[7]=h):h=e[7];let v=`sql-query-${o.id}`,f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=(0,u.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,u.jsx)("path",{d:"M4 6h16M4 12h10M4 18h7"})}),e[8]=f):f=e[8];let N;e[9]!==o.name?(N=(0,u.jsx)("span",{className:"truncate",children:o.name}),e[9]=o.name,e[10]=N):N=e[10];let b;e[11]!==n||e[12]!==c||e[13]!==h||e[14]!==v||e[15]!==N?(b=(0,u.jsxs)("button",{"aria-pressed":n,className:h,"data-testid":v,onClick:c,type:"button",children:[f,N]}),e[11]=n,e[12]=c,e[13]=h,e[14]=v,e[15]=N,e[16]=b):b=e[16];let w;e[17]!==l?(w=l("Delete query"),e[17]=l,e[18]=w):w=e[18];let p;e[19]!==l?(p=l("Delete query"),e[19]=l,e[20]=p):p=e[20];let S;e[21]===Symbol.for("react.memo_cache_sentinel")?(S=(0,u.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,u.jsx)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[21]=S):S=e[21];let y;e[22]!==m||e[23]!==p||e[24]!==w?(y=(0,u.jsx)("button",{"aria-label":w,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:m,title:p,type:"button",children:S}),e[22]=m,e[23]=p,e[24]=w,e[25]=y):y=e[25];let g;return e[26]!==y||e[27]!==b?(g=(0,u.jsxs)("li",{className:"group/q flex items-center",children:[b,y]}),e[26]=y,e[27]=b,e[28]=g):g=e[28],g},"ms"),bt="sql-history-remember",go=a((s,e)=>{let n=e.trim().toLowerCase();return n===""?[...s]:s.filter(t=>t.name.toLowerCase().includes(n))},"ps"),xo=a(s=>{let e=(0,Z.c)(66),{activeId:n,history:t,listRef:r,onClearHistory:o,onDelete:l,onLoadHistory:i,onLoadTemplate:c,onNew:d,onSearchChange:m,onSelect:x,onToggleRememberHistory:h,queries:v,rememberHistory:f,search:N}=s,b=ae(),w,p,S,y,g;if(e[0]!==n||e[1]!==r||e[2]!==l||e[3]!==d||e[4]!==m||e[5]!==x||e[6]!==h||e[7]!==v||e[8]!==N||e[9]!==b){let _=go(v,N),Q;e[15]!==h?(Q=a($=>{h($.target.checked)},"F"),e[15]=h,e[16]=Q):Q=e[16],w=Q,S="flex h-full w-64 shrink-0 flex-col border-e border-border bg-sidebar";let j;e[17]!==b?(j=b("Search queries\u2026"),e[17]=b,e[18]=j):j=e[18];let K;e[19]!==m||e[20]!==N||e[21]!==j?(K=(0,u.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:m,placeholder:j,type:"text",value:N}),e[19]=m,e[20]=N,e[21]=j,e[22]=K):K=e[22];let P;e[23]!==b?(P=b("New query"),e[23]=b,e[24]=P):P=e[24];let W;e[25]!==b?(W=b("New query"),e[25]=b,e[26]=W):W=e[26];let F;e[27]===Symbol.for("react.memo_cache_sentinel")?(F=(0,u.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,u.jsx)("path",{d:"M12 5v14M5 12h14"})}),e[27]=F):F=e[27];let L;e[28]!==d||e[29]!==P||e[30]!==W?(L=(0,u.jsx)("button",{"aria-label":P,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:d,title:W,type:"button",children:F}),e[28]=d,e[29]=P,e[30]=W,e[31]=L):L=e[31],e[32]!==L||e[33]!==K?(y=(0,u.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border p-2",children:[K,L]}),e[32]=L,e[33]=K,e[34]=y):y=e[34],p="flex flex-1 flex-col gap-4 overflow-y-auto p-2";let M;e[35]!==b?(M=b("Private"),e[35]=b,e[36]=M):M=e[36];let z;e[37]!==M?(z=(0,u.jsx)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:M}),e[37]=M,e[38]=z):z=e[38],g=(0,u.jsxs)("div",{children:[z,_.length===0?(0,u.jsx)("p",{className:"px-1 py-2 text-xs text-muted-foreground","data-testid":"sql-private-empty",children:b("No saved queries yet \u2014 they save to this browser as you type.")}):(0,u.jsx)("ul",{className:"flex flex-col gap-px","data-testid":"sql-private",ref:r,children:_.map($=>(0,u.jsx)(bo,{active:n===$.id,onDelete:l,onSelect:x,query:$},$.id))})]}),e[0]=n,e[1]=r,e[2]=l,e[3]=d,e[4]=m,e[5]=x,e[6]=h,e[7]=v,e[8]=N,e[9]=b,e[10]=w,e[11]=p,e[12]=S,e[13]=y,e[14]=g}else w=e[10],p=e[11],S=e[12],y=e[13],g=e[14];let C;e[39]!==b?(C=b("Reference"),e[39]=b,e[40]=C):C=e[40];let k;e[41]!==C?(k=(0,u.jsx)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:C}),e[41]=C,e[42]=k):k=e[42];let q;e[43]!==c?(q=Tt.map(_=>(0,u.jsx)("li",{children:(0,u.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":_.sql,onClick:c,type:"button",children:[(0,u.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,u.jsx)("path",{d:"M7 4h7l4 4v12H7zM14 4v4h4"})}),_.label]})},_.label)),e[43]=c,e[44]=q):q=e[44];let E;e[45]!==q?(E=(0,u.jsx)("ul",{className:"flex flex-col gap-px",children:q}),e[45]=q,e[46]=E):E=e[46];let T;e[47]!==k||e[48]!==E?(T=(0,u.jsxs)("div",{children:[k,E]}),e[47]=k,e[48]=E,e[49]=T):T=e[49];let I;e[50]!==t||e[51]!==o||e[52]!==i||e[53]!==w||e[54]!==f||e[55]!==b?(I=t.length>0&&(0,u.jsxs)("div",{children:[(0,u.jsxs)("div",{className:"flex items-center justify-between px-1 pb-1",children:[(0,u.jsx)("p",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:b("History")}),(0,u.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:o,type:"button",children:b("Clear history")})]}),(0,u.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 px-1 pb-1.5 text-[11px] text-muted-foreground",htmlFor:bt,children:[(0,u.jsx)("input",{checked:f,"data-testid":"sql-history-remember",id:bt,onChange:w,type:"checkbox"}),b("Keep history on this browser")]}),(0,u.jsx)("ul",{className:"flex flex-col gap-px","data-testid":"sql-history",children:t.map(_=>(0,u.jsx)("li",{children:(0,u.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":_.sql,"data-testid":"sql-history-item",onClick:i,title:_.sql,type:"button",children:[(0,u.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,u.jsx)("path",{d:"M12 8v4l3 2M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18Z"})}),(0,u.jsx)("span",{className:"truncate font-mono",children:_.sql})]})},`${_.at.toString()}:${_.sql}`))})]}),e[50]=t,e[51]=o,e[52]=i,e[53]=w,e[54]=f,e[55]=b,e[56]=I):I=e[56];let D;e[57]!==p||e[58]!==I||e[59]!==g||e[60]!==T?(D=(0,u.jsxs)("div",{className:p,children:[g,T,I]}),e[57]=p,e[58]=I,e[59]=g,e[60]=T,e[61]=D):D=e[61];let R;return e[62]!==D||e[63]!==S||e[64]!==y?(R=(0,u.jsxs)("aside",{className:S,children:[y,D]}),e[62]=D,e[63]=S,e[64]=y,e[65]=R):R=e[65],R},"hs"),Pe=a(s=>`border-b-2 px-3 py-2 text-sm outline-none transition-colors ${s?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,"qe"),vo=a(s=>{let e=(0,Z.c)(96),{assistant:n,chart:t,className:r,error:o,onFormat:l,onInferChart:i,onRun:c,onSelectStatement:d,onShardKeyChange:m,onShowChart:x,onShowExplain:h,onShowResults:v,onToggleSplit:f,pane:N,result:b,running:w,script:p,shardKey:S,splitView:y}=s,g=ae(),C=N==="results",k;e[0]!==C?(k=Pe(C),e[0]=C,e[1]=k):k=e[1];let q;e[2]!==g?(q=g("Results"),e[2]=g,e[3]=q):q=e[3];let E;e[4]!==v||e[5]!==k||e[6]!==q?(E=(0,u.jsx)("button",{className:k,"data-testid":"sql-tab-results",onClick:v,type:"button",children:q}),e[4]=v,e[5]=k,e[6]=q,e[7]=E):E=e[7];let T=N==="chart",I;e[8]!==T?(I=Pe(T),e[8]=T,e[9]=I):I=e[9];let D;e[10]!==g?(D=g("Chart"),e[10]=g,e[11]=D):D=e[11];let R;e[12]!==x||e[13]!==I||e[14]!==D?(R=(0,u.jsx)("button",{className:I,"data-testid":"sql-tab-chart",onClick:x,type:"button",children:D}),e[12]=x,e[13]=I,e[14]=D,e[15]=R):R=e[15];let _;e[16]!==n||e[17]!==i||e[18]!==N||e[19]!==b||e[20]!==g?(_=!n.unavailable&&N==="chart"&&b!==null&&(0,u.jsx)("button",{className:Pe(!1),"data-testid":"sql-infer-chart",disabled:n.pending("chart"),onClick:i,type:"button",children:n.pending("chart")?g("Thinking\u2026"):g("Suggest chart")}),e[16]=n,e[17]=i,e[18]=N,e[19]=b,e[20]=g,e[21]=_):_=e[21];let Q=N==="explain",j;e[22]!==Q?(j=Pe(Q),e[22]=Q,e[23]=j):j=e[23];let K;e[24]!==g?(K=g("Explain"),e[24]=g,e[25]=K):K=e[25];let P;e[26]!==h||e[27]!==j||e[28]!==K?(P=(0,u.jsx)("button",{className:j,"data-testid":"sql-tab-explain",onClick:h,type:"button",children:K}),e[26]=h,e[27]=j,e[28]=K,e[29]=P):P=e[29];let W;e[30]!==g?(W=g("Split editor and results"),e[30]=g,e[31]=W):W=e[31];let F=`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 ${y?"bg-accent text-foreground":"text-muted-foreground"}`,L;e[32]!==g?(L=g("Split editor and results"),e[32]=g,e[33]=L):L=e[33];let M;e[34]===Symbol.for("react.memo_cache_sentinel")?(M=(0,u.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,u.jsx)("rect",{height:"16",rx:"2",width:"18",x:"3",y:"4"}),(0,u.jsx)("path",{d:"M12 4v16"})]}),e[34]=M):M=e[34];let z;e[35]!==f||e[36]!==y||e[37]!==W||e[38]!==F||e[39]!==L?(z=(0,u.jsx)("button",{"aria-label":W,"aria-pressed":y,className:F,"data-testid":"sql-split-toggle",onClick:f,title:L,type:"button",children:M}),e[35]=f,e[36]=y,e[37]=W,e[38]=F,e[39]=L,e[40]=z):z=e[40];let $;e[41]!==b?($=b!==null&&b.columns.length>0&&(0,u.jsx)(at,{columns:b.columns,name:"query-result",rows:b.rows}),e[41]=b,e[42]=$):$=e[42];let te;e[43]!==g?(te=g("Format"),e[43]=g,e[44]=te):te=e[44];let V;e[45]!==l||e[46]!==w||e[47]!==te?(V=(0,u.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:w,onClick:l,type:"button",children:te}),e[45]=l,e[46]=w,e[47]=te,e[48]=V):V=e[48];let ee;e[49]!==m||e[50]!==S?(ee=(0,u.jsx)(rt,{onChange:m,testId:"sql-shard-input",value:S}),e[49]=m,e[50]=S,e[51]=ee):ee=e[51];let A;e[52]!==w||e[53]!==g?(A=g(w?"Running\u2026":"Run"),e[52]=w,e[53]=g,e[54]=A):A=e[54];let U;e[55]===Symbol.for("react.memo_cache_sentinel")?(U=(0,u.jsx)("kbd",{className:"rounded border border-primary-foreground/30 px-1 font-sans text-[10px]",children:"\u2318\u21B5"}),e[55]=U):U=e[55];let G;e[56]!==c||e[57]!==w||e[58]!==A?(G=(0,u.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:w,onClick:c,type:"button",children:[A,U]}),e[56]=c,e[57]=w,e[58]=A,e[59]=G):G=e[59];let Y;e[60]!==z||e[61]!==$||e[62]!==V||e[63]!==ee||e[64]!==G?(Y=(0,u.jsxs)("div",{className:"ms-auto flex items-center gap-2",children:[z,$,V,ee,G]}),e[60]=z,e[61]=$,e[62]=V,e[63]=ee,e[64]=G,e[65]=Y):Y=e[65];let O;e[66]!==P||e[67]!==Y||e[68]!==E||e[69]!==R||e[70]!==_?(O=(0,u.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pe-2",children:[E,R,_,P,Y]}),e[66]=P,e[67]=Y,e[68]=E,e[69]=R,e[70]=_,e[71]=O):O=e[71];let oe;e[72]!==d||e[73]!==p?(oe=p!==void 0&&(0,u.jsx)("div",{className:"flex shrink-0 flex-wrap items-center gap-1 border-b border-border px-3 py-1.5","data-testid":"sql-statements",children:p.runs.map((X,re)=>(0,u.jsx)("button",{"aria-pressed":re===p.selected,className:`rounded-md border px-2 py-0.5 font-mono text-[11px] outline-none transition-colors ${re===p.selected?"border-foreground text-foreground":"border-border text-muted-foreground hover:text-foreground"} ${X.error===null?"":"border-destructive/50 text-destructive"}`,"data-testid":`sql-statement-${re.toString()}`,onClick:a(()=>{d(re)},"onClick"),title:X.sql,type:"button",children:re+1},`${re.toString()}:${X.sql}`))}),e[72]=d,e[73]=p,e[74]=oe):oe=e[74];let se;e[75]!==o?(se=o!==null&&(0,u.jsx)(st,{className:"m-3 font-mono text-xs",testId:"sql-error",variant:"destructive",children:o}),e[75]=o,e[76]=se):se=e[76];let le;e[77]!==o||e[78]!==b||e[79]!==g?(le=o===null&&b===null&&(0,u.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-empty",children:g("Click Run to execute your query.")}),e[77]=o,e[78]=b,e[79]=g,e[80]=le):le=e[80];let ie;e[81]!==t||e[82]!==o||e[83]!==N||e[84]!==b||e[85]!==g?(ie=o===null&&b!==null&&(0,u.jsxs)("div",{"data-testid":"sql-result",children:[N==="chart"?(0,u.jsx)(ct,{axes:t,result:b}):(0,u.jsx)(dt,{result:b}),(0,u.jsx)("p",{className:"border-t border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"sql-count",children:b.truncated?g("Showing the first {max} of {count} rows.",{count:b.rowCount,max:b.rows.length}):g("{count} rows",{count:b.rowCount})})]}),e[81]=t,e[82]=o,e[83]=N,e[84]=b,e[85]=g,e[86]=ie):ie=e[86];let H;e[87]!==se||e[88]!==le||e[89]!==ie?(H=(0,u.jsxs)("div",{className:"min-h-0 flex-1 overflow-auto",children:[se,le,ie]}),e[87]=se,e[88]=le,e[89]=ie,e[90]=H):H=e[90];let J;return e[91]!==r||e[92]!==O||e[93]!==oe||e[94]!==H?(J=(0,u.jsxs)("div",{className:r,children:[O,oe,H]}),e[91]=r,e[92]=O,e[93]=oe,e[94]=H,e[95]=J):J=e[95],J},"bs"),yo=a((s,e)=>s.trim()===""?e:(s.split(`
|
|
14
|
+
`).length;E="flex min-h-0 min-w-0 flex-1 flex-col",e[17]!==n||e[18]!==l||e[19]!==f?(T=(0,u.jsx)(no,{assistant:n,failed:l,onGenerated:f}),e[17]=n,e[18]=l,e[19]=f,e[20]=T):T=e[20],e[21]!==n||e[22]!==o.length||e[23]!==m||e[24]!==h||e[25]!==v?(I=m!==null&&(0,u.jsx)(mo,{onAccept:h,onCancel:v,rpc:n,source:m.text,whole:m.start===0&&m.end===o.length},`${m.start.toString()}-${m.end.toString()}`),e[21]=n,e[22]=o.length,e[23]=m,e[24]=h,e[25]=v,e[26]=I):I=e[26],q="flex min-h-0 min-w-0 flex-1",S="true",y="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",g=d,C=fo,k=Array.from({length:$},po),e[0]=n,e[1]=o,e[2]=l,e[3]=d,e[4]=m,e[5]=h,e[6]=v,e[7]=f,e[8]=S,e[9]=y,e[10]=g,e[11]=C,e[12]=k,e[13]=q,e[14]=E,e[15]=T,e[16]=I}else S=e[8],y=e[9],g=e[10],C=e[11],k=e[12],q=e[13],E=e[14],T=e[15],I=e[16];let D;e[27]!==S||e[28]!==y||e[29]!==g||e[30]!==C||e[31]!==k?(D=(0,u.jsx)("div",{"aria-hidden":S,className:y,ref:g,style:C,children:k}),e[27]=S,e[28]=y,e[29]=g,e[30]=C,e[31]=k,e[32]=D):D=e[32];let R;e[33]!==r||e[34]!==o||e[35]!==w?(R=(0,u.jsx)(oo,{diagnostics:r,draft:o,scrollRef:w}),e[33]=r,e[34]=o,e[35]=w,e[36]=R):R=e[36];let _;e[37]!==t||e[38]!==x?(_=t===null?void 0:`${x}-opt-${t.active.toString()}`,e[37]=t,e[38]=x,e[39]=_):_=e[39];let Q=t===null?void 0:x,j=t!==null,K;e[40]!==p?(K=p("SQL query"),e[40]=p,e[41]=K):K=e[41];let P;e[42]!==o||e[43]!==c||e[44]!==i.onBlur||e[45]!==i.onChange||e[46]!==i.onKeyDown||e[47]!==i.onScroll||e[48]!==i.onSelect||e[49]!==_||e[50]!==Q||e[51]!==j||e[52]!==K?(P=(0,u.jsx)("textarea",{"aria-activedescendant":_,"aria-autocomplete":"list","aria-controls":Q,"aria-expanded":j,"aria-label":K,className:`relative size-full resize-none bg-transparent outline-none ${Ze}`,"data-testid":"sql-input",onBlur:i.onBlur,onChange:i.onChange,onKeyDown:i.onKeyDown,onScroll:i.onScroll,onSelect:i.onSelect,placeholder:"SELECT * FROM \u2026",ref:c,role:"combobox",spellCheck:!1,value:o}),e[42]=o,e[43]=c,e[44]=i.onBlur,e[45]=i.onChange,e[46]=i.onKeyDown,e[47]=i.onScroll,e[48]=i.onSelect,e[49]=_,e[50]=Q,e[51]=j,e[52]=K,e[53]=P):P=e[53];let W;e[54]!==t||e[55]!==x||e[56]!==N?(W=(0,u.jsx)(Ln,{listboxId:x,onPick:N,state:t}),e[54]=t,e[55]=x,e[56]=N,e[57]=W):W=e[57];let F;e[58]!==R||e[59]!==P||e[60]!==W?(F=(0,u.jsxs)("div",{className:"relative min-w-0 flex-1 bg-background",children:[R,P,W]}),e[58]=R,e[59]=P,e[60]=W,e[61]=F):F=e[61];let L;e[62]!==D||e[63]!==F||e[64]!==q?(L=(0,u.jsxs)("div",{className:q,children:[D,F]}),e[62]=D,e[63]=F,e[64]=q,e[65]=L):L=e[65];let M;e[66]!==r||e[67]!==b?(M=(0,u.jsx)(so,{diagnostics:r,onSelect:b}),e[66]=r,e[67]=b,e[68]=M):M=e[68];let z;return e[69]!==L||e[70]!==M||e[71]!==E||e[72]!==T||e[73]!==I?(z=(0,u.jsxs)("div",{className:E,children:[T,I,L,M]}),e[69]=L,e[70]=M,e[71]=E,e[72]=T,e[73]=I,e[74]=z):z=e[74],z},"us");function po(s,e){return(0,u.jsx)("div",{children:e+1},e)}a(po,"fs");var Tt=[{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;"}],bo=a(s=>{let e=(0,Z.c)(29),{active:n,onDelete:t,onSelect:r,query:o}=s,l=ae(),i;e[0]!==r||e[1]!==o.id?(i=a(()=>{r(o.id)},"i"),e[0]=r,e[1]=o.id,e[2]=i):i=e[2];let c=i,d;e[3]!==t||e[4]!==o.id?(d=a(C=>{C.stopPropagation(),t(o.id)},"a"),e[3]=t,e[4]=o.id,e[5]=d):d=e[5];let m=d,x=n?"bg-sidebar-accent font-medium text-foreground":"text-muted-foreground",h;e[6]!==x?(h=ue("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",x),e[6]=x,e[7]=h):h=e[7];let v=`sql-query-${o.id}`,f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=(0,u.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,u.jsx)("path",{d:"M4 6h16M4 12h10M4 18h7"})}),e[8]=f):f=e[8];let N;e[9]!==o.name?(N=(0,u.jsx)("span",{className:"truncate",children:o.name}),e[9]=o.name,e[10]=N):N=e[10];let b;e[11]!==n||e[12]!==c||e[13]!==h||e[14]!==v||e[15]!==N?(b=(0,u.jsxs)("button",{"aria-pressed":n,className:h,"data-testid":v,onClick:c,type:"button",children:[f,N]}),e[11]=n,e[12]=c,e[13]=h,e[14]=v,e[15]=N,e[16]=b):b=e[16];let w;e[17]!==l?(w=l("Delete query"),e[17]=l,e[18]=w):w=e[18];let p;e[19]!==l?(p=l("Delete query"),e[19]=l,e[20]=p):p=e[20];let S;e[21]===Symbol.for("react.memo_cache_sentinel")?(S=(0,u.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,u.jsx)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[21]=S):S=e[21];let y;e[22]!==m||e[23]!==p||e[24]!==w?(y=(0,u.jsx)("button",{"aria-label":w,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:m,title:p,type:"button",children:S}),e[22]=m,e[23]=p,e[24]=w,e[25]=y):y=e[25];let g;return e[26]!==y||e[27]!==b?(g=(0,u.jsxs)("li",{className:"group/q flex items-center",children:[b,y]}),e[26]=y,e[27]=b,e[28]=g):g=e[28],g},"ms"),bt="sql-history-remember",go=a((s,e)=>{let n=e.trim().toLowerCase();return n===""?[...s]:s.filter(t=>t.name.toLowerCase().includes(n))},"ps"),xo=a(s=>{let e=(0,Z.c)(66),{activeId:n,history:t,listRef:r,onClearHistory:o,onDelete:l,onLoadHistory:i,onLoadTemplate:c,onNew:d,onSearchChange:m,onSelect:x,onToggleRememberHistory:h,queries:v,rememberHistory:f,search:N}=s,b=ae(),w,p,S,y,g;if(e[0]!==n||e[1]!==r||e[2]!==l||e[3]!==d||e[4]!==m||e[5]!==x||e[6]!==h||e[7]!==v||e[8]!==N||e[9]!==b){let _=go(v,N),Q;e[15]!==h?(Q=a($=>{h($.target.checked)},"F"),e[15]=h,e[16]=Q):Q=e[16],w=Q,S="flex h-full w-64 shrink-0 flex-col border-e border-border bg-sidebar";let j;e[17]!==b?(j=b("Search queries\u2026"),e[17]=b,e[18]=j):j=e[18];let K;e[19]!==m||e[20]!==N||e[21]!==j?(K=(0,u.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:m,placeholder:j,type:"text",value:N}),e[19]=m,e[20]=N,e[21]=j,e[22]=K):K=e[22];let P;e[23]!==b?(P=b("New query"),e[23]=b,e[24]=P):P=e[24];let W;e[25]!==b?(W=b("New query"),e[25]=b,e[26]=W):W=e[26];let F;e[27]===Symbol.for("react.memo_cache_sentinel")?(F=(0,u.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,u.jsx)("path",{d:"M12 5v14M5 12h14"})}),e[27]=F):F=e[27];let L;e[28]!==d||e[29]!==P||e[30]!==W?(L=(0,u.jsx)("button",{"aria-label":P,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:d,title:W,type:"button",children:F}),e[28]=d,e[29]=P,e[30]=W,e[31]=L):L=e[31],e[32]!==L||e[33]!==K?(y=(0,u.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border p-2",children:[K,L]}),e[32]=L,e[33]=K,e[34]=y):y=e[34],p="flex flex-1 flex-col gap-4 overflow-y-auto p-2";let M;e[35]!==b?(M=b("Private"),e[35]=b,e[36]=M):M=e[36];let z;e[37]!==M?(z=(0,u.jsx)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:M}),e[37]=M,e[38]=z):z=e[38],g=(0,u.jsxs)("div",{children:[z,_.length===0?(0,u.jsx)("p",{className:"px-1 py-2 text-xs text-muted-foreground","data-testid":"sql-private-empty",children:b("No saved queries yet \u2014 they save to this browser as you type.")}):(0,u.jsx)("ul",{className:"flex flex-col gap-px","data-testid":"sql-private",ref:r,children:_.map($=>(0,u.jsx)(bo,{active:n===$.id,onDelete:l,onSelect:x,query:$},$.id))})]}),e[0]=n,e[1]=r,e[2]=l,e[3]=d,e[4]=m,e[5]=x,e[6]=h,e[7]=v,e[8]=N,e[9]=b,e[10]=w,e[11]=p,e[12]=S,e[13]=y,e[14]=g}else w=e[10],p=e[11],S=e[12],y=e[13],g=e[14];let C;e[39]!==b?(C=b("Reference"),e[39]=b,e[40]=C):C=e[40];let k;e[41]!==C?(k=(0,u.jsx)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:C}),e[41]=C,e[42]=k):k=e[42];let q;e[43]!==c?(q=Tt.map(_=>(0,u.jsx)("li",{children:(0,u.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":_.sql,onClick:c,type:"button",children:[(0,u.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,u.jsx)("path",{d:"M7 4h7l4 4v12H7zM14 4v4h4"})}),_.label]})},_.label)),e[43]=c,e[44]=q):q=e[44];let E;e[45]!==q?(E=(0,u.jsx)("ul",{className:"flex flex-col gap-px",children:q}),e[45]=q,e[46]=E):E=e[46];let T;e[47]!==k||e[48]!==E?(T=(0,u.jsxs)("div",{children:[k,E]}),e[47]=k,e[48]=E,e[49]=T):T=e[49];let I;e[50]!==t||e[51]!==o||e[52]!==i||e[53]!==w||e[54]!==f||e[55]!==b?(I=t.length>0&&(0,u.jsxs)("div",{children:[(0,u.jsxs)("div",{className:"flex items-center justify-between px-1 pb-1",children:[(0,u.jsx)("p",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:b("History")}),(0,u.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:o,type:"button",children:b("Clear history")})]}),(0,u.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 px-1 pb-1.5 text-[11px] text-muted-foreground",htmlFor:bt,children:[(0,u.jsx)("input",{checked:f,"data-testid":"sql-history-remember",id:bt,onChange:w,type:"checkbox"}),b("Keep history on this browser")]}),(0,u.jsx)("ul",{className:"flex flex-col gap-px","data-testid":"sql-history",children:t.map(_=>(0,u.jsx)("li",{children:(0,u.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":_.sql,"data-testid":"sql-history-item",onClick:i,title:_.sql,type:"button",children:[(0,u.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,u.jsx)("path",{d:"M12 8v4l3 2M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18Z"})}),(0,u.jsx)("span",{className:"truncate font-mono",children:_.sql})]})},`${_.at.toString()}:${_.sql}`))})]}),e[50]=t,e[51]=o,e[52]=i,e[53]=w,e[54]=f,e[55]=b,e[56]=I):I=e[56];let D;e[57]!==p||e[58]!==I||e[59]!==g||e[60]!==T?(D=(0,u.jsxs)("div",{className:p,children:[g,T,I]}),e[57]=p,e[58]=I,e[59]=g,e[60]=T,e[61]=D):D=e[61];let R;return e[62]!==D||e[63]!==S||e[64]!==y?(R=(0,u.jsxs)("aside",{className:S,children:[y,D]}),e[62]=D,e[63]=S,e[64]=y,e[65]=R):R=e[65],R},"hs"),Pe=a(s=>`border-b-2 px-3 py-2 text-sm outline-none transition-colors ${s?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,"qe"),vo=a(s=>{let e=(0,Z.c)(96),{assistant:n,chart:t,className:r,error:o,onFormat:l,onInferChart:i,onRun:c,onSelectStatement:d,onShardKeyChange:m,onShowChart:x,onShowExplain:h,onShowResults:v,onToggleSplit:f,pane:N,result:b,running:w,script:p,shardKey:S,splitView:y}=s,g=ae(),C=N==="results",k;e[0]!==C?(k=Pe(C),e[0]=C,e[1]=k):k=e[1];let q;e[2]!==g?(q=g("Results"),e[2]=g,e[3]=q):q=e[3];let E;e[4]!==v||e[5]!==k||e[6]!==q?(E=(0,u.jsx)("button",{className:k,"data-testid":"sql-tab-results",onClick:v,type:"button",children:q}),e[4]=v,e[5]=k,e[6]=q,e[7]=E):E=e[7];let T=N==="chart",I;e[8]!==T?(I=Pe(T),e[8]=T,e[9]=I):I=e[9];let D;e[10]!==g?(D=g("Chart"),e[10]=g,e[11]=D):D=e[11];let R;e[12]!==x||e[13]!==I||e[14]!==D?(R=(0,u.jsx)("button",{className:I,"data-testid":"sql-tab-chart",onClick:x,type:"button",children:D}),e[12]=x,e[13]=I,e[14]=D,e[15]=R):R=e[15];let _;e[16]!==n||e[17]!==i||e[18]!==N||e[19]!==b||e[20]!==g?(_=!n.unavailable&&N==="chart"&&b!==null&&(0,u.jsx)("button",{className:Pe(!1),"data-testid":"sql-infer-chart",disabled:n.pending("chart"),onClick:i,type:"button",children:n.pending("chart")?g("Thinking\u2026"):g("Suggest chart")}),e[16]=n,e[17]=i,e[18]=N,e[19]=b,e[20]=g,e[21]=_):_=e[21];let Q=N==="explain",j;e[22]!==Q?(j=Pe(Q),e[22]=Q,e[23]=j):j=e[23];let K;e[24]!==g?(K=g("Explain"),e[24]=g,e[25]=K):K=e[25];let P;e[26]!==h||e[27]!==j||e[28]!==K?(P=(0,u.jsx)("button",{className:j,"data-testid":"sql-tab-explain",onClick:h,type:"button",children:K}),e[26]=h,e[27]=j,e[28]=K,e[29]=P):P=e[29];let W;e[30]!==g?(W=g("Split editor and results"),e[30]=g,e[31]=W):W=e[31];let F=`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 ${y?"bg-accent text-foreground":"text-muted-foreground"}`,L;e[32]!==g?(L=g("Split editor and results"),e[32]=g,e[33]=L):L=e[33];let M;e[34]===Symbol.for("react.memo_cache_sentinel")?(M=(0,u.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,u.jsx)("rect",{height:"16",rx:"2",width:"18",x:"3",y:"4"}),(0,u.jsx)("path",{d:"M12 4v16"})]}),e[34]=M):M=e[34];let z;e[35]!==f||e[36]!==y||e[37]!==W||e[38]!==F||e[39]!==L?(z=(0,u.jsx)("button",{"aria-label":W,"aria-pressed":y,className:F,"data-testid":"sql-split-toggle",onClick:f,title:L,type:"button",children:M}),e[35]=f,e[36]=y,e[37]=W,e[38]=F,e[39]=L,e[40]=z):z=e[40];let $;e[41]!==b?($=b!==null&&b.columns.length>0&&(0,u.jsx)(at,{columns:b.columns,name:"query-result",rows:b.rows}),e[41]=b,e[42]=$):$=e[42];let te;e[43]!==g?(te=g("Format"),e[43]=g,e[44]=te):te=e[44];let V;e[45]!==l||e[46]!==w||e[47]!==te?(V=(0,u.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:w,onClick:l,type:"button",children:te}),e[45]=l,e[46]=w,e[47]=te,e[48]=V):V=e[48];let ee;e[49]!==m||e[50]!==S?(ee=(0,u.jsx)(rt,{onChange:m,testId:"sql-shard-input",value:S}),e[49]=m,e[50]=S,e[51]=ee):ee=e[51];let A;e[52]!==w||e[53]!==g?(A=g(w?"Running\u2026":"Run"),e[52]=w,e[53]=g,e[54]=A):A=e[54];let U;e[55]===Symbol.for("react.memo_cache_sentinel")?(U=(0,u.jsx)("kbd",{className:"rounded border border-primary-foreground/30 px-1 font-sans text-[10px]",children:"\u2318\u21B5"}),e[55]=U):U=e[55];let G;e[56]!==c||e[57]!==w||e[58]!==A?(G=(0,u.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:w,onClick:c,type:"button",children:[A,U]}),e[56]=c,e[57]=w,e[58]=A,e[59]=G):G=e[59];let Y;e[60]!==z||e[61]!==$||e[62]!==V||e[63]!==ee||e[64]!==G?(Y=(0,u.jsxs)("div",{className:"ms-auto flex items-center gap-2",children:[z,$,V,ee,G]}),e[60]=z,e[61]=$,e[62]=V,e[63]=ee,e[64]=G,e[65]=Y):Y=e[65];let O;e[66]!==P||e[67]!==Y||e[68]!==E||e[69]!==R||e[70]!==_?(O=(0,u.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pe-2",children:[E,R,_,P,Y]}),e[66]=P,e[67]=Y,e[68]=E,e[69]=R,e[70]=_,e[71]=O):O=e[71];let oe;e[72]!==d||e[73]!==p?(oe=p!==void 0&&(0,u.jsx)("div",{className:"flex shrink-0 flex-wrap items-center gap-1 border-b border-border px-3 py-1.5","data-testid":"sql-statements",children:p.runs.map((X,re)=>(0,u.jsx)("button",{"aria-pressed":re===p.selected,className:`rounded-md border px-2 py-0.5 font-mono text-[11px] outline-none transition-colors ${re===p.selected?"border-foreground text-foreground":"border-border text-muted-foreground hover:text-foreground"} ${X.error===null?"":"border-destructive/50 text-destructive"}`,"data-testid":`sql-statement-${re.toString()}`,onClick:a(()=>{d(re)},"onClick"),title:X.sql,type:"button",children:re+1},`${re.toString()}:${X.sql}`))}),e[72]=d,e[73]=p,e[74]=oe):oe=e[74];let se;e[75]!==o?(se=o!==null&&(0,u.jsx)(st,{className:"m-3 font-mono text-xs",testId:"sql-error",variant:"destructive",children:o}),e[75]=o,e[76]=se):se=e[76];let le;e[77]!==o||e[78]!==b||e[79]!==g?(le=o===null&&b===null&&(0,u.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-empty",children:g("Click Run to execute your query.")}),e[77]=o,e[78]=b,e[79]=g,e[80]=le):le=e[80];let ie;e[81]!==t||e[82]!==o||e[83]!==N||e[84]!==b||e[85]!==g?(ie=o===null&&b!==null&&(0,u.jsxs)("div",{"data-testid":"sql-result",children:[N==="chart"?(0,u.jsx)(ct,{axes:t,result:b}):(0,u.jsx)(dt,{result:b}),(0,u.jsx)("p",{className:"border-t border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"sql-count",children:b.truncated?g("Showing the first {max} rows.",{max:b.rows.length}):g("{count} rows",{count:b.rowCount})})]}),e[81]=t,e[82]=o,e[83]=N,e[84]=b,e[85]=g,e[86]=ie):ie=e[86];let H;e[87]!==se||e[88]!==le||e[89]!==ie?(H=(0,u.jsxs)("div",{className:"min-h-0 flex-1 overflow-auto",children:[se,le,ie]}),e[87]=se,e[88]=le,e[89]=ie,e[90]=H):H=e[90];let J;return e[91]!==r||e[92]!==O||e[93]!==oe||e[94]!==H?(J=(0,u.jsxs)("div",{className:r,children:[O,oe,H]}),e[91]=r,e[92]=O,e[93]=oe,e[94]=H,e[95]=J):J=e[95],J},"bs"),yo=a((s,e)=>s.trim()===""?e:(s.split(`
|
|
15
15
|
`)[0]??s).slice(0,24),"gs"),wo=a(s=>{s?.focus(),s?.select()},"xs"),So=a(s=>{let e=(0,Z.c)(14),{initial:n,onCancel:t,onCommit:r,placeholder:o,testId:l}=s,i=ae(),c;e[0]!==r?(c=a(f=>{r(f.currentTarget.value.trim())},"c"),e[0]=r,e[1]=c):c=e[1];let d=c,m;e[2]!==t||e[3]!==r?(m=a(f=>{f.key==="Enter"?r(f.currentTarget.value.trim()):f.key==="Escape"&&t()},"f"),e[2]=t,e[3]=r,e[4]=m):m=e[4];let x=m,h;e[5]!==i?(h=i("Tab title"),e[5]=i,e[6]=h):h=e[6];let v;return e[7]!==n||e[8]!==d||e[9]!==x||e[10]!==o||e[11]!==h||e[12]!==l?(v=(0,u.jsx)("input",{"aria-label":h,className:"w-40 rounded border border-ring bg-background px-1 py-0.5 text-xs outline-none","data-testid":l,defaultValue:n,onBlur:d,onKeyDown:x,placeholder:o,ref:wo,type:"text"}),e[7]=n,e[8]=d,e[9]=x,e[10]=o,e[11]=h,e[12]=l,e[13]=v):v=e[13],v},"ys"),Co=a(s=>{let e=(0,Z.c)(29),{idBase:n,onDiscard:t,onKeep:r}=s,o=ae(),l=`sql-tab-close-prompt-${n}`,i;e[0]!==o?(i=o("Discard?"),e[0]=o,e[1]=i):i=e[1];let c;e[2]!==i?(c=(0,u.jsx)("span",{className:"text-[11px] text-muted-foreground",children:i}),e[2]=i,e[3]=c):c=e[3];let d;e[4]!==o?(d=o("Discard changes"),e[4]=o,e[5]=d):d=e[5];let m=`sql-tab-close-confirm-${n}`,x;e[6]!==o?(x=o("Discard changes"),e[6]=o,e[7]=x):x=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=(0,u.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,u.jsx)("path",{d:"M5 13l4 4L19 7"})}),e[8]=h):h=e[8];let v;e[9]!==t||e[10]!==d||e[11]!==m||e[12]!==x?(v=(0,u.jsx)("button",{"aria-label":d,className:"flex size-5 items-center justify-center rounded text-destructive hover:bg-destructive/10","data-testid":m,onClick:t,title:x,type:"button",children:h}),e[9]=t,e[10]=d,e[11]=m,e[12]=x,e[13]=v):v=e[13];let f;e[14]!==o?(f=o("Keep editing"),e[14]=o,e[15]=f):f=e[15];let N=`sql-tab-close-cancel-${n}`,b;e[16]!==o?(b=o("Keep editing"),e[16]=o,e[17]=b):b=e[17];let w;e[18]===Symbol.for("react.memo_cache_sentinel")?(w=(0,u.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,u.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})}),e[18]=w):w=e[18];let p;e[19]!==r||e[20]!==N||e[21]!==b||e[22]!==f?(p=(0,u.jsx)("button",{"aria-label":f,className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent","data-testid":N,onClick:r,title:b,type:"button",children:w}),e[19]=r,e[20]=N,e[21]=b,e[22]=f,e[23]=p):p=e[23];let S;return e[24]!==l||e[25]!==p||e[26]!==c||e[27]!==v?(S=(0,u.jsxs)("span",{className:"flex shrink-0 items-center gap-1","data-testid":l,role:"group",children:[c,v,p]}),e[24]=l,e[25]=p,e[26]=c,e[27]=v,e[28]=S):S=e[28],S},"vs"),ko=a(s=>{let e=(0,Z.c)(47),{active:n,canClose:t,onClose:r,onMenu:o,onRename:l,onSelect:i,tab:c}=s,d=ae(),[m,x]=(0,B.useState)(!1),[h,v]=(0,B.useState)(!1),f;e[0]!==o||e[1]!==c.id?(f=a($=>{o(c.id,$)},"d"),e[0]=o,e[1]=c.id,e[2]=f):f=e[2];let N=f,b;e[3]!==i||e[4]!==c.id?(b=a(()=>{i(c.id)},"m"),e[3]=i,e[4]=c.id,e[5]=b):b=e[5];let w=b,p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=a(()=>{x(!0)},"b"),e[6]=p):p=e[6];let S=p,y;e[7]!==r||e[8]!==c?(y=a($=>{$.stopPropagation(),qt(c)?v(!0):r(c.id)},"v"),e[7]=r,e[8]=c,e[9]=y):y=e[9];let g=y,C;e[10]!==r||e[11]!==c.id?(C=a($=>{$.stopPropagation(),v(!1),r(c.id)},"E"),e[10]=r,e[11]=c.id,e[12]=C):C=e[12];let k=C,q;e[13]===Symbol.for("react.memo_cache_sentinel")?(q=a($=>{$.stopPropagation(),v(!1)},"T"),e[13]=q):q=e[13];let E=q,T;e[14]!==l||e[15]!==c.id?(T=a($=>{l(c.id,$),x(!1)},"R"),e[14]=l,e[15]=c.id,e[16]=T):T=e[16];let I=T,D;e[17]===Symbol.for("react.memo_cache_sentinel")?(D=a(()=>{x(!1)},"_"),e[17]=D):D=e[17];let R=D,_;e[18]!==c.name?(_=c.name.trim(),e[18]=c.name,e[19]=_):_=e[19];let Q=_,j;e[20]!==d||e[21]!==c.sql?(j=yo(c.sql,d("Untitled")),e[20]=d,e[21]=c.sql,e[22]=j):j=e[22];let K=j,P=n?"bg-background text-foreground":"bg-muted/40 text-muted-foreground hover:text-foreground",W;e[23]!==P?(W=ue("group/tab flex shrink-0 items-center gap-1 border-e border-border ps-3 pe-1.5 text-xs",P),e[23]=P,e[24]=W):W=e[24];let F=`sql-tab-${c.id}`,L;e[25]!==n||e[26]!==I||e[27]!==Q||e[28]!==K||e[29]!==m||e[30]!==w||e[31]!==d||e[32]!==c.id?(L=m?(0,u.jsx)(So,{initial:Q,onCancel:R,onCommit:I,placeholder:K,testId:`sql-tab-rename-${c.id}`}):(0,u.jsx)("button",{"aria-pressed":n,className:"max-w-40 truncate py-1.5 outline-none","data-testid":`sql-tab-select-${c.id}`,onClick:w,onDoubleClick:S,title:d("Double-click to rename"),type:"button",children:Q===""?K:Q}),e[25]=n,e[26]=I,e[27]=Q,e[28]=K,e[29]=m,e[30]=w,e[31]=d,e[32]=c.id,e[33]=L):L=e[33];let M;e[34]!==t||e[35]!==k||e[36]!==h||e[37]!==g||e[38]!==d||e[39]!==c.id?(M=t&&(h?(0,u.jsx)(Co,{idBase:c.id,onDiscard:k,onKeep:E}):(0,u.jsx)("button",{"aria-label":d("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:g,title:d("Close tab"),type:"button",children:(0,u.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,u.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})})})),e[34]=t,e[35]=k,e[36]=h,e[37]=g,e[38]=d,e[39]=c.id,e[40]=M):M=e[40];let z;return e[41]!==N||e[42]!==W||e[43]!==F||e[44]!==L||e[45]!==M?(z=(0,u.jsxs)("div",{className:W,"data-testid":F,onContextMenu:N,children:[L,M]}),e[41]=N,e[42]=W,e[43]=F,e[44]=L,e[45]=M,e[46]=z):z=e[46],z},"Ss"),No=a(s=>{let e=(0,Z.c)(43),{model:n,onSelect:t}=s,r=ae(),{activeTab:o,addEditorTab:l,cancelBulk:i,closeEditorTab:c,closeTabMenu:d,confirmBulk:m,menuStyle:x,onBackdropContextMenu:h,onCloseAll:v,onCloseOthers:f,onCloseToRight:N,openTabMenu:b,pendingBulk:w,renameTab:p,tabMenu:S,tabs:y}=n,g;if(e[0]!==o||e[1]!==c||e[2]!==t||e[3]!==b||e[4]!==p||e[5]!==y){let _;e[7]!==o||e[8]!==c||e[9]!==t||e[10]!==b||e[11]!==p||e[12]!==y.length?(_=a(Q=>(0,u.jsx)(ko,{active:Q.id===o.id,canClose:y.length>1,onClose:c,onMenu:b,onRename:p,onSelect:t,tab:Q},Q.id),"L"),e[7]=o,e[8]=c,e[9]=t,e[10]=b,e[11]=p,e[12]=y.length,e[13]=_):_=e[13],g=y.map(_),e[0]=o,e[1]=c,e[2]=t,e[3]=b,e[4]=p,e[5]=y,e[6]=g}else g=e[6];let C;e[14]!==r?(C=r("New tab"),e[14]=r,e[15]=C):C=e[15];let k=y.length>=Xe,q;e[16]!==r?(q=r("New tab"),e[16]=r,e[17]=q):q=e[17];let E;e[18]===Symbol.for("react.memo_cache_sentinel")?(E=(0,u.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,u.jsx)("path",{d:"M12 5v14M5 12h14"})}),e[18]=E):E=e[18];let T;e[19]!==l||e[20]!==C||e[21]!==k||e[22]!==q?(T=(0,u.jsx)("button",{"aria-label":C,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:k,onClick:l,title:q,type:"button",children:E}),e[19]=l,e[20]=C,e[21]=k,e[22]=q,e[23]=T):T=e[23];let I;e[24]!==g||e[25]!==T?(I=(0,u.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:[g,T]}),e[24]=g,e[25]=T,e[26]=I):I=e[26];let D;e[27]!==i||e[28]!==d||e[29]!==m||e[30]!==x||e[31]!==h||e[32]!==v||e[33]!==f||e[34]!==N||e[35]!==w||e[36]!==r||e[37]!==S||e[38]!==y?(D=S!==null&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"fixed inset-0 z-40","data-testid":"sql-tab-menu-backdrop",onClick:d,onContextMenu:h,role:"presentation"}),(0,u.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:x,children:w===null?(0,u.jsxs)(u.Fragment,{children:[(0,u.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:y.length<=1,onClick:f,role:"menuitem",type:"button",children:r("Close other tabs")}),(0,u.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:y.findIndex(_=>_.id===S.id)>=y.length-1,onClick:N,role:"menuitem",type:"button",children:r("Close tabs to the right")}),(0,u.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:v,role:"menuitem",type:"button",children:r("Close all tabs")})]}):(0,u.jsxs)("div",{className:"px-3 py-1.5","data-testid":"sql-tab-menu-confirm",children:[(0,u.jsx)("p",{className:"pb-1.5 text-xs text-muted-foreground",children:r("Discard unsaved tabs?")}),(0,u.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,u.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:m,type:"button",children:r("Discard")}),(0,u.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:i,type:"button",children:r("Cancel")})]})]})})]}),e[27]=i,e[28]=d,e[29]=m,e[30]=x,e[31]=h,e[32]=v,e[33]=f,e[34]=N,e[35]=w,e[36]=r,e[37]=S,e[38]=y,e[39]=D):D=e[39];let R;return e[40]!==I||e[41]!==D?(R=(0,u.jsxs)(u.Fragment,{children:[I,D]}),e[40]=I,e[41]=D,e[42]=R):R=e[42],R},"ws"),qo=Se(ke.runSql),Eo="lunora-studio-sql-split-view",To=a(()=>Ee(Tt[0]?.sql??""),"Ns"),Xo=a(s=>{let e=(0,Z.c)(117),{initialShardKey:n}=s,t=_e(),r=Gn(To),{activeTab:o,output:l,patchActiveOutput:i,patchActiveTab:c,setActiveTabId:d,unlinkQuery:m}=r,x;e[0]!==i||e[1]!==c?(x=a((ne,ce)=>{c({activeId:ce,sql:ne}),i({chart:void 0,error:null,failed:void 0,result:null,script:void 0})},"g"),e[0]=i,e[1]=c,e[2]=x):x=e[2];let h=x,v;e[3]!==h||e[4]!==m?(v={loadIntoActiveTab:h,unlinkQuery:m},e[3]=h,e[4]=m,e[5]=v):v=e[5];let f=eo(v),{recordHistory:N,updateQuerySql:b}=f,w=o.sql,{activeId:p}=o,{chart:S,error:y,failed:g,result:C,running:k}=l,q=l.pane,[E,T]=(0,B.useState)(n??""),[I,D]=Ae(Eo,!1),{probe:R,schema:_}=Dn(E),Q;e[6]!==p||e[7]!==c||e[8]!==b?(Q=a(ne=>{c({sql:ne}),p!==null&&b(p,ne)},"F"),e[6]=p,e[7]=c,e[8]=b,e[9]=Q):Q=e[9];let j=Q,K=gn(w,_,E),P=it(E),W;e[10]!==P||e[11]!==i||e[12]!==C?(W=a(()=>{C!==null&&me((async()=>{let ne=await P.inferChart({columns:C.columns,rowCount:C.rowCount,types:Object.fromEntries(C.columns.map(ce=>[ce,typeof(C.rows[0]?.[ce]??"")]))});i({chart:ne})})())},"W"),e[10]=P,e[11]=i,e[12]=C,e[13]=W):W=e[13];let F=W,L;e[14]!==t||e[15]!==N||e[16]!==E?(L=a(async ne=>{try{let ce=await t.query(qo,{sql:ne},Ce(E));return N(ne),{error:null,result:ce,sql:ne}}catch(ce){return{error:tt(ce),result:null,sql:ne}}},"I"),e[14]=t,e[15]=N,e[16]=E,e[17]=L):L=e[17];let M=L,z;e[18]!==w||e[19]!==i||e[20]!==M||e[21]!==E?(z=a(async ne=>{if(w.trim()==="")return;i({running:!0});let ce=ne==="explain"?Ye(Bt(w),0):wt(w),de=[];for(let Re of ce){let It={error:Re.rejection?.message??"",result:null,sql:Re.sql};de.push(Re.rejection===void 0?await M(Re.sql):It)}ot(E);let et=Math.max(de.length-1,0),ye=de[et];i({chart:void 0,error:ye?.error??null,failed:ye?.error===null||ye===void 0?void 0:{error:ye.error,sql:ye.sql},pane:ne,result:ye?.result??null,running:!1,script:de.length>1?{runs:de,selected:et}:void 0})},"K"),e[18]=w,e[19]=i,e[20]=M,e[21]=E,e[22]=z):z=e[22];let $=z,te;e[23]!==l.script?.runs||e[24]!==i?(te=a(ne=>{let ce=l.script?.runs,de=ce?.[ne];ce===void 0||de===void 0||i({chart:void 0,error:de.error,failed:de.error===null?void 0:{error:de.error,sql:de.sql},result:de.result,script:{runs:ce,selected:ne}})},"ee"),e[23]=l.script?.runs,e[24]=i,e[25]=te):te=e[25];let V=te,ee;e[26]!==$?(ee=a(()=>{me($("results"))},"Z"),e[26]=$,e[27]=ee):ee=e[27];let A=ee,U=!P.unavailable,G;e[28]!==l.pane||e[29]!==$?(G=a(()=>{me($(l.pane))},"j"),e[28]=l.pane,e[29]=$,e[30]=G):G=e[30];let Y;e[31]!==R||e[32]!==_||e[33]!==j||e[34]!==G||e[35]!==U?(Y={inlineEditEnabled:U,onSubmit:G,probe:R,schema:_,setDraft:j},e[31]=R,e[32]=_,e[33]=j,e[34]=G,e[35]=U,e[36]=Y):Y=e[36];let O=Pn(Y),{closeAutocomplete:oe,closeInlineEdit:se}=O,le;e[37]!==w||e[38]!==j?(le=a(()=>{j(Jt(w))},"ie"),e[37]=w,e[38]=j,e[39]=le):le=e[39];let ie=le,H;e[40]!==oe||e[41]!==se||e[42]!==d?(H=a(ne=>{oe(),se(),d(ne)},"P"),e[40]=oe,e[41]=se,e[42]=d,e[43]=H):H=e[43];let J=H,X;e[44]!==i?(X=a(()=>{i({pane:"results"})},"V"),e[44]=i,e[45]=X):X=e[45];let re=X,fe;e[46]!==$?(fe=a(()=>{me($("explain"))},"pe"),e[46]=$,e[47]=fe):fe=e[47];let je=fe,Te;e[48]!==i?(Te=a(()=>{i({pane:"chart"})},"ke"),e[48]=i,e[49]=Te):Te=e[49];let ze=Te,Ie;e[50]!==D||e[51]!==I?(Ie=a(()=>{D(!I)},"Te"),e[50]=D,e[51]=I,e[52]=Ie):Ie=e[52];let He=Ie,We=I?"flex min-h-0 flex-1 flex-row":"flex min-h-0 flex-1 flex-col",Be=I?"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",he;e[53]!==p||e[54]!==f.clearHistory||e[55]!==f.deleteQuery||e[56]!==f.history||e[57]!==f.listRef||e[58]!==f.loadFromHistory||e[59]!==f.loadTemplate||e[60]!==f.newQuery||e[61]!==f.onSearchChange||e[62]!==f.queries||e[63]!==f.rememberHistory||e[64]!==f.search||e[65]!==f.selectQuery||e[66]!==f.setRememberHistory?(he=(0,u.jsx)(xo,{activeId:p,history:f.history,listRef:f.listRef,onClearHistory:f.clearHistory,onDelete:f.deleteQuery,onLoadHistory:f.loadFromHistory,onLoadTemplate:f.loadTemplate,onNew:f.newQuery,onSearchChange:f.onSearchChange,onSelect:f.selectQuery,onToggleRememberHistory:f.setRememberHistory,queries:f.queries,rememberHistory:f.rememberHistory,search:f.search}),e[53]=p,e[54]=f.clearHistory,e[55]=f.deleteQuery,e[56]=f.history,e[57]=f.listRef,e[58]=f.loadFromHistory,e[59]=f.loadTemplate,e[60]=f.newQuery,e[61]=f.onSearchChange,e[62]=f.queries,e[63]=f.rememberHistory,e[64]=f.search,e[65]=f.selectQuery,e[66]=f.setRememberHistory,e[67]=he):he=e[67];let pe;e[68]!==r||e[69]!==J?(pe=(0,u.jsx)(No,{model:r,onSelect:J}),e[68]=r,e[69]=J,e[70]=pe):pe=e[70];let be;e[71]!==P||e[72]!==K||e[73]!==w||e[74]!==g||e[75]!==j||e[76]!==O.acceptInlineEdit||e[77]!==O.autocompleteState||e[78]!==O.closeInlineEdit||e[79]!==O.editorRef||e[80]!==O.gutterRef||e[81]!==O.handlers||e[82]!==O.inlineEdit||e[83]!==O.listboxId||e[84]!==O.onPickSuggestion||e[85]!==O.overlayRef||e[86]!==O.revealDiagnostic?(be=(0,u.jsx)(ho,{assistant:P,autocomplete:O.autocompleteState,diagnostics:K,draft:w,editorRef:O.editorRef,failed:g,gutterRef:O.gutterRef,handlers:O.handlers,inlineEdit:O.inlineEdit,listboxId:O.listboxId,onAcceptInlineEdit:O.acceptInlineEdit,onCancelInlineEdit:O.closeInlineEdit,onGenerated:j,onPickSuggestion:O.onPickSuggestion,onRevealDiagnostic:O.revealDiagnostic,overlayRef:O.overlayRef}),e[71]=P,e[72]=K,e[73]=w,e[74]=g,e[75]=j,e[76]=O.acceptInlineEdit,e[77]=O.autocompleteState,e[78]=O.closeInlineEdit,e[79]=O.editorRef,e[80]=O.gutterRef,e[81]=O.handlers,e[82]=O.inlineEdit,e[83]=O.listboxId,e[84]=O.onPickSuggestion,e[85]=O.overlayRef,e[86]=O.revealDiagnostic,e[87]=be):be=e[87];let ge;e[88]!==P||e[89]!==y||e[90]!==ie||e[91]!==F||e[92]!==S||e[93]!==A||e[94]!==V||e[95]!==l.script||e[96]!==C||e[97]!==Be||e[98]!==k||e[99]!==E||e[100]!==ze||e[101]!==je||e[102]!==re||e[103]!==I||e[104]!==q||e[105]!==He?(ge=(0,u.jsx)(vo,{assistant:P,chart:S,className:Be,error:y,onFormat:ie,onInferChart:F,onRun:A,onSelectStatement:V,onShardKeyChange:T,onShowChart:ze,onShowExplain:je,onShowResults:re,onToggleSplit:He,pane:q,result:C,running:k,script:l.script,shardKey:E,splitView:I}),e[88]=P,e[89]=y,e[90]=ie,e[91]=F,e[92]=S,e[93]=A,e[94]=V,e[95]=l.script,e[96]=C,e[97]=Be,e[98]=k,e[99]=E,e[100]=ze,e[101]=je,e[102]=re,e[103]=I,e[104]=q,e[105]=He,e[106]=ge):ge=e[106];let xe;e[107]!==be||e[108]!==ge||e[109]!==We?(xe=(0,u.jsxs)("div",{className:We,children:[be,ge]}),e[107]=be,e[108]=ge,e[109]=We,e[110]=xe):xe=e[110];let ve;e[111]!==pe||e[112]!==xe?(ve=(0,u.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col",children:[pe,xe]}),e[111]=pe,e[112]=xe,e[113]=ve):ve=e[113];let Le;return e[114]!==he||e[115]!==ve?(Le=(0,u.jsxs)("div",{className:"flex h-full min-w-0","data-testid":"lunora-sql-editor",children:[he,ve]}),e[114]=he,e[115]=ve,e[116]=Le):Le=e[116],Le},"Qs");export{Xo as SqlEditorPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as O,b as D}from"./chunk-5B2RTXBS.js";import{a as F}from"./chunk-
|
|
1
|
+
import{a as O,b as D}from"./chunk-5B2RTXBS.js";import{a as F}from"./chunk-EWMBX5N2.js";import{a as j}from"./chunk-R6U22RSY.js";import{a as V}from"./chunk-7Q256NLI.js";import"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import{i as L}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import"./chunk-AUAECCXB.js";import{b as C}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as z}from"./chunk-4ZPDCXIA.js";import"./chunk-NCPW7WHO.js";import"./chunk-CLXX5RVY.js";import"./chunk-55UGUCQ6.js";import{a as T}from"./chunk-4ZEL6BYL.js";import{c as R}from"./chunk-ZBHXISOD.js";import"./chunk-X6XAMP4E.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as k}from"./chunk-RWVIV3U7.js";import{a as A,b as q,c as B,d as p,e as d,f as n}from"./chunk-HCTJKP5J.js";import{a as I,e as E}from"./chunk-2IKDEUCX.js";import{d as b,n as K,u as M}from"./chunk-74IYYDDI.js";import{a as i,d as y,e as ee,g as te}from"./chunk-I26MS5PJ.js";var s=y(ee(),1);var e=y(te(),1);var re=i(o=>o===void 0?"":JSON.stringify(o,K),"te"),ae=41,J=480,H=5,ie=i((o,t)=>O(o,l=>{t(l.height>0?l:{height:J,width:l.width})}),"ae"),Ne=i(({initialShardKey:o})=>{let t=b(),{queryShardKey:l,setShardKey:P,shardKey:U}=j(o),[h,W]=(0,s.useState)(""),{data:f,error:g,errorSource:Z,isLoading:_,liveError:G}=R(T.getAuditLog,{},{live:!0,shardKey:l}),c=(0,s.useMemo)(()=>f?.entries??[],[f]),m=(0,s.useMemo)(()=>{let a=h.trim().toLowerCase();return a===""?c:c.filter(r=>r.op.toLowerCase().includes(a)||(r.table??"").toLowerCase().includes(a)||(r.id??"").toLowerCase().includes(a))},[c,h]),x=(0,s.useRef)(null),v=D({count:m.length,estimateSize:i(()=>ae,"estimateSize"),getScrollElement:i(()=>x.current,"getScrollElement"),initialRect:{height:J,width:800},observeElementRect:ie,overscan:8}),u=v.getVirtualItems(),Q=v.getTotalSize(),N=u[0]?.start??0,w=Q-(u.at(-1)?.end??0),X={height:N},Y={height:w},$=i(a=>{W(a.target.value)},"z");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-audit",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(V,{onChange:P,testId:"au-shard-input",value:U}),(0,e.jsx)(F,{message:G,prefix:"au"}),(0,e.jsx)(L,{"aria-label":t("Filter audit log"),className:"h-8 w-48","data-testid":"au-search",onChange:$,placeholder:t("filter op, table, id"),value:h})]}),g!==null&&(0,e.jsx)(z,{error:Z,testId:"au-error"}),g===null&&!_&&m.length===0&&(0,e.jsx)(k,{description:t("State-changing admin operations are recorded here."),icon:(0,e.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsx)("path",{d:"M8 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2h-2M9 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V3Zm-1 9h8m-8 4h5"})}),testId:"au-empty",title:t("No audit entries.")}),m.length>0&&(0,e.jsx)(I,{className:"overflow-hidden py-0",children:(0,e.jsx)(E,{className:"max-h-[30rem] overflow-auto px-0",ref:x,children:(0,e.jsxs)(A,{"data-testid":"au-table",children:[(0,e.jsx)(q,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(d,{children:t("time")}),(0,e.jsx)(d,{children:t("op")}),(0,e.jsx)(d,{children:t("table")}),(0,e.jsx)(d,{children:t("id")}),(0,e.jsx)(d,{children:t("detail")})]})}),(0,e.jsxs)(B,{children:[N>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:X})}),u.map(a=>{let r=m[a.index],S=re(r.detail);return(0,e.jsxs)(p,{"data-testid":"au-row",children:[(0,e.jsx)(n,{className:"text-muted-foreground tabular-nums",children:M(r.ts,"\u2014")}),(0,e.jsx)(n,{children:(0,e.jsx)(C,{variant:"secondary",children:r.op})}),(0,e.jsx)(n,{className:"font-medium",children:r.table??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(n,{className:"max-w-[20ch] truncate font-mono text-xs",children:r.id??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(n,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:S||void 0,children:S||(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},r.seq)}),w>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:Y})})]})]})})})]})},"we");export{Ne as AuditPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as c}from"./chunk-VESGIGMQ.js";import{i as e}from"./chunk-OQ6I6OXT.js";import{
|
|
1
|
+
import{a as c}from"./chunk-VESGIGMQ.js";import{i as e}from"./chunk-OQ6I6OXT.js";import{q as m}from"./chunk-74IYYDDI.js";import{a as s,d as p,f as n}from"./chunk-I26MS5PJ.js";var f=p(n(),1);var h=s(r=>{let t=(0,f.c)(3),a=e(),o;return t[0]!==a||t[1]!==r?(o=s(i=>{c({shardKey:r,traceId:i}),m(a({to:"/traces"}))},"e"),t[0]=a,t[1]=r,t[2]=o):o=t[2],o},"u");export{h as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as g}from"./chunk-
|
|
1
|
+
import{b as g}from"./chunk-EFXC3EHZ.js";import"./chunk-4ZPDCXIA.js";import"./chunk-NCPW7WHO.js";import"./chunk-CLXX5RVY.js";import"./chunk-55UGUCQ6.js";import{a as f}from"./chunk-4ZEL6BYL.js";import{c as m}from"./chunk-ZBHXISOD.js";import"./chunk-X6XAMP4E.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import"./chunk-HCTJKP5J.js";import"./chunk-2IKDEUCX.js";import{d as p}from"./chunk-74IYYDDI.js";import{a as r,d as h,f as S,g as A}from"./chunk-I26MS5PJ.js";var R=h(S(),1);var k=h(A(),1);var _=r((e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("User subscriptions are ungated")})[s.kind],"k"),w=r(e=>Array.isArray(e.findings)?e.findings:[],"g"),b=r(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"S"),E=r((e,s)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: anyone who can reach the worker can open a socket and run ordinary user subscriptions. Admin subscriptions are unaffected \u2014 they need the admin token. Set it if subscribers should present a shared credential.")})[s.kind],"A"),O=r(()=>{let e=(0,R.c)(8),s=p(),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];let{data:a,error:d,errorSource:c}=m(f.getSecurityAudit,i),n;if(e[1]!==a||e[2]!==s){let u=a===void 0?null:w(a);n=u===null?null:u.map(t=>({description:E(s,t),entity:b(t),issueType:_(s,t),key:t.kind,level:t.level})),e[1]=a,e[2]=s,e[3]=n}else n=e[3];let l=n,o;return e[4]!==d||e[5]!==c||e[6]!==l?(o=(0,k.jsx)(g,{error:d,errorSource:c,rows:l,testId:"lunora-security-advisor"}),e[4]=d,e[5]=c,e[6]=l,e[7]=o):o=e[7],o},"T");export{O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as k}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as q}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as j}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as U}from"./chunk-
|
|
1
|
+
import{i as k}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as q}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as j}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as U}from"./chunk-4ZPDCXIA.js";import"./chunk-NCPW7WHO.js";import"./chunk-CLXX5RVY.js";import"./chunk-55UGUCQ6.js";import{a as R}from"./chunk-4ZEL6BYL.js";import{c as P}from"./chunk-ZBHXISOD.js";import"./chunk-X6XAMP4E.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as M}from"./chunk-RWVIV3U7.js";import{a as G,b as H,c as J,d as B,e as x,f as N}from"./chunk-HCTJKP5J.js";import{a as z,e as D}from"./chunk-2IKDEUCX.js";import{d as F,u as O}from"./chunk-74IYYDDI.js";import{a as A,d as T,e as $,f as X,g as Y}from"./chunk-I26MS5PJ.js";var K=T(X(),1),Q=T($(),1);var t=T(Y(),1);var de=A(()=>{let e=(0,K.c)(39),a=F(),[s,V]=(0,Q.useState)(""),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={},e[0]=y):y=e[0];let{data:C,error:l,errorSource:S,isLoading:E,refetch:_}=P(R.getAuthAuditLog,y),I;if(e[1]!==C?.entries||e[2]!==s){let r=C?.entries??[],v=s.trim().toLowerCase();I=v===""?r:r.filter(w=>w.event.toLowerCase().includes(v)||(w.actorId??"").toLowerCase().includes(v)||(w.actorEmail??"").toLowerCase().includes(v)||(w.ip??"").toLowerCase().includes(v)||w.outcome.toLowerCase().includes(v)),e[1]=C?.entries,e[2]=s,e[3]=I}else I=e[3];let o=I,L;e[4]===Symbol.for("react.memo_cache_sentinel")?(L=A(r=>{V(r.target.value)},"I"),e[4]=L):L=e[4];let W=L,i;e[5]!==a?(i=a("Filter security events"),e[5]=a,e[6]=i):i=e[6];let n;e[7]!==a?(n=a("filter event, actor, IP"),e[7]=a,e[8]=n):n=e[8];let c;e[9]!==s||e[10]!==i||e[11]!==n?(c=(0,t.jsx)(k,{"aria-label":i,className:"h-8 w-56","data-testid":"aa-search",onChange:W,placeholder:n,value:s}),e[9]=s,e[10]=i,e[11]=n,e[12]=c):c=e[12];let d;e[13]!==_?(d=A(()=>{_()},"m"),e[13]=_,e[14]=d):d=e[14];let m;e[15]!==a?(m=a("Refresh"),e[15]=a,e[16]=m):m=e[16];let u;e[17]!==d||e[18]!==m?(u=(0,t.jsx)(q,{"data-testid":"aa-refresh",onClick:d,size:"xs",type:"button",variant:"ghost",children:m}),e[17]=d,e[18]=m,e[19]=u):u=e[19];let h;e[20]!==c||e[21]!==u?(h=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,u]}),e[20]=c,e[21]=u,e[22]=h):h=e[22];let f;e[23]!==l||e[24]!==S?(f=l!==null&&(0,t.jsx)(U,{error:S,testId:"aa-error"}),e[23]=l,e[24]=S,e[25]=f):f=e[25];let p;e[26]!==l||e[27]!==o.length||e[28]!==E||e[29]!==a?(p=l===null&&!E&&o.length===0&&(0,t.jsx)(M,{description:a("Authentication and security events are recorded here."),testId:"aa-empty",title:a("No security events.")}),e[26]=l,e[27]=o.length,e[28]=E,e[29]=a,e[30]=p):p=e[30];let g;e[31]!==o||e[32]!==a?(g=o.length>0&&(0,t.jsx)(z,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"max-h-[30rem] overflow-auto px-0",children:(0,t.jsxs)(G,{"data-testid":"aa-table",children:[(0,t.jsx)(H,{children:(0,t.jsxs)(B,{children:[(0,t.jsx)(x,{children:a("time")}),(0,t.jsx)(x,{children:a("event")}),(0,t.jsx)(x,{children:a("actor")}),(0,t.jsx)(x,{children:a("ip / user agent")}),(0,t.jsx)(x,{children:a("outcome")})]})}),(0,t.jsx)(J,{children:o.map(r=>(0,t.jsxs)(B,{"data-testid":"aa-row",children:[(0,t.jsx)(N,{className:"text-muted-foreground tabular-nums",children:O(r.ts,"\u2014")}),(0,t.jsx)(N,{children:(0,t.jsx)(j,{variant:"secondary",children:r.event})}),(0,t.jsx)(N,{className:"max-w-[24ch] truncate font-mono text-xs",title:r.actorId??void 0,children:r.actorEmail??r.actorId??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,t.jsxs)(N,{className:"max-w-[28ch] truncate text-xs text-muted-foreground",title:r.userAgent??void 0,children:[r.ip??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),r.userAgent!==void 0&&(0,t.jsxs)("span",{className:"ml-1 opacity-70",children:["\xB7 ",r.userAgent]})]}),(0,t.jsx)(N,{children:(0,t.jsx)(j,{variant:r.outcome==="failure"?"destructive":"outline",children:a(r.outcome)})})]},r.seq))})]})})}),e[31]=o,e[32]=a,e[33]=g):g=e[33];let b;return e[34]!==f||e[35]!==p||e[36]!==g||e[37]!==h?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-auth-audit",children:[h,f,p,g]}),e[34]=f,e[35]=p,e[36]=g,e[37]=h,e[38]=b):b=e[38],b},"ne");export{de as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as de}from"./chunk-UYEZR3BI.js";import{a as te,b as re,c as ne}from"./chunk-XGCIDUJF.js";import"./chunk-RGMVGZV4.js";import{b as Y}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as ae}from"./chunk-
|
|
1
|
+
import{b as de}from"./chunk-UYEZR3BI.js";import{a as te,b as re,c as ne}from"./chunk-XGCIDUJF.js";import"./chunk-RGMVGZV4.js";import{b as Y}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as ae}from"./chunk-4ZPDCXIA.js";import"./chunk-NCPW7WHO.js";import"./chunk-CLXX5RVY.js";import"./chunk-55UGUCQ6.js";import{a as ee}from"./chunk-4ZEL6BYL.js";import{c as Z}from"./chunk-ZBHXISOD.js";import"./chunk-X6XAMP4E.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as le,b as oe,c as se,d as H,e as z,f as G}from"./chunk-HCTJKP5J.js";import{a as P,e as q}from"./chunk-2IKDEUCX.js";import{d as X}from"./chunk-74IYYDDI.js";import{a as g,d as W,f as ce,g as me}from"./chunk-I26MS5PJ.js";var J=W(ce(),1);var t=W(me(),1);var ue={binding:"outline",secret:"destructive",var:"secondary"},pe=g((n,e)=>{if(n===void 0)return[];let u=[];return n.workerUrl!==void 0&&u.push({label:e("URL"),value:n.workerUrl}),n.environment!==void 0&&u.push({label:e("Environment"),value:n.environment}),n.deploymentId!==void 0&&u.push({label:e("Deployment"),value:n.deploymentId}),n.versionTag!==void 0&&u.push({label:e("Version"),value:n.versionTag}),u},"ce"),ie=g(n=>{let e=(0,J.c)(18),{modifier:u,name:r,label:p}=n,A=te(),x;e[0]!==r?(x=g(o=>{if(!["Escape","Tab"].includes(o.key)){if(o.shiftKey){o.preventDefault();return}o.preventDefault(),re(r,o.key)}},"b"),e[0]=r,e[1]=x):x=e[1];let i=x,c=`set-shortcut-${r}`,m;e[2]!==p?(m=(0,t.jsx)("dt",{className:"text-muted-foreground",children:p}),e[2]=p,e[3]=m):m=e[3];let h;e[4]!==u?(h=(0,t.jsx)("kbd",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:u}),e[4]=u,e[5]=h):h=e[5];let l=`set-shortcut-input-${r}`,f=A[r],s;e[6]!==p||e[7]!==i||e[8]!==l||e[9]!==f?(s=(0,t.jsx)("input",{"aria-label":p,className:"h-7 w-12 rounded-md border border-border bg-background text-center font-mono text-xs uppercase outline-none focus-visible:border-ring","data-testid":l,onKeyDown:i,readOnly:!0,value:f}),e[6]=p,e[7]=i,e[8]=l,e[9]=f,e[10]=s):s=e[10];let a;e[11]!==h||e[12]!==s?(a=(0,t.jsxs)("dd",{className:"flex items-center gap-1.5",children:[h,s]}),e[11]=h,e[12]=s,e[13]=a):a=e[13];let d;return e[14]!==c||e[15]!==m||e[16]!==a?(d=(0,t.jsxs)("div",{className:"contents","data-testid":c,children:[m,a]}),e[14]=c,e[15]=m,e[16]=a,e[17]=d):d=e[17],d},"z"),Se=g(n=>{let e=(0,J.c)(85),{initialShardKey:u}=n,r=X(),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let A=u??"",x;e[1]!==A?(x={shardKey:A},e[1]=A,e[2]=x):x=e[2];let{data:i,error:c,errorSource:m,isLoading:h}=Z(ee.getSettings,p,x),l,f,s,a,d,o,b;if(e[3]!==c||e[4]!==m||e[5]!==i?.deploy||e[6]!==i?.settings||e[7]!==r){let Q=pe(i?.deploy,r),M;e[15]!==i?.settings?(M=i?.settings??[],e[15]=i?.settings,e[16]=M):M=e[16],l=M,f="flex flex-col gap-4",s="lunora-settings";let V;e[17]!==r?(V=r("Open in Cloudflare"),e[17]=r,e[18]=V):V=e[18],e[19]!==V?(a=(0,t.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,t.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:de,rel:"noreferrer",target:"_blank",children:V})}),e[19]=V,e[20]=a):a=e[20];let $;e[21]!==r?($=r("View-only \u2014 values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=r,e[22]=$):$=e[22],e[23]!==$?(d=(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:$}),e[23]=$,e[24]=d):d=e[24],e[25]!==c||e[26]!==m?(o=c!==null&&(0,t.jsx)(ae,{error:m,testId:"set-error"}),e[25]=c,e[26]=m,e[27]=o):o=e[27],b=Q.length>0&&(0,t.jsxs)(P,{className:"py-0","data-testid":"set-deploy",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Deployment")})}),(0,t.jsx)(q,{className:"py-3",children:(0,t.jsx)("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:Q.map(he)})})]}),e[3]=c,e[4]=m,e[5]=i?.deploy,e[6]=i?.settings,e[7]=r,e[8]=l,e[9]=f,e[10]=s,e[11]=a,e[12]=d,e[13]=o,e[14]=b}else l=e[8],f=e[9],s=e[10],a=e[11],d=e[12],o=e[13],b=e[14];let y;e[28]!==r?(y=r("Keyboard shortcuts"),e[28]=r,e[29]=y):y=e[29];let v;e[30]!==y?(v=(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y}),e[30]=y,e[31]=v):v=e[31];let N;e[32]!==r?(N=r("Reset"),e[32]=r,e[33]=N):N=e[33];let k;e[34]!==N?(k=(0,t.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:ne,type:"button",children:N}),e[34]=N,e[35]=k):k=e[35];let w;e[36]!==v||e[37]!==k?(w=(0,t.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[v,k]}),e[36]=v,e[37]=k,e[38]=w):w=e[38];let C;e[39]!==r?(C=r("Command palette"),e[39]=r,e[40]=C):C=e[40];let S;e[41]!==C?(S=(0,t.jsx)(ie,{label:C,modifier:"\u2318/Ctrl",name:"palette"}),e[41]=C,e[42]=S):S=e[42];let T;e[43]!==r?(T=r("Operation console"),e[43]=r,e[44]=T):T=e[44];let D;e[45]!==T?(D=(0,t.jsx)(ie,{label:T,modifier:"Ctrl",name:"console"}),e[45]=T,e[46]=D):D=e[46];let _;e[47]!==S||e[48]!==D?(_=(0,t.jsxs)("dl",{className:"grid grid-cols-[10rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 text-sm",children:[S,D]}),e[47]=S,e[48]=D,e[49]=_):_=e[49];let E;e[50]!==r?(E=r("Stored in this browser. Focus a box and press a key to rebind it."),e[50]=r,e[51]=E):E=e[51];let I;e[52]!==E?(I=(0,t.jsx)("p",{className:"pt-3 text-xs text-muted-foreground",children:E}),e[52]=E,e[53]=I):I=e[53];let K;e[54]!==_||e[55]!==I?(K=(0,t.jsxs)(q,{className:"py-3",children:[_,I]}),e[54]=_,e[55]=I,e[56]=K):K=e[56];let O;e[57]!==w||e[58]!==K?(O=(0,t.jsxs)(P,{className:"py-0","data-testid":"set-preferences",children:[w,K]}),e[57]=w,e[58]=K,e[59]=O):O=e[59];let U;e[60]!==r?(U=r("Environment & bindings"),e[60]=r,e[61]=U):U=e[61];let j;e[62]!==U?(j=(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:U})}),e[62]=U,e[63]=j):j=e[63];let F;e[64]!==c||e[65]!==h||e[66]!==l.length||e[67]!==r?(F=c===null&&!h&&l.length===0&&(0,t.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:r("No environment variables or bindings.")}),e[64]=c,e[65]=h,e[66]=l.length,e[67]=r,e[68]=F):F=e[68];let L;e[69]!==l||e[70]!==r?(L=l.length>0&&(0,t.jsx)(q,{className:"px-0 py-0",children:(0,t.jsxs)(le,{"data-testid":"set-table",children:[(0,t.jsx)(oe,{children:(0,t.jsxs)(H,{children:[(0,t.jsx)(z,{children:r("name")}),(0,t.jsx)(z,{children:r("kind")}),(0,t.jsx)(z,{children:r("value")})]})}),(0,t.jsx)(se,{children:l.map(fe)})]})}),e[69]=l,e[70]=r,e[71]=L):L=e[71];let R;e[72]!==j||e[73]!==F||e[74]!==L?(R=(0,t.jsxs)(P,{className:"py-0",children:[j,F,L]}),e[72]=j,e[73]=F,e[74]=L,e[75]=R):R=e[75];let B;return e[76]!==O||e[77]!==R||e[78]!==f||e[79]!==s||e[80]!==a||e[81]!==d||e[82]!==o||e[83]!==b?(B=(0,t.jsxs)("div",{className:f,"data-testid":s,children:[a,d,o,b,O,R]}),e[76]=O,e[77]=R,e[78]=f,e[79]=s,e[80]=a,e[81]=d,e[82]=o,e[83]=b,e[84]=B):B=e[84],B},"Ce");function he(n){return(0,t.jsxs)("div",{className:"contents","data-testid":"set-deploy-row",children:[(0,t.jsx)("dt",{className:"text-muted-foreground",children:n.label}),(0,t.jsx)("dd",{className:"truncate font-mono text-xs",title:n.value,children:n.value})]},n.label)}g(he,"me");function fe(n){return(0,t.jsxs)(H,{"data-testid":"set-row",children:[(0,t.jsx)(G,{className:"font-mono text-xs font-medium",children:n.name}),(0,t.jsx)(G,{children:(0,t.jsx)(Y,{variant:ue[n.kind],children:n.bindingType??n.kind})}),(0,t.jsx)(G,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:n.value??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},n.name)}g(fe,"fe");export{Se as SettingsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Ze}from"./chunk-AQFI2GWT.js";import{a as Me,b as Re}from"./chunk-Q6IT6ZD7.js";import"./chunk-FBGCQYRO.js";import"./chunk-NQZALRU3.js";import"./chunk-OPM7ESDV.js";import"./chunk-Y3AYVFTK.js";import{a as ke}from"./chunk-37WYCOQ2.js";import"./chunk-OYCUPD3Q.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import"./chunk-AUGKHAMQ.js";import{a as Ye}from"./chunk-R6U22RSY.js";import{a as Xe}from"./chunk-2EYOYWS2.js";import{b as We}from"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import{i as Je}from"./chunk-OQ6I6OXT.js";import{i as Ae}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{a as ge}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as Ee}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as je}from"./chunk-4ZEL6BYL.js";import{l as Ue}from"./chunk-PAAYRW3Q.js";import"./chunk-QAQDMS6R.js";import"./chunk-WS7WNXF3.js";import{a as Qe}from"./chunk-RWVIV3U7.js";import{a as qe,b as Ge,c as Ke,d as Pe,e as Le}from"./chunk-2IKDEUCX.js";import{d as ze,f as Fe,g as $e,h as Oe,p as be}from"./chunk-5OMZCVRF.js";import{a as r,d as Be,e as nt,f as st,g as rt,i as De}from"./chunk-I26MS5PJ.js";var we=Be(st(),1);var x=Be(nt(),1);var t=Be(rt(),1);var ot=Fe(je.listTables),it=Fe(je.listTableIndexes),dt=Fe(je.readTablePage),ct=Fe(je.describeTables),mt={},He=[],ut=r(s=>{let e=(0,we.c)(74),{initialShardKey:u,initialTable:n}=s,l=Ue(),[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,{},$e(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),$(Oe(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(Oe(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(()=>{be(B(c)),be(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},$e(c)),l.query(it,{table:g},$e(c))]);w.status==="fulfilled"?N(I=>({...I,[v]:w.value.columns})):$(Oe(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(Oe(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,be(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]},$e(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||be(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=ze(),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)(ge,{"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)(ge,{"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)(ge,{"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)(ge,{"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=ze();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)(ge,{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=ze(),a=Je(),[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(()=>{be(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(()=>{be(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(()=>{be(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(()=>{be(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)(ge,{"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)(ge,{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)(ge,{"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)(ge,{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)(ge,{"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)(ge,{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=ze(),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=>{be(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)(Ee,{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(()=>{be(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)(Ee,{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(()=>{be(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)(Ee,{variant:"outline",children:s.type}),s.unique===!0&&(0,t.jsx)(Ee,{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-IKT6EYHN.js";import{a as Me,b as Re}from"./chunk-Q6IT6ZD7.js";import"./chunk-ZFW3QEVE.js";import"./chunk-NQZALRU3.js";import"./chunk-OPM7ESDV.js";import"./chunk-Y3AYVFTK.js";import{a as ke}from"./chunk-37WYCOQ2.js";import"./chunk-OYCUPD3Q.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import"./chunk-AUGKHAMQ.js";import{a as Ye}from"./chunk-R6U22RSY.js";import{a as Xe}from"./chunk-7Q256NLI.js";import{b as We}from"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import{i as Je}from"./chunk-OQ6I6OXT.js";import{i as Ae}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{a as ge}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as Ee}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as je}from"./chunk-4ZEL6BYL.js";import{l as Ue}from"./chunk-X6XAMP4E.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as Qe}from"./chunk-RWVIV3U7.js";import{a as qe,b as Ge,c as Ke,d as Pe,e as Le}from"./chunk-2IKDEUCX.js";import{d as ze,f as Fe,g as $e,h as Oe,q as be}from"./chunk-74IYYDDI.js";import{a as r,d as Be,e as nt,f as st,g as rt,i as De}from"./chunk-I26MS5PJ.js";var we=Be(st(),1);var x=Be(nt(),1);var t=Be(rt(),1);var ot=Fe(je.listTables),it=Fe(je.listTableIndexes),dt=Fe(je.readTablePage),ct=Fe(je.describeTables),mt={},He=[],ut=r(s=>{let e=(0,we.c)(74),{initialShardKey:u,initialTable:n}=s,l=Ue(),[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,{},$e(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),$(Oe(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(Oe(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(()=>{be(B(c)),be(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},$e(c)),l.query(it,{table:g},$e(c))]);w.status==="fulfilled"?N(I=>({...I,[v]:w.value.columns})):$(Oe(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(Oe(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,be(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]},$e(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||be(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=ze(),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)(ge,{"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)(ge,{"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)(ge,{"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)(ge,{"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=ze();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)(ge,{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=ze(),a=Je(),[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(()=>{be(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(()=>{be(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(()=>{be(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(()=>{be(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)(ge,{"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)(ge,{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)(ge,{"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)(ge,{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)(ge,{"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)(ge,{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=ze(),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=>{be(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)(Ee,{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(()=>{be(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)(Ee,{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(()=>{be(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)(Ee,{variant:"outline",children:s.type}),s.unique===!0&&(0,t.jsx)(Ee,{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 s}from"./chunk-7G4Z6Q7X.js";import{d}from"./chunk-
|
|
1
|
+
import{a as s}from"./chunk-7G4Z6Q7X.js";import{d}from"./chunk-74IYYDDI.js";import{a as e,d as r,e as h,g as k}from"./chunk-I26MS5PJ.js";var l=r(h(),1);var t=r(k(),1);var g=e(({children:m,confirmLabel:c,disabled:a=!1,onConfirm:p,testId:i})=>{let o=d(),[f,n]=(0,l.useState)(!1),u=e(()=>{n(!0)},"f"),C=e(()=>{n(!1)},"l"),b=e(()=>{n(!1),p()},"p");return f?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1","data-testid":`${i}-prompt`,role:"group",children:[(0,t.jsx)(s,{"data-testid":`${i}-confirm`,disabled:a,onClick:b,size:"sm",type:"button",variant:"destructive",children:c??o("Confirm")}),(0,t.jsx)(s,{"data-testid":`${i}-cancel`,onClick:C,size:"sm",type:"button",variant:"ghost",children:o("Cancel")})]}):(0,t.jsx)(s,{"data-testid":i,disabled:a,onClick:u,size:"sm",type:"button",variant:"outline",children:m})},"k");export{g as a};
|