@lunora/studio 1.0.0-alpha.96 → 1.0.0-alpha.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/standalone/{chunk-ESIEIGR3.js → chunk-2KRXOCZ2.js} +1 -1
- package/dist/standalone/{chunk-2YGNOZPZ.js → chunk-3626PHEZ.js} +1 -1
- package/dist/standalone/{chunk-2FRLB5SB.js → chunk-3IF75YS7.js} +1 -1
- package/dist/standalone/{chunk-44T6NSYY.js → chunk-3SGYSFRC.js} +1 -1
- package/dist/standalone/{chunk-WPERYUTG.js → chunk-4EHNOASW.js} +1 -1
- package/dist/standalone/{chunk-ZCPQGIQW.js → chunk-5A7NIX77.js} +1 -1
- package/dist/standalone/{chunk-34WN3PEC.js → chunk-5L2VKBAJ.js} +1 -1
- package/dist/standalone/{chunk-YOKL7XDT.js → chunk-5L63KFHD.js} +1 -1
- package/dist/standalone/{chunk-LZGOETI3.js → chunk-6F7KP54M.js} +1 -1
- package/dist/standalone/{chunk-DXJWFZFI.js → chunk-73B3T2SA.js} +1 -1
- package/dist/standalone/{chunk-VWKQ6X2S.js → chunk-7CWPU3LW.js} +1 -1
- package/dist/standalone/{chunk-IGBUUFPN.js → chunk-A6NAMYVS.js} +1 -1
- package/dist/standalone/{chunk-57BUSXRD.js → chunk-ATLV7KWK.js} +1 -1
- package/dist/standalone/{chunk-NSUBZT43.js → chunk-BLHSTFG3.js} +1 -1
- package/dist/standalone/{chunk-ETU7KIO4.js → chunk-C2ZFQARQ.js} +1 -1
- package/dist/standalone/{chunk-WQJOV6L5.js → chunk-CXBXUT5A.js} +2 -2
- package/dist/standalone/{chunk-HJC67CE4.js → chunk-D264UAKY.js} +1 -1
- package/dist/standalone/{chunk-AUXEGD24.js → chunk-DDO5EGID.js} +1 -1
- package/dist/standalone/{chunk-QNQTMABQ.js → chunk-E3Z4QXAD.js} +1 -1
- package/dist/standalone/{chunk-I7FF5IIJ.js → chunk-EZKBI7SZ.js} +1 -1
- package/dist/standalone/{chunk-UZHRBXA7.js → chunk-FHZ5WDTU.js} +1 -1
- package/dist/standalone/{chunk-WOBRLIBX.js → chunk-FXBBFE7Y.js} +1 -1
- package/dist/standalone/{chunk-BAJXBWFJ.js → chunk-G2O3XP7Y.js} +1 -1
- package/dist/standalone/{chunk-BLJANR7J.js → chunk-H5ZYPSLB.js} +1 -1
- package/dist/standalone/{chunk-J4POSI6T.js → chunk-HH5CZ6KD.js} +1 -1
- package/dist/standalone/{chunk-UE6A3CRB.js → chunk-I7V54EDS.js} +1 -1
- package/dist/standalone/{chunk-EYIEO5QZ.js → chunk-II64XEZV.js} +1 -1
- package/dist/standalone/{chunk-TKFI6XYV.js → chunk-IZFPJXB3.js} +1 -1
- package/dist/standalone/{chunk-D7B2KFWM.js → chunk-J4UYSDWF.js} +1 -1
- package/dist/standalone/{chunk-TVRCPIAV.js → chunk-JNY7CFF4.js} +1 -1
- package/dist/standalone/{chunk-TAWXVVAZ.js → chunk-KP6VHTO4.js} +1 -1
- package/dist/standalone/{chunk-CFXL7MQK.js → chunk-LAEO6D34.js} +1 -1
- package/dist/standalone/{chunk-QVPKPH2T.js → chunk-LHAHIDNT.js} +1 -1
- package/dist/standalone/{chunk-LT236J7E.js → chunk-M2M3RYJU.js} +1 -1
- package/dist/standalone/{chunk-KGPNIBOV.js → chunk-M3Z2YAHD.js} +1 -1
- package/dist/standalone/{chunk-TGQH54CS.js → chunk-MW5YIENZ.js} +1 -1
- package/dist/standalone/{chunk-2IFGRS6R.js → chunk-NBANYYGB.js} +1 -1
- package/dist/standalone/{chunk-3WISGFZ7.js → chunk-NCKRVNF2.js} +1 -1
- package/dist/standalone/{chunk-JRAUQ4L2.js → chunk-NDO6YSEG.js} +1 -1
- package/dist/standalone/{chunk-DGO2XJOT.js → chunk-NJRW66LJ.js} +1 -1
- package/dist/standalone/{chunk-LV5UVTHL.js → chunk-OKZP3YY3.js} +1 -1
- package/dist/standalone/{chunk-NQ4FA65F.js → chunk-ON2FIVI2.js} +1 -1
- package/dist/standalone/{chunk-U7ILDM43.js → chunk-OQIGV6FX.js} +1 -1
- package/dist/standalone/{chunk-E2C6CK7F.js → chunk-OZA2RA45.js} +1 -1
- package/dist/standalone/{chunk-YEGFNH56.js → chunk-P33WK7YI.js} +1 -1
- package/dist/standalone/{chunk-LZ2RREQV.js → chunk-PKWJ7UOG.js} +1 -1
- package/dist/standalone/{chunk-GL7YL3VF.js → chunk-PLFTCTMX.js} +1 -1
- package/dist/standalone/{chunk-Q2QILUP4.js → chunk-PMGTIUU2.js} +1 -1
- package/dist/standalone/{chunk-SFQX7RUJ.js → chunk-QC4T2L6I.js} +1 -1
- package/dist/standalone/{chunk-U5MIBWJD.js → chunk-QEVFPILV.js} +1 -1
- package/dist/standalone/{chunk-ECF57FQF.js → chunk-QQYX5WN4.js} +1 -1
- package/dist/standalone/{chunk-7URLLMST.js → chunk-S7ZOM3NK.js} +1 -1
- package/dist/standalone/{chunk-AQZMKZMP.js → chunk-SPE3AB54.js} +1 -1
- package/dist/standalone/{chunk-7KU3LR7G.js → chunk-STESBRLN.js} +1 -1
- package/dist/standalone/{chunk-ZURV2PEP.js → chunk-SZXVX6PY.js} +1 -1
- package/dist/standalone/{chunk-OZK52CH2.js → chunk-UYPXC3OO.js} +1 -1
- package/dist/standalone/{chunk-3PXUIMP2.js → chunk-VH2IO643.js} +1 -1
- package/dist/standalone/{chunk-BMYWOK5Q.js → chunk-WLXH4ECM.js} +1 -1
- package/dist/standalone/{chunk-2NO45MRI.js → chunk-XPOUF2XH.js} +1 -1
- package/dist/standalone/{chunk-MVJMAEP4.js → chunk-YP7WZ6YM.js} +1 -1
- package/dist/standalone/{chunk-FA6AR5QU.js → chunk-YZIR7PL5.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +6 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as p}from"./chunk-YEGFNH56.js";import{a,e as P,f as $,g as lt,h as Ue}from"./chunk-3XIESWL4.js";var L=class{static{a(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 fr=class extends L{static{a(this,"FocusManager")}#e;#t;#r;constructor(){super(),this.#r=t=>{if(typeof window<"u"&&window.addEventListener){let e=a(()=>t(),"listener");return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#r=t,this.#t?.(),this.#t=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#e!==t&&(this.#e=t,this.onFocus())}onFocus(){let t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},X=new fr;var pr={setTimeout:a((t,e)=>setTimeout(t,e),"setTimeout"),clearTimeout:a(t=>clearTimeout(t),"clearTimeout"),setInterval:a((t,e)=>setInterval(t,e),"setInterval"),clearInterval:a(t=>clearInterval(t),"clearInterval")},mr=class{static{a(this,"TimeoutManager")}#e=pr;#t=!1;setTimeoutProvider(t){this.#e=t}setTimeout(t,e){return this.#e.setTimeout(t,e)}clearTimeout(t){this.#e.clearTimeout(t)}setInterval(t,e){return this.#e.setInterval(t,e)}clearInterval(t){this.#e.clearInterval(t)}},Q=new mr;function ft(t){setTimeout(t,0)}a(ft,"systemSetTimeoutZero");var Ne=typeof window>"u"||"Deno"in globalThis;function g(){}a(g,"noop");function yt(t,e){return typeof t=="function"?t(e):t}a(yt,"functionalUpdate");function ie(t){return typeof t=="number"&&t>=0&&t!==1/0}a(ie,"isValidTimeout");function me(t,e){return Math.max(t+(e||0)-Date.now(),0)}a(me,"timeUntilStale");function x(t,e){return typeof t=="function"?t(e):t}a(x,"resolveStaleTime");function I(t,e){return typeof t=="function"?t(e):t}a(I,"resolveQueryBoolean");function ye(t,e){let{type:r="all",exact:s,fetchStatus:i,predicate:n,queryKey:o,stale:c}=t;if(o){if(s){if(e.queryHash!==ne(o,e.options))return!1}else if(!N(e.queryKey,o))return!1}if(r!=="all"){let u=e.isActive();if(r==="active"&&!u||r==="inactive"&&u)return!1}return!(typeof c=="boolean"&&e.isStale()!==c||i&&i!==e.state.fetchStatus||n&&!n(e))}a(ye,"matchQuery");function be(t,e){let{exact:r,status:s,predicate:i,mutationKey:n}=t;if(n){if(!e.options.mutationKey)return!1;if(r){if(H(e.options.mutationKey)!==H(n))return!1}else if(!N(e.options.mutationKey,n))return!1}return!(s&&e.state.status!==s||i&&!i(e))}a(be,"matchMutation");function ne(t,e){return(e?.queryKeyHashFn||H)(t)}a(ne,"hashQueryKeyByOptions");function H(t){return JSON.stringify(t,(e,r)=>qe(r)?Object.keys(r).sort().reduce((s,i)=>(s[i]=r[i],s),{}):r)}a(H,"hashKey");function N(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(t&&e&&typeof t=="object"&&typeof e=="object"){if(Array.isArray(t)&&Array.isArray(e)){for(let s=0;s<e.length;s++)if(!N(t[s],e[s]))return!1;return!0}let r=Object.keys(e);for(let s of r)if(!N(t[s],e[s]))return!1;return!0}return!1}a(N,"partialMatchKey");var yr=Object.prototype.hasOwnProperty;function Be(t,e,r=0){if(t===e)return t;if(r>500)return e;let s=pt(t)&&pt(e);if(!s&&!(qe(t)&&qe(e)))return e;let n=(s?t:Object.keys(t)).length,o=s?e:Object.keys(e),c=o.length,u=s?new Array(c):{},d=0;for(let h=0;h<c;h++){let l=s?h:o[h],f=t[l],m=e[l];if(f===m){u[l]=f,(s?h<n:yr.call(t,l))&&d++;continue}if(f===null||m===null||typeof f!="object"||typeof m!="object"){u[l]=m;continue}let y=Be(f,m,r+1);u[l]=y,y===f&&d++}return n===c&&d===n?t:u}a(Be,"replaceEqualDeep");function ve(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}a(ve,"shallowEqualObjects");function pt(t){return Array.isArray(t)&&t.length===Object.keys(t).length}a(pt,"isPlainArray");function qe(t){if(!mt(t))return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(!mt(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}a(qe,"isPlainObject");function mt(t){return Object.prototype.toString.call(t)==="[object Object]"}a(mt,"hasObjectPrototype");function bt(t){return new Promise(e=>{Q.setTimeout(e,t)})}a(bt,"sleep");function ae(t,e,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,e):r.structuralSharing!==!1?Be(t,e):e}a(ae,"replaceData");function br(t){return t}a(br,"keepPreviousData");function vt(t,e,r=0){let s=[...t,e];return r&&s.length>r?s.slice(1):s}a(vt,"addToEnd");function gt(t,e,r=0){let s=[e,...t];return r&&s.length>r?s.slice(0,-1):s}a(gt,"addToStart");var Y=Symbol();function ge(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===Y?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}a(ge,"ensureQueryFn");function Se(t,e){return typeof t=="function"?t(...e):!!t}a(Se,"shouldThrowError");function St(t,e,r){let s=!1,i;return Object.defineProperty(t,"signal",{enumerable:!0,get:a(()=>(i??=e(),s||(s=!0,i.aborted?r():i.addEventListener("abort",r,{once:!0})),i),"get")}),t}a(St,"addConsumeAwareSignal");var D=(()=>{let t=a(()=>Ne,"isServerFn");return{isServer(){return t()},setIsServer(e){t=e}}})();function oe(){let t,e,r=new Promise((i,n)=>{t=i,e=n});r.status="pending",r.catch(()=>{});function s(i){Object.assign(r,i),delete r.resolve,delete r.reject}return a(s,"finalize"),r.resolve=i=>{s({status:"fulfilled",value:i}),t(i)},r.reject=i=>{s({status:"rejected",reason:i}),e(i)},r}a(oe,"pendingThenable");var wt=ft;function vr(){let t=[],e=0,r=a(c=>{c()},"notifyFn"),s=a(c=>{c()},"batchNotifyFn"),i=wt,n=a(c=>{e?t.push(c):i(()=>{r(c)})},"schedule"),o=a(()=>{let c=t;t=[],c.length&&i(()=>{s(()=>{c.forEach(u=>{r(u)})})})},"flush");return{batch:a(c=>{let u;e++;try{u=c()}finally{e--,e||o()}return u},"batch"),batchCalls:a(c=>(...u)=>{n(()=>{c(...u)})},"batchCalls"),schedule:n,setNotifyFunction:a(c=>{r=c},"setNotifyFunction"),setBatchNotifyFunction:a(c=>{s=c},"setBatchNotifyFunction"),setScheduler:a(c=>{i=c},"setScheduler")}}a(vr,"createNotifyManager");var v=vr();var gr=class extends L{static{a(this,"OnlineManager")}#e=!0;#t;#r;constructor(){super(),this.#r=t=>{if(typeof window<"u"&&window.addEventListener){let e=a(()=>t(!0),"onlineListener"),r=a(()=>t(!1),"offlineListener");return window.addEventListener("online",e,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#r=t,this.#t?.(),this.#t=t(this.setOnline.bind(this))}setOnline(t){this.#e!==t&&(this.#e=t,this.listeners.forEach(r=>{r(t)}))}isOnline(){return this.#e}},Z=new gr;function Sr(t){return Math.min(1e3*2**t,3e4)}a(Sr,"defaultRetryDelay");function Ke(t){return(t??"online")==="online"?Z.isOnline():!0}a(Ke,"canFetch");var we=class extends Error{static{a(this,"CancelledError")}constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function Ce(t){let e=!1,r=0,s,i=oe(),n=a(()=>i.status!=="pending","isResolved"),o=a(b=>{if(!n()){let w=new we(b);f(w),t.onCancel?.(w)}},"cancel"),c=a(()=>{e=!0},"cancelRetry"),u=a(()=>{e=!1},"continueRetry"),d=a(()=>X.isFocused()&&(t.networkMode==="always"||Z.isOnline())&&t.canRun(),"canContinue"),h=a(()=>Ke(t.networkMode)&&t.canRun(),"canStart"),l=a(b=>{n()||(s?.(),i.resolve(b))},"resolve"),f=a(b=>{n()||(s?.(),i.reject(b))},"reject"),m=a(()=>new Promise(b=>{s=a(w=>{(n()||d())&&b(w)},"continueFn"),t.onPause?.()}).then(()=>{s=void 0,n()||t.onContinue?.()}),"pause"),y=a(()=>{if(n())return;let b,w=r===0?t.initialPromise:void 0;try{b=w??t.fn()}catch(E){b=Promise.reject(E)}Promise.resolve(b).then(l).catch(E=>{if(n())return;let M=t.retry??(D.isServer()?0:3),U=t.retryDelay??Sr,K=typeof U=="function"?U(r,E):U,j=M===!0||typeof M=="number"&&r<M||typeof M=="function"&&M(r,E);if(e||!j){f(E);return}r++,t.onFail?.(r,E),bt(K).then(()=>d()?void 0:m()).then(()=>{e?f(E):y()})})},"run");return{promise:i,status:a(()=>i.status,"status"),cancel:o,continue:a(()=>(s?.(),i),"continue"),cancelRetry:c,continueRetry:u,canStart:h,start:a(()=>(h()?y():m().then(y),i),"start")}}a(Ce,"createRetryer");var ke=class{static{a(this,"Removable")}#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ie(this.gcTime)&&(this.#e=Q.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(D.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(Q.clearTimeout(this.#e),this.#e=void 0)}};function kt(t){return{onFetch:a((e,r)=>{let s=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,n=e.state.data?.pages||[],o=e.state.data?.pageParams||[],c={pages:[],pageParams:[]},u=0,d=a(async()=>{let h=!1,l=a(y=>{St(y,()=>e.signal,()=>h=!0)},"addSignalProperty"),f=ge(e.options,e.fetchOptions),m=a(async(y,b,w)=>{if(h)return Promise.reject(e.signal.reason);if(b==null&&y.pages.length)return Promise.resolve(y);let M=a(()=>{let De={client:e.client,queryKey:e.queryKey,pageParam:b,direction:w?"backward":"forward",meta:e.options.meta};return l(De),De},"createQueryFnContext")(),U=await f(M),{maxPages:K}=e.options,j=w?gt:vt;return{pages:j(y.pages,U,K),pageParams:j(y.pageParams,b,K)}},"fetchPage");if(i&&n.length){let y=i==="backward",b=y?wr:Ct,w={pages:n,pageParams:o},E=b(s,w);c=await m(w,E,y)}else{let y=t??n.length;do{let b=u===0?o[0]??s.initialPageParam:Ct(s,c);if(u>0&&b==null)break;c=await m(c,b),u++}while(u<y)}return c},"fetchFn");e.options.persister?e.fetchFn=()=>e.options.persister?.(d,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r):e.fetchFn=d},"onFetch")}}a(kt,"infiniteQueryBehavior");function Ct(t,{pages:e,pageParams:r}){let s=e.length-1;return e.length>0?t.getNextPageParam(e[s],e,r[s],r):void 0}a(Ct,"getNextPageParam");function wr(t,{pages:e,pageParams:r}){return e.length>0?t.getPreviousPageParam?.(e[0],e,r[0],r):void 0}a(wr,"getPreviousPageParam");var Tt=class extends ke{static{a(this,"Query")}#e;#t;#r;#s;#n;#i;#o;#a;constructor(t){super(),this.#a=!1,this.#o=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#n=t.client,this.#s=this.#n.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#t=Et(this.options),this.state=t.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#i?.promise}setOptions(t){if(this.options={...this.#o,...t},t?._type&&(this.#e=t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Et(this.options);e.data!==void 0&&(this.setState(It(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#s.remove(this)}setData(t,e){let r=ae(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.#i?.promise;return this.#i?.cancel(t),e?e.then(g).catch(g):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}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===Y||!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:!me(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.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.#i&&(this.#a||this.#h()?this.#i.cancel({revert:!0}):this.#i.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.#i?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(t&&this.setOptions(t),!this.options.queryFn){let u=this.observers.find(d=>d.options.queryFn);u&&this.setOptions(u.options)}let r=new AbortController,s=a(u=>{Object.defineProperty(u,"signal",{enumerable:!0,get:a(()=>(this.#a=!0,r.signal),"get")})},"addSignalProperty"),i=a(()=>{let u=ge(this.options,e),h=a(()=>{let l={client:this.#n,queryKey:this.queryKey,meta:this.meta};return s(l),l},"createQueryFnContext")();return this.#a=!1,this.options.persister?this.options.persister(u,h,this):u(h)},"fetchFn"),o=a(()=>{let u={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#n,state:this.state,fetchFn:i};return s(u),u},"createFetchContext")();(this.#e==="infinite"?kt(this.options.pages):this.options.behavior)?.onFetch(o,this),this.#r=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#c({type:"fetch",meta:o.fetchOptions?.meta}),this.#i=Ce({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:a(u=>{u instanceof we&&u.revert&&this.setState({...this.#r,fetchStatus:"idle"}),r.abort()},"onCancel"),onFail:a((u,d)=>{this.#c({type:"failed",failureCount:u,error:d})},"onFail"),onPause:a(()=>{this.#c({type:"pause"})},"onPause"),onContinue:a(()=>{this.#c({type:"continue"})},"onContinue"),retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:a(()=>!0,"canRun")});try{let u=await this.#i.start();if(u===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(u),this.#s.config.onSuccess?.(u,this),this.#s.config.onSettled?.(u,this.state.error,this),u}catch(u){if(u instanceof we){if(u.silent)return this.#i.promise;if(u.revert){if(this.state.data===void 0)throw u;return this.state.data}}throw this.#c({type:"error",error:u}),this.#s.config.onError?.(u,this),this.#s.config.onSettled?.(this.state.data,u,this),u}finally{this.scheduleGc()}}#c(t){let e=a(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,...je(r.data,this.options),fetchMeta:t.meta??null};case"success":let s={...r,...It(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 i=t.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}},"reducer");this.state=e(this.state),v.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#s.notify({query:this,type:"updated",action:t})})}};function je(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ke(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}a(je,"fetchState");function It(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}a(It,"successState");function Et(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"}}a(Et,"getDefaultState");var He=class extends L{static{a(this,"QueryObserver")}constructor(t,e){super(),this.options=e,this.#e=t,this.#a=null,this.#o=oe(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#r=void 0;#s=void 0;#n;#i;#o;#a;#h;#c;#p;#d;#l;#u;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Ot(this.#t,this.options)?this.#f():this.updateResult(),this.#g())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return $e(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return $e(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#S(),this.#w(),this.#t.removeObserver(this)}setOptions(t){let e=this.options,r=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof I(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#C(),this.#t.setOptions(this.options),e._defaulted&&!ve(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});let s=this.hasListeners();s&&Rt(this.#t,r,this.options,e)&&this.#f(),this.updateResult(),s&&(this.#t!==r||I(this.options.enabled,this.#t)!==I(e.enabled,this.#t)||x(this.options.staleTime,this.#t)!==x(e.staleTime,this.#t))&&this.#y();let i=this.#b();s&&(this.#t!==r||I(this.options.enabled,this.#t)!==I(e.enabled,this.#t)||i!==this.#u)&&this.#v(i)}getOptimisticResult(t){let e=this.#e.getQueryCache().build(this.#e,t),r=this.createResult(e,t);return kr(this,r)&&(this.#s=r,this.#i=this.options,this.#n=this.#t.state),r}getCurrentResult(){return this.#s}trackResult(t,e){return new Proxy(t,{get:a((r,s)=>(this.trackProp(s),e?.(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s)),"get")})}trackProp(t){this.#m.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){let e=this.#e.defaultQueryOptions(t),r=this.#e.getQueryCache().build(this.#e,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.#C();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(g)),e}#y(){this.#S();let t=x(this.options.staleTime,this.#t);if(D.isServer()||this.#s.isStale||!ie(t))return;let r=me(this.#s.dataUpdatedAt,t)+1;this.#d=Q.setTimeout(()=>{this.#s.isStale||this.updateResult()},r)}#b(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(t){this.#w(),this.#u=t,!(D.isServer()||I(this.options.enabled,this.#t)===!1||!ie(this.#u)||this.#u===0)&&(this.#l=Q.setInterval(()=>{(this.options.refetchIntervalInBackground||X.isFocused())&&this.#f()},this.#u))}#g(){this.#y(),this.#v(this.#b())}#S(){this.#d!==void 0&&(Q.clearTimeout(this.#d),this.#d=void 0)}#w(){this.#l!==void 0&&(Q.clearInterval(this.#l),this.#l=void 0)}createResult(t,e){let r=this.#t,s=this.options,i=this.#s,n=this.#n,o=this.#i,u=t!==r?t.state:this.#r,{state:d}=t,h={...d},l=!1,f;if(e._optimisticResults){let R=this.hasListeners(),se=!R&&Ot(t,e),le=R&&Rt(t,r,e,s);(se||le)&&(h={...h,...je(d.data,t.options)}),e._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:m,errorUpdatedAt:y,status:b}=h;f=h.data;let w=!1;if(e.placeholderData!==void 0&&f===void 0&&b==="pending"){let R;i?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(R=i.data,w=!0):R=typeof e.placeholderData=="function"?e.placeholderData(this.#p?.state.data,this.#p):e.placeholderData,R!==void 0&&(b="success",f=ae(i?.data,R,e),l=!0)}if(e.select&&f!==void 0&&!w)if(i&&f===n?.data&&e.select===this.#h)f=this.#c;else try{this.#h=e.select,f=e.select(f),f=ae(i?.data,f,e),this.#c=f,this.#a=null}catch(R){this.#a=R}this.#a&&(m=this.#a,f=this.#c,y=Date.now(),b="error");let E=h.fetchStatus==="fetching",M=b==="pending",U=b==="error",K=M&&E,j=f!==void 0,q={status:b,fetchStatus:h.fetchStatus,isPending:M,isSuccess:b==="success",isError:U,isInitialLoading:K,isLoading:K,data:f,dataUpdatedAt:h.dataUpdatedAt,error:m,errorUpdatedAt:y,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:h.dataUpdateCount>u.dataUpdateCount||h.errorUpdateCount>u.errorUpdateCount,isFetching:E,isRefetching:E&&!M,isLoadingError:U&&!j,isPaused:h.fetchStatus==="paused",isPlaceholderData:l,isRefetchError:U&&j,isStale:ze(t,e),refetch:this.refetch,promise:this.#o,isEnabled:I(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){let R=q.data!==void 0,se=q.status==="error"&&!R,le=a(pe=>{se?pe.reject(q.error):R&&pe.resolve(q.data)},"finalizeThenableIfPossible"),dt=a(()=>{let pe=this.#o=q.promise=oe();le(pe)},"recreateThenable"),fe=this.#o;switch(fe.status){case"pending":t.queryHash===r.queryHash&&le(fe);break;case"fulfilled":(se||q.data!==fe.value)&&dt();break;case"rejected":(!se||q.error!==fe.reason)&&dt();break}}return q}updateResult(){let t=this.#s,e=this.createResult(this.#t,this.options);if(this.#n=this.#t.state,this.#i=this.options,this.#n.data!==void 0&&(this.#p=this.#t),ve(e,t))return;this.#s=e;let r=a(()=>{if(!t)return!0;let{notifyOnChangeProps:s}=this.options,i=typeof s=="function"?s():s;if(i==="all"||!i&&!this.#m.size)return!0;let n=new Set(i??this.#m);return this.options.throwOnError&&n.add("error"),Object.keys(this.#s).some(o=>{let c=o;return this.#s[c]!==t[c]&&n.has(c)})},"shouldNotifyListeners");this.#k({listeners:r()})}#C(){let t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;let e=this.#t;this.#t=t,this.#r=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#g()}#k(t){v.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#s)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function Cr(t,e){return I(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&I(e.retryOnMount,t)===!1)}a(Cr,"shouldLoadOnMount");function Ot(t,e){return Cr(t,e)||t.state.data!==void 0&&$e(t,e,e.refetchOnMount)}a(Ot,"shouldFetchOnMount");function $e(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&&ze(t,e)}return!1}a($e,"shouldFetchOn");function Rt(t,e,r,s){return(t!==e||I(s.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&ze(t,r)}a(Rt,"shouldFetchOptionally");function ze(t,e){return I(e.enabled,t)!==!1&&t.isStaleByTime(x(e.staleTime,t))}a(ze,"isStale");function kr(t,e){return!ve(t.getCurrentResult(),e)}a(kr,"shouldAssignObserverCurrentProperties");var Pt=class extends ke{static{a(this,"Mutation")}#e;#t;#r;#s;constructor(t){super(),this.#e=t.client,this.mutationId=t.mutationId,this.#r=t.mutationCache,this.#t=[],this.state=t.state||Ir(),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.#t.includes(t)||(this.#t.push(t),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#t=this.#t.filter(e=>e!==t),this.scheduleGc(),this.#r.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#t.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=a(()=>{this.#n({type:"continue"})},"onContinue"),r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#s=Ce({fn:a(()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),"fn"),onFail:a((n,o)=>{this.#n({type:"failed",failureCount:n,error:o})},"onFail"),onPause:a(()=>{this.#n({type:"pause"})},"onPause"),onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:a(()=>this.#r.canRun(this),"canRun")});let s=this.state.status==="pending",i=!this.#s.canStart();try{if(s)e();else{this.#n({type:"pending",variables:t,isPaused:i}),this.#r.config.onMutate&&await this.#r.config.onMutate(t,this,r);let o=await this.options.onMutate?.(t,r);o!==this.state.context&&this.#n({type:"pending",context:o,variables:t,isPaused:i})}let n=await this.#s.start();return await this.#r.config.onSuccess?.(n,t,this.state.context,this,r),await this.options.onSuccess?.(n,t,this.state.context,r),await this.#r.config.onSettled?.(n,null,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(n,null,t,this.state.context,r),this.#n({type:"success",data:n}),n}catch(n){try{await this.#r.config.onError?.(n,t,this.state.context,this,r)}catch(o){Promise.reject(o)}try{await this.options.onError?.(n,t,this.state.context,r)}catch(o){Promise.reject(o)}try{await this.#r.config.onSettled?.(void 0,n,this.state.variables,this.state.context,this,r)}catch(o){Promise.reject(o)}try{await this.options.onSettled?.(void 0,n,t,this.state.context,r)}catch(o){Promise.reject(o)}throw this.#n({type:"error",error:n}),n}finally{this.#r.runNext(this)}}#n(t){let e=a(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),v.batch(()=>{this.#t.forEach(r=>{r.onMutationUpdate(t)}),this.#r.notify({mutation:this,type:"updated",action:t})})}};function Ir(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}a(Ir,"getDefaultState");var At=class extends L{static{a(this,"MutationCache")}constructor(t={}){super(),this.config=t,this.#e=new Set,this.#t=new Map,this.#r=0}#e;#t;#r;build(t,e,r){let s=new Pt({client:t,mutationCache:this,mutationId:++this.#r,options:t.defaultMutationOptions(e),state:r});return this.add(s),s}add(t){this.#e.add(t);let e=Ie(t);if(typeof e=="string"){let r=this.#t.get(e);r?r.push(t):this.#t.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#e.delete(t)){let e=Ie(t);if(typeof e=="string"){let r=this.#t.get(e);if(r)if(r.length>1){let s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&this.#t.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){let e=Ie(t);if(typeof e=="string"){let s=this.#t.get(e)?.find(i=>i.state.status==="pending");return!s||s===t}else return!0}runNext(t){let e=Ie(t);return typeof e=="string"?this.#t.get(e)?.find(s=>s!==t&&s.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){v.batch(()=>{this.#e.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(t){let e={exact:!0,...t};return this.getAll().find(r=>be(e,r))}findAll(t={}){return this.getAll().filter(e=>be(t,e))}notify(t){v.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){let t=this.getAll().filter(e=>e.state.isPaused);return v.batch(()=>Promise.all(t.map(e=>e.continue().catch(g))))}};function Ie(t){return t.options.scope?.id}a(Ie,"scopeFor");var Ft=class extends L{static{a(this,"QueryCache")}constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,r){let s=e.queryKey,i=e.queryHash??ne(s,e),n=this.get(i);return n||(n=new Tt({client:t,queryKey:s,queryHash:i,options:t.defaultQueryOptions(e),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(n)),n}add(t){this.#e.has(t.queryHash)||(this.#e.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){let e=this.#e.get(t.queryHash);e&&(t.destroy(),e===t&&this.#e.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){v.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#e.get(t)}getAll(){return[...this.#e.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){v.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){v.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){v.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}};var We=class{static{a(this,"QueryClient")}#e;#t;#r;#s;#n;#i;#o;#a;constructor(t={}){this.#e=t.queryCache||new Ft,this.#t=t.mutationCache||new At,this.#r=t.defaultOptions||{},this.#s=new Map,this.#n=new Map,this.#i=0}mount(){this.#i++,this.#i===1&&(this.#o=X.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=Z.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#i--,this.#i===0&&(this.#o?.(),this.#o=void 0,this.#a?.(),this.#a=void 0)}isFetching(t){return this.#e.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#t.findAll({...t,status:"pending"}).length}getQueryData(t){let e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state.data}ensureQueryData(t){let e=this.defaultQueryOptions(t),r=this.#e.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.#e.findAll(t).map(({queryKey:e,state:r})=>{let s=r.data;return[e,s]})}setQueryData(t,e,r){let s=this.defaultQueryOptions({queryKey:t}),n=this.#e.get(s.queryHash)?.state.data,o=yt(e,n);if(o!==void 0)return this.#e.build(this,s).setData(o,{...r,manual:!0})}setQueriesData(t,e,r){return v.batch(()=>this.#e.findAll(t).map(({queryKey:s})=>[s,this.setQueryData(s,e,r)]))}getQueryState(t){let e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state}removeQueries(t){let e=this.#e;v.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){let r=this.#e;return v.batch(()=>(r.findAll(t).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){let r={revert:!0,...e},s=v.batch(()=>this.#e.findAll(t).map(i=>i.cancel(r)));return Promise.all(s).then(g).catch(g)}invalidateQueries(t,e={}){return v.batch(()=>(this.#e.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=v.batch(()=>this.#e.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let n=i.fetch(void 0,r);return r.throwOnError||(n=n.catch(g)),i.state.fetchStatus==="paused"?Promise.resolve():n}));return Promise.all(s).then(g)}fetchQuery(t){let e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);let r=this.#e.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(g).catch(g)}fetchInfiniteQuery(t){return t._type="infinite",this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(g).catch(g)}ensureInfiniteQueryData(t){return t._type="infinite",this.ensureQueryData(t)}resumePausedMutations(){return Z.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(t){this.#r=t}setQueryDefaults(t,e){this.#s.set(H(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){let e=[...this.#s.values()],r={};return e.forEach(s=>{N(t,s.queryKey)&&Object.assign(r,s.defaultOptions)}),r}setMutationDefaults(t,e){this.#n.set(H(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){let e=[...this.#n.values()],r={};return e.forEach(s=>{N(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=ne(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===Y&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#r.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};var B=P($(),1);var ee=P($(),1),Mt=P(Ue(),1);var ce=ee.createContext(void 0),Ve=a(t=>{let e=ee.useContext(ce);if(t)return t;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},"useQueryClient"),Ge=a(({client:t,children:e})=>(ee.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),(0,Mt.jsx)(ce.Provider,{value:t,children:e})),"QueryClientProvider");var ue=P($(),1),Er=P(Ue(),1);function Tr(){let t=!1;return{clearReset:a(()=>{t=!1},"clearReset"),reset:a(()=>{t=!0},"reset"),isReset:a(()=>t,"isReset")}}a(Tr,"createValue");var Or=ue.createContext(Tr()),xt=a(()=>ue.useContext(Or),"useQueryErrorResetBoundary");var _t=P($(),1);var Lt=a((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"),Qt=a(t=>{_t.useEffect(()=>{t.clearReset()},[t])},"useClearResetErrorBoundary"),Dt=a(({result:t,errorResetBoundary:e,throwOnError:r,query:s,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&s&&(i&&t.data===void 0||Se(r,[t.error,s])),"getHasError");var Ee=P($(),1);var Ut=Ee.createContext(!1),qt=a(()=>Ee.useContext(Ut),"useIsRestoring"),Ra=Ut.Provider;var Nt=a(t=>{if(t.suspense){let r=a(i=>i==="static"?i:Math.max(i??1e3,1e3),"clamp"),s=t.staleTime;t.staleTime=typeof s=="function"?(...i)=>r(s(...i)):r(s),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},"ensureSuspenseTimers"),Bt=a((t,e)=>t.isLoading&&t.isFetching&&!e,"willFetch"),Kt=a((t,e)=>t?.suspense&&e.isPending,"shouldSuspend"),Je=a((t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()}),"fetchOptimistic");function jt(t,e,r){let s=qt(),i=xt(),n=Ve(r),o=n.defaultQueryOptions(t);n.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let c=n.getQueryCache().get(o.queryHash),u=t.subscribed!==!1;o._optimisticResults=s?"isRestoring":u?"optimistic":void 0,Nt(o),Lt(o,i,c),Qt(i);let d=!n.getQueryCache().get(o.queryHash),[h]=B.useState(()=>new e(n,o)),l=h.getOptimisticResult(o),f=!s&&u;if(B.useSyncExternalStore(B.useCallback(m=>{let y=f?h.subscribe(v.batchCalls(m)):g;return h.updateResult(),y},[h,f]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),B.useEffect(()=>{h.setOptions(o)},[o,h]),Kt(o,l))throw Je(o,h,i);if(Dt({result:l,errorResetBoundary:i,throwOnError:o.throwOnError,query:c,suspense:o.suspense}))throw l.error;return n.getDefaultOptions().queries?._experimental_afterQuery?.(o,l),o.experimental_prefetchInRender&&!D.isServer()&&Bt(l,s)&&(d?Je(o,h,i):c?.promise)?.catch(g).finally(()=>{h.updateResult()}),o.notifyOnChangeProps?l:h.trackResult(l)}a(jt,"useBaseQuery");function Rr(t,e){return jt(t,He,e)}a(Rr,"useQuery");var $t=P(lt(),1);var z=P($(),1),Xe=P(Ue(),1);var Ht=(0,z.createContext)(null),Pr=a(()=>new We({defaultOptions:{mutations:{retry:0},queries:{gcTime:5*6e4,retry:0,staleTime:Number.POSITIVE_INFINITY}}}),"v"),Ar=a(t=>{let e=(0,$t.c)(9),{children:r,client:s,queryClient:i}=t,n=(0,z.use)(ce),o;e[0]!==n||e[1]!==i?(o=a(()=>i??n??Pr(),"o"),e[0]=n,e[1]=i,e[2]=o):o=e[2];let[c]=(0,z.useState)(o),u=i??n??c,d;e[3]!==r||e[4]!==s?(d=(0,Xe.jsx)(Ht,{value:s,children:r}),e[3]=r,e[4]=s,e[5]=d):d=e[5];let h=d;if(n===u)return h;let l;return e[6]!==h||e[7]!==u?(l=(0,Xe.jsx)(Ge,{client:u,children:h}),e[6]=h,e[7]=u,e[8]=l):l=e[8],l},"b"),Ye=a(()=>{let t=(0,z.use)(Ht);if(!t)throw new p("INTERNAL","useLunora must be used inside <LunoraProvider />");return t},"q");var zt=a(()=>{let t=null;return{get:a(()=>t,"get"),set:a(e=>{t=e},"set")}},"l");var Te=class{static{a(this,"u")}values=new Map;subscribers=new Map;get(e){return this.values.has(e.key)?this.values.get(e.key):e.defaultValue}set(e,r){if(r===void 0){this.reset(e);return}this.values.set(e.key,r),this.notify(e.key,r)}reset(e){this.values.delete(e.key),this.notify(e.key,e.defaultValue)}subscribe(e,r){let s=this.subscribers.get(e.key);return s||(s=new Set,this.subscribers.set(e.key,s)),s.add(r),()=>{s.delete(r),s.size===0&&this.subscribers.delete(e.key)}}notify(e,r){let s=this.subscribers.get(e);if(s)for(let i of s)try{i(r)}catch{}}};var Wt=0,Fr="lunora-bridge",Mr=1e3,xr=3e3,Oe=class{static{a(this,"c")}bc;tabId;heartbeatInterval;leaderTimeout;knownLeader=void 0;leader=!1;running=!1;promotionPending=!1;lastHeartbeat=0;heartbeatTimer=void 0;leaderCheckTimer=void 0;onBecomeLeader;onStopBeingLeader;onConnectionStatus;onSubscriptionData;onSubscriptionError;onSubscriptionSettled;constructor(e={}){if(Wt+=1,this.tabId=`tab_${String(Wt)}_${crypto.randomUUID()}`,this.heartbeatInterval=e.heartbeatInterval??Mr,this.leaderTimeout=e.leaderTimeout??xr,this.onBecomeLeader=e.onBecomeLeader,this.onStopBeingLeader=e.onStopBeingLeader,this.onConnectionStatus=e.onConnectionStatus,this.onSubscriptionData=e.onSubscriptionData,this.onSubscriptionError=e.onSubscriptionError,this.onSubscriptionSettled=e.onSubscriptionSettled,typeof BroadcastChannel>"u"){this.bc=void 0;return}this.bc=new BroadcastChannel(e.channelName??Fr),this.bc.addEventListener("message",r=>{this.handleMessage(r.data)})}start(){if(!this.running){if(this.running=!0,this.bc===void 0){this.becomeLeader();return}this.broadcast({type:"claim-leadership",tabId:this.tabId,ts:Date.now()}),setTimeout(()=>{this.running&&this.knownLeader===void 0&&this.becomeLeader()},this.leaderTimeout),this.leaderCheckTimer=setInterval(()=>{this.checkLeaderHealth()},this.leaderTimeout),this.heartbeatTimer=setInterval(()=>{this.sendHeartbeat()},this.heartbeatInterval)}}stop(){this.running=!1,this.leader&&(this.broadcast({type:"yield-leadership",tabId:this.tabId}),this.leader=!1,this.knownLeader=void 0,this.onStopBeingLeader?.()),this.heartbeatTimer!==void 0&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0),this.leaderCheckTimer!==void 0&&(clearInterval(this.leaderCheckTimer),this.leaderCheckTimer=void 0),this.bc?.close()}isLeader(){return this.leader}promoteImmediately(){this.running&&this.becomeLeader()}get leaderTabId(){return this.knownLeader}get id(){return this.tabId}get isRunning(){return this.running}broadcastSubscriptionData(e,r,s,i,n){this.leader&&this.broadcast({type:"subscription-data",tabId:this.tabId,key:e,data:r,...s===void 0?{}:{cursor:s},...i===void 0?{}:{epoch:i},...n===void 0?{}:{identity:n}})}broadcastSubscriptionError(e,r){this.leader&&this.broadcast({type:"subscription-error",tabId:this.tabId,key:e,error:r})}broadcastSubscriptionSettled(e,r,s,i,n,o){this.leader&&this.broadcast({type:"subscription-settled",tabId:this.tabId,key:e,...r===void 0?{}:{cursor:r},...s===void 0?{}:{epoch:s},...i===void 0?{}:{lastMutationId:i},...n===void 0?{}:{clientId:n},...o===void 0?{}:{identity:o}})}broadcastConnectionStatus(e,r){this.leader&&this.broadcast({type:"connection-status",tabId:this.tabId,status:e,...r===void 0?{}:{identity:r}})}broadcast(e){this.bc?.postMessage(e)}handleMessage(e){switch(e.type){case"claim-leadership":{this.handleClaimLeadership(e);break}case"connection-status":{if(this.leader||e.tabId===this.tabId)break;this.onConnectionStatus?.(e.status,e.identity);break}case"heartbeat":{this.handleHeartbeat(e);break}case"subscription-data":{if(this.leader||e.tabId===this.tabId)break;this.onSubscriptionData?.(e.key,e.data,e.cursor,e.epoch,e.identity);break}case"subscription-error":{if(this.leader||e.tabId===this.tabId)break;this.onSubscriptionError?.(e.key,e.error);break}case"subscription-settled":{if(this.leader||e.tabId===this.tabId)break;this.onSubscriptionSettled?.(e.key,e.cursor,e.epoch,e.lastMutationId,e.clientId,e.identity);break}case"yield-leadership":{this.knownLeader===e.tabId&&(this.knownLeader=void 0,this.running&&!this.leader&&this.claimAndPromote());break}}}handleClaimLeadership(e){if(e.tabId!==this.tabId){if(this.leader){this.broadcast({type:"heartbeat",tabId:this.tabId,ts:Date.now()});return}this.knownLeader===void 0&&e.tabId<this.tabId&&(this.knownLeader=e.tabId,this.lastHeartbeat=e.ts)}}handleHeartbeat(e){if(e.tabId!==this.tabId){if(this.leader){this.resolveLeaderVsLeaderTieBreak(e);return}this.lastHeartbeat=e.ts,this.knownLeader=e.tabId}}resolveLeaderVsLeaderTieBreak(e){e.tabId<this.tabId?(this.leader=!1,this.knownLeader=e.tabId,this.lastHeartbeat=e.ts,this.onStopBeingLeader?.()):this.broadcast({type:"heartbeat",tabId:this.tabId,ts:Date.now()})}becomeLeader(){this.leader||(this.leader=!0,this.knownLeader=this.tabId,this.lastHeartbeat=Date.now(),this.onBecomeLeader?.(),this.broadcast({type:"heartbeat",tabId:this.tabId,ts:Date.now()}))}sendHeartbeat(){this.leader&&this.broadcast({type:"heartbeat",tabId:this.tabId,ts:Date.now()})}checkLeaderHealth(){if(!(!this.running||this.leader)){if(this.knownLeader===void 0){this.claimAndPromote();return}Date.now()-this.lastHeartbeat>this.leaderTimeout&&(this.knownLeader=void 0,this.claimAndPromote())}}claimAndPromote(){this.promotionPending||(this.promotionPending=!0,this.broadcast({type:"claim-leadership",tabId:this.tabId,ts:Date.now()}),setTimeout(()=>{this.promotionPending=!1,this.running&&this.knownLeader===void 0&&this.becomeLeader()},this.leaderTimeout))}};var Ze="_creationTime",_r=a(t=>{if(typeof t!="object"||t===null)return;let e=t._id;return typeof e=="string"?e:void 0},"p"),Lr=a(t=>{let e;for(let r of t){let s=r[Ze];if(typeof s=="number"){if(e!==void 0){if(s<e)return!0;if(s>e)return!1}e=s}}return!1},"a"),Qr=a((t,e)=>{let r=e[Ze];if(typeof r!="number")return t.length;let s=Lr(t);for(let[i,n]of t.entries()){let o=n[Ze];if(typeof o=="number"&&(s?o<r:o>r))return i}return t.length},"d"),Vt=a(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")},"y"),Gt=a((t,e)=>{if(!Array.isArray(t))return;let r=[];for(let u of t){if(_r(u)===void 0)return;r.push(u)}let{key:s,op:i,row:n}=e;if(i==="delete"){let u=r.filter(d=>d._id!==s);return u.length===r.length?[...r]:u}if(n===void 0)return;let o=r.findIndex(u=>u._id===s);if(o===-1){let u=[...r];return u.splice(Qr(r,n),0,n),u}let c=[...r];return c[o]=n,c},"g");var Dr=1024,Re=a(t=>{let e=t.maxBuffer??Dr,r=[],s=[],i=!1,n,o=!1,c=a(()=>{let h=s.shift();if(!h)return!1;if(n)return h.reject(n),!0;if(r.length>0){let l=r.shift();return h.resolve({done:!1,value:l}),!0}return i?(h.resolve({done:!0,value:void 0}),!0):(s.unshift(h),!1)},"n"),u={complete(){if(!(i||n))for(i=!0;c(););},fail(h){if(!(i||n))for(n=h,r.length=0;c(););},push(h){if(!(i||n||o)){if(r.length>=e){u.fail(new p("STREAM_BACKPRESSURE",`stream buffer overflow (max=${e.toString()}); the consumer cannot keep up with the producer`));return}r.push(h),c()}}},d=a(()=>{if(!o){o=!0,i=!0,r.length=0;try{t.onCancel()}catch{}for(;c(););}},"c");return{handle:u,iterable:{cancel:d,[Symbol.asyncIterator](){return{next(){if(n)return Promise.reject(n);if(r.length>0){let h=r.shift();return Promise.resolve({done:!1,value:h})}return i?Promise.resolve({done:!0,value:void 0}):new Promise((h,l)=>{s.push({reject:l,resolve:h})})},return(){return d(),Promise.resolve({done:!0,value:void 0})}}}}}},"d");var Jt=/^ /u,Xt=a(t=>typeof t=="object"&&t!==null?JSON.stringify(t):String(t),"u"),Ur=a(t=>{let e="",r=[];for(let s of t.split(`
|
|
1
|
+
import{c as p}from"./chunk-P33WK7YI.js";import{a,e as P,f as $,g as lt,h as Ue}from"./chunk-3XIESWL4.js";var L=class{static{a(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 fr=class extends L{static{a(this,"FocusManager")}#e;#t;#r;constructor(){super(),this.#r=t=>{if(typeof window<"u"&&window.addEventListener){let e=a(()=>t(),"listener");return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#r=t,this.#t?.(),this.#t=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#e!==t&&(this.#e=t,this.onFocus())}onFocus(){let t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},X=new fr;var pr={setTimeout:a((t,e)=>setTimeout(t,e),"setTimeout"),clearTimeout:a(t=>clearTimeout(t),"clearTimeout"),setInterval:a((t,e)=>setInterval(t,e),"setInterval"),clearInterval:a(t=>clearInterval(t),"clearInterval")},mr=class{static{a(this,"TimeoutManager")}#e=pr;#t=!1;setTimeoutProvider(t){this.#e=t}setTimeout(t,e){return this.#e.setTimeout(t,e)}clearTimeout(t){this.#e.clearTimeout(t)}setInterval(t,e){return this.#e.setInterval(t,e)}clearInterval(t){this.#e.clearInterval(t)}},Q=new mr;function ft(t){setTimeout(t,0)}a(ft,"systemSetTimeoutZero");var Ne=typeof window>"u"||"Deno"in globalThis;function g(){}a(g,"noop");function yt(t,e){return typeof t=="function"?t(e):t}a(yt,"functionalUpdate");function ie(t){return typeof t=="number"&&t>=0&&t!==1/0}a(ie,"isValidTimeout");function me(t,e){return Math.max(t+(e||0)-Date.now(),0)}a(me,"timeUntilStale");function x(t,e){return typeof t=="function"?t(e):t}a(x,"resolveStaleTime");function I(t,e){return typeof t=="function"?t(e):t}a(I,"resolveQueryBoolean");function ye(t,e){let{type:r="all",exact:s,fetchStatus:i,predicate:n,queryKey:o,stale:c}=t;if(o){if(s){if(e.queryHash!==ne(o,e.options))return!1}else if(!N(e.queryKey,o))return!1}if(r!=="all"){let u=e.isActive();if(r==="active"&&!u||r==="inactive"&&u)return!1}return!(typeof c=="boolean"&&e.isStale()!==c||i&&i!==e.state.fetchStatus||n&&!n(e))}a(ye,"matchQuery");function be(t,e){let{exact:r,status:s,predicate:i,mutationKey:n}=t;if(n){if(!e.options.mutationKey)return!1;if(r){if(H(e.options.mutationKey)!==H(n))return!1}else if(!N(e.options.mutationKey,n))return!1}return!(s&&e.state.status!==s||i&&!i(e))}a(be,"matchMutation");function ne(t,e){return(e?.queryKeyHashFn||H)(t)}a(ne,"hashQueryKeyByOptions");function H(t){return JSON.stringify(t,(e,r)=>qe(r)?Object.keys(r).sort().reduce((s,i)=>(s[i]=r[i],s),{}):r)}a(H,"hashKey");function N(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(t&&e&&typeof t=="object"&&typeof e=="object"){if(Array.isArray(t)&&Array.isArray(e)){for(let s=0;s<e.length;s++)if(!N(t[s],e[s]))return!1;return!0}let r=Object.keys(e);for(let s of r)if(!N(t[s],e[s]))return!1;return!0}return!1}a(N,"partialMatchKey");var yr=Object.prototype.hasOwnProperty;function Be(t,e,r=0){if(t===e)return t;if(r>500)return e;let s=pt(t)&&pt(e);if(!s&&!(qe(t)&&qe(e)))return e;let n=(s?t:Object.keys(t)).length,o=s?e:Object.keys(e),c=o.length,u=s?new Array(c):{},d=0;for(let h=0;h<c;h++){let l=s?h:o[h],f=t[l],m=e[l];if(f===m){u[l]=f,(s?h<n:yr.call(t,l))&&d++;continue}if(f===null||m===null||typeof f!="object"||typeof m!="object"){u[l]=m;continue}let y=Be(f,m,r+1);u[l]=y,y===f&&d++}return n===c&&d===n?t:u}a(Be,"replaceEqualDeep");function ve(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}a(ve,"shallowEqualObjects");function pt(t){return Array.isArray(t)&&t.length===Object.keys(t).length}a(pt,"isPlainArray");function qe(t){if(!mt(t))return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(!mt(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}a(qe,"isPlainObject");function mt(t){return Object.prototype.toString.call(t)==="[object Object]"}a(mt,"hasObjectPrototype");function bt(t){return new Promise(e=>{Q.setTimeout(e,t)})}a(bt,"sleep");function ae(t,e,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,e):r.structuralSharing!==!1?Be(t,e):e}a(ae,"replaceData");function br(t){return t}a(br,"keepPreviousData");function vt(t,e,r=0){let s=[...t,e];return r&&s.length>r?s.slice(1):s}a(vt,"addToEnd");function gt(t,e,r=0){let s=[e,...t];return r&&s.length>r?s.slice(0,-1):s}a(gt,"addToStart");var Y=Symbol();function ge(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===Y?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}a(ge,"ensureQueryFn");function Se(t,e){return typeof t=="function"?t(...e):!!t}a(Se,"shouldThrowError");function St(t,e,r){let s=!1,i;return Object.defineProperty(t,"signal",{enumerable:!0,get:a(()=>(i??=e(),s||(s=!0,i.aborted?r():i.addEventListener("abort",r,{once:!0})),i),"get")}),t}a(St,"addConsumeAwareSignal");var D=(()=>{let t=a(()=>Ne,"isServerFn");return{isServer(){return t()},setIsServer(e){t=e}}})();function oe(){let t,e,r=new Promise((i,n)=>{t=i,e=n});r.status="pending",r.catch(()=>{});function s(i){Object.assign(r,i),delete r.resolve,delete r.reject}return a(s,"finalize"),r.resolve=i=>{s({status:"fulfilled",value:i}),t(i)},r.reject=i=>{s({status:"rejected",reason:i}),e(i)},r}a(oe,"pendingThenable");var wt=ft;function vr(){let t=[],e=0,r=a(c=>{c()},"notifyFn"),s=a(c=>{c()},"batchNotifyFn"),i=wt,n=a(c=>{e?t.push(c):i(()=>{r(c)})},"schedule"),o=a(()=>{let c=t;t=[],c.length&&i(()=>{s(()=>{c.forEach(u=>{r(u)})})})},"flush");return{batch:a(c=>{let u;e++;try{u=c()}finally{e--,e||o()}return u},"batch"),batchCalls:a(c=>(...u)=>{n(()=>{c(...u)})},"batchCalls"),schedule:n,setNotifyFunction:a(c=>{r=c},"setNotifyFunction"),setBatchNotifyFunction:a(c=>{s=c},"setBatchNotifyFunction"),setScheduler:a(c=>{i=c},"setScheduler")}}a(vr,"createNotifyManager");var v=vr();var gr=class extends L{static{a(this,"OnlineManager")}#e=!0;#t;#r;constructor(){super(),this.#r=t=>{if(typeof window<"u"&&window.addEventListener){let e=a(()=>t(!0),"onlineListener"),r=a(()=>t(!1),"offlineListener");return window.addEventListener("online",e,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#r=t,this.#t?.(),this.#t=t(this.setOnline.bind(this))}setOnline(t){this.#e!==t&&(this.#e=t,this.listeners.forEach(r=>{r(t)}))}isOnline(){return this.#e}},Z=new gr;function Sr(t){return Math.min(1e3*2**t,3e4)}a(Sr,"defaultRetryDelay");function Ke(t){return(t??"online")==="online"?Z.isOnline():!0}a(Ke,"canFetch");var we=class extends Error{static{a(this,"CancelledError")}constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function Ce(t){let e=!1,r=0,s,i=oe(),n=a(()=>i.status!=="pending","isResolved"),o=a(b=>{if(!n()){let w=new we(b);f(w),t.onCancel?.(w)}},"cancel"),c=a(()=>{e=!0},"cancelRetry"),u=a(()=>{e=!1},"continueRetry"),d=a(()=>X.isFocused()&&(t.networkMode==="always"||Z.isOnline())&&t.canRun(),"canContinue"),h=a(()=>Ke(t.networkMode)&&t.canRun(),"canStart"),l=a(b=>{n()||(s?.(),i.resolve(b))},"resolve"),f=a(b=>{n()||(s?.(),i.reject(b))},"reject"),m=a(()=>new Promise(b=>{s=a(w=>{(n()||d())&&b(w)},"continueFn"),t.onPause?.()}).then(()=>{s=void 0,n()||t.onContinue?.()}),"pause"),y=a(()=>{if(n())return;let b,w=r===0?t.initialPromise:void 0;try{b=w??t.fn()}catch(E){b=Promise.reject(E)}Promise.resolve(b).then(l).catch(E=>{if(n())return;let M=t.retry??(D.isServer()?0:3),U=t.retryDelay??Sr,K=typeof U=="function"?U(r,E):U,j=M===!0||typeof M=="number"&&r<M||typeof M=="function"&&M(r,E);if(e||!j){f(E);return}r++,t.onFail?.(r,E),bt(K).then(()=>d()?void 0:m()).then(()=>{e?f(E):y()})})},"run");return{promise:i,status:a(()=>i.status,"status"),cancel:o,continue:a(()=>(s?.(),i),"continue"),cancelRetry:c,continueRetry:u,canStart:h,start:a(()=>(h()?y():m().then(y),i),"start")}}a(Ce,"createRetryer");var ke=class{static{a(this,"Removable")}#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ie(this.gcTime)&&(this.#e=Q.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(D.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(Q.clearTimeout(this.#e),this.#e=void 0)}};function kt(t){return{onFetch:a((e,r)=>{let s=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,n=e.state.data?.pages||[],o=e.state.data?.pageParams||[],c={pages:[],pageParams:[]},u=0,d=a(async()=>{let h=!1,l=a(y=>{St(y,()=>e.signal,()=>h=!0)},"addSignalProperty"),f=ge(e.options,e.fetchOptions),m=a(async(y,b,w)=>{if(h)return Promise.reject(e.signal.reason);if(b==null&&y.pages.length)return Promise.resolve(y);let M=a(()=>{let De={client:e.client,queryKey:e.queryKey,pageParam:b,direction:w?"backward":"forward",meta:e.options.meta};return l(De),De},"createQueryFnContext")(),U=await f(M),{maxPages:K}=e.options,j=w?gt:vt;return{pages:j(y.pages,U,K),pageParams:j(y.pageParams,b,K)}},"fetchPage");if(i&&n.length){let y=i==="backward",b=y?wr:Ct,w={pages:n,pageParams:o},E=b(s,w);c=await m(w,E,y)}else{let y=t??n.length;do{let b=u===0?o[0]??s.initialPageParam:Ct(s,c);if(u>0&&b==null)break;c=await m(c,b),u++}while(u<y)}return c},"fetchFn");e.options.persister?e.fetchFn=()=>e.options.persister?.(d,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r):e.fetchFn=d},"onFetch")}}a(kt,"infiniteQueryBehavior");function Ct(t,{pages:e,pageParams:r}){let s=e.length-1;return e.length>0?t.getNextPageParam(e[s],e,r[s],r):void 0}a(Ct,"getNextPageParam");function wr(t,{pages:e,pageParams:r}){return e.length>0?t.getPreviousPageParam?.(e[0],e,r[0],r):void 0}a(wr,"getPreviousPageParam");var Tt=class extends ke{static{a(this,"Query")}#e;#t;#r;#s;#n;#i;#o;#a;constructor(t){super(),this.#a=!1,this.#o=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#n=t.client,this.#s=this.#n.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#t=Et(this.options),this.state=t.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#i?.promise}setOptions(t){if(this.options={...this.#o,...t},t?._type&&(this.#e=t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Et(this.options);e.data!==void 0&&(this.setState(It(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#s.remove(this)}setData(t,e){let r=ae(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.#i?.promise;return this.#i?.cancel(t),e?e.then(g).catch(g):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}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===Y||!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:!me(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.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.#i&&(this.#a||this.#h()?this.#i.cancel({revert:!0}):this.#i.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.#i?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(t&&this.setOptions(t),!this.options.queryFn){let u=this.observers.find(d=>d.options.queryFn);u&&this.setOptions(u.options)}let r=new AbortController,s=a(u=>{Object.defineProperty(u,"signal",{enumerable:!0,get:a(()=>(this.#a=!0,r.signal),"get")})},"addSignalProperty"),i=a(()=>{let u=ge(this.options,e),h=a(()=>{let l={client:this.#n,queryKey:this.queryKey,meta:this.meta};return s(l),l},"createQueryFnContext")();return this.#a=!1,this.options.persister?this.options.persister(u,h,this):u(h)},"fetchFn"),o=a(()=>{let u={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#n,state:this.state,fetchFn:i};return s(u),u},"createFetchContext")();(this.#e==="infinite"?kt(this.options.pages):this.options.behavior)?.onFetch(o,this),this.#r=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#c({type:"fetch",meta:o.fetchOptions?.meta}),this.#i=Ce({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:a(u=>{u instanceof we&&u.revert&&this.setState({...this.#r,fetchStatus:"idle"}),r.abort()},"onCancel"),onFail:a((u,d)=>{this.#c({type:"failed",failureCount:u,error:d})},"onFail"),onPause:a(()=>{this.#c({type:"pause"})},"onPause"),onContinue:a(()=>{this.#c({type:"continue"})},"onContinue"),retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:a(()=>!0,"canRun")});try{let u=await this.#i.start();if(u===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(u),this.#s.config.onSuccess?.(u,this),this.#s.config.onSettled?.(u,this.state.error,this),u}catch(u){if(u instanceof we){if(u.silent)return this.#i.promise;if(u.revert){if(this.state.data===void 0)throw u;return this.state.data}}throw this.#c({type:"error",error:u}),this.#s.config.onError?.(u,this),this.#s.config.onSettled?.(this.state.data,u,this),u}finally{this.scheduleGc()}}#c(t){let e=a(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,...je(r.data,this.options),fetchMeta:t.meta??null};case"success":let s={...r,...It(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 i=t.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}},"reducer");this.state=e(this.state),v.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#s.notify({query:this,type:"updated",action:t})})}};function je(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ke(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}a(je,"fetchState");function It(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}a(It,"successState");function Et(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"}}a(Et,"getDefaultState");var He=class extends L{static{a(this,"QueryObserver")}constructor(t,e){super(),this.options=e,this.#e=t,this.#a=null,this.#o=oe(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#r=void 0;#s=void 0;#n;#i;#o;#a;#h;#c;#p;#d;#l;#u;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Ot(this.#t,this.options)?this.#f():this.updateResult(),this.#g())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return $e(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return $e(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#S(),this.#w(),this.#t.removeObserver(this)}setOptions(t){let e=this.options,r=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof I(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#C(),this.#t.setOptions(this.options),e._defaulted&&!ve(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});let s=this.hasListeners();s&&Rt(this.#t,r,this.options,e)&&this.#f(),this.updateResult(),s&&(this.#t!==r||I(this.options.enabled,this.#t)!==I(e.enabled,this.#t)||x(this.options.staleTime,this.#t)!==x(e.staleTime,this.#t))&&this.#y();let i=this.#b();s&&(this.#t!==r||I(this.options.enabled,this.#t)!==I(e.enabled,this.#t)||i!==this.#u)&&this.#v(i)}getOptimisticResult(t){let e=this.#e.getQueryCache().build(this.#e,t),r=this.createResult(e,t);return kr(this,r)&&(this.#s=r,this.#i=this.options,this.#n=this.#t.state),r}getCurrentResult(){return this.#s}trackResult(t,e){return new Proxy(t,{get:a((r,s)=>(this.trackProp(s),e?.(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s)),"get")})}trackProp(t){this.#m.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){let e=this.#e.defaultQueryOptions(t),r=this.#e.getQueryCache().build(this.#e,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.#C();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(g)),e}#y(){this.#S();let t=x(this.options.staleTime,this.#t);if(D.isServer()||this.#s.isStale||!ie(t))return;let r=me(this.#s.dataUpdatedAt,t)+1;this.#d=Q.setTimeout(()=>{this.#s.isStale||this.updateResult()},r)}#b(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(t){this.#w(),this.#u=t,!(D.isServer()||I(this.options.enabled,this.#t)===!1||!ie(this.#u)||this.#u===0)&&(this.#l=Q.setInterval(()=>{(this.options.refetchIntervalInBackground||X.isFocused())&&this.#f()},this.#u))}#g(){this.#y(),this.#v(this.#b())}#S(){this.#d!==void 0&&(Q.clearTimeout(this.#d),this.#d=void 0)}#w(){this.#l!==void 0&&(Q.clearInterval(this.#l),this.#l=void 0)}createResult(t,e){let r=this.#t,s=this.options,i=this.#s,n=this.#n,o=this.#i,u=t!==r?t.state:this.#r,{state:d}=t,h={...d},l=!1,f;if(e._optimisticResults){let R=this.hasListeners(),se=!R&&Ot(t,e),le=R&&Rt(t,r,e,s);(se||le)&&(h={...h,...je(d.data,t.options)}),e._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:m,errorUpdatedAt:y,status:b}=h;f=h.data;let w=!1;if(e.placeholderData!==void 0&&f===void 0&&b==="pending"){let R;i?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(R=i.data,w=!0):R=typeof e.placeholderData=="function"?e.placeholderData(this.#p?.state.data,this.#p):e.placeholderData,R!==void 0&&(b="success",f=ae(i?.data,R,e),l=!0)}if(e.select&&f!==void 0&&!w)if(i&&f===n?.data&&e.select===this.#h)f=this.#c;else try{this.#h=e.select,f=e.select(f),f=ae(i?.data,f,e),this.#c=f,this.#a=null}catch(R){this.#a=R}this.#a&&(m=this.#a,f=this.#c,y=Date.now(),b="error");let E=h.fetchStatus==="fetching",M=b==="pending",U=b==="error",K=M&&E,j=f!==void 0,q={status:b,fetchStatus:h.fetchStatus,isPending:M,isSuccess:b==="success",isError:U,isInitialLoading:K,isLoading:K,data:f,dataUpdatedAt:h.dataUpdatedAt,error:m,errorUpdatedAt:y,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:h.dataUpdateCount>u.dataUpdateCount||h.errorUpdateCount>u.errorUpdateCount,isFetching:E,isRefetching:E&&!M,isLoadingError:U&&!j,isPaused:h.fetchStatus==="paused",isPlaceholderData:l,isRefetchError:U&&j,isStale:ze(t,e),refetch:this.refetch,promise:this.#o,isEnabled:I(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){let R=q.data!==void 0,se=q.status==="error"&&!R,le=a(pe=>{se?pe.reject(q.error):R&&pe.resolve(q.data)},"finalizeThenableIfPossible"),dt=a(()=>{let pe=this.#o=q.promise=oe();le(pe)},"recreateThenable"),fe=this.#o;switch(fe.status){case"pending":t.queryHash===r.queryHash&&le(fe);break;case"fulfilled":(se||q.data!==fe.value)&&dt();break;case"rejected":(!se||q.error!==fe.reason)&&dt();break}}return q}updateResult(){let t=this.#s,e=this.createResult(this.#t,this.options);if(this.#n=this.#t.state,this.#i=this.options,this.#n.data!==void 0&&(this.#p=this.#t),ve(e,t))return;this.#s=e;let r=a(()=>{if(!t)return!0;let{notifyOnChangeProps:s}=this.options,i=typeof s=="function"?s():s;if(i==="all"||!i&&!this.#m.size)return!0;let n=new Set(i??this.#m);return this.options.throwOnError&&n.add("error"),Object.keys(this.#s).some(o=>{let c=o;return this.#s[c]!==t[c]&&n.has(c)})},"shouldNotifyListeners");this.#k({listeners:r()})}#C(){let t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;let e=this.#t;this.#t=t,this.#r=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#g()}#k(t){v.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#s)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function Cr(t,e){return I(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&I(e.retryOnMount,t)===!1)}a(Cr,"shouldLoadOnMount");function Ot(t,e){return Cr(t,e)||t.state.data!==void 0&&$e(t,e,e.refetchOnMount)}a(Ot,"shouldFetchOnMount");function $e(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&&ze(t,e)}return!1}a($e,"shouldFetchOn");function Rt(t,e,r,s){return(t!==e||I(s.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&ze(t,r)}a(Rt,"shouldFetchOptionally");function ze(t,e){return I(e.enabled,t)!==!1&&t.isStaleByTime(x(e.staleTime,t))}a(ze,"isStale");function kr(t,e){return!ve(t.getCurrentResult(),e)}a(kr,"shouldAssignObserverCurrentProperties");var Pt=class extends ke{static{a(this,"Mutation")}#e;#t;#r;#s;constructor(t){super(),this.#e=t.client,this.mutationId=t.mutationId,this.#r=t.mutationCache,this.#t=[],this.state=t.state||Ir(),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.#t.includes(t)||(this.#t.push(t),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#t=this.#t.filter(e=>e!==t),this.scheduleGc(),this.#r.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#t.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=a(()=>{this.#n({type:"continue"})},"onContinue"),r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#s=Ce({fn:a(()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),"fn"),onFail:a((n,o)=>{this.#n({type:"failed",failureCount:n,error:o})},"onFail"),onPause:a(()=>{this.#n({type:"pause"})},"onPause"),onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:a(()=>this.#r.canRun(this),"canRun")});let s=this.state.status==="pending",i=!this.#s.canStart();try{if(s)e();else{this.#n({type:"pending",variables:t,isPaused:i}),this.#r.config.onMutate&&await this.#r.config.onMutate(t,this,r);let o=await this.options.onMutate?.(t,r);o!==this.state.context&&this.#n({type:"pending",context:o,variables:t,isPaused:i})}let n=await this.#s.start();return await this.#r.config.onSuccess?.(n,t,this.state.context,this,r),await this.options.onSuccess?.(n,t,this.state.context,r),await this.#r.config.onSettled?.(n,null,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(n,null,t,this.state.context,r),this.#n({type:"success",data:n}),n}catch(n){try{await this.#r.config.onError?.(n,t,this.state.context,this,r)}catch(o){Promise.reject(o)}try{await this.options.onError?.(n,t,this.state.context,r)}catch(o){Promise.reject(o)}try{await this.#r.config.onSettled?.(void 0,n,this.state.variables,this.state.context,this,r)}catch(o){Promise.reject(o)}try{await this.options.onSettled?.(void 0,n,t,this.state.context,r)}catch(o){Promise.reject(o)}throw this.#n({type:"error",error:n}),n}finally{this.#r.runNext(this)}}#n(t){let e=a(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),v.batch(()=>{this.#t.forEach(r=>{r.onMutationUpdate(t)}),this.#r.notify({mutation:this,type:"updated",action:t})})}};function Ir(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}a(Ir,"getDefaultState");var At=class extends L{static{a(this,"MutationCache")}constructor(t={}){super(),this.config=t,this.#e=new Set,this.#t=new Map,this.#r=0}#e;#t;#r;build(t,e,r){let s=new Pt({client:t,mutationCache:this,mutationId:++this.#r,options:t.defaultMutationOptions(e),state:r});return this.add(s),s}add(t){this.#e.add(t);let e=Ie(t);if(typeof e=="string"){let r=this.#t.get(e);r?r.push(t):this.#t.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#e.delete(t)){let e=Ie(t);if(typeof e=="string"){let r=this.#t.get(e);if(r)if(r.length>1){let s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&this.#t.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){let e=Ie(t);if(typeof e=="string"){let s=this.#t.get(e)?.find(i=>i.state.status==="pending");return!s||s===t}else return!0}runNext(t){let e=Ie(t);return typeof e=="string"?this.#t.get(e)?.find(s=>s!==t&&s.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){v.batch(()=>{this.#e.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(t){let e={exact:!0,...t};return this.getAll().find(r=>be(e,r))}findAll(t={}){return this.getAll().filter(e=>be(t,e))}notify(t){v.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){let t=this.getAll().filter(e=>e.state.isPaused);return v.batch(()=>Promise.all(t.map(e=>e.continue().catch(g))))}};function Ie(t){return t.options.scope?.id}a(Ie,"scopeFor");var Ft=class extends L{static{a(this,"QueryCache")}constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,r){let s=e.queryKey,i=e.queryHash??ne(s,e),n=this.get(i);return n||(n=new Tt({client:t,queryKey:s,queryHash:i,options:t.defaultQueryOptions(e),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(n)),n}add(t){this.#e.has(t.queryHash)||(this.#e.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){let e=this.#e.get(t.queryHash);e&&(t.destroy(),e===t&&this.#e.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){v.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#e.get(t)}getAll(){return[...this.#e.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){v.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){v.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){v.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}};var We=class{static{a(this,"QueryClient")}#e;#t;#r;#s;#n;#i;#o;#a;constructor(t={}){this.#e=t.queryCache||new Ft,this.#t=t.mutationCache||new At,this.#r=t.defaultOptions||{},this.#s=new Map,this.#n=new Map,this.#i=0}mount(){this.#i++,this.#i===1&&(this.#o=X.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=Z.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#i--,this.#i===0&&(this.#o?.(),this.#o=void 0,this.#a?.(),this.#a=void 0)}isFetching(t){return this.#e.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#t.findAll({...t,status:"pending"}).length}getQueryData(t){let e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state.data}ensureQueryData(t){let e=this.defaultQueryOptions(t),r=this.#e.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.#e.findAll(t).map(({queryKey:e,state:r})=>{let s=r.data;return[e,s]})}setQueryData(t,e,r){let s=this.defaultQueryOptions({queryKey:t}),n=this.#e.get(s.queryHash)?.state.data,o=yt(e,n);if(o!==void 0)return this.#e.build(this,s).setData(o,{...r,manual:!0})}setQueriesData(t,e,r){return v.batch(()=>this.#e.findAll(t).map(({queryKey:s})=>[s,this.setQueryData(s,e,r)]))}getQueryState(t){let e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state}removeQueries(t){let e=this.#e;v.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){let r=this.#e;return v.batch(()=>(r.findAll(t).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){let r={revert:!0,...e},s=v.batch(()=>this.#e.findAll(t).map(i=>i.cancel(r)));return Promise.all(s).then(g).catch(g)}invalidateQueries(t,e={}){return v.batch(()=>(this.#e.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=v.batch(()=>this.#e.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let n=i.fetch(void 0,r);return r.throwOnError||(n=n.catch(g)),i.state.fetchStatus==="paused"?Promise.resolve():n}));return Promise.all(s).then(g)}fetchQuery(t){let e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);let r=this.#e.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(g).catch(g)}fetchInfiniteQuery(t){return t._type="infinite",this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(g).catch(g)}ensureInfiniteQueryData(t){return t._type="infinite",this.ensureQueryData(t)}resumePausedMutations(){return Z.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(t){this.#r=t}setQueryDefaults(t,e){this.#s.set(H(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){let e=[...this.#s.values()],r={};return e.forEach(s=>{N(t,s.queryKey)&&Object.assign(r,s.defaultOptions)}),r}setMutationDefaults(t,e){this.#n.set(H(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){let e=[...this.#n.values()],r={};return e.forEach(s=>{N(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=ne(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===Y&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#r.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};var B=P($(),1);var ee=P($(),1),Mt=P(Ue(),1);var ce=ee.createContext(void 0),Ve=a(t=>{let e=ee.useContext(ce);if(t)return t;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},"useQueryClient"),Ge=a(({client:t,children:e})=>(ee.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),(0,Mt.jsx)(ce.Provider,{value:t,children:e})),"QueryClientProvider");var ue=P($(),1),Er=P(Ue(),1);function Tr(){let t=!1;return{clearReset:a(()=>{t=!1},"clearReset"),reset:a(()=>{t=!0},"reset"),isReset:a(()=>t,"isReset")}}a(Tr,"createValue");var Or=ue.createContext(Tr()),xt=a(()=>ue.useContext(Or),"useQueryErrorResetBoundary");var _t=P($(),1);var Lt=a((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"),Qt=a(t=>{_t.useEffect(()=>{t.clearReset()},[t])},"useClearResetErrorBoundary"),Dt=a(({result:t,errorResetBoundary:e,throwOnError:r,query:s,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&s&&(i&&t.data===void 0||Se(r,[t.error,s])),"getHasError");var Ee=P($(),1);var Ut=Ee.createContext(!1),qt=a(()=>Ee.useContext(Ut),"useIsRestoring"),Ra=Ut.Provider;var Nt=a(t=>{if(t.suspense){let r=a(i=>i==="static"?i:Math.max(i??1e3,1e3),"clamp"),s=t.staleTime;t.staleTime=typeof s=="function"?(...i)=>r(s(...i)):r(s),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},"ensureSuspenseTimers"),Bt=a((t,e)=>t.isLoading&&t.isFetching&&!e,"willFetch"),Kt=a((t,e)=>t?.suspense&&e.isPending,"shouldSuspend"),Je=a((t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()}),"fetchOptimistic");function jt(t,e,r){let s=qt(),i=xt(),n=Ve(r),o=n.defaultQueryOptions(t);n.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let c=n.getQueryCache().get(o.queryHash),u=t.subscribed!==!1;o._optimisticResults=s?"isRestoring":u?"optimistic":void 0,Nt(o),Lt(o,i,c),Qt(i);let d=!n.getQueryCache().get(o.queryHash),[h]=B.useState(()=>new e(n,o)),l=h.getOptimisticResult(o),f=!s&&u;if(B.useSyncExternalStore(B.useCallback(m=>{let y=f?h.subscribe(v.batchCalls(m)):g;return h.updateResult(),y},[h,f]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),B.useEffect(()=>{h.setOptions(o)},[o,h]),Kt(o,l))throw Je(o,h,i);if(Dt({result:l,errorResetBoundary:i,throwOnError:o.throwOnError,query:c,suspense:o.suspense}))throw l.error;return n.getDefaultOptions().queries?._experimental_afterQuery?.(o,l),o.experimental_prefetchInRender&&!D.isServer()&&Bt(l,s)&&(d?Je(o,h,i):c?.promise)?.catch(g).finally(()=>{h.updateResult()}),o.notifyOnChangeProps?l:h.trackResult(l)}a(jt,"useBaseQuery");function Rr(t,e){return jt(t,He,e)}a(Rr,"useQuery");var $t=P(lt(),1);var z=P($(),1),Xe=P(Ue(),1);var Ht=(0,z.createContext)(null),Pr=a(()=>new We({defaultOptions:{mutations:{retry:0},queries:{gcTime:5*6e4,retry:0,staleTime:Number.POSITIVE_INFINITY}}}),"v"),Ar=a(t=>{let e=(0,$t.c)(9),{children:r,client:s,queryClient:i}=t,n=(0,z.use)(ce),o;e[0]!==n||e[1]!==i?(o=a(()=>i??n??Pr(),"o"),e[0]=n,e[1]=i,e[2]=o):o=e[2];let[c]=(0,z.useState)(o),u=i??n??c,d;e[3]!==r||e[4]!==s?(d=(0,Xe.jsx)(Ht,{value:s,children:r}),e[3]=r,e[4]=s,e[5]=d):d=e[5];let h=d;if(n===u)return h;let l;return e[6]!==h||e[7]!==u?(l=(0,Xe.jsx)(Ge,{client:u,children:h}),e[6]=h,e[7]=u,e[8]=l):l=e[8],l},"b"),Ye=a(()=>{let t=(0,z.use)(Ht);if(!t)throw new p("INTERNAL","useLunora must be used inside <LunoraProvider />");return t},"q");var zt=a(()=>{let t=null;return{get:a(()=>t,"get"),set:a(e=>{t=e},"set")}},"l");var Te=class{static{a(this,"u")}values=new Map;subscribers=new Map;get(e){return this.values.has(e.key)?this.values.get(e.key):e.defaultValue}set(e,r){if(r===void 0){this.reset(e);return}this.values.set(e.key,r),this.notify(e.key,r)}reset(e){this.values.delete(e.key),this.notify(e.key,e.defaultValue)}subscribe(e,r){let s=this.subscribers.get(e.key);return s||(s=new Set,this.subscribers.set(e.key,s)),s.add(r),()=>{s.delete(r),s.size===0&&this.subscribers.delete(e.key)}}notify(e,r){let s=this.subscribers.get(e);if(s)for(let i of s)try{i(r)}catch{}}};var Wt=0,Fr="lunora-bridge",Mr=1e3,xr=3e3,Oe=class{static{a(this,"c")}bc;tabId;heartbeatInterval;leaderTimeout;knownLeader=void 0;leader=!1;running=!1;promotionPending=!1;lastHeartbeat=0;heartbeatTimer=void 0;leaderCheckTimer=void 0;onBecomeLeader;onStopBeingLeader;onConnectionStatus;onSubscriptionData;onSubscriptionError;onSubscriptionSettled;constructor(e={}){if(Wt+=1,this.tabId=`tab_${String(Wt)}_${crypto.randomUUID()}`,this.heartbeatInterval=e.heartbeatInterval??Mr,this.leaderTimeout=e.leaderTimeout??xr,this.onBecomeLeader=e.onBecomeLeader,this.onStopBeingLeader=e.onStopBeingLeader,this.onConnectionStatus=e.onConnectionStatus,this.onSubscriptionData=e.onSubscriptionData,this.onSubscriptionError=e.onSubscriptionError,this.onSubscriptionSettled=e.onSubscriptionSettled,typeof BroadcastChannel>"u"){this.bc=void 0;return}this.bc=new BroadcastChannel(e.channelName??Fr),this.bc.addEventListener("message",r=>{this.handleMessage(r.data)})}start(){if(!this.running){if(this.running=!0,this.bc===void 0){this.becomeLeader();return}this.broadcast({type:"claim-leadership",tabId:this.tabId,ts:Date.now()}),setTimeout(()=>{this.running&&this.knownLeader===void 0&&this.becomeLeader()},this.leaderTimeout),this.leaderCheckTimer=setInterval(()=>{this.checkLeaderHealth()},this.leaderTimeout),this.heartbeatTimer=setInterval(()=>{this.sendHeartbeat()},this.heartbeatInterval)}}stop(){this.running=!1,this.leader&&(this.broadcast({type:"yield-leadership",tabId:this.tabId}),this.leader=!1,this.knownLeader=void 0,this.onStopBeingLeader?.()),this.heartbeatTimer!==void 0&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0),this.leaderCheckTimer!==void 0&&(clearInterval(this.leaderCheckTimer),this.leaderCheckTimer=void 0),this.bc?.close()}isLeader(){return this.leader}promoteImmediately(){this.running&&this.becomeLeader()}get leaderTabId(){return this.knownLeader}get id(){return this.tabId}get isRunning(){return this.running}broadcastSubscriptionData(e,r,s,i,n){this.leader&&this.broadcast({type:"subscription-data",tabId:this.tabId,key:e,data:r,...s===void 0?{}:{cursor:s},...i===void 0?{}:{epoch:i},...n===void 0?{}:{identity:n}})}broadcastSubscriptionError(e,r){this.leader&&this.broadcast({type:"subscription-error",tabId:this.tabId,key:e,error:r})}broadcastSubscriptionSettled(e,r,s,i,n,o){this.leader&&this.broadcast({type:"subscription-settled",tabId:this.tabId,key:e,...r===void 0?{}:{cursor:r},...s===void 0?{}:{epoch:s},...i===void 0?{}:{lastMutationId:i},...n===void 0?{}:{clientId:n},...o===void 0?{}:{identity:o}})}broadcastConnectionStatus(e,r){this.leader&&this.broadcast({type:"connection-status",tabId:this.tabId,status:e,...r===void 0?{}:{identity:r}})}broadcast(e){this.bc?.postMessage(e)}handleMessage(e){switch(e.type){case"claim-leadership":{this.handleClaimLeadership(e);break}case"connection-status":{if(this.leader||e.tabId===this.tabId)break;this.onConnectionStatus?.(e.status,e.identity);break}case"heartbeat":{this.handleHeartbeat(e);break}case"subscription-data":{if(this.leader||e.tabId===this.tabId)break;this.onSubscriptionData?.(e.key,e.data,e.cursor,e.epoch,e.identity);break}case"subscription-error":{if(this.leader||e.tabId===this.tabId)break;this.onSubscriptionError?.(e.key,e.error);break}case"subscription-settled":{if(this.leader||e.tabId===this.tabId)break;this.onSubscriptionSettled?.(e.key,e.cursor,e.epoch,e.lastMutationId,e.clientId,e.identity);break}case"yield-leadership":{this.knownLeader===e.tabId&&(this.knownLeader=void 0,this.running&&!this.leader&&this.claimAndPromote());break}}}handleClaimLeadership(e){if(e.tabId!==this.tabId){if(this.leader){this.broadcast({type:"heartbeat",tabId:this.tabId,ts:Date.now()});return}this.knownLeader===void 0&&e.tabId<this.tabId&&(this.knownLeader=e.tabId,this.lastHeartbeat=e.ts)}}handleHeartbeat(e){if(e.tabId!==this.tabId){if(this.leader){this.resolveLeaderVsLeaderTieBreak(e);return}this.lastHeartbeat=e.ts,this.knownLeader=e.tabId}}resolveLeaderVsLeaderTieBreak(e){e.tabId<this.tabId?(this.leader=!1,this.knownLeader=e.tabId,this.lastHeartbeat=e.ts,this.onStopBeingLeader?.()):this.broadcast({type:"heartbeat",tabId:this.tabId,ts:Date.now()})}becomeLeader(){this.leader||(this.leader=!0,this.knownLeader=this.tabId,this.lastHeartbeat=Date.now(),this.onBecomeLeader?.(),this.broadcast({type:"heartbeat",tabId:this.tabId,ts:Date.now()}))}sendHeartbeat(){this.leader&&this.broadcast({type:"heartbeat",tabId:this.tabId,ts:Date.now()})}checkLeaderHealth(){if(!(!this.running||this.leader)){if(this.knownLeader===void 0){this.claimAndPromote();return}Date.now()-this.lastHeartbeat>this.leaderTimeout&&(this.knownLeader=void 0,this.claimAndPromote())}}claimAndPromote(){this.promotionPending||(this.promotionPending=!0,this.broadcast({type:"claim-leadership",tabId:this.tabId,ts:Date.now()}),setTimeout(()=>{this.promotionPending=!1,this.running&&this.knownLeader===void 0&&this.becomeLeader()},this.leaderTimeout))}};var Ze="_creationTime",_r=a(t=>{if(typeof t!="object"||t===null)return;let e=t._id;return typeof e=="string"?e:void 0},"p"),Lr=a(t=>{let e;for(let r of t){let s=r[Ze];if(typeof s=="number"){if(e!==void 0){if(s<e)return!0;if(s>e)return!1}e=s}}return!1},"a"),Qr=a((t,e)=>{let r=e[Ze];if(typeof r!="number")return t.length;let s=Lr(t);for(let[i,n]of t.entries()){let o=n[Ze];if(typeof o=="number"&&(s?o<r:o>r))return i}return t.length},"d"),Vt=a(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")},"y"),Gt=a((t,e)=>{if(!Array.isArray(t))return;let r=[];for(let u of t){if(_r(u)===void 0)return;r.push(u)}let{key:s,op:i,row:n}=e;if(i==="delete"){let u=r.filter(d=>d._id!==s);return u.length===r.length?[...r]:u}if(n===void 0)return;let o=r.findIndex(u=>u._id===s);if(o===-1){let u=[...r];return u.splice(Qr(r,n),0,n),u}let c=[...r];return c[o]=n,c},"g");var Dr=1024,Re=a(t=>{let e=t.maxBuffer??Dr,r=[],s=[],i=!1,n,o=!1,c=a(()=>{let h=s.shift();if(!h)return!1;if(n)return h.reject(n),!0;if(r.length>0){let l=r.shift();return h.resolve({done:!1,value:l}),!0}return i?(h.resolve({done:!0,value:void 0}),!0):(s.unshift(h),!1)},"n"),u={complete(){if(!(i||n))for(i=!0;c(););},fail(h){if(!(i||n))for(n=h,r.length=0;c(););},push(h){if(!(i||n||o)){if(r.length>=e){u.fail(new p("STREAM_BACKPRESSURE",`stream buffer overflow (max=${e.toString()}); the consumer cannot keep up with the producer`));return}r.push(h),c()}}},d=a(()=>{if(!o){o=!0,i=!0,r.length=0;try{t.onCancel()}catch{}for(;c(););}},"c");return{handle:u,iterable:{cancel:d,[Symbol.asyncIterator](){return{next(){if(n)return Promise.reject(n);if(r.length>0){let h=r.shift();return Promise.resolve({done:!1,value:h})}return i?Promise.resolve({done:!0,value:void 0}):new Promise((h,l)=>{s.push({reject:l,resolve:h})})},return(){return d(),Promise.resolve({done:!0,value:void 0})}}}}}},"d");var Jt=/^ /u,Xt=a(t=>typeof t=="object"&&t!==null?JSON.stringify(t):String(t),"u"),Ur=a(t=>{let e="",r=[];for(let s of t.split(`
|
|
2
2
|
`))s.startsWith("event:")?e=s.slice(6).replace(Jt,""):s.startsWith("data:")&&r.push(s.slice(5).replace(Jt,""));return{data:r.join(`
|
|
3
3
|
`),event:e}},"p"),qr=a((t,e,r)=>{let s=e.params??{},i=t.path.split("/").map(c=>{if(!c.startsWith(":"))return c;let u=c.slice(1),d=s[u];if(d===void 0)throw new p("HTTP_STREAM_MISSING_PARAM",`httpStream: missing path param ":${u}" for route ${t.path}`);return encodeURIComponent(Xt(d))}).join("/"),n=new URLSearchParams;for(let[c,u]of Object.entries(e.searchParams??{}))u!==void 0&&n.set(c,Xt(u));let o=n.toString();return`${r.endsWith("/")?r.slice(0,-1):r}${i}${o===""?"":`?${o}`}`},"S"),Nr=a((t,e)=>{if(t.event==="complete")return e.complete(),!0;if(t.event==="error"){let r={};try{r=JSON.parse(t.data)}catch{}let s=typeof r.message=="string"?r.message:"stream error",i=typeof r.code=="string"?r.code:"HTTP_STREAM_ERROR";return e.fail(new p(i,s)),!0}if((t.event===""||t.event==="message")&&t.data!=="")try{e.push(JSON.parse(t.data))}catch{return e.fail(new p("HTTP_STREAM_BAD_CHUNK","httpStream: malformed SSE chunk (invalid JSON)")),!0}return!1},"T"),Br=a(async(t,e)=>{let r=t.getReader(),s=new TextDecoder,i="",n=a(()=>{let o=i.indexOf(`
|
|
4
4
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as nt}from"./chunk-SFDOII3B.js";import{e as Ee}from"./chunk-SMIESS7P.js";import{c as Ue}from"./chunk-FXCBF4XT.js";import{b as Fe}from"./chunk-THIXMMZD.js";import{a as D}from"./chunk-VDW32UET.js";import{c as ke}from"./chunk-
|
|
1
|
+
import{a as nt}from"./chunk-SFDOII3B.js";import{e as Ee}from"./chunk-SMIESS7P.js";import{c as Ue}from"./chunk-FXCBF4XT.js";import{b as Fe}from"./chunk-THIXMMZD.js";import{a as D}from"./chunk-VDW32UET.js";import{c as ke}from"./chunk-6F7KP54M.js";import{f as We}from"./chunk-C2ZFQARQ.js";import{a as Ye}from"./chunk-XQCVZAGU.js";import{a as T,e as He}from"./chunk-WQH3LT2P.js";import{d as $,f as Qe,g as Xe,l as et,o as Se,p as tt,q as at}from"./chunk-IUYFXK4X.js";import{a as m,e as Ve,f as ct,g as dt,h as mt,j as Be}from"./chunk-3XIESWL4.js";var S=Ve(dt(),1);var L=Ve(ct(),1);var n=Ve(mt(),1);var ut=Qe(D.studioFeatures),it={analytics:!0,auth:!0,containers:!0,flags:!0,kv:!0,mail:!0,notifications:!0,payments:!0,queues:!0,scheduler:!0,storage:!0,vectors:!0,workflows:!0},pt=m(t=>{if(t===null||typeof t!="object")return it;let e=t,s=m(a=>typeof e[a]=="boolean"?e[a]:!0,"a");return{analytics:s("analytics"),auth:s("auth"),containers:s("containers"),flags:s("flags"),kv:s("kv"),mail:s("mail"),notifications:s("notifications"),payments:s("payments"),queues:s("queues"),scheduler:s("scheduler"),storage:s("storage"),vectors:s("vectors"),workflows:s("workflows")}},"ut"),ft=m(()=>{let t=(0,S.c)(3),e=We(),[s,a]=(0,L.useState)(it),r,l;return t[0]!==e?(r=m(()=>{Se((async()=>{try{a(pt(await e.query(ut,{},Xe(""))))}catch{}})())},"s"),l=[e],t[0]=e,t[1]=r,t[2]=l):(r=t[1],l=t[2]),(0,L.useEffect)(r,l),s},"pt"),ht=m(()=>{let t=(0,S.c)(1),e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("svg",{"aria-hidden":"true",className:"size-4 text-muted-foreground",fill:"none",stroke:"currentColor",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,n.jsx)("path",{d:"m9 6 6 6-6 6",strokeLinecap:"round",strokeLinejoin:"round"})}),t[0]=e):e=t[0],e},"ft"),gt=m(t=>{let e=(0,S.c)(24),{group:s}=t,a=$(),r=Ee(),l;e[0]!==s.tab||e[1]!==r?(l=m(()=>{Se(r({to:`/${s.tab}`}))},"o"),e[0]=s.tab,e[1]=r,e[2]=l):l=e[2];let o=l,i=s.bindings.length,c;e[3]!==s.label?(c=(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:s.label}),e[3]=s.label,e[4]=c):c=e[4];let p;e[5]===Symbol.for("react.memo_cache_sentinel")?(p=(0,n.jsx)(ht,{}),e[5]=p):p=e[5];let d;e[6]!==c?(d=(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[c,p]}),e[6]=c,e[7]=d):d=e[7];let f;e[8]!==i||e[9]!==a?(f=i===1?a("1 binding"):a("{count} bindings",{count:i}),e[8]=i,e[9]=a,e[10]=f):f=e[10];let u;e[11]!==f?(u=(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:f}),e[11]=f,e[12]=u):u=e[12];let h;e[13]!==i||e[14]!==s.bindings?(h=i>0&&(0,n.jsx)("div",{className:"flex flex-wrap gap-1.5",children:s.bindings.map(yt)}),e[13]=i,e[14]=s.bindings,e[15]=h):h=e[15];let g;e[16]!==d||e[17]!==u||e[18]!==h?(g=(0,n.jsxs)(He,{className:"flex flex-col gap-2 py-4",children:[d,u,h]}),e[16]=d,e[17]=u,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==s.testId||e[21]!==o||e[22]!==g?(x=(0,n.jsx)(T,{className:"cursor-pointer gap-0 py-0 transition-colors hover:bg-muted/40","data-testid":s.testId,onClick:o,children:g}),e[20]=s.testId,e[21]=o,e[22]=g,e[23]=x):x=e[23],x},"ht"),st=["kv","files","vectors"],xt=m((t,e)=>[...t.filter(s=>s.tab!==e.tab),e].toSorted((s,a)=>st.indexOf(s.tab)-st.indexOf(a.tab)),"gt"),bt=m(()=>{let t=(0,S.c)(19),e=We(),s=ft(),a=$(),r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=[],t[0]=r):r=t[0];let[l,o]=(0,L.useState)(r),i,c;if(t[1]!==e||t[2]!==s.kv||t[3]!==s.storage||t[4]!==s.vectors||t[5]!==a?(i=m(()=>{let g={cancelled:!1},x=[{enabled:s.kv,label:a("KV Namespaces"),load:m(async()=>(await e.listKvNamespaces()).map(vt),"load"),tab:"kv",testId:"home-binding-kv"},{enabled:s.storage,label:a("R2 Buckets"),load:m(()=>e.listStorageBuckets(),"load"),tab:"files",testId:"home-binding-r2"},{enabled:s.vectors,label:a("Vectorize Indexes"),load:m(async()=>(await e.listVectorIndexes()).map(Nt),"load"),tab:"vectors",testId:"home-binding-vectors"}];for(let b of x)b.enabled&&Se((async()=>{try{let y=await b.load();if(!g.cancelled){let k={bindings:y,label:b.label,tab:b.tab,testId:b.testId};o(A=>xt(A,k))}}catch{}})());return()=>{g.cancelled=!0}},"i"),c=[e,s.kv,s.storage,s.vectors,a],t[1]=e,t[2]=s.kv,t[3]=s.storage,t[4]=s.vectors,t[5]=a,t[6]=i,t[7]=c):(i=t[6],c=t[7]),(0,L.useEffect)(i,c),l.length===0)return null;let p;t[8]!==a?(p=a("Bindings"),t[8]=a,t[9]=p):p=t[9];let d;t[10]!==p?(d=(0,n.jsx)("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:p}),t[10]=p,t[11]=d):d=t[11];let f;t[12]!==l?(f=l.map(_t),t[12]=l,t[13]=f):f=t[13];let u;t[14]!==f?(u=(0,n.jsx)("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:f}),t[14]=f,t[15]=u):u=t[15];let h;return t[16]!==d||t[17]!==u?(h=(0,n.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"home-bindings",children:[d,u]}),t[16]=d,t[17]=u,t[18]=h):h=t[18],h},"xt");function yt(t){return(0,n.jsx)(Fe,{variant:"secondary",children:t},t)}m(yt,"bt");function vt(t){return t.binding}m(vt,"yt");function Nt(t){return t.name}m(Nt,"vt");function _t(t){return(0,n.jsx)(gt,{group:t},t.tab)}m(_t,"Nt");var St=[{name:"lunora_list_functions",summary:"list every query, mutation, and action with its path"},{name:"lunora_list_tables",summary:"list the schema's tables"},{name:"lunora_get_function_schema",summary:"read a function's argument JSON Schema before calling it"},{name:"lunora_run_query",summary:"run a read-only query"},{name:"lunora_run_mutation",summary:"run a mutation \u2014 writes; only when LUNORA_MCP_ALLOW_WRITES is set"},{name:"lunora_run_action",summary:"run an action \u2014 writes/effects; only when LUNORA_MCP_ALLOW_WRITES is set"}],kt=m(t=>JSON.stringify({mcpServers:{lunora:{args:["-y","@lunora/mcp"],command:"npx",env:{LUNORA_ADMIN_TOKEN:"<your-admin-token>",LUNORA_URL:t}}}},null,2),"St"),wt=m(t=>{let e=St.map(s=>`- ${s.name} \u2014 ${s.summary}`).join(`
|
|
2
2
|
`);return[`You have a Lunora MCP server connected to the deployment at ${t}.`,"It exposes this backend's functions and schema so you can inspect and operate it:",e,"",`Start by calling lunora_list_functions and lunora_list_tables to learn what exists, then lunora_get_function_schema before any run call. The full HTTP API is also documented at ${t}/_lunora/admin/openapi (that endpoint needs the same admin token the MCP server is configured with).`].join(`
|
|
3
|
-
`)},"kt"),Mt=1500,It=m(()=>{let t=(0,S.c)(35),e=$(),s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=tt(),t[0]=s):s=t[0];let a=s,[r,l]=(0,L.useState)(null),o,i;t[1]!==r?(o=m(()=>{if(r===null)return;let C=globalThis.setTimeout(()=>{l(null)},Mt);return()=>{globalThis.clearTimeout(C)}},"l"),i=[r],t[1]=r,t[2]=o,t[3]=i):(o=t[2],i=t[3]),(0,L.useEffect)(o,i);let c;t[4]===Symbol.for("react.memo_cache_sentinel")?(c=m((C,j)=>{at(j)&&l(C)},"c"),t[4]=c):c=t[4];let p=c,d;t[5]===Symbol.for("react.memo_cache_sentinel")?(d=m(()=>{p("config",kt(a))},"d"),t[5]=d):d=t[5];let f=d,u;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=m(()=>{p("prompt",wt(a))},"m"),t[6]=u):u=t[6];let h=u,g;t[7]!==e?(g=e("Connect an AI agent"),t[7]=e,t[8]=g):g=t[8];let x;t[9]!==g?(x=(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:g}),t[9]=g,t[10]=x):x=t[10];let b;t[11]!==e?(b=e("Drive this deployment from an AI agent over the Model Context Protocol \u2014 it can list functions and tables, read schemas, and run read-only queries. Writes stay off unless you opt in."),t[11]=e,t[12]=b):b=t[12];let y;t[13]!==b?(y=(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:b}),t[13]=b,t[14]=y):y=t[14];let k;t[15]!==x||t[16]!==y?(k=(0,n.jsxs)("div",{className:"flex flex-col gap-1.5 p-4",children:[x,y]}),t[15]=x,t[16]=y,t[17]=k):k=t[17];let A;t[18]===Symbol.for("react.memo_cache_sentinel")?(A=(0,n.jsx)("code",{className:"font-mono text-xs text-muted-foreground","data-testid":"home-connect-agent-command",children:"npx -y @lunora/mcp"}),t[18]=A):A=t[18];let w;t[19]!==r||t[20]!==e?(w=e(r==="config"?"Copied":"Copy MCP config"),t[19]=r,t[20]=e,t[21]=w):w=t[21];let v;t[22]!==w?(v=(0,n.jsx)(Ue,{"data-testid":"home-connect-agent-copy-config",onClick:f,size:"xs",variant:"outline",children:w}),t[22]=w,t[23]=v):v=t[23];let M;t[24]!==r||t[25]!==e?(M=e(r==="prompt"?"Copied":"Copy agent prompt"),t[24]=r,t[25]=e,t[26]=M):M=t[26];let I;t[27]!==M?(I=(0,n.jsx)(Ue,{"data-testid":"home-connect-agent-copy-prompt",onClick:h,size:"xs",variant:"outline",children:M}),t[27]=M,t[28]=I):I=t[28];let N;t[29]!==v||t[30]!==I?(N=(0,n.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border bg-muted/50 px-4 py-3",children:[A,(0,n.jsxs)("div",{className:"flex flex-wrap gap-2",children:[v,I]})]}),t[29]=v,t[30]=I,t[31]=N):N=t[31];let _;return t[32]!==k||t[33]!==N?(_=(0,n.jsxs)(T,{className:"gap-0 py-0","data-testid":"home-connect-agent",children:[k,N]}),t[32]=k,t[33]=N,t[34]=_):_=t[34],_},"$t"),Lt=(0,L.lazy)(()=>import("./chunk-VWKQ6X2S.js")),Ze=m(t=>{if(t<1e3)return`${String(Math.round(t))}ms`;let e=t>=1e4?0:1;return`${(t/1e3).toFixed(e)}s`},"Ee"),At=m((t,e)=>{let s=Math.max(0,Math.round((e-t)/1e3));if(s<60)return`${String(s)}s ago`;let a=Math.round(s/60);if(a<60)return`${String(a)}m ago`;let r=Math.round(a/60);return r<24?`${String(r)}h ago`:`${String(Math.round(r/24))}d ago`},"Mt"),rt=m((t,e)=>{if(t===void 0||t.length===0)return[];let s=new Map;for(let a of t)s.set(a.bucketMs,(s.get(a.bucketMs)??0)+a[e]);return[...s.entries()].toSorted(([a],[r])=>a-r).map(([,a])=>a)},"He"),lt=m((t,e=!0)=>{if(t.length<4)return null;let s=Math.floor(t.length/2),a=t.slice(0,s).reduce((o,i)=>o+i,0),r=t.slice(s).reduce((o,i)=>o+i,0);if(a===0)return null;let l=(r-a)/a*100;return{positive:e?l>=0:l<=0,text:`${l>=0?"+":""}${l.toFixed(1)}%`}},"Je"),qe=m(t=>{let e=(0,S.c)(24),{delta:s,footer:a,label:r,trend:l,unit:o,value:i}=t,c=$(),p;e[0]!==r?(p=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r}),e[0]=r,e[1]=p):p=e[1];let d;e[2]!==i?(d=(0,n.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:i}),e[2]=i,e[3]=d):d=e[3];let f;e[4]!==o?(f=o!==void 0&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=f):f=e[5];let u;e[6]!==d||e[7]!==f?(u=(0,n.jsxs)("span",{className:"flex items-baseline gap-1.5",children:[d,f]}),e[6]=d,e[7]=f,e[8]=u):u=e[8];let h;e[9]!==l?(h=l!==void 0&&(0,n.jsx)(L.Suspense,{fallback:(0,n.jsx)("div",{"aria-hidden":"true",className:"h-8 w-28"}),children:(0,n.jsx)(Lt,{data:l})}),e[9]=l,e[10]=h):h=e[10];let g;e[11]!==u||e[12]!==h?(g=(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[u,h]}),e[11]=u,e[12]=h,e[13]=g):g=e[13];let x;e[14]!==p||e[15]!==g?(x=(0,n.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[p,g]}),e[14]=p,e[15]=g,e[16]=x):x=e[16];let b;e[17]!==s||e[18]!==a||e[19]!==c?(b=s==null?a!=null&&(0,n.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:a}):(0,n.jsxs)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px]",children:[(0,n.jsx)("span",{className:Be("font-semibold",s.positive?"text-success":"text-destructive"),children:s.text})," ",(0,n.jsx)("span",{className:"text-muted-foreground",children:c("vs. prev.")})]}),e[17]=s,e[18]=a,e[19]=c,e[20]=b):b=e[20];let y;return e[21]!==x||e[22]!==b?(y=(0,n.jsxs)(T,{className:"justify-between gap-0 py-0",children:[x,b]}),e[21]=x,e[22]=b,e[23]=y):y=e[23],y},"Oe"),Ct=m(()=>{let t=(0,S.c)(1),e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:(0,n.jsx)("path",{d:"m9 6 6 6-6 6"})}),t[0]=e):e=t[0],e},"At"),Je=m(t=>{let e=(0,S.c)(7),{command:s,label:a}=t,r;e[0]!==a?(r=(0,n.jsx)("div",{className:"p-4",children:(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:a})}),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==s?(l=(0,n.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5",children:(0,n.jsx)("code",{className:"font-mono text-xs text-muted-foreground",children:s})}),e[2]=s,e[3]=l):l=e[3];let o;return e[4]!==r||e[5]!==l?(o=(0,n.jsxs)(T,{className:"justify-between gap-0 py-0",children:[r,l]}),e[4]=r,e[5]=l,e[6]=o):o=e[6],o},"De"),ot=m(t=>{let e=(0,S.c)(18),{count:s,onView:a,testId:r,title:l}=t,o=$(),i;e[0]!==l?(i=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=i):i=e[1];let c;e[2]!==s||e[3]!==o?(c=s===null?(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:o("No data yet")}):(0,n.jsx)(Fe,{variant:s>0?"destructive":"success",children:s>0?s:o("All clear")}),e[2]=s,e[3]=o,e[4]=c):c=e[4];let p;e[5]!==i||e[6]!==c?(p=(0,n.jsxs)("div",{className:"flex items-start justify-between gap-2 p-4",children:[i,c]}),e[5]=i,e[6]=c,e[7]=p):p=e[7];let d;e[8]!==o?(d=o("View"),e[8]=o,e[9]=d):d=e[9];let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=(0,n.jsx)(Ct,{}),e[10]=f):f=e[10];let u;e[11]!==a||e[12]!==d?(u=(0,n.jsxs)("button",{className:"flex items-center gap-1 border-t border-border bg-muted/50 px-4 py-2.5 text-[12px] font-medium text-foreground outline-none transition-colors hover:bg-muted focus-visible:bg-muted",onClick:a,type:"button",children:[d,f]}),e[11]=a,e[12]=d,e[13]=u):u=e[13];let h;return e[14]!==p||e[15]!==u||e[16]!==r?(h=(0,n.jsxs)(T,{className:"justify-between gap-0 py-0","data-testid":r,children:[p,u]}),e[14]=p,e[15]=u,e[16]=r,e[17]=h):h=e[17],h},"Ge"),$t=m(t=>{let e=(0,S.c)(7),{functions:s}=t,a=$(),r;if(e[0]!==s||e[1]!==a){let l=[...s].toSorted(qt).slice(0,5),o;e[3]!==a?(o=a("Top functions"),e[3]=a,e[4]=o):o=e[4];let i;e[5]!==o?(i=(0,n.jsx)("div",{className:"border-b border-border px-4 py-3",children:(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o})}),e[5]=o,e[6]=i):i=e[6],r=(0,n.jsxs)(T,{className:"gap-0 py-0","data-testid":"home-top-functions",children:[i,l.length===0?(0,n.jsx)("p",{className:"px-4 py-8 text-center text-xs text-muted-foreground",children:a("No functions called yet.")}):(0,n.jsxs)("div",{className:"divide-y divide-border",children:[(0,n.jsxs)("div",{className:"grid grid-cols-[1fr_auto_auto_auto] gap-4 px-4 py-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:[(0,n.jsx)("span",{children:a("Function")}),(0,n.jsx)("span",{className:"text-end",children:a("Calls")}),(0,n.jsx)("span",{className:"w-12 text-end",children:a("Avg")}),(0,n.jsx)("span",{className:"w-8 text-end",children:a("Err")})]}),l.map(Rt)]})]}),e[0]=s,e[1]=a,e[2]=r}else r=e[2];return r},"Ct"),jt=m(t=>{let e=(0,S.c)(26),{subs:s}=t,a=$(),r;e[0]!==a?(r=a("Live connections"),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==r?(l=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r}),e[2]=r,e[3]=l):l=e[3];let o=s?.totalConnections??0,i;e[4]!==o?(i=o.toLocaleString(),e[4]=o,e[5]=i):i=e[5];let c;e[6]!==i?(c=(0,n.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:i}),e[6]=i,e[7]=c):c=e[7];let p;e[8]!==a?(p=a("sockets"),e[8]=a,e[9]=p):p=e[9];let d;e[10]!==p?(d=(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:p}),e[10]=p,e[11]=d):d=e[11];let f;e[12]!==c||e[13]!==d?(f=(0,n.jsxs)("span",{className:"flex items-baseline gap-1.5",children:[c,d]}),e[12]=c,e[13]=d,e[14]=f):f=e[14];let u=s?.totalSubscriptions??0,h;e[15]!==u?(h=u.toLocaleString(),e[15]=u,e[16]=h):h=e[16];let g;e[17]!==a?(g=a("active subscriptions"),e[17]=a,e[18]=g):g=e[18];let x;e[19]!==h||e[20]!==g?(x=(0,n.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:[h," ",g]}),e[19]=h,e[20]=g,e[21]=x):x=e[21];let b;return e[22]!==x||e[23]!==l||e[24]!==f?(b=(0,n.jsx)(T,{"data-testid":"home-live-connections",children:(0,n.jsxs)(He,{className:"flex flex-col gap-2.5 py-4",children:[l,f,x]})}),e[22]=x,e[23]=l,e[24]=f,e[25]=b):b=e[25],b},"It"),Tt=m(t=>{let e=(0,S.c)(7),{entries:s}=t,a=$(),r;if(e[0]!==s||e[1]!==a){let l=Date.now(),o;e[3]!==a?(o=a("Recent activity"),e[3]=a,e[4]=o):o=e[4];let i;e[5]!==o?(i=(0,n.jsx)("div",{className:"border-b border-border px-4 py-3",children:(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o})}),e[5]=o,e[6]=i):i=e[6],r=(0,n.jsxs)(T,{className:"gap-0 py-0","data-testid":"home-recent-activity",children:[i,s.length===0?(0,n.jsx)("p",{className:"px-4 py-8 text-center text-xs text-muted-foreground",children:a("No recent activity.")}):(0,n.jsx)("ul",{className:"divide-y divide-border",children:s.slice(0,5).map(c=>(0,n.jsxs)("li",{className:"flex items-center justify-between gap-3 px-4 py-2 text-[13px]",children:[(0,n.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,n.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-muted-foreground/40"}),(0,n.jsxs)("span",{className:"truncate text-foreground",children:[c.op,c.table!==void 0&&(0,n.jsxs)("span",{className:"text-muted-foreground",children:[" \xB7 ",c.table,c.id===void 0?"":`#${c.id}`]})]})]}),(0,n.jsx)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:At(c.ts,l)})]},c.seq))})]}),e[0]=s,e[1]=a,e[2]=r}else r=e[2];return r},"Tt"),Ot=m(t=>{let e=t.reduce((s,a)=>s+a.calls,0);return e===0?null:t.reduce((s,a)=>s+a.totalDurationMs,0)/e},"jt"),Gt=m(t=>{let e=(0,S.c)(151),{initialShardKey:s}=t,a=$(),r=Ee(),l=s??"",o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={},e[0]=o):o=e[0];let i;e[1]!==l?(i={shardKey:l},e[1]=l,e[2]=i):i=e[2];let c=ke(D.getMetrics,o,i),p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p={},e[3]=p):p=e[3];let d;e[4]!==l?(d={shardKey:l},e[4]=l,e[5]=d):d=e[5];let f=ke(D.getFunctionStats,p,d),u,h;e[6]===Symbol.for("react.memo_cache_sentinel")?(u={},h={shardKey:""},e[6]=u,e[7]=h):(u=e[6],h=e[7]);let g=ke(D.getSecurityAudit,u,h),x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x={},e[8]=x):x=e[8];let b;e[9]!==l?(b={shardKey:l},e[9]=l,e[10]=b):b=e[10];let y=ke(D.listSubscriptions,x,b),k;e[11]===Symbol.for("react.memo_cache_sentinel")?(k={},e[11]=k):k=e[11];let A;e[12]!==l?(A={shardKey:l},e[12]=l,e[13]=A):A=e[13];let w=ke(D.getAuditLog,k,A),v=c.data??null,M,I,N,_,C,j,P,O,q,V,W,E,R,K,B,F,U,H;if(e[14]!==w.data||e[15]!==g.data||e[16]!==v||e[17]!==c.data||e[18]!==r||e[19]!==f.data||e[20]!==y.data||e[21]!==a){_=Array.isArray(f.data?.functions)?f.data.functions:[],P=y.data??null;let Le;e[40]!==w.data?(Le=Array.isArray(w.data?.entries)?w.data.entries:[],e[40]=w.data,e[41]=Le):Le=e[41],I=Le,C=c.data===void 0||f.data===void 0?null:nt(v,_).length,j=Array.isArray(g.data?.findings)?g.data.findings.length:null;let Ae;e[42]!==r?(Ae=m(()=>{Se(r({to:"/security"}))},"Me"),e[42]=r,e[43]=Ae):Ae=e[43],H=Ae;let Ce;e[44]!==r?(Ce=m(()=>{Se(r({to:"/insights"}))},"Ae"),e[44]=r,e[45]=Ce):Ce=e[45],U=Ce;let $e=rt(v?.history,"calls"),je=rt(v?.history,"errors"),Ge=Ot(_),Te=Math.max(0,..._.map(Kt)),z=v?.cache,Oe;e[46]!==z?(Oe=z!=null&&z.hits+z.misses>0?Math.round(z.hits/(z.hits+z.misses)*100):null,e[46]=z,e[47]=Oe):Oe=e[47],N=Oe,B="flex flex-col gap-6",F="lunora-home",W="grid gap-3 sm:grid-cols-2 xl:grid-cols-4",E="home-health";let Ke=lt($e),ye;e[48]!==a?(ye=a("Requests"),e[48]=a,e[49]=ye):ye=e[49];let ze=v?.requests??0,ve;e[50]!==ze?(ve=ze.toLocaleString(),e[50]=ze,e[51]=ve):ve=e[51],e[52]!==$e||e[53]!==Ke||e[54]!==ye||e[55]!==ve?(R=(0,n.jsx)(qe,{delta:Ke,label:ye,trend:$e,value:ve}),e[52]=$e,e[53]=Ke,e[54]=ye,e[55]=ve,e[56]=R):R=e[56];let De=lt(je,!1),Ne;e[57]!==a?(Ne=a("Errors"),e[57]=a,e[58]=Ne):Ne=e[58];let Pe=v?.errors??0,_e;e[59]!==Pe?(_e=Pe.toLocaleString(),e[59]=Pe,e[60]=_e):_e=e[60],e[61]!==je||e[62]!==De||e[63]!==Ne||e[64]!==_e?(K=(0,n.jsx)(qe,{delta:De,label:Ne,trend:je,value:_e}),e[61]=je,e[62]=De,e[63]=Ne,e[64]=_e,e[65]=K):K=e[65],M=qe,e[66]!==Te||e[67]!==a?(O=Te>0?`${a("max")} ${Ze(Te)}`:void 0,e[66]=Te,e[67]=a,e[68]=O):O=e[68],e[69]!==a?(q=a("Avg latency"),e[69]=a,e[70]=q):q=e[70],V=Ge===null?"\u2014":Ze(Ge),e[14]=w.data,e[15]=g.data,e[16]=v,e[17]=c.data,e[18]=r,e[19]=f.data,e[20]=y.data,e[21]=a,e[22]=M,e[23]=I,e[24]=N,e[25]=_,e[26]=C,e[27]=j,e[28]=P,e[29]=O,e[30]=q,e[31]=V,e[32]=W,e[33]=E,e[34]=R,e[35]=K,e[36]=B,e[37]=F,e[38]=U,e[39]=H}else M=e[22],I=e[23],N=e[24],_=e[25],C=e[26],j=e[27],P=e[28],O=e[29],q=e[30],V=e[31],W=e[32],E=e[33],R=e[34],K=e[35],B=e[36],F=e[37],U=e[38],H=e[39];let J;e[71]!==M||e[72]!==O||e[73]!==q||e[74]!==V?(J=(0,n.jsx)(M,{footer:O,label:q,value:V}),e[71]=M,e[72]=O,e[73]=q,e[74]=V,e[75]=J):J=e[75];let Z;e[76]!==N||e[77]!==a?(Z=N===null?void 0:`${String(N)}% ${a("cache hit")}`,e[76]=N,e[77]=a,e[78]=Z):Z=e[78];let G;e[79]!==a?(G=a("Database size"),e[79]=a,e[80]=G):G=e[80];let Re=v?.databaseSize??null,Y;e[81]!==Re?(Y=et(Re),e[81]=Re,e[82]=Y):Y=e[82];let Q;e[83]!==Z||e[84]!==G||e[85]!==Y?(Q=(0,n.jsx)(qe,{footer:Z,label:G,value:Y}),e[83]=Z,e[84]=G,e[85]=Y,e[86]=Q):Q=e[86];let X;e[87]!==W||e[88]!==E||e[89]!==R||e[90]!==K||e[91]!==J||e[92]!==Q?(X=(0,n.jsxs)("div",{className:W,"data-testid":E,children:[R,K,J,Q]}),e[87]=W,e[88]=E,e[89]=R,e[90]=K,e[91]=J,e[92]=Q,e[93]=X):X=e[93];let we;e[94]===Symbol.for("react.memo_cache_sentinel")?(we=(0,n.jsx)(bt,{}),e[94]=we):we=e[94];let ee;e[95]!==_?(ee=(0,n.jsx)("div",{className:"lg:col-span-2",children:(0,n.jsx)($t,{functions:_})}),e[95]=_,e[96]=ee):ee=e[96];let te;e[97]!==P?(te=(0,n.jsx)(jt,{subs:P}),e[97]=P,e[98]=te):te=e[98];let ae;e[99]!==I?(ae=(0,n.jsx)(Tt,{entries:I}),e[99]=I,e[100]=ae):ae=e[100];let ne;e[101]!==te||e[102]!==ae?(ne=(0,n.jsxs)("div",{className:"flex flex-col gap-3",children:[te,ae]}),e[101]=te,e[102]=ae,e[103]=ne):ne=e[103];let se;e[104]!==ee||e[105]!==ne?(se=(0,n.jsxs)("div",{className:"grid gap-3 lg:grid-cols-3",children:[ee,ne]}),e[104]=ee,e[105]=ne,e[106]=se):se=e[106];let re;e[107]!==a?(re=a("Advisors"),e[107]=a,e[108]=re):re=e[108];let le;e[109]!==re?(le=(0,n.jsx)("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:re}),e[109]=re,e[110]=le):le=e[110];let oe;e[111]!==C||e[112]!==j||e[113]!==a||e[114]!==U||e[115]!==H?(oe=j===0&&C===0?(0,n.jsx)(Ye,{description:a("No security or performance issues detected."),icon:(0,n.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,n.jsx)("path",{d:"M12 3 4 6v5c0 5 3.4 8.5 8 10 4.6-1.5 8-5 8-10V6l-8-3Z"}),(0,n.jsx)("path",{d:"m9 12 2 2 4-4"})]}),testId:"home-advisors-clear",title:a("No issues found")}):(0,n.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,n.jsx)(ot,{count:j,onView:H,testId:"home-security",title:a("Security findings")}),(0,n.jsx)(ot,{count:C,onView:U,testId:"home-performance",title:a("Performance issues")})]}),e[111]=C,e[112]=j,e[113]=a,e[114]=U,e[115]=H,e[116]=oe):oe=e[116];let ie;e[117]!==le||e[118]!==oe?(ie=(0,n.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"home-advisors",children:[le,oe]}),e[117]=le,e[118]=oe,e[119]=ie):ie=e[119];let ce;e[120]!==a?(ce=a("Get connected"),e[120]=a,e[121]=ce):ce=e[121];let de;e[122]!==ce?(de=(0,n.jsx)("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:ce}),e[122]=ce,e[123]=de):de=e[123];let me;e[124]!==a?(me=a("Client SDK"),e[124]=a,e[125]=me):me=e[125];let ue;e[126]!==me?(ue=(0,n.jsx)(Je,{command:"npm i @lunora/client",label:me}),e[126]=me,e[127]=ue):ue=e[127];let pe;e[128]!==a?(pe=a("React"),e[128]=a,e[129]=pe):pe=e[129];let fe;e[130]!==pe?(fe=(0,n.jsx)(Je,{command:"npm i @lunora/react",label:pe}),e[130]=pe,e[131]=fe):fe=e[131];let he;e[132]!==a?(he=a("CLI"),e[132]=a,e[133]=he):he=e[133];let ge;e[134]!==he?(ge=(0,n.jsx)(Je,{command:"lunora dev",label:he}),e[134]=he,e[135]=ge):ge=e[135];let xe;e[136]!==ue||e[137]!==fe||e[138]!==ge?(xe=(0,n.jsxs)("div",{className:"grid gap-3 sm:grid-cols-3",children:[ue,fe,ge]}),e[136]=ue,e[137]=fe,e[138]=ge,e[139]=xe):xe=e[139];let Me;e[140]===Symbol.for("react.memo_cache_sentinel")?(Me=(0,n.jsx)(It,{}),e[140]=Me):Me=e[140];let be;e[141]!==de||e[142]!==xe?(be=(0,n.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"home-get-connected",children:[de,xe,Me]}),e[141]=de,e[142]=xe,e[143]=be):be=e[143];let Ie;return e[144]!==B||e[145]!==F||e[146]!==X||e[147]!==se||e[148]!==ie||e[149]!==be?(Ie=(0,n.jsxs)("div",{className:B,"data-testid":F,children:[X,we,se,ie,be]}),e[144]=B,e[145]=F,e[146]=X,e[147]=se,e[148]=ie,e[149]=be,e[150]=Ie):Ie=e[150],Ie},"Zt");function qt(t,e){return e.calls-t.calls}m(qt,"Ot");function Rt(t){return(0,n.jsxs)("div",{className:"grid grid-cols-[1fr_auto_auto_auto] items-center gap-4 px-4 py-2 text-[13px]",children:[(0,n.jsx)("span",{className:"truncate font-mono text-xs text-foreground",children:t.path}),(0,n.jsx)("span",{className:"text-end tabular-nums",children:t.calls.toLocaleString()}),(0,n.jsx)("span",{className:"w-12 text-end tabular-nums text-muted-foreground",children:Ze(t.calls>0?t.totalDurationMs/t.calls:0)}),(0,n.jsx)("span",{className:Be("w-8 text-end tabular-nums",t.errors>0?"text-destructive":"text-muted-foreground"),children:t.errors})]},t.path)}m(Rt,"Rt");function Kt(t){return t.maxDurationMs}m(Kt,"qt");export{ft as a,Gt as b};
|
|
3
|
+
`)},"kt"),Mt=1500,It=m(()=>{let t=(0,S.c)(35),e=$(),s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=tt(),t[0]=s):s=t[0];let a=s,[r,l]=(0,L.useState)(null),o,i;t[1]!==r?(o=m(()=>{if(r===null)return;let C=globalThis.setTimeout(()=>{l(null)},Mt);return()=>{globalThis.clearTimeout(C)}},"l"),i=[r],t[1]=r,t[2]=o,t[3]=i):(o=t[2],i=t[3]),(0,L.useEffect)(o,i);let c;t[4]===Symbol.for("react.memo_cache_sentinel")?(c=m((C,j)=>{at(j)&&l(C)},"c"),t[4]=c):c=t[4];let p=c,d;t[5]===Symbol.for("react.memo_cache_sentinel")?(d=m(()=>{p("config",kt(a))},"d"),t[5]=d):d=t[5];let f=d,u;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=m(()=>{p("prompt",wt(a))},"m"),t[6]=u):u=t[6];let h=u,g;t[7]!==e?(g=e("Connect an AI agent"),t[7]=e,t[8]=g):g=t[8];let x;t[9]!==g?(x=(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:g}),t[9]=g,t[10]=x):x=t[10];let b;t[11]!==e?(b=e("Drive this deployment from an AI agent over the Model Context Protocol \u2014 it can list functions and tables, read schemas, and run read-only queries. Writes stay off unless you opt in."),t[11]=e,t[12]=b):b=t[12];let y;t[13]!==b?(y=(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:b}),t[13]=b,t[14]=y):y=t[14];let k;t[15]!==x||t[16]!==y?(k=(0,n.jsxs)("div",{className:"flex flex-col gap-1.5 p-4",children:[x,y]}),t[15]=x,t[16]=y,t[17]=k):k=t[17];let A;t[18]===Symbol.for("react.memo_cache_sentinel")?(A=(0,n.jsx)("code",{className:"font-mono text-xs text-muted-foreground","data-testid":"home-connect-agent-command",children:"npx -y @lunora/mcp"}),t[18]=A):A=t[18];let w;t[19]!==r||t[20]!==e?(w=e(r==="config"?"Copied":"Copy MCP config"),t[19]=r,t[20]=e,t[21]=w):w=t[21];let v;t[22]!==w?(v=(0,n.jsx)(Ue,{"data-testid":"home-connect-agent-copy-config",onClick:f,size:"xs",variant:"outline",children:w}),t[22]=w,t[23]=v):v=t[23];let M;t[24]!==r||t[25]!==e?(M=e(r==="prompt"?"Copied":"Copy agent prompt"),t[24]=r,t[25]=e,t[26]=M):M=t[26];let I;t[27]!==M?(I=(0,n.jsx)(Ue,{"data-testid":"home-connect-agent-copy-prompt",onClick:h,size:"xs",variant:"outline",children:M}),t[27]=M,t[28]=I):I=t[28];let N;t[29]!==v||t[30]!==I?(N=(0,n.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border bg-muted/50 px-4 py-3",children:[A,(0,n.jsxs)("div",{className:"flex flex-wrap gap-2",children:[v,I]})]}),t[29]=v,t[30]=I,t[31]=N):N=t[31];let _;return t[32]!==k||t[33]!==N?(_=(0,n.jsxs)(T,{className:"gap-0 py-0","data-testid":"home-connect-agent",children:[k,N]}),t[32]=k,t[33]=N,t[34]=_):_=t[34],_},"$t"),Lt=(0,L.lazy)(()=>import("./chunk-7CWPU3LW.js")),Ze=m(t=>{if(t<1e3)return`${String(Math.round(t))}ms`;let e=t>=1e4?0:1;return`${(t/1e3).toFixed(e)}s`},"Ee"),At=m((t,e)=>{let s=Math.max(0,Math.round((e-t)/1e3));if(s<60)return`${String(s)}s ago`;let a=Math.round(s/60);if(a<60)return`${String(a)}m ago`;let r=Math.round(a/60);return r<24?`${String(r)}h ago`:`${String(Math.round(r/24))}d ago`},"Mt"),rt=m((t,e)=>{if(t===void 0||t.length===0)return[];let s=new Map;for(let a of t)s.set(a.bucketMs,(s.get(a.bucketMs)??0)+a[e]);return[...s.entries()].toSorted(([a],[r])=>a-r).map(([,a])=>a)},"He"),lt=m((t,e=!0)=>{if(t.length<4)return null;let s=Math.floor(t.length/2),a=t.slice(0,s).reduce((o,i)=>o+i,0),r=t.slice(s).reduce((o,i)=>o+i,0);if(a===0)return null;let l=(r-a)/a*100;return{positive:e?l>=0:l<=0,text:`${l>=0?"+":""}${l.toFixed(1)}%`}},"Je"),qe=m(t=>{let e=(0,S.c)(24),{delta:s,footer:a,label:r,trend:l,unit:o,value:i}=t,c=$(),p;e[0]!==r?(p=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r}),e[0]=r,e[1]=p):p=e[1];let d;e[2]!==i?(d=(0,n.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:i}),e[2]=i,e[3]=d):d=e[3];let f;e[4]!==o?(f=o!==void 0&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=f):f=e[5];let u;e[6]!==d||e[7]!==f?(u=(0,n.jsxs)("span",{className:"flex items-baseline gap-1.5",children:[d,f]}),e[6]=d,e[7]=f,e[8]=u):u=e[8];let h;e[9]!==l?(h=l!==void 0&&(0,n.jsx)(L.Suspense,{fallback:(0,n.jsx)("div",{"aria-hidden":"true",className:"h-8 w-28"}),children:(0,n.jsx)(Lt,{data:l})}),e[9]=l,e[10]=h):h=e[10];let g;e[11]!==u||e[12]!==h?(g=(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[u,h]}),e[11]=u,e[12]=h,e[13]=g):g=e[13];let x;e[14]!==p||e[15]!==g?(x=(0,n.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[p,g]}),e[14]=p,e[15]=g,e[16]=x):x=e[16];let b;e[17]!==s||e[18]!==a||e[19]!==c?(b=s==null?a!=null&&(0,n.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:a}):(0,n.jsxs)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px]",children:[(0,n.jsx)("span",{className:Be("font-semibold",s.positive?"text-success":"text-destructive"),children:s.text})," ",(0,n.jsx)("span",{className:"text-muted-foreground",children:c("vs. prev.")})]}),e[17]=s,e[18]=a,e[19]=c,e[20]=b):b=e[20];let y;return e[21]!==x||e[22]!==b?(y=(0,n.jsxs)(T,{className:"justify-between gap-0 py-0",children:[x,b]}),e[21]=x,e[22]=b,e[23]=y):y=e[23],y},"Oe"),Ct=m(()=>{let t=(0,S.c)(1),e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:(0,n.jsx)("path",{d:"m9 6 6 6-6 6"})}),t[0]=e):e=t[0],e},"At"),Je=m(t=>{let e=(0,S.c)(7),{command:s,label:a}=t,r;e[0]!==a?(r=(0,n.jsx)("div",{className:"p-4",children:(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:a})}),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==s?(l=(0,n.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5",children:(0,n.jsx)("code",{className:"font-mono text-xs text-muted-foreground",children:s})}),e[2]=s,e[3]=l):l=e[3];let o;return e[4]!==r||e[5]!==l?(o=(0,n.jsxs)(T,{className:"justify-between gap-0 py-0",children:[r,l]}),e[4]=r,e[5]=l,e[6]=o):o=e[6],o},"De"),ot=m(t=>{let e=(0,S.c)(18),{count:s,onView:a,testId:r,title:l}=t,o=$(),i;e[0]!==l?(i=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=i):i=e[1];let c;e[2]!==s||e[3]!==o?(c=s===null?(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:o("No data yet")}):(0,n.jsx)(Fe,{variant:s>0?"destructive":"success",children:s>0?s:o("All clear")}),e[2]=s,e[3]=o,e[4]=c):c=e[4];let p;e[5]!==i||e[6]!==c?(p=(0,n.jsxs)("div",{className:"flex items-start justify-between gap-2 p-4",children:[i,c]}),e[5]=i,e[6]=c,e[7]=p):p=e[7];let d;e[8]!==o?(d=o("View"),e[8]=o,e[9]=d):d=e[9];let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=(0,n.jsx)(Ct,{}),e[10]=f):f=e[10];let u;e[11]!==a||e[12]!==d?(u=(0,n.jsxs)("button",{className:"flex items-center gap-1 border-t border-border bg-muted/50 px-4 py-2.5 text-[12px] font-medium text-foreground outline-none transition-colors hover:bg-muted focus-visible:bg-muted",onClick:a,type:"button",children:[d,f]}),e[11]=a,e[12]=d,e[13]=u):u=e[13];let h;return e[14]!==p||e[15]!==u||e[16]!==r?(h=(0,n.jsxs)(T,{className:"justify-between gap-0 py-0","data-testid":r,children:[p,u]}),e[14]=p,e[15]=u,e[16]=r,e[17]=h):h=e[17],h},"Ge"),$t=m(t=>{let e=(0,S.c)(7),{functions:s}=t,a=$(),r;if(e[0]!==s||e[1]!==a){let l=[...s].toSorted(qt).slice(0,5),o;e[3]!==a?(o=a("Top functions"),e[3]=a,e[4]=o):o=e[4];let i;e[5]!==o?(i=(0,n.jsx)("div",{className:"border-b border-border px-4 py-3",children:(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o})}),e[5]=o,e[6]=i):i=e[6],r=(0,n.jsxs)(T,{className:"gap-0 py-0","data-testid":"home-top-functions",children:[i,l.length===0?(0,n.jsx)("p",{className:"px-4 py-8 text-center text-xs text-muted-foreground",children:a("No functions called yet.")}):(0,n.jsxs)("div",{className:"divide-y divide-border",children:[(0,n.jsxs)("div",{className:"grid grid-cols-[1fr_auto_auto_auto] gap-4 px-4 py-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:[(0,n.jsx)("span",{children:a("Function")}),(0,n.jsx)("span",{className:"text-end",children:a("Calls")}),(0,n.jsx)("span",{className:"w-12 text-end",children:a("Avg")}),(0,n.jsx)("span",{className:"w-8 text-end",children:a("Err")})]}),l.map(Rt)]})]}),e[0]=s,e[1]=a,e[2]=r}else r=e[2];return r},"Ct"),jt=m(t=>{let e=(0,S.c)(26),{subs:s}=t,a=$(),r;e[0]!==a?(r=a("Live connections"),e[0]=a,e[1]=r):r=e[1];let l;e[2]!==r?(l=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r}),e[2]=r,e[3]=l):l=e[3];let o=s?.totalConnections??0,i;e[4]!==o?(i=o.toLocaleString(),e[4]=o,e[5]=i):i=e[5];let c;e[6]!==i?(c=(0,n.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:i}),e[6]=i,e[7]=c):c=e[7];let p;e[8]!==a?(p=a("sockets"),e[8]=a,e[9]=p):p=e[9];let d;e[10]!==p?(d=(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:p}),e[10]=p,e[11]=d):d=e[11];let f;e[12]!==c||e[13]!==d?(f=(0,n.jsxs)("span",{className:"flex items-baseline gap-1.5",children:[c,d]}),e[12]=c,e[13]=d,e[14]=f):f=e[14];let u=s?.totalSubscriptions??0,h;e[15]!==u?(h=u.toLocaleString(),e[15]=u,e[16]=h):h=e[16];let g;e[17]!==a?(g=a("active subscriptions"),e[17]=a,e[18]=g):g=e[18];let x;e[19]!==h||e[20]!==g?(x=(0,n.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:[h," ",g]}),e[19]=h,e[20]=g,e[21]=x):x=e[21];let b;return e[22]!==x||e[23]!==l||e[24]!==f?(b=(0,n.jsx)(T,{"data-testid":"home-live-connections",children:(0,n.jsxs)(He,{className:"flex flex-col gap-2.5 py-4",children:[l,f,x]})}),e[22]=x,e[23]=l,e[24]=f,e[25]=b):b=e[25],b},"It"),Tt=m(t=>{let e=(0,S.c)(7),{entries:s}=t,a=$(),r;if(e[0]!==s||e[1]!==a){let l=Date.now(),o;e[3]!==a?(o=a("Recent activity"),e[3]=a,e[4]=o):o=e[4];let i;e[5]!==o?(i=(0,n.jsx)("div",{className:"border-b border-border px-4 py-3",children:(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o})}),e[5]=o,e[6]=i):i=e[6],r=(0,n.jsxs)(T,{className:"gap-0 py-0","data-testid":"home-recent-activity",children:[i,s.length===0?(0,n.jsx)("p",{className:"px-4 py-8 text-center text-xs text-muted-foreground",children:a("No recent activity.")}):(0,n.jsx)("ul",{className:"divide-y divide-border",children:s.slice(0,5).map(c=>(0,n.jsxs)("li",{className:"flex items-center justify-between gap-3 px-4 py-2 text-[13px]",children:[(0,n.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,n.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-muted-foreground/40"}),(0,n.jsxs)("span",{className:"truncate text-foreground",children:[c.op,c.table!==void 0&&(0,n.jsxs)("span",{className:"text-muted-foreground",children:[" \xB7 ",c.table,c.id===void 0?"":`#${c.id}`]})]})]}),(0,n.jsx)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:At(c.ts,l)})]},c.seq))})]}),e[0]=s,e[1]=a,e[2]=r}else r=e[2];return r},"Tt"),Ot=m(t=>{let e=t.reduce((s,a)=>s+a.calls,0);return e===0?null:t.reduce((s,a)=>s+a.totalDurationMs,0)/e},"jt"),Gt=m(t=>{let e=(0,S.c)(151),{initialShardKey:s}=t,a=$(),r=Ee(),l=s??"",o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={},e[0]=o):o=e[0];let i;e[1]!==l?(i={shardKey:l},e[1]=l,e[2]=i):i=e[2];let c=ke(D.getMetrics,o,i),p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p={},e[3]=p):p=e[3];let d;e[4]!==l?(d={shardKey:l},e[4]=l,e[5]=d):d=e[5];let f=ke(D.getFunctionStats,p,d),u,h;e[6]===Symbol.for("react.memo_cache_sentinel")?(u={},h={shardKey:""},e[6]=u,e[7]=h):(u=e[6],h=e[7]);let g=ke(D.getSecurityAudit,u,h),x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x={},e[8]=x):x=e[8];let b;e[9]!==l?(b={shardKey:l},e[9]=l,e[10]=b):b=e[10];let y=ke(D.listSubscriptions,x,b),k;e[11]===Symbol.for("react.memo_cache_sentinel")?(k={},e[11]=k):k=e[11];let A;e[12]!==l?(A={shardKey:l},e[12]=l,e[13]=A):A=e[13];let w=ke(D.getAuditLog,k,A),v=c.data??null,M,I,N,_,C,j,P,O,q,V,W,E,R,K,B,F,U,H;if(e[14]!==w.data||e[15]!==g.data||e[16]!==v||e[17]!==c.data||e[18]!==r||e[19]!==f.data||e[20]!==y.data||e[21]!==a){_=Array.isArray(f.data?.functions)?f.data.functions:[],P=y.data??null;let Le;e[40]!==w.data?(Le=Array.isArray(w.data?.entries)?w.data.entries:[],e[40]=w.data,e[41]=Le):Le=e[41],I=Le,C=c.data===void 0||f.data===void 0?null:nt(v,_).length,j=Array.isArray(g.data?.findings)?g.data.findings.length:null;let Ae;e[42]!==r?(Ae=m(()=>{Se(r({to:"/security"}))},"Me"),e[42]=r,e[43]=Ae):Ae=e[43],H=Ae;let Ce;e[44]!==r?(Ce=m(()=>{Se(r({to:"/insights"}))},"Ae"),e[44]=r,e[45]=Ce):Ce=e[45],U=Ce;let $e=rt(v?.history,"calls"),je=rt(v?.history,"errors"),Ge=Ot(_),Te=Math.max(0,..._.map(Kt)),z=v?.cache,Oe;e[46]!==z?(Oe=z!=null&&z.hits+z.misses>0?Math.round(z.hits/(z.hits+z.misses)*100):null,e[46]=z,e[47]=Oe):Oe=e[47],N=Oe,B="flex flex-col gap-6",F="lunora-home",W="grid gap-3 sm:grid-cols-2 xl:grid-cols-4",E="home-health";let Ke=lt($e),ye;e[48]!==a?(ye=a("Requests"),e[48]=a,e[49]=ye):ye=e[49];let ze=v?.requests??0,ve;e[50]!==ze?(ve=ze.toLocaleString(),e[50]=ze,e[51]=ve):ve=e[51],e[52]!==$e||e[53]!==Ke||e[54]!==ye||e[55]!==ve?(R=(0,n.jsx)(qe,{delta:Ke,label:ye,trend:$e,value:ve}),e[52]=$e,e[53]=Ke,e[54]=ye,e[55]=ve,e[56]=R):R=e[56];let De=lt(je,!1),Ne;e[57]!==a?(Ne=a("Errors"),e[57]=a,e[58]=Ne):Ne=e[58];let Pe=v?.errors??0,_e;e[59]!==Pe?(_e=Pe.toLocaleString(),e[59]=Pe,e[60]=_e):_e=e[60],e[61]!==je||e[62]!==De||e[63]!==Ne||e[64]!==_e?(K=(0,n.jsx)(qe,{delta:De,label:Ne,trend:je,value:_e}),e[61]=je,e[62]=De,e[63]=Ne,e[64]=_e,e[65]=K):K=e[65],M=qe,e[66]!==Te||e[67]!==a?(O=Te>0?`${a("max")} ${Ze(Te)}`:void 0,e[66]=Te,e[67]=a,e[68]=O):O=e[68],e[69]!==a?(q=a("Avg latency"),e[69]=a,e[70]=q):q=e[70],V=Ge===null?"\u2014":Ze(Ge),e[14]=w.data,e[15]=g.data,e[16]=v,e[17]=c.data,e[18]=r,e[19]=f.data,e[20]=y.data,e[21]=a,e[22]=M,e[23]=I,e[24]=N,e[25]=_,e[26]=C,e[27]=j,e[28]=P,e[29]=O,e[30]=q,e[31]=V,e[32]=W,e[33]=E,e[34]=R,e[35]=K,e[36]=B,e[37]=F,e[38]=U,e[39]=H}else M=e[22],I=e[23],N=e[24],_=e[25],C=e[26],j=e[27],P=e[28],O=e[29],q=e[30],V=e[31],W=e[32],E=e[33],R=e[34],K=e[35],B=e[36],F=e[37],U=e[38],H=e[39];let J;e[71]!==M||e[72]!==O||e[73]!==q||e[74]!==V?(J=(0,n.jsx)(M,{footer:O,label:q,value:V}),e[71]=M,e[72]=O,e[73]=q,e[74]=V,e[75]=J):J=e[75];let Z;e[76]!==N||e[77]!==a?(Z=N===null?void 0:`${String(N)}% ${a("cache hit")}`,e[76]=N,e[77]=a,e[78]=Z):Z=e[78];let G;e[79]!==a?(G=a("Database size"),e[79]=a,e[80]=G):G=e[80];let Re=v?.databaseSize??null,Y;e[81]!==Re?(Y=et(Re),e[81]=Re,e[82]=Y):Y=e[82];let Q;e[83]!==Z||e[84]!==G||e[85]!==Y?(Q=(0,n.jsx)(qe,{footer:Z,label:G,value:Y}),e[83]=Z,e[84]=G,e[85]=Y,e[86]=Q):Q=e[86];let X;e[87]!==W||e[88]!==E||e[89]!==R||e[90]!==K||e[91]!==J||e[92]!==Q?(X=(0,n.jsxs)("div",{className:W,"data-testid":E,children:[R,K,J,Q]}),e[87]=W,e[88]=E,e[89]=R,e[90]=K,e[91]=J,e[92]=Q,e[93]=X):X=e[93];let we;e[94]===Symbol.for("react.memo_cache_sentinel")?(we=(0,n.jsx)(bt,{}),e[94]=we):we=e[94];let ee;e[95]!==_?(ee=(0,n.jsx)("div",{className:"lg:col-span-2",children:(0,n.jsx)($t,{functions:_})}),e[95]=_,e[96]=ee):ee=e[96];let te;e[97]!==P?(te=(0,n.jsx)(jt,{subs:P}),e[97]=P,e[98]=te):te=e[98];let ae;e[99]!==I?(ae=(0,n.jsx)(Tt,{entries:I}),e[99]=I,e[100]=ae):ae=e[100];let ne;e[101]!==te||e[102]!==ae?(ne=(0,n.jsxs)("div",{className:"flex flex-col gap-3",children:[te,ae]}),e[101]=te,e[102]=ae,e[103]=ne):ne=e[103];let se;e[104]!==ee||e[105]!==ne?(se=(0,n.jsxs)("div",{className:"grid gap-3 lg:grid-cols-3",children:[ee,ne]}),e[104]=ee,e[105]=ne,e[106]=se):se=e[106];let re;e[107]!==a?(re=a("Advisors"),e[107]=a,e[108]=re):re=e[108];let le;e[109]!==re?(le=(0,n.jsx)("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:re}),e[109]=re,e[110]=le):le=e[110];let oe;e[111]!==C||e[112]!==j||e[113]!==a||e[114]!==U||e[115]!==H?(oe=j===0&&C===0?(0,n.jsx)(Ye,{description:a("No security or performance issues detected."),icon:(0,n.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,n.jsx)("path",{d:"M12 3 4 6v5c0 5 3.4 8.5 8 10 4.6-1.5 8-5 8-10V6l-8-3Z"}),(0,n.jsx)("path",{d:"m9 12 2 2 4-4"})]}),testId:"home-advisors-clear",title:a("No issues found")}):(0,n.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,n.jsx)(ot,{count:j,onView:H,testId:"home-security",title:a("Security findings")}),(0,n.jsx)(ot,{count:C,onView:U,testId:"home-performance",title:a("Performance issues")})]}),e[111]=C,e[112]=j,e[113]=a,e[114]=U,e[115]=H,e[116]=oe):oe=e[116];let ie;e[117]!==le||e[118]!==oe?(ie=(0,n.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"home-advisors",children:[le,oe]}),e[117]=le,e[118]=oe,e[119]=ie):ie=e[119];let ce;e[120]!==a?(ce=a("Get connected"),e[120]=a,e[121]=ce):ce=e[121];let de;e[122]!==ce?(de=(0,n.jsx)("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:ce}),e[122]=ce,e[123]=de):de=e[123];let me;e[124]!==a?(me=a("Client SDK"),e[124]=a,e[125]=me):me=e[125];let ue;e[126]!==me?(ue=(0,n.jsx)(Je,{command:"npm i @lunora/client",label:me}),e[126]=me,e[127]=ue):ue=e[127];let pe;e[128]!==a?(pe=a("React"),e[128]=a,e[129]=pe):pe=e[129];let fe;e[130]!==pe?(fe=(0,n.jsx)(Je,{command:"npm i @lunora/react",label:pe}),e[130]=pe,e[131]=fe):fe=e[131];let he;e[132]!==a?(he=a("CLI"),e[132]=a,e[133]=he):he=e[133];let ge;e[134]!==he?(ge=(0,n.jsx)(Je,{command:"lunora dev",label:he}),e[134]=he,e[135]=ge):ge=e[135];let xe;e[136]!==ue||e[137]!==fe||e[138]!==ge?(xe=(0,n.jsxs)("div",{className:"grid gap-3 sm:grid-cols-3",children:[ue,fe,ge]}),e[136]=ue,e[137]=fe,e[138]=ge,e[139]=xe):xe=e[139];let Me;e[140]===Symbol.for("react.memo_cache_sentinel")?(Me=(0,n.jsx)(It,{}),e[140]=Me):Me=e[140];let be;e[141]!==de||e[142]!==xe?(be=(0,n.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"home-get-connected",children:[de,xe,Me]}),e[141]=de,e[142]=xe,e[143]=be):be=e[143];let Ie;return e[144]!==B||e[145]!==F||e[146]!==X||e[147]!==se||e[148]!==ie||e[149]!==be?(Ie=(0,n.jsxs)("div",{className:B,"data-testid":F,children:[X,we,se,ie,be]}),e[144]=B,e[145]=F,e[146]=X,e[147]=se,e[148]=ie,e[149]=be,e[150]=Ie):Ie=e[150],Ie},"Zt");function qt(t,e){return e.calls-t.calls}m(qt,"Ot");function Rt(t){return(0,n.jsxs)("div",{className:"grid grid-cols-[1fr_auto_auto_auto] items-center gap-4 px-4 py-2 text-[13px]",children:[(0,n.jsx)("span",{className:"truncate font-mono text-xs text-foreground",children:t.path}),(0,n.jsx)("span",{className:"text-end tabular-nums",children:t.calls.toLocaleString()}),(0,n.jsx)("span",{className:"w-12 text-end tabular-nums text-muted-foreground",children:Ze(t.calls>0?t.totalDurationMs/t.calls:0)}),(0,n.jsx)("span",{className:Be("w-8 text-end tabular-nums",t.errors>0?"text-destructive":"text-muted-foreground"),children:t.errors})]},t.path)}m(Rt,"Rt");function Kt(t){return t.maxDurationMs}m(Kt,"qt");export{ft as a,Gt as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Y}from"./chunk-AREBQI6D.js";import{a as V}from"./chunk-3CWGJYBB.js";import{a as G}from"./chunk-RMN2JN4S.js";import{b as Q}from"./chunk-GRL5MG3Z.js";import{a as z}from"./chunk-SFDOII3B.js";import{e as P}from"./chunk-SMIESS7P.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{b as Z,c as ee}from"./chunk-
|
|
1
|
+
import{a as Y}from"./chunk-AREBQI6D.js";import{a as V}from"./chunk-3CWGJYBB.js";import{a as G}from"./chunk-RMN2JN4S.js";import{b as Q}from"./chunk-GRL5MG3Z.js";import{a as z}from"./chunk-SFDOII3B.js";import{e as P}from"./chunk-SMIESS7P.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{b as Z,c as ee}from"./chunk-PLFTCTMX.js";import{a as _,b as W}from"./chunk-2KRXOCZ2.js";import{c as U}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import"./chunk-NCKRVNF2.js";import"./chunk-XXQUMVWH.js";import"./chunk-NJRW66LJ.js";import"./chunk-QLQADHFE.js";import{a as I}from"./chunk-VDW32UET.js";import{c as M}from"./chunk-6F7KP54M.js";import{f as B}from"./chunk-C2ZFQARQ.js";import"./chunk-XBDKZZ67.js";import"./chunk-WJQLNYGX.js";import"./chunk-WQH3LT2P.js";import{d as A,f as H,g as K,o as k}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as l,e as L,f as fe,g as he,h as me}from"./chunk-3XIESWL4.js";var j=L(he(),1);var u=L(fe(),1);var $=L(me(),1);var pe=l(t=>{let{suggestedIndex:e,table:r}=t;return!(typeof r!="string"||r.length===0||typeof e!="object"||e===null||!Array.isArray(e.fields)||e.fields.length===0)},"pe"),be=l((t,e,r)=>{let a=`"${t}"`,n=`"${e}"`,o=r.map(c=>`"${c}"`).join(", ");return`CREATE INDEX IF NOT EXISTS ${n} ON ${a} (${o});`},"ge"),ge=l(t=>{let e=(0,j.c)(19),{fields:r,indexName:a,table:n,testId:o}=t,c=A(),[T,p]=(0,u.useState)(!1),f;e[0]!==r||e[1]!==a||e[2]!==n?(f=l(()=>{let S="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if(S===void 0)return;let y=be(n,a,r);k(S.writeText(y)),p(!0)},"d"),e[0]=r,e[1]=a,e[2]=n,e[3]=f):f=e[3];let v=f;if(T){let S=`${o}-applied`,y;e[4]!==c?(y=c("CREATE INDEX SQL copied to clipboard."),e[4]=c,e[5]=y):y=e[5];let E;return e[6]!==S||e[7]!==y?(E=(0,$.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":S,children:y}),e[6]=S,e[7]=y,e[8]=E):E=e[8],E}let w;e[9]!==c?(w=c("Apply?"),e[9]=c,e[10]=w):w=e[10];let h;e[11]!==c||e[12]!==n?(h=c("Apply index on {table}",{table:n}),e[11]=c,e[12]=n,e[13]=h):h=e[13];let x;return e[14]!==v||e[15]!==w||e[16]!==h||e[17]!==o?(x=(0,$.jsx)(Y,{confirmLabel:w,onConfirm:v,testId:o,children:h}),e[14]=v,e[15]=w,e[16]=h,e[17]=o,e[18]=x):x=e[18],x},"be"),ve=l((t,e)=>{let r=new Map;for(let a of e){let n=`${a.table} ${a.index}`;r.set(n,(r.get(n)??0)+a.reads)}return t.map(a=>({index:a.index,reads:r.get(`${a.table} ${a.index}`)??0,table:a.table}))},"xe"),xe=l(t=>{let e=new Map;for(let r of t)for(let a of r.scannedTables??[])e.set(a.table,(e.get(a.table)??0)+a.scans);return[...e].map(([r,a])=>({scans:a,table:r}))},"ye"),te=l((t,e)=>e.map(r=>({index:r.name,table:t})),"X"),ye=l(t=>{let e=ve(t.declaredIndexes??[],t.indexHits??[]),r=xe(t.functions??[]),a=t.shardTraffic??[],n=t.analyticsMetrics,o=n&&n.indexHits.length>0?n.indexHits:e,c=n&&n.tableScans.length>0?n.tableScans:r,T=n&&n.shardTraffic.length>0?n.shardTraffic:a,p=ee({indexHits:o,schema:{tables:[]},shardTraffic:T,tableScans:c},{lints:Z,source:"runtime"}),f=t.suppressHotScanTables;return(f===void 0?p:p.filter(v=>!(v.metadata.kind==="hot_scan"&&typeof v.metadata.table=="string"&&f.has(v.metadata.table)))).map(v=>_(v))},"ve"),we=H(I.listTables),Se=H(I.listTableIndexes),Te=H(I.listTablesIndexes),q=l(t=>`${(t*100).toFixed(1)}%`,"K"),ae=l(t=>`${(t/1e3).toFixed(2)}s`,"B"),$e=l(t=>{if(t.length<=1)return t[0]??"";let e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},"Te"),Ie=l((t,e)=>({"high-error-rate":t("High error rate"),"high-evictions":t("High cache eviction rate"),"high-write-contention":t("High write contention"),"low-cache-hit-rate":t("Low cache hit rate"),"missing-index":t("Missing index"),"slow-function":t("Slow function")})[e.kind],"Ie"),ne=l((t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:q(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict \u2014 consider sharding to cut contention.",{rate:q(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:q(e.value)}),"missing-index":t("Slowest call took {duration} \u2014 it full-scanned {tables} with no index.",{duration:ae(e.value),tables:$e(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:ae(e.value)})})[e.kind],"J"),Ee=l(t=>{let e=(0,j.c)(10),{onJump:r,table:a}=t,n=A(),o;e[0]!==r||e[1]!==a?(o=l(()=>{r(a)},"o"),e[0]=r,e[1]=a,e[2]=o):o=e[2];let c=o,T=`in-add-index-${a}`,p;e[3]!==n||e[4]!==a?(p=n("Add index on {table}",{table:a}),e[3]=n,e[4]=a,e[5]=p):p=e[5];let f;return e[6]!==c||e[7]!==T||e[8]!==p?(f=(0,$.jsx)(U,{"data-testid":T,onClick:c,size:"sm",type:"button",variant:"outline",children:p}),e[6]=c,e[7]=T,e[8]=p,e[9]=f):f=e[9],f},"Ee"),De=l(({initialShardKey:t,loadShardTraffic:e})=>{let r=B(),a=P(),n=A(),{queryShardKey:o,setShardKey:c,shardKey:T}=V(t),[p,f]=(0,u.useState)(null),[v,w]=(0,u.useState)(null),h=(0,u.useRef)(""),x=M(I.getMetrics,{},{live:!0,shardKey:o}),S=M(I.getFunctionStats,{},{live:!0,shardKey:o}),y=M(I.getAdvisories,{},{live:!0,shardKey:o}),E=x.data??null,F=S.data?.functions??null,O=y.data?.advisories??null,re=x.data?.indexHits??null,R=x.error!==null&&S.error!==null?x.error:null,se=e??(s=>r.shardTraffic(s)),ie=l(async(s,b)=>{let i=s[0];if(i===void 0||i===""){h.current===b&&w(null);return}try{let m=await se(i);if(h.current!==b)return;let d=new Map;for(let g of m.shards)d.has(g.shardKey)||d.set(g.shardKey,{requests:g.requests,shardKey:g.shardKey});w([...d.values()])}catch{h.current===b&&w(null)}},"V"),oe=l(async(s,b)=>{let i=await Promise.allSettled(s.map(async d=>[d,await r.query(Se,{table:d},K(b))])),m=[];for(let d of i)if(d.status==="fulfilled"){let[g,N]=d.value;m.push(...te(g,N.indexes))}return m},"G"),D=(0,u.useEffectEvent)(async s=>{h.current=s;let b=[];try{let i=await r.query(we,{},K(s));if(h.current!==s)return;Q(s),b=i.map(d=>d.name);let m=[];if(b.length>0)try{let d=await r.query(Te,{tables:b},K(s));if(h.current!==s)return;for(let[g,N]of Object.entries(d.indexesByTable))m.push(...te(g,N))}catch{if(m=await oe(b,s),h.current!==s)return}f(m)}catch{h.current===s&&f(null)}await ie(b,s)});(0,u.useEffect)(()=>{k(D(o))},[o]);let le=(0,u.useEffectEvent)(()=>{x.refetch(),S.refetch(),y.refetch(),k(D(o))});(0,u.useEffect)(()=>{let s=l(()=>{document.visibilityState==="visible"&&le()},"i");return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s)}},[]);let J=(0,u.useCallback)(s=>{k(a({search:{table:s},to:"/schema"}))},[a]),C=z(E,F),ce=new Set(C.filter(s=>s.kind==="missing-index").flatMap(s=>s.tables??[])),X=ye({declaredIndexes:p??[],functions:F,indexHits:re,shardTraffic:v,suppressHotScanTables:ce}),de=(0,u.useMemo)(()=>{let s=C.map(i=>{let m=i.kind==="missing-index"?i.tables??[]:[];return{action:m.length>0?m.map(d=>(0,$.jsx)(Ee,{onJump:J,table:d},d)):void 0,description:i.message===void 0?ne(n,i):`${ne(n,i)} \u2014 ${i.message}`,entity:i.fn,issueType:Ie(n,i),key:`${i.kind}:${i.fn??""}`,level:i.severity}}),b=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(O??[]).map(i=>{let m=_(i);if(b.has(i.name)&&pe(i.metadata)){let{table:d,suggestedIndex:g}=i.metadata,N=`in-apply-index-${d}-${g.name}`;return{...m,action:(0,$.jsx)(ge,{fields:g.fields,indexName:g.name,table:d,testId:N})}}return m}),...X,...s]},[O,C,J,X,n]),ue=(0,$.jsx)(G,{onChange:c,testId:"in-shard-input",value:T});return(0,$.jsx)(W,{error:R,errorSource:R===null?void 0:x.errorSource,rows:de,testId:"lunora-insights",toolbar:ue})},"Je");export{De as InsightsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as W}from"./chunk-54MMVNPT.js";import{a as F}from"./chunk-3CWGJYBB.js";import{a as E}from"./chunk-RMN2JN4S.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as y}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as L}from"./chunk-
|
|
1
|
+
import{a as W}from"./chunk-54MMVNPT.js";import{a as F}from"./chunk-3CWGJYBB.js";import{a as E}from"./chunk-RMN2JN4S.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as y}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as L}from"./chunk-NCKRVNF2.js";import"./chunk-XXQUMVWH.js";import"./chunk-NJRW66LJ.js";import"./chunk-QLQADHFE.js";import{a as D}from"./chunk-VDW32UET.js";import{c as _}from"./chunk-6F7KP54M.js";import"./chunk-C2ZFQARQ.js";import"./chunk-XBDKZZ67.js";import{a as T}from"./chunk-XQCVZAGU.js";import{a as O,b as P,c as U,d as w,e as h,f as p}from"./chunk-WJQLNYGX.js";import{a as $,e as j}from"./chunk-WQH3LT2P.js";import{d as M}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as S,e as A,g as R,h as Z}from"./chunk-3XIESWL4.js";var B=A(R(),1);var t=A(Z(),1);var q=80,z=S(a=>{if(a===void 0)return"";let e=JSON.stringify(a);return e.length>q?`${e.slice(0,q)}\u2026`:e},"W"),G=S(a=>{let e=[];for(let r of a){let n=r.id.toString();if(r.subscriptions.length===0){e.push({admin:r.admin,connectionId:r.id,key:`c${n}`,subscription:null});continue}r.subscriptions.forEach((l,i)=>{e.push({admin:r.admin,connectionId:r.id,key:`c${n}-s${i.toString()}`,subscription:l})})}return e},"B"),C=(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),oe=S(a=>{let e=(0,B.c)(22),{initialShardKey:r}=a,n=M(),{queryShardKey:l,setShardKey:i,shardKey:m}=F(r),f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={},e[0]=f):f=e[0];let b;e[1]!==l?(b={keepPreviousData:!0,shardKey:l},e[1]=l,e[2]=b):b=e[2];let{data:s,error:o,errorSource:u,refetch:J}=_(D.listSubscriptions,f,b);W(J,!0);let x;if(e[3]!==o||e[4]!==u||e[5]!==s||e[6]!==i||e[7]!==m||e[8]!==n){let k=s===void 0?[]:G(s.connections),c;e[10]!==i||e[11]!==m?(c=(0,t.jsx)(E,{onChange:i,testId:"subs-shard-input",value:m}),e[10]=i,e[11]=m,e[12]=c):c=e[12];let d;e[13]!==s||e[14]!==n?(d=s!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[(0,t.jsx)(y,{variant:"secondary",children:n("{count} connections",{count:s.totalConnections})}),(0,t.jsx)(y,{variant:"secondary",children:n("{count} subscriptions",{count:s.totalSubscriptions})})]}),e[13]=s,e[14]=n,e[15]=d):d=e[15];let g;e[16]!==c||e[17]!==d?(g=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,d]}),e[16]=c,e[17]=d,e[18]=g):g=e[18];let v;e[19]!==o||e[20]!==u?(v=o!==null&&(0,t.jsx)(L,{error:u,testId:"subs-error"}),e[19]=o,e[20]=u,e[21]=v):v=e[21],x=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[g,v,o===null&&s!==void 0&&k.length===0&&(0,t.jsx)(T,{description:n("Active WebSocket subscriptions on this shard."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),o===null&&k.length>0&&(0,t.jsx)($,{className:"overflow-hidden py-0",children:(0,t.jsx)(j,{className:"px-0",children:(0,t.jsxs)(O,{"data-testid":"subs-table",children:[(0,t.jsx)(P,{children:(0,t.jsxs)(w,{children:[(0,t.jsx)(h,{children:n("Connection")}),(0,t.jsx)(h,{children:n("Function path")}),(0,t.jsx)(h,{children:n("Table")}),(0,t.jsx)(h,{children:n("Arguments")})]})}),(0,t.jsx)(U,{children:k.map(N=>{let{subscription:I}=N,K=z(I?.args);return(0,t.jsxs)(w,{"data-testid":"subs-row",children:[(0,t.jsx)(p,{className:"font-medium tabular-nums",children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:["#",N.connectionId,N.admin&&(0,t.jsx)(y,{variant:"outline",children:n("admin")})]})}),(0,t.jsx)(p,{className:"font-mono text-xs",children:I?.functionPath??C}),(0,t.jsx)(p,{children:I?.table??C}),(0,t.jsx)(p,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:K||void 0,children:K||C})]},N.key)})})]})})})]}),e[3]=o,e[4]=u,e[5]=s,e[6]=i,e[7]=m,e[8]=n,e[9]=x}else x=e[9];return x},"oe");export{oe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as de}from"./chunk-
|
|
1
|
+
import{a as de}from"./chunk-ATLV7KWK.js";import"./chunk-OQIGV6FX.js";import"./chunk-4UOFSGUS.js";import"./chunk-CZZWYUTR.js";import{d as Y,f as ee}from"./chunk-7T7UOTYK.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as T}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as te}from"./chunk-XXQUMVWH.js";import{a as X}from"./chunk-VDW32UET.js";import{f as F}from"./chunk-C2ZFQARQ.js";import"./chunk-XBDKZZ67.js";import{a as H}from"./chunk-XQCVZAGU.js";import{a as Q,b as U,c as D,e as V}from"./chunk-WQH3LT2P.js";import{d as A,f as Z,g as G,h as J,o as P}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as k,e as O,f as ae,g as le,h as se}from"./chunk-3XIESWL4.js";var W=O(le(),1),I=O(ae(),1);var s=O(se(),1);var re=Z(X.runSql),ie=k((_,e)=>{let t=(0,W.c)(11),m=F(),[d,a]=(0,I.useState)(void 0),[r,l]=(0,I.useState)(void 0),[o,E]=(0,I.useState)(!0),c;t[0]!==m||t[1]!==e||t[2]!==_?(c=k(async u=>{E(!0);try{let N=await m.query(re,{sql:_},G(e));u.cancelled||(a(N),l(void 0))}catch(N){let $=N;u.cancelled||(a(void 0),l(J($)))}u.cancelled||E(!1)},"n"),t[0]=m,t[1]=e,t[2]=_,t[3]=c):c=t[3];let C=c,y,K;t[4]!==C?(y=k(()=>{let u={cancelled:!1};return P(C(u)),()=>{u.cancelled=!0}},"y"),K=[C],t[4]=C,t[5]=y,t[6]=K):(y=t[5],K=t[6]),(0,I.useEffect)(y,K);let h;return t[7]!==r||t[8]!==o||t[9]!==d?(h={error:r,loading:o,result:d},t[7]=r,t[8]=o,t[9]=d,t[10]=h):h=t[10],h},"re"),oe="lunora-studio-dashboards",B={shardKey:"",sql:"",title:""},ne=k(_=>{let e=(0,W.c)(54),{onEdit:t,onRemove:m,widget:d}=_,a=A(),{error:r,loading:l,result:o}=ie(d.sql,d.shardKey??""),E;e[0]!==t||e[1]!==d.id?(E=k(()=>{t(d.id)},"$"),e[0]=t,e[1]=d.id,e[2]=E):E=e[2];let c=E,C;e[3]!==m||e[4]!==d.id?(C=k(()=>{m(d.id)},"k"),e[3]=m,e[4]=d.id,e[5]=C):C=e[5];let y=C,K=`dashboards-widget-${d.id}`,h;e[6]!==d.title?(h=(0,s.jsx)(D,{className:"min-w-0 truncate",title:d.title,children:d.title}),e[6]=d.title,e[7]=h):h=e[7];let u;e[8]!==a?(u=a("Edit widget"),e[8]=a,e[9]=u):u=e[9];let N=`dashboards-widget-edit-${d.id}`,$;e[10]!==a?($=a("Edit widget"),e[10]=a,e[11]=$):$=e[11];let L;e[12]===Symbol.for("react.memo_cache_sentinel")?(L=(0,s.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"})}),e[12]=L):L=e[12];let S;e[13]!==c||e[14]!==u||e[15]!==N||e[16]!==$?(S=(0,s.jsx)(T,{"aria-label":u,"data-testid":N,onClick:c,size:"icon-xs",title:$,type:"button",variant:"ghost",children:L}),e[13]=c,e[14]=u,e[15]=N,e[16]=$,e[17]=S):S=e[17];let x;e[18]!==a?(x=a("Remove widget"),e[18]=a,e[19]=x):x=e[19];let j=`dashboards-widget-remove-${d.id}`,g;e[20]!==a?(g=a("Remove widget"),e[20]=a,e[21]=g):g=e[21];let w;e[22]===Symbol.for("react.memo_cache_sentinel")?(w=(0,s.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[22]=w):w=e[22];let b;e[23]!==y||e[24]!==x||e[25]!==j||e[26]!==g?(b=(0,s.jsx)(T,{"aria-label":x,"data-testid":j,onClick:y,size:"icon-xs",title:g,type:"button",variant:"ghost",children:w}),e[23]=y,e[24]=x,e[25]=j,e[26]=g,e[27]=b):b=e[27];let f;e[28]!==b||e[29]!==S?(f=(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[S,b]}),e[28]=b,e[29]=S,e[30]=f):f=e[30];let p;e[31]!==f||e[32]!==h?(p=(0,s.jsxs)(U,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[h,f]}),e[31]=f,e[32]=h,e[33]=p):p=e[33];let v;e[34]!==r||e[35]!==d.id?(v=r!==void 0&&(0,s.jsx)(te,{className:"font-mono text-xs",testId:`dashboards-widget-error-${d.id}`,variant:"destructive",children:r}),e[34]=r,e[35]=d.id,e[36]=v):v=e[36];let R;e[37]!==r||e[38]!==l||e[39]!==o||e[40]!==a||e[41]!==d.id?(R=r===void 0&&l&&o===void 0&&(0,s.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${d.id}`,children:a("Running\u2026")}),e[37]=r,e[38]=l,e[39]=o,e[40]=a,e[41]=d.id,e[42]=R):R=e[42];let i;e[43]!==r||e[44]!==o?(i=r===void 0&&o!==void 0&&(0,s.jsx)(de,{result:o}),e[43]=r,e[44]=o,e[45]=i):i=e[45];let n;e[46]!==v||e[47]!==R||e[48]!==i?(n=(0,s.jsxs)(V,{className:"min-h-32 py-2",children:[v,R,i]}),e[46]=v,e[47]=R,e[48]=i,e[49]=n):n=e[49];let q;return e[50]!==p||e[51]!==n||e[52]!==K?(q=(0,s.jsxs)(Q,{"data-testid":K,children:[p,n]}),e[50]=p,e[51]=n,e[52]=K,e[53]=q):q=e[53],q},"ie"),ce=k(_=>{let e=(0,W.c)(58),{draft:t,editing:m,onCancel:d,onChange:a,onSubmit:r}=_,l=A(),o;e[0]!==t||e[1]!==a?(o=k(z=>{a({...t,title:z.target.value})},"a"),e[0]=t,e[1]=a,e[2]=o):o=e[2];let E=o,c;e[3]!==t||e[4]!==a?(c=k(z=>{a({...t,sql:z.target.value})},"n"),e[3]=t,e[4]=a,e[5]=c):c=e[5];let C=c,y;e[6]!==t||e[7]!==a?(y=k(z=>{a({...t,shardKey:z.target.value})},"y"),e[6]=t,e[7]=a,e[8]=y):y=e[8];let K=y,h;e[9]!==r?(h=k(()=>{r()},"h"),e[9]=r,e[10]=h):h=e[10];let u=h,N;e[11]!==t.sql||e[12]!==t.title?(N=t.title.trim()!==""&&t.sql.trim()!=="",e[11]=t.sql,e[12]=t.title,e[13]=N):N=e[13];let $=N,L;e[14]!==l?(L=l("Widget title"),e[14]=l,e[15]=L):L=e[15];let S;e[16]!==l?(S=l("Widget title"),e[16]=l,e[17]=S):S=e[17];let x;e[18]!==t.title||e[19]!==E||e[20]!==L||e[21]!==S?(x=(0,s.jsx)("input",{"aria-label":L,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:E,placeholder:S,type:"text",value:t.title}),e[18]=t.title,e[19]=E,e[20]=L,e[21]=S,e[22]=x):x=e[22];let j;e[23]!==l?(j=l("SQL query"),e[23]=l,e[24]=j):j=e[24];let g;e[25]!==t.sql||e[26]!==C||e[27]!==j?(g=(0,s.jsx)("textarea",{"aria-label":j,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:C,placeholder:"SELECT author, COUNT(*) AS messages FROM \u2026",spellCheck:!1,value:t.sql}),e[25]=t.sql,e[26]=C,e[27]=j,e[28]=g):g=e[28];let w;e[29]!==l?(w=l("Shard key (optional)"),e[29]=l,e[30]=w):w=e[30];let b;e[31]!==l?(b=l("Shard key (optional)"),e[31]=l,e[32]=b):b=e[32];let f;e[33]!==t.shardKey||e[34]!==K||e[35]!==w||e[36]!==b?(f=(0,s.jsx)("input",{"aria-label":w,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:K,placeholder:b,type:"text",value:t.shardKey}),e[33]=t.shardKey,e[34]=K,e[35]=w,e[36]=b,e[37]=f):f=e[37];let p;e[38]!==l?(p=l("Cancel"),e[38]=l,e[39]=p):p=e[39];let v;e[40]!==d||e[41]!==p?(v=(0,s.jsx)(T,{"data-testid":"dashboards-form-cancel",onClick:d,size:"sm",type:"button",variant:"outline",children:p}),e[40]=d,e[41]=p,e[42]=v):v=e[42];let R=!$,i;e[43]!==m||e[44]!==l?(i=l(m?"Save widget":"Add widget"),e[43]=m,e[44]=l,e[45]=i):i=e[45];let n;e[46]!==u||e[47]!==R||e[48]!==i?(n=(0,s.jsx)(T,{"data-testid":"dashboards-form-save",disabled:R,onClick:u,size:"sm",type:"button",children:i}),e[46]=u,e[47]=R,e[48]=i,e[49]=n):n=e[49];let q;e[50]!==v||e[51]!==n?(q=(0,s.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[v,n]}),e[50]=v,e[51]=n,e[52]=q):q=e[52];let M;return e[53]!==g||e[54]!==f||e[55]!==q||e[56]!==x?(M=(0,s.jsx)(Q,{"data-testid":"dashboards-form",children:(0,s.jsxs)(V,{className:"flex flex-col gap-3 py-4",children:[x,g,f,q]})}),e[53]=g,e[54]=f,e[55]=q,e[56]=x,e[57]=M):M=e[57],M},"ae"),we=k(_=>{let e=(0,W.c)(39),{initialShardKey:t}=_,m=A(),[d,a]=Y(oe),[r,l]=(0,I.useState)(B),[o,E]=(0,I.useState)(null),[c,C]=(0,I.useState)(!1),y;e[0]!==t?(y=k(()=>{E(null),l({...B,shardKey:t??""}),C(!0)},"y"),e[0]=t,e[1]=y):y=e[1];let K=y,h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=k(()=>{C(!1),E(null),l(B)},"h"),e[2]=h):h=e[2];let u=h,N;e[3]!==d?(N=k(i=>{let n=d.find(q=>q.id===i);n!==void 0&&(E(i),l({shardKey:n.shardKey??"",sql:n.sql,title:n.title}),C(!0))},"C"),e[3]=d,e[4]=N):N=e[4];let $=N,L;e[5]!==a?(L=k(i=>{a(n=>n.filter(q=>q.id!==i))},"K"),e[5]=a,e[6]=L):L=e[6];let S=L,x;e[7]!==r.shardKey||e[8]!==r.sql||e[9]!==r.title||e[10]!==o||e[11]!==a?(x=k(()=>{let i=r.title.trim(),n=r.sql.trim();if(i===""||n==="")return;let q=r.shardKey.trim();a(o===null?M=>[...M,{id:ee("w"),shardKey:q,sql:n,title:i}]:M=>M.map(z=>z.id===o?{...z,shardKey:q,sql:n,title:i}:z)),u()},"x"),e[7]=r.shardKey,e[8]=r.sql,e[9]=r.title,e[10]=o,e[11]=a,e[12]=x):x=e[12];let j=x,g;e[13]!==m?(g=m("Chart widgets backed by saved read-only SQL queries."),e[13]=m,e[14]=g):g=e[14];let w;e[15]!==g?(w=(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:g}),e[15]=g,e[16]=w):w=e[16];let b;e[17]!==c||e[18]!==K||e[19]!==m?(b=!c&&(0,s.jsx)(T,{"data-testid":"dashboards-add",onClick:K,size:"sm",type:"button",children:m("Add widget")}),e[17]=c,e[18]=K,e[19]=m,e[20]=b):b=e[20];let f;e[21]!==w||e[22]!==b?(f=(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[w,b]}),e[21]=w,e[22]=b,e[23]=f):f=e[23];let p;e[24]!==r||e[25]!==o||e[26]!==c||e[27]!==j?(p=c&&(0,s.jsx)(ce,{draft:r,editing:o!==null,onCancel:u,onChange:l,onSubmit:j}),e[24]=r,e[25]=o,e[26]=c,e[27]=j,e[28]=p):p=e[28];let v;e[29]!==c||e[30]!==$||e[31]!==S||e[32]!==m||e[33]!==d?(v=d.length===0&&!c?(0,s.jsx)(H,{description:m("Add a widget to chart a saved SQL query on this browser."),testId:"dashboards-empty",title:m("No widgets yet")}):(0,s.jsx)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:d.map(i=>(0,s.jsx)(ne,{onEdit:$,onRemove:S,widget:i},i.id))}),e[29]=c,e[30]=$,e[31]=S,e[32]=m,e[33]=d,e[34]=v):v=e[34];let R;return e[35]!==p||e[36]!==v||e[37]!==f?(R=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-dashboards",children:[f,p,v]}),e[35]=p,e[36]=v,e[37]=f,e[38]=R):R=e[38],R},"we");export{we as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as te}from"./chunk-V53KNYRN.js";import{R as Z}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as I}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as K}from"./chunk-VDW32UET.js";import{c as ee}from"./chunk-LZGOETI3.js";import{f as M}from"./chunk-ETU7KIO4.js";import"./chunk-XBDKZZ67.js";import{a as q}from"./chunk-XQCVZAGU.js";import{a as z,b as D,c as F,d as h,e as o,f as i}from"./chunk-WJQLNYGX.js";import{a as T,e as j}from"./chunk-WQH3LT2P.js";import{d as H,f as Q,g as V,h as W,o as $}from"./chunk-IUYFXK4X.js";import"./chunk-YEGFNH56.js";import{a as n,e as Y,f as ne,h as le}from"./chunk-3XIESWL4.js";var c=Y(ne(),1);var e=Y(le(),1);var oe=["queued","running","paused","waiting","complete","errored","terminated"],ie=["pause","resume","terminate"],de="WORKFLOWS_NOT_CONFIGURED",ce=n(l=>typeof l=="object"&&l!==null&&l.code===de,"ie"),me=n(l=>{let r=l.error??l.output;if(r===void 0)return"\u2014";try{return JSON.stringify(r)}catch{return"(unserializable)"}},"de"),ue=n(({loadDetail:l,loadInstances:r,readOnly:N,runAction:R,workflowName:g})=>{let A=M(),s=H(),[p,k]=(0,c.useState)(null),[S,O]=(0,c.useState)(null),[v,_]=(0,c.useState)(""),[b,f]=(0,c.useState)(null),[J,C]=(0,c.useState)(!1),[L,P]=(0,c.useState)(null),w=l??(a=>A.getWorkflowInstance(a)),x=N?void 0:R??(r===void 0?a=>A.setWorkflowInstanceStatus(a):void 0),E=n(async()=>{f(null),C(!1);let a=v===""?void 0:v;try{if(r===void 0){let d=await A.listWorkflowInstances({name:g,status:a});if(d.configured===!1){k(null),C(!0);return}k(d.instances);return}k(await r({name:g,status:a}))}catch(d){k(null),ce(d)?C(!0):f(W(d))}},"O");(0,c.useEffect)(()=>{O(null),$(E())},[g,v]);let U=n(async a=>{f(null);try{O(await w({id:a,name:g}))}catch(d){f(W(d))}},"D"),B=n(async(a,d)=>{if(x!==void 0){P(a),f(null);try{await x({action:d,id:a,name:g}),await E()}catch(G){f(W(G))}P(null)}},"K");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:s("Instance history")}),(0,e.jsxs)("select",{"aria-label":s("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:n(a=>{_(a.target.value)},"onChange"),value:v,children:[(0,e.jsx)("option",{value:"",children:s("All statuses")}),oe.map(a=>(0,e.jsx)("option",{value:a,children:a},a))]})]}),b!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:b}),J&&(0,e.jsx)(q,{description:s("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:s("Workflow inspection not configured")}),!J&&p!==null&&p.length===0&&(0,e.jsx)(q,{description:s("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:s("No instances")}),p!==null&&p.length>0&&(0,e.jsx)(T,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(z,{"data-testid":"workflow-instances-table",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:s("Instance id")}),(0,e.jsx)(o,{children:s("Status")}),(0,e.jsx)(o,{children:s("Created")}),(0,e.jsx)(o,{children:s("Ended")}),(0,e.jsx)(o,{"aria-label":s("Actions")})]})}),(0,e.jsx)(F,{children:p.map(a=>(0,e.jsxs)(h,{"data-testid":`workflow-instance-${a.id}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:a.id}),(0,e.jsx)(i,{className:"font-mono text-xs",children:a.status}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"\u2014"}),(0,e.jsx)(i,{className:"text-right",children:(0,e.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,e.jsx)(I,{"data-testid":`workflow-instance-steps-${a.id}`,onClick:n(()=>{$(U(a.id))},"onClick"),size:"sm",type:"button",variant:"outline",children:s("Steps")}),x!==void 0&&ie.map(d=>(0,e.jsx)(I,{"data-testid":`workflow-instance-${d}-${a.id}`,disabled:L===a.id,onClick:n(()=>{$(B(a.id,d))},"onClick"),size:"sm",type:"button",variant:"ghost",children:s(d)},d))]})})]},a.id))})]})})}),S!==null&&(0,e.jsx)(T,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:(0,e.jsxs)(j,{className:"flex flex-col gap-2 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[s("Steps")," \xB7 ",S.id]}),(0,e.jsx)(I,{"data-testid":"workflow-instance-detail-close",onClick:n(()=>{O(null)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Close")})]}),S.steps.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:s("This instance has no recorded steps yet.")}):(0,e.jsxs)(z,{"data-testid":"workflow-instance-steps",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:s("Step")}),(0,e.jsx)(o,{children:s("Type")}),(0,e.jsx)(o,{children:s("Attempts")}),(0,e.jsx)(o,{children:s("Started")}),(0,e.jsx)(o,{children:s("Output")})]})}),(0,e.jsx)(F,{children:S.steps.map((a,d)=>(0,e.jsxs)(h,{"data-testid":`workflow-step-${String(d)}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:a.name}),(0,e.jsx)(i,{className:"text-xs text-muted-foreground",children:a.type??"\u2014"}),(0,e.jsx)(i,{className:"tabular-nums",children:a.attempts??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.start??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:me(a)})]},`${a.name}:${String(d)}`))})]})]})})]})},"ce"),fe=Q(K.createWorkflowInstance),he=Q(K.getWorkflowInstanceStatus),pe=n(l=>{if(l.error)return`${l.error.name}: ${l.error.message}`;if(l.output===void 0)return"\u2014";try{return JSON.stringify(l.output)}catch{return"(unserializable)"}},"fe"),we=n((l,r)=>l.some(N=>N.exportName===r)?r:l[0]?.exportName??"","he"),We=n(()=>{let l=M(),r=H(),{data:N,error:R}=ee(K.listWorkflows,{}),[g,A]=(0,c.useState)(""),[s,p]=(0,c.useState)(""),[k,S]=(0,c.useState)(""),[O,v]=(0,c.useState)(!1),[_,b]=(0,c.useState)(null),[f,J]=(0,c.useState)([]),[C,L]=(0,c.useState)(null),P=N!==void 0,w=Array.isArray(N?.workflows)?[...N.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],x=we(w,g),E=w.find(t=>t.exportName===x),U=n(t=>{J(u=>{let m=u.filter(y=>!(y.exportName===t.exportName&&y.id===t.id));return[t,...m]})},"D"),B=n(async()=>{let t=x;if(t==="")return;let u,m=k.trim();if(m!=="")try{u=JSON.parse(m)}catch{b(r("Params must be valid JSON"));return}v(!0),b(null);try{let y=s.trim(),X=await l.query(fe,{exportName:t,id:y===""?void 0:y,params:u},V(""));U({exportName:t,id:X.id,status:X.status}),p("")}catch(y){b(W(y))}v(!1)},"K"),a=n(()=>{$(B())},"a"),d=n(async(t,u)=>{L(u);try{let m=await l.query(he,{exportName:t,id:u},V(""));U({error:m.error,exportName:t,id:m.id,output:m.output,status:m.status})}catch(m){b(W(m))}L(null)},"l"),G=n(t=>{A(t.target.value)},"P"),ae=n(t=>{p(t.target.value)},"Y"),re=n(t=>{S(t.target.value)},"Z"),se=n(t=>{let{export:u,id:m}=t.currentTarget.dataset;u!==void 0&&m!==void 0&&$(d(u,m))},"ee");return(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[R!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:R}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:r("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),P&&w.length===0?(0,e.jsx)(q,{description:r("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:r("No workflows defined")}):(0,e.jsx)(T,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(z,{"data-testid":"workflows-table",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:r("Export")}),(0,e.jsx)(o,{children:r("Name")}),(0,e.jsx)(o,{children:r("Class")}),(0,e.jsx)(o,{children:r("Binding")})]})}),(0,e.jsx)(F,{children:w.map(t=>(0,e.jsxs)(h,{"data-testid":`workflows-row-${t.exportName}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.name}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.className}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.binding})]},t.exportName))})]})})}),w.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Start instance")}),_!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:_}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("select",{"aria-label":r("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:G,value:x,children:w.map(t=>(0,e.jsx)("option",{value:t.exportName,children:t.exportName},t.exportName))}),(0,e.jsx)(Z,{"aria-label":r("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:ae,placeholder:r("Instance id (optional)"),value:s}),(0,e.jsx)(I,{"data-testid":"workflows-start-button",disabled:O||x==="",onClick:a,children:r(O?"Starting\u2026":"Start instance")})]}),(0,e.jsx)(te,{"aria-label":r("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:re,placeholder:r("Params (JSON, optional)"),value:k})]}),f.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Instances")}),(0,e.jsx)(T,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(z,{"data-testid":"workflows-instances-table",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:r("Workflow")}),(0,e.jsx)(o,{children:r("Instance id")}),(0,e.jsx)(o,{children:r("Status")}),(0,e.jsx)(o,{children:r("Output")}),(0,e.jsx)(o,{})]})}),(0,e.jsx)(F,{children:f.map(t=>(0,e.jsxs)(h,{"data-testid":`workflows-instance-${t.id}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.id}),(0,e.jsx)(i,{className:"font-mono text-xs",children:t.status}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:pe(t)}),(0,e.jsx)(i,{children:(0,e.jsx)(I,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:C===t.id,onClick:se,size:"xs",variant:"outline",children:C===t.id?r("Refreshing\u2026"):r("Refresh")})})]},`${t.exportName}:${t.id}`))})]})})})]}),E!==void 0&&(0,e.jsx)(ue,{workflowName:E.name})]})},"Oe");export{We as default};
|
|
1
|
+
import{a as te}from"./chunk-V53KNYRN.js";import{R as Z}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as I}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as K}from"./chunk-VDW32UET.js";import{c as ee}from"./chunk-6F7KP54M.js";import{f as M}from"./chunk-C2ZFQARQ.js";import"./chunk-XBDKZZ67.js";import{a as q}from"./chunk-XQCVZAGU.js";import{a as z,b as D,c as F,d as h,e as o,f as i}from"./chunk-WJQLNYGX.js";import{a as T,e as j}from"./chunk-WQH3LT2P.js";import{d as H,f as Q,g as V,h as W,o as $}from"./chunk-IUYFXK4X.js";import"./chunk-P33WK7YI.js";import{a as n,e as Y,f as ne,h as le}from"./chunk-3XIESWL4.js";var c=Y(ne(),1);var e=Y(le(),1);var oe=["queued","running","paused","waiting","complete","errored","terminated"],ie=["pause","resume","terminate"],de="WORKFLOWS_NOT_CONFIGURED",ce=n(l=>typeof l=="object"&&l!==null&&l.code===de,"ie"),me=n(l=>{let r=l.error??l.output;if(r===void 0)return"\u2014";try{return JSON.stringify(r)}catch{return"(unserializable)"}},"de"),ue=n(({loadDetail:l,loadInstances:r,readOnly:N,runAction:R,workflowName:g})=>{let A=M(),s=H(),[p,k]=(0,c.useState)(null),[S,O]=(0,c.useState)(null),[v,_]=(0,c.useState)(""),[b,f]=(0,c.useState)(null),[J,C]=(0,c.useState)(!1),[L,P]=(0,c.useState)(null),w=l??(a=>A.getWorkflowInstance(a)),x=N?void 0:R??(r===void 0?a=>A.setWorkflowInstanceStatus(a):void 0),E=n(async()=>{f(null),C(!1);let a=v===""?void 0:v;try{if(r===void 0){let d=await A.listWorkflowInstances({name:g,status:a});if(d.configured===!1){k(null),C(!0);return}k(d.instances);return}k(await r({name:g,status:a}))}catch(d){k(null),ce(d)?C(!0):f(W(d))}},"O");(0,c.useEffect)(()=>{O(null),$(E())},[g,v]);let U=n(async a=>{f(null);try{O(await w({id:a,name:g}))}catch(d){f(W(d))}},"D"),B=n(async(a,d)=>{if(x!==void 0){P(a),f(null);try{await x({action:d,id:a,name:g}),await E()}catch(G){f(W(G))}P(null)}},"K");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:s("Instance history")}),(0,e.jsxs)("select",{"aria-label":s("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:n(a=>{_(a.target.value)},"onChange"),value:v,children:[(0,e.jsx)("option",{value:"",children:s("All statuses")}),oe.map(a=>(0,e.jsx)("option",{value:a,children:a},a))]})]}),b!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:b}),J&&(0,e.jsx)(q,{description:s("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:s("Workflow inspection not configured")}),!J&&p!==null&&p.length===0&&(0,e.jsx)(q,{description:s("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:s("No instances")}),p!==null&&p.length>0&&(0,e.jsx)(T,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(z,{"data-testid":"workflow-instances-table",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:s("Instance id")}),(0,e.jsx)(o,{children:s("Status")}),(0,e.jsx)(o,{children:s("Created")}),(0,e.jsx)(o,{children:s("Ended")}),(0,e.jsx)(o,{"aria-label":s("Actions")})]})}),(0,e.jsx)(F,{children:p.map(a=>(0,e.jsxs)(h,{"data-testid":`workflow-instance-${a.id}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:a.id}),(0,e.jsx)(i,{className:"font-mono text-xs",children:a.status}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"\u2014"}),(0,e.jsx)(i,{className:"text-right",children:(0,e.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,e.jsx)(I,{"data-testid":`workflow-instance-steps-${a.id}`,onClick:n(()=>{$(U(a.id))},"onClick"),size:"sm",type:"button",variant:"outline",children:s("Steps")}),x!==void 0&&ie.map(d=>(0,e.jsx)(I,{"data-testid":`workflow-instance-${d}-${a.id}`,disabled:L===a.id,onClick:n(()=>{$(B(a.id,d))},"onClick"),size:"sm",type:"button",variant:"ghost",children:s(d)},d))]})})]},a.id))})]})})}),S!==null&&(0,e.jsx)(T,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:(0,e.jsxs)(j,{className:"flex flex-col gap-2 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[s("Steps")," \xB7 ",S.id]}),(0,e.jsx)(I,{"data-testid":"workflow-instance-detail-close",onClick:n(()=>{O(null)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Close")})]}),S.steps.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:s("This instance has no recorded steps yet.")}):(0,e.jsxs)(z,{"data-testid":"workflow-instance-steps",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:s("Step")}),(0,e.jsx)(o,{children:s("Type")}),(0,e.jsx)(o,{children:s("Attempts")}),(0,e.jsx)(o,{children:s("Started")}),(0,e.jsx)(o,{children:s("Output")})]})}),(0,e.jsx)(F,{children:S.steps.map((a,d)=>(0,e.jsxs)(h,{"data-testid":`workflow-step-${String(d)}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:a.name}),(0,e.jsx)(i,{className:"text-xs text-muted-foreground",children:a.type??"\u2014"}),(0,e.jsx)(i,{className:"tabular-nums",children:a.attempts??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.start??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:me(a)})]},`${a.name}:${String(d)}`))})]})]})})]})},"ce"),fe=Q(K.createWorkflowInstance),he=Q(K.getWorkflowInstanceStatus),pe=n(l=>{if(l.error)return`${l.error.name}: ${l.error.message}`;if(l.output===void 0)return"\u2014";try{return JSON.stringify(l.output)}catch{return"(unserializable)"}},"fe"),we=n((l,r)=>l.some(N=>N.exportName===r)?r:l[0]?.exportName??"","he"),We=n(()=>{let l=M(),r=H(),{data:N,error:R}=ee(K.listWorkflows,{}),[g,A]=(0,c.useState)(""),[s,p]=(0,c.useState)(""),[k,S]=(0,c.useState)(""),[O,v]=(0,c.useState)(!1),[_,b]=(0,c.useState)(null),[f,J]=(0,c.useState)([]),[C,L]=(0,c.useState)(null),P=N!==void 0,w=Array.isArray(N?.workflows)?[...N.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],x=we(w,g),E=w.find(t=>t.exportName===x),U=n(t=>{J(u=>{let m=u.filter(y=>!(y.exportName===t.exportName&&y.id===t.id));return[t,...m]})},"D"),B=n(async()=>{let t=x;if(t==="")return;let u,m=k.trim();if(m!=="")try{u=JSON.parse(m)}catch{b(r("Params must be valid JSON"));return}v(!0),b(null);try{let y=s.trim(),X=await l.query(fe,{exportName:t,id:y===""?void 0:y,params:u},V(""));U({exportName:t,id:X.id,status:X.status}),p("")}catch(y){b(W(y))}v(!1)},"K"),a=n(()=>{$(B())},"a"),d=n(async(t,u)=>{L(u);try{let m=await l.query(he,{exportName:t,id:u},V(""));U({error:m.error,exportName:t,id:m.id,output:m.output,status:m.status})}catch(m){b(W(m))}L(null)},"l"),G=n(t=>{A(t.target.value)},"P"),ae=n(t=>{p(t.target.value)},"Y"),re=n(t=>{S(t.target.value)},"Z"),se=n(t=>{let{export:u,id:m}=t.currentTarget.dataset;u!==void 0&&m!==void 0&&$(d(u,m))},"ee");return(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[R!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:R}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:r("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),P&&w.length===0?(0,e.jsx)(q,{description:r("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:r("No workflows defined")}):(0,e.jsx)(T,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(z,{"data-testid":"workflows-table",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:r("Export")}),(0,e.jsx)(o,{children:r("Name")}),(0,e.jsx)(o,{children:r("Class")}),(0,e.jsx)(o,{children:r("Binding")})]})}),(0,e.jsx)(F,{children:w.map(t=>(0,e.jsxs)(h,{"data-testid":`workflows-row-${t.exportName}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.name}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.className}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.binding})]},t.exportName))})]})})}),w.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Start instance")}),_!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:_}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("select",{"aria-label":r("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:G,value:x,children:w.map(t=>(0,e.jsx)("option",{value:t.exportName,children:t.exportName},t.exportName))}),(0,e.jsx)(Z,{"aria-label":r("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:ae,placeholder:r("Instance id (optional)"),value:s}),(0,e.jsx)(I,{"data-testid":"workflows-start-button",disabled:O||x==="",onClick:a,children:r(O?"Starting\u2026":"Start instance")})]}),(0,e.jsx)(te,{"aria-label":r("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:re,placeholder:r("Params (JSON, optional)"),value:k})]}),f.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Instances")}),(0,e.jsx)(T,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(z,{"data-testid":"workflows-instances-table",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:r("Workflow")}),(0,e.jsx)(o,{children:r("Instance id")}),(0,e.jsx)(o,{children:r("Status")}),(0,e.jsx)(o,{children:r("Output")}),(0,e.jsx)(o,{})]})}),(0,e.jsx)(F,{children:f.map(t=>(0,e.jsxs)(h,{"data-testid":`workflows-instance-${t.id}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.id}),(0,e.jsx)(i,{className:"font-mono text-xs",children:t.status}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:pe(t)}),(0,e.jsx)(i,{children:(0,e.jsx)(I,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:C===t.id,onClick:se,size:"xs",variant:"outline",children:C===t.id?r("Refreshing\u2026"):r("Refresh")})})]},`${t.exportName}:${t.id}`))})]})})})]}),E!==void 0&&(0,e.jsx)(ue,{workflowName:E.name})]})},"Oe");export{We as default};
|