From 7ddb211fcfa240115de053e6341a4a8feca696cc Mon Sep 17 00:00:00 2001 From: Snow Lee Date: Sun, 19 Jul 2026 11:41:35 -0700 Subject: [PATCH] feat(web): scoped insights/history keep the file or folder selected in the tree On /insights/ and /history/ the tree highlights (and unfolds to) the target; Dashboard/History menu items light up only for their root, project-wide views. 50/50 e2e. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01VbiaaVM2ACxeRi8ySG9ybc --- internal/webapp/frontend/e2e/scope.spec.ts | 13 ++++++++++++ internal/webapp/frontend/src/apps/Browser.tsx | 20 +++++++++++-------- internal/webapp/frontend/src/apps/HubApp.tsx | 7 +++++-- .../webapp/static/assets/index-BOZlnkUa.js | 11 ---------- .../webapp/static/assets/index-D_qY6bcM.js | 11 ++++++++++ internal/webapp/static/index.html | 2 +- 6 files changed, 42 insertions(+), 22 deletions(-) delete mode 100644 internal/webapp/static/assets/index-BOZlnkUa.js create mode 100644 internal/webapp/static/assets/index-D_qY6bcM.js diff --git a/internal/webapp/frontend/e2e/scope.spec.ts b/internal/webapp/frontend/e2e/scope.spec.ts index 88d2aea..145c42b 100644 --- a/internal/webapp/frontend/e2e/scope.spec.ts +++ b/internal/webapp/frontend/e2e/scope.spec.ts @@ -9,6 +9,9 @@ test("insights via ⋯ scopes to the open file", async ({ page }) => { await page.click("#more-menu .more-item:has-text('Insights')"); await expect(page).toHaveURL(`/${pid}/insights/notes/readme.md`); await expect(page.locator(".in-title .in-scope")).toContainText("notes/readme.md"); + // The subject stays selected in the tree; Dashboard does NOT light up. + await expect(page.locator('#tree .row[data-path="notes/readme.md"]')).toHaveClass(/active/); + await expect(page.locator("#nav-dashboard")).not.toHaveClass(/active/); }); test("insights via ⋯ scopes to the selected folder", async ({ page }) => { @@ -19,4 +22,14 @@ test("insights via ⋯ scopes to the selected folder", async ({ page }) => { await page.click("#more-menu .more-item:has-text('Insights')"); await expect(page).toHaveURL(`/${pid}/insights/notes`); await expect(page.locator(".in-title .in-scope")).toContainText("notes"); + await expect(page.locator('#tree .row[data-path="notes"]')).toHaveClass(/active/); + await expect(page.locator("#nav-dashboard")).not.toHaveClass(/active/); +}); + +test("root Dashboard still lights the menu, not the tree", async ({ page }) => { + await login(page); + await wikiId(page); + await page.click("#nav-dashboard"); + await expect(page.locator("#nav-dashboard")).toHaveClass(/active/); + await expect(page.locator("#tree .row.active")).toHaveCount(0); }); diff --git a/internal/webapp/frontend/src/apps/Browser.tsx b/internal/webapp/frontend/src/apps/Browser.tsx index 3ffce54..3315eee 100644 --- a/internal/webapp/frontend/src/apps/Browser.tsx +++ b/internal/webapp/frontend/src/apps/Browser.tsx @@ -59,6 +59,9 @@ export default function Browser(props: { }, [insightsOpen, apiBase, qc]); const path = route.path; + // On scoped view routes (/insights/

, /history/

) the subject of the + // page is the target — the tree highlights it, not a menu item. + const treePath = path || (route.view === "insights" || route.view === "history" ? route.viewTarget || "" : ""); const isDir = !!path && dirIndex.has(path); // A file only counts as one when the tree actually contains it — a // missing path gets the not-found view, not a broken file view. @@ -78,18 +81,19 @@ export default function Browser(props: { if (rootDirs.length === 1) setExpanded((s) => new Set(s).add(rootDirs[0].path)); }, [tree]); useEffect(() => { - // Opening any path (tree click, palette, wikilink, deep link) unfolds - // the way to it; a selected folder itself opens too. - if (!path || !loaded) return; + // Opening any path (tree click, palette, wikilink, deep link — or a + // scoped insights/history view of it) unfolds the way to it; a selected + // folder itself opens too. + if (!treePath || !loaded) return; setExpanded((s) => { const next = new Set(s); - for (const a of ancestorsOf(path)) next.add(a); - if (dirIndex.has(path)) next.add(path); + for (const a of ancestorsOf(treePath)) next.add(a); + if (dirIndex.has(treePath)) next.add(treePath); return next; }); - const row = document.querySelector(`#tree .row[data-path="${CSS.escape(path)}"]`); + const row = document.querySelector(`#tree .row[data-path="${CSS.escape(treePath)}"]`); if (row) row.scrollIntoView({ block: "nearest" }); - }, [path, loaded, dirIndex]); + }, [treePath, loaded, dirIndex]); const onToggle = useCallback((p: string) => { setExpanded((s) => { const next = new Set(s); @@ -420,7 +424,7 @@ export default function Browser(props: { root={tree} expanded={expanded} onToggle={onToggle} - currentPath={path} + currentPath={treePath} listingShowing={listingShowing} onOpen={openPath} /> diff --git a/internal/webapp/frontend/src/apps/HubApp.tsx b/internal/webapp/frontend/src/apps/HubApp.tsx index 1a311f7..8cbc50d 100644 --- a/internal/webapp/frontend/src/apps/HubApp.tsx +++ b/internal/webapp/frontend/src/apps/HubApp.tsx @@ -192,13 +192,16 @@ export default function HubApp({ config }: { config: ServerConfig }) { projects={projects} currentId={current.id} menu={{ + // Scoped views (/insights/, /history/) belong to + // the file/folder — the tree carries the selection, no menu + // item lights up. active: panel ? null - : route.view === "insights" + : route.view === "insights" && !route.viewTarget ? "dashboard" : route.view === "install" ? "install" - : route.view === "history" + : route.view === "history" && !route.viewTarget ? "history" : route.view === "settings" ? "settings" diff --git a/internal/webapp/static/assets/index-BOZlnkUa.js b/internal/webapp/static/assets/index-BOZlnkUa.js deleted file mode 100644 index 23e8699..0000000 --- a/internal/webapp/static/assets/index-BOZlnkUa.js +++ /dev/null @@ -1,11 +0,0 @@ -(function(){const c=document.createElement("link").relList;if(c&&c.supports&&c.supports("modulepreload"))return;for(const d of document.querySelectorAll('link[rel="modulepreload"]'))f(d);new MutationObserver(d=>{for(const m of d)if(m.type==="childList")for(const g of m.addedNodes)g.tagName==="LINK"&&g.rel==="modulepreload"&&f(g)}).observe(document,{childList:!0,subtree:!0});function r(d){const m={};return d.integrity&&(m.integrity=d.integrity),d.referrerPolicy&&(m.referrerPolicy=d.referrerPolicy),d.crossOrigin==="use-credentials"?m.credentials="include":d.crossOrigin==="anonymous"?m.credentials="omit":m.credentials="same-origin",m}function f(d){if(d.ep)return;d.ep=!0;const m=r(d);fetch(d.href,m)}})();var Gs={exports:{}},Kn={};var vh;function Lv(){if(vh)return Kn;vh=1;var i=Symbol.for("react.transitional.element"),c=Symbol.for("react.fragment");function r(f,d,m){var g=null;if(m!==void 0&&(g=""+m),d.key!==void 0&&(g=""+d.key),"key"in d){m={};for(var A in d)A!=="key"&&(m[A]=d[A])}else m=d;return d=m.ref,{$$typeof:i,type:f,key:g,ref:d!==void 0?d:null,props:m}}return Kn.Fragment=c,Kn.jsx=r,Kn.jsxs=r,Kn}var ph;function Yv(){return ph||(ph=1,Gs.exports=Lv()),Gs.exports}var o=Yv(),Xs={exports:{}},W={};var gh;function Gv(){if(gh)return W;gh=1;var i=Symbol.for("react.transitional.element"),c=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),f=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),m=Symbol.for("react.consumer"),g=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),E=Symbol.for("react.activity"),x=Symbol.iterator;function q(S){return S===null||typeof S!="object"?null:(S=x&&S[x]||S["@@iterator"],typeof S=="function"?S:null)}var z={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,Y={};function $(S,H,L){this.props=S,this.context=H,this.refs=Y,this.updater=L||z}$.prototype.isReactComponent={},$.prototype.setState=function(S,H){if(typeof S!="object"&&typeof S!="function"&&S!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,S,H,"setState")},$.prototype.forceUpdate=function(S){this.updater.enqueueForceUpdate(this,S,"forceUpdate")};function yt(){}yt.prototype=$.prototype;function ot(S,H,L){this.props=S,this.context=H,this.refs=Y,this.updater=L||z}var Ct=ot.prototype=new yt;Ct.constructor=ot,w(Ct,$.prototype),Ct.isPureReactComponent=!0;var Rt=Array.isArray;function et(){}var k={H:null,A:null,T:null,S:null},gt=Object.prototype.hasOwnProperty;function wt(S,H,L){var G=L.ref;return{$$typeof:i,type:S,key:H,ref:G!==void 0?G:null,props:L}}function ue(S,H){return wt(S.type,H,S.props)}function le(S){return typeof S=="object"&&S!==null&&S.$$typeof===i}function _t(S){var H={"=":"=0",":":"=2"};return"$"+S.replace(/[=:]/g,function(L){return H[L]})}var ce=/\/+/g;function Ut(S,H){return typeof S=="object"&&S!==null&&S.key!=null?_t(""+S.key):H.toString(36)}function kt(S){switch(S.status){case"fulfilled":return S.value;case"rejected":throw S.reason;default:switch(typeof S.status=="string"?S.then(et,et):(S.status="pending",S.then(function(H){S.status==="pending"&&(S.status="fulfilled",S.value=H)},function(H){S.status==="pending"&&(S.status="rejected",S.reason=H)})),S.status){case"fulfilled":return S.value;case"rejected":throw S.reason}}throw S}function D(S,H,L,G,J){var lt=typeof S;(lt==="undefined"||lt==="boolean")&&(S=null);var rt=!1;if(S===null)rt=!0;else switch(lt){case"bigint":case"string":case"number":rt=!0;break;case"object":switch(S.$$typeof){case i:case c:rt=!0;break;case M:return rt=S._init,D(rt(S._payload),H,L,G,J)}}if(rt)return J=J(S),rt=G===""?"."+Ut(S,0):G,Rt(J)?(L="",rt!=null&&(L=rt.replace(ce,"$&/")+"/"),D(J,H,L,"",function(Xl){return Xl})):J!=null&&(le(J)&&(J=ue(J,L+(J.key==null||S&&S.key===J.key?"":(""+J.key).replace(ce,"$&/")+"/")+rt)),H.push(J)),1;rt=0;var Vt=G===""?".":G+":";if(Rt(S))for(var Dt=0;Dt>>1,dt=D[vt];if(0>>1;vtd(L,V))Gd(J,L)?(D[vt]=J,D[G]=V,vt=G):(D[vt]=L,D[H]=V,vt=H);else if(Gd(J,V))D[vt]=J,D[G]=V,vt=G;else break t}}return B}function d(D,B){var V=D.sortIndex-B.sortIndex;return V!==0?V:D.id-B.id}if(i.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var m=performance;i.unstable_now=function(){return m.now()}}else{var g=Date,A=g.now();i.unstable_now=function(){return g.now()-A}}var p=[],y=[],M=1,E=null,x=3,q=!1,z=!1,w=!1,Y=!1,$=typeof setTimeout=="function"?setTimeout:null,yt=typeof clearTimeout=="function"?clearTimeout:null,ot=typeof setImmediate<"u"?setImmediate:null;function Ct(D){for(var B=r(y);B!==null;){if(B.callback===null)f(y);else if(B.startTime<=D)f(y),B.sortIndex=B.expirationTime,c(p,B);else break;B=r(y)}}function Rt(D){if(w=!1,Ct(D),!z)if(r(p)!==null)z=!0,et||(et=!0,_t());else{var B=r(y);B!==null&&kt(Rt,B.startTime-D)}}var et=!1,k=-1,gt=5,wt=-1;function ue(){return Y?!0:!(i.unstable_now()-wtD&&ue());){var vt=E.callback;if(typeof vt=="function"){E.callback=null,x=E.priorityLevel;var dt=vt(E.expirationTime<=D);if(D=i.unstable_now(),typeof dt=="function"){E.callback=dt,Ct(D),B=!0;break e}E===r(p)&&f(p),Ct(D)}else f(p);E=r(p)}if(E!==null)B=!0;else{var S=r(y);S!==null&&kt(Rt,S.startTime-D),B=!1}}break t}finally{E=null,x=V,q=!1}B=void 0}}finally{B?_t():et=!1}}}var _t;if(typeof ot=="function")_t=function(){ot(le)};else if(typeof MessageChannel<"u"){var ce=new MessageChannel,Ut=ce.port2;ce.port1.onmessage=le,_t=function(){Ut.postMessage(null)}}else _t=function(){$(le,0)};function kt(D,B){k=$(function(){D(i.unstable_now())},B)}i.unstable_IdlePriority=5,i.unstable_ImmediatePriority=1,i.unstable_LowPriority=4,i.unstable_NormalPriority=3,i.unstable_Profiling=null,i.unstable_UserBlockingPriority=2,i.unstable_cancelCallback=function(D){D.callback=null},i.unstable_forceFrameRate=function(D){0>D||125vt?(D.sortIndex=V,c(y,D),r(p)===null&&D===r(y)&&(w?(yt(k),k=-1):w=!0,kt(Rt,V-vt))):(D.sortIndex=dt,c(p,D),z||q||(z=!0,et||(et=!0,_t()))),D},i.unstable_shouldYield=ue,i.unstable_wrapCallback=function(D){var B=x;return function(){var V=x;x=B;try{return D.apply(this,arguments)}finally{x=V}}}})(ks)),ks}var xh;function Kv(){return xh||(xh=1,Zs.exports=Xv()),Zs.exports}var Vs={exports:{}},ae={};var jh;function Zv(){if(jh)return ae;jh=1;var i=ur();function c(p){var y="https://react.dev/errors/"+p;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(c){console.error(c)}}return i(),Vs.exports=Zv(),Vs.exports}var Th;function Vv(){if(Th)return Zn;Th=1;var i=Kv(),c=ur(),r=kv();function f(t){var e="https://react.dev/errors/"+t;if(1dt||(t.current=vt[dt],vt[dt]=null,dt--)}function L(t,e){dt++,vt[dt]=t.current,t.current=e}var G=S(null),J=S(null),lt=S(null),rt=S(null);function Vt(t,e){switch(L(lt,e),L(J,t),L(G,null),e.nodeType){case 9:case 11:t=(t=e.documentElement)&&(t=t.namespaceURI)?Bd(t):0;break;default:if(t=e.tagName,e=e.namespaceURI)e=Bd(e),t=Ld(e,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}H(G),L(G,t)}function Dt(){H(G),H(J),H(lt)}function Xl(t){t.memoizedState!==null&&L(rt,t);var e=G.current,l=Ld(e,t.type);e!==l&&(L(J,t),L(G,l))}function ml(t){J.current===t&&(H(G),H(J)),rt.current===t&&(H(rt),Ln._currentValue=V)}var yl,li;function ze(t){if(yl===void 0)try{throw Error()}catch(l){var e=l.stack.trim().match(/\n( *(at )?)/);yl=e&&e[1]||"",li=-1)":-1n||v[a]!==N[n]){var _=` -`+v[a].replace(" at new "," at ");return t.displayName&&_.includes("")&&(_=_.replace("",t.displayName)),_}while(1<=a&&0<=n);break}}}finally{Ye=!1,Error.prepareStackTrace=l}return(l=t?t.displayName||t.name:"")?ze(l):""}function Au(t,e){switch(t.tag){case 26:case 27:case 5:return ze(t.type);case 16:return ze("Lazy");case 13:return t.child!==e&&e!==null?ze("Suspense Fallback"):ze("Suspense");case 19:return ze("SuspenseList");case 0:case 15:return se(t.type,!1);case 11:return se(t.type.render,!1);case 1:return se(t.type,!0);case 31:return ze("Activity");default:return""}}function ai(t){try{var e="",l=null;do e+=Au(t,l),l=t,t=t.return;while(t);return e}catch(a){return` -Error generating stack: `+a.message+` -`+a.stack}}var P=Object.prototype.hasOwnProperty,ft=i.unstable_scheduleCallback,xt=i.unstable_cancelCallback,$a=i.unstable_shouldYield,Cu=i.unstable_requestPaint,ne=i.unstable_now,Sm=i.unstable_getCurrentPriorityLevel,yr=i.unstable_ImmediatePriority,vr=i.unstable_UserBlockingPriority,ni=i.unstable_NormalPriority,xm=i.unstable_LowPriority,pr=i.unstable_IdlePriority,jm=i.log,Em=i.unstable_setDisableYieldValue,Wa=null,be=null;function vl(t){if(typeof jm=="function"&&Em(t),be&&typeof be.setStrictMode=="function")try{be.setStrictMode(Wa,t)}catch{}}var Se=Math.clz32?Math.clz32:Om,Tm=Math.log,Nm=Math.LN2;function Om(t){return t>>>=0,t===0?32:31-(Tm(t)/Nm|0)|0}var ii=256,ui=262144,ci=4194304;function Kl(t){var e=t&42;if(e!==0)return e;switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function si(t,e,l){var a=t.pendingLanes;if(a===0)return 0;var n=0,u=t.suspendedLanes,s=t.pingedLanes;t=t.warmLanes;var h=a&134217727;return h!==0?(a=h&~u,a!==0?n=Kl(a):(s&=h,s!==0?n=Kl(s):l||(l=h&~t,l!==0&&(n=Kl(l))))):(h=a&~u,h!==0?n=Kl(h):s!==0?n=Kl(s):l||(l=a&~t,l!==0&&(n=Kl(l)))),n===0?0:e!==0&&e!==n&&(e&u)===0&&(u=n&-n,l=e&-e,u>=l||u===32&&(l&4194048)!==0)?e:n}function Ia(t,e){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&e)===0}function Mm(t,e){switch(t){case 1:case 2:case 4:case 8:case 64:return e+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function gr(){var t=ci;return ci<<=1,(ci&62914560)===0&&(ci=4194304),t}function zu(t){for(var e=[],l=0;31>l;l++)e.push(t);return e}function Pa(t,e){t.pendingLanes|=e,e!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function Am(t,e,l,a,n,u){var s=t.pendingLanes;t.pendingLanes=l,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=l,t.entangledLanes&=l,t.errorRecoveryDisabledLanes&=l,t.shellSuspendCounter=0;var h=t.entanglements,v=t.expirationTimes,N=t.hiddenUpdates;for(l=s&~l;0"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var Um=/[\n"\\]/g;function De(t){return t.replace(Um,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})}function qu(t,e,l,a,n,u,s,h){t.name="",s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"?t.type=s:t.removeAttribute("type"),e!=null?s==="number"?(e===0&&t.value===""||t.value!=e)&&(t.value=""+_e(e)):t.value!==""+_e(e)&&(t.value=""+_e(e)):s!=="submit"&&s!=="reset"||t.removeAttribute("value"),e!=null?wu(t,s,_e(e)):l!=null?wu(t,s,_e(l)):a!=null&&t.removeAttribute("value"),n==null&&u!=null&&(t.defaultChecked=!!u),n!=null&&(t.checked=n&&typeof n!="function"&&typeof n!="symbol"),h!=null&&typeof h!="function"&&typeof h!="symbol"&&typeof h!="boolean"?t.name=""+_e(h):t.removeAttribute("name")}function _r(t,e,l,a,n,u,s,h){if(u!=null&&typeof u!="function"&&typeof u!="symbol"&&typeof u!="boolean"&&(t.type=u),e!=null||l!=null){if(!(u!=="submit"&&u!=="reset"||e!=null)){Hu(t);return}l=l!=null?""+_e(l):"",e=e!=null?""+_e(e):l,h||e===t.value||(t.value=e),t.defaultValue=e}a=a??n,a=typeof a!="function"&&typeof a!="symbol"&&!!a,t.checked=h?t.checked:!!a,t.defaultChecked=!!a,s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"&&(t.name=s),Hu(t)}function wu(t,e,l){e==="number"&&oi(t.ownerDocument)===t||t.defaultValue===""+l||(t.defaultValue=""+l)}function ma(t,e,l,a){if(t=t.options,e){e={};for(var n=0;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Gu=!1;if(Ie)try{var an={};Object.defineProperty(an,"passive",{get:function(){Gu=!0}}),window.addEventListener("test",an,an),window.removeEventListener("test",an,an)}catch{Gu=!1}var gl=null,Xu=null,hi=null;function Qr(){if(hi)return hi;var t,e=Xu,l=e.length,a,n="value"in gl?gl.value:gl.textContent,u=n.length;for(t=0;t=cn),Kr=" ",Zr=!1;function kr(t,e){switch(t){case"keyup":return sy.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Vr(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var ga=!1;function fy(t,e){switch(t){case"compositionend":return Vr(e);case"keypress":return e.which!==32?null:(Zr=!0,Kr);case"textInput":return t=e.data,t===Kr&&Zr?null:t;default:return null}}function oy(t,e){if(ga)return t==="compositionend"||!Ju&&kr(t,e)?(t=Qr(),hi=Xu=gl=null,ga=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:l,offset:e-t};t=a}t:{for(;l;){if(l.nextSibling){l=l.nextSibling;break t}l=l.parentNode}l=void 0}l=ef(l)}}function af(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?af(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function nf(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var e=oi(t.document);e instanceof t.HTMLIFrameElement;){try{var l=typeof e.contentWindow.location.href=="string"}catch{l=!1}if(l)t=e.contentWindow;else break;e=oi(t.document)}return e}function Wu(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}var by=Ie&&"documentMode"in document&&11>=document.documentMode,ba=null,Iu=null,on=null,Pu=!1;function uf(t,e,l){var a=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Pu||ba==null||ba!==oi(a)||(a=ba,"selectionStart"in a&&Wu(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),on&&fn(on,a)||(on=a,a=uu(Iu,"onSelect"),0>=s,n-=s,ke=1<<32-Se(e)+n|l<tt?(ut=K,K=null):ut=K.sibling;var mt=O(j,K,T[tt],R);if(mt===null){K===null&&(K=ut);break}t&&K&&mt.alternate===null&&e(j,K),b=u(mt,b,tt),ht===null?Z=mt:ht.sibling=mt,ht=mt,K=ut}if(tt===T.length)return l(j,K),ct&&tl(j,tt),Z;if(K===null){for(;tttt?(ut=K,K=null):ut=K.sibling;var Ll=O(j,K,mt.value,R);if(Ll===null){K===null&&(K=ut);break}t&&K&&Ll.alternate===null&&e(j,K),b=u(Ll,b,tt),ht===null?Z=Ll:ht.sibling=Ll,ht=Ll,K=ut}if(mt.done)return l(j,K),ct&&tl(j,tt),Z;if(K===null){for(;!mt.done;tt++,mt=T.next())mt=U(j,mt.value,R),mt!==null&&(b=u(mt,b,tt),ht===null?Z=mt:ht.sibling=mt,ht=mt);return ct&&tl(j,tt),Z}for(K=a(K);!mt.done;tt++,mt=T.next())mt=C(K,j,tt,mt.value,R),mt!==null&&(t&&mt.alternate!==null&&K.delete(mt.key===null?tt:mt.key),b=u(mt,b,tt),ht===null?Z=mt:ht.sibling=mt,ht=mt);return t&&K.forEach(function(Bv){return e(j,Bv)}),ct&&tl(j,tt),Z}function Tt(j,b,T,R){if(typeof T=="object"&&T!==null&&T.type===w&&T.key===null&&(T=T.props.children),typeof T=="object"&&T!==null){switch(T.$$typeof){case q:t:{for(var Z=T.key;b!==null;){if(b.key===Z){if(Z=T.type,Z===w){if(b.tag===7){l(j,b.sibling),R=n(b,T.props.children),R.return=j,j=R;break t}}else if(b.elementType===Z||typeof Z=="object"&&Z!==null&&Z.$$typeof===gt&&ea(Z)===b.type){l(j,b.sibling),R=n(b,T.props),pn(R,T),R.return=j,j=R;break t}l(j,b);break}else e(j,b);b=b.sibling}T.type===w?(R=$l(T.props.children,j.mode,R,T.key),R.return=j,j=R):(R=Ei(T.type,T.key,T.props,null,j.mode,R),pn(R,T),R.return=j,j=R)}return s(j);case z:t:{for(Z=T.key;b!==null;){if(b.key===Z)if(b.tag===4&&b.stateNode.containerInfo===T.containerInfo&&b.stateNode.implementation===T.implementation){l(j,b.sibling),R=n(b,T.children||[]),R.return=j,j=R;break t}else{l(j,b);break}else e(j,b);b=b.sibling}R=uc(T,j.mode,R),R.return=j,j=R}return s(j);case gt:return T=ea(T),Tt(j,b,T,R)}if(kt(T))return X(j,b,T,R);if(_t(T)){if(Z=_t(T),typeof Z!="function")throw Error(f(150));return T=Z.call(T),F(j,b,T,R)}if(typeof T.then=="function")return Tt(j,b,zi(T),R);if(T.$$typeof===ot)return Tt(j,b,Oi(j,T),R);_i(j,T)}return typeof T=="string"&&T!==""||typeof T=="number"||typeof T=="bigint"?(T=""+T,b!==null&&b.tag===6?(l(j,b.sibling),R=n(b,T),R.return=j,j=R):(l(j,b),R=ic(T,j.mode,R),R.return=j,j=R),s(j)):l(j,b)}return function(j,b,T,R){try{vn=0;var Z=Tt(j,b,T,R);return za=null,Z}catch(K){if(K===Ca||K===Ai)throw K;var ht=je(29,K,null,j.mode);return ht.lanes=R,ht.return=j,ht}}}var aa=Cf(!0),zf=Cf(!1),El=!1;function gc(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function bc(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function Tl(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function Nl(t,e,l){var a=t.updateQueue;if(a===null)return null;if(a=a.shared,(pt&2)!==0){var n=a.pending;return n===null?e.next=e:(e.next=n.next,n.next=e),a.pending=e,e=ji(t),hf(t,null,l),e}return xi(t,a,e,l),ji(t)}function gn(t,e,l){if(e=e.updateQueue,e!==null&&(e=e.shared,(l&4194048)!==0)){var a=e.lanes;a&=t.pendingLanes,l|=a,e.lanes=l,Sr(t,l)}}function Sc(t,e){var l=t.updateQueue,a=t.alternate;if(a!==null&&(a=a.updateQueue,l===a)){var n=null,u=null;if(l=l.firstBaseUpdate,l!==null){do{var s={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};u===null?n=u=s:u=u.next=s,l=l.next}while(l!==null);u===null?n=u=e:u=u.next=e}else n=u=e;l={baseState:a.baseState,firstBaseUpdate:n,lastBaseUpdate:u,shared:a.shared,callbacks:a.callbacks},t.updateQueue=l;return}t=l.lastBaseUpdate,t===null?l.firstBaseUpdate=e:t.next=e,l.lastBaseUpdate=e}var xc=!1;function bn(){if(xc){var t=Aa;if(t!==null)throw t}}function Sn(t,e,l,a){xc=!1;var n=t.updateQueue;El=!1;var u=n.firstBaseUpdate,s=n.lastBaseUpdate,h=n.shared.pending;if(h!==null){n.shared.pending=null;var v=h,N=v.next;v.next=null,s===null?u=N:s.next=N,s=v;var _=t.alternate;_!==null&&(_=_.updateQueue,h=_.lastBaseUpdate,h!==s&&(h===null?_.firstBaseUpdate=N:h.next=N,_.lastBaseUpdate=v))}if(u!==null){var U=n.baseState;s=0,_=N=v=null,h=u;do{var O=h.lane&-536870913,C=O!==h.lane;if(C?(it&O)===O:(a&O)===O){O!==0&&O===Ma&&(xc=!0),_!==null&&(_=_.next={lane:0,tag:h.tag,payload:h.payload,callback:null,next:null});t:{var X=t,F=h;O=e;var Tt=l;switch(F.tag){case 1:if(X=F.payload,typeof X=="function"){U=X.call(Tt,U,O);break t}U=X;break t;case 3:X.flags=X.flags&-65537|128;case 0:if(X=F.payload,O=typeof X=="function"?X.call(Tt,U,O):X,O==null)break t;U=E({},U,O);break t;case 2:El=!0}}O=h.callback,O!==null&&(t.flags|=64,C&&(t.flags|=8192),C=n.callbacks,C===null?n.callbacks=[O]:C.push(O))}else C={lane:O,tag:h.tag,payload:h.payload,callback:h.callback,next:null},_===null?(N=_=C,v=U):_=_.next=C,s|=O;if(h=h.next,h===null){if(h=n.shared.pending,h===null)break;C=h,h=C.next,C.next=null,n.lastBaseUpdate=C,n.shared.pending=null}}while(!0);_===null&&(v=U),n.baseState=v,n.firstBaseUpdate=N,n.lastBaseUpdate=_,u===null&&(n.shared.lanes=0),zl|=s,t.lanes=s,t.memoizedState=U}}function _f(t,e){if(typeof t!="function")throw Error(f(191,t));t.call(e)}function Df(t,e){var l=t.callbacks;if(l!==null)for(t.callbacks=null,t=0;tu?u:8;var s=D.T,h={};D.T=h,Lc(t,!1,e,l);try{var v=n(),N=D.S;if(N!==null&&N(h,v),v!==null&&typeof v=="object"&&typeof v.then=="function"){var _=Ay(v,a);En(t,e,_,Me(t))}else En(t,e,a,Me(t))}catch(U){En(t,e,{then:function(){},status:"rejected",reason:U},Me())}finally{B.p=u,s!==null&&h.types!==null&&(s.types=h.types),D.T=s}}function Uy(){}function Qc(t,e,l,a){if(t.tag!==5)throw Error(f(476));var n=fo(t).queue;ro(t,n,e,V,l===null?Uy:function(){return oo(t),l(a)})}function fo(t){var e=t.memoizedState;if(e!==null)return e;e={memoizedState:V,baseState:V,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:nl,lastRenderedState:V},next:null};var l={};return e.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:nl,lastRenderedState:l},next:null},t.memoizedState=e,t=t.alternate,t!==null&&(t.memoizedState=e),e}function oo(t){var e=fo(t);e.next===null&&(e=t.alternate.memoizedState),En(t,e.next.queue,{},Me())}function Bc(){return It(Ln)}function ho(){return Bt().memoizedState}function mo(){return Bt().memoizedState}function Hy(t){for(var e=t.return;e!==null;){switch(e.tag){case 24:case 3:var l=Me();t=Tl(l);var a=Nl(e,t,l);a!==null&&(ye(a,e,l),gn(a,e,l)),e={cache:mc()},t.payload=e;return}e=e.return}}function qy(t,e,l){var a=Me();l={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Yi(t)?vo(e,l):(l=ac(t,e,l,a),l!==null&&(ye(l,t,a),po(l,e,a)))}function yo(t,e,l){var a=Me();En(t,e,l,a)}function En(t,e,l,a){var n={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Yi(t))vo(e,n);else{var u=t.alternate;if(t.lanes===0&&(u===null||u.lanes===0)&&(u=e.lastRenderedReducer,u!==null))try{var s=e.lastRenderedState,h=u(s,l);if(n.hasEagerState=!0,n.eagerState=h,xe(h,s))return xi(t,e,n,0),Nt===null&&Si(),!1}catch{}if(l=ac(t,e,n,a),l!==null)return ye(l,t,a),po(l,e,a),!0}return!1}function Lc(t,e,l,a){if(a={lane:2,revertLane:gs(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Yi(t)){if(e)throw Error(f(479))}else e=ac(t,l,a,2),e!==null&&ye(e,t,2)}function Yi(t){var e=t.alternate;return t===I||e!==null&&e===I}function vo(t,e){Da=Ui=!0;var l=t.pending;l===null?e.next=e:(e.next=l.next,l.next=e),t.pending=e}function po(t,e,l){if((l&4194048)!==0){var a=e.lanes;a&=t.pendingLanes,l|=a,e.lanes=l,Sr(t,l)}}var Tn={readContext:It,use:wi,useCallback:Ht,useContext:Ht,useEffect:Ht,useImperativeHandle:Ht,useLayoutEffect:Ht,useInsertionEffect:Ht,useMemo:Ht,useReducer:Ht,useRef:Ht,useState:Ht,useDebugValue:Ht,useDeferredValue:Ht,useTransition:Ht,useSyncExternalStore:Ht,useId:Ht,useHostTransitionStatus:Ht,useFormState:Ht,useActionState:Ht,useOptimistic:Ht,useMemoCache:Ht,useCacheRefresh:Ht};Tn.useEffectEvent=Ht;var go={readContext:It,use:wi,useCallback:function(t,e){return ie().memoizedState=[t,e===void 0?null:e],t},useContext:It,useEffect:to,useImperativeHandle:function(t,e,l){l=l!=null?l.concat([t]):null,Bi(4194308,4,no.bind(null,e,t),l)},useLayoutEffect:function(t,e){return Bi(4194308,4,t,e)},useInsertionEffect:function(t,e){Bi(4,2,t,e)},useMemo:function(t,e){var l=ie();e=e===void 0?null:e;var a=t();if(na){vl(!0);try{t()}finally{vl(!1)}}return l.memoizedState=[a,e],a},useReducer:function(t,e,l){var a=ie();if(l!==void 0){var n=l(e);if(na){vl(!0);try{l(e)}finally{vl(!1)}}}else n=e;return a.memoizedState=a.baseState=n,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:n},a.queue=t,t=t.dispatch=qy.bind(null,I,t),[a.memoizedState,t]},useRef:function(t){var e=ie();return t={current:t},e.memoizedState=t},useState:function(t){t=Rc(t);var e=t.queue,l=yo.bind(null,I,e);return e.dispatch=l,[t.memoizedState,l]},useDebugValue:qc,useDeferredValue:function(t,e){var l=ie();return wc(l,t,e)},useTransition:function(){var t=Rc(!1);return t=ro.bind(null,I,t.queue,!0,!1),ie().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,e,l){var a=I,n=ie();if(ct){if(l===void 0)throw Error(f(407));l=l()}else{if(l=e(),Nt===null)throw Error(f(349));(it&127)!==0||Qf(a,e,l)}n.memoizedState=l;var u={value:l,getSnapshot:e};return n.queue=u,to(Lf.bind(null,a,u,t),[t]),a.flags|=2048,Ua(9,{destroy:void 0},Bf.bind(null,a,u,l,e),null),l},useId:function(){var t=ie(),e=Nt.identifierPrefix;if(ct){var l=Ve,a=ke;l=(a&~(1<<32-Se(a)-1)).toString(32)+l,e="_"+e+"R_"+l,l=Hi++,0<\/script>",u=u.removeChild(u.firstChild);break;case"select":u=typeof a.is=="string"?s.createElement("select",{is:a.is}):s.createElement("select"),a.multiple?u.multiple=!0:a.size&&(u.size=a.size);break;default:u=typeof a.is=="string"?s.createElement(n,{is:a.is}):s.createElement(n)}}u[$t]=e,u[re]=a;t:for(s=e.child;s!==null;){if(s.tag===5||s.tag===6)u.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===e)break t;for(;s.sibling===null;){if(s.return===null||s.return===e)break t;s=s.return}s.sibling.return=s.return,s=s.sibling}e.stateNode=u;t:switch(te(u,n,a),n){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break t;case"img":a=!0;break t;default:a=!1}a&&ul(e)}}return At(e),ts(e,e.type,t===null?null:t.memoizedProps,e.pendingProps,l),null;case 6:if(t&&e.stateNode!=null)t.memoizedProps!==a&&ul(e);else{if(typeof a!="string"&&e.stateNode===null)throw Error(f(166));if(t=lt.current,Na(e)){if(t=e.stateNode,l=e.memoizedProps,a=null,n=Wt,n!==null)switch(n.tag){case 27:case 5:a=n.memoizedProps}t[$t]=e,t=!!(t.nodeValue===l||a!==null&&a.suppressHydrationWarning===!0||wd(t.nodeValue,l)),t||xl(e,!0)}else t=cu(t).createTextNode(a),t[$t]=e,e.stateNode=t}return At(e),null;case 31:if(l=e.memoizedState,t===null||t.memoizedState!==null){if(a=Na(e),l!==null){if(t===null){if(!a)throw Error(f(318));if(t=e.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(f(557));t[$t]=e}else Wl(),(e.flags&128)===0&&(e.memoizedState=null),e.flags|=4;At(e),t=!1}else l=fc(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=l),t=!0;if(!t)return e.flags&256?(Te(e),e):(Te(e),null);if((e.flags&128)!==0)throw Error(f(558))}return At(e),null;case 13:if(a=e.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(n=Na(e),a!==null&&a.dehydrated!==null){if(t===null){if(!n)throw Error(f(318));if(n=e.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(f(317));n[$t]=e}else Wl(),(e.flags&128)===0&&(e.memoizedState=null),e.flags|=4;At(e),n=!1}else n=fc(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=n),n=!0;if(!n)return e.flags&256?(Te(e),e):(Te(e),null)}return Te(e),(e.flags&128)!==0?(e.lanes=l,e):(l=a!==null,t=t!==null&&t.memoizedState!==null,l&&(a=e.child,n=null,a.alternate!==null&&a.alternate.memoizedState!==null&&a.alternate.memoizedState.cachePool!==null&&(n=a.alternate.memoizedState.cachePool.pool),u=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(u=a.memoizedState.cachePool.pool),u!==n&&(a.flags|=2048)),l!==t&&l&&(e.child.flags|=8192),ki(e,e.updateQueue),At(e),null);case 4:return Dt(),t===null&&js(e.stateNode.containerInfo),At(e),null;case 10:return ll(e.type),At(e),null;case 19:if(H(Qt),a=e.memoizedState,a===null)return At(e),null;if(n=(e.flags&128)!==0,u=a.rendering,u===null)if(n)On(a,!1);else{if(qt!==0||t!==null&&(t.flags&128)!==0)for(t=e.child;t!==null;){if(u=Ri(t),u!==null){for(e.flags|=128,On(a,!1),t=u.updateQueue,e.updateQueue=t,ki(e,t),e.subtreeFlags=0,t=l,l=e.child;l!==null;)mf(l,t),l=l.sibling;return L(Qt,Qt.current&1|2),ct&&tl(e,a.treeForkCount),e.child}t=t.sibling}a.tail!==null&&ne()>Wi&&(e.flags|=128,n=!0,On(a,!1),e.lanes=4194304)}else{if(!n)if(t=Ri(u),t!==null){if(e.flags|=128,n=!0,t=t.updateQueue,e.updateQueue=t,ki(e,t),On(a,!0),a.tail===null&&a.tailMode==="hidden"&&!u.alternate&&!ct)return At(e),null}else 2*ne()-a.renderingStartTime>Wi&&l!==536870912&&(e.flags|=128,n=!0,On(a,!1),e.lanes=4194304);a.isBackwards?(u.sibling=e.child,e.child=u):(t=a.last,t!==null?t.sibling=u:e.child=u,a.last=u)}return a.tail!==null?(t=a.tail,a.rendering=t,a.tail=t.sibling,a.renderingStartTime=ne(),t.sibling=null,l=Qt.current,L(Qt,n?l&1|2:l&1),ct&&tl(e,a.treeForkCount),t):(At(e),null);case 22:case 23:return Te(e),Ec(),a=e.memoizedState!==null,t!==null?t.memoizedState!==null!==a&&(e.flags|=8192):a&&(e.flags|=8192),a?(l&536870912)!==0&&(e.flags&128)===0&&(At(e),e.subtreeFlags&6&&(e.flags|=8192)):At(e),l=e.updateQueue,l!==null&&ki(e,l.retryQueue),l=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(l=t.memoizedState.cachePool.pool),a=null,e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),a!==l&&(e.flags|=2048),t!==null&&H(ta),null;case 24:return l=null,t!==null&&(l=t.memoizedState.cache),e.memoizedState.cache!==l&&(e.flags|=2048),ll(Lt),At(e),null;case 25:return null;case 30:return null}throw Error(f(156,e.tag))}function Yy(t,e){switch(sc(e),e.tag){case 1:return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return ll(Lt),Dt(),t=e.flags,(t&65536)!==0&&(t&128)===0?(e.flags=t&-65537|128,e):null;case 26:case 27:case 5:return ml(e),null;case 31:if(e.memoizedState!==null){if(Te(e),e.alternate===null)throw Error(f(340));Wl()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 13:if(Te(e),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(f(340));Wl()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return H(Qt),null;case 4:return Dt(),null;case 10:return ll(e.type),null;case 22:case 23:return Te(e),Ec(),t!==null&&H(ta),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 24:return ll(Lt),null;case 25:return null;default:return null}}function Go(t,e){switch(sc(e),e.tag){case 3:ll(Lt),Dt();break;case 26:case 27:case 5:ml(e);break;case 4:Dt();break;case 31:e.memoizedState!==null&&Te(e);break;case 13:Te(e);break;case 19:H(Qt);break;case 10:ll(e.type);break;case 22:case 23:Te(e),Ec(),t!==null&&H(ta);break;case 24:ll(Lt)}}function Mn(t,e){try{var l=e.updateQueue,a=l!==null?l.lastEffect:null;if(a!==null){var n=a.next;l=n;do{if((l.tag&t)===t){a=void 0;var u=l.create,s=l.inst;a=u(),s.destroy=a}l=l.next}while(l!==n)}}catch(h){St(e,e.return,h)}}function Al(t,e,l){try{var a=e.updateQueue,n=a!==null?a.lastEffect:null;if(n!==null){var u=n.next;a=u;do{if((a.tag&t)===t){var s=a.inst,h=s.destroy;if(h!==void 0){s.destroy=void 0,n=e;var v=l,N=h;try{N()}catch(_){St(n,v,_)}}}a=a.next}while(a!==u)}}catch(_){St(e,e.return,_)}}function Xo(t){var e=t.updateQueue;if(e!==null){var l=t.stateNode;try{Df(e,l)}catch(a){St(t,t.return,a)}}}function Ko(t,e,l){l.props=ia(t.type,t.memoizedProps),l.state=t.memoizedState;try{l.componentWillUnmount()}catch(a){St(t,e,a)}}function An(t,e){try{var l=t.ref;if(l!==null){switch(t.tag){case 26:case 27:case 5:var a=t.stateNode;break;case 30:a=t.stateNode;break;default:a=t.stateNode}typeof l=="function"?t.refCleanup=l(a):l.current=a}}catch(n){St(t,e,n)}}function Je(t,e){var l=t.ref,a=t.refCleanup;if(l!==null)if(typeof a=="function")try{a()}catch(n){St(t,e,n)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(n){St(t,e,n)}else l.current=null}function Zo(t){var e=t.type,l=t.memoizedProps,a=t.stateNode;try{t:switch(e){case"button":case"input":case"select":case"textarea":l.autoFocus&&a.focus();break t;case"img":l.src?a.src=l.src:l.srcSet&&(a.srcset=l.srcSet)}}catch(n){St(t,t.return,n)}}function es(t,e,l){try{var a=t.stateNode;rv(a,t.type,l,e),a[re]=e}catch(n){St(t,t.return,n)}}function ko(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&Hl(t.type)||t.tag===4}function ls(t){t:for(;;){for(;t.sibling===null;){if(t.return===null||ko(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&Hl(t.type)||t.flags&2||t.child===null||t.tag===4)continue t;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function as(t,e,l){var a=t.tag;if(a===5||a===6)t=t.stateNode,e?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(t,e):(e=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,e.appendChild(t),l=l._reactRootContainer,l!=null||e.onclick!==null||(e.onclick=We));else if(a!==4&&(a===27&&Hl(t.type)&&(l=t.stateNode,e=null),t=t.child,t!==null))for(as(t,e,l),t=t.sibling;t!==null;)as(t,e,l),t=t.sibling}function Vi(t,e,l){var a=t.tag;if(a===5||a===6)t=t.stateNode,e?l.insertBefore(t,e):l.appendChild(t);else if(a!==4&&(a===27&&Hl(t.type)&&(l=t.stateNode),t=t.child,t!==null))for(Vi(t,e,l),t=t.sibling;t!==null;)Vi(t,e,l),t=t.sibling}function Vo(t){var e=t.stateNode,l=t.memoizedProps;try{for(var a=t.type,n=e.attributes;n.length;)e.removeAttributeNode(n[0]);te(e,a,l),e[$t]=t,e[re]=l}catch(u){St(t,t.return,u)}}var cl=!1,Xt=!1,ns=!1,Jo=typeof WeakSet=="function"?WeakSet:Set,Ft=null;function Gy(t,e){if(t=t.containerInfo,Ns=mu,t=nf(t),Wu(t)){if("selectionStart"in t)var l={start:t.selectionStart,end:t.selectionEnd};else t:{l=(l=t.ownerDocument)&&l.defaultView||window;var a=l.getSelection&&l.getSelection();if(a&&a.rangeCount!==0){l=a.anchorNode;var n=a.anchorOffset,u=a.focusNode;a=a.focusOffset;try{l.nodeType,u.nodeType}catch{l=null;break t}var s=0,h=-1,v=-1,N=0,_=0,U=t,O=null;e:for(;;){for(var C;U!==l||n!==0&&U.nodeType!==3||(h=s+n),U!==u||a!==0&&U.nodeType!==3||(v=s+a),U.nodeType===3&&(s+=U.nodeValue.length),(C=U.firstChild)!==null;)O=U,U=C;for(;;){if(U===t)break e;if(O===l&&++N===n&&(h=s),O===u&&++_===a&&(v=s),(C=U.nextSibling)!==null)break;U=O,O=U.parentNode}U=C}l=h===-1||v===-1?null:{start:h,end:v}}else l=null}l=l||{start:0,end:0}}else l=null;for(Os={focusedElem:t,selectionRange:l},mu=!1,Ft=e;Ft!==null;)if(e=Ft,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,Ft=t;else for(;Ft!==null;){switch(e=Ft,u=e.alternate,t=e.flags,e.tag){case 0:if((t&4)!==0&&(t=e.updateQueue,t=t!==null?t.events:null,t!==null))for(l=0;l title"))),te(u,a,l),u[$t]=t,Jt(u),a=u;break t;case"link":var s=th("link","href",n).get(a+(l.href||""));if(s){for(var h=0;hTt&&(s=Tt,Tt=F,F=s);var j=lf(h,F),b=lf(h,Tt);if(j&&b&&(C.rangeCount!==1||C.anchorNode!==j.node||C.anchorOffset!==j.offset||C.focusNode!==b.node||C.focusOffset!==b.offset)){var T=U.createRange();T.setStart(j.node,j.offset),C.removeAllRanges(),F>Tt?(C.addRange(T),C.extend(b.node,b.offset)):(T.setEnd(b.node,b.offset),C.addRange(T))}}}}for(U=[],C=h;C=C.parentNode;)C.nodeType===1&&U.push({element:C,left:C.scrollLeft,top:C.scrollTop});for(typeof h.focus=="function"&&h.focus(),h=0;hl?32:l,D.T=null,l=os,os=null;var u=Dl,s=dl;if(Kt=0,Ba=Dl=null,dl=0,(pt&6)!==0)throw Error(f(331));var h=pt;if(pt|=4,id(u.current),ld(u,u.current,s,l),pt=h,Un(0,!1),be&&typeof be.onPostCommitFiberRoot=="function")try{be.onPostCommitFiberRoot(Wa,u)}catch{}return!0}finally{B.p=n,D.T=a,Ed(t,e)}}function Nd(t,e,l){e=Ue(l,e),e=Kc(t.stateNode,e,2),t=Nl(t,e,2),t!==null&&(Pa(t,2),Fe(t))}function St(t,e,l){if(t.tag===3)Nd(t,t,l);else for(;e!==null;){if(e.tag===3){Nd(e,t,l);break}else if(e.tag===1){var a=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(_l===null||!_l.has(a))){t=Ue(l,t),l=Oo(2),a=Nl(e,l,2),a!==null&&(Mo(l,a,e,t),Pa(a,2),Fe(a));break}}e=e.return}}function ys(t,e,l){var a=t.pingCache;if(a===null){a=t.pingCache=new Zy;var n=new Set;a.set(e,n)}else n=a.get(e),n===void 0&&(n=new Set,a.set(e,n));n.has(l)||(cs=!0,n.add(l),t=$y.bind(null,t,e,l),e.then(t,t))}function $y(t,e,l){var a=t.pingCache;a!==null&&a.delete(e),t.pingedLanes|=t.suspendedLanes&l,t.warmLanes&=~l,Nt===t&&(it&l)===l&&(qt===4||qt===3&&(it&62914560)===it&&300>ne()-$i?(pt&2)===0&&La(t,0):ss|=l,Qa===it&&(Qa=0)),Fe(t)}function Od(t,e){e===0&&(e=gr()),t=Fl(t,e),t!==null&&(Pa(t,e),Fe(t))}function Wy(t){var e=t.memoizedState,l=0;e!==null&&(l=e.retryLane),Od(t,l)}function Iy(t,e){var l=0;switch(t.tag){case 31:case 13:var a=t.stateNode,n=t.memoizedState;n!==null&&(l=n.retryLane);break;case 19:a=t.stateNode;break;case 22:a=t.stateNode._retryCache;break;default:throw Error(f(314))}a!==null&&a.delete(e),Od(t,l)}function Py(t,e){return ft(t,e)}var au=null,Ga=null,vs=!1,nu=!1,ps=!1,Ul=0;function Fe(t){t!==Ga&&t.next===null&&(Ga===null?au=Ga=t:Ga=Ga.next=t),nu=!0,vs||(vs=!0,ev())}function Un(t,e){if(!ps&&nu){ps=!0;do for(var l=!1,a=au;a!==null;){if(t!==0){var n=a.pendingLanes;if(n===0)var u=0;else{var s=a.suspendedLanes,h=a.pingedLanes;u=(1<<31-Se(42|t)+1)-1,u&=n&~(s&~h),u=u&201326741?u&201326741|1:u?u|2:0}u!==0&&(l=!0,zd(a,u))}else u=it,u=si(a,a===Nt?u:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(u&3)===0||Ia(a,u)||(l=!0,zd(a,u));a=a.next}while(l);ps=!1}}function tv(){Md()}function Md(){nu=vs=!1;var t=0;Ul!==0&&ov()&&(t=Ul);for(var e=ne(),l=null,a=au;a!==null;){var n=a.next,u=Ad(a,e);u===0?(a.next=null,l===null?au=n:l.next=n,n===null&&(Ga=l)):(l=a,(t!==0||(u&3)!==0)&&(nu=!0)),a=n}Kt!==0&&Kt!==5||Un(t),Ul!==0&&(Ul=0)}function Ad(t,e){for(var l=t.suspendedLanes,a=t.pingedLanes,n=t.expirationTimes,u=t.pendingLanes&-62914561;0h)break;var _=v.transferSize,U=v.initiatorType;_&&Qd(U)&&(v=v.responseEnd,s+=_*(v"u"?null:document;function $d(t,e,l){var a=Xa;if(a&&typeof e=="string"&&e){var n=De(e);n='link[rel="'+t+'"][href="'+n+'"]',typeof l=="string"&&(n+='[crossorigin="'+l+'"]'),Fd.has(n)||(Fd.add(n),t={rel:t,crossOrigin:l,href:e},a.querySelector(n)===null&&(e=a.createElement("link"),te(e,"link",t),Jt(e),a.head.appendChild(e)))}}function Sv(t){hl.D(t),$d("dns-prefetch",t,null)}function xv(t,e){hl.C(t,e),$d("preconnect",t,e)}function jv(t,e,l){hl.L(t,e,l);var a=Xa;if(a&&t&&e){var n='link[rel="preload"][as="'+De(e)+'"]';e==="image"&&l&&l.imageSrcSet?(n+='[imagesrcset="'+De(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(n+='[imagesizes="'+De(l.imageSizes)+'"]')):n+='[href="'+De(t)+'"]';var u=n;switch(e){case"style":u=Ka(t);break;case"script":u=Za(t)}Le.has(u)||(t=E({rel:"preload",href:e==="image"&&l&&l.imageSrcSet?void 0:t,as:e},l),Le.set(u,t),a.querySelector(n)!==null||e==="style"&&a.querySelector(Qn(u))||e==="script"&&a.querySelector(Bn(u))||(e=a.createElement("link"),te(e,"link",t),Jt(e),a.head.appendChild(e)))}}function Ev(t,e){hl.m(t,e);var l=Xa;if(l&&t){var a=e&&typeof e.as=="string"?e.as:"script",n='link[rel="modulepreload"][as="'+De(a)+'"][href="'+De(t)+'"]',u=n;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":u=Za(t)}if(!Le.has(u)&&(t=E({rel:"modulepreload",href:t},e),Le.set(u,t),l.querySelector(n)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Bn(u)))return}a=l.createElement("link"),te(a,"link",t),Jt(a),l.head.appendChild(a)}}}function Tv(t,e,l){hl.S(t,e,l);var a=Xa;if(a&&t){var n=da(a).hoistableStyles,u=Ka(t);e=e||"default";var s=n.get(u);if(!s){var h={loading:0,preload:null};if(s=a.querySelector(Qn(u)))h.loading=5;else{t=E({rel:"stylesheet",href:t,"data-precedence":e},l),(l=Le.get(u))&&Rs(t,l);var v=s=a.createElement("link");Jt(v),te(v,"link",t),v._p=new Promise(function(N,_){v.onload=N,v.onerror=_}),v.addEventListener("load",function(){h.loading|=1}),v.addEventListener("error",function(){h.loading|=2}),h.loading|=4,ru(s,e,a)}s={type:"stylesheet",instance:s,count:1,state:h},n.set(u,s)}}}function Nv(t,e){hl.X(t,e);var l=Xa;if(l&&t){var a=da(l).hoistableScripts,n=Za(t),u=a.get(n);u||(u=l.querySelector(Bn(n)),u||(t=E({src:t,async:!0},e),(e=Le.get(n))&&Us(t,e),u=l.createElement("script"),Jt(u),te(u,"link",t),l.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},a.set(n,u))}}function Ov(t,e){hl.M(t,e);var l=Xa;if(l&&t){var a=da(l).hoistableScripts,n=Za(t),u=a.get(n);u||(u=l.querySelector(Bn(n)),u||(t=E({src:t,async:!0,type:"module"},e),(e=Le.get(n))&&Us(t,e),u=l.createElement("script"),Jt(u),te(u,"link",t),l.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},a.set(n,u))}}function Wd(t,e,l,a){var n=(n=lt.current)?su(n):null;if(!n)throw Error(f(446));switch(t){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(e=Ka(l.href),l=da(n).hoistableStyles,a=l.get(e),a||(a={type:"style",instance:null,count:0,state:null},l.set(e,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){t=Ka(l.href);var u=da(n).hoistableStyles,s=u.get(t);if(s||(n=n.ownerDocument||n,s={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(t,s),(u=n.querySelector(Qn(t)))&&!u._p&&(s.instance=u,s.state.loading=5),Le.has(t)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Le.set(t,l),u||Mv(n,t,l,s.state))),e&&a===null)throw Error(f(528,""));return s}if(e&&a!==null)throw Error(f(529,""));return null;case"script":return e=l.async,l=l.src,typeof l=="string"&&e&&typeof e!="function"&&typeof e!="symbol"?(e=Za(l),l=da(n).hoistableScripts,a=l.get(e),a||(a={type:"script",instance:null,count:0,state:null},l.set(e,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(f(444,t))}}function Ka(t){return'href="'+De(t)+'"'}function Qn(t){return'link[rel="stylesheet"]['+t+"]"}function Id(t){return E({},t,{"data-precedence":t.precedence,precedence:null})}function Mv(t,e,l,a){t.querySelector('link[rel="preload"][as="style"]['+e+"]")?a.loading=1:(e=t.createElement("link"),a.preload=e,e.addEventListener("load",function(){return a.loading|=1}),e.addEventListener("error",function(){return a.loading|=2}),te(e,"link",l),Jt(e),t.head.appendChild(e))}function Za(t){return'[src="'+De(t)+'"]'}function Bn(t){return"script[async]"+t}function Pd(t,e,l){if(e.count++,e.instance===null)switch(e.type){case"style":var a=t.querySelector('style[data-href~="'+De(l.href)+'"]');if(a)return e.instance=a,Jt(a),a;var n=E({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return a=(t.ownerDocument||t).createElement("style"),Jt(a),te(a,"style",n),ru(a,l.precedence,t),e.instance=a;case"stylesheet":n=Ka(l.href);var u=t.querySelector(Qn(n));if(u)return e.state.loading|=4,e.instance=u,Jt(u),u;a=Id(l),(n=Le.get(n))&&Rs(a,n),u=(t.ownerDocument||t).createElement("link"),Jt(u);var s=u;return s._p=new Promise(function(h,v){s.onload=h,s.onerror=v}),te(u,"link",a),e.state.loading|=4,ru(u,l.precedence,t),e.instance=u;case"script":return u=Za(l.src),(n=t.querySelector(Bn(u)))?(e.instance=n,Jt(n),n):(a=l,(n=Le.get(u))&&(a=E({},l),Us(a,n)),t=t.ownerDocument||t,n=t.createElement("script"),Jt(n),te(n,"link",a),t.head.appendChild(n),e.instance=n);case"void":return null;default:throw Error(f(443,e.type))}else e.type==="stylesheet"&&(e.state.loading&4)===0&&(a=e.instance,e.state.loading|=4,ru(a,l.precedence,t));return e.instance}function ru(t,e,l){for(var a=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),n=a.length?a[a.length-1]:null,u=n,s=0;s title"):null)}function Av(t,e,l){if(l===1||e.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof e.precedence!="string"||typeof e.href!="string"||e.href==="")break;return!0;case"link":if(typeof e.rel!="string"||typeof e.href!="string"||e.href===""||e.onLoad||e.onError)break;return e.rel==="stylesheet"?(t=e.disabled,typeof e.precedence=="string"&&t==null):!0;case"script":if(e.async&&typeof e.async!="function"&&typeof e.async!="symbol"&&!e.onLoad&&!e.onError&&e.src&&typeof e.src=="string")return!0}return!1}function lh(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function Cv(t,e,l,a){if(l.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var n=Ka(a.href),u=e.querySelector(Qn(n));if(u){e=u._p,e!==null&&typeof e=="object"&&typeof e.then=="function"&&(t.count++,t=ou.bind(t),e.then(t,t)),l.state.loading|=4,l.instance=u,Jt(u);return}u=e.ownerDocument||e,a=Id(a),(n=Le.get(n))&&Rs(a,n),u=u.createElement("link"),Jt(u);var s=u;s._p=new Promise(function(h,v){s.onload=h,s.onerror=v}),te(u,"link",a),l.instance=u}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(l,e),(e=l.state.preload)&&(l.state.loading&3)===0&&(t.count++,l=ou.bind(t),e.addEventListener("load",l),e.addEventListener("error",l))}}var Hs=0;function zv(t,e){return t.stylesheets&&t.count===0&&hu(t,t.stylesheets),0Hs?50:800)+e);return t.unsuspend=l,function(){t.unsuspend=null,clearTimeout(a),clearTimeout(n)}}:null}function ou(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)hu(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var du=null;function hu(t,e){t.stylesheets=null,t.unsuspend!==null&&(t.count++,du=new Map,e.forEach(_v,t),du=null,ou.call(t))}function _v(t,e){if(!(e.state.loading&4)){var l=du.get(t);if(l)var a=l.get(null);else{l=new Map,du.set(t,l);for(var n=t.querySelectorAll("link[data-precedence],style[data-precedence]"),u=0;u"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(c){console.error(c)}}return i(),Ks.exports=Vv(),Ks.exports}var Fv=Jv(),ti=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(i){return this.listeners.add(i),this.onSubscribe(),()=>{this.listeners.delete(i),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},$v=class extends ti{#t;#e;#l;constructor(){super(),this.#l=i=>{if(typeof window<"u"&&window.addEventListener){const c=()=>i();return window.addEventListener("visibilitychange",c,!1),()=>{window.removeEventListener("visibilitychange",c)}}}}onSubscribe(){this.#e||this.setEventListener(this.#l)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(i){this.#l=i,this.#e?.(),this.#e=i(c=>{typeof c=="boolean"?this.setFocused(c):this.onFocus()})}setFocused(i){this.#t!==i&&(this.#t=i,this.onFocus())}onFocus(){const i=this.isFocused();this.listeners.forEach(c=>{c(i)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},cr=new $v,Wv={setTimeout:(i,c)=>setTimeout(i,c),clearTimeout:i=>clearTimeout(i),setInterval:(i,c)=>setInterval(i,c),clearInterval:i=>clearInterval(i)},Iv=class{#t=Wv;#e=!1;setTimeoutProvider(i){this.#t=i}setTimeout(i,c){return this.#t.setTimeout(i,c)}clearTimeout(i){this.#t.clearTimeout(i)}setInterval(i,c){return this.#t.setInterval(i,c)}clearInterval(i){this.#t.clearInterval(i)}},sa=new Iv;function Pv(i){setTimeout(i,0)}var t0=typeof window>"u"||"Deno"in globalThis;function ve(){}function e0(i,c){return typeof i=="function"?i(c):i}function Ws(i){return typeof i=="number"&&i>=0&&i!==1/0}function Vh(i,c){return Math.max(i+(c||0)-Date.now(),0)}function Gl(i,c){return typeof i=="function"?i(c):i}function Ae(i,c){return typeof i=="function"?i(c):i}function Oh(i,c){const{type:r="all",exact:f,fetchStatus:d,predicate:m,queryKey:g,stale:A}=i;if(g){if(f){if(c.queryHash!==sr(g,c.options))return!1}else if(!Jn(c.queryKey,g))return!1}if(r!=="all"){const p=c.isActive();if(r==="active"&&!p||r==="inactive"&&p)return!1}return!(typeof A=="boolean"&&c.isStale()!==A||d&&d!==c.state.fetchStatus||m&&!m(c))}function Mh(i,c){const{exact:r,status:f,predicate:d,mutationKey:m}=i;if(m){if(!c.options.mutationKey)return!1;if(r){if(Vn(c.options.mutationKey)!==Vn(m))return!1}else if(!Jn(c.options.mutationKey,m))return!1}return!(f&&c.state.status!==f||d&&!d(c))}function sr(i,c){return(c?.queryKeyHashFn||Vn)(i)}function Vn(i){return JSON.stringify(i,(c,r)=>Ps(r)?Object.keys(r).sort().reduce((f,d)=>(f[d]=r[d],f),{}):r)}function Jn(i,c){return i===c?!0:typeof i!=typeof c?!1:i&&c&&typeof i=="object"&&typeof c=="object"?Object.keys(c).every(r=>Jn(i[r],c[r])):!1}var l0=Object.prototype.hasOwnProperty;function Jh(i,c,r=0){if(i===c)return i;if(r>500)return c;const f=Ah(i)&&Ah(c);if(!f&&!(Ps(i)&&Ps(c)))return c;const m=(f?i:Object.keys(i)).length,g=f?c:Object.keys(c),A=g.length,p=f?new Array(A):{};let y=0;for(let M=0;M{sa.setTimeout(c,i)})}function tr(i,c,r){return typeof r.structuralSharing=="function"?r.structuralSharing(i,c):r.structuralSharing!==!1?Jh(i,c):c}function n0(i,c,r=0){const f=[...i,c];return r&&f.length>r?f.slice(1):f}function i0(i,c,r=0){const f=[c,...i];return r&&f.length>r?f.slice(0,-1):f}var rr=Symbol();function Fh(i,c){return!i.queryFn&&c?.initialPromise?()=>c.initialPromise:!i.queryFn||i.queryFn===rr?()=>Promise.reject(new Error(`Missing queryFn: '${i.queryHash}'`)):i.queryFn}function $h(i,c){return typeof i=="function"?i(...c):!!i}function u0(i,c,r){let f=!1,d;return Object.defineProperty(i,"signal",{enumerable:!0,get:()=>(d??=c(),f||(f=!0,d.aborted?r():d.addEventListener("abort",r,{once:!0})),d)}),i}var Fn=(()=>{let i=()=>t0;return{isServer(){return i()},setIsServer(c){i=c}}})();function er(){let i,c;const r=new Promise((d,m)=>{i=d,c=m});r.status="pending",r.catch(()=>{});function f(d){Object.assign(r,d),delete r.resolve,delete r.reject}return r.resolve=d=>{f({status:"fulfilled",value:d}),i(d)},r.reject=d=>{f({status:"rejected",reason:d}),c(d)},r}var c0=Pv;function s0(){let i=[],c=0,r=A=>{A()},f=A=>{A()},d=c0;const m=A=>{c?i.push(A):d(()=>{r(A)})},g=()=>{const A=i;i=[],A.length&&d(()=>{f(()=>{A.forEach(p=>{r(p)})})})};return{batch:A=>{let p;c++;try{p=A()}finally{c--,c||g()}return p},batchCalls:A=>(...p)=>{m(()=>{A(...p)})},schedule:m,setNotifyFunction:A=>{r=A},setBatchNotifyFunction:A=>{f=A},setScheduler:A=>{d=A}}}var ee=s0(),r0=class extends ti{#t=!0;#e;#l;constructor(){super(),this.#l=i=>{if(typeof window<"u"&&window.addEventListener){const c=()=>i(!0),r=()=>i(!1);return window.addEventListener("online",c,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",c),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#e||this.setEventListener(this.#l)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(i){this.#l=i,this.#e?.(),this.#e=i(this.setOnline.bind(this))}setOnline(i){this.#t!==i&&(this.#t=i,this.listeners.forEach(r=>{r(i)}))}isOnline(){return this.#t}},Ou=new r0;function f0(i){return Math.min(1e3*2**i,3e4)}function Wh(i){return(i??"online")==="online"?Ou.isOnline():!0}var lr=class extends Error{constructor(i){super("CancelledError"),this.revert=i?.revert,this.silent=i?.silent}};function Ih(i){let c=!1,r=0,f;const d=er(),m=()=>d.status!=="pending",g=w=>{if(!m()){const Y=new lr(w);x(Y),i.onCancel?.(Y)}},A=()=>{c=!0},p=()=>{c=!1},y=()=>cr.isFocused()&&(i.networkMode==="always"||Ou.isOnline())&&i.canRun(),M=()=>Wh(i.networkMode)&&i.canRun(),E=w=>{m()||(f?.(),d.resolve(w))},x=w=>{m()||(f?.(),d.reject(w))},q=()=>new Promise(w=>{f=Y=>{(m()||y())&&w(Y)},i.onPause?.()}).then(()=>{f=void 0,m()||i.onContinue?.()}),z=()=>{if(m())return;let w;const Y=r===0?i.initialPromise:void 0;try{w=Y??i.fn()}catch($){w=Promise.reject($)}Promise.resolve(w).then(E).catch($=>{if(m())return;const yt=i.retry??(Fn.isServer()?0:3),ot=i.retryDelay??f0,Ct=typeof ot=="function"?ot(r,$):ot,Rt=yt===!0||typeof yt=="number"&&ry()?void 0:q()).then(()=>{c?x($):z()})})};return{promise:d,status:()=>d.status,cancel:g,continue:()=>(f?.(),d),cancelRetry:A,continueRetry:p,canStart:M,start:()=>(M()?z():q().then(z),d)}}var Ph=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Ws(this.gcTime)&&(this.#t=sa.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(i){this.gcTime=Math.max(this.gcTime||0,i??(Fn.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#t!==void 0&&(sa.clearTimeout(this.#t),this.#t=void 0)}};function o0(i){return{onFetch:(c,r)=>{const f=c.options,d=c.fetchOptions?.meta?.fetchMore?.direction,m=c.state.data?.pages||[],g=c.state.data?.pageParams||[];let A={pages:[],pageParams:[]},p=0;const y=async()=>{let M=!1;const E=z=>{u0(z,()=>c.signal,()=>M=!0)},x=Fh(c.options,c.fetchOptions),q=async(z,w,Y)=>{if(M)return Promise.reject(c.signal.reason);if(w==null&&z.pages.length)return Promise.resolve(z);const yt=(()=>{const et={client:c.client,queryKey:c.queryKey,pageParam:w,direction:Y?"backward":"forward",meta:c.options.meta};return E(et),et})(),ot=await x(yt),{maxPages:Ct}=c.options,Rt=Y?i0:n0;return{pages:Rt(z.pages,ot,Ct),pageParams:Rt(z.pageParams,w,Ct)}};if(d&&m.length){const z=d==="backward",w=z?d0:zh,Y={pages:m,pageParams:g},$=w(f,Y);A=await q(Y,$,z)}else{const z=i??m.length;do{const w=p===0?g[0]??f.initialPageParam:zh(f,A);if(p>0&&w==null)break;A=await q(A,w),p++}while(pc.options.persister?.(y,{client:c.client,queryKey:c.queryKey,meta:c.options.meta,signal:c.signal},r):c.fetchFn=y}}}function zh(i,{pages:c,pageParams:r}){const f=c.length-1;return c.length>0?i.getNextPageParam(c[f],c,r[f],r):void 0}function d0(i,{pages:c,pageParams:r}){return c.length>0?i.getPreviousPageParam?.(c[0],c,r[0],r):void 0}var h0=class extends Ph{#t;#e;#l;#a;#i;#n;#c;#u;constructor(i){super(),this.#u=!1,this.#c=i.defaultOptions,this.setOptions(i.options),this.observers=[],this.#i=i.client,this.#a=this.#i.getQueryCache(),this.queryKey=i.queryKey,this.queryHash=i.queryHash,this.#e=Dh(this.options),this.state=i.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#t}get promise(){return this.#n?.promise}setOptions(i){if(this.options={...this.#c,...i},i?._type&&(this.#t=i._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const c=Dh(this.options);c.data!==void 0&&(this.setState(_h(c.data,c.dataUpdatedAt)),this.#e=c)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#a.remove(this)}setData(i,c){const r=tr(this.state.data,i,this.options);return this.#s({data:r,type:"success",dataUpdatedAt:c?.updatedAt,manual:c?.manual}),r}setState(i){this.#s({type:"setState",state:i})}cancel(i){const c=this.#n?.promise;return this.#n?.cancel(i),c?c.then(ve).catch(ve):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(i=>Ae(i.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===rr||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(i=>Gl(i.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(i=>i.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(i=0){return this.state.data===void 0?!0:i==="static"?!1:this.state.isInvalidated?!0:!Vh(this.state.dataUpdatedAt,i)}onFocus(){this.observers.find(c=>c.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(c=>c.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(i){this.observers.includes(i)||(this.observers.push(i),this.clearGcTimeout(),this.#a.notify({type:"observerAdded",query:this,observer:i}))}removeObserver(i){this.observers.includes(i)&&(this.observers=this.observers.filter(c=>c!==i),this.observers.length||(this.#n&&(this.#u||this.#f()?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#a.notify({type:"observerRemoved",query:this,observer:i}))}getObserversCount(){return this.observers.length}#f(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#s({type:"invalidate"})}async fetch(i,c){if(this.state.fetchStatus!=="idle"&&this.#n?.status()!=="rejected"){if(this.state.data!==void 0&&c?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(i&&this.setOptions(i),!this.options.queryFn){const p=this.observers.find(y=>y.options.queryFn);p&&this.setOptions(p.options)}const r=new AbortController,f=p=>{Object.defineProperty(p,"signal",{enumerable:!0,get:()=>(this.#u=!0,r.signal)})},d=()=>{const p=Fh(this.options,c),M=(()=>{const E={client:this.#i,queryKey:this.queryKey,meta:this.meta};return f(E),E})();return this.#u=!1,this.options.persister?this.options.persister(p,M,this):p(M)},g=(()=>{const p={fetchOptions:c,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:d};return f(p),p})();(this.#t==="infinite"?o0(this.options.pages):this.options.behavior)?.onFetch(g,this),this.#l=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==g.fetchOptions?.meta)&&this.#s({type:"fetch",meta:g.fetchOptions?.meta}),this.#n=Ih({initialPromise:c?.initialPromise,fn:g.fetchFn,onCancel:p=>{p instanceof lr&&p.revert&&this.setState({...this.#l,fetchStatus:"idle"}),r.abort()},onFail:(p,y)=>{this.#s({type:"failed",failureCount:p,error:y})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({type:"continue"})},retry:g.options.retry,retryDelay:g.options.retryDelay,networkMode:g.options.networkMode,canRun:()=>!0});try{const p=await this.#n.start();if(p===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(p),this.#a.config.onSuccess?.(p,this),this.#a.config.onSettled?.(p,this.state.error,this),p}catch(p){if(p instanceof lr){if(p.silent)return this.#n.promise;if(p.revert){if(this.state.data===void 0)throw p;return this.state.data}}throw this.#s({type:"error",error:p}),this.#a.config.onError?.(p,this),this.#a.config.onSettled?.(this.state.data,p,this),p}finally{this.scheduleGc()}}#s(i){const c=r=>{switch(i.type){case"failed":return{...r,fetchFailureCount:i.failureCount,fetchFailureReason:i.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...tm(r.data,this.options),fetchMeta:i.meta??null};case"success":const f={...r,..._h(i.data,i.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!i.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#l=i.manual?f:void 0,f;case"error":const d=i.error;return{...r,error:d,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:d,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...i.state}}};this.state=c(this.state),ee.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#a.notify({query:this,type:"updated",action:i})})}};function tm(i,c){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Wh(c.networkMode)?"fetching":"paused",...i===void 0&&{error:null,status:"pending"}}}function _h(i,c){return{data:i,dataUpdatedAt:c??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Dh(i){const c=typeof i.initialData=="function"?i.initialData():i.initialData,r=c!==void 0,f=r?typeof i.initialDataUpdatedAt=="function"?i.initialDataUpdatedAt():i.initialDataUpdatedAt:0;return{data:c,dataUpdateCount:0,dataUpdatedAt:r?f??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var m0=class extends ti{constructor(i,c){super(),this.options=c,this.#t=i,this.#u=null,this.#c=er(),this.bindMethods(),this.setOptions(c)}#t;#e=void 0;#l=void 0;#a=void 0;#i;#n;#c;#u;#f;#s;#m;#o;#d;#r;#y=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),Rh(this.#e,this.options)?this.#h():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ar(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ar(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#S(),this.#x(),this.#e.removeObserver(this)}setOptions(i){const c=this.options,r=this.#e;if(this.options=this.#t.defaultQueryOptions(i),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ae(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#j(),this.#e.setOptions(this.options),c._defaulted&&!Is(this.options,c)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const f=this.hasListeners();f&&Uh(this.#e,r,this.options,c)&&this.#h(),this.updateResult(),f&&(this.#e!==r||Ae(this.options.enabled,this.#e)!==Ae(c.enabled,this.#e)||Gl(this.options.staleTime,this.#e)!==Gl(c.staleTime,this.#e))&&this.#v();const d=this.#p();f&&(this.#e!==r||Ae(this.options.enabled,this.#e)!==Ae(c.enabled,this.#e)||d!==this.#r)&&this.#g(d)}getOptimisticResult(i){const c=this.#t.getQueryCache().build(this.#t,i),r=this.createResult(c,i);return v0(this,r)&&(this.#a=r,this.#n=this.options,this.#i=this.#e.state),r}getCurrentResult(){return this.#a}trackResult(i,c){return new Proxy(i,{get:(r,f)=>(this.trackProp(f),c?.(f),f==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#c.status==="pending"&&this.#c.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,f))})}trackProp(i){this.#y.add(i)}getCurrentQuery(){return this.#e}refetch({...i}={}){return this.fetch({...i})}fetchOptimistic(i){const c=this.#t.defaultQueryOptions(i),r=this.#t.getQueryCache().build(this.#t,c);return r.fetch().then(()=>this.createResult(r,c))}fetch(i){return this.#h({...i,cancelRefetch:i.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#a))}#h(i){this.#j();let c=this.#e.fetch(this.options,i);return i?.throwOnError||(c=c.catch(ve)),c}#v(){this.#S();const i=Gl(this.options.staleTime,this.#e);if(Fn.isServer()||this.#a.isStale||!Ws(i))return;const r=Vh(this.#a.dataUpdatedAt,i)+1;this.#o=sa.setTimeout(()=>{this.#a.isStale||this.updateResult()},r)}#p(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#g(i){this.#x(),this.#r=i,!(Fn.isServer()||Ae(this.options.enabled,this.#e)===!1||!Ws(this.#r)||this.#r===0)&&(this.#d=sa.setInterval(()=>{(this.options.refetchIntervalInBackground||cr.isFocused())&&this.#h()},this.#r))}#b(){this.#v(),this.#g(this.#p())}#S(){this.#o!==void 0&&(sa.clearTimeout(this.#o),this.#o=void 0)}#x(){this.#d!==void 0&&(sa.clearInterval(this.#d),this.#d=void 0)}createResult(i,c){const r=this.#e,f=this.options,d=this.#a,m=this.#i,g=this.#n,p=i!==r?i.state:this.#l,{state:y}=i;let M={...y},E=!1,x;if(c._optimisticResults){const gt=this.hasListeners(),wt=!gt&&Rh(i,c),ue=gt&&Uh(i,r,c,f);(wt||ue)&&(M={...M,...tm(y.data,i.options)}),c._optimisticResults==="isRestoring"&&(M.fetchStatus="idle")}let{error:q,errorUpdatedAt:z,status:w}=M;x=M.data;let Y=!1;if(c.placeholderData!==void 0&&x===void 0&&w==="pending"){let gt;d?.isPlaceholderData&&c.placeholderData===g?.placeholderData?(gt=d.data,Y=!0):gt=typeof c.placeholderData=="function"?c.placeholderData(this.#m?.state.data,this.#m):c.placeholderData,gt!==void 0&&(w="success",x=tr(d?.data,gt,c),E=!0)}if(c.select&&x!==void 0&&!Y)if(d&&x===m?.data&&c.select===this.#f)x=this.#s;else try{this.#f=c.select,x=c.select(x),x=tr(d?.data,x,c),this.#s=x,this.#u=null}catch(gt){this.#u=gt}this.#u&&(q=this.#u,x=this.#s,z=Date.now(),w="error");const $=M.fetchStatus==="fetching",yt=w==="pending",ot=w==="error",Ct=yt&&$,Rt=x!==void 0,k={status:w,fetchStatus:M.fetchStatus,isPending:yt,isSuccess:w==="success",isError:ot,isInitialLoading:Ct,isLoading:Ct,data:x,dataUpdatedAt:M.dataUpdatedAt,error:q,errorUpdatedAt:z,failureCount:M.fetchFailureCount,failureReason:M.fetchFailureReason,errorUpdateCount:M.errorUpdateCount,isFetched:i.isFetched(),isFetchedAfterMount:M.dataUpdateCount>p.dataUpdateCount||M.errorUpdateCount>p.errorUpdateCount,isFetching:$,isRefetching:$&&!yt,isLoadingError:ot&&!Rt,isPaused:M.fetchStatus==="paused",isPlaceholderData:E,isRefetchError:ot&&Rt,isStale:fr(i,c),refetch:this.refetch,promise:this.#c,isEnabled:Ae(c.enabled,i)!==!1};if(this.options.experimental_prefetchInRender){const gt=k.data!==void 0,wt=k.status==="error"&&!gt,ue=ce=>{wt?ce.reject(k.error):gt&&ce.resolve(k.data)},le=()=>{const ce=this.#c=k.promise=er();ue(ce)},_t=this.#c;switch(_t.status){case"pending":i.queryHash===r.queryHash&&ue(_t);break;case"fulfilled":(wt||k.data!==_t.value)&&le();break;case"rejected":(!wt||k.error!==_t.reason)&&le();break}}return k}updateResult(){const i=this.#a,c=this.createResult(this.#e,this.options);if(this.#i=this.#e.state,this.#n=this.options,this.#i.data!==void 0&&(this.#m=this.#e),Is(c,i))return;this.#a=c;const r=()=>{if(!i)return!0;const{notifyOnChangeProps:f}=this.options,d=typeof f=="function"?f():f;if(d==="all"||!d&&!this.#y.size)return!0;const m=new Set(d??this.#y);return this.options.throwOnError&&m.add("error"),Object.keys(this.#a).some(g=>{const A=g;return this.#a[A]!==i[A]&&m.has(A)})};this.#E({listeners:r()})}#j(){const i=this.#t.getQueryCache().build(this.#t,this.options);if(i===this.#e)return;const c=this.#e;this.#e=i,this.#l=i.state,this.hasListeners()&&(c?.removeObserver(this),i.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#E(i){ee.batch(()=>{i.listeners&&this.listeners.forEach(c=>{c(this.#a)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function y0(i,c){return Ae(c.enabled,i)!==!1&&i.state.data===void 0&&!(i.state.status==="error"&&Ae(c.retryOnMount,i)===!1)}function Rh(i,c){return y0(i,c)||i.state.data!==void 0&&ar(i,c,c.refetchOnMount)}function ar(i,c,r){if(Ae(c.enabled,i)!==!1&&Gl(c.staleTime,i)!=="static"){const f=typeof r=="function"?r(i):r;return f==="always"||f!==!1&&fr(i,c)}return!1}function Uh(i,c,r,f){return(i!==c||Ae(f.enabled,i)===!1)&&(!r.suspense||i.state.status!=="error")&&fr(i,r)}function fr(i,c){return Ae(c.enabled,i)!==!1&&i.isStaleByTime(Gl(c.staleTime,i))}function v0(i,c){return!Is(i.getCurrentResult(),c)}var p0=class extends Ph{#t;#e;#l;#a;constructor(i){super(),this.#t=i.client,this.mutationId=i.mutationId,this.#l=i.mutationCache,this.#e=[],this.state=i.state||g0(),this.setOptions(i.options),this.scheduleGc()}setOptions(i){this.options=i,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(i){this.#e.includes(i)||(this.#e.push(i),this.clearGcTimeout(),this.#l.notify({type:"observerAdded",mutation:this,observer:i}))}removeObserver(i){this.#e=this.#e.filter(c=>c!==i),this.scheduleGc(),this.#l.notify({type:"observerRemoved",mutation:this,observer:i})}optionalRemove(){this.#e.length||(this.state.status==="pending"?this.scheduleGc():this.#l.remove(this))}continue(){return this.#a?.continue()??this.execute(this.state.variables)}async execute(i){const c=()=>{this.#i({type:"continue"})},r={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#a=Ih({fn:()=>this.options.mutationFn?this.options.mutationFn(i,r):Promise.reject(new Error("No mutationFn found")),onFail:(m,g)=>{this.#i({type:"failed",failureCount:m,error:g})},onPause:()=>{this.#i({type:"pause"})},onContinue:c,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#l.canRun(this)});const f=this.state.status==="pending",d=!this.#a.canStart();try{if(f)c();else{this.#i({type:"pending",variables:i,isPaused:d}),this.#l.config.onMutate&&await this.#l.config.onMutate(i,this,r);const g=await this.options.onMutate?.(i,r);g!==this.state.context&&this.#i({type:"pending",context:g,variables:i,isPaused:d})}const m=await this.#a.start();return await this.#l.config.onSuccess?.(m,i,this.state.context,this,r),await this.options.onSuccess?.(m,i,this.state.context,r),await this.#l.config.onSettled?.(m,null,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(m,null,i,this.state.context,r),this.#i({type:"success",data:m}),m}catch(m){try{await this.#l.config.onError?.(m,i,this.state.context,this,r)}catch(g){Promise.reject(g)}try{await this.options.onError?.(m,i,this.state.context,r)}catch(g){Promise.reject(g)}try{await this.#l.config.onSettled?.(void 0,m,this.state.variables,this.state.context,this,r)}catch(g){Promise.reject(g)}try{await this.options.onSettled?.(void 0,m,i,this.state.context,r)}catch(g){Promise.reject(g)}throw this.#i({type:"error",error:m}),m}finally{this.#l.runNext(this)}}#i(i){const c=r=>{switch(i.type){case"failed":return{...r,failureCount:i.failureCount,failureReason:i.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:i.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:i.isPaused,status:"pending",variables:i.variables,submittedAt:Date.now()};case"success":return{...r,data:i.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:i.error,failureCount:r.failureCount+1,failureReason:i.error,isPaused:!1,status:"error"}}};this.state=c(this.state),ee.batch(()=>{this.#e.forEach(r=>{r.onMutationUpdate(i)}),this.#l.notify({mutation:this,type:"updated",action:i})})}};function g0(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var b0=class extends ti{constructor(i={}){super(),this.config=i,this.#t=new Set,this.#e=new Map,this.#l=0}#t;#e;#l;build(i,c,r){const f=new p0({client:i,mutationCache:this,mutationId:++this.#l,options:i.defaultMutationOptions(c),state:r});return this.add(f),f}add(i){this.#t.add(i);const c=xu(i);if(typeof c=="string"){const r=this.#e.get(c);r?r.push(i):this.#e.set(c,[i])}this.notify({type:"added",mutation:i})}remove(i){if(this.#t.delete(i)){const c=xu(i);if(typeof c=="string"){const r=this.#e.get(c);if(r)if(r.length>1){const f=r.indexOf(i);f!==-1&&r.splice(f,1)}else r[0]===i&&this.#e.delete(c)}}this.notify({type:"removed",mutation:i})}canRun(i){const c=xu(i);if(typeof c=="string"){const f=this.#e.get(c)?.find(d=>d.state.status==="pending");return!f||f===i}else return!0}runNext(i){const c=xu(i);return typeof c=="string"?this.#e.get(c)?.find(f=>f!==i&&f.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){ee.batch(()=>{this.#t.forEach(i=>{this.notify({type:"removed",mutation:i})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(i){const c={exact:!0,...i};return this.getAll().find(r=>Mh(c,r))}findAll(i={}){return this.getAll().filter(c=>Mh(i,c))}notify(i){ee.batch(()=>{this.listeners.forEach(c=>{c(i)})})}resumePausedMutations(){const i=this.getAll().filter(c=>c.state.isPaused);return ee.batch(()=>Promise.all(i.map(c=>c.continue().catch(ve))))}};function xu(i){return i.options.scope?.id}var S0=class extends ti{constructor(i={}){super(),this.config=i,this.#t=new Map}#t;build(i,c,r){const f=c.queryKey,d=c.queryHash??sr(f,c);let m=this.get(d);return m||(m=new h0({client:i,queryKey:f,queryHash:d,options:i.defaultQueryOptions(c),state:r,defaultOptions:i.getQueryDefaults(f)}),this.add(m)),m}add(i){this.#t.has(i.queryHash)||(this.#t.set(i.queryHash,i),this.notify({type:"added",query:i}))}remove(i){const c=this.#t.get(i.queryHash);c&&(i.destroy(),c===i&&this.#t.delete(i.queryHash),this.notify({type:"removed",query:i}))}clear(){ee.batch(()=>{this.getAll().forEach(i=>{this.remove(i)})})}get(i){return this.#t.get(i)}getAll(){return[...this.#t.values()]}find(i){const c={exact:!0,...i};return this.getAll().find(r=>Oh(c,r))}findAll(i={}){const c=this.getAll();return Object.keys(i).length>0?c.filter(r=>Oh(i,r)):c}notify(i){ee.batch(()=>{this.listeners.forEach(c=>{c(i)})})}onFocus(){ee.batch(()=>{this.getAll().forEach(i=>{i.onFocus()})})}onOnline(){ee.batch(()=>{this.getAll().forEach(i=>{i.onOnline()})})}},x0=class{#t;#e;#l;#a;#i;#n;#c;#u;constructor(i={}){this.#t=i.queryCache||new S0,this.#e=i.mutationCache||new b0,this.#l=i.defaultOptions||{},this.#a=new Map,this.#i=new Map,this.#n=0}mount(){this.#n++,this.#n===1&&(this.#c=cr.subscribe(async i=>{i&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#u=Ou.subscribe(async i=>{i&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#n--,this.#n===0&&(this.#c?.(),this.#c=void 0,this.#u?.(),this.#u=void 0)}isFetching(i){return this.#t.findAll({...i,fetchStatus:"fetching"}).length}isMutating(i){return this.#e.findAll({...i,status:"pending"}).length}getQueryData(i){const c=this.defaultQueryOptions({queryKey:i});return this.#t.get(c.queryHash)?.state.data}ensureQueryData(i){const c=this.defaultQueryOptions(i),r=this.#t.build(this,c),f=r.state.data;return f===void 0?this.fetchQuery(i):(i.revalidateIfStale&&r.isStaleByTime(Gl(c.staleTime,r))&&this.prefetchQuery(c),Promise.resolve(f))}getQueriesData(i){return this.#t.findAll(i).map(({queryKey:c,state:r})=>{const f=r.data;return[c,f]})}setQueryData(i,c,r){const f=this.defaultQueryOptions({queryKey:i}),m=this.#t.get(f.queryHash)?.state.data,g=e0(c,m);if(g!==void 0)return this.#t.build(this,f).setData(g,{...r,manual:!0})}setQueriesData(i,c,r){return ee.batch(()=>this.#t.findAll(i).map(({queryKey:f})=>[f,this.setQueryData(f,c,r)]))}getQueryState(i){const c=this.defaultQueryOptions({queryKey:i});return this.#t.get(c.queryHash)?.state}removeQueries(i){const c=this.#t;ee.batch(()=>{c.findAll(i).forEach(r=>{c.remove(r)})})}resetQueries(i,c){const r=this.#t;return ee.batch(()=>(r.findAll(i).forEach(f=>{f.reset()}),this.refetchQueries({type:"active",...i},c)))}cancelQueries(i,c={}){const r={revert:!0,...c},f=ee.batch(()=>this.#t.findAll(i).map(d=>d.cancel(r)));return Promise.all(f).then(ve).catch(ve)}invalidateQueries(i,c={}){return ee.batch(()=>(this.#t.findAll(i).forEach(r=>{r.invalidate()}),i?.refetchType==="none"?Promise.resolve():this.refetchQueries({...i,type:i?.refetchType??i?.type??"active"},c)))}refetchQueries(i,c={}){const r={...c,cancelRefetch:c.cancelRefetch??!0},f=ee.batch(()=>this.#t.findAll(i).filter(d=>!d.isDisabled()&&!d.isStatic()).map(d=>{let m=d.fetch(void 0,r);return r.throwOnError||(m=m.catch(ve)),d.state.fetchStatus==="paused"?Promise.resolve():m}));return Promise.all(f).then(ve)}fetchQuery(i){const c=this.defaultQueryOptions(i);c.retry===void 0&&(c.retry=!1);const r=this.#t.build(this,c);return r.isStaleByTime(Gl(c.staleTime,r))?r.fetch(c):Promise.resolve(r.state.data)}prefetchQuery(i){return this.fetchQuery(i).then(ve).catch(ve)}fetchInfiniteQuery(i){return i._type="infinite",this.fetchQuery(i)}prefetchInfiniteQuery(i){return this.fetchInfiniteQuery(i).then(ve).catch(ve)}ensureInfiniteQueryData(i){return i._type="infinite",this.ensureQueryData(i)}resumePausedMutations(){return Ou.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#l}setDefaultOptions(i){this.#l=i}setQueryDefaults(i,c){this.#a.set(Vn(i),{queryKey:i,defaultOptions:c})}getQueryDefaults(i){const c=[...this.#a.values()],r={};return c.forEach(f=>{Jn(i,f.queryKey)&&Object.assign(r,f.defaultOptions)}),r}setMutationDefaults(i,c){this.#i.set(Vn(i),{mutationKey:i,defaultOptions:c})}getMutationDefaults(i){const c=[...this.#i.values()],r={};return c.forEach(f=>{Jn(i,f.mutationKey)&&Object.assign(r,f.defaultOptions)}),r}defaultQueryOptions(i){if(i._defaulted)return i;const c={...this.#l.queries,...this.getQueryDefaults(i.queryKey),...i,_defaulted:!0};return c.queryHash||(c.queryHash=sr(c.queryKey,c)),c.refetchOnReconnect===void 0&&(c.refetchOnReconnect=c.networkMode!=="always"),c.throwOnError===void 0&&(c.throwOnError=!!c.suspense),!c.networkMode&&c.persister&&(c.networkMode="offlineFirst"),c.queryFn===rr&&(c.enabled=!1),c}defaultMutationOptions(i){return i?._defaulted?i:{...this.#l.mutations,...i?.mutationKey&&this.getMutationDefaults(i.mutationKey),...i,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}},em=Q.createContext(void 0),ei=i=>{const c=Q.useContext(em);if(!c)throw new Error("No QueryClient set, use QueryClientProvider to set one");return c},j0=({client:i,children:c})=>(Q.useEffect(()=>(i.mount(),()=>{i.unmount()}),[i]),o.jsx(em.Provider,{value:i,children:c})),lm=Q.createContext(!1),E0=()=>Q.useContext(lm);lm.Provider;function T0(){let i=!1;return{clearReset:()=>{i=!1},reset:()=>{i=!0},isReset:()=>i}}var N0=Q.createContext(T0()),O0=()=>Q.useContext(N0),M0=(i,c,r)=>{const f=r?.state.error&&typeof i.throwOnError=="function"?$h(i.throwOnError,[r.state.error,r]):i.throwOnError;(i.suspense||i.experimental_prefetchInRender||f)&&(c.isReset()||(i.retryOnMount=!1))},A0=i=>{Q.useEffect(()=>{i.clearReset()},[i])},C0=({result:i,errorResetBoundary:c,throwOnError:r,query:f,suspense:d})=>i.isError&&!c.isReset()&&!i.isFetching&&f&&(d&&i.data===void 0||$h(r,[i.error,f])),z0=i=>{if(i.suspense){const r=d=>d==="static"?d:Math.max(d??1e3,1e3),f=i.staleTime;i.staleTime=typeof f=="function"?(...d)=>r(f(...d)):r(f),typeof i.gcTime=="number"&&(i.gcTime=Math.max(i.gcTime,1e3))}},_0=(i,c)=>i.isLoading&&i.isFetching&&!c,D0=(i,c)=>i?.suspense&&c.isPending,Hh=(i,c,r)=>c.fetchOptimistic(i).catch(()=>{r.clearReset()});function R0(i,c,r){const f=E0(),d=O0(),m=ei(),g=m.defaultQueryOptions(i);m.getDefaultOptions().queries?._experimental_beforeQuery?.(g);const A=m.getQueryCache().get(g.queryHash),p=i.subscribed!==!1;g._optimisticResults=f?"isRestoring":p?"optimistic":void 0,z0(g),M0(g,d,A),A0(d);const y=!m.getQueryCache().get(g.queryHash),[M]=Q.useState(()=>new c(m,g)),E=M.getOptimisticResult(g),x=!f&&p;if(Q.useSyncExternalStore(Q.useCallback(q=>{const z=x?M.subscribe(ee.batchCalls(q)):ve;return M.updateResult(),z},[M,x]),()=>M.getCurrentResult(),()=>M.getCurrentResult()),Q.useEffect(()=>{M.setOptions(g)},[g,M]),D0(g,E))throw Hh(g,M,d);if(C0({result:E,errorResetBoundary:d,throwOnError:g.throwOnError,query:A,suspense:g.suspense}))throw E.error;return m.getDefaultOptions().queries?._experimental_afterQuery?.(g,E),g.experimental_prefetchInRender&&!Fn.isServer()&&_0(E,f)&&(y?Hh(g,M,d):A?.promise)?.catch(ve).finally(()=>{M.updateResult()}),g.notifyOnChangeProps?E:M.trackResult(E)}function ge(i,c){return R0(i,m0)}function am(){throw location.href="/auth/login?next="+encodeURIComponent(location.pathname+location.search),new Error("signing in…")}async function Ce(i){const c=await fetch(i);if(c.status===401&&am(),!c.ok)throw new Error(await c.text());return c.json()}async function Yl(i,c,r){const f={method:i};r!==void 0&&(f.headers={"Content-Type":"application/json"},f.body=JSON.stringify(r));const d=await fetch(c,f);if(!d.ok)throw new Error(await d.text());return d.status===204?{}:d.json()}async function Fa(i,c){const r=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c||{})});if(r.status===401&&am(),!r.ok)throw new Error(await r.text());return r.json()}function U0(){return ge({queryKey:["config"],queryFn:async()=>{const i=await Ce("/api/config");return i.auth.enabled&&!i.me&&(location.href="/auth/login?next="+encodeURIComponent(location.pathname+location.search),await new Promise(()=>{})),i},staleTime:1/0})}const nr=new Set;function H0(i){return nr.add(i),()=>nr.delete(i)}function q0(){for(const i of nr)i()}const nm=(...i)=>i.filter((c,r,f)=>!!c&&c.trim()!==""&&f.indexOf(c)===r).join(" ").trim();const w0=i=>i.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const Q0=i=>i.replace(/^([A-Z])|[\s-_]+(\w)/g,(c,r,f)=>f?f.toUpperCase():r.toLowerCase());const qh=i=>{const c=Q0(i);return c.charAt(0).toUpperCase()+c.slice(1)};var Js={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const B0=i=>{for(const c in i)if(c.startsWith("aria-")||c==="role"||c==="title")return!0;return!1},L0=Q.createContext({}),Y0=()=>Q.useContext(L0),G0=Q.forwardRef(({color:i,size:c,strokeWidth:r,absoluteStrokeWidth:f,className:d="",children:m,iconNode:g,...A},p)=>{const{size:y=24,strokeWidth:M=2,absoluteStrokeWidth:E=!1,color:x="currentColor",className:q=""}=Y0()??{},z=f??E?Number(r??M)*24/Number(c??y):r??M;return Q.createElement("svg",{ref:p,...Js,width:c??y??Js.width,height:c??y??Js.height,stroke:i??x,strokeWidth:z,className:nm("lucide",q,d),...!m&&!B0(A)&&{"aria-hidden":"true"},...A},[...g.map(([w,Y])=>Q.createElement(w,Y)),...Array.isArray(m)?m:[m]])});const Ot=(i,c)=>{const r=Q.forwardRef(({className:f,...d},m)=>Q.createElement(G0,{ref:m,iconNode:c,className:nm(`lucide-${w0(qh(i))}`,`lucide-${i}`,f),...d}));return r.displayName=qh(i),r};const X0=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],K0=Ot("check",X0);const Z0=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],k0=Ot("chevron-down",Z0);const V0=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],J0=Ot("chevron-right",V0);const F0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],$0=Ot("clock",F0);const W0=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],I0=Ot("copy",W0);const P0=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],tp=Ot("download",P0);const ep=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],lp=Ot("ellipsis",ep);const ap=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],np=Ot("file-text",ap);const ip=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],up=Ot("folder",ip);const cp=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],sp=Ot("globe",cp);const rp=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],fp=Ot("history",rp);const op=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],dp=Ot("layout-dashboard",op);const hp=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],mp=Ot("link",hp);const yp=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],vp=Ot("lock",yp);const pp=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],gp=Ot("log-out",pp);const bp=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],Sp=Ot("menu",bp);const xp=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],jp=Ot("plus",xp);const Ep=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Tp=Ot("search",Ep);const Np=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Op=Ot("settings",Np);const Mp=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],Ap=Ot("share-2",Mp);const Cp=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],zp=Ot("shield",Cp);const _p=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],Dp=Ot("square-terminal",_p);const Rp=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Up=Ot("trash-2",Rp);const Hp=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],qp=Ot("triangle-alert",Hp);const wp=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Qp=Ot("upload",wp);const Bp=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],Lp=Ot("users",Bp);const Yp=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Gp=Ot("x",Yp);function Xp(){document.body.classList.toggle("sb-open")}function Ze(){document.body.classList.remove("sb-open")}const Kp={alert:qp,check:K0,chev:J0,chevd:k0,clock:$0,copy:I0,doc:np,dots:lp,download:tp,folder:up,dashboard:dp,gear:Op,globe:sp,hist:fp,link:mp,lock:vp,menu:Sp,plus:jp,power:gp,search:Tp,share:Ap,shield:zp,terminal:Dp,trash:Up,upload:Qp,users:Lp,x:Gp};function Zt({name:i}){const c=Kp[i];return c?o.jsx(c,{className:"ico","aria-hidden":"true"}):null}function $n(i){return o.jsxs(o.Fragment,{children:[o.jsx("div",{id:"sb-backdrop",onClick:Ze}),o.jsxs("aside",{id:"sidebar",children:[i.vault,i.projectsNav,i.tree??o.jsx("nav",{id:"tree","aria-label":"Files"}),i.orgBar]}),o.jsxs("main",{id:"main",children:[i.topbar,o.jsx("article",{id:"content",className:i.contentClass??"markdown",ref:i.contentRef,onScroll:i.onContentScroll,children:i.children})]})]})}function Mu(i){const{name:c,onHome:r,showSignout:f,search:d}=i;return o.jsxs("header",{id:"vault",children:[o.jsx("span",{id:"vault-badge","aria-hidden":"true",children:"🐻"}),o.jsx("span",{id:"vault-name",className:r?"vault-link":void 0,onClick:r,role:r?"button":void 0,tabIndex:r?0:void 0,onKeyDown:m=>{r&&(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),r())},children:c}),o.jsxs("div",{className:"vault-actions",children:[d&&o.jsxs("button",{id:"search-btn",className:"icon-btn2 has-tip","aria-label":"Search",onClick:()=>{q0(),Ze()},children:[o.jsx(Zt,{name:"search"}),o.jsxs("span",{className:"tip",role:"tooltip",children:["Search ",o.jsx("kbd",{children:"⌘K"})]})]}),f&&o.jsx("a",{id:"signout",href:"/auth/logout",title:"Sign out","aria-label":"Sign out",children:o.jsx(Zt,{name:"power"})})]})]})}function Wn(i){return o.jsxs("header",{id:"topbar",children:[o.jsx("button",{id:"menu-btn",className:"icon-btn",title:"Menu","aria-label":"Menu",onClick:Xp,children:o.jsx(Zt,{name:"menu"})}),o.jsx("span",{id:"crumb",children:i.crumb}),o.jsx("span",{id:"meta",children:i.meta}),i.actions]})}let or={msg:"",err:!1,shown:!1},Eu=[],wh;function Qh(i){or=i,Eu.forEach(c=>c())}function st(i,c=!1){Qh({msg:i,err:c,shown:!0}),clearTimeout(wh),wh=setTimeout(()=>Qh({...or,shown:!1}),3200)}function Zp(){const i=Q.useSyncExternalStore(c=>(Eu.push(c),()=>{Eu=Eu.filter(r=>r!==c)}),()=>or);return o.jsx("div",{id:"toast",className:i.shown?"show"+(i.err?" err":""):"",children:i.msg})}let im=null,Tu=[];function dr(i){im=i,Tu.forEach(c=>c())}function um(i,c,r="",f="OK"){return new Promise(d=>dr({kind:"prompt",title:i,label:c,value:r,okLabel:f,resolve:d}))}function ju(i,c,r="Confirm",f=!1){return new Promise(d=>dr({kind:"confirm",title:i,message:c,confirmLabel:r,danger:f,resolve:d}))}function kp(){const i=Q.useSyncExternalStore(c=>(Tu.push(c),()=>{Tu=Tu.filter(r=>r!==c)}),()=>im);return i?i.kind==="prompt"?o.jsx(Vp,{m:i}):o.jsx(Jp,{m:i}):null}function cm(){dr(null)}function Vp({m:i}){const c=Q.useRef(null),r=d=>{cm(),i.resolve(d)},f=()=>r(c.current.value.trim()||null);return Q.useEffect(()=>{c.current.focus(),c.current.select();const d=m=>{m.key==="Escape"&&r(null),m.key==="Enter"&&f()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[]),o.jsx("div",{className:"modal-back",onClick:d=>d.target===d.currentTarget&&r(null),children:o.jsxs("div",{className:"modal",children:[o.jsx("h3",{children:i.title}),o.jsx("label",{className:"modal-label",children:i.label}),o.jsx("input",{className:"modal-input",type:"text",autoComplete:"off",defaultValue:i.value,ref:c}),o.jsxs("div",{className:"modal-actions",children:[o.jsx("button",{className:"ai-btn",onClick:()=>r(null),children:"Cancel"}),o.jsx("button",{className:"pbtn",onClick:f,children:i.okLabel})]})]})})}function Jp({m:i}){const c=Q.useRef(null),r=f=>{cm(),i.resolve(f)};return Q.useEffect(()=>{c.current.focus();const f=d=>{d.key==="Escape"&&r(!1),d.key==="Enter"&&r(!0)};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[]),o.jsx("div",{className:"modal-back",onClick:f=>f.target===f.currentTarget&&r(!1),children:o.jsxs("div",{className:"modal",children:[o.jsx("h3",{children:i.title}),o.jsx("p",{className:"modal-msg",children:i.message}),o.jsxs("div",{className:"modal-actions",children:[o.jsx("button",{className:"ai-btn",onClick:()=>r(!1),children:"Cancel"}),o.jsx("button",{className:i.danger?"danger-btn":"pbtn",onClick:()=>r(!0),ref:c,children:i.confirmLabel})]})]})})}function Fp(i){return ge({queryKey:["projects"],queryFn:()=>Ce("/api/projects"),enabled:i,refetchInterval:3e4,select:c=>c.projects||[]})}function $p(i){return ge({queryKey:["orgs"],queryFn:()=>Ce("/api/orgs"),enabled:i,select:c=>c.orgs||[]})}function sm(i){return ge({queryKey:["admin","pending"],queryFn:()=>Ce("/api/admin/pending"),enabled:i,select:c=>c.pending||[]})}function rm(){const i=ei();return()=>Promise.all([i.invalidateQueries({queryKey:["projects"]}),i.invalidateQueries({queryKey:["orgs"]})]).then(()=>{})}function fm(i){return i.split("/").map(encodeURIComponent).join("/")}function Bh(i){return i.split("/").map(decodeURIComponent).join("/")}const Wp=new Set(["insights","history","install","settings"]);function om(i,c){const r=i.replace(/^\/+/,"");if(c!=="hub")return{path:r?Bh(r):""};const f=r.indexOf("/");if(f===-1)return{project:r,path:""};const d={project:r.slice(0,f),path:Bh(r.slice(f+1))},m=d.path.indexOf("/"),g=m===-1?d.path:d.path.slice(0,m);return Wp.has(g)&&(d.view=g,d.viewTarget=m===-1?"":d.path.slice(m+1).replace(/\/+$/,""),d.path=""),d}function Ip(i,c){const r=fm(i);return c?"/"+c+(r?"/"+r:""):"/"+r}function Ja(i,c,r){let f=(c?"/"+c:"")+"/"+i;return r&&(f+="/"+fm(r.replace(/\/+$/,""))),f}let hr="POP";const ir=new Set;function dm(){for(const i of ir)i()}window.addEventListener("popstate",()=>{hr="POP",dm()});function pe(i,c){const r=location.pathname+location.search;!c?.replace&&r===i||(history[c?.replace?"replaceState":"pushState"](null,"",i),hr=c?.replace?"REPLACE":"PUSH",dm())}function mr(){return Q.useSyncExternalStore(i=>(ir.add(i),()=>{ir.delete(i)}),()=>location.pathname)}function Pp(){return hr}function tg({to:i}){return Q.useEffect(()=>{pe(i,{replace:!0})},[i]),null}const eg=/\.(md|markdown)$/i,lg=/\.(png|jpe?g|gif|svg|webp|ico|bmp|avif)$/i,ag=/\.html?$/i,ng=/\.(txt|log|json|ya?ml|toml|csv|go|py|js|ts|jsx|tsx|sh|bash|zsh|rb|rs|c|h|cpp|java|kt|swift|sql|css|xml|ini|conf|env|mod|sum|jsonl)$/i;function hm(i){if(i<1024)return i+" B";const c=["KB","MB","GB","TB"];let r=-1;do i/=1024,r++;while(i>=1024&&rd.invalidateQueries({queryKey:["orgs"]}),y=()=>d.invalidateQueries({queryKey:["invites",i.id]}),M=()=>d.invalidateQueries({queryKey:["orgShares",i.id]}),{data:E}=ge({queryKey:["invites",i.id],queryFn:()=>Ce(`/api/orgs/${i.id}/invites`),enabled:m,select:z=>z.invites||[]}),{data:x}=ge({queryKey:["orgShares",i.id],queryFn:()=>Ce(`/api/orgs/${i.id}/shares`),enabled:m,select:z=>z.shares||[]}),q=c.filter(z=>z.org===i.id);return o.jsxs("div",{className:"admin",children:[o.jsx("h1",{id:"org-title",children:i.name+(m?"":" · member")}),m&&o.jsxs("div",{className:"admin-row",children:[o.jsx("input",{id:"org-rename",type:"text",value:g,onChange:z=>A(z.target.value)}),o.jsx("button",{className:"pbtn",id:"org-rename-btn",onClick:async()=>{try{await Yl("PATCH","/api/orgs/"+i.id,{name:g.trim()}),st("Renamed."),p()}catch(z){st(z.message,!0)}},children:"Rename org"})]}),o.jsx("h3",{children:"Members"}),o.jsx("div",{className:"admin-list",children:i.members.map(z=>{const w=!!r&&z.email.toLowerCase()===r.toLowerCase();return o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main",children:z.email+(w?" (you)":"")}),m&&!w?o.jsxs(o.Fragment,{children:[o.jsxs("select",{value:z.role,onChange:async Y=>{try{await Yl("PATCH",`/api/orgs/${i.id}/members/${encodeURIComponent(z.email)}`,{role:Y.target.value}),st("Role updated.")}catch($){st($.message,!0)}p()},children:[o.jsx("option",{value:"owner",children:"owner"}),o.jsx("option",{value:"member",children:"member"})]}),o.jsx("button",{className:"ai-del",onClick:async()=>{if(await ju("Remove member",`Remove ${z.email} from ${i.name}?`,"Remove",!0))try{await Yl("DELETE",`/api/orgs/${i.id}/members/${encodeURIComponent(z.email)}`),st("Removed."),p()}catch(Y){st(Y.message,!0)}},children:"Remove"})]}):o.jsx("span",{className:"ai-tag",children:z.role})]},z.email)})}),m&&o.jsxs(o.Fragment,{children:[o.jsx("h3",{children:"Projects"}),o.jsxs("div",{className:"admin-list",children:[q.length===0&&o.jsx("div",{className:"admin-empty",children:"No projects yet."}),q.map(z=>o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main",children:z.name}),o.jsx("button",{className:"ai-btn",onClick:async()=>{const w=await um("Rename project","New name",z.name,"Rename");if(!(!w||w===z.name))try{await Yl("PATCH","/api/projects/"+z.id,{name:w}),st("Renamed."),await f()}catch(Y){st(Y.message,!0)}},children:"Rename"}),o.jsx("button",{className:"ai-del",onClick:async()=>{if(await ju("Delete project",`Delete “${z.name}”? Its files stay in storage, but it's removed from the hub.`,"Delete",!0))try{await Yl("DELETE","/api/projects/"+z.id),st(`Deleted “${z.name}”.`),await f()}catch(w){st(w.message,!0)}},children:"Delete"})]},z.id))]}),o.jsxs("div",{className:"admin-h",children:[o.jsx("h3",{children:"Invite links"}),o.jsx("button",{className:"pbtn",onClick:async()=>{try{const z=await Fa(`/api/orgs/${i.id}/invites`),w=await In(z.url);st(w?"Invite link copied to clipboard.":"Invite created — copy it from the list below."),y()}catch(z){st(z.message,!0)}},children:"New invite"})]}),o.jsxs("div",{className:"admin-list",children:[E&&E.length===0&&o.jsx("div",{className:"admin-empty",children:"No active invite links."}),(E||[]).map(z=>o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main mono",style:{cursor:"pointer"},title:"Copy",onClick:()=>In(z.url).then(w=>st(w?"Copied.":"Select and copy the link.")),children:z.url}),o.jsx("span",{className:"ai-tag",children:(z.creator?"by "+z.creator+" · ":"")+(z.uses?z.uses+" joined · ":"unused · ")+"expires "+new Date(z.expires).toLocaleDateString()}),o.jsx("button",{className:"ai-del",onClick:async()=>{if(await ju("Revoke invite","Revoke this invite link? Anyone still holding it won't be able to join.","Revoke",!0))try{await Yl("DELETE",`/api/orgs/${i.id}/invites/${z.token}`),st("Revoked."),y()}catch(w){st(w.message,!0)}},children:"Revoke"})]},z.token))]}),o.jsx("h3",{children:"Public share links"}),o.jsxs("div",{className:"admin-list",children:[x&&x.length===0&&o.jsx("div",{className:"admin-empty",children:"No public shares."}),(x||[]).map(z=>o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main mono",style:{cursor:"pointer"},title:z.url,onClick:()=>window.open(z.url,"_blank"),children:z.path}),o.jsx("span",{className:"ai-tag",children:(z.project_name||"")+(z.creator?" · by "+z.creator:"")+(z.created?" · "+new Date(z.created).toLocaleDateString():"")}),o.jsx("button",{className:"ai-del",onClick:async()=>{if(await ju("Revoke share link",`Revoke the public link to “${z.path}”? Anyone with the URL will lose access.`,"Revoke",!0))try{await Yl("DELETE","/api/shares/"+z.token),st("Share revoked."),M()}catch(w){st(w.message,!0)}},children:"Revoke"})]},z.token))]})]})]})}function ug(){const i=ei(),{data:c,error:r}=ge({queryKey:["admin","policy"],queryFn:()=>Ce("/api/admin/policy")}),{data:f}=sm(!0),[d,m]=Q.useState(!1),[g,A]=Q.useState(!1);if(Q.useEffect(()=>{c&&(m(c.require_verification&&c.mailer),A(c.require_approval))},[c]),Q.useEffect(()=>{r&&st(r.message,!0)},[r]),!c)return null;const p=async(y,M,E)=>{try{await Fa(`/api/admin/pending/${y}/${M}`),st((M==="approve"?"Approved ":"Denied ")+E),i.invalidateQueries({queryKey:["admin","pending"]})}catch(x){st(x.message,!0)}};return o.jsxs("div",{className:"admin",children:[o.jsx("h1",{children:"Signup & access"}),o.jsx("p",{className:"admin-sub",children:"Who can create an account on this hub, and how new accounts are vetted."}),o.jsx("h3",{children:"New-account vetting"}),o.jsxs("div",{className:"admin-list",children:[o.jsx(Lh,{label:"Require email verification",desc:c.mailer?"New accounts must click an emailed link before they can sign in — proves they control the address.":"Configure SMTP on the server (auth.smtp) to enable email verification.",checked:d,disabled:!c.mailer,onChange:m}),o.jsx(Lh,{label:"Require admin approval",desc:"New accounts wait for a hub admin to approve them before they gain access.",checked:g,onChange:A})]}),o.jsx("button",{className:"pbtn",style:{marginTop:14},onClick:async()=>{try{await Fa("/api/admin/policy",{require_verification:d,require_approval:g}),st("Signup policy saved."),i.invalidateQueries({queryKey:["admin","policy"]})}catch(y){st(y.message,!0)}},children:"Save policy"}),o.jsx("h3",{children:"Who can sign up"}),o.jsxs("div",{className:"admin-list",children:[o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main",children:"Allowed email domains"}),o.jsx("span",{className:"ai-tag",children:c.allowed_domains&&c.allowed_domains.length?c.allowed_domains.map(y=>"@"+y).join(", "):"any"})]}),o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main",children:"Self-signup"}),o.jsx("span",{className:"ai-tag",children:c.allow_signup?"open":"invite-only"})]}),o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main",children:"Hub admins"}),o.jsx("span",{className:"ai-tag",children:c.admins&&c.admins.length?c.admins.join(", "):"none"})]})]}),o.jsx("p",{className:"admin-sub",children:"Domains and admins are set in the server config file (they can't be widened from the browser)."}),o.jsx("h3",{children:"Pending signups"}),o.jsxs("div",{className:"admin-list",children:[(!f||f.length===0)&&o.jsx("div",{className:"admin-empty",children:"No one is waiting for approval."}),(f||[]).map(y=>o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main",children:(y.name?y.name+" · ":"")+y.email}),o.jsx("button",{className:"pbtn",onClick:()=>p(y.id,"approve",y.email),children:"Approve"}),o.jsx("button",{className:"ai-del",onClick:()=>p(y.id,"deny",y.email),children:"Deny"})]},y.id))]})]})}function Lh({label:i,desc:c,checked:r,disabled:f,onChange:d}){return o.jsxs("label",{className:"admin-item toggle",style:f?{opacity:.55}:void 0,children:[o.jsxs("span",{className:"ai-main",children:[o.jsx("div",{className:"tg-label",children:i}),o.jsx("div",{className:"tg-desc",children:c})]}),o.jsx("input",{type:"checkbox",checked:r,disabled:f,onChange:m=>d(m.target.checked)})]})}const Yh=["#5b8def","#f5a623","#4cc38a","#e0679b","#8b7bf0","#3ec8c8","#e6934a"];function ym(i){let c=0;for(const r of i)c=c*31+r.charCodeAt(0)>>>0;return Yh[c%Yh.length]}function Gh({projects:i,currentId:c,menu:r}){const f=rm(),d=async()=>{const m=await um("New project","Project name","","Create");if(m)try{const g=await Fa("/api/projects",{name:m});await f(),pe("/"+g.project.id),st(`Created “${g.project.name}”.`)}catch(g){st("Could not create the project: "+g.message,!0)}};return o.jsxs("nav",{id:"projects","aria-label":"Projects",children:[o.jsxs("div",{className:"nav-head",children:[o.jsx("span",{children:"Projects"}),o.jsx("button",{className:"nav-add",title:"New project",onClick:d,children:"+"})]}),o.jsx("div",{className:"proj-row",children:o.jsxs("span",{className:"proj-select-wrap",children:[c&&o.jsx("span",{className:"proj-mark","aria-hidden":"true",style:{background:ym(i.find(m=>m.id===c)?.name||"")}}),o.jsxs("select",{id:"project-select","aria-label":"Switch project",value:c||"",onChange:m=>{m.target.value&&(pe("/"+m.target.value),Ze())},children:[!c&&o.jsx("option",{value:"",disabled:!0}),i.map(m=>o.jsx("option",{value:m.id,children:m.name},m.id))]}),o.jsx(Zt,{name:"chevd"})]})}),r&&o.jsx("ul",{className:"nav-menu","aria-label":"Project pages",children:[["dashboard","Dashboard","dashboard",r.onDashboard],["install","Installation","terminal",r.onInstall],["history","History","hist",r.onHistory],["settings","Settings","gear",r.onSettings]].map(([m,g,A,p])=>o.jsx("li",{children:o.jsxs("div",{id:"nav-"+m,className:"row"+(r.active===m?" active":""),role:"button",tabIndex:0,onClick:p,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),p())},children:[o.jsx(Zt,{name:A}),o.jsx("span",{className:"label",children:g})]})},m))})]})}function cg({me:i,org:c,admin:r,onOrgSettings:f}){const[d,m]=Q.useState(!1),g=Q.useRef(null);Q.useEffect(()=>{if(!d)return;const p=M=>{g.current&&!g.current.contains(M.target)&&m(!1)},y=M=>{M.key==="Escape"&&m(!1)};return document.addEventListener("mousedown",p),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",y)}},[d]);const A=i.name||i.email;return o.jsxs("footer",{id:"accountbar",ref:g,children:[d&&o.jsxs("div",{id:"account-menu",role:"menu","aria-label":"Account menu",children:[c&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"menu-sec",children:"Organization"}),o.jsxs("button",{id:"menu-org-settings",role:"menuitem",onClick:()=>{m(!1),f(c)},children:[o.jsx(Zt,{name:"gear"}),o.jsxs("span",{children:[o.jsx("b",{children:c.name})," Settings"]})]})]}),r&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"menu-sec",children:"Hub"}),o.jsxs("button",{id:"menu-hub-admin",role:"menuitem",onClick:()=>{m(!1),r.onClick()},children:[o.jsx(Zt,{name:"shield"}),o.jsxs("span",{children:["Signup & access",r.pending?` · ${r.pending}`:""]})]})]}),o.jsx("div",{className:"menu-sec",children:"Account"}),o.jsxs("a",{id:"signout",role:"menuitem",href:"/auth/logout",children:[o.jsx(Zt,{name:"power"}),o.jsx("span",{children:"Log out"})]})]}),o.jsxs("button",{id:"account-btn","aria-haspopup":"menu","aria-expanded":d,onClick:()=>m(p=>!p),children:[o.jsx("span",{className:"avatar",style:{background:ym(i.email)},"aria-hidden":"true",children:(A.trim()[0]||"?").toUpperCase()}),o.jsxs("span",{className:"acct",children:[o.jsx("b",{children:A}),i.name&&o.jsx("small",{children:i.email})]}),o.jsx(Zt,{name:"chev"})]})]})}function sg({project:i,org:c}){return o.jsxs("div",{className:"project-settings",children:[o.jsx("h2",{children:i.name}),o.jsxs("dl",{className:"ps-facts",children:[o.jsx("dt",{children:"Project id"}),o.jsx("dd",{children:o.jsx("code",{children:i.id})}),c&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"Workspace"}),o.jsx("dd",{children:c.name})]}),i.created&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"Created"}),o.jsx("dd",{children:new Date(i.created).toLocaleDateString()})]})]})]})}const Fs=[{key:"claude",label:"Claude Code & Cowork"},{key:"hermes",label:"Hermes",hook:"hermes",note:"Registers BearDrive's hooks in Hermes's config: pull before every turn, push after edits with a session note, and report file reads to Insights."},{key:"codex",label:"Codex",hook:"codex",note:"Registers hooks in .codex/hooks.json.",extra:"Run /hooks inside Codex once to trust the project's .codex layer — after that every turn pulls, edits push automatically, and reads are reported to Insights."}];function rg(i,c){const r=window.location.origin,f=c.id;if(i.key==="claude")return[{title:"Add the BearDrive plugin",desc:"One time, in any Claude Code session. The plugin ships the beardrive skill, the /beardrive commands, and turn-boundary sync hooks — and Claude Cowork shares the same plugins, so installing it once covers both.",code:`/plugin marketplace add runbear-io/beardrive -/plugin install beardrive@beardrive`},{title:"Set up this project conversationally",desc:"In a Claude Code or Cowork session in the folder where you want the files, run:",code:"/beardrive:install connect to "+r+", project "+f,extra:"Claude installs the CLI, signs this machine in, mounts the project, and registers the sync hooks — pull the latest before every turn, push after edits (stamped with the session that made them), and report file reads to Insights. It asks before anything it changes."}];const d=(c.name||"project").toLowerCase().replace(/[^a-z0-9._-]+/g,"-")||"project";return[{title:"Install the BearDrive CLI",desc:"One static binary. Homebrew on macOS and Linux; releases and `go install` also work.",code:"brew install runbear-io/tap/beardrive"},{title:"Sign in to this hub",desc:"Opens the browser once and stores a device token on this machine — the synced folder itself never holds credentials.",code:"bdrive login "+r},{title:"Mount the project into a local folder",desc:"Run it where you want the files. An existing folder works too — contents merge, and re-running init later (or after moving the folder) just resumes.",code:"mkdir -p ~/"+d+" && cd ~/"+d+` -bdrive init --project `+f},{title:"Connect "+i.label,desc:i.note,code:"bdrive hooks install --agent "+i.hook,extra:i.extra}]}function fg(){try{return localStorage.getItem("bdrive-guide-agent")||"claude"}catch{return"claude"}}function vm({project:i}){const[c,r]=Q.useState(fg),f=Fs.find(d=>d.key===c)||Fs[0];return o.jsxs("div",{className:"guide",children:[o.jsx("h1",{className:"in-title",children:i.name}),o.jsx("p",{className:"dl-sub",children:"Mount this project as a folder on any machine and connect your coding agent: files sync both ways in the background, every change is journaled with who made it, and agent reads feed Insights."}),o.jsx("div",{className:"gd-tabs",children:Fs.map(d=>o.jsx("button",{className:"gd-tab"+(d.key===f.key?" active":""),"data-key":d.key,onClick:()=>{r(d.key);try{localStorage.setItem("bdrive-guide-agent",d.key)}catch{}},children:d.label},d.key))}),o.jsxs("div",{className:"gd-body",children:[rg(f,i).map((d,m)=>o.jsxs("div",{className:"gd-step",children:[o.jsxs("div",{className:"gd-step-head",children:[o.jsx("span",{className:"gd-num",children:m+1}),o.jsx("span",{className:"gd-step-title",children:d.title})]}),d.desc&&o.jsx("p",{className:"gd-desc",children:d.desc}),d.code&&o.jsx(og,{code:d.code}),d.extra&&o.jsx("p",{className:"gd-desc gd-extra",children:d.extra})]},m)),o.jsx("p",{className:"gd-done",children:"That's it — the folder now syncs on its own. Every agent turn starts from the latest state, edits appear here (and on every teammate's mount) within seconds, and what your agents read shows up in Insights."})]})]})}function og({code:i}){const[c,r]=Q.useState("Copy");return o.jsxs("pre",{className:"gd-code",children:[o.jsx("code",{children:i}),o.jsx("button",{className:"gd-copy",onClick:async()=>{r(await In(i)?"Copied":"Copy failed"),setTimeout(()=>r("Copy"),1400)},children:c})]})}function dg({authEnabled:i,onCreate:c}){const r=Q.useRef(null),f=Q.useRef(null),d=()=>{const m=r.current.value.trim(),g=m.match(/join\/([0-9a-f]+)/)||m.match(/^([0-9a-f]{8,})$/);if(!g){st("That doesn't look like an invite link.",!0);return}location.href="/join/"+g[1]};return o.jsxs("div",{className:"onboard",children:[o.jsx("h1",{children:"Welcome to BearDrive"}),o.jsx("p",{children:"You're signed in, but you're not part of any project yet."}),i&&o.jsxs("div",{className:"ob-card",children:[o.jsx("h3",{children:"Have an invite link?"}),o.jsx("p",{children:"A teammate can send you a join link. Paste it here:"}),o.jsxs("div",{className:"ob-row",children:[o.jsx("input",{id:"ob-invite",type:"text",placeholder:"https://…/join/…",autoComplete:"off",ref:r}),o.jsx("button",{id:"ob-join",className:"pbtn",onClick:d,children:"Join"})]})]}),o.jsxs("div",{className:"ob-card",children:[o.jsx("h3",{children:"Or start a new project"}),o.jsx("p",{children:"Create a shared space for your team's files."}),o.jsxs("div",{className:"ob-row",children:[o.jsx("input",{id:"ob-name",type:"text",placeholder:"Project name, e.g. wiki",autoComplete:"off",ref:f}),o.jsx("button",{id:"ob-create",className:"pbtn",onClick:()=>c(f.current.value.trim()),children:"Create"})]})]})]})}function hg(i,c=!0){const r=ge({queryKey:["tree",i],queryFn:()=>Ce(i+"tree"),enabled:c,refetchInterval:15e3}),f=Q.useMemo(()=>{const d=[],m=new Map,g=A=>{for(const p of A.children||[])p.dir?(m.set(p.path,p),g(p)):d.push(p)};return r.data&&g(r.data),{flatFiles:d,dirIndex:m}},[r.data]);return{tree:r.data,...f,loaded:!!r.data}}function mg(i,c){return ge({queryKey:["heat",i],queryFn:()=>Ce(i+"heat?days=30"),enabled:c,staleTime:6e4,refetchInterval:6e4}).data?.entries??null}function yg(i,c,r){return ge({queryKey:["history",i,"prefix",c,20],queryFn:()=>Ce(i+"history?prefix="+encodeURIComponent(c)+"&n=20"),enabled:r,staleTime:15e3}).data?.entries??null}function Xh(i,c,r){if(!i)return null;if(!r)return i[c]||null;const f={human:0,agent:0,share:0};for(const[d,m]of Object.entries(i))d.startsWith(c+"/")&&(f.human+=m.human||0,f.agent+=m.agent||0,f.share+=m.share||0);return f.human||f.agent||f.share?f:null}function Pn(i){return(i.human||0)+(i.agent||0)+(i.share||0)}function Nu(i){const c=Pn(i);if(!c)return"";let r=c+(c===1?" read":" reads");return i.agent&&(r+=" ("+i.agent+" agent)"),r}function vg(i){const c=Pn(i);return c?c<3?1:c<10?2:c<30?3:4:0}function pg(i){return o.jsx("nav",{id:"tree","aria-label":"Files",children:i.root&&o.jsx(pm,{nodes:i.root.children||[],...i})})}function pm({nodes:i,...c}){return o.jsx("ul",{children:i.map(r=>o.jsx(gg,{node:r,...c},r.path))})}function gg({node:i,...c}){const{expanded:r,onToggle:f,currentPath:d,listingShowing:m,onOpen:g}=c,A=i.dir?r.has(i.path):!1,p=()=>{if(i.dir&&d===i.path&&m){f(i.path);return}g(i.path),i.dir||Ze()};return o.jsxs("li",{className:(i.dir?"dir":"file")+(i.dir&&!A?" collapsed":""),children:[o.jsxs("div",{className:"row"+(d===i.path?" active":""),"data-path":i.path,tabIndex:0,role:"button",title:i.name,"aria-expanded":i.dir?A:void 0,onClick:p,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),p())},children:[o.jsx("span",{className:"chev",onClick:y=>{i.dir&&(y.stopPropagation(),f(i.path))},children:o.jsx(Zt,{name:"chevd"})}),o.jsx("span",{className:"ticon",children:o.jsx(Zt,{name:i.dir?"folder":"doc"})}),o.jsx("span",{className:"label",children:i.name})]}),i.dir&&o.jsx(pm,{nodes:i.children||[],...c})]})}function bg(i){const c=i.split("/"),r=[];let f="";for(let d=0;d{f=f?f+"/"+d:d;const g=f,A=m===r.length-1;return o.jsxs("span",{children:[m>0&&o.jsx("span",{className:"crumb-sep",children:"/"}),A?o.jsx("span",{children:d}):o.jsx("span",{className:"crumb-seg",title:g,onClick:()=>c(g),children:d})]},g)})})}const xg={add:"plus",edit:"edit",delete:"x"},jg={add:"added",edit:"edited",delete:"deleted"};function gm({entry:i,onOpen:c}){const[r,f]=Q.useState(!1),d=i.kind==="put"?"edit":i.kind,m=i.user_name?`${i.user_name} <${i.user}>`:i.user||i.author||"unknown",g=[i.device.name||i.device.id,i.device.os,i.device.ip].filter(Boolean).join(" · "),A=d!=="delete",p=y=>{y.target.tagName!=="A"&&A&&c(i.path)};return o.jsxs("div",{className:"hentry "+d+(A?" clickable":""),tabIndex:A?0:void 0,role:A?"button":void 0,onClick:p,onKeyDown:y=>{A&&(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),c(i.path))},children:[o.jsxs("div",{className:"hline",children:[o.jsx("span",{className:"hkind",children:o.jsx(Zt,{name:xg[d]||"dot"})}),o.jsx("span",{className:"hpath",children:i.path}),o.jsx("span",{className:"htag",children:jg[d]||d}),o.jsx("span",{className:"htime",children:new Date(i.time).toLocaleString()})]}),o.jsxs("div",{className:"hmeta",children:[o.jsx("span",{className:"hwho",children:m}),o.jsx("span",{className:"hdev",children:g}),o.jsx("span",{className:"hsize",children:i.size?hm(i.size):""})]}),i.note&&o.jsx("div",{className:"hnote"+(r?" open":""),tabIndex:0,role:"button",title:r?"Collapse note":"Show full note","aria-expanded":r,onClick:y=>{y.stopPropagation(),y.target.tagName!=="A"&&f(!r)},onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),y.stopPropagation(),f(!r))},children:i.note.split(/(https?:\/\/\S+)/).map((y,M)=>/^https?:\/\//.test(y)?o.jsx("a",{href:y,target:"_blank",rel:"noopener",children:y},M):y)})]})}function Eg(i){const{node:c,heatMap:r,onOpen:f}=i,d=(c.children||[]).slice().sort((y,M)=>Number(M.dir||!1)-Number(y.dir||!1)||y.name.localeCompare(M.name)),m=d.filter(y=>y.dir).length,g=d.length-m,A=[];m&&A.push(m+(m===1?" folder":" folders")),g&&A.push(g+(g===1?" file":" files"));const p=Xh(r,c.path,!0);return p&&A.push(Nu(p)+" in 30 days"),o.jsxs("div",{className:"dirlist",children:[o.jsxs("h1",{className:"dl-title",children:[o.jsx("span",{className:"dl-title-icon",children:o.jsx(Zt,{name:"folder"})}),o.jsx("span",{children:c.name})]}),o.jsx("p",{className:"dl-sub",children:A.join(" · ")||"Empty folder"}),d.length===0?o.jsx("div",{className:"dl-empty",children:"Nothing in this folder yet."}):o.jsx("div",{className:"dl-items",children:d.map(y=>{let M="";if(y.dir){const x=(y.children||[]).length;M=x+(x===1?" item":" items")}else M=[y.size?hm(y.size):"",y.time?new Date(y.time).toLocaleDateString():""].filter(Boolean).join(" · ");const E=Xh(r,y.path,!!y.dir);return E&&(M=Nu(E)+(M?" · "+M:"")),o.jsxs("div",{className:"dl-row",tabIndex:0,role:"button",title:y.path,onClick:()=>f(y.path),onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),f(y.path))},children:[o.jsx("span",{className:"ticon",children:o.jsx(Zt,{name:y.dir?"folder":"doc"})}),o.jsx("span",{className:"dl-name",children:y.name}),E&&o.jsx("span",{className:"heatdot lvl"+vg(E),title:Nu(E)+" in 30 days"}),o.jsx("span",{className:"dl-meta",children:M})]},y.path)})}),i.hub&&o.jsx(Tg,{apiBase:i.apiBase,prefix:c.path+"/",onOpen:f,onFullHistory:()=>i.onFullHistory(c.path+"/"),onRendered:i.onRendered})]})}function Tg(i){const c=yg(i.apiBase,i.prefix,!0),{onRendered:r}=i;return Q.useEffect(()=>{c&&c.length&&r&&r()},[c,r]),!c||c.length===0?null:o.jsxs("div",{className:"dl-history",children:[o.jsx("h3",{className:"dl-h3",children:"Recent changes"}),o.jsx("div",{className:"history dl-hlist",children:c.map((f,d)=>o.jsx(gm,{entry:f,onOpen:i.onOpen},d))}),o.jsx("button",{className:"ai-btn dl-more",onClick:i.onFullHistory,children:"Full history"})]})}function Ng(i){const{apiBase:c,path:r,onMeta:f}=i,d=c+"file?path="+encodeURIComponent(r);return Q.useEffect(()=>()=>f(""),[r,f]),eg.test(r)?o.jsx(Og,{...i}):ag.test(r)?o.jsx("iframe",{className:"htmlview",sandbox:"allow-scripts",src:d,title:r,onLoad:i.onRendered}):lg.test(r)?o.jsx(Cg,{src:d,alt:r,onRendered:i.onRendered}):ng.test(r)?o.jsx(zg,{...i,fileURL:d}):o.jsxs("div",{className:"filecard",children:[o.jsx("div",{className:"name",children:r.split("/").pop()}),o.jsx("p",{children:"No preview for this file type."}),o.jsx("a",{className:"btn",download:!0,href:c+"download?path="+encodeURIComponent(r),children:"Download"})]})}function Og(i){const{apiBase:c,path:r,heatMap:f,flatFiles:d,onOpenFile:m,onMeta:g,onRendered:A}=i,{data:p,error:y}=ge({queryKey:["render",c,r],queryFn:()=>Ce(c+"render?path="+encodeURIComponent(r))}),M=Q.useMemo(()=>p?Ag(p.html,r,c):"",[p,r,c]);return Q.useEffect(()=>{if(!p)return;const E=[];p.author&&E.push(p.author+(p.device?" on "+p.device:"")),p.time&&E.push(new Date(p.time).toLocaleString());const x=f&&f[p.path];x&&Pn(x)&&E.push(Nu(x)+" / 30d"),g(E.join(" · ")),A?.()},[p,f,g,A]),y?o.jsxs("div",{className:"empty",children:["Could not load file: ",y.message]}):p?o.jsx("div",{dangerouslySetInnerHTML:{__html:M},onClick:E=>Mg(E,r,d,m)}):null}function Mg(i,c,r,f){const d=i.target.closest("a");if(!d||!i.currentTarget.contains(d))return;const m=d.getAttribute("href")||"",g=c.includes("/")?c.slice(0,c.lastIndexOf("/")):"";m.startsWith("wiki:")?(i.preventDefault(),_g(decodeURIComponent(m.slice(5)),r,f)):/^([a-z]+:|\/|#)/i.test(m)||(i.preventDefault(),f(mm(g,decodeURIComponent(m))))}function Ag(i,c,r){const f=c.includes("/")?c.slice(0,c.lastIndexOf("/")):"",d=g=>r+"file?path="+encodeURIComponent(g),m=new DOMParser().parseFromString(i,"text/html");for(const g of m.querySelectorAll("img")){const A=g.getAttribute("src")||"";/^([a-z]+:|\/)/i.test(A)||g.setAttribute("src",d(mm(f,A)))}for(const g of m.querySelectorAll("a")){const A=g.getAttribute("href")||"";/^https?:/i.test(A)&&(g.setAttribute("target","_blank"),g.setAttribute("rel","noopener"))}return m.body.innerHTML}function Cg({src:i,alt:c,onRendered:r}){return o.jsx("img",{src:i,alt:c,onLoad:r})}function zg(i){const{path:c,fileURL:r,onRendered:f}=i,{data:d,error:m}=ge({queryKey:["text",r],queryFn:async()=>{const g=await fetch(r);if(!g.ok)throw new Error(await g.text());return g.text()}});return Q.useEffect(()=>{d!=null&&f?.()},[d,f]),m?o.jsxs("div",{className:"empty",children:["Could not load file: ",m.message]}):d==null?null:o.jsx("pre",{className:"plain",children:d},c)}function _g(i,c,r){const f=i.toLowerCase(),d=c.find(m=>m.path.toLowerCase()===f||m.path.toLowerCase()===f+".md")||c.find(m=>{const g=m.name.toLowerCase();return g===f||g===f+".md"});d&&r(d.path)}function Dg({url:i,copied:c,onClose:r}){const f=i.split("/s/")[1];return Q.useEffect(()=>{const d=m=>{m.key==="Escape"&&r()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[r]),o.jsx("div",{className:"modal-back",onClick:d=>d.target===d.currentTarget&&r(),children:o.jsxs("div",{className:"modal",children:[o.jsx("h3",{children:"Public link created"}),o.jsxs("p",{children:[o.jsx("b",{children:"Anyone with this link can view this file"})," — no account needed. It always shows the latest version until you revoke it."]}),o.jsx("div",{className:"modal-url",children:i}),o.jsxs("div",{className:"modal-actions",children:[o.jsx("button",{className:"pbtn",onClick:()=>In(i).then(d=>st(d?"Copied.":"Select and copy the link above.")),children:c?"Copied ✓":"Copy link"}),o.jsx("button",{className:"ai-btn",onClick:()=>window.open(i,"_blank"),children:"Open"}),o.jsx("button",{className:"ai-del",onClick:async()=>{try{await Yl("DELETE","/api/shares/"+f),st("Link revoked — it no longer works."),r()}catch(d){st(d.message,!0)}},children:"Revoke"}),o.jsx("button",{className:"ai-btn",onClick:r,children:"Done"})]})]})})}function Kh(i,c){if(!i)return{score:0,hits:[]};const r=i.toLowerCase(),f=c.toLowerCase();let d=0,m=0,g=0;const A=[];for(let p=0;p3&&f.endsWith("ies")?d=f.slice(0,-3)+"y":f.length>3&&f.endsWith("es")?d=f.slice(0,-2):f.length>2&&f.endsWith("s")&&(d=f.slice(0,-1)),d?Kh(d,c):null}function Ug({text:i,hits:c}){const r=[];let f=0;return c.forEach((d,m)=>{d>f&&r.push(i.slice(f,d)),r.push(o.jsx("b",{children:i[d]},m)),f=d+1}),r.push(i.slice(f)),o.jsx("span",{className:"plabel",children:r})}function Hg({open:i,onClose:c,candidates:r}){const[f,d]=Q.useState(""),[m,g]=Q.useState(0),A=Q.useRef(null),p=Q.useRef(null),y=Q.useMemo(()=>{if(!i)return[];const E=[];for(const x of r()){const q=Rg(f,x.label);q&&E.push({...x,score:q.score,hits:q.hits})}return E.sort((x,q)=>q.score-x.score),E.slice(0,40)},[i,f,r]);Q.useEffect(()=>{i&&(d(""),g(0),A.current?.focus())},[i]),Q.useEffect(()=>g(0),[f]),Q.useEffect(()=>{p.current?.children[m]?.scrollIntoView({block:"nearest"})},[m,y]);const M=E=>{c(),E.run()};return Q.useEffect(()=>{if(!i)return;const E=x=>{if(x.key==="Escape")x.preventDefault(),c();else if(x.key==="ArrowDown"||x.key==="ArrowUp"){x.preventDefault();const q=y.length;q&&g(z=>(z+(x.key==="ArrowDown"?1:q-1))%q)}else x.key==="Enter"&&(x.preventDefault(),y[m]&&M(y[m]))};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[i,y,m]),i?o.jsx("div",{id:"palette-overlay",onClick:E=>E.target===E.currentTarget&&c(),children:o.jsxs("div",{id:"palette",role:"dialog","aria-label":"Search and quick actions",children:[o.jsxs("div",{id:"palette-inputwrap",children:[o.jsx(Zt,{name:"search"}),o.jsx("input",{id:"palette-input",type:"text",placeholder:"Search file names, projects, actions…",autoComplete:"off",spellCheck:!1,ref:A,value:f,onChange:E=>d(E.target.value)})]}),o.jsx("ul",{id:"palette-results",ref:p,children:y.length===0?o.jsx("li",{className:"pempty",children:"No matches — search covers file names, projects, and actions"}):y.map((E,x)=>o.jsxs("li",{className:x===m?"selected":void 0,onClick:()=>M(E),onMouseMove:()=>m!==x&&g(x),children:[o.jsx("span",{className:"picon",children:o.jsx(Zt,{name:E.icon})}),o.jsx(Ug,{text:E.label,hits:E.hits}),o.jsx("span",{className:"pkind",children:E.kind})]},E.kind+":"+E.label))}),o.jsx("footer",{id:"palette-hint",children:"↑↓ navigate · ⏎ select · esc close"})]})}):null}const kn=3,Va=30;function qg(i,c){return ge({queryKey:["heatDevices",i],queryFn:()=>Ce(i+"heat?by=device&days=30"),enabled:c,retry:!1,staleTime:6e4}).data?.devices??null}function Zh(i){const[c,r]=Q.useState("all"),{flatFiles:f,heatMap:d,devices:m,scope:g}=i,A=x=>!g||x===g||x.startsWith(g+"/"),p=g?f.filter(x=>A(x.path)):f,y=m&&g?m.map(x=>{const q={};for(const[z,w]of Object.entries(x.folders||{}))A(z)&&(q[z]=w);return{...x,folders:q}}).filter(x=>Object.keys(x.folders).length>0):m,M=Date.now(),E=p.map(x=>{const q=d&&d[x.path]||{},z=x.time?Math.max(0,(M-new Date(x.time).getTime())/864e5):0,w=c==="all"?Pn(q):q[c]||0;return{path:x.path,reads:w,agent:q.agent||0,total:Pn(q),days:z,danger:w>=kn&&z>=Va}});return o.jsxs("div",{className:"insights",children:[o.jsxs("h1",{className:"in-title",children:["Knowledge insights",g?o.jsxs("span",{className:"in-scope",children:[" · ",g]}):null]}),o.jsx("p",{className:"dl-sub",children:g?`Reads over the last 30 days × freshness, for ${g} and everything in it.`:"Reads over the last 30 days × how long since each file changed. Hot but stale knowledge — read a lot, maintained by nobody — is the danger zone."}),o.jsx("div",{className:"in-lens",children:["all","human","agent"].map(x=>o.jsx("button",{className:"in-lens-btn"+(x===c?" active":""),onClick:()=>r(x),children:x==="all"?"All reads":x==="human"?"Human reads":"Agent reads"},x))}),o.jsx("h3",{className:"dl-h3",children:"Map — cell size = reads, color = freshness"}),o.jsx(Qg,{pts:E,onOpenFile:i.onOpenFile,onOpenFolder:i.onOpenFolder,isFolder:i.isFolder}),o.jsx("h3",{className:"dl-h3",children:"Reads × freshness"}),o.jsx(Bg,{pts:E,onOpenFile:i.onOpenFile}),o.jsx("h3",{className:"dl-h3",children:"Hot path — top files by reads"}),o.jsx(Lg,{pts:E,lens:c,onOpenFile:i.onOpenFile}),y&&y.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("h3",{className:"dl-h3",children:"Agent coverage — which agents read which areas"}),o.jsx(Yg,{devices:y})]})]})}function wg(i){const c=[[76,195,138],[232,196,84],[224,93,93]],r=Math.min(1,Math.max(0,i/300))*(c.length-1),f=Math.min(c.length-2,Math.floor(r)),d=r-f,m=c[f].map((g,A)=>Math.round(g+(c[f+1][A]-g)*d));return`rgb(${m[0]},${m[1]},${m[2]})`}function kh(i,c,r,f,d){const m=i.reduce((y,M)=>y+M.value,0);if(!m||f<=0||d<=0)return[];const g=i.slice().sort((y,M)=>M.value-y.value).map(y=>({it:y,a:y.value/m*f*d})),A=(y,M)=>{const x=y.reduce((z,w)=>z+w.a,0)/M;let q=0;for(const z of y){const w=z.a/x;q=Math.max(q,w/x,x/w)}return q},p=[];for(;g.length;){const y=f>=d,M=y?d:f,E=[g.shift()];for(;g.length&&A(E.concat(g[0]),M)<=A(E,M);)E.push(g.shift());const x=E.reduce((z,w)=>z+w.a,0)/M;let q=0;for(const z of E){const w=z.a/x;y?p.push({item:z.it,x:c,y:r+q,w:x,h:w}):p.push({item:z.it,x:c+q,y:r,w,h:x}),q+=w}y?(c+=x,f-=x):(r+=x,d-=x)}return p}const $s=15;function Qg({pts:i,onOpenFile:c,onOpenFolder:r,isFolder:f}){const g=new Map;for(const p of i){const y=p.path.includes("/")?p.path.split("/")[0]:"/";let M=g.get(y);M||g.set(y,M={name:y,files:[],value:0}),M.files.push(p),M.value+=p.reads+1}const A=[];for(const p of kh([...g.values()],0,0,720,480)){const y=p.item,M=y.name==="/"?"":y.name;if(A.push(o.jsx("rect",{x:p.x+1,y:p.y+1,width:Math.max(0,p.w-2),height:Math.max(0,p.h-2),rx:3,className:"in-tm-group","data-dir":M},"g"+y.name)),p.w>46&&p.h>$s+10){let x=y.name==="/"?"(root)":y.name;const q=Math.floor((p.w-8)/6);x.length>q&&(x=x.slice(0,Math.max(1,q-1))+"…"),A.push(o.jsx("text",{x:p.x+5,y:p.y+12,className:"in-tm-glabel","data-dir":M,children:x},"gl"+y.name))}const E=kh(y.files.map(x=>({...x,name:x.path.split("/").pop(),value:x.reads+1})),p.x+2,p.y+$s,Math.max(0,p.w-4),Math.max(0,p.h-$s-2));for(const x of E)if(A.push(o.jsx("rect",{x:x.x+.6,y:x.y+.6,width:Math.max(.4,x.w-1.2),height:Math.max(.4,x.h-1.2),rx:1.5,fill:wg(x.item.days),className:"in-tm-cell","data-path":x.item.path,children:o.jsx("title",{children:`${x.item.path} — ${x.item.reads} read${x.item.reads===1?"":"s"}/30d · changed ${Math.round(x.item.days)}d ago`})},x.item.path)),x.w>54&&x.h>16){const q=Math.floor((x.w-8)/6);let z=(x.item.danger?"⚠ ":"")+x.item.name;z.length>q&&(z=z.slice(0,Math.max(1,q-1))+"…"),q>=5&&A.push(o.jsx("text",{x:x.x+4.5,y:x.y+12.5,className:"in-tm-label","data-path":x.item.path,children:z},"l"+x.item.path))}}return o.jsx("svg",{viewBox:"0 0 720 480",className:"in-chart in-treemap",onClick:p=>{const y=p.target.closest("[data-path], [data-dir]");if(!y)return;const M=y.getAttribute("data-path");if(M)return c(M);const E=y.getAttribute("data-dir");E&&f(E)&&r(E)},children:A})}function Bg({pts:i,onOpenFile:c}){const d={l:44,r:16,t:20,b:34},m=Math.max(Va*2,...i.map(E=>E.days)),g=Math.max(kn*2,...i.map(E=>E.reads)),A=E=>Math.log10(E+1)/Math.log10(m+1),p=E=>Math.log10(E+1)/Math.log10(g+1),y=E=>d.l+A(E)*(720-d.l-d.r),M=E=>360-d.b-p(E)*(360-d.t-d.b);return o.jsxs("svg",{viewBox:"0 0 720 360",className:"in-chart",children:[o.jsx("rect",{x:y(Va),y:d.t,width:720-d.r-y(Va),height:M(kn)-d.t,className:"in-danger-zone"}),o.jsx("line",{x1:y(Va),y1:d.t,x2:y(Va),y2:360-d.b,className:"in-threshold"}),o.jsx("line",{x1:d.l,y1:M(kn),x2:720-d.r,y2:M(kn),className:"in-threshold"}),o.jsx("line",{x1:d.l,y1:360-d.b,x2:720-d.r,y2:360-d.b,className:"in-axis"}),o.jsx("line",{x1:d.l,y1:d.t,x2:d.l,y2:360-d.b,className:"in-axis"}),o.jsx("text",{x:(d.l+720-d.r)/2,y:352,className:"in-label",children:"days since last change →"}),o.jsx("text",{x:12,y:(d.t+360-d.b)/2,className:"in-label",transform:`rotate(-90 12 ${(d.t+360-d.b)/2})`,children:"reads / 30d →"}),o.jsx("text",{x:720-d.r-6,y:d.t+14,className:"in-quad in-quad-danger",textAnchor:"end",children:"hot + stale"}),o.jsx("text",{x:d.l+6,y:d.t+14,className:"in-quad",children:"hot + fresh"}),o.jsx("text",{x:720-d.r-6,y:360-d.b-8,className:"in-quad",textAnchor:"end",children:"cold + stale"}),o.jsx("text",{x:720-d.r-6,y:d.t+28,className:"in-label",textAnchor:"end",children:"dot size = agent share of reads"}),i.map(E=>{const x=E.total?(E.agent||0)/E.total:0;return o.jsx("circle",{cx:Number(y(E.days).toFixed(1)),cy:Number(M(E.reads).toFixed(1)),r:Number((3+4*x).toFixed(1)),className:"in-pt"+(E.danger?" danger":E.reads?"":" cold"),onClick:()=>c(E.path),children:o.jsx("title",{children:`${E.path} — ${E.reads} read${E.reads===1?"":"s"} / 30d · changed ${Math.round(E.days)}d ago`})},E.path)})]})}function Lg({pts:i,lens:c,onOpenFile:r}){const f=i.filter(m=>m.reads>0).sort((m,g)=>g.reads-m.reads||g.days-m.days).slice(0,20);if(!f.length)return o.jsx("div",{className:"dl-empty",children:"No reads in the window yet."});const d=f[0].reads;return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"in-hotpath",children:f.map(m=>{const g=c==="agent"?1:c==="human"?0:m.total?m.agent/m.total:0,A=m.reads/d*100;return o.jsxs("div",{className:"in-hp-row",tabIndex:0,role:"button",title:m.danger?`${m.reads} read${m.reads===1?"":"s"}/30d · unchanged ${Math.round(m.days)}d — review this file`:m.path,onClick:()=>r(m.path),onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),r(m.path))},children:[o.jsx("span",{className:"in-hp-name"+(m.danger?" danger":""),children:m.path+(m.danger?" ⚠":"")}),o.jsxs("span",{className:"in-hp-bar",children:[o.jsx("span",{className:"in-hp-agent",style:{width:(A*g).toFixed(1)+"%"}}),o.jsx("span",{className:"in-hp-human",style:{width:(A*(1-g)).toFixed(1)+"%"}})]}),o.jsx("span",{className:"in-hp-count",children:m.reads})]},m.path)})}),o.jsxs("p",{className:"in-legend",children:[o.jsx("span",{className:"in-sw agent"})," agent reads ",o.jsx("span",{className:"in-sw human"})," human reads"]})]})}function Yg({devices:i}){const c=new Map;for(const x of i)for(const[q,z]of Object.entries(x.folders||{}))c.set(q,(c.get(q)||0)+z);const r=[...c.entries()].sort((x,q)=>q[1]-x[1]).slice(0,12).map(x=>x[0]),f=i.slice(0,12),d=140,m=6,g=Math.min(76,Math.max(34,(720-d-8)/r.length)),A=26,p=720,y=m+f.length*A+58,M=Math.max(1,...f.flatMap(x=>r.map(q=>(x.folders||{})[q]||0))),E=x=>{const q=[23,25,31],z=[245,166,35],w=q.map((Y,$)=>Math.round(Y+(z[$]-Y)*x));return`rgb(${w[0]},${w[1]},${w[2]})`};return o.jsxs("svg",{viewBox:`0 0 ${p} ${y}`,className:"in-chart in-matrix",children:[f.map((x,q)=>{let z=x.name||x.id||"";return z.length>20&&(z=z.slice(0,19)+"…"),o.jsxs("g",{children:[o.jsx("text",{x:d-8,y:m+q*A+17,textAnchor:"end",className:"in-label",children:z}),r.map((w,Y)=>{const $=(x.folders||{})[w]||0;return o.jsx("rect",{x:d+Y*g,y:m+q*A,width:g-4,height:A-4,rx:3,fill:E(Math.sqrt($/M)),children:o.jsx("title",{children:`${x.name||x.id} × ${w||"(root)"}: ${$} read${$===1?"":"s"}/30d`})},w)})]},x.id||q)}),r.map((x,q)=>{const z=d+q*g+(g-4)/2,w=m+f.length*A+14;return o.jsx("text",{x:z,y:w,className:"in-label",textAnchor:"end",transform:`rotate(-28 ${z} ${w})`,children:x||"(root)"},x)})]})}function Gg(i){const{apiBase:c,target:r,isFolder:f,onMeta:d,onRendered:m}=i,g=r?f(r)?{prefix:r+"/"}:{path:r}:{prefix:""},A="path"in g&&g.path!==void 0?"path="+encodeURIComponent(g.path):"prefix="+encodeURIComponent(g.prefix??""),{data:p,error:y}=ge({queryKey:["history",c,A,200],queryFn:()=>Ce(c+"history?"+A+"&n=200"),staleTime:15e3});if(Q.useEffect(()=>{y&&d("History unavailable: "+y.message)},[y,d]),Q.useEffect(()=>{p&&m?.()},[p,m]),!p)return null;const M=p.entries||[];return o.jsxs("div",{className:"history",children:[M.length===0&&o.jsx("div",{className:"empty",children:"No history yet."}),M.map((E,x)=>o.jsx(gm,{entry:E,onOpen:i.onOpen},x))]})}function Xg(i,c){return i?c(i)?i+"/ (folder)":i:"all changes"}function bm(i){const{config:c,apiBase:r,route:f,hub:d,project:m}=i,g=mr(),A=ei(),{tree:p,flatFiles:y,dirIndex:M,loaded:E}=hg(r,!d||!!m),x=mg(r,d&&!!m&&!!c.reads?.enabled),q=d&&!!m&&!f.path&&!f.view,z=!!i.canInsights&&(f.view==="insights"||q),w=qg(r,z);Q.useEffect(()=>{z&&A.invalidateQueries({queryKey:["heat",r]})},[z,r,A]);const Y=f.path,$=!!Y&&M.has(Y),yt=!!Y&&E&&!$&&y.some(P=>P.path===Y),ot=!!Y&&E&&!$&&!yt,Ct=$&&!f.view,[Rt,et]=Q.useState(()=>new Set),k=Q.useRef(!0);Q.useEffect(()=>{if(!p||!k.current)return;k.current=!1;const P=(p.children||[]).filter(ft=>ft.dir);P.length===1&&et(ft=>new Set(ft).add(P[0].path))},[p]),Q.useEffect(()=>{if(!Y||!E)return;et(ft=>{const xt=new Set(ft);for(const $a of bg(Y))xt.add($a);return M.has(Y)&&xt.add(Y),xt});const P=document.querySelector(`#tree .row[data-path="${CSS.escape(Y)}"]`);P&&P.scrollIntoView({block:"nearest"})},[Y,E,M]);const gt=Q.useCallback(P=>{et(ft=>{const xt=new Set(ft);return xt.has(P)?xt.delete(P):xt.add(P),xt})},[]),wt=Q.useRef(null),ue=Q.useRef(new Map),le=Q.useRef({key:"",want:0,attempts:0});Q.useEffect(()=>{le.current={key:g,want:Pp()==="POP"?ue.current.get(g)??0:0,attempts:0}},[g]);const _t=Q.useCallback(()=>{const P=wt.current,ft=le.current;!P||ft.key!==g||ft.attempts>=3||(ft.attempts++,P.scrollTo({top:ft.want,behavior:"instant"}))},[g]),ce=Q.useCallback(()=>{wt.current&&ue.current.set(g,wt.current.scrollTop)},[g]),Ut=Q.useCallback(P=>{pe(Ip(P,m?.id)),Ze()},[m?.id]),kt=Q.useCallback(P=>pe(Ja("history",m?.id,P)),[m?.id]),[D,B]=Q.useState(""),[V,vt]=Q.useState(null),[dt,S]=Q.useState(!1),[H,L]=Q.useState(!1);Q.useEffect(()=>H0(()=>L(!0)),[]);const G=Q.useRef(null),J=i.panel??null,lt=!J&&d&&!!m&&yt,rt=!J&&d&&!!m,Vt=!J&&yt,Dt=!J&&(yt||d&&!!m&&$),Xl=r+"download?path="+encodeURIComponent(Y),ml=Q.useCallback(async()=>{try{const P=await fetch(r+"shares",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Y})});if(!P.ok)throw new Error(await P.text());const ft=await P.json(),xt=await In(ft.url);vt({url:ft.url,copied:xt})}catch(P){st("Share failed: "+P.message,!0)}},[r,Y]),yl=Q.useCallback(()=>{if(!Y)return kt("");kt($?Y+"/":Y)},[Y,$,kt]);Q.useEffect(()=>{const P=ft=>{(ft.metaKey||ft.ctrlKey)&&ft.key.toLowerCase()==="k"&&(ft.preventDefault(),L(xt=>!xt))};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[]);const li=Q.useCallback(()=>{const P=[],ft=(xt,$a,Cu,ne)=>P.push({icon:xt,label:$a,kind:Cu,run:ne});if(d&&m&&Y&&(yt&&ft("share","Share: "+Y,"action",ml),ft("hist","History: "+Y,"action",yl),yt&&ft("download","Download: "+Y,"action",()=>G.current?.click())),d&&m&&ft("hist","History: whole project","action",()=>kt("")),d)for(const xt of i.projects||[])(!m||xt.id!==m.id)&&ft("folder","Switch to project: "+xt.name,"project",()=>pe("/"+xt.id));c.auth?.enabled&&ft("power","Sign out","action",()=>window.location.href="/auth/logout");for(const xt of M.keys())ft("folder",xt,"folder",()=>Ut(xt));for(const xt of y)ft("doc",xt.path,"file",()=>Ut(xt.path));return P},[d,m,Y,yt,c.auth?.enabled,M,y,i.projects,ml,yl,kt,Ut]);Q.useEffect(()=>{if(!dt)return;const P=()=>S(!1);return document.addEventListener("click",P),()=>document.removeEventListener("click",P)},[dt]);const ze=Q.useCallback(P=>M.has(P),[M]);let Ye="markdown",se;J?(Ye="view",se=J.body):f.view==="insights"?(Ye="view",se=i.canInsights?o.jsx(Zh,{flatFiles:y,heatMap:x,devices:w,scope:f.viewTarget||"",onOpenFile:Ut,onOpenFolder:Ut,isFolder:ze}):o.jsx("div",{className:"empty",children:"Insights is for hub admins and org owners."})):f.view==="history"?(Ye="view",se=o.jsx(Gg,{apiBase:r,target:f.viewTarget||"",isFolder:ze,onOpen:Ut,onMeta:B,onRendered:_t})):Y?E?ot?(Ye="view",se=o.jsxs("div",{className:"notfound",children:[o.jsx("h1",{children:"Couldn't find that"}),o.jsxs("p",{children:[o.jsx("code",{children:Y})," isn't in this project right now."]}),o.jsx("p",{className:"nf-sub",children:"If it was just created, it may still be uploading or syncing from a teammate's device — this page checks again automatically every few seconds, so refresh or come back in a moment."}),o.jsx("button",{className:"pbtn",onClick:()=>A.invalidateQueries({queryKey:["tree",r]}),children:"Check again"})]})):$?(Ye="view",se=o.jsx(Eg,{node:M.get(Y),heatMap:x,hub:d&&!!m,apiBase:r,onOpen:Ut,onFullHistory:kt,onRendered:_t})):se=o.jsx(Ng,{apiBase:r,path:Y,heatMap:x,flatFiles:y,onOpenFile:Ut,onMeta:B,onRendered:_t}):se=o.jsx("div",{className:"empty",children:"Loading…"}):q?(Ye="view",se=o.jsxs(o.Fragment,{children:[o.jsx(vm,{project:m}),i.canInsights&&o.jsx("div",{className:"home-insights",children:o.jsx(Zh,{flatFiles:y,heatMap:x,devices:w,onOpenFile:Ut,onOpenFolder:Ut,isFolder:ze})})]})):se=o.jsx("div",{className:"empty",children:"Select a file to read it."});const Au=J?J.crumb:Y?o.jsx(Sg,{path:Y,onOpenFolder:Ut}):f.view==="insights"?"Insights — "+(f.viewTarget||m?.name||""):f.view==="history"?"History — "+Xg(f.viewTarget||"",ze):q?m.name:null,ai=o.jsx(Wn,{crumb:Au,meta:D,actions:o.jsxs(o.Fragment,{children:[lt&&o.jsx("button",{id:"share-btn",className:"btn icon-only",title:"Share","aria-label":"Share",onClick:ml,children:o.jsx(Zt,{name:"share"})}),rt&&!Y&&!f.view&&o.jsxs("button",{id:"history-btn",className:"btn",onClick:yl,children:[o.jsx(Zt,{name:"hist"})," ",o.jsx("span",{className:"lbl",children:"History"})]}),Vt&&o.jsx("a",{id:"download",hidden:!0,download:!0,href:Xl,ref:G,children:"Download"}),Dt&&o.jsx("button",{id:"more-btn",className:"btn icon-only",title:"More actions","aria-label":"More actions",onClick:P=>{P.stopPropagation(),S(!dt)},children:o.jsx(Zt,{name:"dots"})}),dt&&o.jsxs("div",{id:"more-menu",role:"menu",children:[rt&&o.jsx("button",{className:"more-item",onClick:yl,children:"History"}),Vt&&o.jsx("button",{className:"more-item",onClick:()=>G.current?.click(),children:"Download"}),i.canInsights&&o.jsx("button",{className:"more-item",onClick:()=>{i.onClosePanel?.(),pe(Ja("insights",m?.id,Y))},children:"Insights"})]})]})});return o.jsxs(o.Fragment,{children:[o.jsx($n,{vault:i.sidebar.vault,projectsNav:i.sidebar.projectsNav,orgBar:i.sidebar.orgBar,tree:o.jsx(pg,{root:p,expanded:Rt,onToggle:gt,currentPath:Y,listingShowing:Ct,onOpen:Ut}),topbar:ai,contentClass:Ye,contentRef:wt,onContentScroll:ce,children:se}),V&&o.jsx(Dg,{url:V.url,copied:V.copied,onClose:()=>vt(null)}),o.jsx(Hg,{open:H,onClose:()=>L(!1),candidates:li})]})}function Kg({config:i}){const c=mr(),r=rm(),[f,d]=Q.useState(null),[m,g]=Q.useState(null);Q.useEffect(()=>g(null),[c]);const A=Q.useMemo(()=>{const et=c.match(/^\/join\/([0-9a-f]+)\/?$/);return et?et[1]:null},[c]),{data:p}=Fp(!A),{data:y}=$p(!A),M=!!i.auth.admin,{data:E}=sm(M),x=Q.useMemo(()=>om(c,"hub"),[c]),q=Q.useMemo(()=>p&&(p.find(et=>et.id===x.project)||f&&p.find(et=>et.org===f)||p[0])||null,[p,x.project,f]);if(Q.useEffect(()=>{document.title=q?q.name+" — BearDrive":i.brand||i.volume||"BearDrive"},[q,i]),A)return o.jsx(Zg,{token:A,onDone:async et=>{d(et),await r(),pe("/",{replace:!0})}});const z=i.brand||i.volume||"BearDrive",w=q&&y?.find(et=>et.id===q.org)||null,Y=M||(w?w.role==="owner":!1),$=o.jsx(Mu,{name:z,onHome:()=>pe("/"),search:!!q}),yt=i.me?o.jsx(cg,{me:i.me,org:w,admin:M?{pending:E?.length||0,onClick:()=>{g({kind:"hub"}),Ze()}}:void 0,onOrgSettings:et=>{g({kind:"org",orgId:et.id}),Ze()}}):void 0;if(!p||!y)return o.jsx($n,{vault:$,topbar:o.jsx(Wn,{}),children:o.jsx("div",{className:"empty",children:"Loading…"})});if(!q)return o.jsx($n,{vault:$,projectsNav:o.jsx(Gh,{projects:p}),orgBar:yt,topbar:o.jsx(Wn,{}),contentClass:"view",children:o.jsx(dg,{authEnabled:i.auth.enabled,onCreate:async et=>{if(!et){st("Give the project a name.",!0);return}try{const k=await Fa("/api/projects",{name:et});await r(),pe("/"+k.project.id),st(`Created “${k.project.name}”.`)}catch(k){st("Could not create the project: "+k.message,!0)}}})});const ot=m?.kind==="org"?y.find(et=>et.id===m.orgId):null,Ct=m?.kind==="hub"?{crumb:"Signup & access",body:o.jsx(ug,{})}:ot?{crumb:ot.name,body:o.jsx(ig,{org:ot,projects:p,myEmail:i.me?.email||"",onProjectsChanged:r})}:null,Rt=x.view==="settings"?{crumb:"Project settings",body:o.jsx(sg,{project:q,org:w})}:x.view==="install"?{crumb:"Installation",body:o.jsx("div",{className:"onboard",children:o.jsx(vm,{project:q})})}:null;return x.project!==q.id?o.jsx(tg,{to:"/"+q.id}):o.jsx(bm,{config:i,apiBase:"/api/p/"+q.id+"/",route:x,hub:!0,project:q,projects:p,canInsights:Y,sidebar:{vault:$,projectsNav:o.jsx(Gh,{projects:p,currentId:q.id,menu:{active:m?null:x.view==="insights"?"dashboard":x.view==="install"?"install":x.view==="history"?"history":x.view==="settings"?"settings":null,onDashboard:()=>{g(null),pe(Ja("insights",q.id)),Ze()},onInstall:()=>{g(null),pe(Ja("install",q.id)),Ze()},onHistory:()=>{g(null),pe(Ja("history",q.id)),Ze()},onSettings:()=>{g(null),pe(Ja("settings",q.id)),Ze()}}}),orgBar:yt},panel:Ct||Rt,onClosePanel:()=>g(null)},q.id)}function Zg({token:i,onDone:c}){return Q.useEffect(()=>{let r=!1;return Fa("/api/invites/"+i).then(f=>{r||(st(`Welcome — you joined the “${f.org.name}” team. Opening its projects…`),c(f.org.id))}).catch(f=>{r||String(f.message).includes("signing in")||(st("Could not accept the invite: "+f.message,!0),c(null))}),()=>{r=!0}},[i]),o.jsx($n,{vault:o.jsx(Mu,{name:"BearDrive"}),topbar:o.jsx(Wn,{}),children:o.jsx("div",{className:"empty",children:"Joining…"})})}function kg({config:i}){const c=mr(),r=i.volume||"BearDrive";Q.useEffect(()=>{document.title=i.brand||r},[i,r]);const f=Q.useMemo(()=>om(c,"volume"),[c]);return o.jsx(bm,{config:i,apiBase:"/api/",route:f,hub:!1,sidebar:{vault:o.jsx(Mu,{name:r,showSignout:i.auth.enabled,search:!0})}})}function Vg(){const{data:i}=U0();return o.jsxs(o.Fragment,{children:[i?i.mode==="hub"?o.jsx(Kg,{config:i}):o.jsx(kg,{config:i}):o.jsx($n,{vault:o.jsx(Mu,{name:"…",showSignout:!1}),topbar:o.jsx(Wn,{}),children:o.jsx("div",{className:"empty",children:"Loading…"})}),o.jsx(Zp,{}),o.jsx(kp,{})]})}const Jg=new x0({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}});Fv.createRoot(document.getElementById("root")).render(o.jsx(Q.StrictMode,{children:o.jsx(j0,{client:Jg,children:o.jsx(Vg,{})})})); diff --git a/internal/webapp/static/assets/index-D_qY6bcM.js b/internal/webapp/static/assets/index-D_qY6bcM.js new file mode 100644 index 0000000..3393bbc --- /dev/null +++ b/internal/webapp/static/assets/index-D_qY6bcM.js @@ -0,0 +1,11 @@ +(function(){const c=document.createElement("link").relList;if(c&&c.supports&&c.supports("modulepreload"))return;for(const d of document.querySelectorAll('link[rel="modulepreload"]'))f(d);new MutationObserver(d=>{for(const m of d)if(m.type==="childList")for(const g of m.addedNodes)g.tagName==="LINK"&&g.rel==="modulepreload"&&f(g)}).observe(document,{childList:!0,subtree:!0});function r(d){const m={};return d.integrity&&(m.integrity=d.integrity),d.referrerPolicy&&(m.referrerPolicy=d.referrerPolicy),d.crossOrigin==="use-credentials"?m.credentials="include":d.crossOrigin==="anonymous"?m.credentials="omit":m.credentials="same-origin",m}function f(d){if(d.ep)return;d.ep=!0;const m=r(d);fetch(d.href,m)}})();var Xs={exports:{}},Vn={};var ph;function Lv(){if(ph)return Vn;ph=1;var i=Symbol.for("react.transitional.element"),c=Symbol.for("react.fragment");function r(f,d,m){var g=null;if(m!==void 0&&(g=""+m),d.key!==void 0&&(g=""+d.key),"key"in d){m={};for(var A in d)A!=="key"&&(m[A]=d[A])}else m=d;return d=m.ref,{$$typeof:i,type:f,key:g,ref:d!==void 0?d:null,props:m}}return Vn.Fragment=c,Vn.jsx=r,Vn.jsxs=r,Vn}var gh;function Yv(){return gh||(gh=1,Xs.exports=Lv()),Xs.exports}var o=Yv(),Ks={exports:{}},I={};var bh;function Gv(){if(bh)return I;bh=1;var i=Symbol.for("react.transitional.element"),c=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),f=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),m=Symbol.for("react.consumer"),g=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),E=Symbol.for("react.activity"),x=Symbol.iterator;function w(S){return S===null||typeof S!="object"?null:(S=x&&S[x]||S["@@iterator"],typeof S=="function"?S:null)}var z={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},q=Object.assign,Y={};function F(S,H,L){this.props=S,this.context=H,this.refs=Y,this.updater=L||z}F.prototype.isReactComponent={},F.prototype.setState=function(S,H){if(typeof S!="object"&&typeof S!="function"&&S!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,S,H,"setState")},F.prototype.forceUpdate=function(S){this.updater.enqueueForceUpdate(this,S,"forceUpdate")};function yt(){}yt.prototype=F.prototype;function lt(S,H,L){this.props=S,this.context=H,this.refs=Y,this.updater=L||z}var Ct=lt.prototype=new yt;Ct.constructor=lt,q(Ct,F.prototype),Ct.isPureReactComponent=!0;var Rt=Array.isArray;function at(){}var k={H:null,A:null,T:null,S:null},pt=Object.prototype.hasOwnProperty;function Zt(S,H,L){var G=L.ref;return{$$typeof:i,type:S,key:H,ref:G!==void 0?G:null,props:L}}function ee(S,H){return Zt(S.type,H,S.props)}function le(S){return typeof S=="object"&&S!==null&&S.$$typeof===i}function Ut(S){var H={"=":"=0",":":"=2"};return"$"+S.replace(/[=:]/g,function(L){return H[L]})}var ae=/\/+/g;function Be(S,H){return typeof S=="object"&&S!==null&&S.key!=null?Ut(""+S.key):H.toString(36)}function zt(S){switch(S.status){case"fulfilled":return S.value;case"rejected":throw S.reason;default:switch(typeof S.status=="string"?S.then(at,at):(S.status="pending",S.then(function(H){S.status==="pending"&&(S.status="fulfilled",S.value=H)},function(H){S.status==="pending"&&(S.status="rejected",S.reason=H)})),S.status){case"fulfilled":return S.value;case"rejected":throw S.reason}}throw S}function _(S,H,L,G,$){var W=typeof S;(W==="undefined"||W==="boolean")&&(S=null);var dt=!1;if(S===null)dt=!0;else switch(W){case"bigint":case"string":case"number":dt=!0;break;case"object":switch(S.$$typeof){case i:case c:dt=!0;break;case M:return dt=S._init,_(dt(S._payload),H,L,G,$)}}if(dt)return $=$(S),dt=G===""?"."+Be(S,0):G,Rt($)?(L="",dt!=null&&(L=dt.replace(ae,"$&/")+"/"),_($,H,L,"",function(Gl){return Gl})):$!=null&&(le($)&&($=ee($,L+($.key==null||S&&S.key===$.key?"":(""+$.key).replace(ae,"$&/")+"/")+dt)),H.push($)),1;dt=0;var kt=G===""?".":G+":";if(Rt(S))for(var _t=0;_t>>1,gt=_[ot];if(0>>1;otd(L,V))Gd($,L)?(_[ot]=$,_[G]=V,ot=G):(_[ot]=L,_[H]=V,ot=H);else if(Gd($,V))_[ot]=$,_[G]=V,ot=G;else break t}}return B}function d(_,B){var V=_.sortIndex-B.sortIndex;return V!==0?V:_.id-B.id}if(i.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var m=performance;i.unstable_now=function(){return m.now()}}else{var g=Date,A=g.now();i.unstable_now=function(){return g.now()-A}}var p=[],y=[],M=1,E=null,x=3,w=!1,z=!1,q=!1,Y=!1,F=typeof setTimeout=="function"?setTimeout:null,yt=typeof clearTimeout=="function"?clearTimeout:null,lt=typeof setImmediate<"u"?setImmediate:null;function Ct(_){for(var B=r(y);B!==null;){if(B.callback===null)f(y);else if(B.startTime<=_)f(y),B.sortIndex=B.expirationTime,c(p,B);else break;B=r(y)}}function Rt(_){if(q=!1,Ct(_),!z)if(r(p)!==null)z=!0,at||(at=!0,Ut());else{var B=r(y);B!==null&&zt(Rt,B.startTime-_)}}var at=!1,k=-1,pt=5,Zt=-1;function ee(){return Y?!0:!(i.unstable_now()-Zt_&&ee());){var ot=E.callback;if(typeof ot=="function"){E.callback=null,x=E.priorityLevel;var gt=ot(E.expirationTime<=_);if(_=i.unstable_now(),typeof gt=="function"){E.callback=gt,Ct(_),B=!0;break e}E===r(p)&&f(p),Ct(_)}else f(p);E=r(p)}if(E!==null)B=!0;else{var S=r(y);S!==null&&zt(Rt,S.startTime-_),B=!1}}break t}finally{E=null,x=V,w=!1}B=void 0}}finally{B?Ut():at=!1}}}var Ut;if(typeof lt=="function")Ut=function(){lt(le)};else if(typeof MessageChannel<"u"){var ae=new MessageChannel,Be=ae.port2;ae.port1.onmessage=le,Ut=function(){Be.postMessage(null)}}else Ut=function(){F(le,0)};function zt(_,B){k=F(function(){_(i.unstable_now())},B)}i.unstable_IdlePriority=5,i.unstable_ImmediatePriority=1,i.unstable_LowPriority=4,i.unstable_NormalPriority=3,i.unstable_Profiling=null,i.unstable_UserBlockingPriority=2,i.unstable_cancelCallback=function(_){_.callback=null},i.unstable_forceFrameRate=function(_){0>_||125<_?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):pt=0<_?Math.floor(1e3/_):5},i.unstable_getCurrentPriorityLevel=function(){return x},i.unstable_next=function(_){switch(x){case 1:case 2:case 3:var B=3;break;default:B=x}var V=x;x=B;try{return _()}finally{x=V}},i.unstable_requestPaint=function(){Y=!0},i.unstable_runWithPriority=function(_,B){switch(_){case 1:case 2:case 3:case 4:case 5:break;default:_=3}var V=x;x=_;try{return B()}finally{x=V}},i.unstable_scheduleCallback=function(_,B,V){var ot=i.unstable_now();switch(typeof V=="object"&&V!==null?(V=V.delay,V=typeof V=="number"&&0ot?(_.sortIndex=V,c(y,_),r(p)===null&&_===r(y)&&(q?(yt(k),k=-1):q=!0,zt(Rt,V-ot))):(_.sortIndex=gt,c(p,_),z||w||(z=!0,at||(at=!0,Ut()))),_},i.unstable_shouldYield=ee,i.unstable_wrapCallback=function(_){var B=x;return function(){var V=x;x=B;try{return _.apply(this,arguments)}finally{x=V}}}})(Vs)),Vs}var jh;function Kv(){return jh||(jh=1,ks.exports=Xv()),ks.exports}var Js={exports:{}},ne={};var Eh;function Zv(){if(Eh)return ne;Eh=1;var i=cr();function c(p){var y="https://react.dev/errors/"+p;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(c){console.error(c)}}return i(),Js.exports=Zv(),Js.exports}var Nh;function Vv(){if(Nh)return Jn;Nh=1;var i=Kv(),c=cr(),r=kv();function f(t){var e="https://react.dev/errors/"+t;if(1gt||(t.current=ot[gt],ot[gt]=null,gt--)}function L(t,e){gt++,ot[gt]=t.current,t.current=e}var G=S(null),$=S(null),W=S(null),dt=S(null);function kt(t,e){switch(L(W,e),L($,t),L(G,null),e.nodeType){case 9:case 11:t=(t=e.documentElement)&&(t=t.namespaceURI)?Ld(t):0;break;default:if(t=e.tagName,e=e.namespaceURI)e=Ld(e),t=Yd(e,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}H(G),L(G,t)}function _t(){H(G),H($),H(W)}function Gl(t){t.memoizedState!==null&&L(dt,t);var e=G.current,l=Yd(e,t.type);e!==l&&(L($,t),L(G,l))}function fa(t){$.current===t&&(H(G),H($)),dt.current===t&&(H(dt),Xn._currentValue=V)}var Xl,Kl;function Fe(t){if(Xl===void 0)try{throw Error()}catch(l){var e=l.stack.trim().match(/\n( *(at )?)/);Xl=e&&e[1]||"",Kl=-1)":-1n||v[a]!==N[n]){var D=` +`+v[a].replace(" at new "," at ");return t.displayName&&D.includes("")&&(D=D.replace("",t.displayName)),D}while(1<=a&&0<=n);break}}}finally{ml=!1,Error.prepareStackTrace=l}return(l=t?t.displayName||t.name:"")?Fe(l):""}function Ae(t,e){switch(t.tag){case 26:case 27:case 5:return Fe(t.type);case 16:return Fe("Lazy");case 13:return t.child!==e&&e!==null?Fe("Suspense Fallback"):Fe("Suspense");case 19:return Fe("SuspenseList");case 0:case 15:return Le(t.type,!1);case 11:return Le(t.type.render,!1);case 1:return Le(t.type,!0);case 31:return Fe("Activity");default:return""}}function ii(t){try{var e="",l=null;do e+=Ae(t,l),l=t,t=t.return;while(t);return e}catch(a){return` +Error generating stack: `+a.message+` +`+a.stack}}var Ia=Object.prototype.hasOwnProperty,tt=i.unstable_scheduleCallback,ft=i.unstable_cancelCallback,Ot=i.unstable_shouldYield,Pa=i.unstable_requestPaint,ie=i.unstable_now,zu=i.unstable_getCurrentPriorityLevel,vr=i.unstable_ImmediatePriority,pr=i.unstable_UserBlockingPriority,ui=i.unstable_NormalPriority,xm=i.unstable_LowPriority,gr=i.unstable_IdlePriority,jm=i.log,Em=i.unstable_setDisableYieldValue,tn=null,pe=null;function yl(t){if(typeof jm=="function"&&Em(t),pe&&typeof pe.setStrictMode=="function")try{pe.setStrictMode(tn,t)}catch{}}var ge=Math.clz32?Math.clz32:Om,Tm=Math.log,Nm=Math.LN2;function Om(t){return t>>>=0,t===0?32:31-(Tm(t)/Nm|0)|0}var ci=256,si=262144,ri=4194304;function Zl(t){var e=t&42;if(e!==0)return e;switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function fi(t,e,l){var a=t.pendingLanes;if(a===0)return 0;var n=0,u=t.suspendedLanes,s=t.pingedLanes;t=t.warmLanes;var h=a&134217727;return h!==0?(a=h&~u,a!==0?n=Zl(a):(s&=h,s!==0?n=Zl(s):l||(l=h&~t,l!==0&&(n=Zl(l))))):(h=a&~u,h!==0?n=Zl(h):s!==0?n=Zl(s):l||(l=a&~t,l!==0&&(n=Zl(l)))),n===0?0:e!==0&&e!==n&&(e&u)===0&&(u=n&-n,l=e&-e,u>=l||u===32&&(l&4194048)!==0)?e:n}function en(t,e){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&e)===0}function Mm(t,e){switch(t){case 1:case 2:case 4:case 8:case 64:return e+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function br(){var t=ri;return ri<<=1,(ri&62914560)===0&&(ri=4194304),t}function _u(t){for(var e=[],l=0;31>l;l++)e.push(t);return e}function ln(t,e){t.pendingLanes|=e,e!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function Am(t,e,l,a,n,u){var s=t.pendingLanes;t.pendingLanes=l,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=l,t.entangledLanes&=l,t.errorRecoveryDisabledLanes&=l,t.shellSuspendCounter=0;var h=t.entanglements,v=t.expirationTimes,N=t.hiddenUpdates;for(l=s&~l;0"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var Um=/[\n"\\]/g;function ze(t){return t.replace(Um,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})}function qu(t,e,l,a,n,u,s,h){t.name="",s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"?t.type=s:t.removeAttribute("type"),e!=null?s==="number"?(e===0&&t.value===""||t.value!=e)&&(t.value=""+Ce(e)):t.value!==""+Ce(e)&&(t.value=""+Ce(e)):s!=="submit"&&s!=="reset"||t.removeAttribute("value"),e!=null?Qu(t,s,Ce(e)):l!=null?Qu(t,s,Ce(l)):a!=null&&t.removeAttribute("value"),n==null&&u!=null&&(t.defaultChecked=!!u),n!=null&&(t.checked=n&&typeof n!="function"&&typeof n!="symbol"),h!=null&&typeof h!="function"&&typeof h!="symbol"&&typeof h!="boolean"?t.name=""+Ce(h):t.removeAttribute("name")}function Dr(t,e,l,a,n,u,s,h){if(u!=null&&typeof u!="function"&&typeof u!="symbol"&&typeof u!="boolean"&&(t.type=u),e!=null||l!=null){if(!(u!=="submit"&&u!=="reset"||e!=null)){wu(t);return}l=l!=null?""+Ce(l):"",e=e!=null?""+Ce(e):l,h||e===t.value||(t.value=e),t.defaultValue=e}a=a??n,a=typeof a!="function"&&typeof a!="symbol"&&!!a,t.checked=h?t.checked:!!a,t.defaultChecked=!!a,s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"&&(t.name=s),wu(t)}function Qu(t,e,l){e==="number"&&hi(t.ownerDocument)===t||t.defaultValue===""+l||(t.defaultValue=""+l)}function va(t,e,l,a){if(t=t.options,e){e={};for(var n=0;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Xu=!1;if(Ie)try{var cn={};Object.defineProperty(cn,"passive",{get:function(){Xu=!0}}),window.addEventListener("test",cn,cn),window.removeEventListener("test",cn,cn)}catch{Xu=!1}var pl=null,Ku=null,yi=null;function Br(){if(yi)return yi;var t,e=Ku,l=e.length,a,n="value"in pl?pl.value:pl.textContent,u=n.length;for(t=0;t=fn),Zr=" ",kr=!1;function Vr(t,e){switch(t){case"keyup":return sy.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Jr(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Sa=!1;function fy(t,e){switch(t){case"compositionend":return Jr(e);case"keypress":return e.which!==32?null:(kr=!0,Zr);case"textInput":return t=e.data,t===Zr&&kr?null:t;default:return null}}function oy(t,e){if(Sa)return t==="compositionend"||!Fu&&Vr(t,e)?(t=Br(),yi=Ku=pl=null,Sa=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:l,offset:e-t};t=a}t:{for(;l;){if(l.nextSibling){l=l.nextSibling;break t}l=l.parentNode}l=void 0}l=lf(l)}}function nf(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?nf(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function uf(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var e=hi(t.document);e instanceof t.HTMLIFrameElement;){try{var l=typeof e.contentWindow.location.href=="string"}catch{l=!1}if(l)t=e.contentWindow;else break;e=hi(t.document)}return e}function Iu(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}var by=Ie&&"documentMode"in document&&11>=document.documentMode,xa=null,Pu=null,mn=null,tc=!1;function cf(t,e,l){var a=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;tc||xa==null||xa!==hi(a)||(a=xa,"selectionStart"in a&&Iu(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),mn&&hn(mn,a)||(mn=a,a=su(Pu,"onSelect"),0>=s,n-=s,Ze=1<<32-ge(e)+n|l<et?(ct=K,K=null):ct=K.sibling;var mt=O(j,K,T[et],R);if(mt===null){K===null&&(K=ct);break}t&&K&&mt.alternate===null&&e(j,K),b=u(mt,b,et),ht===null?Z=mt:ht.sibling=mt,ht=mt,K=ct}if(et===T.length)return l(j,K),st&&tl(j,et),Z;if(K===null){for(;etet?(ct=K,K=null):ct=K.sibling;var Bl=O(j,K,mt.value,R);if(Bl===null){K===null&&(K=ct);break}t&&K&&Bl.alternate===null&&e(j,K),b=u(Bl,b,et),ht===null?Z=Bl:ht.sibling=Bl,ht=Bl,K=ct}if(mt.done)return l(j,K),st&&tl(j,et),Z;if(K===null){for(;!mt.done;et++,mt=T.next())mt=U(j,mt.value,R),mt!==null&&(b=u(mt,b,et),ht===null?Z=mt:ht.sibling=mt,ht=mt);return st&&tl(j,et),Z}for(K=a(K);!mt.done;et++,mt=T.next())mt=C(K,j,et,mt.value,R),mt!==null&&(t&&mt.alternate!==null&&K.delete(mt.key===null?et:mt.key),b=u(mt,b,et),ht===null?Z=mt:ht.sibling=mt,ht=mt);return t&&K.forEach(function(Bv){return e(j,Bv)}),st&&tl(j,et),Z}function Et(j,b,T,R){if(typeof T=="object"&&T!==null&&T.type===q&&T.key===null&&(T=T.props.children),typeof T=="object"&&T!==null){switch(T.$$typeof){case w:t:{for(var Z=T.key;b!==null;){if(b.key===Z){if(Z=T.type,Z===q){if(b.tag===7){l(j,b.sibling),R=n(b,T.props.children),R.return=j,j=R;break t}}else if(b.elementType===Z||typeof Z=="object"&&Z!==null&&Z.$$typeof===pt&&la(Z)===b.type){l(j,b.sibling),R=n(b,T.props),Sn(R,T),R.return=j,j=R;break t}l(j,b);break}else e(j,b);b=b.sibling}T.type===q?(R=Wl(T.props.children,j.mode,R,T.key),R.return=j,j=R):(R=Ni(T.type,T.key,T.props,null,j.mode,R),Sn(R,T),R.return=j,j=R)}return s(j);case z:t:{for(Z=T.key;b!==null;){if(b.key===Z)if(b.tag===4&&b.stateNode.containerInfo===T.containerInfo&&b.stateNode.implementation===T.implementation){l(j,b.sibling),R=n(b,T.children||[]),R.return=j,j=R;break t}else{l(j,b);break}else e(j,b);b=b.sibling}R=cc(T,j.mode,R),R.return=j,j=R}return s(j);case pt:return T=la(T),Et(j,b,T,R)}if(zt(T))return X(j,b,T,R);if(Ut(T)){if(Z=Ut(T),typeof Z!="function")throw Error(f(150));return T=Z.call(T),J(j,b,T,R)}if(typeof T.then=="function")return Et(j,b,Di(T),R);if(T.$$typeof===lt)return Et(j,b,Ai(j,T),R);Ri(j,T)}return typeof T=="string"&&T!==""||typeof T=="number"||typeof T=="bigint"?(T=""+T,b!==null&&b.tag===6?(l(j,b.sibling),R=n(b,T),R.return=j,j=R):(l(j,b),R=uc(T,j.mode,R),R.return=j,j=R),s(j)):l(j,b)}return function(j,b,T,R){try{bn=0;var Z=Et(j,b,T,R);return Da=null,Z}catch(K){if(K===_a||K===zi)throw K;var ht=Se(29,K,null,j.mode);return ht.lanes=R,ht.return=j,ht}}}var na=zf(!0),_f=zf(!1),jl=!1;function bc(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Sc(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function El(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function Tl(t,e,l){var a=t.updateQueue;if(a===null)return null;if(a=a.shared,(vt&2)!==0){var n=a.pending;return n===null?e.next=e:(e.next=n.next,n.next=e),a.pending=e,e=Ti(t),mf(t,null,l),e}return Ei(t,a,e,l),Ti(t)}function xn(t,e,l){if(e=e.updateQueue,e!==null&&(e=e.shared,(l&4194048)!==0)){var a=e.lanes;a&=t.pendingLanes,l|=a,e.lanes=l,xr(t,l)}}function xc(t,e){var l=t.updateQueue,a=t.alternate;if(a!==null&&(a=a.updateQueue,l===a)){var n=null,u=null;if(l=l.firstBaseUpdate,l!==null){do{var s={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};u===null?n=u=s:u=u.next=s,l=l.next}while(l!==null);u===null?n=u=e:u=u.next=e}else n=u=e;l={baseState:a.baseState,firstBaseUpdate:n,lastBaseUpdate:u,shared:a.shared,callbacks:a.callbacks},t.updateQueue=l;return}t=l.lastBaseUpdate,t===null?l.firstBaseUpdate=e:t.next=e,l.lastBaseUpdate=e}var jc=!1;function jn(){if(jc){var t=za;if(t!==null)throw t}}function En(t,e,l,a){jc=!1;var n=t.updateQueue;jl=!1;var u=n.firstBaseUpdate,s=n.lastBaseUpdate,h=n.shared.pending;if(h!==null){n.shared.pending=null;var v=h,N=v.next;v.next=null,s===null?u=N:s.next=N,s=v;var D=t.alternate;D!==null&&(D=D.updateQueue,h=D.lastBaseUpdate,h!==s&&(h===null?D.firstBaseUpdate=N:h.next=N,D.lastBaseUpdate=v))}if(u!==null){var U=n.baseState;s=0,D=N=v=null,h=u;do{var O=h.lane&-536870913,C=O!==h.lane;if(C?(ut&O)===O:(a&O)===O){O!==0&&O===Ca&&(jc=!0),D!==null&&(D=D.next={lane:0,tag:h.tag,payload:h.payload,callback:null,next:null});t:{var X=t,J=h;O=e;var Et=l;switch(J.tag){case 1:if(X=J.payload,typeof X=="function"){U=X.call(Et,U,O);break t}U=X;break t;case 3:X.flags=X.flags&-65537|128;case 0:if(X=J.payload,O=typeof X=="function"?X.call(Et,U,O):X,O==null)break t;U=E({},U,O);break t;case 2:jl=!0}}O=h.callback,O!==null&&(t.flags|=64,C&&(t.flags|=8192),C=n.callbacks,C===null?n.callbacks=[O]:C.push(O))}else C={lane:O,tag:h.tag,payload:h.payload,callback:h.callback,next:null},D===null?(N=D=C,v=U):D=D.next=C,s|=O;if(h=h.next,h===null){if(h=n.shared.pending,h===null)break;C=h,h=C.next,C.next=null,n.lastBaseUpdate=C,n.shared.pending=null}}while(!0);D===null&&(v=U),n.baseState=v,n.firstBaseUpdate=N,n.lastBaseUpdate=D,u===null&&(n.shared.lanes=0),Cl|=s,t.lanes=s,t.memoizedState=U}}function Df(t,e){if(typeof t!="function")throw Error(f(191,t));t.call(e)}function Rf(t,e){var l=t.callbacks;if(l!==null)for(t.callbacks=null,t=0;tu?u:8;var s=_.T,h={};_.T=h,Yc(t,!1,e,l);try{var v=n(),N=_.S;if(N!==null&&N(h,v),v!==null&&typeof v=="object"&&typeof v.then=="function"){var D=Ay(v,a);On(t,e,D,Ne(t))}else On(t,e,a,Ne(t))}catch(U){On(t,e,{then:function(){},status:"rejected",reason:U},Ne())}finally{B.p=u,s!==null&&h.types!==null&&(s.types=h.types),_.T=s}}function Uy(){}function Bc(t,e,l,a){if(t.tag!==5)throw Error(f(476));var n=oo(t).queue;fo(t,n,e,V,l===null?Uy:function(){return ho(t),l(a)})}function oo(t){var e=t.memoizedState;if(e!==null)return e;e={memoizedState:V,baseState:V,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:nl,lastRenderedState:V},next:null};var l={};return e.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:nl,lastRenderedState:l},next:null},t.memoizedState=e,t=t.alternate,t!==null&&(t.memoizedState=e),e}function ho(t){var e=oo(t);e.next===null&&(e=t.alternate.memoizedState),On(t,e.next.queue,{},Ne())}function Lc(){return Wt(Xn)}function mo(){return Qt().memoizedState}function yo(){return Qt().memoizedState}function Hy(t){for(var e=t.return;e!==null;){switch(e.tag){case 24:case 3:var l=Ne();t=El(l);var a=Tl(e,t,l);a!==null&&(he(a,e,l),xn(a,e,l)),e={cache:yc()},t.payload=e;return}e=e.return}}function wy(t,e,l){var a=Ne();l={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Xi(t)?po(e,l):(l=nc(t,e,l,a),l!==null&&(he(l,t,a),go(l,e,a)))}function vo(t,e,l){var a=Ne();On(t,e,l,a)}function On(t,e,l,a){var n={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Xi(t))po(e,n);else{var u=t.alternate;if(t.lanes===0&&(u===null||u.lanes===0)&&(u=e.lastRenderedReducer,u!==null))try{var s=e.lastRenderedState,h=u(s,l);if(n.hasEagerState=!0,n.eagerState=h,be(h,s))return Ei(t,e,n,0),Tt===null&&ji(),!1}catch{}if(l=nc(t,e,n,a),l!==null)return he(l,t,a),go(l,e,a),!0}return!1}function Yc(t,e,l,a){if(a={lane:2,revertLane:bs(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Xi(t)){if(e)throw Error(f(479))}else e=nc(t,l,a,2),e!==null&&he(e,t,2)}function Xi(t){var e=t.alternate;return t===P||e!==null&&e===P}function po(t,e){Ua=wi=!0;var l=t.pending;l===null?e.next=e:(e.next=l.next,l.next=e),t.pending=e}function go(t,e,l){if((l&4194048)!==0){var a=e.lanes;a&=t.pendingLanes,l|=a,e.lanes=l,xr(t,l)}}var Mn={readContext:Wt,use:Bi,useCallback:Ht,useContext:Ht,useEffect:Ht,useImperativeHandle:Ht,useLayoutEffect:Ht,useInsertionEffect:Ht,useMemo:Ht,useReducer:Ht,useRef:Ht,useState:Ht,useDebugValue:Ht,useDeferredValue:Ht,useTransition:Ht,useSyncExternalStore:Ht,useId:Ht,useHostTransitionStatus:Ht,useFormState:Ht,useActionState:Ht,useOptimistic:Ht,useMemoCache:Ht,useCacheRefresh:Ht};Mn.useEffectEvent=Ht;var bo={readContext:Wt,use:Bi,useCallback:function(t,e){return ue().memoizedState=[t,e===void 0?null:e],t},useContext:Wt,useEffect:eo,useImperativeHandle:function(t,e,l){l=l!=null?l.concat([t]):null,Yi(4194308,4,io.bind(null,e,t),l)},useLayoutEffect:function(t,e){return Yi(4194308,4,t,e)},useInsertionEffect:function(t,e){Yi(4,2,t,e)},useMemo:function(t,e){var l=ue();e=e===void 0?null:e;var a=t();if(ia){yl(!0);try{t()}finally{yl(!1)}}return l.memoizedState=[a,e],a},useReducer:function(t,e,l){var a=ue();if(l!==void 0){var n=l(e);if(ia){yl(!0);try{l(e)}finally{yl(!1)}}}else n=e;return a.memoizedState=a.baseState=n,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:n},a.queue=t,t=t.dispatch=wy.bind(null,P,t),[a.memoizedState,t]},useRef:function(t){var e=ue();return t={current:t},e.memoizedState=t},useState:function(t){t=Uc(t);var e=t.queue,l=vo.bind(null,P,e);return e.dispatch=l,[t.memoizedState,l]},useDebugValue:qc,useDeferredValue:function(t,e){var l=ue();return Qc(l,t,e)},useTransition:function(){var t=Uc(!1);return t=fo.bind(null,P,t.queue,!0,!1),ue().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,e,l){var a=P,n=ue();if(st){if(l===void 0)throw Error(f(407));l=l()}else{if(l=e(),Tt===null)throw Error(f(349));(ut&127)!==0||Bf(a,e,l)}n.memoizedState=l;var u={value:l,getSnapshot:e};return n.queue=u,eo(Yf.bind(null,a,u,t),[t]),a.flags|=2048,wa(9,{destroy:void 0},Lf.bind(null,a,u,l,e),null),l},useId:function(){var t=ue(),e=Tt.identifierPrefix;if(st){var l=ke,a=Ze;l=(a&~(1<<32-ge(a)-1)).toString(32)+l,e="_"+e+"R_"+l,l=qi++,0<\/script>",u=u.removeChild(u.firstChild);break;case"select":u=typeof a.is=="string"?s.createElement("select",{is:a.is}):s.createElement("select"),a.multiple?u.multiple=!0:a.size&&(u.size=a.size);break;default:u=typeof a.is=="string"?s.createElement(n,{is:a.is}):s.createElement(n)}}u[Ft]=e,u[ce]=a;t:for(s=e.child;s!==null;){if(s.tag===5||s.tag===6)u.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===e)break t;for(;s.sibling===null;){if(s.return===null||s.return===e)break t;s=s.return}s.sibling.return=s.return,s=s.sibling}e.stateNode=u;t:switch(Pt(u,n,a),n){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break t;case"img":a=!0;break t;default:a=!1}a&&ul(e)}}return At(e),es(e,e.type,t===null?null:t.memoizedProps,e.pendingProps,l),null;case 6:if(t&&e.stateNode!=null)t.memoizedProps!==a&&ul(e);else{if(typeof a!="string"&&e.stateNode===null)throw Error(f(166));if(t=W.current,Ma(e)){if(t=e.stateNode,l=e.memoizedProps,a=null,n=$t,n!==null)switch(n.tag){case 27:case 5:a=n.memoizedProps}t[Ft]=e,t=!!(t.nodeValue===l||a!==null&&a.suppressHydrationWarning===!0||Qd(t.nodeValue,l)),t||Sl(e,!0)}else t=ru(t).createTextNode(a),t[Ft]=e,e.stateNode=t}return At(e),null;case 31:if(l=e.memoizedState,t===null||t.memoizedState!==null){if(a=Ma(e),l!==null){if(t===null){if(!a)throw Error(f(318));if(t=e.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(f(557));t[Ft]=e}else Il(),(e.flags&128)===0&&(e.memoizedState=null),e.flags|=4;At(e),t=!1}else l=oc(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=l),t=!0;if(!t)return e.flags&256?(je(e),e):(je(e),null);if((e.flags&128)!==0)throw Error(f(558))}return At(e),null;case 13:if(a=e.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(n=Ma(e),a!==null&&a.dehydrated!==null){if(t===null){if(!n)throw Error(f(318));if(n=e.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(f(317));n[Ft]=e}else Il(),(e.flags&128)===0&&(e.memoizedState=null),e.flags|=4;At(e),n=!1}else n=oc(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=n),n=!0;if(!n)return e.flags&256?(je(e),e):(je(e),null)}return je(e),(e.flags&128)!==0?(e.lanes=l,e):(l=a!==null,t=t!==null&&t.memoizedState!==null,l&&(a=e.child,n=null,a.alternate!==null&&a.alternate.memoizedState!==null&&a.alternate.memoizedState.cachePool!==null&&(n=a.alternate.memoizedState.cachePool.pool),u=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(u=a.memoizedState.cachePool.pool),u!==n&&(a.flags|=2048)),l!==t&&l&&(e.child.flags|=8192),Ji(e,e.updateQueue),At(e),null);case 4:return _t(),t===null&&Es(e.stateNode.containerInfo),At(e),null;case 10:return ll(e.type),At(e),null;case 19:if(H(qt),a=e.memoizedState,a===null)return At(e),null;if(n=(e.flags&128)!==0,u=a.rendering,u===null)if(n)Cn(a,!1);else{if(wt!==0||t!==null&&(t.flags&128)!==0)for(t=e.child;t!==null;){if(u=Hi(t),u!==null){for(e.flags|=128,Cn(a,!1),t=u.updateQueue,e.updateQueue=t,Ji(e,t),e.subtreeFlags=0,t=l,l=e.child;l!==null;)yf(l,t),l=l.sibling;return L(qt,qt.current&1|2),st&&tl(e,a.treeForkCount),e.child}t=t.sibling}a.tail!==null&&ie()>Pi&&(e.flags|=128,n=!0,Cn(a,!1),e.lanes=4194304)}else{if(!n)if(t=Hi(u),t!==null){if(e.flags|=128,n=!0,t=t.updateQueue,e.updateQueue=t,Ji(e,t),Cn(a,!0),a.tail===null&&a.tailMode==="hidden"&&!u.alternate&&!st)return At(e),null}else 2*ie()-a.renderingStartTime>Pi&&l!==536870912&&(e.flags|=128,n=!0,Cn(a,!1),e.lanes=4194304);a.isBackwards?(u.sibling=e.child,e.child=u):(t=a.last,t!==null?t.sibling=u:e.child=u,a.last=u)}return a.tail!==null?(t=a.tail,a.rendering=t,a.tail=t.sibling,a.renderingStartTime=ie(),t.sibling=null,l=qt.current,L(qt,n?l&1|2:l&1),st&&tl(e,a.treeForkCount),t):(At(e),null);case 22:case 23:return je(e),Tc(),a=e.memoizedState!==null,t!==null?t.memoizedState!==null!==a&&(e.flags|=8192):a&&(e.flags|=8192),a?(l&536870912)!==0&&(e.flags&128)===0&&(At(e),e.subtreeFlags&6&&(e.flags|=8192)):At(e),l=e.updateQueue,l!==null&&Ji(e,l.retryQueue),l=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(l=t.memoizedState.cachePool.pool),a=null,e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),a!==l&&(e.flags|=2048),t!==null&&H(ea),null;case 24:return l=null,t!==null&&(l=t.memoizedState.cache),e.memoizedState.cache!==l&&(e.flags|=2048),ll(Bt),At(e),null;case 25:return null;case 30:return null}throw Error(f(156,e.tag))}function Yy(t,e){switch(rc(e),e.tag){case 1:return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return ll(Bt),_t(),t=e.flags,(t&65536)!==0&&(t&128)===0?(e.flags=t&-65537|128,e):null;case 26:case 27:case 5:return fa(e),null;case 31:if(e.memoizedState!==null){if(je(e),e.alternate===null)throw Error(f(340));Il()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 13:if(je(e),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(f(340));Il()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return H(qt),null;case 4:return _t(),null;case 10:return ll(e.type),null;case 22:case 23:return je(e),Tc(),t!==null&&H(ea),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 24:return ll(Bt),null;case 25:return null;default:return null}}function Xo(t,e){switch(rc(e),e.tag){case 3:ll(Bt),_t();break;case 26:case 27:case 5:fa(e);break;case 4:_t();break;case 31:e.memoizedState!==null&&je(e);break;case 13:je(e);break;case 19:H(qt);break;case 10:ll(e.type);break;case 22:case 23:je(e),Tc(),t!==null&&H(ea);break;case 24:ll(Bt)}}function zn(t,e){try{var l=e.updateQueue,a=l!==null?l.lastEffect:null;if(a!==null){var n=a.next;l=n;do{if((l.tag&t)===t){a=void 0;var u=l.create,s=l.inst;a=u(),s.destroy=a}l=l.next}while(l!==n)}}catch(h){St(e,e.return,h)}}function Ml(t,e,l){try{var a=e.updateQueue,n=a!==null?a.lastEffect:null;if(n!==null){var u=n.next;a=u;do{if((a.tag&t)===t){var s=a.inst,h=s.destroy;if(h!==void 0){s.destroy=void 0,n=e;var v=l,N=h;try{N()}catch(D){St(n,v,D)}}}a=a.next}while(a!==u)}}catch(D){St(e,e.return,D)}}function Ko(t){var e=t.updateQueue;if(e!==null){var l=t.stateNode;try{Rf(e,l)}catch(a){St(t,t.return,a)}}}function Zo(t,e,l){l.props=ua(t.type,t.memoizedProps),l.state=t.memoizedState;try{l.componentWillUnmount()}catch(a){St(t,e,a)}}function _n(t,e){try{var l=t.ref;if(l!==null){switch(t.tag){case 26:case 27:case 5:var a=t.stateNode;break;case 30:a=t.stateNode;break;default:a=t.stateNode}typeof l=="function"?t.refCleanup=l(a):l.current=a}}catch(n){St(t,e,n)}}function Ve(t,e){var l=t.ref,a=t.refCleanup;if(l!==null)if(typeof a=="function")try{a()}catch(n){St(t,e,n)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(n){St(t,e,n)}else l.current=null}function ko(t){var e=t.type,l=t.memoizedProps,a=t.stateNode;try{t:switch(e){case"button":case"input":case"select":case"textarea":l.autoFocus&&a.focus();break t;case"img":l.src?a.src=l.src:l.srcSet&&(a.srcset=l.srcSet)}}catch(n){St(t,t.return,n)}}function ls(t,e,l){try{var a=t.stateNode;rv(a,t.type,l,e),a[ce]=e}catch(n){St(t,t.return,n)}}function Vo(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&Ul(t.type)||t.tag===4}function as(t){t:for(;;){for(;t.sibling===null;){if(t.return===null||Vo(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&Ul(t.type)||t.flags&2||t.child===null||t.tag===4)continue t;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function ns(t,e,l){var a=t.tag;if(a===5||a===6)t=t.stateNode,e?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(t,e):(e=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,e.appendChild(t),l=l._reactRootContainer,l!=null||e.onclick!==null||(e.onclick=We));else if(a!==4&&(a===27&&Ul(t.type)&&(l=t.stateNode,e=null),t=t.child,t!==null))for(ns(t,e,l),t=t.sibling;t!==null;)ns(t,e,l),t=t.sibling}function Fi(t,e,l){var a=t.tag;if(a===5||a===6)t=t.stateNode,e?l.insertBefore(t,e):l.appendChild(t);else if(a!==4&&(a===27&&Ul(t.type)&&(l=t.stateNode),t=t.child,t!==null))for(Fi(t,e,l),t=t.sibling;t!==null;)Fi(t,e,l),t=t.sibling}function Jo(t){var e=t.stateNode,l=t.memoizedProps;try{for(var a=t.type,n=e.attributes;n.length;)e.removeAttributeNode(n[0]);Pt(e,a,l),e[Ft]=t,e[ce]=l}catch(u){St(t,t.return,u)}}var cl=!1,Gt=!1,is=!1,Fo=typeof WeakSet=="function"?WeakSet:Set,Jt=null;function Gy(t,e){if(t=t.containerInfo,Os=vu,t=uf(t),Iu(t)){if("selectionStart"in t)var l={start:t.selectionStart,end:t.selectionEnd};else t:{l=(l=t.ownerDocument)&&l.defaultView||window;var a=l.getSelection&&l.getSelection();if(a&&a.rangeCount!==0){l=a.anchorNode;var n=a.anchorOffset,u=a.focusNode;a=a.focusOffset;try{l.nodeType,u.nodeType}catch{l=null;break t}var s=0,h=-1,v=-1,N=0,D=0,U=t,O=null;e:for(;;){for(var C;U!==l||n!==0&&U.nodeType!==3||(h=s+n),U!==u||a!==0&&U.nodeType!==3||(v=s+a),U.nodeType===3&&(s+=U.nodeValue.length),(C=U.firstChild)!==null;)O=U,U=C;for(;;){if(U===t)break e;if(O===l&&++N===n&&(h=s),O===u&&++D===a&&(v=s),(C=U.nextSibling)!==null)break;U=O,O=U.parentNode}U=C}l=h===-1||v===-1?null:{start:h,end:v}}else l=null}l=l||{start:0,end:0}}else l=null;for(Ms={focusedElem:t,selectionRange:l},vu=!1,Jt=e;Jt!==null;)if(e=Jt,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,Jt=t;else for(;Jt!==null;){switch(e=Jt,u=e.alternate,t=e.flags,e.tag){case 0:if((t&4)!==0&&(t=e.updateQueue,t=t!==null?t.events:null,t!==null))for(l=0;l title"))),Pt(u,a,l),u[Ft]=t,Vt(u),a=u;break t;case"link":var s=eh("link","href",n).get(a+(l.href||""));if(s){for(var h=0;hEt&&(s=Et,Et=J,J=s);var j=af(h,J),b=af(h,Et);if(j&&b&&(C.rangeCount!==1||C.anchorNode!==j.node||C.anchorOffset!==j.offset||C.focusNode!==b.node||C.focusOffset!==b.offset)){var T=U.createRange();T.setStart(j.node,j.offset),C.removeAllRanges(),J>Et?(C.addRange(T),C.extend(b.node,b.offset)):(T.setEnd(b.node,b.offset),C.addRange(T))}}}}for(U=[],C=h;C=C.parentNode;)C.nodeType===1&&U.push({element:C,left:C.scrollLeft,top:C.scrollTop});for(typeof h.focus=="function"&&h.focus(),h=0;hl?32:l,_.T=null,l=ds,ds=null;var u=_l,s=dl;if(Xt=0,Ya=_l=null,dl=0,(vt&6)!==0)throw Error(f(331));var h=vt;if(vt|=4,ud(u.current),ad(u,u.current,s,l),vt=h,qn(0,!1),pe&&typeof pe.onPostCommitFiberRoot=="function")try{pe.onPostCommitFiberRoot(tn,u)}catch{}return!0}finally{B.p=n,_.T=a,Td(t,e)}}function Od(t,e,l){e=De(l,e),e=Zc(t.stateNode,e,2),t=Tl(t,e,2),t!==null&&(ln(t,2),Je(t))}function St(t,e,l){if(t.tag===3)Od(t,t,l);else for(;e!==null;){if(e.tag===3){Od(e,t,l);break}else if(e.tag===1){var a=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(zl===null||!zl.has(a))){t=De(l,t),l=Mo(2),a=Tl(e,l,2),a!==null&&(Ao(l,a,e,t),ln(a,2),Je(a));break}}e=e.return}}function vs(t,e,l){var a=t.pingCache;if(a===null){a=t.pingCache=new Zy;var n=new Set;a.set(e,n)}else n=a.get(e),n===void 0&&(n=new Set,a.set(e,n));n.has(l)||(ss=!0,n.add(l),t=$y.bind(null,t,e,l),e.then(t,t))}function $y(t,e,l){var a=t.pingCache;a!==null&&a.delete(e),t.pingedLanes|=t.suspendedLanes&l,t.warmLanes&=~l,Tt===t&&(ut&l)===l&&(wt===4||wt===3&&(ut&62914560)===ut&&300>ie()-Ii?(vt&2)===0&&Ga(t,0):rs|=l,La===ut&&(La=0)),Je(t)}function Md(t,e){e===0&&(e=br()),t=$l(t,e),t!==null&&(ln(t,e),Je(t))}function Wy(t){var e=t.memoizedState,l=0;e!==null&&(l=e.retryLane),Md(t,l)}function Iy(t,e){var l=0;switch(t.tag){case 31:case 13:var a=t.stateNode,n=t.memoizedState;n!==null&&(l=n.retryLane);break;case 19:a=t.stateNode;break;case 22:a=t.stateNode._retryCache;break;default:throw Error(f(314))}a!==null&&a.delete(e),Md(t,l)}function Py(t,e){return tt(t,e)}var iu=null,Ka=null,ps=!1,uu=!1,gs=!1,Rl=0;function Je(t){t!==Ka&&t.next===null&&(Ka===null?iu=Ka=t:Ka=Ka.next=t),uu=!0,ps||(ps=!0,ev())}function qn(t,e){if(!gs&&uu){gs=!0;do for(var l=!1,a=iu;a!==null;){if(t!==0){var n=a.pendingLanes;if(n===0)var u=0;else{var s=a.suspendedLanes,h=a.pingedLanes;u=(1<<31-ge(42|t)+1)-1,u&=n&~(s&~h),u=u&201326741?u&201326741|1:u?u|2:0}u!==0&&(l=!0,_d(a,u))}else u=ut,u=fi(a,a===Tt?u:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(u&3)===0||en(a,u)||(l=!0,_d(a,u));a=a.next}while(l);gs=!1}}function tv(){Ad()}function Ad(){uu=ps=!1;var t=0;Rl!==0&&ov()&&(t=Rl);for(var e=ie(),l=null,a=iu;a!==null;){var n=a.next,u=Cd(a,e);u===0?(a.next=null,l===null?iu=n:l.next=n,n===null&&(Ka=l)):(l=a,(t!==0||(u&3)!==0)&&(uu=!0)),a=n}Xt!==0&&Xt!==5||qn(t),Rl!==0&&(Rl=0)}function Cd(t,e){for(var l=t.suspendedLanes,a=t.pingedLanes,n=t.expirationTimes,u=t.pendingLanes&-62914561;0h)break;var D=v.transferSize,U=v.initiatorType;D&&Bd(U)&&(v=v.responseEnd,s+=D*(v"u"?null:document;function Wd(t,e,l){var a=Za;if(a&&typeof e=="string"&&e){var n=ze(e);n='link[rel="'+t+'"][href="'+n+'"]',typeof l=="string"&&(n+='[crossorigin="'+l+'"]'),$d.has(n)||($d.add(n),t={rel:t,crossOrigin:l,href:e},a.querySelector(n)===null&&(e=a.createElement("link"),Pt(e,"link",t),Vt(e),a.head.appendChild(e)))}}function Sv(t){hl.D(t),Wd("dns-prefetch",t,null)}function xv(t,e){hl.C(t,e),Wd("preconnect",t,e)}function jv(t,e,l){hl.L(t,e,l);var a=Za;if(a&&t&&e){var n='link[rel="preload"][as="'+ze(e)+'"]';e==="image"&&l&&l.imageSrcSet?(n+='[imagesrcset="'+ze(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(n+='[imagesizes="'+ze(l.imageSizes)+'"]')):n+='[href="'+ze(t)+'"]';var u=n;switch(e){case"style":u=ka(t);break;case"script":u=Va(t)}Qe.has(u)||(t=E({rel:"preload",href:e==="image"&&l&&l.imageSrcSet?void 0:t,as:e},l),Qe.set(u,t),a.querySelector(n)!==null||e==="style"&&a.querySelector(Yn(u))||e==="script"&&a.querySelector(Gn(u))||(e=a.createElement("link"),Pt(e,"link",t),Vt(e),a.head.appendChild(e)))}}function Ev(t,e){hl.m(t,e);var l=Za;if(l&&t){var a=e&&typeof e.as=="string"?e.as:"script",n='link[rel="modulepreload"][as="'+ze(a)+'"][href="'+ze(t)+'"]',u=n;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":u=Va(t)}if(!Qe.has(u)&&(t=E({rel:"modulepreload",href:t},e),Qe.set(u,t),l.querySelector(n)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Gn(u)))return}a=l.createElement("link"),Pt(a,"link",t),Vt(a),l.head.appendChild(a)}}}function Tv(t,e,l){hl.S(t,e,l);var a=Za;if(a&&t){var n=ma(a).hoistableStyles,u=ka(t);e=e||"default";var s=n.get(u);if(!s){var h={loading:0,preload:null};if(s=a.querySelector(Yn(u)))h.loading=5;else{t=E({rel:"stylesheet",href:t,"data-precedence":e},l),(l=Qe.get(u))&&Us(t,l);var v=s=a.createElement("link");Vt(v),Pt(v,"link",t),v._p=new Promise(function(N,D){v.onload=N,v.onerror=D}),v.addEventListener("load",function(){h.loading|=1}),v.addEventListener("error",function(){h.loading|=2}),h.loading|=4,ou(s,e,a)}s={type:"stylesheet",instance:s,count:1,state:h},n.set(u,s)}}}function Nv(t,e){hl.X(t,e);var l=Za;if(l&&t){var a=ma(l).hoistableScripts,n=Va(t),u=a.get(n);u||(u=l.querySelector(Gn(n)),u||(t=E({src:t,async:!0},e),(e=Qe.get(n))&&Hs(t,e),u=l.createElement("script"),Vt(u),Pt(u,"link",t),l.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},a.set(n,u))}}function Ov(t,e){hl.M(t,e);var l=Za;if(l&&t){var a=ma(l).hoistableScripts,n=Va(t),u=a.get(n);u||(u=l.querySelector(Gn(n)),u||(t=E({src:t,async:!0,type:"module"},e),(e=Qe.get(n))&&Hs(t,e),u=l.createElement("script"),Vt(u),Pt(u,"link",t),l.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},a.set(n,u))}}function Id(t,e,l,a){var n=(n=W.current)?fu(n):null;if(!n)throw Error(f(446));switch(t){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(e=ka(l.href),l=ma(n).hoistableStyles,a=l.get(e),a||(a={type:"style",instance:null,count:0,state:null},l.set(e,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){t=ka(l.href);var u=ma(n).hoistableStyles,s=u.get(t);if(s||(n=n.ownerDocument||n,s={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(t,s),(u=n.querySelector(Yn(t)))&&!u._p&&(s.instance=u,s.state.loading=5),Qe.has(t)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Qe.set(t,l),u||Mv(n,t,l,s.state))),e&&a===null)throw Error(f(528,""));return s}if(e&&a!==null)throw Error(f(529,""));return null;case"script":return e=l.async,l=l.src,typeof l=="string"&&e&&typeof e!="function"&&typeof e!="symbol"?(e=Va(l),l=ma(n).hoistableScripts,a=l.get(e),a||(a={type:"script",instance:null,count:0,state:null},l.set(e,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(f(444,t))}}function ka(t){return'href="'+ze(t)+'"'}function Yn(t){return'link[rel="stylesheet"]['+t+"]"}function Pd(t){return E({},t,{"data-precedence":t.precedence,precedence:null})}function Mv(t,e,l,a){t.querySelector('link[rel="preload"][as="style"]['+e+"]")?a.loading=1:(e=t.createElement("link"),a.preload=e,e.addEventListener("load",function(){return a.loading|=1}),e.addEventListener("error",function(){return a.loading|=2}),Pt(e,"link",l),Vt(e),t.head.appendChild(e))}function Va(t){return'[src="'+ze(t)+'"]'}function Gn(t){return"script[async]"+t}function th(t,e,l){if(e.count++,e.instance===null)switch(e.type){case"style":var a=t.querySelector('style[data-href~="'+ze(l.href)+'"]');if(a)return e.instance=a,Vt(a),a;var n=E({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return a=(t.ownerDocument||t).createElement("style"),Vt(a),Pt(a,"style",n),ou(a,l.precedence,t),e.instance=a;case"stylesheet":n=ka(l.href);var u=t.querySelector(Yn(n));if(u)return e.state.loading|=4,e.instance=u,Vt(u),u;a=Pd(l),(n=Qe.get(n))&&Us(a,n),u=(t.ownerDocument||t).createElement("link"),Vt(u);var s=u;return s._p=new Promise(function(h,v){s.onload=h,s.onerror=v}),Pt(u,"link",a),e.state.loading|=4,ou(u,l.precedence,t),e.instance=u;case"script":return u=Va(l.src),(n=t.querySelector(Gn(u)))?(e.instance=n,Vt(n),n):(a=l,(n=Qe.get(u))&&(a=E({},l),Hs(a,n)),t=t.ownerDocument||t,n=t.createElement("script"),Vt(n),Pt(n,"link",a),t.head.appendChild(n),e.instance=n);case"void":return null;default:throw Error(f(443,e.type))}else e.type==="stylesheet"&&(e.state.loading&4)===0&&(a=e.instance,e.state.loading|=4,ou(a,l.precedence,t));return e.instance}function ou(t,e,l){for(var a=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),n=a.length?a[a.length-1]:null,u=n,s=0;s title"):null)}function Av(t,e,l){if(l===1||e.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof e.precedence!="string"||typeof e.href!="string"||e.href==="")break;return!0;case"link":if(typeof e.rel!="string"||typeof e.href!="string"||e.href===""||e.onLoad||e.onError)break;return e.rel==="stylesheet"?(t=e.disabled,typeof e.precedence=="string"&&t==null):!0;case"script":if(e.async&&typeof e.async!="function"&&typeof e.async!="symbol"&&!e.onLoad&&!e.onError&&e.src&&typeof e.src=="string")return!0}return!1}function ah(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function Cv(t,e,l,a){if(l.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var n=ka(a.href),u=e.querySelector(Yn(n));if(u){e=u._p,e!==null&&typeof e=="object"&&typeof e.then=="function"&&(t.count++,t=hu.bind(t),e.then(t,t)),l.state.loading|=4,l.instance=u,Vt(u);return}u=e.ownerDocument||e,a=Pd(a),(n=Qe.get(n))&&Us(a,n),u=u.createElement("link"),Vt(u);var s=u;s._p=new Promise(function(h,v){s.onload=h,s.onerror=v}),Pt(u,"link",a),l.instance=u}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(l,e),(e=l.state.preload)&&(l.state.loading&3)===0&&(t.count++,l=hu.bind(t),e.addEventListener("load",l),e.addEventListener("error",l))}}var ws=0;function zv(t,e){return t.stylesheets&&t.count===0&&yu(t,t.stylesheets),0ws?50:800)+e);return t.unsuspend=l,function(){t.unsuspend=null,clearTimeout(a),clearTimeout(n)}}:null}function hu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)yu(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var mu=null;function yu(t,e){t.stylesheets=null,t.unsuspend!==null&&(t.count++,mu=new Map,e.forEach(_v,t),mu=null,hu.call(t))}function _v(t,e){if(!(e.state.loading&4)){var l=mu.get(t);if(l)var a=l.get(null);else{l=new Map,mu.set(t,l);for(var n=t.querySelectorAll("link[data-precedence],style[data-precedence]"),u=0;u"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(c){console.error(c)}}return i(),Zs.exports=Vv(),Zs.exports}var Fv=Jv(),ai=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(i){return this.listeners.add(i),this.onSubscribe(),()=>{this.listeners.delete(i),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},$v=class extends ai{#t;#e;#l;constructor(){super(),this.#l=i=>{if(typeof window<"u"&&window.addEventListener){const c=()=>i();return window.addEventListener("visibilitychange",c,!1),()=>{window.removeEventListener("visibilitychange",c)}}}}onSubscribe(){this.#e||this.setEventListener(this.#l)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(i){this.#l=i,this.#e?.(),this.#e=i(c=>{typeof c=="boolean"?this.setFocused(c):this.onFocus()})}setFocused(i){this.#t!==i&&(this.#t=i,this.onFocus())}onFocus(){const i=this.isFocused();this.listeners.forEach(c=>{c(i)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},sr=new $v,Wv={setTimeout:(i,c)=>setTimeout(i,c),clearTimeout:i=>clearTimeout(i),setInterval:(i,c)=>setInterval(i,c),clearInterval:i=>clearInterval(i)},Iv=class{#t=Wv;#e=!1;setTimeoutProvider(i){this.#t=i}setTimeout(i,c){return this.#t.setTimeout(i,c)}clearTimeout(i){this.#t.clearTimeout(i)}setInterval(i,c){return this.#t.setInterval(i,c)}clearInterval(i){this.#t.clearInterval(i)}},ra=new Iv;function Pv(i){setTimeout(i,0)}var t0=typeof window>"u"||"Deno"in globalThis;function me(){}function e0(i,c){return typeof i=="function"?i(c):i}function Is(i){return typeof i=="number"&&i>=0&&i!==1/0}function Jh(i,c){return Math.max(i+(c||0)-Date.now(),0)}function Yl(i,c){return typeof i=="function"?i(c):i}function Oe(i,c){return typeof i=="function"?i(c):i}function Mh(i,c){const{type:r="all",exact:f,fetchStatus:d,predicate:m,queryKey:g,stale:A}=i;if(g){if(f){if(c.queryHash!==rr(g,c.options))return!1}else if(!Wn(c.queryKey,g))return!1}if(r!=="all"){const p=c.isActive();if(r==="active"&&!p||r==="inactive"&&p)return!1}return!(typeof A=="boolean"&&c.isStale()!==A||d&&d!==c.state.fetchStatus||m&&!m(c))}function Ah(i,c){const{exact:r,status:f,predicate:d,mutationKey:m}=i;if(m){if(!c.options.mutationKey)return!1;if(r){if($n(c.options.mutationKey)!==$n(m))return!1}else if(!Wn(c.options.mutationKey,m))return!1}return!(f&&c.state.status!==f||d&&!d(c))}function rr(i,c){return(c?.queryKeyHashFn||$n)(i)}function $n(i){return JSON.stringify(i,(c,r)=>tr(r)?Object.keys(r).sort().reduce((f,d)=>(f[d]=r[d],f),{}):r)}function Wn(i,c){return i===c?!0:typeof i!=typeof c?!1:i&&c&&typeof i=="object"&&typeof c=="object"?Object.keys(c).every(r=>Wn(i[r],c[r])):!1}var l0=Object.prototype.hasOwnProperty;function Fh(i,c,r=0){if(i===c)return i;if(r>500)return c;const f=Ch(i)&&Ch(c);if(!f&&!(tr(i)&&tr(c)))return c;const m=(f?i:Object.keys(i)).length,g=f?c:Object.keys(c),A=g.length,p=f?new Array(A):{};let y=0;for(let M=0;M{ra.setTimeout(c,i)})}function er(i,c,r){return typeof r.structuralSharing=="function"?r.structuralSharing(i,c):r.structuralSharing!==!1?Fh(i,c):c}function n0(i,c,r=0){const f=[...i,c];return r&&f.length>r?f.slice(1):f}function i0(i,c,r=0){const f=[c,...i];return r&&f.length>r?f.slice(0,-1):f}var fr=Symbol();function $h(i,c){return!i.queryFn&&c?.initialPromise?()=>c.initialPromise:!i.queryFn||i.queryFn===fr?()=>Promise.reject(new Error(`Missing queryFn: '${i.queryHash}'`)):i.queryFn}function Wh(i,c){return typeof i=="function"?i(...c):!!i}function u0(i,c,r){let f=!1,d;return Object.defineProperty(i,"signal",{enumerable:!0,get:()=>(d??=c(),f||(f=!0,d.aborted?r():d.addEventListener("abort",r,{once:!0})),d)}),i}var In=(()=>{let i=()=>t0;return{isServer(){return i()},setIsServer(c){i=c}}})();function lr(){let i,c;const r=new Promise((d,m)=>{i=d,c=m});r.status="pending",r.catch(()=>{});function f(d){Object.assign(r,d),delete r.resolve,delete r.reject}return r.resolve=d=>{f({status:"fulfilled",value:d}),i(d)},r.reject=d=>{f({status:"rejected",reason:d}),c(d)},r}var c0=Pv;function s0(){let i=[],c=0,r=A=>{A()},f=A=>{A()},d=c0;const m=A=>{c?i.push(A):d(()=>{r(A)})},g=()=>{const A=i;i=[],A.length&&d(()=>{f(()=>{A.forEach(p=>{r(p)})})})};return{batch:A=>{let p;c++;try{p=A()}finally{c--,c||g()}return p},batchCalls:A=>(...p)=>{m(()=>{A(...p)})},schedule:m,setNotifyFunction:A=>{r=A},setBatchNotifyFunction:A=>{f=A},setScheduler:A=>{d=A}}}var te=s0(),r0=class extends ai{#t=!0;#e;#l;constructor(){super(),this.#l=i=>{if(typeof window<"u"&&window.addEventListener){const c=()=>i(!0),r=()=>i(!1);return window.addEventListener("online",c,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",c),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#e||this.setEventListener(this.#l)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(i){this.#l=i,this.#e?.(),this.#e=i(this.setOnline.bind(this))}setOnline(i){this.#t!==i&&(this.#t=i,this.listeners.forEach(r=>{r(i)}))}isOnline(){return this.#t}},Au=new r0;function f0(i){return Math.min(1e3*2**i,3e4)}function Ih(i){return(i??"online")==="online"?Au.isOnline():!0}var ar=class extends Error{constructor(i){super("CancelledError"),this.revert=i?.revert,this.silent=i?.silent}};function Ph(i){let c=!1,r=0,f;const d=lr(),m=()=>d.status!=="pending",g=q=>{if(!m()){const Y=new ar(q);x(Y),i.onCancel?.(Y)}},A=()=>{c=!0},p=()=>{c=!1},y=()=>sr.isFocused()&&(i.networkMode==="always"||Au.isOnline())&&i.canRun(),M=()=>Ih(i.networkMode)&&i.canRun(),E=q=>{m()||(f?.(),d.resolve(q))},x=q=>{m()||(f?.(),d.reject(q))},w=()=>new Promise(q=>{f=Y=>{(m()||y())&&q(Y)},i.onPause?.()}).then(()=>{f=void 0,m()||i.onContinue?.()}),z=()=>{if(m())return;let q;const Y=r===0?i.initialPromise:void 0;try{q=Y??i.fn()}catch(F){q=Promise.reject(F)}Promise.resolve(q).then(E).catch(F=>{if(m())return;const yt=i.retry??(In.isServer()?0:3),lt=i.retryDelay??f0,Ct=typeof lt=="function"?lt(r,F):lt,Rt=yt===!0||typeof yt=="number"&&ry()?void 0:w()).then(()=>{c?x(F):z()})})};return{promise:d,status:()=>d.status,cancel:g,continue:()=>(f?.(),d),cancelRetry:A,continueRetry:p,canStart:M,start:()=>(M()?z():w().then(z),d)}}var tm=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Is(this.gcTime)&&(this.#t=ra.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(i){this.gcTime=Math.max(this.gcTime||0,i??(In.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#t!==void 0&&(ra.clearTimeout(this.#t),this.#t=void 0)}};function o0(i){return{onFetch:(c,r)=>{const f=c.options,d=c.fetchOptions?.meta?.fetchMore?.direction,m=c.state.data?.pages||[],g=c.state.data?.pageParams||[];let A={pages:[],pageParams:[]},p=0;const y=async()=>{let M=!1;const E=z=>{u0(z,()=>c.signal,()=>M=!0)},x=$h(c.options,c.fetchOptions),w=async(z,q,Y)=>{if(M)return Promise.reject(c.signal.reason);if(q==null&&z.pages.length)return Promise.resolve(z);const yt=(()=>{const at={client:c.client,queryKey:c.queryKey,pageParam:q,direction:Y?"backward":"forward",meta:c.options.meta};return E(at),at})(),lt=await x(yt),{maxPages:Ct}=c.options,Rt=Y?i0:n0;return{pages:Rt(z.pages,lt,Ct),pageParams:Rt(z.pageParams,q,Ct)}};if(d&&m.length){const z=d==="backward",q=z?d0:_h,Y={pages:m,pageParams:g},F=q(f,Y);A=await w(Y,F,z)}else{const z=i??m.length;do{const q=p===0?g[0]??f.initialPageParam:_h(f,A);if(p>0&&q==null)break;A=await w(A,q),p++}while(pc.options.persister?.(y,{client:c.client,queryKey:c.queryKey,meta:c.options.meta,signal:c.signal},r):c.fetchFn=y}}}function _h(i,{pages:c,pageParams:r}){const f=c.length-1;return c.length>0?i.getNextPageParam(c[f],c,r[f],r):void 0}function d0(i,{pages:c,pageParams:r}){return c.length>0?i.getPreviousPageParam?.(c[0],c,r[0],r):void 0}var h0=class extends tm{#t;#e;#l;#a;#i;#n;#c;#u;constructor(i){super(),this.#u=!1,this.#c=i.defaultOptions,this.setOptions(i.options),this.observers=[],this.#i=i.client,this.#a=this.#i.getQueryCache(),this.queryKey=i.queryKey,this.queryHash=i.queryHash,this.#e=Rh(this.options),this.state=i.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#t}get promise(){return this.#n?.promise}setOptions(i){if(this.options={...this.#c,...i},i?._type&&(this.#t=i._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const c=Rh(this.options);c.data!==void 0&&(this.setState(Dh(c.data,c.dataUpdatedAt)),this.#e=c)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#a.remove(this)}setData(i,c){const r=er(this.state.data,i,this.options);return this.#s({data:r,type:"success",dataUpdatedAt:c?.updatedAt,manual:c?.manual}),r}setState(i){this.#s({type:"setState",state:i})}cancel(i){const c=this.#n?.promise;return this.#n?.cancel(i),c?c.then(me).catch(me):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(i=>Oe(i.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===fr||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(i=>Yl(i.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(i=>i.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(i=0){return this.state.data===void 0?!0:i==="static"?!1:this.state.isInvalidated?!0:!Jh(this.state.dataUpdatedAt,i)}onFocus(){this.observers.find(c=>c.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(c=>c.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(i){this.observers.includes(i)||(this.observers.push(i),this.clearGcTimeout(),this.#a.notify({type:"observerAdded",query:this,observer:i}))}removeObserver(i){this.observers.includes(i)&&(this.observers=this.observers.filter(c=>c!==i),this.observers.length||(this.#n&&(this.#u||this.#f()?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#a.notify({type:"observerRemoved",query:this,observer:i}))}getObserversCount(){return this.observers.length}#f(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#s({type:"invalidate"})}async fetch(i,c){if(this.state.fetchStatus!=="idle"&&this.#n?.status()!=="rejected"){if(this.state.data!==void 0&&c?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(i&&this.setOptions(i),!this.options.queryFn){const p=this.observers.find(y=>y.options.queryFn);p&&this.setOptions(p.options)}const r=new AbortController,f=p=>{Object.defineProperty(p,"signal",{enumerable:!0,get:()=>(this.#u=!0,r.signal)})},d=()=>{const p=$h(this.options,c),M=(()=>{const E={client:this.#i,queryKey:this.queryKey,meta:this.meta};return f(E),E})();return this.#u=!1,this.options.persister?this.options.persister(p,M,this):p(M)},g=(()=>{const p={fetchOptions:c,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:d};return f(p),p})();(this.#t==="infinite"?o0(this.options.pages):this.options.behavior)?.onFetch(g,this),this.#l=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==g.fetchOptions?.meta)&&this.#s({type:"fetch",meta:g.fetchOptions?.meta}),this.#n=Ph({initialPromise:c?.initialPromise,fn:g.fetchFn,onCancel:p=>{p instanceof ar&&p.revert&&this.setState({...this.#l,fetchStatus:"idle"}),r.abort()},onFail:(p,y)=>{this.#s({type:"failed",failureCount:p,error:y})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({type:"continue"})},retry:g.options.retry,retryDelay:g.options.retryDelay,networkMode:g.options.networkMode,canRun:()=>!0});try{const p=await this.#n.start();if(p===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(p),this.#a.config.onSuccess?.(p,this),this.#a.config.onSettled?.(p,this.state.error,this),p}catch(p){if(p instanceof ar){if(p.silent)return this.#n.promise;if(p.revert){if(this.state.data===void 0)throw p;return this.state.data}}throw this.#s({type:"error",error:p}),this.#a.config.onError?.(p,this),this.#a.config.onSettled?.(this.state.data,p,this),p}finally{this.scheduleGc()}}#s(i){const c=r=>{switch(i.type){case"failed":return{...r,fetchFailureCount:i.failureCount,fetchFailureReason:i.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...em(r.data,this.options),fetchMeta:i.meta??null};case"success":const f={...r,...Dh(i.data,i.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!i.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#l=i.manual?f:void 0,f;case"error":const d=i.error;return{...r,error:d,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:d,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...i.state}}};this.state=c(this.state),te.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#a.notify({query:this,type:"updated",action:i})})}};function em(i,c){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ih(c.networkMode)?"fetching":"paused",...i===void 0&&{error:null,status:"pending"}}}function Dh(i,c){return{data:i,dataUpdatedAt:c??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Rh(i){const c=typeof i.initialData=="function"?i.initialData():i.initialData,r=c!==void 0,f=r?typeof i.initialDataUpdatedAt=="function"?i.initialDataUpdatedAt():i.initialDataUpdatedAt:0;return{data:c,dataUpdateCount:0,dataUpdatedAt:r?f??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var m0=class extends ai{constructor(i,c){super(),this.options=c,this.#t=i,this.#u=null,this.#c=lr(),this.bindMethods(),this.setOptions(c)}#t;#e=void 0;#l=void 0;#a=void 0;#i;#n;#c;#u;#f;#s;#m;#o;#d;#r;#y=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),Uh(this.#e,this.options)?this.#h():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return nr(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return nr(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#S(),this.#x(),this.#e.removeObserver(this)}setOptions(i){const c=this.options,r=this.#e;if(this.options=this.#t.defaultQueryOptions(i),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Oe(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#j(),this.#e.setOptions(this.options),c._defaulted&&!Ps(this.options,c)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const f=this.hasListeners();f&&Hh(this.#e,r,this.options,c)&&this.#h(),this.updateResult(),f&&(this.#e!==r||Oe(this.options.enabled,this.#e)!==Oe(c.enabled,this.#e)||Yl(this.options.staleTime,this.#e)!==Yl(c.staleTime,this.#e))&&this.#v();const d=this.#p();f&&(this.#e!==r||Oe(this.options.enabled,this.#e)!==Oe(c.enabled,this.#e)||d!==this.#r)&&this.#g(d)}getOptimisticResult(i){const c=this.#t.getQueryCache().build(this.#t,i),r=this.createResult(c,i);return v0(this,r)&&(this.#a=r,this.#n=this.options,this.#i=this.#e.state),r}getCurrentResult(){return this.#a}trackResult(i,c){return new Proxy(i,{get:(r,f)=>(this.trackProp(f),c?.(f),f==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#c.status==="pending"&&this.#c.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,f))})}trackProp(i){this.#y.add(i)}getCurrentQuery(){return this.#e}refetch({...i}={}){return this.fetch({...i})}fetchOptimistic(i){const c=this.#t.defaultQueryOptions(i),r=this.#t.getQueryCache().build(this.#t,c);return r.fetch().then(()=>this.createResult(r,c))}fetch(i){return this.#h({...i,cancelRefetch:i.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#a))}#h(i){this.#j();let c=this.#e.fetch(this.options,i);return i?.throwOnError||(c=c.catch(me)),c}#v(){this.#S();const i=Yl(this.options.staleTime,this.#e);if(In.isServer()||this.#a.isStale||!Is(i))return;const r=Jh(this.#a.dataUpdatedAt,i)+1;this.#o=ra.setTimeout(()=>{this.#a.isStale||this.updateResult()},r)}#p(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#g(i){this.#x(),this.#r=i,!(In.isServer()||Oe(this.options.enabled,this.#e)===!1||!Is(this.#r)||this.#r===0)&&(this.#d=ra.setInterval(()=>{(this.options.refetchIntervalInBackground||sr.isFocused())&&this.#h()},this.#r))}#b(){this.#v(),this.#g(this.#p())}#S(){this.#o!==void 0&&(ra.clearTimeout(this.#o),this.#o=void 0)}#x(){this.#d!==void 0&&(ra.clearInterval(this.#d),this.#d=void 0)}createResult(i,c){const r=this.#e,f=this.options,d=this.#a,m=this.#i,g=this.#n,p=i!==r?i.state:this.#l,{state:y}=i;let M={...y},E=!1,x;if(c._optimisticResults){const pt=this.hasListeners(),Zt=!pt&&Uh(i,c),ee=pt&&Hh(i,r,c,f);(Zt||ee)&&(M={...M,...em(y.data,i.options)}),c._optimisticResults==="isRestoring"&&(M.fetchStatus="idle")}let{error:w,errorUpdatedAt:z,status:q}=M;x=M.data;let Y=!1;if(c.placeholderData!==void 0&&x===void 0&&q==="pending"){let pt;d?.isPlaceholderData&&c.placeholderData===g?.placeholderData?(pt=d.data,Y=!0):pt=typeof c.placeholderData=="function"?c.placeholderData(this.#m?.state.data,this.#m):c.placeholderData,pt!==void 0&&(q="success",x=er(d?.data,pt,c),E=!0)}if(c.select&&x!==void 0&&!Y)if(d&&x===m?.data&&c.select===this.#f)x=this.#s;else try{this.#f=c.select,x=c.select(x),x=er(d?.data,x,c),this.#s=x,this.#u=null}catch(pt){this.#u=pt}this.#u&&(w=this.#u,x=this.#s,z=Date.now(),q="error");const F=M.fetchStatus==="fetching",yt=q==="pending",lt=q==="error",Ct=yt&&F,Rt=x!==void 0,k={status:q,fetchStatus:M.fetchStatus,isPending:yt,isSuccess:q==="success",isError:lt,isInitialLoading:Ct,isLoading:Ct,data:x,dataUpdatedAt:M.dataUpdatedAt,error:w,errorUpdatedAt:z,failureCount:M.fetchFailureCount,failureReason:M.fetchFailureReason,errorUpdateCount:M.errorUpdateCount,isFetched:i.isFetched(),isFetchedAfterMount:M.dataUpdateCount>p.dataUpdateCount||M.errorUpdateCount>p.errorUpdateCount,isFetching:F,isRefetching:F&&!yt,isLoadingError:lt&&!Rt,isPaused:M.fetchStatus==="paused",isPlaceholderData:E,isRefetchError:lt&&Rt,isStale:or(i,c),refetch:this.refetch,promise:this.#c,isEnabled:Oe(c.enabled,i)!==!1};if(this.options.experimental_prefetchInRender){const pt=k.data!==void 0,Zt=k.status==="error"&&!pt,ee=ae=>{Zt?ae.reject(k.error):pt&&ae.resolve(k.data)},le=()=>{const ae=this.#c=k.promise=lr();ee(ae)},Ut=this.#c;switch(Ut.status){case"pending":i.queryHash===r.queryHash&&ee(Ut);break;case"fulfilled":(Zt||k.data!==Ut.value)&&le();break;case"rejected":(!Zt||k.error!==Ut.reason)&&le();break}}return k}updateResult(){const i=this.#a,c=this.createResult(this.#e,this.options);if(this.#i=this.#e.state,this.#n=this.options,this.#i.data!==void 0&&(this.#m=this.#e),Ps(c,i))return;this.#a=c;const r=()=>{if(!i)return!0;const{notifyOnChangeProps:f}=this.options,d=typeof f=="function"?f():f;if(d==="all"||!d&&!this.#y.size)return!0;const m=new Set(d??this.#y);return this.options.throwOnError&&m.add("error"),Object.keys(this.#a).some(g=>{const A=g;return this.#a[A]!==i[A]&&m.has(A)})};this.#E({listeners:r()})}#j(){const i=this.#t.getQueryCache().build(this.#t,this.options);if(i===this.#e)return;const c=this.#e;this.#e=i,this.#l=i.state,this.hasListeners()&&(c?.removeObserver(this),i.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#E(i){te.batch(()=>{i.listeners&&this.listeners.forEach(c=>{c(this.#a)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function y0(i,c){return Oe(c.enabled,i)!==!1&&i.state.data===void 0&&!(i.state.status==="error"&&Oe(c.retryOnMount,i)===!1)}function Uh(i,c){return y0(i,c)||i.state.data!==void 0&&nr(i,c,c.refetchOnMount)}function nr(i,c,r){if(Oe(c.enabled,i)!==!1&&Yl(c.staleTime,i)!=="static"){const f=typeof r=="function"?r(i):r;return f==="always"||f!==!1&&or(i,c)}return!1}function Hh(i,c,r,f){return(i!==c||Oe(f.enabled,i)===!1)&&(!r.suspense||i.state.status!=="error")&&or(i,r)}function or(i,c){return Oe(c.enabled,i)!==!1&&i.isStaleByTime(Yl(c.staleTime,i))}function v0(i,c){return!Ps(i.getCurrentResult(),c)}var p0=class extends tm{#t;#e;#l;#a;constructor(i){super(),this.#t=i.client,this.mutationId=i.mutationId,this.#l=i.mutationCache,this.#e=[],this.state=i.state||g0(),this.setOptions(i.options),this.scheduleGc()}setOptions(i){this.options=i,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(i){this.#e.includes(i)||(this.#e.push(i),this.clearGcTimeout(),this.#l.notify({type:"observerAdded",mutation:this,observer:i}))}removeObserver(i){this.#e=this.#e.filter(c=>c!==i),this.scheduleGc(),this.#l.notify({type:"observerRemoved",mutation:this,observer:i})}optionalRemove(){this.#e.length||(this.state.status==="pending"?this.scheduleGc():this.#l.remove(this))}continue(){return this.#a?.continue()??this.execute(this.state.variables)}async execute(i){const c=()=>{this.#i({type:"continue"})},r={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#a=Ph({fn:()=>this.options.mutationFn?this.options.mutationFn(i,r):Promise.reject(new Error("No mutationFn found")),onFail:(m,g)=>{this.#i({type:"failed",failureCount:m,error:g})},onPause:()=>{this.#i({type:"pause"})},onContinue:c,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#l.canRun(this)});const f=this.state.status==="pending",d=!this.#a.canStart();try{if(f)c();else{this.#i({type:"pending",variables:i,isPaused:d}),this.#l.config.onMutate&&await this.#l.config.onMutate(i,this,r);const g=await this.options.onMutate?.(i,r);g!==this.state.context&&this.#i({type:"pending",context:g,variables:i,isPaused:d})}const m=await this.#a.start();return await this.#l.config.onSuccess?.(m,i,this.state.context,this,r),await this.options.onSuccess?.(m,i,this.state.context,r),await this.#l.config.onSettled?.(m,null,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(m,null,i,this.state.context,r),this.#i({type:"success",data:m}),m}catch(m){try{await this.#l.config.onError?.(m,i,this.state.context,this,r)}catch(g){Promise.reject(g)}try{await this.options.onError?.(m,i,this.state.context,r)}catch(g){Promise.reject(g)}try{await this.#l.config.onSettled?.(void 0,m,this.state.variables,this.state.context,this,r)}catch(g){Promise.reject(g)}try{await this.options.onSettled?.(void 0,m,i,this.state.context,r)}catch(g){Promise.reject(g)}throw this.#i({type:"error",error:m}),m}finally{this.#l.runNext(this)}}#i(i){const c=r=>{switch(i.type){case"failed":return{...r,failureCount:i.failureCount,failureReason:i.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:i.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:i.isPaused,status:"pending",variables:i.variables,submittedAt:Date.now()};case"success":return{...r,data:i.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:i.error,failureCount:r.failureCount+1,failureReason:i.error,isPaused:!1,status:"error"}}};this.state=c(this.state),te.batch(()=>{this.#e.forEach(r=>{r.onMutationUpdate(i)}),this.#l.notify({mutation:this,type:"updated",action:i})})}};function g0(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var b0=class extends ai{constructor(i={}){super(),this.config=i,this.#t=new Set,this.#e=new Map,this.#l=0}#t;#e;#l;build(i,c,r){const f=new p0({client:i,mutationCache:this,mutationId:++this.#l,options:i.defaultMutationOptions(c),state:r});return this.add(f),f}add(i){this.#t.add(i);const c=Eu(i);if(typeof c=="string"){const r=this.#e.get(c);r?r.push(i):this.#e.set(c,[i])}this.notify({type:"added",mutation:i})}remove(i){if(this.#t.delete(i)){const c=Eu(i);if(typeof c=="string"){const r=this.#e.get(c);if(r)if(r.length>1){const f=r.indexOf(i);f!==-1&&r.splice(f,1)}else r[0]===i&&this.#e.delete(c)}}this.notify({type:"removed",mutation:i})}canRun(i){const c=Eu(i);if(typeof c=="string"){const f=this.#e.get(c)?.find(d=>d.state.status==="pending");return!f||f===i}else return!0}runNext(i){const c=Eu(i);return typeof c=="string"?this.#e.get(c)?.find(f=>f!==i&&f.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){te.batch(()=>{this.#t.forEach(i=>{this.notify({type:"removed",mutation:i})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(i){const c={exact:!0,...i};return this.getAll().find(r=>Ah(c,r))}findAll(i={}){return this.getAll().filter(c=>Ah(i,c))}notify(i){te.batch(()=>{this.listeners.forEach(c=>{c(i)})})}resumePausedMutations(){const i=this.getAll().filter(c=>c.state.isPaused);return te.batch(()=>Promise.all(i.map(c=>c.continue().catch(me))))}};function Eu(i){return i.options.scope?.id}var S0=class extends ai{constructor(i={}){super(),this.config=i,this.#t=new Map}#t;build(i,c,r){const f=c.queryKey,d=c.queryHash??rr(f,c);let m=this.get(d);return m||(m=new h0({client:i,queryKey:f,queryHash:d,options:i.defaultQueryOptions(c),state:r,defaultOptions:i.getQueryDefaults(f)}),this.add(m)),m}add(i){this.#t.has(i.queryHash)||(this.#t.set(i.queryHash,i),this.notify({type:"added",query:i}))}remove(i){const c=this.#t.get(i.queryHash);c&&(i.destroy(),c===i&&this.#t.delete(i.queryHash),this.notify({type:"removed",query:i}))}clear(){te.batch(()=>{this.getAll().forEach(i=>{this.remove(i)})})}get(i){return this.#t.get(i)}getAll(){return[...this.#t.values()]}find(i){const c={exact:!0,...i};return this.getAll().find(r=>Mh(c,r))}findAll(i={}){const c=this.getAll();return Object.keys(i).length>0?c.filter(r=>Mh(i,r)):c}notify(i){te.batch(()=>{this.listeners.forEach(c=>{c(i)})})}onFocus(){te.batch(()=>{this.getAll().forEach(i=>{i.onFocus()})})}onOnline(){te.batch(()=>{this.getAll().forEach(i=>{i.onOnline()})})}},x0=class{#t;#e;#l;#a;#i;#n;#c;#u;constructor(i={}){this.#t=i.queryCache||new S0,this.#e=i.mutationCache||new b0,this.#l=i.defaultOptions||{},this.#a=new Map,this.#i=new Map,this.#n=0}mount(){this.#n++,this.#n===1&&(this.#c=sr.subscribe(async i=>{i&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#u=Au.subscribe(async i=>{i&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#n--,this.#n===0&&(this.#c?.(),this.#c=void 0,this.#u?.(),this.#u=void 0)}isFetching(i){return this.#t.findAll({...i,fetchStatus:"fetching"}).length}isMutating(i){return this.#e.findAll({...i,status:"pending"}).length}getQueryData(i){const c=this.defaultQueryOptions({queryKey:i});return this.#t.get(c.queryHash)?.state.data}ensureQueryData(i){const c=this.defaultQueryOptions(i),r=this.#t.build(this,c),f=r.state.data;return f===void 0?this.fetchQuery(i):(i.revalidateIfStale&&r.isStaleByTime(Yl(c.staleTime,r))&&this.prefetchQuery(c),Promise.resolve(f))}getQueriesData(i){return this.#t.findAll(i).map(({queryKey:c,state:r})=>{const f=r.data;return[c,f]})}setQueryData(i,c,r){const f=this.defaultQueryOptions({queryKey:i}),m=this.#t.get(f.queryHash)?.state.data,g=e0(c,m);if(g!==void 0)return this.#t.build(this,f).setData(g,{...r,manual:!0})}setQueriesData(i,c,r){return te.batch(()=>this.#t.findAll(i).map(({queryKey:f})=>[f,this.setQueryData(f,c,r)]))}getQueryState(i){const c=this.defaultQueryOptions({queryKey:i});return this.#t.get(c.queryHash)?.state}removeQueries(i){const c=this.#t;te.batch(()=>{c.findAll(i).forEach(r=>{c.remove(r)})})}resetQueries(i,c){const r=this.#t;return te.batch(()=>(r.findAll(i).forEach(f=>{f.reset()}),this.refetchQueries({type:"active",...i},c)))}cancelQueries(i,c={}){const r={revert:!0,...c},f=te.batch(()=>this.#t.findAll(i).map(d=>d.cancel(r)));return Promise.all(f).then(me).catch(me)}invalidateQueries(i,c={}){return te.batch(()=>(this.#t.findAll(i).forEach(r=>{r.invalidate()}),i?.refetchType==="none"?Promise.resolve():this.refetchQueries({...i,type:i?.refetchType??i?.type??"active"},c)))}refetchQueries(i,c={}){const r={...c,cancelRefetch:c.cancelRefetch??!0},f=te.batch(()=>this.#t.findAll(i).filter(d=>!d.isDisabled()&&!d.isStatic()).map(d=>{let m=d.fetch(void 0,r);return r.throwOnError||(m=m.catch(me)),d.state.fetchStatus==="paused"?Promise.resolve():m}));return Promise.all(f).then(me)}fetchQuery(i){const c=this.defaultQueryOptions(i);c.retry===void 0&&(c.retry=!1);const r=this.#t.build(this,c);return r.isStaleByTime(Yl(c.staleTime,r))?r.fetch(c):Promise.resolve(r.state.data)}prefetchQuery(i){return this.fetchQuery(i).then(me).catch(me)}fetchInfiniteQuery(i){return i._type="infinite",this.fetchQuery(i)}prefetchInfiniteQuery(i){return this.fetchInfiniteQuery(i).then(me).catch(me)}ensureInfiniteQueryData(i){return i._type="infinite",this.ensureQueryData(i)}resumePausedMutations(){return Au.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#l}setDefaultOptions(i){this.#l=i}setQueryDefaults(i,c){this.#a.set($n(i),{queryKey:i,defaultOptions:c})}getQueryDefaults(i){const c=[...this.#a.values()],r={};return c.forEach(f=>{Wn(i,f.queryKey)&&Object.assign(r,f.defaultOptions)}),r}setMutationDefaults(i,c){this.#i.set($n(i),{mutationKey:i,defaultOptions:c})}getMutationDefaults(i){const c=[...this.#i.values()],r={};return c.forEach(f=>{Wn(i,f.mutationKey)&&Object.assign(r,f.defaultOptions)}),r}defaultQueryOptions(i){if(i._defaulted)return i;const c={...this.#l.queries,...this.getQueryDefaults(i.queryKey),...i,_defaulted:!0};return c.queryHash||(c.queryHash=rr(c.queryKey,c)),c.refetchOnReconnect===void 0&&(c.refetchOnReconnect=c.networkMode!=="always"),c.throwOnError===void 0&&(c.throwOnError=!!c.suspense),!c.networkMode&&c.persister&&(c.networkMode="offlineFirst"),c.queryFn===fr&&(c.enabled=!1),c}defaultMutationOptions(i){return i?._defaulted?i:{...this.#l.mutations,...i?.mutationKey&&this.getMutationDefaults(i.mutationKey),...i,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}},lm=Q.createContext(void 0),ni=i=>{const c=Q.useContext(lm);if(!c)throw new Error("No QueryClient set, use QueryClientProvider to set one");return c},j0=({client:i,children:c})=>(Q.useEffect(()=>(i.mount(),()=>{i.unmount()}),[i]),o.jsx(lm.Provider,{value:i,children:c})),am=Q.createContext(!1),E0=()=>Q.useContext(am);am.Provider;function T0(){let i=!1;return{clearReset:()=>{i=!1},reset:()=>{i=!0},isReset:()=>i}}var N0=Q.createContext(T0()),O0=()=>Q.useContext(N0),M0=(i,c,r)=>{const f=r?.state.error&&typeof i.throwOnError=="function"?Wh(i.throwOnError,[r.state.error,r]):i.throwOnError;(i.suspense||i.experimental_prefetchInRender||f)&&(c.isReset()||(i.retryOnMount=!1))},A0=i=>{Q.useEffect(()=>{i.clearReset()},[i])},C0=({result:i,errorResetBoundary:c,throwOnError:r,query:f,suspense:d})=>i.isError&&!c.isReset()&&!i.isFetching&&f&&(d&&i.data===void 0||Wh(r,[i.error,f])),z0=i=>{if(i.suspense){const r=d=>d==="static"?d:Math.max(d??1e3,1e3),f=i.staleTime;i.staleTime=typeof f=="function"?(...d)=>r(f(...d)):r(f),typeof i.gcTime=="number"&&(i.gcTime=Math.max(i.gcTime,1e3))}},_0=(i,c)=>i.isLoading&&i.isFetching&&!c,D0=(i,c)=>i?.suspense&&c.isPending,wh=(i,c,r)=>c.fetchOptimistic(i).catch(()=>{r.clearReset()});function R0(i,c,r){const f=E0(),d=O0(),m=ni(),g=m.defaultQueryOptions(i);m.getDefaultOptions().queries?._experimental_beforeQuery?.(g);const A=m.getQueryCache().get(g.queryHash),p=i.subscribed!==!1;g._optimisticResults=f?"isRestoring":p?"optimistic":void 0,z0(g),M0(g,d,A),A0(d);const y=!m.getQueryCache().get(g.queryHash),[M]=Q.useState(()=>new c(m,g)),E=M.getOptimisticResult(g),x=!f&&p;if(Q.useSyncExternalStore(Q.useCallback(w=>{const z=x?M.subscribe(te.batchCalls(w)):me;return M.updateResult(),z},[M,x]),()=>M.getCurrentResult(),()=>M.getCurrentResult()),Q.useEffect(()=>{M.setOptions(g)},[g,M]),D0(g,E))throw wh(g,M,d);if(C0({result:E,errorResetBoundary:d,throwOnError:g.throwOnError,query:A,suspense:g.suspense}))throw E.error;return m.getDefaultOptions().queries?._experimental_afterQuery?.(g,E),g.experimental_prefetchInRender&&!In.isServer()&&_0(E,f)&&(y?wh(g,M,d):A?.promise)?.catch(me).finally(()=>{M.updateResult()}),g.notifyOnChangeProps?E:M.trackResult(E)}function ve(i,c){return R0(i,m0)}function nm(){throw location.href="/auth/login?next="+encodeURIComponent(location.pathname+location.search),new Error("signing in…")}async function Me(i){const c=await fetch(i);if(c.status===401&&nm(),!c.ok)throw new Error(await c.text());return c.json()}async function Ll(i,c,r){const f={method:i};r!==void 0&&(f.headers={"Content-Type":"application/json"},f.body=JSON.stringify(r));const d=await fetch(c,f);if(!d.ok)throw new Error(await d.text());return d.status===204?{}:d.json()}async function Wa(i,c){const r=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c||{})});if(r.status===401&&nm(),!r.ok)throw new Error(await r.text());return r.json()}function U0(){return ve({queryKey:["config"],queryFn:async()=>{const i=await Me("/api/config");return i.auth.enabled&&!i.me&&(location.href="/auth/login?next="+encodeURIComponent(location.pathname+location.search),await new Promise(()=>{})),i},staleTime:1/0})}const ir=new Set;function H0(i){return ir.add(i),()=>ir.delete(i)}function w0(){for(const i of ir)i()}const im=(...i)=>i.filter((c,r,f)=>!!c&&c.trim()!==""&&f.indexOf(c)===r).join(" ").trim();const q0=i=>i.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const Q0=i=>i.replace(/^([A-Z])|[\s-_]+(\w)/g,(c,r,f)=>f?f.toUpperCase():r.toLowerCase());const qh=i=>{const c=Q0(i);return c.charAt(0).toUpperCase()+c.slice(1)};var Fs={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const B0=i=>{for(const c in i)if(c.startsWith("aria-")||c==="role"||c==="title")return!0;return!1},L0=Q.createContext({}),Y0=()=>Q.useContext(L0),G0=Q.forwardRef(({color:i,size:c,strokeWidth:r,absoluteStrokeWidth:f,className:d="",children:m,iconNode:g,...A},p)=>{const{size:y=24,strokeWidth:M=2,absoluteStrokeWidth:E=!1,color:x="currentColor",className:w=""}=Y0()??{},z=f??E?Number(r??M)*24/Number(c??y):r??M;return Q.createElement("svg",{ref:p,...Fs,width:c??y??Fs.width,height:c??y??Fs.height,stroke:i??x,strokeWidth:z,className:im("lucide",w,d),...!m&&!B0(A)&&{"aria-hidden":"true"},...A},[...g.map(([q,Y])=>Q.createElement(q,Y)),...Array.isArray(m)?m:[m]])});const Nt=(i,c)=>{const r=Q.forwardRef(({className:f,...d},m)=>Q.createElement(G0,{ref:m,iconNode:c,className:im(`lucide-${q0(qh(i))}`,`lucide-${i}`,f),...d}));return r.displayName=qh(i),r};const X0=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],K0=Nt("check",X0);const Z0=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],k0=Nt("chevron-down",Z0);const V0=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],J0=Nt("chevron-right",V0);const F0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],$0=Nt("clock",F0);const W0=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],I0=Nt("copy",W0);const P0=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],tp=Nt("download",P0);const ep=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],lp=Nt("ellipsis",ep);const ap=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],np=Nt("file-text",ap);const ip=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],up=Nt("folder",ip);const cp=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],sp=Nt("globe",cp);const rp=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],fp=Nt("history",rp);const op=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],dp=Nt("layout-dashboard",op);const hp=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],mp=Nt("link",hp);const yp=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],vp=Nt("lock",yp);const pp=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],gp=Nt("log-out",pp);const bp=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],Sp=Nt("menu",bp);const xp=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],jp=Nt("plus",xp);const Ep=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Tp=Nt("search",Ep);const Np=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Op=Nt("settings",Np);const Mp=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],Ap=Nt("share-2",Mp);const Cp=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],zp=Nt("shield",Cp);const _p=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],Dp=Nt("square-terminal",_p);const Rp=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Up=Nt("trash-2",Rp);const Hp=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],wp=Nt("triangle-alert",Hp);const qp=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Qp=Nt("upload",qp);const Bp=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],Lp=Nt("users",Bp);const Yp=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Gp=Nt("x",Yp);function Xp(){document.body.classList.toggle("sb-open")}function Ke(){document.body.classList.remove("sb-open")}const Kp={alert:wp,check:K0,chev:J0,chevd:k0,clock:$0,copy:I0,doc:np,dots:lp,download:tp,folder:up,dashboard:dp,gear:Op,globe:sp,hist:fp,link:mp,lock:vp,menu:Sp,plus:jp,power:gp,search:Tp,share:Ap,shield:zp,terminal:Dp,trash:Up,upload:Qp,users:Lp,x:Gp};function Kt({name:i}){const c=Kp[i];return c?o.jsx(c,{className:"ico","aria-hidden":"true"}):null}function Pn(i){return o.jsxs(o.Fragment,{children:[o.jsx("div",{id:"sb-backdrop",onClick:Ke}),o.jsxs("aside",{id:"sidebar",children:[i.vault,i.projectsNav,i.tree??o.jsx("nav",{id:"tree","aria-label":"Files"}),i.orgBar]}),o.jsxs("main",{id:"main",children:[i.topbar,o.jsx("article",{id:"content",className:i.contentClass??"markdown",ref:i.contentRef,onScroll:i.onContentScroll,children:i.children})]})]})}function Cu(i){const{name:c,onHome:r,showSignout:f,search:d}=i;return o.jsxs("header",{id:"vault",children:[o.jsx("span",{id:"vault-badge","aria-hidden":"true",children:"🐻"}),o.jsx("span",{id:"vault-name",className:r?"vault-link":void 0,onClick:r,role:r?"button":void 0,tabIndex:r?0:void 0,onKeyDown:m=>{r&&(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),r())},children:c}),o.jsxs("div",{className:"vault-actions",children:[d&&o.jsxs("button",{id:"search-btn",className:"icon-btn2 has-tip","aria-label":"Search",onClick:()=>{w0(),Ke()},children:[o.jsx(Kt,{name:"search"}),o.jsxs("span",{className:"tip",role:"tooltip",children:["Search ",o.jsx("kbd",{children:"⌘K"})]})]}),f&&o.jsx("a",{id:"signout",href:"/auth/logout",title:"Sign out","aria-label":"Sign out",children:o.jsx(Kt,{name:"power"})})]})]})}function ti(i){return o.jsxs("header",{id:"topbar",children:[o.jsx("button",{id:"menu-btn",className:"icon-btn",title:"Menu","aria-label":"Menu",onClick:Xp,children:o.jsx(Kt,{name:"menu"})}),o.jsx("span",{id:"crumb",children:i.crumb}),o.jsx("span",{id:"meta",children:i.meta}),i.actions]})}let dr={msg:"",err:!1,shown:!1},Nu=[],Qh;function Bh(i){dr=i,Nu.forEach(c=>c())}function rt(i,c=!1){Bh({msg:i,err:c,shown:!0}),clearTimeout(Qh),Qh=setTimeout(()=>Bh({...dr,shown:!1}),3200)}function Zp(){const i=Q.useSyncExternalStore(c=>(Nu.push(c),()=>{Nu=Nu.filter(r=>r!==c)}),()=>dr);return o.jsx("div",{id:"toast",className:i.shown?"show"+(i.err?" err":""):"",children:i.msg})}let um=null,Ou=[];function hr(i){um=i,Ou.forEach(c=>c())}function cm(i,c,r="",f="OK"){return new Promise(d=>hr({kind:"prompt",title:i,label:c,value:r,okLabel:f,resolve:d}))}function Tu(i,c,r="Confirm",f=!1){return new Promise(d=>hr({kind:"confirm",title:i,message:c,confirmLabel:r,danger:f,resolve:d}))}function kp(){const i=Q.useSyncExternalStore(c=>(Ou.push(c),()=>{Ou=Ou.filter(r=>r!==c)}),()=>um);return i?i.kind==="prompt"?o.jsx(Vp,{m:i}):o.jsx(Jp,{m:i}):null}function sm(){hr(null)}function Vp({m:i}){const c=Q.useRef(null),r=d=>{sm(),i.resolve(d)},f=()=>r(c.current.value.trim()||null);return Q.useEffect(()=>{c.current.focus(),c.current.select();const d=m=>{m.key==="Escape"&&r(null),m.key==="Enter"&&f()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[]),o.jsx("div",{className:"modal-back",onClick:d=>d.target===d.currentTarget&&r(null),children:o.jsxs("div",{className:"modal",children:[o.jsx("h3",{children:i.title}),o.jsx("label",{className:"modal-label",children:i.label}),o.jsx("input",{className:"modal-input",type:"text",autoComplete:"off",defaultValue:i.value,ref:c}),o.jsxs("div",{className:"modal-actions",children:[o.jsx("button",{className:"ai-btn",onClick:()=>r(null),children:"Cancel"}),o.jsx("button",{className:"pbtn",onClick:f,children:i.okLabel})]})]})})}function Jp({m:i}){const c=Q.useRef(null),r=f=>{sm(),i.resolve(f)};return Q.useEffect(()=>{c.current.focus();const f=d=>{d.key==="Escape"&&r(!1),d.key==="Enter"&&r(!0)};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[]),o.jsx("div",{className:"modal-back",onClick:f=>f.target===f.currentTarget&&r(!1),children:o.jsxs("div",{className:"modal",children:[o.jsx("h3",{children:i.title}),o.jsx("p",{className:"modal-msg",children:i.message}),o.jsxs("div",{className:"modal-actions",children:[o.jsx("button",{className:"ai-btn",onClick:()=>r(!1),children:"Cancel"}),o.jsx("button",{className:i.danger?"danger-btn":"pbtn",onClick:()=>r(!0),ref:c,children:i.confirmLabel})]})]})})}function Fp(i){return ve({queryKey:["projects"],queryFn:()=>Me("/api/projects"),enabled:i,refetchInterval:3e4,select:c=>c.projects||[]})}function $p(i){return ve({queryKey:["orgs"],queryFn:()=>Me("/api/orgs"),enabled:i,select:c=>c.orgs||[]})}function rm(i){return ve({queryKey:["admin","pending"],queryFn:()=>Me("/api/admin/pending"),enabled:i,select:c=>c.pending||[]})}function fm(){const i=ni();return()=>Promise.all([i.invalidateQueries({queryKey:["projects"]}),i.invalidateQueries({queryKey:["orgs"]})]).then(()=>{})}function om(i){return i.split("/").map(encodeURIComponent).join("/")}function Lh(i){return i.split("/").map(decodeURIComponent).join("/")}const Wp=new Set(["insights","history","install","settings"]);function dm(i,c){const r=i.replace(/^\/+/,"");if(c!=="hub")return{path:r?Lh(r):""};const f=r.indexOf("/");if(f===-1)return{project:r,path:""};const d={project:r.slice(0,f),path:Lh(r.slice(f+1))},m=d.path.indexOf("/"),g=m===-1?d.path:d.path.slice(0,m);return Wp.has(g)&&(d.view=g,d.viewTarget=m===-1?"":d.path.slice(m+1).replace(/\/+$/,""),d.path=""),d}function Ip(i,c){const r=om(i);return c?"/"+c+(r?"/"+r:""):"/"+r}function $a(i,c,r){let f=(c?"/"+c:"")+"/"+i;return r&&(f+="/"+om(r.replace(/\/+$/,""))),f}let mr="POP";const ur=new Set;function hm(){for(const i of ur)i()}window.addEventListener("popstate",()=>{mr="POP",hm()});function ye(i,c){const r=location.pathname+location.search;!c?.replace&&r===i||(history[c?.replace?"replaceState":"pushState"](null,"",i),mr=c?.replace?"REPLACE":"PUSH",hm())}function yr(){return Q.useSyncExternalStore(i=>(ur.add(i),()=>{ur.delete(i)}),()=>location.pathname)}function Pp(){return mr}function tg({to:i}){return Q.useEffect(()=>{ye(i,{replace:!0})},[i]),null}const eg=/\.(md|markdown)$/i,lg=/\.(png|jpe?g|gif|svg|webp|ico|bmp|avif)$/i,ag=/\.html?$/i,ng=/\.(txt|log|json|ya?ml|toml|csv|go|py|js|ts|jsx|tsx|sh|bash|zsh|rb|rs|c|h|cpp|java|kt|swift|sql|css|xml|ini|conf|env|mod|sum|jsonl)$/i;function mm(i){if(i<1024)return i+" B";const c=["KB","MB","GB","TB"];let r=-1;do i/=1024,r++;while(i>=1024&&rd.invalidateQueries({queryKey:["orgs"]}),y=()=>d.invalidateQueries({queryKey:["invites",i.id]}),M=()=>d.invalidateQueries({queryKey:["orgShares",i.id]}),{data:E}=ve({queryKey:["invites",i.id],queryFn:()=>Me(`/api/orgs/${i.id}/invites`),enabled:m,select:z=>z.invites||[]}),{data:x}=ve({queryKey:["orgShares",i.id],queryFn:()=>Me(`/api/orgs/${i.id}/shares`),enabled:m,select:z=>z.shares||[]}),w=c.filter(z=>z.org===i.id);return o.jsxs("div",{className:"admin",children:[o.jsx("h1",{id:"org-title",children:i.name+(m?"":" · member")}),m&&o.jsxs("div",{className:"admin-row",children:[o.jsx("input",{id:"org-rename",type:"text",value:g,onChange:z=>A(z.target.value)}),o.jsx("button",{className:"pbtn",id:"org-rename-btn",onClick:async()=>{try{await Ll("PATCH","/api/orgs/"+i.id,{name:g.trim()}),rt("Renamed."),p()}catch(z){rt(z.message,!0)}},children:"Rename org"})]}),o.jsx("h3",{children:"Members"}),o.jsx("div",{className:"admin-list",children:i.members.map(z=>{const q=!!r&&z.email.toLowerCase()===r.toLowerCase();return o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main",children:z.email+(q?" (you)":"")}),m&&!q?o.jsxs(o.Fragment,{children:[o.jsxs("select",{value:z.role,onChange:async Y=>{try{await Ll("PATCH",`/api/orgs/${i.id}/members/${encodeURIComponent(z.email)}`,{role:Y.target.value}),rt("Role updated.")}catch(F){rt(F.message,!0)}p()},children:[o.jsx("option",{value:"owner",children:"owner"}),o.jsx("option",{value:"member",children:"member"})]}),o.jsx("button",{className:"ai-del",onClick:async()=>{if(await Tu("Remove member",`Remove ${z.email} from ${i.name}?`,"Remove",!0))try{await Ll("DELETE",`/api/orgs/${i.id}/members/${encodeURIComponent(z.email)}`),rt("Removed."),p()}catch(Y){rt(Y.message,!0)}},children:"Remove"})]}):o.jsx("span",{className:"ai-tag",children:z.role})]},z.email)})}),m&&o.jsxs(o.Fragment,{children:[o.jsx("h3",{children:"Projects"}),o.jsxs("div",{className:"admin-list",children:[w.length===0&&o.jsx("div",{className:"admin-empty",children:"No projects yet."}),w.map(z=>o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main",children:z.name}),o.jsx("button",{className:"ai-btn",onClick:async()=>{const q=await cm("Rename project","New name",z.name,"Rename");if(!(!q||q===z.name))try{await Ll("PATCH","/api/projects/"+z.id,{name:q}),rt("Renamed."),await f()}catch(Y){rt(Y.message,!0)}},children:"Rename"}),o.jsx("button",{className:"ai-del",onClick:async()=>{if(await Tu("Delete project",`Delete “${z.name}”? Its files stay in storage, but it's removed from the hub.`,"Delete",!0))try{await Ll("DELETE","/api/projects/"+z.id),rt(`Deleted “${z.name}”.`),await f()}catch(q){rt(q.message,!0)}},children:"Delete"})]},z.id))]}),o.jsxs("div",{className:"admin-h",children:[o.jsx("h3",{children:"Invite links"}),o.jsx("button",{className:"pbtn",onClick:async()=>{try{const z=await Wa(`/api/orgs/${i.id}/invites`),q=await ei(z.url);rt(q?"Invite link copied to clipboard.":"Invite created — copy it from the list below."),y()}catch(z){rt(z.message,!0)}},children:"New invite"})]}),o.jsxs("div",{className:"admin-list",children:[E&&E.length===0&&o.jsx("div",{className:"admin-empty",children:"No active invite links."}),(E||[]).map(z=>o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main mono",style:{cursor:"pointer"},title:"Copy",onClick:()=>ei(z.url).then(q=>rt(q?"Copied.":"Select and copy the link.")),children:z.url}),o.jsx("span",{className:"ai-tag",children:(z.creator?"by "+z.creator+" · ":"")+(z.uses?z.uses+" joined · ":"unused · ")+"expires "+new Date(z.expires).toLocaleDateString()}),o.jsx("button",{className:"ai-del",onClick:async()=>{if(await Tu("Revoke invite","Revoke this invite link? Anyone still holding it won't be able to join.","Revoke",!0))try{await Ll("DELETE",`/api/orgs/${i.id}/invites/${z.token}`),rt("Revoked."),y()}catch(q){rt(q.message,!0)}},children:"Revoke"})]},z.token))]}),o.jsx("h3",{children:"Public share links"}),o.jsxs("div",{className:"admin-list",children:[x&&x.length===0&&o.jsx("div",{className:"admin-empty",children:"No public shares."}),(x||[]).map(z=>o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main mono",style:{cursor:"pointer"},title:z.url,onClick:()=>window.open(z.url,"_blank"),children:z.path}),o.jsx("span",{className:"ai-tag",children:(z.project_name||"")+(z.creator?" · by "+z.creator:"")+(z.created?" · "+new Date(z.created).toLocaleDateString():"")}),o.jsx("button",{className:"ai-del",onClick:async()=>{if(await Tu("Revoke share link",`Revoke the public link to “${z.path}”? Anyone with the URL will lose access.`,"Revoke",!0))try{await Ll("DELETE","/api/shares/"+z.token),rt("Share revoked."),M()}catch(q){rt(q.message,!0)}},children:"Revoke"})]},z.token))]})]})]})}function ug(){const i=ni(),{data:c,error:r}=ve({queryKey:["admin","policy"],queryFn:()=>Me("/api/admin/policy")}),{data:f}=rm(!0),[d,m]=Q.useState(!1),[g,A]=Q.useState(!1);if(Q.useEffect(()=>{c&&(m(c.require_verification&&c.mailer),A(c.require_approval))},[c]),Q.useEffect(()=>{r&&rt(r.message,!0)},[r]),!c)return null;const p=async(y,M,E)=>{try{await Wa(`/api/admin/pending/${y}/${M}`),rt((M==="approve"?"Approved ":"Denied ")+E),i.invalidateQueries({queryKey:["admin","pending"]})}catch(x){rt(x.message,!0)}};return o.jsxs("div",{className:"admin",children:[o.jsx("h1",{children:"Signup & access"}),o.jsx("p",{className:"admin-sub",children:"Who can create an account on this hub, and how new accounts are vetted."}),o.jsx("h3",{children:"New-account vetting"}),o.jsxs("div",{className:"admin-list",children:[o.jsx(Yh,{label:"Require email verification",desc:c.mailer?"New accounts must click an emailed link before they can sign in — proves they control the address.":"Configure SMTP on the server (auth.smtp) to enable email verification.",checked:d,disabled:!c.mailer,onChange:m}),o.jsx(Yh,{label:"Require admin approval",desc:"New accounts wait for a hub admin to approve them before they gain access.",checked:g,onChange:A})]}),o.jsx("button",{className:"pbtn",style:{marginTop:14},onClick:async()=>{try{await Wa("/api/admin/policy",{require_verification:d,require_approval:g}),rt("Signup policy saved."),i.invalidateQueries({queryKey:["admin","policy"]})}catch(y){rt(y.message,!0)}},children:"Save policy"}),o.jsx("h3",{children:"Who can sign up"}),o.jsxs("div",{className:"admin-list",children:[o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main",children:"Allowed email domains"}),o.jsx("span",{className:"ai-tag",children:c.allowed_domains&&c.allowed_domains.length?c.allowed_domains.map(y=>"@"+y).join(", "):"any"})]}),o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main",children:"Self-signup"}),o.jsx("span",{className:"ai-tag",children:c.allow_signup?"open":"invite-only"})]}),o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main",children:"Hub admins"}),o.jsx("span",{className:"ai-tag",children:c.admins&&c.admins.length?c.admins.join(", "):"none"})]})]}),o.jsx("p",{className:"admin-sub",children:"Domains and admins are set in the server config file (they can't be widened from the browser)."}),o.jsx("h3",{children:"Pending signups"}),o.jsxs("div",{className:"admin-list",children:[(!f||f.length===0)&&o.jsx("div",{className:"admin-empty",children:"No one is waiting for approval."}),(f||[]).map(y=>o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main",children:(y.name?y.name+" · ":"")+y.email}),o.jsx("button",{className:"pbtn",onClick:()=>p(y.id,"approve",y.email),children:"Approve"}),o.jsx("button",{className:"ai-del",onClick:()=>p(y.id,"deny",y.email),children:"Deny"})]},y.id))]})]})}function Yh({label:i,desc:c,checked:r,disabled:f,onChange:d}){return o.jsxs("label",{className:"admin-item toggle",style:f?{opacity:.55}:void 0,children:[o.jsxs("span",{className:"ai-main",children:[o.jsx("div",{className:"tg-label",children:i}),o.jsx("div",{className:"tg-desc",children:c})]}),o.jsx("input",{type:"checkbox",checked:r,disabled:f,onChange:m=>d(m.target.checked)})]})}const Gh=["#5b8def","#f5a623","#4cc38a","#e0679b","#8b7bf0","#3ec8c8","#e6934a"];function vm(i){let c=0;for(const r of i)c=c*31+r.charCodeAt(0)>>>0;return Gh[c%Gh.length]}function Xh({projects:i,currentId:c,menu:r}){const f=fm(),d=async()=>{const m=await cm("New project","Project name","","Create");if(m)try{const g=await Wa("/api/projects",{name:m});await f(),ye("/"+g.project.id),rt(`Created “${g.project.name}”.`)}catch(g){rt("Could not create the project: "+g.message,!0)}};return o.jsxs("nav",{id:"projects","aria-label":"Projects",children:[o.jsxs("div",{className:"nav-head",children:[o.jsx("span",{children:"Projects"}),o.jsx("button",{className:"nav-add",title:"New project",onClick:d,children:"+"})]}),o.jsx("div",{className:"proj-row",children:o.jsxs("span",{className:"proj-select-wrap",children:[c&&o.jsx("span",{className:"proj-mark","aria-hidden":"true",style:{background:vm(i.find(m=>m.id===c)?.name||"")}}),o.jsxs("select",{id:"project-select","aria-label":"Switch project",value:c||"",onChange:m=>{m.target.value&&(ye("/"+m.target.value),Ke())},children:[!c&&o.jsx("option",{value:"",disabled:!0}),i.map(m=>o.jsx("option",{value:m.id,children:m.name},m.id))]}),o.jsx(Kt,{name:"chevd"})]})}),r&&o.jsx("ul",{className:"nav-menu","aria-label":"Project pages",children:[["dashboard","Dashboard","dashboard",r.onDashboard],["install","Installation","terminal",r.onInstall],["history","History","hist",r.onHistory],["settings","Settings","gear",r.onSettings]].map(([m,g,A,p])=>o.jsx("li",{children:o.jsxs("div",{id:"nav-"+m,className:"row"+(r.active===m?" active":""),role:"button",tabIndex:0,onClick:p,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),p())},children:[o.jsx(Kt,{name:A}),o.jsx("span",{className:"label",children:g})]})},m))})]})}function cg({me:i,org:c,admin:r,onOrgSettings:f}){const[d,m]=Q.useState(!1),g=Q.useRef(null);Q.useEffect(()=>{if(!d)return;const p=M=>{g.current&&!g.current.contains(M.target)&&m(!1)},y=M=>{M.key==="Escape"&&m(!1)};return document.addEventListener("mousedown",p),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",y)}},[d]);const A=i.name||i.email;return o.jsxs("footer",{id:"accountbar",ref:g,children:[d&&o.jsxs("div",{id:"account-menu",role:"menu","aria-label":"Account menu",children:[c&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"menu-sec",children:"Organization"}),o.jsxs("button",{id:"menu-org-settings",role:"menuitem",onClick:()=>{m(!1),f(c)},children:[o.jsx(Kt,{name:"gear"}),o.jsxs("span",{children:[o.jsx("b",{children:c.name})," Settings"]})]})]}),r&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"menu-sec",children:"Hub"}),o.jsxs("button",{id:"menu-hub-admin",role:"menuitem",onClick:()=>{m(!1),r.onClick()},children:[o.jsx(Kt,{name:"shield"}),o.jsxs("span",{children:["Signup & access",r.pending?` · ${r.pending}`:""]})]})]}),o.jsx("div",{className:"menu-sec",children:"Account"}),o.jsxs("a",{id:"signout",role:"menuitem",href:"/auth/logout",children:[o.jsx(Kt,{name:"power"}),o.jsx("span",{children:"Log out"})]})]}),o.jsxs("button",{id:"account-btn","aria-haspopup":"menu","aria-expanded":d,onClick:()=>m(p=>!p),children:[o.jsx("span",{className:"avatar",style:{background:vm(i.email)},"aria-hidden":"true",children:(A.trim()[0]||"?").toUpperCase()}),o.jsxs("span",{className:"acct",children:[o.jsx("b",{children:A}),i.name&&o.jsx("small",{children:i.email})]}),o.jsx(Kt,{name:"chev"})]})]})}function sg({project:i,org:c}){return o.jsxs("div",{className:"project-settings",children:[o.jsx("h2",{children:i.name}),o.jsxs("dl",{className:"ps-facts",children:[o.jsx("dt",{children:"Project id"}),o.jsx("dd",{children:o.jsx("code",{children:i.id})}),c&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"Workspace"}),o.jsx("dd",{children:c.name})]}),i.created&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"Created"}),o.jsx("dd",{children:new Date(i.created).toLocaleDateString()})]})]})]})}const $s=[{key:"claude",label:"Claude Code & Cowork"},{key:"hermes",label:"Hermes",hook:"hermes",note:"Registers BearDrive's hooks in Hermes's config: pull before every turn, push after edits with a session note, and report file reads to Insights."},{key:"codex",label:"Codex",hook:"codex",note:"Registers hooks in .codex/hooks.json.",extra:"Run /hooks inside Codex once to trust the project's .codex layer — after that every turn pulls, edits push automatically, and reads are reported to Insights."}];function rg(i,c){const r=window.location.origin,f=c.id;if(i.key==="claude")return[{title:"Add the BearDrive plugin",desc:"One time, in any Claude Code session. The plugin ships the beardrive skill, the /beardrive commands, and turn-boundary sync hooks — and Claude Cowork shares the same plugins, so installing it once covers both.",code:`/plugin marketplace add runbear-io/beardrive +/plugin install beardrive@beardrive`},{title:"Set up this project conversationally",desc:"In a Claude Code or Cowork session in the folder where you want the files, run:",code:"/beardrive:install connect to "+r+", project "+f,extra:"Claude installs the CLI, signs this machine in, mounts the project, and registers the sync hooks — pull the latest before every turn, push after edits (stamped with the session that made them), and report file reads to Insights. It asks before anything it changes."}];const d=(c.name||"project").toLowerCase().replace(/[^a-z0-9._-]+/g,"-")||"project";return[{title:"Install the BearDrive CLI",desc:"One static binary. Homebrew on macOS and Linux; releases and `go install` also work.",code:"brew install runbear-io/tap/beardrive"},{title:"Sign in to this hub",desc:"Opens the browser once and stores a device token on this machine — the synced folder itself never holds credentials.",code:"bdrive login "+r},{title:"Mount the project into a local folder",desc:"Run it where you want the files. An existing folder works too — contents merge, and re-running init later (or after moving the folder) just resumes.",code:"mkdir -p ~/"+d+" && cd ~/"+d+` +bdrive init --project `+f},{title:"Connect "+i.label,desc:i.note,code:"bdrive hooks install --agent "+i.hook,extra:i.extra}]}function fg(){try{return localStorage.getItem("bdrive-guide-agent")||"claude"}catch{return"claude"}}function pm({project:i}){const[c,r]=Q.useState(fg),f=$s.find(d=>d.key===c)||$s[0];return o.jsxs("div",{className:"guide",children:[o.jsx("h1",{className:"in-title",children:i.name}),o.jsx("p",{className:"dl-sub",children:"Mount this project as a folder on any machine and connect your coding agent: files sync both ways in the background, every change is journaled with who made it, and agent reads feed Insights."}),o.jsx("div",{className:"gd-tabs",children:$s.map(d=>o.jsx("button",{className:"gd-tab"+(d.key===f.key?" active":""),"data-key":d.key,onClick:()=>{r(d.key);try{localStorage.setItem("bdrive-guide-agent",d.key)}catch{}},children:d.label},d.key))}),o.jsxs("div",{className:"gd-body",children:[rg(f,i).map((d,m)=>o.jsxs("div",{className:"gd-step",children:[o.jsxs("div",{className:"gd-step-head",children:[o.jsx("span",{className:"gd-num",children:m+1}),o.jsx("span",{className:"gd-step-title",children:d.title})]}),d.desc&&o.jsx("p",{className:"gd-desc",children:d.desc}),d.code&&o.jsx(og,{code:d.code}),d.extra&&o.jsx("p",{className:"gd-desc gd-extra",children:d.extra})]},m)),o.jsx("p",{className:"gd-done",children:"That's it — the folder now syncs on its own. Every agent turn starts from the latest state, edits appear here (and on every teammate's mount) within seconds, and what your agents read shows up in Insights."})]})]})}function og({code:i}){const[c,r]=Q.useState("Copy");return o.jsxs("pre",{className:"gd-code",children:[o.jsx("code",{children:i}),o.jsx("button",{className:"gd-copy",onClick:async()=>{r(await ei(i)?"Copied":"Copy failed"),setTimeout(()=>r("Copy"),1400)},children:c})]})}function dg({authEnabled:i,onCreate:c}){const r=Q.useRef(null),f=Q.useRef(null),d=()=>{const m=r.current.value.trim(),g=m.match(/join\/([0-9a-f]+)/)||m.match(/^([0-9a-f]{8,})$/);if(!g){rt("That doesn't look like an invite link.",!0);return}location.href="/join/"+g[1]};return o.jsxs("div",{className:"onboard",children:[o.jsx("h1",{children:"Welcome to BearDrive"}),o.jsx("p",{children:"You're signed in, but you're not part of any project yet."}),i&&o.jsxs("div",{className:"ob-card",children:[o.jsx("h3",{children:"Have an invite link?"}),o.jsx("p",{children:"A teammate can send you a join link. Paste it here:"}),o.jsxs("div",{className:"ob-row",children:[o.jsx("input",{id:"ob-invite",type:"text",placeholder:"https://…/join/…",autoComplete:"off",ref:r}),o.jsx("button",{id:"ob-join",className:"pbtn",onClick:d,children:"Join"})]})]}),o.jsxs("div",{className:"ob-card",children:[o.jsx("h3",{children:"Or start a new project"}),o.jsx("p",{children:"Create a shared space for your team's files."}),o.jsxs("div",{className:"ob-row",children:[o.jsx("input",{id:"ob-name",type:"text",placeholder:"Project name, e.g. wiki",autoComplete:"off",ref:f}),o.jsx("button",{id:"ob-create",className:"pbtn",onClick:()=>c(f.current.value.trim()),children:"Create"})]})]})]})}function hg(i,c=!0){const r=ve({queryKey:["tree",i],queryFn:()=>Me(i+"tree"),enabled:c,refetchInterval:15e3}),f=Q.useMemo(()=>{const d=[],m=new Map,g=A=>{for(const p of A.children||[])p.dir?(m.set(p.path,p),g(p)):d.push(p)};return r.data&&g(r.data),{flatFiles:d,dirIndex:m}},[r.data]);return{tree:r.data,...f,loaded:!!r.data}}function mg(i,c){return ve({queryKey:["heat",i],queryFn:()=>Me(i+"heat?days=30"),enabled:c,staleTime:6e4,refetchInterval:6e4}).data?.entries??null}function yg(i,c,r){return ve({queryKey:["history",i,"prefix",c,20],queryFn:()=>Me(i+"history?prefix="+encodeURIComponent(c)+"&n=20"),enabled:r,staleTime:15e3}).data?.entries??null}function Kh(i,c,r){if(!i)return null;if(!r)return i[c]||null;const f={human:0,agent:0,share:0};for(const[d,m]of Object.entries(i))d.startsWith(c+"/")&&(f.human+=m.human||0,f.agent+=m.agent||0,f.share+=m.share||0);return f.human||f.agent||f.share?f:null}function li(i){return(i.human||0)+(i.agent||0)+(i.share||0)}function Mu(i){const c=li(i);if(!c)return"";let r=c+(c===1?" read":" reads");return i.agent&&(r+=" ("+i.agent+" agent)"),r}function vg(i){const c=li(i);return c?c<3?1:c<10?2:c<30?3:4:0}function pg(i){return o.jsx("nav",{id:"tree","aria-label":"Files",children:i.root&&o.jsx(gm,{nodes:i.root.children||[],...i})})}function gm({nodes:i,...c}){return o.jsx("ul",{children:i.map(r=>o.jsx(gg,{node:r,...c},r.path))})}function gg({node:i,...c}){const{expanded:r,onToggle:f,currentPath:d,listingShowing:m,onOpen:g}=c,A=i.dir?r.has(i.path):!1,p=()=>{if(i.dir&&d===i.path&&m){f(i.path);return}g(i.path),i.dir||Ke()};return o.jsxs("li",{className:(i.dir?"dir":"file")+(i.dir&&!A?" collapsed":""),children:[o.jsxs("div",{className:"row"+(d===i.path?" active":""),"data-path":i.path,tabIndex:0,role:"button",title:i.name,"aria-expanded":i.dir?A:void 0,onClick:p,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),p())},children:[o.jsx("span",{className:"chev",onClick:y=>{i.dir&&(y.stopPropagation(),f(i.path))},children:o.jsx(Kt,{name:"chevd"})}),o.jsx("span",{className:"ticon",children:o.jsx(Kt,{name:i.dir?"folder":"doc"})}),o.jsx("span",{className:"label",children:i.name})]}),i.dir&&o.jsx(gm,{nodes:i.children||[],...c})]})}function bg(i){const c=i.split("/"),r=[];let f="";for(let d=0;d{f=f?f+"/"+d:d;const g=f,A=m===r.length-1;return o.jsxs("span",{children:[m>0&&o.jsx("span",{className:"crumb-sep",children:"/"}),A?o.jsx("span",{children:d}):o.jsx("span",{className:"crumb-seg",title:g,onClick:()=>c(g),children:d})]},g)})})}const xg={add:"plus",edit:"edit",delete:"x"},jg={add:"added",edit:"edited",delete:"deleted"};function bm({entry:i,onOpen:c}){const[r,f]=Q.useState(!1),d=i.kind==="put"?"edit":i.kind,m=i.user_name?`${i.user_name} <${i.user}>`:i.user||i.author||"unknown",g=[i.device.name||i.device.id,i.device.os,i.device.ip].filter(Boolean).join(" · "),A=d!=="delete",p=y=>{y.target.tagName!=="A"&&A&&c(i.path)};return o.jsxs("div",{className:"hentry "+d+(A?" clickable":""),tabIndex:A?0:void 0,role:A?"button":void 0,onClick:p,onKeyDown:y=>{A&&(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),c(i.path))},children:[o.jsxs("div",{className:"hline",children:[o.jsx("span",{className:"hkind",children:o.jsx(Kt,{name:xg[d]||"dot"})}),o.jsx("span",{className:"hpath",children:i.path}),o.jsx("span",{className:"htag",children:jg[d]||d}),o.jsx("span",{className:"htime",children:new Date(i.time).toLocaleString()})]}),o.jsxs("div",{className:"hmeta",children:[o.jsx("span",{className:"hwho",children:m}),o.jsx("span",{className:"hdev",children:g}),o.jsx("span",{className:"hsize",children:i.size?mm(i.size):""})]}),i.note&&o.jsx("div",{className:"hnote"+(r?" open":""),tabIndex:0,role:"button",title:r?"Collapse note":"Show full note","aria-expanded":r,onClick:y=>{y.stopPropagation(),y.target.tagName!=="A"&&f(!r)},onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),y.stopPropagation(),f(!r))},children:i.note.split(/(https?:\/\/\S+)/).map((y,M)=>/^https?:\/\//.test(y)?o.jsx("a",{href:y,target:"_blank",rel:"noopener",children:y},M):y)})]})}function Eg(i){const{node:c,heatMap:r,onOpen:f}=i,d=(c.children||[]).slice().sort((y,M)=>Number(M.dir||!1)-Number(y.dir||!1)||y.name.localeCompare(M.name)),m=d.filter(y=>y.dir).length,g=d.length-m,A=[];m&&A.push(m+(m===1?" folder":" folders")),g&&A.push(g+(g===1?" file":" files"));const p=Kh(r,c.path,!0);return p&&A.push(Mu(p)+" in 30 days"),o.jsxs("div",{className:"dirlist",children:[o.jsxs("h1",{className:"dl-title",children:[o.jsx("span",{className:"dl-title-icon",children:o.jsx(Kt,{name:"folder"})}),o.jsx("span",{children:c.name})]}),o.jsx("p",{className:"dl-sub",children:A.join(" · ")||"Empty folder"}),d.length===0?o.jsx("div",{className:"dl-empty",children:"Nothing in this folder yet."}):o.jsx("div",{className:"dl-items",children:d.map(y=>{let M="";if(y.dir){const x=(y.children||[]).length;M=x+(x===1?" item":" items")}else M=[y.size?mm(y.size):"",y.time?new Date(y.time).toLocaleDateString():""].filter(Boolean).join(" · ");const E=Kh(r,y.path,!!y.dir);return E&&(M=Mu(E)+(M?" · "+M:"")),o.jsxs("div",{className:"dl-row",tabIndex:0,role:"button",title:y.path,onClick:()=>f(y.path),onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),f(y.path))},children:[o.jsx("span",{className:"ticon",children:o.jsx(Kt,{name:y.dir?"folder":"doc"})}),o.jsx("span",{className:"dl-name",children:y.name}),E&&o.jsx("span",{className:"heatdot lvl"+vg(E),title:Mu(E)+" in 30 days"}),o.jsx("span",{className:"dl-meta",children:M})]},y.path)})}),i.hub&&o.jsx(Tg,{apiBase:i.apiBase,prefix:c.path+"/",onOpen:f,onFullHistory:()=>i.onFullHistory(c.path+"/"),onRendered:i.onRendered})]})}function Tg(i){const c=yg(i.apiBase,i.prefix,!0),{onRendered:r}=i;return Q.useEffect(()=>{c&&c.length&&r&&r()},[c,r]),!c||c.length===0?null:o.jsxs("div",{className:"dl-history",children:[o.jsx("h3",{className:"dl-h3",children:"Recent changes"}),o.jsx("div",{className:"history dl-hlist",children:c.map((f,d)=>o.jsx(bm,{entry:f,onOpen:i.onOpen},d))}),o.jsx("button",{className:"ai-btn dl-more",onClick:i.onFullHistory,children:"Full history"})]})}function Ng(i){const{apiBase:c,path:r,onMeta:f}=i,d=c+"file?path="+encodeURIComponent(r);return Q.useEffect(()=>()=>f(""),[r,f]),eg.test(r)?o.jsx(Og,{...i}):ag.test(r)?o.jsx("iframe",{className:"htmlview",sandbox:"allow-scripts",src:d,title:r,onLoad:i.onRendered}):lg.test(r)?o.jsx(Cg,{src:d,alt:r,onRendered:i.onRendered}):ng.test(r)?o.jsx(zg,{...i,fileURL:d}):o.jsxs("div",{className:"filecard",children:[o.jsx("div",{className:"name",children:r.split("/").pop()}),o.jsx("p",{children:"No preview for this file type."}),o.jsx("a",{className:"btn",download:!0,href:c+"download?path="+encodeURIComponent(r),children:"Download"})]})}function Og(i){const{apiBase:c,path:r,heatMap:f,flatFiles:d,onOpenFile:m,onMeta:g,onRendered:A}=i,{data:p,error:y}=ve({queryKey:["render",c,r],queryFn:()=>Me(c+"render?path="+encodeURIComponent(r))}),M=Q.useMemo(()=>p?Ag(p.html,r,c):"",[p,r,c]);return Q.useEffect(()=>{if(!p)return;const E=[];p.author&&E.push(p.author+(p.device?" on "+p.device:"")),p.time&&E.push(new Date(p.time).toLocaleString());const x=f&&f[p.path];x&&li(x)&&E.push(Mu(x)+" / 30d"),g(E.join(" · ")),A?.()},[p,f,g,A]),y?o.jsxs("div",{className:"empty",children:["Could not load file: ",y.message]}):p?o.jsx("div",{dangerouslySetInnerHTML:{__html:M},onClick:E=>Mg(E,r,d,m)}):null}function Mg(i,c,r,f){const d=i.target.closest("a");if(!d||!i.currentTarget.contains(d))return;const m=d.getAttribute("href")||"",g=c.includes("/")?c.slice(0,c.lastIndexOf("/")):"";m.startsWith("wiki:")?(i.preventDefault(),_g(decodeURIComponent(m.slice(5)),r,f)):/^([a-z]+:|\/|#)/i.test(m)||(i.preventDefault(),f(ym(g,decodeURIComponent(m))))}function Ag(i,c,r){const f=c.includes("/")?c.slice(0,c.lastIndexOf("/")):"",d=g=>r+"file?path="+encodeURIComponent(g),m=new DOMParser().parseFromString(i,"text/html");for(const g of m.querySelectorAll("img")){const A=g.getAttribute("src")||"";/^([a-z]+:|\/)/i.test(A)||g.setAttribute("src",d(ym(f,A)))}for(const g of m.querySelectorAll("a")){const A=g.getAttribute("href")||"";/^https?:/i.test(A)&&(g.setAttribute("target","_blank"),g.setAttribute("rel","noopener"))}return m.body.innerHTML}function Cg({src:i,alt:c,onRendered:r}){return o.jsx("img",{src:i,alt:c,onLoad:r})}function zg(i){const{path:c,fileURL:r,onRendered:f}=i,{data:d,error:m}=ve({queryKey:["text",r],queryFn:async()=>{const g=await fetch(r);if(!g.ok)throw new Error(await g.text());return g.text()}});return Q.useEffect(()=>{d!=null&&f?.()},[d,f]),m?o.jsxs("div",{className:"empty",children:["Could not load file: ",m.message]}):d==null?null:o.jsx("pre",{className:"plain",children:d},c)}function _g(i,c,r){const f=i.toLowerCase(),d=c.find(m=>m.path.toLowerCase()===f||m.path.toLowerCase()===f+".md")||c.find(m=>{const g=m.name.toLowerCase();return g===f||g===f+".md"});d&&r(d.path)}function Dg({url:i,copied:c,onClose:r}){const f=i.split("/s/")[1];return Q.useEffect(()=>{const d=m=>{m.key==="Escape"&&r()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[r]),o.jsx("div",{className:"modal-back",onClick:d=>d.target===d.currentTarget&&r(),children:o.jsxs("div",{className:"modal",children:[o.jsx("h3",{children:"Public link created"}),o.jsxs("p",{children:[o.jsx("b",{children:"Anyone with this link can view this file"})," — no account needed. It always shows the latest version until you revoke it."]}),o.jsx("div",{className:"modal-url",children:i}),o.jsxs("div",{className:"modal-actions",children:[o.jsx("button",{className:"pbtn",onClick:()=>ei(i).then(d=>rt(d?"Copied.":"Select and copy the link above.")),children:c?"Copied ✓":"Copy link"}),o.jsx("button",{className:"ai-btn",onClick:()=>window.open(i,"_blank"),children:"Open"}),o.jsx("button",{className:"ai-del",onClick:async()=>{try{await Ll("DELETE","/api/shares/"+f),rt("Link revoked — it no longer works."),r()}catch(d){rt(d.message,!0)}},children:"Revoke"}),o.jsx("button",{className:"ai-btn",onClick:r,children:"Done"})]})]})})}function Zh(i,c){if(!i)return{score:0,hits:[]};const r=i.toLowerCase(),f=c.toLowerCase();let d=0,m=0,g=0;const A=[];for(let p=0;p3&&f.endsWith("ies")?d=f.slice(0,-3)+"y":f.length>3&&f.endsWith("es")?d=f.slice(0,-2):f.length>2&&f.endsWith("s")&&(d=f.slice(0,-1)),d?Zh(d,c):null}function Ug({text:i,hits:c}){const r=[];let f=0;return c.forEach((d,m)=>{d>f&&r.push(i.slice(f,d)),r.push(o.jsx("b",{children:i[d]},m)),f=d+1}),r.push(i.slice(f)),o.jsx("span",{className:"plabel",children:r})}function Hg({open:i,onClose:c,candidates:r}){const[f,d]=Q.useState(""),[m,g]=Q.useState(0),A=Q.useRef(null),p=Q.useRef(null),y=Q.useMemo(()=>{if(!i)return[];const E=[];for(const x of r()){const w=Rg(f,x.label);w&&E.push({...x,score:w.score,hits:w.hits})}return E.sort((x,w)=>w.score-x.score),E.slice(0,40)},[i,f,r]);Q.useEffect(()=>{i&&(d(""),g(0),A.current?.focus())},[i]),Q.useEffect(()=>g(0),[f]),Q.useEffect(()=>{p.current?.children[m]?.scrollIntoView({block:"nearest"})},[m,y]);const M=E=>{c(),E.run()};return Q.useEffect(()=>{if(!i)return;const E=x=>{if(x.key==="Escape")x.preventDefault(),c();else if(x.key==="ArrowDown"||x.key==="ArrowUp"){x.preventDefault();const w=y.length;w&&g(z=>(z+(x.key==="ArrowDown"?1:w-1))%w)}else x.key==="Enter"&&(x.preventDefault(),y[m]&&M(y[m]))};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[i,y,m]),i?o.jsx("div",{id:"palette-overlay",onClick:E=>E.target===E.currentTarget&&c(),children:o.jsxs("div",{id:"palette",role:"dialog","aria-label":"Search and quick actions",children:[o.jsxs("div",{id:"palette-inputwrap",children:[o.jsx(Kt,{name:"search"}),o.jsx("input",{id:"palette-input",type:"text",placeholder:"Search file names, projects, actions…",autoComplete:"off",spellCheck:!1,ref:A,value:f,onChange:E=>d(E.target.value)})]}),o.jsx("ul",{id:"palette-results",ref:p,children:y.length===0?o.jsx("li",{className:"pempty",children:"No matches — search covers file names, projects, and actions"}):y.map((E,x)=>o.jsxs("li",{className:x===m?"selected":void 0,onClick:()=>M(E),onMouseMove:()=>m!==x&&g(x),children:[o.jsx("span",{className:"picon",children:o.jsx(Kt,{name:E.icon})}),o.jsx(Ug,{text:E.label,hits:E.hits}),o.jsx("span",{className:"pkind",children:E.kind})]},E.kind+":"+E.label))}),o.jsx("footer",{id:"palette-hint",children:"↑↓ navigate · ⏎ select · esc close"})]})}):null}const Fn=3,Fa=30;function wg(i,c){return ve({queryKey:["heatDevices",i],queryFn:()=>Me(i+"heat?by=device&days=30"),enabled:c,retry:!1,staleTime:6e4}).data?.devices??null}function kh(i){const[c,r]=Q.useState("all"),{flatFiles:f,heatMap:d,devices:m,scope:g}=i,A=x=>!g||x===g||x.startsWith(g+"/"),p=g?f.filter(x=>A(x.path)):f,y=m&&g?m.map(x=>{const w={};for(const[z,q]of Object.entries(x.folders||{}))A(z)&&(w[z]=q);return{...x,folders:w}}).filter(x=>Object.keys(x.folders).length>0):m,M=Date.now(),E=p.map(x=>{const w=d&&d[x.path]||{},z=x.time?Math.max(0,(M-new Date(x.time).getTime())/864e5):0,q=c==="all"?li(w):w[c]||0;return{path:x.path,reads:q,agent:w.agent||0,total:li(w),days:z,danger:q>=Fn&&z>=Fa}});return o.jsxs("div",{className:"insights",children:[o.jsxs("h1",{className:"in-title",children:["Knowledge insights",g?o.jsxs("span",{className:"in-scope",children:[" · ",g]}):null]}),o.jsx("p",{className:"dl-sub",children:g?`Reads over the last 30 days × freshness, for ${g} and everything in it.`:"Reads over the last 30 days × how long since each file changed. Hot but stale knowledge — read a lot, maintained by nobody — is the danger zone."}),o.jsx("div",{className:"in-lens",children:["all","human","agent"].map(x=>o.jsx("button",{className:"in-lens-btn"+(x===c?" active":""),onClick:()=>r(x),children:x==="all"?"All reads":x==="human"?"Human reads":"Agent reads"},x))}),o.jsx("h3",{className:"dl-h3",children:"Map — cell size = reads, color = freshness"}),o.jsx(Qg,{pts:E,onOpenFile:i.onOpenFile,onOpenFolder:i.onOpenFolder,isFolder:i.isFolder}),o.jsx("h3",{className:"dl-h3",children:"Reads × freshness"}),o.jsx(Bg,{pts:E,onOpenFile:i.onOpenFile}),o.jsx("h3",{className:"dl-h3",children:"Hot path — top files by reads"}),o.jsx(Lg,{pts:E,lens:c,onOpenFile:i.onOpenFile}),y&&y.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("h3",{className:"dl-h3",children:"Agent coverage — which agents read which areas"}),o.jsx(Yg,{devices:y})]})]})}function qg(i){const c=[[76,195,138],[232,196,84],[224,93,93]],r=Math.min(1,Math.max(0,i/300))*(c.length-1),f=Math.min(c.length-2,Math.floor(r)),d=r-f,m=c[f].map((g,A)=>Math.round(g+(c[f+1][A]-g)*d));return`rgb(${m[0]},${m[1]},${m[2]})`}function Vh(i,c,r,f,d){const m=i.reduce((y,M)=>y+M.value,0);if(!m||f<=0||d<=0)return[];const g=i.slice().sort((y,M)=>M.value-y.value).map(y=>({it:y,a:y.value/m*f*d})),A=(y,M)=>{const x=y.reduce((z,q)=>z+q.a,0)/M;let w=0;for(const z of y){const q=z.a/x;w=Math.max(w,q/x,x/q)}return w},p=[];for(;g.length;){const y=f>=d,M=y?d:f,E=[g.shift()];for(;g.length&&A(E.concat(g[0]),M)<=A(E,M);)E.push(g.shift());const x=E.reduce((z,q)=>z+q.a,0)/M;let w=0;for(const z of E){const q=z.a/x;y?p.push({item:z.it,x:c,y:r+w,w:x,h:q}):p.push({item:z.it,x:c+w,y:r,w:q,h:x}),w+=q}y?(c+=x,f-=x):(r+=x,d-=x)}return p}const Ws=15;function Qg({pts:i,onOpenFile:c,onOpenFolder:r,isFolder:f}){const g=new Map;for(const p of i){const y=p.path.includes("/")?p.path.split("/")[0]:"/";let M=g.get(y);M||g.set(y,M={name:y,files:[],value:0}),M.files.push(p),M.value+=p.reads+1}const A=[];for(const p of Vh([...g.values()],0,0,720,480)){const y=p.item,M=y.name==="/"?"":y.name;if(A.push(o.jsx("rect",{x:p.x+1,y:p.y+1,width:Math.max(0,p.w-2),height:Math.max(0,p.h-2),rx:3,className:"in-tm-group","data-dir":M},"g"+y.name)),p.w>46&&p.h>Ws+10){let x=y.name==="/"?"(root)":y.name;const w=Math.floor((p.w-8)/6);x.length>w&&(x=x.slice(0,Math.max(1,w-1))+"…"),A.push(o.jsx("text",{x:p.x+5,y:p.y+12,className:"in-tm-glabel","data-dir":M,children:x},"gl"+y.name))}const E=Vh(y.files.map(x=>({...x,name:x.path.split("/").pop(),value:x.reads+1})),p.x+2,p.y+Ws,Math.max(0,p.w-4),Math.max(0,p.h-Ws-2));for(const x of E)if(A.push(o.jsx("rect",{x:x.x+.6,y:x.y+.6,width:Math.max(.4,x.w-1.2),height:Math.max(.4,x.h-1.2),rx:1.5,fill:qg(x.item.days),className:"in-tm-cell","data-path":x.item.path,children:o.jsx("title",{children:`${x.item.path} — ${x.item.reads} read${x.item.reads===1?"":"s"}/30d · changed ${Math.round(x.item.days)}d ago`})},x.item.path)),x.w>54&&x.h>16){const w=Math.floor((x.w-8)/6);let z=(x.item.danger?"⚠ ":"")+x.item.name;z.length>w&&(z=z.slice(0,Math.max(1,w-1))+"…"),w>=5&&A.push(o.jsx("text",{x:x.x+4.5,y:x.y+12.5,className:"in-tm-label","data-path":x.item.path,children:z},"l"+x.item.path))}}return o.jsx("svg",{viewBox:"0 0 720 480",className:"in-chart in-treemap",onClick:p=>{const y=p.target.closest("[data-path], [data-dir]");if(!y)return;const M=y.getAttribute("data-path");if(M)return c(M);const E=y.getAttribute("data-dir");E&&f(E)&&r(E)},children:A})}function Bg({pts:i,onOpenFile:c}){const d={l:44,r:16,t:20,b:34},m=Math.max(Fa*2,...i.map(E=>E.days)),g=Math.max(Fn*2,...i.map(E=>E.reads)),A=E=>Math.log10(E+1)/Math.log10(m+1),p=E=>Math.log10(E+1)/Math.log10(g+1),y=E=>d.l+A(E)*(720-d.l-d.r),M=E=>360-d.b-p(E)*(360-d.t-d.b);return o.jsxs("svg",{viewBox:"0 0 720 360",className:"in-chart",children:[o.jsx("rect",{x:y(Fa),y:d.t,width:720-d.r-y(Fa),height:M(Fn)-d.t,className:"in-danger-zone"}),o.jsx("line",{x1:y(Fa),y1:d.t,x2:y(Fa),y2:360-d.b,className:"in-threshold"}),o.jsx("line",{x1:d.l,y1:M(Fn),x2:720-d.r,y2:M(Fn),className:"in-threshold"}),o.jsx("line",{x1:d.l,y1:360-d.b,x2:720-d.r,y2:360-d.b,className:"in-axis"}),o.jsx("line",{x1:d.l,y1:d.t,x2:d.l,y2:360-d.b,className:"in-axis"}),o.jsx("text",{x:(d.l+720-d.r)/2,y:352,className:"in-label",children:"days since last change →"}),o.jsx("text",{x:12,y:(d.t+360-d.b)/2,className:"in-label",transform:`rotate(-90 12 ${(d.t+360-d.b)/2})`,children:"reads / 30d →"}),o.jsx("text",{x:720-d.r-6,y:d.t+14,className:"in-quad in-quad-danger",textAnchor:"end",children:"hot + stale"}),o.jsx("text",{x:d.l+6,y:d.t+14,className:"in-quad",children:"hot + fresh"}),o.jsx("text",{x:720-d.r-6,y:360-d.b-8,className:"in-quad",textAnchor:"end",children:"cold + stale"}),o.jsx("text",{x:720-d.r-6,y:d.t+28,className:"in-label",textAnchor:"end",children:"dot size = agent share of reads"}),i.map(E=>{const x=E.total?(E.agent||0)/E.total:0;return o.jsx("circle",{cx:Number(y(E.days).toFixed(1)),cy:Number(M(E.reads).toFixed(1)),r:Number((3+4*x).toFixed(1)),className:"in-pt"+(E.danger?" danger":E.reads?"":" cold"),onClick:()=>c(E.path),children:o.jsx("title",{children:`${E.path} — ${E.reads} read${E.reads===1?"":"s"} / 30d · changed ${Math.round(E.days)}d ago`})},E.path)})]})}function Lg({pts:i,lens:c,onOpenFile:r}){const f=i.filter(m=>m.reads>0).sort((m,g)=>g.reads-m.reads||g.days-m.days).slice(0,20);if(!f.length)return o.jsx("div",{className:"dl-empty",children:"No reads in the window yet."});const d=f[0].reads;return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"in-hotpath",children:f.map(m=>{const g=c==="agent"?1:c==="human"?0:m.total?m.agent/m.total:0,A=m.reads/d*100;return o.jsxs("div",{className:"in-hp-row",tabIndex:0,role:"button",title:m.danger?`${m.reads} read${m.reads===1?"":"s"}/30d · unchanged ${Math.round(m.days)}d — review this file`:m.path,onClick:()=>r(m.path),onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),r(m.path))},children:[o.jsx("span",{className:"in-hp-name"+(m.danger?" danger":""),children:m.path+(m.danger?" ⚠":"")}),o.jsxs("span",{className:"in-hp-bar",children:[o.jsx("span",{className:"in-hp-agent",style:{width:(A*g).toFixed(1)+"%"}}),o.jsx("span",{className:"in-hp-human",style:{width:(A*(1-g)).toFixed(1)+"%"}})]}),o.jsx("span",{className:"in-hp-count",children:m.reads})]},m.path)})}),o.jsxs("p",{className:"in-legend",children:[o.jsx("span",{className:"in-sw agent"})," agent reads ",o.jsx("span",{className:"in-sw human"})," human reads"]})]})}function Yg({devices:i}){const c=new Map;for(const x of i)for(const[w,z]of Object.entries(x.folders||{}))c.set(w,(c.get(w)||0)+z);const r=[...c.entries()].sort((x,w)=>w[1]-x[1]).slice(0,12).map(x=>x[0]),f=i.slice(0,12),d=140,m=6,g=Math.min(76,Math.max(34,(720-d-8)/r.length)),A=26,p=720,y=m+f.length*A+58,M=Math.max(1,...f.flatMap(x=>r.map(w=>(x.folders||{})[w]||0))),E=x=>{const w=[23,25,31],z=[245,166,35],q=w.map((Y,F)=>Math.round(Y+(z[F]-Y)*x));return`rgb(${q[0]},${q[1]},${q[2]})`};return o.jsxs("svg",{viewBox:`0 0 ${p} ${y}`,className:"in-chart in-matrix",children:[f.map((x,w)=>{let z=x.name||x.id||"";return z.length>20&&(z=z.slice(0,19)+"…"),o.jsxs("g",{children:[o.jsx("text",{x:d-8,y:m+w*A+17,textAnchor:"end",className:"in-label",children:z}),r.map((q,Y)=>{const F=(x.folders||{})[q]||0;return o.jsx("rect",{x:d+Y*g,y:m+w*A,width:g-4,height:A-4,rx:3,fill:E(Math.sqrt(F/M)),children:o.jsx("title",{children:`${x.name||x.id} × ${q||"(root)"}: ${F} read${F===1?"":"s"}/30d`})},q)})]},x.id||w)}),r.map((x,w)=>{const z=d+w*g+(g-4)/2,q=m+f.length*A+14;return o.jsx("text",{x:z,y:q,className:"in-label",textAnchor:"end",transform:`rotate(-28 ${z} ${q})`,children:x||"(root)"},x)})]})}function Gg(i){const{apiBase:c,target:r,isFolder:f,onMeta:d,onRendered:m}=i,g=r?f(r)?{prefix:r+"/"}:{path:r}:{prefix:""},A="path"in g&&g.path!==void 0?"path="+encodeURIComponent(g.path):"prefix="+encodeURIComponent(g.prefix??""),{data:p,error:y}=ve({queryKey:["history",c,A,200],queryFn:()=>Me(c+"history?"+A+"&n=200"),staleTime:15e3});if(Q.useEffect(()=>{y&&d("History unavailable: "+y.message)},[y,d]),Q.useEffect(()=>{p&&m?.()},[p,m]),!p)return null;const M=p.entries||[];return o.jsxs("div",{className:"history",children:[M.length===0&&o.jsx("div",{className:"empty",children:"No history yet."}),M.map((E,x)=>o.jsx(bm,{entry:E,onOpen:i.onOpen},x))]})}function Xg(i,c){return i?c(i)?i+"/ (folder)":i:"all changes"}function Sm(i){const{config:c,apiBase:r,route:f,hub:d,project:m}=i,g=yr(),A=ni(),{tree:p,flatFiles:y,dirIndex:M,loaded:E}=hg(r,!d||!!m),x=mg(r,d&&!!m&&!!c.reads?.enabled),w=d&&!!m&&!f.path&&!f.view,z=!!i.canInsights&&(f.view==="insights"||w),q=wg(r,z);Q.useEffect(()=>{z&&A.invalidateQueries({queryKey:["heat",r]})},[z,r,A]);const Y=f.path,F=Y||(f.view==="insights"||f.view==="history")&&f.viewTarget||"",yt=!!Y&&M.has(Y),lt=!!Y&&E&&!yt&&y.some(tt=>tt.path===Y),Ct=!!Y&&E&&!yt&&!lt,Rt=yt&&!f.view,[at,k]=Q.useState(()=>new Set),pt=Q.useRef(!0);Q.useEffect(()=>{if(!p||!pt.current)return;pt.current=!1;const tt=(p.children||[]).filter(ft=>ft.dir);tt.length===1&&k(ft=>new Set(ft).add(tt[0].path))},[p]),Q.useEffect(()=>{if(!F||!E)return;k(ft=>{const Ot=new Set(ft);for(const Pa of bg(F))Ot.add(Pa);return M.has(F)&&Ot.add(F),Ot});const tt=document.querySelector(`#tree .row[data-path="${CSS.escape(F)}"]`);tt&&tt.scrollIntoView({block:"nearest"})},[F,E,M]);const Zt=Q.useCallback(tt=>{k(ft=>{const Ot=new Set(ft);return Ot.has(tt)?Ot.delete(tt):Ot.add(tt),Ot})},[]),ee=Q.useRef(null),le=Q.useRef(new Map),Ut=Q.useRef({key:"",want:0,attempts:0});Q.useEffect(()=>{Ut.current={key:g,want:Pp()==="POP"?le.current.get(g)??0:0,attempts:0}},[g]);const ae=Q.useCallback(()=>{const tt=ee.current,ft=Ut.current;!tt||ft.key!==g||ft.attempts>=3||(ft.attempts++,tt.scrollTo({top:ft.want,behavior:"instant"}))},[g]),Be=Q.useCallback(()=>{ee.current&&le.current.set(g,ee.current.scrollTop)},[g]),zt=Q.useCallback(tt=>{ye(Ip(tt,m?.id)),Ke()},[m?.id]),_=Q.useCallback(tt=>ye($a("history",m?.id,tt)),[m?.id]),[B,V]=Q.useState(""),[ot,gt]=Q.useState(null),[S,H]=Q.useState(!1),[L,G]=Q.useState(!1);Q.useEffect(()=>H0(()=>G(!0)),[]);const $=Q.useRef(null),W=i.panel??null,dt=!W&&d&&!!m&<,kt=!W&&d&&!!m,_t=!W&<,Gl=!W&&(lt||d&&!!m&&yt),fa=r+"download?path="+encodeURIComponent(Y),Xl=Q.useCallback(async()=>{try{const tt=await fetch(r+"shares",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Y})});if(!tt.ok)throw new Error(await tt.text());const ft=await tt.json(),Ot=await ei(ft.url);gt({url:ft.url,copied:Ot})}catch(tt){rt("Share failed: "+tt.message,!0)}},[r,Y]),Kl=Q.useCallback(()=>{if(!Y)return _("");_(yt?Y+"/":Y)},[Y,yt,_]);Q.useEffect(()=>{const tt=ft=>{(ft.metaKey||ft.ctrlKey)&&ft.key.toLowerCase()==="k"&&(ft.preventDefault(),G(Ot=>!Ot))};return window.addEventListener("keydown",tt),()=>window.removeEventListener("keydown",tt)},[]);const Fe=Q.useCallback(()=>{const tt=[],ft=(Ot,Pa,ie,zu)=>tt.push({icon:Ot,label:Pa,kind:ie,run:zu});if(d&&m&&Y&&(lt&&ft("share","Share: "+Y,"action",Xl),ft("hist","History: "+Y,"action",Kl),lt&&ft("download","Download: "+Y,"action",()=>$.current?.click())),d&&m&&ft("hist","History: whole project","action",()=>_("")),d)for(const Ot of i.projects||[])(!m||Ot.id!==m.id)&&ft("folder","Switch to project: "+Ot.name,"project",()=>ye("/"+Ot.id));c.auth?.enabled&&ft("power","Sign out","action",()=>window.location.href="/auth/logout");for(const Ot of M.keys())ft("folder",Ot,"folder",()=>zt(Ot));for(const Ot of y)ft("doc",Ot.path,"file",()=>zt(Ot.path));return tt},[d,m,Y,lt,c.auth?.enabled,M,y,i.projects,Xl,Kl,_,zt]);Q.useEffect(()=>{if(!S)return;const tt=()=>H(!1);return document.addEventListener("click",tt),()=>document.removeEventListener("click",tt)},[S]);const ml=Q.useCallback(tt=>M.has(tt),[M]);let Le="markdown",Ae;W?(Le="view",Ae=W.body):f.view==="insights"?(Le="view",Ae=i.canInsights?o.jsx(kh,{flatFiles:y,heatMap:x,devices:q,scope:f.viewTarget||"",onOpenFile:zt,onOpenFolder:zt,isFolder:ml}):o.jsx("div",{className:"empty",children:"Insights is for hub admins and org owners."})):f.view==="history"?(Le="view",Ae=o.jsx(Gg,{apiBase:r,target:f.viewTarget||"",isFolder:ml,onOpen:zt,onMeta:V,onRendered:ae})):Y?E?Ct?(Le="view",Ae=o.jsxs("div",{className:"notfound",children:[o.jsx("h1",{children:"Couldn't find that"}),o.jsxs("p",{children:[o.jsx("code",{children:Y})," isn't in this project right now."]}),o.jsx("p",{className:"nf-sub",children:"If it was just created, it may still be uploading or syncing from a teammate's device — this page checks again automatically every few seconds, so refresh or come back in a moment."}),o.jsx("button",{className:"pbtn",onClick:()=>A.invalidateQueries({queryKey:["tree",r]}),children:"Check again"})]})):yt?(Le="view",Ae=o.jsx(Eg,{node:M.get(Y),heatMap:x,hub:d&&!!m,apiBase:r,onOpen:zt,onFullHistory:_,onRendered:ae})):Ae=o.jsx(Ng,{apiBase:r,path:Y,heatMap:x,flatFiles:y,onOpenFile:zt,onMeta:V,onRendered:ae}):Ae=o.jsx("div",{className:"empty",children:"Loading…"}):w?(Le="view",Ae=o.jsxs(o.Fragment,{children:[o.jsx(pm,{project:m}),i.canInsights&&o.jsx("div",{className:"home-insights",children:o.jsx(kh,{flatFiles:y,heatMap:x,devices:q,onOpenFile:zt,onOpenFolder:zt,isFolder:ml})})]})):Ae=o.jsx("div",{className:"empty",children:"Select a file to read it."});const ii=W?W.crumb:Y?o.jsx(Sg,{path:Y,onOpenFolder:zt}):f.view==="insights"?"Insights — "+(f.viewTarget||m?.name||""):f.view==="history"?"History — "+Xg(f.viewTarget||"",ml):w?m.name:null,Ia=o.jsx(ti,{crumb:ii,meta:B,actions:o.jsxs(o.Fragment,{children:[dt&&o.jsx("button",{id:"share-btn",className:"btn icon-only",title:"Share","aria-label":"Share",onClick:Xl,children:o.jsx(Kt,{name:"share"})}),kt&&!Y&&!f.view&&o.jsxs("button",{id:"history-btn",className:"btn",onClick:Kl,children:[o.jsx(Kt,{name:"hist"})," ",o.jsx("span",{className:"lbl",children:"History"})]}),_t&&o.jsx("a",{id:"download",hidden:!0,download:!0,href:fa,ref:$,children:"Download"}),Gl&&o.jsx("button",{id:"more-btn",className:"btn icon-only",title:"More actions","aria-label":"More actions",onClick:tt=>{tt.stopPropagation(),H(!S)},children:o.jsx(Kt,{name:"dots"})}),S&&o.jsxs("div",{id:"more-menu",role:"menu",children:[kt&&o.jsx("button",{className:"more-item",onClick:Kl,children:"History"}),_t&&o.jsx("button",{className:"more-item",onClick:()=>$.current?.click(),children:"Download"}),i.canInsights&&o.jsx("button",{className:"more-item",onClick:()=>{i.onClosePanel?.(),ye($a("insights",m?.id,Y))},children:"Insights"})]})]})});return o.jsxs(o.Fragment,{children:[o.jsx(Pn,{vault:i.sidebar.vault,projectsNav:i.sidebar.projectsNav,orgBar:i.sidebar.orgBar,tree:o.jsx(pg,{root:p,expanded:at,onToggle:Zt,currentPath:F,listingShowing:Rt,onOpen:zt}),topbar:Ia,contentClass:Le,contentRef:ee,onContentScroll:Be,children:Ae}),ot&&o.jsx(Dg,{url:ot.url,copied:ot.copied,onClose:()=>gt(null)}),o.jsx(Hg,{open:L,onClose:()=>G(!1),candidates:Fe})]})}function Kg({config:i}){const c=yr(),r=fm(),[f,d]=Q.useState(null),[m,g]=Q.useState(null);Q.useEffect(()=>g(null),[c]);const A=Q.useMemo(()=>{const at=c.match(/^\/join\/([0-9a-f]+)\/?$/);return at?at[1]:null},[c]),{data:p}=Fp(!A),{data:y}=$p(!A),M=!!i.auth.admin,{data:E}=rm(M),x=Q.useMemo(()=>dm(c,"hub"),[c]),w=Q.useMemo(()=>p&&(p.find(at=>at.id===x.project)||f&&p.find(at=>at.org===f)||p[0])||null,[p,x.project,f]);if(Q.useEffect(()=>{document.title=w?w.name+" — BearDrive":i.brand||i.volume||"BearDrive"},[w,i]),A)return o.jsx(Zg,{token:A,onDone:async at=>{d(at),await r(),ye("/",{replace:!0})}});const z=i.brand||i.volume||"BearDrive",q=w&&y?.find(at=>at.id===w.org)||null,Y=M||(q?q.role==="owner":!1),F=o.jsx(Cu,{name:z,onHome:()=>ye("/"),search:!!w}),yt=i.me?o.jsx(cg,{me:i.me,org:q,admin:M?{pending:E?.length||0,onClick:()=>{g({kind:"hub"}),Ke()}}:void 0,onOrgSettings:at=>{g({kind:"org",orgId:at.id}),Ke()}}):void 0;if(!p||!y)return o.jsx(Pn,{vault:F,topbar:o.jsx(ti,{}),children:o.jsx("div",{className:"empty",children:"Loading…"})});if(!w)return o.jsx(Pn,{vault:F,projectsNav:o.jsx(Xh,{projects:p}),orgBar:yt,topbar:o.jsx(ti,{}),contentClass:"view",children:o.jsx(dg,{authEnabled:i.auth.enabled,onCreate:async at=>{if(!at){rt("Give the project a name.",!0);return}try{const k=await Wa("/api/projects",{name:at});await r(),ye("/"+k.project.id),rt(`Created “${k.project.name}”.`)}catch(k){rt("Could not create the project: "+k.message,!0)}}})});const lt=m?.kind==="org"?y.find(at=>at.id===m.orgId):null,Ct=m?.kind==="hub"?{crumb:"Signup & access",body:o.jsx(ug,{})}:lt?{crumb:lt.name,body:o.jsx(ig,{org:lt,projects:p,myEmail:i.me?.email||"",onProjectsChanged:r})}:null,Rt=x.view==="settings"?{crumb:"Project settings",body:o.jsx(sg,{project:w,org:q})}:x.view==="install"?{crumb:"Installation",body:o.jsx("div",{className:"onboard",children:o.jsx(pm,{project:w})})}:null;return x.project!==w.id?o.jsx(tg,{to:"/"+w.id}):o.jsx(Sm,{config:i,apiBase:"/api/p/"+w.id+"/",route:x,hub:!0,project:w,projects:p,canInsights:Y,sidebar:{vault:F,projectsNav:o.jsx(Xh,{projects:p,currentId:w.id,menu:{active:m?null:x.view==="insights"&&!x.viewTarget?"dashboard":x.view==="install"?"install":x.view==="history"&&!x.viewTarget?"history":x.view==="settings"?"settings":null,onDashboard:()=>{g(null),ye($a("insights",w.id)),Ke()},onInstall:()=>{g(null),ye($a("install",w.id)),Ke()},onHistory:()=>{g(null),ye($a("history",w.id)),Ke()},onSettings:()=>{g(null),ye($a("settings",w.id)),Ke()}}}),orgBar:yt},panel:Ct||Rt,onClosePanel:()=>g(null)},w.id)}function Zg({token:i,onDone:c}){return Q.useEffect(()=>{let r=!1;return Wa("/api/invites/"+i).then(f=>{r||(rt(`Welcome — you joined the “${f.org.name}” team. Opening its projects…`),c(f.org.id))}).catch(f=>{r||String(f.message).includes("signing in")||(rt("Could not accept the invite: "+f.message,!0),c(null))}),()=>{r=!0}},[i]),o.jsx(Pn,{vault:o.jsx(Cu,{name:"BearDrive"}),topbar:o.jsx(ti,{}),children:o.jsx("div",{className:"empty",children:"Joining…"})})}function kg({config:i}){const c=yr(),r=i.volume||"BearDrive";Q.useEffect(()=>{document.title=i.brand||r},[i,r]);const f=Q.useMemo(()=>dm(c,"volume"),[c]);return o.jsx(Sm,{config:i,apiBase:"/api/",route:f,hub:!1,sidebar:{vault:o.jsx(Cu,{name:r,showSignout:i.auth.enabled,search:!0})}})}function Vg(){const{data:i}=U0();return o.jsxs(o.Fragment,{children:[i?i.mode==="hub"?o.jsx(Kg,{config:i}):o.jsx(kg,{config:i}):o.jsx(Pn,{vault:o.jsx(Cu,{name:"…",showSignout:!1}),topbar:o.jsx(ti,{}),children:o.jsx("div",{className:"empty",children:"Loading…"})}),o.jsx(Zp,{}),o.jsx(kp,{})]})}const Jg=new x0({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}});Fv.createRoot(document.getElementById("root")).render(o.jsx(Q.StrictMode,{children:o.jsx(j0,{client:Jg,children:o.jsx(Vg,{})})})); diff --git a/internal/webapp/static/index.html b/internal/webapp/static/index.html index 48c1588..8ec324c 100644 --- a/internal/webapp/static/index.html +++ b/internal/webapp/static/index.html @@ -5,7 +5,7 @@ BearDrive - +