@lunora/studio 1.0.0-alpha.45 → 1.0.0-alpha.47

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 (145) hide show
  1. package/dist/index.d.ts +5 -3
  2. package/dist/index.js +12 -12
  3. package/dist/mount.js +1 -1
  4. package/dist/packem_chunks/ApiTab.js +3 -3
  5. package/dist/packem_chunks/AuditPanel.js +4 -4
  6. package/dist/packem_chunks/ExportImportPanel.js +4 -4
  7. package/dist/packem_chunks/FileBrowser.js +43 -20
  8. package/dist/packem_chunks/FunctionRunner.js +8 -25
  9. package/dist/packem_chunks/FunctionStatsPanel.js +4 -4
  10. package/dist/packem_chunks/HealthPanel.js +3 -3
  11. package/dist/packem_chunks/InsightsPanel.js +5 -5
  12. package/dist/packem_chunks/LogsPanel.js +4 -4
  13. package/dist/packem_chunks/MailPanel.js +3 -3
  14. package/dist/packem_chunks/MetricsPanel.js +4 -4
  15. package/dist/packem_chunks/MigrationsPanel.js +5 -5
  16. package/dist/packem_chunks/PitrPanel.js +1 -1
  17. package/dist/packem_chunks/SchemaViewer.js +3 -3
  18. package/dist/packem_chunks/SecurityAdvisorPanel.js +2 -2
  19. package/dist/packem_chunks/SettingsPanel.js +2 -2
  20. package/dist/packem_chunks/SqlEditorPanel.js +7 -6
  21. package/dist/packem_chunks/TableEditor.js +6 -29
  22. package/dist/packem_chunks/analytics-panel.js +1 -1
  23. package/dist/packem_chunks/auth-config-panel.js +1 -1
  24. package/dist/packem_chunks/auth-sessions-panel.js +2 -2
  25. package/dist/packem_chunks/containers-panel.js +1 -1
  26. package/dist/packem_chunks/dashboards-panel.js +3 -2
  27. package/dist/packem_chunks/fanout-panel.js +3 -3
  28. package/dist/packem_chunks/flags-panel.js +2 -2
  29. package/dist/packem_chunks/kv-browser.js +2 -2
  30. package/dist/packem_chunks/log-drains-panel.js +1 -1
  31. package/dist/packem_chunks/organizations-panel.js +3 -3
  32. package/dist/packem_chunks/payments-panel.js +3 -3
  33. package/dist/packem_chunks/permissions-panel.js +4 -4
  34. package/dist/packem_chunks/queues-panel.js +3 -3
  35. package/dist/packem_chunks/rls-panel.js +2 -2
  36. package/dist/packem_chunks/schedule-panel.js +3 -3
  37. package/dist/packem_chunks/storage-rules-panel.js +2 -2
  38. package/dist/packem_chunks/subscriptions-panel.js +3 -3
  39. package/dist/packem_chunks/users-panel.js +3 -3
  40. package/dist/packem_chunks/vector-browser.js +1 -1
  41. package/dist/packem_chunks/workflows-panel.js +2 -2
  42. package/dist/packem_shared/{ApiDocsPanel-CBma-lnp.js → ApiDocsPanel-B2Rc7nOF.js} +1 -1
  43. package/dist/packem_shared/{ApiReferencePanel-CQM3pPN7.js → ApiReferencePanel-Dd8pcswz.js} +1 -1
  44. package/dist/packem_shared/{CommandPalette-X2tkbyHk.js → CommandPalette-BXV4eKf5.js} +1 -1
  45. package/dist/packem_shared/{DataBrowser-D2ywrdId.js → DataBrowser-Cc197zke.js} +8 -8
  46. package/dist/packem_shared/{DataFilters-FNquMaiu.js → DataFilters-B1Q7mrt7.js} +6 -2
  47. package/dist/packem_shared/{GlobalDataBrowser-BkTPLzAY.js → GlobalDataBrowser-CxJxRRf2.js} +3 -3
  48. package/dist/packem_shared/{HomePanel-D1Q9LZgK.js → HomePanel-CjDlJzzs.js} +3 -3
  49. package/dist/packem_shared/{OpenRpcReferencePanel-Dno-hfDb.js → OpenRpcReferencePanel-CWaf0ZtX.js} +1 -1
  50. package/dist/packem_shared/{ScheduledJobs-Ctw4jYtU.js → ScheduledJobs-dHMgnJbx.js} +2 -2
  51. package/dist/packem_shared/{ShardInput-gx_DZXXn.js → ShardInput-CZnpHILL.js} +1 -1
  52. package/dist/packem_shared/{Studio-lJhzDAze.js → Studio-sfBFghzO.js} +4 -4
  53. package/dist/packem_shared/{StudioApp-DiMkupvZ.js → StudioApp-Ism1gXfJ.js} +5 -11
  54. package/dist/packem_shared/{advisor-view-BX8OhG0w.js → advisor-view-Cx21PS_T.js} +1 -1
  55. package/dist/packem_shared/browser-storage-L4gOP5gJ.js +105 -0
  56. package/dist/packem_shared/{data-grid-CdXztApG.js → data-grid-C9I16KWr.js} +1 -1
  57. package/dist/packem_shared/{error-alert-CXjqyGw9.js → error-alert-vIPQoN3Y.js} +1 -1
  58. package/dist/packem_shared/{grid-features-BF-KBDFz.js → grid-features-B_fZH4iQ.js} +3 -2
  59. package/dist/packem_shared/{home-panel-TFcRf9Ui.js → home-panel-BohxdqDb.js} +2 -2
  60. package/dist/packem_shared/{internal-CYcbqMjX.js → internal-zwBoOv24.js} +14 -1
  61. package/dist/packem_shared/{reference-view-DUiJcILV.js → reference-view-DUULLuOi.js} +3 -17
  62. package/dist/packem_shared/{browser-storage-BTrX4y3B.js → result-chart-DZradBAS.js} +2 -98
  63. package/dist/packem_shared/shard-history-AxiJ1WPP.js +16 -0
  64. package/dist/packem_shared/{studio-Dh9UlaF_.js → studio-CFC_pv0f.js} +3 -3
  65. package/dist/packem_shared/{table-list-sidebar-UVIXQJdU.js → table-list-sidebar-huX4VmgI.js} +19 -9
  66. package/dist/packem_shared/{use-admin-query-CfHYWx5n.js → use-admin-query-BGJ010yZ.js} +1 -1
  67. package/dist/packem_shared/{use-async-submit-DJQiPc-_.js → use-async-submit-DGCtuDyz.js} +2 -2
  68. package/dist/standalone/{chunk-J75M4LTW.js → chunk-22C6COGE.js} +4 -4
  69. package/dist/standalone/{chunk-7XTR7BWT.js → chunk-2CQ2YNER.js} +1 -1
  70. package/dist/standalone/chunk-2MLA6WFH.js +1 -0
  71. package/dist/standalone/{chunk-2BBENYBY.js → chunk-37HPVOYP.js} +1 -1
  72. package/dist/standalone/{chunk-B4TTGYIX.js → chunk-3HS3ZXFB.js} +1 -1
  73. package/dist/standalone/{chunk-T4XWXBKR.js → chunk-3OZDR3RM.js} +1 -1
  74. package/dist/standalone/chunk-4KSX53SI.js +4 -0
  75. package/dist/standalone/chunk-4PC7IXNY.js +1 -0
  76. package/dist/standalone/{chunk-7KR346F4.js → chunk-5UKRVDFD.js} +1 -1
  77. package/dist/standalone/{chunk-4WGGEF73.js → chunk-ADP5UEHQ.js} +1 -1
  78. package/dist/standalone/{chunk-WKWKAU22.js → chunk-AITOCPML.js} +1 -1
  79. package/dist/standalone/{chunk-ZSNXQT4N.js → chunk-AYANIT5P.js} +1 -1
  80. package/dist/standalone/chunk-BIBCC7EE.js +6 -0
  81. package/dist/standalone/{chunk-XFPHUG7M.js → chunk-CGGZAYGG.js} +1 -1
  82. package/dist/standalone/chunk-CJTT4TBP.js +1 -0
  83. package/dist/standalone/{chunk-73BV73BI.js → chunk-CLMGPTAI.js} +1 -1
  84. package/dist/standalone/{chunk-MP5MTWY5.js → chunk-CTPCJNOP.js} +1 -1
  85. package/dist/standalone/chunk-DDE62TRL.js +1 -0
  86. package/dist/standalone/{chunk-ATG3655M.js → chunk-DH4K2OLM.js} +1 -1
  87. package/dist/standalone/{chunk-KMNEQEHM.js → chunk-EEWKIQUE.js} +1 -1
  88. package/dist/standalone/{chunk-3JO76DWI.js → chunk-EYSL7KEQ.js} +1 -1
  89. package/dist/standalone/{chunk-I4RSHYDW.js → chunk-F4HDP4XW.js} +1 -1
  90. package/dist/standalone/chunk-F5I22A4W.js +1 -0
  91. package/dist/standalone/chunk-FKVCHCYV.js +4 -0
  92. package/dist/standalone/{chunk-6HW2RKAX.js → chunk-FNQQ3B5G.js} +1 -1
  93. package/dist/standalone/{chunk-PXR5E7AX.js → chunk-GSCV2N3F.js} +5 -5
  94. package/dist/standalone/{chunk-ICIQ2GWQ.js → chunk-H27CRIP3.js} +1 -1
  95. package/dist/standalone/{chunk-YSF43KIJ.js → chunk-HROXYAZT.js} +1 -1
  96. package/dist/standalone/{chunk-EOSXQTSQ.js → chunk-HVRDZZHL.js} +1 -1
  97. package/dist/standalone/{chunk-245TEXSO.js → chunk-IRSIK3HT.js} +2 -2
  98. package/dist/standalone/{chunk-2GMEK2W3.js → chunk-ITQKVEP7.js} +9 -9
  99. package/dist/standalone/{chunk-34B5ECBI.js → chunk-IZN4TYMN.js} +1 -1
  100. package/dist/standalone/{chunk-7JOVXGO4.js → chunk-JM7XBQVK.js} +1 -1
  101. package/dist/standalone/{chunk-S6JKSFSO.js → chunk-JPILGFXT.js} +1 -1
  102. package/dist/standalone/{chunk-QQH2YTBW.js → chunk-JQ4WOPMF.js} +1 -1
  103. package/dist/standalone/chunk-K2CB2CHL.js +1 -0
  104. package/dist/standalone/{chunk-3IJLM4GF.js → chunk-KCMKEMUL.js} +1 -1
  105. package/dist/standalone/{chunk-WKUGR7ER.js → chunk-KKD46QVN.js} +1 -1
  106. package/dist/standalone/chunk-L7WR3C4Z.js +1 -0
  107. package/dist/standalone/chunk-LRYLU6EY.js +1 -0
  108. package/dist/standalone/{chunk-I34RPZ7P.js → chunk-MDTNVR3G.js} +1 -1
  109. package/dist/standalone/chunk-PL2KY6IG.js +1 -0
  110. package/dist/standalone/{chunk-KFNNMXUZ.js → chunk-S3Q6R7BA.js} +1 -1
  111. package/dist/standalone/chunk-SDQE2IUJ.js +1 -0
  112. package/dist/standalone/chunk-SEQ43UW2.js +1 -0
  113. package/dist/standalone/{chunk-5KUKYIU6.js → chunk-SHK6RAFG.js} +1 -1
  114. package/dist/standalone/chunk-TXTJPS5F.js +1 -0
  115. package/dist/standalone/chunk-V4ECZI2R.js +1 -0
  116. package/dist/standalone/{chunk-6CRKDJNL.js → chunk-WD2LBHJZ.js} +1 -1
  117. package/dist/standalone/{chunk-PBXQ5QS4.js → chunk-WMWDJLRO.js} +4 -4
  118. package/dist/standalone/{chunk-ZTOATVB7.js → chunk-WOXVMXSQ.js} +1 -1
  119. package/dist/standalone/{chunk-JEVKZIHN.js → chunk-WUFVFVHJ.js} +1 -1
  120. package/dist/standalone/{chunk-ERUIC6WI.js → chunk-X4QFAAZ5.js} +1 -1
  121. package/dist/standalone/{chunk-P7AMKXU2.js → chunk-XVR74IFC.js} +1 -1
  122. package/dist/standalone/chunk-Y2GJJVS5.js +1 -0
  123. package/dist/standalone/chunk-YFA7NUCL.js +1 -0
  124. package/dist/standalone/chunk-YSPZSTDI.js +1 -0
  125. package/dist/standalone/studio.js +43 -43
  126. package/package.json +6 -6
  127. package/dist/packem_shared/shard-history-DyebH1R5.js +0 -38
  128. package/dist/standalone/chunk-3SKIYIBN.js +0 -1
  129. package/dist/standalone/chunk-AFCBRDRQ.js +0 -1
  130. package/dist/standalone/chunk-AX7GYUQC.js +0 -1
  131. package/dist/standalone/chunk-BGHGKAOM.js +0 -1
  132. package/dist/standalone/chunk-BL45HXOJ.js +0 -1
  133. package/dist/standalone/chunk-ERXJPMCU.js +0 -1
  134. package/dist/standalone/chunk-GNMTLLGB.js +0 -1
  135. package/dist/standalone/chunk-M5OMEMQ3.js +0 -1
  136. package/dist/standalone/chunk-O4YNKFCZ.js +0 -1
  137. package/dist/standalone/chunk-OLUEBOHS.js +0 -1
  138. package/dist/standalone/chunk-OOETIPAO.js +0 -1
  139. package/dist/standalone/chunk-OQPT2BEZ.js +0 -6
  140. package/dist/standalone/chunk-PKIPNNRD.js +0 -4
  141. package/dist/standalone/chunk-QB3QUTSJ.js +0 -1
  142. package/dist/standalone/chunk-TBMYIZIO.js +0 -1
  143. package/dist/standalone/chunk-TU5ZNEZ4.js +0 -1
  144. package/dist/standalone/chunk-WATFBATD.js +0 -1
  145. package/dist/standalone/chunk-WSMZLZWM.js +0 -4
@@ -0,0 +1 @@
1
+ import{a as at}from"./chunk-3OA7PECS.js";import{b as d}from"./chunk-22C6COGE.js";import{a as o,e as R,f as K,g as ot,h as cr}from"./chunk-RRCPZMC2.js";var Qt=R(ot(),1);var L=class{static{o(this,"Subscribable")}constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var ur=class extends L{static{o(this,"FocusManager")}#t;#e;#r;constructor(){super(),this.#r=t=>{if(typeof window<"u"&&window.addEventListener){let e=o(()=>t(),"listener");return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#e||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(t){this.#r=t,this.#e?.(),this.#e=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#t!==t&&(this.#t=t,this.onFocus())}onFocus(){let t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},J=new ur;var hr={setTimeout:o((t,e)=>setTimeout(t,e),"setTimeout"),clearTimeout:o(t=>clearTimeout(t),"clearTimeout"),setInterval:o((t,e)=>setInterval(t,e),"setInterval"),clearInterval:o(t=>clearInterval(t),"clearInterval")},lr=class{static{o(this,"TimeoutManager")}#t=hr;#e=!1;setTimeoutProvider(t){this.#e&&t!==this.#t&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:this.#t,provider:t}),this.#t=t,this.#e=!1}setTimeout(t,e){return this.#e=!0,this.#t.setTimeout(t,e)}clearTimeout(t){this.#t.clearTimeout(t)}setInterval(t,e){return this.#e=!0,this.#t.setInterval(t,e)}clearInterval(t){this.#t.clearInterval(t)}},M=new lr;function ct(t){setTimeout(t,0)}o(ct,"systemSetTimeoutZero");var Fe=typeof window>"u"||"Deno"in globalThis;function S(){}o(S,"noop");function lt(t,e){return typeof t=="function"?t(e):t}o(lt,"functionalUpdate");function re(t){return typeof t=="number"&&t>=0&&t!==1/0}o(re,"isValidTimeout");function pe(t,e){return Math.max(t+(e||0)-Date.now(),0)}o(pe,"timeUntilStale");function x(t,e){return typeof t=="function"?t(e):t}o(x,"resolveStaleTime");function I(t,e){return typeof t=="function"?t(e):t}o(I,"resolveQueryBoolean");function ye(t,e){let{type:r="all",exact:s,fetchStatus:n,predicate:i,queryKey:a,stale:u}=t;if(a){if(s){if(e.queryHash!==se(a,e.options))return!1}else if(!G(e.queryKey,a))return!1}if(r!=="all"){let c=e.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof u=="boolean"&&e.isStale()!==u||n&&n!==e.state.fetchStatus||i&&!i(e))}o(ye,"matchQuery");function ge(t,e){let{exact:r,status:s,predicate:n,mutationKey:i}=t;if(i){if(!e.options.mutationKey)return!1;if(r){if(j(e.options.mutationKey)!==j(i))return!1}else if(!G(e.options.mutationKey,i))return!1}return!(s&&e.state.status!==s||n&&!n(e))}o(ge,"matchMutation");function se(t,e){return(e?.queryKeyHashFn||j)(t)}o(se,"hashQueryKeyByOptions");function j(t){return JSON.stringify(t,(e,r)=>Me(r)?Object.keys(r).sort().reduce((s,n)=>(s[n]=r[n],s),{}):r)}o(j,"hashKey");function G(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(r=>G(t[r],e[r])):!1}o(G,"partialMatchKey");var dr=Object.prototype.hasOwnProperty;function me(t,e,r=0){if(t===e)return t;if(r>500)return e;let s=ut(t)&&ut(e);if(!s&&!(Me(t)&&Me(e)))return e;let i=(s?t:Object.keys(t)).length,a=s?e:Object.keys(e),u=a.length,c=s?new Array(u):{},l=0;for(let h=0;h<u;h++){let f=s?h:a[h],m=t[f],p=e[f];if(m===p){c[f]=m,(s?h<i:dr.call(t,f))&&l++;continue}if(m===null||p===null||typeof m!="object"||typeof p!="object"){c[f]=p;continue}let y=me(m,p,r+1);c[f]=y,y===m&&l++}return i===u&&l===i?t:c}o(me,"replaceEqualDeep");function be(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(let r in t)if(t[r]!==e[r])return!1;return!0}o(be,"shallowEqualObjects");function ut(t){return Array.isArray(t)&&t.length===Object.keys(t).length}o(ut,"isPlainArray");function Me(t){if(!ht(t))return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(!ht(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}o(Me,"isPlainObject");function ht(t){return Object.prototype.toString.call(t)==="[object Object]"}o(ht,"hasObjectPrototype");function dt(t){return new Promise(e=>{M.setTimeout(e,t)})}o(dt,"sleep");function ne(t,e,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(t,e);if(r.structuralSharing!==!1){try{return me(t,e)}catch(s){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${s}`),s}return me(t,e)}return e}o(ne,"replaceData");function fr(t){return t}o(fr,"keepPreviousData");function ft(t,e,r=0){let s=[...t,e];return r&&s.length>r?s.slice(1):s}o(ft,"addToEnd");function mt(t,e,r=0){let s=[e,...t];return r&&s.length>r?s.slice(0,-1):s}o(mt,"addToStart");var $=Symbol();function ve(t,e){return t.queryFn===$&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${t.queryHash}'`),!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===$?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}o(ve,"ensureQueryFn");function Se(t,e){return typeof t=="function"?t(...e):!!t}o(Se,"shouldThrowError");function pt(t,e,r){let s=!1,n;return Object.defineProperty(t,"signal",{enumerable:!0,get:o(()=>(n??=e(),s||(s=!0,n.aborted?r():n.addEventListener("abort",r,{once:!0})),n),"get")}),t}o(pt,"addConsumeAwareSignal");var F=(()=>{let t=o(()=>Fe,"isServerFn");return{isServer(){return t()},setIsServer(e){t=e}}})();function ie(){let t,e,r=new Promise((n,i)=>{t=n,e=i});r.status="pending",r.catch(()=>{});function s(n){Object.assign(r,n),delete r.resolve,delete r.reject}return o(s,"finalize"),r.resolve=n=>{s({status:"fulfilled",value:n}),t(n)},r.reject=n=>{s({status:"rejected",reason:n}),e(n)},r}o(ie,"pendingThenable");var yt=ct;function mr(){let t=[],e=0,r=o(u=>{u()},"notifyFn"),s=o(u=>{u()},"batchNotifyFn"),n=yt,i=o(u=>{e?t.push(u):n(()=>{r(u)})},"schedule"),a=o(()=>{let u=t;t=[],u.length&&n(()=>{s(()=>{u.forEach(c=>{r(c)})})})},"flush");return{batch:o(u=>{let c;e++;try{c=u()}finally{e--,e||a()}return c},"batch"),batchCalls:o(u=>(...c)=>{i(()=>{u(...c)})},"batchCalls"),schedule:i,setNotifyFunction:o(u=>{r=u},"setNotifyFunction"),setBatchNotifyFunction:o(u=>{s=u},"setBatchNotifyFunction"),setScheduler:o(u=>{n=u},"setScheduler")}}o(mr,"createNotifyManager");var b=mr();var pr=class extends L{static{o(this,"OnlineManager")}#t=!0;#e;#r;constructor(){super(),this.#r=t=>{if(typeof window<"u"&&window.addEventListener){let e=o(()=>t(!0),"onlineListener"),r=o(()=>t(!1),"offlineListener");return window.addEventListener("online",e,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#e||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(t){this.#r=t,this.#e?.(),this.#e=t(this.setOnline.bind(this))}setOnline(t){this.#t!==t&&(this.#t=t,this.listeners.forEach(r=>{r(t)}))}isOnline(){return this.#t}},X=new pr;function yr(t){return Math.min(1e3*2**t,3e4)}o(yr,"defaultRetryDelay");function Ne(t){return(t??"online")==="online"?X.isOnline():!0}o(Ne,"canFetch");var we=class extends Error{static{o(this,"CancelledError")}constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function Te(t){let e=!1,r=0,s,n=ie(),i=o(()=>n.status!=="pending","isResolved"),a=o(g=>{if(!i()){let v=new we(g);m(v),t.onCancel?.(v)}},"cancel"),u=o(()=>{e=!0},"cancelRetry"),c=o(()=>{e=!1},"continueRetry"),l=o(()=>J.isFocused()&&(t.networkMode==="always"||X.isOnline())&&t.canRun(),"canContinue"),h=o(()=>Ne(t.networkMode)&&t.canRun(),"canStart"),f=o(g=>{i()||(s?.(),n.resolve(g))},"resolve"),m=o(g=>{i()||(s?.(),n.reject(g))},"reject"),p=o(()=>new Promise(g=>{s=o(v=>{(i()||l())&&g(v)},"continueFn"),t.onPause?.()}).then(()=>{s=void 0,i()||t.onContinue?.()}),"pause"),y=o(()=>{if(i())return;let g,v=r===0?t.initialPromise:void 0;try{g=v??t.fn()}catch(E){g=Promise.reject(E)}Promise.resolve(g).then(f).catch(E=>{if(i())return;let A=t.retry??(F.isServer()?0:3),N=t.retryDelay??yr,q=typeof N=="function"?N(r,E):N,B=A===!0||typeof A=="number"&&r<A||typeof A=="function"&&A(r,E);if(e||!B){m(E);return}r++,t.onFail?.(r,E),dt(q).then(()=>l()?void 0:p()).then(()=>{e?m(E):y()})})},"run");return{promise:n,status:o(()=>n.status,"status"),cancel:a,continue:o(()=>(s?.(),n),"continue"),cancelRetry:u,continueRetry:c,canStart:h,start:o(()=>(h()?y():p().then(y),n),"start")}}o(Te,"createRetryer");var Ee=class{static{o(this,"Removable")}#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),re(this.gcTime)&&(this.#t=M.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(F.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#t!==void 0&&(M.clearTimeout(this.#t),this.#t=void 0)}};function bt(t){return{onFetch:o((e,r)=>{let s=e.options,n=e.fetchOptions?.meta?.fetchMore?.direction,i=e.state.data?.pages||[],a=e.state.data?.pageParams||[],u={pages:[],pageParams:[]},c=0,l=o(async()=>{let h=!1,f=o(y=>{pt(y,()=>e.signal,()=>h=!0)},"addSignalProperty"),m=ve(e.options,e.fetchOptions),p=o(async(y,g,v)=>{if(h)return Promise.reject(e.signal.reason);if(g==null&&y.pages.length)return Promise.resolve(y);let A=o(()=>{let Le={client:e.client,queryKey:e.queryKey,pageParam:g,direction:v?"backward":"forward",meta:e.options.meta};return f(Le),Le},"createQueryFnContext")(),N=await m(A),{maxPages:q}=e.options,B=v?mt:ft;return{pages:B(y.pages,N,q),pageParams:B(y.pageParams,g,q)}},"fetchPage");if(n&&i.length){let y=n==="backward",g=y?gr:gt,v={pages:i,pageParams:a},E=g(s,v);u=await p(v,E,y)}else{let y=t??i.length;do{let g=c===0?a[0]??s.initialPageParam:gt(s,u);if(c>0&&g==null)break;u=await p(u,g),c++}while(c<y)}return u},"fetchFn");e.options.persister?e.fetchFn=()=>e.options.persister?.(l,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r):e.fetchFn=l},"onFetch")}}o(bt,"infiniteQueryBehavior");function gt(t,{pages:e,pageParams:r}){let s=e.length-1;return e.length>0?t.getNextPageParam(e[s],e,r[s],r):void 0}o(gt,"getNextPageParam");function gr(t,{pages:e,pageParams:r}){return e.length>0?t.getPreviousPageParam?.(e[0],e,r[0],r):void 0}o(gr,"getPreviousPageParam");var wt=class extends Ee{static{o(this,"Query")}#t;#e;#r;#s;#i;#n;#a;#o;constructor(t){super(),this.#o=!1,this.#a=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#i=t.client,this.#s=this.#i.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#e=St(this.options),this.state=t.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#t}get promise(){return this.#n?.promise}setOptions(t){if(this.options={...this.#a,...t},t?._type&&(this.#t=t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=St(this.options);e.data!==void 0&&(this.setState(vt(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#s.remove(this)}setData(t,e){let r=ne(this.state.data,t,this.options);return this.#c({data:r,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),r}setState(t){this.#c({type:"setState",state:t})}cancel(t){let e=this.#n?.promise;return this.#n?.cancel(t),e?e.then(S).catch(S):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>I(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===$||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>x(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!pe(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#n&&(this.#o||this.#h()?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#s.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}#h(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#c({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#n?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(t&&this.setOptions(t),!this.options.queryFn){let c=this.observers.find(l=>l.options.queryFn);c&&this.setOptions(c.options)}Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']");let r=new AbortController,s=o(c=>{Object.defineProperty(c,"signal",{enumerable:!0,get:o(()=>(this.#o=!0,r.signal),"get")})},"addSignalProperty"),n=o(()=>{let c=ve(this.options,e),h=o(()=>{let f={client:this.#i,queryKey:this.queryKey,meta:this.meta};return s(f),f},"createQueryFnContext")();return this.#o=!1,this.options.persister?this.options.persister(c,h,this):c(h)},"fetchFn"),a=o(()=>{let c={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:n};return s(c),c},"createFetchContext")();(this.#t==="infinite"?bt(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#r=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:"fetch",meta:a.fetchOptions?.meta}),this.#n=Te({initialPromise:e?.initialPromise,fn:a.fetchFn,onCancel:o(c=>{c instanceof we&&c.revert&&this.setState({...this.#r,fetchStatus:"idle"}),r.abort()},"onCancel"),onFail:o((c,l)=>{this.#c({type:"failed",failureCount:c,error:l})},"onFail"),onPause:o(()=>{this.#c({type:"pause"})},"onPause"),onContinue:o(()=>{this.#c({type:"continue"})},"onContinue"),retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:o(()=>!0,"canRun")});try{let c=await this.#n.start();if(c===void 0)throw console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(c),this.#s.config.onSuccess?.(c,this),this.#s.config.onSettled?.(c,this.state.error,this),c}catch(c){if(c instanceof we){if(c.silent)return this.#n.promise;if(c.revert){if(this.state.data===void 0)throw c;return this.state.data}}throw this.#c({type:"error",error:c}),this.#s.config.onError?.(c,this),this.#s.config.onSettled?.(this.state.data,c,this),c}finally{this.scheduleGc()}}#c(t){let e=o(r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...De(r.data,this.options),fetchMeta:t.meta??null};case"success":let s={...r,...vt(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#r=t.manual?s:void 0,s;case"error":let n=t.error;return{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}},"reducer");this.state=e(this.state),b.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#s.notify({query:this,type:"updated",action:t})})}};function De(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ne(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}o(De,"fetchState");function vt(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}o(vt,"successState");function St(t){let e=typeof t.initialData=="function"?t.initialData():t.initialData,r=e!==void 0,s=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}o(St,"getDefaultState");var Qe=class extends L{static{o(this,"QueryObserver")}constructor(t,e){super(),this.options=e,this.#t=t,this.#o=null,this.#a=ie(),this.bindMethods(),this.setOptions(e)}#t;#e=void 0;#r=void 0;#s=void 0;#i;#n;#a;#o;#h;#c;#m;#l;#d;#u;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),Tt(this.#e,this.options)?this.#f():this.updateResult(),this.#v())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ue(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ue(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#S(),this.#w(),this.#e.removeObserver(this)}setOptions(t){let e=this.options,r=this.#e;if(this.options=this.#t.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof I(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#T(),this.#e.setOptions(this.options),e._defaulted&&!be(this.options,e)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});let s=this.hasListeners();s&&Et(this.#e,r,this.options,e)&&this.#f(),this.updateResult(),s&&(this.#e!==r||I(this.options.enabled,this.#e)!==I(e.enabled,this.#e)||x(this.options.staleTime,this.#e)!==x(e.staleTime,this.#e))&&this.#y();let n=this.#g();s&&(this.#e!==r||I(this.options.enabled,this.#e)!==I(e.enabled,this.#e)||n!==this.#u)&&this.#b(n)}getOptimisticResult(t){let e=this.#t.getQueryCache().build(this.#t,t),r=this.createResult(e,t);return vr(this,r)&&(this.#s=r,this.#n=this.options,this.#i=this.#e.state),r}getCurrentResult(){return this.#s}trackResult(t,e){return new Proxy(t,{get:o((r,s)=>(this.trackProp(s),e?.(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#a.status==="pending"&&this.#a.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s)),"get")})}trackProp(t){this.#p.add(t)}getCurrentQuery(){return this.#e}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){let e=this.#t.defaultQueryOptions(t),r=this.#t.getQueryCache().build(this.#t,e);return r.fetch().then(()=>this.createResult(r,e))}fetch(t){return this.#f({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#s))}#f(t){this.#T();let e=this.#e.fetch(this.options,t);return t?.throwOnError||(e=e.catch(S)),e}#y(){this.#S();let t=x(this.options.staleTime,this.#e);if(F.isServer()||this.#s.isStale||!re(t))return;let r=pe(this.#s.dataUpdatedAt,t)+1;this.#l=M.setTimeout(()=>{this.#s.isStale||this.updateResult()},r)}#g(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#b(t){this.#w(),this.#u=t,!(F.isServer()||I(this.options.enabled,this.#e)===!1||!re(this.#u)||this.#u===0)&&(this.#d=M.setInterval(()=>{(this.options.refetchIntervalInBackground||J.isFocused())&&this.#f()},this.#u))}#v(){this.#y(),this.#b(this.#g())}#S(){this.#l!==void 0&&(M.clearTimeout(this.#l),this.#l=void 0)}#w(){this.#d!==void 0&&(M.clearInterval(this.#d),this.#d=void 0)}createResult(t,e){let r=this.#e,s=this.options,n=this.#s,i=this.#i,a=this.#n,c=t!==r?t.state:this.#r,{state:l}=t,h={...l},f=!1,m;if(e._optimisticResults){let k=this.hasListeners(),te=!k&&Tt(t,e),le=k&&Et(t,r,e,s);(te||le)&&(h={...h,...De(l.data,t.options)}),e._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:p,errorUpdatedAt:y,status:g}=h;m=h.data;let v=!1;if(e.placeholderData!==void 0&&m===void 0&&g==="pending"){let k;n?.isPlaceholderData&&e.placeholderData===a?.placeholderData?(k=n.data,v=!0):k=typeof e.placeholderData=="function"?e.placeholderData(this.#m?.state.data,this.#m):e.placeholderData,k!==void 0&&(g="success",m=ne(n?.data,k,e),f=!0)}if(e.select&&m!==void 0&&!v)if(n&&m===i?.data&&e.select===this.#h)m=this.#c;else try{this.#h=e.select,m=e.select(m),m=ne(n?.data,m,e),this.#c=m,this.#o=null}catch(k){this.#o=k}this.#o&&(p=this.#o,m=this.#c,y=Date.now(),g="error");let E=h.fetchStatus==="fetching",A=g==="pending",N=g==="error",q=A&&E,B=m!==void 0,U={status:g,fetchStatus:h.fetchStatus,isPending:A,isSuccess:g==="success",isError:N,isInitialLoading:q,isLoading:q,data:m,dataUpdatedAt:h.dataUpdatedAt,error:p,errorUpdatedAt:y,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:h.dataUpdateCount>c.dataUpdateCount||h.errorUpdateCount>c.errorUpdateCount,isFetching:E,isRefetching:E&&!A,isLoadingError:N&&!B,isPaused:h.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:N&&B,isStale:He(t,e),refetch:this.refetch,promise:this.#a,isEnabled:I(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){let k=U.data!==void 0,te=U.status==="error"&&!k,le=o(fe=>{te?fe.reject(U.error):k&&fe.resolve(U.data)},"finalizeThenableIfPossible"),it=o(()=>{let fe=this.#a=U.promise=ie();le(fe)},"recreateThenable"),de=this.#a;switch(de.status){case"pending":t.queryHash===r.queryHash&&le(de);break;case"fulfilled":(te||U.data!==de.value)&&it();break;case"rejected":(!te||U.error!==de.reason)&&it();break}}return U}updateResult(){let t=this.#s,e=this.createResult(this.#e,this.options);if(this.#i=this.#e.state,this.#n=this.options,this.#i.data!==void 0&&(this.#m=this.#e),be(e,t))return;this.#s=e;let r=o(()=>{if(!t)return!0;let{notifyOnChangeProps:s}=this.options,n=typeof s=="function"?s():s;if(n==="all"||!n&&!this.#p.size)return!0;let i=new Set(n??this.#p);return this.options.throwOnError&&i.add("error"),Object.keys(this.#s).some(a=>{let u=a;return this.#s[u]!==t[u]&&i.has(u)})},"shouldNotifyListeners");this.#E({listeners:r()})}#T(){let t=this.#t.getQueryCache().build(this.#t,this.options);if(t===this.#e)return;let e=this.#e;this.#e=t,this.#r=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#v()}#E(t){b.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#s)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function br(t,e){return I(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&I(e.retryOnMount,t)===!1)}o(br,"shouldLoadOnMount");function Tt(t,e){return br(t,e)||t.state.data!==void 0&&Ue(t,e,e.refetchOnMount)}o(Tt,"shouldFetchOnMount");function Ue(t,e,r){if(I(e.enabled,t)!==!1&&x(e.staleTime,t)!=="static"){let s=typeof r=="function"?r(t):r;return s==="always"||s!==!1&&He(t,e)}return!1}o(Ue,"shouldFetchOn");function Et(t,e,r,s){return(t!==e||I(s.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&He(t,r)}o(Et,"shouldFetchOptionally");function He(t,e){return I(e.enabled,t)!==!1&&t.isStaleByTime(x(e.staleTime,t))}o(He,"isStale");function vr(t,e){return!be(t.getCurrentResult(),e)}o(vr,"shouldAssignObserverCurrentProperties");var Ct=class extends Ee{static{o(this,"Mutation")}#t;#e;#r;#s;constructor(t){super(),this.#t=t.client,this.mutationId=t.mutationId,this.#r=t.mutationCache,this.#e=[],this.state=t.state||Sr(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#e.includes(t)||(this.#e.push(t),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#e=this.#e.filter(e=>e!==t),this.scheduleGc(),this.#r.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#e.length||(this.state.status==="pending"?this.scheduleGc():this.#r.remove(this))}continue(){return this.#s?.continue()??this.execute(this.state.variables)}async execute(t){let e=o(()=>{this.#i({type:"continue"})},"onContinue"),r={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#s=Te({fn:o(()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),"fn"),onFail:o((i,a)=>{this.#i({type:"failed",failureCount:i,error:a})},"onFail"),onPause:o(()=>{this.#i({type:"pause"})},"onPause"),onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:o(()=>this.#r.canRun(this),"canRun")});let s=this.state.status==="pending",n=!this.#s.canStart();try{if(s)e();else{this.#i({type:"pending",variables:t,isPaused:n}),this.#r.config.onMutate&&await this.#r.config.onMutate(t,this,r);let a=await this.options.onMutate?.(t,r);a!==this.state.context&&this.#i({type:"pending",context:a,variables:t,isPaused:n})}let i=await this.#s.start();return await this.#r.config.onSuccess?.(i,t,this.state.context,this,r),await this.options.onSuccess?.(i,t,this.state.context,r),await this.#r.config.onSettled?.(i,null,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(i,null,t,this.state.context,r),this.#i({type:"success",data:i}),i}catch(i){try{await this.#r.config.onError?.(i,t,this.state.context,this,r)}catch(a){Promise.reject(a)}try{await this.options.onError?.(i,t,this.state.context,r)}catch(a){Promise.reject(a)}try{await this.#r.config.onSettled?.(void 0,i,this.state.variables,this.state.context,this,r)}catch(a){Promise.reject(a)}try{await this.options.onSettled?.(void 0,i,t,this.state.context,r)}catch(a){Promise.reject(a)}throw this.#i({type:"error",error:i}),i}finally{this.#r.runNext(this)}}#i(t){let e=o(r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}},"reducer");this.state=e(this.state),b.batch(()=>{this.#e.forEach(r=>{r.onMutationUpdate(t)}),this.#r.notify({mutation:this,type:"updated",action:t})})}};function Sr(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}o(Sr,"getDefaultState");var At=class extends L{static{o(this,"MutationCache")}constructor(t={}){super(),this.config=t,this.#t=new Set,this.#e=new Map,this.#r=0}#t;#e;#r;build(t,e,r){let s=new Ct({client:t,mutationCache:this,mutationId:++this.#r,options:t.defaultMutationOptions(e),state:r});return this.add(s),s}add(t){this.#t.add(t);let e=Ce(t);if(typeof e=="string"){let r=this.#e.get(e);r?r.push(t):this.#e.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#t.delete(t)){let e=Ce(t);if(typeof e=="string"){let r=this.#e.get(e);if(r)if(r.length>1){let s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&this.#e.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){let e=Ce(t);if(typeof e=="string"){let s=this.#e.get(e)?.find(n=>n.state.status==="pending");return!s||s===t}else return!0}runNext(t){let e=Ce(t);return typeof e=="string"?this.#e.get(e)?.find(s=>s!==t&&s.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){b.batch(()=>{this.#t.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(t){let e={exact:!0,...t};return this.getAll().find(r=>ge(e,r))}findAll(t={}){return this.getAll().filter(e=>ge(t,e))}notify(t){b.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){let t=this.getAll().filter(e=>e.state.isPaused);return b.batch(()=>Promise.all(t.map(e=>e.continue().catch(S))))}};function Ce(t){return t.options.scope?.id}o(Ce,"scopeFor");var It=class extends L{static{o(this,"QueryCache")}constructor(t={}){super(),this.config=t,this.#t=new Map}#t;build(t,e,r){let s=e.queryKey,n=e.queryHash??se(s,e),i=this.get(n);return i||(i=new wt({client:t,queryKey:s,queryHash:n,options:t.defaultQueryOptions(e),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(i)),i}add(t){this.#t.has(t.queryHash)||(this.#t.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){let e=this.#t.get(t.queryHash);e&&(t.destroy(),e===t&&this.#t.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){b.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#t.get(t)}getAll(){return[...this.#t.values()]}find(t){let e={exact:!0,...t};return this.getAll().find(r=>ye(e,r))}findAll(t={}){let e=this.getAll();return Object.keys(t).length>0?e.filter(r=>ye(t,r)):e}notify(t){b.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){b.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){b.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}};var qe=class{static{o(this,"QueryClient")}#t;#e;#r;#s;#i;#n;#a;#o;constructor(t={}){this.#t=t.queryCache||new It,this.#e=t.mutationCache||new At,this.#r=t.defaultOptions||{},this.#s=new Map,this.#i=new Map,this.#n=0}mount(){this.#n++,this.#n===1&&(this.#a=J.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#o=X.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#n--,this.#n===0&&(this.#a?.(),this.#a=void 0,this.#o?.(),this.#o=void 0)}isFetching(t){return this.#t.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#e.findAll({...t,status:"pending"}).length}getQueryData(t){let e=this.defaultQueryOptions({queryKey:t});return this.#t.get(e.queryHash)?.state.data}ensureQueryData(t){let e=this.defaultQueryOptions(t),r=this.#t.build(this,e),s=r.state.data;return s===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(x(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(s))}getQueriesData(t){return this.#t.findAll(t).map(({queryKey:e,state:r})=>{let s=r.data;return[e,s]})}setQueryData(t,e,r){let s=this.defaultQueryOptions({queryKey:t}),i=this.#t.get(s.queryHash)?.state.data,a=lt(e,i);if(a!==void 0)return this.#t.build(this,s).setData(a,{...r,manual:!0})}setQueriesData(t,e,r){return b.batch(()=>this.#t.findAll(t).map(({queryKey:s})=>[s,this.setQueryData(s,e,r)]))}getQueryState(t){let e=this.defaultQueryOptions({queryKey:t});return this.#t.get(e.queryHash)?.state}removeQueries(t){let e=this.#t;b.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){let r=this.#t;return b.batch(()=>(r.findAll(t).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){let r={revert:!0,...e},s=b.batch(()=>this.#t.findAll(t).map(n=>n.cancel(r)));return Promise.all(s).then(S).catch(S)}invalidateQueries(t,e={}){return b.batch(()=>(this.#t.findAll(t).forEach(r=>{r.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){let r={...e,cancelRefetch:e.cancelRefetch??!0},s=b.batch(()=>this.#t.findAll(t).filter(n=>!n.isDisabled()&&!n.isStatic()).map(n=>{let i=n.fetch(void 0,r);return r.throwOnError||(i=i.catch(S)),n.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(s).then(S)}fetchQuery(t){let e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);let r=this.#t.build(this,e);return r.isStaleByTime(x(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(S).catch(S)}fetchInfiniteQuery(t){return t._type="infinite",this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(S).catch(S)}ensureInfiniteQueryData(t){return t._type="infinite",this.ensureQueryData(t)}resumePausedMutations(){return X.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#r}setDefaultOptions(t){this.#r=t}setQueryDefaults(t,e){this.#s.set(j(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){let e=[...this.#s.values()],r={};return e.forEach(s=>{G(t,s.queryKey)&&Object.assign(r,s.defaultOptions)}),r}setMutationDefaults(t,e){this.#i.set(j(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){let e=[...this.#i.values()],r={};return e.forEach(s=>{G(t,s.mutationKey)&&Object.assign(r,s.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;let e={...this.#r.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=se(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===$&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#r.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}};var Y=R(K(),1),_t=R(at(),1);var oe=Y.createContext(void 0),Be=o(t=>{let e=Y.useContext(oe);if(t)return t;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},"useQueryClient"),Ke=o(({client:t,children:e})=>(Y.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),(0,_t.jsx)(oe.Provider,{value:t,children:e})),"QueryClientProvider");var Ae=R(K(),1);var kt=Ae.createContext(!1),Rt=o(()=>Ae.useContext(kt),"useIsRestoring"),ao=kt.Provider;var ae=R(K(),1),wr=R(at(),1);function Tr(){let t=!1;return{clearReset:o(()=>{t=!1},"clearReset"),reset:o(()=>{t=!0},"reset"),isReset:o(()=>t,"isReset")}}o(Tr,"createValue");var Er=ae.createContext(Tr()),Ot=o(()=>ae.useContext(Er),"useQueryErrorResetBoundary");var Pt=R(K(),1);var xt=o((t,e,r)=>{let s=r?.state.error&&typeof t.throwOnError=="function"?Se(t.throwOnError,[r.state.error,r]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||s)&&(e.isReset()||(t.retryOnMount=!1))},"ensurePreventErrorBoundaryRetry"),Lt=o(t=>{Pt.useEffect(()=>{t.clearReset()},[t])},"useClearResetErrorBoundary"),Mt=o(({result:t,errorResetBoundary:e,throwOnError:r,query:s,suspense:n})=>t.isError&&!e.isReset()&&!t.isFetching&&s&&(n&&t.data===void 0||Se(r,[t.error,s])),"getHasError");var Ft=o(t=>{if(t.suspense){let r=o(n=>n==="static"?n:Math.max(n??1e3,1e3),"clamp"),s=t.staleTime;t.staleTime=typeof s=="function"?(...n)=>r(s(...n)):r(s),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},"ensureSuspenseTimers"),Nt=o((t,e)=>t.isLoading&&t.isFetching&&!e,"willFetch"),Dt=o((t,e)=>t?.suspense&&e.isPending,"shouldSuspend"),je=o((t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()}),"fetchOptimistic");var Q=R(K(),1);function Ut(t,e,r){if(typeof t!="object"||Array.isArray(t))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');let s=Rt(),n=Ot(),i=Be(r),a=i.defaultQueryOptions(t);i.getDefaultOptions().queries?._experimental_beforeQuery?.(a);let u=i.getQueryCache().get(a.queryHash);a.queryFn||console.error(`[${a.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`);let c=t.subscribed!==!1;a._optimisticResults=s?"isRestoring":c?"optimistic":void 0,Ft(a),xt(a,n,u),Lt(n);let l=!i.getQueryCache().get(a.queryHash),[h]=Q.useState(()=>new e(i,a)),f=h.getOptimisticResult(a),m=!s&&c;if(Q.useSyncExternalStore(Q.useCallback(p=>{let y=m?h.subscribe(b.batchCalls(p)):S;return h.updateResult(),y},[h,m]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),Q.useEffect(()=>{h.setOptions(a)},[a,h]),Dt(a,f))throw je(a,h,n);if(Mt({result:f,errorResetBoundary:n,throwOnError:a.throwOnError,query:u,suspense:a.suspense}))throw f.error;return i.getDefaultOptions().queries?._experimental_afterQuery?.(a,f),a.experimental_prefetchInRender&&!F.isServer()&&Nt(f,s)&&(l?je(a,h,n):u?.promise)?.catch(S).finally(()=>{h.updateResult()}),a.notifyOnChangeProps?f:h.trackResult(f)}o(Ut,"useBaseQuery");function Cr(t,e){return Ut(t,Qe,e)}o(Cr,"useQuery");var V=R(K(),1),$e=R(cr(),1);var Ht=(0,V.createContext)(null),Ar=o(()=>new qe({defaultOptions:{mutations:{retry:0},queries:{gcTime:5*6e4,retry:0,staleTime:Number.POSITIVE_INFINITY}}}),"createDefaultQueryClient"),Ir=o(t=>{let e=(0,Qt.c)(9),{children:r,client:s,queryClient:n}=t,i=(0,V.use)(oe),a;e[0]!==i||e[1]!==n?(a=o(()=>n??i??Ar(),"t1"),e[0]=i,e[1]=n,e[2]=a):a=e[2];let[u]=(0,V.useState)(a),c=n??i??u;if(!c)throw new d("INTERNAL","LunoraProvider: failed to resolve a QueryClient");let l;e[3]!==r||e[4]!==s?(l=(0,$e.jsxDEV)(Ht,{value:s,children:r},void 0,!1),e[3]=r,e[4]=s,e[5]=l):l=e[5];let h=l;if(i===c)return h;let f;return e[6]!==h||e[7]!==c?(f=(0,$e.jsxDEV)(Ke,{client:c,children:h},void 0,!1),e[6]=h,e[7]=c,e[8]=f):f=e[8],f},"LunoraProvider"),Ge=o(()=>{let t=(0,V.use)(Ht);if(!t)throw new d("INTERNAL","useLunora must be used inside <LunoraProvider />");return t},"useLunora");var qt=R(ot(),1),Bt=R(K(),1);var _r=o(()=>{let t=(0,qt.c)(4),e=Ge(),r,s,n;return t[0]!==e?(r=o(i=>e.onConnectionStatus(()=>{i()}),"t0"),s=o(()=>e.connectionStatus(),"t1"),n=o(()=>e.connectionStatus(),"t2"),t[0]=e,t[1]=r,t[2]=s,t[3]=n):(r=t[1],s=t[2],n=t[3]),(0,Bt.useSyncExternalStore)(r,s,n)},"useConnectionStatus");var Kt=o(()=>{let t=null;return{get:o(()=>t,"get"),set:o(e=>{t=e},"set")}},"createInMemoryBookmarkStorage");var Ve="_creationTime",kr=o(t=>{if(typeof t!="object"||t===null)return;let e=t._id;return typeof e=="string"?e:void 0},"rowId"),Rr=o(t=>{let e;for(let r of t){let s=r[Ve];if(typeof s=="number"){if(e!==void 0){if(s<e)return!0;if(s>e)return!1}e=s}}return!1},"isDescending"),Or=o((t,e)=>{let r=e[Ve];if(typeof r!="number")return t.length;let s=Rr(t);for(let[n,i]of t.entries()){let a=i[Ve];if(typeof a=="number"&&(s?a<r:a>r))return n}return t.length},"insertionIndex"),jt=o(t=>{if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.key=="string"&&typeof e.table=="string"&&(e.op==="insert"||e.op==="update"||e.op==="delete")},"isMutationDelta"),$t=o((t,e)=>{if(!Array.isArray(t))return;let r=[];for(let c of t){if(kr(c)===void 0)return;r.push(c)}let{key:s,op:n,row:i}=e;if(n==="delete"){let c=r.filter(l=>l._id!==s);return c.length===r.length?[...r]:c}if(i===void 0)return;let a=r.findIndex(c=>c._id===s);if(a===-1){let c=[...r];return c.splice(Or(r,i),0,i),c}let u=[...r];return u[a]=i,u},"applyDelta");var Pr=o((t,e)=>t<e?-1:t>e?1:0,"compareKeys"),ce=o(t=>{if(t===void 0)return"null";if(typeof t=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a cache key (query/subscription/shape args) \u2014 pass it as a string");if(t===null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t))return`[${t.map(i=>ce(i)).join(",")}]`;let e=Object.getPrototypeOf(t);if(e!==null&&e!==Object.prototype){let i=t.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${i} in a cache key (query/subscription/shape args) \u2014 only plain objects, arrays, and JSON primitives are supported`)}let r=t,s=Object.keys(r).toSorted(Pr),n=[];for(let i of s){let a=r[i];a!==void 0&&n.push(`${JSON.stringify(i)}:${ce(a)}`)}return`{${n.join(",")}}`},"stableStringify"),H=class t{static{o(this,"SubscriptionRegistry")}static key(e,r,s){return`${e}::${ce(r)}::${s??""}`}byKey=new Map;byId=new Map;get(e){return this.byKey.get(e)}getById(e){return this.byId.get(e)}add(e){this.byKey.set(t.key(e.fn.__lunoraRef,e.args,e.shardKey),e),this.byId.set(e.id,e)}remove(e){let r=t.key(e.fn.__lunoraRef,e.args,e.shardKey);this.byKey.get(r)===e&&this.byKey.delete(r),this.byId.delete(e.id)}all(){return[...this.byKey.values()]}};var Ie=o((t,e)=>{let r=t;for(let s of e)try{r=s.transform(r)}catch{}return r},"foldOptimistic"),ue=o((t,e)=>{if(e!==t.lastValue){t.lastValue=e;for(let r of t.callbacks)try{r(e)}catch{}}},"notifySubscription"),ze=o((t,e)=>{let r;try{r=e(t.lastValue)}catch{return}let s={id:Symbol("optimistic"),transform:e};t.optimisticLayers.push(s),ue(t,r);let n=o(()=>{let a=t.optimisticLayers.findIndex(u=>u.id===s.id);return a===-1?!1:(t.optimisticLayers.splice(a,1),!0)},"remove"),i=o(()=>{ue(t,Ie(t.serverBase,t.optimisticLayers))},"refold");return{confirm:o(a=>{if(a===void 0){n();return}s.commitCursor=a,t.serverCursor!==void 0&&t.serverCursor>=a&&n()&&i()},"confirm"),rollback:o(()=>{n()&&i()},"rollback")}},"applyOptimisticLayer"),We=o((t,e)=>{if(e===void 0||t.optimisticLayers.length===0)return!1;let r=t.optimisticLayers.length;return t.optimisticLayers=t.optimisticLayers.filter(s=>s.commitCursor===void 0||s.commitCursor>e),t.optimisticLayers.length!==r},"dropConfirmedLayers"),Gt=o((t,e)=>{let r=[],s=[],n=o((a,u)=>t.get(H.key(a,u,e)),"findState");return{confirms:r,rollbacks:s,store:{getAllQueries:o(a=>{let u=[];for(let c of t.all())c.fn.__lunoraRef===a.__lunoraRef&&(c.shardKey??"")===(e??"")&&u.push({args:c.args,value:c.lastValue});return u},"getAllQueries"),getQuery:o((a,u)=>n(a.__lunoraRef,u??{})?.lastValue,"getQuery"),setQuery:o((a,u,c)=>{let l=n(a.__lunoraRef,u??{});if(!l)return;let h=ze(l,()=>c);h&&(r.push(h.confirm),s.push(h.rollback))},"setQuery")}}},"createLocalStore");var Je=o((t,e)=>t!==void 0&&e!==t,"isStaleVersion"),Vt=0,ke=o(()=>{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();Vt+=1;let t=typeof crypto<"u"&&typeof crypto.getRandomValues=="function"?[...crypto.getRandomValues(new Uint8Array(8))].map(e=>e.toString(16).padStart(2,"0")).join(""):Math.random().toString(16).slice(2,12);return`m_${Date.now().toString(36)}_${Vt.toString(36)}_${t}`},"nextId"),Z=o((t,e,r,s)=>{if(t){t({error:r,mutationId:s,operation:e});return}console.warn(`[lunora] offline-queue persistence ${e} failed`,r)},"reportPersistenceError"),_e=class{static{o(this,"OfflineQueue")}queueBeforeFirstConnect;maxItems;onPersistenceError;persistence;onEvict;onSizeChange;version;items=[];constructor(e={},r={}){this.maxItems=e.maxItems??1e3,this.queueBeforeFirstConnect=e.queueBeforeFirstConnect??!1,this.onPersistenceError=e.onPersistenceError,this.persistence=r.persistence,this.onEvict=r.onEvict,this.onSizeChange=r.onSizeChange,this.version=r.version}get size(){return this.items.length}enqueue(e){let r=e;for(r.id??=ke(),this.items.push(r),this.persistence?.append({args:r.args,functionPath:r.functionPath,id:r.id,identity:r.identity,shardKey:r.shardKey,...this.version===void 0?{}:{version:this.version}}).catch(s=>{Z(this.onPersistenceError,"append",s,r.id)});this.items.length>this.maxItems;){let s=this.items.shift();if(s){s.id&&this.persistence?.remove(s.id).catch(i=>{Z(this.onPersistenceError,"remove",i,s.id)});let n=new Error("offline queue overflow");n.code="OFFLINE_QUEUE_OVERFLOW",s.reject(n),this.onEvict?.(s,n)}}this.notifySize()}async hydrate(){if(!this.persistence)return[];let e;try{e=await this.persistence.load()}catch(s){throw Z(this.onPersistenceError,"load",s),s}let r=new Set;for(let s of e)if(!this.items.some(n=>n.id===s.id)){if(Je(this.version,s.version)){this.persistence.remove(s.id).catch(n=>{Z(this.onPersistenceError,"remove",n,s.id)});continue}this.items.push({args:s.args,functionPath:s.functionPath,id:s.id,identity:s.identity,reject:o(()=>{},"reject"),resolve:o(()=>{},"resolve"),shardKey:s.shardKey}),r.add(s.shardKey)}return this.notifySize(),[...r]}drain(e){if(!e){let n=[...this.items];return this.items.length=0,this.notifySize(),n}let r=[],s=[];for(let n of this.items)(e(n)?r:s).push(n);return this.items.length=0,this.items.push(...s),this.notifySize(),r}requeue(e){e.length!==0&&(this.items.unshift(...e),this.notifySize())}clear(){for(let e of this.items){let r=new Error("CLIENT_CLOSED");r.code="CLIENT_CLOSED",e.reject(r)}this.items.length=0,this.notifySize()}notifySize(){this.onSizeChange?.(this.items.length)}};var O=o(t=>new Promise((e,r)=>{t.addEventListener("success",()=>{e(t.result)}),t.addEventListener("error",()=>{r(t.error??new Error("IndexedDB request failed"))})}),"promisifyRequest"),Re=o((t,e,r,s)=>{let n;return()=>n||(n=new Promise((i,a)=>{let u=t.open(e,r);u.addEventListener("upgradeneeded",()=>{s(u.result)}),u.addEventListener("success",()=>{i(u.result)}),u.addEventListener("error",()=>{a(u.error??new Error("IndexedDB open failed"))})}),n)},"createDatabaseOpener"),Oe=o((t,e)=>async(r,s)=>{let i=(await t()).transaction(e,r),a=await s(i.objectStore(e));return await new Promise((u,c)=>{i.addEventListener("complete",()=>{u()}),i.addEventListener("error",()=>{c(i.error??new Error("IndexedDB transaction failed"))}),i.addEventListener("abort",()=>{c(i.error??new Error("IndexedDB transaction aborted"))})}),a},"createWithStore");var xr="lunora-outbox",Lr="offline-mutations",zt="by_id",Mr=o((t={})=>{let e=t.indexedDB??(typeof indexedDB>"u"?void 0:indexedDB);if(!e)throw new d("INTERNAL","createIndexedDbPersistence: no IndexedDB available \u2014 pass `indexedDB` or use createInMemoryPersistence()");let r=t.databaseName??xr,s=t.storeName??Lr,n=Re(e,r,1,a=>{a.objectStoreNames.contains(s)||a.createObjectStore(s,{autoIncrement:!0}).createIndex(zt,"id",{unique:!0})}),i=Oe(n,s);return{append:o(async a=>{await i("readwrite",u=>O(u.add(a)))},"append"),clear:o(async()=>{await i("readwrite",a=>O(a.clear()))},"clear"),load:o(async()=>i("readonly",a=>O(a.getAll())),"load"),remove:o(async a=>{await i("readwrite",async u=>{let c=await O(u.index(zt).getKey(a));c!==void 0&&await O(u.delete(c))})},"remove")}},"createIndexedDbPersistence"),Wt=o((t,e=!0)=>{if(t!==!1){if(t)return t;if(!(!e||typeof indexedDB>"u"))return Mr()}},"resolvePersistenceAdapter");var Xe=o((t,e,r)=>`${t}::${e}::${r??""}`,"queryCacheKey"),Fr=500;var Nr="lunora-query-cache",Dr="query-cache",Jt="by_ts",Ur=1,Qr=o((t={})=>{let e=t.indexedDB??(typeof indexedDB>"u"?void 0:indexedDB);if(!e)throw new d("INTERNAL","createIndexedDbQueryCache: no IndexedDB available \u2014 pass `indexedDB` or use createInMemoryQueryCache()");let r=t.databaseName??Nr,s=t.storeName??Dr,n=t.maxEntries??Fr,i=Re(e,r,Ur,c=>{c.objectStoreNames.contains(s)||c.createObjectStore(s,{keyPath:"key"}).createIndex(Jt,"ts",{unique:!1})}),a=Oe(i,s),u=o(async c=>{let h=await O(c.count())-n;h<=0||await new Promise((f,m)=>{let p=c.index(Jt).openCursor();p.addEventListener("success",()=>{let y=p.result;if(!y||h<=0){f();return}y.delete(),h-=1,y.continue()}),p.addEventListener("error",()=>{m(p.error??new Error("IndexedDB eviction failed"))})})},"evict");return{clear:o(async()=>{await a("readwrite",c=>O(c.clear()))},"clear"),load:o(async()=>a("readonly",c=>O(c.getAll())),"load"),put:o(async(c,l)=>{await a("readwrite",async h=>{await O(h.put({...l,key:c})),await u(h)})},"put"),remove:o(async c=>{await a("readwrite",l=>O(l.delete(c)))},"remove")}},"createIndexedDbQueryCache"),Xt=o(t=>{if(t!==!1){if(t)return t;if(!(typeof indexedDB>"u"))return Qr()}},"resolveQueryCacheAdapter");var Ye=o((t={},e=Math.random)=>{let r=t.initialDelayMs??250,s=t.maxDelayMs??3e4,n=t.jitter??!0,i=0;return{next(){let a=Math.min(s,r*2**i);if(i+=1,!n)return a;let u=a/2;return Math.floor(u+e()*(a-u))},reset(){i=0}}},"createReconnect");var Hr=1024,Yt=o(t=>{let e=t.maxBuffer??Hr,r=[],s=[],n=!1,i,a=!1,u=o(()=>{let f=s.shift();if(!f)return!1;if(i)return f.reject(i),!0;if(r.length>0){let m=r.shift();return f.resolve({done:!1,value:m}),!0}return n?(f.resolve({done:!0,value:void 0}),!0):(s.unshift(f),!1)},"flushOne"),c={complete(){if(!(n||i))for(n=!0;u(););},fail(f){if(!(n||i))for(i=f,r.length=0;u(););},push(f){if(!(n||i||a)){if(r.length>=e){c.fail(new d("STREAM_BACKPRESSURE",`stream buffer overflow (max=${e.toString()}); the consumer cannot keep up with the producer`));return}r.push(f),u()}}},l=o(()=>{if(!a){a=!0,n=!0,r.length=0;try{t.onCancel()}catch{}for(;u(););}},"cancel");return{handle:c,iterable:{cancel:l,[Symbol.asyncIterator](){return{next(){if(i)return Promise.reject(i);if(r.length>0){let f=r.shift();return Promise.resolve({done:!1,value:f})}return n?Promise.resolve({done:!0,value:void 0}):new Promise((f,m)=>{s.push({reject:m,resolve:f})})},return(){return l(),Promise.resolve({done:!0,value:void 0})}}}}}},"createStream");var Ze=500,qr=o((t,e)=>{if(t.size<e)return;let r=t.keys().next().value;r!==void 0&&t.delete(r)},"evictOldestEntry"),C="$lunora.wire$",xe=64,Zt=1024,er="__proto__",tr={BigInt64Array,BigUint64Array,Float32Array,Float64Array,Int8Array,Int16Array,Int32Array,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array},rr={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},et=o(t=>{let e="";for(let s=0;s<t.length;s+=32768)e+=String.fromCharCode(...t.subarray(s,s+32768));return btoa(e)},"toBase64"),Br=o(t=>{let e=atob(t),r=new Uint8Array(e.length);for(let s=0;s<e.length;s+=1)r[s]=e.codePointAt(s)??0;return r},"fromBase64"),D=o((t,e=0)=>{if(e>xe)throw new RangeError(`wire-codec: value nesting exceeds the ${xe}-level limit`);if(t===void 0)return[C,"undefined"];if(t===null)return null;let r=typeof t;if(r==="bigint")return[C,"bigint",t.toString()];if(r==="number"){let a=t;return Number.isNaN(a)?[C,"nan"]:a===1/0?[C,"inf"]:a===-1/0?[C,"-inf"]:a}if(r!=="object")return t;if(t instanceof Date)return[C,"date",D(t.getTime(),e+1)];if(t instanceof Error){let a=t,u={};for(let l of Object.keys(a))a[l]!==void 0&&(u[l]=D(a[l],e+1));let c=[C,"error",a.name,a.message,u];return a.cause!==void 0&&c.push(D(a.cause,e+1)),c}if(t instanceof URL)return[C,"url",t.href];if(t instanceof Map)return[C,"map",[...t.entries()].map(([a,u])=>[D(a,e+1),D(u,e+1)])];if(t instanceof Set)return[C,"set",[...t].map(a=>D(a,e+1))];if(t instanceof ArrayBuffer)return[C,"bytes",et(new Uint8Array(t)),"ArrayBuffer"];if(ArrayBuffer.isView(t)){let a=t,u=a.constructor.name,c=new Uint8Array(a.buffer,a.byteOffset,a.byteLength);return u==="Uint8Array"?[C,"bytes",et(c)]:[C,"bytes",et(c),u]}if(Array.isArray(t)){let a=t.map(u=>D(u,e+1));return a.length>0&&a[0]===C?[C,"arr",a]:a}let s=Object.getPrototypeOf(t);if(s!==null&&s!==Object.prototype){let a=t.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${a} over the Lunora wire \u2014 only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}let n=t,i={};for(let a of Object.keys(n)){let u=n[a];u!==void 0&&(i[a]=D(u,e+1))}return i},"encodeWire"),w=o((t,e=0)=>{if(e>xe)throw new RangeError(`wire-codec: value nesting exceeds the ${xe}-level limit`);if(t===null||typeof t!="object")return t;if(Array.isArray(t)){if(t[0]===C)switch(t[1]){case"-inf":return-1/0;case"arr":return t[2].map(i=>w(i,e+1));case"bigint":{let i=t[2];if(typeof i!="string"||i.length>Zt||!/^-?\d+$/.test(i))throw new RangeError(`wire-codec: invalid or over-long bigint (max ${Zt} digits)`);return BigInt(i)}case"date":return new Date(w(t[2],e+1));case"map":return new Map(t[2].map(([i,a])=>[w(i,e+1),w(a,e+1)]));case"set":return new Set(t[2].map(i=>w(i,e+1)));case"url":return new URL(t[2]);case"error":{let i=t[2],a=t[3],u=(Object.hasOwn(rr,i)?rr[i]:void 0)??Error,c=new u(a);c.name!==i&&Object.defineProperty(c,"name",{configurable:!0,value:i,writable:!0});let l=w(t[4],e+1);for(let h of Object.keys(l))h===er?Object.defineProperty(c,h,{configurable:!0,enumerable:!0,value:l[h],writable:!0}):c[h]=l[h];return t.length>5&&Object.defineProperty(c,"cause",{configurable:!0,value:w(t[5],e+1),writable:!0}),c}case"bytes":{let i=Br(t[2]),a=t[3]??"Uint8Array";if(a==="ArrayBuffer")return i.buffer.byteLength===i.byteLength?i.buffer:i.slice().buffer;let u=Object.hasOwn(tr,a)?tr[a]:void 0;return u?new u(i.slice().buffer):i}case"inf":return 1/0;case"nan":return Number.NaN;case"undefined":return;default:return t.map(i=>w(i,e+1))}return t.map(n=>w(n,e+1))}let r=t,s={};for(let n of Object.keys(r)){let i=w(r[n],e+1);n===er?Object.defineProperty(s,n,{configurable:!0,enumerable:!0,value:i,writable:!0}):s[n]=i}return s},"decodeWire"),W=class{static{o(this,"Listeners")}listeners=new Set;add(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}emit(...e){let[r]=e;for(let s of this.listeners)try{s(r)}catch{}}clear(){this.listeners.clear()}},Kr="/_lunora/rpc",sr="/_lunora/rpc-batch",jr="/_lunora/ws",tt=o(t=>t===void 0||t===""?"":`&bucket=${encodeURIComponent(t)}`,"bucketQuery"),rt=o(t=>{for(let e=t.length-1;e>=0;e-=1)t[e]?.()},"rollbackOptimistic"),$r=o((t,e)=>{for(let r of e)r.op==="delete"?t.delete(r.key):r.value!==void 0&&t.set(r.key,r.value)},"applyRowOpsToView"),Gr="lunora-ping",Vr=3e4,zr=1e4,Wr=250,Jr=64,Xr="/_lunora/admin/shard-traffic",Yr="/_lunora/admin/scheduled",Zr="/_lunora/admin/scheduled/status",es="/_lunora/admin/scheduled/ws",ts="/_lunora/admin/scheduled/cancel",rs="/_lunora/admin/scheduled/dead",ss="/_lunora/admin/scheduled/dead/retry",ns="/_lunora/admin/scheduled/dead/cancel",is="/_lunora/admin/workflows/instances",os="/_lunora/admin/workflows/instance",as="/_lunora/admin/workflows/status",Pe="/_lunora/admin/storage",cs="/_lunora/admin/storage/url",us="/_lunora/admin/storage/buckets",hs="/_lunora/admin/functions",ls="/_lunora/admin/cron-jobs",ds="/_lunora/admin/cron-jobs/run",fs="/_lunora/admin/openapi",ms="/_lunora/admin/openrpc",ps="/_lunora/admin/global/tables",ys="/_lunora/admin/global/table",gs="/_lunora/admin/global/facet",bs="/_lunora/admin/vector/indexes",vs="/_lunora/admin/vector/query",Ss="/_lunora/admin/kv/namespaces",ws="/_lunora/admin/kv/keys",st="/_lunora/admin/kv/value",Ts="/_lunora/admin/auth/users",nr="/_lunora/admin/auth/sessions",Es="/_lunora/admin/auth/users/create",Cs="/_lunora/admin/auth/users/role",As="/_lunora/admin/auth/users/ban",Is="/_lunora/admin/auth/users/unban",_s="/_lunora/admin/auth/users/password",ks="/_lunora/admin/auth/users/remove",Rs="/_lunora/admin/auth/users/impersonate",Os="/_lunora/admin/auth/sessions/revoke",Ps="/_lunora/admin/auth/sessions/revoke-all",xs="/_lunora/admin/auth/capabilities",Ls="/_lunora/admin/auth/users/update",Ms="/_lunora/admin/auth/accounts",Fs="/_lunora/admin/auth/accounts/unlink",Ns="/_lunora/admin/auth/passkeys",Ds="/_lunora/admin/auth/passkeys/delete",Us="/_lunora/admin/auth/two-factor/disable",Qs="/_lunora/admin/auth/organizations",Hs="/_lunora/admin/auth/organizations/members",qs="/_lunora/admin/auth/organizations/invitations",Bs="/_lunora/admin/auth/organizations/members/remove",Ks="/_lunora/admin/auth/organizations/invitations/cancel",js="/_lunora/admin/auth/config",$s="/_lunora/admin/auth/organizations/create",Gs="/_lunora/admin/auth/organizations/update",Vs="/_lunora/admin/auth/organizations/remove",zs="/_lunora/admin/auth/organizations/members/add",Ws="/_lunora/admin/auth/organizations/members/invite",Js="/_lunora/admin/auth/organizations/members/role",Xs="/_lunora/admin/auth/organizations/teams",Ys="/_lunora/admin/auth/organizations/teams/create",Zs="/_lunora/admin/auth/organizations/teams/update",en="/_lunora/admin/auth/organizations/teams/remove",tn="/_lunora/admin/auth/organizations/teams/members",rn="/_lunora/admin/auth/organizations/teams/members/add",sn="/_lunora/admin/auth/organizations/teams/members/remove",nn="/_lunora/admin/auth/organizations/roles",on="/_lunora/admin/auth/organizations/roles/create",an="/_lunora/admin/auth/organizations/roles/update",cn="/_lunora/admin/auth/organizations/roles/remove",un="/api/auth",hn="/get-session",ir=o(t=>t.startsWith("https://")?`wss://${t.slice(8)}`:t.startsWith("http://")?`ws://${t.slice(7)}`:t,"deriveWsUrl"),z=o((t,e)=>`${t.endsWith("/")?t.slice(0,-1):t}${e}`,"joinUrl"),P=o((t,e)=>{let r=new URLSearchParams;for(let[n,i]of Object.entries(e))i!==void 0&&i!==""&&r.set(n,String(i));let s=r.toString();return s===""?t:`${t}?${s}`},"withQuery"),T=o(t=>t??"","connectionKey"),ln=o(t=>{let e=t.error,r=typeof e?.code=="string"?e.code:void 0,s=typeof e?.message=="string"?e.message:void 0,n=(typeof t.message=="string"?t.message:void 0)??s??"stream error";return r===void 0?new Error(n):new d(r,n)},"buildStreamError"),or=o(t=>{let e=t.error,r=typeof e?.code=="string"?e.code:void 0,s=typeof e?.message=="string"?e.message:void 0;return{message:(typeof t.message=="string"?t.message:void 0)??s??"subscription error",...r===void 0?{}:{code:r}}},"buildSubscriptionError"),ar=o((t,e)=>{for(let r of t)try{r(e)}catch{}},"fanSubscriptionError"),dn=new TextDecoder,fn=o(t=>{if(typeof t=="string")return t;if(t instanceof ArrayBuffer)return dn.decode(t)},"decodeServerFrame"),_=o((t,e)=>{if(!t.socket||t.wsState!=="open")return!1;try{return t.socket.send(JSON.stringify(e)),!0}catch{return!1}},"sendOn"),he=o(t=>{let e=new Error(t.message??"request failed");return e.code=t.code,t.data!==void 0&&(e.data=w(t.data)),t.hint!==void 0&&(e.hint=t.hint),t.docsUrl!==void 0&&(e.docsUrl=t.docsUrl),e},"reconstructError"),ee=o((t,e)=>{try{return D(t)}catch(r){let s=r instanceof Error?r.message:String(r);throw new TypeError(`LunoraClient: cannot encode ${e} \u2014 ${s}`,r instanceof Error?{cause:r}:void 0)}},"encodeCallArgs"),mn=o((t,e)=>{let r=Array.from({length:e});for(let s of t){if(typeof s.id!="number"||s.id<0||s.id>=e)continue;let n=s.body;r[s.id]=n&&"error"in n&&n.error?{error:he(n.error),ok:!1}:{ok:!0,value:w(n?.result)}}return r.map(s=>s??{error:new Error("batch call returned no result"),ok:!1})},"demuxBatchResults"),pn=new Set(["SHARD_ERROR","SHARD_UNAVAILABLE"]),nt=class t{static{o(this,"LunoraClient")}static MAX_POKE_BUFFERS=256;url;wsUrl;wsToken;authBasePath;fetchImpl;WebSocketImpl;bookmark;reconnectOptions;connectTimeoutMs;heartbeatIntervalMs;offlineQueue;outbox;clientId;clientWatermarks=new Map;outboxMutationCounter=0;onPersistenceError;persistence;persistenceVersion;outboxLeaderRelease;queryCache;hydratedQueryCache=new Map;pendingCacheWrites=new Map;cacheFlushTimer;subscriptions=new H;connections=new Map;defaultConnectionContext;connectionContexts=new Map;connectionContextHolders=new Map;authToken=null;authSubject=void 0;queuedIdentities=new Map;closed=!1;authTokenListeners=new W;statusListeners=new W;tokenExpiredListeners=new W;mutationSettledListeners=new W;pendingChangeListeners=new W;whisperHandlers=new Map;lastStatus="idle";nextSubId=0;nextStreamId=0;streams=new Map;shapeSubscriptions=new Map;pokeBuffers=new Map;nextShapeId=0;constructor(e){this.url=e.url,this.wsUrl=e.wsUrl??z(ir(e.url),jr),this.wsToken=e.wsToken;let r=e.authBasePath??un;this.authBasePath=r.endsWith("/")?r.slice(0,-1):r,this.fetchImpl=e.fetch??(typeof fetch=="function"?fetch.bind(globalThis):void 0),this.WebSocketImpl=e.WebSocket??(typeof WebSocket=="function"?WebSocket:void 0),this.bookmark=e.bookmarkStorage??Kt(),this.reconnectOptions=e.reconnect,this.heartbeatIntervalMs=e.heartbeatIntervalMs??Vr,this.connectTimeoutMs=e.connectTimeoutMs??zr,this.defaultConnectionContext=e.connectionContext,this.persistence=Wt(e.persistence,e.outbox===void 0),this.persistenceVersion=e.persistenceVersion,this.queryCache=Xt(e.queryCache),this.onPersistenceError=e.offlineQueue?.onPersistenceError,this.offlineQueue=new _e(e.offlineQueue,{onEvict:o((s,n)=>{this.emitItemSettled(s,"rejected",n)},"onEvict"),onSizeChange:o(s=>{this.pendingChangeListeners.emit(s)},"onSizeChange"),persistence:this.persistence,version:e.persistenceVersion}),this.outbox=e.outbox,this.clientId=e.clientId??`client-${ke()}`,this.persistence&&queueMicrotask(()=>{this.hydrateAsOutboxLeader()}),this.queryCache&&queueMicrotask(()=>{this.hydrateQueryCache().catch(()=>{})})}setAuthToken(e,r){let s=this.authToken!==e,n=this.identityFingerprint();this.authToken=e,r!==void 0&&(this.authSubject=r);let i=this.identityFingerprint();i!==n&&(s?this.rejectQueuedForIdentityChange():this.restampQueuedIdentity(n,i)),s&&this.authTokenListeners.emit(e)}getAuthToken(){return this.authToken}currentIdentity(){return this.identityFingerprint()}clientIdentifier(){return this.clientId}confirmedMutationWatermark(e){return this.clientWatermarks.get(e??"")??0}async callMutator(e,r,s){let n=s?.clientSeq;if(n!==void 0&&(!Number.isInteger(n)||n<=0))throw new d("INTERNAL",`callMutator: clientSeq must be a positive integer, got ${String(n)}`);let i=s?.shardKey??"",a,u=await this.rpc(e,r,s?.shardKey,{captureBookmark:!0,clientId:this.clientId,clientSeq:n,onMutationAck:o(l=>{a=l},"onMutationAck")});return a!==void 0&&a>(this.clientWatermarks.get(i)??0)&&this.clientWatermarks.set(i,a),{applied:a===void 0||a===n,result:u}}onAuthTokenChange(e){return this.authTokenListeners.add(e)}async getCurrentUser(){if(this.closed||!this.fetchImpl)return null;let e={};this.authToken&&(e.authorization=`Bearer ${this.authToken}`);try{let r=await this.fetchImpl(z(this.url,`${this.authBasePath}${hn}`),{credentials:"include",headers:e,method:"GET"});return r.ok?(await r.json())?.user??null:null}catch{return null}}setWsToken(e){if(this.wsToken!==e){this.wsToken=e;for(let r of this.connections.values())if(r.socket)try{r.socket.close()}catch{}}}setConnectionContext(e,r={}){let s=T(r.shardKey);e===void 0?this.connectionContexts.delete(s):this.connectionContexts.set(s,e),this.refreshConnectionContext(s)}acquireConnectionContext(e,r={}){let s=T(r.shardKey),n={context:e},i=this.connectionContextHolders.get(s);i?i.push(n):this.connectionContextHolders.set(s,[n]),this.refreshConnectionContext(s);let a=!1;return()=>{if(a)return;a=!0;let u=this.connectionContextHolders.get(s);if(!u)return;let c=u.indexOf(n);c!==-1&&u.splice(c,1),u.length===0&&this.connectionContextHolders.delete(s),this.refreshConnectionContext(s)}}whisperSubscribe(e,r,s={}){let n=T(s.shardKey),i=this.whisperHandlers.get(n);i||(i=new Map,this.whisperHandlers.set(n,i));let a=i.get(e),u=a===void 0;if(a||(a=new Set,i.set(e,a)),a.add(r),this.ensureSocket(s.shardKey),u){let c=this.getConnection(s.shardKey);c&&_(c,{topic:e,type:"whisper_subscribe"})}return()=>{let c=this.whisperHandlers.get(n),l=c?.get(e);if(!l?.delete(r)||l.size>0)return;c?.delete(e),c?.size===0&&this.whisperHandlers.delete(n);let h=this.getConnection(s.shardKey);h&&_(h,{topic:e,type:"whisper_unsubscribe"})}}whisper(e,r,s={}){this.ensureSocket(s.shardKey);let n=this.getConnection(s.shardKey);n&&_(n,{data:ee(r??null,`whisper data for topic '${e}'`),topic:e,type:"whisper"})}onTokenExpired(e){return this.tokenExpiredListeners.add(e)}connectionStatus(){return this.computeStatus()}onConnectionStatus(e){let r=this.statusListeners.add(e);return e(this.computeStatus()),r}pendingCount(){return this.offlineQueue.size}onPendingChange(e){let r=this.pendingChangeListeners.add(e);return e(this.offlineQueue.size),r}onMutationSettled(e){return this.mutationSettledListeners.add(e)}async query(e,r,s={}){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");return await this.rpc(e.__lunoraRef,r,s.shardKey,{attachBookmark:!0})}async batch(e){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");if(!this.fetchImpl)throw new d("INTERNAL","LunoraClient: no `fetch` implementation available");if(e.length===0)return[];let r=await this.fetchImpl(z(this.url,sr),{body:JSON.stringify({calls:e.map((i,a)=>({args:ee(i.args??{},`args for batch call '${i.fn.__lunoraRef}'`),functionPath:i.fn.__lunoraRef,id:a,shardKey:i.shardKey}))}),headers:this.rpcRequestHeaders({attachBookmark:!0}),method:"POST"}),s=r.headers.get("x-d1-bookmark");s&&this.bookmark.set(s);let n;try{n=await r.json()}catch{throw new d("INTERNAL",`LunoraClient: batch response was not JSON (status ${r.status.toString()})`)}if(!r.ok||n.error&&!n.results)throw n.error?he(n.error):new d("INTERNAL",`LunoraClient: batch request failed (status ${r.status.toString()})`);return mn(n.results??[],e.length)}async mutation(e,r,s={}){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");let n=r,i=s.mutationId??ke(),{confirms:a,rollbacks:u}=this.applyOptimisticUpdates(e.__lunoraRef,n,s.shardKey,s.optimistic);s.optimisticUpdate&&this.applyOptimisticUpdate(s.optimisticUpdate,r,s.shardKey,u,a);let c=this.getConnection(s.shardKey),l=c?.wsState??"idle",h=c?.socket!==void 0,f=c?.wasEverConnected??!1,{queueBeforeFirstConnect:m}=this.offlineQueue,p=f||m,y=this.WebSocketImpl!==void 0&&p;if(l!=="open"&&!h&&y||l==="connecting"&&p)return this.enqueueOfflineMutation(e,n,s.shardKey,i,u,a);try{let v,E=await this.rpc(e.__lunoraRef,n,s.shardKey,{captureBookmark:!0,mutationId:i,onCommitCursor:o(A=>{v=A},"onCommitCursor")});for(let A of a)A(v);return E}catch(v){throw rt(u),v}}async action(e,r,s={}){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");return await this.rpc(e.__lunoraRef,r,s.shardKey)}async shardTraffic(e){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");let r=await this.adminFetch(Xr,"POST",{table:e});return{failed:r.failed??0,ok:r.ok??0,shards:r.shards??[]}}async listScheduledJobs(){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");return(await this.adminFetch(Yr,"GET")).records??[]}async schedulerStatus(){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");let e=await this.adminFetch(Zr,"GET");return{backlog:e.backlog??0,inFlight:e.inFlight??0,pools:e.pools??[]}}async cancelScheduledJob(e){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");return{cancelled:(await this.adminFetch(ts,"POST",{id:e})).cancelled===!0}}async listDeadJobs(){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");return(await this.adminFetch(rs,"GET")).records??[]}async retryDeadJob(e){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");return{retried:(await this.adminFetch(ss,"POST",{id:e})).retried===!0}}async removeDeadJob(e){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");return{removed:(await this.adminFetch(ns,"POST",{id:e})).removed===!0}}async listWorkflowInstances(e){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");let r=new URLSearchParams({name:e.name});e.status!==void 0&&r.set("status",e.status),e.page!==void 0&&r.set("page",String(e.page)),e.perPage!==void 0&&r.set("perPage",String(e.perPage));let s=await this.adminFetch(`${is}?${r.toString()}`,"GET");return{configured:s.configured,instances:s.instances??[],page:s.page??1,perPage:s.perPage??e.perPage??0,totalCount:s.totalCount}}async getWorkflowInstance(e){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");let r=new URLSearchParams({id:e.id,name:e.name}),s=await this.adminFetch(`${os}?${r.toString()}`,"GET");return{createdOn:s.createdOn,endedOn:s.endedOn,error:s.error,id:s.id??e.id,output:s.output,params:s.params,startedOn:s.startedOn,status:s.status??"unknown",steps:s.steps??[]}}async setWorkflowInstanceStatus(e){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");return{status:(await this.adminFetch(as,"POST",{action:e.action,id:e.id,name:e.name})).status??"unknown"}}subscribeScheduledJobs(e){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");if(this.WebSocketImpl===void 0)return()=>{};let r=z(ir(this.url),es),s=Ye(this.reconnectOptions),n,i,a=!1,u=o(()=>{if(a||this.WebSocketImpl===void 0)return;let c=this.wsToken===void 0?r:`${r}?token=${encodeURIComponent(this.wsToken)}`;n=new this.WebSocketImpl(c),n.addEventListener("open",()=>{s.reset()}),n.addEventListener("message",l=>{try{let h=JSON.parse(typeof l.data=="string"?l.data:"");h.type==="jobs"&&Array.isArray(h.records)&&e(h.records)}catch{}}),n.addEventListener("close",()=>{n=void 0,a||(i=setTimeout(u,s.next()))}),n.addEventListener("error",()=>{})},"connect");return u(),()=>{a=!0,i!==void 0&&clearTimeout(i),n?.close()}}async listFunctions(){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");return(await this.adminFetch(hs,"GET")).functions??[]}async getCronJobs(){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");return(await this.adminFetch(ls,"GET")).jobs??[]}async runCronJob(e){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");let r=await this.adminFetch(ds,"POST",{name:e});return{name:r.name??e,ran:r.ran===!0}}async fetchOpenApi(){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");return await this.adminFetch(fs,"GET")}async fetchOpenRpc(){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");return await this.adminFetch(ms,"GET")}async listStorageObjects(e={}){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");let r=new URLSearchParams;e.prefix!==void 0&&e.prefix!==""&&r.set("prefix",e.prefix),e.cursor!==void 0&&e.cursor!==""&&r.set("cursor",e.cursor),e.limit!==void 0&&r.set("limit",String(e.limit)),e.bucket!==void 0&&e.bucket!==""&&r.set("bucket",e.bucket);let s=r.toString(),n=s===""?Pe:`${Pe}?${s}`,i=await this.adminFetch(n,"GET");return{cursor:i.cursor,objects:i.objects??[]}}async deleteStorageObject(e,r){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");let s=`${Pe}?key=${encodeURIComponent(e)}${tt(r?.bucket)}`,n=await this.adminFetch(s,"DELETE");return{deleted:n.deleted??!0,key:n.key??e}}async listStorageBuckets(){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");return(await this.adminFetch(us,"GET")).buckets??[]}async uploadStorageObject(e){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");let r=`${Pe}?key=${encodeURIComponent(e.key)}${tt(e.bucket)}`,s=await this.adminFetch(r,"PUT",e.body,e.contentType);return{etag:s.etag,key:s.key??e.key}}async signedStorageUrl(e,r){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");let s=r?.expiresInSeconds,n=s===void 0?"":`&expiresIn=${encodeURIComponent(s.toString())}`,i=`${cs}?key=${encodeURIComponent(e)}${n}${tt(r?.bucket)}`,a=await this.adminFetch(i,"GET");if(typeof a.url!="string")throw new TypeError("LunoraClient: storage URL endpoint returned no `url`");return a.url}async listGlobalTables(){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");return await this.adminFetch(ps,"GET")}async readGlobalTablePage(e){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");let r=new URLSearchParams({table:e.table});return e.limit!==void 0&&r.set("limit",String(e.limit)),e.offset!==void 0&&r.set("offset",String(e.offset)),e.filters!==void 0&&e.filters.length>0&&r.set("filters",JSON.stringify(e.filters)),await this.adminFetch(`${ys}?${r.toString()}`,"GET")}async facetGlobalColumn(e){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");let r=new URLSearchParams({column:e.column,table:e.table});return e.limit!==void 0&&r.set("limit",String(e.limit)),e.filters!==void 0&&e.filters.length>0&&r.set("filters",JSON.stringify(e.filters)),await this.adminFetch(`${gs}?${r.toString()}`,"GET")}async listVectorIndexes(){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");return(await this.adminFetch(bs,"GET")).indexes??[]}async queryVectorIndex(e){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");return(await this.adminFetch(vs,"POST",e)).matches??[]}async listKvNamespaces(){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");return(await this.adminFetch(Ss,"GET")).namespaces??[]}async listKvKeys(e){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");let r=P(ws,{cursor:e.cursor,limit:e.limit,namespace:e.namespace,prefix:e.prefix});return await this.adminFetch(r,"GET")}async getKvValue(e){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");let r=P(st,{key:e.key,namespace:e.namespace});return await this.adminFetch(r,"GET")}async putKvValue(e){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");await this.adminFetch(st,"PUT",e)}async deleteKvKey(e){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");let r=P(st,{key:e.key,namespace:e.namespace});await this.adminFetch(r,"DELETE")}async listAuthUsers(e={}){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");let r=P(Ts,{filterField:e.filterField,filterValue:e.filterValue,limit:e.limit,offset:e.offset,search:e.search,searchField:e.searchField,sortBy:e.sortBy,sortDirection:e.sortDirection});return await this.adminFetch(r,"GET")}async createAuthUser(e){return await this.adminFetch(Es,"POST",e)}async setAuthUserRole(e){return await this.adminFetch(Cs,"POST",e)}async banAuthUser(e){return await this.adminFetch(As,"POST",e)}async unbanAuthUser(e){return await this.adminFetch(Is,"POST",e)}async setAuthUserPassword(e){await this.adminFetch(_s,"POST",e)}async removeAuthUser(e){await this.adminFetch(ks,"POST",e)}async impersonateAuthUser(e){return await this.adminFetch(Rs,"POST",e)}async revokeAuthSession(e){await this.adminFetch(Os,"POST",e)}async revokeAuthUserSessions(e){await this.adminFetch(Ps,"POST",e)}async getAuthCapabilities(){return await this.adminFetch(xs,"GET")}async updateAuthUser(e){return await this.adminFetch(Ls,"POST",e)}async listAuthAccounts(e){return await this.adminFetch(P(Ms,{userId:e.userId}),"GET")}async unlinkAuthAccount(e){await this.adminFetch(Fs,"POST",e)}async listAuthPasskeys(e){return await this.adminFetch(P(Ns,{userId:e.userId}),"GET")}async deleteAuthPasskey(e){await this.adminFetch(Ds,"POST",e)}async disableAuthTwoFactor(e){await this.adminFetch(Us,"POST",e)}async listAuthOrganizations(e={}){return await this.adminFetch(P(Qs,{limit:e.limit,offset:e.offset}),"GET")}async listAuthOrgMembers(e){let r=P(Hs,{limit:e.limit,offset:e.offset,organizationId:e.organizationId});return await this.adminFetch(r,"GET")}async listAuthOrgInvitations(e){let r=P(qs,{limit:e.limit,offset:e.offset,organizationId:e.organizationId});return await this.adminFetch(r,"GET")}async removeAuthOrgMember(e){await this.adminFetch(Bs,"POST",e)}async cancelAuthOrgInvitation(e){await this.adminFetch(Ks,"POST",e)}async getAuthConfig(){return await this.adminFetch(js,"GET")}async createAuthOrganization(e){return await this.adminFetch($s,"POST",e)}async updateAuthOrganization(e){return await this.adminFetch(Gs,"POST",e)}async deleteAuthOrganization(e){await this.adminFetch(Vs,"POST",e)}async addAuthOrgMember(e){return await this.adminFetch(zs,"POST",e)}async inviteAuthOrgMember(e){return await this.adminFetch(Ws,"POST",e)}async setAuthOrgMemberRole(e){return await this.adminFetch(Js,"POST",e)}async listAuthOrgTeams(e){let r=P(Xs,{limit:e.limit,offset:e.offset,organizationId:e.organizationId});return await this.adminFetch(r,"GET")}async createAuthOrgTeam(e){return await this.adminFetch(Ys,"POST",e)}async updateAuthOrgTeam(e){return await this.adminFetch(Zs,"POST",e)}async removeAuthOrgTeam(e){await this.adminFetch(en,"POST",e)}async listAuthOrgTeamMembers(e){let r=P(tn,{limit:e.limit,offset:e.offset,teamId:e.teamId});return await this.adminFetch(r,"GET")}async addAuthOrgTeamMember(e){return await this.adminFetch(rn,"POST",e)}async removeAuthOrgTeamMember(e){await this.adminFetch(sn,"POST",e)}async listAuthOrgRoles(e){let r=P(nn,{limit:e.limit,offset:e.offset,organizationId:e.organizationId});return await this.adminFetch(r,"GET")}async createAuthOrgRole(e){return await this.adminFetch(on,"POST",e)}async updateAuthOrgRole(e){return await this.adminFetch(an,"POST",e)}async deleteAuthOrgRole(e){await this.adminFetch(cn,"POST",e)}async listAuthSessions(e={}){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");let r=new URLSearchParams;e.userId!==void 0&&e.userId!==""&&r.set("userId",e.userId),e.limit!==void 0&&r.set("limit",String(e.limit)),e.offset!==void 0&&r.set("offset",String(e.offset));let s=r.toString();return await this.adminFetch(s===""?nr:`${nr}?${s}`,"GET")}subscribe(e,r,s,n={}){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");let i=r??{},a=H.key(e.__lunoraRef,i,n.shardKey),u=this.subscriptions.get(a),c=s,l=n.onError;if(!u){this.nextSubId+=1;let f=`sub_${this.nextSubId.toString()}`,m=ce(i),p=this.takeHydratedCache(e.__lunoraRef,m,n.shardKey);u={acked:!1,args:i,argsKey:m,callbacks:new Set,checkpointCallbacks:new Set,errorCallbacks:new Set,fn:e,id:f,lastValue:p?.value,optimisticLayers:[],serverBase:p?.value,serverCursor:p?.serverCursor,shardKey:n.shardKey,...p?.serverEpoch===void 0?{}:{serverEpoch:p.serverEpoch}},this.subscriptions.add(u)}if(u.callbacks.add(c),l&&u.errorCallbacks.add(l),n.onCheckpoint&&u.checkpointCallbacks.add(n.onCheckpoint),u.lastValue!==void 0)try{c(u.lastValue)}catch{}this.ensureSocket(n.shardKey),this.sendSubscribeIfOpen(u);let h=u;return()=>{if(h.callbacks.delete(c),l&&h.errorCallbacks.delete(l),n.onCheckpoint&&h.checkpointCallbacks.delete(n.onCheckpoint),h.callbacks.size===0){let f=this.getConnection(h.shardKey);!(f&&_(f,{id:h.id,type:"unsubscribe"}))&&f&&f.pendingUnsubscribes.push({id:h.id,type:"unsubscribe"}),this.subscriptions.remove(h)}}}subscribeShape(e,r,s={}){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");this.nextShapeId+=1;let n=`shape_${this.nextShapeId.toString()}`,i={args:e.args,callbacks:new Set([r]),errorCallbacks:s.onError?new Set([s.onError]):new Set,id:n,name:e.name,onCheckpoint:s.onCheckpoint,rows:new Map,shardKey:s.shardKey};return this.shapeSubscriptions.set(n,i),this.ensureSocket(s.shardKey),this.sendShapeSubscribeIfOpen(i),()=>{this.shapeSubscriptions.delete(n);let a=this.getConnection(i.shardKey);!(a&&_(a,{id:n,type:"shape_unsubscribe"}))&&a&&a.pendingUnsubscribes.push({id:n,type:"shape_unsubscribe"})}}stream(e,r,s={}){if(this.closed)throw new d("INTERNAL","LunoraClient is closed");if(this.WebSocketImpl===void 0)throw new d("INTERNAL","LunoraClient: streams require a WebSocket implementation");this.nextStreamId+=1;let n=`stream_${this.nextStreamId.toString()}`,{shardKey:i}=s,a=r??{},{handle:u,iterable:c}=Yt({maxBuffer:s.maxBuffer,onCancel:o(()=>{let m=this.getConnection(i);m&&_(m,{id:n,type:"unsubscribe"}),this.streams.delete(n)},"onCancel")});this.streams.set(n,{handle:u,shardKey:i}),this.ensureSocket(i);let l=this.getConnection(i),h={id:n,query:{args:ee(a,`stream args for '${e.__lunoraRef}'`),functionPath:e.__lunoraRef,shardKey:i},type:"stream"};if(!(l?.wsState==="open"&&_(l,h))&&l){for(l.pendingStreams=l.pendingStreams??[];l.pendingStreams.length>=Jr;){let p=l.pendingStreams.shift()?.id,y=p?this.streams.get(p):void 0;y&&(y.handle.fail(new d("STREAM_QUEUE_OVERFLOW","stream-start frame evicted while socket was unreachable")),this.streams.delete(p))}l.pendingStreams.push(h)}return c}close(){this.closed=!0,this.outboxLeaderRelease?.(),this.outboxLeaderRelease=void 0;for(let e of this.streams.values())e.handle.fail(new d("CLIENT_CLOSED","LunoraClient closed"));this.streams.clear();for(let e of this.connections.values()){if(e.reconnectTimer!==void 0&&(clearTimeout(e.reconnectTimer),e.reconnectTimer=void 0),e.connectTimer!==void 0&&(clearTimeout(e.connectTimer),e.connectTimer=void 0),this.stopHeartbeat(e),e.socket){try{e.socket.close()}catch{}e.socket=void 0}e.wsState="closed"}this.offlineQueue.clear(),this.queuedIdentities.clear(),this.cacheFlushTimer!==void 0&&(clearTimeout(this.cacheFlushTimer),this.cacheFlushTimer=void 0),this.pendingCacheWrites.size>0&&this.flushQueryCacheWrites().catch(()=>{}),this.authTokenListeners.clear(),this.statusListeners.clear(),this.tokenExpiredListeners.clear(),this.mutationSettledListeners.clear(),this.pendingChangeListeners.clear(),this.whisperHandlers.clear(),this.shapeSubscriptions.clear(),this.pokeBuffers.clear()}async enqueueOfflineMutation(e,r,s,n,i,a){let u=this.identityFingerprint();if(this.outbox){this.outboxMutationCounter+=1;let c=this.outboxMutationCounter;try{await this.outbox.enqueue({args:r,clientId:this.clientId,functionPath:e.__lunoraRef,idempotencyKey:`${this.clientId}:${String(c)}`,identity:u,mutationId:c,shardKey:s})}catch(l){throw rt(i),l instanceof Error?l:new Error(String(l))}for(let l of a)l(void 0);return}return new Promise((c,l)=>{let h={args:r,functionPath:e.__lunoraRef,liveAwaiter:!0,id:n,identity:u,onCommit:o(f=>{for(let m of a)m(f)},"onCommit"),reject:o(f=>{this.queuedIdentities.delete(n),rt(i),l(f instanceof Error?f:new Error(String(f)))},"reject"),resolve:c,shardKey:s};this.offlineQueue.enqueue(h),h.id!==void 0&&this.queuedIdentities.set(h.id,u)})}async hydratePersistedQueue(){try{let e=await this.offlineQueue.hydrate();for(let r of e)this.ensureSocket(r)}catch{}}hydrateAsOutboxLeader(){let e=o(()=>{this.hydratePersistedQueue().catch(()=>{})},"hydrate"),r=globalThis.navigator?.locks;if(!r){e();return}r.request(`lunora:outbox-leader:${this.url}`,()=>(this.closed||e(),new Promise(s=>{if(this.closed){s();return}this.outboxLeaderRelease=s}))).catch(e)}async hydrateQueryCache(){if(this.queryCache)try{let e=await this.queryCache.load();for(let{key:r,...s}of e){if(Je(this.persistenceVersion,s.version)){this.queryCache.remove(r).catch(()=>{});continue}this.hydratedQueryCache.set(r,s)}}catch{}}takeHydratedCache(e,r,s){let n=Xe(e,r,s),i=this.hydratedQueryCache.get(n);if(i!==void 0)return this.hydratedQueryCache.delete(n),i.identity===this.identityFingerprint()?i:void 0}persistQueryValue(e){let r=e.serverBase;if(!this.queryCache||r===void 0)return;let s=Xe(e.fn.__lunoraRef,e.argsKey,e.shardKey);this.pendingCacheWrites.set(s,{identity:this.identityFingerprint(),serverCursor:e.serverCursor,ts:Date.now(),value:r,...e.serverEpoch===void 0?{}:{serverEpoch:e.serverEpoch},...this.persistenceVersion===void 0?{}:{version:this.persistenceVersion}}),this.cacheFlushTimer??=setTimeout(()=>{this.flushQueryCacheWrites().catch(()=>{})},Wr)}async flushQueryCacheWrites(){this.cacheFlushTimer=void 0;let{queryCache:e}=this;if(!e){this.pendingCacheWrites.clear();return}let r=[...this.pendingCacheWrites.entries()];this.pendingCacheWrites.clear(),await Promise.allSettled(r.map(([s,n])=>e.put(s,n)))}computeStatus(){let e=[...this.connections.values()];return e.length===0?"idle":e.some(r=>r.wsState==="open")?"connected":e.some(r=>r.wsState==="connecting")?"connecting":"offline"}emitConnectionStatus(){let e=this.computeStatus();e!==this.lastStatus&&(this.lastStatus=e,this.statusListeners.emit(e))}emitItemSettled(e,r,s){this.mutationSettledListeners.emit({args:e.args,code:s===void 0?void 0:s.code,error:s,functionPath:e.functionPath,hadAwaiter:e.liveAwaiter??!1,id:e.id??"",shardKey:e.shardKey,status:r})}applyOptimisticUpdates(e,r,s,n){let i=[],a=[];if(!n)return{confirms:i,rollbacks:a};let u=H.key(e,r,s),c=this.subscriptions.get(u);if(c){let l=ze(c,n);l&&(i.push(l.confirm),a.push(l.rollback))}return{confirms:i,rollbacks:a}}applyOptimisticUpdate(e,r,s,n,i){let{confirms:a,rollbacks:u,store:c}=Gt(this.subscriptions,s);try{e(c,r)}catch{for(let l=u.length-1;l>=0;l-=1)u[l]?.();return}n.push(...u),i.push(...a)}getConnection(e){return this.connections.get(T(e))}getOrCreateConnection(e){let r=T(e),s=this.connections.get(r);return s||(s={connectTimer:void 0,heartbeatTimer:void 0,pendingUnsubscribes:[],reconnect:Ye(this.reconnectOptions),reconnectTimer:void 0,shardKey:e,socket:void 0,wasEverConnected:!1,wsState:"idle"},this.connections.set(r,s)),s}wsUrlFor(e){let r=[];if(e!==void 0&&r.push(`shard=${encodeURIComponent(e)}`),this.wsToken!==void 0&&r.push(`token=${encodeURIComponent(this.wsToken)}`),r.length===0)return this.wsUrl;let s=this.wsUrl.includes("?")?"&":"?";return`${this.wsUrl}${s}${r.join("&")}`}rpcRequestHeaders(e){let r={"content-type":"application/json"};if(this.authToken&&(r.authorization=`Bearer ${this.authToken}`),e.mutationId&&(r["x-lunora-mutation-id"]=e.mutationId),e.clientId!==void 0&&(r["x-lunora-client-id"]=e.clientId),e.clientSeq!==void 0&&(r["x-lunora-client-seq"]=e.clientSeq.toString()),e.attachBookmark){let s=this.bookmark.get();s&&(r["x-d1-bookmark"]=s)}return r}async rpc(e,r,s,n={}){if(!this.fetchImpl)throw new d("INTERNAL","LunoraClient: no `fetch` implementation available");let i=this.rpcRequestHeaders(n),a=await this.fetchImpl(z(this.url,Kr),{body:JSON.stringify({args:ee(r,`args for '${e}'`),functionPath:e,shardKey:s}),headers:i,method:"POST"});if(n.captureBookmark){let c=a.headers.get("x-d1-bookmark");c&&this.bookmark.set(c)}let u;try{u=await a.json()}catch{let c=a.statusText?` ${a.statusText}`:"";throw new d("INTERNAL",`LunoraClient: response was not JSON (status ${a.status.toString()}${c})`)}if("error"in u)throw he(u.error);if(!a.ok){let c=a.statusText?` ${a.statusText}`:"";throw new d("INTERNAL",`LunoraClient: request failed (status ${a.status.toString()}${c})`)}return n.onMutationAck?.(u.lastMutationId),n.onCommitCursor?.(u.commitCursor),w(u.result)}async adminFetch(e,r,s,n){if(!this.fetchImpl)throw new d("INTERNAL","LunoraClient: no `fetch` implementation available");let i={};this.authToken&&(i.authorization=`Bearer ${this.authToken}`);let a=s instanceof ArrayBuffer||s instanceof Blob,u;s===void 0?u=void 0:a?(u=s,n!==void 0&&(i["content-type"]=n)):(u=JSON.stringify(s),i["content-type"]="application/json");let c=await this.fetchImpl(z(this.url,e),{body:u,headers:i,method:r}),l;try{l=await c.json()}catch{let h=c.statusText?` ${c.statusText}`:"";throw new d("INTERNAL",`LunoraClient: response was not JSON (status ${c.status.toString()}${h})`)}if(typeof l=="object"&&l!==null&&"error"in l){let h=l.error,f=new Error(h.message??"admin request failed");throw f.code=h.code,f}if(!c.ok){let h=c.statusText?` ${c.statusText}`:"";throw new d("INTERNAL",`LunoraClient: admin request failed (status ${c.status.toString()}${h})`)}return l}effectiveConnectionContext(e){let r=this.connectionContextHolders.get(e);return r&&r.length>0?r[r.length-1]?.context:this.connectionContexts.get(e)??this.defaultConnectionContext}refreshConnectionContext(e){let r=this.connections.get(e);r?.wsState==="open"&&this.sendConnectEnvelope(r)}sendConnectEnvelope(e){let r=this.effectiveConnectionContext(T(e.shardKey));_(e,{clientId:this.clientId,id:"connect",type:"connect",...r===void 0?{}:{context:r}})}resendShapeSubscriptions(e){for(let r of this.shapeSubscriptions.values())T(r.shardKey)===T(e)&&this.sendShapeSubscribeIfOpen(r)}ensureSocket(e){if(this.closed||this.WebSocketImpl===void 0)return;let r=this.getOrCreateConnection(e);if(r.wsState==="open"||r.wsState==="connecting")return;r.wsState="connecting",this.emitConnectionStatus();let s=new this.WebSocketImpl(this.wsUrlFor(e));r.socket=s,this.connectTimeoutMs>0&&(r.connectTimer=setTimeout(()=>{if(r.connectTimer=void 0,!(r.socket!==s||r.wsState!=="connecting")){try{s.close()}catch{}this.handleDisconnect(r)}},this.connectTimeoutMs)),s.addEventListener("open",()=>{if(r.socket!==s)return;r.connectTimer!==void 0&&(clearTimeout(r.connectTimer),r.connectTimer=void 0),r.wsState="open",r.wasEverConnected=!0,r.reconnect.reset(),this.emitConnectionStatus(),this.sendConnectEnvelope(r),this.markShardPendingAck(e);for(let i of this.subscriptions.all())T(i.shardKey)===T(e)&&this.sendSubscribeIfOpen(i);if(this.resendShapeSubscriptions(e),r.pendingUnsubscribes.length>0){let i=r.pendingUnsubscribes;r.pendingUnsubscribes=[];for(let{id:a,type:u}of i)_(r,{id:a,type:u})}if(r.pendingStreams&&r.pendingStreams.length>0){let i=r.pendingStreams;r.pendingStreams=[];for(let a of i)_(r,a)}let n=this.whisperHandlers.get(T(e));if(n)for(let i of n.keys())_(r,{topic:i,type:"whisper_subscribe"});this.flushOfflineQueue(e).catch(()=>{}),this.startHeartbeat(r)}),s.addEventListener("message",n=>{this.handleServerMessage(n.data,e)}),s.addEventListener("close",n=>{r.socket===s&&(n?.code===4001&&this.notifyTokenExpired(),this.handleDisconnect(r))}),s.addEventListener("error",()=>{r.socket===s&&(r.wsState==="connecting"||r.wsState==="open")&&this.handleDisconnect(r)})}handleDisconnect(e){if(this.closed||e.wsState==="idle"||e.wsState==="closed")return;this.stopHeartbeat(e),e.connectTimer!==void 0&&(clearTimeout(e.connectTimer),e.connectTimer=void 0),e.socket=void 0,e.wsState="idle",this.emitConnectionStatus(),this.markShardPendingAck(e.shardKey);let r=new Set((e.pendingStreams??[]).map(n=>n.id));for(let[n,i]of this.streams)T(i.shardKey)===T(e.shardKey)&&!r.has(n)&&(i.handle.fail(new d("STREAM_DISCONNECTED","stream terminated: WebSocket disconnected")),this.streams.delete(n));if(this.WebSocketImpl===void 0)return;let s=e.reconnect.next();e.reconnectTimer=setTimeout(()=>{e.reconnectTimer=void 0,this.ensureSocket(e.shardKey)},s)}startHeartbeat(e){this.stopHeartbeat(e),!(this.heartbeatIntervalMs<=0)&&(e.heartbeatTimer=setInterval(()=>{if(!(e.wsState!=="open"||!e.socket))try{e.socket.send(Gr)}catch{}},this.heartbeatIntervalMs))}stopHeartbeat(e){e.heartbeatTimer!==void 0&&(clearInterval(e.heartbeatTimer),e.heartbeatTimer=void 0)}markShardPendingAck(e){let r=T(e);for(let s of this.subscriptions.all())T(s.shardKey)===r&&(s.acked=!1)}sendSubscribeIfOpen(e){let r=this.getConnection(e.shardKey);if(r?.wsState!=="open"||e.acked)return;let s=e.fn.__lunoraTable??e.fn.__lunoraRef;_(r,{id:e.id,query:{args:e.args,functionPath:e.fn.__lunoraRef,table:s,...e.serverCursor===void 0?{}:{sinceSeq:e.serverCursor},...e.serverEpoch===void 0?{}:{sinceEpoch:e.serverEpoch}},type:"subscribe"})}sendShapeSubscribeIfOpen(e){let r=this.getConnection(e.shardKey);r?.wsState==="open"&&_(r,{id:e.id,shape:{name:e.name,...e.args===void 0?{}:{args:e.args}},type:"shape_subscribe",...e.serverCursor===void 0?{}:{sinceCheckpoint:e.serverCursor},...e.serverEpoch===void 0?{}:{sinceEpoch:e.serverEpoch}})}handleServerMessage(e,r){let s=fn(e);if(s===void 0)return;let n;try{n=JSON.parse(s)}catch{return}switch(n.type){case"ack":{let i=this.subscriptions.getById(n.id);i&&(i.acked=!0);return}case"chunk":{let{data:i,id:a}=n;this.streams.get(a)?.handle.push(w(i));return}case"complete":{this.handleCompleteMessage(n.id);return}case"data":case"delta":{this.handleDataMessage(n);return}case"error":{this.handleErrorMessage(n);break}case"pokeEnd":{this.handlePokeEnd(n);break}case"pokePart":{this.handlePokePart(n);break}case"pokeStart":{this.handlePokeStart(n);break}case"resume":{this.handleResumeMessage(n);break}case"settled":{this.handleSettledMessage(n);break}case"whisper":{this.dispatchWhisper(n,r);break}}}handleErrorMessage(e){if(e.error?.code==="TOKEN_EXPIRED"){this.notifyTokenExpired();return}let{id:s}=e,n=s===void 0?void 0:this.streams.get(s);if(n&&s!==void 0){n.handle.fail(ln(e)),this.streams.delete(s);return}let i=s===void 0?void 0:this.subscriptions.getById(s);if(i){ar(i.errorCallbacks,or(e));return}let a=s===void 0?void 0:this.shapeSubscriptions.get(s);a&&ar(a.errorCallbacks,or(e))}handlePokeStart(e){qr(this.pokeBuffers,t.MAX_POKE_BUFFERS),this.pokeBuffers.set(e.pokeId,{baseCheckpoint:e.baseCheckpoint,epoch:e.epoch,lastMutationId:new Map,parts:new Map})}handlePokePart(e){let r=this.pokeBuffers.get(e.pokeId);if(!r)return;let s=r.parts.get(e.shapeId)??[];for(let n of e.rowsPatch)s.push(n.value===void 0?n:{...n,value:w(n.value)});r.parts.set(e.shapeId,s),e.lastMutationId!==void 0&&r.lastMutationId.set(e.shapeId,e.lastMutationId)}handlePokeEnd(e){let r=this.pokeBuffers.get(e.pokeId);if(r){this.pokeBuffers.delete(e.pokeId);for(let[s,n]of r.parts){let i=this.shapeSubscriptions.get(s);if(!i)continue;let a=r.epoch!==void 0&&i.serverEpoch!==void 0&&r.epoch!==i.serverEpoch,u=r.baseCheckpoint!==void 0&&i.serverCursor!==void 0&&i.serverCursor!==r.baseCheckpoint;if(a||u){i.rows.clear(),i.serverCursor=void 0,i.serverEpoch=void 0,this.emitShapeRows(i),this.sendShapeSubscribeIfOpen(i);continue}$r(i.rows,n),e.checkpoint!==void 0&&(i.serverCursor=e.checkpoint),e.epoch!==void 0&&(i.serverEpoch=e.epoch);let c=r.lastMutationId.get(s);c!==void 0&&(i.lastMutationId=c),this.emitShapeRows(i),i.onCheckpoint?.({checkpoint:i.serverCursor,mutationId:i.lastMutationId})}}}emitShapeRows(e){let r=[...e.rows.values()];for(let s of e.callbacks)try{s(r)}catch{}}handleDataMessage(e){let{id:r}=e,s=r?this.subscriptions.getById(r):void 0;if(!s)return;let n=this.resolveDataPayload(e,s);s.serverBase=n,e.cursor!==void 0&&(s.serverCursor=e.cursor),e.epoch!==void 0&&(s.serverEpoch=e.epoch),this.persistQueryValue(s),We(s,s.serverCursor),ue(s,s.optimisticLayers.length===0?n:Ie(n,s.optimisticLayers))}handleResumeMessage(e){let r=this.subscriptions.getById(e.id);r&&this.ackAndAdvanceCursor(r,e.cursor,e.epoch)}handleSettledMessage(e){let r=this.subscriptions.getById(e.id);if(r){this.ackAndAdvanceCursor(r,e.cursor,e.epoch),e.lastMutationId!==void 0&&(r.lastMutationId=e.lastMutationId);for(let s of r.checkpointCallbacks)s({checkpoint:r.serverCursor,mutationId:r.lastMutationId})}}ackAndAdvanceCursor(e,r,s){e.acked=!0,(r!==void 0&&r!==e.serverCursor||s!==void 0&&s!==e.serverEpoch)&&(r!==void 0&&(e.serverCursor=r),s!==void 0&&(e.serverEpoch=s),this.persistQueryValue(e),We(e,e.serverCursor)&&ue(e,Ie(e.serverBase,e.optimisticLayers)))}resolveDataPayload(e,r){if("data"in e&&e.data!==void 0)return w(e.data);let s=w(e.delta);if(jt(s)&&r.serverBase!==void 0){let n=$t(r.serverBase,s);if(n!==void 0)return n}return s}dispatchWhisper(e,r){let s=this.whisperHandlers.get(T(r))?.get(e.topic);if(!s)return;let n=w(e.data);for(let i of s)try{i(n,e.from)}catch{}}notifyTokenExpired(){this.tokenExpiredListeners.emit()}handleCompleteMessage(e){let r=this.streams.get(e);if(r){r.handle.complete(),this.streams.delete(e);return}let s=this.subscriptions.getById(e);s&&this.subscriptions.remove(s)}unpersist(e){e&&this.persistence?.remove(e).catch(r=>{Z(this.onPersistenceError,"remove",r,e)})}identityFingerprint(){if(this.authSubject!==void 0)return this.authSubject===null?null:`subj:${this.authSubject}`;let e=this.authToken;return e===null?null:this.hashToken(e)}hashToken(e){let r=2166136261,s=5381;for(let n=0;n<e.length;n+=1){let i=e.charCodeAt(n);r^=i,r=Math.imul(r,16777619),s=Math.imul(s,33)+i}return`${e.length.toString(36)}:${(r>>>0).toString(36)}:${(s>>>0).toString(36)}`}isSameCredentialUnderTokenHash(e){if(e===null||e.startsWith("subj:"))return!1;let r=this.authToken;return r===null?!1:this.hashToken(r)===e}rejectQueuedForIdentityChange(){let e=this.offlineQueue.drain();for(let r of e){this.queuedIdentities.delete(r.id??""),this.unpersist(r.id);let s=new Error("offline mutation discarded: auth identity changed before replay");s.code="OFFLINE_IDENTITY_CHANGED",r.reject(s),this.emitItemSettled(r,"rejected",s)}this.clearQueryCacheForIdentityChange()}restampQueuedIdentity(e,r){for(let[s,n]of this.queuedIdentities)n===e&&this.queuedIdentities.set(s,r)}clearQueryCacheForIdentityChange(){this.cacheFlushTimer!==void 0&&(clearTimeout(this.cacheFlushTimer),this.cacheFlushTimer=void 0),this.pendingCacheWrites.clear(),this.hydratedQueryCache.clear(),this.queryCache?.clear().catch(()=>{})}async flushOfflineQueue(e){let r=T(e),s=this.offlineQueue.drain(c=>T(c.shardKey)===r);if(s.length===0)return;let n=this.identityFingerprint(),i=[];for(let c of s)this.passesReplayIdentityGate(c,n)&&i.push(c);if(i.length===0)return;let a=this.encodableOrSettleTerminal(i);if(a.length===0)return;if(a.length===1){await this.replaySequential(a);return}let u=[];for(let c=0;c<a.length;c+=Ze){let l=a.slice(c,c+Ze),h=await this.replayBatched(l);if(u.push(...h.requeue),h.stop){u.push(...a.slice(c+Ze));break}}u.length>0&&this.offlineQueue.requeue(u)}encodableOrSettleTerminal(e){let r=[];for(let s of e)try{ee(s.args,`args for '${s.functionPath}'`),r.push(s)}catch(n){this.settleReplayTerminal(s,n instanceof Error?n:new Error(String(n)))}return r}passesReplayIdentityGate(e,r){let s=e.id===void 0?void 0:this.queuedIdentities.get(e.id),n=s===void 0?e.identity:s;if(n!==void 0&&n!==r&&!this.isSameCredentialUnderTokenHash(n)){this.queuedIdentities.delete(e.id??""),this.unpersist(e.id);let i=new Error("offline mutation skipped: auth identity changed before replay");return i.code="OFFLINE_IDENTITY_CHANGED",e.reject(i),this.emitItemSettled(e,"rejected",i),!1}return this.queuedIdentities.delete(e.id??""),!0}settleReplaySuccess(e,r,s){this.unpersist(e.id),e.onCommit?.(s),e.resolve(r),this.emitItemSettled(e,"committed")}settleReplayTerminal(e,r){this.unpersist(e.id),e.reject(r),this.emitItemSettled(e,"rejected",r)}async replaySequential(e){for(let r=0;r<e.length;r+=1){let s=e[r];if(s)try{let n,i=await this.rpc(s.functionPath,s.args,s.shardKey,{captureBookmark:!0,mutationId:s.id,onCommitCursor:o(a=>{n=a},"onCommitCursor")});this.settleReplaySuccess(s,i,n)}catch(n){if(n.code!==void 0){this.settleReplayTerminal(s,n);continue}this.offlineQueue.requeue(e.slice(r));return}}}async replayBatched(e){if(!this.fetchImpl)return{requeue:e,stop:!0};let r;try{r=await this.fetchImpl(z(this.url,sr),{body:JSON.stringify({calls:e.map((i,a)=>({args:ee(i.args,`args for '${i.functionPath}'`),functionPath:i.functionPath,id:a,mutationId:i.id,shardKey:i.shardKey}))}),headers:this.rpcRequestHeaders({attachBookmark:!0}),method:"POST"})}catch{return{requeue:e,stop:!0}}let s=r.headers.get("x-d1-bookmark");s&&this.bookmark.set(s);let n;try{n=await r.json()}catch{return{requeue:e,stop:!0}}if(!n.results){if(n.error){let i=he(n.error);for(let a of e)this.settleReplayTerminal(a,i);return{requeue:[],stop:!1}}return{requeue:e,stop:!0}}return{requeue:this.settleReplayBatchSlots(e,n.results),stop:!1}}settleReplayBatchSlots(e,r){let s=new Map;for(let i of r)typeof i.id=="number"&&i.body!==void 0&&s.set(i.id,i.body);let n=[];for(let[i,a]of e.entries()){let u=s.get(i);u===void 0?n.push(a):"error"in u?pn.has(u.error.code)?n.push(a):this.settleReplayTerminal(a,he(u.error)):this.settleReplaySuccess(a,w(u.result),u.commitCursor)}return n}};export{nt as a,fr as b,Be as c,Cr as d,Ir as e,Ge as f,_r as g};
@@ -1 +1 @@
1
- import{a as N}from"./chunk-JEVKZIHN.js";import{a as y,b as T,c as E,d,e as c,f as n}from"./chunk-GTM65MVX.js";import{a as g,e as x}from"./chunk-SEU5V7I6.js";import{d as h}from"./chunk-2GMEK2W3.js";import{a as i,e as v,f as A,h as V,j as b}from"./chunk-RRCPZMC2.js";var m=v(A(),1);var e=v(V(),1);var $={ERROR:"error",INFO:"info",WARN:"warning"},F=i(r=>{let o=typeof r.metadata.table=="string"?r.metadata.table:void 0;return{description:`${r.detail} ${r.remediation}`,entity:o,issueType:r.title,key:r.cacheKey,level:$[r.level]}},"advisoryRow"),k=["error","warning","info"],D={error:"bg-destructive",info:"bg-info",warning:"bg-warning"},O=i((r,o)=>({error:r("Errors"),info:r("Info"),warning:r("Warnings")})[o],"levelLabel"),S=i((r,o,a)=>({error:r("{count} errors",{count:a}),info:r("{count} suggestions",{count:a}),warning:r("{count} warnings",{count:a})})[o],"levelCount"),H=i((r,o)=>({error:r("No errors detected"),info:r("No suggestions"),warning:r("No warnings detected")})[o],"emptyTitle"),K=i(({error:r=null,errorSource:o,rows:a,testId:l,toolbar:u})=>{let s=h(),[f,w]=(0,m.useState)("error"),C=(0,m.useMemo)(()=>{let t={error:0,info:0,warning:0};for(let R of a??[])t[R.level]+=1;return t},[a]),p=(a??[]).filter(t=>t.level===f),L=i(t=>{w(t.currentTarget.dataset.level)},"selectTab");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":l,children:[(0,e.jsxDEV)("div",{className:"flex border-b border-border",role:"tablist",children:k.map(t=>(0,e.jsxDEV)("button",{"aria-selected":f===t,className:"flex min-w-32 flex-col gap-0.5 border-b-2 border-transparent px-4 py-2 text-start outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 aria-selected:border-foreground","data-level":t,"data-testid":`${l}-tab-${t}`,onClick:L,role:"tab",type:"button",children:[(0,e.jsxDEV)("span",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[(0,e.jsxDEV)("span",{"aria-hidden":"true",className:b("size-2 rounded-sm",D[t])},void 0,!1),O(s,t)]},void 0,!0),(0,e.jsxDEV)("span",{className:"ps-4 text-xs text-muted-foreground",children:S(s,t,C[t])},void 0,!1)]},t,!0))},void 0,!1),u!==void 0&&(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:u},void 0,!1),r!==null&&(0,e.jsxDEV)(N,{error:o??r,testId:`${l}-error`},void 0,!1),(0,e.jsxDEV)(g,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(x,{className:"px-0",children:(0,e.jsxDEV)(y,{children:[(0,e.jsxDEV)(T,{children:(0,e.jsxDEV)(d,{children:[(0,e.jsxDEV)(c,{children:s("Issue type")},void 0,!1),(0,e.jsxDEV)(c,{children:s("Entity/item")},void 0,!1),(0,e.jsxDEV)(c,{children:s("Description")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(E,{children:p.length===0?(0,e.jsxDEV)(d,{children:(0,e.jsxDEV)(n,{className:"h-40 text-center align-middle text-muted-foreground",colSpan:3,"data-testid":`${l}-empty`,children:[(0,e.jsxDEV)("span",{className:"block text-sm font-medium text-foreground",children:H(s,f)},void 0,!1),(0,e.jsxDEV)("span",{className:"block text-sm",children:s("Nothing to report for this deployment.")},void 0,!1)]},void 0,!0)},void 0,!1):p.map(t=>(0,e.jsxDEV)(d,{children:[(0,e.jsxDEV)(n,{className:"font-medium text-foreground",children:t.issueType},void 0,!1),(0,e.jsxDEV)(n,{className:"font-mono text-xs text-muted-foreground",children:t.entity??"\u2014"},void 0,!1),(0,e.jsxDEV)(n,{className:"text-muted-foreground",children:[(0,e.jsxDEV)("span",{children:t.description},void 0,!1),t.action!==void 0&&(0,e.jsxDEV)("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:t.action},void 0,!1)]},void 0,!0)]},t.key,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0)},"AdvisorView");export{F as a,K as b};
1
+ import{a as N}from"./chunk-WUFVFVHJ.js";import{a as y,b as T,c as E,d,e as c,f as n}from"./chunk-GTM65MVX.js";import{a as g,e as x}from"./chunk-SEU5V7I6.js";import{d as h}from"./chunk-ITQKVEP7.js";import{a as i,e as v,f as A,h as V,j as b}from"./chunk-RRCPZMC2.js";var m=v(A(),1);var e=v(V(),1);var $={ERROR:"error",INFO:"info",WARN:"warning"},F=i(r=>{let o=typeof r.metadata.table=="string"?r.metadata.table:void 0;return{description:`${r.detail} ${r.remediation}`,entity:o,issueType:r.title,key:r.cacheKey,level:$[r.level]}},"advisoryRow"),k=["error","warning","info"],D={error:"bg-destructive",info:"bg-info",warning:"bg-warning"},O=i((r,o)=>({error:r("Errors"),info:r("Info"),warning:r("Warnings")})[o],"levelLabel"),S=i((r,o,a)=>({error:r("{count} errors",{count:a}),info:r("{count} suggestions",{count:a}),warning:r("{count} warnings",{count:a})})[o],"levelCount"),H=i((r,o)=>({error:r("No errors detected"),info:r("No suggestions"),warning:r("No warnings detected")})[o],"emptyTitle"),K=i(({error:r=null,errorSource:o,rows:a,testId:l,toolbar:u})=>{let s=h(),[f,w]=(0,m.useState)("error"),C=(0,m.useMemo)(()=>{let t={error:0,info:0,warning:0};for(let R of a??[])t[R.level]+=1;return t},[a]),p=(a??[]).filter(t=>t.level===f),L=i(t=>{w(t.currentTarget.dataset.level)},"selectTab");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":l,children:[(0,e.jsxDEV)("div",{className:"flex border-b border-border",role:"tablist",children:k.map(t=>(0,e.jsxDEV)("button",{"aria-selected":f===t,className:"flex min-w-32 flex-col gap-0.5 border-b-2 border-transparent px-4 py-2 text-start outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 aria-selected:border-foreground","data-level":t,"data-testid":`${l}-tab-${t}`,onClick:L,role:"tab",type:"button",children:[(0,e.jsxDEV)("span",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[(0,e.jsxDEV)("span",{"aria-hidden":"true",className:b("size-2 rounded-sm",D[t])},void 0,!1),O(s,t)]},void 0,!0),(0,e.jsxDEV)("span",{className:"ps-4 text-xs text-muted-foreground",children:S(s,t,C[t])},void 0,!1)]},t,!0))},void 0,!1),u!==void 0&&(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:u},void 0,!1),r!==null&&(0,e.jsxDEV)(N,{error:o??r,testId:`${l}-error`},void 0,!1),(0,e.jsxDEV)(g,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(x,{className:"px-0",children:(0,e.jsxDEV)(y,{children:[(0,e.jsxDEV)(T,{children:(0,e.jsxDEV)(d,{children:[(0,e.jsxDEV)(c,{children:s("Issue type")},void 0,!1),(0,e.jsxDEV)(c,{children:s("Entity/item")},void 0,!1),(0,e.jsxDEV)(c,{children:s("Description")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(E,{children:p.length===0?(0,e.jsxDEV)(d,{children:(0,e.jsxDEV)(n,{className:"h-40 text-center align-middle text-muted-foreground",colSpan:3,"data-testid":`${l}-empty`,children:[(0,e.jsxDEV)("span",{className:"block text-sm font-medium text-foreground",children:H(s,f)},void 0,!1),(0,e.jsxDEV)("span",{className:"block text-sm",children:s("Nothing to report for this deployment.")},void 0,!1)]},void 0,!0)},void 0,!1):p.map(t=>(0,e.jsxDEV)(d,{children:[(0,e.jsxDEV)(n,{className:"font-medium text-foreground",children:t.issueType},void 0,!1),(0,e.jsxDEV)(n,{className:"font-mono text-xs text-muted-foreground",children:t.entity??"\u2014"},void 0,!1),(0,e.jsxDEV)(n,{className:"text-muted-foreground",children:[(0,e.jsxDEV)("span",{children:t.description},void 0,!1),t.action!==void 0&&(0,e.jsxDEV)("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:t.action},void 0,!1)]},void 0,!0)]},t.key,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0)},"AdvisorView");export{F as a,K as b};
@@ -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-JPILGFXT.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-AITOCPML.js";import"./chunk-KSKXW5PX.js";import"./chunk-5OIBXYZM.js";import"./chunk-L7SK4ZZD.js";import"./chunk-X4QFAAZ5.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-DH4K2OLM.js";import{a as Ze,b as et}from"./chunk-4PC7IXNY.js";import"./chunk-2MLA6WFH.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-HVRDZZHL.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-LRYLU6EY.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as Qe,f as Ge,g as Je,h as We,l as Xe,o as Ae}from"./chunk-ITQKVEP7.js";import"./chunk-22C6COGE.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};
@@ -1 +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-2GMEK2W3.js";import{b as L}from"./chunk-J75M4LTW.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};
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,h as I,k as _,l as w}from"./chunk-ITQKVEP7.js";import{b as L}from"./chunk-22C6COGE.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 N,b as S,c as g,d as x}from"./chunk-X4QFAAZ5.js";import{d as y,k as C}from"./chunk-ITQKVEP7.js";import{a as p,e as b,g as _,h as w}from"./chunk-RRCPZMC2.js";var T=b(_(),1);var s=b(w(),1);var A=50,B={value:{colors:{dark:["var(--chart-1)"],light:["var(--chart-1)"]},label:"value"}},E=p(o=>{let l=o.columns.find(a=>o.rows.length>0&&o.rows.every(r=>typeof r[a]=="number"))??null;return{label:o.columns.find(a=>a!==l)??null,value:l}},"pickColumns"),k=p(o=>{let l=(0,T.c)(15),{result:t}=o,a=y(),r;l[0]!==t?(r=E(t),l[0]=t,l[1]=r):r=l[1];let{label:c,value:n}=r,m;l[2]!==c||l[3]!==t||l[4]!==n?(m=n===null?[]:t.rows.slice(0,A).map((e,i)=>({label:c===null?`#${(i+1).toString()}`:C(e[c]),value:Number(e[n])||0})),l[2]=c,l[3]=t,l[4]=n,l[5]=m):m=l[5];let h=m;if(n===null){let e;l[6]!==a?(e=a("No numeric column to chart."),l[6]=a,l[7]=e):e=l[7];let i;return l[8]!==e?(i=(0,s.jsxDEV)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-chart-empty",children:e},void 0,!1),l[8]=e,l[9]=i):i=l[9],i}let f,u,d;l[10]===Symbol.for("react.memo_cache_sentinel")?(f=(0,s.jsxDEV)(g,{dataKey:"label"},void 0,!1),u=(0,s.jsxDEV)(S,{dataKey:"value"},void 0,!1),d=(0,s.jsxDEV)(x,{},void 0,!1),l[10]=f,l[11]=u,l[12]=d):(f=l[10],u=l[11],d=l[12]);let v;return l[13]!==h?(v=(0,s.jsxDEV)("div",{className:"h-80 w-full p-3","data-testid":"sql-chart",children:(0,s.jsxDEV)(N,{className:"h-full w-full",config:B,data:h,children:[f,u,d]},void 0,!0)},void 0,!1),l[13]=h,l[14]=v):v=l[14],v},"SqlResultChart");export{k as a};
@@ -0,0 +1 @@
1
+ import{a as se}from"./chunk-SDQE2IUJ.js";import"./chunk-X4QFAAZ5.js";import"./chunk-BJGBHGK3.js";import"./chunk-ZIGWVHCS.js";import"./chunk-KEGAWN6Y.js";import{a as te}from"./chunk-XNJNSCLM.js";import{d as X,f as ee}from"./chunk-2MLA6WFH.js";import{c as I}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as J}from"./chunk-BOXSWNXZ.js";import{a as U}from"./chunk-TAD43CG5.js";import{a as z,b as V,c as P,e as D}from"./chunk-SEU5V7I6.js";import"./chunk-CKSHCYGC.js";import{f as Q}from"./chunk-LRYLU6EY.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as O,f as H,g as Y,h as G,l as Z}from"./chunk-ITQKVEP7.js";import"./chunk-22C6COGE.js";import{a as k,e as j,f as ie,g as le,h as oe}from"./chunk-RRCPZMC2.js";var W=j(le(),1),T=j(ie(),1);var o=j(oe(),1);var de=H(J.runSql),ae=k(($,e)=>{let s=Q(),[f,t]=(0,T.useState)(void 0),[i,d]=(0,T.useState)(void 0),[l,c]=(0,T.useState)(!0),q=(0,T.useCallback)(async a=>{c(!0);try{let x=await s.query(de,{sql:$},Y(e));a.cancelled||(t(x),d(void 0))}catch(x){a.cancelled||(t(void 0),d(G(x)))}finally{a.cancelled||c(!1)}},[s,$,e]);return(0,T.useEffect)(()=>{let a={cancelled:!1};return Z(q(a)),()=>{a.cancelled=!0}},[q]),{error:i,loading:l,result:f}},"useRunSql"),re="lunora-studio-dashboards",B={shardKey:"",sql:"",title:""},ne=k($=>{let e=(0,W.c)(54),{onEdit:s,onRemove:f,widget:t}=$,i=O(),{error:d,loading:l,result:c}=ae(t.sql,t.shardKey??""),q;e[0]!==s||e[1]!==t.id?(q=k(()=>{s(t.id)},"t1"),e[0]=s,e[1]=t.id,e[2]=q):q=e[2];let a=q,x;e[3]!==f||e[4]!==t.id?(x=k(()=>{f(t.id)},"t2"),e[3]=f,e[4]=t.id,e[5]=x):x=e[5];let K=x,M=`dashboards-widget-${t.id}`,S;e[6]!==t.title?(S=(0,o.jsxDEV)(P,{className:"min-w-0 truncate",title:t.title,children:t.title},void 0,!1),e[6]=t.title,e[7]=S):S=e[7];let L;e[8]!==i?(L=i("Edit widget"),e[8]=i,e[9]=L):L=e[9];let R=`dashboards-widget-edit-${t.id}`,A;e[10]!==i?(A=i("Edit widget"),e[10]=i,e[11]=A):A=e[11];let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=(0,o.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,o.jsxDEV)("path",{d:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"},void 0,!1)},void 0,!1),e[12]=w):w=e[12];let C;e[13]!==a||e[14]!==L||e[15]!==R||e[16]!==A?(C=(0,o.jsxDEV)(I,{"aria-label":L,"data-testid":R,onClick:a,size:"icon-xs",title:A,type:"button",variant:"ghost",children:w},void 0,!1),e[13]=a,e[14]=L,e[15]=R,e[16]=A,e[17]=C):C=e[17];let b;e[18]!==i?(b=i("Remove widget"),e[18]=i,e[19]=b):b=e[19];let E=`dashboards-widget-remove-${t.id}`,m;e[20]!==i?(m=i("Remove widget"),e[20]=i,e[21]=m):m=e[21];let p;e[22]===Symbol.for("react.memo_cache_sentinel")?(p=(0,o.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,o.jsxDEV)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"},void 0,!1)},void 0,!1),e[22]=p):p=e[22];let u;e[23]!==K||e[24]!==b||e[25]!==E||e[26]!==m?(u=(0,o.jsxDEV)(I,{"aria-label":b,"data-testid":E,onClick:K,size:"icon-xs",title:m,type:"button",variant:"ghost",children:p},void 0,!1),e[23]=K,e[24]=b,e[25]=E,e[26]=m,e[27]=u):u=e[27];let h;e[28]!==u||e[29]!==C?(h=(0,o.jsxDEV)("div",{className:"flex shrink-0 items-center gap-1",children:[C,u]},void 0,!0),e[28]=u,e[29]=C,e[30]=h):h=e[30];let v;e[31]!==h||e[32]!==S?(v=(0,o.jsxDEV)(V,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[S,h]},void 0,!0),e[31]=h,e[32]=S,e[33]=v):v=e[33];let g;e[34]!==d||e[35]!==t.id?(g=d!==void 0&&(0,o.jsxDEV)(te,{className:"font-mono text-xs",testId:`dashboards-widget-error-${t.id}`,variant:"destructive",children:d},void 0,!1),e[34]=d,e[35]=t.id,e[36]=g):g=e[36];let N;e[37]!==d||e[38]!==l||e[39]!==c||e[40]!==i||e[41]!==t.id?(N=d===void 0&&l&&c===void 0&&(0,o.jsxDEV)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${t.id}`,children:i("Running\u2026")},void 0,!1),e[37]=d,e[38]=l,e[39]=c,e[40]=i,e[41]=t.id,e[42]=N):N=e[42];let r;e[43]!==d||e[44]!==c?(r=d===void 0&&c!==void 0&&(0,o.jsxDEV)(se,{result:c},void 0,!1),e[43]=d,e[44]=c,e[45]=r):r=e[45];let n;e[46]!==g||e[47]!==N||e[48]!==r?(n=(0,o.jsxDEV)(D,{className:"min-h-32 py-2",children:[g,N,r]},void 0,!0),e[46]=g,e[47]=N,e[48]=r,e[49]=n):n=e[49];let y;return e[50]!==v||e[51]!==n||e[52]!==M?(y=(0,o.jsxDEV)(z,{"data-testid":M,children:[v,n]},void 0,!0),e[50]=v,e[51]=n,e[52]=M,e[53]=y):y=e[53],y},"WidgetCard"),ce=k($=>{let e=(0,W.c)(58),{draft:s,editing:f,onCancel:t,onChange:i,onSubmit:d}=$,l=O(),c;e[0]!==s||e[1]!==i?(c=k(_=>{i({...s,title:_.target.value})},"t1"),e[0]=s,e[1]=i,e[2]=c):c=e[2];let q=c,a;e[3]!==s||e[4]!==i?(a=k(_=>{i({...s,sql:_.target.value})},"t2"),e[3]=s,e[4]=i,e[5]=a):a=e[5];let x=a,K;e[6]!==s||e[7]!==i?(K=k(_=>{i({...s,shardKey:_.target.value})},"t3"),e[6]=s,e[7]=i,e[8]=K):K=e[8];let M=K,S;e[9]!==d?(S=k(()=>{d()},"t4"),e[9]=d,e[10]=S):S=e[10];let L=S,R;e[11]!==s.sql||e[12]!==s.title?(R=s.title.trim()!==""&&s.sql.trim()!=="",e[11]=s.sql,e[12]=s.title,e[13]=R):R=e[13];let A=R,w;e[14]!==l?(w=l("Widget title"),e[14]=l,e[15]=w):w=e[15];let C;e[16]!==l?(C=l("Widget title"),e[16]=l,e[17]=C):C=e[17];let b;e[18]!==s.title||e[19]!==q||e[20]!==w||e[21]!==C?(b=(0,o.jsxDEV)("input",{"aria-label":w,className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-title",onChange:q,placeholder:C,type:"text",value:s.title},void 0,!1),e[18]=s.title,e[19]=q,e[20]=w,e[21]=C,e[22]=b):b=e[22];let E;e[23]!==l?(E=l("SQL query"),e[23]=l,e[24]=E):E=e[24];let m;e[25]!==s.sql||e[26]!==x||e[27]!==E?(m=(0,o.jsxDEV)("textarea",{"aria-label":E,className:"min-h-24 resize-y rounded-md border border-border bg-background p-2 font-mono text-xs leading-5 outline-none focus-visible:border-ring","data-testid":"dashboards-form-sql",onChange:x,placeholder:"SELECT author, COUNT(*) AS messages FROM \u2026",spellCheck:!1,value:s.sql},void 0,!1),e[25]=s.sql,e[26]=x,e[27]=E,e[28]=m):m=e[28];let p;e[29]!==l?(p=l("Shard key (optional)"),e[29]=l,e[30]=p):p=e[30];let u;e[31]!==l?(u=l("Shard key (optional)"),e[31]=l,e[32]=u):u=e[32];let h;e[33]!==s.shardKey||e[34]!==M||e[35]!==p||e[36]!==u?(h=(0,o.jsxDEV)("input",{"aria-label":p,className:"h-8 rounded-md border border-border bg-background px-2 font-mono text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-shard",onChange:M,placeholder:u,type:"text",value:s.shardKey},void 0,!1),e[33]=s.shardKey,e[34]=M,e[35]=p,e[36]=u,e[37]=h):h=e[37];let v;e[38]!==l?(v=l("Cancel"),e[38]=l,e[39]=v):v=e[39];let g;e[40]!==t||e[41]!==v?(g=(0,o.jsxDEV)(I,{"data-testid":"dashboards-form-cancel",onClick:t,size:"sm",type:"button",variant:"outline",children:v},void 0,!1),e[40]=t,e[41]=v,e[42]=g):g=e[42];let N=!A,r;e[43]!==f||e[44]!==l?(r=l(f?"Save widget":"Add widget"),e[43]=f,e[44]=l,e[45]=r):r=e[45];let n;e[46]!==L||e[47]!==N||e[48]!==r?(n=(0,o.jsxDEV)(I,{"data-testid":"dashboards-form-save",disabled:N,onClick:L,size:"sm",type:"button",children:r},void 0,!1),e[46]=L,e[47]=N,e[48]=r,e[49]=n):n=e[49];let y;e[50]!==g||e[51]!==n?(y=(0,o.jsxDEV)("div",{className:"flex items-center justify-end gap-2",children:[g,n]},void 0,!0),e[50]=g,e[51]=n,e[52]=y):y=e[52];let F;return e[53]!==m||e[54]!==h||e[55]!==y||e[56]!==b?(F=(0,o.jsxDEV)(z,{"data-testid":"dashboards-form",children:(0,o.jsxDEV)(D,{className:"flex flex-col gap-3 py-4",children:[b,m,h,y]},void 0,!0)},void 0,!1),e[53]=m,e[54]=h,e[55]=y,e[56]=b,e[57]=F):F=e[57],F},"WidgetForm"),xe=k($=>{let e=(0,W.c)(39),{initialShardKey:s}=$,f=O(),[t,i]=X(re),[d,l]=(0,T.useState)(B),[c,q]=(0,T.useState)(null),[a,x]=(0,T.useState)(!1),K;e[0]!==s?(K=k(()=>{q(null),l({...B,shardKey:s??""}),x(!0)},"t1"),e[0]=s,e[1]=K):K=e[1];let M=K,S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=k(()=>{x(!1),q(null),l(B)},"t2"),e[2]=S):S=e[2];let L=S,R;e[3]!==t?(R=k(r=>{let n=t.find(y=>y.id===r);n!==void 0&&(q(r),l({shardKey:n.shardKey??"",sql:n.sql,title:n.title}),x(!0))},"t3"),e[3]=t,e[4]=R):R=e[4];let A=R,w;e[5]!==i?(w=k(r=>{i(n=>n.filter(y=>y.id!==r))},"t4"),e[5]=i,e[6]=w):w=e[6];let C=w,b;e[7]!==d.shardKey||e[8]!==d.sql||e[9]!==d.title||e[10]!==c||e[11]!==i?(b=k(()=>{let r=d.title.trim(),n=d.sql.trim();if(r===""||n==="")return;let y=d.shardKey.trim();i(c===null?F=>[...F,{id:ee("w"),shardKey:y,sql:n,title:r}]:F=>F.map(_=>_.id===c?{..._,shardKey:y,sql:n,title:r}:_)),L()},"t5"),e[7]=d.shardKey,e[8]=d.sql,e[9]=d.title,e[10]=c,e[11]=i,e[12]=b):b=e[12];let E=b,m;e[13]!==f?(m=f("Chart widgets backed by saved read-only SQL queries."),e[13]=f,e[14]=m):m=e[14];let p;e[15]!==m?(p=(0,o.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:m},void 0,!1),e[15]=m,e[16]=p):p=e[16];let u;e[17]!==a||e[18]!==M||e[19]!==f?(u=!a&&(0,o.jsxDEV)(I,{"data-testid":"dashboards-add",onClick:M,size:"sm",type:"button",children:f("Add widget")},void 0,!1),e[17]=a,e[18]=M,e[19]=f,e[20]=u):u=e[20];let h;e[21]!==p||e[22]!==u?(h=(0,o.jsxDEV)("div",{className:"flex items-center justify-between",children:[p,u]},void 0,!0),e[21]=p,e[22]=u,e[23]=h):h=e[23];let v;e[24]!==d||e[25]!==c||e[26]!==a||e[27]!==E?(v=a&&(0,o.jsxDEV)(ce,{draft:d,editing:c!==null,onCancel:L,onChange:l,onSubmit:E},void 0,!1),e[24]=d,e[25]=c,e[26]=a,e[27]=E,e[28]=v):v=e[28];let g;e[29]!==a||e[30]!==A||e[31]!==C||e[32]!==f||e[33]!==t?(g=t.length===0&&!a?(0,o.jsxDEV)(U,{description:f("Add a widget to chart a saved SQL query on this browser."),testId:"dashboards-empty",title:f("No widgets yet")},void 0,!1):(0,o.jsxDEV)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:t.map(r=>(0,o.jsxDEV)(ne,{onEdit:A,onRemove:C,widget:r},r.id,!1))},void 0,!1),e[29]=a,e[30]=A,e[31]=C,e[32]=f,e[33]=t,e[34]=g):g=e[34];let N;return e[35]!==v||e[36]!==g||e[37]!==h?(N=(0,o.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-dashboards",children:[h,v,g]},void 0,!0),e[35]=v,e[36]=g,e[37]=h,e[38]=N):N=e[38],N},"DashboardsPanel");export{xe as default};
@@ -1 +1 @@
1
- import{a as Q}from"./chunk-JEVKZIHN.js";import"./chunk-XNJNSCLM.js";import{a as O,b as $,c as j,d as S,e as n,f as c}from"./chunk-GTM65MVX.js";import{a as L}from"./chunk-BOXSWNXZ.js";import{a as _}from"./chunk-TAD43CG5.js";import{b as F}from"./chunk-EOSXQTSQ.js";import{a as B,e as D}from"./chunk-SEU5V7I6.js";import{b as k}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import"./chunk-M5OMEMQ3.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as U}from"./chunk-2GMEK2W3.js";import"./chunk-J75M4LTW.js";import{a as R,e as M,g as z,h as J}from"./chunk-RRCPZMC2.js";var q=M(z(),1);var l=M(J(),1);var V=["read","insert","update","delete"],K=R((e,s)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[s],"operationLabel"),W=R(e=>{let s=new Map;for(let t of e){let r=s.get(t.table)??{operations:new Set,procedures:[],table:t.table};r.operations.add(t.on),r.procedures.includes(t.procedure)||r.procedures.push(t.procedure),s.set(t.table,r)}return[...s.values()].toSorted((t,r)=>t.table.localeCompare(r.table))},"groupByTable"),ie=R(()=>{let e=(0,q.c)(49),s=U(),t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={},e[0]=t):t=e[0];let{data:r,error:C,errorSource:I}=F(L.rlsPolicies,t),f=r!==void 0,p,d,m,a,u,h,v,b,o;if(e[1]!==r||e[2]!==C||e[3]!==I||e[4]!==f||e[5]!==s){let G=W(Array.isArray(r?.policies)?r.policies:[]),P;e[15]!==r?(P=Array.isArray(r?.roles)?r.roles:[],e[15]=r,e[16]=P):P=e[16],d=P,v="flex flex-col gap-6",b="lunora-rls-panel",e[17]!==C||e[18]!==I?(o=C!==null&&(0,l.jsxDEV)(Q,{error:I,testId:"rls-error"},void 0,!1),e[17]=C,e[18]=I,e[19]=o):o=e[19],h="flex flex-col gap-2",p=B,m="overflow-hidden py-0";let A;e[20]!==s?(A=s("Policies"),e[20]=s,e[21]=A):A=e[21],e[22]!==A?(a=(0,l.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,l.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:A},void 0,!1)},void 0,!1),e[22]=A,e[23]=a):a=e[23],u=f&&G.length===0?(0,l.jsxDEV)(_,{description:s("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:s("No policies defined")},void 0,!1):(0,l.jsxDEV)(D,{className:"px-0",children:(0,l.jsxDEV)(O,{"data-testid":"rls-policies-table",children:[(0,l.jsxDEV)($,{children:(0,l.jsxDEV)(S,{children:[(0,l.jsxDEV)(n,{children:s("Table")},void 0,!1),V.map(i=>(0,l.jsxDEV)(n,{children:K(s,i)},i,!1)),(0,l.jsxDEV)(n,{children:s("Guarded by")},void 0,!1)]},void 0,!0)},void 0,!1),(0,l.jsxDEV)(j,{children:G.map(i=>(0,l.jsxDEV)(S,{"data-testid":`rls-table-${i.table}`,children:[(0,l.jsxDEV)(c,{className:"font-mono text-xs",children:i.table},void 0,!1),V.map(H=>(0,l.jsxDEV)(c,{children:i.operations.has(H)?(0,l.jsxDEV)(k,{variant:"secondary",children:s("Guarded")},void 0,!1):(0,l.jsxDEV)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"},void 0,!1)},H,!1)),(0,l.jsxDEV)(c,{className:"font-mono text-xs text-muted-foreground",children:i.procedures.join(", ")},void 0,!1)]},i.table,!0))},void 0,!1)]},void 0,!0)},void 0,!1),e[1]=r,e[2]=C,e[3]=I,e[4]=f,e[5]=s,e[6]=p,e[7]=d,e[8]=m,e[9]=a,e[10]=u,e[11]=h,e[12]=v,e[13]=b,e[14]=o}else p=e[6],d=e[7],m=e[8],a=e[9],u=e[10],h=e[11],v=e[12],b=e[13],o=e[14];let x;e[24]!==p||e[25]!==m||e[26]!==a||e[27]!==u?(x=(0,l.jsxDEV)(p,{className:m,children:[a,u]},void 0,!0),e[24]=p,e[25]=m,e[26]=a,e[27]=u,e[28]=x):x=e[28];let N;e[29]!==h||e[30]!==x?(N=(0,l.jsxDEV)("section",{className:h,children:x},void 0,!1),e[29]=h,e[30]=x,e[31]=N):N=e[31];let y;e[32]!==s?(y=s("Roles"),e[32]=s,e[33]=y):y=e[33];let g;e[34]!==y?(g=(0,l.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,l.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y},void 0,!1)},void 0,!1),e[34]=y,e[35]=g):g=e[35];let T;e[36]!==f||e[37]!==d||e[38]!==s?(T=f&&d.length===0?(0,l.jsxDEV)(_,{description:s("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:s("No roles defined")},void 0,!1):(0,l.jsxDEV)(D,{className:"px-0",children:(0,l.jsxDEV)(O,{"data-testid":"rls-roles-table",children:[(0,l.jsxDEV)($,{children:(0,l.jsxDEV)(S,{children:[(0,l.jsxDEV)(n,{children:s("Role")},void 0,!1),(0,l.jsxDEV)(n,{children:s("Description")},void 0,!1),(0,l.jsxDEV)(n,{children:s("Permissions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,l.jsxDEV)(j,{children:d.map(Y)},void 0,!1)]},void 0,!0)},void 0,!1),e[36]=f,e[37]=d,e[38]=s,e[39]=T):T=e[39];let w;e[40]!==g||e[41]!==T?(w=(0,l.jsxDEV)("section",{className:"flex flex-col gap-2",children:(0,l.jsxDEV)(B,{className:"overflow-hidden py-0",children:[g,T]},void 0,!0)},void 0,!1),e[40]=g,e[41]=T,e[42]=w):w=e[42];let E;return e[43]!==w||e[44]!==v||e[45]!==b||e[46]!==o||e[47]!==N?(E=(0,l.jsxDEV)("div",{className:v,"data-testid":b,children:[o,N,w]},void 0,!0),e[43]=w,e[44]=v,e[45]=b,e[46]=o,e[47]=N,e[48]=E):E=e[48],E},"RlsPanel");function X(e){return(0,l.jsxDEV)(k,{variant:"outline",children:e},e,!1)}R(X,"_temp");function Y(e){return(0,l.jsxDEV)(S,{"data-testid":`rls-role-${e.name}`,children:[(0,l.jsxDEV)(c,{className:"font-mono text-xs",children:e.name},void 0,!1),(0,l.jsxDEV)(c,{className:"text-muted-foreground",children:e.description??""},void 0,!1),(0,l.jsxDEV)(c,{children:e.permissions.length===0?(0,l.jsxDEV)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"},void 0,!1):(0,l.jsxDEV)("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(X)},void 0,!1)},void 0,!1)]},e.name,!0)}R(Y,"_temp2");export{ie as default};
1
+ import{a as Q}from"./chunk-WUFVFVHJ.js";import"./chunk-XNJNSCLM.js";import{a as O,b as $,c as j,d as S,e as n,f as c}from"./chunk-GTM65MVX.js";import{a as L}from"./chunk-BOXSWNXZ.js";import{a as _}from"./chunk-TAD43CG5.js";import{b as F}from"./chunk-HVRDZZHL.js";import{a as B,e as D}from"./chunk-SEU5V7I6.js";import{b as k}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import"./chunk-LRYLU6EY.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as U}from"./chunk-ITQKVEP7.js";import"./chunk-22C6COGE.js";import{a as R,e as M,g as z,h as J}from"./chunk-RRCPZMC2.js";var q=M(z(),1);var l=M(J(),1);var V=["read","insert","update","delete"],K=R((e,s)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[s],"operationLabel"),W=R(e=>{let s=new Map;for(let t of e){let r=s.get(t.table)??{operations:new Set,procedures:[],table:t.table};r.operations.add(t.on),r.procedures.includes(t.procedure)||r.procedures.push(t.procedure),s.set(t.table,r)}return[...s.values()].toSorted((t,r)=>t.table.localeCompare(r.table))},"groupByTable"),ie=R(()=>{let e=(0,q.c)(49),s=U(),t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={},e[0]=t):t=e[0];let{data:r,error:C,errorSource:I}=F(L.rlsPolicies,t),f=r!==void 0,p,d,m,a,u,h,v,b,o;if(e[1]!==r||e[2]!==C||e[3]!==I||e[4]!==f||e[5]!==s){let G=W(Array.isArray(r?.policies)?r.policies:[]),P;e[15]!==r?(P=Array.isArray(r?.roles)?r.roles:[],e[15]=r,e[16]=P):P=e[16],d=P,v="flex flex-col gap-6",b="lunora-rls-panel",e[17]!==C||e[18]!==I?(o=C!==null&&(0,l.jsxDEV)(Q,{error:I,testId:"rls-error"},void 0,!1),e[17]=C,e[18]=I,e[19]=o):o=e[19],h="flex flex-col gap-2",p=B,m="overflow-hidden py-0";let A;e[20]!==s?(A=s("Policies"),e[20]=s,e[21]=A):A=e[21],e[22]!==A?(a=(0,l.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,l.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:A},void 0,!1)},void 0,!1),e[22]=A,e[23]=a):a=e[23],u=f&&G.length===0?(0,l.jsxDEV)(_,{description:s("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:s("No policies defined")},void 0,!1):(0,l.jsxDEV)(D,{className:"px-0",children:(0,l.jsxDEV)(O,{"data-testid":"rls-policies-table",children:[(0,l.jsxDEV)($,{children:(0,l.jsxDEV)(S,{children:[(0,l.jsxDEV)(n,{children:s("Table")},void 0,!1),V.map(i=>(0,l.jsxDEV)(n,{children:K(s,i)},i,!1)),(0,l.jsxDEV)(n,{children:s("Guarded by")},void 0,!1)]},void 0,!0)},void 0,!1),(0,l.jsxDEV)(j,{children:G.map(i=>(0,l.jsxDEV)(S,{"data-testid":`rls-table-${i.table}`,children:[(0,l.jsxDEV)(c,{className:"font-mono text-xs",children:i.table},void 0,!1),V.map(H=>(0,l.jsxDEV)(c,{children:i.operations.has(H)?(0,l.jsxDEV)(k,{variant:"secondary",children:s("Guarded")},void 0,!1):(0,l.jsxDEV)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"},void 0,!1)},H,!1)),(0,l.jsxDEV)(c,{className:"font-mono text-xs text-muted-foreground",children:i.procedures.join(", ")},void 0,!1)]},i.table,!0))},void 0,!1)]},void 0,!0)},void 0,!1),e[1]=r,e[2]=C,e[3]=I,e[4]=f,e[5]=s,e[6]=p,e[7]=d,e[8]=m,e[9]=a,e[10]=u,e[11]=h,e[12]=v,e[13]=b,e[14]=o}else p=e[6],d=e[7],m=e[8],a=e[9],u=e[10],h=e[11],v=e[12],b=e[13],o=e[14];let x;e[24]!==p||e[25]!==m||e[26]!==a||e[27]!==u?(x=(0,l.jsxDEV)(p,{className:m,children:[a,u]},void 0,!0),e[24]=p,e[25]=m,e[26]=a,e[27]=u,e[28]=x):x=e[28];let N;e[29]!==h||e[30]!==x?(N=(0,l.jsxDEV)("section",{className:h,children:x},void 0,!1),e[29]=h,e[30]=x,e[31]=N):N=e[31];let y;e[32]!==s?(y=s("Roles"),e[32]=s,e[33]=y):y=e[33];let g;e[34]!==y?(g=(0,l.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,l.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y},void 0,!1)},void 0,!1),e[34]=y,e[35]=g):g=e[35];let T;e[36]!==f||e[37]!==d||e[38]!==s?(T=f&&d.length===0?(0,l.jsxDEV)(_,{description:s("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:s("No roles defined")},void 0,!1):(0,l.jsxDEV)(D,{className:"px-0",children:(0,l.jsxDEV)(O,{"data-testid":"rls-roles-table",children:[(0,l.jsxDEV)($,{children:(0,l.jsxDEV)(S,{children:[(0,l.jsxDEV)(n,{children:s("Role")},void 0,!1),(0,l.jsxDEV)(n,{children:s("Description")},void 0,!1),(0,l.jsxDEV)(n,{children:s("Permissions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,l.jsxDEV)(j,{children:d.map(Y)},void 0,!1)]},void 0,!0)},void 0,!1),e[36]=f,e[37]=d,e[38]=s,e[39]=T):T=e[39];let w;e[40]!==g||e[41]!==T?(w=(0,l.jsxDEV)("section",{className:"flex flex-col gap-2",children:(0,l.jsxDEV)(B,{className:"overflow-hidden py-0",children:[g,T]},void 0,!0)},void 0,!1),e[40]=g,e[41]=T,e[42]=w):w=e[42];let E;return e[43]!==w||e[44]!==v||e[45]!==b||e[46]!==o||e[47]!==N?(E=(0,l.jsxDEV)("div",{className:v,"data-testid":b,children:[o,N,w]},void 0,!0),e[43]=w,e[44]=v,e[45]=b,e[46]=o,e[47]=N,e[48]=E):E=e[48],E},"RlsPanel");function X(e){return(0,l.jsxDEV)(k,{variant:"outline",children:e},e,!1)}R(X,"_temp");function Y(e){return(0,l.jsxDEV)(S,{"data-testid":`rls-role-${e.name}`,children:[(0,l.jsxDEV)(c,{className:"font-mono text-xs",children:e.name},void 0,!1),(0,l.jsxDEV)(c,{className:"text-muted-foreground",children:e.description??""},void 0,!1),(0,l.jsxDEV)(c,{children:e.permissions.length===0?(0,l.jsxDEV)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"},void 0,!1):(0,l.jsxDEV)("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(X)},void 0,!1)},void 0,!1)]},e.name,!0)}R(Y,"_temp2");export{ie as default};
@@ -0,0 +1 @@
1
+ import{a as O}from"./chunk-J6J54MBP.js";import{a as j}from"./chunk-2K47A3P6.js";import{a as H}from"./chunk-WUFVFVHJ.js";import"./chunk-XNJNSCLM.js";import{a as P,b as F,c as L,d as k,e as u,f as m}from"./chunk-GTM65MVX.js";import{a as _}from"./chunk-DH4K2OLM.js";import"./chunk-4PC7IXNY.js";import"./chunk-2MLA6WFH.js";import"./chunk-3CJW6NWG.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as R}from"./chunk-BOXSWNXZ.js";import{a as B}from"./chunk-TAD43CG5.js";import{b as K}from"./chunk-HVRDZZHL.js";import{a as M,e as $}from"./chunk-SEU5V7I6.js";import{b as y}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import"./chunk-LRYLU6EY.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as D}from"./chunk-ITQKVEP7.js";import"./chunk-22C6COGE.js";import{a as S,e as T,f as U,g as V,h as X}from"./chunk-RRCPZMC2.js";var G=T(V(),1),J=T(U(),1);var t=T(X(),1);var W=80,Z=S(a=>{if(a===void 0)return"";let e=JSON.stringify(a);return e.length>W?`${e.slice(0,W)}\u2026`:e},"formatArguments"),q=S(a=>{let e=[];for(let n of a){let o=n.id.toString();if(n.subscriptions.length===0){e.push({admin:n.admin,connectionId:n.id,key:`c${o}`,subscription:null});continue}n.subscriptions.forEach((s,N)=>{e.push({admin:n.admin,connectionId:n.id,key:`c${o}-s${N.toString()}`,subscription:s})})}return e},"toRows"),w=(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:"\u2014"},void 0,!1),de=S(a=>{let e=(0,G.c)(22),{initialShardKey:n}=a,o=D(),[s,N]=(0,J.useState)(n??""),f;e[0]!==s?(f=s.trim(),e[0]=s,e[1]=f):f=e[1];let A=j(f,400),h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h={},e[2]=h):h=e[2];let p;e[3]!==A?(p={keepPreviousData:!0,shardKey:A},e[3]=A,e[4]=p):p=e[4];let{data:i,error:r,errorSource:c,refetch:Q}=K(R.listSubscriptions,h,p);O(Q,!0);let v;if(e[5]!==r||e[6]!==c||e[7]!==i||e[8]!==s||e[9]!==o){let C=i===void 0?[]:q(i.connections),l;e[11]!==s?(l=(0,t.jsxDEV)(_,{onChange:N,testId:"subs-shard-input",value:s},void 0,!1),e[11]=s,e[12]=l):l=e[12];let d;e[13]!==i||e[14]!==o?(d=i!==void 0&&(0,t.jsxDEV)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[(0,t.jsxDEV)(y,{variant:"secondary",children:o("{count} connections",{count:i.totalConnections})},void 0,!1),(0,t.jsxDEV)(y,{variant:"secondary",children:o("{count} subscriptions",{count:i.totalSubscriptions})},void 0,!1)]},void 0,!0),e[13]=i,e[14]=o,e[15]=d):d=e[15];let b;e[16]!==l||e[17]!==d?(b=(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[l,d]},void 0,!0),e[16]=l,e[17]=d,e[18]=b):b=e[18];let g;e[19]!==r||e[20]!==c?(g=r!==null&&(0,t.jsxDEV)(H,{error:c,testId:"subs-error"},void 0,!1),e[19]=r,e[20]=c,e[21]=g):g=e[21],v=(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[b,g,r===null&&i!==void 0&&C.length===0&&(0,t.jsxDEV)(B,{description:o("Active WebSocket subscriptions on this shard."),icon:(0,t.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsxDEV)("path",{d:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"},void 0,!1)},void 0,!1),testId:"subs-empty",title:o("No active subscriptions.")},void 0,!1),r===null&&C.length>0&&(0,t.jsxDEV)(M,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)($,{className:"px-0",children:(0,t.jsxDEV)(P,{"data-testid":"subs-table",children:[(0,t.jsxDEV)(F,{children:(0,t.jsxDEV)(k,{children:[(0,t.jsxDEV)(u,{children:o("Connection")},void 0,!1),(0,t.jsxDEV)(u,{children:o("Function path")},void 0,!1),(0,t.jsxDEV)(u,{children:o("Table")},void 0,!1),(0,t.jsxDEV)(u,{children:o("Arguments")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(L,{children:C.map(x=>{let{subscription:I}=x,E=Z(I?.args);return(0,t.jsxDEV)(k,{"data-testid":"subs-row",children:[(0,t.jsxDEV)(m,{className:"font-medium tabular-nums",children:(0,t.jsxDEV)("span",{className:"inline-flex items-center gap-1.5",children:["#",x.connectionId,x.admin&&(0,t.jsxDEV)(y,{variant:"outline",children:o("admin")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(m,{className:"font-mono text-xs",children:I?.functionPath??w},void 0,!1),(0,t.jsxDEV)(m,{children:I?.table??w},void 0,!1),(0,t.jsxDEV)(m,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:E||void 0,children:E||w},void 0,!1)]},x.key,!0)})},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0),e[5]=r,e[6]=c,e[7]=i,e[8]=s,e[9]=o,e[10]=v}else v=e[10];return v},"SubscriptionsPanel");export{de as default};
@@ -0,0 +1 @@
1
+ import{a as le}from"./chunk-AITOCPML.js";import{a as Y}from"./chunk-2K47A3P6.js";import{a as Z}from"./chunk-WUFVFVHJ.js";import"./chunk-XNJNSCLM.js";import{a as ee,b as te,c as re,d as j,e as o,f as i}from"./chunk-GTM65MVX.js";import{a as X}from"./chunk-DH4K2OLM.js";import"./chunk-4PC7IXNY.js";import"./chunk-2MLA6WFH.js";import"./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 U}from"./chunk-TAD43CG5.js";import{b as G}from"./chunk-HVRDZZHL.js";import{a as z,e as Q}from"./chunk-SEU5V7I6.js";import{b as O}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import"./chunk-LRYLU6EY.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as H,p as W}from"./chunk-ITQKVEP7.js";import"./chunk-22C6COGE.js";import{a,e as L,f as fe,g as me,h as ue,j as P}from"./chunk-RRCPZMC2.js";var ae=L(me(),1),q=L(fe(),1);var t=L(ue(),1);var he={action:"outline",mutation:"default",query:"secondary"},se=a(r=>r<1e3?`${r<10?r.toFixed(1):Math.round(r).toString()}ms`:`${(r/1e3).toFixed(2)}s`,"formatMs"),ve=a(r=>r.calls===0?"\u2014":r.errors===0?"0":`${r.errors.toString()} (${(r.errors/r.calls*100).toFixed(1)}%)`,"errorCell"),pe=a(r=>{let e=r.conflicts??0;return r.calls===0?"\u2014":e===0?"0":`${e.toString()} (${(e/r.calls*100).toFixed(1)}%)`},"conflictCell"),xe={calls:a((r,e)=>e.calls-r.calls,"calls"),recent:a((r,e)=>e.lastCalledAt-r.lastCalledAt,"recent"),slowest:a((r,e)=>e.maxDurationMs-r.maxDurationMs,"slowest")},Ie=a(r=>{let e=(0,ae.c)(47),{functions:I,initialShardKey:oe}=r,s=H(),[n,ie]=(0,q.useState)(oe??""),[d,ne]=(0,q.useState)("recent"),C;e[0]!==n?(C=n.trim(),e[0]=n,e[1]=C):C=e[1];let F=Y(C,400),M;e[2]===Symbol.for("react.memo_cache_sentinel")?(M={},e[2]=M):M=e[2];let T;e[3]!==F?(T={live:!0,shardKey:F},e[3]=F,e[4]=T):T=e[4];let{data:de,error:c,errorSource:N,liveError:b}=G(J.getFunctionStats,M,T),S=de?.functions??null,w;e[5]!==I?(w=new Map((I??[]).map(ge)),e[5]=I,e[6]=w):w=e[6];let K=w,E;e[7]===Symbol.for("react.memo_cache_sentinel")?(E=a(k=>{ne(k.currentTarget.dataset.sort)},"t5"),e[7]=E):E=e[7];let ce=E,$;if(e[8]!==c||e[9]!==N||e[10]!==K||e[11]!==b||e[12]!==n||e[13]!==d||e[14]!==S||e[15]!==s){let k=S===null?[]:S.toSorted(xe[d]),f;e[17]!==s?(f=s("Recent"),e[17]=s,e[18]=f):f=e[18];let m;e[19]!==f?(m={key:"recent",label:f},e[19]=f,e[20]=m):m=e[20];let u;e[21]!==s?(u=s("Most called"),e[21]=s,e[22]=u):u=e[22];let h;e[23]!==u?(h={key:"calls",label:u},e[23]=u,e[24]=h):h=e[24];let v;e[25]!==s?(v=s("Slowest"),e[25]=s,e[26]=v):v=e[26];let p;e[27]!==v?(p={key:"slowest",label:v},e[27]=v,e[28]=p):p=e[28];let A;e[29]!==h||e[30]!==p||e[31]!==m?(A=[m,h,p],e[29]=h,e[30]=p,e[31]=m,e[32]=A):A=e[32];let _=A,x;e[33]!==n?(x=(0,t.jsxDEV)(X,{onChange:ie,testId:"fs-shard-input",value:n},void 0,!1),e[33]=n,e[34]=x):x=e[34];let g;e[35]!==b?(g=(0,t.jsxDEV)(le,{message:b,prefix:"fs"},void 0,!1),e[35]=b,e[36]=g):g=e[36];let y;e[37]!==_||e[38]!==d?(y=(0,t.jsxDEV)("div",{className:"ml-auto flex items-center gap-1",role:"group",children:_.map(l=>(0,t.jsxDEV)(V,{"data-sort":l.key,"data-testid":`fs-sort-${l.key}`,onClick:ce,size:"sm",type:"button",variant:d===l.key?"secondary":"ghost",children:l.label},l.key,!1))},void 0,!1),e[37]=_,e[38]=d,e[39]=y):y=e[39];let B;e[40]!==x||e[41]!==g||e[42]!==y?(B=(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[x,g,y]},void 0,!0),e[40]=x,e[41]=g,e[42]=y,e[43]=B):B=e[43];let D;e[44]!==c||e[45]!==N?(D=c!==null&&(0,t.jsxDEV)(Z,{error:N,testId:"fs-error"},void 0,!1),e[44]=c,e[45]=N,e[46]=D):D=e[46],$=(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-stats",children:[B,D,S!==null&&k.length===0&&c===null&&(0,t.jsxDEV)(U,{description:s("Per-function call counts, error rates, and latency land here after your first request."),icon:(0,t.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsxDEV)("path",{d:"M3 3v18h18"},void 0,!1),(0,t.jsxDEV)("path",{d:"M7 14l4-4 3 3 5-6"},void 0,!1)]},void 0,!0),testId:"fs-empty",title:s("No functions have run on this shard yet.")},void 0,!1),k.length>0&&(0,t.jsxDEV)(z,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Q,{className:"px-0",children:(0,t.jsxDEV)(ee,{"data-testid":"fs-table",children:[(0,t.jsxDEV)(te,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(o,{children:s("function")},void 0,!1),(0,t.jsxDEV)(o,{children:s("kind")},void 0,!1),(0,t.jsxDEV)(o,{className:"text-right",children:s("calls")},void 0,!1),(0,t.jsxDEV)(o,{className:"text-right",children:s("errors")},void 0,!1),(0,t.jsxDEV)(o,{className:"text-right",children:s("conflicts")},void 0,!1),(0,t.jsxDEV)(o,{className:"text-right",children:s("avg")},void 0,!1),(0,t.jsxDEV)(o,{className:"text-right",children:s("max")},void 0,!1),(0,t.jsxDEV)(o,{children:s("last run")},void 0,!1),(0,t.jsxDEV)(o,{children:s("last error")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(re,{children:k.map(l=>{let R=K.get(l.path);return(0,t.jsxDEV)(j,{"data-testid":`fs-row-${l.path}`,children:[(0,t.jsxDEV)(i,{className:"font-medium",children:l.path},void 0,!1),(0,t.jsxDEV)(i,{children:R===void 0?(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:"\u2014"},void 0,!1):(0,t.jsxDEV)(O,{variant:he[R],children:R},void 0,!1)},void 0,!1),(0,t.jsxDEV)(i,{className:"text-right tabular-nums",children:l.calls},void 0,!1),(0,t.jsxDEV)(i,{className:P("text-right tabular-nums",l.errors>0&&"text-destructive"),children:ve(l)},void 0,!1),(0,t.jsxDEV)(i,{className:P("text-right tabular-nums",(l.conflicts??0)>0&&"text-warning"),children:pe(l)},void 0,!1),(0,t.jsxDEV)(i,{className:"text-right tabular-nums",children:l.calls===0?"\u2014":se(l.totalDurationMs/l.calls)},void 0,!1),(0,t.jsxDEV)(i,{className:"text-right tabular-nums",children:l.calls===0?"\u2014":se(l.maxDurationMs)},void 0,!1),(0,t.jsxDEV)(i,{className:"text-muted-foreground",children:W(l.lastCalledAt,"\u2014")},void 0,!1),(0,t.jsxDEV)(i,{className:"max-w-[24ch] truncate text-destructive",title:l.lastErrorMessage??void 0,children:l.lastErrorMessage??(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:"\u2014"},void 0,!1)},void 0,!1)]},l.path,!0)})},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0),e[8]=c,e[9]=N,e[10]=K,e[11]=b,e[12]=n,e[13]=d,e[14]=S,e[15]=s,e[16]=$}else $=e[16];return $},"FunctionStatsPanel");function ge(r){return[r.path,r.kind]}a(ge,"_temp");export{Ie as FunctionStatsPanel};