@imenam/mcp-documentor 1.0.95 → 1.0.96

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.
@@ -0,0 +1,10 @@
1
+ import{b9 as i,bN as No,b8 as O,bb as e,bm as ls,bp as tn,bq as sn,br as nn,bO as wo,bP as Co,bi as ko,be as Es,bf as $s,bg as Rs,bQ as Ps,bR as So,bS as Eo,bT as $o,bU as Ro,bV as Po,bW as an,bw as on,bt as is,bu as Te,bn as rn,bX as Qt,bY as Do,bZ as ln,b_ as cn,bh as Lo,bj as To,bk as dt,bl as Mo,bv as Io,bs as Ao,bx as _o}from"./DocContent-D2Pgvsaw.js";var Ds="popstate";function Ls(t){return typeof t=="object"&&t!=null&&"pathname"in t&&"search"in t&&"hash"in t&&"state"in t&&"key"in t}function zo(t={}){function s(o,r){let{pathname:l="/",search:c="",hash:d=""}=Ae(o.location.hash.substring(1));return!l.startsWith("/")&&!l.startsWith(".")&&(l="/"+l),Zt("",{pathname:l,search:c,hash:d},r.state&&r.state.usr||null,r.state&&r.state.key||"default")}function n(o,r){let l=o.document.querySelector("base"),c="";if(l&&l.getAttribute("href")){let d=o.location.href,h=d.indexOf("#");c=h===-1?d:d.slice(0,h)}return c+"#"+(typeof r=="string"?r:et(r))}function a(o,r){le(o.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(r)})`)}return Oo(s,n,a,t)}function Z(t,s){if(t===!1||t===null||typeof t>"u")throw new Error(s)}function le(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function Fo(){return Math.random().toString(36).substring(2,10)}function Ts(t,s){return{usr:t.state,key:t.key,idx:s,masked:t.unstable_mask?{pathname:t.pathname,search:t.search,hash:t.hash}:void 0}}function Zt(t,s,n=null,a,o){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof s=="string"?Ae(s):s,state:n,key:s&&s.key||a||Fo(),unstable_mask:o}}function et({pathname:t="/",search:s="",hash:n=""}){return s&&s!=="?"&&(t+=s.charAt(0)==="?"?s:"?"+s),n&&n!=="#"&&(t+=n.charAt(0)==="#"?n:"#"+n),t}function Ae(t){let s={};if(t){let n=t.indexOf("#");n>=0&&(s.hash=t.substring(n),t=t.substring(0,n));let a=t.indexOf("?");a>=0&&(s.search=t.substring(a),t=t.substring(0,a)),t&&(s.pathname=t)}return s}function Oo(t,s,n,a={}){let{window:o=document.defaultView,v5Compat:r=!1}=a,l=o.history,c="POP",d=null,h=m();h==null&&(h=0,l.replaceState({...l.state,idx:h},""));function m(){return(l.state||{idx:null}).idx}function u(){c="POP";let g=m(),b=g==null?null:g-h;h=g,d&&d({action:c,location:j.location,delta:b})}function p(g,b){c="PUSH";let N=Ls(g)?g:Zt(j.location,g,b);n&&n(N,g),h=m()+1;let x=Ts(N,h),v=j.createHref(N.unstable_mask||N);try{l.pushState(x,"",v)}catch(w){if(w instanceof DOMException&&w.name==="DataCloneError")throw w;o.location.assign(v)}r&&d&&d({action:c,location:j.location,delta:1})}function f(g,b){c="REPLACE";let N=Ls(g)?g:Zt(j.location,g,b);n&&n(N,g),h=m();let x=Ts(N,h),v=j.createHref(N.unstable_mask||N);l.replaceState(x,"",v),r&&d&&d({action:c,location:j.location,delta:0})}function k(g){return Uo(g)}let j={get action(){return c},get location(){return t(o,l)},listen(g){if(d)throw new Error("A history only accepts one active listener");return o.addEventListener(Ds,u),d=g,()=>{o.removeEventListener(Ds,u),d=null}},createHref(g){return s(o,g)},createURL:k,encodeLocation(g){let b=k(g);return{pathname:b.pathname,search:b.search,hash:b.hash}},push:p,replace:f,go(g){return l.go(g)}};return j}function Uo(t,s=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Z(n,"No window.location.(origin|href) available to create URL");let a=typeof t=="string"?t:et(t);return a=a.replace(/ $/,"%20"),!s&&a.startsWith("//")&&(a=n+a),new URL(a,n)}function dn(t,s,n="/"){return Ho(t,s,n,!1)}function Ho(t,s,n,a){let o=typeof s=="string"?Ae(s):s,r=ve(o.pathname||"/",n);if(r==null)return null;let l=un(t);Bo(l);let c=null;for(let d=0;c==null&&d<l.length;++d){let h=er(r);c=Qo(l[d],h,a)}return c}function un(t,s=[],n=[],a="",o=!1){let r=(l,c,d=o,h)=>{let m={relativePath:h===void 0?l.path||"":h,caseSensitive:l.caseSensitive===!0,childrenIndex:c,route:l};if(m.relativePath.startsWith("/")){if(!m.relativePath.startsWith(a)&&d)return;Z(m.relativePath.startsWith(a),`Absolute route path "${m.relativePath}" nested under path "${a}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),m.relativePath=m.relativePath.slice(a.length)}let u=he([a,m.relativePath]),p=n.concat(m);l.children&&l.children.length>0&&(Z(l.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${u}".`),un(l.children,s,p,u,d)),!(l.path==null&&!l.index)&&s.push({path:u,score:Yo(u,l.index),routesMeta:p})};return t.forEach((l,c)=>{if(l.path===""||!l.path?.includes("?"))r(l,c);else for(let d of hn(l.path))r(l,c,!0,d)}),s}function hn(t){let s=t.split("/");if(s.length===0)return[];let[n,...a]=s,o=n.endsWith("?"),r=n.replace(/\?$/,"");if(a.length===0)return o?[r,""]:[r];let l=hn(a.join("/")),c=[];return c.push(...l.map(d=>d===""?r:[r,d].join("/"))),o&&c.push(...l),c.map(d=>t.startsWith("/")&&d===""?"/":d)}function Bo(t){t.sort((s,n)=>s.score!==n.score?n.score-s.score:Xo(s.routesMeta.map(a=>a.childrenIndex),n.routesMeta.map(a=>a.childrenIndex)))}var Wo=/^:[\w-]+$/,Vo=3,qo=2,Go=1,Ko=10,Jo=-2,Ms=t=>t==="*";function Yo(t,s){let n=t.split("/"),a=n.length;return n.some(Ms)&&(a+=Jo),s&&(a+=qo),n.filter(o=>!Ms(o)).reduce((o,r)=>o+(Wo.test(r)?Vo:r===""?Go:Ko),a)}function Xo(t,s){return t.length===s.length&&t.slice(0,-1).every((a,o)=>a===s[o])?t[t.length-1]-s[s.length-1]:0}function Qo(t,s,n=!1){let{routesMeta:a}=t,o={},r="/",l=[];for(let c=0;c<a.length;++c){let d=a[c],h=c===a.length-1,m=r==="/"?s:s.slice(r.length)||"/",u=yt({path:d.relativePath,caseSensitive:d.caseSensitive,end:h},m),p=d.route;if(!u&&h&&n&&!a[a.length-1].route.index&&(u=yt({path:d.relativePath,caseSensitive:d.caseSensitive,end:!1},m)),!u)return null;Object.assign(o,u.params),l.push({params:o,pathname:he([r,u.pathname]),pathnameBase:ar(he([r,u.pathnameBase])),route:p}),u.pathnameBase!=="/"&&(r=he([r,u.pathnameBase]))}return l}function yt(t,s){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,a]=Zo(t.path,t.caseSensitive,t.end),o=s.match(n);if(!o)return null;let r=o[0],l=r.replace(/(.)\/+$/,"$1"),c=o.slice(1);return{params:a.reduce((h,{paramName:m,isOptional:u},p)=>{if(m==="*"){let k=c[p]||"";l=r.slice(0,r.length-k.length).replace(/(.)\/+$/,"$1")}const f=c[p];return u&&!f?h[m]=void 0:h[m]=(f||"").replace(/%2F/g,"/"),h},{}),pathname:r,pathnameBase:l,pattern:t}}function Zo(t,s=!1,n=!0){le(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let a=[],o="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,c,d,h,m)=>{if(a.push({paramName:c,isOptional:d!=null}),d){let u=m.charAt(h+l.length);return u&&u!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(a.push({paramName:"*"}),o+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?o+="\\/*$":t!==""&&t!=="/"&&(o+="(?:(?=\\/|$))"),[new RegExp(o,s?void 0:"i"),a]}function er(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return le(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${s}).`),t}}function ve(t,s){if(s==="/")return t;if(!t.toLowerCase().startsWith(s.toLowerCase()))return null;let n=s.endsWith("/")?s.length-1:s.length,a=t.charAt(n);return a&&a!=="/"?null:t.slice(n)||"/"}var tr=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function sr(t,s="/"){let{pathname:n,search:a="",hash:o=""}=typeof t=="string"?Ae(t):t,r;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?r=Is(n.substring(1),"/"):r=Is(n,s)):r=s,{pathname:r,search:or(a),hash:rr(o)}}function Is(t,s){let n=s.replace(/\/+$/,"").split("/");return t.split("/").forEach(o=>{o===".."?n.length>1&&n.pop():o!=="."&&n.push(o)}),n.length>1?n.join("/"):"/"}function Bt(t,s,n,a){return`Cannot include a '${t}' character in a manually specified \`to.${s}\` field [${JSON.stringify(a)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function nr(t){return t.filter((s,n)=>n===0||s.route.path&&s.route.path.length>0)}function mn(t){let s=nr(t);return s.map((n,a)=>a===s.length-1?n.pathname:n.pathnameBase)}function cs(t,s,n,a=!1){let o;typeof t=="string"?o=Ae(t):(o={...t},Z(!o.pathname||!o.pathname.includes("?"),Bt("?","pathname","search",o)),Z(!o.pathname||!o.pathname.includes("#"),Bt("#","pathname","hash",o)),Z(!o.search||!o.search.includes("#"),Bt("#","search","hash",o)));let r=t===""||o.pathname==="",l=r?"/":o.pathname,c;if(l==null)c=n;else{let u=s.length-1;if(!a&&l.startsWith("..")){let p=l.split("/");for(;p[0]==="..";)p.shift(),u-=1;o.pathname=p.join("/")}c=u>=0?s[u]:"/"}let d=sr(o,c),h=l&&l!=="/"&&l.endsWith("/"),m=(r||l===".")&&n.endsWith("/");return!d.pathname.endsWith("/")&&(h||m)&&(d.pathname+="/"),d}var he=t=>t.join("/").replace(/\/\/+/g,"/"),ar=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),or=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,rr=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,lr=class{constructor(t,s,n,a=!1){this.status=t,this.statusText=s||"",this.internal=a,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function ir(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function cr(t){return t.map(s=>s.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var pn=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function fn(t,s){let n=t;if(typeof n!="string"||!tr.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let a=n,o=!1;if(pn)try{let r=new URL(window.location.href),l=n.startsWith("//")?new URL(r.protocol+n):new URL(n),c=ve(l.pathname,s);l.origin===r.origin&&c!=null?n=c+l.search+l.hash:o=!0}catch{le(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:a,isExternal:o,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var gn=["POST","PUT","PATCH","DELETE"];new Set(gn);var dr=["GET",...gn];new Set(dr);var _e=i.createContext(null);_e.displayName="DataRouter";var St=i.createContext(null);St.displayName="DataRouterState";var ur=i.createContext(!1),xn=i.createContext({isTransitioning:!1});xn.displayName="ViewTransition";var hr=i.createContext(new Map);hr.displayName="Fetchers";var mr=i.createContext(null);mr.displayName="Await";var oe=i.createContext(null);oe.displayName="Navigation";var Et=i.createContext(null);Et.displayName="Location";var je=i.createContext({outlet:null,matches:[],isDataRoute:!1});je.displayName="Route";var ds=i.createContext(null);ds.displayName="RouteError";var vn="REACT_ROUTER_ERROR",pr="REDIRECT",fr="ROUTE_ERROR_RESPONSE";function gr(t){if(t.startsWith(`${vn}:${pr}:{`))try{let s=JSON.parse(t.slice(28));if(typeof s=="object"&&s&&typeof s.status=="number"&&typeof s.statusText=="string"&&typeof s.location=="string"&&typeof s.reloadDocument=="boolean"&&typeof s.replace=="boolean")return s}catch{}}function xr(t){if(t.startsWith(`${vn}:${fr}:{`))try{let s=JSON.parse(t.slice(40));if(typeof s=="object"&&s&&typeof s.status=="number"&&typeof s.statusText=="string")return new lr(s.status,s.statusText,s.data)}catch{}}function vr(t,{relative:s}={}){Z(tt(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:a}=i.useContext(oe),{hash:o,pathname:r,search:l}=st(t,{relative:s}),c=r;return n!=="/"&&(c=r==="/"?n:he([n,r])),a.createHref({pathname:c,search:l,hash:o})}function tt(){return i.useContext(Et)!=null}function me(){return Z(tt(),"useLocation() may be used only in the context of a <Router> component."),i.useContext(Et).location}var jn="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function bn(t){i.useContext(oe).static||i.useLayoutEffect(t)}function re(){let{isDataRoute:t}=i.useContext(je);return t?Dr():jr()}function jr(){Z(tt(),"useNavigate() may be used only in the context of a <Router> component.");let t=i.useContext(_e),{basename:s,navigator:n}=i.useContext(oe),{matches:a}=i.useContext(je),{pathname:o}=me(),r=JSON.stringify(mn(a)),l=i.useRef(!1);return bn(()=>{l.current=!0}),i.useCallback((d,h={})=>{if(le(l.current,jn),!l.current)return;if(typeof d=="number"){n.go(d);return}let m=cs(d,JSON.parse(r),o,h.relative==="path");t==null&&s!=="/"&&(m.pathname=m.pathname==="/"?s:he([s,m.pathname])),(h.replace?n.replace:n.push)(m,h.state,h)},[s,n,r,o,t])}i.createContext(null);function st(t,{relative:s}={}){let{matches:n}=i.useContext(je),{pathname:a}=me(),o=JSON.stringify(mn(n));return i.useMemo(()=>cs(t,JSON.parse(o),a,s==="path"),[t,o,a,s])}function br(t,s){return yn(t)}function yn(t,s,n){Z(tt(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=i.useContext(oe),{matches:o}=i.useContext(je),r=o[o.length-1],l=r?r.params:{},c=r?r.pathname:"/",d=r?r.pathnameBase:"/",h=r&&r.route;{let g=h&&h.path||"";wn(c,!h||g.endsWith("*")||g.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${c}" (under <Route path="${g}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
2
+
3
+ Please change the parent <Route path="${g}"> to <Route path="${g==="/"?"*":`${g}/*`}">.`)}let m=me(),u;u=m;let p=u.pathname||"/",f=p;if(d!=="/"){let g=d.replace(/^\//,"").split("/");f="/"+p.replace(/^\//,"").split("/").slice(g.length).join("/")}let k=dn(t,{pathname:f});return le(h||k!=null,`No routes matched location "${u.pathname}${u.search}${u.hash}" `),le(k==null||k[k.length-1].route.element!==void 0||k[k.length-1].route.Component!==void 0||k[k.length-1].route.lazy!==void 0,`Matched leaf route at location "${u.pathname}${u.search}${u.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`),kr(k&&k.map(g=>Object.assign({},g,{params:Object.assign({},l,g.params),pathname:he([d,a.encodeLocation?a.encodeLocation(g.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathname]),pathnameBase:g.pathnameBase==="/"?d:he([d,a.encodeLocation?a.encodeLocation(g.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathnameBase])})),o,n)}function yr(){let t=Pr(),s=ir(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,a="rgba(200,200,200, 0.5)",o={padding:"0.5rem",backgroundColor:a},r={padding:"2px 4px",backgroundColor:a},l=null;return console.error("Error handled by React Router default ErrorBoundary:",t),l=i.createElement(i.Fragment,null,i.createElement("p",null,"💿 Hey developer 👋"),i.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",i.createElement("code",{style:r},"ErrorBoundary")," or"," ",i.createElement("code",{style:r},"errorElement")," prop on your route.")),i.createElement(i.Fragment,null,i.createElement("h2",null,"Unexpected Application Error!"),i.createElement("h3",{style:{fontStyle:"italic"}},s),n?i.createElement("pre",{style:o},n):null,l)}var Nr=i.createElement(yr,null),Nn=class extends i.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,s){return s.location!==t.location||s.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:s.error,location:s.location,revalidation:t.revalidation||s.revalidation}}componentDidCatch(t,s){this.props.onError?this.props.onError(t,s):console.error("React Router caught the following error during render",t)}render(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const n=xr(t.digest);n&&(t=n)}let s=t!==void 0?i.createElement(je.Provider,{value:this.props.routeContext},i.createElement(ds.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?i.createElement(wr,{error:t},s):s}};Nn.contextType=ur;var Wt=new WeakMap;function wr({children:t,error:s}){let{basename:n}=i.useContext(oe);if(typeof s=="object"&&s&&"digest"in s&&typeof s.digest=="string"){let a=gr(s.digest);if(a){let o=Wt.get(s);if(o)throw o;let r=fn(a.location,n);if(pn&&!Wt.get(s))if(r.isExternal||a.reloadDocument)window.location.href=r.absoluteURL||r.to;else{const l=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(r.to,{replace:a.replace}));throw Wt.set(s,l),l}return i.createElement("meta",{httpEquiv:"refresh",content:`0;url=${r.absoluteURL||r.to}`})}}return t}function Cr({routeContext:t,match:s,children:n}){let a=i.useContext(_e);return a&&a.static&&a.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=s.route.id),i.createElement(je.Provider,{value:t},n)}function kr(t,s=[],n){let a=n?.state;if(t==null){if(!a)return null;if(a.errors)t=a.matches;else if(s.length===0&&!a.initialized&&a.matches.length>0)t=a.matches;else return null}let o=t,r=a?.errors;if(r!=null){let m=o.findIndex(u=>u.route.id&&r?.[u.route.id]!==void 0);Z(m>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(r).join(",")}`),o=o.slice(0,Math.min(o.length,m+1))}let l=!1,c=-1;if(n&&a){l=a.renderFallback;for(let m=0;m<o.length;m++){let u=o[m];if((u.route.HydrateFallback||u.route.hydrateFallbackElement)&&(c=m),u.route.id){let{loaderData:p,errors:f}=a,k=u.route.loader&&!p.hasOwnProperty(u.route.id)&&(!f||f[u.route.id]===void 0);if(u.route.lazy||k){n.isStatic&&(l=!0),c>=0?o=o.slice(0,c+1):o=[o[0]];break}}}}let d=n?.onError,h=a&&d?(m,u)=>{d(m,{location:a.location,params:a.matches?.[0]?.params??{},unstable_pattern:cr(a.matches),errorInfo:u})}:void 0;return o.reduceRight((m,u,p)=>{let f,k=!1,j=null,g=null;a&&(f=r&&u.route.id?r[u.route.id]:void 0,j=u.route.errorElement||Nr,l&&(c<0&&p===0?(wn("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),k=!0,g=null):c===p&&(k=!0,g=u.route.hydrateFallbackElement||null)));let b=s.concat(o.slice(0,p+1)),N=()=>{let x;return f?x=j:k?x=g:u.route.Component?x=i.createElement(u.route.Component,null):u.route.element?x=u.route.element:x=m,i.createElement(Cr,{match:u,routeContext:{outlet:m,matches:b,isDataRoute:a!=null},children:x})};return a&&(u.route.ErrorBoundary||u.route.errorElement||p===0)?i.createElement(Nn,{location:a.location,revalidation:a.revalidation,component:j,error:f,children:N(),routeContext:{outlet:null,matches:b,isDataRoute:!0},onError:h}):N()},null)}function us(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Sr(t){let s=i.useContext(_e);return Z(s,us(t)),s}function Er(t){let s=i.useContext(St);return Z(s,us(t)),s}function $r(t){let s=i.useContext(je);return Z(s,us(t)),s}function hs(t){let s=$r(t),n=s.matches[s.matches.length-1];return Z(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function Rr(){return hs("useRouteId")}function Pr(){let t=i.useContext(ds),s=Er("useRouteError"),n=hs("useRouteError");return t!==void 0?t:s.errors?.[n]}function Dr(){let{router:t}=Sr("useNavigate"),s=hs("useNavigate"),n=i.useRef(!1);return bn(()=>{n.current=!0}),i.useCallback(async(o,r={})=>{le(n.current,jn),n.current&&(typeof o=="number"?await t.navigate(o):await t.navigate(o,{fromRouteId:s,...r}))},[t,s])}var As={};function wn(t,s,n){!s&&!As[t]&&(As[t]=!0,le(!1,n))}i.memo(Lr);function Lr({routes:t,future:s,state:n,isStatic:a,onError:o}){return yn(t,void 0,{state:n,isStatic:a,onError:o})}function Tr({basename:t="/",children:s=null,location:n,navigationType:a="POP",navigator:o,static:r=!1,unstable_useTransitions:l}){Z(!tt(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let c=t.replace(/^\/*/,"/"),d=i.useMemo(()=>({basename:c,navigator:o,static:r,unstable_useTransitions:l,future:{}}),[c,o,r,l]);typeof n=="string"&&(n=Ae(n));let{pathname:h="/",search:m="",hash:u="",state:p=null,key:f="default",unstable_mask:k}=n,j=i.useMemo(()=>{let g=ve(h,c);return g==null?null:{location:{pathname:g,search:m,hash:u,state:p,key:f,unstable_mask:k},navigationType:a}},[c,h,m,u,p,f,a,k]);return le(j!=null,`<Router basename="${c}"> is not able to match the URL "${h}${m}${u}" because it does not start with the basename, so the <Router> won't render anything.`),j==null?null:i.createElement(oe.Provider,{value:d},i.createElement(Et.Provider,{children:s,value:j}))}var gt="get",xt="application/x-www-form-urlencoded";function $t(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function Mr(t){return $t(t)&&t.tagName.toLowerCase()==="button"}function Ir(t){return $t(t)&&t.tagName.toLowerCase()==="form"}function Ar(t){return $t(t)&&t.tagName.toLowerCase()==="input"}function _r(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function zr(t,s){return t.button===0&&(!s||s==="_self")&&!_r(t)}var ut=null;function Fr(){if(ut===null)try{new FormData(document.createElement("form"),0),ut=!1}catch{ut=!0}return ut}var Or=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Vt(t){return t!=null&&!Or.has(t)?(le(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${xt}"`),null):t}function Ur(t,s){let n,a,o,r,l;if(Ir(t)){let c=t.getAttribute("action");a=c?ve(c,s):null,n=t.getAttribute("method")||gt,o=Vt(t.getAttribute("enctype"))||xt,r=new FormData(t)}else if(Mr(t)||Ar(t)&&(t.type==="submit"||t.type==="image")){let c=t.form;if(c==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let d=t.getAttribute("formaction")||c.getAttribute("action");if(a=d?ve(d,s):null,n=t.getAttribute("formmethod")||c.getAttribute("method")||gt,o=Vt(t.getAttribute("formenctype"))||Vt(c.getAttribute("enctype"))||xt,r=new FormData(c,t),!Fr()){let{name:h,type:m,value:u}=t;if(m==="image"){let p=h?`${h}.`:"";r.append(`${p}x`,"0"),r.append(`${p}y`,"0")}else h&&r.append(h,u)}}else{if($t(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=gt,a=null,o=xt,l=t}return r&&o==="text/plain"&&(l=r,r=void 0),{action:a,method:n.toLowerCase(),encType:o,formData:r,body:l}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function ms(t,s){if(t===!1||t===null||typeof t>"u")throw new Error(s)}function Hr(t,s,n,a){let o=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return n?o.pathname.endsWith("/")?o.pathname=`${o.pathname}_.${a}`:o.pathname=`${o.pathname}.${a}`:o.pathname==="/"?o.pathname=`_root.${a}`:s&&ve(o.pathname,s)==="/"?o.pathname=`${s.replace(/\/$/,"")}/_root.${a}`:o.pathname=`${o.pathname.replace(/\/$/,"")}.${a}`,o}async function Br(t,s){if(t.id in s)return s[t.id];try{let n=await import(t.module);return s[t.id]=n,n}catch(n){return console.error(`Error loading route module \`${t.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Wr(t){return t==null?!1:t.href==null?t.rel==="preload"&&typeof t.imageSrcSet=="string"&&typeof t.imageSizes=="string":typeof t.rel=="string"&&typeof t.href=="string"}async function Vr(t,s,n){let a=await Promise.all(t.map(async o=>{let r=s.routes[o.route.id];if(r){let l=await Br(r,n);return l.links?l.links():[]}return[]}));return Jr(a.flat(1).filter(Wr).filter(o=>o.rel==="stylesheet"||o.rel==="preload").map(o=>o.rel==="stylesheet"?{...o,rel:"prefetch",as:"style"}:{...o,rel:"prefetch"}))}function _s(t,s,n,a,o,r){let l=(d,h)=>n[h]?d.route.id!==n[h].route.id:!0,c=(d,h)=>n[h].pathname!==d.pathname||n[h].route.path?.endsWith("*")&&n[h].params["*"]!==d.params["*"];return r==="assets"?s.filter((d,h)=>l(d,h)||c(d,h)):r==="data"?s.filter((d,h)=>{let m=a.routes[d.route.id];if(!m||!m.hasLoader)return!1;if(l(d,h)||c(d,h))return!0;if(d.route.shouldRevalidate){let u=d.route.shouldRevalidate({currentUrl:new URL(o.pathname+o.search+o.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(t,window.origin),nextParams:d.params,defaultShouldRevalidate:!0});if(typeof u=="boolean")return u}return!0}):[]}function qr(t,s,{includeHydrateFallback:n}={}){return Gr(t.map(a=>{let o=s.routes[a.route.id];if(!o)return[];let r=[o.module];return o.clientActionModule&&(r=r.concat(o.clientActionModule)),o.clientLoaderModule&&(r=r.concat(o.clientLoaderModule)),n&&o.hydrateFallbackModule&&(r=r.concat(o.hydrateFallbackModule)),o.imports&&(r=r.concat(o.imports)),r}).flat(1))}function Gr(t){return[...new Set(t)]}function Kr(t){let s={},n=Object.keys(t).sort();for(let a of n)s[a]=t[a];return s}function Jr(t,s){let n=new Set;return new Set(s),t.reduce((a,o)=>{let r=JSON.stringify(Kr(o));return n.has(r)||(n.add(r),a.push({key:r,link:o})),a},[])}function Cn(){let t=i.useContext(_e);return ms(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Yr(){let t=i.useContext(St);return ms(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var ps=i.createContext(void 0);ps.displayName="FrameworkContext";function kn(){let t=i.useContext(ps);return ms(t,"You must render this element inside a <HydratedRouter> element"),t}function Xr(t,s){let n=i.useContext(ps),[a,o]=i.useState(!1),[r,l]=i.useState(!1),{onFocus:c,onBlur:d,onMouseEnter:h,onMouseLeave:m,onTouchStart:u}=s,p=i.useRef(null);i.useEffect(()=>{if(t==="render"&&l(!0),t==="viewport"){let j=b=>{b.forEach(N=>{l(N.isIntersecting)})},g=new IntersectionObserver(j,{threshold:.5});return p.current&&g.observe(p.current),()=>{g.disconnect()}}},[t]),i.useEffect(()=>{if(a){let j=setTimeout(()=>{l(!0)},100);return()=>{clearTimeout(j)}}},[a]);let f=()=>{o(!0)},k=()=>{o(!1),l(!1)};return n?t!=="intent"?[r,p,{}]:[r,p,{onFocus:Ge(c,f),onBlur:Ge(d,k),onMouseEnter:Ge(h,f),onMouseLeave:Ge(m,k),onTouchStart:Ge(u,f)}]:[!1,p,{}]}function Ge(t,s){return n=>{t&&t(n),n.defaultPrevented||s(n)}}function Qr({page:t,...s}){let{router:n}=Cn(),a=i.useMemo(()=>dn(n.routes,t,n.basename),[n.routes,t,n.basename]);return a?i.createElement(el,{page:t,matches:a,...s}):null}function Zr(t){let{manifest:s,routeModules:n}=kn(),[a,o]=i.useState([]);return i.useEffect(()=>{let r=!1;return Vr(t,s,n).then(l=>{r||o(l)}),()=>{r=!0}},[t,s,n]),a}function el({page:t,matches:s,...n}){let a=me(),{future:o,manifest:r,routeModules:l}=kn(),{basename:c}=Cn(),{loaderData:d,matches:h}=Yr(),m=i.useMemo(()=>_s(t,s,h,r,a,"data"),[t,s,h,r,a]),u=i.useMemo(()=>_s(t,s,h,r,a,"assets"),[t,s,h,r,a]),p=i.useMemo(()=>{if(t===a.pathname+a.search+a.hash)return[];let j=new Set,g=!1;if(s.forEach(N=>{let x=r.routes[N.route.id];!x||!x.hasLoader||(!m.some(v=>v.route.id===N.route.id)&&N.route.id in d&&l[N.route.id]?.shouldRevalidate||x.hasClientLoader?g=!0:j.add(N.route.id))}),j.size===0)return[];let b=Hr(t,c,o.unstable_trailingSlashAwareDataRequests,"data");return g&&j.size>0&&b.searchParams.set("_routes",s.filter(N=>j.has(N.route.id)).map(N=>N.route.id).join(",")),[b.pathname+b.search]},[c,o.unstable_trailingSlashAwareDataRequests,d,a,r,m,s,t,l]),f=i.useMemo(()=>qr(u,r),[u,r]),k=Zr(u);return i.createElement(i.Fragment,null,p.map(j=>i.createElement("link",{key:j,rel:"prefetch",as:"fetch",href:j,...n})),f.map(j=>i.createElement("link",{key:j,rel:"modulepreload",href:j,...n})),k.map(({key:j,link:g})=>i.createElement("link",{key:j,nonce:n.nonce,...g,crossOrigin:g.crossOrigin??n.crossOrigin})))}function tl(...t){return s=>{t.forEach(n=>{typeof n=="function"?n(s):n!=null&&(n.current=s)})}}var sl=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{sl&&(window.__reactRouterVersion="7.13.1")}catch{}function nl({basename:t,children:s,unstable_useTransitions:n,window:a}){let o=i.useRef();o.current==null&&(o.current=zo({window:a,v5Compat:!0}));let r=o.current,[l,c]=i.useState({action:r.action,location:r.location}),d=i.useCallback(h=>{n===!1?c(h):i.startTransition(()=>c(h))},[n]);return i.useLayoutEffect(()=>r.listen(d),[r,d]),i.createElement(Tr,{basename:t,children:s,location:l.location,navigationType:l.action,navigator:r,unstable_useTransitions:n})}var Sn=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,En=i.forwardRef(function({onClick:s,discover:n="render",prefetch:a="none",relative:o,reloadDocument:r,replace:l,unstable_mask:c,state:d,target:h,to:m,preventScrollReset:u,viewTransition:p,unstable_defaultShouldRevalidate:f,...k},j){let{basename:g,navigator:b,unstable_useTransitions:N}=i.useContext(oe),x=typeof m=="string"&&Sn.test(m),v=fn(m,g);m=v.to;let w=vr(m,{relative:o}),R=me(),E=null;if(c){let B=cs(c,[],R.unstable_mask?R.unstable_mask.pathname:"/",!0);g!=="/"&&(B.pathname=B.pathname==="/"?g:he([g,B.pathname])),E=b.createHref(B)}let[y,$,L]=Xr(a,k),S=ll(m,{replace:l,unstable_mask:c,state:d,target:h,preventScrollReset:u,relative:o,viewTransition:p,unstable_defaultShouldRevalidate:f,unstable_useTransitions:N});function I(B){s&&s(B),B.defaultPrevented||S(B)}let z=!(v.isExternal||r),X=i.createElement("a",{...k,...L,href:(z?E:void 0)||v.absoluteURL||w,onClick:z?I:s,ref:tl(j,$),target:h,"data-discover":!x&&n==="render"?"true":void 0});return y&&!x?i.createElement(i.Fragment,null,X,i.createElement(Qr,{page:w})):X});En.displayName="Link";var al=i.forwardRef(function({"aria-current":s="page",caseSensitive:n=!1,className:a="",end:o=!1,style:r,to:l,viewTransition:c,children:d,...h},m){let u=st(l,{relative:h.relative}),p=me(),f=i.useContext(St),{navigator:k,basename:j}=i.useContext(oe),g=f!=null&&hl(u)&&c===!0,b=k.encodeLocation?k.encodeLocation(u).pathname:u.pathname,N=p.pathname,x=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;n||(N=N.toLowerCase(),x=x?x.toLowerCase():null,b=b.toLowerCase()),x&&j&&(x=ve(x,j)||x);const v=b!=="/"&&b.endsWith("/")?b.length-1:b.length;let w=N===b||!o&&N.startsWith(b)&&N.charAt(v)==="/",R=x!=null&&(x===b||!o&&x.startsWith(b)&&x.charAt(b.length)==="/"),E={isActive:w,isPending:R,isTransitioning:g},y=w?s:void 0,$;typeof a=="function"?$=a(E):$=[a,w?"active":null,R?"pending":null,g?"transitioning":null].filter(Boolean).join(" ");let L=typeof r=="function"?r(E):r;return i.createElement(En,{...h,"aria-current":y,className:$,ref:m,style:L,to:l,viewTransition:c},typeof d=="function"?d(E):d)});al.displayName="NavLink";var ol=i.forwardRef(({discover:t="render",fetcherKey:s,navigate:n,reloadDocument:a,replace:o,state:r,method:l=gt,action:c,onSubmit:d,relative:h,preventScrollReset:m,viewTransition:u,unstable_defaultShouldRevalidate:p,...f},k)=>{let{unstable_useTransitions:j}=i.useContext(oe),g=dl(),b=ul(c,{relative:h}),N=l.toLowerCase()==="get"?"get":"post",x=typeof c=="string"&&Sn.test(c),v=w=>{if(d&&d(w),w.defaultPrevented)return;w.preventDefault();let R=w.nativeEvent.submitter,E=R?.getAttribute("formmethod")||l,y=()=>g(R||w.currentTarget,{fetcherKey:s,method:E,navigate:n,replace:o,state:r,relative:h,preventScrollReset:m,viewTransition:u,unstable_defaultShouldRevalidate:p});j&&n!==!1?i.startTransition(()=>y()):y()};return i.createElement("form",{ref:k,method:N,action:b,onSubmit:a?d:v,...f,"data-discover":!x&&t==="render"?"true":void 0})});ol.displayName="Form";function rl(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function $n(t){let s=i.useContext(_e);return Z(s,rl(t)),s}function ll(t,{target:s,replace:n,unstable_mask:a,state:o,preventScrollReset:r,relative:l,viewTransition:c,unstable_defaultShouldRevalidate:d,unstable_useTransitions:h}={}){let m=re(),u=me(),p=st(t,{relative:l});return i.useCallback(f=>{if(zr(f,s)){f.preventDefault();let k=n!==void 0?n:et(u)===et(p),j=()=>m(t,{replace:k,unstable_mask:a,state:o,preventScrollReset:r,relative:l,viewTransition:c,unstable_defaultShouldRevalidate:d});h?i.startTransition(()=>j()):j()}},[u,m,p,n,a,o,s,t,r,l,c,d,h])}var il=0,cl=()=>`__${String(++il)}__`;function dl(){let{router:t}=$n("useSubmit"),{basename:s}=i.useContext(oe),n=Rr(),a=t.fetch,o=t.navigate;return i.useCallback(async(r,l={})=>{let{action:c,method:d,encType:h,formData:m,body:u}=Ur(r,s);if(l.navigate===!1){let p=l.fetcherKey||cl();await a(p,n,l.action||c,{unstable_defaultShouldRevalidate:l.unstable_defaultShouldRevalidate,preventScrollReset:l.preventScrollReset,formData:m,body:u,formMethod:l.method||d,formEncType:l.encType||h,flushSync:l.flushSync})}else await o(l.action||c,{unstable_defaultShouldRevalidate:l.unstable_defaultShouldRevalidate,preventScrollReset:l.preventScrollReset,formData:m,body:u,formMethod:l.method||d,formEncType:l.encType||h,replace:l.replace,state:l.state,fromRouteId:n,flushSync:l.flushSync,viewTransition:l.viewTransition})},[a,o,s,n])}function ul(t,{relative:s}={}){let{basename:n}=i.useContext(oe),a=i.useContext(je);Z(a,"useFormAction must be used inside a RouteContext");let[o]=a.matches.slice(-1),r={...st(t||".",{relative:s})},l=me();if(t==null){r.search=l.search;let c=new URLSearchParams(r.search),d=c.getAll("index");if(d.some(m=>m==="")){c.delete("index"),d.filter(u=>u).forEach(u=>c.append("index",u));let m=c.toString();r.search=m?`?${m}`:""}}return(!t||t===".")&&o.route.index&&(r.search=r.search?r.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(r.pathname=r.pathname==="/"?n:he([n,r.pathname])),et(r)}function hl(t,{relative:s}={}){let n=i.useContext(xn);Z(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:a}=$n("useViewTransitionState"),o=st(t,{relative:s});if(!n.isTransitioning)return!1;let r=ve(n.currentLocation.pathname,a)||n.currentLocation.pathname,l=ve(n.nextLocation.pathname,a)||n.nextLocation.pathname;return yt(o.pathname,l)!=null||yt(o.pathname,r)!=null}var ml=No();const Rn={name:"book-open",size:24,node:[["path",{d:"M12 5v16",key:"1f6ucr"}],["path",{d:"M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z",key:"1fyvmf"}]]};Rn.node;const pl=O(Rn);const Pn={name:"check",size:24,node:[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]};Pn.node;const Se=O(Pn);const Dn={name:"chevron-down",size:24,node:[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]};Dn.node;const Rt=O(Dn);const Ln={name:"chevron-right",size:24,node:[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]};Ln.node;const fl=O(Ln);const Tn={name:"chevron-up",size:24,node:[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]};Tn.node;const Mn=O(Tn);const In={name:"chevrons-down-up",size:24,node:[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]]};In.node;const gl=O(In);const An={name:"chevrons-up-down",size:24,node:[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]};An.node;const xl=O(An);const _n={name:"circle-alert",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],aliases:["alert-circle"]};_n.node;const vl=O(_n);const zn={name:"circle-check",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 9-5.5 5.5L8 12",key:"xofnsj"}]],aliases:["check-circle-2"]};zn.node;const Je=O(zn);const Fn={name:"clock-alert",size:24,node:[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["path",{d:"M20 12v5",key:"12wsvk"}],["path",{d:"M20 21h.01",key:"1p6o6n"}],["path",{d:"M21.25 8.2A10 10 0 1 0 16 21.16",key:"17fp9f"}]]};Fn.node;const jl=O(Fn);const On={name:"clock",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]};On.node;const Un=O(On);const Hn={name:"cloud",size:24,node:[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]};Hn.node;const fs=O(Hn);const Bn={name:"copy",size:24,node:[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]};Bn.node;const Pt=O(Bn);const Wn={name:"download",size:24,node:[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]};Wn.node;const bl=O(Wn);const Vn={name:"external-link",size:24,node:[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]};Vn.node;const qn=O(Vn);const Gn={name:"file-text",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]};Gn.node;const Kn=O(Gn);const Jn={name:"files",size:24,node:[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]};Jn.node;const yl=O(Jn);const Yn={name:"folder-open",size:24,node:[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]};Yn.node;const Dt=O(Yn);const Xn={name:"folder",size:24,node:[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]};Xn.node;const Qn=O(Xn);const Zn={name:"git-branch",size:24,node:[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]]};Zn.node;const Nl=O(Zn);const ea={name:"git-commit-horizontal",size:24,node:[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],aliases:["git-commit"]};ea.node;const wl=O(ea);const ta={name:"git-fork",size:24,node:[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]]};ta.node;const Nt=O(ta);const sa={name:"globe",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]};sa.node;const Lt=O(sa);const na={name:"import",size:24,node:[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m8 11 4 4 4-4",key:"1dohi6"}],["path",{d:"M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4",key:"1ywtjm"}]]};na.node;const Cl=O(na);const aa={name:"info",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]};aa.node;const kl=O(aa);const oa={name:"key-round",size:24,node:[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]};oa.node;const Sl=O(oa);const ra={name:"laptop",size:24,node:[["path",{d:"M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z",key:"1pdavp"}],["path",{d:"M20.054 15.987H3.946",key:"14rxg9"}]]};ra.node;const gs=O(ra);const la={name:"loader-circle",size:24,node:[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],aliases:["loader-2"]};la.node;const qt=O(la);const ia={name:"lock",size:24,node:[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]};ia.node;const El=O(ia);const ca={name:"package",size:24,node:[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]};ca.node;const $l=O(ca);const da={name:"panel-left-close",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],aliases:["sidebar-close"]};da.node;const Rl=O(da);const ua={name:"plus",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]};ua.node;const ha=O(ua);const ma={name:"refresh-cw",size:24,node:[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]};ma.node;const wt=O(ma);const pa={name:"scan-search",size:24,node:[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m16 16-1.9-1.9",key:"1dq9hf"}]]};pa.node;const Pl=O(pa);const fa={name:"scroll-text",size:24,node:[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]};fa.node;const ga=O(fa);const xa={name:"search",size:24,node:[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]};xa.node;const nt=O(xa);const va={name:"settings",size:24,node:[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]};va.node;const ja=O(va);const ba={name:"trash",size:24,node:[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],aliases:["trash-2"]};ba.node;const Dl=O(ba);const ya={name:"triangle-alert",size:24,node:[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],aliases:["alert-triangle"]};ya.node;const xs=O(ya);const Na={name:"unlink",size:24,node:[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]};Na.node;const vs=O(Na),Ll={currentProject:"default",projects:["default"],docs:[],selectedDocId:null,selectedDoc:null,freshnessResult:null,searchQuery:"",searchResults:[],hasReceivedInitialState:!1,searchAllProjects:!1,historyEntries:null,historyVersionContent:null,exportBundles:[],readOnly:!1,syncEnabled:!1,codeSourceMigrationPending:!1,codeSourcesVersion:0,publicationsVersion:0,commentsVersion:0,commentSummary:{project:"",docs:{}}};let A={...Ll},vt=[];function Q(){vt.forEach(t=>t())}function Y(){const[,t]=i.useState(0),s=i.useCallback(()=>{const n=()=>t(a=>a+1);return vt.push(n),()=>{vt=vt.filter(a=>a!==n)}},[]);return i.useState(()=>s()),{...A,setProjects:n=>{A={...A,projects:n},Q()},setCurrentProject:n=>{A={...A,currentProject:n},Q()},setDocs:n=>{A={...A,docs:n},Q()},setSelectedDocId:n=>{A={...A,selectedDocId:n,freshnessResult:null},Q()},setSelectedDoc:n=>{A={...A,selectedDoc:n},Q()},setFreshnessResult:n=>{A={...A,freshnessResult:n},Q()},setSearchQuery:n=>{A={...A,searchQuery:n},Q()},setSearchResults:n=>{A={...A,searchResults:n},Q()},clearSearch:()=>{A={...A,searchQuery:"",searchResults:[]},Q()},setSearchAllProjects:n=>{A={...A,searchAllProjects:n},Q()},setHistoryEntries:n=>{A={...A,historyEntries:n,historyVersionContent:null},Q()},setHistoryVersionContent:n=>{A={...A,historyVersionContent:n},Q()},setExportBundles:n=>{A={...A,exportBundles:n},Q()},bumpCodeSourcesVersion:()=>{A={...A,codeSourcesVersion:A.codeSourcesVersion+1},Q()},bumpPublicationsVersion:()=>{A={...A,publicationsVersion:A.publicationsVersion+1},Q()},bumpCommentsVersion:()=>{A={...A,commentsVersion:A.commentsVersion+1},Q()},setCommentSummary:(n,a)=>{A={...A,commentSummary:{project:n,docs:a}},Q()},setCodeSourceMigrationPending:n=>{A={...A,codeSourceMigrationPending:n},Q()},applyInitialState:n=>{const a=n.projects??n.config?.projects??A.projects,o=a.length===A.projects.length&&a.every((r,l)=>r===A.projects[l]);A={...A,projects:o?A.projects:a,docs:n.docs??A.docs,exportBundles:n.bundles??A.exportBundles,readOnly:n.readOnly??A.readOnly,syncEnabled:n.syncEnabled??A.syncEnabled,codeSourceMigrationPending:n.codeSourceMigrationPending??A.codeSourceMigrationPending,hasReceivedInitialState:!0},Q()}}}function ne(t,s){const n=encodeURIComponent(t);if(!s)return`/${n}`;const a=s.split("/").filter(Boolean).map(o=>encodeURIComponent(o)).join("/");return a?`/${n}/${a}`:`/${n}`}function zs(t){const s=t.replace(/^\/+|\/+$/g,"");if(!s)return{project:null,docId:null};const n=s.split("/").filter(Boolean);if(n.length===0)return{project:null,docId:null};const a=decodeURIComponent(n[0]);if(n.length===1)return{project:a,docId:null};const o=n.slice(1).map(r=>decodeURIComponent(r)).join("/");return{project:a,docId:o}}function Tl(t){try{return decodeURIComponent(t)}catch{return t}}function xe(t){return t.split("/").filter(Boolean).map(s=>encodeURIComponent(s)).join("/")}const jt="/_logs";function Ct(t){return`${jt}/${t}`}const wa="/_publications";function js(t){return t.replace(/\/+$/,"")===wa}function Ca(t){const s=t.replace(/\/+$/,"");return s!==jt&&!s.startsWith(`${jt}/`)?null:s.slice(jt.length+1)==="github"?"github":"server"}const ka=t=>`mcp-documentor:expanded-folders:${t}`;function Fs(t){try{const s=JSON.parse(localStorage.getItem(ka(t))??"null");return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function Ml(t,s){try{localStorage.setItem(ka(t),JSON.stringify(s))}catch{}}function Sa(t,s,n,a){const o=new URLSearchParams;s&&o.set("flat","1"),n&&o.set("headers","1"),o.set("project",a);const r=o.toString(),l=document.createElement("a");l.href=`/api/export-zip/${t.id}${r?`?${r}`:""}`,l.download=t.zipFilename,l.click()}function Il({bundle:t,onClose:s}){const[n,a]=i.useState(!1),[o,r]=i.useState(!1),{currentProject:l}=Y();return e.jsx("div",{className:"settings-overlay",onClick:s,children:e.jsxs("div",{className:"settings-popover export-bundle-modal",onClick:c=>c.stopPropagation(),children:[e.jsx("h2",{className:"settings-title",children:t.name}),t.description&&e.jsx("p",{className:"export-bundle-modal-desc",children:t.description}),e.jsx("div",{className:"export-bundle-modal-meta",children:e.jsxs("span",{className:"export-bundle-modal-filename",children:["📦 ",t.zipFilename]})}),e.jsxs("div",{className:"export-bundle-modal-section",children:[e.jsxs("div",{className:"export-bundle-modal-section-title",children:["Documents inclus (",t.docs.length,")"]}),e.jsx("ul",{className:"export-bundle-modal-docs",children:t.docs.map(c=>e.jsx("li",{className:"export-bundle-modal-doc-item",children:e.jsx("span",{className:"export-bundle-modal-doc-ref",children:c})},c))})]}),e.jsxs("div",{className:"export-bundle-modal-toggle-row",children:[e.jsx("span",{className:"export-bundle-modal-toggle-label",children:"Ne pas conserver l'arborescence"}),e.jsx("button",{role:"switch","aria-checked":n,className:`toggle-switch${n?" toggle-switch--on":""}`,onClick:()=>a(c=>!c)})]}),e.jsxs("div",{className:"export-bundle-modal-toggle-row",children:[e.jsx("span",{className:"export-bundle-modal-toggle-label",children:"Inclure les entêtes (métadonnées)"}),e.jsx("button",{role:"switch","aria-checked":o,className:`toggle-switch${o?" toggle-switch--on":""}`,onClick:()=>r(c=>!c)})]}),e.jsxs("div",{className:"settings-actions",children:[e.jsx("button",{className:"settings-cancel-btn",onClick:s,children:"Fermer"}),e.jsx("button",{className:"settings-save-btn",onClick:()=>{Sa(t,n,o,l),s()},children:"↓ Télécharger ZIP"})]})]})})}function Al(){const{exportBundles:t,currentProject:s}=Y(),[n,a]=i.useState(null);return t.length===0?e.jsx("div",{className:"nav-empty",children:"No export bundles yet."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"export-bundles-list",children:t.map(o=>e.jsxs("div",{className:"export-bundle-item",onClick:()=>a(o),children:[e.jsxs("div",{className:"export-bundle-info",children:[e.jsx("span",{className:"export-bundle-name",children:o.name}),o.description&&e.jsx("span",{className:"export-bundle-desc",children:o.description}),e.jsxs("span",{className:"export-bundle-meta",children:[o.docs.length," doc",o.docs.length!==1?"s":""]})]}),e.jsx("button",{className:"export-bundle-btn",onClick:r=>{r.stopPropagation(),Sa(o,!1,!1,s)},title:`Télécharger ${o.zipFilename}`,children:"↓ ZIP"})]},o.id))}),n&&e.jsx(Il,{bundle:n,onClose:()=>a(null)})]})}const Ea="mcp-documentor:project";function Os(){try{return localStorage.getItem(Ea)}catch{return null}}function _l(t){try{localStorage.setItem(Ea,t)}catch{}}async function $a(t){try{const s=await fetch(`/api/docs?project=${encodeURIComponent(t)}`);return s.ok?(await s.json()).docs??[]:[]}catch{return[]}}async function zl(t){try{const s=await fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t})});return s.ok?{ok:!0,projects:(await s.json()).projects}:{ok:!1}}catch{return{ok:!1}}}function Fl(t){const s=t.split(/[^a-zA-Z0-9]+/).filter(Boolean);return s.length===0?"?":(s.length>1?s[0][0]+s[1][0]:s[0].slice(0,2)).toUpperCase()}function Ol(t){let s=0;for(const n of t)s=s*31+n.charCodeAt(0)>>>0;return`hsl(${s%360}, 52%, 46%)`}async function ie(t,s){const n=await fetch(t,s);let a=null;try{a=await n.json()}catch{}if(!n.ok)throw new Error(a?.error??`HTTP ${n.status}`);return a}const ze=t=>({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});async function Ra(){return(await ie("/api/code-sources")).projects}async function Ul(t,s){return(await ie("/api/code-sources/search",{...ze({query:t}),signal:s})).results}function Hl(t,s,n){return ie("/api/code-sources/inspect",{...ze({repo:t,branch:s}),signal:n})}function Bl(t,s,n,a){return ie("/api/code-sources/preview",{...ze({project:t,config:s,codeRoot:n}),signal:a})}function Wl(t,s,n){return ie("/api/code-sources/apply",ze({project:t,config:s,codeRoot:n}))}function Vl(t,s){return ie("/api/code-roots/inspect",{...ze({path:t}),signal:s})}function ql(){return ie("/api/code-roots")}function Gl(t){return ie("/api/code-roots/apply",ze({path:t}))}function Kl(){return ie("/api/github-token")}async function Pa(){return(await ie("/api/code-source-migration")).report}function Jl(){return ie("/api/code-source-migration/ack",{method:"POST"})}function Us(t){const s=t.config;return s?s.kind==="github"?`${s.repo} · ${s.branch??"default branch"}`:t.codeRoot?`Local · ${t.codeRoot}`:"Local working copy":"Settings unreadable"}function Yl({source:t,size:s,active:n}){if(t?.error)return e.jsx(xs,{size:s,className:"source-icon error"});const a=`source-icon${n?" active":""}`;return t?.config?.kind==="github"?e.jsx(fs,{size:s,className:a}):e.jsx(gs,{size:s,className:a})}function Hs({project:t,size:s}){return e.jsx("span",{className:"project-avatar",style:{width:s,height:s,background:Ol(t),fontSize:Math.round(s*.36)},children:Fl(t)})}function Da({variant:t,onOpenSettings:s}){const n=re(),{currentProject:a,projects:o,applyInitialState:r,codeSourcesVersion:l}=Y(),[c,d]=i.useState(""),[h,m]=i.useState(!1),[u,p]=i.useState(!1),[f,k]=i.useState(0),[j,g]=i.useState(""),[b,N]=i.useState({}),x=i.useRef(null),v=i.useRef(null),w=i.useRef(null),R=j.trim().toLowerCase(),E=R?o.filter(T=>T.toLowerCase().includes(R)):o,y=i.useCallback(()=>{Ra().then(T=>N(Object.fromEntries(T.map(W=>[W.project,W])))).catch(()=>{})},[]);i.useEffect(y,[l,o,y]),i.useEffect(()=>{u&&y()},[u,y]),i.useEffect(()=>{u&&!h&&w.current?.focus()},[u,h]),i.useEffect(()=>{x.current?.querySelector(`[data-index="${f}"]`)?.scrollIntoView({block:"nearest"})},[f]);const $=T=>{n(ne(T,null))},L=()=>{k(Math.max(0,o.indexOf(a))),g(""),m(!1),p(!0)},S=()=>{p(!1),m(!1),v.current?.focus()},I=T=>{S(),$(T)},z=T=>{p(!1),s(T)},X=T=>{g(T),k(0)},B=T=>{T.key==="ArrowDown"?(T.preventDefault(),k(W=>Math.min(E.length-1,W+1))):T.key==="ArrowUp"?(T.preventDefault(),k(W=>Math.max(0,W-1))):T.key==="Enter"?(T.preventDefault(),E[f]&&I(E[f])):(T.key==="Escape"||T.key==="Tab")&&S()},q=async()=>{const T=c.trim().replace(/[^a-zA-Z0-9_-]/g,"-");if(!T)return;const{ok:W,projects:J}=await zl(T);W&&(J&&r({projects:J}),d(""),S(),$(T))},D=b[a],V=D?`${a} — ${D.error??Us(D)}`:a;return e.jsxs("div",{className:`project-selector project-selector--${t}`,children:[e.jsxs("button",{ref:v,className:`project-trigger${u?" open":""}${D?.error?" error":""}`,onClick:()=>u?S():L(),onKeyDown:T=>{T.key==="ArrowDown"&&!u&&(T.preventDefault(),L())},title:V,"aria-haspopup":"listbox","aria-expanded":u,children:[e.jsx(Hs,{project:a,size:t==="rail"?32:28}),t==="card"&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"project-trigger-text",children:[e.jsx("span",{className:"project-trigger-label",children:a}),e.jsx("span",{className:`project-trigger-caption${D?.error?" error":""}`,children:D?.error?"Code source to fix":"Current project"})]}),e.jsx(xl,{size:14,className:"project-trigger-caret"})]})]}),u&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"menu-backdrop",onClick:S}),e.jsxs("div",{className:"project-menu",children:[e.jsx("div",{className:"project-menu-label",children:"Projects · code source"}),e.jsxs("div",{className:"project-menu-search",children:[e.jsx(nt,{size:14,className:"project-menu-search-icon"}),e.jsx("input",{ref:w,className:"project-menu-search-input",type:"text",placeholder:"Search projects",value:j,onChange:T=>X(T.target.value),onKeyDown:B,role:"combobox","aria-expanded":!0,"aria-controls":"project-menu-list","aria-activedescendant":E.length?`project-option-${f}`:void 0})]}),e.jsxs("div",{id:"project-menu-list",className:"project-menu-list",role:"listbox",tabIndex:-1,ref:x,onKeyDown:B,"aria-activedescendant":E.length?`project-option-${f}`:void 0,children:[E.length===0&&e.jsx("div",{className:"project-menu-empty",children:"No matching project"}),E.map((T,W)=>{const J=b[T],be=T===a;return e.jsxs("div",{id:`project-option-${W}`,"data-index":W,role:"option","aria-selected":be,className:`project-option${be?" current":""}${W===f?" highlighted":""}`,onMouseEnter:()=>k(W),onClick:()=>I(T),children:[e.jsx(Hs,{project:T,size:24}),e.jsxs("div",{className:"project-option-text",children:[e.jsx("span",{className:"project-option-name",children:T}),J&&e.jsxs("span",{className:`project-option-source${J.error?" error":""}`,children:[e.jsx(Yl,{source:J,size:11,active:J.config?.kind==="github"}),J.error??Us(J)]})]}),J?.error?e.jsx("button",{className:"project-option-fix",onClick:ce=>{ce.stopPropagation(),z(T)},children:"Fix"}):e.jsxs(e.Fragment,{children:[be&&e.jsx(Se,{size:14,className:"project-option-check"}),e.jsx("button",{className:"project-option-gear",title:`Settings of ${T}`,onClick:ce=>{ce.stopPropagation(),z(T)},children:e.jsx(ja,{size:14})})]})]},T)})]}),e.jsx("div",{className:"project-menu-footer",children:h?e.jsxs("div",{className:"new-project-row",children:[e.jsx("input",{className:"new-project-input",type:"text",placeholder:"New project",value:c,autoFocus:!0,onChange:T=>d(T.target.value),onKeyDown:T=>{T.key==="Enter"&&q(),T.key==="Escape"&&m(!1)}}),e.jsx("button",{className:"new-project-btn",onClick:q,title:"Create project",children:e.jsx(Se,{size:14})})]}):e.jsxs("button",{className:"project-menu-action",onClick:()=>m(!0),children:[e.jsx(ha,{size:14}),"New project"]})})]})]})]})}function Xl({focusToken:t}){const s=re(),n=i.useRef(null),{searchQuery:a,searchResults:o,searchAllProjects:r,setSearchAllProjects:l,setSearchQuery:c,setSearchResults:d,clearSearch:h,currentProject:m,selectedDocId:u}=Y(),[p,f]=i.useState(a);i.useEffect(()=>{n.current?.focus(),n.current?.select()},[t]);const k=async()=>{if(p.trim()){c(p);try{const N=await(await fetch("/api/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:p,top_k:10,all_projects:r,project:m})})).json();d(N.results||[])}catch{d([])}}},j=()=>{f(""),h(),s(ne(m,null))},g=b=>{b.key==="Enter"&&k(),b.key==="Escape"&&p&&j()};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"search-box",children:[e.jsxs("div",{className:"search-field",children:[e.jsx(nt,{size:14,className:"search-field-icon"}),e.jsx("input",{ref:n,className:"search-input",type:"text",placeholder:"Search documentation",value:p,onChange:b=>f(b.target.value),onKeyDown:g}),p?e.jsx("button",{className:"search-clear-btn",onClick:j,title:"Clear search",children:"✕"}):e.jsx("span",{className:"search-kbd",children:"⌘K"})]}),e.jsxs("div",{className:"segmented",role:"radiogroup","aria-label":"Search scope",children:[e.jsx("button",{role:"radio","aria-checked":!r,className:`segmented-option${r?"":" active"}`,onClick:()=>l(!1),children:"This project"}),e.jsx("button",{role:"radio","aria-checked":r,className:`segmented-option${r?" active":""}`,onClick:()=>l(!0),children:"All projects"})]})]}),a&&o.length===0&&e.jsx("div",{className:"nav-empty",children:"No match."}),o.map(b=>{const N=b.project??m,x=u===b.id&&m===N;return e.jsxs("div",{className:`search-result${x?" active":""}`,onClick:()=>s(ne(N,b.id)),children:[e.jsxs("div",{className:"search-result-head",children:[e.jsx("span",{className:"search-result-title",children:b.title}),e.jsxs("span",{className:"search-result-score",children:[(b.score*100).toFixed(0),"%"]})]}),b.project&&e.jsxs("div",{className:"search-result-meta",children:["Project: ",b.project]}),e.jsxs("div",{className:"search-result-excerpt",children:[b.excerpt.substring(0,80),"..."]})]},`${N}::${b.id}`)})]})}function Ql(t){const s=[],n=new Map;for(const a of t){if(!a.folder){s.push(a);continue}const o=a.folder.split("/").filter(Boolean);let r=n,l="";for(let c=0;c<o.length;c++){const d=o[c];l=l?`${l}/${d}`:d,r.has(d)||r.set(d,{name:d,path:l,children:new Map,docs:[]});const h=r.get(d);c===o.length-1?h.docs.push(a):r=h.children}}return{rootDocs:s,folders:n}}function La(t){let s=t.docs.length;for(const n of t.children.values())s+=La(n);return s}function Ta(t){return t.docs.some(s=>s.isStale)||[...t.children.values()].some(Ta)}function Ma(t,s){return t.docs.some(n=>(s[n.id]?.unread??0)>0)||[...t.children.values()].some(n=>Ma(n,s))}function Ia(){const{commentSummary:t,currentProject:s}=Y();return t.project===s?t.docs:{}}function Aa(t){return[...t.values()].flatMap(s=>[s.path,...Aa(s.children)])}function Zl(t){if(!t)return"";const s=new Date(t),n=a=>String(a).padStart(2,"0");return`${s.getFullYear()}-${n(s.getMonth()+1)}-${n(s.getDate())} ${n(s.getHours())}:${n(s.getMinutes())}`}const es=t=>8+t*16;function bt({doc:t,selectedDocId:s,onSelect:n,depth:a=0,showCreatedAt:o=!1}){const r=Ia()[t.id]?.unread??0;return e.jsxs("div",{className:`tree-row tree-row--doc${s===t.id?" active":""}`,style:{paddingLeft:es(a)+16},onClick:()=>n(t.id),title:t.isStale?`${t.title} — outdated`:t.title,children:[e.jsx(Kn,{size:14,className:"tree-row-icon"}),e.jsx("span",{className:"tree-row-label",children:t.title}),o&&t.createdAt&&e.jsx("span",{className:"tree-row-meta",children:Zl(t.createdAt)}),r>0&&e.jsxs("span",{className:"tree-comments",title:`${r} unread comment${r>1?"s":""}`,children:[e.jsx(ls,{size:11}),r]}),t.isStale&&e.jsx("span",{className:"stale-dot"})]})}function _a({nodes:t,depth:s,selectedDocId:n,onSelect:a,expanded:o,onToggle:r}){const l=Ia();return e.jsx(e.Fragment,{children:[...t.entries()].sort(([c],[d])=>c.localeCompare(d)).map(([,c])=>{const d=!!o[c.path],h=d?Rt:fl,m=d?Dt:Qn;return e.jsxs("div",{children:[e.jsxs("div",{className:"tree-row tree-row--folder",style:{paddingLeft:es(s)},onClick:()=>r(c.path),children:[e.jsx(h,{size:12,className:"tree-row-chevron"}),e.jsx(m,{size:14,className:"tree-row-icon"}),e.jsx("span",{className:"tree-row-label",children:c.name}),Ma(c,l)&&e.jsx("span",{className:"tree-comments",title:"Contains unread comments",children:e.jsx(ls,{size:11})}),Ta(c)&&e.jsx("span",{className:"stale-dot",title:"Contains outdated docs"}),e.jsx("span",{className:"tree-row-count",children:La(c)})]}),d&&e.jsxs("div",{className:"tree-children",style:{"--guide-x":`${es(s)+6}px`},children:[c.docs.map(u=>e.jsx(bt,{doc:u,selectedDocId:n,onSelect:a,depth:s+1},u.id)),e.jsx(_a,{nodes:c.children,depth:s+1,selectedDocId:n,onSelect:a,expanded:o,onToggle:r})]})]},c.path)})})}function ei({mode:t,searchFocusToken:s,onCreateDoc:n,onOpenProjectSettings:a,onClose:o}){const r=re(),{docs:l,selectedDocId:c,currentProject:d,exportBundles:h,readOnly:m}=Y(),[u,p]=i.useState(()=>({project:d,folders:Fs(d)}));u.project!==d&&p({project:d,folders:Fs(d)});const f=u.folders,k=$=>{const L=$(f);Ml(d,L),p({project:d,folders:L})},j=i.useMemo(()=>Ql(l),[l]),g=i.useMemo(()=>l.filter($=>$.isStale),[l]),b=i.useMemo(()=>[...l].sort(($,L)=>{const S=$.createdAt?new Date($.createdAt).getTime():0;return(L.createdAt?new Date(L.createdAt).getTime():0)-S}),[l]),N=l.find($=>$.id===c)?.folder,x=i.useMemo(()=>{const $={};let L="";for(const S of(N??"").split("/").filter(Boolean))L=L?`${L}/${S}`:S,$[L]=!0;return{...$,...f}},[N,f]),v=$=>{r(ne(d,$))},w=$=>{k(L=>({...L,[$]:!x[$]}))},R=()=>{k(()=>Object.fromEntries(Aa(j.folders).map($=>[$,!1])))},E={docs:{title:"Documentation",count:`${l.length} doc${l.length===1?"":"s"}`},search:{title:"Search"},outdated:{title:"Outdated",count:String(g.length)},recent:{title:"Recent",count:String(b.length)},exports:{title:"Export bundles",count:String(h.length)}},y=()=>{switch(t){case"search":return e.jsx(Xl,{focusToken:s});case"exports":return e.jsx(Al,{});case"recent":return b.length===0?e.jsx("div",{className:"nav-empty",children:"No documentation entries yet."}):b.map($=>e.jsx(bt,{doc:$,selectedDocId:c,onSelect:v,showCreatedAt:!0},$.id));case"outdated":return g.length===0?e.jsx("div",{className:"nav-empty",children:"All docs are up to date."}):g.map($=>e.jsx(bt,{doc:$,selectedDocId:c,onSelect:v},$.id));case"docs":return l.length===0?e.jsx("div",{className:"nav-empty",children:"No documentation entries yet."}):e.jsxs(e.Fragment,{children:[e.jsx(_a,{nodes:j.folders,depth:0,selectedDocId:c,onSelect:v,expanded:x,onToggle:w}),j.rootDocs.map($=>e.jsx(bt,{doc:$,selectedDocId:c,onSelect:v},$.id))]})}};return e.jsxs("div",{className:"nav-panel",children:[e.jsxs("div",{className:"nav-panel-project",children:[e.jsx(Da,{variant:"card",onOpenSettings:a}),!m&&e.jsx("button",{className:"nav-panel-new",onClick:n,title:"Create a new document manually",children:e.jsx(ha,{size:16})})]}),e.jsxs("div",{className:"nav-panel-heading",children:[e.jsx("span",{className:"nav-panel-title",children:E[t].title}),E[t].count&&e.jsx("span",{className:"nav-panel-count",children:E[t].count}),t==="docs"&&e.jsx("button",{className:"nav-panel-tool",onClick:R,title:"Collapse all folders",children:e.jsx(gl,{size:15})}),e.jsx("button",{className:"nav-panel-tool",onClick:o,title:"Hide panel",children:e.jsx(Rl,{size:15})})]}),e.jsx("div",{className:"nav-panel-scroll",children:y()})]})}function ti({report:t,trackedFiles:s,onViewCode:n}){if(t.status==="no_tracking")return e.jsx("p",{className:"file-status-view",style:{color:"#8b949e",fontSize:13},children:"No tracked files for this entry."});const a=l=>t.modified.includes(l)?"modified":t.missing.includes(l)?"missing":(t.anchors_lost??[]).includes(l)?"anchors_lost":"ok",o=l=>!!l.sections?.length&&!(t.anchors_lost??[]).includes(l.path),r=l=>{switch(l){case"ok":return e.jsx("span",{className:"status-ok",children:"✓"});case"modified":return e.jsx("span",{className:"status-modified",children:"⚠ Modified"});case"missing":return e.jsx("span",{className:"status-missing",children:"✕ Missing"});case"anchors_lost":return e.jsx("span",{className:"status-anchors-lost",children:"⚠ Anchors lost"});default:return null}};return e.jsxs("div",{className:"file-status-view",style:{marginBottom:16},children:[e.jsxs("h3",{style:{fontSize:14,color:"#8b949e",margin:"0 0 8px 0"},children:["Tracked Files — ",t.status==="stale"?"Stale":"Up to date"]}),e.jsxs("table",{className:"file-status-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"File"}),e.jsx("th",{children:"Snapshot Date"}),e.jsx("th",{children:"Status"})]})}),e.jsx("tbody",{children:s.map(l=>{const c=a(l.path);return e.jsxs("tr",{onClick:o(l)?()=>n(l.path):void 0,className:o(l)?"file-row file-row--clickable":"file-row",title:o(l)?"Cliquer pour voir le code de la section":void 0,children:[e.jsxs("td",{children:[l.path,o(l)&&e.jsx("span",{className:"file-row-code-hint",children:" 〈/〉"})]}),e.jsx("td",{children:new Date(l.lastModifiedAt).toLocaleString()}),e.jsx("td",{children:r(c)})]},l.path)})})]})]})}function si(t){return t.startsWith("+++ ")||t.startsWith("--- ")||t.startsWith("diff ")||t.startsWith("index ")?"file-header":t.startsWith("@@")?"hunk":t.startsWith("+")?"added":t.startsWith("-")?"removed":t.startsWith("###")?"section-title":t==="---"?"separator":"context"}function ni(t){return t.split(`
4
+ `).map(s=>({type:si(s),content:s}))}function ai({diffText:t}){const s=ni(t);return e.jsx("div",{className:"diff-viewer",children:e.jsx("pre",{className:"diff-pre",children:s.map((n,a)=>e.jsx("div",{className:`diff-line diff-line--${n.type}`,children:e.jsx("span",{className:"diff-line-content",children:n.content||" "})},a))})})}class oi{diff(s,n,a={}){let o;typeof a=="function"?(o=a,a={}):"callback"in a&&(o=a.callback);const r=this.castInput(s,a),l=this.castInput(n,a),c=this.removeEmpty(this.tokenize(r,a)),d=this.removeEmpty(this.tokenize(l,a));return this.diffWithOptionsObj(c,d,a,o)}diffWithOptionsObj(s,n,a,o){var r;const l=N=>{if(N=this.postProcess(N,a),o){setTimeout(function(){o(N)},0);return}else return N},c=n.length,d=s.length;let h=1,m=c+d;a.maxEditLength!=null&&(m=Math.min(m,a.maxEditLength));const u=(r=a.timeout)!==null&&r!==void 0?r:1/0,p=Date.now()+u,f=[{oldPos:-1,lastComponent:void 0}];let k=this.extractCommon(f[0],n,s,0,a);if(f[0].oldPos+1>=d&&k+1>=c)return l(this.buildValues(f[0].lastComponent,n,s));let j=-1/0,g=1/0;const b=()=>{for(let N=Math.max(j,-h);N<=Math.min(g,h);N+=2){let x;const v=f[N-1],w=f[N+1];v&&(f[N-1]=void 0);let R=!1;if(w){const y=w.oldPos-N;R=w&&0<=y&&y<c}const E=v&&v.oldPos+1<d;if(!R&&!E){f[N]=void 0;continue}if(!E||R&&v.oldPos<w.oldPos?x=this.addToPath(w,!0,!1,0,a):x=this.addToPath(v,!1,!0,1,a),k=this.extractCommon(x,n,s,N,a),x.oldPos+1>=d&&k+1>=c)return l(this.buildValues(x.lastComponent,n,s))||!0;f[N]=x,x.oldPos+1>=d&&(g=Math.min(g,N-1)),k+1>=c&&(j=Math.max(j,N+1))}h++};if(o)(function N(){setTimeout(function(){if(h>m||Date.now()>p)return o(void 0);b()||N()},0)})();else for(;h<=m&&Date.now()<=p;){const N=b();if(N)return N}}addToPath(s,n,a,o,r){const l=s.lastComponent;return l&&!r.oneChangePerToken&&l.added===n&&l.removed===a?{oldPos:s.oldPos+o,lastComponent:{count:l.count+1,added:n,removed:a,previousComponent:l.previousComponent}}:{oldPos:s.oldPos+o,lastComponent:{count:1,added:n,removed:a,previousComponent:l}}}extractCommon(s,n,a,o,r){const l=n.length,c=a.length;let d=s.oldPos,h=d-o,m=0;for(;h+1<l&&d+1<c&&this.equals(a[d+1],n[h+1],r);)h++,d++,m++,r.oneChangePerToken&&(s.lastComponent={count:1,previousComponent:s.lastComponent,added:!1,removed:!1});return m&&!r.oneChangePerToken&&(s.lastComponent={count:m,previousComponent:s.lastComponent,added:!1,removed:!1}),s.oldPos=d,h}equals(s,n,a){return a.comparator?a.comparator(s,n):s===n||!!a.ignoreCase&&s.toLowerCase()===n.toLowerCase()}removeEmpty(s){const n=[];for(let a=0;a<s.length;a++)s[a]&&n.push(s[a]);return n}castInput(s,n){return s}tokenize(s,n){return Array.from(s)}join(s){return s.join("")}postProcess(s,n){return s}get useLongestToken(){return!1}buildValues(s,n,a){const o=[];let r;for(;s;)o.push(s),r=s.previousComponent,delete s.previousComponent,s=r;o.reverse();const l=o.length;let c=0,d=0,h=0;for(;c<l;c++){const m=o[c];if(m.removed)m.value=this.join(a.slice(h,h+m.count)),h+=m.count;else{if(!m.added&&this.useLongestToken){let u=n.slice(d,d+m.count);u=u.map(function(p,f){const k=a[h+f];return k.length>p.length?k:p}),m.value=this.join(u)}else m.value=this.join(n.slice(d,d+m.count));d+=m.count,m.added||(h+=m.count)}}return o}}function Bs(t,s){let n;for(n=0;n<t.length&&n<s.length;n++)if(t[n]!=s[n])return t.slice(0,n);return t.slice(0,n)}function Ws(t,s){let n;if(!t||!s||t[t.length-1]!=s[s.length-1])return"";for(n=0;n<t.length&&n<s.length;n++)if(t[t.length-(n+1)]!=s[s.length-(n+1)])return t.slice(-n);return t.slice(-n)}function ts(t,s,n){if(t.slice(0,s.length)!=s)throw Error(`string ${JSON.stringify(t)} doesn't start with prefix ${JSON.stringify(s)}; this is a bug`);return n+t.slice(s.length)}function ss(t,s,n){if(!s)return t+n;if(t.slice(-s.length)!=s)throw Error(`string ${JSON.stringify(t)} doesn't end with suffix ${JSON.stringify(s)}; this is a bug`);return t.slice(0,-s.length)+n}function Ke(t,s){return ts(t,s,"")}function ht(t,s){return ss(t,s,"")}function Vs(t,s){return s.slice(0,ri(t,s))}function ri(t,s){let n=0;t.length>s.length&&(n=t.length-s.length);let a=s.length;t.length<s.length&&(a=t.length);const o=Array(a);let r=0;o[0]=0;for(let l=1;l<a;l++){for(s[l]==s[r]?o[l]=o[r]:o[l]=r;r>0&&s[l]!=s[r];)r=o[r];s[l]==s[r]&&r++}r=0;for(let l=n;l<t.length;l++){for(;r>0&&t[l]!=s[r];)r=o[r];t[l]==s[r]&&r++}return r}function za(t,s){const n=[];for(const a of Array.from(s.segment(t))){const o=a.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(o)?n[n.length-1]+=o:n.push(o)}return n}function ns(t,s){if(s)return Ye(t,s)[1];let n;for(n=t.length-1;n>=0&&t[n].match(/\s/);n--);return t.substring(n+1)}function Ie(t,s){if(s)return Ye(t,s)[0];const n=t.match(/^\s*/);return n?n[0]:""}function Ye(t,s){if(!s)return[Ie(t),ns(t)];if(s.resolvedOptions().granularity!="word")throw new Error('The segmenter passed must have a granularity of "word"');const n=za(t,s),a=n[0],o=n[n.length-1],r=/\s/.test(a)?a:"",l=/\s/.test(o)?o:"";return[r,l]}const qs="a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}",li=new RegExp(`[${qs}]+|\\s+|[^${qs}]`,"ug");class ii extends oi{equals(s,n,a){return a.ignoreCase&&(s=s.toLowerCase(),n=n.toLowerCase()),s.trim()===n.trim()}tokenize(s,n={}){let a;if(n.intlSegmenter){const l=n.intlSegmenter;if(l.resolvedOptions().granularity!="word")throw new Error('The segmenter passed must have a granularity of "word"');a=za(s,l)}else a=s.match(li)||[];const o=[];let r=null;return a.forEach(l=>{/\s/.test(l)?r==null?o.push(l):o.push(o.pop()+l):r!=null&&/\s/.test(r)?o[o.length-1]==r?o.push(o.pop()+l):o.push(r+l):o.push(l),r=l}),o}join(s){return s.map((n,a)=>a==0?n:n.replace(/^\s+/,"")).join("")}postProcess(s,n){if(!s||n.oneChangePerToken)return s;let a=null,o=null,r=null;return s.forEach(l=>{l.added?o=l:l.removed?r=l:((o||r)&&Gs(a,r,o,l,n.intlSegmenter),a=l,o=null,r=null)}),(o||r)&&Gs(a,r,o,null,n.intlSegmenter),s}}const ci=new ii;function di(t,s,n){return ci.diff(t,s,n)}function Gs(t,s,n,a,o){if(s&&n){const[r,l]=Ye(s.value,o),[c,d]=Ye(n.value,o);if(t){const h=Bs(r,c);t.value=ss(t.value,c,h),s.value=Ke(s.value,h),n.value=Ke(n.value,h)}if(a){const h=Ws(l,d);a.value=ts(a.value,d,h),s.value=ht(s.value,h),n.value=ht(n.value,h)}}else if(n){if(t){const r=Ie(n.value,o);n.value=n.value.substring(r.length)}if(a){const r=Ie(a.value,o);a.value=a.value.substring(r.length)}}else if(t&&a){const r=Ie(a.value,o),[l,c]=Ye(s.value,o),d=Bs(r,l);s.value=Ke(s.value,d);const h=Ws(Ke(r,d),c);s.value=ht(s.value,h),a.value=ts(a.value,r,h),t.value=ss(t.value,r,r.slice(0,r.length-h.length))}else if(a){const r=Ie(a.value,o),l=ns(s.value,o),c=Vs(l,r);s.value=ht(s.value,c)}else if(t){const r=ns(t.value,o),l=Ie(s.value,o),c=Vs(r,l);s.value=Ke(s.value,c)}}const Gt={create:"Created",update:"Updated",patch:"Patched",delete:"Deleted",snapshot:"Snapshot"},Kt={create:"➕",update:"📝",patch:"🩹",delete:"🗑️",snapshot:"📸"};function ui(t,s){const n={};t.title!==s.title&&(n.title={from:t.title,to:s.title});const a=s.tags.filter(f=>!t.tags.includes(f)),o=t.tags.filter(f=>!s.tags.includes(f));(a.length||o.length)&&(n.tags={added:a,removed:o});const r=t.tracked_files.map(f=>f.path),l=s.tracked_files.map(f=>f.path),c=l.filter(f=>!r.includes(f)),d=r.filter(f=>!l.includes(f));(c.length||d.length)&&(n.tracked_files={added:c,removed:d});const h=t.related_docs??[],m=s.related_docs??[],u=m.filter(f=>!h.includes(f)),p=h.filter(f=>!m.includes(f));return(u.length||p.length)&&(n.related_docs={added:u,removed:p}),n}function hi({diff:t}){return e.jsxs("div",{className:"history-meta-diff",children:[e.jsx("span",{className:"history-meta-diff-title",children:"Metadata changes"}),t.title&&e.jsxs("div",{className:"history-meta-diff-row",children:[e.jsx("span",{className:"history-meta-diff-field",children:"Title"}),e.jsx("span",{className:"history-meta-diff-chip--removed",children:t.title.from}),e.jsx("span",{className:"history-meta-diff-arrow",children:"→"}),e.jsx("span",{className:"history-meta-diff-chip--added",children:t.title.to})]}),t.tags&&e.jsxs("div",{className:"history-meta-diff-row",children:[e.jsx("span",{className:"history-meta-diff-field",children:"Tags"}),e.jsxs("div",{className:"history-meta-diff-chips",children:[t.tags.removed.map(s=>e.jsxs("span",{className:"history-meta-diff-chip--removed",children:["− ",s]},s)),t.tags.added.map(s=>e.jsxs("span",{className:"history-meta-diff-chip--added",children:["+ ",s]},s))]})]}),t.tracked_files&&e.jsxs("div",{className:"history-meta-diff-row",children:[e.jsx("span",{className:"history-meta-diff-field",children:"Tracked files"}),e.jsxs("div",{className:"history-meta-diff-chips",children:[t.tracked_files.removed.map(s=>e.jsxs("span",{className:"history-meta-diff-chip--removed",children:["− ",s]},s)),t.tracked_files.added.map(s=>e.jsxs("span",{className:"history-meta-diff-chip--added",children:["+ ",s]},s))]})]}),t.related_docs&&e.jsxs("div",{className:"history-meta-diff-row",children:[e.jsx("span",{className:"history-meta-diff-field",children:"Related docs"}),e.jsxs("div",{className:"history-meta-diff-chips",children:[t.related_docs.removed.map(s=>e.jsxs("span",{className:"history-meta-diff-chip--removed",children:["− ",s]},s)),t.related_docs.added.map(s=>e.jsxs("span",{className:"history-meta-diff-chip--added",children:["+ ",s]},s))]})]})]})}function mi({changes:t}){return e.jsx("div",{className:"history-inline-diff",children:t.map((s,n)=>s.added?e.jsx("span",{className:"history-inline-diff--added",children:s.value},n):s.removed?e.jsx("span",{className:"history-inline-diff--removed",children:s.value},n):e.jsx("span",{children:s.value},n))})}function pi(t){const s=[],n=[];let a=null;for(const o of t)o.changeType==="snapshot"?(a={snapshot:o,subEntries:[]},n.push(a)):a===null?s.push(o):a.subEntries.push(o);return{uncommitted:s,groups:n}}function fi({docId:t,project:s,entries:n,selectedVersion:a,onSelectVersion:o,markdownComponents:r}){const[l,c]=i.useState(null),[d,h]=i.useState(!1),[m,u]=i.useState(new Set),{uncommitted:p,groups:f}=i.useMemo(()=>pi(n),[n]),k=v=>{u(w=>{const R=new Set(w);return R.has(v)?R.delete(v):R.add(v),R})},j=a!==null&&(a.changeType==="update"||a.changeType==="patch"||a.changeType==="snapshot")&&a.version>1,g=(()=>{if(!a||!j)return null;if(a.changeType==="snapshot"){const v=n.filter(w=>w.version<a.version&&w.changeType==="snapshot").sort((w,R)=>R.version-w.version);return v.length>0?v[0].version:Math.min(...n.map(w=>w.version))}return a.version-1})(),b=g!==null?n.find(v=>v.version===g)??null:null,N=b?ui(b.metadata,a.metadata):null,x=N&&Object.keys(N).length>0;return i.useEffect(()=>{if(c(null),!a||!j||g===null)return;let v=!1;return h(!0),fetch(`/api/history-version/${xe(t)}/${g}?project=${encodeURIComponent(s)}`).then(w=>w.json()).then(w=>{if(v)return;const R=w?.content??"",E=a.content??"";c(di(R,E))}).catch(()=>{v||c([])}).finally(()=>{v||h(!1)}),()=>{v=!0}},[a?.version]),n.length===0?e.jsx("div",{className:"history-viewer",children:e.jsx("div",{className:"doc-viewer-empty",children:"No version history available for this document."})}):e.jsxs("div",{className:"history-viewer",children:[e.jsxs("div",{className:"history-list",children:[p.length>0&&e.jsxs("div",{className:"history-uncommitted",children:[e.jsx("span",{className:"history-uncommitted-label",children:"Non archivé"}),p.map(v=>{const w=a?.version===v.version,R=new Date(v.changedAt).toLocaleString(),E=Gt[v.changeType]??v.changeType,y=Kt[v.changeType]??"❓";return e.jsxs("button",{className:`history-entry history-entry--sub${w?" history-entry--active":""}`,onClick:()=>o(v.version),children:[e.jsxs("div",{className:"history-entry-header",children:[e.jsxs("span",{className:"history-entry-version",children:["v",v.version]}),e.jsxs("span",{className:`history-entry-type history-entry-type--${v.changeType}`,children:[y," ",E]})]}),e.jsx("span",{className:"history-entry-date",children:R})]},v.version)})]}),f.length===0&&p.length===0&&e.jsx("div",{className:"doc-viewer-empty",children:"No version history available."}),f.map(v=>{const w=a?.version===v.snapshot.version,R=m.has(v.snapshot.version),E=new Date(v.snapshot.changedAt).toLocaleString();return e.jsxs("div",{className:"history-group",children:[e.jsx("div",{className:`history-entry history-entry--snapshot-card${w?" history-entry--active":""}`,children:e.jsxs("button",{className:"history-entry-snapshot-main",onClick:()=>o(v.snapshot.version),children:[e.jsxs("div",{className:"history-entry-header",children:[e.jsxs("span",{className:"history-entry-version",children:["Version ",v.snapshot.version]}),e.jsx("span",{className:"history-entry-type history-entry-type--snapshot",children:"📸 Snapshot"})]}),e.jsxs("div",{className:"history-entry-footer",children:[e.jsx("span",{className:"history-entry-date",children:E}),v.subEntries.length>0&&e.jsx("span",{className:`history-group-toggle${R?" history-group-toggle--open":""}`,onClick:y=>{y.stopPropagation(),k(v.snapshot.version)},role:"button",tabIndex:0,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.stopPropagation(),k(v.snapshot.version))},children:R?"Masquer ▲":`Voir les ${v.subEntries.length} modification${v.subEntries.length>1?"s":""} ▼`})]})]})}),R&&e.jsx("div",{className:"history-group-entries",children:v.subEntries.map(y=>{const $=a?.version===y.version,L=new Date(y.changedAt).toLocaleString(),S=Gt[y.changeType]??y.changeType,I=Kt[y.changeType]??"❓";return e.jsxs("button",{className:`history-entry history-entry--sub${$?" history-entry--active":""}`,onClick:()=>o(y.version),children:[e.jsxs("div",{className:"history-entry-header",children:[e.jsxs("span",{className:"history-entry-version",children:["v",y.version]}),e.jsxs("span",{className:`history-entry-type history-entry-type--${y.changeType}`,children:[I," ",S]})]}),e.jsx("span",{className:"history-entry-date",children:L})]},y.version)})})]},v.snapshot.version)})]}),e.jsx("div",{className:"history-content",children:a?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"history-content-meta",children:[e.jsxs("div",{className:"history-content-meta-title",children:[e.jsx("strong",{children:a.metadata.title}),e.jsxs("span",{className:"history-content-version",children:["Version ",a.version]})]}),e.jsxs("div",{className:"history-content-meta-info",children:[e.jsxs("span",{className:`history-entry-type history-entry-type--${a.changeType}`,children:[Kt[a.changeType]??"❓"," ",Gt[a.changeType]??a.changeType]}),e.jsx("span",{className:"history-content-date",children:new Date(a.changedAt).toLocaleString()}),j&&d&&e.jsx("span",{className:"history-diff-loading",children:"Loading diff…"}),j&&!d&&g!==null&&e.jsxs("span",{className:"history-diff-base",children:["vs v",g]})]}),x&&e.jsx(hi,{diff:N})]}),j&&a.changeType==="snapshot"&&!d&&l!==null&&e.jsxs("div",{className:"history-diff-recap-banner",children:["Récapitulatif des modifications effectuées depuis le dernier évènement ",e.jsx("strong",{children:"snapshot"})]}),j?l!==null?e.jsx(mi,{changes:l}):null:e.jsx("div",{className:"doc-content",children:e.jsx(tn,{remarkPlugins:[nn],rehypePlugins:[sn],components:r,children:a.content??""})})]}):e.jsx("div",{className:"doc-viewer-empty",children:"Select a version to view its content."})})]})}const gi={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",py:"python",rb:"ruby",go:"go",java:"java",rs:"rust",cs:"csharp",cpp:"cpp",c:"c",sh:"bash",bash:"bash",zsh:"bash",json:"json",yaml:"yaml",yml:"yaml",toml:"toml",md:"markdown",css:"css",scss:"scss",html:"html",xml:"xml",sql:"sql"};function xi(t){const s=t.split(".").pop()?.toLowerCase()??"";return gi[s]??"text"}function vi({docId:t,project:s,filePath:n,onClose:a}){const[o,r]=i.useState([]),[l,c]=i.useState(!0),[d,h]=i.useState(null);i.useEffect(()=>{const u=new AbortController,p=n.split("/").map(encodeURIComponent).join("/");return fetch(`/api/file-section/${p}?docId=${encodeURIComponent(t)}&project=${encodeURIComponent(s)}`,{signal:u.signal}).then(f=>f.json()).then(f=>{if(f.error)throw new Error(f.error);r(f.sections??[])}).catch(f=>{f.name!=="AbortError"&&h(f.message)}).finally(()=>c(!1)),()=>u.abort()},[t,n]),i.useEffect(()=>{const u=p=>{p.key==="Escape"&&a()};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[a]);const m=xi(n);return e.jsx("div",{className:"modal-overlay",onClick:a,children:e.jsxs("div",{className:"modal-content",onClick:u=>u.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("span",{className:"modal-title",children:n}),e.jsx("button",{className:"modal-close-btn",onClick:a,children:"✕"})]}),e.jsxs("div",{className:"modal-body",children:[l&&e.jsx("p",{style:{color:"#8b949e",fontSize:13},children:"Loading…"}),d&&e.jsx("p",{style:{color:"#f85149",fontSize:13},children:d}),!l&&!d&&o.map((u,p)=>e.jsxs("div",{children:[e.jsxs("p",{className:"section-code-header",children:["Lines ",u.start,"–",u.end]}),e.jsx(wo,{language:m,style:Co,customStyle:{margin:0,borderRadius:"6px",fontSize:"13px"},codeTagProps:{style:{fontFamily:"'Fira Code', 'Cascadia Code', Consolas, monospace"}},showLineNumbers:!0,startingLineNumber:u.start,children:u.code})]},p))]})]})})}function ji({project:t,triggerRef:s,onInsert:n,onClose:a}){const[o,r]=i.useState("upload"),[l,c]=i.useState(""),[d,h]=i.useState(""),[m,u]=i.useState(!1),[p,f]=i.useState(null),[k,j]=i.useState([]),[g,b]=i.useState({visibility:"hidden"}),N=i.useRef(null);i.useLayoutEffect(()=>{const E=N.current;if(!E)return;const y=E.offsetHeight,$=360;b({position:"fixed",top:Math.max(8,(window.innerHeight-y)/2),left:Math.max(8,(window.innerWidth-$)/2),width:$,visibility:"visible"})},[s]),i.useEffect(()=>{fetch(`/api/images/${encodeURIComponent(t)}`).then(E=>E.json()).then(E=>j(E)).catch(()=>{})},[t]),i.useEffect(()=>{function E(y){N.current&&!N.current.contains(y.target)&&s.current!==y.target&&a()}return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[a,s]);const x=i.useCallback(async E=>{u(!0),f(null);try{const y=new FormData;y.append("file",E);const $=await fetch(`/api/images?project=${encodeURIComponent(t)}`,{method:"POST",body:y});if(!$.ok){const S=await $.json().catch(()=>({}));throw new Error(S.error??"Upload failed")}const{url:L}=await $.json();n(`![${l}](${L})`),a()}catch(y){f(y instanceof Error?y.message:"Upload failed")}finally{u(!1)}},[t,l,n,a]),v=async E=>{const y=E.target.files?.[0];y&&await x(y)};i.useEffect(()=>{const E=async y=>{const L=Array.from(y.clipboardData?.items??[]).find(X=>X.type.startsWith("image/"));if(!L)return;y.preventDefault();const S=L.getAsFile();if(!S)return;const I=S.type.split("/")[1]??"png",z=new File([S],`paste-${Date.now()}.${I}`,{type:S.type});await x(z)};return document.addEventListener("paste",E),()=>document.removeEventListener("paste",E)},[x]);const w=()=>{d.trim()&&(n(`![${l}](${d.trim()})`),a())},R=E=>{n(`![${l}](${E})`),a()};return ml.createPortal(e.jsxs("div",{className:"image-insert-popover",ref:N,style:g,children:[e.jsxs("div",{className:"image-insert-header",children:[e.jsx("span",{className:"image-insert-title",children:"Insert image"}),e.jsx("button",{className:"image-insert-close",onClick:a,title:"Close",children:"✕"})]}),e.jsxs("div",{className:"image-insert-tabs",children:[e.jsx("button",{className:`image-insert-tab${o==="upload"?" active":""}`,onClick:()=>r("upload"),children:"Upload"}),e.jsx("button",{className:`image-insert-tab${o==="url"?" active":""}`,onClick:()=>r("url"),children:"URL"})]}),e.jsxs("div",{className:"image-insert-alt-row",children:[e.jsx("label",{className:"image-insert-label",children:"Alt text"}),e.jsx("input",{className:"image-insert-input",type:"text",placeholder:"Description (optional)",value:l,onChange:E=>c(E.target.value)})]}),o==="upload"?e.jsxs("div",{className:"image-insert-tab-content",children:[e.jsxs("label",{className:`image-upload-label${m?" uploading":""}`,children:[e.jsx("input",{type:"file",accept:"image/*",style:{display:"none"},onChange:v,disabled:m}),m?"⏳ Uploading…":"📁 Choose a file"]}),e.jsx("p",{className:"image-paste-hint",children:"or press Ctrl+V / ⌘V to paste from clipboard"}),p&&e.jsx("div",{className:"image-insert-error",children:p})]}):e.jsxs("div",{className:"image-insert-tab-content",children:[e.jsx("input",{className:"image-insert-input",type:"text",placeholder:"https://example.com/image.png",value:d,onChange:E=>h(E.target.value),onKeyDown:E=>E.key==="Enter"&&w()}),e.jsx("button",{className:"image-insert-btn-insert",onClick:w,disabled:!d.trim(),children:"Insert"})]}),k.length>0&&e.jsxs("div",{className:"image-insert-gallery-section",children:[e.jsx("div",{className:"image-insert-gallery-label",children:"Project images"}),e.jsx("div",{className:"image-thumbs",children:k.map(E=>e.jsx("img",{src:E.url,alt:E.filename,className:"image-thumb",title:E.filename,onClick:()=>R(E.url)},E.filename))})]})]}),document.body)}function Ks(t,s){return!t||t.status==="no_tracking"?"unknown":t.modified.includes(s)?"modified":t.missing.includes(s)?"missing":(t.anchors_lost??[]).includes(s)?"anchors_lost":t.unchanged.includes(s)?"ok":"unknown"}function bi(t){if(!t)return"—";const s=new Date(t);if(Number.isNaN(s.getTime()))return"—";const n=a=>String(a).padStart(2,"0");return`${s.toLocaleDateString(void 0,{month:"short",day:"numeric"})}, ${n(s.getHours())}:${n(s.getMinutes())}`}function yi({doc:t,isStale:s,report:n,toc:a,activeHeadingId:o,version:r,onSelectHeading:l,onSelectFile:c,onClose:d,tab:h,onTab:m,comments:u,unreadComments:p}){const f=re(),{docs:k,projects:j,currentProject:g}=Y(),b=x=>!!t.tracked_files.find(w=>w.path===x)?.sections?.length&&Ks(n,x)!=="anchors_lost",N=u!==null&&h==="comments";return e.jsxs("aside",{className:"context-rail",children:[e.jsxs("div",{className:"rail-section rail-section--toc",children:[e.jsxs("div",{className:"rail-section-head",children:[u!==null?e.jsxs("div",{className:"rail-tabs",children:[e.jsx("button",{type:"button",className:`rail-tab${N?"":" active"}`,onClick:()=>m("page"),children:"On this page"}),e.jsxs("button",{type:"button",className:`rail-tab${N?" active":""}`,onClick:()=>m("comments"),children:["Comments",p>0&&e.jsx("span",{className:"rail-tab-count",children:p})]})]}):e.jsx("span",{className:"rail-label",children:a.length>0?"On this page":""}),e.jsx("button",{className:"rail-collapse-btn",onClick:d,title:"Hide details (Ctrl/⌘ + \\)",children:"▷|"})]}),N&&u,!N&&a.length>0&&e.jsx("nav",{className:"rail-toc",children:a.map(x=>e.jsx("button",{className:`rail-toc-item rail-toc-item--h${x.level}${o===x.id?" active":""}`,onClick:()=>l(x.id),children:x.text},x.id))})]}),!N&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rail-section",children:[e.jsx("span",{className:"rail-label",children:"Status"}),e.jsxs("div",{className:"rail-row",children:[e.jsx("span",{className:"rail-key",children:"Freshness"}),e.jsx("span",{className:`rail-chip${s?" rail-chip--stale":" rail-chip--fresh"}`,children:s?"Outdated":"Up to date"})]}),e.jsxs("div",{className:"rail-row",children:[e.jsx("span",{className:"rail-key",children:"Last updated"}),e.jsx("span",{className:"rail-val",children:bi(t.updatedAt)})]}),e.jsxs("div",{className:"rail-row",children:[e.jsx("span",{className:"rail-key",children:"Version"}),e.jsx("span",{className:"rail-val",children:r!==null?`v${r}`:"—"})]})]}),t.tracked_files.length>0&&e.jsxs("div",{className:"rail-section",children:[e.jsxs("span",{className:"rail-label",children:["Tracked files · ",t.tracked_files.length]}),e.jsx("div",{className:"rail-files",children:t.tracked_files.map(x=>{const v=Ks(n,x.path),w=b(x.path);return e.jsxs("button",{className:`rail-file${w?" rail-file--clickable":""}`,onClick:w?()=>c(x.path):void 0,title:w?`${x.path} — voir le code de la section`:x.path,children:[e.jsx("span",{className:`rail-file-dot rail-file-dot--${v}`}),e.jsx("span",{className:"rail-file-path",children:x.path})]},x.path)})}),e.jsx("div",{className:"rail-legend",children:"modified · up to date · missing · anchors lost"})]}),t.tags.length>0&&e.jsxs("div",{className:"rail-section",children:[e.jsx("span",{className:"rail-label",children:"Tags"}),e.jsx("div",{className:"rail-tags",children:t.tags.map(x=>e.jsx("span",{className:"tag-badge",children:x},x))})]}),t.related_docs&&t.related_docs.length>0&&e.jsxs("div",{className:"rail-section",children:[e.jsx("span",{className:"rail-label",children:"Related pages"}),e.jsx("div",{className:"rail-links",children:t.related_docs.map(x=>{const v=x.indexOf(":");if(v!==-1){const R=x.slice(0,v),E=x.slice(v+1);return j.includes(R)?e.jsxs("button",{className:"rail-link rail-link--cross-project",onClick:()=>f(ne(R,E)),title:`Projet : ${R}`,children:["↗ ",R," · ",E]},x):e.jsxs("span",{className:"rail-link rail-link--broken",children:[x," (projet introuvable)"]},x)}const w=k.find(R=>R.id===x);return w?e.jsxs("button",{className:"rail-link",onClick:()=>f(ne(g,x)),children:["▤ ",w.title]},x):e.jsxs("span",{className:"rail-link rail-link--broken",children:[x," (lien cassé)"]},x)})})]})]})]})}function Jt(t){return!t.root.read||t.replies.some(s=>!s.read)}function Ni(t){return[t.root.id,...t.replies.map(s=>s.id)]}function mt(t){return t===null?"an unversioned publication":`v${t}`}function wi({data:t,locatedIds:s,activeId:n,hoveredId:a,readOnly:o,onActivate:r,onHover:l}){const c=ko(t.comments),d=c.filter(y=>!y.root.detached),h=c.filter(y=>y.root.detached),m=t.comments.filter(y=>!y.read).length,[u,p]=i.useState(m>0?"unread":"all"),[f,k]=i.useState(null),[j,g]=i.useState(!1),[b,N]=i.useState(null),x=t.publication?.id,v=t.publication?.commentsClosed===!0;if(!x)return e.jsx("div",{className:"cp-empty",children:"This document is not published: readers cannot comment on it."});const w=async y=>{g(!0),N(null);try{await y()}catch($){N($ instanceof Error?$.message:String($))}finally{g(!1)}},R=u==="unread"?d.filter(Jt):d,E=(y,$)=>{const{root:L}=y,S=Jt(y),I=s.has(L.id);return e.jsxs("div",{className:`cp-card${S?" cp-card--unread":""}${$?" cp-card--detached":""}${n===L.id||a===L.id?" cp-card--active":""}`,onClick:()=>r(L.id),onMouseEnter:()=>l(L.id),onMouseLeave:()=>l(null),children:[e.jsxs("div",{className:"cp-head",children:[$?e.jsx(vs,{size:12,className:"cp-state cp-state--detached"}):S?e.jsx("span",{className:"cp-dot",title:"Unread"}):e.jsx(Se,{size:12,className:"cp-state cp-state--read"}),e.jsx("span",{className:"cp-author",title:Es,children:$s(L.author)}),e.jsxs("span",{className:"cp-time",title:new Date(L.createdAt).toLocaleString(),children:["· ",Rs(L.createdAt)]}),!o&&e.jsxs("span",{className:"cp-actions",onClick:z=>z.stopPropagation(),children:[S&&e.jsx("button",{type:"button",className:"cp-icon",title:"Mark as read",disabled:j,onClick:()=>w(()=>Ps(x,Ni(y))),children:e.jsx(Se,{size:14})}),e.jsx("button",{type:"button",className:"cp-icon cp-icon--danger",title:"Delete",disabled:j,onClick:()=>k(L.id),children:e.jsx(Dl,{size:14})})]})]}),L.anchor&&e.jsxs("div",{className:`cp-quote${I||$?"":" cp-quote--lost"}`,children:["« ",L.anchor.exact," »",$&&L.detached?` — ${mt(L.detached.fromVersion)}`:""]}),!$&&!I&&e.jsx("div",{className:"cp-note",children:"Passage changed since the publication: not highlighted here."}),e.jsx("div",{className:"cp-body",children:L.body}),y.replies.map(z=>e.jsxs("div",{className:`cp-reply${z.read?"":" cp-reply--unread"}`,children:[e.jsxs("div",{className:"cp-reply-head",children:[e.jsx("span",{title:Es,children:$s(z.author)})," · ",Rs(z.createdAt)]}),e.jsx("div",{className:"cp-body",children:z.body})]},z.id)),$&&L.detached&&e.jsxs("div",{className:"cp-note",children:["Detached when the publication went from ",mt(L.detached.fromVersion)," to"," ",mt(L.detached.toVersion)]}),f===L.id&&e.jsxs("div",{className:"cp-confirm",onClick:z=>z.stopPropagation(),children:[e.jsxs("span",{children:["Delete this comment",y.replies.length>0?` and its ${y.replies.length} replies`:"","?"]}),e.jsx("button",{type:"button",className:"cp-confirm-btn",onClick:()=>k(null),disabled:j,children:"Cancel"}),e.jsx("button",{type:"button",className:"cp-confirm-btn cp-confirm-btn--danger",disabled:j,onClick:()=>w(async()=>{await So(x,[L.id]),k(null)}),children:"Delete"})]})]},L.id)};return e.jsxs("div",{className:"cp",children:[e.jsxs("div",{className:"cp-toolbar",children:[e.jsxs("button",{type:"button",className:`cp-filter${u==="unread"?" active":""}`,onClick:()=>p("unread"),children:["Unread · ",c.filter(Jt).length]}),e.jsxs("button",{type:"button",className:`cp-filter${u==="all"?" active":""}`,onClick:()=>p("all"),children:["All · ",d.length]}),!o&&m>0&&e.jsx("button",{type:"button",className:"cp-mark-all",disabled:j,onClick:()=>w(()=>Ps(x,null)),children:"Mark all as read"})]}),e.jsxs("div",{className:"cp-usage",children:[e.jsxs("span",{children:[t.comments.length," / ",t.limit," comments on the published ",mt(t.publication?.version??null),v&&" · closed to new comments"]}),!o&&e.jsx("button",{type:"button",className:"cp-close-toggle",disabled:j,title:v?"Let readers add comments again":"Readers keep seeing the comments but can no longer add any",onClick:()=>w(()=>Eo(x,!v)),children:v?"Reopen comments":"Close comments"})]}),b&&e.jsx("div",{className:"cp-error",children:b}),R.length===0?h.length===0&&e.jsx("div",{className:"cp-empty",children:u==="unread"?"No unread comment.":"No comment yet."}):R.map(y=>E(y,!1)),h.length>0&&e.jsxs("div",{className:"cp-detached",children:[e.jsxs("span",{className:"rail-label",children:["Detached · ",h.length]}),e.jsx("div",{className:"cp-detached-text",children:"Their passage is absent from the published version: readers no longer see them. They still count toward the limit until deleted."}),h.map(y=>E(y,!0))]})]})}function Ci(t,s){const{commentsVersion:n,publicationsVersion:a}=Y(),[o,r]=i.useState(null),[l,c]=i.useState(0),d=`${t}\0${s??""}`;i.useEffect(()=>{if(!s)return;let m=!1;return $o(t,s).then(u=>{m||r({key:d,data:u})}).catch(u=>console.error(`Comments of "${s}" could not be loaded: ${u.message}`)),()=>{m=!0}},[d,t,s,n,a,l]);const h=i.useCallback(()=>c(m=>m+1),[]);return{data:o?.key===d?o.data:null,reload:h}}function ki(){const{currentProject:t,commentsVersion:s,publicationsVersion:n,hasReceivedInitialState:a,setCommentSummary:o}=Y();i.useEffect(()=>{if(!a)return;let r=!1;return Ro(t).then(l=>{r||o(t,l)}).catch(l=>console.error(`Comment counts of "${t}" could not be loaded: ${l.message}`)),()=>{r=!0}},[t,s,n,a])}function Si(t){const{commentSummary:s,currentProject:n}=Y();return!t||s.project!==n?null:s.docs[t]??null}function Fa(){const[t,s]=i.useState(!1);return{copied:t,copy:async a=>{await navigator.clipboard.writeText(a),s(!0),setTimeout(()=>s(!1),2e3)}}}function Oa(t){const{publicationsVersion:s}=Y(),[n,a]=i.useState(null),[o,r]=i.useState(null),[l,c]=i.useState(0);i.useEffect(()=>{let h=!1;return Po(t).then(m=>{h||(a({project:t,publications:m}),r(null))}).catch(m=>{h||r(m.message)}),()=>{h=!0}},[t,s,l]);const d=i.useCallback(()=>c(h=>h+1),[]);return{publications:n?.project===t?n.publications:null,error:o,reload:d}}function Ei({project:t,doc:s,latestVersion:n,readOnly:a}){const{publications:o,reload:r}=Oa(t),[l,c]=i.useState(!1),d=o?.find(m=>m.docId===s.id)??null;if(i.useEffect(()=>{if(!l)return;const m=u=>{u.key==="Escape"&&c(!1)};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[l]),o===null||!d&&a)return null;const h=()=>{l||r(),c(!l)};return e.jsxs("div",{className:"menu-anchor",children:[e.jsxs("button",{className:`btn-secondary publish-btn${l?" publish-btn--open":""}`,onClick:h,title:d?"Public link of this document":"Publish this document",children:[e.jsx(Lt,{size:14,className:d?"publish-btn-icon--published":void 0}),d?"Published":"Publish",d?.status==="modified"&&e.jsx("span",{className:"publish-btn-dot",title:"Changed since it was published"})]}),l&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"menu-backdrop",onClick:()=>c(!1)}),e.jsx("div",{className:"publish-popover",role:"dialog","aria-label":d?"Document published":"Publish this document",children:d?e.jsx(Ri,{publication:d,readOnly:a,onClose:()=>c(!1),onChanged:r}):e.jsx($i,{project:t,doc:s,latestVersion:n,onClose:()=>c(!1),onChanged:r})})]})]})}function Ua({title:t,published:s,onClose:n}){return e.jsxs("div",{className:"publish-head",children:[s&&e.jsx("span",{className:"publish-online-dot"}),e.jsx("span",{className:"publish-title",children:t}),e.jsx("button",{className:"publish-close",onClick:n,"aria-label":"Close",children:e.jsx(rn,{size:14})})]})}function Ha({label:t,value:s,onChange:n,placeholder:a,multiline:o}){return e.jsxs("label",{className:"publish-field",children:[e.jsxs("span",{className:"publish-field-label",children:[t," ",e.jsx("span",{className:"publish-field-optional",children:"(optional)"})]}),o?e.jsx("textarea",{className:"publish-input publish-input--multiline",value:s,maxLength:Qt,rows:3,placeholder:a,onChange:r=>n(r.target.value),autoFocus:!0}):e.jsx("input",{className:"publish-input",value:s,maxLength:Qt,placeholder:a,onChange:r=>n(r.target.value)})]})}function $i({project:t,doc:s,latestVersion:n,onClose:a,onChanged:o}){const[r,l]=i.useState(""),[c,d]=i.useState(!1),[h,m]=i.useState(null),u=async()=>{d(!0),m(null);try{await Do(t,s.id,r),o()}catch(p){m(p instanceof Error?p.message:String(p))}finally{d(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx(Ua,{title:"Publish this document",onClose:a}),e.jsx("p",{className:"publish-text",children:"The public link shows the current version, frozen. Later changes only appear there once the publication is updated."}),e.jsxs("div",{className:"publish-version",children:[e.jsx(wl,{size:14}),"Version ",Te(n)," · modified ",is(s.updatedAt)]}),e.jsx(Ha,{label:"Version note",value:r,onChange:l,placeholder:"e.g. First version shared with the infra team",multiline:!0}),e.jsxs("div",{className:"publish-access",children:[e.jsx(on,{size:14}),"Anyone with the link can read this document."]}),h&&e.jsx("div",{className:"publish-error",children:h}),e.jsxs("div",{className:"publish-actions",children:[e.jsx("button",{className:"btn-secondary",onClick:a,disabled:c,children:"Cancel"}),e.jsxs("button",{className:"btn-primary",onClick:u,disabled:c,children:[e.jsx(Lt,{size:14}),c?"Publishing…":"Publish"]})]})]})}function Ri({publication:t,readOnly:s,onClose:n,onChanged:a}){const[o,r]=i.useState(""),[l,c]=i.useState(!1),[d,h]=i.useState(null),[m,u]=i.useState(!1),{copied:p,copy:f}=Fa(),k=an(t.token),j=t.status==="modified",g=async b=>{c(!0),h(null);try{await b(),r(""),u(!1),a()}catch(N){h(N instanceof Error?N.message:String(N))}finally{c(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx(Ua,{title:"Document published",published:!0,onClose:n}),e.jsxs("div",{className:"publish-link",children:[e.jsx(on,{size:14,className:"publish-link-icon"}),e.jsx("span",{className:"publish-link-url",title:k,children:k}),e.jsx("a",{className:"publish-icon-btn",href:k,target:"_blank",rel:"noopener noreferrer",title:"Open the public page",children:e.jsx(qn,{size:14})}),e.jsx("button",{className:"publish-copy-btn",onClick:()=>f(k),title:"Copy the link",children:p?e.jsx(Se,{size:14}):e.jsx(Pt,{size:14})})]}),e.jsxs("div",{className:"publish-meta",children:["Published ",is(t.publishedAt)," · version ",Te(t.version)]}),t.note&&e.jsx("div",{className:"publish-quote",children:t.note}),e.jsx("div",{className:"publish-sep"}),j?e.jsxs("div",{className:"publish-warning",children:[e.jsx(xs,{size:14}),e.jsxs("div",{children:["The document changed since it was published.",e.jsx("br",{}),"Published: ",Te(t.version)," · current: ",Te(t.currentVersion)]})]}):e.jsxs("div",{className:"publish-uptodate",children:[e.jsx(Je,{size:14}),"The published version is up to date."]}),!s&&j&&!m&&e.jsx(Ha,{label:"Note for the new version",value:o,onChange:r,placeholder:"e.g. Added the Entry points section"}),d&&e.jsx("div",{className:"publish-error",children:d}),!s&&(m?e.jsx(Ba,{busy:l,onCancel:()=>u(!1),onConfirm:()=>g(()=>ln(t.id))}):e.jsxs("div",{className:"publish-actions publish-actions--split",children:[e.jsxs("button",{className:"btn-secondary publish-danger-btn",onClick:()=>u(!0),disabled:l,children:[e.jsx(vs,{size:14}),"Unpublish"]}),j&&e.jsxs("button",{className:"btn-primary",onClick:()=>g(()=>cn(t.id,o)),disabled:l,children:[e.jsx(wt,{size:14}),l?"Updating…":"Update publication"]})]}))]})}function Ba({title:t,busy:s,onCancel:n,onConfirm:a}){return e.jsxs("div",{className:"publish-confirm",children:[e.jsx("div",{className:"publish-confirm-title",children:t?`Unpublish “${t}”?`:"Unpublish this document?"}),e.jsx("div",{className:"publish-confirm-text",children:"The link stops working immediately. Publishing again creates a new link."}),e.jsxs("div",{className:"publish-actions",children:[e.jsx("button",{className:"btn-secondary",onClick:n,disabled:s,children:"Cancel"}),e.jsx("button",{className:"publish-confirm-btn",onClick:a,disabled:s,children:s?"Unpublishing…":"Unpublish"})]})]})}function Js(t){return t.replace(/[^a-zA-Z0-9_\-. ]/g,"_")}const Pi=1280,as="mcp-documentor.contextRail",Xe=()=>typeof window>"u"||window.innerWidth>=Pi;function Di(){try{const t=JSON.parse(localStorage.getItem(as)??"null");return t&&t.wide===Xe()?t.open:null}catch{return null}}function Yt(t){try{t===null?localStorage.removeItem(as):localStorage.setItem(as,JSON.stringify({open:t,wide:Xe()}))}catch{}}function Ys(t){if(!t)return"the last snapshot";const s=new Date(t);if(Number.isNaN(s.getTime()))return"the last snapshot";const n=a=>String(a).padStart(2,"0");return`${s.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})} ${n(s.getHours())}:${n(s.getMinutes())}`}function Li(){const t=re(),s=Y(),{selectedDoc:n,selectedDocId:a,freshnessResult:o,setFreshnessResult:r,setSelectedDoc:l,setDocs:c,docs:d,currentProject:h,projects:m,historyEntries:u,historyVersionContent:p,setHistoryEntries:f,setHistoryVersionContent:k,readOnly:j,codeSourcesVersion:g}=s,b=i.useRef(null),N=i.useRef(null),x=i.useRef(null),[v,w]=i.useState("document"),[R,E]=i.useState(null),[y,$]=i.useState(!1),[L,S]=i.useState(!1),[I,z]=i.useState(!1),[X,B]=i.useState(!1),[q,D]=i.useState(!1),[V,T]=i.useState(""),[W,J]=i.useState(!1),[be,ce]=i.useState(null),[Fe,ye]=i.useState(!1),[Ee,Ne]=i.useState(null),[at,$e]=i.useState(null),[Oe,te]=i.useState(!1),[pe,de]=i.useState(!1),[Re,Pe]=i.useState(!1),[Me,we]=i.useState(null),[M,U]=i.useState(!1),[G,K]=i.useState(!1),[fe,Mt]=i.useState([]),[so,It]=i.useState(null),[ys,Ue]=i.useState(()=>Di()??Xe()),[no,He]=i.useState("page"),[ge,ao]=i.useState(null),[At,_t]=i.useState(null),[zt,ot]=i.useState(null),Ns=i.useRef(null),Ft=C=>{Yt(C),Ue(C)},ws=v==="diff",Cs=v==="history";i.useEffect(()=>{window.__pdfReady=!!(n&&!q)},[n,q]),i.useEffect(()=>{let C=Xe();const P=()=>{const _=Xe();_!==C&&(C=_,Yt(null),Ue(_))};return window.addEventListener("resize",P),()=>window.removeEventListener("resize",P)},[]),i.useEffect(()=>{const C=P=>{(P.metaKey||P.ctrlKey)&&P.key==="\\"&&(P.preventDefault(),Ue(_=>(Yt(!_),!_)))};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[]),i.useEffect(()=>{if(!a)return;window.__pdfReady=!1,window.__mermaidPending=0,b.current&&(b.current.scrollTop=0),w("document"),E(null),z(!1),f(null),D(!1),ce(null),Ne(null),de(!1),we(null),U(!1),K(!1),Mt([]),It(null),He("page"),_t(null),ot(null);const C=xe(a),P=new AbortController;let _=!1;const H=encodeURIComponent(h);return fetch(`/api/doc/${C}?project=${H}`,{signal:P.signal}).then(F=>F.json()).then(F=>{_||(F.doc?l(F.doc):z(!0))}).catch(F=>{_||F.name==="AbortError"||z(!0)}),fetch(`/api/freshness/${C}?project=${H}`,{signal:P.signal}).then(F=>F.json()).then(F=>{_||!F.report||r(F.report)}).catch(()=>{}),fetch(`/api/history/${C}?project=${H}`,{signal:P.signal}).then(F=>F.json()).then(F=>{_||f(F.versions??[])}).catch(()=>{}),()=>{_=!0,P.abort()}},[a,h]),i.useEffect(()=>{if(g===0||!a)return;const C=new AbortController;return fetch(`/api/freshness/${xe(a)}?project=${encodeURIComponent(h)}`,{signal:C.signal}).then(P=>P.json()).then(P=>{P.report&&r(P.report)}).catch(()=>{}),()=>C.abort()},[g]),i.useEffect(()=>{if(v!=="document"||q||!n){Mt([]);return}const C=requestAnimationFrame(()=>{const P=b.current?.querySelector(".doc-content");if(!P)return;const _=[...P.querySelectorAll("h1, h2, h3")];Mt(_.filter(H=>H.id).map(H=>({id:H.id,text:H.textContent??"",level:Number(H.tagName.slice(1))})))});return()=>cancelAnimationFrame(C)},[n,v,q]),i.useEffect(()=>{const C=b.current;if(!C||fe.length===0)return;const P=()=>{const _=C.getBoundingClientRect().top+80;let H=fe[0].id;for(const F of fe){const se=document.getElementById(F.id);se&&se.getBoundingClientRect().top<=_&&(H=F.id)}It(H)};return P(),C.addEventListener("scroll",P,{passive:!0}),()=>C.removeEventListener("scroll",P)},[fe]);const oo=i.useCallback(C=>{document.getElementById(C)?.scrollIntoView({behavior:"smooth",block:"start"}),It(C)},[]),De=Ci(h,n?.id),Ce=Si(n?.id),rt=Lo(ge),ro=i.useMemo(()=>(De.data?.comments??[]).filter(C=>!C.parentId&&!C.detached),[De.data]),ue=To(rt,ro),lo=(De.data?.comments??[]).filter(C=>!C.read).length;i.useEffect(()=>{const C=De.data;!n||!C||Ns.current===n.id||(Ns.current=n.id,C.comments.some(P=>!P.read)&&(He("comments"),Ue(!0)))},[De.data,n]),i.useEffect(()=>{dt("dc-passage",[...ue.values()].map(_=>_.range));const C=zt??At,P=C?ue.get(C):void 0;dt("dc-focus",P?[P.range]:[])},[ue,zt,At]),i.useEffect(()=>()=>{dt("dc-passage",[]),dt("dc-focus",[])},[]);const Ot=i.useCallback((C,P)=>{if(!rt)return null;const _=Mo(C,P),H=_?rt.indexAt(_.node,_.offset):null;if(H===null)return null;for(const[F,se]of ue)if(H>=se.start&&H<se.end)return F;return null},[rt,ue]);i.useEffect(()=>{if(!ge||ue.size===0)return;const C=F=>{if(!window.getSelection()?.isCollapsed||F.target.closest("a, button"))return;const se=Ot(F.clientX,F.clientY);se&&(_t(se),He("comments"),Ue(!0))};let P=0;const _=F=>{cancelAnimationFrame(P),P=requestAnimationFrame(()=>ot(Ot(F.clientX,F.clientY)))},H=()=>{cancelAnimationFrame(P),ot(null)};return ge.addEventListener("click",C),ge.addEventListener("mousemove",_),ge.addEventListener("mouseleave",H),()=>{cancelAnimationFrame(P),ge.removeEventListener("click",C),ge.removeEventListener("mousemove",_),ge.removeEventListener("mouseleave",H)}},[ge,ue,Ot]);const io=i.useCallback(C=>{_t(C),ue.get(C)?.range.startContainer.parentElement?.scrollIntoView({behavior:"smooth",block:"center"})},[ue]),Ut=i.useMemo(()=>({code:Io,a({href:C,children:P,..._}){if(C?.startsWith("doc://")){const H=Tl(C.slice(6)),F=H.indexOf(":");if(F!==-1){const ae=H.slice(0,F),Ve=H.slice(F+1),qe=m.includes(ae);return e.jsx("button",{className:qe?"doc-inline-link doc-inline-link--cross-project":"doc-inline-link doc-inline-link--broken",onClick:()=>{qe&&t(ne(ae,Ve))},title:qe?`Projet : ${ae}`:`Projet introuvable : ${ae}`,children:P})}const se=H,We=d.some(ae=>ae.id===se);return e.jsx("button",{className:We?"doc-inline-link":"doc-inline-link doc-inline-link--broken",onClick:()=>{We&&t(ne(h,se))},title:We?void 0:`Document introuvable : ${se}`,children:P})}return C?.startsWith("#")?e.jsx("a",{href:C,onClick:H=>{H.preventDefault(),document.getElementById(C.slice(1))?.scrollIntoView({behavior:"smooth"})},..._,children:P}):e.jsx("a",{href:C,target:"_blank",rel:"noopener noreferrer",..._,children:P})},img({src:C,alt:P,..._}){return e.jsx("img",{src:C,alt:P??"",className:"doc-image",..._})}}),[d,m,h,t]),co=i.useMemo(()=>n&&e.jsx(tn,{remarkPlugins:[nn],rehypePlugins:[sn],components:Ut,urlTransform:C=>C.startsWith("doc://")?C:Ao(C),children:n.content}),[n,Ut]);if(!n&&!a)return e.jsx("div",{className:"doc-viewer",children:e.jsx("div",{className:"doc-viewer-empty",children:"Select a documentation entry to view"})});if(a&&I&&!n)return e.jsx("div",{className:"doc-viewer",children:e.jsx("div",{className:"doc-viewer-empty",children:"No documentation at this path in the current project."})});const uo=async()=>{if(n)try{const P=await(await fetch(`/api/freshness/${xe(n.id)}?project=${encodeURIComponent(h)}`)).json();P.report&&r(P.report)}catch{}},ho=async()=>{n&&(await navigator.clipboard.writeText(n.content),S(!0),setTimeout(()=>S(!1),2e3))},mo=()=>{if(!n)return;const C=new Blob([n.content],{type:"text/markdown;charset=utf-8"}),P=URL.createObjectURL(C),_=document.createElement("a");_.href=P,_.download=`${Js(n.title)}.md`,document.body.appendChild(_),_.click(),document.body.removeChild(_),URL.revokeObjectURL(P)},po=async()=>{if(!n)return;const C=Number(localStorage.getItem("printScale")??100)/100,P=h,_=n.id;ye(!0),Ne(null);try{const H=new URLSearchParams({project:P,docId:_,scale:String(C)}),F=await fetch(`/api/pdf?${H}`);if(F.status===503){const Ve=await F.json();Ne(Ve.message??"Navigateur introuvable pour la génération PDF."),setTimeout(()=>Ne(null),8e3);return}if(!F.ok){Ne("Échec de la génération PDF."),setTimeout(()=>Ne(null),5e3);return}const se=await F.blob(),We=await new Promise((Ve,qe)=>{const ct=new FileReader;ct.onload=()=>Ve(ct.result),ct.onerror=qe,ct.readAsDataURL(se)}),ae=document.createElement("a");ae.href=We,ae.download=`${Js(n.title)}.pdf`,document.body.appendChild(ae),ae.click(),document.body.removeChild(ae)}finally{ye(!1)}},fo=async()=>{if(!(!n||u!==null)){B(!0);try{const P=await(await fetch(`/api/history/${xe(n.id)}?project=${encodeURIComponent(h)}`)).json();f(P.versions??[])}catch{f([])}finally{B(!1)}}},go=async()=>{if(!(!n||R!==null)){$(!0);try{const P=await(await fetch(`/api/git-diff/${xe(n.id)}?project=${encodeURIComponent(h)}`)).json();E(P.diff??P.error??"No diff available.")}catch{E("Failed to load diff.")}finally{$(!1)}}},Be=C=>{w(C),U(!1),K(!1),C!=="document"&&D(!1),C==="diff"&&go(),C==="history"&&fo()},xo=C=>{const P=N.current;if(!P)return;const _=P.selectionStart,H=P.selectionEnd,F=V.slice(0,_)+C+V.slice(H);T(F),requestAnimationFrame(()=>{P.selectionStart=P.selectionEnd=_+C.length,P.focus()})},vo=async()=>{if(n){J(!0),ce(null);try{const C=xe(n.id),P=await fetch(`/api/doc/${C}?project=${encodeURIComponent(h)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:V})}),_=await P.json();if(!P.ok||_.error)throw new Error(_.error||"Save failed");const H=new Date().toISOString();l({...n,content:V,updatedAt:H}),c(d.map(F=>F.id===n.id?{...F,updatedAt:H}:F)),D(!1)}catch(C){ce(C instanceof Error?C.message:"Save failed")}finally{J(!1)}}},jo=async()=>{if(n){Pe(!0),we(null);try{const C=xe(n.id),P=await fetch(`/api/doc/${C}?project=${encodeURIComponent(h)}`,{method:"DELETE"}),_=await P.json();if(!P.ok||_.error)throw new Error(_.error||"Delete failed");const H=n.id;c(d.filter(F=>F.id!==H)),l(null),r(null),de(!1),t(ne(h,null),{replace:!0})}catch(C){we(C instanceof Error?C.message:"Delete failed")}finally{Pe(!1)}}},Ht=n?d.find(C=>C.id===n.id):void 0,ks=Ht?.isStale??!1,Le=n?.tracked_files.length??0,lt=o?.modified.length??0,it=u&&u.length>0?u[0].version:null,Ss=n&&Le>0?n.tracked_files.map(C=>C.lastModifiedAt).filter(Boolean).sort().slice(-1)[0]:void 0,bo=[...Ht?.folder?Ht.folder.split("/").filter(Boolean):[],n?.title??"…"],yo=!j&&!!n&&v==="document";return e.jsxs("div",{className:"doc-viewer",children:[e.jsxs("div",{className:"doc-main",ref:b,children:[e.jsxs("div",{className:"doc-topbar",children:[e.jsxs("div",{className:"doc-topbar-left",children:[e.jsxs("div",{className:"doc-breadcrumb",children:[e.jsx("button",{className:"nav-btn",onClick:()=>t(-1),title:"Go back",children:"←"}),e.jsx("button",{className:"nav-btn",onClick:()=>t(1),title:"Go forward",children:"→"}),bo.map((C,P)=>e.jsxs("span",{className:"doc-breadcrumb-segment",children:[P>0&&e.jsx("span",{className:"doc-breadcrumb-sep",children:"/"}),C]},`${C}-${P}`))]}),e.jsx("h1",{className:"doc-title",children:n?.title??"…"})]}),e.jsxs("div",{className:"doc-actions",children:[!ys&&n&&e.jsx("button",{className:"icon-btn",onClick:()=>Ft(!0),title:"Show details (Ctrl/⌘ + \\)",children:"|◁"}),n&&!q&&Ce&&Ce.total>0&&e.jsxs("button",{className:"btn-secondary doc-comments-btn",onClick:()=>{He("comments"),Ft(!0)},title:Ce.unread>0?`${Ce.total} comments, ${Ce.unread} unread`:`${Ce.total} comments`,children:[e.jsx(ls,{size:13}),Ce.total,Ce.unread>0&&e.jsx("span",{className:"doc-comments-dot"})]}),n&&!q&&e.jsx(Ei,{project:h,doc:n,latestVersion:it,readOnly:j},n.id),yo&&e.jsx("button",{className:`btn-primary${q?" active":""}`,onClick:()=>{!q&&n&&T(n.content),D(!q),ce(null)},title:q?"Cancel editing":"Edit document",children:q?"✕ Cancel":"✎ Edit"}),n&&!q&&e.jsxs("div",{className:"menu-anchor",children:[e.jsx("button",{className:"btn-secondary",onClick:()=>{U(C=>!C),K(!1)},title:"Export this document",children:"↓ Export ▾"}),M&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"menu-backdrop",onClick:()=>U(!1)}),e.jsxs("div",{className:"menu-popover",children:[e.jsx("button",{className:"menu-item",onClick:()=>{U(!1),ho()},children:L?"✓ Copied!":"⎘ Copy markdown"}),e.jsx("button",{className:"menu-item",onClick:()=>{U(!1),mo()},children:"↓ Download .md"}),e.jsx("button",{className:"menu-item",disabled:Fe,onClick:()=>{U(!1),po()},children:Fe?"⏳ PDF…":"↓ Download PDF"})]})]})]}),n&&!q&&e.jsxs("div",{className:"menu-anchor",children:[e.jsx("button",{className:"btn-icon-secondary",onClick:()=>{K(C=>!C),U(!1)},title:"More actions",children:"⋯"}),G&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"menu-backdrop",onClick:()=>K(!1)}),e.jsxs("div",{className:"menu-popover menu-popover--right",children:[Le>0&&e.jsx("button",{className:"menu-item",onClick:()=>{K(!1),uo()},children:"⟳ Re-check freshness"}),e.jsx("button",{className:"menu-item",onClick:()=>{K(!1),navigator.clipboard.writeText(n.id)},children:"⎘ Copy doc ID"}),!j&&e.jsx("button",{className:"menu-item menu-item--danger",onClick:()=>{K(!1),we(null),de(!0)},children:"🗑 Delete document"})]})]})]})]})]}),e.jsxs("nav",{className:"doc-tabs",children:[e.jsx("button",{className:`doc-tab${v==="document"?" active":""}`,onClick:()=>Be("document"),children:"Document"}),Le>0&&e.jsx("button",{className:`doc-tab${ws?" active":""}`,onClick:()=>Be("diff"),children:y?"Diff…":`Diff${lt>0?` · ${lt}`:""}`}),e.jsx("button",{className:`doc-tab${Cs?" active":""}`,onClick:()=>Be("history"),children:X?"History…":`History${it!==null?` · v${it}`:""}`}),Le>0&&e.jsxs("button",{className:`doc-tab${v==="files"?" active":""}`,onClick:()=>Be("files"),children:["Tracked files · ",Le]})]}),Ee&&e.jsx("div",{className:"pdf-error-banner",children:Ee}),v==="document"&&!q&&ks&&Le>0&&e.jsxs("div",{className:"stale-banner",children:[e.jsx("span",{className:"stale-banner-icon",children:"⚠"}),e.jsxs("div",{className:"stale-banner-body",children:[e.jsx("span",{className:"stale-banner-text",children:lt>0?`${lt} of ${Le} tracked files changed since the snapshot taken on ${Ys(Ss)}.`:`Tracked files changed since the snapshot taken on ${Ys(Ss)}.`}),e.jsx("button",{className:"stale-banner-link",onClick:()=>Be("diff"),children:"View diff"})]})]}),v==="files"&&n&&(o?e.jsx(ti,{report:o,trackedFiles:n.tracked_files,docId:n.id,onViewCode:$e}):e.jsx("div",{className:"doc-tab-loading",children:"Checking tracked files…"})),Cs&&n&&e.jsx(fi,{docId:n.id,project:h,entries:u??[],selectedVersion:p,onSelectVersion:async C=>{const _=await(await fetch(`/api/history-version/${xe(n.id)}/${C}?project=${encodeURIComponent(h)}`)).json();k(_??null)},markdownComponents:Ut}),ws&&(y&&R===null?e.jsx("div",{className:"doc-tab-loading",children:"Loading diff…"}):e.jsx(ai,{diffText:R??""})),v==="document"&&(q&&n?e.jsxs("div",{className:"doc-editor",children:[e.jsx("textarea",{ref:N,className:"doc-editor-textarea",value:V,onChange:C=>T(C.target.value),spellCheck:!1}),e.jsxs("div",{className:"doc-editor-actions",children:[be&&e.jsx("span",{className:"doc-editor-error",children:be}),e.jsxs("div",{className:"doc-editor-actions-right",children:[e.jsx("button",{ref:x,type:"button",className:"image-insert-trigger-btn",onClick:()=>te(C=>!C),title:"Insert image",children:"🖼 Image"}),Oe&&e.jsx(ji,{project:h,triggerRef:x,onInsert:xo,onClose:()=>te(!1)}),e.jsx("button",{type:"button",className:"save-btn",onClick:vo,disabled:W,children:W?"Saving…":"✓ Save"})]})]})]}):e.jsx("div",{className:"doc-content",ref:ao,children:co}))]}),ys&&n&&e.jsx(yi,{doc:n,isStale:ks,report:o,toc:fe,activeHeadingId:so,version:it,onSelectHeading:oo,onSelectFile:$e,onClose:()=>Ft(!1),tab:no,onTab:He,unreadComments:lo,comments:De.data?.publication?e.jsx(wi,{data:De.data,locatedIds:new Set(ue.keys()),activeId:At,hoveredId:zt,readOnly:j,onActivate:C=>{v!=="document"&&w("document"),io(C)},onHover:ot},n.id):null}),pe&&n&&e.jsx("div",{className:"modal-overlay",onClick:()=>!Re&&de(!1),children:e.jsxs("div",{className:"modal-content delete-modal",onClick:C=>C.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("span",{className:"modal-title",children:"Delete documentation"}),e.jsx("button",{className:"modal-close-btn",onClick:()=>de(!1),disabled:Re,children:"✕"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("p",{className:"delete-modal-text",children:["Delete ",e.jsx("strong",{children:n.title})," (",e.jsx("code",{children:n.id}),") from project"," ",e.jsx("strong",{children:h}),"? This action cannot be undone from the interface."]}),Me&&e.jsx("span",{className:"doc-editor-error",children:Me}),e.jsxs("div",{className:"delete-modal-actions",children:[e.jsx("button",{type:"button",className:"copy-btn",onClick:()=>de(!1),disabled:Re,children:"Cancel"}),e.jsx("button",{type:"button",className:"delete-btn delete-btn--confirm",onClick:jo,disabled:Re,children:Re?"Deleting…":"🗑 Delete"})]})]})]})}),at&&n&&e.jsx(vi,{docId:n.id,project:h,filePath:at,onClose:()=>$e(null)})]})}async function bs(t,s){const n=await fetch(t,s);let a=null;try{a=await n.json()}catch{}if(!n.ok)throw new Error(a?.error??`HTTP ${n.status}`);return a}function Ti(){return bs("/api/logs")}function Mi(t,s){const n=s?`?knownSize=${s.size}&knownMtime=${encodeURIComponent(s.mtime??"")}`:"";return bs(`/api/logs/${t}${n}`)}function Ii(){return bs("/api/logs/open-folder",{method:"POST"})}const Ai=t=>`/api/logs/${t}/download`;function Qe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(t<10*1024?1:0)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function ee(t){return t.toLocaleString("fr-FR")}function Wa(t,s){return t.getFullYear()===s.getFullYear()&&t.getMonth()===s.getMonth()&&t.getDate()===s.getDate()}function Tt(t){return Wa(new Date(t),new Date)}function Va(t){const s=new Date(t);if(Number.isNaN(s.getTime()))return t;const n=(o,r=2)=>String(o).padStart(r,"0"),a=`${n(s.getHours())}:${n(s.getMinutes())}:${n(s.getSeconds())}.${n(s.getMilliseconds(),3)}`;return Wa(s,new Date)?a:`${n(s.getDate())}/${n(s.getMonth()+1)} ${a.slice(0,8)}`}function pt(t){return`${ee(t)} ms`}const qa={hour:"Last hour",today:"Today",day:"Last 24 hours",week:"Last 7 days",all:"All loaded"};function Ga(t,s){if(s==="all")return!0;if(s==="today")return Tt(t);const n=Date.now()-new Date(t).getTime(),a=s==="hour"?36e5:s==="day"?864e5:7*864e5;return n<=a}const _i=3e3;function Ka(t,s,n){i.useEffect(()=>{if(!s||(t(),!n))return;const a=setInterval(t,_i);return()=>clearInterval(a)},[s,n,t])}function os(t,s,n){const[a,o]=i.useState(null),[r,l]=i.useState(null),[c,d]=i.useState(null),h=i.useRef(void 0),m=i.useRef(!1),u=i.useCallback(async()=>{if(!m.current){m.current=!0;try{const p=await Mi(t,h.current);"unchanged"in p||(h.current=p.file,o(p)),l(null),d(Date.now())}catch(p){l(p instanceof Error?p.message:String(p))}finally{m.current=!1}}},[t]);return Ka(u,s,n),{data:a,error:r,checkedAt:c}}function zi(t){const[s,n]=i.useState(null),[a,o]=i.useState(null),r=i.useCallback(async()=>{try{n(await Ti()),o(null)}catch(l){o(l instanceof Error?l.message:String(l))}},[]);return Ka(r,!0,t),{directory:s,error:a}}function Fi(t=1e3){const[s,n]=i.useState(()=>Date.now());return i.useEffect(()=>{const a=setInterval(()=>n(Date.now()),t);return()=>clearInterval(a)},[t]),s}function Oi(){const{syncEnabled:t,readOnly:s,currentProject:n}=Y(),[a,o]=i.useState(null),[r,l]=i.useState(!1),[c,d]=i.useState(null),h=i.useCallback(async()=>{try{const j=await fetch("/api/sync/status"),g=await j.json();o(j.ok&&!g.error?g:null)}catch{o(null)}},[]);if(i.useEffect(()=>{!t||s||h()},[t,s,n,h]),!t||s)return null;const m=async()=>{if(!r){l(!0),d(null);try{const j=await fetch("/api/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),g=await j.json();!j.ok||g.error?d({ok:!1,message:g.error??`HTTP ${j.status}`}):d({ok:!0,message:g.message??"Sync terminée."})}catch(j){d({ok:!1,message:j?.message??"Sync failed"})}finally{l(!1),h()}}},u=[];a?.ahead&&u.push(`↑${a.ahead}`),a?.behind&&u.push(`↓${a.behind}`),a?.dirty?.length&&u.push(`●${a.dirty.length}`);const p=a?.conflicted?.length??0,f=r?"Sync…":p>0?`Conflits à résoudre (${p} fichier(s))`:["Sync",a?.branch,...u.length>0?[u.join(" ")]:[]].filter(Boolean).join(" · "),k=p>0?"!":u[0];return e.jsxs("div",{className:"sync-button-wrapper",children:[e.jsxs("button",{className:`rail-btn${p>0?" conflict":""}`,onClick:m,disabled:r,"data-tooltip":f,"aria-label":f,children:[e.jsx(wt,{size:20,className:r?"spinning":void 0}),k&&e.jsx("span",{className:`rail-badge rail-badge--${p>0?"danger":"accent"}`,children:k})]}),c&&e.jsxs("div",{className:`sync-result${c.ok?"":" error"}`,children:[e.jsx("pre",{children:c.message}),e.jsx("button",{className:"sync-result-close",onClick:()=>d(null),title:"Fermer",children:"✕"})]})]})}function ke({icon:t,label:s,active:n,onClick:a,children:o}){return e.jsxs("button",{className:`rail-btn${n?" active":""}`,onClick:a,"data-tooltip":s,"aria-label":s,children:[e.jsx(t,{size:20}),o]})}function Ui({active:t,onSelect:s,onOpenSettings:n,onOpenProjectSettings:a}){const{docs:o,commentSummary:r,currentProject:l}=Y(),c=o.filter(u=>u.isStale).length,d=r.project===l?Object.values(r.docs).reduce((u,p)=>u+p.unread,0):0,h=os("github",!0,!0),m=i.useMemo(()=>(h.data?.entries??[]).filter(u=>Tt(u.ts)&&!u.ok).length,[h.data]);return e.jsxs("nav",{className:"nav-rail",children:[e.jsx("div",{className:"rail-logo",title:"MCP Documentor",children:e.jsx(pl,{size:18})}),e.jsx(Da,{variant:"rail",onOpenSettings:a}),e.jsx("div",{className:"rail-sep"}),e.jsx(ke,{icon:yl,label:"Documentation",active:t==="docs",onClick:()=>s("docs")}),e.jsx(ke,{icon:nt,label:"Search ⌘K",active:t==="search",onClick:()=>s("search")}),e.jsx(ke,{icon:jl,label:c>0?`Outdated · ${c}`:"Outdated",active:t==="outdated",onClick:()=>s("outdated"),children:c>0&&e.jsx("span",{className:"rail-badge rail-badge--warn",children:c})}),e.jsx(ke,{icon:Un,label:"Recent",active:t==="recent",onClick:()=>s("recent")}),e.jsx(ke,{icon:$l,label:"Export bundles",active:t==="exports",onClick:()=>s("exports")}),e.jsx(ke,{icon:Lt,label:d>0?`Publications · ${d} unread comments`:"Publications",active:t==="publications",onClick:()=>s("publications"),children:d>0&&e.jsx("span",{className:"rail-badge rail-badge--accent",children:d})}),e.jsx("div",{className:"rail-sep"}),e.jsx(ke,{icon:ga,label:m>0?`Logs · ${m} failed today`:"Logs",active:t==="logs",onClick:()=>s("logs"),children:m>0&&e.jsx("span",{className:"rail-dot"})}),e.jsx("div",{className:"rail-spacer"}),e.jsx(Oi,{}),e.jsx(ke,{icon:ja,label:"Settings",active:!1,onClick:n})]})}function Hi({onClose:t,onShowMigrationReport:s}){const{readOnly:n}=Y(),[a,o]=i.useState(!1),[r,l]=i.useState(""),[c,d]=i.useState(null),[h,m]=i.useState(""),[u,p]=i.useState(""),[f,k]=i.useState("text-embedding-3-small"),[j,g]=i.useState(100);i.useEffect(()=>{const w=localStorage.getItem("printScale");w&&g(Number(w)),Pa().then(R=>o(!!R)).catch(()=>{}),ql().then(R=>l(R.default??"")).catch(()=>{}),fetch("/api/config").then(R=>R.json()).then(R=>{R.dataDir&&m(R.dataDir),R.model&&k(R.model)}).catch(()=>{})},[]);const b=async(w,R)=>{await fetch("/api/configurations/apply",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:w,value:R})})},N=async()=>{d(null);try{const{path:w}=await Gl(r);l(w??""),d({ok:!0,text:w?"Saved":"Removed"})}catch(w){d({ok:!1,text:w.message})}},x=()=>{localStorage.setItem("printScale",String(j))},v=async()=>{await b("MCP_DATA_DIR",h),u&&await b("MCP_DOCUMENTOR_OPENAI_API_KEY",u),await b("MCP_DOCUMENTOR_OPENAI_MODEL",f),t()};return e.jsx("div",{className:"settings-overlay",onClick:t,children:e.jsxs("div",{className:"settings-popover",onClick:w=>w.stopPropagation(),children:[e.jsx("h2",{className:"settings-title",children:"Settings"}),e.jsxs("div",{className:"settings-field",children:[e.jsx("label",{className:"settings-label",children:"Data Directory"}),e.jsx("input",{className:"settings-input",type:"text",value:h,onChange:w=>m(w.target.value),placeholder:"Leave empty for default"})]}),e.jsxs("div",{className:"settings-field",children:[e.jsx("label",{className:"settings-label",children:"OpenAI API Key"}),e.jsx("input",{className:"settings-input",type:"password",value:u,onChange:w=>p(w.target.value),placeholder:"sk-..."})]}),e.jsxs("div",{className:"settings-field",children:[e.jsx("label",{className:"settings-label",children:"Embedding Model"}),e.jsx("input",{className:"settings-input",type:"text",value:f,onChange:w=>k(w.target.value)})]}),e.jsxs("div",{className:"settings-field",children:[e.jsx("label",{className:"settings-label",children:"Print Scale (%)"}),e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsx("input",{className:"settings-input",type:"number",min:30,max:150,value:j,onChange:w=>g(Number(w.target.value)),style:{width:"80px"}}),e.jsx("button",{className:"settings-save-btn",onClick:x,children:"Apply"})]})]}),e.jsxs("div",{className:"settings-field",children:[e.jsx("label",{className:"settings-label",children:"Default code root (this machine)"}),e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsx("input",{className:"settings-input",type:"text",value:r,disabled:n,onChange:w=>l(w.target.value),placeholder:"Absolute path — used by projects without their own root"}),!n&&e.jsx("button",{className:"settings-save-btn",onClick:N,children:"Apply"})]}),c&&e.jsx("span",{className:`settings-hint${c.ok?"":" error"}`,children:c.text})]}),a&&e.jsxs("div",{className:"settings-field",children:[e.jsx("label",{className:"settings-label",children:"Code sources"}),e.jsx("button",{className:"settings-link-btn",onClick:s,children:"View the environment variables migration report"})]}),e.jsxs("div",{className:"settings-actions",children:[e.jsx("button",{className:"settings-cancel-btn",onClick:t,children:"Cancel"}),!n&&e.jsx("button",{className:"settings-save-btn",onClick:v,children:"Save"})]})]})})}function Bi({value:t,onChange:s,options:n}){const[a,o]=i.useState(!1),[r,l]=i.useState(-1),c=i.useRef(null),d=i.useMemo(()=>{const u=t.trim().toLowerCase();return u?n.filter(p=>p.toLowerCase().includes(u)):n},[n,t]);i.useEffect(()=>{if(!a)return;const u=p=>{c.current&&!c.current.contains(p.target)&&o(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[a]),i.useEffect(()=>{l(-1)},[t,a]);const h=u=>{s(u),o(!1)},m=u=>{u.key==="ArrowDown"?(u.preventDefault(),a||o(!0),l(p=>Math.min(p+1,d.length-1))):u.key==="ArrowUp"?(u.preventDefault(),l(p=>Math.max(p-1,0))):u.key==="Enter"&&a&&r>=0&&d[r]?(u.preventDefault(),h(d[r])):u.key==="Escape"&&o(!1)};return e.jsxs("div",{className:"folder-combobox",ref:c,children:[e.jsx("input",{className:"settings-input",value:t,onChange:u=>{s(u.target.value),a||o(!0)},onFocus:()=>o(!0),onKeyDown:m,placeholder:"optional, e.g. backend/auth or backend/auth/new-subfolder",autoComplete:"off",spellCheck:!1}),e.jsx("button",{type:"button",className:"folder-combobox-toggle",onClick:()=>o(u=>!u),tabIndex:-1,"aria-label":"Toggle folder list",children:"▾"}),a&&e.jsxs("div",{className:"folder-combobox-menu",children:[e.jsx("div",{className:"folder-combobox-header",children:"Existing folders"}),d.length===0?e.jsx("div",{className:"folder-combobox-empty",children:n.length===0?"No folder yet — type a path to create one.":"No match — will create a new folder."}):e.jsx("ul",{className:"folder-combobox-list",children:d.map((u,p)=>e.jsx("li",{className:`folder-combobox-item${p===r?" active":""}`,onMouseDown:f=>{f.preventDefault(),h(u)},onMouseEnter:()=>l(p),children:u},u))})]})]})}function Wi({onClose:t}){const s=re(),{currentProject:n,projects:a,docs:o}=Y(),[r,l]=i.useState(n),[c,d]=i.useState(""),[h,m]=i.useState(""),[u,p]=i.useState(""),[f,k]=i.useState(""),[j,g]=i.useState(!1),[b,N]=i.useState(null),[x,v]=i.useState(null),w=i.useMemo(()=>{const y=new Set;for(const $ of o)if($.folder){const L=$.folder.split("/").filter(Boolean);for(let S=1;S<=L.length;S++)y.add(L.slice(0,S).join("/"))}return Array.from(y).sort()},[o]);i.useEffect(()=>{if(r===n){v(null);return}let y=!1;return fetch(`/api/folders?project=${encodeURIComponent(r)}`).then($=>$.json()).then($=>{y||(Array.isArray($?.folders)?v($.folders):v([]))}).catch(()=>{y||v([])}),()=>{y=!0}},[r,n]);const R=r===n?w:x??[],E=async()=>{if(!c.trim()||!f.trim()){N("Title and content are required");return}g(!0),N(null);try{const y=u.split(",").map(S=>S.trim()).filter(Boolean),$=await fetch("/api/doc",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:c.trim(),content:f,folder:h.trim()||void 0,tags:y.length?y:void 0,project:r})}),L=await $.json();if(!$.ok||L.error)throw new Error(L.error||"Create failed");t(),L.id&&r===n&&s(ne(n,L.id))}catch(y){N(y instanceof Error?y.message:"Create failed")}finally{g(!1)}};return e.jsx("div",{className:"settings-overlay",onClick:t,children:e.jsxs("div",{className:"settings-popover create-doc-popover",onClick:y=>y.stopPropagation(),children:[e.jsx("h2",{className:"settings-title",children:"New document"}),e.jsxs("div",{className:"create-doc-grid",children:[e.jsxs("div",{className:"settings-field",children:[e.jsx("label",{className:"settings-label",children:"Project"}),e.jsx("select",{className:"settings-input",value:r,onChange:y=>l(y.target.value),children:a.map(y=>e.jsxs("option",{value:y,children:[y,y===n?" (current)":""]},y))})]}),e.jsxs("div",{className:"settings-field",children:[e.jsx("label",{className:"settings-label",children:"Title *"}),e.jsx("input",{className:"settings-input",value:c,onChange:y=>d(y.target.value)})]}),e.jsxs("div",{className:"settings-field",children:[e.jsx("label",{className:"settings-label",children:"Folder"}),e.jsx(Bi,{value:h,onChange:m,options:R}),e.jsx("div",{className:"create-doc-hint",children:"Pick from the existing tree or type a new path to add a sub-folder."})]}),e.jsxs("div",{className:"settings-field",children:[e.jsx("label",{className:"settings-label",children:"Tags"}),e.jsx("input",{className:"settings-input",value:u,onChange:y=>p(y.target.value),placeholder:"comma, separated, tags"})]})]}),e.jsxs("div",{className:"settings-field create-doc-content-field",children:[e.jsx("label",{className:"settings-label",children:"Content *"}),e.jsx("textarea",{className:"doc-editor-textarea create-doc-textarea",value:f,onChange:y=>k(y.target.value),spellCheck:!1,placeholder:`# My new document
5
+
6
+ Write Markdown here…`})]}),e.jsxs("div",{className:"settings-actions",children:[b&&e.jsx("span",{className:"doc-editor-error",style:{marginRight:"auto"},children:b}),e.jsx("button",{className:"settings-cancel-btn",onClick:t,disabled:j,children:"Cancel"}),e.jsx("button",{className:"settings-save-btn",onClick:E,disabled:j,children:j?"Creating…":"Create"})]})]})})}const Xs=400,Vi=350,qi=300,Gi=/^(https?:\/\/github\.com\/|git@github\.com:)?[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+(\.git)?(#.+)?$/i;function Ki(t){const s=Math.max(0,(Date.now()-new Date(t).getTime())/1e3);if(Number.isNaN(s))return"";if(s<60)return"just now";const n=[[3600*24*365,"year"],[3600*24*30,"month"],[3600*24,"day"],[3600,"hour"],[60,"minute"]];for(const[a,o]of n)if(s>=a){const r=Math.floor(s/a);return`${r} ${o}${r>1?"s":""} ago`}return""}function Ji({project:t,onClose:s}){const{readOnly:n}=Y(),[a,o]=i.useState(null),[r,l]=i.useState("local"),[c,d]=i.useState(""),[h,m]=i.useState({state:"idle"}),[u,p]=i.useState(""),[f,k]=i.useState(""),[j,g]=i.useState({state:"idle"}),[b,N]=i.useState({state:"idle"}),[x,v]=i.useState({state:"loading"}),[w,R]=i.useState(!1),[E,y]=i.useState(null),$=i.useRef(null),[L,S]=i.useState(""),[I,z]=i.useState({state:"idle"}),[X,B]=i.useState(!1),[q,D]=i.useState(0);i.useEffect(()=>{let M=!1;return Ra().then(U=>{if(M)return;const G=U.find(K=>K.project===t)??{project:t};o(G),G.codeRootOrigin==="project"&&G.codeRoot&&d(G.codeRoot),G.config?.kind==="github"&&(l("github"),p(G.config.repo),k(G.config.branch??""))}).catch(U=>!M&&o({project:t,error:U.message})),Kl().then(U=>!M&&v({state:"done",value:U})).catch(U=>!M&&v({state:"failed",error:U.message})),()=>{M=!0}},[t]),i.useEffect(()=>{const M=U=>{U.key==="Escape"&&s()};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[s]),i.useEffect(()=>{if(r!=="local"||c.trim()===""){m({state:"idle"});return}const M=new AbortController;m({state:"loading"});const U=setTimeout(()=>{Vl(c.trim(),M.signal).then(G=>m({state:"done",value:G})).catch(G=>{G.name!=="AbortError"&&m({state:"failed",error:G.message})})},Xs);return()=>{clearTimeout(U),M.abort()}},[r,c]),i.useEffect(()=>{const M=L.trim();if(M.replace("/","").length<2){z({state:"idle"});return}const U=new AbortController;z({state:"loading"});const G=setTimeout(()=>{Ul(M,U.signal).then(K=>{z({state:"done",value:K}),D(0)}).catch(K=>{K.name!=="AbortError"&&z({state:"failed",error:K.message})})},Vi);return()=>{clearTimeout(G),U.abort()}},[L]);const V=X&&!(I.state==="done"&&I.value.some(M=>M.fullName.toLowerCase()===u.trim().toLowerCase()));i.useEffect(()=>{if(V)return;if(r!=="github"||!Gi.test(u.trim())){g({state:"idle"}),$.current=null;return}const M=$.current;if(M&&M.repo===u&&M.branch===f)return;const U=new AbortController;g({state:"loading"});const G=setTimeout(()=>{Hl(u.trim(),f||void 0,U.signal).then(K=>{g({state:"done",value:K});const fe=K.ok&&!f?K.branch:f;$.current={repo:u,branch:fe},fe!==f&&k(fe)}).catch(K=>{K.name!=="AbortError"&&g({state:"failed",error:K.message})})},Xs);return()=>{clearTimeout(G),U.abort()}},[r,u,f,V]);const T=c.trim()===""||h.state==="done"&&h.value.ok,W=i.useMemo(()=>r==="local"?T?{kind:"local"}:null:j.state!=="done"||!j.value.ok?null:{kind:"github",repo:j.value.repo.fullName,branch:j.value.branch},[r,j,T]),J=r==="local"?c.trim():void 0,be=W?JSON.stringify([W,J]):null;i.useEffect(()=>{if(!W){N({state:"idle"});return}const M=new AbortController;N({state:"loading"});const U=setTimeout(()=>{Bl(t,W,J,M.signal).then(G=>N({state:"done",value:G})).catch(G=>{G.name!=="AbortError"&&N({state:"failed",error:G.message})})},qi);return()=>{clearTimeout(U),M.abort()}},[t,be]);const ce=M=>{p(M),k(""),S(M),B(!0)},Fe=M=>{p(M),k(""),S(""),B(!1)},ye=I.state==="done"?I.value:[],Ee=X&&I.state!=="idle",Ne=M=>{Ee&&(M.key==="ArrowDown"?(M.preventDefault(),D(U=>Math.min(ye.length-1,U+1))):M.key==="ArrowUp"?(M.preventDefault(),D(U=>Math.max(0,U-1))):M.key==="Enter"&&ye[q]?(M.preventDefault(),Fe(ye[q].fullName)):M.key==="Escape"&&(M.stopPropagation(),B(!1)))},at=async()=>{if(W){R(!0),y(null);try{await Wl(t,W,J),s()}catch(M){y(M.message),R(!1)}}},$e=a?.defaultCodeRoot??(a?.codeRootOrigin==="default"?a.codeRoot:void 0),Oe=h.state==="failed"?h.error:h.state==="done"&&!h.value.ok?h.value.error:null,te=j.state==="done"?j.value:null,pe=te?.repo,de=te?.branches??[],Re=j.state==="failed"?j.error:te&&!te.ok&&te.field==="repo"?te.error:null,Pe=Ee?null:Re,Me=te&&!te.ok&&te.field==="branch"?te.error:null,we=f&&!de.includes(f)?[f,...de]:de;return e.jsx("div",{className:"modal-overlay",onClick:s,children:e.jsxs("div",{className:"project-settings",onClick:M=>M.stopPropagation(),role:"dialog","aria-label":"Project settings",children:[e.jsxs("header",{className:"ps-header",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"ps-title",children:"Project settings"}),e.jsxs("div",{className:"ps-subtitle",children:[e.jsx(Qn,{size:13}),t]})]}),e.jsx("button",{className:"ps-close",onClick:s,title:"Close (Esc)",children:e.jsx(rn,{size:18})})]}),e.jsxs("div",{className:"ps-body",children:[a?.error&&!a.config&&e.jsxs("div",{className:"ps-alert error",children:[e.jsx(vl,{size:14}),e.jsxs("span",{children:["The saved settings cannot be read: ",a.error,". Applying replaces them."]})]}),e.jsx("div",{className:"ps-section-label",children:"Where is the code read from?"}),e.jsxs("div",{className:"ps-modes",role:"radiogroup",children:[e.jsxs("button",{className:`ps-mode${r==="local"?" selected":""}`,role:"radio","aria-checked":r==="local",disabled:n,onClick:()=>l("local"),children:[e.jsx(gs,{size:16,className:"ps-mode-icon"}),e.jsxs("span",{className:"ps-mode-text",children:[e.jsx("span",{className:"ps-mode-title",children:"Local working copy"}),e.jsx("span",{className:"ps-mode-desc",children:"Current checkout, uncommitted work included"})]}),r==="local"&&e.jsx(Je,{size:16,className:"ps-mode-check"})]}),e.jsxs("button",{className:`ps-mode${r==="github"?" selected":""}`,role:"radio","aria-checked":r==="github",disabled:n,onClick:()=>l("github"),children:[e.jsx(fs,{size:16,className:"ps-mode-icon"}),e.jsxs("span",{className:"ps-mode-text",children:[e.jsx("span",{className:"ps-mode-title",children:"GitHub repository"}),e.jsx("span",{className:"ps-mode-desc",children:"Published code of one branch"})]}),r==="github"&&e.jsx(Je,{size:16,className:"ps-mode-check"})]})]}),r==="local"&&e.jsxs("label",{className:"ps-field",children:[e.jsx("span",{className:"ps-label",children:"Code root on this machine"}),e.jsxs("span",{className:`ps-input-wrap${Oe?" invalid":""}`,children:[e.jsx(Dt,{size:14,className:"ps-input-icon"}),e.jsx("input",{className:"ps-input",value:c,placeholder:$e?`Machine default: ${$e}`:"Absolute path of the repository",autoFocus:!0,disabled:n,onChange:M=>d(M.target.value)}),h.state==="loading"&&e.jsx(qt,{size:14,className:"ps-input-status spinning"}),h.state==="done"&&h.value.ok&&e.jsx(Je,{size:14,className:"ps-input-status ok"}),!n&&c!==""&&e.jsx("button",{type:"button",className:"ps-link muted ps-input-action",onClick:()=>d(""),children:"Use default"})]}),Oe?e.jsx("span",{className:"ps-help error",children:Oe}):c.trim()!==""?h.state==="done"?e.jsx("span",{className:"ps-help ok",children:"Folder found · used by this project only, on this machine"}):e.jsx("span",{className:"ps-help",children:"Checked as you type."}):$e?e.jsx("span",{className:"ps-help",children:"Uses the machine default. Stored on this machine only, never synced."}):e.jsx("span",{className:"ps-help",children:"No code root on this machine: only tracked files stored with an absolute path can be read."})]}),r==="github"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"ps-field",children:[e.jsx("label",{className:"ps-label",htmlFor:"ps-repo-input",children:"Repository"}),e.jsxs("div",{className:"ps-combobox",children:[e.jsxs("span",{className:`ps-input-wrap${Pe?" invalid":""}`,children:[pe?e.jsx(Nt,{size:14,className:"ps-input-icon"}):e.jsx(nt,{size:14,className:"ps-input-icon"}),e.jsx("input",{id:"ps-repo-input",className:"ps-input",value:u,placeholder:"Search a repository, or paste owner/repo",autoFocus:!0,autoComplete:"off",disabled:n,role:"combobox","aria-expanded":Ee,"aria-controls":"ps-repo-suggestions",onChange:M=>ce(M.target.value),onKeyDown:Ne,onFocus:()=>B(!0),onBlur:()=>B(!1)}),(j.state==="loading"||I.state==="loading")&&e.jsx(qt,{size:14,className:"ps-input-status spinning"}),j.state!=="loading"&&I.state!=="loading"&&pe&&!Pe&&e.jsx(Je,{size:14,className:"ps-input-status ok"})]}),Ee&&e.jsxs("ul",{className:"ps-suggestions",id:"ps-repo-suggestions",role:"listbox",children:[I.state==="loading"&&e.jsx("li",{className:"ps-suggestion-note",children:"Searching…"}),I.state==="failed"&&e.jsx("li",{className:"ps-suggestion-note error",children:I.error}),I.state==="done"&&ye.length===0&&e.jsx("li",{className:"ps-suggestion-note",children:"No repository found"}),ye.map((M,U)=>e.jsxs("li",{role:"option","aria-selected":U===q,className:`ps-suggestion${U===q?" highlighted":""}`,onMouseEnter:()=>D(U),onMouseDown:G=>{G.preventDefault(),Fe(M.fullName)},children:[e.jsxs("span",{className:"ps-suggestion-name",children:[M.private?e.jsx(El,{size:12}):e.jsx(Nt,{size:12}),M.fullName]}),M.description&&e.jsx("span",{className:"ps-suggestion-desc",children:M.description})]},M.fullName))]})]}),Pe?e.jsx("span",{className:"ps-help error",children:Pe}):pe?e.jsxs("span",{className:"ps-help ok",children:["Found · ",pe.private?"private":"public"," · default branch ",pe.defaultBranch]}):e.jsxs("span",{className:"ps-help",children:["Searched as you type",x.state==="done"&&x.value.configured?", private repositories included":"","."]})]}),e.jsxs("label",{className:"ps-field",children:[e.jsx("span",{className:"ps-label",children:"Branch"}),e.jsxs("span",{className:`ps-input-wrap${Me?" invalid":""}`,children:[e.jsx(Nl,{size:14,className:"ps-input-icon"}),e.jsxs("select",{className:"ps-input ps-select",value:f,disabled:n||we.length===0,onChange:M=>k(M.target.value),children:[we.length===0&&e.jsx("option",{value:"",children:"—"}),we.map(M=>e.jsxs("option",{value:M,children:[M,M===pe?.defaultBranch?" (default)":""]},M))]}),f&&f===pe?.defaultBranch&&e.jsx("span",{className:"ps-chip",children:"default"})]}),Me?e.jsx("span",{className:"ps-help error",children:Me}):te?.ok?e.jsxs("span",{className:"ps-help",children:["Head ",te.head.sha.slice(0,7)," · ",te.head.message," · ",Ki(te.head.date)]}):null]}),e.jsxs("div",{className:"ps-field",children:[e.jsx("span",{className:"ps-label",children:"GitHub access"}),e.jsxs("span",{className:"ps-token",children:[e.jsx(Sl,{size:14,className:`ps-token-icon${x.state==="done"&&x.value.login?" ok":x.state==="done"&&x.value.error?" error":""}`}),e.jsxs("span",{className:"ps-token-text",children:[x.state==="loading"&&"Checking the token…",x.state==="failed"&&x.error,x.state==="done"&&(x.value.configured?x.value.login?`${x.value.variable} · connected as ${x.value.login}`:`${x.value.variable} rejected — ${x.value.error}`:`${x.value.variable} is not set · public repositories only`)]})]}),e.jsx("span",{className:"ps-help",children:"Set in the MCP server's environment variables only — not editable here."})]})]}),b.state!=="idle"&&e.jsxs("div",{className:`ps-preview${b.state==="failed"||b.state==="done"&&b.value.sourceError?" error":""}`,children:[b.state==="loading"?e.jsx(qt,{size:16,className:"ps-preview-icon spinning"}):e.jsx(Pl,{size:16,className:"ps-preview-icon"}),e.jsxs("div",{className:"ps-preview-text",children:[b.state==="loading"&&e.jsx("span",{className:"ps-preview-title",children:"Checking the docs against this source…"}),b.state==="failed"&&e.jsx("span",{className:"ps-preview-title",children:b.error}),b.state==="done"&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"ps-preview-title",children:["Checked against ",b.value.label," — ",b.value.docs," doc",b.value.docs===1?"":"s"]}),e.jsx("span",{className:"ps-preview-counts",children:b.value.sourceError?b.value.sourceError:[`${b.value.upToDate} up to date`,`${b.value.stale} would be outdated`,`${b.value.unverifiable} unverifiable`,...b.value.broken>0?[`${b.value.broken} with broken tracking`]:[]].join(" · ")})]})]})]})]}),e.jsxs("footer",{className:"ps-footer",children:[e.jsxs("div",{className:"ps-footer-note",children:[e.jsx(kl,{size:14}),e.jsxs("span",{children:["Source saved with the docs, shared across machines.",e.jsx("br",{}),"Applied at once — no restart."]})]}),E&&e.jsx("span",{className:"ps-help error ps-save-error",children:E}),e.jsx("button",{className:"ps-btn",onClick:s,children:"Cancel"}),!n&&e.jsx("button",{className:"ps-btn primary",onClick:at,disabled:!W||w,children:w?"Applying…":"Apply"})]})]})})}function Yi({entry:t}){return t.status!=="imported"?e.jsx(xs,{size:14,className:"mig-icon warn"}):t.kind==="code-root"?e.jsx(Dt,{size:14,className:"mig-icon"}):t.kind==="local"?e.jsx(gs,{size:14,className:"mig-icon"}):e.jsx(fs,{size:14,className:"mig-icon accent"})}function Xi({onClose:t,onReviewProject:s}){const[n,a]=i.useState(null),[o,r]=i.useState(null),[l,c]=i.useState(!1);i.useEffect(()=>{Pa().then(a).catch(u=>r(u.message))},[]);const d=u=>{Jl().catch(()=>{}).finally(()=>{t(),u?.()})};i.useEffect(()=>{const u=p=>{p.key==="Escape"&&d()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[]);const h=async()=>{if(n)try{await navigator.clipboard.writeText(n.variables.join(`
7
+ `)),c(!0),setTimeout(()=>c(!1),1500)}catch{}},m=n?.entries.find(u=>u.status==="imported"&&u.project)?.project;return e.jsx("div",{className:"modal-overlay",onClick:()=>d(),children:e.jsxs("div",{className:"migration-report",onClick:u=>u.stopPropagation(),role:"dialog","aria-label":"Code source settings imported",children:[e.jsxs("header",{className:"mig-header",children:[e.jsx("span",{className:"mig-badge",children:e.jsx(Cl,{size:18})}),e.jsxs("div",{children:[e.jsx("h2",{className:"mig-title",children:"Code source settings imported"}),e.jsx("p",{className:"mig-subtitle",children:"Found in this server's environment. They now live in each project's settings."})]})]}),o&&e.jsx("div",{className:"ps-alert error mig-error",children:o}),n&&e.jsxs(e.Fragment,{children:[n.entries.length>0&&e.jsxs("table",{className:"mig-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Project"}),e.jsx("th",{children:"Now configured as"}),e.jsx("th",{children:"From"})]})}),e.jsx("tbody",{children:n.entries.map((u,p)=>e.jsxs("tr",{className:u.status!=="imported"?"not-imported":void 0,children:[e.jsx("td",{className:u.project?void 0:"mig-scope",children:u.project??"This machine"}),e.jsx("td",{children:e.jsxs("span",{className:"mig-source",children:[e.jsx(Yi,{entry:u}),u.detail]})}),e.jsx("td",{className:"mig-from",children:u.from})]},p))})]}),e.jsxs("div",{className:"mig-callout",children:[e.jsxs("div",{className:"mig-callout-text",children:[e.jsx("span",{className:"mig-callout-title",children:"These variables are no longer read"}),e.jsx("span",{className:"mig-callout-desc",children:"Remove them from the env block of .mcp.json. Until then, the server ignores them and says so in its log."}),e.jsx("pre",{className:"mig-vars",children:n.variables.join(`
8
+ `)})]}),e.jsx("button",{className:"mig-copy",onClick:h,title:"Copy the list",children:l?e.jsx(Se,{size:14}):e.jsx(Pt,{size:14})})]})]}),e.jsxs("footer",{className:"mig-footer",children:[e.jsx("span",{className:"mig-footer-note",children:"This report stays in Settings."}),m&&e.jsx("button",{className:"ps-btn",onClick:()=>d(()=>s(m)),children:"Review project settings"}),e.jsx("button",{className:"ps-btn primary",onClick:()=>d(),children:"Done"})]})]})})}function rs({tone:t,children:s,wide:n}){return e.jsx("span",{className:`logs-badge logs-badge--${t}${n?" logs-badge--wide":""}`,children:s})}function Ja({source:t,title:s,meta:n,following:a,onToggleFollow:o}){const[r,l]=i.useState(null),c=async()=>{l(null);try{await Ii()}catch(d){l(d instanceof Error?d.message:String(d))}};return e.jsxs("div",{className:"logs-page-header",children:[e.jsxs("div",{className:"logs-page-heading",children:[e.jsxs("div",{className:"logs-breadcrumb",children:["Logs  /  ",s]}),e.jsx("h2",{className:"logs-title",children:s}),e.jsx("div",{className:"logs-file-meta",children:n}),r&&e.jsx("div",{className:"logs-inline-error",children:r})]}),e.jsxs("div",{className:"logs-actions",children:[e.jsxs("button",{className:`logs-btn logs-follow-btn${a?" active":""}`,onClick:o,title:a?"Stop following new lines":"Follow new lines as they are written",children:[e.jsx("span",{className:"logs-live-dot"}),a?"Following":"Paused"]}),e.jsxs("button",{className:"logs-btn",onClick:c,title:"Open the log directory on the server machine",children:[e.jsx(Dt,{size:14}),"Open folder"]}),e.jsxs("a",{className:"logs-btn",href:Ai(t),download:!0,title:"Download the whole file",children:[e.jsx(bl,{size:14}),"Download"]})]})]})}function Ya({value:t,onChange:s,placeholder:n}){return e.jsxs("label",{className:"logs-search",children:[e.jsx(nt,{size:14}),e.jsx("input",{value:t,onChange:a=>s(a.target.value),placeholder:n,spellCheck:!1})]})}function Xa({options:t,value:s,onChange:n}){return e.jsx("div",{className:"logs-segmented",role:"tablist",children:t.map(a=>e.jsxs("button",{role:"tab","aria-selected":a.value===s,className:`logs-segment logs-tone--${a.tone??"neutral"}${a.value===s?" active":""}`,onClick:()=>n(a.value),children:[a.label,e.jsx("span",{className:"logs-segment-count",children:a.count.toLocaleString("fr-FR")})]},a.value))})}function Ze({value:t,onChange:s,options:n,prefix:a,withClock:o,width:r}){const l=n.find(c=>c.value===t)?.label??t;return e.jsxs("label",{className:"logs-select",style:{width:r},children:[o&&e.jsx(Un,{size:14}),e.jsxs("span",{className:"logs-select-value",children:[a?`${a}: `:"",l]}),e.jsx(Rt,{size:12}),e.jsx("select",{value:t,onChange:c=>s(c.target.value),children:n.map(c=>e.jsx("option",{value:c.value,children:c.label},c.value))})]})}function Qi(t,s){if(t===null)return"not loaded yet";const n=Math.max(0,Math.round((s-t)/1e3));return n<60?`updated ${n} s ago`:`updated ${Math.round(n/60)} min ago`}function Qa({following:t,text:s,checkedAt:n,error:a}){const o=Fi();return e.jsxs("div",{className:"logs-status",children:[e.jsx("span",{className:`logs-live-dot${t?"":" paused"}`}),a?e.jsx("span",{className:"logs-status-error",children:a}):e.jsxs("span",{children:[s," · ",Qi(n,o)]}),e.jsx("span",{className:"logs-status-order",children:"Newest at the bottom"})]})}function Za({contentKey:t,className:s,children:n}){const a=i.useRef(null),o=i.useRef(!0);i.useLayoutEffect(()=>{const l=a.current;l&&o.current&&(l.scrollTop=l.scrollHeight)},[t]);const r=()=>{const l=a.current;l&&(o.current=l.scrollHeight-l.scrollTop-l.clientHeight<40)};return e.jsx("div",{className:s,ref:a,onScroll:r,children:n})}const Zi=["today","day","week","all"];function ec(t){return t.ok?"ok":t.status==="404"||t.status==="422"?"warn":"error"}function tc(t){return t.status==="ok"?"OK":t.status==="rejected"?"Rejected":t.status==="failed"?"Failed":t.status==="network error"?"Network":t.status}function sc(t){return i.useMemo(()=>{const s=t.filter(c=>Tt(c.ts)),n=s.filter(c=>!c.ok),a=new Map;for(const c of n)a.set(c.status,(a.get(c.status)??0)+1);const o=s.reduce((c,d)=>!c||d.durationMs>c.durationMs?d:c,null),r=s.length?Math.round(s.reduce((c,d)=>c+d.durationMs,0)/s.length):null,l=[...t].reverse().find(c=>c.rateLimit)?.rateLimit??null;return{total:s.length,git:s.filter(c=>c.kind==="git").length,api:s.filter(c=>c.kind==="api").length,failed:n.length,failureSummary:[...a].map(([c,d])=>`${d} × ${c}`).join(" · "),average:r,slowest:o,rate:l}},[t])}function nc(t){const s=`GET /repos/${t.repo}/`;return!t.repo||!t.command.startsWith(s)?t.command:`GET /repos/…/${t.command.slice(s.length)}`}function ac({data:t,error:s,checkedAt:n,following:a,onToggleFollow:o}){const[r,l]=i.useState(""),[c,d]=i.useState("all"),[h,m]=i.useState("all"),[u,p]=i.useState("all"),[f,k]=i.useState("today"),[j,g]=i.useState(new Set),[b,N]=i.useState(null),x=i.useMemo(()=>t?.entries??[],[t]),v=sc(x),w=i.useMemo(()=>[...new Set(x.map(D=>D.trigger))].sort((D,V)=>D.localeCompare(V)),[x]),R=i.useMemo(()=>{const D=r.trim().toLowerCase();return x.filter(V=>Ga(V.ts,f)&&(h==="all"||h==="ok"===V.ok)&&(u==="all"||V.trigger===u)&&(!D||V.action.toLowerCase().includes(D)||V.command.toLowerCase().includes(D)||(V.repo??"").toLowerCase().includes(D)||(V.error??"").toLowerCase().includes(D)))},[x,r,f,h,u]),E=i.useMemo(()=>c==="all"?R:R.filter(D=>D.kind===c),[R,c]),y=E.slice(-1e3),$=`${t?.file.size}:${y.length}:${c}:${h}:${u}:${f}:${r}`,L=D=>g(V=>{const T=new Set(V);return T.has(D)?T.delete(D):T.add(D),T}),S=async(D,V)=>{try{await navigator.clipboard.writeText(D.raw),N(V),setTimeout(()=>N(T=>T===V?null:T),1500)}catch{}},I=t?.file,z=I?I.exists?`${I.path} · ${Qe(I.size)} · one line per call to GitHub`:`${I.path} · no call to GitHub recorded yet`:"Loading…",X=`${a?"Following new calls":"Paused"} · ${ee(E.length)} of ${ee(x.length)} calls match`+(E.length>y.length?` · showing the latest ${ee(y.length)}`:"")+(t?.unreadable?` · ${t.unreadable} unreadable`:""),B=v.rate,q=B?.reset?new Date(B.reset):null;return e.jsxs("div",{className:"logs-panel",children:[e.jsx(Ja,{source:"github",title:"GitHub access",meta:z,following:a,onToggleFollow:o}),e.jsxs("div",{className:"logs-stats",children:[e.jsxs("div",{className:"logs-stat",children:[e.jsx("div",{className:"logs-stat-label",children:"Calls today"}),e.jsxs("div",{className:"logs-stat-row",children:[e.jsx("span",{className:"logs-stat-value",children:ee(v.total)}),e.jsxs("span",{className:"logs-stat-detail",children:[ee(v.git)," git · ",ee(v.api)," REST API"]})]})]}),e.jsxs("div",{className:"logs-stat",children:[e.jsx("div",{className:"logs-stat-label",children:"Failed"}),e.jsxs("div",{className:"logs-stat-row",children:[e.jsx("span",{className:`logs-stat-value${v.failed?" error":""}`,children:ee(v.failed)}),e.jsx("span",{className:"logs-stat-detail",children:v.failed?v.failureSummary:"no failure today"})]})]}),e.jsxs("div",{className:"logs-stat",children:[e.jsx("div",{className:"logs-stat-label",children:"Average duration"}),e.jsxs("div",{className:"logs-stat-row",children:[e.jsx("span",{className:"logs-stat-value",children:v.average===null?"—":pt(v.average)}),v.slowest&&e.jsxs("span",{className:"logs-stat-detail",title:v.slowest.command,children:["slowest: ",v.slowest.kind==="git"?v.slowest.command.split(" ").slice(0,2).join(" "):v.slowest.action," ",pt(v.slowest.durationMs)]})]})]}),e.jsxs("div",{className:"logs-stat",children:[e.jsxs("div",{className:"logs-stat-label",children:["API rate limit",q&&e.jsxs("span",{className:"logs-stat-aside",children:["resets ",q.toLocaleTimeString("fr-FR",{hour:"2-digit",minute:"2-digit"})]})]}),B?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"logs-stat-value small",children:[ee(B.remaining)," / ",ee(B.limit)]}),e.jsx("div",{className:"logs-gauge",children:e.jsx("div",{className:`logs-gauge-fill${B.remaining/B.limit<.1?" low":""}`,style:{width:`${Math.max(0,Math.min(100,B.remaining/B.limit*100))}%`}})})]}):e.jsxs("div",{className:"logs-stat-row",children:[e.jsx("span",{className:"logs-stat-value small",children:"—"}),e.jsx("span",{className:"logs-stat-detail",children:"known after the next API call"})]})]})]}),e.jsxs("div",{className:"logs-toolbar",children:[e.jsx(Ya,{value:r,onChange:l,placeholder:"Filter by command, path, repository…"}),e.jsx(Xa,{value:c,onChange:d,options:[{value:"all",label:"All",count:R.length},{value:"git",label:"Git",count:R.filter(D=>D.kind==="git").length,tone:"git"},{value:"api",label:"REST API",count:R.filter(D=>D.kind==="api").length,tone:"info"}]}),e.jsx("div",{className:"logs-toolbar-spacer"}),e.jsx(Ze,{value:h,onChange:m,prefix:"Status",width:130,options:[{value:"all",label:"all"},{value:"ok",label:"succeeded"},{value:"failed",label:"failed"}]}),e.jsx(Ze,{value:u,onChange:p,prefix:"Triggered by",width:200,options:[{value:"all",label:"all"},...w.map(D=>({value:D,label:D}))]}),e.jsx(Ze,{value:f,onChange:k,withClock:!0,width:150,options:Zi.map(D=>({value:D,label:qa[D]}))})]}),e.jsxs("div",{className:"logs-table",children:[e.jsxs("div",{className:"logs-table-head logs-github-grid",children:[e.jsx("span",{children:"Time"}),e.jsx("span",{children:"Kind"}),e.jsx("span",{children:"What was done"}),e.jsx("span",{children:"Repository"}),e.jsx("span",{children:"Triggered by"}),e.jsx("span",{children:"Status"}),e.jsx("span",{className:"align-right",children:"Duration"})]}),e.jsxs(Za,{className:"logs-table-body",contentKey:$,children:[y.length===0&&e.jsx("div",{className:"logs-empty",children:t?x.length?"No call matches these filters.":"No call to GitHub recorded yet.":s?"":"Loading…"}),y.map((D,V)=>{const T=`${D.ts}|${E.length-y.length+V}`,W=j.has(T),J=ec(D);return e.jsxs("div",{className:`logs-row logs-row--tall${W?` open logs-row--${J==="ok"?"info":J}`:""}`,children:[e.jsxs("button",{className:"logs-row-line logs-github-grid",onClick:()=>L(T),title:D.ts,children:[e.jsx("span",{className:"logs-cell-time",children:Va(D.ts)}),e.jsx("span",{children:e.jsx(rs,{tone:D.kind==="git"?"git":"info",children:D.kind==="git"?"GIT":"API"})}),e.jsxs("span",{className:"logs-cell-what",children:[e.jsx("span",{className:"logs-cell-action",children:D.action}),e.jsx("span",{className:"logs-cell-command",title:D.command,children:nc(D)})]}),e.jsx("span",{className:`logs-cell-repo${D.repo?"":" muted"}`,children:D.repo??"—"}),e.jsx("span",{className:"logs-cell-trigger",children:D.trigger}),e.jsx("span",{children:e.jsx(rs,{tone:J,wide:!0,children:tc(D)})}),e.jsx("span",{className:"logs-cell-duration",children:pt(D.durationMs)}),W?e.jsx(Mn,{size:12,className:"logs-row-chevron"}):e.jsx(Rt,{size:12,className:"logs-row-chevron hover-only"})]}),W&&e.jsxs("div",{className:"logs-row-detail logs-detail--github",children:[e.jsxs("div",{className:"logs-detail-main",children:[e.jsx("div",{className:"logs-detail-text",children:D.ok?`Completed in ${pt(D.durationMs)}.`:D.error??"Failed without an error message."}),e.jsx("pre",{className:"logs-detail-context",children:[`time ${D.ts}`,`command ${D.command}`,`trigger ${D.trigger}`,...D.rateLimit?[`quota ${ee(D.rateLimit.remaining)} / ${ee(D.rateLimit.limit)} requests left`]:[]].join(`
9
+ `)})]}),e.jsxs("button",{className:"logs-btn logs-btn--small",onClick:()=>S(D,T),children:[b===T?e.jsx(Se,{size:12}):e.jsx(Pt,{size:12}),b===T?"Copied":"Copy log line"]})]})]},T)})]})]}),e.jsx(Qa,{following:a,text:X,checkedAt:n,error:s})]})}const Xt={DEBUG:"neutral",INFO:"info",WARN:"warn",ERROR:"error"},oc=["DEBUG","INFO","WARN","ERROR"],rc=["hour","day","week","all"],lc="GitHub";function ic({data:t,error:s,checkedAt:n,following:a,onToggleFollow:o}){const r=re(),[l,c]=i.useState(""),[d,h]=i.useState("all"),[m,u]=i.useState("all"),[p,f]=i.useState("day"),[k,j]=i.useState(new Set),g=i.useMemo(()=>t?.entries??[],[t]),b=i.useMemo(()=>[...new Set(g.map(S=>S.scope))].sort((S,I)=>S.localeCompare(I)),[g]),N=i.useMemo(()=>{const S=l.trim().toLowerCase();return g.filter(I=>(m==="all"||I.scope===m)&&Ga(I.ts,p)&&(!S||I.message.toLowerCase().includes(S)||I.scope.toLowerCase().includes(S)||I.continuation.some(z=>z.toLowerCase().includes(S))))},[g,l,m,p]),x=i.useMemo(()=>{const S={DEBUG:0,INFO:0,WARN:0,ERROR:0};for(const I of N)S[I.level]++;return S},[N]),v=i.useMemo(()=>d==="all"?N:N.filter(S=>S.level===d),[N,d]),w=v.slice(-1500),R=`${t?.file.size}:${w.length}:${d}:${m}:${p}:${l}`,E=S=>j(I=>{const z=new Set(I);return z.has(S)?z.delete(S):z.add(S),z}),y=t?.file,$=y?y.exists?`${y.path} · ${Qe(y.size)} · ${t.partial?`last ${ee(g.length)} lines`:`${ee(g.length)} lines`}`:`${y.path} · not written yet`:"Loading…",L=`${a?"Following new lines":"Paused"} · ${ee(v.length)} of ${ee(g.length)} lines match`+(v.length>w.length?` · showing the latest ${ee(w.length)}`:"")+(t?.unreadable?` · ${t.unreadable} unreadable`:"");return e.jsxs("div",{className:"logs-panel",children:[e.jsx(Ja,{source:"server",title:"Full log",meta:$,following:a,onToggleFollow:o}),e.jsxs("div",{className:"logs-toolbar",children:[e.jsx(Ya,{value:l,onChange:c,placeholder:"Filter messages, tools, paths…"}),e.jsx(Xa,{value:d,onChange:h,options:[{value:"all",label:"All",count:N.length},...oc.map(S=>({value:S,label:S[0]+S.slice(1).toLowerCase(),count:x[S],tone:Xt[S]}))]}),e.jsx("div",{className:"logs-toolbar-spacer"}),e.jsx(Ze,{value:m,onChange:u,prefix:"Source",width:150,options:[{value:"all",label:"all"},...b.map(S=>({value:S,label:S}))]}),e.jsx(Ze,{value:p,onChange:f,withClock:!0,width:150,options:rc.map(S=>({value:S,label:qa[S]}))})]}),e.jsxs("div",{className:"logs-table",children:[e.jsxs("div",{className:"logs-table-head logs-server-grid",children:[e.jsx("span",{children:"Time"}),e.jsx("span",{children:"Level"}),e.jsx("span",{children:"Source"}),e.jsx("span",{children:"Message"})]}),e.jsxs(Za,{className:"logs-table-body",contentKey:R,children:[w.length===0&&e.jsx("div",{className:"logs-empty",children:t?"No line matches these filters.":s?"":"Loading…"}),w.map((S,I)=>{const z=`${S.ts}|${S.pid}|${v.length-w.length+I}`,X=k.has(z),B=S.scope===lc;return e.jsxs("div",{className:`logs-row${X?` open logs-row--${Xt[S.level]}`:""}`,children:[e.jsxs("button",{className:"logs-row-line logs-server-grid",onClick:()=>E(z),title:S.ts,children:[e.jsx("span",{className:"logs-cell-time",children:Va(S.ts)}),e.jsx("span",{children:e.jsx(rs,{tone:Xt[S.level],children:S.level})}),e.jsx("span",{className:`logs-cell-scope${B?" github":""}`,children:S.scope}),e.jsxs("span",{className:`logs-cell-message logs-level-text--${S.level.toLowerCase()}`,children:[S.message,S.continuation.length>0&&!X&&e.jsxs("span",{className:"logs-more",children:[" +",S.continuation.length," lines"]})]}),X?e.jsx(Mn,{size:12,className:"logs-row-chevron"}):e.jsx(Rt,{size:12,className:"logs-row-chevron hover-only"})]}),X&&e.jsxs("div",{className:"logs-row-detail logs-detail--server",children:[e.jsx("pre",{className:"logs-detail-context",children:[`time ${S.ts}`,`process ${S.process} · PID ${S.pid}`,`scope ${S.scope}`,"",S.message,...S.continuation].join(`
10
+ `)}),B&&e.jsxs("button",{className:"logs-link",onClick:()=>r(Ct("github")),children:[e.jsx(Nt,{size:12}),"Open in GitHub log"]})]})]},z)})]})]}),e.jsx(Qa,{following:a,text:L,checkedAt:n,error:s})]})}function cc({source:t}){const s=re(),[n,a]=i.useState(!0),o=()=>a(p=>!p),{directory:r}=zi(n),l=os("server",t==="server",n),c=os("github",!0,n),d=i.useMemo(()=>new Map((r?.files??[]).map(p=>[p.id,p])),[r]),h=i.useMemo(()=>{const p=(c.data?.entries??[]).filter(f=>Tt(f.ts));return{calls:p.length,failed:p.filter(f=>!f.ok).length}},[c.data]),m=d.get("server"),u=d.get("github");return e.jsxs("div",{className:"logs-view",children:[e.jsxs("aside",{className:"logs-sidebar",children:[e.jsx("div",{className:"logs-sidebar-label",children:"Server"}),e.jsxs("button",{className:`logs-source${t==="server"?" active":""}`,onClick:()=>s(Ct("server")),children:[e.jsx(ga,{size:16,className:"logs-source-icon"}),e.jsxs("span",{className:"logs-source-text",children:[e.jsx("span",{className:"logs-source-title",children:"Full log"}),e.jsxs("span",{className:"logs-source-sub",children:["server.log · ",m?Qe(m.size):"…"," · every event"]})]}),t==="server"&&n&&e.jsx("span",{className:"logs-live-dot",title:"Following"})]}),e.jsx("div",{className:"logs-sidebar-label",children:"Specific logs"}),e.jsxs("button",{className:`logs-source${t==="github"?" active":""}`,onClick:()=>s(Ct("github")),children:[e.jsx(Nt,{size:16,className:"logs-source-icon"}),e.jsxs("span",{className:"logs-source-text",children:[e.jsx("span",{className:"logs-source-title",children:"GitHub access"}),e.jsxs("span",{className:"logs-source-sub",children:["github.log · ",ee(h.calls)," call",h.calls===1?"":"s"," today"]})]}),h.failed>0&&e.jsxs("span",{className:"logs-source-badge",children:[h.failed," failed"]}),t==="github"&&n&&h.failed===0&&e.jsx("span",{className:"logs-live-dot",title:"Following"})]}),e.jsxs("div",{className:"logs-sidebar-footer",children:[e.jsx("div",{className:"logs-sidebar-label",children:"Log directory"}),e.jsx("div",{className:"logs-dir",title:r?.dir,children:r?.dir??"…"}),e.jsxs("div",{className:"logs-dir-sizes",children:["server.log ",m?Qe(m.size):"—"," · github.log"," ",u?.exists?Qe(u.size):"not written yet"]})]})]}),e.jsx("main",{className:"logs-main",children:t==="server"?e.jsx(ic,{...l,following:n,onToggleFollow:o}):e.jsx(ac,{...c,following:n,onToggleFollow:o})})]})}function dc(){const{currentProject:t,readOnly:s}=Y(),{publications:n,error:a,reload:o}=Oa(t),[r,l]=i.useState("all"),c=n??[],d=c.filter(u=>u.status==="modified").length,m=[...r==="modified"?c.filter(u=>u.status==="modified"):c].sort((u,p)=>u.title.localeCompare(p.title));return e.jsxs("div",{className:"pubs-view",children:[e.jsxs("header",{className:"pubs-header",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"pubs-title",children:"Publications"}),e.jsx("div",{className:"pubs-subtitle",children:n===null?"Loading…":`${c.length} document${c.length===1?"":"s"} published in ${t}`+(d>0?` · ${d} changed since published`:"")})]}),e.jsxs("div",{className:"pubs-filter",role:"tablist",children:[e.jsxs("button",{className:r==="all"?"active":"",onClick:()=>l("all"),children:["All · ",c.length]}),e.jsxs("button",{className:r==="modified"?"active":"",onClick:()=>l("modified"),children:["Changed · ",d]})]})]}),a&&e.jsx("div",{className:"publish-error pubs-load-error",children:a}),n!==null&&c.length===0&&e.jsxs("div",{className:"pubs-empty",children:[e.jsx(Lt,{size:28}),e.jsxs("div",{children:["No published document in ",t,"."]}),e.jsx("div",{className:"pubs-empty-hint",children:"Publish one from the toolbar of the document."})]}),c.length>0&&e.jsxs("div",{className:"pubs-table",children:[e.jsxs("div",{className:"pubs-row pubs-row--head",children:[e.jsx("span",{children:"Document"}),e.jsx("span",{children:"Version note"}),e.jsx("span",{children:"Published"}),e.jsx("span",{children:"State"}),e.jsx("span",{})]}),m.map(u=>e.jsx(hc,{publication:u,readOnly:s,onChanged:o},u.id)),m.length===0&&e.jsx("div",{className:"pubs-row-empty",children:"No publication changed since it was published."})]})]})}function uc({publication:t}){return t.status==="missing"?e.jsx("span",{className:"pubs-badge pubs-badge--missing",children:"Document removed"}):t.status==="modified"?e.jsxs("span",{className:"pubs-badge pubs-badge--modified",children:["Changed · ",Te(t.version)," → ",Te(t.currentVersion)]}):e.jsxs("span",{className:"pubs-badge pubs-badge--current",children:["Up to date · ",Te(t.version)]})}function hc({publication:t,readOnly:s,onChanged:n}){const a=re(),{copied:o,copy:r}=Fa(),[l,c]=i.useState("idle"),[d,h]=i.useState(""),[m,u]=i.useState(!1),[p,f]=i.useState(null),k=an(t.token),j=t.docId.includes("/")?t.docId.slice(0,t.docId.lastIndexOf("/")):"",g=async b=>{u(!0),f(null);try{await b(),c("idle"),h(""),n()}catch(N){f(N instanceof Error?N.message:String(N))}finally{u(!1)}};return e.jsxs("div",{className:`pubs-row-wrap${l!=="idle"?" pubs-row-wrap--active":""}`,children:[e.jsxs("div",{className:"pubs-row",children:[e.jsxs("span",{className:"pubs-doc",children:[e.jsx(Kn,{size:14,className:"pubs-doc-icon"}),e.jsxs("span",{className:"pubs-doc-text",children:[t.status==="missing"?e.jsx("span",{className:"pubs-doc-title pubs-doc-title--missing",children:t.title}):e.jsx("button",{className:"pubs-doc-title",onClick:()=>a(ne(t.project,t.docId)),title:"Open the document",children:t.title}),e.jsx("span",{className:"pubs-doc-folder",children:j||"root"})]})]}),e.jsx("span",{className:`pubs-note${t.note?"":" pubs-note--empty"}`,title:t.note||void 0,children:t.note||"—"}),e.jsx("span",{className:"pubs-date",children:is(t.publishedAt)}),e.jsx("span",{children:e.jsx(uc,{publication:t})}),e.jsxs("span",{className:"pubs-actions",children:[!s&&t.status==="modified"&&e.jsxs("button",{className:`pubs-update-btn${l==="update"?" active":""}`,onClick:()=>c(l==="update"?"idle":"update"),children:[e.jsx(wt,{size:14}),"Update"]}),e.jsx("button",{className:"publish-icon-btn",onClick:()=>r(k),title:"Copy the link",children:o?e.jsx(Se,{size:14}):e.jsx(Pt,{size:14})}),e.jsx("a",{className:"publish-icon-btn",href:k,target:"_blank",rel:"noopener noreferrer",title:"Open the public page",children:e.jsx(qn,{size:14})}),!s&&e.jsx("button",{className:`publish-icon-btn publish-icon-btn--danger${l==="unpublish"?" active":""}`,onClick:()=>c(l==="unpublish"?"idle":"unpublish"),title:"Unpublish",children:e.jsx(vs,{size:14})})]})]}),l==="update"&&e.jsxs("div",{className:"pubs-row-panel",children:[e.jsxs("label",{className:"publish-field pubs-row-panel-field",children:[e.jsxs("span",{className:"publish-field-label",children:["Note for the new version ",e.jsx("span",{className:"publish-field-optional",children:"(optional)"})]}),e.jsx("input",{className:"publish-input",value:d,maxLength:Qt,placeholder:"e.g. Added the Entry points section",onChange:b=>h(b.target.value),autoFocus:!0})]}),e.jsxs("div",{className:"publish-actions",children:[e.jsx("button",{className:"btn-secondary",onClick:()=>c("idle"),disabled:m,children:"Cancel"}),e.jsxs("button",{className:"btn-primary",onClick:()=>g(()=>cn(t.id,d)),disabled:m,children:[e.jsx(wt,{size:14}),m?"Updating…":"Update publication"]})]})]}),l==="unpublish"&&e.jsx("div",{className:"pubs-row-panel",children:e.jsx(Ba,{title:t.title,busy:m,onCancel:()=>c("idle"),onConfirm:()=>g(()=>ln(t.id))})}),p&&e.jsx("div",{className:"publish-error pubs-row-error",children:p})]})}const eo="mcp-documentor.panelWidth",kt=264,mc=200,pc=520,to=t=>Math.min(pc,Math.max(mc,Math.round(t)));function fc(){try{const t=Number(localStorage.getItem(eo));return t?to(t):kt}catch{return kt}}function Qs(t){try{localStorage.setItem(eo,String(t))}catch{}}function gc(){const[t,s]=i.useState(fc),[n,a]=i.useState(!1);return{width:t,resizing:n,startResize:l=>{l.preventDefault();const c=l.clientX,d=t;let h=d;a(!0);const m=p=>{h=to(d+p.clientX-c),s(h)},u=()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",u),a(!1),Qs(h)};window.addEventListener("pointermove",m),window.addEventListener("pointerup",u)},resetWidth:()=>{s(kt),Qs(kt)}}}function xc(){const{codeSourceMigrationPending:t,setCodeSourceMigrationPending:s,currentProject:n,selectedDocId:a}=Y(),o=me(),r=re(),l=Ca(o.pathname),c=js(o.pathname),d=l!==null||c,[h,m]=i.useState(!1),[u,p]=i.useState(!1),[f,k]=i.useState("docs"),[j,g]=i.useState(!0),b=gc(),[N,x]=i.useState(0),[v,w]=i.useState(null),[R,E]=i.useState(!1),y=R||t,$=()=>{d&&r(ne(n,a))};i.useEffect(()=>{const I=z=>{(z.metaKey||z.ctrlKey)&&z.key.toLowerCase()==="k"&&(z.preventDefault(),d&&r(ne(n,a)),k("search"),g(!0),x(X=>X+1))};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[d,r,n,a]);const L=I=>{if(I==="logs"){l||r(Ct("server"));return}if(I==="publications"){c||r(wa);return}if(!d&&I===f){g(z=>!z);return}$(),k(I),g(!0)},S=l?"logs":c?"publications":j?f:null;return e.jsxs("div",{className:"dashboard",children:[e.jsx(Ui,{active:S,onSelect:L,onOpenSettings:()=>m(!h),onOpenProjectSettings:w}),u&&e.jsx(Wi,{onClose:()=>p(!1)}),h&&e.jsx(Hi,{onClose:()=>m(!1),onShowMigrationReport:()=>{m(!1),E(!0)}}),v&&e.jsx(Ji,{project:v,onClose:()=>w(null)}),y&&e.jsx(Xi,{onClose:()=>{E(!1),s(!1)},onReviewProject:w}),l?e.jsx(cc,{source:l}):c?e.jsx(dc,{}):e.jsxs("div",{className:"dashboard-body",children:[e.jsxs("div",{className:`nav-panel-wrapper${j?"":" collapsed"}${b.resizing?" resizing":""}`,style:{"--panel-width":`${b.width}px`},children:[e.jsx(ei,{mode:f,searchFocusToken:N,onCreateDoc:()=>p(!0),onOpenProjectSettings:w,onClose:()=>g(!1)}),j&&e.jsx("div",{className:"nav-panel-resizer",onPointerDown:b.startResize,onDoubleClick:b.resetWidth,title:"Drag to resize · double-click to reset"})]}),e.jsx(Li,{})]})]})}const ft="[mcp-documentor]",vc=3e3;async function Zs(t){const s=await fetch(t);if(!s.ok)throw new Error(`${t} answered HTTP ${s.status}: ${await s.text()}`);return s.json()}const jc=()=>{const t=Y(),s=i.useRef(t);s.current=t,i.useEffect(()=>{let n=null,a,o=!1;const r=h=>{$a(h).then(m=>{s.current.currentProject===h&&s.current.setDocs(m)})},l=h=>{if(h.type==="INITIAL_STATE")console.info(`${ft} Received INITIAL_STATE from server`),s.current.applyInitialState(h.data);else if(h.type==="CONFIG_UPDATED")console.info(`${ft} Received CONFIG_UPDATED from server`);else if(h.type==="BUNDLES_UPDATED")console.info(`${ft} Received BUNDLES_UPDATED from server`),s.current.setExportBundles(h.data?.bundles??[]);else if(h.type==="PROJECTS_CHANGED")s.current.applyInitialState({projects:h.data?.projects??[]});else if(h.type==="CODE_SOURCES_CHANGED"){s.current.bumpCodeSourcesVersion();const m=h.data?.project,u=s.current.currentProject;(!m||m===u)&&r(u)}else if(h.type==="DOCS_CHANGED"){const m=h.data?.project;m&&m===s.current.currentProject&&(r(m),s.current.bumpPublicationsVersion())}else h.type==="PUBLICATIONS_CHANGED"?h.data?.project===s.current.currentProject&&s.current.bumpPublicationsVersion():h.type==="COMMENTS_CHANGED"&&h.data?.project===s.current.currentProject&&s.current.bumpCommentsVersion()},c=async h=>{const m=await Zs("/api/initial-state");o||(s.current.applyInitialState(m),h&&(s.current.bumpCodeSourcesVersion(),s.current.bumpPublicationsVersion(),s.current.bumpCommentsVersion(),r(s.current.currentProject)))},d=async()=>{try{const h=n?`?since=${n.seq}&epoch=${encodeURIComponent(n.epoch)}`:"",m=await Zs(`/api/changes${h}`);if(o)return;m.reset?await c(n!==null):m.events.forEach(l),n={epoch:m.epoch,seq:m.seq}}catch(h){console.error(`${ft} Polling /api/changes failed: ${h instanceof Error?h.message:String(h)}`)}o||(a=setTimeout(d,vc))};return d(),()=>{o=!0,clearTimeout(a)}},[])};function en(t){return Ca(t)!==null||js(t)}function bc(){const t=me(),s=re(),{hasReceivedInitialState:n,projects:a,setCurrentProject:o,setDocs:r,setSelectedDocId:l,setSelectedDoc:c}=Y();i.useEffect(()=>{if(!n||en(t.pathname))return;const{project:m}=zs(t.pathname);if(m)return;const u=Os(),p=(u&&a.includes(u)?u:a[0])??"default";s(ne(p,null),{replace:!0})},[n,a,t.pathname,s]),i.useEffect(()=>{if(!n||!js(t.pathname))return;const m=Os();o((m&&a.includes(m)?m:a[0])??"default")},[n,a,t.pathname]);const{project:d,docId:h}=en(t.pathname)?{project:null,docId:null}:zs(t.pathname);i.useEffect(()=>{if(!d)return;let m=!1;return o(d),_l(d),(async()=>{const u=await $a(d);m||r(u)})(),()=>{m=!0}},[d]),i.useEffect(()=>{d&&(l(h),h===null&&c(null))},[d,h])}function yc(){return jc(),bc(),ki(),br([{path:"*",element:e.jsx(xc,{})}])}function Nc(){return e.jsx(nl,{children:e.jsx(yc,{})})}_o.createRoot(document.getElementById("root")).render(e.jsx(i.StrictMode,{children:e.jsx(Nc,{})}));
@@ -5,10 +5,10 @@
5
5
  <link rel="icon" type="image/svg+xml" href="./vite.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>MCP Documentor</title>
8
- <script type="module" crossorigin src="./assets/main-DqcEvJHv.js"></script>
8
+ <script type="module" crossorigin src="./assets/main-CKkycX8v.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="./assets/DocContent-D2Pgvsaw.js">
10
10
  <link rel="stylesheet" crossorigin href="./assets/DocContent-BxncLHIS.css">
11
- <link rel="stylesheet" crossorigin href="./assets/main-BvGBQ4na.css">
11
+ <link rel="stylesheet" crossorigin href="./assets/main-B4PH-HO6.css">
12
12
  </head>
13
13
  <body>
14
14
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imenam/mcp-documentor",
3
- "version": "1.0.95",
3
+ "version": "1.0.96",
4
4
  "main": "dist/src/index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",