@lunora/studio 1.0.0-alpha.94 → 1.0.0-alpha.96

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.
Files changed (163) hide show
  1. package/dist/index.d.ts +5 -5
  2. package/dist/index.js +1 -1
  3. package/dist/mount.d.ts +2 -2
  4. package/dist/mount.js +1 -1
  5. package/dist/packem_chunks/AdvisorHealthPanel.js +1 -1
  6. package/dist/packem_chunks/AuditPanel.js +1 -1
  7. package/dist/packem_chunks/DeploymentHealthPanel.js +1 -1
  8. package/dist/packem_chunks/ExportImportPanel.js +1 -1
  9. package/dist/packem_chunks/FileBrowser.js +1 -1
  10. package/dist/packem_chunks/FunctionStatsPanel.js +1 -1
  11. package/dist/packem_chunks/HealthPanel.js +1 -1
  12. package/dist/packem_chunks/InsightsPanel.js +1 -1
  13. package/dist/packem_chunks/LogsPanel.js +1 -1
  14. package/dist/packem_chunks/MailPanel.js +1 -1
  15. package/dist/packem_chunks/MetricsPanel.js +1 -1
  16. package/dist/packem_chunks/NotificationsPanel.js +1 -1
  17. package/dist/packem_chunks/SchemaViewer.js +1 -1
  18. package/dist/packem_chunks/SecurityAdvisorPanel.js +1 -1
  19. package/dist/packem_chunks/SettingsPanel.js +1 -1
  20. package/dist/packem_chunks/SqlEditorPanel.js +6 -6
  21. package/dist/packem_chunks/TableEditor.js +1 -1
  22. package/dist/packem_chunks/agents-panel.js +1 -1
  23. package/dist/packem_chunks/analytics-panel.js +1 -1
  24. package/dist/packem_chunks/auth-audit-panel.js +1 -1
  25. package/dist/packem_chunks/auth-config-panel.js +1 -1
  26. package/dist/packem_chunks/auth-sessions-panel.js +1 -1
  27. package/dist/packem_chunks/containers-panel.js +1 -1
  28. package/dist/packem_chunks/dashboards-panel.js +1 -1
  29. package/dist/packem_chunks/fanout-panel.js +1 -1
  30. package/dist/packem_chunks/flags-panel.js +1 -1
  31. package/dist/packem_chunks/issues-panel.js +1 -1
  32. package/dist/packem_chunks/kv-browser.js +1 -1
  33. package/dist/packem_chunks/log-drains-panel.js +2 -2
  34. package/dist/packem_chunks/migrations-route.js +1 -1
  35. package/dist/packem_chunks/organizations-panel.js +1 -1
  36. package/dist/packem_chunks/payments-panel.js +1 -1
  37. package/dist/packem_chunks/permissions-panel.js +1 -1
  38. package/dist/packem_chunks/queues-panel.js +1 -1
  39. package/dist/packem_chunks/rls-panel.js +1 -1
  40. package/dist/packem_chunks/schedule-panel.js +1 -1
  41. package/dist/packem_chunks/sparkline.js +1 -1
  42. package/dist/packem_chunks/storage-rules-panel.js +1 -1
  43. package/dist/packem_chunks/subscriptions-panel.js +1 -1
  44. package/dist/packem_chunks/sync-client-panel.js +1 -1
  45. package/dist/packem_chunks/traces-panel.js +1 -1
  46. package/dist/packem_chunks/users-panel.js +1 -1
  47. package/dist/packem_chunks/vector-browser.js +1 -1
  48. package/dist/packem_chunks/workflows-panel.js +1 -1
  49. package/dist/packem_shared/{DataBrowser-H4oUFkPJ.js → DataBrowser-CPNKM0KZ.js} +1 -1
  50. package/dist/packem_shared/{GlobalDataBrowser-CeA8bDjX.js → GlobalDataBrowser-BSmyOO0n.js} +1 -1
  51. package/dist/packem_shared/{HomePanel-DLP1nQdC.js → HomePanel-BUO6BcYQ.js} +1 -1
  52. package/dist/packem_shared/{MigrationsPanel-dm_M75mR.js → MigrationsPanel-BAnvY79E.js} +1 -1
  53. package/dist/packem_shared/{ScheduledJobs-DDJG9Je7.js → ScheduledJobs-pHVlh2xU.js} +1 -1
  54. package/dist/packem_shared/{Studio-BYg65qWq.js → Studio-DG_n-8Pc.js} +1 -1
  55. package/dist/packem_shared/{StudioApp-D0UOg0a_.js → StudioApp-bavavhpe.js} +1 -1
  56. package/dist/packem_shared/advisor-view-CGcwvlMo.js +1 -0
  57. package/dist/packem_shared/{app.d-DW7yZsfu.d.ts → app.d-D1bPR8FO.d.ts} +8 -8
  58. package/dist/packem_shared/bar-chart-B8oDHgnw.js +6 -0
  59. package/dist/packem_shared/{card-CIDGUN6K.js → card-BMKx5UdA.js} +1 -1
  60. package/dist/packem_shared/{dropdown-menu-C3RQ_HlW.js → dropdown-menu-BgS2zw1i.js} +1 -1
  61. package/dist/packem_shared/error-alert-_2q2VtVG.js +1 -0
  62. package/dist/packem_shared/{grid-features-Db_BNYRo.js → grid-features-Y2YSjhCf.js} +2 -2
  63. package/dist/packem_shared/home-panel-Ir3YHReO.js +3 -0
  64. package/dist/packem_shared/result-chart-0VgP_3FP.js +1 -0
  65. package/dist/packem_shared/schema-diagram-GVgnLWTf.js +2 -0
  66. package/dist/packem_shared/{select-Bul-DeII.js → select-BssZMiFY.js} +1 -1
  67. package/dist/packem_shared/{sparkline-CgjeUU2I.js → sparkline-BNvxiJj_.js} +1 -1
  68. package/dist/packem_shared/{stat-card-fm_TF1mo.js → stat-card-BGJdhfm6.js} +1 -1
  69. package/dist/packem_shared/studio-C9Qvg13j.js +2 -0
  70. package/dist/packem_shared/{table-DdJBrClo.js → table-DZAB8cs3.js} +1 -1
  71. package/dist/packem_shared/{trace-handoff-Dw7mwjxu.js → trace-handoff-CuZ6WGgo.js} +1 -1
  72. package/dist/packem_shared/use-async-submit-B32whHJO.js +1 -0
  73. package/dist/standalone/{chunk-TITX6XEA.js → chunk-2FRLB5SB.js} +1 -1
  74. package/dist/standalone/chunk-2IFGRS6R.js +1 -0
  75. package/dist/standalone/{chunk-DBMFI2HC.js → chunk-2NO45MRI.js} +1 -1
  76. package/dist/standalone/{chunk-D62SDRMM.js → chunk-2YGNOZPZ.js} +1 -1
  77. package/dist/standalone/{chunk-UIGAA3GV.js → chunk-34WN3PEC.js} +1 -1
  78. package/dist/standalone/{chunk-ZVAGD3FT.js → chunk-3PXUIMP2.js} +1 -1
  79. package/dist/standalone/chunk-3SCGCJYS.js +1 -0
  80. package/dist/standalone/{chunk-465RIA2L.js → chunk-3WISGFZ7.js} +1 -1
  81. package/dist/standalone/{chunk-2OUIHY7G.js → chunk-44T6NSYY.js} +1 -1
  82. package/dist/standalone/{chunk-IBVBIKUI.js → chunk-57BUSXRD.js} +1 -1
  83. package/dist/standalone/{chunk-3FIN5PH4.js → chunk-6V27P65N.js} +2 -2
  84. package/dist/standalone/{chunk-OM36OEHZ.js → chunk-7KU3LR7G.js} +1 -1
  85. package/dist/standalone/{chunk-G6GX5TVB.js → chunk-7URLLMST.js} +1 -1
  86. package/dist/standalone/{chunk-RNOSWEMO.js → chunk-AB5WGAX6.js} +2 -2
  87. package/dist/standalone/{chunk-M7AWSDGY.js → chunk-AQZMKZMP.js} +1 -1
  88. package/dist/standalone/{chunk-VVNQP4CI.js → chunk-AUXEGD24.js} +1 -1
  89. package/dist/standalone/{chunk-JYLYJT27.js → chunk-BAJXBWFJ.js} +5 -5
  90. package/dist/standalone/{chunk-SCKKQIAE.js → chunk-BLJANR7J.js} +1 -1
  91. package/dist/standalone/{chunk-5TDGHWYU.js → chunk-BMYWOK5Q.js} +1 -1
  92. package/dist/standalone/{chunk-SKYFKPJC.js → chunk-CFXL7MQK.js} +1 -1
  93. package/dist/standalone/chunk-CZZWYUTR.js +1 -0
  94. package/dist/standalone/{chunk-QNHU4SKL.js → chunk-D7B2KFWM.js} +1 -1
  95. package/dist/standalone/{chunk-O3UMJLO3.js → chunk-DGO2XJOT.js} +1 -1
  96. package/dist/standalone/{chunk-2T22UR7E.js → chunk-DXJWFZFI.js} +1 -1
  97. package/dist/standalone/{chunk-QXECM52Z.js → chunk-E2C6CK7F.js} +1 -1
  98. package/dist/standalone/{chunk-PGVJE5F5.js → chunk-ECF57FQF.js} +1 -1
  99. package/dist/standalone/{chunk-BN4CIAXU.js → chunk-ESIEIGR3.js} +1 -1
  100. package/dist/standalone/chunk-ETU7KIO4.js +11 -0
  101. package/dist/standalone/{chunk-6K46XGR5.js → chunk-EYIEO5QZ.js} +1 -1
  102. package/dist/standalone/chunk-FA6AR5QU.js +1 -0
  103. package/dist/standalone/chunk-GL7YL3VF.js +1 -0
  104. package/dist/standalone/{chunk-LZKU262J.js → chunk-HJC67CE4.js} +1 -1
  105. package/dist/standalone/{chunk-WI4XINU2.js → chunk-I7FF5IIJ.js} +1 -1
  106. package/dist/standalone/{chunk-PE7TI4TQ.js → chunk-IGBUUFPN.js} +1 -1
  107. package/dist/standalone/{chunk-Z4AX76YZ.js → chunk-J4POSI6T.js} +1 -1
  108. package/dist/standalone/{chunk-A3DBEJLO.js → chunk-JRAUQ4L2.js} +1 -1
  109. package/dist/standalone/{chunk-3KXDX76D.js → chunk-KGPNIBOV.js} +1 -1
  110. package/dist/standalone/{chunk-4LCY5XUR.js → chunk-LT236J7E.js} +1 -1
  111. package/dist/standalone/{chunk-AQ4JNJF3.js → chunk-LV5UVTHL.js} +1 -1
  112. package/dist/standalone/{chunk-KEVIGWKP.js → chunk-LZ2RREQV.js} +1 -1
  113. package/dist/standalone/{chunk-ZNAGZU6H.js → chunk-LZGOETI3.js} +1 -1
  114. package/dist/standalone/{chunk-JEZDJ7D6.js → chunk-MVJMAEP4.js} +1 -1
  115. package/dist/standalone/{chunk-2O65JEMI.js → chunk-NQ4FA65F.js} +1 -1
  116. package/dist/standalone/{chunk-IUUSMC2R.js → chunk-NSUBZT43.js} +1 -1
  117. package/dist/standalone/{chunk-ZA5YIHZM.js → chunk-OZK52CH2.js} +1 -1
  118. package/dist/standalone/{chunk-7ONX5YGW.js → chunk-Q2QILUP4.js} +1 -1
  119. package/dist/standalone/{chunk-DMJDUC4L.js → chunk-QNQTMABQ.js} +1 -1
  120. package/dist/standalone/{chunk-VNQB6HY4.js → chunk-QVPKPH2T.js} +1 -1
  121. package/dist/standalone/{chunk-ABYJC3LS.js → chunk-SFQX7RUJ.js} +1 -1
  122. package/dist/standalone/{chunk-DYMO6MDG.js → chunk-TAWXVVAZ.js} +1 -1
  123. package/dist/standalone/{chunk-YTWBHPAT.js → chunk-TGQH54CS.js} +1 -1
  124. package/dist/standalone/{chunk-U6KDYJJC.js → chunk-TKFI6XYV.js} +1 -1
  125. package/dist/standalone/{chunk-EQZTSISX.js → chunk-TMGHRD6W.js} +1 -1
  126. package/dist/standalone/{chunk-JWXKUXYA.js → chunk-TVRCPIAV.js} +1 -1
  127. package/dist/standalone/{chunk-3DJ3IUUG.js → chunk-U5MIBWJD.js} +1 -1
  128. package/dist/standalone/chunk-U7ILDM43.js +59 -0
  129. package/dist/standalone/{chunk-UGU5GYDV.js → chunk-UE6A3CRB.js} +1 -1
  130. package/dist/standalone/{chunk-BNAMPDZ2.js → chunk-UZHRBXA7.js} +1 -1
  131. package/dist/standalone/chunk-VWKQ6X2S.js +1 -0
  132. package/dist/standalone/{chunk-TMNKNTC4.js → chunk-WOBRLIBX.js} +1 -1
  133. package/dist/standalone/{chunk-7YJNH3RB.js → chunk-WPERYUTG.js} +1 -1
  134. package/dist/standalone/{chunk-UZERI5YC.js → chunk-WQH3LT2P.js} +1 -1
  135. package/dist/standalone/chunk-WQJOV6L5.js +3 -0
  136. package/dist/standalone/{chunk-XNGYYOLS.js → chunk-YEGFNH56.js} +4 -4
  137. package/dist/standalone/{chunk-NNKN2XEZ.js → chunk-YOKL7XDT.js} +1 -1
  138. package/dist/standalone/{chunk-YD5O2NWK.js → chunk-ZCPQGIQW.js} +1 -1
  139. package/dist/standalone/{chunk-QM4EXWKF.js → chunk-ZURV2PEP.js} +1 -1
  140. package/dist/standalone/studio.js +1 -1
  141. package/dist/styles.css +1 -1
  142. package/package.json +6 -6
  143. package/dist/packem_shared/advisor-view-Coipc04R.js +0 -1
  144. package/dist/packem_shared/bar-chart-DraN_srt.js +0 -9
  145. package/dist/packem_shared/error-alert--Ie7ofJ0.js +0 -1
  146. package/dist/packem_shared/home-panel-BtxdqXDe.js +0 -3
  147. package/dist/packem_shared/result-chart-Gywg9DOk.js +0 -1
  148. package/dist/packem_shared/schema-diagram-DTRaCp6Y.js +0 -2
  149. package/dist/packem_shared/studio-Drf4en3j.js +0 -2
  150. package/dist/packem_shared/use-async-submit-BFIMhRqh.js +0 -1
  151. package/dist/standalone/chunk-5KCULF7S.js +0 -11
  152. package/dist/standalone/chunk-GZMKPBTJ.js +0 -1
  153. package/dist/standalone/chunk-ILNELDFC.js +0 -1
  154. package/dist/standalone/chunk-MV4A2PAK.js +0 -1
  155. package/dist/standalone/chunk-Q2Q7FR3R.js +0 -1
  156. package/dist/standalone/chunk-S3DWUXGY.js +0 -62
  157. package/dist/standalone/chunk-UBIPFCOZ.js +0 -1
  158. package/dist/standalone/chunk-ZQPWVALL.js +0 -3
  159. package/dist/standalone/chunk-ZZJ7VUVZ.js +0 -1
  160. /package/dist/standalone/{chunk-7H7LZRLP.js → chunk-4KIQ5RLS.js} +0 -0
  161. /package/dist/standalone/{chunk-UU2QJMGJ.js → chunk-MKYEFQCA.js} +0 -0
  162. /package/dist/standalone/{chunk-KUVMORDQ.js → chunk-PKSAWP56.js} +0 -0
  163. /package/dist/standalone/{chunk-MIQTKZAR.js → chunk-WJQLNYGX.js} +0 -0
@@ -1,4 +1,4 @@
1
- import{b as Ue}from"./chunk-3FIN5PH4.js";import{c as _e}from"./chunk-XF2B7P5A.js";import"./chunk-7H7LZRLP.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import{a as ye}from"./chunk-JN2Y24PY.js";import"./chunk-ESVP44Y3.js";import{a as Re}from"./chunk-54MMVNPT.js";import"./chunk-I6A5C46N.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import{a as Le}from"./chunk-AREBQI6D.js";import{a as De}from"./chunk-RMN2JN4S.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as Ne}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as re}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as ae}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as be}from"./chunk-VDW32UET.js";import{f as Se}from"./chunk-5KCULF7S.js";import"./chunk-XBDKZZ67.js";import{a as he}from"./chunk-XQCVZAGU.js";import{a as $e,b as Te,c as Fe,d as ce,e as ne,f as ee}from"./chunk-MIQTKZAR.js";import{a as je,e as ze}from"./chunk-UZERI5YC.js";import{d as Ce,f as me,g as ge,h as X,l as pe,o as W,q as Ke}from"./chunk-IUYFXK4X.js";import"./chunk-XNGYYOLS.js";import{a as g,e as fe,f as mt,g as gt,h as pt}from"./chunk-3XIESWL4.js";var M=fe(gt(),1),j=fe(mt(),1);var n=fe(pt(),1);var Oe=g((d,e,t)=>{let{onCopy:r,onDelete:s,onDownload:o,onToggleSelect:c}=t,i=g(()=>{r(d.key)},"i"),l=g(()=>{o(d.key)},"o"),u=g(()=>{s(d.key)},"u"),h=g(()=>{c(d.key)},"h");return{copy:i,download:l,name:d.key.slice(e.length),remove:u,toggle:h}},"Ke"),Me=g(d=>{let e=(0,M.c)(31),{busy:t,buttonClassName:r,copied:s,objectKey:o,onCopy:c,onDelete:i,onDownload:l,t:u}=d,h=`storage-copy-${o}`,f;e[0]!==s||e[1]!==u?(f=u(s?"Copied":"Copy URL"),e[0]=s,e[1]=u,e[2]=f):f=e[2];let m;e[3]!==t||e[4]!==r||e[5]!==c||e[6]!==h||e[7]!==f?(m=(0,n.jsx)(re,{className:r,"data-testid":h,disabled:t,onClick:c,size:"sm",type:"button",variant:"ghost",children:f}),e[3]=t,e[4]=r,e[5]=c,e[6]=h,e[7]=f,e[8]=m):m=e[8];let w=`storage-download-${o}`,a;e[9]!==u?(a=u("Download"),e[9]=u,e[10]=a):a=e[10];let k;e[11]!==t||e[12]!==r||e[13]!==l||e[14]!==w||e[15]!==a?(k=(0,n.jsx)(re,{className:r,"data-testid":w,disabled:t,onClick:l,size:"sm",type:"button",variant:"ghost",children:a}),e[11]=t,e[12]=r,e[13]=l,e[14]=w,e[15]=a,e[16]=k):k=e[16];let C;e[17]!==u?(C=u("Delete object?"),e[17]=u,e[18]=C):C=e[18];let x=`storage-delete-${o}`,b;e[19]!==u?(b=u("Delete"),e[19]=u,e[20]=b):b=e[20];let v;e[21]!==t||e[22]!==i||e[23]!==C||e[24]!==x||e[25]!==b?(v=(0,n.jsx)(Le,{confirmLabel:C,disabled:t,onConfirm:i,testId:x,children:b}),e[21]=t,e[22]=i,e[23]=C,e[24]=x,e[25]=b,e[26]=v):v=e[26];let y;return e[27]!==v||e[28]!==m||e[29]!==k?(y=(0,n.jsxs)(n.Fragment,{children:[m,k,v]}),e[27]=v,e[28]=m,e[29]=k,e[30]=y):y=e[30],y},"De"),Ae=g(d=>{let e=(0,M.c)(14),{objectKey:t,references:r,t:s}=d;if(r===void 0)return null;if(r.length===0){let h=`storage-orphan-${t}`,f;e[0]!==s?(f=s("Orphan"),e[0]=s,e[1]=f):f=e[1];let m;return e[2]!==h||e[3]!==f?(m=(0,n.jsx)(ae,{"data-testid":h,variant:"warning",children:f}),e[2]=h,e[3]=f,e[4]=m):m=e[4],m}let o;e[5]!==r?(o=r.map(bt).join(`
1
+ import{b as Ue}from"./chunk-6V27P65N.js";import{c as _e}from"./chunk-XF2B7P5A.js";import"./chunk-4KIQ5RLS.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import{a as ye}from"./chunk-JN2Y24PY.js";import"./chunk-ESVP44Y3.js";import{a as Re}from"./chunk-54MMVNPT.js";import"./chunk-I6A5C46N.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import{a as Le}from"./chunk-AREBQI6D.js";import{a as De}from"./chunk-RMN2JN4S.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as Ne}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as re}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as ae}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as be}from"./chunk-VDW32UET.js";import{f as Se}from"./chunk-ETU7KIO4.js";import"./chunk-XBDKZZ67.js";import{a as he}from"./chunk-XQCVZAGU.js";import{a as $e,b as Te,c as Fe,d as ce,e as ne,f as ee}from"./chunk-WJQLNYGX.js";import{a as je,e as ze}from"./chunk-WQH3LT2P.js";import{d as Ce,f as me,g as ge,h as X,l as pe,o as W,q as Ke}from"./chunk-IUYFXK4X.js";import"./chunk-YEGFNH56.js";import{a as g,e as fe,f as mt,g as gt,h as pt}from"./chunk-3XIESWL4.js";var M=fe(gt(),1),j=fe(mt(),1);var n=fe(pt(),1);var Oe=g((d,e,t)=>{let{onCopy:r,onDelete:s,onDownload:o,onToggleSelect:c}=t,i=g(()=>{r(d.key)},"i"),l=g(()=>{o(d.key)},"o"),u=g(()=>{s(d.key)},"u"),h=g(()=>{c(d.key)},"h");return{copy:i,download:l,name:d.key.slice(e.length),remove:u,toggle:h}},"Ke"),Me=g(d=>{let e=(0,M.c)(31),{busy:t,buttonClassName:r,copied:s,objectKey:o,onCopy:c,onDelete:i,onDownload:l,t:u}=d,h=`storage-copy-${o}`,f;e[0]!==s||e[1]!==u?(f=u(s?"Copied":"Copy URL"),e[0]=s,e[1]=u,e[2]=f):f=e[2];let m;e[3]!==t||e[4]!==r||e[5]!==c||e[6]!==h||e[7]!==f?(m=(0,n.jsx)(re,{className:r,"data-testid":h,disabled:t,onClick:c,size:"sm",type:"button",variant:"ghost",children:f}),e[3]=t,e[4]=r,e[5]=c,e[6]=h,e[7]=f,e[8]=m):m=e[8];let w=`storage-download-${o}`,a;e[9]!==u?(a=u("Download"),e[9]=u,e[10]=a):a=e[10];let k;e[11]!==t||e[12]!==r||e[13]!==l||e[14]!==w||e[15]!==a?(k=(0,n.jsx)(re,{className:r,"data-testid":w,disabled:t,onClick:l,size:"sm",type:"button",variant:"ghost",children:a}),e[11]=t,e[12]=r,e[13]=l,e[14]=w,e[15]=a,e[16]=k):k=e[16];let C;e[17]!==u?(C=u("Delete object?"),e[17]=u,e[18]=C):C=e[18];let x=`storage-delete-${o}`,b;e[19]!==u?(b=u("Delete"),e[19]=u,e[20]=b):b=e[20];let v;e[21]!==t||e[22]!==i||e[23]!==C||e[24]!==x||e[25]!==b?(v=(0,n.jsx)(Le,{confirmLabel:C,disabled:t,onConfirm:i,testId:x,children:b}),e[21]=t,e[22]=i,e[23]=C,e[24]=x,e[25]=b,e[26]=v):v=e[26];let y;return e[27]!==v||e[28]!==m||e[29]!==k?(y=(0,n.jsxs)(n.Fragment,{children:[m,k,v]}),e[27]=v,e[28]=m,e[29]=k,e[30]=y):y=e[30],y},"De"),Ae=g(d=>{let e=(0,M.c)(14),{objectKey:t,references:r,t:s}=d;if(r===void 0)return null;if(r.length===0){let h=`storage-orphan-${t}`,f;e[0]!==s?(f=s("Orphan"),e[0]=s,e[1]=f):f=e[1];let m;return e[2]!==h||e[3]!==f?(m=(0,n.jsx)(ae,{"data-testid":h,variant:"warning",children:f}),e[2]=h,e[3]=f,e[4]=m):m=e[4],m}let o;e[5]!==r?(o=r.map(bt).join(`
2
2
  `),e[5]=r,e[6]=o):o=e[6];let c=o,i=`storage-refs-${t}`,l;e[7]!==r.length||e[8]!==s?(l=r.length===1?s("1 record"):s("{count} records",{count:r.length}),e[7]=r.length,e[8]=s,e[9]=l):l=e[9];let u;return e[10]!==c||e[11]!==i||e[12]!==l?(u=(0,n.jsx)(ae,{"data-testid":i,title:c,variant:"secondary",children:l}),e[10]=c,e[11]=i,e[12]=l,e[13]=u):u=e[13],u},"Te"),Pe=g(d=>{let e=(0,M.c)(7),{objectKey:t,onToggle:r,selected:s,t:o}=d,c;e[0]!==o?(c=o("Select row"),e[0]=o,e[1]=c):c=e[1];let i=`storage-select-${t}`,l;return e[2]!==r||e[3]!==s||e[4]!==c||e[5]!==i?(l=(0,n.jsx)(ye,{"aria-label":c,checked:s,"data-testid":i,onCheckedChange:r}),e[2]=r,e[3]=s,e[4]=c,e[5]=i,e[6]=l):l=e[6],l},"Fe");function bt(d){return`${d.table}\xB7${d.id}`}g(bt,"yt");var yt=g(d=>{let e=(0,M.c)(10),{colSpan:t,name:r,onEnter:s}=d,o;e[0]!==r||e[1]!==s?(o=g(()=>{s(r)},"n"),e[0]=r,e[1]=s,e[2]=o):o=e[2];let c=o,i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=(0,n.jsx)("svg",{"aria-hidden":"true",className:"size-4 text-muted-foreground",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,n.jsx)("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"})}),e[3]=i):i=e[3];let l;e[4]!==c||e[5]!==r?(l=(0,n.jsxs)("button",{className:"inline-flex items-center gap-2 font-mono text-xs outline-none hover:text-foreground focus-visible:text-foreground","data-testid":"fb-folder",onClick:c,type:"button",children:[i,r]}),e[4]=c,e[5]=r,e[6]=l):l=e[6];let u;return e[7]!==t||e[8]!==l?(u=(0,n.jsx)(ce,{children:(0,n.jsx)(ee,{colSpan:t,children:l})}),e[7]=t,e[8]=l,e[9]=u):u=e[9],u},"xt"),xt=g(d=>{let e=(0,M.c)(37),{busy:t,copiedKey:r,handlers:s,object:o,prefix:c,references:i,selected:l,showReferences:u,t:h}=d,f;e[0]!==s||e[1]!==o||e[2]!==c?(f=Oe(o,c,s),e[0]=s,e[1]=o,e[2]=c,e[3]=f):f=e[3];let{copy:m,download:w,name:a,remove:k,toggle:C}=f,x;e[4]!==o.key||e[5]!==l||e[6]!==h||e[7]!==C?(x=(0,n.jsx)(ee,{className:"w-8",children:(0,n.jsx)(Pe,{objectKey:o.key,onToggle:C,selected:l,t:h})}),e[4]=o.key,e[5]=l,e[6]=h,e[7]=C,e[8]=x):x=e[8];let b;e[9]!==a?(b=(0,n.jsx)(ee,{className:"font-mono text-xs",children:a}),e[9]=a,e[10]=b):b=e[10];let v;e[11]!==o.size?(v=pe(o.size),e[11]=o.size,e[12]=v):v=e[12];let y;e[13]!==v?(y=(0,n.jsx)(ee,{className:"tabular-nums text-muted-foreground",children:v}),e[13]=v,e[14]=y):y=e[14];let z=o.httpMetadata?.contentType??"",S;e[15]!==z?(S=(0,n.jsx)(ee,{children:z}),e[15]=z,e[16]=S):S=e[16];let N;e[17]!==o.key||e[18]!==i||e[19]!==u||e[20]!==h?(N=u&&(0,n.jsx)(ee,{children:(0,n.jsx)(Ae,{objectKey:o.key,references:i,t:h})}),e[17]=o.key,e[18]=i,e[19]=u,e[20]=h,e[21]=N):N=e[21];let $=r===o.key,K;e[22]!==t||e[23]!==m||e[24]!==w||e[25]!==o.key||e[26]!==k||e[27]!==h||e[28]!==$?(K=(0,n.jsx)(ee,{className:"text-right",children:(0,n.jsx)("span",{className:"inline-flex items-center gap-1",children:(0,n.jsx)(Me,{busy:t,copied:$,objectKey:o.key,onCopy:m,onDelete:k,onDownload:w,t:h})})}),e[22]=t,e[23]=m,e[24]=w,e[25]=o.key,e[26]=k,e[27]=h,e[28]=$,e[29]=K):K=e[29];let F;return e[30]!==K||e[31]!==x||e[32]!==b||e[33]!==y||e[34]!==S||e[35]!==N?(F=(0,n.jsxs)(ce,{"data-testid":"fb-row",children:[x,b,y,S,N,K]}),e[30]=K,e[31]=x,e[32]=b,e[33]=y,e[34]=S,e[35]=N,e[36]=F):F=e[36],F},"vt"),vt=g(d=>{let e=(0,M.c)(65),{allSelected:t,busy:r,copiedKey:s,files:o,folders:c,handlers:i,onEnterFolder:l,prefix:u,references:h,selected:f,showReferences:m,someSelected:w,t:a,toggleSelectAll:k}=d,C;e[0]!==a?(C=a("Select all rows"),e[0]=a,e[1]=C):C=e[1];let x;e[2]!==t||e[3]!==w||e[4]!==C||e[5]!==k?(x=(0,n.jsx)(ne,{className:"w-8",children:(0,n.jsx)(ye,{"aria-label":C,checked:t,"data-testid":"storage-select-all",indeterminate:w,onCheckedChange:k})}),e[2]=t,e[3]=w,e[4]=C,e[5]=k,e[6]=x):x=e[6];let b;e[7]!==a?(b=a("key"),e[7]=a,e[8]=b):b=e[8];let v;e[9]!==b?(v=(0,n.jsx)(ne,{children:b}),e[9]=b,e[10]=v):v=e[10];let y;e[11]!==a?(y=a("size"),e[11]=a,e[12]=y):y=e[12];let z;e[13]!==y?(z=(0,n.jsx)(ne,{children:y}),e[13]=y,e[14]=z):z=e[14];let S;e[15]!==a?(S=a("content-type"),e[15]=a,e[16]=S):S=e[16];let N;e[17]!==S?(N=(0,n.jsx)(ne,{children:S}),e[17]=S,e[18]=N):N=e[18];let $;e[19]!==m||e[20]!==a?($=m&&(0,n.jsx)(ne,{children:a("used by")}),e[19]=m,e[20]=a,e[21]=$):$=e[21];let K;e[22]!==a?(K=a("Actions"),e[22]=a,e[23]=K):K=e[23];let F;e[24]!==K?(F=(0,n.jsx)(ne,{"aria-label":K}),e[24]=K,e[25]=F):F=e[25];let T;e[26]!==F||e[27]!==x||e[28]!==v||e[29]!==z||e[30]!==N||e[31]!==$?(T=(0,n.jsx)(Te,{children:(0,n.jsxs)(ce,{children:[x,v,z,N,$,F]})}),e[26]=F,e[27]=x,e[28]=v,e[29]=z,e[30]=N,e[31]=$,e[32]=T):T=e[32];let L;if(e[33]!==c||e[34]!==l||e[35]!==m){let R;e[37]!==l||e[38]!==m?(R=g(_=>(0,n.jsx)(yt,{colSpan:m?6:5,name:_,onEnter:l},_),"R"),e[37]=l,e[38]=m,e[39]=R):R=e[39],L=c.map(R),e[33]=c,e[34]=l,e[35]=m,e[36]=L}else L=e[36];let B;if(e[40]!==r||e[41]!==s||e[42]!==o||e[43]!==i||e[44]!==u||e[45]!==h||e[46]!==f||e[47]!==m||e[48]!==a){let R;e[50]!==r||e[51]!==s||e[52]!==i||e[53]!==u||e[54]!==h||e[55]!==f||e[56]!==m||e[57]!==a?(R=g(_=>(0,n.jsx)(xt,{busy:r,copiedKey:s,handlers:i,object:_,prefix:u,references:h[_.key],selected:f.has(_.key),showReferences:m,t:a},_.key),"R"),e[50]=r,e[51]=s,e[52]=i,e[53]=u,e[54]=h,e[55]=f,e[56]=m,e[57]=a,e[58]=R):R=e[58],B=o.map(R),e[40]=r,e[41]=s,e[42]=o,e[43]=i,e[44]=u,e[45]=h,e[46]=f,e[47]=m,e[48]=a,e[49]=B}else B=e[49];let U;e[59]!==L||e[60]!==B?(U=(0,n.jsxs)(Fe,{children:[L,B]}),e[59]=L,e[60]=B,e[61]=U):U=e[61];let I;return e[62]!==T||e[63]!==U?(I=(0,n.jsx)(je,{className:"overflow-hidden py-0",children:(0,n.jsx)(ze,{className:"px-0",children:(0,n.jsxs)($e,{"data-testid":"fb-table",children:[T,U]})})}),e[62]=T,e[63]=U,e[64]=I):I=e[64],I},"kt"),kt=[{label:"15m",seconds:900},{label:"1h",seconds:3600},{label:"24h",seconds:86400},{label:"7d",seconds:604800}],wt=3600,Be=g((d,e)=>{if(e==="size")return d.size;if(e==="type")return d.httpMetadata?.contentType??"";if(e==="date"){if(d.uploaded===void 0)return 0;let t=new Date(d.uploaded).getTime();return Number.isNaN(t)?0:t}return e.startsWith("tag:")?d.customMetadata?.[e.slice(4)]??"":d.key},"ve"),St=g((d,e,t)=>{let r=t==="desc"?-1:1;return d.toSorted((s,o)=>{let c=Be(s,e),i=Be(o,e);return(typeof c=="number"&&typeof i=="number"?c-i:String(c).localeCompare(String(i)))*r})},"Nt"),Ct=g((d,e)=>{let t=new Set,r=[];for(let s of d){let o=s.key.slice(e.length),c=o.indexOf("/");c===-1?r.push(s):t.add(o.slice(0,c+1))}return{files:r,folders:[...t].toSorted((s,o)=>s.localeCompare(o))}},"Ct"),Nt=g(d=>{let e=(0,M.c)(59),{bucket:t,buckets:r,busy:s,draftPrefix:o,expiry:c,fileInputRef:i,onBucketChange:l,onExpiryChange:u,onFileChange:h,onList:f,onPrefixChange:m,onUploadClick:w,t:a}=d,k;e[0]!==m?(k=g(P=>{m(P.target.value)},"v"),e[0]=m,e[1]=k):k=e[1];let C=k,x;e[2]!==l?(x=g(P=>{l(P.target.value)},"y"),e[2]=l,e[3]=x):x=e[3];let b=x,v;e[4]!==u?(v=g(P=>{u(Number.parseInt(P.target.value,10))},"x"),e[4]=u,e[5]=v):v=e[5];let y=v,z;e[6]!==t||e[7]!==r||e[8]!==b||e[9]!==a?(z=r.length>0&&(0,n.jsx)("select",{"aria-label":a("Bucket"),className:"h-8 rounded-md border border-border bg-background px-1 outline-none focus-visible:border-ring","data-testid":"fb-bucket",onChange:b,value:t,children:r.map(zt)}),e[6]=t,e[7]=r,e[8]=b,e[9]=a,e[10]=z):z=e[10];let S;e[11]!==a?(S=a("Key prefix"),e[11]=a,e[12]=S):S=e[12];let N;e[13]!==a?(N=a("key prefix (optional)"),e[13]=a,e[14]=N):N=e[14];let $;e[15]!==o||e[16]!==C||e[17]!==S||e[18]!==N?($=(0,n.jsx)(Ne,{"aria-label":S,className:"h-8 w-64 max-w-full","data-testid":"fb-prefix-input",onChange:C,placeholder:N,value:o}),e[15]=o,e[16]=C,e[17]=S,e[18]=N,e[19]=$):$=e[19];let K;e[20]!==a?(K=a("List"),e[20]=a,e[21]=K):K=e[21];let F;e[22]!==s||e[23]!==f||e[24]!==K?(F=(0,n.jsx)(re,{"data-testid":"fb-list",disabled:s,onClick:f,size:"sm",type:"button",children:K}),e[22]=s,e[23]=f,e[24]=K,e[25]=F):F=e[25];let T;e[26]!==s||e[27]!==a?(T=a(s?"Uploading\u2026":"Upload"),e[26]=s,e[27]=a,e[28]=T):T=e[28];let L;e[29]!==s||e[30]!==w||e[31]!==T?(L=(0,n.jsx)(re,{"data-testid":"storage-upload",disabled:s,onClick:w,size:"sm",type:"button",variant:"outline",children:T}),e[29]=s,e[30]=w,e[31]=T,e[32]=L):L=e[32];let B;e[33]!==i||e[34]!==h?(B=(0,n.jsx)("input",{className:"hidden","data-testid":"storage-file-input",onChange:h,ref:i,type:"file"}),e[33]=i,e[34]=h,e[35]=B):B=e[35];let U;e[36]!==a?(U=a("Link expiry"),e[36]=a,e[37]=U):U=e[37];let I;e[38]!==a?(I=kt.map(P=>(0,n.jsx)("option",{value:P.seconds,children:a(P.label)},P.seconds)),e[38]=a,e[39]=I):I=e[39];let R;e[40]!==c||e[41]!==y||e[42]!==I?(R=(0,n.jsx)("select",{className:"h-8 rounded-md border border-border bg-background px-1 tabular-nums outline-none focus-visible:border-ring","data-testid":"storage-expiry",id:"storage-expiry",onChange:y,value:c,children:I}),e[40]=c,e[41]=y,e[42]=I,e[43]=R):R=e[43];let _;e[44]!==U||e[45]!==R?(_=(0,n.jsxs)("label",{className:"ml-auto flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"storage-expiry",children:[U,R]}),e[44]=U,e[45]=R,e[46]=_):_=e[46];let O;e[47]!==a?(O=a("Open in Cloudflare"),e[47]=a,e[48]=O):O=e[48];let A;e[49]!==O?(A=(0,n.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"fb-cf-link",href:_e,rel:"noreferrer",target:"_blank",children:O}),e[49]=O,e[50]=A):A=e[50];let G;return e[51]!==L||e[52]!==B||e[53]!==_||e[54]!==A||e[55]!==z||e[56]!==$||e[57]!==F?(G=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[z,$,F,L,B,_,A]}),e[51]=L,e[52]=B,e[53]=_,e[54]=A,e[55]=z,e[56]=$,e[57]=F,e[58]=G):G=e[58],G},"$t"),jt=g(d=>{let e=(0,M.c)(66),{onSortKeyChange:t,onThumbSizeChange:r,showGrid:s,showList:o,sortDirection:c,sortKey:i,t:l,tagKeys:u,thumbSize:h,toggleSortDirection:f,view:m}=d,w;e[0]!==t?(w=g(V=>{t(V.target.value)},"k"),e[0]=t,e[1]=w):w=e[1];let a=w,k;e[2]!==r?(k=g(V=>{r(Number.parseInt(V.target.value,10))},"v"),e[2]=r,e[3]=k):k=e[3];let C=k,x=m==="list",b;e[4]!==l?(b=l("List"),e[4]=l,e[5]=b):b=e[5];let v;e[6]!==o||e[7]!==x||e[8]!==b?(v=(0,n.jsx)("button",{"aria-pressed":x,className:"px-2 py-1 outline-none transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:text-accent-foreground","data-testid":"fb-view-list",onClick:o,type:"button",children:b}),e[6]=o,e[7]=x,e[8]=b,e[9]=v):v=e[9];let y=m==="grid",z;e[10]!==l?(z=l("Grid"),e[10]=l,e[11]=z):z=e[11];let S;e[12]!==s||e[13]!==y||e[14]!==z?(S=(0,n.jsx)("button",{"aria-pressed":y,className:"border-s border-border px-2 py-1 outline-none transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:text-accent-foreground","data-testid":"fb-view-grid",onClick:s,type:"button",children:z}),e[12]=s,e[13]=y,e[14]=z,e[15]=S):S=e[15];let N;e[16]!==v||e[17]!==S?(N=(0,n.jsxs)("div",{className:"inline-flex overflow-hidden rounded-md border border-border",children:[v,S]}),e[16]=v,e[17]=S,e[18]=N):N=e[18];let $;e[19]!==l?($=l("Sort"),e[19]=l,e[20]=$):$=e[20];let K;e[21]!==l?(K=l("Name"),e[21]=l,e[22]=K):K=e[22];let F;e[23]!==K?(F=(0,n.jsx)("option",{value:"name",children:K}),e[23]=K,e[24]=F):F=e[24];let T;e[25]!==l?(T=l("size"),e[25]=l,e[26]=T):T=e[26];let L;e[27]!==T?(L=(0,n.jsx)("option",{value:"size",children:T}),e[27]=T,e[28]=L):L=e[28];let B;e[29]!==l?(B=l("Type"),e[29]=l,e[30]=B):B=e[30];let U;e[31]!==B?(U=(0,n.jsx)("option",{value:"type",children:B}),e[31]=B,e[32]=U):U=e[32];let I;e[33]!==l?(I=l("Modified"),e[33]=l,e[34]=I):I=e[34];let R;e[35]!==I?(R=(0,n.jsx)("option",{value:"date",children:I}),e[35]=I,e[36]=R):R=e[36];let _;e[37]!==u?(_=u.map(Kt),e[37]=u,e[38]=_):_=e[38];let O;e[39]!==a||e[40]!==i||e[41]!==F||e[42]!==L||e[43]!==U||e[44]!==R||e[45]!==_?(O=(0,n.jsxs)("select",{className:"h-8 rounded-md border border-border bg-background px-1 outline-none focus-visible:border-ring","data-testid":"fb-sort",id:"fb-sort",onChange:a,value:i,children:[F,L,U,R,_]}),e[39]=a,e[40]=i,e[41]=F,e[42]=L,e[43]=U,e[44]=R,e[45]=_,e[46]=O):O=e[46];let A;e[47]!==$||e[48]!==O?(A=(0,n.jsxs)("label",{className:"flex items-center gap-1.5 text-muted-foreground",htmlFor:"fb-sort",children:[$,O]}),e[47]=$,e[48]=O,e[49]=A):A=e[49];let G;e[50]!==l?(G=l("Toggle sort direction"),e[50]=l,e[51]=G):G=e[51];let P=c==="asc"?"\u2191":"\u2193",H;e[52]!==G||e[53]!==P||e[54]!==f?(H=(0,n.jsx)("button",{"aria-label":G,className:"flex size-8 items-center justify-center rounded-md border border-border tabular-nums outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"fb-sort-dir",onClick:f,type:"button",children:P}),e[52]=G,e[53]=P,e[54]=f,e[55]=H):H=e[55];let Y;e[56]!==C||e[57]!==l||e[58]!==h||e[59]!==m?(Y=m==="grid"&&(0,n.jsxs)("label",{className:"ml-auto flex items-center gap-1.5 text-muted-foreground",htmlFor:"fb-thumb-size",children:[l("Thumbnail size"),(0,n.jsx)("input",{className:"accent-primary","data-testid":"fb-thumb-size",id:"fb-thumb-size",max:240,min:80,onChange:C,step:8,type:"range",value:h})]}),e[56]=C,e[57]=l,e[58]=h,e[59]=m,e[60]=Y):Y=e[60];let oe;return e[61]!==A||e[62]!==H||e[63]!==Y||e[64]!==N?(oe=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs","data-testid":"fb-controls",children:[N,A,H,Y]}),e[61]=A,e[62]=H,e[63]=Y,e[64]=N,e[65]=oe):oe=e[65],oe},"jt");function zt(d){return(0,n.jsx)("option",{value:d,children:d},d)}g(zt,"zt");function Kt(d){return(0,n.jsx)("option",{value:`tag:${d}`,children:d},d)}g(Kt,"Kt");var Dt=/\.(?:avif|bmp|gif|ico|jpe?g|png|svg|webp)$/iu,$t=g(d=>(d.httpMetadata?.contentType??"").startsWith("image/")||Dt.test(d.key),"Tt"),Tt=g(()=>{let d=(0,M.c)(1),e;return d[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("svg",{"aria-hidden":"true",className:"size-8 text-muted-foreground/60",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.4,viewBox:"0 0 24 24",children:(0,n.jsx)("path",{d:"M7 3h7l5 5v13a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Zm7 0v5h5"})}),d[0]=e):e=d[0],e},"Ft"),Ft=g(d=>{let e=(0,M.c)(13),{object:t,resolveUrl:r}=d,[s,o]=(0,j.useState)(null),[c,i]=(0,j.useState)(!1),l;e[0]!==t?(l=$t(t),e[0]=t,e[1]=l):l=e[1];let u=l,h,f;e[2]!==u||e[3]!==t.key||e[4]!==r?(h=g(()=>{if(!u)return;let k={cancelled:!1};return W((async()=>{try{let C=await r(t.key);k.cancelled||o(C)}catch{k.cancelled||i(!0)}})()),()=>{k.cancelled=!0}},"h"),f=[u,t.key,r],e[2]=u,e[3]=t.key,e[4]=r,e[5]=h,e[6]=f):(h=e[5],f=e[6]),(0,j.useEffect)(h,f);let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=g(()=>{i(!0)},"m"),e[7]=m):m=e[7];let w=m,a;return e[8]!==c||e[9]!==u||e[10]!==t.key||e[11]!==s?(a=(0,n.jsx)("div",{className:"flex aspect-square w-full items-center justify-center overflow-hidden rounded-md border border-border bg-muted/30",children:u&&s!==null&&!c?(0,n.jsx)("img",{alt:t.key,className:"size-full object-cover",loading:"lazy",onError:w,src:s}):(0,n.jsx)(Tt,{})}),e[8]=c,e[9]=u,e[10]=t.key,e[11]=s,e[12]=a):a=e[12],a},"Rt"),Lt=g(d=>{let e=(0,M.c)(42),{busy:t,copiedKey:r,handlers:s,object:o,prefix:c,references:i,resolveUrl:l,selected:u,showReferences:h,t:f}=d,m;e[0]!==s||e[1]!==o||e[2]!==c?(m=Oe(o,c,s),e[0]=s,e[1]=o,e[2]=c,e[3]=m):m=e[3];let{copy:w,download:a,name:k,remove:C,toggle:x}=m,b;e[4]!==o||e[5]!==l?(b=(0,n.jsx)(Ft,{object:o,resolveUrl:l}),e[4]=o,e[5]=l,e[6]=b):b=e[6];let v;e[7]!==o.key||e[8]!==u||e[9]!==f||e[10]!==x?(v=(0,n.jsx)("span",{className:"absolute left-1.5 top-1.5 rounded bg-background/80 p-0.5",children:(0,n.jsx)(Pe,{objectKey:o.key,onToggle:x,selected:u,t:f})}),e[7]=o.key,e[8]=u,e[9]=f,e[10]=x,e[11]=v):v=e[11];let y;e[12]!==b||e[13]!==v?(y=(0,n.jsxs)("div",{className:"relative",children:[b,v]}),e[12]=b,e[13]=v,e[14]=y):y=e[14];let z;e[15]!==k?(z=(0,n.jsx)("p",{className:"truncate font-mono text-xs",title:k,children:k}),e[15]=k,e[16]=z):z=e[16];let S;e[17]!==o.size?(S=pe(o.size),e[17]=o.size,e[18]=S):S=e[18];let N;e[19]!==S?(N=(0,n.jsx)("p",{className:"text-[11px] tabular-nums text-muted-foreground",children:S}),e[19]=S,e[20]=N):N=e[20];let $;e[21]!==o.key||e[22]!==i||e[23]!==h||e[24]!==f?($=h&&(0,n.jsx)("div",{className:"mt-1",children:(0,n.jsx)(Ae,{objectKey:o.key,references:i,t:f})}),e[21]=o.key,e[22]=i,e[23]=h,e[24]=f,e[25]=$):$=e[25];let K;e[26]!==z||e[27]!==N||e[28]!==$?(K=(0,n.jsxs)("div",{className:"min-w-0",children:[z,N,$]}),e[26]=z,e[27]=N,e[28]=$,e[29]=K):K=e[29];let F=r===o.key,T;e[30]!==t||e[31]!==w||e[32]!==a||e[33]!==o.key||e[34]!==C||e[35]!==f||e[36]!==F?(T=(0,n.jsx)("div",{className:"flex items-center gap-1",children:(0,n.jsx)(Me,{busy:t,buttonClassName:"h-7 px-2 text-xs",copied:F,objectKey:o.key,onCopy:w,onDelete:C,onDownload:a,t:f})}),e[30]=t,e[31]=w,e[32]=a,e[33]=o.key,e[34]=C,e[35]=f,e[36]=F,e[37]=T):T=e[37];let L;return e[38]!==T||e[39]!==y||e[40]!==K?(L=(0,n.jsxs)("div",{className:"flex flex-col gap-1.5","data-testid":"fb-tile",children:[y,K,T]}),e[38]=T,e[39]=y,e[40]=K,e[41]=L):L=e[41],L},"Lt"),Rt=g(d=>{let e=(0,M.c)(9),{name:t,onEnter:r}=d,s;e[0]!==t||e[1]!==r?(s=g(()=>{r(t)},"l"),e[0]=t,e[1]=r,e[2]=s):s=e[2];let o=s,c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=(0,n.jsx)("span",{className:"flex aspect-square w-full items-center justify-center rounded-md border border-border bg-muted/30 transition-colors hover:bg-accent",children:(0,n.jsx)("svg",{"aria-hidden":"true",className:"size-10 text-muted-foreground",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.4,viewBox:"0 0 24 24",children:(0,n.jsx)("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"})})}),e[3]=c):c=e[3];let i;e[4]!==t?(i=(0,n.jsx)("span",{className:"truncate font-mono text-xs",title:t,children:t}),e[4]=t,e[5]=i):i=e[5];let l;return e[6]!==o||e[7]!==i?(l=(0,n.jsxs)("button",{className:"flex flex-col gap-1.5 text-left outline-none","data-testid":"fb-folder",onClick:o,type:"button",children:[c,i]}),e[6]=o,e[7]=i,e[8]=l):l=e[8],l},"Ot"),Ut=g(d=>{let e=(0,M.c)(34),{busy:t,copiedKey:r,files:s,folders:o,handlers:c,onEnterFolder:i,prefix:l,references:u,resolveUrl:h,selected:f,showReferences:m,size:w,t:a}=d,k;e[0]!==w?(k=w.toString(),e[0]=w,e[1]=k):k=e[1];let C=`repeat(auto-fill, minmax(${k}px, 1fr))`,x;e[2]!==C?(x={gridTemplateColumns:C},e[2]=C,e[3]=x):x=e[3];let b=x,v;if(e[4]!==o||e[5]!==i){let S;e[7]!==i?(S=g(N=>(0,n.jsx)(Rt,{name:N,onEnter:i},N),"w"),e[7]=i,e[8]=S):S=e[8],v=o.map(S),e[4]=o,e[5]=i,e[6]=v}else v=e[6];let y;if(e[9]!==t||e[10]!==r||e[11]!==s||e[12]!==c||e[13]!==l||e[14]!==u||e[15]!==h||e[16]!==f||e[17]!==m||e[18]!==a){let S;e[20]!==t||e[21]!==r||e[22]!==c||e[23]!==l||e[24]!==u||e[25]!==h||e[26]!==f||e[27]!==m||e[28]!==a?(S=g(N=>(0,n.jsx)(Lt,{busy:t,copiedKey:r,handlers:c,object:N,prefix:l,references:u[N.key],resolveUrl:h,selected:f.has(N.key),showReferences:m,t:a},N.key),"w"),e[20]=t,e[21]=r,e[22]=c,e[23]=l,e[24]=u,e[25]=h,e[26]=f,e[27]=m,e[28]=a,e[29]=S):S=e[29],y=s.map(S),e[9]=t,e[10]=r,e[11]=s,e[12]=c,e[13]=l,e[14]=u,e[15]=h,e[16]=f,e[17]=m,e[18]=a,e[19]=y}else y=e[19];let z;return e[30]!==b||e[31]!==v||e[32]!==y?(z=(0,n.jsxs)("div",{className:"grid gap-4","data-testid":"fb-gallery",style:b,children:[v,y]}),e[30]=b,e[31]=v,e[32]=y,e[33]=z):z=e[33],z},"Et"),_t=g(d=>{let e=(0,M.c)(23),{reference:t,t:r}=d,s=`fb-dangling-${t.table}-${t.id}-${t.column}`,o=`${t.table}\xB7${t.id}`,c;e[0]!==o?(c=(0,n.jsx)(ae,{variant:"secondary",children:o}),e[0]=o,e[1]=c):c=e[1];let i;e[2]!==t.column?(i=(0,n.jsx)("span",{className:"text-muted-foreground",children:t.column}),e[2]=t.column,e[3]=i):i=e[3];let l;e[4]!==r?(l=r("\u2192"),e[4]=r,e[5]=l):l=e[5];let u;e[6]!==l?(u=(0,n.jsx)("span",{className:"text-muted-foreground/60",children:l}),e[6]=l,e[7]=u):u=e[7];let h;e[8]!==t.key?(h=(0,n.jsx)("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-foreground",children:t.key}),e[8]=t.key,e[9]=h):h=e[9];let f;e[10]!==c||e[11]!==i||e[12]!==u||e[13]!==h?(f=(0,n.jsxs)("span",{className:"flex flex-wrap items-center gap-1.5",children:[c,i,u,h]}),e[10]=c,e[11]=i,e[12]=u,e[13]=h,e[14]=f):f=e[14];let m;e[15]!==r?(m=r("Missing object"),e[15]=r,e[16]=m):m=e[16];let w;e[17]!==m?(w=(0,n.jsx)(ae,{className:"border-destructive/40 text-destructive",variant:"outline",children:m}),e[17]=m,e[18]=w):w=e[18];let a;return e[19]!==s||e[20]!==w||e[21]!==f?(a=(0,n.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-border/60 px-3 py-2 text-xs","data-testid":s,children:[f,w]}),e[19]=s,e[20]=w,e[21]=f,e[22]=a):a=e[22],a},"Ut"),Bt=g(d=>{let e=(0,M.c)(37),{busy:t,onCheck:r,references:s,t:o,truncated:c}=d,i;e[0]!==o?(i=o("Integrity"),e[0]=o,e[1]=i):i=e[1];let l;e[2]!==i?(l=(0,n.jsx)("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:i}),e[2]=i,e[3]=l):l=e[3];let u;e[4]!==o?(u=o("Orphaned objects"),e[4]=o,e[5]=u):u=e[5];let h;e[6]!==u?(h=(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:u}),e[6]=u,e[7]=h):h=e[7];let f;e[8]!==o?(f=o("Find records whose file reference points at an object the bucket no longer has."),e[8]=o,e[9]=f):f=e[9];let m;e[10]!==f?(m=(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:f}),e[10]=f,e[11]=m):m=e[11];let w;e[12]!==l||e[13]!==h||e[14]!==m?(w=(0,n.jsxs)("div",{className:"flex flex-col gap-1",children:[l,h,m]}),e[12]=l,e[13]=h,e[14]=m,e[15]=w):w=e[15];let a;e[16]!==t||e[17]!==o?(a=o(t?"Checking\u2026":"Check for orphans"),e[16]=t,e[17]=o,e[18]=a):a=e[18];let k;e[19]!==t||e[20]!==r||e[21]!==a?(k=(0,n.jsx)(re,{"data-testid":"fb-orphans-check",disabled:t,onClick:r,size:"sm",type:"button",variant:"outline",children:a}),e[19]=t,e[20]=r,e[21]=a,e[22]=k):k=e[22];let C;e[23]!==w||e[24]!==k?(C=(0,n.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[w,k]}),e[23]=w,e[24]=k,e[25]=C):C=e[25];let x;e[26]!==s?.length||e[27]!==o?(x=s?.length===0&&(0,n.jsx)(he,{description:o("Every record's file reference points at an object that exists in the bucket."),testId:"fb-orphans-empty",title:o("No dangling references.")}),e[26]=s?.length,e[27]=o,e[28]=x):x=e[28];let b;e[29]!==s||e[30]!==o||e[31]!==c?(b=s!==void 0&&s.length>0&&(0,n.jsxs)(n.Fragment,{children:[c&&(0,n.jsx)("p",{className:"text-xs text-warning","data-testid":"fb-orphans-truncated",children:o("Showing the first {count} dangling references \u2014 the scan was truncated.",{count:s.length})}),(0,n.jsx)("ul",{className:"flex flex-col gap-1.5","data-testid":"fb-orphans-list",children:s.map(y=>(0,n.jsx)(_t,{reference:y,t:o},`${y.table}\xB7${y.id}\xB7${y.column}`))})]}),e[29]=s,e[30]=o,e[31]=c,e[32]=b):b=e[32];let v;return e[33]!==C||e[34]!==x||e[35]!==b?(v=(0,n.jsxs)("section",{className:"flex flex-col gap-2 rounded-lg border border-border/60 p-3","data-testid":"fb-orphans",children:[C,x,b]}),e[33]=C,e[34]=x,e[35]=b,e[36]=v):v=e[36],v},"_t"),Et=g(function(d,e){let t=(0,M.c)(18),r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=new Set,t[0]=r):r=t[0];let[s,o]=(0,j.useState)(r),c;t[1]===Symbol.for("react.memo_cache_sentinel")?(c=g(x=>{o(b=>{let v=new Set(b);return v.has(x)?v.delete(x):v.add(x),v})},"c"),t[1]=c):c=t[1];let i=c,l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l=g(()=>{o(new Set)},"o"),t[2]=l):l=t[2];let u=l,h,f,m;if(t[3]!==d||t[4]!==e||t[5]!==s){let x;t[9]!==e?(x=g(b=>e(b),"y"),t[9]=e,t[10]=x):x=t[10],f=d.map(x),h=f.length>0&&f.every(b=>s.has(b)),m=!h&&f.some(b=>s.has(b)),t[3]=d,t[4]=e,t[5]=s,t[6]=h,t[7]=f,t[8]=m}else h=t[6],f=t[7],m=t[8];let w=m,a;t[11]!==f?(a=g(()=>{o(x=>f.every(b=>x.has(b))?new Set:new Set(f))},"a"),t[11]=f,t[12]=a):a=t[12];let k=a,C;return t[13]!==h||t[14]!==s||t[15]!==w||t[16]!==k?(C={allSelected:h,clear:u,selected:s,someSelected:w,toggle:i,toggleAll:k},t[13]=h,t[14]=s,t[15]=w,t[16]=k,t[17]=C):C=t[17],C},"Bt"),It=me(be.storageReferences),Ot=me(be.storageOrphans),Ee=1e4,Mt=1e3,At=3600,Pt=g((d,e)=>{if(!("document"in globalThis))return;let t=globalThis.document.createElement("a");t.href=d,t.download=e,t.rel="noopener",globalThis.document.body.append(t),t.click(),t.remove()},"Wt"),Wt=g(d=>d.key,"qt"),Gt=g(({initialPrefix:d,pageSize:e})=>{let t=Se(),[r,s]=(0,j.useState)(d??""),[o,c]=(0,j.useState)(d??""),[i,l]=(0,j.useState)(wt),[u,h]=(0,j.useState)("list"),[f,m]=(0,j.useState)(128),[w,a]=(0,j.useState)("name"),[k,C]=(0,j.useState)("asc"),[x,b]=(0,j.useState)(void 0),[v,y]=(0,j.useState)(void 0),[z,S]=(0,j.useState)(!1),[N,$]=(0,j.useState)(void 0),[K,F]=(0,j.useState)(void 0),[T,L]=(0,j.useState)(""),[B,U]=(0,j.useState)({}),[I,R]=(0,j.useState)(!1),[_,O]=(0,j.useState)(void 0),[A,G]=(0,j.useState)(!1),[P,H]=(0,j.useState)(!1),[Y,oe]=(0,j.useState)([]),[V,xe]=(0,j.useState)(""),le=(0,j.useRef)(0),Q=(0,j.useRef)(0);(0,j.useEffect)(()=>{let p={cancelled:!1};return W((async()=>{try{let D=await t.listStorageBuckets();if(!p.cancelled){oe(D);let[E]=D;E!==void 0&&xe(q=>q===""?E:q)}}catch{}})()),()=>{p.cancelled=!0}},[t]);let Z=(0,j.useMemo)(()=>({list:g(p=>t.listStorageObjects({...p,bucket:V}),"list"),remove:g(p=>t.deleteStorageObject(p,{bucket:V}),"remove"),signedUrl:g((p,D)=>t.signedStorageUrl(p,{...D,bucket:V}),"signedUrl"),upload:g(p=>t.uploadStorageObject({...p,bucket:V}),"upload")}),[V,t]),J=(0,j.useCallback)(async(p,D,E)=>{le.current+=1;let q=le.current;y(void 0),S(!0);try{let te=await Z.list({cursor:D,limit:e,prefix:p});if(q!==le.current)return;b(we=>E&&we!==void 0?[...we,...te.objects]:te.objects),F(te.cursor)}catch(te){if(q!==le.current)return;E||b(void 0),y(X(te))}finally{q===le.current&&S(!1)}},[e,Z]);(0,j.useEffect)(()=>{W(J(d??"",void 0,!1))},[J,d]);let We=(x?.length??0)<=e;Re(()=>{W(J(r,void 0,!1))},We);let{files:de,folders:Ge}=Ct(x??[],r),He=(0,j.useMemo)(()=>{let p=new Set;for(let D of de)for(let E of Object.keys(D.customMetadata??{}))p.add(E);return[...p].toSorted((D,E)=>D.localeCompare(E))},[de]),ie=St(de,w,k),ue=(0,j.useMemo)(()=>[...new Set(ie.map(p=>p.key))].toSorted((p,D)=>p.localeCompare(D)).join(`
3
3
  `),[ie]);(0,j.useEffect)(()=>{let p=ue===""?[]:ue.split(`
4
4
  `);if(p.length===0){U({});return}let D={current:!0};return W((async()=>{try{let E=await t.query(It,{keys:p},ge(T));D.current&&(U(E.references??{}),R(Object.keys(E.storageColumns??{}).length>0))}catch{D.current&&(U({}),R(!1))}})()),()=>{D.current=!1}},[t,ue,T]);let{allSelected:qe,clear:se,selected:ve,someSelected:Ve,toggle:Ze,toggleAll:Je}=Et(ie,Wt),Ye=g(()=>{s(o),se(),W(J(o,void 0,!1))},"Ie"),Qe=g(()=>{W(J(r,K,!0))},"Me"),ke=g(p=>{s(p),c(p),se(),W(J(p,void 0,!1))},"be"),Xe=g(p=>{ke(`${r}${p}`)},"Ae"),et=g(p=>Z.signedUrl(p,{expiresInSeconds:At}),"Pe"),tt=g(()=>{h("list")},"We"),rt=g(()=>{h("grid")},"qe"),nt=g(p=>{a(p)},"Ge"),ot=g(()=>{C(p=>p==="asc"?"desc":"asc")},"He"),lt=g(p=>{m(p)},"Ze"),st=g(p=>{l(p)},"Ve"),at=g(()=>{y(void 0),S(!0),W((async()=>{try{for(let p of ve)await Z.remove(p);await J(r,void 0,!1),se()}catch(p){y(X(p))}S(!1)})())},"Xe"),it=g(p=>{y(void 0),W((async()=>{try{let D=await Z.signedUrl(p,{expiresInSeconds:i});Ke(D)&&$(p)}catch(D){y(X(D))}})())},"Ye"),ct=g(p=>{y(void 0),W((async()=>{try{let D=await Z.signedUrl(p,{expiresInSeconds:i}),E=p.slice(p.lastIndexOf("/")+1)||p;Pt(D,E)}catch(D){y(X(D))}})())},"Qe");(0,j.useEffect)(()=>{if(N===void 0)return;let p=globalThis.setTimeout(()=>{$(void 0)},2e3);return()=>{globalThis.clearTimeout(p)}},[N]);let dt=g(p=>{y(void 0),S(!0),W((async()=>{try{await Z.remove(p),await J(r,void 0,!1)}catch(D){y(X(D))}S(!1)})())},"Je"),ut=g(p=>{let D=`${r}${p.name}`;y(void 0),S(!0),W((async()=>{try{let E=await p.arrayBuffer();await Z.upload({body:E,contentType:p.type===""?void 0:p.type,key:D}),await J(r,void 0,!1)}catch(E){y(X(E))}S(!1)})())},"et");(0,j.useEffect)(()=>{Q.current+=1,O(void 0),H(!1)},[T]);let ft=g(()=>{Q.current+=1;let p=Q.current;y(void 0),G(!0),W((async()=>{try{let D=[],E;do{let q=await Z.list({cursor:E,limit:Mt});for(let te of q.objects)D.push(te.key);E=D.length>=Ee?void 0:q.cursor}while(E!==void 0);if(D.length>=Ee)p===Q.current&&(O([]),H(!0));else{let q=await t.query(Ot,{liveKeys:D},ge(T));p===Q.current&&(O(q.references??[]),H(q.truncated===!0))}}catch(D){p===Q.current&&(O([]),H(!1),y(X(D)))}p===Q.current&&G(!1)})())},"tt"),ht=g(p=>{le.current+=1,Q.current+=1,xe(p),s(d??""),c(d??""),b(void 0),O(void 0),H(!1),se()},"rt");return{allSelected:qe,bucket:V,buckets:Y,bulkDelete:at,busy:z,checkOrphans:ft,clearSelection:se,copiedKey:N,danglingBusy:A,danglingReferences:_,danglingTruncated:P,draftPrefix:o,enterFolder:Xe,error:v,expiry:i,files:ie,folders:Ge,hasObjects:x!==void 0&&x.length>0,hasStorageColumns:I,listFirst:Ye,loaded:x!==void 0,loadMore:Qe,navigate:ke,nextCursor:K,onCopy:it,onDelete:dt,onDownload:ct,onExpiryChange:st,onFile:ut,onSortKeyChange:nt,onThumbSizeChange:lt,prefix:r,referenceShard:T,references:B,resolveUrl:et,selectBucket:ht,selected:ve,setDraftPrefix:c,setReferenceShard:L,showGrid:rt,showList:tt,someSelected:Ve,sortDirection:k,sortKey:w,tagKeys:He,thumbSize:f,toggleSelect:Ze,toggleSelectAll:Je,toggleSortDirection:ot,view:u}},"Gt"),Ht=100,Ie=g(d=>{let e=(0,M.c)(6),{label:t,onNavigate:r,target:s}=d,o;e[0]!==r||e[1]!==s?(o=g(()=>{r(s)},"n"),e[0]=r,e[1]=s,e[2]=o):o=e[2];let c=o,i;return e[3]!==c||e[4]!==t?(i=(0,n.jsx)("button",{className:"rounded px-1 text-muted-foreground outline-none hover:text-foreground focus-visible:text-foreground",onClick:c,type:"button",children:t}),e[3]=c,e[4]=t,e[5]=i):i=e[5],i},"we"),qt=g(d=>{let e=(0,M.c)(11),{onNavigate:t,prefix:r,t:s}=d,o;if(e[0]!==t||e[1]!==r||e[2]!==s){let c=r.split("/").filter(Vt),i;e[4]!==s?(i=s("Folder path"),e[4]=s,e[5]=i):i=e[5];let l;e[6]!==s?(l=s("root"),e[6]=s,e[7]=l):l=e[7];let u;e[8]!==t||e[9]!==l?(u=(0,n.jsx)(Ie,{label:l,onNavigate:t,target:""}),e[8]=t,e[9]=l,e[10]=u):u=e[10],o=(0,n.jsxs)("nav",{"aria-label":i,className:"flex flex-wrap items-center gap-0.5 text-xs","data-testid":"fb-breadcrumbs",children:[u,c.map((h,f)=>(0,n.jsxs)("span",{className:"flex items-center gap-0.5",children:[(0,n.jsx)("span",{className:"text-muted-foreground/50",children:"/"}),(0,n.jsx)(Ie,{label:h,onNavigate:t,target:`${c.slice(0,f+1).join("/")}/`})]},`${h}-${f.toString()}`))]}),e[0]=t,e[1]=r,e[2]=s,e[3]=o}else o=e[3];return o},"Zt"),ur=g(({initialPrefix:d,pageSize:e=Ht})=>{let t=Ce(),r=Gt({initialPrefix:d,pageSize:e}),s=(0,j.useRef)(null),{onCopy:o,onDelete:c,onDownload:i,onFile:l,toggleSelect:u}=r,h={onCopy:o,onDelete:c,onDownload:i,onToggleSelect:u},f=g(()=>{s.current?.click()},"f"),m=g(a=>{let k=a.target,C=k.files?.[0];k.value="",C&&l(C)},"m"),w=r.loaded&&!r.hasObjects;return(0,n.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-file-browser",children:[(0,n.jsx)(Nt,{bucket:r.bucket,buckets:r.buckets,busy:r.busy,draftPrefix:r.draftPrefix,expiry:r.expiry,fileInputRef:s,onBucketChange:r.selectBucket,onExpiryChange:r.onExpiryChange,onFileChange:m,onList:r.listFirst,onPrefixChange:r.setDraftPrefix,onUploadClick:f,t}),r.loaded&&(0,n.jsx)(qt,{onNavigate:r.navigate,prefix:r.prefix,t}),r.hasObjects&&(0,n.jsx)(jt,{onSortKeyChange:r.onSortKeyChange,onThumbSizeChange:r.onThumbSizeChange,showGrid:r.showGrid,showList:r.showList,sortDirection:r.sortDirection,sortKey:r.sortKey,t,tagKeys:r.tagKeys,thumbSize:r.thumbSize,toggleSortDirection:r.toggleSortDirection,view:r.view}),r.hasStorageColumns&&(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"fb-references-shard",children:[(0,n.jsx)("label",{className:"text-xs text-muted-foreground",htmlFor:"fb-reference-shard-input",children:t("References shard")}),(0,n.jsx)(De,{id:"fb-reference-shard-input",onChange:r.setReferenceShard,testId:"fb-reference-shard-input",value:r.referenceShard}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:t("Which shard's records are checked for references to these files. Empty = root shard.")})]}),r.hasStorageColumns&&(0,n.jsx)(Bt,{busy:r.danglingBusy,onCheck:r.checkOrphans,references:r.danglingReferences,t,truncated:r.danglingTruncated}),r.selected.size>0&&(0,n.jsx)(Ue,{count:r.selected.size,editable:!0,onClear:r.clearSelection,onDelete:r.bulkDelete}),r.error!==void 0&&(0,n.jsx)("p",{className:"text-sm text-destructive","data-testid":"storage-error",role:"alert",children:r.error}),w&&(0,n.jsx)(he,{description:t("Objects you upload to your R2 buckets will appear here."),icon:(0,n.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,n.jsx)("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"}),(0,n.jsx)("path",{d:"M12 11v5m-2.5-2.5h5"})]}),testId:"fb-empty",title:t("No objects.")}),r.hasObjects&&r.view==="list"&&(0,n.jsx)(vt,{allSelected:r.allSelected,busy:r.busy,copiedKey:r.copiedKey,files:r.files,folders:r.folders,handlers:h,onEnterFolder:r.enterFolder,prefix:r.prefix,references:r.references,selected:r.selected,showReferences:r.hasStorageColumns,someSelected:r.someSelected,t,toggleSelectAll:r.toggleSelectAll}),r.hasObjects&&r.view==="grid"&&(0,n.jsx)(Ut,{busy:r.busy,copiedKey:r.copiedKey,files:r.files,folders:r.folders,handlers:h,onEnterFolder:r.enterFolder,prefix:r.prefix,references:r.references,resolveUrl:r.resolveUrl,selected:r.selected,showReferences:r.hasStorageColumns,size:r.thumbSize,t}),r.nextCursor!==void 0&&(0,n.jsx)("div",{children:(0,n.jsx)(re,{"data-testid":"fb-next",disabled:r.busy,onClick:r.loadMore,size:"sm",type:"button",variant:"outline",children:t("Load more")})})]})},"pr");function Vt(d){return d!==""}g(Vt,"Vt");export{ur as FileBrowser};
@@ -1,4 +1,4 @@
1
- import{a as me}from"./chunk-XF2B7P5A.js";import{R as ne}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as ee}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import"./chunk-XBDKZZ67.js";import{a as te,e as se}from"./chunk-UZERI5YC.js";import{d as Z,h as ie,o as de,q as ce}from"./chunk-IUYFXK4X.js";import{a as h,e as Y,f as ge,g as xe,h as ye}from"./chunk-3XIESWL4.js";var re=Y(xe(),1),K=Y(ge(),1);var s=Y(ye(),1);var be=h(e=>{let t=(0,re.c)(23),{destination:r}=e,f=Z(),g;t[0]!==r.snippet?(g=h(()=>{ce(r.snippet)},"g"),t[0]=r.snippet,t[1]=g):g=t[1];let m=g,a;t[2]!==r.title?(a=(0,s.jsx)("h4",{className:"text-sm font-semibold",children:r.title}),t[2]=r.title,t[3]=a):a=t[3];let o;t[4]!==r.description?(o=(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:r.description}),t[4]=r.description,t[5]=o):o=t[5];let d;t[6]!==a||t[7]!==o?(d=(0,s.jsxs)("div",{children:[a,o]}),t[6]=a,t[7]=o,t[8]=d):d=t[8];let H=`drain-copy-${r.id}`,l;t[9]!==f?(l=f("Copy"),t[9]=f,t[10]=l):l=t[10];let n;t[11]!==m||t[12]!==H||t[13]!==l?(n=(0,s.jsx)(ee,{"data-testid":H,onClick:m,size:"sm",variant:"outline",children:l}),t[11]=m,t[12]=H,t[13]=l,t[14]=n):n=t[14];let i;t[15]!==d||t[16]!==n?(i=(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[d,n]}),t[15]=d,t[16]=n,t[17]=i):i=t[17];let c;t[18]!==r.snippet?(c=(0,s.jsx)("pre",{className:"mt-2 overflow-x-auto rounded bg-muted p-2 font-mono text-xs",children:r.snippet}),t[18]=r.snippet,t[19]=c):c=t[19];let x;return t[20]!==i||t[21]!==c?(x=(0,s.jsx)(te,{className:"py-0","data-testid":"drain-card",children:(0,s.jsxs)(se,{className:"p-3",children:[i,c]})}),t[20]=i,t[21]=c,t[22]=x):x=t[22],x},"he"),je=h(()=>{let e=(0,re.c)(88),t=Z(),r;e[0]!==t?(r=t("Stream every request log to R2, a SIEM, or a third-party log service."),e[0]=t,e[1]=r):r=e[1];let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f=["{",' "logpush": true',"}"],e[2]=f):f=e[2];let g=f.join(`
1
+ import{a as me}from"./chunk-XF2B7P5A.js";import{R as ne}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as ee}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import"./chunk-XBDKZZ67.js";import{a as te,e as se}from"./chunk-WQH3LT2P.js";import{d as Z,h as ie,o as de,q as ce}from"./chunk-IUYFXK4X.js";import{a as h,e as Y,f as ge,g as xe,h as ye}from"./chunk-3XIESWL4.js";var re=Y(xe(),1),K=Y(ge(),1);var s=Y(ye(),1);var be=h(e=>{let t=(0,re.c)(23),{destination:r}=e,f=Z(),g;t[0]!==r.snippet?(g=h(()=>{ce(r.snippet)},"g"),t[0]=r.snippet,t[1]=g):g=t[1];let m=g,a;t[2]!==r.title?(a=(0,s.jsx)("h4",{className:"text-sm font-semibold",children:r.title}),t[2]=r.title,t[3]=a):a=t[3];let o;t[4]!==r.description?(o=(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:r.description}),t[4]=r.description,t[5]=o):o=t[5];let d;t[6]!==a||t[7]!==o?(d=(0,s.jsxs)("div",{children:[a,o]}),t[6]=a,t[7]=o,t[8]=d):d=t[8];let H=`drain-copy-${r.id}`,l;t[9]!==f?(l=f("Copy"),t[9]=f,t[10]=l):l=t[10];let n;t[11]!==m||t[12]!==H||t[13]!==l?(n=(0,s.jsx)(ee,{"data-testid":H,onClick:m,size:"sm",variant:"outline",children:l}),t[11]=m,t[12]=H,t[13]=l,t[14]=n):n=t[14];let i;t[15]!==d||t[16]!==n?(i=(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[d,n]}),t[15]=d,t[16]=n,t[17]=i):i=t[17];let c;t[18]!==r.snippet?(c=(0,s.jsx)("pre",{className:"mt-2 overflow-x-auto rounded bg-muted p-2 font-mono text-xs",children:r.snippet}),t[18]=r.snippet,t[19]=c):c=t[19];let x;return t[20]!==i||t[21]!==c?(x=(0,s.jsx)(te,{className:"py-0","data-testid":"drain-card",children:(0,s.jsxs)(se,{className:"p-3",children:[i,c]})}),t[20]=i,t[21]=c,t[22]=x):x=t[22],x},"he"),je=h(()=>{let e=(0,re.c)(88),t=Z(),r;e[0]!==t?(r=t("Stream every request log to R2, a SIEM, or a third-party log service."),e[0]=t,e[1]=r):r=e[1];let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f=["{",' "logpush": true',"}"],e[2]=f):f=e[2];let g=f.join(`
2
2
  `),m;e[3]!==t?(m=t("Logpush"),e[3]=t,e[4]=m):m=e[4];let a;e[5]!==r||e[6]!==m?(a={description:r,id:"logpush",snippet:g,title:m},e[5]=r,e[6]=m,e[7]=a):a=e[7];let o;e[8]!==t?(o=t("Send logs programmatically to a Worker for custom capture and forwarding."),e[8]=t,e[9]=o):o=e[9];let d;e[10]===Symbol.for("react.memo_cache_sentinel")?(d=["{",' "tail_consumers": [{ "service": "my-log-forwarder" }]',"}"],e[10]=d):d=e[10];let H=d.join(`
3
3
  `),l;e[11]!==t?(l=t("Tail Workers"),e[11]=t,e[12]=l):l=e[12];let n;e[13]!==o||e[14]!==l?(n={description:o,id:"tail-worker",snippet:H,title:l},e[13]=o,e[14]=l,e[15]=n):n=e[15];let i;e[16]!==t?(i=t("Retain and query recent request logs directly in Cloudflare's dashboard."),e[16]=t,e[17]=i):i=e[17];let c;e[18]===Symbol.for("react.memo_cache_sentinel")?(c=["{",' "observability": { "enabled": true }',"}"],e[18]=c):c=e[18];let x=c.join(`
4
- `),y;e[19]!==t?(y=t("Workers Logs"),e[19]=t,e[20]=y):y=e[20];let b;e[21]!==i||e[22]!==y?(b={description:i,id:"workers-logs",snippet:x,title:y},e[21]=i,e[22]=y,e[23]=b):b=e[23];let J;e[24]!==b||e[25]!==a||e[26]!==n?(J=[a,n,b],e[24]=b,e[25]=a,e[26]=n,e[27]=J):J=e[27];let Q=J,[p,pe]=(0,K.useState)(""),[k,ae]=(0,K.useState)(!1),[u,$]=(0,K.useState)(null),A;if(e[28]!==t||e[29]!==p){let V=h(async()=>{let oe=p.trim();if(oe==="")return;let le="fetch"in globalThis?globalThis.fetch:void 0;if(le===void 0){$({kind:"error",message:t("fetch is unavailable in this environment.")});return}let fe={durationMs:12,function:"messages:list",outcome:"ok",shard:"root",source:"lunora",tablesRead:["messages"],tablesWritten:[],ts:new Date().toISOString(),type:"request"};ae(!0),$(null);let he=performance.now();try{let X=await le(oe,{body:JSON.stringify(fe),headers:{"Content-Type":"application/json"},method:"POST"});$({kind:"success",latencyMs:Math.round(performance.now()-he),status:X.status})}catch(X){$({kind:"error",message:ie(X)})}ae(!1)},"G");A=h(()=>{de(V())},"z"),e[28]=t,e[29]=p,e[30]=A}else A=e[30];let U=A,B;e[31]===Symbol.for("react.memo_cache_sentinel")?(B=h(V=>{pe(V.target.value)},"J"),e[31]=B):B=e[31];let ue=B,v;e[32]!==t?(v=t("Open in Cloudflare"),e[32]=t,e[33]=v):v=e[33];let w;e[34]!==v?(w=(0,s.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,s.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"drain-cf-link",href:me,rel:"noreferrer",target:"_blank",children:v})}),e[34]=v,e[35]=w):w=e[35];let N;e[36]!==t?(N=t("Lunora does not ship logs itself \u2014 forwarding is handled by Cloudflare. Configure a destination below, then test your collector."),e[36]=t,e[37]=N):N=e[37];let S;e[38]!==N?(S=(0,s.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"drain-readonly-note",children:N}),e[38]=N,e[39]=S):S=e[39];let _;e[40]!==t?(_=t("Cloudflare destinations"),e[40]=t,e[41]=_):_=e[41];let C;e[42]!==_?(C=(0,s.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:_}),e[42]=_,e[43]=C):C=e[43];let j;e[44]!==Q?(j=Q.map(ke),e[44]=Q,e[45]=j):j=e[45];let T;e[46]!==C||e[47]!==j?(T=(0,s.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"drain-destinations",children:[C,j]}),e[46]=C,e[47]=j,e[48]=T):T=e[48];let q;e[49]!==t?(q=t("Webhook test"),e[49]=t,e[50]=q):q=e[50];let L;e[51]!==q?(L=(0,s.jsx)("h3",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:q}),e[51]=q,e[52]=L):L=e[52];let M;e[53]!==t?(M=t("POST a sample Lunora request-log envelope to your collector to confirm it is reachable."),e[53]=t,e[54]=M):M=e[54];let O;e[55]!==M?(O=(0,s.jsx)("p",{className:"mb-2 text-sm text-muted-foreground",children:M}),e[55]=M,e[56]=O):O=e[56];let W;e[57]!==t?(W=t("https://example.com/logs"),e[57]=t,e[58]=W):W=e[58];let D;e[59]!==W||e[60]!==p?(D=(0,s.jsx)(ne,{className:"min-w-[20rem] flex-1","data-testid":"drain-webhook-url",onChange:ue,placeholder:W,type:"url",value:p}),e[59]=W,e[60]=p,e[61]=D):D=e[61];let P;e[62]!==k||e[63]!==p?(P=k||p.trim()==="",e[62]=k,e[63]=p,e[64]=P):P=e[64];let R;e[65]!==k||e[66]!==t?(R=t(k?"Sending\u2026":"Send test event"),e[65]=k,e[66]=t,e[67]=R):R=e[67];let F;e[68]!==U||e[69]!==P||e[70]!==R?(F=(0,s.jsx)(ee,{"data-testid":"drain-webhook-test",disabled:P,onClick:U,children:R}),e[68]=U,e[69]=P,e[70]=R,e[71]=F):F=e[71];let I;e[72]!==D||e[73]!==F?(I=(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[D,F]}),e[72]=D,e[73]=F,e[74]=I):I=e[74];let z;e[75]!==u||e[76]!==t?(z=u!==null&&(0,s.jsx)("p",{className:u.kind==="success"?"mt-2 text-sm text-muted-foreground":"mt-2 text-sm text-destructive","data-testid":"drain-webhook-result",role:u.kind==="error"?"alert":void 0,children:u.kind==="success"?t("Delivered \u2014 status {status} in {latency}ms",{latency:u.latencyMs,status:u.status}):t("Failed: {message}",{message:u.message})}),e[75]=u,e[76]=t,e[77]=z):z=e[77];let E;e[78]!==L||e[79]!==O||e[80]!==I||e[81]!==z?(E=(0,s.jsx)(te,{className:"py-0",children:(0,s.jsx)(se,{className:"p-3",children:(0,s.jsxs)("section",{"data-testid":"drain-webhook",children:[L,O,I,z]})})}),e[78]=L,e[79]=O,e[80]=I,e[81]=z,e[82]=E):E=e[82];let G;return e[83]!==w||e[84]!==S||e[85]!==T||e[86]!==E?(G=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"log-drains",children:[w,S,T,E]}),e[83]=w,e[84]=S,e[85]=T,e[86]=E,e[87]=G):G=e[87],G},"_e");function ke(e){return(0,s.jsx)(be,{destination:e},e.id)}h(ke,"ge");export{je as LogDrainsPanel};
4
+ `),y;e[19]!==t?(y=t("Workers Logs"),e[19]=t,e[20]=y):y=e[20];let b;e[21]!==i||e[22]!==y?(b={description:i,id:"workers-logs",snippet:x,title:y},e[21]=i,e[22]=y,e[23]=b):b=e[23];let J;e[24]!==b||e[25]!==a||e[26]!==n?(J=[a,n,b],e[24]=b,e[25]=a,e[26]=n,e[27]=J):J=e[27];let Q=J,[p,pe]=(0,K.useState)(""),[k,ae]=(0,K.useState)(!1),[u,$]=(0,K.useState)(null),A;if(e[28]!==t||e[29]!==p){let V=h(async()=>{let oe=p.trim();if(oe==="")return;let le="fetch"in globalThis?globalThis.fetch:void 0;if(le===void 0){$({kind:"error",message:t("fetch is unavailable in this environment.")});return}let fe={durationMs:12,function:"messages:list",outcome:"ok",shard:"root",source:"lunora",tablesRead:["messages"],tablesWritten:[],ts:new Date().toISOString(),type:"request"};ae(!0),$(null);let he=performance.now();try{let X=await le(oe,{body:JSON.stringify(fe),headers:{"Content-Type":"application/json"},method:"POST"});$({kind:"success",latencyMs:Math.round(performance.now()-he),status:X.status})}catch(X){$({kind:"error",message:ie(X)})}ae(!1)},"G");A=h(()=>{de(V())},"z"),e[28]=t,e[29]=p,e[30]=A}else A=e[30];let U=A,B;e[31]===Symbol.for("react.memo_cache_sentinel")?(B=h(V=>{pe(V.target.value)},"J"),e[31]=B):B=e[31];let ue=B,v;e[32]!==t?(v=t("Open in Cloudflare"),e[32]=t,e[33]=v):v=e[33];let w;e[34]!==v?(w=(0,s.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,s.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"drain-cf-link",href:me,rel:"noreferrer",target:"_blank",children:v})}),e[34]=v,e[35]=w):w=e[35];let N;e[36]!==t?(N=t("Lunora does not ship logs itself \u2014 forwarding is handled by Cloudflare. Configure a destination below, then test your collector."),e[36]=t,e[37]=N):N=e[37];let S;e[38]!==N?(S=(0,s.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"drain-readonly-note",children:N}),e[38]=N,e[39]=S):S=e[39];let _;e[40]!==t?(_=t("Cloudflare destinations"),e[40]=t,e[41]=_):_=e[41];let C;e[42]!==_?(C=(0,s.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:_}),e[42]=_,e[43]=C):C=e[43];let j;e[44]!==Q?(j=Q.map(ke),e[44]=Q,e[45]=j):j=e[45];let T;e[46]!==C||e[47]!==j?(T=(0,s.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"drain-destinations",children:[C,j]}),e[46]=C,e[47]=j,e[48]=T):T=e[48];let q;e[49]!==t?(q=t("Webhook test"),e[49]=t,e[50]=q):q=e[50];let M;e[51]!==q?(M=(0,s.jsx)("h3",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:q}),e[51]=q,e[52]=M):M=e[52];let O;e[53]!==t?(O=t("POST a sample Lunora request-log envelope to your collector to confirm it is reachable."),e[53]=t,e[54]=O):O=e[54];let W;e[55]!==O?(W=(0,s.jsx)("p",{className:"mb-2 text-sm text-muted-foreground",children:O}),e[55]=O,e[56]=W):W=e[56];let L;e[57]!==t?(L=t("https://example.com/logs"),e[57]=t,e[58]=L):L=e[58];let R;e[59]!==L||e[60]!==p?(R=(0,s.jsx)(ne,{className:"min-w-[20rem] flex-1","data-testid":"drain-webhook-url",onChange:ue,placeholder:L,type:"url",value:p}),e[59]=L,e[60]=p,e[61]=R):R=e[61];let D;e[62]!==k||e[63]!==p?(D=k||p.trim()==="",e[62]=k,e[63]=p,e[64]=D):D=e[64];let F;e[65]!==k||e[66]!==t?(F=t(k?"Sending\u2026":"Send test event"),e[65]=k,e[66]=t,e[67]=F):F=e[67];let I;e[68]!==U||e[69]!==D||e[70]!==F?(I=(0,s.jsx)(ee,{"data-testid":"drain-webhook-test",disabled:D,onClick:U,children:F}),e[68]=U,e[69]=D,e[70]=F,e[71]=I):I=e[71];let P;e[72]!==R||e[73]!==I?(P=(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[R,I]}),e[72]=R,e[73]=I,e[74]=P):P=e[74];let z;e[75]!==u||e[76]!==t?(z=u!==null&&(0,s.jsx)("p",{className:u.kind==="success"?"mt-2 text-sm text-muted-foreground":"mt-2 text-sm text-destructive","data-testid":"drain-webhook-result",role:u.kind==="error"?"alert":void 0,children:u.kind==="success"?t("Delivered \u2014 status {status} in {latency}ms",{latency:u.latencyMs,status:u.status}):t("Failed: {message}",{message:u.message})}),e[75]=u,e[76]=t,e[77]=z):z=e[77];let E;e[78]!==M||e[79]!==W||e[80]!==P||e[81]!==z?(E=(0,s.jsx)(te,{className:"py-0",children:(0,s.jsx)(se,{className:"p-3",children:(0,s.jsxs)("section",{"data-testid":"drain-webhook",children:[M,W,P,z]})})}),e[78]=M,e[79]=W,e[80]=P,e[81]=z,e[82]=E):E=e[82];let G;return e[83]!==w||e[84]!==S||e[85]!==T||e[86]!==E?(G=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"log-drains",children:[w,S,T,E]}),e[83]=w,e[84]=S,e[85]=T,e[86]=E,e[87]=G):G=e[87],G},"_e");function ke(e){return(0,s.jsx)(be,{destination:e},e.id)}h(ke,"ge");export{je as default};
@@ -1 +1 @@
1
- import{a as D}from"./chunk-54MMVNPT.js";import{b as x}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{b as B}from"./chunk-ZNAGZU6H.js";import{f as O}from"./chunk-5KCULF7S.js";import"./chunk-XBDKZZ67.js";import{a as j}from"./chunk-XQCVZAGU.js";import{a as W,b as q,c as E,d as S,e as r,f as s}from"./chunk-MIQTKZAR.js";import{a as A,e as L}from"./chunk-UZERI5YC.js";import{d as z}from"./chunk-IUYFXK4X.js";import"./chunk-XNGYYOLS.js";import{a as T,e as M,g as $,h as I}from"./chunk-3XIESWL4.js";var F=M($(),1);var n=M(I(),1);var J=2e3,Q=new Set(["open"]),re=T(G=>{let e=(0,F.c)(41),{read:y}=G,t=z(),K=O(),v;e[0]!==K||e[1]!==y?(v=T(()=>Promise.resolve(y?y():K.debug()),"S"),e[0]=K,e[1]=y,e[2]=v):v=e[2];let H=v,P=y?"injected":"live",b;e[3]!==P?(b=["lunora-studio","sync-client-debug",P],e[3]=P,e[4]=b):b=e[4];let{data:c,refetch:Y}=B(b,H);if(D(Y,!0,J),!c){let i;e[5]!==t?(i=t("Reading the sync client's state\u2026"),e[5]=t,e[6]=i):i=e[6];let g;e[7]!==t?(g=t("Sync client"),e[7]=t,e[8]=g):g=e[8];let _;return e[9]!==i||e[10]!==g?(_=(0,n.jsx)(A,{children:(0,n.jsx)(L,{children:(0,n.jsx)(j,{description:i,title:g})})}),e[9]=i,e[10]=g,e[11]=_):_=e[11],_}let{pendingWrites:k,shards:N,subscriptions:w}=c,l;e[12]!==t?(l=t("This Studio session's sync client"),e[12]=t,e[13]=l):l=e[13];let a;e[14]!==l?(a=(0,n.jsx)("span",{className:"text-sm font-medium",children:l}),e[14]=l,e[15]=a):a=e[15];let R=c.connectionStatus==="connected"?"default":"secondary",o;e[16]!==c.connectionStatus||e[17]!==R?(o=(0,n.jsx)(x,{variant:R,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=R,e[18]=o):o=e[18];let d;e[19]!==k||e[20]!==t?(d=k>0?(0,n.jsx)(x,{variant:"secondary",children:t("{count} pending writes",{count:k})}):null,e[19]=k,e[20]=t,e[21]=d):d=e[21];let h;e[22]!==a||e[23]!==o||e[24]!==d?(h=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[a,o,d]}),e[22]=a,e[23]=o,e[24]=d,e[25]=h):h=e[25];let u;e[26]!==t?(u=t("Reads client.debug() for the client running in this page \u2014 not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=t,e[27]=u):u=e[27];let m;e[28]!==u?(m=(0,n.jsx)("p",{className:"text-muted-foreground text-xs",children:u}),e[28]=u,e[29]=m):m=e[29];let p;e[30]!==N||e[31]!==t?(p=N.length===0?(0,n.jsx)(j,{description:t("No shard connection has been opened yet."),title:t("No shards")}):(0,n.jsxs)(W,{children:[(0,n.jsx)(q,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(r,{children:t("Shard")}),(0,n.jsx)(r,{children:t("Socket")}),(0,n.jsx)(r,{children:t("Confirmed watermark")})]})}),(0,n.jsx)(E,{children:N.map(i=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{children:i.shardKey??t("(default)")}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:Q.has(i.wsState)?"default":"secondary",children:i.wsState})}),(0,n.jsx)(s,{children:i.confirmedMutationWatermark})]},i.shardKey??"__default__"))})]}),e[30]=N,e[31]=t,e[32]=p):p=e[32];let f;e[33]!==w||e[34]!==t?(f=w.length===0?(0,n.jsx)(j,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):(0,n.jsxs)(W,{children:[(0,n.jsx)(q,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(r,{children:t("Subscription")}),(0,n.jsx)(r,{children:t("Kind")}),(0,n.jsx)(r,{children:t("Acked")}),(0,n.jsx)(r,{children:t("Cursor")}),(0,n.jsx)(r,{children:t("Pending overlays")})]})}),(0,n.jsx)(E,{children:w.map(i=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{className:"font-mono text-xs",children:i.functionPath}),(0,n.jsx)(s,{children:i.kind}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:i.acked?"default":"secondary",children:i.acked?t("yes"):t("no")})}),(0,n.jsx)(s,{children:i.serverCursor??"\u2014"}),(0,n.jsx)(s,{children:i.pendingOptimisticLayers})]},i.id))})]}),e[33]=w,e[34]=t,e[35]=f):f=e[35];let C;return e[36]!==m||e[37]!==p||e[38]!==f||e[39]!==h?(C=(0,n.jsx)(A,{children:(0,n.jsxs)(L,{className:"flex flex-col gap-4",children:[h,m,p,f]})}),e[36]=m,e[37]=p,e[38]=f,e[39]=h,e[40]=C):C=e[40],C},"re");export{re as default};
1
+ import{a as D}from"./chunk-54MMVNPT.js";import{b as x}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{b as B}from"./chunk-LZGOETI3.js";import{f as O}from"./chunk-ETU7KIO4.js";import"./chunk-XBDKZZ67.js";import{a as j}from"./chunk-XQCVZAGU.js";import{a as W,b as q,c as E,d as S,e as r,f as s}from"./chunk-WJQLNYGX.js";import{a as A,e as L}from"./chunk-WQH3LT2P.js";import{d as z}from"./chunk-IUYFXK4X.js";import"./chunk-YEGFNH56.js";import{a as T,e as M,g as $,h as I}from"./chunk-3XIESWL4.js";var F=M($(),1);var n=M(I(),1);var J=2e3,Q=new Set(["open"]),re=T(G=>{let e=(0,F.c)(41),{read:y}=G,t=z(),K=O(),v;e[0]!==K||e[1]!==y?(v=T(()=>Promise.resolve(y?y():K.debug()),"S"),e[0]=K,e[1]=y,e[2]=v):v=e[2];let H=v,P=y?"injected":"live",b;e[3]!==P?(b=["lunora-studio","sync-client-debug",P],e[3]=P,e[4]=b):b=e[4];let{data:c,refetch:Y}=B(b,H);if(D(Y,!0,J),!c){let i;e[5]!==t?(i=t("Reading the sync client's state\u2026"),e[5]=t,e[6]=i):i=e[6];let g;e[7]!==t?(g=t("Sync client"),e[7]=t,e[8]=g):g=e[8];let _;return e[9]!==i||e[10]!==g?(_=(0,n.jsx)(A,{children:(0,n.jsx)(L,{children:(0,n.jsx)(j,{description:i,title:g})})}),e[9]=i,e[10]=g,e[11]=_):_=e[11],_}let{pendingWrites:k,shards:N,subscriptions:w}=c,l;e[12]!==t?(l=t("This Studio session's sync client"),e[12]=t,e[13]=l):l=e[13];let a;e[14]!==l?(a=(0,n.jsx)("span",{className:"text-sm font-medium",children:l}),e[14]=l,e[15]=a):a=e[15];let R=c.connectionStatus==="connected"?"default":"secondary",o;e[16]!==c.connectionStatus||e[17]!==R?(o=(0,n.jsx)(x,{variant:R,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=R,e[18]=o):o=e[18];let d;e[19]!==k||e[20]!==t?(d=k>0?(0,n.jsx)(x,{variant:"secondary",children:t("{count} pending writes",{count:k})}):null,e[19]=k,e[20]=t,e[21]=d):d=e[21];let h;e[22]!==a||e[23]!==o||e[24]!==d?(h=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[a,o,d]}),e[22]=a,e[23]=o,e[24]=d,e[25]=h):h=e[25];let u;e[26]!==t?(u=t("Reads client.debug() for the client running in this page \u2014 not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=t,e[27]=u):u=e[27];let m;e[28]!==u?(m=(0,n.jsx)("p",{className:"text-muted-foreground text-xs",children:u}),e[28]=u,e[29]=m):m=e[29];let p;e[30]!==N||e[31]!==t?(p=N.length===0?(0,n.jsx)(j,{description:t("No shard connection has been opened yet."),title:t("No shards")}):(0,n.jsxs)(W,{children:[(0,n.jsx)(q,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(r,{children:t("Shard")}),(0,n.jsx)(r,{children:t("Socket")}),(0,n.jsx)(r,{children:t("Confirmed watermark")})]})}),(0,n.jsx)(E,{children:N.map(i=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{children:i.shardKey??t("(default)")}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:Q.has(i.wsState)?"default":"secondary",children:i.wsState})}),(0,n.jsx)(s,{children:i.confirmedMutationWatermark})]},i.shardKey??"__default__"))})]}),e[30]=N,e[31]=t,e[32]=p):p=e[32];let f;e[33]!==w||e[34]!==t?(f=w.length===0?(0,n.jsx)(j,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):(0,n.jsxs)(W,{children:[(0,n.jsx)(q,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(r,{children:t("Subscription")}),(0,n.jsx)(r,{children:t("Kind")}),(0,n.jsx)(r,{children:t("Acked")}),(0,n.jsx)(r,{children:t("Cursor")}),(0,n.jsx)(r,{children:t("Pending overlays")})]})}),(0,n.jsx)(E,{children:w.map(i=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{className:"font-mono text-xs",children:i.functionPath}),(0,n.jsx)(s,{children:i.kind}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:i.acked?"default":"secondary",children:i.acked?t("yes"):t("no")})}),(0,n.jsx)(s,{children:i.serverCursor??"\u2014"}),(0,n.jsx)(s,{children:i.pendingOptimisticLayers})]},i.id))})]}),e[33]=w,e[34]=t,e[35]=f):f=e[35];let C;return e[36]!==m||e[37]!==p||e[38]!==f||e[39]!==h?(C=(0,n.jsx)(A,{children:(0,n.jsxs)(L,{className:"flex flex-col gap-4",children:[h,m,p,f]})}),e[36]=m,e[37]=p,e[38]=f,e[39]=h,e[40]=C):C=e[40],C},"re");export{re as default};
@@ -1 +1 @@
1
- import{a as q}from"./chunk-54MMVNPT.js";import{a as F}from"./chunk-3CWGJYBB.js";import{a as D}from"./chunk-RMN2JN4S.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as y}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as L}from"./chunk-465RIA2L.js";import"./chunk-XXQUMVWH.js";import"./chunk-O3UMJLO3.js";import"./chunk-QLQADHFE.js";import{a as _}from"./chunk-VDW32UET.js";import{c as T}from"./chunk-ZNAGZU6H.js";import"./chunk-5KCULF7S.js";import"./chunk-XBDKZZ67.js";import{a as E}from"./chunk-XQCVZAGU.js";import{a as O,b as P,c as W,d as w,e as h,f as p}from"./chunk-MIQTKZAR.js";import{a as $,e as j}from"./chunk-UZERI5YC.js";import{d as M}from"./chunk-IUYFXK4X.js";import"./chunk-XNGYYOLS.js";import{a as S,e as A,g as G,h as U}from"./chunk-3XIESWL4.js";var J=A(G(),1);var t=A(U(),1);var B=80,Z=S(a=>{if(a===void 0)return"";let e=JSON.stringify(a);return e.length>B?`${e.slice(0,B)}\u2026`:e},"B"),z=S(a=>{let e=[];for(let r of a){let n=r.id.toString();if(r.subscriptions.length===0){e.push({admin:r.admin,connectionId:r.id,key:`c${n}`,subscription:null});continue}r.subscriptions.forEach((l,i)=>{e.push({admin:r.admin,connectionId:r.id,key:`c${n}-s${i.toString()}`,subscription:l})})}return e},"G"),C=(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),oe=S(a=>{let e=(0,J.c)(22),{initialShardKey:r}=a,n=M(),{queryShardKey:l,setShardKey:i,shardKey:u}=F(r),f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={},e[0]=f):f=e[0];let b;e[1]!==l?(b={keepPreviousData:!0,shardKey:l},e[1]=l,e[2]=b):b=e[2];let{data:s,error:o,errorSource:m,refetch:R}=T(_.listSubscriptions,f,b);q(R,!0);let x;if(e[3]!==o||e[4]!==m||e[5]!==s||e[6]!==i||e[7]!==u||e[8]!==n){let k=s===void 0?[]:z(s.connections),c;e[10]!==i||e[11]!==u?(c=(0,t.jsx)(D,{onChange:i,testId:"subs-shard-input",value:u}),e[10]=i,e[11]=u,e[12]=c):c=e[12];let d;e[13]!==s||e[14]!==n?(d=s!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[(0,t.jsx)(y,{variant:"secondary",children:n("{count} connections",{count:s.totalConnections})}),(0,t.jsx)(y,{variant:"secondary",children:n("{count} subscriptions",{count:s.totalSubscriptions})})]}),e[13]=s,e[14]=n,e[15]=d):d=e[15];let g;e[16]!==c||e[17]!==d?(g=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,d]}),e[16]=c,e[17]=d,e[18]=g):g=e[18];let v;e[19]!==o||e[20]!==m?(v=o!==null&&(0,t.jsx)(L,{error:m,testId:"subs-error"}),e[19]=o,e[20]=m,e[21]=v):v=e[21],x=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[g,v,o===null&&s!==void 0&&k.length===0&&(0,t.jsx)(E,{description:n("Active WebSocket subscriptions on this shard."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),o===null&&k.length>0&&(0,t.jsx)($,{className:"overflow-hidden py-0",children:(0,t.jsx)(j,{className:"px-0",children:(0,t.jsxs)(O,{"data-testid":"subs-table",children:[(0,t.jsx)(P,{children:(0,t.jsxs)(w,{children:[(0,t.jsx)(h,{children:n("Connection")}),(0,t.jsx)(h,{children:n("Function path")}),(0,t.jsx)(h,{children:n("Table")}),(0,t.jsx)(h,{children:n("Arguments")})]})}),(0,t.jsx)(W,{children:k.map(N=>{let{subscription:I}=N,K=Z(I?.args);return(0,t.jsxs)(w,{"data-testid":"subs-row",children:[(0,t.jsx)(p,{className:"font-medium tabular-nums",children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:["#",N.connectionId,N.admin&&(0,t.jsx)(y,{variant:"outline",children:n("admin")})]})}),(0,t.jsx)(p,{className:"font-mono text-xs",children:I?.functionPath??C}),(0,t.jsx)(p,{children:I?.table??C}),(0,t.jsx)(p,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:K||void 0,children:K||C})]},N.key)})})]})})})]}),e[3]=o,e[4]=m,e[5]=s,e[6]=i,e[7]=u,e[8]=n,e[9]=x}else x=e[9];return x},"oe");export{oe as default};
1
+ import{a as W}from"./chunk-54MMVNPT.js";import{a as F}from"./chunk-3CWGJYBB.js";import{a as E}from"./chunk-RMN2JN4S.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as y}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as L}from"./chunk-3WISGFZ7.js";import"./chunk-XXQUMVWH.js";import"./chunk-DGO2XJOT.js";import"./chunk-QLQADHFE.js";import{a as D}from"./chunk-VDW32UET.js";import{c as _}from"./chunk-LZGOETI3.js";import"./chunk-ETU7KIO4.js";import"./chunk-XBDKZZ67.js";import{a as T}from"./chunk-XQCVZAGU.js";import{a as O,b as P,c as U,d as w,e as h,f as p}from"./chunk-WJQLNYGX.js";import{a as $,e as j}from"./chunk-WQH3LT2P.js";import{d as M}from"./chunk-IUYFXK4X.js";import"./chunk-YEGFNH56.js";import{a as S,e as A,g as R,h as Z}from"./chunk-3XIESWL4.js";var B=A(R(),1);var t=A(Z(),1);var q=80,z=S(a=>{if(a===void 0)return"";let e=JSON.stringify(a);return e.length>q?`${e.slice(0,q)}\u2026`:e},"W"),G=S(a=>{let e=[];for(let r of a){let n=r.id.toString();if(r.subscriptions.length===0){e.push({admin:r.admin,connectionId:r.id,key:`c${n}`,subscription:null});continue}r.subscriptions.forEach((l,i)=>{e.push({admin:r.admin,connectionId:r.id,key:`c${n}-s${i.toString()}`,subscription:l})})}return e},"B"),C=(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),oe=S(a=>{let e=(0,B.c)(22),{initialShardKey:r}=a,n=M(),{queryShardKey:l,setShardKey:i,shardKey:m}=F(r),f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={},e[0]=f):f=e[0];let b;e[1]!==l?(b={keepPreviousData:!0,shardKey:l},e[1]=l,e[2]=b):b=e[2];let{data:s,error:o,errorSource:u,refetch:J}=_(D.listSubscriptions,f,b);W(J,!0);let x;if(e[3]!==o||e[4]!==u||e[5]!==s||e[6]!==i||e[7]!==m||e[8]!==n){let k=s===void 0?[]:G(s.connections),c;e[10]!==i||e[11]!==m?(c=(0,t.jsx)(E,{onChange:i,testId:"subs-shard-input",value:m}),e[10]=i,e[11]=m,e[12]=c):c=e[12];let d;e[13]!==s||e[14]!==n?(d=s!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[(0,t.jsx)(y,{variant:"secondary",children:n("{count} connections",{count:s.totalConnections})}),(0,t.jsx)(y,{variant:"secondary",children:n("{count} subscriptions",{count:s.totalSubscriptions})})]}),e[13]=s,e[14]=n,e[15]=d):d=e[15];let g;e[16]!==c||e[17]!==d?(g=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,d]}),e[16]=c,e[17]=d,e[18]=g):g=e[18];let v;e[19]!==o||e[20]!==u?(v=o!==null&&(0,t.jsx)(L,{error:u,testId:"subs-error"}),e[19]=o,e[20]=u,e[21]=v):v=e[21],x=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[g,v,o===null&&s!==void 0&&k.length===0&&(0,t.jsx)(T,{description:n("Active WebSocket subscriptions on this shard."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),o===null&&k.length>0&&(0,t.jsx)($,{className:"overflow-hidden py-0",children:(0,t.jsx)(j,{className:"px-0",children:(0,t.jsxs)(O,{"data-testid":"subs-table",children:[(0,t.jsx)(P,{children:(0,t.jsxs)(w,{children:[(0,t.jsx)(h,{children:n("Connection")}),(0,t.jsx)(h,{children:n("Function path")}),(0,t.jsx)(h,{children:n("Table")}),(0,t.jsx)(h,{children:n("Arguments")})]})}),(0,t.jsx)(U,{children:k.map(N=>{let{subscription:I}=N,K=z(I?.args);return(0,t.jsxs)(w,{"data-testid":"subs-row",children:[(0,t.jsx)(p,{className:"font-medium tabular-nums",children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:["#",N.connectionId,N.admin&&(0,t.jsx)(y,{variant:"outline",children:n("admin")})]})}),(0,t.jsx)(p,{className:"font-mono text-xs",children:I?.functionPath??C}),(0,t.jsx)(p,{children:I?.table??C}),(0,t.jsx)(p,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:K||void 0,children:K||C})]},N.key)})})]})})})]}),e[3]=o,e[4]=u,e[5]=s,e[6]=i,e[7]=m,e[8]=n,e[9]=x}else x=e[9];return x},"oe");export{oe as default};
@@ -1,6 +1,6 @@
1
- import{a as Ze}from"./chunk-IBVBIKUI.js";import{a as Je,b as Ve}from"./chunk-DYMO6MDG.js";import{a as Xe}from"./chunk-3FIN5PH4.js";import"./chunk-7H7LZRLP.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import"./chunk-ESVP44Y3.js";import"./chunk-I6A5C46N.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import{a as Ge}from"./chunk-FURI47Z2.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import"./chunk-S3DWUXGY.js";import"./chunk-4UOFSGUS.js";import"./chunk-ILNELDFC.js";import"./chunk-AREBQI6D.js";import{a as Qe}from"./chunk-RMN2JN4S.js";import{b as Pe}from"./chunk-GRL5MG3Z.js";import{d as Ce,e as Oe,f as Me}from"./chunk-7T7UOTYK.js";import{R as Fe}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as We}from"./chunk-XXQUMVWH.js";import{a as we}from"./chunk-VDW32UET.js";import"./chunk-ZNAGZU6H.js";import{f as ke}from"./chunk-5KCULF7S.js";import"./chunk-XBDKZZ67.js";import{a as He,b as je,c as Ke,d as De,e as Ye,f as Ue}from"./chunk-MIQTKZAR.js";import{d as oe,f as ve,g as ye,h as _e,o as ie}from"./chunk-IUYFXK4X.js";import"./chunk-XNGYYOLS.js";import{a as i,e as Ee,f as dt,g as ut,h as mt,j as ue}from"./chunk-3XIESWL4.js";var K=Ee(ut(),1);var P=Ee(dt(),1);var c=Ee(mt(),1);var ht=["ORDER BY","GROUP BY","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN","EXPLAIN QUERY PLAN","SELECT","DISTINCT","FROM","WHERE","HAVING","LIMIT","OFFSET","JOIN","ON","AND","OR","AS","ASC","DESC","WITH","UNION","EXPLAIN"],ft=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],Ie=String.fromCodePoint(0),pt=new RegExp(`${Ie}${String.raw`(\d+)`}${Ie}`,"gu"),bt=ht.map(l=>({pattern:new RegExp(String.raw`\b${l.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:l})),gt=ft.map(l=>({pattern:new RegExp(String.raw`\s+${l.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
1
+ import{a as Ze}from"./chunk-57BUSXRD.js";import{a as Je,b as Ve}from"./chunk-TAWXVVAZ.js";import{a as Xe}from"./chunk-6V27P65N.js";import"./chunk-4KIQ5RLS.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import"./chunk-ESVP44Y3.js";import"./chunk-I6A5C46N.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import{a as Ge}from"./chunk-FURI47Z2.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import"./chunk-U7ILDM43.js";import"./chunk-4UOFSGUS.js";import"./chunk-CZZWYUTR.js";import"./chunk-AREBQI6D.js";import{a as Qe}from"./chunk-RMN2JN4S.js";import{b as Pe}from"./chunk-GRL5MG3Z.js";import{d as Ce,e as Oe,f as Me}from"./chunk-7T7UOTYK.js";import{R as Fe}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as We}from"./chunk-XXQUMVWH.js";import{a as we}from"./chunk-VDW32UET.js";import"./chunk-LZGOETI3.js";import{f as ke}from"./chunk-ETU7KIO4.js";import"./chunk-XBDKZZ67.js";import{a as He,b as je,c as Ke,d as De,e as Ye,f as Ue}from"./chunk-WJQLNYGX.js";import{d as oe,f as ve,g as ye,h as _e,o as ie}from"./chunk-IUYFXK4X.js";import"./chunk-YEGFNH56.js";import{a as i,e as Ee,f as dt,g as ut,h as mt,j as ue}from"./chunk-3XIESWL4.js";var K=Ee(ut(),1);var P=Ee(dt(),1);var c=Ee(mt(),1);var ht=["ORDER BY","GROUP BY","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN","EXPLAIN QUERY PLAN","SELECT","DISTINCT","FROM","WHERE","HAVING","LIMIT","OFFSET","JOIN","ON","AND","OR","AS","ASC","DESC","WITH","UNION","EXPLAIN"],ft=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],Ie=String.fromCodePoint(0),pt=new RegExp(`${Ie}${String.raw`(\d+)`}${Ie}`,"gu"),bt=ht.map(l=>({pattern:new RegExp(String.raw`\b${l.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:l})),gt=ft.map(l=>({pattern:new RegExp(String.raw`\s+${l.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
2
2
  ${l}`})),xt=i(l=>{let e=[],t=l.replaceAll(/'(?:[^']|'')*'/gu,n=>(e.push(n),`${Ie}${(e.length-1).toString()}${Ie}`)).replaceAll(/\s+/gu," ").trim();for(let{pattern:n,replacement:r}of bt)t=t.replaceAll(n,r);for(let{pattern:n,replacement:r}of gt)t=t.replaceAll(n,r);return t=t.replaceAll(pt,(n,r)=>e[Number(r)]??""),t},"yt"),vt=/^(?:explain\s+(?:query\s+plan\s+)?)?(?:select|with)\b/iu,yt=/\b(?:alter|attach|create|delete|detach|drop|insert|pragma|reindex|replace|truncate|update|vacuum)\b/iu,wt=/^\w+/u,St=/;\s*$/u,Nt=/\s/u,kt=i((l,e)=>{let t=e+2;for(;t<l.length&&l[t]!==`
3
- `;)t+=1;return t},"qt"),Ct=i((l,e)=>{let t=l.indexOf("*/",e+2);return t===-1?-1:t+2},"$t"),qt=i(l=>{let e=0;for(;e<l.length;){let t=l[e];if(t!==void 0&&Nt.test(t))e+=1;else if(t==="-"&&l[e+1]==="-")e=kt(l,e);else if(t==="/"&&l[e+1]==="*"){let n=Ct(l,e);if(n===-1)break;e=n}else break}return e},"Tt"),Tt=i(l=>{let e=qt(l),t=l.slice(e).trimEnd();if(t==="")return{code:"SQL_EMPTY",message:"the query is empty"};let n=t.replace(St,""),r=n.indexOf(";");if(r!==-1)return{code:"SQL_MULTIPLE_STATEMENTS",length:1,message:"only a single statement may be run",offset:e+r};let o="the SQL editor is read-only \u2014 only SELECT / WITH / EXPLAIN queries are allowed";if(!vt.test(n))return{code:"SQL_NOT_READONLY",length:wt.exec(n)?.[0].length??1,message:o,offset:e};let s=yt.exec(n);if(s!==null)return{code:"SQL_NOT_READONLY",length:s[0].length,message:`${o} (\`${s[0].toUpperCase()}\` is not allowed)`,offset:e+s.index}},"Rt"),It=/\b(?:from|join)\s+([a-z_][\w$]*)(?:\s+(?:as\s+)?([a-z_][\w$]*))?/giu,Rt=/(?:\bwith\s+(?:recursive\s+)?|,\s*)([a-z_][\w$]*)\s+as\s*\(/giu,Lt=new Set(["cross","full","group","having","inner","join","left","limit","offset","on","order","right","union","using","where","window"]),Et=/[^\n]/gu,_t=i((l,e)=>{let t=l[e];if(t==="'"){let n=e+1;for(;n<l.length&&l[n]!=="'";)n+=1;return Math.min(n+1,l.length)}if(t==="-"&&l[e+1]==="-"){let n=l.indexOf(`
4
- `,e);return n===-1?l.length:n}if(t==="/"&&l[e+1]==="*"){let n=l.indexOf("*/",e+2);return n===-1?l.length:n+2}return-1},"Ot"),Ot=i(l=>{let e="",t=0;for(;t<l.length;){let n=_t(l,t);n===-1?(e+=l.slice(t,t+1),t+=1):(e+=l.slice(t,n).replaceAll(Et," "),t=n)}return e},"Mt"),Mt=i(l=>{let e=new Set;for(let t of l.matchAll(Rt))e.add((t[1]??"").toLowerCase());return e},"Dt"),Dt=i((l,e)=>{let t=new Map;for(let n of l.matchAll(It)){let r=(n[1]??"").toLowerCase(),o=(n[2]??"").toLowerCase();e.has(r)&&(t.set(r,r),o!==""&&!Lt.has(o)&&t.set(o,r))}return t},"At"),ot=i((l,e)=>{let t=Ot(l),n=new Set(e.map(r=>r.toLowerCase()));return{ctes:Mt(t),masked:t,targets:Dt(t,n)}},"Ke"),At=/^(?:__lunora|sqlite_)/iu,Bt=/\b(?:from|join)\s+([a-z_][\w$]*)/giu,$t=/\b([a-z_][\w$]*)\.([a-z_][\w$]*)/giu,zt=new Set(["cross","full","group","having","inner","join","lateral","left","limit","offset","order","right","select","union","where","window"]),Ft=i((l,e,t)=>{let n=[];for(let r of l.matchAll(Bt)){let o=r[1]??"",s=o.toLowerCase();!e.has(s)&&!t.has(s)&&!zt.has(s)&&!At.test(o)&&n.push({length:o.length,message:`unknown table \`${o}\``,offset:r.index+r[0].length-o.length,severity:"error",source:"schema"})}return n},"Ft"),Pt=i((l,e,t)=>{let n=[],r=new Map;for(let[o,s]of Object.entries(e.columns))r.set(o.toLowerCase(),new Set(s.map(m=>m.toLowerCase())));for(let o of l.matchAll($t)){let s=(o[1]??"").toLowerCase(),m=o[2]??"",a=t.get(s),d=a===void 0?void 0:r.get(a);d!==void 0&&!d.has(m.toLowerCase())&&n.push({length:m.length,message:`\`${a??""}\` has no column \`${m}\``,offset:o.index+o[0].length-m.length,severity:"error",source:"schema"})}return n},"Qt"),Qt=i((l,e)=>{if(l.trim()==="")return[];let t=Tt(l);if(t!==void 0)return t.code==="SQL_EMPTY"?[]:[{length:t.length,message:t.message,offset:t.offset,severity:"error",source:"gate"}];let{ctes:n,masked:r,targets:o}=ot(l,e.tables),s=new Set(e.tables.map(m=>m.toLowerCase()));return[...Ft(r,s,n),...Pt(r,e,o)]},"jt"),Wt=ve(we.lintSql),Ht=600,jt=i((l,e,t)=>{let n=ke(),[r,o]=(0,P.useState)([]),s=(0,P.useMemo)(()=>Qt(l,e),[l,e]),m=Ge(l,Ht),a=s.some(p=>p.source==="gate")||m.trim()==="",d=(0,P.useCallback)(async p=>{try{let b=await n.query(Wt,{sql:m},ye(t));p.cancelled||o(b.diagnostics??[])}catch{p.cancelled||o([])}},[n,m,t]);(0,P.useEffect)(()=>{if(a){o([]);return}let p={cancelled:!1};return ie(d(p)),()=>{p.cancelled=!0}},[d,a]);let f=m===l;return(0,P.useMemo)(()=>f?[...s,...r]:s,[s,r,f])},"Ut"),qe=8,Kt=["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"],Yt=new Set(["AND","BY","HAVING","ON","OR","SELECT","WHERE"]),Ut=/[\w$]/,rt=i(l=>l!==void 0&&Ut.test(l),"Ue"),lt=i(l=>{let e=l.length;for(;e>0&&rt(l[e-1]);)e-=1;return l.slice(e)},"Ye"),st=i((l,e)=>{let t=e;for(;t>0&&rt(l[t-1]);)t-=1;return{end:e,start:t,text:l.slice(t,e)}},"Je"),et=i((l,e)=>{let t=l.slice(0,e).trimEnd();return t.endsWith(".")||Yt.has(lt(t).toUpperCase())},"Pe"),Gt=i((l,e,t)=>{let n=l.slice(0,e);if(!n.endsWith("."))return;let r=lt(n.slice(0,-1));if(r!=="")return ot(l,t).targets.get(r.toLowerCase())??r},"Vt"),Be=i((l,e)=>l.toLowerCase().startsWith(e.toLowerCase()),"Me"),tt=i((l,e,t,n)=>{let r=[];for(let o of l)if(Be(o,e)&&(r.push(n(o)),r.length>=t))break;return r},"Fe"),Jt=i((l,e,t)=>{let n=new Map;for(let[r,o]of Object.entries(l.columns))for(let s of o)if(Be(s,e)&&!n.has(s)&&(n.set(s,r),n.size>=t))return[...n].map(([m,a])=>({detail:a,kind:"column",label:m}));return[...n].map(([r,o])=>({detail:o,kind:"column",label:r}))},"Xt"),Vt=i((l,e,t)=>{let n=st(l,e),r=Gt(l,n.start,t.tables);if(r!==void 0){let a=t.columns[r]??t.columns[r.toLowerCase()]??[];return tt(a,n.text,qe,d=>({detail:r,kind:"column",label:d}))}if(n.text===""&&!et(l,n.start))return[];let o=tt(t.tables,n.text,qe,a=>({kind:"table",label:a})),s=Jt(t,n.text,qe),m=Kt.flatMap(a=>n.text!==""&&Be(a,n.text)&&a.toLowerCase()!==n.text.toLowerCase()?[{kind:"keyword",label:a}]:[]);return(et(l,n.start)?[...s,...o,...m]:[...o,...s,...m]).slice(0,qe)},"Zt"),Xt=i((l,e,t)=>{let n=st(l,e),r=l.slice(0,n.start)+t.label+l.slice(n.end);return{caret:n.start+t.label.length,value:r}},"en"),Zt=["boxSizing","borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textTransform","width","wordSpacing"],en=i((l,e)=>{let t=globalThis.getComputedStyle(l),n=globalThis.document.createElement("div"),{style:r}=n;r.position="absolute",r.visibility="hidden",r.whiteSpace="pre-wrap",r.overflowWrap="break-word";for(let a of Zt)r[a]=t[a];n.textContent=l.value.slice(0,Math.max(0,e));let o=globalThis.document.createElement("span");o.textContent=l.value.slice(Math.max(0,e))||".",n.append(o),globalThis.document.body.append(n);let s=o.offsetLeft-l.scrollLeft,m=o.offsetTop-l.scrollTop;return n.remove(),{left:s,top:m}},"nn"),tn=i((l,e,t)=>{let n=(0,K.c)(16),[r,o]=(0,P.useState)(null),s;n[0]!==l||n[1]!==e?(s=i((w,g)=>{let h=Vt(w,g,l);if(h.length===0){o(null);return}let S=e.current,{left:k,top:N}=S===null?{left:0,top:0}:en(S,g);o(C=>C!==null&&C.active===0&&C.left===k&&C.top===N&&C.suggestions.length===h.length&&C.suggestions.every((L,R)=>{let E=h.at(R);return L.kind===E?.kind&&L.label===E.label&&L.detail===E.detail})?C:{active:0,left:k,suggestions:h,top:N})},"s"),n[0]=l,n[1]=e,n[2]=s):s=n[2];let m=s,a;n[3]===Symbol.for("react.memo_cache_sentinel")?(a=i(()=>{o(null)},"a"),n[3]=a):a=n[3];let d=a,f;n[4]===Symbol.for("react.memo_cache_sentinel")?(f=i(w=>{o(g=>{if(g===null)return g;let h=g.suggestions.length,S=(g.active+w+h)%h;return{...g,active:S}})},"f"),n[4]=f):f=n[4];let p=f,b;n[5]!==t||n[6]!==r||n[7]!==e?(b=i(w=>{let g=e.current;if(r===null||g===null)return!1;let h=r.suggestions[w??r.active];if(h===void 0)return!1;let S=Xt(g.value,g.selectionStart,h);return t(S.value),o(null),requestAnimationFrame(()=>{let k=e.current;k!==null&&(k.focus(),k.setSelectionRange(S.caret,S.caret))}),!0},"p"),n[5]=t,n[6]=r,n[7]=e,n[8]=b):b=n[8];let v=b,u;n[9]!==v?(u=i(()=>v(),"c"),n[9]=v,n[10]=u):u=n[10];let x=u,y;return n[11]!==x||n[12]!==v||n[13]!==m||n[14]!==r?(y={close:d,commit:x,commitAt:v,move:p,refresh:m,state:r},n[11]=x,n[12]=v,n[13]=m,n[14]=r,n[15]=y):y=n[15],y},"on"),nn={column:"column",keyword:"keyword",table:"table"},on=20,rn=i(l=>{let e=(0,K.c)(17),{listboxId:t,onPick:n,state:r}=l,o=oe(),s;e[0]!==r?(s=r===null?void 0:{left:r.left,top:r.top+on},e[0]=r,e[1]=s):s=e[1];let m=s;if(r===null)return null;let a;if(e[2]!==t||e[3]!==n||e[4]!==r.active||e[5]!==r.suggestions||e[6]!==o){let f;e[8]!==t||e[9]!==n||e[10]!==r.active||e[11]!==o?(f=i((p,b)=>(0,c.jsxs)("li",{"aria-selected":b===r.active,className:ue("flex cursor-pointer items-center gap-2 px-2 py-1 text-[13px]",b===r.active?"bg-accent text-accent-foreground":"text-foreground"),"data-testid":"sql-autocomplete-item",id:`${t}-opt-${b.toString()}`,onMouseDown:i(v=>{v.preventDefault(),n(b)},"onMouseDown"),role:"option",children:[(0,c.jsx)("span",{className:"truncate font-mono",children:p.label}),p.detail!==void 0&&(0,c.jsx)("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:p.detail}),(0,c.jsx)("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:o(nn[p.kind])})]},`${p.kind}:${p.label}`),"f"),e[8]=t,e[9]=n,e[10]=r.active,e[11]=o,e[12]=f):f=e[12],a=r.suggestions.map(f),e[2]=t,e[3]=n,e[4]=r.active,e[5]=r.suggestions,e[6]=o,e[7]=a}else a=e[7];let d;return e[13]!==t||e[14]!==m||e[15]!==a?(d=(0,c.jsx)("ul",{className:"absolute z-30 max-h-56 w-72 overflow-auto rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-autocomplete",id:t,role:"listbox",style:m,children:a}),e[13]=t,e[14]=m,e[15]=a,e[16]=d):d=e[16],d},"sn"),ln=ve(we.listTables),sn=ve(we.readTablePage),an=i(l=>{let e=(0,K.c)(16),t=ke(),n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],e[0]=n):n=e[0];let[r,o]=(0,P.useState)(n),s;e[1]===Symbol.for("react.memo_cache_sentinel")?(s={},e[1]=s):s=e[1];let[m,a]=(0,P.useState)(s),d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=new Set,e[2]=d):d=e[2];let f=(0,P.useRef)(d),p,b;e[3]!==t||e[4]!==l?(p=i(()=>{let g={cancelled:!1};return ie((async()=>{try{let h=await t.query(ln,{},ye(l));g.cancelled||(o(h.map(dn)),a({}),f.current=new Set)}catch{g.cancelled||(o([]),a({}),f.current=new Set)}})()),()=>{g.cancelled=!0}},"h"),b=[t,l],e[3]=t,e[4]=l,e[5]=p,e[6]=b):(p=e[5],b=e[6]),(0,P.useEffect)(p,b);let v;e[7]!==t||e[8]!==l?(v=i(g=>{f.current.has(g)||(f.current.add(g),ie((async()=>{try{let h=await t.query(sn,{limit:1,offset:0,table:g},ye(l));a(S=>({...S,[g]:h.columns}))}catch{f.current.delete(g)}})()))},"x"),e[7]=t,e[8]=l,e[9]=v):v=e[9];let u=v,x;e[10]!==m||e[11]!==r?(x={columns:m,tables:r},e[10]=m,e[11]=r,e[12]=x):x=e[12];let y=x,w;return e[13]!==u||e[14]!==y?(w={probe:u,schema:y},e[13]=u,e[14]=y,e[15]=w):w=e[15],w},"dn"),Ae=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,cn=i(l=>{let e=new Set;Ae.lastIndex=0;let t=Ae.exec(l);for(;t!==null;)e.add(t[1]??t[2]),t=Ae.exec(l);return[...e]},"un");function dn(l){return l.name}i(dn,"mn");var un=i(l=>{let e=(0,K.c)(34),{onSubmit:t,probe:n,schema:r,setDraft:o}=l,s=(0,P.useId)(),m=(0,P.useRef)(null),a=(0,P.useRef)(null),d=(0,P.useRef)(null),f=tn(r,d,o),{close:p,commit:b,commitAt:v,move:u,refresh:x,state:y}=f,w;e[0]!==v?(w=i(I=>{v(I)},"y"),e[0]=v,e[1]=w):w=e[1];let g=w,h;e[2]!==x?(h=i(()=>{let I=d.current;I!==null&&I===document.activeElement&&x(I.value,I.selectionStart)},"m"),e[2]=x,e[3]=h):h=e[3];let S;e[4]!==x||e[5]!==r?(S=[x,r],e[4]=x,e[5]=r,e[6]=S):S=e[6],(0,P.useEffect)(h,S);let k;e[7]!==n||e[8]!==x||e[9]!==o?(k=i(I=>{let{selectionStart:$,value:W}=I.target;o(W);for(let Q of cn(W))n(Q);x(W,$)},"N"),e[7]=n,e[8]=x,e[9]=o,e[10]=k):k=e[10];let N=k,C;e[11]!==x?(C=i(I=>{let $=I.currentTarget;x($.value,$.selectionStart)},"k"),e[11]=x,e[12]=C):C=e[12];let L=C,R;e[13]!==y||e[14]!==p||e[15]!==b||e[16]!==u||e[17]!==t?(R=i(I=>{if(y!==null){if(I.key==="ArrowDown"){I.preventDefault(),u(1);return}if(I.key==="ArrowUp"){I.preventDefault(),u(-1);return}if(I.key==="Escape"){I.preventDefault(),p();return}if((I.key==="Enter"||I.key==="Tab")&&!I.metaKey&&!I.ctrlKey&&b()){I.preventDefault();return}}(I.metaKey||I.ctrlKey)&&I.key==="Enter"&&(I.preventDefault(),t())},"T"),e[13]=y,e[14]=p,e[15]=b,e[16]=u,e[17]=t,e[18]=R):R=e[18];let E=R,q;e[19]!==p?(q=i(()=>{requestAnimationFrame(()=>{p()})},"C"),e[19]=p,e[20]=q):q=e[20];let O=q,M;e[21]===Symbol.for("react.memo_cache_sentinel")?(M=i(I=>{let{scrollLeft:$,scrollTop:W}=I.currentTarget;m.current!==null&&(m.current.scrollTop=W),a.current!==null&&(a.current.scrollTop=W,a.current.scrollLeft=$)},"_"),e[21]=M):M=e[21];let D=M,T;e[22]===Symbol.for("react.memo_cache_sentinel")?(T=i(I=>{let $=d.current;$===null||I.offset===void 0||($.focus(),$.setSelectionRange(I.offset,I.offset+(I.length??0)))},"q"),e[22]=T):T=e[22];let _=T,A;e[23]!==N||e[24]!==O||e[25]!==E||e[26]!==L?(A={onBlur:O,onChange:N,onKeyDown:E,onScroll:D,onSelect:L},e[23]=N,e[24]=O,e[25]=E,e[26]=L,e[27]=A):A=e[27];let B;return e[28]!==y||e[29]!==p||e[30]!==s||e[31]!==g||e[32]!==A?(B={autocompleteState:y,closeAutocomplete:p,handlers:A,listboxId:s,onPickSuggestion:g,editorRef:d,gutterRef:m,overlayRef:a,revealDiagnostic:_},e[28]=y,e[29]=p,e[30]=s,e[31]=g,e[32]=A,e[33]=B):B=e[33],B},"fn"),mn="lunora-studio-sql-tabs",hn="lunora-studio-sql-active-tab",$e=12,Se=i((l="",e="")=>({activeId:null,id:Me("tab"),name:e,sql:l}),"ve"),fn=i(()=>Oe(hn,""),"bn"),pn=i(l=>{let e=(0,K.c)(16),[t,n]=Ce(mn),[r,o]=fn(),[s]=(0,P.useState)(l),m,a;e[0]!==s||e[1]!==n||e[2]!==t.length?(m=i(()=>{t.length===0&&n([s])},"d"),a=[s,n,t.length],e[0]=s,e[1]=n,e[2]=t.length,e[3]=m,e[4]=a):(m=e[3],a=e[4]),(0,P.useEffect)(m,a);let d;e[5]!==s||e[6]!==t?(d=t.length===0?[s]:t,e[5]=s,e[6]=t,e[7]=d):d=e[7];let f=d,p;e[8]!==r||e[9]!==f?(p=f.some(u=>u.id===r)?r:f[0]?.id??"",e[8]=r,e[9]=f,e[10]=p):p=e[10];let b=p,v;return e[11]!==b||e[12]!==o||e[13]!==n||e[14]!==f?(v={activeId:b,setActiveId:o,setTabs:n,tabs:f},e[11]=b,e[12]=o,e[13]=n,e[14]=f,e[15]=v):v=e[15],v},"gn"),at=i(l=>l.activeId===null&&l.sql.trim()!=="","Ge"),bn=i((l,e)=>[...l,e].slice(-$e),"xn"),gn=i((l,e,t)=>{let n=l.findIndex(o=>o.id===e);if(n===-1)return{activeId:l[0]?.id??"",tabs:[...l]};let r=l.filter(o=>o.id!==e);if(r.length===0){let o=t();return{activeId:o.id,tabs:[o]}}return{activeId:r[Math.min(n,r.length-1)].id,tabs:r}},"vn"),xn=i((l,e)=>{let t=l.filter(n=>n.id===e);return t.length===0?{activeId:l[0]?.id??"",tabs:[...l]}:{activeId:e,tabs:t}},"yn"),vn=i((l,e,t)=>{let n=l.findIndex(o=>o.id===e);if(n===-1)return{activeId:t,tabs:[...l]};let r=l.slice(0,n+1);return{activeId:r.some(o=>o.id===t)?t:e,tabs:r}},"wn"),yn=i(l=>{let e=l();return{activeId:e.id,tabs:[e]}},"Sn"),wn=i((l,e,t)=>{if(l==="others")return e.filter(n=>n.id!==t);if(l==="right"){let n=e.findIndex(r=>r.id===t);return n===-1?[]:e.slice(n+1)}return[...e]},"Nn"),nt={error:null,pane:"results",result:null,running:!1},Sn=i(l=>{let e=(0,K.c)(66),{activeId:t,setActiveId:n,setTabs:r,tabs:o}=pn(l),s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];let[m,a]=(0,P.useState)(s),[d,f]=(0,P.useState)(null),[p,b]=(0,P.useState)(null),v;e[1]!==t||e[2]!==o?(v=o.find(F=>F.id===t)??o[0]??Se(),e[1]=t,e[2]=o,e[3]=v):v=e[3];let u=v,x=m[u.id]??nt,y;e[4]!==u.id||e[5]!==r?(y=i(F=>{r(j=>j.map(U=>U.id===u.id?{...U,...F}:U))},"v"),e[4]=u.id,e[5]=r,e[6]=y):y=e[6];let w=y,g;e[7]!==u.id?(g=i(F=>{a(j=>{let U=j[u.id]??nt;return{...j,[u.id]:{...U,...F}}})},"b"),e[7]=u.id,e[8]=g):g=e[8];let h=g,S;e[9]!==n||e[10]!==r||e[11]!==o.length?(S=i(()=>{if(o.length>=$e)return;let F=Se();r(j=>bn(j,F)),n(F.id)},"w"),e[9]=n,e[10]=r,e[11]=o.length,e[12]=S):S=e[12];let k=S,N;e[13]!==n||e[14]!==r?(N=i(F=>{f(null),b(null),r(F.tabs),n(F.activeId);let j=new Set(F.tabs.map(Nn));a(U=>Object.fromEntries(Object.entries(U).filter(ae=>{let[xe]=ae;return j.has(xe)})))},"S"),e[13]=n,e[14]=r,e[15]=N):N=e[15];let C=N,L;e[16]!==C||e[17]!==o?(L=i(F=>{C(gn(o,F,Se))},"R"),e[16]=C,e[17]=o,e[18]=L):L=e[18];let R=L,E;e[19]!==t||e[20]!==C||e[21]!==o?(E=i((F,j)=>{C(F==="others"?xn(o,j):F==="right"?vn(o,j,t):yn(Se))},"I"),e[19]=t,e[20]=C,e[21]=o,e[22]=E):E=e[22];let q=E,O;e[23]!==q||e[24]!==d||e[25]!==o?(O=i(F=>{d!==null&&(wn(F,o,d.id).some(kn)?b(F):q(F,d.id))},"L"),e[23]=q,e[24]=d,e[25]=o,e[26]=O):O=e[26];let M=O,D;e[27]===Symbol.for("react.memo_cache_sentinel")?(D=i((F,j)=>{j.preventDefault(),b(null),f({id:F,x:j.clientX,y:j.clientY})},"O"),e[27]=D):D=e[27];let T=D,_;e[28]===Symbol.for("react.memo_cache_sentinel")?(_=i(()=>{f(null),b(null)},"E"),e[28]=_):_=e[28];let A=_,B;e[29]===Symbol.for("react.memo_cache_sentinel")?(B=i(F=>{F.preventDefault(),f(null),b(null)},"D"),e[29]=B):B=e[29];let I=B,$;e[30]!==M?($=i(()=>{M("others")},"B"),e[30]=M,e[31]=$):$=e[31];let W=$,Q;e[32]!==M?(Q=i(()=>{M("right")},"P"),e[32]=M,e[33]=Q):Q=e[33];let Y=Q,H;e[34]!==M?(H=i(()=>{M("all")},"Q"),e[34]=M,e[35]=H):H=e[35];let G=H,J;e[36]!==q||e[37]!==p||e[38]!==d?(J=i(()=>{d!==null&&p!==null&&q(p,d.id),b(null)},"J"),e[36]=q,e[37]=p,e[38]=d,e[39]=J):J=e[39];let z=J,V;e[40]===Symbol.for("react.memo_cache_sentinel")?(V=i(()=>{b(null)},"G"),e[40]=V):V=e[40];let re=V,X;e[41]!==d?(X=d===null?void 0:{left:d.x,top:d.y},e[41]=d,e[42]=X):X=e[42];let Z=X,ee;e[43]!==r?(ee=i(F=>{r(j=>j.map(U=>U.activeId===F?{...U,activeId:null}:U))},"Z"),e[43]=r,e[44]=ee):ee=e[44];let te=ee,ne;e[45]!==r?(ne=i((F,j)=>{r(U=>U.map(ae=>ae.id===F?{...ae,name:j}:ae))},"te"),e[45]=r,e[46]=ne):ne=e[46];let le=ne,ce;return e[47]!==u||e[48]!==t||e[49]!==k||e[50]!==R||e[51]!==z||e[52]!==G||e[53]!==W||e[54]!==Y||e[55]!==x||e[56]!==h||e[57]!==w||e[58]!==p||e[59]!==le||e[60]!==n||e[61]!==d||e[62]!==Z||e[63]!==o||e[64]!==te?(ce={activeTab:u,activeTabId:t,addEditorTab:k,cancelBulk:re,closeEditorTab:R,closeTabMenu:A,confirmBulk:z,menuStyle:Z,onBackdropContextMenu:I,onCloseAll:G,onCloseOthers:W,onCloseToRight:Y,openTabMenu:T,output:x,patchActiveOutput:h,patchActiveTab:w,pendingBulk:p,renameTab:le,setActiveTabId:n,tabMenu:d,tabs:o,unlinkQuery:te},e[47]=u,e[48]=t,e[49]=k,e[50]=R,e[51]=z,e[52]=G,e[53]=W,e[54]=Y,e[55]=x,e[56]=h,e[57]=w,e[58]=p,e[59]=le,e[60]=n,e[61]=d,e[62]=Z,e[63]=o,e[64]=te,e[65]=ce):ce=e[65],ce},"kn");function Nn(l){return l.id}i(Nn,"Cn");function kn(l){return at(l)}i(kn,"qn");var Cn="lunora-studio-sql-queries",qn="lunora-studio-sql-history",Tn=25,In=i(l=>{let e=(0,K.c)(33),{loadIntoActiveTab:t,unlinkQuery:n}=l,r=oe(),[o,s]=Ce(Cn),[m,a]=Ce(qn),[d,f]=(0,P.useState)(""),p=(0,P.useRef)(null),b;e[0]!==a?(b=i(T=>{a(_=>_[0]?.sql===T?_:[{at:Date.now(),sql:T},..._.filter(A=>A.sql!==T)].slice(0,Tn))},"p"),e[0]=a,e[1]=b):b=e[1];let v=b,u;e[2]!==t||e[3]!==s||e[4]!==r?(u=i(()=>{let T={id:Me("q"),name:r("Untitled query"),sql:""};s(_=>[T,..._]),t("",T.id)},"c"),e[2]=t,e[3]=s,e[4]=r,e[5]=u):u=e[5];let x=u,y;e[6]!==t||e[7]!==o?(y=i(T=>{let _=o.find(A=>A.id===T);_!==void 0&&(t(_.sql,T),p.current?.querySelector(`[data-testid="sql-query-${T}"]`)?.scrollIntoView({block:"nearest"}))},"v"),e[6]=t,e[7]=o,e[8]=y):y=e[8];let w=y,g;e[9]!==s||e[10]!==n?(g=i(T=>{s(_=>_.filter(A=>A.id!==T)),n(T)},"b"),e[9]=s,e[10]=n,e[11]=g):g=e[11];let h=g,S;e[12]!==t?(S=i(T=>{t(T.currentTarget.dataset.sql??"",null)},"w"),e[12]=t,e[13]=S):S=e[13];let k=S,N;e[14]!==t?(N=i(T=>{t(T.currentTarget.dataset.sql??"",null)},"S"),e[14]=t,e[15]=N):N=e[15];let C=N,L;e[16]!==a?(L=i(()=>{a([])},"R"),e[16]=a,e[17]=L):L=e[17];let R=L,E;e[18]===Symbol.for("react.memo_cache_sentinel")?(E=i(T=>{f(T.target.value)},"I"),e[18]=E):E=e[18];let q=E,O;e[19]!==s?(O=i((T,_)=>{s(A=>A.map(B=>B.id===T?{...B,sql:_}:B))},"L"),e[19]=s,e[20]=O):O=e[20];let M=O,D;return e[21]!==R||e[22]!==h||e[23]!==m||e[24]!==C||e[25]!==k||e[26]!==x||e[27]!==o||e[28]!==v||e[29]!==d||e[30]!==w||e[31]!==M?(D={clearHistory:R,deleteQuery:h,history:m,listRef:p,loadFromHistory:C,loadTemplate:k,newQuery:x,onSearchChange:q,queries:o,recordHistory:v,search:d,selectQuery:w,updateQuerySql:M},e[21]=R,e[22]=h,e[23]=m,e[24]=C,e[25]=k,e[26]=x,e[27]=o,e[28]=v,e[29]=d,e[30]=w,e[31]=M,e[32]=D):D=e[32],D},"In"),it="p-3 font-mono text-xs leading-5 whitespace-pre-wrap break-words",Rn=i((l,e)=>{let t=[];for(let r of l){if(r.offset===void 0||r.length===void 0||r.length<=0)continue;let o=Math.max(0,Math.min(r.offset,e)),s=Math.max(o,Math.min(r.offset+r.length,e));o!==s&&t.push({end:s,severity:r.severity,start:o})}t.sort((r,o)=>r.start-o.start);let n=[];for(let r of t)r.start>=(n.at(-1)?.end??0)&&n.push(r);return n},"En"),Ln=i(l=>l==="unsafe-response"?"The model returned a statement that is not read-only, so it was discarded.":l==="empty-response"?"The model returned nothing usable.":"The model could not be reached.","Ln"),En=i(l=>{let e=(0,K.c)(51),{assistant:t,failed:n,onGenerated:r}=l,o=oe(),[s,m]=(0,P.useState)("");if(t.unavailable)return null;let a;e[0]!==t?(a=t.pending("sql"),e[0]=t,e[1]=a):a=e[1];let d=a,f;if(e[2]!==t||e[3]!==n||e[4]!==r||e[5]!==d||e[6]!==s||e[7]!==o){let p=t.reason("sql"),b;e[9]!==t||e[10]!==n||e[11]!==r||e[12]!==s?(b=i(q=>{let O=s.trim();O===""&&!q||ie((async()=>{let M=await t.generate(O===""?"fix the failing statement":O,q?n:void 0);M!==void 0&&r(M)})())},"p"),e[9]=t,e[10]=n,e[11]=r,e[12]=s,e[13]=b):b=e[13];let v=b,u;e[14]!==o?(u=o("Describe the query you want"),e[14]=o,e[15]=u):u=e[15];let x;e[16]===Symbol.for("react.memo_cache_sentinel")?(x=i(q=>{m(q.target.value)},"g"),e[16]=x):x=e[16];let y;e[17]!==v?(y=i(q=>{q.key==="Enter"&&(q.preventDefault(),v(!1))},"v"),e[17]=v,e[18]=y):y=e[18];let w;e[19]!==o?(w=o("Describe the query you want"),e[19]=o,e[20]=w):w=e[20];let g;e[21]!==d||e[22]!==s||e[23]!==u||e[24]!==y||e[25]!==w?(g=(0,c.jsx)(Fe,{"aria-label":u,className:"h-7 flex-1 text-xs","data-testid":"sql-assistant-prompt",disabled:d,onChange:x,onKeyDown:y,placeholder:w,value:s}),e[21]=d,e[22]=s,e[23]=u,e[24]=y,e[25]=w,e[26]=g):g=e[26];let h=d&&"opacity-60",S;e[27]!==h?(S=ue("rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",h),e[27]=h,e[28]=S):S=e[28];let k;e[29]!==d||e[30]!==s?(k=d||s.trim()==="",e[29]=d,e[30]=s,e[31]=k):k=e[31];let N;e[32]!==v?(N=i(()=>{v(!1)},"S"),e[32]=v,e[33]=N):N=e[33];let C;e[34]!==d||e[35]!==o?(C=o(d?"Thinking\u2026":"Draft SQL"),e[34]=d,e[35]=o,e[36]=C):C=e[36];let L;e[37]!==S||e[38]!==k||e[39]!==N||e[40]!==C?(L=(0,c.jsx)("button",{className:S,"data-testid":"sql-assistant-generate",disabled:k,onClick:N,type:"button",children:C}),e[37]=S,e[38]=k,e[39]=N,e[40]=C,e[41]=L):L=e[41];let R;e[42]!==n||e[43]!==d||e[44]!==v||e[45]!==o?(R=n!==void 0&&(0,c.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:i(()=>{v(!0)},"onClick"),type:"button",children:o("Fix this")}),e[42]=n,e[43]=d,e[44]=v,e[45]=o,e[46]=R):R=e[46];let E;e[47]!==L||e[48]!==R||e[49]!==g?(E=(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[g,L,R]}),e[47]=L,e[48]=R,e[49]=g,e[50]=E):E=e[50],f=(0,c.jsxs)("div",{className:"flex flex-col gap-1 border-b border-border px-3 py-2","data-testid":"sql-assistant",children:[E,p!==void 0&&(0,c.jsx)("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-assistant-reason",role:"status",children:Ln(p)})]}),e[2]=t,e[3]=n,e[4]=r,e[5]=d,e[6]=s,e[7]=o,e[8]=f}else f=e[8];return f},"_n"),_n=i(l=>{let e=(0,K.c)(8),{diagnostics:t,draft:n,scrollRef:r}=l,o,s;if(e[0]!==t||e[1]!==n){s=Symbol.for("react.early_return_sentinel");e:{let d=Rn(t,n.length);if(d.length===0){s=null;break e}o=[];let f=0;for(let[p,b]of d.entries())b.start>f&&o.push(n.slice(f,b.start)),o.push((0,c.jsx)("span",{className:ue("decoration-wavy underline underline-offset-4",b.severity==="error"?"decoration-destructive":"decoration-amber-500"),children:n.slice(b.start,b.end)},`${b.start.toString()}-${p.toString()}`)),f=b.end;o.push(n.slice(f))}e[0]=t,e[1]=n,e[2]=o,e[3]=s}else o=e[2],s=e[3];if(s!==Symbol.for("react.early_return_sentinel"))return s;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=ue("pointer-events-none absolute inset-0 overflow-hidden text-transparent",it),e[4]=m):m=e[4];let a;return e[5]!==o||e[6]!==r?(a=(0,c.jsx)("div",{"aria-hidden":"true",className:m,"data-testid":"sql-diagnostics-overlay",ref:r,children:o}),e[5]=o,e[6]=r,e[7]=a):a=e[7],a},"On"),On={gate:"read-only",plan:"plan",schema:"schema",syntax:"syntax"},Mn=i(l=>{let e=(0,K.c)(10),{diagnostics:t,onSelect:n}=l,r=oe();if(t.length===0)return null;let o;e[0]!==r?(o=r("SQL problems"),e[0]=r,e[1]=o):o=e[1];let s;if(e[2]!==t||e[3]!==n){let a;e[5]!==n?(a=i((d,f)=>(0,c.jsx)("li",{children:(0,c.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:i(()=>{n(d)},"onClick"),type:"button",children:[(0,c.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:On[d.source]}),(0,c.jsx)("span",{className:"min-w-0 text-muted-foreground",children:d.message})]})},`${d.source}-${(d.offset??f).toString()}-${f.toString()}`),"a"),e[5]=n,e[6]=a):a=e[6],s=t.map(a),e[2]=t,e[3]=n,e[4]=s}else s=e[4];let m;return e[7]!==o||e[8]!==s?(m=(0,c.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:s}),e[7]=o,e[8]=s,e[9]=m):m=e[9],m},"Dn"),Dn={minWidth:"2.75rem",paddingInline:"0.5rem"},An=i(l=>{let e=(0,K.c)(64),{assistant:t,autocomplete:n,diagnostics:r,draft:o,failed:s,handlers:m,editorRef:a,gutterRef:d,listboxId:f,onGenerated:p,onPickSuggestion:b,onRevealDiagnostic:v,overlayRef:u}=l,x=oe(),y,w,g,h,S,k,N,C;if(e[0]!==t||e[1]!==o||e[2]!==s||e[3]!==d||e[4]!==p){let $=o.split(`
5
- `).length;N="flex min-h-0 min-w-0 flex-1 flex-col",e[13]!==t||e[14]!==s||e[15]!==p?(C=(0,c.jsx)(En,{assistant:t,failed:s,onGenerated:p}),e[13]=t,e[14]=s,e[15]=p,e[16]=C):C=e[16],k="flex min-h-0 min-w-0 flex-1",y="true",w="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,h=Dn,S=Array.from({length:$},Bn),e[0]=t,e[1]=o,e[2]=s,e[3]=d,e[4]=p,e[5]=y,e[6]=w,e[7]=g,e[8]=h,e[9]=S,e[10]=k,e[11]=N,e[12]=C}else y=e[5],w=e[6],g=e[7],h=e[8],S=e[9],k=e[10],N=e[11],C=e[12];let L;e[17]!==y||e[18]!==w||e[19]!==g||e[20]!==h||e[21]!==S?(L=(0,c.jsx)("div",{"aria-hidden":y,className:w,ref:g,style:h,children:S}),e[17]=y,e[18]=w,e[19]=g,e[20]=h,e[21]=S,e[22]=L):L=e[22];let R;e[23]!==r||e[24]!==o||e[25]!==u?(R=(0,c.jsx)(_n,{diagnostics:r,draft:o,scrollRef:u}),e[23]=r,e[24]=o,e[25]=u,e[26]=R):R=e[26];let E;e[27]!==n||e[28]!==f?(E=n===null?void 0:`${f}-opt-${n.active.toString()}`,e[27]=n,e[28]=f,e[29]=E):E=e[29];let q=n===null?void 0:f,O=n!==null,M;e[30]!==x?(M=x("SQL query"),e[30]=x,e[31]=M):M=e[31];let D;e[32]!==o||e[33]!==a||e[34]!==m.onBlur||e[35]!==m.onChange||e[36]!==m.onKeyDown||e[37]!==m.onScroll||e[38]!==m.onSelect||e[39]!==E||e[40]!==q||e[41]!==O||e[42]!==M?(D=(0,c.jsx)("textarea",{"aria-activedescendant":E,"aria-autocomplete":"list","aria-controls":q,"aria-expanded":O,"aria-label":M,className:`relative size-full resize-none bg-transparent outline-none ${it}`,"data-testid":"sql-input",onBlur:m.onBlur,onChange:m.onChange,onKeyDown:m.onKeyDown,onScroll:m.onScroll,onSelect:m.onSelect,placeholder:"SELECT * FROM \u2026",ref:a,role:"combobox",spellCheck:!1,value:o}),e[32]=o,e[33]=a,e[34]=m.onBlur,e[35]=m.onChange,e[36]=m.onKeyDown,e[37]=m.onScroll,e[38]=m.onSelect,e[39]=E,e[40]=q,e[41]=O,e[42]=M,e[43]=D):D=e[43];let T;e[44]!==n||e[45]!==f||e[46]!==b?(T=(0,c.jsx)(rn,{listboxId:f,onPick:b,state:n}),e[44]=n,e[45]=f,e[46]=b,e[47]=T):T=e[47];let _;e[48]!==R||e[49]!==D||e[50]!==T?(_=(0,c.jsxs)("div",{className:"relative min-w-0 flex-1 bg-background",children:[R,D,T]}),e[48]=R,e[49]=D,e[50]=T,e[51]=_):_=e[51];let A;e[52]!==_||e[53]!==k||e[54]!==L?(A=(0,c.jsxs)("div",{className:k,children:[L,_]}),e[52]=_,e[53]=k,e[54]=L,e[55]=A):A=e[55];let B;e[56]!==r||e[57]!==v?(B=(0,c.jsx)(Mn,{diagnostics:r,onSelect:v}),e[56]=r,e[57]=v,e[58]=B):B=e[58];let I;return e[59]!==A||e[60]!==B||e[61]!==N||e[62]!==C?(I=(0,c.jsxs)("div",{className:N,children:[C,A,B]}),e[59]=A,e[60]=B,e[61]=N,e[62]=C,e[63]=I):I=e[63],I},"Bn");function Bn(l,e){return(0,c.jsx)("div",{children:e+1},e)}i(Bn,"zn");var ct=[{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;"}],$n=i(l=>{let e=(0,K.c)(29),{active:t,onDelete:n,onSelect:r,query:o}=l,s=oe(),m;e[0]!==r||e[1]!==o.id?(m=i(()=>{r(o.id)},"d"),e[0]=r,e[1]=o.id,e[2]=m):m=e[2];let a=m,d;e[3]!==n||e[4]!==o.id?(d=i(N=>{N.stopPropagation(),n(o.id)},"i"),e[3]=n,e[4]=o.id,e[5]=d):d=e[5];let f=d,p=t?"bg-sidebar-accent font-medium text-foreground":"text-muted-foreground",b;e[6]!==p?(b=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",p),e[6]=p,e[7]=b):b=e[7];let v=`sql-query-${o.id}`,u;e[8]===Symbol.for("react.memo_cache_sentinel")?(u=(0,c.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,c.jsx)("path",{d:"M4 6h16M4 12h10M4 18h7"})}),e[8]=u):u=e[8];let x;e[9]!==o.name?(x=(0,c.jsx)("span",{className:"truncate",children:o.name}),e[9]=o.name,e[10]=x):x=e[10];let y;e[11]!==t||e[12]!==a||e[13]!==b||e[14]!==v||e[15]!==x?(y=(0,c.jsxs)("button",{"aria-pressed":t,className:b,"data-testid":v,onClick:a,type:"button",children:[u,x]}),e[11]=t,e[12]=a,e[13]=b,e[14]=v,e[15]=x,e[16]=y):y=e[16];let w;e[17]!==s?(w=s("Delete query"),e[17]=s,e[18]=w):w=e[18];let g;e[19]!==s?(g=s("Delete query"),e[19]=s,e[20]=g):g=e[20];let h;e[21]===Symbol.for("react.memo_cache_sentinel")?(h=(0,c.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,c.jsx)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[21]=h):h=e[21];let S;e[22]!==f||e[23]!==g||e[24]!==w?(S=(0,c.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:f,title:g,type:"button",children:h}),e[22]=f,e[23]=g,e[24]=w,e[25]=S):S=e[25];let k;return e[26]!==S||e[27]!==y?(k=(0,c.jsxs)("li",{className:"group/q flex items-center",children:[y,S]}),e[26]=S,e[27]=y,e[28]=k):k=e[28],k},"Hn"),zn=i((l,e)=>{let t=e.trim().toLowerCase();return t===""?[...l]:l.filter(n=>n.name.toLowerCase().includes(t))},"Pn"),Fn=i(l=>{let e=(0,K.c)(60),{activeId:t,history:n,listRef:r,onClearHistory:o,onDelete:s,onLoadHistory:m,onLoadTemplate:a,onNew:d,onSearchChange:f,onSelect:p,queries:b,search:v}=l,u=oe(),x,y,w,g;if(e[0]!==t||e[1]!==r||e[2]!==s||e[3]!==d||e[4]!==f||e[5]!==p||e[6]!==b||e[7]!==v||e[8]!==u){let q=zn(b,v);y="flex h-full w-64 shrink-0 flex-col border-e border-border bg-sidebar";let O;e[13]!==u?(O=u("Search queries\u2026"),e[13]=u,e[14]=O):O=e[14];let M;e[15]!==f||e[16]!==v||e[17]!==O?(M=(0,c.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:f,placeholder:O,type:"text",value:v}),e[15]=f,e[16]=v,e[17]=O,e[18]=M):M=e[18];let D;e[19]!==u?(D=u("New query"),e[19]=u,e[20]=D):D=e[20];let T;e[21]!==u?(T=u("New query"),e[21]=u,e[22]=T):T=e[22];let _;e[23]===Symbol.for("react.memo_cache_sentinel")?(_=(0,c.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,c.jsx)("path",{d:"M12 5v14M5 12h14"})}),e[23]=_):_=e[23];let A;e[24]!==d||e[25]!==D||e[26]!==T?(A=(0,c.jsx)("button",{"aria-label":D,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:T,type:"button",children:_}),e[24]=d,e[25]=D,e[26]=T,e[27]=A):A=e[27],e[28]!==A||e[29]!==M?(w=(0,c.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border p-2",children:[M,A]}),e[28]=A,e[29]=M,e[30]=w):w=e[30],x="flex flex-1 flex-col gap-4 overflow-y-auto p-2";let B;e[31]!==u?(B=u("Private"),e[31]=u,e[32]=B):B=e[32];let I;e[33]!==B?(I=(0,c.jsx)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:B}),e[33]=B,e[34]=I):I=e[34],g=(0,c.jsxs)("div",{children:[I,q.length===0?(0,c.jsx)("p",{className:"px-1 py-2 text-xs text-muted-foreground","data-testid":"sql-private-empty",children:u("No saved queries yet \u2014 they save to this browser as you type.")}):(0,c.jsx)("ul",{className:"flex flex-col gap-px","data-testid":"sql-private",ref:r,children:q.map($=>(0,c.jsx)($n,{active:t===$.id,onDelete:s,onSelect:p,query:$},$.id))})]}),e[0]=t,e[1]=r,e[2]=s,e[3]=d,e[4]=f,e[5]=p,e[6]=b,e[7]=v,e[8]=u,e[9]=x,e[10]=y,e[11]=w,e[12]=g}else x=e[9],y=e[10],w=e[11],g=e[12];let h;e[35]!==u?(h=u("Reference"),e[35]=u,e[36]=h):h=e[36];let S;e[37]!==h?(S=(0,c.jsx)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h}),e[37]=h,e[38]=S):S=e[38];let k;e[39]!==a?(k=ct.map(q=>(0,c.jsx)("li",{children:(0,c.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":q.sql,onClick:a,type:"button",children:[(0,c.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,c.jsx)("path",{d:"M7 4h7l4 4v12H7zM14 4v4h4"})}),q.label]})},q.label)),e[39]=a,e[40]=k):k=e[40];let N;e[41]!==k?(N=(0,c.jsx)("ul",{className:"flex flex-col gap-px",children:k}),e[41]=k,e[42]=N):N=e[42];let C;e[43]!==S||e[44]!==N?(C=(0,c.jsxs)("div",{children:[S,N]}),e[43]=S,e[44]=N,e[45]=C):C=e[45];let L;e[46]!==n||e[47]!==o||e[48]!==m||e[49]!==u?(L=n.length>0&&(0,c.jsxs)("div",{children:[(0,c.jsxs)("div",{className:"flex items-center justify-between px-1 pb-1",children:[(0,c.jsx)("p",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:u("History")}),(0,c.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:u("Clear history")})]}),(0,c.jsx)("ul",{className:"flex flex-col gap-px","data-testid":"sql-history",children:n.map(q=>(0,c.jsx)("li",{children:(0,c.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":q.sql,"data-testid":"sql-history-item",onClick:m,title:q.sql,type:"button",children:[(0,c.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,c.jsx)("path",{d:"M12 8v4l3 2M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18Z"})}),(0,c.jsx)("span",{className:"truncate font-mono",children:q.sql})]})},`${q.at.toString()}:${q.sql}`))})]}),e[46]=n,e[47]=o,e[48]=m,e[49]=u,e[50]=L):L=e[50];let R;e[51]!==x||e[52]!==L||e[53]!==g||e[54]!==C?(R=(0,c.jsxs)("div",{className:x,children:[g,C,L]}),e[51]=x,e[52]=L,e[53]=g,e[54]=C,e[55]=R):R=e[55];let E;return e[56]!==R||e[57]!==y||e[58]!==w?(E=(0,c.jsxs)("aside",{className:y,children:[w,R]}),e[56]=R,e[57]=y,e[58]=w,e[59]=E):E=e[59],E},"Fn"),Pn=i(l=>{let e=(0,K.c)(19),{result:t}=l,n=oe();if(t.columns.length===0){let d;e[0]!==t.rowCount||e[1]!==n?(d=n("{count} rows",{count:t.rowCount}),e[0]=t.rowCount,e[1]=n,e[2]=d):d=e[2];let f;return e[3]!==d?(f=(0,c.jsx)("p",{className:"p-4 text-sm text-muted-foreground",children:d}),e[3]=d,e[4]=f):f=e[4],f}let r;e[5]!==t.columns?(r=t.columns.map(Qn),e[5]=t.columns,e[6]=r):r=e[6];let o;e[7]!==r?(o=(0,c.jsx)(je,{className:"sticky top-0 z-10 bg-muted",children:(0,c.jsx)(De,{children:r})}),e[7]=r,e[8]=o):o=e[8];let s;if(e[9]!==t.columns||e[10]!==t.rows){let d;e[12]!==t.columns?(d=i((f,p)=>(0,c.jsx)(De,{"data-testid":"sql-row",children:t.columns.map(b=>(0,c.jsx)(Ue,{className:"max-w-md truncate font-mono text-xs",children:(0,c.jsx)(Ve,{value:f[b]})},b))},p),"i"),e[12]=t.columns,e[13]=d):d=e[13],s=t.rows.map(d),e[9]=t.columns,e[10]=t.rows,e[11]=s}else s=e[11];let m;e[14]!==s?(m=(0,c.jsx)(Ke,{children:s}),e[14]=s,e[15]=m):m=e[15];let a;return e[16]!==o||e[17]!==m?(a=(0,c.jsxs)(He,{"data-testid":"sql-rows",children:[o,m]}),e[16]=o,e[17]=m,e[18]=a):a=e[18],a},"Qn");function Qn(l){return(0,c.jsx)(Ye,{children:l},l)}i(Qn,"jn");var Te=i(l=>`border-b-2 px-3 py-2 text-sm outline-none transition-colors ${l?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,"Ne"),Wn=i(l=>{let e=(0,K.c)(92),{assistant:t,chart:n,className:r,error:o,onFormat:s,onInferChart:m,onRun:a,onShardKeyChange:d,onShowChart:f,onShowExplain:p,onShowResults:b,onToggleSplit:v,pane:u,result:x,running:y,shardKey:w,splitView:g}=l,h=oe(),S=u==="results",k;e[0]!==S?(k=Te(S),e[0]=S,e[1]=k):k=e[1];let N;e[2]!==h?(N=h("Results"),e[2]=h,e[3]=N):N=e[3];let C;e[4]!==b||e[5]!==k||e[6]!==N?(C=(0,c.jsx)("button",{className:k,"data-testid":"sql-tab-results",onClick:b,type:"button",children:N}),e[4]=b,e[5]=k,e[6]=N,e[7]=C):C=e[7];let L=u==="chart",R;e[8]!==L?(R=Te(L),e[8]=L,e[9]=R):R=e[9];let E;e[10]!==h?(E=h("Chart"),e[10]=h,e[11]=E):E=e[11];let q;e[12]!==f||e[13]!==R||e[14]!==E?(q=(0,c.jsx)("button",{className:R,"data-testid":"sql-tab-chart",onClick:f,type:"button",children:E}),e[12]=f,e[13]=R,e[14]=E,e[15]=q):q=e[15];let O;e[16]!==t||e[17]!==m||e[18]!==u||e[19]!==x||e[20]!==h?(O=!t.unavailable&&u==="chart"&&x!==null&&(0,c.jsx)("button",{className:Te(!1),"data-testid":"sql-infer-chart",disabled:t.pending("chart"),onClick:m,type:"button",children:t.pending("chart")?h("Thinking\u2026"):h("Suggest chart")}),e[16]=t,e[17]=m,e[18]=u,e[19]=x,e[20]=h,e[21]=O):O=e[21];let M=u==="explain",D;e[22]!==M?(D=Te(M),e[22]=M,e[23]=D):D=e[23];let T;e[24]!==h?(T=h("Explain"),e[24]=h,e[25]=T):T=e[25];let _;e[26]!==p||e[27]!==D||e[28]!==T?(_=(0,c.jsx)("button",{className:D,"data-testid":"sql-tab-explain",onClick:p,type:"button",children:T}),e[26]=p,e[27]=D,e[28]=T,e[29]=_):_=e[29];let A;e[30]!==h?(A=h("Split editor and results"),e[30]=h,e[31]=A):A=e[31];let B=`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 ${g?"bg-accent text-foreground":"text-muted-foreground"}`,I;e[32]!==h?(I=h("Split editor and results"),e[32]=h,e[33]=I):I=e[33];let $;e[34]===Symbol.for("react.memo_cache_sentinel")?($=(0,c.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,c.jsx)("rect",{height:"16",rx:"2",width:"18",x:"3",y:"4"}),(0,c.jsx)("path",{d:"M12 4v16"})]}),e[34]=$):$=e[34];let W;e[35]!==v||e[36]!==g||e[37]!==A||e[38]!==B||e[39]!==I?(W=(0,c.jsx)("button",{"aria-label":A,"aria-pressed":g,className:B,"data-testid":"sql-split-toggle",onClick:v,title:I,type:"button",children:$}),e[35]=v,e[36]=g,e[37]=A,e[38]=B,e[39]=I,e[40]=W):W=e[40];let Q;e[41]!==x?(Q=x!==null&&x.columns.length>0&&(0,c.jsx)(Xe,{columns:x.columns,name:"query-result",rows:x.rows}),e[41]=x,e[42]=Q):Q=e[42];let Y;e[43]!==h?(Y=h("Format"),e[43]=h,e[44]=Y):Y=e[44];let H;e[45]!==s||e[46]!==y||e[47]!==Y?(H=(0,c.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:y,onClick:s,type:"button",children:Y}),e[45]=s,e[46]=y,e[47]=Y,e[48]=H):H=e[48];let G;e[49]!==d||e[50]!==w?(G=(0,c.jsx)(Qe,{onChange:d,testId:"sql-shard-input",value:w}),e[49]=d,e[50]=w,e[51]=G):G=e[51];let J;e[52]!==y||e[53]!==h?(J=h(y?"Running\u2026":"Run"),e[52]=y,e[53]=h,e[54]=J):J=e[54];let z;e[55]===Symbol.for("react.memo_cache_sentinel")?(z=(0,c.jsx)("kbd",{className:"rounded border border-primary-foreground/30 px-1 font-sans text-[10px]",children:"\u2318\u21B5"}),e[55]=z):z=e[55];let V;e[56]!==a||e[57]!==y||e[58]!==J?(V=(0,c.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:y,onClick:a,type:"button",children:[J,z]}),e[56]=a,e[57]=y,e[58]=J,e[59]=V):V=e[59];let re;e[60]!==W||e[61]!==Q||e[62]!==H||e[63]!==G||e[64]!==V?(re=(0,c.jsxs)("div",{className:"ms-auto flex items-center gap-2",children:[W,Q,H,G,V]}),e[60]=W,e[61]=Q,e[62]=H,e[63]=G,e[64]=V,e[65]=re):re=e[65];let X;e[66]!==_||e[67]!==re||e[68]!==C||e[69]!==q||e[70]!==O?(X=(0,c.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pe-2",children:[C,q,O,_,re]}),e[66]=_,e[67]=re,e[68]=C,e[69]=q,e[70]=O,e[71]=X):X=e[71];let Z;e[72]!==o?(Z=o!==null&&(0,c.jsx)(We,{className:"m-3 font-mono text-xs",testId:"sql-error",variant:"destructive",children:o}),e[72]=o,e[73]=Z):Z=e[73];let ee;e[74]!==o||e[75]!==x||e[76]!==h?(ee=o===null&&x===null&&(0,c.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-empty",children:h("Click Run to execute your query.")}),e[74]=o,e[75]=x,e[76]=h,e[77]=ee):ee=e[77];let te;e[78]!==n||e[79]!==o||e[80]!==u||e[81]!==x||e[82]!==h?(te=o===null&&x!==null&&(0,c.jsxs)("div",{"data-testid":"sql-result",children:[u==="chart"?(0,c.jsx)(Ze,{axes:n,result:x}):(0,c.jsx)(Pn,{result:x}),(0,c.jsx)("p",{className:"border-t border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"sql-count",children:x.truncated?h("Showing the first {max} of {count} rows.",{count:x.rowCount,max:x.rows.length}):h("{count} rows",{count:x.rowCount})})]}),e[78]=n,e[79]=o,e[80]=u,e[81]=x,e[82]=h,e[83]=te):te=e[83];let ne;e[84]!==Z||e[85]!==ee||e[86]!==te?(ne=(0,c.jsxs)("div",{className:"min-h-0 flex-1 overflow-auto",children:[Z,ee,te]}),e[84]=Z,e[85]=ee,e[86]=te,e[87]=ne):ne=e[87];let le;return e[88]!==r||e[89]!==X||e[90]!==ne?(le=(0,c.jsxs)("div",{className:r,children:[X,ne]}),e[88]=r,e[89]=X,e[90]=ne,e[91]=le):le=e[91],le},"Wn"),Hn=i((l,e)=>l.trim()===""?e:(l.split(`
6
- `)[0]??l).slice(0,24),"Kn"),jn=i(l=>{l?.focus(),l?.select()},"Un"),Kn=i(l=>{let e=(0,K.c)(14),{initial:t,onCancel:n,onCommit:r,placeholder:o,testId:s}=l,m=oe(),a;e[0]!==r?(a=i(u=>{r(u.currentTarget.value.trim())},"a"),e[0]=r,e[1]=a):a=e[1];let d=a,f;e[2]!==n||e[3]!==r?(f=i(u=>{u.key==="Enter"?r(u.currentTarget.value.trim()):u.key==="Escape"&&n()},"f"),e[2]=n,e[3]=r,e[4]=f):f=e[4];let p=f,b;e[5]!==m?(b=m("Tab title"),e[5]=m,e[6]=b):b=e[6];let v;return e[7]!==t||e[8]!==d||e[9]!==p||e[10]!==o||e[11]!==b||e[12]!==s?(v=(0,c.jsx)("input",{"aria-label":b,className:"w-40 rounded border border-ring bg-background px-1 py-0.5 text-xs outline-none","data-testid":s,defaultValue:t,onBlur:d,onKeyDown:p,placeholder:o,ref:jn,type:"text"}),e[7]=t,e[8]=d,e[9]=p,e[10]=o,e[11]=b,e[12]=s,e[13]=v):v=e[13],v},"Yn"),Yn=i(l=>{let e=(0,K.c)(29),{idBase:t,onDiscard:n,onKeep:r}=l,o=oe(),s=`sql-tab-close-prompt-${t}`,m;e[0]!==o?(m=o("Discard?"),e[0]=o,e[1]=m):m=e[1];let a;e[2]!==m?(a=(0,c.jsx)("span",{className:"text-[11px] text-muted-foreground",children:m}),e[2]=m,e[3]=a):a=e[3];let d;e[4]!==o?(d=o("Discard changes"),e[4]=o,e[5]=d):d=e[5];let f=`sql-tab-close-confirm-${t}`,p;e[6]!==o?(p=o("Discard changes"),e[6]=o,e[7]=p):p=e[7];let b;e[8]===Symbol.for("react.memo_cache_sentinel")?(b=(0,c.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,c.jsx)("path",{d:"M5 13l4 4L19 7"})}),e[8]=b):b=e[8];let v;e[9]!==n||e[10]!==d||e[11]!==f||e[12]!==p?(v=(0,c.jsx)("button",{"aria-label":d,className:"flex size-5 items-center justify-center rounded text-destructive hover:bg-destructive/10","data-testid":f,onClick:n,title:p,type:"button",children:b}),e[9]=n,e[10]=d,e[11]=f,e[12]=p,e[13]=v):v=e[13];let u;e[14]!==o?(u=o("Keep editing"),e[14]=o,e[15]=u):u=e[15];let x=`sql-tab-close-cancel-${t}`,y;e[16]!==o?(y=o("Keep editing"),e[16]=o,e[17]=y):y=e[17];let w;e[18]===Symbol.for("react.memo_cache_sentinel")?(w=(0,c.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,c.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})}),e[18]=w):w=e[18];let g;e[19]!==r||e[20]!==x||e[21]!==y||e[22]!==u?(g=(0,c.jsx)("button",{"aria-label":u,className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent","data-testid":x,onClick:r,title:y,type:"button",children:w}),e[19]=r,e[20]=x,e[21]=y,e[22]=u,e[23]=g):g=e[23];let h;return e[24]!==s||e[25]!==g||e[26]!==a||e[27]!==v?(h=(0,c.jsxs)("span",{className:"flex shrink-0 items-center gap-1","data-testid":s,role:"group",children:[a,v,g]}),e[24]=s,e[25]=g,e[26]=a,e[27]=v,e[28]=h):h=e[28],h},"Jn"),Un=i(l=>{let e=(0,K.c)(47),{active:t,canClose:n,onClose:r,onMenu:o,onRename:s,onSelect:m,tab:a}=l,d=oe(),[f,p]=(0,P.useState)(!1),[b,v]=(0,P.useState)(!1),u;e[0]!==o||e[1]!==a.id?(u=i(H=>{o(a.id,H)},"c"),e[0]=o,e[1]=a.id,e[2]=u):u=e[2];let x=u,y;e[3]!==m||e[4]!==a.id?(y=i(()=>{m(a.id)},"v"),e[3]=m,e[4]=a.id,e[5]=y):y=e[5];let w=y,g;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=i(()=>{p(!0)},"b"),e[6]=g):g=e[6];let h=g,S;e[7]!==r||e[8]!==a?(S=i(H=>{H.stopPropagation(),at(a)?v(!0):r(a.id)},"w"),e[7]=r,e[8]=a,e[9]=S):S=e[9];let k=S,N;e[10]!==r||e[11]!==a.id?(N=i(H=>{H.stopPropagation(),v(!1),r(a.id)},"S"),e[10]=r,e[11]=a.id,e[12]=N):N=e[12];let C=N,L;e[13]===Symbol.for("react.memo_cache_sentinel")?(L=i(H=>{H.stopPropagation(),v(!1)},"R"),e[13]=L):L=e[13];let R=L,E;e[14]!==s||e[15]!==a.id?(E=i(H=>{s(a.id,H),p(!1)},"I"),e[14]=s,e[15]=a.id,e[16]=E):E=e[16];let q=E,O;e[17]===Symbol.for("react.memo_cache_sentinel")?(O=i(()=>{p(!1)},"L"),e[17]=O):O=e[17];let M=O,D;e[18]!==a.name?(D=a.name.trim(),e[18]=a.name,e[19]=D):D=e[19];let T=D,_;e[20]!==d||e[21]!==a.sql?(_=Hn(a.sql,d("Untitled")),e[20]=d,e[21]=a.sql,e[22]=_):_=e[22];let A=_,B=t?"bg-background text-foreground":"bg-muted/40 text-muted-foreground hover:text-foreground",I;e[23]!==B?(I=ue("group/tab flex shrink-0 items-center gap-1 border-e border-border ps-3 pe-1.5 text-xs",B),e[23]=B,e[24]=I):I=e[24];let $=`sql-tab-${a.id}`,W;e[25]!==t||e[26]!==q||e[27]!==T||e[28]!==A||e[29]!==f||e[30]!==w||e[31]!==d||e[32]!==a.id?(W=f?(0,c.jsx)(Kn,{initial:T,onCancel:M,onCommit:q,placeholder:A,testId:`sql-tab-rename-${a.id}`}):(0,c.jsx)("button",{"aria-pressed":t,className:"max-w-40 truncate py-1.5 outline-none","data-testid":`sql-tab-select-${a.id}`,onClick:w,onDoubleClick:h,title:d("Double-click to rename"),type:"button",children:T===""?A:T}),e[25]=t,e[26]=q,e[27]=T,e[28]=A,e[29]=f,e[30]=w,e[31]=d,e[32]=a.id,e[33]=W):W=e[33];let Q;e[34]!==n||e[35]!==C||e[36]!==b||e[37]!==k||e[38]!==d||e[39]!==a.id?(Q=n&&(b?(0,c.jsx)(Yn,{idBase:a.id,onDiscard:C,onKeep:R}):(0,c.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-${a.id}`,onClick:k,title:d("Close tab"),type:"button",children:(0,c.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,c.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})})})),e[34]=n,e[35]=C,e[36]=b,e[37]=k,e[38]=d,e[39]=a.id,e[40]=Q):Q=e[40];let Y;return e[41]!==x||e[42]!==I||e[43]!==$||e[44]!==W||e[45]!==Q?(Y=(0,c.jsxs)("div",{className:I,"data-testid":$,onContextMenu:x,children:[W,Q]}),e[41]=x,e[42]=I,e[43]=$,e[44]=W,e[45]=Q,e[46]=Y):Y=e[46],Y},"Gn"),Gn=i(l=>{let e=(0,K.c)(43),{model:t,onSelect:n}=l,r=oe(),{activeTab:o,addEditorTab:s,cancelBulk:m,closeEditorTab:a,closeTabMenu:d,confirmBulk:f,menuStyle:p,onBackdropContextMenu:b,onCloseAll:v,onCloseOthers:u,onCloseToRight:x,openTabMenu:y,pendingBulk:w,renameTab:g,tabMenu:h,tabs:S}=t,k;if(e[0]!==o||e[1]!==a||e[2]!==n||e[3]!==y||e[4]!==g||e[5]!==S){let D;e[7]!==o||e[8]!==a||e[9]!==n||e[10]!==y||e[11]!==g||e[12]!==S.length?(D=i(T=>(0,c.jsx)(Un,{active:T.id===o.id,canClose:S.length>1,onClose:a,onMenu:y,onRename:g,onSelect:n,tab:T},T.id),"O"),e[7]=o,e[8]=a,e[9]=n,e[10]=y,e[11]=g,e[12]=S.length,e[13]=D):D=e[13],k=S.map(D),e[0]=o,e[1]=a,e[2]=n,e[3]=y,e[4]=g,e[5]=S,e[6]=k}else k=e[6];let N;e[14]!==r?(N=r("New tab"),e[14]=r,e[15]=N):N=e[15];let C=S.length>=$e,L;e[16]!==r?(L=r("New tab"),e[16]=r,e[17]=L):L=e[17];let R;e[18]===Symbol.for("react.memo_cache_sentinel")?(R=(0,c.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,c.jsx)("path",{d:"M12 5v14M5 12h14"})}),e[18]=R):R=e[18];let E;e[19]!==s||e[20]!==N||e[21]!==C||e[22]!==L?(E=(0,c.jsx)("button",{"aria-label":N,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:C,onClick:s,title:L,type:"button",children:R}),e[19]=s,e[20]=N,e[21]=C,e[22]=L,e[23]=E):E=e[23];let q;e[24]!==k||e[25]!==E?(q=(0,c.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:[k,E]}),e[24]=k,e[25]=E,e[26]=q):q=e[26];let O;e[27]!==m||e[28]!==d||e[29]!==f||e[30]!==p||e[31]!==b||e[32]!==v||e[33]!==u||e[34]!==x||e[35]!==w||e[36]!==r||e[37]!==h||e[38]!==S?(O=h!==null&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("div",{className:"fixed inset-0 z-40","data-testid":"sql-tab-menu-backdrop",onClick:d,onContextMenu:b,role:"presentation"}),(0,c.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:p,children:w===null?(0,c.jsxs)(c.Fragment,{children:[(0,c.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:S.length<=1,onClick:u,role:"menuitem",type:"button",children:r("Close other tabs")}),(0,c.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:S.findIndex(D=>D.id===h.id)>=S.length-1,onClick:x,role:"menuitem",type:"button",children:r("Close tabs to the right")}),(0,c.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,c.jsxs)("div",{className:"px-3 py-1.5","data-testid":"sql-tab-menu-confirm",children:[(0,c.jsx)("p",{className:"pb-1.5 text-xs text-muted-foreground",children:r("Discard unsaved tabs?")}),(0,c.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,c.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:f,type:"button",children:r("Discard")}),(0,c.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:m,type:"button",children:r("Cancel")})]})]})})]}),e[27]=m,e[28]=d,e[29]=f,e[30]=p,e[31]=b,e[32]=v,e[33]=u,e[34]=x,e[35]=w,e[36]=r,e[37]=h,e[38]=S,e[39]=O):O=e[39];let M;return e[40]!==q||e[41]!==O?(M=(0,c.jsxs)(c.Fragment,{children:[q,O]}),e[40]=q,e[41]=O,e[42]=M):M=e[42],M},"Vn"),Jn=ve(we.runSql),Vn="lunora-studio-sql-split-view",Xn=i(()=>Se(ct[0]?.sql??""),"eo"),bo=i(l=>{let e=(0,K.c)(102),{initialShardKey:t}=l,n=ke(),r=Sn(Xn),{activeTab:o,output:s,patchActiveOutput:m,patchActiveTab:a,setActiveTabId:d,unlinkQuery:f}=r,p;e[0]!==m||e[1]!==a?(p=i((se,de)=>{a({activeId:de,sql:se}),m({chart:void 0,error:null,failed:void 0,result:null})},"h"),e[0]=m,e[1]=a,e[2]=p):p=e[2];let b=p,v;e[3]!==b||e[4]!==f?(v={loadIntoActiveTab:b,unlinkQuery:f},e[3]=b,e[4]=f,e[5]=v):v=e[5];let u=In(v),{recordHistory:x,updateQuerySql:y}=u,w=o.sql,{activeId:g}=o,{chart:h,error:S,failed:k,result:N,running:C}=s,L=s.pane,[R,E]=(0,P.useState)(t??""),[q,O]=Oe(Vn,!1),{probe:M,schema:D}=an(R),T;e[6]!==g||e[7]!==a||e[8]!==y?(T=i(se=>{a({sql:se}),g!==null&&y(g,se)},"q"),e[6]=g,e[7]=a,e[8]=y,e[9]=T):T=e[9];let _=T,A=jt(w,D,R),B=Je(R),I;e[10]!==B||e[11]!==m||e[12]!==N?(I=i(()=>{N!==null&&ie((async()=>{let se=await B.inferChart({columns:N.columns,rowCount:N.rowCount,types:Object.fromEntries(N.columns.map(de=>[de,typeof(N.rows[0]?.[de]??"")]))});m({chart:se})})())},"$"),e[10]=B,e[11]=m,e[12]=N,e[13]=I):I=e[13];let $=I,W;e[14]!==n||e[15]!==w||e[16]!==m||e[17]!==x||e[18]!==R?(W=i(async se=>{if(w.trim()==="")return;m({running:!0});let de=se==="explain"?`EXPLAIN QUERY PLAN ${w}`:w;try{let Le=await n.query(Jn,{sql:de},ye(R));m({chart:void 0,error:null,failed:void 0,pane:se,result:Le,running:!1}),Pe(R),x(de)}catch(Le){let ze=Le;m({chart:void 0,error:_e(ze),failed:{error:_e(ze),sql:de},pane:se,result:null,running:!1})}},"F"),e[14]=n,e[15]=w,e[16]=m,e[17]=x,e[18]=R,e[19]=W):W=e[19];let Q=W,Y;e[20]!==Q?(Y=i(()=>{ie(Q("results"))},"W"),e[20]=Q,e[21]=Y):Y=e[21];let H=Y,G;e[22]!==s.pane||e[23]!==Q?(G=i(()=>{ie(Q(s.pane))},"Y"),e[22]=s.pane,e[23]=Q,e[24]=G):G=e[24];let J;e[25]!==M||e[26]!==D||e[27]!==_||e[28]!==G?(J={onSubmit:G,probe:M,schema:D,setDraft:_},e[25]=M,e[26]=D,e[27]=_,e[28]=G,e[29]=J):J=e[29];let z=un(J),{closeAutocomplete:V}=z,re;e[30]!==w||e[31]!==_?(re=i(()=>{_(xt(w))},"ne"),e[30]=w,e[31]=_,e[32]=re):re=e[32];let X=re,Z;e[33]!==V||e[34]!==d?(Z=i(se=>{V(),d(se)},"X"),e[33]=V,e[34]=d,e[35]=Z):Z=e[35];let ee=Z,te;e[36]!==m?(te=i(()=>{m({pane:"results"})},"ee"),e[36]=m,e[37]=te):te=e[37];let ne=te,le;e[38]!==Q?(le=i(()=>{ie(Q("explain"))},"oe"),e[38]=Q,e[39]=le):le=e[39];let ce=le,F;e[40]!==m?(F=i(()=>{m({pane:"chart"})},"H"),e[40]=m,e[41]=F):F=e[41];let j=F,U;e[42]!==O||e[43]!==q?(U=i(()=>{O(!q)},"U"),e[42]=O,e[43]=q,e[44]=U):U=e[44];let ae=U,xe=q?"flex min-h-0 flex-1 flex-row":"flex min-h-0 flex-1 flex-col",Re=q?"flex w-2/5 min-h-0 min-w-0 shrink-0 flex-col border-s border-border":"flex h-2/5 min-h-0 shrink-0 flex-col border-t border-border",me;e[45]!==g||e[46]!==u.clearHistory||e[47]!==u.deleteQuery||e[48]!==u.history||e[49]!==u.listRef||e[50]!==u.loadFromHistory||e[51]!==u.loadTemplate||e[52]!==u.newQuery||e[53]!==u.onSearchChange||e[54]!==u.queries||e[55]!==u.search||e[56]!==u.selectQuery?(me=(0,c.jsx)(Fn,{activeId:g,history:u.history,listRef:u.listRef,onClearHistory:u.clearHistory,onDelete:u.deleteQuery,onLoadHistory:u.loadFromHistory,onLoadTemplate:u.loadTemplate,onNew:u.newQuery,onSearchChange:u.onSearchChange,onSelect:u.selectQuery,queries:u.queries,search:u.search}),e[45]=g,e[46]=u.clearHistory,e[47]=u.deleteQuery,e[48]=u.history,e[49]=u.listRef,e[50]=u.loadFromHistory,e[51]=u.loadTemplate,e[52]=u.newQuery,e[53]=u.onSearchChange,e[54]=u.queries,e[55]=u.search,e[56]=u.selectQuery,e[57]=me):me=e[57];let he;e[58]!==r||e[59]!==ee?(he=(0,c.jsx)(Gn,{model:r,onSelect:ee}),e[58]=r,e[59]=ee,e[60]=he):he=e[60];let fe;e[61]!==B||e[62]!==A||e[63]!==w||e[64]!==k||e[65]!==_||e[66]!==z.autocompleteState||e[67]!==z.editorRef||e[68]!==z.gutterRef||e[69]!==z.handlers||e[70]!==z.listboxId||e[71]!==z.onPickSuggestion||e[72]!==z.overlayRef||e[73]!==z.revealDiagnostic?(fe=(0,c.jsx)(An,{assistant:B,autocomplete:z.autocompleteState,diagnostics:A,draft:w,editorRef:z.editorRef,failed:k,gutterRef:z.gutterRef,handlers:z.handlers,listboxId:z.listboxId,onGenerated:_,onPickSuggestion:z.onPickSuggestion,onRevealDiagnostic:z.revealDiagnostic,overlayRef:z.overlayRef}),e[61]=B,e[62]=A,e[63]=w,e[64]=k,e[65]=_,e[66]=z.autocompleteState,e[67]=z.editorRef,e[68]=z.gutterRef,e[69]=z.handlers,e[70]=z.listboxId,e[71]=z.onPickSuggestion,e[72]=z.overlayRef,e[73]=z.revealDiagnostic,e[74]=fe):fe=e[74];let pe;e[75]!==B||e[76]!==S||e[77]!==X||e[78]!==$||e[79]!==h||e[80]!==H||e[81]!==N||e[82]!==Re||e[83]!==C||e[84]!==R||e[85]!==j||e[86]!==ce||e[87]!==ne||e[88]!==q||e[89]!==L||e[90]!==ae?(pe=(0,c.jsx)(Wn,{assistant:B,chart:h,className:Re,error:S,onFormat:X,onInferChart:$,onRun:H,onShardKeyChange:E,onShowChart:j,onShowExplain:ce,onShowResults:ne,onToggleSplit:ae,pane:L,result:N,running:C,shardKey:R,splitView:q}),e[75]=B,e[76]=S,e[77]=X,e[78]=$,e[79]=h,e[80]=H,e[81]=N,e[82]=Re,e[83]=C,e[84]=R,e[85]=j,e[86]=ce,e[87]=ne,e[88]=q,e[89]=L,e[90]=ae,e[91]=pe):pe=e[91];let be;e[92]!==fe||e[93]!==pe||e[94]!==xe?(be=(0,c.jsxs)("div",{className:xe,children:[fe,pe]}),e[92]=fe,e[93]=pe,e[94]=xe,e[95]=be):be=e[95];let ge;e[96]!==he||e[97]!==be?(ge=(0,c.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col",children:[he,be]}),e[96]=he,e[97]=be,e[98]=ge):ge=e[98];let Ne;return e[99]!==me||e[100]!==ge?(Ne=(0,c.jsxs)("div",{className:"flex h-full min-w-0","data-testid":"lunora-sql-editor",children:[me,ge]}),e[99]=me,e[100]=ge,e[101]=Ne):Ne=e[101],Ne},"wo");export{bo as SqlEditorPanel};
3
+ `;)t+=1;return t},"$t"),Ct=i((l,e)=>{let t=l.indexOf("*/",e+2);return t===-1?-1:t+2},"qt"),qt=i(l=>{let e=0;for(;e<l.length;){let t=l[e];if(t!==void 0&&Nt.test(t))e+=1;else if(t==="-"&&l[e+1]==="-")e=kt(l,e);else if(t==="/"&&l[e+1]==="*"){let n=Ct(l,e);if(n===-1)break;e=n}else break}return e},"Tt"),Tt=i(l=>{let e=qt(l),t=l.slice(e).trimEnd();if(t==="")return{code:"SQL_EMPTY",message:"the query is empty"};let n=t.replace(St,""),r=n.indexOf(";");if(r!==-1)return{code:"SQL_MULTIPLE_STATEMENTS",length:1,message:"only a single statement may be run",offset:e+r};let o="the SQL editor is read-only \u2014 only SELECT / WITH / EXPLAIN queries are allowed";if(!vt.test(n))return{code:"SQL_NOT_READONLY",length:wt.exec(n)?.[0].length??1,message:o,offset:e};let s=yt.exec(n);if(s!==null)return{code:"SQL_NOT_READONLY",length:s[0].length,message:`${o} (\`${s[0].toUpperCase()}\` is not allowed)`,offset:e+s.index}},"Rt"),It=/\b(?:from|join)\s+([a-z_][\w$]*)(?:\s+(?:as\s+)?([a-z_][\w$]*))?/giu,Rt=/(?:\bwith\s+(?:recursive\s+)?|,\s*)([a-z_][\w$]*)\s+as\s*\(/giu,Lt=new Set(["cross","full","group","having","inner","join","left","limit","offset","on","order","right","union","using","where","window"]),Et=/[^\n]/gu,_t=i((l,e)=>{let t=l[e];if(t==="'"){let n=e+1;for(;n<l.length&&l[n]!=="'";)n+=1;return Math.min(n+1,l.length)}if(t==="-"&&l[e+1]==="-"){let n=l.indexOf(`
4
+ `,e);return n===-1?l.length:n}if(t==="/"&&l[e+1]==="*"){let n=l.indexOf("*/",e+2);return n===-1?l.length:n+2}return-1},"Ot"),Ot=i(l=>{let e="",t=0;for(;t<l.length;){let n=_t(l,t);n===-1?(e+=l.slice(t,t+1),t+=1):(e+=l.slice(t,n).replaceAll(Et," "),t=n)}return e},"Mt"),Mt=i(l=>{let e=new Set;for(let t of l.matchAll(Rt))e.add((t[1]??"").toLowerCase());return e},"Dt"),Dt=i((l,e)=>{let t=new Map;for(let n of l.matchAll(It)){let r=(n[1]??"").toLowerCase(),o=(n[2]??"").toLowerCase();e.has(r)&&(t.set(r,r),o!==""&&!Lt.has(o)&&t.set(o,r))}return t},"At"),ot=i((l,e)=>{let t=Ot(l),n=new Set(e.map(r=>r.toLowerCase()));return{ctes:Mt(t),masked:t,targets:Dt(t,n)}},"Ke"),At=/^(?:__lunora|sqlite_)/iu,$t=/\b(?:from|join)\s+([a-z_][\w$]*)/giu,Bt=/\b([a-z_][\w$]*)\.([a-z_][\w$]*)/giu,zt=new Set(["cross","full","group","having","inner","join","lateral","left","limit","offset","order","right","select","union","where","window"]),Ft=i((l,e,t)=>{let n=[];for(let r of l.matchAll($t)){let o=r[1]??"",s=o.toLowerCase();!e.has(s)&&!t.has(s)&&!zt.has(s)&&!At.test(o)&&n.push({length:o.length,message:`unknown table \`${o}\``,offset:r.index+r[0].length-o.length,severity:"error",source:"schema"})}return n},"Ft"),Pt=i((l,e,t)=>{let n=[],r=new Map;for(let[o,s]of Object.entries(e.columns))r.set(o.toLowerCase(),new Set(s.map(m=>m.toLowerCase())));for(let o of l.matchAll(Bt)){let s=(o[1]??"").toLowerCase(),m=o[2]??"",a=t.get(s),d=a===void 0?void 0:r.get(a);d!==void 0&&!d.has(m.toLowerCase())&&n.push({length:m.length,message:`\`${a??""}\` has no column \`${m}\``,offset:o.index+o[0].length-m.length,severity:"error",source:"schema"})}return n},"Qt"),Qt=i((l,e)=>{if(l.trim()==="")return[];let t=Tt(l);if(t!==void 0)return t.code==="SQL_EMPTY"?[]:[{length:t.length,message:t.message,offset:t.offset,severity:"error",source:"gate"}];let{ctes:n,masked:r,targets:o}=ot(l,e.tables),s=new Set(e.tables.map(m=>m.toLowerCase()));return[...Ft(r,s,n),...Pt(r,e,o)]},"jt"),Wt=ve(we.lintSql),Ht=600,jt=i((l,e,t)=>{let n=ke(),[r,o]=(0,P.useState)([]),s=(0,P.useMemo)(()=>Qt(l,e),[l,e]),m=Ge(l,Ht),a=s.some(p=>p.source==="gate")||m.trim()==="",d=(0,P.useCallback)(async p=>{try{let b=await n.query(Wt,{sql:m},ye(t));p.cancelled||o(b.diagnostics??[])}catch{p.cancelled||o([])}},[n,m,t]);(0,P.useEffect)(()=>{if(a){o([]);return}let p={cancelled:!1};return ie(d(p)),()=>{p.cancelled=!0}},[d,a]);let f=m===l;return(0,P.useMemo)(()=>f?[...s,...r]:s,[s,r,f])},"Ut"),qe=8,Kt=["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"],Yt=new Set(["AND","BY","HAVING","ON","OR","SELECT","WHERE"]),Ut=/[\w$]/,rt=i(l=>l!==void 0&&Ut.test(l),"Ue"),lt=i(l=>{let e=l.length;for(;e>0&&rt(l[e-1]);)e-=1;return l.slice(e)},"Ye"),st=i((l,e)=>{let t=e;for(;t>0&&rt(l[t-1]);)t-=1;return{end:e,start:t,text:l.slice(t,e)}},"Je"),et=i((l,e)=>{let t=l.slice(0,e).trimEnd();return t.endsWith(".")||Yt.has(lt(t).toUpperCase())},"Pe"),Gt=i((l,e,t)=>{let n=l.slice(0,e);if(!n.endsWith("."))return;let r=lt(n.slice(0,-1));if(r!=="")return ot(l,t).targets.get(r.toLowerCase())??r},"Vt"),$e=i((l,e)=>l.toLowerCase().startsWith(e.toLowerCase()),"Me"),tt=i((l,e,t,n)=>{let r=[];for(let o of l)if($e(o,e)&&(r.push(n(o)),r.length>=t))break;return r},"Fe"),Jt=i((l,e,t)=>{let n=new Map;for(let[r,o]of Object.entries(l.columns))for(let s of o)if($e(s,e)&&!n.has(s)&&(n.set(s,r),n.size>=t))return[...n].map(([m,a])=>({detail:a,kind:"column",label:m}));return[...n].map(([r,o])=>({detail:o,kind:"column",label:r}))},"Xt"),Vt=i((l,e,t)=>{let n=st(l,e),r=Gt(l,n.start,t.tables);if(r!==void 0){let a=t.columns[r]??t.columns[r.toLowerCase()]??[];return tt(a,n.text,qe,d=>({detail:r,kind:"column",label:d}))}if(n.text===""&&!et(l,n.start))return[];let o=tt(t.tables,n.text,qe,a=>({kind:"table",label:a})),s=Jt(t,n.text,qe),m=Kt.flatMap(a=>n.text!==""&&$e(a,n.text)&&a.toLowerCase()!==n.text.toLowerCase()?[{kind:"keyword",label:a}]:[]);return(et(l,n.start)?[...s,...o,...m]:[...o,...s,...m]).slice(0,qe)},"Zt"),Xt=i((l,e,t)=>{let n=st(l,e),r=l.slice(0,n.start)+t.label+l.slice(n.end);return{caret:n.start+t.label.length,value:r}},"en"),Zt=["boxSizing","borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textTransform","width","wordSpacing"],en=i((l,e)=>{let t=globalThis.getComputedStyle(l),n=globalThis.document.createElement("div"),{style:r}=n;r.position="absolute",r.visibility="hidden",r.whiteSpace="pre-wrap",r.overflowWrap="break-word";for(let a of Zt)r[a]=t[a];n.textContent=l.value.slice(0,Math.max(0,e));let o=globalThis.document.createElement("span");o.textContent=l.value.slice(Math.max(0,e))||".",n.append(o),globalThis.document.body.append(n);let s=o.offsetLeft-l.scrollLeft,m=o.offsetTop-l.scrollTop;return n.remove(),{left:s,top:m}},"nn"),tn=i((l,e,t)=>{let n=(0,K.c)(16),[r,o]=(0,P.useState)(null),s;n[0]!==l||n[1]!==e?(s=i((w,g)=>{let h=Vt(w,g,l);if(h.length===0){o(null);return}let S=e.current,{left:k,top:N}=S===null?{left:0,top:0}:en(S,g);o(C=>C!==null&&C.active===0&&C.left===k&&C.top===N&&C.suggestions.length===h.length&&C.suggestions.every((L,R)=>{let E=h.at(R);return L.kind===E?.kind&&L.label===E.label&&L.detail===E.detail})?C:{active:0,left:k,suggestions:h,top:N})},"s"),n[0]=l,n[1]=e,n[2]=s):s=n[2];let m=s,a;n[3]===Symbol.for("react.memo_cache_sentinel")?(a=i(()=>{o(null)},"a"),n[3]=a):a=n[3];let d=a,f;n[4]===Symbol.for("react.memo_cache_sentinel")?(f=i(w=>{o(g=>{if(g===null)return g;let h=g.suggestions.length,S=(g.active+w+h)%h;return{...g,active:S}})},"f"),n[4]=f):f=n[4];let p=f,b;n[5]!==t||n[6]!==r||n[7]!==e?(b=i(w=>{let g=e.current;if(r===null||g===null)return!1;let h=r.suggestions[w??r.active];if(h===void 0)return!1;let S=Xt(g.value,g.selectionStart,h);return t(S.value),o(null),requestAnimationFrame(()=>{let k=e.current;k!==null&&(k.focus(),k.setSelectionRange(S.caret,S.caret))}),!0},"p"),n[5]=t,n[6]=r,n[7]=e,n[8]=b):b=n[8];let v=b,u;n[9]!==v?(u=i(()=>v(),"c"),n[9]=v,n[10]=u):u=n[10];let x=u,y;return n[11]!==x||n[12]!==v||n[13]!==m||n[14]!==r?(y={close:d,commit:x,commitAt:v,move:p,refresh:m,state:r},n[11]=x,n[12]=v,n[13]=m,n[14]=r,n[15]=y):y=n[15],y},"on"),nn={column:"column",keyword:"keyword",table:"table"},on=20,rn=i(l=>{let e=(0,K.c)(17),{listboxId:t,onPick:n,state:r}=l,o=oe(),s;e[0]!==r?(s=r===null?void 0:{left:r.left,top:r.top+on},e[0]=r,e[1]=s):s=e[1];let m=s;if(r===null)return null;let a;if(e[2]!==t||e[3]!==n||e[4]!==r.active||e[5]!==r.suggestions||e[6]!==o){let f;e[8]!==t||e[9]!==n||e[10]!==r.active||e[11]!==o?(f=i((p,b)=>(0,c.jsxs)("li",{"aria-selected":b===r.active,className:ue("flex cursor-pointer items-center gap-2 px-2 py-1 text-[13px]",b===r.active?"bg-accent text-accent-foreground":"text-foreground"),"data-testid":"sql-autocomplete-item",id:`${t}-opt-${b.toString()}`,onMouseDown:i(v=>{v.preventDefault(),n(b)},"onMouseDown"),role:"option",children:[(0,c.jsx)("span",{className:"truncate font-mono",children:p.label}),p.detail!==void 0&&(0,c.jsx)("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:p.detail}),(0,c.jsx)("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:o(nn[p.kind])})]},`${p.kind}:${p.label}`),"f"),e[8]=t,e[9]=n,e[10]=r.active,e[11]=o,e[12]=f):f=e[12],a=r.suggestions.map(f),e[2]=t,e[3]=n,e[4]=r.active,e[5]=r.suggestions,e[6]=o,e[7]=a}else a=e[7];let d;return e[13]!==t||e[14]!==m||e[15]!==a?(d=(0,c.jsx)("ul",{className:"absolute z-30 max-h-56 w-72 overflow-auto rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-autocomplete",id:t,role:"listbox",style:m,children:a}),e[13]=t,e[14]=m,e[15]=a,e[16]=d):d=e[16],d},"sn"),ln=ve(we.listTables),sn=ve(we.readTablePage),an=i(l=>{let e=(0,K.c)(16),t=ke(),n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],e[0]=n):n=e[0];let[r,o]=(0,P.useState)(n),s;e[1]===Symbol.for("react.memo_cache_sentinel")?(s={},e[1]=s):s=e[1];let[m,a]=(0,P.useState)(s),d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=new Set,e[2]=d):d=e[2];let f=(0,P.useRef)(d),p,b;e[3]!==t||e[4]!==l?(p=i(()=>{let g={cancelled:!1};return ie((async()=>{try{let h=await t.query(ln,{},ye(l));g.cancelled||(o(h.map(dn)),a({}),f.current=new Set)}catch{g.cancelled||(o([]),a({}),f.current=new Set)}})()),()=>{g.cancelled=!0}},"h"),b=[t,l],e[3]=t,e[4]=l,e[5]=p,e[6]=b):(p=e[5],b=e[6]),(0,P.useEffect)(p,b);let v;e[7]!==t||e[8]!==l?(v=i(g=>{f.current.has(g)||(f.current.add(g),ie((async()=>{try{let h=await t.query(sn,{limit:1,offset:0,table:g},ye(l));a(S=>({...S,[g]:h.columns}))}catch{f.current.delete(g)}})()))},"x"),e[7]=t,e[8]=l,e[9]=v):v=e[9];let u=v,x;e[10]!==m||e[11]!==r?(x={columns:m,tables:r},e[10]=m,e[11]=r,e[12]=x):x=e[12];let y=x,w;return e[13]!==u||e[14]!==y?(w={probe:u,schema:y},e[13]=u,e[14]=y,e[15]=w):w=e[15],w},"dn"),Ae=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,cn=i(l=>{let e=new Set;Ae.lastIndex=0;let t=Ae.exec(l);for(;t!==null;)e.add(t[1]??t[2]),t=Ae.exec(l);return[...e]},"un");function dn(l){return l.name}i(dn,"mn");var un=i(l=>{let e=(0,K.c)(34),{onSubmit:t,probe:n,schema:r,setDraft:o}=l,s=(0,P.useId)(),m=(0,P.useRef)(null),a=(0,P.useRef)(null),d=(0,P.useRef)(null),f=tn(r,d,o),{close:p,commit:b,commitAt:v,move:u,refresh:x,state:y}=f,w;e[0]!==v?(w=i(I=>{v(I)},"y"),e[0]=v,e[1]=w):w=e[1];let g=w,h;e[2]!==x?(h=i(()=>{let I=d.current;I!==null&&I===document.activeElement&&x(I.value,I.selectionStart)},"m"),e[2]=x,e[3]=h):h=e[3];let S;e[4]!==x||e[5]!==r?(S=[x,r],e[4]=x,e[5]=r,e[6]=S):S=e[6],(0,P.useEffect)(h,S);let k;e[7]!==n||e[8]!==x||e[9]!==o?(k=i(I=>{let{selectionStart:B,value:W}=I.target;o(W);for(let Q of cn(W))n(Q);x(W,B)},"N"),e[7]=n,e[8]=x,e[9]=o,e[10]=k):k=e[10];let N=k,C;e[11]!==x?(C=i(I=>{let B=I.currentTarget;x(B.value,B.selectionStart)},"k"),e[11]=x,e[12]=C):C=e[12];let L=C,R;e[13]!==y||e[14]!==p||e[15]!==b||e[16]!==u||e[17]!==t?(R=i(I=>{if(y!==null){if(I.key==="ArrowDown"){I.preventDefault(),u(1);return}if(I.key==="ArrowUp"){I.preventDefault(),u(-1);return}if(I.key==="Escape"){I.preventDefault(),p();return}if((I.key==="Enter"||I.key==="Tab")&&!I.metaKey&&!I.ctrlKey&&b()){I.preventDefault();return}}(I.metaKey||I.ctrlKey)&&I.key==="Enter"&&(I.preventDefault(),t())},"T"),e[13]=y,e[14]=p,e[15]=b,e[16]=u,e[17]=t,e[18]=R):R=e[18];let E=R,q;e[19]!==p?(q=i(()=>{requestAnimationFrame(()=>{p()})},"C"),e[19]=p,e[20]=q):q=e[20];let O=q,M;e[21]===Symbol.for("react.memo_cache_sentinel")?(M=i(I=>{let{scrollLeft:B,scrollTop:W}=I.currentTarget;m.current!==null&&(m.current.scrollTop=W),a.current!==null&&(a.current.scrollTop=W,a.current.scrollLeft=B)},"_"),e[21]=M):M=e[21];let D=M,T;e[22]===Symbol.for("react.memo_cache_sentinel")?(T=i(I=>{let B=d.current;B===null||I.offset===void 0||(B.focus(),B.setSelectionRange(I.offset,I.offset+(I.length??0)))},"$"),e[22]=T):T=e[22];let _=T,A;e[23]!==N||e[24]!==O||e[25]!==E||e[26]!==L?(A={onBlur:O,onChange:N,onKeyDown:E,onScroll:D,onSelect:L},e[23]=N,e[24]=O,e[25]=E,e[26]=L,e[27]=A):A=e[27];let $;return e[28]!==y||e[29]!==p||e[30]!==s||e[31]!==g||e[32]!==A?($={autocompleteState:y,closeAutocomplete:p,handlers:A,listboxId:s,onPickSuggestion:g,editorRef:d,gutterRef:m,overlayRef:a,revealDiagnostic:_},e[28]=y,e[29]=p,e[30]=s,e[31]=g,e[32]=A,e[33]=$):$=e[33],$},"fn"),mn="lunora-studio-sql-tabs",hn="lunora-studio-sql-active-tab",Be=12,Se=i((l="",e="")=>({activeId:null,id:Me("tab"),name:e,sql:l}),"ve"),fn=i(()=>Oe(hn,""),"bn"),pn=i(l=>{let e=(0,K.c)(16),[t,n]=Ce(mn),[r,o]=fn(),[s]=(0,P.useState)(l),m,a;e[0]!==s||e[1]!==n||e[2]!==t.length?(m=i(()=>{t.length===0&&n([s])},"d"),a=[s,n,t.length],e[0]=s,e[1]=n,e[2]=t.length,e[3]=m,e[4]=a):(m=e[3],a=e[4]),(0,P.useEffect)(m,a);let d;e[5]!==s||e[6]!==t?(d=t.length===0?[s]:t,e[5]=s,e[6]=t,e[7]=d):d=e[7];let f=d,p;e[8]!==r||e[9]!==f?(p=f.some(u=>u.id===r)?r:f[0]?.id??"",e[8]=r,e[9]=f,e[10]=p):p=e[10];let b=p,v;return e[11]!==b||e[12]!==o||e[13]!==n||e[14]!==f?(v={activeId:b,setActiveId:o,setTabs:n,tabs:f},e[11]=b,e[12]=o,e[13]=n,e[14]=f,e[15]=v):v=e[15],v},"gn"),at=i(l=>l.activeId===null&&l.sql.trim()!=="","Ge"),bn=i((l,e)=>[...l,e].slice(-Be),"xn"),gn=i((l,e,t)=>{let n=l.findIndex(o=>o.id===e);if(n===-1)return{activeId:l[0]?.id??"",tabs:[...l]};let r=l.filter(o=>o.id!==e);if(r.length===0){let o=t();return{activeId:o.id,tabs:[o]}}return{activeId:r[Math.min(n,r.length-1)].id,tabs:r}},"vn"),xn=i((l,e)=>{let t=l.filter(n=>n.id===e);return t.length===0?{activeId:l[0]?.id??"",tabs:[...l]}:{activeId:e,tabs:t}},"yn"),vn=i((l,e,t)=>{let n=l.findIndex(o=>o.id===e);if(n===-1)return{activeId:t,tabs:[...l]};let r=l.slice(0,n+1);return{activeId:r.some(o=>o.id===t)?t:e,tabs:r}},"wn"),yn=i(l=>{let e=l();return{activeId:e.id,tabs:[e]}},"Sn"),wn=i((l,e,t)=>{if(l==="others")return e.filter(n=>n.id!==t);if(l==="right"){let n=e.findIndex(r=>r.id===t);return n===-1?[]:e.slice(n+1)}return[...e]},"Nn"),nt={error:null,pane:"results",result:null,running:!1},Sn=i(l=>{let e=(0,K.c)(66),{activeId:t,setActiveId:n,setTabs:r,tabs:o}=pn(l),s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];let[m,a]=(0,P.useState)(s),[d,f]=(0,P.useState)(null),[p,b]=(0,P.useState)(null),v;e[1]!==t||e[2]!==o?(v=o.find(F=>F.id===t)??o[0]??Se(),e[1]=t,e[2]=o,e[3]=v):v=e[3];let u=v,x=m[u.id]??nt,y;e[4]!==u.id||e[5]!==r?(y=i(F=>{r(j=>j.map(U=>U.id===u.id?{...U,...F}:U))},"v"),e[4]=u.id,e[5]=r,e[6]=y):y=e[6];let w=y,g;e[7]!==u.id?(g=i(F=>{a(j=>{let U=j[u.id]??nt;return{...j,[u.id]:{...U,...F}}})},"b"),e[7]=u.id,e[8]=g):g=e[8];let h=g,S;e[9]!==n||e[10]!==r||e[11]!==o.length?(S=i(()=>{if(o.length>=Be)return;let F=Se();r(j=>bn(j,F)),n(F.id)},"w"),e[9]=n,e[10]=r,e[11]=o.length,e[12]=S):S=e[12];let k=S,N;e[13]!==n||e[14]!==r?(N=i(F=>{f(null),b(null),r(F.tabs),n(F.activeId);let j=new Set(F.tabs.map(Nn));a(U=>Object.fromEntries(Object.entries(U).filter(ae=>{let[xe]=ae;return j.has(xe)})))},"S"),e[13]=n,e[14]=r,e[15]=N):N=e[15];let C=N,L;e[16]!==C||e[17]!==o?(L=i(F=>{C(gn(o,F,Se))},"R"),e[16]=C,e[17]=o,e[18]=L):L=e[18];let R=L,E;e[19]!==t||e[20]!==C||e[21]!==o?(E=i((F,j)=>{C(F==="others"?xn(o,j):F==="right"?vn(o,j,t):yn(Se))},"I"),e[19]=t,e[20]=C,e[21]=o,e[22]=E):E=e[22];let q=E,O;e[23]!==q||e[24]!==d||e[25]!==o?(O=i(F=>{d!==null&&(wn(F,o,d.id).some(kn)?b(F):q(F,d.id))},"L"),e[23]=q,e[24]=d,e[25]=o,e[26]=O):O=e[26];let M=O,D;e[27]===Symbol.for("react.memo_cache_sentinel")?(D=i((F,j)=>{j.preventDefault(),b(null),f({id:F,x:j.clientX,y:j.clientY})},"O"),e[27]=D):D=e[27];let T=D,_;e[28]===Symbol.for("react.memo_cache_sentinel")?(_=i(()=>{f(null),b(null)},"E"),e[28]=_):_=e[28];let A=_,$;e[29]===Symbol.for("react.memo_cache_sentinel")?($=i(F=>{F.preventDefault(),f(null),b(null)},"D"),e[29]=$):$=e[29];let I=$,B;e[30]!==M?(B=i(()=>{M("others")},"B"),e[30]=M,e[31]=B):B=e[31];let W=B,Q;e[32]!==M?(Q=i(()=>{M("right")},"P"),e[32]=M,e[33]=Q):Q=e[33];let Y=Q,H;e[34]!==M?(H=i(()=>{M("all")},"Q"),e[34]=M,e[35]=H):H=e[35];let G=H,J;e[36]!==q||e[37]!==p||e[38]!==d?(J=i(()=>{d!==null&&p!==null&&q(p,d.id),b(null)},"J"),e[36]=q,e[37]=p,e[38]=d,e[39]=J):J=e[39];let z=J,V;e[40]===Symbol.for("react.memo_cache_sentinel")?(V=i(()=>{b(null)},"G"),e[40]=V):V=e[40];let re=V,X;e[41]!==d?(X=d===null?void 0:{left:d.x,top:d.y},e[41]=d,e[42]=X):X=e[42];let Z=X,ee;e[43]!==r?(ee=i(F=>{r(j=>j.map(U=>U.activeId===F?{...U,activeId:null}:U))},"Z"),e[43]=r,e[44]=ee):ee=e[44];let te=ee,ne;e[45]!==r?(ne=i((F,j)=>{r(U=>U.map(ae=>ae.id===F?{...ae,name:j}:ae))},"te"),e[45]=r,e[46]=ne):ne=e[46];let le=ne,ce;return e[47]!==u||e[48]!==t||e[49]!==k||e[50]!==R||e[51]!==z||e[52]!==G||e[53]!==W||e[54]!==Y||e[55]!==x||e[56]!==h||e[57]!==w||e[58]!==p||e[59]!==le||e[60]!==n||e[61]!==d||e[62]!==Z||e[63]!==o||e[64]!==te?(ce={activeTab:u,activeTabId:t,addEditorTab:k,cancelBulk:re,closeEditorTab:R,closeTabMenu:A,confirmBulk:z,menuStyle:Z,onBackdropContextMenu:I,onCloseAll:G,onCloseOthers:W,onCloseToRight:Y,openTabMenu:T,output:x,patchActiveOutput:h,patchActiveTab:w,pendingBulk:p,renameTab:le,setActiveTabId:n,tabMenu:d,tabs:o,unlinkQuery:te},e[47]=u,e[48]=t,e[49]=k,e[50]=R,e[51]=z,e[52]=G,e[53]=W,e[54]=Y,e[55]=x,e[56]=h,e[57]=w,e[58]=p,e[59]=le,e[60]=n,e[61]=d,e[62]=Z,e[63]=o,e[64]=te,e[65]=ce):ce=e[65],ce},"kn");function Nn(l){return l.id}i(Nn,"Cn");function kn(l){return at(l)}i(kn,"$n");var Cn="lunora-studio-sql-queries",qn="lunora-studio-sql-history",Tn=25,In=i(l=>{let e=(0,K.c)(33),{loadIntoActiveTab:t,unlinkQuery:n}=l,r=oe(),[o,s]=Ce(Cn),[m,a]=Ce(qn),[d,f]=(0,P.useState)(""),p=(0,P.useRef)(null),b;e[0]!==a?(b=i(T=>{a(_=>_[0]?.sql===T?_:[{at:Date.now(),sql:T},..._.filter(A=>A.sql!==T)].slice(0,Tn))},"p"),e[0]=a,e[1]=b):b=e[1];let v=b,u;e[2]!==t||e[3]!==s||e[4]!==r?(u=i(()=>{let T={id:Me("q"),name:r("Untitled query"),sql:""};s(_=>[T,..._]),t("",T.id)},"c"),e[2]=t,e[3]=s,e[4]=r,e[5]=u):u=e[5];let x=u,y;e[6]!==t||e[7]!==o?(y=i(T=>{let _=o.find(A=>A.id===T);_!==void 0&&(t(_.sql,T),p.current?.querySelector(`[data-testid="sql-query-${T}"]`)?.scrollIntoView({block:"nearest"}))},"v"),e[6]=t,e[7]=o,e[8]=y):y=e[8];let w=y,g;e[9]!==s||e[10]!==n?(g=i(T=>{s(_=>_.filter(A=>A.id!==T)),n(T)},"b"),e[9]=s,e[10]=n,e[11]=g):g=e[11];let h=g,S;e[12]!==t?(S=i(T=>{t(T.currentTarget.dataset.sql??"",null)},"w"),e[12]=t,e[13]=S):S=e[13];let k=S,N;e[14]!==t?(N=i(T=>{t(T.currentTarget.dataset.sql??"",null)},"S"),e[14]=t,e[15]=N):N=e[15];let C=N,L;e[16]!==a?(L=i(()=>{a([])},"R"),e[16]=a,e[17]=L):L=e[17];let R=L,E;e[18]===Symbol.for("react.memo_cache_sentinel")?(E=i(T=>{f(T.target.value)},"I"),e[18]=E):E=e[18];let q=E,O;e[19]!==s?(O=i((T,_)=>{s(A=>A.map($=>$.id===T?{...$,sql:_}:$))},"L"),e[19]=s,e[20]=O):O=e[20];let M=O,D;return e[21]!==R||e[22]!==h||e[23]!==m||e[24]!==C||e[25]!==k||e[26]!==x||e[27]!==o||e[28]!==v||e[29]!==d||e[30]!==w||e[31]!==M?(D={clearHistory:R,deleteQuery:h,history:m,listRef:p,loadFromHistory:C,loadTemplate:k,newQuery:x,onSearchChange:q,queries:o,recordHistory:v,search:d,selectQuery:w,updateQuerySql:M},e[21]=R,e[22]=h,e[23]=m,e[24]=C,e[25]=k,e[26]=x,e[27]=o,e[28]=v,e[29]=d,e[30]=w,e[31]=M,e[32]=D):D=e[32],D},"In"),it="p-3 font-mono text-xs leading-5 whitespace-pre-wrap break-words",Rn=i((l,e)=>{let t=[];for(let r of l){if(r.offset===void 0||r.length===void 0||r.length<=0)continue;let o=Math.max(0,Math.min(r.offset,e)),s=Math.max(o,Math.min(r.offset+r.length,e));o!==s&&t.push({end:s,severity:r.severity,start:o})}t.sort((r,o)=>r.start-o.start);let n=[];for(let r of t)r.start>=(n.at(-1)?.end??0)&&n.push(r);return n},"En"),Ln=i(l=>l==="unsafe-response"?"The model returned a statement that is not read-only, so it was discarded.":l==="empty-response"?"The model returned nothing usable.":"The model could not be reached.","Ln"),En=i(l=>{let e=(0,K.c)(51),{assistant:t,failed:n,onGenerated:r}=l,o=oe(),[s,m]=(0,P.useState)("");if(t.unavailable)return null;let a;e[0]!==t?(a=t.pending("sql"),e[0]=t,e[1]=a):a=e[1];let d=a,f;if(e[2]!==t||e[3]!==n||e[4]!==r||e[5]!==d||e[6]!==s||e[7]!==o){let p=t.reason("sql"),b;e[9]!==t||e[10]!==n||e[11]!==r||e[12]!==s?(b=i(q=>{let O=s.trim();O===""&&!q||ie((async()=>{let M=await t.generate(O===""?"fix the failing statement":O,q?n:void 0);M!==void 0&&r(M)})())},"p"),e[9]=t,e[10]=n,e[11]=r,e[12]=s,e[13]=b):b=e[13];let v=b,u;e[14]!==o?(u=o("Describe the query you want"),e[14]=o,e[15]=u):u=e[15];let x;e[16]===Symbol.for("react.memo_cache_sentinel")?(x=i(q=>{m(q.target.value)},"g"),e[16]=x):x=e[16];let y;e[17]!==v?(y=i(q=>{q.key==="Enter"&&(q.preventDefault(),v(!1))},"v"),e[17]=v,e[18]=y):y=e[18];let w;e[19]!==o?(w=o("Describe the query you want"),e[19]=o,e[20]=w):w=e[20];let g;e[21]!==d||e[22]!==s||e[23]!==u||e[24]!==y||e[25]!==w?(g=(0,c.jsx)(Fe,{"aria-label":u,className:"h-7 flex-1 text-xs","data-testid":"sql-assistant-prompt",disabled:d,onChange:x,onKeyDown:y,placeholder:w,value:s}),e[21]=d,e[22]=s,e[23]=u,e[24]=y,e[25]=w,e[26]=g):g=e[26];let h=d&&"opacity-60",S;e[27]!==h?(S=ue("rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",h),e[27]=h,e[28]=S):S=e[28];let k;e[29]!==d||e[30]!==s?(k=d||s.trim()==="",e[29]=d,e[30]=s,e[31]=k):k=e[31];let N;e[32]!==v?(N=i(()=>{v(!1)},"S"),e[32]=v,e[33]=N):N=e[33];let C;e[34]!==d||e[35]!==o?(C=o(d?"Thinking\u2026":"Draft SQL"),e[34]=d,e[35]=o,e[36]=C):C=e[36];let L;e[37]!==S||e[38]!==k||e[39]!==N||e[40]!==C?(L=(0,c.jsx)("button",{className:S,"data-testid":"sql-assistant-generate",disabled:k,onClick:N,type:"button",children:C}),e[37]=S,e[38]=k,e[39]=N,e[40]=C,e[41]=L):L=e[41];let R;e[42]!==n||e[43]!==d||e[44]!==v||e[45]!==o?(R=n!==void 0&&(0,c.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:i(()=>{v(!0)},"onClick"),type:"button",children:o("Fix this")}),e[42]=n,e[43]=d,e[44]=v,e[45]=o,e[46]=R):R=e[46];let E;e[47]!==L||e[48]!==R||e[49]!==g?(E=(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[g,L,R]}),e[47]=L,e[48]=R,e[49]=g,e[50]=E):E=e[50],f=(0,c.jsxs)("div",{className:"flex flex-col gap-1 border-b border-border px-3 py-2","data-testid":"sql-assistant",children:[E,p!==void 0&&(0,c.jsx)("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-assistant-reason",role:"status",children:Ln(p)})]}),e[2]=t,e[3]=n,e[4]=r,e[5]=d,e[6]=s,e[7]=o,e[8]=f}else f=e[8];return f},"_n"),_n=i(l=>{let e=(0,K.c)(8),{diagnostics:t,draft:n,scrollRef:r}=l,o,s;if(e[0]!==t||e[1]!==n){s=Symbol.for("react.early_return_sentinel");e:{let d=Rn(t,n.length);if(d.length===0){s=null;break e}o=[];let f=0;for(let[p,b]of d.entries())b.start>f&&o.push(n.slice(f,b.start)),o.push((0,c.jsx)("span",{className:ue("decoration-wavy underline underline-offset-4",b.severity==="error"?"decoration-destructive":"decoration-amber-500"),children:n.slice(b.start,b.end)},`${b.start.toString()}-${p.toString()}`)),f=b.end;o.push(n.slice(f))}e[0]=t,e[1]=n,e[2]=o,e[3]=s}else o=e[2],s=e[3];if(s!==Symbol.for("react.early_return_sentinel"))return s;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=ue("pointer-events-none absolute inset-0 overflow-hidden text-transparent",it),e[4]=m):m=e[4];let a;return e[5]!==o||e[6]!==r?(a=(0,c.jsx)("div",{"aria-hidden":"true",className:m,"data-testid":"sql-diagnostics-overlay",ref:r,children:o}),e[5]=o,e[6]=r,e[7]=a):a=e[7],a},"On"),On={gate:"read-only",plan:"plan",schema:"schema",syntax:"syntax"},Mn=i(l=>{let e=(0,K.c)(10),{diagnostics:t,onSelect:n}=l,r=oe();if(t.length===0)return null;let o;e[0]!==r?(o=r("SQL problems"),e[0]=r,e[1]=o):o=e[1];let s;if(e[2]!==t||e[3]!==n){let a;e[5]!==n?(a=i((d,f)=>(0,c.jsx)("li",{children:(0,c.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:i(()=>{n(d)},"onClick"),type:"button",children:[(0,c.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:On[d.source]}),(0,c.jsx)("span",{className:"min-w-0 text-muted-foreground",children:d.message})]})},`${d.source}-${(d.offset??f).toString()}-${f.toString()}`),"a"),e[5]=n,e[6]=a):a=e[6],s=t.map(a),e[2]=t,e[3]=n,e[4]=s}else s=e[4];let m;return e[7]!==o||e[8]!==s?(m=(0,c.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:s}),e[7]=o,e[8]=s,e[9]=m):m=e[9],m},"Dn"),Dn={minWidth:"2.75rem",paddingInline:"0.5rem"},An=i(l=>{let e=(0,K.c)(64),{assistant:t,autocomplete:n,diagnostics:r,draft:o,failed:s,handlers:m,editorRef:a,gutterRef:d,listboxId:f,onGenerated:p,onPickSuggestion:b,onRevealDiagnostic:v,overlayRef:u}=l,x=oe(),y,w,g,h,S,k,N,C;if(e[0]!==t||e[1]!==o||e[2]!==s||e[3]!==d||e[4]!==p){let B=o.split(`
5
+ `).length;N="flex min-h-0 min-w-0 flex-1 flex-col",e[13]!==t||e[14]!==s||e[15]!==p?(C=(0,c.jsx)(En,{assistant:t,failed:s,onGenerated:p}),e[13]=t,e[14]=s,e[15]=p,e[16]=C):C=e[16],k="flex min-h-0 min-w-0 flex-1",y="true",w="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,h=Dn,S=Array.from({length:B},$n),e[0]=t,e[1]=o,e[2]=s,e[3]=d,e[4]=p,e[5]=y,e[6]=w,e[7]=g,e[8]=h,e[9]=S,e[10]=k,e[11]=N,e[12]=C}else y=e[5],w=e[6],g=e[7],h=e[8],S=e[9],k=e[10],N=e[11],C=e[12];let L;e[17]!==y||e[18]!==w||e[19]!==g||e[20]!==h||e[21]!==S?(L=(0,c.jsx)("div",{"aria-hidden":y,className:w,ref:g,style:h,children:S}),e[17]=y,e[18]=w,e[19]=g,e[20]=h,e[21]=S,e[22]=L):L=e[22];let R;e[23]!==r||e[24]!==o||e[25]!==u?(R=(0,c.jsx)(_n,{diagnostics:r,draft:o,scrollRef:u}),e[23]=r,e[24]=o,e[25]=u,e[26]=R):R=e[26];let E;e[27]!==n||e[28]!==f?(E=n===null?void 0:`${f}-opt-${n.active.toString()}`,e[27]=n,e[28]=f,e[29]=E):E=e[29];let q=n===null?void 0:f,O=n!==null,M;e[30]!==x?(M=x("SQL query"),e[30]=x,e[31]=M):M=e[31];let D;e[32]!==o||e[33]!==a||e[34]!==m.onBlur||e[35]!==m.onChange||e[36]!==m.onKeyDown||e[37]!==m.onScroll||e[38]!==m.onSelect||e[39]!==E||e[40]!==q||e[41]!==O||e[42]!==M?(D=(0,c.jsx)("textarea",{"aria-activedescendant":E,"aria-autocomplete":"list","aria-controls":q,"aria-expanded":O,"aria-label":M,className:`relative size-full resize-none bg-transparent outline-none ${it}`,"data-testid":"sql-input",onBlur:m.onBlur,onChange:m.onChange,onKeyDown:m.onKeyDown,onScroll:m.onScroll,onSelect:m.onSelect,placeholder:"SELECT * FROM \u2026",ref:a,role:"combobox",spellCheck:!1,value:o}),e[32]=o,e[33]=a,e[34]=m.onBlur,e[35]=m.onChange,e[36]=m.onKeyDown,e[37]=m.onScroll,e[38]=m.onSelect,e[39]=E,e[40]=q,e[41]=O,e[42]=M,e[43]=D):D=e[43];let T;e[44]!==n||e[45]!==f||e[46]!==b?(T=(0,c.jsx)(rn,{listboxId:f,onPick:b,state:n}),e[44]=n,e[45]=f,e[46]=b,e[47]=T):T=e[47];let _;e[48]!==R||e[49]!==D||e[50]!==T?(_=(0,c.jsxs)("div",{className:"relative min-w-0 flex-1 bg-background",children:[R,D,T]}),e[48]=R,e[49]=D,e[50]=T,e[51]=_):_=e[51];let A;e[52]!==_||e[53]!==k||e[54]!==L?(A=(0,c.jsxs)("div",{className:k,children:[L,_]}),e[52]=_,e[53]=k,e[54]=L,e[55]=A):A=e[55];let $;e[56]!==r||e[57]!==v?($=(0,c.jsx)(Mn,{diagnostics:r,onSelect:v}),e[56]=r,e[57]=v,e[58]=$):$=e[58];let I;return e[59]!==A||e[60]!==$||e[61]!==N||e[62]!==C?(I=(0,c.jsxs)("div",{className:N,children:[C,A,$]}),e[59]=A,e[60]=$,e[61]=N,e[62]=C,e[63]=I):I=e[63],I},"Bn");function $n(l,e){return(0,c.jsx)("div",{children:e+1},e)}i($n,"zn");var ct=[{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;"}],Bn=i(l=>{let e=(0,K.c)(29),{active:t,onDelete:n,onSelect:r,query:o}=l,s=oe(),m;e[0]!==r||e[1]!==o.id?(m=i(()=>{r(o.id)},"d"),e[0]=r,e[1]=o.id,e[2]=m):m=e[2];let a=m,d;e[3]!==n||e[4]!==o.id?(d=i(N=>{N.stopPropagation(),n(o.id)},"i"),e[3]=n,e[4]=o.id,e[5]=d):d=e[5];let f=d,p=t?"bg-sidebar-accent font-medium text-foreground":"text-muted-foreground",b;e[6]!==p?(b=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",p),e[6]=p,e[7]=b):b=e[7];let v=`sql-query-${o.id}`,u;e[8]===Symbol.for("react.memo_cache_sentinel")?(u=(0,c.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,c.jsx)("path",{d:"M4 6h16M4 12h10M4 18h7"})}),e[8]=u):u=e[8];let x;e[9]!==o.name?(x=(0,c.jsx)("span",{className:"truncate",children:o.name}),e[9]=o.name,e[10]=x):x=e[10];let y;e[11]!==t||e[12]!==a||e[13]!==b||e[14]!==v||e[15]!==x?(y=(0,c.jsxs)("button",{"aria-pressed":t,className:b,"data-testid":v,onClick:a,type:"button",children:[u,x]}),e[11]=t,e[12]=a,e[13]=b,e[14]=v,e[15]=x,e[16]=y):y=e[16];let w;e[17]!==s?(w=s("Delete query"),e[17]=s,e[18]=w):w=e[18];let g;e[19]!==s?(g=s("Delete query"),e[19]=s,e[20]=g):g=e[20];let h;e[21]===Symbol.for("react.memo_cache_sentinel")?(h=(0,c.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,c.jsx)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[21]=h):h=e[21];let S;e[22]!==f||e[23]!==g||e[24]!==w?(S=(0,c.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:f,title:g,type:"button",children:h}),e[22]=f,e[23]=g,e[24]=w,e[25]=S):S=e[25];let k;return e[26]!==S||e[27]!==y?(k=(0,c.jsxs)("li",{className:"group/q flex items-center",children:[y,S]}),e[26]=S,e[27]=y,e[28]=k):k=e[28],k},"Hn"),zn=i((l,e)=>{let t=e.trim().toLowerCase();return t===""?[...l]:l.filter(n=>n.name.toLowerCase().includes(t))},"Pn"),Fn=i(l=>{let e=(0,K.c)(60),{activeId:t,history:n,listRef:r,onClearHistory:o,onDelete:s,onLoadHistory:m,onLoadTemplate:a,onNew:d,onSearchChange:f,onSelect:p,queries:b,search:v}=l,u=oe(),x,y,w,g;if(e[0]!==t||e[1]!==r||e[2]!==s||e[3]!==d||e[4]!==f||e[5]!==p||e[6]!==b||e[7]!==v||e[8]!==u){let q=zn(b,v);y="flex h-full w-64 shrink-0 flex-col border-e border-border bg-sidebar";let O;e[13]!==u?(O=u("Search queries\u2026"),e[13]=u,e[14]=O):O=e[14];let M;e[15]!==f||e[16]!==v||e[17]!==O?(M=(0,c.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:f,placeholder:O,type:"text",value:v}),e[15]=f,e[16]=v,e[17]=O,e[18]=M):M=e[18];let D;e[19]!==u?(D=u("New query"),e[19]=u,e[20]=D):D=e[20];let T;e[21]!==u?(T=u("New query"),e[21]=u,e[22]=T):T=e[22];let _;e[23]===Symbol.for("react.memo_cache_sentinel")?(_=(0,c.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,c.jsx)("path",{d:"M12 5v14M5 12h14"})}),e[23]=_):_=e[23];let A;e[24]!==d||e[25]!==D||e[26]!==T?(A=(0,c.jsx)("button",{"aria-label":D,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:T,type:"button",children:_}),e[24]=d,e[25]=D,e[26]=T,e[27]=A):A=e[27],e[28]!==A||e[29]!==M?(w=(0,c.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border p-2",children:[M,A]}),e[28]=A,e[29]=M,e[30]=w):w=e[30],x="flex flex-1 flex-col gap-4 overflow-y-auto p-2";let $;e[31]!==u?($=u("Private"),e[31]=u,e[32]=$):$=e[32];let I;e[33]!==$?(I=(0,c.jsx)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:$}),e[33]=$,e[34]=I):I=e[34],g=(0,c.jsxs)("div",{children:[I,q.length===0?(0,c.jsx)("p",{className:"px-1 py-2 text-xs text-muted-foreground","data-testid":"sql-private-empty",children:u("No saved queries yet \u2014 they save to this browser as you type.")}):(0,c.jsx)("ul",{className:"flex flex-col gap-px","data-testid":"sql-private",ref:r,children:q.map(B=>(0,c.jsx)(Bn,{active:t===B.id,onDelete:s,onSelect:p,query:B},B.id))})]}),e[0]=t,e[1]=r,e[2]=s,e[3]=d,e[4]=f,e[5]=p,e[6]=b,e[7]=v,e[8]=u,e[9]=x,e[10]=y,e[11]=w,e[12]=g}else x=e[9],y=e[10],w=e[11],g=e[12];let h;e[35]!==u?(h=u("Reference"),e[35]=u,e[36]=h):h=e[36];let S;e[37]!==h?(S=(0,c.jsx)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h}),e[37]=h,e[38]=S):S=e[38];let k;e[39]!==a?(k=ct.map(q=>(0,c.jsx)("li",{children:(0,c.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":q.sql,onClick:a,type:"button",children:[(0,c.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,c.jsx)("path",{d:"M7 4h7l4 4v12H7zM14 4v4h4"})}),q.label]})},q.label)),e[39]=a,e[40]=k):k=e[40];let N;e[41]!==k?(N=(0,c.jsx)("ul",{className:"flex flex-col gap-px",children:k}),e[41]=k,e[42]=N):N=e[42];let C;e[43]!==S||e[44]!==N?(C=(0,c.jsxs)("div",{children:[S,N]}),e[43]=S,e[44]=N,e[45]=C):C=e[45];let L;e[46]!==n||e[47]!==o||e[48]!==m||e[49]!==u?(L=n.length>0&&(0,c.jsxs)("div",{children:[(0,c.jsxs)("div",{className:"flex items-center justify-between px-1 pb-1",children:[(0,c.jsx)("p",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:u("History")}),(0,c.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:u("Clear history")})]}),(0,c.jsx)("ul",{className:"flex flex-col gap-px","data-testid":"sql-history",children:n.map(q=>(0,c.jsx)("li",{children:(0,c.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":q.sql,"data-testid":"sql-history-item",onClick:m,title:q.sql,type:"button",children:[(0,c.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,c.jsx)("path",{d:"M12 8v4l3 2M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18Z"})}),(0,c.jsx)("span",{className:"truncate font-mono",children:q.sql})]})},`${q.at.toString()}:${q.sql}`))})]}),e[46]=n,e[47]=o,e[48]=m,e[49]=u,e[50]=L):L=e[50];let R;e[51]!==x||e[52]!==L||e[53]!==g||e[54]!==C?(R=(0,c.jsxs)("div",{className:x,children:[g,C,L]}),e[51]=x,e[52]=L,e[53]=g,e[54]=C,e[55]=R):R=e[55];let E;return e[56]!==R||e[57]!==y||e[58]!==w?(E=(0,c.jsxs)("aside",{className:y,children:[w,R]}),e[56]=R,e[57]=y,e[58]=w,e[59]=E):E=e[59],E},"Fn"),Pn=i(l=>{let e=(0,K.c)(19),{result:t}=l,n=oe();if(t.columns.length===0){let d;e[0]!==t.rowCount||e[1]!==n?(d=n("{count} rows",{count:t.rowCount}),e[0]=t.rowCount,e[1]=n,e[2]=d):d=e[2];let f;return e[3]!==d?(f=(0,c.jsx)("p",{className:"p-4 text-sm text-muted-foreground",children:d}),e[3]=d,e[4]=f):f=e[4],f}let r;e[5]!==t.columns?(r=t.columns.map(Qn),e[5]=t.columns,e[6]=r):r=e[6];let o;e[7]!==r?(o=(0,c.jsx)(je,{className:"sticky top-0 z-10 bg-muted",children:(0,c.jsx)(De,{children:r})}),e[7]=r,e[8]=o):o=e[8];let s;if(e[9]!==t.columns||e[10]!==t.rows){let d;e[12]!==t.columns?(d=i((f,p)=>(0,c.jsx)(De,{"data-testid":"sql-row",children:t.columns.map(b=>(0,c.jsx)(Ue,{className:"max-w-md truncate font-mono text-xs",children:(0,c.jsx)(Ve,{value:f[b]})},b))},p),"i"),e[12]=t.columns,e[13]=d):d=e[13],s=t.rows.map(d),e[9]=t.columns,e[10]=t.rows,e[11]=s}else s=e[11];let m;e[14]!==s?(m=(0,c.jsx)(Ke,{children:s}),e[14]=s,e[15]=m):m=e[15];let a;return e[16]!==o||e[17]!==m?(a=(0,c.jsxs)(He,{"data-testid":"sql-rows",children:[o,m]}),e[16]=o,e[17]=m,e[18]=a):a=e[18],a},"Qn");function Qn(l){return(0,c.jsx)(Ye,{children:l},l)}i(Qn,"jn");var Te=i(l=>`border-b-2 px-3 py-2 text-sm outline-none transition-colors ${l?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,"Ne"),Wn=i(l=>{let e=(0,K.c)(92),{assistant:t,chart:n,className:r,error:o,onFormat:s,onInferChart:m,onRun:a,onShardKeyChange:d,onShowChart:f,onShowExplain:p,onShowResults:b,onToggleSplit:v,pane:u,result:x,running:y,shardKey:w,splitView:g}=l,h=oe(),S=u==="results",k;e[0]!==S?(k=Te(S),e[0]=S,e[1]=k):k=e[1];let N;e[2]!==h?(N=h("Results"),e[2]=h,e[3]=N):N=e[3];let C;e[4]!==b||e[5]!==k||e[6]!==N?(C=(0,c.jsx)("button",{className:k,"data-testid":"sql-tab-results",onClick:b,type:"button",children:N}),e[4]=b,e[5]=k,e[6]=N,e[7]=C):C=e[7];let L=u==="chart",R;e[8]!==L?(R=Te(L),e[8]=L,e[9]=R):R=e[9];let E;e[10]!==h?(E=h("Chart"),e[10]=h,e[11]=E):E=e[11];let q;e[12]!==f||e[13]!==R||e[14]!==E?(q=(0,c.jsx)("button",{className:R,"data-testid":"sql-tab-chart",onClick:f,type:"button",children:E}),e[12]=f,e[13]=R,e[14]=E,e[15]=q):q=e[15];let O;e[16]!==t||e[17]!==m||e[18]!==u||e[19]!==x||e[20]!==h?(O=!t.unavailable&&u==="chart"&&x!==null&&(0,c.jsx)("button",{className:Te(!1),"data-testid":"sql-infer-chart",disabled:t.pending("chart"),onClick:m,type:"button",children:t.pending("chart")?h("Thinking\u2026"):h("Suggest chart")}),e[16]=t,e[17]=m,e[18]=u,e[19]=x,e[20]=h,e[21]=O):O=e[21];let M=u==="explain",D;e[22]!==M?(D=Te(M),e[22]=M,e[23]=D):D=e[23];let T;e[24]!==h?(T=h("Explain"),e[24]=h,e[25]=T):T=e[25];let _;e[26]!==p||e[27]!==D||e[28]!==T?(_=(0,c.jsx)("button",{className:D,"data-testid":"sql-tab-explain",onClick:p,type:"button",children:T}),e[26]=p,e[27]=D,e[28]=T,e[29]=_):_=e[29];let A;e[30]!==h?(A=h("Split editor and results"),e[30]=h,e[31]=A):A=e[31];let $=`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 ${g?"bg-accent text-foreground":"text-muted-foreground"}`,I;e[32]!==h?(I=h("Split editor and results"),e[32]=h,e[33]=I):I=e[33];let B;e[34]===Symbol.for("react.memo_cache_sentinel")?(B=(0,c.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,c.jsx)("rect",{height:"16",rx:"2",width:"18",x:"3",y:"4"}),(0,c.jsx)("path",{d:"M12 4v16"})]}),e[34]=B):B=e[34];let W;e[35]!==v||e[36]!==g||e[37]!==A||e[38]!==$||e[39]!==I?(W=(0,c.jsx)("button",{"aria-label":A,"aria-pressed":g,className:$,"data-testid":"sql-split-toggle",onClick:v,title:I,type:"button",children:B}),e[35]=v,e[36]=g,e[37]=A,e[38]=$,e[39]=I,e[40]=W):W=e[40];let Q;e[41]!==x?(Q=x!==null&&x.columns.length>0&&(0,c.jsx)(Xe,{columns:x.columns,name:"query-result",rows:x.rows}),e[41]=x,e[42]=Q):Q=e[42];let Y;e[43]!==h?(Y=h("Format"),e[43]=h,e[44]=Y):Y=e[44];let H;e[45]!==s||e[46]!==y||e[47]!==Y?(H=(0,c.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:y,onClick:s,type:"button",children:Y}),e[45]=s,e[46]=y,e[47]=Y,e[48]=H):H=e[48];let G;e[49]!==d||e[50]!==w?(G=(0,c.jsx)(Qe,{onChange:d,testId:"sql-shard-input",value:w}),e[49]=d,e[50]=w,e[51]=G):G=e[51];let J;e[52]!==y||e[53]!==h?(J=h(y?"Running\u2026":"Run"),e[52]=y,e[53]=h,e[54]=J):J=e[54];let z;e[55]===Symbol.for("react.memo_cache_sentinel")?(z=(0,c.jsx)("kbd",{className:"rounded border border-primary-foreground/30 px-1 font-sans text-[10px]",children:"\u2318\u21B5"}),e[55]=z):z=e[55];let V;e[56]!==a||e[57]!==y||e[58]!==J?(V=(0,c.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:y,onClick:a,type:"button",children:[J,z]}),e[56]=a,e[57]=y,e[58]=J,e[59]=V):V=e[59];let re;e[60]!==W||e[61]!==Q||e[62]!==H||e[63]!==G||e[64]!==V?(re=(0,c.jsxs)("div",{className:"ms-auto flex items-center gap-2",children:[W,Q,H,G,V]}),e[60]=W,e[61]=Q,e[62]=H,e[63]=G,e[64]=V,e[65]=re):re=e[65];let X;e[66]!==_||e[67]!==re||e[68]!==C||e[69]!==q||e[70]!==O?(X=(0,c.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pe-2",children:[C,q,O,_,re]}),e[66]=_,e[67]=re,e[68]=C,e[69]=q,e[70]=O,e[71]=X):X=e[71];let Z;e[72]!==o?(Z=o!==null&&(0,c.jsx)(We,{className:"m-3 font-mono text-xs",testId:"sql-error",variant:"destructive",children:o}),e[72]=o,e[73]=Z):Z=e[73];let ee;e[74]!==o||e[75]!==x||e[76]!==h?(ee=o===null&&x===null&&(0,c.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-empty",children:h("Click Run to execute your query.")}),e[74]=o,e[75]=x,e[76]=h,e[77]=ee):ee=e[77];let te;e[78]!==n||e[79]!==o||e[80]!==u||e[81]!==x||e[82]!==h?(te=o===null&&x!==null&&(0,c.jsxs)("div",{"data-testid":"sql-result",children:[u==="chart"?(0,c.jsx)(Ze,{axes:n,result:x}):(0,c.jsx)(Pn,{result:x}),(0,c.jsx)("p",{className:"border-t border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"sql-count",children:x.truncated?h("Showing the first {max} of {count} rows.",{count:x.rowCount,max:x.rows.length}):h("{count} rows",{count:x.rowCount})})]}),e[78]=n,e[79]=o,e[80]=u,e[81]=x,e[82]=h,e[83]=te):te=e[83];let ne;e[84]!==Z||e[85]!==ee||e[86]!==te?(ne=(0,c.jsxs)("div",{className:"min-h-0 flex-1 overflow-auto",children:[Z,ee,te]}),e[84]=Z,e[85]=ee,e[86]=te,e[87]=ne):ne=e[87];let le;return e[88]!==r||e[89]!==X||e[90]!==ne?(le=(0,c.jsxs)("div",{className:r,children:[X,ne]}),e[88]=r,e[89]=X,e[90]=ne,e[91]=le):le=e[91],le},"Wn"),Hn=i((l,e)=>l.trim()===""?e:(l.split(`
6
+ `)[0]??l).slice(0,24),"Kn"),jn=i(l=>{l?.focus(),l?.select()},"Un"),Kn=i(l=>{let e=(0,K.c)(14),{initial:t,onCancel:n,onCommit:r,placeholder:o,testId:s}=l,m=oe(),a;e[0]!==r?(a=i(u=>{r(u.currentTarget.value.trim())},"a"),e[0]=r,e[1]=a):a=e[1];let d=a,f;e[2]!==n||e[3]!==r?(f=i(u=>{u.key==="Enter"?r(u.currentTarget.value.trim()):u.key==="Escape"&&n()},"f"),e[2]=n,e[3]=r,e[4]=f):f=e[4];let p=f,b;e[5]!==m?(b=m("Tab title"),e[5]=m,e[6]=b):b=e[6];let v;return e[7]!==t||e[8]!==d||e[9]!==p||e[10]!==o||e[11]!==b||e[12]!==s?(v=(0,c.jsx)("input",{"aria-label":b,className:"w-40 rounded border border-ring bg-background px-1 py-0.5 text-xs outline-none","data-testid":s,defaultValue:t,onBlur:d,onKeyDown:p,placeholder:o,ref:jn,type:"text"}),e[7]=t,e[8]=d,e[9]=p,e[10]=o,e[11]=b,e[12]=s,e[13]=v):v=e[13],v},"Yn"),Yn=i(l=>{let e=(0,K.c)(29),{idBase:t,onDiscard:n,onKeep:r}=l,o=oe(),s=`sql-tab-close-prompt-${t}`,m;e[0]!==o?(m=o("Discard?"),e[0]=o,e[1]=m):m=e[1];let a;e[2]!==m?(a=(0,c.jsx)("span",{className:"text-[11px] text-muted-foreground",children:m}),e[2]=m,e[3]=a):a=e[3];let d;e[4]!==o?(d=o("Discard changes"),e[4]=o,e[5]=d):d=e[5];let f=`sql-tab-close-confirm-${t}`,p;e[6]!==o?(p=o("Discard changes"),e[6]=o,e[7]=p):p=e[7];let b;e[8]===Symbol.for("react.memo_cache_sentinel")?(b=(0,c.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,c.jsx)("path",{d:"M5 13l4 4L19 7"})}),e[8]=b):b=e[8];let v;e[9]!==n||e[10]!==d||e[11]!==f||e[12]!==p?(v=(0,c.jsx)("button",{"aria-label":d,className:"flex size-5 items-center justify-center rounded text-destructive hover:bg-destructive/10","data-testid":f,onClick:n,title:p,type:"button",children:b}),e[9]=n,e[10]=d,e[11]=f,e[12]=p,e[13]=v):v=e[13];let u;e[14]!==o?(u=o("Keep editing"),e[14]=o,e[15]=u):u=e[15];let x=`sql-tab-close-cancel-${t}`,y;e[16]!==o?(y=o("Keep editing"),e[16]=o,e[17]=y):y=e[17];let w;e[18]===Symbol.for("react.memo_cache_sentinel")?(w=(0,c.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,c.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})}),e[18]=w):w=e[18];let g;e[19]!==r||e[20]!==x||e[21]!==y||e[22]!==u?(g=(0,c.jsx)("button",{"aria-label":u,className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent","data-testid":x,onClick:r,title:y,type:"button",children:w}),e[19]=r,e[20]=x,e[21]=y,e[22]=u,e[23]=g):g=e[23];let h;return e[24]!==s||e[25]!==g||e[26]!==a||e[27]!==v?(h=(0,c.jsxs)("span",{className:"flex shrink-0 items-center gap-1","data-testid":s,role:"group",children:[a,v,g]}),e[24]=s,e[25]=g,e[26]=a,e[27]=v,e[28]=h):h=e[28],h},"Jn"),Un=i(l=>{let e=(0,K.c)(47),{active:t,canClose:n,onClose:r,onMenu:o,onRename:s,onSelect:m,tab:a}=l,d=oe(),[f,p]=(0,P.useState)(!1),[b,v]=(0,P.useState)(!1),u;e[0]!==o||e[1]!==a.id?(u=i(H=>{o(a.id,H)},"c"),e[0]=o,e[1]=a.id,e[2]=u):u=e[2];let x=u,y;e[3]!==m||e[4]!==a.id?(y=i(()=>{m(a.id)},"v"),e[3]=m,e[4]=a.id,e[5]=y):y=e[5];let w=y,g;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=i(()=>{p(!0)},"b"),e[6]=g):g=e[6];let h=g,S;e[7]!==r||e[8]!==a?(S=i(H=>{H.stopPropagation(),at(a)?v(!0):r(a.id)},"w"),e[7]=r,e[8]=a,e[9]=S):S=e[9];let k=S,N;e[10]!==r||e[11]!==a.id?(N=i(H=>{H.stopPropagation(),v(!1),r(a.id)},"S"),e[10]=r,e[11]=a.id,e[12]=N):N=e[12];let C=N,L;e[13]===Symbol.for("react.memo_cache_sentinel")?(L=i(H=>{H.stopPropagation(),v(!1)},"R"),e[13]=L):L=e[13];let R=L,E;e[14]!==s||e[15]!==a.id?(E=i(H=>{s(a.id,H),p(!1)},"I"),e[14]=s,e[15]=a.id,e[16]=E):E=e[16];let q=E,O;e[17]===Symbol.for("react.memo_cache_sentinel")?(O=i(()=>{p(!1)},"L"),e[17]=O):O=e[17];let M=O,D;e[18]!==a.name?(D=a.name.trim(),e[18]=a.name,e[19]=D):D=e[19];let T=D,_;e[20]!==d||e[21]!==a.sql?(_=Hn(a.sql,d("Untitled")),e[20]=d,e[21]=a.sql,e[22]=_):_=e[22];let A=_,$=t?"bg-background text-foreground":"bg-muted/40 text-muted-foreground hover:text-foreground",I;e[23]!==$?(I=ue("group/tab flex shrink-0 items-center gap-1 border-e border-border ps-3 pe-1.5 text-xs",$),e[23]=$,e[24]=I):I=e[24];let B=`sql-tab-${a.id}`,W;e[25]!==t||e[26]!==q||e[27]!==T||e[28]!==A||e[29]!==f||e[30]!==w||e[31]!==d||e[32]!==a.id?(W=f?(0,c.jsx)(Kn,{initial:T,onCancel:M,onCommit:q,placeholder:A,testId:`sql-tab-rename-${a.id}`}):(0,c.jsx)("button",{"aria-pressed":t,className:"max-w-40 truncate py-1.5 outline-none","data-testid":`sql-tab-select-${a.id}`,onClick:w,onDoubleClick:h,title:d("Double-click to rename"),type:"button",children:T===""?A:T}),e[25]=t,e[26]=q,e[27]=T,e[28]=A,e[29]=f,e[30]=w,e[31]=d,e[32]=a.id,e[33]=W):W=e[33];let Q;e[34]!==n||e[35]!==C||e[36]!==b||e[37]!==k||e[38]!==d||e[39]!==a.id?(Q=n&&(b?(0,c.jsx)(Yn,{idBase:a.id,onDiscard:C,onKeep:R}):(0,c.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-${a.id}`,onClick:k,title:d("Close tab"),type:"button",children:(0,c.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,c.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})})})),e[34]=n,e[35]=C,e[36]=b,e[37]=k,e[38]=d,e[39]=a.id,e[40]=Q):Q=e[40];let Y;return e[41]!==x||e[42]!==I||e[43]!==B||e[44]!==W||e[45]!==Q?(Y=(0,c.jsxs)("div",{className:I,"data-testid":B,onContextMenu:x,children:[W,Q]}),e[41]=x,e[42]=I,e[43]=B,e[44]=W,e[45]=Q,e[46]=Y):Y=e[46],Y},"Gn"),Gn=i(l=>{let e=(0,K.c)(43),{model:t,onSelect:n}=l,r=oe(),{activeTab:o,addEditorTab:s,cancelBulk:m,closeEditorTab:a,closeTabMenu:d,confirmBulk:f,menuStyle:p,onBackdropContextMenu:b,onCloseAll:v,onCloseOthers:u,onCloseToRight:x,openTabMenu:y,pendingBulk:w,renameTab:g,tabMenu:h,tabs:S}=t,k;if(e[0]!==o||e[1]!==a||e[2]!==n||e[3]!==y||e[4]!==g||e[5]!==S){let D;e[7]!==o||e[8]!==a||e[9]!==n||e[10]!==y||e[11]!==g||e[12]!==S.length?(D=i(T=>(0,c.jsx)(Un,{active:T.id===o.id,canClose:S.length>1,onClose:a,onMenu:y,onRename:g,onSelect:n,tab:T},T.id),"O"),e[7]=o,e[8]=a,e[9]=n,e[10]=y,e[11]=g,e[12]=S.length,e[13]=D):D=e[13],k=S.map(D),e[0]=o,e[1]=a,e[2]=n,e[3]=y,e[4]=g,e[5]=S,e[6]=k}else k=e[6];let N;e[14]!==r?(N=r("New tab"),e[14]=r,e[15]=N):N=e[15];let C=S.length>=Be,L;e[16]!==r?(L=r("New tab"),e[16]=r,e[17]=L):L=e[17];let R;e[18]===Symbol.for("react.memo_cache_sentinel")?(R=(0,c.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,c.jsx)("path",{d:"M12 5v14M5 12h14"})}),e[18]=R):R=e[18];let E;e[19]!==s||e[20]!==N||e[21]!==C||e[22]!==L?(E=(0,c.jsx)("button",{"aria-label":N,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:C,onClick:s,title:L,type:"button",children:R}),e[19]=s,e[20]=N,e[21]=C,e[22]=L,e[23]=E):E=e[23];let q;e[24]!==k||e[25]!==E?(q=(0,c.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:[k,E]}),e[24]=k,e[25]=E,e[26]=q):q=e[26];let O;e[27]!==m||e[28]!==d||e[29]!==f||e[30]!==p||e[31]!==b||e[32]!==v||e[33]!==u||e[34]!==x||e[35]!==w||e[36]!==r||e[37]!==h||e[38]!==S?(O=h!==null&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("div",{className:"fixed inset-0 z-40","data-testid":"sql-tab-menu-backdrop",onClick:d,onContextMenu:b,role:"presentation"}),(0,c.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:p,children:w===null?(0,c.jsxs)(c.Fragment,{children:[(0,c.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:S.length<=1,onClick:u,role:"menuitem",type:"button",children:r("Close other tabs")}),(0,c.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:S.findIndex(D=>D.id===h.id)>=S.length-1,onClick:x,role:"menuitem",type:"button",children:r("Close tabs to the right")}),(0,c.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,c.jsxs)("div",{className:"px-3 py-1.5","data-testid":"sql-tab-menu-confirm",children:[(0,c.jsx)("p",{className:"pb-1.5 text-xs text-muted-foreground",children:r("Discard unsaved tabs?")}),(0,c.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,c.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:f,type:"button",children:r("Discard")}),(0,c.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:m,type:"button",children:r("Cancel")})]})]})})]}),e[27]=m,e[28]=d,e[29]=f,e[30]=p,e[31]=b,e[32]=v,e[33]=u,e[34]=x,e[35]=w,e[36]=r,e[37]=h,e[38]=S,e[39]=O):O=e[39];let M;return e[40]!==q||e[41]!==O?(M=(0,c.jsxs)(c.Fragment,{children:[q,O]}),e[40]=q,e[41]=O,e[42]=M):M=e[42],M},"Vn"),Jn=ve(we.runSql),Vn="lunora-studio-sql-split-view",Xn=i(()=>Se(ct[0]?.sql??""),"eo"),bo=i(l=>{let e=(0,K.c)(102),{initialShardKey:t}=l,n=ke(),r=Sn(Xn),{activeTab:o,output:s,patchActiveOutput:m,patchActiveTab:a,setActiveTabId:d,unlinkQuery:f}=r,p;e[0]!==m||e[1]!==a?(p=i((se,de)=>{a({activeId:de,sql:se}),m({chart:void 0,error:null,failed:void 0,result:null})},"h"),e[0]=m,e[1]=a,e[2]=p):p=e[2];let b=p,v;e[3]!==b||e[4]!==f?(v={loadIntoActiveTab:b,unlinkQuery:f},e[3]=b,e[4]=f,e[5]=v):v=e[5];let u=In(v),{recordHistory:x,updateQuerySql:y}=u,w=o.sql,{activeId:g}=o,{chart:h,error:S,failed:k,result:N,running:C}=s,L=s.pane,[R,E]=(0,P.useState)(t??""),[q,O]=Oe(Vn,!1),{probe:M,schema:D}=an(R),T;e[6]!==g||e[7]!==a||e[8]!==y?(T=i(se=>{a({sql:se}),g!==null&&y(g,se)},"$"),e[6]=g,e[7]=a,e[8]=y,e[9]=T):T=e[9];let _=T,A=jt(w,D,R),$=Je(R),I;e[10]!==$||e[11]!==m||e[12]!==N?(I=i(()=>{N!==null&&ie((async()=>{let se=await $.inferChart({columns:N.columns,rowCount:N.rowCount,types:Object.fromEntries(N.columns.map(de=>[de,typeof(N.rows[0]?.[de]??"")]))});m({chart:se})})())},"q"),e[10]=$,e[11]=m,e[12]=N,e[13]=I):I=e[13];let B=I,W;e[14]!==n||e[15]!==w||e[16]!==m||e[17]!==x||e[18]!==R?(W=i(async se=>{if(w.trim()==="")return;m({running:!0});let de=se==="explain"?`EXPLAIN QUERY PLAN ${w}`:w;try{let Le=await n.query(Jn,{sql:de},ye(R));m({chart:void 0,error:null,failed:void 0,pane:se,result:Le,running:!1}),Pe(R),x(de)}catch(Le){let ze=Le;m({chart:void 0,error:_e(ze),failed:{error:_e(ze),sql:de},pane:se,result:null,running:!1})}},"F"),e[14]=n,e[15]=w,e[16]=m,e[17]=x,e[18]=R,e[19]=W):W=e[19];let Q=W,Y;e[20]!==Q?(Y=i(()=>{ie(Q("results"))},"W"),e[20]=Q,e[21]=Y):Y=e[21];let H=Y,G;e[22]!==s.pane||e[23]!==Q?(G=i(()=>{ie(Q(s.pane))},"Y"),e[22]=s.pane,e[23]=Q,e[24]=G):G=e[24];let J;e[25]!==M||e[26]!==D||e[27]!==_||e[28]!==G?(J={onSubmit:G,probe:M,schema:D,setDraft:_},e[25]=M,e[26]=D,e[27]=_,e[28]=G,e[29]=J):J=e[29];let z=un(J),{closeAutocomplete:V}=z,re;e[30]!==w||e[31]!==_?(re=i(()=>{_(xt(w))},"ne"),e[30]=w,e[31]=_,e[32]=re):re=e[32];let X=re,Z;e[33]!==V||e[34]!==d?(Z=i(se=>{V(),d(se)},"X"),e[33]=V,e[34]=d,e[35]=Z):Z=e[35];let ee=Z,te;e[36]!==m?(te=i(()=>{m({pane:"results"})},"ee"),e[36]=m,e[37]=te):te=e[37];let ne=te,le;e[38]!==Q?(le=i(()=>{ie(Q("explain"))},"oe"),e[38]=Q,e[39]=le):le=e[39];let ce=le,F;e[40]!==m?(F=i(()=>{m({pane:"chart"})},"H"),e[40]=m,e[41]=F):F=e[41];let j=F,U;e[42]!==O||e[43]!==q?(U=i(()=>{O(!q)},"U"),e[42]=O,e[43]=q,e[44]=U):U=e[44];let ae=U,xe=q?"flex min-h-0 flex-1 flex-row":"flex min-h-0 flex-1 flex-col",Re=q?"flex w-2/5 min-h-0 min-w-0 shrink-0 flex-col border-s border-border":"flex h-2/5 min-h-0 shrink-0 flex-col border-t border-border",me;e[45]!==g||e[46]!==u.clearHistory||e[47]!==u.deleteQuery||e[48]!==u.history||e[49]!==u.listRef||e[50]!==u.loadFromHistory||e[51]!==u.loadTemplate||e[52]!==u.newQuery||e[53]!==u.onSearchChange||e[54]!==u.queries||e[55]!==u.search||e[56]!==u.selectQuery?(me=(0,c.jsx)(Fn,{activeId:g,history:u.history,listRef:u.listRef,onClearHistory:u.clearHistory,onDelete:u.deleteQuery,onLoadHistory:u.loadFromHistory,onLoadTemplate:u.loadTemplate,onNew:u.newQuery,onSearchChange:u.onSearchChange,onSelect:u.selectQuery,queries:u.queries,search:u.search}),e[45]=g,e[46]=u.clearHistory,e[47]=u.deleteQuery,e[48]=u.history,e[49]=u.listRef,e[50]=u.loadFromHistory,e[51]=u.loadTemplate,e[52]=u.newQuery,e[53]=u.onSearchChange,e[54]=u.queries,e[55]=u.search,e[56]=u.selectQuery,e[57]=me):me=e[57];let he;e[58]!==r||e[59]!==ee?(he=(0,c.jsx)(Gn,{model:r,onSelect:ee}),e[58]=r,e[59]=ee,e[60]=he):he=e[60];let fe;e[61]!==$||e[62]!==A||e[63]!==w||e[64]!==k||e[65]!==_||e[66]!==z.autocompleteState||e[67]!==z.editorRef||e[68]!==z.gutterRef||e[69]!==z.handlers||e[70]!==z.listboxId||e[71]!==z.onPickSuggestion||e[72]!==z.overlayRef||e[73]!==z.revealDiagnostic?(fe=(0,c.jsx)(An,{assistant:$,autocomplete:z.autocompleteState,diagnostics:A,draft:w,editorRef:z.editorRef,failed:k,gutterRef:z.gutterRef,handlers:z.handlers,listboxId:z.listboxId,onGenerated:_,onPickSuggestion:z.onPickSuggestion,onRevealDiagnostic:z.revealDiagnostic,overlayRef:z.overlayRef}),e[61]=$,e[62]=A,e[63]=w,e[64]=k,e[65]=_,e[66]=z.autocompleteState,e[67]=z.editorRef,e[68]=z.gutterRef,e[69]=z.handlers,e[70]=z.listboxId,e[71]=z.onPickSuggestion,e[72]=z.overlayRef,e[73]=z.revealDiagnostic,e[74]=fe):fe=e[74];let pe;e[75]!==$||e[76]!==S||e[77]!==X||e[78]!==B||e[79]!==h||e[80]!==H||e[81]!==N||e[82]!==Re||e[83]!==C||e[84]!==R||e[85]!==j||e[86]!==ce||e[87]!==ne||e[88]!==q||e[89]!==L||e[90]!==ae?(pe=(0,c.jsx)(Wn,{assistant:$,chart:h,className:Re,error:S,onFormat:X,onInferChart:B,onRun:H,onShardKeyChange:E,onShowChart:j,onShowExplain:ce,onShowResults:ne,onToggleSplit:ae,pane:L,result:N,running:C,shardKey:R,splitView:q}),e[75]=$,e[76]=S,e[77]=X,e[78]=B,e[79]=h,e[80]=H,e[81]=N,e[82]=Re,e[83]=C,e[84]=R,e[85]=j,e[86]=ce,e[87]=ne,e[88]=q,e[89]=L,e[90]=ae,e[91]=pe):pe=e[91];let be;e[92]!==fe||e[93]!==pe||e[94]!==xe?(be=(0,c.jsxs)("div",{className:xe,children:[fe,pe]}),e[92]=fe,e[93]=pe,e[94]=xe,e[95]=be):be=e[95];let ge;e[96]!==he||e[97]!==be?(ge=(0,c.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col",children:[he,be]}),e[96]=he,e[97]=be,e[98]=ge):ge=e[98];let Ne;return e[99]!==me||e[100]!==ge?(Ne=(0,c.jsxs)("div",{className:"flex h-full min-w-0","data-testid":"lunora-sql-editor",children:[me,ge]}),e[99]=me,e[100]=ge,e[101]=Ne):Ne=e[101],Ne},"wo");export{bo as SqlEditorPanel};