@imenam/mcp-documentor 1.0.91 → 1.0.93

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/README.md +343 -327
  2. package/dist/src/core/git-sync.js +1 -0
  3. package/dist/src/core/publication-store.d.ts +76 -0
  4. package/dist/src/core/publication-store.js +180 -0
  5. package/dist/src/gui-worker.js +183 -67
  6. package/dist/src/index.js +118 -4
  7. package/gui/dist/assets/DocContent-BxncLHIS.css +1 -0
  8. package/gui/dist/assets/DocContent-qNz5QMPa.js +346 -0
  9. package/gui/dist/assets/arc-DvP0UOkD.js +1 -0
  10. package/gui/dist/assets/architectureDiagram-3BPJPVTR-3wEHUA1o.js +36 -0
  11. package/gui/dist/assets/{blockDiagram-GPEHLZMM-G4A-rV4c.js → blockDiagram-GPEHLZMM-C01nZdXH.js} +1 -1
  12. package/gui/dist/assets/{c4Diagram-AAUBKEIU-Dq3aMw8v.js → c4Diagram-AAUBKEIU-C995ER45.js} +1 -1
  13. package/gui/dist/assets/channel-Cjefy81D.js +1 -0
  14. package/gui/dist/assets/chunk-2J33WTMH-B7Z-cZqf.js +1 -0
  15. package/gui/dist/assets/chunk-4BX2VUAB-BRtaRRAZ.js +1 -0
  16. package/gui/dist/assets/chunk-55IACEB6-CZbPaYTs.js +1 -0
  17. package/gui/dist/assets/{chunk-727SXJPM-Dv3Ay2KV.js → chunk-727SXJPM-BMKPsW_V.js} +1 -1
  18. package/gui/dist/assets/{chunk-AQP2D5EJ-BycHHbwh.js → chunk-AQP2D5EJ-BQJRaqJz.js} +1 -1
  19. package/gui/dist/assets/{chunk-FMBD7UC4-DBoCiqpY.js → chunk-FMBD7UC4-BiKjOUxU.js} +1 -1
  20. package/gui/dist/assets/chunk-ND2GUHAM-BQYUzZi5.js +1 -0
  21. package/gui/dist/assets/chunk-QZHKN3VN-C0mI_9k0.js +1 -0
  22. package/gui/dist/assets/classDiagram-4FO5ZUOK-U-TA2l-f.js +1 -0
  23. package/gui/dist/assets/classDiagram-v2-Q7XG4LA2-U-TA2l-f.js +1 -0
  24. package/gui/dist/assets/cose-bilkent-S5V4N54A-9QkakK6h.js +1 -0
  25. package/gui/dist/assets/dagre-BM42HDAG-p_TitJwo.js +4 -0
  26. package/gui/dist/assets/diagram-2AECGRRQ-T3ul_-C1.js +43 -0
  27. package/gui/dist/assets/diagram-5GNKFQAL-Cv4-mYjj.js +10 -0
  28. package/gui/dist/assets/{diagram-KO2AKTUF-CZAde8Sg.js → diagram-KO2AKTUF-GEuY7REm.js} +1 -1
  29. package/gui/dist/assets/diagram-LMA3HP47-BlZVA1ZL.js +24 -0
  30. package/gui/dist/assets/diagram-OG6HWLK6-DZ9muekA.js +24 -0
  31. package/gui/dist/assets/{erDiagram-TEJ5UH35-DPUEmQfe.js → erDiagram-TEJ5UH35-BQ_TWeSA.js} +1 -1
  32. package/gui/dist/assets/{flowDiagram-I6XJVG4X-p2HfkBjW.js → flowDiagram-I6XJVG4X-BVxlCJhG.js} +1 -1
  33. package/gui/dist/assets/ganttDiagram-6RSMTGT7-DlHxknKg.js +292 -0
  34. package/gui/dist/assets/gitGraphDiagram-PVQCEYII-DYHNhcQ1.js +106 -0
  35. package/gui/dist/assets/infoDiagram-5YYISTIA-usWWgsgX.js +2 -0
  36. package/gui/dist/assets/{ishikawaDiagram-YF4QCWOH-DZ61Cc8a.js → ishikawaDiagram-YF4QCWOH-GXA4mXdI.js} +1 -1
  37. package/gui/dist/assets/{journeyDiagram-JHISSGLW-qYtEmFuB.js → journeyDiagram-JHISSGLW-DuiQ_voI.js} +1 -1
  38. package/gui/dist/assets/{kanban-definition-UN3LZRKU-Bs-W313s.js → kanban-definition-UN3LZRKU-Cf5Zx4Ai.js} +1 -1
  39. package/gui/dist/assets/linear-Dxg5B9lZ.js +1 -0
  40. package/gui/dist/assets/main-BoIDzkiC.js +10 -0
  41. package/gui/dist/assets/main-DDy8gF40.css +1 -0
  42. package/gui/dist/assets/{mindmap-definition-RKZ34NQL-CvBqAH4c.js → mindmap-definition-RKZ34NQL-BI-GTubt.js} +1 -1
  43. package/gui/dist/assets/{pieDiagram-4H26LBE5-BD2UcQce.js → pieDiagram-4H26LBE5-jm6JjM7-.js} +1 -1
  44. package/gui/dist/assets/public-5AzxUEZY.css +1 -0
  45. package/gui/dist/assets/public-BbfNIL4J.js +1 -0
  46. package/gui/dist/assets/{quadrantDiagram-W4KKPZXB-DEuynlP9.js → quadrantDiagram-W4KKPZXB-D_FMBvP7.js} +1 -1
  47. package/gui/dist/assets/{requirementDiagram-4Y6WPE33-DPxfzOF3.js → requirementDiagram-4Y6WPE33-DrAnq7B5.js} +1 -1
  48. package/gui/dist/assets/{sankeyDiagram-5OEKKPKP-C70_cePR.js → sankeyDiagram-5OEKKPKP-BBxMYinl.js} +1 -1
  49. package/gui/dist/assets/{sequenceDiagram-3UESZ5HK-FDb_1B1W.js → sequenceDiagram-3UESZ5HK-CzlReNxZ.js} +1 -1
  50. package/gui/dist/assets/stateDiagram-AJRCARHV-CAj_FaGh.js +1 -0
  51. package/gui/dist/assets/stateDiagram-v2-BHNVJYJU-DL8IxfA-.js +1 -0
  52. package/gui/dist/assets/{timeline-definition-PNZ67QCA-DNUx0JIp.js → timeline-definition-PNZ67QCA-CHzi4ypa.js} +1 -1
  53. package/gui/dist/assets/{vennDiagram-CIIHVFJN-DEAfzbjb.js → vennDiagram-CIIHVFJN-DT2hW75o.js} +1 -1
  54. package/gui/dist/assets/{wardley-L42UT6IY-_REPWPb-.js → wardley-L42UT6IY-BBPqyjj6.js} +1 -1
  55. package/gui/dist/assets/{wardleyDiagram-YWT4CUSO-CZFLXFE3.js → wardleyDiagram-YWT4CUSO-CoB6ihhL.js} +1 -1
  56. package/gui/dist/assets/{xychartDiagram-2RQKCTM6-P2Nhif6M.js → xychartDiagram-2RQKCTM6-FgTwWkea.js} +1 -1
  57. package/gui/dist/index.html +4 -2
  58. package/gui/dist/public.html +17 -0
  59. package/package.json +1 -1
  60. package/gui/dist/assets/arc-VljQAUvA.js +0 -1
  61. package/gui/dist/assets/architectureDiagram-3BPJPVTR-lbkjtvmN.js +0 -36
  62. package/gui/dist/assets/channel-DFvG2cZZ.js +0 -1
  63. package/gui/dist/assets/chunk-2J33WTMH-VSzyIJHo.js +0 -1
  64. package/gui/dist/assets/chunk-4BX2VUAB-DER41q8w.js +0 -1
  65. package/gui/dist/assets/chunk-55IACEB6-BlOGGRk4.js +0 -1
  66. package/gui/dist/assets/chunk-ND2GUHAM-DGKypjhb.js +0 -1
  67. package/gui/dist/assets/chunk-QZHKN3VN-B8Gn_mBo.js +0 -1
  68. package/gui/dist/assets/classDiagram-4FO5ZUOK-B8xEoAMI.js +0 -1
  69. package/gui/dist/assets/classDiagram-v2-Q7XG4LA2-B8xEoAMI.js +0 -1
  70. package/gui/dist/assets/cose-bilkent-S5V4N54A-DyamTuYj.js +0 -1
  71. package/gui/dist/assets/dagre-BM42HDAG-BKC5D2WN.js +0 -4
  72. package/gui/dist/assets/diagram-2AECGRRQ-BV2lBpwH.js +0 -43
  73. package/gui/dist/assets/diagram-5GNKFQAL-DGwbAj4W.js +0 -10
  74. package/gui/dist/assets/diagram-LMA3HP47-fQfo0z7i.js +0 -24
  75. package/gui/dist/assets/diagram-OG6HWLK6-BlD3VAFM.js +0 -24
  76. package/gui/dist/assets/ganttDiagram-6RSMTGT7-CWfFoy4g.js +0 -292
  77. package/gui/dist/assets/gitGraphDiagram-PVQCEYII-DkTKzmes.js +0 -106
  78. package/gui/dist/assets/index-BJ4WCWig.css +0 -1
  79. package/gui/dist/assets/index-C8LVeAsA.js +0 -358
  80. package/gui/dist/assets/infoDiagram-5YYISTIA-CXHTqZoU.js +0 -2
  81. package/gui/dist/assets/linear-CU6J91M5.js +0 -1
  82. package/gui/dist/assets/stateDiagram-AJRCARHV-BH1bq2it.js +0 -1
  83. package/gui/dist/assets/stateDiagram-v2-BHNVJYJU-BfpDu1Qi.js +0 -1
@@ -0,0 +1,10 @@
1
+ import{b5 as i,bA as qa,b4 as F,b6 as e,ba as Ms,bb as Is,bc as _s,bB as Ga,bC as Ka,bD as Ja,bE as As,bf as zs,b8 as Vt,b9 as Se,bF as _t,bG as Ya,bH as Fs,bI as Os,be as Qa,bd as Xa,b7 as Za,bg as eo}from"./DocContent-qNz5QMPa.js";var ds="popstate";function us(t){return typeof t=="object"&&t!=null&&"pathname"in t&&"search"in t&&"hash"in t&&"state"in t&&"key"in t}function to(t={}){function s(o,r){let{pathname:l="/",search:c="",hash:d=""}=Pe(o.location.hash.substring(1));return!l.startsWith("/")&&!l.startsWith(".")&&(l="/"+l),At("",{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,u=d.indexOf("#");c=u===-1?d:d.slice(0,u)}return c+"#"+(typeof r=="string"?r:Ge(r))}function a(o,r){oe(o.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(r)})`)}return no(s,n,a,t)}function J(t,s){if(t===!1||t===null||typeof t>"u")throw new Error(s)}function oe(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function so(){return Math.random().toString(36).substring(2,10)}function hs(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 At(t,s,n=null,a,o){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof s=="string"?Pe(s):s,state:n,key:s&&s.key||a||so(),unstable_mask:o}}function Ge({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 Pe(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 no(t,s,n,a={}){let{window:o=document.defaultView,v5Compat:r=!1}=a,l=o.history,c="POP",d=null,u=m();u==null&&(u=0,l.replaceState({...l.state,idx:u},""));function m(){return(l.state||{idx:null}).idx}function h(){c="POP";let g=m(),v=g==null?null:g-u;u=g,d&&d({action:c,location:j.location,delta:v})}function p(g,v){c="PUSH";let y=us(g)?g:At(j.location,g,v);n&&n(y,g),u=m()+1;let w=hs(y,u),b=j.createHref(y.unstable_mask||y);try{l.pushState(w,"",b)}catch(k){if(k instanceof DOMException&&k.name==="DataCloneError")throw k;o.location.assign(b)}r&&d&&d({action:c,location:j.location,delta:1})}function f(g,v){c="REPLACE";let y=us(g)?g:At(j.location,g,v);n&&n(y,g),u=m();let w=hs(y,u),b=j.createHref(y.unstable_mask||y);l.replaceState(w,"",b),r&&d&&d({action:c,location:j.location,delta:0})}function x(g){return ao(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,h),d=g,()=>{o.removeEventListener(ds,h),d=null}},createHref(g){return s(o,g)},createURL:x,encodeLocation(g){let v=x(g);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:p,replace:f,go(g){return l.go(g)}};return j}function ao(t,s=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),J(n,"No window.location.(origin|href) available to create URL");let a=typeof t=="string"?t:Ge(t);return a=a.replace(/ $/,"%20"),!s&&a.startsWith("//")&&(a=n+a),new URL(a,n)}function Us(t,s,n="/"){return oo(t,s,n,!1)}function oo(t,s,n,a){let o=typeof s=="string"?Pe(s):s,r=pe(o.pathname||"/",n);if(r==null)return null;let l=Hs(t);ro(l);let c=null;for(let d=0;c==null&&d<l.length;++d){let u=vo(r);c=go(l[d],u,a)}return c}function Hs(t,s=[],n=[],a="",o=!1){let r=(l,c,d=o,u)=>{let m={relativePath:u===void 0?l.path||"":u,caseSensitive:l.caseSensitive===!0,childrenIndex:c,route:l};if(m.relativePath.startsWith("/")){if(!m.relativePath.startsWith(a)&&d)return;J(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 h=ce([a,m.relativePath]),p=n.concat(m);l.children&&l.children.length>0&&(J(l.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),Hs(l.children,s,p,h,d)),!(l.path==null&&!l.index)&&s.push({path:h,score:po(h,l.index),routesMeta:p})};return t.forEach((l,c)=>{if(l.path===""||!l.path?.includes("?"))r(l,c);else for(let d of Bs(l.path))r(l,c,!0,d)}),s}function Bs(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=Bs(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 ro(t){t.sort((s,n)=>s.score!==n.score?n.score-s.score:fo(s.routesMeta.map(a=>a.childrenIndex),n.routesMeta.map(a=>a.childrenIndex)))}var lo=/^:[\w-]+$/,io=3,co=2,uo=1,ho=10,mo=-2,ms=t=>t==="*";function po(t,s){let n=t.split("/"),a=n.length;return n.some(ms)&&(a+=mo),s&&(a+=co),n.filter(o=>!ms(o)).reduce((o,r)=>o+(lo.test(r)?io:r===""?uo:ho),a)}function fo(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 go(t,s,n=!1){let{routesMeta:a}=t,o={},r="/",l=[];for(let c=0;c<a.length;++c){let d=a[c],u=c===a.length-1,m=r==="/"?s:s.slice(r.length)||"/",h=dt({path:d.relativePath,caseSensitive:d.caseSensitive,end:u},m),p=d.route;if(!h&&u&&n&&!a[a.length-1].route.index&&(h=dt({path:d.relativePath,caseSensitive:d.caseSensitive,end:!1},m)),!h)return null;Object.assign(o,h.params),l.push({params:o,pathname:ce([r,h.pathname]),pathnameBase:No(ce([r,h.pathnameBase])),route:p}),h.pathnameBase!=="/"&&(r=ce([r,h.pathnameBase]))}return l}function dt(t,s){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,a]=xo(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((u,{paramName:m,isOptional:h},p)=>{if(m==="*"){let x=c[p]||"";l=r.slice(0,r.length-x.length).replace(/(.)\/+$/,"$1")}const f=c[p];return h&&!f?u[m]=void 0:u[m]=(f||"").replace(/%2F/g,"/"),u},{}),pathname:r,pathnameBase:l,pattern:t}}function xo(t,s=!1,n=!0){oe(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,u,m)=>{if(a.push({paramName:c,isOptional:d!=null}),d){let h=m.charAt(u+l.length);return h&&h!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}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 vo(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return oe(!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 pe(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 jo=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function yo(t,s="/"){let{pathname:n,search:a="",hash:o=""}=typeof t=="string"?Pe(t):t,r;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?r=ps(n.substring(1),"/"):r=ps(n,s)):r=s,{pathname:r,search:wo(a),hash:ko(o)}}function ps(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 $t(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 bo(t){return t.filter((s,n)=>n===0||s.route.path&&s.route.path.length>0)}function Ws(t){let s=bo(t);return s.map((n,a)=>a===s.length-1?n.pathname:n.pathnameBase)}function qt(t,s,n,a=!1){let o;typeof t=="string"?o=Pe(t):(o={...t},J(!o.pathname||!o.pathname.includes("?"),$t("?","pathname","search",o)),J(!o.pathname||!o.pathname.includes("#"),$t("#","pathname","hash",o)),J(!o.search||!o.search.includes("#"),$t("#","search","hash",o)));let r=t===""||o.pathname==="",l=r?"/":o.pathname,c;if(l==null)c=n;else{let h=s.length-1;if(!a&&l.startsWith("..")){let p=l.split("/");for(;p[0]==="..";)p.shift(),h-=1;o.pathname=p.join("/")}c=h>=0?s[h]:"/"}let d=yo(o,c),u=l&&l!=="/"&&l.endsWith("/"),m=(r||l===".")&&n.endsWith("/");return!d.pathname.endsWith("/")&&(u||m)&&(d.pathname+="/"),d}var ce=t=>t.join("/").replace(/\/\/+/g,"/"),No=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),wo=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,ko=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,Co=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 So(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function Eo(t){return t.map(s=>s.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Vs=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function qs(t,s){let n=t;if(typeof n!="string"||!jo.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let a=n,o=!1;if(Vs)try{let r=new URL(window.location.href),l=n.startsWith("//")?new URL(r.protocol+n):new URL(n),c=pe(l.pathname,s);l.origin===r.origin&&c!=null?n=c+l.search+l.hash:o=!0}catch{oe(!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 Gs=["POST","PUT","PATCH","DELETE"];new Set(Gs);var $o=["GET",...Gs];new Set($o);var Le=i.createContext(null);Le.displayName="DataRouter";var ft=i.createContext(null);ft.displayName="DataRouterState";var Ro=i.createContext(!1),Ks=i.createContext({isTransitioning:!1});Ks.displayName="ViewTransition";var Do=i.createContext(new Map);Do.displayName="Fetchers";var Po=i.createContext(null);Po.displayName="Await";var ne=i.createContext(null);ne.displayName="Navigation";var gt=i.createContext(null);gt.displayName="Location";var fe=i.createContext({outlet:null,matches:[],isDataRoute:!1});fe.displayName="Route";var Gt=i.createContext(null);Gt.displayName="RouteError";var Js="REACT_ROUTER_ERROR",Lo="REDIRECT",To="ROUTE_ERROR_RESPONSE";function Mo(t){if(t.startsWith(`${Js}:${Lo}:{`))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 Io(t){if(t.startsWith(`${Js}:${To}:{`))try{let s=JSON.parse(t.slice(40));if(typeof s=="object"&&s&&typeof s.status=="number"&&typeof s.statusText=="string")return new Co(s.status,s.statusText,s.data)}catch{}}function _o(t,{relative:s}={}){J(Ke(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:a}=i.useContext(ne),{hash:o,pathname:r,search:l}=Je(t,{relative:s}),c=r;return n!=="/"&&(c=r==="/"?n:ce([n,r])),a.createHref({pathname:c,search:l,hash:o})}function Ke(){return i.useContext(gt)!=null}function de(){return J(Ke(),"useLocation() may be used only in the context of a <Router> component."),i.useContext(gt).location}var Ys="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Qs(t){i.useContext(ne).static||i.useLayoutEffect(t)}function ae(){let{isDataRoute:t}=i.useContext(fe);return t?Jo():Ao()}function Ao(){J(Ke(),"useNavigate() may be used only in the context of a <Router> component.");let t=i.useContext(Le),{basename:s,navigator:n}=i.useContext(ne),{matches:a}=i.useContext(fe),{pathname:o}=de(),r=JSON.stringify(Ws(a)),l=i.useRef(!1);return Qs(()=>{l.current=!0}),i.useCallback((d,u={})=>{if(oe(l.current,Ys),!l.current)return;if(typeof d=="number"){n.go(d);return}let m=qt(d,JSON.parse(r),o,u.relative==="path");t==null&&s!=="/"&&(m.pathname=m.pathname==="/"?s:ce([s,m.pathname])),(u.replace?n.replace:n.push)(m,u.state,u)},[s,n,r,o,t])}i.createContext(null);function Je(t,{relative:s}={}){let{matches:n}=i.useContext(fe),{pathname:a}=de(),o=JSON.stringify(Ws(n));return i.useMemo(()=>qt(t,JSON.parse(o),a,s==="path"),[t,o,a,s])}function zo(t,s){return Xs(t)}function Xs(t,s,n){J(Ke(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=i.useContext(ne),{matches:o}=i.useContext(fe),r=o[o.length-1],l=r?r.params:{},c=r?r.pathname:"/",d=r?r.pathnameBase:"/",u=r&&r.route;{let g=u&&u.path||"";en(c,!u||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=de(),h;h=m;let p=h.pathname||"/",f=p;if(d!=="/"){let g=d.replace(/^\//,"").split("/");f="/"+p.replace(/^\//,"").split("/").slice(g.length).join("/")}let x=Us(t,{pathname:f});return oe(u||x!=null,`No routes matched location "${h.pathname}${h.search}${h.hash}" `),oe(x==null||x[x.length-1].route.element!==void 0||x[x.length-1].route.Component!==void 0||x[x.length-1].route.lazy!==void 0,`Matched leaf route at location "${h.pathname}${h.search}${h.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.`),Bo(x&&x.map(g=>Object.assign({},g,{params:Object.assign({},l,g.params),pathname:ce([d,a.encodeLocation?a.encodeLocation(g.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathname]),pathnameBase:g.pathnameBase==="/"?d:ce([d,a.encodeLocation?a.encodeLocation(g.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathnameBase])})),o,n)}function Fo(){let t=Ko(),s=So(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 Oo=i.createElement(Fo,null),Zs=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=Io(t.digest);n&&(t=n)}let s=t!==void 0?i.createElement(fe.Provider,{value:this.props.routeContext},i.createElement(Gt.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?i.createElement(Uo,{error:t},s):s}};Zs.contextType=Ro;var Rt=new WeakMap;function Uo({children:t,error:s}){let{basename:n}=i.useContext(ne);if(typeof s=="object"&&s&&"digest"in s&&typeof s.digest=="string"){let a=Mo(s.digest);if(a){let o=Rt.get(s);if(o)throw o;let r=qs(a.location,n);if(Vs&&!Rt.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 Rt.set(s,l),l}return i.createElement("meta",{httpEquiv:"refresh",content:`0;url=${r.absoluteURL||r.to}`})}}return t}function Ho({routeContext:t,match:s,children:n}){let a=i.useContext(Le);return a&&a.static&&a.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=s.route.id),i.createElement(fe.Provider,{value:t},n)}function Bo(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(h=>h.route.id&&r?.[h.route.id]!==void 0);J(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 h=o[m];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(c=m),h.route.id){let{loaderData:p,errors:f}=a,x=h.route.loader&&!p.hasOwnProperty(h.route.id)&&(!f||f[h.route.id]===void 0);if(h.route.lazy||x){n.isStatic&&(l=!0),c>=0?o=o.slice(0,c+1):o=[o[0]];break}}}}let d=n?.onError,u=a&&d?(m,h)=>{d(m,{location:a.location,params:a.matches?.[0]?.params??{},unstable_pattern:Eo(a.matches),errorInfo:h})}:void 0;return o.reduceRight((m,h,p)=>{let f,x=!1,j=null,g=null;a&&(f=r&&h.route.id?r[h.route.id]:void 0,j=h.route.errorElement||Oo,l&&(c<0&&p===0?(en("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,g=null):c===p&&(x=!0,g=h.route.hydrateFallbackElement||null)));let v=s.concat(o.slice(0,p+1)),y=()=>{let w;return f?w=j:x?w=g:h.route.Component?w=i.createElement(h.route.Component,null):h.route.element?w=h.route.element:w=m,i.createElement(Ho,{match:h,routeContext:{outlet:m,matches:v,isDataRoute:a!=null},children:w})};return a&&(h.route.ErrorBoundary||h.route.errorElement||p===0)?i.createElement(Zs,{location:a.location,revalidation:a.revalidation,component:j,error:f,children:y(),routeContext:{outlet:null,matches:v,isDataRoute:!0},onError:u}):y()},null)}function Kt(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Wo(t){let s=i.useContext(Le);return J(s,Kt(t)),s}function Vo(t){let s=i.useContext(ft);return J(s,Kt(t)),s}function qo(t){let s=i.useContext(fe);return J(s,Kt(t)),s}function Jt(t){let s=qo(t),n=s.matches[s.matches.length-1];return J(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function Go(){return Jt("useRouteId")}function Ko(){let t=i.useContext(Gt),s=Vo("useRouteError"),n=Jt("useRouteError");return t!==void 0?t:s.errors?.[n]}function Jo(){let{router:t}=Wo("useNavigate"),s=Jt("useNavigate"),n=i.useRef(!1);return Qs(()=>{n.current=!0}),i.useCallback(async(o,r={})=>{oe(n.current,Ys),n.current&&(typeof o=="number"?await t.navigate(o):await t.navigate(o,{fromRouteId:s,...r}))},[t,s])}var fs={};function en(t,s,n){!s&&!fs[t]&&(fs[t]=!0,oe(!1,n))}i.memo(Yo);function Yo({routes:t,future:s,state:n,isStatic:a,onError:o}){return Xs(t,void 0,{state:n,isStatic:a,onError:o})}function Qo({basename:t="/",children:s=null,location:n,navigationType:a="POP",navigator:o,static:r=!1,unstable_useTransitions:l}){J(!Ke(),"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=Pe(n));let{pathname:u="/",search:m="",hash:h="",state:p=null,key:f="default",unstable_mask:x}=n,j=i.useMemo(()=>{let g=pe(u,c);return g==null?null:{location:{pathname:g,search:m,hash:h,state:p,key:f,unstable_mask:x},navigationType:a}},[c,u,m,h,p,f,a,x]);return oe(j!=null,`<Router basename="${c}"> is not able to match the URL "${u}${m}${h}" because it does not start with the basename, so the <Router> won't render anything.`),j==null?null:i.createElement(ne.Provider,{value:d},i.createElement(gt.Provider,{children:s,value:j}))}var ot="get",rt="application/x-www-form-urlencoded";function xt(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function Xo(t){return xt(t)&&t.tagName.toLowerCase()==="button"}function Zo(t){return xt(t)&&t.tagName.toLowerCase()==="form"}function er(t){return xt(t)&&t.tagName.toLowerCase()==="input"}function tr(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function sr(t,s){return t.button===0&&(!s||s==="_self")&&!tr(t)}var tt=null;function nr(){if(tt===null)try{new FormData(document.createElement("form"),0),tt=!1}catch{tt=!0}return tt}var ar=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Dt(t){return t!=null&&!ar.has(t)?(oe(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${rt}"`),null):t}function or(t,s){let n,a,o,r,l;if(Zo(t)){let c=t.getAttribute("action");a=c?pe(c,s):null,n=t.getAttribute("method")||ot,o=Dt(t.getAttribute("enctype"))||rt,r=new FormData(t)}else if(Xo(t)||er(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?pe(d,s):null,n=t.getAttribute("formmethod")||c.getAttribute("method")||ot,o=Dt(t.getAttribute("formenctype"))||Dt(c.getAttribute("enctype"))||rt,r=new FormData(c,t),!nr()){let{name:u,type:m,value:h}=t;if(m==="image"){let p=u?`${u}.`:"";r.append(`${p}x`,"0"),r.append(`${p}y`,"0")}else u&&r.append(u,h)}}else{if(xt(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=ot,a=null,o=rt,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 Yt(t,s){if(t===!1||t===null||typeof t>"u")throw new Error(s)}function rr(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&&pe(o.pathname,s)==="/"?o.pathname=`${s.replace(/\/$/,"")}/_root.${a}`:o.pathname=`${o.pathname.replace(/\/$/,"")}.${a}`,o}async function lr(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 ir(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 cr(t,s,n){let a=await Promise.all(t.map(async o=>{let r=s.routes[o.route.id];if(r){let l=await lr(r,n);return l.links?l.links():[]}return[]}));return mr(a.flat(1).filter(ir).filter(o=>o.rel==="stylesheet"||o.rel==="preload").map(o=>o.rel==="stylesheet"?{...o,rel:"prefetch",as:"style"}:{...o,rel:"prefetch"}))}function gs(t,s,n,a,o,r){let l=(d,u)=>n[u]?d.route.id!==n[u].route.id:!0,c=(d,u)=>n[u].pathname!==d.pathname||n[u].route.path?.endsWith("*")&&n[u].params["*"]!==d.params["*"];return r==="assets"?s.filter((d,u)=>l(d,u)||c(d,u)):r==="data"?s.filter((d,u)=>{let m=a.routes[d.route.id];if(!m||!m.hasLoader)return!1;if(l(d,u)||c(d,u))return!0;if(d.route.shouldRevalidate){let h=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 h=="boolean")return h}return!0}):[]}function dr(t,s,{includeHydrateFallback:n}={}){return ur(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 ur(t){return[...new Set(t)]}function hr(t){let s={},n=Object.keys(t).sort();for(let a of n)s[a]=t[a];return s}function mr(t,s){let n=new Set;return new Set(s),t.reduce((a,o)=>{let r=JSON.stringify(hr(o));return n.has(r)||(n.add(r),a.push({key:r,link:o})),a},[])}function tn(){let t=i.useContext(Le);return Yt(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function pr(){let t=i.useContext(ft);return Yt(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var Qt=i.createContext(void 0);Qt.displayName="FrameworkContext";function sn(){let t=i.useContext(Qt);return Yt(t,"You must render this element inside a <HydratedRouter> element"),t}function fr(t,s){let n=i.useContext(Qt),[a,o]=i.useState(!1),[r,l]=i.useState(!1),{onFocus:c,onBlur:d,onMouseEnter:u,onMouseLeave:m,onTouchStart:h}=s,p=i.useRef(null);i.useEffect(()=>{if(t==="render"&&l(!0),t==="viewport"){let j=v=>{v.forEach(y=>{l(y.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)},x=()=>{o(!1),l(!1)};return n?t!=="intent"?[r,p,{}]:[r,p,{onFocus:Oe(c,f),onBlur:Oe(d,x),onMouseEnter:Oe(u,f),onMouseLeave:Oe(m,x),onTouchStart:Oe(h,f)}]:[!1,p,{}]}function Oe(t,s){return n=>{t&&t(n),n.defaultPrevented||s(n)}}function gr({page:t,...s}){let{router:n}=tn(),a=i.useMemo(()=>Us(n.routes,t,n.basename),[n.routes,t,n.basename]);return a?i.createElement(vr,{page:t,matches:a,...s}):null}function xr(t){let{manifest:s,routeModules:n}=sn(),[a,o]=i.useState([]);return i.useEffect(()=>{let r=!1;return cr(t,s,n).then(l=>{r||o(l)}),()=>{r=!0}},[t,s,n]),a}function vr({page:t,matches:s,...n}){let a=de(),{future:o,manifest:r,routeModules:l}=sn(),{basename:c}=tn(),{loaderData:d,matches:u}=pr(),m=i.useMemo(()=>gs(t,s,u,r,a,"data"),[t,s,u,r,a]),h=i.useMemo(()=>gs(t,s,u,r,a,"assets"),[t,s,u,r,a]),p=i.useMemo(()=>{if(t===a.pathname+a.search+a.hash)return[];let j=new Set,g=!1;if(s.forEach(y=>{let w=r.routes[y.route.id];!w||!w.hasLoader||(!m.some(b=>b.route.id===y.route.id)&&y.route.id in d&&l[y.route.id]?.shouldRevalidate||w.hasClientLoader?g=!0:j.add(y.route.id))}),j.size===0)return[];let v=rr(t,c,o.unstable_trailingSlashAwareDataRequests,"data");return g&&j.size>0&&v.searchParams.set("_routes",s.filter(y=>j.has(y.route.id)).map(y=>y.route.id).join(",")),[v.pathname+v.search]},[c,o.unstable_trailingSlashAwareDataRequests,d,a,r,m,s,t,l]),f=i.useMemo(()=>dr(h,r),[h,r]),x=xr(h);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})),x.map(({key:j,link:g})=>i.createElement("link",{key:j,nonce:n.nonce,...g,crossOrigin:g.crossOrigin??n.crossOrigin})))}function jr(...t){return s=>{t.forEach(n=>{typeof n=="function"?n(s):n!=null&&(n.current=s)})}}var yr=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{yr&&(window.__reactRouterVersion="7.13.1")}catch{}function br({basename:t,children:s,unstable_useTransitions:n,window:a}){let o=i.useRef();o.current==null&&(o.current=to({window:a,v5Compat:!0}));let r=o.current,[l,c]=i.useState({action:r.action,location:r.location}),d=i.useCallback(u=>{n===!1?c(u):i.startTransition(()=>c(u))},[n]);return i.useLayoutEffect(()=>r.listen(d),[r,d]),i.createElement(Qo,{basename:t,children:s,location:l.location,navigationType:l.action,navigator:r,unstable_useTransitions:n})}var nn=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,an=i.forwardRef(function({onClick:s,discover:n="render",prefetch:a="none",relative:o,reloadDocument:r,replace:l,unstable_mask:c,state:d,target:u,to:m,preventScrollReset:h,viewTransition:p,unstable_defaultShouldRevalidate:f,...x},j){let{basename:g,navigator:v,unstable_useTransitions:y}=i.useContext(ne),w=typeof m=="string"&&nn.test(m),b=qs(m,g);m=b.to;let k=_o(m,{relative:o}),R=de(),E=null;if(c){let A=qt(c,[],R.unstable_mask?R.unstable_mask.pathname:"/",!0);g!=="/"&&(A.pathname=A.pathname==="/"?g:ce([g,A.pathname])),E=v.createHref(A)}let[N,D,_]=fr(a,x),C=Cr(m,{replace:l,unstable_mask:c,state:d,target:u,preventScrollReset:h,relative:o,viewTransition:p,unstable_defaultShouldRevalidate:f,unstable_useTransitions:y});function M(A){s&&s(A),A.defaultPrevented||C(A)}let $=!(b.isExternal||r),H=i.createElement("a",{...x,..._,href:($?E:void 0)||b.absoluteURL||k,onClick:$?M:s,ref:jr(j,D),target:u,"data-discover":!w&&n==="render"?"true":void 0});return N&&!w?i.createElement(i.Fragment,null,H,i.createElement(gr,{page:k})):H});an.displayName="Link";var Nr=i.forwardRef(function({"aria-current":s="page",caseSensitive:n=!1,className:a="",end:o=!1,style:r,to:l,viewTransition:c,children:d,...u},m){let h=Je(l,{relative:u.relative}),p=de(),f=i.useContext(ft),{navigator:x,basename:j}=i.useContext(ne),g=f!=null&&Dr(h)&&c===!0,v=x.encodeLocation?x.encodeLocation(h).pathname:h.pathname,y=p.pathname,w=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;n||(y=y.toLowerCase(),w=w?w.toLowerCase():null,v=v.toLowerCase()),w&&j&&(w=pe(w,j)||w);const b=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let k=y===v||!o&&y.startsWith(v)&&y.charAt(b)==="/",R=w!=null&&(w===v||!o&&w.startsWith(v)&&w.charAt(v.length)==="/"),E={isActive:k,isPending:R,isTransitioning:g},N=k?s:void 0,D;typeof a=="function"?D=a(E):D=[a,k?"active":null,R?"pending":null,g?"transitioning":null].filter(Boolean).join(" ");let _=typeof r=="function"?r(E):r;return i.createElement(an,{...u,"aria-current":N,className:D,ref:m,style:_,to:l,viewTransition:c},typeof d=="function"?d(E):d)});Nr.displayName="NavLink";var wr=i.forwardRef(({discover:t="render",fetcherKey:s,navigate:n,reloadDocument:a,replace:o,state:r,method:l=ot,action:c,onSubmit:d,relative:u,preventScrollReset:m,viewTransition:h,unstable_defaultShouldRevalidate:p,...f},x)=>{let{unstable_useTransitions:j}=i.useContext(ne),g=$r(),v=Rr(c,{relative:u}),y=l.toLowerCase()==="get"?"get":"post",w=typeof c=="string"&&nn.test(c),b=k=>{if(d&&d(k),k.defaultPrevented)return;k.preventDefault();let R=k.nativeEvent.submitter,E=R?.getAttribute("formmethod")||l,N=()=>g(R||k.currentTarget,{fetcherKey:s,method:E,navigate:n,replace:o,state:r,relative:u,preventScrollReset:m,viewTransition:h,unstable_defaultShouldRevalidate:p});j&&n!==!1?i.startTransition(()=>N()):N()};return i.createElement("form",{ref:x,method:y,action:v,onSubmit:a?d:b,...f,"data-discover":!w&&t==="render"?"true":void 0})});wr.displayName="Form";function kr(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function on(t){let s=i.useContext(Le);return J(s,kr(t)),s}function Cr(t,{target:s,replace:n,unstable_mask:a,state:o,preventScrollReset:r,relative:l,viewTransition:c,unstable_defaultShouldRevalidate:d,unstable_useTransitions:u}={}){let m=ae(),h=de(),p=Je(t,{relative:l});return i.useCallback(f=>{if(sr(f,s)){f.preventDefault();let x=n!==void 0?n:Ge(h)===Ge(p),j=()=>m(t,{replace:x,unstable_mask:a,state:o,preventScrollReset:r,relative:l,viewTransition:c,unstable_defaultShouldRevalidate:d});u?i.startTransition(()=>j()):j()}},[h,m,p,n,a,o,s,t,r,l,c,d,u])}var Sr=0,Er=()=>`__${String(++Sr)}__`;function $r(){let{router:t}=on("useSubmit"),{basename:s}=i.useContext(ne),n=Go(),a=t.fetch,o=t.navigate;return i.useCallback(async(r,l={})=>{let{action:c,method:d,encType:u,formData:m,body:h}=or(r,s);if(l.navigate===!1){let p=l.fetcherKey||Er();await a(p,n,l.action||c,{unstable_defaultShouldRevalidate:l.unstable_defaultShouldRevalidate,preventScrollReset:l.preventScrollReset,formData:m,body:h,formMethod:l.method||d,formEncType:l.encType||u,flushSync:l.flushSync})}else await o(l.action||c,{unstable_defaultShouldRevalidate:l.unstable_defaultShouldRevalidate,preventScrollReset:l.preventScrollReset,formData:m,body:h,formMethod:l.method||d,formEncType:l.encType||u,replace:l.replace,state:l.state,fromRouteId:n,flushSync:l.flushSync,viewTransition:l.viewTransition})},[a,o,s,n])}function Rr(t,{relative:s}={}){let{basename:n}=i.useContext(ne),a=i.useContext(fe);J(a,"useFormAction must be used inside a RouteContext");let[o]=a.matches.slice(-1),r={...Je(t||".",{relative:s})},l=de();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(h=>h).forEach(h=>c.append("index",h));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:ce([n,r.pathname])),Ge(r)}function Dr(t,{relative:s}={}){let n=i.useContext(Ks);J(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:a}=on("useViewTransitionState"),o=Je(t,{relative:s});if(!n.isTransitioning)return!1;let r=pe(n.currentLocation.pathname,a)||n.currentLocation.pathname,l=pe(n.nextLocation.pathname,a)||n.nextLocation.pathname;return dt(o.pathname,l)!=null||dt(o.pathname,r)!=null}var Pr=qa();const rn={name:"check",size:24,node:[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]};rn.node;const De=F(rn);const ln={name:"chevron-down",size:24,node:[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]};ln.node;const vt=F(ln);const cn={name:"chevron-right",size:24,node:[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]};cn.node;const Lr=F(cn);const dn={name:"chevron-up",size:24,node:[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]};dn.node;const un=F(dn);const hn={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"}]]};hn.node;const Tr=F(hn);const mn={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"}]]};mn.node;const Mr=F(mn);const pn={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"]};pn.node;const Ir=F(pn);const fn={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"]};fn.node;const He=F(fn);const gn={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"}]]};gn.node;const _r=F(gn);const xn={name:"clock",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]};xn.node;const vn=F(xn);const jn={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"}]]};jn.node;const Xt=F(jn);const yn={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"}]]};yn.node;const jt=F(yn);const bn={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"}]]};bn.node;const Ar=F(bn);const Nn={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"}]]};Nn.node;const wn=F(Nn);const kn={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"}]]};kn.node;const Cn=F(kn);const Sn={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"}]]};Sn.node;const zr=F(Sn);const En={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"}]]};En.node;const yt=F(En);const $n={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"}]]};$n.node;const Rn=F($n);const Dn={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"}]]};Dn.node;const Fr=F(Dn);const Pn={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"]};Pn.node;const Or=F(Pn);const Ln={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"}]]};Ln.node;const ut=F(Ln);const Tn={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"}]]};Tn.node;const bt=F(Tn);const Mn={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"}]]};Mn.node;const Ur=F(Mn);const In={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"}]]};In.node;const Hr=F(In);const _n={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"}]]};_n.node;const Br=F(_n);const An={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"}]]};An.node;const Zt=F(An);const zn={name:"loader-circle",size:24,node:[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],aliases:["loader-2"]};zn.node;const Pt=F(zn);const Fn={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"}]]};Fn.node;const Wr=F(Fn);const On={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"}]]};On.node;const Vr=F(On);const Un={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"]};Un.node;const qr=F(Un);const Hn={name:"plus",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]};Hn.node;const Bn=F(Hn);const Wn={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"}]]};Wn.node;const ht=F(Wn);const Vn={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"}]]};Vn.node;const Gr=F(Vn);const qn={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"}]]};qn.node;const Gn=F(qn);const Kn={name:"search",size:24,node:[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]};Kn.node;const Nt=F(Kn);const Jn={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"}]]};Jn.node;const Yn=F(Jn);const Qn={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"]};Qn.node;const es=F(Qn);const Xn={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"}]]};Xn.node;const Zn=F(Xn);const ea={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]};ea.node;const ta=F(ea),Kr={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};let I={...Kr},lt=[];function X(){lt.forEach(t=>t())}function Z(){const[,t]=i.useState(0),s=i.useCallback(()=>{const n=()=>t(a=>a+1);return lt.push(n),()=>{lt=lt.filter(a=>a!==n)}},[]);return i.useState(()=>s()),{...I,setProjects:n=>{I={...I,projects:n},X()},setCurrentProject:n=>{I={...I,currentProject:n},X()},setDocs:n=>{I={...I,docs:n},X()},setSelectedDocId:n=>{I={...I,selectedDocId:n,freshnessResult:null},X()},setSelectedDoc:n=>{I={...I,selectedDoc:n},X()},setFreshnessResult:n=>{I={...I,freshnessResult:n},X()},setSearchQuery:n=>{I={...I,searchQuery:n},X()},setSearchResults:n=>{I={...I,searchResults:n},X()},clearSearch:()=>{I={...I,searchQuery:"",searchResults:[]},X()},setSearchAllProjects:n=>{I={...I,searchAllProjects:n},X()},setHistoryEntries:n=>{I={...I,historyEntries:n,historyVersionContent:null},X()},setHistoryVersionContent:n=>{I={...I,historyVersionContent:n},X()},setExportBundles:n=>{I={...I,exportBundles:n},X()},bumpCodeSourcesVersion:()=>{I={...I,codeSourcesVersion:I.codeSourcesVersion+1},X()},bumpPublicationsVersion:()=>{I={...I,publicationsVersion:I.publicationsVersion+1},X()},setCodeSourceMigrationPending:n=>{I={...I,codeSourceMigrationPending:n},X()},applyInitialState:n=>{const a=n.projects??n.config?.projects??I.projects,o=a.length===I.projects.length&&a.every((r,l)=>r===I.projects[l]);I={...I,projects:o?I.projects:a,docs:n.docs??I.docs,exportBundles:n.bundles??I.exportBundles,readOnly:n.readOnly??I.readOnly,syncEnabled:n.syncEnabled??I.syncEnabled,codeSourceMigrationPending:n.codeSourceMigrationPending??I.codeSourceMigrationPending,hasReceivedInitialState:!0},X()}}}function te(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 xs(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 me(t){return t.split("/").filter(Boolean).map(s=>encodeURIComponent(s)).join("/")}const it="/_logs";function mt(t){return`${it}/${t}`}const sa="/_publications";function ts(t){return t.replace(/\/+$/,"")===sa}function na(t){const s=t.replace(/\/+$/,"");return s!==it&&!s.startsWith(`${it}/`)?null:s.slice(it.length+1)==="github"?"github":"server"}const aa=t=>`mcp-documentor:expanded-folders:${t}`;function vs(t){try{const s=JSON.parse(localStorage.getItem(aa(t))??"null");return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function Jr(t,s){try{localStorage.setItem(aa(t),JSON.stringify(s))}catch{}}function oa(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 Yr({bundle:t,onClose:s}){const[n,a]=i.useState(!1),[o,r]=i.useState(!1),{currentProject:l}=Z();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:()=>{oa(t,n,o,l),s()},children:"↓ Télécharger ZIP"})]})]})})}function Qr(){const{exportBundles:t,currentProject:s}=Z(),[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(),oa(o,!1,!1,s)},title:`Télécharger ${o.zipFilename}`,children:"↓ ZIP"})]},o.id))}),n&&e.jsx(Yr,{bundle:n,onClose:()=>a(null)})]})}const ra="mcp-documentor:project";function js(){try{return localStorage.getItem(ra)}catch{return null}}function Xr(t){try{localStorage.setItem(ra,t)}catch{}}async function la(t){try{const s=await fetch(`/api/docs?project=${encodeURIComponent(t)}`);return s.ok?(await s.json()).docs??[]:[]}catch{return[]}}async function Zr(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 el(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 tl(t){let s=0;for(const n of t)s=s*31+n.charCodeAt(0)>>>0;return`hsl(${s%360}, 52%, 46%)`}async function re(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 Te=t=>({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});async function ia(){return(await re("/api/code-sources")).projects}async function sl(t,s){return(await re("/api/code-sources/search",{...Te({query:t}),signal:s})).results}function nl(t,s,n){return re("/api/code-sources/inspect",{...Te({repo:t,branch:s}),signal:n})}function al(t,s,n,a){return re("/api/code-sources/preview",{...Te({project:t,config:s,codeRoot:n}),signal:a})}function ol(t,s,n){return re("/api/code-sources/apply",Te({project:t,config:s,codeRoot:n}))}function rl(t,s){return re("/api/code-roots/inspect",{...Te({path:t}),signal:s})}function ll(){return re("/api/code-roots")}function il(t){return re("/api/code-roots/apply",Te({path:t}))}function cl(){return re("/api/github-token")}async function ca(){return(await re("/api/code-source-migration")).report}function dl(){return re("/api/code-source-migration/ack",{method:"POST"})}function ys(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 ul({source:t,size:s,active:n}){if(t?.error)return e.jsx(es,{size:s,className:"source-icon error"});const a=`source-icon${n?" active":""}`;return t?.config?.kind==="github"?e.jsx(Xt,{size:s,className:a}):e.jsx(Zt,{size:s,className:a})}function bs({project:t,size:s}){return e.jsx("span",{className:"project-avatar",style:{width:s,height:s,background:tl(t),fontSize:Math.round(s*.36)},children:el(t)})}function da({variant:t,onOpenSettings:s}){const n=ae(),{currentProject:a,projects:o,applyInitialState:r,codeSourcesVersion:l}=Z(),[c,d]=i.useState(""),[u,m]=i.useState(!1),[h,p]=i.useState(!1),[f,x]=i.useState(0),[j,g]=i.useState({}),v=i.useRef(null),y=i.useRef(null),w=i.useCallback(()=>{ia().then($=>g(Object.fromEntries($.map(H=>[H.project,H])))).catch(()=>{})},[]);i.useEffect(w,[l,o,w]),i.useEffect(()=>{h&&w()},[h,w]),i.useEffect(()=>{h&&!u&&v.current?.focus()},[h,u]),i.useEffect(()=>{v.current?.querySelector(`[data-index="${f}"]`)?.scrollIntoView({block:"nearest"})},[f]);const b=$=>{n(te($,null))},k=()=>{x(Math.max(0,o.indexOf(a))),m(!1),p(!0)},R=()=>{p(!1),m(!1),y.current?.focus()},E=$=>{R(),b($)},N=$=>{p(!1),s($)},D=$=>{$.key==="ArrowDown"?($.preventDefault(),x(H=>Math.min(o.length-1,H+1))):$.key==="ArrowUp"?($.preventDefault(),x(H=>Math.max(0,H-1))):$.key==="Enter"?($.preventDefault(),o[f]&&E(o[f])):($.key==="Escape"||$.key==="Tab")&&R()},_=async()=>{const $=c.trim().replace(/[^a-zA-Z0-9_-]/g,"-");if(!$)return;const{ok:H,projects:A}=await Zr($);H&&(A&&r({projects:A}),d(""),R(),b($))},C=j[a],M=C?`${a} — ${C.error??ys(C)}`:a;return e.jsxs("div",{className:`project-selector project-selector--${t}`,children:[e.jsxs("button",{ref:y,className:`project-trigger${h?" open":""}${C?.error?" error":""}`,onClick:()=>h?R():k(),onKeyDown:$=>{$.key==="ArrowDown"&&!h&&($.preventDefault(),k())},title:M,"aria-haspopup":"listbox","aria-expanded":h,children:[e.jsx(bs,{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${C?.error?" error":""}`,children:C?.error?"Code source to fix":"Current project"})]}),e.jsx(Mr,{size:14,className:"project-trigger-caret"})]})]}),h&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"menu-backdrop",onClick:R}),e.jsxs("div",{className:"project-menu",children:[e.jsx("div",{className:"project-menu-label",children:"Projects · code source"}),e.jsx("div",{className:"project-menu-list",role:"listbox",tabIndex:-1,ref:v,onKeyDown:D,"aria-activedescendant":`project-option-${f}`,children:o.map(($,H)=>{const A=j[$],W=$===a;return e.jsxs("div",{id:`project-option-${H}`,"data-index":H,role:"option","aria-selected":W,className:`project-option${W?" current":""}${H===f?" highlighted":""}`,onMouseEnter:()=>x(H),onClick:()=>E($),children:[e.jsx(bs,{project:$,size:24}),e.jsxs("div",{className:"project-option-text",children:[e.jsx("span",{className:"project-option-name",children:$}),A&&e.jsxs("span",{className:`project-option-source${A.error?" error":""}`,children:[e.jsx(ul,{source:A,size:11,active:A.config?.kind==="github"}),A.error??ys(A)]})]}),A?.error?e.jsx("button",{className:"project-option-fix",onClick:P=>{P.stopPropagation(),N($)},children:"Fix"}):e.jsxs(e.Fragment,{children:[W&&e.jsx(De,{size:14,className:"project-option-check"}),e.jsx("button",{className:"project-option-gear",title:`Settings of ${$}`,onClick:P=>{P.stopPropagation(),N($)},children:e.jsx(Yn,{size:14})})]})]},$)})}),e.jsx("div",{className:"project-menu-footer",children:u?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:$=>d($.target.value),onKeyDown:$=>{$.key==="Enter"&&_(),$.key==="Escape"&&m(!1)}}),e.jsx("button",{className:"new-project-btn",onClick:_,title:"Create project",children:e.jsx(De,{size:14})})]}):e.jsxs("button",{className:"project-menu-action",onClick:()=>m(!0),children:[e.jsx(Bn,{size:14}),"New project"]})})]})]})]})}function hl({focusToken:t}){const s=ae(),n=i.useRef(null),{searchQuery:a,searchResults:o,searchAllProjects:r,setSearchAllProjects:l,setSearchQuery:c,setSearchResults:d,clearSearch:u,currentProject:m,selectedDocId:h}=Z(),[p,f]=i.useState(a);i.useEffect(()=>{n.current?.focus(),n.current?.select()},[t]);const x=async()=>{if(p.trim()){c(p);try{const y=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(y.results||[])}catch{d([])}}},j=()=>{f(""),u(),s(te(m,null))},g=v=>{v.key==="Enter"&&x(),v.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:v=>f(v.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(v=>{const y=v.project??m,w=h===v.id&&m===y;return e.jsxs("div",{className:`search-result${w?" active":""}`,onClick:()=>s(te(y,v.id)),children:[e.jsxs("div",{className:"search-result-head",children:[e.jsx("span",{className:"search-result-title",children:v.title}),e.jsxs("span",{className:"search-result-score",children:[(v.score*100).toFixed(0),"%"]})]}),v.project&&e.jsxs("div",{className:"search-result-meta",children:["Project: ",v.project]}),e.jsxs("div",{className:"search-result-excerpt",children:[v.excerpt.substring(0,80),"..."]})]},`${y}::${v.id}`)})]})}function ml(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 u=r.get(d);c===o.length-1?u.docs.push(a):r=u.children}}return{rootDocs:s,folders:n}}function ua(t){let s=t.docs.length;for(const n of t.children.values())s+=ua(n);return s}function ha(t){return t.docs.some(s=>s.isStale)||[...t.children.values()].some(ha)}function ma(t){return[...t.values()].flatMap(s=>[s.path,...ma(s.children)])}function pl(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 zt=t=>8+t*16;function ct({doc:t,selectedDocId:s,onSelect:n,depth:a=0,showCreatedAt:o=!1}){return e.jsxs("div",{className:`tree-row tree-row--doc${s===t.id?" active":""}`,style:{paddingLeft:zt(a)+16},onClick:()=>n(t.id),title:t.isStale?`${t.title} — outdated`:t.title,children:[e.jsx(Cn,{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:pl(t.createdAt)}),t.isStale&&e.jsx("span",{className:"stale-dot"})]})}function pa({nodes:t,depth:s,selectedDocId:n,onSelect:a,expanded:o,onToggle:r}){return e.jsx(e.Fragment,{children:[...t.entries()].sort(([l],[c])=>l.localeCompare(c)).map(([,l])=>{const c=!!o[l.path],d=c?vt:Lr,u=c?yt:Rn;return e.jsxs("div",{children:[e.jsxs("div",{className:"tree-row tree-row--folder",style:{paddingLeft:zt(s)},onClick:()=>r(l.path),children:[e.jsx(d,{size:12,className:"tree-row-chevron"}),e.jsx(u,{size:14,className:"tree-row-icon"}),e.jsx("span",{className:"tree-row-label",children:l.name}),ha(l)&&e.jsx("span",{className:"stale-dot",title:"Contains outdated docs"}),e.jsx("span",{className:"tree-row-count",children:ua(l)})]}),c&&e.jsxs("div",{className:"tree-children",style:{"--guide-x":`${zt(s)+6}px`},children:[l.docs.map(m=>e.jsx(ct,{doc:m,selectedDocId:n,onSelect:a,depth:s+1},m.id)),e.jsx(pa,{nodes:l.children,depth:s+1,selectedDocId:n,onSelect:a,expanded:o,onToggle:r})]})]},l.path)})})}function fl({mode:t,searchFocusToken:s,onCreateDoc:n,onOpenProjectSettings:a,onClose:o}){const r=ae(),{docs:l,selectedDocId:c,currentProject:d,exportBundles:u,readOnly:m}=Z(),[h,p]=i.useState(()=>({project:d,folders:vs(d)}));h.project!==d&&p({project:d,folders:vs(d)});const f=h.folders,x=D=>{const _=D(f);Jr(d,_),p({project:d,folders:_})},j=i.useMemo(()=>ml(l),[l]),g=i.useMemo(()=>l.filter(D=>D.isStale),[l]),v=i.useMemo(()=>[...l].sort((D,_)=>{const C=D.createdAt?new Date(D.createdAt).getTime():0;return(_.createdAt?new Date(_.createdAt).getTime():0)-C}),[l]),y=l.find(D=>D.id===c)?.folder,w=i.useMemo(()=>{const D={};let _="";for(const C of(y??"").split("/").filter(Boolean))_=_?`${_}/${C}`:C,D[_]=!0;return{...D,...f}},[y,f]),b=D=>{r(te(d,D))},k=D=>{x(_=>({..._,[D]:!w[D]}))},R=()=>{x(()=>Object.fromEntries(ma(j.folders).map(D=>[D,!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(v.length)},exports:{title:"Export bundles",count:String(u.length)}},N=()=>{switch(t){case"search":return e.jsx(hl,{focusToken:s});case"exports":return e.jsx(Qr,{});case"recent":return v.length===0?e.jsx("div",{className:"nav-empty",children:"No documentation entries yet."}):v.map(D=>e.jsx(ct,{doc:D,selectedDocId:c,onSelect:b,showCreatedAt:!0},D.id));case"outdated":return g.length===0?e.jsx("div",{className:"nav-empty",children:"All docs are up to date."}):g.map(D=>e.jsx(ct,{doc:D,selectedDocId:c,onSelect:b},D.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(pa,{nodes:j.folders,depth:0,selectedDocId:c,onSelect:b,expanded:w,onToggle:k}),j.rootDocs.map(D=>e.jsx(ct,{doc:D,selectedDocId:c,onSelect:b},D.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(Bn,{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(Tr,{size:15})}),e.jsx("button",{className:"nav-panel-tool",onClick:o,title:"Hide panel",children:e.jsx(qr,{size:15})})]}),e.jsx("div",{className:"nav-panel-scroll",children:N()})]})}function gl({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 xl(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 vl(t){return t.split(`
4
+ `).map(s=>({type:xl(s),content:s}))}function jl({diffText:t}){const s=vl(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 yl{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=y=>{if(y=this.postProcess(y,a),o){setTimeout(function(){o(y)},0);return}else return y},c=n.length,d=s.length;let u=1,m=c+d;a.maxEditLength!=null&&(m=Math.min(m,a.maxEditLength));const h=(r=a.timeout)!==null&&r!==void 0?r:1/0,p=Date.now()+h,f=[{oldPos:-1,lastComponent:void 0}];let x=this.extractCommon(f[0],n,s,0,a);if(f[0].oldPos+1>=d&&x+1>=c)return l(this.buildValues(f[0].lastComponent,n,s));let j=-1/0,g=1/0;const v=()=>{for(let y=Math.max(j,-u);y<=Math.min(g,u);y+=2){let w;const b=f[y-1],k=f[y+1];b&&(f[y-1]=void 0);let R=!1;if(k){const N=k.oldPos-y;R=k&&0<=N&&N<c}const E=b&&b.oldPos+1<d;if(!R&&!E){f[y]=void 0;continue}if(!E||R&&b.oldPos<k.oldPos?w=this.addToPath(k,!0,!1,0,a):w=this.addToPath(b,!1,!0,1,a),x=this.extractCommon(w,n,s,y,a),w.oldPos+1>=d&&x+1>=c)return l(this.buildValues(w.lastComponent,n,s))||!0;f[y]=w,w.oldPos+1>=d&&(g=Math.min(g,y-1)),x+1>=c&&(j=Math.max(j,y+1))}u++};if(o)(function y(){setTimeout(function(){if(u>m||Date.now()>p)return o(void 0);v()||y()},0)})();else for(;u<=m&&Date.now()<=p;){const y=v();if(y)return y}}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,u=d-o,m=0;for(;u+1<l&&d+1<c&&this.equals(a[d+1],n[u+1],r);)u++,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,u}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,u=0;for(;c<l;c++){const m=o[c];if(m.removed)m.value=this.join(a.slice(u,u+m.count)),u+=m.count;else{if(!m.added&&this.useLongestToken){let h=n.slice(d,d+m.count);h=h.map(function(p,f){const x=a[u+f];return x.length>p.length?x:p}),m.value=this.join(h)}else m.value=this.join(n.slice(d,d+m.count));d+=m.count,m.added||(u+=m.count)}}return o}}function Ns(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 Ft(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 Ot(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 Ue(t,s){return Ft(t,s,"")}function st(t,s){return Ot(t,s,"")}function ks(t,s){return s.slice(0,bl(t,s))}function bl(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 fa(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 Ut(t,s){if(s)return Be(t,s)[1];let n;for(n=t.length-1;n>=0&&t[n].match(/\s/);n--);return t.substring(n+1)}function Re(t,s){if(s)return Be(t,s)[0];const n=t.match(/^\s*/);return n?n[0]:""}function Be(t,s){if(!s)return[Re(t),Ut(t)];if(s.resolvedOptions().granularity!="word")throw new Error('The segmenter passed must have a granularity of "word"');const n=fa(t,s),a=n[0],o=n[n.length-1],r=/\s/.test(a)?a:"",l=/\s/.test(o)?o:"";return[r,l]}const Cs="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}",Nl=new RegExp(`[${Cs}]+|\\s+|[^${Cs}]`,"ug");class wl extends yl{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=fa(s,l)}else a=s.match(Nl)||[];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)&&Ss(a,r,o,l,n.intlSegmenter),a=l,o=null,r=null)}),(o||r)&&Ss(a,r,o,null,n.intlSegmenter),s}}const kl=new wl;function Cl(t,s,n){return kl.diff(t,s,n)}function Ss(t,s,n,a,o){if(s&&n){const[r,l]=Be(s.value,o),[c,d]=Be(n.value,o);if(t){const u=Ns(r,c);t.value=Ot(t.value,c,u),s.value=Ue(s.value,u),n.value=Ue(n.value,u)}if(a){const u=ws(l,d);a.value=Ft(a.value,d,u),s.value=st(s.value,u),n.value=st(n.value,u)}}else if(n){if(t){const r=Re(n.value,o);n.value=n.value.substring(r.length)}if(a){const r=Re(a.value,o);a.value=a.value.substring(r.length)}}else if(t&&a){const r=Re(a.value,o),[l,c]=Be(s.value,o),d=Ns(r,l);s.value=Ue(s.value,d);const u=ws(Ue(r,d),c);s.value=st(s.value,u),a.value=Ft(a.value,r,u),t.value=Ot(t.value,r,r.slice(0,r.length-u.length))}else if(a){const r=Re(a.value,o),l=Ut(s.value,o),c=ks(l,r);s.value=st(s.value,c)}else if(t){const r=Ut(t.value,o),l=Re(s.value,o),c=ks(r,l);s.value=Ue(s.value,c)}}const Lt={create:"Created",update:"Updated",patch:"Patched",delete:"Deleted",snapshot:"Snapshot"},Tt={create:"➕",update:"📝",patch:"🩹",delete:"🗑️",snapshot:"📸"};function Sl(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 u=t.related_docs??[],m=s.related_docs??[],h=m.filter(f=>!u.includes(f)),p=u.filter(f=>!m.includes(f));return(h.length||p.length)&&(n.related_docs={added:h,removed:p}),n}function El({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 $l({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 Rl(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 Dl({docId:t,project:s,entries:n,selectedVersion:a,onSelectVersion:o,markdownComponents:r}){const[l,c]=i.useState(null),[d,u]=i.useState(!1),[m,h]=i.useState(new Set),{uncommitted:p,groups:f}=i.useMemo(()=>Rl(n),[n]),x=b=>{h(k=>{const R=new Set(k);return R.has(b)?R.delete(b):R.add(b),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 b=n.filter(k=>k.version<a.version&&k.changeType==="snapshot").sort((k,R)=>R.version-k.version);return b.length>0?b[0].version:Math.min(...n.map(k=>k.version))}return a.version-1})(),v=g!==null?n.find(b=>b.version===g)??null:null,y=v?Sl(v.metadata,a.metadata):null,w=y&&Object.keys(y).length>0;return i.useEffect(()=>{if(c(null),!a||!j||g===null)return;let b=!1;return u(!0),fetch(`/api/history-version/${me(t)}/${g}?project=${encodeURIComponent(s)}`).then(k=>k.json()).then(k=>{if(b)return;const R=k?.content??"",E=a.content??"";c(Cl(R,E))}).catch(()=>{b||c([])}).finally(()=>{b||u(!1)}),()=>{b=!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(b=>{const k=a?.version===b.version,R=new Date(b.changedAt).toLocaleString(),E=Lt[b.changeType]??b.changeType,N=Tt[b.changeType]??"❓";return e.jsxs("button",{className:`history-entry history-entry--sub${k?" history-entry--active":""}`,onClick:()=>o(b.version),children:[e.jsxs("div",{className:"history-entry-header",children:[e.jsxs("span",{className:"history-entry-version",children:["v",b.version]}),e.jsxs("span",{className:`history-entry-type history-entry-type--${b.changeType}`,children:[N," ",E]})]}),e.jsx("span",{className:"history-entry-date",children:R})]},b.version)})]}),f.length===0&&p.length===0&&e.jsx("div",{className:"doc-viewer-empty",children:"No version history available."}),f.map(b=>{const k=a?.version===b.snapshot.version,R=m.has(b.snapshot.version),E=new Date(b.snapshot.changedAt).toLocaleString();return e.jsxs("div",{className:"history-group",children:[e.jsx("div",{className:`history-entry history-entry--snapshot-card${k?" history-entry--active":""}`,children:e.jsxs("button",{className:"history-entry-snapshot-main",onClick:()=>o(b.snapshot.version),children:[e.jsxs("div",{className:"history-entry-header",children:[e.jsxs("span",{className:"history-entry-version",children:["Version ",b.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}),b.subEntries.length>0&&e.jsx("span",{className:`history-group-toggle${R?" history-group-toggle--open":""}`,onClick:N=>{N.stopPropagation(),x(b.snapshot.version)},role:"button",tabIndex:0,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.stopPropagation(),x(b.snapshot.version))},children:R?"Masquer ▲":`Voir les ${b.subEntries.length} modification${b.subEntries.length>1?"s":""} ▼`})]})]})}),R&&e.jsx("div",{className:"history-group-entries",children:b.subEntries.map(N=>{const D=a?.version===N.version,_=new Date(N.changedAt).toLocaleString(),C=Lt[N.changeType]??N.changeType,M=Tt[N.changeType]??"❓";return e.jsxs("button",{className:`history-entry history-entry--sub${D?" history-entry--active":""}`,onClick:()=>o(N.version),children:[e.jsxs("div",{className:"history-entry-header",children:[e.jsxs("span",{className:"history-entry-version",children:["v",N.version]}),e.jsxs("span",{className:`history-entry-type history-entry-type--${N.changeType}`,children:[M," ",C]})]}),e.jsx("span",{className:"history-entry-date",children:_})]},N.version)})})]},b.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:[Tt[a.changeType]??"❓"," ",Lt[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]})]}),w&&e.jsx(El,{diff:y})]}),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($l,{changes:l}):null:e.jsx("div",{className:"doc-content",children:e.jsx(Ms,{remarkPlugins:[_s],rehypePlugins:[Is],components:r,children:a.content??""})})]}):e.jsx("div",{className:"doc-viewer-empty",children:"Select a version to view its content."})})]})}const Pl={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 Ll(t){const s=t.split(".").pop()?.toLowerCase()??"";return Pl[s]??"text"}function Tl({docId:t,project:s,filePath:n,onClose:a}){const[o,r]=i.useState([]),[l,c]=i.useState(!0),[d,u]=i.useState(null);i.useEffect(()=>{const h=new AbortController,p=n.split("/").map(encodeURIComponent).join("/");return fetch(`/api/file-section/${p}?docId=${encodeURIComponent(t)}&project=${encodeURIComponent(s)}`,{signal:h.signal}).then(f=>f.json()).then(f=>{if(f.error)throw new Error(f.error);r(f.sections??[])}).catch(f=>{f.name!=="AbortError"&&u(f.message)}).finally(()=>c(!1)),()=>h.abort()},[t,n]),i.useEffect(()=>{const h=p=>{p.key==="Escape"&&a()};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[a]);const m=Ll(n);return e.jsx("div",{className:"modal-overlay",onClick:a,children:e.jsxs("div",{className:"modal-content",onClick:h=>h.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((h,p)=>e.jsxs("div",{children:[e.jsxs("p",{className:"section-code-header",children:["Lines ",h.start,"–",h.end]}),e.jsx(Ga,{language:m,style:Ka,customStyle:{margin:0,borderRadius:"6px",fontSize:"13px"},codeTagProps:{style:{fontFamily:"'Fira Code', 'Cascadia Code', Consolas, monospace"}},showLineNumbers:!0,startingLineNumber:h.start,children:h.code})]},p))]})]})})}function Ml({project:t,triggerRef:s,onInsert:n,onClose:a}){const[o,r]=i.useState("upload"),[l,c]=i.useState(""),[d,u]=i.useState(""),[m,h]=i.useState(!1),[p,f]=i.useState(null),[x,j]=i.useState([]),[g,v]=i.useState({visibility:"hidden"}),y=i.useRef(null);i.useLayoutEffect(()=>{const E=y.current;if(!E)return;const N=E.offsetHeight,D=360;v({position:"fixed",top:Math.max(8,(window.innerHeight-N)/2),left:Math.max(8,(window.innerWidth-D)/2),width:D,visibility:"visible"})},[s]),i.useEffect(()=>{fetch(`/api/images/${encodeURIComponent(t)}`).then(E=>E.json()).then(E=>j(E)).catch(()=>{})},[t]),i.useEffect(()=>{function E(N){y.current&&!y.current.contains(N.target)&&s.current!==N.target&&a()}return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[a,s]);const w=i.useCallback(async E=>{h(!0),f(null);try{const N=new FormData;N.append("file",E);const D=await fetch(`/api/images?project=${encodeURIComponent(t)}`,{method:"POST",body:N});if(!D.ok){const C=await D.json().catch(()=>({}));throw new Error(C.error??"Upload failed")}const{url:_}=await D.json();n(`![${l}](${_})`),a()}catch(N){f(N instanceof Error?N.message:"Upload failed")}finally{h(!1)}},[t,l,n,a]),b=async E=>{const N=E.target.files?.[0];N&&await w(N)};i.useEffect(()=>{const E=async N=>{const _=Array.from(N.clipboardData?.items??[]).find(H=>H.type.startsWith("image/"));if(!_)return;N.preventDefault();const C=_.getAsFile();if(!C)return;const M=C.type.split("/")[1]??"png",$=new File([C],`paste-${Date.now()}.${M}`,{type:C.type});await w($)};return document.addEventListener("paste",E),()=>document.removeEventListener("paste",E)},[w]);const k=()=>{d.trim()&&(n(`![${l}](${d.trim()})`),a())},R=E=>{n(`![${l}](${E})`),a()};return Pr.createPortal(e.jsxs("div",{className:"image-insert-popover",ref:y,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:b,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=>u(E.target.value),onKeyDown:E=>E.key==="Enter"&&k()}),e.jsx("button",{className:"image-insert-btn-insert",onClick:k,disabled:!d.trim(),children:"Insert"})]}),x.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:x.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 Es(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 Il(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 _l({doc:t,isStale:s,report:n,toc:a,activeHeadingId:o,version:r,onSelectHeading:l,onSelectFile:c,onClose:d}){const u=ae(),{docs:m,projects:h,currentProject:p}=Z(),f=x=>!!t.tracked_files.find(g=>g.path===x)?.sections?.length&&Es(n,x)!=="anchors_lost";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:[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:"▷|"})]}),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))})]}),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:Il(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 j=Es(n,x.path),g=f(x.path);return e.jsxs("button",{className:`rail-file${g?" rail-file--clickable":""}`,onClick:g?()=>c(x.path):void 0,title:g?`${x.path} — voir le code de la section`:x.path,children:[e.jsx("span",{className:`rail-file-dot rail-file-dot--${j}`}),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 j=x.indexOf(":");if(j!==-1){const v=x.slice(0,j),y=x.slice(j+1);return h.includes(v)?e.jsxs("button",{className:"rail-link rail-link--cross-project",onClick:()=>u(te(v,y)),title:`Projet : ${v}`,children:["↗ ",v," · ",y]},x):e.jsxs("span",{className:"rail-link rail-link--broken",children:[x," (projet introuvable)"]},x)}const g=m.find(v=>v.id===x);return g?e.jsxs("button",{className:"rail-link",onClick:()=>u(te(p,x)),children:["▤ ",g.title]},x):e.jsxs("span",{className:"rail-link rail-link--broken",children:[x," (lien cassé)"]},x)})})]})]})}function ga(){const[t,s]=i.useState(!1);return{copied:t,copy:async a=>{await navigator.clipboard.writeText(a),s(!0),setTimeout(()=>s(!1),2e3)}}}function xa(t){const{publicationsVersion:s}=Z(),[n,a]=i.useState(null),[o,r]=i.useState(null),[l,c]=i.useState(0);i.useEffect(()=>{let u=!1;return Ja(t).then(m=>{u||(a({project:t,publications:m}),r(null))}).catch(m=>{u||r(m.message)}),()=>{u=!0}},[t,s,l]);const d=i.useCallback(()=>c(u=>u+1),[]);return{publications:n?.project===t?n.publications:null,error:o,reload:d}}function Al({project:t,doc:s,latestVersion:n,readOnly:a}){const{publications:o,reload:r}=xa(t),[l,c]=i.useState(!1),d=o?.find(m=>m.docId===s.id)??null;if(i.useEffect(()=>{if(!l)return;const m=h=>{h.key==="Escape"&&c(!1)};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[l]),o===null||!d&&a)return null;const u=()=>{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:u,title:d?"Public link of this document":"Publish this document",children:[e.jsx(bt,{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(Fl,{publication:d,readOnly:a,onClose:()=>c(!1),onChanged:r}):e.jsx(zl,{project:t,doc:s,latestVersion:n,onClose:()=>c(!1),onChanged:r})})]})]})}function va({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(ta,{size:14})})]})}function ja({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:_t,rows:3,placeholder:a,onChange:r=>n(r.target.value),autoFocus:!0}):e.jsx("input",{className:"publish-input",value:s,maxLength:_t,placeholder:a,onChange:r=>n(r.target.value)})]})}function zl({project:t,doc:s,latestVersion:n,onClose:a,onChanged:o}){const[r,l]=i.useState(""),[c,d]=i.useState(!1),[u,m]=i.useState(null),h=async()=>{d(!0),m(null);try{await Ya(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(va,{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(Or,{size:14}),"Version ",Se(n)," · modified ",Vt(s.updatedAt)]}),e.jsx(ja,{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(zs,{size:14}),"Anyone with the link can read this document."]}),u&&e.jsx("div",{className:"publish-error",children:u}),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:h,disabled:c,children:[e.jsx(bt,{size:14}),c?"Publishing…":"Publish"]})]})]})}function Fl({publication:t,readOnly:s,onClose:n,onChanged:a}){const[o,r]=i.useState(""),[l,c]=i.useState(!1),[d,u]=i.useState(null),[m,h]=i.useState(!1),{copied:p,copy:f}=ga(),x=As(t.token),j=t.status==="modified",g=async v=>{c(!0),u(null);try{await v(),r(""),h(!1),a()}catch(y){u(y instanceof Error?y.message:String(y))}finally{c(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx(va,{title:"Document published",published:!0,onClose:n}),e.jsxs("div",{className:"publish-link",children:[e.jsx(zs,{size:14,className:"publish-link-icon"}),e.jsx("span",{className:"publish-link-url",title:x,children:x}),e.jsx("a",{className:"publish-icon-btn",href:x,target:"_blank",rel:"noopener noreferrer",title:"Open the public page",children:e.jsx(wn,{size:14})}),e.jsx("button",{className:"publish-copy-btn",onClick:()=>f(x),title:"Copy the link",children:p?e.jsx(De,{size:14}):e.jsx(jt,{size:14})})]}),e.jsxs("div",{className:"publish-meta",children:["Published ",Vt(t.publishedAt)," · version ",Se(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(es,{size:14}),e.jsxs("div",{children:["The document changed since it was published.",e.jsx("br",{}),"Published: ",Se(t.version)," · current: ",Se(t.currentVersion)]})]}):e.jsxs("div",{className:"publish-uptodate",children:[e.jsx(He,{size:14}),"The published version is up to date."]}),!s&&j&&!m&&e.jsx(ja,{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(ya,{busy:l,onCancel:()=>h(!1),onConfirm:()=>g(()=>Fs(t.id))}):e.jsxs("div",{className:"publish-actions publish-actions--split",children:[e.jsxs("button",{className:"btn-secondary publish-danger-btn",onClick:()=>h(!0),disabled:l,children:[e.jsx(Zn,{size:14}),"Unpublish"]}),j&&e.jsxs("button",{className:"btn-primary",onClick:()=>g(()=>Os(t.id,o)),disabled:l,children:[e.jsx(ht,{size:14}),l?"Updating…":"Update publication"]})]}))]})}function ya({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 $s(t){return t.replace(/[^a-zA-Z0-9_\-. ]/g,"_")}const Ol=1280,Ht="mcp-documentor.contextRail",We=()=>typeof window>"u"||window.innerWidth>=Ol;function Ul(){try{const t=JSON.parse(localStorage.getItem(Ht)??"null");return t&&t.wide===We()?t.open:null}catch{return null}}function Mt(t){try{t===null?localStorage.removeItem(Ht):localStorage.setItem(Ht,JSON.stringify({open:t,wide:We()}))}catch{}}function Rs(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 Hl(){const t=ae(),s=Z(),{selectedDoc:n,selectedDocId:a,freshnessResult:o,setFreshnessResult:r,setSelectedDoc:l,setDocs:c,docs:d,currentProject:u,projects:m,historyEntries:h,historyVersionContent:p,setHistoryEntries:f,setHistoryVersionContent:x,readOnly:j,codeSourcesVersion:g}=s,v=i.useRef(null),y=i.useRef(null),w=i.useRef(null),[b,k]=i.useState("document"),[R,E]=i.useState(null),[N,D]=i.useState(!1),[_,C]=i.useState(!1),[M,$]=i.useState(!1),[H,A]=i.useState(!1),[W,P]=i.useState(!1),[V,K]=i.useState(""),[ee,le]=i.useState(!1),[Ye,Ee]=i.useState(null),[Me,ge]=i.useState(!1),[be,xe]=i.useState(null),[Qe,Ne]=i.useState(null),[Ie,Q]=i.useState(!1),[ue,ie]=i.useState(!1),[we,ke]=i.useState(!1),[$e,ve]=i.useState(null),[L,O]=i.useState(!1),[q,G]=i.useState(!1),[he,kt]=i.useState([]),[Ta,Ct]=i.useState(null),[ns,St]=i.useState(()=>Ul()??We()),as=S=>{Mt(S),St(S)},os=b==="diff",rs=b==="history";i.useEffect(()=>{window.__pdfReady=!!(n&&!W)},[n,W]),i.useEffect(()=>{let S=We();const T=()=>{const z=We();z!==S&&(S=z,Mt(null),St(z))};return window.addEventListener("resize",T),()=>window.removeEventListener("resize",T)},[]),i.useEffect(()=>{const S=T=>{(T.metaKey||T.ctrlKey)&&T.key==="\\"&&(T.preventDefault(),St(z=>(Mt(!z),!z)))};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[]),i.useEffect(()=>{if(!a)return;window.__pdfReady=!1,window.__mermaidPending=0,v.current&&(v.current.scrollTop=0),k("document"),E(null),$(!1),f(null),P(!1),Ee(null),xe(null),ie(!1),ve(null),O(!1),G(!1),kt([]),Ct(null);const S=me(a),T=new AbortController;let z=!1;const B=encodeURIComponent(u);return fetch(`/api/doc/${S}?project=${B}`,{signal:T.signal}).then(U=>U.json()).then(U=>{z||(U.doc?l(U.doc):$(!0))}).catch(U=>{z||U.name==="AbortError"||$(!0)}),fetch(`/api/freshness/${S}?project=${B}`,{signal:T.signal}).then(U=>U.json()).then(U=>{z||!U.report||r(U.report)}).catch(()=>{}),fetch(`/api/history/${S}?project=${B}`,{signal:T.signal}).then(U=>U.json()).then(U=>{z||f(U.versions??[])}).catch(()=>{}),()=>{z=!0,T.abort()}},[a,u]),i.useEffect(()=>{if(g===0||!a)return;const S=new AbortController;return fetch(`/api/freshness/${me(a)}?project=${encodeURIComponent(u)}`,{signal:S.signal}).then(T=>T.json()).then(T=>{T.report&&r(T.report)}).catch(()=>{}),()=>S.abort()},[g]),i.useEffect(()=>{if(b!=="document"||W||!n){kt([]);return}const S=requestAnimationFrame(()=>{const T=v.current?.querySelector(".doc-content");if(!T)return;const z=[...T.querySelectorAll("h1, h2, h3")];kt(z.filter(B=>B.id).map(B=>({id:B.id,text:B.textContent??"",level:Number(B.tagName.slice(1))})))});return()=>cancelAnimationFrame(S)},[n,b,W]),i.useEffect(()=>{const S=v.current;if(!S||he.length===0)return;const T=()=>{const z=S.getBoundingClientRect().top+80;let B=he[0].id;for(const U of he){const je=document.getElementById(U.id);je&&je.getBoundingClientRect().top<=z&&(B=U.id)}Ct(B)};return T(),S.addEventListener("scroll",T,{passive:!0}),()=>S.removeEventListener("scroll",T)},[he]);const Ma=i.useCallback(S=>{document.getElementById(S)?.scrollIntoView({behavior:"smooth",block:"start"}),Ct(S)},[]);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&&M&&!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 Ia=async()=>{if(n)try{const T=await(await fetch(`/api/freshness/${me(n.id)}?project=${encodeURIComponent(u)}`)).json();T.report&&r(T.report)}catch{}},_a=async()=>{n&&(await navigator.clipboard.writeText(n.content),C(!0),setTimeout(()=>C(!1),2e3))},Aa=()=>{if(!n)return;const S=new Blob([n.content],{type:"text/markdown;charset=utf-8"}),T=URL.createObjectURL(S),z=document.createElement("a");z.href=T,z.download=`${$s(n.title)}.md`,document.body.appendChild(z),z.click(),document.body.removeChild(z),URL.revokeObjectURL(T)},za=async()=>{if(!n)return;const S=Number(localStorage.getItem("printScale")??100)/100,T=u,z=n.id;ge(!0),xe(null);try{const B=new URLSearchParams({project:T,docId:z,scale:String(S)}),U=await fetch(`/api/pdf?${B}`);if(U.status===503){const ze=await U.json();xe(ze.message??"Navigateur introuvable pour la génération PDF."),setTimeout(()=>xe(null),8e3);return}if(!U.ok){xe("Échec de la génération PDF."),setTimeout(()=>xe(null),5e3);return}const je=await U.blob(),Ae=await new Promise((ze,Fe)=>{const et=new FileReader;et.onload=()=>ze(et.result),et.onerror=Fe,et.readAsDataURL(je)}),se=document.createElement("a");se.href=Ae,se.download=`${$s(n.title)}.pdf`,document.body.appendChild(se),se.click(),document.body.removeChild(se)}finally{ge(!1)}},Fa=async()=>{if(!(!n||h!==null)){A(!0);try{const T=await(await fetch(`/api/history/${me(n.id)}?project=${encodeURIComponent(u)}`)).json();f(T.versions??[])}catch{f([])}finally{A(!1)}}},Oa=async()=>{if(!(!n||R!==null)){D(!0);try{const T=await(await fetch(`/api/git-diff/${me(n.id)}?project=${encodeURIComponent(u)}`)).json();E(T.diff??T.error??"No diff available.")}catch{E("Failed to load diff.")}finally{D(!1)}}},_e=S=>{k(S),O(!1),G(!1),S!=="document"&&P(!1),S==="diff"&&Oa(),S==="history"&&Fa()},Ua=S=>{const T=y.current;if(!T)return;const z=T.selectionStart,B=T.selectionEnd,U=V.slice(0,z)+S+V.slice(B);K(U),requestAnimationFrame(()=>{T.selectionStart=T.selectionEnd=z+S.length,T.focus()})},Ha=async()=>{if(n){le(!0),Ee(null);try{const S=me(n.id),T=await fetch(`/api/doc/${S}?project=${encodeURIComponent(u)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:V})}),z=await T.json();if(!T.ok||z.error)throw new Error(z.error||"Save failed");const B=new Date().toISOString();l({...n,content:V,updatedAt:B}),c(d.map(U=>U.id===n.id?{...U,updatedAt:B}:U)),P(!1)}catch(S){Ee(S instanceof Error?S.message:"Save failed")}finally{le(!1)}}},Ba=async()=>{if(n){ke(!0),ve(null);try{const S=me(n.id),T=await fetch(`/api/doc/${S}?project=${encodeURIComponent(u)}`,{method:"DELETE"}),z=await T.json();if(!T.ok||z.error)throw new Error(z.error||"Delete failed");const B=n.id;c(d.filter(U=>U.id!==B)),l(null),r(null),ie(!1),t(te(u,null),{replace:!0})}catch(S){ve(S instanceof Error?S.message:"Delete failed")}finally{ke(!1)}}},Et=n?d.find(S=>S.id===n.id):void 0,ls=Et?.isStale??!1,Ce=n?.tracked_files.length??0,Xe=o?.modified.length??0,Ze=h&&h.length>0?h[0].version:null,is=n&&Ce>0?n.tracked_files.map(S=>S.lastModifiedAt).filter(Boolean).sort().slice(-1)[0]:void 0,Wa=[...Et?.folder?Et.folder.split("/").filter(Boolean):[],n?.title??"…"],Va=!j&&!!n&&b==="document",cs={code:Qa,a({href:S,children:T,...z}){if(S?.startsWith("doc://")){const B=S.slice(6),U=B.indexOf(":");if(U!==-1){const se=B.slice(0,U),ze=B.slice(U+1),Fe=m.includes(se);return e.jsx("button",{className:Fe?"doc-inline-link doc-inline-link--cross-project":"doc-inline-link doc-inline-link--broken",onClick:()=>{Fe&&t(te(se,ze))},title:Fe?`Projet : ${se}`:`Projet introuvable : ${se}`,children:T})}const je=B,Ae=d.some(se=>se.id===je);return e.jsx("button",{className:Ae?"doc-inline-link":"doc-inline-link doc-inline-link--broken",onClick:()=>{Ae&&t(te(u,je))},title:Ae?void 0:`Document introuvable : ${je}`,children:T})}return S?.startsWith("#")?e.jsx("a",{href:S,onClick:B=>{B.preventDefault(),document.getElementById(S.slice(1))?.scrollIntoView({behavior:"smooth"})},...z,children:T}):e.jsx("a",{href:S,target:"_blank",rel:"noopener noreferrer",...z,children:T})},img({src:S,alt:T,...z}){return e.jsx("img",{src:S,alt:T??"",className:"doc-image",...z})}};return e.jsxs("div",{className:"doc-viewer",children:[e.jsxs("div",{className:"doc-main",ref:v,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:"→"}),Wa.map((S,T)=>e.jsxs("span",{className:"doc-breadcrumb-segment",children:[T>0&&e.jsx("span",{className:"doc-breadcrumb-sep",children:"/"}),S]},`${S}-${T}`))]}),e.jsx("h1",{className:"doc-title",children:n?.title??"…"})]}),e.jsxs("div",{className:"doc-actions",children:[!ns&&n&&e.jsx("button",{className:"icon-btn",onClick:()=>as(!0),title:"Show details (Ctrl/⌘ + \\)",children:"|◁"}),n&&!W&&e.jsx(Al,{project:u,doc:n,latestVersion:Ze,readOnly:j},n.id),Va&&e.jsx("button",{className:`btn-primary${W?" active":""}`,onClick:()=>{!W&&n&&K(n.content),P(!W),Ee(null)},title:W?"Cancel editing":"Edit document",children:W?"✕ Cancel":"✎ Edit"}),n&&!W&&e.jsxs("div",{className:"menu-anchor",children:[e.jsx("button",{className:"btn-secondary",onClick:()=>{O(S=>!S),G(!1)},title:"Export this document",children:"↓ Export ▾"}),L&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"menu-backdrop",onClick:()=>O(!1)}),e.jsxs("div",{className:"menu-popover",children:[e.jsx("button",{className:"menu-item",onClick:()=>{O(!1),_a()},children:_?"✓ Copied!":"⎘ Copy markdown"}),e.jsx("button",{className:"menu-item",onClick:()=>{O(!1),Aa()},children:"↓ Download .md"}),e.jsx("button",{className:"menu-item",disabled:Me,onClick:()=>{O(!1),za()},children:Me?"⏳ PDF…":"↓ Download PDF"})]})]})]}),n&&!W&&e.jsxs("div",{className:"menu-anchor",children:[e.jsx("button",{className:"btn-icon-secondary",onClick:()=>{G(S=>!S),O(!1)},title:"More actions",children:"⋯"}),q&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"menu-backdrop",onClick:()=>G(!1)}),e.jsxs("div",{className:"menu-popover menu-popover--right",children:[Ce>0&&e.jsx("button",{className:"menu-item",onClick:()=>{G(!1),Ia()},children:"⟳ Re-check freshness"}),e.jsx("button",{className:"menu-item",onClick:()=>{G(!1),navigator.clipboard.writeText(n.id)},children:"⎘ Copy doc ID"}),!j&&e.jsx("button",{className:"menu-item menu-item--danger",onClick:()=>{G(!1),ve(null),ie(!0)},children:"🗑 Delete document"})]})]})]})]})]}),e.jsxs("nav",{className:"doc-tabs",children:[e.jsx("button",{className:`doc-tab${b==="document"?" active":""}`,onClick:()=>_e("document"),children:"Document"}),Ce>0&&e.jsx("button",{className:`doc-tab${os?" active":""}`,onClick:()=>_e("diff"),children:N?"Diff…":`Diff${Xe>0?` · ${Xe}`:""}`}),e.jsx("button",{className:`doc-tab${rs?" active":""}`,onClick:()=>_e("history"),children:H?"History…":`History${Ze!==null?` · v${Ze}`:""}`}),Ce>0&&e.jsxs("button",{className:`doc-tab${b==="files"?" active":""}`,onClick:()=>_e("files"),children:["Tracked files · ",Ce]})]}),be&&e.jsx("div",{className:"pdf-error-banner",children:be}),b==="document"&&!W&&ls&&Ce>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:Xe>0?`${Xe} of ${Ce} tracked files changed since the snapshot taken on ${Rs(is)}.`:`Tracked files changed since the snapshot taken on ${Rs(is)}.`}),e.jsx("button",{className:"stale-banner-link",onClick:()=>_e("diff"),children:"View diff"})]})]}),b==="files"&&n&&(o?e.jsx(gl,{report:o,trackedFiles:n.tracked_files,docId:n.id,onViewCode:Ne}):e.jsx("div",{className:"doc-tab-loading",children:"Checking tracked files…"})),rs&&n&&e.jsx(Dl,{docId:n.id,project:u,entries:h??[],selectedVersion:p,onSelectVersion:async S=>{const z=await(await fetch(`/api/history-version/${me(n.id)}/${S}?project=${encodeURIComponent(u)}`)).json();x(z??null)},markdownComponents:cs}),os&&(N&&R===null?e.jsx("div",{className:"doc-tab-loading",children:"Loading diff…"}):e.jsx(jl,{diffText:R??""})),b==="document"&&(W&&n?e.jsxs("div",{className:"doc-editor",children:[e.jsx("textarea",{ref:y,className:"doc-editor-textarea",value:V,onChange:S=>K(S.target.value),spellCheck:!1}),e.jsxs("div",{className:"doc-editor-actions",children:[Ye&&e.jsx("span",{className:"doc-editor-error",children:Ye}),e.jsxs("div",{className:"doc-editor-actions-right",children:[e.jsx("button",{ref:w,type:"button",className:"image-insert-trigger-btn",onClick:()=>Q(S=>!S),title:"Insert image",children:"🖼 Image"}),Ie&&e.jsx(Ml,{project:u,triggerRef:w,onInsert:Ua,onClose:()=>Q(!1)}),e.jsx("button",{type:"button",className:"save-btn",onClick:Ha,disabled:ee,children:ee?"Saving…":"✓ Save"})]})]})]}):e.jsx("div",{className:"doc-content",children:n&&e.jsx(Ms,{remarkPlugins:[_s],rehypePlugins:[Is],components:cs,urlTransform:S=>S.startsWith("doc://")?S:Xa(S),children:n.content})}))]}),ns&&n&&e.jsx(_l,{doc:n,isStale:ls,report:o,toc:he,activeHeadingId:Ta,version:Ze,onSelectHeading:Ma,onSelectFile:Ne,onClose:()=>as(!1)}),ue&&n&&e.jsx("div",{className:"modal-overlay",onClick:()=>!we&&ie(!1),children:e.jsxs("div",{className:"modal-content delete-modal",onClick:S=>S.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:()=>ie(!1),disabled:we,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:u}),"? This action cannot be undone from the interface."]}),$e&&e.jsx("span",{className:"doc-editor-error",children:$e}),e.jsxs("div",{className:"delete-modal-actions",children:[e.jsx("button",{type:"button",className:"copy-btn",onClick:()=>ie(!1),disabled:we,children:"Cancel"}),e.jsx("button",{type:"button",className:"delete-btn delete-btn--confirm",onClick:Ba,disabled:we,children:we?"Deleting…":"🗑 Delete"})]})]})]})}),Qe&&n&&e.jsx(Tl,{docId:n.id,project:u,filePath:Qe,onClose:()=>Ne(null)})]})}async function ss(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 Bl(){return ss("/api/logs")}function Wl(t,s){const n=s?`?knownSize=${s.size}&knownMtime=${encodeURIComponent(s.mtime??"")}`:"";return ss(`/api/logs/${t}${n}`)}function Vl(){return ss("/api/logs/open-folder",{method:"POST"})}const ql=t=>`/api/logs/${t}/download`;function Ve(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 Y(t){return t.toLocaleString("fr-FR")}function ba(t,s){return t.getFullYear()===s.getFullYear()&&t.getMonth()===s.getMonth()&&t.getDate()===s.getDate()}function wt(t){return ba(new Date(t),new Date)}function Na(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 ba(s,new Date)?a:`${n(s.getDate())}/${n(s.getMonth()+1)} ${a.slice(0,8)}`}function nt(t){return`${Y(t)} ms`}const wa={hour:"Last hour",today:"Today",day:"Last 24 hours",week:"Last 7 days",all:"All loaded"};function ka(t,s){if(s==="all")return!0;if(s==="today")return wt(t);const n=Date.now()-new Date(t).getTime(),a=s==="hour"?36e5:s==="day"?864e5:7*864e5;return n<=a}const Gl=3e3;function Ca(t,s,n){i.useEffect(()=>{if(!s||(t(),!n))return;const a=setInterval(t,Gl);return()=>clearInterval(a)},[s,n,t])}function Bt(t,s,n){const[a,o]=i.useState(null),[r,l]=i.useState(null),[c,d]=i.useState(null),u=i.useRef(void 0),m=i.useRef(!1),h=i.useCallback(async()=>{if(!m.current){m.current=!0;try{const p=await Wl(t,u.current);"unchanged"in p||(u.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 Ca(h,s,n),{data:a,error:r,checkedAt:c}}function Kl(t){const[s,n]=i.useState(null),[a,o]=i.useState(null),r=i.useCallback(async()=>{try{n(await Bl()),o(null)}catch(l){o(l instanceof Error?l.message:String(l))}},[]);return Ca(r,!0,t),{directory:s,error:a}}function Jl(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 Yl(){const{syncEnabled:t,readOnly:s,currentProject:n}=Z(),[a,o]=i.useState(null),[r,l]=i.useState(!1),[c,d]=i.useState(null),u=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||u()},[t,s,n,u]),!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),u()}}},h=[];a?.ahead&&h.push(`↑${a.ahead}`),a?.behind&&h.push(`↓${a.behind}`),a?.dirty?.length&&h.push(`●${a.dirty.length}`);const p=a?.conflicted?.length??0,f=r?"Sync…":p>0?`Conflits à résoudre (${p} fichier(s))`:["Sync",a?.branch,...h.length>0?[h.join(" ")]:[]].filter(Boolean).join(" · "),x=p>0?"!":h[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(ht,{size:20,className:r?"spinning":void 0}),x&&e.jsx("span",{className:`rail-badge rail-badge--${p>0?"danger":"accent"}`,children:x})]}),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 ye({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 Ql({active:t,onSelect:s,onOpenSettings:n,onOpenProjectSettings:a}){const{docs:o}=Z(),r=o.filter(d=>d.isStale).length,l=Bt("github",!0,!0),c=i.useMemo(()=>(l.data?.entries??[]).filter(d=>wt(d.ts)&&!d.ok).length,[l.data]);return e.jsxs("nav",{className:"nav-rail",children:[e.jsx("div",{className:"rail-logo",title:"MCP Documentor",children:e.jsx(Za,{size:18})}),e.jsx(da,{variant:"rail",onOpenSettings:a}),e.jsx("div",{className:"rail-sep"}),e.jsx(ye,{icon:zr,label:"Documentation",active:t==="docs",onClick:()=>s("docs")}),e.jsx(ye,{icon:Nt,label:"Search ⌘K",active:t==="search",onClick:()=>s("search")}),e.jsx(ye,{icon:_r,label:r>0?`Outdated · ${r}`:"Outdated",active:t==="outdated",onClick:()=>s("outdated"),children:r>0&&e.jsx("span",{className:"rail-badge rail-badge--warn",children:r})}),e.jsx(ye,{icon:vn,label:"Recent",active:t==="recent",onClick:()=>s("recent")}),e.jsx(ye,{icon:Vr,label:"Export bundles",active:t==="exports",onClick:()=>s("exports")}),e.jsx(ye,{icon:bt,label:"Publications",active:t==="publications",onClick:()=>s("publications")}),e.jsx("div",{className:"rail-sep"}),e.jsx(ye,{icon:Gn,label:c>0?`Logs · ${c} failed today`:"Logs",active:t==="logs",onClick:()=>s("logs"),children:c>0&&e.jsx("span",{className:"rail-dot"})}),e.jsx("div",{className:"rail-spacer"}),e.jsx(Yl,{}),e.jsx(ye,{icon:Yn,label:"Settings",active:!1,onClick:n})]})}function Xl({onClose:t,onShowMigrationReport:s}){const{readOnly:n}=Z(),[a,o]=i.useState(!1),[r,l]=i.useState(""),[c,d]=i.useState(null),[u,m]=i.useState(""),[h,p]=i.useState(""),[f,x]=i.useState("text-embedding-3-small"),[j,g]=i.useState(100);i.useEffect(()=>{const k=localStorage.getItem("printScale");k&&g(Number(k)),ca().then(R=>o(!!R)).catch(()=>{}),ll().then(R=>l(R.default??"")).catch(()=>{}),fetch("/api/config").then(R=>R.json()).then(R=>{R.dataDir&&m(R.dataDir),R.model&&x(R.model)}).catch(()=>{})},[]);const v=async(k,R)=>{await fetch("/api/configurations/apply",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:k,value:R})})},y=async()=>{d(null);try{const{path:k}=await il(r);l(k??""),d({ok:!0,text:k?"Saved":"Removed"})}catch(k){d({ok:!1,text:k.message})}},w=()=>{localStorage.setItem("printScale",String(j))},b=async()=>{await v("MCP_DATA_DIR",u),h&&await v("MCP_DOCUMENTOR_OPENAI_API_KEY",h),await v("MCP_DOCUMENTOR_OPENAI_MODEL",f),t()};return e.jsx("div",{className:"settings-overlay",onClick:t,children:e.jsxs("div",{className:"settings-popover",onClick:k=>k.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:u,onChange:k=>m(k.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:h,onChange:k=>p(k.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:k=>x(k.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:k=>g(Number(k.target.value)),style:{width:"80px"}}),e.jsx("button",{className:"settings-save-btn",onClick:w,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:k=>l(k.target.value),placeholder:"Absolute path — used by projects without their own root"}),!n&&e.jsx("button",{className:"settings-save-btn",onClick:y,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:b,children:"Save"})]})]})})}function Zl({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 h=t.trim().toLowerCase();return h?n.filter(p=>p.toLowerCase().includes(h)):n},[n,t]);i.useEffect(()=>{if(!a)return;const h=p=>{c.current&&!c.current.contains(p.target)&&o(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[a]),i.useEffect(()=>{l(-1)},[t,a]);const u=h=>{s(h),o(!1)},m=h=>{h.key==="ArrowDown"?(h.preventDefault(),a||o(!0),l(p=>Math.min(p+1,d.length-1))):h.key==="ArrowUp"?(h.preventDefault(),l(p=>Math.max(p-1,0))):h.key==="Enter"&&a&&r>=0&&d[r]?(h.preventDefault(),u(d[r])):h.key==="Escape"&&o(!1)};return e.jsxs("div",{className:"folder-combobox",ref:c,children:[e.jsx("input",{className:"settings-input",value:t,onChange:h=>{s(h.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(h=>!h),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((h,p)=>e.jsx("li",{className:`folder-combobox-item${p===r?" active":""}`,onMouseDown:f=>{f.preventDefault(),u(h)},onMouseEnter:()=>l(p),children:h},h))})]})]})}function ei({onClose:t}){const s=ae(),{currentProject:n,projects:a,docs:o}=Z(),[r,l]=i.useState(n),[c,d]=i.useState(""),[u,m]=i.useState(""),[h,p]=i.useState(""),[f,x]=i.useState(""),[j,g]=i.useState(!1),[v,y]=i.useState(null),[w,b]=i.useState(null),k=i.useMemo(()=>{const N=new Set;for(const D of o)if(D.folder){const _=D.folder.split("/").filter(Boolean);for(let C=1;C<=_.length;C++)N.add(_.slice(0,C).join("/"))}return Array.from(N).sort()},[o]);i.useEffect(()=>{if(r===n){b(null);return}let N=!1;return fetch(`/api/folders?project=${encodeURIComponent(r)}`).then(D=>D.json()).then(D=>{N||(Array.isArray(D?.folders)?b(D.folders):b([]))}).catch(()=>{N||b([])}),()=>{N=!0}},[r,n]);const R=r===n?k:w??[],E=async()=>{if(!c.trim()||!f.trim()){y("Title and content are required");return}g(!0),y(null);try{const N=h.split(",").map(C=>C.trim()).filter(Boolean),D=await fetch("/api/doc",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:c.trim(),content:f,folder:u.trim()||void 0,tags:N.length?N:void 0,project:r})}),_=await D.json();if(!D.ok||_.error)throw new Error(_.error||"Create failed");t(),_.id&&r===n&&s(te(n,_.id))}catch(N){y(N instanceof Error?N.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:N=>N.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:N=>l(N.target.value),children:a.map(N=>e.jsxs("option",{value:N,children:[N,N===n?" (current)":""]},N))})]}),e.jsxs("div",{className:"settings-field",children:[e.jsx("label",{className:"settings-label",children:"Title *"}),e.jsx("input",{className:"settings-input",value:c,onChange:N=>d(N.target.value)})]}),e.jsxs("div",{className:"settings-field",children:[e.jsx("label",{className:"settings-label",children:"Folder"}),e.jsx(Zl,{value:u,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:h,onChange:N=>p(N.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:N=>x(N.target.value),spellCheck:!1,placeholder:`# My new document
5
+
6
+ Write Markdown here…`})]}),e.jsxs("div",{className:"settings-actions",children:[v&&e.jsx("span",{className:"doc-editor-error",style:{marginRight:"auto"},children:v}),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 Ds=400,ti=350,si=300,ni=/^(https?:\/\/github\.com\/|git@github\.com:)?[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+(\.git)?(#.+)?$/i;function ai(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 oi({project:t,onClose:s}){const{readOnly:n}=Z(),[a,o]=i.useState(null),[r,l]=i.useState("local"),[c,d]=i.useState(""),[u,m]=i.useState({state:"idle"}),[h,p]=i.useState(""),[f,x]=i.useState(""),[j,g]=i.useState({state:"idle"}),[v,y]=i.useState({state:"idle"}),[w,b]=i.useState({state:"loading"}),[k,R]=i.useState(!1),[E,N]=i.useState(null),D=i.useRef(null),[_,C]=i.useState(""),[M,$]=i.useState({state:"idle"}),[H,A]=i.useState(!1),[W,P]=i.useState(0);i.useEffect(()=>{let L=!1;return ia().then(O=>{if(L)return;const q=O.find(G=>G.project===t)??{project:t};o(q),q.codeRootOrigin==="project"&&q.codeRoot&&d(q.codeRoot),q.config?.kind==="github"&&(l("github"),p(q.config.repo),x(q.config.branch??""))}).catch(O=>!L&&o({project:t,error:O.message})),cl().then(O=>!L&&b({state:"done",value:O})).catch(O=>!L&&b({state:"failed",error:O.message})),()=>{L=!0}},[t]),i.useEffect(()=>{const L=O=>{O.key==="Escape"&&s()};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[s]),i.useEffect(()=>{if(r!=="local"||c.trim()===""){m({state:"idle"});return}const L=new AbortController;m({state:"loading"});const O=setTimeout(()=>{rl(c.trim(),L.signal).then(q=>m({state:"done",value:q})).catch(q=>{q.name!=="AbortError"&&m({state:"failed",error:q.message})})},Ds);return()=>{clearTimeout(O),L.abort()}},[r,c]),i.useEffect(()=>{const L=_.trim();if(L.replace("/","").length<2){$({state:"idle"});return}const O=new AbortController;$({state:"loading"});const q=setTimeout(()=>{sl(L,O.signal).then(G=>{$({state:"done",value:G}),P(0)}).catch(G=>{G.name!=="AbortError"&&$({state:"failed",error:G.message})})},ti);return()=>{clearTimeout(q),O.abort()}},[_]);const V=H&&!(M.state==="done"&&M.value.some(L=>L.fullName.toLowerCase()===h.trim().toLowerCase()));i.useEffect(()=>{if(V)return;if(r!=="github"||!ni.test(h.trim())){g({state:"idle"}),D.current=null;return}const L=D.current;if(L&&L.repo===h&&L.branch===f)return;const O=new AbortController;g({state:"loading"});const q=setTimeout(()=>{nl(h.trim(),f||void 0,O.signal).then(G=>{g({state:"done",value:G});const he=G.ok&&!f?G.branch:f;D.current={repo:h,branch:he},he!==f&&x(he)}).catch(G=>{G.name!=="AbortError"&&g({state:"failed",error:G.message})})},Ds);return()=>{clearTimeout(q),O.abort()}},[r,h,f,V]);const K=c.trim()===""||u.state==="done"&&u.value.ok,ee=i.useMemo(()=>r==="local"?K?{kind:"local"}:null:j.state!=="done"||!j.value.ok?null:{kind:"github",repo:j.value.repo.fullName,branch:j.value.branch},[r,j,K]),le=r==="local"?c.trim():void 0,Ye=ee?JSON.stringify([ee,le]):null;i.useEffect(()=>{if(!ee){y({state:"idle"});return}const L=new AbortController;y({state:"loading"});const O=setTimeout(()=>{al(t,ee,le,L.signal).then(q=>y({state:"done",value:q})).catch(q=>{q.name!=="AbortError"&&y({state:"failed",error:q.message})})},si);return()=>{clearTimeout(O),L.abort()}},[t,Ye]);const Ee=L=>{p(L),x(""),C(L),A(!0)},Me=L=>{p(L),x(""),C(""),A(!1)},ge=M.state==="done"?M.value:[],be=H&&M.state!=="idle",xe=L=>{be&&(L.key==="ArrowDown"?(L.preventDefault(),P(O=>Math.min(ge.length-1,O+1))):L.key==="ArrowUp"?(L.preventDefault(),P(O=>Math.max(0,O-1))):L.key==="Enter"&&ge[W]?(L.preventDefault(),Me(ge[W].fullName)):L.key==="Escape"&&(L.stopPropagation(),A(!1)))},Qe=async()=>{if(ee){R(!0),N(null);try{await ol(t,ee,le),s()}catch(L){N(L.message),R(!1)}}},Ne=a?.defaultCodeRoot??(a?.codeRootOrigin==="default"?a.codeRoot:void 0),Ie=u.state==="failed"?u.error:u.state==="done"&&!u.value.ok?u.value.error:null,Q=j.state==="done"?j.value:null,ue=Q?.repo,ie=Q?.branches??[],we=j.state==="failed"?j.error:Q&&!Q.ok&&Q.field==="repo"?Q.error:null,ke=be?null:we,$e=Q&&!Q.ok&&Q.field==="branch"?Q.error:null,ve=f&&!ie.includes(f)?[f,...ie]:ie;return e.jsx("div",{className:"modal-overlay",onClick:s,children:e.jsxs("div",{className:"project-settings",onClick:L=>L.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(Rn,{size:13}),t]})]}),e.jsx("button",{className:"ps-close",onClick:s,title:"Close (Esc)",children:e.jsx(ta,{size:18})})]}),e.jsxs("div",{className:"ps-body",children:[a?.error&&!a.config&&e.jsxs("div",{className:"ps-alert error",children:[e.jsx(Ir,{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(Zt,{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(He,{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(Xt,{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(He,{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${Ie?" invalid":""}`,children:[e.jsx(yt,{size:14,className:"ps-input-icon"}),e.jsx("input",{className:"ps-input",value:c,placeholder:Ne?`Machine default: ${Ne}`:"Absolute path of the repository",autoFocus:!0,disabled:n,onChange:L=>d(L.target.value)}),u.state==="loading"&&e.jsx(Pt,{size:14,className:"ps-input-status spinning"}),u.state==="done"&&u.value.ok&&e.jsx(He,{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"})]}),Ie?e.jsx("span",{className:"ps-help error",children:Ie}):c.trim()!==""?u.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."}):Ne?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${ke?" invalid":""}`,children:[ue?e.jsx(ut,{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:h,placeholder:"Search a repository, or paste owner/repo",autoFocus:!0,autoComplete:"off",disabled:n,role:"combobox","aria-expanded":be,"aria-controls":"ps-repo-suggestions",onChange:L=>Ee(L.target.value),onKeyDown:xe,onFocus:()=>A(!0),onBlur:()=>A(!1)}),(j.state==="loading"||M.state==="loading")&&e.jsx(Pt,{size:14,className:"ps-input-status spinning"}),j.state!=="loading"&&M.state!=="loading"&&ue&&!ke&&e.jsx(He,{size:14,className:"ps-input-status ok"})]}),be&&e.jsxs("ul",{className:"ps-suggestions",id:"ps-repo-suggestions",role:"listbox",children:[M.state==="loading"&&e.jsx("li",{className:"ps-suggestion-note",children:"Searching…"}),M.state==="failed"&&e.jsx("li",{className:"ps-suggestion-note error",children:M.error}),M.state==="done"&&ge.length===0&&e.jsx("li",{className:"ps-suggestion-note",children:"No repository found"}),ge.map((L,O)=>e.jsxs("li",{role:"option","aria-selected":O===W,className:`ps-suggestion${O===W?" highlighted":""}`,onMouseEnter:()=>P(O),onMouseDown:q=>{q.preventDefault(),Me(L.fullName)},children:[e.jsxs("span",{className:"ps-suggestion-name",children:[L.private?e.jsx(Wr,{size:12}):e.jsx(ut,{size:12}),L.fullName]}),L.description&&e.jsx("span",{className:"ps-suggestion-desc",children:L.description})]},L.fullName))]})]}),ke?e.jsx("span",{className:"ps-help error",children:ke}):ue?e.jsxs("span",{className:"ps-help ok",children:["Found · ",ue.private?"private":"public"," · default branch ",ue.defaultBranch]}):e.jsxs("span",{className:"ps-help",children:["Searched as you type",w.state==="done"&&w.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${$e?" invalid":""}`,children:[e.jsx(Fr,{size:14,className:"ps-input-icon"}),e.jsxs("select",{className:"ps-input ps-select",value:f,disabled:n||ve.length===0,onChange:L=>x(L.target.value),children:[ve.length===0&&e.jsx("option",{value:"",children:"—"}),ve.map(L=>e.jsxs("option",{value:L,children:[L,L===ue?.defaultBranch?" (default)":""]},L))]}),f&&f===ue?.defaultBranch&&e.jsx("span",{className:"ps-chip",children:"default"})]}),$e?e.jsx("span",{className:"ps-help error",children:$e}):Q?.ok?e.jsxs("span",{className:"ps-help",children:["Head ",Q.head.sha.slice(0,7)," · ",Q.head.message," · ",ai(Q.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(Br,{size:14,className:`ps-token-icon${w.state==="done"&&w.value.login?" ok":w.state==="done"&&w.value.error?" error":""}`}),e.jsxs("span",{className:"ps-token-text",children:[w.state==="loading"&&"Checking the token…",w.state==="failed"&&w.error,w.state==="done"&&(w.value.configured?w.value.login?`${w.value.variable} · connected as ${w.value.login}`:`${w.value.variable} rejected — ${w.value.error}`:`${w.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."})]})]}),v.state!=="idle"&&e.jsxs("div",{className:`ps-preview${v.state==="failed"||v.state==="done"&&v.value.sourceError?" error":""}`,children:[v.state==="loading"?e.jsx(Pt,{size:16,className:"ps-preview-icon spinning"}):e.jsx(Gr,{size:16,className:"ps-preview-icon"}),e.jsxs("div",{className:"ps-preview-text",children:[v.state==="loading"&&e.jsx("span",{className:"ps-preview-title",children:"Checking the docs against this source…"}),v.state==="failed"&&e.jsx("span",{className:"ps-preview-title",children:v.error}),v.state==="done"&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"ps-preview-title",children:["Checked against ",v.value.label," — ",v.value.docs," doc",v.value.docs===1?"":"s"]}),e.jsx("span",{className:"ps-preview-counts",children:v.value.sourceError?v.value.sourceError:[`${v.value.upToDate} up to date`,`${v.value.stale} would be outdated`,`${v.value.unverifiable} unverifiable`,...v.value.broken>0?[`${v.value.broken} with broken tracking`]:[]].join(" · ")})]})]})]})]}),e.jsxs("footer",{className:"ps-footer",children:[e.jsxs("div",{className:"ps-footer-note",children:[e.jsx(Hr,{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:Qe,disabled:!ee||k,children:k?"Applying…":"Apply"})]})]})})}function ri({entry:t}){return t.status!=="imported"?e.jsx(es,{size:14,className:"mig-icon warn"}):t.kind==="code-root"?e.jsx(yt,{size:14,className:"mig-icon"}):t.kind==="local"?e.jsx(Zt,{size:14,className:"mig-icon"}):e.jsx(Xt,{size:14,className:"mig-icon accent"})}function li({onClose:t,onReviewProject:s}){const[n,a]=i.useState(null),[o,r]=i.useState(null),[l,c]=i.useState(!1);i.useEffect(()=>{ca().then(a).catch(h=>r(h.message))},[]);const d=h=>{dl().catch(()=>{}).finally(()=>{t(),h?.()})};i.useEffect(()=>{const h=p=>{p.key==="Escape"&&d()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[]);const u=async()=>{if(n)try{await navigator.clipboard.writeText(n.variables.join(`
7
+ `)),c(!0),setTimeout(()=>c(!1),1500)}catch{}},m=n?.entries.find(h=>h.status==="imported"&&h.project)?.project;return e.jsx("div",{className:"modal-overlay",onClick:()=>d(),children:e.jsxs("div",{className:"migration-report",onClick:h=>h.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(Ur,{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((h,p)=>e.jsxs("tr",{className:h.status!=="imported"?"not-imported":void 0,children:[e.jsx("td",{className:h.project?void 0:"mig-scope",children:h.project??"This machine"}),e.jsx("td",{children:e.jsxs("span",{className:"mig-source",children:[e.jsx(ri,{entry:h}),h.detail]})}),e.jsx("td",{className:"mig-from",children:h.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:u,title:"Copy the list",children:l?e.jsx(De,{size:14}):e.jsx(jt,{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 Wt({tone:t,children:s,wide:n}){return e.jsx("span",{className:`logs-badge logs-badge--${t}${n?" logs-badge--wide":""}`,children:s})}function Sa({source:t,title:s,meta:n,following:a,onToggleFollow:o}){const[r,l]=i.useState(null),c=async()=>{l(null);try{await Vl()}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(yt,{size:14}),"Open folder"]}),e.jsxs("a",{className:"logs-btn",href:ql(t),download:!0,title:"Download the whole file",children:[e.jsx(Ar,{size:14}),"Download"]})]})]})}function Ea({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 $a({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 qe({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(vn,{size:14}),e.jsxs("span",{className:"logs-select-value",children:[a?`${a}: `:"",l]}),e.jsx(vt,{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 ii(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 Ra({following:t,text:s,checkedAt:n,error:a}){const o=Jl();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," · ",ii(n,o)]}),e.jsx("span",{className:"logs-status-order",children:"Newest at the bottom"})]})}function Da({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 ci=["today","day","week","all"];function di(t){return t.ok?"ok":t.status==="404"||t.status==="422"?"warn":"error"}function ui(t){return t.status==="ok"?"OK":t.status==="rejected"?"Rejected":t.status==="failed"?"Failed":t.status==="network error"?"Network":t.status}function hi(t){return i.useMemo(()=>{const s=t.filter(c=>wt(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 mi(t){const s=`GET /repos/${t.repo}/`;return!t.repo||!t.command.startsWith(s)?t.command:`GET /repos/…/${t.command.slice(s.length)}`}function pi({data:t,error:s,checkedAt:n,following:a,onToggleFollow:o}){const[r,l]=i.useState(""),[c,d]=i.useState("all"),[u,m]=i.useState("all"),[h,p]=i.useState("all"),[f,x]=i.useState("today"),[j,g]=i.useState(new Set),[v,y]=i.useState(null),w=i.useMemo(()=>t?.entries??[],[t]),b=hi(w),k=i.useMemo(()=>[...new Set(w.map(P=>P.trigger))].sort((P,V)=>P.localeCompare(V)),[w]),R=i.useMemo(()=>{const P=r.trim().toLowerCase();return w.filter(V=>ka(V.ts,f)&&(u==="all"||u==="ok"===V.ok)&&(h==="all"||V.trigger===h)&&(!P||V.action.toLowerCase().includes(P)||V.command.toLowerCase().includes(P)||(V.repo??"").toLowerCase().includes(P)||(V.error??"").toLowerCase().includes(P)))},[w,r,f,u,h]),E=i.useMemo(()=>c==="all"?R:R.filter(P=>P.kind===c),[R,c]),N=E.slice(-1e3),D=`${t?.file.size}:${N.length}:${c}:${u}:${h}:${f}:${r}`,_=P=>g(V=>{const K=new Set(V);return K.has(P)?K.delete(P):K.add(P),K}),C=async(P,V)=>{try{await navigator.clipboard.writeText(P.raw),y(V),setTimeout(()=>y(K=>K===V?null:K),1500)}catch{}},M=t?.file,$=M?M.exists?`${M.path} · ${Ve(M.size)} · one line per call to GitHub`:`${M.path} · no call to GitHub recorded yet`:"Loading…",H=`${a?"Following new calls":"Paused"} · ${Y(E.length)} of ${Y(w.length)} calls match`+(E.length>N.length?` · showing the latest ${Y(N.length)}`:"")+(t?.unreadable?` · ${t.unreadable} unreadable`:""),A=b.rate,W=A?.reset?new Date(A.reset):null;return e.jsxs("div",{className:"logs-panel",children:[e.jsx(Sa,{source:"github",title:"GitHub access",meta:$,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:Y(b.total)}),e.jsxs("span",{className:"logs-stat-detail",children:[Y(b.git)," git · ",Y(b.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${b.failed?" error":""}`,children:Y(b.failed)}),e.jsx("span",{className:"logs-stat-detail",children:b.failed?b.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:b.average===null?"—":nt(b.average)}),b.slowest&&e.jsxs("span",{className:"logs-stat-detail",title:b.slowest.command,children:["slowest: ",b.slowest.kind==="git"?b.slowest.command.split(" ").slice(0,2).join(" "):b.slowest.action," ",nt(b.slowest.durationMs)]})]})]}),e.jsxs("div",{className:"logs-stat",children:[e.jsxs("div",{className:"logs-stat-label",children:["API rate limit",W&&e.jsxs("span",{className:"logs-stat-aside",children:["resets ",W.toLocaleTimeString("fr-FR",{hour:"2-digit",minute:"2-digit"})]})]}),A?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"logs-stat-value small",children:[Y(A.remaining)," / ",Y(A.limit)]}),e.jsx("div",{className:"logs-gauge",children:e.jsx("div",{className:`logs-gauge-fill${A.remaining/A.limit<.1?" low":""}`,style:{width:`${Math.max(0,Math.min(100,A.remaining/A.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(Ea,{value:r,onChange:l,placeholder:"Filter by command, path, repository…"}),e.jsx($a,{value:c,onChange:d,options:[{value:"all",label:"All",count:R.length},{value:"git",label:"Git",count:R.filter(P=>P.kind==="git").length,tone:"git"},{value:"api",label:"REST API",count:R.filter(P=>P.kind==="api").length,tone:"info"}]}),e.jsx("div",{className:"logs-toolbar-spacer"}),e.jsx(qe,{value:u,onChange:m,prefix:"Status",width:130,options:[{value:"all",label:"all"},{value:"ok",label:"succeeded"},{value:"failed",label:"failed"}]}),e.jsx(qe,{value:h,onChange:p,prefix:"Triggered by",width:200,options:[{value:"all",label:"all"},...k.map(P=>({value:P,label:P}))]}),e.jsx(qe,{value:f,onChange:x,withClock:!0,width:150,options:ci.map(P=>({value:P,label:wa[P]}))})]}),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(Da,{className:"logs-table-body",contentKey:D,children:[N.length===0&&e.jsx("div",{className:"logs-empty",children:t?w.length?"No call matches these filters.":"No call to GitHub recorded yet.":s?"":"Loading…"}),N.map((P,V)=>{const K=`${P.ts}|${E.length-N.length+V}`,ee=j.has(K),le=di(P);return e.jsxs("div",{className:`logs-row logs-row--tall${ee?` open logs-row--${le==="ok"?"info":le}`:""}`,children:[e.jsxs("button",{className:"logs-row-line logs-github-grid",onClick:()=>_(K),title:P.ts,children:[e.jsx("span",{className:"logs-cell-time",children:Na(P.ts)}),e.jsx("span",{children:e.jsx(Wt,{tone:P.kind==="git"?"git":"info",children:P.kind==="git"?"GIT":"API"})}),e.jsxs("span",{className:"logs-cell-what",children:[e.jsx("span",{className:"logs-cell-action",children:P.action}),e.jsx("span",{className:"logs-cell-command",title:P.command,children:mi(P)})]}),e.jsx("span",{className:`logs-cell-repo${P.repo?"":" muted"}`,children:P.repo??"—"}),e.jsx("span",{className:"logs-cell-trigger",children:P.trigger}),e.jsx("span",{children:e.jsx(Wt,{tone:le,wide:!0,children:ui(P)})}),e.jsx("span",{className:"logs-cell-duration",children:nt(P.durationMs)}),ee?e.jsx(un,{size:12,className:"logs-row-chevron"}):e.jsx(vt,{size:12,className:"logs-row-chevron hover-only"})]}),ee&&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:P.ok?`Completed in ${nt(P.durationMs)}.`:P.error??"Failed without an error message."}),e.jsx("pre",{className:"logs-detail-context",children:[`time ${P.ts}`,`command ${P.command}`,`trigger ${P.trigger}`,...P.rateLimit?[`quota ${Y(P.rateLimit.remaining)} / ${Y(P.rateLimit.limit)} requests left`]:[]].join(`
9
+ `)})]}),e.jsxs("button",{className:"logs-btn logs-btn--small",onClick:()=>C(P,K),children:[v===K?e.jsx(De,{size:12}):e.jsx(jt,{size:12}),v===K?"Copied":"Copy log line"]})]})]},K)})]})]}),e.jsx(Ra,{following:a,text:H,checkedAt:n,error:s})]})}const It={DEBUG:"neutral",INFO:"info",WARN:"warn",ERROR:"error"},fi=["DEBUG","INFO","WARN","ERROR"],gi=["hour","day","week","all"],xi="GitHub";function vi({data:t,error:s,checkedAt:n,following:a,onToggleFollow:o}){const r=ae(),[l,c]=i.useState(""),[d,u]=i.useState("all"),[m,h]=i.useState("all"),[p,f]=i.useState("day"),[x,j]=i.useState(new Set),g=i.useMemo(()=>t?.entries??[],[t]),v=i.useMemo(()=>[...new Set(g.map(C=>C.scope))].sort((C,M)=>C.localeCompare(M)),[g]),y=i.useMemo(()=>{const C=l.trim().toLowerCase();return g.filter(M=>(m==="all"||M.scope===m)&&ka(M.ts,p)&&(!C||M.message.toLowerCase().includes(C)||M.scope.toLowerCase().includes(C)||M.continuation.some($=>$.toLowerCase().includes(C))))},[g,l,m,p]),w=i.useMemo(()=>{const C={DEBUG:0,INFO:0,WARN:0,ERROR:0};for(const M of y)C[M.level]++;return C},[y]),b=i.useMemo(()=>d==="all"?y:y.filter(C=>C.level===d),[y,d]),k=b.slice(-1500),R=`${t?.file.size}:${k.length}:${d}:${m}:${p}:${l}`,E=C=>j(M=>{const $=new Set(M);return $.has(C)?$.delete(C):$.add(C),$}),N=t?.file,D=N?N.exists?`${N.path} · ${Ve(N.size)} · ${t.partial?`last ${Y(g.length)} lines`:`${Y(g.length)} lines`}`:`${N.path} · not written yet`:"Loading…",_=`${a?"Following new lines":"Paused"} · ${Y(b.length)} of ${Y(g.length)} lines match`+(b.length>k.length?` · showing the latest ${Y(k.length)}`:"")+(t?.unreadable?` · ${t.unreadable} unreadable`:"");return e.jsxs("div",{className:"logs-panel",children:[e.jsx(Sa,{source:"server",title:"Full log",meta:D,following:a,onToggleFollow:o}),e.jsxs("div",{className:"logs-toolbar",children:[e.jsx(Ea,{value:l,onChange:c,placeholder:"Filter messages, tools, paths…"}),e.jsx($a,{value:d,onChange:u,options:[{value:"all",label:"All",count:y.length},...fi.map(C=>({value:C,label:C[0]+C.slice(1).toLowerCase(),count:w[C],tone:It[C]}))]}),e.jsx("div",{className:"logs-toolbar-spacer"}),e.jsx(qe,{value:m,onChange:h,prefix:"Source",width:150,options:[{value:"all",label:"all"},...v.map(C=>({value:C,label:C}))]}),e.jsx(qe,{value:p,onChange:f,withClock:!0,width:150,options:gi.map(C=>({value:C,label:wa[C]}))})]}),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(Da,{className:"logs-table-body",contentKey:R,children:[k.length===0&&e.jsx("div",{className:"logs-empty",children:t?"No line matches these filters.":s?"":"Loading…"}),k.map((C,M)=>{const $=`${C.ts}|${C.pid}|${b.length-k.length+M}`,H=x.has($),A=C.scope===xi;return e.jsxs("div",{className:`logs-row${H?` open logs-row--${It[C.level]}`:""}`,children:[e.jsxs("button",{className:"logs-row-line logs-server-grid",onClick:()=>E($),title:C.ts,children:[e.jsx("span",{className:"logs-cell-time",children:Na(C.ts)}),e.jsx("span",{children:e.jsx(Wt,{tone:It[C.level],children:C.level})}),e.jsx("span",{className:`logs-cell-scope${A?" github":""}`,children:C.scope}),e.jsxs("span",{className:`logs-cell-message logs-level-text--${C.level.toLowerCase()}`,children:[C.message,C.continuation.length>0&&!H&&e.jsxs("span",{className:"logs-more",children:[" +",C.continuation.length," lines"]})]}),H?e.jsx(un,{size:12,className:"logs-row-chevron"}):e.jsx(vt,{size:12,className:"logs-row-chevron hover-only"})]}),H&&e.jsxs("div",{className:"logs-row-detail logs-detail--server",children:[e.jsx("pre",{className:"logs-detail-context",children:[`time ${C.ts}`,`process ${C.process} · PID ${C.pid}`,`scope ${C.scope}`,"",C.message,...C.continuation].join(`
10
+ `)}),A&&e.jsxs("button",{className:"logs-link",onClick:()=>r(mt("github")),children:[e.jsx(ut,{size:12}),"Open in GitHub log"]})]})]},$)})]})]}),e.jsx(Ra,{following:a,text:_,checkedAt:n,error:s})]})}function ji({source:t}){const s=ae(),[n,a]=i.useState(!0),o=()=>a(p=>!p),{directory:r}=Kl(n),l=Bt("server",t==="server",n),c=Bt("github",!0,n),d=i.useMemo(()=>new Map((r?.files??[]).map(p=>[p.id,p])),[r]),u=i.useMemo(()=>{const p=(c.data?.entries??[]).filter(f=>wt(f.ts));return{calls:p.length,failed:p.filter(f=>!f.ok).length}},[c.data]),m=d.get("server"),h=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(mt("server")),children:[e.jsx(Gn,{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?Ve(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(mt("github")),children:[e.jsx(ut,{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 · ",Y(u.calls)," call",u.calls===1?"":"s"," today"]})]}),u.failed>0&&e.jsxs("span",{className:"logs-source-badge",children:[u.failed," failed"]}),t==="github"&&n&&u.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?Ve(m.size):"—"," · github.log"," ",h?.exists?Ve(h.size):"not written yet"]})]})]}),e.jsx("main",{className:"logs-main",children:t==="server"?e.jsx(vi,{...l,following:n,onToggleFollow:o}):e.jsx(pi,{...c,following:n,onToggleFollow:o})})]})}function yi(){const{currentProject:t,readOnly:s}=Z(),{publications:n,error:a,reload:o}=xa(t),[r,l]=i.useState("all"),c=n??[],d=c.filter(h=>h.status==="modified").length,m=[...r==="modified"?c.filter(h=>h.status==="modified"):c].sort((h,p)=>h.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(bt,{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(h=>e.jsx(Ni,{publication:h,readOnly:s,onChanged:o},h.id)),m.length===0&&e.jsx("div",{className:"pubs-row-empty",children:"No publication changed since it was published."})]})]})}function bi({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 · ",Se(t.version)," → ",Se(t.currentVersion)]}):e.jsxs("span",{className:"pubs-badge pubs-badge--current",children:["Up to date · ",Se(t.version)]})}function Ni({publication:t,readOnly:s,onChanged:n}){const a=ae(),{copied:o,copy:r}=ga(),[l,c]=i.useState("idle"),[d,u]=i.useState(""),[m,h]=i.useState(!1),[p,f]=i.useState(null),x=As(t.token),j=t.docId.includes("/")?t.docId.slice(0,t.docId.lastIndexOf("/")):"",g=async v=>{h(!0),f(null);try{await v(),c("idle"),u(""),n()}catch(y){f(y instanceof Error?y.message:String(y))}finally{h(!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(Cn,{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(te(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:Vt(t.publishedAt)}),e.jsx("span",{children:e.jsx(bi,{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(ht,{size:14}),"Update"]}),e.jsx("button",{className:"publish-icon-btn",onClick:()=>r(x),title:"Copy the link",children:o?e.jsx(De,{size:14}):e.jsx(jt,{size:14})}),e.jsx("a",{className:"publish-icon-btn",href:x,target:"_blank",rel:"noopener noreferrer",title:"Open the public page",children:e.jsx(wn,{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(Zn,{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:_t,placeholder:"e.g. Added the Entry points section",onChange:v=>u(v.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(()=>Os(t.id,d)),disabled:m,children:[e.jsx(ht,{size:14}),m?"Updating…":"Update publication"]})]})]}),l==="unpublish"&&e.jsx("div",{className:"pubs-row-panel",children:e.jsx(ya,{title:t.title,busy:m,onCancel:()=>c("idle"),onConfirm:()=>g(()=>Fs(t.id))})}),p&&e.jsx("div",{className:"publish-error pubs-row-error",children:p})]})}const Pa="mcp-documentor.panelWidth",pt=264,wi=200,ki=520,La=t=>Math.min(ki,Math.max(wi,Math.round(t)));function Ci(){try{const t=Number(localStorage.getItem(Pa));return t?La(t):pt}catch{return pt}}function Ps(t){try{localStorage.setItem(Pa,String(t))}catch{}}function Si(){const[t,s]=i.useState(Ci),[n,a]=i.useState(!1);return{width:t,resizing:n,startResize:l=>{l.preventDefault();const c=l.clientX,d=t;let u=d;a(!0);const m=p=>{u=La(d+p.clientX-c),s(u)},h=()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",h),a(!1),Ps(u)};window.addEventListener("pointermove",m),window.addEventListener("pointerup",h)},resetWidth:()=>{s(pt),Ps(pt)}}}function Ei(){const{codeSourceMigrationPending:t,setCodeSourceMigrationPending:s,currentProject:n,selectedDocId:a}=Z(),o=de(),r=ae(),l=na(o.pathname),c=ts(o.pathname),d=l!==null||c,[u,m]=i.useState(!1),[h,p]=i.useState(!1),[f,x]=i.useState("docs"),[j,g]=i.useState(!0),v=Si(),[y,w]=i.useState(0),[b,k]=i.useState(null),[R,E]=i.useState(!1),N=R||t,D=()=>{d&&r(te(n,a))};i.useEffect(()=>{const M=$=>{($.metaKey||$.ctrlKey)&&$.key.toLowerCase()==="k"&&($.preventDefault(),d&&r(te(n,a)),x("search"),g(!0),w(H=>H+1))};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[d,r,n,a]);const _=M=>{if(M==="logs"){l||r(mt("server"));return}if(M==="publications"){c||r(sa);return}if(!d&&M===f){g($=>!$);return}D(),x(M),g(!0)},C=l?"logs":c?"publications":j?f:null;return e.jsxs("div",{className:"dashboard",children:[e.jsx(Ql,{active:C,onSelect:_,onOpenSettings:()=>m(!u),onOpenProjectSettings:k}),h&&e.jsx(ei,{onClose:()=>p(!1)}),u&&e.jsx(Xl,{onClose:()=>m(!1),onShowMigrationReport:()=>{m(!1),E(!0)}}),b&&e.jsx(oi,{project:b,onClose:()=>k(null)}),N&&e.jsx(li,{onClose:()=>{E(!1),s(!1)},onReviewProject:k}),l?e.jsx(ji,{source:l}):c?e.jsx(yi,{}):e.jsxs("div",{className:"dashboard-body",children:[e.jsxs("div",{className:`nav-panel-wrapper${j?"":" collapsed"}${v.resizing?" resizing":""}`,style:{"--panel-width":`${v.width}px`},children:[e.jsx(fl,{mode:f,searchFocusToken:y,onCreateDoc:()=>p(!0),onOpenProjectSettings:k,onClose:()=>g(!1)}),j&&e.jsx("div",{className:"nav-panel-resizer",onPointerDown:v.startResize,onDoubleClick:v.resetWidth,title:"Drag to resize · double-click to reset"})]}),e.jsx(Hl,{})]})]})}const at="[mcp-documentor]",$i=3e3;async function Ls(t){const s=await fetch(t);if(!s.ok)throw new Error(`${t} answered HTTP ${s.status}: ${await s.text()}`);return s.json()}const Ri=()=>{const t=Z(),s=i.useRef(t);s.current=t,i.useEffect(()=>{let n=null,a,o=!1;const r=u=>{la(u).then(m=>{s.current.currentProject===u&&s.current.setDocs(m)})},l=u=>{if(u.type==="INITIAL_STATE")console.info(`${at} Received INITIAL_STATE from server`),s.current.applyInitialState(u.data);else if(u.type==="CONFIG_UPDATED")console.info(`${at} Received CONFIG_UPDATED from server`);else if(u.type==="BUNDLES_UPDATED")console.info(`${at} Received BUNDLES_UPDATED from server`),s.current.setExportBundles(u.data?.bundles??[]);else if(u.type==="PROJECTS_CHANGED")s.current.applyInitialState({projects:u.data?.projects??[]});else if(u.type==="CODE_SOURCES_CHANGED"){s.current.bumpCodeSourcesVersion();const m=u.data?.project,h=s.current.currentProject;(!m||m===h)&&r(h)}else if(u.type==="DOCS_CHANGED"){const m=u.data?.project;m&&m===s.current.currentProject&&(r(m),s.current.bumpPublicationsVersion())}else u.type==="PUBLICATIONS_CHANGED"&&u.data?.project===s.current.currentProject&&s.current.bumpPublicationsVersion()},c=async u=>{const m=await Ls("/api/initial-state");o||(s.current.applyInitialState(m),u&&(s.current.bumpCodeSourcesVersion(),s.current.bumpPublicationsVersion(),r(s.current.currentProject)))},d=async()=>{try{const u=n?`?since=${n.seq}&epoch=${encodeURIComponent(n.epoch)}`:"",m=await Ls(`/api/changes${u}`);if(o)return;m.reset?await c(n!==null):m.events.forEach(l),n={epoch:m.epoch,seq:m.seq}}catch(u){console.error(`${at} Polling /api/changes failed: ${u instanceof Error?u.message:String(u)}`)}o||(a=setTimeout(d,$i))};return d(),()=>{o=!0,clearTimeout(a)}},[])};function Ts(t){return na(t)!==null||ts(t)}function Di(){const t=de(),s=ae(),{hasReceivedInitialState:n,projects:a,setCurrentProject:o,setDocs:r,setSelectedDocId:l,setSelectedDoc:c}=Z();i.useEffect(()=>{if(!n||Ts(t.pathname))return;const{project:m}=xs(t.pathname);if(m)return;const h=js(),p=(h&&a.includes(h)?h:a[0])??"default";s(te(p,null),{replace:!0})},[n,a,t.pathname,s]),i.useEffect(()=>{if(!n||!ts(t.pathname))return;const m=js();o((m&&a.includes(m)?m:a[0])??"default")},[n,a,t.pathname]);const{project:d,docId:u}=Ts(t.pathname)?{project:null,docId:null}:xs(t.pathname);i.useEffect(()=>{if(!d)return;let m=!1;return o(d),Xr(d),(async()=>{const h=await la(d);m||r(h)})(),()=>{m=!0}},[d]),i.useEffect(()=>{d&&(l(u),u===null&&c(null))},[d,u])}function Pi(){return Ri(),Di(),zo([{path:"*",element:e.jsx(Ei,{})}])}function Li(){return e.jsx(br,{children:e.jsx(Pi,{})})}eo.createRoot(document.getElementById("root")).render(e.jsx(i.StrictMode,{children:e.jsx(Li,{})}));