@inkeep/open-knowledge 0.0.0-dev-20260430084452 → 0.0.0-dev-20260430143017

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/cli.mjs +5 -5
  2. package/dist/constants-CxQqeafL.mjs +2 -0
  3. package/dist/{dist-BDg14jGz.mjs → dist-CgDgVcCw.mjs} +2 -2
  4. package/dist/{dist-lH1rFykQ.mjs → dist-DIvHbLlg.mjs} +7 -6
  5. package/dist/{dist-z6Pnn4ba.mjs → dist-EY8HptxY.mjs} +1 -1
  6. package/dist/index.mjs +1 -1
  7. package/dist/init-B3uGrxky.mjs +1 -0
  8. package/dist/init-Bjf0qJPH.mjs +1 -0
  9. package/dist/{init-B17CsUv4.mjs → init-DUoMa9vS.mjs} +3 -3
  10. package/dist/{init-Dzyn5Ju0.mjs → init-M_iZj3b4.mjs} +2 -2
  11. package/dist/loader-CDwZoOZT.mjs +1 -0
  12. package/dist/{loader-zFw4KIRl.mjs → loader-DtQHwYLI.mjs} +2 -2
  13. package/dist/paths-BDTDW9fv.mjs +1 -0
  14. package/dist/paths-D6PiyuBM.mjs +2 -0
  15. package/dist/{preview-2t4ui9wU.mjs → preview-BdpgALxC.mjs} +2 -2
  16. package/dist/preview-Bik03UEr.mjs +1 -0
  17. package/dist/public/assets/{ActivityModeContent-BvIa8sg6.js → ActivityModeContent-BTaFD1U9.js} +1 -1
  18. package/dist/public/assets/DocumentContext-DAIo0tO4.js +33 -0
  19. package/dist/public/assets/{GraphPanel-OfJ6ZXTH.js → GraphPanel-T5dT_tWz.js} +1 -1
  20. package/dist/public/assets/{SettingsPane-dPT0GR3e.js → SettingsPane-DI69uSJ8.js} +1 -1
  21. package/dist/public/assets/{SourceEditor-DnN8ecIW.js → SourceEditor-DETsdSVD.js} +2 -2
  22. package/dist/public/assets/{clipboard-B7tjjy0f.js → clipboard-u6JJjR6P.js} +1 -1
  23. package/dist/public/assets/{config-validation-events-CClJAn-U.js → config-validation-events-DVkEzAED.js} +1 -1
  24. package/dist/public/assets/{index-D2CyGhtn.js → index-Cw2rGin_.js} +3 -3
  25. package/dist/public/assets/index-DmIpWOAZ.css +1 -0
  26. package/dist/public/assets/{target-navigation-intent-CQjWevWz.js → target-navigation-intent-DNQiDIT9.js} +1 -1
  27. package/dist/public/assets/{toggle-group-cRp8rv2M.js → toggle-group-Dn9Kc8gY.js} +1 -1
  28. package/dist/public/assets/{tooltip-Br-RALG_.js → tooltip-DHY5QgRr.js} +1 -1
  29. package/dist/public/index.html +8 -8
  30. package/dist/{server-DA6nsbFj.mjs → server-CTsFrqmD.mjs} +2 -2
  31. package/dist/src-K3thD12M.mjs +1 -0
  32. package/dist/start-CRIGht80.mjs +1 -0
  33. package/dist/{start-DCDH6QD1.mjs → start-CaJ1XX6a.mjs} +2 -2
  34. package/package.json +1 -1
  35. package/dist/constants-DAMd3G6l.mjs +0 -2
  36. package/dist/init-BYQ11BLZ.mjs +0 -1
  37. package/dist/init-C7naYfb0.mjs +0 -1
  38. package/dist/loader-DfW4SP3a.mjs +0 -1
  39. package/dist/paths-BrKyXWk0.mjs +0 -1
  40. package/dist/paths-lZiOnd-N.mjs +0 -2
  41. package/dist/preview-Cj0YGJun.mjs +0 -1
  42. package/dist/public/assets/DocumentContext-BPdAgLvW.js +0 -33
  43. package/dist/public/assets/index-C5vN2roo.css +0 -1
  44. package/dist/src-E9tVI5Hq.mjs +0 -1
  45. package/dist/start-CjOssqIN.mjs +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./telemetry-impl-DF7KVxgp.js","./chunk-DECur_0Z.js","./propagation-api-LnD10wq2.js","./trace-api-CbLDdnQA.js","./McpConsentDialogBody-BKRS2Qm0.js","./button-CXhPNzpp.js","./compiler-runtime-Y11fyRVL.js","./dialog-CJazZw1E.js","./mcp-consent-store-BBTXqzE6.js","./ActivityPanelDiffView-C1vRNF09.js","./ActivityPanelDiffView-legcy4jI.css","./GraphPanel-OfJ6ZXTH.js","./toggle-group-cRp8rv2M.js","./w3c-keyname-B5t0fahT.js","./tooltip-Br-RALG_.js","./panel-DiSt1efw.js","./target-navigation-intent-CQjWevWz.js","./circle-check-bKAq6pcI.js","./ActivityModeContent-BvIa8sg6.js","./DocumentContext-BPdAgLvW.js","./dist-oNAFjGrp.js","./dist-dkPJvrfr.js","./dist-RVD4DzGH.js","./agent-presence-XtMgnv3n.js","./SourceEditor-DnN8ecIW.js","./clipboard-B7tjjy0f.js","./SettingsPane-dPT0GR3e.js","./config-validation-events-CClJAn-U.js"])))=>i.map(i=>d[i]);
2
- import{r as e,t}from"./chunk-DECur_0Z.js";import{i as n}from"./propagation-api-LnD10wq2.js";import{n as r,r as i,t as a}from"./compiler-runtime-Y11fyRVL.js";import{A as o,C as s,D as c,E as l,O as u,S as d,T as f,_ as p,a as m,b as h,c as g,d as _,f as v,g as y,h as b,i as x,k as S,l as C,m as w,n as T,o as E,p as D,r as O,s as k,t as A,u as j,v as M,w as N,x as P,y as F}from"./panel-DiSt1efw.js";import{A as I,An as L,Bn as R,Cn as z,Dn as B,En as V,F as H,Fn as U,G as W,Hn as G,In as ee,It as K,J as te,K as ne,Ln as re,Lt as ie,Mn as ae,Nn as oe,Nt as se,On as ce,Pn as le,Pt as ue,Qt as de,Rn as fe,Rt as pe,Sn as me,T as he,Tn as ge,Ut as _e,Vn as ve,Wt as ye,Y as be,Zt as xe,_ as Se,_t as Ce,a as we,at as Te,bn as Ee,cn as De,dt as Oe,et as ke,f as Ae,ft as je,g as Me,gt as Ne,i as Pe,jn as Fe,k as Ie,kn as Le,l as Re,ln as ze,lt as Be,mt as Ve,n as He,nt as Ue,o as We,ot as Ge,p as Ke,q as qe,r as Je,rn as Ye,t as Xe,tn as Ze,tt as Qe,u as $e,un as et,w as tt,wn as nt,xn as rt,yn as it,z as at,zn as ot}from"./toggle-group-cRp8rv2M.js";import{S as st,a as ct,b as lt,c as ut,f as dt,g as ft,h as pt,i as mt,m as ht,n as q,o as gt,p as _t,r as vt,s as yt,t as J,u as bt,v as xt,x as Y,y as St}from"./button-CXhPNzpp.js";import{A as Ct,B as wt,C as Tt,Ct as Et,D as Dt,Dt as Ot,E as kt,Et as At,F as jt,G as Mt,I as Nt,J as Pt,K as Ft,L as It,M as Lt,Mt as Rt,N as zt,Nt as Bt,O as Vt,Ot as Ht,P as Ut,Pt as Wt,R as Gt,S as Kt,St as qt,T as Jt,Tt as Yt,U as Xt,V as Zt,Y as Qt,Z as $t,_ as en,_t as tn,a as nn,b as rn,bt as an,c as on,d as sn,dt as cn,f as ln,ft as un,g as dn,gt as fn,ht as pn,i as mn,j as hn,jt as gn,k as _n,kt as vn,l as yn,lt as bn,mt as xn,n as Sn,o as Cn,pt as wn,q as Tn,r as En,s as Dn,t as On,u as kn,ut as An,v as jn,vt as Mn,w as Nn,wt as Pn,x as Fn,xt as In,y as Ln,yt as Rn,z as zn}from"./DocumentContext-BPdAgLvW.js";import{a as Bn,c as Vn,d as Hn,f as Un,i as Wn,l as Gn,m as Kn,n as qn,o as Jn,p as Yn,r as Xn,s as Zn,t as Qn,u as $n}from"./agent-presence-XtMgnv3n.js";import{a as er,c as tr,i as nr,o as rr,r as ir,s as ar,t as or}from"./config-validation-events-CClJAn-U.js";import{n as sr,r as cr,t as lr}from"./target-navigation-intent-CQjWevWz.js";import{t as ur}from"./circle-check-bKAq6pcI.js";import{S as dr,_ as fr,a as pr,b as mr,c as hr,f as gr,g as _r,h as vr,i as yr,l as br,m as xr,n as Sr,o as Cr,p as wr,r as Tr,s as Er,t as Dr,u as Or,v as kr,x as Ar,y as jr}from"./dialog-CJazZw1E.js";import{n as Mr,t as Nr}from"./mcp-consent-store-BBTXqzE6.js";import{i as Pr,n as Fr,r as Ir,t as Lr}from"./tooltip-Br-RALG_.js";import{At as Rr,C as zr,Dt as Br,Et as Vr,F as Hr,Ft as Ur,Nt as Wr,O as Gr,Pt as Kr,Q as qr,St as Jr,X as Yr,Y as Xr,Z as Zr,it as Qr,jt as $r,kt as ei,q as ti,wt as ni,yt as ri}from"./dist-dkPJvrfr.js";import{a as ii,d as ai,i as oi,n as si,o as ci,r as li,s as ui}from"./clipboard-B7tjjy0f.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function di(){({BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1})?.VITE_OTEL_ENABLED===`true`&&n(()=>import(`./telemetry-impl-DF7KVxgp.js`).then(e=>e.install()),__vite__mapDeps([0,1,2,3]),import.meta.url)}function fi(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{y(e,()=>t.signal,()=>n=!0)},u=F(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject();if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?M:p;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?mi:pi,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:pi(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function pi(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function mi(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var hi=class extends v{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||gi(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=D({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}})(this.state),b.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function gi(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var _i=class extends o{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new hi({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=vi(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=vi(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=vi(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=vi(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){b.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>s(t,e))}findAll(e={}){return this.getAll().filter(t=>s(e,t))}notify(e){b.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return b.batch(()=>Promise.all(e.map(e=>e.continue().catch(f))))}};function vi(e){return e.options.scope?.id}var yi=class extends o{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??d(r,t),a=this.get(i);return a||(a=new _({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){b.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>N(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>N(e,t)):t}notify(e){b.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){b.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){b.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},bi=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new yi,this.#t=e.mutationCache||new _i,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=S.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=w.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(c(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=h(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return b.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;b.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return b.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=b.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(f).catch(f)}invalidateQueries(e,t={}){return b.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=b.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(f)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(f)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(c(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(f).catch(f)}fetchInfiniteQuery(e){return e.behavior=fi(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(f).catch(f)}ensureInfiniteQueryData(e){return e.behavior=fi(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return w.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(P(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{l(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(P(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{l(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=d(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===u&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},xi=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Si=t(((e,t)=>{t.exports=xi()})),Ci=t((e=>{var t=Si(),n=r(),i=st();function a(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function o(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function s(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function c(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function u(e){if(s(e)!==e)throw Error(a(188))}function d(e){var t=e.alternate;if(!t){if(t=s(e),t===null)throw Error(a(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return u(i),e;if(o===r)return u(i),t;o=o.sibling}throw Error(a(188))}if(n.return!==r.return)n=i,r=o;else{for(var c=!1,l=i.child;l;){if(l===n){c=!0,n=i,r=o;break}if(l===r){c=!0,r=i,n=o;break}l=l.sibling}if(!c){for(l=o.child;l;){if(l===n){c=!0,n=o,r=i;break}if(l===r){c=!0,r=o,n=i;break}l=l.sibling}if(!c)throw Error(a(189))}}if(n.alternate!==r)throw Error(a(190))}if(n.tag!==3)throw Error(a(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}var p=Object.assign,m=Symbol.for(`react.element`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.memo_cache_sentinel`),k=Symbol.iterator;function A(e){return typeof e!=`object`||!e?null:(e=k&&e[k]||e[`@@iterator`],typeof e==`function`?e:null)}var j=Symbol.for(`react.client.reference`);function M(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===j?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case D:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case g:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case T:return t=e.displayName||null,t===null?M(e.type)||`Memo`:t;case E:t=e._payload,e=e._init;try{return M(e(t))}catch{}}return null}var N=Array.isArray,P=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I={pending:!1,data:null,method:null,action:null},L=[],R=-1;function z(e){return{current:e}}function B(e){0>R||(e.current=L[R],L[R]=null,R--)}function V(e,t){R++,L[R]=e.current,e.current=t}var H=z(null),U=z(null),W=z(null),G=z(null);function ee(e,t){switch(V(W,t),V(U,e),V(H,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Hd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Hd(t),e=Ud(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}B(H),V(H,e)}function K(){B(H),B(U),B(W)}function te(e){e.memoizedState!==null&&V(G,e);var t=H.current,n=Ud(t,e.type);t!==n&&(V(U,e),V(H,n))}function ne(e){U.current===e&&(B(H),B(U)),G.current===e&&(B(G),$f._currentValue=I)}var re,ie;function ae(e){if(re===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);re=t&&t[1]||``,ie=-1<e.stack.indexOf(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./telemetry-impl-DF7KVxgp.js","./chunk-DECur_0Z.js","./propagation-api-LnD10wq2.js","./trace-api-CbLDdnQA.js","./McpConsentDialogBody-BKRS2Qm0.js","./button-CXhPNzpp.js","./compiler-runtime-Y11fyRVL.js","./dialog-CJazZw1E.js","./mcp-consent-store-BBTXqzE6.js","./ActivityPanelDiffView-C1vRNF09.js","./ActivityPanelDiffView-legcy4jI.css","./GraphPanel-T5dT_tWz.js","./toggle-group-Dn9Kc8gY.js","./w3c-keyname-B5t0fahT.js","./tooltip-DHY5QgRr.js","./panel-DiSt1efw.js","./target-navigation-intent-DNQiDIT9.js","./circle-check-bKAq6pcI.js","./ActivityModeContent-BTaFD1U9.js","./DocumentContext-DAIo0tO4.js","./dist-oNAFjGrp.js","./dist-dkPJvrfr.js","./dist-RVD4DzGH.js","./agent-presence-XtMgnv3n.js","./SourceEditor-DETsdSVD.js","./clipboard-u6JJjR6P.js","./SettingsPane-DI69uSJ8.js","./config-validation-events-DVkEzAED.js"])))=>i.map(i=>d[i]);
2
+ import{r as e,t}from"./chunk-DECur_0Z.js";import{i as n}from"./propagation-api-LnD10wq2.js";import{n as r,r as i,t as a}from"./compiler-runtime-Y11fyRVL.js";import{A as o,C as s,D as c,E as l,O as u,S as d,T as f,_ as p,a as m,b as h,c as g,d as _,f as v,g as y,h as b,i as x,k as S,l as C,m as w,n as T,o as E,p as D,r as O,s as k,t as A,u as j,v as M,w as N,x as P,y as F}from"./panel-DiSt1efw.js";import{A as I,An as L,Bn as R,Cn as z,Dn as B,En as V,F as H,Fn as U,G as W,Hn as G,In as ee,It as K,J as te,K as ne,Ln as re,Lt as ie,Mn as ae,Nn as oe,Nt as se,On as ce,Pn as le,Pt as ue,Qt as de,Rn as fe,Rt as pe,Sn as me,T as he,Tn as ge,Ut as _e,Vn as ve,Wt as ye,Y as be,Zt as xe,_ as Se,_t as Ce,a as we,at as Te,bn as Ee,cn as De,dt as Oe,et as ke,f as Ae,ft as je,g as Me,gt as Ne,i as Pe,jn as Fe,k as Ie,kn as Le,l as Re,ln as ze,lt as Be,mt as Ve,n as He,nt as Ue,o as We,ot as Ge,p as Ke,q as qe,r as Je,rn as Ye,t as Xe,tn as Ze,tt as Qe,u as $e,un as et,w as tt,wn as nt,xn as rt,yn as it,z as at,zn as ot}from"./toggle-group-Dn9Kc8gY.js";import{S as st,a as ct,b as lt,c as ut,f as dt,g as ft,h as pt,i as mt,m as ht,n as q,o as gt,p as _t,r as vt,s as yt,t as J,u as bt,v as xt,x as Y,y as St}from"./button-CXhPNzpp.js";import{A as Ct,B as wt,C as Tt,Ct as Et,D as Dt,Dt as Ot,E as kt,Et as At,F as jt,G as Mt,I as Nt,J as Pt,K as Ft,L as It,M as Lt,Mt as Rt,N as zt,Nt as Bt,O as Vt,Ot as Ht,P as Ut,Pt as Wt,R as Gt,S as Kt,St as qt,T as Jt,Tt as Yt,U as Xt,V as Zt,Y as Qt,Z as $t,_ as en,_t as tn,a as nn,b as rn,bt as an,c as on,d as sn,dt as cn,f as ln,ft as un,g as dn,gt as fn,ht as pn,i as mn,j as hn,jt as gn,k as _n,kt as vn,l as yn,lt as bn,mt as xn,n as Sn,o as Cn,pt as wn,q as Tn,r as En,s as Dn,t as On,u as kn,ut as An,v as jn,vt as Mn,w as Nn,wt as Pn,x as Fn,xt as In,y as Ln,yt as Rn,z as zn}from"./DocumentContext-DAIo0tO4.js";import{a as Bn,c as Vn,d as Hn,f as Un,i as Wn,l as Gn,m as Kn,n as qn,o as Jn,p as Yn,r as Xn,s as Zn,t as Qn,u as $n}from"./agent-presence-XtMgnv3n.js";import{a as er,c as tr,i as nr,o as rr,r as ir,s as ar,t as or}from"./config-validation-events-DVkEzAED.js";import{n as sr,r as cr,t as lr}from"./target-navigation-intent-DNQiDIT9.js";import{t as ur}from"./circle-check-bKAq6pcI.js";import{S as dr,_ as fr,a as pr,b as mr,c as hr,f as gr,g as _r,h as vr,i as yr,l as br,m as xr,n as Sr,o as Cr,p as wr,r as Tr,s as Er,t as Dr,u as Or,v as kr,x as Ar,y as jr}from"./dialog-CJazZw1E.js";import{n as Mr,t as Nr}from"./mcp-consent-store-BBTXqzE6.js";import{i as Pr,n as Fr,r as Ir,t as Lr}from"./tooltip-DHY5QgRr.js";import{At as Rr,C as zr,Dt as Br,Et as Vr,F as Hr,Ft as Ur,Nt as Wr,O as Gr,Pt as Kr,Q as qr,St as Jr,X as Yr,Y as Xr,Z as Zr,it as Qr,jt as $r,kt as ei,q as ti,wt as ni,yt as ri}from"./dist-dkPJvrfr.js";import{a as ii,d as ai,i as oi,n as si,o as ci,r as li,s as ui}from"./clipboard-u6JJjR6P.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function di(){({BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1})?.VITE_OTEL_ENABLED===`true`&&n(()=>import(`./telemetry-impl-DF7KVxgp.js`).then(e=>e.install()),__vite__mapDeps([0,1,2,3]),import.meta.url)}function fi(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{y(e,()=>t.signal,()=>n=!0)},u=F(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject();if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?M:p;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?mi:pi,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:pi(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function pi(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function mi(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var hi=class extends v{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||gi(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=D({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}})(this.state),b.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function gi(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var _i=class extends o{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new hi({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=vi(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=vi(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=vi(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=vi(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){b.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>s(t,e))}findAll(e={}){return this.getAll().filter(t=>s(e,t))}notify(e){b.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return b.batch(()=>Promise.all(e.map(e=>e.continue().catch(f))))}};function vi(e){return e.options.scope?.id}var yi=class extends o{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??d(r,t),a=this.get(i);return a||(a=new _({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){b.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>N(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>N(e,t)):t}notify(e){b.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){b.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){b.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},bi=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new yi,this.#t=e.mutationCache||new _i,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=S.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=w.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(c(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=h(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return b.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;b.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return b.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=b.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(f).catch(f)}invalidateQueries(e,t={}){return b.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=b.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(f)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(f)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(c(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(f).catch(f)}fetchInfiniteQuery(e){return e.behavior=fi(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(f).catch(f)}ensureInfiniteQueryData(e){return e.behavior=fi(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return w.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(P(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{l(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(P(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{l(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=d(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===u&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},xi=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Si=t(((e,t)=>{t.exports=xi()})),Ci=t((e=>{var t=Si(),n=r(),i=st();function a(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function o(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function s(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function c(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function u(e){if(s(e)!==e)throw Error(a(188))}function d(e){var t=e.alternate;if(!t){if(t=s(e),t===null)throw Error(a(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return u(i),e;if(o===r)return u(i),t;o=o.sibling}throw Error(a(188))}if(n.return!==r.return)n=i,r=o;else{for(var c=!1,l=i.child;l;){if(l===n){c=!0,n=i,r=o;break}if(l===r){c=!0,r=i,n=o;break}l=l.sibling}if(!c){for(l=o.child;l;){if(l===n){c=!0,n=o,r=i;break}if(l===r){c=!0,r=o,n=i;break}l=l.sibling}if(!c)throw Error(a(189))}}if(n.alternate!==r)throw Error(a(190))}if(n.tag!==3)throw Error(a(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}var p=Object.assign,m=Symbol.for(`react.element`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.memo_cache_sentinel`),k=Symbol.iterator;function A(e){return typeof e!=`object`||!e?null:(e=k&&e[k]||e[`@@iterator`],typeof e==`function`?e:null)}var j=Symbol.for(`react.client.reference`);function M(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===j?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case D:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case g:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case T:return t=e.displayName||null,t===null?M(e.type)||`Memo`:t;case E:t=e._payload,e=e._init;try{return M(e(t))}catch{}}return null}var N=Array.isArray,P=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I={pending:!1,data:null,method:null,action:null},L=[],R=-1;function z(e){return{current:e}}function B(e){0>R||(e.current=L[R],L[R]=null,R--)}function V(e,t){R++,L[R]=e.current,e.current=t}var H=z(null),U=z(null),W=z(null),G=z(null);function ee(e,t){switch(V(W,t),V(U,e),V(H,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Hd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Hd(t),e=Ud(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}B(H),V(H,e)}function K(){B(H),B(U),B(W)}function te(e){e.memoizedState!==null&&V(G,e);var t=H.current,n=Ud(t,e.type);t!==n&&(V(U,e),V(H,n))}function ne(e){U.current===e&&(B(H),B(U)),G.current===e&&(B(G),$f._currentValue=I)}var re,ie;function ae(e){if(re===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);re=t&&t[1]||``,ie=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+re+e+ie}var oe=!1;function se(e,t){if(!e||oe)return``;oe=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,`props`,{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,`name`,{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
5
5
  `),l=s.split(`
@@ -25,7 +25,7 @@ Error generating stack: `+e.message+`
25
25
  `}function Qm(e,t,n,r,i,a,o){if(typeof o==`function`&&(o={callback:o}),o?.callback){let{callback:s}=o;Xm(e,t,n,r,i,a,Object.assign(Object.assign({},o),{callback:e=>{s(e?Zm(e,o.headerOptions):void 0)}}))}else{let s=Xm(e,t,n,r,i,a,o);return s?Zm(s,o?.headerOptions):void 0}}function $m(e,t,n,r,i,a){return Qm(e,e,t,n,r,i,a)}function eh(e){let t=e.endsWith(`
26
26
  `),n=e.split(`
27
27
  `).map(e=>e+`
28
- `);return t?n.pop():n.push(n.pop().slice(0,-1)),n}function th(e,t){return`${e}\u0000${t}`}function nh(e,t,n){let r=ue(e).body,i=ue(t).body;return r===i?``:$m(n,r,i,``,``,{context:3})}function rh(e,t,n){let r=(0,Q.c)(8),{activeProvider:i}=Sn(),a;r[0]===Symbol.for(`react.memo_cache_sentinel`)?(a={status:`idle`,diff:null},r[0]=a):a=r[0];let[o,s]=(0,Z.useState)(a),c=(0,Z.useRef)(i),l;r[1]===i?l=r[2]:(l=()=>{c.current=i},r[1]=i,r[2]=l),(0,Z.useEffect)(l);let u,d;return r[3]!==n||r[4]!==t||r[5]!==e?(u=()=>{if(!e){s({status:`idle`,diff:null});return}let r=e,i=!1;return s({status:`loading`,diff:null}),(async function(){try{let e=th(t,r),a=n.get(e);if(a===void 0){let o=await fetch(`/api/history/${r}?docName=${encodeURIComponent(t)}`);if(i)return;if(!o.ok){s({status:`error`,diff:null});return}let c=await o.json();if(i)return;a=c.content??``,n.set(e,a)}if(i)return;let o=c.current?.document.getText(`source`).toString()??``,l=nh(a,o,t);if(i)return;s({status:`ready`,diff:l})}catch(e){i||(console.error(`[timeline-diff] failed to load entry diff`,{sha:r,docName:t,err:e}),s({status:`error`,diff:null}))}})(),()=>{i=!0}},d=[e,t,n],r[3]=n,r[4]=t,r[5]=e,r[6]=u,r[7]=d):(u=r[6],d=r[7]),(0,Z.useEffect)(u,d),o}var ih=(0,Z.lazy)(async()=>({default:(await n(()=>import(`./ActivityPanelDiffView-C1vRNF09.js`),__vite__mapDeps([9,1,6,10]),import.meta.url)).ActivityPanelDiffView}));function ah(e){let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/1e3);if(r<60)return`just now`;if(r<3600)return`${Math.floor(r/60)} min ago`;if(r<86400)return`${Math.floor(r/3600)}h ago`;if(r<86400*2)return`yesterday`;let i=Math.floor(r/86400);return i<7?`${i} days ago`:t.toLocaleDateString()}function oh(e){return new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function sh(e){return e.slice(0,7)}function ch(e){return e.type===`upstream`?`Upstream sync`:e.contributors.length===1?e.contributors[0].name:e.contributors.length>1?e.contributors.map(e=>e.name).join(`, `):e.author===`openknowledge-server`||e.author===`server`?`Auto-save`:e.author}function lh(e){let t=(0,Q.c)(17),n,r;if(t[0]===e?(n=t[1],r=t[2]):({icon:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),n===`claude`){let e;return t[3]===r?e=t[4]:(e=(0,X.jsx)(Hn,{...r}),t[3]=r,t[4]=e),e}if(n===`cursor`){let e;return t[5]===r?e=t[6]:(e=(0,X.jsx)(Jn,{...r}),t[5]=r,t[6]=e),e}if(n===`windsurf`){let e;return t[7]===r?e=t[8]:(e=(0,X.jsx)(Bn,{...r}),t[7]=r,t[8]=e),e}if(n===`openai`){let e;return t[9]===r?e=t[10]:(e=(0,X.jsx)(Gn,{...r}),t[9]=r,t[10]=e),e}if(n===`cline`){let e;return t[11]===r?e=t[12]:(e=(0,X.jsx)($n,{...r}),t[11]=r,t[12]=e),e}if(n===`github`){let e;return t[13]===r?e=t[14]:(e=(0,X.jsx)(Zn,{...r}),t[13]=r,t[14]=e),e}let i=r,a;return t[15]===i?a=t[16]:(a=(0,X.jsx)(Yn,{strokeWidth:1.5,...i}),t[15]=i,t[16]=a),a}function uh(e){let t=(0,Q.c)(17),{entry:n,isDark:r}=e;if(n.type===`upstream`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(ea,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[0]=e):e=t[0],e}if(n.contributors.length>0){let e=n.contributors[0],i=e.colorSeed??e.name,a;t[1]===i?a=t[2]:(a=Ce(i),t[1]=i,t[2]=a);let o=a,s=r?Se[o]??Me[o]:Me[o],c;t[3]!==s||t[4]!==i?(c=s??ke(i),t[3]=s,t[4]=i,t[5]=c):c=t[5];let l=c;if(o!==`bot`){let e;t[6]===l?e=t[7]:(e={color:l},t[6]=l,t[7]=e);let n;return t[8]!==o||t[9]!==e?(n=(0,X.jsx)(lh,{icon:o,width:14,height:14,className:`shrink-0`,style:e}),t[8]=o,t[9]=e,t[10]=n):n=t[10],n}if(e.name===`File System`){let e;return t[11]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(ra,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[11]=e):e=t[11],e}if(e.name===`Open Knowledge (service)`||e.name===`Git (upstream)`){let e;return t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Ti,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[12]=e):e=t[12],e}let u;return t[13]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,X.jsx)(Va,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[13]=u):u=t[13],u}if(n.authorEmail.includes(`agent`)||n.author.includes(`agent`)||n.authorEmail.includes(`cursor`)||n.authorEmail.includes(`claude`)){let e;return t[14]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Yn,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[14]=e):e=t[14],e}if(n.author===`openknowledge-server`||n.author===`server`){let e;return t[15]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Ti,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[15]=e):e=t[15],e}let i;return t[16]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,X.jsx)(Va,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[16]=i):i=t[16],i}function dh(e){let t=(0,Q.c)(20),{entries:n,defaultExpanded:r,isDark:i,diffLayout:a,cache:o,docName:s,expandedShas:c,onToggleExpanded:l,onRestoreSuccess:u}=e,[d,f]=(0,Z.useState)(r);if(n.length===0)return null;let p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>f(fh),t[0]=p):p=t[0];let m;t[1]===d?m=t[2]:(m=d?(0,X.jsx)(Rt,{className:`size-3`}):(0,X.jsx)(gn,{className:`size-3`}),t[1]=d,t[2]=m);let h=d?`Hide ${n.length} auto-save${n.length>1?`s`:``}`:`Show ${n.length} auto-save${n.length>1?`s`:``}`,g;t[3]!==d||t[4]!==m||t[5]!==h?(g=(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":d,className:`flex items-center gap-1.5 rounded-lg px-3 py-2 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors text-left`,onClick:p,children:[m,h]}),t[3]=d,t[4]=m,t[5]=h,t[6]=g):g=t[6];let _;t[7]!==o||t[8]!==a||t[9]!==s||t[10]!==n||t[11]!==d||t[12]!==c||t[13]!==i||t[14]!==u||t[15]!==l?(_=d&&n.map(e=>(0,X.jsx)(Eh,{entry:e,isDark:i,diffLayout:a,cache:o,docName:s,expanded:c.has(e.sha),onToggleExpanded:l,onRestoreSuccess:u},e.sha)),t[7]=o,t[8]=a,t[9]=s,t[10]=n,t[11]=d,t[12]=c,t[13]=i,t[14]=u,t[15]=l,t[16]=_):_=t[16];let v;return t[17]!==g||t[18]!==_?(v=(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[g,_]}),t[17]=g,t[18]=_,t[19]=v):v=t[19],v}function fh(e){return!e}function ph(e){return e.checkpoint?e.checkpoint.kind:`save`}function mh(e){let t=ph(e);if(t===`save`)return`Save Version`;let n=e.checkpoint?.size??null,r=n!=null&&n>0?` (${hh(n)})`:``;return t===`bridge-merge-loss`?`Auto-saved before a concurrent edit${r}`:`Recovered from an external change${r}`}function hh(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/102.4)/10} KB`:`${Math.round(e/104857.6)/10} MB`}function gh(e){return e.type===`checkpoint`?ph(e)===`save`?`version`:`auto-save`:`wip`}var _h={version:`Restore this version`,"auto-save":`Restore this auto-save`,wip:`Restore to this point`},vh={version:`Restore this version?`,"auto-save":`Restore this auto-save?`,wip:`Restore to this point?`};function yh(e){return _h[gh(e)]}function bh(e){return vh[gh(e)]}function xh(e){let t=[];for(let n of e.contributors)if(n.summaries)for(let e of n.summaries)t.push(e);return t}function Sh(e){let t=(0,Q.c)(20),{summaries:n}=e,[r,i]=(0,Z.useState)(!1),a=(0,Z.useId)();if(n.length===0)return null;let o,s;t[0]===n?(o=t[1],s=t[2]):([o,...s]=n,t[0]=n,t[1]=o,t[2]=s);let c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,X.jsx)(`span`,{"aria-hidden":`true`,children:`• `}),t[3]=c):c=t[3];let l;t[4]===o?l=t[5]:(l=(0,X.jsxs)(`li`,{className:`text-xs text-foreground/90`,children:[c,o]}),t[4]=o,t[5]=l);let u;t[6]!==r||t[7]!==s?(u=r&&s.map(wh),t[6]=r,t[7]=s,t[8]=u):u=t[8];let d;t[9]!==a||t[10]!==l||t[11]!==u?(d=(0,X.jsxs)(`ul`,{id:a,className:`list-none`,children:[l,u]}),t[9]=a,t[10]=l,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==r||t[14]!==a||t[15]!==s.length?(f=s.length>0&&(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":r,"aria-controls":a,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,onClick:e=>{e.stopPropagation(),i(Ch)},children:[r?(0,X.jsx)(Rt,{className:`size-3`}):(0,X.jsx)(gn,{className:`size-3`}),r?`Hide ${s.length} more`:`Show ${s.length} more`]}),t[13]=r,t[14]=a,t[15]=s.length,t[16]=f):f=t[16];let p;return t[17]!==d||t[18]!==f?(p=(0,X.jsxs)(`div`,{className:`mt-0.5`,children:[d,f]}),t[17]=d,t[18]=f,t[19]=p):p=t[19],p}function Ch(e){return!e}function wh(e,t){return(0,X.jsxs)(`li`,{className:`text-xs text-foreground/90`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,children:`• `}),e]},`${t}-${e}`)}function Th(e){let t=(0,Q.c)(13),{sha:n,docName:r,cache:i,diffLayout:a,panelId:o}=e,s=rh(n,r,i),c;t[0]===s.status?c=t[1]:(c=s.status===`loading`&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-xs text-muted-foreground`,children:[(0,X.jsx)(Rn,{className:`size-3 animate-spin`}),`Loading diff…`]}),t[0]=s.status,t[1]=c);let l;t[2]===s.status?l=t[3]:(l=s.status===`error`&&(0,X.jsx)(`p`,{className:`py-2 text-xs text-destructive`,children:`Diff unavailable`}),t[2]=s.status,t[3]=l);let u;t[4]!==a||t[5]!==s.diff||t[6]!==s.status?(u=s.status===`ready`&&(0,X.jsx)(Z.Suspense,{fallback:(0,X.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-xs text-muted-foreground`,children:[(0,X.jsx)(Rn,{className:`size-3 animate-spin`}),`Loading diff renderer…`]}),children:(0,X.jsx)(ih,{diff:s.diff,viewType:a})}),t[4]=a,t[5]=s.diff,t[6]=s.status,t[7]=u):u=t[7];let d;return t[8]!==o||t[9]!==c||t[10]!==l||t[11]!==u?(d=(0,X.jsxs)(`div`,{id:o,className:`px-3 pb-2`,"data-testid":`timeline-entry-diff`,children:[c,l,u]}),t[8]=o,t[9]=c,t[10]=l,t[11]=u,t[12]=d):d=t[12],d}function Eh(e){let t=(0,Q.c)(128),{entry:n,prominent:r,isDark:i,diffLayout:a,cache:o,docName:s,expanded:c,onToggleExpanded:l,onRestoreSuccess:u}=e,d=r===void 0?!1:r,f;t[0]===n.timestamp?f=t[1]:(f=ah(n.timestamp),t[0]=n.timestamp,t[1]=f);let p=f,m;t[2]===n?m=t[3]:(m=ch(n),t[2]=n,t[3]=m);let h=m,g=n.contributors.flatMap(Dh),_;t[4]===n?_=t[5]:(_=xh(n),t[4]=n,t[5]=_);let v=_,[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(!1),C=(0,Z.useRef)(null),w=(0,Z.useId)(),T,E;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>()=>C.current?.abort(),E=[],t[6]=T,t[7]=E):(T=t[6],E=t[7]),(0,Z.useEffect)(T,E);let D;t[8]!==n.sha||t[9]!==l?(D=()=>l(n.sha),t[8]=n.sha,t[9]=l,t[10]=D):D=t[10];let O=D,k;t[11]===b?k=t[12]:(k=function(){C.current?.abort(),C.current=null,S(!1),b(!1)},t[11]=b,t[12]=k);let A=k,j;t[13]!==s||t[14]!==n.sha||t[15]!==u||t[16]!==b?(j=async function(){S(!0);let e=new AbortController;C.current=e;let t=function(){e.signal.aborted||S(!1),C.current===e&&(C.current=null)},r;try{r=await fetch(`/api/rollback`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({docName:s,commitSha:n.sha}),signal:e.signal})}catch(r){let i=r;!e.signal.aborted&&!(i instanceof DOMException&&i.name===`AbortError`)&&(console.error(`[timeline] rollback fetch failed`,{docName:s,sha:n.sha,err:i}),Ar.error(`Restore failed — document unchanged`,{duration:4e3})),t();return}if(e.signal.aborted){t();return}if(r.ok)b(!1),u();else{let e=`HTTP ${r.status}`;try{let t=await r.json();t.error&&(e=t.error)}catch{}console.error(`[timeline] rollback failed`,{docName:s,sha:n.sha,status:r.status,detail:e}),Ar.error(`Restore failed`,{description:e,duration:6e3})}t()},t[13]=s,t[14]=n.sha,t[15]=u,t[16]=b,t[17]=j):j=t[17];let M=j,N;t[18]!==n||t[19]!==i||t[20]!==d?(N=d?(()=>{let e=ph(n);return e===`bridge-merge-loss`?(0,X.jsx)(R,{className:`size-3.5 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":`true`}):e===`external-change-rescue`?(0,X.jsx)(qi,{className:`size-3.5 shrink-0 text-sky-600 dark:text-sky-400`,"aria-hidden":`true`}):(0,X.jsx)(Gi,{className:`size-3.5 shrink-0 text-muted-foreground`})})():(0,X.jsx)(uh,{entry:n,isDark:i}),t[18]=n,t[19]=i,t[20]=d,t[21]=N):N=t[21];let P=N,F=c?w:void 0,I=c?`bg-muted`:`hover:bg-muted/50`,L;t[22]===I?L=t[23]:(L=[`group flex w-full items-start gap-3 rounded-lg px-3 py-2.5 text-left transition-colors cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-ring`,I],t[22]=I,t[23]=L);let z=L.join(` `),B;t[24]===O?B=t[25]:(B=e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),O())},t[24]=O,t[25]=B);let V;t[26]===P?V=t[27]:(V=(0,X.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:P}),t[26]=P,t[27]=V);let H;t[28]!==h||t[29]!==n||t[30]!==d?(H=d?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`text-xs text-foreground truncate`,children:mh(n)}),(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground/50`,children:`·`}),(0,X.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:h})]}):(0,X.jsx)(`span`,{className:`truncate text-xs text-foreground`,children:h}),t[28]=h,t[29]=n,t[30]=d,t[31]=H):H=t[31];let U;t[32]!==n.timestamp||t[33]!==p?(U=(0,X.jsx)(`time`,{className:`ml-auto shrink-0 text-xs text-muted-foreground/80`,dateTime:n.timestamp,title:n.timestamp,children:p}),t[32]=n.timestamp,t[33]=p,t[34]=U):U=t[34];let W;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-px shrink-0 bg-border`}),t[35]=W):W=t[35];let G;t[36]===n?G=t[37]:(G=yh(n),t[36]=n,t[37]=G);let ee;t[38]===b?ee=t[39]:(ee=e=>{e.stopPropagation(),b(!0)},t[38]=b,t[39]=ee);let K;t[40]===x?K=t[41]:(K=x?(0,X.jsx)(Rn,{className:`size-3 animate-spin`}):(0,X.jsx)(Un,{className:`size-3`}),t[40]=x,t[41]=K);let te;t[42]!==x||t[43]!==G||t[44]!==ee||t[45]!==K?(te=(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(J,{variant:`ghost`,size:`icon`,className:`size-5 shrink-0 text-muted-foreground hover:text-destructive`,"data-testid":`timeline-entry-restore`,"aria-label":G,disabled:x,onClick:ee,children:K})}),t[42]=x,t[43]=G,t[44]=ee,t[45]=K,t[46]=te):te=t[46];let ne;t[47]===n?ne=t[48]:(ne=yh(n),t[47]=n,t[48]=ne);let re;t[49]===ne?re=t[50]:(re=(0,X.jsx)(Fr,{side:`top`,children:ne}),t[49]=ne,t[50]=re);let ie;t[51]!==te||t[52]!==re?(ie=(0,X.jsxs)(Lr,{children:[te,re]}),t[51]=te,t[52]=re,t[53]=ie):ie=t[53];let ae;t[54]!==H||t[55]!==U||t[56]!==ie?(ae=(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[H,U,W,ie]}),t[54]=H,t[55]=U,t[56]=ie,t[57]=ae):ae=t[57];let oe;t[58]===v?oe=t[59]:(oe=v.length>0&&(0,X.jsx)(Sh,{summaries:v}),t[58]=v,t[59]=oe);let se=g.length>0?(0,X.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,title:g.join(`, `),children:g.join(`, `)}):(0,X.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,title:n.message,children:n.message}),ce;t[60]!==ae||t[61]!==oe||t[62]!==se?(ce=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[ae,oe,se]}),t[60]=ae,t[61]=oe,t[62]=se,t[63]=ce):ce=t[63];let le;t[64]!==c||t[65]!==O||t[66]!==F||t[67]!==z||t[68]!==B||t[69]!==V||t[70]!==ce?(le=(0,X.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-expanded":c,"aria-controls":F,"data-testid":`timeline-entry-expand`,className:z,onClick:O,onKeyDown:B,children:[V,ce]}),t[64]=c,t[65]=O,t[66]=F,t[67]=z,t[68]=B,t[69]=V,t[70]=ce,t[71]=le):le=t[71];let ue;t[72]!==o||t[73]!==a||t[74]!==w||t[75]!==s||t[76]!==n.sha||t[77]!==c?(ue=c&&(0,X.jsx)(Th,{sha:n.sha,docName:s,cache:o,diffLayout:a,panelId:w}),t[72]=o,t[73]=a,t[74]=w,t[75]=s,t[76]=n.sha,t[77]=c,t[78]=ue):ue=t[78];let de;t[79]!==le||t[80]!==ue?(de=(0,X.jsxs)(`div`,{className:`flex flex-col rounded-lg`,children:[le,ue]}),t[79]=le,t[80]=ue,t[81]=de):de=t[81];let fe;t[82]!==A||t[83]!==b?(fe=e=>{e?b(!0):A()},t[82]=A,t[83]=b,t[84]=fe):fe=t[84];let pe;t[85]===n?pe=t[86]:(pe=bh(n),t[85]=n,t[86]=pe);let me;t[87]===pe?me=t[88]:(me=(0,X.jsx)(hr,{children:pe}),t[87]=pe,t[88]=me);let he;t[89]===n.timestamp?he=t[90]:(he=oh(n.timestamp),t[89]=n.timestamp,t[90]=he);let ge;t[91]===n.sha?ge=t[92]:(ge=sh(n.sha),t[91]=n.sha,t[92]=ge);let _e;t[93]!==p||t[94]!==he||t[95]!==ge?(_e=(0,X.jsxs)(`span`,{className:`font-medium text-foreground`,children:[p,` (`,he,`, `,ge,`)`]}),t[93]=p,t[94]=he,t[95]=ge,t[96]=_e):_e=t[96];let ve;t[97]===h?ve=t[98]:(ve=(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:h}),t[97]=h,t[98]=ve);let ye;t[99]!==_e||t[100]!==ve?(ye=(0,X.jsxs)(pr,{children:[`This will replace the current document content with the version from`,` `,_e,` `,`by `,ve,`. Your current content is already saved in the timeline — you can restore it anytime.`]}),t[99]=_e,t[100]=ve,t[101]=ye):ye=t[101];let be;t[102]!==me||t[103]!==ye?(be=(0,X.jsxs)(Er,{children:[me,ye]}),t[102]=me,t[103]=ye,t[104]=be):be=t[104];let xe;t[105]===A?xe=t[106]:(xe=(0,X.jsx)(J,{variant:`outline`,"data-testid":`timeline-entry-restore-cancel`,onClick:A,children:`Cancel`}),t[105]=A,t[106]=xe);let Se;t[107]===M?Se=t[108]:(Se=()=>M(),t[107]=M,t[108]=Se);let Ce;t[109]===x?Ce=t[110]:(Ce=x?(0,X.jsx)(Rn,{className:`mr-2 size-4 animate-spin`}):null,t[109]=x,t[110]=Ce);let we;t[111]!==x||t[112]!==Se||t[113]!==Ce?(we=(0,X.jsxs)(J,{variant:`destructive`,"data-testid":`timeline-entry-restore-confirm`,disabled:x,onClick:Se,children:[Ce,`Restore`]}),t[111]=x,t[112]=Se,t[113]=Ce,t[114]=we):we=t[114];let Te;t[115]!==xe||t[116]!==we?(Te=(0,X.jsxs)(Cr,{children:[xe,we]}),t[115]=xe,t[116]=we,t[117]=Te):Te=t[117];let Ee;t[118]!==be||t[119]!==Te?(Ee=(0,X.jsxs)(yr,{children:[be,Te]}),t[118]=be,t[119]=Te,t[120]=Ee):Ee=t[120];let De;t[121]!==y||t[122]!==fe||t[123]!==Ee?(De=(0,X.jsx)(Dr,{open:y,onOpenChange:fe,children:Ee}),t[121]=y,t[122]=fe,t[123]=Ee,t[124]=De):De=t[124];let Oe;return t[125]!==de||t[126]!==De?(Oe=(0,X.jsxs)(X.Fragment,{children:[de,De]}),t[125]=de,t[126]=De,t[127]=Oe):Oe=t[127],Oe}function Dh(e){return e.docs}function Oh(e){let t=(0,Q.c)(63),{docName:n,diffLayout:r,onDiffLayoutChange:i}=e,{resolvedTheme:a}=G(),o=a===`dark`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=[],t[0]=s):s=t[0];let[c,l]=(0,Z.useState)(s),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null),m=(0,Z.useRef)(null),[h]=(0,Z.useState)(Mh),[g,_]=(0,Z.useState)(jh),v;t[1]===h?v=t[2]:(v=()=>{_(new Set),h.clear()},t[1]=h,t[2]=v);let y;t[3]===n?y=t[4]:(y=[n],t[3]=n,t[4]=y),(0,Z.useEffect)(v,y);let b;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(b=function(e){_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[5]=b):b=t[5];let x=b,S;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(S=function(){_(new Set)},t[6]=S):S=t[6];let C=S,w,T;t[7]===n?(w=t[8],T=t[9]):(w=()=>{if(!n){l([]);return}let e=!1,t=async function(){if(n)try{let t=await fetch(`/api/history?docName=${encodeURIComponent(n)}&limit=100`);if(e)return;if(!t.ok){p(`History unavailable`);return}let r=await t.json();if(e)return;l(r.entries??[]),p(null)}catch(t){let n=t;if(e)return;p(`History unavailable`),console.error(`[timeline]`,n)}};return d(!0),t().finally(()=>{e||d(!1)}),m.current=setInterval(t,1e4),()=>{e=!0,m.current&&clearInterval(m.current)}},T=[n],t[7]=n,t[8]=w,t[9]=T),(0,Z.useEffect)(w,T);let E,D,O,k,A,j,M,N;if(t[10]!==h||t[11]!==r||t[12]!==n||t[13]!==c||t[14]!==f||t[15]!==g||t[16]!==o||t[17]!==u||t[18]!==i){let e=[],a=[],s=!1;for(let t of c)t.type===`checkpoint`?(a.length>0&&(e.push({kind:`wip-group`,entries:a,isPreCheckpoint:!s}),a=[]),e.push({kind:`checkpoint`,entry:t}),s=!0):a.push(t);a.length>0&&e.push({kind:`wip-group`,entries:a,isPreCheckpoint:!s});let l;t[27]===c?l=t[28]:(l=c.some(Ah),t[27]=c,t[28]=l);let d=!l,p=!u&&!f&&c.length>0;A=`flex h-full flex-col`,t[29]!==r||t[30]!==p||t[31]!==i?(j=p&&(0,X.jsx)(`div`,{className:`flex items-center justify-end gap-1 px-2 py-1.5`,children:(0,X.jsxs)(Lr,{children:[(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsxs)(Xe,{type:`single`,value:r,onValueChange:e=>{e&&i(e)},"aria-label":`Diff layout`,variant:`segmented`,size:`sm`,spacing:1,className:`bg-muted dark:bg-background p-0.5 rounded-md shrink-0`,children:[(0,X.jsx)(He,{value:`unified`,"aria-label":`Unified diff`,className:`size-6 px-0`,children:(0,X.jsx)(Ta,{className:`size-3.5`})}),(0,X.jsx)(He,{value:`split`,"aria-label":`Split diff`,className:`size-6 px-0`,children:(0,X.jsx)(Bi,{className:`size-3.5`})})]})}),(0,X.jsx)(Fr,{children:r===`unified`?`Unified diff`:`Split diff`})]})}),t[29]=r,t[30]=p,t[31]=i,t[32]=j):j=t[32],M=`flex-1 overflow-y-auto subtle-scrollbar`,t[33]===u?N=t[34]:(N=u&&(0,X.jsx)(`div`,{className:`flex flex-col gap-1 p-2`,role:`status`,"aria-busy":`true`,"aria-label":`Loading timeline history`,children:[1,2,3].map(kh)}),t[33]=u,t[34]=N),t[35]!==f||t[36]!==u?(E=!u&&f&&(0,X.jsx)(`div`,{className:`px-4 py-3`,children:(0,X.jsx)(`p`,{className:`text-xs text-destructive`,children:f})}),t[35]=f,t[36]=u,t[37]=E):E=t[37],t[38]!==c.length||t[39]!==f||t[40]!==u?(D=!u&&!f&&c.length===0&&(0,X.jsx)(`div`,{className:`px-4 py-8 text-center`,children:(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No history yet`})}),t[38]=c.length,t[39]=f,t[40]=u,t[41]=D):D=t[41],t[42]!==h||t[43]!==r||t[44]!==n||t[45]!==c||t[46]!==f||t[47]!==g||t[48]!==d||t[49]!==o||t[50]!==u?(O=!u&&!f&&d&&c.length>0&&(0,X.jsx)(`div`,{className:`flex flex-col gap-1 p-2`,children:c.map(e=>(0,X.jsx)(Eh,{entry:e,isDark:o,diffLayout:r,cache:h,docName:n,expanded:g.has(e.sha),onToggleExpanded:x,onRestoreSuccess:C},e.sha))}),t[42]=h,t[43]=r,t[44]=n,t[45]=c,t[46]=f,t[47]=g,t[48]=d,t[49]=o,t[50]=u,t[51]=O):O=t[51],k=!u&&!f&&!d&&(0,X.jsx)(`div`,{className:`flex flex-col gap-1 p-2`,children:e.map((e,t)=>e.kind===`checkpoint`?(0,X.jsx)(Eh,{entry:e.entry,prominent:!0,isDark:o,diffLayout:r,cache:h,docName:n,expanded:g.has(e.entry.sha),onToggleExpanded:x,onRestoreSuccess:C},e.entry.sha):(0,X.jsx)(dh,{entries:e.entries,defaultExpanded:e.isPreCheckpoint,isDark:o,diffLayout:r,cache:h,docName:n,expandedShas:g,onToggleExpanded:x,onRestoreSuccess:C},e.entries[0]?.sha??`wip-${t}`))}),t[10]=h,t[11]=r,t[12]=n,t[13]=c,t[14]=f,t[15]=g,t[16]=o,t[17]=u,t[18]=i,t[19]=E,t[20]=D,t[21]=O,t[22]=k,t[23]=A,t[24]=j,t[25]=M,t[26]=N}else E=t[19],D=t[20],O=t[21],k=t[22],A=t[23],j=t[24],M=t[25],N=t[26];let P;t[52]!==E||t[53]!==D||t[54]!==O||t[55]!==k||t[56]!==M||t[57]!==N?(P=(0,X.jsxs)(`div`,{className:M,children:[N,E,D,O,k]}),t[52]=E,t[53]=D,t[54]=O,t[55]=k,t[56]=M,t[57]=N,t[58]=P):P=t[58];let F;return t[59]!==A||t[60]!==j||t[61]!==P?(F=(0,X.jsxs)(`div`,{className:A,children:[j,P]}),t[59]=A,t[60]=j,t[61]=P,t[62]=F):F=t[62],F}function kh(e){return(0,X.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg px-3 py-2.5`,children:[(0,X.jsx)(nr,{className:`size-3.5 rounded mt-0.5 shrink-0`}),(0,X.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,X.jsx)(nr,{className:`h-3 w-28`}),(0,X.jsx)(nr,{className:`h-3 w-40`})]})]},e)}function Ah(e){return e.type===`checkpoint`}function jh(){return new Set}function Mh(){return new Wn(32)}var Nh=[{id:`outline`,label:`Outline`,icon:ua},{id:`backlinks`,label:`Backlinks`,icon:Ui},{id:`forward-links`,label:`Outgoing Links`,icon:Wi},{id:`graph`,label:`Graph`,icon:pa},{id:`timeline`,label:`Timeline`,icon:Ii}];function Ph(){return n(()=>import(`./GraphPanel-OfJ6ZXTH.js`),__vite__mapDeps([11,1,12,3,5,6,13,14,15,16,17]),import.meta.url)}var Fh=(0,Z.lazy)(async()=>({default:(await Ph()).GraphPanel})),Ih=(0,Z.lazy)(async()=>({default:(await n(()=>import(`./ActivityModeContent-BvIa8sg6.js`),__vite__mapDeps([18,1,2,3,19,20,21,13,12,5,6,22,7,14,23]),import.meta.url)).ActivityModeContent}));function Lh(e){let t=(0,Q.c)(13),{docName:n,isSourceMode:r,activeTab:i,onActiveTabChange:a,mode:o}=e,[s,c]=(0,Z.useState)(`unified`),l;t[0]!==i||t[1]!==o||t[2]!==a?(l=o===`doc`?(0,X.jsx)(`div`,{className:`flex flex-row items-center justify-center gap-3 border-b border-border/60 p-2`,children:(0,X.jsx)(Xe,{type:`single`,variant:`outline`,value:i,onValueChange:e=>{e&&a(e)},"aria-label":`Document panels`,children:Nh.map(Rh)})}):null,t[0]=i,t[1]=o,t[2]=a,t[3]=l):l=t[3];let u;t[4]!==i||t[5]!==s||t[6]!==n||t[7]!==r||t[8]!==o?(u=o===`doc`?(0,X.jsxs)(`div`,{role:`tabpanel`,id:`panel-${i}`,"aria-labelledby":`tab-${i}`,className:`min-h-0 flex-1`,children:[i===`outline`&&(0,X.jsx)(ci,{docName:n,isSourceMode:r}),i===`backlinks`&&(0,X.jsx)(wm,{docName:n}),i===`forward-links`&&(0,X.jsx)(Dm,{docName:n}),i===`graph`&&(0,X.jsx)(Z.Suspense,{fallback:(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Loading graph…`}),children:(0,X.jsx)(Fh,{activeDocName:n})}),i===`timeline`&&(0,X.jsx)(Oh,{docName:n,diffLayout:s,onDiffLayoutChange:c})]}):(0,X.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,X.jsx)(Z.Suspense,{fallback:(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Loading agent activity…`}),children:(0,X.jsx)(Ih,{})})}),t[4]=i,t[5]=s,t[6]=n,t[7]=r,t[8]=o,t[9]=u):u=t[9];let d;return t[10]!==l||t[11]!==u?(d=(0,X.jsxs)(X.Fragment,{children:[l,u]}),t[10]=l,t[11]=u,t[12]=d):d=t[12],d}function Rh(e){let{id:t,label:n,icon:r}=e;return(0,X.jsxs)(Lr,{children:[(0,X.jsx)(He,{value:t,role:`tab`,id:`tab-${t}`,"aria-controls":`panel-${t}`,"aria-label":n,asChild:!0,children:(0,X.jsx)(Pr,{children:(0,X.jsx)(r,{})})}),(0,X.jsx)(Fr,{side:`bottom`,children:n})]},t)}function zh(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function Bh(e,t){let n=getComputedStyle(e.ownerDocument.body);return t*parseFloat(n.fontSize)}function Vh(e){return e/100*window.innerHeight}function Hh(e){return e/100*window.innerWidth}function Uh(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}function Wh({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=Uh(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=Bh(t,i);break;case`em`:r=zh(t,i);break;case`vh`:r=Vh(i);break;case`vw`:r=Hh(i);break}return r}function Gh(e){return parseFloat(e.toFixed(3))}function Kh({group:e}){let{orientation:t,panels:n}=e;return n.reduce((e,n)=>(e+=t===`horizontal`?n.element.offsetWidth:n.element.offsetHeight,e),0)}function qh(e){let{panels:t}=e,n=Kh({group:e});return n===0?t.map(e=>({groupResizeBehavior:e.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:e.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let{element:t,panelConstraints:r}=e,i=0;r.collapsedSize!==void 0&&(i=Gh(Wh({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=Gh(Wh({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=Gh(Wh({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=Gh(Wh({groupSize:n,panelElement:t,styleProp:r.maxSize})/n*100)),{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:i,collapsible:r.collapsible===!0,defaultSize:a,disabled:r.disabled,minSize:o,maxSize:s,panelId:e.id}})}function Jh(e,t=`Assertion error`){if(!e)throw Error(t)}function Yh(e,t){return Array.from(t).sort(e===`horizontal`?Xh:Zh)}function Xh(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function Zh(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function Qh(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function $h(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function eg({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=$h(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return Jh(i,`No rect found`),i}var tg;function ng(){return tg===void 0&&(tg=typeof matchMedia==`function`?!!matchMedia(`(pointer:coarse)`).matches:!1),tg}function rg(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=Yh(n,Array.from(t.children).filter(Qh).map(e=>({element:e}))).map(({element:e})=>e),o=[],s=!1,c=!1,l=-1,u=-1,d=0,f,p=[];{let e=-1;for(let t of a)t.hasAttribute(`data-panel`)&&(e++,t.hasAttribute(`data-disabled`)||(d++,l===-1&&(l=e),u=e))}if(d>1){let t=-1;for(let d of a)if(d.hasAttribute(`data-panel`)){t++;let i=r.find(e=>e.element===d);if(i){if(f){let r=f.element.getBoundingClientRect(),a=d.getBoundingClientRect(),m;if(c){let e=n===`horizontal`?new DOMRect(r.right,r.top,0,r.height):new DOMRect(r.left,r.bottom,r.width,0),t=n===`horizontal`?new DOMRect(a.left,a.top,0,a.height):new DOMRect(a.left,a.top,a.width,0);switch(p.length){case 0:m=[e,t];break;case 1:{let i=p[0];m=[i,eg({orientation:n,rects:[r,a],targetRect:i.element.getBoundingClientRect()})===r?t:e];break}default:m=p;break}}else m=p.length?p:[n===`horizontal`?new DOMRect(r.right,a.top,a.left-r.right,a.height):new DOMRect(a.left,r.bottom,a.width,a.top-r.bottom)];for(let n of m){let r=`width`in n?n:n.element.getBoundingClientRect(),a=ng()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(r.width<a){let e=a-r.width;r=new DOMRect(r.x-e/2,r.y,r.width+e,r.height)}if(r.height<a){let e=a-r.height;r=new DOMRect(r.x,r.y-e/2,r.width,r.height+e)}!s&&!(t<=l||t>u)&&o.push({group:e,groupSize:Kh({group:e}),panels:[f,i],separator:`width`in n?void 0:n,rect:r}),s=!1}}c=!1,f=i,p=[]}}else if(d.hasAttribute(`data-separator`)){d.ariaDisabled!==null&&(s=!0);let e=i.find(e=>e.element===d);e?p.push(e):(f=void 0,p=[])}else c=!0}return o}var ig=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0)if(n.length===1)n[0].call(null,t);else{let e=!1,r=null,i=Array.from(n);for(let n=0;n<i.length;n++){let a=i[n];try{a.call(null,t)}catch(t){r===null&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}},ag=new Map,og=new ig;function sg(e){ag=new Map(ag),ag.delete(e)}function cg(e,t){for(let[t]of ag)if(t.id===e)return t}function lg(e,t){for(let[t,n]of ag)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function ug(){return ag}function dg(e,t){return og.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function fg(e,t){let n=ag.get(e);ag=new Map(ag),ag.set(e,t),og.emit(`groupChange`,{group:e,prev:n,next:t})}function pg(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=$h(n,a.rect);switch(e){case`horizontal`:t.x<=i.x&&(r=a,i=t);break;case`vertical`:t.y<=i.y&&(r=a,i=t);break}}return r?{distance:i,hitRegion:r}:void 0}function mg(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function hg(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:xg(e),b:xg(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();Jh(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:bg(yg(n.a)),b:bg(yg(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var gg=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function _g(e){let t=getComputedStyle(Sg(e)??e).display;return t===`flex`||t===`inline-flex`}function vg(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||_g(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||gg.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function yg(e){let t=e.length;for(;t--;){let n=e[t];if(Jh(n,`Missing node`),vg(n))return n}return null}function bg(e){return e&&Number(getComputedStyle(e).zIndex)||0}function xg(e){let t=[];for(;e;)t.push(e),e=Sg(e);return t}function Sg(e){let{parentNode:t}=e;return mg(t)?t.host:t}function Cg(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function wg({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!Qh(n)||n.contains(e)||e.contains(n))return!0;if(hg(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(Cg(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function Tg(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=rg(r),a=pg(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&wg({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function Eg(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function Dg(e,t,n=0){return Math.abs(Gh(e)-Gh(t))<=n}function Og(e,t){return Dg(e,t)?0:e>t?1:-1}function kg({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsible:a,disabled:o,maxSize:s=100,minSize:c=0}=t;if(o&&!e)return n;if(Og(r,c)<0)if(a){let e=(i+c)/2;r=Og(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=Gh(r),r}function Ag({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(Dg(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;Jh(u!=null,`Invalid first pivot index`),Jh(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];Jh(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(Jh(n!=null,`Previous layout not found for panel index ${t}`),Dg(n,i)){let t=o-n;Og(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];Jh(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(Jh(n!=null,`Previous layout not found for panel index ${t}`),Dg(n,o)){let t=n-i;Og(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];Jh(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&Og(i,c)<0)if(e>0){let t=c-o,n=t/2;Og(i+e,c)<0&&(e=Og(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;Og(i-e,c)<0&&(e=Og(100+e,n)>0?0:-t)}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];Jh(e!=null,`Previous layout not found for panel index ${r}`);let a=kg({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];Jh(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=kg({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!Dg(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(Eg(c,l))return i;{let t=e<0?d:u,r=s[t];Jh(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=kg({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!Dg(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];Jh(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=kg({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(Dg(i,s)||(t-=s-i,l[r]=s),Dg(t,0))break;e>0?r--:r++}}}if(!Dg(Object.values(l).reduce((e,t)=>t+e,0),100,.1))return i;let p=Object.keys(i);return l.reduce((e,t,n)=>(e[p[n]]=t,e),{})}function jg(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||Og(e[n],t[n])!==0)return!1;return!0}function Mg({layout:e,panelConstraints:t}){let n=Object.values(e),r=[...n],i=r.reduce((e,t)=>e+t,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(e=>`${e}%`).join(`, `)}`);if(!Dg(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];Jh(t!=null,`No layout data found for index ${e}`),r[e]=100/i*t}let a=0;for(let e=0;e<t.length;e++){let i=n[e];Jh(i!=null,`No layout data found for index ${e}`);let o=r[e];Jh(o!=null,`No layout data found for index ${e}`);let s=kg({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!Dg(a,0))for(let e=0;e<t.length;e++){let n=r[e];Jh(n!=null,`No layout data found for index ${e}`);let i=n+a,o=kg({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,Dg(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function Ng({groupId:e,panelId:t}){let n=()=>{let t=ug();for(let[n,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:a,groupSize:o,separatorToPanels:s}]of t)if(n.id===e)return{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:n,groupSize:o,layout:a,separatorToPanels:s};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedPanelConstraints.find(e=>e.panelId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let e=n().group.panels.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},a=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=e=>{let r=a();if(e===r)return;let{defaultLayoutDeferred:i,derivedPanelConstraints:o,group:s,groupSize:c,layout:l,separatorToPanels:u}=n(),d=s.panels.findIndex(e=>e.id===t),f=d===s.panels.length-1,p=Mg({layout:Ag({delta:f?r-e:e-r,initialLayout:l,panelConstraints:o,pivotIndices:f?[d-1,d]:[d,d+1],prevLayout:l,trigger:`imperative-api`}),panelConstraints:o});jg(l,p)||fg(s,{defaultLayoutDeferred:i,derivedPanelConstraints:o,groupSize:c,layout:p,separatorToPanels:u})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),s=a();e&&s!==t&&(n.expandToSize=s,o(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:s}=i(),c=a();if(e&&c===t){let e=s.expandToSize??n;e===0&&(e=1),o(e)}},getSize:()=>{let{group:e}=n(),t=a(),{element:r}=i();return{asPercentage:t,inPixels:e.orientation===`horizontal`?r.offsetWidth:r.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=a();return e&&Dg(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=Kh({group:t});o(Gh(Wh({groupSize:a,panelElement:r,styleProp:e})/a*100))}}}function Pg(e){e.defaultPrevented||Tg(e,ug()).forEach(t=>{if(t.separator&&!t.separator.disableDoubleClick){let n=t.panels.find(e=>e.panelConstraints.defaultSize!==void 0);if(n){let r=n.panelConstraints.defaultSize,i=Ng({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function Fg(e){let t=ug();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function Ig({groupId:e}){let t=()=>{let t=ug();for(let[n,r]of t)if(n.id===e)return{group:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:i,groupSize:a,layout:o,separatorToPanels:s}=t(),c=Mg({layout:e,panelConstraints:r});return n?o:(jg(o,c)||fg(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function Lg(e,t){let n=Fg(e),r=lg(n.id,!0),i=n.separators.find(t=>t.element===e);Jh(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);Jh(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=Ig({groupId:n.id}).getLayout(),c=Mg({layout:Ag({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});jg(s,c)||fg(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels})}function Rg(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=Fg(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&Lg(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&Lg(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&Lg(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&Lg(t,-5);break;case`End`:e.preventDefault(),Lg(t,100);break;case`Enter`:{e.preventDefault();let n=Fg(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=lg(n.id,!0),o=n.separators.find(e=>e.element===t);Jh(o,`Matching separator not found`);let s=a.get(o);Jh(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(Jh(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];Lg(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=Fg(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);Jh(r!==null,`Index not found`),n[e.shiftKey?r>0?r-1:n.length-1:r+1<n.length?r+1:0].focus({preventScroll:!0});break}case`Home`:e.preventDefault(),Lg(t,-100);break}}var zg={cursorFlags:0,state:`inactive`},Bg=new ig;function Vg(){return zg}function Hg(e){return Bg.addListener(`change`,e)}function Ug(e){let t=zg,n={...zg};n.cursorFlags=e,zg=n,Bg.emit(`change`,{prev:t,next:n})}function Wg(e){let t=zg;zg=e,Bg.emit(`change`,{prev:t,next:e})}function Gg(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=ug(),n=Tg(e,t),r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus({preventScroll:!0})));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),Wg({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}var Kg=e=>e,qg=()=>{},Jg=1,Yg=2,Xg=4,Zg=8,Qg=3,$g=12,e_;function t_(){return e_===void 0&&(e_=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(e_=!0)),e_}function n_({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++;break}})}if(!(r===0&&i===0)){switch(n){case`active`:if(e&&t_()){let t=(e&Jg)!==0,n=(e&Yg)!==0,r=(e&Xg)!==0,i=(e&Zg)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}break}return t_()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var r_=new WeakMap;function i_(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=r_.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(n));let r=Vg();switch(r.state){case`active`:case`hover`:{let e=n_({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(e=>e.group),state:r.state}),i=`*, *:hover {cursor: ${e} !important; }`;if(t===i)return;t=i,e?n.cssRules.length===0?n.insertRule(i):n.replaceSync(i):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}r_.set(e,{prevStyle:t,styleSheet:n})}function a_({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:a,prevCursorFlags:o}){let s=0;n.forEach(e=>{let{group:n,groupSize:o}=e,{orientation:c,panels:l}=n,{disableCursor:u}=n.mutableState,d=0;d=a?c===`horizontal`?(t.clientX-a.x)/o*100:(t.clientY-a.y)/o*100:c===`horizontal`?t.clientX<0?-100:100:t.clientY<0?-100:100;let f=r.get(n),p=i.get(n);if(!f||!p)return;let{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:_,separatorToPanels:v}=p;if(h&&_&&v){let t=Ag({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(jg(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?Jg:Yg;break;case`vertical`:s|=d<0?Xg:Zg;break}}else fg(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&Qg:c|=s&Qg,t.movementY===0?c|=o&$g:c|=s&$g,Ug(c),i_(e)}function o_(e){let t=ug(),n=Vg();switch(n.state){case`active`:a_({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function s_(e){if(e.defaultPrevented)return;let t=Vg(),n=ug();switch(t.state){case`active`:if(e.buttons===0){Wg({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=lg(e.group.id,!0);fg(e.group,t)});return}for(let n of t.hitRegions)if(n.separator){let{element:t}=n.separator;t.hasPointerCapture?.(e.pointerId)||t.setPointerCapture?.(e.pointerId)}a_({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=Tg(e,n);r.length===0?t.state!==`inactive`&&Wg({cursorFlags:0,state:`inactive`}):Wg({cursorFlags:0,hitRegions:r,state:`hover`}),i_(e.currentTarget);break}}}function c_(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(Vg().state){case`hover`:Wg({cursorFlags:0,state:`inactive`})}}function l_(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=Vg();switch(t.state){case`active`:Wg({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(i_(e.currentTarget),t.hitRegions.forEach(e=>{let t=lg(e.group.id,!0);fg(e.group,t)}),e.preventDefault())}}function u_(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=Gh(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=Gh((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function d_(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=Kh({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:Gh(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function f_(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function p_({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,a=0,o=!1,s=new Map,c=[];for(let l of e.panels){let e=r[l.id]??0;switch(l.panelConstraints.groupResizeBehavior){case`preserve-pixel-size`:{o=!0;let r=Gh(e/100*n/t*100);s.set(l.id,r),i+=r;break}default:c.push(l.id),a+=e;break}}if(!o||c.length===0)return r;let l=100-i,u={...r};if(s.forEach((e,t)=>{u[t]=e}),a>0)for(let e of c)u[e]=Gh((r[e]??0)/a*l);else{let e=Gh(l/c.length);for(let t of c)u[t]=e}return u}function m_(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}var h_=new Map;function g_(e){let t=!0;Jh(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{for(let r of n){let{borderBoxSize:n,target:i}=r;if(i===e.element){if(t){let t=Kh({group:e});if(t===0)return;let n=lg(e.id);if(!n)return;let r=qh(e),i=n.defaultLayoutDeferred?u_(r):n.layout,a=Mg({layout:p_({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&jg(n.layout,a)&&f_(n.derivedPanelConstraints,r)&&n.groupSize===t)return;fg(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else d_(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{Jh(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=Kh({group:e}),s=qh(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(m_(e.panels,l)||(l=void 0));let u=Mg({layout:e.mutableState.layouts[c]??l??u_(s),panelConstraints:s}),d=e.element.ownerDocument;h_.set(d,(h_.get(d)??0)+1);let f=new Map;return rg(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),fg(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,groupSize:o,layout:u,separatorToPanels:f}),e.separators.forEach(e=>{Jh(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,Rg)}),h_.get(d)===1&&(d.addEventListener(`dblclick`,Pg,!0),d.addEventListener(`pointerdown`,Gg,!0),d.addEventListener(`pointerleave`,o_),d.addEventListener(`pointermove`,s_),d.addEventListener(`pointerout`,c_),d.addEventListener(`pointerup`,l_,!0)),function(){t=!1,h_.set(d,Math.max(0,(h_.get(d)??0)-1)),sg(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,Rg)}),h_.get(d)||(d.removeEventListener(`dblclick`,Pg,!0),d.removeEventListener(`pointerdown`,Gg,!0),d.removeEventListener(`pointerleave`,o_),d.removeEventListener(`pointermove`,s_),d.removeEventListener(`pointerout`,c_),d.removeEventListener(`pointerup`,l_,!0)),a.disconnect()}}function __(){let[e,t]=(0,Z.useState)({});return[e,(0,Z.useCallback)(()=>t({}),[])]}function v_(e){let t=(0,Z.useId)();return`${e??t}`}var y_=typeof window<`u`?Z.useLayoutEffect:Z.useEffect;function b_(e){let t=(0,Z.useRef)(e);return y_(()=>{t.current=e},[e]),(0,Z.useCallback)((...e)=>t.current?.(...e),[t])}function x_(...e){return b_(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function S_(e){let t=(0,Z.useRef)({...e});return y_(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var C_=(0,Z.createContext)(null);function w_(e,t){let n=(0,Z.useRef)({getLayout:()=>({}),setLayout:Kg});(0,Z.useImperativeHandle)(t,()=>n.current,[]),y_(()=>{Object.assign(n.current,Ig({groupId:e}))})}function T_({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){let m=(0,Z.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=b_(e=>{jg(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=b_(e=>{jg(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e))}),_=v_(s),v=(0,Z.useRef)(null),[y,b]=__(),x=(0,Z.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=x_(v,a);w_(_,o);let C=b_((e,t)=>{let r=Vg(),i=cg(e),a=lg(e);if(a){let e=!1;switch(r.state){case`active`:e=r.hitRegions.some(e=>e.group===i);break}return{flexGrow:a.layout[t]??1,pointerEvents:e?`none`:void 0}}if(n?.[t])return{flexGrow:n?.[t]}}),w=S_({defaultLayout:n,disableCursor:r}),T=(0,Z.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=Yh(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=Yh(u,[...t.separators,e]),b(),()=>{t.separators=t.separators.filter(t=>t!==e),b()}},updatePanelProps:(e,{disabled:t})=>{let n=x.current.panels.find(t=>t.id===e);n&&(n.panelConstraints.disabled=t);let r=cg(_),i=lg(_);r&&i&&fg(r,{...i,derivedPanelConstraints:qh(r)})},updateSeparatorProps:(e,{disabled:t,disableDoubleClick:n})=>{let r=x.current.separators.find(t=>t.id===e);r&&(r.disabled=t,r.disableDoubleClick=n)}}),[C,_,b,u,w]),E=(0,Z.useRef)(null);return y_(()=>{let e=v.current;if(e===null)return;let t=x.current,n;if(w.defaultLayout!==void 0&&Object.keys(w.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=w.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={disabled:!!i,element:e,id:_,mutableState:{defaultLayout:n,disableCursor:!!w.disableCursor,expandedPanelSizes:x.current.lastExpandedPanelSizes,layouts:x.current.layouts},orientation:u,panels:t.panels,resizeTargetMinimumSize:t.resizeTargetMinimumSize,separators:t.separators};E.current=r;let a=g_(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=lg(r.id,!0);!o&&s.length>0&&(h(c),g(c));let l=dg(_,e=>{let{defaultLayoutDeferred:t,derivedPanelConstraints:n,layout:i}=e.next;if(t||n.length===0)return;let a=r.panels.map(({id:e})=>e).join(`,`);r.mutableState.layouts[a]=i,n.forEach(t=>{if(t.collapsible){let{layout:n}=e.prev??{};if(n){let e=Dg(t.collapsedSize,i[t.panelId]),a=Dg(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=Vg().state!==`active`;h(i),o&&g(i)});return()=>{E.current=null,a(),l()}},[i,_,g,h,u,y,w]),(0,Z.useEffect)(()=>{let e=E.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,X.jsx)(C_.Provider,{value:T,children:(0,X.jsx)(`div`,{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:S,style:{height:`100%`,width:`100%`,overflow:`hidden`,...f,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:e})})}T_.displayName=`Group`;function E_(){let e=(0,Z.useContext)(C_);return Jh(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function D_(e,t){let{id:n}=E_(),r=(0,Z.useRef)({collapse:qg,expand:qg,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:qg});(0,Z.useImperativeHandle)(t,()=>r.current,[]),y_(()=>{Object.assign(r.current,Ng({groupId:n,panelId:e}))})}function O_({children:e,className:t,collapsedSize:n=`0%`,collapsible:r=!1,defaultSize:i,disabled:a,elementRef:o,groupResizeBehavior:s=`preserve-relative-size`,id:c,maxSize:l=`100%`,minSize:u=`0%`,onResize:d,panelRef:f,style:p,...m}){let h=!!c,g=v_(c),_=S_({disabled:a}),v=(0,Z.useRef)(null),y=x_(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,updatePanelProps:w}=E_(),T=d!==null,E=b_((e,t,n)=>{d?.(e,c,n)});y_(()=>{let e=v.current;if(e!==null)return C({element:e,id:g,idIsStable:h,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:T?E:void 0,panelConstraints:{groupResizeBehavior:s,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:l,minSize:u}})},[s,n,r,i,T,g,h,l,u,E,C,_]),(0,Z.useEffect)(()=>{w(g,{disabled:a})},[a,g,w]),D_(g,f);let D=()=>{let e=b(x,g);if(e)return JSON.stringify(e)},O=(0,Z.useSyncExternalStore)(e=>dg(x,e),D,D),k;return k=O?JSON.parse(O):i?{flexGrow:void 0,flexShrink:void 0,flexBasis:i}:{flexGrow:1},(0,X.jsx)(`div`,{...m,"data-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...k_,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...k},children:(0,X.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...p,touchAction:S===`horizontal`?`pan-y`:`pan-x`},children:e})})}O_.displayName=`Panel`;var k_={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function A_(){return(0,Z.useRef)(null)}function j_({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a,o=e[n],s=t.find(e=>e.panelId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=Mg({layout:Ag({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=Mg({layout:Ag({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function M_({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,style:o,...s}){let c=v_(a),l=S_({disabled:n,disableDoubleClick:r}),[u,d]=(0,Z.useState)({}),[f,p]=(0,Z.useState)(`inactive`),m=(0,Z.useRef)(null),h=x_(m,i),{disableCursor:g,id:_,orientation:v,registerSeparator:y,updateSeparatorProps:b}=E_(),x=v===`horizontal`?`vertical`:`horizontal`;y_(()=>{let e=m.current;if(e!==null){let t={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:e,id:c},n=y(t),r=Hg(e=>{p(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=dg(_,e=>{let{derivedPanelConstraints:n,layout:r,separatorToPanels:i}=e.next,a=i.get(t);if(a){let e=a[0],t=a.indexOf(e);d(j_({layout:r,panelConstraints:n,panelId:e.id,panelIndex:t}))}});return()=>{r(),i(),n()}}},[_,c,y,l]),(0,Z.useEffect)(()=>{b(c,{disabled:n,disableDoubleClick:r})},[n,r,c,b]);let S;return n&&!g&&(S=`not-allowed`),(0,X.jsx)(`div`,{...s,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":x,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":n?`disabled`:f,"data-testid":c,id:c,ref:h,role:`separator`,style:{flexBasis:`auto`,cursor:S,...o,flexGrow:0,flexShrink:0,touchAction:`none`},tabIndex:n?void 0:0})}M_.displayName=`Separator`;function N_(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,X.jsx)(`div`,{className:`tiptap-editor pt-10`,role:`status`,"aria-busy":`true`,"aria-label":`Loading document`,children:(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsx)(nr,{className:`h-9 w-2/5 mt-6 mb-5`}),(0,X.jsx)(nr,{className:`h-4 w-full`}),(0,X.jsx)(nr,{className:`h-4 w-3/4`})]})}),e[0]=t):t=e[0],t}var P_=1700,F_=3;function I_(e,t,n){let r=n?.windowMs??600,i=n?.maxLevel??F_;if(e===0||t>=r)return 1;let a=e+1;return a>i?i:a}var L_={0:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},1:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},2:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},3:{count:16,startRadius:11,baseDistance:7,distanceVariance:3,sizeMin:.45,sizeMax:1.2,maxDelay:250,durationMin:620,durationMax:1400}},R_=[`var(--color-azure-blue)`,`var(--color-sky-blue)`,`var(--color-violet-300)`,`var(--color-orange-light)`,`var(--color-crystal-blue)`,`var(--color-white-cream)`];function z_(e,t={}){let n=t.rng??Math.random,r=t.colors??R_,i=L_[e];if(i.count===0||r.length===0)return[];let a=[],o=Math.PI*2/i.count;for(let e=0;e<i.count;e++){let t=e*o+(n()-.5)*o*.7,s=i.baseDistance+(n()-.5)*2*i.distanceVariance,c=i.sizeMin+n()*(i.sizeMax-i.sizeMin),l=n()*i.maxDelay,u=i.durationMin+n()*(i.durationMax-i.durationMin),d=Math.floor(n()*r.length),f=Math.cos(t),p=Math.sin(t);a.push({id:e,dx:f*s,dy:p*s,originDx:f*i.startRadius,originDy:p*i.startRadius,size:c,color:r[d]??`currentColor`,delay:l,duration:u})}return a}var B_=1.8,V_=90,H_=16,U_=380,W_=.025,G_=.1,K_=.18,q_=400,J_=9.2736,Y_=18.1799,X_=14.5244,Z_={1:{halfWidth:1.5,apexLift:2.2},2:{halfWidth:1.4,apexLift:2.6},3:{halfWidth:1.25,apexLift:3}};function Q_(e,t){let{halfWidth:n,apexLift:r}=Z_[t];return`M${e-n} ${X_+.3} Q${e} ${X_-r}, ${e+n} ${X_+.3}`}function $_(e){let t=1.5,n=.3;return`M${e-t} ${X_-n} Q${e} ${X_+1.4}, ${e+t} ${X_-n}`}var ev=15,tv=15;function nv(e){return{fill:e.color,"--fx-tx":`${e.dx}px`,"--fx-ty":`${e.dy}px`,"--fx-delay":`${e.delay}ms`,"--fx-duration":`${e.duration}ms`}}function rv(e){let t=(0,Q.c)(71),{size:n,className:r,trackMouse:i,variant:a,celebrateSignal:o}=e,s=n===void 0?48:n,c=i===void 0?!0:i,l=a===void 0?`default`:a,u=o===void 0?0:o,d=(0,Z.useRef)(null),f=(0,Z.useRef)(null),p=(0,Z.useRef)(null),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m={x:0,y:0},t[0]=m):m=t[0];let h=(0,Z.useRef)(m),[g,_]=(0,Z.useState)(0),[v,y]=(0,Z.useState)(0),b;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(b=[],t[1]=b):b=t[1];let[x,S]=(0,Z.useState)(b),C=(0,Z.useRef)(0),w=(0,Z.useRef)(void 0),T=l===`sleeping`,E;t[2]!==g||t[3]!==T?(E=function(){if(T)return;let e=typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now(),t=C.current===0?1/0:e-C.current;C.current=e;let n=I_(g,t);_(n),y(sv),S(z_(n)),clearTimeout(w.current),w.current=setTimeout(()=>{_(0),S([])},P_)},t[2]=g,t[3]=T,t[4]=E):E=t[4];let D=E,O,k;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(O=()=>()=>clearTimeout(w.current),k=[],t[5]=O,t[6]=k):(O=t[5],k=t[6]),(0,Z.useEffect)(O,k);let A,j;t[7]!==u||t[8]!==T?(A=()=>{u===0||T||(_(3),y(ov),S(z_(3)),clearTimeout(w.current),w.current=setTimeout(()=>{_(0),S([])},P_))},j=[u,T],t[7]=u,t[8]=T,t[9]=A,t[10]=j):(A=t[9],j=t[10]),(0,Z.useEffect)(A,j);let M,N;t[11]!==T||t[12]!==c?(M=()=>{if(!c||T||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let e=0,t=0,n=!1,r=0,i=0,a=0,o=0,s=0,l=function(r){e=r.clientX,t=r.clientY,n=!0};function u(){if(s=requestAnimationFrame(u),!n)return;let c=f.current,l=d.current;if(!c||!l)return;let m=c.getBoundingClientRect(),g=m.left+m.width/2,_=m.top+m.height*.48,v=e-g,y=t-_,b=Math.hypot(v,y),x=Math.max(-1,Math.min(1,v/U_)),S=Math.max(-1,Math.min(1,y/U_)),C=x*H_,w=-S*H_;r+=(w-r)*G_,i+=(C-i)*G_,l.style.transform=`perspective(${q_}px) rotateX(${r.toFixed(3)}deg) rotateY(${i.toFixed(3)}deg)`;let T=0,E=0;if(b>=1){let e=Math.min(b/V_,1)*B_;T=v/b*e,E=y/b*e}a+=(T-a)*K_,o+=(E-o)*K_;let D=i*W_,O=-r*W_,k=a+D,A=o+O;h.current.x=k,h.current.y=A,p.current?.setAttribute(`transform`,`translate(${k.toFixed(3)} ${A.toFixed(3)})`)}return document.addEventListener(`mousemove`,l,{passive:!0}),s=requestAnimationFrame(u),()=>{document.removeEventListener(`mousemove`,l),cancelAnimationFrame(s),d.current&&(d.current.style.transform=``),h.current={x:0,y:0},p.current?.removeAttribute(`transform`)}},N=[c,T],t[11]=T,t[12]=c,t[13]=M,t[14]=N):(M=t[13],N=t[14]),(0,Z.useEffect)(M,N);let P;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(P=()=>{let e=p.current;if(!e)return;let{x:t,y:n}=h.current;e.setAttribute(`transform`,`translate(${t.toFixed(3)} ${n.toFixed(3)})`)},t[15]=P):P=t[15],(0,Z.useLayoutEffect)(P);let F=g>0,I=F?g:1,L=F?`ok-blob-clicked-${g}`:null,R;t[16]===r?R=t[17]:(R=q(`ok-blob-3d-wrapper`,r),t[16]=r,t[17]=R);let z=T?`cursor-default`:`cursor-pointer`,B=`body-${v}`,V=T&&`ok-blob-sleeping`,H;t[18]!==L||t[19]!==V?(H=q(`ok-blob-group`,V,L),t[18]=L,t[19]=V,t[20]=H):H=t[20];let U;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,X.jsx)(`path`,{d:`M25.2339 6.78134C25.5199 7.35734 25.8179 8.47234 26.0179 9.07834C26.0189 9.08234 26.0209 9.08634 26.0219 9.09134C26.0229 9.09534 26.0249 9.10034 26.0259 9.10434C26.0539 9.19734 26.0949 9.29533 26.1519 9.41633C26.2919 9.71133 26.5269 10.1173 27.1299 11.1683C27.3259 11.4643 27.5209 11.7693 27.7119 12.0903C29.9739 15.1623 29.3259 20.1913 27.0469 22.9153C26.7779 23.2953 26.4869 23.6043 26.1889 23.8863C26.1519 23.9253 26.1129 23.9643 26.0729 24.0033C25.3159 24.7543 24.2949 25.4673 23.6129 25.8323C22.7469 26.2983 22.1349 26.5483 21.6299 26.7463C20.3649 27.3063 19.0609 27.7733 17.6569 28.0423C15.9649 28.3513 14.1939 28.4433 12.4569 28.1373C11.4779 27.9663 10.5119 27.6663 9.60891 27.2493C8.77491 26.8663 7.99192 26.3853 7.26992 25.8403C6.83592 25.5393 6.43893 25.2343 6.08093 24.9383C5.57893 24.5223 5.15993 24.1263 4.83493 23.7793C4.04993 22.9443 3.31593 21.8893 2.80893 21.0953C2.72593 20.9663 2.64792 20.8433 2.57592 20.7293C2.56192 20.7093 2.54793 20.6893 2.53393 20.6703C2.08593 20.0263 1.71892 19.3293 1.43792 18.5993C1.42892 18.5453 1.42093 18.4903 1.41293 18.4353C1.32093 17.7443 1.08292 16.9423 1.01092 15.6333C0.984921 15.0653 0.998928 14.4013 1.12393 13.6353C1.20693 13.1413 1.31993 12.9023 1.40893 12.7113C1.43593 12.6543 1.46193 12.6023 1.48593 12.5483C1.56793 12.3653 1.59392 12.1563 1.63592 11.9083C1.68992 11.5883 1.76992 11.1943 2.04592 10.7553C2.94392 9.37934 3.36792 8.81934 3.66592 8.33934C3.75592 8.20334 3.84292 8.08134 3.94192 7.96634C4.21592 7.64634 4.67693 7.29534 5.10293 7.05734C5.16693 7.02234 5.23093 6.98834 5.29193 6.95534C5.62993 6.77834 6.22592 6.30135 6.66992 5.92035C6.83692 5.77635 7.08193 5.60735 7.37393 5.40935C7.67393 5.20535 8.02593 4.96934 8.39193 4.70234C9.32093 4.02634 9.84091 3.69134 10.2599 3.42334C10.3799 3.34734 10.4919 3.27734 10.6049 3.20834C10.9609 2.98834 11.4149 2.73034 11.8869 2.48634C12.4519 2.19334 13.0469 1.92133 13.5089 1.72233C14.7399 1.30233 16.0539 1.01333 17.4169 1.00033C18.1169 0.991333 18.7939 1.16534 19.2389 1.43034C19.6869 1.69534 19.8689 2.00335 19.8039 2.23935C19.7379 2.47835 19.4399 2.63634 19.0109 2.74734C18.5789 2.85634 18.0469 2.92035 17.4889 2.96135C16.3639 3.04235 15.2399 3.36435 14.1499 3.80835C12.8199 4.35135 11.5379 5.07133 10.2719 5.84733C9.38691 6.39133 8.51192 6.97334 7.63592 7.56834C7.54492 7.63034 7.45492 7.69135 7.36492 7.75235C6.97392 8.06635 6.58293 8.38134 6.22293 8.66334C5.97893 8.85734 5.76793 9.04834 5.59393 9.21434C5.26893 9.52334 5.02393 9.74334 4.81893 9.93934C4.67793 10.0753 4.55793 10.2013 4.45593 10.3443C4.40093 10.4213 4.32992 10.5273 4.24792 10.6593C3.90492 11.1933 3.44493 12.1693 3.15393 13.1173C3.01893 13.5363 2.87991 14.0343 2.79391 14.5253C2.66591 15.2253 2.65594 15.9053 2.71994 16.2373C2.82794 16.8193 2.95593 17.4833 3.14093 18.0553C3.31293 18.6003 3.52991 19.0583 3.70791 19.2823C3.81591 19.4183 3.90394 19.5473 3.99594 19.6913C4.09394 19.8413 4.19191 20.0073 4.31091 20.2033C4.47891 20.4803 4.68592 20.8163 5.00192 21.2493C5.36492 21.7463 5.61793 22.1043 5.83493 22.4023C6.14493 22.8243 6.38591 23.1343 6.83691 23.5033C7.33891 23.9113 7.86593 24.3113 8.26693 24.6393C8.44893 24.7883 8.66993 24.9443 8.90493 25.0963C9.21593 25.2963 9.55192 25.4893 9.85592 25.6703C10.1059 25.8203 10.3059 25.9633 10.4869 26.0863C10.5429 26.1243 10.5979 26.1603 10.6519 26.1943C10.8699 26.2803 11.0929 26.3593 11.3159 26.4283C11.3539 26.4323 11.3949 26.4353 11.4369 26.4393C11.6509 26.4573 11.9089 26.4733 12.2209 26.5133C12.7169 26.5753 13.1399 26.6603 13.6019 26.7243C13.9589 26.7733 14.3409 26.8083 14.7729 26.7893C15.0729 26.7753 15.4069 26.7353 15.7389 26.6813C16.2349 26.6023 16.7179 26.4943 17.0569 26.4473C17.1499 26.4343 17.2359 26.4343 17.3209 26.4373C17.3489 26.4393 17.3799 26.4413 17.4109 26.4433C17.4119 26.4433 17.4119 26.4433 17.4129 26.4433C17.4199 26.4433 17.4279 26.4443 17.4349 26.4443C18.2329 26.2413 19.0259 25.9433 19.7959 25.5983C19.8609 25.5633 19.9259 25.5273 19.9899 25.4913C20.3059 25.3173 20.6049 25.1383 20.7869 24.9943C20.9829 24.8393 21.5189 24.5373 22.0579 24.1853C22.4109 23.9553 22.7649 23.7053 23.0369 23.4833C23.1949 23.3553 23.3689 23.2693 23.5479 23.1773C23.7129 23.0923 23.8809 23.0013 24.0349 22.8653C24.1109 22.7983 24.1869 22.7173 24.2639 22.6303C24.3309 22.5563 24.4039 22.4723 24.4759 22.3923C24.5459 22.3153 24.7199 22.1723 24.9139 21.9793C25.0079 21.8863 25.1059 21.7783 25.1909 21.6713C25.2199 21.6323 25.2489 21.5943 25.2769 21.5553C25.5919 21.0403 25.8779 20.5003 26.1019 19.9653C26.1299 19.8403 26.1379 19.7293 26.1279 19.6373C26.1199 19.5703 26.1029 19.5113 26.0839 19.4503C26.0599 19.3643 26.0329 19.2773 26.0239 19.1723C26.0169 19.0893 26.0309 19.0043 26.0629 18.9543C26.0779 18.9323 26.0969 18.9143 26.1129 18.8993C26.1329 18.8823 26.1499 18.8673 26.1569 18.8443C26.1609 18.8273 26.1579 18.8073 26.1529 18.7833C26.1459 18.7443 26.1369 18.6943 26.1539 18.6293C26.2189 18.3853 26.2869 18.1103 26.3319 17.8383C26.3829 17.5393 26.4049 17.2433 26.3949 17.0123C26.3849 16.7493 26.3909 16.3823 26.3469 16.0003C26.3179 15.7343 26.2659 15.4663 26.1979 15.2383C26.1319 15.0143 26.0219 14.7913 25.9039 14.5783C25.7629 14.3223 25.6119 14.0783 25.5169 13.8453C25.4969 13.7983 25.4999 13.7263 25.4999 13.6323C25.5009 13.5673 25.4999 13.4913 25.4919 13.4083C25.3239 13.1243 25.1459 12.8423 24.9589 12.5483C24.9479 12.5413 24.9369 12.5333 24.9249 12.5263C24.6689 12.3503 24.3139 12.1173 24.0769 11.5503C24.0179 11.4063 24.0069 11.2983 23.9969 11.1993C23.9859 11.1013 23.9799 11.0183 23.9289 10.9093C23.8709 10.7853 23.7759 10.6583 23.6709 10.4993C23.5849 10.3703 23.4899 10.2133 23.4199 10.0423C23.3819 9.95134 23.3509 9.85734 23.3329 9.75934C23.3299 9.74334 23.3269 9.72534 23.3229 9.70634C23.2899 9.52734 23.2439 9.26534 23.2409 8.98634C23.0209 8.24434 22.8339 7.48833 22.6519 6.77633C22.3429 5.57133 22.0519 4.54234 21.3329 3.95434C20.9839 3.65334 20.5689 3.35433 20.2459 3.05433C19.9259 2.75633 19.7449 2.47534 19.8019 2.23834C19.8639 2.00634 20.1589 1.82934 20.6659 1.80534C21.1699 1.78334 21.8699 1.93235 22.5209 2.39235C23.6159 3.14235 24.2029 4.38334 24.5599 5.35734C24.5829 5.40834 24.6049 5.46034 24.6259 5.51234C24.7849 5.89434 24.9529 6.22834 25.1199 6.55534C25.1579 6.63034 25.1969 6.70834 25.2339 6.78134Z`,className:`ok-blob-body`}),t[21]=U):U=t[21];let W=(F||T)&&`ok-blob-eye-hidden`,G;t[22]===W?G=t[23]:(G=q(`ok-blob-eye`,W),t[22]=W,t[23]=G);let ee;t[24]===G?ee=t[25]:(ee=(0,X.jsx)(`ellipse`,{cx:J_,cy:X_,rx:1.2722,ry:1.9083,className:G}),t[24]=G,t[25]=ee);let K=(F||T)&&`ok-blob-eye-hidden`,te;t[26]===K?te=t[27]:(te=q(`ok-blob-eye ok-blob-eye-right`,K),t[26]=K,t[27]=te);let ne;t[28]===te?ne=t[29]:(ne=(0,X.jsx)(`ellipse`,{cx:Y_,cy:X_,rx:1.2722,ry:1.9083,className:te}),t[28]=te,t[29]=ne);let re;t[30]===I?re=t[31]:(re=Q_(J_,I),t[30]=I,t[31]=re);let ie=(!F||T)&&`ok-blob-eye-hidden`,ae;t[32]===ie?ae=t[33]:(ae=q(`ok-blob-happy-eye`,ie),t[32]=ie,t[33]=ae);let oe;t[34]!==re||t[35]!==ae?(oe=(0,X.jsx)(`path`,{d:re,strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:ae}),t[34]=re,t[35]=ae,t[36]=oe):oe=t[36];let se;t[37]===I?se=t[38]:(se=Q_(Y_,I),t[37]=I,t[38]=se);let ce=(!F||T)&&`ok-blob-eye-hidden`,le;t[39]===ce?le=t[40]:(le=q(`ok-blob-happy-eye`,ce),t[39]=ce,t[40]=le);let ue;t[41]!==se||t[42]!==le?(ue=(0,X.jsx)(`path`,{d:se,strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:le}),t[41]=se,t[42]=le,t[43]=ue):ue=t[43];let de;t[44]===T?de=t[45]:(de=T?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`path`,{d:$_(J_),strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:`ok-blob-sleeping-eye`}),(0,X.jsx)(`path`,{d:$_(Y_),strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:`ok-blob-sleeping-eye`})]}):null,t[44]=T,t[45]=de);let fe;t[46]!==ee||t[47]!==ne||t[48]!==oe||t[49]!==ue||t[50]!==de?(fe=(0,X.jsxs)(`g`,{ref:p,children:[ee,ne,oe,ue,de]}),t[46]=ee,t[47]=ne,t[48]=oe,t[49]=ue,t[50]=de,t[51]=fe):fe=t[51];let pe;t[52]!==B||t[53]!==H||t[54]!==fe?(pe=(0,X.jsxs)(`g`,{className:H,children:[U,fe]},B),t[52]=B,t[53]=H,t[54]=fe,t[55]=pe):pe=t[55];let me;t[56]===T?me=t[57]:(me=T?(0,X.jsxs)(`g`,{children:[(0,X.jsx)(`text`,{x:21,y:7,className:`ok-blob-z ok-blob-z-1`,children:`z`}),(0,X.jsx)(`text`,{x:26,y:2,className:`ok-blob-z ok-blob-z-2`,children:`z`})]}):null,t[56]=T,t[57]=me);let he;t[58]!==v||t[59]!==x?(he=x.length>0&&(0,X.jsx)(`g`,{children:x.map(iv)},`firework-${v}`),t[58]=v,t[59]=x,t[60]=he):he=t[60];let ge;t[61]!==D||t[62]!==s||t[63]!==z||t[64]!==pe||t[65]!==me||t[66]!==he?(ge=(0,X.jsxs)(`svg`,{ref:f,width:s,height:s,viewBox:`0 0 30 30`,fill:`none`,overflow:`visible`,xmlns:`http://www.w3.org/2000/svg`,className:z,"aria-hidden":`true`,onClick:D,onMouseDown:av,children:[pe,me,he]}),t[61]=D,t[62]=s,t[63]=z,t[64]=pe,t[65]=me,t[66]=he,t[67]=ge):ge=t[67];let _e;return t[68]!==R||t[69]!==ge?(_e=(0,X.jsx)(`span`,{ref:d,className:R,children:ge}),t[68]=R,t[69]=ge,t[70]=_e):_e=t[70],_e}function iv(e){return(0,X.jsx)(`circle`,{cx:ev+e.originDx,cy:tv+e.originDy,r:e.size,className:`ok-blob-firework`,style:nv(e)},e.id)}function av(e){return e.preventDefault()}function ov(e){return e+1}function sv(e){return e+1}function cv(e){let t=(0,Q.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=q(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(jc,{"data-slot":`label`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function lv(e){let t=(0,Q.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,orientation:i,decorative:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`horizontal`:i,s=a===void 0?!0:a,c;t[5]===n?c=t[6]:(c=q(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,n),t[5]=n,t[6]=c);let l;return t[7]!==s||t[8]!==o||t[9]!==r||t[10]!==c?(l=(0,X.jsx)(ul,{"data-slot":`separator`,decorative:s,orientation:o,className:c,...r}),t[7]=s,t[8]=o,t[9]=r,t[10]=c,t[11]=l):l=t[11],l}var uv=lt(`group/field flex w-full gap-2 data-[invalid=true]:text-destructive`,{variants:{orientation:{vertical:`flex-col *:w-full [&>.sr-only]:w-auto`,horizontal:`flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`,responsive:`flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`}},defaultVariants:{orientation:`vertical`}});function dv(e){let t=(0,Q.c)(11),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?`vertical`:i,o;t[4]!==n||t[5]!==a?(o=q(uv({orientation:a}),n),t[4]=n,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==a||t[8]!==r||t[9]!==o?(s=(0,X.jsx)(`div`,{role:`group`,"data-slot":`field`,"data-orientation":a,className:o,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function fv(e){let t=(0,Q.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=q(`group/field-content flex flex-1 flex-col gap-0.5 leading-snug`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(`div`,{"data-slot":`field-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function pv(e){let t=(0,Q.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=q(`group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10`,`has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(cv,{"data-slot":`field-label`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function mv(e){let t=(0,Q.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=q(`flex w-fit items-center gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(`div`,{"data-slot":`field-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function hv(e){let t=(0,Q.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=q(`text-left text-sm leading-normal font-normal text-muted-foreground group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5`,`last:mt-0 nth-last-2:-mt-1`,`[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(`p`,{"data-slot":`field-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function gv(e){let t=(0,Q.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=q(`grid w-full gap-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(nl,{"data-slot":`radio-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function _v(e){let t=(0,Q.c)(9),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=q(`group/radio-group-item peer relative flex aspect-square size-4 shrink-0 rounded-full border border-input outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary`,n),t[3]=n,t[4]=i);let a;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(il,{"data-slot":`radio-group-indicator`,className:`flex size-4 items-center justify-center`,children:(0,X.jsx)(`span`,{className:`absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary-foreground`})}),t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==i?(o=(0,X.jsx)(rl,{"data-slot":`radio-group-item`,className:i,...r,children:a}),t[6]=r,t[7]=i,t[8]=o):o=t[8],o}function vv(){let e=typeof window<`u`?window.okDesktop:void 0;return e?.seed?{plan:t=>e.seed.plan(t),apply:t=>e.seed.apply(t)}:{plan:async e=>{let t=e?`?rootDir=${encodeURIComponent(e)}`:``;return await(await fetch(`/api/seed/plan${t}`)).json()},apply:async e=>await(await fetch(`/api/seed/apply`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({plan:e})})).json()}}function yv(e){let t=(0,Q.c)(45),{open:n,onOpenChange:r,onSeedApplied:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a={kind:`loading`},t[0]=a):a=t[0];let[o,s]=(0,Z.useState)(a),[c,l]=(0,Z.useState)(`project-root`),[u,d]=(0,Z.useState)(`brain`),f=(0,Z.useRef)(!0),p,m;t[1]===n?(p=t[2],m=t[3]):(p=()=>{n&&(l(`project-root`),d(`brain`),f.current=!0)},m=[n],t[1]=n,t[2]=p,t[3]=m),(0,Z.useEffect)(p,m);let h;t[4]===u?h=t[5]:(h=u.trim(),t[4]=u,t[5]=h);let g=h,_=c===`subfolder`&&g===``,v,y;t[6]!==n||t[7]!==c||t[8]!==_||t[9]!==g?(v=()=>{if(!n)return;if(_){s({kind:`error`,message:`Enter a folder name (e.g. brain).`});return}let e=c===`project-root`?void 0:g,t=f.current?0:200;f.current=!1;let r=!1,i=setTimeout(()=>{r||(s(bv),vv().plan(e).then(e=>{if(!r){if(!e.ok){s({kind:`error`,message:e.error.message});return}s(e.plan.created.length>0||e.plan.configEdits.length>0?{kind:`plan`,plan:e.plan}:{kind:`already-seeded`,plan:e.plan})}}).catch(e=>{r||s({kind:`error`,message:e instanceof Error?e.message:String(e)})}))},t);return()=>{r=!0,clearTimeout(i)}},y=[n,c,g,_],t[6]=n,t[7]=c,t[8]=_,t[9]=g,t[10]=v,t[11]=y):(v=t[10],y=t[11]),(0,Z.useEffect)(v,y);let b;t[12]!==r||t[13]!==i||t[14]!==o.kind||t[15]!==o.plan?(b=async function(){if(o.kind!==`plan`)return;s({kind:`applying`,plan:o.plan});let e=await vv().apply(o.plan);e.ok?(Ar.success(`LLM brain initialized (${e.result.applied} ${e.result.applied===1?`entry`:`entries`})`),i?.(),r(!1)):(Ar.error(`Initialize failed: ${e.error.message}`),s({kind:`error`,message:e.error.message}))},t[12]=r,t[13]=i,t[14]=o.kind,t[15]=o.plan,t[16]=b):b=t[16];let x=b,S;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,X.jsxs)(Er,{children:[(0,X.jsxs)(hr,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Yn,{"aria-hidden":`true`,className:`h-4 w-4 text-foreground opacity-70`}),`Initialize LLM brain`]}),(0,X.jsx)(pr,{children:`Three layers designed so AI agents can navigate naturally: raw sources, working drafts, and canonical articles.`})]}),t[17]=S):S=t[17];let C;t[18]!==c||t[19]!==u?(C=(0,X.jsx)(xv,{choice:c,subfolder:u,onChoiceChange:l,onSubfolderChange:d}),t[18]=c,t[19]=u,t[20]=C):C=t[20];let w;t[21]===o?w=t[22]:(w=(0,X.jsx)(Sv,{phase:o}),t[21]=o,t[22]=w);let T;t[23]!==w||t[24]!==C?(T=(0,X.jsxs)(Sr,{className:`space-y-6`,children:[C,w]}),t[23]=w,t[24]=C,t[25]=T):T=t[25];let E;t[26]===r?E=t[27]:(E=()=>r(!1),t[26]=r,t[27]=E);let D=o.kind===`already-seeded`||o.kind===`error`?`Close`:`Cancel`,O;t[28]!==E||t[29]!==D?(O=(0,X.jsx)(J,{className:`uppercase font-mono`,variant:`ghost`,onClick:E,children:D}),t[28]=E,t[29]=D,t[30]=O):O=t[30];let k;t[31]!==x||t[32]!==o.kind||t[33]!==_?(k=o.kind===`plan`?(0,X.jsx)(J,{onClick:x,disabled:_,children:`Initialize`}):o.kind===`applying`?(0,X.jsxs)(J,{disabled:!0,children:[(0,X.jsx)(Rn,{"aria-hidden":`true`,className:`h-4 w-4 animate-spin`}),`Setting up…`]}):null,t[31]=x,t[32]=o.kind,t[33]=_,t[34]=k):k=t[34];let A;t[35]!==O||t[36]!==k?(A=(0,X.jsxs)(Cr,{children:[O,k]}),t[35]=O,t[36]=k,t[37]=A):A=t[37];let j;t[38]!==T||t[39]!==A?(j=(0,X.jsxs)(yr,{className:`sm:max-w-2xl`,"data-ok-layer-spawned":``,children:[S,T,A]}),t[38]=T,t[39]=A,t[40]=j):j=t[40];let M;return t[41]!==r||t[42]!==n||t[43]!==j?(M=(0,X.jsx)(Dr,{open:n,onOpenChange:r,children:j}),t[41]=r,t[42]=n,t[43]=j,t[44]=M):M=t[44],M}function bv(e){return e.kind===`plan`||e.kind===`already-seeded`?e:{kind:`loading`}}function xv(e){let t=(0,Q.c)(21),{choice:n,subfolder:r,onChoiceChange:i,onSubfolderChange:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,X.jsx)(`p`,{className:`text-sm font-medium`,children:`Where should the brain live?`}),t[0]=o):o=t[0];let s;t[1]===i?s=t[2]:(s=e=>i(e),t[1]=i,t[2]=s);let c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,X.jsx)(pv,{htmlFor:`seed-root-project-root`,children:(0,X.jsxs)(dv,{orientation:`horizontal`,children:[(0,X.jsxs)(fv,{children:[(0,X.jsx)(mv,{children:`Project root`}),(0,X.jsx)(hv,{children:`Scaffold the three folders directly under this project.`})]}),(0,X.jsx)(_v,{value:`project-root`,id:`seed-root-project-root`})]})}),t[3]=c):c=t[3];let l,u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,X.jsx)(mv,{children:`In a subfolder`}),u=(0,X.jsx)(hv,{className:`nth-last-2:mt-0`,children:`Created if missing. Reuses the folder if it already exists.`}),t[4]=l,t[5]=u):(l=t[4],u=t[5]);let d;t[6]===a?d=t[7]:(d=e=>a(e.target.value),t[6]=a,t[7]=d);let f;t[8]===i?f=t[9]:(f=()=>i(`subfolder`),t[8]=i,t[9]=f);let p;t[10]!==r||t[11]!==d||t[12]!==f?(p=(0,X.jsxs)(fv,{children:[l,u,(0,X.jsx)(zt,{value:r,onChange:d,onFocus:f,placeholder:`brain`,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,className:`mt-1.5 font-mono text-xs bg-background`})]}),t[10]=r,t[11]=d,t[12]=f,t[13]=p):p=t[13];let m;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,X.jsx)(_v,{value:`subfolder`,id:`seed-root-subfolder`}),t[14]=m):m=t[14];let h;t[15]===p?h=t[16]:(h=(0,X.jsx)(pv,{htmlFor:`seed-root-subfolder`,children:(0,X.jsxs)(dv,{orientation:`horizontal`,children:[p,m]})}),t[15]=p,t[16]=h);let g;return t[17]!==n||t[18]!==h||t[19]!==s?(g=(0,X.jsxs)(`div`,{className:`space-y-2 py-1`,children:[o,(0,X.jsxs)(gv,{className:`sm:flex`,value:n,onValueChange:s,children:[c,h]})]}),t[17]=n,t[18]=h,t[19]=s,t[20]=g):g=t[20],g}function Sv(e){let t=(0,Q.c)(11),{phase:n}=e;if(n.kind===`loading`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsxs)(`div`,{className:`flex items-center gap-2 py-4 text-sm text-muted-foreground`,children:[(0,X.jsx)(Rn,{"aria-hidden":`true`,className:`h-4 w-4 animate-spin`}),`Computing scaffold plan…`]}),t[0]=e):e=t[0],e}if(n.kind===`error`){let e;return t[1]===n.message?e=t[2]:(e=(0,X.jsx)(`div`,{className:`rounded-md bg-destructive/10 p-3 text-sm text-destructive`,children:n.message}),t[1]=n.message,t[2]=e),e}if(n.kind===`already-seeded`){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsxs)(`div`,{className:`py-2 text-sm`,children:[(0,X.jsx)(`p`,{className:`font-medium`,children:`This LLM brain is already set up.`}),(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:`The three-layer structure is in place — there's nothing left to scaffold.`})]}),t[3]=e):e=t[3],e}let r=n.plan,i;t[4]===r?i=t[5]:(i=(0,X.jsx)(Ov,{plan:r}),t[4]=r,t[5]=i);let a;t[6]===r.warnings?a=t[7]:(a=r.warnings.length>0?(0,X.jsx)(`div`,{className:`rounded-md bg-warning/10 p-3 text-xs text-warning-foreground`,children:r.warnings.map(Cv)}):null,t[6]=r.warnings,t[7]=a);let o;return t[8]!==i||t[9]!==a?(o=(0,X.jsxs)(`div`,{className:`space-y-6 py-1 text-sm`,children:[i,a]}),t[8]=i,t[9]=a,t[10]=o):o=t[10],o}function Cv(e){return(0,X.jsx)(`p`,{children:e},e)}var wv=[{name:`external-sources`,blurb:`Raw sources saved verbatim — full text of URLs and PDFs, not just citations. Every claim traces back to preserved evidence.`},{name:`research`,blurb:`Provisional analysis synthesizing sources. Every claim cites a doc; promotes to articles/ once the team trusts the findings.`},{name:`articles`,blurb:`Canonical decisions. Each links back through research/ to its sources — no dead links, full evidence chain in repo.`}],Tv={"log.md":`Append-only timeline`};function Ev(e){return e.split(`/`).pop()??e}function Dv(e){let t=new Map(wv.map(e=>[e.name,e.blurb])),n=e.created.filter(e=>e.kind===`folder`).map(e=>({kind:`folder`,name:`${e.path}/`,description:t.get(Ev(e.path))??``})),r=e.created.filter(e=>e.kind===`file`).map(e=>({kind:`file`,name:e.path,description:Tv[Ev(e.path)]??``})),i=e.configEdits.length>0?[{kind:`config`,name:`.open-knowledge/config.yml`,description:`Folder descriptions for AI agents`}]:[];return[...n,...r,...i]}function Ov(e){let t=(0,Q.c)(13),{plan:n}=e,r,i,a,o;if(t[0]!==n){let e=Dv(n);a=`space-y-3`,t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,X.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase font-mono tracking-wider text-primary`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`flex items-center justify-center`,children:`◇`}),`What gets created`]}),t[5]=o):o=t[5],r=`space-y-3 overflow-y-auto subtle-scrollbar max-h-full`,i=e.map(kv),t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o}else r=t[1],i=t[2],a=t[3],o=t[4];let s;t[6]!==r||t[7]!==i?(s=(0,X.jsx)(`ul`,{className:r,children:i}),t[6]=r,t[7]=i,t[8]=s):s=t[8];let c;return t[9]!==a||t[10]!==o||t[11]!==s?(c=(0,X.jsxs)(`section`,{className:a,children:[o,s]}),t[9]=a,t[10]=o,t[11]=s,t[12]=c):c=t[12],c}function kv(e){return(0,X.jsxs)(`li`,{className:`flex items-start gap-3 rounded-md border border-border/60 bg-muted/20 p-3`,children:[e.kind===`folder`?(0,X.jsx)($i,{"aria-hidden":`true`,className:`mt-1 h-4 w-4 shrink-0 text-muted-foreground`,strokeWidth:1.5}):e.kind===`config`?(0,X.jsx)(Ji,{"aria-hidden":`true`,className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`,strokeWidth:1.5}):(0,X.jsx)(Yi,{"aria-hidden":`true`,className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`,strokeWidth:1.5}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,X.jsx)(`code`,{className:`font-mono text-1sm`,children:e.name}),e.description?(0,X.jsx)(`p`,{className:`text-1sm text-muted-foreground`,children:e.description}):null]})]},e.name)}function Av(){let e=(0,Q.c)(15),[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(`loading`),[s,c]=(0,Z.useState)(0),l=(0,Z.useRef)(!1),u=(0,Z.useRef)(void 0),d,f;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{let e=!1,t=async function(){let t=fetch(`/api/documents`).then(async t=>{let n=await t.json().catch(Fv);e||(t.ok&&n?.ok&&Array.isArray(n.documents)?(i(n.documents.length),l.current=!0):l.current||=(i(1),!0))}).catch(()=>{!e&&!l.current&&(i(1),l.current=!0)}),n=(async()=>{let t=typeof window<`u`?window.okDesktop:void 0;try{let n=t?.seed?await t.seed.plan():await fetch(`/api/seed/plan`).then(Pv);if(e)return;if(!n?.ok){o(`error`);return}o(n.plan.created.length>0||n.plan.configEdits.length>0?`has-work`:`seeded`)}catch{e||o(`error`)}})();await Promise.all([t,n])};t();let n=We(e=>{e.includes(`files`)&&t()});return()=>{e=!0,n(),clearTimeout(u.current)}},f=[],e[0]=d,e[1]=f):(d=e[0],f=e[1]),(0,Z.useEffect)(d,f);let p;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=function(){clearTimeout(u.current),u.current=setTimeout(()=>c(Nv),250),o(`seeded`),fetch(`/api/documents`).then(async e=>{let t=await e.json().catch(Mv);e.ok&&t?.ok&&Array.isArray(t.documents)&&i(t.documents.length)}).catch(jv)},e[2]=p):p=e[2];let m=p,h=a===`has-work`,g=r!==null&&a!==`loading`,_=r===0,v;e[3]===s?v=e[4]:(v=(0,X.jsx)(rv,{size:80,celebrateSignal:s}),e[3]=s,e[4]=v);let y;e[5]!==_||e[6]!==g||e[7]!==h?(y=g?_?(0,X.jsx)(Iv,{onCtaClick:()=>n(!0),showCta:h}):(0,X.jsx)(Lv,{onCtaClick:()=>n(!0),showCta:h}):null,e[5]=_,e[6]=g,e[7]=h,e[8]=y):y=e[8];let b;e[9]===t?b=e[10]:(b=(0,X.jsx)(yv,{open:t,onOpenChange:n,onSeedApplied:m}),e[9]=t,e[10]=b);let x;return e[11]!==v||e[12]!==y||e[13]!==b?(x=(0,X.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-6 px-6`,children:[v,y,b]}),e[11]=v,e[12]=y,e[13]=b,e[14]=x):x=e[14],x}function jv(){}function Mv(){return null}function Nv(e){return e+1}function Pv(e){return e.json()}function Fv(){return null}function Iv(e){let t=(0,Q.c)(7),{onCtaClick:n,showCta:r}=e,i,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,X.jsx)(`h2`,{className:`text-base font-medium`,children:`Welcome to your LLM brain`}),a=(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`A space for working with AI agents. Start with a curated layer structure — or create your own files in the sidebar.`}),t[0]=i,t[1]=a):(i=t[0],a=t[1]);let o;t[2]!==n||t[3]!==r?(o=r?(0,X.jsxs)(J,{className:`mt-1`,onClick:n,children:[(0,X.jsx)(Yn,{"aria-hidden":`true`,className:`h-4 w-4`}),`Initialize LLM brain`]}):null,t[2]=n,t[3]=r,t[4]=o):o=t[4];let s;return t[5]===o?s=t[6]:(s=(0,X.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-3 text-center`,children:[i,a,o]}),t[5]=o,t[6]=s),s}function Lv(e){let t=(0,Q.c)(6),{onCtaClick:n,showCta:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,X.jsx)(`span`,{className:`select-none text-sm text-muted-foreground`,children:`Select a document to edit`}),t[0]=i):i=t[0];let a;t[1]!==n||t[2]!==r?(a=r?(0,X.jsxs)(J,{variant:`ghost`,size:`sm`,className:`uppercase font-mono text-xs`,onClick:n,children:[(0,X.jsx)(Yn,{"aria-hidden":`true`,className:`h-3.5 w-3.5`}),`Initialize LLM brain`]}):null,t[1]=n,t[2]=r,t[3]=a):a=t[3];let o;return t[4]===a?o=t[5]:(o=(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[i,a]}),t[4]=a,t[5]=o),o}function Rv(e){let t=e.split(`/`).pop();return t?`${e}/${t}`:null}function zv(e,t){let n=t.get(`${e}/index`);if(n)return n;let r=Rv(e);if(r){let e=t.get(r);if(e)return e}return e.split(`/`).pop()??e}function Bv(e,t,n){let r=n.get(e);return r&&r!==e?r:t}function Vv(e,t){let n=`${e}/`,r=[...t.folderPaths].filter(e=>e.startsWith(n)).map(e=>({path:e,rel:e.slice(n.length)})).filter(e=>e.rel.length>0&&!e.rel.includes(`/`)).map(({path:e,rel:n})=>({kind:`folder`,path:e,name:n,title:zv(e,t.pageTitles)})),i=[...t.pages].filter(e=>e.startsWith(n)).map(e=>({docName:e,rel:e.slice(n.length)})).filter(e=>e.rel.length>0&&!e.rel.includes(`/`)).map(({docName:e,rel:n})=>{let r=t.pageMeta.get(e);return{kind:`file`,path:e,name:n,title:Bv(e,n,t.pageTitles),size:r?.size??0,modified:r?.modified??``}}),a=[...r,...i].sort((e,t)=>e.kind===t.kind?e.title.localeCompare(t.title)||e.name.localeCompare(t.name):e.kind===`folder`?-1:1);return{title:zv(e,t.pageTitles),children:a}}function Hv(e){let t=(0,Q.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,X.jsx)(gc,{"data-slot":`dropdown-menu`,...n}),t[2]=n,t[3]=r),r}function Uv(e){let t=(0,Q.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,X.jsx)(_c,{"data-slot":`dropdown-menu-trigger`,...n}),t[2]=n,t[3]=r),r}function Wv(e){let t=(0,Q.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,align:i,sideOffset:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`start`:i,s=a===void 0?4:a,c;t[5]===n?c=t[6]:(c=q(`z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:overflow-hidden data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n),t[5]=n,t[6]=c);let l;return t[7]!==o||t[8]!==r||t[9]!==s||t[10]!==c?(l=(0,X.jsx)(vc,{children:(0,X.jsx)(yc,{"data-slot":`dropdown-menu-content`,sideOffset:s,align:o,className:c,...r})}),t[7]=o,t[8]=r,t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function Gv(e){let t=(0,Q.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,inset:r,variant:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?`default`:a,s;t[5]===n?s=t[6]:(s=q(`group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive`,n),t[5]=n,t[6]=s);let c;return t[7]!==r||t[8]!==i||t[9]!==s||t[10]!==o?(c=(0,X.jsx)(xc,{"data-slot":`dropdown-menu-item`,"data-inset":r,"data-variant":o,className:s,...i}),t[7]=r,t[8]=i,t[9]=s,t[10]=o,t[11]=c):c=t[11],c}function Kv(e){let t=(0,Q.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,X.jsx)(Sc,{"data-slot":`dropdown-menu-radio-group`,...n}),t[2]=n,t[3]=r),r}function qv(e){let t=(0,Q.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,children:n,inset:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===r?o=t[6]:(o=q(`relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,r),t[5]=r,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,X.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex items-center justify-center`,"data-slot":`dropdown-menu-radio-item-indicator`,children:(0,X.jsx)(wc,{children:(0,X.jsx)(ar,{})})}),t[7]=s):s=t[7];let c;return t[8]!==n||t[9]!==i||t[10]!==a||t[11]!==o?(c=(0,X.jsxs)(Cc,{"data-slot":`dropdown-menu-radio-item`,"data-inset":i,className:o,...a,children:[s,n]}),t[8]=n,t[9]=i,t[10]=a,t[11]=o,t[12]=c):c=t[12],c}function Jv(e){let t=(0,Q.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,inset:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=q(`px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==i||t[8]!==a?(o=(0,X.jsx)(bc,{"data-slot":`dropdown-menu-label`,"data-inset":r,className:a,...i}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function Yv(e){let t=(0,Q.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=q(`-mx-1 my-1 h-px bg-border`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(Tc,{"data-slot":`dropdown-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Xv(e){let t=(0,Q.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,X.jsx)(Ec,{"data-slot":`dropdown-menu-sub`,...n}),t[2]=n,t[3]=r),r}function Zv(e){let t=(0,Q.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,inset:i,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===r?o=t[6]:(o=q(`flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,r),t[5]=r,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,X.jsx)(gn,{className:`ml-auto`}),t[7]=s):s=t[7];let c;return t[8]!==n||t[9]!==i||t[10]!==a||t[11]!==o?(c=(0,X.jsxs)(Dc,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":i,className:o,...a,children:[n,s]}),t[8]=n,t[9]=i,t[10]=a,t[11]=o,t[12]=c):c=t[12],c}function Qv(e){let t=(0,Q.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=q(`z-50 min-w-[96px] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-lg bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(Oc,{"data-slot":`dropdown-menu-sub-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function $v(e){let t=(0,Q.c)(14),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,containerClassName:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=q(`relative w-full overflow-x-auto subtle-scrollbar`,r),t[4]=r,t[5]=a);let o;t[6]===n?o=t[7]:(o=q(`w-full caption-bottom text-sm`,n),t[6]=n,t[7]=o);let s;t[8]!==i||t[9]!==o?(s=(0,X.jsx)(`table`,{"data-slot":`table`,className:o,...i}),t[8]=i,t[9]=o,t[10]=s):s=t[10];let c;return t[11]!==a||t[12]!==s?(c=(0,X.jsx)(`div`,{"data-slot":`table-container`,className:a,children:s}),t[11]=a,t[12]=s,t[13]=c):c=t[13],c}function ey(e){let t=(0,Q.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=q(`[&_tr]:border-b`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(`thead`,{"data-slot":`table-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function ty(e){let t=(0,Q.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=q(`[&_tr:last-child]:border-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(`tbody`,{"data-slot":`table-body`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function ny(e){let t=(0,Q.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,noHover:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=(i===void 0?!1:i)&&`hover:bg-transparent`,o;t[4]!==n||t[5]!==a?(o=q(`hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors`,a,n),t[4]=n,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==o?(s=(0,X.jsx)(`tr`,{"data-slot":`table-row`,className:o,...r}),t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function ry(e){let t=(0,Q.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,scope:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`col`:i,o;t[4]===n?o=t[5]:(o=q(`font-mono uppercase text-xs text-muted-foreground h-10 px-4 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,n),t[4]=n,t[5]=o);let s;return t[6]!==r||t[7]!==a||t[8]!==o?(s=(0,X.jsx)(`th`,{"data-slot":`table-head`,scope:a,className:o,...r}),t[6]=r,t[7]=a,t[8]=o,t[9]=s):s=t[9],s}function iy(e){let t=(0,Q.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=q(`py-3 px-4 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(`td`,{"data-slot":`table-cell`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function ay(e){if(!e)return`—`;let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<30?`${a}d ago`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function oy(e,t,n){return[...e].sort((e,r)=>{if(e.kind!==r.kind)return e.kind===`folder`?-1:1;let i=0;switch(t){case`name`:i=e.title.localeCompare(r.title)||e.name.localeCompare(r.name);break;case`modified`:{let t=e.kind===`file`?e.modified:``,n=r.kind===`file`?r.modified:``;i=t.localeCompare(n);break}}return n===`asc`?i:-i})}function sy(e){let t=(0,Q.c)(10),{label:n,sortKey:r,activeKey:i,activeDir:a,onSort:o}=e,s=i===r,c;t[0]!==o||t[1]!==r?(c=()=>o(r),t[0]=o,t[1]=r,t[2]=c):c=t[2];let l;t[3]!==a||t[4]!==s?(l=s?a===`asc`?(0,X.jsx)(Bt,{className:`ml-1 size-3`}):(0,X.jsx)(Wt,{className:`ml-1 size-3`}):(0,X.jsx)(Ei,{className:`ml-1 size-3 text-muted-foreground/50`}),t[3]=a,t[4]=s,t[5]=l):l=t[5];let u;return t[6]!==n||t[7]!==c||t[8]!==l?(u=(0,X.jsxs)(J,{variant:`ghost`,size:`sm`,className:`-ml-3 h-8 uppercase font-mono`,onClick:c,children:[n,l]}),t[6]=n,t[7]=c,t[8]=l,t[9]=u):u=t[9],u}function cy(e){let t=(0,Q.c)(87),{folderPath:n}=e,{addPage:r,folderPaths:i,loading:a,pages:o,pageTitles:s,pageMeta:c}=Pe(),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(`name`),[_,v]=(0,Z.useState)(`asc`);if(a){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(nr,{className:`size-5 rounded`}),(0,X.jsx)(nr,{className:`h-7 w-48`})]}),(0,X.jsx)(nr,{className:`h-9 w-20 rounded-md`})]}),t[0]=e):e=t[0];let n;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,X.jsx)(nr,{className:`h-4 w-16`}),t[1]=n):n=t[1];let r;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start overflow-y-auto subtle-scrollbar`,role:`status`,"aria-busy":`true`,"aria-label":`Loading folder contents`,children:(0,X.jsxs)(`div`,{className:`mx-auto flex w-full max-w-4xl flex-col gap-6 px-6 py-8`,children:[e,(0,X.jsxs)(`div`,{className:`rounded-lg border`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-4 border-b px-4 py-3`,children:[n,(0,X.jsx)(`div`,{className:`ml-auto`,children:(0,X.jsx)(nr,{className:`h-4 w-20`})})]}),[`a`,`b`,`c`,`d`].map(fy)]})]})}),t[2]=r):r=t[2],r}let y,b,x,S,C,w,T,E;if(t[3]!==r||t[4]!==p||t[5]!==d||t[6]!==n||t[7]!==i||t[8]!==c||t[9]!==s||t[10]!==o||t[11]!==_||t[12]!==h){let e=Vv(n,{pages:o,pageTitles:s,pageMeta:c,folderPaths:i}),a=oy(e.children,h,_),l;t[21]===h?l=t[22]:(l=function(e){e===h?v(dy):(g(e),v(`asc`))},t[21]=h,t[22]=l);let D=l,O;t[23]!==r||t[24]!==n?(O=async function(){f(!0),m(null);try{let e=`${n}/index.md`,t=await fetch(`/api/create-page`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e})}),i=await t.json().catch(uy);if(!t.ok||!i?.ok){m(i?.error??`Server error (HTTP ${t.status})`),f(!1);return}let a=i.docName??`${n}/index`;r(a),we([`files`,`backlinks`,`graph`]),window.location.hash=$e(a)}catch(e){console.warn(`[FolderOverview] create index note failed:`,e),m(`Network error — please try again`)}f(!1)},t[23]=r,t[24]=n,t[25]=O):O=t[25];let k=O;E=`flex min-h-0 flex-1 items-start overflow-y-auto subtle-scrollbar`,w=`mx-auto flex w-full max-w-4xl flex-col gap-6 px-6 py-8`;let A;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,X.jsx)(Ot,{className:`size-5 text-muted-foreground`}),t[26]=A):A=t[26];let j=(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[A,(0,X.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:e.title})]}),M;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,X.jsx)(xa,{className:`size-4`}),t[27]=M):M=t[27];let N;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,X.jsx)(Uv,{asChild:!0,children:(0,X.jsxs)(J,{children:[M,`New`,(0,X.jsx)(Rt,{className:`size-3`})]})}),t[28]=N):N=t[28];let P;t[29]===k?P=t[30]:(P=()=>void k(),t[29]=k,t[30]=P);let F;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`font-medium`,children:`Index note`}),(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Landing page for this folder`})]}),t[31]=F):F=t[31];let I;t[32]!==d||t[33]!==P?(I=(0,X.jsx)(Gv,{disabled:d,onSelect:P,children:F}),t[32]=d,t[33]=P,t[34]=I):I=t[34];let L;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,X.jsx)(Gv,{onSelect:()=>u(!0),children:(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`font-medium`,children:`Note`}),(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`New note inside this folder`})]})}),t[35]=L):L=t[35];let R;t[36]===I?R=t[37]:(R=(0,X.jsxs)(Hv,{children:[N,(0,X.jsxs)(Wv,{align:`end`,children:[I,L]})]}),t[36]=I,t[37]=R);let z;t[38]!==j||t[39]!==R?(z=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[j,R]}),t[38]=j,t[39]=R,t[40]=z):z=t[40];let B;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This folder has no landing note yet. Choose an explicit action to add one or open a note inside the folder.`}),t[41]=B):B=t[41];let V;t[42]===p?V=t[43]:(V=p?(0,X.jsx)(`span`,{role:`alert`,className:`text-sm text-destructive`,children:p}):null,t[42]=p,t[43]=V),t[44]!==z||t[45]!==V?(T=(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[z,B,V]}),t[44]=z,t[45]=V,t[46]=T):T=t[46],C=`rounded-lg border`,b=$v;let H=h===`name`?_===`asc`?`ascending`:`descending`:`none`,U;t[47]!==D||t[48]!==_||t[49]!==h?(U=(0,X.jsx)(sy,{label:`Name`,sortKey:`name`,activeKey:h,activeDir:_,onSort:D}),t[47]=D,t[48]=_,t[49]=h,t[50]=U):U=t[50];let W;t[51]!==H||t[52]!==U?(W=(0,X.jsx)(ry,{"aria-sort":H,children:U}),t[51]=H,t[52]=U,t[53]=W):W=t[53];let G=h===`modified`?_===`asc`?`ascending`:`descending`:`none`,ee;t[54]!==D||t[55]!==_||t[56]!==h?(ee=(0,X.jsx)(sy,{label:`Modified`,sortKey:`modified`,activeKey:h,activeDir:_,onSort:D}),t[54]=D,t[55]=_,t[56]=h,t[57]=ee):ee=t[57];let K;t[58]!==G||t[59]!==ee?(K=(0,X.jsx)(ry,{className:`w-32`,"aria-sort":G,children:ee}),t[58]=G,t[59]=ee,t[60]=K):K=t[60],t[61]!==W||t[62]!==K?(S=(0,X.jsx)(ey,{children:(0,X.jsxs)(ny,{children:[W,K]})}),t[61]=W,t[62]=K,t[63]=S):S=t[63],y=ty,x=a.length?a.map(ly):(0,X.jsx)(ny,{children:(0,X.jsx)(iy,{colSpan:2,className:`h-24 text-center text-muted-foreground`,children:`This folder is empty.`})}),t[3]=r,t[4]=p,t[5]=d,t[6]=n,t[7]=i,t[8]=c,t[9]=s,t[10]=o,t[11]=_,t[12]=h,t[13]=y,t[14]=b,t[15]=x,t[16]=S,t[17]=C,t[18]=w,t[19]=T,t[20]=E}else y=t[13],b=t[14],x=t[15],S=t[16],C=t[17],w=t[18],T=t[19],E=t[20];let D;t[64]!==y||t[65]!==x?(D=(0,X.jsx)(y,{children:x}),t[64]=y,t[65]=x,t[66]=D):D=t[66];let O;t[67]!==b||t[68]!==S||t[69]!==D?(O=(0,X.jsxs)(b,{children:[S,D]}),t[67]=b,t[68]=S,t[69]=D,t[70]=O):O=t[70];let k;t[71]!==C||t[72]!==O?(k=(0,X.jsx)(`div`,{className:C,children:O}),t[71]=C,t[72]=O,t[73]=k):k=t[73];let A;t[74]!==w||t[75]!==T||t[76]!==k?(A=(0,X.jsxs)(`div`,{className:w,children:[T,k]}),t[74]=w,t[75]=T,t[76]=k,t[77]=A):A=t[77];let j;t[78]!==A||t[79]!==E?(j=(0,X.jsx)(`div`,{className:E,children:A}),t[78]=A,t[79]=E,t[80]=j):j=t[80];let M;t[81]!==l||t[82]!==n?(M=(0,X.jsx)(hn,{open:l,onOpenChange:u,kind:`file`,initialDir:n}),t[81]=l,t[82]=n,t[83]=M):M=t[83];let N;return t[84]!==j||t[85]!==M?(N=(0,X.jsxs)(X.Fragment,{children:[j,M]}),t[84]=j,t[85]=M,t[86]=N):N=t[86],N}function ly(e){return(0,X.jsxs)(ny,{children:[(0,X.jsx)(iy,{children:(0,X.jsxs)(`a`,{href:$e(e.path),className:`flex items-center gap-2 rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[e.kind===`folder`?(0,X.jsx)($i,{className:`size-4 shrink-0 text-muted-foreground`}):(0,X.jsx)(Ht,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsx)(`span`,{className:`truncate`,children:e.title})]})}),(0,X.jsx)(iy,{className:`text-muted-foreground`,children:e.kind===`file`?ay(e.modified):`—`})]},e.path)}function uy(){return null}function dy(e){return e===`asc`?`desc`:`asc`}function fy(e){return(0,X.jsxs)(`div`,{className:`flex items-center gap-3 border-b px-4 py-3 last:border-b-0`,children:[(0,X.jsx)(nr,{className:`size-4 rounded`}),(0,X.jsx)(nr,{className:`h-4 w-40`}),(0,X.jsx)(`div`,{className:`ml-auto`,children:(0,X.jsx)(nr,{className:`h-4 w-16`})})]},e)}function py(e){let t=(0,Q.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=q(`flex h-full w-full aria-[orientation=vertical]:flex-col`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(T_,{"data-slot":`resizable-panel-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function my(e){let t=(0,Q.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,X.jsx)(O_,{"data-slot":`resizable-panel`,...n}),t[2]=n,t[3]=r),r}function hy(e){let t=(0,Q.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({withHandle:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=q(`relative flex w-px items-center justify-center bg-border ring-offset-background after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90`,n),t[4]=n,t[5]=a);let o;t[6]===i?o=t[7]:(o=i&&(0,X.jsx)(`div`,{className:`z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border`}),t[6]=i,t[7]=o);let s;return t[8]!==r||t[9]!==a||t[10]!==o?(s=(0,X.jsx)(M_,{"data-slot":`resizable-handle`,className:a,...r,children:o}),t[8]=r,t[9]=a,t[10]=o,t[11]=s):s=t[11],s}var gy=960,_y=1024;function vy(){let e=(0,Q.c)(5),[t,n]=(0,Z.useState)(by),[r,i]=(0,Z.useState)(yy),a,o;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{let e=window.matchMedia(`(max-width: ${gy-1}px)`),t=window.matchMedia(`(max-width: ${_y-1}px)`),r=()=>{let r=e.matches;n(r?`sheet`:`panel`),i(!r&&t.matches)};return e.addEventListener(`change`,r),t.addEventListener(`change`,r),()=>{e.removeEventListener(`change`,r),t.removeEventListener(`change`,r)}},o=[],e[0]=a,e[1]=o):(a=e[0],o=e[1]),(0,Z.useEffect)(a,o);let s;return e[2]!==r||e[3]!==t?(s={layout:t,autoCollapse:r},e[2]=r,e[3]=t,e[4]=s):s=e[4],s}function yy(){return window.innerWidth>=gy&&window.innerWidth<_y}function by(){return window.innerWidth<gy?`sheet`:`panel`}var xy={words:0,chars:0,tokens:0},Sy=/[ -〿぀-ゟ゠-ヿ㐀-䶿一-鿿豈-﫿＀-￯฀-๿ក-៿]/,Cy=/[\p{L}\p{N}]/u;function wy(e){if(!e)return 0;let t=0;for(let n of e.split(/\s+/))Cy.test(n)&&t++;return t}function Ty(e){let t=globalThis.Intl.Segmenter;if(!t)return wy(e);let n=new t(void 0,{granularity:`word`}),r=0;for(let t of n.segment(e))t.isWordLike&&r++;return r}function Ey(e){let t=Sy.test(e)?1.5:4;return Math.ceil(e.length/t)}function Dy(e){if(!e)return{words:0,chars:0,tokens:0};let{body:t}=ue(e),n=t.trim();return n?{words:Sy.test(n)?Ty(n):wy(n),chars:n.length,tokens:Ey(n)}:{words:0,chars:0,tokens:0}}var Oy=300;function ky(e,t){let n=(0,Q.c)(4),[r,i]=(0,Z.useState)(xy),a,o;return n[0]!==t||n[1]!==e?(a=()=>{if(!e||!t){i(xy);return}let n=e.document.getText(`source`),r=!1,a=null,o=function(){r||i(Dy(n.toString()))};o();let s=function(){a&&clearTimeout(a),a=setTimeout(o,Oy)};return n.observe(s),()=>{r=!0,n.unobserve(s),a&&clearTimeout(a)}},o=[e,t],n[0]=t,n[1]=e,n[2]=a,n[3]=o):(a=n[2],o=n[3]),(0,Z.useEffect)(a,o),r}var Ay=K;function jy(e,t={}){let n=zn(e.componentName);return n.name===`*`?t.unregisteredSuffix?`${e.componentName} (unregistered)`:e.componentName:n.displayName??n.name}var My=4;function Ny(e){let t=(0,Q.c)(8),{editor:n}=e,r=Kt(n),i=!!(n&&r&&r.ancestorChain.length>0),a=i?void 0:`true`,o=`jsx-component-breadcrumb flex items-center gap-1 min-h-[28px] px-3 py-1.5 text-xs font-mono text-muted-foreground overflow-hidden ${i?`border-t border-border`:``}`,s;t[0]!==r||t[1]!==n||t[2]!==i?(s=i&&r?(0,X.jsx)(Fy,{editor:n,blockSelection:r}):null,t[0]=r,t[1]=n,t[2]=i,t[3]=s):s=t[3];let c;return t[4]!==a||t[5]!==o||t[6]!==s?(c=(0,X.jsx)(`nav`,{"aria-label":`Block ancestor navigation`,"aria-hidden":a,className:o,children:s}),t[4]=a,t[5]=o,t[6]=s,t[7]=c):c=t[7],c}function Py(e,t){let n=It.getState(e.state)?.posToId;if(!n)return t.pos;for(let[e,r]of n)if(r===t.bridgeId)return e;return null}function Fy(e){let t=(0,Q.c)(9),{editor:n,blockSelection:r}=e,{ancestorChain:i,selectedBlockId:a}=r,o;if(t[0]!==i||t[1]!==n||t[2]!==a){let e=Ry(i),r;t[4]===n?r=t[5]:(r=(0,X.jsx)(`button`,{type:`button`,className:`opacity-60 hover:opacity-100 hover:text-foreground transition-opacity outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm`,onClick:()=>{n.chain().focus().setTextSelection(0).command(Ly).run()},children:rn}),t[4]=n,t[5]=r);let s;t[6]!==n||t[7]!==a?(s=e=>{if(e.kind===`ellipsis`)return(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(gn,{size:12,className:`opacity-50`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{role:`img`,"aria-label":`${e.hiddenCount} hidden ancestors`,title:`${e.hiddenCount} hidden ancestors`,className:`opacity-60`,children:`…`})]},`ellipsis`);let t=jy(e.entry),r=e.entry.bridgeId===a;return(0,X.jsxs)(`span`,{className:`flex items-center gap-1 min-w-0`,children:[(0,X.jsx)(gn,{size:12,className:`opacity-50 shrink-0`,"aria-hidden":`true`}),r?(0,X.jsx)(`span`,{"aria-current":`location`,className:`text-foreground truncate`,children:t}):(0,X.jsx)(`button`,{type:`button`,className:`hover:text-foreground transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm truncate`,onClick:()=>{let t=Py(n,e.entry);t!==null&&n.chain().focus().setNodeSelection(t).command(Iy).run()},children:t})]},e.entry.bridgeId)},t[6]=n,t[7]=a,t[8]=s):s=t[8],o=(0,X.jsxs)(X.Fragment,{children:[r,e.map(s)]}),t[0]=i,t[1]=n,t[2]=a,t[3]=o}else o=t[3];return o}function Iy(e){let{tr:t}=e;return t.setMeta(Tt,`programmatic`),!0}function Ly(e){let{tr:t}=e;return t.setMeta(Tt,`programmatic`),!0}function Ry(e){if(e.length<=My)return e.map(e=>({kind:`entry`,entry:e}));let t=e[0],n=e.slice(-2),r=e.length-1-n.length;return[{kind:`entry`,entry:t},{kind:`ellipsis`,hiddenCount:r},...n.map(e=>({kind:`entry`,entry:e}))]}var zy=200,By=`Outside any block`;function Vy(e){let t=(0,Q.c)(5),{editor:n}=e,r=Kt(n),i=(0,Z.useRef)(null),a=(0,Z.useRef)(null),o=(0,Z.useRef)(!1),s,c;t[0]!==r||t[1]!==n?(s=()=>{if(a.current!==null&&(window.clearTimeout(a.current),a.current=null),!n||!i.current)return;let e=r!==null&&r.ancestorChain.length>0,t;return t=e?Hy(n,r):o.current?By:``,a.current=window.setTimeout(()=>{i.current&&(i.current.textContent=``,i.current.textContent=t),o.current=e,a.current=null},zy),()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null)}},c=[n,r],t[0]=r,t[1]=n,t[2]=s,t[3]=c):(s=t[2],c=t[3]),(0,Z.useEffect)(s,c);let l;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,X.jsx)(`div`,{ref:i,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`sr-only`}),t[4]=l):l=t[4],l}function Hy(e,t){if(!t||t.ancestorChain.length===0)return``;let n=t.ancestorChain,r=n[n.length-1],i=jy(r,{unregisteredSuffix:!0});if(n.length===1)return`Selected: ${i}`;let a=n[n.length-2],o=jy(a);try{let t=e.state.doc.resolve(r.pos),n=t.index(t.depth),a=t.parent.childCount;return`Selected: ${i}, ${n+1} of ${a} in ${o}`}catch{return`Selected: ${i} in ${o}`}}function Uy(){let[e]=(0,Z.useState)(Oe);return e}function Wy({principal:e,identity:t}){return e&&e.source===`git-config`?{type:`human`,name:Be(e.display_name),color:ke(e.id,I),coeditor:t.coeditor,tabId:t.tabId,principalId:e.id}:e&&e.source===`synthesized`?{type:`human`,name:t.name,color:ke(e.id,I),coeditor:t.coeditor,tabId:t.tabId}:{type:`human`,name:t.name,color:t.color,coeditor:t.coeditor,tabId:t.tabId}}function Gy(e,t){let n=Math.min(e.top,t.top),r=Math.max(e.bottom,t.bottom),i=Math.min(e.left,t.left),a=Math.max(e.right,t.right)-i,o=r-n;return new DOMRect(i,n,a,o)}var Ky=class{constructor({editor:e,element:t,view:n,pluginKey:r=`bubbleMenu`,updateDelay:i=250,resizeDelay:a=60,shouldShow:o,appendTo:s,getReferencedVirtualElement:c,options:l}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:`absolute`,placement:`top`,offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:e,state:t,from:n,to:r})=>{let{doc:i,selection:a}=t,{empty:o}=a,s=!i.textBetween(n,r).length&&Ze(t.selection),c=this.element.contains(document.activeElement);return!(!(e.hasFocus()||c)||o||s||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}e?.relatedTarget&&this.element.parentNode?.contains(e.relatedTarget)||e?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(e,t)=>{let n=!t?.selection.eq(e.state.selection),r=!t?.doc.eq(e.state.doc);!n&&!r||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(e,n,r,t)},this.updateDelay))},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;if(!(i||!t&&!n)){if(!this.getShouldShow(r)){this.hide();return}this.show(),this.updatePosition()}},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);t===`updatePosition`?this.updatePosition():t&&typeof t==`object`&&t.type===`updateOptions`?this.updateOptions(t.options):t===`hide`?this.hide():t===`show`&&(this.updatePosition(),this.show())},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=a,this.appendTo=s,this.scrollTarget=l?.scrollTarget??window,this.getReferencedVirtualElement=c,this.floatingUIOptions={...this.floatingUIOptions,...l},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener(`dragstart`,this.dragstartHandler),this.editor.on(`focus`,this.focusHandler),this.editor.on(`blur`,this.blurHandler),this.editor.on(`transaction`,this.transactionHandler),window.addEventListener(`resize`,this.resizeHandler),this.scrollTarget.addEventListener(`scroll`,this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(Fe(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(U(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(le(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(B(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(ee(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(ce(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(ae(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(oe(typeof this.floatingUIOptions.inline==`boolean`?void 0:this.floatingUIOptions.inline)),e}get virtualElement(){let{selection:e}=this.editor.state,t=this.getReferencedVirtualElement?.call(this);if(t)return t;if(!this.view?.dom?.parentNode)return;let n=Ye(this.view,e.from,e.to),r={getBoundingClientRect:()=>n,getClientRects:()=>[n]};if(e instanceof De){let t=this.view.nodeDOM(e.from),n=t.dataset.nodeViewWrapper?t:t.querySelector(`[data-node-view-wrapper]`);n&&(t=n),t&&(r={getBoundingClientRect:()=>t.getBoundingClientRect(),getClientRects:()=>[t.getBoundingClientRect()]})}if(e instanceof ie){let{$anchorCell:t,$headCell:n}=e,i=t?t.pos:n.pos,a=n?n.pos:t.pos,o=this.view.nodeDOM(i),s=this.view.nodeDOM(a);if(!o||!s)return;let c=o===s?o.getBoundingClientRect():Gy(o.getBoundingClientRect(),s.getBoundingClientRect());r={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return r}updatePosition(){if(!this.isVisible)return;let e=this.virtualElement;e&&L(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{if(!(!this.isVisible||this.editor.isDestroyed||!this.element.isConnected)){if(r.hide?.referenceHidden||r.hide?.escaped){this.element.style.visibility=`hidden`;return}this.element.style.visibility=`visible`,this.element.style.width=`max-content`,this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()}})}update(e,t){let{state:n}=e,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(e,t);return}let i=!t?.selection.eq(e.state.selection),a=!t?.doc.eq(e.state.doc);this.updateHandler(e,i,a,t)}getShouldShow(e){let{state:t}=this.view,{selection:n}=t,{ranges:r}=n,i=Math.min(...r.map(e=>e.$from.pos)),a=Math.max(...r.map(e=>e.$to.pos));return this.shouldShow?.call(this,{editor:this.editor,element:this.element,view:this.view,state:t,oldState:e,from:i,to:a})||!1}show(){var e;this.isVisible||(this.element.style.visibility=`visible`,this.element.style.opacity=`1`,(e=(typeof this.appendTo==`function`?this.appendTo():this.appendTo)??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&=(this.element.style.visibility=`hidden`,this.element.style.opacity=`0`,this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),!1)}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){let t=e.options.scrollTarget??window;t!==this.scrollTarget&&(this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.scrollTarget=t,this.scrollTarget.addEventListener(`scroll`,this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}destroy(){this.hide(),this.element.removeEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener(`dragstart`,this.dragstartHandler),window.removeEventListener(`resize`,this.resizeHandler),this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.editor.off(`focus`,this.focusHandler),this.editor.off(`blur`,this.blurHandler),this.editor.off(`transaction`,this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},qy=e=>new ze({key:typeof e.pluginKey==`string`?new et(e.pluginKey):e.pluginKey,view:t=>new Ky({view:t,...e})});ye.create({name:`bubbleMenu`,addOptions(){return{element:null,pluginKey:`bubbleMenu`,updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[qy({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});var Jy=class{constructor({editor:e,element:t,view:n,pluginKey:r=`floatingMenu`,updateDelay:i=250,resizeDelay:a=60,options:o,appendTo:s,shouldShow:c}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:e,state:t})=>{let{selection:n}=t,{$anchor:r,empty:i}=n,a=r.depth===1,o=r.parent.isTextblock&&!r.parent.type.spec.code&&!r.parent.textContent&&r.parent.childCount===0&&!this.getTextContent(r.parent);return!(!e.hasFocus()||!i||!a||!o||!this.editor.isEditable)},this.floatingUIOptions={strategy:`absolute`,placement:`right`,offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;if(!(i||!t&&!n)){if(!this.getShouldShow(r)){this.hide();return}this.updatePosition(),this.show()}},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{if(this.preventHide){this.preventHide=!1;return}e?.relatedTarget&&this.element.parentNode?.contains(e.relatedTarget)||e?.relatedTarget!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);t===`updatePosition`?this.updatePosition():t&&typeof t==`object`&&t.type===`updateOptions`?this.updateOptions(t.options):t===`hide`?this.hide():t===`show`&&(this.updatePosition(),this.show())},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=a,this.appendTo=s,this.scrollTarget=o?.scrollTarget??window,this.floatingUIOptions={...this.floatingUIOptions,...o},this.element.tabIndex=0,c&&(this.shouldShow=c),this.element.addEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.editor.on(`focus`,this.focusHandler),this.editor.on(`blur`,this.blurHandler),this.editor.on(`transaction`,this.transactionHandler),window.addEventListener(`resize`,this.resizeHandler),this.scrollTarget.addEventListener(`scroll`,this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(e){return xe(e,{textSerializers:de(this.editor.schema)})}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(Fe(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(U(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(le(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(B(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(ee(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(ce(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(ae(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(oe(typeof this.floatingUIOptions.inline==`boolean`?void 0:this.floatingUIOptions.inline)),e}getShouldShow(e){let{state:t}=this.view,{selection:n}=t,{ranges:r}=n,i=Math.min(...r.map(e=>e.$from.pos)),a=Math.max(...r.map(e=>e.$to.pos));return this.shouldShow?.call(this,{editor:this.editor,view:this.view,state:t,oldState:e,from:i,to:a})}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){let t=e.options.scrollTarget??window;t!==this.scrollTarget&&(this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.scrollTarget=t,this.scrollTarget.addEventListener(`scroll`,this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}updatePosition(){let{selection:e}=this.editor.state,t=Ye(this.view,e.from,e.to);L({getBoundingClientRect:()=>t,getClientRects:()=>[t]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{if(r.hide?.referenceHidden||r.hide?.escaped){this.element.style.visibility=`hidden`;return}this.element.style.visibility=`visible`,this.element.style.width=`max-content`,this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){let n=!t?.selection.eq(e.state.selection),r=!t?.doc.eq(e.state.doc);this.updateHandler(e,n,r,t)}show(){var e;this.isVisible||(this.element.style.visibility=`visible`,this.element.style.opacity=`1`,(e=(typeof this.appendTo==`function`?this.appendTo():this.appendTo)??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&=(this.element.style.visibility=`hidden`,this.element.style.opacity=`0`,this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),!1)}destroy(){this.hide(),this.element.removeEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),window.removeEventListener(`resize`,this.resizeHandler),this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.editor.off(`focus`,this.focusHandler),this.editor.off(`blur`,this.blurHandler),this.editor.off(`transaction`,this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},Yy=e=>new ze({key:typeof e.pluginKey==`string`?new et(e.pluginKey):e.pluginKey,view:t=>new Jy({view:t,...e})});ye.create({name:`floatingMenu`,addOptions(){return{element:null,options:{},pluginKey:`floatingMenu`,updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}},addCommands(){return{updateFloatingMenuPosition:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(this.options.pluginKey,`updatePosition`),!0)}},addProseMirrorPlugins(){return this.options.element?[Yy({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,resizeDelay:this.options.resizeDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});function Xy(e,t){return e??new et(t)}var Zy=typeof window<`u`?Z.useLayoutEffect:Z.useEffect,Qy=new Set([`left`,`opacity`,`position`,`top`,`visibility`,`width`]),$y=new Set(`animationIterationCount.aspectRatio.borderImageOutset.borderImageSlice.borderImageWidth.columnCount.columns.fillOpacity.flex.flexGrow.flexShrink.fontWeight.gridArea.gridColumn.gridColumnEnd.gridColumnStart.gridRow.gridRowEnd.gridRowStart.lineClamp.lineHeight.opacity.order.orphans.scale.stopOpacity.strokeDasharray.strokeDashoffset.strokeMiterlimit.strokeOpacity.strokeWidth.tabSize.widows.zIndex.zoom`.split(`.`)),eb=new Set([`children`,`className`,`style`]),tb=new Set([`tabIndex`]),nb=new Set([`accessKey`,`autoCapitalize`,`contentEditable`,`contextMenu`,`dir`,`draggable`,`enterKeyHint`,`hidden`,`id`,`lang`,`nonce`,`role`,`slot`,`spellCheck`,`tabIndex`,`title`,`translate`]),rb={Blur:`focusout`,DoubleClick:`dblclick`,Focus:`focusin`,MouseEnter:`mouseenter`,MouseLeave:`mouseleave`};function ib(e,t){return/^on[A-Z]/.test(e)&&typeof t==`function`}function ab(e){return e.startsWith(`aria-`)||e.startsWith(`data-`),e}function ob(e){return e.startsWith(`aria-`)||e.startsWith(`data-`)||nb.has(e)}function sb(e){return e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function cb(e){let t=e.endsWith(`Capture`),n=(t?e.slice(0,-7):e).slice(2);return{eventName:rb[n]??n.toLowerCase(),options:t?{capture:!0}:void 0}}function lb(e,t){let n=t.defaultPrevented,r=!1,i=Object.create(t);return Object.defineProperties(i,{nativeEvent:{value:t},currentTarget:{value:e},target:{value:t.target},persist:{value:()=>void 0},isDefaultPrevented:{value:()=>n},isPropagationStopped:{value:()=>r},preventDefault:{value:()=>{n=!0,t.preventDefault()}},stopPropagation:{value:()=>{r=!0,t.stopPropagation()}}}),i}function ub(e){return tb.has(e)}function db(e,t,n){if(t===`tabIndex`){e.tabIndex=Number(n);return}e[t]=n}function fb(e,t){if(t===`tabIndex`){e.removeAttribute(`tabindex`);return}let n=e[t];if(typeof n==`boolean`){e[t]=!1;return}if(typeof n==`number`){e[t]=0;return}e[t]=``}function pb(e,t){return typeof t!=`number`||t===0||e.startsWith(`--`)||$y.has(e)?String(t):`${t}px`}function mb(e,t){Qy.has(t)||e.style.removeProperty(sb(t))}function hb(e,t,n){Qy.has(t)||e.style.setProperty(sb(t),pb(t,n))}function gb(e,t,n){new Set([...Object.keys(t),...Object.keys(n)]).forEach(r=>{if(eb.has(r)||!ob(r)||ib(r,t[r])||ib(r,n[r]))return;let i=t[r],a=n[r];if(i===a)return;let o=ab(r);if(a==null||a===!1){ub(r)&&fb(e,r),e.removeAttribute(o);return}if(a===!0){ub(r)&&db(e,r,!0),e.setAttribute(o,``);return}if(ub(r)){db(e,r,a);return}e.setAttribute(o,String(a))})}function _b(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute(`class`)}}function vb(e,t,n){let r=t??{},i=n??{};new Set([...Object.keys(r),...Object.keys(i)]).forEach(t=>{let n=r[t],a=i[t];if(n!==a){if(a==null){mb(e,t);return}hb(e,t,a)}})}function yb(e,t,n){t.forEach(({eventName:t,listener:n,options:r})=>{e.removeEventListener(t,n,r)});let r=[];return Object.entries(n).forEach(([t,n])=>{if(!ib(t,n))return;let{eventName:i,options:a}=cb(t),o=t=>{n(lb(e,t))};e.addEventListener(i,o,a),r.push({eventName:i,listener:o,options:a})}),r}function bb(e,t){let n=(0,Z.useRef)({}),r=(0,Z.useRef)([]);Zy(()=>{let i=n.current;return _b(e,i.className,t.className),vb(e,i.style,t.style),gb(e,i,t),r.current=yb(e,r.current,t),n.current=t,()=>{r.current.forEach(({eventName:t,listener:n,options:r})=>{e.removeEventListener(t,n,r)}),r.current=[]}},[e,t])}var xb=Z.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,getReferencedVirtualElement:o,options:s,children:c,...l},u)=>{let d=(0,Z.useRef)(document.createElement(`div`)),f=(0,Z.useRef)(Xy(e,`bubbleMenu`)).current;bb(d.current,l),typeof u==`function`?u(d.current):u&&(u.current=d.current);let{editor:p}=An(),m=t||p,h={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:f,shouldShow:a,getReferencedVirtualElement:o,options:s},g=(0,Z.useRef)(h);g.current=h;let[_,v]=(0,Z.useState)(!1),y=(0,Z.useRef)(!0);return(0,Z.useEffect)(()=>{if(m?.isDestroyed)return;if(!m){console.warn(`BubbleMenu component is not rendered inside of an editor component or does not have editor prop.`);return}let e=d.current;e.style.visibility=`hidden`,e.style.position=`absolute`;let t=qy({...g.current,editor:m,element:e});m.registerPlugin(t);let n=g.current.pluginKey;return y.current=!0,v(!0),()=>{v(!1),m.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[m]),(0,Z.useEffect)(()=>{if(!(!_||!m||m.isDestroyed)){if(y.current){y.current=!1;return}m.view.dispatch(m.state.tr.setMeta(f,{type:`updateOptions`,options:g.current}))}},[_,m,n,r,a,s,i,o,f]),(0,Ai.createPortal)(c,d.current)});Z.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,options:o,children:s,...c},l)=>{let u=(0,Z.useRef)(document.createElement(`div`)),d=(0,Z.useRef)(Xy(e,`floatingMenu`)).current;bb(u.current,c),typeof l==`function`?l(u.current):l&&(l.current=u.current);let{editor:f}=An(),p=t||f,m={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:d,shouldShow:a,options:o},h=(0,Z.useRef)(m);h.current=m;let[g,_]=(0,Z.useState)(!1),v=(0,Z.useRef)(!0);return(0,Z.useEffect)(()=>{if(p?.isDestroyed)return;if(!p){console.warn(`FloatingMenu component is not rendered inside of an editor component or does not have editor prop.`);return}let e=u.current;e.style.visibility=`hidden`,e.style.position=`absolute`;let t=Yy({...h.current,editor:p,element:e});p.registerPlugin(t);let n=h.current.pluginKey;return v.current=!0,_(!0),()=>{_(!1),p.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[p]),(0,Z.useEffect)(()=>{if(!(!g||!p||p.isDestroyed)){if(v.current){v.current=!1;return}p.view.dispatch(p.state.tr.setMeta(d,{type:`updateOptions`,options:h.current}))}},[g,p,n,r,a,o,i,d]),(0,Ai.createPortal)(s,u.current)});var Sb=[{name:`paragraph`,label:`Text`,icon:va,isActive:e=>e.isActive(`paragraph`)&&!e.isActive(`list`),command:e=>e.chain().focus().setParagraph().run()},{name:`heading1`,label:`Heading 1`,icon:At,isActive:e=>e.isActive(`heading`,{level:1}),command:e=>e.chain().focus().toggleHeading({level:1}).run()},{name:`heading2`,label:`Heading 2`,icon:Yt,isActive:e=>e.isActive(`heading`,{level:2}),command:e=>e.chain().focus().toggleHeading({level:2}).run()},{name:`heading3`,label:`Heading 3`,icon:Pn,isActive:e=>e.isActive(`heading`,{level:3}),command:e=>e.chain().focus().toggleHeading({level:3}).run()},{name:`bulletList`,label:`Bullet List`,icon:an,isActive:e=>e.isActive(`list`,{ordered:!1})&&!e.isActive(`listItem`,{checked:!0})&&!e.isActive(`listItem`,{checked:!1}),command:e=>e.chain().focus().toggleBulletList().run()},{name:`orderedList`,label:`Ordered List`,icon:qt,isActive:e=>e.isActive(`list`,{ordered:!0}),command:e=>e.chain().focus().toggleOrderedList().run()},{name:`taskList`,label:`Task List`,icon:In,isActive:e=>e.isActive(`listItem`,{checked:!0})||e.isActive(`listItem`,{checked:!1}),command:e=>e.chain().focus().toggleTaskList().run()},{name:`blockquote`,label:`Quote`,icon:tn,isActive:e=>e.isActive(`blockquote`),command:e=>e.chain().focus().toggleBlockquote().run()},{name:`codeBlock`,label:`Code Block`,icon:ja,isActive:e=>e.isActive(`codeBlock`),command:e=>e.chain().focus().toggleCodeBlock().run()}];function Cb(e){let t=(0,Q.c)(18),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:wb},t[0]=n,t[1]=r);let{current:i,activeStates:a}=cn(r),o=i.icon,s;t[2]===o?s=t[3]:(s=(0,X.jsx)(o,{className:`size-3.5`}),t[2]=o,t[3]=s);let c;t[4]===i.label?c=t[5]:(c=(0,X.jsx)(`span`,{children:i.label}),t[4]=i.label,t[5]=c);let l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,X.jsx)(Rt,{className:`size-3 opacity-50`}),t[6]=l):l=t[6];let u;t[7]!==s||t[8]!==c?(u=(0,X.jsx)(Uv,{asChild:!0,children:(0,X.jsxs)(J,{variant:`ghost`,size:`sm`,className:`gap-1 px-2 text-sm font-medium text-accent-foreground/80`,children:[s,c,l]})}),t[7]=s,t[8]=c,t[9]=u):u=t[9];let d;t[10]!==a||t[11]!==n?(d=Sb.map(e=>{let t=e.icon,r=a[e.name];return(0,X.jsxs)(Gv,{className:r?`bg-accent text-accent-foreground`:``,onSelect:()=>{e.command(n)},children:[(0,X.jsx)(t,{className:`size-4`}),(0,X.jsx)(`span`,{children:e.label})]},e.name)}),t[10]=a,t[11]=n,t[12]=d):d=t[12];let f;t[13]===d?f=t[14]:(f=(0,X.jsx)(Wv,{align:`start`,sideOffset:8,className:`w-44 max-h-(--radix-dropdown-menu-content-available-height) overflow-y-auto subtle-scrollbar`,children:d}),t[13]=d,t[14]=f);let p;return t[15]!==u||t[16]!==f?(p=(0,X.jsxs)(Hv,{children:[u,f]}),t[15]=u,t[16]=f,t[17]=p):p=t[17],p}function wb(e){let t=Object.fromEntries(Sb.map(t=>[t.name,t.isActive(e.editor)]));return{current:Sb.find(e=>t[e.name])??Sb[0],activeStates:t}}var Tb=[{name:`bold`,icon:Oi,command:e=>e.chain().focus().toggleBold().run(),isActive:e=>e.isActive(`strong`),shortcut:`⌘B`},{name:`italic`,icon:aa,command:e=>e.chain().focus().toggleItalic().run(),isActive:e=>e.isActive(`emphasis`),shortcut:`⌘I`},{name:`underline`,icon:Ra,command:e=>e.chain().focus().toggleUnderline().run(),isActive:e=>e.isActive(`underline`),shortcut:`⌘U`},{name:`strikethrough`,icon:Pa,command:e=>e.chain().focus().toggleStrike().run(),isActive:e=>e.isActive(`strike`),shortcut:`⌘⇧X`},{name:`code`,icon:zi,command:e=>e.chain().focus().toggleCode().run(),isActive:e=>e.isActive(`code`),shortcut:`⌘E`},{name:`highlight`,icon:ia,command:e=>e.chain().focus().toggleHighlight().run(),isActive:e=>e.isActive(`highlight`),shortcut:`⌘⇧H`}];function Eb(e){let t=(0,Q.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:Db},t[0]=n,t[1]=r);let i=cn(r),a;t[2]!==i||t[3]!==n?(a=Tb.map(e=>{let t=e.icon,r=i[e.name];return(0,X.jsxs)(Lr,{children:[(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(J,{variant:`ghost`,size:`icon-xs`,"aria-label":e.name,className:r?`bg-accent text-primary`:`text-accent-foreground`,onMouseDown:t=>{t.preventDefault(),e.command(n)},children:(0,X.jsx)(t,{className:`size-3.5`})})}),(0,X.jsxs)(Fr,{side:`bottom`,sideOffset:8,children:[(0,X.jsx)(`span`,{className:`capitalize`,children:e.name}),(0,X.jsx)(`kbd`,{className:`ml-1.5 text-[10px] opacity-60`,children:e.shortcut})]})]},e.name)}),t[2]=i,t[3]=n,t[4]=a):a=t[4];let o;return t[5]===a?o=t[6]:(o=(0,X.jsx)(`div`,{className:`flex items-center gap-0.5`,children:a}),t[5]=a,t[6]=o),o}function Db(e){return Object.fromEntries(Tb.map(t=>[t.name,t.isActive(e.editor)]))}function Ob(e){let t=(0,Q.c)(46),{editor:n}=e,[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(``),s=(0,Z.useRef)(null),c;t[0]===n?c=t[1]:(c=n.isActive(`link`),t[0]=n,t[1]=c);let l=c,u;t[2]===n?u=t[3]:(u=n.getAttributes(`link`).href??``,t[2]=n,t[3]=u);let d=u,f,p;t[4]===n?(f=t[5],p=t[6]):(f=()=>{let e=function(){n.state.selection.empty&&i(!1)};return n.on(`selectionUpdate`,e),()=>{n.off(`selectionUpdate`,e)}},p=[n],t[4]=n,t[5]=f,t[6]=p),(0,Z.useEffect)(f,p);let m,h;t[7]!==d||t[8]!==r?(m=()=>{r&&(o(d),requestAnimationFrame(()=>s.current?.focus()))},h=[r,d],t[7]=d,t[8]=r,t[9]=m,t[10]=h):(m=t[9],h=t[10]),(0,Z.useEffect)(m,h);let g;t[11]!==n||t[12]!==l||t[13]!==a?(g=function(){a.trim()?n.chain().focus().setLink({href:a.trim()}).run():l&&n.chain().focus().unsetLink().run(),i(!1)},t[11]=n,t[12]=l,t[13]=a,t[14]=g):g=t[14];let _=g,v;t[15]===n?v=t[16]:(v=function(){n.chain().focus().unsetLink().run(),i(!1)},t[15]=n,t[16]=v);let y=v,b;t[17]!==_||t[18]!==n?(b=function(e){e.key===`Enter`&&(e.preventDefault(),_()),e.key===`Escape`&&(e.preventDefault(),i(!1),n.chain().focus().run())},t[17]=_,t[18]=n,t[19]=b):b=t[19];let x=b;if(r){let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=e=>o(e.target.value),t[20]=e):e=t[20];let n;t[21]!==x||t[22]!==a?(n=(0,X.jsx)(`input`,{ref:s,type:`url`,placeholder:`Paste link...`,value:a,onChange:e,onKeyDown:x,"aria-label":`Link URL`,className:`h-5 w-44 bg-transparent text-sm border-none outline-none placeholder:text-muted-foreground`}),t[21]=x,t[22]=a,t[23]=n):n=t[23];let r;t[24]===_?r=t[25]:(r=()=>{_()},t[24]=_,t[25]=r);let i;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,X.jsx)(Ui,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[26]=i):i=t[26];let c;t[27]===r?c=t[28]:(c=(0,X.jsx)(J,{variant:`ghost`,size:`icon-xs`,"aria-label":`Apply link`,onClick:r,children:i}),t[27]=r,t[28]=c);let u;t[29]!==n||t[30]!==c?(u=(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border bg-background px-2 py-1`,children:[n,c]}),t[29]=n,t[30]=c,t[31]=u):u=t[31];let f;t[32]!==d||t[33]!==l||t[34]!==y?(f=l&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Lr,{children:[(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(J,{variant:`ghost`,size:`icon-xs`,"aria-label":`Open link in new tab`,onMouseDown:e=>{e.preventDefault(),window.open(d,`_blank`,`noopener,noreferrer`)},children:(0,X.jsx)(cr,{className:`size-3.5`})})}),(0,X.jsx)(Fr,{side:`bottom`,sideOffset:8,children:`Open link in new tab`})]}),(0,X.jsxs)(Lr,{children:[(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(J,{variant:`ghost`,size:`icon-xs`,"aria-label":`Remove link`,onMouseDown:e=>{e.preventDefault(),y()},children:(0,X.jsx)(fn,{className:`size-3.5`})})}),(0,X.jsx)(Fr,{side:`bottom`,sideOffset:8,children:`Remove link`})]})]}),t[32]=d,t[33]=l,t[34]=y,t[35]=f):f=t[35];let p;return t[36]!==u||t[37]!==f?(p=(0,X.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[u,f]}),t[36]=u,t[37]=f,t[38]=p):p=t[38],p}let S=l?`bg-accent text-primary`:`text-accent-foreground`,C,w;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{e.preventDefault(),i(!0)},w=(0,X.jsx)(ca,{className:`size-3.5`}),t[39]=C,t[40]=w):(C=t[39],w=t[40]);let T;t[41]===S?T=t[42]:(T=(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(J,{variant:`ghost`,size:`icon-xs`,"aria-label":`Insert link`,className:S,onMouseDown:C,children:w})}),t[41]=S,t[42]=T);let E;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,X.jsxs)(Fr,{side:`bottom`,sideOffset:8,children:[`Link`,(0,X.jsx)(`kbd`,{className:`ml-1.5 text-[10px] opacity-60`,children:`⌘K`})]}),t[43]=E):E=t[43];let D;return t[44]===T?D=t[45]:(D=(0,X.jsxs)(Lr,{children:[T,E]}),t[44]=T,t[45]=D),D}function kb({editor:e}){if(e.state.selection.empty||e.isActive(`codeBlock`))return!1;let{from:t,to:n}=e.state.selection;return!!e.state.doc.textBetween(t,n,` `).trim()}function Ab(e){let t=(0,Q.c)(25),{editor:n}=e,r=(0,Z.useRef)(null),[i,a]=(0,Z.useState)(0),o=(0,Z.useRef)(null),s;t[0]!==n.state||t[1]!==n.view?(s=()=>{try{let{from:e,to:t}=n.state.selection;return Ye(n.view,e,t)}catch{return new DOMRect}},t[0]=n.state,t[1]=n.view,t[2]=s):s=t[2];let c;if(t[3]!==n.view.dom||t[4]!==s){let e={getBoundingClientRect:s,contextElement:n.view.dom};c=()=>{let t=r.current;t&&(o.current?.(),o.current=Le(e,t,()=>{L(e,t,{placement:`top`,strategy:`fixed`,middleware:[le(8),Fe(),U({padding:8})]}).then(e=>{let{x:n,y:r}=e;t.isConnected&&(t.style.position=`fixed`,t.style.left=`${n}px`,t.style.top=`${r}px`)}).catch(Nb)}))},t[3]=n.view.dom,t[4]=s,t[5]=c}else c=t[5];let l=c,u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{o.current?.(),o.current=null,a(Mb)},t[6]=u):u=t[6];let d=u,f;t[7]===l?f=t[8]:(f={onShow:l,onHide:d,strategy:`fixed`},t[7]=l,t[8]=f);let p;t[9]===n?p=t[10]:(p=(0,X.jsx)(Cb,{editor:n}),t[9]=n,t[10]=p);let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,X.jsx)(lv,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[11]=m):m=t[11];let h;t[12]!==n||t[13]!==i?(h=(0,X.jsx)(Eb,{editor:n},i),t[12]=n,t[13]=i,t[14]=h):h=t[14];let g;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,X.jsx)(lv,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[15]=g):g=t[15];let _=`${i}-link`,v;t[16]!==n||t[17]!==_?(v=(0,X.jsx)(Ob,{editor:n},_),t[16]=n,t[17]=_,t[18]=v):v=t[18];let y;return t[19]!==n||t[20]!==v||t[21]!==f||t[22]!==p||t[23]!==h?(y=(0,X.jsxs)(xb,{ref:r,editor:n,appendTo:jb,shouldShow:kb,updateDelay:250,options:f,className:`z-50 flex items-center gap-0.5 rounded-lg border bg-background p-1 shadow-md`,children:[p,m,h,g,v]}),t[19]=n,t[20]=v,t[21]=f,t[22]=p,t[23]=h,t[24]=y):y=t[24],y}function jb(){return document.body}function Mb(e){return e+1}function Nb(){}var Pb=[{name:`addRowBefore`,icon:Bt,label:`Add row above`,command:e=>e.chain().focus().addRowBefore().run()},{name:`addRowAfter`,icon:Wt,label:`Add row below`,command:e=>e.chain().focus().addRowAfter().run()},{name:`deleteRow`,icon:fn,label:`Delete row`,command:e=>e.chain().focus().deleteRow().run()}],Fb=[{name:`addColumnBefore`,icon:Kn,label:`Add column left`,command:e=>e.chain().focus().addColumnBefore().run()},{name:`addColumnAfter`,icon:tr,label:`Add column right`,command:e=>e.chain().focus().addColumnAfter().run()},{name:`deleteColumn`,icon:fn,label:`Delete column`,command:e=>e.chain().focus().deleteColumn().run()}],Ib=[{name:`toggleHeaderRow`,icon:Ia,label:`Toggle header row`,command:e=>e.chain().focus().toggleHeaderRow().run()},{name:`toggleHeaderColumn`,icon:Vi,label:`Toggle header column`,command:e=>e.chain().focus().toggleHeaderColumn().run()},{name:`deleteTable`,icon:na,label:`Delete table`,command:e=>e.chain().focus().deleteTable().run()}];function Lb({editor:e}){return e.isActive(`table`)}function Rb(e){let t=(0,Q.c)(14),{action:n,editor:r}=e,i=n.icon,a;t[0]!==n||t[1]!==r?(a=e=>{e.preventDefault(),n.command(r)},t[0]=n,t[1]=r,t[2]=a):a=t[2];let o;t[3]===i?o=t[4]:(o=(0,X.jsx)(i,{className:`size-3.5`}),t[3]=i,t[4]=o);let s;t[5]!==n.label||t[6]!==a||t[7]!==o?(s=(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(J,{variant:`ghost`,size:`icon-xs`,"aria-label":n.label,className:`text-muted-foreground`,onMouseDown:a,children:o})}),t[5]=n.label,t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;t[9]===n.label?c=t[10]:(c=(0,X.jsx)(Fr,{side:`bottom`,sideOffset:8,children:n.label}),t[9]=n.label,t[10]=c);let l;return t[11]!==s||t[12]!==c?(l=(0,X.jsxs)(Lr,{children:[s,c]}),t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function zb(e){let t=(0,Q.c)(13),{editor:n}=e,r;t[0]===n?r=t[1]:(r=Pb.map(e=>(0,X.jsx)(Rb,{action:e,editor:n},e.name)),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,X.jsx)(lv,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[2]=i):i=t[2];let a;t[3]===n?a=t[4]:(a=Fb.map(e=>(0,X.jsx)(Rb,{action:e,editor:n},e.name)),t[3]=n,t[4]=a);let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,X.jsx)(lv,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[5]=o):o=t[5];let s;t[6]===n?s=t[7]:(s=Ib.map(e=>(0,X.jsx)(Rb,{action:e,editor:n},e.name)),t[6]=n,t[7]=s);let c;return t[8]!==n||t[9]!==r||t[10]!==a||t[11]!==s?(c=(0,X.jsxs)(xb,{editor:n,shouldShow:Lb,updateDelay:100,className:`flex items-center gap-0.5 rounded-lg border bg-background p-1 shadow-md`,children:[r,i,a,o,s]}),t[8]=n,t[9]=r,t[10]=a,t[11]=s,t[12]=c):c=t[12],c}var Bb=new WeakMap;function Vb(e){let t=document.createElement(`span`);t.classList.add(`collaboration-cursor__caret`),t.style.borderColor=e.color;let n=document.createElement(`div`);return n.classList.add(`collaboration-cursor__label`),n.style.backgroundColor=e.color,n.style.color=Te(e.color),n.textContent=e.name,t.append(n),t}var Hb={state:`idle`,count:0,lastFiredAt:null,position:`append`,lastAgentId:null},Ub=e=>{let t=(0,Q.c)(69),{provider:n,placeholder:r,isSourceMode:i}=e,a=(0,Z.useRef)(``),o=(0,Z.useRef)(null),s=(0,Z.useRef)(Hb),c=Uy(),{principal:l,activeDocName:u}=Sn(),d=n.configuration.name??``,[f]=(0,Z.useState)(Wb),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null);if(h)throw h;let _=(0,Z.useRef)(null),v;t[0]!==f||t[1]!==d||t[2]!==r||t[3]!==n?(v=()=>{let e;try{let t={viewCount:0,bytes:n.document.getText(`source`).length};e=Xt({docName:d,container:document.createElement(`div`),sizeStats:t,factory:e=>{let t=performance.now();return{editor:new _e({element:e,onBeforeCreate:e=>{let{editor:n}=e;Bb.set(n,t)},onCreate:e=>{let{editor:t}=e,r=Bb.get(t);if(Bb.delete(t),r==null)return;let i=performance.now();wn(`ok/editor/create-tiptap`,{docName:n.configuration.name??`unknown`,ytextLength:n.document.getText(`source`).length},{startTime:r,duration:Math.max(0,i-r)})},editorProps:{attributes:{class:`pt-10 pb-16 h-full`},clipboardTextParser:(e,t,n,r)=>{let i=f.mdManager.parse(e);return r.state.schema.nodeFromJSON(i).content},clipboardTextSerializer:(e,t)=>f.text(e,t),clipboardSerializer:f.html,handlePaste:(e,t)=>f.paste(e,t)},extensions:[...ln.map(e=>e.name===`link`?e.configure({docName:n.configuration.name??``}):e),Ay.configure({placeholder:r??`Type '/' for commands`,showOnlyCurrent:!0}),Nt.configure({document:n.document}),ye.create({name:`imageUploadDecoration`,addProseMirrorPlugins(){return[Gt]}}),ye.create({name:`collaborationCursor`,addProseMirrorPlugins(){let e=n.awareness;if(!e)throw Error(`[TiptapEditor] HocuspocusProvider has no awareness instance — cursor plugin cannot initialize`);return[Qt(e,{cursorBuilder:Vb})]}})]}),ydoc:n.document,ytext:n.document.getText(`source`),provider:n}}}),_.current=e,m(e.editor)}catch(e){let t=e;console.error(`[TiptapEditor] mountTiptapEditor failed`,t),_.current=null,m(null),g(t instanceof Error?t:Error(String(t)))}return()=>{let e=_.current;e&&Mt(e),_.current=null,m(null)}},t[0]=f,t[1]=d,t[2]=r,t[3]=n,t[4]=v):v=t[4];let y;t[5]!==f||t[6]!==d||t[7]!==n?(y=[d,n,f],t[5]=f,t[6]=d,t[7]=n,t[8]=y):y=t[8],(0,Z.useEffect)(v,y);let b;t[9]!==p||t[10]!==n.configuration.name?(b=()=>{if(p)return wt(p,n.configuration.name??null),()=>{wt(p,null)}},t[9]=p,t[10]=n.configuration.name,t[11]=b):b=t[11];let x;t[12]!==p||t[13]!==n?(x=[p,n],t[12]=p,t[13]=n,t[14]=x):x=t[14],(0,Z.useEffect)(b,x);let S;t[15]!==p||t[16]!==n.configuration.name?(S=()=>{},t[15]=p,t[16]=n.configuration.name,t[17]=S):S=t[17];let C;t[18]!==p||t[19]!==n?(C=[p,n],t[18]=p,t[19]=n,t[20]=C):C=t[20],(0,Z.useEffect)(S,C);let w,T;t[21]===p?(w=t[22],T=t[23]):(w=()=>{if(!p)return;let e=Gb,t=null,n=()=>{if(t||!p||p.isDestroyed)return;let n=Ln(p);n&&(t=n.dom,t.addEventListener(`keydown`,e),t.addEventListener(`paste`,e),t.addEventListener(`drop`,e),t.addEventListener(`cut`,e))},r=()=>{t&&=(t.removeEventListener(`keydown`,e),t.removeEventListener(`paste`,e),t.removeEventListener(`drop`,e),t.removeEventListener(`cut`,e),null)};return Ln(p)?n():p.on(`create`,n),()=>{p.off(`create`,n),r()}},T=[p],t[21]=p,t[22]=w,t[23]=T),(0,Z.useEffect)(w,T);let E,D;t[24]!==p||t[25]!==n.document?(D=()=>{if(!p)return;let e=n.document.getMap(`agent-flash`),t=Date.now(),r=0,i=null,a=null,c=null,l=()=>{let t=null;for(let[,n]of e.entries()){let e=n;e.timestamp&&(!t||e.timestamp>t.timestamp)&&(t={agentId:e.agentId??`unknown`,timestamp:e.timestamp,type:e.type??`insert`,description:e.description})}return t},u=e=>{s.current=e;let t=o.current;t&&(t.setAttribute(`data-agent-flash-state`,e.state),t.setAttribute(`data-agent-flash-count`,String(e.count)),t.setAttribute(`data-agent-flash-position`,e.position),t.setAttribute(`data-agent-flash-agent-id`,e.lastAgentId??``))},d=()=>{let e=l(),t=e?.description?.toLowerCase().includes(`prepend`)?`prepend`:`append`,n={state:`editing`,count:(s.current?.count??0)+1,lastFiredAt:Date.now(),position:t,lastAgentId:e?.agentId??null};u(n),document.dispatchEvent(new CustomEvent(`agent-flash`,{detail:n})),a&&clearTimeout(a),c&&clearTimeout(c),a=window.setTimeout(()=>{let e={...n,state:`settled`};u(e),document.dispatchEvent(new CustomEvent(`agent-flash-end`,{detail:e})),c=window.setTimeout(()=>{u({...e,state:`idle`})},300)},Ie)};u(Hb);let f=()=>{if(Ge(e),!Ve(e,t)||document.visibilityState!==`visible`)return;let n=Date.now();if(t=n,n-r<500){if(!i){let e=500-(n-r);i=window.setTimeout(()=>{i=null,r=Date.now(),d()},e)}return}r=n,d()};e.observe(f);let m=()=>{document.visibilityState===`visible`?Ve(e,t)&&(t=Date.now(),r=Date.now(),d()):t=Date.now()};return document.addEventListener(`visibilitychange`,m),()=>{e.unobserve(f),document.removeEventListener(`visibilitychange`,m),i&&clearTimeout(i),a&&clearTimeout(a),c&&clearTimeout(c)}},E=[p,n.document],t[24]=p,t[25]=n.document,t[26]=E,t[27]=D):(E=t[26],D=t[27]),(0,Z.useEffect)(D,E);let O,k;t[28]===n?(O=t[29],k=t[30]):(O=()=>{let e=window.location.hash,t=e.indexOf(`?`),r=t>=0?new URLSearchParams(e.slice(t+1)).get(`anchor`):null;if(!r)return;let i=r,a=0,o,s=!1;function c(){if(s)return;let e=document.getElementById(i);e?(e.scrollIntoView({behavior:`smooth`,block:`start`}),s=!0,n.off(`synced`,c)):a<20&&(a+=1,o=window.setTimeout(c,100))}return c(),n.on(`synced`,c),()=>{o!==void 0&&clearTimeout(o),n.off(`synced`,c)}},k=[n],t[28]=n,t[29]=O,t[30]=k),(0,Z.useEffect)(O,k);let A,j;t[31]===p?(A=t[32],j=t[33]):(A=()=>{if(!p)return;let e=function(e){let t=e.detail;if(!t||t.mode!==`wysiwyg`||!p||p.isDestroyed)return;let n=Ln(p);if(!n)return;let r=n.dom.querySelectorAll(`h1, h2, h3, h4, h5, h6`)[t.index];r&&r.scrollIntoView({behavior:`smooth`,block:`start`})};return window.addEventListener(ii,e),()=>window.removeEventListener(ii,e)},j=[p],t[31]=p,t[32]=A,t[33]=j),(0,Z.useEffect)(A,j);let M,N;t[34]===n.document?(M=t[35],N=t[36]):(M=()=>{let e=n.document.getMap(`metadata`),t=e.get(`frontmatter`);typeof t==`string`&&t&&(a.current=t);let r=()=>{let t=e.get(`frontmatter`);typeof t==`string`&&(a.current=t)};return e.observe(r),()=>e.unobserve(r)},N=[n.document],t[34]=n.document,t[35]=M,t[36]=N),(0,Z.useEffect)(M,N);let P;t[37]!==u||t[38]!==d||t[39]!==c||t[40]!==i||t[41]!==l||t[42]!==n.awareness?(P=()=>{let e=n.awareness;if(e){if(d!==u){e.setLocalState(null);return}e.setLocalState({user:Wy({principal:l,identity:c}),mode:i?`source`:`wysiwyg`})}},t[37]=u,t[38]=d,t[39]=c,t[40]=i,t[41]=l,t[42]=n.awareness,t[43]=P):P=t[43];let F;t[44]!==u||t[45]!==d||t[46]!==c||t[47]!==i||t[48]!==l||t[49]!==n?(F=[n,d,u,c,l,i],t[44]=u,t[45]=d,t[46]=c,t[47]=i,t[48]=l,t[49]=n,t[50]=F):F=t[50],(0,Z.useEffect)(P,F);let I;t[51]===p?I=t[52]:(I=p&&(0,X.jsx)(Ab,{editor:p}),t[51]=p,t[52]=I);let L;t[53]===p?L=t[54]:(L=p&&(0,X.jsx)(zb,{editor:p}),t[53]=p,t[54]=L);let R,z;t[55]===p?(R=t[56],z=t[57]):(R=(0,X.jsx)(bn,{editor:p,className:`h-full`}),z=p&&(0,X.jsx)(Ny,{editor:p}),t[55]=p,t[56]=R,t[57]=z);let B;t[58]===p?B=t[59]:(B=p&&(0,X.jsx)(Vy,{editor:p}),t[58]=p,t[59]=B);let V;t[60]===p?V=t[61]:(V=p&&(0,X.jsx)(Ct,{store:_n(p).store}),t[60]=p,t[61]=V);let H;return t[62]!==I||t[63]!==L||t[64]!==R||t[65]!==z||t[66]!==B||t[67]!==V?(H=(0,X.jsxs)(`div`,{ref:o,className:`tiptap-editor h-full`,"data-agent-flash-state":`idle`,"data-agent-flash-count":`0`,"data-agent-flash-position":`append`,"data-agent-flash-agent-id":``,children:[I,L,R,z,B,V]}),t[62]=I,t[63]=L,t[64]=R,t[65]=z,t[66]=B,t[67]=V,t[68]=H):H=t[68],H};function Wb(){let e=new H({extensions:se});return{mdManager:e,text:li({mdManager:e}),html:si({mdManager:e}),paste:oi({mdManager:e})}}function Gb(){return Fn()}function Kb(e){let t=(0,Q.c)(2),{docName:n,provider:r,children:i}=e;(0,Z.use)(kn(n,r));let a;return t[0]===i?a=t[1]:(a=(0,X.jsx)(X.Fragment,{children:i}),t[0]=i,t[1]=a),a}var qb=`__back-nav__`;function Jb(e){return e instanceof on||e instanceof Cn||e instanceof nn||e instanceof mn||e instanceof Dn?e.docName:null}function Yb(e){return e instanceof on?{title:`Couldn't load document`,summary:`"${e.docName}" took too long. Check your connection.`}:e instanceof Cn?{title:`Connection dropped`,summary:`Lost connection to "${e.docName}".`}:e instanceof nn?{title:`Document not found`,summary:`"${e.docName}" doesn't exist.`}:e instanceof mn?{title:`Couldn't open document`,summary:`Something went wrong opening "${e.docName}".`}:e instanceof Dn?{title:`Server can't open documents`,summary:`This project's running server doesn't support live editing. Restart Open Knowledge to fix.`}:{title:`Unknown error`,summary:e instanceof Error&&e.message?e.message:`An unexpected error occurred.`}}function Xb(e){let t=(0,Q.c)(27),{error:n,resetErrorBoundary:r,activeDocName:i,previousDocName:a,onNavigateBack:o}=e,s;t[0]===n?s=t[1]:(s=Yb(n),t[0]=n,t[1]=s);let{title:c,summary:l}=s,u=!!a&&!!o,d=(0,Z.useRef)(null),f,p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{d.current?.focus()},p=[],t[2]=f,t[3]=p):(f=t[2],p=t[3]),(0,Z.useEffect)(f,p);let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,X.jsx)(rv,{size:80,variant:`sleeping`}),t[4]=m):m=t[4];let h;t[5]===c?h=t[6]:(h=(0,X.jsx)(`h2`,{id:`document-error-title`,className:`text-lg font-medium`,children:c}),t[5]=c,t[6]=h);let g;t[7]===l?g=t[8]:(g=(0,X.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:l}),t[7]=l,t[8]=g);let _;t[9]!==h||t[10]!==g?(_=(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[h,g]}),t[9]=h,t[10]=g,t[11]=_):_=t[11];let v;t[12]===r?v=t[13]:(v=(0,X.jsx)(J,{ref:d,variant:`default`,onClick:r,children:`Try again`}),t[12]=r,t[13]=v);let y;t[14]!==i||t[15]!==u||t[16]!==n||t[17]!==o||t[18]!==a||t[19]!==r?(y=u?(0,X.jsx)(J,{variant:`ghost`,className:`font-mono uppercase`,onClick:()=>{!a||!o||(yn(Jb(n)??i),o(a),r(qb))},children:`Go back`}):null,t[14]=i,t[15]=u,t[16]=n,t[17]=o,t[18]=a,t[19]=r,t[20]=y):y=t[20];let b;t[21]!==v||t[22]!==y?(b=(0,X.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[v,y]}),t[21]=v,t[22]=y,t[23]=b):b=t[23];let x;return t[24]!==b||t[25]!==_?(x=(0,X.jsxs)(`div`,{role:`alert`,"aria-labelledby":`document-error-title`,"data-slot":`document-error-boundary`,className:`flex h-full flex-col items-center justify-center gap-8 p-8 text-center`,children:[m,_,b]}),t[24]=b,t[25]=_,t[26]=x):x=t[26],x}function Zb(e){let t=(0,Q.c)(17),{activeDocName:n,previousDocName:r,onNavigateBack:i,onRecycle:a,children:o}=e,s;t[0]!==n||t[1]!==i||t[2]!==r?(s=e=>(0,X.jsx)(Xb,{...e,activeDocName:n,previousDocName:r,onNavigateBack:i}),t[0]=n,t[1]=i,t[2]=r,t[3]=s):s=t[3];let c;t[4]===n?c=t[5]:(c=[n],t[4]=n,t[5]=c);let l;t[6]!==n||t[7]!==a?(l=e=>{if(e.reason===`imperative-api`){if(Array.isArray(e.args)&&e.args[0]===qb){console.warn(`[DocumentErrorBoundary] back-nav reset (no recycle)`);return}a(n),console.warn(`[DocumentErrorBoundary] retry recycled ${n}`)}else console.warn(`[DocumentErrorBoundary] reset by key change (${e.prev?.[0]} → ${e.next?.[0]})`)},t[6]=n,t[7]=a,t[8]=l):l=t[8];let u;t[9]===n?u=t[10]:(u=e=>{console.warn(`[DocumentErrorBoundary] rendered fallback for ${n}: ${Yb(e).title}`)},t[9]=n,t[10]=u);let d;return t[11]!==o||t[12]!==s||t[13]!==c||t[14]!==l||t[15]!==u?(d=(0,X.jsx)(Vt,{fallbackRender:s,resetKeys:c,onReset:l,onError:u,children:o}),t[11]=o,t[12]=s,t[13]=c,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}function Qb(e){let t=e.threshold??5e5;return e.ytextLength>t?{renderSource:e.isSourceMode||e.visitedSource,renderVisual:!e.isSourceMode||e.visitedVisual,isLarge:!0}:{renderSource:!0,renderVisual:!0,isLarge:!1}}function $b(){return n(()=>import(`./SourceEditor-DnN8ecIW.js`),__vite__mapDeps([24,1,19,2,3,20,21,13,12,5,6,22,7,25,15]),import.meta.url)}var ex=(0,Z.lazy)(async()=>({default:(await $b()).SourceEditor}));function tx(e,t,n){if(n<=0)return[];let r=e.filter(e=>!sn(e.docName)),i=[...r].sort((e,t)=>t.lastAccessedAt-e.lastAccessedAt).slice(0,n);if(t===null||i.some(e=>e.docName===t))return i;let a=r.find(e=>e.docName===t);return a?[...i.slice(0,n-1),a]:i}function nx(e,t){return t.kind===`idle`?null:t.kind===`failed`&&t.failedDocNames.includes(e)?{kind:`failed`,title:`Couldn't reconnect after server restart`,summary:t.reason===`clear-data-timeout`?`Local collaboration data for "${e}" could not be cleared in time. Reload to retry.`:`Local collaboration data for "${e}" could not be cleared. Reload to retry.`,actionLabel:`Reload`}:t.kind===`recovering`&&t.docNames.includes(e)?{kind:`recovering`,title:`Reconnecting after server restart`,summary:t.phase===`clearing-local-cache`?`Clearing local collaboration data for "${e}" before reconnecting.`:`Reopening "${e}" with a fresh local collaboration cache.`}:null}function rx(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,X.jsx)(un,{name:`activity-pool`,children:(0,X.jsx)(ix,{...e})}),t[0]=e,t[1]=n),n}function ix(e){let t=(0,Q.c)(12),{activeDocName:n,isSourceMode:r,editorPlaceholder:i,previousDocName:a,onNavigateBack:o,onRecycle:s}=e,{poolEntries:c,serverRestartRecovery:l}=Sn(),{pages:u,loading:d}=Pe(),f=tx(c,n,3),p=(0,Z.useRef)(``),m=f.map(ax).join(`,`);(0,Z.useLayoutEffect)(()=>{if(p.current===m)return;let e=p.current?p.current.split(`,`):[],t=m?m.split(`,`):[];wn(`ok/activity/mount-list-change`,{active:n,mounted:t,evicted:e.filter(e=>!t.includes(e))}),p.current=m,Ft(t)},[m,n]);let h;t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==d||t[4]!==o||t[5]!==s||t[6]!==u||t[7]!==a||t[8]!==l?(h=e=>(0,X.jsx)(ux,{entry:e,isActive:e.docName===n,isSourceMode:r,editorPlaceholder:i,isNewDoc:!d&&!u.has(e.docName),previousDocName:a,onNavigateBack:o,onRecycle:s,serverRestartRecovery:l},e.docName),t[0]=n,t[1]=i,t[2]=r,t[3]=d,t[4]=o,t[5]=s,t[6]=u,t[7]=a,t[8]=l,t[9]=h):h=t[9];let g=f.map(h),_;return t[10]===g?_=t[11]:(_=(0,X.jsx)(X.Fragment,{children:g}),t[10]=g,t[11]=_),_}function ax(e){return e.docName}function ox(e){let t=(0,Q.c)(8),{isActive:n,children:r}=e,i=(0,Z.useRef)(null),a=(0,Z.useRef)(0),o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{let e=i.current;if(!e)return;let t=()=>{e.scrollTop>0&&(a.current=e.scrollTop)};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},s=[],t[0]=o,t[1]=s):(o=t[0],s=t[1]),(0,Z.useEffect)(o,s);let c,l;t[2]===n?(c=t[3],l=t[4]):(c=()=>{if(!n)return;let e=i.current;if(!e)return;let t=a.current;if(t===0||(e.scrollTop=t,e.scrollTop===t))return;let r=!1,o=()=>{r||(r=!0,s.disconnect(),clearTimeout(c))},s=new ResizeObserver(()=>{r||!e||e.scrollHeight>t&&(e.scrollTop=t,e.scrollTop===t&&o())});s.observe(e);let c=setTimeout(o,500);return o},l=[n],t[2]=n,t[3]=c,t[4]=l),(0,Z.useLayoutEffect)(c,l);let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u={overflowAnchor:`auto`},t[5]=u):u=t[5];let d;return t[6]===r?d=t[7]:(d=(0,X.jsx)(`div`,{ref:i,className:`subtle-scrollbar h-full overflow-y-auto`,style:u,children:r}),t[6]=r,t[7]=d),d}function sx(e){let t=(0,Q.c)(12),{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a}=e,o=r&&i,[s,c]=(0,Z.useState)(o),l,u;if(t[0]===o?(l=t[1],u=t[2]):(l=()=>{o&&c(!0)},u=[o],t[0]=o,t[1]=l,t[2]=u),(0,Z.useEffect)(l,u),!s&&!o)return null;let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,X.jsx)(N_,{}),t[3]=d):d=t[3];let f=n.docName,p;t[4]===n.provider.document?p=t[5]:(p=n.provider.document.getText(`source`),t[4]=n.provider.document,t[5]=p);let m;return t[6]!==a||t[7]!==n.docName||t[8]!==n.provider||t[9]!==o||t[10]!==p?(m=(0,X.jsx)(Z.Suspense,{fallback:d,children:(0,X.jsx)(ex,{docName:f,ytext:p,provider:n.provider,placeholder:a,isSourceModeActive:o})}),t[6]=a,t[7]=n.docName,t[8]=n.provider,t[9]=o,t[10]=p,t[11]=m):m=t[11],m}function cx(e){let t=(0,Q.c)(18),{view:n}=e,r=n.kind===`failed`,i=r?`alert`:`status`,a=!r,o;t[0]===r?o=t[1]:(o=(0,X.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-full border bg-muted text-muted-foreground`,children:r?(0,X.jsx)(wa,{className:`size-5`,"aria-hidden":`true`}):(0,X.jsx)(Rn,{className:`size-5 animate-spin`,"aria-hidden":`true`})}),t[0]=r,t[1]=o);let s;t[2]===n.title?s=t[3]:(s=(0,X.jsx)(`h2`,{className:`text-lg font-medium`,children:n.title}),t[2]=n.title,t[3]=s);let c;t[4]===n.summary?c=t[5]:(c=(0,X.jsx)(`p`,{className:`max-w-md text-sm text-muted-foreground`,children:n.summary}),t[4]=n.summary,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]!==r||t[10]!==n.actionLabel?(u=r?(0,X.jsxs)(J,{type:`button`,onClick:lx,children:[(0,X.jsx)(wa,{className:`size-4`,"aria-hidden":`true`}),n.actionLabel]}):null,t[9]=r,t[10]=n.actionLabel,t[11]=u):u=t[11];let d;return t[12]!==i||t[13]!==a||t[14]!==o||t[15]!==l||t[16]!==u?(d=(0,X.jsxs)(`div`,{"data-slot":`server-restart-recovery`,role:i,"aria-busy":a,className:`flex h-full flex-col items-center justify-center gap-6 p-8 text-center`,children:[o,l,u]}),t[12]=i,t[13]=a,t[14]=o,t[15]=l,t[16]=u,t[17]=d):d=t[17],d}function lx(){return window.location.reload()}function ux(e){let t=(0,Q.c)(36),{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a,isNewDoc:o,previousDocName:s,onNavigateBack:c,onRecycle:l,serverRestartRecovery:u}=e,d;t[0]!==n.docName||t[1]!==u?(d=nx(n.docName,u),t[0]=n.docName,t[1]=u,t[2]=d):d=t[2];let f=d,p=n.provider.document.getText(`source`).length,[m,h]=(0,Z.useState)(i),[g,_]=(0,Z.useState)(!i),v,y;t[3]!==i||t[4]!==m||t[5]!==g?(v=()=>{i&&!m?h(!0):!i&&!g&&_(!0)},y=[i,m,g],t[3]=i,t[4]=m,t[5]=g,t[6]=v,t[7]=y):(v=t[6],y=t[7]),(0,Z.useEffect)(v,y);let b=Qb({ytextLength:p,isSourceMode:i,visitedSource:m,visitedVisual:g}),x=(0,Z.useRef)(``),S=`${b.isLarge}-${b.renderSource}-${b.renderVisual}`,C,w;t[8]!==n.docName||t[9]!==b.isLarge||t[10]!==b.renderSource||t[11]!==b.renderVisual||t[12]!==S||t[13]!==i||t[14]!==p?(C=()=>{x.current!==S&&(x.current=S,b.isLarge&&wn(`ok/activity/defer-mount`,{docName:n.docName,ytextLength:p,isSourceMode:i,renderSource:b.renderSource,renderVisual:b.renderVisual}))},w=[S,b.isLarge,b.renderSource,b.renderVisual,n.docName,p,i],t[8]=n.docName,t[9]=b.isLarge,t[10]=b.renderSource,t[11]=b.renderVisual,t[12]=S,t[13]=i,t[14]=p,t[15]=C,t[16]=w):(C=t[15],w=t[16]),(0,Z.useEffect)(C,w);let T=r?`visible`:`hidden`,E=`editor:${n.docName}`,D;t[17]!==a||t[18]!==n||t[19]!==b.renderSource||t[20]!==b.renderVisual||t[21]!==r||t[22]!==o||t[23]!==i||t[24]!==c||t[25]!==l||t[26]!==s||t[27]!==f?(D=f?(0,X.jsx)(cx,{view:f}):(0,X.jsx)(X.Fragment,{children:(0,X.jsx)(Zb,{activeDocName:n.docName,previousDocName:s,onNavigateBack:c,onRecycle:l,children:(0,X.jsx)(Z.Suspense,{fallback:(0,X.jsx)(N_,{}),children:(0,X.jsx)(Kb,{docName:n.docName,provider:n.provider,children:(0,X.jsxs)(`div`,{className:`relative h-full`,children:[b.renderSource?(0,X.jsx)(`div`,{className:i?`h-full`:`ok-mode-hidden h-full`,children:(0,X.jsx)(sx,{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a})}):null,b.renderVisual?(0,X.jsx)(`div`,{className:i?`ok-mode-hidden h-full`:`h-full`,children:(0,X.jsx)(Ub,{provider:n.provider,placeholder:a,isSourceMode:i},`${n.docName}-${String(o)}`)}):null]})})})})}),t[17]=a,t[18]=n,t[19]=b.renderSource,t[20]=b.renderVisual,t[21]=r,t[22]=o,t[23]=i,t[24]=c,t[25]=l,t[26]=s,t[27]=f,t[28]=D):D=t[28];let O;t[29]!==r||t[30]!==D?(O=(0,X.jsx)(ox,{isActive:r,children:D}),t[29]=r,t[30]=D,t[31]=O):O=t[31];let k;return t[32]!==T||t[33]!==E||t[34]!==O?(k=(0,X.jsx)(Z.Activity,{mode:T,name:E,children:O}),t[32]=T,t[33]=E,t[34]=O,t[35]=k):k=t[35],k}function dx(e){let t=(0,Q.c)(26),{stats:n}=e,r;t[0]===n.words?r=t[1]:(r=n.words.toLocaleString(),t[0]=n.words,t[1]=r);let i;t[2]===r?i=t[3]:(i=(0,X.jsx)(`span`,{className:`tabular-nums`,children:r}),t[2]=r,t[3]=i);let a=n.words===1?`word`:`words`,o;t[4]!==i||t[5]!==a?(o=(0,X.jsxs)(`span`,{children:[i,` `,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6];let s;t[7]===n.chars?s=t[8]:(s=n.chars.toLocaleString(),t[7]=n.chars,t[8]=s);let c;t[9]===s?c=t[10]:(c=(0,X.jsx)(`span`,{className:`tabular-nums`,children:s}),t[9]=s,t[10]=c);let l=n.chars===1?`char`:`chars`,u;t[11]!==c||t[12]!==l?(u=(0,X.jsxs)(`span`,{children:[c,` `,l]}),t[11]=c,t[12]=l,t[13]=u):u=t[13];let d=n.tokens>0?`~`:``,f;t[14]===n.tokens?f=t[15]:(f=n.tokens.toLocaleString(),t[14]=n.tokens,t[15]=f);let p;t[16]===f?p=t[17]:(p=(0,X.jsx)(`span`,{className:`tabular-nums`,children:f}),t[16]=f,t[17]=p);let m=n.tokens===1?`token`:`tokens`,h;t[18]!==p||t[19]!==m||t[20]!==d?(h=(0,X.jsxs)(`span`,{children:[d,p,` `,m]}),t[18]=p,t[19]=m,t[20]=d,t[21]=h):h=t[21];let g;return t[22]!==h||t[23]!==o||t[24]!==u?(g=(0,X.jsxs)(`section`,{"aria-label":`Document statistics`,className:`flex h-6 shrink-0 items-center justify-end gap-3 px-3 text-2xs text-muted-foreground`,children:[o,u,h]}),t[22]=h,t[23]=o,t[24]=u,t[25]=g):g=t[25],g}var fx=(0,Z.lazy)(()=>n(()=>import(`./SettingsPane-dPT0GR3e.js`).then(e=>({default:e.SettingsPane})),__vite__mapDeps([26,1,19,2,3,20,21,13,12,5,6,22,7,14,27,17]),import.meta.url));function px(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,X.jsx)(un,{name:`editor-area`,children:(0,X.jsx)(mx,{...e})}),t[0]=e,t[1]=n),n}function mx(e){let t=(0,Q.c)(92),{editorMode:n,activeTab:r,onActiveTabChange:i}=e,a=ed(),{activeDocName:o,activeProvider:s,activeTarget:c,recycleDocument:l,docPanelMode:u,docPanelExpandSignal:d}=Sn(),{openDocumentTransition:f}=En(),p=ky(s,o),m=(0,Z.useDeferredValue)(o),h=c?.kind===`missing`,g=!!o&&c?.kind!==`folder`,_=h?`Start writing to create this page…`:void 0,v=A_(),[y,b]=(0,Z.useState)(!1),{layout:x,autoCollapse:S}=vy(),C=x===`sheet`,[w,T]=(0,Z.useState)(!1),E=(0,Z.useRef)(!1),D,O;t[0]!==S||t[1]!==x||t[2]!==v?(D=()=>{x===`panel`&&(S?(E.current=!1,v.current?.collapse()):E.current||v.current?.expand())},O=[S,x,v],t[0]=S,t[1]=x,t[2]=v,t[3]=D,t[4]=O):(D=t[3],O=t[4]),(0,Z.useEffect)(D,O);let k,A;t[5]!==d||t[6]!==C||t[7]!==v?(k=()=>{d!==0&&(C?T(!0):(E.current=!1,v.current?.expand()))},A=[d,C,v],t[5]=d,t[6]=C,t[7]=v,t[8]=k,t[9]=A):(k=t[8],A=t[9]),(0,Z.useEffect)(k,A);let j=(0,Z.useRef)(null),[M,N]=(0,Z.useState)(null),P,F;if(t[10]===o?(P=t[11],F=t[12]):(P=()=>{if(o&&o!==j.current){let e=j.current;j.current=o,N(e)}},F=[o],t[10]=o,t[11]=P,t[12]=F),(0,Z.useEffect)(P,F),a.scope!==null){let e;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(N_,{}),t[13]=e):e=t[13];let n;return t[14]!==a.close||t[15]!==a.scope||t[16]!==a.setScope?(n=(0,X.jsx)(Z.Suspense,{fallback:e,children:(0,X.jsx)(fx,{scope:a.scope,onClose:a.close,onScopeChange:a.setScope})}),t[14]=a.close,t[15]=a.scope,t[16]=a.setScope,t[17]=n):n=t[17],n}if(c?.kind===`folder`){let e;return t[18]===c.folderPath?e=t[19]:(e=(0,X.jsx)(cy,{folderPath:c.folderPath}),t[18]=c.folderPath,t[19]=e),e}if(!s||!o){if((typeof window<`u`?Re(window.location.hash):null)!==null){let e;return t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(N_,{}),t[20]=e):e=t[20],e}let e;return t[21]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Av,{}),t[21]=e):e=t[21],e}let I=n===`source`,L=C?!w:y,R;t[22]!==y||t[23]!==C||t[24]!==v?(R=()=>{C?T(hx):y?(E.current=!1,v.current?.expand()):(E.current=!0,v.current?.collapse())},t[22]=y,t[23]=C,t[24]=v,t[25]=R):R=t[25];let z=L?`Show document panel`:`Hide document panel`,B;t[26]===L?B=t[27]:(B=L?(0,X.jsx)(_a,{className:`size-4`}):(0,X.jsx)(ga,{className:`size-4`}),t[26]=L,t[27]=B);let V;t[28]!==R||t[29]!==z||t[30]!==B?(V=(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(J,{variant:`ghost`,size:`icon`,onClick:R,"aria-label":z,className:`text-muted-foreground`,children:B})}),t[28]=R,t[29]=z,t[30]=B,t[31]=V):V=t[31];let H=L?`Show panel`:`Hide panel`,U;t[32]===H?U=t[33]:(U=(0,X.jsx)(Fr,{side:`left`,children:H}),t[32]=H,t[33]=U);let W;t[34]!==V||t[35]!==U?(W=(0,X.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:(0,X.jsxs)(Lr,{children:[V,U]})}),t[34]=V,t[35]=U,t[36]=W):W=t[36];let G=W,ee=m??o,K=M??void 0,te;t[37]===f?te=t[38]:(te=e=>{let t=$e(e);window.location.hash===t?f(e):window.location.hash=t},t[37]=f,t[38]=te);let ne;t[39]!==_||t[40]!==I||t[41]!==l||t[42]!==ee||t[43]!==K||t[44]!==te?(ne=(0,X.jsx)(rx,{activeDocName:ee,isSourceMode:I,editorPlaceholder:_,previousDocName:K,onNavigateBack:te,onRecycle:l}),t[39]=_,t[40]=I,t[41]=l,t[42]=ee,t[43]=K,t[44]=te,t[45]=ne):ne=t[45];let re;t[46]!==o||t[47]!==m?(re=o&&o!==m?(0,X.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,X.jsx)(N_,{})}):null,t[46]=o,t[47]=m,t[48]=re):re=t[48];let ie;t[49]!==ne||t[50]!==re?(ie=(0,X.jsxs)(`div`,{className:`relative h-full`,children:[ne,re]}),t[49]=ne,t[50]=re,t[51]=ie):ie=t[51];let ae;t[52]!==ie||t[53]!==G?(ae=(0,X.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[ie,G]}),t[52]=ie,t[53]=G,t[54]=ae):ae=t[54];let oe;t[55]!==g||t[56]!==p?(oe=g&&(0,X.jsx)(dx,{stats:p}),t[55]=g,t[56]=p,t[57]=oe):oe=t[57];let se;t[58]!==ae||t[59]!==oe?(se=(0,X.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[ae,oe]}),t[58]=ae,t[59]=oe,t[60]=se):se=t[60];let ce=se;if(C){let e;t[61]===ce?e=t[62]:(e=(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:ce}),t[61]=ce,t[62]=e);let n;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,X.jsx)(mm,{className:`sr-only`,children:(0,X.jsx)(hm,{children:`Document panel`})}),t[63]=n):n=t[63];let a;t[64]!==o||t[65]!==r||t[66]!==u||t[67]!==I||t[68]!==i?(a=(0,X.jsxs)(pm,{side:`right`,className:`flex w-80 sm:w-96 flex-col gap-0 p-0`,children:[n,(0,X.jsx)(Lh,{docName:o,isSourceMode:I,activeTab:r,onActiveTabChange:i,mode:u})]}),t[64]=o,t[65]=r,t[66]=u,t[67]=I,t[68]=i,t[69]=a):a=t[69];let s;t[70]!==w||t[71]!==a?(s=(0,X.jsx)(um,{open:w,onOpenChange:T,children:a}),t[70]=w,t[71]=a,t[72]=s):s=t[72];let c;return t[73]!==e||t[74]!==s?(c=(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[e,s]}),t[73]=e,t[74]=s,t[75]=c):c=t[75],c}let le;t[76]===ce?le=t[77]:(le=(0,X.jsx)(my,{minSize:`30%`,defaultSize:`75%`,children:ce}),t[76]=ce,t[77]=le);let ue;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,X.jsx)(hy,{withHandle:!0}),t[78]=ue):ue=t[78];let de;t[79]===Symbol.for(`react.memo_cache_sentinel`)?(de=e=>b(e.asPercentage===0),t[79]=de):de=t[79];let fe;t[80]!==o||t[81]!==r||t[82]!==u||t[83]!==I||t[84]!==i?(fe=(0,X.jsx)(Lh,{docName:o,isSourceMode:I,activeTab:r,onActiveTabChange:i,mode:u}),t[80]=o,t[81]=r,t[82]=u,t[83]=I,t[84]=i,t[85]=fe):fe=t[85];let pe;t[86]!==v||t[87]!==fe?(pe=(0,X.jsx)(my,{panelRef:v,defaultSize:`25%`,minSize:`300px`,maxSize:`40%`,collapsible:!0,collapsedSize:0,onResize:de,className:`flex flex-col bg-muted/20`,children:fe}),t[86]=v,t[87]=fe,t[88]=pe):pe=t[88];let me;return t[89]!==le||t[90]!==pe?(me=(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,X.jsxs)(py,{orientation:`horizontal`,children:[le,ue,pe]})}),t[89]=le,t[90]=pe,t[91]=me):me=t[91],me}function hx(e){return!e}function gx(e,t){return t.trim()}function _x(e){return![``,`.`,`..`].includes(e)&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)}function vx(e,t){let n=gx(e.kind,t),r=e.path.split(`/`);return r[r.length-1]=n,r.join(`/`)}function yx(e,t){if(t.length===0)return e;let n=new Map(t.map(e=>[e.fromDocName,e.toDocName]));return e.map(e=>({...e,docName:n.get(e.docName)??e.docName}))}function bx(e,t){if(t.length===0)return e;let n=new Set(t);return e.filter(e=>!n.has(e.docName))}function xx(e,t){return e?t.find(t=>t.fromDocName===e)?.toDocName??e:null}var Sx=1280;function Cx(){let e=(0,Q.c)(2),[t,n]=(0,Z.useState)(wx),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(max-width: ${Sx-1}px)`),t=()=>{n(window.innerWidth<Sx)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Z.useEffect)(r,i),t}function wx(){return window.innerWidth<Sx}function Tx(e){let t=e.endsWith(`rem`)?`rem`:`px`;return{value:Number.parseFloat(e),unit:t}}function Ex(e){let{value:t,unit:n}=Tx(e);return n===`rem`?t*16:t}function Dx(e,t){return`${t===`rem`?e.toFixed(1):Math.round(e)}${t}`}var Ox=3600*24*7;function kx(e){let t=(0,Q.c)(28),{direction:n,currentWidth:r,onResize:i,onToggle:a,isCollapsed:o,minResizeWidth:s,maxResizeWidth:c,enableToggle:l,enableAutoCollapse:u,autoCollapseThreshold:d,expandThreshold:f,enableDrag:p,setIsDraggingRail:m,widthCookieName:h,widthCookieMaxAge:g,isNested:_}=e,v=n===void 0?`right`:n,y=o===void 0?!1:o,b=s===void 0?`14rem`:s,x=c===void 0?`24rem`:c,S=l===void 0?!0:l,C=u===void 0?!0:u,w=d===void 0?1.5:d,T=f===void 0?.2:f,E=p===void 0?!0:p,D=m===void 0?Ax:m,O=g===void 0?Ox:g,k=_===void 0?!1:_,A=(0,Z.useRef)(null),j=(0,Z.useRef)(0),M=(0,Z.useRef)(0),N=(0,Z.useRef)(!1),P=(0,Z.useRef)(!1),F=(0,Z.useRef)(null),I=(0,Z.useRef)(0),L=(0,Z.useRef)(!1),R=(0,Z.useRef)(0),z=(0,Z.useRef)(0),B=(0,Z.useRef)(null),V=(0,Z.useRef)(r),H=(0,Z.useRef)(y),U,W;t[0]===r?(U=t[1],W=t[2]):(U=()=>{V.current=r},W=[r],t[0]=r,t[1]=U,t[2]=W),(0,Z.useEffect)(U,W);let G,ee;t[3]===y?(G=t[4],ee=t[5]):(G=()=>{H.current=y},ee=[y],t[3]=y,t[4]=G,t[5]=ee),(0,Z.useEffect)(G,ee);let K=Ex(b),te;t[6]===x?te=t[7]:(te=Ex(x),t[6]=x,t[7]=te);let ne=te,re;t[8]!==E||t[9]!==k?(re=function(e){P.current=!0,E&&(j.current=H.current?0:Ex(V.current),M.current=e.clientX,I.current=e.clientX,F.current=null,L.current=!1,R.current=0,z.current=0,B.current=k&&A.current?A.current.getBoundingClientRect():null,e.preventDefault())},t[8]=E,t[9]=k,t[10]=re):re=t[10];let ie=re,ae,oe;t[11]!==w||t[12]!==v||t[13]!==C||t[14]!==S||t[15]!==T||t[16]!==k||t[17]!==ne||t[18]!==K||t[19]!==i||t[20]!==a||t[21]!==D||t[22]!==O||t[23]!==h?(ae=()=>{let e=function(e){h&&(document.cookie=`${h}=${e}; path=/; max-age=${O}`)},t=function(e,t){return v===`left`?e<t:e>t},n=function(e,t,n,r){if(k&&r){let r=e.clientX-t;return v===`left`?n-r:n+r}return v===`left`?window.innerWidth-e.clientX:e.clientX},r=function(r){if(!P.current)return;let o=Math.abs(r.clientX-M.current);if(!N.current&&o>5&&(N.current=!0,D(!0)),N.current){let{unit:o}=Tx(V.current),s=B.current;k&&A.current&&(s=A.current.getBoundingClientRect());let c=t(r.clientX,I.current)?`expand`:`collapse`;F.current!==c&&(F.current=c),z.current=Math.abs(r.clientX-I.current);let l=Date.now();if(L.current&&l-R.current>200&&(L.current=!1),!L.current){if(C&&a&&!H.current){let e=n(r,M.current,j.current,s),t=!1;if(w<=1)t=e<=K*w;else if(e<=K){let n=K*(w-1);t=K-e>=n}if(c===`collapse`&&t){a(),I.current=r.clientX,L.current=!0,R.current=l;return}}if(a&&H.current&&c===`expand`&&z.current>K*T){a();let t=n(r,M.current,j.current,s),c=Math.max(K,Math.min(ne,t)),u=Dx(o===`rem`?c/16:c,o);i(u),e(u),I.current=r.clientX,L.current=!0,R.current=l;return}}if(H.current)return;let u=n(r,M.current,j.current,s),d=Math.max(K,Math.min(ne,u)),f=Dx(o===`rem`?d/16:d,o);i(f),e(f)}},o=function(){P.current&&(!N.current&&a&&S&&a(),N.current=!1,P.current=!1,F.current=null,I.current=0,L.current=!1,R.current=0,z.current=0,B.current=null,D(!1))};return document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,o),()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,o)}},oe=[i,a,D,K,ne,k,C,w,T,S,h,O,v],t[11]=w,t[12]=v,t[13]=C,t[14]=S,t[15]=T,t[16]=k,t[17]=ne,t[18]=K,t[19]=i,t[20]=a,t[21]=D,t[22]=O,t[23]=h,t[24]=ae,t[25]=oe):(ae=t[24],oe=t[25]),(0,Z.useEffect)(ae,oe);let se;return t[26]===ie?se=t[27]:(se={dragRef:A,isDragging:N,handleMouseDown:ie},t[26]=ie,t[27]=se),se}function Ax(){}var jx=`sidebar_state`,Mx=3600*24*7,Nx=`18rem`,Px=`3rem`,Fx=`\\`,Ix=`app-file-sidebar`,Lx=`14rem`,Rx=`22rem`,zx=`sidebar_width`,Bx=/^\d+(?:\.\d+)?(?:rem|px)$/,Vx=Z.createContext(null);function Hx(e){if(typeof document>`u`)return e;let t=document.cookie.split(`; `).find(e=>e.startsWith(`${zx}=`))?.split(`=`)[1];if(!t)return e;let n=decodeURIComponent(t);return Bx.test(n)?n:e}function Ux(){let e=Z.use(Vx);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function Wx(e){let t=(0,Q.c)(55),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({defaultOpen:c,open:i,onOpenChange:o,className:r,style:s,children:n,defaultWidth:l,...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,t[8]=l);let u=c===void 0?!0:c,d=l===void 0?Nx:l,f=Cx(),p;t[9]===d?p=t[10]:(p=()=>Hx(d),t[9]=d,t[10]=p);let[m,h]=Z.useState(p),[g,_]=Z.useState(!1),[v,y]=Z.useState(!1),[b,x]=Z.useState(!1),[S,C]=Z.useState(u),w=i??S,T;t[11]!==w||t[12]!==o?(T=e=>{let t=typeof e==`function`?e(w):e;o?o(t):C(t),document.cookie=`${jx}=${t}; path=/; max-age=${Mx}`},t[11]=w,t[12]=o,t[13]=T):T=t[13];let E=T,D;t[14]!==f||t[15]!==E?(D=function(){return f?_(Kx):E(Gx)},t[14]=f,t[15]=E,t[16]=D):D=t[16];let O=D,k;t[17]!==f||t[18]!==g?(k=function(){!f||!g||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches||x(!0)},t[17]=f,t[18]=g,t[19]=k):k=t[19];let A=k,j,M;t[20]===O?(j=t[21],M=t[22]):(j=()=>{let e=e=>{e.key===Fx&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),O())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},M=[O],t[20]=O,t[21]=j,t[22]=M),Z.useEffect(j,M);let N,P;t[23]!==f||t[24]!==g?(P=()=>{if(!f||!g)return;let e=e=>{e.key===`Escape`&&(document.querySelector(`[data-state="open"][role="dialog"], [data-state="open"][role="alertdialog"], [data-state="open"][role="menu"], [data-state="open"][role="listbox"], [data-radix-popper-content-wrapper] [data-state="open"]`)||_(!1))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},N=[f,g],t[23]=f,t[24]=g,t[25]=N,t[26]=P):(N=t[25],P=t[26]),Z.useEffect(P,N);let F=Z.useRef(f),I,L;t[27]!==f||t[28]!==w?(I=()=>{!F.current&&f&&_(w),F.current=f},L=[f,w],t[27]=f,t[28]=w,t[29]=I,t[30]=L):(I=t[29],L=t[30]),Z.useEffect(I,L);let R=f?g?`expanded`:`collapsed`:w?`expanded`:`collapsed`,z;t[31]!==v||t[32]!==f||t[33]!==A||t[34]!==w||t[35]!==g||t[36]!==E||t[37]!==b||t[38]!==R||t[39]!==O||t[40]!==m?(z={state:R,open:w,setOpen:E,isMobile:f,openMobile:g,setOpenMobile:_,toggleSidebar:O,width:m,setWidth:h,isDraggingRail:v,setIsDraggingRail:y,showPushPulse:b,setShowPushPulse:x,notifySidebarFileSelected:A},t[31]=v,t[32]=f,t[33]=A,t[34]=w,t[35]=g,t[36]=E,t[37]=b,t[38]=R,t[39]=O,t[40]=m,t[41]=z):z=t[41];let B;t[42]!==s||t[43]!==m?(B={"--sidebar-width":m,"--sidebar-width-icon":Px,...s},t[42]=s,t[43]=m,t[44]=B):B=t[44];let V=B,H;t[45]===r?H=t[46]:(H=q(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),t[45]=r,t[46]=H);let U;t[47]!==n||t[48]!==a||t[49]!==V||t[50]!==H?(U=(0,X.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:V,className:H,...a,children:n}),t[47]=n,t[48]=a,t[49]=V,t[50]=H,t[51]=U):U=t[51];let W;return t[52]!==z||t[53]!==U?(W=(0,X.jsx)(Vx.Provider,{value:z,children:U}),t[52]=z,t[53]=U,t[54]=W):W=t[54],W}function Gx(e){return!e}function Kx(e){return!e}function qx(e){let t=(0,Q.c)(51),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({side:a,variant:o,collapsible:s,className:r,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);let c=a===void 0?`left`:a,l=o===void 0?`sidebar`:o,u=s===void 0?`offcanvas`:s,{isMobile:d,state:f,openMobile:p,isDraggingRail:m}=Ux();if(u===`none`){let e;t[7]===r?e=t[8]:(e=q(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),t[7]=r,t[8]=e);let a;return t[9]!==n||t[10]!==i||t[11]!==e||t[12]!==l?(a=(0,X.jsx)(`div`,{"data-slot":`sidebar`,"data-variant":l,className:e,...i,children:n}),t[9]=n,t[10]=i,t[11]=e,t[12]=l,t[13]=a):a=t[13],a}if(d){let e=p?`expanded`:`collapsed`,a=l===`floating`||l===`inset`?`p-2`:``,o;t[14]!==r||t[15]!==a?(o=q(`fixed inset-y-0 z-30 flex h-svh w-(--sidebar-width)`,`transition-transform duration-200 ease-linear motion-reduce:transition-none`,`data-[side=left]:left-0 data-[side=right]:right-0`,`group-data-[state=collapsed]:data-[side=left]:-translate-x-full`,`group-data-[state=collapsed]:data-[side=right]:translate-x-full`,a,r),t[14]=r,t[15]=a,t[16]=o):o=t[16];let s;t[17]===n?s=t[18]:(s=(0,X.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[17]=n,t[18]=s);let u;t[19]!==i||t[20]!==c||t[21]!==o||t[22]!==s?(u=(0,X.jsx)(`nav`,{id:Ix,"aria-label":`File sidebar`,"data-slot":`sidebar-container`,"data-side":c,className:o,...i,children:s}),t[19]=i,t[20]=c,t[21]=o,t[22]=s,t[23]=u):u=t[23];let d;return t[24]!==e||t[25]!==c||t[26]!==u||t[27]!==l?(d=(0,X.jsx)(`div`,{className:`group peer text-sidebar-foreground`,"data-state":e,"data-variant":l,"data-side":c,"data-slot":`sidebar`,"data-mobile":`true`,children:u}),t[24]=e,t[25]=c,t[26]=u,t[27]=l,t[28]=d):d=t[28],d}let h=f===`collapsed`?u:``,g=l===`floating`||l===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`,_;t[29]===g?_=t[30]:(_=q(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,g,`group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0`),t[29]=g,t[30]=_);let v;t[31]===_?v=t[32]:(v=(0,X.jsx)(`div`,{"data-slot":`sidebar-gap`,className:_}),t[31]=_,t[32]=v);let y=l===`floating`||l===`inset`?`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l`,b;t[33]!==r||t[34]!==y?(b=q(`fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear 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`,y,`group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0`,r),t[33]=r,t[34]=y,t[35]=b):b=t[35];let x;t[36]===n?x=t[37]:(x=(0,X.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[36]=n,t[37]=x);let S;t[38]!==i||t[39]!==c||t[40]!==x||t[41]!==b?(S=(0,X.jsx)(`div`,{"data-slot":`sidebar-container`,"data-side":c,className:b,...i,children:x}),t[38]=i,t[39]=c,t[40]=x,t[41]=b,t[42]=S):S=t[42];let C;return t[43]!==m||t[44]!==c||t[45]!==f||t[46]!==S||t[47]!==h||t[48]!==v||t[49]!==l?(C=(0,X.jsxs)(`div`,{className:`group peer hidden text-sidebar-foreground md:block`,"data-state":f,"data-collapsible":h,"data-variant":l,"data-side":c,"data-slot":`sidebar`,"data-dragging":m,children:[v,S]}),t[43]=m,t[44]=c,t[45]=f,t[46]=S,t[47]=h,t[48]=v,t[49]=l,t[50]=C):C=t[50],C}function Jx(e){let t=(0,Q.c)(16),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,state:o}=Ux(),s=o===`expanded`,c;t[4]===n?c=t[5]:(c=q(n),t[4]=n,t[5]=c);let l;t[6]!==r||t[7]!==a?(l=e=>{r?.(e),a()},t[6]=r,t[7]=a,t[8]=l):l=t[8];let u,d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,X.jsx)(ha,{}),d=(0,X.jsx)(`span`,{className:`sr-only`,children:`Toggle Sidebar`}),t[9]=u,t[10]=d):(u=t[9],d=t[10]);let f;return t[11]!==i||t[12]!==s||t[13]!==c||t[14]!==l?(f=(0,X.jsxs)(J,{"data-sidebar":`trigger`,"data-slot":`sidebar-trigger`,variant:`ghost`,size:`icon-sm`,"aria-expanded":s,"aria-controls":Ix,className:c,onClick:l,...i,children:[u,d]}),t[11]=i,t[12]=s,t[13]=c,t[14]=l,t[15]=f):f=t[15],f}function Yx(e){let t=(0,Q.c)(22),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,enableDrag:a,onMouseDown:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?!0:a,{toggleSidebar:s,setWidth:c,state:l,width:u,setIsDraggingRail:d}=Ux(),f=l===`collapsed`,p;t[5]!==o||t[6]!==d||t[7]!==c||t[8]!==f||t[9]!==s||t[10]!==u?(p={direction:`right`,enableDrag:o,onResize:c,onToggle:s,currentWidth:u,isCollapsed:f,minResizeWidth:Lx,maxResizeWidth:Rx,setIsDraggingRail:d,widthCookieName:zx,widthCookieMaxAge:Mx},t[5]=o,t[6]=d,t[7]=c,t[8]=f,t[9]=s,t[10]=u,t[11]=p):p=t[11];let{dragRef:m,handleMouseDown:h}=kx(p),g;t[12]!==h||t[13]!==r?(g=e=>{r?.(e),e.defaultPrevented||h(e)},t[12]=h,t[13]=r,t[14]=g):g=t[14];let _;t[15]===n?_=t[16]:(_=q(`absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2`,`in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize`,`[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize`,`group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar`,`[[data-side=left][data-collapsible=offcanvas]_&]:-right-2`,`[[data-side=right][data-collapsible=offcanvas]_&]:-left-2`,n),t[15]=n,t[16]=_);let v;return t[17]!==m||t[18]!==i||t[19]!==g||t[20]!==_?(v=(0,X.jsx)(`button`,{ref:m,"data-sidebar":`rail`,"data-slot":`sidebar-rail`,"aria-label":`Toggle Sidebar`,tabIndex:-1,onMouseDown:g,title:`Toggle Sidebar`,className:_,...i}),t[17]=m,t[18]=i,t[19]=g,t[20]=_,t[21]=v):v=t[21],v}function Xx(e){let t=(0,Q.c)(21),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,onClick:i,onAnimationEnd:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{isMobile:o,openMobile:s,setOpenMobile:c,showPushPulse:l,setShowPushPulse:u}=Ux(),d;t[5]!==o||t[6]!==i||t[7]!==s||t[8]!==c?(d=e=>{i?.(e),!e.defaultPrevented&&(!o||!s||e.target?.closest(`[data-sidebar="trigger"]`)||c(!1))},t[5]=o,t[6]=i,t[7]=s,t[8]=c,t[9]=d):d=t[9];let f=d,p;t[10]!==r||t[11]!==u?(p=e=>{r?.(e),e.animationName===`sidebar-push-pulse`&&u(!1)},t[10]=r,t[11]=u,t[12]=p):p=t[12];let m=p,h=l?``:void 0,g;t[13]===n?g=t[14]:(g=q(`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`,`transition-transform duration-200 ease-linear motion-reduce:transition-none`,`peer-data-[mobile=true]:peer-data-[state=expanded]:translate-x-(--sidebar-width)`,n),t[13]=n,t[14]=g);let _;return t[15]!==m||t[16]!==f||t[17]!==a||t[18]!==h||t[19]!==g?(_=(0,X.jsx)(`main`,{"data-slot":`sidebar-inset`,"data-push-pulse":h,onClick:f,onAnimationEnd:m,className:g,...a}),t[15]=m,t[16]=f,t[17]=a,t[18]=h,t[19]=g,t[20]=_):_=t[20],_}function Zx(e){let t=(0,Q.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=q(`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,X.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 Qx(e){let t=(0,Q.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=q(`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,X.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 $x(e){let t=(0,Q.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=q(`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,X.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 eS(e){let t=(0,Q.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=q(`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,X.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 tS(e){let t=(0,Q.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=q(`group/menu-item relative`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.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 nS=lt(`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:bg-sidebar-hover hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-hover 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-hover data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground data-active:hover:bg-sidebar-accent [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate`,{variants:{variant:{default:`hover:bg-sidebar-hover hover:text-sidebar-accent-foreground`,outline:`bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-hover hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]`},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 rS(e){let t=(0,Q.c)(28),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]):({asChild:i,isActive:a,variant:o,size:s,tooltip:c,className:n,...r}=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=i===void 0?!1:i,u=a===void 0?!1:a,d=o===void 0?`default`:o,f=s===void 0?`default`:s,p=l?pt:`button`,{isMobile:m,state:h}=Ux(),g;t[8]!==n||t[9]!==f||t[10]!==d?(g=q(nS({variant:d,size:f}),n),t[8]=n,t[9]=f,t[10]=d,t[11]=g):g=t[11];let _;t[12]!==p||t[13]!==u||t[14]!==r||t[15]!==f||t[16]!==g?(_=(0,X.jsx)(p,{"data-slot":`sidebar-menu-button`,"data-sidebar":`menu-button`,"data-size":f,"data-active":u,className:g,...r}),t[12]=p,t[13]=u,t[14]=r,t[15]=f,t[16]=g,t[17]=_):_=t[17];let v=_;if(!c)return v;if(typeof c==`string`){let e;t[18]===c?e=t[19]:(e={children:c},t[18]=c,t[19]=e),c=e}let y;t[20]===v?y=t[21]:(y=(0,X.jsx)(Pr,{asChild:!0,children:v}),t[20]=v,t[21]=y);let b=h!==`collapsed`||m,x;t[22]!==b||t[23]!==c?(x=(0,X.jsx)(Fr,{side:`right`,align:`center`,hidden:b,...c}),t[22]=b,t[23]=c,t[24]=x):x=t[24];let S;return t[25]!==y||t[26]!==x?(S=(0,X.jsxs)(Lr,{children:[y,x]}),t[25]=y,t[26]=x,t[27]=S):S=t[27],S}function iS(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.kind!==i.kind)return!1;if(r.kind===`human`&&i.kind===`human`){if(r.clientId!==i.clientId||r.mode!==i.mode||r.tabCount!==i.tabCount)return!1;let e=r.user,t=i.user;if(e.name!==t.name||e.color!==t.color||e.icon!==t.icon)return!1}else if(r.kind===`agent`&&i.kind===`agent`){if(r.agentId!==i.agentId)return!1;let e=r.presence,t=i.presence;if(e.displayName!==t.displayName||e.icon!==t.icon||e.color!==t.color||e.currentDoc!==t.currentDoc||e.mode!==t.mode)return!1}}return!0}function aS(e){let t=new Map;for(let n of e){let e=n.user.principalId;if(typeof e==`string`&&e.length>0){let r=t.get(e);r?r.push(n):t.set(e,[n])}}let n=new Map;for(let[e,r]of t){let t=r.reduce((e,t)=>Math.min(e,t.clientId),1/0);n.set(e,{repClientId:t,count:r.length})}let r=[];for(let t of e){let e=t.user.principalId;if(typeof e==`string`&&e.length>0){let i=n.get(e);i&&i.repClientId===t.clientId&&r.push({...t,tabCount:i.count})}else r.push({...t,tabCount:1})}return r}var oS=1e3,sS=!1;function cS(e,t,n){let r=(0,Q.c)(9),i;r[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={current:[],crossDoc:[]},r[0]=i):i=r[0];let[a,o]=(0,Z.useState)(i),s;r[1]!==n||r[2]!==e?.awareness||r[3]!==t?.awareness?(s=()=>{let r=e?.awareness,i=t?.awareness,a;i==null?a=void 0:Qn(i)?a=i:(a=void 0,sS||(sS=!0,console.warn(`[agent-presence] __system__ provider awareness missing getStates() — presence bar will render without agent peers`)));let s=()=>{let e=[];if(r)for(let[t,n]of r.getStates().entries()){let r=n;if(!r.user||typeof r.user!=`object`)continue;let i=r.user;i.type===`human`&&e.push({kind:`human`,clientId:t,user:i,mode:r.mode??`wysiwyg`,tabCount:1})}let t=aS(e),{current:i,crossDoc:s}=a?qn(a,n,Date.now()):{current:[],crossDoc:[]},c=lS,l=i.map(c),u=s.map(c),d=[...t,...l],f=u;o(e=>iS(e.current,d)&&iS(e.crossDoc,f)?e:{current:d,crossDoc:f})};s();let c=()=>s(),l=()=>s();r?.on(`change`,c),t?.awareness?.on(`change`,l);let u=setInterval(s,oS);return()=>{r?.off(`change`,c),t?.awareness?.off(`change`,l),clearInterval(u)}},r[1]=n,r[2]=e?.awareness,r[3]=t?.awareness,r[4]=s):s=r[4];let c;return r[5]!==n||r[6]!==e||r[7]!==t?(c=[e,t,n],r[5]=n,r[6]=e,r[7]=t,r[8]=c):c=r[8],(0,Z.useEffect)(s,c),a}function lS(e){let{agentId:t,entry:n}=e;return{kind:`agent`,agentId:t,presence:n}}function uS(e){let t=(0,Q.c)(3),[n,r]=(0,Z.useState)(`connecting`),i,a;return t[0]===e?(i=t[1],a=t[2]):(i=()=>{if(!e){r(`connecting`);return}let t=e.configuration.websocketProvider.status;e.isSynced?r(`synced`):r(t===`connected`?`connected`:t===`disconnected`?`disconnected`:`connecting`);let n=e=>{let{status:t}=e;r(t===`connected`?dS:t===`disconnected`?`disconnected`:`connecting`)},i=e=>{let{state:t}=e;r(t?`synced`:`connected`)},a=()=>r(`disconnected`);return e.on(`status`,n),e.on(`synced`,i),e.on(`disconnect`,a),()=>{e.off(`status`,n),e.off(`synced`,i),e.off(`disconnect`,a)}},a=[e],t[0]=e,t[1]=i,t[2]=a),(0,Z.useEffect)(i,a),n}function dS(e){return e===`synced`?`synced`:`connected`}var fS=`sync-status`;function pS(e,t){let n=(0,Q.c)(4),r=(0,Z.useRef)(!1),i=(0,Z.useRef)(!1),a=(0,Z.useRef)(t),o,s;n[0]!==t||n[1]!==e?(o=()=>{a.current!==t&&(a.current=t,r.current=!1,i.current=!1),t&&(e===`synced`&&(r.current=!0),e===`disconnected`&&r.current?(i.current=!0,Ar.warning(`Connection lost — keep this tab open, your edits will sync when reconnected`,{id:fS,duration:1/0})):i.current&&e===`synced`&&(i.current=!1,Ar.success(`Reconnected`,{id:fS,duration:3e3})))},s=[e,t],n[0]=t,n[1]=e,n[2]=o,n[3]=s):(o=n[2],s=n[3]),(0,Z.useEffect)(o,s)}var mS=4,hS=3,gS={Bird:Di,Cat:Ni,Dog:Ki,Fish:Xi,Mouse:Ca,Rabbit:Sa,Shrimp:ka,Snail:Aa,Squirrel:Na,Turtle:La};Object.freeze([...Object.keys(gS)]);function _S(e){if(typeof e.principalId==`string`&&e.principalId.length>0)return{kind:`initials`};let t=e.name.split(` `)[1];return t&&Object.hasOwn(gS,t)?{kind:`animal`,animal:t}:{kind:`initials`}}var vS={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`,bot:`Agent`};function yS(e){let t=(0,Q.c)(20),{user:n,mode:r,tabCount:i}=e,a=_S(n),o=a.kind===`animal`?gS[a.animal]:void 0,s;t[0]===n.name?s=t[1]:(s=Ue(n.name),t[0]=n.name,t[1]=s);let c=s,l;t[2]===n.color?l=t[3]:(l=Te(n.color),t[2]=n.color,t[3]=l);let u=l,d=i>1?`${n.name} · ${i} tabs`:n.name,f=i>1?`${n.name}, ${i} concurrent tabs`:n.name,p;t[4]===n.color?p=t[5]:(p={backgroundColor:n.color},t[4]=n.color,t[5]=p);let m;t[6]!==o||t[7]!==u||t[8]!==c?(m=o?(0,X.jsx)(o,{size:18,color:u,strokeWidth:1.5}):(0,X.jsx)(`span`,{className:`font-mono text-2xs font-semibold leading-none`,style:{color:u},children:c}),t[6]=o,t[7]=u,t[8]=c,t[9]=m):m=t[9];let h;t[10]!==f||t[11]!==r||t[12]!==p||t[13]!==m?(h=(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(`div`,{"data-presence-badge":`human`,"data-presence-mode":r,role:`img`,"aria-label":f,className:`inline-flex size-7 shrink-0 cursor-default items-center justify-center rounded-full ring-2 ring-background`,style:p,children:m})}),t[10]=f,t[11]=r,t[12]=p,t[13]=m,t[14]=h):h=t[14];let g;t[15]===d?g=t[16]:(g=(0,X.jsx)(Fr,{children:d}),t[15]=d,t[16]=g);let _;return t[17]!==h||t[18]!==g?(_=(0,X.jsxs)(Lr,{children:[h,g]}),t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function bS(e){let t=vS[e.icon];return e.displayName||t||`Agent`}function xS(e){let t=(0,Q.c)(3),[n,r]=(0,Z.useState)(e===`writing`),i=(0,Z.useRef)(null),a,o;return t[0]===e?(a=t[1],o=t[2]):(a=()=>{if(e===`writing`){i.current!==null&&(clearTimeout(i.current),i.current=null),r(!0);return}return i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>{i.current=null,r(!1)},600),()=>{i.current!==null&&(clearTimeout(i.current),i.current=null)}},o=[e],t[0]=e,t[1]=a,t[2]=o),(0,Z.useEffect)(a,o),n}function SS(e){let t=(0,Q.c)(36),{participant:n,crossDoc:r,scoped:i,onClickAgent:a}=e,{presence:o,agentId:s}=n,c;t[0]===o?c=t[1]:(c=bS(o),t[0]=o,t[1]=c);let l=c,u=xS(o.mode),d=!r&&u,f=i?`ring-primary ring-offset-2 ring-offset-background`:`ring-background`,p=d&&!i?`ring-primary/40 animate-pulse`:``,m;t[2]!==f||t[3]!==p?(m=[`inline-flex size-7 shrink-0 items-center justify-center rounded-full ring-2 cursor-pointer`,f,p].filter(Boolean),t[2]=f,t[3]=p,t[4]=m):m=t[4];let h=m.join(` `),g=r?`true`:void 0,_=i?`true`:void 0,v;t[5]!==o.mode||t[6]!==g||t[7]!==_?(v={"data-presence-badge":`agent`,"data-presence-mode":o.mode,"data-presence-crossdoc":g,"data-presence-scoped":_},t[5]=o.mode,t[6]=g,t[7]=_,t[8]=v):v=t[8];let y=v,b=r&&o.currentDoc?`Open activity panel for ${l}, editing ${o.currentDoc}`:`Open activity panel for ${l}`,x;t[9]===o.color?x=t[10]:(x={backgroundColor:o.color},t[9]=o.color,t[10]=x);let S;t[11]!==s||t[12]!==a?(S=()=>a(s),t[11]=s,t[12]=a,t[13]=S):S=t[13];let C;t[14]===o.icon?C=t[15]:(C=(0,X.jsx)(Xn,{icon:o.icon,width:16,height:16,className:`text-white`}),t[14]=o.icon,t[15]=C);let w;t[16]!==b||t[17]!==y||t[18]!==h||t[19]!==C||t[20]!==x||t[21]!==S?(w=(0,X.jsx)(`button`,{type:`button`,...y,"aria-label":b,className:h,style:x,onClick:S,children:C}),t[16]=b,t[17]=y,t[18]=h,t[19]=C,t[20]=x,t[21]=S,t[22]=w):w=t[22];let T=w,E;t[23]===T?E=t[24]:(E=(0,X.jsx)(Pr,{asChild:!0,children:T}),t[23]=T,t[24]=E);let D;t[25]===l?D=t[26]:(D=(0,X.jsx)(`span`,{className:`font-medium`,children:l}),t[25]=l,t[26]=D);let O;t[27]!==r||t[28]!==o.currentDoc?(O=r&&o.currentDoc?(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`editing [[`,o.currentDoc,`]]`]}):null,t[27]=r,t[28]=o.currentDoc,t[29]=O):O=t[29];let k;t[30]!==D||t[31]!==O?(k=(0,X.jsxs)(Fr,{className:`flex flex-col gap-0.5`,children:[D,O]}),t[30]=D,t[31]=O,t[32]=k):k=t[32];let A;return t[33]!==E||t[34]!==k?(A=(0,X.jsxs)(Lr,{children:[E,k]}),t[33]=E,t[34]=k,t[35]=A):A=t[35],A}function CS(e){let t=(0,Q.c)(18),{count:n,remainder:r,crossDoc:i,scopedAgentId:a,onClickAgent:o}=e,s=i?`true`:void 0,c=`${n} more ${i?`cross-doc `:``}${n===1?`participant`:`participants`}`,l;t[0]!==n||t[1]!==s||t[2]!==c?(l=(0,X.jsx)(Dt,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,"data-slot":`presence-overflow`,"data-presence-crossdoc":s,className:`inline-flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-full bg-muted font-medium text-muted-foreground text-xs ring-2 ring-background hover:bg-muted/80`,"aria-label":c,children:[`+`,n]})}),t[0]=n,t[1]=s,t[2]=c,t[3]=l):l=t[3];let u;if(t[4]!==i||t[5]!==o||t[6]!==r||t[7]!==a){let e;t[9]!==i||t[10]!==o||t[11]!==a?(e=e=>e.kind===`human`?(0,X.jsx)(yS,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,X.jsx)(SS,{participant:e,crossDoc:i,scoped:a===e.agentId,onClickAgent:o},e.agentId),t[9]=i,t[10]=o,t[11]=a,t[12]=e):e=t[12],u=r.map(e),t[4]=i,t[5]=o,t[6]=r,t[7]=a,t[8]=u}else u=t[8];let d;t[13]===u?d=t[14]:(d=(0,X.jsx)(kt,{align:`end`,className:`w-auto max-w-xs p-2`,children:(0,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:u})}),t[13]=u,t[14]=d);let f;return t[15]!==l||t[16]!==d?(f=(0,X.jsxs)(Jt,{children:[l,d]}),t[15]=l,t[16]=d,t[17]=f):f=t[17],f}function wS(e,t,n,r){return e.kind===`human`?(0,X.jsx)(yS,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,X.jsx)(SS,{participant:e,crossDoc:n,scoped:r===e.agentId,onClickAgent:t},e.agentId)}function TS(){let e=(0,Q.c)(20),{activeProvider:t,activeDocName:n,systemProvider:r,openActivityPanel:i,docPanelMode:a,docPanelAgentId:o}=Sn(),{current:s,crossDoc:c}=cS(t,r,n);pS(uS(t),n);let l;if(e[0]!==c||e[1]!==s||e[2]!==o||e[3]!==a||e[4]!==i){let t=s.slice(0,mS),n;e[6]===s?n=e[7]:(n=s.slice(mS),e[6]=s,e[7]=n);let r=n,u=c.slice(0,hS),d;e[8]===c?d=e[9]:(d=c.slice(hS),e[8]=c,e[9]=d);let f=d,p=i,m=a===`agent`?o:null,h;e[10]!==p||e[11]!==m?(h=e=>wS(e,p,!1,m),e[10]=p,e[11]=m,e[12]=h):h=e[12];let g=t.map(h),_;e[13]!==r||e[14]!==p||e[15]!==m?(_=r.length>0?(0,X.jsx)(CS,{count:r.length,remainder:r,crossDoc:!1,scopedAgentId:m,onClickAgent:p}):null,e[13]=r,e[14]=p,e[15]=m,e[16]=_):_=e[16];let v;e[17]!==g||e[18]!==_?(v=(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,"data-presence-section":`current`,children:[g,_]}),e[17]=g,e[18]=_,e[19]=v):v=e[19],l=(0,X.jsxs)(`div`,{"data-slot":`presence-bar`,className:`flex items-center px-1 py-1.5`,children:[v,c.length>0?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`mx-2 h-4 w-px bg-border`,"aria-hidden":!0,"data-slot":`presence-divider`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 opacity-60 grayscale`,"data-presence-section":`crossdoc`,children:[u.map(e=>wS(e,p,!0,m)),f.length>0?(0,X.jsx)(CS,{count:f.length,remainder:f,crossDoc:!0,scopedAgentId:m,onClickAgent:p}):null]})]}):null]}),e[0]=c,e[1]=s,e[2]=o,e[3]=a,e[4]=i,e[5]=l}else l=e[5];return l}function ES(e){let t=(0,Q.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,X.jsx)(`title`,{children:`LinkedIn`}),r=(0,X.jsx)(`path`,{d:`M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,X.jsxs)(`svg`,{role:`img`,fill:`currentColor`,height:24,width:24,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}function DS(e){let t=(0,Q.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,X.jsx)(`title`,{children:`X (Twitter)`}),r=(0,X.jsx)(`path`,{d:`M18.901 1.153h3.68l-8.04 9.19L24 22.846h-7.406l-5.8-7.584-6.638 7.584H.474l8.6-9.83L0 1.154h7.594l5.243 6.932ZM17.61 20.644h2.039L6.486 3.24H4.298Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,X.jsxs)(`svg`,{role:`img`,fill:`currentColor`,height:24,width:24,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}var OS=[{label:`Documentation`,href:`https://openknowledge.ai/docs`,icon:ki},{label:`Homepage`,href:`https://openknowledge.ai/`,icon:sr},{label:`Twitter / X`,href:`https://x.com/inkeep`,icon:DS},{label:`LinkedIn`,href:`https://www.linkedin.com/company/inkeep/`,icon:ES}],kS=()=>{let e=(0,Q.c)(15),[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(!1),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsxs)(Lr,{children:[(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(Dt,{asChild:!0,children:(0,X.jsxs)(J,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[(0,X.jsx)(Fi,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Help & resources`})]})})}),(0,X.jsx)(Fr,{children:`Help & resources`})]}),e[0]=a):a=e[0];let o;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,X.jsx)(`p`,{className:`font-mono tracking-wide uppercase text-muted-foreground text-xs mb-1`,children:`Setup`}),e[1]=o):o=e[1];let s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{i(!1),window.location.hash!==`#settings`&&(window.location.hash=Yu)},e[2]=s):s=e[2];let c;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,"data-testid":`help-popover-settings`,onClick:s,className:`flex w-full items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-sm text-muted-foreground transition-colors hover:bg-azure-900/5 dark:hover:bg-white/20 hover:text-primary`,children:[(0,X.jsx)(Oa,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,X.jsx)(`span`,{children:`Settings…`})]})}),e[3]=c):c=e[3];let l;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{i(!1),n(!0)},e[4]=l):l=e[4];let u,d;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,X.jsxs)(`ul`,{className:`mb-3 space-y-0.5`,children:[c,(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,onClick:l,className:`flex w-full items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-sm text-muted-foreground transition-colors hover:bg-azure-900/5 dark:hover:bg-white/20 hover:text-primary`,children:[(0,X.jsx)(er,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,X.jsx)(`span`,{children:`Install for Claude Chat & Cowork…`})]})})]}),d=(0,X.jsx)(`p`,{className:`font-mono tracking-wide uppercase text-muted-foreground text-xs mb-1`,children:`Resources`}),e[5]=u,e[6]=d):(u=e[5],d=e[6]);let f;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,X.jsxs)(kt,{align:`end`,className:`w-64 p-3`,children:[o,u,d,(0,X.jsx)(`nav`,{"aria-label":`Help and resources`,children:(0,X.jsx)(`ul`,{className:`space-y-0.5`,children:OS.map(AS)})})]}),e[7]=f):f=e[7];let p;e[8]===r?p=e[9]:(p=(0,X.jsxs)(Jt,{open:r,onOpenChange:i,children:[a,f]}),e[8]=r,e[9]=p);let m;e[10]===t?m=e[11]:(m=(0,X.jsx)(ir,{open:t,onOpenChange:n}),e[10]=t,e[11]=m);let h;return e[12]!==p||e[13]!==m?(h=(0,X.jsxs)(X.Fragment,{children:[p,m]}),e[12]=p,e[13]=m,e[14]=h):h=e[14],h};function AS(e){let{label:t,href:n,icon:r}=e;return(0,X.jsx)(`li`,{children:(0,X.jsxs)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-2.5 rounded-md px-2 py-1.5 text-sm text-muted-foreground transition-colors hover:bg-azure-900/5 dark:hover:bg-white/20 hover:text-primary`,children:[(0,X.jsx)(r,{"aria-hidden":`true`,className:`size-4 shrink-0`}),t]})},n)}var jS={"claude-cowork":`claude`,"claude-code":`claude`,codex:`openai`,cursor:`cursor`};function MS(e){let t=(0,Q.c)(23),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({id:r,style:a,className:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{resolvedTheme:o}=G(),s=jS[r],c=s?(o===`dark`?Se[s]:void 0)??Me[s]:void 0,l;t[5]!==c||t[6]!==a?(l=c?{...a,"--ok-brand-color":c}:a,t[5]=c,t[6]=a,t[7]=l):l=t[7];let u=l,d=c&&`[&_*]:![color:var(--ok-brand-color)]`,f;t[8]!==n||t[9]!==d?(f=q(d,n),t[8]=n,t[9]=d,t[10]=f):f=t[10];let p=f;if(r===`claude-cowork`||r===`claude-code`){let e;return t[11]!==p||t[12]!==u||t[13]!==i?(e=(0,X.jsx)(Hn,{style:u,className:p,...i}),t[11]=p,t[12]=u,t[13]=i,t[14]=e):e=t[14],e}if(r===`codex`){let e;return t[15]!==p||t[16]!==u||t[17]!==i?(e=(0,X.jsx)(Vn,{style:u,className:p,...i}),t[15]=p,t[16]=u,t[17]=i,t[18]=e):e=t[18],e}if(r===`cursor`){let e;return t[19]!==p||t[20]!==u||t[21]!==i?(e=(0,X.jsx)(Jn,{style:u,className:p,...i}),t[19]=p,t[20]=u,t[21]=i,t[22]=e):e=t[22],e}return null}var NS=`https://github.com/inkeep/open-knowledge/releases`;function PS(e){let{target:t,installState:n,isElectronHost:r}=e;return t.id===`cursor`&&!r?`Desktop only`:n.installed===null?`Detecting…`:n.installed===!1?`Not installed`:null}function FS(e){let{target:t,installState:n,isElectronHost:r}=e;if(t.id===`cursor`&&!r)return{enabled:!1,tooltip:{message:`Cursor handoff requires the desktop build.`,installAction:{label:`Install the Open Knowledge desktop app →`,url:NS}}};if(n.installed===null)return{enabled:!1,tooltip:null};if(n.installed===!1){let e=t.appBrandName??t.displayName;return{enabled:!1,tooltip:{message:`Requires ${e}.`,installAction:{label:`Install ${e} →`,url:t.installUrl},...t.hasWebFallback?{webFallback:{label:`Open in claude.ai →`,url:``}}:{}}}}return{enabled:!0,tooltip:null}}function IS(e){return ne(e)}function LS(e){return`Opened ${e} in your browser.`}function RS(e){let t=(0,Q.c)(73),{target:n,installState:r,isElectronHost:i,prompt:a,onSelect:o}=e,s=e.openExternal??cd,c=e.onWebFallbackSuccess??BS,l=e.onWebFallbackError??zS,u;t[0]!==r||t[1]!==i||t[2]!==n?(u=FS({target:n,installState:r,isElectronHost:i}),t[0]=r,t[1]=i,t[2]=n,t[3]=u):u=t[3];let d=u,f;t[4]!==r||t[5]!==i||t[6]!==n?(f=PS({target:n,installState:r,isElectronHost:i}),t[4]=r,t[5]=i,t[6]=n,t[7]=f):f=t[7];let p=f,m;t[8]!==s||t[9]!==d.tooltip?(m=()=>{d.tooltip&&s(d.tooltip.installAction.url)},t[8]=s,t[9]=d.tooltip,t[10]=m):m=t[10];let h=m,g;t[11]!==l||t[12]!==c||t[13]!==s||t[14]!==a||t[15]!==n?(g=()=>{(async()=>{let e=await s(IS(a));e.ok?c(n):l(n,e.detail??e.reason)})()},t[11]=l,t[12]=c,t[13]=s,t[14]=a,t[15]=n,t[16]=g):g=t[16];let _=g;if(d.enabled){let e=`open-in-agent-item-${n.id}`,r=`Open in ${n.displayName}`,i;t[17]===n.id?i=t[18]:(i=(0,X.jsx)(MS,{id:n.id,"aria-hidden":`true`}),t[17]=n.id,t[18]=i);let a;t[19]===n.displayName?a=t[20]:(a=(0,X.jsx)(`span`,{children:n.displayName}),t[19]=n.displayName,t[20]=a);let s;return t[21]!==o||t[22]!==e||t[23]!==r||t[24]!==i||t[25]!==a?(s=(0,X.jsxs)(Gv,{onSelect:o,"data-testid":e,"aria-label":r,children:[i,a]}),t[21]=o,t[22]=e,t[23]=r,t[24]=i,t[25]=a,t[26]=s):s=t[26],s}if(!d.tooltip){let e=p?`Open in ${n.displayName}, ${p}`:`Open in ${n.displayName}`,r=`open-in-agent-item-${n.id}`,i;t[27]===n.id?i=t[28]:(i=(0,X.jsx)(MS,{id:n.id,"aria-hidden":`true`}),t[27]=n.id,t[28]=i);let a;t[29]===n.displayName?a=t[30]:(a=(0,X.jsx)(`span`,{className:`flex-1`,children:n.displayName}),t[29]=n.displayName,t[30]=a);let o;t[31]===p?o=t[32]:(o=p?(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:p}):null,t[31]=p,t[32]=o);let s;return t[33]!==e||t[34]!==r||t[35]!==i||t[36]!==a||t[37]!==o?(s=(0,X.jsxs)(Gv,{disabled:!0,"data-testid":r,"aria-label":e,children:[i,a,o]}),t[33]=e,t[34]=r,t[35]=i,t[36]=a,t[37]=o,t[38]=s):s=t[38],s}let v=p?`Open in ${n.displayName}, ${p}`:`Open in ${n.displayName}`,y=`open-in-agent-item-${n.id}`,b;t[39]===n.id?b=t[40]:(b=(0,X.jsx)(MS,{id:n.id,"aria-hidden":`true`,className:`mr-2`}),t[39]=n.id,t[40]=b);let x;t[41]===n.displayName?x=t[42]:(x=(0,X.jsx)(`span`,{className:`flex-1`,children:n.displayName}),t[41]=n.displayName,t[42]=x);let S;t[43]===p?S=t[44]:(S=p?(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:p}):null,t[43]=p,t[44]=S);let C;t[45]!==v||t[46]!==y||t[47]!==b||t[48]!==x||t[49]!==S?(C=(0,X.jsxs)(Zv,{"data-testid":y,"data-row-disabled":``,"aria-label":v,children:[b,x,S]}),t[45]=v,t[46]=y,t[47]=b,t[48]=x,t[49]=S,t[50]=C):C=t[50];let w=`open-in-agent-submenu-${n.id}`,T=`open-in-agent-message-${n.id}`,E;t[51]!==d.tooltip.message||t[52]!==T?(E=(0,X.jsx)(Jv,{className:`font-normal text-muted-foreground text-xs`,"data-testid":T,children:d.tooltip.message}),t[51]=d.tooltip.message,t[52]=T,t[53]=E):E=t[53];let D;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,X.jsx)(Yv,{}),t[54]=D):D=t[54];let O=`open-in-agent-install-${n.id}`,k;t[55]===d.tooltip.installAction.label?k=t[56]:(k=(0,X.jsx)(`span`,{children:d.tooltip.installAction.label}),t[55]=d.tooltip.installAction.label,t[56]=k);let A;t[57]!==h||t[58]!==O||t[59]!==k?(A=(0,X.jsx)(Gv,{onSelect:h,"data-testid":O,children:k}),t[57]=h,t[58]=O,t[59]=k,t[60]=A):A=t[60];let j;t[61]!==_||t[62]!==d.tooltip.webFallback||t[63]!==n.id?(j=d.tooltip.webFallback?(0,X.jsxs)(Gv,{onSelect:_,"data-testid":`open-in-agent-web-fallback-${n.id}`,"aria-label":`${d.tooltip.webFallback.label}, opens in browser with prompt pre-filled`,children:[(0,X.jsx)(`span`,{className:`flex-1`,children:d.tooltip.webFallback.label}),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:`opens in browser with prompt pre-filled`})]}):null,t[61]=_,t[62]=d.tooltip.webFallback,t[63]=n.id,t[64]=j):j=t[64];let M;t[65]!==E||t[66]!==A||t[67]!==j||t[68]!==w?(M=(0,X.jsxs)(Qv,{className:`min-w-[260px]`,"data-testid":w,children:[E,D,A,j]}),t[65]=E,t[66]=A,t[67]=j,t[68]=w,t[69]=M):M=t[69];let N;return t[70]!==M||t[71]!==C?(N=(0,X.jsxs)(Xv,{children:[C,M]}),t[70]=M,t[71]=C,t[72]=N):N=t[72],N}function zS(){}function BS(){}function VS(e){let t=(0,Q.c)(25),{input:n}=e,{states:r,refresh:i}=zd(),{dispatch:a}=Od(),[o,s]=(0,Z.useState)(!1),c=typeof window<`u`&&window.okDesktop!=null,l=US,u=HS,d;t[0]===i?d=t[1]:(d=e=>{s(e),e&&i()},t[0]=i,t[1]=d);let f=d,p=n===null,m;t[2]===n?m=t[3]:(m=n===null?``:Qe(n.docContext),t[2]=n,t[3]=m);let h=m,g;t[4]!==a||t[5]!==n?(g=e=>{n!==null&&a(e.id,n)},t[4]=a,t[5]=n,t[6]=g):g=t[6];let _=g,v;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,X.jsx)(Yn,{className:`size-4`}),t[7]=v):v=t[7];let y;t[8]===p?y=t[9]:(y=(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(Uv,{asChild:!0,children:(0,X.jsx)(J,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit with AI`,disabled:p,className:`text-muted-foreground`,"data-testid":`open-in-agent-trigger`,children:v})})}),t[8]=p,t[9]=y);let b;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,X.jsx)(Fr,{children:`Edit with AI`}),t[10]=b):b=t[10];let x;t[11]===y?x=t[12]:(x=(0,X.jsxs)(Lr,{children:[y,b]}),t[11]=y,t[12]=x);let S;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,X.jsx)(Jv,{className:`font-mono font-normal tracking-wide uppercase text-muted-foreground text-xs`,children:`Open in…`}),t[13]=S):S=t[13];let C;t[14]!==_||t[15]!==h||t[16]!==r?(C=Ju.map(e=>{let t=r[e.id];return(0,X.jsx)(RS,{target:e,installState:t,isElectronHost:c,prompt:h,onSelect:()=>_(e),onWebFallbackSuccess:l,onWebFallbackError:u},e.id)}),t[14]=_,t[15]=h,t[16]=r,t[17]=C):C=t[17];let w;t[18]===C?w=t[19]:(w=(0,X.jsxs)(Wv,{align:`end`,className:`min-w-[220px]`,"data-testid":`open-in-agent-menu`,children:[S,C]}),t[18]=C,t[19]=w);let T;return t[20]!==f||t[21]!==o||t[22]!==w||t[23]!==x?(T=(0,X.jsxs)(Hv,{open:o,onOpenChange:f,children:[x,w]}),t[20]=f,t[21]=o,t[22]=w,t[23]=x,t[24]=T):T=t[24],T}function HS(e){Ar.error(`Couldn't open ${e.displayName} in your browser.`)}function US(e){Ar.success(LS(e.displayName))}var WS={fill:`none`,height:24,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,viewBox:`0 0 24 24`,width:24,xmlns:`http://www.w3.org/2000/svg`},GS=e=>{let t=(0,Q.c)(15),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]):({color:a,size:o,strokeWidth:s,absoluteStrokeWidth:n,className:c,children:r,...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=a===void 0?`currentColor`:a,u=o===void 0?24:o,d=s===void 0?2:s,f=c===void 0?``:c,p=n?Number(d)*24/Number(u):d,m;return t[8]!==r||t[9]!==f||t[10]!==l||t[11]!==i||t[12]!==u||t[13]!==p?(m=(0,X.jsx)(`svg`,{"aria-hidden":`true`,...WS,className:f,height:u,stroke:l,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:p,width:u,...i,children:r}),t[8]=r,t[9]=f,t[10]=l,t[11]=i,t[12]=u,t[13]=p,t[14]=m):m=t[14],m},KS=e=>{let t=(0,Q.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,X.jsx)(`title`,{children:`Markdown`}),r=(0,X.jsx)(`path`,{d:`M232,48H24A16,16,0,0,0,8,64V192a16,16,0,0,0,16,16H232a16,16,0,0,0,16-16V64A16,16,0,0,0,232,48Zm0,144H24V64H232V192ZM128,104v48a8,8,0,0,1-16,0V123.31L93.66,141.66a8,8,0,0,1-11.32,0L64,123.31V152a8,8,0,0,1-16,0V104a8,8,0,0,1,13.66-5.66L88,124.69l26.34-26.35A8,8,0,0,1,128,104Zm77.66,18.34a8,8,0,0,1,0,11.32l-24,24a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L168,132.69V104a8,8,0,0,1,16,0v28.69l10.34-10.35A8,8,0,0,1,205.66,122.34Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,X.jsxs)(GS,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},qS=e=>{let t=(0,Q.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,X.jsx)(`title`,{children:`Textbox`}),r=(0,X.jsx)(`path`,{d:`M112,40a8,8,0,0,0-8,8V64H24A16,16,0,0,0,8,80v96a16,16,0,0,0,16,16h80v16a8,8,0,0,0,16,0V48A8,8,0,0,0,112,40ZM24,176V80h80v96ZM248,80v96a16,16,0,0,1-16,16H144a8,8,0,0,1,0-16h88V80H144a8,8,0,0,1,0-16h88A16,16,0,0,1,248,80ZM88,112a8,8,0,0,1-8,8H72v24a8,8,0,0,1-16,0V120H48a8,8,0,0,1,0-16H80A8,8,0,0,1,88,112Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,X.jsxs)(GS,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i};function JS(e){if(!e)return`never`;let t=Date.now()-new Date(e).getTime();return t<6e4?`just now`:t<36e5?`${Math.floor(t/6e4)} min ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:new Date(e).toLocaleDateString()}async function YS(e){await fetch(`/api/sync/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({op:e})})}async function XS(e){let t=await fetch(`/api/sync/set-enabled`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})});if(!t.ok)throw Error(`set-enabled failed: HTTP ${t.status}`)}function ZS(e){let t=(0,Q.c)(9),{status:n}=e;switch(n.state){case`dormant`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Ri,{className:`size-3.5 text-muted-foreground`}),t[0]=e):e=t[0],e}case`idle`:{if(n.ahead>0||n.behind>0){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(wa,{className:`size-3.5 text-muted-foreground`}),t[1]=e):e=t[1],e}let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Ri,{className:`size-3.5 text-emerald-500`}),t[2]=e):e=t[2],e}case`fetching`:case`pulling`:case`pushing`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(wa,{className:`size-3.5 text-muted-foreground animate-spin`}),t[3]=e):e=t[3],e}case`conflict`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(R,{className:`size-3.5 text-amber-500`}),t[4]=e):e=t[4],e}case`offline`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Li,{className:`size-3.5 text-muted-foreground`}),t[5]=e):e=t[5],e}case`auth-error`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(da,{className:`size-3.5 text-destructive`}),t[6]=e):e=t[6],e}case`disabled`:{let e;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Li,{className:`size-3.5 text-muted-foreground`}),t[7]=e):e=t[7],e}default:{let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Ri,{className:`size-3.5 text-muted-foreground`}),t[8]=e):e=t[8],e}}}function QS(e){switch(e.state){case`idle`:return e.ahead>0?`↑${e.ahead}`:e.behind>0?`↓${e.behind}`:``;case`fetching`:case`pulling`:case`pushing`:return``;case`conflict`:return e.conflictCount>0?`${e.conflictCount}`:``;case`offline`:return``;case`auth-error`:return``;case`disabled`:return``;default:return``}}function $S(e){switch(e){case`dormant`:return`No git remote`;case`idle`:return`Synced`;case`fetching`:return`Fetching…`;case`pulling`:return`Pulling…`;case`pushing`:return`Pushing…`;case`conflict`:return`Conflict`;case`offline`:return`Offline`;case`auth-error`:return`Sign in required`;case`disabled`:return`Sync disabled`;default:return e}}function eC(e){switch(e){case`external-changes-pending`:return`External changes pending`;case`dirty-tree`:return`Working tree has uncommitted changes`;case`detached-head`:return`Detached HEAD — checkout a branch to resume`;case`auth-error`:return`Sign in required`;case`protected-branch`:return`Protected branch — cannot push`;default:return e}}function tC(e){return e.syncEnabled?e.state===`idle`?e.ahead>0&&e.behind>0?`${e.ahead} ahead, ${e.behind} behind`:e.ahead>0?`${e.ahead} ahead`:e.behind>0?`${e.behind} behind`:`Synced`:e.state===`conflict`&&e.conflictCount>0?`${e.conflictCount} conflict${e.conflictCount===1?``:`s`}`:$S(e.state):`Sync off`}function nC(e){let t=(0,Q.c)(72),{status:n,onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a}=e,[o,s]=(0,Z.useState)(!1),c=n.syncEnabled,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=async function(e){s(!0);try{await XS(e)}catch(t){console.error(`[sync] toggle failed`,t),Ar.error(`Failed to ${e?`enable`:`disable`} sync — try again`)}s(!1)},t[0]=l):l=t[0];let u=l,d;t[1]===n?d=t[2]:(d=(0,X.jsx)(ZS,{status:n}),t[1]=n,t[2]=d);let f;t[3]===n.state?f=t[4]:(f=$S(n.state),t[3]=n.state,t[4]=f);let p;t[5]===f?p=t[6]:(p=(0,X.jsx)(`span`,{className:`text-sm font-medium truncate`,children:f}),t[5]=f,t[6]=p);let m;t[7]!==d||t[8]!==p?(m=(0,X.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[d,p]}),t[7]=d,t[8]=p,t[9]=m):m=t[9];let h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(h=e=>void u(e),t[10]=h):h=t[10];let g=c?`Disable sync`:`Enable sync`,_;t[11]!==c||t[12]!==g||t[13]!==o?(_=(0,X.jsx)(Nn,{checked:c,disabled:o,onCheckedChange:h,"aria-label":g}),t[11]=c,t[12]=g,t[13]=o,t[14]=_):_=t[14];let v;t[15]!==m||t[16]!==_?(v=(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[m,_]}),t[15]=m,t[16]=_,t[17]=v):v=t[17];let y;t[18]===n.error?y=t[19]:(y=n.error&&(0,X.jsx)(`p`,{className:`text-xs text-destructive`,children:n.error}),t[18]=n.error,t[19]=y);let b;t[20]===n.pausedReason?b=t[21]:(b=n.pausedReason&&(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:eC(n.pausedReason)}),t[20]=n.pausedReason,t[21]=b);let x;t[22]===n.state?x=t[23]:(x=n.state===`conflict`&&(0,X.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-400`,children:`Sync paused — resolve conflicts to resume.`}),t[22]=n.state,t[23]=x);let S;t[24]!==c||t[25]!==n.lastSyncUtc||t[26]!==n.state?(S=c&&n.state!==`dormant`&&(0,X.jsxs)(`div`,{children:[`Last synced: `,JS(n.lastSyncUtc)]}),t[24]=c,t[25]=n.lastSyncUtc,t[26]=n.state,t[27]=S):S=t[27];let C;t[28]===n.ahead?C=t[29]:(C=n.ahead>0&&(0,X.jsxs)(`div`,{children:[n.ahead,` commit`,n.ahead===1?``:`s`,` ahead`]}),t[28]=n.ahead,t[29]=C);let w;t[30]===n.behind?w=t[31]:(w=n.behind>0&&(0,X.jsxs)(`div`,{children:[n.behind,` commit`,n.behind===1?``:`s`,` behind`]}),t[30]=n.behind,t[31]=w);let T;t[32]===n.conflictCount?T=t[33]:(T=n.conflictCount>0&&(0,X.jsxs)(`div`,{children:[n.conflictCount,` file`,n.conflictCount===1?``:`s`,` conflicted`]}),t[32]=n.conflictCount,t[33]=T);let E;t[34]===c?E=t[35]:(E=!c&&(0,X.jsx)(`div`,{children:`Sync is off — your edits will not sync to the remote repository.`}),t[34]=c,t[35]=E);let D;t[36]!==S||t[37]!==C||t[38]!==w||t[39]!==T||t[40]!==E?(D=(0,X.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-0.5`,children:[S,C,w,T,E]}),t[36]=S,t[37]=C,t[38]=w,t[39]=T,t[40]=E,t[41]=D):D=t[41];let O;t[42]!==a||t[43]!==n.identityUnresolved?(O=n.identityUnresolved&&a&&(0,X.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed p-2`,children:[(0,X.jsx)(Ba,{className:`size-3.5 mt-0.5 text-muted-foreground shrink-0`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5 min-w-0`,children:[(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground leading-snug`,children:`Git identity isn't set — commits use a default author. Set yours so teammates see your name.`}),(0,X.jsx)(J,{variant:`outline`,size:`xs`,className:`self-start`,onClick:a,children:`Set identity`})]})]}),t[42]=a,t[43]=n.identityUnresolved,t[44]=O):O=t[44];let k;t[45]!==c||t[46]!==n.state?(k=c&&n.state!==`dormant`&&n.state!==`disabled`&&n.state!==`auth-error`&&n.state!==`conflict`&&(0,X.jsx)(J,{variant:`outline`,size:`xs`,onClick:iC,children:`Sync now`}),t[45]=c,t[46]=n.state,t[47]=k):k=t[47];let A;t[48]!==c||t[49]!==r||t[50]!==n.state?(A=c&&n.state===`auth-error`&&(0,X.jsx)(J,{variant:`outline`,size:`xs`,onClick:r,children:`Sign in`}),t[48]=c,t[49]=r,t[50]=n.state,t[51]=A):A=t[51];let j;t[52]!==c||t[53]!==n.state?(j=c&&n.state===`offline`&&(0,X.jsx)(J,{variant:`outline`,size:`xs`,onClick:rC,children:`Retry`}),t[52]=c,t[53]=n.state,t[54]=j):j=t[54];let M;t[55]!==c||t[56]!==i||t[57]!==n.state?(M=c&&n.state===`conflict`&&i&&(0,X.jsx)(J,{variant:`outline`,size:`xs`,onClick:i,children:`Review conflicts`}),t[55]=c,t[56]=i,t[57]=n.state,t[58]=M):M=t[58];let N;t[59]!==k||t[60]!==A||t[61]!==j||t[62]!==M?(N=(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-1 pt-1`,children:[k,A,j,M]}),t[59]=k,t[60]=A,t[61]=j,t[62]=M,t[63]=N):N=t[63];let P;return t[64]!==y||t[65]!==b||t[66]!==x||t[67]!==D||t[68]!==O||t[69]!==N||t[70]!==v?(P=(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[v,y,b,x,D,O,N]}),t[64]=y,t[65]=b,t[66]=x,t[67]=D,t[68]=O,t[69]=N,t[70]=v,t[71]=P):P=t[71],P}function rC(){YS(`sync`)}function iC(){YS(`sync`)}function aC(e){let t=(0,Q.c)(36),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a}=n,{status:o,fetchError:s}=of();if(!o){if(s){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(J,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground`,"aria-label":`Sync status unavailable`,disabled:!0,children:(0,X.jsx)(Li,{className:`size-3.5`})})}),t[2]=e):e=t[2];let n=s===`network`?`Sync status unavailable — server unreachable.`:`Sync status unavailable — server error.`,r;return t[3]===n?r=t[4]:(r=(0,X.jsxs)(Lr,{children:[e,(0,X.jsx)(Fr,{children:n})]}),t[3]=n,t[4]=r),r}return null}if(o.state===`dormant`&&!o.hasRemote)return null;let c;t[5]===o?c=t[6]:(c=QS(o),t[5]=o,t[6]=c);let l=c,u=!!o.identityUnresolved,d;t[7]===o.state?d=t[8]:(d=$S(o.state),t[7]=o.state,t[8]=d);let f=`Sync status: ${d}${u?` — git identity unset`:``}`,p;t[9]===o?p=t[10]:(p=(0,X.jsx)(ZS,{status:o}),t[9]=o,t[10]=p);let m;t[11]===l?m=t[12]:(m=l&&(0,X.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 text-[9px] leading-none font-medium bg-background border rounded-full px-0.5`,children:l}),t[11]=l,t[12]=m);let h;t[13]!==l||t[14]!==u?(h=!l&&u&&(0,X.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 size-1.5 rounded-full bg-amber-500 ring-2 ring-background`,"aria-hidden":!0}),t[13]=l,t[14]=u,t[15]=h):h=t[15];let g;t[16]!==f||t[17]!==p||t[18]!==m||t[19]!==h?(g=(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(Dt,{asChild:!0,children:(0,X.jsxs)(J,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground relative`,"aria-label":f,children:[p,m,h]})})}),t[16]=f,t[17]=p,t[18]=m,t[19]=h,t[20]=g):g=t[20];let _;t[21]===o?_=t[22]:(_=tC(o),t[21]=o,t[22]=_);let v;t[23]===_?v=t[24]:(v=(0,X.jsx)(Fr,{children:_}),t[23]=_,t[24]=v);let y;t[25]!==v||t[26]!==g?(y=(0,X.jsxs)(Lr,{children:[g,v]}),t[25]=v,t[26]=g,t[27]=y):y=t[27];let b;t[28]!==i||t[29]!==a||t[30]!==r||t[31]!==o?(b=(0,X.jsx)(kt,{align:`end`,className:`w-64 p-3`,children:(0,X.jsx)(nC,{status:o,onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a})}),t[28]=i,t[29]=a,t[30]=r,t[31]=o,t[32]=b):b=t[32];let x;return t[33]!==y||t[34]!==b?(x=(0,X.jsxs)(Jt,{children:[y,b]}),t[33]=y,t[34]=b,t[35]=x):x=t[35],x}var oC=(0,Z.createContext)(null);function sC(e,t,n){let r=new $t,i=new Zt({url:e,name:t,document:r}),a=W(i,n);return{binding:a,config:a.current(),cleanup:()=>{a.dispose(),i.destroy(),r.destroy()}}}function cC(e){let t=(0,Q.c)(19),{children:n}=e,{collabUrl:r}=Sn(),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null),c,l;t[0]===r?(c=t[1],l=t[2]):(c=()=>{if(r===null)return;let e=sC(r,tt,`user`),t=sC(r,he,`workspace`);a({binding:e.binding,config:e.config}),s({binding:t.binding,config:t.config});let n=e.binding.subscribe(t=>{a(n=>n?.binding===e.binding?{...n,config:t}:n)}),i=t.binding.subscribe(e=>{s(n=>n?.binding===t.binding?{...n,config:e}:n)});return()=>{n(),i(),e.cleanup(),t.cleanup(),a(t=>t?.binding===e.binding?null:t),s(e=>e?.binding===t.binding?null:e)}},l=[r],t[0]=r,t[1]=c,t[2]=l),(0,Z.useEffect)(c,l);let u;t[3]!==i||t[4]!==o?(u=i&&o?uC(i.config,o.config):null,t[3]=i,t[4]=o,t[5]=u):u=t[5];let d=u,{setTheme:f}=G(),p=d?.appearance?.theme,m,h;t[6]!==f||t[7]!==p?(m=()=>{(p===`light`||p===`dark`||p===`system`)&&f(p)},h=[p,f],t[6]=f,t[7]=p,t[8]=m,t[9]=h):(m=t[8],h=t[9]),(0,Z.useEffect)(m,h);let g=i?.binding??null,_=o?.binding??null,v=i?.config??null,y=o?.config??null,b;t[10]!==d||t[11]!==g||t[12]!==_||t[13]!==v||t[14]!==y?(b={userBinding:g,workspaceBinding:_,userConfig:v,workspaceConfig:y,merged:d},t[10]=d,t[11]=g,t[12]=_,t[13]=v,t[14]=y,t[15]=b):b=t[15];let x=b,S;return t[16]!==n||t[17]!==x?(S=(0,X.jsx)(oC,{value:x,children:n}),t[16]=n,t[17]=x,t[18]=S):S=t[18],S}function lC(){let e=(0,Z.use)(oC);if(e===null)throw Error(`useConfigContext must be used within <ConfigProvider />`);return e}function uC(e,t){return dC(e,t,[])}function dC(e,t,n){if(n.length>0){let r=je(pe,n);if(r?.scope===`user`)return e;if(r?.scope===`workspace`)return t??e}if(t===void 0)return e;if(t===null)return null;if(Array.isArray(t)||typeof t!=`object`||typeof e!=`object`||!e||Array.isArray(e))return t;let r={...e};for(let[i,a]of Object.entries(t))r[i]=dC(e[i],a,[...n,i]);return r}var fC=[{value:`light`,label:`Light`,icon:Fa},{value:`dark`,label:`Dark`,icon:fa},{value:`system`,label:`System`,icon:Hi}],pC=()=>{let e=(0,Q.c)(16),{theme:t}=G(),{merged:n,userBinding:r}=lC(),i=n?.appearance?.theme??t??`system`,a;e[0]===r?a=e[1]:(a=e=>{if(e!==`light`&&e!==`dark`&&e!==`system`||!r)return;let t=r.patch({appearance:{theme:e}});t.ok||Ar.error(Ne(t.error))},e[0]=r,e[1]=a);let o=a,s=i===`system`?Hi:i===`dark`?fa:Fa,c;e[2]===s?c=e[3]:(c=(0,X.jsx)(s,{}),e[2]=s,e[3]=c);let l;e[4]===i?l=e[5]:(l=(0,X.jsxs)(`span`,{className:`sr-only`,children:[`Toggle theme (current: `,i,`)`]}),e[4]=i,e[5]=l);let u;e[6]!==c||e[7]!==l?(u=(0,X.jsx)(Uv,{asChild:!0,children:(0,X.jsxs)(J,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[c,l]})}),e[6]=c,e[7]=l,e[8]=u):u=e[8];let d;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=fC.map(mC),e[9]=d):d=e[9];let f;e[10]!==i||e[11]!==o?(f=(0,X.jsx)(Wv,{align:`end`,children:(0,X.jsx)(Kv,{value:i,onValueChange:o,children:d})}),e[10]=i,e[11]=o,e[12]=f):f=e[12];let p;return e[13]!==u||e[14]!==f?(p=(0,X.jsxs)(Hv,{children:[u,f]}),e[13]=u,e[14]=f,e[15]=p):p=e[15],p};function mC(e){let{value:t,label:n,icon:r}=e;return(0,X.jsxs)(qv,{value:t,className:`capitalize`,children:[(0,X.jsx)(r,{className:`text-muted-foreground`}),n]},t)}function hC(e){return typeof e==`object`&&!!e&&typeof e.fromDocName==`string`&&typeof e.toDocName==`string`}function gC(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.ok===!0?Array.isArray(t.renamed)&&t.renamed.every(hC)&&Array.isArray(t.rewrittenDocs):t.ok===!1?typeof t.error==`string`:!1}function _C(e){let t=(0,Q.c)(91),{editorMode:n,onModeChange:r,onSaveVersion:i,saving:a,onSignIn:o,onSetIdentity:s,onOpenConflictResolver:c,onOpenClone:l}=e,{activeDocName:u,activeProvider:d,activeTarget:f,closeDocument:p,pinnedDoc:m,pin:h,unpin:g}=Sn(),{pageMeta:_}=Pe(),{state:v}=Ux(),y=rd(),b=uS(d),x;t[0]!==u||t[1]!==y?(x=yd({docName:u,workspace:y}),t[0]=u,t[1]=y,t[2]=x):x=t[2];let S=x,C=!u||!(b===`connected`||b===`synced`),w=f?.kind===`folder`,T=f?.kind===`missing`,E;t[3]!==u||t[4]!==_?(E=u&&_.get(u)?.docExt||`.md`,t[3]=u,t[4]=_,t[5]=E):E=t[5];let D=E,O=w?`${f.folderPath}/`:u?`${u}${D}`:``,k;t[6]===u?k=t[7]:(k=u?.lastIndexOf(`/`)??-1,t[6]=u,t[7]=k);let A=k,j;t[8]!==u||t[9]!==A?(j=u&&A!==-1?`${u.substring(0,A+1)}`:``,t[8]=u,t[9]=A,t[10]=j):j=t[10];let M=j,N;t[11]!==u||t[12]!==A?(N=u?u.substring(A+1):``,t[11]=u,t[12]=A,t[13]=N):N=t[13];let P=N,F=m!==null,I;t[14]!==u||t[15]!==F||t[16]!==h||t[17]!==g?(I=function(){u&&(F?g():h(u))},t[14]=u,t[15]=F,t[16]=h,t[17]=g,t[18]=I):I=t[18];let L=I,[R,z]=(0,Z.useState)(!1),[B,V]=(0,Z.useState)(``),[H,U]=(0,Z.useState)(null),[W,G]=(0,Z.useState)(!1),ee=(0,Z.useRef)(null),K=(0,Z.useRef)(!1),te=(0,Z.useRef)(!1),ne=(0,Z.useRef)(null),re=(0,Z.useRef)(null),ie;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(ie=()=>{te.current=!0,ne.current=null,re.current=null,z(!1),U(null)},t[19]=ie):ie=t[19];let ae;t[20]===u?ae=t[21]:(ae=[u],t[20]=u,t[21]=ae),(0,Z.useEffect)(ie,ae);let oe,se;t[22]===R?(oe=t[23],se=t[24]):(se=()=>{if(R){let e=setTimeout(()=>{let e=ee.current;e&&(e.focus(),e.select())},0);return()=>clearTimeout(e)}},oe=[R],t[22]=R,t[23]=oe,t[24]=se),(0,Z.useEffect)(se,oe);let ce;t[25]!==u||t[26]!==w?(ce=function(){if(!u||w)return;let e=u.split(`/`);te.current=!1,ne.current=u,V(e[e.length-1]),U(null),re.current=null,z(!0)},t[25]=u,t[26]=w,t[27]=ce):ce=t[27];let le=ce,ue;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(ue=function(){te.current=!0,ne.current=null,re.current=null,z(!1),V(``),U(null)},t[28]=ue):ue=t[28];let de=ue,fe;t[29]!==p||t[30]!==B?(fe=async function(){if(te.current){te.current=!1;return}if(K.current)return;let e=ne.current;if(!e){de();return}let t=gx(`file`,B),n=e.split(`/`),r=n[n.length-1];if(t===r){de();return}if(t===re.current)return;if(!_x(t)){U(`Name can’t be empty, ".", "..", or contain / or \\`);return}let i=vx({kind:`file`,path:e,name:r},t);K.current=!0,G(!0),U(null);try{let n=await fetch(`/api/rename`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({docName:e,newDocName:i})});if(te.current){G(!1),K.current=!1;return}let r;try{r=await n.json()}catch(r){console.warn(`[EditorHeader] rename response JSON parse failed`,{parseErr:r,status:n.status,docName:e,newDocName:i}),U(`Server error (HTTP ${n.status})`),G(!1),K.current=!1,re.current=t;return}if(!n.ok||!gC(r)){let a=r;console.warn(`[EditorHeader] rename failed`,{status:n.status,docName:e,newDocName:i}),U(a?.error||`Server error (HTTP ${n.status})`),G(!1),K.current=!1,re.current=t;return}if(!r.ok){U(r.error||`Failed to rename path`),G(!1),K.current=!1,re.current=t;return}let a=r.renamed,o=xx(e,a);for(let e of a)p(e.fromDocName);we([`files`,`backlinks`,`graph`]),z(!1),V(``),G(!1),K.current=!1,re.current=null,ne.current=null,o&&o!==e&&(window.location.hash=$e(o))}catch(n){console.warn(`[EditorHeader] rename failed`,{err:n,docName:e,newDocName:i,normalized:t}),U(`Network error — please try again`),G(!1),K.current=!1,re.current=t}},t[29]=p,t[30]=B,t[31]=fe):fe=t[31];let pe=fe,me;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(Jx,{className:`-ml-1 shrink-0 text-muted-foreground`})}),t[32]=me):me=t[32];let he=v===`expanded`?`Hide Files`:`Show Files`,ge;t[33]===he?ge=t[34]:(ge=(0,X.jsxs)(Lr,{children:[me,(0,X.jsx)(Fr,{children:he})]}),t[33]=he,t[34]=ge);let _e;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,X.jsx)(lv,{orientation:`vertical`,className:`mr-1 h-4 shrink-0 data-vertical:self-center`}),t[35]=_e):_e=t[35];let ve;t[36]!==D||t[37]!==u||t[38]!==pe||t[39]!==O||t[40]!==le||t[41]!==P||t[42]!==w||t[43]!==W||t[44]!==R||t[45]!==M||t[46]!==H||t[47]!==B?(ve=w?(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 text-sm text-muted-foreground`,children:[(0,X.jsx)(Ot,{className:`size-4 shrink-0`}),(0,X.jsx)(`span`,{className:`truncate`,children:O})]}):u?(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center overflow-hidden`,children:[M&&(0,X.jsxs)(`span`,{className:`flex shrink items-center overflow-hidden text-sm text-muted-foreground/60 transition-[max-width,opacity] duration-200 ease-in-out`,style:R?{maxWidth:0,opacity:0}:{maxWidth:`20rem`,opacity:1},children:[(0,X.jsx)(`span`,{className:`truncate`,children:M.slice(0,-1)}),(0,X.jsx)(`span`,{className:`shrink-0 pl-2`,children:`/`})]}),R?(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(zt,{ref:ee,value:B,disabled:W,"aria-label":`Rename ${u}`,"aria-invalid":H?!0:void 0,"aria-describedby":H?`editor-header-rename-error`:void 0,"aria-busy":W||void 0,onChange:e=>{V(e.target.value),U(null),re.current=null},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),pe()):e.key===`Escape`&&(e.preventDefault(),de())},onBlur:()=>void pe(),className:`h-7 min-w-0 flex-1 border-none bg-background text-sm shadow-none focus-visible:ring-0`}),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-xs text-muted-foreground/40`,children:D})]}),H&&(0,X.jsx)(`span`,{id:`editor-header-rename-error`,role:`alert`,className:`text-xs text-destructive mt-0.5`,children:H})]}):(0,X.jsx)(J,{variant:`ghost`,size:`sm`,onClick:le,className:`h-7 shrink-0 px-2 text-sm font-normal text-muted-foreground hover:text-foreground`,children:`${P}${D}`})]}):(0,X.jsx)(`span`,{className:`text-sm text-muted-foreground truncate min-w-0`,children:O}),t[36]=D,t[37]=u,t[38]=pe,t[39]=O,t[40]=le,t[41]=P,t[42]=w,t[43]=W,t[44]=R,t[45]=M,t[46]=H,t[47]=B,t[48]=ve):ve=t[48];let ye;t[49]!==u||t[50]!==F||t[51]!==L?(ye=u&&(0,X.jsxs)(Lr,{children:[(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 shrink-0 text-muted-foreground`,onClick:L,"aria-label":F?`Unpin — resume following agent`:`Pin this doc — stop following agent`,"aria-pressed":F,"data-pinned":F?`true`:`false`,children:F?(0,X.jsx)(ba,{className:`size-4 text-foreground`,fill:`currentColor`}):(0,X.jsx)(ya,{className:`size-4`})})}),(0,X.jsx)(Fr,{children:F?`Pinned — click to resume following agent navigation`:`Pin to stay on this doc — browser won’t auto-navigate to the agent’s current focus`})]}),t[49]=u,t[50]=F,t[51]=L,t[52]=ye):ye=t[52];let be;t[53]===T?be=t[54]:(be=T&&(0,X.jsx)(xn,{variant:`dashed`,children:`New file`}),t[53]=T,t[54]=be);let xe;t[55]!==ge||t[56]!==ve||t[57]!==ye||t[58]!==be?(xe=(0,X.jsxs)(`div`,{className:`flex flex-1 items-center gap-1 px-3 min-w-0`,children:[ge,_e,ve,ye,be]}),t[55]=ge,t[56]=ve,t[57]=ye,t[58]=be,t[59]=xe):xe=t[59];let Se;t[60]!==u||t[61]!==n||t[62]!==r||t[63]!==C?(Se=u&&(0,X.jsxs)(Xe,{type:`single`,value:n===`source`?`source`:`visual`,onValueChange:e=>{e&&r(e===`source`?`source`:`wysiwyg`)},"aria-label":`Editor mode`,variant:`segmented`,size:`sm`,spacing:1,className:`bg-muted dark:bg-background p-0.5 rounded-lg shrink-0`,disabled:!u,children:[(0,X.jsxs)(Lr,{children:[(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(`span`,{children:(0,X.jsxs)(He,{value:`visual`,"aria-label":`Visual editor`,className:`gap-1.5 text-xs`,children:[(0,X.jsx)(qS,{className:`size-4 text-muted-foreground`}),(0,X.jsx)(`span`,{className:`hidden md:inline`,children:`Visual`})]})})}),(0,X.jsx)(Fr,{className:`md:hidden`,children:`Visual`})]}),(0,X.jsxs)(Lr,{children:[(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(`span`,{tabIndex:C?0:void 0,children:(0,X.jsxs)(He,{value:`source`,"aria-label":`Markdown source`,className:`gap-1.5 text-xs`,disabled:C,children:[(0,X.jsx)(KS,{className:`size-4 text-muted-foreground`}),(0,X.jsx)(`span`,{className:`hidden md:inline`,children:`Markdown`})]})})}),C&&!u?null:C?(0,X.jsx)(Fr,{children:`Source mode requires a live connection — your edits are saved and will appear when you reconnect.`}):(0,X.jsx)(Fr,{className:`md:hidden`,children:`Markdown`})]})]}),t[60]=u,t[61]=n,t[62]=r,t[63]=C,t[64]=Se):Se=t[64];let Ce;t[65]===l?Ce=t[66]:(Ce=l&&(0,X.jsxs)(Lr,{children:[(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(J,{variant:`ghost`,size:`icon-sm`,"aria-label":`Clone from GitHub`,onClick:l,className:`text-muted-foreground`,children:(0,X.jsx)(ta,{className:`size-3.5`})})}),(0,X.jsx)(Fr,{children:`Clone from GitHub…`})]}),t[65]=l,t[66]=Ce);let Te;t[67]!==u||t[68]!==i||t[69]!==a?(Te=u&&(0,X.jsxs)(Lr,{children:[(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(J,{variant:`ghost`,size:`icon-sm`,"aria-label":`Checkpoint version`,onClick:i,disabled:a,className:`text-muted-foreground`,children:(0,X.jsx)(Ea,{className:`size-3.5`})})}),(0,X.jsx)(Fr,{children:a?`Saving…`:`Checkpoint version`})]}),t[67]=u,t[68]=i,t[69]=a,t[70]=Te):Te=t[70];let Ee;t[71]!==u||t[72]!==S?(Ee=u&&(0,X.jsx)(VS,{input:S}),t[71]=u,t[72]=S,t[73]=Ee):Ee=t[73];let De;t[74]!==c||t[75]!==s||t[76]!==o?(De=(0,X.jsx)(aC,{onSignIn:o,onSetIdentity:s,onOpenConflictResolver:c}),t[74]=c,t[75]=s,t[76]=o,t[77]=De):De=t[77];let Oe,ke,Ae,je;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,X.jsx)(TS,{}),ke=(0,X.jsx)(lv,{orientation:`vertical`,className:`h-4 shrink-0 data-vertical:self-center`}),Ae=(0,X.jsx)(kS,{}),je=(0,X.jsx)(pC,{}),t[78]=Oe,t[79]=ke,t[80]=Ae,t[81]=je):(Oe=t[78],ke=t[79],Ae=t[80],je=t[81]);let Me;t[82]!==Ce||t[83]!==Te||t[84]!==Ee||t[85]!==De?(Me=(0,X.jsxs)(`div`,{className:`flex flex-1 items-center justify-end gap-2 px-3`,children:[Ce,Te,Ee,De,Oe,ke,Ae,je]}),t[82]=Ce,t[83]=Te,t[84]=Ee,t[85]=De,t[86]=Me):Me=t[86];let Ne;return t[87]!==xe||t[88]!==Se||t[89]!==Me?(Ne=(0,X.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center border-b`,children:[xe,Se,Me]}),t[87]=xe,t[88]=Se,t[89]=Me,t[90]=Ne):Ne=t[90],Ne}function vC(){let e=(0,Q.c)(41),[t,n]=nf(),[r,i]=(0,Z.useState)(t),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(`auth`),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(Nh[0].id),[_,v]=(0,Z.useState)(!1),y=(0,Z.useRef)(!1),b=af(),{activeDocName:x}=Sn(),S,C;e[0]===x?(S=e[1],C=e[2]):(S=()=>{let e=function(e){let t=e.detail;t&&x&&ai(x,{kind:`raw-mdx`,detail:t}),i(`source`)};return window.addEventListener(Jd,e),()=>window.removeEventListener(Jd,e)},C=[x],e[0]=x,e[1]=S,e[2]=C),(0,Z.useEffect)(S,C);let w;e[3]===b?w=e[4]:(w=()=>{!y.current&&b?.state===`dormant`&&b.hasRemote&&(y.current=!0,Ar.info(`This project has a GitHub remote.`,{description:`Sign in to enable automatic sync with your team.`,duration:8e3,action:{label:`Sign in`,onClick:()=>c(!0)}}))},e[3]=b,e[4]=w);let T=b?.state,E=b?.hasRemote,D;e[5]!==T||e[6]!==E?(D=[T,E],e[5]=T,e[6]=E,e[7]=D):D=e[7],(0,Z.useEffect)(w,D);let O;e[8]===n?O=e[9]:(O=function(e){i(e),n(e)},e[8]=n,e[9]=O);let k=O,A;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(A=async function(){v(!0);try{let e=await fetch(`/api/save-version`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})});e.ok?Ar.success(`Checkpoint saved`):(console.error(`[save-version] failed:`,await e.text()),Ar.error(`Checkpoint failed — try again`))}catch(e){console.error(`[save-version] failed:`,e),Ar.error(`Checkpoint failed — try again`)}v(!1)},e[10]=A):A=e[10];let j=A,M;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,X.jsx)(yf,{onOpenResolver:()=>o(!0)}),e[11]=M):M=e[11];let N,P,F,I;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>{u(`auth`),c(!0)},N=()=>{u(`identity`),c(!0)},P=()=>o(!0),F=()=>f(!0),e[12]=N,e[13]=P,e[14]=F,e[15]=I):(N=e[12],P=e[13],F=e[14],I=e[15]);let L;e[16]!==r||e[17]!==k||e[18]!==_?(L=(0,X.jsx)(_C,{editorMode:r,onModeChange:k,onSaveVersion:j,saving:_,onSignIn:I,onSetIdentity:N,onOpenConflictResolver:P,onOpenClone:F}),e[16]=r,e[17]=k,e[18]=_,e[19]=L):L=e[19];let R;e[20]!==h||e[21]!==r?(R=(0,X.jsx)(px,{editorMode:r,activeTab:h,onActiveTabChange:g}),e[20]=h,e[21]=r,e[22]=R):R=e[22];let z;e[23]===a?z=e[24]:(z=(0,X.jsx)(xm,{open:a,onOpenChange:o}),e[23]=a,e[24]=z);let B;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>{c(e),e||m(!1)},e[25]=B):B=e[25];let V=l===`identity`,H;e[26]===p?H=e[27]:(H=()=>{c(!1),p&&(m(!1),f(!0))},e[26]=p,e[27]=H);let U;e[28]!==s||e[29]!==V||e[30]!==H?(U=(0,X.jsx)(pf,{open:s,onOpenChange:B,identityPrompt:V,onSuccess:H}),e[28]=s,e[29]=V,e[30]=H,e[31]=U):U=e[31];let W;e[32]===Symbol.for(`react.memo_cache_sentinel`)?(W=()=>{f(!1),u(`auth`),m(!0),c(!0)},e[32]=W):W=e[32];let G;e[33]===d?G=e[34]:(G=(0,X.jsx)(_f,{open:d,onOpenChange:f,onSignIn:W}),e[33]=d,e[34]=G);let ee;return e[35]!==L||e[36]!==R||e[37]!==z||e[38]!==U||e[39]!==G?(ee=(0,X.jsxs)(X.Fragment,{children:[M,L,R,z,U,G]}),e[35]=L,e[36]=R,e[37]=z,e[38]=U,e[39]=G,e[40]=ee):ee=e[40],ee}var yC=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
28
+ `);return t?n.pop():n.push(n.pop().slice(0,-1)),n}function th(e,t){return`${e}\u0000${t}`}function nh(e,t,n){let r=ue(e).body,i=ue(t).body;return r===i?``:$m(n,r,i,``,``,{context:3})}function rh(e,t,n){let r=(0,Q.c)(8),{activeProvider:i}=Sn(),a;r[0]===Symbol.for(`react.memo_cache_sentinel`)?(a={status:`idle`,diff:null},r[0]=a):a=r[0];let[o,s]=(0,Z.useState)(a),c=(0,Z.useRef)(i),l;r[1]===i?l=r[2]:(l=()=>{c.current=i},r[1]=i,r[2]=l),(0,Z.useEffect)(l);let u,d;return r[3]!==n||r[4]!==t||r[5]!==e?(u=()=>{if(!e){s({status:`idle`,diff:null});return}let r=e,i=!1;return s({status:`loading`,diff:null}),(async function(){try{let e=th(t,r),a=n.get(e);if(a===void 0){let o=await fetch(`/api/history/${r}?docName=${encodeURIComponent(t)}`);if(i)return;if(!o.ok){s({status:`error`,diff:null});return}let c=await o.json();if(i)return;a=c.content??``,n.set(e,a)}if(i)return;let o=c.current?.document.getText(`source`).toString()??``,l=nh(a,o,t);if(i)return;s({status:`ready`,diff:l})}catch(e){i||(console.error(`[timeline-diff] failed to load entry diff`,{sha:r,docName:t,err:e}),s({status:`error`,diff:null}))}})(),()=>{i=!0}},d=[e,t,n],r[3]=n,r[4]=t,r[5]=e,r[6]=u,r[7]=d):(u=r[6],d=r[7]),(0,Z.useEffect)(u,d),o}var ih=(0,Z.lazy)(async()=>({default:(await n(()=>import(`./ActivityPanelDiffView-C1vRNF09.js`),__vite__mapDeps([9,1,6,10]),import.meta.url)).ActivityPanelDiffView}));function ah(e){let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/1e3);if(r<60)return`just now`;if(r<3600)return`${Math.floor(r/60)} min ago`;if(r<86400)return`${Math.floor(r/3600)}h ago`;if(r<86400*2)return`yesterday`;let i=Math.floor(r/86400);return i<7?`${i} days ago`:t.toLocaleDateString()}function oh(e){return new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function sh(e){return e.slice(0,7)}function ch(e){return e.type===`upstream`?`Upstream sync`:e.contributors.length===1?e.contributors[0].name:e.contributors.length>1?e.contributors.map(e=>e.name).join(`, `):e.author===`openknowledge-server`||e.author===`server`?`Auto-save`:e.author}function lh(e){let t=(0,Q.c)(17),n,r;if(t[0]===e?(n=t[1],r=t[2]):({icon:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),n===`claude`){let e;return t[3]===r?e=t[4]:(e=(0,X.jsx)(Hn,{...r}),t[3]=r,t[4]=e),e}if(n===`cursor`){let e;return t[5]===r?e=t[6]:(e=(0,X.jsx)(Jn,{...r}),t[5]=r,t[6]=e),e}if(n===`windsurf`){let e;return t[7]===r?e=t[8]:(e=(0,X.jsx)(Bn,{...r}),t[7]=r,t[8]=e),e}if(n===`openai`){let e;return t[9]===r?e=t[10]:(e=(0,X.jsx)(Gn,{...r}),t[9]=r,t[10]=e),e}if(n===`cline`){let e;return t[11]===r?e=t[12]:(e=(0,X.jsx)($n,{...r}),t[11]=r,t[12]=e),e}if(n===`github`){let e;return t[13]===r?e=t[14]:(e=(0,X.jsx)(Zn,{...r}),t[13]=r,t[14]=e),e}let i=r,a;return t[15]===i?a=t[16]:(a=(0,X.jsx)(Yn,{strokeWidth:1.5,...i}),t[15]=i,t[16]=a),a}function uh(e){let t=(0,Q.c)(17),{entry:n,isDark:r}=e;if(n.type===`upstream`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(ea,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[0]=e):e=t[0],e}if(n.contributors.length>0){let e=n.contributors[0],i=e.colorSeed??e.name,a;t[1]===i?a=t[2]:(a=Ce(i),t[1]=i,t[2]=a);let o=a,s=r?Se[o]??Me[o]:Me[o],c;t[3]!==s||t[4]!==i?(c=s??ke(i),t[3]=s,t[4]=i,t[5]=c):c=t[5];let l=c;if(o!==`bot`){let e;t[6]===l?e=t[7]:(e={color:l},t[6]=l,t[7]=e);let n;return t[8]!==o||t[9]!==e?(n=(0,X.jsx)(lh,{icon:o,width:14,height:14,className:`shrink-0`,style:e}),t[8]=o,t[9]=e,t[10]=n):n=t[10],n}if(e.name===`File System`){let e;return t[11]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(ra,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[11]=e):e=t[11],e}if(e.name===`Open Knowledge (service)`||e.name===`Git (upstream)`){let e;return t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Ti,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[12]=e):e=t[12],e}let u;return t[13]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,X.jsx)(Va,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[13]=u):u=t[13],u}if(n.authorEmail.includes(`agent`)||n.author.includes(`agent`)||n.authorEmail.includes(`cursor`)||n.authorEmail.includes(`claude`)){let e;return t[14]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Yn,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[14]=e):e=t[14],e}if(n.author===`openknowledge-server`||n.author===`server`){let e;return t[15]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Ti,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[15]=e):e=t[15],e}let i;return t[16]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,X.jsx)(Va,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[16]=i):i=t[16],i}function dh(e){let t=(0,Q.c)(20),{entries:n,defaultExpanded:r,isDark:i,diffLayout:a,cache:o,docName:s,expandedShas:c,onToggleExpanded:l,onRestoreSuccess:u}=e,[d,f]=(0,Z.useState)(r);if(n.length===0)return null;let p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>f(fh),t[0]=p):p=t[0];let m;t[1]===d?m=t[2]:(m=d?(0,X.jsx)(Rt,{className:`size-3`}):(0,X.jsx)(gn,{className:`size-3`}),t[1]=d,t[2]=m);let h=d?`Hide ${n.length} auto-save${n.length>1?`s`:``}`:`Show ${n.length} auto-save${n.length>1?`s`:``}`,g;t[3]!==d||t[4]!==m||t[5]!==h?(g=(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":d,className:`flex items-center gap-1.5 rounded-lg px-3 py-2 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors text-left`,onClick:p,children:[m,h]}),t[3]=d,t[4]=m,t[5]=h,t[6]=g):g=t[6];let _;t[7]!==o||t[8]!==a||t[9]!==s||t[10]!==n||t[11]!==d||t[12]!==c||t[13]!==i||t[14]!==u||t[15]!==l?(_=d&&n.map(e=>(0,X.jsx)(Eh,{entry:e,isDark:i,diffLayout:a,cache:o,docName:s,expanded:c.has(e.sha),onToggleExpanded:l,onRestoreSuccess:u},e.sha)),t[7]=o,t[8]=a,t[9]=s,t[10]=n,t[11]=d,t[12]=c,t[13]=i,t[14]=u,t[15]=l,t[16]=_):_=t[16];let v;return t[17]!==g||t[18]!==_?(v=(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[g,_]}),t[17]=g,t[18]=_,t[19]=v):v=t[19],v}function fh(e){return!e}function ph(e){return e.checkpoint?e.checkpoint.kind:`save`}function mh(e){let t=ph(e);if(t===`save`)return`Save Version`;let n=e.checkpoint?.size??null,r=n!=null&&n>0?` (${hh(n)})`:``;return t===`bridge-merge-loss`?`Auto-saved before a concurrent edit${r}`:`Recovered from an external change${r}`}function hh(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/102.4)/10} KB`:`${Math.round(e/104857.6)/10} MB`}function gh(e){return e.type===`checkpoint`?ph(e)===`save`?`version`:`auto-save`:`wip`}var _h={version:`Restore this version`,"auto-save":`Restore this auto-save`,wip:`Restore to this point`},vh={version:`Restore this version?`,"auto-save":`Restore this auto-save?`,wip:`Restore to this point?`};function yh(e){return _h[gh(e)]}function bh(e){return vh[gh(e)]}function xh(e){let t=[];for(let n of e.contributors)if(n.summaries)for(let e of n.summaries)t.push(e);return t}function Sh(e){let t=(0,Q.c)(20),{summaries:n}=e,[r,i]=(0,Z.useState)(!1),a=(0,Z.useId)();if(n.length===0)return null;let o,s;t[0]===n?(o=t[1],s=t[2]):([o,...s]=n,t[0]=n,t[1]=o,t[2]=s);let c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,X.jsx)(`span`,{"aria-hidden":`true`,children:`• `}),t[3]=c):c=t[3];let l;t[4]===o?l=t[5]:(l=(0,X.jsxs)(`li`,{className:`text-xs text-foreground/90`,children:[c,o]}),t[4]=o,t[5]=l);let u;t[6]!==r||t[7]!==s?(u=r&&s.map(wh),t[6]=r,t[7]=s,t[8]=u):u=t[8];let d;t[9]!==a||t[10]!==l||t[11]!==u?(d=(0,X.jsxs)(`ul`,{id:a,className:`list-none`,children:[l,u]}),t[9]=a,t[10]=l,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==r||t[14]!==a||t[15]!==s.length?(f=s.length>0&&(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":r,"aria-controls":a,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,onClick:e=>{e.stopPropagation(),i(Ch)},children:[r?(0,X.jsx)(Rt,{className:`size-3`}):(0,X.jsx)(gn,{className:`size-3`}),r?`Hide ${s.length} more`:`Show ${s.length} more`]}),t[13]=r,t[14]=a,t[15]=s.length,t[16]=f):f=t[16];let p;return t[17]!==d||t[18]!==f?(p=(0,X.jsxs)(`div`,{className:`mt-0.5`,children:[d,f]}),t[17]=d,t[18]=f,t[19]=p):p=t[19],p}function Ch(e){return!e}function wh(e,t){return(0,X.jsxs)(`li`,{className:`text-xs text-foreground/90`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,children:`• `}),e]},`${t}-${e}`)}function Th(e){let t=(0,Q.c)(13),{sha:n,docName:r,cache:i,diffLayout:a,panelId:o}=e,s=rh(n,r,i),c;t[0]===s.status?c=t[1]:(c=s.status===`loading`&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-xs text-muted-foreground`,children:[(0,X.jsx)(Rn,{className:`size-3 animate-spin`}),`Loading diff…`]}),t[0]=s.status,t[1]=c);let l;t[2]===s.status?l=t[3]:(l=s.status===`error`&&(0,X.jsx)(`p`,{className:`py-2 text-xs text-destructive`,children:`Diff unavailable`}),t[2]=s.status,t[3]=l);let u;t[4]!==a||t[5]!==s.diff||t[6]!==s.status?(u=s.status===`ready`&&(0,X.jsx)(Z.Suspense,{fallback:(0,X.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-xs text-muted-foreground`,children:[(0,X.jsx)(Rn,{className:`size-3 animate-spin`}),`Loading diff renderer…`]}),children:(0,X.jsx)(ih,{diff:s.diff,viewType:a})}),t[4]=a,t[5]=s.diff,t[6]=s.status,t[7]=u):u=t[7];let d;return t[8]!==o||t[9]!==c||t[10]!==l||t[11]!==u?(d=(0,X.jsxs)(`div`,{id:o,className:`px-3 pb-2`,"data-testid":`timeline-entry-diff`,children:[c,l,u]}),t[8]=o,t[9]=c,t[10]=l,t[11]=u,t[12]=d):d=t[12],d}function Eh(e){let t=(0,Q.c)(128),{entry:n,prominent:r,isDark:i,diffLayout:a,cache:o,docName:s,expanded:c,onToggleExpanded:l,onRestoreSuccess:u}=e,d=r===void 0?!1:r,f;t[0]===n.timestamp?f=t[1]:(f=ah(n.timestamp),t[0]=n.timestamp,t[1]=f);let p=f,m;t[2]===n?m=t[3]:(m=ch(n),t[2]=n,t[3]=m);let h=m,g=n.contributors.flatMap(Dh),_;t[4]===n?_=t[5]:(_=xh(n),t[4]=n,t[5]=_);let v=_,[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(!1),C=(0,Z.useRef)(null),w=(0,Z.useId)(),T,E;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>()=>C.current?.abort(),E=[],t[6]=T,t[7]=E):(T=t[6],E=t[7]),(0,Z.useEffect)(T,E);let D;t[8]!==n.sha||t[9]!==l?(D=()=>l(n.sha),t[8]=n.sha,t[9]=l,t[10]=D):D=t[10];let O=D,k;t[11]===b?k=t[12]:(k=function(){C.current?.abort(),C.current=null,S(!1),b(!1)},t[11]=b,t[12]=k);let A=k,j;t[13]!==s||t[14]!==n.sha||t[15]!==u||t[16]!==b?(j=async function(){S(!0);let e=new AbortController;C.current=e;let t=function(){e.signal.aborted||S(!1),C.current===e&&(C.current=null)},r;try{r=await fetch(`/api/rollback`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({docName:s,commitSha:n.sha}),signal:e.signal})}catch(r){let i=r;!e.signal.aborted&&!(i instanceof DOMException&&i.name===`AbortError`)&&(console.error(`[timeline] rollback fetch failed`,{docName:s,sha:n.sha,err:i}),Ar.error(`Restore failed — document unchanged`,{duration:4e3})),t();return}if(e.signal.aborted){t();return}if(r.ok)b(!1),u();else{let e=`HTTP ${r.status}`;try{let t=await r.json();t.error&&(e=t.error)}catch{}console.error(`[timeline] rollback failed`,{docName:s,sha:n.sha,status:r.status,detail:e}),Ar.error(`Restore failed`,{description:e,duration:6e3})}t()},t[13]=s,t[14]=n.sha,t[15]=u,t[16]=b,t[17]=j):j=t[17];let M=j,N;t[18]!==n||t[19]!==i||t[20]!==d?(N=d?(()=>{let e=ph(n);return e===`bridge-merge-loss`?(0,X.jsx)(R,{className:`size-3.5 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":`true`}):e===`external-change-rescue`?(0,X.jsx)(qi,{className:`size-3.5 shrink-0 text-sky-600 dark:text-sky-400`,"aria-hidden":`true`}):(0,X.jsx)(Gi,{className:`size-3.5 shrink-0 text-muted-foreground`})})():(0,X.jsx)(uh,{entry:n,isDark:i}),t[18]=n,t[19]=i,t[20]=d,t[21]=N):N=t[21];let P=N,F=c?w:void 0,I=c?`bg-muted`:`hover:bg-muted/50`,L;t[22]===I?L=t[23]:(L=[`group flex w-full items-start gap-3 rounded-lg px-3 py-2.5 text-left transition-colors cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-ring`,I],t[22]=I,t[23]=L);let z=L.join(` `),B;t[24]===O?B=t[25]:(B=e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),O())},t[24]=O,t[25]=B);let V;t[26]===P?V=t[27]:(V=(0,X.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:P}),t[26]=P,t[27]=V);let H;t[28]!==h||t[29]!==n||t[30]!==d?(H=d?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`text-xs text-foreground truncate`,children:mh(n)}),(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground/50`,children:`·`}),(0,X.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:h})]}):(0,X.jsx)(`span`,{className:`truncate text-xs text-foreground`,children:h}),t[28]=h,t[29]=n,t[30]=d,t[31]=H):H=t[31];let U;t[32]!==n.timestamp||t[33]!==p?(U=(0,X.jsx)(`time`,{className:`ml-auto shrink-0 text-xs text-muted-foreground/80`,dateTime:n.timestamp,title:n.timestamp,children:p}),t[32]=n.timestamp,t[33]=p,t[34]=U):U=t[34];let W;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-px shrink-0 bg-border`}),t[35]=W):W=t[35];let G;t[36]===n?G=t[37]:(G=yh(n),t[36]=n,t[37]=G);let ee;t[38]===b?ee=t[39]:(ee=e=>{e.stopPropagation(),b(!0)},t[38]=b,t[39]=ee);let K;t[40]===x?K=t[41]:(K=x?(0,X.jsx)(Rn,{className:`size-3 animate-spin`}):(0,X.jsx)(Un,{className:`size-3`}),t[40]=x,t[41]=K);let te;t[42]!==x||t[43]!==G||t[44]!==ee||t[45]!==K?(te=(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(J,{variant:`ghost`,size:`icon`,className:`size-5 shrink-0 text-muted-foreground hover:text-destructive`,"data-testid":`timeline-entry-restore`,"aria-label":G,disabled:x,onClick:ee,children:K})}),t[42]=x,t[43]=G,t[44]=ee,t[45]=K,t[46]=te):te=t[46];let ne;t[47]===n?ne=t[48]:(ne=yh(n),t[47]=n,t[48]=ne);let re;t[49]===ne?re=t[50]:(re=(0,X.jsx)(Fr,{side:`top`,children:ne}),t[49]=ne,t[50]=re);let ie;t[51]!==te||t[52]!==re?(ie=(0,X.jsxs)(Lr,{children:[te,re]}),t[51]=te,t[52]=re,t[53]=ie):ie=t[53];let ae;t[54]!==H||t[55]!==U||t[56]!==ie?(ae=(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[H,U,W,ie]}),t[54]=H,t[55]=U,t[56]=ie,t[57]=ae):ae=t[57];let oe;t[58]===v?oe=t[59]:(oe=v.length>0&&(0,X.jsx)(Sh,{summaries:v}),t[58]=v,t[59]=oe);let se=g.length>0?(0,X.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,title:g.join(`, `),children:g.join(`, `)}):(0,X.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,title:n.message,children:n.message}),ce;t[60]!==ae||t[61]!==oe||t[62]!==se?(ce=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[ae,oe,se]}),t[60]=ae,t[61]=oe,t[62]=se,t[63]=ce):ce=t[63];let le;t[64]!==c||t[65]!==O||t[66]!==F||t[67]!==z||t[68]!==B||t[69]!==V||t[70]!==ce?(le=(0,X.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-expanded":c,"aria-controls":F,"data-testid":`timeline-entry-expand`,className:z,onClick:O,onKeyDown:B,children:[V,ce]}),t[64]=c,t[65]=O,t[66]=F,t[67]=z,t[68]=B,t[69]=V,t[70]=ce,t[71]=le):le=t[71];let ue;t[72]!==o||t[73]!==a||t[74]!==w||t[75]!==s||t[76]!==n.sha||t[77]!==c?(ue=c&&(0,X.jsx)(Th,{sha:n.sha,docName:s,cache:o,diffLayout:a,panelId:w}),t[72]=o,t[73]=a,t[74]=w,t[75]=s,t[76]=n.sha,t[77]=c,t[78]=ue):ue=t[78];let de;t[79]!==le||t[80]!==ue?(de=(0,X.jsxs)(`div`,{className:`flex flex-col rounded-lg`,children:[le,ue]}),t[79]=le,t[80]=ue,t[81]=de):de=t[81];let fe;t[82]!==A||t[83]!==b?(fe=e=>{e?b(!0):A()},t[82]=A,t[83]=b,t[84]=fe):fe=t[84];let pe;t[85]===n?pe=t[86]:(pe=bh(n),t[85]=n,t[86]=pe);let me;t[87]===pe?me=t[88]:(me=(0,X.jsx)(hr,{children:pe}),t[87]=pe,t[88]=me);let he;t[89]===n.timestamp?he=t[90]:(he=oh(n.timestamp),t[89]=n.timestamp,t[90]=he);let ge;t[91]===n.sha?ge=t[92]:(ge=sh(n.sha),t[91]=n.sha,t[92]=ge);let _e;t[93]!==p||t[94]!==he||t[95]!==ge?(_e=(0,X.jsxs)(`span`,{className:`font-medium text-foreground`,children:[p,` (`,he,`, `,ge,`)`]}),t[93]=p,t[94]=he,t[95]=ge,t[96]=_e):_e=t[96];let ve;t[97]===h?ve=t[98]:(ve=(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:h}),t[97]=h,t[98]=ve);let ye;t[99]!==_e||t[100]!==ve?(ye=(0,X.jsxs)(pr,{children:[`This will replace the current document content with the version from`,` `,_e,` `,`by `,ve,`. Your current content is already saved in the timeline — you can restore it anytime.`]}),t[99]=_e,t[100]=ve,t[101]=ye):ye=t[101];let be;t[102]!==me||t[103]!==ye?(be=(0,X.jsxs)(Er,{children:[me,ye]}),t[102]=me,t[103]=ye,t[104]=be):be=t[104];let xe;t[105]===A?xe=t[106]:(xe=(0,X.jsx)(J,{variant:`outline`,"data-testid":`timeline-entry-restore-cancel`,onClick:A,children:`Cancel`}),t[105]=A,t[106]=xe);let Se;t[107]===M?Se=t[108]:(Se=()=>M(),t[107]=M,t[108]=Se);let Ce;t[109]===x?Ce=t[110]:(Ce=x?(0,X.jsx)(Rn,{className:`mr-2 size-4 animate-spin`}):null,t[109]=x,t[110]=Ce);let we;t[111]!==x||t[112]!==Se||t[113]!==Ce?(we=(0,X.jsxs)(J,{variant:`destructive`,"data-testid":`timeline-entry-restore-confirm`,disabled:x,onClick:Se,children:[Ce,`Restore`]}),t[111]=x,t[112]=Se,t[113]=Ce,t[114]=we):we=t[114];let Te;t[115]!==xe||t[116]!==we?(Te=(0,X.jsxs)(Cr,{children:[xe,we]}),t[115]=xe,t[116]=we,t[117]=Te):Te=t[117];let Ee;t[118]!==be||t[119]!==Te?(Ee=(0,X.jsxs)(yr,{children:[be,Te]}),t[118]=be,t[119]=Te,t[120]=Ee):Ee=t[120];let De;t[121]!==y||t[122]!==fe||t[123]!==Ee?(De=(0,X.jsx)(Dr,{open:y,onOpenChange:fe,children:Ee}),t[121]=y,t[122]=fe,t[123]=Ee,t[124]=De):De=t[124];let Oe;return t[125]!==de||t[126]!==De?(Oe=(0,X.jsxs)(X.Fragment,{children:[de,De]}),t[125]=de,t[126]=De,t[127]=Oe):Oe=t[127],Oe}function Dh(e){return e.docs}function Oh(e){let t=(0,Q.c)(63),{docName:n,diffLayout:r,onDiffLayoutChange:i}=e,{resolvedTheme:a}=G(),o=a===`dark`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=[],t[0]=s):s=t[0];let[c,l]=(0,Z.useState)(s),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null),m=(0,Z.useRef)(null),[h]=(0,Z.useState)(Mh),[g,_]=(0,Z.useState)(jh),v;t[1]===h?v=t[2]:(v=()=>{_(new Set),h.clear()},t[1]=h,t[2]=v);let y;t[3]===n?y=t[4]:(y=[n],t[3]=n,t[4]=y),(0,Z.useEffect)(v,y);let b;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(b=function(e){_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[5]=b):b=t[5];let x=b,S;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(S=function(){_(new Set)},t[6]=S):S=t[6];let C=S,w,T;t[7]===n?(w=t[8],T=t[9]):(w=()=>{if(!n){l([]);return}let e=!1,t=async function(){if(n)try{let t=await fetch(`/api/history?docName=${encodeURIComponent(n)}&limit=100`);if(e)return;if(!t.ok){p(`History unavailable`);return}let r=await t.json();if(e)return;l(r.entries??[]),p(null)}catch(t){let n=t;if(e)return;p(`History unavailable`),console.error(`[timeline]`,n)}};return d(!0),t().finally(()=>{e||d(!1)}),m.current=setInterval(t,1e4),()=>{e=!0,m.current&&clearInterval(m.current)}},T=[n],t[7]=n,t[8]=w,t[9]=T),(0,Z.useEffect)(w,T);let E,D,O,k,A,j,M,N;if(t[10]!==h||t[11]!==r||t[12]!==n||t[13]!==c||t[14]!==f||t[15]!==g||t[16]!==o||t[17]!==u||t[18]!==i){let e=[],a=[],s=!1;for(let t of c)t.type===`checkpoint`?(a.length>0&&(e.push({kind:`wip-group`,entries:a,isPreCheckpoint:!s}),a=[]),e.push({kind:`checkpoint`,entry:t}),s=!0):a.push(t);a.length>0&&e.push({kind:`wip-group`,entries:a,isPreCheckpoint:!s});let l;t[27]===c?l=t[28]:(l=c.some(Ah),t[27]=c,t[28]=l);let d=!l,p=!u&&!f&&c.length>0;A=`flex h-full flex-col`,t[29]!==r||t[30]!==p||t[31]!==i?(j=p&&(0,X.jsx)(`div`,{className:`flex items-center justify-end gap-1 px-2 py-1.5`,children:(0,X.jsxs)(Lr,{children:[(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsxs)(Xe,{type:`single`,value:r,onValueChange:e=>{e&&i(e)},"aria-label":`Diff layout`,variant:`segmented`,size:`sm`,spacing:1,className:`bg-muted dark:bg-background p-0.5 rounded-md shrink-0`,children:[(0,X.jsx)(He,{value:`unified`,"aria-label":`Unified diff`,className:`size-6 px-0`,children:(0,X.jsx)(Ta,{className:`size-3.5`})}),(0,X.jsx)(He,{value:`split`,"aria-label":`Split diff`,className:`size-6 px-0`,children:(0,X.jsx)(Bi,{className:`size-3.5`})})]})}),(0,X.jsx)(Fr,{children:r===`unified`?`Unified diff`:`Split diff`})]})}),t[29]=r,t[30]=p,t[31]=i,t[32]=j):j=t[32],M=`flex-1 overflow-y-auto subtle-scrollbar`,t[33]===u?N=t[34]:(N=u&&(0,X.jsx)(`div`,{className:`flex flex-col gap-1 p-2`,role:`status`,"aria-busy":`true`,"aria-label":`Loading timeline history`,children:[1,2,3].map(kh)}),t[33]=u,t[34]=N),t[35]!==f||t[36]!==u?(E=!u&&f&&(0,X.jsx)(`div`,{className:`px-4 py-3`,children:(0,X.jsx)(`p`,{className:`text-xs text-destructive`,children:f})}),t[35]=f,t[36]=u,t[37]=E):E=t[37],t[38]!==c.length||t[39]!==f||t[40]!==u?(D=!u&&!f&&c.length===0&&(0,X.jsx)(`div`,{className:`px-4 py-8 text-center`,children:(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No history yet`})}),t[38]=c.length,t[39]=f,t[40]=u,t[41]=D):D=t[41],t[42]!==h||t[43]!==r||t[44]!==n||t[45]!==c||t[46]!==f||t[47]!==g||t[48]!==d||t[49]!==o||t[50]!==u?(O=!u&&!f&&d&&c.length>0&&(0,X.jsx)(`div`,{className:`flex flex-col gap-1 p-2`,children:c.map(e=>(0,X.jsx)(Eh,{entry:e,isDark:o,diffLayout:r,cache:h,docName:n,expanded:g.has(e.sha),onToggleExpanded:x,onRestoreSuccess:C},e.sha))}),t[42]=h,t[43]=r,t[44]=n,t[45]=c,t[46]=f,t[47]=g,t[48]=d,t[49]=o,t[50]=u,t[51]=O):O=t[51],k=!u&&!f&&!d&&(0,X.jsx)(`div`,{className:`flex flex-col gap-1 p-2`,children:e.map((e,t)=>e.kind===`checkpoint`?(0,X.jsx)(Eh,{entry:e.entry,prominent:!0,isDark:o,diffLayout:r,cache:h,docName:n,expanded:g.has(e.entry.sha),onToggleExpanded:x,onRestoreSuccess:C},e.entry.sha):(0,X.jsx)(dh,{entries:e.entries,defaultExpanded:e.isPreCheckpoint,isDark:o,diffLayout:r,cache:h,docName:n,expandedShas:g,onToggleExpanded:x,onRestoreSuccess:C},e.entries[0]?.sha??`wip-${t}`))}),t[10]=h,t[11]=r,t[12]=n,t[13]=c,t[14]=f,t[15]=g,t[16]=o,t[17]=u,t[18]=i,t[19]=E,t[20]=D,t[21]=O,t[22]=k,t[23]=A,t[24]=j,t[25]=M,t[26]=N}else E=t[19],D=t[20],O=t[21],k=t[22],A=t[23],j=t[24],M=t[25],N=t[26];let P;t[52]!==E||t[53]!==D||t[54]!==O||t[55]!==k||t[56]!==M||t[57]!==N?(P=(0,X.jsxs)(`div`,{className:M,children:[N,E,D,O,k]}),t[52]=E,t[53]=D,t[54]=O,t[55]=k,t[56]=M,t[57]=N,t[58]=P):P=t[58];let F;return t[59]!==A||t[60]!==j||t[61]!==P?(F=(0,X.jsxs)(`div`,{className:A,children:[j,P]}),t[59]=A,t[60]=j,t[61]=P,t[62]=F):F=t[62],F}function kh(e){return(0,X.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg px-3 py-2.5`,children:[(0,X.jsx)(nr,{className:`size-3.5 rounded mt-0.5 shrink-0`}),(0,X.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,X.jsx)(nr,{className:`h-3 w-28`}),(0,X.jsx)(nr,{className:`h-3 w-40`})]})]},e)}function Ah(e){return e.type===`checkpoint`}function jh(){return new Set}function Mh(){return new Wn(32)}var Nh=[{id:`outline`,label:`Outline`,icon:ua},{id:`backlinks`,label:`Backlinks`,icon:Ui},{id:`forward-links`,label:`Outgoing Links`,icon:Wi},{id:`graph`,label:`Graph`,icon:pa},{id:`timeline`,label:`Timeline`,icon:Ii}];function Ph(){return n(()=>import(`./GraphPanel-T5dT_tWz.js`),__vite__mapDeps([11,1,12,3,5,6,13,14,15,16,17]),import.meta.url)}var Fh=(0,Z.lazy)(async()=>({default:(await Ph()).GraphPanel})),Ih=(0,Z.lazy)(async()=>({default:(await n(()=>import(`./ActivityModeContent-BTaFD1U9.js`),__vite__mapDeps([18,1,2,3,19,20,21,13,12,5,6,22,7,14,23]),import.meta.url)).ActivityModeContent}));function Lh(e){let t=(0,Q.c)(13),{docName:n,isSourceMode:r,activeTab:i,onActiveTabChange:a,mode:o}=e,[s,c]=(0,Z.useState)(`unified`),l;t[0]!==i||t[1]!==o||t[2]!==a?(l=o===`doc`?(0,X.jsx)(`div`,{className:`flex flex-row items-center justify-center gap-3 border-b border-border/60 p-2`,children:(0,X.jsx)(Xe,{type:`single`,variant:`outline`,value:i,onValueChange:e=>{e&&a(e)},"aria-label":`Document panels`,children:Nh.map(Rh)})}):null,t[0]=i,t[1]=o,t[2]=a,t[3]=l):l=t[3];let u;t[4]!==i||t[5]!==s||t[6]!==n||t[7]!==r||t[8]!==o?(u=o===`doc`?(0,X.jsxs)(`div`,{role:`tabpanel`,id:`panel-${i}`,"aria-labelledby":`tab-${i}`,className:`min-h-0 flex-1`,children:[i===`outline`&&(0,X.jsx)(ci,{docName:n,isSourceMode:r}),i===`backlinks`&&(0,X.jsx)(wm,{docName:n}),i===`forward-links`&&(0,X.jsx)(Dm,{docName:n}),i===`graph`&&(0,X.jsx)(Z.Suspense,{fallback:(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Loading graph…`}),children:(0,X.jsx)(Fh,{activeDocName:n})}),i===`timeline`&&(0,X.jsx)(Oh,{docName:n,diffLayout:s,onDiffLayoutChange:c})]}):(0,X.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,X.jsx)(Z.Suspense,{fallback:(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Loading agent activity…`}),children:(0,X.jsx)(Ih,{})})}),t[4]=i,t[5]=s,t[6]=n,t[7]=r,t[8]=o,t[9]=u):u=t[9];let d;return t[10]!==l||t[11]!==u?(d=(0,X.jsxs)(X.Fragment,{children:[l,u]}),t[10]=l,t[11]=u,t[12]=d):d=t[12],d}function Rh(e){let{id:t,label:n,icon:r}=e;return(0,X.jsxs)(Lr,{children:[(0,X.jsx)(He,{value:t,role:`tab`,id:`tab-${t}`,"aria-controls":`panel-${t}`,"aria-label":n,asChild:!0,children:(0,X.jsx)(Pr,{children:(0,X.jsx)(r,{})})}),(0,X.jsx)(Fr,{side:`bottom`,children:n})]},t)}function zh(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function Bh(e,t){let n=getComputedStyle(e.ownerDocument.body);return t*parseFloat(n.fontSize)}function Vh(e){return e/100*window.innerHeight}function Hh(e){return e/100*window.innerWidth}function Uh(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}function Wh({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=Uh(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=Bh(t,i);break;case`em`:r=zh(t,i);break;case`vh`:r=Vh(i);break;case`vw`:r=Hh(i);break}return r}function Gh(e){return parseFloat(e.toFixed(3))}function Kh({group:e}){let{orientation:t,panels:n}=e;return n.reduce((e,n)=>(e+=t===`horizontal`?n.element.offsetWidth:n.element.offsetHeight,e),0)}function qh(e){let{panels:t}=e,n=Kh({group:e});return n===0?t.map(e=>({groupResizeBehavior:e.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:e.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let{element:t,panelConstraints:r}=e,i=0;r.collapsedSize!==void 0&&(i=Gh(Wh({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=Gh(Wh({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=Gh(Wh({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=Gh(Wh({groupSize:n,panelElement:t,styleProp:r.maxSize})/n*100)),{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:i,collapsible:r.collapsible===!0,defaultSize:a,disabled:r.disabled,minSize:o,maxSize:s,panelId:e.id}})}function Jh(e,t=`Assertion error`){if(!e)throw Error(t)}function Yh(e,t){return Array.from(t).sort(e===`horizontal`?Xh:Zh)}function Xh(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function Zh(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function Qh(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function $h(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function eg({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=$h(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return Jh(i,`No rect found`),i}var tg;function ng(){return tg===void 0&&(tg=typeof matchMedia==`function`?!!matchMedia(`(pointer:coarse)`).matches:!1),tg}function rg(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=Yh(n,Array.from(t.children).filter(Qh).map(e=>({element:e}))).map(({element:e})=>e),o=[],s=!1,c=!1,l=-1,u=-1,d=0,f,p=[];{let e=-1;for(let t of a)t.hasAttribute(`data-panel`)&&(e++,t.hasAttribute(`data-disabled`)||(d++,l===-1&&(l=e),u=e))}if(d>1){let t=-1;for(let d of a)if(d.hasAttribute(`data-panel`)){t++;let i=r.find(e=>e.element===d);if(i){if(f){let r=f.element.getBoundingClientRect(),a=d.getBoundingClientRect(),m;if(c){let e=n===`horizontal`?new DOMRect(r.right,r.top,0,r.height):new DOMRect(r.left,r.bottom,r.width,0),t=n===`horizontal`?new DOMRect(a.left,a.top,0,a.height):new DOMRect(a.left,a.top,a.width,0);switch(p.length){case 0:m=[e,t];break;case 1:{let i=p[0];m=[i,eg({orientation:n,rects:[r,a],targetRect:i.element.getBoundingClientRect()})===r?t:e];break}default:m=p;break}}else m=p.length?p:[n===`horizontal`?new DOMRect(r.right,a.top,a.left-r.right,a.height):new DOMRect(a.left,r.bottom,a.width,a.top-r.bottom)];for(let n of m){let r=`width`in n?n:n.element.getBoundingClientRect(),a=ng()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(r.width<a){let e=a-r.width;r=new DOMRect(r.x-e/2,r.y,r.width+e,r.height)}if(r.height<a){let e=a-r.height;r=new DOMRect(r.x,r.y-e/2,r.width,r.height+e)}!s&&!(t<=l||t>u)&&o.push({group:e,groupSize:Kh({group:e}),panels:[f,i],separator:`width`in n?void 0:n,rect:r}),s=!1}}c=!1,f=i,p=[]}}else if(d.hasAttribute(`data-separator`)){d.ariaDisabled!==null&&(s=!0);let e=i.find(e=>e.element===d);e?p.push(e):(f=void 0,p=[])}else c=!0}return o}var ig=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0)if(n.length===1)n[0].call(null,t);else{let e=!1,r=null,i=Array.from(n);for(let n=0;n<i.length;n++){let a=i[n];try{a.call(null,t)}catch(t){r===null&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}},ag=new Map,og=new ig;function sg(e){ag=new Map(ag),ag.delete(e)}function cg(e,t){for(let[t]of ag)if(t.id===e)return t}function lg(e,t){for(let[t,n]of ag)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function ug(){return ag}function dg(e,t){return og.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function fg(e,t){let n=ag.get(e);ag=new Map(ag),ag.set(e,t),og.emit(`groupChange`,{group:e,prev:n,next:t})}function pg(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=$h(n,a.rect);switch(e){case`horizontal`:t.x<=i.x&&(r=a,i=t);break;case`vertical`:t.y<=i.y&&(r=a,i=t);break}}return r?{distance:i,hitRegion:r}:void 0}function mg(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function hg(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:xg(e),b:xg(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();Jh(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:bg(yg(n.a)),b:bg(yg(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var gg=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function _g(e){let t=getComputedStyle(Sg(e)??e).display;return t===`flex`||t===`inline-flex`}function vg(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||_g(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||gg.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function yg(e){let t=e.length;for(;t--;){let n=e[t];if(Jh(n,`Missing node`),vg(n))return n}return null}function bg(e){return e&&Number(getComputedStyle(e).zIndex)||0}function xg(e){let t=[];for(;e;)t.push(e),e=Sg(e);return t}function Sg(e){let{parentNode:t}=e;return mg(t)?t.host:t}function Cg(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function wg({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!Qh(n)||n.contains(e)||e.contains(n))return!0;if(hg(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(Cg(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function Tg(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=rg(r),a=pg(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&wg({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function Eg(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function Dg(e,t,n=0){return Math.abs(Gh(e)-Gh(t))<=n}function Og(e,t){return Dg(e,t)?0:e>t?1:-1}function kg({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsible:a,disabled:o,maxSize:s=100,minSize:c=0}=t;if(o&&!e)return n;if(Og(r,c)<0)if(a){let e=(i+c)/2;r=Og(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=Gh(r),r}function Ag({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(Dg(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;Jh(u!=null,`Invalid first pivot index`),Jh(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];Jh(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(Jh(n!=null,`Previous layout not found for panel index ${t}`),Dg(n,i)){let t=o-n;Og(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];Jh(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(Jh(n!=null,`Previous layout not found for panel index ${t}`),Dg(n,o)){let t=n-i;Og(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];Jh(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&Og(i,c)<0)if(e>0){let t=c-o,n=t/2;Og(i+e,c)<0&&(e=Og(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;Og(i-e,c)<0&&(e=Og(100+e,n)>0?0:-t)}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];Jh(e!=null,`Previous layout not found for panel index ${r}`);let a=kg({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];Jh(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=kg({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!Dg(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(Eg(c,l))return i;{let t=e<0?d:u,r=s[t];Jh(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=kg({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!Dg(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];Jh(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=kg({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(Dg(i,s)||(t-=s-i,l[r]=s),Dg(t,0))break;e>0?r--:r++}}}if(!Dg(Object.values(l).reduce((e,t)=>t+e,0),100,.1))return i;let p=Object.keys(i);return l.reduce((e,t,n)=>(e[p[n]]=t,e),{})}function jg(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||Og(e[n],t[n])!==0)return!1;return!0}function Mg({layout:e,panelConstraints:t}){let n=Object.values(e),r=[...n],i=r.reduce((e,t)=>e+t,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(e=>`${e}%`).join(`, `)}`);if(!Dg(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];Jh(t!=null,`No layout data found for index ${e}`),r[e]=100/i*t}let a=0;for(let e=0;e<t.length;e++){let i=n[e];Jh(i!=null,`No layout data found for index ${e}`);let o=r[e];Jh(o!=null,`No layout data found for index ${e}`);let s=kg({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!Dg(a,0))for(let e=0;e<t.length;e++){let n=r[e];Jh(n!=null,`No layout data found for index ${e}`);let i=n+a,o=kg({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,Dg(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function Ng({groupId:e,panelId:t}){let n=()=>{let t=ug();for(let[n,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:a,groupSize:o,separatorToPanels:s}]of t)if(n.id===e)return{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:n,groupSize:o,layout:a,separatorToPanels:s};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedPanelConstraints.find(e=>e.panelId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let e=n().group.panels.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},a=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=e=>{let r=a();if(e===r)return;let{defaultLayoutDeferred:i,derivedPanelConstraints:o,group:s,groupSize:c,layout:l,separatorToPanels:u}=n(),d=s.panels.findIndex(e=>e.id===t),f=d===s.panels.length-1,p=Mg({layout:Ag({delta:f?r-e:e-r,initialLayout:l,panelConstraints:o,pivotIndices:f?[d-1,d]:[d,d+1],prevLayout:l,trigger:`imperative-api`}),panelConstraints:o});jg(l,p)||fg(s,{defaultLayoutDeferred:i,derivedPanelConstraints:o,groupSize:c,layout:p,separatorToPanels:u})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),s=a();e&&s!==t&&(n.expandToSize=s,o(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:s}=i(),c=a();if(e&&c===t){let e=s.expandToSize??n;e===0&&(e=1),o(e)}},getSize:()=>{let{group:e}=n(),t=a(),{element:r}=i();return{asPercentage:t,inPixels:e.orientation===`horizontal`?r.offsetWidth:r.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=a();return e&&Dg(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=Kh({group:t});o(Gh(Wh({groupSize:a,panelElement:r,styleProp:e})/a*100))}}}function Pg(e){e.defaultPrevented||Tg(e,ug()).forEach(t=>{if(t.separator&&!t.separator.disableDoubleClick){let n=t.panels.find(e=>e.panelConstraints.defaultSize!==void 0);if(n){let r=n.panelConstraints.defaultSize,i=Ng({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function Fg(e){let t=ug();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function Ig({groupId:e}){let t=()=>{let t=ug();for(let[n,r]of t)if(n.id===e)return{group:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:i,groupSize:a,layout:o,separatorToPanels:s}=t(),c=Mg({layout:e,panelConstraints:r});return n?o:(jg(o,c)||fg(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function Lg(e,t){let n=Fg(e),r=lg(n.id,!0),i=n.separators.find(t=>t.element===e);Jh(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);Jh(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=Ig({groupId:n.id}).getLayout(),c=Mg({layout:Ag({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});jg(s,c)||fg(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels})}function Rg(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=Fg(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&Lg(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&Lg(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&Lg(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&Lg(t,-5);break;case`End`:e.preventDefault(),Lg(t,100);break;case`Enter`:{e.preventDefault();let n=Fg(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=lg(n.id,!0),o=n.separators.find(e=>e.element===t);Jh(o,`Matching separator not found`);let s=a.get(o);Jh(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(Jh(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];Lg(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=Fg(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);Jh(r!==null,`Index not found`),n[e.shiftKey?r>0?r-1:n.length-1:r+1<n.length?r+1:0].focus({preventScroll:!0});break}case`Home`:e.preventDefault(),Lg(t,-100);break}}var zg={cursorFlags:0,state:`inactive`},Bg=new ig;function Vg(){return zg}function Hg(e){return Bg.addListener(`change`,e)}function Ug(e){let t=zg,n={...zg};n.cursorFlags=e,zg=n,Bg.emit(`change`,{prev:t,next:n})}function Wg(e){let t=zg;zg=e,Bg.emit(`change`,{prev:t,next:e})}function Gg(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=ug(),n=Tg(e,t),r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus({preventScroll:!0})));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),Wg({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}var Kg=e=>e,qg=()=>{},Jg=1,Yg=2,Xg=4,Zg=8,Qg=3,$g=12,e_;function t_(){return e_===void 0&&(e_=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(e_=!0)),e_}function n_({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++;break}})}if(!(r===0&&i===0)){switch(n){case`active`:if(e&&t_()){let t=(e&Jg)!==0,n=(e&Yg)!==0,r=(e&Xg)!==0,i=(e&Zg)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}break}return t_()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var r_=new WeakMap;function i_(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=r_.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(n));let r=Vg();switch(r.state){case`active`:case`hover`:{let e=n_({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(e=>e.group),state:r.state}),i=`*, *:hover {cursor: ${e} !important; }`;if(t===i)return;t=i,e?n.cssRules.length===0?n.insertRule(i):n.replaceSync(i):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}r_.set(e,{prevStyle:t,styleSheet:n})}function a_({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:a,prevCursorFlags:o}){let s=0;n.forEach(e=>{let{group:n,groupSize:o}=e,{orientation:c,panels:l}=n,{disableCursor:u}=n.mutableState,d=0;d=a?c===`horizontal`?(t.clientX-a.x)/o*100:(t.clientY-a.y)/o*100:c===`horizontal`?t.clientX<0?-100:100:t.clientY<0?-100:100;let f=r.get(n),p=i.get(n);if(!f||!p)return;let{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:_,separatorToPanels:v}=p;if(h&&_&&v){let t=Ag({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(jg(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?Jg:Yg;break;case`vertical`:s|=d<0?Xg:Zg;break}}else fg(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&Qg:c|=s&Qg,t.movementY===0?c|=o&$g:c|=s&$g,Ug(c),i_(e)}function o_(e){let t=ug(),n=Vg();switch(n.state){case`active`:a_({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function s_(e){if(e.defaultPrevented)return;let t=Vg(),n=ug();switch(t.state){case`active`:if(e.buttons===0){Wg({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=lg(e.group.id,!0);fg(e.group,t)});return}for(let n of t.hitRegions)if(n.separator){let{element:t}=n.separator;t.hasPointerCapture?.(e.pointerId)||t.setPointerCapture?.(e.pointerId)}a_({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=Tg(e,n);r.length===0?t.state!==`inactive`&&Wg({cursorFlags:0,state:`inactive`}):Wg({cursorFlags:0,hitRegions:r,state:`hover`}),i_(e.currentTarget);break}}}function c_(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(Vg().state){case`hover`:Wg({cursorFlags:0,state:`inactive`})}}function l_(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=Vg();switch(t.state){case`active`:Wg({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(i_(e.currentTarget),t.hitRegions.forEach(e=>{let t=lg(e.group.id,!0);fg(e.group,t)}),e.preventDefault())}}function u_(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=Gh(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=Gh((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function d_(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=Kh({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:Gh(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function f_(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function p_({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,a=0,o=!1,s=new Map,c=[];for(let l of e.panels){let e=r[l.id]??0;switch(l.panelConstraints.groupResizeBehavior){case`preserve-pixel-size`:{o=!0;let r=Gh(e/100*n/t*100);s.set(l.id,r),i+=r;break}default:c.push(l.id),a+=e;break}}if(!o||c.length===0)return r;let l=100-i,u={...r};if(s.forEach((e,t)=>{u[t]=e}),a>0)for(let e of c)u[e]=Gh((r[e]??0)/a*l);else{let e=Gh(l/c.length);for(let t of c)u[t]=e}return u}function m_(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}var h_=new Map;function g_(e){let t=!0;Jh(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{for(let r of n){let{borderBoxSize:n,target:i}=r;if(i===e.element){if(t){let t=Kh({group:e});if(t===0)return;let n=lg(e.id);if(!n)return;let r=qh(e),i=n.defaultLayoutDeferred?u_(r):n.layout,a=Mg({layout:p_({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&jg(n.layout,a)&&f_(n.derivedPanelConstraints,r)&&n.groupSize===t)return;fg(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else d_(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{Jh(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=Kh({group:e}),s=qh(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(m_(e.panels,l)||(l=void 0));let u=Mg({layout:e.mutableState.layouts[c]??l??u_(s),panelConstraints:s}),d=e.element.ownerDocument;h_.set(d,(h_.get(d)??0)+1);let f=new Map;return rg(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),fg(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,groupSize:o,layout:u,separatorToPanels:f}),e.separators.forEach(e=>{Jh(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,Rg)}),h_.get(d)===1&&(d.addEventListener(`dblclick`,Pg,!0),d.addEventListener(`pointerdown`,Gg,!0),d.addEventListener(`pointerleave`,o_),d.addEventListener(`pointermove`,s_),d.addEventListener(`pointerout`,c_),d.addEventListener(`pointerup`,l_,!0)),function(){t=!1,h_.set(d,Math.max(0,(h_.get(d)??0)-1)),sg(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,Rg)}),h_.get(d)||(d.removeEventListener(`dblclick`,Pg,!0),d.removeEventListener(`pointerdown`,Gg,!0),d.removeEventListener(`pointerleave`,o_),d.removeEventListener(`pointermove`,s_),d.removeEventListener(`pointerout`,c_),d.removeEventListener(`pointerup`,l_,!0)),a.disconnect()}}function __(){let[e,t]=(0,Z.useState)({});return[e,(0,Z.useCallback)(()=>t({}),[])]}function v_(e){let t=(0,Z.useId)();return`${e??t}`}var y_=typeof window<`u`?Z.useLayoutEffect:Z.useEffect;function b_(e){let t=(0,Z.useRef)(e);return y_(()=>{t.current=e},[e]),(0,Z.useCallback)((...e)=>t.current?.(...e),[t])}function x_(...e){return b_(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function S_(e){let t=(0,Z.useRef)({...e});return y_(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var C_=(0,Z.createContext)(null);function w_(e,t){let n=(0,Z.useRef)({getLayout:()=>({}),setLayout:Kg});(0,Z.useImperativeHandle)(t,()=>n.current,[]),y_(()=>{Object.assign(n.current,Ig({groupId:e}))})}function T_({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){let m=(0,Z.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=b_(e=>{jg(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=b_(e=>{jg(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e))}),_=v_(s),v=(0,Z.useRef)(null),[y,b]=__(),x=(0,Z.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=x_(v,a);w_(_,o);let C=b_((e,t)=>{let r=Vg(),i=cg(e),a=lg(e);if(a){let e=!1;switch(r.state){case`active`:e=r.hitRegions.some(e=>e.group===i);break}return{flexGrow:a.layout[t]??1,pointerEvents:e?`none`:void 0}}if(n?.[t])return{flexGrow:n?.[t]}}),w=S_({defaultLayout:n,disableCursor:r}),T=(0,Z.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=Yh(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=Yh(u,[...t.separators,e]),b(),()=>{t.separators=t.separators.filter(t=>t!==e),b()}},updatePanelProps:(e,{disabled:t})=>{let n=x.current.panels.find(t=>t.id===e);n&&(n.panelConstraints.disabled=t);let r=cg(_),i=lg(_);r&&i&&fg(r,{...i,derivedPanelConstraints:qh(r)})},updateSeparatorProps:(e,{disabled:t,disableDoubleClick:n})=>{let r=x.current.separators.find(t=>t.id===e);r&&(r.disabled=t,r.disableDoubleClick=n)}}),[C,_,b,u,w]),E=(0,Z.useRef)(null);return y_(()=>{let e=v.current;if(e===null)return;let t=x.current,n;if(w.defaultLayout!==void 0&&Object.keys(w.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=w.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={disabled:!!i,element:e,id:_,mutableState:{defaultLayout:n,disableCursor:!!w.disableCursor,expandedPanelSizes:x.current.lastExpandedPanelSizes,layouts:x.current.layouts},orientation:u,panels:t.panels,resizeTargetMinimumSize:t.resizeTargetMinimumSize,separators:t.separators};E.current=r;let a=g_(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=lg(r.id,!0);!o&&s.length>0&&(h(c),g(c));let l=dg(_,e=>{let{defaultLayoutDeferred:t,derivedPanelConstraints:n,layout:i}=e.next;if(t||n.length===0)return;let a=r.panels.map(({id:e})=>e).join(`,`);r.mutableState.layouts[a]=i,n.forEach(t=>{if(t.collapsible){let{layout:n}=e.prev??{};if(n){let e=Dg(t.collapsedSize,i[t.panelId]),a=Dg(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=Vg().state!==`active`;h(i),o&&g(i)});return()=>{E.current=null,a(),l()}},[i,_,g,h,u,y,w]),(0,Z.useEffect)(()=>{let e=E.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,X.jsx)(C_.Provider,{value:T,children:(0,X.jsx)(`div`,{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:S,style:{height:`100%`,width:`100%`,overflow:`hidden`,...f,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:e})})}T_.displayName=`Group`;function E_(){let e=(0,Z.useContext)(C_);return Jh(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function D_(e,t){let{id:n}=E_(),r=(0,Z.useRef)({collapse:qg,expand:qg,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:qg});(0,Z.useImperativeHandle)(t,()=>r.current,[]),y_(()=>{Object.assign(r.current,Ng({groupId:n,panelId:e}))})}function O_({children:e,className:t,collapsedSize:n=`0%`,collapsible:r=!1,defaultSize:i,disabled:a,elementRef:o,groupResizeBehavior:s=`preserve-relative-size`,id:c,maxSize:l=`100%`,minSize:u=`0%`,onResize:d,panelRef:f,style:p,...m}){let h=!!c,g=v_(c),_=S_({disabled:a}),v=(0,Z.useRef)(null),y=x_(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,updatePanelProps:w}=E_(),T=d!==null,E=b_((e,t,n)=>{d?.(e,c,n)});y_(()=>{let e=v.current;if(e!==null)return C({element:e,id:g,idIsStable:h,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:T?E:void 0,panelConstraints:{groupResizeBehavior:s,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:l,minSize:u}})},[s,n,r,i,T,g,h,l,u,E,C,_]),(0,Z.useEffect)(()=>{w(g,{disabled:a})},[a,g,w]),D_(g,f);let D=()=>{let e=b(x,g);if(e)return JSON.stringify(e)},O=(0,Z.useSyncExternalStore)(e=>dg(x,e),D,D),k;return k=O?JSON.parse(O):i?{flexGrow:void 0,flexShrink:void 0,flexBasis:i}:{flexGrow:1},(0,X.jsx)(`div`,{...m,"data-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...k_,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...k},children:(0,X.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...p,touchAction:S===`horizontal`?`pan-y`:`pan-x`},children:e})})}O_.displayName=`Panel`;var k_={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function A_(){return(0,Z.useRef)(null)}function j_({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a,o=e[n],s=t.find(e=>e.panelId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=Mg({layout:Ag({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=Mg({layout:Ag({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function M_({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,style:o,...s}){let c=v_(a),l=S_({disabled:n,disableDoubleClick:r}),[u,d]=(0,Z.useState)({}),[f,p]=(0,Z.useState)(`inactive`),m=(0,Z.useRef)(null),h=x_(m,i),{disableCursor:g,id:_,orientation:v,registerSeparator:y,updateSeparatorProps:b}=E_(),x=v===`horizontal`?`vertical`:`horizontal`;y_(()=>{let e=m.current;if(e!==null){let t={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:e,id:c},n=y(t),r=Hg(e=>{p(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=dg(_,e=>{let{derivedPanelConstraints:n,layout:r,separatorToPanels:i}=e.next,a=i.get(t);if(a){let e=a[0],t=a.indexOf(e);d(j_({layout:r,panelConstraints:n,panelId:e.id,panelIndex:t}))}});return()=>{r(),i(),n()}}},[_,c,y,l]),(0,Z.useEffect)(()=>{b(c,{disabled:n,disableDoubleClick:r})},[n,r,c,b]);let S;return n&&!g&&(S=`not-allowed`),(0,X.jsx)(`div`,{...s,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":x,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":n?`disabled`:f,"data-testid":c,id:c,ref:h,role:`separator`,style:{flexBasis:`auto`,cursor:S,...o,flexGrow:0,flexShrink:0,touchAction:`none`},tabIndex:n?void 0:0})}M_.displayName=`Separator`;function N_(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,X.jsx)(`div`,{className:`tiptap-editor pt-10`,role:`status`,"aria-busy":`true`,"aria-label":`Loading document`,children:(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsx)(nr,{className:`h-9 w-2/5 mt-6 mb-5`}),(0,X.jsx)(nr,{className:`h-4 w-full`}),(0,X.jsx)(nr,{className:`h-4 w-3/4`})]})}),e[0]=t):t=e[0],t}var P_=1700,F_=3;function I_(e,t,n){let r=n?.windowMs??600,i=n?.maxLevel??F_;if(e===0||t>=r)return 1;let a=e+1;return a>i?i:a}var L_={0:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},1:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},2:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},3:{count:16,startRadius:11,baseDistance:7,distanceVariance:3,sizeMin:.45,sizeMax:1.2,maxDelay:250,durationMin:620,durationMax:1400}},R_=[`var(--color-azure-blue)`,`var(--color-sky-blue)`,`var(--color-violet-300)`,`var(--color-orange-light)`,`var(--color-crystal-blue)`,`var(--color-white-cream)`];function z_(e,t={}){let n=t.rng??Math.random,r=t.colors??R_,i=L_[e];if(i.count===0||r.length===0)return[];let a=[],o=Math.PI*2/i.count;for(let e=0;e<i.count;e++){let t=e*o+(n()-.5)*o*.7,s=i.baseDistance+(n()-.5)*2*i.distanceVariance,c=i.sizeMin+n()*(i.sizeMax-i.sizeMin),l=n()*i.maxDelay,u=i.durationMin+n()*(i.durationMax-i.durationMin),d=Math.floor(n()*r.length),f=Math.cos(t),p=Math.sin(t);a.push({id:e,dx:f*s,dy:p*s,originDx:f*i.startRadius,originDy:p*i.startRadius,size:c,color:r[d]??`currentColor`,delay:l,duration:u})}return a}var B_=1.8,V_=90,H_=16,U_=380,W_=.025,G_=.1,K_=.18,q_=400,J_=9.2736,Y_=18.1799,X_=14.5244,Z_={1:{halfWidth:1.5,apexLift:2.2},2:{halfWidth:1.4,apexLift:2.6},3:{halfWidth:1.25,apexLift:3}};function Q_(e,t){let{halfWidth:n,apexLift:r}=Z_[t];return`M${e-n} ${X_+.3} Q${e} ${X_-r}, ${e+n} ${X_+.3}`}function $_(e){let t=1.5,n=.3;return`M${e-t} ${X_-n} Q${e} ${X_+1.4}, ${e+t} ${X_-n}`}var ev=15,tv=15;function nv(e){return{fill:e.color,"--fx-tx":`${e.dx}px`,"--fx-ty":`${e.dy}px`,"--fx-delay":`${e.delay}ms`,"--fx-duration":`${e.duration}ms`}}function rv(e){let t=(0,Q.c)(71),{size:n,className:r,trackMouse:i,variant:a,celebrateSignal:o}=e,s=n===void 0?48:n,c=i===void 0?!0:i,l=a===void 0?`default`:a,u=o===void 0?0:o,d=(0,Z.useRef)(null),f=(0,Z.useRef)(null),p=(0,Z.useRef)(null),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m={x:0,y:0},t[0]=m):m=t[0];let h=(0,Z.useRef)(m),[g,_]=(0,Z.useState)(0),[v,y]=(0,Z.useState)(0),b;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(b=[],t[1]=b):b=t[1];let[x,S]=(0,Z.useState)(b),C=(0,Z.useRef)(0),w=(0,Z.useRef)(void 0),T=l===`sleeping`,E;t[2]!==g||t[3]!==T?(E=function(){if(T)return;let e=typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now(),t=C.current===0?1/0:e-C.current;C.current=e;let n=I_(g,t);_(n),y(sv),S(z_(n)),clearTimeout(w.current),w.current=setTimeout(()=>{_(0),S([])},P_)},t[2]=g,t[3]=T,t[4]=E):E=t[4];let D=E,O,k;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(O=()=>()=>clearTimeout(w.current),k=[],t[5]=O,t[6]=k):(O=t[5],k=t[6]),(0,Z.useEffect)(O,k);let A,j;t[7]!==u||t[8]!==T?(A=()=>{u===0||T||(_(3),y(ov),S(z_(3)),clearTimeout(w.current),w.current=setTimeout(()=>{_(0),S([])},P_))},j=[u,T],t[7]=u,t[8]=T,t[9]=A,t[10]=j):(A=t[9],j=t[10]),(0,Z.useEffect)(A,j);let M,N;t[11]!==T||t[12]!==c?(M=()=>{if(!c||T||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let e=0,t=0,n=!1,r=0,i=0,a=0,o=0,s=0,l=function(r){e=r.clientX,t=r.clientY,n=!0};function u(){if(s=requestAnimationFrame(u),!n)return;let c=f.current,l=d.current;if(!c||!l)return;let m=c.getBoundingClientRect(),g=m.left+m.width/2,_=m.top+m.height*.48,v=e-g,y=t-_,b=Math.hypot(v,y),x=Math.max(-1,Math.min(1,v/U_)),S=Math.max(-1,Math.min(1,y/U_)),C=x*H_,w=-S*H_;r+=(w-r)*G_,i+=(C-i)*G_,l.style.transform=`perspective(${q_}px) rotateX(${r.toFixed(3)}deg) rotateY(${i.toFixed(3)}deg)`;let T=0,E=0;if(b>=1){let e=Math.min(b/V_,1)*B_;T=v/b*e,E=y/b*e}a+=(T-a)*K_,o+=(E-o)*K_;let D=i*W_,O=-r*W_,k=a+D,A=o+O;h.current.x=k,h.current.y=A,p.current?.setAttribute(`transform`,`translate(${k.toFixed(3)} ${A.toFixed(3)})`)}return document.addEventListener(`mousemove`,l,{passive:!0}),s=requestAnimationFrame(u),()=>{document.removeEventListener(`mousemove`,l),cancelAnimationFrame(s),d.current&&(d.current.style.transform=``),h.current={x:0,y:0},p.current?.removeAttribute(`transform`)}},N=[c,T],t[11]=T,t[12]=c,t[13]=M,t[14]=N):(M=t[13],N=t[14]),(0,Z.useEffect)(M,N);let P;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(P=()=>{let e=p.current;if(!e)return;let{x:t,y:n}=h.current;e.setAttribute(`transform`,`translate(${t.toFixed(3)} ${n.toFixed(3)})`)},t[15]=P):P=t[15],(0,Z.useLayoutEffect)(P);let F=g>0,I=F?g:1,L=F?`ok-blob-clicked-${g}`:null,R;t[16]===r?R=t[17]:(R=q(`ok-blob-3d-wrapper`,r),t[16]=r,t[17]=R);let z=T?`cursor-default`:`cursor-pointer`,B=`body-${v}`,V=T&&`ok-blob-sleeping`,H;t[18]!==L||t[19]!==V?(H=q(`ok-blob-group`,V,L),t[18]=L,t[19]=V,t[20]=H):H=t[20];let U;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,X.jsx)(`path`,{d:`M25.2339 6.78134C25.5199 7.35734 25.8179 8.47234 26.0179 9.07834C26.0189 9.08234 26.0209 9.08634 26.0219 9.09134C26.0229 9.09534 26.0249 9.10034 26.0259 9.10434C26.0539 9.19734 26.0949 9.29533 26.1519 9.41633C26.2919 9.71133 26.5269 10.1173 27.1299 11.1683C27.3259 11.4643 27.5209 11.7693 27.7119 12.0903C29.9739 15.1623 29.3259 20.1913 27.0469 22.9153C26.7779 23.2953 26.4869 23.6043 26.1889 23.8863C26.1519 23.9253 26.1129 23.9643 26.0729 24.0033C25.3159 24.7543 24.2949 25.4673 23.6129 25.8323C22.7469 26.2983 22.1349 26.5483 21.6299 26.7463C20.3649 27.3063 19.0609 27.7733 17.6569 28.0423C15.9649 28.3513 14.1939 28.4433 12.4569 28.1373C11.4779 27.9663 10.5119 27.6663 9.60891 27.2493C8.77491 26.8663 7.99192 26.3853 7.26992 25.8403C6.83592 25.5393 6.43893 25.2343 6.08093 24.9383C5.57893 24.5223 5.15993 24.1263 4.83493 23.7793C4.04993 22.9443 3.31593 21.8893 2.80893 21.0953C2.72593 20.9663 2.64792 20.8433 2.57592 20.7293C2.56192 20.7093 2.54793 20.6893 2.53393 20.6703C2.08593 20.0263 1.71892 19.3293 1.43792 18.5993C1.42892 18.5453 1.42093 18.4903 1.41293 18.4353C1.32093 17.7443 1.08292 16.9423 1.01092 15.6333C0.984921 15.0653 0.998928 14.4013 1.12393 13.6353C1.20693 13.1413 1.31993 12.9023 1.40893 12.7113C1.43593 12.6543 1.46193 12.6023 1.48593 12.5483C1.56793 12.3653 1.59392 12.1563 1.63592 11.9083C1.68992 11.5883 1.76992 11.1943 2.04592 10.7553C2.94392 9.37934 3.36792 8.81934 3.66592 8.33934C3.75592 8.20334 3.84292 8.08134 3.94192 7.96634C4.21592 7.64634 4.67693 7.29534 5.10293 7.05734C5.16693 7.02234 5.23093 6.98834 5.29193 6.95534C5.62993 6.77834 6.22592 6.30135 6.66992 5.92035C6.83692 5.77635 7.08193 5.60735 7.37393 5.40935C7.67393 5.20535 8.02593 4.96934 8.39193 4.70234C9.32093 4.02634 9.84091 3.69134 10.2599 3.42334C10.3799 3.34734 10.4919 3.27734 10.6049 3.20834C10.9609 2.98834 11.4149 2.73034 11.8869 2.48634C12.4519 2.19334 13.0469 1.92133 13.5089 1.72233C14.7399 1.30233 16.0539 1.01333 17.4169 1.00033C18.1169 0.991333 18.7939 1.16534 19.2389 1.43034C19.6869 1.69534 19.8689 2.00335 19.8039 2.23935C19.7379 2.47835 19.4399 2.63634 19.0109 2.74734C18.5789 2.85634 18.0469 2.92035 17.4889 2.96135C16.3639 3.04235 15.2399 3.36435 14.1499 3.80835C12.8199 4.35135 11.5379 5.07133 10.2719 5.84733C9.38691 6.39133 8.51192 6.97334 7.63592 7.56834C7.54492 7.63034 7.45492 7.69135 7.36492 7.75235C6.97392 8.06635 6.58293 8.38134 6.22293 8.66334C5.97893 8.85734 5.76793 9.04834 5.59393 9.21434C5.26893 9.52334 5.02393 9.74334 4.81893 9.93934C4.67793 10.0753 4.55793 10.2013 4.45593 10.3443C4.40093 10.4213 4.32992 10.5273 4.24792 10.6593C3.90492 11.1933 3.44493 12.1693 3.15393 13.1173C3.01893 13.5363 2.87991 14.0343 2.79391 14.5253C2.66591 15.2253 2.65594 15.9053 2.71994 16.2373C2.82794 16.8193 2.95593 17.4833 3.14093 18.0553C3.31293 18.6003 3.52991 19.0583 3.70791 19.2823C3.81591 19.4183 3.90394 19.5473 3.99594 19.6913C4.09394 19.8413 4.19191 20.0073 4.31091 20.2033C4.47891 20.4803 4.68592 20.8163 5.00192 21.2493C5.36492 21.7463 5.61793 22.1043 5.83493 22.4023C6.14493 22.8243 6.38591 23.1343 6.83691 23.5033C7.33891 23.9113 7.86593 24.3113 8.26693 24.6393C8.44893 24.7883 8.66993 24.9443 8.90493 25.0963C9.21593 25.2963 9.55192 25.4893 9.85592 25.6703C10.1059 25.8203 10.3059 25.9633 10.4869 26.0863C10.5429 26.1243 10.5979 26.1603 10.6519 26.1943C10.8699 26.2803 11.0929 26.3593 11.3159 26.4283C11.3539 26.4323 11.3949 26.4353 11.4369 26.4393C11.6509 26.4573 11.9089 26.4733 12.2209 26.5133C12.7169 26.5753 13.1399 26.6603 13.6019 26.7243C13.9589 26.7733 14.3409 26.8083 14.7729 26.7893C15.0729 26.7753 15.4069 26.7353 15.7389 26.6813C16.2349 26.6023 16.7179 26.4943 17.0569 26.4473C17.1499 26.4343 17.2359 26.4343 17.3209 26.4373C17.3489 26.4393 17.3799 26.4413 17.4109 26.4433C17.4119 26.4433 17.4119 26.4433 17.4129 26.4433C17.4199 26.4433 17.4279 26.4443 17.4349 26.4443C18.2329 26.2413 19.0259 25.9433 19.7959 25.5983C19.8609 25.5633 19.9259 25.5273 19.9899 25.4913C20.3059 25.3173 20.6049 25.1383 20.7869 24.9943C20.9829 24.8393 21.5189 24.5373 22.0579 24.1853C22.4109 23.9553 22.7649 23.7053 23.0369 23.4833C23.1949 23.3553 23.3689 23.2693 23.5479 23.1773C23.7129 23.0923 23.8809 23.0013 24.0349 22.8653C24.1109 22.7983 24.1869 22.7173 24.2639 22.6303C24.3309 22.5563 24.4039 22.4723 24.4759 22.3923C24.5459 22.3153 24.7199 22.1723 24.9139 21.9793C25.0079 21.8863 25.1059 21.7783 25.1909 21.6713C25.2199 21.6323 25.2489 21.5943 25.2769 21.5553C25.5919 21.0403 25.8779 20.5003 26.1019 19.9653C26.1299 19.8403 26.1379 19.7293 26.1279 19.6373C26.1199 19.5703 26.1029 19.5113 26.0839 19.4503C26.0599 19.3643 26.0329 19.2773 26.0239 19.1723C26.0169 19.0893 26.0309 19.0043 26.0629 18.9543C26.0779 18.9323 26.0969 18.9143 26.1129 18.8993C26.1329 18.8823 26.1499 18.8673 26.1569 18.8443C26.1609 18.8273 26.1579 18.8073 26.1529 18.7833C26.1459 18.7443 26.1369 18.6943 26.1539 18.6293C26.2189 18.3853 26.2869 18.1103 26.3319 17.8383C26.3829 17.5393 26.4049 17.2433 26.3949 17.0123C26.3849 16.7493 26.3909 16.3823 26.3469 16.0003C26.3179 15.7343 26.2659 15.4663 26.1979 15.2383C26.1319 15.0143 26.0219 14.7913 25.9039 14.5783C25.7629 14.3223 25.6119 14.0783 25.5169 13.8453C25.4969 13.7983 25.4999 13.7263 25.4999 13.6323C25.5009 13.5673 25.4999 13.4913 25.4919 13.4083C25.3239 13.1243 25.1459 12.8423 24.9589 12.5483C24.9479 12.5413 24.9369 12.5333 24.9249 12.5263C24.6689 12.3503 24.3139 12.1173 24.0769 11.5503C24.0179 11.4063 24.0069 11.2983 23.9969 11.1993C23.9859 11.1013 23.9799 11.0183 23.9289 10.9093C23.8709 10.7853 23.7759 10.6583 23.6709 10.4993C23.5849 10.3703 23.4899 10.2133 23.4199 10.0423C23.3819 9.95134 23.3509 9.85734 23.3329 9.75934C23.3299 9.74334 23.3269 9.72534 23.3229 9.70634C23.2899 9.52734 23.2439 9.26534 23.2409 8.98634C23.0209 8.24434 22.8339 7.48833 22.6519 6.77633C22.3429 5.57133 22.0519 4.54234 21.3329 3.95434C20.9839 3.65334 20.5689 3.35433 20.2459 3.05433C19.9259 2.75633 19.7449 2.47534 19.8019 2.23834C19.8639 2.00634 20.1589 1.82934 20.6659 1.80534C21.1699 1.78334 21.8699 1.93235 22.5209 2.39235C23.6159 3.14235 24.2029 4.38334 24.5599 5.35734C24.5829 5.40834 24.6049 5.46034 24.6259 5.51234C24.7849 5.89434 24.9529 6.22834 25.1199 6.55534C25.1579 6.63034 25.1969 6.70834 25.2339 6.78134Z`,className:`ok-blob-body`}),t[21]=U):U=t[21];let W=(F||T)&&`ok-blob-eye-hidden`,G;t[22]===W?G=t[23]:(G=q(`ok-blob-eye`,W),t[22]=W,t[23]=G);let ee;t[24]===G?ee=t[25]:(ee=(0,X.jsx)(`ellipse`,{cx:J_,cy:X_,rx:1.2722,ry:1.9083,className:G}),t[24]=G,t[25]=ee);let K=(F||T)&&`ok-blob-eye-hidden`,te;t[26]===K?te=t[27]:(te=q(`ok-blob-eye ok-blob-eye-right`,K),t[26]=K,t[27]=te);let ne;t[28]===te?ne=t[29]:(ne=(0,X.jsx)(`ellipse`,{cx:Y_,cy:X_,rx:1.2722,ry:1.9083,className:te}),t[28]=te,t[29]=ne);let re;t[30]===I?re=t[31]:(re=Q_(J_,I),t[30]=I,t[31]=re);let ie=(!F||T)&&`ok-blob-eye-hidden`,ae;t[32]===ie?ae=t[33]:(ae=q(`ok-blob-happy-eye`,ie),t[32]=ie,t[33]=ae);let oe;t[34]!==re||t[35]!==ae?(oe=(0,X.jsx)(`path`,{d:re,strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:ae}),t[34]=re,t[35]=ae,t[36]=oe):oe=t[36];let se;t[37]===I?se=t[38]:(se=Q_(Y_,I),t[37]=I,t[38]=se);let ce=(!F||T)&&`ok-blob-eye-hidden`,le;t[39]===ce?le=t[40]:(le=q(`ok-blob-happy-eye`,ce),t[39]=ce,t[40]=le);let ue;t[41]!==se||t[42]!==le?(ue=(0,X.jsx)(`path`,{d:se,strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:le}),t[41]=se,t[42]=le,t[43]=ue):ue=t[43];let de;t[44]===T?de=t[45]:(de=T?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`path`,{d:$_(J_),strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:`ok-blob-sleeping-eye`}),(0,X.jsx)(`path`,{d:$_(Y_),strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:`ok-blob-sleeping-eye`})]}):null,t[44]=T,t[45]=de);let fe;t[46]!==ee||t[47]!==ne||t[48]!==oe||t[49]!==ue||t[50]!==de?(fe=(0,X.jsxs)(`g`,{ref:p,children:[ee,ne,oe,ue,de]}),t[46]=ee,t[47]=ne,t[48]=oe,t[49]=ue,t[50]=de,t[51]=fe):fe=t[51];let pe;t[52]!==B||t[53]!==H||t[54]!==fe?(pe=(0,X.jsxs)(`g`,{className:H,children:[U,fe]},B),t[52]=B,t[53]=H,t[54]=fe,t[55]=pe):pe=t[55];let me;t[56]===T?me=t[57]:(me=T?(0,X.jsxs)(`g`,{children:[(0,X.jsx)(`text`,{x:21,y:7,className:`ok-blob-z ok-blob-z-1`,children:`z`}),(0,X.jsx)(`text`,{x:26,y:2,className:`ok-blob-z ok-blob-z-2`,children:`z`})]}):null,t[56]=T,t[57]=me);let he;t[58]!==v||t[59]!==x?(he=x.length>0&&(0,X.jsx)(`g`,{children:x.map(iv)},`firework-${v}`),t[58]=v,t[59]=x,t[60]=he):he=t[60];let ge;t[61]!==D||t[62]!==s||t[63]!==z||t[64]!==pe||t[65]!==me||t[66]!==he?(ge=(0,X.jsxs)(`svg`,{ref:f,width:s,height:s,viewBox:`0 0 30 30`,fill:`none`,overflow:`visible`,xmlns:`http://www.w3.org/2000/svg`,className:z,"aria-hidden":`true`,onClick:D,onMouseDown:av,children:[pe,me,he]}),t[61]=D,t[62]=s,t[63]=z,t[64]=pe,t[65]=me,t[66]=he,t[67]=ge):ge=t[67];let _e;return t[68]!==R||t[69]!==ge?(_e=(0,X.jsx)(`span`,{ref:d,className:R,children:ge}),t[68]=R,t[69]=ge,t[70]=_e):_e=t[70],_e}function iv(e){return(0,X.jsx)(`circle`,{cx:ev+e.originDx,cy:tv+e.originDy,r:e.size,className:`ok-blob-firework`,style:nv(e)},e.id)}function av(e){return e.preventDefault()}function ov(e){return e+1}function sv(e){return e+1}function cv(e){let t=(0,Q.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=q(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(jc,{"data-slot":`label`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function lv(e){let t=(0,Q.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,orientation:i,decorative:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`horizontal`:i,s=a===void 0?!0:a,c;t[5]===n?c=t[6]:(c=q(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,n),t[5]=n,t[6]=c);let l;return t[7]!==s||t[8]!==o||t[9]!==r||t[10]!==c?(l=(0,X.jsx)(ul,{"data-slot":`separator`,decorative:s,orientation:o,className:c,...r}),t[7]=s,t[8]=o,t[9]=r,t[10]=c,t[11]=l):l=t[11],l}var uv=lt(`group/field flex w-full gap-2 data-[invalid=true]:text-destructive`,{variants:{orientation:{vertical:`flex-col *:w-full [&>.sr-only]:w-auto`,horizontal:`flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`,responsive:`flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`}},defaultVariants:{orientation:`vertical`}});function dv(e){let t=(0,Q.c)(11),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?`vertical`:i,o;t[4]!==n||t[5]!==a?(o=q(uv({orientation:a}),n),t[4]=n,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==a||t[8]!==r||t[9]!==o?(s=(0,X.jsx)(`div`,{role:`group`,"data-slot":`field`,"data-orientation":a,className:o,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function fv(e){let t=(0,Q.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=q(`group/field-content flex flex-1 flex-col gap-0.5 leading-snug`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(`div`,{"data-slot":`field-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function pv(e){let t=(0,Q.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=q(`group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10`,`has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(cv,{"data-slot":`field-label`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function mv(e){let t=(0,Q.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=q(`flex w-fit items-center gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(`div`,{"data-slot":`field-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function hv(e){let t=(0,Q.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=q(`text-left text-sm leading-normal font-normal text-muted-foreground group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5`,`last:mt-0 nth-last-2:-mt-1`,`[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(`p`,{"data-slot":`field-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function gv(e){let t=(0,Q.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=q(`grid w-full gap-2`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(nl,{"data-slot":`radio-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function _v(e){let t=(0,Q.c)(9),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=q(`group/radio-group-item peer relative flex aspect-square size-4 shrink-0 rounded-full border border-input outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary`,n),t[3]=n,t[4]=i);let a;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(il,{"data-slot":`radio-group-indicator`,className:`flex size-4 items-center justify-center`,children:(0,X.jsx)(`span`,{className:`absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary-foreground`})}),t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==i?(o=(0,X.jsx)(rl,{"data-slot":`radio-group-item`,className:i,...r,children:a}),t[6]=r,t[7]=i,t[8]=o):o=t[8],o}function vv(){let e=typeof window<`u`?window.okDesktop:void 0;return e?.seed?{plan:t=>e.seed.plan(t),apply:t=>e.seed.apply(t)}:{plan:async e=>{let t=e?`?rootDir=${encodeURIComponent(e)}`:``;return await(await fetch(`/api/seed/plan${t}`)).json()},apply:async e=>await(await fetch(`/api/seed/apply`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({plan:e})})).json()}}function yv(e){let t=(0,Q.c)(45),{open:n,onOpenChange:r,onSeedApplied:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a={kind:`loading`},t[0]=a):a=t[0];let[o,s]=(0,Z.useState)(a),[c,l]=(0,Z.useState)(`project-root`),[u,d]=(0,Z.useState)(`brain`),f=(0,Z.useRef)(!0),p,m;t[1]===n?(p=t[2],m=t[3]):(p=()=>{n&&(l(`project-root`),d(`brain`),f.current=!0)},m=[n],t[1]=n,t[2]=p,t[3]=m),(0,Z.useEffect)(p,m);let h;t[4]===u?h=t[5]:(h=u.trim(),t[4]=u,t[5]=h);let g=h,_=c===`subfolder`&&g===``,v,y;t[6]!==n||t[7]!==c||t[8]!==_||t[9]!==g?(v=()=>{if(!n)return;if(_){s({kind:`error`,message:`Enter a folder name (e.g. brain).`});return}let e=c===`project-root`?void 0:g,t=f.current?0:200;f.current=!1;let r=!1,i=setTimeout(()=>{r||(s(bv),vv().plan(e).then(e=>{if(!r){if(!e.ok){s({kind:`error`,message:e.error.message});return}s(e.plan.created.length>0||e.plan.configEdits.length>0?{kind:`plan`,plan:e.plan}:{kind:`already-seeded`,plan:e.plan})}}).catch(e=>{r||s({kind:`error`,message:e instanceof Error?e.message:String(e)})}))},t);return()=>{r=!0,clearTimeout(i)}},y=[n,c,g,_],t[6]=n,t[7]=c,t[8]=_,t[9]=g,t[10]=v,t[11]=y):(v=t[10],y=t[11]),(0,Z.useEffect)(v,y);let b;t[12]!==r||t[13]!==i||t[14]!==o.kind||t[15]!==o.plan?(b=async function(){if(o.kind!==`plan`)return;s({kind:`applying`,plan:o.plan});let e=await vv().apply(o.plan);e.ok?(Ar.success(`LLM brain initialized (${e.result.applied} ${e.result.applied===1?`entry`:`entries`})`),i?.(),r(!1)):(Ar.error(`Initialize failed: ${e.error.message}`),s({kind:`error`,message:e.error.message}))},t[12]=r,t[13]=i,t[14]=o.kind,t[15]=o.plan,t[16]=b):b=t[16];let x=b,S;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,X.jsxs)(Er,{children:[(0,X.jsxs)(hr,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Yn,{"aria-hidden":`true`,className:`h-4 w-4 text-foreground opacity-70`}),`Initialize LLM brain`]}),(0,X.jsx)(pr,{children:`Three layers designed so AI agents can navigate naturally: raw sources, working drafts, and canonical articles.`})]}),t[17]=S):S=t[17];let C;t[18]!==c||t[19]!==u?(C=(0,X.jsx)(xv,{choice:c,subfolder:u,onChoiceChange:l,onSubfolderChange:d}),t[18]=c,t[19]=u,t[20]=C):C=t[20];let w;t[21]===o?w=t[22]:(w=(0,X.jsx)(Sv,{phase:o}),t[21]=o,t[22]=w);let T;t[23]!==w||t[24]!==C?(T=(0,X.jsxs)(Sr,{className:`space-y-6`,children:[C,w]}),t[23]=w,t[24]=C,t[25]=T):T=t[25];let E;t[26]===r?E=t[27]:(E=()=>r(!1),t[26]=r,t[27]=E);let D=o.kind===`already-seeded`||o.kind===`error`?`Close`:`Cancel`,O;t[28]!==E||t[29]!==D?(O=(0,X.jsx)(J,{className:`uppercase font-mono`,variant:`ghost`,onClick:E,children:D}),t[28]=E,t[29]=D,t[30]=O):O=t[30];let k;t[31]!==x||t[32]!==o.kind||t[33]!==_?(k=o.kind===`plan`?(0,X.jsx)(J,{onClick:x,disabled:_,children:`Initialize`}):o.kind===`applying`?(0,X.jsxs)(J,{disabled:!0,children:[(0,X.jsx)(Rn,{"aria-hidden":`true`,className:`h-4 w-4 animate-spin`}),`Setting up…`]}):null,t[31]=x,t[32]=o.kind,t[33]=_,t[34]=k):k=t[34];let A;t[35]!==O||t[36]!==k?(A=(0,X.jsxs)(Cr,{children:[O,k]}),t[35]=O,t[36]=k,t[37]=A):A=t[37];let j;t[38]!==T||t[39]!==A?(j=(0,X.jsxs)(yr,{className:`sm:max-w-2xl`,"data-ok-layer-spawned":``,children:[S,T,A]}),t[38]=T,t[39]=A,t[40]=j):j=t[40];let M;return t[41]!==r||t[42]!==n||t[43]!==j?(M=(0,X.jsx)(Dr,{open:n,onOpenChange:r,children:j}),t[41]=r,t[42]=n,t[43]=j,t[44]=M):M=t[44],M}function bv(e){return e.kind===`plan`||e.kind===`already-seeded`?e:{kind:`loading`}}function xv(e){let t=(0,Q.c)(21),{choice:n,subfolder:r,onChoiceChange:i,onSubfolderChange:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,X.jsx)(`p`,{className:`text-sm font-medium`,children:`Where should the brain live?`}),t[0]=o):o=t[0];let s;t[1]===i?s=t[2]:(s=e=>i(e),t[1]=i,t[2]=s);let c;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,X.jsx)(pv,{htmlFor:`seed-root-project-root`,children:(0,X.jsxs)(dv,{orientation:`horizontal`,children:[(0,X.jsxs)(fv,{children:[(0,X.jsx)(mv,{children:`Project root`}),(0,X.jsx)(hv,{children:`Scaffold the three folders directly under this project.`})]}),(0,X.jsx)(_v,{value:`project-root`,id:`seed-root-project-root`})]})}),t[3]=c):c=t[3];let l,u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,X.jsx)(mv,{children:`In a subfolder`}),u=(0,X.jsx)(hv,{className:`nth-last-2:mt-0`,children:`Created if missing. Reuses the folder if it already exists.`}),t[4]=l,t[5]=u):(l=t[4],u=t[5]);let d;t[6]===a?d=t[7]:(d=e=>a(e.target.value),t[6]=a,t[7]=d);let f;t[8]===i?f=t[9]:(f=()=>i(`subfolder`),t[8]=i,t[9]=f);let p;t[10]!==r||t[11]!==d||t[12]!==f?(p=(0,X.jsxs)(fv,{children:[l,u,(0,X.jsx)(zt,{value:r,onChange:d,onFocus:f,placeholder:`brain`,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,className:`mt-1.5 font-mono text-xs bg-background`})]}),t[10]=r,t[11]=d,t[12]=f,t[13]=p):p=t[13];let m;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,X.jsx)(_v,{value:`subfolder`,id:`seed-root-subfolder`}),t[14]=m):m=t[14];let h;t[15]===p?h=t[16]:(h=(0,X.jsx)(pv,{htmlFor:`seed-root-subfolder`,children:(0,X.jsxs)(dv,{orientation:`horizontal`,children:[p,m]})}),t[15]=p,t[16]=h);let g;return t[17]!==n||t[18]!==h||t[19]!==s?(g=(0,X.jsxs)(`div`,{className:`space-y-2 py-1`,children:[o,(0,X.jsxs)(gv,{className:`sm:flex`,value:n,onValueChange:s,children:[c,h]})]}),t[17]=n,t[18]=h,t[19]=s,t[20]=g):g=t[20],g}function Sv(e){let t=(0,Q.c)(11),{phase:n}=e;if(n.kind===`loading`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsxs)(`div`,{className:`flex items-center gap-2 py-4 text-sm text-muted-foreground`,children:[(0,X.jsx)(Rn,{"aria-hidden":`true`,className:`h-4 w-4 animate-spin`}),`Computing scaffold plan…`]}),t[0]=e):e=t[0],e}if(n.kind===`error`){let e;return t[1]===n.message?e=t[2]:(e=(0,X.jsx)(`div`,{className:`rounded-md bg-destructive/10 p-3 text-sm text-destructive`,children:n.message}),t[1]=n.message,t[2]=e),e}if(n.kind===`already-seeded`){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsxs)(`div`,{className:`py-2 text-sm`,children:[(0,X.jsx)(`p`,{className:`font-medium`,children:`This LLM brain is already set up.`}),(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:`The three-layer structure is in place — there's nothing left to scaffold.`})]}),t[3]=e):e=t[3],e}let r=n.plan,i;t[4]===r?i=t[5]:(i=(0,X.jsx)(Ov,{plan:r}),t[4]=r,t[5]=i);let a;t[6]===r.warnings?a=t[7]:(a=r.warnings.length>0?(0,X.jsx)(`div`,{className:`rounded-md bg-warning/10 p-3 text-xs text-warning-foreground`,children:r.warnings.map(Cv)}):null,t[6]=r.warnings,t[7]=a);let o;return t[8]!==i||t[9]!==a?(o=(0,X.jsxs)(`div`,{className:`space-y-6 py-1 text-sm`,children:[i,a]}),t[8]=i,t[9]=a,t[10]=o):o=t[10],o}function Cv(e){return(0,X.jsx)(`p`,{children:e},e)}var wv=[{name:`external-sources`,blurb:`Raw sources saved verbatim — full text of URLs and PDFs, not just citations. Every claim traces back to preserved evidence.`},{name:`research`,blurb:`Provisional analysis synthesizing sources. Every claim cites a doc; promotes to articles/ once the team trusts the findings.`},{name:`articles`,blurb:`Canonical decisions. Each links back through research/ to its sources — no dead links, full evidence chain in repo.`}],Tv={"log.md":`Append-only timeline`};function Ev(e){return e.split(`/`).pop()??e}function Dv(e){let t=new Map(wv.map(e=>[e.name,e.blurb])),n=e.created.filter(e=>e.kind===`folder`).map(e=>({kind:`folder`,name:`${e.path}/`,description:t.get(Ev(e.path))??``})),r=e.created.filter(e=>e.kind===`file`).map(e=>({kind:`file`,name:e.path,description:Tv[Ev(e.path)]??``})),i=e.configEdits.length>0?[{kind:`config`,name:`.open-knowledge/config.yml`,description:`Folder descriptions for AI agents`}]:[];return[...n,...r,...i]}function Ov(e){let t=(0,Q.c)(13),{plan:n}=e,r,i,a,o;if(t[0]!==n){let e=Dv(n);a=`space-y-3`,t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,X.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase font-mono tracking-wider text-primary`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`flex items-center justify-center`,children:`◇`}),`What gets created`]}),t[5]=o):o=t[5],r=`space-y-3 overflow-y-auto subtle-scrollbar max-h-full`,i=e.map(kv),t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o}else r=t[1],i=t[2],a=t[3],o=t[4];let s;t[6]!==r||t[7]!==i?(s=(0,X.jsx)(`ul`,{className:r,children:i}),t[6]=r,t[7]=i,t[8]=s):s=t[8];let c;return t[9]!==a||t[10]!==o||t[11]!==s?(c=(0,X.jsxs)(`section`,{className:a,children:[o,s]}),t[9]=a,t[10]=o,t[11]=s,t[12]=c):c=t[12],c}function kv(e){return(0,X.jsxs)(`li`,{className:`flex items-start gap-3 rounded-md border border-border/60 bg-muted/20 p-3`,children:[e.kind===`folder`?(0,X.jsx)($i,{"aria-hidden":`true`,className:`mt-1 h-4 w-4 shrink-0 text-muted-foreground`,strokeWidth:1.5}):e.kind===`config`?(0,X.jsx)(Ji,{"aria-hidden":`true`,className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`,strokeWidth:1.5}):(0,X.jsx)(Yi,{"aria-hidden":`true`,className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`,strokeWidth:1.5}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,X.jsx)(`code`,{className:`font-mono text-1sm`,children:e.name}),e.description?(0,X.jsx)(`p`,{className:`text-1sm text-muted-foreground`,children:e.description}):null]})]},e.name)}function Av(){let e=(0,Q.c)(15),[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(`loading`),[s,c]=(0,Z.useState)(0),l=(0,Z.useRef)(!1),u=(0,Z.useRef)(void 0),d,f;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{let e=!1,t=async function(){let t=fetch(`/api/documents`).then(async t=>{let n=await t.json().catch(Fv);e||(t.ok&&n?.ok&&Array.isArray(n.documents)?(i(n.documents.length),l.current=!0):l.current||=(i(1),!0))}).catch(()=>{!e&&!l.current&&(i(1),l.current=!0)}),n=(async()=>{let t=typeof window<`u`?window.okDesktop:void 0;try{let n=t?.seed?await t.seed.plan():await fetch(`/api/seed/plan`).then(Pv);if(e)return;if(!n?.ok){o(`error`);return}o(n.plan.created.length>0||n.plan.configEdits.length>0?`has-work`:`seeded`)}catch{e||o(`error`)}})();await Promise.all([t,n])};t();let n=We(e=>{e.includes(`files`)&&t()});return()=>{e=!0,n(),clearTimeout(u.current)}},f=[],e[0]=d,e[1]=f):(d=e[0],f=e[1]),(0,Z.useEffect)(d,f);let p;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=function(){clearTimeout(u.current),u.current=setTimeout(()=>c(Nv),250),o(`seeded`),fetch(`/api/documents`).then(async e=>{let t=await e.json().catch(Mv);e.ok&&t?.ok&&Array.isArray(t.documents)&&i(t.documents.length)}).catch(jv)},e[2]=p):p=e[2];let m=p,h=a===`has-work`,g=r!==null&&a!==`loading`,_=r===0,v;e[3]===s?v=e[4]:(v=(0,X.jsx)(rv,{size:80,celebrateSignal:s}),e[3]=s,e[4]=v);let y;e[5]!==_||e[6]!==g||e[7]!==h?(y=g?_?(0,X.jsx)(Iv,{onCtaClick:()=>n(!0),showCta:h}):(0,X.jsx)(Lv,{onCtaClick:()=>n(!0),showCta:h}):null,e[5]=_,e[6]=g,e[7]=h,e[8]=y):y=e[8];let b;e[9]===t?b=e[10]:(b=(0,X.jsx)(yv,{open:t,onOpenChange:n,onSeedApplied:m}),e[9]=t,e[10]=b);let x;return e[11]!==v||e[12]!==y||e[13]!==b?(x=(0,X.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-6 px-6`,children:[v,y,b]}),e[11]=v,e[12]=y,e[13]=b,e[14]=x):x=e[14],x}function jv(){}function Mv(){return null}function Nv(e){return e+1}function Pv(e){return e.json()}function Fv(){return null}function Iv(e){let t=(0,Q.c)(7),{onCtaClick:n,showCta:r}=e,i,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,X.jsx)(`h2`,{className:`text-base font-medium`,children:`Welcome to your LLM brain`}),a=(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`A space for working with AI agents. Start with a curated layer structure — or create your own files in the sidebar.`}),t[0]=i,t[1]=a):(i=t[0],a=t[1]);let o;t[2]!==n||t[3]!==r?(o=r?(0,X.jsxs)(J,{className:`mt-1`,onClick:n,children:[(0,X.jsx)(Yn,{"aria-hidden":`true`,className:`h-4 w-4`}),`Initialize LLM brain`]}):null,t[2]=n,t[3]=r,t[4]=o):o=t[4];let s;return t[5]===o?s=t[6]:(s=(0,X.jsxs)(`div`,{className:`flex max-w-sm flex-col items-center gap-3 text-center`,children:[i,a,o]}),t[5]=o,t[6]=s),s}function Lv(e){let t=(0,Q.c)(6),{onCtaClick:n,showCta:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,X.jsx)(`span`,{className:`select-none text-sm text-muted-foreground`,children:`Select a document to edit`}),t[0]=i):i=t[0];let a;t[1]!==n||t[2]!==r?(a=r?(0,X.jsxs)(J,{variant:`ghost`,size:`sm`,className:`uppercase font-mono text-xs`,onClick:n,children:[(0,X.jsx)(Yn,{"aria-hidden":`true`,className:`h-3.5 w-3.5`}),`Initialize LLM brain`]}):null,t[1]=n,t[2]=r,t[3]=a):a=t[3];let o;return t[4]===a?o=t[5]:(o=(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[i,a]}),t[4]=a,t[5]=o),o}function Rv(e){let t=e.split(`/`).pop();return t?`${e}/${t}`:null}function zv(e,t){let n=t.get(`${e}/index`);if(n)return n;let r=Rv(e);if(r){let e=t.get(r);if(e)return e}return e.split(`/`).pop()??e}function Bv(e,t,n){let r=n.get(e);return r&&r!==e?r:t}function Vv(e,t){let n=`${e}/`,r=[...t.folderPaths].filter(e=>e.startsWith(n)).map(e=>({path:e,rel:e.slice(n.length)})).filter(e=>e.rel.length>0&&!e.rel.includes(`/`)).map(({path:e,rel:n})=>({kind:`folder`,path:e,name:n,title:zv(e,t.pageTitles)})),i=[...t.pages].filter(e=>e.startsWith(n)).map(e=>({docName:e,rel:e.slice(n.length)})).filter(e=>e.rel.length>0&&!e.rel.includes(`/`)).map(({docName:e,rel:n})=>{let r=t.pageMeta.get(e);return{kind:`file`,path:e,name:n,title:Bv(e,n,t.pageTitles),size:r?.size??0,modified:r?.modified??``}}),a=[...r,...i].sort((e,t)=>e.kind===t.kind?e.title.localeCompare(t.title)||e.name.localeCompare(t.name):e.kind===`folder`?-1:1);return{title:zv(e,t.pageTitles),children:a}}function Hv(e){let t=(0,Q.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,X.jsx)(gc,{"data-slot":`dropdown-menu`,...n}),t[2]=n,t[3]=r),r}function Uv(e){let t=(0,Q.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,X.jsx)(_c,{"data-slot":`dropdown-menu-trigger`,...n}),t[2]=n,t[3]=r),r}function Wv(e){let t=(0,Q.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,align:i,sideOffset:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=i===void 0?`start`:i,s=a===void 0?4:a,c;t[5]===n?c=t[6]:(c=q(`z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:overflow-hidden data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n),t[5]=n,t[6]=c);let l;return t[7]!==o||t[8]!==r||t[9]!==s||t[10]!==c?(l=(0,X.jsx)(vc,{children:(0,X.jsx)(yc,{"data-slot":`dropdown-menu-content`,sideOffset:s,align:o,className:c,...r})}),t[7]=o,t[8]=r,t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function Gv(e){let t=(0,Q.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,inset:r,variant:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?`default`:a,s;t[5]===n?s=t[6]:(s=q(`group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive`,n),t[5]=n,t[6]=s);let c;return t[7]!==r||t[8]!==i||t[9]!==s||t[10]!==o?(c=(0,X.jsx)(xc,{"data-slot":`dropdown-menu-item`,"data-inset":r,"data-variant":o,className:s,...i}),t[7]=r,t[8]=i,t[9]=s,t[10]=o,t[11]=c):c=t[11],c}function Kv(e){let t=(0,Q.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,X.jsx)(Sc,{"data-slot":`dropdown-menu-radio-group`,...n}),t[2]=n,t[3]=r),r}function qv(e){let t=(0,Q.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,children:n,inset:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===r?o=t[6]:(o=q(`relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,r),t[5]=r,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,X.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex items-center justify-center`,"data-slot":`dropdown-menu-radio-item-indicator`,children:(0,X.jsx)(wc,{children:(0,X.jsx)(ar,{})})}),t[7]=s):s=t[7];let c;return t[8]!==n||t[9]!==i||t[10]!==a||t[11]!==o?(c=(0,X.jsxs)(Cc,{"data-slot":`dropdown-menu-radio-item`,"data-inset":i,className:o,...a,children:[s,n]}),t[8]=n,t[9]=i,t[10]=a,t[11]=o,t[12]=c):c=t[12],c}function Jv(e){let t=(0,Q.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,inset:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=q(`px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==i||t[8]!==a?(o=(0,X.jsx)(bc,{"data-slot":`dropdown-menu-label`,"data-inset":r,className:a,...i}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function Yv(e){let t=(0,Q.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=q(`-mx-1 my-1 h-px bg-border`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(Tc,{"data-slot":`dropdown-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Xv(e){let t=(0,Q.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,X.jsx)(Ec,{"data-slot":`dropdown-menu-sub`,...n}),t[2]=n,t[3]=r),r}function Zv(e){let t=(0,Q.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,inset:i,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===r?o=t[6]:(o=q(`flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,r),t[5]=r,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,X.jsx)(gn,{className:`ml-auto`}),t[7]=s):s=t[7];let c;return t[8]!==n||t[9]!==i||t[10]!==a||t[11]!==o?(c=(0,X.jsxs)(Dc,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":i,className:o,...a,children:[n,s]}),t[8]=n,t[9]=i,t[10]=a,t[11]=o,t[12]=c):c=t[12],c}function Qv(e){let t=(0,Q.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=q(`z-50 min-w-[96px] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-lg bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(Oc,{"data-slot":`dropdown-menu-sub-content`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function $v(e){let t=(0,Q.c)(14),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,containerClassName:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=q(`relative w-full overflow-x-auto subtle-scrollbar`,r),t[4]=r,t[5]=a);let o;t[6]===n?o=t[7]:(o=q(`w-full caption-bottom text-sm`,n),t[6]=n,t[7]=o);let s;t[8]!==i||t[9]!==o?(s=(0,X.jsx)(`table`,{"data-slot":`table`,className:o,...i}),t[8]=i,t[9]=o,t[10]=s):s=t[10];let c;return t[11]!==a||t[12]!==s?(c=(0,X.jsx)(`div`,{"data-slot":`table-container`,className:a,children:s}),t[11]=a,t[12]=s,t[13]=c):c=t[13],c}function ey(e){let t=(0,Q.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=q(`[&_tr]:border-b`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(`thead`,{"data-slot":`table-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function ty(e){let t=(0,Q.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=q(`[&_tr:last-child]:border-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(`tbody`,{"data-slot":`table-body`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function ny(e){let t=(0,Q.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,noHover:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=(i===void 0?!1:i)&&`hover:bg-transparent`,o;t[4]!==n||t[5]!==a?(o=q(`hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors`,a,n),t[4]=n,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==o?(s=(0,X.jsx)(`tr`,{"data-slot":`table-row`,className:o,...r}),t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function ry(e){let t=(0,Q.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,scope:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`col`:i,o;t[4]===n?o=t[5]:(o=q(`font-mono uppercase text-xs text-muted-foreground h-10 px-4 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,n),t[4]=n,t[5]=o);let s;return t[6]!==r||t[7]!==a||t[8]!==o?(s=(0,X.jsx)(`th`,{"data-slot":`table-head`,scope:a,className:o,...r}),t[6]=r,t[7]=a,t[8]=o,t[9]=s):s=t[9],s}function iy(e){let t=(0,Q.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=q(`py-3 px-4 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(`td`,{"data-slot":`table-cell`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function ay(e){if(!e)return`—`;let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<30?`${a}d ago`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function oy(e,t,n){return[...e].sort((e,r)=>{if(e.kind!==r.kind)return e.kind===`folder`?-1:1;let i=0;switch(t){case`name`:i=e.title.localeCompare(r.title)||e.name.localeCompare(r.name);break;case`modified`:{let t=e.kind===`file`?e.modified:``,n=r.kind===`file`?r.modified:``;i=t.localeCompare(n);break}}return n===`asc`?i:-i})}function sy(e){let t=(0,Q.c)(10),{label:n,sortKey:r,activeKey:i,activeDir:a,onSort:o}=e,s=i===r,c;t[0]!==o||t[1]!==r?(c=()=>o(r),t[0]=o,t[1]=r,t[2]=c):c=t[2];let l;t[3]!==a||t[4]!==s?(l=s?a===`asc`?(0,X.jsx)(Bt,{className:`ml-1 size-3`}):(0,X.jsx)(Wt,{className:`ml-1 size-3`}):(0,X.jsx)(Ei,{className:`ml-1 size-3 text-muted-foreground/50`}),t[3]=a,t[4]=s,t[5]=l):l=t[5];let u;return t[6]!==n||t[7]!==c||t[8]!==l?(u=(0,X.jsxs)(J,{variant:`ghost`,size:`sm`,className:`-ml-3 h-8 uppercase font-mono`,onClick:c,children:[n,l]}),t[6]=n,t[7]=c,t[8]=l,t[9]=u):u=t[9],u}function cy(e){let t=(0,Q.c)(87),{folderPath:n}=e,{addPage:r,folderPaths:i,loading:a,pages:o,pageTitles:s,pageMeta:c}=Pe(),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(`name`),[_,v]=(0,Z.useState)(`asc`);if(a){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(nr,{className:`size-5 rounded`}),(0,X.jsx)(nr,{className:`h-7 w-48`})]}),(0,X.jsx)(nr,{className:`h-9 w-20 rounded-md`})]}),t[0]=e):e=t[0];let n;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,X.jsx)(nr,{className:`h-4 w-16`}),t[1]=n):n=t[1];let r;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start overflow-y-auto subtle-scrollbar`,role:`status`,"aria-busy":`true`,"aria-label":`Loading folder contents`,children:(0,X.jsxs)(`div`,{className:`mx-auto flex w-full max-w-4xl flex-col gap-6 px-6 py-8`,children:[e,(0,X.jsxs)(`div`,{className:`rounded-lg border`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-4 border-b px-4 py-3`,children:[n,(0,X.jsx)(`div`,{className:`ml-auto`,children:(0,X.jsx)(nr,{className:`h-4 w-20`})})]}),[`a`,`b`,`c`,`d`].map(fy)]})]})}),t[2]=r):r=t[2],r}let y,b,x,S,C,w,T,E;if(t[3]!==r||t[4]!==p||t[5]!==d||t[6]!==n||t[7]!==i||t[8]!==c||t[9]!==s||t[10]!==o||t[11]!==_||t[12]!==h){let e=Vv(n,{pages:o,pageTitles:s,pageMeta:c,folderPaths:i}),a=oy(e.children,h,_),l;t[21]===h?l=t[22]:(l=function(e){e===h?v(dy):(g(e),v(`asc`))},t[21]=h,t[22]=l);let D=l,O;t[23]!==r||t[24]!==n?(O=async function(){f(!0),m(null);try{let e=`${n}/index.md`,t=await fetch(`/api/create-page`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e})}),i=await t.json().catch(uy);if(!t.ok||!i?.ok){m(i?.error??`Server error (HTTP ${t.status})`),f(!1);return}let a=i.docName??`${n}/index`;r(a),we([`files`,`backlinks`,`graph`]),window.location.hash=$e(a)}catch(e){console.warn(`[FolderOverview] create index note failed:`,e),m(`Network error — please try again`)}f(!1)},t[23]=r,t[24]=n,t[25]=O):O=t[25];let k=O;E=`flex min-h-0 flex-1 items-start overflow-y-auto subtle-scrollbar`,w=`mx-auto flex w-full max-w-4xl flex-col gap-6 px-6 py-8`;let A;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,X.jsx)(Ot,{className:`size-5 text-muted-foreground`}),t[26]=A):A=t[26];let j=(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[A,(0,X.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:e.title})]}),M;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,X.jsx)(xa,{className:`size-4`}),t[27]=M):M=t[27];let N;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,X.jsx)(Uv,{asChild:!0,children:(0,X.jsxs)(J,{children:[M,`New`,(0,X.jsx)(Rt,{className:`size-3`})]})}),t[28]=N):N=t[28];let P;t[29]===k?P=t[30]:(P=()=>void k(),t[29]=k,t[30]=P);let F;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`font-medium`,children:`Index note`}),(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Landing page for this folder`})]}),t[31]=F):F=t[31];let I;t[32]!==d||t[33]!==P?(I=(0,X.jsx)(Gv,{disabled:d,onSelect:P,children:F}),t[32]=d,t[33]=P,t[34]=I):I=t[34];let L;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,X.jsx)(Gv,{onSelect:()=>u(!0),children:(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`font-medium`,children:`Note`}),(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`New note inside this folder`})]})}),t[35]=L):L=t[35];let R;t[36]===I?R=t[37]:(R=(0,X.jsxs)(Hv,{children:[N,(0,X.jsxs)(Wv,{align:`end`,children:[I,L]})]}),t[36]=I,t[37]=R);let z;t[38]!==j||t[39]!==R?(z=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[j,R]}),t[38]=j,t[39]=R,t[40]=z):z=t[40];let B;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This folder has no landing note yet. Choose an explicit action to add one or open a note inside the folder.`}),t[41]=B):B=t[41];let V;t[42]===p?V=t[43]:(V=p?(0,X.jsx)(`span`,{role:`alert`,className:`text-sm text-destructive`,children:p}):null,t[42]=p,t[43]=V),t[44]!==z||t[45]!==V?(T=(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[z,B,V]}),t[44]=z,t[45]=V,t[46]=T):T=t[46],C=`rounded-lg border`,b=$v;let H=h===`name`?_===`asc`?`ascending`:`descending`:`none`,U;t[47]!==D||t[48]!==_||t[49]!==h?(U=(0,X.jsx)(sy,{label:`Name`,sortKey:`name`,activeKey:h,activeDir:_,onSort:D}),t[47]=D,t[48]=_,t[49]=h,t[50]=U):U=t[50];let W;t[51]!==H||t[52]!==U?(W=(0,X.jsx)(ry,{"aria-sort":H,children:U}),t[51]=H,t[52]=U,t[53]=W):W=t[53];let G=h===`modified`?_===`asc`?`ascending`:`descending`:`none`,ee;t[54]!==D||t[55]!==_||t[56]!==h?(ee=(0,X.jsx)(sy,{label:`Modified`,sortKey:`modified`,activeKey:h,activeDir:_,onSort:D}),t[54]=D,t[55]=_,t[56]=h,t[57]=ee):ee=t[57];let K;t[58]!==G||t[59]!==ee?(K=(0,X.jsx)(ry,{className:`w-32`,"aria-sort":G,children:ee}),t[58]=G,t[59]=ee,t[60]=K):K=t[60],t[61]!==W||t[62]!==K?(S=(0,X.jsx)(ey,{children:(0,X.jsxs)(ny,{children:[W,K]})}),t[61]=W,t[62]=K,t[63]=S):S=t[63],y=ty,x=a.length?a.map(ly):(0,X.jsx)(ny,{children:(0,X.jsx)(iy,{colSpan:2,className:`h-24 text-center text-muted-foreground`,children:`This folder is empty.`})}),t[3]=r,t[4]=p,t[5]=d,t[6]=n,t[7]=i,t[8]=c,t[9]=s,t[10]=o,t[11]=_,t[12]=h,t[13]=y,t[14]=b,t[15]=x,t[16]=S,t[17]=C,t[18]=w,t[19]=T,t[20]=E}else y=t[13],b=t[14],x=t[15],S=t[16],C=t[17],w=t[18],T=t[19],E=t[20];let D;t[64]!==y||t[65]!==x?(D=(0,X.jsx)(y,{children:x}),t[64]=y,t[65]=x,t[66]=D):D=t[66];let O;t[67]!==b||t[68]!==S||t[69]!==D?(O=(0,X.jsxs)(b,{children:[S,D]}),t[67]=b,t[68]=S,t[69]=D,t[70]=O):O=t[70];let k;t[71]!==C||t[72]!==O?(k=(0,X.jsx)(`div`,{className:C,children:O}),t[71]=C,t[72]=O,t[73]=k):k=t[73];let A;t[74]!==w||t[75]!==T||t[76]!==k?(A=(0,X.jsxs)(`div`,{className:w,children:[T,k]}),t[74]=w,t[75]=T,t[76]=k,t[77]=A):A=t[77];let j;t[78]!==A||t[79]!==E?(j=(0,X.jsx)(`div`,{className:E,children:A}),t[78]=A,t[79]=E,t[80]=j):j=t[80];let M;t[81]!==l||t[82]!==n?(M=(0,X.jsx)(hn,{open:l,onOpenChange:u,kind:`file`,initialDir:n}),t[81]=l,t[82]=n,t[83]=M):M=t[83];let N;return t[84]!==j||t[85]!==M?(N=(0,X.jsxs)(X.Fragment,{children:[j,M]}),t[84]=j,t[85]=M,t[86]=N):N=t[86],N}function ly(e){return(0,X.jsxs)(ny,{children:[(0,X.jsx)(iy,{children:(0,X.jsxs)(`a`,{href:$e(e.path),className:`flex items-center gap-2 rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[e.kind===`folder`?(0,X.jsx)($i,{className:`size-4 shrink-0 text-muted-foreground`}):(0,X.jsx)(Ht,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsx)(`span`,{className:`truncate`,children:e.title})]})}),(0,X.jsx)(iy,{className:`text-muted-foreground`,children:e.kind===`file`?ay(e.modified):`—`})]},e.path)}function uy(){return null}function dy(e){return e===`asc`?`desc`:`asc`}function fy(e){return(0,X.jsxs)(`div`,{className:`flex items-center gap-3 border-b px-4 py-3 last:border-b-0`,children:[(0,X.jsx)(nr,{className:`size-4 rounded`}),(0,X.jsx)(nr,{className:`h-4 w-40`}),(0,X.jsx)(`div`,{className:`ml-auto`,children:(0,X.jsx)(nr,{className:`h-4 w-16`})})]},e)}function py(e){let t=(0,Q.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=q(`flex h-full w-full aria-[orientation=vertical]:flex-col`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(T_,{"data-slot":`resizable-panel-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function my(e){let t=(0,Q.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,X.jsx)(O_,{"data-slot":`resizable-panel`,...n}),t[2]=n,t[3]=r),r}function hy(e){let t=(0,Q.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({withHandle:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=q(`relative flex w-px items-center justify-center bg-border ring-offset-background after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90`,n),t[4]=n,t[5]=a);let o;t[6]===i?o=t[7]:(o=i&&(0,X.jsx)(`div`,{className:`z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border`}),t[6]=i,t[7]=o);let s;return t[8]!==r||t[9]!==a||t[10]!==o?(s=(0,X.jsx)(M_,{"data-slot":`resizable-handle`,className:a,...r,children:o}),t[8]=r,t[9]=a,t[10]=o,t[11]=s):s=t[11],s}var gy=960,_y=1024;function vy(){let e=(0,Q.c)(5),[t,n]=(0,Z.useState)(by),[r,i]=(0,Z.useState)(yy),a,o;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{let e=window.matchMedia(`(max-width: ${gy-1}px)`),t=window.matchMedia(`(max-width: ${_y-1}px)`),r=()=>{let r=e.matches;n(r?`sheet`:`panel`),i(!r&&t.matches)};return e.addEventListener(`change`,r),t.addEventListener(`change`,r),()=>{e.removeEventListener(`change`,r),t.removeEventListener(`change`,r)}},o=[],e[0]=a,e[1]=o):(a=e[0],o=e[1]),(0,Z.useEffect)(a,o);let s;return e[2]!==r||e[3]!==t?(s={layout:t,autoCollapse:r},e[2]=r,e[3]=t,e[4]=s):s=e[4],s}function yy(){return window.innerWidth>=gy&&window.innerWidth<_y}function by(){return window.innerWidth<gy?`sheet`:`panel`}var xy={words:0,chars:0,tokens:0},Sy=/[ -〿぀-ゟ゠-ヿ㐀-䶿一-鿿豈-﫿＀-￯฀-๿ក-៿]/,Cy=/[\p{L}\p{N}]/u;function wy(e){if(!e)return 0;let t=0;for(let n of e.split(/\s+/))Cy.test(n)&&t++;return t}function Ty(e){let t=globalThis.Intl.Segmenter;if(!t)return wy(e);let n=new t(void 0,{granularity:`word`}),r=0;for(let t of n.segment(e))t.isWordLike&&r++;return r}function Ey(e){let t=Sy.test(e)?1.5:4;return Math.ceil(e.length/t)}function Dy(e){if(!e)return{words:0,chars:0,tokens:0};let{body:t}=ue(e),n=t.trim();return n?{words:Sy.test(n)?Ty(n):wy(n),chars:n.length,tokens:Ey(n)}:{words:0,chars:0,tokens:0}}var Oy=300;function ky(e,t){let n=(0,Q.c)(4),[r,i]=(0,Z.useState)(xy),a,o;return n[0]!==t||n[1]!==e?(a=()=>{if(!e||!t){i(xy);return}let n=e.document.getText(`source`),r=!1,a=null,o=function(){r||i(Dy(n.toString()))};o();let s=function(){a&&clearTimeout(a),a=setTimeout(o,Oy)};return n.observe(s),()=>{r=!0,n.unobserve(s),a&&clearTimeout(a)}},o=[e,t],n[0]=t,n[1]=e,n[2]=a,n[3]=o):(a=n[2],o=n[3]),(0,Z.useEffect)(a,o),r}var Ay=K;function jy(e,t={}){let n=zn(e.componentName);return n.name===`*`?t.unregisteredSuffix?`${e.componentName} (unregistered)`:e.componentName:n.displayName??n.name}var My=4;function Ny(e){let t=(0,Q.c)(8),{editor:n}=e,r=Fn(n),i=!!(n&&r&&r.ancestorChain.length>0),a=i?void 0:`true`,o=`jsx-component-breadcrumb flex items-center gap-1 min-h-[28px] px-3 py-1.5 text-xs font-mono text-muted-foreground overflow-hidden ${i?`border-t border-border`:``}`,s;t[0]!==r||t[1]!==n||t[2]!==i?(s=i&&r?(0,X.jsx)(Fy,{editor:n,blockSelection:r}):null,t[0]=r,t[1]=n,t[2]=i,t[3]=s):s=t[3];let c;return t[4]!==a||t[5]!==o||t[6]!==s?(c=(0,X.jsx)(`nav`,{"aria-label":`Block ancestor navigation`,"aria-hidden":a,className:o,children:s}),t[4]=a,t[5]=o,t[6]=s,t[7]=c):c=t[7],c}function Py(e,t){let n=It.getState(e.state)?.posToId;if(!n)return t.pos;for(let[e,r]of n)if(r===t.bridgeId)return e;return null}function Fy(e){let t=(0,Q.c)(9),{editor:n,blockSelection:r}=e,{ancestorChain:i,selectedBlockId:a}=r,o;if(t[0]!==i||t[1]!==n||t[2]!==a){let e=Ry(i),r;t[4]===n?r=t[5]:(r=(0,X.jsx)(`button`,{type:`button`,className:`opacity-60 hover:opacity-100 hover:text-foreground transition-opacity outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm`,onClick:()=>{n.chain().focus().setTextSelection(0).command(Ly).run()},children:Tt}),t[4]=n,t[5]=r);let s;t[6]!==n||t[7]!==a?(s=e=>{if(e.kind===`ellipsis`)return(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(gn,{size:12,className:`opacity-50`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{role:`img`,"aria-label":`${e.hiddenCount} hidden ancestors`,title:`${e.hiddenCount} hidden ancestors`,className:`opacity-60`,children:`…`})]},`ellipsis`);let t=jy(e.entry),r=e.entry.bridgeId===a;return(0,X.jsxs)(`span`,{className:`flex items-center gap-1 min-w-0`,children:[(0,X.jsx)(gn,{size:12,className:`opacity-50 shrink-0`,"aria-hidden":`true`}),r?(0,X.jsx)(`span`,{"aria-current":`location`,className:`text-foreground truncate`,children:t}):(0,X.jsx)(`button`,{type:`button`,className:`hover:text-foreground transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm truncate`,onClick:()=>{let t=Py(n,e.entry);t!==null&&n.chain().focus().setNodeSelection(t).command(Iy).run()},children:t})]},e.entry.bridgeId)},t[6]=n,t[7]=a,t[8]=s):s=t[8],o=(0,X.jsxs)(X.Fragment,{children:[r,e.map(s)]}),t[0]=i,t[1]=n,t[2]=a,t[3]=o}else o=t[3];return o}function Iy(e){let{tr:t}=e;return t.setMeta(Kt,`programmatic`),!0}function Ly(e){let{tr:t}=e;return t.setMeta(Kt,`programmatic`),!0}function Ry(e){if(e.length<=My)return e.map(e=>({kind:`entry`,entry:e}));let t=e[0],n=e.slice(-2),r=e.length-1-n.length;return[{kind:`entry`,entry:t},{kind:`ellipsis`,hiddenCount:r},...n.map(e=>({kind:`entry`,entry:e}))]}var zy=200,By=`Outside any block`;function Vy(e){let t=(0,Q.c)(5),{editor:n}=e,r=Fn(n),i=(0,Z.useRef)(null),a=(0,Z.useRef)(null),o=(0,Z.useRef)(!1),s,c;t[0]!==r||t[1]!==n?(s=()=>{if(a.current!==null&&(window.clearTimeout(a.current),a.current=null),!n||!i.current)return;let e=r!==null&&r.ancestorChain.length>0,t;return t=e?Hy(n,r):o.current?By:``,a.current=window.setTimeout(()=>{i.current&&(i.current.textContent=``,i.current.textContent=t),o.current=e,a.current=null},zy),()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null)}},c=[n,r],t[0]=r,t[1]=n,t[2]=s,t[3]=c):(s=t[2],c=t[3]),(0,Z.useEffect)(s,c);let l;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,X.jsx)(`div`,{ref:i,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`sr-only`}),t[4]=l):l=t[4],l}function Hy(e,t){if(!t||t.ancestorChain.length===0)return``;let n=t.ancestorChain,r=n[n.length-1],i=jy(r,{unregisteredSuffix:!0});if(n.length===1)return`Selected: ${i}`;let a=n[n.length-2],o=jy(a);try{let t=e.state.doc.resolve(r.pos),n=t.index(t.depth),a=t.parent.childCount;return`Selected: ${i}, ${n+1} of ${a} in ${o}`}catch{return`Selected: ${i} in ${o}`}}function Uy(){let[e]=(0,Z.useState)(Oe);return e}function Wy({principal:e,identity:t}){return e&&e.source===`git-config`?{type:`human`,name:Be(e.display_name),color:ke(e.id,I),coeditor:t.coeditor,tabId:t.tabId,principalId:e.id}:e&&e.source===`synthesized`?{type:`human`,name:t.name,color:ke(e.id,I),coeditor:t.coeditor,tabId:t.tabId}:{type:`human`,name:t.name,color:t.color,coeditor:t.coeditor,tabId:t.tabId}}function Gy(e,t){let n=Math.min(e.top,t.top),r=Math.max(e.bottom,t.bottom),i=Math.min(e.left,t.left),a=Math.max(e.right,t.right)-i,o=r-n;return new DOMRect(i,n,a,o)}var Ky=class{constructor({editor:e,element:t,view:n,pluginKey:r=`bubbleMenu`,updateDelay:i=250,resizeDelay:a=60,shouldShow:o,appendTo:s,getReferencedVirtualElement:c,options:l}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:`absolute`,placement:`top`,offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:e,state:t,from:n,to:r})=>{let{doc:i,selection:a}=t,{empty:o}=a,s=!i.textBetween(n,r).length&&Ze(t.selection),c=this.element.contains(document.activeElement);return!(!(e.hasFocus()||c)||o||s||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}e?.relatedTarget&&this.element.parentNode?.contains(e.relatedTarget)||e?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(e,t)=>{let n=!t?.selection.eq(e.state.selection),r=!t?.doc.eq(e.state.doc);!n&&!r||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(e,n,r,t)},this.updateDelay))},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;if(!(i||!t&&!n)){if(!this.getShouldShow(r)){this.hide();return}this.show(),this.updatePosition()}},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);t===`updatePosition`?this.updatePosition():t&&typeof t==`object`&&t.type===`updateOptions`?this.updateOptions(t.options):t===`hide`?this.hide():t===`show`&&(this.updatePosition(),this.show())},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=a,this.appendTo=s,this.scrollTarget=l?.scrollTarget??window,this.getReferencedVirtualElement=c,this.floatingUIOptions={...this.floatingUIOptions,...l},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener(`dragstart`,this.dragstartHandler),this.editor.on(`focus`,this.focusHandler),this.editor.on(`blur`,this.blurHandler),this.editor.on(`transaction`,this.transactionHandler),window.addEventListener(`resize`,this.resizeHandler),this.scrollTarget.addEventListener(`scroll`,this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(Fe(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(U(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(le(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(B(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(ee(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(ce(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(ae(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(oe(typeof this.floatingUIOptions.inline==`boolean`?void 0:this.floatingUIOptions.inline)),e}get virtualElement(){let{selection:e}=this.editor.state,t=this.getReferencedVirtualElement?.call(this);if(t)return t;if(!this.view?.dom?.parentNode)return;let n=Ye(this.view,e.from,e.to),r={getBoundingClientRect:()=>n,getClientRects:()=>[n]};if(e instanceof De){let t=this.view.nodeDOM(e.from),n=t.dataset.nodeViewWrapper?t:t.querySelector(`[data-node-view-wrapper]`);n&&(t=n),t&&(r={getBoundingClientRect:()=>t.getBoundingClientRect(),getClientRects:()=>[t.getBoundingClientRect()]})}if(e instanceof ie){let{$anchorCell:t,$headCell:n}=e,i=t?t.pos:n.pos,a=n?n.pos:t.pos,o=this.view.nodeDOM(i),s=this.view.nodeDOM(a);if(!o||!s)return;let c=o===s?o.getBoundingClientRect():Gy(o.getBoundingClientRect(),s.getBoundingClientRect());r={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return r}updatePosition(){if(!this.isVisible)return;let e=this.virtualElement;e&&L(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{if(!(!this.isVisible||this.editor.isDestroyed||!this.element.isConnected)){if(r.hide?.referenceHidden||r.hide?.escaped){this.element.style.visibility=`hidden`;return}this.element.style.visibility=`visible`,this.element.style.width=`max-content`,this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()}})}update(e,t){let{state:n}=e,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(e,t);return}let i=!t?.selection.eq(e.state.selection),a=!t?.doc.eq(e.state.doc);this.updateHandler(e,i,a,t)}getShouldShow(e){let{state:t}=this.view,{selection:n}=t,{ranges:r}=n,i=Math.min(...r.map(e=>e.$from.pos)),a=Math.max(...r.map(e=>e.$to.pos));return this.shouldShow?.call(this,{editor:this.editor,element:this.element,view:this.view,state:t,oldState:e,from:i,to:a})||!1}show(){var e;this.isVisible||(this.element.style.visibility=`visible`,this.element.style.opacity=`1`,(e=(typeof this.appendTo==`function`?this.appendTo():this.appendTo)??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&=(this.element.style.visibility=`hidden`,this.element.style.opacity=`0`,this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),!1)}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){let t=e.options.scrollTarget??window;t!==this.scrollTarget&&(this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.scrollTarget=t,this.scrollTarget.addEventListener(`scroll`,this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}destroy(){this.hide(),this.element.removeEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener(`dragstart`,this.dragstartHandler),window.removeEventListener(`resize`,this.resizeHandler),this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.editor.off(`focus`,this.focusHandler),this.editor.off(`blur`,this.blurHandler),this.editor.off(`transaction`,this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},qy=e=>new ze({key:typeof e.pluginKey==`string`?new et(e.pluginKey):e.pluginKey,view:t=>new Ky({view:t,...e})});ye.create({name:`bubbleMenu`,addOptions(){return{element:null,pluginKey:`bubbleMenu`,updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[qy({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});var Jy=class{constructor({editor:e,element:t,view:n,pluginKey:r=`floatingMenu`,updateDelay:i=250,resizeDelay:a=60,options:o,appendTo:s,shouldShow:c}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:e,state:t})=>{let{selection:n}=t,{$anchor:r,empty:i}=n,a=r.depth===1,o=r.parent.isTextblock&&!r.parent.type.spec.code&&!r.parent.textContent&&r.parent.childCount===0&&!this.getTextContent(r.parent);return!(!e.hasFocus()||!i||!a||!o||!this.editor.isEditable)},this.floatingUIOptions={strategy:`absolute`,placement:`right`,offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;if(!(i||!t&&!n)){if(!this.getShouldShow(r)){this.hide();return}this.updatePosition(),this.show()}},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{if(this.preventHide){this.preventHide=!1;return}e?.relatedTarget&&this.element.parentNode?.contains(e.relatedTarget)||e?.relatedTarget!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);t===`updatePosition`?this.updatePosition():t&&typeof t==`object`&&t.type===`updateOptions`?this.updateOptions(t.options):t===`hide`?this.hide():t===`show`&&(this.updatePosition(),this.show())},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=a,this.appendTo=s,this.scrollTarget=o?.scrollTarget??window,this.floatingUIOptions={...this.floatingUIOptions,...o},this.element.tabIndex=0,c&&(this.shouldShow=c),this.element.addEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.editor.on(`focus`,this.focusHandler),this.editor.on(`blur`,this.blurHandler),this.editor.on(`transaction`,this.transactionHandler),window.addEventListener(`resize`,this.resizeHandler),this.scrollTarget.addEventListener(`scroll`,this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(e){return xe(e,{textSerializers:de(this.editor.schema)})}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(Fe(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(U(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(le(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(B(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(ee(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(ce(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(ae(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(oe(typeof this.floatingUIOptions.inline==`boolean`?void 0:this.floatingUIOptions.inline)),e}getShouldShow(e){let{state:t}=this.view,{selection:n}=t,{ranges:r}=n,i=Math.min(...r.map(e=>e.$from.pos)),a=Math.max(...r.map(e=>e.$to.pos));return this.shouldShow?.call(this,{editor:this.editor,view:this.view,state:t,oldState:e,from:i,to:a})}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){let t=e.options.scrollTarget??window;t!==this.scrollTarget&&(this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.scrollTarget=t,this.scrollTarget.addEventListener(`scroll`,this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}updatePosition(){let{selection:e}=this.editor.state,t=Ye(this.view,e.from,e.to);L({getBoundingClientRect:()=>t,getClientRects:()=>[t]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{if(r.hide?.referenceHidden||r.hide?.escaped){this.element.style.visibility=`hidden`;return}this.element.style.visibility=`visible`,this.element.style.width=`max-content`,this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){let n=!t?.selection.eq(e.state.selection),r=!t?.doc.eq(e.state.doc);this.updateHandler(e,n,r,t)}show(){var e;this.isVisible||(this.element.style.visibility=`visible`,this.element.style.opacity=`1`,(e=(typeof this.appendTo==`function`?this.appendTo():this.appendTo)??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&=(this.element.style.visibility=`hidden`,this.element.style.opacity=`0`,this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),!1)}destroy(){this.hide(),this.element.removeEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),window.removeEventListener(`resize`,this.resizeHandler),this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.editor.off(`focus`,this.focusHandler),this.editor.off(`blur`,this.blurHandler),this.editor.off(`transaction`,this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},Yy=e=>new ze({key:typeof e.pluginKey==`string`?new et(e.pluginKey):e.pluginKey,view:t=>new Jy({view:t,...e})});ye.create({name:`floatingMenu`,addOptions(){return{element:null,options:{},pluginKey:`floatingMenu`,updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}},addCommands(){return{updateFloatingMenuPosition:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(this.options.pluginKey,`updatePosition`),!0)}},addProseMirrorPlugins(){return this.options.element?[Yy({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,resizeDelay:this.options.resizeDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});function Xy(e,t){return e??new et(t)}var Zy=typeof window<`u`?Z.useLayoutEffect:Z.useEffect,Qy=new Set([`left`,`opacity`,`position`,`top`,`visibility`,`width`]),$y=new Set(`animationIterationCount.aspectRatio.borderImageOutset.borderImageSlice.borderImageWidth.columnCount.columns.fillOpacity.flex.flexGrow.flexShrink.fontWeight.gridArea.gridColumn.gridColumnEnd.gridColumnStart.gridRow.gridRowEnd.gridRowStart.lineClamp.lineHeight.opacity.order.orphans.scale.stopOpacity.strokeDasharray.strokeDashoffset.strokeMiterlimit.strokeOpacity.strokeWidth.tabSize.widows.zIndex.zoom`.split(`.`)),eb=new Set([`children`,`className`,`style`]),tb=new Set([`tabIndex`]),nb=new Set([`accessKey`,`autoCapitalize`,`contentEditable`,`contextMenu`,`dir`,`draggable`,`enterKeyHint`,`hidden`,`id`,`lang`,`nonce`,`role`,`slot`,`spellCheck`,`tabIndex`,`title`,`translate`]),rb={Blur:`focusout`,DoubleClick:`dblclick`,Focus:`focusin`,MouseEnter:`mouseenter`,MouseLeave:`mouseleave`};function ib(e,t){return/^on[A-Z]/.test(e)&&typeof t==`function`}function ab(e){return e.startsWith(`aria-`)||e.startsWith(`data-`),e}function ob(e){return e.startsWith(`aria-`)||e.startsWith(`data-`)||nb.has(e)}function sb(e){return e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function cb(e){let t=e.endsWith(`Capture`),n=(t?e.slice(0,-7):e).slice(2);return{eventName:rb[n]??n.toLowerCase(),options:t?{capture:!0}:void 0}}function lb(e,t){let n=t.defaultPrevented,r=!1,i=Object.create(t);return Object.defineProperties(i,{nativeEvent:{value:t},currentTarget:{value:e},target:{value:t.target},persist:{value:()=>void 0},isDefaultPrevented:{value:()=>n},isPropagationStopped:{value:()=>r},preventDefault:{value:()=>{n=!0,t.preventDefault()}},stopPropagation:{value:()=>{r=!0,t.stopPropagation()}}}),i}function ub(e){return tb.has(e)}function db(e,t,n){if(t===`tabIndex`){e.tabIndex=Number(n);return}e[t]=n}function fb(e,t){if(t===`tabIndex`){e.removeAttribute(`tabindex`);return}let n=e[t];if(typeof n==`boolean`){e[t]=!1;return}if(typeof n==`number`){e[t]=0;return}e[t]=``}function pb(e,t){return typeof t!=`number`||t===0||e.startsWith(`--`)||$y.has(e)?String(t):`${t}px`}function mb(e,t){Qy.has(t)||e.style.removeProperty(sb(t))}function hb(e,t,n){Qy.has(t)||e.style.setProperty(sb(t),pb(t,n))}function gb(e,t,n){new Set([...Object.keys(t),...Object.keys(n)]).forEach(r=>{if(eb.has(r)||!ob(r)||ib(r,t[r])||ib(r,n[r]))return;let i=t[r],a=n[r];if(i===a)return;let o=ab(r);if(a==null||a===!1){ub(r)&&fb(e,r),e.removeAttribute(o);return}if(a===!0){ub(r)&&db(e,r,!0),e.setAttribute(o,``);return}if(ub(r)){db(e,r,a);return}e.setAttribute(o,String(a))})}function _b(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute(`class`)}}function vb(e,t,n){let r=t??{},i=n??{};new Set([...Object.keys(r),...Object.keys(i)]).forEach(t=>{let n=r[t],a=i[t];if(n!==a){if(a==null){mb(e,t);return}hb(e,t,a)}})}function yb(e,t,n){t.forEach(({eventName:t,listener:n,options:r})=>{e.removeEventListener(t,n,r)});let r=[];return Object.entries(n).forEach(([t,n])=>{if(!ib(t,n))return;let{eventName:i,options:a}=cb(t),o=t=>{n(lb(e,t))};e.addEventListener(i,o,a),r.push({eventName:i,listener:o,options:a})}),r}function bb(e,t){let n=(0,Z.useRef)({}),r=(0,Z.useRef)([]);Zy(()=>{let i=n.current;return _b(e,i.className,t.className),vb(e,i.style,t.style),gb(e,i,t),r.current=yb(e,r.current,t),n.current=t,()=>{r.current.forEach(({eventName:t,listener:n,options:r})=>{e.removeEventListener(t,n,r)}),r.current=[]}},[e,t])}var xb=Z.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,getReferencedVirtualElement:o,options:s,children:c,...l},u)=>{let d=(0,Z.useRef)(document.createElement(`div`)),f=(0,Z.useRef)(Xy(e,`bubbleMenu`)).current;bb(d.current,l),typeof u==`function`?u(d.current):u&&(u.current=d.current);let{editor:p}=An(),m=t||p,h={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:f,shouldShow:a,getReferencedVirtualElement:o,options:s},g=(0,Z.useRef)(h);g.current=h;let[_,v]=(0,Z.useState)(!1),y=(0,Z.useRef)(!0);return(0,Z.useEffect)(()=>{if(m?.isDestroyed)return;if(!m){console.warn(`BubbleMenu component is not rendered inside of an editor component or does not have editor prop.`);return}let e=d.current;e.style.visibility=`hidden`,e.style.position=`absolute`;let t=qy({...g.current,editor:m,element:e});m.registerPlugin(t);let n=g.current.pluginKey;return y.current=!0,v(!0),()=>{v(!1),m.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[m]),(0,Z.useEffect)(()=>{if(!(!_||!m||m.isDestroyed)){if(y.current){y.current=!1;return}m.view.dispatch(m.state.tr.setMeta(f,{type:`updateOptions`,options:g.current}))}},[_,m,n,r,a,s,i,o,f]),(0,Ai.createPortal)(c,d.current)});Z.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:r,appendTo:i,shouldShow:a=null,options:o,children:s,...c},l)=>{let u=(0,Z.useRef)(document.createElement(`div`)),d=(0,Z.useRef)(Xy(e,`floatingMenu`)).current;bb(u.current,c),typeof l==`function`?l(u.current):l&&(l.current=u.current);let{editor:f}=An(),p=t||f,m={updateDelay:n,resizeDelay:r,appendTo:i,pluginKey:d,shouldShow:a,options:o},h=(0,Z.useRef)(m);h.current=m;let[g,_]=(0,Z.useState)(!1),v=(0,Z.useRef)(!0);return(0,Z.useEffect)(()=>{if(p?.isDestroyed)return;if(!p){console.warn(`FloatingMenu component is not rendered inside of an editor component or does not have editor prop.`);return}let e=u.current;e.style.visibility=`hidden`,e.style.position=`absolute`;let t=Yy({...h.current,editor:p,element:e});p.registerPlugin(t);let n=h.current.pluginKey;return v.current=!0,_(!0),()=>{_(!1),p.unregisterPlugin(n),window.requestAnimationFrame(()=>{e.parentNode&&e.parentNode.removeChild(e)})}},[p]),(0,Z.useEffect)(()=>{if(!(!g||!p||p.isDestroyed)){if(v.current){v.current=!1;return}p.view.dispatch(p.state.tr.setMeta(d,{type:`updateOptions`,options:h.current}))}},[g,p,n,r,a,o,i,d]),(0,Ai.createPortal)(s,u.current)});var Sb=[{name:`paragraph`,label:`Text`,icon:va,isActive:e=>e.isActive(`paragraph`)&&!e.isActive(`list`),command:e=>e.chain().focus().setParagraph().run()},{name:`heading1`,label:`Heading 1`,icon:At,isActive:e=>e.isActive(`heading`,{level:1}),command:e=>e.chain().focus().toggleHeading({level:1}).run()},{name:`heading2`,label:`Heading 2`,icon:Yt,isActive:e=>e.isActive(`heading`,{level:2}),command:e=>e.chain().focus().toggleHeading({level:2}).run()},{name:`heading3`,label:`Heading 3`,icon:Pn,isActive:e=>e.isActive(`heading`,{level:3}),command:e=>e.chain().focus().toggleHeading({level:3}).run()},{name:`bulletList`,label:`Bullet List`,icon:an,isActive:e=>e.isActive(`list`,{ordered:!1})&&!e.isActive(`listItem`,{checked:!0})&&!e.isActive(`listItem`,{checked:!1}),command:e=>e.chain().focus().toggleBulletList().run()},{name:`orderedList`,label:`Ordered List`,icon:qt,isActive:e=>e.isActive(`list`,{ordered:!0}),command:e=>e.chain().focus().toggleOrderedList().run()},{name:`taskList`,label:`Task List`,icon:In,isActive:e=>e.isActive(`listItem`,{checked:!0})||e.isActive(`listItem`,{checked:!1}),command:e=>e.chain().focus().toggleTaskList().run()},{name:`blockquote`,label:`Quote`,icon:tn,isActive:e=>e.isActive(`blockquote`),command:e=>e.chain().focus().toggleBlockquote().run()},{name:`codeBlock`,label:`Code Block`,icon:ja,isActive:e=>e.isActive(`codeBlock`),command:e=>e.chain().focus().toggleCodeBlock().run()}];function Cb(e){let t=(0,Q.c)(18),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:wb},t[0]=n,t[1]=r);let{current:i,activeStates:a}=cn(r),o=i.icon,s;t[2]===o?s=t[3]:(s=(0,X.jsx)(o,{className:`size-3.5`}),t[2]=o,t[3]=s);let c;t[4]===i.label?c=t[5]:(c=(0,X.jsx)(`span`,{children:i.label}),t[4]=i.label,t[5]=c);let l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,X.jsx)(Rt,{className:`size-3 opacity-50`}),t[6]=l):l=t[6];let u;t[7]!==s||t[8]!==c?(u=(0,X.jsx)(Uv,{asChild:!0,children:(0,X.jsxs)(J,{variant:`ghost`,size:`sm`,className:`gap-1 px-2 text-sm font-medium text-accent-foreground/80`,children:[s,c,l]})}),t[7]=s,t[8]=c,t[9]=u):u=t[9];let d;t[10]!==a||t[11]!==n?(d=Sb.map(e=>{let t=e.icon,r=a[e.name];return(0,X.jsxs)(Gv,{className:r?`bg-accent text-accent-foreground`:``,onSelect:()=>{e.command(n)},children:[(0,X.jsx)(t,{className:`size-4`}),(0,X.jsx)(`span`,{children:e.label})]},e.name)}),t[10]=a,t[11]=n,t[12]=d):d=t[12];let f;t[13]===d?f=t[14]:(f=(0,X.jsx)(Wv,{align:`start`,sideOffset:8,className:`w-44 max-h-(--radix-dropdown-menu-content-available-height) overflow-y-auto subtle-scrollbar`,children:d}),t[13]=d,t[14]=f);let p;return t[15]!==u||t[16]!==f?(p=(0,X.jsxs)(Hv,{children:[u,f]}),t[15]=u,t[16]=f,t[17]=p):p=t[17],p}function wb(e){let t=Object.fromEntries(Sb.map(t=>[t.name,t.isActive(e.editor)]));return{current:Sb.find(e=>t[e.name])??Sb[0],activeStates:t}}var Tb=[{name:`bold`,icon:Oi,command:e=>e.chain().focus().toggleBold().run(),isActive:e=>e.isActive(`strong`),shortcut:`⌘B`},{name:`italic`,icon:aa,command:e=>e.chain().focus().toggleItalic().run(),isActive:e=>e.isActive(`emphasis`),shortcut:`⌘I`},{name:`underline`,icon:Ra,command:e=>e.chain().focus().toggleUnderline().run(),isActive:e=>e.isActive(`underline`),shortcut:`⌘U`},{name:`strikethrough`,icon:Pa,command:e=>e.chain().focus().toggleStrike().run(),isActive:e=>e.isActive(`strike`),shortcut:`⌘⇧X`},{name:`code`,icon:zi,command:e=>e.chain().focus().toggleCode().run(),isActive:e=>e.isActive(`code`),shortcut:`⌘E`},{name:`highlight`,icon:ia,command:e=>e.chain().focus().toggleHighlight().run(),isActive:e=>e.isActive(`highlight`),shortcut:`⌘⇧H`}];function Eb(e){let t=(0,Q.c)(7),{editor:n}=e,r;t[0]===n?r=t[1]:(r={editor:n,selector:Db},t[0]=n,t[1]=r);let i=cn(r),a;t[2]!==i||t[3]!==n?(a=Tb.map(e=>{let t=e.icon,r=i[e.name];return(0,X.jsxs)(Lr,{children:[(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(J,{variant:`ghost`,size:`icon-xs`,"aria-label":e.name,className:r?`bg-accent text-primary`:`text-accent-foreground`,onMouseDown:t=>{t.preventDefault(),e.command(n)},children:(0,X.jsx)(t,{className:`size-3.5`})})}),(0,X.jsxs)(Fr,{side:`bottom`,sideOffset:8,children:[(0,X.jsx)(`span`,{className:`capitalize`,children:e.name}),(0,X.jsx)(`kbd`,{className:`ml-1.5 text-[10px] opacity-60`,children:e.shortcut})]})]},e.name)}),t[2]=i,t[3]=n,t[4]=a):a=t[4];let o;return t[5]===a?o=t[6]:(o=(0,X.jsx)(`div`,{className:`flex items-center gap-0.5`,children:a}),t[5]=a,t[6]=o),o}function Db(e){return Object.fromEntries(Tb.map(t=>[t.name,t.isActive(e.editor)]))}function Ob(e){let t=(0,Q.c)(46),{editor:n}=e,[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(``),s=(0,Z.useRef)(null),c;t[0]===n?c=t[1]:(c=n.isActive(`link`),t[0]=n,t[1]=c);let l=c,u;t[2]===n?u=t[3]:(u=n.getAttributes(`link`).href??``,t[2]=n,t[3]=u);let d=u,f,p;t[4]===n?(f=t[5],p=t[6]):(f=()=>{let e=function(){n.state.selection.empty&&i(!1)};return n.on(`selectionUpdate`,e),()=>{n.off(`selectionUpdate`,e)}},p=[n],t[4]=n,t[5]=f,t[6]=p),(0,Z.useEffect)(f,p);let m,h;t[7]!==d||t[8]!==r?(m=()=>{r&&(o(d),requestAnimationFrame(()=>s.current?.focus()))},h=[r,d],t[7]=d,t[8]=r,t[9]=m,t[10]=h):(m=t[9],h=t[10]),(0,Z.useEffect)(m,h);let g;t[11]!==n||t[12]!==l||t[13]!==a?(g=function(){a.trim()?n.chain().focus().setLink({href:a.trim()}).run():l&&n.chain().focus().unsetLink().run(),i(!1)},t[11]=n,t[12]=l,t[13]=a,t[14]=g):g=t[14];let _=g,v;t[15]===n?v=t[16]:(v=function(){n.chain().focus().unsetLink().run(),i(!1)},t[15]=n,t[16]=v);let y=v,b;t[17]!==_||t[18]!==n?(b=function(e){e.key===`Enter`&&(e.preventDefault(),_()),e.key===`Escape`&&(e.preventDefault(),i(!1),n.chain().focus().run())},t[17]=_,t[18]=n,t[19]=b):b=t[19];let x=b;if(r){let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=e=>o(e.target.value),t[20]=e):e=t[20];let n;t[21]!==x||t[22]!==a?(n=(0,X.jsx)(`input`,{ref:s,type:`url`,placeholder:`Paste link...`,value:a,onChange:e,onKeyDown:x,"aria-label":`Link URL`,className:`h-5 w-44 bg-transparent text-sm border-none outline-none placeholder:text-muted-foreground`}),t[21]=x,t[22]=a,t[23]=n):n=t[23];let r;t[24]===_?r=t[25]:(r=()=>{_()},t[24]=_,t[25]=r);let i;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,X.jsx)(Ui,{className:`size-3.5 shrink-0 text-muted-foreground`}),t[26]=i):i=t[26];let c;t[27]===r?c=t[28]:(c=(0,X.jsx)(J,{variant:`ghost`,size:`icon-xs`,"aria-label":`Apply link`,onClick:r,children:i}),t[27]=r,t[28]=c);let u;t[29]!==n||t[30]!==c?(u=(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border bg-background px-2 py-1`,children:[n,c]}),t[29]=n,t[30]=c,t[31]=u):u=t[31];let f;t[32]!==d||t[33]!==l||t[34]!==y?(f=l&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Lr,{children:[(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(J,{variant:`ghost`,size:`icon-xs`,"aria-label":`Open link in new tab`,onMouseDown:e=>{e.preventDefault(),window.open(d,`_blank`,`noopener,noreferrer`)},children:(0,X.jsx)(cr,{className:`size-3.5`})})}),(0,X.jsx)(Fr,{side:`bottom`,sideOffset:8,children:`Open link in new tab`})]}),(0,X.jsxs)(Lr,{children:[(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(J,{variant:`ghost`,size:`icon-xs`,"aria-label":`Remove link`,onMouseDown:e=>{e.preventDefault(),y()},children:(0,X.jsx)(fn,{className:`size-3.5`})})}),(0,X.jsx)(Fr,{side:`bottom`,sideOffset:8,children:`Remove link`})]})]}),t[32]=d,t[33]=l,t[34]=y,t[35]=f):f=t[35];let p;return t[36]!==u||t[37]!==f?(p=(0,X.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[u,f]}),t[36]=u,t[37]=f,t[38]=p):p=t[38],p}let S=l?`bg-accent text-primary`:`text-accent-foreground`,C,w;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{e.preventDefault(),i(!0)},w=(0,X.jsx)(ca,{className:`size-3.5`}),t[39]=C,t[40]=w):(C=t[39],w=t[40]);let T;t[41]===S?T=t[42]:(T=(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(J,{variant:`ghost`,size:`icon-xs`,"aria-label":`Insert link`,className:S,onMouseDown:C,children:w})}),t[41]=S,t[42]=T);let E;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,X.jsxs)(Fr,{side:`bottom`,sideOffset:8,children:[`Link`,(0,X.jsx)(`kbd`,{className:`ml-1.5 text-[10px] opacity-60`,children:`⌘K`})]}),t[43]=E):E=t[43];let D;return t[44]===T?D=t[45]:(D=(0,X.jsxs)(Lr,{children:[T,E]}),t[44]=T,t[45]=D),D}function kb({editor:e}){if(e.state.selection.empty||e.isActive(`codeBlock`))return!1;let{from:t,to:n}=e.state.selection;return!!e.state.doc.textBetween(t,n,` `).trim()}function Ab(e){let t=(0,Q.c)(25),{editor:n}=e,r=(0,Z.useRef)(null),[i,a]=(0,Z.useState)(0),o=(0,Z.useRef)(null),s;t[0]!==n.state||t[1]!==n.view?(s=()=>{try{let{from:e,to:t}=n.state.selection;return Ye(n.view,e,t)}catch{return new DOMRect}},t[0]=n.state,t[1]=n.view,t[2]=s):s=t[2];let c;if(t[3]!==n.view.dom||t[4]!==s){let e={getBoundingClientRect:s,contextElement:n.view.dom};c=()=>{let t=r.current;t&&(o.current?.(),o.current=Le(e,t,()=>{L(e,t,{placement:`top`,strategy:`fixed`,middleware:[le(8),Fe(),U({padding:8})]}).then(e=>{let{x:n,y:r}=e;t.isConnected&&(t.style.position=`fixed`,t.style.left=`${n}px`,t.style.top=`${r}px`)}).catch(Nb)}))},t[3]=n.view.dom,t[4]=s,t[5]=c}else c=t[5];let l=c,u;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{o.current?.(),o.current=null,a(Mb)},t[6]=u):u=t[6];let d=u,f;t[7]===l?f=t[8]:(f={onShow:l,onHide:d,strategy:`fixed`},t[7]=l,t[8]=f);let p;t[9]===n?p=t[10]:(p=(0,X.jsx)(Cb,{editor:n}),t[9]=n,t[10]=p);let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,X.jsx)(lv,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[11]=m):m=t[11];let h;t[12]!==n||t[13]!==i?(h=(0,X.jsx)(Eb,{editor:n},i),t[12]=n,t[13]=i,t[14]=h):h=t[14];let g;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,X.jsx)(lv,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[15]=g):g=t[15];let _=`${i}-link`,v;t[16]!==n||t[17]!==_?(v=(0,X.jsx)(Ob,{editor:n},_),t[16]=n,t[17]=_,t[18]=v):v=t[18];let y;return t[19]!==n||t[20]!==v||t[21]!==f||t[22]!==p||t[23]!==h?(y=(0,X.jsxs)(xb,{ref:r,editor:n,appendTo:jb,shouldShow:kb,updateDelay:250,options:f,className:`z-50 flex items-center gap-0.5 rounded-lg border bg-background p-1 shadow-md`,children:[p,m,h,g,v]}),t[19]=n,t[20]=v,t[21]=f,t[22]=p,t[23]=h,t[24]=y):y=t[24],y}function jb(){return document.body}function Mb(e){return e+1}function Nb(){}var Pb=[{name:`addRowBefore`,icon:Bt,label:`Add row above`,command:e=>e.chain().focus().addRowBefore().run()},{name:`addRowAfter`,icon:Wt,label:`Add row below`,command:e=>e.chain().focus().addRowAfter().run()},{name:`deleteRow`,icon:fn,label:`Delete row`,command:e=>e.chain().focus().deleteRow().run()}],Fb=[{name:`addColumnBefore`,icon:Kn,label:`Add column left`,command:e=>e.chain().focus().addColumnBefore().run()},{name:`addColumnAfter`,icon:tr,label:`Add column right`,command:e=>e.chain().focus().addColumnAfter().run()},{name:`deleteColumn`,icon:fn,label:`Delete column`,command:e=>e.chain().focus().deleteColumn().run()}],Ib=[{name:`toggleHeaderRow`,icon:Ia,label:`Toggle header row`,command:e=>e.chain().focus().toggleHeaderRow().run()},{name:`toggleHeaderColumn`,icon:Vi,label:`Toggle header column`,command:e=>e.chain().focus().toggleHeaderColumn().run()},{name:`deleteTable`,icon:na,label:`Delete table`,command:e=>e.chain().focus().deleteTable().run()}];function Lb({editor:e}){return e.isActive(`table`)}function Rb(e){let t=(0,Q.c)(14),{action:n,editor:r}=e,i=n.icon,a;t[0]!==n||t[1]!==r?(a=e=>{e.preventDefault(),n.command(r)},t[0]=n,t[1]=r,t[2]=a):a=t[2];let o;t[3]===i?o=t[4]:(o=(0,X.jsx)(i,{className:`size-3.5`}),t[3]=i,t[4]=o);let s;t[5]!==n.label||t[6]!==a||t[7]!==o?(s=(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(J,{variant:`ghost`,size:`icon-xs`,"aria-label":n.label,className:`text-muted-foreground`,onMouseDown:a,children:o})}),t[5]=n.label,t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;t[9]===n.label?c=t[10]:(c=(0,X.jsx)(Fr,{side:`bottom`,sideOffset:8,children:n.label}),t[9]=n.label,t[10]=c);let l;return t[11]!==s||t[12]!==c?(l=(0,X.jsxs)(Lr,{children:[s,c]}),t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function zb(e){let t=(0,Q.c)(13),{editor:n}=e,r;t[0]===n?r=t[1]:(r=Pb.map(e=>(0,X.jsx)(Rb,{action:e,editor:n},e.name)),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,X.jsx)(lv,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[2]=i):i=t[2];let a;t[3]===n?a=t[4]:(a=Fb.map(e=>(0,X.jsx)(Rb,{action:e,editor:n},e.name)),t[3]=n,t[4]=a);let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,X.jsx)(lv,{orientation:`vertical`,className:`mx-0.5 h-5 data-vertical:self-center`}),t[5]=o):o=t[5];let s;t[6]===n?s=t[7]:(s=Ib.map(e=>(0,X.jsx)(Rb,{action:e,editor:n},e.name)),t[6]=n,t[7]=s);let c;return t[8]!==n||t[9]!==r||t[10]!==a||t[11]!==s?(c=(0,X.jsxs)(xb,{editor:n,shouldShow:Lb,updateDelay:100,className:`flex items-center gap-0.5 rounded-lg border bg-background p-1 shadow-md`,children:[r,i,a,o,s]}),t[8]=n,t[9]=r,t[10]=a,t[11]=s,t[12]=c):c=t[12],c}var Bb=new WeakMap;function Vb(e){let t=document.createElement(`span`);t.classList.add(`collaboration-cursor__caret`),t.style.borderColor=e.color;let n=document.createElement(`div`);return n.classList.add(`collaboration-cursor__label`),n.style.backgroundColor=e.color,n.style.color=Te(e.color),n.textContent=e.name,t.append(n),t}var Hb={state:`idle`,count:0,lastFiredAt:null,position:`append`,lastAgentId:null},Ub=e=>{let t=(0,Q.c)(69),{provider:n,placeholder:r,isSourceMode:i}=e,a=(0,Z.useRef)(``),o=(0,Z.useRef)(null),s=(0,Z.useRef)(Hb),c=Uy(),{principal:l,activeDocName:u}=Sn(),d=n.configuration.name??``,[f]=(0,Z.useState)(Wb),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null);if(h)throw h;let _=(0,Z.useRef)(null),v;t[0]!==f||t[1]!==d||t[2]!==r||t[3]!==n?(v=()=>{let e;try{let t={viewCount:0,bytes:n.document.getText(`source`).length};e=Xt({docName:d,container:document.createElement(`div`),sizeStats:t,factory:e=>{let t=performance.now();return{editor:new _e({element:e,onBeforeCreate:e=>{let{editor:n}=e;Bb.set(n,t)},onCreate:e=>{let{editor:t}=e,r=Bb.get(t);if(Bb.delete(t),r==null)return;let i=performance.now();wn(`ok/editor/create-tiptap`,{docName:n.configuration.name??`unknown`,ytextLength:n.document.getText(`source`).length},{startTime:r,duration:Math.max(0,i-r)})},editorProps:{attributes:{class:`pt-10 pb-16 h-full`},clipboardTextParser:(e,t,n,r)=>{let i=f.mdManager.parse(e);return r.state.schema.nodeFromJSON(i).content},clipboardTextSerializer:(e,t)=>f.text(e,t),clipboardSerializer:f.html,handlePaste:(e,t)=>f.paste(e,t)},extensions:[...ln.map(e=>e.name===`link`?e.configure({docName:n.configuration.name??``}):e),Ay.configure({placeholder:r??`Type '/' for commands`,showOnlyCurrent:!0}),Nt.configure({document:n.document}),ye.create({name:`imageUploadDecoration`,addProseMirrorPlugins(){return[Gt]}}),ye.create({name:`collaborationCursor`,addProseMirrorPlugins(){let e=n.awareness;if(!e)throw Error(`[TiptapEditor] HocuspocusProvider has no awareness instance — cursor plugin cannot initialize`);return[Qt(e,{cursorBuilder:Vb})]}})]}),ydoc:n.document,ytext:n.document.getText(`source`),provider:n}}}),_.current=e,m(e.editor)}catch(e){let t=e;console.error(`[TiptapEditor] mountTiptapEditor failed`,t),_.current=null,m(null),g(t instanceof Error?t:Error(String(t)))}return()=>{let e=_.current;e&&Mt(e),_.current=null,m(null)}},t[0]=f,t[1]=d,t[2]=r,t[3]=n,t[4]=v):v=t[4];let y;t[5]!==f||t[6]!==d||t[7]!==n?(y=[d,n,f],t[5]=f,t[6]=d,t[7]=n,t[8]=y):y=t[8],(0,Z.useEffect)(v,y);let b;t[9]!==p||t[10]!==n.configuration.name?(b=()=>{if(p)return wt(p,n.configuration.name??null),()=>{wt(p,null)}},t[9]=p,t[10]=n.configuration.name,t[11]=b):b=t[11];let x;t[12]!==p||t[13]!==n?(x=[p,n],t[12]=p,t[13]=n,t[14]=x):x=t[14],(0,Z.useEffect)(b,x);let S;t[15]!==p||t[16]!==n.configuration.name?(S=()=>{},t[15]=p,t[16]=n.configuration.name,t[17]=S):S=t[17];let C;t[18]!==p||t[19]!==n?(C=[p,n],t[18]=p,t[19]=n,t[20]=C):C=t[20],(0,Z.useEffect)(S,C);let w,T;t[21]===p?(w=t[22],T=t[23]):(w=()=>{if(!p)return;let e=Gb,t=null,n=()=>{if(t||!p||p.isDestroyed)return;let n=Ln(p);n&&(t=n.dom,t.addEventListener(`keydown`,e),t.addEventListener(`paste`,e),t.addEventListener(`drop`,e),t.addEventListener(`cut`,e))},r=()=>{t&&=(t.removeEventListener(`keydown`,e),t.removeEventListener(`paste`,e),t.removeEventListener(`drop`,e),t.removeEventListener(`cut`,e),null)};return Ln(p)?n():p.on(`create`,n),()=>{p.off(`create`,n),r()}},T=[p],t[21]=p,t[22]=w,t[23]=T),(0,Z.useEffect)(w,T);let E,D;t[24]!==p||t[25]!==n.document?(D=()=>{if(!p)return;let e=n.document.getMap(`agent-flash`),t=Date.now(),r=0,i=null,a=null,c=null,l=()=>{let t=null;for(let[,n]of e.entries()){let e=n;e.timestamp&&(!t||e.timestamp>t.timestamp)&&(t={agentId:e.agentId??`unknown`,timestamp:e.timestamp,type:e.type??`insert`,description:e.description})}return t},u=e=>{s.current=e;let t=o.current;t&&(t.setAttribute(`data-agent-flash-state`,e.state),t.setAttribute(`data-agent-flash-count`,String(e.count)),t.setAttribute(`data-agent-flash-position`,e.position),t.setAttribute(`data-agent-flash-agent-id`,e.lastAgentId??``))},d=()=>{let e=l(),t=e?.description?.toLowerCase().includes(`prepend`)?`prepend`:`append`,n={state:`editing`,count:(s.current?.count??0)+1,lastFiredAt:Date.now(),position:t,lastAgentId:e?.agentId??null};u(n),document.dispatchEvent(new CustomEvent(`agent-flash`,{detail:n})),a&&clearTimeout(a),c&&clearTimeout(c),a=window.setTimeout(()=>{let e={...n,state:`settled`};u(e),document.dispatchEvent(new CustomEvent(`agent-flash-end`,{detail:e})),c=window.setTimeout(()=>{u({...e,state:`idle`})},300)},Ie)};u(Hb);let f=()=>{if(Ge(e),!Ve(e,t)||document.visibilityState!==`visible`)return;let n=Date.now();if(t=n,n-r<500){if(!i){let e=500-(n-r);i=window.setTimeout(()=>{i=null,r=Date.now(),d()},e)}return}r=n,d()};e.observe(f);let m=()=>{document.visibilityState===`visible`?Ve(e,t)&&(t=Date.now(),r=Date.now(),d()):t=Date.now()};return document.addEventListener(`visibilitychange`,m),()=>{e.unobserve(f),document.removeEventListener(`visibilitychange`,m),i&&clearTimeout(i),a&&clearTimeout(a),c&&clearTimeout(c)}},E=[p,n.document],t[24]=p,t[25]=n.document,t[26]=E,t[27]=D):(E=t[26],D=t[27]),(0,Z.useEffect)(D,E);let O,k;t[28]===n?(O=t[29],k=t[30]):(O=()=>{let e=window.location.hash,t=e.indexOf(`?`),r=t>=0?new URLSearchParams(e.slice(t+1)).get(`anchor`):null;if(!r)return;let i=r,a=0,o,s=!1;function c(){if(s)return;let e=document.getElementById(i);e?(e.scrollIntoView({behavior:`smooth`,block:`start`}),s=!0,n.off(`synced`,c)):a<20&&(a+=1,o=window.setTimeout(c,100))}return c(),n.on(`synced`,c),()=>{o!==void 0&&clearTimeout(o),n.off(`synced`,c)}},k=[n],t[28]=n,t[29]=O,t[30]=k),(0,Z.useEffect)(O,k);let A,j;t[31]===p?(A=t[32],j=t[33]):(A=()=>{if(!p)return;let e=function(e){let t=e.detail;if(!t||t.mode!==`wysiwyg`||!p||p.isDestroyed)return;let n=Ln(p);if(!n)return;let r=n.dom.querySelectorAll(`h1, h2, h3, h4, h5, h6`)[t.index];r&&r.scrollIntoView({behavior:`smooth`,block:`start`})};return window.addEventListener(ii,e),()=>window.removeEventListener(ii,e)},j=[p],t[31]=p,t[32]=A,t[33]=j),(0,Z.useEffect)(A,j);let M,N;t[34]===n.document?(M=t[35],N=t[36]):(M=()=>{let e=n.document.getMap(`metadata`),t=e.get(`frontmatter`);typeof t==`string`&&t&&(a.current=t);let r=()=>{let t=e.get(`frontmatter`);typeof t==`string`&&(a.current=t)};return e.observe(r),()=>e.unobserve(r)},N=[n.document],t[34]=n.document,t[35]=M,t[36]=N),(0,Z.useEffect)(M,N);let P;t[37]!==u||t[38]!==d||t[39]!==c||t[40]!==i||t[41]!==l||t[42]!==n.awareness?(P=()=>{let e=n.awareness;if(e){if(d!==u){e.setLocalState(null);return}e.setLocalState({user:Wy({principal:l,identity:c}),mode:i?`source`:`wysiwyg`})}},t[37]=u,t[38]=d,t[39]=c,t[40]=i,t[41]=l,t[42]=n.awareness,t[43]=P):P=t[43];let F;t[44]!==u||t[45]!==d||t[46]!==c||t[47]!==i||t[48]!==l||t[49]!==n?(F=[n,d,u,c,l,i],t[44]=u,t[45]=d,t[46]=c,t[47]=i,t[48]=l,t[49]=n,t[50]=F):F=t[50],(0,Z.useEffect)(P,F);let I;t[51]===p?I=t[52]:(I=p&&(0,X.jsx)(Ab,{editor:p}),t[51]=p,t[52]=I);let L;t[53]===p?L=t[54]:(L=p&&(0,X.jsx)(zb,{editor:p}),t[53]=p,t[54]=L);let R,z;t[55]===p?(R=t[56],z=t[57]):(R=(0,X.jsx)(bn,{editor:p,className:`h-full`}),z=p&&(0,X.jsx)(Ny,{editor:p}),t[55]=p,t[56]=R,t[57]=z);let B;t[58]===p?B=t[59]:(B=p&&(0,X.jsx)(Vy,{editor:p}),t[58]=p,t[59]=B);let V;t[60]===p?V=t[61]:(V=p&&(0,X.jsx)(Ct,{store:_n(p).store}),t[60]=p,t[61]=V);let H;return t[62]!==I||t[63]!==L||t[64]!==R||t[65]!==z||t[66]!==B||t[67]!==V?(H=(0,X.jsxs)(`div`,{ref:o,className:`tiptap-editor h-full`,"data-agent-flash-state":`idle`,"data-agent-flash-count":`0`,"data-agent-flash-position":`append`,"data-agent-flash-agent-id":``,children:[I,L,R,z,B,V]}),t[62]=I,t[63]=L,t[64]=R,t[65]=z,t[66]=B,t[67]=V,t[68]=H):H=t[68],H};function Wb(){let e=new H({extensions:se});return{mdManager:e,text:li({mdManager:e}),html:si({mdManager:e}),paste:oi({mdManager:e})}}function Gb(){return rn()}function Kb(e){let t=(0,Q.c)(2),{docName:n,provider:r,children:i}=e;(0,Z.use)(kn(n,r));let a;return t[0]===i?a=t[1]:(a=(0,X.jsx)(X.Fragment,{children:i}),t[0]=i,t[1]=a),a}var qb=`__back-nav__`;function Jb(e){return e instanceof on||e instanceof Cn||e instanceof nn||e instanceof mn||e instanceof Dn?e.docName:null}function Yb(e){return e instanceof on?{title:`Couldn't load document`,summary:`"${e.docName}" took too long. Check your connection.`}:e instanceof Cn?{title:`Connection dropped`,summary:`Lost connection to "${e.docName}".`}:e instanceof nn?{title:`Document not found`,summary:`"${e.docName}" doesn't exist.`}:e instanceof mn?{title:`Couldn't open document`,summary:`Something went wrong opening "${e.docName}".`}:e instanceof Dn?{title:`Server can't open documents`,summary:`This project's running server doesn't support live editing. Restart Open Knowledge to fix.`}:{title:`Unknown error`,summary:e instanceof Error&&e.message?e.message:`An unexpected error occurred.`}}function Xb(e){let t=(0,Q.c)(27),{error:n,resetErrorBoundary:r,activeDocName:i,previousDocName:a,onNavigateBack:o}=e,s;t[0]===n?s=t[1]:(s=Yb(n),t[0]=n,t[1]=s);let{title:c,summary:l}=s,u=!!a&&!!o,d=(0,Z.useRef)(null),f,p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{d.current?.focus()},p=[],t[2]=f,t[3]=p):(f=t[2],p=t[3]),(0,Z.useEffect)(f,p);let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,X.jsx)(rv,{size:80,variant:`sleeping`}),t[4]=m):m=t[4];let h;t[5]===c?h=t[6]:(h=(0,X.jsx)(`h2`,{id:`document-error-title`,className:`text-lg font-medium`,children:c}),t[5]=c,t[6]=h);let g;t[7]===l?g=t[8]:(g=(0,X.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:l}),t[7]=l,t[8]=g);let _;t[9]!==h||t[10]!==g?(_=(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[h,g]}),t[9]=h,t[10]=g,t[11]=_):_=t[11];let v;t[12]===r?v=t[13]:(v=(0,X.jsx)(J,{ref:d,variant:`default`,onClick:r,children:`Try again`}),t[12]=r,t[13]=v);let y;t[14]!==i||t[15]!==u||t[16]!==n||t[17]!==o||t[18]!==a||t[19]!==r?(y=u?(0,X.jsx)(J,{variant:`ghost`,className:`font-mono uppercase`,onClick:()=>{!a||!o||(yn(Jb(n)??i),o(a),r(qb))},children:`Go back`}):null,t[14]=i,t[15]=u,t[16]=n,t[17]=o,t[18]=a,t[19]=r,t[20]=y):y=t[20];let b;t[21]!==v||t[22]!==y?(b=(0,X.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[v,y]}),t[21]=v,t[22]=y,t[23]=b):b=t[23];let x;return t[24]!==b||t[25]!==_?(x=(0,X.jsxs)(`div`,{role:`alert`,"aria-labelledby":`document-error-title`,"data-slot":`document-error-boundary`,className:`flex h-full flex-col items-center justify-center gap-8 p-8 text-center`,children:[m,_,b]}),t[24]=b,t[25]=_,t[26]=x):x=t[26],x}function Zb(e){let t=(0,Q.c)(17),{activeDocName:n,previousDocName:r,onNavigateBack:i,onRecycle:a,children:o}=e,s;t[0]!==n||t[1]!==i||t[2]!==r?(s=e=>(0,X.jsx)(Xb,{...e,activeDocName:n,previousDocName:r,onNavigateBack:i}),t[0]=n,t[1]=i,t[2]=r,t[3]=s):s=t[3];let c;t[4]===n?c=t[5]:(c=[n],t[4]=n,t[5]=c);let l;t[6]!==n||t[7]!==a?(l=e=>{if(e.reason===`imperative-api`){if(Array.isArray(e.args)&&e.args[0]===qb){console.warn(`[DocumentErrorBoundary] back-nav reset (no recycle)`);return}a(n),console.warn(`[DocumentErrorBoundary] retry recycled ${n}`)}else console.warn(`[DocumentErrorBoundary] reset by key change (${e.prev?.[0]} → ${e.next?.[0]})`)},t[6]=n,t[7]=a,t[8]=l):l=t[8];let u;t[9]===n?u=t[10]:(u=e=>{console.warn(`[DocumentErrorBoundary] rendered fallback for ${n}: ${Yb(e).title}`)},t[9]=n,t[10]=u);let d;return t[11]!==o||t[12]!==s||t[13]!==c||t[14]!==l||t[15]!==u?(d=(0,X.jsx)(Vt,{fallbackRender:s,resetKeys:c,onReset:l,onError:u,children:o}),t[11]=o,t[12]=s,t[13]=c,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}function Qb(e){let t=e.threshold??5e5;return e.ytextLength>t?{renderSource:e.isSourceMode||e.visitedSource,renderVisual:!e.isSourceMode||e.visitedVisual,isLarge:!0}:{renderSource:!0,renderVisual:!0,isLarge:!1}}function $b(){return n(()=>import(`./SourceEditor-DETsdSVD.js`),__vite__mapDeps([24,1,19,2,3,20,21,13,12,5,6,22,7,25,15]),import.meta.url)}var ex=(0,Z.lazy)(async()=>({default:(await $b()).SourceEditor}));function tx(e,t,n){if(n<=0)return[];let r=e.filter(e=>!sn(e.docName)),i=[...r].sort((e,t)=>t.lastAccessedAt-e.lastAccessedAt).slice(0,n);if(t===null||i.some(e=>e.docName===t))return i;let a=r.find(e=>e.docName===t);return a?[...i.slice(0,n-1),a]:i}function nx(e,t){return t.kind===`idle`?null:t.kind===`failed`&&t.failedDocNames.includes(e)?{kind:`failed`,title:`Couldn't reconnect after server restart`,summary:t.reason===`clear-data-timeout`?`Local collaboration data for "${e}" could not be cleared in time. Reload to retry.`:`Local collaboration data for "${e}" could not be cleared. Reload to retry.`,actionLabel:`Reload`}:t.kind===`recovering`&&t.docNames.includes(e)?{kind:`recovering`,title:`Reconnecting after server restart`,summary:t.phase===`clearing-local-cache`?`Clearing local collaboration data for "${e}" before reconnecting.`:`Reopening "${e}" with a fresh local collaboration cache.`}:null}function rx(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,X.jsx)(un,{name:`activity-pool`,children:(0,X.jsx)(ix,{...e})}),t[0]=e,t[1]=n),n}function ix(e){let t=(0,Q.c)(12),{activeDocName:n,isSourceMode:r,editorPlaceholder:i,previousDocName:a,onNavigateBack:o,onRecycle:s}=e,{poolEntries:c,serverRestartRecovery:l}=Sn(),{pages:u,loading:d}=Pe(),f=tx(c,n,3),p=(0,Z.useRef)(``),m=f.map(ax).join(`,`);(0,Z.useLayoutEffect)(()=>{if(p.current===m)return;let e=p.current?p.current.split(`,`):[],t=m?m.split(`,`):[];wn(`ok/activity/mount-list-change`,{active:n,mounted:t,evicted:e.filter(e=>!t.includes(e))}),p.current=m,Ft(t)},[m,n]);let h;t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==d||t[4]!==o||t[5]!==s||t[6]!==u||t[7]!==a||t[8]!==l?(h=e=>(0,X.jsx)(ux,{entry:e,isActive:e.docName===n,isSourceMode:r,editorPlaceholder:i,isNewDoc:!d&&!u.has(e.docName),previousDocName:a,onNavigateBack:o,onRecycle:s,serverRestartRecovery:l},e.docName),t[0]=n,t[1]=i,t[2]=r,t[3]=d,t[4]=o,t[5]=s,t[6]=u,t[7]=a,t[8]=l,t[9]=h):h=t[9];let g=f.map(h),_;return t[10]===g?_=t[11]:(_=(0,X.jsx)(X.Fragment,{children:g}),t[10]=g,t[11]=_),_}function ax(e){return e.docName}function ox(e){let t=(0,Q.c)(8),{isActive:n,children:r}=e,i=(0,Z.useRef)(null),a=(0,Z.useRef)(0),o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{let e=i.current;if(!e)return;let t=()=>{e.scrollTop>0&&(a.current=e.scrollTop)};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},s=[],t[0]=o,t[1]=s):(o=t[0],s=t[1]),(0,Z.useEffect)(o,s);let c,l;t[2]===n?(c=t[3],l=t[4]):(c=()=>{if(!n)return;let e=i.current;if(!e)return;let t=a.current;if(t===0||(e.scrollTop=t,e.scrollTop===t))return;let r=!1,o=()=>{r||(r=!0,s.disconnect(),clearTimeout(c))},s=new ResizeObserver(()=>{r||!e||e.scrollHeight>t&&(e.scrollTop=t,e.scrollTop===t&&o())});s.observe(e);let c=setTimeout(o,500);return o},l=[n],t[2]=n,t[3]=c,t[4]=l),(0,Z.useLayoutEffect)(c,l);let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u={overflowAnchor:`auto`},t[5]=u):u=t[5];let d;return t[6]===r?d=t[7]:(d=(0,X.jsx)(`div`,{ref:i,className:`subtle-scrollbar h-full overflow-y-auto`,style:u,children:r}),t[6]=r,t[7]=d),d}function sx(e){let t=(0,Q.c)(12),{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a}=e,o=r&&i,[s,c]=(0,Z.useState)(o),l,u;if(t[0]===o?(l=t[1],u=t[2]):(l=()=>{o&&c(!0)},u=[o],t[0]=o,t[1]=l,t[2]=u),(0,Z.useEffect)(l,u),!s&&!o)return null;let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,X.jsx)(N_,{}),t[3]=d):d=t[3];let f=n.docName,p;t[4]===n.provider.document?p=t[5]:(p=n.provider.document.getText(`source`),t[4]=n.provider.document,t[5]=p);let m;return t[6]!==a||t[7]!==n.docName||t[8]!==n.provider||t[9]!==o||t[10]!==p?(m=(0,X.jsx)(Z.Suspense,{fallback:d,children:(0,X.jsx)(ex,{docName:f,ytext:p,provider:n.provider,placeholder:a,isSourceModeActive:o})}),t[6]=a,t[7]=n.docName,t[8]=n.provider,t[9]=o,t[10]=p,t[11]=m):m=t[11],m}function cx(e){let t=(0,Q.c)(18),{view:n}=e,r=n.kind===`failed`,i=r?`alert`:`status`,a=!r,o;t[0]===r?o=t[1]:(o=(0,X.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-full border bg-muted text-muted-foreground`,children:r?(0,X.jsx)(wa,{className:`size-5`,"aria-hidden":`true`}):(0,X.jsx)(Rn,{className:`size-5 animate-spin`,"aria-hidden":`true`})}),t[0]=r,t[1]=o);let s;t[2]===n.title?s=t[3]:(s=(0,X.jsx)(`h2`,{className:`text-lg font-medium`,children:n.title}),t[2]=n.title,t[3]=s);let c;t[4]===n.summary?c=t[5]:(c=(0,X.jsx)(`p`,{className:`max-w-md text-sm text-muted-foreground`,children:n.summary}),t[4]=n.summary,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]!==r||t[10]!==n.actionLabel?(u=r?(0,X.jsxs)(J,{type:`button`,onClick:lx,children:[(0,X.jsx)(wa,{className:`size-4`,"aria-hidden":`true`}),n.actionLabel]}):null,t[9]=r,t[10]=n.actionLabel,t[11]=u):u=t[11];let d;return t[12]!==i||t[13]!==a||t[14]!==o||t[15]!==l||t[16]!==u?(d=(0,X.jsxs)(`div`,{"data-slot":`server-restart-recovery`,role:i,"aria-busy":a,className:`flex h-full flex-col items-center justify-center gap-6 p-8 text-center`,children:[o,l,u]}),t[12]=i,t[13]=a,t[14]=o,t[15]=l,t[16]=u,t[17]=d):d=t[17],d}function lx(){return window.location.reload()}function ux(e){let t=(0,Q.c)(36),{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a,isNewDoc:o,previousDocName:s,onNavigateBack:c,onRecycle:l,serverRestartRecovery:u}=e,d;t[0]!==n.docName||t[1]!==u?(d=nx(n.docName,u),t[0]=n.docName,t[1]=u,t[2]=d):d=t[2];let f=d,p=n.provider.document.getText(`source`).length,[m,h]=(0,Z.useState)(i),[g,_]=(0,Z.useState)(!i),v,y;t[3]!==i||t[4]!==m||t[5]!==g?(v=()=>{i&&!m?h(!0):!i&&!g&&_(!0)},y=[i,m,g],t[3]=i,t[4]=m,t[5]=g,t[6]=v,t[7]=y):(v=t[6],y=t[7]),(0,Z.useEffect)(v,y);let b=Qb({ytextLength:p,isSourceMode:i,visitedSource:m,visitedVisual:g}),x=(0,Z.useRef)(``),S=`${b.isLarge}-${b.renderSource}-${b.renderVisual}`,C,w;t[8]!==n.docName||t[9]!==b.isLarge||t[10]!==b.renderSource||t[11]!==b.renderVisual||t[12]!==S||t[13]!==i||t[14]!==p?(C=()=>{x.current!==S&&(x.current=S,b.isLarge&&wn(`ok/activity/defer-mount`,{docName:n.docName,ytextLength:p,isSourceMode:i,renderSource:b.renderSource,renderVisual:b.renderVisual}))},w=[S,b.isLarge,b.renderSource,b.renderVisual,n.docName,p,i],t[8]=n.docName,t[9]=b.isLarge,t[10]=b.renderSource,t[11]=b.renderVisual,t[12]=S,t[13]=i,t[14]=p,t[15]=C,t[16]=w):(C=t[15],w=t[16]),(0,Z.useEffect)(C,w);let T=r?`visible`:`hidden`,E=`editor:${n.docName}`,D;t[17]!==a||t[18]!==n||t[19]!==b.renderSource||t[20]!==b.renderVisual||t[21]!==r||t[22]!==o||t[23]!==i||t[24]!==c||t[25]!==l||t[26]!==s||t[27]!==f?(D=f?(0,X.jsx)(cx,{view:f}):(0,X.jsx)(X.Fragment,{children:(0,X.jsx)(Zb,{activeDocName:n.docName,previousDocName:s,onNavigateBack:c,onRecycle:l,children:(0,X.jsx)(Z.Suspense,{fallback:(0,X.jsx)(N_,{}),children:(0,X.jsx)(Kb,{docName:n.docName,provider:n.provider,children:(0,X.jsxs)(`div`,{className:`relative h-full`,children:[b.renderSource?(0,X.jsx)(`div`,{className:i?`h-full`:`ok-mode-hidden h-full`,children:(0,X.jsx)(sx,{entry:n,isActive:r,isSourceMode:i,editorPlaceholder:a})}):null,b.renderVisual?(0,X.jsx)(`div`,{className:i?`ok-mode-hidden h-full`:`h-full`,children:(0,X.jsx)(Ub,{provider:n.provider,placeholder:a,isSourceMode:i},`${n.docName}-${String(o)}`)}):null]})})})})}),t[17]=a,t[18]=n,t[19]=b.renderSource,t[20]=b.renderVisual,t[21]=r,t[22]=o,t[23]=i,t[24]=c,t[25]=l,t[26]=s,t[27]=f,t[28]=D):D=t[28];let O;t[29]!==r||t[30]!==D?(O=(0,X.jsx)(ox,{isActive:r,children:D}),t[29]=r,t[30]=D,t[31]=O):O=t[31];let k;return t[32]!==T||t[33]!==E||t[34]!==O?(k=(0,X.jsx)(Z.Activity,{mode:T,name:E,children:O}),t[32]=T,t[33]=E,t[34]=O,t[35]=k):k=t[35],k}function dx(e){let t=(0,Q.c)(26),{stats:n}=e,r;t[0]===n.words?r=t[1]:(r=n.words.toLocaleString(),t[0]=n.words,t[1]=r);let i;t[2]===r?i=t[3]:(i=(0,X.jsx)(`span`,{className:`tabular-nums`,children:r}),t[2]=r,t[3]=i);let a=n.words===1?`word`:`words`,o;t[4]!==i||t[5]!==a?(o=(0,X.jsxs)(`span`,{children:[i,` `,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6];let s;t[7]===n.chars?s=t[8]:(s=n.chars.toLocaleString(),t[7]=n.chars,t[8]=s);let c;t[9]===s?c=t[10]:(c=(0,X.jsx)(`span`,{className:`tabular-nums`,children:s}),t[9]=s,t[10]=c);let l=n.chars===1?`char`:`chars`,u;t[11]!==c||t[12]!==l?(u=(0,X.jsxs)(`span`,{children:[c,` `,l]}),t[11]=c,t[12]=l,t[13]=u):u=t[13];let d=n.tokens>0?`~`:``,f;t[14]===n.tokens?f=t[15]:(f=n.tokens.toLocaleString(),t[14]=n.tokens,t[15]=f);let p;t[16]===f?p=t[17]:(p=(0,X.jsx)(`span`,{className:`tabular-nums`,children:f}),t[16]=f,t[17]=p);let m=n.tokens===1?`token`:`tokens`,h;t[18]!==p||t[19]!==m||t[20]!==d?(h=(0,X.jsxs)(`span`,{children:[d,p,` `,m]}),t[18]=p,t[19]=m,t[20]=d,t[21]=h):h=t[21];let g;return t[22]!==h||t[23]!==o||t[24]!==u?(g=(0,X.jsxs)(`section`,{"aria-label":`Document statistics`,className:`flex h-6 shrink-0 items-center justify-end gap-3 px-3 text-2xs text-muted-foreground`,children:[o,u,h]}),t[22]=h,t[23]=o,t[24]=u,t[25]=g):g=t[25],g}var fx=(0,Z.lazy)(()=>n(()=>import(`./SettingsPane-DI69uSJ8.js`).then(e=>({default:e.SettingsPane})),__vite__mapDeps([26,1,19,2,3,20,21,13,12,5,6,22,7,14,27,17]),import.meta.url));function px(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=(0,X.jsx)(un,{name:`editor-area`,children:(0,X.jsx)(mx,{...e})}),t[0]=e,t[1]=n),n}function mx(e){let t=(0,Q.c)(92),{editorMode:n,activeTab:r,onActiveTabChange:i}=e,a=ed(),{activeDocName:o,activeProvider:s,activeTarget:c,recycleDocument:l,docPanelMode:u,docPanelExpandSignal:d}=Sn(),{openDocumentTransition:f}=En(),p=ky(s,o),m=(0,Z.useDeferredValue)(o),h=c?.kind===`missing`,g=!!o&&c?.kind!==`folder`,_=h?`Start writing to create this page…`:void 0,v=A_(),[y,b]=(0,Z.useState)(!1),{layout:x,autoCollapse:S}=vy(),C=x===`sheet`,[w,T]=(0,Z.useState)(!1),E=(0,Z.useRef)(!1),D,O;t[0]!==S||t[1]!==x||t[2]!==v?(D=()=>{x===`panel`&&(S?(E.current=!1,v.current?.collapse()):E.current||v.current?.expand())},O=[S,x,v],t[0]=S,t[1]=x,t[2]=v,t[3]=D,t[4]=O):(D=t[3],O=t[4]),(0,Z.useEffect)(D,O);let k,A;t[5]!==d||t[6]!==C||t[7]!==v?(k=()=>{d!==0&&(C?T(!0):(E.current=!1,v.current?.expand()))},A=[d,C,v],t[5]=d,t[6]=C,t[7]=v,t[8]=k,t[9]=A):(k=t[8],A=t[9]),(0,Z.useEffect)(k,A);let j=(0,Z.useRef)(null),[M,N]=(0,Z.useState)(null),P,F;if(t[10]===o?(P=t[11],F=t[12]):(P=()=>{if(o&&o!==j.current){let e=j.current;j.current=o,N(e)}},F=[o],t[10]=o,t[11]=P,t[12]=F),(0,Z.useEffect)(P,F),a.scope!==null){let e;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(N_,{}),t[13]=e):e=t[13];let n;return t[14]!==a.close||t[15]!==a.scope||t[16]!==a.setScope?(n=(0,X.jsx)(Z.Suspense,{fallback:e,children:(0,X.jsx)(fx,{scope:a.scope,onClose:a.close,onScopeChange:a.setScope})}),t[14]=a.close,t[15]=a.scope,t[16]=a.setScope,t[17]=n):n=t[17],n}if(c?.kind===`folder`){let e;return t[18]===c.folderPath?e=t[19]:(e=(0,X.jsx)(cy,{folderPath:c.folderPath}),t[18]=c.folderPath,t[19]=e),e}if(!s||!o){if((typeof window<`u`?Re(window.location.hash):null)!==null){let e;return t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(N_,{}),t[20]=e):e=t[20],e}let e;return t[21]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Av,{}),t[21]=e):e=t[21],e}let I=n===`source`,L=C?!w:y,R;t[22]!==y||t[23]!==C||t[24]!==v?(R=()=>{C?T(hx):y?(E.current=!1,v.current?.expand()):(E.current=!0,v.current?.collapse())},t[22]=y,t[23]=C,t[24]=v,t[25]=R):R=t[25];let z=L?`Show document panel`:`Hide document panel`,B;t[26]===L?B=t[27]:(B=L?(0,X.jsx)(_a,{className:`size-4`}):(0,X.jsx)(ga,{className:`size-4`}),t[26]=L,t[27]=B);let V;t[28]!==R||t[29]!==z||t[30]!==B?(V=(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(J,{variant:`ghost`,size:`icon`,onClick:R,"aria-label":z,className:`text-muted-foreground`,children:B})}),t[28]=R,t[29]=z,t[30]=B,t[31]=V):V=t[31];let H=L?`Show panel`:`Hide panel`,U;t[32]===H?U=t[33]:(U=(0,X.jsx)(Fr,{side:`left`,children:H}),t[32]=H,t[33]=U);let W;t[34]!==V||t[35]!==U?(W=(0,X.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:(0,X.jsxs)(Lr,{children:[V,U]})}),t[34]=V,t[35]=U,t[36]=W):W=t[36];let G=W,ee=m??o,K=M??void 0,te;t[37]===f?te=t[38]:(te=e=>{let t=$e(e);window.location.hash===t?f(e):window.location.hash=t},t[37]=f,t[38]=te);let ne;t[39]!==_||t[40]!==I||t[41]!==l||t[42]!==ee||t[43]!==K||t[44]!==te?(ne=(0,X.jsx)(rx,{activeDocName:ee,isSourceMode:I,editorPlaceholder:_,previousDocName:K,onNavigateBack:te,onRecycle:l}),t[39]=_,t[40]=I,t[41]=l,t[42]=ee,t[43]=K,t[44]=te,t[45]=ne):ne=t[45];let re;t[46]!==o||t[47]!==m?(re=o&&o!==m?(0,X.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,X.jsx)(N_,{})}):null,t[46]=o,t[47]=m,t[48]=re):re=t[48];let ie;t[49]!==ne||t[50]!==re?(ie=(0,X.jsxs)(`div`,{className:`relative h-full`,children:[ne,re]}),t[49]=ne,t[50]=re,t[51]=ie):ie=t[51];let ae;t[52]!==ie||t[53]!==G?(ae=(0,X.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[ie,G]}),t[52]=ie,t[53]=G,t[54]=ae):ae=t[54];let oe;t[55]!==g||t[56]!==p?(oe=g&&(0,X.jsx)(dx,{stats:p}),t[55]=g,t[56]=p,t[57]=oe):oe=t[57];let se;t[58]!==ae||t[59]!==oe?(se=(0,X.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[ae,oe]}),t[58]=ae,t[59]=oe,t[60]=se):se=t[60];let ce=se;if(C){let e;t[61]===ce?e=t[62]:(e=(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:ce}),t[61]=ce,t[62]=e);let n;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,X.jsx)(mm,{className:`sr-only`,children:(0,X.jsx)(hm,{children:`Document panel`})}),t[63]=n):n=t[63];let a;t[64]!==o||t[65]!==r||t[66]!==u||t[67]!==I||t[68]!==i?(a=(0,X.jsxs)(pm,{side:`right`,className:`flex w-80 sm:w-96 flex-col gap-0 p-0`,children:[n,(0,X.jsx)(Lh,{docName:o,isSourceMode:I,activeTab:r,onActiveTabChange:i,mode:u})]}),t[64]=o,t[65]=r,t[66]=u,t[67]=I,t[68]=i,t[69]=a):a=t[69];let s;t[70]!==w||t[71]!==a?(s=(0,X.jsx)(um,{open:w,onOpenChange:T,children:a}),t[70]=w,t[71]=a,t[72]=s):s=t[72];let c;return t[73]!==e||t[74]!==s?(c=(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[e,s]}),t[73]=e,t[74]=s,t[75]=c):c=t[75],c}let le;t[76]===ce?le=t[77]:(le=(0,X.jsx)(my,{minSize:`30%`,defaultSize:`75%`,children:ce}),t[76]=ce,t[77]=le);let ue;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,X.jsx)(hy,{withHandle:!0}),t[78]=ue):ue=t[78];let de;t[79]===Symbol.for(`react.memo_cache_sentinel`)?(de=e=>b(e.asPercentage===0),t[79]=de):de=t[79];let fe;t[80]!==o||t[81]!==r||t[82]!==u||t[83]!==I||t[84]!==i?(fe=(0,X.jsx)(Lh,{docName:o,isSourceMode:I,activeTab:r,onActiveTabChange:i,mode:u}),t[80]=o,t[81]=r,t[82]=u,t[83]=I,t[84]=i,t[85]=fe):fe=t[85];let pe;t[86]!==v||t[87]!==fe?(pe=(0,X.jsx)(my,{panelRef:v,defaultSize:`25%`,minSize:`300px`,maxSize:`40%`,collapsible:!0,collapsedSize:0,onResize:de,className:`flex flex-col bg-muted/20`,children:fe}),t[86]=v,t[87]=fe,t[88]=pe):pe=t[88];let me;return t[89]!==le||t[90]!==pe?(me=(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,X.jsxs)(py,{orientation:`horizontal`,children:[le,ue,pe]})}),t[89]=le,t[90]=pe,t[91]=me):me=t[91],me}function hx(e){return!e}function gx(e,t){return t.trim()}function _x(e){return![``,`.`,`..`].includes(e)&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)}function vx(e,t){let n=gx(e.kind,t),r=e.path.split(`/`);return r[r.length-1]=n,r.join(`/`)}function yx(e,t){if(t.length===0)return e;let n=new Map(t.map(e=>[e.fromDocName,e.toDocName]));return e.map(e=>({...e,docName:n.get(e.docName)??e.docName}))}function bx(e,t){if(t.length===0)return e;let n=new Set(t);return e.filter(e=>!n.has(e.docName))}function xx(e,t){return e?t.find(t=>t.fromDocName===e)?.toDocName??e:null}var Sx=1280;function Cx(){let e=(0,Q.c)(2),[t,n]=(0,Z.useState)(wx),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=window.matchMedia(`(max-width: ${Sx-1}px)`),t=()=>{n(window.innerWidth<Sx)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Z.useEffect)(r,i),t}function wx(){return window.innerWidth<Sx}function Tx(e){let t=e.endsWith(`rem`)?`rem`:`px`;return{value:Number.parseFloat(e),unit:t}}function Ex(e){let{value:t,unit:n}=Tx(e);return n===`rem`?t*16:t}function Dx(e,t){return`${t===`rem`?e.toFixed(1):Math.round(e)}${t}`}var Ox=3600*24*7;function kx(e){let t=(0,Q.c)(28),{direction:n,currentWidth:r,onResize:i,onToggle:a,isCollapsed:o,minResizeWidth:s,maxResizeWidth:c,enableToggle:l,enableAutoCollapse:u,autoCollapseThreshold:d,expandThreshold:f,enableDrag:p,setIsDraggingRail:m,widthCookieName:h,widthCookieMaxAge:g,isNested:_}=e,v=n===void 0?`right`:n,y=o===void 0?!1:o,b=s===void 0?`14rem`:s,x=c===void 0?`24rem`:c,S=l===void 0?!0:l,C=u===void 0?!0:u,w=d===void 0?1.5:d,T=f===void 0?.2:f,E=p===void 0?!0:p,D=m===void 0?Ax:m,O=g===void 0?Ox:g,k=_===void 0?!1:_,A=(0,Z.useRef)(null),j=(0,Z.useRef)(0),M=(0,Z.useRef)(0),N=(0,Z.useRef)(!1),P=(0,Z.useRef)(!1),F=(0,Z.useRef)(null),I=(0,Z.useRef)(0),L=(0,Z.useRef)(!1),R=(0,Z.useRef)(0),z=(0,Z.useRef)(0),B=(0,Z.useRef)(null),V=(0,Z.useRef)(r),H=(0,Z.useRef)(y),U,W;t[0]===r?(U=t[1],W=t[2]):(U=()=>{V.current=r},W=[r],t[0]=r,t[1]=U,t[2]=W),(0,Z.useEffect)(U,W);let G,ee;t[3]===y?(G=t[4],ee=t[5]):(G=()=>{H.current=y},ee=[y],t[3]=y,t[4]=G,t[5]=ee),(0,Z.useEffect)(G,ee);let K=Ex(b),te;t[6]===x?te=t[7]:(te=Ex(x),t[6]=x,t[7]=te);let ne=te,re;t[8]!==E||t[9]!==k?(re=function(e){P.current=!0,E&&(j.current=H.current?0:Ex(V.current),M.current=e.clientX,I.current=e.clientX,F.current=null,L.current=!1,R.current=0,z.current=0,B.current=k&&A.current?A.current.getBoundingClientRect():null,e.preventDefault())},t[8]=E,t[9]=k,t[10]=re):re=t[10];let ie=re,ae,oe;t[11]!==w||t[12]!==v||t[13]!==C||t[14]!==S||t[15]!==T||t[16]!==k||t[17]!==ne||t[18]!==K||t[19]!==i||t[20]!==a||t[21]!==D||t[22]!==O||t[23]!==h?(ae=()=>{let e=function(e){h&&(document.cookie=`${h}=${e}; path=/; max-age=${O}`)},t=function(e,t){return v===`left`?e<t:e>t},n=function(e,t,n,r){if(k&&r){let r=e.clientX-t;return v===`left`?n-r:n+r}return v===`left`?window.innerWidth-e.clientX:e.clientX},r=function(r){if(!P.current)return;let o=Math.abs(r.clientX-M.current);if(!N.current&&o>5&&(N.current=!0,D(!0)),N.current){let{unit:o}=Tx(V.current),s=B.current;k&&A.current&&(s=A.current.getBoundingClientRect());let c=t(r.clientX,I.current)?`expand`:`collapse`;F.current!==c&&(F.current=c),z.current=Math.abs(r.clientX-I.current);let l=Date.now();if(L.current&&l-R.current>200&&(L.current=!1),!L.current){if(C&&a&&!H.current){let e=n(r,M.current,j.current,s),t=!1;if(w<=1)t=e<=K*w;else if(e<=K){let n=K*(w-1);t=K-e>=n}if(c===`collapse`&&t){a(),I.current=r.clientX,L.current=!0,R.current=l;return}}if(a&&H.current&&c===`expand`&&z.current>K*T){a();let t=n(r,M.current,j.current,s),c=Math.max(K,Math.min(ne,t)),u=Dx(o===`rem`?c/16:c,o);i(u),e(u),I.current=r.clientX,L.current=!0,R.current=l;return}}if(H.current)return;let u=n(r,M.current,j.current,s),d=Math.max(K,Math.min(ne,u)),f=Dx(o===`rem`?d/16:d,o);i(f),e(f)}},o=function(){P.current&&(!N.current&&a&&S&&a(),N.current=!1,P.current=!1,F.current=null,I.current=0,L.current=!1,R.current=0,z.current=0,B.current=null,D(!1))};return document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,o),()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,o)}},oe=[i,a,D,K,ne,k,C,w,T,S,h,O,v],t[11]=w,t[12]=v,t[13]=C,t[14]=S,t[15]=T,t[16]=k,t[17]=ne,t[18]=K,t[19]=i,t[20]=a,t[21]=D,t[22]=O,t[23]=h,t[24]=ae,t[25]=oe):(ae=t[24],oe=t[25]),(0,Z.useEffect)(ae,oe);let se;return t[26]===ie?se=t[27]:(se={dragRef:A,isDragging:N,handleMouseDown:ie},t[26]=ie,t[27]=se),se}function Ax(){}var jx=`sidebar_state`,Mx=3600*24*7,Nx=`18rem`,Px=`3rem`,Fx=`\\`,Ix=`app-file-sidebar`,Lx=`14rem`,Rx=`22rem`,zx=`sidebar_width`,Bx=/^\d+(?:\.\d+)?(?:rem|px)$/,Vx=Z.createContext(null);function Hx(e){if(typeof document>`u`)return e;let t=document.cookie.split(`; `).find(e=>e.startsWith(`${zx}=`))?.split(`=`)[1];if(!t)return e;let n=decodeURIComponent(t);return Bx.test(n)?n:e}function Ux(){let e=Z.use(Vx);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function Wx(e){let t=(0,Q.c)(55),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({defaultOpen:c,open:i,onOpenChange:o,className:r,style:s,children:n,defaultWidth:l,...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,t[8]=l);let u=c===void 0?!0:c,d=l===void 0?Nx:l,f=Cx(),p;t[9]===d?p=t[10]:(p=()=>Hx(d),t[9]=d,t[10]=p);let[m,h]=Z.useState(p),[g,_]=Z.useState(!1),[v,y]=Z.useState(!1),[b,x]=Z.useState(!1),[S,C]=Z.useState(u),w=i??S,T;t[11]!==w||t[12]!==o?(T=e=>{let t=typeof e==`function`?e(w):e;o?o(t):C(t),document.cookie=`${jx}=${t}; path=/; max-age=${Mx}`},t[11]=w,t[12]=o,t[13]=T):T=t[13];let E=T,D;t[14]!==f||t[15]!==E?(D=function(){return f?_(Kx):E(Gx)},t[14]=f,t[15]=E,t[16]=D):D=t[16];let O=D,k;t[17]!==f||t[18]!==g?(k=function(){!f||!g||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches||x(!0)},t[17]=f,t[18]=g,t[19]=k):k=t[19];let A=k,j,M;t[20]===O?(j=t[21],M=t[22]):(j=()=>{let e=e=>{e.key===Fx&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),O())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},M=[O],t[20]=O,t[21]=j,t[22]=M),Z.useEffect(j,M);let N,P;t[23]!==f||t[24]!==g?(P=()=>{if(!f||!g)return;let e=e=>{e.key===`Escape`&&(document.querySelector(`[data-state="open"][role="dialog"], [data-state="open"][role="alertdialog"], [data-state="open"][role="menu"], [data-state="open"][role="listbox"], [data-radix-popper-content-wrapper] [data-state="open"]`)||_(!1))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},N=[f,g],t[23]=f,t[24]=g,t[25]=N,t[26]=P):(N=t[25],P=t[26]),Z.useEffect(P,N);let F=Z.useRef(f),I,L;t[27]!==f||t[28]!==w?(I=()=>{!F.current&&f&&_(w),F.current=f},L=[f,w],t[27]=f,t[28]=w,t[29]=I,t[30]=L):(I=t[29],L=t[30]),Z.useEffect(I,L);let R=f?g?`expanded`:`collapsed`:w?`expanded`:`collapsed`,z;t[31]!==v||t[32]!==f||t[33]!==A||t[34]!==w||t[35]!==g||t[36]!==E||t[37]!==b||t[38]!==R||t[39]!==O||t[40]!==m?(z={state:R,open:w,setOpen:E,isMobile:f,openMobile:g,setOpenMobile:_,toggleSidebar:O,width:m,setWidth:h,isDraggingRail:v,setIsDraggingRail:y,showPushPulse:b,setShowPushPulse:x,notifySidebarFileSelected:A},t[31]=v,t[32]=f,t[33]=A,t[34]=w,t[35]=g,t[36]=E,t[37]=b,t[38]=R,t[39]=O,t[40]=m,t[41]=z):z=t[41];let B;t[42]!==s||t[43]!==m?(B={"--sidebar-width":m,"--sidebar-width-icon":Px,...s},t[42]=s,t[43]=m,t[44]=B):B=t[44];let V=B,H;t[45]===r?H=t[46]:(H=q(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),t[45]=r,t[46]=H);let U;t[47]!==n||t[48]!==a||t[49]!==V||t[50]!==H?(U=(0,X.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:V,className:H,...a,children:n}),t[47]=n,t[48]=a,t[49]=V,t[50]=H,t[51]=U):U=t[51];let W;return t[52]!==z||t[53]!==U?(W=(0,X.jsx)(Vx.Provider,{value:z,children:U}),t[52]=z,t[53]=U,t[54]=W):W=t[54],W}function Gx(e){return!e}function Kx(e){return!e}function qx(e){let t=(0,Q.c)(51),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({side:a,variant:o,collapsible:s,className:r,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);let c=a===void 0?`left`:a,l=o===void 0?`sidebar`:o,u=s===void 0?`offcanvas`:s,{isMobile:d,state:f,openMobile:p,isDraggingRail:m}=Ux();if(u===`none`){let e;t[7]===r?e=t[8]:(e=q(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),t[7]=r,t[8]=e);let a;return t[9]!==n||t[10]!==i||t[11]!==e||t[12]!==l?(a=(0,X.jsx)(`div`,{"data-slot":`sidebar`,"data-variant":l,className:e,...i,children:n}),t[9]=n,t[10]=i,t[11]=e,t[12]=l,t[13]=a):a=t[13],a}if(d){let e=p?`expanded`:`collapsed`,a=l===`floating`||l===`inset`?`p-2`:``,o;t[14]!==r||t[15]!==a?(o=q(`fixed inset-y-0 z-30 flex h-svh w-(--sidebar-width)`,`transition-transform duration-200 ease-linear motion-reduce:transition-none`,`data-[side=left]:left-0 data-[side=right]:right-0`,`group-data-[state=collapsed]:data-[side=left]:-translate-x-full`,`group-data-[state=collapsed]:data-[side=right]:translate-x-full`,a,r),t[14]=r,t[15]=a,t[16]=o):o=t[16];let s;t[17]===n?s=t[18]:(s=(0,X.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[17]=n,t[18]=s);let u;t[19]!==i||t[20]!==c||t[21]!==o||t[22]!==s?(u=(0,X.jsx)(`nav`,{id:Ix,"aria-label":`File sidebar`,"data-slot":`sidebar-container`,"data-side":c,className:o,...i,children:s}),t[19]=i,t[20]=c,t[21]=o,t[22]=s,t[23]=u):u=t[23];let d;return t[24]!==e||t[25]!==c||t[26]!==u||t[27]!==l?(d=(0,X.jsx)(`div`,{className:`group peer text-sidebar-foreground`,"data-state":e,"data-variant":l,"data-side":c,"data-slot":`sidebar`,"data-mobile":`true`,children:u}),t[24]=e,t[25]=c,t[26]=u,t[27]=l,t[28]=d):d=t[28],d}let h=f===`collapsed`?u:``,g=l===`floating`||l===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`,_;t[29]===g?_=t[30]:(_=q(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,g,`group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0`),t[29]=g,t[30]=_);let v;t[31]===_?v=t[32]:(v=(0,X.jsx)(`div`,{"data-slot":`sidebar-gap`,className:_}),t[31]=_,t[32]=v);let y=l===`floating`||l===`inset`?`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l`,b;t[33]!==r||t[34]!==y?(b=q(`fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear 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`,y,`group-data-[dragging=true]:duration-0! group-data-[dragging=true]_*:!duration-0`,r),t[33]=r,t[34]=y,t[35]=b):b=t[35];let x;t[36]===n?x=t[37]:(x=(0,X.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[36]=n,t[37]=x);let S;t[38]!==i||t[39]!==c||t[40]!==x||t[41]!==b?(S=(0,X.jsx)(`div`,{"data-slot":`sidebar-container`,"data-side":c,className:b,...i,children:x}),t[38]=i,t[39]=c,t[40]=x,t[41]=b,t[42]=S):S=t[42];let C;return t[43]!==m||t[44]!==c||t[45]!==f||t[46]!==S||t[47]!==h||t[48]!==v||t[49]!==l?(C=(0,X.jsxs)(`div`,{className:`group peer hidden text-sidebar-foreground md:block`,"data-state":f,"data-collapsible":h,"data-variant":l,"data-side":c,"data-slot":`sidebar`,"data-dragging":m,children:[v,S]}),t[43]=m,t[44]=c,t[45]=f,t[46]=S,t[47]=h,t[48]=v,t[49]=l,t[50]=C):C=t[50],C}function Jx(e){let t=(0,Q.c)(16),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,state:o}=Ux(),s=o===`expanded`,c;t[4]===n?c=t[5]:(c=q(n),t[4]=n,t[5]=c);let l;t[6]!==r||t[7]!==a?(l=e=>{r?.(e),a()},t[6]=r,t[7]=a,t[8]=l):l=t[8];let u,d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,X.jsx)(ha,{}),d=(0,X.jsx)(`span`,{className:`sr-only`,children:`Toggle Sidebar`}),t[9]=u,t[10]=d):(u=t[9],d=t[10]);let f;return t[11]!==i||t[12]!==s||t[13]!==c||t[14]!==l?(f=(0,X.jsxs)(J,{"data-sidebar":`trigger`,"data-slot":`sidebar-trigger`,variant:`ghost`,size:`icon-sm`,"aria-expanded":s,"aria-controls":Ix,className:c,onClick:l,...i,children:[u,d]}),t[11]=i,t[12]=s,t[13]=c,t[14]=l,t[15]=f):f=t[15],f}function Yx(e){let t=(0,Q.c)(22),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,enableDrag:a,onMouseDown:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?!0:a,{toggleSidebar:s,setWidth:c,state:l,width:u,setIsDraggingRail:d}=Ux(),f=l===`collapsed`,p;t[5]!==o||t[6]!==d||t[7]!==c||t[8]!==f||t[9]!==s||t[10]!==u?(p={direction:`right`,enableDrag:o,onResize:c,onToggle:s,currentWidth:u,isCollapsed:f,minResizeWidth:Lx,maxResizeWidth:Rx,setIsDraggingRail:d,widthCookieName:zx,widthCookieMaxAge:Mx},t[5]=o,t[6]=d,t[7]=c,t[8]=f,t[9]=s,t[10]=u,t[11]=p):p=t[11];let{dragRef:m,handleMouseDown:h}=kx(p),g;t[12]!==h||t[13]!==r?(g=e=>{r?.(e),e.defaultPrevented||h(e)},t[12]=h,t[13]=r,t[14]=g):g=t[14];let _;t[15]===n?_=t[16]:(_=q(`absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2`,`in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize`,`[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize`,`group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar`,`[[data-side=left][data-collapsible=offcanvas]_&]:-right-2`,`[[data-side=right][data-collapsible=offcanvas]_&]:-left-2`,n),t[15]=n,t[16]=_);let v;return t[17]!==m||t[18]!==i||t[19]!==g||t[20]!==_?(v=(0,X.jsx)(`button`,{ref:m,"data-sidebar":`rail`,"data-slot":`sidebar-rail`,"aria-label":`Toggle Sidebar`,tabIndex:-1,onMouseDown:g,title:`Toggle Sidebar`,className:_,...i}),t[17]=m,t[18]=i,t[19]=g,t[20]=_,t[21]=v):v=t[21],v}function Xx(e){let t=(0,Q.c)(21),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,onClick:i,onAnimationEnd:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{isMobile:o,openMobile:s,setOpenMobile:c,showPushPulse:l,setShowPushPulse:u}=Ux(),d;t[5]!==o||t[6]!==i||t[7]!==s||t[8]!==c?(d=e=>{i?.(e),!e.defaultPrevented&&(!o||!s||e.target?.closest(`[data-sidebar="trigger"]`)||c(!1))},t[5]=o,t[6]=i,t[7]=s,t[8]=c,t[9]=d):d=t[9];let f=d,p;t[10]!==r||t[11]!==u?(p=e=>{r?.(e),e.animationName===`sidebar-push-pulse`&&u(!1)},t[10]=r,t[11]=u,t[12]=p):p=t[12];let m=p,h=l?``:void 0,g;t[13]===n?g=t[14]:(g=q(`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`,`transition-transform duration-200 ease-linear motion-reduce:transition-none`,`peer-data-[mobile=true]:peer-data-[state=expanded]:translate-x-(--sidebar-width)`,n),t[13]=n,t[14]=g);let _;return t[15]!==m||t[16]!==f||t[17]!==a||t[18]!==h||t[19]!==g?(_=(0,X.jsx)(`main`,{"data-slot":`sidebar-inset`,"data-push-pulse":h,onClick:f,onAnimationEnd:m,className:g,...a}),t[15]=m,t[16]=f,t[17]=a,t[18]=h,t[19]=g,t[20]=_):_=t[20],_}function Zx(e){let t=(0,Q.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=q(`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,X.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 Qx(e){let t=(0,Q.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=q(`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,X.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 $x(e){let t=(0,Q.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=q(`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,X.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 eS(e){let t=(0,Q.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=q(`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,X.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 tS(e){let t=(0,Q.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=q(`group/menu-item relative`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.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 nS=lt(`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:bg-sidebar-hover hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-hover 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-hover data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground data-active:hover:bg-sidebar-accent [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate`,{variants:{variant:{default:`hover:bg-sidebar-hover hover:text-sidebar-accent-foreground`,outline:`bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-hover hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]`},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 rS(e){let t=(0,Q.c)(28),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]):({asChild:i,isActive:a,variant:o,size:s,tooltip:c,className:n,...r}=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=i===void 0?!1:i,u=a===void 0?!1:a,d=o===void 0?`default`:o,f=s===void 0?`default`:s,p=l?pt:`button`,{isMobile:m,state:h}=Ux(),g;t[8]!==n||t[9]!==f||t[10]!==d?(g=q(nS({variant:d,size:f}),n),t[8]=n,t[9]=f,t[10]=d,t[11]=g):g=t[11];let _;t[12]!==p||t[13]!==u||t[14]!==r||t[15]!==f||t[16]!==g?(_=(0,X.jsx)(p,{"data-slot":`sidebar-menu-button`,"data-sidebar":`menu-button`,"data-size":f,"data-active":u,className:g,...r}),t[12]=p,t[13]=u,t[14]=r,t[15]=f,t[16]=g,t[17]=_):_=t[17];let v=_;if(!c)return v;if(typeof c==`string`){let e;t[18]===c?e=t[19]:(e={children:c},t[18]=c,t[19]=e),c=e}let y;t[20]===v?y=t[21]:(y=(0,X.jsx)(Pr,{asChild:!0,children:v}),t[20]=v,t[21]=y);let b=h!==`collapsed`||m,x;t[22]!==b||t[23]!==c?(x=(0,X.jsx)(Fr,{side:`right`,align:`center`,hidden:b,...c}),t[22]=b,t[23]=c,t[24]=x):x=t[24];let S;return t[25]!==y||t[26]!==x?(S=(0,X.jsxs)(Lr,{children:[y,x]}),t[25]=y,t[26]=x,t[27]=S):S=t[27],S}function iS(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.kind!==i.kind)return!1;if(r.kind===`human`&&i.kind===`human`){if(r.clientId!==i.clientId||r.mode!==i.mode||r.tabCount!==i.tabCount)return!1;let e=r.user,t=i.user;if(e.name!==t.name||e.color!==t.color||e.icon!==t.icon)return!1}else if(r.kind===`agent`&&i.kind===`agent`){if(r.agentId!==i.agentId)return!1;let e=r.presence,t=i.presence;if(e.displayName!==t.displayName||e.icon!==t.icon||e.color!==t.color||e.currentDoc!==t.currentDoc||e.mode!==t.mode)return!1}}return!0}function aS(e){let t=new Map;for(let n of e){let e=n.user.principalId;if(typeof e==`string`&&e.length>0){let r=t.get(e);r?r.push(n):t.set(e,[n])}}let n=new Map;for(let[e,r]of t){let t=r.reduce((e,t)=>Math.min(e,t.clientId),1/0);n.set(e,{repClientId:t,count:r.length})}let r=[];for(let t of e){let e=t.user.principalId;if(typeof e==`string`&&e.length>0){let i=n.get(e);i&&i.repClientId===t.clientId&&r.push({...t,tabCount:i.count})}else r.push({...t,tabCount:1})}return r}var oS=1e3,sS=!1;function cS(e,t,n){let r=(0,Q.c)(9),i;r[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={current:[],crossDoc:[]},r[0]=i):i=r[0];let[a,o]=(0,Z.useState)(i),s;r[1]!==n||r[2]!==e?.awareness||r[3]!==t?.awareness?(s=()=>{let r=e?.awareness,i=t?.awareness,a;i==null?a=void 0:Qn(i)?a=i:(a=void 0,sS||(sS=!0,console.warn(`[agent-presence] __system__ provider awareness missing getStates() — presence bar will render without agent peers`)));let s=()=>{let e=[];if(r)for(let[t,n]of r.getStates().entries()){let r=n;if(!r.user||typeof r.user!=`object`)continue;let i=r.user;i.type===`human`&&e.push({kind:`human`,clientId:t,user:i,mode:r.mode??`wysiwyg`,tabCount:1})}let t=aS(e),{current:i,crossDoc:s}=a?qn(a,n,Date.now()):{current:[],crossDoc:[]},c=lS,l=i.map(c),u=s.map(c),d=[...t,...l],f=u;o(e=>iS(e.current,d)&&iS(e.crossDoc,f)?e:{current:d,crossDoc:f})};s();let c=()=>s(),l=()=>s();r?.on(`change`,c),t?.awareness?.on(`change`,l);let u=setInterval(s,oS);return()=>{r?.off(`change`,c),t?.awareness?.off(`change`,l),clearInterval(u)}},r[1]=n,r[2]=e?.awareness,r[3]=t?.awareness,r[4]=s):s=r[4];let c;return r[5]!==n||r[6]!==e||r[7]!==t?(c=[e,t,n],r[5]=n,r[6]=e,r[7]=t,r[8]=c):c=r[8],(0,Z.useEffect)(s,c),a}function lS(e){let{agentId:t,entry:n}=e;return{kind:`agent`,agentId:t,presence:n}}function uS(e){let t=(0,Q.c)(3),[n,r]=(0,Z.useState)(`connecting`),i,a;return t[0]===e?(i=t[1],a=t[2]):(i=()=>{if(!e){r(`connecting`);return}let t=e.configuration.websocketProvider.status;e.isSynced?r(`synced`):r(t===`connected`?`connected`:t===`disconnected`?`disconnected`:`connecting`);let n=e=>{let{status:t}=e;r(t===`connected`?dS:t===`disconnected`?`disconnected`:`connecting`)},i=e=>{let{state:t}=e;r(t?`synced`:`connected`)},a=()=>r(`disconnected`);return e.on(`status`,n),e.on(`synced`,i),e.on(`disconnect`,a),()=>{e.off(`status`,n),e.off(`synced`,i),e.off(`disconnect`,a)}},a=[e],t[0]=e,t[1]=i,t[2]=a),(0,Z.useEffect)(i,a),n}function dS(e){return e===`synced`?`synced`:`connected`}var fS=`sync-status`;function pS(e,t){let n=(0,Q.c)(4),r=(0,Z.useRef)(!1),i=(0,Z.useRef)(!1),a=(0,Z.useRef)(t),o,s;n[0]!==t||n[1]!==e?(o=()=>{a.current!==t&&(a.current=t,r.current=!1,i.current=!1),t&&(e===`synced`&&(r.current=!0),e===`disconnected`&&r.current?(i.current=!0,Ar.warning(`Connection lost — keep this tab open, your edits will sync when reconnected`,{id:fS,duration:1/0})):i.current&&e===`synced`&&(i.current=!1,Ar.success(`Reconnected`,{id:fS,duration:3e3})))},s=[e,t],n[0]=t,n[1]=e,n[2]=o,n[3]=s):(o=n[2],s=n[3]),(0,Z.useEffect)(o,s)}var mS=4,hS=3,gS={Bird:Di,Cat:Ni,Dog:Ki,Fish:Xi,Mouse:Ca,Rabbit:Sa,Shrimp:ka,Snail:Aa,Squirrel:Na,Turtle:La};Object.freeze([...Object.keys(gS)]);function _S(e){if(typeof e.principalId==`string`&&e.principalId.length>0)return{kind:`initials`};let t=e.name.split(` `)[1];return t&&Object.hasOwn(gS,t)?{kind:`animal`,animal:t}:{kind:`initials`}}var vS={claude:`Claude`,cursor:`Cursor`,windsurf:`Windsurf`,openai:`Codex`,github:`Copilot`,cline:`Cline`,bot:`Agent`};function yS(e){let t=(0,Q.c)(20),{user:n,mode:r,tabCount:i}=e,a=_S(n),o=a.kind===`animal`?gS[a.animal]:void 0,s;t[0]===n.name?s=t[1]:(s=Ue(n.name),t[0]=n.name,t[1]=s);let c=s,l;t[2]===n.color?l=t[3]:(l=Te(n.color),t[2]=n.color,t[3]=l);let u=l,d=i>1?`${n.name} · ${i} tabs`:n.name,f=i>1?`${n.name}, ${i} concurrent tabs`:n.name,p;t[4]===n.color?p=t[5]:(p={backgroundColor:n.color},t[4]=n.color,t[5]=p);let m;t[6]!==o||t[7]!==u||t[8]!==c?(m=o?(0,X.jsx)(o,{size:18,color:u,strokeWidth:1.5}):(0,X.jsx)(`span`,{className:`font-mono text-2xs font-semibold leading-none`,style:{color:u},children:c}),t[6]=o,t[7]=u,t[8]=c,t[9]=m):m=t[9];let h;t[10]!==f||t[11]!==r||t[12]!==p||t[13]!==m?(h=(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(`div`,{"data-presence-badge":`human`,"data-presence-mode":r,role:`img`,"aria-label":f,className:`inline-flex size-7 shrink-0 cursor-default items-center justify-center rounded-full ring-2 ring-background`,style:p,children:m})}),t[10]=f,t[11]=r,t[12]=p,t[13]=m,t[14]=h):h=t[14];let g;t[15]===d?g=t[16]:(g=(0,X.jsx)(Fr,{children:d}),t[15]=d,t[16]=g);let _;return t[17]!==h||t[18]!==g?(_=(0,X.jsxs)(Lr,{children:[h,g]}),t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function bS(e){let t=vS[e.icon];return e.displayName||t||`Agent`}function xS(e){let t=(0,Q.c)(3),[n,r]=(0,Z.useState)(e===`writing`),i=(0,Z.useRef)(null),a,o;return t[0]===e?(a=t[1],o=t[2]):(a=()=>{if(e===`writing`){i.current!==null&&(clearTimeout(i.current),i.current=null),r(!0);return}return i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>{i.current=null,r(!1)},600),()=>{i.current!==null&&(clearTimeout(i.current),i.current=null)}},o=[e],t[0]=e,t[1]=a,t[2]=o),(0,Z.useEffect)(a,o),n}function SS(e){let t=(0,Q.c)(36),{participant:n,crossDoc:r,scoped:i,onClickAgent:a}=e,{presence:o,agentId:s}=n,c;t[0]===o?c=t[1]:(c=bS(o),t[0]=o,t[1]=c);let l=c,u=xS(o.mode),d=!r&&u,f=i?`ring-primary ring-offset-2 ring-offset-background`:`ring-background`,p=d&&!i?`ring-primary/40 animate-pulse`:``,m;t[2]!==f||t[3]!==p?(m=[`inline-flex size-7 shrink-0 items-center justify-center rounded-full ring-2 cursor-pointer`,f,p].filter(Boolean),t[2]=f,t[3]=p,t[4]=m):m=t[4];let h=m.join(` `),g=r?`true`:void 0,_=i?`true`:void 0,v;t[5]!==o.mode||t[6]!==g||t[7]!==_?(v={"data-presence-badge":`agent`,"data-presence-mode":o.mode,"data-presence-crossdoc":g,"data-presence-scoped":_},t[5]=o.mode,t[6]=g,t[7]=_,t[8]=v):v=t[8];let y=v,b=r&&o.currentDoc?`Open activity panel for ${l}, editing ${o.currentDoc}`:`Open activity panel for ${l}`,x;t[9]===o.color?x=t[10]:(x={backgroundColor:o.color},t[9]=o.color,t[10]=x);let S;t[11]!==s||t[12]!==a?(S=()=>a(s),t[11]=s,t[12]=a,t[13]=S):S=t[13];let C;t[14]===o.icon?C=t[15]:(C=(0,X.jsx)(Xn,{icon:o.icon,width:16,height:16,className:`text-white`}),t[14]=o.icon,t[15]=C);let w;t[16]!==b||t[17]!==y||t[18]!==h||t[19]!==C||t[20]!==x||t[21]!==S?(w=(0,X.jsx)(`button`,{type:`button`,...y,"aria-label":b,className:h,style:x,onClick:S,children:C}),t[16]=b,t[17]=y,t[18]=h,t[19]=C,t[20]=x,t[21]=S,t[22]=w):w=t[22];let T=w,E;t[23]===T?E=t[24]:(E=(0,X.jsx)(Pr,{asChild:!0,children:T}),t[23]=T,t[24]=E);let D;t[25]===l?D=t[26]:(D=(0,X.jsx)(`span`,{className:`font-medium`,children:l}),t[25]=l,t[26]=D);let O;t[27]!==r||t[28]!==o.currentDoc?(O=r&&o.currentDoc?(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`editing [[`,o.currentDoc,`]]`]}):null,t[27]=r,t[28]=o.currentDoc,t[29]=O):O=t[29];let k;t[30]!==D||t[31]!==O?(k=(0,X.jsxs)(Fr,{className:`flex flex-col gap-0.5`,children:[D,O]}),t[30]=D,t[31]=O,t[32]=k):k=t[32];let A;return t[33]!==E||t[34]!==k?(A=(0,X.jsxs)(Lr,{children:[E,k]}),t[33]=E,t[34]=k,t[35]=A):A=t[35],A}function CS(e){let t=(0,Q.c)(18),{count:n,remainder:r,crossDoc:i,scopedAgentId:a,onClickAgent:o}=e,s=i?`true`:void 0,c=`${n} more ${i?`cross-doc `:``}${n===1?`participant`:`participants`}`,l;t[0]!==n||t[1]!==s||t[2]!==c?(l=(0,X.jsx)(Dt,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,"data-slot":`presence-overflow`,"data-presence-crossdoc":s,className:`inline-flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-full bg-muted font-medium text-muted-foreground text-xs ring-2 ring-background hover:bg-muted/80`,"aria-label":c,children:[`+`,n]})}),t[0]=n,t[1]=s,t[2]=c,t[3]=l):l=t[3];let u;if(t[4]!==i||t[5]!==o||t[6]!==r||t[7]!==a){let e;t[9]!==i||t[10]!==o||t[11]!==a?(e=e=>e.kind===`human`?(0,X.jsx)(yS,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,X.jsx)(SS,{participant:e,crossDoc:i,scoped:a===e.agentId,onClickAgent:o},e.agentId),t[9]=i,t[10]=o,t[11]=a,t[12]=e):e=t[12],u=r.map(e),t[4]=i,t[5]=o,t[6]=r,t[7]=a,t[8]=u}else u=t[8];let d;t[13]===u?d=t[14]:(d=(0,X.jsx)(kt,{align:`end`,className:`w-auto max-w-xs p-2`,children:(0,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:u})}),t[13]=u,t[14]=d);let f;return t[15]!==l||t[16]!==d?(f=(0,X.jsxs)(Jt,{children:[l,d]}),t[15]=l,t[16]=d,t[17]=f):f=t[17],f}function wS(e,t,n,r){return e.kind===`human`?(0,X.jsx)(yS,{user:e.user,mode:e.mode,tabCount:e.tabCount},e.clientId):(0,X.jsx)(SS,{participant:e,crossDoc:n,scoped:r===e.agentId,onClickAgent:t},e.agentId)}function TS(){let e=(0,Q.c)(20),{activeProvider:t,activeDocName:n,systemProvider:r,openActivityPanel:i,docPanelMode:a,docPanelAgentId:o}=Sn(),{current:s,crossDoc:c}=cS(t,r,n);pS(uS(t),n);let l;if(e[0]!==c||e[1]!==s||e[2]!==o||e[3]!==a||e[4]!==i){let t=s.slice(0,mS),n;e[6]===s?n=e[7]:(n=s.slice(mS),e[6]=s,e[7]=n);let r=n,u=c.slice(0,hS),d;e[8]===c?d=e[9]:(d=c.slice(hS),e[8]=c,e[9]=d);let f=d,p=i,m=a===`agent`?o:null,h;e[10]!==p||e[11]!==m?(h=e=>wS(e,p,!1,m),e[10]=p,e[11]=m,e[12]=h):h=e[12];let g=t.map(h),_;e[13]!==r||e[14]!==p||e[15]!==m?(_=r.length>0?(0,X.jsx)(CS,{count:r.length,remainder:r,crossDoc:!1,scopedAgentId:m,onClickAgent:p}):null,e[13]=r,e[14]=p,e[15]=m,e[16]=_):_=e[16];let v;e[17]!==g||e[18]!==_?(v=(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,"data-presence-section":`current`,children:[g,_]}),e[17]=g,e[18]=_,e[19]=v):v=e[19],l=(0,X.jsxs)(`div`,{"data-slot":`presence-bar`,className:`flex items-center px-1 py-1.5`,children:[v,c.length>0?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`mx-2 h-4 w-px bg-border`,"aria-hidden":!0,"data-slot":`presence-divider`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 opacity-60 grayscale`,"data-presence-section":`crossdoc`,children:[u.map(e=>wS(e,p,!0,m)),f.length>0?(0,X.jsx)(CS,{count:f.length,remainder:f,crossDoc:!0,scopedAgentId:m,onClickAgent:p}):null]})]}):null]}),e[0]=c,e[1]=s,e[2]=o,e[3]=a,e[4]=i,e[5]=l}else l=e[5];return l}function ES(e){let t=(0,Q.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,X.jsx)(`title`,{children:`LinkedIn`}),r=(0,X.jsx)(`path`,{d:`M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,X.jsxs)(`svg`,{role:`img`,fill:`currentColor`,height:24,width:24,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}function DS(e){let t=(0,Q.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,X.jsx)(`title`,{children:`X (Twitter)`}),r=(0,X.jsx)(`path`,{d:`M18.901 1.153h3.68l-8.04 9.19L24 22.846h-7.406l-5.8-7.584-6.638 7.584H.474l8.6-9.83L0 1.154h7.594l5.243 6.932ZM17.61 20.644h2.039L6.486 3.24H4.298Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,X.jsxs)(`svg`,{role:`img`,fill:`currentColor`,height:24,width:24,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[n,r]}),t[2]=e,t[3]=i),i}var OS=[{label:`Documentation`,href:`https://openknowledge.ai/docs`,icon:ki},{label:`Homepage`,href:`https://openknowledge.ai/`,icon:sr},{label:`Twitter / X`,href:`https://x.com/inkeep`,icon:DS},{label:`LinkedIn`,href:`https://www.linkedin.com/company/inkeep/`,icon:ES}],kS=()=>{let e=(0,Q.c)(15),[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(!1),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsxs)(Lr,{children:[(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(Dt,{asChild:!0,children:(0,X.jsxs)(J,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[(0,X.jsx)(Fi,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Help & resources`})]})})}),(0,X.jsx)(Fr,{children:`Help & resources`})]}),e[0]=a):a=e[0];let o;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,X.jsx)(`p`,{className:`font-mono tracking-wide uppercase text-muted-foreground text-xs mb-1`,children:`Setup`}),e[1]=o):o=e[1];let s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{i(!1),window.location.hash!==`#settings`&&(window.location.hash=Yu)},e[2]=s):s=e[2];let c;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,"data-testid":`help-popover-settings`,onClick:s,className:`flex w-full items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-sm text-muted-foreground transition-colors hover:bg-azure-900/5 dark:hover:bg-white/20 hover:text-primary`,children:[(0,X.jsx)(Oa,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,X.jsx)(`span`,{children:`Settings…`})]})}),e[3]=c):c=e[3];let l;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{i(!1),n(!0)},e[4]=l):l=e[4];let u,d;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,X.jsxs)(`ul`,{className:`mb-3 space-y-0.5`,children:[c,(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,onClick:l,className:`flex w-full items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-sm text-muted-foreground transition-colors hover:bg-azure-900/5 dark:hover:bg-white/20 hover:text-primary`,children:[(0,X.jsx)(er,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,X.jsx)(`span`,{children:`Install for Claude Chat & Cowork…`})]})})]}),d=(0,X.jsx)(`p`,{className:`font-mono tracking-wide uppercase text-muted-foreground text-xs mb-1`,children:`Resources`}),e[5]=u,e[6]=d):(u=e[5],d=e[6]);let f;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,X.jsxs)(kt,{align:`end`,className:`w-64 p-3`,children:[o,u,d,(0,X.jsx)(`nav`,{"aria-label":`Help and resources`,children:(0,X.jsx)(`ul`,{className:`space-y-0.5`,children:OS.map(AS)})})]}),e[7]=f):f=e[7];let p;e[8]===r?p=e[9]:(p=(0,X.jsxs)(Jt,{open:r,onOpenChange:i,children:[a,f]}),e[8]=r,e[9]=p);let m;e[10]===t?m=e[11]:(m=(0,X.jsx)(ir,{open:t,onOpenChange:n}),e[10]=t,e[11]=m);let h;return e[12]!==p||e[13]!==m?(h=(0,X.jsxs)(X.Fragment,{children:[p,m]}),e[12]=p,e[13]=m,e[14]=h):h=e[14],h};function AS(e){let{label:t,href:n,icon:r}=e;return(0,X.jsx)(`li`,{children:(0,X.jsxs)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-2.5 rounded-md px-2 py-1.5 text-sm text-muted-foreground transition-colors hover:bg-azure-900/5 dark:hover:bg-white/20 hover:text-primary`,children:[(0,X.jsx)(r,{"aria-hidden":`true`,className:`size-4 shrink-0`}),t]})},n)}var jS={"claude-cowork":`claude`,"claude-code":`claude`,codex:`openai`,cursor:`cursor`};function MS(e){let t=(0,Q.c)(23),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({id:r,style:a,className:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{resolvedTheme:o}=G(),s=jS[r],c=s?(o===`dark`?Se[s]:void 0)??Me[s]:void 0,l;t[5]!==c||t[6]!==a?(l=c?{...a,"--ok-brand-color":c}:a,t[5]=c,t[6]=a,t[7]=l):l=t[7];let u=l,d=c&&`[&_*]:![color:var(--ok-brand-color)]`,f;t[8]!==n||t[9]!==d?(f=q(d,n),t[8]=n,t[9]=d,t[10]=f):f=t[10];let p=f;if(r===`claude-cowork`||r===`claude-code`){let e;return t[11]!==p||t[12]!==u||t[13]!==i?(e=(0,X.jsx)(Hn,{style:u,className:p,...i}),t[11]=p,t[12]=u,t[13]=i,t[14]=e):e=t[14],e}if(r===`codex`){let e;return t[15]!==p||t[16]!==u||t[17]!==i?(e=(0,X.jsx)(Vn,{style:u,className:p,...i}),t[15]=p,t[16]=u,t[17]=i,t[18]=e):e=t[18],e}if(r===`cursor`){let e;return t[19]!==p||t[20]!==u||t[21]!==i?(e=(0,X.jsx)(Jn,{style:u,className:p,...i}),t[19]=p,t[20]=u,t[21]=i,t[22]=e):e=t[22],e}return null}var NS=`https://github.com/inkeep/open-knowledge/releases`;function PS(e){let{target:t,installState:n,isElectronHost:r}=e;return t.id===`cursor`&&!r?`Desktop only`:n.installed===null?`Detecting…`:n.installed===!1?`Not installed`:null}function FS(e){let{target:t,installState:n,isElectronHost:r}=e;if(t.id===`cursor`&&!r)return{enabled:!1,tooltip:{message:`Cursor handoff requires the desktop build.`,installAction:{label:`Install the Open Knowledge desktop app →`,url:NS}}};if(n.installed===null)return{enabled:!1,tooltip:null};if(n.installed===!1){let e=t.appBrandName??t.displayName;return{enabled:!1,tooltip:{message:`Requires ${e}.`,installAction:{label:`Install ${e} →`,url:t.installUrl},...t.hasWebFallback?{webFallback:{label:`Open in claude.ai →`,url:``}}:{}}}}return{enabled:!0,tooltip:null}}function IS(e){return ne(e)}function LS(e){return`Opened ${e} in your browser.`}function RS(e){let t=(0,Q.c)(73),{target:n,installState:r,isElectronHost:i,prompt:a,onSelect:o}=e,s=e.openExternal??cd,c=e.onWebFallbackSuccess??BS,l=e.onWebFallbackError??zS,u;t[0]!==r||t[1]!==i||t[2]!==n?(u=FS({target:n,installState:r,isElectronHost:i}),t[0]=r,t[1]=i,t[2]=n,t[3]=u):u=t[3];let d=u,f;t[4]!==r||t[5]!==i||t[6]!==n?(f=PS({target:n,installState:r,isElectronHost:i}),t[4]=r,t[5]=i,t[6]=n,t[7]=f):f=t[7];let p=f,m;t[8]!==s||t[9]!==d.tooltip?(m=()=>{d.tooltip&&s(d.tooltip.installAction.url)},t[8]=s,t[9]=d.tooltip,t[10]=m):m=t[10];let h=m,g;t[11]!==l||t[12]!==c||t[13]!==s||t[14]!==a||t[15]!==n?(g=()=>{(async()=>{let e=await s(IS(a));e.ok?c(n):l(n,e.detail??e.reason)})()},t[11]=l,t[12]=c,t[13]=s,t[14]=a,t[15]=n,t[16]=g):g=t[16];let _=g;if(d.enabled){let e=`open-in-agent-item-${n.id}`,r=`Open in ${n.displayName}`,i;t[17]===n.id?i=t[18]:(i=(0,X.jsx)(MS,{id:n.id,"aria-hidden":`true`}),t[17]=n.id,t[18]=i);let a;t[19]===n.displayName?a=t[20]:(a=(0,X.jsx)(`span`,{children:n.displayName}),t[19]=n.displayName,t[20]=a);let s;return t[21]!==o||t[22]!==e||t[23]!==r||t[24]!==i||t[25]!==a?(s=(0,X.jsxs)(Gv,{onSelect:o,"data-testid":e,"aria-label":r,children:[i,a]}),t[21]=o,t[22]=e,t[23]=r,t[24]=i,t[25]=a,t[26]=s):s=t[26],s}if(!d.tooltip){let e=p?`Open in ${n.displayName}, ${p}`:`Open in ${n.displayName}`,r=`open-in-agent-item-${n.id}`,i;t[27]===n.id?i=t[28]:(i=(0,X.jsx)(MS,{id:n.id,"aria-hidden":`true`}),t[27]=n.id,t[28]=i);let a;t[29]===n.displayName?a=t[30]:(a=(0,X.jsx)(`span`,{className:`flex-1`,children:n.displayName}),t[29]=n.displayName,t[30]=a);let o;t[31]===p?o=t[32]:(o=p?(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:p}):null,t[31]=p,t[32]=o);let s;return t[33]!==e||t[34]!==r||t[35]!==i||t[36]!==a||t[37]!==o?(s=(0,X.jsxs)(Gv,{disabled:!0,"data-testid":r,"aria-label":e,children:[i,a,o]}),t[33]=e,t[34]=r,t[35]=i,t[36]=a,t[37]=o,t[38]=s):s=t[38],s}let v=p?`Open in ${n.displayName}, ${p}`:`Open in ${n.displayName}`,y=`open-in-agent-item-${n.id}`,b;t[39]===n.id?b=t[40]:(b=(0,X.jsx)(MS,{id:n.id,"aria-hidden":`true`,className:`mr-2`}),t[39]=n.id,t[40]=b);let x;t[41]===n.displayName?x=t[42]:(x=(0,X.jsx)(`span`,{className:`flex-1`,children:n.displayName}),t[41]=n.displayName,t[42]=x);let S;t[43]===p?S=t[44]:(S=p?(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:p}):null,t[43]=p,t[44]=S);let C;t[45]!==v||t[46]!==y||t[47]!==b||t[48]!==x||t[49]!==S?(C=(0,X.jsxs)(Zv,{"data-testid":y,"data-row-disabled":``,"aria-label":v,children:[b,x,S]}),t[45]=v,t[46]=y,t[47]=b,t[48]=x,t[49]=S,t[50]=C):C=t[50];let w=`open-in-agent-submenu-${n.id}`,T=`open-in-agent-message-${n.id}`,E;t[51]!==d.tooltip.message||t[52]!==T?(E=(0,X.jsx)(Jv,{className:`font-normal text-muted-foreground text-xs`,"data-testid":T,children:d.tooltip.message}),t[51]=d.tooltip.message,t[52]=T,t[53]=E):E=t[53];let D;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,X.jsx)(Yv,{}),t[54]=D):D=t[54];let O=`open-in-agent-install-${n.id}`,k;t[55]===d.tooltip.installAction.label?k=t[56]:(k=(0,X.jsx)(`span`,{children:d.tooltip.installAction.label}),t[55]=d.tooltip.installAction.label,t[56]=k);let A;t[57]!==h||t[58]!==O||t[59]!==k?(A=(0,X.jsx)(Gv,{onSelect:h,"data-testid":O,children:k}),t[57]=h,t[58]=O,t[59]=k,t[60]=A):A=t[60];let j;t[61]!==_||t[62]!==d.tooltip.webFallback||t[63]!==n.id?(j=d.tooltip.webFallback?(0,X.jsxs)(Gv,{onSelect:_,"data-testid":`open-in-agent-web-fallback-${n.id}`,"aria-label":`${d.tooltip.webFallback.label}, opens in browser with prompt pre-filled`,children:[(0,X.jsx)(`span`,{className:`flex-1`,children:d.tooltip.webFallback.label}),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`ml-2 text-muted-foreground text-xs`,children:`opens in browser with prompt pre-filled`})]}):null,t[61]=_,t[62]=d.tooltip.webFallback,t[63]=n.id,t[64]=j):j=t[64];let M;t[65]!==E||t[66]!==A||t[67]!==j||t[68]!==w?(M=(0,X.jsxs)(Qv,{className:`min-w-[260px]`,"data-testid":w,children:[E,D,A,j]}),t[65]=E,t[66]=A,t[67]=j,t[68]=w,t[69]=M):M=t[69];let N;return t[70]!==M||t[71]!==C?(N=(0,X.jsxs)(Xv,{children:[C,M]}),t[70]=M,t[71]=C,t[72]=N):N=t[72],N}function zS(){}function BS(){}function VS(e){let t=(0,Q.c)(25),{input:n}=e,{states:r,refresh:i}=zd(),{dispatch:a}=Od(),[o,s]=(0,Z.useState)(!1),c=typeof window<`u`&&window.okDesktop!=null,l=US,u=HS,d;t[0]===i?d=t[1]:(d=e=>{s(e),e&&i()},t[0]=i,t[1]=d);let f=d,p=n===null,m;t[2]===n?m=t[3]:(m=n===null?``:Qe(n.docContext),t[2]=n,t[3]=m);let h=m,g;t[4]!==a||t[5]!==n?(g=e=>{n!==null&&a(e.id,n)},t[4]=a,t[5]=n,t[6]=g):g=t[6];let _=g,v;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,X.jsx)(Yn,{className:`size-4`}),t[7]=v):v=t[7];let y;t[8]===p?y=t[9]:(y=(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(Uv,{asChild:!0,children:(0,X.jsx)(J,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit with AI`,disabled:p,className:`text-muted-foreground`,"data-testid":`open-in-agent-trigger`,children:v})})}),t[8]=p,t[9]=y);let b;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,X.jsx)(Fr,{children:`Edit with AI`}),t[10]=b):b=t[10];let x;t[11]===y?x=t[12]:(x=(0,X.jsxs)(Lr,{children:[y,b]}),t[11]=y,t[12]=x);let S;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,X.jsx)(Jv,{className:`font-mono font-normal tracking-wide uppercase text-muted-foreground text-xs`,children:`Open in…`}),t[13]=S):S=t[13];let C;t[14]!==_||t[15]!==h||t[16]!==r?(C=Ju.map(e=>{let t=r[e.id];return(0,X.jsx)(RS,{target:e,installState:t,isElectronHost:c,prompt:h,onSelect:()=>_(e),onWebFallbackSuccess:l,onWebFallbackError:u},e.id)}),t[14]=_,t[15]=h,t[16]=r,t[17]=C):C=t[17];let w;t[18]===C?w=t[19]:(w=(0,X.jsxs)(Wv,{align:`end`,className:`min-w-[220px]`,"data-testid":`open-in-agent-menu`,children:[S,C]}),t[18]=C,t[19]=w);let T;return t[20]!==f||t[21]!==o||t[22]!==w||t[23]!==x?(T=(0,X.jsxs)(Hv,{open:o,onOpenChange:f,children:[x,w]}),t[20]=f,t[21]=o,t[22]=w,t[23]=x,t[24]=T):T=t[24],T}function HS(e){Ar.error(`Couldn't open ${e.displayName} in your browser.`)}function US(e){Ar.success(LS(e.displayName))}var WS={fill:`none`,height:24,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,viewBox:`0 0 24 24`,width:24,xmlns:`http://www.w3.org/2000/svg`},GS=e=>{let t=(0,Q.c)(15),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]):({color:a,size:o,strokeWidth:s,absoluteStrokeWidth:n,className:c,children:r,...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=a===void 0?`currentColor`:a,u=o===void 0?24:o,d=s===void 0?2:s,f=c===void 0?``:c,p=n?Number(d)*24/Number(u):d,m;return t[8]!==r||t[9]!==f||t[10]!==l||t[11]!==i||t[12]!==u||t[13]!==p?(m=(0,X.jsx)(`svg`,{"aria-hidden":`true`,...WS,className:f,height:u,stroke:l,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:p,width:u,...i,children:r}),t[8]=r,t[9]=f,t[10]=l,t[11]=i,t[12]=u,t[13]=p,t[14]=m):m=t[14],m},KS=e=>{let t=(0,Q.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,X.jsx)(`title`,{children:`Markdown`}),r=(0,X.jsx)(`path`,{d:`M232,48H24A16,16,0,0,0,8,64V192a16,16,0,0,0,16,16H232a16,16,0,0,0,16-16V64A16,16,0,0,0,232,48Zm0,144H24V64H232V192ZM128,104v48a8,8,0,0,1-16,0V123.31L93.66,141.66a8,8,0,0,1-11.32,0L64,123.31V152a8,8,0,0,1-16,0V104a8,8,0,0,1,13.66-5.66L88,124.69l26.34-26.35A8,8,0,0,1,128,104Zm77.66,18.34a8,8,0,0,1,0,11.32l-24,24a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L168,132.69V104a8,8,0,0,1,16,0v28.69l10.34-10.35A8,8,0,0,1,205.66,122.34Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,X.jsxs)(GS,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i},qS=e=>{let t=(0,Q.c)(4),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,X.jsx)(`title`,{children:`Textbox`}),r=(0,X.jsx)(`path`,{d:`M112,40a8,8,0,0,0-8,8V64H24A16,16,0,0,0,8,80v96a16,16,0,0,0,16,16h80v16a8,8,0,0,0,16,0V48A8,8,0,0,0,112,40ZM24,176V80h80v96ZM248,80v96a16,16,0,0,1-16,16H144a8,8,0,0,1,0-16h88V80H144a8,8,0,0,1,0-16h88A16,16,0,0,1,248,80ZM88,112a8,8,0,0,1-8,8H72v24a8,8,0,0,1-16,0V120H48a8,8,0,0,1,0-16H80A8,8,0,0,1,88,112Z`}),t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;return t[2]===e?i=t[3]:(i=(0,X.jsxs)(GS,{...e,viewBox:`0 0 256 256`,fill:`currentColor`,children:[n,r]}),t[2]=e,t[3]=i),i};function JS(e){if(!e)return`never`;let t=Date.now()-new Date(e).getTime();return t<6e4?`just now`:t<36e5?`${Math.floor(t/6e4)} min ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:new Date(e).toLocaleDateString()}async function YS(e){await fetch(`/api/sync/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({op:e})})}async function XS(e){let t=await fetch(`/api/sync/set-enabled`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})});if(!t.ok)throw Error(`set-enabled failed: HTTP ${t.status}`)}function ZS(e){let t=(0,Q.c)(9),{status:n}=e;switch(n.state){case`dormant`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Ri,{className:`size-3.5 text-muted-foreground`}),t[0]=e):e=t[0],e}case`idle`:{if(n.ahead>0||n.behind>0){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(wa,{className:`size-3.5 text-muted-foreground`}),t[1]=e):e=t[1],e}let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Ri,{className:`size-3.5 text-emerald-500`}),t[2]=e):e=t[2],e}case`fetching`:case`pulling`:case`pushing`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(wa,{className:`size-3.5 text-muted-foreground animate-spin`}),t[3]=e):e=t[3],e}case`conflict`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(R,{className:`size-3.5 text-amber-500`}),t[4]=e):e=t[4],e}case`offline`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Li,{className:`size-3.5 text-muted-foreground`}),t[5]=e):e=t[5],e}case`auth-error`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(da,{className:`size-3.5 text-destructive`}),t[6]=e):e=t[6],e}case`disabled`:{let e;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Li,{className:`size-3.5 text-muted-foreground`}),t[7]=e):e=t[7],e}default:{let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Ri,{className:`size-3.5 text-muted-foreground`}),t[8]=e):e=t[8],e}}}function QS(e){switch(e.state){case`idle`:return e.ahead>0?`↑${e.ahead}`:e.behind>0?`↓${e.behind}`:``;case`fetching`:case`pulling`:case`pushing`:return``;case`conflict`:return e.conflictCount>0?`${e.conflictCount}`:``;case`offline`:return``;case`auth-error`:return``;case`disabled`:return``;default:return``}}function $S(e){switch(e){case`dormant`:return`No git remote`;case`idle`:return`Synced`;case`fetching`:return`Fetching…`;case`pulling`:return`Pulling…`;case`pushing`:return`Pushing…`;case`conflict`:return`Conflict`;case`offline`:return`Offline`;case`auth-error`:return`Sign in required`;case`disabled`:return`Sync disabled`;default:return e}}function eC(e){switch(e){case`external-changes-pending`:return`External changes pending`;case`dirty-tree`:return`Working tree has uncommitted changes`;case`detached-head`:return`Detached HEAD — checkout a branch to resume`;case`auth-error`:return`Sign in required`;case`protected-branch`:return`Protected branch — cannot push`;default:return e}}function tC(e){return e.syncEnabled?e.state===`idle`?e.ahead>0&&e.behind>0?`${e.ahead} ahead, ${e.behind} behind`:e.ahead>0?`${e.ahead} ahead`:e.behind>0?`${e.behind} behind`:`Synced`:e.state===`conflict`&&e.conflictCount>0?`${e.conflictCount} conflict${e.conflictCount===1?``:`s`}`:$S(e.state):`Sync off`}function nC(e){let t=(0,Q.c)(72),{status:n,onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a}=e,[o,s]=(0,Z.useState)(!1),c=n.syncEnabled,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=async function(e){s(!0);try{await XS(e)}catch(t){console.error(`[sync] toggle failed`,t),Ar.error(`Failed to ${e?`enable`:`disable`} sync — try again`)}s(!1)},t[0]=l):l=t[0];let u=l,d;t[1]===n?d=t[2]:(d=(0,X.jsx)(ZS,{status:n}),t[1]=n,t[2]=d);let f;t[3]===n.state?f=t[4]:(f=$S(n.state),t[3]=n.state,t[4]=f);let p;t[5]===f?p=t[6]:(p=(0,X.jsx)(`span`,{className:`text-sm font-medium truncate`,children:f}),t[5]=f,t[6]=p);let m;t[7]!==d||t[8]!==p?(m=(0,X.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[d,p]}),t[7]=d,t[8]=p,t[9]=m):m=t[9];let h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(h=e=>void u(e),t[10]=h):h=t[10];let g=c?`Disable sync`:`Enable sync`,_;t[11]!==c||t[12]!==g||t[13]!==o?(_=(0,X.jsx)(Nn,{checked:c,disabled:o,onCheckedChange:h,"aria-label":g}),t[11]=c,t[12]=g,t[13]=o,t[14]=_):_=t[14];let v;t[15]!==m||t[16]!==_?(v=(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[m,_]}),t[15]=m,t[16]=_,t[17]=v):v=t[17];let y;t[18]===n.error?y=t[19]:(y=n.error&&(0,X.jsx)(`p`,{className:`text-xs text-destructive`,children:n.error}),t[18]=n.error,t[19]=y);let b;t[20]===n.pausedReason?b=t[21]:(b=n.pausedReason&&(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:eC(n.pausedReason)}),t[20]=n.pausedReason,t[21]=b);let x;t[22]===n.state?x=t[23]:(x=n.state===`conflict`&&(0,X.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-400`,children:`Sync paused — resolve conflicts to resume.`}),t[22]=n.state,t[23]=x);let S;t[24]!==c||t[25]!==n.lastSyncUtc||t[26]!==n.state?(S=c&&n.state!==`dormant`&&(0,X.jsxs)(`div`,{children:[`Last synced: `,JS(n.lastSyncUtc)]}),t[24]=c,t[25]=n.lastSyncUtc,t[26]=n.state,t[27]=S):S=t[27];let C;t[28]===n.ahead?C=t[29]:(C=n.ahead>0&&(0,X.jsxs)(`div`,{children:[n.ahead,` commit`,n.ahead===1?``:`s`,` ahead`]}),t[28]=n.ahead,t[29]=C);let w;t[30]===n.behind?w=t[31]:(w=n.behind>0&&(0,X.jsxs)(`div`,{children:[n.behind,` commit`,n.behind===1?``:`s`,` behind`]}),t[30]=n.behind,t[31]=w);let T;t[32]===n.conflictCount?T=t[33]:(T=n.conflictCount>0&&(0,X.jsxs)(`div`,{children:[n.conflictCount,` file`,n.conflictCount===1?``:`s`,` conflicted`]}),t[32]=n.conflictCount,t[33]=T);let E;t[34]===c?E=t[35]:(E=!c&&(0,X.jsx)(`div`,{children:`Sync is off — your edits will not sync to the remote repository.`}),t[34]=c,t[35]=E);let D;t[36]!==S||t[37]!==C||t[38]!==w||t[39]!==T||t[40]!==E?(D=(0,X.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-0.5`,children:[S,C,w,T,E]}),t[36]=S,t[37]=C,t[38]=w,t[39]=T,t[40]=E,t[41]=D):D=t[41];let O;t[42]!==a||t[43]!==n.identityUnresolved?(O=n.identityUnresolved&&a&&(0,X.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-dashed p-2`,children:[(0,X.jsx)(Ba,{className:`size-3.5 mt-0.5 text-muted-foreground shrink-0`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5 min-w-0`,children:[(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground leading-snug`,children:`Git identity isn't set — commits use a default author. Set yours so teammates see your name.`}),(0,X.jsx)(J,{variant:`outline`,size:`xs`,className:`self-start`,onClick:a,children:`Set identity`})]})]}),t[42]=a,t[43]=n.identityUnresolved,t[44]=O):O=t[44];let k;t[45]!==c||t[46]!==n.state?(k=c&&n.state!==`dormant`&&n.state!==`disabled`&&n.state!==`auth-error`&&n.state!==`conflict`&&(0,X.jsx)(J,{variant:`outline`,size:`xs`,onClick:iC,children:`Sync now`}),t[45]=c,t[46]=n.state,t[47]=k):k=t[47];let A;t[48]!==c||t[49]!==r||t[50]!==n.state?(A=c&&n.state===`auth-error`&&(0,X.jsx)(J,{variant:`outline`,size:`xs`,onClick:r,children:`Sign in`}),t[48]=c,t[49]=r,t[50]=n.state,t[51]=A):A=t[51];let j;t[52]!==c||t[53]!==n.state?(j=c&&n.state===`offline`&&(0,X.jsx)(J,{variant:`outline`,size:`xs`,onClick:rC,children:`Retry`}),t[52]=c,t[53]=n.state,t[54]=j):j=t[54];let M;t[55]!==c||t[56]!==i||t[57]!==n.state?(M=c&&n.state===`conflict`&&i&&(0,X.jsx)(J,{variant:`outline`,size:`xs`,onClick:i,children:`Review conflicts`}),t[55]=c,t[56]=i,t[57]=n.state,t[58]=M):M=t[58];let N;t[59]!==k||t[60]!==A||t[61]!==j||t[62]!==M?(N=(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-1 pt-1`,children:[k,A,j,M]}),t[59]=k,t[60]=A,t[61]=j,t[62]=M,t[63]=N):N=t[63];let P;return t[64]!==y||t[65]!==b||t[66]!==x||t[67]!==D||t[68]!==O||t[69]!==N||t[70]!==v?(P=(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[v,y,b,x,D,O,N]}),t[64]=y,t[65]=b,t[66]=x,t[67]=D,t[68]=O,t[69]=N,t[70]=v,t[71]=P):P=t[71],P}function rC(){YS(`sync`)}function iC(){YS(`sync`)}function aC(e){let t=(0,Q.c)(36),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a}=n,{status:o,fetchError:s}=of();if(!o){if(s){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(J,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground`,"aria-label":`Sync status unavailable`,disabled:!0,children:(0,X.jsx)(Li,{className:`size-3.5`})})}),t[2]=e):e=t[2];let n=s===`network`?`Sync status unavailable — server unreachable.`:`Sync status unavailable — server error.`,r;return t[3]===n?r=t[4]:(r=(0,X.jsxs)(Lr,{children:[e,(0,X.jsx)(Fr,{children:n})]}),t[3]=n,t[4]=r),r}return null}if(o.state===`dormant`&&!o.hasRemote)return null;let c;t[5]===o?c=t[6]:(c=QS(o),t[5]=o,t[6]=c);let l=c,u=!!o.identityUnresolved,d;t[7]===o.state?d=t[8]:(d=$S(o.state),t[7]=o.state,t[8]=d);let f=`Sync status: ${d}${u?` — git identity unset`:``}`,p;t[9]===o?p=t[10]:(p=(0,X.jsx)(ZS,{status:o}),t[9]=o,t[10]=p);let m;t[11]===l?m=t[12]:(m=l&&(0,X.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 text-[9px] leading-none font-medium bg-background border rounded-full px-0.5`,children:l}),t[11]=l,t[12]=m);let h;t[13]!==l||t[14]!==u?(h=!l&&u&&(0,X.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 size-1.5 rounded-full bg-amber-500 ring-2 ring-background`,"aria-hidden":!0}),t[13]=l,t[14]=u,t[15]=h):h=t[15];let g;t[16]!==f||t[17]!==p||t[18]!==m||t[19]!==h?(g=(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(Dt,{asChild:!0,children:(0,X.jsxs)(J,{variant:`ghost`,size:`icon-sm`,className:`text-muted-foreground relative`,"aria-label":f,children:[p,m,h]})})}),t[16]=f,t[17]=p,t[18]=m,t[19]=h,t[20]=g):g=t[20];let _;t[21]===o?_=t[22]:(_=tC(o),t[21]=o,t[22]=_);let v;t[23]===_?v=t[24]:(v=(0,X.jsx)(Fr,{children:_}),t[23]=_,t[24]=v);let y;t[25]!==v||t[26]!==g?(y=(0,X.jsxs)(Lr,{children:[g,v]}),t[25]=v,t[26]=g,t[27]=y):y=t[27];let b;t[28]!==i||t[29]!==a||t[30]!==r||t[31]!==o?(b=(0,X.jsx)(kt,{align:`end`,className:`w-64 p-3`,children:(0,X.jsx)(nC,{status:o,onSignIn:r,onOpenConflictResolver:i,onSetIdentity:a})}),t[28]=i,t[29]=a,t[30]=r,t[31]=o,t[32]=b):b=t[32];let x;return t[33]!==y||t[34]!==b?(x=(0,X.jsxs)(Jt,{children:[y,b]}),t[33]=y,t[34]=b,t[35]=x):x=t[35],x}var oC=(0,Z.createContext)(null);function sC(e,t,n){let r=new $t,i=new Zt({url:e,name:t,document:r}),a=W(i,n);return{binding:a,config:a.current(),cleanup:()=>{a.dispose(),i.destroy(),r.destroy()}}}function cC(e){let t=(0,Q.c)(19),{children:n}=e,{collabUrl:r}=Sn(),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null),c,l;t[0]===r?(c=t[1],l=t[2]):(c=()=>{if(r===null)return;let e=sC(r,tt,`user`),t=sC(r,he,`workspace`);a({binding:e.binding,config:e.config}),s({binding:t.binding,config:t.config});let n=e.binding.subscribe(t=>{a(n=>n?.binding===e.binding?{...n,config:t}:n)}),i=t.binding.subscribe(e=>{s(n=>n?.binding===t.binding?{...n,config:e}:n)});return()=>{n(),i(),e.cleanup(),t.cleanup(),a(t=>t?.binding===e.binding?null:t),s(e=>e?.binding===t.binding?null:e)}},l=[r],t[0]=r,t[1]=c,t[2]=l),(0,Z.useEffect)(c,l);let u;t[3]!==i||t[4]!==o?(u=i&&o?uC(i.config,o.config):null,t[3]=i,t[4]=o,t[5]=u):u=t[5];let d=u,{setTheme:f}=G(),p=d?.appearance?.theme,m,h;t[6]!==f||t[7]!==p?(m=()=>{(p===`light`||p===`dark`||p===`system`)&&f(p)},h=[p,f],t[6]=f,t[7]=p,t[8]=m,t[9]=h):(m=t[8],h=t[9]),(0,Z.useEffect)(m,h);let g=i?.binding??null,_=o?.binding??null,v=i?.config??null,y=o?.config??null,b;t[10]!==d||t[11]!==g||t[12]!==_||t[13]!==v||t[14]!==y?(b={userBinding:g,workspaceBinding:_,userConfig:v,workspaceConfig:y,merged:d},t[10]=d,t[11]=g,t[12]=_,t[13]=v,t[14]=y,t[15]=b):b=t[15];let x=b,S;return t[16]!==n||t[17]!==x?(S=(0,X.jsx)(oC,{value:x,children:n}),t[16]=n,t[17]=x,t[18]=S):S=t[18],S}function lC(){let e=(0,Z.use)(oC);if(e===null)throw Error(`useConfigContext must be used within <ConfigProvider />`);return e}function uC(e,t){return dC(e,t,[])}function dC(e,t,n){if(n.length>0){let r=je(pe,n);if(r?.scope===`user`)return e;if(r?.scope===`workspace`)return t??e}if(t===void 0)return e;if(t===null)return null;if(Array.isArray(t)||typeof t!=`object`||typeof e!=`object`||!e||Array.isArray(e))return t;let r={...e};for(let[i,a]of Object.entries(t))r[i]=dC(e[i],a,[...n,i]);return r}var fC=[{value:`light`,label:`Light`,icon:Fa},{value:`dark`,label:`Dark`,icon:fa},{value:`system`,label:`System`,icon:Hi}],pC=()=>{let e=(0,Q.c)(16),{theme:t}=G(),{merged:n,userBinding:r}=lC(),i=n?.appearance?.theme??t??`system`,a;e[0]===r?a=e[1]:(a=e=>{if(e!==`light`&&e!==`dark`&&e!==`system`||!r)return;let t=r.patch({appearance:{theme:e}});t.ok||Ar.error(Ne(t.error))},e[0]=r,e[1]=a);let o=a,s=i===`system`?Hi:i===`dark`?fa:Fa,c;e[2]===s?c=e[3]:(c=(0,X.jsx)(s,{}),e[2]=s,e[3]=c);let l;e[4]===i?l=e[5]:(l=(0,X.jsxs)(`span`,{className:`sr-only`,children:[`Toggle theme (current: `,i,`)`]}),e[4]=i,e[5]=l);let u;e[6]!==c||e[7]!==l?(u=(0,X.jsx)(Uv,{asChild:!0,children:(0,X.jsxs)(J,{variant:`ghost`,size:`icon`,className:`size-7 hover:bg-accent text-muted-foreground`,children:[c,l]})}),e[6]=c,e[7]=l,e[8]=u):u=e[8];let d;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=fC.map(mC),e[9]=d):d=e[9];let f;e[10]!==i||e[11]!==o?(f=(0,X.jsx)(Wv,{align:`end`,children:(0,X.jsx)(Kv,{value:i,onValueChange:o,children:d})}),e[10]=i,e[11]=o,e[12]=f):f=e[12];let p;return e[13]!==u||e[14]!==f?(p=(0,X.jsxs)(Hv,{children:[u,f]}),e[13]=u,e[14]=f,e[15]=p):p=e[15],p};function mC(e){let{value:t,label:n,icon:r}=e;return(0,X.jsxs)(qv,{value:t,className:`capitalize`,children:[(0,X.jsx)(r,{className:`text-muted-foreground`}),n]},t)}function hC(e){return typeof e==`object`&&!!e&&typeof e.fromDocName==`string`&&typeof e.toDocName==`string`}function gC(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.ok===!0?Array.isArray(t.renamed)&&t.renamed.every(hC)&&Array.isArray(t.rewrittenDocs):t.ok===!1?typeof t.error==`string`:!1}function _C(e){let t=(0,Q.c)(91),{editorMode:n,onModeChange:r,onSaveVersion:i,saving:a,onSignIn:o,onSetIdentity:s,onOpenConflictResolver:c,onOpenClone:l}=e,{activeDocName:u,activeProvider:d,activeTarget:f,closeDocument:p,pinnedDoc:m,pin:h,unpin:g}=Sn(),{pageMeta:_}=Pe(),{state:v}=Ux(),y=rd(),b=uS(d),x;t[0]!==u||t[1]!==y?(x=yd({docName:u,workspace:y}),t[0]=u,t[1]=y,t[2]=x):x=t[2];let S=x,C=!u||!(b===`connected`||b===`synced`),w=f?.kind===`folder`,T=f?.kind===`missing`,E;t[3]!==u||t[4]!==_?(E=u&&_.get(u)?.docExt||`.md`,t[3]=u,t[4]=_,t[5]=E):E=t[5];let D=E,O=w?`${f.folderPath}/`:u?`${u}${D}`:``,k;t[6]===u?k=t[7]:(k=u?.lastIndexOf(`/`)??-1,t[6]=u,t[7]=k);let A=k,j;t[8]!==u||t[9]!==A?(j=u&&A!==-1?`${u.substring(0,A+1)}`:``,t[8]=u,t[9]=A,t[10]=j):j=t[10];let M=j,N;t[11]!==u||t[12]!==A?(N=u?u.substring(A+1):``,t[11]=u,t[12]=A,t[13]=N):N=t[13];let P=N,F=m!==null,I;t[14]!==u||t[15]!==F||t[16]!==h||t[17]!==g?(I=function(){u&&(F?g():h(u))},t[14]=u,t[15]=F,t[16]=h,t[17]=g,t[18]=I):I=t[18];let L=I,[R,z]=(0,Z.useState)(!1),[B,V]=(0,Z.useState)(``),[H,U]=(0,Z.useState)(null),[W,G]=(0,Z.useState)(!1),ee=(0,Z.useRef)(null),K=(0,Z.useRef)(!1),te=(0,Z.useRef)(!1),ne=(0,Z.useRef)(null),re=(0,Z.useRef)(null),ie;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(ie=()=>{te.current=!0,ne.current=null,re.current=null,z(!1),U(null)},t[19]=ie):ie=t[19];let ae;t[20]===u?ae=t[21]:(ae=[u],t[20]=u,t[21]=ae),(0,Z.useEffect)(ie,ae);let oe,se;t[22]===R?(oe=t[23],se=t[24]):(se=()=>{if(R){let e=setTimeout(()=>{let e=ee.current;e&&(e.focus(),e.select())},0);return()=>clearTimeout(e)}},oe=[R],t[22]=R,t[23]=oe,t[24]=se),(0,Z.useEffect)(se,oe);let ce;t[25]!==u||t[26]!==w?(ce=function(){if(!u||w)return;let e=u.split(`/`);te.current=!1,ne.current=u,V(e[e.length-1]),U(null),re.current=null,z(!0)},t[25]=u,t[26]=w,t[27]=ce):ce=t[27];let le=ce,ue;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(ue=function(){te.current=!0,ne.current=null,re.current=null,z(!1),V(``),U(null)},t[28]=ue):ue=t[28];let de=ue,fe;t[29]!==p||t[30]!==B?(fe=async function(){if(te.current){te.current=!1;return}if(K.current)return;let e=ne.current;if(!e){de();return}let t=gx(`file`,B),n=e.split(`/`),r=n[n.length-1];if(t===r){de();return}if(t===re.current)return;if(!_x(t)){U(`Name can’t be empty, ".", "..", or contain / or \\`);return}let i=vx({kind:`file`,path:e,name:r},t);K.current=!0,G(!0),U(null);try{let n=await fetch(`/api/rename`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({docName:e,newDocName:i})});if(te.current){G(!1),K.current=!1;return}let r;try{r=await n.json()}catch(r){console.warn(`[EditorHeader] rename response JSON parse failed`,{parseErr:r,status:n.status,docName:e,newDocName:i}),U(`Server error (HTTP ${n.status})`),G(!1),K.current=!1,re.current=t;return}if(!n.ok||!gC(r)){let a=r;console.warn(`[EditorHeader] rename failed`,{status:n.status,docName:e,newDocName:i}),U(a?.error||`Server error (HTTP ${n.status})`),G(!1),K.current=!1,re.current=t;return}if(!r.ok){U(r.error||`Failed to rename path`),G(!1),K.current=!1,re.current=t;return}let a=r.renamed,o=xx(e,a);for(let e of a)p(e.fromDocName);we([`files`,`backlinks`,`graph`]),z(!1),V(``),G(!1),K.current=!1,re.current=null,ne.current=null,o&&o!==e&&(window.location.hash=$e(o))}catch(n){console.warn(`[EditorHeader] rename failed`,{err:n,docName:e,newDocName:i,normalized:t}),U(`Network error — please try again`),G(!1),K.current=!1,re.current=t}},t[29]=p,t[30]=B,t[31]=fe):fe=t[31];let pe=fe,me;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(Jx,{className:`-ml-1 shrink-0 text-muted-foreground`})}),t[32]=me):me=t[32];let he=v===`expanded`?`Hide Files`:`Show Files`,ge;t[33]===he?ge=t[34]:(ge=(0,X.jsxs)(Lr,{children:[me,(0,X.jsx)(Fr,{children:he})]}),t[33]=he,t[34]=ge);let _e;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,X.jsx)(lv,{orientation:`vertical`,className:`mr-1 h-4 shrink-0 data-vertical:self-center`}),t[35]=_e):_e=t[35];let ve;t[36]!==D||t[37]!==u||t[38]!==pe||t[39]!==O||t[40]!==le||t[41]!==P||t[42]!==w||t[43]!==W||t[44]!==R||t[45]!==M||t[46]!==H||t[47]!==B?(ve=w?(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 text-sm text-muted-foreground`,children:[(0,X.jsx)(Ot,{className:`size-4 shrink-0`}),(0,X.jsx)(`span`,{className:`truncate`,children:O})]}):u?(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center overflow-hidden`,children:[M&&(0,X.jsxs)(`span`,{className:`flex shrink items-center overflow-hidden text-sm text-muted-foreground/60 transition-[max-width,opacity] duration-200 ease-in-out`,style:R?{maxWidth:0,opacity:0}:{maxWidth:`20rem`,opacity:1},children:[(0,X.jsx)(`span`,{className:`truncate`,children:M.slice(0,-1)}),(0,X.jsx)(`span`,{className:`shrink-0 pl-2`,children:`/`})]}),R?(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(zt,{ref:ee,value:B,disabled:W,"aria-label":`Rename ${u}`,"aria-invalid":H?!0:void 0,"aria-describedby":H?`editor-header-rename-error`:void 0,"aria-busy":W||void 0,onChange:e=>{V(e.target.value),U(null),re.current=null},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),pe()):e.key===`Escape`&&(e.preventDefault(),de())},onBlur:()=>void pe(),className:`h-7 min-w-0 flex-1 border-none bg-background text-sm shadow-none focus-visible:ring-0`}),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-xs text-muted-foreground/40`,children:D})]}),H&&(0,X.jsx)(`span`,{id:`editor-header-rename-error`,role:`alert`,className:`text-xs text-destructive mt-0.5`,children:H})]}):(0,X.jsx)(J,{variant:`ghost`,size:`sm`,onClick:le,className:`h-7 shrink-0 px-2 text-sm font-normal text-muted-foreground hover:text-foreground`,children:`${P}${D}`})]}):(0,X.jsx)(`span`,{className:`text-sm text-muted-foreground truncate min-w-0`,children:O}),t[36]=D,t[37]=u,t[38]=pe,t[39]=O,t[40]=le,t[41]=P,t[42]=w,t[43]=W,t[44]=R,t[45]=M,t[46]=H,t[47]=B,t[48]=ve):ve=t[48];let ye;t[49]!==u||t[50]!==F||t[51]!==L?(ye=u&&(0,X.jsxs)(Lr,{children:[(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 shrink-0 text-muted-foreground`,onClick:L,"aria-label":F?`Unpin — resume following agent`:`Pin this doc — stop following agent`,"aria-pressed":F,"data-pinned":F?`true`:`false`,children:F?(0,X.jsx)(ba,{className:`size-4 text-foreground`,fill:`currentColor`}):(0,X.jsx)(ya,{className:`size-4`})})}),(0,X.jsx)(Fr,{children:F?`Pinned — click to resume following agent navigation`:`Pin to stay on this doc — browser won’t auto-navigate to the agent’s current focus`})]}),t[49]=u,t[50]=F,t[51]=L,t[52]=ye):ye=t[52];let be;t[53]===T?be=t[54]:(be=T&&(0,X.jsx)(xn,{variant:`dashed`,children:`New file`}),t[53]=T,t[54]=be);let xe;t[55]!==ge||t[56]!==ve||t[57]!==ye||t[58]!==be?(xe=(0,X.jsxs)(`div`,{className:`flex flex-1 items-center gap-1 px-3 min-w-0`,children:[ge,_e,ve,ye,be]}),t[55]=ge,t[56]=ve,t[57]=ye,t[58]=be,t[59]=xe):xe=t[59];let Se;t[60]!==u||t[61]!==n||t[62]!==r||t[63]!==C?(Se=u&&(0,X.jsxs)(Xe,{type:`single`,value:n===`source`?`source`:`visual`,onValueChange:e=>{e&&r(e===`source`?`source`:`wysiwyg`)},"aria-label":`Editor mode`,variant:`segmented`,size:`sm`,spacing:1,className:`bg-muted dark:bg-background p-0.5 rounded-lg shrink-0`,disabled:!u,children:[(0,X.jsxs)(Lr,{children:[(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(`span`,{children:(0,X.jsxs)(He,{value:`visual`,"aria-label":`Visual editor`,className:`gap-1.5 text-xs`,children:[(0,X.jsx)(qS,{className:`size-4 text-muted-foreground`}),(0,X.jsx)(`span`,{className:`hidden md:inline`,children:`Visual`})]})})}),(0,X.jsx)(Fr,{className:`md:hidden`,children:`Visual`})]}),(0,X.jsxs)(Lr,{children:[(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(`span`,{tabIndex:C?0:void 0,children:(0,X.jsxs)(He,{value:`source`,"aria-label":`Markdown source`,className:`gap-1.5 text-xs`,disabled:C,children:[(0,X.jsx)(KS,{className:`size-4 text-muted-foreground`}),(0,X.jsx)(`span`,{className:`hidden md:inline`,children:`Markdown`})]})})}),C&&!u?null:C?(0,X.jsx)(Fr,{children:`Source mode requires a live connection — your edits are saved and will appear when you reconnect.`}):(0,X.jsx)(Fr,{className:`md:hidden`,children:`Markdown`})]})]}),t[60]=u,t[61]=n,t[62]=r,t[63]=C,t[64]=Se):Se=t[64];let Ce;t[65]===l?Ce=t[66]:(Ce=l&&(0,X.jsxs)(Lr,{children:[(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(J,{variant:`ghost`,size:`icon-sm`,"aria-label":`Clone from GitHub`,onClick:l,className:`text-muted-foreground`,children:(0,X.jsx)(ta,{className:`size-3.5`})})}),(0,X.jsx)(Fr,{children:`Clone from GitHub…`})]}),t[65]=l,t[66]=Ce);let Te;t[67]!==u||t[68]!==i||t[69]!==a?(Te=u&&(0,X.jsxs)(Lr,{children:[(0,X.jsx)(Pr,{asChild:!0,children:(0,X.jsx)(J,{variant:`ghost`,size:`icon-sm`,"aria-label":`Checkpoint version`,onClick:i,disabled:a,className:`text-muted-foreground`,children:(0,X.jsx)(Ea,{className:`size-3.5`})})}),(0,X.jsx)(Fr,{children:a?`Saving…`:`Checkpoint version`})]}),t[67]=u,t[68]=i,t[69]=a,t[70]=Te):Te=t[70];let Ee;t[71]!==u||t[72]!==S?(Ee=u&&(0,X.jsx)(VS,{input:S}),t[71]=u,t[72]=S,t[73]=Ee):Ee=t[73];let De;t[74]!==c||t[75]!==s||t[76]!==o?(De=(0,X.jsx)(aC,{onSignIn:o,onSetIdentity:s,onOpenConflictResolver:c}),t[74]=c,t[75]=s,t[76]=o,t[77]=De):De=t[77];let Oe,ke,Ae,je;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,X.jsx)(TS,{}),ke=(0,X.jsx)(lv,{orientation:`vertical`,className:`h-4 shrink-0 data-vertical:self-center`}),Ae=(0,X.jsx)(kS,{}),je=(0,X.jsx)(pC,{}),t[78]=Oe,t[79]=ke,t[80]=Ae,t[81]=je):(Oe=t[78],ke=t[79],Ae=t[80],je=t[81]);let Me;t[82]!==Ce||t[83]!==Te||t[84]!==Ee||t[85]!==De?(Me=(0,X.jsxs)(`div`,{className:`flex flex-1 items-center justify-end gap-2 px-3`,children:[Ce,Te,Ee,De,Oe,ke,Ae,je]}),t[82]=Ce,t[83]=Te,t[84]=Ee,t[85]=De,t[86]=Me):Me=t[86];let Ne;return t[87]!==xe||t[88]!==Se||t[89]!==Me?(Ne=(0,X.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center border-b`,children:[xe,Se,Me]}),t[87]=xe,t[88]=Se,t[89]=Me,t[90]=Ne):Ne=t[90],Ne}function vC(){let e=(0,Q.c)(41),[t,n]=nf(),[r,i]=(0,Z.useState)(t),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(`auth`),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(Nh[0].id),[_,v]=(0,Z.useState)(!1),y=(0,Z.useRef)(!1),b=af(),{activeDocName:x}=Sn(),S,C;e[0]===x?(S=e[1],C=e[2]):(S=()=>{let e=function(e){let t=e.detail;t&&x&&ai(x,{kind:`raw-mdx`,detail:t}),i(`source`)};return window.addEventListener(Jd,e),()=>window.removeEventListener(Jd,e)},C=[x],e[0]=x,e[1]=S,e[2]=C),(0,Z.useEffect)(S,C);let w;e[3]===b?w=e[4]:(w=()=>{!y.current&&b?.state===`dormant`&&b.hasRemote&&(y.current=!0,Ar.info(`This project has a GitHub remote.`,{description:`Sign in to enable automatic sync with your team.`,duration:8e3,action:{label:`Sign in`,onClick:()=>c(!0)}}))},e[3]=b,e[4]=w);let T=b?.state,E=b?.hasRemote,D;e[5]!==T||e[6]!==E?(D=[T,E],e[5]=T,e[6]=E,e[7]=D):D=e[7],(0,Z.useEffect)(w,D);let O;e[8]===n?O=e[9]:(O=function(e){i(e),n(e)},e[8]=n,e[9]=O);let k=O,A;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(A=async function(){v(!0);try{let e=await fetch(`/api/save-version`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})});e.ok?Ar.success(`Checkpoint saved`):(console.error(`[save-version] failed:`,await e.text()),Ar.error(`Checkpoint failed — try again`))}catch(e){console.error(`[save-version] failed:`,e),Ar.error(`Checkpoint failed — try again`)}v(!1)},e[10]=A):A=e[10];let j=A,M;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,X.jsx)(yf,{onOpenResolver:()=>o(!0)}),e[11]=M):M=e[11];let N,P,F,I;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>{u(`auth`),c(!0)},N=()=>{u(`identity`),c(!0)},P=()=>o(!0),F=()=>f(!0),e[12]=N,e[13]=P,e[14]=F,e[15]=I):(N=e[12],P=e[13],F=e[14],I=e[15]);let L;e[16]!==r||e[17]!==k||e[18]!==_?(L=(0,X.jsx)(_C,{editorMode:r,onModeChange:k,onSaveVersion:j,saving:_,onSignIn:I,onSetIdentity:N,onOpenConflictResolver:P,onOpenClone:F}),e[16]=r,e[17]=k,e[18]=_,e[19]=L):L=e[19];let R;e[20]!==h||e[21]!==r?(R=(0,X.jsx)(px,{editorMode:r,activeTab:h,onActiveTabChange:g}),e[20]=h,e[21]=r,e[22]=R):R=e[22];let z;e[23]===a?z=e[24]:(z=(0,X.jsx)(xm,{open:a,onOpenChange:o}),e[23]=a,e[24]=z);let B;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>{c(e),e||m(!1)},e[25]=B):B=e[25];let V=l===`identity`,H;e[26]===p?H=e[27]:(H=()=>{c(!1),p&&(m(!1),f(!0))},e[26]=p,e[27]=H);let U;e[28]!==s||e[29]!==V||e[30]!==H?(U=(0,X.jsx)(pf,{open:s,onOpenChange:B,identityPrompt:V,onSuccess:H}),e[28]=s,e[29]=V,e[30]=H,e[31]=U):U=e[31];let W;e[32]===Symbol.for(`react.memo_cache_sentinel`)?(W=()=>{f(!1),u(`auth`),m(!0),c(!0)},e[32]=W):W=e[32];let G;e[33]===d?G=e[34]:(G=(0,X.jsx)(_f,{open:d,onOpenChange:f,onSignIn:W}),e[33]=d,e[34]=G);let ee;return e[35]!==L||e[36]!==R||e[37]!==z||e[38]!==U||e[39]!==G?(ee=(0,X.jsxs)(X.Fragment,{children:[M,L,R,z,U,G]}),e[35]=L,e[36]=R,e[37]=z,e[38]=U,e[39]=G,e[40]=ee):ee=e[40],ee}var yC=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
29
29
  <symbol id="file-tree-icon-chevron" viewBox="0 0 16 16">
30
30
  <path d="M3.47 5.47a.75.75 0 0 1 1.06 0L8 8.94l3.47-3.47a.75.75 0 1 1 1.06 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 0 1 0-1.06" fill="currentcolor"/>
31
31
  </symbol>