@alivault/pico 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.output/nitro.json +1 -1
- package/.output/public/assets/{index-BMJXPFQq.js → index-CksX3NW4.js} +3 -3
- package/.output/public/assets/{routes-BPkTKiWN.js → routes-VohBsBcC.js} +3 -3
- package/.output/public/assets/styles-ej_ltn_F.css +2 -0
- package/.output/server/_ssr/{router-DB3DegnY.mjs → router-Di8B08B6.mjs} +3 -3
- package/.output/server/_ssr/{routes-C2DKvBRY.mjs → routes-B99MXwvx.mjs} +2 -2
- package/.output/server/_ssr/{routes-RV18btaL.mjs → routes-CRDrPu8Q.mjs} +5 -5
- package/.output/server/_ssr/ssr.mjs +2 -2
- package/.output/server/{_tanstack-start-manifest_v-K79umiqV.mjs → _tanstack-start-manifest_v-DK9pZs2A.mjs} +4 -4
- package/.output/server/index.mjs +513 -513
- package/package.json +1 -1
- package/.output/public/assets/styles-BteSJJZQ.css +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/angular-html-BZNntD0J.js","assets/rolldown-runtime-S-ySWqyJ.js","assets/html-ddqpqPg0.js","assets/css-DRmnABqB.js","assets/javascript-Cop1kpy_.js","assets/angular-ts-SQQMYL2C.js","assets/scss-DNczJ95n.js","assets/apl-D5V6uPDr.js","assets/json-CTw4n7kn.js","assets/xml-eU7M3iZJ.js","assets/java-DVLnIrqC.js","assets/astro-DeXKSaFP.js","assets/postcss-BTQso3H9.js","assets/tsx-BjkCKOtw.js","assets/typescript-BoHeP9q1.js","assets/blade-Bu5re0Vg.js","assets/html-derivative-DWGxf_At.js","assets/sql-CrTmZCMa.js","assets/bsl-B1qbqNES.js","assets/sdbl-BmWYR-pI.js","assets/c-Nc9zJT78.js","assets/cairo-BDj8wWhy.js","assets/python-CKg5r0C3.js","assets/cobol-nvZDS9LT.js","assets/coffee-BKLOTq4e.js","assets/cpp-D6g1DVNt.js","assets/glsl-JAhLUe0P.js","assets/regexp-3-A0406L.js","assets/crystal-DfoZI57w.js","assets/shellscript-DaVPunOM.js","assets/edge-DwocGnOF.js","assets/elixir-Dtbfds1r.js","assets/elm-CpPtm471.js","assets/erb--z3IM9Cb.js","assets/ruby-Cl8PVkbY.js","assets/graphql-D2ba3BkR.js","assets/jsx-0oMUGqZj.js","assets/haml-C-oIZcDo.js","assets/lua-31hdJClp.js","assets/yaml-BTD1XHJG.js","assets/erlang-Bc4hQuqa.js","assets/markdown-BaI9LyM4.js","assets/fortran-fixed-form-B02FOYI-.js","assets/fortran-free-form-BPTf0lbT.js","assets/fsharp-DhdR18vN.js","assets/gdresource-DgnrMPIx.js","assets/gdscript-CsadCSaZ.js","assets/gdshader-PfnN_8tR.js","assets/git-commit-DGJi7qBD.js","assets/diff-CdkWtnkL.js","assets/git-rebase-Ce47xoa6.js","assets/glimmer-js-C0BuzxQC.js","assets/glimmer-ts-irOZ-cAQ.js","assets/hack-CgzUpY8l.js","assets/handlebars-CbP-Mhzf.js","assets/http-Bg1nG1nG.js","assets/hurl-zm47Pi1n.js","assets/csv-DNUpVBxl.js","assets/hxml-adC65L_J.js","assets/haxe-DfXTCEOz.js","assets/jinja-Bnj4awH5.js","assets/jison-CuCNs9Q3.js","assets/julia-DNYHzXlE.js","assets/r-UcxRcvcA.js","assets/just-BlWkkmf2.js","assets/perl-CAGVW6Ra.js","assets/latex-DqPzjMIt.js","assets/tex-D8LVuLf5.js","assets/liquid-BURJK16h.js","assets/marko-C2ZcdSLh.js","assets/less-C95PyOu0.js","assets/mdc-N1ii9pk5.js","assets/nextflow-JEyYUlIq.js","assets/nextflow-groovy-wvmJO4hi.js","assets/nginx-BuomO0W8.js","assets/nim-hKoEPsYL.js","assets/php-BycclmzS.js","assets/pug-4maJHz9G.js","assets/qml-JLIQfzyb.js","assets/razor-P8rbooCh.js","assets/csharp-BDKQY1K9.js","assets/rst-C6GHyL-N.js","assets/cmake-D5rSbMir.js","assets/sas-CXoVwlZN.js","assets/shaderlab-DZ3Lsiak.js","assets/hlsl-DpuYn7pp.js","assets/shellsession-COm1V40U.js","assets/soy-DwewhJ_3.js","assets/sparql-B9c85a_o.js","assets/turtle-CqNXyJWZ.js","assets/stata-Bl--TAbZ.js","assets/surrealql-BW79EE-U.js","assets/svelte-ziMErdPi.js","assets/templ-C_9I6ncv.js","assets/go-DLnOLj8q.js","assets/ts-tags-DKuFCGsc.js","assets/twig-Bs1kcsO6.js","assets/vue-Dnf0y5RU.js","assets/vue-html-CRtKS76J.js","assets/vue-vine-BxjPqU7T.js","assets/stylus-sKwvsUaC.js","assets/xsl-DSqe4nTO.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{n as e,r as t,t as n}from"./rolldown-runtime-S-ySWqyJ.js";import{$ as r,$r as i,$t as a,A as o,An as s,Ar as c,At as l,B as u,Bn as d,Br as f,Bt as p,C as m,Cn as h,Cr as g,Ct as _,D as v,Dn as y,Dr as b,Dt as x,E as S,En as C,Er as w,Et as T,F as E,Fn as D,Fr as O,Ft as k,G as A,Gn as j,Gr as M,Gt as N,H as P,Hn as F,Hr as I,Ht as L,I as R,In as z,Ir as B,It as V,J as H,Jn as U,Jr as W,Jt as G,K as ee,Kn as te,Kr as K,Kt as ne,L as q,Ln as J,Lr as re,Lt as Y,M as ie,Mn as ae,Mr as oe,Mt as se,N as ce,Nn as le,Nr as ue,Nt as de,O as fe,On as pe,Or as me,Ot as he,P as ge,Pn as _e,Pr as ve,Pt as ye,Q as be,Qn as xe,Qr as Se,Qt as Ce,R as we,Rn as Te,Rr as Ee,Rt as De,S as Oe,Sn as ke,Sr as Ae,St as je,T as Me,Tn as Ne,Tr as Pe,Tt as Fe,U as Ie,Un as Le,Ur as Re,Ut as ze,V as Be,Vn as Ve,Vr as He,Vt as Ue,W as We,Wn as Ge,Wr as Ke,Wt as qe,X as Je,Xn as Ye,Xr as Xe,Xt as Ze,Y as Qe,Yn as $e,Yr as et,Yt as tt,Z as nt,Zn as rt,Zr as it,Zt as at,_ as ot,_n as st,_r as ct,_t as lt,a as ut,an as dt,at as ft,b as pt,bn as mt,br as ht,bt as gt,c as _t,cn as vt,cr as yt,ct as bt,d as xt,dn as St,dr as Ct,dt as wt,ei as Tt,en as Et,er as Dt,et as Ot,f as kt,fn as At,fr as jt,ft as Mt,g as Nt,gn as Pt,gr as Ft,gt as It,h as Lt,hn as Rt,hr as zt,ht as Bt,i as Vt,ii as Ht,in as Ut,ir as Wt,it as Gt,j as Kt,jn as qt,jr as Jt,jt as Yt,k as Xt,kn as Zt,kr as Qt,kt as $t,l as en,ln as tn,lr as nn,lt as rn,m as an,mn as on,mr as sn,mt as cn,n as X,ni as ln,nn as un,nr as dn,nt as fn,o as pn,on as mn,or as hn,ot as gn,p as _n,pn as vn,pr as yn,pt as bn,q as xn,qn as Sn,qr as Cn,qt as wn,r as Tn,ri as En,rn as Dn,rr as On,rt as kn,s as An,sn as jn,st as Mn,t as Nn,ti as Pn,tn as Fn,tr as In,tt as Ln,u as Rn,un as zn,ur as Bn,ut as Vn,v as Hn,vn as Un,vr as Wn,vt as Gn,w as Kn,wn as qn,wr as Jn,wt as Yn,x as Xn,xn as Zn,xr as Qn,xt as $n,y as er,yn as tr,yr as nr,yt as rr,z as eee,zn as ir,zr as ar,zt as or}from"./index-BMJXPFQq.js";var sr=class extends ln{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=I(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),lr(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ur(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ur(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof et(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!it(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&dr(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||et(this.options.enabled,this.#t)!==et(t.enabled,this.#t)||Xe(this.options.staleTime,this.#t)!==Xe(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||et(this.options.enabled,this.#t)!==et(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return pr(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(K)),t}#g(){this.#b();let e=Xe(this.options.staleTime,this.#t);if(Re.isServer()||this.#r.isStale||!M(e))return;let t=i(this.#r.dataUpdatedAt,e)+1;this.#d=Tt.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(Re.isServer()||et(this.options.enabled,this.#t)===!1||!M(this.#p)||this.#p===0)&&(this.#f=Tt.setInterval(()=>{(this.options.refetchIntervalInBackground||Pn.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(Tt.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(Tt.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&lr(e,t),o=i&&dr(e,n,t,r);(a||o)&&(l={...l,...f(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:p,errorUpdatedAt:m,status:h}=l;d=l.data;let g=!1;if(t.placeholderData!==void 0&&d===void 0&&h===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,g=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(h=`success`,d=Cn(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!g)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=Cn(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(p=this.#s,d=this.#l,m=Date.now(),h=`error`);let _=l.fetchStatus===`fetching`,v=h===`pending`,y=h===`error`,b=v&&_,x=d!==void 0,S={status:h,fetchStatus:l.fetchStatus,isPending:v,isSuccess:h===`success`,isError:y,isInitialLoading:b,isLoading:b,data:d,dataUpdatedAt:l.dataUpdatedAt,error:p,errorUpdatedAt:m,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:_,isRefetching:_&&!v,isLoadingError:y&&!x,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:y&&x,isStale:fr(e,t),refetch:this.refetch,promise:this.#o,isEnabled:et(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=S.data!==void 0,r=S.status===`error`&&!t,i=e=>{r?e.reject(S.error):t&&e.resolve(S.data)},a=()=>{i(this.#o=S.promise=I())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||S.data!==o.value)&&a();break;case`rejected`:(!r||S.error!==o.reason)&&a();break}}return S}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!it(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){He.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function cr(e,t){return et(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&t.retryOnMount===!1)}function lr(e,t){return cr(e,t)||e.state.data!==void 0&&ur(e,t,t.refetchOnMount)}function ur(e,t,n){if(et(t.enabled,e)!==!1&&Xe(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&fr(e,t)}return!1}function dr(e,t,n,r){return(e!==t||et(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&fr(e,n)}function fr(e,t){return et(t.enabled,e)!==!1&&e.isStaleByTime(Xe(t.staleTime,e))}function pr(e,t){return!it(e.getCurrentResult(),t)}var mr=class extends ln{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),it(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&Ke(t.mutationKey)!==Ke(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??ar();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){He.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},Z=t(Ht(),1),hr=Z.createContext(!1),gr=()=>Z.useContext(hr);hr.Provider;var Q=Ee();function _r(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var vr=Z.createContext(_r()),yr=()=>Z.useContext(vr),br=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?Se(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},xr=e=>{Z.useEffect(()=>{e.clearReset()},[e])},Sr=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Se(n,[e.error,r])),Cr=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},wr=(e,t)=>e.isLoading&&e.isFetching&&!t,Tr=(e,t)=>e?.suspense&&t.isPending,Er=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Dr(e,t,n){let r=gr(),i=yr(),a=re(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?`isRestoring`:`optimistic`,Cr(o),br(o,i,s),xr(i);let c=!a.getQueryCache().get(o.queryHash),[l]=Z.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&e.subscribed!==!1;if(Z.useSyncExternalStore(Z.useCallback(e=>{let t=d?l.subscribe(He.batchCalls(e)):K;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),Z.useEffect(()=>{l.setOptions(o)},[o,l]),Tr(o,u))throw Er(o,l,i);if(Sr({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!Re.isServer()&&wr(u,r)&&(c?Er(o,l,i):s?.promise)?.catch(K).finally(()=>{l.updateResult()}),o.notifyOnChangeProps?u:l.trackResult(u)}function Or(e,t){return Dr(e,sr,t)}function kr(e,t){let n=re(t),r=n.getQueryCache();return Z.useSyncExternalStore(Z.useCallback(e=>r.subscribe(He.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}function Ar(e,t){let n=re(t);return Mr({filters:{...e,status:`pending`}},n).length}function jr(e,t){return e.findAll(t.filters).map(e=>t.select?t.select(e):e.state)}function Mr(e={},t){let n=re(t).getMutationCache(),r=Z.useRef(e),i=Z.useRef(null);return i.current===null&&(i.current=jr(n,e)),Z.useEffect(()=>{r.current=e}),Z.useSyncExternalStore(Z.useCallback(e=>n.subscribe(()=>{let t=W(i.current,jr(n,r.current));i.current!==t&&(i.current=t,He.schedule(e))}),[n]),()=>i.current,()=>i.current)}function Nr(e,t){let n=re(t),[r]=Z.useState(()=>new mr(n,e));Z.useEffect(()=>{r.setOptions(e)},[r,e]);let i=Z.useSyncExternalStore(Z.useCallback(e=>r.subscribe(He.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=Z.useCallback((e,t)=>{r.mutate(e,t).catch(K)},[r]);if(i.error&&Se(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function Pr(e){return typeof e==`object`&&!!e&&`current`in e}function Fr(){if(typeof navigator>`u`)return`linux`;let e=navigator.platform?.toLowerCase()??``,t=navigator.userAgent?.toLowerCase()??``;return e.includes(`mac`)||t.includes(`mac`)?`mac`:e.includes(`win`)||t.includes(`win`)?`windows`:`linux`}var Ir=[`Control`,`Alt`,`Shift`,`Meta`];new Set(Ir);var Lr={Control:`Control`,Ctrl:`Control`,control:`Control`,ctrl:`Control`,Shift:`Shift`,shift:`Shift`,Alt:`Alt`,Option:`Alt`,alt:`Alt`,option:`Alt`,Command:`Meta`,Cmd:`Meta`,Meta:`Meta`,command:`Meta`,cmd:`Meta`,meta:`Meta`,OS:`Meta`,os:`Meta`,Win:`Meta`,win:`Meta`,CommandOrControl:`Mod`,Mod:`Mod`,commandorcontrol:`Mod`,mod:`Mod`};function Rr(e,t=Fr()){return e===`Mod`?t===`mac`?`Meta`:`Control`:e}var zr=new Set(`ABCDEFGHIJKLMNOPQRSTUVWXYZ`.split(``)),Br=new Set([`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`]),Vr=new Set([`F1`,`F2`,`F3`,`F4`,`F5`,`F6`,`F7`,`F8`,`F9`,`F10`,`F11`,`F12`]),Hr=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`,`PageUp`,`PageDown`]),Ur=new Set([`Enter`,`Escape`,`Space`,`Tab`,`Backspace`,`Delete`]),Wr=new Set([`/`,`[`,`]`,`\\`,`=`,`-`,`,`,`.`,`;`,"`"]),Gr={Backquote:"`",Backslash:`\\`,BracketLeft:`[`,BracketRight:`]`,Comma:`,`,Equal:`=`,Minus:`-`,Period:`.`,Semicolon:`;`,Slash:`/`};new Set([...zr,...Br,...Vr,...Hr,...Ur,...Wr]);var Kr={Esc:`Escape`,esc:`Escape`,escape:`Escape`,Return:`Enter`,return:`Enter`,enter:`Enter`," ":`Space`,space:`Space`,Spacebar:`Space`,spacebar:`Space`,tab:`Tab`,backspace:`Backspace`,Del:`Delete`,del:`Delete`,delete:`Delete`,Up:`ArrowUp`,up:`ArrowUp`,arrowup:`ArrowUp`,Down:`ArrowDown`,down:`ArrowDown`,arrowdown:`ArrowDown`,Left:`ArrowLeft`,left:`ArrowLeft`,arrowleft:`ArrowLeft`,Right:`ArrowRight`,right:`ArrowRight`,arrowright:`ArrowRight`,home:`Home`,end:`End`,pageup:`PageUp`,pagedown:`PageDown`,PgUp:`PageUp`,PgDn:`PageDown`,pgup:`PageUp`,pgdn:`PageDown`};function qr(e){return/^\p{Letter}$/u.test(e)}function Jr(e){if(!e)return``;if(e in Kr)return Kr[e];if(qr(e)){let t=e.toUpperCase();return t.length===1?t:e}let t=e.toUpperCase();return/^F([1-9]|1[0-2])$/.test(t)?t:e}var Yr={Control:`⌃`,Alt:`⌥`,Shift:`⇧`,Meta:`⌘`,Mod:`⌘`},Xr={Control:`Control`,Alt:`Option`,Shift:`Shift`,Meta:`Cmd`,Mod:`Cmd`},Zr={Control:`Ctrl`,Alt:`Alt`,Shift:`Shift`,Meta:`Win`,Mod:`Ctrl`},Qr={...Zr,Meta:`Super`},$r={"`":`Backquote`,"\\":`Backslash`,"[":`Left Bracket`,"]":`Right Bracket`,",":`Comma`,"=":`Equal`,"-":`Minus`,".":`Period`,";":`Semicolon`},ei={ArrowUp:`↑`,ArrowDown:`↓`,ArrowLeft:`←`,ArrowRight:`→`,Enter:`↵`,Escape:`Esc`,Backspace:`⌫`,Delete:`⌦`,Tab:`⇥`,Space:`␣`};function ti(e,t=Fr()){let n=e.split(`+`),r=new Set,i=``;for(let e=0;e<n.length;e++){let a=n[e].trim();if(e===n.length-1)i=Jr(a);else{let e=Lr[a]??Lr[a.toLowerCase()];if(e){let n=Rr(e,t);r.add(n)}else n.length===1&&(i=Jr(a))}}return!i&&n.length>0&&(i=Jr(n[n.length-1].trim())),{key:i,ctrl:r.has(`Control`),shift:r.has(`Shift`),alt:r.has(`Alt`),meta:r.has(`Meta`),modifiers:Ir.filter(e=>r.has(e))}}function ni(e,t=Fr()){let n=e.ctrl??!1,r=e.shift??!1,i=e.alt??!1,a=e.meta??!1;e.mod&&(Rr(`Mod`,t)===`Control`?n=!0:a=!0);let o=Ir.filter(e=>{switch(e){case`Control`:return n;case`Shift`:return r;case`Alt`:return i;case`Meta`:return a;default:return!1}});return{key:e.key,ctrl:n,shift:r,alt:i,meta:a,modifiers:o}}function ri(e,t){let n=t===`mac`?e.meta&&!e.ctrl:e.ctrl&&!e.meta,r=[];if(n)r.push(`Mod`),e.alt&&r.push(`Alt`),e.shift&&r.push(`Shift`);else for(let t of Ir)e.modifiers.includes(t)&&r.push(t);return r.push(Jr(e.key)),r.join(`+`)}function ii(e,t=Fr()){return ri(ti(e,t),t)}function ai(e,t=Fr()){return ri(e,t)}function oi(e,t=Fr()){return typeof e==`string`?ii(e,t):ai(ni(e,t),t)}function si(e){return e in Lr||e.toLowerCase()in Lr}function ci(e){let t=[];for(let n of Ir)e.modifiers.includes(n)&&t.push(n);return t.push(e.key),t.join(`+`)}function li(e,t={}){let n=t.platform??Fr(),r=t.useSymbols??!0,i=t.separatorToken??(n===`mac`&&r?` `:`+`);return oi(e,n).split(`+`).map(e=>{if(si(e)){let t=Lr[e]??Lr[e.toLowerCase()];return n===`mac`?r?Yr[t]:Xr[t]:n===`windows`?Zr[t]:Qr[t]}else return r&&ei[e]||!r&&$r[e]||e}).join(i)}function ui(e,t,n=Fr()){let r=typeof t==`string`?ti(t,n):t;if(e.ctrlKey!==r.ctrl||e.shiftKey!==r.shift||e.altKey!==r.alt||e.metaKey!==r.meta)return!1;let i=Jr(e.key),a=r.key;if(i!==`Dead`&&i.length===1&&a.length===1){if(i.toUpperCase()===a.toUpperCase())return!0;if(qr(i)&&(/^[A-Za-z]$/.test(i)||!e.altKey))return!1}if(e.code&&(i===`Dead`||i.length===1&&a.length===1)){if(e.code.startsWith(`Key`)){let t=e.code.slice(3);if(t.length===1&&/^[A-Za-z]$/.test(t))return t.toUpperCase()===a.toUpperCase()}if(e.code.startsWith(`Digit`)){let t=e.code.slice(5);if(t.length===1&&/^[0-9]$/.test(t))return t===a}return e.code in Gr?Gr[e.code]===a:!1}return i===a}var di={preventDefault:!0,stopPropagation:!0,eventType:`keydown`,enabled:!0,ignoreInputs:!0,conflictBehavior:`warn`};function fi(e){return!(e.ctrl||e.meta||e.key===`Escape`)}function pi(e){if(!e)return!1;if(e instanceof HTMLInputElement){let t=e.type.toLowerCase();return!(t===`button`||t===`submit`||t===`reset`)}return!!(e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable)}function mi(e){return typeof document>`u`?null:typeof Document<`u`&&e instanceof Document||typeof Node<`u`&&e.nodeType===Node.DOCUMENT_NODE?e.activeElement:typeof HTMLElement<`u`&&e instanceof HTMLElement?e.ownerDocument.activeElement??null:e.document.activeElement??null}function hi(e,t,n){let r=mi(t);return r&&pi(r)&&r!==n||e.composedPath().some(e=>pi(e)&&e!==n)?!0:pi(e.target)&&e.target!==n}function gi(e,t){return t===document||t===window?e.currentTarget===t||e.currentTarget===document.documentElement:t===window?e.currentTarget===window||e.currentTarget===document||e.currentTarget===document.documentElement:!!(t instanceof HTMLElement&&(e.currentTarget===t||e.target instanceof Node&&t.contains(e.target)))}function _i(e,t,n,r){if(n!==`allow`){if(n===`warn`){console.warn(`'${t}' is already registered. Multiple handlers will be triggered. Use conflictBehavior: 'replace' to replace the existing handler, or conflictBehavior: 'allow' to suppress this warning.`);return}if(n===`error`)throw Error(`'${t}' is already registered. Use conflictBehavior: 'replace' to replace the existing handler, or conflictBehavior: 'allow' to allow multiple registrations.`);r(e)}}var vi=function(e){return e[e.None=0]=`None`,e[e.Mutable=1]=`Mutable`,e[e.Watching=2]=`Watching`,e[e.RecursedCheck=4]=`RecursedCheck`,e[e.Recursed=8]=`Recursed`,e[e.Dirty=16]=`Dirty`,e[e.Pending=32]=`Pending`,e}({});function yi({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&(vi.RecursedCheck|vi.Recursed|vi.Dirty|vi.Pending)?a&(vi.RecursedCheck|vi.Recursed)?a&vi.RecursedCheck?!(a&(vi.Dirty|vi.Pending))&&c(e,i)?(i.flags=a|(vi.Recursed|vi.Pending),a&=vi.Mutable):a=vi.None:i.flags=a&~vi.Recursed|vi.Pending:a=vi.None:i.flags=a|vi.Pending,a&vi.Watching&&t(i),a&vi.Mutable){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(!0)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&vi.Dirty)a=!0;else if((c&(vi.Mutable|vi.Dirty))===(vi.Mutable|vi.Dirty)){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&(vi.Mutable|vi.Pending))===(vi.Mutable|vi.Pending)){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=~vi.Pending;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(!0)}function s(e){do{let n=e.sub,r=n.flags;(r&(vi.Pending|vi.Dirty))===vi.Pending&&(n.flags=r|vi.Dirty,(r&(vi.Watching|vi.RecursedCheck))===vi.Watching&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function bi(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var xi=[],Si=0,{link:Ci,unlink:wi,propagate:Ti,checkDirty:Ei,shallowPropagate:Di}=yi({update(e){return e._update()},notify(e){xi[ki++]=e,e.flags&=~vi.Watching},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=vi.Mutable|vi.Dirty,Ni(e))}}),Oi=0,ki=0,Ai,ji=0;function Mi(e){try{++ji,e()}finally{--ji||Pi()}}function Ni(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=wi(n,e)}function Pi(){if(!(ji>0)){for(;Oi<ki;){let e=xi[Oi];xi[Oi++]=void 0,e.notify()}Oi=0,ki=0}}function Fi(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:n?vi.None:vi.Mutable,get(){return Ai!==void 0&&Ci(i,Ai,Si),i._snapshot},subscribe(e){let t=bi(e),n={current:!1},r=Ii(()=>{i.get(),n.current?t.next?.(i._snapshot):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=Ai,o=t?.compare??Object.is;if(n)Ai=i,++Si,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=vi.Mutable|vi.RecursedCheck);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{Ai=a,n&&(i.flags&=~vi.RecursedCheck),Ni(i)}}};return n?(i.flags=vi.Mutable|vi.Dirty,i.get=function(){let e=i.flags;if(e&vi.Dirty||e&vi.Pending&&Ei(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&Di(e)}}else e&vi.Pending&&(i.flags=e&~vi.Pending);return Ai!==void 0&&Ci(i,Ai,Si),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(Ti(e),Di(e),Pi())}},i}function Ii(e){let t=()=>{let t=Ai;Ai=n,++Si,n.depsTail=void 0,n.flags=vi.Watching|vi.RecursedCheck;try{return e()}finally{Ai=t,n.flags&=~vi.RecursedCheck,Ni(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:vi.Watching|vi.RecursedCheck,notify(){let e=this.flags;e&vi.Dirty||e&vi.Pending&&Ei(this.deps,this)?t():this.flags=vi.Watching},stop(){this.flags=vi.None,this.depsTail=void 0,Ni(this)}};return t(),n}var Li=class{constructor(e,t){this.atom=Fi(e),this.get=this.get.bind(this),this.setState=this.setState.bind(this),this.subscribe=this.subscribe.bind(this),t&&(this.actions=t(this))}setState(e){this.atom.set(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(bi(e))}},Ri=class{constructor(e){this.atom=Fi(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(bi(e))}};function zi(e,t){return typeof e==`function`?new Ri(e):t?new Li(e,t):new Li(e)}function Bi(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();let n=Vi(e);if(n.length!==Vi(t).length)return!1;for(let r=0;r<n.length;r++)if(!Object.prototype.hasOwnProperty.call(t,n[r])||!Object.is(e[n[r]],t[n[r]]))return!1;return!0}function Vi(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}var tee=0;function Hi(){return`hotkey_${++tee}`}var Ui=class e{static#e=null;#t;#n=new Map;#r=new Map;constructor(){this.registrations=new Li(new Map),this.#t=Fr()}static getInstance(){return e.#e||=new e,e.#e}static resetInstance(){e.#e&&=(e.#e.destroy(),null)}register(e,t,n={}){if(typeof document>`u`&&!n.target){let e=t;return{id:Hi(),unregister:()=>{},get callback(){return e},set callback(t){e=t},setOptions:()=>{},get isActive(){return!1}}}let r=Hi(),i=n.platform??this.#t,a=typeof e==`string`?ti(e,i):ni(e,i),o=typeof e==`string`?e:ci(a),s=n.target??document,c=n.conflictBehavior??`warn`,l=this.#d(o,s);l&&_i(l.id,o,c,e=>this.#i(e));let u=n.ignoreInputs??fi(a),d={id:r,hotkey:o,parsedHotkey:a,callback:t,options:{...di,requireReset:!1,...n,platform:i,ignoreInputs:u},hasFired:!1,triggerCount:0,target:s};this.registrations.setState(e=>new Map(e).set(r,d)),this.#r.has(s)||this.#r.set(s,new Set),this.#r.get(s).add(r),this.#a(s);let f=this;return{get id(){return r},unregister:()=>{f.#i(r)},get callback(){return f.registrations.state.get(r)?.callback??t},set callback(e){let t=f.registrations.state.get(r);t&&(t.callback=e)},setOptions:e=>{f.registrations.setState(t=>{let n=t.get(r);if(n){let i=new Map(t);return i.set(r,{...n,options:{...n.options,...e}}),i}return t})},get isActive(){return f.registrations.state.has(r)}}}#i(e){let t=this.registrations.state.get(e);if(!t)return;let n=t.target;this.registrations.setState(t=>{let n=new Map(t);return n.delete(e),n});let r=this.#r.get(n);r&&(r.delete(e),r.size===0&&this.#o(n))}#a(e){if(typeof document>`u`||this.#n.has(e))return;let t=this.#l(e),n=this.#u(e);e.addEventListener(`keydown`,t),e.addEventListener(`keyup`,n),this.#n.set(e,{keydown:t,keyup:n})}#o(e){if(typeof document>`u`)return;let t=this.#n.get(e);t&&(e.removeEventListener(`keydown`,t.keydown),e.removeEventListener(`keyup`,t.keyup),this.#n.delete(e),this.#r.delete(e))}#s(e,t,n){let r=this.#r.get(t);if(r)for(let i of r){let r=this.registrations.state.get(i);if(r&&gi(e,t)&&r.options.enabled&&!(r.options.ignoreInputs!==!1&&hi(e,t,r.target)))if(n===`keydown`){if(r.options.eventType!==`keydown`)continue;ui(e,r.parsedHotkey,r.options.platform)&&(r.options.preventDefault&&e.preventDefault(),r.options.stopPropagation&&e.stopPropagation(),(!r.options.requireReset||!r.hasFired)&&(this.#c(r,e),r.options.requireReset&&(r.hasFired=!0)))}else r.options.eventType===`keyup`&&ui(e,r.parsedHotkey,r.options.platform)&&this.#c(r,e),r.options.requireReset&&r.hasFired&&this.#f(r,e)&&(r.hasFired=!1)}}#c(e,t){e.options.preventDefault&&t.preventDefault(),e.options.stopPropagation&&t.stopPropagation(),e.triggerCount++,this.registrations.setState(e=>new Map(e));let n={hotkey:e.hotkey,parsedHotkey:e.parsedHotkey};e.callback(t,n)}#l(e){return t=>{this.#s(t,e,`keydown`)}}#u(e){return t=>{this.#s(t,e,`keyup`)}}#d(e,t){for(let n of this.registrations.state.values())if(n.hotkey===e&&n.target===t)return n;return null}#f(e,t){let n=e.parsedHotkey,r=Jr(t.key),i=n.key.length===1?n.key.toUpperCase():n.key;return!!((r.length===1?r.toUpperCase():r)===i||n.ctrl&&r===`Control`||n.shift&&r===`Shift`||n.alt&&r===`Alt`||n.meta&&r===`Meta`)}triggerRegistration(e){let t=this.registrations.state.get(e);if(!t)return!1;let n=t.parsedHotkey,r=new KeyboardEvent(t.options.eventType??`keydown`,{key:n.key,ctrlKey:n.ctrl,shiftKey:n.shift,altKey:n.alt,metaKey:n.meta,bubbles:!0,cancelable:!0});return t.triggerCount++,this.registrations.setState(e=>new Map(e)),t.callback(r,{hotkey:t.hotkey,parsedHotkey:t.parsedHotkey}),!0}getRegistrationCount(){return this.registrations.state.size}isRegistered(e,t){for(let n of this.registrations.state.values())if(n.hotkey===e&&(t===void 0||n.target===t))return!0;return!1}destroy(){for(let e of this.#n.keys())this.#o(e);this.registrations.setState(()=>new Map),this.#n.clear(),this.#r.clear()}};function Wi(){return Ui.getInstance()}function Gi(e,t={}){let n=ve().hotkey,r=Wi(),i=t.platform??n?.platform??Fr(),a=(0,Z.useRef)(new Map),o=(0,Z.useRef)(e),s=(0,Z.useRef)([]),c=(0,Z.useRef)(t),l=(0,Z.useRef)(n),u=(0,Z.useRef)(r),d=e.map(e=>oi(e.hotkey,i));o.current=e,s.current=d,c.current=t,l.current=n,u.current=r,(0,Z.useEffect)(()=>{let e=a.current,t=new Map,n=[];for(let e=0;e<o.current.length;e++){let t=o.current[e],r=s.current[e],i={...l.current,...c.current,...t.options},a=Pr(i.target)?i.target.current:i.target??(typeof document<`u`?document:null);if(!a)continue;let u=`${e}:${r}`;n.push({registrationKey:u,def:t,hotkeyStr:r,mergedOptions:i,resolvedTarget:a})}let r=new Set(n.map(e=>e.registrationKey));for(let[t,n]of e)!r.has(t)&&n.handle.isActive&&n.handle.unregister();for(let r of n){let{registrationKey:n,def:i,hotkeyStr:a,mergedOptions:o,resolvedTarget:s}=r,c=e.get(n);if(c?.handle.isActive&&c.target===s){t.set(n,c);continue}c?.handle.isActive&&c.handle.unregister();let l=u.current.register(a,i.callback,{...o,target:s});t.set(n,{handle:l,target:s})}a.current=t}),(0,Z.useEffect)(()=>()=>{for(let{handle:e}of a.current.values())e.isActive&&e.unregister();a.current=new Map},[]);for(let r=0;r<e.length;r++){let i=e[r],o=d[r],s=`${r}:${o}`,c=a.current.get(s)?.handle;if(c?.isActive){c.callback=i.callback;let{target:e,...r}={...n,...t,...i.options};c.setOptions(r)}}}var Ki=B();function qi(e,t){return e===t}function Ji(e,t=e=>e,n){let r=n?.compare??qi,i=(0,Z.useCallback)(t=>{let{unsubscribe:n}=e.subscribe(t);return n},[e]),a=(0,Z.useCallback)(()=>e.get(),[e]);return(0,Ki.useSyncExternalStoreWithSelector)(i,a,a,t,r)}var Yi=0;function Xi(e,t={}){let{preventScroll:n=!1,cancelPrevious:r=!0,sync:i=!1}=t;r&&cancelAnimationFrame(Yi);let a=()=>e?.focus({preventScroll:n});if(i)return a(),zt;let o=requestAnimationFrame(a);return Yi=o,()=>{Yi===o&&(cancelAnimationFrame(o),Yi=0)}}var Zi={inert:new WeakMap,"aria-hidden":new WeakMap},Qi=`data-base-ui-inert`,$i={inert:new WeakSet,"aria-hidden":new WeakSet},ea=new WeakMap,ta=0;function na(e){return $i[e]}function ra(e){return e?$e(e)?e.host:ra(e.parentNode):null}var ia=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=ra(t);return e.contains(n)?n:null}).filter(e=>e!=null),aa=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},oa=(e,t,n)=>{let r=[],i=e=>{!e||n.has(e)||Array.from(e.children).forEach(e=>{F(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function sa(e,t,n,r,{mark:i=!0,markerIgnoreElements:a=[]}){let o=r?`inert`:n?`aria-hidden`:null,s=null,c=null,l=ia(t,e),u=i?ia(t,a):[],d=new Set(u),f=i?oa(t,aa(l),new Set(l)).filter(e=>!d.has(e)):[],p=[],m=[];if(o){let e=Zi[o],n=na(o);c=n,s=e;let r=ia(t,Array.from(t.querySelectorAll(`[aria-live]`))),i=l.concat(r);oa(t,aa(i),new Set(i)).forEach(t=>{let r=t.getAttribute(o),i=r!==null&&r!==`false`,a=(e.get(t)||0)+1;e.set(t,a),p.push(t),a===1&&i&&n.add(t),i||t.setAttribute(o,o===`inert`?``:`true`)})}return i&&f.forEach(e=>{let t=(ea.get(e)||0)+1;ea.set(e,t),m.push(e),t===1&&e.setAttribute(Qi,``)}),ta+=1,()=>{s&&p.forEach(e=>{let t=(s.get(e)||0)-1;s.set(e,t),t||(!c?.has(e)&&o&&e.removeAttribute(o),c?.delete(e))}),i&&m.forEach(e=>{let t=(ea.get(e)||0)-1;ea.set(e,t),t||e.removeAttribute(Qi)}),--ta,ta||(Zi.inert=new WeakMap,Zi[`aria-hidden`]=new WeakMap,$i.inert=new WeakSet,$i[`aria-hidden`]=new WeakSet,ea=new WeakMap)}}function ca(e,t={}){let{ariaHidden:n=!1,inert:r=!1,mark:i=!0,markerIgnoreElements:a=[]}=t,o=_e(e[0]).body;return sa(e,o,n,r,{mark:i,markerIgnoreElements:a})}function la(e,t){let n=Ge(pe(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||`keyboard`:`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var ua=20,da=[];function fa(){da=da.filter(e=>e.deref()?.isConnected)}function pa(e){fa(),e&&F(e)!==`body`&&(da.push(new WeakRef(e)),da.length>ua&&(da=da.slice(-ua)))}function ma(){return fa(),da[da.length-1]?.deref()}function ha(e){return e?St(e)?e:At(e)[0]||e:null}function ga(e){return!e||!e.isConnected?!1:typeof e.checkVisibility==`function`?e.checkVisibility():mt(e)}function _a(e,t){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!t.current.includes(`floating`)&&!e.getAttribute(`role`)?.includes(`dialog`))return;let n=dt(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return St(e)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),r=e.getAttribute(`tabindex`);t.current.includes(`floating`)||n.length===0?r!==`0`&&e.setAttribute(`tabindex`,`0`):(r!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}function va(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,restoreFocus:o=!1,modal:s=!0,closeOnFocusOut:c=!0,openInteractionType:l=``,nextFocusableElement:u,previousFocusableElement:f,beforeContentFocusGuardRef:p,externalTree:m,getInsideElements:_}=e,v=`rootStore`in t?t.rootStore:t,b=v.useState(`open`),x=v.useState(`domReferenceElement`),S=v.useState(`floatingElement`),{events:w,dataRef:T}=v.context,E=J(()=>T.current.floatingContext?.nodeId),D=i===!1,O=qn(x)&&D,k=Z.useRef([`content`]),A=Te(i),j=Te(a),M=Te(l),N=wn(m),P=Ze(),F=Z.useRef(!1),I=Z.useRef(!1),R=Z.useRef(!1),B=Z.useRef(null),V=Z.useRef(``),H=Z.useRef(``),U=Z.useRef(null),W=Z.useRef(null),G=ir(U,p,P?.beforeInsideRef),ee=ir(W,P?.afterInsideRef),K=Pe(),ne=Pe(),q=z(),re=P!=null,Y=h(S),ie=J((e=Y)=>e?At(e):[]),ae=J(()=>_?.().filter(e=>e!=null)??[]);Z.useEffect(()=>{if(r||!s)return;function e(e){e.key===`Tab`&&y(Y,C(_e(Y)))&&ie().length===0&&!O&&ht(e)}return Ve(_e(Y),`keydown`,e)},[r,x,Y,s,k,O,ie]),Z.useEffect(()=>{if(r||!b)return;let e=_e(Y);function t(){R.current=!1}function n(e){let t=pe(e),n=ae();R.current=!(y(S,t)||y(x,t)||y(P?.portalNode,t)||n.some(e=>e===t||y(e,t))),H.current=e.pointerType||`keyboard`,t?.closest(`[data-base-ui-click-trigger]`)&&(I.current=!0)}function i(){H.current=`keyboard`}return d(Ve(e,`pointerdown`,n,!0),Ve(e,`pointerup`,t,!0),Ve(e,`pointercancel`,t,!0),Ve(e,`keydown`,i,!0))},[r,S,x,Y,b,P,ae]),Z.useEffect(()=>{if(r||!c)return;let e=_e(Y);function t(){I.current=!0,ne.start(0,()=>{I.current=!1})}function n(e){let t=pe(e);St(t)&&(B.current=t)}function i(t){let n=t.relatedTarget,r=t.currentTarget,i=pe(t);queueMicrotask(()=>{let a=E(),c=v.context.triggerElements,l=ae(),d=n?.hasAttribute(un(`focus-guard`))&&[U.current,W.current,P?.beforeInsideRef.current,P?.afterInsideRef.current,P?.beforeOutsideRef.current,P?.afterOutsideRef.current,L(f),L(u)].includes(n),p=!(y(x,n)||y(S,n)||y(n,S)||y(P?.portalNode,n)||l.some(e=>e===n||y(e,n))||n!=null&&c.hasElement(n)||c.hasMatchingElement(e=>y(e,n))||d||N&&(Ut(N.nodesRef.current,a).find(e=>y(e.context?.elements.floating,n)||y(e.context?.elements.domReference,n))||Dn(N.nodesRef.current,a).find(e=>[e.context?.elements.floating,h(e.context?.elements.floating)].includes(n)||e.context?.elements.domReference===n)));if(r===x&&Y&&_a(Y,k),o&&r!==x&&!ga(i)&&C(e)===e.body){if(te(Y)&&(Y.focus(),o===`popup`)){q.request(()=>{Y.focus()});return}let e=ie(),t=B.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||Y;te(n)&&n.focus()}if(T.current.insideReactTree){T.current.insideReactTree=!1;return}(O||!s)&&n&&p&&!I.current&&(O||n!==ma())&&(F.current=!0,v.setOpen(!1,Ye(Dt,t)))})}function a(){R.current||(T.current.insideReactTree=!0,K.start(0,()=>{T.current.insideReactTree=!1}))}let l=te(x)?x:null;if(!(!S&&!l))return d(l&&Ve(l,`focusout`,i),l&&Ve(l,`pointerdown`,t),S&&Ve(S,`focusin`,n),S&&Ve(S,`focusout`,i),S&&P&&Ve(S,`focusout`,a,!0))},[r,x,S,Y,s,N,P,v,c,o,ie,O,E,k,T,K,ne,q,u,f,ae]),Z.useEffect(()=>{if(r||!S||!b)return;let e=Array.from(P?.portalNode?.querySelectorAll(`[${un(`portal`)}]`)||[]),t=(N?Dn(N.nodesRef.current,E()):[]).find(e=>qn(e.context?.elements.domReference||null))?.context?.elements.domReference,n=ca([...[S,...e,U.current,W.current,P?.beforeOutsideRef.current,P?.afterOutsideRef.current,...ae()],t,L(f),L(u),O?x:null].filter(e=>e!=null),{ariaHidden:s||O,mark:!1}),i=ca([S,...e].filter(e=>e!=null));return()=>{i(),n()}},[b,r,x,S,s,k,P,O,N,E,u,f,ae]),me(()=>{if(!b||r||!te(Y))return;let e=C(_e(Y));queueMicrotask(()=>{let t=A.current,n=typeof t==`function`?t(M.current||``):t;if(n===void 0||n===!1||y(Y,e))return;let r=null,i=()=>(r??=ie(Y),r[0]||Y),a;a=n===!0||n===null?i():L(n),a||=i(),Xi(a,{preventScroll:a===Y})})},[r,b,Y,D,ie,A,M]),me(()=>{if(r||!Y)return;let e=_e(Y);pa(C(e));function t(e){if(e.open||(V.current=la(e.nativeEvent,H.current)),e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`&&(F.current=!0),e.reason===`outside-press`)if(e.nested)F.current=!1;else if(Wn(e.nativeEvent)||nr(e.nativeEvent))F.current=!1;else{let e=!1;_e(Y).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?F.current=!1:F.current=!0}}w.on(`openchange`,t);function n(){let e=j.current,t=typeof e==`function`?e(V.current):e;if(t===void 0||t===!1)return null;if(t===null&&(t=!0),typeof t==`boolean`){let e=x||ma();return e&&e.isConnected?e:null}let n=x||ma();return L(t)||n||null}return()=>{w.off(`openchange`,t);let r=C(e),i=ae(),a=y(S,r)||i.some(e=>e===r||y(e,r))||N&&Ut(N.nodesRef.current,E(),!1).some(e=>y(e.context?.elements.floating,r)),o=j.current,s=n();queueMicrotask(()=>{let t=ha(s),n=typeof o!=`boolean`;o&&!F.current&&te(t)&&(!(!n&&t!==r&&r!==e.body)||a)&&t.focus({preventScroll:!0}),F.current=!1})}},[r,S,Y,j,T,w,N,x,E,ae]),me(()=>{if(!g||b||!S)return;let e=C(_e(S));!te(e)||!Ne(e)||y(S,e)&&e.blur()},[b,S]),me(()=>{if(!(r||!P))return P.setFocusManagerState({modal:s,closeOnFocusOut:c,open:b,onOpenChange:v.setOpen,domReference:x}),()=>{P.setFocusManagerState(null)}},[r,P,s,b,v,c,x]),me(()=>{if(!(r||!Y))return _a(Y,k),()=>{queueMicrotask(fa)}},[r,Y,k]);let oe=!r&&(s?!O:!0)&&(re||s);return(0,Q.jsxs)(Z.Fragment,{children:[oe&&(0,Q.jsx)(le,{"data-type":`inside`,ref:G,onFocus:e=>{if(s){let e=ie();Xi(e[e.length-1])}else P?.portalNode&&(F.current=!1,zn(e,P.portalNode)?mn(x)?.focus():L(f??P.beforeOutsideRef)?.focus())}}),n,oe&&(0,Q.jsx)(le,{"data-type":`inside`,ref:ee,onFocus:e=>{s?Xi(ie()[0]):P?.portalNode&&(c&&(F.current=!0),zn(e,P.portalNode)?jn(x)?.focus():L(u??P.afterOutsideRef)?.focus())}})]})}function ya(e,t={}){let n=`rootStore`in e?e.rootStore:e,r=n.context.dataRef,{enabled:i=!0,event:a=`click`,toggle:o=!0,ignoreMouse:s=!1,stickIfOpen:c=!0,touchOpenDelay:l=0,reason:u=nn}=t,d=Z.useRef(void 0),f=z(),p=Pe(),m=Z.useMemo(()=>({onPointerDown(e){d.current=e.pointerType},onMouseDown(e){let t=d.current,i=e.nativeEvent,m=n.select(`open`);if(e.button!==0||a===`click`||ct(t,!0)&&s)return;let h=r.current.openEvent,g=h?.type,_=n.select(`domReferenceElement`)!==e.currentTarget,v=m&&_||!(m&&o&&(!(h&&c)||g===`click`||g===`mousedown`)),y=pe(i);if(Ne(y)){let e=Ye(u,i,y);v&&t===`touch`&&l>0?p.start(l,()=>{n.setOpen(!0,e)}):n.setOpen(v,e);return}let b=e.currentTarget;f.request(()=>{let e=Ye(u,i,b);v&&t===`touch`&&l>0?p.start(l,()=>{n.setOpen(!0,e)}):n.setOpen(v,e)})},onClick(e){if(a===`mousedown-only`)return;let t=d.current;if(a===`mousedown`&&t){d.current=void 0;return}if(ct(t,!0)&&s)return;let i=n.select(`open`),f=r.current.openEvent,m=n.select(`domReferenceElement`)!==e.currentTarget,h=i&&m||!(i&&o&&(!(f&&c)||Ft(f))),g=Ye(u,e.nativeEvent,e.currentTarget);h&&t===`touch`&&l>0?p.start(l,()=>{n.setOpen(!0,g)}):n.setOpen(h,g)},onKeyDown(){d.current=void 0}}),[r,a,s,n,c,o,f,p,l,u]);return Z.useMemo(()=>i?{reference:m}:sn,[i,m])}function nee(e){let t=e.currentTarget.getBoundingClientRect();return t.top+1<=e.clientY&&e.clientY<=t.bottom-1&&t.left+1<=e.clientX&&e.clientX<=t.right-1}var ree=`Escape`;function ba(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function xa(e,t){return ba(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function Sa(e,t,n){return ba(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function Ca(e,t,n){return ba(t,n?e===s:e===qt,e===Zt)}function wa(e,t,n,r){return t===`both`||t===`horizontal`&&r&&r>1?e===ree:ba(t,n?e===qt:e===s,e===ae)}function Ta(e,t){let n=`rootStore`in e?e.rootStore:e,r=n.useState(`open`),i=n.useState(`floatingElement`),a=n.useState(`domReferenceElement`),o=n.context.dataRef,{listRef:s,activeIndex:c,onNavigate:l=()=>{},enabled:u=!0,selectedIndex:d=null,allowEscape:f=!1,loopFocus:p=!1,nested:m=!1,rtl:g=!1,virtual:_=!1,focusItemOnOpen:v=`auto`,focusItemOnHover:b=!0,openOnArrowKeyDown:x=!0,disabledIndices:S=void 0,orientation:w=`vertical`,parentOrientation:T,cols:E=1,id:D,resetOnPointerLeave:O=!0,externalTree:k}=t,A=Te(h(i)),j=ne(),M=wn(k);me(()=>{o.current.orientation=w},[o,w]);let N=qn(a),P=Z.useRef(v),F=Z.useRef(d??-1),I=Z.useRef(null),L=Z.useRef(!0),R=J(e=>{l(F.current===-1?null:F.current,e)}),z=Z.useRef(R),B=Z.useRef(!!i),V=Z.useRef(r),H=Z.useRef(!1),U=Z.useRef(!1),W=Z.useRef(null),G=Te(S),ee=Te(r),K=Te(d),q=Te(O),re=J(()=>{function e(e){_?M?.events.emit(`virtualfocus`,e):W.current=Xi(e,{sync:H.current,preventScroll:!0})}let t=s.current[F.current],n=U.current;t&&e(t),(H.current?e=>e():requestAnimationFrame)(()=>{let r=s.current[F.current]||t;r&&(t||e(r),ae&&(n||!L.current)&&r.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});me(()=>{u&&(r&&i?(F.current=d??-1,P.current&&d!=null&&(U.current=!0,R())):B.current&&(F.current=-1,z.current()))},[u,r,i,d,R]),me(()=>{if(u){if(!r){H.current=!1;return}if(i)if(c==null){if(H.current=!1,K.current!=null)return;if(B.current&&(F.current=-1,re()),(!V.current||!B.current)&&P.current&&(I.current!=null||P.current===!0&&I.current==null)){let e=0,t=()=>{s.current[0]==null?(e<2&&(e?requestAnimationFrame:queueMicrotask)(t),e+=1):(F.current=I.current==null||Sa(I.current,w,g)||m?tr(s):Un(s),I.current=null,R())};t()}}else Zn(s.current,c)||(F.current=c,re(),U.current=!1)}},[u,r,i,c,K,m,s,w,g,R,re,G]),me(()=>{if(!u||i||!M||_||!B.current)return;let e=M.nodesRef.current,t=e.find(e=>e.id===j)?.context?.elements.floating,n=C(_e(i)),r=e.some(e=>e.context&&y(e.context.elements.floating,n));t&&!r&&L.current&&t.focus({preventScroll:!0})},[u,i,M,j,_]),me(()=>{z.current=R,V.current=r,B.current=!!i}),me(()=>{r||(I.current=null,P.current=v)},[r,v]);let Y=c!=null,ie=J(e=>{if(!ee.current)return;let t=s.current.indexOf(e.currentTarget);t!==-1&&(F.current!==t||c!==t)&&(F.current=t,R(e))}),ae=Z.useMemo(()=>({onFocus(e){H.current=!0,ie(e)},onClick:({currentTarget:e})=>e.focus({preventScroll:!0}),onMouseMove(e){H.current=!0,U.current=!1,b&&ie(e)},onPointerLeave(e){if(!ee.current||!L.current||e.pointerType===`touch`)return;H.current=!0;let t=e.relatedTarget;if(!nee(e)&&!(!b||s.current.includes(t))&&q.current&&(W.current?.(),W.current=null,F.current=-1,R(e),!_)){let e=A.current,t=C(_e(e));e&&y(e,t)&&e.focus({preventScroll:!0})}}}),[ie,ee,A,b,s,R,q,_]),oe=Z.useCallback(()=>T??M?.nodesRef.current.find(e=>e.id===j)?.context?.dataRef?.current.orientation,[j,M,T]),se=J(e=>{if(L.current=!1,H.current=!0,e.which===229||!ee.current&&e.currentTarget===A.current)return;if(m&&wa(e.key,w,g,E)){xa(e.key,oe())||ht(e),n.setOpen(!1,Ye(On,e.nativeEvent)),te(a)&&(_?M?.events.emit(`virtualfocus`,a):a.focus());return}let t=F.current,i=tr(s,S),o=Un(s,S);if(N||(e.key===`Home`&&(ht(e),F.current=i,R(e)),e.key===`End`&&(ht(e),F.current=o,R(e))),E>1){let t=Array.from({length:s.current.length},()=>({width:1,height:1})),n=vn(t,E,!1),r=n.findIndex(e=>e!=null&&!ke(s.current,e,S)),a=n.reduce((e,t,n)=>t!=null&&!ke(s.current,t,S)?n:e,-1),c=n[st(n.map(e=>e==null?null:s.current[e]),{event:e,orientation:w,loopFocus:p,rtl:g,cols:E,disabledIndices:Pt([...(typeof S==`function`?null:S)||s.current.map((e,t)=>ke(s.current,t,S)?t:void 0),void 0],n),minIndex:r,maxIndex:a,prevIndex:Rt(F.current>o?i:F.current,t,n,E,e.key===`ArrowDown`?`bl`:e.key===(g?`ArrowLeft`:`ArrowRight`)?`tr`:`tl`),stopEvent:!0})];if(c!=null&&(F.current=c,R(e)),w===`both`)return}if(xa(e.key,w)){if(ht(e),r&&!_&&C(e.currentTarget.ownerDocument)===e.currentTarget){F.current=Sa(e.key,w,g)?i:o,R(e);return}Sa(e.key,w,g)?p?t>=o?f&&t!==s.current.length?F.current=-1:(H.current=!1,F.current=i):F.current=on(s.current,{startingIndex:t,disabledIndices:S}):F.current=Math.min(o,on(s.current,{startingIndex:t,disabledIndices:S})):p?t<=i?f&&t!==-1?F.current=s.current.length:(H.current=!1,F.current=o):F.current=on(s.current,{startingIndex:t,decrement:!0,disabledIndices:S}):F.current=Math.max(i,on(s.current,{startingIndex:t,decrement:!0,disabledIndices:S})),Zn(s.current,F.current)&&(F.current=-1),R(e)}}),ce=Z.useMemo(()=>_&&r&&Y&&{"aria-activedescendant":`${D}-${c}`},[_,r,Y,D,c]),le=Z.useMemo(()=>({"aria-orientation":w===`both`?void 0:w,...N?{}:ce,onKeyDown(e){if(e.key===`Tab`&&e.shiftKey&&r&&!_){let t=pe(e.nativeEvent);if(t&&!y(A.current,t))return;ht(e),n.setOpen(!1,Ye(Dt,e.nativeEvent)),te(a)&&a.focus();return}se(e)},onPointerMove(){L.current=!0}}),[ce,se,A,w,N,n,r,_,a]),ue=Z.useMemo(()=>{function e(e){v===`auto`&&Wn(e.nativeEvent)&&(P.current=!_)}function t(e){P.current=v,v===`auto`&&nr(e.nativeEvent)&&(P.current=!0)}return{onKeyDown(e){let t=n.select(`open`);L.current=!1;let r=e.key.startsWith(`Arrow`),i=Ca(e.key,oe(),g),a=xa(e.key,w),o=(m?i:a)||e.key===`Enter`||e.key.trim()===``;if(_&&t)return se(e);if(!(!t&&!x&&r)){if(o){let t=xa(e.key,oe());I.current=m&&t?null:e.key}if(m){i&&(ht(e),t?(F.current=tr(s,G.current),R(e)):n.setOpen(!0,Ye(On,e.nativeEvent,e.currentTarget)));return}a&&(K.current!=null&&(F.current=K.current),ht(e),!t&&x?n.setOpen(!0,Ye(On,e.nativeEvent,e.currentTarget)):se(e),t&&R(e))}},onFocus(e){n.select(`open`)&&!_&&(F.current=-1,R(e))},onPointerDown:t,onPointerEnter:t,onMouseDown:e,onClick:e}},[se,G,v,s,m,R,n,x,w,oe,g,K,_]),de=Z.useMemo(()=>({...ce,...ue}),[ce,ue]);return Z.useMemo(()=>u?{reference:de,floating:le,item:ae,trigger:ue}:{},[u,de,le,ue,ae])}var Ea=new Map([[`select`,`listbox`],[`combobox`,`listbox`],[`label`,!1]]);function Da(e,t={}){let n=`rootStore`in e?e.rootStore:e,r=n.useState(`open`),i=n.useState(`floatingId`),a=n.useState(`domReferenceElement`),o=n.useState(`floatingElement`),{role:s=`dialog`}=t,c=Fn(),l=a?.id||c,u=Z.useMemo(()=>h(o)?.id||i,[o,i]),d=Ea.get(s)??s,f=ne()!=null,p=Z.useMemo(()=>d===`tooltip`||s===`label`?sn:{"aria-haspopup":d===`alertdialog`?`dialog`:d,"aria-expanded":`false`,...d===`listbox`&&{role:`combobox`},...d===`menu`&&f&&{role:`menuitem`},...s===`select`&&{"aria-autocomplete":`none`},...s===`combobox`&&{"aria-autocomplete":`list`}},[d,f,s]),m=Z.useMemo(()=>d===`tooltip`||s===`label`?{[`aria-${s===`label`?`labelledby`:`describedby`}`]:r?u:void 0}:{...p,"aria-expanded":r?`true`:`false`,"aria-controls":r?u:void 0,...d===`menu`&&{id:l}},[d,u,r,l,s,p]),g=Z.useMemo(()=>{let e={id:u,...d&&{role:d}};return d===`tooltip`||s===`label`?e:{...e,...d===`menu`&&{"aria-labelledby":l}}},[d,u,l,s]),_=Z.useCallback(({active:e,selected:t})=>{let n={role:`option`,...e&&{id:`${u}-fui-option`}};switch(s){case`select`:case`combobox`:return{...n,"aria-selected":t};default:}return{}},[u,s]);return Z.useMemo(()=>({reference:m,floating:g,item:_,trigger:p}),[m,g,p,_])}function Oa(e,t){let n=`rootStore`in e?e.rootStore:e,r=n.context.dataRef,i=n.useState(`open`),{listRef:a,elementsRef:o,activeIndex:s,onMatch:c,onTypingChange:l,enabled:u=!0,resetMs:d=750,selectedIndex:f=null}=t,p=Pe(),m=Z.useRef(``),h=Z.useRef(f??s??-1),g=Z.useRef(null);me(()=>{!i&&f!==null||(p.clear(),g.current=null,m.current!==``&&(m.current=``))},[i,f,p]),me(()=>{i&&m.current===``&&(h.current=f??s??-1)},[i,f,s]);let _=J(e=>{e?r.current.typing||(r.current.typing=e,l?.(e)):r.current.typing&&(r.current.typing=e,l?.(e))}),v=J(e=>{function t(e){let t=o?.current[e];return!t||mt(t)}function n(e,n,r=0){if(e.length===0)return-1;let i=(r%e.length+e.length)%e.length,a=n.toLocaleLowerCase();for(let n=0;n<e.length;n+=1){let r=(i+n)%e.length;if(!(!e[r]?.toLocaleLowerCase().startsWith(a)||!t(r)))return r}return-1}let r=a.current;if(m.current.length>0&&e.key===` `&&(ht(e),_(!0)),m.current.length>0&&m.current[0]!==` `&&n(r,m.current)===-1&&e.key!==` `&&_(!1),r==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;i&&e.key!==` `&&(ht(e),_(!0));let l=m.current===``;l&&(h.current=f??s??-1),r.every(e=>e?e[0]?.toLocaleLowerCase()!==e[1]?.toLocaleLowerCase():!0)&&m.current===e.key&&(m.current=``,h.current=g.current),m.current+=e.key,p.start(d,()=>{m.current=``,h.current=g.current,_(!1)});let u=((l?f??s??-1:h.current)??0)+1,v=n(r,m.current,u);v===-1?e.key!==` `&&(m.current=``,_(!1)):(c?.(v),g.current=v)}),b=J(e=>{let t=e.relatedTarget,r=n.select(`domReferenceElement`),i=n.select(`floatingElement`),a=y(r,t),o=y(i,t);a||o||(p.clear(),m.current=``,h.current=g.current,_(!1))}),x=Z.useMemo(()=>({onKeyDown:v,onBlur:b}),[v,b]),S=Z.useMemo(()=>({onKeyDown:v,onBlur:b}),[v,b]);return Z.useMemo(()=>u?{reference:x,floating:S}:{},[u,x,S])}function ka(e){return Et(19)?e:e?`true`:void 0}var Aa=bt(`arrow-up-to-line`,[[`path`,{d:`M5 3h14`,key:`7usisc`}],[`path`,{d:`m18 13-6-6-6 6`,key:`1kf1n9`}],[`path`,{d:`M12 7v14`,key:`1akyts`}]]),ja=bt(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Ma=bt(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Na=bt(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Pa=bt(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),Fa=bt(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Ia=bt(`copy`,[[`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`}]]),La=bt(`download`,[[`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`}]]),Ra=bt(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),za=bt(`ellipsis`,[[`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`}]]),Ba=bt(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`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`}]]),Va=bt(`folder`,[[`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`}]]),Ha=bt(`git-commit-horizontal`,[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]]),Ua=bt(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),Wa=bt(`image-plus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),Ga=bt(`list-end`,[[`path`,{d:`M16 5H3`,key:`m91uny`}],[`path`,{d:`M16 12H3`,key:`1a2rj7`}],[`path`,{d:`M9 19H3`,key:`s61nz1`}],[`path`,{d:`m16 16-3 3 3 3`,key:`117b85`}],[`path`,{d:`M21 5v12a2 2 0 0 1-2 2h-6`,key:`hey24a`}]]),Ka=bt(`list-start`,[[`path`,{d:`M3 5h6`,key:`1ltk0q`}],[`path`,{d:`M3 12h13`,key:`ppymz1`}],[`path`,{d:`M3 19h13`,key:`bpdczq`}],[`path`,{d:`m16 8-3-3 3-3`,key:`1pjpp6`}],[`path`,{d:`M21 19V7a2 2 0 0 0-2-2h-6`,key:`4zzq67`}]]),qa=bt(`panel-left-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]]),Ja=bt(`panel-left-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),Ya=bt(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),Xa=bt(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),Za=bt(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Qa=bt(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),$a=bt(`square-arrow-out-up-right`,[[`path`,{d:`M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6`,key:`y09zxi`}],[`path`,{d:`m21 3-9 9`,key:`mpx6sq`}],[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}]]),eo=bt(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),iee=bt(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),to=bt(`upload`,[[`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`}]]),aee=bt(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),no=bt(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function oee(e){return typeof e==`function`}function ro(e,...t){return oee(e)?e(...t):e}var see=class{#e=!0;#t;#n;#r;#i;#a;#o;#s;#c=0;#l=5;#u=!1;#d=!1;#f=null;#p=()=>{this.debugLog(`Connected to event bus`),this.#a=!0,this.#u=!1,this.debugLog(`Emitting queued events`,this.#i),this.#i.forEach(e=>this.emitEventToBus(e)),this.#i=[],this.stopConnectLoop(),this.#n().removeEventListener(`tanstack-connect-success`,this.#p)};#m=()=>{if(this.#c<this.#l){this.#c++,this.dispatchCustomEvent(`tanstack-connect`,{});return}this.#n().removeEventListener(`tanstack-connect`,this.#m),this.#d=!0,this.debugLog(`Max retries reached, giving up on connection`),this.stopConnectLoop()};#h=()=>{this.#u||(this.#u=!0,this.#n().addEventListener(`tanstack-connect-success`,this.#p),this.#m())};constructor({pluginId:e,debug:t=!1,enabled:n=!0,reconnectEveryMs:r=300}){this.#t=e,this.#e=n,this.#n=this.getGlobalTarget,this.#r=t,this.debugLog(` Initializing event subscription for plugin`,this.#t),this.#i=[],this.#a=!1,this.#d=!1,this.#o=null,this.#s=r}startConnectLoop(){this.#o!==null||this.#a||(this.debugLog(`Starting connect loop (every ${this.#s}ms)`),this.#o=setInterval(this.#m,this.#s))}stopConnectLoop(){this.#u=!1,this.#o!==null&&(clearInterval(this.#o),this.#o=null,this.#i=[],this.debugLog(`Stopped connect loop`))}debugLog(...e){this.#r&&console.log(`🌴 [tanstack-devtools:${this.#t}-plugin]`,...e)}getGlobalTarget(){if(typeof globalThis<`u`&&globalThis.__TANSTACK_EVENT_TARGET__)return this.debugLog(`Using global event target`),globalThis.__TANSTACK_EVENT_TARGET__;if(typeof window<`u`&&window.addEventListener!==void 0)return this.debugLog(`Using window as event target`),window;let e=typeof EventTarget<`u`?new EventTarget:void 0;return e===void 0||e.addEventListener===void 0?(this.debugLog(`No event mechanism available, running in non-web environment`),{addEventListener:()=>{},removeEventListener:()=>{},dispatchEvent:()=>!1}):(this.debugLog(`Using new EventTarget as fallback`),e)}getPluginId(){return this.#t}dispatchCustomEventShim(e,t){try{let n=new Event(e,{detail:t});this.#n().dispatchEvent(n)}catch{this.debugLog(`Failed to dispatch shim event`)}}dispatchCustomEvent(e,t){try{this.#n().dispatchEvent(new CustomEvent(e,{detail:t}))}catch{this.dispatchCustomEventShim(e,t)}}emitEventToBus(e){this.debugLog(`Emitting event to client bus`,e),this.dispatchCustomEvent(`tanstack-dispatch-event`,e)}createEventPayload(e,t){return{type:`${this.#t}:${e}`,payload:t,pluginId:this.#t}}emit(e,t){if(!this.#e){this.debugLog(`Event bus client is disabled, not emitting event`,e,t);return}if(this.#f&&(this.debugLog(`Emitting event to internal event target`,e,t),this.#f.dispatchEvent(new CustomEvent(`${this.#t}:${e}`,{detail:this.createEventPayload(e,t)}))),this.#d){this.debugLog(`Previously failed to connect, not emitting to bus`);return}if(!this.#a){this.debugLog(`Bus not available, will be pushed as soon as connected`),this.#i.push(this.createEventPayload(e,t)),typeof CustomEvent<`u`&&!this.#u&&(this.#h(),this.startConnectLoop());return}return this.emitEventToBus(this.createEventPayload(e,t))}on(e,t,n){let r=n?.withEventTarget??!1,i=`${this.#t}:${e}`;if(r&&(this.#f||=new EventTarget,this.#f.addEventListener(i,e=>{t(e.detail)})),!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`,i),()=>{};let a=e=>{this.debugLog(`Received event from bus`,e.detail),t(e.detail)};return this.#n().addEventListener(i,a),this.debugLog(`Registered event to bus`,i),()=>{r&&this.#f?.removeEventListener(i,a),this.#n().removeEventListener(i,a)}}onAll(e){if(!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`),()=>{};let t=t=>{let n=t.detail;e(n)};return this.#n().addEventListener(`tanstack-devtools-global`,t),()=>this.#n().removeEventListener(`tanstack-devtools-global`,t)}onAllPluginEvents(e){if(!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`),()=>{};let t=t=>{let n=t.detail;this.#t&&n.pluginId!==this.#t||e(n)};return this.#n().addEventListener(`tanstack-devtools-global`,t),()=>this.#n().removeEventListener(`tanstack-devtools-global`,t)}},io=new Map;function ao(e,t){io.set(e,t)}function oo(e){if(e!==void 0)try{return JSON.parse(JSON.stringify(e))}catch{return null}}function so(e){return typeof e.get==`function`?e.get():e.state}function co(e){return{key:e.key,store:{state:oo(so(e.store))},options:oo(e.options)}}var lo=class extends see{constructor(e){super({pluginId:`pacer`,debug:e?.debug,reconnectEveryMs:1e3})}},uo=(e,t)=>{let n=t.key;n&&(ao(n,t),fo.emit(e,co({...t,key:n})))},fo=new lo;function po(){return{currentAttempt:0,executionCount:0,isExecuting:!1,lastError:void 0,lastExecutionTime:0,lastResult:void 0,status:`idle`,totalExecutionTime:0}}var mo={backoff:`exponential`,baseWait:1e3,maxWait:1/0,enabled:!0,jitter:0,maxAttempts:3,maxExecutionTime:1/0,maxTotalExecutionTime:1/0,throwOnError:`last`},ho=class{#e;constructor(e,t={}){this.fn=e,this.store=new Li(po()),this.#e=null,this.setOptions=e=>{this.options={...this.options,...e}},this.#t=e=>{this.store.setState(t=>{let n={...t,...e},{isExecuting:r,currentAttempt:i}=n;return{...n,status:this.#n()?r&&i===1?`executing`:r&&i>1?`retrying`:`idle`:`disabled`}}),uo(`AsyncRetryer`,this)},this.#n=()=>!!ro(this.options.enabled,this),this.#r=()=>ro(this.options.maxAttempts,this),this.#i=()=>ro(this.options.baseWait,this),this.#a=()=>ro(this.options.maxWait,this),this.#o=e=>{let t=this.options.jitter;if(t<=0)return 0;try{let n=typeof globalThis<`u`?globalThis.crypto:void 0;if(n?.getRandomValues){let r=new Uint32Array(1);n.getRandomValues(r);let i=r[0]/4294967295*2-1;return Math.floor(e*t*i)}}catch{}return 0},this.#s=e=>{let t=this.#i(),n;switch(this.options.backoff){case`linear`:n=t*e;break;case`exponential`:n=t*2**(e-1);break;default:n=t;break}n=Math.min(n,this.#a());let r=this.#o(n);return Math.max(0,n+r)},this.execute=async(...e)=>{if(!this.#n())return;this.abort(`new-execution`);let t=Date.now(),n,r;this.#e=new AbortController;let i=this.#e.signal;this.#t({isExecuting:!0,currentAttempt:0,lastError:void 0});let a;this.options.maxTotalExecutionTime!==1/0&&(a=setTimeout(()=>{this.options.onTotalExecutionTimeout?.(this),this.abort(`total-timeout`)},this.options.maxTotalExecutionTime));let o=!1;for(let a=1;a<=this.#r();a++){o=a===this.#r(),this.#t({currentAttempt:a});try{if(i.aborted)return;let n=Date.now()-t;if(this.options.maxTotalExecutionTime!==1/0&&n>=this.options.maxTotalExecutionTime){this.options.onTotalExecutionTimeout?.(this),this.abort(`total-timeout`);return}if(r=this.options.maxExecutionTime===1/0?await this.fn(...e):await Promise.race([this.fn(...e),new Promise((e,t)=>{let n=setTimeout(()=>{this.options.onExecutionTimeout?.(this),this.abort(`execution-timeout`),t(Error(`Execution timeout: ${this.options.maxExecutionTime}ms exceeded`))},this.options.maxExecutionTime);i.addEventListener(`abort`,()=>{clearTimeout(n),t(Error(`Aborted`))},{once:!0})})]),i.aborted)return;let a=Date.now()-t;return this.#t({executionCount:this.store.state.executionCount+1,isExecuting:!1,lastExecutionTime:Date.now(),totalExecutionTime:a,currentAttempt:0,lastResult:r}),this.options.onSuccess?.(r,e,this),r}catch(t){if(t&&typeof t==`object`&&`name`in t&&t.name===`AbortError`)return;if(n=t instanceof Error?t:Error(String(t)),this.#t({lastError:n}),this.options.onError?.(n,e,this),a<this.#r()){this.options.onRetry?.(a,n,this);let e=this.#s(a);if(e>0&&(this.#t({isExecuting:!0,currentAttempt:a+1}),await new Promise(t=>{let n=setTimeout(()=>{i.removeEventListener(`abort`,r),t()},e),r=()=>{clearTimeout(n),i.removeEventListener(`abort`,r),t()};i.addEventListener(`abort`,r)}),i.aborted))return}}finally{this.options.onSettled?.(e,this)}}if(a&&clearTimeout(a),this.#t({isExecuting:!1}),this.options.onLastError?.(n,this),this.options.onSettled?.(e,this),this.options.throwOnError===`last`&&o||this.options.throwOnError===!0)throw n},this.getAbortSignal=()=>this.#e?.signal??null,this.abort=(e=`manual`)=>{this.#e&&(this.#e.abort(),this.#e=null,this.#t({isExecuting:!1}),this.options.onAbort?.(e,this))},this.reset=()=>{this.#t(po())},this.key=t.key,this.options={...mo,...t,throwOnError:t.throwOnError??(t.onError?!1:mo.throwOnError)},this.#t(this.options.initialState??{}),this.key&&fo.on(`d-AsyncRetryer`,e=>{e.payload.key===this.key&&(this.#t(e.payload.store.state),this.setOptions(e.payload.options))})}#t;#n;#r;#i;#a;#o;#s};function go(){return{canLeadingExecute:!0,errorCount:0,isExecuting:!1,isPending:!1,lastArgs:void 0,lastResult:void 0,maybeExecuteCount:0,settleCount:0,status:`idle`,successCount:0}}var _o={asyncRetryerOptions:{maxAttempts:1},enabled:!0,leading:!1,trailing:!0,wait:0},vo=class{#e;#t;constructor(e,t){this.fn=e,this.store=new Li(go()),this.asyncRetryers=new Map,this.#e=null,this.#t=null,this.setOptions=e=>{this.options={...this.options,...e},this.#r()||this.cancel()},this.#n=e=>{this.store.setState(t=>{let n={...t,...e},{isPending:r,isExecuting:i,settleCount:a}=n;return{...n,status:this.#r()?r?`pending`:i?`executing`:a>0?`settled`:`idle`:`disabled`}}),uo(`AsyncDebouncer`,this)},this.#r=()=>!!ro(this.options.enabled,this),this.#i=()=>ro(this.options.wait,this),this.maybeExecute=async(...e)=>{if(this.#r())return this.#c(),this.#n({lastArgs:e,maybeExecuteCount:this.store.state.maybeExecuteCount+1}),this.options.leading&&this.store.state.canLeadingExecute?(this.#n({canLeadingExecute:!1}),await this.#a(...e),this.store.state.lastResult):(this.options.trailing&&this.#r()&&this.#n({isPending:!0}),new Promise((e,t)=>{this.#t=e,this.#e=setTimeout(async()=>{if(this.options.trailing&&this.store.state.lastArgs)try{await this.#a(...this.store.state.lastArgs)}catch(e){t(e)}this.#n({canLeadingExecute:!0}),this.#t=null,e(this.store.state.lastResult)},this.#i())}))},this.#a=async(...e)=>{if(!this.#r())return;let t=this.store.state.maybeExecuteCount+1;try{this.#n({isExecuting:!0});let n=new ho(this.fn,{...this.options.asyncRetryerOptions,key:`${this.key}-retryer-${t}`});this.asyncRetryers.set(t,n);let r=await n.execute(...e);this.#n({lastResult:r,successCount:this.store.state.successCount+1}),this.options.onSuccess?.(r,e,this)}catch(t){if(this.#n({errorCount:this.store.state.errorCount+1}),this.options.onError?.(t,e,this),this.options.throwOnError)throw t}finally{this.asyncRetryers.delete(t),this.#n({isExecuting:!1,isPending:!1,lastArgs:void 0,settleCount:this.store.state.settleCount+1}),this.options.onSettled?.(e,this)}return this.store.state.lastResult},this.flush=async()=>{if(this.store.state.isPending&&this.store.state.lastArgs){let{lastArgs:e}=this.store.state;return this.#c(),await this.#a(...e)}},this.#o=()=>{this.#t&&=(this.#t(this.store.state.lastResult),null)},this.#s=()=>{this.#e&&=(clearTimeout(this.#e),null)},this.#c=()=>{this.#s(),this.#o(),this.#n({isPending:!1,lastArgs:void 0})},this.getAbortSignal=e=>{let t=e??this.store.state.maybeExecuteCount;return this.asyncRetryers.get(t)?.getAbortSignal()??null},this.abort=()=>{this.asyncRetryers.forEach(e=>e.abort()),this.asyncRetryers.clear(),this.#n({isExecuting:!1})},this.cancel=()=>{this.#c(),this.#n({canLeadingExecute:!0})},this.reset=()=>{this.#n(go()),this.asyncRetryers.forEach(e=>e.reset())},this.key=t.key,this.options={..._o,...t,throwOnError:t.throwOnError??!t.onError},this.#n(this.options.initialState??{}),this.key&&fo.on(`d-AsyncDebouncer`,e=>{e.payload.key===this.key&&(this.#n(e.payload.store.state),this.setOptions(e.payload.options))})}#n;#r;#i;#a;#o;#s;#c};function yo(){return{executionCount:0,isEmpty:!0,isPending:!1,totalItemsProcessed:0,items:[],size:0,status:`idle`}}var bo={getShouldExecute:()=>!1,maxSize:1/0,started:!0,wait:1/0},xo=class{#e;constructor(e,t){this.fn=e,this.store=new Li(yo()),this.#e=null,this.setOptions=e=>{this.options={...this.options,...e}},this.#t=e=>{this.store.setState(t=>{let n={...t,...e},{isPending:r,items:i}=n,a=i.length,o=a===0;return{...n,isEmpty:o,size:a,status:r?`pending`:`idle`}}),uo(`Batcher`,this)},this.#n=()=>ro(this.options.wait,this),this.addItem=e=>{this.#t({items:[...this.store.state.items,e],isPending:this.options.wait!==1/0}),this.options.onItemsChange?.(this),this.store.state.items.length>=this.options.maxSize||this.options.getShouldExecute(this.store.state.items,this)?this.#r():this.options.wait!==1/0&&(this.#i(),this.#e=setTimeout(()=>this.#r(),this.#n()))},this.#r=()=>{if(this.store.state.items.length===0)return;let e=this.peekAllItems();this.clear(),this.options.onItemsChange?.(this),this.fn(e),this.#t({executionCount:this.store.state.executionCount+1,totalItemsProcessed:this.store.state.totalItemsProcessed+e.length}),this.options.onExecute?.(e,this)},this.flush=()=>{this.#i(),this.#r()},this.peekAllItems=()=>[...this.store.state.items],this.#i=()=>{this.#e&&=(clearTimeout(this.#e),null)},this.clear=()=>{this.#t({items:[],isPending:!1})},this.cancel=()=>{this.#i(),this.#t({isPending:!1})},this.reset=()=>{this.#t(yo()),this.options.onItemsChange?.(this)},this.key=t.key,this.options={...bo,...t},this.#t(this.options.initialState??{}),this.key&&fo.on(`d-Batcher`,e=>{e.payload.key===this.key&&(this.#t(e.payload.store.state),this.setOptions(e.payload.options))})}#t;#n;#r;#i};function So(){return{executionCount:0,isPending:!1,lastArgs:void 0,lastExecutionTime:0,nextExecutionTime:0,status:`idle`,maybeExecuteCount:0}}var Co={enabled:!0,leading:!0,trailing:!0,wait:0},wo=class{#e;constructor(e,t){this.fn=e,this.store=new Li(So()),this.setOptions=e=>{this.options={...this.options,...e},this.#n()||this.cancel()},this.#t=e=>{this.store.setState(t=>{let n={...t,...e},{isPending:r}=n;return{...n,status:this.#n()?r?`pending`:`idle`:`disabled`}}),uo(`Throttler`,this)},this.#n=()=>!!ro(this.options.enabled,this),this.#r=()=>ro(this.options.wait,this),this.maybeExecute=(...e)=>{this.#t({maybeExecuteCount:this.store.state.maybeExecuteCount+1});let t=Date.now(),n=t-this.store.state.lastExecutionTime,r=this.#r();if(this.options.leading&&n>=r)this.#i(...e);else if(this.#t({lastArgs:e}),!this.#e&&this.options.trailing){let e=r-(this.store.state.lastExecutionTime?t-this.store.state.lastExecutionTime:0);this.#t({isPending:!0}),this.#e=setTimeout(()=>{let{lastArgs:e}=this.store.state;e!==void 0&&this.#i(...e)},e)}},this.#i=(...e)=>{if(!this.#n())return;this.fn(...e);let t=Date.now(),n=t+this.#r();this.#a(),this.#t({executionCount:this.store.state.executionCount+1,lastExecutionTime:t,nextExecutionTime:n,isPending:!1,lastArgs:void 0}),this.options.onExecute?.(e,this),setTimeout(()=>{this.store.state.isPending||this.#t({nextExecutionTime:void 0})},this.#r())},this.flush=()=>{this.store.state.isPending&&this.store.state.lastArgs&&this.#i(...this.store.state.lastArgs)},this.#a=()=>{this.#e&&=(clearTimeout(this.#e),void 0)},this.cancel=()=>{this.#a(),this.#t({lastArgs:void 0,isPending:!1})},this.reset=()=>{this.#t(So())},this.key=t.key,this.options={...Co,...t},this.#t(this.options.initialState??{}),this.key&&fo.on(`d-Throttler`,e=>{e.payload.key===this.key&&(this.#t(e.payload.store.state),this.setOptions(e.payload.options))})}#t;#n;#r;#i;#a};function To(e){return at(e.defaultTagName??`div`,e,e)}var $=O(),Eo=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,Do=Vn,Oo=(e,t)=>n=>{if(t?.variants==null)return Do(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=Eo(t)||Eo(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return Do(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},ko=768;function Ao(){let e=(0,$.c)(2),[t,n]=Z.useState(void 0),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(max-width: ${ko-1}px)`),t=()=>{n(window.innerWidth<ko)};return e.addEventListener(`change`,t),n(window.innerWidth<ko),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Z.useEffect(r,i),!!t}var jo=4,Mo=.5,No=.2,Po=20,Fo=10,Io=320,Lo=256,Ro=512;function zo(){if(typeof window>`u`)return`col-resize`;let e=window.navigator.userAgent;return e.includes(`Chrome`)||e.includes(`Firefox`)?`ew-resize`:`col-resize`}function Bo(){if(typeof window>`u`)return`row-resize`;let e=window.navigator.userAgent;return e.includes(`Chrome`)||e.includes(`Firefox`)?`ns-resize`:`row-resize`}function Vo(){return typeof window>`u`?Fo:window.matchMedia(`(pointer:coarse)`).matches?Po:Fo}function Ho(e){let t=document.createElement(`style`);return t.dataset.resizeCursor=`true`,t.textContent=`*, *:hover { cursor: ${e} !important; }`,document.head.append(t),()=>t.remove()}function Uo(e,t){let n=e.trim(),r=Number.parseFloat(n);return Number.isFinite(r)?n.endsWith(`rem`)?r*(typeof window>`u`?16:Number.parseFloat(window.getComputedStyle(document.documentElement).fontSize)||16):r:t}function Wo(e,t,n){return Math.min(Math.max(e,t),n)}function Go(e){return e.closest(`[data-slot='sidebar']`)?.dataset.side===`right`?`right`:`left`}function Ko(e){return e.closest(`[data-slot='sidebar-wrapper']`)}function qo(e,t){e.latestWidth=t,e.previewElement&&e.previewAnimationFrame===null&&(e.previewAnimationFrame=window.requestAnimationFrame(()=>{e.previewAnimationFrame=null,!(!e.previewElement||!e.latestWidth)&&e.previewElement.style.setProperty(`--sidebar-width`,e.latestWidth)}))}function Jo(e){e.previewAnimationFrame!==null&&(window.cancelAnimationFrame(e.previewAnimationFrame),e.previewAnimationFrame=null)}function Yo(e,t){let n=t-e.startX;return e.side===`left`?e.startWidth+n:e.startWidth-n}function Xo(e,t){return e.side===`left`?t>e.startX:t<e.startX}function Zo(e){let t=Z.useRef(e);return t.current=e,t}function Qo(e){let t=(0,$.c)(20),{enabled:n,expandThreshold:r,isMobile:i,maxWidth:a,minWidth:o,state:s,width:c,onOpenChange:l,onResize:u,onResizeActiveChange:d}=e,f=n===void 0?!0:n,p=r===void 0?No:r,m;t[0]!==f||t[1]!==p||t[2]!==i||t[3]!==a||t[4]!==o||t[5]!==l||t[6]!==u||t[7]!==d||t[8]!==s||t[9]!==c?(m={enabled:f,expandThreshold:p,isMobile:i,maxWidth:a,minWidth:o,state:s,width:c,onOpenChange:l,onResize:u,onResizeActiveChange:d},t[0]=f,t[1]=p,t[2]=i,t[3]=a,t[4]=o,t[5]=l,t[6]=u,t[7]=d,t[8]=s,t[9]=c,t[10]=m):m=t[10];let h=Zo(m),g=Z.useRef(!1),_=Z.useRef(null),v,y;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(v=()=>()=>_.current?.(),y=[],t[11]=v,t[12]=y):(v=t[11],y=t[12]),Z.useEffect(v,y);let b;t[13]===h?b=t[14]:(b=e=>{if(g.current){e.preventDefault(),e.stopPropagation(),g.current=!1;return}let{onOpenChange:t,state:n}=h.current;t(n!==`expanded`)},t[13]=h,t[14]=b);let x=b,S;t[15]===h?S=t[16]:(S=e=>{let t=h.current;if(e.defaultPrevented||e.button!==0||t.isMobile||!t.enabled)return;let n=Uo(t.minWidth,Lo),r=Uo(t.maxWidth,Ro),i=Uo(t.width,Io),a={collapsed:t.state!==`expanded`,latestWidth:null,moved:!1,previewAnimationFrame:null,previewElement:Ko(e.currentTarget),previousCursor:document.body.style.cursor,previousUserSelect:document.body.style.userSelect,side:Go(e.currentTarget),startWidth:t.state===`expanded`?i:0,startX:e.clientX};_.current?.();let o=null,s=()=>{window.removeEventListener(`pointermove`,d),window.removeEventListener(`pointerup`,f),window.removeEventListener(`pointercancel`,f),o?.(),Jo(a),document.body.style.cursor=a.previousCursor,document.body.style.userSelect=a.previousUserSelect,a.moved&&h.current.onResizeActiveChange(!1),_.current=null},c=()=>{let e=zo();a.moved=!0,g.current=!0,h.current.onResizeActiveChange(!0),o=Ho(e),document.body.style.cursor=e,document.body.style.userSelect=`none`},l=e=>{let t=`${Math.round(n)}px`;qo(a,t),h.current.onResize(t),h.current.onOpenChange(!1),a.collapsed=!0,a.startWidth=0,a.startX=e},u=e=>{let t=`${Math.round(n)}px`;qo(a,t),h.current.onResize(t),h.current.onOpenChange(!0),a.collapsed=!1,a.startWidth=n,a.startX=e},d=e=>{let t=Math.abs(e.clientX-a.startX);if(!a.moved&&t<jo)return;a.moved||c(),e.preventDefault();let i=Yo(a,e.clientX);if(a.collapsed){let t=n*h.current.expandThreshold;Xo(a,e.clientX)&&i>=t&&u(e.clientX);return}if(i<=n*Mo){l(e.clientX);return}let o=Wo(i,n,r);qo(a,`${Math.round(o)}px`)},f=e=>{a.moved&&(e.preventDefault(),a.latestWidth&&h.current.onResize(a.latestWidth),window.setTimeout(()=>{g.current=!1},0)),s()};_.current=s,window.addEventListener(`pointermove`,d),window.addEventListener(`pointerup`,f),window.addEventListener(`pointercancel`,f)},t[15]=h,t[16]=S);let C=S,w;return t[17]!==x||t[18]!==C?(w={handleClick:x,handlePointerDown:C},t[17]=x,t[18]=C,t[19]=w):w=t[19],w}var $o=Z.createContext(void 0);function es(e=!1){let t=Z.useContext($o);if(t===void 0&&!e)throw Error(b(16));return t}function ts(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:Z.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function ns(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:o}=e,s=Z.useRef(null),c=es(!0),l=o??c!==void 0,{props:u}=ts({focusableWhenDisabled:n,disabled:t,composite:l,tabIndex:r,isNativeButton:i}),d=Z.useCallback(()=>{let e=s.current;rs(e)&&l&&t&&u.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,u.disabled,l]);return me(d,[d]),{getButtonProps:Z.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:o,onKeyDown:s,onPointerDown:c,...d}=e;return a({type:i?`button`:void 0,onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(Ce(e),s?.(e),e.baseUIHandlerPrevented))return;let r=e.target===e.currentTarget,a=e.currentTarget,o=rs(a),c=!i&&is(a),u=r&&(i?o:!c),d=e.key===`Enter`,f=e.key===` `,p=a.getAttribute(`role`),m=p?.startsWith(`menuitem`)||p===`option`||p===`gridcell`;if(r&&l&&f){if(e.defaultPrevented&&m)return;e.preventDefault(),c||i&&o?(a.click(),e.preventBaseUIHandler()):u&&(n?.(e),e.preventBaseUIHandler());return}u&&(!i&&(f||d)&&e.preventDefault(),!i&&d&&n?.(e))},onKeyUp(e){if(!t){if(Ce(e),o?.(e),e.target===e.currentTarget&&i&&l&&rs(e.currentTarget)&&e.key===` `){e.preventDefault();return}e.baseUIHandlerPrevented||e.target===e.currentTarget&&!i&&!l&&e.key===` `&&n?.(e)}},onPointerDown(e){if(t){e.preventDefault();return}c?.(e)}},i?void 0:{role:`button`},u,d)},[t,u,l,i]),buttonRef:J(e=>{s.current=e,d()})}}function rs(e){return te(e)&&e.tagName===`BUTTON`}function is(e){return!!(e?.tagName===`A`&&e?.href)}var as=Z.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,focusableWhenDisabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{getButtonProps:l,buttonRef:u}=ns({disabled:i,focusableWhenDisabled:a,native:o});return at(`button`,e,{state:{disabled:i},ref:[t,u],props:[c,l]})}),os=Oo(`group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,outline:`border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground`,ghost:`hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50`,destructive:`bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,xs:`h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,icon:`size-8`,"icon-xs":`size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg`,"icon-lg":`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function ss(e){let t=(0,$.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,variant:i,size:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`default`:i,s=a===void 0?`default`:a,c;t[5]!==n||t[6]!==s||t[7]!==o?(c=rn(os({variant:o,size:s,className:n})),t[5]=n,t[6]=s,t[7]=o,t[8]=c):c=t[8];let l;return t[9]!==r||t[10]!==c?(l=(0,Q.jsx)(as,{"data-slot":`button`,className:c,...r}),t[9]=r,t[10]=c,t[11]=l):l=t[11],l}var cs=function(e){return e.disabled=`data-disabled`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),ls={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},us={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},ds={disabled:!1,...us},fs={valid(e){return e===null?null:e?{[cs.valid]:``}:{[cs.invalid]:``}}},ps=Z.createContext({invalid:void 0,name:void 0,validityData:{state:ls,errors:[],error:``,value:``,initialValue:null},setValidityData:zt,disabled:void 0,touched:us.touched,setTouched:zt,dirty:us.dirty,setDirty:zt,filled:us.filled,setFilled:zt,focused:us.focused,setFocused:zt,validate:()=>null,validationMode:`onSubmit`,validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:ds,markedDirtyRef:{current:!1},registerFieldControl:zt,validation:{getValidationProps:(e=sn)=>e,getInputValidationProps:(e=sn)=>e,inputRef:{current:null},commit:async()=>{}}});function ms(e=!0){let t=Z.useContext(ps);if(t.setValidityData===zt&&!e)throw Error(b(28));return t}var hs=Z.createContext({controlId:void 0,registerControlId:zt,labelId:void 0,setLabelId:zt,messageIds:[],setMessageIds:zt,getDescriptionProps:e=>e});function gs(){return Z.useContext(hs)}function _s({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=Z.useRef(e!==void 0),[a,o]=Z.useState(t);return[i?e:a,Z.useCallback(e=>{i||o(e)},[])]}function vs(e,t){let{enabled:n=!0,getValue:r,id:i,value:a}=t,{registerFieldControl:o}=ms(),s=Z.useRef(null);s.current||=Symbol(),me(()=>{let t=s.current;if(!(!t||!n))return o(t,{controlRef:e,getValue:r,id:i,value:a}),()=>{o(t,void 0)}},[e,n,r,i,o,a])}function ys(e={}){let{id:t,implicit:n=!1,controlRef:r}=e,{controlId:i,registerControlId:a}=gs(),o=It(t),s=n?i:void 0,c=oe(()=>Symbol(`labelable-control`)),l=Z.useRef(!1),u=Z.useRef(t!=null),d=J(()=>{!l.current||a===zt||(l.current=!1,a(c.current,void 0))});return me(()=>{if(a===zt)return;let e;if(n){let n=r?.current;e=j(n)&&n.closest(`label`)!=null?t??null:s??o}else if(t!=null)u.current=!0,e=t;else if(u.current)e=o;else{d();return}if(e===void 0){d();return}l.current=!0,a(c.current,e)},[t,r,s,a,n,o,c,d]),Z.useEffect(()=>d,[d]),i??o}var bs=Z.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:g,setDirty:_,validityData:v,setFocused:y,setFilled:b,validationMode:x,validation:S}=ms(),w=h||s,T=m??a,E={...p,disabled:w},{labelId:D}=gs(),O=ys({id:i});me(()=>{let e=o!=null;S.inputRef.current?.value||e&&o!==``?b(!0):e&&o===``&&b(!1)},[S.inputRef,b,o]);let k=Z.useRef(null);me(()=>{u&&k.current===C(_e(k.current))&&y(!0)},[u,y]);let[A]=_s({controlled:o,default:l,name:`FieldControl`,state:`value`}),j=o!==void 0,M=j?A:void 0,N=J(()=>S.inputRef.current?.value);return vs(S.inputRef,{id:O,value:M,getValue:N}),at(`input`,e,{ref:[t,k],state:E,props:[{id:O,disabled:w,name:T,ref:S.inputRef,"aria-labelledby":D,autoFocus:u,...j?{value:M}:{defaultValue:l},onChange(e){let t=e.currentTarget.value;c?.(t,Ye(Wt,e.nativeEvent)),_(t!==v.initialValue),b(t!==``)},onFocus(){y(!0)},onBlur(e){g(!0),y(!1),x===`onBlur`&&S.commit(e.currentTarget.value)},onKeyDown(e){e.currentTarget.tagName===`INPUT`&&e.key===`Enter`&&(g(!0),S.commit(e.currentTarget.value))}},S.getInputValidationProps(),f],stateAttributesMapping:fs})}),cee=Z.forwardRef(function(e,t){return(0,Q.jsx)(bs,{ref:t,...e})});function xs(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,type:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=rn(`h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==a||t[8]!==i?(o=(0,Q.jsx)(cee,{type:i,"data-slot":`input`,className:a,...r}),t[6]=r,t[7]=a,t[8]=i,t[9]=o):o=t[9],o}var Ss=`after:transition-colors after:duration-150 hover:after:bg-primary focus-visible:after:bg-primary active:after:bg-primary`,lee=`after:transition-colors after:duration-150 hover:group-data-[collapsible=offcanvas]:after:bg-primary focus-visible:group-data-[collapsible=offcanvas]:after:bg-primary active:group-data-[collapsible=offcanvas]:after:bg-primary`,Cs=Z.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return at(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})});function uee(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,orientation:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`horizontal`:i,o;t[4]===n?o=t[5]:(o=rn(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,n),t[4]=n,t[5]=o);let s;return t[6]!==a||t[7]!==r||t[8]!==o?(s=(0,Q.jsx)(Cs,{"data-slot":`separator`,orientation:a,className:o,...r}),t[6]=a,t[7]=r,t[8]=o,t[9]=s):s=t[9],s}var ws=Z.createContext(void 0);function Ts(e){let t=Z.useContext(ws);if(e===!1&&t===void 0)throw Error(b(27));return t}var dee={...Gn,...Y},Es=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,{store:s}=Ts(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return at(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:dee,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),Ds=Z.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,nativeButton:a=!0,style:o,...s}=e,{store:c}=Ts(),l=c.useState(`open`);function u(e){l&&c.setOpen(!1,Ye(xe,e.nativeEvent))}let{getButtonProps:d,buttonRef:f}=ns({disabled:i,native:a});return at(`button`,e,{state:{disabled:i},ref:[t,f],props:[{onClick:u},s,d]})}),Os=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,{store:s}=Ts(),c=It(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),at(`p`,e,{ref:t,props:[{id:c},o]})}),ks=function(e){return e.nestedDialogs=`--nested-dialogs`,e}({}),As=function(e){return e[e.open=lt.open]=`open`,e[e.closed=lt.closed]=`closed`,e[e.startingStyle=lt.startingStyle]=`startingStyle`,e[e.endingStyle=lt.endingStyle]=`endingStyle`,e.nested=`data-nested`,e.nestedDialogOpen=`data-nested-dialog-open`,e}({}),js=Z.createContext(void 0);function Ms(){let e=Z.useContext(js);if(e===void 0)throw Error(b(26));return e}var Ns=`ArrowUp`,Ps=`ArrowDown`,Fs=`ArrowLeft`,Is=`ArrowRight`,Ls=`Home`,Rs=new Set([Fs,Is]),zs=new Set([Fs,Is,Ls,`End`]),Bs=new Set([Ns,Ps]),Vs=new Set([Ns,Ps,Ls,`End`]),Hs=new Set([...Rs,...Bs]),Us=new Set([...Hs,Ls,`End`]),Ws=new Set([Ns,Ps,Fs,Is,Ls,`End`]),Gs=new Set([`Shift`,`Control`,`Alt`,`Meta`]);function Ks(e){return te(e)&&e.tagName===`INPUT`}function qs(e){return!!(Ks(e)&&e.selectionStart!=null||te(e)&&e.tagName===`TEXTAREA`)}function Js(e,t,n,r){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop,o=e.clientWidth<e.scrollWidth,s=e.clientHeight<e.scrollHeight;if(o&&r!==`vertical`){let r=Ys(e,t,`left`),a=Xs(e),o=Xs(t);n===`ltr`&&(r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight?i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight:r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft&&(i=r-o.scrollMarginLeft-a.scrollPaddingLeft)),n===`rtl`&&(r-o.scrollMarginRight<e.scrollLeft+a.scrollPaddingLeft?i=r-o.scrollMarginLeft-a.scrollPaddingLeft:r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight&&(i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight))}if(s&&r!==`horizontal`){let n=Ys(e,t,`top`),r=Xs(e),i=Xs(t);n-i.scrollMarginTop<e.scrollTop+r.scrollPaddingTop?a=n-i.scrollMarginTop-r.scrollPaddingTop:n+t.offsetHeight+i.scrollMarginBottom>e.scrollTop+e.clientHeight-r.scrollPaddingBottom&&(a=n+t.offsetHeight+i.scrollMarginBottom-e.clientHeight+r.scrollPaddingBottom)}e.scrollTo({left:i,top:a,behavior:`auto`})}function Ys(e,t,n){let r=n===`left`?`offsetLeft`:`offsetTop`,i=0;for(;t.offsetParent&&(i+=t[r],t.offsetParent!==e);)t=t.offsetParent;return i}function Xs(e){let t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}var Zs={...Gn,...Y,nestedDialogOpen(e){return e?{[As.nestedDialogOpen]:``}:null}},Qs=Z.forwardRef(function(e,t){let{className:n,finalFocus:r,initialFocus:i,render:a,style:o,...s}=e,{store:c}=Ts(),l=c.useState(`descriptionElementId`),u=c.useState(`disablePointerDismissal`),d=c.useState(`floatingRootContext`),f=c.useState(`popupProps`),p=c.useState(`modal`),m=c.useState(`mounted`),h=c.useState(`nested`),g=c.useState(`nestedOpenDialogCount`),_=c.useState(`open`),v=c.useState(`openMethod`),y=c.useState(`titleElementId`),b=c.useState(`transitionStatus`),x=c.useState(`role`);Ms(),ye({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});function S(e){return e===`touch`?c.context.popupRef.current:!0}let C=i===void 0?S:i,w=at(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:g>0},props:[f,{"aria-labelledby":y??void 0,"aria-describedby":l??void 0,role:x,tabIndex:-1,hidden:!m,onKeyDown(e){Ws.has(e.key)&&e.stopPropagation()},style:{[ks.nestedDialogs]:g}},s],ref:[t,c.context.popupRef,c.useStateSetter(`popupElement`)],stateAttributesMapping:Zs});return(0,Q.jsx)(va,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:r,modal:p!==!1,restoreFocus:`popup`,children:w})}),$s=Z.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return(0,Q.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})}),ec=Z.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i}=Ts(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,Q.jsx)(js.Provider,{value:n,children:(0,Q.jsxs)(tt,{ref:t,...r,children:[a&&o===!0&&(0,Q.jsx)($s,{ref:i.context.internalBackdropRef,inert:ka(!s)}),e.children]})}):null}),tc={},nc={},rc=``;function ic(e){if(typeof document>`u`)return!1;let t=_e(e);return Ge(t).innerWidth-t.documentElement.clientWidth>0}function ac(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=_e(e),n=t.documentElement,r=t.body,i=U(n)?n:r,a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function oc(e){let t=_e(e),n=t.documentElement,r=t.body,i=U(n)?n:r,a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function sc(e){let t=_e(e),n=t.documentElement,r=t.body,i=Ge(n),a=0,o=0,s=!1,c=D.create();if(g&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,tc={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},rc=n.style.scrollBehavior,nc={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=U(n)?n:r;if(s=ac(e),s){n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`;return}Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflow:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`}function u(){Object.assign(n.style,tc),Object.assign(r.style,nc),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=rc)}function d(){u(),c.request(l)}l();let f=Ve(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var cc=new class{lockCount=0;restore=null;timeoutLock=Jn.create();timeoutUnlock=Jn.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=_e(e).documentElement,n=Ge(t).getComputedStyle(t).overflowY;if(n===`hidden`||n===`clip`){this.restore=zt;return}let r=Qn||!ic(e);this.restore=r?oc(e):sc(e)}};function lc(e=!0,t=null){me(()=>{if(e)return cc.acquire(t)},[e,t])}function uc(e){let t=Z.useRef(``),n=Z.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:Z.useCallback(n=>{if(n.detail===0){e(n,`keyboard`);return}`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``},[e]),onPointerDown:n}}function dc(e,t){let n=Z.useRef(e),r=J(t);me(()=>{n.current!==e&&r(n.current)},[e,r]),me(()=>{n.current=e},[e])}function fc(e){let[t,n]=Z.useState(null),r=J((t,r)=>{e||n(r||(Qn?`touch`:``))});dc(e,t=>{t&&!e&&n(null)});let{onClick:i,onPointerDown:a}=uc(r);return Z.useMemo(()=>({openMethod:t,triggerProps:{onClick:i,onPointerDown:a}}),[t,i,a])}function pc(e){let{store:t,parentContext:n,actionsRef:r,isDrawer:i}=e,a=t.useState(`open`),o=t.useState(`disablePointerDismissal`),s=t.useState(`modal`),c=t.useState(`popupElement`),{openMethod:u,triggerProps:d}=fc(a);l(t);let{forceUnmount:f}=Yt(a,t),p=J(e=>{let n=Ye(e);return n.preventUnmountOnClose=()=>{t.set(`preventUnmountingOnClose`,!0)},n}),m=Z.useCallback(()=>{t.setOpen(!1,p(In))},[t,p]);Z.useImperativeHandle(r,()=>({unmount:f,close:m}),[f,m]);let h=T({popupStore:t,onOpenChange:t.setOpen,treatPopupAsFloatingElement:!0}),[g,_]=Z.useState(0),[v,b]=Z.useState(0),x=g===0,S=Da(h),C=Ue(h,{outsidePressEvent(){return t.context.internalBackdropRef.current||t.context.backdropRef.current?`intentional`:{mouse:s===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(e){if(!t.context.outsidePressEnabledRef.current||`button`in e&&e.button!==0||`touches`in e&&e.touches.length!==1)return!1;let n=pe(e);if(x&&!o){let e=n;return s&&(t.context.internalBackdropRef.current||t.context.backdropRef.current)?t.context.internalBackdropRef.current===e||t.context.backdropRef.current===e||y(e,c)&&!e?.hasAttribute(`data-base-ui-portal`):!0}return!1},escapeKey:x});lc(a&&s===!0,c);let{getReferenceProps:w,getFloatingProps:E,getTriggerProps:D}=je([S,C]);t.useContextCallback(`onNestedDialogOpen`,(e,t)=>{_(e),b(t)}),t.useContextCallback(`onNestedDialogClose`,()=>{_(0),b(0)}),Z.useEffect(()=>(n?.onNestedDialogOpen&&a&&n.onNestedDialogOpen(g+1,v+ +!!i),n?.onNestedDialogClose&&!a&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&a&&n.onNestedDialogClose()}),[i,a,g,v,n]);let O=Z.useMemo(()=>w(d),[w,d]),k=Z.useMemo(()=>D(d),[D,d]),A=Z.useMemo(()=>E(),[E]);t.useSyncedValues({openMethod:u,activeTriggerProps:O,inactiveTriggerProps:k,popupProps:A,floatingRootContext:h,nestedOpenDialogCount:g,nestedOpenDrawerCount:v})}var mc={...he,modal:p(e=>e.modal),nested:p(e=>e.nested),nestedOpenDialogCount:p(e=>e.nestedOpenDialogCount),nestedOpenDrawerCount:p(e=>e.nestedOpenDrawerCount),disablePointerDismissal:p(e=>e.disablePointerDismissal),openMethod:p(e=>e.openMethod),descriptionElementId:p(e=>e.descriptionElementId),titleElementId:p(e=>e.titleElementId),viewportElement:p(e=>e.viewportElement),role:p(e=>e.role)},hc=class e extends or{constructor(e){super(gc(e),{popupRef:Z.createRef(),backdropRef:Z.createRef(),internalBackdropRef:Z.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:new $t,onOpenChange:void 0,onOpenChangeComplete:void 0},mc)}setOpen=(e,t)=>{if(t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let n={open:e},r=t.trigger?.id??null;(r||e)&&(n.activeTriggerId=r,n.activeTriggerElement=t.trigger??null),this.update(n)};static useStore(t,n){let r=oe(()=>new e(n)).current;return t??r}};function gc(e={}){return{...x(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e}}var _c=Z.createContext(!1);function vc(e){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,disablePointerDismissal:o=!1,modal:s=!0,actionsRef:c,handle:l,triggerId:u,defaultTriggerId:d=null}=e,f=Ts(!0),p=Z.useContext(_c),m=!!f,h=hc.useStore(l?.store,{open:r,openProp:n,activeTriggerId:d,triggerIdProp:u,modal:s,disablePointerDismissal:o,nested:m});Qt(()=>{n===void 0&&h.state.open===!1&&r===!0&&h.update({open:!0,activeTriggerId:d})}),h.useControlledProp(`openProp`,n),h.useControlledProp(`triggerIdProp`,u),h.useSyncedValues({disablePointerDismissal:o,nested:m,modal:s}),h.useContextCallback(`onOpenChange`,i),h.useContextCallback(`onOpenChangeComplete`,a);let g=h.useState(`payload`);pc({store:h,actionsRef:c,parentContext:f?.store.context,isDrawer:p,onOpenChange:i,triggerIdProp:u});let _=Z.useMemo(()=>({store:h}),[h]);return(0,Q.jsx)(_c.Provider,{value:!1,children:(0,Q.jsx)(ws.Provider,{value:_,children:typeof t==`function`?t({payload:g}):t})})}var yc=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,{store:s}=Ts(),c=It(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),at(`h2`,e,{ref:t,props:[{id:c},o]})});function bc(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Q.jsx)(vc,{"data-slot":`sheet`,...n}),t[2]=n,t[3]=r),r}function xc(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Q.jsx)(ec,{"data-slot":`sheet-portal`,...n}),t[2]=n,t[3]=r),r}function Sc(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=rn(`fixed inset-0 z-50 bg-black/10 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(Es,{"data-slot":`sheet-overlay`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Cc(e){let t=(0,$.c)(17),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,children:n,side:a,showCloseButton:o,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=a===void 0?`right`:a,c=o===void 0?!0:o,l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(Sc,{}),t[6]=l):l=t[6];let u;t[7]===r?u=t[8]:(u=rn(`fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm`,r),t[7]=r,t[8]=u);let d;t[9]===c?d=t[10]:(d=c&&(0,Q.jsxs)(Ds,{"data-slot":`sheet-close`,render:(0,Q.jsx)(ss,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`}),children:[(0,Q.jsx)(no,{}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Close`})]}),t[9]=c,t[10]=d);let f;return t[11]!==n||t[12]!==i||t[13]!==s||t[14]!==u||t[15]!==d?(f=(0,Q.jsxs)(xc,{children:[l,(0,Q.jsxs)(Qs,{"data-slot":`sheet-content`,"data-side":s,className:u,...i,children:[n,d]})]}),t[11]=n,t[12]=i,t[13]=s,t[14]=u,t[15]=d,t[16]=f):f=t[16],f}function wc(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=rn(`flex flex-col gap-0.5 p-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`div`,{"data-slot":`sheet-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Tc(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=rn(`font-heading text-base font-medium text-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(yc,{"data-slot":`sheet-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Ec(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=rn(`text-sm text-muted-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(Os,{"data-slot":`sheet-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var Dc=`sidebar_state`,Oc=3600*24*7,kc=`20rem`,Ac=`16rem`,jc=`32rem`,Mc=`pico-sidebar-width`,Nc=`sidebar_width`,Pc=`20rem`,Fc=`3rem`,Ic=`b`,Lc=Z.createContext(null);function Rc(e,t){let n=e.trim(),r=Number.parseFloat(n);return Number.isFinite(r)?n.endsWith(`rem`)?r*(typeof window>`u`?16:Number.parseFloat(window.getComputedStyle(document.documentElement).fontSize)||16):r:t}function zc(e){let t=Rc(kc,320),n=Rc(Ac,256),r=Rc(jc,512),i=Rc(e??``,t);return`${Math.round(Math.min(Math.max(i,n),r))}px`}function Bc(){if(typeof window>`u`)return zc(kc);try{return zc(window.localStorage.getItem(Mc)??window.localStorage.getItem(Nc))}catch{return zc(kc)}}function Vc(e){try{window.localStorage.setItem(Mc,e)}catch{}}function Hc(e){let t=Z.useRef(e);return t.current=e,t}function Uc(){let e=Z.useContext(Lc);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function Wc({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:a,...o}){let s=Ao(),[c,l]=Z.useState(!1),[u,d]=Z.useState(!1),[f,p]=Z.useState(()=>zc(kc)),[m,h]=Z.useState(!1),g=Z.useRef(f);g.current=f,Z.useEffect(()=>{let e=Bc();g.current!==e&&(g.current=e,p(e))},[]);let _=e=>{let t=zc(e);g.current!==t&&(g.current=t,p(t),Vc(t))},[v,y]=Z.useState(e),b=t??v,x=e=>{let t=typeof e==`function`?e(b):e;n?n(t):y(t),document.cookie=`${Dc}=${t}; path=/; max-age=${Oc}`},S=()=>s?l(e=>!e):x(e=>!e),C=Hc(S);Z.useEffect(()=>{let e=e=>{e.key.toLowerCase()===Ic&&(e.metaKey||e.ctrlKey)&&!(e.metaKey&&e.ctrlKey)&&!e.shiftKey&&!e.altKey&&(e.preventDefault(),C.current())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[C]);let w={state:b?`expanded`:`collapsed`,open:b,setOpen:x,isMobile:s,openMobile:c,openMobileSettled:u,setOpenMobile:l,setOpenMobileSettled:d,sidebarResizing:m,setSidebarResizing:h,sidebarWidth:f,setSidebarWidth:_,toggleSidebar:S};return(0,Q.jsx)(Lc.Provider,{value:w,children:(0,Q.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:{...i,"--sidebar-width":f,"--sidebar-width-icon":Fc},className:rn(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),...o,children:a})})}function Gc(e){let t=(0,$.c)(50),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({side:o,variant:s,collapsible:c,className:r,children:n,dir:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=o===void 0?`left`:o,u=s===void 0?`sidebar`:s,d=c===void 0?`offcanvas`:c,{isMobile:f,state:p,openMobile:m,setOpenMobile:h,setOpenMobileSettled:g,sidebarResizing:_}=Uc();if(d===`none`){let e;t[8]===r?e=t[9]:(e=rn(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),t[8]=r,t[9]=e);let i;return t[10]!==n||t[11]!==a||t[12]!==e?(i=(0,Q.jsx)(`div`,{"data-slot":`sidebar`,className:e,...a,children:n}),t[10]=n,t[11]=a,t[12]=e,t[13]=i):i=t[13],i}if(f){let e;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(e={"--sidebar-width":Pc},t[14]=e):e=t[14];let r;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsxs)(wc,{className:`sr-only`,children:[(0,Q.jsx)(Tc,{children:`Sidebar`}),(0,Q.jsx)(Ec,{children:`Displays the mobile sidebar.`})]}),t[15]=r):r=t[15];let o;t[16]===n?o=t[17]:(o=(0,Q.jsx)(`div`,{className:`flex h-full w-full flex-col`,children:n}),t[16]=n,t[17]=o);let s;t[18]!==i||t[19]!==l||t[20]!==o?(s=(0,Q.jsxs)(Cc,{dir:i,"data-sidebar":`sidebar`,"data-slot":`sidebar`,"data-mobile":`true`,className:`w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden`,style:e,side:l,children:[r,o]}),t[18]=i,t[19]=l,t[20]=o,t[21]=s):s=t[21];let c;return t[22]!==m||t[23]!==a||t[24]!==h||t[25]!==g||t[26]!==s?(c=(0,Q.jsx)(bc,{open:m,onOpenChange:h,onOpenChangeComplete:g,...a,children:s}),t[22]=m,t[23]=a,t[24]=h,t[25]=g,t[26]=s,t[27]=c):c=t[27],c}let v=p===`collapsed`?d:``,y=_?`true`:void 0,b=u===`floating`||u===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`,x;t[28]===b?x=t[29]:(x=rn(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear group-data-[resizing=true]:transition-none`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,b),t[28]=b,t[29]=x);let S;t[30]===x?S=t[31]:(S=(0,Q.jsx)(`div`,{"data-slot":`sidebar-gap`,className:x}),t[30]=x,t[31]=S);let C=u===`floating`||u===`inset`?`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]`:`border-sidebar-border/70 group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l`,w;t[32]!==r||t[33]!==C?(w=rn(`fixed inset-y-0 z-30 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear group-data-[resizing=true]:transition-none data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex`,C,r),t[32]=r,t[33]=C,t[34]=w):w=t[34];let T;t[35]===n?T=t[36]:(T=(0,Q.jsx)(`div`,{"data-sidebar":`sidebar`,"data-slot":`sidebar-inner`,className:`flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border`,children:n}),t[35]=n,t[36]=T);let E;t[37]!==a||t[38]!==l||t[39]!==w||t[40]!==T?(E=(0,Q.jsx)(`div`,{"data-slot":`sidebar-container`,"data-side":l,className:w,...a,children:T}),t[37]=a,t[38]=l,t[39]=w,t[40]=T,t[41]=E):E=t[41];let D;return t[42]!==l||t[43]!==p||t[44]!==E||t[45]!==v||t[46]!==y||t[47]!==S||t[48]!==u?(D=(0,Q.jsxs)(`div`,{className:`group peer hidden text-sidebar-foreground md:block`,"data-state":p,"data-collapsible":v,"data-resizing":y,"data-variant":u,"data-side":l,"data-slot":`sidebar`,children:[S,E]}),t[42]=l,t[43]=p,t[44]=E,t[45]=v,t[46]=y,t[47]=S,t[48]=u,t[49]=D):D=t[49],D}function Kc(e){let t=(0,$.c)(15),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,onClick:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let{toggleSidebar:a}=Uc(),o;t[4]===n?o=t[5]:(o=rn(n),t[4]=n,t[5]=o);let s;t[6]!==r||t[7]!==a?(s=e=>{r?.(e),a()},t[6]=r,t[7]=a,t[8]=s):s=t[8];let c,l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(Ya,{}),l=(0,Q.jsx)(`span`,{className:`sr-only`,children:`Toggle Sidebar`}),t[9]=c,t[10]=l):(c=t[9],l=t[10]);let u;return t[11]!==i||t[12]!==o||t[13]!==s?(u=(0,Q.jsx)(Je,{title:`Toggle sidebar`,kbd:`⌃ B`,children:(0,Q.jsxs)(ss,{"data-sidebar":`trigger`,"data-slot":`sidebar-trigger`,variant:`ghost`,size:`icon`,className:o,onClick:s,...i,children:[c,l]})}),t[11]=i,t[12]=o,t[13]=s,t[14]=u):u=t[14],u}function qc(e){let t=(0,$.c)(34),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:n,onClick:r,onPointerDown:i,style:o,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let{isMobile:s,setOpen:c,setSidebarResizing:l,setSidebarWidth:u,sidebarWidth:d,state:f}=Uc(),p;t[6]!==s||t[7]!==c||t[8]!==l||t[9]!==u||t[10]!==d||t[11]!==f?(p={isMobile:s,maxWidth:jc,minWidth:Ac,state:f,width:d,onOpenChange:c,onResize:u,onResizeActiveChange:l},t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=d,t[11]=f,t[12]=p):p=t[12];let{handleClick:m,handlePointerDown:h}=Qo(p),[g,_]=Z.useState(`col-resize`),[v,y]=Z.useState(10),b,x;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{let e=()=>{y(Vo())},t=window.matchMedia(`(pointer:coarse)`);return _(zo()),e(),t.addEventListener(`change`,e),()=>{t.removeEventListener(`change`,e)}},x=[],t[13]=b,t[14]=x):(b=t[13],x=t[14]),Z.useEffect(b,x);let S=g===`ew-resize`?`cursor-ew-resize group-data-[side=left]:cursor-ew-resize group-data-[side=right]:cursor-ew-resize [[data-side=left][data-state=collapsed]_&]:cursor-ew-resize [[data-side=right][data-state=collapsed]_&]:cursor-ew-resize`:`cursor-col-resize group-data-[side=left]:cursor-col-resize group-data-[side=right]:cursor-col-resize [[data-side=left][data-state=collapsed]_&]:cursor-col-resize [[data-side=right][data-state=collapsed]_&]:cursor-col-resize`,C;t[15]!==m||t[16]!==r?(C=e=>{r?.(e),!e.defaultPrevented&&m(e)},t[15]=m,t[16]=r,t[17]=C):C=t[17];let w;t[18]!==h||t[19]!==i?(w=e=>{i?.(e),!e.defaultPrevented&&h(e)},t[18]=h,t[19]=i,t[20]=w):w=t[20];let T=`${v}px`,E;t[21]!==g||t[22]!==o||t[23]!==T?(E={...o,"--sidebar-rail-width":T,cursor:g},t[21]=g,t[22]=o,t[23]=T,t[24]=E):E=t[24];let D=E,O;t[25]!==n||t[26]!==S?(O=rn(`absolute inset-y-0 z-40 hidden w-(--sidebar-rail-width) touch-none bg-transparent transition-all ease-linear select-none group-data-[side=left]:right-[calc(var(--sidebar-rail-width)*-1)] group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-px after:bg-transparent sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2`,Ss,S,`group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full`,lee,`[[data-side=left][data-collapsible=offcanvas]_&]:-right-2`,`[[data-side=right][data-collapsible=offcanvas]_&]:-left-2`,n),t[25]=n,t[26]=S,t[27]=O):O=t[27];let k;return t[28]!==a||t[29]!==C||t[30]!==w||t[31]!==D||t[32]!==O?(k=(0,Q.jsx)(`button`,{"data-sidebar":`rail`,"data-slot":`sidebar-rail`,"aria-label":`Toggle or resize Sidebar`,tabIndex:-1,onClick:C,onPointerDown:w,title:`Toggle or resize Sidebar`,style:D,className:O,...a}),t[28]=a,t[29]=C,t[30]=w,t[31]=D,t[32]=O,t[33]=k):k=t[33],k}function Jc(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=rn(`relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`main`,{"data-slot":`sidebar-inset`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Yc(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=rn(`flex flex-col gap-2 p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`div`,{"data-slot":`sidebar-header`,"data-sidebar":`header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Xc(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=rn(`flex flex-col gap-2 p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`div`,{"data-slot":`sidebar-footer`,"data-sidebar":`footer`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Zc(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=rn(`no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`div`,{"data-slot":`sidebar-content`,"data-sidebar":`content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Qc(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=rn(`relative flex w-full min-w-0 flex-col p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`div`,{"data-slot":`sidebar-group`,"data-sidebar":`group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function $c(e){let t=(0,$.c)(10),n,r,i,o;if(t[0]!==e){let{className:s,render:c,...l}=e;n=c,o=To,r=`div`,i=a({className:rn(`flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0`,s)},l),t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=o}else n=t[1],r=t[2],i=t[3],o=t[4];let s;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(s={slot:`sidebar-group-label`,sidebar:`group-label`},t[5]=s):s=t[5];let c;return t[6]!==n||t[7]!==r||t[8]!==i?(c={defaultTagName:r,props:i,render:n,state:s},t[6]=n,t[7]=r,t[8]=i,t[9]=c):c=t[9],o(c)}function el(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=rn(`w-full text-sm`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`div`,{"data-slot":`sidebar-group-content`,"data-sidebar":`group-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function tl(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=rn(`flex w-full min-w-0 flex-col gap-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`ul`,{"data-slot":`sidebar-menu`,"data-sidebar":`menu`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function nl(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=rn(`group/menu-item relative`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`li`,{"data-slot":`sidebar-menu-item`,"data-sidebar":`menu-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var rl=Oo(`peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:text-sidebar-accent-foreground not-data-active:hover:bg-sidebar-accent/50 focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent/50 data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&_svg]:shrink-0 [&>span:last-child]:truncate [&>svg]:size-4`,{variants:{variant:{default:`hover:text-sidebar-accent-foreground not-data-active:hover:bg-sidebar-accent/50`,outline:`bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))] not-data-active:hover:bg-sidebar-accent/50`},size:{default:`h-8 text-sm`,sm:`h-7 text-xs`,lg:`h-12 text-sm group-data-[collapsible=icon]:p-0!`}},defaultVariants:{variant:`default`,size:`default`}});function il(e){let t=(0,$.c)(18),{render:n,isActive:i,variant:o,size:s,tooltip:c,className:l,...u}=e,d=i===void 0?!1:i,f=o===void 0?`default`:o,p=s===void 0?`default`:s,{isMobile:m,state:h}=Uc(),g=a({className:rn(rl({variant:f,size:p}),l)},u),_;t[0]!==n||t[1]!==c?(_=c?(0,Q.jsx)(r,{render:n}):n,t[0]=n,t[1]=c,t[2]=_):_=t[2];let v;t[3]!==d||t[4]!==p?(v={slot:`sidebar-menu-button`,sidebar:`menu-button`,size:p,active:d},t[3]=d,t[4]=p,t[5]=v):v=t[5];let y;t[6]!==g||t[7]!==_||t[8]!==v?(y={defaultTagName:`button`,props:g,render:_,state:v},t[6]=g,t[7]=_,t[8]=v,t[9]=y):y=t[9];let b=To(y);if(!c)return b;if(typeof c==`string`){let e;t[10]===c?e=t[11]:(e={children:c},t[10]=c,t[11]=e),c=e}let x=h!==`collapsed`||m,S;t[12]!==x||t[13]!==c?(S=(0,Q.jsx)(be,{side:`right`,align:`center`,hidden:x,...c}),t[12]=x,t[13]=c,t[14]=S):S=t[14];let C;return t[15]!==b||t[16]!==S?(C=(0,Q.jsxs)(nt,{children:[b,S]}),t[15]=b,t[16]=S,t[17]=C):C=t[17],C}var al=1,ol=.9,sl=.8,cl=.17,ll=.1,ul=.999,dl=.9999,fl=.99,pl=/[\\\/_+.#"@\[\(\{&]/,ml=/[\\\/_+.#"@\[\(\{&]/g,hl=/[\s-]/,gl=/[\s-]/g;function _l(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?al:fl;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=_l(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=al:pl.test(e.charAt(l-1))?(d*=sl,p=e.slice(i,l-1).match(ml),p&&i>0&&(d*=ul**+p.length)):hl.test(e.charAt(l-1))?(d*=ol,m=e.slice(i,l-1).match(gl),m&&i>0&&(d*=ul**+m.length)):(d*=cl,i>0&&(d*=ul**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=dl)),(d<ll&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=_l(e,t,n,r,l+1,a+2,o),f*ll>d&&(d=f*ll)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function vl(e){return e.toLowerCase().replace(gl,` `)}function yl(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,_l(e,t,vl(e),vl(t),0,0,{})}typeof window<`u`&&window.document&&window.document.createElement;function bl(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function xl(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Sl(...e){return t=>{let n=!1,r=e.map(e=>{let r=xl(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():xl(e[t],null)}}}}function Cl(...e){return Z.useCallback(Sl(...e),e)}function wl(e,t){let n=Z.createContext(t),r=e=>{let{children:t,...r}=e,i=Z.useMemo(()=>r,Object.values(r));return(0,Q.jsx)(n.Provider,{value:i,children:t})};r.displayName=e+`Provider`;function i(r){let i=Z.useContext(n);if(i)return i;if(t!==void 0)return t;throw Error(`\`${r}\` must be used within \`${e}\``)}return[r,i]}function Tl(e,t=[]){let n=[];function r(t,r){let i=Z.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=Z.useMemo(()=>o,Object.values(o));return(0,Q.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=Z.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>Z.createContext(e));return function(n){let r=n?.[e]||t;return Z.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,El(i,...t)]}function El(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return Z.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}var Dl=globalThis?.document?Z.useLayoutEffect:()=>{},Ol=Z.useId||(()=>void 0),kl=0;function Al(e){let[t,n]=Z.useState(Ol());return Dl(()=>{e||n(e=>e??String(kl++))},[e]),e||(t?`radix-${t}`:``)}var jl=Z.useInsertionEffect||Dl;function Ml({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=Nl({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=Z.useRef(e!==void 0);Z.useEffect(()=>{let e=t.current;e!==s&&console.warn(`${r} is changing from ${e?`controlled`:`uncontrolled`} to ${s?`controlled`:`uncontrolled`}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),t.current=s},[s,r])}return[c,Z.useCallback(t=>{if(s){let n=Pl(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function Nl({defaultProp:e,onChange:t}){let[n,r]=Z.useState(e),i=Z.useRef(n),a=Z.useRef(t);return jl(()=>{a.current=t},[t]),Z.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function Pl(e){return typeof e==`function`}var Fl=t(En(),1);function Il(e){let t=Ll(e),n=Z.forwardRef((e,n)=>{let{children:r,...i}=e,a=Z.Children.toArray(r),o=a.find(zl);if(o){let e=o.props.children,r=a.map(t=>t===o?Z.Children.count(e)>1?Z.Children.only(null):Z.isValidElement(e)?e.props.children:null:t);return(0,Q.jsx)(t,{...i,ref:n,children:Z.isValidElement(e)?Z.cloneElement(e,void 0,r):null})}return(0,Q.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function Ll(e){let t=Z.forwardRef((e,t)=>{let{children:n,...r}=e;if(Z.isValidElement(n)){let e=Vl(n),i=Bl(r,n.props);return n.type!==Z.Fragment&&(i.ref=t?Sl(t,e):e),Z.cloneElement(n,i)}return Z.Children.count(n)>1?Z.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Rl=Symbol(`radix.slottable`);function zl(e){return Z.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===Rl}function Bl(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function Vl(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Hl=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=Il(`Primitive.${t}`),r=Z.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,Q.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Ul(e,t){e&&Fl.flushSync(()=>e.dispatchEvent(t))}function Wl(e){let t=Z.useRef(e);return Z.useEffect(()=>{t.current=e}),Z.useMemo(()=>(...e)=>t.current?.(...e),[])}function Gl(e,t=globalThis?.document){let n=Wl(e);Z.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var Kl=`DismissableLayer`,ql=`dismissableLayer.update`,Jl=`dismissableLayer.pointerDownOutside`,Yl=`dismissableLayer.focusOutside`,Xl,Zl=Z.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ql=Z.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:s,...c}=e,l=Z.useContext(Zl),[u,d]=Z.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=Z.useState({}),m=Cl(t,e=>d(e)),h=Array.from(l.layers),[g]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),_=h.indexOf(g),v=u?h.indexOf(u):-1,y=l.layersWithOutsidePointerEventsDisabled.size>0,b=v>=_,x=tu(e=>{let t=e.target,n=[...l.branches].some(e=>e.contains(t));!b||n||(i?.(e),o?.(e),e.defaultPrevented||s?.())},f),S=nu(e=>{let t=e.target;[...l.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||s?.())},f);return Gl(e=>{v===l.layers.size-1&&(r?.(e),!e.defaultPrevented&&s&&(e.preventDefault(),s()))},f),Z.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(Xl=f.body.style.pointerEvents,f.body.style.pointerEvents=`none`),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),ru(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=Xl)}},[u,f,n,l]),Z.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),ru())},[u,l]),Z.useEffect(()=>{let e=()=>p({});return document.addEventListener(ql,e),()=>document.removeEventListener(ql,e)},[]),(0,Q.jsx)(Hl.div,{...c,ref:m,style:{pointerEvents:y?b?`auto`:`none`:void 0,...e.style},onFocusCapture:bl(e.onFocusCapture,S.onFocusCapture),onBlurCapture:bl(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:bl(e.onPointerDownCapture,x.onPointerDownCapture)})});Ql.displayName=Kl;var $l=`DismissableLayerBranch`,eu=Z.forwardRef((e,t)=>{let n=Z.useContext(Zl),r=Z.useRef(null),i=Cl(t,r);return Z.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,Q.jsx)(Hl.div,{...e,ref:i})});eu.displayName=$l;function tu(e,t=globalThis?.document){let n=Wl(e),r=Z.useRef(!1),i=Z.useRef(()=>{});return Z.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){iu(Jl,n,a,{discrete:!0})},a={originalEvent:e};e.pointerType===`touch`?(t.removeEventListener(`click`,i.current),i.current=r,t.addEventListener(`click`,i.current,{once:!0})):r()}else t.removeEventListener(`click`,i.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener(`pointerdown`,e)},0);return()=>{window.clearTimeout(a),t.removeEventListener(`pointerdown`,e),t.removeEventListener(`click`,i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function nu(e,t=globalThis?.document){let n=Wl(e),r=Z.useRef(!1);return Z.useEffect(()=>{let e=e=>{e.target&&!r.current&&iu(Yl,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function ru(){let e=new CustomEvent(ql);document.dispatchEvent(e)}function iu(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Ul(i,a):i.dispatchEvent(a)}var au=`focusScope.autoFocusOnMount`,ou=`focusScope.autoFocusOnUnmount`,su={bubbles:!1,cancelable:!0},cu=`FocusScope`,lu=Z.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=Z.useState(null),l=Wl(i),u=Wl(a),d=Z.useRef(null),f=Cl(t,e=>c(e)),p=Z.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;Z.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:gu(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||gu(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&gu(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),Z.useEffect(()=>{if(s){_u.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(au,su);s.addEventListener(au,l),s.dispatchEvent(t),t.defaultPrevented||(uu(bu(fu(s)),{select:!0}),document.activeElement===e&&gu(s))}return()=>{s.removeEventListener(au,l),setTimeout(()=>{let t=new CustomEvent(ou,su);s.addEventListener(ou,u),s.dispatchEvent(t),t.defaultPrevented||gu(e??document.body,{select:!0}),s.removeEventListener(ou,u),_u.remove(p)},0)}}},[s,l,u,p]);let m=Z.useCallback(e=>{if(!n&&!r||p.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=du(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&gu(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&gu(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,Q.jsx)(Hl.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});lu.displayName=cu;function uu(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(gu(r,{select:t}),document.activeElement!==n)return}function du(e){let t=fu(e);return[pu(t,e),pu(t.reverse(),e)]}function fu(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function pu(e,t){for(let n of e)if(!mu(n,{upTo:t}))return n}function mu(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function hu(e){return e instanceof HTMLInputElement&&`select`in e}function gu(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&hu(e)&&t&&e.select()}}var _u=vu();function vu(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=yu(e,t),e.unshift(t)},remove(t){e=yu(e,t),e[0]?.resume()}}}function yu(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function bu(e){return e.filter(e=>e.tagName!==`A`)}var xu=`Portal`,Su=Z.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=Z.useState(!1);Dl(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?Fl.createPortal((0,Q.jsx)(Hl.div,{...r,ref:t}),o):null});Su.displayName=xu;function fee(e,t){return Z.useReducer((e,n)=>t[e][n]??e,e)}var Cu=e=>{let{present:t,children:n}=e,r=pee(t),i=typeof n==`function`?n({present:r.isPresent}):Z.Children.only(n),a=Cl(r.ref,mee(i));return typeof n==`function`||r.isPresent?Z.cloneElement(i,{ref:a}):null};Cu.displayName=`Presence`;function pee(e){let[t,n]=Z.useState(),r=Z.useRef(null),i=Z.useRef(e),a=Z.useRef(`none`),[o,s]=fee(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return Z.useEffect(()=>{let e=wu(r.current);a.current=o===`mounted`?e:`none`},[o]),Dl(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=wu(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),Dl(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=wu(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(s(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},c=e=>{e.target===t&&(a.current=wu(r.current))};return t.addEventListener(`animationstart`,c),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,c),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:Z.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function wu(e){return e?.animationName||`none`}function mee(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Tu=0;function hee(){Z.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??Eu()),document.body.insertAdjacentElement(`beforeend`,e[1]??Eu()),Tu++,()=>{Tu===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),Tu--}},[])}function Eu(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var Du=function(){return Du=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Du.apply(this,arguments)};function Ou(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function gee(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var ku=`right-scroll-bar-position`,Au=`width-before-scroll-bar`,_ee=`with-scroll-bars-hidden`,vee=`--removed-body-scroll-bar-size`;function ju(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function yee(e,t){var n=(0,Z.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var bee=typeof window<`u`?Z.useLayoutEffect:Z.useEffect,Mu=new WeakMap;function xee(e,t){var n=yee(t||null,function(t){return e.forEach(function(e){return ju(e,t)})});return bee(function(){var t=Mu.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||ju(e,null)}),i.forEach(function(e){r.has(e)||ju(e,a)})}Mu.set(n,e)},[e]),n}function See(e){return e}function Cee(e,t){t===void 0&&(t=See);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function wee(e){e===void 0&&(e={});var t=Cee(null);return t.options=Du({async:!0,ssr:!1},e),t}var Nu=function(e){var t=e.sideCar,n=Ou(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return Z.createElement(r,Du({},n))};Nu.isSideCarExport=!0;function Tee(e,t){return e.useMedium(t),Nu}var Pu=wee(),Fu=function(){},Iu=Z.forwardRef(function(e,t){var n=Z.useRef(null),r=Z.useState({onScrollCapture:Fu,onWheelCapture:Fu,onTouchMoveCapture:Fu}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,b=Ou(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=xee([n,t]),C=Du(Du({},b),i);return Z.createElement(Z.Fragment,null,u&&Z.createElement(x,{sideCar:Pu,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?Z.cloneElement(Z.Children.only(s),Du(Du({},C),{ref:S})):Z.createElement(v,Du({},C,{className:c,ref:S}),s))});Iu.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Iu.classNames={fullWidth:Au,zeroRight:ku};var Lu,Ru=function(){if(Lu)return Lu;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function zu(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=Ru();return t&&e.setAttribute(`nonce`,t),e}function Bu(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Vu(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var Hu=function(){var e=0,t=null;return{add:function(n){e==0&&(t=zu())&&(Bu(t,n),Vu(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Uu=function(){var e=Hu();return function(t,n){Z.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Wu=function(){var e=Uu();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},Gu={left:0,top:0,right:0,gap:0},Ku=function(e){return parseInt(e||``,10)||0},qu=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[Ku(n),Ku(r),Ku(i)]},Ju=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return Gu;var t=qu(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Yu=Wu(),Xu=`data-scroll-locked`,Zu=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
2
|
+
import{n as e,r as t,t as n}from"./rolldown-runtime-S-ySWqyJ.js";import{$ as r,$r as i,$t as a,A as o,An as s,Ar as c,At as l,B as u,Bn as d,Br as f,Bt as p,C as m,Cn as h,Cr as g,Ct as _,D as v,Dn as y,Dr as b,Dt as x,E as S,En as C,Er as w,Et as T,F as E,Fn as D,Fr as O,Ft as k,G as A,Gn as j,Gr as M,Gt as N,H as P,Hn as F,Hr as I,Ht as L,I as R,In as z,Ir as B,It as V,J as H,Jn as U,Jr as W,Jt as G,K as ee,Kn as te,Kr as K,Kt as ne,L as q,Ln as J,Lr as re,Lt as Y,M as ie,Mn as ae,Mr as oe,Mt as se,N as ce,Nn as le,Nr as ue,Nt as de,O as fe,On as pe,Or as me,Ot as he,P as ge,Pn as _e,Pr as ve,Pt as ye,Q as be,Qn as xe,Qr as Se,Qt as Ce,R as we,Rn as Te,Rr as Ee,Rt as De,S as Oe,Sn as ke,Sr as Ae,St as je,T as Me,Tn as Ne,Tr as Pe,Tt as Fe,U as Ie,Un as Le,Ur as Re,Ut as ze,V as Be,Vn as Ve,Vr as He,Vt as Ue,W as We,Wn as Ge,Wr as Ke,Wt as qe,X as Je,Xn as Ye,Xr as Xe,Xt as Ze,Y as Qe,Yn as $e,Yr as et,Yt as tt,Z as nt,Zn as rt,Zr as it,Zt as at,_ as ot,_n as st,_r as ct,_t as lt,a as ut,an as dt,at as ft,b as pt,bn as mt,br as ht,bt as gt,c as _t,cn as vt,cr as yt,ct as bt,d as xt,dn as St,dr as Ct,dt as wt,ei as Tt,en as Et,er as Dt,et as Ot,f as kt,fn as At,fr as jt,ft as Mt,g as Nt,gn as Pt,gr as Ft,gt as It,h as Lt,hn as Rt,hr as zt,ht as Bt,i as Vt,ii as Ht,in as Ut,ir as Wt,it as Gt,j as Kt,jn as qt,jr as Jt,jt as Yt,k as Xt,kn as Zt,kr as Qt,kt as $t,l as en,ln as tn,lr as nn,lt as rn,m as an,mn as on,mr as sn,mt as cn,n as X,ni as ln,nn as un,nr as dn,nt as fn,o as pn,on as mn,or as hn,ot as gn,p as _n,pn as vn,pr as yn,pt as bn,q as xn,qn as Sn,qr as Cn,qt as wn,r as Tn,ri as En,rn as Dn,rr as On,rt as kn,s as An,sn as jn,st as Mn,t as Nn,ti as Pn,tn as Fn,tr as In,tt as Ln,u as Rn,un as zn,ur as Bn,ut as Vn,v as Hn,vn as Un,vr as Wn,vt as Gn,w as Kn,wn as qn,wr as Jn,wt as Yn,x as Xn,xn as Zn,xr as Qn,xt as $n,y as er,yn as tr,yr as nr,yt as rr,z as eee,zn as ir,zr as ar,zt as or}from"./index-CksX3NW4.js";var sr=class extends ln{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=I(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),lr(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ur(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ur(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof et(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!it(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&dr(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||et(this.options.enabled,this.#t)!==et(t.enabled,this.#t)||Xe(this.options.staleTime,this.#t)!==Xe(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||et(this.options.enabled,this.#t)!==et(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return pr(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(K)),t}#g(){this.#b();let e=Xe(this.options.staleTime,this.#t);if(Re.isServer()||this.#r.isStale||!M(e))return;let t=i(this.#r.dataUpdatedAt,e)+1;this.#d=Tt.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(Re.isServer()||et(this.options.enabled,this.#t)===!1||!M(this.#p)||this.#p===0)&&(this.#f=Tt.setInterval(()=>{(this.options.refetchIntervalInBackground||Pn.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(Tt.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(Tt.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&lr(e,t),o=i&&dr(e,n,t,r);(a||o)&&(l={...l,...f(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:p,errorUpdatedAt:m,status:h}=l;d=l.data;let g=!1;if(t.placeholderData!==void 0&&d===void 0&&h===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,g=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(h=`success`,d=Cn(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!g)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=Cn(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(p=this.#s,d=this.#l,m=Date.now(),h=`error`);let _=l.fetchStatus===`fetching`,v=h===`pending`,y=h===`error`,b=v&&_,x=d!==void 0,S={status:h,fetchStatus:l.fetchStatus,isPending:v,isSuccess:h===`success`,isError:y,isInitialLoading:b,isLoading:b,data:d,dataUpdatedAt:l.dataUpdatedAt,error:p,errorUpdatedAt:m,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:_,isRefetching:_&&!v,isLoadingError:y&&!x,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:y&&x,isStale:fr(e,t),refetch:this.refetch,promise:this.#o,isEnabled:et(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=S.data!==void 0,r=S.status===`error`&&!t,i=e=>{r?e.reject(S.error):t&&e.resolve(S.data)},a=()=>{i(this.#o=S.promise=I())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||S.data!==o.value)&&a();break;case`rejected`:(!r||S.error!==o.reason)&&a();break}}return S}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!it(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){He.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function cr(e,t){return et(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&t.retryOnMount===!1)}function lr(e,t){return cr(e,t)||e.state.data!==void 0&&ur(e,t,t.refetchOnMount)}function ur(e,t,n){if(et(t.enabled,e)!==!1&&Xe(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&fr(e,t)}return!1}function dr(e,t,n,r){return(e!==t||et(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&fr(e,n)}function fr(e,t){return et(t.enabled,e)!==!1&&e.isStaleByTime(Xe(t.staleTime,e))}function pr(e,t){return!it(e.getCurrentResult(),t)}var mr=class extends ln{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),it(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&Ke(t.mutationKey)!==Ke(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??ar();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){He.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},Z=t(Ht(),1),hr=Z.createContext(!1),gr=()=>Z.useContext(hr);hr.Provider;var Q=Ee();function _r(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var vr=Z.createContext(_r()),yr=()=>Z.useContext(vr),br=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?Se(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},xr=e=>{Z.useEffect(()=>{e.clearReset()},[e])},Sr=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Se(n,[e.error,r])),Cr=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},wr=(e,t)=>e.isLoading&&e.isFetching&&!t,Tr=(e,t)=>e?.suspense&&t.isPending,Er=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Dr(e,t,n){let r=gr(),i=yr(),a=re(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?`isRestoring`:`optimistic`,Cr(o),br(o,i,s),xr(i);let c=!a.getQueryCache().get(o.queryHash),[l]=Z.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&e.subscribed!==!1;if(Z.useSyncExternalStore(Z.useCallback(e=>{let t=d?l.subscribe(He.batchCalls(e)):K;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),Z.useEffect(()=>{l.setOptions(o)},[o,l]),Tr(o,u))throw Er(o,l,i);if(Sr({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!Re.isServer()&&wr(u,r)&&(c?Er(o,l,i):s?.promise)?.catch(K).finally(()=>{l.updateResult()}),o.notifyOnChangeProps?u:l.trackResult(u)}function Or(e,t){return Dr(e,sr,t)}function kr(e,t){let n=re(t),r=n.getQueryCache();return Z.useSyncExternalStore(Z.useCallback(e=>r.subscribe(He.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}function Ar(e,t){let n=re(t);return Mr({filters:{...e,status:`pending`}},n).length}function jr(e,t){return e.findAll(t.filters).map(e=>t.select?t.select(e):e.state)}function Mr(e={},t){let n=re(t).getMutationCache(),r=Z.useRef(e),i=Z.useRef(null);return i.current===null&&(i.current=jr(n,e)),Z.useEffect(()=>{r.current=e}),Z.useSyncExternalStore(Z.useCallback(e=>n.subscribe(()=>{let t=W(i.current,jr(n,r.current));i.current!==t&&(i.current=t,He.schedule(e))}),[n]),()=>i.current,()=>i.current)}function Nr(e,t){let n=re(t),[r]=Z.useState(()=>new mr(n,e));Z.useEffect(()=>{r.setOptions(e)},[r,e]);let i=Z.useSyncExternalStore(Z.useCallback(e=>r.subscribe(He.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=Z.useCallback((e,t)=>{r.mutate(e,t).catch(K)},[r]);if(i.error&&Se(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function Pr(e){return typeof e==`object`&&!!e&&`current`in e}function Fr(){if(typeof navigator>`u`)return`linux`;let e=navigator.platform?.toLowerCase()??``,t=navigator.userAgent?.toLowerCase()??``;return e.includes(`mac`)||t.includes(`mac`)?`mac`:e.includes(`win`)||t.includes(`win`)?`windows`:`linux`}var Ir=[`Control`,`Alt`,`Shift`,`Meta`];new Set(Ir);var Lr={Control:`Control`,Ctrl:`Control`,control:`Control`,ctrl:`Control`,Shift:`Shift`,shift:`Shift`,Alt:`Alt`,Option:`Alt`,alt:`Alt`,option:`Alt`,Command:`Meta`,Cmd:`Meta`,Meta:`Meta`,command:`Meta`,cmd:`Meta`,meta:`Meta`,OS:`Meta`,os:`Meta`,Win:`Meta`,win:`Meta`,CommandOrControl:`Mod`,Mod:`Mod`,commandorcontrol:`Mod`,mod:`Mod`};function Rr(e,t=Fr()){return e===`Mod`?t===`mac`?`Meta`:`Control`:e}var zr=new Set(`ABCDEFGHIJKLMNOPQRSTUVWXYZ`.split(``)),Br=new Set([`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`]),Vr=new Set([`F1`,`F2`,`F3`,`F4`,`F5`,`F6`,`F7`,`F8`,`F9`,`F10`,`F11`,`F12`]),Hr=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`,`PageUp`,`PageDown`]),Ur=new Set([`Enter`,`Escape`,`Space`,`Tab`,`Backspace`,`Delete`]),Wr=new Set([`/`,`[`,`]`,`\\`,`=`,`-`,`,`,`.`,`;`,"`"]),Gr={Backquote:"`",Backslash:`\\`,BracketLeft:`[`,BracketRight:`]`,Comma:`,`,Equal:`=`,Minus:`-`,Period:`.`,Semicolon:`;`,Slash:`/`};new Set([...zr,...Br,...Vr,...Hr,...Ur,...Wr]);var Kr={Esc:`Escape`,esc:`Escape`,escape:`Escape`,Return:`Enter`,return:`Enter`,enter:`Enter`," ":`Space`,space:`Space`,Spacebar:`Space`,spacebar:`Space`,tab:`Tab`,backspace:`Backspace`,Del:`Delete`,del:`Delete`,delete:`Delete`,Up:`ArrowUp`,up:`ArrowUp`,arrowup:`ArrowUp`,Down:`ArrowDown`,down:`ArrowDown`,arrowdown:`ArrowDown`,Left:`ArrowLeft`,left:`ArrowLeft`,arrowleft:`ArrowLeft`,Right:`ArrowRight`,right:`ArrowRight`,arrowright:`ArrowRight`,home:`Home`,end:`End`,pageup:`PageUp`,pagedown:`PageDown`,PgUp:`PageUp`,PgDn:`PageDown`,pgup:`PageUp`,pgdn:`PageDown`};function qr(e){return/^\p{Letter}$/u.test(e)}function Jr(e){if(!e)return``;if(e in Kr)return Kr[e];if(qr(e)){let t=e.toUpperCase();return t.length===1?t:e}let t=e.toUpperCase();return/^F([1-9]|1[0-2])$/.test(t)?t:e}var Yr={Control:`⌃`,Alt:`⌥`,Shift:`⇧`,Meta:`⌘`,Mod:`⌘`},Xr={Control:`Control`,Alt:`Option`,Shift:`Shift`,Meta:`Cmd`,Mod:`Cmd`},Zr={Control:`Ctrl`,Alt:`Alt`,Shift:`Shift`,Meta:`Win`,Mod:`Ctrl`},Qr={...Zr,Meta:`Super`},$r={"`":`Backquote`,"\\":`Backslash`,"[":`Left Bracket`,"]":`Right Bracket`,",":`Comma`,"=":`Equal`,"-":`Minus`,".":`Period`,";":`Semicolon`},ei={ArrowUp:`↑`,ArrowDown:`↓`,ArrowLeft:`←`,ArrowRight:`→`,Enter:`↵`,Escape:`Esc`,Backspace:`⌫`,Delete:`⌦`,Tab:`⇥`,Space:`␣`};function ti(e,t=Fr()){let n=e.split(`+`),r=new Set,i=``;for(let e=0;e<n.length;e++){let a=n[e].trim();if(e===n.length-1)i=Jr(a);else{let e=Lr[a]??Lr[a.toLowerCase()];if(e){let n=Rr(e,t);r.add(n)}else n.length===1&&(i=Jr(a))}}return!i&&n.length>0&&(i=Jr(n[n.length-1].trim())),{key:i,ctrl:r.has(`Control`),shift:r.has(`Shift`),alt:r.has(`Alt`),meta:r.has(`Meta`),modifiers:Ir.filter(e=>r.has(e))}}function ni(e,t=Fr()){let n=e.ctrl??!1,r=e.shift??!1,i=e.alt??!1,a=e.meta??!1;e.mod&&(Rr(`Mod`,t)===`Control`?n=!0:a=!0);let o=Ir.filter(e=>{switch(e){case`Control`:return n;case`Shift`:return r;case`Alt`:return i;case`Meta`:return a;default:return!1}});return{key:e.key,ctrl:n,shift:r,alt:i,meta:a,modifiers:o}}function ri(e,t){let n=t===`mac`?e.meta&&!e.ctrl:e.ctrl&&!e.meta,r=[];if(n)r.push(`Mod`),e.alt&&r.push(`Alt`),e.shift&&r.push(`Shift`);else for(let t of Ir)e.modifiers.includes(t)&&r.push(t);return r.push(Jr(e.key)),r.join(`+`)}function ii(e,t=Fr()){return ri(ti(e,t),t)}function ai(e,t=Fr()){return ri(e,t)}function oi(e,t=Fr()){return typeof e==`string`?ii(e,t):ai(ni(e,t),t)}function si(e){return e in Lr||e.toLowerCase()in Lr}function ci(e){let t=[];for(let n of Ir)e.modifiers.includes(n)&&t.push(n);return t.push(e.key),t.join(`+`)}function li(e,t={}){let n=t.platform??Fr(),r=t.useSymbols??!0,i=t.separatorToken??(n===`mac`&&r?` `:`+`);return oi(e,n).split(`+`).map(e=>{if(si(e)){let t=Lr[e]??Lr[e.toLowerCase()];return n===`mac`?r?Yr[t]:Xr[t]:n===`windows`?Zr[t]:Qr[t]}else return r&&ei[e]||!r&&$r[e]||e}).join(i)}function ui(e,t,n=Fr()){let r=typeof t==`string`?ti(t,n):t;if(e.ctrlKey!==r.ctrl||e.shiftKey!==r.shift||e.altKey!==r.alt||e.metaKey!==r.meta)return!1;let i=Jr(e.key),a=r.key;if(i!==`Dead`&&i.length===1&&a.length===1){if(i.toUpperCase()===a.toUpperCase())return!0;if(qr(i)&&(/^[A-Za-z]$/.test(i)||!e.altKey))return!1}if(e.code&&(i===`Dead`||i.length===1&&a.length===1)){if(e.code.startsWith(`Key`)){let t=e.code.slice(3);if(t.length===1&&/^[A-Za-z]$/.test(t))return t.toUpperCase()===a.toUpperCase()}if(e.code.startsWith(`Digit`)){let t=e.code.slice(5);if(t.length===1&&/^[0-9]$/.test(t))return t===a}return e.code in Gr?Gr[e.code]===a:!1}return i===a}var di={preventDefault:!0,stopPropagation:!0,eventType:`keydown`,enabled:!0,ignoreInputs:!0,conflictBehavior:`warn`};function fi(e){return!(e.ctrl||e.meta||e.key===`Escape`)}function pi(e){if(!e)return!1;if(e instanceof HTMLInputElement){let t=e.type.toLowerCase();return!(t===`button`||t===`submit`||t===`reset`)}return!!(e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable)}function mi(e){return typeof document>`u`?null:typeof Document<`u`&&e instanceof Document||typeof Node<`u`&&e.nodeType===Node.DOCUMENT_NODE?e.activeElement:typeof HTMLElement<`u`&&e instanceof HTMLElement?e.ownerDocument.activeElement??null:e.document.activeElement??null}function hi(e,t,n){let r=mi(t);return r&&pi(r)&&r!==n||e.composedPath().some(e=>pi(e)&&e!==n)?!0:pi(e.target)&&e.target!==n}function gi(e,t){return t===document||t===window?e.currentTarget===t||e.currentTarget===document.documentElement:t===window?e.currentTarget===window||e.currentTarget===document||e.currentTarget===document.documentElement:!!(t instanceof HTMLElement&&(e.currentTarget===t||e.target instanceof Node&&t.contains(e.target)))}function _i(e,t,n,r){if(n!==`allow`){if(n===`warn`){console.warn(`'${t}' is already registered. Multiple handlers will be triggered. Use conflictBehavior: 'replace' to replace the existing handler, or conflictBehavior: 'allow' to suppress this warning.`);return}if(n===`error`)throw Error(`'${t}' is already registered. Use conflictBehavior: 'replace' to replace the existing handler, or conflictBehavior: 'allow' to allow multiple registrations.`);r(e)}}var vi=function(e){return e[e.None=0]=`None`,e[e.Mutable=1]=`Mutable`,e[e.Watching=2]=`Watching`,e[e.RecursedCheck=4]=`RecursedCheck`,e[e.Recursed=8]=`Recursed`,e[e.Dirty=16]=`Dirty`,e[e.Pending=32]=`Pending`,e}({});function yi({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&(vi.RecursedCheck|vi.Recursed|vi.Dirty|vi.Pending)?a&(vi.RecursedCheck|vi.Recursed)?a&vi.RecursedCheck?!(a&(vi.Dirty|vi.Pending))&&c(e,i)?(i.flags=a|(vi.Recursed|vi.Pending),a&=vi.Mutable):a=vi.None:i.flags=a&~vi.Recursed|vi.Pending:a=vi.None:i.flags=a|vi.Pending,a&vi.Watching&&t(i),a&vi.Mutable){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(!0)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&vi.Dirty)a=!0;else if((c&(vi.Mutable|vi.Dirty))===(vi.Mutable|vi.Dirty)){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&(vi.Mutable|vi.Pending))===(vi.Mutable|vi.Pending)){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=~vi.Pending;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(!0)}function s(e){do{let n=e.sub,r=n.flags;(r&(vi.Pending|vi.Dirty))===vi.Pending&&(n.flags=r|vi.Dirty,(r&(vi.Watching|vi.RecursedCheck))===vi.Watching&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function bi(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var xi=[],Si=0,{link:Ci,unlink:wi,propagate:Ti,checkDirty:Ei,shallowPropagate:Di}=yi({update(e){return e._update()},notify(e){xi[ki++]=e,e.flags&=~vi.Watching},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=vi.Mutable|vi.Dirty,Ni(e))}}),Oi=0,ki=0,Ai,ji=0;function Mi(e){try{++ji,e()}finally{--ji||Pi()}}function Ni(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=wi(n,e)}function Pi(){if(!(ji>0)){for(;Oi<ki;){let e=xi[Oi];xi[Oi++]=void 0,e.notify()}Oi=0,ki=0}}function Fi(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:n?vi.None:vi.Mutable,get(){return Ai!==void 0&&Ci(i,Ai,Si),i._snapshot},subscribe(e){let t=bi(e),n={current:!1},r=Ii(()=>{i.get(),n.current?t.next?.(i._snapshot):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=Ai,o=t?.compare??Object.is;if(n)Ai=i,++Si,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=vi.Mutable|vi.RecursedCheck);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{Ai=a,n&&(i.flags&=~vi.RecursedCheck),Ni(i)}}};return n?(i.flags=vi.Mutable|vi.Dirty,i.get=function(){let e=i.flags;if(e&vi.Dirty||e&vi.Pending&&Ei(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&Di(e)}}else e&vi.Pending&&(i.flags=e&~vi.Pending);return Ai!==void 0&&Ci(i,Ai,Si),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(Ti(e),Di(e),Pi())}},i}function Ii(e){let t=()=>{let t=Ai;Ai=n,++Si,n.depsTail=void 0,n.flags=vi.Watching|vi.RecursedCheck;try{return e()}finally{Ai=t,n.flags&=~vi.RecursedCheck,Ni(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:vi.Watching|vi.RecursedCheck,notify(){let e=this.flags;e&vi.Dirty||e&vi.Pending&&Ei(this.deps,this)?t():this.flags=vi.Watching},stop(){this.flags=vi.None,this.depsTail=void 0,Ni(this)}};return t(),n}var Li=class{constructor(e,t){this.atom=Fi(e),this.get=this.get.bind(this),this.setState=this.setState.bind(this),this.subscribe=this.subscribe.bind(this),t&&(this.actions=t(this))}setState(e){this.atom.set(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(bi(e))}},Ri=class{constructor(e){this.atom=Fi(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(bi(e))}};function zi(e,t){return typeof e==`function`?new Ri(e):t?new Li(e,t):new Li(e)}function Bi(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();let n=Vi(e);if(n.length!==Vi(t).length)return!1;for(let r=0;r<n.length;r++)if(!Object.prototype.hasOwnProperty.call(t,n[r])||!Object.is(e[n[r]],t[n[r]]))return!1;return!0}function Vi(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e))}var tee=0;function Hi(){return`hotkey_${++tee}`}var Ui=class e{static#e=null;#t;#n=new Map;#r=new Map;constructor(){this.registrations=new Li(new Map),this.#t=Fr()}static getInstance(){return e.#e||=new e,e.#e}static resetInstance(){e.#e&&=(e.#e.destroy(),null)}register(e,t,n={}){if(typeof document>`u`&&!n.target){let e=t;return{id:Hi(),unregister:()=>{},get callback(){return e},set callback(t){e=t},setOptions:()=>{},get isActive(){return!1}}}let r=Hi(),i=n.platform??this.#t,a=typeof e==`string`?ti(e,i):ni(e,i),o=typeof e==`string`?e:ci(a),s=n.target??document,c=n.conflictBehavior??`warn`,l=this.#d(o,s);l&&_i(l.id,o,c,e=>this.#i(e));let u=n.ignoreInputs??fi(a),d={id:r,hotkey:o,parsedHotkey:a,callback:t,options:{...di,requireReset:!1,...n,platform:i,ignoreInputs:u},hasFired:!1,triggerCount:0,target:s};this.registrations.setState(e=>new Map(e).set(r,d)),this.#r.has(s)||this.#r.set(s,new Set),this.#r.get(s).add(r),this.#a(s);let f=this;return{get id(){return r},unregister:()=>{f.#i(r)},get callback(){return f.registrations.state.get(r)?.callback??t},set callback(e){let t=f.registrations.state.get(r);t&&(t.callback=e)},setOptions:e=>{f.registrations.setState(t=>{let n=t.get(r);if(n){let i=new Map(t);return i.set(r,{...n,options:{...n.options,...e}}),i}return t})},get isActive(){return f.registrations.state.has(r)}}}#i(e){let t=this.registrations.state.get(e);if(!t)return;let n=t.target;this.registrations.setState(t=>{let n=new Map(t);return n.delete(e),n});let r=this.#r.get(n);r&&(r.delete(e),r.size===0&&this.#o(n))}#a(e){if(typeof document>`u`||this.#n.has(e))return;let t=this.#l(e),n=this.#u(e);e.addEventListener(`keydown`,t),e.addEventListener(`keyup`,n),this.#n.set(e,{keydown:t,keyup:n})}#o(e){if(typeof document>`u`)return;let t=this.#n.get(e);t&&(e.removeEventListener(`keydown`,t.keydown),e.removeEventListener(`keyup`,t.keyup),this.#n.delete(e),this.#r.delete(e))}#s(e,t,n){let r=this.#r.get(t);if(r)for(let i of r){let r=this.registrations.state.get(i);if(r&&gi(e,t)&&r.options.enabled&&!(r.options.ignoreInputs!==!1&&hi(e,t,r.target)))if(n===`keydown`){if(r.options.eventType!==`keydown`)continue;ui(e,r.parsedHotkey,r.options.platform)&&(r.options.preventDefault&&e.preventDefault(),r.options.stopPropagation&&e.stopPropagation(),(!r.options.requireReset||!r.hasFired)&&(this.#c(r,e),r.options.requireReset&&(r.hasFired=!0)))}else r.options.eventType===`keyup`&&ui(e,r.parsedHotkey,r.options.platform)&&this.#c(r,e),r.options.requireReset&&r.hasFired&&this.#f(r,e)&&(r.hasFired=!1)}}#c(e,t){e.options.preventDefault&&t.preventDefault(),e.options.stopPropagation&&t.stopPropagation(),e.triggerCount++,this.registrations.setState(e=>new Map(e));let n={hotkey:e.hotkey,parsedHotkey:e.parsedHotkey};e.callback(t,n)}#l(e){return t=>{this.#s(t,e,`keydown`)}}#u(e){return t=>{this.#s(t,e,`keyup`)}}#d(e,t){for(let n of this.registrations.state.values())if(n.hotkey===e&&n.target===t)return n;return null}#f(e,t){let n=e.parsedHotkey,r=Jr(t.key),i=n.key.length===1?n.key.toUpperCase():n.key;return!!((r.length===1?r.toUpperCase():r)===i||n.ctrl&&r===`Control`||n.shift&&r===`Shift`||n.alt&&r===`Alt`||n.meta&&r===`Meta`)}triggerRegistration(e){let t=this.registrations.state.get(e);if(!t)return!1;let n=t.parsedHotkey,r=new KeyboardEvent(t.options.eventType??`keydown`,{key:n.key,ctrlKey:n.ctrl,shiftKey:n.shift,altKey:n.alt,metaKey:n.meta,bubbles:!0,cancelable:!0});return t.triggerCount++,this.registrations.setState(e=>new Map(e)),t.callback(r,{hotkey:t.hotkey,parsedHotkey:t.parsedHotkey}),!0}getRegistrationCount(){return this.registrations.state.size}isRegistered(e,t){for(let n of this.registrations.state.values())if(n.hotkey===e&&(t===void 0||n.target===t))return!0;return!1}destroy(){for(let e of this.#n.keys())this.#o(e);this.registrations.setState(()=>new Map),this.#n.clear(),this.#r.clear()}};function Wi(){return Ui.getInstance()}function Gi(e,t={}){let n=ve().hotkey,r=Wi(),i=t.platform??n?.platform??Fr(),a=(0,Z.useRef)(new Map),o=(0,Z.useRef)(e),s=(0,Z.useRef)([]),c=(0,Z.useRef)(t),l=(0,Z.useRef)(n),u=(0,Z.useRef)(r),d=e.map(e=>oi(e.hotkey,i));o.current=e,s.current=d,c.current=t,l.current=n,u.current=r,(0,Z.useEffect)(()=>{let e=a.current,t=new Map,n=[];for(let e=0;e<o.current.length;e++){let t=o.current[e],r=s.current[e],i={...l.current,...c.current,...t.options},a=Pr(i.target)?i.target.current:i.target??(typeof document<`u`?document:null);if(!a)continue;let u=`${e}:${r}`;n.push({registrationKey:u,def:t,hotkeyStr:r,mergedOptions:i,resolvedTarget:a})}let r=new Set(n.map(e=>e.registrationKey));for(let[t,n]of e)!r.has(t)&&n.handle.isActive&&n.handle.unregister();for(let r of n){let{registrationKey:n,def:i,hotkeyStr:a,mergedOptions:o,resolvedTarget:s}=r,c=e.get(n);if(c?.handle.isActive&&c.target===s){t.set(n,c);continue}c?.handle.isActive&&c.handle.unregister();let l=u.current.register(a,i.callback,{...o,target:s});t.set(n,{handle:l,target:s})}a.current=t}),(0,Z.useEffect)(()=>()=>{for(let{handle:e}of a.current.values())e.isActive&&e.unregister();a.current=new Map},[]);for(let r=0;r<e.length;r++){let i=e[r],o=d[r],s=`${r}:${o}`,c=a.current.get(s)?.handle;if(c?.isActive){c.callback=i.callback;let{target:e,...r}={...n,...t,...i.options};c.setOptions(r)}}}var Ki=B();function qi(e,t){return e===t}function Ji(e,t=e=>e,n){let r=n?.compare??qi,i=(0,Z.useCallback)(t=>{let{unsubscribe:n}=e.subscribe(t);return n},[e]),a=(0,Z.useCallback)(()=>e.get(),[e]);return(0,Ki.useSyncExternalStoreWithSelector)(i,a,a,t,r)}var Yi=0;function Xi(e,t={}){let{preventScroll:n=!1,cancelPrevious:r=!0,sync:i=!1}=t;r&&cancelAnimationFrame(Yi);let a=()=>e?.focus({preventScroll:n});if(i)return a(),zt;let o=requestAnimationFrame(a);return Yi=o,()=>{Yi===o&&(cancelAnimationFrame(o),Yi=0)}}var Zi={inert:new WeakMap,"aria-hidden":new WeakMap},Qi=`data-base-ui-inert`,$i={inert:new WeakSet,"aria-hidden":new WeakSet},ea=new WeakMap,ta=0;function na(e){return $i[e]}function ra(e){return e?$e(e)?e.host:ra(e.parentNode):null}var ia=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=ra(t);return e.contains(n)?n:null}).filter(e=>e!=null),aa=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},oa=(e,t,n)=>{let r=[],i=e=>{!e||n.has(e)||Array.from(e.children).forEach(e=>{F(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function sa(e,t,n,r,{mark:i=!0,markerIgnoreElements:a=[]}){let o=r?`inert`:n?`aria-hidden`:null,s=null,c=null,l=ia(t,e),u=i?ia(t,a):[],d=new Set(u),f=i?oa(t,aa(l),new Set(l)).filter(e=>!d.has(e)):[],p=[],m=[];if(o){let e=Zi[o],n=na(o);c=n,s=e;let r=ia(t,Array.from(t.querySelectorAll(`[aria-live]`))),i=l.concat(r);oa(t,aa(i),new Set(i)).forEach(t=>{let r=t.getAttribute(o),i=r!==null&&r!==`false`,a=(e.get(t)||0)+1;e.set(t,a),p.push(t),a===1&&i&&n.add(t),i||t.setAttribute(o,o===`inert`?``:`true`)})}return i&&f.forEach(e=>{let t=(ea.get(e)||0)+1;ea.set(e,t),m.push(e),t===1&&e.setAttribute(Qi,``)}),ta+=1,()=>{s&&p.forEach(e=>{let t=(s.get(e)||0)-1;s.set(e,t),t||(!c?.has(e)&&o&&e.removeAttribute(o),c?.delete(e))}),i&&m.forEach(e=>{let t=(ea.get(e)||0)-1;ea.set(e,t),t||e.removeAttribute(Qi)}),--ta,ta||(Zi.inert=new WeakMap,Zi[`aria-hidden`]=new WeakMap,$i.inert=new WeakSet,$i[`aria-hidden`]=new WeakSet,ea=new WeakMap)}}function ca(e,t={}){let{ariaHidden:n=!1,inert:r=!1,mark:i=!0,markerIgnoreElements:a=[]}=t,o=_e(e[0]).body;return sa(e,o,n,r,{mark:i,markerIgnoreElements:a})}function la(e,t){let n=Ge(pe(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||`keyboard`:`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var ua=20,da=[];function fa(){da=da.filter(e=>e.deref()?.isConnected)}function pa(e){fa(),e&&F(e)!==`body`&&(da.push(new WeakRef(e)),da.length>ua&&(da=da.slice(-ua)))}function ma(){return fa(),da[da.length-1]?.deref()}function ha(e){return e?St(e)?e:At(e)[0]||e:null}function ga(e){return!e||!e.isConnected?!1:typeof e.checkVisibility==`function`?e.checkVisibility():mt(e)}function _a(e,t){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!t.current.includes(`floating`)&&!e.getAttribute(`role`)?.includes(`dialog`))return;let n=dt(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return St(e)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),r=e.getAttribute(`tabindex`);t.current.includes(`floating`)||n.length===0?r!==`0`&&e.setAttribute(`tabindex`,`0`):(r!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}function va(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,restoreFocus:o=!1,modal:s=!0,closeOnFocusOut:c=!0,openInteractionType:l=``,nextFocusableElement:u,previousFocusableElement:f,beforeContentFocusGuardRef:p,externalTree:m,getInsideElements:_}=e,v=`rootStore`in t?t.rootStore:t,b=v.useState(`open`),x=v.useState(`domReferenceElement`),S=v.useState(`floatingElement`),{events:w,dataRef:T}=v.context,E=J(()=>T.current.floatingContext?.nodeId),D=i===!1,O=qn(x)&&D,k=Z.useRef([`content`]),A=Te(i),j=Te(a),M=Te(l),N=wn(m),P=Ze(),F=Z.useRef(!1),I=Z.useRef(!1),R=Z.useRef(!1),B=Z.useRef(null),V=Z.useRef(``),H=Z.useRef(``),U=Z.useRef(null),W=Z.useRef(null),G=ir(U,p,P?.beforeInsideRef),ee=ir(W,P?.afterInsideRef),K=Pe(),ne=Pe(),q=z(),re=P!=null,Y=h(S),ie=J((e=Y)=>e?At(e):[]),ae=J(()=>_?.().filter(e=>e!=null)??[]);Z.useEffect(()=>{if(r||!s)return;function e(e){e.key===`Tab`&&y(Y,C(_e(Y)))&&ie().length===0&&!O&&ht(e)}return Ve(_e(Y),`keydown`,e)},[r,x,Y,s,k,O,ie]),Z.useEffect(()=>{if(r||!b)return;let e=_e(Y);function t(){R.current=!1}function n(e){let t=pe(e),n=ae();R.current=!(y(S,t)||y(x,t)||y(P?.portalNode,t)||n.some(e=>e===t||y(e,t))),H.current=e.pointerType||`keyboard`,t?.closest(`[data-base-ui-click-trigger]`)&&(I.current=!0)}function i(){H.current=`keyboard`}return d(Ve(e,`pointerdown`,n,!0),Ve(e,`pointerup`,t,!0),Ve(e,`pointercancel`,t,!0),Ve(e,`keydown`,i,!0))},[r,S,x,Y,b,P,ae]),Z.useEffect(()=>{if(r||!c)return;let e=_e(Y);function t(){I.current=!0,ne.start(0,()=>{I.current=!1})}function n(e){let t=pe(e);St(t)&&(B.current=t)}function i(t){let n=t.relatedTarget,r=t.currentTarget,i=pe(t);queueMicrotask(()=>{let a=E(),c=v.context.triggerElements,l=ae(),d=n?.hasAttribute(un(`focus-guard`))&&[U.current,W.current,P?.beforeInsideRef.current,P?.afterInsideRef.current,P?.beforeOutsideRef.current,P?.afterOutsideRef.current,L(f),L(u)].includes(n),p=!(y(x,n)||y(S,n)||y(n,S)||y(P?.portalNode,n)||l.some(e=>e===n||y(e,n))||n!=null&&c.hasElement(n)||c.hasMatchingElement(e=>y(e,n))||d||N&&(Ut(N.nodesRef.current,a).find(e=>y(e.context?.elements.floating,n)||y(e.context?.elements.domReference,n))||Dn(N.nodesRef.current,a).find(e=>[e.context?.elements.floating,h(e.context?.elements.floating)].includes(n)||e.context?.elements.domReference===n)));if(r===x&&Y&&_a(Y,k),o&&r!==x&&!ga(i)&&C(e)===e.body){if(te(Y)&&(Y.focus(),o===`popup`)){q.request(()=>{Y.focus()});return}let e=ie(),t=B.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||Y;te(n)&&n.focus()}if(T.current.insideReactTree){T.current.insideReactTree=!1;return}(O||!s)&&n&&p&&!I.current&&(O||n!==ma())&&(F.current=!0,v.setOpen(!1,Ye(Dt,t)))})}function a(){R.current||(T.current.insideReactTree=!0,K.start(0,()=>{T.current.insideReactTree=!1}))}let l=te(x)?x:null;if(!(!S&&!l))return d(l&&Ve(l,`focusout`,i),l&&Ve(l,`pointerdown`,t),S&&Ve(S,`focusin`,n),S&&Ve(S,`focusout`,i),S&&P&&Ve(S,`focusout`,a,!0))},[r,x,S,Y,s,N,P,v,c,o,ie,O,E,k,T,K,ne,q,u,f,ae]),Z.useEffect(()=>{if(r||!S||!b)return;let e=Array.from(P?.portalNode?.querySelectorAll(`[${un(`portal`)}]`)||[]),t=(N?Dn(N.nodesRef.current,E()):[]).find(e=>qn(e.context?.elements.domReference||null))?.context?.elements.domReference,n=ca([...[S,...e,U.current,W.current,P?.beforeOutsideRef.current,P?.afterOutsideRef.current,...ae()],t,L(f),L(u),O?x:null].filter(e=>e!=null),{ariaHidden:s||O,mark:!1}),i=ca([S,...e].filter(e=>e!=null));return()=>{i(),n()}},[b,r,x,S,s,k,P,O,N,E,u,f,ae]),me(()=>{if(!b||r||!te(Y))return;let e=C(_e(Y));queueMicrotask(()=>{let t=A.current,n=typeof t==`function`?t(M.current||``):t;if(n===void 0||n===!1||y(Y,e))return;let r=null,i=()=>(r??=ie(Y),r[0]||Y),a;a=n===!0||n===null?i():L(n),a||=i(),Xi(a,{preventScroll:a===Y})})},[r,b,Y,D,ie,A,M]),me(()=>{if(r||!Y)return;let e=_e(Y);pa(C(e));function t(e){if(e.open||(V.current=la(e.nativeEvent,H.current)),e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`&&(F.current=!0),e.reason===`outside-press`)if(e.nested)F.current=!1;else if(Wn(e.nativeEvent)||nr(e.nativeEvent))F.current=!1;else{let e=!1;_e(Y).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?F.current=!1:F.current=!0}}w.on(`openchange`,t);function n(){let e=j.current,t=typeof e==`function`?e(V.current):e;if(t===void 0||t===!1)return null;if(t===null&&(t=!0),typeof t==`boolean`){let e=x||ma();return e&&e.isConnected?e:null}let n=x||ma();return L(t)||n||null}return()=>{w.off(`openchange`,t);let r=C(e),i=ae(),a=y(S,r)||i.some(e=>e===r||y(e,r))||N&&Ut(N.nodesRef.current,E(),!1).some(e=>y(e.context?.elements.floating,r)),o=j.current,s=n();queueMicrotask(()=>{let t=ha(s),n=typeof o!=`boolean`;o&&!F.current&&te(t)&&(!(!n&&t!==r&&r!==e.body)||a)&&t.focus({preventScroll:!0}),F.current=!1})}},[r,S,Y,j,T,w,N,x,E,ae]),me(()=>{if(!g||b||!S)return;let e=C(_e(S));!te(e)||!Ne(e)||y(S,e)&&e.blur()},[b,S]),me(()=>{if(!(r||!P))return P.setFocusManagerState({modal:s,closeOnFocusOut:c,open:b,onOpenChange:v.setOpen,domReference:x}),()=>{P.setFocusManagerState(null)}},[r,P,s,b,v,c,x]),me(()=>{if(!(r||!Y))return _a(Y,k),()=>{queueMicrotask(fa)}},[r,Y,k]);let oe=!r&&(s?!O:!0)&&(re||s);return(0,Q.jsxs)(Z.Fragment,{children:[oe&&(0,Q.jsx)(le,{"data-type":`inside`,ref:G,onFocus:e=>{if(s){let e=ie();Xi(e[e.length-1])}else P?.portalNode&&(F.current=!1,zn(e,P.portalNode)?mn(x)?.focus():L(f??P.beforeOutsideRef)?.focus())}}),n,oe&&(0,Q.jsx)(le,{"data-type":`inside`,ref:ee,onFocus:e=>{s?Xi(ie()[0]):P?.portalNode&&(c&&(F.current=!0),zn(e,P.portalNode)?jn(x)?.focus():L(u??P.afterOutsideRef)?.focus())}})]})}function ya(e,t={}){let n=`rootStore`in e?e.rootStore:e,r=n.context.dataRef,{enabled:i=!0,event:a=`click`,toggle:o=!0,ignoreMouse:s=!1,stickIfOpen:c=!0,touchOpenDelay:l=0,reason:u=nn}=t,d=Z.useRef(void 0),f=z(),p=Pe(),m=Z.useMemo(()=>({onPointerDown(e){d.current=e.pointerType},onMouseDown(e){let t=d.current,i=e.nativeEvent,m=n.select(`open`);if(e.button!==0||a===`click`||ct(t,!0)&&s)return;let h=r.current.openEvent,g=h?.type,_=n.select(`domReferenceElement`)!==e.currentTarget,v=m&&_||!(m&&o&&(!(h&&c)||g===`click`||g===`mousedown`)),y=pe(i);if(Ne(y)){let e=Ye(u,i,y);v&&t===`touch`&&l>0?p.start(l,()=>{n.setOpen(!0,e)}):n.setOpen(v,e);return}let b=e.currentTarget;f.request(()=>{let e=Ye(u,i,b);v&&t===`touch`&&l>0?p.start(l,()=>{n.setOpen(!0,e)}):n.setOpen(v,e)})},onClick(e){if(a===`mousedown-only`)return;let t=d.current;if(a===`mousedown`&&t){d.current=void 0;return}if(ct(t,!0)&&s)return;let i=n.select(`open`),f=r.current.openEvent,m=n.select(`domReferenceElement`)!==e.currentTarget,h=i&&m||!(i&&o&&(!(f&&c)||Ft(f))),g=Ye(u,e.nativeEvent,e.currentTarget);h&&t===`touch`&&l>0?p.start(l,()=>{n.setOpen(!0,g)}):n.setOpen(h,g)},onKeyDown(){d.current=void 0}}),[r,a,s,n,c,o,f,p,l,u]);return Z.useMemo(()=>i?{reference:m}:sn,[i,m])}function nee(e){let t=e.currentTarget.getBoundingClientRect();return t.top+1<=e.clientY&&e.clientY<=t.bottom-1&&t.left+1<=e.clientX&&e.clientX<=t.right-1}var ree=`Escape`;function ba(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function xa(e,t){return ba(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function Sa(e,t,n){return ba(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function Ca(e,t,n){return ba(t,n?e===s:e===qt,e===Zt)}function wa(e,t,n,r){return t===`both`||t===`horizontal`&&r&&r>1?e===ree:ba(t,n?e===qt:e===s,e===ae)}function Ta(e,t){let n=`rootStore`in e?e.rootStore:e,r=n.useState(`open`),i=n.useState(`floatingElement`),a=n.useState(`domReferenceElement`),o=n.context.dataRef,{listRef:s,activeIndex:c,onNavigate:l=()=>{},enabled:u=!0,selectedIndex:d=null,allowEscape:f=!1,loopFocus:p=!1,nested:m=!1,rtl:g=!1,virtual:_=!1,focusItemOnOpen:v=`auto`,focusItemOnHover:b=!0,openOnArrowKeyDown:x=!0,disabledIndices:S=void 0,orientation:w=`vertical`,parentOrientation:T,cols:E=1,id:D,resetOnPointerLeave:O=!0,externalTree:k}=t,A=Te(h(i)),j=ne(),M=wn(k);me(()=>{o.current.orientation=w},[o,w]);let N=qn(a),P=Z.useRef(v),F=Z.useRef(d??-1),I=Z.useRef(null),L=Z.useRef(!0),R=J(e=>{l(F.current===-1?null:F.current,e)}),z=Z.useRef(R),B=Z.useRef(!!i),V=Z.useRef(r),H=Z.useRef(!1),U=Z.useRef(!1),W=Z.useRef(null),G=Te(S),ee=Te(r),K=Te(d),q=Te(O),re=J(()=>{function e(e){_?M?.events.emit(`virtualfocus`,e):W.current=Xi(e,{sync:H.current,preventScroll:!0})}let t=s.current[F.current],n=U.current;t&&e(t),(H.current?e=>e():requestAnimationFrame)(()=>{let r=s.current[F.current]||t;r&&(t||e(r),ae&&(n||!L.current)&&r.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});me(()=>{u&&(r&&i?(F.current=d??-1,P.current&&d!=null&&(U.current=!0,R())):B.current&&(F.current=-1,z.current()))},[u,r,i,d,R]),me(()=>{if(u){if(!r){H.current=!1;return}if(i)if(c==null){if(H.current=!1,K.current!=null)return;if(B.current&&(F.current=-1,re()),(!V.current||!B.current)&&P.current&&(I.current!=null||P.current===!0&&I.current==null)){let e=0,t=()=>{s.current[0]==null?(e<2&&(e?requestAnimationFrame:queueMicrotask)(t),e+=1):(F.current=I.current==null||Sa(I.current,w,g)||m?tr(s):Un(s),I.current=null,R())};t()}}else Zn(s.current,c)||(F.current=c,re(),U.current=!1)}},[u,r,i,c,K,m,s,w,g,R,re,G]),me(()=>{if(!u||i||!M||_||!B.current)return;let e=M.nodesRef.current,t=e.find(e=>e.id===j)?.context?.elements.floating,n=C(_e(i)),r=e.some(e=>e.context&&y(e.context.elements.floating,n));t&&!r&&L.current&&t.focus({preventScroll:!0})},[u,i,M,j,_]),me(()=>{z.current=R,V.current=r,B.current=!!i}),me(()=>{r||(I.current=null,P.current=v)},[r,v]);let Y=c!=null,ie=J(e=>{if(!ee.current)return;let t=s.current.indexOf(e.currentTarget);t!==-1&&(F.current!==t||c!==t)&&(F.current=t,R(e))}),ae=Z.useMemo(()=>({onFocus(e){H.current=!0,ie(e)},onClick:({currentTarget:e})=>e.focus({preventScroll:!0}),onMouseMove(e){H.current=!0,U.current=!1,b&&ie(e)},onPointerLeave(e){if(!ee.current||!L.current||e.pointerType===`touch`)return;H.current=!0;let t=e.relatedTarget;if(!nee(e)&&!(!b||s.current.includes(t))&&q.current&&(W.current?.(),W.current=null,F.current=-1,R(e),!_)){let e=A.current,t=C(_e(e));e&&y(e,t)&&e.focus({preventScroll:!0})}}}),[ie,ee,A,b,s,R,q,_]),oe=Z.useCallback(()=>T??M?.nodesRef.current.find(e=>e.id===j)?.context?.dataRef?.current.orientation,[j,M,T]),se=J(e=>{if(L.current=!1,H.current=!0,e.which===229||!ee.current&&e.currentTarget===A.current)return;if(m&&wa(e.key,w,g,E)){xa(e.key,oe())||ht(e),n.setOpen(!1,Ye(On,e.nativeEvent)),te(a)&&(_?M?.events.emit(`virtualfocus`,a):a.focus());return}let t=F.current,i=tr(s,S),o=Un(s,S);if(N||(e.key===`Home`&&(ht(e),F.current=i,R(e)),e.key===`End`&&(ht(e),F.current=o,R(e))),E>1){let t=Array.from({length:s.current.length},()=>({width:1,height:1})),n=vn(t,E,!1),r=n.findIndex(e=>e!=null&&!ke(s.current,e,S)),a=n.reduce((e,t,n)=>t!=null&&!ke(s.current,t,S)?n:e,-1),c=n[st(n.map(e=>e==null?null:s.current[e]),{event:e,orientation:w,loopFocus:p,rtl:g,cols:E,disabledIndices:Pt([...(typeof S==`function`?null:S)||s.current.map((e,t)=>ke(s.current,t,S)?t:void 0),void 0],n),minIndex:r,maxIndex:a,prevIndex:Rt(F.current>o?i:F.current,t,n,E,e.key===`ArrowDown`?`bl`:e.key===(g?`ArrowLeft`:`ArrowRight`)?`tr`:`tl`),stopEvent:!0})];if(c!=null&&(F.current=c,R(e)),w===`both`)return}if(xa(e.key,w)){if(ht(e),r&&!_&&C(e.currentTarget.ownerDocument)===e.currentTarget){F.current=Sa(e.key,w,g)?i:o,R(e);return}Sa(e.key,w,g)?p?t>=o?f&&t!==s.current.length?F.current=-1:(H.current=!1,F.current=i):F.current=on(s.current,{startingIndex:t,disabledIndices:S}):F.current=Math.min(o,on(s.current,{startingIndex:t,disabledIndices:S})):p?t<=i?f&&t!==-1?F.current=s.current.length:(H.current=!1,F.current=o):F.current=on(s.current,{startingIndex:t,decrement:!0,disabledIndices:S}):F.current=Math.max(i,on(s.current,{startingIndex:t,decrement:!0,disabledIndices:S})),Zn(s.current,F.current)&&(F.current=-1),R(e)}}),ce=Z.useMemo(()=>_&&r&&Y&&{"aria-activedescendant":`${D}-${c}`},[_,r,Y,D,c]),le=Z.useMemo(()=>({"aria-orientation":w===`both`?void 0:w,...N?{}:ce,onKeyDown(e){if(e.key===`Tab`&&e.shiftKey&&r&&!_){let t=pe(e.nativeEvent);if(t&&!y(A.current,t))return;ht(e),n.setOpen(!1,Ye(Dt,e.nativeEvent)),te(a)&&a.focus();return}se(e)},onPointerMove(){L.current=!0}}),[ce,se,A,w,N,n,r,_,a]),ue=Z.useMemo(()=>{function e(e){v===`auto`&&Wn(e.nativeEvent)&&(P.current=!_)}function t(e){P.current=v,v===`auto`&&nr(e.nativeEvent)&&(P.current=!0)}return{onKeyDown(e){let t=n.select(`open`);L.current=!1;let r=e.key.startsWith(`Arrow`),i=Ca(e.key,oe(),g),a=xa(e.key,w),o=(m?i:a)||e.key===`Enter`||e.key.trim()===``;if(_&&t)return se(e);if(!(!t&&!x&&r)){if(o){let t=xa(e.key,oe());I.current=m&&t?null:e.key}if(m){i&&(ht(e),t?(F.current=tr(s,G.current),R(e)):n.setOpen(!0,Ye(On,e.nativeEvent,e.currentTarget)));return}a&&(K.current!=null&&(F.current=K.current),ht(e),!t&&x?n.setOpen(!0,Ye(On,e.nativeEvent,e.currentTarget)):se(e),t&&R(e))}},onFocus(e){n.select(`open`)&&!_&&(F.current=-1,R(e))},onPointerDown:t,onPointerEnter:t,onMouseDown:e,onClick:e}},[se,G,v,s,m,R,n,x,w,oe,g,K,_]),de=Z.useMemo(()=>({...ce,...ue}),[ce,ue]);return Z.useMemo(()=>u?{reference:de,floating:le,item:ae,trigger:ue}:{},[u,de,le,ue,ae])}var Ea=new Map([[`select`,`listbox`],[`combobox`,`listbox`],[`label`,!1]]);function Da(e,t={}){let n=`rootStore`in e?e.rootStore:e,r=n.useState(`open`),i=n.useState(`floatingId`),a=n.useState(`domReferenceElement`),o=n.useState(`floatingElement`),{role:s=`dialog`}=t,c=Fn(),l=a?.id||c,u=Z.useMemo(()=>h(o)?.id||i,[o,i]),d=Ea.get(s)??s,f=ne()!=null,p=Z.useMemo(()=>d===`tooltip`||s===`label`?sn:{"aria-haspopup":d===`alertdialog`?`dialog`:d,"aria-expanded":`false`,...d===`listbox`&&{role:`combobox`},...d===`menu`&&f&&{role:`menuitem`},...s===`select`&&{"aria-autocomplete":`none`},...s===`combobox`&&{"aria-autocomplete":`list`}},[d,f,s]),m=Z.useMemo(()=>d===`tooltip`||s===`label`?{[`aria-${s===`label`?`labelledby`:`describedby`}`]:r?u:void 0}:{...p,"aria-expanded":r?`true`:`false`,"aria-controls":r?u:void 0,...d===`menu`&&{id:l}},[d,u,r,l,s,p]),g=Z.useMemo(()=>{let e={id:u,...d&&{role:d}};return d===`tooltip`||s===`label`?e:{...e,...d===`menu`&&{"aria-labelledby":l}}},[d,u,l,s]),_=Z.useCallback(({active:e,selected:t})=>{let n={role:`option`,...e&&{id:`${u}-fui-option`}};switch(s){case`select`:case`combobox`:return{...n,"aria-selected":t};default:}return{}},[u,s]);return Z.useMemo(()=>({reference:m,floating:g,item:_,trigger:p}),[m,g,p,_])}function Oa(e,t){let n=`rootStore`in e?e.rootStore:e,r=n.context.dataRef,i=n.useState(`open`),{listRef:a,elementsRef:o,activeIndex:s,onMatch:c,onTypingChange:l,enabled:u=!0,resetMs:d=750,selectedIndex:f=null}=t,p=Pe(),m=Z.useRef(``),h=Z.useRef(f??s??-1),g=Z.useRef(null);me(()=>{!i&&f!==null||(p.clear(),g.current=null,m.current!==``&&(m.current=``))},[i,f,p]),me(()=>{i&&m.current===``&&(h.current=f??s??-1)},[i,f,s]);let _=J(e=>{e?r.current.typing||(r.current.typing=e,l?.(e)):r.current.typing&&(r.current.typing=e,l?.(e))}),v=J(e=>{function t(e){let t=o?.current[e];return!t||mt(t)}function n(e,n,r=0){if(e.length===0)return-1;let i=(r%e.length+e.length)%e.length,a=n.toLocaleLowerCase();for(let n=0;n<e.length;n+=1){let r=(i+n)%e.length;if(!(!e[r]?.toLocaleLowerCase().startsWith(a)||!t(r)))return r}return-1}let r=a.current;if(m.current.length>0&&e.key===` `&&(ht(e),_(!0)),m.current.length>0&&m.current[0]!==` `&&n(r,m.current)===-1&&e.key!==` `&&_(!1),r==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;i&&e.key!==` `&&(ht(e),_(!0));let l=m.current===``;l&&(h.current=f??s??-1),r.every(e=>e?e[0]?.toLocaleLowerCase()!==e[1]?.toLocaleLowerCase():!0)&&m.current===e.key&&(m.current=``,h.current=g.current),m.current+=e.key,p.start(d,()=>{m.current=``,h.current=g.current,_(!1)});let u=((l?f??s??-1:h.current)??0)+1,v=n(r,m.current,u);v===-1?e.key!==` `&&(m.current=``,_(!1)):(c?.(v),g.current=v)}),b=J(e=>{let t=e.relatedTarget,r=n.select(`domReferenceElement`),i=n.select(`floatingElement`),a=y(r,t),o=y(i,t);a||o||(p.clear(),m.current=``,h.current=g.current,_(!1))}),x=Z.useMemo(()=>({onKeyDown:v,onBlur:b}),[v,b]),S=Z.useMemo(()=>({onKeyDown:v,onBlur:b}),[v,b]);return Z.useMemo(()=>u?{reference:x,floating:S}:{},[u,x,S])}function ka(e){return Et(19)?e:e?`true`:void 0}var Aa=bt(`arrow-up-to-line`,[[`path`,{d:`M5 3h14`,key:`7usisc`}],[`path`,{d:`m18 13-6-6-6 6`,key:`1kf1n9`}],[`path`,{d:`M12 7v14`,key:`1akyts`}]]),ja=bt(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Ma=bt(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Na=bt(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Pa=bt(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),Fa=bt(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Ia=bt(`copy`,[[`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`}]]),La=bt(`download`,[[`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`}]]),Ra=bt(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),za=bt(`ellipsis`,[[`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`}]]),Ba=bt(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`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`}]]),Va=bt(`folder`,[[`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`}]]),Ha=bt(`git-commit-horizontal`,[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]]),Ua=bt(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),Wa=bt(`image-plus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),Ga=bt(`list-end`,[[`path`,{d:`M16 5H3`,key:`m91uny`}],[`path`,{d:`M16 12H3`,key:`1a2rj7`}],[`path`,{d:`M9 19H3`,key:`s61nz1`}],[`path`,{d:`m16 16-3 3 3 3`,key:`117b85`}],[`path`,{d:`M21 5v12a2 2 0 0 1-2 2h-6`,key:`hey24a`}]]),Ka=bt(`list-start`,[[`path`,{d:`M3 5h6`,key:`1ltk0q`}],[`path`,{d:`M3 12h13`,key:`ppymz1`}],[`path`,{d:`M3 19h13`,key:`bpdczq`}],[`path`,{d:`m16 8-3-3 3-3`,key:`1pjpp6`}],[`path`,{d:`M21 19V7a2 2 0 0 0-2-2h-6`,key:`4zzq67`}]]),qa=bt(`panel-left-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]]),Ja=bt(`panel-left-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),Ya=bt(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),Xa=bt(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),Za=bt(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Qa=bt(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),$a=bt(`square-arrow-out-up-right`,[[`path`,{d:`M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6`,key:`y09zxi`}],[`path`,{d:`m21 3-9 9`,key:`mpx6sq`}],[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}]]),eo=bt(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),iee=bt(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),to=bt(`upload`,[[`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`}]]),aee=bt(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),no=bt(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function oee(e){return typeof e==`function`}function ro(e,...t){return oee(e)?e(...t):e}var see=class{#e=!0;#t;#n;#r;#i;#a;#o;#s;#c=0;#l=5;#u=!1;#d=!1;#f=null;#p=()=>{this.debugLog(`Connected to event bus`),this.#a=!0,this.#u=!1,this.debugLog(`Emitting queued events`,this.#i),this.#i.forEach(e=>this.emitEventToBus(e)),this.#i=[],this.stopConnectLoop(),this.#n().removeEventListener(`tanstack-connect-success`,this.#p)};#m=()=>{if(this.#c<this.#l){this.#c++,this.dispatchCustomEvent(`tanstack-connect`,{});return}this.#n().removeEventListener(`tanstack-connect`,this.#m),this.#d=!0,this.debugLog(`Max retries reached, giving up on connection`),this.stopConnectLoop()};#h=()=>{this.#u||(this.#u=!0,this.#n().addEventListener(`tanstack-connect-success`,this.#p),this.#m())};constructor({pluginId:e,debug:t=!1,enabled:n=!0,reconnectEveryMs:r=300}){this.#t=e,this.#e=n,this.#n=this.getGlobalTarget,this.#r=t,this.debugLog(` Initializing event subscription for plugin`,this.#t),this.#i=[],this.#a=!1,this.#d=!1,this.#o=null,this.#s=r}startConnectLoop(){this.#o!==null||this.#a||(this.debugLog(`Starting connect loop (every ${this.#s}ms)`),this.#o=setInterval(this.#m,this.#s))}stopConnectLoop(){this.#u=!1,this.#o!==null&&(clearInterval(this.#o),this.#o=null,this.#i=[],this.debugLog(`Stopped connect loop`))}debugLog(...e){this.#r&&console.log(`🌴 [tanstack-devtools:${this.#t}-plugin]`,...e)}getGlobalTarget(){if(typeof globalThis<`u`&&globalThis.__TANSTACK_EVENT_TARGET__)return this.debugLog(`Using global event target`),globalThis.__TANSTACK_EVENT_TARGET__;if(typeof window<`u`&&window.addEventListener!==void 0)return this.debugLog(`Using window as event target`),window;let e=typeof EventTarget<`u`?new EventTarget:void 0;return e===void 0||e.addEventListener===void 0?(this.debugLog(`No event mechanism available, running in non-web environment`),{addEventListener:()=>{},removeEventListener:()=>{},dispatchEvent:()=>!1}):(this.debugLog(`Using new EventTarget as fallback`),e)}getPluginId(){return this.#t}dispatchCustomEventShim(e,t){try{let n=new Event(e,{detail:t});this.#n().dispatchEvent(n)}catch{this.debugLog(`Failed to dispatch shim event`)}}dispatchCustomEvent(e,t){try{this.#n().dispatchEvent(new CustomEvent(e,{detail:t}))}catch{this.dispatchCustomEventShim(e,t)}}emitEventToBus(e){this.debugLog(`Emitting event to client bus`,e),this.dispatchCustomEvent(`tanstack-dispatch-event`,e)}createEventPayload(e,t){return{type:`${this.#t}:${e}`,payload:t,pluginId:this.#t}}emit(e,t){if(!this.#e){this.debugLog(`Event bus client is disabled, not emitting event`,e,t);return}if(this.#f&&(this.debugLog(`Emitting event to internal event target`,e,t),this.#f.dispatchEvent(new CustomEvent(`${this.#t}:${e}`,{detail:this.createEventPayload(e,t)}))),this.#d){this.debugLog(`Previously failed to connect, not emitting to bus`);return}if(!this.#a){this.debugLog(`Bus not available, will be pushed as soon as connected`),this.#i.push(this.createEventPayload(e,t)),typeof CustomEvent<`u`&&!this.#u&&(this.#h(),this.startConnectLoop());return}return this.emitEventToBus(this.createEventPayload(e,t))}on(e,t,n){let r=n?.withEventTarget??!1,i=`${this.#t}:${e}`;if(r&&(this.#f||=new EventTarget,this.#f.addEventListener(i,e=>{t(e.detail)})),!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`,i),()=>{};let a=e=>{this.debugLog(`Received event from bus`,e.detail),t(e.detail)};return this.#n().addEventListener(i,a),this.debugLog(`Registered event to bus`,i),()=>{r&&this.#f?.removeEventListener(i,a),this.#n().removeEventListener(i,a)}}onAll(e){if(!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`),()=>{};let t=t=>{let n=t.detail;e(n)};return this.#n().addEventListener(`tanstack-devtools-global`,t),()=>this.#n().removeEventListener(`tanstack-devtools-global`,t)}onAllPluginEvents(e){if(!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`),()=>{};let t=t=>{let n=t.detail;this.#t&&n.pluginId!==this.#t||e(n)};return this.#n().addEventListener(`tanstack-devtools-global`,t),()=>this.#n().removeEventListener(`tanstack-devtools-global`,t)}},io=new Map;function ao(e,t){io.set(e,t)}function oo(e){if(e!==void 0)try{return JSON.parse(JSON.stringify(e))}catch{return null}}function so(e){return typeof e.get==`function`?e.get():e.state}function co(e){return{key:e.key,store:{state:oo(so(e.store))},options:oo(e.options)}}var lo=class extends see{constructor(e){super({pluginId:`pacer`,debug:e?.debug,reconnectEveryMs:1e3})}},uo=(e,t)=>{let n=t.key;n&&(ao(n,t),fo.emit(e,co({...t,key:n})))},fo=new lo;function po(){return{currentAttempt:0,executionCount:0,isExecuting:!1,lastError:void 0,lastExecutionTime:0,lastResult:void 0,status:`idle`,totalExecutionTime:0}}var mo={backoff:`exponential`,baseWait:1e3,maxWait:1/0,enabled:!0,jitter:0,maxAttempts:3,maxExecutionTime:1/0,maxTotalExecutionTime:1/0,throwOnError:`last`},ho=class{#e;constructor(e,t={}){this.fn=e,this.store=new Li(po()),this.#e=null,this.setOptions=e=>{this.options={...this.options,...e}},this.#t=e=>{this.store.setState(t=>{let n={...t,...e},{isExecuting:r,currentAttempt:i}=n;return{...n,status:this.#n()?r&&i===1?`executing`:r&&i>1?`retrying`:`idle`:`disabled`}}),uo(`AsyncRetryer`,this)},this.#n=()=>!!ro(this.options.enabled,this),this.#r=()=>ro(this.options.maxAttempts,this),this.#i=()=>ro(this.options.baseWait,this),this.#a=()=>ro(this.options.maxWait,this),this.#o=e=>{let t=this.options.jitter;if(t<=0)return 0;try{let n=typeof globalThis<`u`?globalThis.crypto:void 0;if(n?.getRandomValues){let r=new Uint32Array(1);n.getRandomValues(r);let i=r[0]/4294967295*2-1;return Math.floor(e*t*i)}}catch{}return 0},this.#s=e=>{let t=this.#i(),n;switch(this.options.backoff){case`linear`:n=t*e;break;case`exponential`:n=t*2**(e-1);break;default:n=t;break}n=Math.min(n,this.#a());let r=this.#o(n);return Math.max(0,n+r)},this.execute=async(...e)=>{if(!this.#n())return;this.abort(`new-execution`);let t=Date.now(),n,r;this.#e=new AbortController;let i=this.#e.signal;this.#t({isExecuting:!0,currentAttempt:0,lastError:void 0});let a;this.options.maxTotalExecutionTime!==1/0&&(a=setTimeout(()=>{this.options.onTotalExecutionTimeout?.(this),this.abort(`total-timeout`)},this.options.maxTotalExecutionTime));let o=!1;for(let a=1;a<=this.#r();a++){o=a===this.#r(),this.#t({currentAttempt:a});try{if(i.aborted)return;let n=Date.now()-t;if(this.options.maxTotalExecutionTime!==1/0&&n>=this.options.maxTotalExecutionTime){this.options.onTotalExecutionTimeout?.(this),this.abort(`total-timeout`);return}if(r=this.options.maxExecutionTime===1/0?await this.fn(...e):await Promise.race([this.fn(...e),new Promise((e,t)=>{let n=setTimeout(()=>{this.options.onExecutionTimeout?.(this),this.abort(`execution-timeout`),t(Error(`Execution timeout: ${this.options.maxExecutionTime}ms exceeded`))},this.options.maxExecutionTime);i.addEventListener(`abort`,()=>{clearTimeout(n),t(Error(`Aborted`))},{once:!0})})]),i.aborted)return;let a=Date.now()-t;return this.#t({executionCount:this.store.state.executionCount+1,isExecuting:!1,lastExecutionTime:Date.now(),totalExecutionTime:a,currentAttempt:0,lastResult:r}),this.options.onSuccess?.(r,e,this),r}catch(t){if(t&&typeof t==`object`&&`name`in t&&t.name===`AbortError`)return;if(n=t instanceof Error?t:Error(String(t)),this.#t({lastError:n}),this.options.onError?.(n,e,this),a<this.#r()){this.options.onRetry?.(a,n,this);let e=this.#s(a);if(e>0&&(this.#t({isExecuting:!0,currentAttempt:a+1}),await new Promise(t=>{let n=setTimeout(()=>{i.removeEventListener(`abort`,r),t()},e),r=()=>{clearTimeout(n),i.removeEventListener(`abort`,r),t()};i.addEventListener(`abort`,r)}),i.aborted))return}}finally{this.options.onSettled?.(e,this)}}if(a&&clearTimeout(a),this.#t({isExecuting:!1}),this.options.onLastError?.(n,this),this.options.onSettled?.(e,this),this.options.throwOnError===`last`&&o||this.options.throwOnError===!0)throw n},this.getAbortSignal=()=>this.#e?.signal??null,this.abort=(e=`manual`)=>{this.#e&&(this.#e.abort(),this.#e=null,this.#t({isExecuting:!1}),this.options.onAbort?.(e,this))},this.reset=()=>{this.#t(po())},this.key=t.key,this.options={...mo,...t,throwOnError:t.throwOnError??(t.onError?!1:mo.throwOnError)},this.#t(this.options.initialState??{}),this.key&&fo.on(`d-AsyncRetryer`,e=>{e.payload.key===this.key&&(this.#t(e.payload.store.state),this.setOptions(e.payload.options))})}#t;#n;#r;#i;#a;#o;#s};function go(){return{canLeadingExecute:!0,errorCount:0,isExecuting:!1,isPending:!1,lastArgs:void 0,lastResult:void 0,maybeExecuteCount:0,settleCount:0,status:`idle`,successCount:0}}var _o={asyncRetryerOptions:{maxAttempts:1},enabled:!0,leading:!1,trailing:!0,wait:0},vo=class{#e;#t;constructor(e,t){this.fn=e,this.store=new Li(go()),this.asyncRetryers=new Map,this.#e=null,this.#t=null,this.setOptions=e=>{this.options={...this.options,...e},this.#r()||this.cancel()},this.#n=e=>{this.store.setState(t=>{let n={...t,...e},{isPending:r,isExecuting:i,settleCount:a}=n;return{...n,status:this.#r()?r?`pending`:i?`executing`:a>0?`settled`:`idle`:`disabled`}}),uo(`AsyncDebouncer`,this)},this.#r=()=>!!ro(this.options.enabled,this),this.#i=()=>ro(this.options.wait,this),this.maybeExecute=async(...e)=>{if(this.#r())return this.#c(),this.#n({lastArgs:e,maybeExecuteCount:this.store.state.maybeExecuteCount+1}),this.options.leading&&this.store.state.canLeadingExecute?(this.#n({canLeadingExecute:!1}),await this.#a(...e),this.store.state.lastResult):(this.options.trailing&&this.#r()&&this.#n({isPending:!0}),new Promise((e,t)=>{this.#t=e,this.#e=setTimeout(async()=>{if(this.options.trailing&&this.store.state.lastArgs)try{await this.#a(...this.store.state.lastArgs)}catch(e){t(e)}this.#n({canLeadingExecute:!0}),this.#t=null,e(this.store.state.lastResult)},this.#i())}))},this.#a=async(...e)=>{if(!this.#r())return;let t=this.store.state.maybeExecuteCount+1;try{this.#n({isExecuting:!0});let n=new ho(this.fn,{...this.options.asyncRetryerOptions,key:`${this.key}-retryer-${t}`});this.asyncRetryers.set(t,n);let r=await n.execute(...e);this.#n({lastResult:r,successCount:this.store.state.successCount+1}),this.options.onSuccess?.(r,e,this)}catch(t){if(this.#n({errorCount:this.store.state.errorCount+1}),this.options.onError?.(t,e,this),this.options.throwOnError)throw t}finally{this.asyncRetryers.delete(t),this.#n({isExecuting:!1,isPending:!1,lastArgs:void 0,settleCount:this.store.state.settleCount+1}),this.options.onSettled?.(e,this)}return this.store.state.lastResult},this.flush=async()=>{if(this.store.state.isPending&&this.store.state.lastArgs){let{lastArgs:e}=this.store.state;return this.#c(),await this.#a(...e)}},this.#o=()=>{this.#t&&=(this.#t(this.store.state.lastResult),null)},this.#s=()=>{this.#e&&=(clearTimeout(this.#e),null)},this.#c=()=>{this.#s(),this.#o(),this.#n({isPending:!1,lastArgs:void 0})},this.getAbortSignal=e=>{let t=e??this.store.state.maybeExecuteCount;return this.asyncRetryers.get(t)?.getAbortSignal()??null},this.abort=()=>{this.asyncRetryers.forEach(e=>e.abort()),this.asyncRetryers.clear(),this.#n({isExecuting:!1})},this.cancel=()=>{this.#c(),this.#n({canLeadingExecute:!0})},this.reset=()=>{this.#n(go()),this.asyncRetryers.forEach(e=>e.reset())},this.key=t.key,this.options={..._o,...t,throwOnError:t.throwOnError??!t.onError},this.#n(this.options.initialState??{}),this.key&&fo.on(`d-AsyncDebouncer`,e=>{e.payload.key===this.key&&(this.#n(e.payload.store.state),this.setOptions(e.payload.options))})}#n;#r;#i;#a;#o;#s;#c};function yo(){return{executionCount:0,isEmpty:!0,isPending:!1,totalItemsProcessed:0,items:[],size:0,status:`idle`}}var bo={getShouldExecute:()=>!1,maxSize:1/0,started:!0,wait:1/0},xo=class{#e;constructor(e,t){this.fn=e,this.store=new Li(yo()),this.#e=null,this.setOptions=e=>{this.options={...this.options,...e}},this.#t=e=>{this.store.setState(t=>{let n={...t,...e},{isPending:r,items:i}=n,a=i.length,o=a===0;return{...n,isEmpty:o,size:a,status:r?`pending`:`idle`}}),uo(`Batcher`,this)},this.#n=()=>ro(this.options.wait,this),this.addItem=e=>{this.#t({items:[...this.store.state.items,e],isPending:this.options.wait!==1/0}),this.options.onItemsChange?.(this),this.store.state.items.length>=this.options.maxSize||this.options.getShouldExecute(this.store.state.items,this)?this.#r():this.options.wait!==1/0&&(this.#i(),this.#e=setTimeout(()=>this.#r(),this.#n()))},this.#r=()=>{if(this.store.state.items.length===0)return;let e=this.peekAllItems();this.clear(),this.options.onItemsChange?.(this),this.fn(e),this.#t({executionCount:this.store.state.executionCount+1,totalItemsProcessed:this.store.state.totalItemsProcessed+e.length}),this.options.onExecute?.(e,this)},this.flush=()=>{this.#i(),this.#r()},this.peekAllItems=()=>[...this.store.state.items],this.#i=()=>{this.#e&&=(clearTimeout(this.#e),null)},this.clear=()=>{this.#t({items:[],isPending:!1})},this.cancel=()=>{this.#i(),this.#t({isPending:!1})},this.reset=()=>{this.#t(yo()),this.options.onItemsChange?.(this)},this.key=t.key,this.options={...bo,...t},this.#t(this.options.initialState??{}),this.key&&fo.on(`d-Batcher`,e=>{e.payload.key===this.key&&(this.#t(e.payload.store.state),this.setOptions(e.payload.options))})}#t;#n;#r;#i};function So(){return{executionCount:0,isPending:!1,lastArgs:void 0,lastExecutionTime:0,nextExecutionTime:0,status:`idle`,maybeExecuteCount:0}}var Co={enabled:!0,leading:!0,trailing:!0,wait:0},wo=class{#e;constructor(e,t){this.fn=e,this.store=new Li(So()),this.setOptions=e=>{this.options={...this.options,...e},this.#n()||this.cancel()},this.#t=e=>{this.store.setState(t=>{let n={...t,...e},{isPending:r}=n;return{...n,status:this.#n()?r?`pending`:`idle`:`disabled`}}),uo(`Throttler`,this)},this.#n=()=>!!ro(this.options.enabled,this),this.#r=()=>ro(this.options.wait,this),this.maybeExecute=(...e)=>{this.#t({maybeExecuteCount:this.store.state.maybeExecuteCount+1});let t=Date.now(),n=t-this.store.state.lastExecutionTime,r=this.#r();if(this.options.leading&&n>=r)this.#i(...e);else if(this.#t({lastArgs:e}),!this.#e&&this.options.trailing){let e=r-(this.store.state.lastExecutionTime?t-this.store.state.lastExecutionTime:0);this.#t({isPending:!0}),this.#e=setTimeout(()=>{let{lastArgs:e}=this.store.state;e!==void 0&&this.#i(...e)},e)}},this.#i=(...e)=>{if(!this.#n())return;this.fn(...e);let t=Date.now(),n=t+this.#r();this.#a(),this.#t({executionCount:this.store.state.executionCount+1,lastExecutionTime:t,nextExecutionTime:n,isPending:!1,lastArgs:void 0}),this.options.onExecute?.(e,this),setTimeout(()=>{this.store.state.isPending||this.#t({nextExecutionTime:void 0})},this.#r())},this.flush=()=>{this.store.state.isPending&&this.store.state.lastArgs&&this.#i(...this.store.state.lastArgs)},this.#a=()=>{this.#e&&=(clearTimeout(this.#e),void 0)},this.cancel=()=>{this.#a(),this.#t({lastArgs:void 0,isPending:!1})},this.reset=()=>{this.#t(So())},this.key=t.key,this.options={...Co,...t},this.#t(this.options.initialState??{}),this.key&&fo.on(`d-Throttler`,e=>{e.payload.key===this.key&&(this.#t(e.payload.store.state),this.setOptions(e.payload.options))})}#t;#n;#r;#i;#a};function To(e){return at(e.defaultTagName??`div`,e,e)}var $=O(),Eo=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,Do=Vn,Oo=(e,t)=>n=>{if(t?.variants==null)return Do(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=Eo(t)||Eo(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return Do(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},ko=768;function Ao(){let e=(0,$.c)(2),[t,n]=Z.useState(void 0),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(max-width: ${ko-1}px)`),t=()=>{n(window.innerWidth<ko)};return e.addEventListener(`change`,t),n(window.innerWidth<ko),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Z.useEffect(r,i),!!t}var jo=4,Mo=.5,No=.2,Po=20,Fo=10,Io=320,Lo=256,Ro=512;function zo(){if(typeof window>`u`)return`col-resize`;let e=window.navigator.userAgent;return e.includes(`Chrome`)||e.includes(`Firefox`)?`ew-resize`:`col-resize`}function Bo(){if(typeof window>`u`)return`row-resize`;let e=window.navigator.userAgent;return e.includes(`Chrome`)||e.includes(`Firefox`)?`ns-resize`:`row-resize`}function Vo(){return typeof window>`u`?Fo:window.matchMedia(`(pointer:coarse)`).matches?Po:Fo}function Ho(e){let t=document.createElement(`style`);return t.dataset.resizeCursor=`true`,t.textContent=`*, *:hover { cursor: ${e} !important; }`,document.head.append(t),()=>t.remove()}function Uo(e,t){let n=e.trim(),r=Number.parseFloat(n);return Number.isFinite(r)?n.endsWith(`rem`)?r*(typeof window>`u`?16:Number.parseFloat(window.getComputedStyle(document.documentElement).fontSize)||16):r:t}function Wo(e,t,n){return Math.min(Math.max(e,t),n)}function Go(e){return e.closest(`[data-slot='sidebar']`)?.dataset.side===`right`?`right`:`left`}function Ko(e){return e.closest(`[data-slot='sidebar-wrapper']`)}function qo(e,t){e.latestWidth=t,e.previewElement&&e.previewAnimationFrame===null&&(e.previewAnimationFrame=window.requestAnimationFrame(()=>{e.previewAnimationFrame=null,!(!e.previewElement||!e.latestWidth)&&e.previewElement.style.setProperty(`--sidebar-width`,e.latestWidth)}))}function Jo(e){e.previewAnimationFrame!==null&&(window.cancelAnimationFrame(e.previewAnimationFrame),e.previewAnimationFrame=null)}function Yo(e,t){let n=t-e.startX;return e.side===`left`?e.startWidth+n:e.startWidth-n}function Xo(e,t){return e.side===`left`?t>e.startX:t<e.startX}function Zo(e){let t=Z.useRef(e);return t.current=e,t}function Qo(e){let t=(0,$.c)(20),{enabled:n,expandThreshold:r,isMobile:i,maxWidth:a,minWidth:o,state:s,width:c,onOpenChange:l,onResize:u,onResizeActiveChange:d}=e,f=n===void 0?!0:n,p=r===void 0?No:r,m;t[0]!==f||t[1]!==p||t[2]!==i||t[3]!==a||t[4]!==o||t[5]!==l||t[6]!==u||t[7]!==d||t[8]!==s||t[9]!==c?(m={enabled:f,expandThreshold:p,isMobile:i,maxWidth:a,minWidth:o,state:s,width:c,onOpenChange:l,onResize:u,onResizeActiveChange:d},t[0]=f,t[1]=p,t[2]=i,t[3]=a,t[4]=o,t[5]=l,t[6]=u,t[7]=d,t[8]=s,t[9]=c,t[10]=m):m=t[10];let h=Zo(m),g=Z.useRef(!1),_=Z.useRef(null),v,y;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(v=()=>()=>_.current?.(),y=[],t[11]=v,t[12]=y):(v=t[11],y=t[12]),Z.useEffect(v,y);let b;t[13]===h?b=t[14]:(b=e=>{if(g.current){e.preventDefault(),e.stopPropagation(),g.current=!1;return}let{onOpenChange:t,state:n}=h.current;t(n!==`expanded`)},t[13]=h,t[14]=b);let x=b,S;t[15]===h?S=t[16]:(S=e=>{let t=h.current;if(e.defaultPrevented||e.button!==0||t.isMobile||!t.enabled)return;let n=Uo(t.minWidth,Lo),r=Uo(t.maxWidth,Ro),i=Uo(t.width,Io),a={collapsed:t.state!==`expanded`,latestWidth:null,moved:!1,previewAnimationFrame:null,previewElement:Ko(e.currentTarget),previousCursor:document.body.style.cursor,previousUserSelect:document.body.style.userSelect,side:Go(e.currentTarget),startWidth:t.state===`expanded`?i:0,startX:e.clientX};_.current?.();let o=null,s=()=>{window.removeEventListener(`pointermove`,d),window.removeEventListener(`pointerup`,f),window.removeEventListener(`pointercancel`,f),o?.(),Jo(a),document.body.style.cursor=a.previousCursor,document.body.style.userSelect=a.previousUserSelect,a.moved&&h.current.onResizeActiveChange(!1),_.current=null},c=()=>{let e=zo();a.moved=!0,g.current=!0,h.current.onResizeActiveChange(!0),o=Ho(e),document.body.style.cursor=e,document.body.style.userSelect=`none`},l=e=>{let t=`${Math.round(n)}px`;qo(a,t),h.current.onResize(t),h.current.onOpenChange(!1),a.collapsed=!0,a.startWidth=0,a.startX=e},u=e=>{let t=`${Math.round(n)}px`;qo(a,t),h.current.onResize(t),h.current.onOpenChange(!0),a.collapsed=!1,a.startWidth=n,a.startX=e},d=e=>{let t=Math.abs(e.clientX-a.startX);if(!a.moved&&t<jo)return;a.moved||c(),e.preventDefault();let i=Yo(a,e.clientX);if(a.collapsed){let t=n*h.current.expandThreshold;Xo(a,e.clientX)&&i>=t&&u(e.clientX);return}if(i<=n*Mo){l(e.clientX);return}let o=Wo(i,n,r);qo(a,`${Math.round(o)}px`)},f=e=>{a.moved&&(e.preventDefault(),a.latestWidth&&h.current.onResize(a.latestWidth),window.setTimeout(()=>{g.current=!1},0)),s()};_.current=s,window.addEventListener(`pointermove`,d),window.addEventListener(`pointerup`,f),window.addEventListener(`pointercancel`,f)},t[15]=h,t[16]=S);let C=S,w;return t[17]!==x||t[18]!==C?(w={handleClick:x,handlePointerDown:C},t[17]=x,t[18]=C,t[19]=w):w=t[19],w}var $o=Z.createContext(void 0);function es(e=!1){let t=Z.useContext($o);if(t===void 0&&!e)throw Error(b(16));return t}function ts(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:Z.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function ns(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:o}=e,s=Z.useRef(null),c=es(!0),l=o??c!==void 0,{props:u}=ts({focusableWhenDisabled:n,disabled:t,composite:l,tabIndex:r,isNativeButton:i}),d=Z.useCallback(()=>{let e=s.current;rs(e)&&l&&t&&u.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,u.disabled,l]);return me(d,[d]),{getButtonProps:Z.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:o,onKeyDown:s,onPointerDown:c,...d}=e;return a({type:i?`button`:void 0,onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(Ce(e),s?.(e),e.baseUIHandlerPrevented))return;let r=e.target===e.currentTarget,a=e.currentTarget,o=rs(a),c=!i&&is(a),u=r&&(i?o:!c),d=e.key===`Enter`,f=e.key===` `,p=a.getAttribute(`role`),m=p?.startsWith(`menuitem`)||p===`option`||p===`gridcell`;if(r&&l&&f){if(e.defaultPrevented&&m)return;e.preventDefault(),c||i&&o?(a.click(),e.preventBaseUIHandler()):u&&(n?.(e),e.preventBaseUIHandler());return}u&&(!i&&(f||d)&&e.preventDefault(),!i&&d&&n?.(e))},onKeyUp(e){if(!t){if(Ce(e),o?.(e),e.target===e.currentTarget&&i&&l&&rs(e.currentTarget)&&e.key===` `){e.preventDefault();return}e.baseUIHandlerPrevented||e.target===e.currentTarget&&!i&&!l&&e.key===` `&&n?.(e)}},onPointerDown(e){if(t){e.preventDefault();return}c?.(e)}},i?void 0:{role:`button`},u,d)},[t,u,l,i]),buttonRef:J(e=>{s.current=e,d()})}}function rs(e){return te(e)&&e.tagName===`BUTTON`}function is(e){return!!(e?.tagName===`A`&&e?.href)}var as=Z.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,focusableWhenDisabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{getButtonProps:l,buttonRef:u}=ns({disabled:i,focusableWhenDisabled:a,native:o});return at(`button`,e,{state:{disabled:i},ref:[t,u],props:[c,l]})}),os=Oo(`group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,outline:`border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground`,ghost:`hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50`,destructive:`bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,xs:`h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,icon:`size-8`,"icon-xs":`size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg`,"icon-lg":`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function ss(e){let t=(0,$.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,variant:i,size:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`default`:i,s=a===void 0?`default`:a,c;t[5]!==n||t[6]!==s||t[7]!==o?(c=rn(os({variant:o,size:s,className:n})),t[5]=n,t[6]=s,t[7]=o,t[8]=c):c=t[8];let l;return t[9]!==r||t[10]!==c?(l=(0,Q.jsx)(as,{"data-slot":`button`,className:c,...r}),t[9]=r,t[10]=c,t[11]=l):l=t[11],l}var cs=function(e){return e.disabled=`data-disabled`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),ls={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},us={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},ds={disabled:!1,...us},fs={valid(e){return e===null?null:e?{[cs.valid]:``}:{[cs.invalid]:``}}},ps=Z.createContext({invalid:void 0,name:void 0,validityData:{state:ls,errors:[],error:``,value:``,initialValue:null},setValidityData:zt,disabled:void 0,touched:us.touched,setTouched:zt,dirty:us.dirty,setDirty:zt,filled:us.filled,setFilled:zt,focused:us.focused,setFocused:zt,validate:()=>null,validationMode:`onSubmit`,validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:ds,markedDirtyRef:{current:!1},registerFieldControl:zt,validation:{getValidationProps:(e=sn)=>e,getInputValidationProps:(e=sn)=>e,inputRef:{current:null},commit:async()=>{}}});function ms(e=!0){let t=Z.useContext(ps);if(t.setValidityData===zt&&!e)throw Error(b(28));return t}var hs=Z.createContext({controlId:void 0,registerControlId:zt,labelId:void 0,setLabelId:zt,messageIds:[],setMessageIds:zt,getDescriptionProps:e=>e});function gs(){return Z.useContext(hs)}function _s({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=Z.useRef(e!==void 0),[a,o]=Z.useState(t);return[i?e:a,Z.useCallback(e=>{i||o(e)},[])]}function vs(e,t){let{enabled:n=!0,getValue:r,id:i,value:a}=t,{registerFieldControl:o}=ms(),s=Z.useRef(null);s.current||=Symbol(),me(()=>{let t=s.current;if(!(!t||!n))return o(t,{controlRef:e,getValue:r,id:i,value:a}),()=>{o(t,void 0)}},[e,n,r,i,o,a])}function ys(e={}){let{id:t,implicit:n=!1,controlRef:r}=e,{controlId:i,registerControlId:a}=gs(),o=It(t),s=n?i:void 0,c=oe(()=>Symbol(`labelable-control`)),l=Z.useRef(!1),u=Z.useRef(t!=null),d=J(()=>{!l.current||a===zt||(l.current=!1,a(c.current,void 0))});return me(()=>{if(a===zt)return;let e;if(n){let n=r?.current;e=j(n)&&n.closest(`label`)!=null?t??null:s??o}else if(t!=null)u.current=!0,e=t;else if(u.current)e=o;else{d();return}if(e===void 0){d();return}l.current=!0,a(c.current,e)},[t,r,s,a,n,o,c,d]),Z.useEffect(()=>d,[d]),i??o}var bs=Z.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:g,setDirty:_,validityData:v,setFocused:y,setFilled:b,validationMode:x,validation:S}=ms(),w=h||s,T=m??a,E={...p,disabled:w},{labelId:D}=gs(),O=ys({id:i});me(()=>{let e=o!=null;S.inputRef.current?.value||e&&o!==``?b(!0):e&&o===``&&b(!1)},[S.inputRef,b,o]);let k=Z.useRef(null);me(()=>{u&&k.current===C(_e(k.current))&&y(!0)},[u,y]);let[A]=_s({controlled:o,default:l,name:`FieldControl`,state:`value`}),j=o!==void 0,M=j?A:void 0,N=J(()=>S.inputRef.current?.value);return vs(S.inputRef,{id:O,value:M,getValue:N}),at(`input`,e,{ref:[t,k],state:E,props:[{id:O,disabled:w,name:T,ref:S.inputRef,"aria-labelledby":D,autoFocus:u,...j?{value:M}:{defaultValue:l},onChange(e){let t=e.currentTarget.value;c?.(t,Ye(Wt,e.nativeEvent)),_(t!==v.initialValue),b(t!==``)},onFocus(){y(!0)},onBlur(e){g(!0),y(!1),x===`onBlur`&&S.commit(e.currentTarget.value)},onKeyDown(e){e.currentTarget.tagName===`INPUT`&&e.key===`Enter`&&(g(!0),S.commit(e.currentTarget.value))}},S.getInputValidationProps(),f],stateAttributesMapping:fs})}),cee=Z.forwardRef(function(e,t){return(0,Q.jsx)(bs,{ref:t,...e})});function xs(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,type:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=rn(`h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==a||t[8]!==i?(o=(0,Q.jsx)(cee,{type:i,"data-slot":`input`,className:a,...r}),t[6]=r,t[7]=a,t[8]=i,t[9]=o):o=t[9],o}var Ss=`after:transition-colors after:duration-150 hover:after:bg-primary focus-visible:after:bg-primary active:after:bg-primary`,lee=`after:transition-colors after:duration-150 hover:group-data-[collapsible=offcanvas]:after:bg-primary focus-visible:group-data-[collapsible=offcanvas]:after:bg-primary active:group-data-[collapsible=offcanvas]:after:bg-primary`,Cs=Z.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return at(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})});function uee(e){let t=(0,$.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,orientation:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`horizontal`:i,o;t[4]===n?o=t[5]:(o=rn(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,n),t[4]=n,t[5]=o);let s;return t[6]!==a||t[7]!==r||t[8]!==o?(s=(0,Q.jsx)(Cs,{"data-slot":`separator`,orientation:a,className:o,...r}),t[6]=a,t[7]=r,t[8]=o,t[9]=s):s=t[9],s}var ws=Z.createContext(void 0);function Ts(e){let t=Z.useContext(ws);if(e===!1&&t===void 0)throw Error(b(27));return t}var dee={...Gn,...Y},Es=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,{store:s}=Ts(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return at(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:dee,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),Ds=Z.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,nativeButton:a=!0,style:o,...s}=e,{store:c}=Ts(),l=c.useState(`open`);function u(e){l&&c.setOpen(!1,Ye(xe,e.nativeEvent))}let{getButtonProps:d,buttonRef:f}=ns({disabled:i,native:a});return at(`button`,e,{state:{disabled:i},ref:[t,f],props:[{onClick:u},s,d]})}),Os=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,{store:s}=Ts(),c=It(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),at(`p`,e,{ref:t,props:[{id:c},o]})}),ks=function(e){return e.nestedDialogs=`--nested-dialogs`,e}({}),As=function(e){return e[e.open=lt.open]=`open`,e[e.closed=lt.closed]=`closed`,e[e.startingStyle=lt.startingStyle]=`startingStyle`,e[e.endingStyle=lt.endingStyle]=`endingStyle`,e.nested=`data-nested`,e.nestedDialogOpen=`data-nested-dialog-open`,e}({}),js=Z.createContext(void 0);function Ms(){let e=Z.useContext(js);if(e===void 0)throw Error(b(26));return e}var Ns=`ArrowUp`,Ps=`ArrowDown`,Fs=`ArrowLeft`,Is=`ArrowRight`,Ls=`Home`,Rs=new Set([Fs,Is]),zs=new Set([Fs,Is,Ls,`End`]),Bs=new Set([Ns,Ps]),Vs=new Set([Ns,Ps,Ls,`End`]),Hs=new Set([...Rs,...Bs]),Us=new Set([...Hs,Ls,`End`]),Ws=new Set([Ns,Ps,Fs,Is,Ls,`End`]),Gs=new Set([`Shift`,`Control`,`Alt`,`Meta`]);function Ks(e){return te(e)&&e.tagName===`INPUT`}function qs(e){return!!(Ks(e)&&e.selectionStart!=null||te(e)&&e.tagName===`TEXTAREA`)}function Js(e,t,n,r){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop,o=e.clientWidth<e.scrollWidth,s=e.clientHeight<e.scrollHeight;if(o&&r!==`vertical`){let r=Ys(e,t,`left`),a=Xs(e),o=Xs(t);n===`ltr`&&(r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight?i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight:r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft&&(i=r-o.scrollMarginLeft-a.scrollPaddingLeft)),n===`rtl`&&(r-o.scrollMarginRight<e.scrollLeft+a.scrollPaddingLeft?i=r-o.scrollMarginLeft-a.scrollPaddingLeft:r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight&&(i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight))}if(s&&r!==`horizontal`){let n=Ys(e,t,`top`),r=Xs(e),i=Xs(t);n-i.scrollMarginTop<e.scrollTop+r.scrollPaddingTop?a=n-i.scrollMarginTop-r.scrollPaddingTop:n+t.offsetHeight+i.scrollMarginBottom>e.scrollTop+e.clientHeight-r.scrollPaddingBottom&&(a=n+t.offsetHeight+i.scrollMarginBottom-e.clientHeight+r.scrollPaddingBottom)}e.scrollTo({left:i,top:a,behavior:`auto`})}function Ys(e,t,n){let r=n===`left`?`offsetLeft`:`offsetTop`,i=0;for(;t.offsetParent&&(i+=t[r],t.offsetParent!==e);)t=t.offsetParent;return i}function Xs(e){let t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}var Zs={...Gn,...Y,nestedDialogOpen(e){return e?{[As.nestedDialogOpen]:``}:null}},Qs=Z.forwardRef(function(e,t){let{className:n,finalFocus:r,initialFocus:i,render:a,style:o,...s}=e,{store:c}=Ts(),l=c.useState(`descriptionElementId`),u=c.useState(`disablePointerDismissal`),d=c.useState(`floatingRootContext`),f=c.useState(`popupProps`),p=c.useState(`modal`),m=c.useState(`mounted`),h=c.useState(`nested`),g=c.useState(`nestedOpenDialogCount`),_=c.useState(`open`),v=c.useState(`openMethod`),y=c.useState(`titleElementId`),b=c.useState(`transitionStatus`),x=c.useState(`role`);Ms(),ye({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});function S(e){return e===`touch`?c.context.popupRef.current:!0}let C=i===void 0?S:i,w=at(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:g>0},props:[f,{"aria-labelledby":y??void 0,"aria-describedby":l??void 0,role:x,tabIndex:-1,hidden:!m,onKeyDown(e){Ws.has(e.key)&&e.stopPropagation()},style:{[ks.nestedDialogs]:g}},s],ref:[t,c.context.popupRef,c.useStateSetter(`popupElement`)],stateAttributesMapping:Zs});return(0,Q.jsx)(va,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:r,modal:p!==!1,restoreFocus:`popup`,children:w})}),$s=Z.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return(0,Q.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})}),ec=Z.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i}=Ts(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,Q.jsx)(js.Provider,{value:n,children:(0,Q.jsxs)(tt,{ref:t,...r,children:[a&&o===!0&&(0,Q.jsx)($s,{ref:i.context.internalBackdropRef,inert:ka(!s)}),e.children]})}):null}),tc={},nc={},rc=``;function ic(e){if(typeof document>`u`)return!1;let t=_e(e);return Ge(t).innerWidth-t.documentElement.clientWidth>0}function ac(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=_e(e),n=t.documentElement,r=t.body,i=U(n)?n:r,a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function oc(e){let t=_e(e),n=t.documentElement,r=t.body,i=U(n)?n:r,a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function sc(e){let t=_e(e),n=t.documentElement,r=t.body,i=Ge(n),a=0,o=0,s=!1,c=D.create();if(g&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,tc={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},rc=n.style.scrollBehavior,nc={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=U(n)?n:r;if(s=ac(e),s){n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`;return}Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflow:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`}function u(){Object.assign(n.style,tc),Object.assign(r.style,nc),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=rc)}function d(){u(),c.request(l)}l();let f=Ve(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var cc=new class{lockCount=0;restore=null;timeoutLock=Jn.create();timeoutUnlock=Jn.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=_e(e).documentElement,n=Ge(t).getComputedStyle(t).overflowY;if(n===`hidden`||n===`clip`){this.restore=zt;return}let r=Qn||!ic(e);this.restore=r?oc(e):sc(e)}};function lc(e=!0,t=null){me(()=>{if(e)return cc.acquire(t)},[e,t])}function uc(e){let t=Z.useRef(``),n=Z.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:Z.useCallback(n=>{if(n.detail===0){e(n,`keyboard`);return}`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``},[e]),onPointerDown:n}}function dc(e,t){let n=Z.useRef(e),r=J(t);me(()=>{n.current!==e&&r(n.current)},[e,r]),me(()=>{n.current=e},[e])}function fc(e){let[t,n]=Z.useState(null),r=J((t,r)=>{e||n(r||(Qn?`touch`:``))});dc(e,t=>{t&&!e&&n(null)});let{onClick:i,onPointerDown:a}=uc(r);return Z.useMemo(()=>({openMethod:t,triggerProps:{onClick:i,onPointerDown:a}}),[t,i,a])}function pc(e){let{store:t,parentContext:n,actionsRef:r,isDrawer:i}=e,a=t.useState(`open`),o=t.useState(`disablePointerDismissal`),s=t.useState(`modal`),c=t.useState(`popupElement`),{openMethod:u,triggerProps:d}=fc(a);l(t);let{forceUnmount:f}=Yt(a,t),p=J(e=>{let n=Ye(e);return n.preventUnmountOnClose=()=>{t.set(`preventUnmountingOnClose`,!0)},n}),m=Z.useCallback(()=>{t.setOpen(!1,p(In))},[t,p]);Z.useImperativeHandle(r,()=>({unmount:f,close:m}),[f,m]);let h=T({popupStore:t,onOpenChange:t.setOpen,treatPopupAsFloatingElement:!0}),[g,_]=Z.useState(0),[v,b]=Z.useState(0),x=g===0,S=Da(h),C=Ue(h,{outsidePressEvent(){return t.context.internalBackdropRef.current||t.context.backdropRef.current?`intentional`:{mouse:s===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(e){if(!t.context.outsidePressEnabledRef.current||`button`in e&&e.button!==0||`touches`in e&&e.touches.length!==1)return!1;let n=pe(e);if(x&&!o){let e=n;return s&&(t.context.internalBackdropRef.current||t.context.backdropRef.current)?t.context.internalBackdropRef.current===e||t.context.backdropRef.current===e||y(e,c)&&!e?.hasAttribute(`data-base-ui-portal`):!0}return!1},escapeKey:x});lc(a&&s===!0,c);let{getReferenceProps:w,getFloatingProps:E,getTriggerProps:D}=je([S,C]);t.useContextCallback(`onNestedDialogOpen`,(e,t)=>{_(e),b(t)}),t.useContextCallback(`onNestedDialogClose`,()=>{_(0),b(0)}),Z.useEffect(()=>(n?.onNestedDialogOpen&&a&&n.onNestedDialogOpen(g+1,v+ +!!i),n?.onNestedDialogClose&&!a&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&a&&n.onNestedDialogClose()}),[i,a,g,v,n]);let O=Z.useMemo(()=>w(d),[w,d]),k=Z.useMemo(()=>D(d),[D,d]),A=Z.useMemo(()=>E(),[E]);t.useSyncedValues({openMethod:u,activeTriggerProps:O,inactiveTriggerProps:k,popupProps:A,floatingRootContext:h,nestedOpenDialogCount:g,nestedOpenDrawerCount:v})}var mc={...he,modal:p(e=>e.modal),nested:p(e=>e.nested),nestedOpenDialogCount:p(e=>e.nestedOpenDialogCount),nestedOpenDrawerCount:p(e=>e.nestedOpenDrawerCount),disablePointerDismissal:p(e=>e.disablePointerDismissal),openMethod:p(e=>e.openMethod),descriptionElementId:p(e=>e.descriptionElementId),titleElementId:p(e=>e.titleElementId),viewportElement:p(e=>e.viewportElement),role:p(e=>e.role)},hc=class e extends or{constructor(e){super(gc(e),{popupRef:Z.createRef(),backdropRef:Z.createRef(),internalBackdropRef:Z.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:new $t,onOpenChange:void 0,onOpenChangeComplete:void 0},mc)}setOpen=(e,t)=>{if(t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let n={open:e},r=t.trigger?.id??null;(r||e)&&(n.activeTriggerId=r,n.activeTriggerElement=t.trigger??null),this.update(n)};static useStore(t,n){let r=oe(()=>new e(n)).current;return t??r}};function gc(e={}){return{...x(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e}}var _c=Z.createContext(!1);function vc(e){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,disablePointerDismissal:o=!1,modal:s=!0,actionsRef:c,handle:l,triggerId:u,defaultTriggerId:d=null}=e,f=Ts(!0),p=Z.useContext(_c),m=!!f,h=hc.useStore(l?.store,{open:r,openProp:n,activeTriggerId:d,triggerIdProp:u,modal:s,disablePointerDismissal:o,nested:m});Qt(()=>{n===void 0&&h.state.open===!1&&r===!0&&h.update({open:!0,activeTriggerId:d})}),h.useControlledProp(`openProp`,n),h.useControlledProp(`triggerIdProp`,u),h.useSyncedValues({disablePointerDismissal:o,nested:m,modal:s}),h.useContextCallback(`onOpenChange`,i),h.useContextCallback(`onOpenChangeComplete`,a);let g=h.useState(`payload`);pc({store:h,actionsRef:c,parentContext:f?.store.context,isDrawer:p,onOpenChange:i,triggerIdProp:u});let _=Z.useMemo(()=>({store:h}),[h]);return(0,Q.jsx)(_c.Provider,{value:!1,children:(0,Q.jsx)(ws.Provider,{value:_,children:typeof t==`function`?t({payload:g}):t})})}var yc=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,{store:s}=Ts(),c=It(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),at(`h2`,e,{ref:t,props:[{id:c},o]})});function bc(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Q.jsx)(vc,{"data-slot":`sheet`,...n}),t[2]=n,t[3]=r),r}function xc(e){let t=(0,$.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Q.jsx)(ec,{"data-slot":`sheet-portal`,...n}),t[2]=n,t[3]=r),r}function Sc(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=rn(`fixed inset-0 z-50 bg-black/10 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(Es,{"data-slot":`sheet-overlay`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Cc(e){let t=(0,$.c)(17),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,children:n,side:a,showCloseButton:o,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=a===void 0?`right`:a,c=o===void 0?!0:o,l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(Sc,{}),t[6]=l):l=t[6];let u;t[7]===r?u=t[8]:(u=rn(`fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm`,r),t[7]=r,t[8]=u);let d;t[9]===c?d=t[10]:(d=c&&(0,Q.jsxs)(Ds,{"data-slot":`sheet-close`,render:(0,Q.jsx)(ss,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`}),children:[(0,Q.jsx)(no,{}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Close`})]}),t[9]=c,t[10]=d);let f;return t[11]!==n||t[12]!==i||t[13]!==s||t[14]!==u||t[15]!==d?(f=(0,Q.jsxs)(xc,{children:[l,(0,Q.jsxs)(Qs,{"data-slot":`sheet-content`,"data-side":s,className:u,...i,children:[n,d]})]}),t[11]=n,t[12]=i,t[13]=s,t[14]=u,t[15]=d,t[16]=f):f=t[16],f}function wc(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=rn(`flex flex-col gap-0.5 p-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`div`,{"data-slot":`sheet-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Tc(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=rn(`font-heading text-base font-medium text-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(yc,{"data-slot":`sheet-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Ec(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=rn(`text-sm text-muted-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(Os,{"data-slot":`sheet-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var Dc=`sidebar_state`,Oc=3600*24*7,kc=`20rem`,Ac=`16rem`,jc=`32rem`,Mc=`pico-sidebar-width`,Nc=`sidebar_width`,Pc=`20rem`,Fc=`3rem`,Ic=`b`,Lc=Z.createContext(null);function Rc(e,t){let n=e.trim(),r=Number.parseFloat(n);return Number.isFinite(r)?n.endsWith(`rem`)?r*(typeof window>`u`?16:Number.parseFloat(window.getComputedStyle(document.documentElement).fontSize)||16):r:t}function zc(e){let t=Rc(kc,320),n=Rc(Ac,256),r=Rc(jc,512),i=Rc(e??``,t);return`${Math.round(Math.min(Math.max(i,n),r))}px`}function Bc(){if(typeof window>`u`)return zc(kc);try{return zc(window.localStorage.getItem(Mc)??window.localStorage.getItem(Nc))}catch{return zc(kc)}}function Vc(e){try{window.localStorage.setItem(Mc,e)}catch{}}function Hc(e){let t=Z.useRef(e);return t.current=e,t}function Uc(){let e=Z.useContext(Lc);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function Wc({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:a,...o}){let s=Ao(),[c,l]=Z.useState(!1),[u,d]=Z.useState(!1),[f,p]=Z.useState(()=>zc(kc)),[m,h]=Z.useState(!1),g=Z.useRef(f);g.current=f,Z.useEffect(()=>{let e=Bc();g.current!==e&&(g.current=e,p(e))},[]);let _=e=>{let t=zc(e);g.current!==t&&(g.current=t,p(t),Vc(t))},[v,y]=Z.useState(e),b=t??v,x=e=>{let t=typeof e==`function`?e(b):e;n?n(t):y(t),document.cookie=`${Dc}=${t}; path=/; max-age=${Oc}`},S=()=>s?l(e=>!e):x(e=>!e),C=Hc(S);Z.useEffect(()=>{let e=e=>{e.key.toLowerCase()===Ic&&(e.metaKey||e.ctrlKey)&&!(e.metaKey&&e.ctrlKey)&&!e.shiftKey&&!e.altKey&&(e.preventDefault(),C.current())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[C]);let w={state:b?`expanded`:`collapsed`,open:b,setOpen:x,isMobile:s,openMobile:c,openMobileSettled:u,setOpenMobile:l,setOpenMobileSettled:d,sidebarResizing:m,setSidebarResizing:h,sidebarWidth:f,setSidebarWidth:_,toggleSidebar:S};return(0,Q.jsx)(Lc.Provider,{value:w,children:(0,Q.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:{...i,"--sidebar-width":f,"--sidebar-width-icon":Fc},className:rn(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),...o,children:a})})}function Gc(e){let t=(0,$.c)(50),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({side:o,variant:s,collapsible:c,className:r,children:n,dir:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=o===void 0?`left`:o,u=s===void 0?`sidebar`:s,d=c===void 0?`offcanvas`:c,{isMobile:f,state:p,openMobile:m,setOpenMobile:h,setOpenMobileSettled:g,sidebarResizing:_}=Uc();if(d===`none`){let e;t[8]===r?e=t[9]:(e=rn(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),t[8]=r,t[9]=e);let i;return t[10]!==n||t[11]!==a||t[12]!==e?(i=(0,Q.jsx)(`div`,{"data-slot":`sidebar`,className:e,...a,children:n}),t[10]=n,t[11]=a,t[12]=e,t[13]=i):i=t[13],i}if(f){let e;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(e={"--sidebar-width":Pc},t[14]=e):e=t[14];let r;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsxs)(wc,{className:`sr-only`,children:[(0,Q.jsx)(Tc,{children:`Sidebar`}),(0,Q.jsx)(Ec,{children:`Displays the mobile sidebar.`})]}),t[15]=r):r=t[15];let o;t[16]===n?o=t[17]:(o=(0,Q.jsx)(`div`,{className:`flex h-full w-full flex-col`,children:n}),t[16]=n,t[17]=o);let s;t[18]!==i||t[19]!==l||t[20]!==o?(s=(0,Q.jsxs)(Cc,{dir:i,"data-sidebar":`sidebar`,"data-slot":`sidebar`,"data-mobile":`true`,className:`w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden`,style:e,side:l,children:[r,o]}),t[18]=i,t[19]=l,t[20]=o,t[21]=s):s=t[21];let c;return t[22]!==m||t[23]!==a||t[24]!==h||t[25]!==g||t[26]!==s?(c=(0,Q.jsx)(bc,{open:m,onOpenChange:h,onOpenChangeComplete:g,...a,children:s}),t[22]=m,t[23]=a,t[24]=h,t[25]=g,t[26]=s,t[27]=c):c=t[27],c}let v=p===`collapsed`?d:``,y=_?`true`:void 0,b=u===`floating`||u===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`,x;t[28]===b?x=t[29]:(x=rn(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear group-data-[resizing=true]:transition-none`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,b),t[28]=b,t[29]=x);let S;t[30]===x?S=t[31]:(S=(0,Q.jsx)(`div`,{"data-slot":`sidebar-gap`,className:x}),t[30]=x,t[31]=S);let C=u===`floating`||u===`inset`?`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]`:`border-sidebar-border/70 group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l`,w;t[32]!==r||t[33]!==C?(w=rn(`fixed inset-y-0 z-30 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear group-data-[resizing=true]:transition-none data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex`,C,r),t[32]=r,t[33]=C,t[34]=w):w=t[34];let T;t[35]===n?T=t[36]:(T=(0,Q.jsx)(`div`,{"data-sidebar":`sidebar`,"data-slot":`sidebar-inner`,className:`flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border`,children:n}),t[35]=n,t[36]=T);let E;t[37]!==a||t[38]!==l||t[39]!==w||t[40]!==T?(E=(0,Q.jsx)(`div`,{"data-slot":`sidebar-container`,"data-side":l,className:w,...a,children:T}),t[37]=a,t[38]=l,t[39]=w,t[40]=T,t[41]=E):E=t[41];let D;return t[42]!==l||t[43]!==p||t[44]!==E||t[45]!==v||t[46]!==y||t[47]!==S||t[48]!==u?(D=(0,Q.jsxs)(`div`,{className:`group peer hidden text-sidebar-foreground md:block`,"data-state":p,"data-collapsible":v,"data-resizing":y,"data-variant":u,"data-side":l,"data-slot":`sidebar`,children:[S,E]}),t[42]=l,t[43]=p,t[44]=E,t[45]=v,t[46]=y,t[47]=S,t[48]=u,t[49]=D):D=t[49],D}function Kc(e){let t=(0,$.c)(15),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,onClick:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let{toggleSidebar:a}=Uc(),o;t[4]===n?o=t[5]:(o=rn(n),t[4]=n,t[5]=o);let s;t[6]!==r||t[7]!==a?(s=e=>{r?.(e),a()},t[6]=r,t[7]=a,t[8]=s):s=t[8];let c,l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(Ya,{}),l=(0,Q.jsx)(`span`,{className:`sr-only`,children:`Toggle Sidebar`}),t[9]=c,t[10]=l):(c=t[9],l=t[10]);let u;return t[11]!==i||t[12]!==o||t[13]!==s?(u=(0,Q.jsx)(Je,{title:`Toggle sidebar`,kbd:`⌃ B`,children:(0,Q.jsxs)(ss,{"data-sidebar":`trigger`,"data-slot":`sidebar-trigger`,variant:`ghost`,size:`icon`,className:o,onClick:s,...i,children:[c,l]})}),t[11]=i,t[12]=o,t[13]=s,t[14]=u):u=t[14],u}function qc(e){let t=(0,$.c)(34),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:n,onClick:r,onPointerDown:i,style:o,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let{isMobile:s,setOpen:c,setSidebarResizing:l,setSidebarWidth:u,sidebarWidth:d,state:f}=Uc(),p;t[6]!==s||t[7]!==c||t[8]!==l||t[9]!==u||t[10]!==d||t[11]!==f?(p={isMobile:s,maxWidth:jc,minWidth:Ac,state:f,width:d,onOpenChange:c,onResize:u,onResizeActiveChange:l},t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=d,t[11]=f,t[12]=p):p=t[12];let{handleClick:m,handlePointerDown:h}=Qo(p),[g,_]=Z.useState(`col-resize`),[v,y]=Z.useState(10),b,x;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{let e=()=>{y(Vo())},t=window.matchMedia(`(pointer:coarse)`);return _(zo()),e(),t.addEventListener(`change`,e),()=>{t.removeEventListener(`change`,e)}},x=[],t[13]=b,t[14]=x):(b=t[13],x=t[14]),Z.useEffect(b,x);let S=g===`ew-resize`?`cursor-ew-resize group-data-[side=left]:cursor-ew-resize group-data-[side=right]:cursor-ew-resize [[data-side=left][data-state=collapsed]_&]:cursor-ew-resize [[data-side=right][data-state=collapsed]_&]:cursor-ew-resize`:`cursor-col-resize group-data-[side=left]:cursor-col-resize group-data-[side=right]:cursor-col-resize [[data-side=left][data-state=collapsed]_&]:cursor-col-resize [[data-side=right][data-state=collapsed]_&]:cursor-col-resize`,C;t[15]!==m||t[16]!==r?(C=e=>{r?.(e),!e.defaultPrevented&&m(e)},t[15]=m,t[16]=r,t[17]=C):C=t[17];let w;t[18]!==h||t[19]!==i?(w=e=>{i?.(e),!e.defaultPrevented&&h(e)},t[18]=h,t[19]=i,t[20]=w):w=t[20];let T=`${v}px`,E;t[21]!==g||t[22]!==o||t[23]!==T?(E={...o,"--sidebar-rail-width":T,cursor:g},t[21]=g,t[22]=o,t[23]=T,t[24]=E):E=t[24];let D=E,O;t[25]!==n||t[26]!==S?(O=rn(`absolute inset-y-0 z-40 hidden w-(--sidebar-rail-width) touch-none bg-transparent transition-all ease-linear select-none group-data-[side=left]:right-[calc(var(--sidebar-rail-width)*-1)] group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-px after:bg-transparent sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2`,Ss,S,`group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full`,lee,`[[data-side=left][data-collapsible=offcanvas]_&]:-right-2`,`[[data-side=right][data-collapsible=offcanvas]_&]:-left-2`,n),t[25]=n,t[26]=S,t[27]=O):O=t[27];let k;return t[28]!==a||t[29]!==C||t[30]!==w||t[31]!==D||t[32]!==O?(k=(0,Q.jsx)(`button`,{"data-sidebar":`rail`,"data-slot":`sidebar-rail`,"aria-label":`Toggle or resize Sidebar`,tabIndex:-1,onClick:C,onPointerDown:w,title:`Toggle or resize Sidebar`,style:D,className:O,...a}),t[28]=a,t[29]=C,t[30]=w,t[31]=D,t[32]=O,t[33]=k):k=t[33],k}function Jc(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=rn(`relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`main`,{"data-slot":`sidebar-inset`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Yc(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=rn(`flex flex-col gap-2 p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`div`,{"data-slot":`sidebar-header`,"data-sidebar":`header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Xc(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=rn(`flex flex-col gap-2 p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`div`,{"data-slot":`sidebar-footer`,"data-sidebar":`footer`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Zc(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=rn(`no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`div`,{"data-slot":`sidebar-content`,"data-sidebar":`content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Qc(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=rn(`relative flex w-full min-w-0 flex-col p-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`div`,{"data-slot":`sidebar-group`,"data-sidebar":`group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function $c(e){let t=(0,$.c)(10),n,r,i,o;if(t[0]!==e){let{className:s,render:c,...l}=e;n=c,o=To,r=`div`,i=a({className:rn(`flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0`,s)},l),t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=o}else n=t[1],r=t[2],i=t[3],o=t[4];let s;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(s={slot:`sidebar-group-label`,sidebar:`group-label`},t[5]=s):s=t[5];let c;return t[6]!==n||t[7]!==r||t[8]!==i?(c={defaultTagName:r,props:i,render:n,state:s},t[6]=n,t[7]=r,t[8]=i,t[9]=c):c=t[9],o(c)}function el(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=rn(`w-full text-sm`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`div`,{"data-slot":`sidebar-group-content`,"data-sidebar":`group-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function tl(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=rn(`flex w-full min-w-0 flex-col gap-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`ul`,{"data-slot":`sidebar-menu`,"data-sidebar":`menu`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function nl(e){let t=(0,$.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=rn(`group/menu-item relative`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`li`,{"data-slot":`sidebar-menu-item`,"data-sidebar":`menu-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var rl=Oo(`peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:text-sidebar-accent-foreground not-data-active:hover:bg-sidebar-accent/50 focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent/50 data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&_svg]:shrink-0 [&>span:last-child]:truncate [&>svg]:size-4`,{variants:{variant:{default:`hover:text-sidebar-accent-foreground not-data-active:hover:bg-sidebar-accent/50`,outline:`bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))] not-data-active:hover:bg-sidebar-accent/50`},size:{default:`h-8 text-sm`,sm:`h-7 text-xs`,lg:`h-12 text-sm group-data-[collapsible=icon]:p-0!`}},defaultVariants:{variant:`default`,size:`default`}});function il(e){let t=(0,$.c)(18),{render:n,isActive:i,variant:o,size:s,tooltip:c,className:l,...u}=e,d=i===void 0?!1:i,f=o===void 0?`default`:o,p=s===void 0?`default`:s,{isMobile:m,state:h}=Uc(),g=a({className:rn(rl({variant:f,size:p}),l)},u),_;t[0]!==n||t[1]!==c?(_=c?(0,Q.jsx)(r,{render:n}):n,t[0]=n,t[1]=c,t[2]=_):_=t[2];let v;t[3]!==d||t[4]!==p?(v={slot:`sidebar-menu-button`,sidebar:`menu-button`,size:p,active:d},t[3]=d,t[4]=p,t[5]=v):v=t[5];let y;t[6]!==g||t[7]!==_||t[8]!==v?(y={defaultTagName:`button`,props:g,render:_,state:v},t[6]=g,t[7]=_,t[8]=v,t[9]=y):y=t[9];let b=To(y);if(!c)return b;if(typeof c==`string`){let e;t[10]===c?e=t[11]:(e={children:c},t[10]=c,t[11]=e),c=e}let x=h!==`collapsed`||m,S;t[12]!==x||t[13]!==c?(S=(0,Q.jsx)(be,{side:`right`,align:`center`,hidden:x,...c}),t[12]=x,t[13]=c,t[14]=S):S=t[14];let C;return t[15]!==b||t[16]!==S?(C=(0,Q.jsxs)(nt,{children:[b,S]}),t[15]=b,t[16]=S,t[17]=C):C=t[17],C}var al=1,ol=.9,sl=.8,cl=.17,ll=.1,ul=.999,dl=.9999,fl=.99,pl=/[\\\/_+.#"@\[\(\{&]/,ml=/[\\\/_+.#"@\[\(\{&]/g,hl=/[\s-]/,gl=/[\s-]/g;function _l(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?al:fl;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=_l(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=al:pl.test(e.charAt(l-1))?(d*=sl,p=e.slice(i,l-1).match(ml),p&&i>0&&(d*=ul**+p.length)):hl.test(e.charAt(l-1))?(d*=ol,m=e.slice(i,l-1).match(gl),m&&i>0&&(d*=ul**+m.length)):(d*=cl,i>0&&(d*=ul**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=dl)),(d<ll&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=_l(e,t,n,r,l+1,a+2,o),f*ll>d&&(d=f*ll)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function vl(e){return e.toLowerCase().replace(gl,` `)}function yl(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,_l(e,t,vl(e),vl(t),0,0,{})}typeof window<`u`&&window.document&&window.document.createElement;function bl(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function xl(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Sl(...e){return t=>{let n=!1,r=e.map(e=>{let r=xl(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():xl(e[t],null)}}}}function Cl(...e){return Z.useCallback(Sl(...e),e)}function wl(e,t){let n=Z.createContext(t),r=e=>{let{children:t,...r}=e,i=Z.useMemo(()=>r,Object.values(r));return(0,Q.jsx)(n.Provider,{value:i,children:t})};r.displayName=e+`Provider`;function i(r){let i=Z.useContext(n);if(i)return i;if(t!==void 0)return t;throw Error(`\`${r}\` must be used within \`${e}\``)}return[r,i]}function Tl(e,t=[]){let n=[];function r(t,r){let i=Z.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=Z.useMemo(()=>o,Object.values(o));return(0,Q.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=Z.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>Z.createContext(e));return function(n){let r=n?.[e]||t;return Z.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,El(i,...t)]}function El(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return Z.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}var Dl=globalThis?.document?Z.useLayoutEffect:()=>{},Ol=Z.useId||(()=>void 0),kl=0;function Al(e){let[t,n]=Z.useState(Ol());return Dl(()=>{e||n(e=>e??String(kl++))},[e]),e||(t?`radix-${t}`:``)}var jl=Z.useInsertionEffect||Dl;function Ml({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=Nl({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=Z.useRef(e!==void 0);Z.useEffect(()=>{let e=t.current;e!==s&&console.warn(`${r} is changing from ${e?`controlled`:`uncontrolled`} to ${s?`controlled`:`uncontrolled`}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),t.current=s},[s,r])}return[c,Z.useCallback(t=>{if(s){let n=Pl(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function Nl({defaultProp:e,onChange:t}){let[n,r]=Z.useState(e),i=Z.useRef(n),a=Z.useRef(t);return jl(()=>{a.current=t},[t]),Z.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function Pl(e){return typeof e==`function`}var Fl=t(En(),1);function Il(e){let t=Ll(e),n=Z.forwardRef((e,n)=>{let{children:r,...i}=e,a=Z.Children.toArray(r),o=a.find(zl);if(o){let e=o.props.children,r=a.map(t=>t===o?Z.Children.count(e)>1?Z.Children.only(null):Z.isValidElement(e)?e.props.children:null:t);return(0,Q.jsx)(t,{...i,ref:n,children:Z.isValidElement(e)?Z.cloneElement(e,void 0,r):null})}return(0,Q.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function Ll(e){let t=Z.forwardRef((e,t)=>{let{children:n,...r}=e;if(Z.isValidElement(n)){let e=Vl(n),i=Bl(r,n.props);return n.type!==Z.Fragment&&(i.ref=t?Sl(t,e):e),Z.cloneElement(n,i)}return Z.Children.count(n)>1?Z.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Rl=Symbol(`radix.slottable`);function zl(e){return Z.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===Rl}function Bl(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function Vl(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Hl=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=Il(`Primitive.${t}`),r=Z.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,Q.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Ul(e,t){e&&Fl.flushSync(()=>e.dispatchEvent(t))}function Wl(e){let t=Z.useRef(e);return Z.useEffect(()=>{t.current=e}),Z.useMemo(()=>(...e)=>t.current?.(...e),[])}function Gl(e,t=globalThis?.document){let n=Wl(e);Z.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var Kl=`DismissableLayer`,ql=`dismissableLayer.update`,Jl=`dismissableLayer.pointerDownOutside`,Yl=`dismissableLayer.focusOutside`,Xl,Zl=Z.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ql=Z.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:s,...c}=e,l=Z.useContext(Zl),[u,d]=Z.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=Z.useState({}),m=Cl(t,e=>d(e)),h=Array.from(l.layers),[g]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),_=h.indexOf(g),v=u?h.indexOf(u):-1,y=l.layersWithOutsidePointerEventsDisabled.size>0,b=v>=_,x=tu(e=>{let t=e.target,n=[...l.branches].some(e=>e.contains(t));!b||n||(i?.(e),o?.(e),e.defaultPrevented||s?.())},f),S=nu(e=>{let t=e.target;[...l.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||s?.())},f);return Gl(e=>{v===l.layers.size-1&&(r?.(e),!e.defaultPrevented&&s&&(e.preventDefault(),s()))},f),Z.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(Xl=f.body.style.pointerEvents,f.body.style.pointerEvents=`none`),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),ru(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=Xl)}},[u,f,n,l]),Z.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),ru())},[u,l]),Z.useEffect(()=>{let e=()=>p({});return document.addEventListener(ql,e),()=>document.removeEventListener(ql,e)},[]),(0,Q.jsx)(Hl.div,{...c,ref:m,style:{pointerEvents:y?b?`auto`:`none`:void 0,...e.style},onFocusCapture:bl(e.onFocusCapture,S.onFocusCapture),onBlurCapture:bl(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:bl(e.onPointerDownCapture,x.onPointerDownCapture)})});Ql.displayName=Kl;var $l=`DismissableLayerBranch`,eu=Z.forwardRef((e,t)=>{let n=Z.useContext(Zl),r=Z.useRef(null),i=Cl(t,r);return Z.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,Q.jsx)(Hl.div,{...e,ref:i})});eu.displayName=$l;function tu(e,t=globalThis?.document){let n=Wl(e),r=Z.useRef(!1),i=Z.useRef(()=>{});return Z.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){iu(Jl,n,a,{discrete:!0})},a={originalEvent:e};e.pointerType===`touch`?(t.removeEventListener(`click`,i.current),i.current=r,t.addEventListener(`click`,i.current,{once:!0})):r()}else t.removeEventListener(`click`,i.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener(`pointerdown`,e)},0);return()=>{window.clearTimeout(a),t.removeEventListener(`pointerdown`,e),t.removeEventListener(`click`,i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function nu(e,t=globalThis?.document){let n=Wl(e),r=Z.useRef(!1);return Z.useEffect(()=>{let e=e=>{e.target&&!r.current&&iu(Yl,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function ru(){let e=new CustomEvent(ql);document.dispatchEvent(e)}function iu(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Ul(i,a):i.dispatchEvent(a)}var au=`focusScope.autoFocusOnMount`,ou=`focusScope.autoFocusOnUnmount`,su={bubbles:!1,cancelable:!0},cu=`FocusScope`,lu=Z.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=Z.useState(null),l=Wl(i),u=Wl(a),d=Z.useRef(null),f=Cl(t,e=>c(e)),p=Z.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;Z.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:gu(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||gu(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&gu(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),Z.useEffect(()=>{if(s){_u.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(au,su);s.addEventListener(au,l),s.dispatchEvent(t),t.defaultPrevented||(uu(bu(fu(s)),{select:!0}),document.activeElement===e&&gu(s))}return()=>{s.removeEventListener(au,l),setTimeout(()=>{let t=new CustomEvent(ou,su);s.addEventListener(ou,u),s.dispatchEvent(t),t.defaultPrevented||gu(e??document.body,{select:!0}),s.removeEventListener(ou,u),_u.remove(p)},0)}}},[s,l,u,p]);let m=Z.useCallback(e=>{if(!n&&!r||p.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=du(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&gu(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&gu(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,Q.jsx)(Hl.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});lu.displayName=cu;function uu(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(gu(r,{select:t}),document.activeElement!==n)return}function du(e){let t=fu(e);return[pu(t,e),pu(t.reverse(),e)]}function fu(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function pu(e,t){for(let n of e)if(!mu(n,{upTo:t}))return n}function mu(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function hu(e){return e instanceof HTMLInputElement&&`select`in e}function gu(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&hu(e)&&t&&e.select()}}var _u=vu();function vu(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=yu(e,t),e.unshift(t)},remove(t){e=yu(e,t),e[0]?.resume()}}}function yu(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function bu(e){return e.filter(e=>e.tagName!==`A`)}var xu=`Portal`,Su=Z.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=Z.useState(!1);Dl(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?Fl.createPortal((0,Q.jsx)(Hl.div,{...r,ref:t}),o):null});Su.displayName=xu;function fee(e,t){return Z.useReducer((e,n)=>t[e][n]??e,e)}var Cu=e=>{let{present:t,children:n}=e,r=pee(t),i=typeof n==`function`?n({present:r.isPresent}):Z.Children.only(n),a=Cl(r.ref,mee(i));return typeof n==`function`||r.isPresent?Z.cloneElement(i,{ref:a}):null};Cu.displayName=`Presence`;function pee(e){let[t,n]=Z.useState(),r=Z.useRef(null),i=Z.useRef(e),a=Z.useRef(`none`),[o,s]=fee(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return Z.useEffect(()=>{let e=wu(r.current);a.current=o===`mounted`?e:`none`},[o]),Dl(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=wu(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),Dl(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=wu(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(s(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},c=e=>{e.target===t&&(a.current=wu(r.current))};return t.addEventListener(`animationstart`,c),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,c),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:Z.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function wu(e){return e?.animationName||`none`}function mee(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Tu=0;function hee(){Z.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??Eu()),document.body.insertAdjacentElement(`beforeend`,e[1]??Eu()),Tu++,()=>{Tu===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),Tu--}},[])}function Eu(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var Du=function(){return Du=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Du.apply(this,arguments)};function Ou(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function gee(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var ku=`right-scroll-bar-position`,Au=`width-before-scroll-bar`,_ee=`with-scroll-bars-hidden`,vee=`--removed-body-scroll-bar-size`;function ju(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function yee(e,t){var n=(0,Z.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var bee=typeof window<`u`?Z.useLayoutEffect:Z.useEffect,Mu=new WeakMap;function xee(e,t){var n=yee(t||null,function(t){return e.forEach(function(e){return ju(e,t)})});return bee(function(){var t=Mu.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||ju(e,null)}),i.forEach(function(e){r.has(e)||ju(e,a)})}Mu.set(n,e)},[e]),n}function See(e){return e}function Cee(e,t){t===void 0&&(t=See);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function wee(e){e===void 0&&(e={});var t=Cee(null);return t.options=Du({async:!0,ssr:!1},e),t}var Nu=function(e){var t=e.sideCar,n=Ou(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return Z.createElement(r,Du({},n))};Nu.isSideCarExport=!0;function Tee(e,t){return e.useMedium(t),Nu}var Pu=wee(),Fu=function(){},Iu=Z.forwardRef(function(e,t){var n=Z.useRef(null),r=Z.useState({onScrollCapture:Fu,onWheelCapture:Fu,onTouchMoveCapture:Fu}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,b=Ou(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=xee([n,t]),C=Du(Du({},b),i);return Z.createElement(Z.Fragment,null,u&&Z.createElement(x,{sideCar:Pu,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?Z.cloneElement(Z.Children.only(s),Du(Du({},C),{ref:S})):Z.createElement(v,Du({},C,{className:c,ref:S}),s))});Iu.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Iu.classNames={fullWidth:Au,zeroRight:ku};var Lu,Ru=function(){if(Lu)return Lu;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function zu(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=Ru();return t&&e.setAttribute(`nonce`,t),e}function Bu(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Vu(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var Hu=function(){var e=0,t=null;return{add:function(n){e==0&&(t=zu())&&(Bu(t,n),Vu(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Uu=function(){var e=Hu();return function(t,n){Z.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Wu=function(){var e=Uu();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},Gu={left:0,top:0,right:0,gap:0},Ku=function(e){return parseInt(e||``,10)||0},qu=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[Ku(n),Ku(r),Ku(i)]},Ju=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return Gu;var t=qu(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Yu=Wu(),Xu=`data-scroll-locked`,Zu=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
3
3
|
.${_ee} {
|
|
4
4
|
overflow: hidden ${r};
|
|
5
5
|
padding-right: ${s}px ${r};
|
|
@@ -2145,7 +2145,7 @@ XID_Start XIDS`.split(/\s/).map(e=>[Qk(e),e])),rne=new Map([[`s`,xA(383)],[xA(38
|
|
|
2145
2145
|
--trees-selected-fg-override: var(--accent-foreground);
|
|
2146
2146
|
--trees-padding-inline-override: 0px;
|
|
2147
2147
|
}
|
|
2148
|
-
`,Zne=QY(`complete`),Qne=vX({set:`complete`,colored:!0});function x7(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none block h-0 w-0 overflow-hidden`,dangerouslySetInnerHTML:{__html:Zne}}),e[0]=t):t=e[0],t}function S7(e){let t=(0,$.c)(25),{path:n}=e,r,i,a,o,s,c,l,u,d,f;if(t[0]!==n){let e=Qne.resolveIcon(`file-tree-icon-file`,n),p=e.token?eX(e.token):void 0;a=`true`,o=`size-4 shrink-0 text-muted-foreground`,s=e.remappedFrom??e.name,c=e.token,l=`false`,u=p?{color:p}:void 0,d=e.viewBox??`0 0 ${e.width??16} ${e.height??16}`,f=e.width??16,i=e.height??16;let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=/^#/,t[11]=m):m=t[11],r=e.name.replace(m,``),t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];let p=`#${r}`,m;t[12]===p?m=t[13]:(m=(0,Q.jsx)(`use`,{href:p}),t[12]=p,t[13]=m);let h;return t[14]!==i||t[15]!==m||t[16]!==a||t[17]!==o||t[18]!==s||t[19]!==c||t[20]!==l||t[21]!==u||t[22]!==d||t[23]!==f?(h=(0,Q.jsx)(`svg`,{"aria-hidden":a,className:o,"data-icon-name":s,"data-icon-token":c,focusable:l,style:u,viewBox:d,width:f,height:i,children:m}),t[14]=i,t[15]=m,t[16]=a,t[17]=o,t[18]=s,t[19]=c,t[20]=l,t[21]=u,t[22]=d,t[23]=f,t[24]=h):h=t[24],h}function $ne(e){return e?.isDirectory()===!0}function ere(e){let t=new Set;for(let n of e){let e=n.split(`/`).filter(Boolean);for(let n=1;n<e.length;n+=1)t.add(`${e.slice(0,n).join(`/`)}/`)}return[...t].sort((e,t)=>t.split(`/`).length-e.split(`/`).length||t.length-e.length||t.localeCompare(e))}function tre({collapseAllRevision:e,paths:t,selectedPath:n,onSelectFile:r}){let i=Z.useRef(new Set(t)),a=Z.useRef(r),o=Z.useRef(0);i.current=new Set(t),a.current=r;let{model:s}=t6({paths:t,flattenEmptyDirectories:!0,initialExpansion:1,initialSelectedPaths:n?[n]:[],onSelectionChange:e=>{let[t]=e;!t||!i.current.has(t)||a.current(t)},search:!0,unsafeCSS:Xne});Z.useEffect(()=>{s.resetPaths(t)},[s,t]),Z.useEffect(()=>{if(!n)return;let e=s.getItem(n);if(e){for(let e of s.getSelectedPaths())e!==n&&s.getItem(e)?.deselect();e.select(),e.focus()}},[s,n]),Z.useEffect(()=>{if(!(e<=0||e===o.current||t.length===0)){o.current=e;for(let e of ere(t)){let t=s.getItem(e);!$ne(t)||!t.isExpanded()||t.collapse()}s.focusNearestPath(n||s.getFocusedPath())}},[e,s,t,n]);let c=()=>{window.requestAnimationFrame(()=>{let e=s.getFocusedPath();!e||!i.current.has(e)||a.current(e)})};return(0,Q.jsx)(e6,{model:s,className:`block h-full min-h-0 w-full overflow-hidden`,onClick:c,onKeyUp:e=>{e.key!==`Enter`&&e.key!==` `||c()}})}function C7(e){let t=(0,$.c)(59),{viewerContextId:n,cwd:r,active:i,activeFilePath:a,onCloseFile:o,onOpenFile:s,previewMode:c}=e,l=c===void 0?`external`:c,u=a_(r),[d,f]=Z.useState(!1),[p,m]=Z.useState(0),h=l===`inline`&&!!a,g=b7({viewerContextId:n,cwd:u}),_=!!(i&&n&&u),v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=[`data`,`isPending`,`error`],t[0]=v):v=t[0];let y;t[1]!==g||t[2]!==_?(y={...g,enabled:_,select:rre,notifyOnChangeProps:v},t[1]=g,t[2]=_,t[3]=y):y=t[3];let b=Or(y),x;t[4]===b.data?x=t[5]:(x=b.data??[],t[4]=b.data,t[5]=x);let S=x,C=h?`grid grid-rows-[minmax(0,1fr)_minmax(0,1fr)]`:`flex flex-col`,w;t[6]===C?w=t[7]:(w=rn(`h-full min-h-0 overflow-hidden`,C),t[6]=C,t[7]=w);let T=h?`border-b border-border/70`:`flex-1 overflow-hidden`,E;t[8]===T?E=t[9]:(E=rn(`flex min-h-0 flex-col bg-background`,T),t[8]=T,t[9]=E);let D;t[10]===S.length?D=t[11]:(D=S.length.toLocaleString(),t[10]=S.length,t[11]=D);let O;t[12]===D?O=t[13]:(O=(0,Q.jsxs)(`div`,{className:`text-xs font-bold tracking-[0.04em] text-muted-foreground uppercase`,children:[D,` files`]}),t[12]=D,t[13]=O);let k=S.length===0,A;t[14]===m?A=t[15]:(A=()=>{m(nre)},t[14]=m,t[15]=A);let j;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Q.jsx)(Pa,{className:`size-4`}),t[16]=j):j=t[16];let M;t[17]!==k||t[18]!==A?(M=(0,Q.jsx)(Je,{title:`Collapse all folders`,children:(0,Q.jsx)(ss,{type:`button`,variant:`outline`,size:`icon`,"aria-label":`Collapse all folders`,disabled:k,onClick:A,children:j})}),t[17]=k,t[18]=A,t[19]=M):M=t[19];let N;t[20]===f?N=t[21]:(N=(0,Q.jsx)(ss,{type:`button`,variant:`outline`,onClick:()=>{f(!0)},children:`Open File`}),t[20]=f,t[21]=N);let P;t[22]!==M||t[23]!==N?(P=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[M,N]}),t[22]=M,t[23]=N,t[24]=P):P=t[24];let F;t[25]!==O||t[26]!==P?(F=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-border/70 p-2`,children:[O,P]}),t[25]=O,t[26]=P,t[27]=F):F=t[27];let I;t[28]!==a||t[29]!==p||t[30]!==b.data||t[31]!==b.error||t[32]!==b.isPending||t[33]!==u||t[34]!==s||t[35]!==S||t[36]!==n?(I=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden p-2`,children:u?n?b.isPending&&b.data===void 0?(0,Q.jsxs)(h7,{children:[(0,Q.jsx)(H,{}),` Loading files…`]}):b.error?(0,Q.jsx)(h7,{tone:`destructive`,children:c_(b.error,`Failed to load files`)}):S.length>0?(0,Q.jsx)(tre,{collapseAllRevision:p,paths:S,selectedPath:a,onSelectFile:s}):(0,Q.jsx)(h7,{children:`No files found.`}):(0,Q.jsx)(h7,{children:`Waiting for viewer context…`}):(0,Q.jsx)(h7,{children:`No directory selected.`})}),t[28]=a,t[29]=p,t[30]=b.data,t[31]=b.error,t[32]=b.isPending,t[33]=u,t[34]=s,t[35]=S,t[36]=n,t[37]=I):I=t[37];let L;t[38]!==E||t[39]!==F||t[40]!==I?(L=(0,Q.jsxs)(`div`,{className:E,children:[F,I]}),t[38]=E,t[39]=F,t[40]=I,t[41]=L):L=t[41];let R;t[42]!==i||t[43]!==a||t[44]!==u||t[45]!==o||t[46]!==h||t[47]!==n?(R=h?(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden bg-background`,children:[(0,Q.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center justify-between gap-2 border-b border-border/70 px-3 text-xs font-medium text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,title:a,children:a}),(0,Q.jsx)(Je,{title:`Close file preview`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Close file preview`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,onClick:o,children:(0,Q.jsx)(no,{className:`size-4`})})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,Q.jsx)(T7,{viewerContextId:n,cwd:u,active:i,path:a})})]}):null,t[42]=i,t[43]=a,t[44]=u,t[45]=o,t[46]=h,t[47]=n,t[48]=R):R=t[48];let z;t[49]!==s||t[50]!==d||t[51]!==S||t[52]!==f?(z=(0,Q.jsx)(w7,{open:d,onOpenChange:f,paths:S,onOpenFile:s}),t[49]=s,t[50]=d,t[51]=S,t[52]=f,t[53]=z):z=t[53];let B;return t[54]!==L||t[55]!==R||t[56]!==z||t[57]!==w?(B=(0,Q.jsxs)(`div`,{className:w,children:[L,R,z]}),t[54]=L,t[55]=R,t[56]=z,t[57]=w,t[58]=B):B=t[58],B}function nre(e){return e+1}function rre(e){return e.paths}function w7(e){let t=(0,$.c)(23),{open:n,onOpenChange:r,paths:i,onOpenFile:a}=e,[o,s]=Z.useState(``),c,l;t[0]===n?(c=t[1],l=t[2]):(c=()=>{n||s(``)},l=[n],t[0]=n,t[1]=c,t[2]=l),Z.useEffect(c,l);let u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(x7,{}),t[3]=u):u=t[3];let d;t[4]===o?d=t[5]:(d=(0,Q.jsx)(kp,{value:o,onValueChange:s,placeholder:`Search files…`}),t[4]=o,t[5]=d);let f;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(jp,{children:`No files found.`}),t[6]=f):f=t[6];let p;if(t[7]!==r||t[8]!==a||t[9]!==i){let e;t[11]!==r||t[12]!==a?(e=e=>(0,Q.jsxs)(Np,{value:e,keywords:[e],onSelect:()=>{a(e),r(!1)},children:[(0,Q.jsx)(S7,{path:e}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:e})]},e),t[11]=r,t[12]=a,t[13]=e):e=t[13],p=i.map(e),t[7]=r,t[8]=a,t[9]=i,t[10]=p}else p=t[10];let m;t[14]===p?m=t[15]:(m=(0,Q.jsxs)(Ap,{children:[f,(0,Q.jsx)(Mp,{heading:`Files`,children:p})]}),t[14]=p,t[15]=m);let h;t[16]!==d||t[17]!==m?(h=(0,Q.jsxs)(Dp,{shouldFilter:!0,children:[u,d,m]}),t[16]=d,t[17]=m,t[18]=h):h=t[18];let g;return t[19]!==r||t[20]!==n||t[21]!==h?(g=(0,Q.jsx)(Op,{open:n,onOpenChange:r,title:`Open Files`,description:`Search project files to open.`,children:h}),t[19]=r,t[20]=n,t[21]=h,t[22]=g):g=t[22],g}function T7(e){let t=(0,$.c)(25),{viewerContextId:n,cwd:r,active:i,path:a}=e,o,s,c;t[0]!==r||t[1]!==a||t[2]!==n?(o=a_(r),c=Or,s=Yne({viewerContextId:n,cwd:o,path:a}),t[0]=r,t[1]=a,t[2]=n,t[3]=o,t[4]=s,t[5]=c):(o=t[3],s=t[4],c=t[5]);let l=!!(i&&n&&o&&a),u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(u=[`data`,`isPending`,`error`],t[6]=u):u=t[6];let d;t[7]!==s||t[8]!==l?(d={...s,enabled:l,notifyOnChangeProps:u},t[7]=s,t[8]=l,t[9]=d):d=t[9];let f=c(d),p=f.data?.content??``,m;t[10]===a?m=t[11]:(m=Kne(a),t[10]=a,t[11]=m);let h=m,[g,_]=Z.useState(null),v,y;if(t[12]!==i||t[13]!==p||t[14]!==h?(v=()=>{let e=!1;if(!i||!p||!h){_(null);return}return _(null),Jne(p,h).then(t=>{e||_(t)}).catch(()=>{e||_({ok:!0,unavailable:!0})}),()=>{e=!0}},y=[i,p,h],t[12]=i,t[13]=p,t[14]=h,t[15]=v,t[16]=y):(v=t[15],y=t[16]),Z.useEffect(v,y),!a){let e;return t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-center text-sm text-muted-foreground`,children:`Select a file to preview it.`}),t[17]=e):e=t[17],e}let b;return t[18]!==p||t[19]!==f.data||t[20]!==f.error||t[21]!==f.isPending||t[22]!==g||t[23]!==h?(b=(0,Q.jsx)(`div`,{className:`h-full min-h-0 overflow-auto bg-background`,children:f.isPending&&!f.data?(0,Q.jsx)(`div`,{className:`p-4`,children:(0,Q.jsxs)(h7,{children:[(0,Q.jsx)(H,{}),` Loading file…`]})}):f.error?(0,Q.jsx)(`div`,{className:`p-4`,children:(0,Q.jsx)(h7,{tone:`destructive`,children:c_(f.error,`Failed to load file`)})}):qne(g)?(0,Q.jsx)(`pre`,{className:`m-0 min-h-full p-4 font-mono text-[13px] leading-5 whitespace-pre-wrap text-foreground`,children:(0,Q.jsx)(`code`,{className:rn(h&&`language-${h}`),dangerouslySetInnerHTML:{__html:g.html}})}):(0,Q.jsx)(`pre`,{className:`m-0 min-h-full p-4 font-mono text-[13px] leading-5 whitespace-pre-wrap text-foreground`,children:(0,Q.jsx)(`code`,{children:p})})}),t[18]=p,t[19]=f.data,t[20]=f.error,t[21]=f.isPending,t[22]=g,t[23]=h,t[24]=b):b=t[24],b}function E7(e){let t=(0,$.c)(62),{active:n,dragging:r,dragListeners:i,dragAttributes:a,index:o,onActiveFileChange:s,onActiveTabChange:c,onCloseAllFiles:l,onCloseFile:u,onCloseFilesToRight:d,onCloseOtherFiles:f,path:p,preview:m,tabCount:h}=e,g=r===void 0?!1:r,_=n&&`bg-muted text-foreground`,v=g&&`border-transparent shadow-none ring-0`,y;t[0]!==_||t[1]!==v?(y=rn(`inline-flex h-8 max-w-56 shrink-0 items-center rounded-md border border-transparent text-sm font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,_,v),t[0]=_,t[1]=v,t[2]=y):y=t[2];let b;t[3]!==s||t[4]!==c||t[5]!==p?(b=()=>{c(`files`),s?.(p)},t[3]=s,t[4]=c,t[5]=p,t[6]=b):b=t[6];let x;t[7]===p?x=t[8]:(x=(0,Q.jsx)(S7,{path:p}),t[7]=p,t[8]=x);let S=m&&`italic`,C;t[9]===S?C=t[10]:(C=rn(`block min-w-0 truncate`,S),t[9]=S,t[10]=C);let w;t[11]===p?w=t[12]:(w=pre(p),t[11]=p,t[12]=w);let T;t[13]!==C||t[14]!==w?(T=(0,Q.jsx)(`span`,{className:C,children:w}),t[13]=C,t[14]=w,t[15]=T):T=t[15];let E;t[16]!==p||t[17]!==T||t[18]!==b||t[19]!==x?(E=(0,Q.jsxs)(`button`,{type:`button`,title:p,className:`flex min-w-0 flex-1 items-center gap-1.5 px-2.5 text-left`,onClick:b,children:[x,T]}),t[16]=p,t[17]=T,t[18]=b,t[19]=x,t[20]=E):E=t[20];let D=`Close ${p}`,O;t[21]!==u||t[22]!==p?(O=()=>{u?.(p)},t[21]=u,t[22]=p,t[23]=O):O=t[23];let k;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Q.jsx)(no,{className:`size-3`}),t[24]=k):k=t[24];let A;t[25]!==D||t[26]!==O?(A=(0,Q.jsx)(`button`,{type:`button`,"aria-label":D,className:`mr-1 inline-flex size-4 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-muted hover:text-foreground`,onClick:O,children:k}),t[25]=D,t[26]=O,t[27]=A):A=t[27];let j;t[28]!==a||t[29]!==i||t[30]!==E||t[31]!==A||t[32]!==y?(j=(0,Q.jsxs)(`div`,{className:y,...a,...i,children:[E,A]}),t[28]=a,t[29]=i,t[30]=E,t[31]=A,t[32]=y,t[33]=j):j=t[33];let M=j,N;t[34]===M?N=t[35]:(N=(0,Q.jsx)(f7,{render:M}),t[34]=M,t[35]=N);let P;t[36]!==u||t[37]!==p?(P=(0,Q.jsx)(m7,{onClick:()=>u?.(p),children:`Close`}),t[36]=u,t[37]=p,t[38]=P):P=t[38];let F=h<=1,I;t[39]!==f||t[40]!==p?(I=()=>f?.(p),t[39]=f,t[40]=p,t[41]=I):I=t[41];let L;t[42]!==F||t[43]!==I?(L=(0,Q.jsx)(m7,{disabled:F,onClick:I,children:`Close others`}),t[42]=F,t[43]=I,t[44]=L):L=t[44];let R=o>=h-1,z;t[45]!==d||t[46]!==p?(z=()=>d?.(p),t[45]=d,t[46]=p,t[47]=z):z=t[47];let B;t[48]!==R||t[49]!==z?(B=(0,Q.jsx)(m7,{disabled:R,onClick:z,children:`Close to the right`}),t[48]=R,t[49]=z,t[50]=B):B=t[50];let V;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Q.jsx)(Vne,{}),t[51]=V):V=t[51];let H;t[52]===l?H=t[53]:(H=(0,Q.jsx)(m7,{onClick:()=>l?.(),children:`Close all`}),t[52]=l,t[53]=H);let U;t[54]!==P||t[55]!==L||t[56]!==B||t[57]!==H?(U=(0,Q.jsxs)(p7,{className:`w-44`,children:[P,L,B,V,H]}),t[54]=P,t[55]=L,t[56]=B,t[57]=H,t[58]=U):U=t[58];let W;return t[59]!==N||t[60]!==U?(W=(0,Q.jsxs)(d7,{children:[N,U]}),t[59]=N,t[60]=U,t[61]=W):W=t[61],W}function ire(e){let t=(0,$.c)(18),n;t[0]===e.path?n=t[1]:(n={id:e.path},t[0]=e.path,t[1]=n);let{attributes:r,isDragging:i,listeners:a,setNodeRef:o,transform:s,transition:c}=l7(n),l;t[2]===s?l=t[3]:(l=D6.Transform.toString(s),t[2]=s,t[3]=l);let u;t[4]!==l||t[5]!==c?(u={transform:l,transition:c},t[4]=l,t[5]=c,t[6]=u):u=t[6];let d=u,f=i&&`opacity-0`,p;t[7]===f?p=t[8]:(p=rn(`shrink-0`,f),t[7]=f,t[8]=p);let m;t[9]!==r||t[10]!==a||t[11]!==e?(m=(0,Q.jsx)(E7,{...e,dragAttributes:r,dragListeners:a}),t[9]=r,t[10]=a,t[11]=e,t[12]=m):m=t[12];let h;return t[13]!==o||t[14]!==d||t[15]!==p||t[16]!==m?(h=(0,Q.jsx)(`div`,{ref:o,style:d,className:p,children:m}),t[13]=o,t[14]=d,t[15]=p,t[16]=m,t[17]=h):h=t[17],h}function are(e){let t=(0,$.c)(6),{activeFilePath:n,activePath:r,filePreviewPath:i,fileTabs:a}=e,o=a.indexOf(r);if(o<0)return null;let s=n===r,c=i===r,l;return t[0]!==r||t[1]!==a.length||t[2]!==o||t[3]!==s||t[4]!==c?(l=(0,Q.jsx)(E7,{active:s,dragging:!0,index:o,onActiveTabChange:ore,path:r,preview:c,tabCount:a.length}),t[0]=r,t[1]=a.length,t[2]=o,t[3]=s,t[4]=c,t[5]=l):l=t[5],l}function ore(){}function sre(e){let t=(0,$.c)(46),{activeFilePath:n,activeTab:r,filePreviewPath:i,fileTabs:a,onActiveFileChange:o,onActiveTabChange:s,onCloseAllFiles:c,onCloseFile:l,onCloseFilesToRight:u,onCloseOtherFiles:d,onOpenFileDialog:f,onReorderFiles:p,showReview:m}=e,h=i===void 0?``:i,g;t[0]===a?g=t[1]:(g=a===void 0?[]:a,t[0]=a,t[1]=g);let _=g,v=m===void 0?!1:m,y;t[2]!==r||t[3]!==s?(y=e=>{let{label:t,value:n}=e,i=r===n;return(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":i,className:rn(`inline-flex h-8 shrink-0 items-center rounded-md border border-transparent px-2.5 text-sm font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,i&&`bg-muted text-foreground`),onClick:()=>{s(n)},children:t},n)},t[2]=r,t[3]=s,t[4]=y):y=t[4];let b=y,[x,S]=Z.useState(``),C=_.length>0,w;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(w={activationConstraint:{distance:6}},t[5]=w):w=t[5];let T=U6(H6(W8,w)),E;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(E=e=>{S(String(e.active.id))},t[6]=E):E=t[6];let D=E,O;t[7]!==_||t[8]!==p?(O=e=>{let t=String(e.active.id),n=e.over?String(e.over.id):``;if(!t||!n||t===n)return;let r=_.indexOf(t),i=_.indexOf(n);r===-1||i===-1||(p?.(e7(_,r,i)),S(``))},t[7]=_,t[8]=p,t[9]=O):O=t[9];let k=O,A;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(A=()=>{S(``)},t[10]=A):A=t[10];let j=A,M;t[11]===C?M=t[12]:(M=C?(0,Q.jsx)(x7,{}):null,t[11]=C,t[12]=M);let N;t[13]!==b||t[14]!==v?(N=v?b({label:`Changes`,value:`review`}):null,t[13]=b,t[14]=v,t[15]=N):N=t[15];let P;t[16]!==C||t[17]!==b?(P=C?null:b({label:`Files`,value:`files`}),t[16]=C,t[17]=b,t[18]=P):P=t[18];let F;t[19]===C?F=t[20]:(F=C?(0,Q.jsx)(`span`,{className:`mx-1 shrink-0 text-xs text-border`,"aria-hidden":`true`,children:`|`}):null,t[19]=C,t[20]=F);let I;t[21]!==x||t[22]!==n||t[23]!==r||t[24]!==h||t[25]!==_||t[26]!==k||t[27]!==C||t[28]!==o||t[29]!==s||t[30]!==c||t[31]!==l||t[32]!==u||t[33]!==d||t[34]!==T?(I=C?(0,Q.jsxs)(V5,{sensors:T,collisionDetection:Z6,onDragStart:D,onDragEnd:k,onDragCancel:j,children:[(0,Q.jsx)(s7,{items:_,strategy:Cne,children:_.map((e,t)=>(0,Q.jsx)(ire,{active:r===`files`&&n===e,index:t,onActiveFileChange:o,onActiveTabChange:s,onCloseAllFiles:c,onCloseFile:l,onCloseFilesToRight:u,onCloseOtherFiles:d,path:e,preview:h===e,tabCount:_.length},e))}),(0,Q.jsx)($5,{dropAnimation:null,modifiers:Wne,children:x?(0,Q.jsx)(are,{activeFilePath:n,activePath:x,filePreviewPath:h,fileTabs:_}):null})]}):null,t[21]=x,t[22]=n,t[23]=r,t[24]=h,t[25]=_,t[26]=k,t[27]=C,t[28]=o,t[29]=s,t[30]=c,t[31]=l,t[32]=u,t[33]=d,t[34]=T,t[35]=I):I=t[35];let L;t[36]!==C||t[37]!==f?(L=C?(0,Q.jsx)(Je,{title:`Open another file`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Open another file`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md border border-transparent text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,onClick:f,children:`+`})}):null,t[36]=C,t[37]=f,t[38]=L):L=t[38];let R;return t[39]!==M||t[40]!==N||t[41]!==P||t[42]!==F||t[43]!==I||t[44]!==L?(R=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 overflow-x-auto border-b border-border/70 bg-background p-2`,children:[M,N,P,F,I,L]}),t[39]=M,t[40]=N,t[41]=P,t[42]=F,t[43]=I,t[44]=L,t[45]=R):R=t[45],R}function D7(e){return Number.isFinite(e)?Math.round(Math.min(Une,Math.max(Hne,e))):v7}function cre(){let e=A(er);return e==null?v7:D7(Number(e))}function lre(e){ee(er,String(D7(e)))}function ure(e){let t=(0,$.c)(6),{onResize:n,width:r}=e,i;t[0]===n?i=t[1]:(i=e=>{n(D7(e))},t[0]=n,t[1]=i);let a=i,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=rn(`absolute inset-y-0 right-0 z-20 w-3 translate-x-1/2 cursor-col-resize touch-none bg-transparent outline-hidden after:absolute after:inset-y-0 after:left-1/2 after:w-px after:bg-border/70 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1`,Ss),t[2]=o):o=t[2];let s;return t[3]!==a||t[4]!==r?(s=(0,Q.jsx)(`div`,{role:`separator`,"aria-label":`Resize file tree`,"aria-orientation":`vertical`,tabIndex:0,className:o,onKeyDown:e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=e.shiftKey?48:16;a(r+(e.key===`ArrowRight`?t:-t))},onPointerDown:e=>{if(e.button!==0)return;e.preventDefault();let t=e.clientX,n=r,i=document.body.style.cursor,o=document.body.style.userSelect,s=Ho(`col-resize`);document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let c=e=>{a(n+e.clientX-t)},l=()=>{s(),document.body.style.cursor=i,document.body.style.userSelect=o,document.removeEventListener(`pointermove`,c),document.removeEventListener(`pointerup`,l),document.removeEventListener(`pointercancel`,l)};document.addEventListener(`pointermove`,c),document.addEventListener(`pointerup`,l),document.addEventListener(`pointercancel`,l)}}),t[3]=a,t[4]=r,t[5]=s):s=t[5],s}function dre(e){let t=(0,$.c)(18),{viewerContextId:n,cwd:r,active:i,activeFilePath:a,onOpenFile:o,previewMode:s}=e,[c,l]=Z.useState(v7),u,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{l(cre())},d=[],t[0]=u,t[1]=d):(u=t[0],d=t[1]),Z.useEffect(u,d);let f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=e=>{let t=D7(e);l(t),lre(t)},t[2]=f):f=t[2];let p=f,m=`${c}px`,h;t[3]===m?h=t[4]:(h={width:m,maxWidth:`70%`},t[3]=m,t[4]=h);let g;t[5]!==i||t[6]!==a||t[7]!==r||t[8]!==o||t[9]!==s||t[10]!==n?(g=(0,Q.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden`,children:(0,Q.jsx)(C7,{viewerContextId:n,cwd:r,active:i,activeFilePath:a,onCloseFile:fre,onOpenFile:o,previewMode:s})}),t[5]=i,t[6]=a,t[7]=r,t[8]=o,t[9]=s,t[10]=n,t[11]=g):g=t[11];let _;t[12]===c?_=t[13]:(_=(0,Q.jsx)(ure,{width:c,onResize:p}),t[12]=c,t[13]=_);let v;return t[14]!==h||t[15]!==g||t[16]!==_?(v=(0,Q.jsxs)(`div`,{className:`relative min-h-0 shrink-0 overflow-visible border-r border-border/70`,style:h,children:[g,_]}),t[14]=h,t[15]=g,t[16]=_,t[17]=v):v=t[17],v}function fre(){}function pre(e){return e.split(`/`).filter(Boolean).at(-1)||e}function mre(e){let t=(0,$.c)(30),{fileTreeCollapsed:n,onFileTreeCollapsedChange:r,path:i}=e,a=n===void 0?!1:n,o,s,c,l,u,d,f,p,m;if(t[0]!==a||t[1]!==r||t[2]!==i){m=Symbol.for(`react.early_return_sentinel`);bb0:{let e=i.split(`/`).filter(Boolean);if(e.length===0){m=null;break bb0}f=`flex h-10 shrink-0 items-center gap-2 border-b border-border/70 bg-background px-3`,t[12]!==a||t[13]!==r?(p=r?(0,Q.jsx)(Je,{title:a?`Show file tree`:`Collapse file tree`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":a,"aria-label":a?`Show file tree`:`Collapse file tree`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md border border-transparent text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,onClick:()=>{r(!a)},children:a?(0,Q.jsx)(Ja,{className:`size-4`}):(0,Q.jsx)(qa,{className:`size-4`})})}):null,t[12]=a,t[13]=r,t[14]=p):p=t[14],d=`min-w-0 flex-1 overflow-x-auto`,s=Pne,u=i,o=Fne,c=`flex-nowrap gap-1 font-mono text-xs whitespace-nowrap`,l=e.map((t,n)=>{let r=n===e.length-1,i=`${n}:${t}`;return(0,Q.jsxs)(Z.Fragment,{children:[n>0?(0,Q.jsx)(Rne,{className:`text-muted-foreground/60`}):null,(0,Q.jsx)(Ine,{className:`min-w-0 shrink-0`,children:r?(0,Q.jsx)(Lne,{className:`max-w-80 truncate font-mono text-xs font-medium`,children:t}):(0,Q.jsx)(`span`,{className:`max-w-40 truncate text-muted-foreground`,children:t})})]},i)})}t[0]=a,t[1]=r,t[2]=i,t[3]=o,t[4]=s,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m}else o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11];if(m!==Symbol.for(`react.early_return_sentinel`))return m;let h;t[15]!==o||t[16]!==c||t[17]!==l?(h=(0,Q.jsx)(o,{className:c,children:l}),t[15]=o,t[16]=c,t[17]=l,t[18]=h):h=t[18];let g;t[19]!==s||t[20]!==u||t[21]!==h?(g=(0,Q.jsx)(s,{title:u,children:h}),t[19]=s,t[20]=u,t[21]=h,t[22]=g):g=t[22];let _;t[23]!==g||t[24]!==d?(_=(0,Q.jsx)(`div`,{className:d,children:g}),t[23]=g,t[24]=d,t[25]=_):_=t[25];let v;return t[26]!==_||t[27]!==f||t[28]!==p?(v=(0,Q.jsxs)(`div`,{className:f,children:[p,_]}),t[26]=_,t[27]=f,t[28]=p,t[29]=v):v=t[29],v}function O7(e){let t=(0,$.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Q.jsx)(Ot,{children:n}),t[0]=n,t[1]=r),r}function hre(e){let t=(0,$.c)(156),{viewerContextId:n,cwd:r,active:i,gitStatus:a,open:o,onOpenChange:s}=e,c=re(),l=Ao(),u=Rh(l),d=a_(r),[f,p]=Z.useState(``),[m,h]=Z.useState(`browse`),[g,_]=Z.useState(``),[v,y]=Z.useState(``),b=f_({viewerContextId:n,cwd:d,scope:`branches`}),x=!!(o&&i&&n&&d),S;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(S=[`data`,`isPending`,`error`],t[0]=S):S=t[0];let C;t[1]!==b||t[2]!==x?(C={...b,enabled:x,notifyOnChangeProps:S},t[1]=b,t[2]=x,t[3]=C):C=t[3];let w=Or(C),T=w.data,E,D,O;if(t[4]!==T?.localBranches||t[5]!==T?.remoteBranches||t[6]!==a){E=M_(T?.localBranches,a);let e;t[10]===T?.remoteBranches?e=t[11]:(e=T?.remoteBranches??[],t[10]=T?.remoteBranches,t[11]=e);let n;t[12]===e?n=t[13]:(n=e.filter(yre),t[12]=e,t[13]=n),D=n,O=new Set(E.map(vre)),t[4]=T?.localBranches,t[5]=T?.remoteBranches,t[6]=a,t[7]=E,t[8]=D,t[9]=O}else E=t[7],D=t[8],O=t[9];let k=O,A;t[14]!==o||t[15]!==y||t[16]!==p||t[17]!==_||t[18]!==h?(A=()=>{o||(p(``),h(`browse`),_(``),y(``))},t[14]=o,t[15]=y,t[16]=p,t[17]=_,t[18]=h,t[19]=A):A=t[19];let j;t[20]===o?j=t[21]:(j=[o],t[20]=o,t[21]=j),Z.useEffect(A,j);let M;t[22]!==E||t[23]!==o||t[24]!==D[0]||t[25]!==g||t[26]!==_?(M=()=>{if(!o||g)return;let e=E.find(_re);_(e?`local:${e.name}`:E[0]?`local:${E[0].name}`:D[0]?`remote:${D[0].name}`:`action:create`)},t[22]=E,t[23]=o,t[24]=D[0],t[25]=g,t[26]=_,t[27]=M):M=t[27];let N;t[28]!==E||t[29]!==o||t[30]!==D||t[31]!==g?(N=[E,o,D,g],t[28]=E,t[29]=o,t[30]=D,t[31]=g,t[32]=N):N=t[32],Z.useEffect(M,N);let P;t[33]!==d||t[34]!==n?(P=async e=>await wh(Ch(`/api/git-checkout`,{contextId:n}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({cwd:d,...e})}),t[33]=d,t[34]=n,t[35]=P):P=t[35];let F;t[36]!==d||t[37]!==s||t[38]!==c||t[39]!==n?(F=async(e,t)=>{await __({queryClient:c,viewerContextId:n,cwd:d}),s(!1),Qe.success(t.create?`Created and switched to ${t.branch}`:`Switched to ${t.branch}`)},t[36]=d,t[37]=s,t[38]=c,t[39]=n,t[40]=F):F=t[40];let I;t[41]!==P||t[42]!==F?(I={mutationFn:P,onSuccess:F,onError:gre},t[41]=P,t[42]=F,t[43]=I):I=t[43];let L=Nr(I),R;t[44]===L?R=t[45]:(R=e=>{e.current||L.isPending||L.mutate({branch:e.name})},t[44]=L,t[45]=R);let z=R,B;t[46]!==L||t[47]!==k?(B=e=>{if(L.isPending)return;let t=N_(e.name).branch||e.name;if(k.has(t)){L.mutate({branch:t});return}L.mutate({branch:t,create:!0,startPoint:e.name,track:!0})},t[46]=L,t[47]=k,t[48]=B):B=t[48];let V=B,U;t[49]!==L||t[50]!==v?(U=()=>{let e=v.trim();!e||L.isPending||L.mutate({branch:e,create:!0})},t[49]=L,t[50]=v,t[51]=U):U=t[51];let W=U,G;t[52]===h?G=t[53]:(G=e=>{Wh(e.nativeEvent,`Control+N`)&&(e.preventDefault(),h(`create`))},t[52]=h,t[53]=G);let ee;t[54]!==f||t[55]!==p||t[56]!==u?(ee=(0,Q.jsx)(kp,{autoFocus:u,value:f,onValueChange:p,placeholder:`Search branches`,className:`text-base md:text-sm`}),t[54]=f,t[55]=p,t[56]=u,t[57]=ee):ee=t[57];let te=w.isPending?`Loading branches…`:`No branches found.`,K;t[58]===te?K=t[59]:(K=(0,Q.jsx)(jp,{children:te}),t[58]=te,t[59]=K);let ne;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(ne=[`new`,`create`,`branch`],t[60]=ne):ne=t[60];let q;t[61]===h?q=t[62]:(q=()=>{h(`create`)},t[61]=h,t[62]=q);let J,Y;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,Q.jsx)(Ua,{className:`size-4 text-muted-foreground`}),Y=(0,Q.jsx)(`span`,{className:`font-medium`,children:`Create new branch…`}),t[63]=J,t[64]=Y):(J=t[63],Y=t[64]);let ie;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,Q.jsx)(Pp,{children:Uh(`Control+N`)}),t[65]=ie):ie=t[65];let ae;t[66]===q?ae=t[67]:(ae=(0,Q.jsx)(Mp,{heading:`Actions`,children:(0,Q.jsxs)(Np,{value:`action:create`,keywords:ne,onSelect:q,children:[J,Y,ie]})}),t[66]=q,t[67]=ae);let oe=`Local branches · ${E.length}`,se;t[68]!==w.isPending||t[69]!==E.length?(se=w.isPending&&E.length===0?(0,Q.jsxs)(Np,{value:`loading:branches`,disabled:!0,children:[(0,Q.jsx)(H,{className:`size-3.5 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Loading branches…`})]}):null,t[68]=w.isPending,t[69]=E.length,t[70]=se):se=t[70];let ce;if(t[71]!==L.isPending||t[72]!==E||t[73]!==z){let e;t[75]!==L.isPending||t[76]!==z?(e=e=>{let t=k_(e),n=e.current?`current`:j_(e.relativeDate),r=[e.name,e.upstream,e.subject].filter(Boolean).join(` · `)||e.name;return(0,Q.jsxs)(Np,{value:`local:${e.name}`,keywords:[e.name,e.upstream??``,e.subject??``],disabled:L.isPending,onSelect:()=>z(e),className:`items-start py-2`,children:[(0,Q.jsx)(`span`,{className:`mt-0.5 flex size-4 shrink-0 items-center justify-center`,children:e.current?(0,Q.jsx)(ja,{className:`size-3.5 text-emerald-500`}):null}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,title:r,children:[(0,Q.jsx)(`div`,{className:`truncate font-mono text-[13px] font-medium`,children:e.name}),(0,Q.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:[e.upstream,e.subject].filter(Boolean).join(` · `)||`Local branch`})]}),(0,Q.jsx)(Pp,{className:rn(`shrink-0 tracking-normal normal-case`,t&&A_(e,t)),children:t||n})]},e.name)},t[75]=L.isPending,t[76]=z,t[77]=e):e=t[77],ce=E.map(e),t[71]=L.isPending,t[72]=E,t[73]=z,t[74]=ce}else ce=t[74];let le;t[78]!==oe||t[79]!==se||t[80]!==ce?(le=(0,Q.jsxs)(Mp,{heading:oe,children:[se,ce]}),t[78]=oe,t[79]=se,t[80]=ce,t[81]=le):le=t[81];let ue=`Remote branches · ${D.length}`,de;if(t[82]!==L.isPending||t[83]!==k||t[84]!==D||t[85]!==V){let e;t[87]!==L.isPending||t[88]!==k||t[89]!==V?(e=e=>{let t=N_(e.name),n=t.branch||e.name,r=k.has(n);return(0,Q.jsxs)(Np,{value:`remote:${e.name}`,keywords:[e.name,n,e.subject??``],disabled:L.isPending,onSelect:()=>V(e),className:`items-start py-2`,children:[(0,Q.jsx)(Ua,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,title:e.name,children:[(0,Q.jsxs)(`div`,{className:`truncate font-mono text-[13px] font-medium`,children:[t.remote?(0,Q.jsxs)(`span`,{className:`text-muted-foreground/70`,children:[t.remote,`/`]}):null,t.branch||e.name]}),(0,Q.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.subject||`Remote branch`})]}),(0,Q.jsx)(Pp,{className:`shrink-0 tracking-normal normal-case`,children:r?`Switch`:`Track`})]},e.name)},t[87]=L.isPending,t[88]=k,t[89]=V,t[90]=e):e=t[90],de=D.map(e),t[82]=L.isPending,t[83]=k,t[84]=D,t[85]=V,t[86]=de}else de=t[86];let fe;t[91]!==ue||t[92]!==de?(fe=(0,Q.jsx)(Mp,{heading:ue,children:de}),t[91]=ue,t[92]=de,t[93]=fe):fe=t[93];let pe;t[94]!==K||t[95]!==ae||t[96]!==le||t[97]!==fe?(pe=(0,Q.jsxs)(Ap,{className:`max-h-none min-h-0 flex-1 md:max-h-[min(70vh,28rem)]`,children:[K,ae,le,fe]}),t[94]=K,t[95]=ae,t[96]=le,t[97]=fe,t[98]=pe):pe=t[98];let me;t[99]===l?me=t[100]:(me=l?null:(0,Q.jsxs)(`div`,{className:`hidden flex-wrap items-center gap-x-3 gap-y-1 border-t border-border/70 px-3 py-2 text-xs text-muted-foreground md:flex`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(O7,{children:`Enter`}),` Switch`]}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(O7,{children:Uh(`Control+N`)}),` `,`New branch`]}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(O7,{children:`Esc`}),` Close`]})]}),t[99]=l,t[100]=me);let he;t[101]!==g||t[102]!==_||t[103]!==G||t[104]!==ee||t[105]!==pe||t[106]!==me?(he=(0,Q.jsxs)(Dp,{shouldFilter:!0,loop:!0,value:g,onValueChange:_,onKeyDown:G,className:`min-h-0 flex-1`,children:[ee,pe,me]}),t[101]=g,t[102]=_,t[103]=G,t[104]=ee,t[105]=pe,t[106]=me,t[107]=he):he=t[107];let ge=he,_e;t[108]===h?_e=t[109]:(_e=()=>h(`browse`),t[108]=h,t[109]=_e);let ve;t[110]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,Q.jsx)(gn,{}),t[110]=ve):ve=t[110];let ye;t[111]===_e?ye=t[112]:(ye=(0,Q.jsx)(ss,{type:`button`,variant:`ghost`,size:`icon`,onClick:_e,"aria-label":`Back to branches`,children:ve}),t[111]=_e,t[112]=ye);let be;t[113]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate text-sm font-medium`,children:`Create branch`}),(0,Q.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:`From the current HEAD`})]}),t[113]=be):be=t[113];let xe;t[114]===ye?xe=t[115]:(xe=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/70 px-3 py-2`,children:[ye,be]}),t[114]=ye,t[115]=xe);let Se;t[116]===y?Se=t[117]:(Se=e=>y(e.target.value),t[116]=y,t[117]=Se);let Ce;t[118]!==W||t[119]!==h?(Ce=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),h(`browse`);return}e.key!==`Enter`||e.nativeEvent.isComposing||(e.preventDefault(),e.stopPropagation(),W())},t[118]=W,t[119]=h,t[120]=Ce):Ce=t[120];let we;t[121]!==v||t[122]!==u||t[123]!==Se||t[124]!==Ce?(we=(0,Q.jsx)(xs,{autoFocus:u,value:v,onChange:Se,onKeyDown:Ce,placeholder:`branch-name`,className:`min-w-0 flex-1`}),t[121]=v,t[122]=u,t[123]=Se,t[124]=Ce,t[125]=we):we=t[125];let Te;t[126]!==L.isPending||t[127]!==v?(Te=!v.trim()||L.isPending,t[126]=L.isPending,t[127]=v,t[128]=Te):Te=t[128];let Ee;t[129]===L.isPending?Ee=t[130]:(Ee=L.isPending?(0,Q.jsx)(H,{}):null,t[129]=L.isPending,t[130]=Ee);let De;t[131]!==W||t[132]!==Te||t[133]!==Ee?(De=(0,Q.jsxs)(ss,{type:`button`,disabled:Te,onClick:W,children:[Ee,`Create`]}),t[131]=W,t[132]=Te,t[133]=Ee,t[134]=De):De=t[134];let Oe;t[135]!==we||t[136]!==De?(Oe=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-center gap-2 p-3`,children:[we,De]}),t[135]=we,t[136]=De,t[137]=Oe):Oe=t[137];let ke;t[138]===l?ke=t[139]:(ke=l?null:(0,Q.jsxs)(`div`,{className:`hidden flex-wrap items-center gap-x-3 gap-y-1 border-t border-border/70 px-3 py-2 text-xs text-muted-foreground md:flex`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(O7,{children:`Enter`}),` Create`]}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(O7,{children:`Esc`}),` Back`]})]}),t[138]=l,t[139]=ke);let Ae;t[140]!==xe||t[141]!==Oe||t[142]!==ke?(Ae=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[xe,Oe,ke]}),t[140]=xe,t[141]=Oe,t[142]=ke,t[143]=Ae):Ae=t[143];let je=m===`create`?Ae:ge;if(l){let e;t[144]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsxs)(Um,{children:[(0,Q.jsx)(Gm,{children:`Branches`}),(0,Q.jsx)(Km,{children:`Switch branches or create a new branch.`})]}),t[144]=e):e=t[144];let n;t[145]===je?n=t[146]:(n=(0,Q.jsxs)(Hm,{className:`max-h-[90svh] overflow-hidden`,children:[e,(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-4 pb-4`,children:je})]}),t[145]=je,t[146]=n);let r;return t[147]!==s||t[148]!==o||t[149]!==u||t[150]!==n?(r=(0,Q.jsx)(zm,{open:o,onOpenChange:s,autoFocus:u,children:n}),t[147]=s,t[148]=o,t[149]=u,t[150]=n,t[151]=r):r=t[151],r}let Me;return t[152]!==je||t[153]!==s||t[154]!==o?(Me=(0,Q.jsx)(Op,{open:o,onOpenChange:s,title:`Branches`,description:`Switch branches or create a new branch.`,className:`sm:max-w-2xl`,initialFocus:!0,children:je}),t[152]=je,t[153]=s,t[154]=o,t[155]=Me):Me=t[155],Me}function gre(e,t){Qe.error(c_(e,t.create?`Failed to create branch`:`Failed to switch branch`))}function _re(e){return e.current}function vre(e){return e.name}function yre(e){return!e.name.endsWith(`/HEAD`)}function bre(e){let t=(0,$.c)(20),{viewerContextId:n,cwd:r,active:i}=e,a=a_(r),o=!!(i&&n&&a),s=Or({...d_({viewerContextId:n,cwd:a}),enabled:o,notifyOnChangeProps:[`error`,`errorUpdatedAt`]}),c=Or({...f_({viewerContextId:n,cwd:a,scope:`files`}),enabled:o,notifyOnChangeProps:[`error`,`errorUpdatedAt`]}),l=Or({...f_({viewerContextId:n,cwd:a,scope:`branches`}),enabled:o,notifyOnChangeProps:[`error`,`errorUpdatedAt`]}),u=f_({viewerContextId:n,cwd:a,scope:`commits`}),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=[`error`,`errorUpdatedAt`],t[0]=d):d=t[0];let f;t[1]!==o||t[2]!==u?(f={...u,enabled:o,notifyOnChangeProps:d},t[1]=o,t[2]=u,t[3]=f):f=t[3];let p=Or(f),m;t[4]!==i||t[5]!==l.error||t[6]!==p.error||t[7]!==c.error||t[8]!==s.error?(m=()=>{if(!i)return;let e=c.error||l.error||p.error||s.error;e&&Qe.error(c_(e,`Failed to load git view`))},t[4]=i,t[5]=l.error,t[6]=p.error,t[7]=c.error,t[8]=s.error,t[9]=m):m=t[9];let h;return t[10]!==i||t[11]!==l.error||t[12]!==l.errorUpdatedAt||t[13]!==p.error||t[14]!==p.errorUpdatedAt||t[15]!==c.error||t[16]!==c.errorUpdatedAt||t[17]!==s.error||t[18]!==s.errorUpdatedAt?(h=[i,l.error,l.errorUpdatedAt,p.error,p.errorUpdatedAt,c.error,c.errorUpdatedAt,s.error,s.errorUpdatedAt],t[10]=i,t[11]=l.error,t[12]=l.errorUpdatedAt,t[13]=p.error,t[14]=p.errorUpdatedAt,t[15]=c.error,t[16]=c.errorUpdatedAt,t[17]=s.error,t[18]=s.errorUpdatedAt,t[19]=h):h=t[19],Z.useEffect(m,h),null}function xre(e){let t=(0,$.c)(29),{viewerContextId:n,cwd:r,active:i,onBranchClick:a}=e,o=a_(r),s=!!(i&&n&&o),c=Or({...d_({viewerContextId:n,cwd:o}),enabled:s,select:h_,notifyOnChangeProps:[`data`,`isPending`,`error`]});if(!o){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(h7,{children:`No directory selected.`}),t[0]=e):e=t[0],e}if(!n){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(h7,{children:`Waiting for viewer context…`}),t[1]=e):e=t[1],e}if(c.isPending&&c.data===void 0){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsxs)(h7,{children:[(0,Q.jsx)(H,{}),` Loading repository status…`]}),t[2]=e):e=t[2],e}if(c.error){let e;t[3]===c.error?e=t[4]:(e=c_(c.error,`Failed to load repository status`),t[3]=c.error,t[4]=e);let n;return t[5]===e?n=t[6]:(n=(0,Q.jsx)(h7,{tone:`destructive`,children:e}),t[5]=e,t[6]=n),n}let l=c.data;if(!l){let e;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(h7,{children:`No git repository detected.`}),t[7]=e):e=t[7],e}let u=l.detached?`Detached HEAD${l.revision?` (${l.revision})`:``}`:l.branch||l.label,d=s_(o),f=l.ahead===0&&l.behind===0,p=o_(o),m;t[8]!==l.title||t[9]!==p?(m=[p,l.title].filter(Boolean),t[8]=l.title,t[9]=p,t[10]=m):m=t[10];let h=m.join(` · `),g;t[11]===f?g=t[12]:(g=f?(0,Q.jsx)(ja,{className:`size-3 shrink-0 text-emerald-500`}):null,t[11]=f,t[12]=g);let _;t[13]===l.behind?_=t[14]:(_=l.behind>0?(0,Q.jsxs)(`span`,{className:`shrink-0 font-medium text-sky-500 tabular-nums`,children:[`↓`,l.behind]}):null,t[13]=l.behind,t[14]=_);let v;t[15]===l.ahead?v=t[16]:(v=l.ahead>0?(0,Q.jsxs)(`span`,{className:`shrink-0 font-medium text-amber-500 tabular-nums`,children:[`↑`,l.ahead]}):null,t[15]=l.ahead,t[16]=v);let y=d||`No cwd`,b;t[17]===y?b=t[18]:(b=(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:y}),t[17]=y,t[18]=b);let x;t[19]!==u||t[20]!==a?(x=u?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`→`}),a?(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Switch branch`,className:`-mx-1 inline-flex min-w-0 items-center gap-1 rounded-md px-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,onClick:a,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:u}),(0,Q.jsx)(Fa,{className:`size-3 shrink-0`})]}):(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:u})]}):null,t[19]=u,t[20]=a,t[21]=x):x=t[21];let S;return t[22]!==g||t[23]!==_||t[24]!==v||t[25]!==b||t[26]!==x||t[27]!==h?(S=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-xs leading-5`,title:h,children:[g,_,v,b,x]}),t[22]=g,t[23]=_,t[24]=v,t[25]=b,t[26]=x,t[27]=h,t[28]=S):S=t[28],S}function Sre(e){let t=(0,$.c)(50),{viewerContextId:n,cwd:r,active:i}=e,a=re(),o=a_(r),[s,c]=Z.useState(!1),[l,u]=Z.useState(!1),d=Or({...d_({viewerContextId:n,cwd:o}),enabled:!!(i&&n&&o),select:h_,notifyOnChangeProps:[`data`]}),f=Or({...f_({viewerContextId:n,cwd:o,scope:`files`}),enabled:!!(i&&n&&o),select:g_,notifyOnChangeProps:[`data`]}),p=kr({queryKey:_g.gitStatus(n,o),exact:!0}),m=kr({queryKey:_g.gitFiles(n,o),exact:!0}),h=kr({queryKey:_g.gitBranches(n,o),exact:!0}),g=kr({queryKey:_g.gitCommits(n,o),exact:!1}),_=p+m+h+g>0,v=d.data,y;t[0]===f.data?y=t[1]:(y=Array.isArray(f.data)?f.data:[],t[0]=f.data,t[1]=y);let b=y,x=!!v,S=!!(v?.dirty||b.length>0),C=!!(x&&!v?.detached&&(v?.ahead||0)>0),w;t[2]===v?w=t[3]:(w=b_(v),t[2]=v,t[3]=w);let T=w,E=!!(x&&!v?.detached&&(v?.behind||0)>0),D=Nr({mutationFn:async e=>await wh(Ch(e===`pull`?`/api/git-pull`:`/api/git-push`,{contextId:n}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({cwd:o,force:e===`force-push`})}),onSuccess:async(e,t)=>{await __({queryClient:a,viewerContextId:n,cwd:o}),t!==`pull`&&Fq({response:e,force:t===`force-push`})},onError:Cre}),O=Ar({mutationKey:_g.gitAction(n,o,`push`)}),k=Ar({mutationKey:_g.gitAction(n,o,`force-push`)}),A=_g.gitAction(n,o,`pull`),j;t[4]===A?j=t[5]:(j={mutationKey:A},t[4]=A,t[5]=j);let M=Ar(j),N=D.isPending&&D.variables===`push`||O>0,P=D.isPending&&D.variables===`force-push`||k>0,F=D.isPending&&D.variables===`pull`||M>0,I=D.isPending||N||P||F,L=!!(n&&o&&S),R=!!(n&&o&&C&&(!I||N)),z=!!(n&&o&&T&&(!I||P)),B=!!(n&&o&&E&&(!I||F)),V=L||R||z||B,U;t[6]===c?U=t[7]:(U=()=>{c(!0)},t[6]=c,t[7]=U);let W;t[8]!==i||t[9]!==o||t[10]!==U||t[11]!==n?(W=(0,Q.jsx)(xre,{viewerContextId:n,cwd:o,active:i,onBranchClick:U}),t[8]=i,t[9]=o,t[10]=U,t[11]=n,t[12]=W):W=t[12];let G;t[13]!==i||t[14]!==_?(G=i&&_?(0,Q.jsx)(H,{className:`size-3 shrink-0 text-muted-foreground`}):null,t[13]=i,t[14]=_,t[15]=G):G=t[15];let ee;t[16]!==W||t[17]!==G?(ee=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[W,G]}),t[16]=W,t[17]=G,t[18]=ee):ee=t[18];let te;t[19]!==P||t[20]!==I||t[21]!==D||t[22]!==F||t[23]!==N||t[24]!==u||t[25]!==V||t[26]!==L||t[27]!==z||t[28]!==B||t[29]!==R?(te=V?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[L?(0,Q.jsx)(Je,{title:`Commit`,kbd:Uh(`Control+C`),children:(0,Q.jsxs)(ss,{variant:`outline`,onClick:()=>{u(!0)},children:[(0,Q.jsx)(Ha,{}),` Commit…`]})}):null,R?(0,Q.jsx)(Je,{title:`Push`,kbd:Uh(`Control+P`),children:(0,Q.jsxs)(ss,{variant:`outline`,disabled:I,onClick:()=>{D.mutate(`push`)},children:[N?(0,Q.jsx)(H,{}):(0,Q.jsx)(to,{}),`Push`]})}):null,z?(0,Q.jsx)(Je,{title:`Force push`,kbd:Uh(`Control+Shift+P`),children:(0,Q.jsxs)(ss,{variant:`outline`,disabled:I,onClick:()=>{D.mutate(`force-push`)},children:[P?(0,Q.jsx)(H,{}):(0,Q.jsx)(to,{}),`Force Push`]})}):null,B?(0,Q.jsx)(Je,{title:`Pull`,kbd:Uh(`Alt+P`),children:(0,Q.jsxs)(ss,{variant:`outline`,disabled:I,onClick:()=>{D.mutate(`pull`)},children:[F?(0,Q.jsx)(H,{}):(0,Q.jsx)(La,{}),`Pull`]})}):null]}):null,t[19]=P,t[20]=I,t[21]=D,t[22]=F,t[23]=N,t[24]=u,t[25]=V,t[26]=L,t[27]=z,t[28]=B,t[29]=R,t[30]=te):te=t[30];let K;t[31]!==i||t[32]!==s||t[33]!==v||t[34]!==o||t[35]!==c||t[36]!==n?(K=(0,Q.jsx)(hre,{viewerContextId:n,cwd:o,active:i,gitStatus:v,open:s,onOpenChange:c}),t[31]=i,t[32]=s,t[33]=v,t[34]=o,t[35]=c,t[36]=n,t[37]=K):K=t[37];let ne;t[38]!==l||t[39]!==b||t[40]!==v||t[41]!==o||t[42]!==u||t[43]!==n?(ne=(0,Q.jsx)(U_,{viewerContextId:n,cwd:o,files:b,gitStatus:v,open:l,onOpenChange:u}),t[38]=l,t[39]=b,t[40]=v,t[41]=o,t[42]=u,t[43]=n,t[44]=ne):ne=t[44];let q;return t[45]!==K||t[46]!==ne||t[47]!==ee||t[48]!==te?(q=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[ee,te,K,ne]}),t[45]=K,t[46]=ne,t[47]=ee,t[48]=te,t[49]=q):q=t[49],q}function Cre(e,t){Qe.error(c_(e,t===`pull`?`Failed to pull changes`:t===`force-push`?`Failed to force push changes`:`Failed to push changes`))}var k7=Z.createContext(void 0);function wre(e=!0){let t=Z.useContext(k7);if(t===void 0&&!e)throw Error(b(7));return t}var Tre=Z.forwardRef(function(e,t){let{className:n,defaultPressed:r=!1,disabled:i=!1,form:a,onPressedChange:o,pressed:s,render:c,type:l,value:u,nativeButton:d=!0,style:f,...p}=e,m=It(u||void 0),h=wre(),g=h?.value??[],_=h?void 0:r,v=(i||h?.disabled)??!1,[y,b]=_s({controlled:h?m!==void 0&&g.indexOf(m)>-1:s,default:_,name:`Toggle`,state:`pressed`}),x=J((e,t)=>{m&&h?.setGroupValue?.(m,e,t),o?.(e,t)}),{getButtonProps:S,buttonRef:C}=ns({disabled:v,native:d}),w={disabled:v,pressed:y},T=[C,t],E=[{"aria-pressed":y,onClick(e){let t=!y,n=Ye(Wt,e.nativeEvent);x(t,n),!n.isCanceled&&b(t)}},p,S],D=at(`button`,e,{enabled:!h,state:w,ref:T,props:E});return h?(0,Q.jsx)(Oy,{tag:`button`,render:c,className:n,style:f,state:w,refs:T,props:E}):D}),Ere=function(e){return e.disabled=`data-disabled`,e.orientation=`data-orientation`,e.multiple=`data-multiple`,e}({}),A7={multiple(e){return e?{[Ere.multiple]:``}:null}},Dre=Z.forwardRef(function(e,t){let{defaultValue:n,disabled:r=!1,loopFocus:i=!0,onValueChange:a,orientation:o=`horizontal`,multiple:s=!1,value:c,className:l,render:u,style:d,...f}=e,p=ly(!0),m=Z.useMemo(()=>{if(c===void 0)return n??[]},[c,n]),h=Z.useMemo(()=>c!==void 0||n!==void 0,[c,n]),g=(p?.disabled??!1)||r,[_,v]=_s({controlled:c,default:m,name:`ToggleGroup`,state:`value`}),y=J((e,t,n)=>{let r;if(s?(r=_.slice(),t?r.push(e):r.splice(_.indexOf(e),1)):r=t?[e]:[],Array.isArray(r)){if(a?.(r,n),n.isCanceled)return;v(r)}}),b={disabled:g,multiple:s,orientation:o},x=Z.useMemo(()=>({disabled:g,orientation:o,setGroupValue:y,value:_,isValueInitialized:h}),[g,o,y,_,h]),S={role:`group`},C=at(`div`,e,{enabled:!!p,state:b,ref:t,props:[S,f],stateAttributesMapping:A7});return(0,Q.jsx)(k7.Provider,{value:x,children:p?C:(0,Q.jsx)(Kv,{render:u,className:l,style:d,state:b,refs:[t],props:[S,f],stateAttributesMapping:A7,loopFocus:i,enableHomeAndEndKeys:!0,orientation:o})})}),Ore=Oo(`group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-transparent`,outline:`border border-input bg-transparent hover:bg-muted`},size:{default:`h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,sm:`h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`}},defaultVariants:{variant:`default`,size:`default`}}),j7=Z.createContext({size:`default`,variant:`default`,spacing:0,orientation:`horizontal`});function kre(e){let t=(0,$.c)(29),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({className:r,variant:c,size:a,spacing:o,orientation:s,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=o===void 0?0:o,u=s===void 0?`horizontal`:s,d;t[8]===l?d=t[9]:(d={"--gap":l},t[8]=l,t[9]=d);let f=d,p;t[10]===r?p=t[11]:(p=rn(`group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-vertical:flex-col data-vertical:items-stretch`,r),t[10]=r,t[11]=p);let m;t[12]!==u||t[13]!==a||t[14]!==l||t[15]!==c?(m={variant:c,size:a,spacing:l,orientation:u},t[12]=u,t[13]=a,t[14]=l,t[15]=c,t[16]=m):m=t[16];let h;t[17]!==n||t[18]!==m?(h=(0,Q.jsx)(j7.Provider,{value:m,children:n}),t[17]=n,t[18]=m,t[19]=h):h=t[19];let g;return t[20]!==u||t[21]!==i||t[22]!==a||t[23]!==l||t[24]!==f||t[25]!==p||t[26]!==h||t[27]!==c?(g=(0,Q.jsx)(Dre,{"data-slot":`toggle-group`,"data-variant":c,"data-size":a,"data-spacing":l,"data-orientation":u,style:f,className:p,...i,children:h}),t[20]=u,t[21]=i,t[22]=a,t[23]=l,t[24]=f,t[25]=p,t[26]=h,t[27]=c,t[28]=g):g=t[28],g}function Are(e){let t=(0,$.c)(19),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,children:n,variant:a,size:o,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=a===void 0?`default`:a,c=o===void 0?`default`:o,l=Z.useContext(j7),u=l.variant||s,d=l.size||c,f=l.spacing,p;t[6]!==r||t[7]!==l.size||t[8]!==l.variant||t[9]!==c||t[10]!==s?(p=rn(`shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t`,Ore({variant:l.variant||s,size:l.size||c}),r),t[6]=r,t[7]=l.size,t[8]=l.variant,t[9]=c,t[10]=s,t[11]=p):p=t[11];let m;return t[12]!==n||t[13]!==l.spacing||t[14]!==i||t[15]!==u||t[16]!==d||t[17]!==p?(m=(0,Q.jsx)(Tre,{"data-slot":`toggle-group-item`,"data-variant":u,"data-size":d,"data-spacing":f,className:p,...i,children:n}),t[12]=n,t[13]=l.spacing,t[14]=i,t[15]=u,t[16]=d,t[17]=p,t[18]=m):m=t[18],m}function jre(e){let t=(0,$.c)(23),{title:n,meta:r,controls:i,className:a,bodyClassName:o,children:s}=e,c;t[0]===a?c=t[1]:(c=rn(`overflow-hidden rounded-xl border border-border/80 bg-card/50`,a),t[0]=a,t[1]=c);let l;t[2]===n?l=t[3]:(l=(0,Q.jsx)(`div`,{className:`text-xs font-bold tracking-[0.04em] text-muted-foreground uppercase`,children:n}),t[2]=n,t[3]=l);let u;t[4]===r?u=t[5]:(u=r?(0,Q.jsx)(`div`,{className:`min-w-0 truncate text-xs text-muted-foreground/80`,children:r}):null,t[4]=r,t[5]=u);let d;t[6]!==l||t[7]!==u?(d=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-3`,children:[l,u]}),t[6]=l,t[7]=u,t[8]=d):d=t[8];let f;t[9]===i?f=t[10]:(f=i?(0,Q.jsx)(`div`,{className:`shrink-0`,children:i}):null,t[9]=i,t[10]=f);let p;t[11]!==d||t[12]!==f?(p=(0,Q.jsxs)(`div`,{className:`flex min-h-10 items-center justify-between gap-3 border-b border-border/70 bg-background px-3 py-2`,children:[d,f]}),t[11]=d,t[12]=f,t[13]=p):p=t[13];let m;t[14]===o?m=t[15]:(m=rn(`grid gap-2 px-3 py-2.5`,o),t[14]=o,t[15]=m);let h;t[16]!==s||t[17]!==m?(h=(0,Q.jsx)(`div`,{className:m,children:s}),t[16]=s,t[17]=m,t[18]=h):h=t[18];let g;return t[19]!==c||t[20]!==p||t[21]!==h?(g=(0,Q.jsxs)(`section`,{className:c,children:[p,h]}),t[19]=c,t[20]=p,t[21]=h,t[22]=g):g=t[22],g}var M7=[`#0ea5e9`,`#db2777`,`#22c55e`,`#f59e0b`,`#8b5cf6`,`#14b8a6`],N7=-1,P7=20,Mre=150,F7=14,I7=12;function L7(e,t=!1){return t?`#f87171`:M7[e%M7.length]}var Nre=class{colour;lines=[];constructor(e){this.colour=e}addLine(e,t){this.lines.push({p1:e,p2:t})}getColour(){return this.colour}getLines(){return this.lines}},R7=class{id;connections=[];nextParent=0;nextX=0;onBranch=null;parents=[];x=0;constructor(e){this.id=e}addParent(e){this.parents.push(e)}getNextParent(){return this.parents[this.nextParent]??null}registerParentProcessed(){this.nextParent+=1}isMerge(){return this.parents.length>1}addToBranch(e,t){this.onBranch===null&&(this.onBranch=e,this.x=t)}isNotOnBranch(){return this.onBranch===null}getBranch(){return this.onBranch}getPoint(){return{x:this.x,y:this.id}}getNextPoint(){return{x:this.nextX,y:this.id}}getPointConnectingTo(e,t){for(let n=0;n<this.connections.length;n++){let r=this.connections[n];if(r?.connectsTo===e&&r.onBranch===t)return{x:n,y:this.id}}return null}registerUnavailablePoint(e,t,n){e===this.nextX&&(this.nextX=e+1,this.connections[e]={connectsTo:t,onBranch:n})}};function z7(e){let t=e.map(e=>I_(e)),n=new Map;t.forEach((e,t)=>{e.fullHash&&n.set(e.fullHash,t)});let r=new R7(N7),i=t.map((e,t)=>new R7(t)),a=[],o=[];t.forEach((e,t)=>{if(!e.fullHash)return;let a=i[t];e.parents.forEach(e=>{let t=n.get(e);if(typeof t==`number`){let e=i[t];a.addParent(e)}else a.addParent(r)})});let s=e=>{for(let t=0;t<o.length;t++)if(e>(o[t]??0))return t;return o.push(0),o.length-1},c=e=>{let t=e,n=i[t],r=n.getNextParent(),c=n.isNotOnBranch()?n.getNextPoint():n.getPoint();if(r!==null&&r.id!==N7&&n.isMerge()&&!n.isNotOnBranch()&&!r.isNotOnBranch()){let a=r.getBranch(),o=!1;for(t=e+1;t<i.length;t++){let e=i[t],s=e.getPointConnectingTo(r,a),l=s??e.getNextPoint();if(a.addLine(c,l),e.registerUnavailablePoint(l.x,r,a),c=l,s!==null){n.registerParentProcessed(),o=!0;break}}o||n.registerParentProcessed();return}let l=new Nre(s(e));for(n.addToBranch(l,c.x),n.registerUnavailablePoint(c.x,n,l),t=e+1;t<i.length;t++){let e=i[t],a=r===e&&!r.isNotOnBranch()?e.getPoint():e.getNextPoint();if(l.addLine(c,a),e.registerUnavailablePoint(a.x,r,l),c=a,r===e){n.registerParentProcessed();let e=!r.isNotOnBranch();if(r.addToBranch(l,a.x),n=r,r=n.getNextParent(),r===null||e)break}}t===i.length&&r!==null&&r.id===N7&&n.registerParentProcessed(),a.push(l),o[l.getColour()]=t},l=0;for(;l<i.length;){let e=i[l];t[l].fullHash&&(e.getNextParent()!==null||e.isNotOnBranch())?c(l):l+=1}let u=t.map((e,t)=>{let n=i[t]?.getBranch()??null;return{colour:n?.getColour()??0,commitLane:e.fullHash&&n?i[t].getPoint().x:-1,parsed:e}});return{branches:a,maxLaneCount:Math.max(1,...i.map(e=>e.getNextPoint().x)),rows:u}}function B7(e,t){return e.parsed.fullHash||`commit-row:${t}`}function V7(e,t){let n=new Set(t);return e.map((e,t)=>n.has(B7(e,t))?P7+Mre:P7)}function Pre(e){let t=0;return e.map(e=>{let n=t;return t+=e,n})}function Fre(e){return e.reduce((e,t)=>e+t,0)}function H7(e,t){return(e[t]??t*P7)+P7/2}function Ire({line:e,rowTops:t}){let n=e.p1.x*F7+I7,r=H7(t,e.p1.y),i=e.p2.x*F7+I7,a=H7(t,e.p2.y);if(n===i)return`M ${n} ${r} L ${i} ${a}`;let o=P7*.8;return`M ${n} ${r} C ${n} ${r+o}, ${i} ${a-o}, ${i} ${a}`}function Lre(e){let t=(0,$.c)(15),{lines:n,openCommitValues:r,unpushedCommitShortHashes:i}=e,a,o,s,c;if(t[0]!==n||t[1]!==r||t[2]!==i){let{branches:e,maxLaneCount:l,rows:u}=z7(n),d=V7(u,r),f=Pre(d);c=Math.max(24,l*F7+4),o=Math.max(P7,Fre(d)),s=[],a=[],e.forEach((e,t)=>{e.getLines().forEach((n,r)=>{s.push((0,Q.jsx)(`path`,{d:Ire({line:n,rowTops:f}),fill:`none`,stroke:L7(e.getColour()),strokeLinecap:`round`,strokeWidth:`2`},`path:${t}:${r}`))})}),u.forEach((e,t)=>{if(e.commitLane<0)return;let n=e.commitLane*F7+I7,r=H7(f,t),o=!!(e.parsed.hash&&i.has(e.parsed.hash));a.push((0,Q.jsx)(`circle`,{cx:n,cy:r,r:`4`,fill:L7(e.colour,o)},`circle:${t}:${e.parsed.fullHash}`))}),t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c}else a=t[3],o=t[4],s=t[5],c=t[6];let l=`0 0 ${c} ${o}`,u;t[7]!==o||t[8]!==c?(u={width:c,height:o},t[7]=o,t[8]=c,t[9]=u):u=t[9];let d;return t[10]!==a||t[11]!==s||t[12]!==l||t[13]!==u?(d=(0,Q.jsxs)(`svg`,{"aria-hidden":!0,viewBox:l,className:`pointer-events-none absolute top-0 left-0 z-10 overflow-visible`,style:u,children:[s,a]}),t[10]=a,t[11]=s,t[12]=l,t[13]=u,t[14]=d):d=t[14],d}function Rre(e){let t=(0,$.c)(66),{graphWidth:n,line:r,value:i}=e,a=I_(r),[o,s]=Z.useState(!1),c=Z.useRef(void 0),l=a.subject.trim(),u=L_(a.relativeDate),d=R_(a.fullDate),f=z_(a.stats,`insertions`),p=z_(a.stats,`deletions`),m=a.hash||a.fullHash.slice(0,7),h,g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>()=>{typeof c.current==`number`&&window.clearTimeout(c.current)},g=[],t[0]=h,t[1]=g):(h=t[0],g=t[1]),Z.useEffect(h,g);let _;t[2]!==a.fullHash||t[3]!==s?(_=()=>{a.fullHash&&V_(a.fullHash).then(e=>{e&&(s(!0),typeof c.current==`number`&&window.clearTimeout(c.current),c.current=window.setTimeout(()=>{s(!1)},1200))})},t[2]=a.fullHash,t[3]=s,t[4]=_):_=t[4];let v=_;if(!a.hash&&!a.subject){let e;t[5]===a.subject?e=t[6]:(e=a.subject?(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:a.subject}):null,t[5]=a.subject,t[6]=e);let n;return t[7]===e?n=t[8]:(n=(0,Q.jsx)(`div`,{className:`flex h-5 max-w-full min-w-0 items-center font-mono text-[13px] leading-5`,children:e}),t[7]=e,t[8]=n),n}let y;t[9]===n?y=t[10]:(y={paddingLeft:n},t[9]=n,t[10]=y);let b=l||a.hash||`Commit`,x;t[11]!==y||t[12]!==b?(x=(0,Q.jsx)(Sb,{headerClassName:`min-w-0`,className:`h-5 min-h-5 w-full items-center gap-2 rounded-none px-1.5 py-0 font-mono text-[13px] leading-5 font-normal transition-colors hover:bg-muted/50 hover:text-foreground hover:no-underline focus-visible:ring-0 aria-expanded:bg-muted aria-expanded:text-foreground **:data-[slot=accordion-trigger-icon]:size-4`,children:(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,style:y,children:b})}),t[11]=y,t[12]=b,t[13]=x):x=t[13];let S=x,C;t[14]===S?C=t[15]:(C=(0,Q.jsx)(f7,{render:S}),t[14]=S,t[15]=C);let w=!a.fullHash,T;t[16]===a.fullHash?T=t[17]:(T=()=>{V_(a.fullHash)},t[16]=a.fullHash,t[17]=T);let E;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Q.jsx)(Ia,{}),t[18]=E):E=t[18];let D;t[19]!==w||t[20]!==T?(D=(0,Q.jsxs)(m7,{disabled:w,onClick:T,children:[E,`Copy commit hash`]}),t[19]=w,t[20]=T,t[21]=D):D=t[21];let O=!a.subject,k;t[22]===a.subject?k=t[23]:(k=()=>{V_(a.subject)},t[22]=a.subject,t[23]=k);let A;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Q.jsx)(Ia,{}),t[24]=A):A=t[24];let j;t[25]!==O||t[26]!==k?(j=(0,Q.jsxs)(m7,{disabled:O,onClick:k,children:[A,`Copy commit message`]}),t[25]=O,t[26]=k,t[27]=j):j=t[27];let M;t[28]!==D||t[29]!==j?(M=(0,Q.jsxs)(p7,{className:`w-52`,children:[D,j]}),t[28]=D,t[29]=j,t[30]=M):M=t[30];let N;t[31]!==M||t[32]!==C?(N=(0,Q.jsxs)(d7,{children:[C,M]}),t[31]=M,t[32]=C,t[33]=N):N=t[33];let P;t[34]===n?P=t[35]:(P={paddingLeft:n},t[34]=n,t[35]=P);let F;t[36]!==d||t[37]!==a.author||t[38]!==u?(F=a.author||u?(0,Q.jsxs)(`div`,{className:`flex max-w-full flex-wrap items-center gap-x-2 gap-y-1 text-muted-foreground`,children:[a.author?(0,Q.jsx)(`span`,{children:a.author}):null,a.author&&u?(0,Q.jsx)(`span`,{"aria-hidden":!0,children:`·`}):null,u?(0,Q.jsx)(Je,{title:d,side:`top`,children:(0,Q.jsx)(`span`,{children:u})}):null]}):null,t[36]=d,t[37]=a.author,t[38]=u,t[39]=F):F=t[39];let I=l||`No commit message`,L;t[40]===I?L=t[41]:(L=(0,Q.jsx)(`div`,{className:`max-w-full break-words whitespace-normal text-foreground`,children:I}),t[40]=I,t[41]=L);let R=f===1?``:`s`,z;t[42]!==f||t[43]!==R?(z=(0,Q.jsxs)(`span`,{className:`text-emerald-500`,children:[`+`,f,` addition`,R]}),t[42]=f,t[43]=R,t[44]=z):z=t[44];let B=p===1?``:`s`,V;t[45]!==p||t[46]!==B?(V=(0,Q.jsxs)(`span`,{className:`text-red-400`,children:[`-`,p,` deletion`,B]}),t[45]=p,t[46]=B,t[47]=V):V=t[47];let H;t[48]!==z||t[49]!==V?(H=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1`,children:[z,V]}),t[48]=z,t[49]=V,t[50]=H):H=t[50];let U;t[51]!==v||t[52]!==o||t[53]!==a.fullHash||t[54]!==m?(U=a.fullHash?(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:m}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Copy full commit hash`,className:`inline-flex size-5 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,onClick:e=>{e.preventDefault(),e.stopPropagation(),v()},children:o?(0,Q.jsx)(ja,{className:`size-3.5 text-emerald-500`}):(0,Q.jsx)(Ia,{className:`size-3.5`})})]}):null,t[51]=v,t[52]=o,t[53]=a.fullHash,t[54]=m,t[55]=U):U=t[55];let W;t[56]!==P||t[57]!==F||t[58]!==L||t[59]!==H||t[60]!==U?(W=(0,Q.jsx)(Cb,{className:`h-[150px] overflow-y-auto border-b border-border/70 bg-muted/20 pr-2 pb-2`,children:(0,Q.jsxs)(`div`,{className:`grid content-start gap-1.5 pt-1 font-mono text-xs leading-4`,style:P,children:[F,L,H,U]})}),t[56]=P,t[57]=F,t[58]=L,t[59]=H,t[60]=U,t[61]=W):W=t[61];let G;return t[62]!==N||t[63]!==W||t[64]!==i?(G=(0,Q.jsxs)(xb,{value:i,className:`border-0`,children:[N,W]}),t[62]=N,t[63]=W,t[64]=i,t[65]=G):G=t[65],G}function zre(e){let t=(0,$.c)(23),{lines:n,unpushedCommitShortHashes:r}=e,{maxLaneCount:i,rows:a}=z7(n),o=Math.max(24,i*F7+4),s=a.map(Bre),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[0]=c):c=t[0];let[l,u]=Z.useState(c),d=l.filter(e=>s.includes(e)),f=V7(a,d),p;t[1]!==n||t[2]!==r||t[3]!==d?(p=(0,Q.jsx)(Lre,{lines:n,openCommitValues:d,unpushedCommitShortHashes:r}),t[1]=n,t[2]=r,t[3]=d,t[4]=p):p=t[4];let m;t[5]===u?m=t[6]:(m=e=>{u(e.slice(-1))},t[5]=u,t[6]=m);let h;if(t[7]!==o||t[8]!==n||t[9]!==f||t[10]!==s){let e;t[12]!==o||t[13]!==f||t[14]!==s?(e=(e,t)=>(0,Q.jsx)(`div`,{className:`min-w-0`,style:{minHeight:f[t]??P7},children:(0,Q.jsx)(Rre,{graphWidth:o,line:e,value:s[t]??`${t}`})},`${t}:${e}`),t[12]=o,t[13]=f,t[14]=s,t[15]=e):e=t[15],h=n.map(e),t[7]=o,t[8]=n,t[9]=f,t[10]=s,t[11]=h}else h=t[11];let g;t[16]!==m||t[17]!==h||t[18]!==d?(g=(0,Q.jsx)(bb,{multiple:!0,value:d,onValueChange:m,className:`grid min-w-0 gap-0`,children:h}),t[16]=m,t[17]=h,t[18]=d,t[19]=g):g=t[19];let _;return t[20]!==p||t[21]!==g?(_=(0,Q.jsxs)(`div`,{className:`relative min-w-0`,children:[p,g]}),t[20]=p,t[21]=g,t[22]=_):_=t[22],_}function Bre(e,t){return B7(e,t)}function Vre(e){let t=(0,$.c)(50),{viewerContextId:n,cwd:r,active:i,embedded:a,flush:o}=e,s=a===void 0?!1:a,c=o===void 0?!1:o,l=a_(r),[u,d]=Z.useState(50),f=Z.useRef(null),p;t[0]===d?p=t[1]:(p=()=>{d(50)},t[0]=d,t[1]=p),Z.useEffect(p,[l]);let m=_g.gitCommits(n,l),h=f_({viewerContextId:n,cwd:l,scope:`commits`,commitsLimit:u}),g=!!(i&&n&&l),_;t[2]===m?_=t[3]:(_=(e,t)=>{let n=t?.queryKey;return m.every((e,t)=>n?.[t]===e)?e:void 0},t[2]=m,t[3]=_);let v;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(v=[`data`,`isFetching`,`isPending`,`error`],t[4]=v):v=t[4];let y;t[5]!==h||t[6]!==g||t[7]!==_?(y={...h,enabled:g,placeholderData:_,notifyOnChangeProps:v},t[5]=h,t[6]=g,t[7]=_,t[8]=y):y=t[8];let b=Or(y),x=b.data,S=x?.commits,C=!!x?.commitsHasMore,w;t[9]===S?w=t[10]:(w=Array.isArray(S)?F_(S):``,t[9]=S,t[10]=w);let T=w,E;t[11]===x?.unpushedCommitShortHashes?E=t[12]:(E=x?.unpushedCommitShortHashes??[],t[11]=x?.unpushedCommitShortHashes,t[12]=E);let D;t[13]===E?D=t[14]:(D=new Set(E),t[13]=E,t[14]=D);let O=D,k;t[15]!==i||t[16]!==C||t[17]!==b.isFetching||t[18]!==d?(k=()=>{let e=f.current;if(!e||!i||!C||b.isFetching||typeof IntersectionObserver>`u`)return;let t=!1,n=new IntersectionObserver(e=>{let[n]=e;!n?.isIntersecting||t||(t=!0,d(Ure))},{rootMargin:`320px 0px`});return n.observe(e),()=>n.disconnect()},t[15]=i,t[16]=C,t[17]=b.isFetching,t[18]=d,t[19]=k):k=t[19];let A;t[20]!==i||t[21]!==C||t[22]!==b.isFetching||t[23]!==l?(A=[i,C,b.isFetching,l],t[20]=i,t[21]=C,t[22]=b.isFetching,t[23]=l,t[24]=A):A=t[24],Z.useEffect(k,A);let j;t[25]!==S||t[26]!==C||t[27]!==b.error||t[28]!==b.isFetching||t[29]!==b.isPending||t[30]!==l||t[31]!==d||t[32]!==O||t[33]!==n?(j=l?n?b.isPending&&S===void 0||b.isFetching&&S===null?(0,Q.jsxs)(h7,{className:`px-3 py-2.5`,children:[(0,Q.jsx)(H,{}),` Loading commits…`]}):b.error?(0,Q.jsx)(h7,{tone:`destructive`,className:`px-3 py-2.5`,children:c_(b.error,`Failed to load commits`)}):S===null?(0,Q.jsx)(h7,{className:`px-3 py-2.5`,children:`No git repository detected.`}):Array.isArray(S)&&S.length>0?(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-3`,children:[(0,Q.jsx)(zre,{lines:S,unpushedCommitShortHashes:O}),C?(0,Q.jsx)(`div`,{ref:f,className:`flex`,children:(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex h-8 w-fit items-center justify-center rounded-md border border-border/80 bg-background px-3 text-xs font-semibold text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-60`,disabled:b.isFetching,onClick:()=>{d(Hre)},children:b.isFetching?`Loading more…`:`Load more`})}):null]}):(0,Q.jsx)(h7,{className:`px-3 py-2.5`,children:`No commits on this branch yet.`}):(0,Q.jsx)(h7,{className:`px-3 py-2.5`,children:`Waiting for viewer context…`}):(0,Q.jsx)(h7,{className:`px-3 py-2.5`,children:`No directory selected.`}),t[25]=S,t[26]=C,t[27]=b.error,t[28]=b.isFetching,t[29]=b.isPending,t[30]=l,t[31]=d,t[32]=O,t[33]=n,t[34]=j):j=t[34];let M=j;if(s){let e;return t[35]===M?e=t[36]:(e=(0,Q.jsx)(`div`,{className:`grid min-w-0 gap-2 overflow-x-hidden`,children:M}),t[35]=M,t[36]=e),e}if(c){let e;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(`div`,{className:`text-xs font-bold tracking-[0.04em] text-muted-foreground uppercase`,children:`History`}),t[37]=e):e=t[37];let n;t[38]===T?n=t[39]:(n=T?(0,Q.jsx)(`div`,{className:`min-w-0 truncate text-xs text-muted-foreground/80`,children:T}):null,t[38]=T,t[39]=n);let r;t[40]===n?r=t[41]:(r=(0,Q.jsx)(`div`,{className:`flex min-h-10 items-center justify-between gap-3 border-b border-border/70 bg-background px-3 py-2`,children:(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-3`,children:[e,n]})}),t[40]=n,t[41]=r);let i;t[42]===M?i=t[43]:(i=(0,Q.jsx)(`div`,{className:`grid min-h-0 min-w-0 flex-1 gap-2 overflow-x-hidden overflow-y-auto`,children:M}),t[42]=M,t[43]=i);let a;return t[44]!==r||t[45]!==i?(a=(0,Q.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-background`,children:[r,i]}),t[44]=r,t[45]=i,t[46]=a):a=t[46],a}let N;return t[47]!==M||t[48]!==T?(N=(0,Q.jsx)(jre,{title:`Commits`,meta:T,className:`overflow-x-hidden`,bodyClassName:`min-w-0 overflow-x-hidden p-0`,children:M}),t[47]=M,t[48]=T,t[49]=N):N=t[49],N}function Hre(e){return e+50}function Ure(e){return e+50}function U7(e,t){e(e=>Object.is(e,t)?e:t)}function Wre(e){return!!(e&&e.scrollTop>0)}function Gre({getValue:e,scrollElement:t,selector:n}){if(!t||t.scrollTop<=0)return``;let r=t.getBoundingClientRect().top,i=Array.from(t.querySelectorAll(n));for(let t of i){let n=t.getBoundingClientRect();if(n.top<=r+1&&n.bottom>r+1)return e(t)}return``}function Kre(e){let t=(0,$.c)(2),{status:n}=e,r;if(t[0]!==n){let[e,i]=S_(n);r=(0,Q.jsx)(`span`,{className:`inline-flex w-[2ch] shrink-0 items-center whitespace-pre text-muted-foreground/70`,children:[[`index`,e],[`worktree`,i]].map(e=>{let[t,r]=e,i=C_({character:r,column:t,status:n}),a=(0,Q.jsx)(`span`,{"aria-label":i||void 0,className:rn(`w-[1ch] text-center whitespace-pre`,i&&`cursor-help`,T_(w_(t,r))),children:r},t);return i?(0,Q.jsx)(Je,{title:i,side:`top`,children:a},t):a})}),t[0]=n,t[1]=r}else r=t[1];return r}function qre(e){let t=(0,$.c)(8),{file:n}=e;if(!D_(n)){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(`span`,{className:`min-w-0`}),t[0]=e):e=t[0],e}let r=E_(n.linesAdded),i=E_(n.linesDeleted),a;t[1]===r?a=t[2]:(a=r>0?(0,Q.jsxs)(`span`,{className:`text-emerald-500`,children:[`+`,r]}):null,t[1]=r,t[2]=a);let o;t[3]===i?o=t[4]:(o=i>0?(0,Q.jsxs)(`span`,{className:`text-red-500`,children:[`-`,i]}):null,t[3]=i,t[4]=o);let s;return t[5]!==a||t[6]!==o?(s=(0,Q.jsxs)(`span`,{className:`inline-flex min-w-0 gap-2 justify-self-end whitespace-nowrap tabular-nums`,children:[a,o]}),t[5]=a,t[6]=o,t[7]=s):s=t[7],s}var W7=160,Jre=1600;function G7(e){if(Number.isFinite(e))return Math.round(Math.min(Jre,Math.max(W7,e)))}function K7(){let e=A(pt);if(e!=null)return G7(Number(e))}function Yre(e){let t=G7(e);typeof t==`number`&&ee(pt,String(t))}function q7(e){return`${e.status}:${e.previousPath||``}:${e.path}`}function Xre(e){return E_(e.linesAdded)+E_(e.linesDeleted)}function Zre(e){return typeof e.sizeBytes==`number`&&e.sizeBytes>1e4||Xre(e)>100}function Qre(e){let t=(0,$.c)(114),{viewerContextId:n,cwd:r,active:i,onOpenFile:a}=e,o=a_(r),s=Ao(),[c,l]=Z.useState(`unified`),[u,d]=Z.useState(!0),[f,p]=Z.useState(nie),[m,h]=Z.useState(void 0),[g,_]=Z.useState(`row-resize`),v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=[],t[0]=v):v=t[0];let[y,b]=Z.useState(v),[x,S]=Z.useState(``),[C,w]=Z.useState(!1),T=Z.useRef(null),E=Z.useRef(null),D=Z.useRef(null),O=Z.useRef(null),k=Z.useRef(o),A=f_({viewerContextId:n,cwd:o,scope:`files`}),j=!!(i&&n&&o),M;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(M=[`data`,`isPending`,`error`],t[1]=M):M=t[1];let N;t[2]!==A||t[3]!==j?(N={...A,enabled:j,select:g_,notifyOnChangeProps:M},t[2]=A,t[3]=j,t[4]=N):N=t[4];let P=Or(N),F=P.data,I;t[5]===F?I=t[6]:(I=Array.isArray(F)?F:[],t[5]=F,t[6]=I);let L=I,R;t[7]!==o||t[8]!==k||t[9]!==h||t[10]!==w||t[11]!==d||t[12]!==p||t[13]!==b||t[14]!==S?(R=()=>{k.current!==o&&(k.current=o,d(!0),p(K7()),h(void 0),b([]),S(``),w(!1))},t[7]=o,t[8]=k,t[9]=h,t[10]=w,t[11]=d,t[12]=p,t[13]=b,t[14]=S,t[15]=R):R=t[15];let z;t[16]===o?z=t[17]:(z=[o],t[16]=o,t[17]=z),Z.useEffect(R,z);let B;t[18]===_?B=t[19]:(B=()=>{_(Bo())},t[18]=_,t[19]=B);let V;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(V=[],t[20]=V):V=t[20],Z.useEffect(B,V);let U;t[21]===S?U=t[22]:(U=e=>{U7(S,Gre({getValue:tie,scrollElement:e,selector:`[data-review-file-trigger]`}))},t[21]=S,t[22]=U);let W=U,G;t[23]===w?G=t[24]:(G=e=>{U7(w,Wre(e))},t[23]=w,t[24]=G);let ee=G,te;t[25]===W?te=t[26]:(te=()=>{W(T.current)},t[25]=W,t[26]=te);let K;t[27]===y?K=t[28]:(K=[y],t[27]=y,t[28]=K),Z.useEffect(te,K);let ne;t[29]!==u||t[30]!==w||t[31]!==ee?(ne=()=>{if(!u){U7(w,!1);return}ee(O.current)},t[29]=u,t[30]=w,t[31]=ee,t[32]=ne):ne=t[32];let q;t[33]===u?q=t[34]:(q=[u],t[33]=u,t[34]=q),Z.useEffect(ne,q);let J;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(J=()=>{let e=E.current?.getBoundingClientRect().height||0;if(e<=0)return{minHeight:W7,maxHeight:1/0};let t=Math.min(W7,e/2);return{minHeight:t,maxHeight:Math.max(t,e-t)}},t[35]=J):J=t[35];let re=J,Y;t[36]!==s||t[37]!==p?(Y=e=>{if(s||e.button!==0)return;e.preventDefault();let{maxHeight:t,minHeight:n}=re(),r=D.current?.getBoundingClientRect().height||n,i=e.clientY,a=document.body.style.cursor,o=document.body.style.userSelect,c=Bo(),l=Ho(c),u=Math.min(t,Math.max(n,r));document.body.style.cursor=c,document.body.style.userSelect=`none`;let d=e=>{let a=r-(e.clientY-i);u=Math.min(t,Math.max(n,a)),p(u)},f=()=>{Yre(u),l(),document.body.style.cursor=a,document.body.style.userSelect=o,document.removeEventListener(`pointermove`,d),document.removeEventListener(`pointerup`,f),document.removeEventListener(`pointercancel`,f)};document.addEventListener(`pointermove`,d),document.addEventListener(`pointerup`,f),document.addEventListener(`pointercancel`,f)},t[36]=s,t[37]=p,t[38]=Y):Y=t[38];let ie=Y,ae;t[39]!==u||t[40]!==s||t[41]!==h||t[42]!==p?(ae=()=>{if(s||!u)return;let e=()=>{let e=E.current?.getBoundingClientRect().height||0,{maxHeight:t,minHeight:n}=re(),r=e>0?e*.5:0;h(r>0?Math.min(t,Math.max(n,r)):void 0),p(e=>typeof e==`number`?Math.min(t,Math.max(n,e)):e)};return e(),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e)}},t[39]=u,t[40]=s,t[41]=h,t[42]=p,t[43]=ae):ae=t[43];let oe;t[44]!==u||t[45]!==s||t[46]!==o?(oe=[u,s,o],t[44]=u,t[45]=s,t[46]=o,t[47]=oe):oe=t[47],Z.useEffect(ae,oe);let se=y.length>0,ce;t[48]!==L||t[49]!==se||t[50]!==b?(ce=()=>{b(se?[]:L.map(q7))},t[48]=L,t[49]=se,t[50]=b,t[51]=ce):ce=t[51];let le=ce,ue;t[52]!==i||t[53]!==o||t[54]!==n?(ue=(0,Q.jsx)(`div`,{className:`flex min-h-12 shrink-0 flex-col justify-center gap-2 border-b border-border/70 bg-background p-2`,children:(0,Q.jsx)(Sre,{viewerContextId:n,cwd:o,active:i})}),t[52]=i,t[53]=o,t[54]=n,t[55]=ue):ue=t[55];let de;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,Q.jsx)(`div`,{className:`flex min-w-0 items-center`,children:(0,Q.jsx)(`span`,{className:`text-xs font-bold tracking-[0.04em] text-muted-foreground uppercase`,children:`Diffs`})}),t[56]=de):de=t[56];let fe;t[57]===c?fe=t[58]:(fe=[c],t[57]=c,t[58]=fe);let pe;t[59]===l?pe=t[60]:(pe=e=>{let t=e[0];(t===`unified`||t===`split`)&&l(t)},t[59]=l,t[60]=pe);let me;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(me=[`unified`,`split`],t[61]=me):me=t[61];let he;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(he=me.map(eie),t[62]=he):he=t[62];let ge;t[63]!==fe||t[64]!==pe?(ge=(0,Q.jsx)(kre,{variant:`outline`,value:fe,onValueChange:pe,children:he}),t[63]=fe,t[64]=pe,t[65]=ge):ge=t[65];let _e=L.length===0,ve;t[66]===se?ve=t[67]:(ve=se?(0,Q.jsx)(Pa,{className:`size-4`}):(0,Q.jsx)(Fa,{className:`size-4`}),t[66]=se,t[67]=ve);let ye=se?`Collapse all`:`Expand all`,be;t[68]!==_e||t[69]!==ve||t[70]!==ye||t[71]!==le?(be=(0,Q.jsxs)(ss,{variant:`outline`,disabled:_e,onClick:le,children:[ve,ye]}),t[68]=_e,t[69]=ve,t[70]=ye,t[71]=le,t[72]=be):be=t[72];let xe;t[73]!==ge||t[74]!==be?(xe=(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border/70 bg-background p-2`,children:[de,(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[ge,be]})]}),t[73]=ge,t[74]=be,t[75]=xe):xe=t[75];let Se;t[76]===W?Se=t[77]:(Se=e=>{W(e.currentTarget)},t[76]=W,t[77]=Se);let Ce;t[78]!==i||t[79]!==L||t[80]!==c||t[81]!==F||t[82]!==P.error||t[83]!==P.isPending||t[84]!==o||t[85]!==a||t[86]!==y||t[87]!==b||t[88]!==x||t[89]!==n?(Ce=o?n?P.isPending&&F===void 0?(0,Q.jsxs)(h7,{className:`px-3 py-2.5`,children:[(0,Q.jsx)(H,{}),` Loading changes…`]}):P.error?(0,Q.jsx)(h7,{tone:`destructive`,className:`px-3 py-2.5`,children:c_(P.error,`Failed to load changes`)}):F===null?(0,Q.jsx)(h7,{className:`px-3 py-2.5`,children:`No git repository detected.`}):L.length>0?(0,Q.jsx)(bb,{multiple:!0,value:y,onValueChange:b,className:`border-b border-border/80`,children:L.map(e=>(0,Q.jsx)(rie,{viewerContextId:n,cwd:o,active:i,diffStyle:c,file:e,open:y.includes(q7(e)),stuck:x===q7(e),onOpenFile:a},q7(e)))}):(0,Q.jsx)(h7,{className:`px-3 py-2.5`,children:`Working tree clean.`}):(0,Q.jsx)(h7,{className:`px-3 py-2.5`,children:`Waiting for viewer context…`}):(0,Q.jsx)(h7,{className:`px-3 py-2.5`,children:`No directory selected.`}),t[78]=i,t[79]=L,t[80]=c,t[81]=F,t[82]=P.error,t[83]=P.isPending,t[84]=o,t[85]=a,t[86]=y,t[87]=b,t[88]=x,t[89]=n,t[90]=Ce):Ce=t[90];let we;t[91]!==Se||t[92]!==Ce?(we=(0,Q.jsx)(`div`,{ref:T,className:`min-h-0 flex-1 overflow-auto`,onScroll:Se,children:Ce}),t[91]=Se,t[92]=Ce,t[93]=we):we=t[93];let Te;t[94]!==i||t[95]!==m||t[96]!==F||t[97]!==P.error||t[98]!==C||t[99]!==u||t[100]!==f||t[101]!==s||t[102]!==o||t[103]!==d||t[104]!==ie||t[105]!==ee||t[106]!==g||t[107]!==n?(Te=o&&n&&F!==null&&!P.error?(0,Q.jsxs)(`div`,{ref:D,className:`relative flex max-h-[50%] min-h-0 shrink-0 flex-col overflow-hidden border-t border-border/70 bg-card/50 md:max-h-none`,style:!s&&u?{height:f??m}:void 0,children:[u?(0,Q.jsx)(`div`,{role:`separator`,"aria-label":`Resize history panel`,"aria-orientation":`horizontal`,style:{cursor:g},className:rn(`absolute inset-x-0 top-0 z-10 hidden h-2 -translate-y-1/2 touch-none bg-transparent after:absolute after:inset-x-0 after:top-1/2 after:h-px after:bg-transparent md:block`,Ss,g===`ns-resize`?`cursor-ns-resize`:`cursor-row-resize`),onPointerDown:ie}):null,(0,Q.jsxs)(`button`,{type:`button`,"aria-expanded":u,className:rn(`flex min-h-10 w-full shrink-0 items-center justify-between gap-3 bg-background px-3 py-2 text-left transition-[background-color,box-shadow] hover:bg-muted/60`,C&&`shadow-sm`),onClick:()=>{d($re)},children:[(0,Q.jsx)(`span`,{className:`flex min-w-0 items-center`,children:(0,Q.jsx)(`span`,{className:`text-xs font-bold tracking-[0.04em] text-muted-foreground uppercase`,children:`History`})}),u?(0,Q.jsx)(Ma,{className:`size-4 shrink-0 text-muted-foreground`}):(0,Q.jsx)(Gt,{className:`size-4 shrink-0 text-muted-foreground`})]}),u?(0,Q.jsx)(`div`,{ref:O,className:`min-h-0 flex-1 touch-pan-y overflow-x-hidden overflow-y-auto overscroll-contain border-t border-border/70`,onScroll:e=>{ee(e.currentTarget)},children:(0,Q.jsx)(Vre,{viewerContextId:n,cwd:o,active:i&&u,embedded:!0})}):null]}):null,t[94]=i,t[95]=m,t[96]=F,t[97]=P.error,t[98]=C,t[99]=u,t[100]=f,t[101]=s,t[102]=o,t[103]=d,t[104]=ie,t[105]=ee,t[106]=g,t[107]=n,t[108]=Te):Te=t[108];let Ee;return t[109]!==ue||t[110]!==xe||t[111]!==we||t[112]!==Te?(Ee=(0,Q.jsxs)(`div`,{ref:E,className:`flex h-full min-h-0 flex-col bg-background`,children:[ue,xe,we,Te]}),t[109]=ue,t[110]=xe,t[111]=we,t[112]=Te,t[113]=Ee):Ee=t[113],Ee}function $re(e){return!e}function eie(e){return(0,Q.jsx)(Are,{value:e,children:e===`unified`?`Unified`:`Split`},e)}function tie(e){return e.dataset.reviewFileValue||``}function nie(){return K7()}function rie(e){let t=(0,$.c)(59),{viewerContextId:n,cwd:r,active:i,diffStyle:a,file:o,open:s,stuck:c,onOpenFile:l}=e,u=a_(r),d;t[0]===o?d=t[1]:(d=q7(o),t[0]=o,t[1]=d);let f=d,[p,m]=Z.useState(!1),h;t[2]!==o||t[3]!==p?(h=Zre(o)&&!p,t[2]=o,t[3]=p,t[4]=h):h=t[4];let g=h,_=Or({...p_({viewerContextId:n,cwd:u,path:o.path}),enabled:!!(g&&s&&i&&n&&u),notifyOnChangeProps:[`data`,`isPending`,`error`]}),v=m_({viewerContextId:n,cwd:u,path:o.path,previousPath:o.previousPath}),y=!!(!g&&s&&i&&n&&u),b;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(b=[`data`,`isPending`,`error`],t[5]=b):b=t[5];let x;t[6]!==v||t[7]!==y?(x={...v,enabled:y,notifyOnChangeProps:b},t[6]=v,t[7]=y,t[8]=x):x=t[8];let S=Or(x),C=S.data?.oldContent??``,w=S.data?.newContent??``,T=_.data?.patch??``,E;t[9]===m?E=t[10]:(E=()=>{m(!1)},t[9]=m,t[10]=E);let D;t[11]===f?D=t[12]:(D=[f],t[11]=f,t[12]=D),Z.useEffect(E,D);let O=c&&`shadow-sm`,k;t[13]===O?k=t[14]:(k=rn(`group/review-file-header sticky top-0 z-20 flex bg-background transition-shadow`,O),t[13]=O,t[14]=k);let A;t[15]===o.status?A=t[16]:(A=(0,Q.jsx)(Kre,{status:o.status}),t[15]=o.status,t[16]=A);let j;t[17]!==o.path||t[18]!==o.previousPath?(j=o.previousPath?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:o.previousPath}),(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:` → `}),(0,Q.jsx)(`span`,{children:o.path})]}):o.path,t[17]=o.path,t[18]=o.previousPath,t[19]=j):j=t[19];let M;t[20]===j?M=t[21]:(M=(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-left`,children:j}),t[20]=j,t[21]=M);let N;t[22]===o?N=t[23]:(N=(0,Q.jsx)(qre,{file:o}),t[22]=o,t[23]=N);let P;t[24]!==A||t[25]!==M||t[26]!==N?(P=(0,Q.jsxs)(`span`,{className:`grid min-w-0 flex-1 grid-cols-[auto_minmax(0,1fr)_auto] items-baseline gap-3`,children:[A,M,N]}),t[24]=A,t[25]=M,t[26]=N,t[27]=P):P=t[27];let F,I;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Q.jsx)(Ma,{"data-slot":`accordion-trigger-icon`,className:`pointer-events-none size-4 shrink-0 group-aria-expanded/review-file-trigger:hidden`}),I=(0,Q.jsx)(Gt,{"data-slot":`accordion-trigger-icon`,className:`pointer-events-none hidden size-4 shrink-0 group-aria-expanded/review-file-trigger:inline`}),t[28]=F,t[29]=I):(F=t[28],I=t[29]);let L;t[30]!==P||t[31]!==f?(L=(0,Q.jsxs)(hb,{"data-review-file-trigger":!0,"data-review-file-value":f,className:`group/review-file-trigger relative flex min-h-10 min-w-0 flex-1 items-center justify-between gap-3 rounded-none border border-transparent bg-background px-3 py-2 text-left font-mono text-[13px] font-medium transition-all outline-none hover:no-underline focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-disabled:pointer-events-none aria-disabled:opacity-50 **:data-[slot=accordion-trigger-icon]:ml-auto **:data-[slot=accordion-trigger-icon]:size-4 **:data-[slot=accordion-trigger-icon]:text-muted-foreground`,children:[P,F,I]}),t[30]=P,t[31]=f,t[32]=L):L=t[32];let R;t[33]!==o.path||t[34]!==l?(R=l?(0,Q.jsx)(Je,{title:`Open file`,side:`top`,children:(0,Q.jsx)(ss,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Open ${o.path}`,className:`mr-2 self-center`,onClick:e=>{e.stopPropagation(),l(o.path,{pin:!0})},children:(0,Q.jsx)($a,{className:`size-3.5`})})}):null,t[33]=o.path,t[34]=l,t[35]=R):R=t[35];let z;t[36]!==k||t[37]!==L||t[38]!==R?(z=(0,Q.jsxs)(fb,{className:k,children:[L,R]}),t[36]=k,t[37]=L,t[38]=R,t[39]=z):z=t[39];let B;t[40]!==_.data||t[41]!==_.error||t[42]!==_.isPending||t[43]!==a||t[44]!==o.path||t[45]!==o.previousPath||t[46]!==w||t[47]!==C||t[48]!==T||t[49]!==g||t[50]!==S.data||t[51]!==S.error||t[52]!==S.isPending||t[53]!==m?(B=(0,Q.jsx)(Cb,{className:`bg-background p-0`,children:g?_.isPending&&!_.data?(0,Q.jsx)(`div`,{className:`p-3`,children:(0,Q.jsxs)(h7,{children:[(0,Q.jsx)(H,{}),` Loading hunk…`]})}):_.error?(0,Q.jsx)(`div`,{className:`p-3`,children:(0,Q.jsx)(h7,{tone:`destructive`,children:c_(_.error,`Failed to load hunk`)})}):T?(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-border/70 bg-background px-3 py-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:`Showing changed hunks only for this large change.`}),(0,Q.jsx)(ss,{variant:`outline`,className:`shrink-0`,onClick:()=>{m(!0)},children:`Load full context`})]}),(0,Q.jsx)(YP,{patch:T,disableWorkerPool:!0,options:{diffStyle:a,disableFileHeader:!0,overflow:`wrap`}})]}):(0,Q.jsx)(`div`,{className:`p-3`,children:(0,Q.jsx)(h7,{children:`No line changes.`})}):S.isPending&&!S.data?(0,Q.jsx)(`div`,{className:`p-3`,children:(0,Q.jsxs)(h7,{children:[(0,Q.jsx)(H,{}),` Loading hunk…`]})}):S.error?(0,Q.jsx)(`div`,{className:`p-3`,children:(0,Q.jsx)(h7,{tone:`destructive`,children:c_(S.error,`Failed to load hunk`)})}):C===w?(0,Q.jsx)(`div`,{className:`p-3`,children:(0,Q.jsx)(h7,{children:`No line changes.`})}):(0,Q.jsx)(qP,{oldFile:{name:o.previousPath||o.path,contents:C},newFile:{name:o.path,contents:w},disableWorkerPool:!0,options:{diffStyle:a,disableFileHeader:!0,overflow:`wrap`}})}),t[40]=_.data,t[41]=_.error,t[42]=_.isPending,t[43]=a,t[44]=o.path,t[45]=o.previousPath,t[46]=w,t[47]=C,t[48]=T,t[49]=g,t[50]=S.data,t[51]=S.error,t[52]=S.isPending,t[53]=m,t[54]=B):B=t[54];let V;return t[55]!==z||t[56]!==B||t[57]!==f?(V=(0,Q.jsxs)(xb,{value:f,className:`border-border/70`,children:[z,B]}),t[55]=z,t[56]=B,t[57]=f,t[58]=V):V=t[58],V}function J7(e){let t=(0,$.c)(89),{viewerContextId:n,cwd:r,active:i,activeFilePath:a,activeTab:o,filePreviewPath:s,fileTabs:c,fileTreeCollapsed:l,onActiveFileChange:u,onActiveTabChange:d,onCloseAllFiles:f,onCloseFile:p,onCloseFilesToRight:m,onCloseOtherFiles:h,onFileTreeCollapsedChange:g,onOpenFile:_,onReorderFiles:v,showToolbar:y}=e,b=a===void 0?``:a,x=s===void 0?``:s,S;t[0]===c?S=t[1]:(S=c===void 0?[]:c,t[0]=c,t[1]=S);let C=S,w=l===void 0?!1:l,T=y===void 0?!0:y,E=a_(r),D=Ao(),[O,k]=Z.useState(`review`),A=o??O,j;t[2]!==d||t[3]!==k?(j=e=>{k(e),d?.(e)},t[2]=d,t[3]=k,t[4]=j):j=t[4];let M=j,[N,P]=Z.useState(``),[F,I]=Z.useState(!1),L=D?`inline`:`external`,R=T&&!D,z=L===`inline`?N:b,B=C.length>0,V=b7({viewerContextId:n,cwd:E}),H=!!(i&&B&&n&&E),U;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(U=[`data`],t[5]=U):U=t[5];let W;t[6]!==V||t[7]!==H?(W={...V,enabled:H,select:iie,notifyOnChangeProps:U},t[6]=V,t[7]=H,t[8]=W):W=t[8];let G=Or(W),ee;t[9]===G.data?ee=t[10]:(ee=G.data??[],t[9]=G.data,t[10]=ee);let te=ee,K;t[11]!==u||t[12]!==_||t[13]!==L||t[14]!==M||t[15]!==P?(K=(e,t)=>{if(e){if(M(`files`),L===`inline`){P(e);return}_?.(e,t),u?.(e)}},t[11]=u,t[12]=_,t[13]=L,t[14]=M,t[15]=P,t[16]=K):K=t[16];let ne=K,q;t[17]!==o||t[18]!==k?(q=()=>{o||k(`review`)},t[17]=o,t[18]=k,t[19]=q):q=t[19];let J;t[20]!==o||t[21]!==D||t[22]!==E?(J=[o,D,E],t[20]=o,t[21]=D,t[22]=E,t[23]=J):J=t[23],Z.useEffect(q,J);let re;t[24]===P?re=t[25]:(re=()=>{P(``)},t[24]=P,t[25]=re);let Y;t[26]!==D||t[27]!==E?(Y=[D,E],t[26]=D,t[27]=E,t[28]=Y):Y=t[28],Z.useEffect(re,Y);let ie;t[29]!==i||t[30]!==E||t[31]!==n?(ie=(0,Q.jsx)(bre,{viewerContextId:n,cwd:E,active:i}),t[29]=i,t[30]=E,t[31]=n,t[32]=ie):ie=t[32];let ae=R?`rounded-xl border border-border/80`:`rounded-none border-0`,oe;t[33]===ae?oe=t[34]:(oe=rn(`flex h-full min-h-[520px] min-w-0 flex-col overflow-hidden bg-card/50`,ae),t[33]=ae,t[34]=oe);let se;t[35]===I?se=t[36]:(se=()=>{I(!0)},t[35]=I,t[36]=se);let ce;t[37]!==A||t[38]!==z||t[39]!==x||t[40]!==C||t[41]!==u||t[42]!==f||t[43]!==p||t[44]!==m||t[45]!==h||t[46]!==v||t[47]!==M||t[48]!==se?(ce=(0,Q.jsx)(sre,{activeFilePath:z,activeTab:A,filePreviewPath:x,fileTabs:C,onActiveFileChange:u,onActiveTabChange:M,onCloseAllFiles:f,onCloseFile:p,onCloseFilesToRight:m,onCloseOtherFiles:h,onOpenFileDialog:se,onReorderFiles:v,showReview:!0}),t[37]=A,t[38]=z,t[39]=x,t[40]=C,t[41]=u,t[42]=f,t[43]=p,t[44]=m,t[45]=h,t[46]=v,t[47]=M,t[48]=se,t[49]=ce):ce=t[49];let le=A===`review`?`visible`:`hidden`,ue=i&&A===`review`,de;t[50]!==E||t[51]!==ne||t[52]!==ue||t[53]!==n?(de=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,Q.jsx)(Qre,{viewerContextId:n,cwd:E,active:ue,onOpenFile:ne})}),t[50]=E,t[51]=ne,t[52]=ue,t[53]=n,t[54]=de):de=t[54];let fe;t[55]!==le||t[56]!==de?(fe=(0,Q.jsx)(Z.Activity,{mode:le,children:de}),t[55]=le,t[56]=de,t[57]=fe):fe=t[57];let pe=A===`files`?`visible`:`hidden`,me;t[58]!==i||t[59]!==A||t[60]!==z||t[61]!==w||t[62]!==B||t[63]!==E||t[64]!==g||t[65]!==ne||t[66]!==L||t[67]!==P||t[68]!==n?(me=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:L===`external`&&B?(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col overflow-hidden`,children:[z?(0,Q.jsx)(mre,{path:z,fileTreeCollapsed:w,onFileTreeCollapsedChange:g}):null,(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[w?null:(0,Q.jsx)(dre,{viewerContextId:n,cwd:E,active:i&&A===`files`,activeFilePath:z,onOpenFile:ne,previewMode:L}),z?(0,Q.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,Q.jsx)(T7,{viewerContextId:n,cwd:E,active:i&&A===`files`,path:z})}):null]})]}):(0,Q.jsx)(C7,{viewerContextId:n,cwd:E,active:i&&A===`files`,activeFilePath:z,onCloseFile:()=>{P(``)},onOpenFile:ne,previewMode:L})}),t[58]=i,t[59]=A,t[60]=z,t[61]=w,t[62]=B,t[63]=E,t[64]=g,t[65]=ne,t[66]=L,t[67]=P,t[68]=n,t[69]=me):me=t[69];let he;t[70]!==pe||t[71]!==me?(he=(0,Q.jsx)(Z.Activity,{mode:pe,children:me}),t[70]=pe,t[71]=me,t[72]=he):he=t[72];let ge;t[73]===ne?ge=t[74]:(ge=e=>{ne(e,{pin:!0})},t[73]=ne,t[74]=ge);let _e;t[75]!==te||t[76]!==F||t[77]!==I||t[78]!==ge?(_e=(0,Q.jsx)(w7,{open:F,onOpenChange:I,paths:te,onOpenFile:ge}),t[75]=te,t[76]=F,t[77]=I,t[78]=ge,t[79]=_e):_e=t[79];let ve;t[80]!==oe||t[81]!==ce||t[82]!==fe||t[83]!==he||t[84]!==_e?(ve=(0,Q.jsxs)(`div`,{className:oe,children:[ce,fe,he,_e]}),t[80]=oe,t[81]=ce,t[82]=fe,t[83]=he,t[84]=_e,t[85]=ve):ve=t[85];let ye;return t[86]!==ie||t[87]!==ve?(ye=(0,Q.jsxs)(`div`,{className:`h-full min-h-[520px] w-full min-w-0`,children:[ie,ve]}),t[86]=ie,t[87]=ve,t[88]=ye):ye=t[88],ye}function iie(e){return e.paths}function aie(e){return e===`files`||e===`review`?e:`review`}function oie(){return aie(A(Hn))}function Y7(e){ee(Hn,e)}function X7(e,t){Bg(e,`activeTab`,t),Y7(t)}function sie(){return{activeTab:oie(),fileActivePath:``,filePreviewPath:``,fileTabs:[],fileTreeCollapsed:!1}}function Z7(e){return e.filePreviewPath&&!e.fileTabs.includes(e.filePreviewPath)?[...e.fileTabs,e.filePreviewPath]:e.fileTabs}function cie(e){return Z7(e).length>0}function Q7(e){zg(e,e=>({...e,fileActivePath:``,filePreviewPath:``,fileTabs:[],fileTreeCollapsed:!1}))}function lie(e,t,n){t&&(Y7(`files`),zg(e,e=>{let r=!!n?.pin||e.fileTabs.includes(t)||e.fileActivePath===t,i=r?e.fileTabs.includes(t)?e.fileTabs:[...e.fileTabs,t]:e.fileTabs,a=r?e.filePreviewPath===t?``:e.filePreviewPath:t;return{...e,activeTab:`files`,fileActivePath:t,filePreviewPath:a,fileTabs:i,fileTreeCollapsed:!1}}))}function uie(e,t){zg(e,e=>{let n=Z7(e).indexOf(t),r=e.fileTabs.filter(e=>e!==t),i=e.filePreviewPath===t?``:e.filePreviewPath,a=i&&!r.includes(i)?[...r,i]:r,o=e.fileActivePath===t?a[Math.max(0,n-1)]||a[0]||``:e.fileActivePath;return{...e,fileActivePath:o,filePreviewPath:i,fileTabs:r}})}function die(e,t){zg(e,e=>{let n=e.fileTabs.includes(t)?[t]:[];return{...e,fileActivePath:t,filePreviewPath:n.length===0?t:``,fileTabs:n}})}function fie(e,t){zg(e,e=>{let n=Z7(e),r=n.indexOf(t);if(r<0)return e;let i=new Set(n.slice(0,r+1)),a=e.fileTabs.filter(e=>i.has(e)),o=i.has(e.filePreviewPath)?e.filePreviewPath:``,s=o&&!a.includes(o)?[...a,o]:a;return{...e,fileActivePath:s.includes(e.fileActivePath)?e.fileActivePath:t,filePreviewPath:o,fileTabs:a}})}function pie(e){zg(e,e=>({...e,fileActivePath:``,filePreviewPath:``,fileTabs:[]}))}function mie(e,t){let n=t.filter((e,n)=>e&&t.indexOf(e)===n);n.length!==0&&zg(e,e=>({...e,fileActivePath:n.includes(e.fileActivePath)?e.fileActivePath:n[0]||``,filePreviewPath:``,fileTabs:n}))}function hie(e){let t=(0,$.c)(4),{sessionStore:n,viewerContextId:r}=e,i=Ji(n,gie),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(Zv,{value:`session`,className:`h-8 data-active:bg-muted dark:data-active:bg-muted`,children:`Session`}),t[0]=a):a=t[0];let o;return t[1]!==i||t[2]!==r?(o=(0,Q.jsxs)(Xv,{className:`w-full gap-2 rounded-none border-b border-border/70 bg-background p-2 group-data-horizontal/tabs:h-auto md:hidden`,children:[a,(0,Q.jsx)(Zv,{value:`git`,className:`h-8 data-active:bg-muted dark:data-active:bg-muted`,children:(0,Q.jsx)(Iq,{viewerContextId:r,cwd:i})})]}),t[1]=i,t[2]=r,t[3]=o):o=t[3],o}function gie(e){return e.cwd}var _ie=Z.memo(function(e){let t=(0,$.c)(24),{active:n,onCloseAllFiles:r,onCloseFile:i,onCloseFilesToRight:a,onCloseOtherFiles:o,onOpenFile:s,onReorderFiles:c,rightSidebarStore:l,sessionStore:u,viewerContextId:d}=e,f=Ji(u,Aie),p=Ji(l,jie),m=Ji(l,Mie),h=Ji(l,Nie),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g={compare:Ag},t[0]=g):g=t[0];let _=Ji(l,Z7,g),v=Ji(l,Pie),y,b;t[1]===l?(y=t[2],b=t[3]):(y=e=>{Bg(l,`fileActivePath`,e)},b=e=>{X7(l,e)},t[1]=l,t[2]=y,t[3]=b);let x;t[4]===l?x=t[5]:(x=e=>{Bg(l,`fileTreeCollapsed`,e)},t[4]=l,t[5]=x);let S;return t[6]!==n||t[7]!==p||t[8]!==m||t[9]!==f||t[10]!==h||t[11]!==_||t[12]!==v||t[13]!==r||t[14]!==i||t[15]!==a||t[16]!==o||t[17]!==s||t[18]!==c||t[19]!==y||t[20]!==b||t[21]!==x||t[22]!==d?(S=(0,Q.jsx)(J7,{viewerContextId:d,cwd:f,active:n,activeFilePath:p,activeTab:m,filePreviewPath:h,fileTabs:_,fileTreeCollapsed:v,onActiveFileChange:y,onActiveTabChange:b,onCloseAllFiles:r,onCloseFile:i,onCloseFilesToRight:a,onCloseOtherFiles:o,onFileTreeCollapsedChange:x,onOpenFile:s,onReorderFiles:c}),t[6]=n,t[7]=p,t[8]=m,t[9]=f,t[10]=h,t[11]=_,t[12]=v,t[13]=r,t[14]=i,t[15]=a,t[16]=o,t[17]=s,t[18]=c,t[19]=y,t[20]=b,t[21]=x,t[22]=d,t[23]=S):S=t[23],S});function vie(e){let t=(0,$.c)(28),{active:n,onCloseAllFiles:r,onCloseFile:i,onCloseFilesToRight:a,onCloseOtherFiles:o,onOpenFile:s,onReorderFiles:c,rightSidebarStore:l,sessionStore:u,viewerContextId:d}=e,f=Ji(u,Cie),p=Ji(l,Sie),m=Ji(l,xie),h=Ji(l,bie),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g={compare:Ag},t[0]=g):g=t[0];let _=Ji(l,Z7,g),v=Ji(l,yie),y=!n,b=n?`open`:`closed`,x,S;t[1]===l?(x=t[2],S=t[3]):(x=e=>{Bg(l,`fileActivePath`,e)},S=e=>{X7(l,e)},t[1]=l,t[2]=x,t[3]=S);let C;t[4]===l?C=t[5]:(C=e=>{Bg(l,`fileTreeCollapsed`,e)},t[4]=l,t[5]=C);let w;t[6]!==n||t[7]!==p||t[8]!==m||t[9]!==f||t[10]!==h||t[11]!==_||t[12]!==v||t[13]!==r||t[14]!==i||t[15]!==a||t[16]!==o||t[17]!==s||t[18]!==c||t[19]!==x||t[20]!==S||t[21]!==C||t[22]!==d?(w=(0,Q.jsx)(J7,{viewerContextId:d,cwd:f,active:n,activeFilePath:p,activeTab:m,filePreviewPath:h,fileTabs:_,fileTreeCollapsed:v,onActiveFileChange:x,onActiveTabChange:S,onCloseAllFiles:r,onCloseFile:i,onCloseFilesToRight:a,onCloseOtherFiles:o,onFileTreeCollapsedChange:C,onOpenFile:s,onReorderFiles:c,showToolbar:!1}),t[6]=n,t[7]=p,t[8]=m,t[9]=f,t[10]=h,t[11]=_,t[12]=v,t[13]=r,t[14]=i,t[15]=a,t[16]=o,t[17]=s,t[18]=c,t[19]=x,t[20]=S,t[21]=C,t[22]=d,t[23]=w):w=t[23];let T;return t[24]!==y||t[25]!==b||t[26]!==w?(T=(0,Q.jsx)(`aside`,{"aria-label":`Right sidebar`,"aria-hidden":y,"data-state":b,className:`flex h-full min-h-0 w-full min-w-0 flex-col border-l border-border/70 bg-background data-[state=closed]:pointer-events-none data-[state=closed]:border-transparent`,children:w}),t[24]=y,t[25]=b,t[26]=w,t[27]=T):T=t[27],T}function yie(e){return e.fileTreeCollapsed}function bie(e){return e.filePreviewPath}function xie(e){return e.activeTab}function Sie(e){return e.fileActivePath}function Cie(e){return e.cwd}var $7=520,e9=320,t9=320,n9=260,wie=1600;function r9(){return{fileViewWidth:$7,gitPanelWidth:e9}}function i9(e,t){let n=typeof e==`number`?e:Number(e);return Number.isFinite(n)?Math.round(Math.min(wie,Math.max(n9,n))):t}function a9(e){if(!e||typeof e!=`object`)return r9();let t=e;return{fileViewWidth:i9(t.fileViewWidth,$7),gitPanelWidth:i9(t.gitPanelWidth,e9)}}function Tie(){try{let e=A(Oe);return e?a9(JSON.parse(e)):r9()}catch{return r9()}}function Eie(e){ee(Oe,JSON.stringify(a9(e)))}function o9(e,t){return e.fileViewWidth===t.fileViewWidth&&e.gitPanelWidth===t.gitPanelWidth}function s9(e,t,n){return Number.isFinite(e)?n<=t?Math.max(0,n):Math.min(n,Math.max(t,e)):t}function Die({availableWidth:e,fileOpen:t,fileWidth:n,gitOpen:r,gitWidth:i}){let a=Math.max(0,e-t9);if(!t&&!r)return{fileWidth:0,gitWidth:0,sideWidth:0};if(t&&!r){let e=s9(n,Math.min(n9,a),a);return{fileWidth:e,gitWidth:0,sideWidth:e}}if(!t&&r){let e=s9(i,Math.min(n9,a),a);return{fileWidth:0,gitWidth:e,sideWidth:e}}let o=Math.max(1,n+i);if(o<=a)return{fileWidth:n,gitWidth:i,sideWidth:n+i};let s=Math.min(n9,a/2),c=Math.round(n/o*a);c=Math.max(s,Math.min(a-s,c));let l=Math.max(0,a-c);return{fileWidth:c,gitWidth:l,sideWidth:c+l}}function Oie(e){let t=(0,$.c)(24),{label:n,max:r,min:i,onResize:a,onResizeEnd:o,onResizeStart:s,size:c}=e,l;t[0]!==r||t[1]!==i||t[2]!==a||t[3]!==o||t[4]!==s||t[5]!==c?(l={max:r,min:i,onResize:a,onResizeEnd:o,onResizeStart:s,size:c},t[0]=r,t[1]=i,t[2]=a,t[3]=o,t[4]=s,t[5]=c,t[6]=l):l=t[6];let u=Mg(l),[d,f]=Z.useState(`col-resize`),[p,m]=Z.useState(10),h,g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>{let e=()=>{m(Vo())},t=window.matchMedia(`(pointer:coarse)`);return f(zo()),e(),t.addEventListener(`change`,e),()=>{t.removeEventListener(`change`,e)}},g=[],t[7]=h,t[8]=g):(h=t[7],g=t[8]),Z.useEffect(h,g);let _=d===`ew-resize`?`cursor-ew-resize`:`cursor-col-resize`,v;t[9]===u?v=t[10]:(v=e=>{let t=u.current;t.onResize(s9(e,t.min,t.max))},t[9]=u,t[10]=v);let y=v,b=`${p}px`,x;t[11]!==d||t[12]!==b?(x={"--resize-target-width":b,cursor:d},t[11]=d,t[12]=b,t[13]=x):x=t[13];let S=x,C=`absolute inset-y-0 left-0 z-20 w-(--resize-target-width) -translate-x-1/2 touch-none bg-transparent outline-hidden after:absolute after:inset-y-0 after:left-1/2 after:w-px after:bg-transparent focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 ${Ss} ${_}`,w,T;t[14]!==u||t[15]!==y?(T=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=e.shiftKey?48:16;y(u.current.size+(e.key===`ArrowLeft`?t:-t))},w=e=>{if(e.button!==0)return;e.preventDefault();let t=u.current,n=e.clientX,r=t.size,i=zo(),a=document.body.style.cursor,o=document.body.style.userSelect,s=Ho(i);t.onResizeStart?.(),document.body.style.userSelect=`none`,document.body.style.cursor=i;let c=e=>{y(r+n-e.clientX)},l=()=>{s(),document.body.style.userSelect=o,document.body.style.cursor=a,document.removeEventListener(`pointermove`,c),document.removeEventListener(`pointerup`,l),document.removeEventListener(`pointercancel`,l),u.current.onResizeEnd?.()};document.addEventListener(`pointermove`,c),document.addEventListener(`pointerup`,l),document.addEventListener(`pointercancel`,l)},t[14]=u,t[15]=y,t[16]=w,t[17]=T):(w=t[16],T=t[17]);let E;return t[18]!==n||t[19]!==w||t[20]!==S||t[21]!==C||t[22]!==T?(E=(0,Q.jsx)(`div`,{role:`separator`,"aria-label":n,"aria-orientation":`vertical`,tabIndex:0,style:S,className:C,onKeyDown:T,onPointerDown:w}),t[18]=n,t[19]=w,t[20]=S,t[21]=C,t[22]=T,t[23]=E):E=t[23],E}function kie({actionsRef:e,appUiStore:t,awaitingFirstTurn:n,composerPanelRef:r,contextUsageStore:i,conversationFrameRef:a,conversationItemsStore:o,defaultNewSessionDirectory:s,displaySettingsStore:c,fileInputRef:l,gitPanelOpen:u,hiddenThinkingPreviewStore:d,isSessionViewLoading:f,isSubmitting:p,isMobile:m,newSessionDirectoryOptions:h,onCancelCompaction:g,onCreateSession:_,onOpenAddDirectoryDialog:v,onCloseAllFileViewTabs:y,onCloseFileViewTab:b,onCloseFileViewTabsToRight:x,onCloseOtherFileViewTabs:S,onOpenFileViewTab:C,onReorderFileViewTabs:w,onValueChange:T,rightSidebarStore:E,sessionStore:D,store:O,viewerContextId:k,workingStateStore:A}){let j=Ji(t,e=>e.currentTab),M=!Ji(D,e=>e.draft)||f,N=j===`git`?`hidden min-h-0 flex-1 flex-col md:flex`:`flex min-h-0 flex-1 flex-col`,P=j===`git`?`min-h-0 flex-1 overflow-hidden md:hidden`:`hidden`,F=Ji(E,cie),I=!m&&u,L=!m&&u&&F,R=L||I,z=Z.useRef(null),[B,V]=Z.useState(0),[H,U]=Z.useState(()=>r9()),W=Z.useRef(!1),G=Z.useRef(H);G.current=H;let ee=H.fileViewWidth,te=H.gitPanelWidth,K=e=>{let t=G.current,n=a9(Rg(t,e));o9(t,n)||(G.current=n,U(n),W.current&&Eie(n))},ne=e=>{K(t=>({...t,fileViewWidth:i9(Rg(t.fileViewWidth,e),$7)}))},q=e=>{K(t=>({...t,gitPanelWidth:i9(Rg(t.gitPanelWidth,e),e9)}))},[J,re]=Z.useState(I),[Y,ie]=Z.useState(!1);Z.useEffect(()=>{let e=Tie();W.current=!0,G.current=e,U(t=>o9(t,e)?t:e)},[]);let ae=(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,Q.jsx)(`div`,{className:N,children:(0,Q.jsx)(HJ,{actionsRef:e,awaitingFirstTurn:n,composerPanelRef:r,contextUsageStore:i,conversationFrameRef:a,conversationItemsStore:o,defaultNewSessionDirectory:s,displaySettingsStore:c,fileInputRef:l,hiddenThinkingPreviewStore:d,isSessionViewLoading:f,isSubmitting:p,newSessionDirectoryOptions:h,onCancelCompaction:g,onCreateSession:_,onOpenAddDirectoryDialog:v,sessionStore:D,store:O,viewerContextId:k,workingStateStore:A})}),m?(0,Q.jsx)(`div`,{className:P,children:(0,Q.jsx)(_ie,{viewerContextId:k,sessionStore:D,active:j===`git`,rightSidebarStore:E,onCloseAllFiles:y,onCloseFile:b,onCloseFilesToRight:x,onCloseOtherFiles:S,onOpenFile:C,onReorderFiles:w})}):null]});Z.useLayoutEffect(()=>{if(m){re(!1);return}R&&re(!0)},[R,m]),Z.useLayoutEffect(()=>{if(m)return;let e=z.current;if(!e)return;let t=()=>{V(e.clientWidth)};if(t(),typeof ResizeObserver>`u`)return window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t);let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[m]);let oe=B||(typeof window>`u`?1200:window.innerWidth),se=R||J||I,ce=Die({availableWidth:oe,fileOpen:L,fileWidth:ee,gitOpen:I,gitWidth:te}),le=R||J,ue=R?ce.sideWidth:0,de=Y?``:`transition-[width] duration-200 ease-linear`,fe=()=>{ie(!0)},pe=()=>{ie(!1)},me=Math.max(0,oe-t9);return(0,Q.jsxs)(Jv,{value:j,onValueChange:T,className:`flex min-h-0 flex-1 flex-col gap-0 overflow-hidden`,children:[M?(0,Q.jsx)(hie,{sessionStore:D,viewerContextId:k}):null,m?(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:ae}):(0,Q.jsxs)(`div`,{ref:z,className:`relative flex h-full min-h-0 w-full flex-1 overflow-hidden`,children:[(0,Q.jsx)(`div`,{"data-desktop-panel":`session`,className:`h-full min-h-0 min-w-0 shrink-0 overflow-hidden ${de}`,style:{width:R?`calc(100% - ${ue}px)`:`100%`},children:ae}),le?(0,Q.jsx)(`aside`,{"aria-label":`Desktop side workspace`,"aria-hidden":!R,"data-state":R?`open`:`closed`,"data-desktop-panel":`side-workspace`,className:`flex h-full min-h-0 min-w-0 shrink-0 overflow-visible bg-background data-[state=closed]:pointer-events-none ${de}`,style:{width:`${ue}px`},children:se?(0,Q.jsxs)(`div`,{"data-desktop-panel":`git`,className:`relative h-full min-h-0 min-w-0 shrink-0 overflow-visible ${de}`,style:{width:`${ue}px`},children:[I?(0,Q.jsx)(Oie,{label:`Resize right sidebar`,min:Math.min(n9,me),max:me,size:ue,onResize:e=>{if(!L){q(e);return}ne(Math.max(n9,e-te))},onResizeStart:fe,onResizeEnd:pe}):null,(0,Q.jsx)(`div`,{className:`h-full min-h-0 min-w-0 overflow-hidden`,children:se?(0,Q.jsx)(vie,{viewerContextId:k,sessionStore:D,active:I,rightSidebarStore:E,onCloseAllFiles:y,onCloseFile:b,onCloseFilesToRight:x,onCloseOtherFiles:S,onOpenFile:C,onReorderFiles:w}):null})]}):null}):null]})]})}function Aie(e){return e.cwd}function jie(e){return e.fileActivePath}function Mie(e){return e.activeTab}function Nie(e){return e.filePreviewPath}function Pie(e){return e.fileTreeCollapsed}var Fie=Z.memo(function(e){let t=(0,$.c)(131),{actionsRef:n,defaultNewSessionDirectory:r,displaySessionCwd:i,gitPanelOpen:a,loadingDisplaySessionTitle:o,currentSessionPinned:s,displaySettingsStore:c,isSessionViewLoading:l,newSessionDirectoryOptions:u,onToggleGitPanel:d,sessionStore:f,viewerContextId:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m={compare:Pg},t[0]=m):m=t[0];let h=Ji(f,Iie,m),g=Ji(c,Lie),{isMobile:_,openMobile:v,state:y}=Uc(),b=_?v:y===`expanded`,x=!b,S;t[1]!==l||t[2]!==o||t[3]!==h?(S=l?o:Fg(h),t[1]=l,t[2]=o,t[3]=h,t[4]=S):S=t[4];let C=S,w=b?`secondary`:`ghost`,T;t[5]===w?T=t[6]:(T=(0,Q.jsx)(Kc,{variant:w,className:`shrink-0`}),t[5]=w,t[6]=T);let E;t[7]!==n||t[8]!==r||t[9]!==x?(E=x?(0,Q.jsx)(Je,{title:r?`Create a new session in ${Og(r)}`:`Create a new session`,kbd:Uh(`Control+N`),children:(0,Q.jsx)(ss,{size:`icon`,variant:`ghost`,className:`shrink-0`,"aria-label":`Create a new session`,onClick:()=>{n.current.createSession()},children:(0,Q.jsx)(eo,{})})}):null,t[7]=n,t[8]=r,t[9]=x,t[10]=E):E=t[10];let D;t[11]!==l||t[12]!==h.sessionStreaming?(D=!l&&h.sessionStreaming?(0,Q.jsx)(H,{className:`size-3.5 shrink-0`,"aria-label":`Session streaming`}):null,t[11]=l,t[12]=h.sessionStreaming,t[13]=D):D=t[13];let O;t[14]===C?O=t[15]:(O=(0,Q.jsx)(`h2`,{className:`min-w-0 truncate text-[13px] leading-tight font-semibold`,children:C}),t[14]=C,t[15]=O);let k;t[16]!==C||t[17]!==O?(k=(0,Q.jsx)(Je,{title:C,children:O}),t[16]=C,t[17]=O,t[18]=k):k=t[18];let A;t[19]!==D||t[20]!==k?(A=(0,Q.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center justify-center gap-1.5`,children:[D,k]}),t[19]=D,t[20]=k,t[21]=A):A=t[21];let j;t[22]===i?j=t[23]:(j=i?(0,Q.jsx)(`span`,{className:`inline-flex min-w-0 items-center text-xs text-muted-foreground`,children:(0,Q.jsx)(`span`,{className:`truncate`,children:kg(i)})}):null,t[22]=i,t[23]=j);let M;t[24]!==i||t[25]!==p?(M=(0,Q.jsx)(Rq,{viewerContextId:p,cwd:i}),t[24]=i,t[25]=p,t[26]=M):M=t[26];let N;t[27]!==j||t[28]!==M?(N=(0,Q.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center justify-center gap-x-3`,children:[j,M]}),t[27]=j,t[28]=M,t[29]=N):N=t[29];let P;t[30]!==N||t[31]!==A?(P=(0,Q.jsxs)(`div`,{className:`absolute left-1/2 flex w-max max-w-[calc(100%-4rem)] -translate-x-1/2 flex-col items-center justify-center gap-0 text-center`,children:[A,N]}),t[30]=N,t[31]=A,t[32]=P):P=t[32];let F;t[33]!==i||t[34]!==p?(F=(0,Q.jsx)(zq,{viewerContextId:p,cwd:i}),t[33]=i,t[34]=p,t[35]=F):F=t[35];let I;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Q.jsx)(Je,{title:`Session menu`,children:(0,Q.jsx)(Ry,{render:(0,Q.jsx)(ss,{size:`icon`,variant:`ghost`,"aria-label":`Session menu`}),children:(0,Q.jsx)(za,{})})}),t[36]=I):I=t[36];let L;t[37]===n?L=t[38]:(L=()=>{n.current.createSession()},t[37]=n,t[38]=L);let R;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,Q.jsx)(`span`,{children:`Create new session`}),t[39]=R):R=t[39];let z;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Q.jsx)(Gy,{children:Uh(`Control+N`)}),t[40]=z):z=t[40];let B;t[41]===L?B=t[42]:(B=(0,Q.jsxs)(By,{onClick:L,children:[R,z]}),t[41]=L,t[42]=B);let V;t[43]!==n||t[44]!==r||t[45]!==u?(V=u.length>0?(0,Q.jsxs)(Vy,{children:[(0,Q.jsx)(Hy,{children:`New session in…`}),(0,Q.jsx)(Uy,{className:`w-72`,children:u.map(e=>(0,Q.jsxs)(By,{onClick:()=>{n.current.createSession(e.path)},children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.label}),(0,Q.jsx)(`span`,{className:`truncate`,children:Og(e.path)})]}),e.path===r?(0,Q.jsx)(Gy,{children:`Default`}):null]},e.path))})]}):null,t[43]=n,t[44]=r,t[45]=u,t[46]=V):V=t[46];let U;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Q.jsx)(Wy,{}),t[47]=U):U=t[47];let W=!h.sessionHasFile,G;t[48]===n?G=t[49]:(G=()=>{n.current.onToggleCurrentSessionPinned()},t[48]=n,t[49]=G);let ee=s?`Unpin from sidebar`:`Pin to sidebar`,te;t[50]===ee?te=t[51]:(te=(0,Q.jsx)(`span`,{children:ee}),t[50]=ee,t[51]=te);let K;t[52]!==W||t[53]!==G||t[54]!==te?(K=(0,Q.jsx)(By,{disabled:W,onClick:G,children:te}),t[52]=W,t[53]=G,t[54]=te,t[55]=K):K=t[55];let ne;t[56]===n?ne=t[57]:(ne=()=>{n.current.onRunCompact()},t[56]=n,t[57]=ne);let q;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,Q.jsx)(`span`,{children:`Compact session`}),t[58]=q):q=t[58];let J;t[59]===ne?J=t[60]:(J=(0,Q.jsx)(By,{onClick:ne,children:q}),t[59]=ne,t[60]=J);let re;t[61]===n?re=t[62]:(re=()=>{n.current.onTreeSession()},t[61]=n,t[62]=re);let Y,ie;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,Q.jsx)(`span`,{children:`Tree`}),ie=(0,Q.jsx)(Gy,{children:`Esc Esc`}),t[63]=Y,t[64]=ie):(Y=t[63],ie=t[64]);let ae;t[65]===re?ae=t[66]:(ae=(0,Q.jsxs)(By,{onClick:re,children:[Y,ie]}),t[65]=re,t[66]=ae);let oe;t[67]===n?oe=t[68]:(oe=()=>{n.current.onForkSession()},t[67]=n,t[68]=oe);let se;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Q.jsx)(`span`,{children:`Fork`}),t[69]=se):se=t[69];let ce;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,Q.jsx)(Gy,{children:Uh(`Control+F`)}),t[70]=ce):ce=t[70];let le;t[71]===oe?le=t[72]:(le=(0,Q.jsxs)(By,{onClick:oe,children:[se,ce]}),t[71]=oe,t[72]=le);let ue;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,Q.jsx)(Wy,{}),t[73]=ue):ue=t[73];let de;t[74]===n?de=t[75]:(de=()=>{n.current.onToggleHideThinking()},t[74]=n,t[75]=de);let fe=h.hideThinkingBlock?`Show thinking`:`Hide thinking`,pe;t[76]===fe?pe=t[77]:(pe=(0,Q.jsx)(`span`,{children:fe}),t[76]=fe,t[77]=pe);let me;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,Q.jsx)(Gy,{children:Uh(`Control+T`)}),t[78]=me):me=t[78];let he;t[79]!==de||t[80]!==pe?(he=(0,Q.jsxs)(By,{onClick:de,children:[pe,me]}),t[79]=de,t[80]=pe,t[81]=he):he=t[81];let ge;t[82]===n?ge=t[83]:(ge=()=>{n.current.onToggleHideToolBlocks()},t[82]=n,t[83]=ge);let _e=g?`Show tools`:`Hide tools`,ve;t[84]===_e?ve=t[85]:(ve=(0,Q.jsx)(`span`,{children:_e}),t[84]=_e,t[85]=ve);let ye;t[86]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,Q.jsx)(Gy,{children:Uh(`Control+O`)}),t[86]=ye):ye=t[86];let be;t[87]!==ge||t[88]!==ve?(be=(0,Q.jsxs)(By,{onClick:ge,children:[ve,ye]}),t[87]=ge,t[88]=ve,t[89]=be):be=t[89];let xe;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,Q.jsx)(Wy,{}),t[90]=xe):xe=t[90];let Se=!h.sessionHasFile,Ce;t[91]===n?Ce=t[92]:(Ce=()=>{n.current.onRenameSession()},t[91]=n,t[92]=Ce);let we;t[93]===Symbol.for(`react.memo_cache_sentinel`)?(we=(0,Q.jsx)(`span`,{children:`Rename session`}),t[93]=we):we=t[93];let Te;t[94]===Symbol.for(`react.memo_cache_sentinel`)?(Te=(0,Q.jsx)(Gy,{children:Uh(`Control+E`)}),t[94]=Te):Te=t[94];let Ee;t[95]!==Se||t[96]!==Ce?(Ee=(0,Q.jsxs)(By,{disabled:Se,onClick:Ce,children:[we,Te]}),t[95]=Se,t[96]=Ce,t[97]=Ee):Ee=t[97];let De=!h.sessionHasFile,Oe;t[98]===n?Oe=t[99]:(Oe=()=>{n.current.onDeleteCurrentSession()},t[98]=n,t[99]=Oe);let ke;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,Q.jsx)(`span`,{children:`Delete session`}),t[100]=ke):ke=t[100];let Ae;t[101]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=(0,Q.jsx)(Gy,{children:Uh(`Control+X`)}),t[101]=Ae):Ae=t[101];let je;t[102]!==De||t[103]!==Oe?(je=(0,Q.jsxs)(By,{variant:`destructive`,disabled:De,onClick:Oe,children:[ke,Ae]}),t[102]=De,t[103]=Oe,t[104]=je):je=t[104];let Me;t[105]!==B||t[106]!==V||t[107]!==K||t[108]!==J||t[109]!==ae||t[110]!==le||t[111]!==he||t[112]!==be||t[113]!==Ee||t[114]!==je?(Me=(0,Q.jsxs)(Ly,{children:[I,(0,Q.jsxs)(zy,{align:`end`,className:`w-56`,children:[B,V,U,K,J,ae,le,ue,he,be,xe,Ee,je]})]}),t[105]=B,t[106]=V,t[107]=K,t[108]=J,t[109]=ae,t[110]=le,t[111]=he,t[112]=be,t[113]=Ee,t[114]=je,t[115]=Me):Me=t[115];let Ne;t[116]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=Uh(`Control+\\`),t[116]=Ne):Ne=t[116];let Pe=a?`secondary`:`ghost`,Fe;t[117]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=(0,Q.jsx)(Xa,{}),t[117]=Fe):Fe=t[117];let Ie;t[118]!==a||t[119]!==d||t[120]!==Pe?(Ie=(0,Q.jsx)(Je,{title:`Toggle right sidebar`,kbd:Ne,children:(0,Q.jsx)(ss,{size:`icon`,variant:Pe,className:`hidden md:inline-flex`,"aria-pressed":a,"aria-label":`Toggle right sidebar`,onClick:d,children:Fe})}),t[118]=a,t[119]=d,t[120]=Pe,t[121]=Ie):Ie=t[121];let Le;t[122]!==F||t[123]!==Me||t[124]!==Ie?(Le=(0,Q.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-1`,children:[F,Me,Ie]}),t[122]=F,t[123]=Me,t[124]=Ie,t[125]=Le):Le=t[125];let Re;return t[126]!==P||t[127]!==T||t[128]!==E||t[129]!==Le?(Re=(0,Q.jsx)(`div`,{className:`sticky top-0 z-50 flex min-h-[var(--header-height)] w-full shrink-0 items-center border-b border-border/70 bg-background p-2`,children:(0,Q.jsxs)(`div`,{className:`relative flex w-full items-center gap-1`,children:[T,E,P,Le]})}),t[126]=P,t[127]=T,t[128]=E,t[129]=Le,t[130]=Re):Re=t[130],Re});function Iie(e){return{firstMessage:e.firstMessage,hideThinkingBlock:e.hideThinkingBlock,sessionHasFile:!!e.sessionFile,sessionName:e.sessionName,sessionStreaming:e.streaming}}function Lie(e){return e.hideToolBlocks}var Rie=250,zie=1e3,c9=1e3,l9=60*c9,u9=60*l9,d9=24*u9,Bie=7*d9,Vie=30*d9,Hie=365*d9;function Uie(e,t){let n=(0,$.c)(4),[r,i]=Z.useState(!1),a,o;return n[0]!==t||n[1]!==e?(a=()=>{if(!e){i(!1);return}let n=window.setTimeout(()=>{i(!0)},t);return()=>{window.clearTimeout(n)}},o=[t,e],n[0]=t,n[1]=e,n[2]=a,n[3]=o):(a=n[2],o=n[3]),Z.useEffect(a,o),r}function Wie(e){return e.replace(/^\/Users\/[^/]+(?=\/|$)/,`~`).replace(/^\/home\/[^/]+(?=\/|$)/,`~`)}function Gie(e){if(!e)return{leading:``,trailing:``};let t=e.replace(/[\\/]+$/,``);if(!t)return{leading:``,trailing:e};let n=e.slice(t.length),r=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return r<0||r===t.length-1?{leading:``,trailing:`${t}${n}`}:{leading:t.slice(0,r+1),trailing:`${t.slice(r+1)}${n}`}}function Kie(e){let t=(0,$.c)(10),{path:n}=e,r,i;t[0]===n?(r=t[1],i=t[2]):(r=Wie(n),i=Gie(r),t[0]=n,t[1]=r,t[2]=i);let{leading:a,trailing:o}=i,s;t[3]===a?s=t[4]:(s=a?(0,Q.jsx)(`span`,{className:`truncate text-sidebar-foreground/60`,children:a}):null,t[3]=a,t[4]=s);let c=o||r,l;t[5]===c?l=t[6]:(l=(0,Q.jsx)(`span`,{className:`shrink-0 font-medium`,children:c}),t[5]=c,t[6]=l);let u;return t[7]!==s||t[8]!==l?(u=(0,Q.jsx)(`span`,{className:`block min-w-0 text-sm text-sidebar-foreground`,children:(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[s,l]})}),t[7]=s,t[8]=l,t[9]=u):u=t[9],u}var f9=[],p9=`__pico_pinned_sessions__`,m9=`__pico_directories__`;function qie(){if(typeof window>`u`)return!1;let e=window.navigator.platform||window.navigator.userAgent;return/mac|iphone|ipad|ipod/i.test(e)}function Jie(e){return qie()?e.metaKey:e.ctrlKey}function h9(e,t=Date.now()){if(!e)return``;let n=new Date(e).getTime();if(Number.isNaN(n))return``;let r=t-n,i=r>=0,a=Math.max(1,Math.floor(Math.abs(r)/1e3)),o=i?``:`in `;if(a<60)return`${o}${a}s`;let s=Math.floor(a/60);if(s<60)return`${o}${s}m`;let c=Math.floor(s/60);if(c<24)return`${o}${c}h`;let l=Math.floor(c/24);if(l<7)return`${o}${l}d`;let u=Math.floor(l/7);if(u<5)return`${o}${u}w`;let d=Math.floor(l/30);if(d<12)return`${o}${Math.max(1,d)}mo`;let f=Math.floor(l/365);return`${o}${Math.max(1,f)}y`}function Yie(e){return e?!Number.isNaN(new Date(e).getTime()):!1}function Xie(e){let t=Math.max(1,Math.floor(e/c9));if(t<60)return c9;let n=Math.floor(t/60);if(n<60)return l9;let r=Math.floor(n/60);if(r<24)return u9;let i=Math.floor(r/24);return i<7?d9:Math.floor(i/7)<5?Bie:Math.floor(i/30)<12?Vie:Hie}function Zie(e,t=Date.now()){let n=t-e,r=Math.abs(n),i=Xie(r),a=r%i,o=n>=0?i-a:a||i;return Math.max(zie,o)}function Qie(e){let t=(0,$.c)(18),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({value:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===i?a=t[5]:(a=i?new Date(i).getTime():NaN,t[4]=i,t[5]=a);let o=a,s;t[6]===i?s=t[7]:(s=()=>h9(i),t[6]=i,t[7]=s);let[c,l]=Z.useState(s),u,d;if(t[8]!==o||t[9]!==i?(u=()=>{if(Number.isNaN(o)){l(``);return}let e,t=!1,n=()=>{if(t)return;let r=Date.now();l(h9(i,r)),e=window.setTimeout(n,Zie(o,r))};return n(),()=>{t=!0,e!==void 0&&window.clearTimeout(e)}},d=[o,i],t[8]=o,t[9]=i,t[10]=u,t[11]=d):(u=t[10],d=t[11]),Z.useEffect(u,d),!c)return null;let f;t[12]===n?f=t[13]:(f=rn(`tabular-nums`,n),t[12]=n,t[13]=f);let p;return t[14]!==c||t[15]!==r||t[16]!==f?(p=(0,Q.jsx)(`span`,{className:f,...r,children:c}),t[14]=c,t[15]=r,t[16]=f,t[17]=p):p=t[17],p}function g9(e,t){return e.length===t.length?e.every((e,n)=>e===t[n]):!1}function $ie(e,t){let n=Object.keys(e).sort();return g9(n,Object.keys(t).sort())?n.every(n=>!!e[n]==!!t[n]):!1}function eae(){let e=Lg({},$ie),t=()=>{ee(_n,JSON.stringify(e.state))};return Object.assign(e,{loadStored(){zg(e,ge())},toggle(t){e.setCollapsed(t,!e.state[t])},setCollapsed(n,r){zg(e,e=>{if(!!e[n]===r)return e;let t={...e};return r?t[n]=!0:delete t[n],t}),t()},setAll(n,r){zg(e,e=>{let t=!1,i={...e};for(let e of n)if(r){if(i[e])continue;i[e]=!0,t=!0}else{if(!i[e])continue;delete i[e],t=!0}return t?i:e}),t()},remove(n){zg(e,e=>{if(!e[n])return e;let t={...e};return delete t[n],t}),t()}}),e}function _9(e,t,n){let r=(0,$.c)(3),i;return r[0]!==t||r[1]!==n?(i=e=>n?!1:!!e[t],r[0]=t,r[1]=n,r[2]=i):i=r[2],Ji(e,i)}function tae(e,t){let n=(0,$.c)(2),r;return n[0]===t?r=n[1]:(r=e=>t.length>0&&t.every(t=>e[t]),n[0]=t,n[1]=r),Ji(e,r)}function nae(e){let t=(0,$.c)(17),{id:n,disabled:r,children:i}=e,a;t[0]!==r||t[1]!==n?(a={id:n,disabled:r},t[0]=r,t[1]=n,t[2]=a):a=t[2];let{attributes:o,listeners:s,setNodeRef:c,transform:l,transition:u,isDragging:d}=l7(a),f;t[3]===l?f=t[4]:(f=D6.Transform.toString(l),t[3]=l,t[4]=f);let p;t[5]!==f||t[6]!==u?(p={transform:f,transition:u},t[5]=f,t[6]=u,t[7]=p):p=t[7];let m=o,h=s,g;t[8]!==i||t[9]!==d||t[10]!==m||t[11]!==h?(g=i({attributes:m,listeners:h,isDragging:d}),t[8]=i,t[9]=d,t[10]=m,t[11]=h,t[12]=g):g=t[12];let _;return t[13]!==c||t[14]!==p||t[15]!==g?(_=(0,Q.jsx)(`div`,{ref:c,style:p,children:g}),t[13]=c,t[14]=p,t[15]=g,t[16]=_):_=t[16],_}function rae(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function iae(){let e=Lg(new Set,rae);return Object.assign(e,{setKeys(t){zg(e,new Set(t.filter(Boolean)))}}),e}function aae(e){let t=e?.trim()||``;return t?t.startsWith(`path:`)||t.startsWith(`id:`)?t:t.includes(`/`)||t.includes(`\\`)?xn({path:t}):t:``}function oae(){let e=Lg({sessionId:``,sessionKey:``});return Object.assign(e,{setActive(t){let n=t.sessionId||``,r=aae(t.sessionKey);zg(e,e=>e.sessionId===n&&e.sessionKey===r?e:{sessionId:n,sessionKey:r})}}),e}function sae(e,t){let n=(0,$.c)(2),r;return n[0]===t?r=n[1]:(r=e=>!!(t&&e.has(t)),n[0]=t,n[1]=r),Ji(e,r)}function cae(e,t,n){let r=(0,$.c)(3),i;return r[0]!==t||r[1]!==n?(i=e=>e.sessionKey&&t===e.sessionKey?!0:!!(e.sessionId&&n===e.sessionId),r[0]=t,r[1]=n,r[2]=i):i=r[2],Ji(e,i)}function v9(e){let t=(0,$.c)(54),{entryKey:n,directorySessionsStore:r,activeSessionStore:i,selectedSessionKeyStore:a,isPinned:o,isMobile:s,overlay:c,setOpenMobile:l,onSessionClick:u,onRenameSession:d,onDeleteSession:f,onTogglePinnedSession:p}=e,m=pae(r,n),h=sae(a,n),g=cae(i,n,m?.id);if(!m)return null;let _=m.lastMessageAt||m.modified||m.lastUserMessageAt,v;t[0]===_?v=t[1]:(v=Yie(_),t[0]=_,t[1]=v);let y=v,b;t[2]===m.lastMessagePreview?b=t[3]:(b=m.lastMessagePreview?.trim()||``,t[2]=m.lastMessagePreview,t[3]=b);let x=b,S;t[4]!==m.cwd||t[5]!==m.path||t[6]!==o?(S=o?Og(m.cwd?.trim()||m.path?.trim()||``):``,t[4]=m.cwd,t[5]=m.path,t[6]=o,t[7]=S):S=t[7];let C=S,w;t[8]!==y||t[9]!==_?(w=y&&_?new Date(_).toLocaleString():void 0,t[8]=y,t[9]=_,t[10]=w):w=t[10];let T=w,E=!!m.unread&&!m.streaming,D=!!(p||m.path&&(d||f))&&!c,O=g||h,k=(g||h)&&`bg-sidebar-accent text-sidebar-accent-foreground`,A;t[11]===k?A=t[12]:(A=rn(`relative h-auto min-w-0 items-start gap-2 py-2 pr-2 pl-8 not-data-active:hover:bg-transparent! not-data-active:hover:text-sidebar-foreground! not-data-active:data-open:hover:bg-transparent! not-data-active:data-open:hover:text-sidebar-foreground!`,k),t[11]=k,t[12]=A);let j;t[13]!==m||t[14]!==s||t[15]!==u||t[16]!==l?(j=e=>{u?.(m,{multiSelectKey:Jie(e),shiftKey:e.shiftKey}),s&&l(!1)},t[13]=m,t[14]=s,t[15]=u,t[16]=l,t[17]=j):j=t[17];let M;t[18]!==m.streaming||t[19]!==E?(M=m.streaming?(0,Q.jsx)(`span`,{className:`absolute top-2.5 left-2 flex size-4 items-center justify-center`,children:(0,Q.jsx)(H,{className:`size-3.5`,"aria-label":`Session streaming`})}):E?(0,Q.jsx)(`span`,{className:`absolute top-2.5 left-2 flex size-4 items-center justify-center`,children:(0,Q.jsx)(`span`,{className:`size-2 rounded-full bg-primary`,"aria-label":`Session done`})}):null,t[18]=m.streaming,t[19]=E,t[20]=M):M=t[20];let N;t[21]===m.title?N=t[22]:(N=(0,Q.jsx)(`span`,{className:`flex min-w-0 items-center gap-2`,children:(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate pr-16 font-medium`,children:m.title})}),t[21]=m.title,t[22]=N);let P;t[23]===x?P=t[24]:(P=x?(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-[11px] font-normal text-sidebar-foreground/50`,children:x}):null,t[23]=x,t[24]=P);let F;t[25]===C?F=t[26]:(F=C?(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-[11px] font-normal text-sidebar-foreground/50`,children:C}):null,t[25]=C,t[26]=F);let I;t[27]!==N||t[28]!==P||t[29]!==F?(I=(0,Q.jsx)(`span`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[N,P,F]})}),t[27]=N,t[28]=P,t[29]=F,t[30]=I):I=t[30];let L;t[31]!==n||t[32]!==I||t[33]!==O||t[34]!==A||t[35]!==j||t[36]!==M?(L=(0,Q.jsxs)(il,{type:`button`,"data-sidebar-session-item":!0,"data-session-key":n,isActive:O,className:A,onClick:j,children:[M,I]}),t[31]=n,t[32]=I,t[33]=O,t[34]=A,t[35]=j,t[36]=M,t[37]=L):L=t[37];let R=L,z;t[38]!==T||t[39]!==y||t[40]!==s||t[41]!==_?(z=y?(0,Q.jsx)(`span`,{className:`absolute top-2.5 right-2 z-10 flex min-w-4 items-center justify-end`,children:(0,Q.jsx)(Je,{title:s?void 0:T,side:`right`,align:`center`,children:(0,Q.jsx)(Qie,{value:_,className:`shrink-0 text-[11px] font-normal text-sidebar-foreground/50`})})}):null,t[38]=T,t[39]=y,t[40]=s,t[41]=_,t[42]=z):z=t[42];let B=z,V;t[43]!==R||t[44]!==B?(V=(0,Q.jsxs)(`div`,{className:`group/session relative`,children:[R,B]}),t[43]=R,t[44]=B,t[45]=V):V=t[45];let U=V,W;return t[46]!==m||t[47]!==D||t[48]!==o||t[49]!==f||t[50]!==d||t[51]!==p||t[52]!==U?(W=(0,Q.jsx)(nl,{children:D?(0,Q.jsxs)(d7,{children:[(0,Q.jsx)(f7,{render:U}),(0,Q.jsxs)(p7,{className:`w-44`,children:[p?(0,Q.jsx)(m7,{onClick:()=>p(m),children:o?`Unpin`:`Pin to sidebar`}):null,d&&m.path?(0,Q.jsx)(m7,{onClick:()=>d(m),children:`Rename`}):null,f&&m.path?(0,Q.jsx)(m7,{variant:`destructive`,onClick:()=>f(m),children:`Delete`}):null]})]}):U}),t[46]=m,t[47]=D,t[48]=o,t[49]=f,t[50]=d,t[51]=p,t[52]=U,t[53]=W):W=t[53],W}function y9(e,t){return e===t?!0:!e||!t?!1:e.path===t.path&&e.id===t.id&&e.cwd===t.cwd&&e.name===t.name&&e.title===t.title&&e.modified===t.modified&&e.lastUserMessageAt===t.lastUserMessageAt&&e.lastMessageAt===t.lastMessageAt&&e.lastMessagePreview===t.lastMessagePreview&&e.messageCount===t.messageCount&&JSON.stringify(e.contextUsage??null)===JSON.stringify(t.contextUsage??null)&&!!e.streaming==!!t.streaming&&!!e.unread==!!t.unread}function b9(e){let t=new Map;for(let n of Object.values(e))for(let e of n){let n=xn(e);!n||t.has(n)||t.set(n,e)}return t}function x9(e){let t={};for(let[n,r]of Object.entries(e))t[n]=r.map(e=>xn(e)).filter(Boolean);return t}function lae(e,t){return e.isLoadingSessions===t.isLoadingSessions&&g9(e.sessionKeys,t.sessionKeys)}function uae(e,t){let n=new Set([...Object.keys(e.sessionKeysByDirectory),...Object.keys(e.loadingByDirectory),...Object.keys(t.sessionKeysByDirectory),...Object.keys(t.loadingByDirectory)]);for(let r of n)if(!g9(e.sessionKeysByDirectory[r]??f9,t.sessionKeysByDirectory[r]??f9)||!!e.loadingByDirectory[r]!=!!t.loadingByDirectory[r])return!1;let r=new Set([...e.entriesByKey.keys(),...t.entriesByKey.keys()]);for(let n of r)if(!y9(e.entriesByKey.get(n),t.entriesByKey.get(n)))return!1;return!0}function dae(e,t){let n=Lg({sessionKeysByDirectory:x9(e),entriesByKey:b9(e),loadingByDirectory:t},uae);return Object.assign(n,{setData(e,t){zg(n,{sessionKeysByDirectory:x9(e),entriesByKey:b9(e),loadingByDirectory:t})}}),n}function fae(e,t){let n=(0,$.c)(3),r;n[0]===t?r=n[1]:(r=e=>({sessionKeys:e.sessionKeysByDirectory[t]??f9,isLoadingSessions:!!e.loadingByDirectory[t]}),n[0]=t,n[1]=r);let i;return n[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={compare:lae},n[2]=i):i=n[2],Ji(e,r,i)}function pae(e,t){let n=(0,$.c)(3),r;n[0]===t?r=n[1]:(r=e=>e.entriesByKey.get(t),n[0]=t,n[1]=r);let i;return n[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={compare:y9},n[2]=i):i=n[2],Ji(e,r,i)}var S9=Z.memo(function(e){let t=(0,$.c)(74),{directory:n,directorySessionsStore:r,collapsedDirectoryStore:i,searchActive:a,directoryOrderingEnabled:o,activeSessionStore:s,selectedSessionKeyStore:c,pinnedSessionKeys:l,isMobile:u,setOpenMobile:d,isDragging:f,overlay:p,attributes:m,listeners:h,onSessionClick:g,onRenameSession:_,onDeleteSession:v,onTogglePinnedSession:y,onCreateSessionInDirectory:b,onDeleteOldSessionsInDirectory:x,onRemoveDirectory:S}=e,C=p===void 0?!1:p,[w,T]=Z.useState(5),{isLoadingSessions:E,sessionKeys:D}=fae(r,n),O=_9(i,n,a),k;t[0]===l?k=t[1]:(k=new Set(l),t[0]=l,t[1]=k);let A=k,j;t[2]===A?j=t[3]:(j=e=>!A.has(e),t[2]=A,t[3]=j);let M=D.filter(j),N=a?M.length:Math.min(M.length,w),P=M.slice(0,N),F=N<M.length,I=Uie(E,Rie),L=E&&D.length===0,R=I&&M.length===0&&O,z=!C&&!!(b||x||S),B=o&&!C&&`cursor-grab active:cursor-grabbing`,V=a&&`cursor-default`,U;t[4]!==B||t[5]!==V?(U=rn(`group/directory-label flex min-w-0 flex-1 items-center gap-2 text-left text-sm text-sidebar-foreground`,B,V),t[4]=B,t[5]=V,t[6]=U):U=t[6];let W=a||C,G;t[7]===m?G=t[8]:(G=m??{},t[7]=m,t[8]=G);let ee;t[9]===h?ee=t[10]:(ee=h??{},t[9]=h,t[10]=ee);let te;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,Q.jsx)(Va,{className:`size-4 shrink-0 text-sidebar-foreground/50`}),t[11]=te):te=t[11];let K;t[12]===n?K=t[13]:(K=(0,Q.jsx)(`span`,{className:`max-w-full min-w-0`,children:(0,Q.jsx)(Kie,{path:n})}),t[12]=n,t[13]=K);let ne;t[14]!==O||t[15]!==a?(ne=a?null:O?(0,Q.jsx)(Na,{className:`size-4 shrink-0 opacity-0 transition-opacity group-hover/directory-label:opacity-100 group-focus-visible/directory-label:opacity-100`}):(0,Q.jsx)(Ma,{className:`size-4 shrink-0 opacity-0 transition-opacity group-hover/directory-label:opacity-100 group-focus-visible/directory-label:opacity-100`}),t[14]=O,t[15]=a,t[16]=ne):ne=t[16];let q;t[17]===R?q=t[18]:(q=R?(0,Q.jsx)(H,{className:`size-3.5 shrink-0`}):null,t[17]=R,t[18]=q);let J;t[19]!==K||t[20]!==ne||t[21]!==q||t[22]!==U||t[23]!==W||t[24]!==G||t[25]!==ee?(J=(0,Q.jsxs)(iW,{type:`button`,className:U,disabled:W,...G,...ee,children:[te,K,ne,q]}),t[19]=K,t[20]=ne,t[21]=q,t[22]=U,t[23]=W,t[24]=G,t[25]=ee,t[26]=J):J=t[26];let re;t[27]!==n||t[28]!==u||t[29]!==b||t[30]!==C?(re=b&&!C&&!u?(0,Q.jsx)(Je,{title:`Create a session in ${n}`,children:(0,Q.jsx)(ss,{size:`icon`,variant:`ghost`,className:`shrink-0 hover:bg-sidebar-accent/50 hover:text-sidebar-accent-foreground`,onClick:()=>b(n),children:(0,Q.jsx)(eo,{className:`size-4`})})}):null,t[27]=n,t[28]=u,t[29]=b,t[30]=C,t[31]=re):re=t[31];let Y;t[32]!==n||t[33]!==z||t[34]!==u||t[35]!==b||t[36]!==x||t[37]!==S?(Y=z&&u?(0,Q.jsxs)(Ly,{children:[(0,Q.jsx)(Ry,{render:(0,Q.jsx)(ss,{size:`icon`,variant:`ghost`,className:`shrink-0 hover:bg-sidebar-accent/50 hover:text-sidebar-accent-foreground`,"aria-label":`Directory actions for ${n}`}),children:(0,Q.jsx)(Ra,{className:`size-4`})}),(0,Q.jsxs)(zy,{align:`end`,className:`w-48`,children:[b?(0,Q.jsx)(By,{onClick:()=>b(n),children:`New session`}):null,x?(0,Q.jsx)(By,{onClick:()=>x(n),children:`Delete old sessions…`}):null,S?(0,Q.jsx)(By,{variant:`destructive`,onClick:()=>S(n),children:`Remove from sidebar`}):null]})]}):null,t[32]=n,t[33]=z,t[34]=u,t[35]=b,t[36]=x,t[37]=S,t[38]=Y):Y=t[38];let ie;t[39]!==J||t[40]!==re||t[41]!==Y?(ie=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg px-2`,children:[J,re,Y]}),t[39]=J,t[40]=re,t[41]=Y,t[42]=ie):ie=t[42];let ae=ie,oe=rW,se=!O,ce;t[43]!==i||t[44]!==n||t[45]!==C||t[46]!==a?(ce=e=>{a||C||i.setCollapsed(n,!e)},t[43]=i,t[44]=n,t[45]=C,t[46]=a,t[47]=ce):ce=t[47];let le=f&&!C&&`opacity-0`,ue;t[48]===le?ue=t[49]:(ue=rn(`rounded-lg py-1`,le),t[48]=le,t[49]=ue);let de=Qc,fe;t[50]!==n||t[51]!==ae||t[52]!==z||t[53]!==u||t[54]!==b||t[55]!==x||t[56]!==S?(fe=z&&!u?(0,Q.jsxs)(d7,{children:[(0,Q.jsx)(f7,{render:ae}),(0,Q.jsxs)(p7,{className:`w-48`,children:[b?(0,Q.jsx)(m7,{onClick:()=>b(n),children:`New session`}):null,x?(0,Q.jsx)(m7,{onClick:()=>x(n),children:`Delete old sessions…`}):null,S?(0,Q.jsx)(m7,{variant:`destructive`,onClick:()=>S(n),children:`Remove from sidebar`}):null]})]}):ae,t[50]=n,t[51]=ae,t[52]=z,t[53]=u,t[54]=b,t[55]=x,t[56]=S,t[57]=fe):fe=t[57];let pe=aW,me=el,he=L?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-2 text-sm text-sidebar-foreground/70`,children:[I?(0,Q.jsx)(H,{}):(0,Q.jsx)(`span`,{className:`size-4`,"aria-hidden":`true`}),`Loading sessions…`]}):M.length>0?(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(tl,{children:P.map(e=>(0,Q.jsx)(v9,{entryKey:e,directorySessionsStore:r,activeSessionStore:s,selectedSessionKeyStore:c,isPinned:l.includes(e),isMobile:u,overlay:C,setOpenMobile:d,onSessionClick:g,onRenameSession:_,onDeleteSession:v,onTogglePinnedSession:y},e))}),F&&!C?(0,Q.jsxs)(ss,{variant:`ghost`,className:`h-8 justify-start pl-8 text-sidebar-foreground/60 hover:bg-sidebar-accent/50 hover:text-sidebar-accent-foreground`,onClick:()=>{T(e=>Math.min(M.length,e+5))},children:[`Show`,` `,Math.min(5,M.length-N),` `,`more`]}):null]}):(0,Q.jsx)(`div`,{className:`px-2 py-2 text-sm text-sidebar-foreground/70`,children:a?`No matching unpinned sessions.`:`No unpinned sessions.`}),ge;t[58]!==me||t[59]!==he?(ge=(0,Q.jsx)(me,{children:he}),t[58]=me,t[59]=he,t[60]=ge):ge=t[60];let _e;t[61]!==pe||t[62]!==ge?(_e=(0,Q.jsx)(pe,{children:ge}),t[61]=pe,t[62]=ge,t[63]=_e):_e=t[63];let ve;t[64]!==de||t[65]!==fe||t[66]!==_e?(ve=(0,Q.jsxs)(de,{className:`py-0`,children:[fe,_e]}),t[64]=de,t[65]=fe,t[66]=_e,t[67]=ve):ve=t[67];let ye;return t[68]!==oe||t[69]!==se||t[70]!==ce||t[71]!==ue||t[72]!==ve?(ye=(0,Q.jsx)(oe,{open:se,onOpenChange:ce,className:ue,children:ve}),t[68]=oe,t[69]=se,t[70]=ce,t[71]=ue,t[72]=ve,t[73]=ye):ye=t[73],ye});function mae(e){let t=(0,$.c)(45),{pinnedSessionKeys:n,directorySessionsStore:r,collapsedDirectoryStore:i,searchActive:a,activeSessionStore:o,selectedSessionKeyStore:s,isMobile:c,setOpenMobile:l,onSessionClick:u,onRenameSession:d,onDeleteSession:f,onTogglePinnedSession:p}=e,m=_9(i,p9,a);if(n.length===0)return null;let h=!m,g;t[0]!==i||t[1]!==a?(g=e=>{a||i.setCollapsed(p9,!e)},t[0]=i,t[1]=a,t[2]=g):g=t[2];let _;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(iW,{className:`group/pinned-label justify-between gap-3`}),t[3]=_):_=t[3];let v;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:`Pinned`}),t[4]=v):v=t[4];let y;t[5]!==m||t[6]!==a?(y=a?null:m?(0,Q.jsx)(Na,{className:`size-4 shrink-0 opacity-0 transition-opacity group-hover/pinned-label:opacity-100 group-focus-visible/pinned-label:opacity-100`}):(0,Q.jsx)(Ma,{className:`size-4 shrink-0 opacity-0 transition-opacity group-hover/pinned-label:opacity-100 group-focus-visible/pinned-label:opacity-100`}),t[5]=m,t[6]=a,t[7]=y):y=t[7];let b;t[8]===y?b=t[9]:(b=(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[v,y]}),t[8]=y,t[9]=b);let x;t[10]===n.length?x=t[11]:(x=(0,Q.jsx)(`span`,{className:`text-[11px] font-normal text-sidebar-foreground/50`,children:n.length}),t[10]=n.length,t[11]=x);let S;t[12]!==b||t[13]!==x?(S=(0,Q.jsxs)($c,{render:_,children:[b,x]}),t[12]=b,t[13]=x,t[14]=S):S=t[14];let C;if(t[15]!==o||t[16]!==r||t[17]!==c||t[18]!==f||t[19]!==d||t[20]!==u||t[21]!==p||t[22]!==n||t[23]!==s||t[24]!==l){let e;t[26]!==o||t[27]!==r||t[28]!==c||t[29]!==f||t[30]!==d||t[31]!==u||t[32]!==p||t[33]!==s||t[34]!==l?(e=e=>(0,Q.jsx)(v9,{entryKey:e,directorySessionsStore:r,activeSessionStore:o,selectedSessionKeyStore:s,isPinned:!0,isMobile:c,overlay:!1,setOpenMobile:l,onSessionClick:u,onRenameSession:d,onDeleteSession:f,onTogglePinnedSession:p},e),t[26]=o,t[27]=r,t[28]=c,t[29]=f,t[30]=d,t[31]=u,t[32]=p,t[33]=s,t[34]=l,t[35]=e):e=t[35],C=n.map(e),t[15]=o,t[16]=r,t[17]=c,t[18]=f,t[19]=d,t[20]=u,t[21]=p,t[22]=n,t[23]=s,t[24]=l,t[25]=C}else C=t[25];let w;t[36]===C?w=t[37]:(w=(0,Q.jsx)(aW,{children:(0,Q.jsx)(el,{children:(0,Q.jsx)(tl,{children:C})})}),t[36]=C,t[37]=w);let T;t[38]!==w||t[39]!==S?(T=(0,Q.jsxs)(Qc,{className:`py-1`,children:[S,w]}),t[38]=w,t[39]=S,t[40]=T):T=t[40];let E;return t[41]!==h||t[42]!==T||t[43]!==g?(E=(0,Q.jsx)(rW,{open:h,onOpenChange:g,children:T}),t[41]=h,t[42]=T,t[43]=g,t[44]=E):E=t[44],E}function hae(e){let t=(0,$.c)(14),{searchActive:n,visibleDirectories:r,collapsedDirectoryStore:i}=e,a=tae(i,r),o=a?`Expand all directories`:`Collapse all directories`,s=n||r.length===0,c;t[0]!==a||t[1]!==i||t[2]!==r?(c=()=>{i.setAll(r,!a)},t[0]=a,t[1]=i,t[2]=r,t[3]=c):c=t[3];let l;t[4]===a?l=t[5]:(l=a?(0,Q.jsx)(Fa,{}):(0,Q.jsx)(Pa,{}),t[4]=a,t[5]=l);let u;t[6]!==s||t[7]!==c||t[8]!==l||t[9]!==o?(u=(0,Q.jsx)(ss,{size:`icon`,variant:`ghost`,className:`text-sidebar-foreground/70 hover:bg-sidebar-accent/50 hover:text-sidebar-accent-foreground`,disabled:s,onClick:c,"aria-label":o,children:l}),t[6]=s,t[7]=c,t[8]=l,t[9]=o,t[10]=u):u=t[10];let d;return t[11]!==u||t[12]!==o?(d=(0,Q.jsx)(Je,{title:o,children:u}),t[11]=u,t[12]=o,t[13]=d):d=t[13],d}function gae(e){let t=(0,$.c)(13),{onOpenSessionsDialog:n,onCreateSession:r}=e,i,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(Za,{}),a=(0,Q.jsx)(`span`,{children:`Search sessions...`}),t[0]=i,t[1]=a):(i=t[0],a=t[1]);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(`span`,{className:`ml-auto hidden items-center md:flex`,children:(0,Q.jsx)(Ot,{children:Uh(`Control+S`)})}),t[2]=o):o=t[2];let s;t[3]===n?s=t[4]:(s=(0,Q.jsx)(nl,{children:(0,Q.jsxs)(il,{type:`button`,onClick:n,children:[i,a,o]})}),t[3]=n,t[4]=s);let c,l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(eo,{}),l=(0,Q.jsx)(`span`,{children:`New session`}),t[5]=c,t[6]=l):(c=t[5],l=t[6]);let u;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(`span`,{className:`ml-auto hidden items-center md:flex`,children:(0,Q.jsx)(Ot,{children:Uh(`Control+N`)})}),t[7]=u):u=t[7];let d;t[8]===r?d=t[9]:(d=(0,Q.jsx)(nl,{children:(0,Q.jsxs)(il,{type:`button`,onClick:r,children:[c,l,u]})}),t[8]=r,t[9]=d);let f;return t[10]!==s||t[11]!==d?(f=(0,Q.jsx)(Yc,{className:`gap-2 border-b border-sidebar-border/70`,children:(0,Q.jsxs)(tl,{children:[s,d]})}),t[10]=s,t[11]=d,t[12]=f):f=t[12],f}function _ae(e){let t=(0,$.c)(25),{sessionSearch:n,visibleDirectories:r,matchingSessionCount:i,collapsed:a,collapsedDirectoryStore:o,onOpenAddDirectoryDialog:s}=e,c;t[0]===n?c=t[1]:(c=n.trim(),t[0]=n,t[1]=c);let l=c.length>0,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(iW,{className:`group/directories-label justify-between gap-3`}),t[2]=u):u=t[2];let d=l?`${i} matching session${i===1?``:`s`}`:`Directories`,f;t[3]===d?f=t[4]:(f=(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:d}),t[3]=d,t[4]=f);let p;t[5]!==a||t[6]!==l?(p=l?null:a?(0,Q.jsx)(Na,{className:`size-4 shrink-0 opacity-0 transition-opacity group-hover/directories-label:opacity-100 group-focus-visible/directories-label:opacity-100`}):(0,Q.jsx)(Ma,{className:`size-4 shrink-0 opacity-0 transition-opacity group-hover/directories-label:opacity-100 group-focus-visible/directories-label:opacity-100`}),t[5]=a,t[6]=l,t[7]=p):p=t[7];let m;t[8]!==f||t[9]!==p?(m=(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[f,p]}),t[8]=f,t[9]=p,t[10]=m):m=t[10];let h;t[11]!==o||t[12]!==l||t[13]!==r?(h=(0,Q.jsx)(hae,{searchActive:l,visibleDirectories:r,collapsedDirectoryStore:o}),t[11]=o,t[12]=l,t[13]=r,t[14]=h):h=t[14];let g;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(g=Uh(`Control+D`),t[15]=g):g=t[15];let _;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(Ba,{}),t[16]=_):_=t[16];let v;t[17]===s?v=t[18]:(v=(0,Q.jsx)(Je,{title:`Add directory`,kbd:g,children:(0,Q.jsx)(ss,{variant:`ghost`,size:`icon`,className:`hover:bg-sidebar-accent/50 hover:text-sidebar-accent-foreground`,onClick:s,"aria-label":`Add directory`,children:_})}),t[17]=s,t[18]=v);let y;t[19]!==v||t[20]!==h?(y=(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[h,v]}),t[19]=v,t[20]=h,t[21]=y):y=t[21];let b;return t[22]!==y||t[23]!==m?(b=(0,Q.jsxs)($c,{render:u,children:[m,y]}),t[22]=y,t[23]=m,t[24]=b):b=t[24],b}function vae(e){let t=(0,$.c)(125),{sessionSearch:n,onOpenSessionsDialog:r,visibleDirectories:i,directorySessionsStore:a,matchingSessionCount:o,selectedSessionKeys:s,activeSessionId:c,activeSessionKey:l,pinnedSessionKeys:u,emptyStateText:d,onCreateSession:f,onOpenAddDirectoryDialog:p,onOpenCommandPalette:m,onOpenSettings:h,onSessionClick:g,onRenameSession:_,onDeleteSession:v,onTogglePinnedSession:y,onCreateSessionInDirectory:b,onDeleteOldSessionsInDirectory:x,onRemoveDirectory:S,onReorderDirectories:C}=e,{isMobile:w,setOpenMobile:T}=Uc(),E;t[0]===n?E=t[1]:(E=n.trim(),t[0]=n,t[1]=E);let D=E.length>0,O=!D&&i.length>1,[k,A]=Z.useState(null),[j,M]=Z.useState(null),[N]=Z.useState(eae),[P]=Z.useState(iae),[F]=Z.useState(oae),I=_9(N,m9,D),L,R;t[2]!==P||t[3]!==s?(L=()=>{P.setKeys(s)},R=[P,s],t[2]=P,t[3]=s,t[4]=L,t[5]=R):(L=t[4],R=t[5]),Z.useLayoutEffect(L,R);let z,B;t[6]!==c||t[7]!==l||t[8]!==F?(z=()=>{F.setActive({sessionId:c,sessionKey:l})},B=[c,l,F],t[6]=c,t[7]=l,t[8]=F,t[9]=z,t[10]=B):(z=t[9],B=t[10]),Z.useLayoutEffect(z,B);let V;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(V={activationConstraint:{distance:6}},t[11]=V):V=t[11];let H=U6(H6(W8,V)),U,W;t[12]===N?(U=t[13],W=t[14]):(U=()=>{N.loadStored()},W=[N],t[12]=N,t[13]=U,t[14]=W),Z.useEffect(U,W);let G,ee;t[15]===O?(G=t[16],ee=t[17]):(ee=()=>{O||(A(null),M(null))},G=[O],t[15]=O,t[16]=G,t[17]=ee),Z.useEffect(ee,G);let te;bb0:{if(!j||j.length===0){te=i;break bb0}let e;t[18]===i?e=t[19]:(e=new Set(i),t[18]=i,t[19]=e);let n=e,r;if(t[20]!==j||t[21]!==i||t[22]!==n){let e;t[24]===n?e=t[25]:(e=e=>n.has(e),t[24]=n,t[25]=e);let a=j.filter(e),o=i.filter(e=>!a.includes(e));r=[...a,...o],t[20]=j,t[21]=i,t[22]=n,t[23]=r}else r=t[23];te=r}let K=te,ne,q;t[26]!==K||t[27]!==j||t[28]!==i?(ne=()=>{j&&g9(K,i)&&M(null)},q=[K,j,i],t[26]=K,t[27]=j,t[28]=i,t[29]=ne,t[30]=q):(ne=t[29],q=t[30]),Z.useEffect(ne,q);let J;t[31]!==N||t[32]!==S?(J=e=>{N.remove(e),S?.(e)},t[31]=N,t[32]=S,t[33]=J):J=t[33];let re=J,Y;t[34]===i?Y=t[35]:(Y=(e,t)=>{M(n=>{let r=n&&n.length>0?n:i,a=r.indexOf(e),o=r.indexOf(t);return a===-1||o===-1||a===o?n:e7(r,a,o)})},t[34]=i,t[35]=Y);let ie=Y,ae;t[36]===i?ae=t[37]:(ae=e=>{A(String(e.active.id)),M(i)},t[36]=i,t[37]=ae);let oe=ae,se;t[38]===ie?se=t[39]:(se=e=>{let t=String(e.active.id),n=e.over?String(e.over.id):``;!t||!n||t===n||ie(t,n)},t[38]=ie,t[39]=se);let ce=se,le;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(le=()=>{A(null),M(null)},t[40]=le):le=t[40];let ue=le,de;t[41]!==C||t[42]!==j||t[43]!==i?(de=e=>{let t=String(e.active.id),n=e.over?String(e.over.id):``,r=j;if((!r||r.length===0)&&t&&n&&t!==n){let e=i.indexOf(t),a=i.indexOf(n);e!==-1&&a!==-1&&(r=e7(i,e,a))}r&&r.length>0&&!g9(r,i)&&C?.(r),A(null),M(null)},t[41]=C,t[42]=j,t[43]=i,t[44]=de):de=t[44];let fe=de,pe;t[45]!==f||t[46]!==r?(pe=(0,Q.jsx)(gae,{onOpenSessionsDialog:r,onCreateSession:f}),t[45]=f,t[46]=r,t[47]=pe):pe=t[47];let me;t[48]!==F||t[49]!==N||t[50]!==a||t[51]!==w||t[52]!==v||t[53]!==_||t[54]!==g||t[55]!==y||t[56]!==u||t[57]!==D||t[58]!==P||t[59]!==T?(me=(0,Q.jsx)(mae,{pinnedSessionKeys:u,directorySessionsStore:a,collapsedDirectoryStore:N,searchActive:D,activeSessionStore:F,selectedSessionKeyStore:P,isMobile:w,setOpenMobile:T,onSessionClick:g,onRenameSession:_,onDeleteSession:v,onTogglePinnedSession:y}),t[48]=F,t[49]=N,t[50]=a,t[51]=w,t[52]=v,t[53]=_,t[54]=g,t[55]=y,t[56]=u,t[57]=D,t[58]=P,t[59]=T,t[60]=me):me=t[60];let he=!I,ge;t[61]!==N||t[62]!==D?(ge=e=>{D||N.setCollapsed(m9,!e)},t[61]=N,t[62]=D,t[63]=ge):ge=t[63];let _e;t[64]!==N||t[65]!==I||t[66]!==o||t[67]!==p||t[68]!==n||t[69]!==i?(_e=(0,Q.jsx)(_ae,{sessionSearch:n,visibleDirectories:i,matchingSessionCount:o,collapsed:I,collapsedDirectoryStore:N,onOpenAddDirectoryDialog:p}),t[64]=N,t[65]=I,t[66]=o,t[67]=p,t[68]=n,t[69]=i,t[70]=_e):_e=t[70];let ve;t[71]!==k||t[72]!==F||t[73]!==N||t[74]!==O||t[75]!==a||t[76]!==d||t[77]!==fe||t[78]!==ce||t[79]!==oe||t[80]!==w||t[81]!==b||t[82]!==x||t[83]!==v||t[84]!==S||t[85]!==_||t[86]!==g||t[87]!==y||t[88]!==K||t[89]!==u||t[90]!==re||t[91]!==D||t[92]!==P||t[93]!==H||t[94]!==T||t[95]!==i.length?(ve=(0,Q.jsx)(aW,{children:(0,Q.jsx)(el,{children:i.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-2`,children:(0,Q.jsx)(Dq,{className:`rounded-xl border border-dashed bg-sidebar-accent/10 py-10`,children:(0,Q.jsxs)(Oq,{children:[(0,Q.jsx)(Aq,{variant:`icon`,children:(0,Q.jsx)(Va,{})}),(0,Q.jsx)(jq,{children:d})]})})}):(0,Q.jsxs)(V5,{sensors:H,collisionDetection:Z6,onDragStart:O?oe:void 0,onDragOver:O?ce:void 0,onDragEnd:O?fe:void 0,onDragCancel:O?ue:void 0,children:[(0,Q.jsx)(s7,{items:K,strategy:Tne,children:K.map(e=>(0,Q.jsx)(nae,{id:e,disabled:!O,children:t=>{let{attributes:n,listeners:r,isDragging:i}=t;return(0,Q.jsx)(S9,{directory:e,directorySessionsStore:a,collapsedDirectoryStore:N,searchActive:D,directoryOrderingEnabled:O,activeSessionStore:F,selectedSessionKeyStore:P,pinnedSessionKeys:u,isMobile:w,setOpenMobile:T,isDragging:i,attributes:n,listeners:r,onSessionClick:g,onRenameSession:_,onDeleteSession:v,onTogglePinnedSession:y,onCreateSessionInDirectory:b,onDeleteOldSessionsInDirectory:x,onRemoveDirectory:S?re:void 0})}},e))}),(0,Q.jsx)($5,{children:k?(0,Q.jsx)(S9,{directory:k,directorySessionsStore:a,collapsedDirectoryStore:N,searchActive:D,directoryOrderingEnabled:O,activeSessionStore:F,selectedSessionKeyStore:P,pinnedSessionKeys:u,isMobile:w,setOpenMobile:T,overlay:!0,onSessionClick:g,onRenameSession:_,onDeleteSession:v,onTogglePinnedSession:y,onCreateSessionInDirectory:b,onDeleteOldSessionsInDirectory:x,onRemoveDirectory:S?re:void 0}):null})]})})}),t[71]=k,t[72]=F,t[73]=N,t[74]=O,t[75]=a,t[76]=d,t[77]=fe,t[78]=ce,t[79]=oe,t[80]=w,t[81]=b,t[82]=x,t[83]=v,t[84]=S,t[85]=_,t[86]=g,t[87]=y,t[88]=K,t[89]=u,t[90]=re,t[91]=D,t[92]=P,t[93]=H,t[94]=T,t[95]=i.length,t[96]=ve):ve=t[96];let ye;t[97]!==_e||t[98]!==ve?(ye=(0,Q.jsxs)(Qc,{className:`py-1`,children:[_e,ve]}),t[97]=_e,t[98]=ve,t[99]=ye):ye=t[99];let be;t[100]!==he||t[101]!==ge||t[102]!==ye?(be=(0,Q.jsx)(rW,{open:he,onOpenChange:ge,children:ye}),t[100]=he,t[101]=ge,t[102]=ye,t[103]=be):be=t[103];let xe;t[104]!==me||t[105]!==be?(xe=(0,Q.jsxs)(Zc,{children:[me,be]}),t[104]=me,t[105]=be,t[106]=xe):xe=t[106];let Se,Ce;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,Q.jsx)(kn,{}),Ce=(0,Q.jsx)(`span`,{children:`Commands`}),t[107]=Se,t[108]=Ce):(Se=t[107],Ce=t[108]);let we;t[109]===Symbol.for(`react.memo_cache_sentinel`)?(we=(0,Q.jsx)(`span`,{className:`ml-auto hidden items-center md:flex`,children:(0,Q.jsx)(Ot,{children:Uh(`Control+K`)})}),t[109]=we):we=t[109];let Te;t[110]===m?Te=t[111]:(Te=(0,Q.jsx)(nl,{children:(0,Q.jsxs)(il,{type:`button`,onClick:m,children:[Se,Ce,we]})}),t[110]=m,t[111]=Te);let Ee,De;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=(0,Q.jsx)(Qa,{}),De=(0,Q.jsx)(`span`,{children:`Settings`}),t[112]=Ee,t[113]=De):(Ee=t[112],De=t[113]);let Oe;t[114]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,Q.jsx)(`span`,{className:`ml-auto hidden items-center md:flex`,children:(0,Q.jsx)(Ot,{children:Uh(`Control+,`)})}),t[114]=Oe):Oe=t[114];let ke;t[115]===h?ke=t[116]:(ke=(0,Q.jsx)(nl,{children:(0,Q.jsxs)(il,{type:`button`,onClick:h,children:[Ee,De,Oe]})}),t[115]=h,t[116]=ke);let Ae;t[117]!==Te||t[118]!==ke?(Ae=(0,Q.jsx)(Xc,{className:`gap-2 border-t border-sidebar-border/70`,children:(0,Q.jsxs)(tl,{children:[Te,ke]})}),t[117]=Te,t[118]=ke,t[119]=Ae):Ae=t[119];let je;t[120]===Symbol.for(`react.memo_cache_sentinel`)?(je=(0,Q.jsx)(qc,{}),t[120]=je):je=t[120];let Me;return t[121]!==pe||t[122]!==xe||t[123]!==Ae?(Me=(0,Q.jsxs)(Gc,{collapsible:`offcanvas`,className:`top-(--header-height) !h-[calc(100svh-var(--header-height))] border-r border-sidebar-border/70`,children:[pe,xe,Ae,je]}),t[121]=pe,t[122]=xe,t[123]=Ae,t[124]=Me):Me=t[124],Me}var yae=`__pico_pinned_sessions__`;function bae(e,t){let n=t.sessionPath?.trim()||``,r=t.sessionId?.trim()||``;if(n){let t=xn({path:n});if(e.has(t))return t}if(r){let t=xn({id:r});if(e.has(t))return t}for(let[t,i]of e)if(n&&i.path===n||r&&i.id===r)return t;return``}function xae(e){let t=(0,$.c)(116),{viewerContextId:n,sidebarStore:r,sessionWorkspaceRef:i}=e,[a]=Z.useState(Vae),o=i_(r,Bae,Ag),s=i_(r,zae,jg),c=i_(r,Rae),l=i_(r,Lae,Kg),u=i_(r,Iae),d;t[0]===u?d=t[1]:(d=u.map(Fae).filter(Boolean),t[0]=u,t[1]=d);let f=d,p=i_(r,Pae,jg),m=i_(r,Nae,Ag),h=i_(r,Mae),g=i_(r,jae),_=i_(r,Aae,Ag),v=i_(r,kae,Oae),y=i_(r,Dae),b=v.activeSessionId,x=v.activeSessionKey,S=v.activeSessionPath,C=v.activeStreaming,w;if(t[2]!==l||t[3]!==m){let e;t[5]===l?e=t[6]:(e=(e,t)=>e+(l[t]?.length??0),t[5]=l,t[6]=e),w=m.reduce(e,0),t[2]=l,t[3]=m,t[4]=w}else w=t[4];let T=w,E=i_(r,Eae),D=i_(r,Tae),O=i_(r,wae),k;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(k={signature:``,key:``},t[7]=k):k=t[7];let A=Z.useRef(k),j=Z.useRef(0),M;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(M={},t[8]=M):M=t[8];let N=Z.useRef(M),P=Z.useRef(null),F;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(F=e=>{let t=j.current+1;j.current=t;for(let n of e)N.current[n]=t;return t},t[9]=F):F=t[9];let I=F,L;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(L=(e,t)=>e.filter(e=>N.current[e]===t),t[10]=L):L=t[10];let R=L,z;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(z=(e,t)=>{for(let n of e)N.current[n]===t&&delete N.current[n]},t[11]=z):z=t[11];let B=z,V,H;t[12]!==g||t[13]!==a||t[14]!==l||t[15]!==u?(V=()=>{a.setData(u.length>0?{...l,[yae]:u}:l,g)},H=[g,a,l,u],t[12]=g,t[13]=a,t[14]=l,t[15]=u,t[16]=V,t[17]=H):(V=t[16],H=t[17]),Z.useLayoutEffect(V,H);let U,W;t[18]===r?(U=t[19],W=t[20]):(U=()=>{let e=0,t=window.requestAnimationFrame(()=>{e=window.setTimeout(()=>{r.setSidebarDeferredDirectoryLoadingReady(!0)},0)});return()=>{window.cancelAnimationFrame(t),e&&window.clearTimeout(e)}},W=[r],t[18]=r,t[19]=U,t[20]=W),Z.useEffect(U,W);let G,te;t[21]!==o||t[22]!==r?(G=()=>{let e=new Set(o);r.setDirectoryIndexDataByPath(t=>{let n={};for(let[r,i]of Object.entries(t))e.has(r)&&(n[r]=i);return JSON.stringify(n)===JSON.stringify(t)?t:n}),r.setDirectoryIndexLoading(t=>{let n={};for(let[r,i]of Object.entries(t))e.has(r)&&(n[r]=i);return JSON.stringify(n)===JSON.stringify(t)?t:n});let t={};for(let[n,r]of Object.entries(N.current))e.has(n)&&(t[n]=r);N.current=t},te=[o,r],t[21]=o,t[22]=r,t[23]=G,t[24]=te):(G=t[23],te=t[24]),Z.useEffect(G,te);let K,ne;t[25]!==b||t[26]!==x||t[27]!==S||t[28]!==C||t[29]!==o||t[30]!==h||t[31]!==g||t[32]!==s||t[33]!==y||t[34]!==r||t[35]!==n?(K=()=>{if(!n||!y)return;let e=y.directoryIndexes||{},t=Object.keys(e);r.setSidebarState(n=>{let r=Jg(t.length?Ug(n.directoryIndexDataByPath,e):n.directoryIndexDataByPath,{sessionId:b,sessionPath:S}),i=t.length?Gg(n.directoryIndexLoading,t,!1):n.directoryIndexLoading,a=!Wg(n.directoryIndexDataByPath,r);return!a&&i===n.directoryIndexLoading?n:{directoryIndexDataByPath:a?r:n.directoryIndexDataByPath,directoryIndexLoading:i}});let i=P.current,a={},c=[];for(let e of o){let n=s.get(e)?.revision||``,r=i?.revisions[e]||``;a[e]=n,!t.includes(e)&&Object.prototype.hasOwnProperty.call(h,e)&&(g[e]||N.current[e]||r!==n&&(C||c.push(e)))}if(P.current={activeSessionId:b,activeSessionKey:x,activeSessionPath:S,revisions:a},c.length===0)return;let l=I(c);Hg({viewerContextId:n,directories:c}).then(e=>{let t=R(c,l);if(t.length===0)return;B(t,l);let n=Object.fromEntries(t.map(t=>[t,e.directoryIndexes[t]]).filter(Cae));r.setSidebarState(e=>{let r=Object.keys(n).length>0?Ug(e.directoryIndexDataByPath,n):e.directoryIndexDataByPath,i=Gg(e.directoryIndexLoading,t,!1);return r===e.directoryIndexDataByPath&&i===e.directoryIndexLoading?e:{directoryIndexDataByPath:r,directoryIndexLoading:i}})}).catch(e=>{let t=R(c,l);t.length!==0&&(B(t,l),r.setDirectoryIndexLoading(e=>Gg(e,t,!1)),Qe.error(e instanceof Error?e.message:`Failed to load sidebar sessions`))})},ne=[o,h,g,b,x,S,C,s,y,r,n],t[25]=b,t[26]=x,t[27]=S,t[28]=C,t[29]=o,t[30]=h,t[31]=g,t[32]=s,t[33]=y,t[34]=r,t[35]=n,t[36]=K,t[37]=ne):(K=t[36],ne=t[37]),Z.useEffect(K,ne);let q,J;t[38]!==b||t[39]!==x||t[40]!==S||t[41]!==r?(q=()=>{!b&&!x&&!S||r.setSidebarSessionStatusByKey(e=>Zg(e,{type:`session_status`,sessionKey:x,sessionId:b,sessionPath:S,unread:!1}))},J=[b,x,S,r],t[38]=b,t[39]=x,t[40]=S,t[41]=r,t[42]=q,t[43]=J):(q=t[42],J=t[43]),Z.useEffect(q,J);let re,Y;t[44]!==b||t[45]!==x||t[46]!==S||t[47]!==p||t[48]!==r?(re=()=>{let e=[b,S,x].join(`\0`),t=bae(p,{sessionId:b,sessionPath:S});!t&&x&&p.has(x)&&(t=x);let n=A.current;n.signature===e&&n.key===t||(A.current={signature:e,key:t},r.setSelectedSidebarSessionKeys(e=>{let n=t?[t]:[];return Ag(e,n)?e:n}),r.setSidebarSessionSelectionAnchor(e=>e===t?e:t))},Y=[b,x,S,p,r],t[44]=b,t[45]=x,t[46]=S,t[47]=p,t[48]=r,t[49]=re,t[50]=Y):(re=t[49],Y=t[50]),Z.useEffect(re,Y);let ie,ae;t[51]!==o||t[52]!==h||t[53]!==g||t[54]!==D||t[55]!==r||t[56]!==n?(ie=()=>{if(!n||!D)return;let e=o.filter(e=>!Object.prototype.hasOwnProperty.call(h,e)&&!g[e]&&!N.current[e]);if(e.length===0)return;let t=I(e);r.setDirectoryIndexLoading(t=>Gg(t,e,!0)),Hg({viewerContextId:n,directories:e}).then(n=>{let i=R(e,t);if(i.length===0)return;B(i,t);let a=Object.fromEntries(i.map(e=>[e,n.directoryIndexes[e]]).filter(Sae));r.setSidebarState(e=>{let t=Object.keys(a).length>0?Ug(e.directoryIndexDataByPath,a):e.directoryIndexDataByPath,n=Gg(e.directoryIndexLoading,i,!1);return t===e.directoryIndexDataByPath&&n===e.directoryIndexLoading?e:{directoryIndexDataByPath:t,directoryIndexLoading:n}})}).catch(n=>{let i=R(e,t);i.length!==0&&(B(i,t),r.setDirectoryIndexLoading(e=>Gg(e,i,!1)),Qe.error(n instanceof Error?n.message:`Failed to load sidebar sessions`))})},ae=[o,h,g,D,r,n],t[51]=o,t[52]=h,t[53]=g,t[54]=D,t[55]=r,t[56]=n,t[57]=ie,t[58]=ae):(ie=t[57],ae=t[58]),Z.useEffect(ie,ae);let oe,se;t[59]!==p||t[60]!==r?(oe=()=>{let e=new Set(p.keys());r.setSelectedSidebarSessionKeys(t=>{let n=t.filter(t=>e.has(t));return n.length===t.length?t:n}),r.setSidebarSessionSelectionAnchor(t=>t&&e.has(t)?t:``)},se=[p,r],t[59]=p,t[60]=r,t[61]=oe,t[62]=se):(oe=t[61],se=t[62]),Z.useEffect(oe,se);let ce;t[63]===r?ce=t[64]:(ce=e=>{let t=Xt(e);t.length!==0&&r.setSidebarDirectories(e=>{let n=Xt(e);return JSON.stringify(n)===JSON.stringify(t)?e:(ee(Me,JSON.stringify(t)),t)})},t[63]=r,t[64]=ce);let le=ce,ue;t[65]===r?ue=t[66]:(ue=e=>{let t=xn(e);t&&r.setPinnedSidebarSessionKeys(e=>{let n=fe(e),r=n.includes(t)?n.filter(e=>e!==t):[t,...n];return ee(Nt,JSON.stringify(r)),r})},t[65]=r,t[66]=ue);let de=ue,pe;t[67]===r?pe=t[68]:(pe=(e,t)=>{let n=t===void 0?``:t,i=fe(e),a=i.length===0?``:n&&i.includes(n)?n:i[i.length-1]??``;r.setSelectedSidebarSessionKeys(e=>Ag(e,i)?e:i),r.setSidebarSessionSelectionAnchor(e=>e===a?e:a)},t[67]=r,t[68]=pe);let me=pe,he;t[69]!==_||t[70]!==me||t[71]!==O?(he=e=>{let t=e.trim();if(!t)return;let n=qg(),r=n.indexOf(t);if(r<0){me([t],t);return}let i=n.includes(O)?O:_.find(e=>n.includes(e))??t,a=n.indexOf(i);if(a<0){me([t],t);return}let o=Math.min(a,r),s=Math.max(a,r);me(n.slice(o,s+1),i)},t[69]=_,t[70]=me,t[71]=O,t[72]=he):he=t[72];let ge=he,_e;t[73]!==ge||t[74]!==_||t[75]!==i||t[76]!==me?(_e=(e,t)=>{let n=xn(e);if(!n){e.id&&i.current?.selectSession(e.id,{sessionPath:e.path});return}if(t.shiftKey){ge(n);return}if(t.multiSelectKey){me(_.includes(n)?_.filter(e=>e!==n):[..._,n],n);return}me([n],n),e.id&&i.current?.selectSession(e.id,{sessionPath:e.path})},t[73]=ge,t[74]=_,t[75]=i,t[76]=me,t[77]=_e):_e=t[77];let ve=_e,ye;t[78]===i?ye=t[79]:(ye=()=>{i.current?.openSessionsDialog()},t[78]=i,t[79]=ye);let be=b||void 0,xe=x||void 0,Se,Ce,we,Te;t[80]===i?(Se=t[81],Ce=t[82],we=t[83],Te=t[84]):(Se=()=>{i.current?.createSession(void 0,{closeMobileSidebar:!0})},Ce=()=>{i.current?.openAddDirectoryDialog()},we=()=>{i.current?.openCommandPalette()},Te=()=>{i.current?.openSettingsDialog()},t[80]=i,t[81]=Se,t[82]=Ce,t[83]=we,t[84]=Te);let Ee,De;t[85]===i?(Ee=t[86],De=t[87]):(Ee=e=>{i.current?.openRenameDialogForEntry(e)},De=e=>{i.current?.openDeleteDialog([e])},t[85]=i,t[86]=Ee,t[87]=De);let Oe,ke;t[88]===i?(Oe=t[89],ke=t[90]):(Oe=e=>{i.current?.createSession(e,{closeMobileSidebar:!0})},ke=e=>{i.current?.openDeleteOldDirectorySessionsDialog(e)},t[88]=i,t[89]=Oe,t[90]=ke);let Ae;t[91]===r?Ae=t[92]:(Ae=e=>{r.setSidebarDirectories(t=>{let n=t.filter(t=>t!==e);return ee(Me,JSON.stringify(n)),n})},t[91]=r,t[92]=Ae);let je;return t[93]!==a||t[94]!==c||t[95]!==ve||t[96]!==T||t[97]!==f||t[98]!==le||t[99]!==_||t[100]!==E||t[101]!==ye||t[102]!==be||t[103]!==xe||t[104]!==Se||t[105]!==Ce||t[106]!==we||t[107]!==Te||t[108]!==Ee||t[109]!==De||t[110]!==Oe||t[111]!==ke||t[112]!==Ae||t[113]!==de||t[114]!==m?(je=(0,Q.jsx)(vae,{sessionSearch:E,onOpenSessionsDialog:ye,visibleDirectories:m,directorySessionsStore:a,matchingSessionCount:T,selectedSessionKeys:_,activeSessionId:be,activeSessionKey:xe,pinnedSessionKeys:f,emptyStateText:c,onCreateSession:Se,onOpenAddDirectoryDialog:Ce,onOpenCommandPalette:we,onOpenSettings:Te,onSessionClick:ve,onRenameSession:Ee,onDeleteSession:De,onTogglePinnedSession:de,onCreateSessionInDirectory:Oe,onDeleteOldSessionsInDirectory:ke,onRemoveDirectory:Ae,onReorderDirectories:le}),t[93]=a,t[94]=c,t[95]=ve,t[96]=T,t[97]=f,t[98]=le,t[99]=_,t[100]=E,t[101]=ye,t[102]=be,t[103]=xe,t[104]=Se,t[105]=Ce,t[106]=we,t[107]=Te,t[108]=Ee,t[109]=De,t[110]=Oe,t[111]=ke,t[112]=Ae,t[113]=de,t[114]=m,t[115]=je):je=t[115],je}function Sae(e){return!!e[1]}function Cae(e){return!!e[1]}function wae(e){return e.state.sidebarSessionSelectionAnchor}function Tae(e){return e.state.sidebarDeferredDirectoryLoadingReady}function Eae(e){return e.state.sessionSearch}function Dae(e){return e.state.sessionsEvent}function Oae(e,t){return e.activeSessionId===t.activeSessionId&&e.activeSessionKey===t.activeSessionKey&&e.activeSessionPath===t.activeSessionPath&&e.activeStreaming===t.activeStreaming&&e.event?.activeSessionId===t.event?.activeSessionId&&e.event?.activeSessionKey===t.event?.activeSessionKey&&e.event?.activeSessionPath===t.event?.activeSessionPath&&Ag(e.event?.directories||[],t.event?.directories||[])}function kae(e){let t=e.state.sessionsEvent,n=e.state.activeSidebarSessionId,r=e.state.activeSidebarSessionKey,i=e.state.activeSidebarSessionPath,a=e.state.sidebarSessionStatusByKey;return{event:t,activeSessionId:n,activeSessionKey:r,activeSessionPath:i,activeStreaming:!!((i?a[`path:${i}`]:void 0)||(n?a[`id:${n}`]:void 0)||(r?a[`key:${r}`]:void 0))?.streaming}}function Aae(e){return e.state.selectedSidebarSessionKeys}function jae(e){return e.state.directoryIndexLoading}function Mae(e){return e.state.directoryIndexDataByPath}function Nae(e){return e.derived.visibleDirectories}function Pae(e){return e.derived.sidebarSessionEntriesByKey}function Fae(e){return xn(e)}function Iae(e){return e.derived.pinnedSidebarSessions}function Lae(e){return e.derived.filteredDirectorySessions}function Rae(e){return e.derived.emptySidebarStateText}function zae(e){return e.derived.directoryStateByPath}function Bae(e){return e.derived.baseSidebarDirectories}function Vae(){return dae({},{})}var Hae=4e3,C9=`/sounds/session-done.mp3`,Uae=.85,w9=null,T9=null,E9=null;function Wae(){if(typeof window>`u`)return null;let e=window;return globalThis.AudioContext??e.webkitAudioContext??null}function D9(){if(typeof navigator>`u`)return!1;let e=navigator.userActivation;return e?e.isActive:!0}function O9({requireUserActivation:e=!1}={}){let t=Wae();if(!t)return null;if(!w9){if(e&&!D9())return null;w9=new t}return w9}async function k9(e){if(e.state===`suspended`){if(!D9())return!1;try{await e.resume()}catch{return!1}}return e.state===`running`}async function A9(e){return T9||(E9??=fetch(C9).then(e=>{if(!e.ok)throw Error(`Failed to load ${C9}`);return e.arrayBuffer()}).then(t=>e.decodeAudioData(t)).then(e=>(T9=e,e)).catch(()=>(E9=null,null)),E9)}function Gae(e){let t=e.createOscillator(),n=e.createGain();t.type=`triangle`,t.frequency.setValueAtTime(659.25,e.currentTime),t.frequency.linearRampToValueAtTime(783.99,e.currentTime+.12),n.gain.setValueAtTime(1e-4,e.currentTime),n.gain.exponentialRampToValueAtTime(.08,e.currentTime+.02),n.gain.exponentialRampToValueAtTime(1e-4,e.currentTime+.28),t.connect(n),n.connect(e.destination),t.start(e.currentTime),t.stop(e.currentTime+.3)}async function j9(){let e=O9({requireUserActivation:!0});return!e||!await k9(e)?!1:!!await A9(e)}async function M9(){let e=O9({requireUserActivation:!0});if(!e||!await k9(e))return!1;let t=await A9(e);if(!t)return Gae(e),!0;let n=e.createBufferSource(),r=e.createGain();return n.buffer=t,r.gain.value=Uae,n.connect(r),r.connect(e.destination),n.start(),!0}function Kae(){return typeof Notification>`u`?`unsupported`:Notification.permission}async function qae(){if(typeof Notification>`u`)return`unsupported`;let e=Notification.requestPermission();return typeof e==`string`?e:await e}function N9({title:e,body:t,tag:n}){if(typeof Notification>`u`||Notification.permission!==`granted`)return!1;try{let r=new Notification(e,{body:t,tag:n,silent:!0});return window.setTimeout(()=>{r.close()},Hae),!0}catch{return!1}}var P9=[`🌑`,`🌒`,`🌓`,`🌔`,`🌕`,`🌖`,`🌗`,`🌘`],Jae=500;function Yae(e){let t=(0,$.c)(20),{isSessionViewLoading:n,loadingDisplaySessionTitle:r,notificationStore:i,onSelectSession:a,sessionStore:o,sidebarStore:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={compare:Pg},t[0]=c):c=t[0];let l=Ji(o,Zae,c),u=Ji(i),d,f;t[1]===u.sessionDoneSoundEnabled?(d=t[2],f=t[3]):(d=()=>{if(!u.sessionDoneSoundEnabled)return;let e=Xae;return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,e,!0),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,e,!0)}},f=[u.sessionDoneSoundEnabled],t[1]=u.sessionDoneSoundEnabled,t[2]=d,t[3]=f),Z.useEffect(d,f);let p;t[4]===l?p=t[5]:(p=Fg(l),t[4]=l,t[5]=p);let m=p,h=n?r:l.uiTitle||(m===`New session`?`Pico`:m),g;t[6]===i?g=t[7]:(g=e=>{let t=new Set(e);Bg(i,`sessionDoneEvents`,e=>e.filter(e=>!t.has(e.id)))},t[6]=i,t[7]=g);let _=g,v;return t[8]!==h||t[9]!==u.sessionDoneDesktopNotificationsEnabled||t[10]!==u.sessionDoneEvents||t[11]!==u.sessionDoneSoundEnabled||t[12]!==_||t[13]!==a||t[14]!==l.activeSessionKey||t[15]!==l.activeSessionNotificationKey||t[16]!==l.sessionCwd||t[17]!==l.sessionStreaming||t[18]!==s?(v=(0,Q.jsx)(Qae,{activeSessionKey:l.activeSessionKey,activeSessionNotificationKey:l.activeSessionNotificationKey,currentPageTitle:h,sessionCwd:l.sessionCwd,sessionDoneDesktopNotificationsEnabled:u.sessionDoneDesktopNotificationsEnabled,sessionDoneSoundEnabled:u.sessionDoneSoundEnabled,sessionStreaming:l.sessionStreaming,sessionDoneEvents:u.sessionDoneEvents,sidebarStore:s,onConsumeSessionDoneEvents:_,onSelectSession:a}),t[8]=h,t[9]=u.sessionDoneDesktopNotificationsEnabled,t[10]=u.sessionDoneEvents,t[11]=u.sessionDoneSoundEnabled,t[12]=_,t[13]=a,t[14]=l.activeSessionKey,t[15]=l.activeSessionNotificationKey,t[16]=l.sessionCwd,t[17]=l.sessionStreaming,t[18]=s,t[19]=v):v=t[19],v}function Xae(){j9()}function Zae(e){return{activeSessionKey:e.sessionKey,activeSessionNotificationKey:Dg({sessionId:e.sessionId,sessionFile:e.sessionFile}),sessionCwd:e.cwd,sessionName:e.sessionName,sessionStreaming:e.streaming,firstMessage:e.firstMessage,uiTitle:e.uiState.title?.trim()||``}}function Qae(e){let t=(0,$.c)(30),{activeSessionKey:n,activeSessionNotificationKey:r,currentPageTitle:i,sessionCwd:a,sessionDoneDesktopNotificationsEnabled:o,sessionDoneSoundEnabled:s,sessionStreaming:c,sessionDoneEvents:l,sidebarStore:u,onConsumeSessionDoneEvents:d,onSelectSession:f}=e,[p,m]=Z.useState(roe),[h,g]=Z.useState(0),[_,v]=Z.useState(``),y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y=new Set,t[0]=y):y=t[0];let b=Z.useRef(y),x,S;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{let e=()=>{m(document.visibilityState===`visible`&&document.hasFocus())};return e(),window.addEventListener(`focus`,e),window.addEventListener(`blur`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),window.removeEventListener(`blur`,e),document.removeEventListener(`visibilitychange`,e)}},S=[],t[1]=x,t[2]=S):(x=t[1],S=t[2]),Z.useEffect(x,S);let C,w;t[3]!==r||t[4]!==p?(C=()=>{if(p||!r){v(``);return}v(e=>e&&e!==r?``:e)},w=[r,p],t[3]=r,t[4]=p,t[5]=C,t[6]=w):(C=t[5],w=t[6]),Z.useEffect(C,w);let T,E;t[7]===c?(T=t[8],E=t[9]):(T=()=>{if(!c){g(0);return}let e=window.setInterval(()=>{g(noe)},Jae);return()=>{window.clearInterval(e)}},E=[c],t[7]=c,t[8]=T,t[9]=E),Z.useEffect(T,E);let D,O;t[10]!==n||t[11]!==r||t[12]!==p||t[13]!==d||t[14]!==f||t[15]!==a||t[16]!==o||t[17]!==l||t[18]!==s?(D=()=>{if(l.length===0)return;let e=[],t=!1;for(let i of l){if(e.push(i.id),b.current.has(i.id))continue;b.current.add(i.id);let c=Dg({sessionId:i.sessionId,sessionPath:i.sessionPath}),l=!!(c&&r&&c===r||i.sessionKey&&n&&i.sessionKey===n),u=ite(i),d=i.cwd||a||`Open Pico to continue`,m=i.sessionPath||i.sessionId||i.id;if(l){!p&&c&&v(c),o&&!p&&N9({title:u,body:d,tag:m}),s&&!p&&!t&&(t=!0,M9());continue}if(i.sessionId){let e=i.sessionId,t=i.id;Qe.success(u,{id:t,className:`cursor-pointer`,action:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Open ${u}`,className:`absolute inset-0 z-10 cursor-pointer rounded-[var(--border-radius)] bg-transparent p-0 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none`,onClick:()=>{Qe.dismiss(t),f(e)}})})}else Qe.success(u);o&&!p&&N9({title:u,body:d,tag:m}),s&&!t&&(t=!0,M9())}d(e)},O=[n,r,p,d,f,a,o,l,s],t[10]=n,t[11]=r,t[12]=p,t[13]=d,t[14]=f,t[15]=a,t[16]=o,t[17]=l,t[18]=s,t[19]=D,t[20]=O):(D=t[19],O=t[20]),Z.useEffect(D,O);let k=Ji(u,$ae),A;t[21]!==_||t[22]!==k?(A=new Set(k?k.split(`
|
|
2148
|
+
`,Zne=QY(`complete`),Qne=vX({set:`complete`,colored:!0});function x7(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none block h-0 w-0 overflow-hidden`,dangerouslySetInnerHTML:{__html:Zne}}),e[0]=t):t=e[0],t}function S7(e){let t=(0,$.c)(25),{path:n}=e,r,i,a,o,s,c,l,u,d,f;if(t[0]!==n){let e=Qne.resolveIcon(`file-tree-icon-file`,n),p=e.token?eX(e.token):void 0;a=`true`,o=`size-4 shrink-0 text-muted-foreground`,s=e.remappedFrom??e.name,c=e.token,l=`false`,u=p?{color:p}:void 0,d=e.viewBox??`0 0 ${e.width??16} ${e.height??16}`,f=e.width??16,i=e.height??16;let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=/^#/,t[11]=m):m=t[11],r=e.name.replace(m,``),t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];let p=`#${r}`,m;t[12]===p?m=t[13]:(m=(0,Q.jsx)(`use`,{href:p}),t[12]=p,t[13]=m);let h;return t[14]!==i||t[15]!==m||t[16]!==a||t[17]!==o||t[18]!==s||t[19]!==c||t[20]!==l||t[21]!==u||t[22]!==d||t[23]!==f?(h=(0,Q.jsx)(`svg`,{"aria-hidden":a,className:o,"data-icon-name":s,"data-icon-token":c,focusable:l,style:u,viewBox:d,width:f,height:i,children:m}),t[14]=i,t[15]=m,t[16]=a,t[17]=o,t[18]=s,t[19]=c,t[20]=l,t[21]=u,t[22]=d,t[23]=f,t[24]=h):h=t[24],h}function $ne(e){return e?.isDirectory()===!0}function ere(e){let t=new Set;for(let n of e){let e=n.split(`/`).filter(Boolean);for(let n=1;n<e.length;n+=1)t.add(`${e.slice(0,n).join(`/`)}/`)}return[...t].sort((e,t)=>t.split(`/`).length-e.split(`/`).length||t.length-e.length||t.localeCompare(e))}function tre({collapseAllRevision:e,paths:t,selectedPath:n,onSelectFile:r}){let i=Z.useRef(new Set(t)),a=Z.useRef(r),o=Z.useRef(0);i.current=new Set(t),a.current=r;let{model:s}=t6({paths:t,flattenEmptyDirectories:!0,initialExpansion:1,initialSelectedPaths:n?[n]:[],onSelectionChange:e=>{let[t]=e;!t||!i.current.has(t)||a.current(t)},search:!0,unsafeCSS:Xne});Z.useEffect(()=>{s.resetPaths(t)},[s,t]),Z.useEffect(()=>{if(!n)return;let e=s.getItem(n);if(e){for(let e of s.getSelectedPaths())e!==n&&s.getItem(e)?.deselect();e.select(),e.focus()}},[s,n]),Z.useEffect(()=>{if(!(e<=0||e===o.current||t.length===0)){o.current=e;for(let e of ere(t)){let t=s.getItem(e);!$ne(t)||!t.isExpanded()||t.collapse()}s.focusNearestPath(n||s.getFocusedPath())}},[e,s,t,n]);let c=()=>{window.requestAnimationFrame(()=>{let e=s.getFocusedPath();!e||!i.current.has(e)||a.current(e)})};return(0,Q.jsx)(e6,{model:s,className:`block h-full min-h-0 w-full overflow-hidden`,onClick:c,onKeyUp:e=>{e.key!==`Enter`&&e.key!==` `||c()}})}function C7(e){let t=(0,$.c)(59),{viewerContextId:n,cwd:r,active:i,activeFilePath:a,onCloseFile:o,onOpenFile:s,previewMode:c}=e,l=c===void 0?`external`:c,u=a_(r),[d,f]=Z.useState(!1),[p,m]=Z.useState(0),h=l===`inline`&&!!a,g=b7({viewerContextId:n,cwd:u}),_=!!(i&&n&&u),v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=[`data`,`isPending`,`error`],t[0]=v):v=t[0];let y;t[1]!==g||t[2]!==_?(y={...g,enabled:_,select:rre,notifyOnChangeProps:v},t[1]=g,t[2]=_,t[3]=y):y=t[3];let b=Or(y),x;t[4]===b.data?x=t[5]:(x=b.data??[],t[4]=b.data,t[5]=x);let S=x,C=h?`grid grid-rows-[minmax(0,1fr)_minmax(0,1fr)]`:`flex flex-col`,w;t[6]===C?w=t[7]:(w=rn(`h-full min-h-0 overflow-hidden`,C),t[6]=C,t[7]=w);let T=h?`border-b border-border/70`:`flex-1 overflow-hidden`,E;t[8]===T?E=t[9]:(E=rn(`flex min-h-0 flex-col bg-background`,T),t[8]=T,t[9]=E);let D;t[10]===S.length?D=t[11]:(D=S.length.toLocaleString(),t[10]=S.length,t[11]=D);let O;t[12]===D?O=t[13]:(O=(0,Q.jsxs)(`div`,{className:`text-xs font-bold tracking-[0.04em] text-muted-foreground uppercase`,children:[D,` files`]}),t[12]=D,t[13]=O);let k=S.length===0,A;t[14]===m?A=t[15]:(A=()=>{m(nre)},t[14]=m,t[15]=A);let j;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Q.jsx)(Pa,{className:`size-4`}),t[16]=j):j=t[16];let M;t[17]!==k||t[18]!==A?(M=(0,Q.jsx)(Je,{title:`Collapse all folders`,children:(0,Q.jsx)(ss,{type:`button`,variant:`outline`,size:`icon`,"aria-label":`Collapse all folders`,disabled:k,onClick:A,children:j})}),t[17]=k,t[18]=A,t[19]=M):M=t[19];let N;t[20]===f?N=t[21]:(N=(0,Q.jsx)(ss,{type:`button`,variant:`outline`,onClick:()=>{f(!0)},children:`Open File`}),t[20]=f,t[21]=N);let P;t[22]!==M||t[23]!==N?(P=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[M,N]}),t[22]=M,t[23]=N,t[24]=P):P=t[24];let F;t[25]!==O||t[26]!==P?(F=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-border/70 p-2`,children:[O,P]}),t[25]=O,t[26]=P,t[27]=F):F=t[27];let I;t[28]!==a||t[29]!==p||t[30]!==b.data||t[31]!==b.error||t[32]!==b.isPending||t[33]!==u||t[34]!==s||t[35]!==S||t[36]!==n?(I=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden p-2`,children:u?n?b.isPending&&b.data===void 0?(0,Q.jsxs)(h7,{children:[(0,Q.jsx)(H,{}),` Loading files…`]}):b.error?(0,Q.jsx)(h7,{tone:`destructive`,children:c_(b.error,`Failed to load files`)}):S.length>0?(0,Q.jsx)(tre,{collapseAllRevision:p,paths:S,selectedPath:a,onSelectFile:s}):(0,Q.jsx)(h7,{children:`No files found.`}):(0,Q.jsx)(h7,{children:`Waiting for viewer context…`}):(0,Q.jsx)(h7,{children:`No directory selected.`})}),t[28]=a,t[29]=p,t[30]=b.data,t[31]=b.error,t[32]=b.isPending,t[33]=u,t[34]=s,t[35]=S,t[36]=n,t[37]=I):I=t[37];let L;t[38]!==E||t[39]!==F||t[40]!==I?(L=(0,Q.jsxs)(`div`,{className:E,children:[F,I]}),t[38]=E,t[39]=F,t[40]=I,t[41]=L):L=t[41];let R;t[42]!==i||t[43]!==a||t[44]!==u||t[45]!==o||t[46]!==h||t[47]!==n?(R=h?(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden bg-background`,children:[(0,Q.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center justify-between gap-2 border-b border-border/70 px-3 text-xs font-medium text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,title:a,children:a}),(0,Q.jsx)(Je,{title:`Close file preview`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Close file preview`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,onClick:o,children:(0,Q.jsx)(no,{className:`size-4`})})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,Q.jsx)(T7,{viewerContextId:n,cwd:u,active:i,path:a})})]}):null,t[42]=i,t[43]=a,t[44]=u,t[45]=o,t[46]=h,t[47]=n,t[48]=R):R=t[48];let z;t[49]!==s||t[50]!==d||t[51]!==S||t[52]!==f?(z=(0,Q.jsx)(w7,{open:d,onOpenChange:f,paths:S,onOpenFile:s}),t[49]=s,t[50]=d,t[51]=S,t[52]=f,t[53]=z):z=t[53];let B;return t[54]!==L||t[55]!==R||t[56]!==z||t[57]!==w?(B=(0,Q.jsxs)(`div`,{className:w,children:[L,R,z]}),t[54]=L,t[55]=R,t[56]=z,t[57]=w,t[58]=B):B=t[58],B}function nre(e){return e+1}function rre(e){return e.paths}function w7(e){let t=(0,$.c)(23),{open:n,onOpenChange:r,paths:i,onOpenFile:a}=e,[o,s]=Z.useState(``),c,l;t[0]===n?(c=t[1],l=t[2]):(c=()=>{n||s(``)},l=[n],t[0]=n,t[1]=c,t[2]=l),Z.useEffect(c,l);let u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(x7,{}),t[3]=u):u=t[3];let d;t[4]===o?d=t[5]:(d=(0,Q.jsx)(kp,{value:o,onValueChange:s,placeholder:`Search files…`}),t[4]=o,t[5]=d);let f;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(jp,{children:`No files found.`}),t[6]=f):f=t[6];let p;if(t[7]!==r||t[8]!==a||t[9]!==i){let e;t[11]!==r||t[12]!==a?(e=e=>(0,Q.jsxs)(Np,{value:e,keywords:[e],onSelect:()=>{a(e),r(!1)},children:[(0,Q.jsx)(S7,{path:e}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:e})]},e),t[11]=r,t[12]=a,t[13]=e):e=t[13],p=i.map(e),t[7]=r,t[8]=a,t[9]=i,t[10]=p}else p=t[10];let m;t[14]===p?m=t[15]:(m=(0,Q.jsxs)(Ap,{children:[f,(0,Q.jsx)(Mp,{heading:`Files`,children:p})]}),t[14]=p,t[15]=m);let h;t[16]!==d||t[17]!==m?(h=(0,Q.jsxs)(Dp,{shouldFilter:!0,children:[u,d,m]}),t[16]=d,t[17]=m,t[18]=h):h=t[18];let g;return t[19]!==r||t[20]!==n||t[21]!==h?(g=(0,Q.jsx)(Op,{open:n,onOpenChange:r,title:`Open Files`,description:`Search project files to open.`,children:h}),t[19]=r,t[20]=n,t[21]=h,t[22]=g):g=t[22],g}function T7(e){let t=(0,$.c)(25),{viewerContextId:n,cwd:r,active:i,path:a}=e,o,s,c;t[0]!==r||t[1]!==a||t[2]!==n?(o=a_(r),c=Or,s=Yne({viewerContextId:n,cwd:o,path:a}),t[0]=r,t[1]=a,t[2]=n,t[3]=o,t[4]=s,t[5]=c):(o=t[3],s=t[4],c=t[5]);let l=!!(i&&n&&o&&a),u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(u=[`data`,`isPending`,`error`],t[6]=u):u=t[6];let d;t[7]!==s||t[8]!==l?(d={...s,enabled:l,notifyOnChangeProps:u},t[7]=s,t[8]=l,t[9]=d):d=t[9];let f=c(d),p=f.data?.content??``,m;t[10]===a?m=t[11]:(m=Kne(a),t[10]=a,t[11]=m);let h=m,[g,_]=Z.useState(null),v,y;if(t[12]!==i||t[13]!==p||t[14]!==h?(v=()=>{let e=!1;if(!i||!p||!h){_(null);return}return _(null),Jne(p,h).then(t=>{e||_(t)}).catch(()=>{e||_({ok:!0,unavailable:!0})}),()=>{e=!0}},y=[i,p,h],t[12]=i,t[13]=p,t[14]=h,t[15]=v,t[16]=y):(v=t[15],y=t[16]),Z.useEffect(v,y),!a){let e;return t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-center text-sm text-muted-foreground`,children:`Select a file to preview it.`}),t[17]=e):e=t[17],e}let b;return t[18]!==p||t[19]!==f.data||t[20]!==f.error||t[21]!==f.isPending||t[22]!==g||t[23]!==h?(b=(0,Q.jsx)(`div`,{className:`h-full min-h-0 overflow-auto bg-background`,children:f.isPending&&!f.data?(0,Q.jsx)(`div`,{className:`p-4`,children:(0,Q.jsxs)(h7,{children:[(0,Q.jsx)(H,{}),` Loading file…`]})}):f.error?(0,Q.jsx)(`div`,{className:`p-4`,children:(0,Q.jsx)(h7,{tone:`destructive`,children:c_(f.error,`Failed to load file`)})}):qne(g)?(0,Q.jsx)(`pre`,{className:`m-0 min-h-full p-4 font-mono text-[13px] leading-5 whitespace-pre-wrap text-foreground`,children:(0,Q.jsx)(`code`,{className:rn(h&&`language-${h}`),dangerouslySetInnerHTML:{__html:g.html}})}):(0,Q.jsx)(`pre`,{className:`m-0 min-h-full p-4 font-mono text-[13px] leading-5 whitespace-pre-wrap text-foreground`,children:(0,Q.jsx)(`code`,{children:p})})}),t[18]=p,t[19]=f.data,t[20]=f.error,t[21]=f.isPending,t[22]=g,t[23]=h,t[24]=b):b=t[24],b}function E7(e){let t=(0,$.c)(62),{active:n,dragging:r,dragListeners:i,dragAttributes:a,index:o,onActiveFileChange:s,onActiveTabChange:c,onCloseAllFiles:l,onCloseFile:u,onCloseFilesToRight:d,onCloseOtherFiles:f,path:p,preview:m,tabCount:h}=e,g=r===void 0?!1:r,_=n&&`bg-muted text-foreground`,v=g&&`border-transparent shadow-none ring-0`,y;t[0]!==_||t[1]!==v?(y=rn(`inline-flex h-8 max-w-56 shrink-0 items-center rounded-md border border-transparent text-sm font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,_,v),t[0]=_,t[1]=v,t[2]=y):y=t[2];let b;t[3]!==s||t[4]!==c||t[5]!==p?(b=()=>{c(`files`),s?.(p)},t[3]=s,t[4]=c,t[5]=p,t[6]=b):b=t[6];let x;t[7]===p?x=t[8]:(x=(0,Q.jsx)(S7,{path:p}),t[7]=p,t[8]=x);let S=m&&`italic`,C;t[9]===S?C=t[10]:(C=rn(`block min-w-0 truncate`,S),t[9]=S,t[10]=C);let w;t[11]===p?w=t[12]:(w=pre(p),t[11]=p,t[12]=w);let T;t[13]!==C||t[14]!==w?(T=(0,Q.jsx)(`span`,{className:C,children:w}),t[13]=C,t[14]=w,t[15]=T):T=t[15];let E;t[16]!==p||t[17]!==T||t[18]!==b||t[19]!==x?(E=(0,Q.jsxs)(`button`,{type:`button`,title:p,className:`flex min-w-0 flex-1 items-center gap-1.5 px-2.5 text-left`,onClick:b,children:[x,T]}),t[16]=p,t[17]=T,t[18]=b,t[19]=x,t[20]=E):E=t[20];let D=`Close ${p}`,O;t[21]!==u||t[22]!==p?(O=()=>{u?.(p)},t[21]=u,t[22]=p,t[23]=O):O=t[23];let k;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Q.jsx)(no,{className:`size-3`}),t[24]=k):k=t[24];let A;t[25]!==D||t[26]!==O?(A=(0,Q.jsx)(`button`,{type:`button`,"aria-label":D,className:`mr-1 inline-flex size-4 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-muted hover:text-foreground`,onClick:O,children:k}),t[25]=D,t[26]=O,t[27]=A):A=t[27];let j;t[28]!==a||t[29]!==i||t[30]!==E||t[31]!==A||t[32]!==y?(j=(0,Q.jsxs)(`div`,{className:y,...a,...i,children:[E,A]}),t[28]=a,t[29]=i,t[30]=E,t[31]=A,t[32]=y,t[33]=j):j=t[33];let M=j,N;t[34]===M?N=t[35]:(N=(0,Q.jsx)(f7,{render:M}),t[34]=M,t[35]=N);let P;t[36]!==u||t[37]!==p?(P=(0,Q.jsx)(m7,{onClick:()=>u?.(p),children:`Close`}),t[36]=u,t[37]=p,t[38]=P):P=t[38];let F=h<=1,I;t[39]!==f||t[40]!==p?(I=()=>f?.(p),t[39]=f,t[40]=p,t[41]=I):I=t[41];let L;t[42]!==F||t[43]!==I?(L=(0,Q.jsx)(m7,{disabled:F,onClick:I,children:`Close others`}),t[42]=F,t[43]=I,t[44]=L):L=t[44];let R=o>=h-1,z;t[45]!==d||t[46]!==p?(z=()=>d?.(p),t[45]=d,t[46]=p,t[47]=z):z=t[47];let B;t[48]!==R||t[49]!==z?(B=(0,Q.jsx)(m7,{disabled:R,onClick:z,children:`Close to the right`}),t[48]=R,t[49]=z,t[50]=B):B=t[50];let V;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Q.jsx)(Vne,{}),t[51]=V):V=t[51];let H;t[52]===l?H=t[53]:(H=(0,Q.jsx)(m7,{onClick:()=>l?.(),children:`Close all`}),t[52]=l,t[53]=H);let U;t[54]!==P||t[55]!==L||t[56]!==B||t[57]!==H?(U=(0,Q.jsxs)(p7,{className:`w-44`,children:[P,L,B,V,H]}),t[54]=P,t[55]=L,t[56]=B,t[57]=H,t[58]=U):U=t[58];let W;return t[59]!==N||t[60]!==U?(W=(0,Q.jsxs)(d7,{children:[N,U]}),t[59]=N,t[60]=U,t[61]=W):W=t[61],W}function ire(e){let t=(0,$.c)(18),n;t[0]===e.path?n=t[1]:(n={id:e.path},t[0]=e.path,t[1]=n);let{attributes:r,isDragging:i,listeners:a,setNodeRef:o,transform:s,transition:c}=l7(n),l;t[2]===s?l=t[3]:(l=D6.Transform.toString(s),t[2]=s,t[3]=l);let u;t[4]!==l||t[5]!==c?(u={transform:l,transition:c},t[4]=l,t[5]=c,t[6]=u):u=t[6];let d=u,f=i&&`opacity-0`,p;t[7]===f?p=t[8]:(p=rn(`shrink-0`,f),t[7]=f,t[8]=p);let m;t[9]!==r||t[10]!==a||t[11]!==e?(m=(0,Q.jsx)(E7,{...e,dragAttributes:r,dragListeners:a}),t[9]=r,t[10]=a,t[11]=e,t[12]=m):m=t[12];let h;return t[13]!==o||t[14]!==d||t[15]!==p||t[16]!==m?(h=(0,Q.jsx)(`div`,{ref:o,style:d,className:p,children:m}),t[13]=o,t[14]=d,t[15]=p,t[16]=m,t[17]=h):h=t[17],h}function are(e){let t=(0,$.c)(6),{activeFilePath:n,activePath:r,filePreviewPath:i,fileTabs:a}=e,o=a.indexOf(r);if(o<0)return null;let s=n===r,c=i===r,l;return t[0]!==r||t[1]!==a.length||t[2]!==o||t[3]!==s||t[4]!==c?(l=(0,Q.jsx)(E7,{active:s,dragging:!0,index:o,onActiveTabChange:ore,path:r,preview:c,tabCount:a.length}),t[0]=r,t[1]=a.length,t[2]=o,t[3]=s,t[4]=c,t[5]=l):l=t[5],l}function ore(){}function sre(e){let t=(0,$.c)(46),{activeFilePath:n,activeTab:r,filePreviewPath:i,fileTabs:a,onActiveFileChange:o,onActiveTabChange:s,onCloseAllFiles:c,onCloseFile:l,onCloseFilesToRight:u,onCloseOtherFiles:d,onOpenFileDialog:f,onReorderFiles:p,showReview:m}=e,h=i===void 0?``:i,g;t[0]===a?g=t[1]:(g=a===void 0?[]:a,t[0]=a,t[1]=g);let _=g,v=m===void 0?!1:m,y;t[2]!==r||t[3]!==s?(y=e=>{let{label:t,value:n}=e,i=r===n;return(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":i,className:rn(`inline-flex h-8 shrink-0 items-center rounded-md border border-transparent px-2.5 text-sm font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,i&&`bg-muted text-foreground`),onClick:()=>{s(n)},children:t},n)},t[2]=r,t[3]=s,t[4]=y):y=t[4];let b=y,[x,S]=Z.useState(``),C=_.length>0,w;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(w={activationConstraint:{distance:6}},t[5]=w):w=t[5];let T=U6(H6(W8,w)),E;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(E=e=>{S(String(e.active.id))},t[6]=E):E=t[6];let D=E,O;t[7]!==_||t[8]!==p?(O=e=>{let t=String(e.active.id),n=e.over?String(e.over.id):``;if(!t||!n||t===n)return;let r=_.indexOf(t),i=_.indexOf(n);r===-1||i===-1||(p?.(e7(_,r,i)),S(``))},t[7]=_,t[8]=p,t[9]=O):O=t[9];let k=O,A;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(A=()=>{S(``)},t[10]=A):A=t[10];let j=A,M;t[11]===C?M=t[12]:(M=C?(0,Q.jsx)(x7,{}):null,t[11]=C,t[12]=M);let N;t[13]!==b||t[14]!==v?(N=v?b({label:`Changes`,value:`review`}):null,t[13]=b,t[14]=v,t[15]=N):N=t[15];let P;t[16]!==C||t[17]!==b?(P=C?null:b({label:`Files`,value:`files`}),t[16]=C,t[17]=b,t[18]=P):P=t[18];let F;t[19]===C?F=t[20]:(F=C?(0,Q.jsx)(`span`,{className:`mx-1 shrink-0 text-xs text-border`,"aria-hidden":`true`,children:`|`}):null,t[19]=C,t[20]=F);let I;t[21]!==x||t[22]!==n||t[23]!==r||t[24]!==h||t[25]!==_||t[26]!==k||t[27]!==C||t[28]!==o||t[29]!==s||t[30]!==c||t[31]!==l||t[32]!==u||t[33]!==d||t[34]!==T?(I=C?(0,Q.jsxs)(V5,{sensors:T,collisionDetection:Z6,onDragStart:D,onDragEnd:k,onDragCancel:j,children:[(0,Q.jsx)(s7,{items:_,strategy:Cne,children:_.map((e,t)=>(0,Q.jsx)(ire,{active:r===`files`&&n===e,index:t,onActiveFileChange:o,onActiveTabChange:s,onCloseAllFiles:c,onCloseFile:l,onCloseFilesToRight:u,onCloseOtherFiles:d,path:e,preview:h===e,tabCount:_.length},e))}),(0,Q.jsx)($5,{dropAnimation:null,modifiers:Wne,children:x?(0,Q.jsx)(are,{activeFilePath:n,activePath:x,filePreviewPath:h,fileTabs:_}):null})]}):null,t[21]=x,t[22]=n,t[23]=r,t[24]=h,t[25]=_,t[26]=k,t[27]=C,t[28]=o,t[29]=s,t[30]=c,t[31]=l,t[32]=u,t[33]=d,t[34]=T,t[35]=I):I=t[35];let L;t[36]!==C||t[37]!==f?(L=C?(0,Q.jsx)(Je,{title:`Open another file`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Open another file`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md border border-transparent text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,onClick:f,children:`+`})}):null,t[36]=C,t[37]=f,t[38]=L):L=t[38];let R;return t[39]!==M||t[40]!==N||t[41]!==P||t[42]!==F||t[43]!==I||t[44]!==L?(R=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 overflow-x-auto border-b border-border/70 bg-background p-2`,children:[M,N,P,F,I,L]}),t[39]=M,t[40]=N,t[41]=P,t[42]=F,t[43]=I,t[44]=L,t[45]=R):R=t[45],R}function D7(e){return Number.isFinite(e)?Math.round(Math.min(Une,Math.max(Hne,e))):v7}function cre(){let e=A(er);return e==null?v7:D7(Number(e))}function lre(e){ee(er,String(D7(e)))}function ure(e){let t=(0,$.c)(6),{onResize:n,width:r}=e,i;t[0]===n?i=t[1]:(i=e=>{n(D7(e))},t[0]=n,t[1]=i);let a=i,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=rn(`absolute inset-y-0 right-0 z-20 w-3 translate-x-1/2 cursor-col-resize touch-none bg-transparent outline-hidden after:absolute after:inset-y-0 after:left-1/2 after:w-px after:bg-border/70 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1`,Ss),t[2]=o):o=t[2];let s;return t[3]!==a||t[4]!==r?(s=(0,Q.jsx)(`div`,{role:`separator`,"aria-label":`Resize file tree`,"aria-orientation":`vertical`,tabIndex:0,className:o,onKeyDown:e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=e.shiftKey?48:16;a(r+(e.key===`ArrowRight`?t:-t))},onPointerDown:e=>{if(e.button!==0)return;e.preventDefault();let t=e.clientX,n=r,i=document.body.style.cursor,o=document.body.style.userSelect,s=Ho(`col-resize`);document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let c=e=>{a(n+e.clientX-t)},l=()=>{s(),document.body.style.cursor=i,document.body.style.userSelect=o,document.removeEventListener(`pointermove`,c),document.removeEventListener(`pointerup`,l),document.removeEventListener(`pointercancel`,l)};document.addEventListener(`pointermove`,c),document.addEventListener(`pointerup`,l),document.addEventListener(`pointercancel`,l)}}),t[3]=a,t[4]=r,t[5]=s):s=t[5],s}function dre(e){let t=(0,$.c)(18),{viewerContextId:n,cwd:r,active:i,activeFilePath:a,onOpenFile:o,previewMode:s}=e,[c,l]=Z.useState(v7),u,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{l(cre())},d=[],t[0]=u,t[1]=d):(u=t[0],d=t[1]),Z.useEffect(u,d);let f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=e=>{let t=D7(e);l(t),lre(t)},t[2]=f):f=t[2];let p=f,m=`${c}px`,h;t[3]===m?h=t[4]:(h={width:m,maxWidth:`70%`},t[3]=m,t[4]=h);let g;t[5]!==i||t[6]!==a||t[7]!==r||t[8]!==o||t[9]!==s||t[10]!==n?(g=(0,Q.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden`,children:(0,Q.jsx)(C7,{viewerContextId:n,cwd:r,active:i,activeFilePath:a,onCloseFile:fre,onOpenFile:o,previewMode:s})}),t[5]=i,t[6]=a,t[7]=r,t[8]=o,t[9]=s,t[10]=n,t[11]=g):g=t[11];let _;t[12]===c?_=t[13]:(_=(0,Q.jsx)(ure,{width:c,onResize:p}),t[12]=c,t[13]=_);let v;return t[14]!==h||t[15]!==g||t[16]!==_?(v=(0,Q.jsxs)(`div`,{className:`relative min-h-0 shrink-0 overflow-visible border-r border-border/70`,style:h,children:[g,_]}),t[14]=h,t[15]=g,t[16]=_,t[17]=v):v=t[17],v}function fre(){}function pre(e){return e.split(`/`).filter(Boolean).at(-1)||e}function mre(e){let t=(0,$.c)(30),{fileTreeCollapsed:n,onFileTreeCollapsedChange:r,path:i}=e,a=n===void 0?!1:n,o,s,c,l,u,d,f,p,m;if(t[0]!==a||t[1]!==r||t[2]!==i){m=Symbol.for(`react.early_return_sentinel`);bb0:{let e=i.split(`/`).filter(Boolean);if(e.length===0){m=null;break bb0}f=`flex h-10 shrink-0 items-center gap-2 border-b border-border/70 bg-background px-3`,t[12]!==a||t[13]!==r?(p=r?(0,Q.jsx)(Je,{title:a?`Show file tree`:`Collapse file tree`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":a,"aria-label":a?`Show file tree`:`Collapse file tree`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md border border-transparent text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,onClick:()=>{r(!a)},children:a?(0,Q.jsx)(Ja,{className:`size-4`}):(0,Q.jsx)(qa,{className:`size-4`})})}):null,t[12]=a,t[13]=r,t[14]=p):p=t[14],d=`min-w-0 flex-1 overflow-x-auto`,s=Pne,u=i,o=Fne,c=`flex-nowrap gap-1 font-mono text-xs whitespace-nowrap`,l=e.map((t,n)=>{let r=n===e.length-1,i=`${n}:${t}`;return(0,Q.jsxs)(Z.Fragment,{children:[n>0?(0,Q.jsx)(Rne,{className:`text-muted-foreground/60`}):null,(0,Q.jsx)(Ine,{className:`min-w-0 shrink-0`,children:r?(0,Q.jsx)(Lne,{className:`max-w-80 truncate font-mono text-xs font-medium`,children:t}):(0,Q.jsx)(`span`,{className:`max-w-40 truncate text-muted-foreground`,children:t})})]},i)})}t[0]=a,t[1]=r,t[2]=i,t[3]=o,t[4]=s,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m}else o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11];if(m!==Symbol.for(`react.early_return_sentinel`))return m;let h;t[15]!==o||t[16]!==c||t[17]!==l?(h=(0,Q.jsx)(o,{className:c,children:l}),t[15]=o,t[16]=c,t[17]=l,t[18]=h):h=t[18];let g;t[19]!==s||t[20]!==u||t[21]!==h?(g=(0,Q.jsx)(s,{title:u,children:h}),t[19]=s,t[20]=u,t[21]=h,t[22]=g):g=t[22];let _;t[23]!==g||t[24]!==d?(_=(0,Q.jsx)(`div`,{className:d,children:g}),t[23]=g,t[24]=d,t[25]=_):_=t[25];let v;return t[26]!==_||t[27]!==f||t[28]!==p?(v=(0,Q.jsxs)(`div`,{className:f,children:[p,_]}),t[26]=_,t[27]=f,t[28]=p,t[29]=v):v=t[29],v}function O7(e){let t=(0,$.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Q.jsx)(Ot,{children:n}),t[0]=n,t[1]=r),r}function hre(e){let t=(0,$.c)(156),{viewerContextId:n,cwd:r,active:i,gitStatus:a,open:o,onOpenChange:s}=e,c=re(),l=Ao(),u=Rh(l),d=a_(r),[f,p]=Z.useState(``),[m,h]=Z.useState(`browse`),[g,_]=Z.useState(``),[v,y]=Z.useState(``),b=f_({viewerContextId:n,cwd:d,scope:`branches`}),x=!!(o&&i&&n&&d),S;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(S=[`data`,`isPending`,`error`],t[0]=S):S=t[0];let C;t[1]!==b||t[2]!==x?(C={...b,enabled:x,notifyOnChangeProps:S},t[1]=b,t[2]=x,t[3]=C):C=t[3];let w=Or(C),T=w.data,E,D,O;if(t[4]!==T?.localBranches||t[5]!==T?.remoteBranches||t[6]!==a){E=M_(T?.localBranches,a);let e;t[10]===T?.remoteBranches?e=t[11]:(e=T?.remoteBranches??[],t[10]=T?.remoteBranches,t[11]=e);let n;t[12]===e?n=t[13]:(n=e.filter(yre),t[12]=e,t[13]=n),D=n,O=new Set(E.map(vre)),t[4]=T?.localBranches,t[5]=T?.remoteBranches,t[6]=a,t[7]=E,t[8]=D,t[9]=O}else E=t[7],D=t[8],O=t[9];let k=O,A;t[14]!==o||t[15]!==y||t[16]!==p||t[17]!==_||t[18]!==h?(A=()=>{o||(p(``),h(`browse`),_(``),y(``))},t[14]=o,t[15]=y,t[16]=p,t[17]=_,t[18]=h,t[19]=A):A=t[19];let j;t[20]===o?j=t[21]:(j=[o],t[20]=o,t[21]=j),Z.useEffect(A,j);let M;t[22]!==E||t[23]!==o||t[24]!==D[0]||t[25]!==g||t[26]!==_?(M=()=>{if(!o||g)return;let e=E.find(_re);_(e?`local:${e.name}`:E[0]?`local:${E[0].name}`:D[0]?`remote:${D[0].name}`:`action:create`)},t[22]=E,t[23]=o,t[24]=D[0],t[25]=g,t[26]=_,t[27]=M):M=t[27];let N;t[28]!==E||t[29]!==o||t[30]!==D||t[31]!==g?(N=[E,o,D,g],t[28]=E,t[29]=o,t[30]=D,t[31]=g,t[32]=N):N=t[32],Z.useEffect(M,N);let P;t[33]!==d||t[34]!==n?(P=async e=>await wh(Ch(`/api/git-checkout`,{contextId:n}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({cwd:d,...e})}),t[33]=d,t[34]=n,t[35]=P):P=t[35];let F;t[36]!==d||t[37]!==s||t[38]!==c||t[39]!==n?(F=async(e,t)=>{await __({queryClient:c,viewerContextId:n,cwd:d}),s(!1),Qe.success(t.create?`Created and switched to ${t.branch}`:`Switched to ${t.branch}`)},t[36]=d,t[37]=s,t[38]=c,t[39]=n,t[40]=F):F=t[40];let I;t[41]!==P||t[42]!==F?(I={mutationFn:P,onSuccess:F,onError:gre},t[41]=P,t[42]=F,t[43]=I):I=t[43];let L=Nr(I),R;t[44]===L?R=t[45]:(R=e=>{e.current||L.isPending||L.mutate({branch:e.name})},t[44]=L,t[45]=R);let z=R,B;t[46]!==L||t[47]!==k?(B=e=>{if(L.isPending)return;let t=N_(e.name).branch||e.name;if(k.has(t)){L.mutate({branch:t});return}L.mutate({branch:t,create:!0,startPoint:e.name,track:!0})},t[46]=L,t[47]=k,t[48]=B):B=t[48];let V=B,U;t[49]!==L||t[50]!==v?(U=()=>{let e=v.trim();!e||L.isPending||L.mutate({branch:e,create:!0})},t[49]=L,t[50]=v,t[51]=U):U=t[51];let W=U,G;t[52]===h?G=t[53]:(G=e=>{Wh(e.nativeEvent,`Control+N`)&&(e.preventDefault(),h(`create`))},t[52]=h,t[53]=G);let ee;t[54]!==f||t[55]!==p||t[56]!==u?(ee=(0,Q.jsx)(kp,{autoFocus:u,value:f,onValueChange:p,placeholder:`Search branches`,className:`text-base md:text-sm`}),t[54]=f,t[55]=p,t[56]=u,t[57]=ee):ee=t[57];let te=w.isPending?`Loading branches…`:`No branches found.`,K;t[58]===te?K=t[59]:(K=(0,Q.jsx)(jp,{children:te}),t[58]=te,t[59]=K);let ne;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(ne=[`new`,`create`,`branch`],t[60]=ne):ne=t[60];let q;t[61]===h?q=t[62]:(q=()=>{h(`create`)},t[61]=h,t[62]=q);let J,Y;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,Q.jsx)(Ua,{className:`size-4 text-muted-foreground`}),Y=(0,Q.jsx)(`span`,{className:`font-medium`,children:`Create new branch…`}),t[63]=J,t[64]=Y):(J=t[63],Y=t[64]);let ie;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,Q.jsx)(Pp,{children:Uh(`Control+N`)}),t[65]=ie):ie=t[65];let ae;t[66]===q?ae=t[67]:(ae=(0,Q.jsx)(Mp,{heading:`Actions`,children:(0,Q.jsxs)(Np,{value:`action:create`,keywords:ne,onSelect:q,children:[J,Y,ie]})}),t[66]=q,t[67]=ae);let oe=`Local branches · ${E.length}`,se;t[68]!==w.isPending||t[69]!==E.length?(se=w.isPending&&E.length===0?(0,Q.jsxs)(Np,{value:`loading:branches`,disabled:!0,children:[(0,Q.jsx)(H,{className:`size-3.5 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Loading branches…`})]}):null,t[68]=w.isPending,t[69]=E.length,t[70]=se):se=t[70];let ce;if(t[71]!==L.isPending||t[72]!==E||t[73]!==z){let e;t[75]!==L.isPending||t[76]!==z?(e=e=>{let t=k_(e),n=e.current?`current`:j_(e.relativeDate),r=[e.name,e.upstream,e.subject].filter(Boolean).join(` · `)||e.name;return(0,Q.jsxs)(Np,{value:`local:${e.name}`,keywords:[e.name,e.upstream??``,e.subject??``],disabled:L.isPending,onSelect:()=>z(e),className:`items-start py-2`,children:[(0,Q.jsx)(`span`,{className:`mt-0.5 flex size-4 shrink-0 items-center justify-center`,children:e.current?(0,Q.jsx)(ja,{className:`size-3.5 text-emerald-500`}):null}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,title:r,children:[(0,Q.jsx)(`div`,{className:`truncate font-mono text-[13px] font-medium`,children:e.name}),(0,Q.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:[e.upstream,e.subject].filter(Boolean).join(` · `)||`Local branch`})]}),(0,Q.jsx)(Pp,{className:rn(`shrink-0 tracking-normal normal-case`,t&&A_(e,t)),children:t||n})]},e.name)},t[75]=L.isPending,t[76]=z,t[77]=e):e=t[77],ce=E.map(e),t[71]=L.isPending,t[72]=E,t[73]=z,t[74]=ce}else ce=t[74];let le;t[78]!==oe||t[79]!==se||t[80]!==ce?(le=(0,Q.jsxs)(Mp,{heading:oe,children:[se,ce]}),t[78]=oe,t[79]=se,t[80]=ce,t[81]=le):le=t[81];let ue=`Remote branches · ${D.length}`,de;if(t[82]!==L.isPending||t[83]!==k||t[84]!==D||t[85]!==V){let e;t[87]!==L.isPending||t[88]!==k||t[89]!==V?(e=e=>{let t=N_(e.name),n=t.branch||e.name,r=k.has(n);return(0,Q.jsxs)(Np,{value:`remote:${e.name}`,keywords:[e.name,n,e.subject??``],disabled:L.isPending,onSelect:()=>V(e),className:`items-start py-2`,children:[(0,Q.jsx)(Ua,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,title:e.name,children:[(0,Q.jsxs)(`div`,{className:`truncate font-mono text-[13px] font-medium`,children:[t.remote?(0,Q.jsxs)(`span`,{className:`text-muted-foreground/70`,children:[t.remote,`/`]}):null,t.branch||e.name]}),(0,Q.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.subject||`Remote branch`})]}),(0,Q.jsx)(Pp,{className:`shrink-0 tracking-normal normal-case`,children:r?`Switch`:`Track`})]},e.name)},t[87]=L.isPending,t[88]=k,t[89]=V,t[90]=e):e=t[90],de=D.map(e),t[82]=L.isPending,t[83]=k,t[84]=D,t[85]=V,t[86]=de}else de=t[86];let fe;t[91]!==ue||t[92]!==de?(fe=(0,Q.jsx)(Mp,{heading:ue,children:de}),t[91]=ue,t[92]=de,t[93]=fe):fe=t[93];let pe;t[94]!==K||t[95]!==ae||t[96]!==le||t[97]!==fe?(pe=(0,Q.jsxs)(Ap,{className:`max-h-none min-h-0 flex-1 md:max-h-[min(70vh,28rem)]`,children:[K,ae,le,fe]}),t[94]=K,t[95]=ae,t[96]=le,t[97]=fe,t[98]=pe):pe=t[98];let me;t[99]===l?me=t[100]:(me=l?null:(0,Q.jsxs)(`div`,{className:`hidden flex-wrap items-center gap-x-3 gap-y-1 border-t border-border/70 px-3 py-2 text-xs text-muted-foreground md:flex`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(O7,{children:`Enter`}),` Switch`]}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(O7,{children:Uh(`Control+N`)}),` `,`New branch`]}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(O7,{children:`Esc`}),` Close`]})]}),t[99]=l,t[100]=me);let he;t[101]!==g||t[102]!==_||t[103]!==G||t[104]!==ee||t[105]!==pe||t[106]!==me?(he=(0,Q.jsxs)(Dp,{shouldFilter:!0,loop:!0,value:g,onValueChange:_,onKeyDown:G,className:`min-h-0 flex-1`,children:[ee,pe,me]}),t[101]=g,t[102]=_,t[103]=G,t[104]=ee,t[105]=pe,t[106]=me,t[107]=he):he=t[107];let ge=he,_e;t[108]===h?_e=t[109]:(_e=()=>h(`browse`),t[108]=h,t[109]=_e);let ve;t[110]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,Q.jsx)(gn,{}),t[110]=ve):ve=t[110];let ye;t[111]===_e?ye=t[112]:(ye=(0,Q.jsx)(ss,{type:`button`,variant:`ghost`,size:`icon`,onClick:_e,"aria-label":`Back to branches`,children:ve}),t[111]=_e,t[112]=ye);let be;t[113]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate text-sm font-medium`,children:`Create branch`}),(0,Q.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:`From the current HEAD`})]}),t[113]=be):be=t[113];let xe;t[114]===ye?xe=t[115]:(xe=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/70 px-3 py-2`,children:[ye,be]}),t[114]=ye,t[115]=xe);let Se;t[116]===y?Se=t[117]:(Se=e=>y(e.target.value),t[116]=y,t[117]=Se);let Ce;t[118]!==W||t[119]!==h?(Ce=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),h(`browse`);return}e.key!==`Enter`||e.nativeEvent.isComposing||(e.preventDefault(),e.stopPropagation(),W())},t[118]=W,t[119]=h,t[120]=Ce):Ce=t[120];let we;t[121]!==v||t[122]!==u||t[123]!==Se||t[124]!==Ce?(we=(0,Q.jsx)(xs,{autoFocus:u,value:v,onChange:Se,onKeyDown:Ce,placeholder:`branch-name`,className:`min-w-0 flex-1`}),t[121]=v,t[122]=u,t[123]=Se,t[124]=Ce,t[125]=we):we=t[125];let Te;t[126]!==L.isPending||t[127]!==v?(Te=!v.trim()||L.isPending,t[126]=L.isPending,t[127]=v,t[128]=Te):Te=t[128];let Ee;t[129]===L.isPending?Ee=t[130]:(Ee=L.isPending?(0,Q.jsx)(H,{}):null,t[129]=L.isPending,t[130]=Ee);let De;t[131]!==W||t[132]!==Te||t[133]!==Ee?(De=(0,Q.jsxs)(ss,{type:`button`,disabled:Te,onClick:W,children:[Ee,`Create`]}),t[131]=W,t[132]=Te,t[133]=Ee,t[134]=De):De=t[134];let Oe;t[135]!==we||t[136]!==De?(Oe=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-center gap-2 p-3`,children:[we,De]}),t[135]=we,t[136]=De,t[137]=Oe):Oe=t[137];let ke;t[138]===l?ke=t[139]:(ke=l?null:(0,Q.jsxs)(`div`,{className:`hidden flex-wrap items-center gap-x-3 gap-y-1 border-t border-border/70 px-3 py-2 text-xs text-muted-foreground md:flex`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(O7,{children:`Enter`}),` Create`]}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(O7,{children:`Esc`}),` Back`]})]}),t[138]=l,t[139]=ke);let Ae;t[140]!==xe||t[141]!==Oe||t[142]!==ke?(Ae=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[xe,Oe,ke]}),t[140]=xe,t[141]=Oe,t[142]=ke,t[143]=Ae):Ae=t[143];let je=m===`create`?Ae:ge;if(l){let e;t[144]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsxs)(Um,{children:[(0,Q.jsx)(Gm,{children:`Branches`}),(0,Q.jsx)(Km,{children:`Switch branches or create a new branch.`})]}),t[144]=e):e=t[144];let n;t[145]===je?n=t[146]:(n=(0,Q.jsxs)(Hm,{className:`max-h-[90svh] overflow-hidden`,children:[e,(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-4 pb-4`,children:je})]}),t[145]=je,t[146]=n);let r;return t[147]!==s||t[148]!==o||t[149]!==u||t[150]!==n?(r=(0,Q.jsx)(zm,{open:o,onOpenChange:s,autoFocus:u,children:n}),t[147]=s,t[148]=o,t[149]=u,t[150]=n,t[151]=r):r=t[151],r}let Me;return t[152]!==je||t[153]!==s||t[154]!==o?(Me=(0,Q.jsx)(Op,{open:o,onOpenChange:s,title:`Branches`,description:`Switch branches or create a new branch.`,className:`sm:max-w-2xl`,initialFocus:!0,children:je}),t[152]=je,t[153]=s,t[154]=o,t[155]=Me):Me=t[155],Me}function gre(e,t){Qe.error(c_(e,t.create?`Failed to create branch`:`Failed to switch branch`))}function _re(e){return e.current}function vre(e){return e.name}function yre(e){return!e.name.endsWith(`/HEAD`)}function bre(e){let t=(0,$.c)(20),{viewerContextId:n,cwd:r,active:i}=e,a=a_(r),o=!!(i&&n&&a),s=Or({...d_({viewerContextId:n,cwd:a}),enabled:o,notifyOnChangeProps:[`error`,`errorUpdatedAt`]}),c=Or({...f_({viewerContextId:n,cwd:a,scope:`files`}),enabled:o,notifyOnChangeProps:[`error`,`errorUpdatedAt`]}),l=Or({...f_({viewerContextId:n,cwd:a,scope:`branches`}),enabled:o,notifyOnChangeProps:[`error`,`errorUpdatedAt`]}),u=f_({viewerContextId:n,cwd:a,scope:`commits`}),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=[`error`,`errorUpdatedAt`],t[0]=d):d=t[0];let f;t[1]!==o||t[2]!==u?(f={...u,enabled:o,notifyOnChangeProps:d},t[1]=o,t[2]=u,t[3]=f):f=t[3];let p=Or(f),m;t[4]!==i||t[5]!==l.error||t[6]!==p.error||t[7]!==c.error||t[8]!==s.error?(m=()=>{if(!i)return;let e=c.error||l.error||p.error||s.error;e&&Qe.error(c_(e,`Failed to load git view`))},t[4]=i,t[5]=l.error,t[6]=p.error,t[7]=c.error,t[8]=s.error,t[9]=m):m=t[9];let h;return t[10]!==i||t[11]!==l.error||t[12]!==l.errorUpdatedAt||t[13]!==p.error||t[14]!==p.errorUpdatedAt||t[15]!==c.error||t[16]!==c.errorUpdatedAt||t[17]!==s.error||t[18]!==s.errorUpdatedAt?(h=[i,l.error,l.errorUpdatedAt,p.error,p.errorUpdatedAt,c.error,c.errorUpdatedAt,s.error,s.errorUpdatedAt],t[10]=i,t[11]=l.error,t[12]=l.errorUpdatedAt,t[13]=p.error,t[14]=p.errorUpdatedAt,t[15]=c.error,t[16]=c.errorUpdatedAt,t[17]=s.error,t[18]=s.errorUpdatedAt,t[19]=h):h=t[19],Z.useEffect(m,h),null}function xre(e){let t=(0,$.c)(29),{viewerContextId:n,cwd:r,active:i,onBranchClick:a}=e,o=a_(r),s=!!(i&&n&&o),c=Or({...d_({viewerContextId:n,cwd:o}),enabled:s,select:h_,notifyOnChangeProps:[`data`,`isPending`,`error`]});if(!o){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(h7,{children:`No directory selected.`}),t[0]=e):e=t[0],e}if(!n){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(h7,{children:`Waiting for viewer context…`}),t[1]=e):e=t[1],e}if(c.isPending&&c.data===void 0){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsxs)(h7,{children:[(0,Q.jsx)(H,{}),` Loading repository status…`]}),t[2]=e):e=t[2],e}if(c.error){let e;t[3]===c.error?e=t[4]:(e=c_(c.error,`Failed to load repository status`),t[3]=c.error,t[4]=e);let n;return t[5]===e?n=t[6]:(n=(0,Q.jsx)(h7,{tone:`destructive`,children:e}),t[5]=e,t[6]=n),n}let l=c.data;if(!l){let e;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(h7,{children:`No git repository detected.`}),t[7]=e):e=t[7],e}let u=l.detached?`Detached HEAD${l.revision?` (${l.revision})`:``}`:l.branch||l.label,d=s_(o),f=l.ahead===0&&l.behind===0,p=o_(o),m;t[8]!==l.title||t[9]!==p?(m=[p,l.title].filter(Boolean),t[8]=l.title,t[9]=p,t[10]=m):m=t[10];let h=m.join(` · `),g;t[11]===f?g=t[12]:(g=f?(0,Q.jsx)(ja,{className:`size-3 shrink-0 text-emerald-500`}):null,t[11]=f,t[12]=g);let _;t[13]===l.behind?_=t[14]:(_=l.behind>0?(0,Q.jsxs)(`span`,{className:`shrink-0 font-medium text-sky-500 tabular-nums`,children:[`↓`,l.behind]}):null,t[13]=l.behind,t[14]=_);let v;t[15]===l.ahead?v=t[16]:(v=l.ahead>0?(0,Q.jsxs)(`span`,{className:`shrink-0 font-medium text-amber-500 tabular-nums`,children:[`↑`,l.ahead]}):null,t[15]=l.ahead,t[16]=v);let y=d||`No cwd`,b;t[17]===y?b=t[18]:(b=(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:y}),t[17]=y,t[18]=b);let x;t[19]!==u||t[20]!==a?(x=u?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`→`}),a?(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Switch branch`,className:`-mx-1 inline-flex min-w-0 items-center gap-1 rounded-md px-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,onClick:a,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:u}),(0,Q.jsx)(Fa,{className:`size-3 shrink-0`})]}):(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:u})]}):null,t[19]=u,t[20]=a,t[21]=x):x=t[21];let S;return t[22]!==g||t[23]!==_||t[24]!==v||t[25]!==b||t[26]!==x||t[27]!==h?(S=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-xs leading-5`,title:h,children:[g,_,v,b,x]}),t[22]=g,t[23]=_,t[24]=v,t[25]=b,t[26]=x,t[27]=h,t[28]=S):S=t[28],S}function Sre(e){let t=(0,$.c)(50),{viewerContextId:n,cwd:r,active:i}=e,a=re(),o=a_(r),[s,c]=Z.useState(!1),[l,u]=Z.useState(!1),d=Or({...d_({viewerContextId:n,cwd:o}),enabled:!!(i&&n&&o),select:h_,notifyOnChangeProps:[`data`]}),f=Or({...f_({viewerContextId:n,cwd:o,scope:`files`}),enabled:!!(i&&n&&o),select:g_,notifyOnChangeProps:[`data`]}),p=kr({queryKey:_g.gitStatus(n,o),exact:!0}),m=kr({queryKey:_g.gitFiles(n,o),exact:!0}),h=kr({queryKey:_g.gitBranches(n,o),exact:!0}),g=kr({queryKey:_g.gitCommits(n,o),exact:!1}),_=p+m+h+g>0,v=d.data,y;t[0]===f.data?y=t[1]:(y=Array.isArray(f.data)?f.data:[],t[0]=f.data,t[1]=y);let b=y,x=!!v,S=!!(v?.dirty||b.length>0),C=!!(x&&!v?.detached&&(v?.ahead||0)>0),w;t[2]===v?w=t[3]:(w=b_(v),t[2]=v,t[3]=w);let T=w,E=!!(x&&!v?.detached&&(v?.behind||0)>0),D=Nr({mutationFn:async e=>await wh(Ch(e===`pull`?`/api/git-pull`:`/api/git-push`,{contextId:n}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({cwd:o,force:e===`force-push`})}),onSuccess:async(e,t)=>{await __({queryClient:a,viewerContextId:n,cwd:o}),t!==`pull`&&Fq({response:e,force:t===`force-push`})},onError:Cre}),O=Ar({mutationKey:_g.gitAction(n,o,`push`)}),k=Ar({mutationKey:_g.gitAction(n,o,`force-push`)}),A=_g.gitAction(n,o,`pull`),j;t[4]===A?j=t[5]:(j={mutationKey:A},t[4]=A,t[5]=j);let M=Ar(j),N=D.isPending&&D.variables===`push`||O>0,P=D.isPending&&D.variables===`force-push`||k>0,F=D.isPending&&D.variables===`pull`||M>0,I=D.isPending||N||P||F,L=!!(n&&o&&S),R=!!(n&&o&&C&&(!I||N)),z=!!(n&&o&&T&&(!I||P)),B=!!(n&&o&&E&&(!I||F)),V=L||R||z||B,U;t[6]===c?U=t[7]:(U=()=>{c(!0)},t[6]=c,t[7]=U);let W;t[8]!==i||t[9]!==o||t[10]!==U||t[11]!==n?(W=(0,Q.jsx)(xre,{viewerContextId:n,cwd:o,active:i,onBranchClick:U}),t[8]=i,t[9]=o,t[10]=U,t[11]=n,t[12]=W):W=t[12];let G;t[13]!==i||t[14]!==_?(G=i&&_?(0,Q.jsx)(H,{className:`size-3 shrink-0 text-muted-foreground`}):null,t[13]=i,t[14]=_,t[15]=G):G=t[15];let ee;t[16]!==W||t[17]!==G?(ee=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[W,G]}),t[16]=W,t[17]=G,t[18]=ee):ee=t[18];let te;t[19]!==P||t[20]!==I||t[21]!==D||t[22]!==F||t[23]!==N||t[24]!==u||t[25]!==V||t[26]!==L||t[27]!==z||t[28]!==B||t[29]!==R?(te=V?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[L?(0,Q.jsx)(Je,{title:`Commit`,kbd:Uh(`Control+C`),children:(0,Q.jsxs)(ss,{variant:`outline`,onClick:()=>{u(!0)},children:[(0,Q.jsx)(Ha,{}),` Commit…`]})}):null,R?(0,Q.jsx)(Je,{title:`Push`,kbd:Uh(`Control+P`),children:(0,Q.jsxs)(ss,{variant:`outline`,disabled:I,onClick:()=>{D.mutate(`push`)},children:[N?(0,Q.jsx)(H,{}):(0,Q.jsx)(to,{}),`Push`]})}):null,z?(0,Q.jsx)(Je,{title:`Force push`,kbd:Uh(`Control+Shift+P`),children:(0,Q.jsxs)(ss,{variant:`outline`,disabled:I,onClick:()=>{D.mutate(`force-push`)},children:[P?(0,Q.jsx)(H,{}):(0,Q.jsx)(to,{}),`Force Push`]})}):null,B?(0,Q.jsx)(Je,{title:`Pull`,kbd:Uh(`Alt+P`),children:(0,Q.jsxs)(ss,{variant:`outline`,disabled:I,onClick:()=>{D.mutate(`pull`)},children:[F?(0,Q.jsx)(H,{}):(0,Q.jsx)(La,{}),`Pull`]})}):null]}):null,t[19]=P,t[20]=I,t[21]=D,t[22]=F,t[23]=N,t[24]=u,t[25]=V,t[26]=L,t[27]=z,t[28]=B,t[29]=R,t[30]=te):te=t[30];let K;t[31]!==i||t[32]!==s||t[33]!==v||t[34]!==o||t[35]!==c||t[36]!==n?(K=(0,Q.jsx)(hre,{viewerContextId:n,cwd:o,active:i,gitStatus:v,open:s,onOpenChange:c}),t[31]=i,t[32]=s,t[33]=v,t[34]=o,t[35]=c,t[36]=n,t[37]=K):K=t[37];let ne;t[38]!==l||t[39]!==b||t[40]!==v||t[41]!==o||t[42]!==u||t[43]!==n?(ne=(0,Q.jsx)(U_,{viewerContextId:n,cwd:o,files:b,gitStatus:v,open:l,onOpenChange:u}),t[38]=l,t[39]=b,t[40]=v,t[41]=o,t[42]=u,t[43]=n,t[44]=ne):ne=t[44];let q;return t[45]!==K||t[46]!==ne||t[47]!==ee||t[48]!==te?(q=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[ee,te,K,ne]}),t[45]=K,t[46]=ne,t[47]=ee,t[48]=te,t[49]=q):q=t[49],q}function Cre(e,t){Qe.error(c_(e,t===`pull`?`Failed to pull changes`:t===`force-push`?`Failed to force push changes`:`Failed to push changes`))}var k7=Z.createContext(void 0);function wre(e=!0){let t=Z.useContext(k7);if(t===void 0&&!e)throw Error(b(7));return t}var Tre=Z.forwardRef(function(e,t){let{className:n,defaultPressed:r=!1,disabled:i=!1,form:a,onPressedChange:o,pressed:s,render:c,type:l,value:u,nativeButton:d=!0,style:f,...p}=e,m=It(u||void 0),h=wre(),g=h?.value??[],_=h?void 0:r,v=(i||h?.disabled)??!1,[y,b]=_s({controlled:h?m!==void 0&&g.indexOf(m)>-1:s,default:_,name:`Toggle`,state:`pressed`}),x=J((e,t)=>{m&&h?.setGroupValue?.(m,e,t),o?.(e,t)}),{getButtonProps:S,buttonRef:C}=ns({disabled:v,native:d}),w={disabled:v,pressed:y},T=[C,t],E=[{"aria-pressed":y,onClick(e){let t=!y,n=Ye(Wt,e.nativeEvent);x(t,n),!n.isCanceled&&b(t)}},p,S],D=at(`button`,e,{enabled:!h,state:w,ref:T,props:E});return h?(0,Q.jsx)(Oy,{tag:`button`,render:c,className:n,style:f,state:w,refs:T,props:E}):D}),Ere=function(e){return e.disabled=`data-disabled`,e.orientation=`data-orientation`,e.multiple=`data-multiple`,e}({}),A7={multiple(e){return e?{[Ere.multiple]:``}:null}},Dre=Z.forwardRef(function(e,t){let{defaultValue:n,disabled:r=!1,loopFocus:i=!0,onValueChange:a,orientation:o=`horizontal`,multiple:s=!1,value:c,className:l,render:u,style:d,...f}=e,p=ly(!0),m=Z.useMemo(()=>{if(c===void 0)return n??[]},[c,n]),h=Z.useMemo(()=>c!==void 0||n!==void 0,[c,n]),g=(p?.disabled??!1)||r,[_,v]=_s({controlled:c,default:m,name:`ToggleGroup`,state:`value`}),y=J((e,t,n)=>{let r;if(s?(r=_.slice(),t?r.push(e):r.splice(_.indexOf(e),1)):r=t?[e]:[],Array.isArray(r)){if(a?.(r,n),n.isCanceled)return;v(r)}}),b={disabled:g,multiple:s,orientation:o},x=Z.useMemo(()=>({disabled:g,orientation:o,setGroupValue:y,value:_,isValueInitialized:h}),[g,o,y,_,h]),S={role:`group`},C=at(`div`,e,{enabled:!!p,state:b,ref:t,props:[S,f],stateAttributesMapping:A7});return(0,Q.jsx)(k7.Provider,{value:x,children:p?C:(0,Q.jsx)(Kv,{render:u,className:l,style:d,state:b,refs:[t],props:[S,f],stateAttributesMapping:A7,loopFocus:i,enableHomeAndEndKeys:!0,orientation:o})})}),Ore=Oo(`group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-transparent`,outline:`border border-input bg-transparent hover:bg-muted`},size:{default:`h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,sm:`h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`}},defaultVariants:{variant:`default`,size:`default`}}),j7=Z.createContext({size:`default`,variant:`default`,spacing:0,orientation:`horizontal`});function kre(e){let t=(0,$.c)(29),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({className:r,variant:c,size:a,spacing:o,orientation:s,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=o===void 0?0:o,u=s===void 0?`horizontal`:s,d;t[8]===l?d=t[9]:(d={"--gap":l},t[8]=l,t[9]=d);let f=d,p;t[10]===r?p=t[11]:(p=rn(`group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-vertical:flex-col data-vertical:items-stretch`,r),t[10]=r,t[11]=p);let m;t[12]!==u||t[13]!==a||t[14]!==l||t[15]!==c?(m={variant:c,size:a,spacing:l,orientation:u},t[12]=u,t[13]=a,t[14]=l,t[15]=c,t[16]=m):m=t[16];let h;t[17]!==n||t[18]!==m?(h=(0,Q.jsx)(j7.Provider,{value:m,children:n}),t[17]=n,t[18]=m,t[19]=h):h=t[19];let g;return t[20]!==u||t[21]!==i||t[22]!==a||t[23]!==l||t[24]!==f||t[25]!==p||t[26]!==h||t[27]!==c?(g=(0,Q.jsx)(Dre,{"data-slot":`toggle-group`,"data-variant":c,"data-size":a,"data-spacing":l,"data-orientation":u,style:f,className:p,...i,children:h}),t[20]=u,t[21]=i,t[22]=a,t[23]=l,t[24]=f,t[25]=p,t[26]=h,t[27]=c,t[28]=g):g=t[28],g}function Are(e){let t=(0,$.c)(19),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,children:n,variant:a,size:o,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=a===void 0?`default`:a,c=o===void 0?`default`:o,l=Z.useContext(j7),u=l.variant||s,d=l.size||c,f=l.spacing,p;t[6]!==r||t[7]!==l.size||t[8]!==l.variant||t[9]!==c||t[10]!==s?(p=rn(`shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t`,Ore({variant:l.variant||s,size:l.size||c}),r),t[6]=r,t[7]=l.size,t[8]=l.variant,t[9]=c,t[10]=s,t[11]=p):p=t[11];let m;return t[12]!==n||t[13]!==l.spacing||t[14]!==i||t[15]!==u||t[16]!==d||t[17]!==p?(m=(0,Q.jsx)(Tre,{"data-slot":`toggle-group-item`,"data-variant":u,"data-size":d,"data-spacing":f,className:p,...i,children:n}),t[12]=n,t[13]=l.spacing,t[14]=i,t[15]=u,t[16]=d,t[17]=p,t[18]=m):m=t[18],m}function jre(e){let t=(0,$.c)(23),{title:n,meta:r,controls:i,className:a,bodyClassName:o,children:s}=e,c;t[0]===a?c=t[1]:(c=rn(`overflow-hidden rounded-xl border border-border/80 bg-card/50`,a),t[0]=a,t[1]=c);let l;t[2]===n?l=t[3]:(l=(0,Q.jsx)(`div`,{className:`text-xs font-bold tracking-[0.04em] text-muted-foreground uppercase`,children:n}),t[2]=n,t[3]=l);let u;t[4]===r?u=t[5]:(u=r?(0,Q.jsx)(`div`,{className:`min-w-0 truncate text-xs text-muted-foreground/80`,children:r}):null,t[4]=r,t[5]=u);let d;t[6]!==l||t[7]!==u?(d=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-3`,children:[l,u]}),t[6]=l,t[7]=u,t[8]=d):d=t[8];let f;t[9]===i?f=t[10]:(f=i?(0,Q.jsx)(`div`,{className:`shrink-0`,children:i}):null,t[9]=i,t[10]=f);let p;t[11]!==d||t[12]!==f?(p=(0,Q.jsxs)(`div`,{className:`flex min-h-10 items-center justify-between gap-3 border-b border-border/70 bg-background px-3 py-2`,children:[d,f]}),t[11]=d,t[12]=f,t[13]=p):p=t[13];let m;t[14]===o?m=t[15]:(m=rn(`grid gap-2 px-3 py-2.5`,o),t[14]=o,t[15]=m);let h;t[16]!==s||t[17]!==m?(h=(0,Q.jsx)(`div`,{className:m,children:s}),t[16]=s,t[17]=m,t[18]=h):h=t[18];let g;return t[19]!==c||t[20]!==p||t[21]!==h?(g=(0,Q.jsxs)(`section`,{className:c,children:[p,h]}),t[19]=c,t[20]=p,t[21]=h,t[22]=g):g=t[22],g}var M7=[`#0ea5e9`,`#db2777`,`#22c55e`,`#f59e0b`,`#8b5cf6`,`#14b8a6`],N7=-1,P7=20,Mre=150,F7=14,I7=12;function L7(e,t=!1){return t?`#f87171`:M7[e%M7.length]}var Nre=class{colour;lines=[];constructor(e){this.colour=e}addLine(e,t){this.lines.push({p1:e,p2:t})}getColour(){return this.colour}getLines(){return this.lines}},R7=class{id;connections=[];nextParent=0;nextX=0;onBranch=null;parents=[];x=0;constructor(e){this.id=e}addParent(e){this.parents.push(e)}getNextParent(){return this.parents[this.nextParent]??null}registerParentProcessed(){this.nextParent+=1}isMerge(){return this.parents.length>1}addToBranch(e,t){this.onBranch===null&&(this.onBranch=e,this.x=t)}isNotOnBranch(){return this.onBranch===null}getBranch(){return this.onBranch}getPoint(){return{x:this.x,y:this.id}}getNextPoint(){return{x:this.nextX,y:this.id}}getPointConnectingTo(e,t){for(let n=0;n<this.connections.length;n++){let r=this.connections[n];if(r?.connectsTo===e&&r.onBranch===t)return{x:n,y:this.id}}return null}registerUnavailablePoint(e,t,n){e===this.nextX&&(this.nextX=e+1,this.connections[e]={connectsTo:t,onBranch:n})}};function z7(e){let t=e.map(e=>I_(e)),n=new Map;t.forEach((e,t)=>{e.fullHash&&n.set(e.fullHash,t)});let r=new R7(N7),i=t.map((e,t)=>new R7(t)),a=[],o=[];t.forEach((e,t)=>{if(!e.fullHash)return;let a=i[t];e.parents.forEach(e=>{let t=n.get(e);if(typeof t==`number`){let e=i[t];a.addParent(e)}else a.addParent(r)})});let s=e=>{for(let t=0;t<o.length;t++)if(e>(o[t]??0))return t;return o.push(0),o.length-1},c=e=>{let t=e,n=i[t],r=n.getNextParent(),c=n.isNotOnBranch()?n.getNextPoint():n.getPoint();if(r!==null&&r.id!==N7&&n.isMerge()&&!n.isNotOnBranch()&&!r.isNotOnBranch()){let a=r.getBranch(),o=!1;for(t=e+1;t<i.length;t++){let e=i[t],s=e.getPointConnectingTo(r,a),l=s??e.getNextPoint();if(a.addLine(c,l),e.registerUnavailablePoint(l.x,r,a),c=l,s!==null){n.registerParentProcessed(),o=!0;break}}o||n.registerParentProcessed();return}let l=new Nre(s(e));for(n.addToBranch(l,c.x),n.registerUnavailablePoint(c.x,n,l),t=e+1;t<i.length;t++){let e=i[t],a=r===e&&!r.isNotOnBranch()?e.getPoint():e.getNextPoint();if(l.addLine(c,a),e.registerUnavailablePoint(a.x,r,l),c=a,r===e){n.registerParentProcessed();let e=!r.isNotOnBranch();if(r.addToBranch(l,a.x),n=r,r=n.getNextParent(),r===null||e)break}}t===i.length&&r!==null&&r.id===N7&&n.registerParentProcessed(),a.push(l),o[l.getColour()]=t},l=0;for(;l<i.length;){let e=i[l];t[l].fullHash&&(e.getNextParent()!==null||e.isNotOnBranch())?c(l):l+=1}let u=t.map((e,t)=>{let n=i[t]?.getBranch()??null;return{colour:n?.getColour()??0,commitLane:e.fullHash&&n?i[t].getPoint().x:-1,parsed:e}});return{branches:a,maxLaneCount:Math.max(1,...i.map(e=>e.getNextPoint().x)),rows:u}}function B7(e,t){return e.parsed.fullHash||`commit-row:${t}`}function V7(e,t){let n=new Set(t);return e.map((e,t)=>n.has(B7(e,t))?P7+Mre:P7)}function Pre(e){let t=0;return e.map(e=>{let n=t;return t+=e,n})}function Fre(e){return e.reduce((e,t)=>e+t,0)}function H7(e,t){return(e[t]??t*P7)+P7/2}function Ire({line:e,rowTops:t}){let n=e.p1.x*F7+I7,r=H7(t,e.p1.y),i=e.p2.x*F7+I7,a=H7(t,e.p2.y);if(n===i)return`M ${n} ${r} L ${i} ${a}`;let o=P7*.8;return`M ${n} ${r} C ${n} ${r+o}, ${i} ${a-o}, ${i} ${a}`}function Lre(e){let t=(0,$.c)(15),{lines:n,openCommitValues:r,unpushedCommitShortHashes:i}=e,a,o,s,c;if(t[0]!==n||t[1]!==r||t[2]!==i){let{branches:e,maxLaneCount:l,rows:u}=z7(n),d=V7(u,r),f=Pre(d);c=Math.max(24,l*F7+4),o=Math.max(P7,Fre(d)),s=[],a=[],e.forEach((e,t)=>{e.getLines().forEach((n,r)=>{s.push((0,Q.jsx)(`path`,{d:Ire({line:n,rowTops:f}),fill:`none`,stroke:L7(e.getColour()),strokeLinecap:`round`,strokeWidth:`2`},`path:${t}:${r}`))})}),u.forEach((e,t)=>{if(e.commitLane<0)return;let n=e.commitLane*F7+I7,r=H7(f,t),o=!!(e.parsed.hash&&i.has(e.parsed.hash));a.push((0,Q.jsx)(`circle`,{cx:n,cy:r,r:`4`,fill:L7(e.colour,o)},`circle:${t}:${e.parsed.fullHash}`))}),t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c}else a=t[3],o=t[4],s=t[5],c=t[6];let l=`0 0 ${c} ${o}`,u;t[7]!==o||t[8]!==c?(u={width:c,height:o},t[7]=o,t[8]=c,t[9]=u):u=t[9];let d;return t[10]!==a||t[11]!==s||t[12]!==l||t[13]!==u?(d=(0,Q.jsxs)(`svg`,{"aria-hidden":!0,viewBox:l,className:`pointer-events-none absolute top-0 left-0 z-10 overflow-visible`,style:u,children:[s,a]}),t[10]=a,t[11]=s,t[12]=l,t[13]=u,t[14]=d):d=t[14],d}function Rre(e){let t=(0,$.c)(66),{graphWidth:n,line:r,value:i}=e,a=I_(r),[o,s]=Z.useState(!1),c=Z.useRef(void 0),l=a.subject.trim(),u=L_(a.relativeDate),d=R_(a.fullDate),f=z_(a.stats,`insertions`),p=z_(a.stats,`deletions`),m=a.hash||a.fullHash.slice(0,7),h,g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>()=>{typeof c.current==`number`&&window.clearTimeout(c.current)},g=[],t[0]=h,t[1]=g):(h=t[0],g=t[1]),Z.useEffect(h,g);let _;t[2]!==a.fullHash||t[3]!==s?(_=()=>{a.fullHash&&V_(a.fullHash).then(e=>{e&&(s(!0),typeof c.current==`number`&&window.clearTimeout(c.current),c.current=window.setTimeout(()=>{s(!1)},1200))})},t[2]=a.fullHash,t[3]=s,t[4]=_):_=t[4];let v=_;if(!a.hash&&!a.subject){let e;t[5]===a.subject?e=t[6]:(e=a.subject?(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:a.subject}):null,t[5]=a.subject,t[6]=e);let n;return t[7]===e?n=t[8]:(n=(0,Q.jsx)(`div`,{className:`flex h-5 max-w-full min-w-0 items-center font-mono text-[13px] leading-5`,children:e}),t[7]=e,t[8]=n),n}let y;t[9]===n?y=t[10]:(y={paddingLeft:n},t[9]=n,t[10]=y);let b=l||a.hash||`Commit`,x;t[11]!==y||t[12]!==b?(x=(0,Q.jsx)(Sb,{headerClassName:`min-w-0`,className:`h-5 min-h-5 w-full items-center gap-2 rounded-none px-1.5 py-0 font-mono text-[13px] leading-5 font-normal transition-colors hover:bg-muted/50 hover:text-foreground hover:no-underline focus-visible:ring-0 aria-expanded:bg-muted aria-expanded:text-foreground **:data-[slot=accordion-trigger-icon]:size-4`,children:(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,style:y,children:b})}),t[11]=y,t[12]=b,t[13]=x):x=t[13];let S=x,C;t[14]===S?C=t[15]:(C=(0,Q.jsx)(f7,{render:S}),t[14]=S,t[15]=C);let w=!a.fullHash,T;t[16]===a.fullHash?T=t[17]:(T=()=>{V_(a.fullHash)},t[16]=a.fullHash,t[17]=T);let E;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Q.jsx)(Ia,{}),t[18]=E):E=t[18];let D;t[19]!==w||t[20]!==T?(D=(0,Q.jsxs)(m7,{disabled:w,onClick:T,children:[E,`Copy commit hash`]}),t[19]=w,t[20]=T,t[21]=D):D=t[21];let O=!a.subject,k;t[22]===a.subject?k=t[23]:(k=()=>{V_(a.subject)},t[22]=a.subject,t[23]=k);let A;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Q.jsx)(Ia,{}),t[24]=A):A=t[24];let j;t[25]!==O||t[26]!==k?(j=(0,Q.jsxs)(m7,{disabled:O,onClick:k,children:[A,`Copy commit message`]}),t[25]=O,t[26]=k,t[27]=j):j=t[27];let M;t[28]!==D||t[29]!==j?(M=(0,Q.jsxs)(p7,{className:`w-52`,children:[D,j]}),t[28]=D,t[29]=j,t[30]=M):M=t[30];let N;t[31]!==M||t[32]!==C?(N=(0,Q.jsxs)(d7,{children:[C,M]}),t[31]=M,t[32]=C,t[33]=N):N=t[33];let P;t[34]===n?P=t[35]:(P={paddingLeft:n},t[34]=n,t[35]=P);let F;t[36]!==d||t[37]!==a.author||t[38]!==u?(F=a.author||u?(0,Q.jsxs)(`div`,{className:`flex max-w-full flex-wrap items-center gap-x-2 gap-y-1 text-muted-foreground`,children:[a.author?(0,Q.jsx)(`span`,{children:a.author}):null,a.author&&u?(0,Q.jsx)(`span`,{"aria-hidden":!0,children:`·`}):null,u?(0,Q.jsx)(Je,{title:d,side:`top`,children:(0,Q.jsx)(`span`,{children:u})}):null]}):null,t[36]=d,t[37]=a.author,t[38]=u,t[39]=F):F=t[39];let I=l||`No commit message`,L;t[40]===I?L=t[41]:(L=(0,Q.jsx)(`div`,{className:`max-w-full break-words whitespace-normal text-foreground`,children:I}),t[40]=I,t[41]=L);let R=f===1?``:`s`,z;t[42]!==f||t[43]!==R?(z=(0,Q.jsxs)(`span`,{className:`text-emerald-500`,children:[`+`,f,` addition`,R]}),t[42]=f,t[43]=R,t[44]=z):z=t[44];let B=p===1?``:`s`,V;t[45]!==p||t[46]!==B?(V=(0,Q.jsxs)(`span`,{className:`text-red-400`,children:[`-`,p,` deletion`,B]}),t[45]=p,t[46]=B,t[47]=V):V=t[47];let H;t[48]!==z||t[49]!==V?(H=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1`,children:[z,V]}),t[48]=z,t[49]=V,t[50]=H):H=t[50];let U;t[51]!==v||t[52]!==o||t[53]!==a.fullHash||t[54]!==m?(U=a.fullHash?(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:m}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Copy full commit hash`,className:`inline-flex size-5 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,onClick:e=>{e.preventDefault(),e.stopPropagation(),v()},children:o?(0,Q.jsx)(ja,{className:`size-3.5 text-emerald-500`}):(0,Q.jsx)(Ia,{className:`size-3.5`})})]}):null,t[51]=v,t[52]=o,t[53]=a.fullHash,t[54]=m,t[55]=U):U=t[55];let W;t[56]!==P||t[57]!==F||t[58]!==L||t[59]!==H||t[60]!==U?(W=(0,Q.jsx)(Cb,{className:`h-[150px] overflow-y-auto border-b border-border/70 bg-muted/20 pr-2 pb-2`,children:(0,Q.jsxs)(`div`,{className:`grid content-start gap-1.5 pt-1 font-mono text-xs leading-4`,style:P,children:[F,L,H,U]})}),t[56]=P,t[57]=F,t[58]=L,t[59]=H,t[60]=U,t[61]=W):W=t[61];let G;return t[62]!==N||t[63]!==W||t[64]!==i?(G=(0,Q.jsxs)(xb,{value:i,className:`border-0`,children:[N,W]}),t[62]=N,t[63]=W,t[64]=i,t[65]=G):G=t[65],G}function zre(e){let t=(0,$.c)(23),{lines:n,unpushedCommitShortHashes:r}=e,{maxLaneCount:i,rows:a}=z7(n),o=Math.max(24,i*F7+4),s=a.map(Bre),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[0]=c):c=t[0];let[l,u]=Z.useState(c),d=l.filter(e=>s.includes(e)),f=V7(a,d),p;t[1]!==n||t[2]!==r||t[3]!==d?(p=(0,Q.jsx)(Lre,{lines:n,openCommitValues:d,unpushedCommitShortHashes:r}),t[1]=n,t[2]=r,t[3]=d,t[4]=p):p=t[4];let m;t[5]===u?m=t[6]:(m=e=>{u(e.slice(-1))},t[5]=u,t[6]=m);let h;if(t[7]!==o||t[8]!==n||t[9]!==f||t[10]!==s){let e;t[12]!==o||t[13]!==f||t[14]!==s?(e=(e,t)=>(0,Q.jsx)(`div`,{className:`min-w-0`,style:{minHeight:f[t]??P7},children:(0,Q.jsx)(Rre,{graphWidth:o,line:e,value:s[t]??`${t}`})},`${t}:${e}`),t[12]=o,t[13]=f,t[14]=s,t[15]=e):e=t[15],h=n.map(e),t[7]=o,t[8]=n,t[9]=f,t[10]=s,t[11]=h}else h=t[11];let g;t[16]!==m||t[17]!==h||t[18]!==d?(g=(0,Q.jsx)(bb,{multiple:!0,value:d,onValueChange:m,className:`grid min-w-0 gap-0`,children:h}),t[16]=m,t[17]=h,t[18]=d,t[19]=g):g=t[19];let _;return t[20]!==p||t[21]!==g?(_=(0,Q.jsxs)(`div`,{className:`relative min-w-0`,children:[p,g]}),t[20]=p,t[21]=g,t[22]=_):_=t[22],_}function Bre(e,t){return B7(e,t)}function Vre(e){let t=(0,$.c)(50),{viewerContextId:n,cwd:r,active:i,embedded:a,flush:o}=e,s=a===void 0?!1:a,c=o===void 0?!1:o,l=a_(r),[u,d]=Z.useState(50),f=Z.useRef(null),p;t[0]===d?p=t[1]:(p=()=>{d(50)},t[0]=d,t[1]=p),Z.useEffect(p,[l]);let m=_g.gitCommits(n,l),h=f_({viewerContextId:n,cwd:l,scope:`commits`,commitsLimit:u}),g=!!(i&&n&&l),_;t[2]===m?_=t[3]:(_=(e,t)=>{let n=t?.queryKey;return m.every((e,t)=>n?.[t]===e)?e:void 0},t[2]=m,t[3]=_);let v;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(v=[`data`,`isFetching`,`isPending`,`error`],t[4]=v):v=t[4];let y;t[5]!==h||t[6]!==g||t[7]!==_?(y={...h,enabled:g,placeholderData:_,notifyOnChangeProps:v},t[5]=h,t[6]=g,t[7]=_,t[8]=y):y=t[8];let b=Or(y),x=b.data,S=x?.commits,C=!!x?.commitsHasMore,w;t[9]===S?w=t[10]:(w=Array.isArray(S)?F_(S):``,t[9]=S,t[10]=w);let T=w,E;t[11]===x?.unpushedCommitShortHashes?E=t[12]:(E=x?.unpushedCommitShortHashes??[],t[11]=x?.unpushedCommitShortHashes,t[12]=E);let D;t[13]===E?D=t[14]:(D=new Set(E),t[13]=E,t[14]=D);let O=D,k;t[15]!==i||t[16]!==C||t[17]!==b.isFetching||t[18]!==d?(k=()=>{let e=f.current;if(!e||!i||!C||b.isFetching||typeof IntersectionObserver>`u`)return;let t=!1,n=new IntersectionObserver(e=>{let[n]=e;!n?.isIntersecting||t||(t=!0,d(Ure))},{rootMargin:`320px 0px`});return n.observe(e),()=>n.disconnect()},t[15]=i,t[16]=C,t[17]=b.isFetching,t[18]=d,t[19]=k):k=t[19];let A;t[20]!==i||t[21]!==C||t[22]!==b.isFetching||t[23]!==l?(A=[i,C,b.isFetching,l],t[20]=i,t[21]=C,t[22]=b.isFetching,t[23]=l,t[24]=A):A=t[24],Z.useEffect(k,A);let j;t[25]!==S||t[26]!==C||t[27]!==b.error||t[28]!==b.isFetching||t[29]!==b.isPending||t[30]!==l||t[31]!==d||t[32]!==O||t[33]!==n?(j=l?n?b.isPending&&S===void 0||b.isFetching&&S===null?(0,Q.jsxs)(h7,{className:`px-3 py-2.5`,children:[(0,Q.jsx)(H,{}),` Loading commits…`]}):b.error?(0,Q.jsx)(h7,{tone:`destructive`,className:`px-3 py-2.5`,children:c_(b.error,`Failed to load commits`)}):S===null?(0,Q.jsx)(h7,{className:`px-3 py-2.5`,children:`No git repository detected.`}):Array.isArray(S)&&S.length>0?(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-3`,children:[(0,Q.jsx)(zre,{lines:S,unpushedCommitShortHashes:O}),C?(0,Q.jsx)(`div`,{ref:f,className:`flex`,children:(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex h-8 w-fit items-center justify-center rounded-md border border-border/80 bg-background px-3 text-xs font-semibold text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-60`,disabled:b.isFetching,onClick:()=>{d(Hre)},children:b.isFetching?`Loading more…`:`Load more`})}):null]}):(0,Q.jsx)(h7,{className:`px-3 py-2.5`,children:`No commits on this branch yet.`}):(0,Q.jsx)(h7,{className:`px-3 py-2.5`,children:`Waiting for viewer context…`}):(0,Q.jsx)(h7,{className:`px-3 py-2.5`,children:`No directory selected.`}),t[25]=S,t[26]=C,t[27]=b.error,t[28]=b.isFetching,t[29]=b.isPending,t[30]=l,t[31]=d,t[32]=O,t[33]=n,t[34]=j):j=t[34];let M=j;if(s){let e;return t[35]===M?e=t[36]:(e=(0,Q.jsx)(`div`,{className:`grid min-w-0 gap-2 overflow-x-hidden`,children:M}),t[35]=M,t[36]=e),e}if(c){let e;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(`div`,{className:`text-xs font-bold tracking-[0.04em] text-muted-foreground uppercase`,children:`History`}),t[37]=e):e=t[37];let n;t[38]===T?n=t[39]:(n=T?(0,Q.jsx)(`div`,{className:`min-w-0 truncate text-xs text-muted-foreground/80`,children:T}):null,t[38]=T,t[39]=n);let r;t[40]===n?r=t[41]:(r=(0,Q.jsx)(`div`,{className:`flex min-h-10 items-center justify-between gap-3 border-b border-border/70 bg-background px-3 py-2`,children:(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-3`,children:[e,n]})}),t[40]=n,t[41]=r);let i;t[42]===M?i=t[43]:(i=(0,Q.jsx)(`div`,{className:`grid min-h-0 min-w-0 flex-1 gap-2 overflow-x-hidden overflow-y-auto`,children:M}),t[42]=M,t[43]=i);let a;return t[44]!==r||t[45]!==i?(a=(0,Q.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-background`,children:[r,i]}),t[44]=r,t[45]=i,t[46]=a):a=t[46],a}let N;return t[47]!==M||t[48]!==T?(N=(0,Q.jsx)(jre,{title:`Commits`,meta:T,className:`overflow-x-hidden`,bodyClassName:`min-w-0 overflow-x-hidden p-0`,children:M}),t[47]=M,t[48]=T,t[49]=N):N=t[49],N}function Hre(e){return e+50}function Ure(e){return e+50}function U7(e,t){e(e=>Object.is(e,t)?e:t)}function Wre(e){return!!(e&&e.scrollTop>0)}function Gre({getValue:e,scrollElement:t,selector:n}){if(!t||t.scrollTop<=0)return``;let r=t.getBoundingClientRect().top,i=Array.from(t.querySelectorAll(n));for(let t of i){let n=t.getBoundingClientRect();if(n.top<=r+1&&n.bottom>r+1)return e(t)}return``}function Kre(e){let t=(0,$.c)(2),{status:n}=e,r;if(t[0]!==n){let[e,i]=S_(n);r=(0,Q.jsx)(`span`,{className:`inline-flex w-[2ch] shrink-0 items-center whitespace-pre text-muted-foreground/70`,children:[[`index`,e],[`worktree`,i]].map(e=>{let[t,r]=e,i=C_({character:r,column:t,status:n}),a=(0,Q.jsx)(`span`,{"aria-label":i||void 0,className:rn(`w-[1ch] text-center whitespace-pre`,i&&`cursor-help`,T_(w_(t,r))),children:r},t);return i?(0,Q.jsx)(Je,{title:i,side:`top`,children:a},t):a})}),t[0]=n,t[1]=r}else r=t[1];return r}function qre(e){let t=(0,$.c)(8),{file:n}=e;if(!D_(n)){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(`span`,{className:`min-w-0`}),t[0]=e):e=t[0],e}let r=E_(n.linesAdded),i=E_(n.linesDeleted),a;t[1]===r?a=t[2]:(a=r>0?(0,Q.jsxs)(`span`,{className:`text-emerald-500`,children:[`+`,r]}):null,t[1]=r,t[2]=a);let o;t[3]===i?o=t[4]:(o=i>0?(0,Q.jsxs)(`span`,{className:`text-red-500`,children:[`-`,i]}):null,t[3]=i,t[4]=o);let s;return t[5]!==a||t[6]!==o?(s=(0,Q.jsxs)(`span`,{className:`inline-flex min-w-0 gap-2 justify-self-end whitespace-nowrap tabular-nums`,children:[a,o]}),t[5]=a,t[6]=o,t[7]=s):s=t[7],s}var W7=160,Jre=1600;function G7(e){if(Number.isFinite(e))return Math.round(Math.min(Jre,Math.max(W7,e)))}function K7(){let e=A(pt);if(e!=null)return G7(Number(e))}function Yre(e){let t=G7(e);typeof t==`number`&&ee(pt,String(t))}function q7(e){return`${e.status}:${e.previousPath||``}:${e.path}`}function Xre(e){return E_(e.linesAdded)+E_(e.linesDeleted)}function Zre(e){return typeof e.sizeBytes==`number`&&e.sizeBytes>1e4||Xre(e)>100}function Qre(e){let t=(0,$.c)(114),{viewerContextId:n,cwd:r,active:i,onOpenFile:a}=e,o=a_(r),s=Ao(),[c,l]=Z.useState(`unified`),[u,d]=Z.useState(!0),[f,p]=Z.useState(nie),[m,h]=Z.useState(void 0),[g,_]=Z.useState(`row-resize`),v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=[],t[0]=v):v=t[0];let[y,b]=Z.useState(v),[x,S]=Z.useState(``),[C,w]=Z.useState(!1),T=Z.useRef(null),E=Z.useRef(null),D=Z.useRef(null),O=Z.useRef(null),k=Z.useRef(o),A=f_({viewerContextId:n,cwd:o,scope:`files`}),j=!!(i&&n&&o),M;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(M=[`data`,`isPending`,`error`],t[1]=M):M=t[1];let N;t[2]!==A||t[3]!==j?(N={...A,enabled:j,select:g_,notifyOnChangeProps:M},t[2]=A,t[3]=j,t[4]=N):N=t[4];let P=Or(N),F=P.data,I;t[5]===F?I=t[6]:(I=Array.isArray(F)?F:[],t[5]=F,t[6]=I);let L=I,R;t[7]!==o||t[8]!==k||t[9]!==h||t[10]!==w||t[11]!==d||t[12]!==p||t[13]!==b||t[14]!==S?(R=()=>{k.current!==o&&(k.current=o,d(!0),p(K7()),h(void 0),b([]),S(``),w(!1))},t[7]=o,t[8]=k,t[9]=h,t[10]=w,t[11]=d,t[12]=p,t[13]=b,t[14]=S,t[15]=R):R=t[15];let z;t[16]===o?z=t[17]:(z=[o],t[16]=o,t[17]=z),Z.useEffect(R,z);let B;t[18]===_?B=t[19]:(B=()=>{_(Bo())},t[18]=_,t[19]=B);let V;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(V=[],t[20]=V):V=t[20],Z.useEffect(B,V);let U;t[21]===S?U=t[22]:(U=e=>{U7(S,Gre({getValue:tie,scrollElement:e,selector:`[data-review-file-trigger]`}))},t[21]=S,t[22]=U);let W=U,G;t[23]===w?G=t[24]:(G=e=>{U7(w,Wre(e))},t[23]=w,t[24]=G);let ee=G,te;t[25]===W?te=t[26]:(te=()=>{W(T.current)},t[25]=W,t[26]=te);let K;t[27]===y?K=t[28]:(K=[y],t[27]=y,t[28]=K),Z.useEffect(te,K);let ne;t[29]!==u||t[30]!==w||t[31]!==ee?(ne=()=>{if(!u){U7(w,!1);return}ee(O.current)},t[29]=u,t[30]=w,t[31]=ee,t[32]=ne):ne=t[32];let q;t[33]===u?q=t[34]:(q=[u],t[33]=u,t[34]=q),Z.useEffect(ne,q);let J;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(J=()=>{let e=E.current?.getBoundingClientRect().height||0;if(e<=0)return{minHeight:W7,maxHeight:1/0};let t=Math.min(W7,e/2);return{minHeight:t,maxHeight:Math.max(t,e-t)}},t[35]=J):J=t[35];let re=J,Y;t[36]!==s||t[37]!==p?(Y=e=>{if(s||e.button!==0)return;e.preventDefault();let{maxHeight:t,minHeight:n}=re(),r=D.current?.getBoundingClientRect().height||n,i=e.clientY,a=document.body.style.cursor,o=document.body.style.userSelect,c=Bo(),l=Ho(c),u=Math.min(t,Math.max(n,r));document.body.style.cursor=c,document.body.style.userSelect=`none`;let d=e=>{let a=r-(e.clientY-i);u=Math.min(t,Math.max(n,a)),p(u)},f=()=>{Yre(u),l(),document.body.style.cursor=a,document.body.style.userSelect=o,document.removeEventListener(`pointermove`,d),document.removeEventListener(`pointerup`,f),document.removeEventListener(`pointercancel`,f)};document.addEventListener(`pointermove`,d),document.addEventListener(`pointerup`,f),document.addEventListener(`pointercancel`,f)},t[36]=s,t[37]=p,t[38]=Y):Y=t[38];let ie=Y,ae;t[39]!==u||t[40]!==s||t[41]!==h||t[42]!==p?(ae=()=>{if(s||!u)return;let e=()=>{let e=E.current?.getBoundingClientRect().height||0,{maxHeight:t,minHeight:n}=re(),r=e>0?e*.5:0;h(r>0?Math.min(t,Math.max(n,r)):void 0),p(e=>typeof e==`number`?Math.min(t,Math.max(n,e)):e)};return e(),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e)}},t[39]=u,t[40]=s,t[41]=h,t[42]=p,t[43]=ae):ae=t[43];let oe;t[44]!==u||t[45]!==s||t[46]!==o?(oe=[u,s,o],t[44]=u,t[45]=s,t[46]=o,t[47]=oe):oe=t[47],Z.useEffect(ae,oe);let se=y.length>0,ce;t[48]!==L||t[49]!==se||t[50]!==b?(ce=()=>{b(se?[]:L.map(q7))},t[48]=L,t[49]=se,t[50]=b,t[51]=ce):ce=t[51];let le=ce,ue;t[52]!==i||t[53]!==o||t[54]!==n?(ue=(0,Q.jsx)(`div`,{className:`flex min-h-12 shrink-0 flex-col justify-center gap-2 border-b border-border/70 bg-background p-2`,children:(0,Q.jsx)(Sre,{viewerContextId:n,cwd:o,active:i})}),t[52]=i,t[53]=o,t[54]=n,t[55]=ue):ue=t[55];let de;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,Q.jsx)(`div`,{className:`flex min-w-0 items-center`,children:(0,Q.jsx)(`span`,{className:`text-xs font-bold tracking-[0.04em] text-muted-foreground uppercase`,children:`Diffs`})}),t[56]=de):de=t[56];let fe;t[57]===c?fe=t[58]:(fe=[c],t[57]=c,t[58]=fe);let pe;t[59]===l?pe=t[60]:(pe=e=>{let t=e[0];(t===`unified`||t===`split`)&&l(t)},t[59]=l,t[60]=pe);let me;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(me=[`unified`,`split`],t[61]=me):me=t[61];let he;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(he=me.map(eie),t[62]=he):he=t[62];let ge;t[63]!==fe||t[64]!==pe?(ge=(0,Q.jsx)(kre,{variant:`outline`,value:fe,onValueChange:pe,children:he}),t[63]=fe,t[64]=pe,t[65]=ge):ge=t[65];let _e=L.length===0,ve;t[66]===se?ve=t[67]:(ve=se?(0,Q.jsx)(Pa,{className:`size-4`}):(0,Q.jsx)(Fa,{className:`size-4`}),t[66]=se,t[67]=ve);let ye=se?`Collapse all`:`Expand all`,be;t[68]!==_e||t[69]!==ve||t[70]!==ye||t[71]!==le?(be=(0,Q.jsxs)(ss,{variant:`outline`,disabled:_e,onClick:le,children:[ve,ye]}),t[68]=_e,t[69]=ve,t[70]=ye,t[71]=le,t[72]=be):be=t[72];let xe;t[73]!==ge||t[74]!==be?(xe=(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border/70 bg-background p-2`,children:[de,(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[ge,be]})]}),t[73]=ge,t[74]=be,t[75]=xe):xe=t[75];let Se;t[76]===W?Se=t[77]:(Se=e=>{W(e.currentTarget)},t[76]=W,t[77]=Se);let Ce;t[78]!==i||t[79]!==L||t[80]!==c||t[81]!==F||t[82]!==P.error||t[83]!==P.isPending||t[84]!==o||t[85]!==a||t[86]!==y||t[87]!==b||t[88]!==x||t[89]!==n?(Ce=o?n?P.isPending&&F===void 0?(0,Q.jsxs)(h7,{className:`px-3 py-2.5`,children:[(0,Q.jsx)(H,{}),` Loading changes…`]}):P.error?(0,Q.jsx)(h7,{tone:`destructive`,className:`px-3 py-2.5`,children:c_(P.error,`Failed to load changes`)}):F===null?(0,Q.jsx)(h7,{className:`px-3 py-2.5`,children:`No git repository detected.`}):L.length>0?(0,Q.jsx)(bb,{multiple:!0,value:y,onValueChange:b,className:`border-b border-border/80`,children:L.map(e=>(0,Q.jsx)(rie,{viewerContextId:n,cwd:o,active:i,diffStyle:c,file:e,open:y.includes(q7(e)),stuck:x===q7(e),onOpenFile:a},q7(e)))}):(0,Q.jsx)(h7,{className:`px-3 py-2.5`,children:`Working tree clean.`}):(0,Q.jsx)(h7,{className:`px-3 py-2.5`,children:`Waiting for viewer context…`}):(0,Q.jsx)(h7,{className:`px-3 py-2.5`,children:`No directory selected.`}),t[78]=i,t[79]=L,t[80]=c,t[81]=F,t[82]=P.error,t[83]=P.isPending,t[84]=o,t[85]=a,t[86]=y,t[87]=b,t[88]=x,t[89]=n,t[90]=Ce):Ce=t[90];let we;t[91]!==Se||t[92]!==Ce?(we=(0,Q.jsx)(`div`,{ref:T,className:`min-h-0 flex-1 overflow-auto`,onScroll:Se,children:Ce}),t[91]=Se,t[92]=Ce,t[93]=we):we=t[93];let Te;t[94]!==i||t[95]!==m||t[96]!==F||t[97]!==P.error||t[98]!==C||t[99]!==u||t[100]!==f||t[101]!==s||t[102]!==o||t[103]!==d||t[104]!==ie||t[105]!==ee||t[106]!==g||t[107]!==n?(Te=o&&n&&F!==null&&!P.error?(0,Q.jsxs)(`div`,{ref:D,className:`relative flex max-h-[50%] min-h-0 shrink-0 flex-col overflow-hidden border-t border-border/70 bg-card/50 md:max-h-none`,style:!s&&u?{height:f??m}:void 0,children:[u?(0,Q.jsx)(`div`,{role:`separator`,"aria-label":`Resize history panel`,"aria-orientation":`horizontal`,style:{cursor:g},className:rn(`absolute inset-x-0 top-0 z-10 hidden h-2 -translate-y-1/2 touch-none bg-transparent after:absolute after:inset-x-0 after:top-1/2 after:h-px after:bg-transparent md:block`,Ss,g===`ns-resize`?`cursor-ns-resize`:`cursor-row-resize`),onPointerDown:ie}):null,(0,Q.jsxs)(`button`,{type:`button`,"aria-expanded":u,className:rn(`flex min-h-10 w-full shrink-0 items-center justify-between gap-3 bg-background px-3 py-2 text-left transition-[background-color,box-shadow] hover:bg-muted/60`,C&&`shadow-sm`),onClick:()=>{d($re)},children:[(0,Q.jsx)(`span`,{className:`flex min-w-0 items-center`,children:(0,Q.jsx)(`span`,{className:`text-xs font-bold tracking-[0.04em] text-muted-foreground uppercase`,children:`History`})}),u?(0,Q.jsx)(Ma,{className:`size-4 shrink-0 text-muted-foreground`}):(0,Q.jsx)(Gt,{className:`size-4 shrink-0 text-muted-foreground`})]}),u?(0,Q.jsx)(`div`,{ref:O,className:`min-h-0 flex-1 touch-pan-y overflow-x-hidden overflow-y-auto overscroll-contain border-t border-border/70`,onScroll:e=>{ee(e.currentTarget)},children:(0,Q.jsx)(Vre,{viewerContextId:n,cwd:o,active:i&&u,embedded:!0})}):null]}):null,t[94]=i,t[95]=m,t[96]=F,t[97]=P.error,t[98]=C,t[99]=u,t[100]=f,t[101]=s,t[102]=o,t[103]=d,t[104]=ie,t[105]=ee,t[106]=g,t[107]=n,t[108]=Te):Te=t[108];let Ee;return t[109]!==ue||t[110]!==xe||t[111]!==we||t[112]!==Te?(Ee=(0,Q.jsxs)(`div`,{ref:E,className:`flex h-full min-h-0 flex-col bg-background`,children:[ue,xe,we,Te]}),t[109]=ue,t[110]=xe,t[111]=we,t[112]=Te,t[113]=Ee):Ee=t[113],Ee}function $re(e){return!e}function eie(e){return(0,Q.jsx)(Are,{value:e,children:e===`unified`?`Unified`:`Split`},e)}function tie(e){return e.dataset.reviewFileValue||``}function nie(){return K7()}function rie(e){let t=(0,$.c)(59),{viewerContextId:n,cwd:r,active:i,diffStyle:a,file:o,open:s,stuck:c,onOpenFile:l}=e,u=a_(r),d;t[0]===o?d=t[1]:(d=q7(o),t[0]=o,t[1]=d);let f=d,[p,m]=Z.useState(!1),h;t[2]!==o||t[3]!==p?(h=Zre(o)&&!p,t[2]=o,t[3]=p,t[4]=h):h=t[4];let g=h,_=Or({...p_({viewerContextId:n,cwd:u,path:o.path}),enabled:!!(g&&s&&i&&n&&u),notifyOnChangeProps:[`data`,`isPending`,`error`]}),v=m_({viewerContextId:n,cwd:u,path:o.path,previousPath:o.previousPath}),y=!!(!g&&s&&i&&n&&u),b;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(b=[`data`,`isPending`,`error`],t[5]=b):b=t[5];let x;t[6]!==v||t[7]!==y?(x={...v,enabled:y,notifyOnChangeProps:b},t[6]=v,t[7]=y,t[8]=x):x=t[8];let S=Or(x),C=S.data?.oldContent??``,w=S.data?.newContent??``,T=_.data?.patch??``,E;t[9]===m?E=t[10]:(E=()=>{m(!1)},t[9]=m,t[10]=E);let D;t[11]===f?D=t[12]:(D=[f],t[11]=f,t[12]=D),Z.useEffect(E,D);let O=c&&`shadow-sm`,k;t[13]===O?k=t[14]:(k=rn(`group/review-file-header sticky top-0 z-20 flex bg-background transition-shadow`,O),t[13]=O,t[14]=k);let A;t[15]===o.status?A=t[16]:(A=(0,Q.jsx)(Kre,{status:o.status}),t[15]=o.status,t[16]=A);let j;t[17]!==o.path||t[18]!==o.previousPath?(j=o.previousPath?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:o.previousPath}),(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:` → `}),(0,Q.jsx)(`span`,{children:o.path})]}):o.path,t[17]=o.path,t[18]=o.previousPath,t[19]=j):j=t[19];let M;t[20]===j?M=t[21]:(M=(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-left`,children:j}),t[20]=j,t[21]=M);let N;t[22]===o?N=t[23]:(N=(0,Q.jsx)(qre,{file:o}),t[22]=o,t[23]=N);let P;t[24]!==A||t[25]!==M||t[26]!==N?(P=(0,Q.jsxs)(`span`,{className:`grid min-w-0 flex-1 grid-cols-[auto_minmax(0,1fr)_auto] items-baseline gap-3`,children:[A,M,N]}),t[24]=A,t[25]=M,t[26]=N,t[27]=P):P=t[27];let F,I;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Q.jsx)(Ma,{"data-slot":`accordion-trigger-icon`,className:`pointer-events-none size-4 shrink-0 group-aria-expanded/review-file-trigger:hidden`}),I=(0,Q.jsx)(Gt,{"data-slot":`accordion-trigger-icon`,className:`pointer-events-none hidden size-4 shrink-0 group-aria-expanded/review-file-trigger:inline`}),t[28]=F,t[29]=I):(F=t[28],I=t[29]);let L;t[30]!==P||t[31]!==f?(L=(0,Q.jsxs)(hb,{"data-review-file-trigger":!0,"data-review-file-value":f,className:`group/review-file-trigger relative flex min-h-10 min-w-0 flex-1 items-center justify-between gap-3 rounded-none border border-transparent bg-background px-3 py-2 text-left font-mono text-[13px] font-medium transition-all outline-none hover:no-underline focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-disabled:pointer-events-none aria-disabled:opacity-50 **:data-[slot=accordion-trigger-icon]:ml-auto **:data-[slot=accordion-trigger-icon]:size-4 **:data-[slot=accordion-trigger-icon]:text-muted-foreground`,children:[P,F,I]}),t[30]=P,t[31]=f,t[32]=L):L=t[32];let R;t[33]!==o.path||t[34]!==l?(R=l?(0,Q.jsx)(Je,{title:`Open file`,side:`top`,children:(0,Q.jsx)(ss,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Open ${o.path}`,className:`mr-2 self-center`,onClick:e=>{e.stopPropagation(),l(o.path,{pin:!0})},children:(0,Q.jsx)($a,{className:`size-3.5`})})}):null,t[33]=o.path,t[34]=l,t[35]=R):R=t[35];let z;t[36]!==k||t[37]!==L||t[38]!==R?(z=(0,Q.jsxs)(fb,{className:k,children:[L,R]}),t[36]=k,t[37]=L,t[38]=R,t[39]=z):z=t[39];let B;t[40]!==_.data||t[41]!==_.error||t[42]!==_.isPending||t[43]!==a||t[44]!==o.path||t[45]!==o.previousPath||t[46]!==w||t[47]!==C||t[48]!==T||t[49]!==g||t[50]!==S.data||t[51]!==S.error||t[52]!==S.isPending||t[53]!==m?(B=(0,Q.jsx)(Cb,{className:`bg-background p-0`,children:g?_.isPending&&!_.data?(0,Q.jsx)(`div`,{className:`p-3`,children:(0,Q.jsxs)(h7,{children:[(0,Q.jsx)(H,{}),` Loading hunk…`]})}):_.error?(0,Q.jsx)(`div`,{className:`p-3`,children:(0,Q.jsx)(h7,{tone:`destructive`,children:c_(_.error,`Failed to load hunk`)})}):T?(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-border/70 bg-background px-3 py-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:`Showing changed hunks only for this large change.`}),(0,Q.jsx)(ss,{variant:`outline`,className:`shrink-0`,onClick:()=>{m(!0)},children:`Load full context`})]}),(0,Q.jsx)(YP,{patch:T,disableWorkerPool:!0,options:{diffStyle:a,disableFileHeader:!0,overflow:`wrap`}})]}):(0,Q.jsx)(`div`,{className:`p-3`,children:(0,Q.jsx)(h7,{children:`No line changes.`})}):S.isPending&&!S.data?(0,Q.jsx)(`div`,{className:`p-3`,children:(0,Q.jsxs)(h7,{children:[(0,Q.jsx)(H,{}),` Loading hunk…`]})}):S.error?(0,Q.jsx)(`div`,{className:`p-3`,children:(0,Q.jsx)(h7,{tone:`destructive`,children:c_(S.error,`Failed to load hunk`)})}):C===w?(0,Q.jsx)(`div`,{className:`p-3`,children:(0,Q.jsx)(h7,{children:`No line changes.`})}):(0,Q.jsx)(qP,{oldFile:{name:o.previousPath||o.path,contents:C},newFile:{name:o.path,contents:w},disableWorkerPool:!0,options:{diffStyle:a,disableFileHeader:!0,overflow:`wrap`}})}),t[40]=_.data,t[41]=_.error,t[42]=_.isPending,t[43]=a,t[44]=o.path,t[45]=o.previousPath,t[46]=w,t[47]=C,t[48]=T,t[49]=g,t[50]=S.data,t[51]=S.error,t[52]=S.isPending,t[53]=m,t[54]=B):B=t[54];let V;return t[55]!==z||t[56]!==B||t[57]!==f?(V=(0,Q.jsxs)(xb,{value:f,className:`border-border/70`,children:[z,B]}),t[55]=z,t[56]=B,t[57]=f,t[58]=V):V=t[58],V}function J7(e){let t=(0,$.c)(89),{viewerContextId:n,cwd:r,active:i,activeFilePath:a,activeTab:o,filePreviewPath:s,fileTabs:c,fileTreeCollapsed:l,onActiveFileChange:u,onActiveTabChange:d,onCloseAllFiles:f,onCloseFile:p,onCloseFilesToRight:m,onCloseOtherFiles:h,onFileTreeCollapsedChange:g,onOpenFile:_,onReorderFiles:v,showToolbar:y}=e,b=a===void 0?``:a,x=s===void 0?``:s,S;t[0]===c?S=t[1]:(S=c===void 0?[]:c,t[0]=c,t[1]=S);let C=S,w=l===void 0?!1:l,T=y===void 0?!0:y,E=a_(r),D=Ao(),[O,k]=Z.useState(`review`),A=o??O,j;t[2]!==d||t[3]!==k?(j=e=>{k(e),d?.(e)},t[2]=d,t[3]=k,t[4]=j):j=t[4];let M=j,[N,P]=Z.useState(``),[F,I]=Z.useState(!1),L=D?`inline`:`external`,R=T&&!D,z=L===`inline`?N:b,B=C.length>0,V=b7({viewerContextId:n,cwd:E}),H=!!(i&&B&&n&&E),U;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(U=[`data`],t[5]=U):U=t[5];let W;t[6]!==V||t[7]!==H?(W={...V,enabled:H,select:iie,notifyOnChangeProps:U},t[6]=V,t[7]=H,t[8]=W):W=t[8];let G=Or(W),ee;t[9]===G.data?ee=t[10]:(ee=G.data??[],t[9]=G.data,t[10]=ee);let te=ee,K;t[11]!==u||t[12]!==_||t[13]!==L||t[14]!==M||t[15]!==P?(K=(e,t)=>{if(e){if(M(`files`),L===`inline`){P(e);return}_?.(e,t),u?.(e)}},t[11]=u,t[12]=_,t[13]=L,t[14]=M,t[15]=P,t[16]=K):K=t[16];let ne=K,q;t[17]!==o||t[18]!==k?(q=()=>{o||k(`review`)},t[17]=o,t[18]=k,t[19]=q):q=t[19];let J;t[20]!==o||t[21]!==D||t[22]!==E?(J=[o,D,E],t[20]=o,t[21]=D,t[22]=E,t[23]=J):J=t[23],Z.useEffect(q,J);let re;t[24]===P?re=t[25]:(re=()=>{P(``)},t[24]=P,t[25]=re);let Y;t[26]!==D||t[27]!==E?(Y=[D,E],t[26]=D,t[27]=E,t[28]=Y):Y=t[28],Z.useEffect(re,Y);let ie;t[29]!==i||t[30]!==E||t[31]!==n?(ie=(0,Q.jsx)(bre,{viewerContextId:n,cwd:E,active:i}),t[29]=i,t[30]=E,t[31]=n,t[32]=ie):ie=t[32];let ae=R?`rounded-xl border border-border/80`:`rounded-none border-0`,oe;t[33]===ae?oe=t[34]:(oe=rn(`flex h-full min-h-[520px] min-w-0 flex-col overflow-hidden bg-card/50`,ae),t[33]=ae,t[34]=oe);let se;t[35]===I?se=t[36]:(se=()=>{I(!0)},t[35]=I,t[36]=se);let ce;t[37]!==A||t[38]!==z||t[39]!==x||t[40]!==C||t[41]!==u||t[42]!==f||t[43]!==p||t[44]!==m||t[45]!==h||t[46]!==v||t[47]!==M||t[48]!==se?(ce=(0,Q.jsx)(sre,{activeFilePath:z,activeTab:A,filePreviewPath:x,fileTabs:C,onActiveFileChange:u,onActiveTabChange:M,onCloseAllFiles:f,onCloseFile:p,onCloseFilesToRight:m,onCloseOtherFiles:h,onOpenFileDialog:se,onReorderFiles:v,showReview:!0}),t[37]=A,t[38]=z,t[39]=x,t[40]=C,t[41]=u,t[42]=f,t[43]=p,t[44]=m,t[45]=h,t[46]=v,t[47]=M,t[48]=se,t[49]=ce):ce=t[49];let le=A===`review`?`visible`:`hidden`,ue=i&&A===`review`,de;t[50]!==E||t[51]!==ne||t[52]!==ue||t[53]!==n?(de=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,Q.jsx)(Qre,{viewerContextId:n,cwd:E,active:ue,onOpenFile:ne})}),t[50]=E,t[51]=ne,t[52]=ue,t[53]=n,t[54]=de):de=t[54];let fe;t[55]!==le||t[56]!==de?(fe=(0,Q.jsx)(Z.Activity,{mode:le,children:de}),t[55]=le,t[56]=de,t[57]=fe):fe=t[57];let pe=A===`files`?`visible`:`hidden`,me;t[58]!==i||t[59]!==A||t[60]!==z||t[61]!==w||t[62]!==B||t[63]!==E||t[64]!==g||t[65]!==ne||t[66]!==L||t[67]!==P||t[68]!==n?(me=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:L===`external`&&B?(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col overflow-hidden`,children:[z?(0,Q.jsx)(mre,{path:z,fileTreeCollapsed:w,onFileTreeCollapsedChange:g}):null,(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[w?null:(0,Q.jsx)(dre,{viewerContextId:n,cwd:E,active:i&&A===`files`,activeFilePath:z,onOpenFile:ne,previewMode:L}),z?(0,Q.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,Q.jsx)(T7,{viewerContextId:n,cwd:E,active:i&&A===`files`,path:z})}):null]})]}):(0,Q.jsx)(C7,{viewerContextId:n,cwd:E,active:i&&A===`files`,activeFilePath:z,onCloseFile:()=>{P(``)},onOpenFile:ne,previewMode:L})}),t[58]=i,t[59]=A,t[60]=z,t[61]=w,t[62]=B,t[63]=E,t[64]=g,t[65]=ne,t[66]=L,t[67]=P,t[68]=n,t[69]=me):me=t[69];let he;t[70]!==pe||t[71]!==me?(he=(0,Q.jsx)(Z.Activity,{mode:pe,children:me}),t[70]=pe,t[71]=me,t[72]=he):he=t[72];let ge;t[73]===ne?ge=t[74]:(ge=e=>{ne(e,{pin:!0})},t[73]=ne,t[74]=ge);let _e;t[75]!==te||t[76]!==F||t[77]!==I||t[78]!==ge?(_e=(0,Q.jsx)(w7,{open:F,onOpenChange:I,paths:te,onOpenFile:ge}),t[75]=te,t[76]=F,t[77]=I,t[78]=ge,t[79]=_e):_e=t[79];let ve;t[80]!==oe||t[81]!==ce||t[82]!==fe||t[83]!==he||t[84]!==_e?(ve=(0,Q.jsxs)(`div`,{className:oe,children:[ce,fe,he,_e]}),t[80]=oe,t[81]=ce,t[82]=fe,t[83]=he,t[84]=_e,t[85]=ve):ve=t[85];let ye;return t[86]!==ie||t[87]!==ve?(ye=(0,Q.jsxs)(`div`,{className:`h-full min-h-[520px] w-full min-w-0`,children:[ie,ve]}),t[86]=ie,t[87]=ve,t[88]=ye):ye=t[88],ye}function iie(e){return e.paths}function aie(e){return e===`files`||e===`review`?e:`review`}function oie(){return aie(A(Hn))}function Y7(e){ee(Hn,e)}function X7(e,t){Bg(e,`activeTab`,t),Y7(t)}function sie(){return{activeTab:oie(),fileActivePath:``,filePreviewPath:``,fileTabs:[],fileTreeCollapsed:!1}}function Z7(e){return e.filePreviewPath&&!e.fileTabs.includes(e.filePreviewPath)?[...e.fileTabs,e.filePreviewPath]:e.fileTabs}function cie(e){return Z7(e).length>0}function Q7(e){zg(e,e=>({...e,fileActivePath:``,filePreviewPath:``,fileTabs:[],fileTreeCollapsed:!1}))}function lie(e,t,n){t&&(Y7(`files`),zg(e,e=>{let r=!!n?.pin||e.fileTabs.includes(t)||e.fileActivePath===t,i=r?e.fileTabs.includes(t)?e.fileTabs:[...e.fileTabs,t]:e.fileTabs,a=r?e.filePreviewPath===t?``:e.filePreviewPath:t;return{...e,activeTab:`files`,fileActivePath:t,filePreviewPath:a,fileTabs:i,fileTreeCollapsed:!1}}))}function uie(e,t){zg(e,e=>{let n=Z7(e).indexOf(t),r=e.fileTabs.filter(e=>e!==t),i=e.filePreviewPath===t?``:e.filePreviewPath,a=i&&!r.includes(i)?[...r,i]:r,o=e.fileActivePath===t?a[Math.max(0,n-1)]||a[0]||``:e.fileActivePath;return{...e,fileActivePath:o,filePreviewPath:i,fileTabs:r}})}function die(e,t){zg(e,e=>{let n=e.fileTabs.includes(t)?[t]:[];return{...e,fileActivePath:t,filePreviewPath:n.length===0?t:``,fileTabs:n}})}function fie(e,t){zg(e,e=>{let n=Z7(e),r=n.indexOf(t);if(r<0)return e;let i=new Set(n.slice(0,r+1)),a=e.fileTabs.filter(e=>i.has(e)),o=i.has(e.filePreviewPath)?e.filePreviewPath:``,s=o&&!a.includes(o)?[...a,o]:a;return{...e,fileActivePath:s.includes(e.fileActivePath)?e.fileActivePath:t,filePreviewPath:o,fileTabs:a}})}function pie(e){zg(e,e=>({...e,fileActivePath:``,filePreviewPath:``,fileTabs:[]}))}function mie(e,t){let n=t.filter((e,n)=>e&&t.indexOf(e)===n);n.length!==0&&zg(e,e=>({...e,fileActivePath:n.includes(e.fileActivePath)?e.fileActivePath:n[0]||``,filePreviewPath:``,fileTabs:n}))}function hie(e){let t=(0,$.c)(4),{sessionStore:n,viewerContextId:r}=e,i=Ji(n,gie),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(Zv,{value:`session`,className:`h-8 data-active:bg-muted dark:data-active:bg-muted`,children:`Session`}),t[0]=a):a=t[0];let o;return t[1]!==i||t[2]!==r?(o=(0,Q.jsxs)(Xv,{className:`w-full gap-2 rounded-none border-b border-border/70 bg-background p-2 group-data-horizontal/tabs:h-auto md:hidden`,children:[a,(0,Q.jsx)(Zv,{value:`git`,className:`h-8 data-active:bg-muted dark:data-active:bg-muted`,children:(0,Q.jsx)(Iq,{viewerContextId:r,cwd:i})})]}),t[1]=i,t[2]=r,t[3]=o):o=t[3],o}function gie(e){return e.cwd}var _ie=Z.memo(function(e){let t=(0,$.c)(24),{active:n,onCloseAllFiles:r,onCloseFile:i,onCloseFilesToRight:a,onCloseOtherFiles:o,onOpenFile:s,onReorderFiles:c,rightSidebarStore:l,sessionStore:u,viewerContextId:d}=e,f=Ji(u,Aie),p=Ji(l,jie),m=Ji(l,Mie),h=Ji(l,Nie),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g={compare:Ag},t[0]=g):g=t[0];let _=Ji(l,Z7,g),v=Ji(l,Pie),y,b;t[1]===l?(y=t[2],b=t[3]):(y=e=>{Bg(l,`fileActivePath`,e)},b=e=>{X7(l,e)},t[1]=l,t[2]=y,t[3]=b);let x;t[4]===l?x=t[5]:(x=e=>{Bg(l,`fileTreeCollapsed`,e)},t[4]=l,t[5]=x);let S;return t[6]!==n||t[7]!==p||t[8]!==m||t[9]!==f||t[10]!==h||t[11]!==_||t[12]!==v||t[13]!==r||t[14]!==i||t[15]!==a||t[16]!==o||t[17]!==s||t[18]!==c||t[19]!==y||t[20]!==b||t[21]!==x||t[22]!==d?(S=(0,Q.jsx)(J7,{viewerContextId:d,cwd:f,active:n,activeFilePath:p,activeTab:m,filePreviewPath:h,fileTabs:_,fileTreeCollapsed:v,onActiveFileChange:y,onActiveTabChange:b,onCloseAllFiles:r,onCloseFile:i,onCloseFilesToRight:a,onCloseOtherFiles:o,onFileTreeCollapsedChange:x,onOpenFile:s,onReorderFiles:c}),t[6]=n,t[7]=p,t[8]=m,t[9]=f,t[10]=h,t[11]=_,t[12]=v,t[13]=r,t[14]=i,t[15]=a,t[16]=o,t[17]=s,t[18]=c,t[19]=y,t[20]=b,t[21]=x,t[22]=d,t[23]=S):S=t[23],S});function vie(e){let t=(0,$.c)(28),{active:n,onCloseAllFiles:r,onCloseFile:i,onCloseFilesToRight:a,onCloseOtherFiles:o,onOpenFile:s,onReorderFiles:c,rightSidebarStore:l,sessionStore:u,viewerContextId:d}=e,f=Ji(u,Cie),p=Ji(l,Sie),m=Ji(l,xie),h=Ji(l,bie),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g={compare:Ag},t[0]=g):g=t[0];let _=Ji(l,Z7,g),v=Ji(l,yie),y=!n,b=n?`open`:`closed`,x,S;t[1]===l?(x=t[2],S=t[3]):(x=e=>{Bg(l,`fileActivePath`,e)},S=e=>{X7(l,e)},t[1]=l,t[2]=x,t[3]=S);let C;t[4]===l?C=t[5]:(C=e=>{Bg(l,`fileTreeCollapsed`,e)},t[4]=l,t[5]=C);let w;t[6]!==n||t[7]!==p||t[8]!==m||t[9]!==f||t[10]!==h||t[11]!==_||t[12]!==v||t[13]!==r||t[14]!==i||t[15]!==a||t[16]!==o||t[17]!==s||t[18]!==c||t[19]!==x||t[20]!==S||t[21]!==C||t[22]!==d?(w=(0,Q.jsx)(J7,{viewerContextId:d,cwd:f,active:n,activeFilePath:p,activeTab:m,filePreviewPath:h,fileTabs:_,fileTreeCollapsed:v,onActiveFileChange:x,onActiveTabChange:S,onCloseAllFiles:r,onCloseFile:i,onCloseFilesToRight:a,onCloseOtherFiles:o,onFileTreeCollapsedChange:C,onOpenFile:s,onReorderFiles:c,showToolbar:!1}),t[6]=n,t[7]=p,t[8]=m,t[9]=f,t[10]=h,t[11]=_,t[12]=v,t[13]=r,t[14]=i,t[15]=a,t[16]=o,t[17]=s,t[18]=c,t[19]=x,t[20]=S,t[21]=C,t[22]=d,t[23]=w):w=t[23];let T;return t[24]!==y||t[25]!==b||t[26]!==w?(T=(0,Q.jsx)(`aside`,{"aria-label":`Right sidebar`,"aria-hidden":y,"data-state":b,className:`flex h-full min-h-0 w-full min-w-0 flex-col border-l border-border/70 bg-background data-[state=closed]:pointer-events-none data-[state=closed]:border-transparent`,children:w}),t[24]=y,t[25]=b,t[26]=w,t[27]=T):T=t[27],T}function yie(e){return e.fileTreeCollapsed}function bie(e){return e.filePreviewPath}function xie(e){return e.activeTab}function Sie(e){return e.fileActivePath}function Cie(e){return e.cwd}var $7=520,e9=320,t9=320,n9=260,wie=1600;function r9(){return{fileViewWidth:$7,gitPanelWidth:e9}}function i9(e,t){let n=typeof e==`number`?e:Number(e);return Number.isFinite(n)?Math.round(Math.min(wie,Math.max(n9,n))):t}function a9(e){if(!e||typeof e!=`object`)return r9();let t=e;return{fileViewWidth:i9(t.fileViewWidth,$7),gitPanelWidth:i9(t.gitPanelWidth,e9)}}function Tie(){try{let e=A(Oe);return e?a9(JSON.parse(e)):r9()}catch{return r9()}}function Eie(e){ee(Oe,JSON.stringify(a9(e)))}function o9(e,t){return e.fileViewWidth===t.fileViewWidth&&e.gitPanelWidth===t.gitPanelWidth}function s9(e,t,n){return Number.isFinite(e)?n<=t?Math.max(0,n):Math.min(n,Math.max(t,e)):t}function Die({availableWidth:e,fileOpen:t,fileWidth:n,gitOpen:r,gitWidth:i}){let a=Math.max(0,e-t9);if(!t&&!r)return{fileWidth:0,gitWidth:0,sideWidth:0};if(t&&!r){let e=s9(n,Math.min(n9,a),a);return{fileWidth:e,gitWidth:0,sideWidth:e}}if(!t&&r){let e=s9(i,Math.min(n9,a),a);return{fileWidth:0,gitWidth:e,sideWidth:e}}let o=Math.max(1,n+i);if(o<=a)return{fileWidth:n,gitWidth:i,sideWidth:n+i};let s=Math.min(n9,a/2),c=Math.round(n/o*a);c=Math.max(s,Math.min(a-s,c));let l=Math.max(0,a-c);return{fileWidth:c,gitWidth:l,sideWidth:c+l}}function Oie(e){let t=(0,$.c)(24),{label:n,max:r,min:i,onResize:a,onResizeEnd:o,onResizeStart:s,size:c}=e,l;t[0]!==r||t[1]!==i||t[2]!==a||t[3]!==o||t[4]!==s||t[5]!==c?(l={max:r,min:i,onResize:a,onResizeEnd:o,onResizeStart:s,size:c},t[0]=r,t[1]=i,t[2]=a,t[3]=o,t[4]=s,t[5]=c,t[6]=l):l=t[6];let u=Mg(l),[d,f]=Z.useState(`col-resize`),[p,m]=Z.useState(10),h,g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>{let e=()=>{m(Vo())},t=window.matchMedia(`(pointer:coarse)`);return f(zo()),e(),t.addEventListener(`change`,e),()=>{t.removeEventListener(`change`,e)}},g=[],t[7]=h,t[8]=g):(h=t[7],g=t[8]),Z.useEffect(h,g);let _=d===`ew-resize`?`cursor-ew-resize`:`cursor-col-resize`,v;t[9]===u?v=t[10]:(v=e=>{let t=u.current;t.onResize(s9(e,t.min,t.max))},t[9]=u,t[10]=v);let y=v,b=`${p}px`,x;t[11]!==d||t[12]!==b?(x={"--resize-target-width":b,cursor:d},t[11]=d,t[12]=b,t[13]=x):x=t[13];let S=x,C=`absolute inset-y-0 left-0 z-20 w-(--resize-target-width) -translate-x-1/2 touch-none bg-transparent outline-hidden after:absolute after:inset-y-0 after:left-1/2 after:w-px after:bg-transparent focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 ${Ss} ${_}`,w,T;t[14]!==u||t[15]!==y?(T=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=e.shiftKey?48:16;y(u.current.size+(e.key===`ArrowLeft`?t:-t))},w=e=>{if(e.button!==0)return;e.preventDefault();let t=u.current,n=e.clientX,r=t.size,i=zo(),a=document.body.style.cursor,o=document.body.style.userSelect,s=Ho(i);t.onResizeStart?.(),document.body.style.userSelect=`none`,document.body.style.cursor=i;let c=e=>{y(r+n-e.clientX)},l=()=>{s(),document.body.style.userSelect=o,document.body.style.cursor=a,document.removeEventListener(`pointermove`,c),document.removeEventListener(`pointerup`,l),document.removeEventListener(`pointercancel`,l),u.current.onResizeEnd?.()};document.addEventListener(`pointermove`,c),document.addEventListener(`pointerup`,l),document.addEventListener(`pointercancel`,l)},t[14]=u,t[15]=y,t[16]=w,t[17]=T):(w=t[16],T=t[17]);let E;return t[18]!==n||t[19]!==w||t[20]!==S||t[21]!==C||t[22]!==T?(E=(0,Q.jsx)(`div`,{role:`separator`,"aria-label":n,"aria-orientation":`vertical`,tabIndex:0,style:S,className:C,onKeyDown:T,onPointerDown:w}),t[18]=n,t[19]=w,t[20]=S,t[21]=C,t[22]=T,t[23]=E):E=t[23],E}function kie({actionsRef:e,appUiStore:t,awaitingFirstTurn:n,composerPanelRef:r,contextUsageStore:i,conversationFrameRef:a,conversationItemsStore:o,defaultNewSessionDirectory:s,displaySettingsStore:c,fileInputRef:l,gitPanelOpen:u,hiddenThinkingPreviewStore:d,isSessionViewLoading:f,isSubmitting:p,isMobile:m,newSessionDirectoryOptions:h,onCancelCompaction:g,onCreateSession:_,onOpenAddDirectoryDialog:v,onCloseAllFileViewTabs:y,onCloseFileViewTab:b,onCloseFileViewTabsToRight:x,onCloseOtherFileViewTabs:S,onOpenFileViewTab:C,onReorderFileViewTabs:w,onValueChange:T,rightSidebarStore:E,sessionStore:D,store:O,viewerContextId:k,workingStateStore:A}){let j=Ji(t,e=>e.currentTab),M=!Ji(D,e=>e.draft)||f,N=j===`git`?`hidden min-h-0 flex-1 flex-col md:flex`:`flex min-h-0 flex-1 flex-col`,P=j===`git`?`min-h-0 flex-1 overflow-hidden md:hidden`:`hidden`,F=Ji(E,cie),I=!m&&u,L=!m&&u&&F,R=L||I,z=Z.useRef(null),[B,V]=Z.useState(0),[H,U]=Z.useState(()=>r9()),W=Z.useRef(!1),G=Z.useRef(H);G.current=H;let ee=H.fileViewWidth,te=H.gitPanelWidth,K=e=>{let t=G.current,n=a9(Rg(t,e));o9(t,n)||(G.current=n,U(n),W.current&&Eie(n))},ne=e=>{K(t=>({...t,fileViewWidth:i9(Rg(t.fileViewWidth,e),$7)}))},q=e=>{K(t=>({...t,gitPanelWidth:i9(Rg(t.gitPanelWidth,e),e9)}))},[J,re]=Z.useState(I),[Y,ie]=Z.useState(!1);Z.useEffect(()=>{let e=Tie();W.current=!0,G.current=e,U(t=>o9(t,e)?t:e)},[]);let ae=(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,Q.jsx)(`div`,{className:N,children:(0,Q.jsx)(HJ,{actionsRef:e,awaitingFirstTurn:n,composerPanelRef:r,contextUsageStore:i,conversationFrameRef:a,conversationItemsStore:o,defaultNewSessionDirectory:s,displaySettingsStore:c,fileInputRef:l,hiddenThinkingPreviewStore:d,isSessionViewLoading:f,isSubmitting:p,newSessionDirectoryOptions:h,onCancelCompaction:g,onCreateSession:_,onOpenAddDirectoryDialog:v,sessionStore:D,store:O,viewerContextId:k,workingStateStore:A})}),m?(0,Q.jsx)(`div`,{className:P,children:(0,Q.jsx)(_ie,{viewerContextId:k,sessionStore:D,active:j===`git`,rightSidebarStore:E,onCloseAllFiles:y,onCloseFile:b,onCloseFilesToRight:x,onCloseOtherFiles:S,onOpenFile:C,onReorderFiles:w})}):null]});Z.useLayoutEffect(()=>{if(m){re(!1);return}R&&re(!0)},[R,m]),Z.useLayoutEffect(()=>{if(m)return;let e=z.current;if(!e)return;let t=()=>{V(e.clientWidth)};if(t(),typeof ResizeObserver>`u`)return window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t);let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[m]);let oe=B||(typeof window>`u`?1200:window.innerWidth),se=R||J||I,ce=Die({availableWidth:oe,fileOpen:L,fileWidth:ee,gitOpen:I,gitWidth:te}),le=R||J,ue=R?ce.sideWidth:0,de=Y?``:`transition-[width] duration-200 ease-linear`,fe=()=>{ie(!0)},pe=()=>{ie(!1)},me=Math.max(0,oe-t9);return(0,Q.jsxs)(Jv,{value:j,onValueChange:T,className:`flex min-h-0 flex-1 flex-col gap-0 overflow-hidden`,children:[M?(0,Q.jsx)(hie,{sessionStore:D,viewerContextId:k}):null,m?(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:ae}):(0,Q.jsxs)(`div`,{ref:z,className:`relative flex h-full min-h-0 w-full flex-1 overflow-hidden`,children:[(0,Q.jsx)(`div`,{"data-desktop-panel":`session`,className:`h-full min-h-0 min-w-0 shrink-0 overflow-hidden ${de}`,style:{width:R?`calc(100% - ${ue}px)`:`100%`},children:ae}),le?(0,Q.jsx)(`aside`,{"aria-label":`Desktop side workspace`,"aria-hidden":!R,"data-state":R?`open`:`closed`,"data-desktop-panel":`side-workspace`,className:`flex h-full min-h-0 min-w-0 shrink-0 overflow-visible bg-background data-[state=closed]:pointer-events-none ${de}`,style:{width:`${ue}px`},children:se?(0,Q.jsxs)(`div`,{"data-desktop-panel":`git`,className:`relative h-full min-h-0 min-w-0 shrink-0 overflow-visible ${de}`,style:{width:`${ue}px`},children:[I?(0,Q.jsx)(Oie,{label:`Resize right sidebar`,min:Math.min(n9,me),max:me,size:ue,onResize:e=>{if(!L){q(e);return}ne(Math.max(n9,e-te))},onResizeStart:fe,onResizeEnd:pe}):null,(0,Q.jsx)(`div`,{className:`h-full min-h-0 min-w-0 overflow-hidden`,children:se?(0,Q.jsx)(vie,{viewerContextId:k,sessionStore:D,active:I,rightSidebarStore:E,onCloseAllFiles:y,onCloseFile:b,onCloseFilesToRight:x,onCloseOtherFiles:S,onOpenFile:C,onReorderFiles:w}):null})]}):null}):null]})]})}function Aie(e){return e.cwd}function jie(e){return e.fileActivePath}function Mie(e){return e.activeTab}function Nie(e){return e.filePreviewPath}function Pie(e){return e.fileTreeCollapsed}var Fie=Z.memo(function(e){let t=(0,$.c)(131),{actionsRef:n,defaultNewSessionDirectory:r,displaySessionCwd:i,gitPanelOpen:a,loadingDisplaySessionTitle:o,currentSessionPinned:s,displaySettingsStore:c,isSessionViewLoading:l,newSessionDirectoryOptions:u,onToggleGitPanel:d,sessionStore:f,viewerContextId:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m={compare:Pg},t[0]=m):m=t[0];let h=Ji(f,Iie,m),g=Ji(c,Lie),{isMobile:_,openMobile:v,state:y}=Uc(),b=_?v:y===`expanded`,x=!b,S;t[1]!==l||t[2]!==o||t[3]!==h?(S=l?o:Fg(h),t[1]=l,t[2]=o,t[3]=h,t[4]=S):S=t[4];let C=S,w=b?`secondary`:`ghost`,T;t[5]===w?T=t[6]:(T=(0,Q.jsx)(Kc,{variant:w,className:`shrink-0`}),t[5]=w,t[6]=T);let E;t[7]!==n||t[8]!==r||t[9]!==x?(E=x?(0,Q.jsx)(Je,{title:r?`Create a new session in ${Og(r)}`:`Create a new session`,kbd:Uh(`Control+N`),children:(0,Q.jsx)(ss,{size:`icon`,variant:`ghost`,className:`shrink-0`,"aria-label":`Create a new session`,onClick:()=>{n.current.createSession()},children:(0,Q.jsx)(eo,{})})}):null,t[7]=n,t[8]=r,t[9]=x,t[10]=E):E=t[10];let D;t[11]!==l||t[12]!==h.sessionStreaming?(D=!l&&h.sessionStreaming?(0,Q.jsx)(H,{className:`size-3.5 shrink-0`,"aria-label":`Session streaming`}):null,t[11]=l,t[12]=h.sessionStreaming,t[13]=D):D=t[13];let O;t[14]===C?O=t[15]:(O=(0,Q.jsx)(`h2`,{className:`min-w-0 truncate text-[13px] leading-tight font-semibold`,children:C}),t[14]=C,t[15]=O);let k;t[16]!==C||t[17]!==O?(k=(0,Q.jsx)(Je,{title:C,children:O}),t[16]=C,t[17]=O,t[18]=k):k=t[18];let A;t[19]!==D||t[20]!==k?(A=(0,Q.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center justify-center gap-1.5`,children:[D,k]}),t[19]=D,t[20]=k,t[21]=A):A=t[21];let j;t[22]===i?j=t[23]:(j=i?(0,Q.jsx)(`span`,{className:`inline-flex min-w-0 items-center text-xs text-muted-foreground`,children:(0,Q.jsx)(`span`,{className:`truncate`,children:kg(i)})}):null,t[22]=i,t[23]=j);let M;t[24]!==i||t[25]!==p?(M=(0,Q.jsx)(Rq,{viewerContextId:p,cwd:i}),t[24]=i,t[25]=p,t[26]=M):M=t[26];let N;t[27]!==j||t[28]!==M?(N=(0,Q.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center justify-center gap-x-3`,children:[j,M]}),t[27]=j,t[28]=M,t[29]=N):N=t[29];let P;t[30]!==N||t[31]!==A?(P=(0,Q.jsxs)(`div`,{className:`absolute left-1/2 flex w-max max-w-[calc(100%-4rem)] -translate-x-1/2 flex-col items-center justify-center gap-0 text-center`,children:[A,N]}),t[30]=N,t[31]=A,t[32]=P):P=t[32];let F;t[33]!==i||t[34]!==p?(F=(0,Q.jsx)(zq,{viewerContextId:p,cwd:i}),t[33]=i,t[34]=p,t[35]=F):F=t[35];let I;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Q.jsx)(Je,{title:`Session menu`,children:(0,Q.jsx)(Ry,{render:(0,Q.jsx)(ss,{size:`icon`,variant:`ghost`,"aria-label":`Session menu`}),children:(0,Q.jsx)(za,{})})}),t[36]=I):I=t[36];let L;t[37]===n?L=t[38]:(L=()=>{n.current.createSession()},t[37]=n,t[38]=L);let R;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,Q.jsx)(`span`,{children:`Create new session`}),t[39]=R):R=t[39];let z;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Q.jsx)(Gy,{children:Uh(`Control+N`)}),t[40]=z):z=t[40];let B;t[41]===L?B=t[42]:(B=(0,Q.jsxs)(By,{onClick:L,children:[R,z]}),t[41]=L,t[42]=B);let V;t[43]!==n||t[44]!==r||t[45]!==u?(V=u.length>0?(0,Q.jsxs)(Vy,{children:[(0,Q.jsx)(Hy,{children:`New session in…`}),(0,Q.jsx)(Uy,{className:`w-72`,children:u.map(e=>(0,Q.jsxs)(By,{onClick:()=>{n.current.createSession(e.path)},children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.label}),(0,Q.jsx)(`span`,{className:`truncate`,children:Og(e.path)})]}),e.path===r?(0,Q.jsx)(Gy,{children:`Default`}):null]},e.path))})]}):null,t[43]=n,t[44]=r,t[45]=u,t[46]=V):V=t[46];let U;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Q.jsx)(Wy,{}),t[47]=U):U=t[47];let W=!h.sessionHasFile,G;t[48]===n?G=t[49]:(G=()=>{n.current.onToggleCurrentSessionPinned()},t[48]=n,t[49]=G);let ee=s?`Unpin from sidebar`:`Pin to sidebar`,te;t[50]===ee?te=t[51]:(te=(0,Q.jsx)(`span`,{children:ee}),t[50]=ee,t[51]=te);let K;t[52]!==W||t[53]!==G||t[54]!==te?(K=(0,Q.jsx)(By,{disabled:W,onClick:G,children:te}),t[52]=W,t[53]=G,t[54]=te,t[55]=K):K=t[55];let ne;t[56]===n?ne=t[57]:(ne=()=>{n.current.onRunCompact()},t[56]=n,t[57]=ne);let q;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,Q.jsx)(`span`,{children:`Compact session`}),t[58]=q):q=t[58];let J;t[59]===ne?J=t[60]:(J=(0,Q.jsx)(By,{onClick:ne,children:q}),t[59]=ne,t[60]=J);let re;t[61]===n?re=t[62]:(re=()=>{n.current.onTreeSession()},t[61]=n,t[62]=re);let Y,ie;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,Q.jsx)(`span`,{children:`Tree`}),ie=(0,Q.jsx)(Gy,{children:`Esc Esc`}),t[63]=Y,t[64]=ie):(Y=t[63],ie=t[64]);let ae;t[65]===re?ae=t[66]:(ae=(0,Q.jsxs)(By,{onClick:re,children:[Y,ie]}),t[65]=re,t[66]=ae);let oe;t[67]===n?oe=t[68]:(oe=()=>{n.current.onForkSession()},t[67]=n,t[68]=oe);let se;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Q.jsx)(`span`,{children:`Fork`}),t[69]=se):se=t[69];let ce;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,Q.jsx)(Gy,{children:Uh(`Control+F`)}),t[70]=ce):ce=t[70];let le;t[71]===oe?le=t[72]:(le=(0,Q.jsxs)(By,{onClick:oe,children:[se,ce]}),t[71]=oe,t[72]=le);let ue;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,Q.jsx)(Wy,{}),t[73]=ue):ue=t[73];let de;t[74]===n?de=t[75]:(de=()=>{n.current.onToggleHideThinking()},t[74]=n,t[75]=de);let fe=h.hideThinkingBlock?`Show thinking`:`Hide thinking`,pe;t[76]===fe?pe=t[77]:(pe=(0,Q.jsx)(`span`,{children:fe}),t[76]=fe,t[77]=pe);let me;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,Q.jsx)(Gy,{children:Uh(`Control+T`)}),t[78]=me):me=t[78];let he;t[79]!==de||t[80]!==pe?(he=(0,Q.jsxs)(By,{onClick:de,children:[pe,me]}),t[79]=de,t[80]=pe,t[81]=he):he=t[81];let ge;t[82]===n?ge=t[83]:(ge=()=>{n.current.onToggleHideToolBlocks()},t[82]=n,t[83]=ge);let _e=g?`Show tools`:`Hide tools`,ve;t[84]===_e?ve=t[85]:(ve=(0,Q.jsx)(`span`,{children:_e}),t[84]=_e,t[85]=ve);let ye;t[86]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,Q.jsx)(Gy,{children:Uh(`Control+O`)}),t[86]=ye):ye=t[86];let be;t[87]!==ge||t[88]!==ve?(be=(0,Q.jsxs)(By,{onClick:ge,children:[ve,ye]}),t[87]=ge,t[88]=ve,t[89]=be):be=t[89];let xe;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,Q.jsx)(Wy,{}),t[90]=xe):xe=t[90];let Se=!h.sessionHasFile,Ce;t[91]===n?Ce=t[92]:(Ce=()=>{n.current.onRenameSession()},t[91]=n,t[92]=Ce);let we;t[93]===Symbol.for(`react.memo_cache_sentinel`)?(we=(0,Q.jsx)(`span`,{children:`Rename session`}),t[93]=we):we=t[93];let Te;t[94]===Symbol.for(`react.memo_cache_sentinel`)?(Te=(0,Q.jsx)(Gy,{children:Uh(`Control+E`)}),t[94]=Te):Te=t[94];let Ee;t[95]!==Se||t[96]!==Ce?(Ee=(0,Q.jsxs)(By,{disabled:Se,onClick:Ce,children:[we,Te]}),t[95]=Se,t[96]=Ce,t[97]=Ee):Ee=t[97];let De=!h.sessionHasFile,Oe;t[98]===n?Oe=t[99]:(Oe=()=>{n.current.onDeleteCurrentSession()},t[98]=n,t[99]=Oe);let ke;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,Q.jsx)(`span`,{children:`Delete session`}),t[100]=ke):ke=t[100];let Ae;t[101]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=(0,Q.jsx)(Gy,{children:Uh(`Control+X`)}),t[101]=Ae):Ae=t[101];let je;t[102]!==De||t[103]!==Oe?(je=(0,Q.jsxs)(By,{variant:`destructive`,disabled:De,onClick:Oe,children:[ke,Ae]}),t[102]=De,t[103]=Oe,t[104]=je):je=t[104];let Me;t[105]!==B||t[106]!==V||t[107]!==K||t[108]!==J||t[109]!==ae||t[110]!==le||t[111]!==he||t[112]!==be||t[113]!==Ee||t[114]!==je?(Me=(0,Q.jsxs)(Ly,{children:[I,(0,Q.jsxs)(zy,{align:`end`,className:`w-56`,children:[B,V,U,K,J,ae,le,ue,he,be,xe,Ee,je]})]}),t[105]=B,t[106]=V,t[107]=K,t[108]=J,t[109]=ae,t[110]=le,t[111]=he,t[112]=be,t[113]=Ee,t[114]=je,t[115]=Me):Me=t[115];let Ne;t[116]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=Uh(`Control+\\`),t[116]=Ne):Ne=t[116];let Pe=a?`secondary`:`ghost`,Fe;t[117]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=(0,Q.jsx)(Xa,{}),t[117]=Fe):Fe=t[117];let Ie;t[118]!==a||t[119]!==d||t[120]!==Pe?(Ie=(0,Q.jsx)(Je,{title:`Toggle right sidebar`,kbd:Ne,children:(0,Q.jsx)(ss,{size:`icon`,variant:Pe,className:`hidden md:inline-flex`,"aria-pressed":a,"aria-label":`Toggle right sidebar`,onClick:d,children:Fe})}),t[118]=a,t[119]=d,t[120]=Pe,t[121]=Ie):Ie=t[121];let Le;t[122]!==F||t[123]!==Me||t[124]!==Ie?(Le=(0,Q.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-1`,children:[F,Me,Ie]}),t[122]=F,t[123]=Me,t[124]=Ie,t[125]=Le):Le=t[125];let Re;return t[126]!==P||t[127]!==T||t[128]!==E||t[129]!==Le?(Re=(0,Q.jsx)(`div`,{className:`sticky top-0 z-50 flex h-[var(--header-height)] w-full shrink-0 items-center border-b border-border/70 bg-background p-2`,children:(0,Q.jsxs)(`div`,{className:`relative flex w-full items-center gap-1`,children:[T,E,P,Le]})}),t[126]=P,t[127]=T,t[128]=E,t[129]=Le,t[130]=Re):Re=t[130],Re});function Iie(e){return{firstMessage:e.firstMessage,hideThinkingBlock:e.hideThinkingBlock,sessionHasFile:!!e.sessionFile,sessionName:e.sessionName,sessionStreaming:e.streaming}}function Lie(e){return e.hideToolBlocks}var Rie=250,zie=1e3,c9=1e3,l9=60*c9,u9=60*l9,d9=24*u9,Bie=7*d9,Vie=30*d9,Hie=365*d9;function Uie(e,t){let n=(0,$.c)(4),[r,i]=Z.useState(!1),a,o;return n[0]!==t||n[1]!==e?(a=()=>{if(!e){i(!1);return}let n=window.setTimeout(()=>{i(!0)},t);return()=>{window.clearTimeout(n)}},o=[t,e],n[0]=t,n[1]=e,n[2]=a,n[3]=o):(a=n[2],o=n[3]),Z.useEffect(a,o),r}function Wie(e){return e.replace(/^\/Users\/[^/]+(?=\/|$)/,`~`).replace(/^\/home\/[^/]+(?=\/|$)/,`~`)}function Gie(e){if(!e)return{leading:``,trailing:``};let t=e.replace(/[\\/]+$/,``);if(!t)return{leading:``,trailing:e};let n=e.slice(t.length),r=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return r<0||r===t.length-1?{leading:``,trailing:`${t}${n}`}:{leading:t.slice(0,r+1),trailing:`${t.slice(r+1)}${n}`}}function Kie(e){let t=(0,$.c)(10),{path:n}=e,r,i;t[0]===n?(r=t[1],i=t[2]):(r=Wie(n),i=Gie(r),t[0]=n,t[1]=r,t[2]=i);let{leading:a,trailing:o}=i,s;t[3]===a?s=t[4]:(s=a?(0,Q.jsx)(`span`,{className:`truncate text-sidebar-foreground/60`,children:a}):null,t[3]=a,t[4]=s);let c=o||r,l;t[5]===c?l=t[6]:(l=(0,Q.jsx)(`span`,{className:`shrink-0 font-medium`,children:c}),t[5]=c,t[6]=l);let u;return t[7]!==s||t[8]!==l?(u=(0,Q.jsx)(`span`,{className:`block min-w-0 text-sm text-sidebar-foreground`,children:(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[s,l]})}),t[7]=s,t[8]=l,t[9]=u):u=t[9],u}var f9=[],p9=`__pico_pinned_sessions__`,m9=`__pico_directories__`;function qie(){if(typeof window>`u`)return!1;let e=window.navigator.platform||window.navigator.userAgent;return/mac|iphone|ipad|ipod/i.test(e)}function Jie(e){return qie()?e.metaKey:e.ctrlKey}function h9(e,t=Date.now()){if(!e)return``;let n=new Date(e).getTime();if(Number.isNaN(n))return``;let r=t-n,i=r>=0,a=Math.max(1,Math.floor(Math.abs(r)/1e3)),o=i?``:`in `;if(a<60)return`${o}${a}s`;let s=Math.floor(a/60);if(s<60)return`${o}${s}m`;let c=Math.floor(s/60);if(c<24)return`${o}${c}h`;let l=Math.floor(c/24);if(l<7)return`${o}${l}d`;let u=Math.floor(l/7);if(u<5)return`${o}${u}w`;let d=Math.floor(l/30);if(d<12)return`${o}${Math.max(1,d)}mo`;let f=Math.floor(l/365);return`${o}${Math.max(1,f)}y`}function Yie(e){return e?!Number.isNaN(new Date(e).getTime()):!1}function Xie(e){let t=Math.max(1,Math.floor(e/c9));if(t<60)return c9;let n=Math.floor(t/60);if(n<60)return l9;let r=Math.floor(n/60);if(r<24)return u9;let i=Math.floor(r/24);return i<7?d9:Math.floor(i/7)<5?Bie:Math.floor(i/30)<12?Vie:Hie}function Zie(e,t=Date.now()){let n=t-e,r=Math.abs(n),i=Xie(r),a=r%i,o=n>=0?i-a:a||i;return Math.max(zie,o)}function Qie(e){let t=(0,$.c)(18),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({value:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===i?a=t[5]:(a=i?new Date(i).getTime():NaN,t[4]=i,t[5]=a);let o=a,s;t[6]===i?s=t[7]:(s=()=>h9(i),t[6]=i,t[7]=s);let[c,l]=Z.useState(s),u,d;if(t[8]!==o||t[9]!==i?(u=()=>{if(Number.isNaN(o)){l(``);return}let e,t=!1,n=()=>{if(t)return;let r=Date.now();l(h9(i,r)),e=window.setTimeout(n,Zie(o,r))};return n(),()=>{t=!0,e!==void 0&&window.clearTimeout(e)}},d=[o,i],t[8]=o,t[9]=i,t[10]=u,t[11]=d):(u=t[10],d=t[11]),Z.useEffect(u,d),!c)return null;let f;t[12]===n?f=t[13]:(f=rn(`tabular-nums`,n),t[12]=n,t[13]=f);let p;return t[14]!==c||t[15]!==r||t[16]!==f?(p=(0,Q.jsx)(`span`,{className:f,...r,children:c}),t[14]=c,t[15]=r,t[16]=f,t[17]=p):p=t[17],p}function g9(e,t){return e.length===t.length?e.every((e,n)=>e===t[n]):!1}function $ie(e,t){let n=Object.keys(e).sort();return g9(n,Object.keys(t).sort())?n.every(n=>!!e[n]==!!t[n]):!1}function eae(){let e=Lg({},$ie),t=()=>{ee(_n,JSON.stringify(e.state))};return Object.assign(e,{loadStored(){zg(e,ge())},toggle(t){e.setCollapsed(t,!e.state[t])},setCollapsed(n,r){zg(e,e=>{if(!!e[n]===r)return e;let t={...e};return r?t[n]=!0:delete t[n],t}),t()},setAll(n,r){zg(e,e=>{let t=!1,i={...e};for(let e of n)if(r){if(i[e])continue;i[e]=!0,t=!0}else{if(!i[e])continue;delete i[e],t=!0}return t?i:e}),t()},remove(n){zg(e,e=>{if(!e[n])return e;let t={...e};return delete t[n],t}),t()}}),e}function _9(e,t,n){let r=(0,$.c)(3),i;return r[0]!==t||r[1]!==n?(i=e=>n?!1:!!e[t],r[0]=t,r[1]=n,r[2]=i):i=r[2],Ji(e,i)}function tae(e,t){let n=(0,$.c)(2),r;return n[0]===t?r=n[1]:(r=e=>t.length>0&&t.every(t=>e[t]),n[0]=t,n[1]=r),Ji(e,r)}function nae(e){let t=(0,$.c)(17),{id:n,disabled:r,children:i}=e,a;t[0]!==r||t[1]!==n?(a={id:n,disabled:r},t[0]=r,t[1]=n,t[2]=a):a=t[2];let{attributes:o,listeners:s,setNodeRef:c,transform:l,transition:u,isDragging:d}=l7(a),f;t[3]===l?f=t[4]:(f=D6.Transform.toString(l),t[3]=l,t[4]=f);let p;t[5]!==f||t[6]!==u?(p={transform:f,transition:u},t[5]=f,t[6]=u,t[7]=p):p=t[7];let m=o,h=s,g;t[8]!==i||t[9]!==d||t[10]!==m||t[11]!==h?(g=i({attributes:m,listeners:h,isDragging:d}),t[8]=i,t[9]=d,t[10]=m,t[11]=h,t[12]=g):g=t[12];let _;return t[13]!==c||t[14]!==p||t[15]!==g?(_=(0,Q.jsx)(`div`,{ref:c,style:p,children:g}),t[13]=c,t[14]=p,t[15]=g,t[16]=_):_=t[16],_}function rae(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function iae(){let e=Lg(new Set,rae);return Object.assign(e,{setKeys(t){zg(e,new Set(t.filter(Boolean)))}}),e}function aae(e){let t=e?.trim()||``;return t?t.startsWith(`path:`)||t.startsWith(`id:`)?t:t.includes(`/`)||t.includes(`\\`)?xn({path:t}):t:``}function oae(){let e=Lg({sessionId:``,sessionKey:``});return Object.assign(e,{setActive(t){let n=t.sessionId||``,r=aae(t.sessionKey);zg(e,e=>e.sessionId===n&&e.sessionKey===r?e:{sessionId:n,sessionKey:r})}}),e}function sae(e,t){let n=(0,$.c)(2),r;return n[0]===t?r=n[1]:(r=e=>!!(t&&e.has(t)),n[0]=t,n[1]=r),Ji(e,r)}function cae(e,t,n){let r=(0,$.c)(3),i;return r[0]!==t||r[1]!==n?(i=e=>e.sessionKey&&t===e.sessionKey?!0:!!(e.sessionId&&n===e.sessionId),r[0]=t,r[1]=n,r[2]=i):i=r[2],Ji(e,i)}function v9(e){let t=(0,$.c)(54),{entryKey:n,directorySessionsStore:r,activeSessionStore:i,selectedSessionKeyStore:a,isPinned:o,isMobile:s,overlay:c,setOpenMobile:l,onSessionClick:u,onRenameSession:d,onDeleteSession:f,onTogglePinnedSession:p}=e,m=pae(r,n),h=sae(a,n),g=cae(i,n,m?.id);if(!m)return null;let _=m.lastMessageAt||m.modified||m.lastUserMessageAt,v;t[0]===_?v=t[1]:(v=Yie(_),t[0]=_,t[1]=v);let y=v,b;t[2]===m.lastMessagePreview?b=t[3]:(b=m.lastMessagePreview?.trim()||``,t[2]=m.lastMessagePreview,t[3]=b);let x=b,S;t[4]!==m.cwd||t[5]!==m.path||t[6]!==o?(S=o?Og(m.cwd?.trim()||m.path?.trim()||``):``,t[4]=m.cwd,t[5]=m.path,t[6]=o,t[7]=S):S=t[7];let C=S,w;t[8]!==y||t[9]!==_?(w=y&&_?new Date(_).toLocaleString():void 0,t[8]=y,t[9]=_,t[10]=w):w=t[10];let T=w,E=!!m.unread&&!m.streaming,D=!!(p||m.path&&(d||f))&&!c,O=g||h,k=(g||h)&&`bg-sidebar-accent text-sidebar-accent-foreground`,A;t[11]===k?A=t[12]:(A=rn(`relative h-auto min-w-0 items-start gap-2 py-2 pr-2 pl-8 not-data-active:hover:bg-transparent! not-data-active:hover:text-sidebar-foreground! not-data-active:data-open:hover:bg-transparent! not-data-active:data-open:hover:text-sidebar-foreground!`,k),t[11]=k,t[12]=A);let j;t[13]!==m||t[14]!==s||t[15]!==u||t[16]!==l?(j=e=>{u?.(m,{multiSelectKey:Jie(e),shiftKey:e.shiftKey}),s&&l(!1)},t[13]=m,t[14]=s,t[15]=u,t[16]=l,t[17]=j):j=t[17];let M;t[18]!==m.streaming||t[19]!==E?(M=m.streaming?(0,Q.jsx)(`span`,{className:`absolute top-2.5 left-2 flex size-4 items-center justify-center`,children:(0,Q.jsx)(H,{className:`size-3.5`,"aria-label":`Session streaming`})}):E?(0,Q.jsx)(`span`,{className:`absolute top-2.5 left-2 flex size-4 items-center justify-center`,children:(0,Q.jsx)(`span`,{className:`size-2 rounded-full bg-primary`,"aria-label":`Session done`})}):null,t[18]=m.streaming,t[19]=E,t[20]=M):M=t[20];let N;t[21]===m.title?N=t[22]:(N=(0,Q.jsx)(`span`,{className:`flex min-w-0 items-center gap-2`,children:(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate pr-16 font-medium`,children:m.title})}),t[21]=m.title,t[22]=N);let P;t[23]===x?P=t[24]:(P=x?(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-[11px] font-normal text-sidebar-foreground/50`,children:x}):null,t[23]=x,t[24]=P);let F;t[25]===C?F=t[26]:(F=C?(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-[11px] font-normal text-sidebar-foreground/50`,children:C}):null,t[25]=C,t[26]=F);let I;t[27]!==N||t[28]!==P||t[29]!==F?(I=(0,Q.jsx)(`span`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[N,P,F]})}),t[27]=N,t[28]=P,t[29]=F,t[30]=I):I=t[30];let L;t[31]!==n||t[32]!==I||t[33]!==O||t[34]!==A||t[35]!==j||t[36]!==M?(L=(0,Q.jsxs)(il,{type:`button`,"data-sidebar-session-item":!0,"data-session-key":n,isActive:O,className:A,onClick:j,children:[M,I]}),t[31]=n,t[32]=I,t[33]=O,t[34]=A,t[35]=j,t[36]=M,t[37]=L):L=t[37];let R=L,z;t[38]!==T||t[39]!==y||t[40]!==s||t[41]!==_?(z=y?(0,Q.jsx)(`span`,{className:`absolute top-2.5 right-2 z-10 flex min-w-4 items-center justify-end`,children:(0,Q.jsx)(Je,{title:s?void 0:T,side:`right`,align:`center`,children:(0,Q.jsx)(Qie,{value:_,className:`shrink-0 text-[11px] font-normal text-sidebar-foreground/50`})})}):null,t[38]=T,t[39]=y,t[40]=s,t[41]=_,t[42]=z):z=t[42];let B=z,V;t[43]!==R||t[44]!==B?(V=(0,Q.jsxs)(`div`,{className:`group/session relative`,children:[R,B]}),t[43]=R,t[44]=B,t[45]=V):V=t[45];let U=V,W;return t[46]!==m||t[47]!==D||t[48]!==o||t[49]!==f||t[50]!==d||t[51]!==p||t[52]!==U?(W=(0,Q.jsx)(nl,{children:D?(0,Q.jsxs)(d7,{children:[(0,Q.jsx)(f7,{render:U}),(0,Q.jsxs)(p7,{className:`w-44`,children:[p?(0,Q.jsx)(m7,{onClick:()=>p(m),children:o?`Unpin`:`Pin to sidebar`}):null,d&&m.path?(0,Q.jsx)(m7,{onClick:()=>d(m),children:`Rename`}):null,f&&m.path?(0,Q.jsx)(m7,{variant:`destructive`,onClick:()=>f(m),children:`Delete`}):null]})]}):U}),t[46]=m,t[47]=D,t[48]=o,t[49]=f,t[50]=d,t[51]=p,t[52]=U,t[53]=W):W=t[53],W}function y9(e,t){return e===t?!0:!e||!t?!1:e.path===t.path&&e.id===t.id&&e.cwd===t.cwd&&e.name===t.name&&e.title===t.title&&e.modified===t.modified&&e.lastUserMessageAt===t.lastUserMessageAt&&e.lastMessageAt===t.lastMessageAt&&e.lastMessagePreview===t.lastMessagePreview&&e.messageCount===t.messageCount&&JSON.stringify(e.contextUsage??null)===JSON.stringify(t.contextUsage??null)&&!!e.streaming==!!t.streaming&&!!e.unread==!!t.unread}function b9(e){let t=new Map;for(let n of Object.values(e))for(let e of n){let n=xn(e);!n||t.has(n)||t.set(n,e)}return t}function x9(e){let t={};for(let[n,r]of Object.entries(e))t[n]=r.map(e=>xn(e)).filter(Boolean);return t}function lae(e,t){return e.isLoadingSessions===t.isLoadingSessions&&g9(e.sessionKeys,t.sessionKeys)}function uae(e,t){let n=new Set([...Object.keys(e.sessionKeysByDirectory),...Object.keys(e.loadingByDirectory),...Object.keys(t.sessionKeysByDirectory),...Object.keys(t.loadingByDirectory)]);for(let r of n)if(!g9(e.sessionKeysByDirectory[r]??f9,t.sessionKeysByDirectory[r]??f9)||!!e.loadingByDirectory[r]!=!!t.loadingByDirectory[r])return!1;let r=new Set([...e.entriesByKey.keys(),...t.entriesByKey.keys()]);for(let n of r)if(!y9(e.entriesByKey.get(n),t.entriesByKey.get(n)))return!1;return!0}function dae(e,t){let n=Lg({sessionKeysByDirectory:x9(e),entriesByKey:b9(e),loadingByDirectory:t},uae);return Object.assign(n,{setData(e,t){zg(n,{sessionKeysByDirectory:x9(e),entriesByKey:b9(e),loadingByDirectory:t})}}),n}function fae(e,t){let n=(0,$.c)(3),r;n[0]===t?r=n[1]:(r=e=>({sessionKeys:e.sessionKeysByDirectory[t]??f9,isLoadingSessions:!!e.loadingByDirectory[t]}),n[0]=t,n[1]=r);let i;return n[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={compare:lae},n[2]=i):i=n[2],Ji(e,r,i)}function pae(e,t){let n=(0,$.c)(3),r;n[0]===t?r=n[1]:(r=e=>e.entriesByKey.get(t),n[0]=t,n[1]=r);let i;return n[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={compare:y9},n[2]=i):i=n[2],Ji(e,r,i)}var S9=Z.memo(function(e){let t=(0,$.c)(74),{directory:n,directorySessionsStore:r,collapsedDirectoryStore:i,searchActive:a,directoryOrderingEnabled:o,activeSessionStore:s,selectedSessionKeyStore:c,pinnedSessionKeys:l,isMobile:u,setOpenMobile:d,isDragging:f,overlay:p,attributes:m,listeners:h,onSessionClick:g,onRenameSession:_,onDeleteSession:v,onTogglePinnedSession:y,onCreateSessionInDirectory:b,onDeleteOldSessionsInDirectory:x,onRemoveDirectory:S}=e,C=p===void 0?!1:p,[w,T]=Z.useState(5),{isLoadingSessions:E,sessionKeys:D}=fae(r,n),O=_9(i,n,a),k;t[0]===l?k=t[1]:(k=new Set(l),t[0]=l,t[1]=k);let A=k,j;t[2]===A?j=t[3]:(j=e=>!A.has(e),t[2]=A,t[3]=j);let M=D.filter(j),N=a?M.length:Math.min(M.length,w),P=M.slice(0,N),F=N<M.length,I=Uie(E,Rie),L=E&&D.length===0,R=I&&M.length===0&&O,z=!C&&!!(b||x||S),B=o&&!C&&`cursor-grab active:cursor-grabbing`,V=a&&`cursor-default`,U;t[4]!==B||t[5]!==V?(U=rn(`group/directory-label flex min-w-0 flex-1 items-center gap-2 text-left text-sm text-sidebar-foreground`,B,V),t[4]=B,t[5]=V,t[6]=U):U=t[6];let W=a||C,G;t[7]===m?G=t[8]:(G=m??{},t[7]=m,t[8]=G);let ee;t[9]===h?ee=t[10]:(ee=h??{},t[9]=h,t[10]=ee);let te;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,Q.jsx)(Va,{className:`size-4 shrink-0 text-sidebar-foreground/50`}),t[11]=te):te=t[11];let K;t[12]===n?K=t[13]:(K=(0,Q.jsx)(`span`,{className:`max-w-full min-w-0`,children:(0,Q.jsx)(Kie,{path:n})}),t[12]=n,t[13]=K);let ne;t[14]!==O||t[15]!==a?(ne=a?null:O?(0,Q.jsx)(Na,{className:`size-4 shrink-0 opacity-0 transition-opacity group-hover/directory-label:opacity-100 group-focus-visible/directory-label:opacity-100`}):(0,Q.jsx)(Ma,{className:`size-4 shrink-0 opacity-0 transition-opacity group-hover/directory-label:opacity-100 group-focus-visible/directory-label:opacity-100`}),t[14]=O,t[15]=a,t[16]=ne):ne=t[16];let q;t[17]===R?q=t[18]:(q=R?(0,Q.jsx)(H,{className:`size-3.5 shrink-0`}):null,t[17]=R,t[18]=q);let J;t[19]!==K||t[20]!==ne||t[21]!==q||t[22]!==U||t[23]!==W||t[24]!==G||t[25]!==ee?(J=(0,Q.jsxs)(iW,{type:`button`,className:U,disabled:W,...G,...ee,children:[te,K,ne,q]}),t[19]=K,t[20]=ne,t[21]=q,t[22]=U,t[23]=W,t[24]=G,t[25]=ee,t[26]=J):J=t[26];let re;t[27]!==n||t[28]!==u||t[29]!==b||t[30]!==C?(re=b&&!C&&!u?(0,Q.jsx)(Je,{title:`Create a session in ${n}`,children:(0,Q.jsx)(ss,{size:`icon`,variant:`ghost`,className:`shrink-0 hover:bg-sidebar-accent/50 hover:text-sidebar-accent-foreground`,onClick:()=>b(n),children:(0,Q.jsx)(eo,{className:`size-4`})})}):null,t[27]=n,t[28]=u,t[29]=b,t[30]=C,t[31]=re):re=t[31];let Y;t[32]!==n||t[33]!==z||t[34]!==u||t[35]!==b||t[36]!==x||t[37]!==S?(Y=z&&u?(0,Q.jsxs)(Ly,{children:[(0,Q.jsx)(Ry,{render:(0,Q.jsx)(ss,{size:`icon`,variant:`ghost`,className:`shrink-0 hover:bg-sidebar-accent/50 hover:text-sidebar-accent-foreground`,"aria-label":`Directory actions for ${n}`}),children:(0,Q.jsx)(Ra,{className:`size-4`})}),(0,Q.jsxs)(zy,{align:`end`,className:`w-48`,children:[b?(0,Q.jsx)(By,{onClick:()=>b(n),children:`New session`}):null,x?(0,Q.jsx)(By,{onClick:()=>x(n),children:`Delete old sessions…`}):null,S?(0,Q.jsx)(By,{variant:`destructive`,onClick:()=>S(n),children:`Remove from sidebar`}):null]})]}):null,t[32]=n,t[33]=z,t[34]=u,t[35]=b,t[36]=x,t[37]=S,t[38]=Y):Y=t[38];let ie;t[39]!==J||t[40]!==re||t[41]!==Y?(ie=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg px-2`,children:[J,re,Y]}),t[39]=J,t[40]=re,t[41]=Y,t[42]=ie):ie=t[42];let ae=ie,oe=rW,se=!O,ce;t[43]!==i||t[44]!==n||t[45]!==C||t[46]!==a?(ce=e=>{a||C||i.setCollapsed(n,!e)},t[43]=i,t[44]=n,t[45]=C,t[46]=a,t[47]=ce):ce=t[47];let le=f&&!C&&`opacity-0`,ue;t[48]===le?ue=t[49]:(ue=rn(`rounded-lg py-1`,le),t[48]=le,t[49]=ue);let de=Qc,fe;t[50]!==n||t[51]!==ae||t[52]!==z||t[53]!==u||t[54]!==b||t[55]!==x||t[56]!==S?(fe=z&&!u?(0,Q.jsxs)(d7,{children:[(0,Q.jsx)(f7,{render:ae}),(0,Q.jsxs)(p7,{className:`w-48`,children:[b?(0,Q.jsx)(m7,{onClick:()=>b(n),children:`New session`}):null,x?(0,Q.jsx)(m7,{onClick:()=>x(n),children:`Delete old sessions…`}):null,S?(0,Q.jsx)(m7,{variant:`destructive`,onClick:()=>S(n),children:`Remove from sidebar`}):null]})]}):ae,t[50]=n,t[51]=ae,t[52]=z,t[53]=u,t[54]=b,t[55]=x,t[56]=S,t[57]=fe):fe=t[57];let pe=aW,me=el,he=L?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-2 text-sm text-sidebar-foreground/70`,children:[I?(0,Q.jsx)(H,{}):(0,Q.jsx)(`span`,{className:`size-4`,"aria-hidden":`true`}),`Loading sessions…`]}):M.length>0?(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(tl,{children:P.map(e=>(0,Q.jsx)(v9,{entryKey:e,directorySessionsStore:r,activeSessionStore:s,selectedSessionKeyStore:c,isPinned:l.includes(e),isMobile:u,overlay:C,setOpenMobile:d,onSessionClick:g,onRenameSession:_,onDeleteSession:v,onTogglePinnedSession:y},e))}),F&&!C?(0,Q.jsxs)(ss,{variant:`ghost`,className:`h-8 justify-start pl-8 text-sidebar-foreground/60 hover:bg-sidebar-accent/50 hover:text-sidebar-accent-foreground`,onClick:()=>{T(e=>Math.min(M.length,e+5))},children:[`Show`,` `,Math.min(5,M.length-N),` `,`more`]}):null]}):(0,Q.jsx)(`div`,{className:`px-2 py-2 text-sm text-sidebar-foreground/70`,children:a?`No matching unpinned sessions.`:`No unpinned sessions.`}),ge;t[58]!==me||t[59]!==he?(ge=(0,Q.jsx)(me,{children:he}),t[58]=me,t[59]=he,t[60]=ge):ge=t[60];let _e;t[61]!==pe||t[62]!==ge?(_e=(0,Q.jsx)(pe,{children:ge}),t[61]=pe,t[62]=ge,t[63]=_e):_e=t[63];let ve;t[64]!==de||t[65]!==fe||t[66]!==_e?(ve=(0,Q.jsxs)(de,{className:`py-0`,children:[fe,_e]}),t[64]=de,t[65]=fe,t[66]=_e,t[67]=ve):ve=t[67];let ye;return t[68]!==oe||t[69]!==se||t[70]!==ce||t[71]!==ue||t[72]!==ve?(ye=(0,Q.jsx)(oe,{open:se,onOpenChange:ce,className:ue,children:ve}),t[68]=oe,t[69]=se,t[70]=ce,t[71]=ue,t[72]=ve,t[73]=ye):ye=t[73],ye});function mae(e){let t=(0,$.c)(45),{pinnedSessionKeys:n,directorySessionsStore:r,collapsedDirectoryStore:i,searchActive:a,activeSessionStore:o,selectedSessionKeyStore:s,isMobile:c,setOpenMobile:l,onSessionClick:u,onRenameSession:d,onDeleteSession:f,onTogglePinnedSession:p}=e,m=_9(i,p9,a);if(n.length===0)return null;let h=!m,g;t[0]!==i||t[1]!==a?(g=e=>{a||i.setCollapsed(p9,!e)},t[0]=i,t[1]=a,t[2]=g):g=t[2];let _;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(iW,{className:`group/pinned-label justify-between gap-3`}),t[3]=_):_=t[3];let v;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:`Pinned`}),t[4]=v):v=t[4];let y;t[5]!==m||t[6]!==a?(y=a?null:m?(0,Q.jsx)(Na,{className:`size-4 shrink-0 opacity-0 transition-opacity group-hover/pinned-label:opacity-100 group-focus-visible/pinned-label:opacity-100`}):(0,Q.jsx)(Ma,{className:`size-4 shrink-0 opacity-0 transition-opacity group-hover/pinned-label:opacity-100 group-focus-visible/pinned-label:opacity-100`}),t[5]=m,t[6]=a,t[7]=y):y=t[7];let b;t[8]===y?b=t[9]:(b=(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[v,y]}),t[8]=y,t[9]=b);let x;t[10]===n.length?x=t[11]:(x=(0,Q.jsx)(`span`,{className:`text-[11px] font-normal text-sidebar-foreground/50`,children:n.length}),t[10]=n.length,t[11]=x);let S;t[12]!==b||t[13]!==x?(S=(0,Q.jsxs)($c,{render:_,children:[b,x]}),t[12]=b,t[13]=x,t[14]=S):S=t[14];let C;if(t[15]!==o||t[16]!==r||t[17]!==c||t[18]!==f||t[19]!==d||t[20]!==u||t[21]!==p||t[22]!==n||t[23]!==s||t[24]!==l){let e;t[26]!==o||t[27]!==r||t[28]!==c||t[29]!==f||t[30]!==d||t[31]!==u||t[32]!==p||t[33]!==s||t[34]!==l?(e=e=>(0,Q.jsx)(v9,{entryKey:e,directorySessionsStore:r,activeSessionStore:o,selectedSessionKeyStore:s,isPinned:!0,isMobile:c,overlay:!1,setOpenMobile:l,onSessionClick:u,onRenameSession:d,onDeleteSession:f,onTogglePinnedSession:p},e),t[26]=o,t[27]=r,t[28]=c,t[29]=f,t[30]=d,t[31]=u,t[32]=p,t[33]=s,t[34]=l,t[35]=e):e=t[35],C=n.map(e),t[15]=o,t[16]=r,t[17]=c,t[18]=f,t[19]=d,t[20]=u,t[21]=p,t[22]=n,t[23]=s,t[24]=l,t[25]=C}else C=t[25];let w;t[36]===C?w=t[37]:(w=(0,Q.jsx)(aW,{children:(0,Q.jsx)(el,{children:(0,Q.jsx)(tl,{children:C})})}),t[36]=C,t[37]=w);let T;t[38]!==w||t[39]!==S?(T=(0,Q.jsxs)(Qc,{className:`py-1`,children:[S,w]}),t[38]=w,t[39]=S,t[40]=T):T=t[40];let E;return t[41]!==h||t[42]!==T||t[43]!==g?(E=(0,Q.jsx)(rW,{open:h,onOpenChange:g,children:T}),t[41]=h,t[42]=T,t[43]=g,t[44]=E):E=t[44],E}function hae(e){let t=(0,$.c)(14),{searchActive:n,visibleDirectories:r,collapsedDirectoryStore:i}=e,a=tae(i,r),o=a?`Expand all directories`:`Collapse all directories`,s=n||r.length===0,c;t[0]!==a||t[1]!==i||t[2]!==r?(c=()=>{i.setAll(r,!a)},t[0]=a,t[1]=i,t[2]=r,t[3]=c):c=t[3];let l;t[4]===a?l=t[5]:(l=a?(0,Q.jsx)(Fa,{}):(0,Q.jsx)(Pa,{}),t[4]=a,t[5]=l);let u;t[6]!==s||t[7]!==c||t[8]!==l||t[9]!==o?(u=(0,Q.jsx)(ss,{size:`icon`,variant:`ghost`,className:`text-sidebar-foreground/70 hover:bg-sidebar-accent/50 hover:text-sidebar-accent-foreground`,disabled:s,onClick:c,"aria-label":o,children:l}),t[6]=s,t[7]=c,t[8]=l,t[9]=o,t[10]=u):u=t[10];let d;return t[11]!==u||t[12]!==o?(d=(0,Q.jsx)(Je,{title:o,children:u}),t[11]=u,t[12]=o,t[13]=d):d=t[13],d}function gae(e){let t=(0,$.c)(13),{onOpenSessionsDialog:n,onCreateSession:r}=e,i,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(Za,{}),a=(0,Q.jsx)(`span`,{children:`Search sessions...`}),t[0]=i,t[1]=a):(i=t[0],a=t[1]);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(`span`,{className:`ml-auto hidden items-center md:flex`,children:(0,Q.jsx)(Ot,{children:Uh(`Control+S`)})}),t[2]=o):o=t[2];let s;t[3]===n?s=t[4]:(s=(0,Q.jsx)(nl,{children:(0,Q.jsxs)(il,{type:`button`,onClick:n,children:[i,a,o]})}),t[3]=n,t[4]=s);let c,l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(eo,{}),l=(0,Q.jsx)(`span`,{children:`New session`}),t[5]=c,t[6]=l):(c=t[5],l=t[6]);let u;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(`span`,{className:`ml-auto hidden items-center md:flex`,children:(0,Q.jsx)(Ot,{children:Uh(`Control+N`)})}),t[7]=u):u=t[7];let d;t[8]===r?d=t[9]:(d=(0,Q.jsx)(nl,{children:(0,Q.jsxs)(il,{type:`button`,onClick:r,children:[c,l,u]})}),t[8]=r,t[9]=d);let f;return t[10]!==s||t[11]!==d?(f=(0,Q.jsx)(Yc,{className:`gap-2 border-b border-sidebar-border/70`,children:(0,Q.jsxs)(tl,{children:[s,d]})}),t[10]=s,t[11]=d,t[12]=f):f=t[12],f}function _ae(e){let t=(0,$.c)(25),{sessionSearch:n,visibleDirectories:r,matchingSessionCount:i,collapsed:a,collapsedDirectoryStore:o,onOpenAddDirectoryDialog:s}=e,c;t[0]===n?c=t[1]:(c=n.trim(),t[0]=n,t[1]=c);let l=c.length>0,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(iW,{className:`group/directories-label justify-between gap-3`}),t[2]=u):u=t[2];let d=l?`${i} matching session${i===1?``:`s`}`:`Directories`,f;t[3]===d?f=t[4]:(f=(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:d}),t[3]=d,t[4]=f);let p;t[5]!==a||t[6]!==l?(p=l?null:a?(0,Q.jsx)(Na,{className:`size-4 shrink-0 opacity-0 transition-opacity group-hover/directories-label:opacity-100 group-focus-visible/directories-label:opacity-100`}):(0,Q.jsx)(Ma,{className:`size-4 shrink-0 opacity-0 transition-opacity group-hover/directories-label:opacity-100 group-focus-visible/directories-label:opacity-100`}),t[5]=a,t[6]=l,t[7]=p):p=t[7];let m;t[8]!==f||t[9]!==p?(m=(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[f,p]}),t[8]=f,t[9]=p,t[10]=m):m=t[10];let h;t[11]!==o||t[12]!==l||t[13]!==r?(h=(0,Q.jsx)(hae,{searchActive:l,visibleDirectories:r,collapsedDirectoryStore:o}),t[11]=o,t[12]=l,t[13]=r,t[14]=h):h=t[14];let g;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(g=Uh(`Control+D`),t[15]=g):g=t[15];let _;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(Ba,{}),t[16]=_):_=t[16];let v;t[17]===s?v=t[18]:(v=(0,Q.jsx)(Je,{title:`Add directory`,kbd:g,children:(0,Q.jsx)(ss,{variant:`ghost`,size:`icon`,className:`hover:bg-sidebar-accent/50 hover:text-sidebar-accent-foreground`,onClick:s,"aria-label":`Add directory`,children:_})}),t[17]=s,t[18]=v);let y;t[19]!==v||t[20]!==h?(y=(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[h,v]}),t[19]=v,t[20]=h,t[21]=y):y=t[21];let b;return t[22]!==y||t[23]!==m?(b=(0,Q.jsxs)($c,{render:u,children:[m,y]}),t[22]=y,t[23]=m,t[24]=b):b=t[24],b}function vae(e){let t=(0,$.c)(125),{sessionSearch:n,onOpenSessionsDialog:r,visibleDirectories:i,directorySessionsStore:a,matchingSessionCount:o,selectedSessionKeys:s,activeSessionId:c,activeSessionKey:l,pinnedSessionKeys:u,emptyStateText:d,onCreateSession:f,onOpenAddDirectoryDialog:p,onOpenCommandPalette:m,onOpenSettings:h,onSessionClick:g,onRenameSession:_,onDeleteSession:v,onTogglePinnedSession:y,onCreateSessionInDirectory:b,onDeleteOldSessionsInDirectory:x,onRemoveDirectory:S,onReorderDirectories:C}=e,{isMobile:w,setOpenMobile:T}=Uc(),E;t[0]===n?E=t[1]:(E=n.trim(),t[0]=n,t[1]=E);let D=E.length>0,O=!D&&i.length>1,[k,A]=Z.useState(null),[j,M]=Z.useState(null),[N]=Z.useState(eae),[P]=Z.useState(iae),[F]=Z.useState(oae),I=_9(N,m9,D),L,R;t[2]!==P||t[3]!==s?(L=()=>{P.setKeys(s)},R=[P,s],t[2]=P,t[3]=s,t[4]=L,t[5]=R):(L=t[4],R=t[5]),Z.useLayoutEffect(L,R);let z,B;t[6]!==c||t[7]!==l||t[8]!==F?(z=()=>{F.setActive({sessionId:c,sessionKey:l})},B=[c,l,F],t[6]=c,t[7]=l,t[8]=F,t[9]=z,t[10]=B):(z=t[9],B=t[10]),Z.useLayoutEffect(z,B);let V;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(V={activationConstraint:{distance:6}},t[11]=V):V=t[11];let H=U6(H6(W8,V)),U,W;t[12]===N?(U=t[13],W=t[14]):(U=()=>{N.loadStored()},W=[N],t[12]=N,t[13]=U,t[14]=W),Z.useEffect(U,W);let G,ee;t[15]===O?(G=t[16],ee=t[17]):(ee=()=>{O||(A(null),M(null))},G=[O],t[15]=O,t[16]=G,t[17]=ee),Z.useEffect(ee,G);let te;bb0:{if(!j||j.length===0){te=i;break bb0}let e;t[18]===i?e=t[19]:(e=new Set(i),t[18]=i,t[19]=e);let n=e,r;if(t[20]!==j||t[21]!==i||t[22]!==n){let e;t[24]===n?e=t[25]:(e=e=>n.has(e),t[24]=n,t[25]=e);let a=j.filter(e),o=i.filter(e=>!a.includes(e));r=[...a,...o],t[20]=j,t[21]=i,t[22]=n,t[23]=r}else r=t[23];te=r}let K=te,ne,q;t[26]!==K||t[27]!==j||t[28]!==i?(ne=()=>{j&&g9(K,i)&&M(null)},q=[K,j,i],t[26]=K,t[27]=j,t[28]=i,t[29]=ne,t[30]=q):(ne=t[29],q=t[30]),Z.useEffect(ne,q);let J;t[31]!==N||t[32]!==S?(J=e=>{N.remove(e),S?.(e)},t[31]=N,t[32]=S,t[33]=J):J=t[33];let re=J,Y;t[34]===i?Y=t[35]:(Y=(e,t)=>{M(n=>{let r=n&&n.length>0?n:i,a=r.indexOf(e),o=r.indexOf(t);return a===-1||o===-1||a===o?n:e7(r,a,o)})},t[34]=i,t[35]=Y);let ie=Y,ae;t[36]===i?ae=t[37]:(ae=e=>{A(String(e.active.id)),M(i)},t[36]=i,t[37]=ae);let oe=ae,se;t[38]===ie?se=t[39]:(se=e=>{let t=String(e.active.id),n=e.over?String(e.over.id):``;!t||!n||t===n||ie(t,n)},t[38]=ie,t[39]=se);let ce=se,le;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(le=()=>{A(null),M(null)},t[40]=le):le=t[40];let ue=le,de;t[41]!==C||t[42]!==j||t[43]!==i?(de=e=>{let t=String(e.active.id),n=e.over?String(e.over.id):``,r=j;if((!r||r.length===0)&&t&&n&&t!==n){let e=i.indexOf(t),a=i.indexOf(n);e!==-1&&a!==-1&&(r=e7(i,e,a))}r&&r.length>0&&!g9(r,i)&&C?.(r),A(null),M(null)},t[41]=C,t[42]=j,t[43]=i,t[44]=de):de=t[44];let fe=de,pe;t[45]!==f||t[46]!==r?(pe=(0,Q.jsx)(gae,{onOpenSessionsDialog:r,onCreateSession:f}),t[45]=f,t[46]=r,t[47]=pe):pe=t[47];let me;t[48]!==F||t[49]!==N||t[50]!==a||t[51]!==w||t[52]!==v||t[53]!==_||t[54]!==g||t[55]!==y||t[56]!==u||t[57]!==D||t[58]!==P||t[59]!==T?(me=(0,Q.jsx)(mae,{pinnedSessionKeys:u,directorySessionsStore:a,collapsedDirectoryStore:N,searchActive:D,activeSessionStore:F,selectedSessionKeyStore:P,isMobile:w,setOpenMobile:T,onSessionClick:g,onRenameSession:_,onDeleteSession:v,onTogglePinnedSession:y}),t[48]=F,t[49]=N,t[50]=a,t[51]=w,t[52]=v,t[53]=_,t[54]=g,t[55]=y,t[56]=u,t[57]=D,t[58]=P,t[59]=T,t[60]=me):me=t[60];let he=!I,ge;t[61]!==N||t[62]!==D?(ge=e=>{D||N.setCollapsed(m9,!e)},t[61]=N,t[62]=D,t[63]=ge):ge=t[63];let _e;t[64]!==N||t[65]!==I||t[66]!==o||t[67]!==p||t[68]!==n||t[69]!==i?(_e=(0,Q.jsx)(_ae,{sessionSearch:n,visibleDirectories:i,matchingSessionCount:o,collapsed:I,collapsedDirectoryStore:N,onOpenAddDirectoryDialog:p}),t[64]=N,t[65]=I,t[66]=o,t[67]=p,t[68]=n,t[69]=i,t[70]=_e):_e=t[70];let ve;t[71]!==k||t[72]!==F||t[73]!==N||t[74]!==O||t[75]!==a||t[76]!==d||t[77]!==fe||t[78]!==ce||t[79]!==oe||t[80]!==w||t[81]!==b||t[82]!==x||t[83]!==v||t[84]!==S||t[85]!==_||t[86]!==g||t[87]!==y||t[88]!==K||t[89]!==u||t[90]!==re||t[91]!==D||t[92]!==P||t[93]!==H||t[94]!==T||t[95]!==i.length?(ve=(0,Q.jsx)(aW,{children:(0,Q.jsx)(el,{children:i.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-2`,children:(0,Q.jsx)(Dq,{className:`rounded-xl border border-dashed bg-sidebar-accent/10 py-10`,children:(0,Q.jsxs)(Oq,{children:[(0,Q.jsx)(Aq,{variant:`icon`,children:(0,Q.jsx)(Va,{})}),(0,Q.jsx)(jq,{children:d})]})})}):(0,Q.jsxs)(V5,{sensors:H,collisionDetection:Z6,onDragStart:O?oe:void 0,onDragOver:O?ce:void 0,onDragEnd:O?fe:void 0,onDragCancel:O?ue:void 0,children:[(0,Q.jsx)(s7,{items:K,strategy:Tne,children:K.map(e=>(0,Q.jsx)(nae,{id:e,disabled:!O,children:t=>{let{attributes:n,listeners:r,isDragging:i}=t;return(0,Q.jsx)(S9,{directory:e,directorySessionsStore:a,collapsedDirectoryStore:N,searchActive:D,directoryOrderingEnabled:O,activeSessionStore:F,selectedSessionKeyStore:P,pinnedSessionKeys:u,isMobile:w,setOpenMobile:T,isDragging:i,attributes:n,listeners:r,onSessionClick:g,onRenameSession:_,onDeleteSession:v,onTogglePinnedSession:y,onCreateSessionInDirectory:b,onDeleteOldSessionsInDirectory:x,onRemoveDirectory:S?re:void 0})}},e))}),(0,Q.jsx)($5,{children:k?(0,Q.jsx)(S9,{directory:k,directorySessionsStore:a,collapsedDirectoryStore:N,searchActive:D,directoryOrderingEnabled:O,activeSessionStore:F,selectedSessionKeyStore:P,pinnedSessionKeys:u,isMobile:w,setOpenMobile:T,overlay:!0,onSessionClick:g,onRenameSession:_,onDeleteSession:v,onTogglePinnedSession:y,onCreateSessionInDirectory:b,onDeleteOldSessionsInDirectory:x,onRemoveDirectory:S?re:void 0}):null})]})})}),t[71]=k,t[72]=F,t[73]=N,t[74]=O,t[75]=a,t[76]=d,t[77]=fe,t[78]=ce,t[79]=oe,t[80]=w,t[81]=b,t[82]=x,t[83]=v,t[84]=S,t[85]=_,t[86]=g,t[87]=y,t[88]=K,t[89]=u,t[90]=re,t[91]=D,t[92]=P,t[93]=H,t[94]=T,t[95]=i.length,t[96]=ve):ve=t[96];let ye;t[97]!==_e||t[98]!==ve?(ye=(0,Q.jsxs)(Qc,{className:`py-1`,children:[_e,ve]}),t[97]=_e,t[98]=ve,t[99]=ye):ye=t[99];let be;t[100]!==he||t[101]!==ge||t[102]!==ye?(be=(0,Q.jsx)(rW,{open:he,onOpenChange:ge,children:ye}),t[100]=he,t[101]=ge,t[102]=ye,t[103]=be):be=t[103];let xe;t[104]!==me||t[105]!==be?(xe=(0,Q.jsxs)(Zc,{children:[me,be]}),t[104]=me,t[105]=be,t[106]=xe):xe=t[106];let Se,Ce;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,Q.jsx)(kn,{}),Ce=(0,Q.jsx)(`span`,{children:`Commands`}),t[107]=Se,t[108]=Ce):(Se=t[107],Ce=t[108]);let we;t[109]===Symbol.for(`react.memo_cache_sentinel`)?(we=(0,Q.jsx)(`span`,{className:`ml-auto hidden items-center md:flex`,children:(0,Q.jsx)(Ot,{children:Uh(`Control+K`)})}),t[109]=we):we=t[109];let Te;t[110]===m?Te=t[111]:(Te=(0,Q.jsx)(nl,{children:(0,Q.jsxs)(il,{type:`button`,onClick:m,children:[Se,Ce,we]})}),t[110]=m,t[111]=Te);let Ee,De;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=(0,Q.jsx)(Qa,{}),De=(0,Q.jsx)(`span`,{children:`Settings`}),t[112]=Ee,t[113]=De):(Ee=t[112],De=t[113]);let Oe;t[114]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,Q.jsx)(`span`,{className:`ml-auto hidden items-center md:flex`,children:(0,Q.jsx)(Ot,{children:Uh(`Control+,`)})}),t[114]=Oe):Oe=t[114];let ke;t[115]===h?ke=t[116]:(ke=(0,Q.jsx)(nl,{children:(0,Q.jsxs)(il,{type:`button`,onClick:h,children:[Ee,De,Oe]})}),t[115]=h,t[116]=ke);let Ae;t[117]!==Te||t[118]!==ke?(Ae=(0,Q.jsx)(Xc,{className:`gap-2 border-t border-sidebar-border/70`,children:(0,Q.jsxs)(tl,{children:[Te,ke]})}),t[117]=Te,t[118]=ke,t[119]=Ae):Ae=t[119];let je;t[120]===Symbol.for(`react.memo_cache_sentinel`)?(je=(0,Q.jsx)(qc,{}),t[120]=je):je=t[120];let Me;return t[121]!==pe||t[122]!==xe||t[123]!==Ae?(Me=(0,Q.jsxs)(Gc,{collapsible:`offcanvas`,className:`top-[var(--header-height)] !h-[calc(100svh_-_var(--header-height))] border-r border-sidebar-border/70`,children:[pe,xe,Ae,je]}),t[121]=pe,t[122]=xe,t[123]=Ae,t[124]=Me):Me=t[124],Me}var yae=`__pico_pinned_sessions__`;function bae(e,t){let n=t.sessionPath?.trim()||``,r=t.sessionId?.trim()||``;if(n){let t=xn({path:n});if(e.has(t))return t}if(r){let t=xn({id:r});if(e.has(t))return t}for(let[t,i]of e)if(n&&i.path===n||r&&i.id===r)return t;return``}function xae(e){let t=(0,$.c)(116),{viewerContextId:n,sidebarStore:r,sessionWorkspaceRef:i}=e,[a]=Z.useState(Vae),o=i_(r,Bae,Ag),s=i_(r,zae,jg),c=i_(r,Rae),l=i_(r,Lae,Kg),u=i_(r,Iae),d;t[0]===u?d=t[1]:(d=u.map(Fae).filter(Boolean),t[0]=u,t[1]=d);let f=d,p=i_(r,Pae,jg),m=i_(r,Nae,Ag),h=i_(r,Mae),g=i_(r,jae),_=i_(r,Aae,Ag),v=i_(r,kae,Oae),y=i_(r,Dae),b=v.activeSessionId,x=v.activeSessionKey,S=v.activeSessionPath,C=v.activeStreaming,w;if(t[2]!==l||t[3]!==m){let e;t[5]===l?e=t[6]:(e=(e,t)=>e+(l[t]?.length??0),t[5]=l,t[6]=e),w=m.reduce(e,0),t[2]=l,t[3]=m,t[4]=w}else w=t[4];let T=w,E=i_(r,Eae),D=i_(r,Tae),O=i_(r,wae),k;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(k={signature:``,key:``},t[7]=k):k=t[7];let A=Z.useRef(k),j=Z.useRef(0),M;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(M={},t[8]=M):M=t[8];let N=Z.useRef(M),P=Z.useRef(null),F;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(F=e=>{let t=j.current+1;j.current=t;for(let n of e)N.current[n]=t;return t},t[9]=F):F=t[9];let I=F,L;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(L=(e,t)=>e.filter(e=>N.current[e]===t),t[10]=L):L=t[10];let R=L,z;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(z=(e,t)=>{for(let n of e)N.current[n]===t&&delete N.current[n]},t[11]=z):z=t[11];let B=z,V,H;t[12]!==g||t[13]!==a||t[14]!==l||t[15]!==u?(V=()=>{a.setData(u.length>0?{...l,[yae]:u}:l,g)},H=[g,a,l,u],t[12]=g,t[13]=a,t[14]=l,t[15]=u,t[16]=V,t[17]=H):(V=t[16],H=t[17]),Z.useLayoutEffect(V,H);let U,W;t[18]===r?(U=t[19],W=t[20]):(U=()=>{let e=0,t=window.requestAnimationFrame(()=>{e=window.setTimeout(()=>{r.setSidebarDeferredDirectoryLoadingReady(!0)},0)});return()=>{window.cancelAnimationFrame(t),e&&window.clearTimeout(e)}},W=[r],t[18]=r,t[19]=U,t[20]=W),Z.useEffect(U,W);let G,te;t[21]!==o||t[22]!==r?(G=()=>{let e=new Set(o);r.setDirectoryIndexDataByPath(t=>{let n={};for(let[r,i]of Object.entries(t))e.has(r)&&(n[r]=i);return JSON.stringify(n)===JSON.stringify(t)?t:n}),r.setDirectoryIndexLoading(t=>{let n={};for(let[r,i]of Object.entries(t))e.has(r)&&(n[r]=i);return JSON.stringify(n)===JSON.stringify(t)?t:n});let t={};for(let[n,r]of Object.entries(N.current))e.has(n)&&(t[n]=r);N.current=t},te=[o,r],t[21]=o,t[22]=r,t[23]=G,t[24]=te):(G=t[23],te=t[24]),Z.useEffect(G,te);let K,ne;t[25]!==b||t[26]!==x||t[27]!==S||t[28]!==C||t[29]!==o||t[30]!==h||t[31]!==g||t[32]!==s||t[33]!==y||t[34]!==r||t[35]!==n?(K=()=>{if(!n||!y)return;let e=y.directoryIndexes||{},t=Object.keys(e);r.setSidebarState(n=>{let r=Jg(t.length?Ug(n.directoryIndexDataByPath,e):n.directoryIndexDataByPath,{sessionId:b,sessionPath:S}),i=t.length?Gg(n.directoryIndexLoading,t,!1):n.directoryIndexLoading,a=!Wg(n.directoryIndexDataByPath,r);return!a&&i===n.directoryIndexLoading?n:{directoryIndexDataByPath:a?r:n.directoryIndexDataByPath,directoryIndexLoading:i}});let i=P.current,a={},c=[];for(let e of o){let n=s.get(e)?.revision||``,r=i?.revisions[e]||``;a[e]=n,!t.includes(e)&&Object.prototype.hasOwnProperty.call(h,e)&&(g[e]||N.current[e]||r!==n&&(C||c.push(e)))}if(P.current={activeSessionId:b,activeSessionKey:x,activeSessionPath:S,revisions:a},c.length===0)return;let l=I(c);Hg({viewerContextId:n,directories:c}).then(e=>{let t=R(c,l);if(t.length===0)return;B(t,l);let n=Object.fromEntries(t.map(t=>[t,e.directoryIndexes[t]]).filter(Cae));r.setSidebarState(e=>{let r=Object.keys(n).length>0?Ug(e.directoryIndexDataByPath,n):e.directoryIndexDataByPath,i=Gg(e.directoryIndexLoading,t,!1);return r===e.directoryIndexDataByPath&&i===e.directoryIndexLoading?e:{directoryIndexDataByPath:r,directoryIndexLoading:i}})}).catch(e=>{let t=R(c,l);t.length!==0&&(B(t,l),r.setDirectoryIndexLoading(e=>Gg(e,t,!1)),Qe.error(e instanceof Error?e.message:`Failed to load sidebar sessions`))})},ne=[o,h,g,b,x,S,C,s,y,r,n],t[25]=b,t[26]=x,t[27]=S,t[28]=C,t[29]=o,t[30]=h,t[31]=g,t[32]=s,t[33]=y,t[34]=r,t[35]=n,t[36]=K,t[37]=ne):(K=t[36],ne=t[37]),Z.useEffect(K,ne);let q,J;t[38]!==b||t[39]!==x||t[40]!==S||t[41]!==r?(q=()=>{!b&&!x&&!S||r.setSidebarSessionStatusByKey(e=>Zg(e,{type:`session_status`,sessionKey:x,sessionId:b,sessionPath:S,unread:!1}))},J=[b,x,S,r],t[38]=b,t[39]=x,t[40]=S,t[41]=r,t[42]=q,t[43]=J):(q=t[42],J=t[43]),Z.useEffect(q,J);let re,Y;t[44]!==b||t[45]!==x||t[46]!==S||t[47]!==p||t[48]!==r?(re=()=>{let e=[b,S,x].join(`\0`),t=bae(p,{sessionId:b,sessionPath:S});!t&&x&&p.has(x)&&(t=x);let n=A.current;n.signature===e&&n.key===t||(A.current={signature:e,key:t},r.setSelectedSidebarSessionKeys(e=>{let n=t?[t]:[];return Ag(e,n)?e:n}),r.setSidebarSessionSelectionAnchor(e=>e===t?e:t))},Y=[b,x,S,p,r],t[44]=b,t[45]=x,t[46]=S,t[47]=p,t[48]=r,t[49]=re,t[50]=Y):(re=t[49],Y=t[50]),Z.useEffect(re,Y);let ie,ae;t[51]!==o||t[52]!==h||t[53]!==g||t[54]!==D||t[55]!==r||t[56]!==n?(ie=()=>{if(!n||!D)return;let e=o.filter(e=>!Object.prototype.hasOwnProperty.call(h,e)&&!g[e]&&!N.current[e]);if(e.length===0)return;let t=I(e);r.setDirectoryIndexLoading(t=>Gg(t,e,!0)),Hg({viewerContextId:n,directories:e}).then(n=>{let i=R(e,t);if(i.length===0)return;B(i,t);let a=Object.fromEntries(i.map(e=>[e,n.directoryIndexes[e]]).filter(Sae));r.setSidebarState(e=>{let t=Object.keys(a).length>0?Ug(e.directoryIndexDataByPath,a):e.directoryIndexDataByPath,n=Gg(e.directoryIndexLoading,i,!1);return t===e.directoryIndexDataByPath&&n===e.directoryIndexLoading?e:{directoryIndexDataByPath:t,directoryIndexLoading:n}})}).catch(n=>{let i=R(e,t);i.length!==0&&(B(i,t),r.setDirectoryIndexLoading(e=>Gg(e,i,!1)),Qe.error(n instanceof Error?n.message:`Failed to load sidebar sessions`))})},ae=[o,h,g,D,r,n],t[51]=o,t[52]=h,t[53]=g,t[54]=D,t[55]=r,t[56]=n,t[57]=ie,t[58]=ae):(ie=t[57],ae=t[58]),Z.useEffect(ie,ae);let oe,se;t[59]!==p||t[60]!==r?(oe=()=>{let e=new Set(p.keys());r.setSelectedSidebarSessionKeys(t=>{let n=t.filter(t=>e.has(t));return n.length===t.length?t:n}),r.setSidebarSessionSelectionAnchor(t=>t&&e.has(t)?t:``)},se=[p,r],t[59]=p,t[60]=r,t[61]=oe,t[62]=se):(oe=t[61],se=t[62]),Z.useEffect(oe,se);let ce;t[63]===r?ce=t[64]:(ce=e=>{let t=Xt(e);t.length!==0&&r.setSidebarDirectories(e=>{let n=Xt(e);return JSON.stringify(n)===JSON.stringify(t)?e:(ee(Me,JSON.stringify(t)),t)})},t[63]=r,t[64]=ce);let le=ce,ue;t[65]===r?ue=t[66]:(ue=e=>{let t=xn(e);t&&r.setPinnedSidebarSessionKeys(e=>{let n=fe(e),r=n.includes(t)?n.filter(e=>e!==t):[t,...n];return ee(Nt,JSON.stringify(r)),r})},t[65]=r,t[66]=ue);let de=ue,pe;t[67]===r?pe=t[68]:(pe=(e,t)=>{let n=t===void 0?``:t,i=fe(e),a=i.length===0?``:n&&i.includes(n)?n:i[i.length-1]??``;r.setSelectedSidebarSessionKeys(e=>Ag(e,i)?e:i),r.setSidebarSessionSelectionAnchor(e=>e===a?e:a)},t[67]=r,t[68]=pe);let me=pe,he;t[69]!==_||t[70]!==me||t[71]!==O?(he=e=>{let t=e.trim();if(!t)return;let n=qg(),r=n.indexOf(t);if(r<0){me([t],t);return}let i=n.includes(O)?O:_.find(e=>n.includes(e))??t,a=n.indexOf(i);if(a<0){me([t],t);return}let o=Math.min(a,r),s=Math.max(a,r);me(n.slice(o,s+1),i)},t[69]=_,t[70]=me,t[71]=O,t[72]=he):he=t[72];let ge=he,_e;t[73]!==ge||t[74]!==_||t[75]!==i||t[76]!==me?(_e=(e,t)=>{let n=xn(e);if(!n){e.id&&i.current?.selectSession(e.id,{sessionPath:e.path});return}if(t.shiftKey){ge(n);return}if(t.multiSelectKey){me(_.includes(n)?_.filter(e=>e!==n):[..._,n],n);return}me([n],n),e.id&&i.current?.selectSession(e.id,{sessionPath:e.path})},t[73]=ge,t[74]=_,t[75]=i,t[76]=me,t[77]=_e):_e=t[77];let ve=_e,ye;t[78]===i?ye=t[79]:(ye=()=>{i.current?.openSessionsDialog()},t[78]=i,t[79]=ye);let be=b||void 0,xe=x||void 0,Se,Ce,we,Te;t[80]===i?(Se=t[81],Ce=t[82],we=t[83],Te=t[84]):(Se=()=>{i.current?.createSession(void 0,{closeMobileSidebar:!0})},Ce=()=>{i.current?.openAddDirectoryDialog()},we=()=>{i.current?.openCommandPalette()},Te=()=>{i.current?.openSettingsDialog()},t[80]=i,t[81]=Se,t[82]=Ce,t[83]=we,t[84]=Te);let Ee,De;t[85]===i?(Ee=t[86],De=t[87]):(Ee=e=>{i.current?.openRenameDialogForEntry(e)},De=e=>{i.current?.openDeleteDialog([e])},t[85]=i,t[86]=Ee,t[87]=De);let Oe,ke;t[88]===i?(Oe=t[89],ke=t[90]):(Oe=e=>{i.current?.createSession(e,{closeMobileSidebar:!0})},ke=e=>{i.current?.openDeleteOldDirectorySessionsDialog(e)},t[88]=i,t[89]=Oe,t[90]=ke);let Ae;t[91]===r?Ae=t[92]:(Ae=e=>{r.setSidebarDirectories(t=>{let n=t.filter(t=>t!==e);return ee(Me,JSON.stringify(n)),n})},t[91]=r,t[92]=Ae);let je;return t[93]!==a||t[94]!==c||t[95]!==ve||t[96]!==T||t[97]!==f||t[98]!==le||t[99]!==_||t[100]!==E||t[101]!==ye||t[102]!==be||t[103]!==xe||t[104]!==Se||t[105]!==Ce||t[106]!==we||t[107]!==Te||t[108]!==Ee||t[109]!==De||t[110]!==Oe||t[111]!==ke||t[112]!==Ae||t[113]!==de||t[114]!==m?(je=(0,Q.jsx)(vae,{sessionSearch:E,onOpenSessionsDialog:ye,visibleDirectories:m,directorySessionsStore:a,matchingSessionCount:T,selectedSessionKeys:_,activeSessionId:be,activeSessionKey:xe,pinnedSessionKeys:f,emptyStateText:c,onCreateSession:Se,onOpenAddDirectoryDialog:Ce,onOpenCommandPalette:we,onOpenSettings:Te,onSessionClick:ve,onRenameSession:Ee,onDeleteSession:De,onTogglePinnedSession:de,onCreateSessionInDirectory:Oe,onDeleteOldSessionsInDirectory:ke,onRemoveDirectory:Ae,onReorderDirectories:le}),t[93]=a,t[94]=c,t[95]=ve,t[96]=T,t[97]=f,t[98]=le,t[99]=_,t[100]=E,t[101]=ye,t[102]=be,t[103]=xe,t[104]=Se,t[105]=Ce,t[106]=we,t[107]=Te,t[108]=Ee,t[109]=De,t[110]=Oe,t[111]=ke,t[112]=Ae,t[113]=de,t[114]=m,t[115]=je):je=t[115],je}function Sae(e){return!!e[1]}function Cae(e){return!!e[1]}function wae(e){return e.state.sidebarSessionSelectionAnchor}function Tae(e){return e.state.sidebarDeferredDirectoryLoadingReady}function Eae(e){return e.state.sessionSearch}function Dae(e){return e.state.sessionsEvent}function Oae(e,t){return e.activeSessionId===t.activeSessionId&&e.activeSessionKey===t.activeSessionKey&&e.activeSessionPath===t.activeSessionPath&&e.activeStreaming===t.activeStreaming&&e.event?.activeSessionId===t.event?.activeSessionId&&e.event?.activeSessionKey===t.event?.activeSessionKey&&e.event?.activeSessionPath===t.event?.activeSessionPath&&Ag(e.event?.directories||[],t.event?.directories||[])}function kae(e){let t=e.state.sessionsEvent,n=e.state.activeSidebarSessionId,r=e.state.activeSidebarSessionKey,i=e.state.activeSidebarSessionPath,a=e.state.sidebarSessionStatusByKey;return{event:t,activeSessionId:n,activeSessionKey:r,activeSessionPath:i,activeStreaming:!!((i?a[`path:${i}`]:void 0)||(n?a[`id:${n}`]:void 0)||(r?a[`key:${r}`]:void 0))?.streaming}}function Aae(e){return e.state.selectedSidebarSessionKeys}function jae(e){return e.state.directoryIndexLoading}function Mae(e){return e.state.directoryIndexDataByPath}function Nae(e){return e.derived.visibleDirectories}function Pae(e){return e.derived.sidebarSessionEntriesByKey}function Fae(e){return xn(e)}function Iae(e){return e.derived.pinnedSidebarSessions}function Lae(e){return e.derived.filteredDirectorySessions}function Rae(e){return e.derived.emptySidebarStateText}function zae(e){return e.derived.directoryStateByPath}function Bae(e){return e.derived.baseSidebarDirectories}function Vae(){return dae({},{})}var Hae=4e3,C9=`/sounds/session-done.mp3`,Uae=.85,w9=null,T9=null,E9=null;function Wae(){if(typeof window>`u`)return null;let e=window;return globalThis.AudioContext??e.webkitAudioContext??null}function D9(){if(typeof navigator>`u`)return!1;let e=navigator.userActivation;return e?e.isActive:!0}function O9({requireUserActivation:e=!1}={}){let t=Wae();if(!t)return null;if(!w9){if(e&&!D9())return null;w9=new t}return w9}async function k9(e){if(e.state===`suspended`){if(!D9())return!1;try{await e.resume()}catch{return!1}}return e.state===`running`}async function A9(e){return T9||(E9??=fetch(C9).then(e=>{if(!e.ok)throw Error(`Failed to load ${C9}`);return e.arrayBuffer()}).then(t=>e.decodeAudioData(t)).then(e=>(T9=e,e)).catch(()=>(E9=null,null)),E9)}function Gae(e){let t=e.createOscillator(),n=e.createGain();t.type=`triangle`,t.frequency.setValueAtTime(659.25,e.currentTime),t.frequency.linearRampToValueAtTime(783.99,e.currentTime+.12),n.gain.setValueAtTime(1e-4,e.currentTime),n.gain.exponentialRampToValueAtTime(.08,e.currentTime+.02),n.gain.exponentialRampToValueAtTime(1e-4,e.currentTime+.28),t.connect(n),n.connect(e.destination),t.start(e.currentTime),t.stop(e.currentTime+.3)}async function j9(){let e=O9({requireUserActivation:!0});return!e||!await k9(e)?!1:!!await A9(e)}async function M9(){let e=O9({requireUserActivation:!0});if(!e||!await k9(e))return!1;let t=await A9(e);if(!t)return Gae(e),!0;let n=e.createBufferSource(),r=e.createGain();return n.buffer=t,r.gain.value=Uae,n.connect(r),r.connect(e.destination),n.start(),!0}function Kae(){return typeof Notification>`u`?`unsupported`:Notification.permission}async function qae(){if(typeof Notification>`u`)return`unsupported`;let e=Notification.requestPermission();return typeof e==`string`?e:await e}function N9({title:e,body:t,tag:n}){if(typeof Notification>`u`||Notification.permission!==`granted`)return!1;try{let r=new Notification(e,{body:t,tag:n,silent:!0});return window.setTimeout(()=>{r.close()},Hae),!0}catch{return!1}}var P9=[`🌑`,`🌒`,`🌓`,`🌔`,`🌕`,`🌖`,`🌗`,`🌘`],Jae=500;function Yae(e){let t=(0,$.c)(20),{isSessionViewLoading:n,loadingDisplaySessionTitle:r,notificationStore:i,onSelectSession:a,sessionStore:o,sidebarStore:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={compare:Pg},t[0]=c):c=t[0];let l=Ji(o,Zae,c),u=Ji(i),d,f;t[1]===u.sessionDoneSoundEnabled?(d=t[2],f=t[3]):(d=()=>{if(!u.sessionDoneSoundEnabled)return;let e=Xae;return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,e,!0),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,e,!0)}},f=[u.sessionDoneSoundEnabled],t[1]=u.sessionDoneSoundEnabled,t[2]=d,t[3]=f),Z.useEffect(d,f);let p;t[4]===l?p=t[5]:(p=Fg(l),t[4]=l,t[5]=p);let m=p,h=n?r:l.uiTitle||(m===`New session`?`Pico`:m),g;t[6]===i?g=t[7]:(g=e=>{let t=new Set(e);Bg(i,`sessionDoneEvents`,e=>e.filter(e=>!t.has(e.id)))},t[6]=i,t[7]=g);let _=g,v;return t[8]!==h||t[9]!==u.sessionDoneDesktopNotificationsEnabled||t[10]!==u.sessionDoneEvents||t[11]!==u.sessionDoneSoundEnabled||t[12]!==_||t[13]!==a||t[14]!==l.activeSessionKey||t[15]!==l.activeSessionNotificationKey||t[16]!==l.sessionCwd||t[17]!==l.sessionStreaming||t[18]!==s?(v=(0,Q.jsx)(Qae,{activeSessionKey:l.activeSessionKey,activeSessionNotificationKey:l.activeSessionNotificationKey,currentPageTitle:h,sessionCwd:l.sessionCwd,sessionDoneDesktopNotificationsEnabled:u.sessionDoneDesktopNotificationsEnabled,sessionDoneSoundEnabled:u.sessionDoneSoundEnabled,sessionStreaming:l.sessionStreaming,sessionDoneEvents:u.sessionDoneEvents,sidebarStore:s,onConsumeSessionDoneEvents:_,onSelectSession:a}),t[8]=h,t[9]=u.sessionDoneDesktopNotificationsEnabled,t[10]=u.sessionDoneEvents,t[11]=u.sessionDoneSoundEnabled,t[12]=_,t[13]=a,t[14]=l.activeSessionKey,t[15]=l.activeSessionNotificationKey,t[16]=l.sessionCwd,t[17]=l.sessionStreaming,t[18]=s,t[19]=v):v=t[19],v}function Xae(){j9()}function Zae(e){return{activeSessionKey:e.sessionKey,activeSessionNotificationKey:Dg({sessionId:e.sessionId,sessionFile:e.sessionFile}),sessionCwd:e.cwd,sessionName:e.sessionName,sessionStreaming:e.streaming,firstMessage:e.firstMessage,uiTitle:e.uiState.title?.trim()||``}}function Qae(e){let t=(0,$.c)(30),{activeSessionKey:n,activeSessionNotificationKey:r,currentPageTitle:i,sessionCwd:a,sessionDoneDesktopNotificationsEnabled:o,sessionDoneSoundEnabled:s,sessionStreaming:c,sessionDoneEvents:l,sidebarStore:u,onConsumeSessionDoneEvents:d,onSelectSession:f}=e,[p,m]=Z.useState(roe),[h,g]=Z.useState(0),[_,v]=Z.useState(``),y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y=new Set,t[0]=y):y=t[0];let b=Z.useRef(y),x,S;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{let e=()=>{m(document.visibilityState===`visible`&&document.hasFocus())};return e(),window.addEventListener(`focus`,e),window.addEventListener(`blur`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),window.removeEventListener(`blur`,e),document.removeEventListener(`visibilitychange`,e)}},S=[],t[1]=x,t[2]=S):(x=t[1],S=t[2]),Z.useEffect(x,S);let C,w;t[3]!==r||t[4]!==p?(C=()=>{if(p||!r){v(``);return}v(e=>e&&e!==r?``:e)},w=[r,p],t[3]=r,t[4]=p,t[5]=C,t[6]=w):(C=t[5],w=t[6]),Z.useEffect(C,w);let T,E;t[7]===c?(T=t[8],E=t[9]):(T=()=>{if(!c){g(0);return}let e=window.setInterval(()=>{g(noe)},Jae);return()=>{window.clearInterval(e)}},E=[c],t[7]=c,t[8]=T,t[9]=E),Z.useEffect(T,E);let D,O;t[10]!==n||t[11]!==r||t[12]!==p||t[13]!==d||t[14]!==f||t[15]!==a||t[16]!==o||t[17]!==l||t[18]!==s?(D=()=>{if(l.length===0)return;let e=[],t=!1;for(let i of l){if(e.push(i.id),b.current.has(i.id))continue;b.current.add(i.id);let c=Dg({sessionId:i.sessionId,sessionPath:i.sessionPath}),l=!!(c&&r&&c===r||i.sessionKey&&n&&i.sessionKey===n),u=ite(i),d=i.cwd||a||`Open Pico to continue`,m=i.sessionPath||i.sessionId||i.id;if(l){!p&&c&&v(c),o&&!p&&N9({title:u,body:d,tag:m}),s&&!p&&!t&&(t=!0,M9());continue}if(i.sessionId){let e=i.sessionId,t=i.id;Qe.success(u,{id:t,className:`cursor-pointer`,action:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Open ${u}`,className:`absolute inset-0 z-10 cursor-pointer rounded-[var(--border-radius)] bg-transparent p-0 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none`,onClick:()=>{Qe.dismiss(t),f(e)}})})}else Qe.success(u);o&&!p&&N9({title:u,body:d,tag:m}),s&&!t&&(t=!0,M9())}d(e)},O=[n,r,p,d,f,a,o,l,s],t[10]=n,t[11]=r,t[12]=p,t[13]=d,t[14]=f,t[15]=a,t[16]=o,t[17]=l,t[18]=s,t[19]=D,t[20]=O):(D=t[19],O=t[20]),Z.useEffect(D,O);let k=Ji(u,$ae),A;t[21]!==_||t[22]!==k?(A=new Set(k?k.split(`
|
|
2149
2149
|
`):[]),_&&A.add(_),t[21]=_,t[22]=k,t[23]=A):A=t[23];let j=A.size,M,N;return t[24]!==i||t[25]!==c||t[26]!==h||t[27]!==j?(M=()=>{let e=`${c?`${P9[h]} `:``}${i}`;document.title=j>0?`(${j}) ${e}`:e},N=[i,c,h,j],t[24]=i,t[25]=c,t[26]=h,t[27]=j,t[28]=M,t[29]=N):(M=t[28],N=t[29]),Z.useEffect(M,N),null}function $ae(e){return e.derived.sidebarSessions.filter(toe).map(eoe).filter(Boolean).sort().join(`
|
|
2150
2150
|
`)}function eoe(e){return Dg(e)}function toe(e){return e.unread}function noe(e){return(e+1)%P9.length}function roe(){return typeof document>`u`?!0:document.visibilityState===`visible`&&document.hasFocus()}function F9(e,t){return e.optimisticId||`pending-draft:${t}`}function ioe(e,t,n){let r=e.findIndex((e,n)=>F9(e,n)===t);if(r===-1)return null;let i=e[r];if(!i)return null;let a=[...e],o=r+n,s=a[o];if(n===-1&&(i.streamingBehavior===`followUp`&&!s||i.streamingBehavior===`followUp`&&s.streamingBehavior===`steer`))return a[r]={...i,streamingBehavior:`steer`},a;if(n===1&&(i.streamingBehavior===`steer`&&!s||i.streamingBehavior===`steer`&&s.streamingBehavior===`followUp`))return a[r]={...i,streamingBehavior:`followUp`},a;if(!s)return null;let[c]=a.splice(r,1);return c?(a.splice(o,0,c),a):null}var I9=[],L9=[];function R9(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(!r||!i||r.mimeType!==i.mimeType||r.data!==i.data||r.previewUrl!==i.previewUrl)return!1}return!0}function aoe(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(!r||!i||r.pendingId!==i.pendingId||r.text!==i.text||r.streamingBehavior!==i.streamingBehavior||!R9(r.images,i.images))return!1}return!0}function ooe(e,t){return e.activeSessionId===t.activeSessionId&&e.awaitingFirstTurn===t.awaitingFirstTurn&&e.centerMessages===t.centerMessages&&e.composerSkill===t.composerSkill&&e.composerSyncNonce===t.composerSyncNonce&&e.composerText===t.composerText&&e.disabled===t.disabled&&e.isStreaming===t.isStreaming&&e.isSubmitting===t.isSubmitting&&e.viewerContextId===t.viewerContextId&&R9(e.composerImages,t.composerImages)&&aoe(e.currentPendingMessages,t.currentPendingMessages)}function soe(e){return{activeSessionId:void 0,awaitingFirstTurn:!1,centerMessages:!1,composerImages:I9,composerSkill:void 0,composerSyncNonce:0,composerText:``,currentPendingMessages:L9,disabled:!1,isStreaming:!1,isSubmitting:!1,viewerContextId:e}}function z9(e){let t=e.cwd?.trim()||e.previous.cwd?.trim()||``;return{...pn(),connected:e.previous.connected,draft:!0,sessionKey:`optimistic:${e.ownerKey}`,cwd:t||void 0,model:e.previous.model,thinkingLevel:e.previous.thinkingLevel,availableThinkingLevels:e.previous.availableThinkingLevels,availableModels:e.previous.availableModels,availableSkills:e.previous.availableSkills,hideThinkingBlock:e.previous.hideThinkingBlock}}function coe(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`optimistic:${crypto.randomUUID()}`:`optimistic:${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function loe(e,t){if(t.pendingId&&e.some(e=>e.kind===`user`&&e.pendingId===t.pendingId))return e;let n=[...e],r=n[n.length-1],i=r?.kind===`assistant`&&r.streaming?n.length-1:n.length;return n.splice(i,0,t),n}function uoe(e,t){let n=!1,r=e.filter(e=>{let r=e.kind===`user`&&e.pendingId===t;return r&&(n=!0),!r});return n?r:e}var doe=`Compacting context...`,foe=`Error: Compaction cancelled`;function poe(e,t){return e?.label===t?.label&&e?.summary===t?.summary&&e?.done===t?.done&&e?.error===t?.error&&e?.cancelable===t?.cancelable}function moe(e){let t=new wo(t=>{e.onLatest(t)},{key:e.key,wait:e.wait,leading:!1,trailing:!0});return{add:e=>t.maybeExecute(e),flush:()=>t.flush(),cancel:()=>t.cancel()}}function hoe(e,t){return e.cwd===t.cwd&&e.draft===t.draft&&e.sessionFile===t.sessionFile&&e.sessionId===t.sessionId&&e.sessionKey===t.sessionKey&&e.streaming===t.streaming}function goe(e){let t=(0,$.c)(1),n;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={compare:hoe},t[0]=n):n=t[0],Ji(e,_oe,n)}function _oe(e){return{cwd:e.cwd,draft:e.draft,sessionFile:e.sessionFile,sessionId:e.sessionId,sessionKey:e.sessionKey,streaming:e.streaming}}function B9(e){return e===`followUp`?`followUp`:`steer`}function V9(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`optimistic:${crypto.randomUUID()}`:`optimistic:${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function H9(e,{contextId:t,sessionState:n,fallbackSessionId:r}){let i=n.sessionKey&&!n.sessionKey.startsWith(`optimistic:`)?n.sessionKey:void 0,a=!!(i&&(n.draft||!n.sessionId));return Ch(e,{contextId:t,sessionId:a?void 0:n.sessionId??r,searchParams:a?{sessionKey:i}:void 0})}function voe(e){return e instanceof Error&&e.message.toLowerCase().includes(`pending prompt not found`)}function yoe(e,t,n){let r=e.findIndex(e=>e.pendingId===t);if(r===-1)return null;let i=e[r];if(!i)return null;let a=[...e],o=r+n,s=a[o];if(n===-1&&(i.streamingBehavior===`followUp`&&!s||i.streamingBehavior===`followUp`&&s.streamingBehavior===`steer`))return a[r]={...i,streamingBehavior:`steer`},a;if(n===1&&(i.streamingBehavior===`steer`&&!s||i.streamingBehavior===`steer`&&s.streamingBehavior===`followUp`))return a[r]={...i,streamingBehavior:`followUp`},a;if(!s)return null;let[c]=a.splice(r,1);return c?(a.splice(o,0,c),a):null}function boe({viewerContextId:e,activeSessionId:t,defaultNewSessionDirectory:n,sessionStore:r,sessionStateRef:i,draftSessionLoadingOwnerKey:a,pendingDraftPrompt:o,pendingDraftFollowUps:s,awaitingFirstTurn:c,pendingMessages:l,composerImagesRef:u,composerTextRef:d,composerSkillRef:f,replaceComposerDraft:p,lastSyncedEditorTextRef:m,rememberRecentDirectory:h,prefetchDirectorySessionsIndex:g,addOptimisticUserMessage:_,removeOptimisticUserMessage:v,setSidebarDirectories:y,setStoredDraftDirectory:b,setDraftSessionLoadingOwnerKey:x,setPendingDraftPrompt:S,setPendingDraftFollowUps:C,setPendingMessages:w,setAwaitingFirstTurn:T,setIsSubmitting:E,setComposerImages:D}){let O=Z.useRef(a),k=Z.useRef(o),A=Z.useRef(s),j=Z.useRef(l),M=Z.useRef(c),N=goe(r),P=Z.useRef(N.streaming);Z.useEffect(()=>{O.current=a},[a]),Z.useEffect(()=>{k.current=o},[o]),Z.useEffect(()=>{A.current=s},[s]),Z.useEffect(()=>{j.current=l},[l]),Z.useEffect(()=>{M.current=c},[c]),Z.useEffect(()=>{P.current=N.streaming},[N.streaming]);let F=Z.useCallback(e=>{w(t=>{let n=e(t);return j.current=n,n})},[w]),I=Z.useCallback(e=>{F(t=>t.some(t=>t.pendingId===e.pendingId)?t:[...t,e])},[F]),L=Z.useCallback(e=>{F(t=>t.filter(t=>t.pendingId!==e))},[F]),R=Z.useCallback((e,t)=>{F(n=>{if(n.some(t=>t.pendingId===e.pendingId))return n;let r=[...n];return r.splice(Math.max(0,Math.min(t,r.length)),0,e),r})},[F]),z=Nr({mutationFn:async n=>{if(!e)throw Error(`Viewer context unavailable`);return await wh(Ch(`/api/directory/resolve`,{contextId:e,sessionId:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:n})})}}),B=Z.useCallback(e=>(p(e.message),D(e.images.map(e=>({...e}))),!0),[p,D]),V=Z.useCallback(e=>{let t=k.current;if(!t||t.ownerKey!==e)return!1;v(t.optimisticId);for(let e of A.current)v(e.optimisticId);return k.current=null,A.current=[],S(null),C([]),M.current=!1,T(!1),B(t)},[B,v,T,C,S]),H=Z.useCallback(async t=>{if(!e)return!1;let n=t.trim();if(!n)return!1;try{let e=await z.mutateAsync(n);return y(t=>{let n=Xt([...t,e.path]);return ee(Me,JSON.stringify(n)),n}),h(e.path),g(e.path),e.path}catch(e){return Qe.error(e instanceof Error?e.message:`Failed to add directory`),!1}},[z,g,h,y,e]),U=Z.useCallback(async({cwd:n})=>{if(!e)throw Error(`Viewer context unavailable`);return await wh(Ch(`/api/session/new`,{contextId:e,sessionId:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({cwd:n})})},[t,e]),W=Z.useCallback(async t=>{if(!e)return!1;let r=t||n||void 0;r&&(h(r),ee(an,r),b(r));let i=Kt({cwd:r});O.current=i,x(i);try{return await U({cwd:r}),!0}catch(e){return O.current===i&&(O.current=null),x(e=>e===i?null:e),V(i),Qe.error(e instanceof Error?e.message:`Failed to create session`),!1}},[U,n,h,V,x,b,e]),G=Z.useCallback(e=>{let t=O.current;if(!t)return!1;let n=Xx({text:d.current,skillName:f.current}).trim(),r=u.current.map(e=>({...e}));if(!n&&r.length===0)return!1;if(k.current?.ownerKey===t&&k.current){let t=B9(e),i=V9(),a=[...A.current,{message:n,images:r,streamingBehavior:t,optimisticId:i}];A.current=a,C(a)}else{let e={ownerKey:t,message:n,images:r,optimisticId:_({message:n,images:r,queued:!1})};k.current=e,S(e),M.current=!0,T(!0),Qe.info(`Prompt will send when the new session is ready.`)}return p(``,void 0,{forceSync:!0}),D([]),m.current=``,!0},[_,u,f,d,m,p,T,D,C,S]),te=Nr({mutationFn:async({message:n,images:r,streamingBehavior:a,pendingId:o,thinkingLevel:s})=>{if(!e)throw Error(`Viewer context unavailable`);return await wh(H9(`/api/prompt`,{contextId:e,sessionState:i.current,fallbackSessionId:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:n,images:r,streamingBehavior:a,pendingId:o,thinkingLevel:s})})}}),K=Z.useCallback(async(t,n)=>{if(!e)return!1;if(O.current)return G(t);let r=Xx({text:d.current,skillName:f.current}).trim();if(!r&&u.current.length===0)return!1;let a=n?.forceFirstPrompt?!1:!!(P.current||M.current),o=a?B9(t):void 0,s=u.current.map(e=>({...e})),c=a?V9():void 0,l=n?.optimisticId??(a?void 0:_({message:r,images:s,queued:!1}));c&&o&&I({pendingId:c,text:r,images:s.map(e=>({...e})),streamingBehavior:o}),E(!0),a||(M.current=!0,T(!0)),p(``,void 0,{forceSync:!0}),D([]),m.current=``;try{let e=await te.mutateAsync({message:r,images:s,streamingBehavior:o,pendingId:c,thinkingLevel:i.current.thinkingLevel});return c&&`queued`in e&&(!e.queued||e.canceled)&&L(c),!0}catch(e){return c&&L(c),v(l),a||(M.current=!1,T(!1)),Xx({text:d.current,skillName:f.current}).trim()||(p(r),D(e=>e.length===0?s.map(e=>({...e})):e)),Qe.error(e instanceof Error?e.message:`Failed to submit prompt`),!1}finally{E(!1)}},[I,_,u,f,d,m,te,G,i,L,v,p,T,D,E,e]),ne=Z.useCallback(async()=>{if(O.current)return!1;let e=A.current;if(e.length===0)return!1;let t=e.map(e=>({message:e.message,images:e.images.map(e=>({...e})),streamingBehavior:e.streamingBehavior,optimisticId:e.optimisticId}));A.current=[],C([]);for(let e=0;e<t.length;e+=1){let n=t[e];if(n)try{await te.mutateAsync({message:n.message,images:n.images,streamingBehavior:n.streamingBehavior,pendingId:n.optimisticId,thinkingLevel:i.current.thinkingLevel})}catch(r){for(let n of t.slice(e))v(n.optimisticId);return d.current||(p(n.message),D(n.images)),Qe.error(r instanceof Error?r.message:`Failed to submit queued follow-up`),!1}}return!0},[d,te,v,i,p,D,C]),q=Z.useCallback(async e=>{let t=k.current;if(!t||t.ownerKey!==e||O.current)return!1;if(k.current=null,S(null),B(t),!await K(t.streamingBehavior,{forceFirstPrompt:!0,optimisticId:t.optimisticId})){for(let e of A.current)v(e.optimisticId);return A.current=[],C([]),!1}return await ne(),!0},[B,ne,v,C,S,K]);Z.useEffect(()=>{if(!a)return;let e=i.current;if(e.sessionKey?.startsWith(`optimistic:`))return;let t=Kt(e);!e.draft||t!==a||(O.current=null,x(null),k.current?.ownerKey===a&&q(a))},[a,q,N,i,x]),Z.useEffect(()=>{if(!c)return;let e=i.current,t=e.items.some(e=>e.kind===`assistant`&&e.blocks.some(e=>e.type===`text`&&e.text.trim()));(e.streaming||t||l.length>0)&&(M.current=!1,T(!1))},[c,l.length,N.streaming,i,T]);let J=Nr({mutationFn:async()=>{if(!e)throw Error(`Viewer context unavailable`);return await wh(H9(`/api/abort`,{contextId:e,sessionState:i.current,fallbackSessionId:t}),{method:`POST`})}}),re=Z.useCallback(async()=>{if(e)try{await J.mutateAsync()}catch(e){Qe.error(e instanceof Error?e.message:`Failed to abort session`)}},[J,e]),Y=Nr({mutationFn:async n=>{if(!e)throw Error(`Viewer context unavailable`);return await wh(H9(`/api/pending-messages/reorder`,{contextId:e,sessionState:i.current,fallbackSessionId:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({pendingMessages:n})})}}),ie=Z.useCallback(async(t,n)=>{if(!e)return;let r=j.current,i=r.find(e=>e.pendingId===t);if(!i)return;if(!n.trim()&&i.images.length===0){Qe.error(`Enter a message or keep at least one image`);return}let a=r.map(e=>e.pendingId===t?{...e,text:n}:e);F(e=>e.map(e=>e.pendingId===t?{...e,text:n}:e));try{await Y.mutateAsync(a)}catch(e){F(()=>r),Qe.error(e instanceof Error?e.message:`Failed to update pending prompt`)}},[Y,j,F,e]),ae=Nr({mutationFn:async n=>{if(!e)throw Error(`Viewer context unavailable`);return await wh(H9(`/api/pending-message/remove`,{contextId:e,sessionState:i.current,fallbackSessionId:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({pendingId:n})})}});return{abortSession:re,addDirectoryPath:H,createSession:W,editPendingMessage:ie,removePendingMessage:Z.useCallback(async t=>{if(!e)return;let n=j.current.findIndex(e=>e.pendingId===t),r=j.current[n];L(t);try{await ae.mutateAsync(t)}catch(e){if(voe(e))return;r&&R(r,n),Qe.error(e instanceof Error?e.message:`Failed to remove pending prompt`)}},[L,ae,R,e]),reorderPending:Z.useCallback(async(t,n)=>{if(!e)return;let r=yoe(j.current,t,n);if(r)try{await Y.mutateAsync(r)}catch(e){Qe.error(e instanceof Error?e.message:`Failed to update pending prompts`)}},[Y,j,e]),submitPrompt:K}}function U9(e,t){return e.sessionKey||t.sessionKey?e.sessionKey===t.sessionKey:e.sessionId||t.sessionId?e.sessionId===t.sessionId:e.sessionFile||t.sessionFile?e.sessionFile===t.sessionFile:e.cwd===t.cwd&&e.draft===t.draft}function xoe(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function W9(e,t,n){let r=!1,i={...e};for(let[a,o]of Object.entries(e)){let e=!1,s=o.sessions.map(i=>i.path!==t||i.name===n&&i.title===n?i:(e=!0,r=!0,{...i,name:n,title:n}));e&&(i[a]={...o,sessions:s})}return r?i:e}function G9(e,t){if(t.size===0)return e;let n=!1,r={...e};for(let[i,a]of Object.entries(e)){let e=a.sessions.filter(e=>!e.path||!t.has(e.path)),o=a.sessions.length-e.length;o!==0&&(n=!0,r[i]={...a,totalCount:Math.max(0,a.totalCount-o),sessions:e})}return n?r:e}function K9(e,t){if(!e||t.size===0)return[];let n=[];for(let[r,i]of Object.entries(e))i.sessions.some(e=>e.path&&t.has(e.path))&&n.push(r);return n}function q9(e,t,n){if(n.length===0)return e;let r=!1,i={...e};for(let a of n){let n=t?.[a];if(n){e[a]!==n&&(i[a]=n,r=!0);continue}Object.prototype.hasOwnProperty.call(e,a)&&(delete i[a],r=!0)}return r?i:e}function J9(e,t){if(!e?.directoryIndexes)return e;let n=t(e.directoryIndexes);return n===e.directoryIndexes?e:{...e,directoryIndexes:n}}function Soe(e,t){return{selectedSidebarSessionKeys:e.selectedSidebarSessionKeys.filter(e=>!t.has(e)),sidebarSessionSelectionAnchor:e.sidebarSessionSelectionAnchor&&t.has(e.sidebarSessionSelectionAnchor)?``:e.sidebarSessionSelectionAnchor}}function Coe({viewerContextId:e,activeSessionId:t,sessionStateRef:n,setSessionState:r,getDirectoryIndexDataByPath:i,setDirectoryIndexDataByPath:a,getSessionsEvent:o,setSessionsEvent:s,getSidebarSelection:c,optimisticallyClearActiveDeletedSession:l,setSelectedSidebarSessionKeys:u,setSidebarSessionSelectionAnchor:d,setCompactWorkingState:f,isCompactAbortRequested:p}){let m=Z.useRef(0),h=Z.useRef(null);Z.useEffect(()=>()=>{h.current&&clearTimeout(h.current)},[]);let g=Z.useCallback(async n=>{if(!e)return;let[r,i]=n.split(`/`);if(!(!r||!i))try{await wh(Ch(`/api/model`,{contextId:e,sessionId:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({provider:r,modelId:i})})}catch(e){Qe.error(e instanceof Error?e.message:`Failed to update model`)}},[t,e]),_=Z.useCallback(async i=>{if(!e)return;let a=m.current+1;m.current=a;let o=n.current,s=o.thinkingLevel,c=o.availableThinkingLevels,l={cwd:o.cwd,draft:o.draft,sessionFile:o.sessionFile,sessionId:o.sessionId,sessionKey:o.sessionKey};s!==i&&r({...o,thinkingLevel:i}),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{h.current=null,(async()=>{try{let o=await wh(Ch(`/api/thinking`,{contextId:e,sessionId:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({level:i})});if(m.current!==a)return;let s=n.current;if(!U9(l,s))return;let c=o.thinkingLevel||i,u=o.availableThinkingLevels.length>0?o.availableThinkingLevels:s.availableThinkingLevels;if(s.thinkingLevel===c&&s.availableThinkingLevels===u)return;r({...s,thinkingLevel:c,availableThinkingLevels:u})}catch(e){if(m.current!==a)return;let t=n.current;U9(l,t)&&t.thinkingLevel===i&&r({...t,thinkingLevel:s,availableThinkingLevels:c}),Qe.error(e instanceof Error?e.message:`Failed to update thinking level`)}})()},100)},[n,t,r,e]),v=Z.useCallback(async e=>{let t=n.current,r=t.availableThinkingLevels.length?t.availableThinkingLevels:[`off`],i=r.indexOf(t.thinkingLevel||`off`);await _(r[((i>=0?i:0)+e+r.length)%r.length]||r[0])},[n,_]),y=Z.useCallback(async n=>{if(e)try{await wh(Ch(`/api/settings/hide-thinking`,{contextId:e,sessionId:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({hide:n})}),Qe.info(n?`Thinking hidden`:`Thinking shown`)}catch(e){Qe.error(e instanceof Error?e.message:`Failed to update thinking visibility`)}},[t,e]),b=Z.useCallback(async()=>{await y(!n.current.hideThinkingBlock)},[n,y]),x=Z.useCallback(async()=>{if(e){f(!0);try{await wh(Ch(`/api/slash-command`,{contextId:e,sessionId:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:`compact`,args:``})})}catch(e){p()||Qe.error(e instanceof Error?e.message:`Failed to compact session`)}finally{f(!1)}}},[t,p,f,e]),S=Z.useCallback(async()=>{if(e)try{if((await wh(Ch(`/api/session/clone`,{contextId:e,sessionId:t}),{method:`POST`,headers:{"content-type":`application/json`}})).cancelled)return;Qe.success(`Cloned session`)}catch(e){Qe.error(e instanceof Error?e.message:`Failed to clone session`)}},[t,e]),C=Nr({mutationFn:async({path:n,name:r})=>{if(!e)throw Error(`Viewer context unavailable`);return await wh(Ch(`/api/session/rename`,{contextId:e,sessionId:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:n,name:r})})}}),w=Z.useCallback(async(t,c)=>{if(!e||!t)return!1;let l=c.trim();if(!l)return Qe.error(`Name is required`),!1;let u=i(),d=o(),f=new Set([t]),p=K9(u,f),m=K9(d?.directoryIndexes,f),h=n.current.sessionName,g=n.current.sessionFile===t;return s(e=>J9(e,e=>W9(e,t,l))),a(e=>W9(e,t,l)),g&&n.current.sessionName!==l&&r(e=>e.sessionFile===t?{...e,sessionName:l}:e),(async()=>{try{let e=(await C.mutateAsync({path:t,name:l})).name||l;e!==l&&(s(n=>J9(n,n=>W9(n,t,e))),a(n=>W9(n,t,e)),r(n=>n.sessionFile===t&&n.sessionName===l?{...n,sessionName:e}:n)),Qe.success(`Renamed session`)}catch(e){s(e=>J9(e,e=>q9(e,d?.directoryIndexes,m))),a(e=>q9(e,u,p)),r(e=>e.sessionFile===t&&e.sessionName===l?{...e,sessionName:h}:e),Qe.error(e instanceof Error?e.message:`Failed to rename session`)}})(),!0},[i,o,C,n,a,r,s,e]),T=Nr({mutationFn:async n=>{if(!e)throw Error(`Viewer context unavailable`);await wh(Ch(`/api/sessions/delete`,{contextId:e,sessionId:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({paths:n})})}});return{cycleThinkingLevel:v,deleteSessions:Z.useCallback(async t=>{if(!e||t.length===0)return!1;let r=[...t.filter(e=>e.path&&e.path!==n.current.sessionFile),...t.filter(e=>e.path&&e.path===n.current.sessionFile)],f=[],p=new Set;for(let e of r)!e.path||p.has(e.path)||(p.add(e.path),f.push(e.path));if(f.length===0)return!1;let m=new Set(r.map(e=>xn(e)).filter(Boolean)),h=i(),g=o(),_=K9(h,p),v=K9(g?.directoryIndexes,p),y=c(),b=Soe(y,m);s(e=>J9(e,e=>G9(e,p))),a(e=>G9(e,p)),u(e=>e.filter(e=>!m.has(e))),d(e=>e&&m.has(e)?``:e);let x=n.current.sessionFile,S=x&&p.has(x)?l?.(x):void 0;return(async()=>{try{await T.mutateAsync(f),Qe.success(f.length===1?`Deleted session`:`Deleted ${f.length} sessions`)}catch(e){s(e=>J9(e,e=>q9(e,g?.directoryIndexes,v))),a(e=>q9(e,h,_)),S?.();let t=c();xoe(t.selectedSidebarSessionKeys,b.selectedSidebarSessionKeys)&&t.sidebarSessionSelectionAnchor===b.sidebarSessionSelectionAnchor&&(u(y.selectedSidebarSessionKeys),d(y.sidebarSessionSelectionAnchor)),Qe.error(e instanceof Error?e.message:`Failed to delete session`)}})(),!0},[T,i,o,c,l,n,a,u,s,d,e]),renameSessionPath:w,runClone:S,runCompact:x,setModel:g,setThinkingBlocksHidden:y,setThinkingLevel:_,toggleHideThinking:b}}var woe=3e4,Toe=`Compacting context...`;function Eoe(e){if(lh(e)&&Array.isArray(e.pendingUserMessages))return e.pendingUserMessages.map(e=>({pendingId:typeof e.pendingId==`string`?e.pendingId:``,text:typeof e.text==`string`?e.text:``,images:Array.isArray(e.images)?e.images.map(e=>An(e)).filter(e=>!!e):[],streamingBehavior:e.streamingBehavior===`steer`?`steer`:`followUp`}))}function Doe(e=[],t=[]){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function Ooe(e=[],t=[]){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(!r||!i||r.mimeType!==i.mimeType||r.data!==i.data||r.previewUrl!==i.previewUrl)return!1}return!0}function koe(e=[],t=[]){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(!r||!i||r.pendingId!==i.pendingId||r.text!==i.text||r.streamingBehavior!==i.streamingBehavior||!Ooe(r.images,i.images))return!1}return!0}function Aoe(e=[],t=[]){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(!r||!i||r.path!==i.path||r.totalCount!==i.totalCount||r.revision!==i.revision)return!1}return!0}function joe(e=[],t=[]){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(!r||!i||r.path!==i.path||r.id!==i.id||r.cwd!==i.cwd||r.name!==i.name||r.title!==i.title||r.modified!==i.modified||r.lastUserMessageAt!==i.lastUserMessageAt||r.lastMessageAt!==i.lastMessageAt||r.lastMessagePreview!==i.lastMessagePreview||r.messageCount!==i.messageCount||!en(r.contextUsage,i.contextUsage)||!!r.streaming!=!!i.streaming||!!r.unread!=!!i.unread)return!1}return!0}function Moe(e,t){let n=Object.entries(e||{}),r=Object.entries(t||{});if(n.length!==r.length)return!1;for(let[e,r]of n){let n=t?.[e];if(!r||!n||r.directory!==n.directory||r.totalCount!==n.totalCount||r.revision!==n.revision||!joe(r.sessions,n.sessions))return!1}return!0}function Y9(e,t){return e===t?!0:!e||!t?!1:e.activeSessionId===t.activeSessionId&&e.activeSessionKey===t.activeSessionKey&&e.activeSessionPath===t.activeSessionPath&&Doe(e.directories||[],t.directories||[])&&Aoe(e.directoryStates||[],t.directoryStates||[])&&Moe(e.directoryIndexes,t.directoryIndexes)}function Noe(e,t){switch(e.type){case`text`:return e.text.trim()?`text:${e.text}`:``;case`compaction`:return`compaction:${e.tokensBefore}:${e.summary}`;case`thinking`:return t.hideThinking?``:`thinking:${e.summaryLabel||``}:${e.text}`;case`tool`:return t.hideToolBlocks?``:`tool:${e.callId||``}:${e.name||``}:${JSON.stringify(e.args??null)}:${e.output}:${JSON.stringify(e.details??null)}:${e.isError?`1`:`0`}:${e.running?`1`:`0`}`;default:return``}}function Poe(e){return e.renderKey||e.itemKey||``}function X9(e,t){let n=[];for(let r of e){let e=Poe(r);if(r.kind===`user`){n.push(`user:${e}:${r.text}:${r.queued?`1`:`0`}:${r.streamingBehavior||``}:${r.images.map(e=>`${e.mimeType}:${e.data}`).join(`,`)}`);continue}let i=r.blocks.map(e=>Noe(e,t)).filter(Boolean),a=[r.done===!1?`0`:`1`,r.model?.provider||``,r.model?.id||``].join(`:`);if(i.length===0){(r.streaming||r.done===!1||a!==`1::`)&&n.push(`assistant:${e}:${r.streaming?`1`:`0`}:${a}`);continue}n.push(`assistant:${e}:${r.streaming?`1`:`0`}:${a}:${i.join(`|`)}`)}return n.join(`
|
|
2151
|
-
`)}function Foe(e,t,n){return e===t?!0:X9(e,n)===X9(t,n)}function Z9(e,t){return e.connected===t.connected&&e.replaying===t.replaying&&e.streaming===t.streaming&&e.compacting===t.compacting&&e.draft===t.draft&&e.historyOffset===t.historyOffset&&e.historyTotalCount===t.historyTotalCount&&e.sessionId===t.sessionId&&e.sessionKey===t.sessionKey&&e.sessionName===t.sessionName&&e.firstMessage===t.firstMessage&&e.sessionFile===t.sessionFile&&e.cwd===t.cwd&&e.modified===t.modified&&e.model===t.model&&e.thinkingLevel===t.thinkingLevel&&e.availableThinkingLevels===t.availableThinkingLevels&&e.availableModels===t.availableModels&&e.availableSkills===t.availableSkills&&e.hideThinkingBlock===t.hideThinkingBlock&&e.uiRequest===t.uiRequest}function Ioe(e,t){return e.statuses===t.statuses&&e.title===t.title&&e.editorText===t.editorText}function Loe(e,t){return e===t?!1:!Z9(e,t)||!Ioe(e.uiState,t.uiState)||e.items.length===0!=(t.items.length===0)}function Roe(e,t){return!t||e.draft!==!0?!1:Kt({cwd:typeof e.cwd==`string`?e.cwd:void 0,sessionFile:typeof e.sessionFile==`string`?e.sessionFile:void 0,sessionId:typeof e.sessionId==`string`?e.sessionId:void 0})===t}function zoe(e){let t=e.previousState.sessionKey||``,n=typeof e.payload.sessionKey==`string`?e.payload.sessionKey:``;return!t.startsWith(`optimistic:`)||!n||n===t?!1:!Roe(e.payload,e.ownerKey)}function Boe(e){let t=(0,$.c)(85),{viewerContextId:n,sessionId:r,draftSessionLoadingOwnerKey:i,bootstrapSidebarDirectories:a,hideToolBlocksRef:o,sessionStore:s,sessionStateRef:c,composerTextRef:l,composerSkillRef:u,replaceComposerDraftRef:d,handleSelectSessionRef:f,pendingRouteSessionIdRef:p,pendingRouteSessionPathRef:m,setSessionState:h,setConversationItems:g,setHiddenThinkingPreview:_,setWorkingState:v,setCompactRunningState:y,setComposerContextUsage:b,setComposerStreaming:x,setSessionsEvent:S,setSessionDoneEvents:C,applySidebarSessionStatusRef:w,setComposerImages:T,setPendingMessages:E,pendingUiRequestHandlerRef:D,lastSyncedEditorTextRef:O}=e,k=re(),A=Z.useRef(r),j=Z.useRef(r),M=Z.useRef(i),N=Z.useRef(null),P=Z.useRef(!1),F=Z.useRef(null),I=Z.useRef(!1),[L,R]=Z.useState(0),z,B;t[0]===r?(z=t[1],B=t[2]):(z=()=>{j.current=r},B=[r],t[0]=r,t[1]=z,t[2]=B),Z.useEffect(z,B);let V,H;t[3]===i?(V=t[4],H=t[5]):(V=()=>{M.current=i},H=[i],t[3]=i,t[4]=V,t[5]=H),Z.useEffect(V,H);let U,W;t[6]===r?(U=t[7],W=t[8]):(U=()=>{N.current||(A.current=r)},W=[r],t[6]=r,t[7]=U,t[8]=W),Z.useEffect(U,W);let G=Ji(s,Koe),ee=Z.useRef(G),te=Z.useRef(void 0),K=Ji(s,Goe),ne,q;t[9]!==p||t[10]!==m||t[11]!==r||t[12]!==G?(ne=()=>{let e=te.current!==r;if(te.current=r,!r){p.current=void 0,m.current=void 0;return}if(r===G){p.current===r&&(p.current=void 0,m.current=void 0);return}e&&(p.current!==r&&(m.current=void 0),p.current=r)},q=[p,m,r,G],t[9]=p,t[10]=m,t[11]=r,t[12]=G,t[13]=ne,t[14]=q):(ne=t[13],q=t[14]),Z.useEffect(ne,q);let J,Y;t[15]!==k||t[16]!==n?(Y=()=>{if(!n)return;let e=()=>{F.current=Date.now(),I.current=!0},t=e=>{let t=e===void 0?!1:e;if(document.visibilityState!==`visible`)return;let n=F.current,r=n?Date.now()-n:0,i=t||I.current&&r>=woe;F.current=null,I.current=!1,i&&(A.current=j.current,R(Woe),k.invalidateQueries({refetchType:`active`}).catch(Uoe))},r=()=>{if(document.visibilityState===`hidden`){e();return}t()},i=()=>{t()},a=e=>{t(e.persisted)};return document.visibilityState===`hidden`&&e(),window.addEventListener(`blur`,e),window.addEventListener(`focus`,i),window.addEventListener(`pagehide`,e),window.addEventListener(`pageshow`,a),document.addEventListener(`visibilitychange`,r),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`focus`,i),window.removeEventListener(`pagehide`,e),window.removeEventListener(`pageshow`,a),document.removeEventListener(`visibilitychange`,r)}},J=[k,n],t[15]=k,t[16]=n,t[17]=J,t[18]=Y):(J=t[17],Y=t[18]),Z.useEffect(Y,J);let ie;t[19]!==w||t[20]!==a||t[21]!==u||t[22]!==l||t[23]!==f||t[24]!==o||t[25]!==O||t[26]!==p||t[27]!==D||t[28]!==k||t[29]!==d||t[30]!==c||t[31]!==y||t[32]!==b||t[33]!==T||t[34]!==x||t[35]!==g||t[36]!==_||t[37]!==E||t[38]!==C||t[39]!==h||t[40]!==S||t[41]!==v||t[42]!==n?(ie=()=>{if(!n)return;P.current=!1;let e=new xo(e=>{let t=new Map;for(let n of e){let e=t.get(n.cwd)??new Set;for(let t of n.scopes)e.add(t);t.set(n.cwd,e)}let r=[];for(let[e,i]of t)i.has(`status`)&&r.push(k.invalidateQueries({queryKey:_g.gitStatus(n,e),exact:!0,refetchType:`active`})),i.has(`files`)&&r.push(k.invalidateQueries({queryKey:_g.gitFiles(n,e),exact:!0,refetchType:`active`}),k.invalidateQueries({queryKey:_g.projectFileTree(n,e),exact:!0,refetchType:`active`}),k.invalidateQueries({queryKey:_g.gitFileReviews(n,e),exact:!1,refetchType:`active`})),i.has(`refs`)&&r.push(k.invalidateQueries({queryKey:_g.gitBranches(n,e),exact:!0,refetchType:`active`}),k.invalidateQueries({queryKey:_g.gitCommits(n,e),exact:!1,refetchType:`active`}));Promise.all(r).catch(Hoe)},{key:`pico.git.invalidations`,wait:100}),t=new EventSource(Ch(`/events`,{contextId:n,sessionId:A.current,searchParams:{sidebarDirectory:a}}));return N.current=t,t.onopen=()=>{if(N.current!==t)return;let e=c.current;if(e.connected)return;let n={...e,connected:!0};c.current=n,g(n.items),h(n)},t.onerror=()=>{if(N.current!==t)return;let e=c.current;if(!e.connected)return;let n={...e,connected:!1};c.current=n,g(n.items),h(n)},t.onmessage=n=>{if(N.current!==t)return;let r=JSON.parse(n.data);if(lh(r)){P.current=!0;let e=c.current;if(zoe({ownerKey:M.current,payload:r,previousState:e}))return;let t=l.current;We(e,Xx({text:t,skillName:u.current}));let n=e.uiState.editorText||``,i=Oh(e,r),a=Kt(i)!==Kt(e),s=j.current,m=M.current,C=i.draft&&!i.sessionKey?.startsWith(`optimistic:`),D=e.draft&&e.sessionKey?.startsWith(`optimistic:`),k=m?Kt(i)===m:!1,A=!!(s&&!p.current&&C&&(k||D)),N=!a&&t!==n,F=N?t:we(i)??i.uiState.editorText??``;Mi(()=>{c.current=i,_(i.hiddenThinkingPreview||``,{preserveExisting:!!(e.streaming&&i.streaming&&!i.hiddenThinkingPreview)}),e.contextUsage!==i.contextUsage&&b(i.contextUsage);let t=e.sessionKey!==i.sessionKey||e.sessionId!==i.sessionId||e.sessionFile!==i.sessionFile;e.streaming!==i.streaming&&x(i.streaming),(t||e.compacting!==i.compacting)&&y(i.compacting),(t||e.streaming||i.streaming||e.compacting||i.compacting)&&v(i.compacting?{label:Toe,cancelable:!0}:i.streaming?{label:i.uiState.workingMessage||`Working…`}:null),(t||!Foe(e.items,i.items,{hideThinking:i.hideThinkingBlock,hideToolBlocks:o.current}))&&g(i.items),Loe(e,i)&&h(i),(e.sessionKey!==i.sessionKey||e.sessionId!==i.sessionId||e.sessionFile!==i.sessionFile||e.streaming!==i.streaming)&&w.current({type:`session_status`,sessionKey:i.sessionKey,sessionId:i.sessionId,sessionPath:i.sessionFile,streaming:i.streaming,unread:!1}),a&&S(e=>{if(!e)return e;let t={...e,activeSessionId:i.sessionId,activeSessionKey:i.sessionKey,activeSessionPath:i.sessionFile};return Y9(e,t)?e:t}),a&&T(Voe),A&&f.current(void 0,{replace:!0}),N||d.current(F,i),O.current=i.uiState.editorText||``;let n=Eoe(r);n&&E(e=>koe(e,n)?e:n)});return}if(uh(r)){S(e=>Y9(e,r)?e:r);return}if(dh(r)){w.current(r);return}if(fh(r)){C(e=>e.some(e=>e.id===r.id)?e:[...e,r]);return}if(ph(r)){let t=r.cwd.trim();t&&e.addItem({cwd:t,scopes:new Set(r.scopes??[`status`,`files`,`refs`])});return}if(r.type===`request_error`){Qe.error(r.error||`Request failed`);return}if(r.type===`extension_error`){Qe.error(r.error||`Extension error`);return}if(r.type===`extension_ui_request`){if(r.method===`notify`){let e=r.message||`Notification`;r.notifyType===`success`?Qe.success(e):r.notifyType===`warning`?Qe.warning(e):r.notifyType===`error`?Qe.error(e):Qe.info(e);return}D.current(r)}},()=>{N.current===t&&(N.current=null),t.close(),e.flush(),e.cancel(),e.clear()}},t[19]=w,t[20]=a,t[21]=u,t[22]=l,t[23]=f,t[24]=o,t[25]=O,t[26]=p,t[27]=D,t[28]=k,t[29]=d,t[30]=c,t[31]=y,t[32]=b,t[33]=T,t[34]=x,t[35]=g,t[36]=_,t[37]=E,t[38]=C,t[39]=h,t[40]=S,t[41]=v,t[42]=n,t[43]=ie):ie=t[43];let ae;t[44]!==w||t[45]!==a||t[46]!==u||t[47]!==l||t[48]!==L||t[49]!==O||t[50]!==D||t[51]!==k||t[52]!==d||t[53]!==c||t[54]!==y||t[55]!==b||t[56]!==T||t[57]!==x||t[58]!==g||t[59]!==_||t[60]!==E||t[61]!==C||t[62]!==h||t[63]!==S||t[64]!==v||t[65]!==n?(ae=[a,u,l,O,w,k,d,c,T,_,v,y,b,x,g,E,D,C,h,S,n,L],t[44]=w,t[45]=a,t[46]=u,t[47]=l,t[48]=L,t[49]=O,t[50]=D,t[51]=k,t[52]=d,t[53]=c,t[54]=y,t[55]=b,t[56]=T,t[57]=x,t[58]=g,t[59]=_,t[60]=E,t[61]=C,t[62]=h,t[63]=S,t[64]=v,t[65]=n,t[66]=ae):ae=t[66],Z.useEffect(ie,ae);let oe,se;t[67]===G?(oe=t[68],se=t[69]):(oe=()=>{ee.current=G},se=[G],t[67]=G,t[68]=oe,t[69]=se),Z.useEffect(oe,se);let ce,le;t[70]!==i||t[71]!==p||t[72]!==m||t[73]!==r||t[74]!==n?(ce=()=>{if(!n||!r||i||!P.current||r===ee.current||p.current!==r)return;let e=new AbortController,t=m.current;return wh(Ch(`/api/session/select`,{contextId:n,sessionId:r,searchParams:{sessionPath:t}}),{method:`POST`,signal:e.signal}).catch(t=>{e.signal.aborted||Qe.error(t instanceof Error?t.message:`Failed to select session`)}),()=>{e.abort()}},le=[i,p,m,n,r],t[70]=i,t[71]=p,t[72]=m,t[73]=r,t[74]=n,t[75]=ce,t[76]=le):(ce=t[75],le=t[76]),Z.useEffect(ce,le);let ue,de;t[77]!==f||t[78]!==p||t[79]!==m||t[80]!==r||t[81]!==K||t[82]!==G?(ue=()=>{if(K||!G)return;let e=p.current;if(e){G===e&&(p.current=void 0,m.current=void 0);return}G!==r&&f.current(G,{replace:!0})},de=[f,p,m,r,K,G],t[77]=f,t[78]=p,t[79]=m,t[80]=r,t[81]=K,t[82]=G,t[83]=ue,t[84]=de):(ue=t[83],de=t[84]),Z.useEffect(ue,de)}function Voe(e){return e.length===0?e:[]}function Hoe(){}function Uoe(){}function Woe(e){return e+1}function Goe(e){return e.draft}function Koe(e){return e.sessionId}var qoe=500;function Q9(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return e.isContentEditable||t===`input`||t===`textarea`||e.closest(`[contenteditable="true"]`)!==null}function $9(e){return e instanceof HTMLTextAreaElement&&e.name===`prompt`}function Joe(e){if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)return e.selectionStart!==e.selectionEnd;if(e instanceof HTMLElement){let e=window.getSelection();return!!(e&&String(e).trim())}return!1}function Yoe(e){let t=(0,$.c)(34),{addDirectoryOpenRef:n,commandPaletteOpenRef:r,compactRunningRef:i,deleteOpenRef:a,forkOpenRef:o,gitCommitOpenRef:s,pendingUiRequestOpenRef:c,renameOpenRef:l,sessionSearchInputRef:u,sessionsOpenRef:d,settingsOpenRef:f,shortcutActionsRef:p,shortcutStateRef:m,treeOpenRef:h}=e,g=Z.useRef(0),_,v,y,b,x,S,C;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==o||t[5]!==s||t[6]!==c||t[7]!==l||t[8]!==u||t[9]!==d||t[10]!==f||t[11]!==p||t[12]!==m||t[13]!==h){let e=e=>{let t=m.current,i=r.current,p=n.current||l.current||a.current||o.current||s.current||h.current||d.current||f.current||c.current,g=document.activeElement,_=g instanceof HTMLElement&&g.closest(`[data-conversation-viewport="true"]`)!==null,v=g instanceof HTMLElement?g.dataset.sessionKey?.trim()??``:``,y=v?t.sidebarSessionEntriesByKey.get(v):void 0,b=e.target instanceof HTMLInputElement&&e.target===u.current;return{...t,activeElement:g,activeElementIsConversationViewport:_,blockingModalOpen:p,commandPaletteOpen:i,focusedSidebarSession:y,modalOpen:p||i,targetIsSessionSearch:b}},w=e=>{e&&p.current.closeCommandPalette()},T=t=>{let n=e(t);if(t.repeat||n.modalOpen||t.defaultPrevented)return;let r=Date.now();if(r-g.current<=qoe){g.current=0,t.preventDefault(),p.current.openTreeDialog();return}if(g.current=r,i.current){t.preventDefault(),p.current.abortCompact();return}n.sessionIsStreaming&&!Q9(t.target)&&(t.preventDefault(),p.current.abortSession())},E=t=>{let n=e(t);if(n.modalOpen||Q9(t.target)&&!n.targetIsSessionSearch||n.activeElementIsConversationViewport)return;let r=Array.from(document.querySelectorAll(`[data-sidebar-session-item]`)),i=n.activeElement instanceof HTMLElement?n.activeElement.closest(`[data-sidebar-session-item]`):null;if(r.length===0)return;let a=i?r.findIndex(e=>e===i):-1,o=t.key===`Home`?0:t.key===`End`?r.length-1:a>=0?Math.max(0,Math.min(r.length-1,a+(t.key===`ArrowDown`?1:-1))):t.key===`ArrowUp`?r.length-1:0;t.preventDefault(),r[o]?.focus()},D=t=>{let n=e(t);if(n.modalOpen||Q9(t.target)&&!n.targetIsSessionSearch)return;let r=n.selectedSidebarSessions.length>0?n.selectedSidebarSessions:n.focusedSidebarSession?.path?[n.focusedSidebarSession]:[];r.length!==0&&(t.preventDefault(),p.current.openDeleteDialog(r))},O=t=>{let n=e(t);n.blockingModalOpen||t.defaultPrevented||(t.preventDefault(),w(n.commandPaletteOpen),p.current.focusPrompt())},k=t=>{let n=e(t);if(!(n.currentTab!==`session`||n.modalOpen||t.defaultPrevented||Q9(t.target)&&!$9(t.target))){if(t.preventDefault(),t.key===`ArrowLeft`){p.current.jumpToPreviousMessage();return}if(t.key===`ArrowRight`){p.current.jumpToNextMessage();return}if(t.key===`ArrowUp`){p.current.scrollConversationToTop();return}p.current.scrollConversationToBottom()}};_=t=>{let n=t.altKey&&t.code.startsWith(`Key`)?t.code.slice(3).toLowerCase():t.key.toLowerCase(),r=e(t);if(!r.blockingModalOpen){if(n===`\\`){t.preventDefault(),w(r.commandPaletteOpen),p.current.toggleGitPanel();return}if(n===`k`){t.preventDefault(),p.current.openCommandPalette();return}if(n===`p`){if(t.preventDefault(),w(r.commandPaletteOpen),t.altKey){p.current.pullGitChanges();return}if(t.shiftKey){p.current.forcePushGitChanges();return}p.current.pushGitChanges();return}if(n===`n`){t.preventDefault(),w(r.commandPaletteOpen),p.current.createSession();return}if(n===`s`){t.preventDefault(),w(r.commandPaletteOpen),p.current.openSessionsDialog();return}if(n===`e`){if(!r.sessionHasFile)return;t.preventDefault(),w(r.commandPaletteOpen),p.current.openRenameDialog();return}if(n===`f`){t.preventDefault(),w(r.commandPaletteOpen),p.current.openForkDialog();return}if(n===`d`){t.preventDefault(),w(r.commandPaletteOpen),p.current.openAddDirectoryDialog();return}if(n===`,`){t.preventDefault(),w(r.commandPaletteOpen),p.current.openSettingsDialog();return}if(n===`m`){if(!r.sessionHasAvailableModels&&!r.commandPaletteOpen)return;t.preventDefault(),w(r.commandPaletteOpen),p.current.focusModelSelector();return}if(n===`t`){t.preventDefault(),w(r.commandPaletteOpen),p.current.toggleHideThinking();return}if(n===`r`){t.preventDefault(),w(r.commandPaletteOpen),p.current.cycleThinkingLevel(t.shiftKey?-1:1);return}if(n===`o`){t.preventDefault(),w(r.commandPaletteOpen),p.current.toggleHideToolBlocks();return}if(n===`c`){if(!r.commandPaletteOpen&&Joe(t.target))return;t.preventDefault(),w(r.commandPaletteOpen),p.current.openCommitDialog();return}if(n===`x`){if(Q9(t.target)&&!$9(t.target)||!r.sessionHasFile)return;t.preventDefault(),w(r.commandPaletteOpen),p.current.openDeleteDialogForCurrentSession()}}},v={hotkey:`Escape`,callback:T,options:{meta:{name:`Abort active session`,description:`Abort compaction or the streaming assistant response.`}}},y=[{key:`ArrowDown`},{key:`ArrowUp`},{key:`Home`},{key:`End`},{key:`ArrowDown`,shift:!0},{key:`ArrowUp`,shift:!0},{key:`Home`,shift:!0},{key:`End`,shift:!0}].map(e=>({hotkey:e,callback:E,options:{meta:{name:`Move sidebar focus`,description:`Move keyboard focus through sidebar sessions.`}}})),b=[`Delete`,`Backspace`].map(e=>({hotkey:e,callback:D,options:{meta:{name:`Delete selected sidebar sessions`,description:`Open the delete dialog for focused or selected sessions.`}}})),x={hotkey:{key:`Enter`,ctrl:!0},callback:O,options:{meta:{name:`Focus prompt`,description:`Focus the prompt composer.`}}},S=[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`].map(e=>({hotkey:{key:e,ctrl:!0},callback:k,options:{meta:{name:`Navigate conversation`,description:`Jump between messages or to conversation boundaries.`}}})),C=[{key:`\\`},{key:`K`},{key:`P`},{key:`P`,shift:!0},{key:`N`},{key:`S`},{key:`E`},{key:`F`},{key:`D`},{key:`,`},{key:`M`},{key:`T`},{key:`R`},{key:`R`,shift:!0},{key:`V`},{key:`O`},{key:`C`},{key:`X`}].map(e=>({hotkey:{...e,ctrl:!0},callback:_,options:{meta:{name:`App shell shortcut`,description:`Run a Pico app shell command.`}}})),t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=_,t[15]=v,t[16]=y,t[17]=b,t[18]=x,t[19]=S,t[20]=C}else _=t[14],v=t[15],y=t[16],b=t[17],x=t[18],S=t[19],C=t[20];let w;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(w={key:`P`,alt:!0},t[21]=w):w=t[21];let T;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(T={meta:{name:`App shell shortcut`,description:`Run a Pico app shell command.`}},t[22]=T):T=t[22];let E;t[23]===_?E=t[24]:(E={hotkey:w,callback:_,options:T},t[23]=_,t[24]=E);let D;t[25]!==v||t[26]!==y||t[27]!==b||t[28]!==x||t[29]!==S||t[30]!==C||t[31]!==E?(D=[v,...y,...b,x,...S,...C,E],t[25]=v,t[26]=y,t[27]=b,t[28]=x,t[29]=S,t[30]=C,t[31]=E,t[32]=D):D=t[32];let O=D,k;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(k={conflictBehavior:`allow`,ignoreInputs:!1,preventDefault:!1,stopPropagation:!1},t[33]=k):k=t[33],Gi(O,k)}var Xoe=6,Zoe=Z.forwardRef(function({viewerContextId:e,sessionId:t,onSelectSession:n,sidebar:r,sidebarStore:i,sessionSearchInputRef:a},s){let c=re(),l=Z.useRef(null);l.current||=pn();let d=Z.useRef(null);d.current||=Lg(l.current);let f=d.current,p=Z.useRef(f.state),h=Z.useRef(null);h.current||=Lg({currentTab:`session`,gitPanelOpen:!1,initialLoadingSessionId:t||null,loadingSessionId:null},Pg);let g=h.current,_=Z.useRef(null);_.current||=Lg(sie());let v=_.current,y=Z.useCallback(e=>{Bg(g,`currentTab`,e)},[g]),b=Z.useCallback(e=>{let t=Rg(g.state.gitPanelOpen,e);Bg(g,`gitPanelOpen`,t),ee(Xn,t?`1`:`0`)},[g]),x=Z.useCallback(e=>{Bg(g,`loadingSessionId`,e)},[g]),S=Z.useCallback(e=>{Bg(g,`initialLoadingSessionId`,e)},[g]),C=Z.useRef(t),w=Z.useRef(null);w.current||=Lg({text:``,syncNonce:0});let T=w.current,D=Z.useRef(null);D.current||=Lg([]);let O=D.current,k=Z.useRef([]),A=Z.useRef(null);A.current||=Lg({autoScrollEnabled:!0,centerMessages:!1,hideToolBlocks:!1},Pg);let j=A.current,M=Z.useRef(j.state),N=Z.useRef(j.state.hideToolBlocks),F=Z.useCallback(e=>{let t=j.state,n=Rg(t.hideToolBlocks,e);if(n===t.hideToolBlocks)return;let r={...t,hideToolBlocks:n};M.current=r,N.current=r.hideToolBlocks,zg(j,r)},[j]),I=Z.useCallback(e=>{let t=j.state,n=Rg(t.centerMessages,e);if(n===t.centerMessages)return;let r={...t,centerMessages:n};M.current=r,zg(j,r)},[j]),L=Z.useCallback(e=>{let t=j.state,n=Rg(t.autoScrollEnabled,e);if(n===t.autoScrollEnabled)return;let r={...t,autoScrollEnabled:n};M.current=r,zg(j,r)},[j]),z=Z.useRef(null);z.current||=Lg(!1);let B=z.current,V=Z.useRef(null);V.current||=Lg(null);let H=V.current,U=Z.useRef(null);U.current||=Lg([]);let W=U.current,G=Z.useRef(null);G.current||=Lg(!1);let te=G.current,K=Z.useRef(null);K.current||=Lg([]);let ne=K.current,q=Z.useRef(null);q.current||=Lg({desktopNotificationPermission:`unsupported`,sessionDoneDesktopNotificationsEnabled:!0,sessionDoneEvents:[],sessionDoneSoundEnabled:!0},Pg);let J=q.current,Y=Z.useCallback(e=>{Bg(J,`sessionDoneEvents`,e)},[J]),ae=Z.useCallback(e=>{Bg(J,`sessionDoneSoundEnabled`,e)},[J]),oe=Z.useCallback(e=>{Bg(J,`sessionDoneDesktopNotificationsEnabled`,e)},[J]),se=Z.useCallback(e=>{Bg(J,`desktopNotificationPermission`,e)},[J]),le=Z.useRef(null);le.current||=Lg({draftSessionLoadingOwnerKey:null,storedDraftDirectory:``},Pg);let de=le.current,pe=Z.useCallback(e=>{Bg(de,`draftSessionLoadingOwnerKey`,e)},[de]),me=Z.useCallback(e=>{Bg(de,`storedDraftDirectory`,e)},[de]),he=Z.useRef(null);he.current||=Lg([],Ag);let ge=he.current,_e=Z.useCallback(e=>{let t=ge.state,n=Rg(t,e);n!==t&&zg(ge,n)},[ge]),{isMobile:ve,openMobile:ye,openMobileSettled:be,setOpenMobile:xe}=Uc(),Se=Z.useRef(null),Ce=Z.useRef(null),we=Z.useRef(null);we.current||=Lg(soe(e),ooe);let Te=we.current,Ee=Z.useRef(null);Ee.current||=Lg(void 0);let De=Ee.current,Oe=Z.useRef(null);Oe.current||=new wo(e=>{zg(De,e)},{key:`pico.composer.context-usage`,wait:250,leading:!0,trailing:!0});let ke=Oe.current;Z.useEffect(()=>()=>{ke.flush(),ke.cancel()},[ke]);let Ae=Z.useCallback(e=>{let t=T.state,n=Rg(t,e);n!==t&&Mi(()=>{zg(T,n);let e=Te.state;zg(Te,{...e,composerSkill:e.disabled?void 0:n.skillName,composerSyncNonce:n.syncNonce,composerText:e.disabled?``:n.text})})},[T,Te]),je=Z.useCallback(e=>{let t=O.state,n=Rg(t,e);n!==t&&(k.current=n,Mi(()=>{zg(O,n);let e=Te.state;zg(Te,{...e,composerImages:e.disabled?[]:n})}))},[O,Te]),Ne=Z.useCallback(e=>{ke.maybeExecute(e)},[ke]),Pe=Z.useCallback(e=>{let t=Te.state;zg(Te,{...t,isStreaming:t.disabled?!1:e})},[Te]),Fe=Z.useRef(null),Ie=Z.useRef(!1),Le=Z.useRef(null),Re=Z.useRef(!1),ze=Z.useRef(null),Ve=Z.useRef(!1),He=Z.useRef(null),Ue=Z.useRef(!1),Ge=Z.useRef(null),Ke=Z.useRef(!1),qe=Z.useRef(null),Je=Z.useRef(!1),Ye=Z.useRef(null),Xe=Z.useRef(!1),Ze=Z.useRef(null),$e=Z.useRef(!1),et=Z.useRef(null),tt=Z.useRef(!1),nt=Z.useRef(null),rt=Z.useRef(!1),it=Z.useRef(null),at=Z.useRef(!1),st=Z.useRef(null),ct=Z.useRef(!1),lt=Z.useRef(null),ut=Z.useRef(``),dt=Z.useCallback(e=>{let t=p.current,n=typeof e==`function`?e(t):e,r=f.state;Object.is(t,n)&&Object.is(r,n)||(p.current=n,zg(f,n))},[f]),ft=Z.useRef(T.state.text),pt=Z.useRef(T.state.skillName),mt=Z.useRef(void 0),ht=Z.useRef(void 0),gt=Z.useRef(e=>{});gt.current=e=>{st.current?.open(e)};let _t=Z.useRef(new Set),vt=Z.useRef(!1),yt=Z.useRef(null);yt.current||=qq(p.current.items);let bt=yt.current,St=Z.useRef(null);St.current||=Lg(p.current.hiddenThinkingPreview||``);let Ct=St.current,wt=Z.useRef(null);wt.current||=Lg(null,poe);let Tt=wt.current,Et=Z.useRef(!1),Dt=Z.useRef(!1),Ot=Z.useCallback(e=>{Et.current=e,e&&(Dt.current=!1)},[]),At=Z.useCallback(e=>{let t=B.state,n=Rg(t,e);n!==t&&Mi(()=>{zg(B,n);let e=Te.state;zg(Te,{...e,awaitingFirstTurn:e.disabled?!1:n}),n&&!p.current.streaming?zg(Tt,{label:`Waiting for first response…`}):!n&&Tt.state?.label===`Waiting for first response…`&&zg(Tt,null)})},[B,Te,Tt]),jt=Z.useCallback(e=>{let t=te.state,n=Rg(t,e);n!==t&&Mi(()=>{zg(te,n);let e=Te.state;zg(Te,{...e,isSubmitting:e.disabled?!1:n})})},[Te,te]),Mt=Z.useCallback(()=>{let e=W.state.map((e,t)=>({pendingId:e.optimisticId||`pending-draft:${t}`,text:e.message,images:e.images,streamingBehavior:e.streamingBehavior})),t=Te.state;zg(Te,{...t,currentPendingMessages:t.disabled?[]:[...e,...ne.state]})},[Te,W,ne]),Pt=Z.useCallback(e=>{let t=H.state,n=Rg(t,e);n!==t&&Mi(()=>{zg(H,n),n?zg(Tt,{label:`Waiting for new session…`}):Tt.state?.label===`Waiting for new session…`&&zg(Tt,null)})},[H,Tt]),Ft=Z.useCallback(e=>{let t=W.state,n=Rg(t,e);n!==t&&Mi(()=>{zg(W,n),Mt()})},[W,Mt]),It=Z.useCallback(e=>{let t=ne.state,n=Rg(t,e);n!==t&&Mi(()=>{zg(ne,n),Mt()})},[ne,Mt]),Rt=Z.useRef(null);Rt.current||=moe({key:`pico.conversation.streaming-items`,wait:16,onLatest:e=>{bt.setItems(e)}});let zt=Rt.current,Bt=Z.useCallback(e=>{if(e.some(e=>e.kind===`assistant`&&e.streaming)&&typeof window<`u`){zt.add(e);return}zt.cancel(),bt.setItems(e)},[zt,bt]);Z.useEffect(()=>()=>{zt.flush(),zt.cancel()},[zt]);let Vt=Z.useCallback((e,t)=>{t?.preserveExisting&&!e||zg(Ct,e)},[Ct]),Ht=Z.useCallback(e=>{zg(Tt,e)},[Tt]),Ut=Z.useCallback(e=>{let t=coe(),n={kind:`user`,itemKey:`pending:${t}`,pendingId:t,text:e.message,images:e.images.map(e=>({...e})),queued:e.queued,streamingBehavior:e.streamingBehavior},r=p.current,i=loe(r.items,n);if(i!==r.items){let e={...r,items:i};p.current=e,bt.setItems(i),dt(e)}return t},[bt]),Wt=Z.useCallback(e=>{if(!e)return;let t=p.current,n=uoe(t.items,e);if(n===t.items)return;let r={...t,items:n};p.current=r,bt.setItems(n),dt(r)},[bt]),{setTheme:Gt,theme:qt}=ue(),Jt=o(qt),{initialLoadingSessionId:Yt,loadingSessionId:Zt}=Ji(g,e=>({initialLoadingSessionId:e.initialLoadingSessionId,loadingSessionId:e.loadingSessionId}),{compare:Pg}),{draftSessionLoadingOwnerKey:Qt,storedDraftDirectory:$t}=Ji(de),en=Ji(f,e=>({cwd:e.cwd,draft:e.draft,sessionFile:e.sessionFile,sessionId:e.sessionId,sessionKey:e.sessionKey}),{compare:Pg}),tn=Z.useCallback(e=>{let t=e.draft?``:e.sessionId?.trim()||``,n=e.draft?``:(e.sessionFile||e.sessionPath||``).trim(),r=e.draft?``:Dg({sessionFile:n,sessionId:t})||e.sessionKey?.trim()||``;i.setSidebarState(e=>e.activeSidebarSessionId===t&&e.activeSidebarSessionKey===r&&e.activeSidebarSessionPath===n?e:{activeSidebarSessionId:t,activeSidebarSessionKey:r,activeSidebarSessionPath:n})},[i]);Z.useLayoutEffect(()=>{tn(en)},[en,tn]);let nn=Ji(g,e=>e.gitPanelOpen),rn=(e,t)=>{e&&Mi(()=>{b(!0),lie(v,e,t)})},on=e=>{uie(v,e)},sn=e=>{die(v,e)},cn=e=>{fie(v,e)},X=()=>{pie(v)},ln=e=>{mie(v,e)},un=()=>{let e=v.state.activeTab;if(ve){X7(v,`review`),y(t=>t===`git`&&e===`review`?`session`:`git`);return}if(nn&&e===`review`){b(!1);return}Mi(()=>{X7(v,`review`),b(!0)})};Z.useEffect(()=>{Q7(v)},[v,en.cwd]),Z.useEffect(()=>{en.draft&&Q7(v)},[v,en.draft]),i_(i,e=>e.derived.workspaceVersion);let{baseSidebarDirectories:dn,directoryStateByPath:fn,directoryIndexes:mn,sidebarSessions:hn,selectedSidebarSessions:gn,sidebarSessionEntriesByKey:_n}=i.getWorkspaceSnapshot(),vn=i_(i,e=>e.state.sessionsEvent?.directories||[],Ag),yn=Z.useRef(e=>{i.setSidebarSessionStatusByKey(t=>Zg(t,e))});yn.current=e=>{i.setSidebarSessionStatusByKey(t=>Zg(t,e))};let bn=en.sessionId||(en.sessionKey?void 0:t),Sn=xn({path:en.sessionFile,id:bn}),Cn=i_(i,e=>Sn?e.state.pinnedSidebarSessionKeys.includes(Sn):!1),wn=ate(en),En=Z.useRef(``);Z.useLayoutEffect(()=>{En.current!==wn&&(En.current=wn,ke.cancel(),zg(De,p.current.contextUsage))},[De,ke,wn]);let Dn=Yt&&!en.sessionKey?Yt:null,On=Zt&&Zt!==en.sessionId?Zt:Dn&&Dn!==en.sessionId?Dn:null,kn=!!On,An=On?hn.find(e=>e.id===On):void 0,jn=Tn(An),Mn=jn===`New session`?`Loading session…`:jn,Nn=kn?An?.cwd:en.cwd;Z.useEffect(()=>{let e=C.current;if(C.current=t,e!==t){if(y(e=>e===`git`?`session`:e),!t){S(null),x(null);return}p.current.sessionId!==t&&x(t)}},[t]),Z.useEffect(()=>{ve||y(e=>e===`git`?`session`:e)},[ve,y]);let Pn=(e,t=p.current)=>{let n=Yx(e),r=n.matched?n.text:e,i=n.matched?n.skillName:void 0;ft.current=r,pt.current=i;let a=T.state;(a.text!==r||a.skillName!==i)&&zg(T,{...a,text:r,skillName:i}),We(t,Xx({text:r,skillName:i}))},Fn=(e,t=p.current,n)=>{let r=Yx(e),i=r.matched?r.text:e,a=r.matched?r.skillName:void 0;ft.current=i,pt.current=a,Ae(e=>{let t=e.text===i&&e.skillName===a,r=n?.forceSync===!0;return t&&!r?e:{text:i,skillName:a,syncNonce:r?e.syncNonce+1:e.syncNonce}}),We(t,Xx({text:i,skillName:a}))},In=Mg(Fn);Z.useEffect(()=>{b(u()),me(E()||``),ae(P()),oe(Be()),F(R()),I(ce()),L(ie()),_e(eee()),se(Kae())},[]);let Ln=()=>{et.current?.close(),nt.current?.close(),Fe.current?.open()},Rn=()=>{Fe.current?.close()},zn=()=>{Fe.current?.close(),nt.current?.close(),et.current?.open()},Bn=()=>{Fe.current?.close(),et.current?.close(),nt.current?.open()},Vn=()=>{Fe.current?.close(),et.current?.close(),nt.current?.close(),Ze.current?.open()},Hn=async t=>{await Promise.all([c.invalidateQueries({queryKey:_g.gitStatus(e,t),exact:!0,refetchType:`active`}),c.invalidateQueries({queryKey:_g.gitFiles(e,t),exact:!0,refetchType:`active`}),c.invalidateQueries({queryKey:_g.gitBranches(e,t),exact:!0,refetchType:`active`}),c.invalidateQueries({queryKey:_g.gitCommits(e,t),exact:!1,refetchType:`active`}),c.invalidateQueries({queryKey:_g.projectFileTree(e,t),exact:!0,refetchType:`active`}),c.invalidateQueries({queryKey:_g.gitFileReviews(e,t),exact:!1,refetchType:`active`})])},Un=Nr({mutationKey:_g.gitAction(e,p.current.cwd?.trim()||``,`push`),mutationFn:async t=>await wh(Ch(`/api/git-push`,{contextId:e}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({cwd:t})}),onSuccess:async(e,t)=>{await Hn(t),Fq({response:e})},onError:e=>{Qe.error(e instanceof Error?e.message:`Failed to push`)}}),Wn=Nr({mutationKey:_g.gitAction(e,p.current.cwd?.trim()||``,`force-push`),mutationFn:async t=>await wh(Ch(`/api/git-push`,{contextId:e}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({cwd:t,force:!0})}),onSuccess:async(e,t)=>{await Hn(t),Fq({response:e,force:!0})},onError:e=>{Qe.error(e instanceof Error?e.message:`Failed to force push`)}}),Gn=Nr({mutationKey:_g.gitAction(e,p.current.cwd?.trim()||``,`pull`),mutationFn:async t=>await wh(Ch(`/api/git-pull`,{contextId:e}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({cwd:t})}),onSuccess:async(e,t)=>{await Hn(t),Qe.success(`Pulled changes`)},onError:e=>{Qe.error(e instanceof Error?e.message:`Failed to pull`)}}),qn=async e=>{let t=p.current.cwd?.trim()||``;if(!t){Qe.error(`Open a session in a repository before running Git actions.`);return}let n=e===`pull`?Gn:e===`force-push`?Wn:Un;Un.isPending||Wn.isPending||Gn.isPending||await n.mutateAsync(t).catch(()=>{})},Jn=async()=>{await qn(`push`)},Yn=async()=>{await qn(`force-push`)},Zn=async()=>{await qn(`pull`)},Qn=()=>{if(ve){y(e=>e===`git`?`session`:`git`);return}b(e=>!e)},$n=()=>{let e=p.current;e.sessionFile&&ze.current?.open({path:e.sessionFile,title:e.sessionName||Fg(e)})},er=e=>{ze.current?.openForEntry(e)},tr=e=>{He.current?.open(e)},nr=e=>{Ge.current?.open(e)},rr=()=>{let e=p.current;e.sessionFile&&tr([{path:e.sessionFile,id:e.sessionId,title:Fg(e),name:e.sessionName,modified:e.modified}])},ir=()=>{Le.current?.open()},ar=async()=>{await qe.current?.open()},or=async()=>{await Ye.current?.open()},sr=()=>{zn()},cr=()=>{if(g.state.currentTab!==`session`&&y(`session`),ve&&(ye||be)){vt.current=!0,ye&&xe(!1);return}window.requestAnimationFrame(()=>{Ce.current?.focusPrompt({preventScroll:!0})})},lr=()=>{Ce.current?.openModelPicker()},ur=Mg(cr),[dr,fr]=Z.useState({sessionId:``,nonce:0}),pr=Z.useRef(null);Z.useEffect(()=>{if(!vt.current||ye||be)return;vt.current=!1;let e=window.setTimeout(()=>{ur.current()},0);return()=>{window.clearTimeout(e)}},[ur,ye,be]),Z.useEffect(()=>{if(kn)return;let e=en.sessionKey||en.sessionId||`draft`;pr.current!==e&&(pr.current=e,ur.current())},[ur,kn,en.sessionId,en.sessionKey]),Z.useEffect(()=>{if(!dr.nonce||kn||dr.sessionId&&en.sessionId!==dr.sessionId)return;let e=window.setTimeout(()=>{ur.current()},50);return()=>{window.clearTimeout(e)}},[ur,kn,dr,en.sessionId]);let mr=e=>{ae(e),ee(Kn,e?`1`:`0`),e&&j9()},hr=async e=>{if(oe(e),ee(m,e?`1`:`0`),!e)return;let t=await qae();se(t),t===`denied`?Qe.info(`Allow notifications for this site in your browser to receive desktop alerts.`):t===`unsupported`&&Qe.error(`Desktop notifications are unavailable in this browser.`)},gr=Z.useCallback((e,t)=>{let n=e?ote(i.state.derived.sidebarSessionEntriesByKey,{sessionId:e,sessionPath:t?.sessionPath}):``;i.setSelectedSidebarSessionKeys(e=>n?Ag(e,[n])?e:[n]:e.length===0?e:[]),i.setSidebarSessionSelectionAnchor(e=>e===n?e:n)},[i]),_r=Z.useCallback((e,t)=>{y(e=>e===`git`?`session`:e),gr(e,t),tn({draft:!e,sessionId:e,sessionPath:t?.sessionPath}),mt.current=e,ht.current=t?.sessionPath?.trim()||void 0,e&&fr(t=>({sessionId:e,nonce:t.nonce+1})),x(t=>e?!p.current.draft&&p.current.sessionId===e?t:e:null),n?.(e,t)},[n,p,tn,gr]),vr=Mg(_r);Boe({viewerContextId:e,sessionId:t,draftSessionLoadingOwnerKey:Qt,bootstrapSidebarDirectories:i.state.state.initialSidebarBootstrapDirectories,hideToolBlocksRef:N,sessionStore:f,sessionStateRef:p,composerTextRef:ft,composerSkillRef:pt,replaceComposerDraftRef:In,handleSelectSessionRef:vr,pendingRouteSessionIdRef:mt,pendingRouteSessionPathRef:ht,setSessionState:dt,setConversationItems:Bt,setHiddenThinkingPreview:Vt,setWorkingState:Ht,setCompactRunningState:Ot,setComposerContextUsage:Ne,setComposerStreaming:Pe,setSessionsEvent:i.setSessionsEvent,setSessionDoneEvents:Y,applySidebarSessionStatusRef:yn,setComposerImages:je,setPendingMessages:It,pendingUiRequestHandlerRef:gt,lastSyncedEditorTextRef:ut}),Z.useEffect(()=>{let e=en.cwd?.trim();e&&(ee(an,e),me(e))},[en.cwd]),Z.useEffect(()=>{let e=en.cwd?.trim(),n=en.sessionId?.trim();if(!t||!n||en.draft||!e||n!==t)return;let r=`${n}\n${e}`;_t.current.has(r)||(_t.current.add(r),i.setSidebarDirectories(t=>{let n=Xt(t);if(n.includes(e))return t;let r=Xt([e,...n]);return ee(Me,JSON.stringify(r)),r}))},[t,en.cwd,en.draft,en.sessionId,i]);let yr=en.cwd?.trim()||dn[0]||$t||``,br=Z.useMemo(()=>{let e=[],t=new Set,n=(n,r)=>{let i=n.trim();!i||t.has(i)||(t.add(i),e.push({path:i,label:r}))};en.cwd?.trim()&&n(en.cwd,`Current session directory`),$t&&n($t,`Draft directory`);for(let e of dn)n(e,`Sidebar directory`);return e},[dn,en.cwd,$t]),xr=Z.useMemo(()=>Xt([...dn,...vn,en.cwd||``,$t,...Array.from(fn.keys()),...Object.values(mn).flatMap(e=>e.map(e=>e.cwd||``))]),[dn,mn,fn,en.cwd,vn,$t]),Sr=en.cwd?.trim()||(dn.length>0?dn[0]??``:$t)||yr,Cr=e=>{let t=e.trim();t&&_e(e=>{let n=Xt([t,...e]).slice(0,8);return ee(ot,JSON.stringify(n)),n})},wr=Z.useCallback(e=>{},[]),Tr=Z.useCallback(()=>{i.setSelectedSidebarSessionKeys(e=>e.length===0?e:[]),i.setSidebarSessionSelectionAnchor(e=>e&&``)},[i]),Er=B.state,Dr=te.state,Or=H.state,kr=W.state,Ar=ne.state,{abortSession:jr,addDirectoryPath:Mr,createSession:Pr,editPendingMessage:Fr,removePendingMessage:Ir,reorderPending:Lr,submitPrompt:Rr}=boe({viewerContextId:e,activeSessionId:bn,defaultNewSessionDirectory:yr,sessionStore:f,sessionStateRef:p,draftSessionLoadingOwnerKey:Qt,pendingDraftPrompt:Or,pendingDraftFollowUps:kr,awaitingFirstTurn:Er,pendingMessages:Ar,composerImagesRef:k,composerTextRef:ft,composerSkillRef:pt,replaceComposerDraft:Fn,lastSyncedEditorTextRef:ut,rememberRecentDirectory:Cr,prefetchDirectorySessionsIndex:wr,addOptimisticUserMessage:Ut,removeOptimisticUserMessage:Wt,setSidebarDirectories:i.setSidebarDirectories,setStoredDraftDirectory:me,setDraftSessionLoadingOwnerKey:pe,setPendingDraftPrompt:Pt,setPendingDraftFollowUps:Ft,setPendingMessages:It,setAwaitingFirstTurn:At,setIsSubmitting:jt,setComposerImages:je}),zr=Z.useCallback(e=>{let t=e.trim();if(!t)return;let n=p.current;if(!n.draft||n.items.length>0)return;ee(an,t),me(t),Cr(t);let r=z9({previous:n,cwd:t,ownerKey:Kt({cwd:t})});p.current=r,bt.setItems(r.items),dt(r),We(r,Xx({text:ft.current,skillName:pt.current}))},[bt,Cr,p,dt,me]),Br=Z.useCallback(async e=>{let t=await Mr(e);return typeof t==`string`&&zr(t),t},[Mr,zr]),Vr=Z.useCallback(async(e,t)=>{let n=e||yr||void 0,r=Kt({cwd:n}),i=`optimistic:${r}`,a=p.current,o=!!t?.closeMobileSidebar&&ve&&ye;_r(void 0),Tr(),o?(vt.current=!0,xe(!1)):cr(),At(!1),It(e=>e.length===0?e:[]);let s=z9({previous:a,cwd:n,ownerKey:r});p.current=s,bt.setItems(s.items),dt(s),!await Pr(e)&&p.current.sessionKey===i&&(p.current=a,bt.setItems(a.items),dt(a))},[Tr,bt,yr,cr,_r,ve,ye,Pr,p,At,xe,It,dt]),Hr=async e=>{if(!e||e.length===0)return;let t=Array.from(e).filter(e=>e.type.startsWith(`image/`));if(t.length===0)return;let n=await Promise.all(t.slice(0,8).map(e=>Th(e)));je(e=>[...e,...n].slice(0,8))},Ur=T.state,Wr=O.state,Gr=kr.map((e,t)=>({pendingId:F9(e,t),text:e.message,images:e.images,streamingBehavior:e.streamingBehavior})),Kr=Gr.length>0||Ar.length>0?[...Gr,...Ar]:L9,qr=kn,Jr=qr?L9:Kr,Yr=qr?I9:Wr,Xr=qr?``:Ur.text,Zr=qr?void 0:Ur.skillName,Qr=(e,t)=>{let n=kr.find((t,n)=>F9(t,n)===e);return n?!t.trim()&&n.images.length===0?(Qe.error(`Enter a message or keep at least one image`),!0):(Ft(n=>n.map((n,r)=>F9(n,r)===e?{...n,message:t}:n)),!0):!1},$r=e=>kr.some((t,n)=>F9(t,n)===e)?(Ft(t=>t.filter((t,n)=>F9(t,n)!==e)),!0):!1,ei=(e,t)=>{let n=ioe(kr,e,t);return n?(Ft(n),!0):!1},ti=Z.useCallback(e=>{if(Ot(e),e){zg(Tt,{label:doe,cancelable:!0});return}if(Dt.current){Dt.current=!1,zg(Tt,{label:foe,error:!0});return}Tt.state?.label===`Compacting context...`&&zg(Tt,null)},[Ot,Tt]),ni=Z.useCallback(()=>Dt.current,[]),{cycleThinkingLevel:ri,deleteSessions:ii,renameSessionPath:ai,runClone:oi,runCompact:si,setModel:ci,setThinkingBlocksHidden:li,setThinkingLevel:ui,toggleHideThinking:di}=Coe({viewerContextId:e,activeSessionId:bn,sessionStateRef:p,setSessionState:dt,getDirectoryIndexDataByPath:()=>i.state.state.directoryIndexDataByPath,setDirectoryIndexDataByPath:i.setDirectoryIndexDataByPath,getSessionsEvent:()=>i.state.state.sessionsEvent,setSessionsEvent:i.setSessionsEvent,getSidebarSelection:()=>{let e=i.state.state;return{selectedSidebarSessionKeys:e.selectedSidebarSessionKeys,sidebarSessionSelectionAnchor:e.sidebarSessionSelectionAnchor}},optimisticallyClearActiveDeletedSession:e=>{let t=p.current;if(t.sessionFile!==e)return;let n=`delete:${e}`,r=`optimistic:${n}`;_r(void 0,{replace:!0});let i=z9({previous:t,cwd:t.cwd,ownerKey:n});return p.current=i,bt.setItems(i.items),dt(i),()=>{p.current.sessionKey===r&&(t.sessionId&&_r(t.sessionId,{replace:!0,sessionPath:t.sessionFile}),p.current=t,bt.setItems(t.items),dt(t))}},setSelectedSidebarSessionKeys:i.setSelectedSidebarSessionKeys,setSidebarSessionSelectionAnchor:i.setSidebarSessionSelectionAnchor,setCompactWorkingState:ti,isCompactAbortRequested:ni}),fi=e=>{F(e),ee(Lt,e?`1`:`0`)},pi=()=>{let e=M.current.hideToolBlocks;fi(!e),Qe.info(e?`Tools shown`:`Tools hidden`)},mi=e=>{I(e),ee(kt,e?`1`:`0`)},hi=e=>{L(e),ee(xt,e?`1`:`0`)},gi=(e=`login`)=>{it.current?.open(e)},_i=async(e,t)=>{let n=t.trim(),r=()=>{Fn(``,p.current,{forceSync:!0})};switch(e){case`login`:if(n){Qe.error(`/login does not take any arguments yet.`);return}r(),gi(`login`);return;case`logout`:if(n){Qe.error(`/logout does not take any arguments yet.`);return}r(),gi(`logout`);return;case`compact`:if(Wr.length>0){Qe.error(`Built-in slash commands do not support images.`);return}r(),await si();return;case`clone`:if(n){Qe.error(`/clone does not take any arguments.`);return}if(Wr.length>0){Qe.error(`Built-in slash commands do not support images.`);return}r(),await oi();return;case`rename`:if(!en.sessionFile){Qe.error(`Start the session before renaming it.`);return}if(!n){r(),$n();return}r(),await ai(en.sessionFile,n);return;case`delete`:if(!en.sessionFile){Qe.error(`Start the session before deleting it.`);return}r(),rr();return;case`fork`:if(n){Qe.error(`/fork does not take any arguments.`);return}r(),await ar();return;case`tree`:if(n){Qe.error(`/tree does not take any arguments.`);return}r(),await or();return;case`hide-thinking`:r(),p.current.hideThinkingBlock||await di();return;case`show-thinking`:r(),p.current.hideThinkingBlock&&await di();return;case`hide-tools`:r(),fi(!0);return;case`show-tools`:r(),fi(!1);return;default:Qe.error(`Unsupported slash command: /${e}`)}},vi=e=>{Gt(e)},yi={activeSessionId:bn,awaitingFirstTurn:qr?!1:Er,centerMessages:M.current.centerMessages,composerImages:Yr,composerSkill:Zr,composerSyncNonce:Ur.syncNonce,composerText:Xr,currentPendingMessages:Jr,disabled:qr,isStreaming:qr?!1:p.current.streaming,isSubmitting:qr?!1:Dr,viewerContextId:e};Z.useLayoutEffect(()=>{zg(Te,yi)});let bi=Mg({abortSession:jr,onPickImages:Hr,onRemoveComposerImage:e=>{je(t=>t.filter((t,n)=>n!==e))},editPendingDraftFollowUp:Qr,editPendingMessage:Fr,removePendingDraftFollowUp:$r,removePendingMessage:Ir,reorderPending:Lr,reorderPendingDraftFollowUp:ei,runBuiltinSlashCommand:_i,setModel:ci,setThinkingLevel:ui,submitPrompt:Rr,syncComposerDraft:Pn}),xi=Mg({gitPanelOpen:nn,hasAvailableModels:p.current.availableModels.length>0,isMobile:ve,selectedSidebarSessions:gn,sessionFile:en.sessionFile}),Si=Mg(()=>{let e=xi.current,t=p.current.hideThinkingBlock,n=p.current.thinkingLevel,r=[{id:`new-session`,group:`Sessions`,title:`New session`,description:`Create a new draft session`,shortcut:Uh(`Control+N`),keywords:[`create`,`draft`,`session`],onSelect:Vr},{id:`open-sessions`,group:`Sessions`,title:`Open sessions`,description:`Search and switch sessions`,shortcut:Uh(`Control+S`),keywords:[`session`,`search`,`switch`,`jump`],onSelect:zn},{id:`open-git-view`,group:`Git`,title:e.isMobile?`Toggle right sidebar tab`:e.gitPanelOpen?`Close right sidebar`:`Open right sidebar`,description:e.isMobile?`Switch the mobile right sidebar tab on or off`:`Toggle the right sidebar`,shortcut:Uh(`Control+\\`),keywords:[`right`,`sidebar`,`git`,`changes`,`branch`,`commit`,`panel`],onSelect:Qn},{id:`commit-changes`,group:`Git`,title:`Commit changes`,description:`Open the Git commit dialog`,shortcut:Uh(`Control+C`),keywords:[`git`,`commit`,`changes`,`stage`],onSelect:Vn},{id:`push-changes`,group:`Git`,title:`Push changes`,description:`Push local commits to the remote`,shortcut:Uh(`Control+P`),keywords:[`git`,`push`,`remote`,`upstream`],onSelect:Jn},{id:`force-push-changes`,group:`Git`,title:`Force push changes`,description:`Force push local commits with --force-with-lease`,shortcut:Uh(`Control+Shift+P`),keywords:[`git`,`force`,`push`,`remote`,`upstream`,`lease`],onSelect:Yn},{id:`pull-changes`,group:`Git`,title:`Pull changes`,description:`Pull remote changes into the current branch`,shortcut:Uh(`Alt+P`),keywords:[`git`,`pull`,`remote`,`upstream`],onSelect:Zn},{id:`focus-prompt`,group:`Assistant`,title:`Focus prompt`,description:`Move focus to the prompt field`,shortcut:Uh(`Control+Enter`),keywords:[`prompt`,`composer`,`input`,`message`,`reply`],onSelect:cr},{id:`set-model`,group:`Assistant`,title:`Set model`,description:`Open the model picker`,shortcut:Uh(`Control+M`),keywords:[`model`,`provider`,`picker`,`choose`],onSelect:()=>{if(!xi.current.hasAvailableModels)throw Error(`No models are available right now.`);lr()}},{id:`add-directory`,group:`Sidebar`,title:`Add Directory`,description:`Add a directory accordion to the sidebar`,shortcut:Uh(`Control+D`),keywords:[`workspace`,`sidebar`,`directory`,`folder`],onSelect:ir},{id:`tree-session`,group:`Sessions`,title:`Open tree`,description:`Jump to an earlier point in the current session tree`,shortcut:`Esc Esc`,keywords:[`tree`,`branch`,`history`,`navigate`],onSelect:or},{id:`fork-session`,group:`Sessions`,title:`Fork session`,description:`Create a new session from a previous user message`,shortcut:Uh(`Control+F`),keywords:[`fork`,`branch`,`draft`],onSelect:ar},{id:`clone-session`,group:`Sessions`,title:`Clone session`,description:`Duplicate the current active branch into a new session`,keywords:[`clone`,`branch`,`duplicate`,`session`],onSelect:oi},{id:`compact-session`,group:`Sessions`,title:`Compact`,description:`Manually compact the session context with /compact`,keywords:[`compact`,`context`,`compress`,`summarize`],onSelect:si},{id:`toggle-thinking`,group:`Assistant`,title:t?`Show thinking blocks`:`Hide thinking blocks`,description:t?`Show assistant thinking blocks`:`Hide assistant thinking blocks`,shortcut:Uh(`Control+T`),keywords:[`thinking`,`reasoning`,`visibility`,`show`,`hide`],onSelect:di},{id:`cycle-reasoning`,group:`Assistant`,title:`Next reasoning level`,description:`Current level: ${n}`,shortcut:Uh(`Control+R`),keywords:[`thinking`,`reasoning`,`level`,`cycle`,`next`],onSelect:()=>{ri(1)}},{id:`previous-reasoning`,group:`Assistant`,title:`Previous reasoning level`,description:`Current level: ${n}`,shortcut:Uh(`Control+Shift+R`),keywords:[`thinking`,`reasoning`,`level`,`cycle`,`previous`,`back`],onSelect:()=>{ri(-1)}},{id:`toggle-review-pane`,group:`Git`,title:`Toggle Review Pane`,description:`Toggle the review pane for changed files`,keywords:[`review`,`diff`,`file`,`changes`,`pane`],onSelect:un},{id:`toggle-tools`,group:`Assistant`,title:M.current.hideToolBlocks?`Show tool calls`:`Hide tool calls`,description:M.current.hideToolBlocks?`Show assistant tool calls`:`Hide assistant tool calls`,shortcut:Uh(`Control+O`),keywords:[`tools`,`tool calls`,`visibility`,`show`,`hide`],onSelect:pi},{id:`login-provider`,group:`App`,title:`Login to provider`,description:`Configure provider API key or subscription auth`,keywords:[`login`,`auth`,`api key`,`oauth`,`provider`],onSelect:()=>gi(`login`)},{id:`logout-provider`,group:`App`,title:`Logout from provider`,description:`Remove stored provider credentials`,keywords:[`logout`,`auth`,`api key`,`oauth`,`provider`],onSelect:()=>gi(`logout`)},{id:`open-settings`,group:`App`,title:`Open settings`,description:`Open app settings`,shortcut:Uh(`Control+,`),keywords:[`settings`,`theme`,`notifications`,`display`],onSelect:Bn}];return e.sessionFile&&(r.splice(1,0,{id:`rename-session`,group:`Sessions`,title:`Rename session`,description:`Rename the current session`,shortcut:Uh(`Control+E`),keywords:[`rename`,`title`,`name`],onSelect:$n}),r.push({id:`delete-session`,group:`Sessions`,title:`Delete session`,description:`Delete ${Fg(p.current)}`,shortcut:Uh(`Control+X`),keywords:[`delete`,`remove`,`session`],onSelect:rr})),e.selectedSidebarSessions.length>0&&r.push({id:`delete-selected-sessions`,group:`Sidebar`,title:`Delete selected sidebar sessions`,description:`Delete ${e.selectedSidebarSessions.length} selected sidebar ${e.selectedSidebarSessions.length===1?`session`:`sessions`}`,keywords:[`delete`,`selected`,`sidebar`,`sessions`],onSelect:()=>{tr(xi.current.selectedSidebarSessions)}}),r}),Ci=Z.useCallback(async()=>{Et.current&&(Dt.current=!0,await jr())},[jr]),wi=Mg({abortCompact:Ci,abortSession:jr,createSession:Vr,closeCommandPalette:Rn,forcePushGitChanges:Yn,focusModelSelector:lr,focusPrompt:cr,focusSessionSearch:sr,jumpToNextMessage:()=>{lt.current?.jumpToNextMessage()},jumpToPreviousMessage:()=>{lt.current?.jumpToPreviousMessage()},openAddDirectoryDialog:ir,openCommandPalette:Ln,openCommitDialog:Vn,openDeleteDialog:tr,openDeleteDialogForCurrentSession:rr,openForkDialog:ar,openRenameDialog:$n,openSessionsDialog:zn,openSettingsDialog:Bn,openTreeDialog:or,pullGitChanges:Zn,pushGitChanges:Jn,scrollConversationToBottom:()=>{lt.current?.scrollConversationToBottom()},scrollConversationToTop:()=>{lt.current?.scrollConversationToTop()},toggleGitPanel:Qn,toggleHideThinking:di,toggleHideToolBlocks:pi,cycleThinkingLevel:ri}),Ti=Mg({currentTab:ve?g.state.currentTab:`session`,selectedSidebarSessions:gn,sessionHasAvailableModels:p.current.availableModels.length>0,sessionHasFile:!!en.sessionFile,sessionIsStreaming:p.current.streaming,sidebarSessionEntriesByKey:_n}),Ei=Mg({createSession:Vr,onDeleteCurrentSession:rr,onForkSession:ar,onRenameSession:$n,onRunCompact:si,onToggleCurrentSessionPinned:()=>{let e=p.current,t=xn({path:e.sessionFile,id:e.sessionId});t&&i.setPinnedSidebarSessionKeys(e=>{let n=fe(e),r=n.includes(t)?n.filter(e=>e!==t):[t,...n];return ee(Nt,JSON.stringify(r)),r})},onToggleHideThinking:di,onToggleHideToolBlocks:pi,onTreeSession:or});Yoe({addDirectoryOpenRef:Re,commandPaletteOpenRef:Ie,compactRunningRef:Et,deleteOpenRef:Ue,forkOpenRef:Je,gitCommitOpenRef:$e,pendingUiRequestOpenRef:ct,renameOpenRef:Ve,sessionSearchInputRef:a,sessionsOpenRef:tt,settingsOpenRef:rt,shortcutActionsRef:wi,shortcutStateRef:Ti,treeOpenRef:Xe});let Di=Z.useRef(null);return Di.current={stores:{appUi:g,composer:Te,contextUsage:De,conversationItems:bt,displaySettings:j,draftFlow:de,notification:J,rightSidebar:v,session:f,sidebar:i},refs:{composerImages:k,composerPanel:Ce,composerSkill:pt,composerText:ft,conversationFrame:lt,sessionState:p},actions:{createSession:Vr,focusModelSelector:lr,focusPrompt:cr,focusSessionSearch:sr,openAddDirectoryDialog:ir,openCommandPalette:Ln,openDeleteDialog:tr,openDeleteOldDirectorySessionsDialog:nr,openRenameDialogForEntry:er,openSessionsDialog:zn,openSettingsDialog:Bn,selectSession:_r}},Z.useImperativeHandle(s,()=>{let e=Di.current?.actions;return{createSession:e?.createSession??Vr,openAddDirectoryDialog:e?.openAddDirectoryDialog??ir,openCommandPalette:e?.openCommandPalette??Ln,openDeleteDialog:e?.openDeleteDialog??tr,openDeleteOldDirectorySessionsDialog:e?.openDeleteOldDirectorySessionsDialog??nr,openRenameDialogForEntry:e?.openRenameDialogForEntry??er,openSessionsDialog:e?.openSessionsDialog??zn,openSettingsDialog:e?.openSettingsDialog??Bn,selectSession:e?.selectSession??_r}},[Vr,_r,ir,Ln,tr,nr,er,zn,Bn]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Yae,{isSessionViewLoading:kn,loadingDisplaySessionTitle:Mn,notificationStore:J,sessionStore:f,sidebarStore:i,onSelectSession:_r}),(0,Q.jsx)(Fie,{actionsRef:Ei,defaultNewSessionDirectory:yr,displaySessionCwd:Nn,gitPanelOpen:nn,loadingDisplaySessionTitle:Mn,currentSessionPinned:Cn,displaySettingsStore:j,isSessionViewLoading:kn,newSessionDirectoryOptions:br,onToggleGitPanel:Qn,sessionStore:f,viewerContextId:e}),(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[r,(0,Q.jsx)(Jc,{className:`min-h-0 overflow-hidden`,children:(0,Q.jsx)(kie,{actionsRef:bi,appUiStore:g,composerPanelRef:Ce,contextUsageStore:De,conversationFrameRef:lt,conversationItemsStore:bt,defaultNewSessionDirectory:yr,displaySettingsStore:j,fileInputRef:Se,gitPanelOpen:nn,hiddenThinkingPreviewStore:Ct,isSessionViewLoading:kn,isSubmitting:Dr,isMobile:ve,newSessionDirectoryOptions:br,onCancelCompaction:Ci,onCreateSession:e=>{Vr(e)},onOpenAddDirectoryDialog:ir,onCloseAllFileViewTabs:X,onCloseFileViewTab:on,onCloseFileViewTabsToRight:cn,onCloseOtherFileViewTabs:sn,onOpenFileViewTab:rn,onReorderFileViewTabs:ln,rightSidebarStore:v,sessionStore:f,store:Te,viewerContextId:e,workingStateStore:Tt,awaitingFirstTurn:Er,onValueChange:y})})]}),(0,Q.jsx)(hv,{activeSessionId:bn,addDirectoryDialogRef:Le,addDirectoryOpenRef:Re,addDirectoryPath:Br,baseSidebarDirectories:dn,commandPaletteCommandsRef:Si,commandPaletteOpenRef:Ie,commandPaletteRef:Fe,currentSessionQueryScope:wn,currentTheme:Jt,authDialogRef:it,authOpenRef:at,deleteDialogRef:He,deleteOpenRef:Ue,deleteSessions:ii,deleteOldDirectorySessionsDialogRef:Ge,deleteOldDirectorySessionsOpenRef:Ke,notificationStore:J,forkDialogRef:qe,forkOpenRef:Je,gitCommitDialogRef:Ze,gitCommitOpenRef:$e,displaySettingsStore:j,knownDirectories:xr,onAutoScrollEnabledChange:hi,onCenterMessagesChange:mi,onHideThinkingBlocksChange:e=>{li(e)},onHideToolBlocksChange:fi,onSessionDoneDesktopNotificationsEnabledChange:hr,onSessionDoneSoundEnabledChange:mr,onSessionDialogSelect:_r,onThemeChange:vi,recentDirectoriesStore:ge,renameDialogRef:ze,renameOpenRef:Ve,renameSessionPath:ai,sessionCwd:en.cwd,sessionsDialogDirectory:Sr,sessionsDialogRef:et,sessionsOpenRef:tt,sessionStore:f,settingsDialogRef:nt,settingsOpenRef:rt,sidebarStore:i,treeDialogRef:Ye,treeOpenRef:Xe,uiRequestDialogRef:st,uiRequestOpenRef:ct,viewerContextId:e})]})});function Qoe({sessionId:e,onSelectSession:t}){let[n,r]=Z.useState(``),i=Z.useRef(null);i.current||=r_();let a=i.current,o=Z.useRef(null),s=Z.useRef(null);return Z.useEffect(()=>{let e=window.localStorage.getItem(`pico-context-id`)?.trim()||v();ee(S,e),r(e);let t=Xt(Ie().directories),n=t.slice(0,Xoe),i=q();a.setSidebarState(e=>Ag(e.sidebarDirectories,t)&&Ag(e.initialSidebarBootstrapDirectories,n)&&Ag(e.pinnedSidebarSessionKeys,i)?e:{sidebarDirectories:t,initialSidebarBootstrapDirectories:n,pinnedSidebarSessionKeys:i})},[a]),(0,Q.jsx)(Wc,{className:`h-full flex-col overflow-hidden bg-background [--header-height:2.75rem]`,children:(0,Q.jsx)(Zoe,{ref:s,viewerContextId:n,sessionId:e,onSelectSession:t,sidebar:(0,Q.jsx)(xae,{viewerContextId:n,sidebarStore:a,sessionWorkspaceRef:s}),sidebarStore:a,sessionSearchInputRef:o})})}function $oe(){let e=(0,$.c)(6),{session:t}=Nn.useSearch(),n=Nn.useNavigate(),r;e[0]!==n||e[1]!==t?(r=(e,r)=>{let i=e||void 0;i!==t&&n({search:e=>({...e,session:i}),replace:r?.replace??!1})},e[0]=n,e[1]=t,e[2]=r):r=e[2];let i;return e[3]!==t||e[4]!==r?(i=(0,Q.jsx)(Qoe,{sessionId:t,onSelectSession:r}),e[3]=t,e[4]=r,e[5]=i):i=e[5],i}export{$oe as component};
|
|
2151
|
+
`)}function Foe(e,t,n){return e===t?!0:X9(e,n)===X9(t,n)}function Z9(e,t){return e.connected===t.connected&&e.replaying===t.replaying&&e.streaming===t.streaming&&e.compacting===t.compacting&&e.draft===t.draft&&e.historyOffset===t.historyOffset&&e.historyTotalCount===t.historyTotalCount&&e.sessionId===t.sessionId&&e.sessionKey===t.sessionKey&&e.sessionName===t.sessionName&&e.firstMessage===t.firstMessage&&e.sessionFile===t.sessionFile&&e.cwd===t.cwd&&e.modified===t.modified&&e.model===t.model&&e.thinkingLevel===t.thinkingLevel&&e.availableThinkingLevels===t.availableThinkingLevels&&e.availableModels===t.availableModels&&e.availableSkills===t.availableSkills&&e.hideThinkingBlock===t.hideThinkingBlock&&e.uiRequest===t.uiRequest}function Ioe(e,t){return e.statuses===t.statuses&&e.title===t.title&&e.editorText===t.editorText}function Loe(e,t){return e===t?!1:!Z9(e,t)||!Ioe(e.uiState,t.uiState)||e.items.length===0!=(t.items.length===0)}function Roe(e,t){return!t||e.draft!==!0?!1:Kt({cwd:typeof e.cwd==`string`?e.cwd:void 0,sessionFile:typeof e.sessionFile==`string`?e.sessionFile:void 0,sessionId:typeof e.sessionId==`string`?e.sessionId:void 0})===t}function zoe(e){let t=e.previousState.sessionKey||``,n=typeof e.payload.sessionKey==`string`?e.payload.sessionKey:``;return!t.startsWith(`optimistic:`)||!n||n===t?!1:!Roe(e.payload,e.ownerKey)}function Boe(e){let t=(0,$.c)(85),{viewerContextId:n,sessionId:r,draftSessionLoadingOwnerKey:i,bootstrapSidebarDirectories:a,hideToolBlocksRef:o,sessionStore:s,sessionStateRef:c,composerTextRef:l,composerSkillRef:u,replaceComposerDraftRef:d,handleSelectSessionRef:f,pendingRouteSessionIdRef:p,pendingRouteSessionPathRef:m,setSessionState:h,setConversationItems:g,setHiddenThinkingPreview:_,setWorkingState:v,setCompactRunningState:y,setComposerContextUsage:b,setComposerStreaming:x,setSessionsEvent:S,setSessionDoneEvents:C,applySidebarSessionStatusRef:w,setComposerImages:T,setPendingMessages:E,pendingUiRequestHandlerRef:D,lastSyncedEditorTextRef:O}=e,k=re(),A=Z.useRef(r),j=Z.useRef(r),M=Z.useRef(i),N=Z.useRef(null),P=Z.useRef(!1),F=Z.useRef(null),I=Z.useRef(!1),[L,R]=Z.useState(0),z,B;t[0]===r?(z=t[1],B=t[2]):(z=()=>{j.current=r},B=[r],t[0]=r,t[1]=z,t[2]=B),Z.useEffect(z,B);let V,H;t[3]===i?(V=t[4],H=t[5]):(V=()=>{M.current=i},H=[i],t[3]=i,t[4]=V,t[5]=H),Z.useEffect(V,H);let U,W;t[6]===r?(U=t[7],W=t[8]):(U=()=>{N.current||(A.current=r)},W=[r],t[6]=r,t[7]=U,t[8]=W),Z.useEffect(U,W);let G=Ji(s,Koe),ee=Z.useRef(G),te=Z.useRef(void 0),K=Ji(s,Goe),ne,q;t[9]!==p||t[10]!==m||t[11]!==r||t[12]!==G?(ne=()=>{let e=te.current!==r;if(te.current=r,!r){p.current=void 0,m.current=void 0;return}if(r===G){p.current===r&&(p.current=void 0,m.current=void 0);return}e&&(p.current!==r&&(m.current=void 0),p.current=r)},q=[p,m,r,G],t[9]=p,t[10]=m,t[11]=r,t[12]=G,t[13]=ne,t[14]=q):(ne=t[13],q=t[14]),Z.useEffect(ne,q);let J,Y;t[15]!==k||t[16]!==n?(Y=()=>{if(!n)return;let e=()=>{F.current=Date.now(),I.current=!0},t=e=>{let t=e===void 0?!1:e;if(document.visibilityState!==`visible`)return;let n=F.current,r=n?Date.now()-n:0,i=t||I.current&&r>=woe;F.current=null,I.current=!1,i&&(A.current=j.current,R(Woe),k.invalidateQueries({refetchType:`active`}).catch(Uoe))},r=()=>{if(document.visibilityState===`hidden`){e();return}t()},i=()=>{t()},a=e=>{t(e.persisted)};return document.visibilityState===`hidden`&&e(),window.addEventListener(`blur`,e),window.addEventListener(`focus`,i),window.addEventListener(`pagehide`,e),window.addEventListener(`pageshow`,a),document.addEventListener(`visibilitychange`,r),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`focus`,i),window.removeEventListener(`pagehide`,e),window.removeEventListener(`pageshow`,a),document.removeEventListener(`visibilitychange`,r)}},J=[k,n],t[15]=k,t[16]=n,t[17]=J,t[18]=Y):(J=t[17],Y=t[18]),Z.useEffect(Y,J);let ie;t[19]!==w||t[20]!==a||t[21]!==u||t[22]!==l||t[23]!==f||t[24]!==o||t[25]!==O||t[26]!==p||t[27]!==D||t[28]!==k||t[29]!==d||t[30]!==c||t[31]!==y||t[32]!==b||t[33]!==T||t[34]!==x||t[35]!==g||t[36]!==_||t[37]!==E||t[38]!==C||t[39]!==h||t[40]!==S||t[41]!==v||t[42]!==n?(ie=()=>{if(!n)return;P.current=!1;let e=new xo(e=>{let t=new Map;for(let n of e){let e=t.get(n.cwd)??new Set;for(let t of n.scopes)e.add(t);t.set(n.cwd,e)}let r=[];for(let[e,i]of t)i.has(`status`)&&r.push(k.invalidateQueries({queryKey:_g.gitStatus(n,e),exact:!0,refetchType:`active`})),i.has(`files`)&&r.push(k.invalidateQueries({queryKey:_g.gitFiles(n,e),exact:!0,refetchType:`active`}),k.invalidateQueries({queryKey:_g.projectFileTree(n,e),exact:!0,refetchType:`active`}),k.invalidateQueries({queryKey:_g.gitFileReviews(n,e),exact:!1,refetchType:`active`})),i.has(`refs`)&&r.push(k.invalidateQueries({queryKey:_g.gitBranches(n,e),exact:!0,refetchType:`active`}),k.invalidateQueries({queryKey:_g.gitCommits(n,e),exact:!1,refetchType:`active`}));Promise.all(r).catch(Hoe)},{key:`pico.git.invalidations`,wait:100}),t=new EventSource(Ch(`/events`,{contextId:n,sessionId:A.current,searchParams:{sidebarDirectory:a}}));return N.current=t,t.onopen=()=>{if(N.current!==t)return;let e=c.current;if(e.connected)return;let n={...e,connected:!0};c.current=n,g(n.items),h(n)},t.onerror=()=>{if(N.current!==t)return;let e=c.current;if(!e.connected)return;let n={...e,connected:!1};c.current=n,g(n.items),h(n)},t.onmessage=n=>{if(N.current!==t)return;let r=JSON.parse(n.data);if(lh(r)){P.current=!0;let e=c.current;if(zoe({ownerKey:M.current,payload:r,previousState:e}))return;let t=l.current;We(e,Xx({text:t,skillName:u.current}));let n=e.uiState.editorText||``,i=Oh(e,r),a=Kt(i)!==Kt(e),s=j.current,m=M.current,C=i.draft&&!i.sessionKey?.startsWith(`optimistic:`),D=e.draft&&e.sessionKey?.startsWith(`optimistic:`),k=m?Kt(i)===m:!1,A=!!(s&&!p.current&&C&&(k||D)),N=!a&&t!==n,F=N?t:we(i)??i.uiState.editorText??``;Mi(()=>{c.current=i,_(i.hiddenThinkingPreview||``,{preserveExisting:!!(e.streaming&&i.streaming&&!i.hiddenThinkingPreview)}),e.contextUsage!==i.contextUsage&&b(i.contextUsage);let t=e.sessionKey!==i.sessionKey||e.sessionId!==i.sessionId||e.sessionFile!==i.sessionFile;e.streaming!==i.streaming&&x(i.streaming),(t||e.compacting!==i.compacting)&&y(i.compacting),(t||e.streaming||i.streaming||e.compacting||i.compacting)&&v(i.compacting?{label:Toe,cancelable:!0}:i.streaming?{label:i.uiState.workingMessage||`Working…`}:null),(t||!Foe(e.items,i.items,{hideThinking:i.hideThinkingBlock,hideToolBlocks:o.current}))&&g(i.items),Loe(e,i)&&h(i),(e.sessionKey!==i.sessionKey||e.sessionId!==i.sessionId||e.sessionFile!==i.sessionFile||e.streaming!==i.streaming)&&w.current({type:`session_status`,sessionKey:i.sessionKey,sessionId:i.sessionId,sessionPath:i.sessionFile,streaming:i.streaming,unread:!1}),a&&S(e=>{if(!e)return e;let t={...e,activeSessionId:i.sessionId,activeSessionKey:i.sessionKey,activeSessionPath:i.sessionFile};return Y9(e,t)?e:t}),a&&T(Voe),A&&f.current(void 0,{replace:!0}),N||d.current(F,i),O.current=i.uiState.editorText||``;let n=Eoe(r);n&&E(e=>koe(e,n)?e:n)});return}if(uh(r)){S(e=>Y9(e,r)?e:r);return}if(dh(r)){w.current(r);return}if(fh(r)){C(e=>e.some(e=>e.id===r.id)?e:[...e,r]);return}if(ph(r)){let t=r.cwd.trim();t&&e.addItem({cwd:t,scopes:new Set(r.scopes??[`status`,`files`,`refs`])});return}if(r.type===`request_error`){Qe.error(r.error||`Request failed`);return}if(r.type===`extension_error`){Qe.error(r.error||`Extension error`);return}if(r.type===`extension_ui_request`){if(r.method===`notify`){let e=r.message||`Notification`;r.notifyType===`success`?Qe.success(e):r.notifyType===`warning`?Qe.warning(e):r.notifyType===`error`?Qe.error(e):Qe.info(e);return}D.current(r)}},()=>{N.current===t&&(N.current=null),t.close(),e.flush(),e.cancel(),e.clear()}},t[19]=w,t[20]=a,t[21]=u,t[22]=l,t[23]=f,t[24]=o,t[25]=O,t[26]=p,t[27]=D,t[28]=k,t[29]=d,t[30]=c,t[31]=y,t[32]=b,t[33]=T,t[34]=x,t[35]=g,t[36]=_,t[37]=E,t[38]=C,t[39]=h,t[40]=S,t[41]=v,t[42]=n,t[43]=ie):ie=t[43];let ae;t[44]!==w||t[45]!==a||t[46]!==u||t[47]!==l||t[48]!==L||t[49]!==O||t[50]!==D||t[51]!==k||t[52]!==d||t[53]!==c||t[54]!==y||t[55]!==b||t[56]!==T||t[57]!==x||t[58]!==g||t[59]!==_||t[60]!==E||t[61]!==C||t[62]!==h||t[63]!==S||t[64]!==v||t[65]!==n?(ae=[a,u,l,O,w,k,d,c,T,_,v,y,b,x,g,E,D,C,h,S,n,L],t[44]=w,t[45]=a,t[46]=u,t[47]=l,t[48]=L,t[49]=O,t[50]=D,t[51]=k,t[52]=d,t[53]=c,t[54]=y,t[55]=b,t[56]=T,t[57]=x,t[58]=g,t[59]=_,t[60]=E,t[61]=C,t[62]=h,t[63]=S,t[64]=v,t[65]=n,t[66]=ae):ae=t[66],Z.useEffect(ie,ae);let oe,se;t[67]===G?(oe=t[68],se=t[69]):(oe=()=>{ee.current=G},se=[G],t[67]=G,t[68]=oe,t[69]=se),Z.useEffect(oe,se);let ce,le;t[70]!==i||t[71]!==p||t[72]!==m||t[73]!==r||t[74]!==n?(ce=()=>{if(!n||!r||i||!P.current||r===ee.current||p.current!==r)return;let e=new AbortController,t=m.current;return wh(Ch(`/api/session/select`,{contextId:n,sessionId:r,searchParams:{sessionPath:t}}),{method:`POST`,signal:e.signal}).catch(t=>{e.signal.aborted||Qe.error(t instanceof Error?t.message:`Failed to select session`)}),()=>{e.abort()}},le=[i,p,m,n,r],t[70]=i,t[71]=p,t[72]=m,t[73]=r,t[74]=n,t[75]=ce,t[76]=le):(ce=t[75],le=t[76]),Z.useEffect(ce,le);let ue,de;t[77]!==f||t[78]!==p||t[79]!==m||t[80]!==r||t[81]!==K||t[82]!==G?(ue=()=>{if(K||!G)return;let e=p.current;if(e){G===e&&(p.current=void 0,m.current=void 0);return}G!==r&&f.current(G,{replace:!0})},de=[f,p,m,r,K,G],t[77]=f,t[78]=p,t[79]=m,t[80]=r,t[81]=K,t[82]=G,t[83]=ue,t[84]=de):(ue=t[83],de=t[84]),Z.useEffect(ue,de)}function Voe(e){return e.length===0?e:[]}function Hoe(){}function Uoe(){}function Woe(e){return e+1}function Goe(e){return e.draft}function Koe(e){return e.sessionId}var qoe=500;function Q9(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return e.isContentEditable||t===`input`||t===`textarea`||e.closest(`[contenteditable="true"]`)!==null}function $9(e){return e instanceof HTMLTextAreaElement&&e.name===`prompt`}function Joe(e){if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)return e.selectionStart!==e.selectionEnd;if(e instanceof HTMLElement){let e=window.getSelection();return!!(e&&String(e).trim())}return!1}function Yoe(e){let t=(0,$.c)(34),{addDirectoryOpenRef:n,commandPaletteOpenRef:r,compactRunningRef:i,deleteOpenRef:a,forkOpenRef:o,gitCommitOpenRef:s,pendingUiRequestOpenRef:c,renameOpenRef:l,sessionSearchInputRef:u,sessionsOpenRef:d,settingsOpenRef:f,shortcutActionsRef:p,shortcutStateRef:m,treeOpenRef:h}=e,g=Z.useRef(0),_,v,y,b,x,S,C;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==o||t[5]!==s||t[6]!==c||t[7]!==l||t[8]!==u||t[9]!==d||t[10]!==f||t[11]!==p||t[12]!==m||t[13]!==h){let e=e=>{let t=m.current,i=r.current,p=n.current||l.current||a.current||o.current||s.current||h.current||d.current||f.current||c.current,g=document.activeElement,_=g instanceof HTMLElement&&g.closest(`[data-conversation-viewport="true"]`)!==null,v=g instanceof HTMLElement?g.dataset.sessionKey?.trim()??``:``,y=v?t.sidebarSessionEntriesByKey.get(v):void 0,b=e.target instanceof HTMLInputElement&&e.target===u.current;return{...t,activeElement:g,activeElementIsConversationViewport:_,blockingModalOpen:p,commandPaletteOpen:i,focusedSidebarSession:y,modalOpen:p||i,targetIsSessionSearch:b}},w=e=>{e&&p.current.closeCommandPalette()},T=t=>{let n=e(t);if(t.repeat||n.modalOpen||t.defaultPrevented)return;let r=Date.now();if(r-g.current<=qoe){g.current=0,t.preventDefault(),p.current.openTreeDialog();return}if(g.current=r,i.current){t.preventDefault(),p.current.abortCompact();return}n.sessionIsStreaming&&!Q9(t.target)&&(t.preventDefault(),p.current.abortSession())},E=t=>{let n=e(t);if(n.modalOpen||Q9(t.target)&&!n.targetIsSessionSearch||n.activeElementIsConversationViewport)return;let r=Array.from(document.querySelectorAll(`[data-sidebar-session-item]`)),i=n.activeElement instanceof HTMLElement?n.activeElement.closest(`[data-sidebar-session-item]`):null;if(r.length===0)return;let a=i?r.findIndex(e=>e===i):-1,o=t.key===`Home`?0:t.key===`End`?r.length-1:a>=0?Math.max(0,Math.min(r.length-1,a+(t.key===`ArrowDown`?1:-1))):t.key===`ArrowUp`?r.length-1:0;t.preventDefault(),r[o]?.focus()},D=t=>{let n=e(t);if(n.modalOpen||Q9(t.target)&&!n.targetIsSessionSearch)return;let r=n.selectedSidebarSessions.length>0?n.selectedSidebarSessions:n.focusedSidebarSession?.path?[n.focusedSidebarSession]:[];r.length!==0&&(t.preventDefault(),p.current.openDeleteDialog(r))},O=t=>{let n=e(t);n.blockingModalOpen||t.defaultPrevented||(t.preventDefault(),w(n.commandPaletteOpen),p.current.focusPrompt())},k=t=>{let n=e(t);if(!(n.currentTab!==`session`||n.modalOpen||t.defaultPrevented||Q9(t.target)&&!$9(t.target))){if(t.preventDefault(),t.key===`ArrowLeft`){p.current.jumpToPreviousMessage();return}if(t.key===`ArrowRight`){p.current.jumpToNextMessage();return}if(t.key===`ArrowUp`){p.current.scrollConversationToTop();return}p.current.scrollConversationToBottom()}};_=t=>{let n=t.altKey&&t.code.startsWith(`Key`)?t.code.slice(3).toLowerCase():t.key.toLowerCase(),r=e(t);if(!r.blockingModalOpen){if(n===`\\`){t.preventDefault(),w(r.commandPaletteOpen),p.current.toggleGitPanel();return}if(n===`k`){t.preventDefault(),p.current.openCommandPalette();return}if(n===`p`){if(t.preventDefault(),w(r.commandPaletteOpen),t.altKey){p.current.pullGitChanges();return}if(t.shiftKey){p.current.forcePushGitChanges();return}p.current.pushGitChanges();return}if(n===`n`){t.preventDefault(),w(r.commandPaletteOpen),p.current.createSession();return}if(n===`s`){t.preventDefault(),w(r.commandPaletteOpen),p.current.openSessionsDialog();return}if(n===`e`){if(!r.sessionHasFile)return;t.preventDefault(),w(r.commandPaletteOpen),p.current.openRenameDialog();return}if(n===`f`){t.preventDefault(),w(r.commandPaletteOpen),p.current.openForkDialog();return}if(n===`d`){t.preventDefault(),w(r.commandPaletteOpen),p.current.openAddDirectoryDialog();return}if(n===`,`){t.preventDefault(),w(r.commandPaletteOpen),p.current.openSettingsDialog();return}if(n===`m`){if(!r.sessionHasAvailableModels&&!r.commandPaletteOpen)return;t.preventDefault(),w(r.commandPaletteOpen),p.current.focusModelSelector();return}if(n===`t`){t.preventDefault(),w(r.commandPaletteOpen),p.current.toggleHideThinking();return}if(n===`r`){t.preventDefault(),w(r.commandPaletteOpen),p.current.cycleThinkingLevel(t.shiftKey?-1:1);return}if(n===`o`){t.preventDefault(),w(r.commandPaletteOpen),p.current.toggleHideToolBlocks();return}if(n===`c`){if(!r.commandPaletteOpen&&Joe(t.target))return;t.preventDefault(),w(r.commandPaletteOpen),p.current.openCommitDialog();return}if(n===`x`){if(Q9(t.target)&&!$9(t.target)||!r.sessionHasFile)return;t.preventDefault(),w(r.commandPaletteOpen),p.current.openDeleteDialogForCurrentSession()}}},v={hotkey:`Escape`,callback:T,options:{meta:{name:`Abort active session`,description:`Abort compaction or the streaming assistant response.`}}},y=[{key:`ArrowDown`},{key:`ArrowUp`},{key:`Home`},{key:`End`},{key:`ArrowDown`,shift:!0},{key:`ArrowUp`,shift:!0},{key:`Home`,shift:!0},{key:`End`,shift:!0}].map(e=>({hotkey:e,callback:E,options:{meta:{name:`Move sidebar focus`,description:`Move keyboard focus through sidebar sessions.`}}})),b=[`Delete`,`Backspace`].map(e=>({hotkey:e,callback:D,options:{meta:{name:`Delete selected sidebar sessions`,description:`Open the delete dialog for focused or selected sessions.`}}})),x={hotkey:{key:`Enter`,ctrl:!0},callback:O,options:{meta:{name:`Focus prompt`,description:`Focus the prompt composer.`}}},S=[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`].map(e=>({hotkey:{key:e,ctrl:!0},callback:k,options:{meta:{name:`Navigate conversation`,description:`Jump between messages or to conversation boundaries.`}}})),C=[{key:`\\`},{key:`K`},{key:`P`},{key:`P`,shift:!0},{key:`N`},{key:`S`},{key:`E`},{key:`F`},{key:`D`},{key:`,`},{key:`M`},{key:`T`},{key:`R`},{key:`R`,shift:!0},{key:`V`},{key:`O`},{key:`C`},{key:`X`}].map(e=>({hotkey:{...e,ctrl:!0},callback:_,options:{meta:{name:`App shell shortcut`,description:`Run a Pico app shell command.`}}})),t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=_,t[15]=v,t[16]=y,t[17]=b,t[18]=x,t[19]=S,t[20]=C}else _=t[14],v=t[15],y=t[16],b=t[17],x=t[18],S=t[19],C=t[20];let w;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(w={key:`P`,alt:!0},t[21]=w):w=t[21];let T;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(T={meta:{name:`App shell shortcut`,description:`Run a Pico app shell command.`}},t[22]=T):T=t[22];let E;t[23]===_?E=t[24]:(E={hotkey:w,callback:_,options:T},t[23]=_,t[24]=E);let D;t[25]!==v||t[26]!==y||t[27]!==b||t[28]!==x||t[29]!==S||t[30]!==C||t[31]!==E?(D=[v,...y,...b,x,...S,...C,E],t[25]=v,t[26]=y,t[27]=b,t[28]=x,t[29]=S,t[30]=C,t[31]=E,t[32]=D):D=t[32];let O=D,k;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(k={conflictBehavior:`allow`,ignoreInputs:!1,preventDefault:!1,stopPropagation:!1},t[33]=k):k=t[33],Gi(O,k)}var Xoe=6,Zoe=Z.forwardRef(function({viewerContextId:e,sessionId:t,onSelectSession:n,sidebar:r,sidebarStore:i,sessionSearchInputRef:a},s){let c=re(),l=Z.useRef(null);l.current||=pn();let d=Z.useRef(null);d.current||=Lg(l.current);let f=d.current,p=Z.useRef(f.state),h=Z.useRef(null);h.current||=Lg({currentTab:`session`,gitPanelOpen:!1,initialLoadingSessionId:t||null,loadingSessionId:null},Pg);let g=h.current,_=Z.useRef(null);_.current||=Lg(sie());let v=_.current,y=Z.useCallback(e=>{Bg(g,`currentTab`,e)},[g]),b=Z.useCallback(e=>{let t=Rg(g.state.gitPanelOpen,e);Bg(g,`gitPanelOpen`,t),ee(Xn,t?`1`:`0`)},[g]),x=Z.useCallback(e=>{Bg(g,`loadingSessionId`,e)},[g]),S=Z.useCallback(e=>{Bg(g,`initialLoadingSessionId`,e)},[g]),C=Z.useRef(t),w=Z.useRef(null);w.current||=Lg({text:``,syncNonce:0});let T=w.current,D=Z.useRef(null);D.current||=Lg([]);let O=D.current,k=Z.useRef([]),A=Z.useRef(null);A.current||=Lg({autoScrollEnabled:!0,centerMessages:!1,hideToolBlocks:!1},Pg);let j=A.current,M=Z.useRef(j.state),N=Z.useRef(j.state.hideToolBlocks),F=Z.useCallback(e=>{let t=j.state,n=Rg(t.hideToolBlocks,e);if(n===t.hideToolBlocks)return;let r={...t,hideToolBlocks:n};M.current=r,N.current=r.hideToolBlocks,zg(j,r)},[j]),I=Z.useCallback(e=>{let t=j.state,n=Rg(t.centerMessages,e);if(n===t.centerMessages)return;let r={...t,centerMessages:n};M.current=r,zg(j,r)},[j]),L=Z.useCallback(e=>{let t=j.state,n=Rg(t.autoScrollEnabled,e);if(n===t.autoScrollEnabled)return;let r={...t,autoScrollEnabled:n};M.current=r,zg(j,r)},[j]),z=Z.useRef(null);z.current||=Lg(!1);let B=z.current,V=Z.useRef(null);V.current||=Lg(null);let H=V.current,U=Z.useRef(null);U.current||=Lg([]);let W=U.current,G=Z.useRef(null);G.current||=Lg(!1);let te=G.current,K=Z.useRef(null);K.current||=Lg([]);let ne=K.current,q=Z.useRef(null);q.current||=Lg({desktopNotificationPermission:`unsupported`,sessionDoneDesktopNotificationsEnabled:!0,sessionDoneEvents:[],sessionDoneSoundEnabled:!0},Pg);let J=q.current,Y=Z.useCallback(e=>{Bg(J,`sessionDoneEvents`,e)},[J]),ae=Z.useCallback(e=>{Bg(J,`sessionDoneSoundEnabled`,e)},[J]),oe=Z.useCallback(e=>{Bg(J,`sessionDoneDesktopNotificationsEnabled`,e)},[J]),se=Z.useCallback(e=>{Bg(J,`desktopNotificationPermission`,e)},[J]),le=Z.useRef(null);le.current||=Lg({draftSessionLoadingOwnerKey:null,storedDraftDirectory:``},Pg);let de=le.current,pe=Z.useCallback(e=>{Bg(de,`draftSessionLoadingOwnerKey`,e)},[de]),me=Z.useCallback(e=>{Bg(de,`storedDraftDirectory`,e)},[de]),he=Z.useRef(null);he.current||=Lg([],Ag);let ge=he.current,_e=Z.useCallback(e=>{let t=ge.state,n=Rg(t,e);n!==t&&zg(ge,n)},[ge]),{isMobile:ve,openMobile:ye,openMobileSettled:be,setOpenMobile:xe}=Uc(),Se=Z.useRef(null),Ce=Z.useRef(null),we=Z.useRef(null);we.current||=Lg(soe(e),ooe);let Te=we.current,Ee=Z.useRef(null);Ee.current||=Lg(void 0);let De=Ee.current,Oe=Z.useRef(null);Oe.current||=new wo(e=>{zg(De,e)},{key:`pico.composer.context-usage`,wait:250,leading:!0,trailing:!0});let ke=Oe.current;Z.useEffect(()=>()=>{ke.flush(),ke.cancel()},[ke]);let Ae=Z.useCallback(e=>{let t=T.state,n=Rg(t,e);n!==t&&Mi(()=>{zg(T,n);let e=Te.state;zg(Te,{...e,composerSkill:e.disabled?void 0:n.skillName,composerSyncNonce:n.syncNonce,composerText:e.disabled?``:n.text})})},[T,Te]),je=Z.useCallback(e=>{let t=O.state,n=Rg(t,e);n!==t&&(k.current=n,Mi(()=>{zg(O,n);let e=Te.state;zg(Te,{...e,composerImages:e.disabled?[]:n})}))},[O,Te]),Ne=Z.useCallback(e=>{ke.maybeExecute(e)},[ke]),Pe=Z.useCallback(e=>{let t=Te.state;zg(Te,{...t,isStreaming:t.disabled?!1:e})},[Te]),Fe=Z.useRef(null),Ie=Z.useRef(!1),Le=Z.useRef(null),Re=Z.useRef(!1),ze=Z.useRef(null),Ve=Z.useRef(!1),He=Z.useRef(null),Ue=Z.useRef(!1),Ge=Z.useRef(null),Ke=Z.useRef(!1),qe=Z.useRef(null),Je=Z.useRef(!1),Ye=Z.useRef(null),Xe=Z.useRef(!1),Ze=Z.useRef(null),$e=Z.useRef(!1),et=Z.useRef(null),tt=Z.useRef(!1),nt=Z.useRef(null),rt=Z.useRef(!1),it=Z.useRef(null),at=Z.useRef(!1),st=Z.useRef(null),ct=Z.useRef(!1),lt=Z.useRef(null),ut=Z.useRef(``),dt=Z.useCallback(e=>{let t=p.current,n=typeof e==`function`?e(t):e,r=f.state;Object.is(t,n)&&Object.is(r,n)||(p.current=n,zg(f,n))},[f]),ft=Z.useRef(T.state.text),pt=Z.useRef(T.state.skillName),mt=Z.useRef(void 0),ht=Z.useRef(void 0),gt=Z.useRef(e=>{});gt.current=e=>{st.current?.open(e)};let _t=Z.useRef(new Set),vt=Z.useRef(!1),yt=Z.useRef(null);yt.current||=qq(p.current.items);let bt=yt.current,St=Z.useRef(null);St.current||=Lg(p.current.hiddenThinkingPreview||``);let Ct=St.current,wt=Z.useRef(null);wt.current||=Lg(null,poe);let Tt=wt.current,Et=Z.useRef(!1),Dt=Z.useRef(!1),Ot=Z.useCallback(e=>{Et.current=e,e&&(Dt.current=!1)},[]),At=Z.useCallback(e=>{let t=B.state,n=Rg(t,e);n!==t&&Mi(()=>{zg(B,n);let e=Te.state;zg(Te,{...e,awaitingFirstTurn:e.disabled?!1:n}),n&&!p.current.streaming?zg(Tt,{label:`Waiting for first response…`}):!n&&Tt.state?.label===`Waiting for first response…`&&zg(Tt,null)})},[B,Te,Tt]),jt=Z.useCallback(e=>{let t=te.state,n=Rg(t,e);n!==t&&Mi(()=>{zg(te,n);let e=Te.state;zg(Te,{...e,isSubmitting:e.disabled?!1:n})})},[Te,te]),Mt=Z.useCallback(()=>{let e=W.state.map((e,t)=>({pendingId:e.optimisticId||`pending-draft:${t}`,text:e.message,images:e.images,streamingBehavior:e.streamingBehavior})),t=Te.state;zg(Te,{...t,currentPendingMessages:t.disabled?[]:[...e,...ne.state]})},[Te,W,ne]),Pt=Z.useCallback(e=>{let t=H.state,n=Rg(t,e);n!==t&&Mi(()=>{zg(H,n),n?zg(Tt,{label:`Waiting for new session…`}):Tt.state?.label===`Waiting for new session…`&&zg(Tt,null)})},[H,Tt]),Ft=Z.useCallback(e=>{let t=W.state,n=Rg(t,e);n!==t&&Mi(()=>{zg(W,n),Mt()})},[W,Mt]),It=Z.useCallback(e=>{let t=ne.state,n=Rg(t,e);n!==t&&Mi(()=>{zg(ne,n),Mt()})},[ne,Mt]),Rt=Z.useRef(null);Rt.current||=moe({key:`pico.conversation.streaming-items`,wait:16,onLatest:e=>{bt.setItems(e)}});let zt=Rt.current,Bt=Z.useCallback(e=>{if(e.some(e=>e.kind===`assistant`&&e.streaming)&&typeof window<`u`){zt.add(e);return}zt.cancel(),bt.setItems(e)},[zt,bt]);Z.useEffect(()=>()=>{zt.flush(),zt.cancel()},[zt]);let Vt=Z.useCallback((e,t)=>{t?.preserveExisting&&!e||zg(Ct,e)},[Ct]),Ht=Z.useCallback(e=>{zg(Tt,e)},[Tt]),Ut=Z.useCallback(e=>{let t=coe(),n={kind:`user`,itemKey:`pending:${t}`,pendingId:t,text:e.message,images:e.images.map(e=>({...e})),queued:e.queued,streamingBehavior:e.streamingBehavior},r=p.current,i=loe(r.items,n);if(i!==r.items){let e={...r,items:i};p.current=e,bt.setItems(i),dt(e)}return t},[bt]),Wt=Z.useCallback(e=>{if(!e)return;let t=p.current,n=uoe(t.items,e);if(n===t.items)return;let r={...t,items:n};p.current=r,bt.setItems(n),dt(r)},[bt]),{setTheme:Gt,theme:qt}=ue(),Jt=o(qt),{initialLoadingSessionId:Yt,loadingSessionId:Zt}=Ji(g,e=>({initialLoadingSessionId:e.initialLoadingSessionId,loadingSessionId:e.loadingSessionId}),{compare:Pg}),{draftSessionLoadingOwnerKey:Qt,storedDraftDirectory:$t}=Ji(de),en=Ji(f,e=>({cwd:e.cwd,draft:e.draft,sessionFile:e.sessionFile,sessionId:e.sessionId,sessionKey:e.sessionKey}),{compare:Pg}),tn=Z.useCallback(e=>{let t=e.draft?``:e.sessionId?.trim()||``,n=e.draft?``:(e.sessionFile||e.sessionPath||``).trim(),r=e.draft?``:Dg({sessionFile:n,sessionId:t})||e.sessionKey?.trim()||``;i.setSidebarState(e=>e.activeSidebarSessionId===t&&e.activeSidebarSessionKey===r&&e.activeSidebarSessionPath===n?e:{activeSidebarSessionId:t,activeSidebarSessionKey:r,activeSidebarSessionPath:n})},[i]);Z.useLayoutEffect(()=>{tn(en)},[en,tn]);let nn=Ji(g,e=>e.gitPanelOpen),rn=(e,t)=>{e&&Mi(()=>{b(!0),lie(v,e,t)})},on=e=>{uie(v,e)},sn=e=>{die(v,e)},cn=e=>{fie(v,e)},X=()=>{pie(v)},ln=e=>{mie(v,e)},un=()=>{let e=v.state.activeTab;if(ve){X7(v,`review`),y(t=>t===`git`&&e===`review`?`session`:`git`);return}if(nn&&e===`review`){b(!1);return}Mi(()=>{X7(v,`review`),b(!0)})};Z.useEffect(()=>{Q7(v)},[v,en.cwd]),Z.useEffect(()=>{en.draft&&Q7(v)},[v,en.draft]),i_(i,e=>e.derived.workspaceVersion);let{baseSidebarDirectories:dn,directoryStateByPath:fn,directoryIndexes:mn,sidebarSessions:hn,selectedSidebarSessions:gn,sidebarSessionEntriesByKey:_n}=i.getWorkspaceSnapshot(),vn=i_(i,e=>e.state.sessionsEvent?.directories||[],Ag),yn=Z.useRef(e=>{i.setSidebarSessionStatusByKey(t=>Zg(t,e))});yn.current=e=>{i.setSidebarSessionStatusByKey(t=>Zg(t,e))};let bn=en.sessionId||(en.sessionKey?void 0:t),Sn=xn({path:en.sessionFile,id:bn}),Cn=i_(i,e=>Sn?e.state.pinnedSidebarSessionKeys.includes(Sn):!1),wn=ate(en),En=Z.useRef(``);Z.useLayoutEffect(()=>{En.current!==wn&&(En.current=wn,ke.cancel(),zg(De,p.current.contextUsage))},[De,ke,wn]);let Dn=Yt&&!en.sessionKey?Yt:null,On=Zt&&Zt!==en.sessionId?Zt:Dn&&Dn!==en.sessionId?Dn:null,kn=!!On,An=On?hn.find(e=>e.id===On):void 0,jn=Tn(An),Mn=jn===`New session`?`Loading session…`:jn,Nn=kn?An?.cwd:en.cwd;Z.useEffect(()=>{let e=C.current;if(C.current=t,e!==t){if(y(e=>e===`git`?`session`:e),!t){S(null),x(null);return}p.current.sessionId!==t&&x(t)}},[t]),Z.useEffect(()=>{ve||y(e=>e===`git`?`session`:e)},[ve,y]);let Pn=(e,t=p.current)=>{let n=Yx(e),r=n.matched?n.text:e,i=n.matched?n.skillName:void 0;ft.current=r,pt.current=i;let a=T.state;(a.text!==r||a.skillName!==i)&&zg(T,{...a,text:r,skillName:i}),We(t,Xx({text:r,skillName:i}))},Fn=(e,t=p.current,n)=>{let r=Yx(e),i=r.matched?r.text:e,a=r.matched?r.skillName:void 0;ft.current=i,pt.current=a,Ae(e=>{let t=e.text===i&&e.skillName===a,r=n?.forceSync===!0;return t&&!r?e:{text:i,skillName:a,syncNonce:r?e.syncNonce+1:e.syncNonce}}),We(t,Xx({text:i,skillName:a}))},In=Mg(Fn);Z.useEffect(()=>{b(u()),me(E()||``),ae(P()),oe(Be()),F(R()),I(ce()),L(ie()),_e(eee()),se(Kae())},[]);let Ln=()=>{et.current?.close(),nt.current?.close(),Fe.current?.open()},Rn=()=>{Fe.current?.close()},zn=()=>{Fe.current?.close(),nt.current?.close(),et.current?.open()},Bn=()=>{Fe.current?.close(),et.current?.close(),nt.current?.open()},Vn=()=>{Fe.current?.close(),et.current?.close(),nt.current?.close(),Ze.current?.open()},Hn=async t=>{await Promise.all([c.invalidateQueries({queryKey:_g.gitStatus(e,t),exact:!0,refetchType:`active`}),c.invalidateQueries({queryKey:_g.gitFiles(e,t),exact:!0,refetchType:`active`}),c.invalidateQueries({queryKey:_g.gitBranches(e,t),exact:!0,refetchType:`active`}),c.invalidateQueries({queryKey:_g.gitCommits(e,t),exact:!1,refetchType:`active`}),c.invalidateQueries({queryKey:_g.projectFileTree(e,t),exact:!0,refetchType:`active`}),c.invalidateQueries({queryKey:_g.gitFileReviews(e,t),exact:!1,refetchType:`active`})])},Un=Nr({mutationKey:_g.gitAction(e,p.current.cwd?.trim()||``,`push`),mutationFn:async t=>await wh(Ch(`/api/git-push`,{contextId:e}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({cwd:t})}),onSuccess:async(e,t)=>{await Hn(t),Fq({response:e})},onError:e=>{Qe.error(e instanceof Error?e.message:`Failed to push`)}}),Wn=Nr({mutationKey:_g.gitAction(e,p.current.cwd?.trim()||``,`force-push`),mutationFn:async t=>await wh(Ch(`/api/git-push`,{contextId:e}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({cwd:t,force:!0})}),onSuccess:async(e,t)=>{await Hn(t),Fq({response:e,force:!0})},onError:e=>{Qe.error(e instanceof Error?e.message:`Failed to force push`)}}),Gn=Nr({mutationKey:_g.gitAction(e,p.current.cwd?.trim()||``,`pull`),mutationFn:async t=>await wh(Ch(`/api/git-pull`,{contextId:e}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({cwd:t})}),onSuccess:async(e,t)=>{await Hn(t),Qe.success(`Pulled changes`)},onError:e=>{Qe.error(e instanceof Error?e.message:`Failed to pull`)}}),qn=async e=>{let t=p.current.cwd?.trim()||``;if(!t){Qe.error(`Open a session in a repository before running Git actions.`);return}let n=e===`pull`?Gn:e===`force-push`?Wn:Un;Un.isPending||Wn.isPending||Gn.isPending||await n.mutateAsync(t).catch(()=>{})},Jn=async()=>{await qn(`push`)},Yn=async()=>{await qn(`force-push`)},Zn=async()=>{await qn(`pull`)},Qn=()=>{if(ve){y(e=>e===`git`?`session`:`git`);return}b(e=>!e)},$n=()=>{let e=p.current;e.sessionFile&&ze.current?.open({path:e.sessionFile,title:e.sessionName||Fg(e)})},er=e=>{ze.current?.openForEntry(e)},tr=e=>{He.current?.open(e)},nr=e=>{Ge.current?.open(e)},rr=()=>{let e=p.current;e.sessionFile&&tr([{path:e.sessionFile,id:e.sessionId,title:Fg(e),name:e.sessionName,modified:e.modified}])},ir=()=>{Le.current?.open()},ar=async()=>{await qe.current?.open()},or=async()=>{await Ye.current?.open()},sr=()=>{zn()},cr=()=>{if(g.state.currentTab!==`session`&&y(`session`),ve&&(ye||be)){vt.current=!0,ye&&xe(!1);return}window.requestAnimationFrame(()=>{Ce.current?.focusPrompt({preventScroll:!0})})},lr=()=>{Ce.current?.openModelPicker()},ur=Mg(cr),[dr,fr]=Z.useState({sessionId:``,nonce:0}),pr=Z.useRef(null);Z.useEffect(()=>{if(!vt.current||ye||be)return;vt.current=!1;let e=window.setTimeout(()=>{ur.current()},0);return()=>{window.clearTimeout(e)}},[ur,ye,be]),Z.useEffect(()=>{if(kn)return;let e=en.sessionKey||en.sessionId||`draft`;pr.current!==e&&(pr.current=e,ur.current())},[ur,kn,en.sessionId,en.sessionKey]),Z.useEffect(()=>{if(!dr.nonce||kn||dr.sessionId&&en.sessionId!==dr.sessionId)return;let e=window.setTimeout(()=>{ur.current()},50);return()=>{window.clearTimeout(e)}},[ur,kn,dr,en.sessionId]);let mr=e=>{ae(e),ee(Kn,e?`1`:`0`),e&&j9()},hr=async e=>{if(oe(e),ee(m,e?`1`:`0`),!e)return;let t=await qae();se(t),t===`denied`?Qe.info(`Allow notifications for this site in your browser to receive desktop alerts.`):t===`unsupported`&&Qe.error(`Desktop notifications are unavailable in this browser.`)},gr=Z.useCallback((e,t)=>{let n=e?ote(i.state.derived.sidebarSessionEntriesByKey,{sessionId:e,sessionPath:t?.sessionPath}):``;i.setSelectedSidebarSessionKeys(e=>n?Ag(e,[n])?e:[n]:e.length===0?e:[]),i.setSidebarSessionSelectionAnchor(e=>e===n?e:n)},[i]),_r=Z.useCallback((e,t)=>{y(e=>e===`git`?`session`:e),gr(e,t),tn({draft:!e,sessionId:e,sessionPath:t?.sessionPath}),mt.current=e,ht.current=t?.sessionPath?.trim()||void 0,e&&fr(t=>({sessionId:e,nonce:t.nonce+1})),x(t=>e?!p.current.draft&&p.current.sessionId===e?t:e:null),n?.(e,t)},[n,p,tn,gr]),vr=Mg(_r);Boe({viewerContextId:e,sessionId:t,draftSessionLoadingOwnerKey:Qt,bootstrapSidebarDirectories:i.state.state.initialSidebarBootstrapDirectories,hideToolBlocksRef:N,sessionStore:f,sessionStateRef:p,composerTextRef:ft,composerSkillRef:pt,replaceComposerDraftRef:In,handleSelectSessionRef:vr,pendingRouteSessionIdRef:mt,pendingRouteSessionPathRef:ht,setSessionState:dt,setConversationItems:Bt,setHiddenThinkingPreview:Vt,setWorkingState:Ht,setCompactRunningState:Ot,setComposerContextUsage:Ne,setComposerStreaming:Pe,setSessionsEvent:i.setSessionsEvent,setSessionDoneEvents:Y,applySidebarSessionStatusRef:yn,setComposerImages:je,setPendingMessages:It,pendingUiRequestHandlerRef:gt,lastSyncedEditorTextRef:ut}),Z.useEffect(()=>{let e=en.cwd?.trim();e&&(ee(an,e),me(e))},[en.cwd]),Z.useEffect(()=>{let e=en.cwd?.trim(),n=en.sessionId?.trim();if(!t||!n||en.draft||!e||n!==t)return;let r=`${n}\n${e}`;_t.current.has(r)||(_t.current.add(r),i.setSidebarDirectories(t=>{let n=Xt(t);if(n.includes(e))return t;let r=Xt([e,...n]);return ee(Me,JSON.stringify(r)),r}))},[t,en.cwd,en.draft,en.sessionId,i]);let yr=en.cwd?.trim()||dn[0]||$t||``,br=Z.useMemo(()=>{let e=[],t=new Set,n=(n,r)=>{let i=n.trim();!i||t.has(i)||(t.add(i),e.push({path:i,label:r}))};en.cwd?.trim()&&n(en.cwd,`Current session directory`),$t&&n($t,`Draft directory`);for(let e of dn)n(e,`Sidebar directory`);return e},[dn,en.cwd,$t]),xr=Z.useMemo(()=>Xt([...dn,...vn,en.cwd||``,$t,...Array.from(fn.keys()),...Object.values(mn).flatMap(e=>e.map(e=>e.cwd||``))]),[dn,mn,fn,en.cwd,vn,$t]),Sr=en.cwd?.trim()||(dn.length>0?dn[0]??``:$t)||yr,Cr=e=>{let t=e.trim();t&&_e(e=>{let n=Xt([t,...e]).slice(0,8);return ee(ot,JSON.stringify(n)),n})},wr=Z.useCallback(e=>{},[]),Tr=Z.useCallback(()=>{i.setSelectedSidebarSessionKeys(e=>e.length===0?e:[]),i.setSidebarSessionSelectionAnchor(e=>e&&``)},[i]),Er=B.state,Dr=te.state,Or=H.state,kr=W.state,Ar=ne.state,{abortSession:jr,addDirectoryPath:Mr,createSession:Pr,editPendingMessage:Fr,removePendingMessage:Ir,reorderPending:Lr,submitPrompt:Rr}=boe({viewerContextId:e,activeSessionId:bn,defaultNewSessionDirectory:yr,sessionStore:f,sessionStateRef:p,draftSessionLoadingOwnerKey:Qt,pendingDraftPrompt:Or,pendingDraftFollowUps:kr,awaitingFirstTurn:Er,pendingMessages:Ar,composerImagesRef:k,composerTextRef:ft,composerSkillRef:pt,replaceComposerDraft:Fn,lastSyncedEditorTextRef:ut,rememberRecentDirectory:Cr,prefetchDirectorySessionsIndex:wr,addOptimisticUserMessage:Ut,removeOptimisticUserMessage:Wt,setSidebarDirectories:i.setSidebarDirectories,setStoredDraftDirectory:me,setDraftSessionLoadingOwnerKey:pe,setPendingDraftPrompt:Pt,setPendingDraftFollowUps:Ft,setPendingMessages:It,setAwaitingFirstTurn:At,setIsSubmitting:jt,setComposerImages:je}),zr=Z.useCallback(e=>{let t=e.trim();if(!t)return;let n=p.current;if(!n.draft||n.items.length>0)return;ee(an,t),me(t),Cr(t);let r=z9({previous:n,cwd:t,ownerKey:Kt({cwd:t})});p.current=r,bt.setItems(r.items),dt(r),We(r,Xx({text:ft.current,skillName:pt.current}))},[bt,Cr,p,dt,me]),Br=Z.useCallback(async e=>{let t=await Mr(e);return typeof t==`string`&&zr(t),t},[Mr,zr]),Vr=Z.useCallback(async(e,t)=>{let n=e||yr||void 0,r=Kt({cwd:n}),i=`optimistic:${r}`,a=p.current,o=!!t?.closeMobileSidebar&&ve&&ye;_r(void 0),Tr(),o?(vt.current=!0,xe(!1)):cr(),At(!1),It(e=>e.length===0?e:[]);let s=z9({previous:a,cwd:n,ownerKey:r});p.current=s,bt.setItems(s.items),dt(s),!await Pr(e)&&p.current.sessionKey===i&&(p.current=a,bt.setItems(a.items),dt(a))},[Tr,bt,yr,cr,_r,ve,ye,Pr,p,At,xe,It,dt]),Hr=async e=>{if(!e||e.length===0)return;let t=Array.from(e).filter(e=>e.type.startsWith(`image/`));if(t.length===0)return;let n=await Promise.all(t.slice(0,8).map(e=>Th(e)));je(e=>[...e,...n].slice(0,8))},Ur=T.state,Wr=O.state,Gr=kr.map((e,t)=>({pendingId:F9(e,t),text:e.message,images:e.images,streamingBehavior:e.streamingBehavior})),Kr=Gr.length>0||Ar.length>0?[...Gr,...Ar]:L9,qr=kn,Jr=qr?L9:Kr,Yr=qr?I9:Wr,Xr=qr?``:Ur.text,Zr=qr?void 0:Ur.skillName,Qr=(e,t)=>{let n=kr.find((t,n)=>F9(t,n)===e);return n?!t.trim()&&n.images.length===0?(Qe.error(`Enter a message or keep at least one image`),!0):(Ft(n=>n.map((n,r)=>F9(n,r)===e?{...n,message:t}:n)),!0):!1},$r=e=>kr.some((t,n)=>F9(t,n)===e)?(Ft(t=>t.filter((t,n)=>F9(t,n)!==e)),!0):!1,ei=(e,t)=>{let n=ioe(kr,e,t);return n?(Ft(n),!0):!1},ti=Z.useCallback(e=>{if(Ot(e),e){zg(Tt,{label:doe,cancelable:!0});return}if(Dt.current){Dt.current=!1,zg(Tt,{label:foe,error:!0});return}Tt.state?.label===`Compacting context...`&&zg(Tt,null)},[Ot,Tt]),ni=Z.useCallback(()=>Dt.current,[]),{cycleThinkingLevel:ri,deleteSessions:ii,renameSessionPath:ai,runClone:oi,runCompact:si,setModel:ci,setThinkingBlocksHidden:li,setThinkingLevel:ui,toggleHideThinking:di}=Coe({viewerContextId:e,activeSessionId:bn,sessionStateRef:p,setSessionState:dt,getDirectoryIndexDataByPath:()=>i.state.state.directoryIndexDataByPath,setDirectoryIndexDataByPath:i.setDirectoryIndexDataByPath,getSessionsEvent:()=>i.state.state.sessionsEvent,setSessionsEvent:i.setSessionsEvent,getSidebarSelection:()=>{let e=i.state.state;return{selectedSidebarSessionKeys:e.selectedSidebarSessionKeys,sidebarSessionSelectionAnchor:e.sidebarSessionSelectionAnchor}},optimisticallyClearActiveDeletedSession:e=>{let t=p.current;if(t.sessionFile!==e)return;let n=`delete:${e}`,r=`optimistic:${n}`;_r(void 0,{replace:!0});let i=z9({previous:t,cwd:t.cwd,ownerKey:n});return p.current=i,bt.setItems(i.items),dt(i),()=>{p.current.sessionKey===r&&(t.sessionId&&_r(t.sessionId,{replace:!0,sessionPath:t.sessionFile}),p.current=t,bt.setItems(t.items),dt(t))}},setSelectedSidebarSessionKeys:i.setSelectedSidebarSessionKeys,setSidebarSessionSelectionAnchor:i.setSidebarSessionSelectionAnchor,setCompactWorkingState:ti,isCompactAbortRequested:ni}),fi=e=>{F(e),ee(Lt,e?`1`:`0`)},pi=()=>{let e=M.current.hideToolBlocks;fi(!e),Qe.info(e?`Tools shown`:`Tools hidden`)},mi=e=>{I(e),ee(kt,e?`1`:`0`)},hi=e=>{L(e),ee(xt,e?`1`:`0`)},gi=(e=`login`)=>{it.current?.open(e)},_i=async(e,t)=>{let n=t.trim(),r=()=>{Fn(``,p.current,{forceSync:!0})};switch(e){case`login`:if(n){Qe.error(`/login does not take any arguments yet.`);return}r(),gi(`login`);return;case`logout`:if(n){Qe.error(`/logout does not take any arguments yet.`);return}r(),gi(`logout`);return;case`compact`:if(Wr.length>0){Qe.error(`Built-in slash commands do not support images.`);return}r(),await si();return;case`clone`:if(n){Qe.error(`/clone does not take any arguments.`);return}if(Wr.length>0){Qe.error(`Built-in slash commands do not support images.`);return}r(),await oi();return;case`rename`:if(!en.sessionFile){Qe.error(`Start the session before renaming it.`);return}if(!n){r(),$n();return}r(),await ai(en.sessionFile,n);return;case`delete`:if(!en.sessionFile){Qe.error(`Start the session before deleting it.`);return}r(),rr();return;case`fork`:if(n){Qe.error(`/fork does not take any arguments.`);return}r(),await ar();return;case`tree`:if(n){Qe.error(`/tree does not take any arguments.`);return}r(),await or();return;case`hide-thinking`:r(),p.current.hideThinkingBlock||await di();return;case`show-thinking`:r(),p.current.hideThinkingBlock&&await di();return;case`hide-tools`:r(),fi(!0);return;case`show-tools`:r(),fi(!1);return;default:Qe.error(`Unsupported slash command: /${e}`)}},vi=e=>{Gt(e)},yi={activeSessionId:bn,awaitingFirstTurn:qr?!1:Er,centerMessages:M.current.centerMessages,composerImages:Yr,composerSkill:Zr,composerSyncNonce:Ur.syncNonce,composerText:Xr,currentPendingMessages:Jr,disabled:qr,isStreaming:qr?!1:p.current.streaming,isSubmitting:qr?!1:Dr,viewerContextId:e};Z.useLayoutEffect(()=>{zg(Te,yi)});let bi=Mg({abortSession:jr,onPickImages:Hr,onRemoveComposerImage:e=>{je(t=>t.filter((t,n)=>n!==e))},editPendingDraftFollowUp:Qr,editPendingMessage:Fr,removePendingDraftFollowUp:$r,removePendingMessage:Ir,reorderPending:Lr,reorderPendingDraftFollowUp:ei,runBuiltinSlashCommand:_i,setModel:ci,setThinkingLevel:ui,submitPrompt:Rr,syncComposerDraft:Pn}),xi=Mg({gitPanelOpen:nn,hasAvailableModels:p.current.availableModels.length>0,isMobile:ve,selectedSidebarSessions:gn,sessionFile:en.sessionFile}),Si=Mg(()=>{let e=xi.current,t=p.current.hideThinkingBlock,n=p.current.thinkingLevel,r=[{id:`new-session`,group:`Sessions`,title:`New session`,description:`Create a new draft session`,shortcut:Uh(`Control+N`),keywords:[`create`,`draft`,`session`],onSelect:Vr},{id:`open-sessions`,group:`Sessions`,title:`Open sessions`,description:`Search and switch sessions`,shortcut:Uh(`Control+S`),keywords:[`session`,`search`,`switch`,`jump`],onSelect:zn},{id:`open-git-view`,group:`Git`,title:e.isMobile?`Toggle right sidebar tab`:e.gitPanelOpen?`Close right sidebar`:`Open right sidebar`,description:e.isMobile?`Switch the mobile right sidebar tab on or off`:`Toggle the right sidebar`,shortcut:Uh(`Control+\\`),keywords:[`right`,`sidebar`,`git`,`changes`,`branch`,`commit`,`panel`],onSelect:Qn},{id:`commit-changes`,group:`Git`,title:`Commit changes`,description:`Open the Git commit dialog`,shortcut:Uh(`Control+C`),keywords:[`git`,`commit`,`changes`,`stage`],onSelect:Vn},{id:`push-changes`,group:`Git`,title:`Push changes`,description:`Push local commits to the remote`,shortcut:Uh(`Control+P`),keywords:[`git`,`push`,`remote`,`upstream`],onSelect:Jn},{id:`force-push-changes`,group:`Git`,title:`Force push changes`,description:`Force push local commits with --force-with-lease`,shortcut:Uh(`Control+Shift+P`),keywords:[`git`,`force`,`push`,`remote`,`upstream`,`lease`],onSelect:Yn},{id:`pull-changes`,group:`Git`,title:`Pull changes`,description:`Pull remote changes into the current branch`,shortcut:Uh(`Alt+P`),keywords:[`git`,`pull`,`remote`,`upstream`],onSelect:Zn},{id:`focus-prompt`,group:`Assistant`,title:`Focus prompt`,description:`Move focus to the prompt field`,shortcut:Uh(`Control+Enter`),keywords:[`prompt`,`composer`,`input`,`message`,`reply`],onSelect:cr},{id:`set-model`,group:`Assistant`,title:`Set model`,description:`Open the model picker`,shortcut:Uh(`Control+M`),keywords:[`model`,`provider`,`picker`,`choose`],onSelect:()=>{if(!xi.current.hasAvailableModels)throw Error(`No models are available right now.`);lr()}},{id:`add-directory`,group:`Sidebar`,title:`Add Directory`,description:`Add a directory accordion to the sidebar`,shortcut:Uh(`Control+D`),keywords:[`workspace`,`sidebar`,`directory`,`folder`],onSelect:ir},{id:`tree-session`,group:`Sessions`,title:`Open tree`,description:`Jump to an earlier point in the current session tree`,shortcut:`Esc Esc`,keywords:[`tree`,`branch`,`history`,`navigate`],onSelect:or},{id:`fork-session`,group:`Sessions`,title:`Fork session`,description:`Create a new session from a previous user message`,shortcut:Uh(`Control+F`),keywords:[`fork`,`branch`,`draft`],onSelect:ar},{id:`clone-session`,group:`Sessions`,title:`Clone session`,description:`Duplicate the current active branch into a new session`,keywords:[`clone`,`branch`,`duplicate`,`session`],onSelect:oi},{id:`compact-session`,group:`Sessions`,title:`Compact`,description:`Manually compact the session context with /compact`,keywords:[`compact`,`context`,`compress`,`summarize`],onSelect:si},{id:`toggle-thinking`,group:`Assistant`,title:t?`Show thinking blocks`:`Hide thinking blocks`,description:t?`Show assistant thinking blocks`:`Hide assistant thinking blocks`,shortcut:Uh(`Control+T`),keywords:[`thinking`,`reasoning`,`visibility`,`show`,`hide`],onSelect:di},{id:`cycle-reasoning`,group:`Assistant`,title:`Next reasoning level`,description:`Current level: ${n}`,shortcut:Uh(`Control+R`),keywords:[`thinking`,`reasoning`,`level`,`cycle`,`next`],onSelect:()=>{ri(1)}},{id:`previous-reasoning`,group:`Assistant`,title:`Previous reasoning level`,description:`Current level: ${n}`,shortcut:Uh(`Control+Shift+R`),keywords:[`thinking`,`reasoning`,`level`,`cycle`,`previous`,`back`],onSelect:()=>{ri(-1)}},{id:`toggle-review-pane`,group:`Git`,title:`Toggle Review Pane`,description:`Toggle the review pane for changed files`,keywords:[`review`,`diff`,`file`,`changes`,`pane`],onSelect:un},{id:`toggle-tools`,group:`Assistant`,title:M.current.hideToolBlocks?`Show tool calls`:`Hide tool calls`,description:M.current.hideToolBlocks?`Show assistant tool calls`:`Hide assistant tool calls`,shortcut:Uh(`Control+O`),keywords:[`tools`,`tool calls`,`visibility`,`show`,`hide`],onSelect:pi},{id:`login-provider`,group:`App`,title:`Login to provider`,description:`Configure provider API key or subscription auth`,keywords:[`login`,`auth`,`api key`,`oauth`,`provider`],onSelect:()=>gi(`login`)},{id:`logout-provider`,group:`App`,title:`Logout from provider`,description:`Remove stored provider credentials`,keywords:[`logout`,`auth`,`api key`,`oauth`,`provider`],onSelect:()=>gi(`logout`)},{id:`open-settings`,group:`App`,title:`Open settings`,description:`Open app settings`,shortcut:Uh(`Control+,`),keywords:[`settings`,`theme`,`notifications`,`display`],onSelect:Bn}];return e.sessionFile&&(r.splice(1,0,{id:`rename-session`,group:`Sessions`,title:`Rename session`,description:`Rename the current session`,shortcut:Uh(`Control+E`),keywords:[`rename`,`title`,`name`],onSelect:$n}),r.push({id:`delete-session`,group:`Sessions`,title:`Delete session`,description:`Delete ${Fg(p.current)}`,shortcut:Uh(`Control+X`),keywords:[`delete`,`remove`,`session`],onSelect:rr})),e.selectedSidebarSessions.length>0&&r.push({id:`delete-selected-sessions`,group:`Sidebar`,title:`Delete selected sidebar sessions`,description:`Delete ${e.selectedSidebarSessions.length} selected sidebar ${e.selectedSidebarSessions.length===1?`session`:`sessions`}`,keywords:[`delete`,`selected`,`sidebar`,`sessions`],onSelect:()=>{tr(xi.current.selectedSidebarSessions)}}),r}),Ci=Z.useCallback(async()=>{Et.current&&(Dt.current=!0,await jr())},[jr]),wi=Mg({abortCompact:Ci,abortSession:jr,createSession:Vr,closeCommandPalette:Rn,forcePushGitChanges:Yn,focusModelSelector:lr,focusPrompt:cr,focusSessionSearch:sr,jumpToNextMessage:()=>{lt.current?.jumpToNextMessage()},jumpToPreviousMessage:()=>{lt.current?.jumpToPreviousMessage()},openAddDirectoryDialog:ir,openCommandPalette:Ln,openCommitDialog:Vn,openDeleteDialog:tr,openDeleteDialogForCurrentSession:rr,openForkDialog:ar,openRenameDialog:$n,openSessionsDialog:zn,openSettingsDialog:Bn,openTreeDialog:or,pullGitChanges:Zn,pushGitChanges:Jn,scrollConversationToBottom:()=>{lt.current?.scrollConversationToBottom()},scrollConversationToTop:()=>{lt.current?.scrollConversationToTop()},toggleGitPanel:Qn,toggleHideThinking:di,toggleHideToolBlocks:pi,cycleThinkingLevel:ri}),Ti=Mg({currentTab:ve?g.state.currentTab:`session`,selectedSidebarSessions:gn,sessionHasAvailableModels:p.current.availableModels.length>0,sessionHasFile:!!en.sessionFile,sessionIsStreaming:p.current.streaming,sidebarSessionEntriesByKey:_n}),Ei=Mg({createSession:Vr,onDeleteCurrentSession:rr,onForkSession:ar,onRenameSession:$n,onRunCompact:si,onToggleCurrentSessionPinned:()=>{let e=p.current,t=xn({path:e.sessionFile,id:e.sessionId});t&&i.setPinnedSidebarSessionKeys(e=>{let n=fe(e),r=n.includes(t)?n.filter(e=>e!==t):[t,...n];return ee(Nt,JSON.stringify(r)),r})},onToggleHideThinking:di,onToggleHideToolBlocks:pi,onTreeSession:or});Yoe({addDirectoryOpenRef:Re,commandPaletteOpenRef:Ie,compactRunningRef:Et,deleteOpenRef:Ue,forkOpenRef:Je,gitCommitOpenRef:$e,pendingUiRequestOpenRef:ct,renameOpenRef:Ve,sessionSearchInputRef:a,sessionsOpenRef:tt,settingsOpenRef:rt,shortcutActionsRef:wi,shortcutStateRef:Ti,treeOpenRef:Xe});let Di=Z.useRef(null);return Di.current={stores:{appUi:g,composer:Te,contextUsage:De,conversationItems:bt,displaySettings:j,draftFlow:de,notification:J,rightSidebar:v,session:f,sidebar:i},refs:{composerImages:k,composerPanel:Ce,composerSkill:pt,composerText:ft,conversationFrame:lt,sessionState:p},actions:{createSession:Vr,focusModelSelector:lr,focusPrompt:cr,focusSessionSearch:sr,openAddDirectoryDialog:ir,openCommandPalette:Ln,openDeleteDialog:tr,openDeleteOldDirectorySessionsDialog:nr,openRenameDialogForEntry:er,openSessionsDialog:zn,openSettingsDialog:Bn,selectSession:_r}},Z.useImperativeHandle(s,()=>{let e=Di.current?.actions;return{createSession:e?.createSession??Vr,openAddDirectoryDialog:e?.openAddDirectoryDialog??ir,openCommandPalette:e?.openCommandPalette??Ln,openDeleteDialog:e?.openDeleteDialog??tr,openDeleteOldDirectorySessionsDialog:e?.openDeleteOldDirectorySessionsDialog??nr,openRenameDialogForEntry:e?.openRenameDialogForEntry??er,openSessionsDialog:e?.openSessionsDialog??zn,openSettingsDialog:e?.openSettingsDialog??Bn,selectSession:e?.selectSession??_r}},[Vr,_r,ir,Ln,tr,nr,er,zn,Bn]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Yae,{isSessionViewLoading:kn,loadingDisplaySessionTitle:Mn,notificationStore:J,sessionStore:f,sidebarStore:i,onSelectSession:_r}),(0,Q.jsx)(Fie,{actionsRef:Ei,defaultNewSessionDirectory:yr,displaySessionCwd:Nn,gitPanelOpen:nn,loadingDisplaySessionTitle:Mn,currentSessionPinned:Cn,displaySettingsStore:j,isSessionViewLoading:kn,newSessionDirectoryOptions:br,onToggleGitPanel:Qn,sessionStore:f,viewerContextId:e}),(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[r,(0,Q.jsx)(Jc,{className:`min-h-0 overflow-hidden`,children:(0,Q.jsx)(kie,{actionsRef:bi,appUiStore:g,composerPanelRef:Ce,contextUsageStore:De,conversationFrameRef:lt,conversationItemsStore:bt,defaultNewSessionDirectory:yr,displaySettingsStore:j,fileInputRef:Se,gitPanelOpen:nn,hiddenThinkingPreviewStore:Ct,isSessionViewLoading:kn,isSubmitting:Dr,isMobile:ve,newSessionDirectoryOptions:br,onCancelCompaction:Ci,onCreateSession:e=>{Vr(e)},onOpenAddDirectoryDialog:ir,onCloseAllFileViewTabs:X,onCloseFileViewTab:on,onCloseFileViewTabsToRight:cn,onCloseOtherFileViewTabs:sn,onOpenFileViewTab:rn,onReorderFileViewTabs:ln,rightSidebarStore:v,sessionStore:f,store:Te,viewerContextId:e,workingStateStore:Tt,awaitingFirstTurn:Er,onValueChange:y})})]}),(0,Q.jsx)(hv,{activeSessionId:bn,addDirectoryDialogRef:Le,addDirectoryOpenRef:Re,addDirectoryPath:Br,baseSidebarDirectories:dn,commandPaletteCommandsRef:Si,commandPaletteOpenRef:Ie,commandPaletteRef:Fe,currentSessionQueryScope:wn,currentTheme:Jt,authDialogRef:it,authOpenRef:at,deleteDialogRef:He,deleteOpenRef:Ue,deleteSessions:ii,deleteOldDirectorySessionsDialogRef:Ge,deleteOldDirectorySessionsOpenRef:Ke,notificationStore:J,forkDialogRef:qe,forkOpenRef:Je,gitCommitDialogRef:Ze,gitCommitOpenRef:$e,displaySettingsStore:j,knownDirectories:xr,onAutoScrollEnabledChange:hi,onCenterMessagesChange:mi,onHideThinkingBlocksChange:e=>{li(e)},onHideToolBlocksChange:fi,onSessionDoneDesktopNotificationsEnabledChange:hr,onSessionDoneSoundEnabledChange:mr,onSessionDialogSelect:_r,onThemeChange:vi,recentDirectoriesStore:ge,renameDialogRef:ze,renameOpenRef:Ve,renameSessionPath:ai,sessionCwd:en.cwd,sessionsDialogDirectory:Sr,sessionsDialogRef:et,sessionsOpenRef:tt,sessionStore:f,settingsDialogRef:nt,settingsOpenRef:rt,sidebarStore:i,treeDialogRef:Ye,treeOpenRef:Xe,uiRequestDialogRef:st,uiRequestOpenRef:ct,viewerContextId:e})]})});function Qoe({sessionId:e,onSelectSession:t}){let[n,r]=Z.useState(``),i=Z.useRef(null);i.current||=r_();let a=i.current,o=Z.useRef(null),s=Z.useRef(null);return Z.useEffect(()=>{let e=window.localStorage.getItem(`pico-context-id`)?.trim()||v();ee(S,e),r(e);let t=Xt(Ie().directories),n=t.slice(0,Xoe),i=q();a.setSidebarState(e=>Ag(e.sidebarDirectories,t)&&Ag(e.initialSidebarBootstrapDirectories,n)&&Ag(e.pinnedSidebarSessionKeys,i)?e:{sidebarDirectories:t,initialSidebarBootstrapDirectories:n,pinnedSidebarSessionKeys:i})},[a]),(0,Q.jsx)(Wc,{className:`h-full flex-col overflow-hidden bg-background [--header-height:3rem]`,children:(0,Q.jsx)(Zoe,{ref:s,viewerContextId:n,sessionId:e,onSelectSession:t,sidebar:(0,Q.jsx)(xae,{viewerContextId:n,sidebarStore:a,sessionWorkspaceRef:s}),sidebarStore:a,sessionSearchInputRef:o})})}function $oe(){let e=(0,$.c)(6),{session:t}=Nn.useSearch(),n=Nn.useNavigate(),r;e[0]!==n||e[1]!==t?(r=(e,r)=>{let i=e||void 0;i!==t&&n({search:e=>({...e,session:i}),replace:r?.replace??!1})},e[0]=n,e[1]=t,e[2]=r):r=e[2];let i;return e[3]!==t||e[4]!==r?(i=(0,Q.jsx)(Qoe,{sessionId:t,onSelectSession:r}),e[3]=t,e[4]=r,e[5]=i):i=e[5],i}export{$oe as component};
|