@lunora/studio 1.0.0-alpha.4 → 1.0.0-alpha.41

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 (187) hide show
  1. package/LICENSE.md +6 -0
  2. package/__assets__/package-og.svg +1 -1
  3. package/dist/index.d.ts +33 -18
  4. package/dist/index.js +29 -29
  5. package/dist/mount.d.ts +1 -1
  6. package/dist/mount.js +3 -2
  7. package/dist/{packem_shared/ApiTab-W3no0KOj.js → packem_chunks/ApiTab.js} +5 -5
  8. package/dist/{packem_shared/AuditPanel-Bq4o_IqT.js → packem_chunks/AuditPanel.js} +29 -41
  9. package/dist/{packem_shared/ExportImportPanel-dxY56TDF.js → packem_chunks/ExportImportPanel.js} +16 -11
  10. package/dist/{packem_shared/FileBrowser-Dhy4zES8.js → packem_chunks/FileBrowser.js} +15 -15
  11. package/dist/{packem_shared/FunctionRunner--fQJRPAD.js → packem_chunks/FunctionRunner.js} +10 -10
  12. package/dist/{packem_shared/FunctionStatsPanel-BjRUA_G3.js → packem_chunks/FunctionStatsPanel.js} +153 -208
  13. package/dist/{packem_shared/HealthPanel-PxclMWmA.js → packem_chunks/HealthPanel.js} +37 -29
  14. package/dist/{packem_shared/InsightsPanel-CWS_C-xW.js → packem_chunks/InsightsPanel.js} +108 -69
  15. package/dist/{packem_shared/LogsPanel-CTW8CFcM.js → packem_chunks/LogsPanel.js} +46 -58
  16. package/dist/{packem_shared/MailPanel-BwkvfIHF.js → packem_chunks/MailPanel.js} +45 -139
  17. package/dist/{packem_shared/MetricsPanel-BLuOhZQ4.js → packem_chunks/MetricsPanel.js} +41 -322
  18. package/dist/{packem_shared/MigrationsPanel-DT3lnwHF.js → packem_chunks/MigrationsPanel.js} +44 -51
  19. package/dist/{packem_shared/PitrPanel-CdErL7EJ.js → packem_chunks/PitrPanel.js} +9 -9
  20. package/dist/{packem_shared/SchemaViewer-LJDcmNIO.js → packem_chunks/SchemaViewer.js} +17 -16
  21. package/dist/{packem_shared/SecurityAdvisorPanel-C_ETsPih.js → packem_chunks/SecurityAdvisorPanel.js} +47 -31
  22. package/dist/packem_chunks/SettingsPanel.js +391 -0
  23. package/dist/{packem_shared/sql-editor-panel-BFRpzj6r.js → packem_chunks/SqlEditorPanel.js} +158 -387
  24. package/dist/{packem_shared/TableEditor-ChfUOZec.js → packem_chunks/TableEditor.js} +10 -68
  25. package/dist/packem_chunks/analytics-panel.js +261 -0
  26. package/dist/packem_chunks/auth-config-panel.js +365 -0
  27. package/dist/packem_chunks/auth-sessions-panel.js +175 -0
  28. package/dist/packem_chunks/containers-panel.js +247 -0
  29. package/dist/packem_chunks/dashboards-panel.js +780 -0
  30. package/dist/packem_chunks/fanout-panel.js +482 -0
  31. package/dist/packem_chunks/flags-panel.js +176 -0
  32. package/dist/packem_chunks/kv-browser.js +1896 -0
  33. package/dist/packem_chunks/log-drains-panel.js +273 -0
  34. package/dist/packem_chunks/organizations-panel.js +3178 -0
  35. package/dist/packem_chunks/payments-panel.js +186 -0
  36. package/dist/packem_chunks/permissions-panel.js +805 -0
  37. package/dist/packem_chunks/queues-panel.js +1075 -0
  38. package/dist/packem_chunks/rls-panel.js +315 -0
  39. package/dist/packem_chunks/schedule-panel.js +831 -0
  40. package/dist/packem_chunks/sparkline.js +79 -0
  41. package/dist/packem_chunks/storage-rules-panel.js +140 -0
  42. package/dist/packem_chunks/subscriptions-panel.js +238 -0
  43. package/dist/packem_chunks/users-panel.js +1731 -0
  44. package/dist/packem_chunks/vector-browser.js +281 -0
  45. package/dist/packem_chunks/workflows-panel.js +562 -0
  46. package/dist/packem_shared/{ADMIN_FUNCTIONS-DmBqMZ-z.js → ADMIN_FUNCTIONS-BHHJi3Gb.js} +7 -0
  47. package/dist/packem_shared/{ApiDocsPanel-C5-yJ1p7.js → ApiDocsPanel-CBma-lnp.js} +2 -2
  48. package/dist/packem_shared/{ApiReferencePanel-1vubqG5s.js → ApiReferencePanel-CQM3pPN7.js} +2 -1
  49. package/dist/packem_shared/{CommandPalette-BtgkBzZI.js → CommandPalette-X2tkbyHk.js} +1 -1
  50. package/dist/packem_shared/{DataBrowser-CtBe1So9.js → DataBrowser-D2ywrdId.js} +198 -247
  51. package/dist/packem_shared/{GlobalDataBrowser-BTEmGrph.js → GlobalDataBrowser-BkTPLzAY.js} +37 -66
  52. package/dist/packem_shared/HomePanel-D1Q9LZgK.js +14 -0
  53. package/dist/packem_shared/{OpenRpcReferencePanel-vbcYbv3V.js → OpenRpcReferencePanel-Dno-hfDb.js} +2 -1
  54. package/dist/packem_shared/{ScheduledJobs-CabfKbyM.js → ScheduledJobs-Ctw4jYtU.js} +163 -60
  55. package/dist/packem_shared/Studio-lJhzDAze.js +16 -0
  56. package/dist/packem_shared/{StudioApp-CHOZA-z-.js → StudioApp-DiMkupvZ.js} +276 -11
  57. package/dist/packem_shared/{advisor-view-CGcfMiPq.js → advisor-view-BX8OhG0w.js} +6 -6
  58. package/dist/packem_shared/alert-CdAET2K_.js +68 -0
  59. package/dist/packem_shared/{app.d-CCmwDEVs.d.ts → app.d-CNLRTrWw.d.ts} +1 -1
  60. package/dist/packem_shared/{bar-chart-CzJAgqkp.js → bar-chart-DSwcWIRy.js} +5 -4
  61. package/dist/packem_shared/browser-storage-BTrX4y3B.js +215 -0
  62. package/dist/packem_shared/{cf-links-2cktDedA.js → cf-links-BZfRdxSE.js} +1 -1
  63. package/dist/packem_shared/{data-grid-B5CaV3wS.js → data-grid-CdXztApG.js} +1 -1
  64. package/dist/packem_shared/data-view-params-Cd6yRVbv.js +96 -0
  65. package/dist/packem_shared/error-alert-CXjqyGw9.js +114 -0
  66. package/dist/packem_shared/{grid-features-CzUfqgsM.js → grid-features-BF-KBDFz.js} +131 -163
  67. package/dist/packem_shared/home-panel-TFcRf9Ui.js +1889 -0
  68. package/dist/packem_shared/{internal-rXJEAhXS.js → internal-CYcbqMjX.js} +44 -3
  69. package/dist/packem_shared/modal-shell-hyaJvIJ6.js +100 -0
  70. package/dist/packem_shared/{reference-view-B4E49Lip.js → reference-view-DUiJcILV.js} +6 -45
  71. package/dist/packem_shared/scroll-area-DLhcy-ml.js +93 -0
  72. package/dist/packem_shared/select-UkNYCT3s.js +273 -0
  73. package/dist/packem_shared/skeleton-CGhL0p20.js +45 -0
  74. package/dist/packem_shared/{sparkline-10dG-_f0.js → sparkline-BnA1kC9X.js} +1 -1
  75. package/dist/packem_shared/studio-Dh9UlaF_.js +4015 -0
  76. package/dist/packem_shared/{table-_RzNvy3R.js → table-DsCa9Qp9.js} +1 -1
  77. package/dist/packem_shared/{table-list-sidebar-Bg7uzbvC.js → table-list-sidebar-UVIXQJdU.js} +1 -1
  78. package/dist/packem_shared/use-admin-query-CfHYWx5n.js +106 -0
  79. package/dist/packem_shared/use-async-submit-DJQiPc-_.js +91 -0
  80. package/dist/standalone/chunk-25AYY4H7.js +2 -0
  81. package/dist/standalone/chunk-2ANAF4ZM.js +1 -0
  82. package/dist/standalone/chunk-2K47A3P6.js +1 -0
  83. package/dist/standalone/chunk-2NGUNNGW.js +1 -0
  84. package/dist/standalone/chunk-3CJW6NWG.js +4 -0
  85. package/dist/standalone/chunk-3OA7PECS.js +6 -0
  86. package/dist/standalone/chunk-3OIHOXVV.js +1 -0
  87. package/dist/standalone/chunk-447TAUFD.js +1 -0
  88. package/dist/standalone/chunk-4QHKBC77.js +1 -0
  89. package/dist/standalone/chunk-5C4TSNE6.js +1 -0
  90. package/dist/standalone/chunk-5OIBXYZM.js +1 -0
  91. package/dist/standalone/chunk-6HSHEMZV.js +76 -0
  92. package/dist/standalone/chunk-6JIZ34MB.js +3 -0
  93. package/dist/standalone/chunk-6VO23MMW.js +4 -0
  94. package/dist/standalone/chunk-7MVSQS7B.js +1 -0
  95. package/dist/standalone/chunk-7TJJXVSE.js +1 -0
  96. package/dist/standalone/chunk-7YXOPTWI.js +1 -0
  97. package/dist/standalone/chunk-AHILM3ZP.js +1 -0
  98. package/dist/standalone/chunk-BGXOXASQ.js +1 -0
  99. package/dist/standalone/chunk-BJGBHGK3.js +1 -0
  100. package/dist/standalone/chunk-BOXSWNXZ.js +1 -0
  101. package/dist/standalone/chunk-BX5MKYOC.js +1 -0
  102. package/dist/standalone/chunk-CKSHCYGC.js +2 -0
  103. package/dist/standalone/chunk-DWDILV2E.js +1 -0
  104. package/dist/standalone/chunk-E75ANNWX.js +19 -0
  105. package/dist/standalone/chunk-EQZQOTJY.js +1 -0
  106. package/dist/standalone/chunk-GTLEWM5Y.js +1 -0
  107. package/dist/standalone/chunk-GTM65MVX.js +1 -0
  108. package/dist/standalone/chunk-GUI5GFFI.js +1 -0
  109. package/dist/standalone/chunk-HN6KJXYQ.js +1 -0
  110. package/dist/standalone/chunk-HV7G6DFP.js +5 -0
  111. package/dist/standalone/chunk-HYDJNCGW.js +1 -0
  112. package/dist/standalone/chunk-HZK5RQHG.js +1 -0
  113. package/dist/standalone/chunk-IN2SYVJB.js +1 -0
  114. package/dist/standalone/chunk-IOANPSJN.js +1 -0
  115. package/dist/standalone/chunk-ISDZPW3V.js +1 -0
  116. package/dist/standalone/chunk-IXDH4GL5.js +1 -0
  117. package/dist/standalone/chunk-J6J54MBP.js +1 -0
  118. package/dist/standalone/chunk-J73VHFCL.js +1 -0
  119. package/dist/standalone/chunk-JHKMUTIF.js +13 -0
  120. package/dist/standalone/chunk-JPRH6DPK.js +1 -0
  121. package/dist/standalone/chunk-JSEXCW5Q.js +1 -0
  122. package/dist/standalone/chunk-KA5YB3VP.js +1 -0
  123. package/dist/standalone/chunk-KBB75WNT.js +1 -0
  124. package/dist/standalone/chunk-KEGAWN6Y.js +1 -0
  125. package/dist/standalone/chunk-KJJ3WM6H.js +4 -0
  126. package/dist/standalone/chunk-KQV4NGH3.js +1 -0
  127. package/dist/standalone/chunk-KSKXW5PX.js +1 -0
  128. package/dist/standalone/chunk-KUH4P5F5.js +1 -0
  129. package/dist/standalone/chunk-KYJPPVGB.js +1 -0
  130. package/dist/standalone/chunk-KZ6INM5M.js +1 -0
  131. package/dist/standalone/chunk-L2TJVSDQ.js +1 -0
  132. package/dist/standalone/chunk-L7SK4ZZD.js +1 -0
  133. package/dist/standalone/chunk-LAK5VSPI.js +1 -0
  134. package/dist/standalone/chunk-LBN7LPVK.js +1 -0
  135. package/dist/standalone/chunk-LNZIB2MD.js +1 -0
  136. package/dist/standalone/chunk-MJWVMKQ4.js +6 -0
  137. package/dist/standalone/chunk-MLZYX5CQ.js +1 -0
  138. package/dist/standalone/chunk-N2X2OO4V.js +1 -0
  139. package/dist/standalone/chunk-NGKITPQP.js +13 -0
  140. package/dist/standalone/chunk-O3NAGRTR.js +1 -0
  141. package/dist/standalone/chunk-OZACQNKG.js +1 -0
  142. package/dist/standalone/chunk-PNDNXS5Z.js +1 -0
  143. package/dist/standalone/chunk-Q7DMUTUE.js +1 -0
  144. package/dist/standalone/chunk-QAFAJBAW.js +1 -0
  145. package/dist/standalone/chunk-QBAT52GB.js +1 -0
  146. package/dist/standalone/chunk-RHZ4M2NZ.js +1 -0
  147. package/dist/standalone/chunk-RRCPZMC2.js +22 -0
  148. package/dist/standalone/chunk-SEU5V7I6.js +1 -0
  149. package/dist/standalone/chunk-TAD43CG5.js +1 -0
  150. package/dist/standalone/chunk-TBMYIZIO.js +1 -0
  151. package/dist/standalone/chunk-TDZ44E5I.js +4 -0
  152. package/dist/standalone/chunk-THNBTMUF.js +1 -0
  153. package/dist/standalone/chunk-TIQISBGK.js +1 -0
  154. package/dist/standalone/chunk-TMYVNQ66.js +1 -0
  155. package/dist/standalone/chunk-TQ36RWOP.js +1 -0
  156. package/dist/standalone/chunk-UGUEC6BC.js +1 -0
  157. package/dist/standalone/chunk-UJB2LEI4.js +4 -0
  158. package/dist/standalone/chunk-UK64ZSUW.js +1 -0
  159. package/dist/standalone/chunk-UKDJ4H7I.js +1 -0
  160. package/dist/standalone/chunk-VLXV72QE.js +1 -0
  161. package/dist/standalone/chunk-VON7JUPG.js +1 -0
  162. package/dist/standalone/chunk-W3JK4YWR.js +1 -0
  163. package/dist/standalone/chunk-W3SHEIAL.js +3 -0
  164. package/dist/standalone/chunk-WI7GWFEG.js +1 -0
  165. package/dist/standalone/chunk-WIHXMNUY.js +1 -0
  166. package/dist/standalone/chunk-WLDVXVI2.js +1 -0
  167. package/dist/standalone/chunk-XLXNLJ4N.js +1 -0
  168. package/dist/standalone/chunk-XNJNSCLM.js +1 -0
  169. package/dist/standalone/chunk-YAECF5LW.js +1 -0
  170. package/dist/standalone/chunk-YBGC4PPD.js +1 -0
  171. package/dist/standalone/chunk-YJAPWSDC.js +4 -0
  172. package/dist/standalone/chunk-ZEJB6DXU.js +8 -0
  173. package/dist/standalone/chunk-ZFNBPAIZ.js +1 -0
  174. package/dist/standalone/chunk-ZHVTQ37P.js +1 -0
  175. package/dist/standalone/chunk-ZIGWVHCS.js +1 -0
  176. package/dist/standalone/chunk-ZPP2KOR4.js +1 -0
  177. package/dist/standalone/chunk-ZPUO7FNI.js +1 -0
  178. package/dist/standalone/studio.js +104 -246
  179. package/dist/styles.css +2 -2
  180. package/package.json +15 -13
  181. package/dist/packem_shared/HomePanel-Cw16stjq.js +0 -1273
  182. package/dist/packem_shared/SettingsPanel-C0uLRf5P.js +0 -176
  183. package/dist/packem_shared/SqlEditorPanel-CguV7otm.js +0 -13
  184. package/dist/packem_shared/Studio-DFWAlcuf.js +0 -33
  185. package/dist/packem_shared/studio-Bj8psK1c.js +0 -10303
  186. package/dist/packem_shared/use-live-admin-Dq6g3daN.js +0 -73
  187. package/dist/packem_shared/use-live-shard-seed-Cuk3dnH0.js +0 -76
@@ -0,0 +1 @@
1
+ import{a as k,b as N,c as O,d as x,e as q,f as D}from"./chunk-GTM65MVX.js";import{a as C}from"./chunk-TAD43CG5.js";import{a as g}from"./chunk-SEU5V7I6.js";import{d as T,g as I,j as _,k as w}from"./chunk-E75ANNWX.js";import{b as L}from"./chunk-JHKMUTIF.js";import{a as d,e as b,f as U,g as Y,h as F}from"./chunk-RRCPZMC2.js";var M=b(Y(),1);var H="https://api.cloudflare.com/client/v4/accounts",E=class extends L{static{d(this,"AnalyticsSqlError")}constructor(e,f){super("ANALYTICS_SQL_ERROR",`Analytics Engine SQL API returned ${String(e)}: ${f}`,{name:"AnalyticsSqlError",status:e})}},v=d(t=>{let e=t.fetch??globalThis.fetch,f=`${H}/${encodeURIComponent(t.accountId)}/analytics_engine/sql`;return{query:d(async s=>{let l=await e(f,{body:s,headers:{Authorization:`Bearer ${t.apiToken}`,"Content-Type":"text/plain"},method:"POST"});if(!l.ok)throw new E(l.status,await l.text());let n;try{n=await l.json()}catch{throw new E(l.status,"Analytics Engine SQL API returned a non-JSON body.")}let o=n,a=o.data??[];return{columns:o.meta??[],rowCount:o.rows??a.length,rows:a}},"query")}},"createAnalyticsSqlClient");var m=b(U(),1);var r=b(F(),1);var W="ANALYTICS",P=[{key:"volume",sql:d(t=>`SELECT blob2 AS fn, count() AS calls FROM ${t} WHERE blob1 = 'function_call' GROUP BY fn ORDER BY calls DESC LIMIT 25`,"sql"),title:"Request volume per function"},{key:"latency",sql:d(t=>`SELECT blob2 AS fn, quantileWeighted(0.50)(double1, _sample_interval) AS p50, quantileWeighted(0.95)(double1, _sample_interval) AS p95 FROM ${t} WHERE blob1 = 'function_call' GROUP BY fn ORDER BY p95 DESC LIMIT 25`,"sql"),title:"Latency p50 / p95 per function"},{key:"hotShards",sql:d(t=>`SELECT blob3 AS shard, count() AS calls FROM ${t} WHERE blob1 = 'function_call' GROUP BY shard ORDER BY calls DESC LIMIT 25`,"sql"),title:"Hot shards"}],j={error:null,loading:!0,result:null},G=d(t=>{let e=(0,M.c)(27),{state:f,title:p}=t,s=T(),{error:l,loading:n,result:o}=f,a=`analytics-panel-${p}`,i;e[0]!==s||e[1]!==p?(i=s(p),e[0]=s,e[1]=p,e[2]=i):i=e[2];let c;e[3]!==i?(c=(0,r.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i},void 0,!1)},void 0,!1),e[3]=i,e[4]=c):c=e[4];let u;e[5]!==n||e[6]!==s?(u=n&&(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"analytics-loading",children:s("Loading\u2026")},void 0,!1),e[5]=n,e[6]=s,e[7]=u):u=e[7];let y;e[8]!==l||e[9]!==n?(y=!n&&l!==null&&(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"analytics-error",role:"alert",children:l},void 0,!1),e[8]=l,e[9]=n,e[10]=y):y=e[10];let h;e[11]!==l||e[12]!==n||e[13]!==o||e[14]!==s?(h=!n&&l===null&&o!==null&&o.rows.length===0&&(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"analytics-empty-rows",children:s("No data points yet.")},void 0,!1),e[11]=l,e[12]=n,e[13]=o,e[14]=s,e[15]=h):h=e[15];let A;e[16]!==l||e[17]!==n||e[18]!==o?(A=!n&&l===null&&o!==null&&o.rows.length>0&&(0,r.jsxDEV)(k,{children:[(0,r.jsxDEV)(N,{children:(0,r.jsxDEV)(x,{children:o.columns.map(Q)},void 0,!1)},void 0,!1),(0,r.jsxDEV)(O,{children:o.rows.map((B,$)=>(0,r.jsxDEV)(x,{children:o.columns.map(R=>(0,r.jsxDEV)(D,{className:"font-mono text-xs",children:_(B[R.name])},R.name,!1))},$,!1))},void 0,!1)]},void 0,!0),e[16]=l,e[17]=n,e[18]=o,e[19]=A):A=e[19];let S;return e[20]!==a||e[21]!==c||e[22]!==u||e[23]!==y||e[24]!==h||e[25]!==A?(S=(0,r.jsxDEV)(g,{className:"gap-0 py-0","data-testid":a,children:[c,u,y,h,A]},void 0,!0),e[20]=a,e[21]=c,e[22]=u,e[23]=y,e[24]=h,e[25]=A,e[26]=S):S=e[26],S},"PanelResult"),re=d(({config:t,dataset:e=W,runQuery:f}={})=>{let p=T(),[s,l]=(0,m.useState)({}),n=(0,m.useMemo)(()=>{if(f!==void 0)return f;if(t===void 0)return null;let a=v({accountId:t.accountId,apiToken:t.apiToken});return i=>a.query(i)},[t,f]),o=(0,m.useCallback)(async a=>{if(n!==null)for(let i of P){if(a.cancelled)return;l(c=>({...c,[i.key]:{error:null,loading:!0,result:null}}));try{let c=await n(i.sql(e));a.cancelled||l(u=>({...u,[i.key]:{error:null,loading:!1,result:c}}))}catch(c){a.cancelled||l(u=>({...u,[i.key]:{error:I(c),loading:!1,result:null}}))}}},[n,e]);return(0,m.useEffect)(()=>{let a={cancelled:!1};return w(o(a)),()=>{a.cancelled=!0}},[o]),n===null?(0,r.jsxDEV)(C,{description:p("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN (Analytics Read) in your .dev.vars to enable usage panels."),icon:(0,r.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsxDEV)("path",{d:"M5 20V10m6.5 10V4M18 20v-7M3 20h18"},void 0,!1)},void 0,!1),testId:"analytics-not-configured",title:p("Analytics is not configured.")},void 0,!1):(0,r.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-analytics-panel",children:P.map(a=>(0,r.jsxDEV)(G,{state:s[a.key]??j,title:a.title},a.key,!1))},void 0,!1)},"AnalyticsPanel");function Q(t){return(0,r.jsxDEV)(q,{children:t.name},t.name,!1)}d(Q,"_temp");export{re as AnalyticsPanel};
@@ -0,0 +1 @@
1
+ import{a as S}from"./chunk-HN6KJXYQ.js";import"./chunk-XNJNSCLM.js";import{a as w,b as A,c as E,d as m,e as s,f as l}from"./chunk-GTM65MVX.js";import{a as O}from"./chunk-VLXV72QE.js";import{a as k}from"./chunk-JSEXCW5Q.js";import{a as C}from"./chunk-BOXSWNXZ.js";import{a as u}from"./chunk-TAD43CG5.js";import{b as T}from"./chunk-RHZ4M2NZ.js";import{a as N,e as b}from"./chunk-SEU5V7I6.js";import{b as y}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import"./chunk-XLXNLJ4N.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as h}from"./chunk-E75ANNWX.js";import"./chunk-JHKMUTIF.js";import{a as d,e as p,f as D,h as H}from"./chunk-RRCPZMC2.js";var n=p(D(),1);var e=p(H(),1);var K=d(a=>{let t=a.trim();if(t.length===0)return{context:void 0,error:null};try{let o=JSON.parse(t);return o===null||typeof o!="object"||Array.isArray(o)?{context:void 0,error:"Targeting context must be a JSON object."}:{context:o,error:null}}catch{return{context:void 0,error:"Targeting context is not valid JSON."}}},"parseContext"),R='{ "targetingKey": "user-123", "plan": "premium" }',M=d(a=>a.type==="object"?JSON.stringify(a.value):String(a.value),"formatValue"),Y=d(({initialShardKey:a=""})=>{let t=h(),[o,F]=(0,n.useState)(""),{context:f,error:g}=K(o),I=(0,n.useMemo)(()=>f===void 0?{}:{context:f},[f]),{data:i,error:J,errorSource:L,liveError:j}=T(C.listFlags,I,{live:!0,shardKey:a}),v=i!==void 0,V=i?.configured??!1,x=(0,n.useMemo)(()=>Array.isArray(i?.flags)?[...i.flags].toSorted((r,B)=>r.key.localeCompare(B.key)):[],[i]),c;return v&&!V?c=(0,e.jsxDEV)(u,{description:t("No @lunora/flags provider is wired in this deployment. Add lunora/flags.ts with defineFlags({ provider }) to gate code paths on feature flags."),testId:"flags-unconfigured",title:t("No flags provider configured")},void 0,!1):v&&x.length===0?c=(0,e.jsxDEV)(u,{description:t('A flags provider is configured, but no handler reads a flag yet. Call ctx.flags.boolean("key", false) in a query, mutation, or action.'),testId:"flags-empty",title:t("No flags read")},void 0,!1):c=(0,e.jsxDEV)(N,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(b,{className:"px-0",children:(0,e.jsxDEV)(w,{"data-testid":"flags-table",children:[(0,e.jsxDEV)(A,{children:(0,e.jsxDEV)(m,{children:[(0,e.jsxDEV)(s,{children:t("Key")},void 0,!1),(0,e.jsxDEV)(s,{children:t("Type")},void 0,!1),(0,e.jsxDEV)(s,{children:t("Value")},void 0,!1),(0,e.jsxDEV)(s,{children:t("Reason")},void 0,!1),(0,e.jsxDEV)(s,{children:t("Variant")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(E,{children:x.map(r=>(0,e.jsxDEV)(m,{"data-testid":`flags-row-${r.key}`,children:[(0,e.jsxDEV)(l,{className:"font-mono text-xs",children:r.key},void 0,!1),(0,e.jsxDEV)(l,{className:"font-mono text-xs text-muted-foreground",children:r.type},void 0,!1),(0,e.jsxDEV)(l,{className:"font-mono text-xs",children:M(r)},void 0,!1),(0,e.jsxDEV)(l,{children:r.errorCode===void 0?(0,e.jsxDEV)("span",{className:"font-mono text-xs text-muted-foreground",children:r.reason??"\u2014"},void 0,!1):(0,e.jsxDEV)(y,{"data-testid":`flags-error-${r.key}`,variant:"destructive",children:r.errorCode},void 0,!1)},void 0,!1),(0,e.jsxDEV)(l,{className:"font-mono text-xs text-muted-foreground",children:r.variant??"\u2014"},void 0,!1)]},r.key,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-6","data-testid":"lunora-flags-panel",children:[J!==null&&(0,e.jsxDEV)(S,{error:L,testId:"flags-error"},void 0,!1),(0,e.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:t('Feature flags are read in code with ctx.flags.<type>("key", default). They evaluate through the OpenFeature provider configured in lunora/flags.ts; edit the targeting context below to see how each flag resolves for a given audience.')},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-2",children:[(0,e.jsxDEV)(k,{htmlFor:"flags-targeting-context",children:t("Targeting context (JSON)")},void 0,!1),(0,e.jsxDEV)(O,{className:"font-mono text-xs","data-testid":"flags-context-input",id:"flags-targeting-context",onChange:d(r=>{F(r.target.value)},"onChange"),placeholder:R,rows:3,value:o},void 0,!1),g!==null&&(0,e.jsxDEV)("p",{className:"text-xs text-destructive","data-testid":"flags-context-error",role:"alert",children:t(g)},void 0,!1),j!==void 0&&(0,e.jsxDEV)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"flags-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")},void 0,!1)]},void 0,!0),c]},void 0,!0)},"FlagsPanel");export{Y as FlagsPanel};
@@ -0,0 +1 @@
1
+ import{a as m,e as r,g as c,h as d,j as i}from"./chunk-RRCPZMC2.js";var n=r(c(),1);var f=r(d(),1);function u(a){let e=(0,n.c)(8),t,s;e[0]!==a?({className:t,...s}=a,e[0]=a,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let o;e[3]!==t?(o=i("animate-pulse rounded-md bg-muted",t),e[3]=t,e[4]=o):o=e[4];let l;return e[5]!==s||e[6]!==o?(l=(0,f.jsxDEV)("div",{"data-slot":"skeleton",className:o,...s},void 0,!1),e[5]=s,e[6]=o,e[7]=l):l=e[7],l}m(u,"Skeleton");export{u as a};
@@ -0,0 +1 @@
1
+ import{a as He}from"./chunk-YAECF5LW.js";import"./chunk-DWDILV2E.js";import{a as je}from"./chunk-J6J54MBP.js";import"./chunk-5OIBXYZM.js";import{a as Pe}from"./chunk-HN6KJXYQ.js";import{a as Ge}from"./chunk-XNJNSCLM.js";import{a as Be,b as Re,c as $e,d as j,e as E,f as _}from"./chunk-GTM65MVX.js";import{a as Ve}from"./chunk-VLXV72QE.js";import{R as We}from"./chunk-3CJW6NWG.js";import{c as V}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as J}from"./chunk-BOXSWNXZ.js";import{a as ie}from"./chunk-TAD43CG5.js";import{b as De}from"./chunk-RHZ4M2NZ.js";import{a as Le,e as Me}from"./chunk-SEU5V7I6.js";import{b as de}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as Fe}from"./chunk-XLXNLJ4N.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as U,e as ce,f as ue,g as me,k as fe,o as ze}from"./chunk-E75ANNWX.js";import"./chunk-JHKMUTIF.js";import{a as f,e as Ie,f as at,g as ot,h as rt}from"./chunk-RRCPZMC2.js";var F=Ie(ot(),1);var w=Ie(at(),1);var t=Ie(rt(),1);var lt=f((o,e)=>{let s=new Set(o.map(a=>a.deadLetterQueue).filter(a=>typeof a=="string"&&a!=="")),i=o.filter(a=>(a.deadLetterQueue===void 0||a.deadLetterQueue==="")&&!s.has(a.name)),n=e.filter(a=>a.deadLettered).length;return{deadLetteredCount:n,queuesWithoutDlq:i,showReliabilityWarning:i.length>0||n>0}},"computeQueueReliability"),nt=200,dt=ce(J.sendQueueMessage),it=ce(J.replayQueueMessage),ct=ce(J.clearQueueMessages),Ye=96,ut=f(o=>{if(o===void 0)return"\u2014";try{return JSON.stringify(o)}catch{return"[unserializable]"}},"formatBody"),mt=f(o=>o.length>Ye?`${o.slice(0,Ye)}\u2026`:o,"truncate"),ft=f(o=>o==="error"?"destructive":o==="retry"?"outline":"secondary","outcomeVariant"),ht=f((o,e)=>e(o==="messages"?"Messages":o==="send"?"Send":"Declared"),"tabLabel"),pt=f(o=>{let e=(0,F.c)(11),{loaded:s,queues:i}=o,n=U(),a;e[0]!==n?(a=n("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[0]=n,e[1]=a):a=e[1];let l;e[2]!==a?(l=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:a},void 0,!1),e[2]=a,e[3]=l):l=e[3];let r;e[4]!==s||e[5]!==i||e[6]!==n?(r=s&&i.length===0?(0,t.jsxDEV)(ie,{description:n("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:n("No queues defined")},void 0,!1):(0,t.jsxDEV)(Le,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Me,{className:"px-0",children:(0,t.jsxDEV)(Be,{"data-testid":"queues-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(E,{children:n("Export")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Queue")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Mode")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Binding")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Dead-letter")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)($e,{children:i.map(yt)},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[4]=s,e[5]=i,e[6]=n,e[7]=r):r=e[7];let h;return e[8]!==l||e[9]!==r?(h=(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[l,r]},void 0,!0),e[8]=l,e[9]=r,e[10]=h):h=e[10],h},"QueuesDeclaredTab"),gt=f(o=>{let e=(0,F.c)(67),{message:s,onReplay:i,replayingId:n}=o,a=U(),l,r,h,u,y,p,x,d,m,g;if(e[0]!==s.attempts||e[1]!==s.body||e[2]!==s.deadLettered||e[3]!==s.exportName||e[4]!==s.id||e[5]!==s.messageId||e[6]!==s.outcome||e[7]!==s.queue||e[8]!==a){let W=ut(s.body);r=j,p=`queues-message-${s.id}`;let z=s.exportName??s.queue;e[19]!==z?(x=(0,t.jsxDEV)(_,{className:"font-mono text-xs",children:z},void 0,!1),e[19]=z,e[20]=x):x=e[20],e[21]!==s.messageId?(d=(0,t.jsxDEV)(_,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:s.messageId,children:s.messageId},void 0,!1),e[21]=s.messageId,e[22]=d):d=e[22],e[23]!==s.attempts?(m=(0,t.jsxDEV)(_,{className:"font-mono text-xs tabular-nums",children:s.attempts},void 0,!1),e[23]=s.attempts,e[24]=m):m=e[24];let I=`queues-outcome-${s.id}`,L;e[25]!==s.outcome?(L=ft(s.outcome),e[25]=s.outcome,e[26]=L):L=e[26];let T;e[27]!==s.outcome||e[28]!==I||e[29]!==L?(T=(0,t.jsxDEV)(de,{"data-testid":I,variant:L,children:s.outcome},void 0,!1),e[27]=s.outcome,e[28]=I,e[29]=L,e[30]=T):T=e[30];let M;e[31]!==s.deadLettered||e[32]!==s.id||e[33]!==a?(M=s.deadLettered&&(0,t.jsxDEV)(de,{"data-testid":`queues-dlq-${s.id}`,variant:"destructive",children:a("DLQ")},void 0,!1),e[31]=s.deadLettered,e[32]=s.id,e[33]=a,e[34]=M):M=e[34],e[35]!==T||e[36]!==M?(g=(0,t.jsxDEV)(_,{children:(0,t.jsxDEV)("span",{className:"inline-flex items-center gap-1",children:[T,M]},void 0,!0)},void 0,!1),e[35]=T,e[36]=M,e[37]=g):g=e[37],l=_,h="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",u=W,y=mt(W),e[0]=s.attempts,e[1]=s.body,e[2]=s.deadLettered,e[3]=s.exportName,e[4]=s.id,e[5]=s.messageId,e[6]=s.outcome,e[7]=s.queue,e[8]=a,e[9]=l,e[10]=r,e[11]=h,e[12]=u,e[13]=y,e[14]=p,e[15]=x,e[16]=d,e[17]=m,e[18]=g}else l=e[9],r=e[10],h=e[11],u=e[12],y=e[13],p=e[14],x=e[15],d=e[16],m=e[17],g=e[18];let v;e[38]!==l||e[39]!==h||e[40]!==u||e[41]!==y?(v=(0,t.jsxDEV)(l,{className:h,title:u,children:y},void 0,!1),e[38]=l,e[39]=h,e[40]=u,e[41]=y,e[42]=v):v=e[42];let N;e[43]!==s.capturedAt?(N=ze(s.capturedAt,"\u2014"),e[43]=s.capturedAt,e[44]=N):N=e[44];let b;e[45]!==N?(b=(0,t.jsxDEV)(_,{className:"text-xs text-muted-foreground tabular-nums",children:N},void 0,!1),e[45]=N,e[46]=b):b=e[46];let S=`queues-replay-${s.id}`,A=n!==null,C;e[47]!==s.id||e[48]!==n||e[49]!==a?(C=n===s.id?a("Replaying\u2026"):a("Replay"),e[47]=s.id,e[48]=n,e[49]=a,e[50]=C):C=e[50];let Q;e[51]!==s.id||e[52]!==i||e[53]!==S||e[54]!==A||e[55]!==C?(Q=(0,t.jsxDEV)(_,{children:(0,t.jsxDEV)(V,{"data-id":s.id,"data-testid":S,disabled:A,onClick:i,size:"xs",type:"button",variant:"outline",children:C},void 0,!1)},void 0,!1),e[51]=s.id,e[52]=i,e[53]=S,e[54]=A,e[55]=C,e[56]=Q):Q=e[56];let D;return e[57]!==r||e[58]!==b||e[59]!==Q||e[60]!==p||e[61]!==x||e[62]!==d||e[63]!==m||e[64]!==g||e[65]!==v?(D=(0,t.jsxDEV)(r,{"data-testid":p,children:[x,d,m,g,v,b,Q]},void 0,!0),e[57]=r,e[58]=b,e[59]=Q,e[60]=p,e[61]=x,e[62]=d,e[63]=m,e[64]=g,e[65]=v,e[66]=D):D=e[66],D},"QueueLogRow"),vt=f(o=>{let e=(0,F.c)(26),{hasError:s,messages:i,onClear:n,onReplay:a,replayingId:l}=o,r=U(),h;e[0]!==r?(h=r("Cloudflare Queues have no peek API, so this is what push consumers actually processed \u2014 not pending depth."),e[0]=r,e[1]=h):h=e[1];let u;e[2]!==h?(u=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:h},void 0,!1),e[2]=h,e[3]=u):u=e[3];let y=i.length===0,p;e[4]!==r?(p=r("Clear log"),e[4]=r,e[5]=p):p=e[5];let x;e[6]!==n||e[7]!==y||e[8]!==p?(x=(0,t.jsxDEV)(V,{className:"ml-auto","data-testid":"queues-clear",disabled:y,onClick:n,size:"sm",type:"button",variant:"outline",children:p},void 0,!1),e[6]=n,e[7]=y,e[8]=p,e[9]=x):x=e[9];let d;e[10]!==i.length||e[11]!==r?(d=i.length>0&&(0,t.jsxDEV)(de,{"data-testid":"queues-count",variant:"secondary",children:r("{count} messages",{count:i.length})},void 0,!1),e[10]=i.length,e[11]=r,e[12]=d):d=e[12];let m;e[13]!==u||e[14]!==x||e[15]!==d?(m=(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[u,x,d]},void 0,!0),e[13]=u,e[14]=x,e[15]=d,e[16]=m):m=e[16];let g;e[17]!==s||e[18]!==i||e[19]!==a||e[20]!==l||e[21]!==r?(g=!s&&i.length===0?(0,t.jsxDEV)(ie,{description:r("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:r("No consumed messages yet.")},void 0,!1):(0,t.jsxDEV)(Le,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Me,{className:"px-0",children:(0,t.jsxDEV)(He,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:(0,t.jsxDEV)(Be,{"data-testid":"queues-messages-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(E,{children:r("Export")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Message")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Attempts")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Outcome")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Body")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Captured")},void 0,!1),(0,t.jsxDEV)(E,{},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)($e,{children:i.map(N=>(0,t.jsxDEV)(gt,{message:N,onReplay:a,replayingId:l},N.id,!1))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)},void 0,!1),e[17]=s,e[18]=i,e[19]=a,e[20]=l,e[21]=r,e[22]=g):g=e[22];let v;return e[23]!==m||e[24]!==g?(v=(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[m,g]},void 0,!0),e[23]=m,e[24]=g,e[25]=v):v=e[25],v},"QueuesMessagesTab"),xt=f(o=>{let e=(0,F.c)(20),{batchMode:s,bodyText:i,delayText:n,onBatchModeChange:a,onBodyChange:l,onDelayChange:r,onSelectExport:h,onSend:u,queues:y,selectedExportName:p,sending:x}=o,d=U(),m;e[0]!==d?(m=d("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=d,e[1]=m):m=e[1];let g;e[2]!==m?(g=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:m},void 0,!1),e[2]=m,e[3]=g):g=e[3];let v;e[4]!==s||e[5]!==i||e[6]!==n||e[7]!==a||e[8]!==l||e[9]!==r||e[10]!==h||e[11]!==u||e[12]!==y||e[13]!==p||e[14]!==x||e[15]!==d?(v=y.length===0?(0,t.jsxDEV)(ie,{description:d("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:d("No queues to send to")},void 0,!1):(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxDEV)("select",{"aria-label":d("Queue"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"queues-send-select",onChange:h,value:p,children:y.map(bt)},void 0,!1),(0,t.jsxDEV)(We,{"aria-label":d("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:r,placeholder:d("Delay (s)"),type:"number",value:n},void 0,!1),(0,t.jsxDEV)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[(0,t.jsxDEV)("input",{checked:s,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:a,type:"checkbox"},void 0,!1),d("Send as batch (JSON array)")]},void 0,!0),(0,t.jsxDEV)(V,{className:"ml-auto","data-testid":"queues-send-button",disabled:x||p==="",onClick:u,type:"button",children:d(x?"Sending\u2026":"Send message")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(Ve,{"aria-label":d("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:l,placeholder:s?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:i},void 0,!1)]},void 0,!0),e[4]=s,e[5]=i,e[6]=n,e[7]=a,e[8]=l,e[9]=r,e[10]=h,e[11]=u,e[12]=y,e[13]=p,e[14]=x,e[15]=d,e[16]=v):v=e[16];let N;return e[17]!==g||e[18]!==v?(N=(0,t.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[g,v]},void 0,!0),e[17]=g,e[18]=v,e[19]=N):N=e[19],N},"QueuesSendTab"),Ut=f(o=>{let e=(0,F.c)(59),{limit:s}=o,i=s??nt,n=Fe(),a=U(),[l,r]=(0,w.useState)("declared"),[h,u]=(0,w.useState)(null),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={},e[0]=y):y=e[0];let{data:p,error:x,errorSource:d}=De(J.listQueues,y),m;e[1]!==i?(m={limit:i},e[1]=i,e[2]=m):m=e[2];let{data:g,error:v,errorSource:N,refetch:b}=De(J.getQueueMessages,m),S=Array.isArray(p?.queues)?[...p.queues].toSorted(Nt):[],A=g?.entries??[],{deadLetteredCount:C,queuesWithoutDlq:Q,showReliabilityWarning:D}=lt(S,A),[W,z]=(0,w.useState)(""),[I,L]=(0,w.useState)(""),[T,M]=(0,w.useState)(""),[G,Xe]=(0,w.useState)(!1),[he,Oe]=(0,w.useState)(!1),[pe,ke]=(0,w.useState)(null),H=S.some(c=>c.exportName===W)?W:S[0]?.exportName??"",Ue=l==="messages"?v:x,Ke=l==="messages"?N:d,ge=Ue??h,ve=Ue===null?h:Ke,Y;e[3]!==b?(Y=f(()=>{b()},"t3"),e[3]=b,e[4]=Y):Y=e[4],je(Y,l==="messages");let xe=f(async()=>{u(null);let c=H;if(c==="")return;let q=null,we=I.trim();if(we!=="")try{q=JSON.parse(we)}catch{u(a("Body must be valid JSON."));return}let Ae,Je=T.trim();if(Je!==""){let P=Number(Je);if(!Number.isFinite(P)||P<0){u(a("Delay must be a non-negative number of seconds."));return}Ae=P}if(G&&!Array.isArray(q)){u(a("Batch mode needs a JSON array body \u2014 each element is enqueued as one message."));return}Oe(!0);let st=G?{batch:q,delaySeconds:Ae,exportName:c}:{body:q,delaySeconds:Ae,exportName:c};try{await n.query(dt,st,ue("")),b()}catch(P){u(me(P))}Oe(!1)},"send"),X;e[5]!==n||e[6]!==b?(X=f(async c=>{u(null),ke(c);try{await n.query(it,{id:c},ue("")),b()}catch(q){u(me(q))}ke(null)},"t5"),e[5]=n,e[6]=b,e[7]=X):X=e[7];let ye=X,K;e[8]!==n||e[9]!==b?(K=f(async()=>{u(null);try{await n.query(ct,{},ue("")),b()}catch(c){u(me(c))}},"t6"),e[8]=n,e[9]=b,e[10]=K):K=e[10];let be=K,Z;e[11]===Symbol.for("react.memo_cache_sentinel")?(Z=f(c=>{let q=c.currentTarget.dataset.tab;(q==="declared"||q==="messages"||q==="send")&&r(q)},"t7"),e[11]=Z):Z=e[11];let Ze=Z,ee;e[12]===Symbol.for("react.memo_cache_sentinel")?(ee=f(c=>{z(c.currentTarget.value)},"t8"),e[12]=ee):ee=e[12];let Ne=ee,te;e[13]===Symbol.for("react.memo_cache_sentinel")?(te=f(c=>{L(c.currentTarget.value)},"t9"),e[13]=te):te=e[13];let qe=te,se;e[14]===Symbol.for("react.memo_cache_sentinel")?(se=f(c=>{M(c.currentTarget.value)},"t10"),e[14]=se):se=e[14];let Se=se,ae;e[15]===Symbol.for("react.memo_cache_sentinel")?(ae=f(c=>{Xe(c.currentTarget.checked)},"t11"),e[15]=ae):ae=e[15];let Ee=ae,oe;e[16]!==xe?(oe=f(()=>{fe(xe())},"t12"),e[16]=xe,e[17]=oe):oe=e[17];let _e=oe,re;e[18]!==ye?(re=f(c=>{let{id:q}=c.currentTarget.dataset;q!==void 0&&fe(ye(q))},"t13"),e[18]=ye,e[19]=re):re=e[19];let Te=re,le;e[20]!==be?(le=f(()=>{fe(be())},"t14"),e[20]=be,e[21]=le):le=e[21];let Ce=le,et="flex flex-col gap-6",tt="lunora-queues-panel",B;e[22]!==a||e[23]!==l?(B=(0,t.jsxDEV)("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(c=>(0,t.jsxDEV)(V,{"aria-selected":l===c,"data-tab":c,"data-testid":`queues-tab-${c}`,onClick:Ze,role:"tab",size:"sm",type:"button",variant:l===c?"secondary":"ghost",children:ht(c,a)},c,!1))},void 0,!1),e[22]=a,e[23]=l,e[24]=B):B=e[24];let R;e[25]!==ge||e[26]!==ve?(R=ge!==null&&(0,t.jsxDEV)(Pe,{error:ve,testId:"queues-error"},void 0,!1),e[25]=ge,e[26]=ve,e[27]=R):R=e[27];let Qe=D&&(0,t.jsxDEV)(Ge,{icon:(0,t.jsxDEV)("span",{"aria-hidden":"true",className:"text-base leading-none",children:"\u26A0"},void 0,!1),testId:"queues-dlq-warning",variant:"warning",children:(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[Q.length>0&&(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)("p",{className:"font-medium",children:a("No dead-letter queue on {queues}.",{queues:Q.map(qt).join(", ")})},void 0,!1),(0,t.jsxDEV)("p",{className:"text-muted-foreground",children:a("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")},void 0,!1)]},void 0,!0),C>0&&(0,t.jsxDEV)("p",{className:Q.length>0?"text-muted-foreground":"font-medium",children:C===1?a("1 message was recently dead-lettered."):a("{count} messages were recently dead-lettered.",{count:C})},void 0,!1)]},void 0,!0)},void 0,!1),$;e[28]!==S||e[29]!==p||e[30]!==l?($=l==="declared"&&(0,t.jsxDEV)(pt,{loaded:p!==void 0,queues:S},void 0,!1),e[28]=S,e[29]=p,e[30]=l,e[31]=$):$=e[31];let O;e[32]!==A||e[33]!==v||e[34]!==Ce||e[35]!==Te||e[36]!==pe||e[37]!==l?(O=l==="messages"&&(0,t.jsxDEV)(vt,{hasError:v!==null,messages:A,onClear:Ce,onReplay:Te,replayingId:pe},void 0,!1),e[32]=A,e[33]=v,e[34]=Ce,e[35]=Te,e[36]=pe,e[37]=l,e[38]=O):O=e[38];let k;e[39]!==G||e[40]!==I||e[41]!==T||e[42]!==Ee||e[43]!==qe||e[44]!==Se||e[45]!==Ne||e[46]!==_e||e[47]!==S||e[48]!==H||e[49]!==he||e[50]!==l?(k=l==="send"&&(0,t.jsxDEV)(xt,{batchMode:G,bodyText:I,delayText:T,onBatchModeChange:Ee,onBodyChange:qe,onDelayChange:Se,onSelectExport:Ne,onSend:_e,queues:S,selectedExportName:H,sending:he},void 0,!1),e[39]=G,e[40]=I,e[41]=T,e[42]=Ee,e[43]=qe,e[44]=Se,e[45]=Ne,e[46]=_e,e[47]=S,e[48]=H,e[49]=he,e[50]=l,e[51]=k):k=e[51];let ne;return e[52]!==B||e[53]!==R||e[54]!==Qe||e[55]!==$||e[56]!==O||e[57]!==k?(ne=(0,t.jsxDEV)("div",{className:et,"data-testid":tt,children:[B,R,Qe,$,O,k]},void 0,!0),e[52]=B,e[53]=R,e[54]=Qe,e[55]=$,e[56]=O,e[57]=k,e[58]=ne):ne=e[58],ne},"QueuesPanel");function yt(o){return(0,t.jsxDEV)(j,{"data-testid":`queues-row-${o.exportName}`,children:[(0,t.jsxDEV)(_,{className:"font-mono text-xs",children:o.exportName},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.name},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.mode},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.binding},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.deadLetterQueue??"\u2014"},void 0,!1)]},o.exportName,!0)}f(yt,"_temp");function bt(o){return(0,t.jsxDEV)("option",{value:o.exportName,children:o.exportName},o.exportName,!1)}f(bt,"_temp2");function Nt(o,e){return o.exportName.localeCompare(e.exportName)}f(Nt,"_temp3");function qt(o){return o.name}f(qt,"_temp4");export{Ut as default};
@@ -0,0 +1 @@
1
+ import{a as o,c as r}from"./chunk-O3NAGRTR.js";import{a as i,e as d,f as l}from"./chunk-RRCPZMC2.js";var s={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},p={...s,position:"fixed",top:0,left:0},u={...s,position:"absolute"};var a=d(l(),1);function b(e,c){let t=a.useRef(e),n=r(c);o(()=>{t.current!==e&&n(t.current)},[e,n]),o(()=>{t.current=e},[e])}i(b,"useValueChanged");export{p as a,u as b,b as c};
@@ -0,0 +1 @@
1
+ import{a as o}from"./chunk-KJJ3WM6H.js";import{a as t}from"./chunk-RRCPZMC2.js";var d=t((h,i,r)=>o(h,e=>{i(e.height>0?e:{height:r,width:e.width})}),"flooredRectObserver");export{d as a};
@@ -0,0 +1 @@
1
+ import{b as f}from"./chunk-THNBTMUF.js";import"./chunk-HN6KJXYQ.js";import"./chunk-XNJNSCLM.js";import"./chunk-GTM65MVX.js";import{a as R}from"./chunk-BOXSWNXZ.js";import{b as p}from"./chunk-RHZ4M2NZ.js";import"./chunk-SEU5V7I6.js";import"./chunk-XLXNLJ4N.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as h}from"./chunk-E75ANNWX.js";import"./chunk-JHKMUTIF.js";import{a as i,e as m,g as S,h as A}from"./chunk-RRCPZMC2.js";var g=m(S(),1);var k=m(A(),1);var _=i((e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("Live admin subscriptions are ungated")})[s.kind],"findingTitle"),E=i(e=>Array.isArray(e.findings)?e.findings:[],"toFindings"),w=i(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"findingEntity"),T=i((e,s)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: live admin subscriptions need no credential. Set it to gate them like the HTTP admin RPCs.")})[s.kind],"findingDetail"),v=i(()=>{let e=(0,g.c)(8),s=h(),r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},e[0]=r):r=e[0];let{data:a,error:d,errorSource:c}=p(R.getSecurityAudit,r),o;if(e[1]!==a||e[2]!==s){let u=a===void 0?null:E(a);o=u===null?null:u.map(t=>({description:T(s,t),entity:w(t),issueType:_(s,t),key:t.kind,level:t.level})),e[1]=a,e[2]=s,e[3]=o}else o=e[3];let l=o,n;return e[4]!==d||e[5]!==c||e[6]!==l?(n=(0,k.jsxDEV)(f,{error:d,errorSource:c,rows:l,testId:"lunora-security-advisor"},void 0,!1),e[4]=d,e[5]=c,e[6]=l,e[7]=n):n=e[7],n},"SecurityAdvisorPanel");export{v as default};
@@ -0,0 +1 @@
1
+ import{b as pe,c as fn,d as gn,e as xn}from"./chunk-QBAT52GB.js";import{a as Rn}from"./chunk-QAFAJBAW.js";import{a as $o,c as Ko,d as Qo,e as dn}from"./chunk-IXDH4GL5.js";import{A as To,D as U,E as wo,F as ko,I as _o,K as Do,L as Ao,O as Vo,P as Bo,Q as Fo,S as Lo,T as Uo,U as Go,V as Ho,W as jo,Y as Yo,_ as zo,aa as Jo,ba as at,ca as Wo,da as Xo,ea as ut,ha as qo,ia as Gt,ja as Ge,l as Ut,la as Zo,ma as en,n as Eo,na as on,o as Io,oa as nn,pa as rn,q as yo,qa as sn,r as nt,ra as an,s as rt,t as Po,ta as un,u as st,ua as cn,v as So,va as pn,w as No,x as Oo,y as it}from"./chunk-KSKXW5PX.js";import{b as tn}from"./chunk-5OIBXYZM.js";import{i as ln,k as mn}from"./chunk-4QHKBC77.js";import{C as Se,I as Fe,J as vo,K as Le,L as tt,M as ot,O as y,P as J,d as Ft,e as ee,h as We,i as Co,p as Lt}from"./chunk-3CJW6NWG.js";import{a as ct,b as Ue}from"./chunk-UK64ZSUW.js";import{a as me,b as xo,c as Be,i as Mo,q as ho,t as bo}from"./chunk-O3NAGRTR.js";import{a as he,c as go,d as et,f as Ro,h as Je,i as ce,j as E}from"./chunk-CKSHCYGC.js";import{a as Me}from"./chunk-3OA7PECS.js";import{a as n,d as Xn,e as f,f as C,g as qn,h as Qn,j as Ve}from"./chunk-RRCPZMC2.js";var ke=f(qn(),1),Oc=f(C(),1);var te={};Xn(te,{Arrow:()=>Ht,Backdrop:()=>jt,CheckboxItem:()=>$t,CheckboxItemIndicator:()=>Kt,Group:()=>zt,GroupLabel:()=>Jt,Handle:()=>Qe,Item:()=>Wt,LinkItem:()=>Xt,Popup:()=>qt,Portal:()=>Zt,Positioner:()=>eo,RadioGroup:()=>oo,RadioItem:()=>no,RadioItemIndicator:()=>ro,Root:()=>qe,Separator:()=>Rn,SubmenuRoot:()=>Vn,SubmenuTrigger:()=>po,Trigger:()=>uo,Viewport:()=>co,createHandle:()=>jn});var Mn=f(C(),1);var pt=f(C(),1);var dt=pt.createContext(void 0);dt.displayName="MenuPositionerContext";function W(t){let e=pt.useContext(dt);if(e===void 0&&!t)throw new Error("Base UI: MenuPositionerContext is missing. MenuPositioner parts must be placed within <Menu.Positioner>.");return e}n(W,"useMenuPositionerContext");var lt=f(C(),1);var mt=lt.createContext(void 0);mt.displayName="MenuRootContext";function O(t){let e=lt.useContext(mt);if(e===void 0&&!t)throw new Error("Base UI: MenuRootContext is missing. Menu parts must be placed within <Menu.Root>.");return e}n(O,"useMenuRootContext");var Ht=Mn.forwardRef(n(function(e,o){let{render:i,className:u,style:a,...d}=e,{store:l}=O(),{arrowRef:r,side:m,align:R,arrowUncentered:g,arrowStyles:x}=W(),v={open:l.useState("open"),side:m,align:R,uncentered:g};return E("div",e,{ref:[r,o],stateAttributesMapping:Ge,state:v,props:{style:x,"aria-hidden":!0,...d}})},"MenuArrow"));Ht.displayName="MenuArrow";var bn=f(C(),1);var ft=f(C(),1);var hn=ft.createContext(void 0);hn.displayName="ContextMenuRootContext";function be(t=!0){let e=ft.useContext(hn);if(e===void 0&&!t)throw new Error("Base UI: ContextMenuRootContext is missing. ContextMenu parts must be placed within <ContextMenu.Root>.");return e}n(be,"useContextMenuRootContext");var Zn={...Ge,...Fe},jt=bn.forwardRef(n(function(e,o){let{render:i,className:u,style:a,...d}=e,{store:l}=O(),r=l.useState("open"),m=l.useState("mounted"),R=l.useState("transitionStatus"),g=l.useState("lastOpenChangeReason"),x=be(),M={open:r,transitionStatus:R};return E("div",e,{ref:x?.backdropRef?[o,x.backdropRef]:o,state:M,stateAttributesMapping:Zn,props:[{role:"presentation",hidden:!m,style:{pointerEvents:g===y.triggerHover?"none":void 0,userSelect:"none",WebkitUserSelect:"none"}},d]})},"MenuBackdrop"));jt.displayName="MenuBackdrop";var Mt=f(C(),1);var gt=f(C(),1);var Rt=gt.createContext(void 0);Rt.displayName="MenuCheckboxItemContext";function Cn(){let t=gt.useContext(Rt);if(t===void 0)throw new Error("Base UI: MenuCheckboxItemContext is missing. MenuCheckboxItem parts must be placed within <Menu.CheckboxItem>.");return t}n(Cn,"useMenuCheckboxItemContext");var He=f(C(),1);var vn=f(C(),1);function xt(t){let{closeOnClick:e,highlighted:o,id:i,nodeId:u,store:a,typingRef:d,itemRef:l,itemMetadata:r}=t,{events:m}=a.useState("floatingTreeRoot"),R=a.useState("open"),g=be(!0),x=g!==void 0;return vn.useMemo(()=>({id:i,role:"menuitem",tabIndex:R&&o?0:-1,onKeyDown(M){M.key===" "&&d?.current&&M.preventDefault()},onMouseMove(M){u&&m.emit("itemhover",{nodeId:u,target:M.currentTarget})},onClick(M){e&&m.emit("close",{domEvent:M,reason:y.itemPress})},onMouseUp(M){if(g){let v=g.initialCursorPointRef.current;if(g.initialCursorPointRef.current=null,x&&v&&Math.abs(M.clientX-v.x)<=1&&Math.abs(M.clientY-v.y)<=1||x&&!Co.os.mac&&M.button===2)return}l.current&&a.context.allowMouseUpTriggerRef.current&&(!x||M.button===2)&&(!r||r.type==="regular-item")&&l.current.click()}}),[e,o,i,m,u,R,a,d,l,g,x,r])}n(xt,"useMenuItemCommonProps");var je={type:"regular-item"};function Ne(t){let{closeOnClick:e,disabled:o=!1,highlighted:i,id:u,store:a,typingRef:d=a.context.typingRef,nativeButton:l,itemMetadata:r,nodeId:m}=t,R=a.useState("disabled"),g=o||R,x=He.useRef(null),{getButtonProps:M,buttonRef:v}=Ue({disabled:g,focusableWhenDisabled:!0,native:l,composite:!0}),S=xt({closeOnClick:e,highlighted:i,id:u,nodeId:m,store:a,typingRef:d,itemRef:x,itemMetadata:r}),c=He.useCallback(b=>he(S,{onMouseEnter(){r.type==="submenu-trigger"&&r.setActive()}},b,M),[S,M,r]),h=et(x,v);return He.useMemo(()=>({getItemProps:c,itemRef:h}),[c,h])}n(Ne,"useMenuItem");var Yt=(function(t){return t.checked="data-checked",t.unchecked="data-unchecked",t.disabled="data-disabled",t.highlighted="data-highlighted",t})({});var Oe={checked(t){return t?{[Yt.checked]:""}:{[Yt.unchecked]:""}},...Fe};var En=f(Me(),1);var $t=Mt.forwardRef(n(function(e,o){let{render:i,className:u,id:a,label:d,nativeButton:l=!1,disabled:r=!1,closeOnClick:m=!1,checked:R,defaultChecked:g,onCheckedChange:x,style:M,...v}=e,S=pe({label:d}),c=W(!0),h=ee(a),{store:b}=O(),p=b.useState("isActive",S.index),T=b.useState("itemProps"),[V,s]=ot({controlled:R,default:g??!1,name:"MenuCheckboxItem",state:"checked"}),{getItemProps:k,itemRef:P}=Ne({closeOnClick:m,disabled:r,highlighted:p,id:h,store:b,nativeButton:l,nodeId:c?.context.nodeId,itemMetadata:je}),H=Mt.useMemo(()=>({disabled:r,highlighted:p,checked:V}),[r,p,V]);function N(D){let F=J(y.itemPress,D.nativeEvent,void 0,{preventUnmountOnClose(){}});x?.(!V,F),!F.isCanceled&&s(Y=>!Y)}n(N,"handleClick");let _=E("div",e,{state:H,stateAttributesMapping:Oe,props:[T,{role:"menuitemcheckbox","aria-checked":V,onClick:N},v,k],ref:[P,o,S.ref]});return(0,En.jsx)(Rt.Provider,{value:H,children:_})},"MenuCheckboxItem"));$t.displayName="MenuCheckboxItem";var ht=f(C(),1);var Kt=ht.forwardRef(n(function(e,o){let{render:i,className:u,style:a,keepMounted:d=!1,...l}=e,r=Cn(),m=ht.useRef(null),{transitionStatus:R,setMounted:g}=tt(r.checked);Le({open:r.checked,ref:m,onComplete(){r.checked||g(!1)}});let x={checked:r.checked,disabled:r.disabled,highlighted:r.highlighted,transitionStatus:R};return E("span",e,{state:x,ref:[o,m],stateAttributesMapping:Oe,props:{"aria-hidden":!0,...l},enabled:d||r.checked})},"MenuCheckboxItemIndicator"));Kt.displayName="MenuCheckboxItemIndicator";var Ct=f(C(),1);var bt=f(C(),1);var Ye=bt.createContext(void 0);Ye.displayName="MenuGroupContext";function In(){let t=bt.useContext(Ye);if(t===void 0)throw new Error("Base UI: MenuGroupContext is missing. Menu group parts must be used within <Menu.Group> or <Menu.RadioGroup>.");return t}n(In,"useMenuGroupRootContext");var yn=f(Me(),1);var zt=Ct.forwardRef(n(function(e,o){let{render:i,className:u,style:a,...d}=e,[l,r]=Ct.useState(void 0),m=E("div",e,{ref:o,props:{role:"group","aria-labelledby":l,...d}});return(0,yn.jsx)(Ye.Provider,{value:r,children:m})},"MenuGroup"));zt.displayName="MenuGroup";var Pn=f(C(),1);var Jt=Pn.forwardRef(n(function(e,o){let{render:i,className:u,style:a,id:d,...l}=e,r=ee(d),m=In();return me(()=>(m(r),()=>{m(void 0)}),[m,r]),E("div",e,{ref:o,props:{id:r,role:"presentation",...l}})},"MenuGroupLabel"));Jt.displayName="MenuGroupLabel";var Sn=f(C(),1);var Wt=Sn.forwardRef(n(function(e,o){let{render:i,className:u,id:a,label:d,nativeButton:l=!1,disabled:r=!1,closeOnClick:m=!0,style:R,...g}=e,x=pe({label:d}),M=W(!0),v=ee(a),{store:S}=O(),c=S.useState("isActive",x.index),h=S.useState("itemProps"),{getItemProps:b,itemRef:p}=Ne({closeOnClick:m,disabled:r,highlighted:c,id:v,store:S,nativeButton:l,nodeId:M?.context.nodeId,itemMetadata:je});return E("div",e,{state:{disabled:r,highlighted:c},props:[h,g,b],ref:[p,o,x.ref]})},"MenuItem"));Wt.displayName="MenuItem";var vt=f(C(),1);var Xt=vt.forwardRef(n(function(e,o){let{render:i,className:u,id:a,label:d,closeOnClick:l=!1,style:r,...m}=e,R=vt.useRef(null),g=pe({label:d}),M=W(!0)?.context.nodeId,v=ee(a),{store:S}=O(),c=S.useState("isActive",g.index),h=S.useState("itemProps"),b=S.context.typingRef,{getButtonProps:p,buttonRef:T}=Ue({native:!1,composite:!0}),V=xt({closeOnClick:l,highlighted:c,id:v,nodeId:M,store:S,typingRef:b,itemRef:R});function s(P){return he(V,P,p)}return n(s,"getItemProps"),E("a",e,{state:{highlighted:c},props:[h,m,s],ref:[R,T,o,g.ref]})},"MenuLinkItem"));Xt.displayName="MenuLinkItem";var $e=f(C(),1);var Nn=f(Me(),1);var er={...Ge,...Fe},qt=$e.forwardRef(n(function(e,o){let{render:i,className:u,style:a,finalFocus:d,...l}=e,{store:r}=O(),{side:m,align:R}=W(),g=pn(!0)!=null,x=r.useState("open"),M=r.useState("transitionStatus"),v=r.useState("popupProps"),S=r.useState("mounted"),c=r.useState("instantType"),h=r.useState("activeTriggerElement"),b=r.useState("parent"),p=r.useState("lastOpenChangeReason"),T=r.useState("rootId"),V=r.useState("floatingRootContext"),s=r.useState("floatingTreeRoot"),k=r.useState("closeDelay"),P=r.useState("activeTriggerElement"),H=r.useState("hoverEnabled"),N=r.useState("disabled"),_=r.useState("openMethod"),D=b.type==="context-menu";Le({open:x,ref:r.context.popupRef,onComplete(){x&&r.context.onOpenChangeComplete?.(!0)}}),$e.useEffect(()=>{function K(w){r.setOpen(!1,J(w.reason,w.domEvent))}return n(K,"handleClose"),s.events.on("close",K),()=>{s.events.off("close",K)}},[s.events,r]),Jo(V,{enabled:H&&!N&&!D&&b.type!=="menubar",closeDelay:k});let F=$e.useCallback(K=>{r.set("popupElement",K)},[r]),Y={transitionStatus:M,side:m,align:R,open:x,nested:b.type==="menu",instant:c},$=E("div",e,{state:Y,ref:[o,r.context.popupRef,F],stateAttributesMapping:er,props:[v,{onKeyDown(K){g&&cn.has(K.key)&&K.stopPropagation()}},sn(M),l,{"data-rootownerid":T}]}),q=b.type===void 0||D;return(h||b.type==="menubar"&&p!==y.outsidePress)&&(q=!0),(0,Nn.jsx)(Oo,{context:V,openInteractionType:_,modal:D,disabled:!S,returnFocus:d===void 0?q:d,initialFocus:b.type!=="menu",restoreFocus:!0,externalTree:b.type!=="menubar"?s:void 0,previousFocusableElement:P,nextFocusableElement:b.type===void 0?r.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:b.type===void 0?r.context.beforeContentFocusGuardRef:void 0,children:$})},"MenuPopup"));qt.displayName="MenuPopup";var Tn=f(C(),1);var Et=f(C(),1);var It=Et.createContext(void 0);It.displayName="MenuPortalContext";function On(){let t=Et.useContext(It);if(t===void 0)throw new Error("Base UI: <Menu.Portal> is missing.");return t}n(On,"useMenuPortalContext");var Qt=f(Me(),1);var Zt=Tn.forwardRef(n(function(e,o){let{keepMounted:i=!1,...u}=e,{store:a}=O();return a.useState("mounted")||i?(0,Qt.jsx)(It.Provider,{value:i,children:(0,Qt.jsx)(yo,{ref:o,...u})}):null},"MenuPortal"));Zt.displayName="MenuPortal";var Ce=f(C(),1);var Ke=f(Me(),1);var eo=Ce.forwardRef(n(function(e,o){let{anchor:i,positionMethod:u="absolute",className:a,render:d,side:l,align:r,sideOffset:m=0,alignOffset:R=0,collisionBoundary:g="clipping-ancestors",collisionPadding:x=5,arrowPadding:M=5,sticky:v=!1,disableAnchorTracking:S=!1,collisionAvoidance:c=Eo,style:h,...b}=e,{store:p}=O(),T=On(),V=be(!0),s=p.useState("parent"),k=p.useState("floatingRootContext"),P=p.useState("floatingTreeRoot"),H=p.useState("mounted"),N=p.useState("open"),_=p.useState("modal"),D=p.useState("openMethod"),F=p.useState("activeTriggerElement"),Y=p.useState("transitionStatus"),$=p.useState("positionerElement"),q=p.useState("instantType"),K=p.useState("hasViewport"),w=p.useState("lastOpenChangeReason"),Q=p.useState("floatingNodeId"),ne=p.useState("floatingParentNodeId"),ve=k.useState("domReferenceElement"),de=Ce.useRef(null),ie=vo($,!1,!1),fe=i,ge=m,ye=R,j=r,re=c;s.type==="context-menu"&&(fe=i??s.context?.anchor,j=j??"start",!l&&j!=="center"&&(ye=e.alignOffset??2,ge=e.sideOffset??-5));let ae=l,Re=j;s.type==="menu"?(ae=ae??"inline-end",Re=Re??"start",re=e.collisionAvoidance??Io):s.type==="menubar"&&(ae=ae??(s.context.orientation==="vertical"?"inline-end":"bottom"),Re=Re??"start");let xe=s.type==="context-menu",se=nn({anchor:fe,floatingRootContext:k,positionMethod:V?"fixed":u,mounted:H,side:ae,sideOffset:ge,align:Re,alignOffset:ye,arrowPadding:xe?0:M,collisionBoundary:g,collisionPadding:x,sticky:v,nodeId:Q,keepMounted:T,disableAnchorTracking:S,collisionAvoidance:re,shiftCrossAxis:xe&&!("side"in re&&re.side==="flip"),externalTree:P,adaptiveOrigin:K?on:void 0});Ce.useEffect(()=>{function B(A){A.open&&(A.parentNodeId===Q&&p.set("hoverEnabled",!1),A.nodeId!==Q&&A.parentNodeId===p.select("floatingParentNodeId")&&p.setOpen(!1,J(y.siblingOpen)))}return n(B,"onMenuOpenChange"),P.events.on("menuopenchange",B),()=>{P.events.off("menuopenchange",B)}},[p,P.events,Q]),Ce.useEffect(()=>{if(p.select("floatingParentNodeId")==null)return;function B(A){if(A.open||A.nodeId!==p.select("floatingParentNodeId"))return;let Ee=A.reason??y.siblingOpen;p.setOpen(!1,J(Ee))}return n(B,"onParentClose"),P.events.on("menuopenchange",B),()=>{P.events.off("menuopenchange",B)}},[P.events,p]);let ue=Se();Ce.useEffect(()=>{N||ue.clear()},[N,ue]),Ce.useEffect(()=>{function B(A){if(!(!N||A.nodeId!==p.select("floatingParentNodeId")))if(A.target&&F&&F!==A.target){let Ee=p.select("closeDelay");Ee>0?ue.isStarted()||ue.start(Ee,()=>{p.setOpen(!1,J(y.siblingOpen))}):p.setOpen(!1,J(y.siblingOpen))}else ue.clear()}return n(B,"onItemHover"),P.events.on("itemhover",B),()=>{P.events.off("itemhover",B)}},[P.events,N,F,p,ue]),Ce.useEffect(()=>{let B={open:N,nodeId:Q,parentNodeId:ne,reason:p.select("lastOpenChangeReason")};P.events.emit("menuopenchange",B)},[P.events,N,p,Q,ne]),me(()=>{let B=ve,A=de.current;if(B&&(de.current=B),A&&B&&B!==A){p.set("instantType",void 0);let Ee=new AbortController;return ie(()=>{p.set("instantType","trigger-change")},Ee.signal),()=>{Ee.abort()}}},[ve,ie,p]);let _e={open:N,side:se.side,align:se.align,anchorHidden:se.anchorHidden,nested:s.type==="menu",instant:q},Pe=s.type==="menubar"&&s.context.modal,le=_&&w!==y.triggerHover;un(N&&(Pe||le),D==="touch",$,F);let De=an(e,_e,{styles:se.positionerStyles,transitionStatus:Y,props:b,refs:[o,p.useStateSetter("positionerElement")],hidden:!H,inert:!N}),Ae=H&&s.type!=="menu"&&(s.type!=="menubar"&&_&&w!==y.triggerHover||s.type==="menubar"&&s.context.modal),L=null;return s.type==="menubar"?L=s.context.contentElement:s.type===void 0&&(L=F),(0,Ke.jsxs)(dt.Provider,{value:se,children:[Ae&&(0,Ke.jsx)(rn,{ref:s.type==="context-menu"||s.type==="nested-context-menu"?s.context.internalBackdropRef:null,inert:en(!N),cutout:L}),(0,Ke.jsx)(So,{id:Q,children:(0,Ke.jsx)(fn,{elementsRef:p.context.itemDomElements,labelsRef:p.context.itemLabels,children:De})})]})},"MenuPositioner"));eo.displayName="MenuPositioner";var Te=f(C(),1);var yt=f(C(),1);var Pt=yt.createContext(void 0);Pt.displayName="MenuRadioGroupContext";function wn(){let t=yt.useContext(Pt);if(t===void 0)throw new Error("Base UI: MenuRadioGroupContext is missing. MenuRadioGroup parts must be placed within <Menu.RadioGroup>.");return t}n(wn,"useMenuRadioGroupContext");var to=f(Me(),1);var oo=Te.memo(Te.forwardRef(n(function(e,o){let{render:i,className:u,value:a,defaultValue:d,onValueChange:l,disabled:r=!1,style:m,"aria-labelledby":R,...g}=e,[x,M]=Te.useState(void 0),[v,S]=ot({controlled:a,default:d,name:"MenuRadioGroup"}),c=Be((T,V)=>{l?.(T,V),!V.isCanceled&&S(T)}),b=E("div",e,{state:{disabled:r},ref:o,props:{role:"group","aria-labelledby":R??x,"aria-disabled":r||void 0,...g}}),p=Te.useMemo(()=>({value:v,setValue:c,disabled:r}),[v,c,r]);return(0,to.jsx)(Ye.Provider,{value:M,children:(0,to.jsx)(Pt.Provider,{value:p,children:b})})},"MenuRadioGroup")));oo.displayName="MenuRadioGroup";var Ot=f(C(),1);var St=f(C(),1);var Nt=St.createContext(void 0);Nt.displayName="MenuRadioItemContext";function kn(){let t=St.useContext(Nt);if(t===void 0)throw new Error("Base UI: MenuRadioItemContext is missing. MenuRadioItem parts must be placed within <Menu.RadioItem>.");return t}n(kn,"useMenuRadioItemContext");var _n=f(Me(),1);var no=Ot.forwardRef(n(function(e,o){let{render:i,className:u,id:a,label:d,nativeButton:l=!1,disabled:r=!1,closeOnClick:m=!1,value:R,style:g,...x}=e,M=pe({label:d}),v=W(!0),S=ee(a),{store:c}=O(),h=c.useState("isActive",M.index),b=c.useState("itemProps"),{value:p,setValue:T,disabled:V}=wn(),s=V||r,k=p===R,{getItemProps:P,itemRef:H}=Ne({closeOnClick:m,disabled:s,highlighted:h,id:S,store:c,nativeButton:l,nodeId:v?.context.nodeId,itemMetadata:je}),N=Ot.useMemo(()=>({disabled:s,highlighted:h,checked:k}),[s,h,k]);function _(F){let Y=J(y.itemPress,F.nativeEvent,void 0,{preventUnmountOnClose(){}});T(R,Y)}n(_,"handleClick");let D=E("div",e,{state:N,stateAttributesMapping:Oe,props:[b,{role:"menuitemradio","aria-checked":k,onClick:_},x,P],ref:[H,o,M.ref]});return(0,_n.jsx)(Nt.Provider,{value:N,children:D})},"MenuRadioItem"));no.displayName="MenuRadioItem";var Tt=f(C(),1);var ro=Tt.forwardRef(n(function(e,o){let{render:i,className:u,style:a,keepMounted:d=!1,...l}=e,r=kn(),m=Tt.useRef(null),{transitionStatus:R,setMounted:g}=tt(r.checked);Le({open:r.checked,ref:m,onComplete(){r.checked||g(!1)}});let x={checked:r.checked,disabled:r.disabled,highlighted:r.highlighted,transitionStatus:R};return E("span",e,{state:x,stateAttributesMapping:Oe,ref:[o,m],props:{"aria-hidden":!0,...l},enabled:d||r.checked})},"MenuRadioItemIndicator"));ro.displayName="MenuRadioItemIndicator";var G=f(C(),1);var wt=f(C(),1);var Dn=wt.createContext(null);Dn.displayName="MenubarContext";function kt(t){let e=wt.useContext(Dn);if(e===null&&!t)throw new Error("Base UI: MenubarContext is missing. Menubar parts must be placed within <Menubar>.");return e}n(kt,"useMenubarContext");var Xe=f(C(),1);var tr={...Ko,disabled:U(t=>t.parent.type==="menubar"&&t.parent.context.disabled||t.disabled),modal:U(t=>(t.parent.type===void 0||t.parent.type==="context-menu")&&(t.modal??!0)),openMethod:U(t=>t.openMethod),allowMouseEnter:U(t=>t.allowMouseEnter),highlightItemOnHover:U(t=>t.highlightItemOnHover),stickIfOpen:U(t=>t.stickIfOpen),parent:U(t=>t.parent),rootId:U(t=>t.parent.type==="menu"?t.parent.store.select("rootId"):t.parent.type!==void 0?t.parent.context.rootId:t.rootId),activeIndex:U(t=>t.activeIndex),isActive:U((t,e)=>t.activeIndex===e),hoverEnabled:U(t=>t.hoverEnabled),instantType:U(t=>t.instantType),lastOpenChangeReason:U(t=>t.openChangeReason),floatingTreeRoot:U(t=>t.parent.type==="menu"?t.parent.store.select("floatingTreeRoot"):t.floatingTreeRoot),floatingNodeId:U(t=>t.floatingNodeId),floatingParentNodeId:U(t=>t.floatingParentNodeId),itemProps:U(t=>t.itemProps),closeDelay:U(t=>t.closeDelay),hasViewport:U(t=>t.hasViewport),keyboardEventRelay:U(t=>{if(t.keyboardEventRelay)return t.keyboardEventRelay;if(t.parent.type==="menu")return t.parent.store.select("keyboardEventRelay")})},ze=class t extends _o{static{n(this,"MenuStore")}constructor(e){super({...or(),...e},{positionerRef:Xe.createRef(),popupRef:Xe.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:Xe.createRef(),beforeContentFocusGuardRef:Xe.createRef(),onOpenChangeComplete:void 0,triggerElements:new Yo},tr),this.unsubscribeParentListener=this.observe("parent",o=>{if(this.unsubscribeParentListener?.(),o.type==="menu"){let i=o.store.select("rootId"),u=o.store.select("floatingTreeRoot"),a=o.store.select("keyboardEventRelay");this.unsubscribeParentListener=o.store.subscribe(()=>{let d=o.store.select("rootId"),l=o.store.select("floatingTreeRoot"),r=o.store.select("keyboardEventRelay");i===d&&u===l&&a===r||(i=d,u=l,a=r,this.notifyAll())}),this.context.allowMouseUpTriggerRef=o.store.context.allowMouseUpTriggerRef;return}o.type!==void 0&&(this.context.allowMouseUpTriggerRef=o.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(e,o){this.state.floatingRootContext.context.events.emit("setOpen",{open:e,eventDetails:o})}static useStore(e,o){let i=go(()=>new t(o)).current;return e??i}unsubscribeParentListener=null};function or(){return{...$o(),disabled:!1,modal:!0,openMethod:null,allowMouseEnter:!1,highlightItemOnHover:!0,stickIfOpen:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new nt,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:ce,keyboardEventRelay:void 0,closeDelay:0,hasViewport:!1}}n(or,"createInitialState");var _t=f(C(),1);var Dt=_t.createContext(void 0);Dt.displayName="MenuSubmenuRootContext";function At(){return _t.useContext(Dt)}n(At,"useMenuSubmenuRootContext");var so=f(Me(),1);var qe=wo(n(function(e){let{children:o,open:i,onOpenChange:u,onOpenChangeComplete:a,defaultOpen:d=!1,disabled:l=!1,modal:r,loopFocus:m=!0,orientation:R="vertical",actionsRef:g,closeParentOnEsc:x=!1,handle:M,triggerId:v,defaultTriggerId:S=null,highlightItemOnHover:c=!0}=e,h=be(!0),b=O(!0),p=kt(!0),T=At(),V=G.useMemo(()=>T&&b?{type:"menu",store:b.store}:p?{type:"menubar",context:p}:h&&!b?{type:"context-menu",context:h}:{type:void 0},[h,b,p,T]),s=ze.useStore(M?.store,{open:d,openProp:i,activeTriggerId:S,triggerIdProp:v,parent:V});Lo(s,i,d,S),s.useControlledProp("openProp",i),s.useControlledProp("triggerIdProp",v),s.useContextCallback("onOpenChangeComplete",a);let k=Ft(),P=Ft(),H=s.useState("floatingTreeRoot"),N=st(H),_=rt(),D=s.useState("open"),F=s.useState("activeTriggerElement"),Y=s.useState("positionerElement"),$=s.useState("hoverEnabled"),q=s.useState("disabled"),K=s.useState("lastOpenChangeReason"),w=s.useState("parent"),Q=s.useState("activeIndex"),ne=s.useState("payload"),ve=s.useState("floatingParentNodeId"),de=G.useRef(null),ie=G.useRef(w.type!=="context-menu"),fe=Se(),ge=G.useRef(!0),ye=Se(),j=ve!=null;w.type!==void 0&&r!==void 0&&console.warn("Base UI: The `modal` prop is not supported on nested menus. It will be ignored.");let{openMethod:re,triggerProps:ae}=Zo(D);s.useSyncedValues({disabled:l,highlightItemOnHover:c,modal:w.type===void 0?r:void 0,openMethod:re,rootId:k}),Go(s);let{forceUnmount:Re}=Ho(D,s,()=>{s.update({allowMouseEnter:!1,stickIfOpen:!0})});me(()=>{h&&!b?s.update({parent:{type:"context-menu",context:h},floatingNodeId:N,floatingParentNodeId:_}):b&&s.update({floatingNodeId:N,floatingParentNodeId:_})},[h,b,N,_,s]),G.useEffect(()=>{if(D||(de.current=null),w.type==="context-menu"){if(!D){fe.clear(),ie.current=!1;return}fe.start(500,()=>{ie.current=!0})}},[fe,D,w.type]),me(()=>{!D&&!$&&s.set("hoverEnabled",!0)},[D,$,s]);let xe=Be((I,z)=>{let Z=z.reason;if(D===I&&z.trigger===F&&K===Z)return;let Jn=Fo(z);if(!I&&z.trigger==null&&(z.trigger=F??void 0),u?.(I,z),z.isCanceled)return;s.state.floatingRootContext.dispatchOpenChange(I,z);let Ze=z.event;if(I===!1&&Ze?.type==="click"&&Ze.pointerType==="touch"&&!ge.current)return;I&&Z===y.triggerFocus?(ge.current=!1,ye.start(300,()=>{ge.current=!0})):(ge.current=!0,ye.clear());let mo=(Z===y.triggerPress||Z===y.itemPress)&&Ze.detail===0&&Ze?.isTrusted,Wn=!I&&(Z===y.escapeKey||Z==null),fo={open:I,openChangeReason:Z};de.current=z.event??null,Bo(fo,I,z.trigger,Jn()),s.update(fo),w.type==="menubar"&&(Z===y.triggerFocus||Z===y.focusOut||Z===y.triggerHover||Z===y.listNavigation||Z===y.siblingOpen)?s.set("instantType","group"):mo||Wn?s.set("instantType",mo?"click":"dismiss"):s.set("instantType",void 0)}),se=Do({popupStore:s,floatingId:P,nested:_!=null,onOpenChange:xe}),ue=se.context.events;G.useEffect(()=>{let I=n(({open:z,eventDetails:Z})=>xe(z,Z),"handleSetOpenEvent");return ue.on("setOpen",I),()=>{ue?.off("setOpen",I)}},[ue,xe]);let _e=G.useCallback(()=>{s.setOpen(!1,J(y.imperativeAction))},[s]);G.useImperativeHandle(g,()=>({unmount:Re,close:_e}),[Re,_e]);let Pe;w.type==="context-menu"&&(Pe=w.context),G.useImperativeHandle(Pe?.positionerRef,()=>Y,[Y]),G.useImperativeHandle(Pe?.actionsRef,()=>({setOpen:xe}),[xe]);let le=To(se,{enabled:!q,bubbles:{escapeKey:x&&w.type==="menu"},outsidePress(){return w.type!=="context-menu"||de.current?.type==="contextmenu"?!0:ie.current},externalTree:j?H:void 0}),De=tn(),Ae=G.useCallback(I=>{s.select("activeIndex")!==I&&s.set("activeIndex",I)},[s]),L=Wo(se,{enabled:!q,listRef:s.context.itemDomElements,activeIndex:Q,nested:w.type!==void 0,loopFocus:m,orientation:R,parentOrientation:w.type==="menubar"?w.context.orientation:void 0,rtl:De==="rtl",disabledIndices:Je,onNavigate:Ae,openOnArrowKeyDown:w.type!=="context-menu",externalTree:j?H:void 0,focusItemOnHover:c}),B=G.useCallback(I=>{s.context.typingRef.current=I},[s]),A=Xo(se,{enabled:!q,listRef:s.context.itemLabels,elementsRef:s.context.itemDomElements,activeIndex:Q,resetMs:500,onMatch:n(I=>{D&&I!==Q&&s.set("activeIndex",I)},"onMatch"),onTyping:B}),Ee=G.useMemo(()=>{let I=he(A.reference,L.reference,le.reference,{onMouseMove(){s.set("allowMouseEnter",!0)}},ae);return I["aria-haspopup"]="menu",I["aria-expanded"]=D,I},[s,A.reference,L.reference,le.reference,ae,D]),Yn=G.useMemo(()=>{let I=he(L.trigger,le.trigger,ae);return I["aria-haspopup"]="menu",I["aria-expanded"]=!1,I},[L.trigger,le.trigger,ae]),$n=G.useMemo(()=>he(Ao,{id:P,role:"menu","aria-labelledby":F?.id,onMouseMove(){s.set("allowMouseEnter",!0),w.type==="menu"&&s.set("hoverEnabled",!1)},onClick(){s.select("hoverEnabled")&&s.set("hoverEnabled",!1)},onKeyDown(I){let z=s.select("keyboardEventRelay");z&&!I.isPropagationStopped()&&z(I)}},A.floating,L.floating,le.floating),[F,P,w.type,s,A.floating,L.floating,le.floating]),Kn=L.item??ce;jo(s,{floatingRootContext:se,activeTriggerProps:Ee,inactiveTriggerProps:Yn,popupProps:$n,itemProps:Kn});let zn=G.useMemo(()=>({store:s,parent:V}),[s,V]),lo=(0,so.jsx)(mt.Provider,{value:zn,children:typeof o=="function"?o({payload:ne}):o});return w.type===void 0||w.type==="context-menu"?(0,so.jsx)(No,{externalTree:H,children:lo}):lo},"MenuRoot"));qe.displayName="MenuRoot";var An=f(C(),1);var io=f(Me(),1);function Vn(t){let e=O().store,o=An.useMemo(()=>({parentMenu:e}),[e]);return(0,io.jsx)(Dt.Provider,{value:o,children:(0,io.jsx)(qe,{...t})})}n(Vn,"MenuSubmenuRoot");var X=f(C(),1);var Bn=f(C(),1);function Fn(t={}){let{highlightItemOnHover:e,highlightedIndex:o,onHighlightedIndexChange:i}=ct(),{ref:u,index:a}=pe(t),d=o===a,l=Bn.useRef(null),r=et(u,l);return{compositeProps:{tabIndex:d?0:-1,onFocus(){i(a)},onMouseMove(){let R=l.current;if(!e||!R)return;let g=R.hasAttribute("disabled")||R.ariaDisabled==="true";!d&&!g&&R.focus()}},compositeRef:r,index:a}}n(Fn,"useCompositeItem");function Ln(t){let{render:e,className:o,style:i,state:u=ce,props:a=Je,refs:d=Je,metadata:l,stateAttributesMapping:r,tag:m="div",...R}=t,{compositeProps:g,compositeRef:x}=Fn({metadata:l});return E(m,t,{state:u,ref:[...d,x],props:[g,...a,R],stateAttributesMapping:r})}n(Ln,"CompositeItem");function ao(t){if(Mo(t)&&t.hasAttribute("data-rootownerid"))return t.getAttribute("data-rootownerid")??void 0;if(!ho(t))return ao(bo(t))}n(ao,"findRootOwnerId");var Vt=f(C(),1);function Un(t){let{enabled:e=!0,mouseDownAction:o,open:i}=t,u=Vt.useRef(!1);return Vt.useMemo(()=>e?{onMouseDown:n(a=>{(o==="open"&&!i||o==="close"&&i)&&(u.current=!0,We(a.currentTarget).addEventListener("click",()=>{u.current=!1},{once:!0}))},"onMouseDown"),onClick:n(a=>{u.current&&(u.current=!1,a.preventBaseUIHandler())},"onClick")}:ce,[e,o,i])}n(Un,"useMixedToggleClickHandler");var we=f(Me(),1);var Bt=2,uo=ko(n(function(e,o){let{render:i,className:u,style:a,disabled:d=!1,nativeButton:l=!0,id:r,openOnHover:m,delay:R=100,closeDelay:g=0,handle:x,payload:M,...v}=e,S=O(!0),c=x?.store??S?.store;if(!c)throw new Error("Base UI: <Menu.Trigger> must be either used within a <Menu.Root> component or provided with a handle.");let h=ee(r),b=c.useState("isTriggerActive",h),p=c.useState("floatingRootContext"),T=c.useState("isOpenedByTrigger",h),V=c.useState("triggerPopupId",h),s=X.useRef(null),k=rr(),P=ct(!0),H=Po(),N=X.useMemo(()=>H??new nt,[H]),_=st(N),D=rt(),{registerTrigger:F,isMountedByThisTrigger:Y}=Uo(h,s,c,{payload:M,closeDelay:g,parent:k,floatingTreeRoot:N,floatingNodeId:_,floatingParentNodeId:D,keyboardEventRelay:P?.relayKeyboardEvent}),$=k.type==="menubar",q=c.useState("disabled"),K=d||q||$&&k.context.disabled,{getButtonProps:w,buttonRef:Q}=Ue({disabled:K,native:l});X.useEffect(()=>{!T&&k.type===void 0&&(c.context.allowMouseUpTriggerRef.current=!1)},[c,T,k.type]);let ne=X.useRef(null),ve=Se(),de=Be(L=>{if(!ne.current)return;ve.clear(),c.context.allowMouseUpTriggerRef.current=!1;let B=L.target;if(Lt(ne.current,B)||Lt(c.select("positionerElement"),B)||B===ne.current||B!=null&&ao(B)===c.select("rootId"))return;let A=gn(ne.current);L.clientX>=A.left-Bt&&L.clientX<=A.right+Bt&&L.clientY>=A.top-Bt&&L.clientY<=A.bottom+Bt||N.events.emit("close",{domEvent:L,reason:y.cancelOpen})});X.useEffect(()=>{T&&c.select("lastOpenChangeReason")===y.triggerHover&&We(ne.current).addEventListener("mouseup",de,{once:!0})},[T,de,c]);let ie=$&&k.context.hasSubmenuOpen,ge=at(p,{enabled:(m??ie)&&!K&&k.type!=="context-menu"&&(!$||ie&&!Y),handleClose:ut({blockPointerEvents:!$}),mouseOnly:!0,move:!1,restMs:k.type===void 0?R:void 0,delay:{close:g},triggerElementRef:s,externalTree:N,isActiveTrigger:b,isClosing:n(()=>c.select("transitionStatus")==="ending","isClosing")}),ye=nr(T,c.select("lastOpenChangeReason")),j=it(p,{enabled:!K&&k.type!=="context-menu",event:T&&$?"click":"mousedown",toggle:!0,ignoreMouse:!1,stickIfOpen:k.type===void 0?ye:!1}),re=zo(p,{enabled:!K&&ie}),ae=Un({open:T,enabled:$,mouseDownAction:"open"}),Re=X.useMemo(()=>he(re.reference,j.reference),[re.reference,j.reference]),xe=c.useState("triggerProps",Y),{preFocusGuardRef:se,handlePreFocusGuardFocus:ue,handleFocusTargetFocus:_e}=Qo(c,s),Pe={disabled:K,open:T},le=[ne,o,Q,F,s],De=[Re,ge??ce,xe,{"aria-haspopup":"menu","aria-controls":V,id:h,onMouseDown:n(L=>{if(c.select("open"))return;ve.start(200,()=>{c.context.allowMouseUpTriggerRef.current=!0}),We(L.currentTarget).addEventListener("mouseup",de,{once:!0})},"onMouseDown")},$?{role:"menuitem"}:{},ae,v,w],Ae=E("button",e,{enabled:!$,stateAttributesMapping:Gt,state:Pe,ref:le,props:De});return $?(0,we.jsx)(Ln,{tag:"button",render:i,className:u,style:a,state:Pe,refs:le,props:De,stateAttributesMapping:Gt}):T?(0,we.jsxs)(X.Fragment,{children:[(0,we.jsx)(Ut,{ref:se,onFocus:ue},`${h}-pre-focus-guard`),(0,we.jsx)(X.Fragment,{children:Ae},h),(0,we.jsx)(Ut,{ref:c.context.triggerFocusTargetRef,onFocus:_e},`${h}-post-focus-guard`)]}):(0,we.jsx)(X.Fragment,{children:Ae},h)},"MenuTrigger"));uo.displayName="MenuTrigger";function nr(t,e){let o=Se(),[i,u]=X.useState(!1);return me(()=>{t&&e==="trigger-hover"?(u(!0),o.start(500,()=>{u(!1)})):t||(o.clear(),u(!1))},[t,e,o]),i}n(nr,"useStickIfOpen");function rr(){let t=be(!0),e=O(!0),o=kt(!0);return X.useMemo(()=>o?{type:"menubar",context:o}:t&&!e?{type:"context-menu",context:t}:{type:void 0},[t,e,o])}n(rr,"useMenuParent");var Hn=f(C(),1);var Gn=(function(t){return t.popupWidth="--popup-width",t.popupHeight="--popup-height",t})({});var sr={activationDirection:n(t=>t?{"data-activation-direction":t}:null,"activationDirection")},co=Hn.forwardRef(n(function(e,o){let{render:i,className:u,style:a,children:d,...l}=e,{store:r}=O(),{side:m}=W(),R=r.useState("instantType"),{children:g,state:x}=dn({store:r,side:m,cssVars:Gn,children:d}),M={activationDirection:x.activationDirection,transitioning:x.transitioning,instant:R};return E("div",e,{state:M,ref:o,props:[l,{children:g}],stateAttributesMapping:sr})},"MenuViewport"));co.displayName="MenuViewport";var Ie=f(C(),1);var po=Ie.forwardRef(n(function(e,o){let{render:i,className:u,style:a,label:d,id:l,nativeButton:r=!1,openOnHover:m=!0,delay:R=100,closeDelay:g=0,disabled:x=!1,...M}=e,v=pe({label:d}),S=W(),{store:c}=O(),h=ee(l),b=c.useState("open"),p=c.useState("floatingRootContext"),T=c.useState("floatingTreeRoot"),V=c.useState("triggerPopupId",h),s=Vo(h,c),k=Ie.useCallback(j=>{let re=s(j);return j!==null&&c.select("open")&&c.select("activeTriggerId")==null&&c.update({activeTriggerId:h,activeTriggerElement:j,closeDelay:g}),re},[s,g,c,h]),P=Ie.useRef(null),H=Ie.useCallback(j=>{P.current=j,c.set("activeTriggerElement",j)},[c]),N=At();if(!N?.parentMenu)throw new Error("Base UI: <Menu.SubmenuTrigger> must be placed in <Menu.SubmenuRoot>.");c.useSyncedValue("closeDelay",g);let _=N.parentMenu,D=c.useState("disabled"),F=_.useState("disabled"),Y=x||D||F;me(()=>{let j=P.current;if(j&&xn(j)&&!Y){let re=xo.captureOwnerStack?.()||"";Ro(`A disabled element was detected on <Menu.SubmenuTrigger>. To properly disable the trigger, use the \`disabled\` prop on the component instead of setting it on the rendered element.${re}`)}});let $=_.useState("itemProps"),q=_.useState("isActive",v.index),K=Ie.useMemo(()=>({type:"submenu-trigger",setActive(){_.select("highlightItemOnHover")&&_.set("activeIndex",v.index)}}),[_,v.index]),{getItemProps:w,itemRef:Q}=Ne({closeOnClick:!1,disabled:Y,highlighted:q,id:h,store:c,typingRef:_.context.typingRef,nativeButton:r,itemMetadata:K,nodeId:S?.context.nodeId}),ne=c.useState("hoverEnabled"),ve=at(p,{enabled:ne&&m&&!Y,handleClose:ut({blockPointerEvents:!0}),mouseOnly:!0,move:!0,restMs:R,delay:{open:R,close:g},shouldOpen:R>0?()=>_.select("allowMouseEnter"):void 0,triggerElementRef:P,externalTree:T,isClosing:n(()=>c.select("transitionStatus")==="ending","isClosing")}),ie=it(p,{enabled:!Y,event:"mousedown",toggle:!m,ignoreMouse:m,stickIfOpen:!1}).reference??ce,fe=c.useState("triggerProps",!0);return delete fe.id,E("div",e,{state:{disabled:Y,highlighted:q,open:b},stateAttributesMapping:qo,props:[ie,ve,fe,$,{"aria-controls":V,tabIndex:b||q?0:-1,onBlur(){q&&_.set("activeIndex",null)}},M,w],ref:[o,v.ref,Q,k,H]})},"MenuSubmenuTrigger"));po.displayName="MenuSubmenuTrigger";var Qe=class{static{n(this,"MenuHandle")}constructor(){this.store=new ze}open(e){let o=e?this.store.context.triggerElements.getById(e):void 0;if(e&&!o)throw new Error(`Base UI: MenuHandle.open: No trigger found with id "${e}".`);this.store.setOpen(!0,J("imperative-action",void 0,o))}close(){this.store.setOpen(!1,J("imperative-action",void 0,void 0))}get isOpen(){return this.store.select("open")}};function jn(){return new Qe}n(jn,"createMenuHandle");var oe=f(Qn(),1);function Dc(t){let e=(0,ke.c)(4),o;e[0]!==t?({...o}=t,e[0]=t,e[1]=o):o=e[1];let i;return e[2]!==o?(i=(0,oe.jsxDEV)(te.Root,{"data-slot":"dropdown-menu",...o},void 0,!1),e[2]=o,e[3]=i):i=e[3],i}n(Dc,"DropdownMenu");function Ac(t){let e=(0,ke.c)(4),o;e[0]!==t?({...o}=t,e[0]=t,e[1]=o):o=e[1];let i;return e[2]!==o?(i=(0,oe.jsxDEV)(te.Trigger,{"data-slot":"dropdown-menu-trigger",...o},void 0,!1),e[2]=o,e[3]=i):i=e[3],i}n(Ac,"DropdownMenuTrigger");function Vc({align:t="start",alignOffset:e=0,side:o="bottom",sideOffset:i=4,className:u,...a}){return(0,oe.jsxDEV)(te.Portal,{children:(0,oe.jsxDEV)(te.Positioner,{className:"isolate z-50 outline-none",align:t,alignOffset:e,side:o,sideOffset:i,children:(0,oe.jsxDEV)(te.Popup,{"data-slot":"dropdown-menu-content",className:Ve("z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-start-2 data-[side=inline-start]:slide-in-from-end-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95 animate-none! relative bg-popover before:pointer-events-none before:absolute before:inset-0 before:-z-1 before:rounded-[inherit] **:data-[slot$=-item]:focus:bg-foreground/10 **:data-[slot$=-item]:data-highlighted:bg-foreground/10 **:data-[slot$=-separator]:bg-foreground/5 **:data-[slot$=-trigger]:focus:bg-foreground/10 **:data-[slot$=-trigger]:aria-expanded:bg-foreground/10! **:data-[variant=destructive]:focus:bg-foreground/10! **:data-[variant=destructive]:text-accent-foreground! **:data-[variant=destructive]:**:text-accent-foreground!",u),...a},void 0,!1)},void 0,!1)},void 0,!1)}n(Vc,"DropdownMenuContent");function Bc(t){let e=(0,ke.c)(4),o;e[0]!==t?({...o}=t,e[0]=t,e[1]=o):o=e[1];let i;return e[2]!==o?(i=(0,oe.jsxDEV)(te.Group,{"data-slot":"dropdown-menu-group",...o},void 0,!1),e[2]=o,e[3]=i):i=e[3],i}n(Bc,"DropdownMenuGroup");function Fc(t){let e=(0,ke.c)(10),o,i,u;e[0]!==t?({className:o,inset:i,...u}=t,e[0]=t,e[1]=o,e[2]=i,e[3]=u):(o=e[1],i=e[2],u=e[3]);let a;e[4]!==o?(a=Ve("px-2 py-2 text-xs text-muted-foreground data-inset:ps-7",o),e[4]=o,e[5]=a):a=e[5];let d;return e[6]!==i||e[7]!==u||e[8]!==a?(d=(0,oe.jsxDEV)(te.GroupLabel,{"data-slot":"dropdown-menu-label","data-inset":i,className:a,...u},void 0,!1),e[6]=i,e[7]=u,e[8]=a,e[9]=d):d=e[9],d}n(Fc,"DropdownMenuLabel");function Lc({className:t,inset:e,variant:o="default",...i}){return(0,oe.jsxDEV)(te.Item,{"data-slot":"dropdown-menu-item","data-inset":e,"data-variant":o,className:Ve("group/dropdown-menu-item relative flex cursor-default items-center gap-2 rounded-md px-2 py-2 text-xs outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:ps-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",t),...i},void 0,!1)}n(Lc,"DropdownMenuItem");function Uc(t){let e=(0,ke.c)(15),o,i,u,a,d;e[0]!==t?({className:u,children:i,checked:o,inset:a,...d}=t,e[0]=t,e[1]=o,e[2]=i,e[3]=u,e[4]=a,e[5]=d):(o=e[1],i=e[2],u=e[3],a=e[4],d=e[5]);let l;e[6]!==u?(l=Ve("relative flex cursor-default items-center gap-2 rounded-md py-2 pe-8 ps-2 text-xs outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:ps-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",u),e[6]=u,e[7]=l):l=e[7];let r;e[8]===Symbol.for("react.memo_cache_sentinel")?(r=(0,oe.jsxDEV)("span",{className:"pointer-events-none absolute end-2 flex items-center justify-center","data-slot":"dropdown-menu-checkbox-item-indicator",children:(0,oe.jsxDEV)(te.CheckboxItemIndicator,{children:(0,oe.jsxDEV)(mn,{icon:ln,strokeWidth:2},void 0,!1)},void 0,!1)},void 0,!1),e[8]=r):r=e[8];let m;return e[9]!==o||e[10]!==i||e[11]!==a||e[12]!==d||e[13]!==l?(m=(0,oe.jsxDEV)(te.CheckboxItem,{"data-slot":"dropdown-menu-checkbox-item","data-inset":a,className:l,checked:o,...d,children:[r,i]},void 0,!0),e[9]=o,e[10]=i,e[11]=a,e[12]=d,e[13]=l,e[14]=m):m=e[14],m}n(Uc,"DropdownMenuCheckboxItem");function Gc(t){let e=(0,ke.c)(8),o,i;e[0]!==t?({className:o,...i}=t,e[0]=t,e[1]=o,e[2]=i):(o=e[1],i=e[2]);let u;e[3]!==o?(u=Ve("-mx-1 h-px bg-border",o),e[3]=o,e[4]=u):u=e[4];let a;return e[5]!==i||e[6]!==u?(a=(0,oe.jsxDEV)(te.Separator,{"data-slot":"dropdown-menu-separator",className:u,...i},void 0,!1),e[5]=i,e[6]=u,e[7]=a):a=e[7],a}n(Gc,"DropdownMenuSeparator");export{Dc as a,Ac as b,Vc as c,Bc as d,Fc as e,Lc as f,Uc as g,Gc as h};
@@ -0,0 +1,6 @@
1
+ import{a as M,b as E,c as O,d as B,e as I,f as $,g as R,h as J}from"./chunk-LNZIB2MD.js";import{a as q}from"./chunk-AHILM3ZP.js";import{a as U}from"./chunk-YBGC4PPD.js";import{d as k,j as A,m as V}from"./chunk-E75ANNWX.js";import{a as C,e as j,f as z,g as K,h as P}from"./chunk-RRCPZMC2.js";var T=j(K(),1),H=j(z(),1);var a=j(P(),1);var D="inline-flex items-center gap-1 rounded-md border border-border px-2.5 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50",W=/["\n,]/u,G=C(o=>{if(o==null)return"";let e;return typeof o=="string"?e=o:typeof o=="number"||typeof o=="boolean"||typeof o=="bigint"?e=String(o):e=JSON.stringify(o),W.test(e)?`"${e.replaceAll('"','""')}"`:e},"csvCell"),X=C((o,e)=>{let l=o.map(n=>G(n)).join(","),s=e.map(n=>o.map(t=>G(n[t])).join(","));return[l,...s].join(`
2
+ `)},"toCsv"),Y=C(o=>JSON.stringify(o,null,2),"toJson"),Q=500,F=C(o=>`"${o.replaceAll('"','""')}"`,"sqlIdentifier"),Z=C(o=>o==null?"NULL":typeof o=="number"?Number.isFinite(o)?String(o):"NULL":typeof o=="bigint"?String(o):typeof o=="boolean"?o?"1":"0":`'${(typeof o=="string"?o:JSON.stringify(o)).replaceAll("'","''")}'`,"sqlLiteral"),ee=C((o,e,l)=>{if(e.length===0||l.length===0)return"";let s=e.map(t=>F(t)).join(", "),n=[];for(let t=0;t<l.length;t+=Q){let r=l.slice(t,t+Q).map(m=>` (${e.map(i=>Z(m[i])).join(", ")})`).join(`,
3
+ `);n.push(`INSERT INTO ${F(o)} (${s}) VALUES
4
+ ${r};`)}return n.join(`
5
+
6
+ `)},"toSql"),_=C((o,e,l)=>{if(!("document"in globalThis))return;let s=globalThis.URL.createObjectURL(new globalThis.Blob([e],{type:l})),n=globalThis.document.createElement("a");n.href=s,n.download=o,globalThis.document.body.append(n),n.click(),n.remove(),globalThis.URL.revokeObjectURL(s)},"downloadFile"),te=C(o=>{let e=(0,T.c)(36),{columns:l,name:s,rows:n}=o,t=k(),r;e[0]!==l||e[1]!==s||e[2]!==n?(r=C(()=>{_(`${s}.csv`,X(l,n),"text/csv;charset=utf-8")},"t1"),e[0]=l,e[1]=s,e[2]=n,e[3]=r):r=e[3];let m=r,i;e[4]!==s||e[5]!==n?(i=C(()=>{_(`${s}.json`,Y(n),"application/json")},"t2"),e[4]=s,e[5]=n,e[6]=i):i=e[6];let f=i,d;e[7]!==l||e[8]!==s||e[9]!==n?(d=C(()=>{_(`${s}.sql`,ee(s,l,n),"application/sql;charset=utf-8")},"t3"),e[7]=l,e[8]=s,e[9]=n,e[10]=d):d=e[10];let p=d,c=n.length===0,u;e[11]!==c?(u=(0,a.jsxDEV)(E,{className:D,"data-testid":"grid-export",disabled:c,title:"Exports only the rows loaded on the current page, not the whole table",children:"Export page"},void 0,!1),e[11]=c,e[12]=u):u=e[12];let v;e[13]===Symbol.for("react.memo_cache_sentinel")?(v=(0,a.jsxDEV)(I,{children:"Export loaded rows"},void 0,!1),e[13]=v):v=e[13];let g;e[14]!==t?(g=t("CSV"),e[14]=t,e[15]=g):g=e[15];let b;e[16]!==m||e[17]!==g?(b=(0,a.jsxDEV)($,{"data-testid":"grid-export-csv",onClick:m,children:g},void 0,!1),e[16]=m,e[17]=g,e[18]=b):b=e[18];let h;e[19]!==t?(h=t("JSON"),e[19]=t,e[20]=h):h=e[20];let x;e[21]!==f||e[22]!==h?(x=(0,a.jsxDEV)($,{"data-testid":"grid-export-json",onClick:f,children:h},void 0,!1),e[21]=f,e[22]=h,e[23]=x):x=e[23];let y;e[24]!==t?(y=t("SQL"),e[24]=t,e[25]=y):y=e[25];let w;e[26]!==p||e[27]!==y?(w=(0,a.jsxDEV)($,{"data-testid":"grid-export-sql",onClick:p,children:y},void 0,!1),e[26]=p,e[27]=y,e[28]=w):w=e[28];let S;e[29]!==x||e[30]!==w||e[31]!==b?(S=(0,a.jsxDEV)(O,{align:"end",children:[v,b,x,w]},void 0,!0),e[29]=x,e[30]=w,e[31]=b,e[32]=S):S=e[32];let N;return e[33]!==S||e[34]!==u?(N=(0,a.jsxDEV)(M,{children:[u,S]},void 0,!0),e[33]=S,e[34]=u,e[35]=N):N=e[35],N},"ExportMenu"),le=C(o=>{let e=(0,T.c)(9),{column:l}=o,s;e[0]!==l?(s=C(()=>{l.toggleVisibility()},"t1"),e[0]=l,e[1]=s):s=e[1];let n=s,t;e[2]!==l?(t=l.getIsVisible(),e[2]=l,e[3]=t):t=e[3];let r=`grid-column-${l.id}`,m;return e[4]!==l.id||e[5]!==n||e[6]!==t||e[7]!==r?(m=(0,a.jsxDEV)(R,{checked:t,closeOnClick:!1,"data-testid":r,onCheckedChange:n,children:l.id},void 0,!1),e[4]=l.id,e[5]=n,e[6]=t,e[7]=r,e[8]=m):m=e[8],m},"ColumnToggle"),oe=C(o=>{let e=(0,T.c)(30),{table:l}=o,s=k(),n;e[0]!==l?(n=l.getIsAllColumnsVisible(),e[0]=l,e[1]=n):n=e[1];let t=n,r;e[2]!==t||e[3]!==l?(r=C(()=>{l.toggleAllColumnsVisible(!t)},"t2"),e[2]=t,e[3]=l,e[4]=r):r=e[4];let m=r,i;e[5]!==s?(i=s("Columns"),e[5]=s,e[6]=i):i=e[6];let f;e[7]!==i?(f=(0,a.jsxDEV)(E,{className:D,"data-testid":"grid-columns",children:i},void 0,!1),e[7]=i,e[8]=f):f=e[8];let d;e[9]!==s?(d=s("Columns"),e[9]=s,e[10]=d):d=e[10];let p;e[11]!==d?(p=(0,a.jsxDEV)(I,{children:d},void 0,!1),e[11]=d,e[12]=p):p=e[12];let c;e[13]!==t||e[14]!==s?(c=s(t?"Hide all":"Show all"),e[13]=t,e[14]=s,e[15]=c):c=e[15];let u;e[16]!==t||e[17]!==m||e[18]!==c?(u=(0,a.jsxDEV)(R,{checked:t,closeOnClick:!1,"data-testid":"grid-columns-all",onCheckedChange:m,children:c},void 0,!1),e[16]=t,e[17]=m,e[18]=c,e[19]=u):u=e[19];let v;e[20]===Symbol.for("react.memo_cache_sentinel")?(v=(0,a.jsxDEV)(J,{},void 0,!1),e[20]=v):v=e[20];let g;e[21]!==l?(g=l.getAllLeafColumns().map(ne),e[21]=l,e[22]=g):g=e[22];let b;e[23]!==g||e[24]!==p||e[25]!==u?(b=(0,a.jsxDEV)(O,{align:"end",className:"max-h-80 overflow-y-auto",children:(0,a.jsxDEV)(B,{children:[p,u,v,g]},void 0,!0)},void 0,!1),e[23]=g,e[24]=p,e[25]=u,e[26]=b):b=e[26];let h;return e[27]!==b||e[28]!==f?(h=(0,a.jsxDEV)(M,{children:[f,b]},void 0,!0),e[27]=b,e[28]=f,e[29]=h):h=e[29],h},"ColumnsMenu"),se=C(o=>{let e=(0,T.c)(19),{count:l,editable:s,onClear:n,onDelete:t}=o,r=k(),m;e[0]!==l||e[1]!==r?(m=r("{count} selected",{count:l}),e[0]=l,e[1]=r,e[2]=m):m=e[2];let i;e[3]!==m?(i=(0,a.jsxDEV)("span",{className:"font-medium tabular-nums","data-testid":"grid-selection-count",children:m},void 0,!1),e[3]=m,e[4]=i):i=e[4];let f;e[5]!==r?(f=r("Clear"),e[5]=r,e[6]=f):f=e[6];let d;e[7]!==n||e[8]!==f?(d=(0,a.jsxDEV)("button",{className:D,"data-testid":"grid-selection-clear",onClick:n,type:"button",children:f},void 0,!1),e[7]=n,e[8]=f,e[9]=d):d=e[9];let p;e[10]!==l||e[11]!==s||e[12]!==t||e[13]!==r?(p=s&&(0,a.jsxDEV)(U,{confirmLabel:r("Delete {count} rows?",{count:l}),onConfirm:t,testId:"grid-selection-delete",children:r("Delete {count}",{count:l})},void 0,!1),e[10]=l,e[11]=s,e[12]=t,e[13]=r,e[14]=p):p=e[14];let c;return e[15]!==i||e[16]!==d||e[17]!==p?(c=(0,a.jsxDEV)("div",{className:"flex items-center gap-2 rounded-md border border-border bg-accent/40 px-3 py-1.5 text-xs","data-testid":"grid-selection-bar",children:[i,d,p]},void 0,!0),e[15]=i,e[16]=d,e[17]=p,e[18]=c):c=e[18],c},"SelectionBar"),me=C(o=>{let e=(0,T.c)(32),{column:l,onClose:s,value:n}=o,t=k(),[r,m]=(0,H.useState)(!1),i;e[0]!==n?(i=A(n),e[0]=n,e[1]=i):i=e[1];let f=i,d;e[2]!==f?(d=C(()=>{V(f)&&m(!0)},"t2"),e[2]=f,e[3]=d):d=e[3];let p=d,c;e[4]!==t?(c=t("Cell value"),e[4]=t,e[5]=c):c=e[5];let u;e[6]!==l?(u=(0,a.jsxDEV)("h2",{className:"truncate font-mono text-sm font-semibold text-foreground",children:l},void 0,!1),e[6]=l,e[7]=u):u=e[7];let v;e[8]!==r||e[9]!==t?(v=t(r?"Copied":"Copy"),e[8]=r,e[9]=t,e[10]=v):v=e[10];let g;e[11]!==p||e[12]!==v?(g=(0,a.jsxDEV)("button",{className:D,"data-testid":"grid-cell-copy",onClick:p,type:"button",children:v},void 0,!1),e[11]=p,e[12]=v,e[13]=g):g=e[13];let b;e[14]!==t?(b=t("Close"),e[14]=t,e[15]=b):b=e[15];let h;e[16]!==s||e[17]!==b?(h=(0,a.jsxDEV)("button",{className:D,"data-testid":"grid-cell-close",onClick:s,type:"button",children:b},void 0,!1),e[16]=s,e[17]=b,e[18]=h):h=e[18];let x;e[19]!==g||e[20]!==h?(x=(0,a.jsxDEV)("div",{className:"flex items-center gap-1.5",children:[g,h]},void 0,!0),e[19]=g,e[20]=h,e[21]=x):x=e[21];let y;e[22]!==u||e[23]!==x?(y=(0,a.jsxDEV)("div",{className:"flex items-center justify-between",children:[u,x]},void 0,!0),e[22]=u,e[23]=x,e[24]=y):y=e[24];let w;e[25]!==f?(w=(0,a.jsxDEV)("pre",{className:"min-h-0 flex-1 overflow-auto rounded-md border border-border bg-muted/30 p-3 font-mono text-xs whitespace-pre-wrap","data-testid":"grid-cell-value",children:f},void 0,!1),e[25]=f,e[26]=w):w=e[26];let S;return e[27]!==s||e[28]!==y||e[29]!==w||e[30]!==c?(S=(0,a.jsxDEV)(q,{className:"max-h-[70vh] w-[min(40rem,90vw)]",label:c,onClose:s,panelTestId:"grid-cell-dialog",testId:"grid-cell-dialog-overlay",variant:"dialog",children:[y,w]},void 0,!0),e[27]=s,e[28]=y,e[29]=w,e[30]=c,e[31]=S):S=e[31],S},"CellDetailDialog"),pe=C(o=>{let e=(0,T.c)(33),{columns:l,editable:s,name:n,onBulkDelete:t,onToggleTranspose:r,rows:m,table:i,transposed:f}=o,d=k(),p;e[0]!==i?(p=i.getSelectedRowModel(),e[0]=i,e[1]=p):p=e[1];let c=p.rows,u;e[2]!==i?(u=C(()=>{i.resetRowSelection()},"t2"),e[2]=i,e[3]=u):u=e[3];let v=u,g;e[4]!==t||e[5]!==c||e[6]!==i?(g=C(()=>{t(c.map(ie)),i.resetRowSelection()},"t3"),e[4]=t,e[5]=c,e[6]=i,e[7]=g):g=e[7];let b=g,h;e[8]!==l||e[9]!==n||e[10]!==m?(h=(0,a.jsxDEV)(te,{columns:l,name:n,rows:m},void 0,!1),e[8]=l,e[9]=n,e[10]=m,e[11]=h):h=e[11];let x;e[12]!==i?(x=(0,a.jsxDEV)(oe,{table:i},void 0,!1),e[12]=i,e[13]=x):x=e[13];let y;e[14]!==d?(y=d("Swap rows and columns"),e[14]=d,e[15]=y):y=e[15];let w;e[16]!==d?(w=d("Transpose"),e[16]=d,e[17]=w):w=e[17];let S;e[18]!==r||e[19]!==y||e[20]!==w||e[21]!==f?(S=(0,a.jsxDEV)("button",{"aria-pressed":f,className:D,"data-testid":"grid-transpose",onClick:r,title:y,type:"button",children:w},void 0,!1),e[18]=r,e[19]=y,e[20]=w,e[21]=f,e[22]=S):S=e[22];let N;e[23]!==s||e[24]!==v||e[25]!==b||e[26]!==c.length?(N=c.length>0&&(0,a.jsxDEV)(se,{count:c.length,editable:s,onClear:v,onDelete:b},void 0,!1),e[23]=s,e[24]=v,e[25]=b,e[26]=c.length,e[27]=N):N=e[27];let L;return e[28]!==h||e[29]!==x||e[30]!==S||e[31]!==N?(L=(0,a.jsxDEV)("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"grid-actions",children:[h,x,S,N]},void 0,!0),e[28]=h,e[29]=x,e[30]=S,e[31]=N,e[32]=L):L=e[32],L},"GridActionsBar");function ne(o){return(0,a.jsxDEV)(le,{column:o},o.id,!1)}C(ne,"_temp");function ie(o){return o.id}C(ie,"_temp2");export{te as a,se as b,me as c,pe as d};
@@ -0,0 +1 @@
1
+ import{a as A}from"./chunk-RHZ4M2NZ.js";import{a as y,e as I}from"./chunk-SEU5V7I6.js";import{b as m}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as k}from"./chunk-XLXNLJ4N.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as C}from"./chunk-E75ANNWX.js";import"./chunk-JHKMUTIF.js";import{a as u,e as w,g as S,h as P}from"./chunk-RRCPZMC2.js";var N=w(S(),1);var a=w(P(),1);var z=[{key:"accounts",label:"Accounts"},{key:"admin",label:"Admin"},{key:"organization",label:"Organizations"},{key:"passkey",label:"Passkeys"},{key:"twoFactor",label:"Two-factor"}],b=u(e=>{if(e===void 0)return"\u2014";let l=[[86400,"d"],[3600,"h"],[60,"m"]];for(let[t,o]of l)if(e>=t&&e%t===0)return`${String(e/t)}${o}`;return`${String(e)}s`},"formatDuration"),h=u(e=>{let l=(0,N.c)(8),{children:t,heading:o,testId:r}=e,i;l[0]!==o?(i=(0,a.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o},void 0,!1)},void 0,!1),l[0]=o,l[1]=i):i=l[1];let s;l[2]!==t?(s=(0,a.jsxDEV)(I,{className:"p-3",children:t},void 0,!1),l[2]=t,l[3]=s):s=l[3];let c;return l[4]!==i||l[5]!==s||l[6]!==r?(c=(0,a.jsxDEV)(y,{className:"gap-0 py-0","data-testid":r,children:[i,s]},void 0,!0),l[4]=i,l[5]=s,l[6]=r,l[7]=c):c=l[7],c},"ConfigCard"),d=u(e=>{let l=(0,N.c)(7),{label:t,value:o}=e,r;l[0]!==t?(r=(0,a.jsxDEV)("span",{className:"text-sm",children:t},void 0,!1),l[0]=t,l[1]=r):r=l[1];let i;l[2]!==o?(i=(0,a.jsxDEV)("span",{className:"text-sm text-muted-foreground tabular-nums",children:o},void 0,!1),l[2]=o,l[3]=i):i=l[3];let s;return l[4]!==r||l[5]!==i?(s=(0,a.jsxDEV)("div",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs",children:[r,i]},void 0,!0),l[4]=r,l[5]=i,l[6]=s):s=l[6],s},"KeyValue"),O=u(()=>{let e=(0,N.c)(20),l=k(),t=C(),o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-auth-config"],e[0]=o):o=e[0];let r;e[1]!==l?(r=u(()=>l.getAuthConfig(),"t1"),e[1]=l,e[2]=r):r=e[2];let{data:i,error:s}=A(o,r),c;e[3]!==t?(c=u(n=>(0,a.jsxDEV)(m,{variant:n?"success":"outline",children:t(n?"Enabled":"Disabled")},void 0,!1),"t2"),e[3]=t,e[4]=c):c=e[4];let f=c,g;e[5]!==s?(g=s!==null&&(0,a.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"auth-config-error",role:"alert",children:s},void 0,!1),e[5]=s,e[6]=g):g=e[6];let p;e[7]!==i||e[8]!==s||e[9]!==t?(p=s===null&&i===void 0&&(0,a.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"auth-config-loading",children:t("Loading auth configuration\u2026")},void 0,!1),e[7]=i,e[8]=s,e[9]=t,e[10]=p):p=e[10];let v;e[11]!==i||e[12]!==s||e[13]!==f||e[14]!==t?(v=s===null&&i!==void 0&&(0,a.jsxDEV)(a.Fragment,{children:[(0,a.jsxDEV)(h,{heading:t("Enabled capabilities"),testId:"auth-config-capabilities",children:(0,a.jsxDEV)("ul",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:z.map(n=>{let $=i.capabilities[n.key];return(0,a.jsxDEV)("li",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs","data-testid":`auth-config-cap-${n.key}`,children:[(0,a.jsxDEV)("span",{className:"text-sm",children:t(n.label)},void 0,!1),f($)]},n.key,!0)})},void 0,!1)},void 0,!1),(0,a.jsxDEV)(h,{heading:t("Plugins"),testId:"auth-config-plugins",children:i.plugins.length===0?(0,a.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:t("No plugins enabled.")},void 0,!1):(0,a.jsxDEV)("div",{className:"flex flex-wrap gap-2",children:i.plugins.map(L)},void 0,!1)},void 0,!1),(0,a.jsxDEV)(h,{heading:t("Sign-in methods"),testId:"auth-config-signin",children:(0,a.jsxDEV)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxDEV)(d,{label:t("Email & password"),value:f(i.emailAndPassword)},void 0,!1),(0,a.jsxDEV)(d,{label:t("Social providers"),value:i.socialProviders.length===0?t("None"):(0,a.jsxDEV)("span",{className:"flex flex-wrap justify-end gap-1",children:i.socialProviders.map(j)},void 0,!1)},void 0,!1)]},void 0,!0)},void 0,!1),i.organization.enabled&&(0,a.jsxDEV)(h,{heading:t("Organizations"),testId:"auth-config-org",children:(0,a.jsxDEV)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxDEV)(d,{label:t("Teams"),value:f(i.organization.teams)},void 0,!1),(0,a.jsxDEV)(d,{label:t("Custom roles"),value:f(i.organization.roles)},void 0,!1)]},void 0,!0)},void 0,!1),(0,a.jsxDEV)(h,{heading:t("Session policy"),testId:"auth-config-session",children:(0,a.jsxDEV)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxDEV)(d,{label:t("Expires in"),value:b(i.session.expiresIn)},void 0,!1),(0,a.jsxDEV)(d,{label:t("Refresh after"),value:b(i.session.updateAge)},void 0,!1),(0,a.jsxDEV)(d,{label:t("Fresh window"),value:b(i.session.freshAge)},void 0,!1),(0,a.jsxDEV)(d,{label:t("Cookie cache"),value:f(i.session.cookieCache===!0)},void 0,!1)]},void 0,!0)},void 0,!1),(0,a.jsxDEV)(h,{heading:t("Rate limit"),testId:"auth-config-ratelimit",children:(0,a.jsxDEV)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxDEV)(d,{label:t("Status"),value:f(i.rateLimit.enabled)},void 0,!1),i.rateLimit.enabled&&(0,a.jsxDEV)(a.Fragment,{children:[(0,a.jsxDEV)(d,{label:t("Max requests"),value:i.rateLimit.max??"\u2014"},void 0,!1),(0,a.jsxDEV)(d,{label:t("Window"),value:b(i.rateLimit.window)},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1),i.userFields.length>0&&(0,a.jsxDEV)(h,{heading:t("Plugin user fields"),testId:"auth-config-user-fields",children:(0,a.jsxDEV)("ul",{className:"flex flex-col gap-2",children:i.userFields.map(n=>(0,a.jsxDEV)("li",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs","data-testid":`auth-config-user-field-${n.name}`,children:[(0,a.jsxDEV)("span",{className:"flex flex-col",children:[(0,a.jsxDEV)("span",{className:"font-mono text-xs",children:n.name},void 0,!1),n.plugin!==void 0&&(0,a.jsxDEV)("span",{className:"text-[11px] text-muted-foreground",children:n.plugin},void 0,!1)]},void 0,!0),(0,a.jsxDEV)("span",{className:"flex items-center gap-1",children:[(0,a.jsxDEV)(m,{variant:"outline",children:n.type},void 0,!1),n.required&&(0,a.jsxDEV)(m,{variant:"secondary",children:t("required")},void 0,!1),n.unique&&(0,a.jsxDEV)(m,{variant:"secondary",children:t("unique")},void 0,!1)]},void 0,!0)]},n.name,!0))},void 0,!1)},void 0,!1),(0,a.jsxDEV)(y,{className:"gap-0 py-0",children:(0,a.jsxDEV)("p",{className:"px-4 py-3 text-xs text-muted-foreground","data-testid":"auth-config-note",children:t("OAuth providers, email templates, and rate limits are configured at deploy time in the better-auth setup and aren't editable here. See the Mail tab for email output.")},void 0,!1)},void 0,!1)]},void 0,!0),e[11]=i,e[12]=s,e[13]=f,e[14]=t,e[15]=v):v=e[15];let x;return e[16]!==g||e[17]!==p||e[18]!==v?(x=(0,a.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"auth-config",children:[g,p,v]},void 0,!0),e[16]=g,e[17]=p,e[18]=v,e[19]=x):x=e[19],x},"AuthConfigPanel");function L(e){return(0,a.jsxDEV)(m,{"data-testid":`auth-config-plugin-${e}`,variant:"outline",children:e},e,!1)}u(L,"_temp");function j(e){return(0,a.jsxDEV)(m,{"data-testid":`auth-config-provider-${e}`,variant:"outline",children:e},e,!1)}u(j,"_temp2");export{O as AuthConfigPanel};
@@ -0,0 +1 @@
1
+ import{a as dt,b as nt,c as ct,d as ut,e as Me}from"./chunk-VON7JUPG.js";import{a as ft,b as mt,c as vt,d as ht,e as gt}from"./chunk-KBB75WNT.js";import"./chunk-DWDILV2E.js";import"./chunk-QBAT52GB.js";import{e as ot}from"./chunk-TQ36RWOP.js";import"./chunk-QAFAJBAW.js";import{a as it}from"./chunk-UGUEC6BC.js";import"./chunk-KSKXW5PX.js";import"./chunk-5OIBXYZM.js";import"./chunk-L7SK4ZZD.js";import"./chunk-6HSHEMZV.js";import"./chunk-BJGBHGK3.js";import"./chunk-ZIGWVHCS.js";import{a as rt}from"./chunk-2K47A3P6.js";import"./chunk-KEGAWN6Y.js";import{a as st,b as lt,c as at,d as je,e as $e,f as Te}from"./chunk-GTM65MVX.js";import"./chunk-4QHKBC77.js";import{a as tt}from"./chunk-UKDJ4H7I.js";import{a as Ze,b as et}from"./chunk-TBMYIZIO.js";import"./chunk-3CJW6NWG.js";import{c as Oe}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as Pe}from"./chunk-BOXSWNXZ.js";import{b as Ye}from"./chunk-RHZ4M2NZ.js";import{a as B,b as Re,c as _e,d as Ve,e as P}from"./chunk-SEU5V7I6.js";import{b as Ke}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as Ue}from"./chunk-XLXNLJ4N.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as Qe,e as Ge,f as Je,g as We,k as Xe,n as Ae}from"./chunk-E75ANNWX.js";import"./chunk-JHKMUTIF.js";import{a as n,e as Be,f as pt,g as xt,h as bt}from"./chunk-RRCPZMC2.js";var Le=Be(xt(),1);var v=Be(pt(),1);var t=Be(bt(),1);var ze=n(l=>l>=100?"critical":l>=50?"warning":"good","performanceLevel"),He=n(l=>l<1?`${(l*1e3).toFixed(0)}\u03BCs`:l<1e3?`${l.toFixed(1)}ms`:`${(l/1e3).toFixed(2)}s`,"formatLatency"),Ee=n(l=>l>=1e9?`${(l/1e9).toFixed(1)}B`:l>=1e6?`${(l/1e6).toFixed(1)}M`:l>=1e3?`${(l/1e3).toFixed(1)}K`:l.toLocaleString(),"formatCount"),Nt=n(l=>{let e=(0,Le.c)(3),{level:s}=l;if(s==="critical"){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsxDEV)(Ke,{variant:"destructive",children:"Slow"},void 0,!1),e[0]=i):i=e[0],i}if(s==="warning"){let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsxDEV)("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning",children:"Moderate"},void 0,!1),e[1]=i):i=e[1],i}let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsxDEV)("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-success/10 px-2 py-0.5 text-xs font-medium text-success",children:"Fast"},void 0,!1),e[2]=r):r=e[2],r},"PerformanceBadge"),yt=n(l=>{let e=(0,Le.c)(152),{queryStats:s}=l,r=Qe(),[i,Q]=(0,v.useState)("totalTime"),C;e[0]===Symbol.for("react.memo_cache_sentinel")?(C=new Set,e[0]=C):C=e[0];let[h,T]=(0,v.useState)(C),p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=n(o=>{o!==null&&Q(o)},"t2"),e[1]=p):p=e[1];let S=p,u;if(e[2]!==s||e[3]!==i){u=[...s];let o;e[5]!==i?(o=n((m,c)=>{switch(i){case"avgTime":return c.avgDurationMs-m.avgDurationMs;case"execCount":return c.execCount-m.execCount;case"rowsRead":return c.rowsRead-m.rowsRead;default:return c.totalDurationMs-m.totalDurationMs}},"t310"),e[5]=i,e[6]=o):o=e[6],u.sort(o),e[2]=s,e[3]=i,e[4]=u}else u=e[4];let g=u,$;e[7]!==s?($=s.filter(St),e[7]=s,e[8]=$):$=e[8];let j=$.length,H;e[9]!==s?(H=s.filter(wt),e[9]=s,e[10]=H):H=e[10];let d=H.length,_;e[11]!==s?(_=s.filter(qt),e[11]=s,e[12]=_):_=e[12];let U=_.length,O;e[13]===Symbol.for("react.memo_cache_sentinel")?(O=n(o=>{T(m=>{let c=new Set(m);return c.has(o)?c.delete(o):c.add(o),c})},"t6"),e[13]=O):O=e[13];let Fe=O;if(s.length===0){let o;e[14]!==r?(o=r("No query insights yet"),e[14]=r,e[15]=o):o=e[15];let m;e[16]!==o?(m=(0,t.jsxDEV)("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:o},void 0,!1),e[16]=o,e[17]=m):m=e[17];let c;e[18]!==r?(c=r("Query insights appear once statements are executed against this shard."),e[18]=r,e[19]=c):c=e[19];let z;e[20]!==c?(z=(0,t.jsxDEV)("p",{className:"mt-1 text-sm",children:c},void 0,!1),e[20]=c,e[21]=z):z=e[21];let ke;return e[22]!==z||e[23]!==m?(ke=(0,t.jsxDEV)(B,{children:(0,t.jsxDEV)(P,{className:"py-12",children:(0,t.jsxDEV)("div",{className:"text-center text-muted-foreground",children:[m,z]},void 0,!0)},void 0,!1)},void 0,!1),e[22]=z,e[23]=m,e[24]=ke):ke=e[24],ke}let I;e[25]!==r?(I=r("Critical queries"),e[25]=r,e[26]=I):I=e[26];let f;e[27]!==I?(f=(0,t.jsxDEV)(Re,{className:"pb-2",children:(0,t.jsxDEV)(_e,{className:"text-sm font-medium",children:I},void 0,!1)},void 0,!1),e[27]=I,e[28]=f):f=e[28];let M;e[29]!==j?(M=(0,t.jsxDEV)("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:j},void 0,!1),e[29]=j,e[30]=M):M=e[30];let D;e[31]!==r?(D=r(">100ms avg execution"),e[31]=r,e[32]=D):D=e[32];let R;e[33]!==D?(R=(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:D},void 0,!1),e[33]=D,e[34]=R):R=e[34];let F;e[35]!==R||e[36]!==M?(F=(0,t.jsxDEV)(P,{children:[M,R]},void 0,!0),e[35]=R,e[36]=M,e[37]=F):F=e[37];let b;e[38]!==F||e[39]!==f?(b=(0,t.jsxDEV)(B,{children:[f,F]},void 0,!0),e[38]=F,e[39]=f,e[40]=b):b=e[40];let N;e[41]!==r?(N=r("Moderate queries"),e[41]=r,e[42]=N):N=e[42];let k;e[43]!==N?(k=(0,t.jsxDEV)(Re,{className:"pb-2",children:(0,t.jsxDEV)(_e,{className:"text-sm font-medium",children:N},void 0,!1)},void 0,!1),e[43]=N,e[44]=k):k=e[44];let A;e[45]!==d?(A=(0,t.jsxDEV)("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:d},void 0,!1),e[45]=d,e[46]=A):A=e[46];let E;e[47]!==r?(E=r("50\u2013100ms avg execution"),e[47]=r,e[48]=E):E=e[48];let L;e[49]!==E?(L=(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:E},void 0,!1),e[49]=E,e[50]=L):L=e[50];let a;e[51]!==A||e[52]!==L?(a=(0,t.jsxDEV)(P,{children:[A,L]},void 0,!0),e[51]=A,e[52]=L,e[53]=a):a=e[53];let w;e[54]!==k||e[55]!==a?(w=(0,t.jsxDEV)(B,{children:[k,a]},void 0,!0),e[54]=k,e[55]=a,e[56]=w):w=e[56];let x;e[57]!==r?(x=r("Fast queries"),e[57]=r,e[58]=x):x=e[58];let y;e[59]!==x?(y=(0,t.jsxDEV)(Re,{className:"pb-2",children:(0,t.jsxDEV)(_e,{className:"text-sm font-medium",children:x},void 0,!1)},void 0,!1),e[59]=x,e[60]=y):y=e[60];let K;e[61]!==U?(K=(0,t.jsxDEV)("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:U},void 0,!1),e[61]=U,e[62]=K):K=e[62];let V;e[63]!==r?(V=r("<50ms avg execution"),e[63]=r,e[64]=V):V=e[64];let G;e[65]!==V?(G=(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:V},void 0,!1),e[65]=V,e[66]=G):G=e[66];let J;e[67]!==K||e[68]!==G?(J=(0,t.jsxDEV)(P,{children:[K,G]},void 0,!0),e[67]=K,e[68]=G,e[69]=J):J=e[69];let W;e[70]!==y||e[71]!==J?(W=(0,t.jsxDEV)(B,{children:[y,J]},void 0,!0),e[70]=y,e[71]=J,e[72]=W):W=e[72];let X;e[73]!==b||e[74]!==w||e[75]!==W?(X=(0,t.jsxDEV)("div",{className:"grid gap-4 md:grid-cols-3",children:[b,w,W]},void 0,!0),e[73]=b,e[74]=w,e[75]=W,e[76]=X):X=e[76];let Y;e[77]!==r?(Y=r("Query leaderboard"),e[77]=r,e[78]=Y):Y=e[78];let Z;e[79]!==Y?(Z=(0,t.jsxDEV)("h3",{className:"text-lg font-semibold",children:Y},void 0,!1),e[79]=Y,e[80]=Z):Z=e[80];let ee;e[81]!==i||e[82]!==r?(ee=r("Slow queries sorted by {sortField}",{sortField:r(i)}),e[81]=i,e[82]=r,e[83]=ee):ee=e[83];let te;e[84]!==ee?(te=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:ee},void 0,!1),e[84]=ee,e[85]=te):te=e[85];let re;e[86]!==Z||e[87]!==te?(re=(0,t.jsxDEV)("div",{children:[Z,te]},void 0,!0),e[86]=Z,e[87]=te,e[88]=re):re=e[88];let se;e[89]!==r?(se=r("Sort by"),e[89]=r,e[90]=se):se=e[90];let le;e[91]!==se?(le=(0,t.jsxDEV)("span",{className:"text-sm text-muted-foreground",children:se},void 0,!1),e[91]=se,e[92]=le):le=e[92];let ae;e[93]!==r?(ae=r("Sort queries by"),e[93]=r,e[94]=ae):ae=e[94];let Ie;e[95]===Symbol.for("react.memo_cache_sentinel")?(Ie=(0,t.jsxDEV)(nt,{},void 0,!1),e[95]=Ie):Ie=e[95];let ie;e[96]!==ae?(ie=(0,t.jsxDEV)(ct,{"aria-label":ae,className:"w-[140px]","data-testid":"qi-sort",children:Ie},void 0,!1),e[96]=ae,e[97]=ie):ie=e[97];let oe;e[98]!==r?(oe=r("Total time"),e[98]=r,e[99]=oe):oe=e[99];let de;e[100]!==oe?(de=(0,t.jsxDEV)(Me,{value:"totalTime",children:oe},void 0,!1),e[100]=oe,e[101]=de):de=e[101];let ne;e[102]!==r?(ne=r("Avg time"),e[102]=r,e[103]=ne):ne=e[103];let ce;e[104]!==ne?(ce=(0,t.jsxDEV)(Me,{value:"avgTime",children:ne},void 0,!1),e[104]=ne,e[105]=ce):ce=e[105];let ue;e[106]!==r?(ue=r("Execution count"),e[106]=r,e[107]=ue):ue=e[107];let fe;e[108]!==ue?(fe=(0,t.jsxDEV)(Me,{value:"execCount",children:ue},void 0,!1),e[108]=ue,e[109]=fe):fe=e[109];let me;e[110]!==r?(me=r("Rows read"),e[110]=r,e[111]=me):me=e[111];let ve;e[112]!==me?(ve=(0,t.jsxDEV)(Me,{value:"rowsRead",children:me},void 0,!1),e[112]=me,e[113]=ve):ve=e[113];let he;e[114]!==de||e[115]!==ce||e[116]!==fe||e[117]!==ve?(he=(0,t.jsxDEV)(ut,{children:[de,ce,fe,ve]},void 0,!0),e[114]=de,e[115]=ce,e[116]=fe,e[117]=ve,e[118]=he):he=e[118];let ge;e[119]!==i||e[120]!==ie||e[121]!==he?(ge=(0,t.jsxDEV)(dt,{onValueChange:S,value:i,children:[ie,he]},void 0,!0),e[119]=i,e[120]=ie,e[121]=he,e[122]=ge):ge=e[122];let pe;e[123]!==le||e[124]!==ge?(pe=(0,t.jsxDEV)("div",{className:"flex items-center gap-2",children:[le,ge]},void 0,!0),e[123]=le,e[124]=ge,e[125]=pe):pe=e[125];let xe;e[126]!==re||e[127]!==pe?(xe=(0,t.jsxDEV)("div",{className:"flex items-center justify-between",children:[re,pe]},void 0,!0),e[126]=re,e[127]=pe,e[128]=xe):xe=e[128];let be;e[129]!==r?(be=r("Statements"),e[129]=r,e[130]=be):be=e[130];let Ne;e[131]!==be?(Ne=(0,t.jsxDEV)(_e,{children:be},void 0,!1),e[131]=be,e[132]=Ne):Ne=e[132];let ye;e[133]!==g.length||e[134]!==r?(ye=r("{count} tracked statements",{count:g.length}),e[133]=g.length,e[134]=r,e[135]=ye):ye=e[135];let Se;e[136]!==ye?(Se=(0,t.jsxDEV)(Ve,{children:ye},void 0,!1),e[136]=ye,e[137]=Se):Se=e[137];let we;e[138]!==Ne||e[139]!==Se?(we=(0,t.jsxDEV)(Re,{children:[Ne,Se]},void 0,!0),e[138]=Ne,e[139]=Se,e[140]=we):we=e[140];let qe;e[141]!==h||e[142]!==g||e[143]!==r?(qe=(0,t.jsxDEV)(P,{children:(0,t.jsxDEV)("div",{className:"space-y-2",children:g.map(o=>{let m=o.normalizedSql,c=h.has(m),z=ze(o.avgDurationMs);return(0,t.jsxDEV)("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[(0,t.jsxDEV)("button",{"aria-expanded":c,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:n(()=>{Fe(m)},"onClick"),type:"button",children:[(0,t.jsxDEV)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,t.jsxDEV)(Nt,{level:z},void 0,!1),(0,t.jsxDEV)("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:o.normalizedSql},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex shrink-0 items-center gap-4",children:[(0,t.jsxDEV)("div",{className:"text-right",children:[(0,t.jsxDEV)("div",{className:"text-sm font-medium",children:He(o.totalDurationMs)},void 0,!1),(0,t.jsxDEV)("div",{className:"text-xs text-muted-foreground",children:r("total")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"text-right",children:[(0,t.jsxDEV)("div",{className:"text-sm font-medium",children:He(o.avgDurationMs)},void 0,!1),(0,t.jsxDEV)("div",{className:"text-xs text-muted-foreground",children:r("avg")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"text-right",children:[(0,t.jsxDEV)("div",{className:"text-sm font-medium",children:Ee(o.execCount)},void 0,!1),(0,t.jsxDEV)("div",{className:"text-xs text-muted-foreground",children:r("calls")},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0),c&&(0,t.jsxDEV)("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("p",{className:"mb-2 text-sm font-medium",children:r("Full statement")},void 0,!1),(0,t.jsxDEV)("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:o.normalizedSql},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:r("Exec count")},void 0,!1),(0,t.jsxDEV)("span",{className:"block font-medium tabular-nums",children:Ee(o.execCount)},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:r("Total time")},void 0,!1),(0,t.jsxDEV)("span",{className:"block font-medium tabular-nums",children:He(o.totalDurationMs)},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:r("Rows read")},void 0,!1),(0,t.jsxDEV)("span",{className:"block font-medium tabular-nums",children:Ee(o.rowsRead)},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:r("Rows written")},void 0,!1),(0,t.jsxDEV)("span",{className:"block font-medium tabular-nums",children:Ee(o.rowsWritten)},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0)]},m,!0)})},void 0,!1)},void 0,!1),e[141]=h,e[142]=g,e[143]=r,e[144]=qe):qe=e[144];let Ce;e[145]!==we||e[146]!==qe?(Ce=(0,t.jsxDEV)(B,{children:[we,qe]},void 0,!0),e[145]=we,e[146]=qe,e[147]=Ce):Ce=e[147];let De;return e[148]!==X||e[149]!==xe||e[150]!==Ce?(De=(0,t.jsxDEV)("div",{className:"space-y-4","data-testid":"qi-root",children:[X,xe,Ce]},void 0,!0),e[148]=X,e[149]=xe,e[150]=Ce,e[151]=De):De=e[151],De},"QueryInsights");function St(l){return ze(l.avgDurationMs)==="critical"}n(St,"_temp");function wt(l){return ze(l.avgDurationMs)==="warning"}n(wt,"_temp2");function qt(l){return ze(l.avgDurationMs)==="good"}n(qt,"_temp3");var Ct=Ge(Pe.getMetrics),Tt=n(l=>{let e=Math.floor(l/1e3),s=Math.floor(e/3600),r=Math.floor(e%3600/60),i=e%60;return s>0?`${s.toString()}h ${r.toString()}m`:r>0?`${r.toString()}m ${i.toString()}s`:`${i.toString()}s`},"formatDuration"),Rt=n((l,e)=>l?e:"overview","resolveTab"),_t=n((l,e)=>{let s=l+e;return s===0?"\u2014":`${(l/s*100).toFixed(1)}%`},"hitRate"),q=n(l=>{let e=(0,Le.c)(16),{chart:s,footer:r,label:i,testId:Q,value:C}=l,h;e[0]!==i?(h=(0,t.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i},void 0,!1),e[0]=i,e[1]=h):h=e[1];let T;e[2]!==Q||e[3]!==C?(T=(0,t.jsxDEV)("span",{className:"truncate text-2xl font-semibold tabular-nums text-foreground","data-testid":Q,children:C},void 0,!1),e[2]=Q,e[3]=C,e[4]=T):T=e[4];let p;e[5]!==s||e[6]!==T?(p=(0,t.jsxDEV)("div",{className:"flex items-center justify-between gap-3",children:[T,s]},void 0,!0),e[5]=s,e[6]=T,e[7]=p):p=e[7];let S;e[8]!==h||e[9]!==p?(S=(0,t.jsxDEV)("div",{className:"flex flex-col gap-2.5 p-4",children:[h,p]},void 0,!0),e[8]=h,e[9]=p,e[10]=S):S=e[10];let u;e[11]!==r?(u=r!=null&&(0,t.jsxDEV)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:r},void 0,!1),e[11]=r,e[12]=u):u=e[12];let g;return e[13]!==S||e[14]!==u?(g=(0,t.jsxDEV)(B,{className:"justify-between gap-0 py-0",children:[S,u]},void 0,!0),e[13]=S,e[14]=u,e[15]=g):g=e[15],g},"StatCard"),Kt=n(({initialShardKey:l})=>{let e=Ue(),s=Qe(),[r,i]=(0,v.useState)(l??""),[Q,C]=(0,v.useState)("overview"),[h,T]=(0,v.useState)([]),p=(0,v.useRef)(null),S=(0,v.useRef)(null),u=(0,v.useRef)(!0);(0,v.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]);let g=rt(r.trim(),400),{data:$,error:j,liveError:H}=Ye(Pe.getMetrics,{},{live:!0,shardKey:g}),d=$??null;(0,v.useEffect)(()=>{if($===void 0)return;et(g);let a=$,w=p.current,x=S.current!==null&&S.current!==a.shard;if(S.current=a.shard,p.current=a.requests,x){T([]);return}w!==null&&a.requests>=w&&T(y=>[...y,a.requests-w].slice(-30))},[$,g]);let[_,U]=(0,v.useState)(null),[O,Fe]=(0,v.useState)(!1),I=n(async()=>{Fe(!0);let a=mt(r,Ze());try{let w=await Promise.all(a.map(async x=>{try{let y=await e.query(Ct,{},Je(x));return{error:null,metrics:y,shard:x===""?y.shard:x}}catch(y){return{error:We(y),metrics:null,shard:x===""?"__root__":x}}}));u.current&&U(w)}finally{u.current&&Fe(!1)}},"aggregateAll"),f=_===null?null:ft(_),M=d===null||d.requests===0?"\u2014":`${(d.errors/d.requests*100).toFixed(1)}%`,D=h.length>0?h.at(-1):0,R=d?vt(d):{p90:0,p95:0},F=n(a=>a<=0?"\u2014":a<1?`${(a*1e3).toFixed(0)}\u03BCs`:a<1e3?`${a.toFixed(1)}ms`:`${(a/1e3).toFixed(2)}s`,"formatMs"),b=(0,v.useMemo)(()=>{if(!d||!("queryStats"in d))return;let a=d.queryStats;if(!(!a||!Array.isArray(a)))return ht(a)},[d]),N=Rt(b!==void 0,Q),k=n(()=>{Xe(I())},"runAggregate"),A=n(()=>{U(null)},"clearAggregate"),E=n(()=>{C("overview")},"switchToOverview"),L=n(()=>{C("query-insights")},"switchToQueryInsights");return(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxDEV)(tt,{onChange:i,testId:"mt-shard-input",value:r},void 0,!1),(0,t.jsxDEV)(it,{message:H,prefix:"mt"},void 0,!1),(0,t.jsxDEV)(Oe,{"data-testid":"mt-aggregate",disabled:O,onClick:k,size:"sm",type:"button",variant:"secondary",children:s(O?"Aggregating\u2026":"All shards")},void 0,!1),_!==null&&(0,t.jsxDEV)(Oe,{"data-testid":"mt-aggregate-clear",onClick:A,size:"sm",type:"button",variant:"ghost",children:s("Hide")},void 0,!1),(0,t.jsxDEV)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:ot,rel:"noreferrer",target:"_blank",children:s("Open in Cloudflare")},void 0,!1)]},void 0,!0),j!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:j},void 0,!1),b!==void 0&&(0,t.jsxDEV)("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[(0,t.jsxDEV)("button",{className:`pb-2 text-sm font-medium transition-colors ${N==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:E,type:"button",children:s("Overview")},void 0,!1),(0,t.jsxDEV)("button",{className:`pb-2 text-sm font-medium transition-colors ${N==="query-insights"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-query-insights",onClick:L,type:"button",children:[s("Query insights"),b.length>0&&(0,t.jsxDEV)("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:b.length},void 0,!1)]},void 0,!0)]},void 0,!0),N==="query-insights"&&b!==void 0&&(0,t.jsxDEV)(yt,{queryStats:b},void 0,!1),N==="overview"&&d!==null&&(0,t.jsxDEV)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[(0,t.jsxDEV)(q,{chart:h.length>=2?(0,t.jsxDEV)(gt,{ariaLabel:s("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:h,testId:"mt-sparkline"},void 0,!1):void 0,footer:h.length>=2?(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)("span",{className:"font-semibold text-foreground",children:`+${D.toLocaleString()}`},void 0,!1)," ",s("last interval")]},void 0,!0):(0,t.jsxDEV)("span",{"data-testid":"mt-sparkline-empty",children:s("collecting samples\u2026")},void 0,!1),label:s("Requests"),testId:"mt-requests",value:d.requests},void 0,!1),(0,t.jsxDEV)(q,{footer:s("{rate} error rate",{rate:M}),label:s("Errors"),testId:"mt-errors",value:(0,t.jsxDEV)(t.Fragment,{children:[d.errors," (",M,")"]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(q,{footer:R.p90>0?`P90 ${F(R.p90)}`:void 0,label:s("P95 latency"),testId:"mt-p95",value:R.p95>0?F(R.p95):"\u2014"},void 0,!1),(0,t.jsxDEV)(q,{footer:d.cache===null?void 0:`${d.cache.entries.toLocaleString()} ${s("cache entries")}`,label:s("Database size"),testId:"mt-db-size",value:Ae(d.databaseSize)},void 0,!1),(0,t.jsxDEV)(q,{label:s("Shard"),testId:"mt-shard",value:d.shard},void 0,!1),(0,t.jsxDEV)(q,{label:s("Uptime"),testId:"mt-uptime",value:Tt(d.uptimeMs)},void 0,!1),(0,t.jsxDEV)(q,{label:s("Cache hit rate"),testId:"mt-cache",value:d.cache===null?s("no cache configured"):s("{rate} ({count} entries)",{count:d.cache.entries,rate:_t(d.cache.hits,d.cache.misses)})},void 0,!1)]},void 0,!0),N==="overview"&&d===null&&null,N==="overview"&&f!==null&&_!==null&&(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[(0,t.jsxDEV)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[(0,t.jsxDEV)(q,{label:s("Shards"),testId:"mt-agg-shards",value:f.failed>0?s("{reachable} reachable, {failed} unreachable",{failed:f.failed,reachable:f.reachable}):s("{reachable} reachable",{reachable:f.reachable})},void 0,!1),(0,t.jsxDEV)(q,{label:s("Total requests"),testId:"mt-agg-requests",value:f.totalRequests},void 0,!1),(0,t.jsxDEV)(q,{label:s("Total errors"),testId:"mt-agg-errors",value:f.totalErrors},void 0,!1),(0,t.jsxDEV)(q,{label:s("Total database size"),testId:"mt-agg-db-size",value:Ae(f.totalDatabaseSize)},void 0,!1),(0,t.jsxDEV)(q,{label:s("Combined cache hit rate"),testId:"mt-agg-cache",value:f.hitRate===null?s("no cache configured"):`${(f.hitRate*100).toFixed(1)}%`},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(B,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(P,{className:"px-0",children:(0,t.jsxDEV)(st,{"data-testid":"mt-agg-table",children:[(0,t.jsxDEV)(lt,{children:(0,t.jsxDEV)(je,{children:[(0,t.jsxDEV)($e,{children:s("shard")},void 0,!1),(0,t.jsxDEV)($e,{children:s("requests")},void 0,!1),(0,t.jsxDEV)($e,{children:s("errors")},void 0,!1),(0,t.jsxDEV)($e,{children:s("db size")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(at,{children:_.map(a=>(0,t.jsxDEV)(je,{"data-testid":`mt-agg-row-${a.shard}`,children:[(0,t.jsxDEV)(Te,{children:a.shard},void 0,!1),a.metrics===null?(0,t.jsxDEV)(Te,{className:"text-destructive",colSpan:3,children:a.error??s("unreachable")},void 0,!1):(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)(Te,{className:"tabular-nums",children:a.metrics.requests},void 0,!1),(0,t.jsxDEV)(Te,{className:"tabular-nums",children:a.metrics.errors},void 0,!1),(0,t.jsxDEV)(Te,{className:"tabular-nums",children:Ae(a.metrics.databaseSize)},void 0,!1)]},void 0,!0)]},a.shard,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0)]},void 0,!0)},"MetricsPanel");export{Kt as MetricsPanel};
@@ -0,0 +1,13 @@
1
+ import{a as Ae}from"./chunk-VLXV72QE.js";import{a as xe}from"./chunk-JSEXCW5Q.js";import{a as X}from"./chunk-KZ6INM5M.js";import{d as we,f as Oe,g as $e,k as ae}from"./chunk-4QHKBC77.js";import{a as Ce}from"./chunk-UKDJ4H7I.js";import"./chunk-TBMYIZIO.js";import{R as ke}from"./chunk-3CJW6NWG.js";import{c as H}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as Te}from"./chunk-BOXSWNXZ.js";import{a as W}from"./chunk-TAD43CG5.js";import{b as Se}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as G}from"./chunk-XLXNLJ4N.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as M,e as le,f as de,g as ce,k as Ie,m as re}from"./chunk-E75ANNWX.js";import{b as Ne}from"./chunk-JHKMUTIF.js";import{a as p,e as q,f as he,g as oe,h as ne,j as ge}from"./chunk-RRCPZMC2.js";var Ue=q(oe(),1),ye=q(he(),1);var ee=q(oe(),1);var Z=q(he(),1);var B=q(ne(),1);var Ye=le(Te.listTables),Qe=["react","client","cli"],Xe=!1,Ze={action:"action",mutation:"mutation",query:"query"},Pe=p(t=>{let e=t.indexOf(":");return e===-1?{file:"",fn:t}:{file:t.slice(0,e),fn:t.slice(e+1)}},"splitPath"),Ee=p(({file:t,fn:e,kind:o})=>`await client.${Ze[o]}(api.${t}.${e}, { /* args */ });`,"buildClientSnippet"),et=p(t=>{let e=`api.${t.file}.${t.fn}`;switch(t.kind){case"action":return Ee(t);case"mutation":return`const ${t.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},"buildReactSnippet"),tt=p(({file:t,fn:e})=>`lunora run ${t}:${e} --args '{ }'`,"buildCliSnippet"),st=p(t=>["// Read rows",`const rows = await ctx.db.query("${t}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${t}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${t}">;`,`type RowId = Id<"${t}">;`].join(`
2
+ `),"buildTableSnippet"),ot=p((t,e)=>{switch(t){case"cli":return tt(e);case"client":return Ee(e);default:return et(e)}},"snippetForTab"),_e=p(t=>{let e=(0,ee.c)(19),{code:o,label:s,testId:n}=t,r=M(),l;e[0]!==o?(l=p(()=>{re(o)},"t1"),e[0]=o,e[1]=l):l=e[1];let i=l,d;e[2]!==s?(d=(0,B.jsxDEV)("span",{className:"text-xs font-medium text-muted-foreground",children:s},void 0,!1),e[2]=s,e[3]=d):d=e[3];let c=`${n}-copy`,m;e[4]!==r?(m=r("Copy"),e[4]=r,e[5]=m):m=e[5];let a;e[6]!==i||e[7]!==c||e[8]!==m?(a=(0,B.jsxDEV)(H,{"data-testid":c,onClick:i,size:"xs",type:"button",variant:"ghost",children:m},void 0,!1),e[6]=i,e[7]=c,e[8]=m,e[9]=a):a=e[9];let u;e[10]!==d||e[11]!==a?(u=(0,B.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[d,a]},void 0,!0),e[10]=d,e[11]=a,e[12]=u):u=e[12];let v;e[13]!==o||e[14]!==n?(v=(0,B.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":n,children:o},void 0,!1),e[13]=o,e[14]=n,e[15]=v):v=e[15];let k;return e[16]!==u||e[17]!==v?(k=(0,B.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[u,v]},void 0,!0),e[16]=u,e[17]=v,e[18]=k):k=e[18],k},"SnippetBlock"),nt=p(t=>{let e=(0,ee.c)(50),{file:o,fn:s,kind:n}=t,r=M(),[l,i]=(0,Z.useState)("react"),d,c,m;if(e[0]!==o||e[1]!==s||e[2]!==n||e[3]!==r||e[4]!==l){let T={file:o,fn:s,kind:n},I;e[8]!==r?(I=r("CLI"),e[8]=r,e[9]=I):I=e[9];let P;e[10]!==r?(P=r("Client"),e[10]=r,e[11]=P):P=e[11];let E;e[12]!==r?(E=r("React"),e[12]=r,e[13]=E):E=e[13];let j;e[14]!==I||e[15]!==P||e[16]!==E?(j={cli:I,client:P,react:E},e[14]=I,e[15]=P,e[16]=E,e[17]=j):j=e[17],m=j;let R;e[18]===Symbol.for("react.memo_cache_sentinel")?(R=p(L=>{i(L.currentTarget.dataset.tab)},"t62"),e[18]=R):R=e[18],d=R,c=ot(l,T),e[0]=o,e[1]=s,e[2]=n,e[3]=r,e[4]=l,e[5]=d,e[6]=c,e[7]=m}else d=e[5],c=e[6],m=e[7];let a=c,u=n==="action"&&l==="react"&&!Xe,v=`api.${o}.${s}`,k;e[19]!==v?(k=(0,B.jsxDEV)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-fn-title",children:v},void 0,!1),e[19]=v,e[20]=k):k=e[20];let O;e[21]!==n||e[22]!==r?(O=r("Call this {kind} from your app.",{kind:n}),e[21]=n,e[22]=r,e[23]=O):O=e[23];let h;e[24]!==O?(h=(0,B.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:O},void 0,!1),e[24]=O,e[25]=h):h=e[25];let g;e[26]!==k||e[27]!==h?(g=(0,B.jsxDEV)("div",{children:[k,h]},void 0,!0),e[26]=k,e[27]=h,e[28]=g):g=e[28];let x;e[29]!==r?(x=r("Snippet flavour"),e[29]=r,e[30]=x):x=e[30];let b;e[31]!==d||e[32]!==l||e[33]!==m?(b=Qe.map(T=>(0,B.jsxDEV)(H,{"aria-selected":l===T,"data-tab":T,"data-testid":`api-tab-${T}`,onClick:d,role:"tab",size:"xs",type:"button",variant:l===T?"default":"outline",children:m[T]},T,!1)),e[31]=d,e[32]=l,e[33]=m,e[34]=b):b=e[34];let S;e[35]!==x||e[36]!==b?(S=(0,B.jsxDEV)("div",{"aria-label":x,className:"flex gap-1.5","data-testid":"api-tabs",role:"tablist",children:b},void 0,!1),e[35]=x,e[36]=b,e[37]=S):S=e[37];let y=m[l],$=`api-snippet-${l}`,N;e[38]!==a||e[39]!==y||e[40]!==$?(N=(0,B.jsxDEV)(_e,{code:a,label:y,testId:$},void 0,!1),e[38]=a,e[39]=y,e[40]=$,e[41]=N):N=e[41];let w;e[42]!==u||e[43]!==r?(w=u&&(0,B.jsxDEV)("p",{className:"text-xs text-muted-foreground","data-testid":"api-action-note",children:r("Actions have no React hook \u2014 call them through the client.")},void 0,!1),e[42]=u,e[43]=r,e[44]=w):w=e[44];let C;return e[45]!==N||e[46]!==w||e[47]!==g||e[48]!==S?(C=(0,B.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"api-fn-doc",children:[g,S,N,w]},void 0,!0),e[45]=N,e[46]=w,e[47]=g,e[48]=S,e[49]=C):C=e[49],C},"FunctionDoc"),rt=p(t=>{let e=(0,ee.c)(19),{name:o}=t,s=M(),n;e[0]!==o?(n=st(o),e[0]=o,e[1]=n):n=e[1];let r=n,l;e[2]!==o?(l=(0,B.jsxDEV)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-table-title",children:o},void 0,!1),e[2]=o,e[3]=l):l=e[3];let i;e[4]!==s?(i=s("Read and write this table through the typed data model."),e[4]=s,e[5]=i):i=e[5];let d;e[6]!==i?(d=(0,B.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:i},void 0,!1),e[6]=i,e[7]=d):d=e[7];let c;e[8]!==l||e[9]!==d?(c=(0,B.jsxDEV)("div",{children:[l,d]},void 0,!0),e[8]=l,e[9]=d,e[10]=c):c=e[10];let m;e[11]!==s?(m=s("Data model"),e[11]=s,e[12]=m):m=e[12];let a;e[13]!==r||e[14]!==m?(a=(0,B.jsxDEV)(_e,{code:r,label:m,testId:"api-snippet-table"},void 0,!1),e[13]=r,e[14]=m,e[15]=a):a=e[15];let u;return e[16]!==c||e[17]!==a?(u=(0,B.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"api-table-doc",children:[c,a]},void 0,!0),e[16]=c,e[17]=a,e[18]=u):u=e[18],u},"TableDoc"),Re=p(t=>{let e=(0,ee.c)(8),{active:o,label:s,onSelect:n,testId:r,value:l}=t,i;e[0]!==n||e[1]!==l?(i=p(()=>{n(l)},"t1"),e[0]=n,e[1]=l,e[2]=i):i=e[2];let d=i,c=o?"page":void 0,m;return e[3]!==s||e[4]!==d||e[5]!==c||e[6]!==r?(m=(0,B.jsxDEV)("button",{"aria-current":c,className:"w-full truncate rounded-md px-2 py-1 text-start font-mono text-xs text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-testid":r,onClick:d,type:"button",children:s},void 0,!1),e[3]=s,e[4]=d,e[5]=c,e[6]=r,e[7]=m):m=e[7],m},"RailButton"),je=p(t=>{let e=(0,ee.c)(67),{functions:o,initialShardKey:s}=t,n=M(),r=G(),[l,i]=(0,Z.useState)(null),[d,c]=(0,Z.useState)(null),m,a;e[0]!==r||e[1]!==s?(m=p(()=>{let _=!1;return r.query(Ye,{},de(s??"")).then(D=>(_||i(D),D)).catch(()=>{_||i([])}),()=>{_=!0}},"t1"),a=[r,s],e[0]=r,e[1]=s,e[2]=m,e[3]=a):(m=e[2],a=e[3]),(0,Z.useEffect)(m,a);let u;e[4]!==o?(u=o??[],e[4]=o,e[5]=u):u=e[5];let v=u,k;if(e[6]!==v){let _=new Map;for(let D of v){let{file:V,fn:U}=Pe(D.path),ie=_.get(V)??[];ie.push({fn:U,kind:D.kind,path:D.path}),_.set(V,ie)}k=[..._.entries()].map(at).toSorted(lt),e[6]=v,e[7]=k}else k=e[7];let O=k,h,g,x,b,S,y,$,N,w,C;if(e[8]!==v||e[9]!==O||e[10]!==d||e[11]!==n||e[12]!==l){let _=(l??[]).map(dt).toSorted(ct),D;e[23]===Symbol.for("react.memo_cache_sentinel")?(D=p(F=>{c({kind:"fn",path:F})},"t122"),e[23]=D):D=e[23];let V=D,U;e[24]===Symbol.for("react.memo_cache_sentinel")?(U=p(F=>{c({kind:"table",name:F})},"t132"),e[24]=U):U=e[24];let ie=U;if(g=d?.kind==="fn"?v.find(F=>F.path===d.path):void 0,h=v.length>0||_.length>0,x=g===void 0?void 0:Pe(g.path),b="grid min-h-0 gap-6 md:grid-cols-[16rem_minmax(0,1fr)]",S="lunora-api-docs",e[25]!==n?(y=n("API resources"),e[25]=n,e[26]=y):y=e[26],$="flex flex-col gap-4 overflow-y-auto",N="api-rail",e[27]!==O||e[28]!==d||e[29]!==n){let F;e[31]!==d||e[32]!==n?(F=p(ve=>(0,B.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,B.jsxDEV)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:ve.file||n("(root)")},void 0,!1),ve.items.map(se=>(0,B.jsxDEV)(Re,{active:d?.kind==="fn"&&d.path===se.path,label:se.fn,onSelect:V,testId:`api-rail-fn-${se.path}`,value:se.path},se.path,!1))]},ve.file,!0),"t142"),e[31]=d,e[32]=n,e[33]=F):F=e[33],w=O.map(F),e[27]=O,e[28]=d,e[29]=n,e[30]=w}else w=e[30];C=_.length>0&&(0,B.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,B.jsxDEV)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Tables")},void 0,!1),_.map(F=>(0,B.jsxDEV)(Re,{active:d?.kind==="table"&&d.name===F,label:F,onSelect:ie,testId:`api-rail-table-${F}`,value:F},F,!1))]},void 0,!0),e[8]=v,e[9]=O,e[10]=d,e[11]=n,e[12]=l,e[13]=h,e[14]=g,e[15]=x,e[16]=b,e[17]=S,e[18]=y,e[19]=$,e[20]=N,e[21]=w,e[22]=C}else h=e[13],g=e[14],x=e[15],b=e[16],S=e[17],y=e[18],$=e[19],N=e[20],w=e[21],C=e[22];let T;e[34]!==h||e[35]!==n?(T=!h&&(0,B.jsxDEV)("p",{className:"px-2 text-xs text-muted-foreground","data-testid":"api-rail-empty",children:n("No functions or tables to document yet.")},void 0,!1),e[34]=h,e[35]=n,e[36]=T):T=e[36];let I;e[37]!==T||e[38]!==y||e[39]!==$||e[40]!==N||e[41]!==w||e[42]!==C?(I=(0,B.jsxDEV)("nav",{"aria-label":y,className:$,"data-testid":N,children:[w,C,T]},void 0,!0),e[37]=T,e[38]=y,e[39]=$,e[40]=N,e[41]=w,e[42]=C,e[43]=I):I=e[43];let P;e[44]!==d||e[45]!==n?(P=d===null&&(0,B.jsxDEV)(W,{description:n("Select a function or table to see how to call it from your app."),testId:"api-empty",title:n("API usage snippets")},void 0,!1),e[44]=d,e[45]=n,e[46]=P):P=e[46];let E;e[47]!==d?.kind||e[48]!==g||e[49]!==x?(E=d?.kind==="fn"&&g!==void 0&&x!==void 0&&(0,B.jsxDEV)(nt,{file:x.file,fn:x.fn,kind:g.kind},g.path,!1),e[47]=d?.kind,e[48]=g,e[49]=x,e[50]=E):E=e[50];let j;e[51]!==d?.kind||e[52]!==g||e[53]!==n?(j=d?.kind==="fn"&&g===void 0&&(0,B.jsxDEV)(W,{testId:"api-empty",title:n("API usage snippets")},void 0,!1),e[51]=d?.kind,e[52]=g,e[53]=n,e[54]=j):j=e[54];let R;e[55]!==d?(R=d?.kind==="table"&&(0,B.jsxDEV)(rt,{name:d.name},void 0,!1),e[55]=d,e[56]=R):R=e[56];let L;e[57]!==P||e[58]!==E||e[59]!==j||e[60]!==R?(L=(0,B.jsxDEV)("div",{className:"min-w-0",children:[P,E,j,R]},void 0,!0),e[57]=P,e[58]=E,e[59]=j,e[60]=R,e[61]=L):L=e[61];let A;return e[62]!==b||e[63]!==S||e[64]!==I||e[65]!==L?(A=(0,B.jsxDEV)("div",{className:b,"data-testid":S,children:[I,L]},void 0,!0),e[62]=b,e[63]=S,e[64]=I,e[65]=L,e[66]=A):A=e[66],A},"ApiDocsPanel");function it(t,e){return t.fn.localeCompare(e.fn)}p(it,"_temp");function at(t){let[e,o]=t;return{file:e,items:o.toSorted(it)}}p(at,"_temp2");function lt(t,e){return t.file.localeCompare(e.file)}p(lt,"_temp3");function dt(t){return t.name}p(dt,"_temp4");function ct(t,e){return t.localeCompare(e)}p(ct,"_temp5");var Ve=q(oe(),1);var J=q(oe(),1),K=q(he(),1);var f=q(ne(),1);var ue=p(function(t,e,o){let s=(0,J.c)(10),n;s[0]===Symbol.for("react.memo_cache_sentinel")?(n={kind:"loading"},s[0]=n):n=s[0];let[r,l]=(0,K.useState)(n),i,d;s[1]!==o||s[2]!==e||s[3]!==t?(i=p(()=>{if(t!==void 0)return;let m=!1;return e().then(a=>(m||l(o(a)),a)).catch(a=>{m||l({kind:"error",message:ce(a)})}),()=>{m=!0}},"t1"),d=[o,e,t],s[1]=o,s[2]=e,s[3]=t,s[4]=i,s[5]=d):(i=s[4],d=s[5]),(0,K.useEffect)(i,d);let c;return s[6]!==o||s[7]!==r||s[8]!==t?(c=t===void 0?r:o(t),s[6]=o,s[7]=r,s[8]=t,s[9]=c):c=s[9],c},"useAdminSpec"),ft=p(t=>typeof t=="number"?"number":typeof t=="boolean"?"boolean":"string","scalarOf"),De=p(t=>{if(t.enum!==void 0&&t.enum.length>0)return t.enum;if(t.anyOf!==void 0&&t.anyOf.length>0&&t.anyOf.every(e=>e.const!==void 0))return t.anyOf.map(e=>e.const)},"enumValues"),pe=p(t=>t===void 0?"any":t.const!==void 0?JSON.stringify(t.const):t.enum!==void 0&&t.enum.length>0?t.enum.map(e=>JSON.stringify(e)).join(" | "):t.anyOf!==void 0&&t.anyOf.length>0?t.anyOf.map(e=>pe(e)).join(" | "):t.type==="array"?`array<${pe(t.items)}>`:t.type??"any","typeLabel"),pt=p(t=>{let e=De(t);return e!==void 0?t.type??ft(e[0]):pe(t)},"fieldTypeLabel"),ut=p(t=>{let e=De(t);return e===void 0?void 0:e.map(o=>JSON.stringify(o)).join(" | ")},"valueInText"),mt=p(t=>{let e=[];t.minimum!==void 0?e.push(`${String(t.minimum)} \u2264`):t.exclusiveMinimum!==void 0&&e.push(`${String(t.exclusiveMinimum)} <`);let o=e.length>0;e.push("value"),t.maximum!==void 0?e.push(`\u2264 ${String(t.maximum)}`):t.exclusiveMaximum!==void 0&&e.push(`< ${String(t.exclusiveMaximum)}`);let s=e.length>(o?2:1);return o||s?e.join(" "):void 0},"rangeText"),vt=p(t=>{if(t.type==="object"&&t.properties!==void 0)return t;if(t.type==="array"&&t.items?.type==="object"&&t.items.properties!==void 0)return t.items},"childObject"),te=p(t=>{if(t===void 0)return null;if(t.const!==void 0)return t.const;if(t.enum!==void 0&&t.enum.length>0)return t.enum[0];if(t.anyOf!==void 0&&t.anyOf.length>0)return te(t.anyOf[0]);switch(t.type){case"array":return[];case"boolean":return!1;case"number":return 0;case"object":{let e={};for(let[o,s]of Object.entries(t.properties??{}))e[o]=te(s);return e}case"string":return"";default:return null}},"exampleForSchema"),fe=p(t=>{let e=(0,J.c)(7),{label:o,value:s}=t,n;e[0]!==o?(n=(0,f.jsxDEV)("span",{className:"text-muted-foreground",children:o},void 0,!1),e[0]=o,e[1]=n):n=e[1];let r;e[2]!==s?(r=(0,f.jsxDEV)("span",{className:"text-foreground",children:s},void 0,!1),e[2]=s,e[3]=r):r=e[3];let l;return e[4]!==n||e[5]!==r?(l=(0,f.jsxDEV)("span",{className:"inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 font-mono text-[10px]",children:[n,r]},void 0,!0),e[4]=n,e[5]=r,e[6]=l):l=e[6],l},"Badge"),ht=p(t=>{let e=(0,J.c)(40),{name:o,required:s,schema:n}=t,r=M(),l;e[0]!==n?(l=mt(n),e[0]=n,e[1]=l):l=e[1];let i=l,d;e[2]!==n?(d=ut(n),e[2]=n,e[3]=d):d=e[3];let c=d,m=n["x-lunora-table"],a=n.format!==void 0||i!==void 0||c!==void 0||m!==void 0,u;e[4]!==n?(u=vt(n),e[4]=n,e[5]=u):u=e[5];let v=u,k=s?"*":"?",O;e[6]!==k?(O=(0,f.jsxDEV)("span",{className:"text-muted-foreground",children:k},void 0,!1),e[6]=k,e[7]=O):O=e[7];let h;e[8]!==o||e[9]!==O?(h=(0,f.jsxDEV)("span",{className:"font-mono text-foreground",children:[o,O]},void 0,!0),e[8]=o,e[9]=O,e[10]=h):h=e[10];let g;e[11]!==n?(g=pt(n),e[11]=n,e[12]=g):g=e[12];let x;e[13]!==g?(x=(0,f.jsxDEV)("span",{className:"font-mono text-muted-foreground",children:g},void 0,!1),e[13]=g,e[14]=x):x=e[14];let b;e[15]!==h||e[16]!==x?(b=(0,f.jsxDEV)("div",{className:"flex items-baseline gap-2",children:[h,x]},void 0,!0),e[15]=h,e[16]=x,e[17]=b):b=e[17];let S;e[18]!==n.description?(S=n.description!==void 0&&(0,f.jsxDEV)("p",{className:"max-w-prose text-muted-foreground",children:n.description},void 0,!1),e[18]=n.description,e[19]=S):S=e[19];let y;e[20]!==a||e[21]!==i||e[22]!==m||e[23]!==n.format||e[24]!==r||e[25]!==c?(y=a&&(0,f.jsxDEV)("div",{className:"flex flex-wrap gap-1",children:[n.format!==void 0&&(0,f.jsxDEV)(fe,{label:r("Format"),value:n.format},void 0,!1),i!==void 0&&(0,f.jsxDEV)(fe,{label:r("Range"),value:i},void 0,!1),c!==void 0&&(0,f.jsxDEV)(fe,{label:r("Value in"),value:c},void 0,!1),m!==void 0&&(0,f.jsxDEV)(fe,{label:r("relation"),value:m},void 0,!1)]},void 0,!0),e[20]=a,e[21]=i,e[22]=m,e[23]=n.format,e[24]=r,e[25]=c,e[26]=y):y=e[26];let $;e[27]!==S||e[28]!==y||e[29]!==b?($=(0,f.jsxDEV)("div",{className:"flex flex-col gap-1 py-2",children:[b,S,y]},void 0,!0),e[27]=S,e[28]=y,e[29]=b,e[30]=$):$=e[30];let N=$;if(v===void 0){let I;return e[31]!==N?(I=(0,f.jsxDEV)("div",{className:"border-b border-border/50 last:border-b-0",children:N},void 0,!1),e[31]=N,e[32]=I):I=e[32],I}let w;e[33]!==N?(w=(0,f.jsxDEV)("summary",{className:"cursor-pointer marker:text-muted-foreground",children:N},void 0,!1),e[33]=N,e[34]=w):w=e[34];let C;e[35]!==v?(C=(0,f.jsxDEV)("div",{className:"mb-2 ml-2 border-l border-border pl-3",children:(0,f.jsxDEV)(Me,{schema:v},void 0,!1)},void 0,!1),e[35]=v,e[36]=C):C=e[36];let T;return e[37]!==w||e[38]!==C?(T=(0,f.jsxDEV)("details",{className:"border-b border-border/50 last:border-b-0",children:[w,C]},void 0,!0),e[37]=w,e[38]=C,e[39]=T):T=e[39],T},"FieldRow"),Me=p(t=>{let e=(0,J.c)(7),{schema:o}=t,s;e[0]!==o.required?(s=new Set(o.required),e[0]=o.required,e[1]=s):s=e[1];let n=s,r;e[2]!==o.properties?(r=Object.entries(o.properties??{}),e[2]=o.properties,e[3]=r):r=e[3];let l=r,i;return e[4]!==n||e[5]!==l?(i=(0,f.jsxDEV)("div",{className:"flex flex-col",children:l.map(d=>{let[c,m]=d;return(0,f.jsxDEV)(ht,{name:c,required:n.has(c),schema:m},c,!1)})},void 0,!1),e[4]=n,e[5]=l,e[6]=i):i=e[6],i},"SchemaFields"),Le=p(t=>{let e=(0,J.c)(10),{schema:o,testId:s}=t;if(o?.type!=="object"||Object.keys(o.properties??{}).length===0){let l;e[0]!==o?(l=pe(o),e[0]=o,e[1]=l):l=e[1];let i;return e[2]!==l||e[3]!==s?(i=(0,f.jsxDEV)("p",{className:"font-mono text-xs text-muted-foreground","data-testid":s,children:l},void 0,!1),e[2]=l,e[3]=s,e[4]=i):i=e[4],i}let n;e[5]!==o?(n=(0,f.jsxDEV)(Me,{schema:o},void 0,!1),e[5]=o,e[6]=n):n=e[6];let r;return e[7]!==n||e[8]!==s?(r=(0,f.jsxDEV)("div",{className:"text-xs","data-testid":s,children:n},void 0,!1),e[7]=n,e[8]=s,e[9]=r):r=e[9],r},"SchemaTable"),gt=["curl","javascript","lunora"],xt={lunora:"Lunora",curl:"cURL",javascript:"JavaScript"},bt=p(t=>`api.${t.replaceAll(/[/:]/g,".")}`,"apiReferenceOf"),yt=p(t=>{let e=te(t.argsSchema)??{};return t.functionPath===void 0?e:{args:e,functionPath:t.functionPath}},"requestBody"),Nt=p((t,e,o)=>{let s=`${o}${e.httpPath}`,n=JSON.stringify(yt(e),void 0,2),r=JSON.stringify(te(e.argsSchema)??{},void 0,2);switch(t){case"curl":{let l=e.method!=="GET"&&e.method!=="HEAD",i=[`curl -X ${e.method} ${JSON.stringify(s)}`];return l&&i.push(' -H "Content-Type: application/json"',` -d '${n}'`),i.join(` \\
3
+ `)}case"lunora":return e.functionPath===void 0?`await fetch(${JSON.stringify(e.httpPath)}, { method: ${JSON.stringify(e.method)} });`:`import { useLunora } from "@lunora/react";
4
+ import { api } from "./_generated/api";
5
+
6
+ const client = useLunora();
7
+ await client.${e.kind??"query"}(${bt(e.functionPath)}, ${r});`;default:{let i=e.method!=="GET"&&e.method!=="HEAD"?`{
8
+ method: ${JSON.stringify(e.method)},
9
+ headers: { "Content-Type": "application/json" },
10
+ body: JSON.stringify(${n}),
11
+ }`:`{ method: ${JSON.stringify(e.method)} }`;return`const response = await fetch(${JSON.stringify(s)}, ${i});
12
+ const data = await response.json();`}}},"sampleSource"),St=p(t=>{let e=(0,J.c)(24),{operation:o,server:s}=t,n=M(),[r,l]=(0,K.useState)("curl"),i;e[0]!==o||e[1]!==r||e[2]!==s?(i=Nt(r,o,s),e[0]=o,e[1]=r,e[2]=s,e[3]=i):i=e[3];let d=i,c;e[4]!==d?(c=p(()=>{re(d)},"t2"),e[4]=d,e[5]=c):c=e[5];let m=c,a;e[6]===Symbol.for("react.memo_cache_sentinel")?(a=p(S=>{l(S.currentTarget.dataset.sample)},"t3"),e[6]=a):a=e[6];let u=a,v;e[7]!==r?(v=gt.map(S=>(0,f.jsxDEV)("button",{"aria-selected":r===S,className:"rounded px-2 py-0.5 text-xs text-muted-foreground transition-colors hover:text-foreground aria-selected:bg-muted aria-selected:font-medium aria-selected:text-foreground","data-sample":S,"data-testid":`api-sample-${S}`,onClick:u,role:"tab",type:"button",children:xt[S]},S,!1)),e[7]=r,e[8]=v):v=e[8];let k;e[9]!==v?(k=(0,f.jsxDEV)("div",{className:"flex gap-1",role:"tablist",children:v},void 0,!1),e[9]=v,e[10]=k):k=e[10];let O;e[11]!==n?(O=n("Copy"),e[11]=n,e[12]=O):O=e[12];let h;e[13]!==m||e[14]!==O?(h=(0,f.jsxDEV)(H,{"data-testid":"api-sample-copy",onClick:m,size:"xs",type:"button",variant:"ghost",children:O},void 0,!1),e[13]=m,e[14]=O,e[15]=h):h=e[15];let g;e[16]!==k||e[17]!==h?(g=(0,f.jsxDEV)("div",{className:"flex items-center justify-between gap-2 border-b border-border px-3 py-2",children:[k,h]},void 0,!0),e[16]=k,e[17]=h,e[18]=g):g=e[18];let x;e[19]!==d?(x=(0,f.jsxDEV)("pre",{className:"overflow-auto px-3 pb-3 font-mono text-xs","data-testid":"api-sample-source",children:d},void 0,!1),e[19]=d,e[20]=x):x=e[20];let b;return e[21]!==g||e[22]!==x?(b=(0,f.jsxDEV)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card","data-testid":"api-code-samples",children:[g,x]},void 0,!0),e[21]=g,e[22]=x,e[23]=b):b=e[23],b},"CodeSamples"),kt={blue:"text-info",emerald:"text-success",neutral:"text-muted-foreground",orange:"text-warning",red:"text-destructive",violet:"text-royal-amethyst"},wt=p(t=>{switch(t.toUpperCase()){case"DELETE":return"red";case"GET":return"emerald";case"PATCH":return"orange";case"POST":return"blue";case"PUT":return"orange";default:return"neutral"}},"methodTone"),Ot=p(t=>{switch(t){case"action":return"violet";case"mutation":return"orange";case"query":return"emerald";default:return"neutral"}},"kindTone"),be=p(t=>{let e=(0,J.c)(7),{kind:o,method:s,testId:n}=t,r;e[0]!==o||e[1]!==s?(r=o??s.toUpperCase(),e[0]=o,e[1]=s,e[2]=r):r=e[2];let l=r,i=o===void 0?wt(s):Ot(o),d=`${kt[i]} font-mono text-[10px] tracking-wide uppercase`,c;return e[3]!==l||e[4]!==d||e[5]!==n?(c=(0,f.jsxDEV)(Se,{className:d,"data-testid":n,variant:"ghost",children:l},void 0,!1),e[3]=l,e[4]=d,e[5]=n,e[6]=c):c=e[6],c},"MethodBadge"),Ke=p(t=>t.startsWith("2")?"text-emerald-600 dark:text-emerald-400":t==="default"||t.startsWith("4")||t.startsWith("5")?"text-red-600 dark:text-red-400":"text-muted-foreground","statusToneClass"),Fe=p(t=>t.startsWith("2")?"bg-emerald-500":t==="default"||t.startsWith("4")||t.startsWith("5")?"bg-red-500":"bg-muted-foreground","statusDotClass"),$t=p(t=>JSON.stringify(te(t.argsSchema)??{},void 0,2),"seedArgs"),Je=(0,K.createContext)(null),qe=p(()=>{let t=(0,K.use)(Je);if(t===null)throw new Ne("INTERNAL","useOperationRun must be used within an OperationRunProvider");return t},"useOperationRun"),It=p(({children:t,operation:e})=>{let o=M(),s=G(),[n,r]=(0,K.useState)(()=>$t(e)),[l,i]=(0,K.useState)(""),[d,c]=(0,K.useState)("idle"),[m,a]=(0,K.useState)(void 0),[u,v]=(0,K.useState)(null),[k,O]=(0,K.useState)(null),h=p(async()=>{let b;try{b=n.trim()===""?{}:JSON.parse(n)}catch(y){c("error"),a(void 0),O(null),v(o("Invalid JSON args: {message}",{message:ce(y)}));return}c("running"),v(null);let S=performance.now();try{let y;if(e.functionPath===void 0){let $=e.method!=="GET"&&e.method!=="HEAD",w=await(await fetch(e.httpPath,{body:$?JSON.stringify(b):void 0,headers:$?{"content-type":"application/json"}:void 0,method:e.method})).text();try{y=JSON.parse(w)}catch{y=w}}else{let $=le(e.functionPath),N=de(l);switch(e.kind){case"action":{y=await s.action($,b,N);break}case"mutation":{y=await s.mutation($,b,N);break}default:y=await s.query($,b,N)}}a(y),O(Math.round(performance.now()-S)),c("success")}catch(y){a(void 0),O(Math.round(performance.now()-S)),v(ce(y)),c("error")}},"send");return(0,f.jsxDEV)(Je,{value:{argsText:n,durationMs:k,error:u,operation:e,response:m,send:p(()=>{Ie(h())},"onSend"),setArgsText:r,setShardKey:i,shardKey:l,status:d},children:t},void 0,!1)},"OperationRunProvider"),Tt=p(()=>{let t=(0,J.c)(48),e=M(),{argsText:o,operation:s,send:n,setArgsText:r,setShardKey:l,shardKey:i,status:d}=qe(),c;t[0]!==r?(c=p(R=>{r(R.target.value)},"t0"),t[0]=r,t[1]=c):c=t[1];let m=c,a;t[2]!==n?(a=p(R=>{R.key==="Enter"&&(R.metaKey||R.ctrlKey)&&(R.preventDefault(),n())},"t1"),t[2]=n,t[3]=a):a=t[3];let u=a,v=d==="running",k;t[4]!==s.kind||t[5]!==s.method?(k=(0,f.jsxDEV)(be,{kind:s.kind,method:s.method,testId:"api-try-method"},void 0,!1),t[4]=s.kind,t[5]=s.method,t[6]=k):k=t[6];let O=s.functionPath??s.httpPath,h;t[7]!==O?(h=(0,f.jsxDEV)("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",children:O},void 0,!1),t[7]=O,t[8]=h):h=t[8];let g=v?"animate-pulse":void 0,x;t[9]!==g?(x=(0,f.jsxDEV)(ae,{className:g,icon:$e,strokeWidth:2},void 0,!1),t[9]=g,t[10]=x):x=t[10];let b;t[11]!==v||t[12]!==e?(b=e(v?"Sending\u2026":"Send"),t[11]=v,t[12]=e,t[13]=b):b=t[13];let S;t[14]!==v||t[15]!==n||t[16]!==x||t[17]!==b?(S=(0,f.jsxDEV)(H,{"data-testid":"api-try-send",disabled:v,onClick:n,size:"sm",type:"button",children:[x,b]},void 0,!0),t[14]=v,t[15]=n,t[16]=x,t[17]=b,t[18]=S):S=t[18];let y;t[19]!==k||t[20]!==h||t[21]!==S?(y=(0,f.jsxDEV)("div",{className:"flex items-center gap-2 border-b border-border bg-muted px-3 py-2",children:[k,h,S]},void 0,!0),t[19]=k,t[20]=h,t[21]=S,t[22]=y):y=t[22];let $;t[23]!==e?($=e("Arguments (JSON)"),t[23]=e,t[24]=$):$=t[24];let N;t[25]!==$?(N=(0,f.jsxDEV)(xe,{htmlFor:"api-try-args",children:$},void 0,!1),t[25]=$,t[26]=N):N=t[26];let w;t[27]!==o?(w=o.split(`
13
+ `),t[27]=o,t[28]=w):w=t[28];let C=Math.min(12,Math.max(3,w.length)),T;t[29]!==o||t[30]!==m||t[31]!==u||t[32]!==C?(T=(0,f.jsxDEV)(Ae,{className:"font-mono text-xs","data-testid":"api-try-args",id:"api-try-args",onChange:m,onKeyDown:u,rows:C,spellCheck:!1,value:o},void 0,!1),t[29]=o,t[30]=m,t[31]=u,t[32]=C,t[33]=T):T=t[33];let I;t[34]!==N||t[35]!==T?(I=(0,f.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[N,T]},void 0,!0),t[34]=N,t[35]=T,t[36]=I):I=t[36];let P;t[37]!==s.functionPath||t[38]!==l||t[39]!==i||t[40]!==e?(P=s.functionPath!==void 0&&(0,f.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,f.jsxDEV)(xe,{htmlFor:"shard-input",children:e("Shard key (optional)")},void 0,!1),(0,f.jsxDEV)(Ce,{id:"shard-input",onChange:l,testId:"shard-input",value:i},void 0,!1)]},void 0,!0),t[37]=s.functionPath,t[38]=l,t[39]=i,t[40]=e,t[41]=P):P=t[41];let E;t[42]!==I||t[43]!==P?(E=(0,f.jsxDEV)("div",{className:"flex flex-col gap-3 p-3",children:[I,P]},void 0,!0),t[42]=I,t[43]=P,t[44]=E):E=t[44];let j;return t[45]!==E||t[46]!==y?(j=(0,f.jsxDEV)("div",{className:"overflow-hidden rounded-xl border border-border bg-card","data-testid":"api-try-it",children:[y,E]},void 0,!0),t[45]=E,t[46]=y,t[47]=j):j=t[47],j},"TryIt"),Ct=p(t=>{let e=(0,J.c)(51),{operation:o}=t,s=M(),n=`api-operation-${o.operationId}`,r=o.key,l;e[0]!==o.kind||e[1]!==o.method?(l=(0,f.jsxDEV)(be,{kind:o.kind,method:o.method,testId:"api-operation-method"},void 0,!1),e[0]=o.kind,e[1]=o.method,e[2]=l):l=e[2];let i=o.functionPath??o.httpPath,d;e[3]!==i?(d=(0,f.jsxDEV)("code",{className:"truncate font-mono text-xs text-muted-foreground",children:i},void 0,!1),e[3]=i,e[4]=d):d=e[4];let c;e[5]!==l||e[6]!==d?(c=(0,f.jsxDEV)("div",{className:"flex items-center gap-2",children:[l,d]},void 0,!0),e[5]=l,e[6]=d,e[7]=c):c=e[7];let m;e[8]!==o.title?(m=(0,f.jsxDEV)("h1",{className:"text-lg font-semibold text-foreground","data-testid":"api-operation-title",children:o.title},void 0,!1),e[8]=o.title,e[9]=m):m=e[9];let a;e[10]!==o.description?(a=o.description!==void 0&&(0,f.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:o.description},void 0,!1),e[10]=o.description,e[11]=a):a=e[11];let u;e[12]!==c||e[13]!==m||e[14]!==a?(u=(0,f.jsxDEV)("header",{className:"sticky top-0 z-10 -mx-6 -mt-6 flex flex-col gap-2 border-b border-border bg-background px-6 pt-6 pb-3",children:[c,m,a]},void 0,!0),e[12]=c,e[13]=m,e[14]=a,e[15]=u):u=e[15];let v;e[16]!==s?(v=s("Try it"),e[16]=s,e[17]=v):v=e[17];let k;e[18]!==v?(k=(0,f.jsxDEV)("h2",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v},void 0,!1),e[18]=v,e[19]=k):k=e[19];let O;e[20]===Symbol.for("react.memo_cache_sentinel")?(O=(0,f.jsxDEV)(Tt,{},void 0,!1),e[20]=O):O=e[20];let h;e[21]!==k?(h=(0,f.jsxDEV)("section",{className:"flex flex-col gap-2",children:[k,O]},void 0,!0),e[21]=k,e[22]=h):h=e[22];let g;e[23]!==s?(g=s("Request arguments"),e[23]=s,e[24]=g):g=e[24];let x;e[25]!==g?(x=(0,f.jsxDEV)("h2",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:g},void 0,!1),e[25]=g,e[26]=x):x=e[26];let b;e[27]!==o.argsSchema?(b=(0,f.jsxDEV)(Le,{schema:o.argsSchema,testId:"api-operation-args"},void 0,!1),e[27]=o.argsSchema,e[28]=b):b=e[28];let S;e[29]!==x||e[30]!==b?(S=(0,f.jsxDEV)("section",{className:"flex flex-col gap-2",children:[x,b]},void 0,!0),e[29]=x,e[30]=b,e[31]=S):S=e[31];let y;e[32]!==s?(y=s("Response body"),e[32]=s,e[33]=y):y=e[33];let $;e[34]!==y?($=(0,f.jsxDEV)("h2",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y},void 0,!1),e[34]=y,e[35]=$):$=e[35];let N;if(e[36]!==o.responses||e[37]!==s){let T;e[39]!==s?(T=p(I=>(0,f.jsxDEV)("div",{className:"flex flex-col gap-1.5 rounded-xl border border-border bg-card p-3",children:[(0,f.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[(0,f.jsxDEV)("span",{className:`inline-flex items-center gap-1.5 font-mono text-xs font-semibold ${Ke(I.status)}`,children:[(0,f.jsxDEV)("span",{className:`size-1.5 rounded-full ${Fe(I.status)}`},void 0,!1),I.status]},void 0,!0),I.schema!==void 0&&(0,f.jsxDEV)("span",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground",children:s("application/json")},void 0,!1)]},void 0,!0),I.description!==void 0&&(0,f.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:I.description},void 0,!1),I.schema!==void 0&&(0,f.jsxDEV)(Le,{schema:I.schema,testId:`api-response-${I.status}`},void 0,!1)]},I.status,!0),"t212"),e[39]=s,e[40]=T):T=e[40],N=o.responses.map(T),e[36]=o.responses,e[37]=s,e[38]=N}else N=e[38];let w;e[41]!==$||e[42]!==N?(w=(0,f.jsxDEV)("section",{className:"flex flex-col gap-3",children:[$,N]},void 0,!0),e[41]=$,e[42]=N,e[43]=w):w=e[43];let C;return e[44]!==o.key||e[45]!==n||e[46]!==h||e[47]!==S||e[48]!==w||e[49]!==u?(C=(0,f.jsxDEV)("div",{className:"flex flex-col gap-6 duration-200 animate-in fade-in-0 slide-in-from-bottom-1","data-testid":n,children:[u,h,S,w]},r,!0),e[44]=o.key,e[45]=n,e[46]=h,e[47]=S,e[48]=w,e[49]=u,e[50]=C):C=e[50],C},"OperationView"),At={boolean:"text-royal-amethyst",key:"text-sky-sapphire",number:"text-warning",plain:"",string:"text-success"},Pt=/"(?:[^"\\]|\\.)*"|\b(?:true|false|null)\b|-?\d+(?:\.\d+)?/g,Rt=/^\s*:/,Et=p((t,e,o)=>o.startsWith('"')?Rt.test(t.slice(e))?"key":"string":o==="true"||o==="false"||o==="null"?"boolean":"number","classify"),_t=p(t=>{let e=[],o=0;for(let s of t.matchAll(Pt)){let{index:n}=s,r=s[0],l=n+r.length;n>o&&e.push({kind:"plain",start:o,text:t.slice(o,n)}),e.push({kind:Et(t,l,r),start:n,text:r}),o=l}return o<t.length&&e.push({kind:"plain",start:o,text:t.slice(o)}),e},"tokenize"),jt=p(t=>{let e=(0,J.c)(4),{code:o}=t,s;e[0]!==o?(s=_t(o).map(Lt),e[0]=o,e[1]=s):s=e[1];let n;return e[2]!==s?(n=(0,f.jsxDEV)(f.Fragment,{children:s},void 0,!1),e[2]=s,e[3]=n):n=e[3],n},"JsonHighlight");function Lt(t){return(0,f.jsxDEV)("span",{className:At[t.kind],children:t.text},t.start,!1)}p(Lt,"_temp$1");var Be="__live__",Bt=p(t=>t.schema===void 0?"":JSON.stringify(te(t.schema),void 0,2),"exampleBody"),Dt=p((t,e,o)=>o?t??"":e===void 0?"":JSON.stringify(e,void 0,2),"liveBody"),Mt=p(t=>{let e=(0,J.c)(18),{active:o,running:s,showError:n}=t,r=M();if(s){let a;e[0]!==r?(a=r("Sending\u2026"),e[0]=r,e[1]=a):a=e[1];let u;return e[2]!==a?(u=(0,f.jsxDEV)("p",{className:"px-3 py-3 text-xs text-muted-foreground","data-testid":"api-response-running",children:a},void 0,!1),e[2]=a,e[3]=u):u=e[3],u}if(o===void 0||o.body===""){let a;e[4]!==o?.live||e[5]!==r?(a=o?.live===!0?r("Send a request to see the response."):r("No example for this response."),e[4]=o?.live,e[5]=r,e[6]=a):a=e[6];let u;return e[7]!==a?(u=(0,f.jsxDEV)("p",{className:"px-3 py-3 text-xs text-muted-foreground","data-testid":"api-response-idle",children:a},void 0,!1),e[7]=a,e[8]=u):u=e[8],u}let l=n&&"text-destructive",i;e[9]!==l?(i=ge("max-h-[28rem] overflow-auto px-3 py-3 font-mono text-xs",l),e[9]=l,e[10]=i):i=e[10];let d=n?"api-response-error":"api-response-body",c;e[11]!==o.body||e[12]!==n?(c=n?o.body:(0,f.jsxDEV)(jt,{code:o.body},void 0,!1),e[11]=o.body,e[12]=n,e[13]=c):c=e[13];let m;return e[14]!==i||e[15]!==d||e[16]!==c?(m=(0,f.jsxDEV)("pre",{className:i,"data-testid":d,children:c},void 0,!1),e[14]=i,e[15]=d,e[16]=c,e[17]=m):m=e[17],m},"ResponseBody"),Kt=p(()=>{let t=(0,J.c)(67),e=M(),{durationMs:o,error:s,operation:n,response:r,status:l}=qe(),i=l==="running",d=l==="error",c=l==="success"||d,m;if(t[0]!==o||t[1]!==s||t[2]!==d||t[3]!==n.responses||t[4]!==c||t[5]!==r||t[6]!==e){e:{let L=n.responses.map(Ft);if(!c){m=L;break e}let A;t[8]!==s||t[9]!==d||t[10]!==r?(A=Dt(s,r,d),t[8]=s,t[9]=d,t[10]=r,t[11]=A):A=t[11];let _;t[12]!==e?(_=e("Live"),t[12]=e,t[13]=_):_=t[13];let D=d?"error":"200",V;t[14]!==o||t[15]!==A||t[16]!==_||t[17]!==D?(V={body:A,durationMs:o,id:Be,label:_,live:!0,status:D},t[14]=o,t[15]=A,t[16]=_,t[17]=D,t[18]=V):V=t[18],m=[V,...L]}t[0]=o,t[1]=s,t[2]=d,t[3]=n.responses,t[4]=c,t[5]=r,t[6]=e,t[7]=m}else m=t[7];let a=m,u;t[19]!==c||t[20]!==a?(u=c?Be:a.find(Jt)?.id??a[0]?.id??"",t[19]=c,t[20]=a,t[21]=u):u=t[21];let v=u,[k,O]=(0,K.useState)(null),h,g,x,b,S,y,$,N,w,C;if(t[22]!==v||t[23]!==k||t[24]!==e||t[25]!==a){h=a.find(D=>D.id===(k??v))??a[0];let L;t[36]===Symbol.for("react.memo_cache_sentinel")?(L=p(D=>{let{id:V}=D.currentTarget.dataset;V!==void 0&&O(V)},"t82"),t[36]=L):L=t[36],x=L,g=p(()=>{h!==void 0&&re(h.body)},"onCopy");let A=h?.live===!0?h.durationMs:null;b=h?.live===!0&&h.status==="error",w="flex min-h-0 flex-col rounded-xl border border-border bg-card",C="api-response-panel",$="flex items-center justify-between gap-2 border-b border-border px-3 py-2";let _;t[37]!==e?(_=e("Response"),t[37]=e,t[38]=_):_=t[38],t[39]!==_?(N=(0,f.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:_},void 0,!1),t[39]=_,t[40]=N):N=t[40],S="flex items-center gap-2",y=A!==null&&(0,f.jsxDEV)("span",{className:"font-mono text-[10px] text-muted-foreground",children:e("{ms} ms",{ms:A})},void 0,!1),t[22]=v,t[23]=k,t[24]=e,t[25]=a,t[26]=h,t[27]=g,t[28]=x,t[29]=b,t[30]=S,t[31]=y,t[32]=$,t[33]=N,t[34]=w,t[35]=C}else h=t[26],g=t[27],x=t[28],b=t[29],S=t[30],y=t[31],$=t[32],N=t[33],w=t[34],C=t[35];let T;t[41]!==h||t[42]!==g||t[43]!==e?(T=h!==void 0&&h.body!==""&&(0,f.jsxDEV)(H,{"aria-label":e("Copy"),"data-testid":"api-response-copy",onClick:g,size:"icon-xs",type:"button",variant:"ghost",children:(0,f.jsxDEV)(ae,{icon:we,strokeWidth:2},void 0,!1)},void 0,!1),t[41]=h,t[42]=g,t[43]=e,t[44]=T):T=t[44];let I;t[45]!==S||t[46]!==y||t[47]!==T?(I=(0,f.jsxDEV)("div",{className:S,children:[y,T]},void 0,!0),t[45]=S,t[46]=y,t[47]=T,t[48]=I):I=t[48];let P;t[49]!==$||t[50]!==N||t[51]!==I?(P=(0,f.jsxDEV)("div",{className:$,children:[N,I]},void 0,!0),t[49]=$,t[50]=N,t[51]=I,t[52]=P):P=t[52];let E;t[53]!==h?.id||t[54]!==x||t[55]!==a?(E=a.length>0&&(0,f.jsxDEV)("div",{className:"flex gap-1 overflow-x-auto border-b border-border px-2 py-1.5",role:"tablist",children:a.map(L=>{let A=L.id===h?.id;return(0,f.jsxDEV)("button",{"aria-selected":A,className:ge("inline-flex items-center gap-1.5 rounded px-2 py-0.5 font-mono text-xs transition-colors hover:text-foreground aria-selected:bg-muted aria-selected:font-medium",A?Ke(L.status):"text-muted-foreground"),"data-id":L.id,"data-testid":L.live?"api-response-tab-live":`api-response-tab-${L.status}`,onClick:x,role:"tab",type:"button",children:[(0,f.jsxDEV)("span",{className:`size-1.5 rounded-full ${Fe(L.status)}`},void 0,!1),L.label]},L.id,!0)})},void 0,!1),t[53]=h?.id,t[54]=x,t[55]=a,t[56]=E):E=t[56];let j;t[57]!==h||t[58]!==i||t[59]!==b?(j=(0,f.jsxDEV)(Mt,{active:h,running:i,showError:b},void 0,!1),t[57]=h,t[58]=i,t[59]=b,t[60]=j):j=t[60];let R;return t[61]!==P||t[62]!==E||t[63]!==j||t[64]!==w||t[65]!==C?(R=(0,f.jsxDEV)("div",{className:w,"data-testid":C,children:[P,E,j]},void 0,!0),t[61]=P,t[62]=E,t[63]=j,t[64]=w,t[65]=C,t[66]=R):R=t[66],R},"ResponsePanel");function Ft(t){return{body:Bt(t),durationMs:null,id:t.status,label:t.status,live:!1,status:t.status}}p(Ft,"_temp");function Jt(t){return t.status.startsWith("2")}p(Jt,"_temp2");var qt=p((t,e)=>{let o=e.trim().toLowerCase();return o===""?t:t.map(s=>({...s,operations:s.operations.filter(n=>`${n.summary} ${n.operationId}`.toLowerCase().includes(o))})).filter(s=>s.operations.length>0)},"filterGroups"),me=p(t=>{let e=(0,J.c)(53),{model:o}=t,s=M(),n=o.groups[0]?.operations[0]?.key??"",[r,l]=(0,K.useState)(n),[i,d]=(0,K.useState)(""),c;e[0]!==n||e[1]!==o.operationByKey||e[2]!==r?(c=o.operationByKey.get(r)??o.operationByKey.get(n),e[0]=n,e[1]=o.operationByKey,e[2]=r,e[3]=c):c=e[3];let m=c,a,u,v,k,O,h,g,x,b,S;if(e[4]!==i||e[5]!==o.groups||e[6]!==o.server||e[7]!==m?.key||e[8]!==s){a=qt(o.groups,i);let T;e[19]===Symbol.for("react.memo_cache_sentinel")?(T=p(A=>{let{key:_}=A.currentTarget.dataset;_!==void 0&&l(_)},"t102"),e[19]=T):T=e[19];let I=T,P;e[20]===Symbol.for("react.memo_cache_sentinel")?(P=p(A=>{d(A.target.value)},"t112"),e[20]=P):P=e[20];let E=P;u=o.server??"",b="grid min-h-0 flex-1 grid-cols-1 overflow-hidden lg:grid-cols-[16rem_minmax(0,1fr)_22rem]",S="api-reference",e[21]!==s?(O=s("API operations"),e[21]=s,e[22]=O):O=e[22],h="flex min-h-0 flex-col overflow-y-auto border-r border-border",g="api-reference-nav";let j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=(0,f.jsxDEV)(ae,{className:"pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-muted-foreground",icon:Oe,strokeWidth:2},void 0,!1),e[23]=j):j=e[23];let R;e[24]!==s?(R=s("Filter operations"),e[24]=s,e[25]=R):R=e[25],e[26]!==i||e[27]!==R?(x=(0,f.jsxDEV)("div",{className:"sticky top-0 z-10 border-b border-border bg-sidebar p-2",children:(0,f.jsxDEV)("div",{className:"relative",children:[j,(0,f.jsxDEV)(ke,{className:"h-7 pl-7","data-testid":"api-filter",onChange:E,placeholder:R,value:i},void 0,!1)]},void 0,!0)},void 0,!1),e[26]=i,e[27]=R,e[28]=x):x=e[28],v="flex flex-col gap-4 p-2";let L;e[29]!==m?.key||e[30]!==s?(L=p(A=>(0,f.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,f.jsxDEV)("div",{className:"flex items-center justify-between px-2",children:[(0,f.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:A.name||s("(root)")},void 0,!1),(0,f.jsxDEV)("span",{className:"font-mono text-[10px] text-muted-foreground/70",children:A.operations.length},void 0,!1)]},void 0,!0),A.operations.map(_=>{let D=_.key===m?.key;return(0,f.jsxDEV)("button",{"aria-current":D?"page":void 0,className:"flex items-center justify-between gap-2 rounded-md border-l-2 border-transparent px-2 py-1 text-start text-xs text-muted-foreground transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground aria-[current=page]:border-primary aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-key":_.key,"data-testid":`api-nav-${_.operationId}`,onClick:I,type:"button",children:[(0,f.jsxDEV)("span",{className:"truncate",children:_.summary},void 0,!1),(0,f.jsxDEV)(be,{kind:_.kind,method:_.method},void 0,!1)]},_.key,!0)})]},A.name,!0),"t142"),e[29]=m?.key,e[30]=s,e[31]=L):L=e[31],k=a.map(L),e[4]=i,e[5]=o.groups,e[6]=o.server,e[7]=m?.key,e[8]=s,e[9]=a,e[10]=u,e[11]=v,e[12]=k,e[13]=O,e[14]=h,e[15]=g,e[16]=x,e[17]=b,e[18]=S}else a=e[9],u=e[10],v=e[11],k=e[12],O=e[13],h=e[14],g=e[15],x=e[16],b=e[17],S=e[18];let y;e[32]!==a.length||e[33]!==s?(y=a.length===0&&(0,f.jsxDEV)("p",{className:"px-2 py-1 text-xs text-muted-foreground","data-testid":"api-nav-empty",children:s("No operations match your filter.")},void 0,!1),e[32]=a.length,e[33]=s,e[34]=y):y=e[34];let $;e[35]!==y||e[36]!==v||e[37]!==k?($=(0,f.jsxDEV)("div",{className:v,children:[k,y]},void 0,!0),e[35]=y,e[36]=v,e[37]=k,e[38]=$):$=e[38];let N;e[39]!==$||e[40]!==O||e[41]!==h||e[42]!==g||e[43]!==x?(N=(0,f.jsxDEV)("nav",{"aria-label":O,className:h,"data-testid":g,children:[x,$]},void 0,!0),e[39]=$,e[40]=O,e[41]=h,e[42]=g,e[43]=x,e[44]=N):N=e[44];let w;e[45]!==m||e[46]!==u?(w=m===void 0?(0,f.jsxDEV)("div",{className:"lg:col-span-2"},void 0,!1):(0,f.jsxDEV)(It,{operation:m,children:[(0,f.jsxDEV)("div",{className:"min-w-0 overflow-y-auto p-6","data-testid":"api-reference-main",children:(0,f.jsxDEV)(Ct,{operation:m},void 0,!1)},void 0,!1),(0,f.jsxDEV)("aside",{className:"flex min-w-0 flex-col gap-4 overflow-y-auto border-border p-4 lg:border-l","data-testid":"api-reference-aside",children:[(0,f.jsxDEV)(St,{operation:m,server:u},void 0,!1),(0,f.jsxDEV)(Kt,{},void 0,!1)]},void 0,!0)]},m.key,!0),e[45]=m,e[46]=u,e[47]=w):w=e[47];let C;return e[48]!==N||e[49]!==w||e[50]!==b||e[51]!==S?(C=(0,f.jsxDEV)("div",{className:b,"data-testid":S,children:[N,w]},void 0,!0),e[48]=N,e[49]=w,e[50]=b,e[51]=S,e[52]=C):C=e[52],C},"ReferenceView");var Y=q(ne(),1);var Vt=["get","post","put","patch","delete","head","options","trace"],ze=p(t=>t?.content?.["application/json"]?.schema,"jsonSchemaOf"),zt=p((t,e)=>Object.entries(t.responses??{}).map(([o,s])=>{let n=s.$ref?.replace("#/components/responses/",""),r=n===void 0?s:e.components?.responses?.[n]??s;return{description:r.description,schema:ze(r),status:o}}),"buildResponses"),Ht=p((t,e,o,s,n)=>{let r=ze(s.requestBody),l=r?.properties?.functionPath?.const,i=typeof l=="string"?l:void 0,d=i===void 0?r:r?.properties?.args,c=s.operationId??`${o} ${e}`;return{argsSchema:d,description:s.description,functionPath:i,httpPath:e,key:t,kind:s["x-lunora-function-kind"],method:o.toUpperCase(),operationId:c,requestSchema:r,responses:zt(s,n),summary:s.summary??c,tags:s.tags??[],title:s.summary??c}},"flattenOperation"),Wt=p(t=>{let e=[];for(let[o,s]of Object.entries(t.paths??{})){let n=o.includes("#")?o.slice(0,o.indexOf("#")):o;for(let r of Vt){let l=s[r];l!==void 0&&e.push(Ht(o,n,r,l,t))}}return e},"collectOperations"),Gt=p(t=>{let e=t??{},o=Wt(e),s=new Map((e.tags??[]).map(i=>[i.name,i.description])),n=new Set,r=[],l=p(i=>{if(n.has(i))return;n.add(i);let d=o.filter(c=>(c.tags[0]??"")===i);d.length>0&&r.push({description:s.get(i),name:i,operations:d})},"pushGroup");for(let i of e.tags??[])l(i.name);for(let i of o)l(i.tags[0]??"");return{groups:r,operationByKey:new Map(o.map(i=>[i.key,i])),server:e.servers?.[0]?.url,title:e.info?.title??"API reference",version:e.info?.version}},"parseOpenApi"),Ut=p(t=>{let{paths:e}=t;return e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0},"isEmptySpec"),Yt=p(t=>{let e=t;return Ut(e)?{kind:"empty"}:{kind:"ready",spec:e}},"classifySpec"),He=p(t=>{let e=(0,Ve.c)(23),{spec:o}=t,s=M(),n=G(),r;e[0]!==n?(r=p(()=>n.fetchOpenApi(),"t1"),e[0]=n,e[1]=r):r=e[1];let i=ue(o,r,Yt),d;e[2]!==i.kind||e[3]!==i.spec?(d=i.kind==="ready"?Gt(i.spec):void 0,e[2]=i.kind,e[3]=i.spec,e[4]=d):d=e[4];let c=d;if(i.kind==="loading"){let a;return e[5]===Symbol.for("react.memo_cache_sentinel")?(a=(0,Y.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"api-reference-loading",children:[(0,Y.jsxDEV)(X,{className:"h-8 w-48"},void 0,!1),(0,Y.jsxDEV)(X,{className:"h-64 w-full"},void 0,!1)]},void 0,!0),e[5]=a):a=e[5],a}if(i.kind==="error"){let a;e[6]!==i.message||e[7]!==s?(a=s("Couldn't load the OpenAPI spec: {message}",{message:i.message}),e[6]=i.message,e[7]=s,e[8]=a):a=e[8];let u;e[9]!==s?(u=s("API reference unavailable"),e[9]=s,e[10]=u):u=e[10];let v;return e[11]!==a||e[12]!==u?(v=(0,Y.jsxDEV)(W,{description:a,testId:"api-reference-error",title:u},void 0,!1),e[11]=a,e[12]=u,e[13]=v):v=e[13],v}if(i.kind==="empty"||c===void 0){let a;e[14]!==s?(a=s("Run `lunora codegen` and wire `_generated/openapi.json` to the worker to render the API reference here."),e[14]=s,e[15]=a):a=e[15];let u;e[16]!==s?(u=s("No OpenAPI spec configured"),e[16]=s,e[17]=u):u=e[17];let v;return e[18]!==a||e[19]!==u?(v=(0,Y.jsxDEV)(W,{description:a,testId:"api-reference-empty",title:u},void 0,!1),e[18]=a,e[19]=u,e[20]=v):v=e[20],v}let m;return e[21]!==c?(m=(0,Y.jsxDEV)(me,{model:c},void 0,!1),e[21]=c,e[22]=m):m=e[22],m},"ApiReferencePanel");var We=q(oe(),1);var Q=q(ne(),1);var Qt=p(t=>(t.params??[]).find(e=>e.name==="args")??(t.params??[])[0],"argsParameterOf"),Xt=p(t=>t["x-tags"]?.[0]?.name??(t.name.includes(":")?t.name.slice(0,t.name.indexOf(":")):""),"namespaceOf"),Zt=p(t=>{let e=Qt(t)?.schema;return{argsSchema:e,description:t.description,functionPath:t.name,httpPath:"/_lunora/rpc",key:t.name,kind:t["x-lunora-function-kind"],method:"POST",operationId:t.name,requestSchema:e,responses:[{description:t.result?.name,schema:t.result?.schema,status:"200"}],summary:t.summary??t.name,tags:[Xt(t)],title:t.summary??t.name}},"toOperation"),es=p(t=>{let e=t??{},o=(e.methods??[]).map(r=>Zt(r)),s=new Map;for(let r of o){let l=r.tags[0]??"",i=s.get(l)??[];i.push(r),s.set(l,i)}return{groups:[...s.entries()].map(([r,l])=>({name:r,operations:l.toSorted((i,d)=>i.operationId.localeCompare(d.operationId))})).toSorted((r,l)=>r.name.localeCompare(l.name)),operationByKey:new Map(o.map(r=>[r.key,r])),title:e.info?.title??"API reference",version:e.info?.version}},"parseOpenRpc"),ts=p(t=>t.methods===void 0||t.methods.length===0,"isEmptyDocument"),ss=p(t=>{let e=t;return ts(e)?{kind:"empty"}:{kind:"ready",spec:e}},"classifyDocument"),Ge=p(t=>{let e=(0,We.c)(23),{spec:o}=t,s=M(),n=G(),r;e[0]!==n?(r=p(()=>n.fetchOpenRpc(),"t1"),e[0]=n,e[1]=r):r=e[1];let i=ue(o,r,ss),d;e[2]!==i.kind||e[3]!==i.spec?(d=i.kind==="ready"?es(i.spec):void 0,e[2]=i.kind,e[3]=i.spec,e[4]=d):d=e[4];let c=d;if(i.kind==="loading"){let a;return e[5]===Symbol.for("react.memo_cache_sentinel")?(a=(0,Q.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"openrpc-reference-loading",children:[(0,Q.jsxDEV)(X,{className:"h-8 w-48"},void 0,!1),(0,Q.jsxDEV)(X,{className:"h-64 w-full"},void 0,!1)]},void 0,!0),e[5]=a):a=e[5],a}if(i.kind==="error"){let a;e[6]!==i.message||e[7]!==s?(a=s("Couldn't load the OpenRPC spec: {message}",{message:i.message}),e[6]=i.message,e[7]=s,e[8]=a):a=e[8];let u;e[9]!==s?(u=s("API reference unavailable"),e[9]=s,e[10]=u):u=e[10];let v;return e[11]!==a||e[12]!==u?(v=(0,Q.jsxDEV)(W,{description:a,testId:"openrpc-reference-error",title:u},void 0,!1),e[11]=a,e[12]=u,e[13]=v):v=e[13],v}if(i.kind==="empty"||c===void 0){let a;e[14]!==s?(a=s("Run `lunora codegen --api-spec openrpc` and wire `_generated/openrpc.json` to the worker to render the OpenRPC reference here."),e[14]=s,e[15]=a):a=e[15];let u;e[16]!==s?(u=s("No OpenRPC spec configured"),e[16]=s,e[17]=u):u=e[17];let v;return e[18]!==a||e[19]!==u?(v=(0,Q.jsxDEV)(W,{description:a,testId:"openrpc-reference-empty",title:u},void 0,!1),e[18]=a,e[19]=u,e[20]=v):v=e[20],v}let m;return e[21]!==c?(m=(0,Q.jsxDEV)(me,{model:c},void 0,!1),e[21]=c,e[22]=m):m=e[22],m},"OpenRpcReferencePanel");var z=q(ne(),1);var os=["reference","snippets"],ns=["openapi","openrpc"],Ws=p(t=>{let e=(0,Ue.c)(51),{functions:o,initialShardKey:s,openApiSpec:n,openRpcSpec:r}=t,l=M(),[i,d]=(0,ye.useState)("reference"),[c,m]=(0,ye.useState)("openapi"),a;e[0]!==l?(a=l("Reference"),e[0]=l,e[1]=a):a=e[1];let u;e[2]!==l?(u=l("Snippets"),e[2]=l,e[3]=u):u=e[3];let v;e[4]!==a||e[5]!==u?(v={reference:a,snippets:u},e[4]=a,e[5]=u,e[6]=v):v=e[6];let k=v,O;e[7]!==l?(O=l("OpenAPI"),e[7]=l,e[8]=O):O=e[8];let h;e[9]!==l?(h=l("OpenRPC"),e[9]=l,e[10]=h):h=e[10];let g;e[11]!==O||e[12]!==h?(g={openapi:O,openrpc:h},e[11]=O,e[12]=h,e[13]=g):g=e[13];let x=g,b;e[14]===Symbol.for("react.memo_cache_sentinel")?(b=p(A=>{d(A.currentTarget.dataset.view)},"t7"),e[14]=b):b=e[14];let S=b,y;e[15]===Symbol.for("react.memo_cache_sentinel")?(y=p(A=>{m(A.currentTarget.dataset.format)},"t8"),e[15]=y):y=e[15];let $=y,N;e[16]!==l?(N=l("API view"),e[16]=l,e[17]=N):N=e[17];let w;e[18]!==i||e[19]!==k?(w=os.map(A=>(0,z.jsxDEV)(H,{"aria-selected":i===A,"data-testid":`api-view-${A}`,"data-view":A,onClick:S,role:"tab",size:"sm",type:"button",variant:i===A?"default":"outline",children:k[A]},A,!1)),e[18]=i,e[19]=k,e[20]=w):w=e[20];let C;e[21]!==w||e[22]!==N?(C=(0,z.jsxDEV)("div",{"aria-label":N,className:"flex gap-1.5","data-testid":"api-view-toggle",role:"tablist",children:w},void 0,!1),e[21]=w,e[22]=N,e[23]=C):C=e[23];let T;e[24]!==c||e[25]!==x||e[26]!==l||e[27]!==i?(T=i==="reference"&&(0,z.jsxDEV)("div",{"aria-label":l("API spec format"),className:"flex gap-1.5","data-testid":"api-format-toggle",role:"tablist",children:ns.map(A=>(0,z.jsxDEV)(H,{"aria-selected":c===A,"data-format":A,"data-testid":`api-format-${A}`,onClick:$,role:"tab",size:"sm",type:"button",variant:c===A?"default":"outline",children:x[A]},A,!1))},void 0,!1),e[24]=c,e[25]=x,e[26]=l,e[27]=i,e[28]=T):T=e[28];let I;e[29]!==C||e[30]!==T?(I=(0,z.jsxDEV)("div",{className:"flex shrink-0 flex-wrap items-center gap-3 border-b border-border px-6 py-3",children:[C,T]},void 0,!0),e[29]=C,e[30]=T,e[31]=I):I=e[31];let P;e[32]!==o||e[33]!==s||e[34]!==i?(P=i==="snippets"&&(0,z.jsxDEV)("div",{className:"min-h-0 flex-1 overflow-y-auto p-6",children:(0,z.jsxDEV)(je,{functions:o,initialShardKey:s},void 0,!1)},void 0,!1),e[32]=o,e[33]=s,e[34]=i,e[35]=P):P=e[35];let E;e[36]!==c||e[37]!==n||e[38]!==i?(E=i==="reference"&&c==="openapi"&&(0,z.jsxDEV)(He,{spec:n},void 0,!1),e[36]=c,e[37]=n,e[38]=i,e[39]=E):E=e[39];let j;e[40]!==c||e[41]!==r||e[42]!==i?(j=i==="reference"&&c==="openrpc"&&(0,z.jsxDEV)(Ge,{spec:r},void 0,!1),e[40]=c,e[41]=r,e[42]=i,e[43]=j):j=e[43];let R;e[44]!==P||e[45]!==E||e[46]!==j?(R=(0,z.jsxDEV)("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[P,E,j]},void 0,!0),e[44]=P,e[45]=E,e[46]=j,e[47]=R):R=e[47];let L;return e[48]!==I||e[49]!==R?(L=(0,z.jsxDEV)("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"lunora-api-tab",children:[I,R]},void 0,!0),e[48]=I,e[49]=R,e[50]=L):L=e[50],L},"ApiTab");export{Ws as default};
@@ -0,0 +1 @@
1
+ import{c as y}from"./chunk-CKSHCYGC.js";import{a as n,e as b,f as h}from"./chunk-RRCPZMC2.js";var N=b(h(),1);var _=n(()=>{},"noop"),F=typeof document<"u"?N.useLayoutEffect:_;var O=b(h(),1),l={...O};var a=l.useInsertionEffect,V=a&&a!==l.useLayoutEffect?a:t=>t();function z(t){let e=y(B).current;return e.next=t,V(e.effect),e.trampoline}n(z,"useStableCallback");function B(){let t={next:void 0,callback:W,trampoline:n((...e)=>t.callback?.(...e),"trampoline"),effect:n(()=>{t.callback=t.next},"effect")};return t}n(B,"createStableCallback");function W(){throw new Error("Base UI: Cannot call an event handler while rendering.")}n(W,"assertNotCalled");function u(){return typeof window<"u"}n(u,"hasWindow");function m(t){return v(t)?(t.nodeName||"").toLowerCase():"#document"}n(m,"getNodeName");function i(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}n(i,"getWindow");function $(t){var e;return(e=(v(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}n($,"getDocumentElement");function v(t){return u()?t instanceof Node||t instanceof i(t).Node:!1}n(v,"isNode");function C(t){return u()?t instanceof Element||t instanceof i(t).Element:!1}n(C,"isElement");function L(t){return u()?t instanceof HTMLElement||t instanceof i(t).HTMLElement:!1}n(L,"isHTMLElement");function S(t){return!u()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof i(t).ShadowRoot}n(S,"isShadowRoot");function R(t){let{overflow:e,overflowX:c,overflowY:s,display:o}=k(t);return/auto|scroll|overlay|hidden|clip/.test(e+s+c)&&o!=="inline"&&o!=="contents"}n(R,"isOverflowElement");function Q(t){return/^(table|td|th)$/.test(m(t))}n(Q,"isTableElement");function I(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}n(I,"isTopLayer");var A=/transform|translate|scale|rotate|perspective|filter/,H=/paint|layout|strict|content/,r=n(t=>!!t&&t!=="none","isNotNone"),d;function K(t){let e=C(t)?k(t):t;return r(e.transform)||r(e.translate)||r(e.scale)||r(e.rotate)||r(e.perspective)||!M()&&(r(e.backdropFilter)||r(e.filter))||A.test(e.willChange||"")||H.test(e.contain||"")}n(K,"isContainingBlock");function Z(t){let e=p(t);for(;L(e)&&!D(e);){if(K(e))return e;if(I(e))return null;e=p(e)}return null}n(Z,"getContainingBlock");function M(){return d==null&&(d=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),d}n(M,"isWebKit");function D(t){return/^(html|body|#document)$/.test(m(t))}n(D,"isLastTraversableNode");function k(t){return i(t).getComputedStyle(t)}n(k,"getComputedStyle");function tt(t){return C(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}n(tt,"getNodeScroll");function p(t){if(m(t)==="html")return t;let e=t.assignedSlot||t.parentNode||S(t)&&t.host||$(t);return S(e)?e.host:e}n(p,"getParentNode");function x(t){let e=p(t);return D(e)?t.ownerDocument?t.ownerDocument.body:t.body:L(e)&&R(e)?e:x(e)}n(x,"getNearestOverflowAncestor");function g(t,e,c){var s;e===void 0&&(e=[]),c===void 0&&(c=!0);let o=x(t),T=o===((s=t.ownerDocument)==null?void 0:s.body),f=i(o);if(T){let E=j(f);return e.concat(f,f.visualViewport||[],R(o)?o:[],E&&c?g(E):[])}else return e.concat(o,g(o,[],c))}n(g,"getOverflowAncestors");function j(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}n(j,"getFrameElement");var w;w=new Set;function ot(...t){{let e=t.join(" ");w.has(e)||(w.add(e),console.error(`Base UI: ${e}`))}}n(ot,"error");export{F as a,l as b,z as c,m as d,i as e,$ as f,v as g,C as h,L as i,S as j,R as k,Q as l,I as m,K as n,Z as o,M as p,D as q,k as r,tt as s,p as t,g as u,j as v,ot as w};
@@ -0,0 +1 @@
1
+ import{a as le}from"./chunk-LAK5VSPI.js";import{b as ae}from"./chunk-KJJ3WM6H.js";import{a as ne}from"./chunk-TQ36RWOP.js";import{a as oe}from"./chunk-UGUEC6BC.js";import{a as re}from"./chunk-2K47A3P6.js";import{a as se}from"./chunk-HN6KJXYQ.js";import"./chunk-XNJNSCLM.js";import{a as te}from"./chunk-UKDJ4H7I.js";import{b as ee}from"./chunk-TBMYIZIO.js";import{R as E}from"./chunk-3CJW6NWG.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as U}from"./chunk-BOXSWNXZ.js";import{a as Z}from"./chunk-TAD43CG5.js";import{b as K}from"./chunk-RHZ4M2NZ.js";import{b as D}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import"./chunk-XLXNLJ4N.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as X}from"./chunk-E75ANNWX.js";import"./chunk-JHKMUTIF.js";import{a as i,e as z,f as Te,g as qe,h as Pe,j as R}from"./chunk-RRCPZMC2.js";var T=z(qe(),1);var m=z(Te(),1);var r=z(Pe(),1);var Y=400,Me=36,Oe={height:Y,overflow:"auto"},ue={left:0,position:"absolute",top:0,width:"100%"},Ae={debug:"secondary",error:"destructive",info:"outline",warn:"secondary"},Fe={error:"destructive",ok:"secondary"},_e=i(a=>{let e=(0,T.c)(21),{entry:t,index:l,measureRef:n,start:o}=a,d=`translateY(${String(o)}px)`,v;e[0]!==d?(v={...ue,transform:d},e[0]=d,e[1]=v):v=e[1];let f=v,u;e[2]!==t.timestamp?(u=new Date(t.timestamp).toLocaleString(),e[2]=t.timestamp,e[3]=u):u=e[3];let c;e[4]!==u?(c=(0,r.jsxDEV)("span",{className:"w-44 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:u},void 0,!1),e[4]=u,e[5]=c):c=e[5];let y=Ae[t.level],g;e[6]!==t.level||e[7]!==y?(g=(0,r.jsxDEV)("span",{className:"w-20 shrink-0",role:"gridcell",children:(0,r.jsxDEV)(D,{variant:y,children:t.level},void 0,!1)},void 0,!1),e[6]=t.level,e[7]=y,e[8]=g):g=e[8];let b=t.functionPath??"\u2014",p;e[9]!==b?(p=(0,r.jsxDEV)("span",{className:"w-48 shrink-0 truncate text-muted-foreground",role:"gridcell",children:b},void 0,!1),e[9]=b,e[10]=p):p=e[10];let h;e[11]!==t.message?(h=(0,r.jsxDEV)("span",{className:"flex-1 truncate",role:"gridcell",children:t.message},void 0,!1),e[11]=t.message,e[12]=h):h=e[12];let x;return e[13]!==l||e[14]!==n||e[15]!==f||e[16]!==c||e[17]!==g||e[18]!==p||e[19]!==h?(x=(0,r.jsxDEV)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":l,"data-testid":"lg-row",ref:n,role:"row",style:f,children:[c,g,p,h]},void 0,!0),e[13]=l,e[14]=n,e[15]=f,e[16]=c,e[17]=g,e[18]=p,e[19]=h,e[20]=x):x=e[20],x},"LogRow"),ie=i(a=>a.length===0?"\u2014":a.join(", "),"tablesLabel"),Ve=i(a=>{let e=(0,T.c)(37),{entry:t,index:l,measureRef:n,start:o}=a,d=`translateY(${String(o)}px)`,v;e[0]!==d?(v={...ue,transform:d},e[0]=d,e[1]=v):v=e[1];let f=v,u;e[2]!==t.ts?(u=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=u):u=e[3];let c;e[4]!==u?(c=(0,r.jsxDEV)("span",{className:"w-40 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:u},void 0,!1),e[4]=u,e[5]=c):c=e[5];let y=Fe[t.outcome],g;e[6]!==t.outcome||e[7]!==y?(g=(0,r.jsxDEV)("span",{className:"w-16 shrink-0",role:"gridcell",children:(0,r.jsxDEV)(D,{variant:y,children:t.outcome},void 0,!1)},void 0,!1),e[6]=t.outcome,e[7]=y,e[8]=g):g=e[8];let b;e[9]!==t.functionPath?(b=(0,r.jsxDEV)("span",{className:"w-44 shrink-0 truncate",role:"gridcell",title:t.functionPath,children:t.functionPath},void 0,!1),e[9]=t.functionPath,e[10]=b):b=e[10];let p=t.shardKey??"\u2014",h;e[11]!==p?(h=(0,r.jsxDEV)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:p},void 0,!1),e[11]=p,e[12]=h):h=e[12];let x=t.userId??"\u2014",L;e[13]!==x?(L=(0,r.jsxDEV)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:x},void 0,!1),e[13]=x,e[14]=L):L=e[14];let k;e[15]!==t.durationMs?(k=Math.round(t.durationMs),e[15]=t.durationMs,e[16]=k):k=e[16];let I=`${String(k)}ms`,w;e[17]!==I?(w=(0,r.jsxDEV)("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:I},void 0,!1),e[17]=I,e[18]=w):w=e[18];let S;e[19]!==t.errorMessage||e[20]!==t.outcome||e[21]!==t.tablesRead||e[22]!==t.tablesWritten?(S=t.outcome==="error"&&t.errorMessage!==void 0?t.errorMessage:`r:${ie(t.tablesRead)} \xB7 w:${ie(t.tablesWritten)}`,e[19]=t.errorMessage,e[20]=t.outcome,e[21]=t.tablesRead,e[22]=t.tablesWritten,e[23]=S):S=e[23];let N;e[24]!==S?(N=(0,r.jsxDEV)("span",{className:"flex-1 truncate text-muted-foreground",role:"gridcell",children:S},void 0,!1),e[24]=S,e[25]=N):N=e[25];let C;return e[26]!==l||e[27]!==n||e[28]!==f||e[29]!==L||e[30]!==w||e[31]!==N||e[32]!==c||e[33]!==g||e[34]!==b||e[35]!==h?(C=(0,r.jsxDEV)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":l,"data-testid":"lg-req-row",ref:n,role:"row",style:f,children:[c,g,b,h,L,w,N]},void 0,!0),e[26]=l,e[27]=n,e[28]=f,e[29]=L,e[30]=w,e[31]=N,e[32]=c,e[33]=g,e[34]=b,e[35]=h,e[36]=C):C=e[36],C},"RequestRow"),de=i(a=>{let{entries:e}=a??{};return Array.isArray(e)?e:[]},"entriesOf"),$e=i(a=>{let e={};return a.functionPathPrefix.trim()!==""&&(e.functionPathPrefix=a.functionPathPrefix.trim()),a.userId.trim()!==""&&(e.userId=a.userId.trim()),a.tableTouched.trim()!==""&&(e.tableTouched=a.tableTouched.trim()),(a.outcome==="ok"||a.outcome==="error")&&(e.outcome=a.outcome),e},"buildRequestQuery"),me=["debug","info","warn","error"],Be={"5m":300*1e3,"15m":900*1e3,"1h":3600*1e3},ze=i((a,e)=>{let t=e.search.trim().toLowerCase(),l=e.path.trim().toLowerCase(),n=e.range==="all"?Number.NEGATIVE_INFINITY:e.now-Be[e.range];return a.filter(o=>e.levels.size>0&&!e.levels.has(o.level)||o.timestamp<n||l!==""&&!(o.functionPath??"").toLowerCase().includes(l)?!1:t===""||o.message.toLowerCase().includes(t))},"filterLogs"),De="\u2014",Ke=i(a=>{let e=new Map,t=new Map;for(let o of a){e.set(o.level,(e.get(o.level)??0)+1);let d=o.functionPath??De;t.set(d,(t.get(d)??0)+1)}let l=me.filter(o=>e.has(o)).map(o=>({count:e.get(o)??0,key:o})),n=[...t.entries()].map(([o,d])=>({count:d,key:o})).toSorted((o,d)=>d.count===o.count?o.key.localeCompare(d.key):d.count-o.count);return{byLevel:l,byPath:n,total:a.length}},"summarizeLogs"),Ue=i(a=>{let e=(0,T.c)(11),{level:t,onToggle:l,selected:n}=a,o;e[0]!==t||e[1]!==l?(o=i(()=>{l(t)},"t1"),e[0]=t,e[1]=l,e[2]=o):o=e[2];let d=o,v=n?"border-border bg-muted font-medium":"border-input text-muted-foreground",f;e[3]!==v?(f=R("rounded-md border px-2 py-1 text-xs",v),e[3]=v,e[4]=f):f=e[4];let u=`logs-level-${t}`,c;return e[5]!==t||e[6]!==d||e[7]!==n||e[8]!==f||e[9]!==u?(c=(0,r.jsxDEV)("button",{"aria-pressed":n,className:f,"data-testid":u,onClick:d,type:"button",children:t},void 0,!1),e[5]=t,e[6]=d,e[7]=n,e[8]=f,e[9]=u,e[10]=c):c=e[10],c},"LevelToggle"),ce=i(a=>{let e=(0,T.c)(7),{bucket:t}=a,l;e[0]!==t.key?(l=(0,r.jsxDEV)("span",{className:"truncate text-muted-foreground",role:"gridcell",children:t.key},void 0,!1),e[0]=t.key,e[1]=l):l=e[1];let n;e[2]!==t.count?(n=(0,r.jsxDEV)("span",{className:"shrink-0 tabular-nums",role:"gridcell",children:t.count},void 0,!1),e[2]=t.count,e[3]=n):n=e[3];let o;return e[4]!==l||e[5]!==n?(o=(0,r.jsxDEV)("div",{className:"flex items-center justify-between gap-4 px-3 py-1 font-mono text-xs","data-testid":"logs-summary-row",role:"row",children:[l,n]},void 0,!0),e[4]=l,e[5]=n,e[6]=o):o=e[6],o},"SummaryBucketRow"),nt=i(({initialShardKey:a})=>{let e=X(),[t,l]=(0,m.useState)("requests"),[n,o]=(0,m.useState)(a??""),[d,v]=(0,m.useState)(""),[f,u]=(0,m.useState)(()=>new Set),[c,y]=(0,m.useState)(""),[g,b]=(0,m.useState)("all"),[p,h]=(0,m.useState)(!1),[x,L]=(0,m.useState)(""),[k,I]=(0,m.useState)(""),[w,S]=(0,m.useState)(""),[N,C]=(0,m.useState)("all"),q=re(n.trim(),400),fe=$e({functionPathPrefix:x,outcome:N,tableTouched:w,userId:k}),Q=K(U.getRequestLog,fe,{enabled:t==="requests",live:!0,shardKey:q}),W=K(U.getLogs,{},{enabled:t==="errors",live:!0,shardKey:q}),A=t==="requests"?Q:W,{error:G,errorSource:he,isLoading:H,liveError:ge}=A,ve=de(W.data),j=de(Q.data);(0,m.useEffect)(()=>{A.data!==void 0&&ee(q)},[A.data,q]);let F=ze(ve,{levels:f,now:Date.now(),path:c,range:g,search:d}),_=Ke(F),V=t==="requests"?j.length:F.length,$=t==="errors"&&p,P=(0,m.useMemo)(()=>G!==null?"error":V===0?H?$?"summary":"list":"empty":$?"summary":"list",[V,H,G,$]),J=(0,m.useRef)(null),M=ae({count:V,estimateSize:i(()=>Me,"estimateSize"),getScrollElement:i(()=>J.current,"getScrollElement"),initialRect:{height:Y,width:800},observeElementRect:i((s,B)=>le(s,B,Y),"observeElementRect"),overscan:8}),pe=M.getVirtualItems(),be={height:M.getTotalSize(),position:"relative",width:"100%"},xe=i(s=>{v(s.target.value)},"onSearchChange"),ye=i(s=>{u(B=>{let O=new Set(B);return O.has(s)?O.delete(s):O.add(s),O})},"toggleLevel"),we=i(s=>{y(s.target.value)},"onLogPathChange"),Ne=i(s=>{b(s.target.value)},"onTimeRangeChange"),Le=i(()=>{h(s=>!s)},"toggleSummary"),Se=i(s=>{L(s.target.value)},"onPathChange"),ke=i(s=>{I(s.target.value)},"onUserChange"),Ce=i(s=>{S(s.target.value)},"onTableChange"),Ee=i(s=>{C(s.target.value)},"onOutcomeChange"),Ie=i(()=>{l("requests"),h(!1)},"showRequests"),Re=i(()=>{l("errors"),h(!1)},"showErrors");return(0,r.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-logs",children:[(0,r.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxDEV)("div",{className:"inline-flex overflow-hidden rounded-lg border border-border",role:"tablist",children:[(0,r.jsxDEV)("button",{"aria-selected":t==="requests",className:R("px-3 py-1 text-sm",t==="requests"?"bg-muted font-medium":"text-muted-foreground"),"data-testid":"lg-view-requests",onClick:Ie,role:"tab",type:"button",children:e("Requests")},void 0,!1),(0,r.jsxDEV)("button",{"aria-selected":t==="errors",className:R("px-3 py-1 text-sm",t==="errors"?"bg-muted font-medium":"text-muted-foreground"),"data-testid":"lg-view-errors",onClick:Re,role:"tab",type:"button",children:e("Errors")},void 0,!1)]},void 0,!0),(0,r.jsxDEV)(te,{onChange:o,testId:"lg-shard-input",value:n},void 0,!1),(0,r.jsxDEV)(oe,{message:ge,prefix:"lg"},void 0,!1),(0,r.jsxDEV)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"lg-cf-link",href:ne,rel:"noreferrer",target:"_blank",children:e("Open in Cloudflare")},void 0,!1)]},void 0,!0),t==="errors"&&(0,r.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxDEV)(E,{"aria-label":e("Search messages"),className:"h-8 w-48","data-testid":"lg-search",onChange:xe,placeholder:e("search message"),value:d},void 0,!1),(0,r.jsxDEV)(E,{"aria-label":e("Function path"),className:"h-8 w-40","data-testid":"logs-path-filter",onChange:we,placeholder:e("filter path"),value:c},void 0,!1),(0,r.jsxDEV)("div",{"aria-label":e("Level filter"),className:"inline-flex items-center gap-1","data-testid":"logs-level-filter",role:"group",children:me.map(s=>(0,r.jsxDEV)(Ue,{level:s,onToggle:ye,selected:f.has(s)},s,!1))},void 0,!1),(0,r.jsxDEV)("select",{"aria-label":e("Time range"),className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"logs-time-range",onChange:Ne,value:g,children:[(0,r.jsxDEV)("option",{value:"all",children:e("All time")},void 0,!1),(0,r.jsxDEV)("option",{value:"5m",children:e("Last 5m")},void 0,!1),(0,r.jsxDEV)("option",{value:"15m",children:e("Last 15m")},void 0,!1),(0,r.jsxDEV)("option",{value:"1h",children:e("Last hour")},void 0,!1)]},void 0,!0),(0,r.jsxDEV)("button",{"aria-pressed":p,className:R("h-8 rounded-md border px-3 text-sm",p?"border-border bg-muted font-medium":"border-input text-muted-foreground"),"data-testid":"logs-summary-toggle",onClick:Le,type:"button",children:e(p?"List":"Summary")},void 0,!1)]},void 0,!0),t==="requests"&&(0,r.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxDEV)(E,{"aria-label":e("Function path"),className:"h-8 w-44","data-testid":"lg-req-path",onChange:Se,placeholder:e("file:function"),value:x},void 0,!1),(0,r.jsxDEV)(E,{"aria-label":e("User id"),className:"h-8 w-32","data-testid":"lg-req-user",onChange:ke,placeholder:e("userId"),value:k},void 0,!1),(0,r.jsxDEV)(E,{"aria-label":e("Table touched"),className:"h-8 w-32","data-testid":"lg-req-table",onChange:Ce,placeholder:e("table"),value:w},void 0,!1),(0,r.jsxDEV)("select",{"aria-label":e("Outcome filter"),className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"lg-req-outcome",onChange:Ee,value:N,children:[(0,r.jsxDEV)("option",{value:"all",children:e("all")},void 0,!1),(0,r.jsxDEV)("option",{value:"ok",children:e("ok")},void 0,!1),(0,r.jsxDEV)("option",{value:"error",children:e("error")},void 0,!1)]},void 0,!0)]},void 0,!0),P==="error"&&(0,r.jsxDEV)(se,{error:he,testId:"lg-error"},void 0,!1),P==="empty"&&(0,r.jsxDEV)(Z,{description:e("Function and request logs for this shard show up here as your app handles traffic."),icon:(0,r.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsxDEV)("path",{d:"M4 5h16M4 12h16M4 19h10"},void 0,!1)},void 0,!1),testId:"lg-empty",title:e("No logs.")},void 0,!1),P==="summary"&&(0,r.jsxDEV)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"logs-summary",children:[(0,r.jsxDEV)("p",{className:"text-xs text-muted-foreground","data-testid":"logs-summary-total",children:e("{count} entries",{count:_.total})},void 0,!1),(0,r.jsxDEV)("div",{children:[(0,r.jsxDEV)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:e("By level")},void 0,!1),(0,r.jsxDEV)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-levels",role:"grid",children:_.byLevel.map(s=>(0,r.jsxDEV)(ce,{bucket:s},s.key,!1))},void 0,!1)]},void 0,!0),(0,r.jsxDEV)("div",{children:[(0,r.jsxDEV)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:e("By function")},void 0,!1),(0,r.jsxDEV)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-paths",role:"grid",children:_.byPath.map(s=>(0,r.jsxDEV)(ce,{bucket:s},s.key,!1))},void 0,!1)]},void 0,!0)]},void 0,!0),P==="list"&&(0,r.jsxDEV)("div",{className:"rounded-xl border border-border shadow-xs","data-testid":"lg-scroll",ref:J,style:Oe,children:(0,r.jsxDEV)("div",{"aria-label":e("Recent logs"),"data-testid":"lg-table",role:"grid",style:be,children:pe.map(s=>t==="requests"?(0,r.jsxDEV)(Ve,{entry:j[s.index],index:s.index,measureRef:M.measureElement,start:s.start},s.key,!1):(0,r.jsxDEV)(_e,{entry:F[s.index],index:s.index,measureRef:M.measureElement,start:s.start},s.key,!1))},void 0,!1)},void 0,!1)]},void 0,!0)},"LogsPanel");export{nt as LogsPanel,ze as filterLogs,Ke as summarizeLogs};
@@ -0,0 +1 @@
1
+ import{a as T,b as w,c as A,d as C}from"./chunk-6HSHEMZV.js";import{d as y,j as N}from"./chunk-E75ANNWX.js";import{a as i,e as b,f as x,g as E,h as I}from"./chunk-RRCPZMC2.js";var g=b(E(),1);var m=b(I(),1),S=b(x(),1);var _=50,B={value:{colors:{dark:["var(--chart-1)"],light:["var(--chart-1)"]},label:"value"}},J=i(s=>{let t=s.columns.find(l=>s.rows.length>0&&s.rows.every(n=>typeof n[l]=="number"))??null;return{label:s.columns.find(l=>l!==t)??null,value:t}},"pickColumns"),X=i(s=>{let t=(0,g.c)(15),{result:e}=s,l=y(),n;t[0]!==e?(n=J(e),t[0]=e,t[1]=n):n=t[1];let{label:o,value:r}=n,a;t[2]!==o||t[3]!==e||t[4]!==r?(a=r===null?[]:e.rows.slice(0,_).map((c,h)=>({label:o===null?`#${(h+1).toString()}`:N(c[o]),value:Number(c[r])||0})),t[2]=o,t[3]=e,t[4]=r,t[5]=a):a=t[5];let u=a;if(r===null){let c;t[6]!==l?(c=l("No numeric column to chart."),t[6]=l,t[7]=c):c=t[7];let h;return t[8]!==c?(h=(0,m.jsxDEV)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-chart-empty",children:c},void 0,!1),t[8]=c,t[9]=h):h=t[9],h}let f,d,v;t[10]===Symbol.for("react.memo_cache_sentinel")?(f=(0,m.jsxDEV)(A,{dataKey:"label"},void 0,!1),d=(0,m.jsxDEV)(w,{dataKey:"value"},void 0,!1),v=(0,m.jsxDEV)(C,{},void 0,!1),t[10]=f,t[11]=d,t[12]=v):(f=t[10],d=t[11],v=t[12]);let p;return t[13]!==u?(p=(0,m.jsxDEV)("div",{className:"h-80 w-full p-3","data-testid":"sql-chart",children:(0,m.jsxDEV)(T,{className:"h-full w-full",config:B,data:u,children:[f,d,v]},void 0,!0)},void 0,!1),t[13]=u,t[14]=p):p=t[14],p},"SqlResultChart"),$=i(()=>{try{return globalThis.localStorage}catch{return}},"store"),R=i(function(s){try{let t=$()?.getItem(s)??void 0,e=t===void 0?[]:JSON.parse(t);return Array.isArray(e)?e:[]}catch{return[]}},"loadJsonArray"),V=i((s,t)=>{let e=$();if(e!==void 0)try{e.setItem(s,JSON.stringify(t))}catch{}},"saveJson"),q=i(function(s){let t=(0,g.c)(8),e;t[0]!==s?(e=i(()=>R(s),"t0"),t[0]=s,t[1]=e):e=t[1];let[l,n]=(0,S.useState)(e),o,r;t[2]!==s||t[3]!==l?(o=i(()=>{V(s,l)},"t1"),r=[s,l],t[2]=s,t[3]=l,t[4]=o,t[5]=r):(o=t[4],r=t[5]),(0,S.useEffect)(o,r);let a;return t[6]!==l?(a=[l,n],t[6]=l,t[7]=a):a=t[7],a},"usePersistedList"),D=i(function(s,t){let e=(0,g.c)(6),[l,n]=q(s),o;e[0]!==t||e[1]!==n?(o=i(f=>{n(d=>{let v=d[0]??t;return[typeof f=="function"?f(v):f]})},"t0"),e[0]=t,e[1]=n,e[2]=o):o=e[2];let r=o,a=l[0]??t,u;return e[3]!==r||e[4]!==a?(u=[a,r],e[3]=r,e[4]=a,e[5]=u):u=e[5],u},"usePersistedValue"),K=i(s=>globalThis.crypto?.randomUUID?.()??`${s}-${globalThis.performance.now().toString(36)}`,"newId");export{X as a,q as b,D as c,K as d};
@@ -0,0 +1 @@
1
+ import{a as V}from"./chunk-VLXV72QE.js";import{a as g}from"./chunk-JSEXCW5Q.js";import{a as z}from"./chunk-UKDJ4H7I.js";import{b as q}from"./chunk-TBMYIZIO.js";import{R as j}from"./chunk-3CJW6NWG.js";import{c as p}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as P}from"./chunk-BOXSWNXZ.js";import{b as w}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as L}from"./chunk-XLXNLJ4N.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as U,e as B,g as J,k as K,o as M}from"./chunk-E75ANNWX.js";import"./chunk-JHKMUTIF.js";import{a,e as D,f as oe,h as ne}from"./chunk-RRCPZMC2.js";var n=D(oe(),1);var t=D(ne(),1);var ie=a(r=>r.kind==="id"?r.table===void 0?"id":`id<${r.table}>`:r.kind==="array"?r.element===void 0?"array":`${r.element}[]`:r.kind,"argumentType"),de=a(r=>r===void 0||r.length===0?"()":`(${r.map(l=>`${l.name}${l.optional?"?":""}: ${ie(l)}`).join(", ")})`,"formatSignature"),le=a(r=>{switch(r){case"array":return[];case"bigint":case"number":return 0;case"boolean":return!1;case"object":case"record":return{};default:return""}},"placeholderValue"),ce=a(r=>{let l={};for(let s of r??[])s.optional||(l[s.name]=le(s.kind));return JSON.stringify(l,void 0,2)},"argumentsTemplate"),ue=B(P.runAs),fe=10,me=a(r=>r===void 0?"undefined":JSON.stringify(r,null,2),"formatResult"),Ie=a(({functions:r,runAsIdentity:l=!1}={})=>{let s=U(),c=L(),[H,X]=(0,n.useState)(null),[k,Y]=(0,n.useState)(null),x=r??H??[],[R,I]=(0,n.useState)(""),[f,b]=(0,n.useState)("{}"),[u,A]=(0,n.useState)(""),[m,G]=(0,n.useState)(""),[N,h]=(0,n.useState)("idle"),[Q,y]=(0,n.useState)(void 0),[C,S]=(0,n.useState)(null),[T,W]=(0,n.useState)([]);(0,n.useEffect)(()=>{if(r!==void 0)return;let e=!1;return c.listFunctions().then(i=>(e||X(i),i)).catch(i=>{e||Y(J(i))}),()=>{e=!0}},[c,r]);let F=R===""?x[0]?.path??"":R,o=x.find(e=>e.path===F),Z=a(async()=>{if(!o)return;let e;try{e=f.trim()===""?{}:JSON.parse(f)}catch(d){h("error"),y(void 0),S(s("Invalid JSON args: {message}",{message:d.message}));return}let i={__lunoraRef:o.path},v=u.trim()===""?{}:{shardKey:u.trim()},$=l?m.trim():"",E=a(d=>{W(O=>[{argsText:f,at:Date.now(),id:(O[0]?.id??0)+1,kind:o.kind,path:o.path,shardKey:u,status:d},...O].slice(0,fe))},"record");h("running"),S(null);try{let d;if($==="")switch(o.kind){case"action":{d=await c.action(i,e,v);break}case"mutation":{d=await c.mutation(i,e,v);break}default:d=await c.query(i,e,v)}else d=await c.query(ue,{args:e,functionPath:o.path,userId:$},v);q(u),y(d),h("success"),E("success")}catch(d){y(void 0),S(d.message),h("error"),E("error")}},"run"),_=a(e=>{I(e.path),b(e.argsText),A(e.shardKey)},"loadRun"),ee=a(e=>{I(e.target.value)},"onSelectChange"),te=a(e=>{b(e.target.value)},"onArgsChange"),re=a(e=>{G(e.target.value)},"onRunAsChange"),se=a(()=>{K(Z())},"runOnce"),ae=a(()=>{b(ce(o?.args))},"prefillArgs");return(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-runner",children:[k!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"function-discover-error",role:"alert",children:k},void 0,!1),(0,t.jsxDEV)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4",children:[(0,t.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsxDEV)(g,{htmlFor:"function-select",children:s("Function")},void 0,!1),(0,t.jsxDEV)("select",{"aria-label":s("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"function-select",id:"function-select",onChange:ee,value:F,children:x.map(e=>(0,t.jsxDEV)("option",{value:e.path,children:[e.path," (",e.kind,")"]},e.path,!0))},void 0,!1),o!==void 0&&(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:[(0,t.jsxDEV)("span",{className:"mr-1.5 font-medium",children:s("Signature")},void 0,!1),(0,t.jsxDEV)("code",{className:"font-mono","data-testid":"function-signature",children:de(o.args)},void 0,!1)]},void 0,!0)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxDEV)(g,{htmlFor:"args-input",children:s("Arguments")},void 0,!1),(0,t.jsxDEV)(p,{"data-testid":"prefill-button",disabled:o===void 0,onClick:ae,size:"xs",type:"button",variant:"ghost",children:s("Prefill")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(V,{"aria-label":s("Arguments"),className:"font-mono text-xs","data-testid":"args-input",id:"args-input",onChange:te,value:f},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(z,{onChange:A,testId:"shard-input",value:u},void 0,!1),l&&(0,t.jsxDEV)("div",{className:"flex flex-col gap-1.5","data-testid":"run-as-field",children:[(0,t.jsxDEV)(g,{htmlFor:"run-as-input",children:s("Run as identity (userId)")},void 0,!1),(0,t.jsxDEV)(j,{"aria-label":s("Run as identity (userId)"),className:"font-mono text-xs","data-testid":"run-as-input",id:"run-as-input",onChange:re,placeholder:s("Leave empty to run as admin"),value:m},void 0,!1),(0,t.jsxDEV)("p",{className:"text-[11px] text-muted-foreground",children:s("Dev only: runs the function as this user so you can test auth and RLS. Forged over the admin gate.")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxDEV)(p,{"data-testid":"run-button",disabled:N==="running"||o===void 0,onClick:se,type:"button",children:s("Run")},void 0,!1),o!==void 0&&(0,t.jsxDEV)(w,{variant:"outline",children:o.kind},void 0,!1),l&&m.trim()!==""&&(0,t.jsxDEV)(w,{"data-testid":"run-as-badge",variant:"secondary",children:s("as {userId}",{userId:m.trim()})},void 0,!1)]},void 0,!0)]},void 0,!0),N==="error"&&C!==null&&(0,t.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"error",role:"alert",children:C},void 0,!1),N==="success"&&(0,t.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"result",children:me(Q)},void 0,!1),T.length>0&&(0,t.jsxDEV)("ul",{className:"flex flex-col overflow-hidden rounded-xl border border-border","data-testid":"fn-history",children:T.map((e,i)=>(0,t.jsxDEV)("li",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2 text-sm last:border-b-0","data-testid":"fn-history-row",children:[(0,t.jsxDEV)("span",{className:e.status==="success"?"text-success":"text-destructive","data-testid":`fn-history-status-${i.toString()}`,children:e.status==="success"?"\u2713":"\u2717"},void 0,!1)," ",(0,t.jsxDEV)("span",{className:"font-mono text-xs",children:[e.path," (",e.kind,")"]},void 0,!0)," ",(0,t.jsxDEV)("time",{className:"text-xs text-muted-foreground",children:M(e.at)},void 0,!1)," ",(0,t.jsxDEV)(p,{className:"ml-auto","data-testid":`fn-history-load-${i.toString()}`,onClick:a(()=>{_(e)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Load")},void 0,!1)]},e.id,!0))},void 0,!1)]},void 0,!0)},"FunctionRunner");export{Ie as FunctionRunner};
@@ -0,0 +1 @@
1
+ import{j as o}from"./chunk-CKSHCYGC.js";import{a as r,e as i,f as p}from"./chunk-RRCPZMC2.js";var a=i(p(),1);var c=a.forwardRef(r(function(e,n){let{className:m,render:f,orientation:t="horizontal",style:d,...s}=e;return o("div",e,{state:{orientation:t},ref:n,props:[{role:"separator","aria-orientation":t},s]})},"SeparatorComponent"));c.displayName="Separator";export{c as a};
@@ -0,0 +1 @@
1
+ import{i as y}from"./chunk-3CJW6NWG.js";import{a as C,c as M,e as P}from"./chunk-O3NAGRTR.js";import{c as _}from"./chunk-CKSHCYGC.js";import{a as z}from"./chunk-3OA7PECS.js";import{a as o,e as L,f as T}from"./chunk-RRCPZMC2.js";var O=L(T(),1);var w=L(T(),1);var D=w.createContext({register:o(()=>{},"register"),unregister:o(()=>{},"unregister"),subscribeMapChange:o(()=>()=>{},"subscribeMapChange"),elementsRef:{current:[]},nextIndexRef:{current:0}});D.displayName="CompositeListContext";function F(){return w.useContext(D)}o(F,"useCompositeListContext");var W=(function(t){return t[t.None=0]="None",t[t.GuessFromOrder=1]="GuessFromOrder",t})({});function V(t={}){let{label:n,metadata:r,textRef:s,indexGuessBehavior:N,index:m}=t,{register:x,unregister:p,subscribeMapChange:f,elementsRef:d,labelsRef:h,nextIndexRef:c}=F(),g=O.useRef(-1),[a,i]=O.useState(m??(N===W.GuessFromOrder?()=>{if(g.current===-1){let e=c.current;c.current+=1,g.current=e}return g.current}:-1)),E=O.useRef(null),S=O.useCallback(e=>{if(E.current=e,a!==-1&&e!==null&&(d.current[a]=e,h)){let l=n!==void 0;h.current[a]=l?n:s?.current?.textContent??e.textContent}},[a,d,h,n,s]);return C(()=>{if(m!=null)return;let e=E.current;if(e)return x(e,r),()=>{p(e)}},[m,x,p,r]),C(()=>{if(m==null)return f(e=>{let l=E.current?e.get(E.current)?.index:null;l!=null&&i(l)})},[m,f,i]),{ref:S,index:a}}o(V,"useCompositeListItem");var b=L(T(),1);var v=L(z(),1);function Z(t){let{children:n,elementsRef:r,labelsRef:s,onMapChange:N}=t,m=M(N),x=b.useRef(0),p=_(U).current,f=_(k).current,[d,h]=b.useState(0),c=b.useRef(d),g=M((e,l)=>{f.set(e,l??null),c.current+=1,h(c.current)}),a=M(e=>{f.delete(e),c.current+=1,h(c.current)}),i=b.useMemo(()=>{let e=new Map;return Array.from(f.keys()).filter(u=>u.isConnected).sort(A).forEach((u,I)=>{let R=f.get(u)??{};e.set(u,{...R,index:I})}),e},[f,d]);C(()=>{if(typeof MutationObserver!="function"||i.size===0)return;let e=new MutationObserver(l=>{let u=new Set,I=o(R=>u.has(R)?u.delete(R):u.add(R),"updateDiff");l.forEach(R=>{R.removedNodes.forEach(I),R.addedNodes.forEach(I)}),u.size===0&&(c.current+=1,h(c.current))});return i.forEach((l,u)=>{u.parentElement&&e.observe(u.parentElement,{childList:!0})}),()=>{e.disconnect()}},[i]),C(()=>{c.current===d&&(r.current.length!==i.size&&(r.current.length=i.size),s&&s.current.length!==i.size&&(s.current.length=i.size),x.current=i.size),m(i)},[m,i,r,s,d]),C(()=>()=>{r.current=[]},[r]),C(()=>()=>{s&&(s.current=[])},[s]);let E=M(e=>(p.add(e),()=>{p.delete(e)}));C(()=>{p.forEach(e=>e(i))},[p,i]);let S=b.useMemo(()=>({register:g,unregister:a,subscribeMapChange:E,elementsRef:r,labelsRef:s,nextIndexRef:x}),[g,a,E,r,s,x]);return(0,v.jsx)(D.Provider,{value:S,children:n})}o(Z,"CompositeList");function k(){return new Map}o(k,"createMap");function U(){return new Set}o(U,"createListeners");function A(t,n){let r=t.compareDocumentPosition(n);return r&Node.DOCUMENT_POSITION_FOLLOWING||r&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:r&Node.DOCUMENT_POSITION_PRECEDING||r&Node.DOCUMENT_POSITION_CONTAINS?1:0}o(A,"sortByDocumentPosition");function re(t){let n=t.getBoundingClientRect(),r=P(t);if(y.env.jsdom)return n;let s=r.getComputedStyle(t,"::before"),N=r.getComputedStyle(t,"::after");if(!(s.content!=="none"||N.content!=="none"))return n;let x=parseFloat(s.width)||0,p=parseFloat(s.height)||0,f=parseFloat(N.width)||0,d=parseFloat(N.height)||0,h=Math.max(n.width,x,f),c=Math.max(n.height,p,d),g=h-n.width,a=c-n.height;return{left:n.left-g/2,right:n.right+g/2,top:n.top-a/2,bottom:n.bottom+a/2}}o(re,"getPseudoElementBounds");function ie(t){return t==null||t.hasAttribute("disabled")||t.getAttribute("aria-disabled")==="true"}o(ie,"isElementDisabled");export{W as a,V as b,Z as c,re as d,ie as e};