@imenam/mcp-documentor 1.0.96 → 1.0.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/src/core/comment-store.d.ts +2 -0
- package/dist/src/core/comment-store.js +1 -0
- package/gui/dist/assets/DocContent-ByGAvCaA.js +356 -0
- package/gui/dist/assets/abnfDiagram-WEYOIA3C-C9H-rU6M.js +1 -0
- package/gui/dist/assets/arc-vCYNE25X.js +1 -0
- package/gui/dist/assets/architectureDiagram-ZHVYKT53-BKQrc7ec.js +36 -0
- package/gui/dist/assets/blockDiagram-RJAE7QA3-D_dicGXX.js +140 -0
- package/gui/dist/assets/c4Diagram-XDPPPE54-CZFnurNd.js +38 -0
- package/gui/dist/assets/channel-CXrvaRTy.js +1 -0
- package/gui/dist/assets/chunk-2E7WHVMD-B-MISuU2.js +88 -0
- package/gui/dist/assets/{chunk-QZHKN3VN-BFpijhFi.js → chunk-2Q5K7J3B-2a52SE3x.js} +1 -1
- package/gui/dist/assets/chunk-4EMNKR2T-DPfeHeMi.js +1 -0
- package/gui/dist/assets/chunk-55XCU76K-CuJqVzJg.js +1 -0
- package/gui/dist/assets/{chunk-FMBD7UC4-ytPdLd3c.js → chunk-5VM5RSS4-CjT3LcWh.js} +1 -1
- package/gui/dist/assets/{chunk-4BX2VUAB-AGQbPC36.js → chunk-JWPE2WC7-pBWIoivI.js} +1 -1
- package/gui/dist/assets/{chunk-2J33WTMH-CrEHZokt.js → chunk-VQ5W62QI-B2vesLrV.js} +1 -1
- package/gui/dist/assets/{chunk-55IACEB6-1dY_RrZJ.js → chunk-XXDRQBXY-COcLsneb.js} +1 -1
- package/gui/dist/assets/chunk-ZCHMQSOR-Dmi8Z1BU.js +2 -0
- package/gui/dist/assets/classDiagram-v2-4MYWR3UA-D2osY65Q.js +217 -0
- package/gui/dist/assets/{cose-bilkent-S5V4N54A-DydPBClW.js → cose-bilkent-JH36ORCC-D-LBPHYI.js} +1 -1
- package/gui/dist/assets/cynefin-EF2NZ3EQ-u1hU8acG.js +141 -0
- package/gui/dist/assets/cynefinDiagram-WF24UDRP-BkfQkkkP.js +62 -0
- package/gui/dist/assets/cytoscape.esm-BDkkwuE4.js +321 -0
- package/gui/dist/assets/dagre-NK4GIZVX-C-EzM8in.js +4 -0
- package/gui/dist/assets/diagram-CBK3MWTC-BOKTtHCl.js +24 -0
- package/gui/dist/assets/diagram-I5XIIV2D-ngRhV4vV.js +24 -0
- package/gui/dist/assets/diagram-ODIL2UCW-DwTFpM7V.js +30 -0
- package/gui/dist/assets/diagram-PFBEJUXE-CNhBo08V.js +3 -0
- package/gui/dist/assets/diagram-RJA3I4VV-qNCeztWZ.js +41 -0
- package/gui/dist/assets/diagram-TYUNFSNR-DLMiUXhU.js +200 -0
- package/gui/dist/assets/ebnfDiagram-V4P3TTPT-2EvohYBp.js +1 -0
- package/gui/dist/assets/elk-QONTBCTQ-DWMzZmm4.js +27 -0
- package/gui/dist/assets/erDiagram-KYQIGQAA-BgT-YhVQ.js +99 -0
- package/gui/dist/assets/flowDiagram-IUGLLWBU-CtGI0l2V.js +213 -0
- package/gui/dist/assets/ganttDiagram-R7GPNTJY-DEQo6jBk.js +292 -0
- package/gui/dist/assets/{gitGraphDiagram-PVQCEYII-TGZH1N13.js → gitGraphDiagram-PDYL7XHY-idf8MV3F.js} +3 -3
- package/gui/dist/assets/{graph--OzhPTMs.js → graph-D8UmR1vK.js} +1 -1
- package/gui/dist/assets/infoDiagram-MVDRKAX5-m0KC07GR.js +2 -0
- package/gui/dist/assets/{ishikawaDiagram-YF4QCWOH-BubX7AqP.js → ishikawaDiagram-HPEHV2GE-CQzdMlUE.js} +5 -5
- package/gui/dist/assets/{journeyDiagram-JHISSGLW-BT5Bu4px.js → journeyDiagram-BOSHW7O7-Bn-ydjkw.js} +2 -2
- package/gui/dist/assets/{kanban-definition-UN3LZRKU-CyiNLbBC.js → kanban-definition-FNSA4HC5-CIPHomZ_.js} +22 -22
- package/gui/dist/assets/katex-DLSO0Xi6.js +257 -0
- package/gui/dist/assets/{linear-rOmZOzd-.js → linear-BtDtYBvG.js} +1 -1
- package/gui/dist/assets/{main-B4PH-HO6.css → main-BhezOZ_3.css} +1 -1
- package/gui/dist/assets/main-Cs4w8XB_.js +10 -0
- package/gui/dist/assets/{mindmap-definition-RKZ34NQL-Cvy4YAiE.js → mindmap-definition-6OY57UG3-Dq-MAgfA.js} +16 -14
- package/gui/dist/assets/pegDiagram-ECIUJNBX-DkN63ahL.js +1 -0
- package/gui/dist/assets/pieDiagram-GNMPY74T-DMxFYL7W.js +39 -0
- package/gui/dist/assets/public-BWV0VJ0G.js +1 -0
- package/gui/dist/assets/public-BgJMfZNd.css +1 -0
- package/gui/dist/assets/{quadrantDiagram-W4KKPZXB-DG_N325e.js → quadrantDiagram-D57K4MC3-DvCAV95z.js} +4 -4
- package/gui/dist/assets/railroadDiagram-Y72NRBL7-DIqa4oYb.js +1 -0
- package/gui/dist/assets/requirementDiagram-EQYSW5RA-CiiuKxrT.js +84 -0
- package/gui/dist/assets/sankeyDiagram-SY24JHO5-D7Pqsvht.js +40 -0
- package/gui/dist/assets/sequenceDiagram-BLEHNHQU-CNOJD6dZ.js +169 -0
- package/gui/dist/assets/sizeCapture-INFHLROL-CZUHdjoX.js +1 -0
- package/gui/dist/assets/stateDiagram-v2-A6IESKWZ-DwJxREKr.js +291 -0
- package/gui/dist/assets/swimlanes-B3ENRKFQ-CmwpC4o5.js +1 -0
- package/gui/dist/assets/swimlanesDiagram-AYQRV4AK-DDXQdzqq.js +8 -0
- package/gui/dist/assets/timeline-definition-JXYKGLGB-BYqVvD1n.js +120 -0
- package/gui/dist/assets/usecaseDiagram-WPOLBNNX-w3DqfbYF.js +370 -0
- package/gui/dist/assets/vennDiagram-Q3Y3IDCW-apvvK_7Z.js +34 -0
- package/gui/dist/assets/{wardleyDiagram-YWT4CUSO-Cv3OBAYm.js → wardleyDiagram-IVAIDKWA-DJCHxKD3.js} +4 -4
- package/gui/dist/assets/xychartDiagram-4URNHDU4-CBbKJ4ms.js +7 -0
- package/gui/dist/index.html +3 -3
- package/gui/dist/public.html +3 -3
- package/package.json +2 -2
- package/gui/dist/assets/DocContent-D2Pgvsaw.js +0 -346
- package/gui/dist/assets/arc-ytJX8b9b.js +0 -1
- package/gui/dist/assets/architectureDiagram-3BPJPVTR-vChxNmWw.js +0 -36
- package/gui/dist/assets/blockDiagram-GPEHLZMM-D19nVYke.js +0 -132
- package/gui/dist/assets/c4Diagram-AAUBKEIU-7kCjxzBQ.js +0 -10
- package/gui/dist/assets/channel-DegAVRd2.js +0 -1
- package/gui/dist/assets/chunk-727SXJPM-DFrVc2F4.js +0 -206
- package/gui/dist/assets/chunk-AQP2D5EJ-Bf5AjFYW.js +0 -231
- package/gui/dist/assets/chunk-ND2GUHAM-MQj2MK8N.js +0 -1
- package/gui/dist/assets/classDiagram-4FO5ZUOK-C8gjytbe.js +0 -1
- package/gui/dist/assets/classDiagram-v2-Q7XG4LA2-C8gjytbe.js +0 -1
- package/gui/dist/assets/cytoscape.esm-DkOyvmE4.js +0 -321
- package/gui/dist/assets/dagre-BM42HDAG-Dt1NYir9.js +0 -4
- package/gui/dist/assets/diagram-2AECGRRQ-By8731FV.js +0 -43
- package/gui/dist/assets/diagram-5GNKFQAL-6DboNPr2.js +0 -10
- package/gui/dist/assets/diagram-KO2AKTUF-BlsHXUTP.js +0 -3
- package/gui/dist/assets/diagram-LMA3HP47-NlfihhmZ.js +0 -24
- package/gui/dist/assets/diagram-OG6HWLK6-BuPvvcLW.js +0 -24
- package/gui/dist/assets/erDiagram-TEJ5UH35-Bwh4WcoJ.js +0 -85
- package/gui/dist/assets/flowDiagram-I6XJVG4X-Cpo3jFt_.js +0 -162
- package/gui/dist/assets/ganttDiagram-6RSMTGT7-MTzCwVCF.js +0 -292
- package/gui/dist/assets/infoDiagram-5YYISTIA-CjtHqsAF.js +0 -2
- package/gui/dist/assets/katex-DHMw6HUq.js +0 -257
- package/gui/dist/assets/layout-SsrduOYp.js +0 -1
- package/gui/dist/assets/main-CKkycX8v.js +0 -10
- package/gui/dist/assets/pieDiagram-4H26LBE5-BKrVYqW5.js +0 -30
- package/gui/dist/assets/public-BOnoF84L.js +0 -1
- package/gui/dist/assets/public-BmtG1Lfn.css +0 -1
- package/gui/dist/assets/requirementDiagram-4Y6WPE33-oWqsr2x0.js +0 -84
- package/gui/dist/assets/sankeyDiagram-5OEKKPKP-B8uXp_JX.js +0 -40
- package/gui/dist/assets/sequenceDiagram-3UESZ5HK-bZUsMsnM.js +0 -162
- package/gui/dist/assets/stateDiagram-AJRCARHV-3o_sYDh3.js +0 -1
- package/gui/dist/assets/stateDiagram-v2-BHNVJYJU-CfMfyWVZ.js +0 -1
- package/gui/dist/assets/timeline-definition-PNZ67QCA-BWMaBPME.js +0 -120
- package/gui/dist/assets/vennDiagram-CIIHVFJN-BuBBjBVe.js +0 -34
- package/gui/dist/assets/wardley-L42UT6IY-Da4i2-Py.js +0 -161
- package/gui/dist/assets/xychartDiagram-2RQKCTM6-DFmCIdof.js +0 -7
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{bm as i,bl as O,bo as t,bt as Se,bE as ln,bA as ds,bF as cn,bG as dn,bH as un,c2 as Do,c3 as Lo,bD as To,bw as Mo,br as Ls,bs as Ts,bu as Ms,c4 as Is,c5 as Io,c6 as Ao,c7 as _o,c8 as zo,c9 as Fo,ca as hn,bM as mn,bJ as us,bK as Te,bB as pn,cb as ts,cc as Oo,cd as fn,ce as gn,bv as Uo,bx as Ho,by as ut,bz as Bo,bL as Wo,bI as Vo,bN as qo}from"./DocContent-ByGAvCaA.js";var hs=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,xn=/^[\\/]{2}/;function Go(e,s){return s+e.replace(/\\/g,"/")}var As="popstate";function _s(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function Ko(e={}){function s(o,r){let{pathname:l="/",search:c="",hash:d=""}=ze(o.location.hash.substring(1));return!l.startsWith("/")&&!l.startsWith(".")&&(l="/"+l),ss("",{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:Ae(r))}function a(o,r){ie(o.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(r)})`)}return Yo(s,n,a,e)}function Z(e,s){if(e===!1||e===null||typeof e>"u")throw new Error(s)}function ie(e,s){if(!e){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function Jo(){return Math.random().toString(36).substring(2,10)}function zs(e,s){return{usr:e.state,key:e.key,idx:s,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function ss(e,s,n=null,a,o){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof s=="string"?ze(s):s,state:n,key:s&&s.key||a||Jo(),mask:o}}function Ae({pathname:e="/",search:s="",hash:n=""}){return s&&s!=="?"&&(e+=s.charAt(0)==="?"?s:"?"+s),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function ze(e){let s={};if(e){let n=e.indexOf("#");n>=0&&(s.hash=e.substring(n),e=e.substring(0,n));let a=e.indexOf("?");a>=0&&(s.search=e.substring(a),e=e.substring(0,a)),e&&(s.pathname=e)}return s}function Yo(e,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(),b=g==null?null:g-u;u=g,d&&d({action:c,location:j.location,delta:b})}function p(g,b){c="PUSH";let N=_s(g)?g:ss(j.location,g,b);n&&n(N,g),u=m()+1;let x=zs(N,u),v=j.createHref(N.mask||N);try{l.pushState(x,"",v)}catch(w){if(w instanceof DOMException&&w.name==="DataCloneError")throw w;o.location.assign(v)}r&&d&&d({action:c,location:j.location,delta:1})}function f(g,b){c="REPLACE";let N=_s(g)?g:ss(j.location,g,b);n&&n(N,g),u=m();let x=zs(N,u),v=j.createHref(N.mask||N);l.replaceState(x,"",v),r&&d&&d({action:c,location:j.location,delta:0})}function C(g){return Xo(o,g)}let j={get action(){return c},get location(){return e(o,l)},listen(g){if(d)throw new Error("A history only accepts one active listener");return o.addEventListener(As,h),d=g,()=>{o.removeEventListener(As,h),d=null}},createHref(g){return s(o,g)},createURL:C,encodeLocation(g){let b=C(g);return{pathname:b.pathname,search:b.search,hash:b.hash}},push:p,replace:f,go(g){return l.go(g)}};return j}function Xo(e,s,n=!1){let a="http://localhost";e&&(a=e.location.origin!=="null"?e.location.origin:e.location.href),Z(a,"No window.location.(origin|href) available to create URL");let o=typeof s=="string"?s:Ae(s);return o=o.replace(/ $/,"%20"),!n&&xn.test(o)&&(o=a+o),new URL(o,a)}function vn(e,s,n="/"){return Qo(e,s,n,!1)}function Qo(e,s,n,a,o){let r=typeof s=="string"?ze(s):s,l=ve(r.pathname||"/",n);if(l==null)return null;let c=Zo(e),d=null,u=dr(l);for(let m=0;d==null&&m<c.length;++m)d=cr(c[m],u,a);return d}function Zo(e){let s=jn(e);return er(s),s}function jn(e,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;Z(m.relativePath.startsWith(a),`Absolute route path "${m.relativePath}" nested under path "${a}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),m.relativePath=m.relativePath.slice(a.length)}let h=le([a,m.relativePath]),p=n.concat(m);l.children&&l.children.length>0&&(Z(l.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),jn(l.children,s,p,h,d)),!(l.path==null&&!l.index)&&s.push({path:h,score:lr(h,l.index),routesMeta:p.map((f,C)=>{let[j,g]=Nn(f.relativePath,f.caseSensitive,C===p.length-1);return{...f,matcher:j,compiledParams:g}})})};return e.forEach((l,c)=>{if(l.path===""||!l.path?.includes("?"))r(l,c);else for(let d of bn(l.path))r(l,c,!0,d)}),s}function bn(e){let s=e.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=bn(a.join("/")),c=[];return c.push(...l.map(d=>d===""?r:[r,d].join("/"))),o&&c.push(...l),c.map(d=>e.startsWith("/")&&d===""?"/":d)}function er(e){e.sort((s,n)=>s.score!==n.score?n.score-s.score:ir(s.routesMeta.map(a=>a.childrenIndex),n.routesMeta.map(a=>a.childrenIndex)))}var tr=/^:[\w-]+$/,sr=3,nr=2,ar=1,or=10,rr=-2,Fs=e=>e==="*";function lr(e,s){let n=e.split("/"),a=n.length;return n.some(Fs)&&(a+=rr),s&&(a+=nr),n.filter(o=>!Fs(o)).reduce((o,r)=>o+(tr.test(r)?sr:r===""?ar:or),a)}function ir(e,s){return e.length===s.length&&e.slice(0,-1).every((a,o)=>a===s[o])?e[e.length-1]-s[s.length-1]:0}function cr(e,s,n=!1){let{routesMeta:a}=e,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={path:d.relativePath,caseSensitive:d.caseSensitive,end:u},p=d.matcher&&d.compiledParams?yn(h,m,d.matcher,d.compiledParams):Nt(h,m),f=d.route;if(!p&&u&&n&&!a[a.length-1].route.index&&(p=Nt({path:d.relativePath,caseSensitive:d.caseSensitive,end:!1},m)),!p)return null;Object.assign(o,p.params),l.push({params:o,pathname:le([r,p.pathname]),pathnameBase:mr(le([r,p.pathnameBase])),route:f}),p.pathnameBase!=="/"&&(r=le([r,p.pathnameBase]))}return l}function Nt(e,s){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,a]=Nn(e.path,e.caseSensitive,e.end);return yn(e,s,n,a)}function yn(e,s,n,a){let o=s.match(n);if(!o)return null;let r=o[0],l=_e(r,1),c=o.slice(1);return{params:a.reduce((u,{paramName:m,isOptional:h},p)=>{if(m==="*"){let C=c[p]||"";l=_e(r.slice(0,r.length-C.length),1)}const f=c[p];return h&&!f?u[m]=void 0:u[m]=(f||"").replace(/%2F/g,"/"),u},{}),pathname:r,pathnameBase:l,pattern:e}}function Nn(e,s=!1,n=!0){ie(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let a=[],o="^"+e.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 e.endsWith("*")?(a.push({paramName:"*"}),o+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?o+="\\/*$":e!==""&&e!=="/"&&(o+="(?:(?=\\/|$))"),[new RegExp(o,s?void 0:"i"),a]}function dr(e){try{return e.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return ie(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${s}).`),e}}function ve(e,s){if(s==="/")return e;if(!e.toLowerCase().startsWith(s.toLowerCase()))return null;let n=s.endsWith("/")?s.length-1:s.length,a=e.charAt(n);return a&&a!=="/"?null:e.slice(n)||"/"}function ur(e,s="/"){let{pathname:n,search:a="",hash:o=""}=typeof e=="string"?ze(e):e,r;return n?(n=Cn(n),n.startsWith("/")||n.startsWith("\\")?r=Os(n.substring(1),"/"):r=Os(n,s)):r=s,{pathname:r,search:pr(a),hash:fr(o)}}function Os(e,s){let n=_e(s).split("/");return e.split("/").forEach(o=>{o===".."?n.length>1&&n.pop():o!=="."&&n.push(o)}),n.length>1?n.join("/"):"/"}function Vt(e,s,n,a){return`Cannot include a '${e}' 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 hr(e){return e.filter((s,n)=>n===0||s.route.path&&s.route.path.length>0)}function wn(e){let s=hr(e);return s.map((n,a)=>a===s.length-1?n.pathname:n.pathnameBase)}function ms(e,s,n,a=!1){let o;typeof e=="string"?o=ze(e):(o={...e},Z(!o.pathname||!o.pathname.includes("?"),Vt("?","pathname","search",o)),Z(!o.pathname||!o.pathname.includes("#"),Vt("#","pathname","hash",o)),Z(!o.search||!o.search.includes("#"),Vt("#","search","hash",o)));let r=e===""||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=ur(o,c),u=l&&l!=="/"&&l.endsWith("/"),m=(r||l===".")&&n.endsWith("/");return!d.pathname.endsWith("/")&&(u||m)&&(d.pathname+="/"),d}var Cn=e=>e.replace(/[\\/]{2,}/g,"/"),le=e=>Cn(e.join("/"));function _e(e,s=0){let n=e.length;for(;n>s&&e.charCodeAt(n-1)===47;)n--;return n===e.length?e:e.slice(0,n)}var mr=e=>_e(e).replace(/^\/*/,"/"),pr=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,fr=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,gr=class{constructor(e,s,n,a=!1){this.status=e,this.statusText=s||"",this.internal=a,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function xr(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function vr(e){let s=e.map(n=>n.route.path).filter(Boolean);return le(s)||"/"}var kn=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Sn(e,s){let n=e;if(typeof n!="string"||!hs.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let a=n,o=!1;if(kn)try{let r=new URL(window.location.href),l=xn.test(n)?new URL(Go(n,r.protocol)):new URL(n),c=ve(l.pathname,s);l.origin===r.origin&&c!=null?n=c+l.search+l.hash:o=!0}catch{ie(!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 Us=new URL("http://localhost");function En(e){if(e.createURL)return e.createURL("/");try{return new URL(e.createHref("/"),Us)}catch{return Us}}function qt(e,s){return e.origin===s.origin&&(e.origin!=="null"||e.protocol===s.protocol&&e.host===s.host)}function jr(e,s){if(e.startsWith("//"))return!0;let n=s.protocol.toLowerCase();return e.toLowerCase().startsWith(n)?s.host===""||e.slice(n.length).startsWith("//"):!1}function $n(e,s,n,a){let o=null;try{o=e==null?null:new URL(e,n)}catch{}let r=new URL(s,n),l=o!=null&&!qt(o,n),c=!qt(r,n);if(a==="reject"){if(l||c)throw new Error("External navigation is not allowed")}else if(c&&(o==null||!jr(e,o)||!qt(o,r)))throw new Error("External navigation is not allowed")}var Rn=["POST","PUT","PATCH","DELETE"];new Set(Rn);var br=["GET",...Rn];new Set(br);var yr=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function Nr(e){try{return yr.includes(new URL(e).protocol)}catch{return!1}}var Fe=i.createContext(null);Fe.displayName="DataRouter";var Et=i.createContext(null);Et.displayName="DataRouterState";var Pn=i.createContext(!1);function wr(){return i.useContext(Pn)}var Dn=i.createContext({isTransitioning:!1});Dn.displayName="ViewTransition";var Cr=i.createContext(new Map);Cr.displayName="Fetchers";var kr=i.createContext(null);kr.displayName="Await";var oe=i.createContext(null);oe.displayName="Navigation";var $t=i.createContext(null);$t.displayName="Location";var je=i.createContext({outlet:null,matches:[],isDataRoute:!1});je.displayName="Route";var ps=i.createContext(null);ps.displayName="RouteError";var Ln="REACT_ROUTER_ERROR",Sr="REDIRECT",Er="ROUTE_ERROR_RESPONSE";function $r(e){if(e.startsWith(`${Ln}:${Sr}:{`))try{let s=JSON.parse(e.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 Rr(e){if(e.startsWith(`${Ln}:${Er}:{`))try{let s=JSON.parse(e.slice(40));if(typeof s=="object"&&s&&typeof s.status=="number"&&typeof s.statusText=="string")return new gr(s.status,s.statusText,s.data)}catch{}}function Pr(e,{relative:s}={}){Z(st(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:a}=i.useContext(oe),{hash:o,pathname:r,search:l}=nt(e,{relative:s}),c=r;return n!=="/"&&(c=r==="/"?n:le([n,r])),a.createHref({pathname:c,search:l,hash:o})}function st(){return i.useContext($t)!=null}function ce(){return Z(st(),"useLocation() may be used only in the context of a <Router> component."),i.useContext($t).location}var Tn="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Mn(e){i.useContext(oe).static||i.useLayoutEffect(e)}function re(){let{isDataRoute:e}=i.useContext(je);return e?Br():Dr()}function Dr(){Z(st(),"useNavigate() may be used only in the context of a <Router> component.");let e=i.useContext(Fe),{basename:s,navigator:n}=i.useContext(oe),{matches:a}=i.useContext(je),{pathname:o}=ce(),r=JSON.stringify(wn(a)),l=i.useRef(!1);return Mn(()=>{l.current=!0}),i.useCallback((d,u={})=>{if(ie(l.current,Tn),!l.current)return;if(typeof d=="number"){n.go(d);return}let m=ms(d,JSON.parse(r),o,u.relative==="path");e==null&&s!=="/"&&(m.pathname=m.pathname==="/"?s:le([s,m.pathname])),$n(typeof d=="string"?d:Ae(d),n.createHref(m),En(n),"reject"),(u.replace?n.replace:n.push)(m,u.state,u)},[s,n,r,o,e])}i.createContext(null);function nt(e,{relative:s}={}){let{matches:n}=i.useContext(je),{pathname:a}=ce(),o=JSON.stringify(wn(n));return i.useMemo(()=>ms(e,JSON.parse(o),a,s==="path"),[e,o,a,s])}function Lr(e,s){return In(e)}function In(e,s,n){Z(st(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=i.useContext(oe),{matches:o}=i.useContext(je),r=o[o.length-1],l=r?r.params:{},c=r?r.pathname:"/",d=r?r.pathnameBase:"/",u=r&&r.route;{let g=u&&u.path||"";_n(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=ce(),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 C=n&&n.state.matches.length?n.state.matches.map(g=>Object.assign(g,{route:n.manifest[g.route.id]||g.route})):vn(e,{pathname:f});return ie(u||C!=null,`No routes matched location "${h.pathname}${h.search}${h.hash}" `),ie(C==null||C[C.length-1].route.element!==void 0||C[C.length-1].route.Component!==void 0||C[C.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.`),_r(C&&C.map(g=>Object.assign({},g,{params:Object.assign({},l,g.params),pathname:le([d,a.encodeLocation?a.encodeLocation(g.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathname]),pathnameBase:g.pathnameBase==="/"?d:le([d,a.encodeLocation?a.encodeLocation(g.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathnameBase])})),o,n)}function Tr(){let e=Hr(),s=xr(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.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:",e),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 Mr=i.createElement(Tr,null),An=class extends i.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,s){return s.location!==e.location||s.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:s.error,location:s.location,revalidation:e.revalidation||s.revalidation}}componentDidCatch(e,s){this.props.onError?this.props.onError(e,s):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const n=Rr(e.digest);n&&(e=n)}let s=e!==void 0?i.createElement(je.Provider,{value:this.props.routeContext},i.createElement(ps.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?i.createElement(Ir,{error:e},s):s}};An.contextType=Pn;var Gt=new WeakMap;function Ir({children:e,error:s}){let{basename:n,navigator:a}=i.useContext(oe);if(typeof s=="object"&&s&&"digest"in s&&typeof s.digest=="string"){let o=$r(s.digest);if(o){let r=Gt.get(s);if(r)throw r;let l=Sn(o.location,n),c=l.absoluteURL||l.to;if($n(o.location,c,En(a),"allow-explicit"),Nr(c))throw new Error("Invalid redirect location");if(kn&&!Gt.get(s))if(l.isExternal||o.reloadDocument)window.location.href=c;else{const d=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(l.to,{replace:o.replace}));throw Gt.set(s,d),d}return i.createElement("meta",{httpEquiv:"refresh",content:`0;url=${c}`})}}return e}function Ar({routeContext:e,match:s,children:n}){let a=i.useContext(Fe);return a&&a.static&&a.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=s.route.id),i.createElement(je.Provider,{value:e},n)}function _r(e,s=[],n){let a=n?.state;if(e==null){if(!a)return null;if(a.errors)e=a.matches;else if(s.length===0&&!a.initialized&&a.matches.length>0)e=a.matches;else return null}let o=e,r=a?.errors;if(r!=null){let m=o.findIndex(h=>h.route.id&&r?.[h.route.id]!==void 0);Z(m>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(r).join(",")}`),o=o.slice(0,Math.min(o.length,m+1))}let l=!1,c=-1;if(n&&a){l=a.renderFallback;for(let m=0;m<o.length;m++){let h=o[m];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(c=m),h.route.id){let{loaderData:p,errors:f}=a,C=h.route.loader&&!p.hasOwnProperty(h.route.id)&&(!f||f[h.route.id]===void 0);if(h.route.lazy||C){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??{},pattern:vr(a.matches),errorInfo:h})}:void 0;return o.reduceRight((m,h,p)=>{let f,C=!1,j=null,g=null;a&&(f=r&&h.route.id?r[h.route.id]:void 0,j=h.route.errorElement||Mr,l&&(c<0&&p===0?(_n("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),C=!0,g=null):c===p&&(C=!0,g=h.route.hydrateFallbackElement||null)));let b=s.concat(o.slice(0,p+1)),N=()=>{let x;return f?x=j:C?x=g:h.route.Component?x=i.createElement(h.route.Component,null):h.route.element?x=h.route.element:x=m,i.createElement(Ar,{match:h,routeContext:{outlet:m,matches:b,isDataRoute:a!=null},children:x})};return a&&(h.route.ErrorBoundary||h.route.errorElement||p===0)?i.createElement(An,{location:a.location,revalidation:a.revalidation,component:j,error:f,children:N(),routeContext:{outlet:null,matches:b,isDataRoute:!0},onError:u}):N()},null)}function fs(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function zr(e){let s=i.useContext(Fe);return Z(s,fs(e)),s}function Fr(e){let s=i.useContext(Et);return Z(s,fs(e)),s}function Or(e){let s=i.useContext(je);return Z(s,fs(e)),s}function gs(e){let s=Or(e),n=s.matches[s.matches.length-1];return Z(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Ur(){return gs("useRouteId")}function Hr(){let e=i.useContext(ps),s=Fr("useRouteError"),n=gs("useRouteError");return e!==void 0?e:s.errors?.[n]}function Br(){let{router:e}=zr("useNavigate"),s=gs("useNavigate"),n=i.useRef(!1);return Mn(()=>{n.current=!0}),i.useCallback(async(o,r={})=>{ie(n.current,Tn),n.current&&(typeof o=="number"?await e.navigate(o):await e.navigate(o,{fromRouteId:s,...r}))},[e,s])}var Hs={};function _n(e,s,n){!s&&!Hs[e]&&(Hs[e]=!0,ie(!1,n))}i.memo(Wr);function Wr({routes:e,manifest:s,future:n,state:a,isStatic:o,onError:r}){return In(e,void 0,{manifest:s,state:a,isStatic:o,onError:r})}function Vr({basename:e="/",children:s=null,location:n,navigationType:a="POP",navigator:o,static:r=!1,useTransitions:l}){Z(!st(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let c=e.replace(/^\/*/,"/"),d=i.useMemo(()=>({basename:c,navigator:o,static:r,useTransitions:l,future:{}}),[c,o,r,l]);typeof n=="string"&&(n=ze(n));let{pathname:u="/",search:m="",hash:h="",state:p=null,key:f="default",mask:C}=n,j=i.useMemo(()=>{let g=ve(u,c);return g==null?null:{location:{pathname:g,search:m,hash:h,state:p,key:f,mask:C},navigationType:a}},[c,u,m,h,p,f,a,C]);return ie(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(oe.Provider,{value:d},i.createElement($t.Provider,{children:s,value:j}))}var xt="get",vt="application/x-www-form-urlencoded";function Rt(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function qr(e){return Rt(e)&&e.tagName.toLowerCase()==="button"}function Gr(e){return Rt(e)&&e.tagName.toLowerCase()==="form"}function Kr(e){return Rt(e)&&e.tagName.toLowerCase()==="input"}function Jr(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Yr(e,s){return e.button===0&&(!s||s==="_self")&&!Jr(e)}var ht=null;function Xr(){if(ht===null)try{new FormData(document.createElement("form"),0),ht=!1}catch{ht=!0}return ht}var Qr=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Kt(e){return e!=null&&!Qr.has(e)?(ie(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${vt}"`),null):e}function Zr(e,s){let n,a,o,r,l;if(Gr(e)){let c=e.getAttribute("action");a=c?ve(c,s):null,n=e.getAttribute("method")||xt,o=Kt(e.getAttribute("enctype"))||vt,r=new FormData(e)}else if(qr(e)||Kr(e)&&(e.type==="submit"||e.type==="image")){let c=e.form;if(c==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let d=e.getAttribute("formaction")||c.getAttribute("action");if(a=d?ve(d,s):null,n=e.getAttribute("formmethod")||c.getAttribute("method")||xt,o=Kt(e.getAttribute("formenctype"))||Kt(c.getAttribute("enctype"))||vt,r=new FormData(c,e),!Xr()){let{name:u,type:m,value:h}=e;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(Rt(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=xt,a=null,o=vt,l=e}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 xs(e,s){if(e===!1||e===null||typeof e>"u")throw new Error(s)}function zn(e,s,n,a){let o=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?o.pathname.endsWith("/")?o.pathname=`${o.pathname}_.${a}`:o.pathname=`${o.pathname}.${a}`:o.pathname==="/"?o.pathname=`_root.${a}`:s&&ve(o.pathname,s)==="/"?o.pathname=`${_e(s)}/_root.${a}`:o.pathname=`${_e(o.pathname)}.${a}`,o}async function el(e,s){if(e.id in s)return s[e.id];try{let n=await import(e.module);return s[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function tl(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function sl(e,s,n){let a=await Promise.all(e.map(async o=>{let r=s.routes[o.route.id];if(r){let l=await el(r,n);return l.links?l.links():[]}return[]}));return rl(a.flat(1).filter(tl).filter(o=>o.rel==="stylesheet"||o.rel==="preload").map(o=>o.rel==="stylesheet"?{...o,rel:"prefetch",as:"style"}:{...o,rel:"prefetch"}))}function Bs(e,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(e,window.origin),nextParams:d.params,defaultShouldRevalidate:!0});if(typeof h=="boolean")return h}return!0}):[]}function nl(e,s,{includeHydrateFallback:n}={}){return al(e.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 al(e){return[...new Set(e)]}function ol(e){let s={},n=Object.keys(e).sort();for(let a of n)s[a]=e[a];return s}function rl(e,s){let n=new Set;return new Set(s),e.reduce((a,o)=>{let r=JSON.stringify(ol(o));return n.has(r)||(n.add(r),a.push({key:r,link:o})),a},[])}function vs(){let e=i.useContext(Fe);return xs(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function ll(){let e=i.useContext(Et);return xs(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var js=i.createContext(void 0);js.displayName="FrameworkContext";function Pt(){let e=i.useContext(js);return xs(e,"You must render this element inside a <HydratedRouter> element"),e}function il(e,s){let n=i.useContext(js),[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(e==="render"&&l(!0),e==="viewport"){let j=b=>{b.forEach(N=>{l(N.isIntersecting)})},g=new IntersectionObserver(j,{threshold:.5});return p.current&&g.observe(p.current),()=>{g.disconnect()}}},[e]),i.useEffect(()=>{if(a){let j=setTimeout(()=>{l(!0)},100);return()=>{clearTimeout(j)}}},[a]);let f=()=>{o(!0)},C=()=>{o(!1),l(!1)};return n?e!=="intent"?[r,p,{}]:[r,p,{onFocus:Je(c,f),onBlur:Je(d,C),onMouseEnter:Je(u,f),onMouseLeave:Je(m,C),onTouchStart:Je(h,f)}]:[!1,p,{}]}function Je(e,s){return n=>{e&&e(n),n.defaultPrevented||s(n)}}function cl({page:e,...s}){let n=wr(),{nonce:a}=Pt(),{router:o}=vs(),r=i.useMemo(()=>vn(o.routes,e,o.basename),[o.routes,e,o.basename]);return r?(s.nonce==null&&a&&(s={...s,nonce:a}),n?i.createElement(ul,{page:e,matches:r,...s}):i.createElement(hl,{page:e,matches:r,...s})):null}function dl(e){let{manifest:s,routeModules:n}=Pt(),[a,o]=i.useState([]);return i.useEffect(()=>{let r=!1;return sl(e,s,n).then(l=>{r||o(l)}),()=>{r=!0}},[e,s,n]),a}function ul({page:e,matches:s,...n}){let a=ce(),{future:o}=Pt(),{basename:r}=vs(),l=i.useMemo(()=>{if(e===a.pathname+a.search+a.hash)return[];let c=zn(e,r,o.v8_trailingSlashAwareDataRequests,"rsc"),d=!1,u=[];for(let m of s)typeof m.route.shouldRevalidate=="function"?d=!0:u.push(m.route.id);return d&&u.length>0&&c.searchParams.set("_routes",u.join(",")),[c.pathname+c.search]},[r,o.v8_trailingSlashAwareDataRequests,e,a,s]);return i.createElement(i.Fragment,null,l.map(c=>i.createElement("link",{key:c,rel:"prefetch",as:"fetch",href:c,...n})))}function hl({page:e,matches:s,...n}){let a=ce(),{future:o,manifest:r,routeModules:l}=Pt(),{basename:c}=vs(),{loaderData:d,matches:u}=ll(),m=i.useMemo(()=>Bs(e,s,u,r,a,"data"),[e,s,u,r,a]),h=i.useMemo(()=>Bs(e,s,u,r,a,"assets"),[e,s,u,r,a]),p=i.useMemo(()=>{if(e===a.pathname+a.search+a.hash)return[];let j=new Set,g=!1;if(s.forEach(N=>{let x=r.routes[N.route.id];!x||!x.hasLoader||(!m.some(v=>v.route.id===N.route.id)&&N.route.id in d&&l[N.route.id]?.shouldRevalidate||x.hasClientLoader?g=!0:j.add(N.route.id))}),j.size===0)return[];let b=zn(e,c,o.v8_trailingSlashAwareDataRequests,"data");return g&&j.size>0&&b.searchParams.set("_routes",s.filter(N=>j.has(N.route.id)).map(N=>N.route.id).join(",")),[b.pathname+b.search]},[c,o.v8_trailingSlashAwareDataRequests,d,a,r,m,s,e,l]),f=i.useMemo(()=>nl(h,r),[h,r]),C=dl(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})),C.map(({key:j,link:g})=>i.createElement("link",{key:j,nonce:n.nonce,...g,crossOrigin:g.crossOrigin??n.crossOrigin})))}function ml(...e){return s=>{e.forEach(n=>{typeof n=="function"?n(s):n!=null&&(n.current=s)})}}var pl=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{pl&&(window.__reactRouterVersion="7.18.4")}catch{}function fl({basename:e,children:s,useTransitions:n,window:a}){let o=i.useRef();o.current==null&&(o.current=Ko({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(Vr,{basename:e,children:s,location:l.location,navigationType:l.action,navigator:r,useTransitions:n})}var Fn=i.forwardRef(function({onClick:s,discover:n="render",prefetch:a="none",relative:o,reloadDocument:r,replace:l,mask:c,state:d,target:u,to:m,preventScrollReset:h,viewTransition:p,defaultShouldRevalidate:f,...C},j){let{basename:g,navigator:b,useTransitions:N}=i.useContext(oe),x=typeof m=="string"&&hs.test(m),v=Sn(m,g);m=v.to;let w=Pr(m,{relative:o}),R=ce(),E=null;if(c){let B=ms(c,[],R.mask?R.mask.pathname:"/",!0);g!=="/"&&(B.pathname=B.pathname==="/"?g:le([g,B.pathname])),E=b.createHref(B)}let[y,$,L]=il(a,C),S=jl(m,{replace:l,mask:c,state:d,target:u,preventScrollReset:h,relative:o,viewTransition:p,defaultShouldRevalidate:f,useTransitions:N});function I(B){s&&s(B),B.defaultPrevented||S(B)}let z=!(v.isExternal||r),X=i.createElement("a",{...C,...L,href:(z?E:void 0)||v.absoluteURL||w,onClick:z?I:s,ref:ml(j,$),target:u,"data-discover":!x&&n==="render"?"true":void 0});return y&&!x?i.createElement(i.Fragment,null,X,i.createElement(cl,{page:w})):X});Fn.displayName="Link";var gl=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=nt(l,{relative:u.relative}),p=ce(),f=i.useContext(Et),{navigator:C,basename:j}=i.useContext(oe),g=f!=null&&Cl(h)&&c===!0,b=C.encodeLocation?C.encodeLocation(h).pathname:h.pathname,N=p.pathname,x=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;n||(N=N.toLowerCase(),x=x?x.toLowerCase():null,b=b.toLowerCase()),x&&j&&(x=ve(x,j)||x);const v=b!=="/"&&b.endsWith("/")?b.length-1:b.length;let w=N===b||!o&&N.startsWith(b)&&N.charAt(v)==="/",R=x!=null&&(x===b||!o&&x.startsWith(b)&&x.charAt(b.length)==="/"),E={isActive:w,isPending:R,isTransitioning:g},y=w?s:void 0,$;typeof a=="function"?$=a(E):$=[a,w?"active":null,R?"pending":null,g?"transitioning":null].filter(Boolean).join(" ");let L=typeof r=="function"?r(E):r;return i.createElement(Fn,{...u,"aria-current":y,className:$,ref:m,style:L,to:l,viewTransition:c},typeof d=="function"?d(E):d)});gl.displayName="NavLink";var xl=i.forwardRef(({discover:e="render",fetcherKey:s,navigate:n,reloadDocument:a,replace:o,state:r,method:l=xt,action:c,onSubmit:d,relative:u,preventScrollReset:m,viewTransition:h,defaultShouldRevalidate:p,...f},C)=>{let{useTransitions:j}=i.useContext(oe),g=Nl(),b=wl(c,{relative:u}),N=l.toLowerCase()==="get"?"get":"post",x=typeof c=="string"&&hs.test(c),v=w=>{if(d&&d(w),w.defaultPrevented)return;w.preventDefault();let R=w.nativeEvent.submitter,E=R?.getAttribute("formmethod")||l,y=()=>g(R||w.currentTarget,{fetcherKey:s,method:E,navigate:n,replace:o,state:r,relative:u,preventScrollReset:m,viewTransition:h,defaultShouldRevalidate:p});j&&n!==!1?i.startTransition(()=>y()):y()};return i.createElement("form",{ref:C,method:N,action:b,onSubmit:a?d:v,...f,"data-discover":!x&&e==="render"?"true":void 0})});xl.displayName="Form";function vl(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function On(e){let s=i.useContext(Fe);return Z(s,vl(e)),s}function jl(e,{target:s,replace:n,mask:a,state:o,preventScrollReset:r,relative:l,viewTransition:c,defaultShouldRevalidate:d,useTransitions:u}={}){let m=re(),h=ce(),p=nt(e,{relative:l});return i.useCallback(f=>{if(Yr(f,s)){f.preventDefault();let C=n!==void 0?n:Ae(h)===Ae(p),j=()=>m(e,{replace:C,mask:a,state:o,preventScrollReset:r,relative:l,viewTransition:c,defaultShouldRevalidate:d});u?i.startTransition(()=>j()):j()}},[h,m,p,n,a,o,s,e,r,l,c,d,u])}var bl=0,yl=()=>`__${String(++bl)}__`;function Nl(){let{router:e}=On("useSubmit"),{basename:s}=i.useContext(oe),n=Ur(),a=e.fetch,o=e.navigate;return i.useCallback(async(r,l={})=>{let{action:c,method:d,encType:u,formData:m,body:h}=Zr(r,s);if(l.navigate===!1){let p=l.fetcherKey||yl();await a(p,n,l.action||c,{defaultShouldRevalidate:l.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,{defaultShouldRevalidate:l.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 wl(e,{relative:s}={}){let{basename:n}=i.useContext(oe),a=i.useContext(je);Z(a,"useFormAction must be used inside a RouteContext");let[o]=a.matches.slice(-1),r={...nt(e||".",{relative:s})},l=ce();if(e==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(!e||e===".")&&o.route.index&&(r.search=r.search?r.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(r.pathname=r.pathname==="/"?n:le([n,r.pathname])),Ae(r)}function Cl(e,{relative:s}={}){let n=i.useContext(Dn);Z(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=nt(e,{relative:s});if(!n.isTransitioning)return!1;let r=ve(n.currentLocation.pathname,a)||n.currentLocation.pathname,l=ve(n.nextLocation.pathname,a)||n.nextLocation.pathname;return Nt(o.pathname,l)!=null||Nt(o.pathname,r)!=null}const Un={name:"book-open",size:24,node:[["path",{d:"M12 5v16",key:"1f6ucr"}],["path",{d:"M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z",key:"1fyvmf"}]]};Un.node;const kl=O(Un);const Hn={name:"chevron-down",size:24,node:[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]};Hn.node;const Dt=O(Hn);const Bn={name:"chevron-right",size:24,node:[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]};Bn.node;const Sl=O(Bn);const Wn={name:"chevron-up",size:24,node:[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]};Wn.node;const Vn=O(Wn);const qn={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"}]]};qn.node;const El=O(qn);const Gn={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"}]]};Gn.node;const $l=O(Gn);const Kn={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"]};Kn.node;const Rl=O(Kn);const Jn={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"]};Jn.node;const Xe=O(Jn);const Yn={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"}]]};Yn.node;const Pl=O(Yn);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 Qn=O(Xn);const Zn={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"}]]};Zn.node;const bs=O(Zn);const ea={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"}]]};ea.node;const Lt=O(ea);const ta={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"}]]};ta.node;const Dl=O(ta);const sa={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"}]]};sa.node;const na=O(sa);const aa={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"}]]};aa.node;const oa=O(aa);const ra={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"}]]};ra.node;const Ll=O(ra);const la={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"}]]};la.node;const Tt=O(la);const ia={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"}]]};ia.node;const ca=O(ia);const da={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"}]]};da.node;const Tl=O(da);const ua={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"]};ua.node;const Ml=O(ua);const ha={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"}]]};ha.node;const wt=O(ha);const ma={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"}]]};ma.node;const Mt=O(ma);const pa={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"}]]};pa.node;const Il=O(pa);const fa={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"}]]};fa.node;const Al=O(fa);const ga={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"}]]};ga.node;const _l=O(ga);const xa={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"}]]};xa.node;const ys=O(xa);const va={name:"loader-circle",size:24,node:[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],aliases:["loader-2"]};va.node;const Jt=O(va);const ja={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"}]]};ja.node;const zl=O(ja);const ba={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"}]]};ba.node;const Fl=O(ba);const ya={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"]};ya.node;const Ol=O(ya);const Na={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"}]]};Na.node;const Ct=O(Na);const wa={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"}]]};wa.node;const Ul=O(wa);const Ca={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"}]]};Ca.node;const ka=O(Ca);const Sa={name:"search",size:24,node:[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]};Sa.node;const at=O(Sa);const Ea={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"}]]};Ea.node;const $a=O(Ea);const Ra={name:"trash",size:24,node:[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],aliases:["trash-2"]};Ra.node;const Hl=O(Ra);const Pa={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"]};Pa.node;const Ns=O(Pa);const Da={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"}]]};Da.node;const ws=O(Da),Bl={currentProject:"default",projects:["default"],docs:[],selectedDocId:null,selectedDoc:null,freshnessResult:null,searchQuery:"",searchResults:[],hasReceivedInitialState:!1,searchAllProjects:!1,historyEntries:null,historyVersionContent:null,exportBundles:[],readOnly:!1,syncEnabled:!1,codeSourceMigrationPending:!1,codeSourcesVersion:0,publicationsVersion:0,commentsVersion:0,commentSummary:{project:"",docs:{}}};let A={...Bl},jt=[];function Q(){jt.forEach(e=>e())}function Y(){const[,e]=i.useState(0),s=i.useCallback(()=>{const n=()=>e(a=>a+1);return jt.push(n),()=>{jt=jt.filter(a=>a!==n)}},[]);return i.useState(()=>s()),{...A,setProjects:n=>{A={...A,projects:n},Q()},setCurrentProject:n=>{A={...A,currentProject:n},Q()},setDocs:n=>{A={...A,docs:n},Q()},setSelectedDocId:n=>{A={...A,selectedDocId:n,freshnessResult:null},Q()},setSelectedDoc:n=>{A={...A,selectedDoc:n},Q()},setFreshnessResult:n=>{A={...A,freshnessResult:n},Q()},setSearchQuery:n=>{A={...A,searchQuery:n},Q()},setSearchResults:n=>{A={...A,searchResults:n},Q()},clearSearch:()=>{A={...A,searchQuery:"",searchResults:[]},Q()},setSearchAllProjects:n=>{A={...A,searchAllProjects:n},Q()},setHistoryEntries:n=>{A={...A,historyEntries:n,historyVersionContent:null},Q()},setHistoryVersionContent:n=>{A={...A,historyVersionContent:n},Q()},setExportBundles:n=>{A={...A,exportBundles:n},Q()},bumpCodeSourcesVersion:()=>{A={...A,codeSourcesVersion:A.codeSourcesVersion+1},Q()},bumpPublicationsVersion:()=>{A={...A,publicationsVersion:A.publicationsVersion+1},Q()},bumpCommentsVersion:()=>{A={...A,commentsVersion:A.commentsVersion+1},Q()},setCommentSummary:(n,a)=>{A={...A,commentSummary:{project:n,docs:a}},Q()},setCodeSourceMigrationPending:n=>{A={...A,codeSourceMigrationPending:n},Q()},applyInitialState:n=>{const a=n.projects??n.config?.projects??A.projects,o=a.length===A.projects.length&&a.every((r,l)=>r===A.projects[l]);A={...A,projects:o?A.projects:a,docs:n.docs??A.docs,exportBundles:n.bundles??A.exportBundles,readOnly:n.readOnly??A.readOnly,syncEnabled:n.syncEnabled??A.syncEnabled,codeSourceMigrationPending:n.codeSourceMigrationPending??A.codeSourceMigrationPending,hasReceivedInitialState:!0},Q()}}}function ne(e,s){const n=encodeURIComponent(e);if(!s)return`/${n}`;const a=s.split("/").filter(Boolean).map(o=>encodeURIComponent(o)).join("/");return a?`/${n}/${a}`:`/${n}`}function Ws(e){const s=e.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 Wl(e){try{return decodeURIComponent(e)}catch{return e}}function xe(e){return e.split("/").filter(Boolean).map(s=>encodeURIComponent(s)).join("/")}const bt="/_logs";function kt(e){return`${bt}/${e}`}const La="/_publications";function Cs(e){return e.replace(/\/+$/,"")===La}function Ta(e){const s=e.replace(/\/+$/,"");return s!==bt&&!s.startsWith(`${bt}/`)?null:s.slice(bt.length+1)==="github"?"github":"server"}const Ma=e=>`mcp-documentor:expanded-folders:${e}`;function Vs(e){try{const s=JSON.parse(localStorage.getItem(Ma(e))??"null");return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function Vl(e,s){try{localStorage.setItem(Ma(e),JSON.stringify(s))}catch{}}function Ia(e,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/${e.id}${r?`?${r}`:""}`,l.download=e.zipFilename,l.click()}function ql({bundle:e,onClose:s}){const[n,a]=i.useState(!1),[o,r]=i.useState(!1),{currentProject:l}=Y();return t.jsx("div",{className:"settings-overlay",onClick:s,children:t.jsxs("div",{className:"settings-popover export-bundle-modal",onClick:c=>c.stopPropagation(),children:[t.jsx("h2",{className:"settings-title",children:e.name}),e.description&&t.jsx("p",{className:"export-bundle-modal-desc",children:e.description}),t.jsx("div",{className:"export-bundle-modal-meta",children:t.jsxs("span",{className:"export-bundle-modal-filename",children:["📦 ",e.zipFilename]})}),t.jsxs("div",{className:"export-bundle-modal-section",children:[t.jsxs("div",{className:"export-bundle-modal-section-title",children:["Documents inclus (",e.docs.length,")"]}),t.jsx("ul",{className:"export-bundle-modal-docs",children:e.docs.map(c=>t.jsx("li",{className:"export-bundle-modal-doc-item",children:t.jsx("span",{className:"export-bundle-modal-doc-ref",children:c})},c))})]}),t.jsxs("div",{className:"export-bundle-modal-toggle-row",children:[t.jsx("span",{className:"export-bundle-modal-toggle-label",children:"Ne pas conserver l'arborescence"}),t.jsx("button",{role:"switch","aria-checked":n,className:`toggle-switch${n?" toggle-switch--on":""}`,onClick:()=>a(c=>!c)})]}),t.jsxs("div",{className:"export-bundle-modal-toggle-row",children:[t.jsx("span",{className:"export-bundle-modal-toggle-label",children:"Inclure les entêtes (métadonnées)"}),t.jsx("button",{role:"switch","aria-checked":o,className:`toggle-switch${o?" toggle-switch--on":""}`,onClick:()=>r(c=>!c)})]}),t.jsxs("div",{className:"settings-actions",children:[t.jsx("button",{className:"settings-cancel-btn",onClick:s,children:"Fermer"}),t.jsx("button",{className:"settings-save-btn",onClick:()=>{Ia(e,n,o,l),s()},children:"↓ Télécharger ZIP"})]})]})})}function Gl(){const{exportBundles:e,currentProject:s}=Y(),[n,a]=i.useState(null);return e.length===0?t.jsx("div",{className:"nav-empty",children:"No export bundles yet."}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"export-bundles-list",children:e.map(o=>t.jsxs("div",{className:"export-bundle-item",onClick:()=>a(o),children:[t.jsxs("div",{className:"export-bundle-info",children:[t.jsx("span",{className:"export-bundle-name",children:o.name}),o.description&&t.jsx("span",{className:"export-bundle-desc",children:o.description}),t.jsxs("span",{className:"export-bundle-meta",children:[o.docs.length," doc",o.docs.length!==1?"s":""]})]}),t.jsx("button",{className:"export-bundle-btn",onClick:r=>{r.stopPropagation(),Ia(o,!1,!1,s)},title:`Télécharger ${o.zipFilename}`,children:"↓ ZIP"})]},o.id))}),n&&t.jsx(ql,{bundle:n,onClose:()=>a(null)})]})}const Aa="mcp-documentor:project";function qs(){try{return localStorage.getItem(Aa)}catch{return null}}function Kl(e){try{localStorage.setItem(Aa,e)}catch{}}async function _a(e){try{const s=await fetch(`/api/docs?project=${encodeURIComponent(e)}`);return s.ok?(await s.json()).docs??[]:[]}catch{return[]}}async function Jl(e){try{const s=await fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e})});return s.ok?{ok:!0,projects:(await s.json()).projects}:{ok:!1}}catch{return{ok:!1}}}function Yl(e){const s=e.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 Xl(e){let s=0;for(const n of e)s=s*31+n.charCodeAt(0)>>>0;return`hsl(${s%360}, 52%, 46%)`}async function de(e,s){const n=await fetch(e,s);let a=null;try{a=await n.json()}catch{}if(!n.ok)throw new Error(a?.error??`HTTP ${n.status}`);return a}const Oe=e=>({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});async function za(){return(await de("/api/code-sources")).projects}async function Ql(e,s){return(await de("/api/code-sources/search",{...Oe({query:e}),signal:s})).results}function Zl(e,s,n){return de("/api/code-sources/inspect",{...Oe({repo:e,branch:s}),signal:n})}function ei(e,s,n,a){return de("/api/code-sources/preview",{...Oe({project:e,config:s,codeRoot:n}),signal:a})}function ti(e,s,n){return de("/api/code-sources/apply",Oe({project:e,config:s,codeRoot:n}))}function si(e,s){return de("/api/code-roots/inspect",{...Oe({path:e}),signal:s})}function ni(){return de("/api/code-roots")}function ai(e){return de("/api/code-roots/apply",Oe({path:e}))}function oi(){return de("/api/github-token")}async function Fa(){return(await de("/api/code-source-migration")).report}function ri(){return de("/api/code-source-migration/ack",{method:"POST"})}function Gs(e){const s=e.config;return s?s.kind==="github"?`${s.repo} · ${s.branch??"default branch"}`:e.codeRoot?`Local · ${e.codeRoot}`:"Local working copy":"Settings unreadable"}function li({source:e,size:s,active:n}){if(e?.error)return t.jsx(Ns,{size:s,className:"source-icon error"});const a=`source-icon${n?" active":""}`;return e?.config?.kind==="github"?t.jsx(bs,{size:s,className:a}):t.jsx(ys,{size:s,className:a})}function Ks({project:e,size:s}){return t.jsx("span",{className:"project-avatar",style:{width:s,height:s,background:Xl(e),fontSize:Math.round(s*.36)},children:Yl(e)})}function Oa({variant:e,onOpenSettings:s}){const n=re(),{currentProject:a,projects:o,applyInitialState:r,codeSourcesVersion:l}=Y(),[c,d]=i.useState(""),[u,m]=i.useState(!1),[h,p]=i.useState(!1),[f,C]=i.useState(0),[j,g]=i.useState(""),[b,N]=i.useState({}),x=i.useRef(null),v=i.useRef(null),w=i.useRef(null),R=j.trim().toLowerCase(),E=R?o.filter(T=>T.toLowerCase().includes(R)):o,y=i.useCallback(()=>{za().then(T=>N(Object.fromEntries(T.map(W=>[W.project,W])))).catch(()=>{})},[]);i.useEffect(y,[l,o,y]),i.useEffect(()=>{h&&y()},[h,y]),i.useEffect(()=>{h&&!u&&w.current?.focus()},[h,u]),i.useEffect(()=>{x.current?.querySelector(`[data-index="${f}"]`)?.scrollIntoView({block:"nearest"})},[f]);const $=T=>{n(ne(T,null))},L=()=>{C(Math.max(0,o.indexOf(a))),g(""),m(!1),p(!0)},S=()=>{p(!1),m(!1),v.current?.focus()},I=T=>{S(),$(T)},z=T=>{p(!1),s(T)},X=T=>{g(T),C(0)},B=T=>{T.key==="ArrowDown"?(T.preventDefault(),C(W=>Math.min(E.length-1,W+1))):T.key==="ArrowUp"?(T.preventDefault(),C(W=>Math.max(0,W-1))):T.key==="Enter"?(T.preventDefault(),E[f]&&I(E[f])):(T.key==="Escape"||T.key==="Tab")&&S()},q=async()=>{const T=c.trim().replace(/[^a-zA-Z0-9_-]/g,"-");if(!T)return;const{ok:W,projects:J}=await Jl(T);W&&(J&&r({projects:J}),d(""),S(),$(T))},D=b[a],V=D?`${a} — ${D.error??Gs(D)}`:a;return t.jsxs("div",{className:`project-selector project-selector--${e}`,children:[t.jsxs("button",{ref:v,className:`project-trigger${h?" open":""}${D?.error?" error":""}`,onClick:()=>h?S():L(),onKeyDown:T=>{T.key==="ArrowDown"&&!h&&(T.preventDefault(),L())},title:V,"aria-haspopup":"listbox","aria-expanded":h,children:[t.jsx(Ks,{project:a,size:e==="rail"?32:28}),e==="card"&&t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"project-trigger-text",children:[t.jsx("span",{className:"project-trigger-label",children:a}),t.jsx("span",{className:`project-trigger-caption${D?.error?" error":""}`,children:D?.error?"Code source to fix":"Current project"})]}),t.jsx($l,{size:14,className:"project-trigger-caret"})]})]}),h&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"menu-backdrop",onClick:S}),t.jsxs("div",{className:"project-menu",children:[t.jsx("div",{className:"project-menu-label",children:"Projects · code source"}),t.jsxs("div",{className:"project-menu-search",children:[t.jsx(at,{size:14,className:"project-menu-search-icon"}),t.jsx("input",{ref:w,className:"project-menu-search-input",type:"text",placeholder:"Search projects",value:j,onChange:T=>X(T.target.value),onKeyDown:B,role:"combobox","aria-expanded":!0,"aria-controls":"project-menu-list","aria-activedescendant":E.length?`project-option-${f}`:void 0})]}),t.jsxs("div",{id:"project-menu-list",className:"project-menu-list",role:"listbox",tabIndex:-1,ref:x,onKeyDown:B,"aria-activedescendant":E.length?`project-option-${f}`:void 0,children:[E.length===0&&t.jsx("div",{className:"project-menu-empty",children:"No matching project"}),E.map((T,W)=>{const J=b[T],be=T===a;return t.jsxs("div",{id:`project-option-${W}`,"data-index":W,role:"option","aria-selected":be,className:`project-option${be?" current":""}${W===f?" highlighted":""}`,onMouseEnter:()=>C(W),onClick:()=>I(T),children:[t.jsx(Ks,{project:T,size:24}),t.jsxs("div",{className:"project-option-text",children:[t.jsx("span",{className:"project-option-name",children:T}),J&&t.jsxs("span",{className:`project-option-source${J.error?" error":""}`,children:[t.jsx(li,{source:J,size:11,active:J.config?.kind==="github"}),J.error??Gs(J)]})]}),J?.error?t.jsx("button",{className:"project-option-fix",onClick:ue=>{ue.stopPropagation(),z(T)},children:"Fix"}):t.jsxs(t.Fragment,{children:[be&&t.jsx(Se,{size:14,className:"project-option-check"}),t.jsx("button",{className:"project-option-gear",title:`Settings of ${T}`,onClick:ue=>{ue.stopPropagation(),z(T)},children:t.jsx($a,{size:14})})]})]},T)})]}),t.jsx("div",{className:"project-menu-footer",children:u?t.jsxs("div",{className:"new-project-row",children:[t.jsx("input",{className:"new-project-input",type:"text",placeholder:"New project",value:c,autoFocus:!0,onChange:T=>d(T.target.value),onKeyDown:T=>{T.key==="Enter"&&q(),T.key==="Escape"&&m(!1)}}),t.jsx("button",{className:"new-project-btn",onClick:q,title:"Create project",children:t.jsx(Se,{size:14})})]}):t.jsxs("button",{className:"project-menu-action",onClick:()=>m(!0),children:[t.jsx(ln,{size:14}),"New project"]})})]})]})]})}function ii({focusToken:e}){const s=re(),n=i.useRef(null),{searchQuery:a,searchResults:o,searchAllProjects:r,setSearchAllProjects:l,setSearchQuery:c,setSearchResults:d,clearSearch:u,currentProject:m,selectedDocId:h}=Y(),[p,f]=i.useState(a);i.useEffect(()=>{n.current?.focus(),n.current?.select()},[e]);const C=async()=>{if(p.trim()){c(p);try{const N=await(await fetch("/api/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:p,top_k:10,all_projects:r,project:m})})).json();d(N.results||[])}catch{d([])}}},j=()=>{f(""),u(),s(ne(m,null))},g=b=>{b.key==="Enter"&&C(),b.key==="Escape"&&p&&j()};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"search-box",children:[t.jsxs("div",{className:"search-field",children:[t.jsx(at,{size:14,className:"search-field-icon"}),t.jsx("input",{ref:n,className:"search-input",type:"text",placeholder:"Search documentation",value:p,onChange:b=>f(b.target.value),onKeyDown:g}),p?t.jsx("button",{className:"search-clear-btn",onClick:j,title:"Clear search",children:"✕"}):t.jsx("span",{className:"search-kbd",children:"⌘K"})]}),t.jsxs("div",{className:"segmented",role:"radiogroup","aria-label":"Search scope",children:[t.jsx("button",{role:"radio","aria-checked":!r,className:`segmented-option${r?"":" active"}`,onClick:()=>l(!1),children:"This project"}),t.jsx("button",{role:"radio","aria-checked":r,className:`segmented-option${r?" active":""}`,onClick:()=>l(!0),children:"All projects"})]})]}),a&&o.length===0&&t.jsx("div",{className:"nav-empty",children:"No match."}),o.map(b=>{const N=b.project??m,x=h===b.id&&m===N;return t.jsxs("div",{className:`search-result${x?" active":""}`,onClick:()=>s(ne(N,b.id)),children:[t.jsxs("div",{className:"search-result-head",children:[t.jsx("span",{className:"search-result-title",children:b.title}),t.jsxs("span",{className:"search-result-score",children:[(b.score*100).toFixed(0),"%"]})]}),b.project&&t.jsxs("div",{className:"search-result-meta",children:["Project: ",b.project]}),t.jsxs("div",{className:"search-result-excerpt",children:[b.excerpt.substring(0,80),"..."]})]},`${N}::${b.id}`)})]})}function ci(e){const s=[],n=new Map;for(const a of e){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(e){let s=e.docs.length;for(const n of e.children.values())s+=Ua(n);return s}function Ha(e){return e.docs.some(s=>s.isStale)||[...e.children.values()].some(Ha)}function Ba(e,s){return e.docs.some(n=>(s[n.id]?.unread??0)>0)||[...e.children.values()].some(n=>Ba(n,s))}function Wa(){const{commentSummary:e,currentProject:s}=Y();return e.project===s?e.docs:{}}function Va(e){return[...e.values()].flatMap(s=>[s.path,...Va(s.children)])}function di(e){if(!e)return"";const s=new Date(e),n=a=>String(a).padStart(2,"0");return`${s.getFullYear()}-${n(s.getMonth()+1)}-${n(s.getDate())} ${n(s.getHours())}:${n(s.getMinutes())}`}const ns=e=>8+e*16;function yt({doc:e,selectedDocId:s,onSelect:n,depth:a=0,showCreatedAt:o=!1}){const r=Wa()[e.id]?.unread??0,l=ns(a)+16;return t.jsxs("div",{className:`tree-row tree-row--doc${s===e.id?" active":""}`,style:{paddingLeft:l},onClick:()=>n(e.id),title:e.isStale?`${e.title} — outdated`:e.title,children:[r>0&&t.jsxs("span",{className:"tree-comments tree-comments--gutter",style:{right:`calc(100% - ${l-4}px)`},title:`${r} unread comment${r>1?"s":""}`,children:[t.jsx(ds,{size:11}),r]}),t.jsx(oa,{size:14,className:"tree-row-icon"}),t.jsx("span",{className:"tree-row-label",children:e.title}),o&&e.createdAt&&t.jsx("span",{className:"tree-row-meta",children:di(e.createdAt)}),e.isStale&&t.jsx("span",{className:"stale-dot"})]})}function qa({nodes:e,depth:s,selectedDocId:n,onSelect:a,expanded:o,onToggle:r}){const l=Wa();return t.jsx(t.Fragment,{children:[...e.entries()].sort(([c],[d])=>c.localeCompare(d)).map(([,c])=>{const d=!!o[c.path],u=d?Dt:Sl,m=d?Tt:ca;return t.jsxs("div",{children:[t.jsxs("div",{className:"tree-row tree-row--folder",style:{paddingLeft:ns(s)},onClick:()=>r(c.path),children:[t.jsx(u,{size:12,className:"tree-row-chevron"}),t.jsx(m,{size:14,className:"tree-row-icon"}),t.jsx("span",{className:"tree-row-label",children:c.name}),Ba(c,l)&&t.jsx("span",{className:"tree-comments",title:"Contains unread comments",children:t.jsx(ds,{size:11})}),Ha(c)&&t.jsx("span",{className:"stale-dot",title:"Contains outdated docs"}),t.jsx("span",{className:"tree-row-count",children:Ua(c)})]}),d&&t.jsxs("div",{className:"tree-children",style:{"--guide-x":`${ns(s)+6}px`},children:[c.docs.map(h=>t.jsx(yt,{doc:h,selectedDocId:n,onSelect:a,depth:s+1},h.id)),t.jsx(qa,{nodes:c.children,depth:s+1,selectedDocId:n,onSelect:a,expanded:o,onToggle:r})]})]},c.path)})})}function ui({mode:e,searchFocusToken:s,onCreateDoc:n,onOpenProjectSettings:a,onClose:o}){const r=re(),{docs:l,selectedDocId:c,currentProject:d,exportBundles:u,readOnly:m}=Y(),[h,p]=i.useState(()=>({project:d,folders:Vs(d)}));h.project!==d&&p({project:d,folders:Vs(d)});const f=h.folders,C=$=>{const L=$(f);Vl(d,L),p({project:d,folders:L})},j=i.useMemo(()=>ci(l),[l]),g=i.useMemo(()=>l.filter($=>$.isStale),[l]),b=i.useMemo(()=>[...l].sort(($,L)=>{const S=$.createdAt?new Date($.createdAt).getTime():0;return(L.createdAt?new Date(L.createdAt).getTime():0)-S}),[l]),N=l.find($=>$.id===c)?.folder,x=i.useMemo(()=>{const $={};let L="";for(const S of(N??"").split("/").filter(Boolean))L=L?`${L}/${S}`:S,$[L]=!0;return{...$,...f}},[N,f]),v=$=>{r(ne(d,$))},w=$=>{C(L=>({...L,[$]:!x[$]}))},R=()=>{C(()=>Object.fromEntries(Va(j.folders).map($=>[$,!1])))},E={docs:{title:"Documentation",count:`${l.length} doc${l.length===1?"":"s"}`},search:{title:"Search"},outdated:{title:"Outdated",count:String(g.length)},recent:{title:"Recent",count:String(b.length)},exports:{title:"Export bundles",count:String(u.length)}},y=()=>{switch(e){case"search":return t.jsx(ii,{focusToken:s});case"exports":return t.jsx(Gl,{});case"recent":return b.length===0?t.jsx("div",{className:"nav-empty",children:"No documentation entries yet."}):b.map($=>t.jsx(yt,{doc:$,selectedDocId:c,onSelect:v,showCreatedAt:!0},$.id));case"outdated":return g.length===0?t.jsx("div",{className:"nav-empty",children:"All docs are up to date."}):g.map($=>t.jsx(yt,{doc:$,selectedDocId:c,onSelect:v},$.id));case"docs":return l.length===0?t.jsx("div",{className:"nav-empty",children:"No documentation entries yet."}):t.jsxs(t.Fragment,{children:[t.jsx(qa,{nodes:j.folders,depth:0,selectedDocId:c,onSelect:v,expanded:x,onToggle:w}),j.rootDocs.map($=>t.jsx(yt,{doc:$,selectedDocId:c,onSelect:v},$.id))]})}};return t.jsxs("div",{className:"nav-panel",children:[t.jsxs("div",{className:"nav-panel-project",children:[t.jsx(Oa,{variant:"card",onOpenSettings:a}),!m&&t.jsx("button",{className:"nav-panel-new",onClick:n,title:"Create a new document manually",children:t.jsx(ln,{size:16})})]}),t.jsxs("div",{className:"nav-panel-heading",children:[t.jsx("span",{className:"nav-panel-title",children:E[e].title}),E[e].count&&t.jsx("span",{className:"nav-panel-count",children:E[e].count}),e==="docs"&&t.jsx("button",{className:"nav-panel-tool",onClick:R,title:"Collapse all folders",children:t.jsx(El,{size:15})}),t.jsx("button",{className:"nav-panel-tool",onClick:o,title:"Hide panel",children:t.jsx(Ol,{size:15})})]}),t.jsx("div",{className:"nav-panel-scroll",children:y()})]})}function hi({report:e,trackedFiles:s,onViewCode:n}){if(e.status==="no_tracking")return t.jsx("p",{className:"file-status-view",style:{color:"#8b949e",fontSize:13},children:"No tracked files for this entry."});const a=l=>e.modified.includes(l)?"modified":e.missing.includes(l)?"missing":(e.anchors_lost??[]).includes(l)?"anchors_lost":"ok",o=l=>!!l.sections?.length&&!(e.anchors_lost??[]).includes(l.path),r=l=>{switch(l){case"ok":return t.jsx("span",{className:"status-ok",children:"✓"});case"modified":return t.jsx("span",{className:"status-modified",children:"⚠ Modified"});case"missing":return t.jsx("span",{className:"status-missing",children:"✕ Missing"});case"anchors_lost":return t.jsx("span",{className:"status-anchors-lost",children:"⚠ Anchors lost"});default:return null}};return t.jsxs("div",{className:"file-status-view",style:{marginBottom:16},children:[t.jsxs("h3",{style:{fontSize:14,color:"#8b949e",margin:"0 0 8px 0"},children:["Tracked Files — ",e.status==="stale"?"Stale":"Up to date"]}),t.jsxs("table",{className:"file-status-table",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{children:"File"}),t.jsx("th",{children:"Snapshot Date"}),t.jsx("th",{children:"Status"})]})}),t.jsx("tbody",{children:s.map(l=>{const c=a(l.path);return t.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:[t.jsxs("td",{children:[l.path,o(l)&&t.jsx("span",{className:"file-row-code-hint",children:" 〈/〉"})]}),t.jsx("td",{children:new Date(l.lastModifiedAt).toLocaleString()}),t.jsx("td",{children:r(c)})]},l.path)})})]})]})}function mi(e){return e.startsWith("+++ ")||e.startsWith("--- ")||e.startsWith("diff ")||e.startsWith("index ")?"file-header":e.startsWith("@@")?"hunk":e.startsWith("+")?"added":e.startsWith("-")?"removed":e.startsWith("###")?"section-title":e==="---"?"separator":"context"}function pi(e){return e.split(`
|
|
4
|
+
`).map(s=>({type:mi(s),content:s}))}function fi({diffText:e}){const s=pi(e);return t.jsx("div",{className:"diff-viewer",children:t.jsx("pre",{className:"diff-pre",children:s.map((n,a)=>t.jsx("div",{className:`diff-line diff-line--${n.type}`,children:t.jsx("span",{className:"diff-line-content",children:n.content||" "})},a))})})}class gi{diff(s,n,a={}){let o;typeof a=="function"?(o=a,a={}):"callback"in a&&(o=a.callback);const r=this.castInput(s,a),l=this.castInput(n,a),c=this.removeEmpty(this.tokenize(r,a)),d=this.removeEmpty(this.tokenize(l,a));return this.diffWithOptionsObj(c,d,a,o)}diffWithOptionsObj(s,n,a,o){var r;const l=N=>{if(N=this.postProcess(N,a),o){setTimeout(function(){o(N)},0);return}else return N},c=n.length,d=s.length;let 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 C=this.extractCommon(f[0],n,s,0,a);if(f[0].oldPos+1>=d&&C+1>=c)return l(this.buildValues(f[0].lastComponent,n,s));let j=-1/0,g=1/0;const b=()=>{for(let N=Math.max(j,-u);N<=Math.min(g,u);N+=2){let x;const v=f[N-1],w=f[N+1];v&&(f[N-1]=void 0);let R=!1;if(w){const y=w.oldPos-N;R=w&&0<=y&&y<c}const E=v&&v.oldPos+1<d;if(!R&&!E){f[N]=void 0;continue}if(!E||R&&v.oldPos<w.oldPos?x=this.addToPath(w,!0,!1,0,a):x=this.addToPath(v,!1,!0,1,a),C=this.extractCommon(x,n,s,N,a),x.oldPos+1>=d&&C+1>=c)return l(this.buildValues(x.lastComponent,n,s))||!0;f[N]=x,x.oldPos+1>=d&&(g=Math.min(g,N-1)),C+1>=c&&(j=Math.max(j,N+1))}u++};if(o)(function N(){setTimeout(function(){if(u>m||Date.now()>p)return o(void 0);b()||N()},0)})();else for(;u<=m&&Date.now()<=p;){const N=b();if(N)return N}}addToPath(s,n,a,o,r){const l=s.lastComponent;return l&&!r.oneChangePerToken&&l.added===n&&l.removed===a?{oldPos:s.oldPos+o,lastComponent:{count:l.count+1,added:n,removed:a,previousComponent:l.previousComponent}}:{oldPos:s.oldPos+o,lastComponent:{count:1,added:n,removed:a,previousComponent:l}}}extractCommon(s,n,a,o,r){const l=n.length,c=a.length;let d=s.oldPos,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 C=a[u+f];return C.length>p.length?C: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 Js(e,s){let n;for(n=0;n<e.length&&n<s.length;n++)if(e[n]!=s[n])return e.slice(0,n);return e.slice(0,n)}function Ys(e,s){let n;if(!e||!s||e[e.length-1]!=s[s.length-1])return"";for(n=0;n<e.length&&n<s.length;n++)if(e[e.length-(n+1)]!=s[s.length-(n+1)])return e.slice(-n);return e.slice(-n)}function as(e,s,n){if(e.slice(0,s.length)!=s)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(s)}; this is a bug`);return n+e.slice(s.length)}function os(e,s,n){if(!s)return e+n;if(e.slice(-s.length)!=s)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(s)}; this is a bug`);return e.slice(0,-s.length)+n}function Ye(e,s){return as(e,s,"")}function mt(e,s){return os(e,s,"")}function Xs(e,s){return s.slice(0,xi(e,s))}function xi(e,s){let n=0;e.length>s.length&&(n=e.length-s.length);let a=s.length;e.length<s.length&&(a=e.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<e.length;l++){for(;r>0&&e[l]!=s[r];)r=o[r];e[l]==s[r]&&r++}return r}function Ga(e,s){const n=[];for(const a of Array.from(s.segment(e))){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 rs(e,s){if(s)return Qe(e,s)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function Ie(e,s){if(s)return Qe(e,s)[0];const n=e.match(/^\s*/);return n?n[0]:""}function Qe(e,s){if(!s)return[Ie(e),rs(e)];if(s.resolvedOptions().granularity!="word")throw new Error('The segmenter passed must have a granularity of "word"');const n=Ga(e,s),a=n[0],o=n[n.length-1],r=/\s/.test(a)?a:"",l=/\s/.test(o)?o:"";return[r,l]}const Qs="a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}",vi=new RegExp(`[${Qs}]+|\\s+|[^${Qs}]`,"ug");class ji extends gi{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=Ga(s,l)}else a=s.match(vi)||[];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)&&Zs(a,r,o,l,n.intlSegmenter),a=l,o=null,r=null)}),(o||r)&&Zs(a,r,o,null,n.intlSegmenter),s}}const bi=new ji;function yi(e,s,n){return bi.diff(e,s,n)}function Zs(e,s,n,a,o){if(s&&n){const[r,l]=Qe(s.value,o),[c,d]=Qe(n.value,o);if(e){const u=Js(r,c);e.value=os(e.value,c,u),s.value=Ye(s.value,u),n.value=Ye(n.value,u)}if(a){const u=Ys(l,d);a.value=as(a.value,d,u),s.value=mt(s.value,u),n.value=mt(n.value,u)}}else if(n){if(e){const r=Ie(n.value,o);n.value=n.value.substring(r.length)}if(a){const r=Ie(a.value,o);a.value=a.value.substring(r.length)}}else if(e&&a){const r=Ie(a.value,o),[l,c]=Qe(s.value,o),d=Js(r,l);s.value=Ye(s.value,d);const u=Ys(Ye(r,d),c);s.value=mt(s.value,u),a.value=as(a.value,r,u),e.value=os(e.value,r,r.slice(0,r.length-u.length))}else if(a){const r=Ie(a.value,o),l=rs(s.value,o),c=Xs(l,r);s.value=mt(s.value,c)}else if(e){const r=rs(e.value,o),l=Ie(s.value,o),c=Xs(r,l);s.value=Ye(s.value,c)}}const Yt={create:"Created",update:"Updated",patch:"Patched",delete:"Deleted",snapshot:"Snapshot"},Xt={create:"➕",update:"📝",patch:"🩹",delete:"🗑️",snapshot:"📸"};function Ni(e,s){const n={};e.title!==s.title&&(n.title={from:e.title,to:s.title});const a=s.tags.filter(f=>!e.tags.includes(f)),o=e.tags.filter(f=>!s.tags.includes(f));(a.length||o.length)&&(n.tags={added:a,removed:o});const r=e.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=e.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 wi({diff:e}){return t.jsxs("div",{className:"history-meta-diff",children:[t.jsx("span",{className:"history-meta-diff-title",children:"Metadata changes"}),e.title&&t.jsxs("div",{className:"history-meta-diff-row",children:[t.jsx("span",{className:"history-meta-diff-field",children:"Title"}),t.jsx("span",{className:"history-meta-diff-chip--removed",children:e.title.from}),t.jsx("span",{className:"history-meta-diff-arrow",children:"→"}),t.jsx("span",{className:"history-meta-diff-chip--added",children:e.title.to})]}),e.tags&&t.jsxs("div",{className:"history-meta-diff-row",children:[t.jsx("span",{className:"history-meta-diff-field",children:"Tags"}),t.jsxs("div",{className:"history-meta-diff-chips",children:[e.tags.removed.map(s=>t.jsxs("span",{className:"history-meta-diff-chip--removed",children:["− ",s]},s)),e.tags.added.map(s=>t.jsxs("span",{className:"history-meta-diff-chip--added",children:["+ ",s]},s))]})]}),e.tracked_files&&t.jsxs("div",{className:"history-meta-diff-row",children:[t.jsx("span",{className:"history-meta-diff-field",children:"Tracked files"}),t.jsxs("div",{className:"history-meta-diff-chips",children:[e.tracked_files.removed.map(s=>t.jsxs("span",{className:"history-meta-diff-chip--removed",children:["− ",s]},s)),e.tracked_files.added.map(s=>t.jsxs("span",{className:"history-meta-diff-chip--added",children:["+ ",s]},s))]})]}),e.related_docs&&t.jsxs("div",{className:"history-meta-diff-row",children:[t.jsx("span",{className:"history-meta-diff-field",children:"Related docs"}),t.jsxs("div",{className:"history-meta-diff-chips",children:[e.related_docs.removed.map(s=>t.jsxs("span",{className:"history-meta-diff-chip--removed",children:["− ",s]},s)),e.related_docs.added.map(s=>t.jsxs("span",{className:"history-meta-diff-chip--added",children:["+ ",s]},s))]})]})]})}function Ci({changes:e}){return t.jsx("div",{className:"history-inline-diff",children:e.map((s,n)=>s.added?t.jsx("span",{className:"history-inline-diff--added",children:s.value},n):s.removed?t.jsx("span",{className:"history-inline-diff--removed",children:s.value},n):t.jsx("span",{children:s.value},n))})}function ki(e){const s=[],n=[];let a=null;for(const o of e)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 Si({docId:e,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(()=>ki(n),[n]),C=v=>{h(w=>{const R=new Set(w);return R.has(v)?R.delete(v):R.add(v),R})},j=a!==null&&(a.changeType==="update"||a.changeType==="patch"||a.changeType==="snapshot")&&a.version>1,g=(()=>{if(!a||!j)return null;if(a.changeType==="snapshot"){const v=n.filter(w=>w.version<a.version&&w.changeType==="snapshot").sort((w,R)=>R.version-w.version);return v.length>0?v[0].version:Math.min(...n.map(w=>w.version))}return a.version-1})(),b=g!==null?n.find(v=>v.version===g)??null:null,N=b?Ni(b.metadata,a.metadata):null,x=N&&Object.keys(N).length>0;return i.useEffect(()=>{if(c(null),!a||!j||g===null)return;let v=!1;return u(!0),fetch(`/api/history-version/${xe(e)}/${g}?project=${encodeURIComponent(s)}`).then(w=>w.json()).then(w=>{if(v)return;const R=w?.content??"",E=a.content??"";c(yi(R,E))}).catch(()=>{v||c([])}).finally(()=>{v||u(!1)}),()=>{v=!0}},[a?.version]),n.length===0?t.jsx("div",{className:"history-viewer",children:t.jsx("div",{className:"doc-viewer-empty",children:"No version history available for this document."})}):t.jsxs("div",{className:"history-viewer",children:[t.jsxs("div",{className:"history-list",children:[p.length>0&&t.jsxs("div",{className:"history-uncommitted",children:[t.jsx("span",{className:"history-uncommitted-label",children:"Non archivé"}),p.map(v=>{const w=a?.version===v.version,R=new Date(v.changedAt).toLocaleString(),E=Yt[v.changeType]??v.changeType,y=Xt[v.changeType]??"❓";return t.jsxs("button",{className:`history-entry history-entry--sub${w?" history-entry--active":""}`,onClick:()=>o(v.version),children:[t.jsxs("div",{className:"history-entry-header",children:[t.jsxs("span",{className:"history-entry-version",children:["v",v.version]}),t.jsxs("span",{className:`history-entry-type history-entry-type--${v.changeType}`,children:[y," ",E]})]}),t.jsx("span",{className:"history-entry-date",children:R})]},v.version)})]}),f.length===0&&p.length===0&&t.jsx("div",{className:"doc-viewer-empty",children:"No version history available."}),f.map(v=>{const w=a?.version===v.snapshot.version,R=m.has(v.snapshot.version),E=new Date(v.snapshot.changedAt).toLocaleString();return t.jsxs("div",{className:"history-group",children:[t.jsx("div",{className:`history-entry history-entry--snapshot-card${w?" history-entry--active":""}`,children:t.jsxs("button",{className:"history-entry-snapshot-main",onClick:()=>o(v.snapshot.version),children:[t.jsxs("div",{className:"history-entry-header",children:[t.jsxs("span",{className:"history-entry-version",children:["Version ",v.snapshot.version]}),t.jsx("span",{className:"history-entry-type history-entry-type--snapshot",children:"📸 Snapshot"})]}),t.jsxs("div",{className:"history-entry-footer",children:[t.jsx("span",{className:"history-entry-date",children:E}),v.subEntries.length>0&&t.jsx("span",{className:`history-group-toggle${R?" history-group-toggle--open":""}`,onClick:y=>{y.stopPropagation(),C(v.snapshot.version)},role:"button",tabIndex:0,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.stopPropagation(),C(v.snapshot.version))},children:R?"Masquer ▲":`Voir les ${v.subEntries.length} modification${v.subEntries.length>1?"s":""} ▼`})]})]})}),R&&t.jsx("div",{className:"history-group-entries",children:v.subEntries.map(y=>{const $=a?.version===y.version,L=new Date(y.changedAt).toLocaleString(),S=Yt[y.changeType]??y.changeType,I=Xt[y.changeType]??"❓";return t.jsxs("button",{className:`history-entry history-entry--sub${$?" history-entry--active":""}`,onClick:()=>o(y.version),children:[t.jsxs("div",{className:"history-entry-header",children:[t.jsxs("span",{className:"history-entry-version",children:["v",y.version]}),t.jsxs("span",{className:`history-entry-type history-entry-type--${y.changeType}`,children:[I," ",S]})]}),t.jsx("span",{className:"history-entry-date",children:L})]},y.version)})})]},v.snapshot.version)})]}),t.jsx("div",{className:"history-content",children:a?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"history-content-meta",children:[t.jsxs("div",{className:"history-content-meta-title",children:[t.jsx("strong",{children:a.metadata.title}),t.jsxs("span",{className:"history-content-version",children:["Version ",a.version]})]}),t.jsxs("div",{className:"history-content-meta-info",children:[t.jsxs("span",{className:`history-entry-type history-entry-type--${a.changeType}`,children:[Xt[a.changeType]??"❓"," ",Yt[a.changeType]??a.changeType]}),t.jsx("span",{className:"history-content-date",children:new Date(a.changedAt).toLocaleString()}),j&&d&&t.jsx("span",{className:"history-diff-loading",children:"Loading diff…"}),j&&!d&&g!==null&&t.jsxs("span",{className:"history-diff-base",children:["vs v",g]})]}),x&&t.jsx(wi,{diff:N})]}),j&&a.changeType==="snapshot"&&!d&&l!==null&&t.jsxs("div",{className:"history-diff-recap-banner",children:["Récapitulatif des modifications effectuées depuis le dernier évènement ",t.jsx("strong",{children:"snapshot"})]}),j?l!==null?t.jsx(Ci,{changes:l}):null:t.jsx("div",{className:"doc-content",children:t.jsx(cn,{remarkPlugins:[un],rehypePlugins:[dn],components:r,children:a.content??""})})]}):t.jsx("div",{className:"doc-viewer-empty",children:"Select a version to view its content."})})]})}const Ei={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 $i(e){const s=e.split(".").pop()?.toLowerCase()??"";return Ei[s]??"text"}function Ri({docId:e,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(e)}&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()},[e,n]),i.useEffect(()=>{const h=p=>{p.key==="Escape"&&a()};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[a]);const m=$i(n);return t.jsx("div",{className:"modal-overlay",onClick:a,children:t.jsxs("div",{className:"modal-content",onClick:h=>h.stopPropagation(),children:[t.jsxs("div",{className:"modal-header",children:[t.jsx("span",{className:"modal-title",children:n}),t.jsx("button",{className:"modal-close-btn",onClick:a,children:"✕"})]}),t.jsxs("div",{className:"modal-body",children:[l&&t.jsx("p",{style:{color:"#8b949e",fontSize:13},children:"Loading…"}),d&&t.jsx("p",{style:{color:"#f85149",fontSize:13},children:d}),!l&&!d&&o.map((h,p)=>t.jsxs("div",{children:[t.jsxs("p",{className:"section-code-header",children:["Lines ",h.start,"–",h.end]}),t.jsx(Do,{language:m,style:Lo,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 Pi({project:e,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),[C,j]=i.useState([]),[g,b]=i.useState({visibility:"hidden"}),N=i.useRef(null);i.useLayoutEffect(()=>{const E=N.current;if(!E)return;const y=E.offsetHeight,$=360;b({position:"fixed",top:Math.max(8,(window.innerHeight-y)/2),left:Math.max(8,(window.innerWidth-$)/2),width:$,visibility:"visible"})},[s]),i.useEffect(()=>{fetch(`/api/images/${encodeURIComponent(e)}`).then(E=>E.json()).then(E=>j(E)).catch(()=>{})},[e]),i.useEffect(()=>{function E(y){N.current&&!N.current.contains(y.target)&&s.current!==y.target&&a()}return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[a,s]);const x=i.useCallback(async E=>{h(!0),f(null);try{const y=new FormData;y.append("file",E);const $=await fetch(`/api/images?project=${encodeURIComponent(e)}`,{method:"POST",body:y});if(!$.ok){const S=await $.json().catch(()=>({}));throw new Error(S.error??"Upload failed")}const{url:L}=await $.json();n(``),a()}catch(y){f(y instanceof Error?y.message:"Upload failed")}finally{h(!1)}},[e,l,n,a]),v=async E=>{const y=E.target.files?.[0];y&&await x(y)};i.useEffect(()=>{const E=async y=>{const L=Array.from(y.clipboardData?.items??[]).find(X=>X.type.startsWith("image/"));if(!L)return;y.preventDefault();const S=L.getAsFile();if(!S)return;const I=S.type.split("/")[1]??"png",z=new File([S],`paste-${Date.now()}.${I}`,{type:S.type});await x(z)};return document.addEventListener("paste",E),()=>document.removeEventListener("paste",E)},[x]);const w=()=>{d.trim()&&(n(`})`),a())},R=E=>{n(``),a()};return To.createPortal(t.jsxs("div",{className:"image-insert-popover",ref:N,style:g,children:[t.jsxs("div",{className:"image-insert-header",children:[t.jsx("span",{className:"image-insert-title",children:"Insert image"}),t.jsx("button",{className:"image-insert-close",onClick:a,title:"Close",children:"✕"})]}),t.jsxs("div",{className:"image-insert-tabs",children:[t.jsx("button",{className:`image-insert-tab${o==="upload"?" active":""}`,onClick:()=>r("upload"),children:"Upload"}),t.jsx("button",{className:`image-insert-tab${o==="url"?" active":""}`,onClick:()=>r("url"),children:"URL"})]}),t.jsxs("div",{className:"image-insert-alt-row",children:[t.jsx("label",{className:"image-insert-label",children:"Alt text"}),t.jsx("input",{className:"image-insert-input",type:"text",placeholder:"Description (optional)",value:l,onChange:E=>c(E.target.value)})]}),o==="upload"?t.jsxs("div",{className:"image-insert-tab-content",children:[t.jsxs("label",{className:`image-upload-label${m?" uploading":""}`,children:[t.jsx("input",{type:"file",accept:"image/*",style:{display:"none"},onChange:v,disabled:m}),m?"⏳ Uploading…":"📁 Choose a file"]}),t.jsx("p",{className:"image-paste-hint",children:"or press Ctrl+V / ⌘V to paste from clipboard"}),p&&t.jsx("div",{className:"image-insert-error",children:p})]}):t.jsxs("div",{className:"image-insert-tab-content",children:[t.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"&&w()}),t.jsx("button",{className:"image-insert-btn-insert",onClick:w,disabled:!d.trim(),children:"Insert"})]}),C.length>0&&t.jsxs("div",{className:"image-insert-gallery-section",children:[t.jsx("div",{className:"image-insert-gallery-label",children:"Project images"}),t.jsx("div",{className:"image-thumbs",children:C.map(E=>t.jsx("img",{src:E.url,alt:E.filename,className:"image-thumb",title:E.filename,onClick:()=>R(E.url)},E.filename))})]})]}),document.body)}function en(e,s){return!e||e.status==="no_tracking"?"unknown":e.modified.includes(s)?"modified":e.missing.includes(s)?"missing":(e.anchors_lost??[]).includes(s)?"anchors_lost":e.unchanged.includes(s)?"ok":"unknown"}function Di(e){if(!e)return"—";const s=new Date(e);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 Li({doc:e,isStale:s,report:n,toc:a,activeHeadingId:o,version:r,onSelectHeading:l,onSelectFile:c,onClose:d,tab:u,onTab:m,comments:h,unreadComments:p}){const f=re(),{docs:C,projects:j,currentProject:g}=Y(),b=x=>!!e.tracked_files.find(w=>w.path===x)?.sections?.length&&en(n,x)!=="anchors_lost",N=h!==null&&u==="comments";return t.jsxs("aside",{className:"context-rail",children:[t.jsxs("div",{className:"rail-section rail-section--toc",children:[t.jsxs("div",{className:"rail-section-head",children:[h!==null?t.jsxs("div",{className:"rail-tabs",children:[t.jsx("button",{type:"button",className:`rail-tab${N?"":" active"}`,onClick:()=>m("page"),children:"On this page"}),t.jsxs("button",{type:"button",className:`rail-tab${N?" active":""}`,onClick:()=>m("comments"),children:["Comments",p>0&&t.jsx("span",{className:"rail-tab-count",children:p})]})]}):t.jsx("span",{className:"rail-label",children:a.length>0?"On this page":""}),t.jsx("button",{className:"rail-collapse-btn",onClick:d,title:"Hide details (Ctrl/⌘ + \\)",children:"▷|"})]}),N&&h,!N&&a.length>0&&t.jsx("nav",{className:"rail-toc",children:a.map(x=>t.jsx("button",{className:`rail-toc-item rail-toc-item--h${x.level}${o===x.id?" active":""}`,onClick:()=>l(x.id),children:x.text},x.id))})]}),!N&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"rail-section",children:[t.jsx("span",{className:"rail-label",children:"Status"}),t.jsxs("div",{className:"rail-row",children:[t.jsx("span",{className:"rail-key",children:"Freshness"}),t.jsx("span",{className:`rail-chip${s?" rail-chip--stale":" rail-chip--fresh"}`,children:s?"Outdated":"Up to date"})]}),t.jsxs("div",{className:"rail-row",children:[t.jsx("span",{className:"rail-key",children:"Last updated"}),t.jsx("span",{className:"rail-val",children:Di(e.updatedAt)})]}),t.jsxs("div",{className:"rail-row",children:[t.jsx("span",{className:"rail-key",children:"Version"}),t.jsx("span",{className:"rail-val",children:r!==null?`v${r}`:"—"})]})]}),e.tracked_files.length>0&&t.jsxs("div",{className:"rail-section",children:[t.jsxs("span",{className:"rail-label",children:["Tracked files · ",e.tracked_files.length]}),t.jsx("div",{className:"rail-files",children:e.tracked_files.map(x=>{const v=en(n,x.path),w=b(x.path);return t.jsxs("button",{className:`rail-file${w?" rail-file--clickable":""}`,onClick:w?()=>c(x.path):void 0,title:w?`${x.path} — voir le code de la section`:x.path,children:[t.jsx("span",{className:`rail-file-dot rail-file-dot--${v}`}),t.jsx("span",{className:"rail-file-path",children:x.path})]},x.path)})}),t.jsx("div",{className:"rail-legend",children:"modified · up to date · missing · anchors lost"})]}),e.tags.length>0&&t.jsxs("div",{className:"rail-section",children:[t.jsx("span",{className:"rail-label",children:"Tags"}),t.jsx("div",{className:"rail-tags",children:e.tags.map(x=>t.jsx("span",{className:"tag-badge",children:x},x))})]}),e.related_docs&&e.related_docs.length>0&&t.jsxs("div",{className:"rail-section",children:[t.jsx("span",{className:"rail-label",children:"Related pages"}),t.jsx("div",{className:"rail-links",children:e.related_docs.map(x=>{const v=x.indexOf(":");if(v!==-1){const R=x.slice(0,v),E=x.slice(v+1);return j.includes(R)?t.jsxs("button",{className:"rail-link rail-link--cross-project",onClick:()=>f(ne(R,E)),title:`Projet : ${R}`,children:["↗ ",R," · ",E]},x):t.jsxs("span",{className:"rail-link rail-link--broken",children:[x," (projet introuvable)"]},x)}const w=C.find(R=>R.id===x);return w?t.jsxs("button",{className:"rail-link",onClick:()=>f(ne(g,x)),children:["▤ ",w.title]},x):t.jsxs("span",{className:"rail-link rail-link--broken",children:[x," (lien cassé)"]},x)})})]})]})]})}function Qt(e){return!e.root.read||e.replies.some(s=>!s.read)}function Ti(e){return[e.root.id,...e.replies.map(s=>s.id)]}function pt(e){return e===null?"an unversioned publication":`v${e}`}function Mi({data:e,locatedIds:s,activeId:n,hoveredId:a,readOnly:o,onActivate:r,onHover:l}){const c=Mo(e.comments),d=c.filter(y=>!y.root.detached),u=c.filter(y=>y.root.detached),m=e.comments.filter(y=>!y.read).length,[h,p]=i.useState(m>0?"unread":"all"),[f,C]=i.useState(null),[j,g]=i.useState(!1),[b,N]=i.useState(null),x=e.publication?.id,v=e.publication?.commentsClosed===!0;if(!x)return t.jsx("div",{className:"cp-empty",children:"This document is not published: readers cannot comment on it."});const w=async y=>{g(!0),N(null);try{await y()}catch($){N($ instanceof Error?$.message:String($))}finally{g(!1)}},R=h==="unread"?d.filter(Qt):d,E=(y,$)=>{const{root:L}=y,S=Qt(y),I=s.has(L.id);return t.jsxs("div",{className:`cp-card${S?" cp-card--unread":""}${$?" cp-card--detached":""}${n===L.id||a===L.id?" cp-card--active":""}`,onClick:()=>r(L.id),onMouseEnter:()=>l(L.id),onMouseLeave:()=>l(null),children:[t.jsxs("div",{className:"cp-head",children:[$?t.jsx(ws,{size:12,className:"cp-state cp-state--detached"}):S?t.jsx("span",{className:"cp-dot",title:"Unread"}):t.jsx(Se,{size:12,className:"cp-state cp-state--read"}),t.jsx("span",{className:"cp-author",title:Ls,children:Ts(L.author)}),t.jsxs("span",{className:"cp-time",title:new Date(L.createdAt).toLocaleString(),children:["· ",Ms(L.createdAt)]}),!o&&t.jsxs("span",{className:"cp-actions",onClick:z=>z.stopPropagation(),children:[S&&t.jsx("button",{type:"button",className:"cp-icon",title:"Mark as read",disabled:j,onClick:()=>w(()=>Is(x,Ti(y))),children:t.jsx(Se,{size:14})}),t.jsx("button",{type:"button",className:"cp-icon cp-icon--danger",title:"Delete",disabled:j,onClick:()=>C(L.id),children:t.jsx(Hl,{size:14})})]})]}),L.anchor&&t.jsxs("div",{className:`cp-quote${I||$?"":" cp-quote--lost"}`,children:["« ",L.anchor.exact," »",$&&L.detached?` — ${pt(L.detached.fromVersion)}`:""]}),!$&&!I&&t.jsx("div",{className:"cp-note",children:"Passage changed since the publication: not highlighted here."}),t.jsx("div",{className:"cp-body",children:L.body}),y.replies.map(z=>t.jsxs("div",{className:`cp-reply${z.read?"":" cp-reply--unread"}`,children:[t.jsxs("div",{className:"cp-reply-head",children:[t.jsx("span",{title:Ls,children:Ts(z.author)})," · ",Ms(z.createdAt)]}),t.jsx("div",{className:"cp-body",children:z.body})]},z.id)),$&&L.detached&&t.jsxs("div",{className:"cp-note",children:["Detached when the publication went from ",pt(L.detached.fromVersion)," to"," ",pt(L.detached.toVersion)]}),f===L.id&&t.jsxs("div",{className:"cp-confirm",onClick:z=>z.stopPropagation(),children:[t.jsxs("span",{children:["Delete this comment",y.replies.length>0?` and its ${y.replies.length} replies`:"","?"]}),t.jsx("button",{type:"button",className:"cp-confirm-btn",onClick:()=>C(null),disabled:j,children:"Cancel"}),t.jsx("button",{type:"button",className:"cp-confirm-btn cp-confirm-btn--danger",disabled:j,onClick:()=>w(async()=>{await Io(x,[L.id]),C(null)}),children:"Delete"})]})]},L.id)};return t.jsxs("div",{className:"cp",children:[t.jsxs("div",{className:"cp-toolbar",children:[t.jsxs("button",{type:"button",className:`cp-filter${h==="unread"?" active":""}`,onClick:()=>p("unread"),children:["Unread · ",c.filter(Qt).length]}),t.jsxs("button",{type:"button",className:`cp-filter${h==="all"?" active":""}`,onClick:()=>p("all"),children:["All · ",d.length]}),!o&&m>0&&t.jsx("button",{type:"button",className:"cp-mark-all",disabled:j,onClick:()=>w(()=>Is(x,null)),children:"Mark all as read"})]}),t.jsxs("div",{className:"cp-usage",children:[t.jsxs("span",{children:[e.comments.length," / ",e.limit," comments on the published ",pt(e.publication?.version??null),v&&" · closed to new comments"]}),!o&&t.jsx("button",{type:"button",className:"cp-close-toggle",disabled:j,title:v?"Let readers add comments again":"Readers keep seeing the comments but can no longer add any",onClick:()=>w(()=>Ao(x,!v)),children:v?"Reopen comments":"Close comments"})]}),b&&t.jsx("div",{className:"cp-error",children:b}),R.length===0?u.length===0&&t.jsx("div",{className:"cp-empty",children:h==="unread"?"No unread comment.":"No comment yet."}):R.map(y=>E(y,!1)),u.length>0&&t.jsxs("div",{className:"cp-detached",children:[t.jsxs("span",{className:"rail-label",children:["Detached · ",u.length]}),t.jsx("div",{className:"cp-detached-text",children:"Their passage is absent from the published version: readers no longer see them. They still count toward the limit until deleted."}),u.map(y=>E(y,!0))]})]})}function Ii(e,s){const{commentsVersion:n,publicationsVersion:a}=Y(),[o,r]=i.useState(null),[l,c]=i.useState(0),d=`${e}\0${s??""}`;i.useEffect(()=>{if(!s)return;let m=!1;return _o(e,s).then(h=>{m||r({key:d,data:h})}).catch(h=>console.error(`Comments of "${s}" could not be loaded: ${h.message}`)),()=>{m=!0}},[d,e,s,n,a,l]);const u=i.useCallback(()=>c(m=>m+1),[]);return{data:o?.key===d?o.data:null,reload:u}}function Ai(){const{currentProject:e,commentsVersion:s,publicationsVersion:n,hasReceivedInitialState:a,setCommentSummary:o}=Y();i.useEffect(()=>{if(!a)return;let r=!1;return zo(e).then(l=>{r||o(e,l)}).catch(l=>console.error(`Comment counts of "${e}" could not be loaded: ${l.message}`)),()=>{r=!0}},[e,s,n,a])}function _i(e){const{commentSummary:s,currentProject:n}=Y();return!e||s.project!==n?null:s.docs[e]??null}function Ka(){const[e,s]=i.useState(!1);return{copied:e,copy:async a=>{await navigator.clipboard.writeText(a),s(!0),setTimeout(()=>s(!1),2e3)}}}function Ja(e){const{publicationsVersion:s}=Y(),[n,a]=i.useState(null),[o,r]=i.useState(null),[l,c]=i.useState(0);i.useEffect(()=>{let u=!1;return Fo(e).then(m=>{u||(a({project:e,publications:m}),r(null))}).catch(m=>{u||r(m.message)}),()=>{u=!0}},[e,s,l]);const d=i.useCallback(()=>c(u=>u+1),[]);return{publications:n?.project===e?n.publications:null,error:o,reload:d}}function zi({project:e,doc:s,latestVersion:n,readOnly:a}){const{publications:o,reload:r}=Ja(e),[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 t.jsxs("div",{className:"menu-anchor",children:[t.jsxs("button",{className:`btn-secondary publish-btn${l?" publish-btn--open":""}`,onClick:u,title:d?"Public link of this document":"Publish this document",children:[t.jsx(Mt,{size:14,className:d?"publish-btn-icon--published":void 0}),d?"Published":"Publish",d?.status==="modified"&&t.jsx("span",{className:"publish-btn-dot",title:"Changed since it was published"})]}),l&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"menu-backdrop",onClick:()=>c(!1)}),t.jsx("div",{className:"publish-popover",role:"dialog","aria-label":d?"Document published":"Publish this document",children:d?t.jsx(Oi,{publication:d,readOnly:a,onClose:()=>c(!1),onChanged:r}):t.jsx(Fi,{project:e,doc:s,latestVersion:n,onClose:()=>c(!1),onChanged:r})})]})]})}function Ya({title:e,published:s,onClose:n}){return t.jsxs("div",{className:"publish-head",children:[s&&t.jsx("span",{className:"publish-online-dot"}),t.jsx("span",{className:"publish-title",children:e}),t.jsx("button",{className:"publish-close",onClick:n,"aria-label":"Close",children:t.jsx(pn,{size:14})})]})}function Xa({label:e,value:s,onChange:n,placeholder:a,multiline:o}){return t.jsxs("label",{className:"publish-field",children:[t.jsxs("span",{className:"publish-field-label",children:[e," ",t.jsx("span",{className:"publish-field-optional",children:"(optional)"})]}),o?t.jsx("textarea",{className:"publish-input publish-input--multiline",value:s,maxLength:ts,rows:3,placeholder:a,onChange:r=>n(r.target.value),autoFocus:!0}):t.jsx("input",{className:"publish-input",value:s,maxLength:ts,placeholder:a,onChange:r=>n(r.target.value)})]})}function Fi({project:e,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 Oo(e,s.id,r),o()}catch(p){m(p instanceof Error?p.message:String(p))}finally{d(!1)}};return t.jsxs(t.Fragment,{children:[t.jsx(Ya,{title:"Publish this document",onClose:a}),t.jsx("p",{className:"publish-text",children:"The public link shows the current version, frozen. Later changes only appear there once the publication is updated."}),t.jsxs("div",{className:"publish-version",children:[t.jsx(Ml,{size:14}),"Version ",Te(n)," · modified ",us(s.updatedAt)]}),t.jsx(Xa,{label:"Version note",value:r,onChange:l,placeholder:"e.g. First version shared with the infra team",multiline:!0}),t.jsxs("div",{className:"publish-access",children:[t.jsx(mn,{size:14}),"Anyone with the link can read this document."]}),u&&t.jsx("div",{className:"publish-error",children:u}),t.jsxs("div",{className:"publish-actions",children:[t.jsx("button",{className:"btn-secondary",onClick:a,disabled:c,children:"Cancel"}),t.jsxs("button",{className:"btn-primary",onClick:h,disabled:c,children:[t.jsx(Mt,{size:14}),c?"Publishing…":"Publish"]})]})]})}function Oi({publication:e,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}=Ka(),C=hn(e.token),j=e.status==="modified",g=async b=>{c(!0),u(null);try{await b(),r(""),h(!1),a()}catch(N){u(N instanceof Error?N.message:String(N))}finally{c(!1)}};return t.jsxs(t.Fragment,{children:[t.jsx(Ya,{title:"Document published",published:!0,onClose:n}),t.jsxs("div",{className:"publish-link",children:[t.jsx(mn,{size:14,className:"publish-link-icon"}),t.jsx("span",{className:"publish-link-url",title:C,children:C}),t.jsx("a",{className:"publish-icon-btn",href:C,target:"_blank",rel:"noopener noreferrer",title:"Open the public page",children:t.jsx(na,{size:14})}),t.jsx("button",{className:"publish-copy-btn",onClick:()=>f(C),title:"Copy the link",children:p?t.jsx(Se,{size:14}):t.jsx(Lt,{size:14})})]}),t.jsxs("div",{className:"publish-meta",children:["Published ",us(e.publishedAt)," · version ",Te(e.version)]}),e.note&&t.jsx("div",{className:"publish-quote",children:e.note}),t.jsx("div",{className:"publish-sep"}),j?t.jsxs("div",{className:"publish-warning",children:[t.jsx(Ns,{size:14}),t.jsxs("div",{children:["The document changed since it was published.",t.jsx("br",{}),"Published: ",Te(e.version)," · current: ",Te(e.currentVersion)]})]}):t.jsxs("div",{className:"publish-uptodate",children:[t.jsx(Xe,{size:14}),"The published version is up to date."]}),!s&&j&&!m&&t.jsx(Xa,{label:"Note for the new version",value:o,onChange:r,placeholder:"e.g. Added the Entry points section"}),d&&t.jsx("div",{className:"publish-error",children:d}),!s&&(m?t.jsx(Qa,{busy:l,onCancel:()=>h(!1),onConfirm:()=>g(()=>fn(e.id))}):t.jsxs("div",{className:"publish-actions publish-actions--split",children:[t.jsxs("button",{className:"btn-secondary publish-danger-btn",onClick:()=>h(!0),disabled:l,children:[t.jsx(ws,{size:14}),"Unpublish"]}),j&&t.jsxs("button",{className:"btn-primary",onClick:()=>g(()=>gn(e.id,o)),disabled:l,children:[t.jsx(Ct,{size:14}),l?"Updating…":"Update publication"]})]}))]})}function Qa({title:e,busy:s,onCancel:n,onConfirm:a}){return t.jsxs("div",{className:"publish-confirm",children:[t.jsx("div",{className:"publish-confirm-title",children:e?`Unpublish “${e}”?`:"Unpublish this document?"}),t.jsx("div",{className:"publish-confirm-text",children:"The link stops working immediately. Publishing again creates a new link."}),t.jsxs("div",{className:"publish-actions",children:[t.jsx("button",{className:"btn-secondary",onClick:n,disabled:s,children:"Cancel"}),t.jsx("button",{className:"publish-confirm-btn",onClick:a,disabled:s,children:s?"Unpublishing…":"Unpublish"})]})]})}function tn(e){return e.replace(/[^a-zA-Z0-9_\-. ]/g,"_")}const Ui=1280,ls="mcp-documentor.contextRail",Ze=()=>typeof window>"u"||window.innerWidth>=Ui;function Hi(){try{const e=JSON.parse(localStorage.getItem(ls)??"null");return e&&e.wide===Ze()?e.open:null}catch{return null}}function Zt(e){try{e===null?localStorage.removeItem(ls):localStorage.setItem(ls,JSON.stringify({open:e,wide:Ze()}))}catch{}}function sn(e){if(!e)return"the last snapshot";const s=new Date(e);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 Bi(){const e=re(),s=Y(),{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:C,readOnly:j,codeSourcesVersion:g}=s,b=i.useRef(null),N=i.useRef(null),x=i.useRef(null),[v,w]=i.useState("document"),[R,E]=i.useState(null),[y,$]=i.useState(!1),[L,S]=i.useState(!1),[I,z]=i.useState(!1),[X,B]=i.useState(!1),[q,D]=i.useState(!1),[V,T]=i.useState(""),[W,J]=i.useState(!1),[be,ue]=i.useState(null),[Ue,ye]=i.useState(!1),[Ee,Ne]=i.useState(null),[ot,$e]=i.useState(null),[He,te]=i.useState(!1),[pe,he]=i.useState(!1),[Re,Pe]=i.useState(!1),[Me,we]=i.useState(null),[M,U]=i.useState(!1),[G,K]=i.useState(!1),[fe,At]=i.useState([]),[ho,_t]=i.useState(null),[Ss,Be]=i.useState(()=>Hi()??Ze()),[mo,We]=i.useState("page"),[ge,po]=i.useState(null),[zt,Ft]=i.useState(null),[Ot,rt]=i.useState(null),Es=i.useRef(null),Ut=k=>{Zt(k),Be(k)},$s=v==="diff",Rs=v==="history";i.useEffect(()=>{window.__pdfReady=!!(n&&!q)},[n,q]),i.useEffect(()=>{let k=Ze();const P=()=>{const _=Ze();_!==k&&(k=_,Zt(null),Be(_))};return window.addEventListener("resize",P),()=>window.removeEventListener("resize",P)},[]),i.useEffect(()=>{const k=P=>{(P.metaKey||P.ctrlKey)&&P.key==="\\"&&(P.preventDefault(),Be(_=>(Zt(!_),!_)))};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[]),i.useEffect(()=>{if(!a)return;window.__pdfReady=!1,window.__mermaidPending=0,b.current&&(b.current.scrollTop=0),w("document"),E(null),z(!1),f(null),D(!1),ue(null),Ne(null),he(!1),we(null),U(!1),K(!1),At([]),_t(null),We("page"),Ft(null),rt(null);const k=xe(a),P=new AbortController;let _=!1;const H=encodeURIComponent(u);return fetch(`/api/doc/${k}?project=${H}`,{signal:P.signal}).then(F=>F.json()).then(F=>{_||(F.doc?l(F.doc):z(!0))}).catch(F=>{_||F.name==="AbortError"||z(!0)}),fetch(`/api/freshness/${k}?project=${H}`,{signal:P.signal}).then(F=>F.json()).then(F=>{_||!F.report||r(F.report)}).catch(()=>{}),fetch(`/api/history/${k}?project=${H}`,{signal:P.signal}).then(F=>F.json()).then(F=>{_||f(F.versions??[])}).catch(()=>{}),()=>{_=!0,P.abort()}},[a,u]),i.useEffect(()=>{if(g===0||!a)return;const k=new AbortController;return fetch(`/api/freshness/${xe(a)}?project=${encodeURIComponent(u)}`,{signal:k.signal}).then(P=>P.json()).then(P=>{P.report&&r(P.report)}).catch(()=>{}),()=>k.abort()},[g]),i.useEffect(()=>{if(v!=="document"||q||!n){At([]);return}const k=requestAnimationFrame(()=>{const P=b.current?.querySelector(".doc-content");if(!P)return;const _=[...P.querySelectorAll("h1, h2, h3")];At(_.filter(H=>H.id).map(H=>({id:H.id,text:H.textContent??"",level:Number(H.tagName.slice(1))})))});return()=>cancelAnimationFrame(k)},[n,v,q]),i.useEffect(()=>{const k=b.current;if(!k||fe.length===0)return;const P=()=>{const _=k.getBoundingClientRect().top+80;let H=fe[0].id;for(const F of fe){const se=document.getElementById(F.id);se&&se.getBoundingClientRect().top<=_&&(H=F.id)}_t(H)};return P(),k.addEventListener("scroll",P,{passive:!0}),()=>k.removeEventListener("scroll",P)},[fe]);const fo=i.useCallback(k=>{document.getElementById(k)?.scrollIntoView({behavior:"smooth",block:"start"}),_t(k)},[]),De=Ii(u,n?.id),Ce=_i(n?.id),lt=Uo(ge),go=i.useMemo(()=>(De.data?.comments??[]).filter(k=>!k.parentId&&!k.detached),[De.data]),me=Ho(lt,go),xo=(De.data?.comments??[]).filter(k=>!k.read).length;i.useEffect(()=>{const k=De.data;!n||!k||Es.current===n.id||(Es.current=n.id,k.comments.some(P=>!P.read)&&(We("comments"),Be(!0)))},[De.data,n]),i.useEffect(()=>{ut("dc-passage",[...me.values()].map(_=>_.range));const k=Ot??zt,P=k?me.get(k):void 0;ut("dc-focus",P?[P.range]:[])},[me,Ot,zt]),i.useEffect(()=>()=>{ut("dc-passage",[]),ut("dc-focus",[])},[]);const Ht=i.useCallback((k,P)=>{if(!lt)return null;const _=Bo(k,P),H=_?lt.indexAt(_.node,_.offset):null;if(H===null)return null;for(const[F,se]of me)if(H>=se.start&&H<se.end)return F;return null},[lt,me]);i.useEffect(()=>{if(!ge||me.size===0)return;const k=F=>{if(!window.getSelection()?.isCollapsed||F.target.closest("a, button"))return;const se=Ht(F.clientX,F.clientY);se&&(Ft(se),We("comments"),Be(!0))};let P=0;const _=F=>{cancelAnimationFrame(P),P=requestAnimationFrame(()=>rt(Ht(F.clientX,F.clientY)))},H=()=>{cancelAnimationFrame(P),rt(null)};return ge.addEventListener("click",k),ge.addEventListener("mousemove",_),ge.addEventListener("mouseleave",H),()=>{cancelAnimationFrame(P),ge.removeEventListener("click",k),ge.removeEventListener("mousemove",_),ge.removeEventListener("mouseleave",H)}},[ge,me,Ht]);const vo=i.useCallback(k=>{Ft(k),me.get(k)?.range.startContainer.parentElement?.scrollIntoView({behavior:"smooth",block:"center"})},[me]),Bt=i.useMemo(()=>({code:Wo,a({href:k,children:P,..._}){if(k?.startsWith("doc://")){const H=Wl(k.slice(6)),F=H.indexOf(":");if(F!==-1){const ae=H.slice(0,F),Ge=H.slice(F+1),Ke=m.includes(ae);return t.jsx("button",{className:Ke?"doc-inline-link doc-inline-link--cross-project":"doc-inline-link doc-inline-link--broken",onClick:()=>{Ke&&e(ne(ae,Ge))},title:Ke?`Projet : ${ae}`:`Projet introuvable : ${ae}`,children:P})}const se=H,qe=d.some(ae=>ae.id===se);return t.jsx("button",{className:qe?"doc-inline-link":"doc-inline-link doc-inline-link--broken",onClick:()=>{qe&&e(ne(u,se))},title:qe?void 0:`Document introuvable : ${se}`,children:P})}return k?.startsWith("#")?t.jsx("a",{href:k,onClick:H=>{H.preventDefault(),document.getElementById(k.slice(1))?.scrollIntoView({behavior:"smooth"})},..._,children:P}):t.jsx("a",{href:k,target:"_blank",rel:"noopener noreferrer",..._,children:P})},img({src:k,alt:P,..._}){return t.jsx("img",{src:k,alt:P??"",className:"doc-image",..._})}}),[d,m,u,e]),jo=i.useMemo(()=>n&&t.jsx(cn,{remarkPlugins:[un],rehypePlugins:[dn],components:Bt,urlTransform:k=>k.startsWith("doc://")?k:Vo(k),children:n.content}),[n,Bt]);if(!n&&!a)return t.jsx("div",{className:"doc-viewer",children:t.jsx("div",{className:"doc-viewer-empty",children:"Select a documentation entry to view"})});if(a&&I&&!n)return t.jsx("div",{className:"doc-viewer",children:t.jsx("div",{className:"doc-viewer-empty",children:"No documentation at this path in the current project."})});const bo=async()=>{if(n)try{const P=await(await fetch(`/api/freshness/${xe(n.id)}?project=${encodeURIComponent(u)}`)).json();P.report&&r(P.report)}catch{}},yo=async()=>{n&&(await navigator.clipboard.writeText(n.content),S(!0),setTimeout(()=>S(!1),2e3))},No=()=>{if(!n)return;const k=new Blob([n.content],{type:"text/markdown;charset=utf-8"}),P=URL.createObjectURL(k),_=document.createElement("a");_.href=P,_.download=`${tn(n.title)}.md`,document.body.appendChild(_),_.click(),document.body.removeChild(_),URL.revokeObjectURL(P)},wo=async()=>{if(!n)return;const k=Number(localStorage.getItem("printScale")??100)/100,P=u,_=n.id;ye(!0),Ne(null);try{const H=new URLSearchParams({project:P,docId:_,scale:String(k)}),F=await fetch(`/api/pdf?${H}`);if(F.status===503){const Ge=await F.json();Ne(Ge.message??"Navigateur introuvable pour la génération PDF."),setTimeout(()=>Ne(null),8e3);return}if(!F.ok){Ne("Échec de la génération PDF."),setTimeout(()=>Ne(null),5e3);return}const se=await F.blob(),qe=await new Promise((Ge,Ke)=>{const dt=new FileReader;dt.onload=()=>Ge(dt.result),dt.onerror=Ke,dt.readAsDataURL(se)}),ae=document.createElement("a");ae.href=qe,ae.download=`${tn(n.title)}.pdf`,document.body.appendChild(ae),ae.click(),document.body.removeChild(ae)}finally{ye(!1)}},Co=async()=>{if(!(!n||h!==null)){B(!0);try{const P=await(await fetch(`/api/history/${xe(n.id)}?project=${encodeURIComponent(u)}`)).json();f(P.versions??[])}catch{f([])}finally{B(!1)}}},ko=async()=>{if(!(!n||R!==null)){$(!0);try{const P=await(await fetch(`/api/git-diff/${xe(n.id)}?project=${encodeURIComponent(u)}`)).json();E(P.diff??P.error??"No diff available.")}catch{E("Failed to load diff.")}finally{$(!1)}}},Ve=k=>{w(k),U(!1),K(!1),k!=="document"&&D(!1),k==="diff"&&ko(),k==="history"&&Co()},So=k=>{const P=N.current;if(!P)return;const _=P.selectionStart,H=P.selectionEnd,F=V.slice(0,_)+k+V.slice(H);T(F),requestAnimationFrame(()=>{P.selectionStart=P.selectionEnd=_+k.length,P.focus()})},Eo=async()=>{if(n){J(!0),ue(null);try{const k=xe(n.id),P=await fetch(`/api/doc/${k}?project=${encodeURIComponent(u)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:V})}),_=await P.json();if(!P.ok||_.error)throw new Error(_.error||"Save failed");const H=new Date().toISOString();l({...n,content:V,updatedAt:H}),c(d.map(F=>F.id===n.id?{...F,updatedAt:H}:F)),D(!1)}catch(k){ue(k instanceof Error?k.message:"Save failed")}finally{J(!1)}}},$o=async()=>{if(n){Pe(!0),we(null);try{const k=xe(n.id),P=await fetch(`/api/doc/${k}?project=${encodeURIComponent(u)}`,{method:"DELETE"}),_=await P.json();if(!P.ok||_.error)throw new Error(_.error||"Delete failed");const H=n.id;c(d.filter(F=>F.id!==H)),l(null),r(null),he(!1),e(ne(u,null),{replace:!0})}catch(k){we(k instanceof Error?k.message:"Delete failed")}finally{Pe(!1)}}},Wt=n?d.find(k=>k.id===n.id):void 0,Ps=Wt?.isStale??!1,Le=n?.tracked_files.length??0,it=o?.modified.length??0,ct=h&&h.length>0?h[0].version:null,Ds=n&&Le>0?n.tracked_files.map(k=>k.lastModifiedAt).filter(Boolean).sort().slice(-1)[0]:void 0,Ro=[...Wt?.folder?Wt.folder.split("/").filter(Boolean):[],n?.title??"…"],Po=!j&&!!n&&v==="document";return t.jsxs("div",{className:"doc-viewer",children:[t.jsxs("div",{className:"doc-main",ref:b,children:[t.jsxs("div",{className:"doc-topbar",children:[t.jsxs("div",{className:"doc-topbar-left",children:[t.jsxs("div",{className:"doc-breadcrumb",children:[t.jsx("button",{className:"nav-btn",onClick:()=>e(-1),title:"Go back",children:"←"}),t.jsx("button",{className:"nav-btn",onClick:()=>e(1),title:"Go forward",children:"→"}),Ro.map((k,P)=>t.jsxs("span",{className:"doc-breadcrumb-segment",children:[P>0&&t.jsx("span",{className:"doc-breadcrumb-sep",children:"/"}),k]},`${k}-${P}`))]}),t.jsx("h1",{className:"doc-title",children:n?.title??"…"})]}),t.jsxs("div",{className:"doc-actions",children:[!Ss&&n&&t.jsx("button",{className:"icon-btn",onClick:()=>Ut(!0),title:"Show details (Ctrl/⌘ + \\)",children:"|◁"}),n&&!q&&Ce&&Ce.total>0&&t.jsxs("button",{className:"btn-secondary doc-comments-btn",onClick:()=>{We("comments"),Ut(!0)},title:Ce.unread>0?`${Ce.total} comments, ${Ce.unread} unread`:`${Ce.total} comments`,children:[t.jsx(ds,{size:13}),Ce.total,Ce.unread>0&&t.jsx("span",{className:"doc-comments-dot"})]}),n&&!q&&t.jsx(zi,{project:u,doc:n,latestVersion:ct,readOnly:j},n.id),Po&&t.jsx("button",{className:`btn-primary${q?" active":""}`,onClick:()=>{!q&&n&&T(n.content),D(!q),ue(null)},title:q?"Cancel editing":"Edit document",children:q?"✕ Cancel":"✎ Edit"}),n&&!q&&t.jsxs("div",{className:"menu-anchor",children:[t.jsx("button",{className:"btn-secondary",onClick:()=>{U(k=>!k),K(!1)},title:"Export this document",children:"↓ Export ▾"}),M&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"menu-backdrop",onClick:()=>U(!1)}),t.jsxs("div",{className:"menu-popover",children:[t.jsx("button",{className:"menu-item",onClick:()=>{U(!1),yo()},children:L?"✓ Copied!":"⎘ Copy markdown"}),t.jsx("button",{className:"menu-item",onClick:()=>{U(!1),No()},children:"↓ Download .md"}),t.jsx("button",{className:"menu-item",disabled:Ue,onClick:()=>{U(!1),wo()},children:Ue?"⏳ PDF…":"↓ Download PDF"})]})]})]}),n&&!q&&t.jsxs("div",{className:"menu-anchor",children:[t.jsx("button",{className:"btn-icon-secondary",onClick:()=>{K(k=>!k),U(!1)},title:"More actions",children:"⋯"}),G&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"menu-backdrop",onClick:()=>K(!1)}),t.jsxs("div",{className:"menu-popover menu-popover--right",children:[Le>0&&t.jsx("button",{className:"menu-item",onClick:()=>{K(!1),bo()},children:"⟳ Re-check freshness"}),t.jsx("button",{className:"menu-item",onClick:()=>{K(!1),navigator.clipboard.writeText(n.id)},children:"⎘ Copy doc ID"}),!j&&t.jsx("button",{className:"menu-item menu-item--danger",onClick:()=>{K(!1),we(null),he(!0)},children:"🗑 Delete document"})]})]})]})]})]}),t.jsxs("nav",{className:"doc-tabs",children:[t.jsx("button",{className:`doc-tab${v==="document"?" active":""}`,onClick:()=>Ve("document"),children:"Document"}),Le>0&&t.jsx("button",{className:`doc-tab${$s?" active":""}`,onClick:()=>Ve("diff"),children:y?"Diff…":`Diff${it>0?` · ${it}`:""}`}),t.jsx("button",{className:`doc-tab${Rs?" active":""}`,onClick:()=>Ve("history"),children:X?"History…":`History${ct!==null?` · v${ct}`:""}`}),Le>0&&t.jsxs("button",{className:`doc-tab${v==="files"?" active":""}`,onClick:()=>Ve("files"),children:["Tracked files · ",Le]})]}),Ee&&t.jsx("div",{className:"pdf-error-banner",children:Ee}),v==="document"&&!q&&Ps&&Le>0&&t.jsxs("div",{className:"stale-banner",children:[t.jsx("span",{className:"stale-banner-icon",children:"⚠"}),t.jsxs("div",{className:"stale-banner-body",children:[t.jsx("span",{className:"stale-banner-text",children:it>0?`${it} of ${Le} tracked files changed since the snapshot taken on ${sn(Ds)}.`:`Tracked files changed since the snapshot taken on ${sn(Ds)}.`}),t.jsx("button",{className:"stale-banner-link",onClick:()=>Ve("diff"),children:"View diff"})]})]}),v==="files"&&n&&(o?t.jsx(hi,{report:o,trackedFiles:n.tracked_files,docId:n.id,onViewCode:$e}):t.jsx("div",{className:"doc-tab-loading",children:"Checking tracked files…"})),Rs&&n&&t.jsx(Si,{docId:n.id,project:u,entries:h??[],selectedVersion:p,onSelectVersion:async k=>{const _=await(await fetch(`/api/history-version/${xe(n.id)}/${k}?project=${encodeURIComponent(u)}`)).json();C(_??null)},markdownComponents:Bt}),$s&&(y&&R===null?t.jsx("div",{className:"doc-tab-loading",children:"Loading diff…"}):t.jsx(fi,{diffText:R??""})),v==="document"&&(q&&n?t.jsxs("div",{className:"doc-editor",children:[t.jsx("textarea",{ref:N,className:"doc-editor-textarea",value:V,onChange:k=>T(k.target.value),spellCheck:!1}),t.jsxs("div",{className:"doc-editor-actions",children:[be&&t.jsx("span",{className:"doc-editor-error",children:be}),t.jsxs("div",{className:"doc-editor-actions-right",children:[t.jsx("button",{ref:x,type:"button",className:"image-insert-trigger-btn",onClick:()=>te(k=>!k),title:"Insert image",children:"🖼 Image"}),He&&t.jsx(Pi,{project:u,triggerRef:x,onInsert:So,onClose:()=>te(!1)}),t.jsx("button",{type:"button",className:"save-btn",onClick:Eo,disabled:W,children:W?"Saving…":"✓ Save"})]})]})]}):t.jsx("div",{className:"doc-content",ref:po,children:jo}))]}),Ss&&n&&t.jsx(Li,{doc:n,isStale:Ps,report:o,toc:fe,activeHeadingId:ho,version:ct,onSelectHeading:fo,onSelectFile:$e,onClose:()=>Ut(!1),tab:mo,onTab:We,unreadComments:xo,comments:De.data?.publication?t.jsx(Mi,{data:De.data,locatedIds:new Set(me.keys()),activeId:zt,hoveredId:Ot,readOnly:j,onActivate:k=>{v!=="document"&&w("document"),vo(k)},onHover:rt},n.id):null}),pe&&n&&t.jsx("div",{className:"modal-overlay",onClick:()=>!Re&&he(!1),children:t.jsxs("div",{className:"modal-content delete-modal",onClick:k=>k.stopPropagation(),children:[t.jsxs("div",{className:"modal-header",children:[t.jsx("span",{className:"modal-title",children:"Delete documentation"}),t.jsx("button",{className:"modal-close-btn",onClick:()=>he(!1),disabled:Re,children:"✕"})]}),t.jsxs("div",{className:"modal-body",children:[t.jsxs("p",{className:"delete-modal-text",children:["Delete ",t.jsx("strong",{children:n.title})," (",t.jsx("code",{children:n.id}),") from project"," ",t.jsx("strong",{children:u}),"? This action cannot be undone from the interface."]}),Me&&t.jsx("span",{className:"doc-editor-error",children:Me}),t.jsxs("div",{className:"delete-modal-actions",children:[t.jsx("button",{type:"button",className:"copy-btn",onClick:()=>he(!1),disabled:Re,children:"Cancel"}),t.jsx("button",{type:"button",className:"delete-btn delete-btn--confirm",onClick:$o,disabled:Re,children:Re?"Deleting…":"🗑 Delete"})]})]})]})}),ot&&n&&t.jsx(Ri,{docId:n.id,project:u,filePath:ot,onClose:()=>$e(null)})]})}async function ks(e,s){const n=await fetch(e,s);let a=null;try{a=await n.json()}catch{}if(!n.ok)throw new Error(a?.error??`HTTP ${n.status}`);return a}function Wi(){return ks("/api/logs")}function Vi(e,s){const n=s?`?knownSize=${s.size}&knownMtime=${encodeURIComponent(s.mtime??"")}`:"";return ks(`/api/logs/${e}${n}`)}function qi(){return ks("/api/logs/open-folder",{method:"POST"})}const Gi=e=>`/api/logs/${e}/download`;function et(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(e<10*1024?1:0)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function ee(e){return e.toLocaleString("fr-FR")}function Za(e,s){return e.getFullYear()===s.getFullYear()&&e.getMonth()===s.getMonth()&&e.getDate()===s.getDate()}function It(e){return Za(new Date(e),new Date)}function eo(e){const s=new Date(e);if(Number.isNaN(s.getTime()))return e;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 Za(s,new Date)?a:`${n(s.getDate())}/${n(s.getMonth()+1)} ${a.slice(0,8)}`}function ft(e){return`${ee(e)} ms`}const to={hour:"Last hour",today:"Today",day:"Last 24 hours",week:"Last 7 days",all:"All loaded"};function so(e,s){if(s==="all")return!0;if(s==="today")return It(e);const n=Date.now()-new Date(e).getTime(),a=s==="hour"?36e5:s==="day"?864e5:7*864e5;return n<=a}const Ki=3e3;function no(e,s,n){i.useEffect(()=>{if(!s||(e(),!n))return;const a=setInterval(e,Ki);return()=>clearInterval(a)},[s,n,e])}function is(e,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 Vi(e,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}}},[e]);return no(h,s,n),{data:a,error:r,checkedAt:c}}function Ji(e){const[s,n]=i.useState(null),[a,o]=i.useState(null),r=i.useCallback(async()=>{try{n(await Wi()),o(null)}catch(l){o(l instanceof Error?l.message:String(l))}},[]);return no(r,!0,e),{directory:s,error:a}}function Yi(e=1e3){const[s,n]=i.useState(()=>Date.now());return i.useEffect(()=>{const a=setInterval(()=>n(Date.now()),e);return()=>clearInterval(a)},[e]),s}function Xi(){const{syncEnabled:e,readOnly:s,currentProject:n}=Y(),[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(()=>{!e||s||u()},[e,s,n,u]),!e||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(" · "),C=p>0?"!":h[0];return t.jsxs("div",{className:"sync-button-wrapper",children:[t.jsxs("button",{className:`rail-btn${p>0?" conflict":""}`,onClick:m,disabled:r,"data-tooltip":f,"aria-label":f,children:[t.jsx(Ct,{size:20,className:r?"spinning":void 0}),C&&t.jsx("span",{className:`rail-badge rail-badge--${p>0?"danger":"accent"}`,children:C})]}),c&&t.jsxs("div",{className:`sync-result${c.ok?"":" error"}`,children:[t.jsx("pre",{children:c.message}),t.jsx("button",{className:"sync-result-close",onClick:()=>d(null),title:"Fermer",children:"✕"})]})]})}function ke({icon:e,label:s,active:n,onClick:a,children:o}){return t.jsxs("button",{className:`rail-btn${n?" active":""}`,onClick:a,"data-tooltip":s,"aria-label":s,children:[t.jsx(e,{size:20}),o]})}function Qi({active:e,onSelect:s,onOpenSettings:n,onOpenProjectSettings:a}){const{docs:o,commentSummary:r,currentProject:l}=Y(),c=o.filter(h=>h.isStale).length,d=r.project===l?Object.values(r.docs).reduce((h,p)=>h+p.unread,0):0,u=is("github",!0,!0),m=i.useMemo(()=>(u.data?.entries??[]).filter(h=>It(h.ts)&&!h.ok).length,[u.data]);return t.jsxs("nav",{className:"nav-rail",children:[t.jsx("div",{className:"rail-logo",title:"MCP Documentor",children:t.jsx(kl,{size:18})}),t.jsx(Oa,{variant:"rail",onOpenSettings:a}),t.jsx("div",{className:"rail-sep"}),t.jsx(ke,{icon:Ll,label:"Documentation",active:e==="docs",onClick:()=>s("docs")}),t.jsx(ke,{icon:at,label:"Search ⌘K",active:e==="search",onClick:()=>s("search")}),t.jsx(ke,{icon:Pl,label:c>0?`Outdated · ${c}`:"Outdated",active:e==="outdated",onClick:()=>s("outdated"),children:c>0&&t.jsx("span",{className:"rail-badge rail-badge--warn",children:c})}),t.jsx(ke,{icon:Qn,label:"Recent",active:e==="recent",onClick:()=>s("recent")}),t.jsx(ke,{icon:Fl,label:"Export bundles",active:e==="exports",onClick:()=>s("exports")}),t.jsx(ke,{icon:Mt,label:d>0?`Publications · ${d} unread comments`:"Publications",active:e==="publications",onClick:()=>s("publications"),children:d>0&&t.jsx("span",{className:"rail-badge rail-badge--accent",children:d})}),t.jsx("div",{className:"rail-sep"}),t.jsx(ke,{icon:ka,label:m>0?`Logs · ${m} failed today`:"Logs",active:e==="logs",onClick:()=>s("logs"),children:m>0&&t.jsx("span",{className:"rail-dot"})}),t.jsx("div",{className:"rail-spacer"}),t.jsx(Xi,{}),t.jsx(ke,{icon:$a,label:"Settings",active:!1,onClick:n})]})}function Zi({onClose:e,onShowMigrationReport:s}){const{readOnly:n}=Y(),[a,o]=i.useState(!1),[r,l]=i.useState(""),[c,d]=i.useState(null),[u,m]=i.useState(""),[h,p]=i.useState(""),[f,C]=i.useState("text-embedding-3-small"),[j,g]=i.useState(100);i.useEffect(()=>{const w=localStorage.getItem("printScale");w&&g(Number(w)),Fa().then(R=>o(!!R)).catch(()=>{}),ni().then(R=>l(R.default??"")).catch(()=>{}),fetch("/api/config").then(R=>R.json()).then(R=>{R.dataDir&&m(R.dataDir),R.model&&C(R.model)}).catch(()=>{})},[]);const b=async(w,R)=>{await fetch("/api/configurations/apply",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:w,value:R})})},N=async()=>{d(null);try{const{path:w}=await ai(r);l(w??""),d({ok:!0,text:w?"Saved":"Removed"})}catch(w){d({ok:!1,text:w.message})}},x=()=>{localStorage.setItem("printScale",String(j))},v=async()=>{await b("MCP_DATA_DIR",u),h&&await b("MCP_DOCUMENTOR_OPENAI_API_KEY",h),await b("MCP_DOCUMENTOR_OPENAI_MODEL",f),e()};return t.jsx("div",{className:"settings-overlay",onClick:e,children:t.jsxs("div",{className:"settings-popover",onClick:w=>w.stopPropagation(),children:[t.jsx("h2",{className:"settings-title",children:"Settings"}),t.jsxs("div",{className:"settings-field",children:[t.jsx("label",{className:"settings-label",children:"Data Directory"}),t.jsx("input",{className:"settings-input",type:"text",value:u,onChange:w=>m(w.target.value),placeholder:"Leave empty for default"})]}),t.jsxs("div",{className:"settings-field",children:[t.jsx("label",{className:"settings-label",children:"OpenAI API Key"}),t.jsx("input",{className:"settings-input",type:"password",value:h,onChange:w=>p(w.target.value),placeholder:"sk-..."})]}),t.jsxs("div",{className:"settings-field",children:[t.jsx("label",{className:"settings-label",children:"Embedding Model"}),t.jsx("input",{className:"settings-input",type:"text",value:f,onChange:w=>C(w.target.value)})]}),t.jsxs("div",{className:"settings-field",children:[t.jsx("label",{className:"settings-label",children:"Print Scale (%)"}),t.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[t.jsx("input",{className:"settings-input",type:"number",min:30,max:150,value:j,onChange:w=>g(Number(w.target.value)),style:{width:"80px"}}),t.jsx("button",{className:"settings-save-btn",onClick:x,children:"Apply"})]})]}),t.jsxs("div",{className:"settings-field",children:[t.jsx("label",{className:"settings-label",children:"Default code root (this machine)"}),t.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[t.jsx("input",{className:"settings-input",type:"text",value:r,disabled:n,onChange:w=>l(w.target.value),placeholder:"Absolute path — used by projects without their own root"}),!n&&t.jsx("button",{className:"settings-save-btn",onClick:N,children:"Apply"})]}),c&&t.jsx("span",{className:`settings-hint${c.ok?"":" error"}`,children:c.text})]}),a&&t.jsxs("div",{className:"settings-field",children:[t.jsx("label",{className:"settings-label",children:"Code sources"}),t.jsx("button",{className:"settings-link-btn",onClick:s,children:"View the environment variables migration report"})]}),t.jsxs("div",{className:"settings-actions",children:[t.jsx("button",{className:"settings-cancel-btn",onClick:e,children:"Cancel"}),!n&&t.jsx("button",{className:"settings-save-btn",onClick:v,children:"Save"})]})]})})}function ec({value:e,onChange:s,options:n}){const[a,o]=i.useState(!1),[r,l]=i.useState(-1),c=i.useRef(null),d=i.useMemo(()=>{const h=e.trim().toLowerCase();return h?n.filter(p=>p.toLowerCase().includes(h)):n},[n,e]);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)},[e,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 t.jsxs("div",{className:"folder-combobox",ref:c,children:[t.jsx("input",{className:"settings-input",value:e,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}),t.jsx("button",{type:"button",className:"folder-combobox-toggle",onClick:()=>o(h=>!h),tabIndex:-1,"aria-label":"Toggle folder list",children:"▾"}),a&&t.jsxs("div",{className:"folder-combobox-menu",children:[t.jsx("div",{className:"folder-combobox-header",children:"Existing folders"}),d.length===0?t.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."}):t.jsx("ul",{className:"folder-combobox-list",children:d.map((h,p)=>t.jsx("li",{className:`folder-combobox-item${p===r?" active":""}`,onMouseDown:f=>{f.preventDefault(),u(h)},onMouseEnter:()=>l(p),children:h},h))})]})]})}function tc({onClose:e}){const s=re(),{currentProject:n,projects:a,docs:o}=Y(),[r,l]=i.useState(n),[c,d]=i.useState(""),[u,m]=i.useState(""),[h,p]=i.useState(""),[f,C]=i.useState(""),[j,g]=i.useState(!1),[b,N]=i.useState(null),[x,v]=i.useState(null),w=i.useMemo(()=>{const y=new Set;for(const $ of o)if($.folder){const L=$.folder.split("/").filter(Boolean);for(let S=1;S<=L.length;S++)y.add(L.slice(0,S).join("/"))}return Array.from(y).sort()},[o]);i.useEffect(()=>{if(r===n){v(null);return}let y=!1;return fetch(`/api/folders?project=${encodeURIComponent(r)}`).then($=>$.json()).then($=>{y||(Array.isArray($?.folders)?v($.folders):v([]))}).catch(()=>{y||v([])}),()=>{y=!0}},[r,n]);const R=r===n?w:x??[],E=async()=>{if(!c.trim()||!f.trim()){N("Title and content are required");return}g(!0),N(null);try{const y=h.split(",").map(S=>S.trim()).filter(Boolean),$=await fetch("/api/doc",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:c.trim(),content:f,folder:u.trim()||void 0,tags:y.length?y:void 0,project:r})}),L=await $.json();if(!$.ok||L.error)throw new Error(L.error||"Create failed");e(),L.id&&r===n&&s(ne(n,L.id))}catch(y){N(y instanceof Error?y.message:"Create failed")}finally{g(!1)}};return t.jsx("div",{className:"settings-overlay",onClick:e,children:t.jsxs("div",{className:"settings-popover create-doc-popover",onClick:y=>y.stopPropagation(),children:[t.jsx("h2",{className:"settings-title",children:"New document"}),t.jsxs("div",{className:"create-doc-grid",children:[t.jsxs("div",{className:"settings-field",children:[t.jsx("label",{className:"settings-label",children:"Project"}),t.jsx("select",{className:"settings-input",value:r,onChange:y=>l(y.target.value),children:a.map(y=>t.jsxs("option",{value:y,children:[y,y===n?" (current)":""]},y))})]}),t.jsxs("div",{className:"settings-field",children:[t.jsx("label",{className:"settings-label",children:"Title *"}),t.jsx("input",{className:"settings-input",value:c,onChange:y=>d(y.target.value)})]}),t.jsxs("div",{className:"settings-field",children:[t.jsx("label",{className:"settings-label",children:"Folder"}),t.jsx(ec,{value:u,onChange:m,options:R}),t.jsx("div",{className:"create-doc-hint",children:"Pick from the existing tree or type a new path to add a sub-folder."})]}),t.jsxs("div",{className:"settings-field",children:[t.jsx("label",{className:"settings-label",children:"Tags"}),t.jsx("input",{className:"settings-input",value:h,onChange:y=>p(y.target.value),placeholder:"comma, separated, tags"})]})]}),t.jsxs("div",{className:"settings-field create-doc-content-field",children:[t.jsx("label",{className:"settings-label",children:"Content *"}),t.jsx("textarea",{className:"doc-editor-textarea create-doc-textarea",value:f,onChange:y=>C(y.target.value),spellCheck:!1,placeholder:`# My new document
|
|
5
|
+
|
|
6
|
+
Write Markdown here…`})]}),t.jsxs("div",{className:"settings-actions",children:[b&&t.jsx("span",{className:"doc-editor-error",style:{marginRight:"auto"},children:b}),t.jsx("button",{className:"settings-cancel-btn",onClick:e,disabled:j,children:"Cancel"}),t.jsx("button",{className:"settings-save-btn",onClick:E,disabled:j,children:j?"Creating…":"Create"})]})]})})}const nn=400,sc=350,nc=300,ac=/^(https?:\/\/github\.com\/|git@github\.com:)?[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+(\.git)?(#.+)?$/i;function oc(e){const s=Math.max(0,(Date.now()-new Date(e).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 rc({project:e,onClose:s}){const{readOnly:n}=Y(),[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,C]=i.useState(""),[j,g]=i.useState({state:"idle"}),[b,N]=i.useState({state:"idle"}),[x,v]=i.useState({state:"loading"}),[w,R]=i.useState(!1),[E,y]=i.useState(null),$=i.useRef(null),[L,S]=i.useState(""),[I,z]=i.useState({state:"idle"}),[X,B]=i.useState(!1),[q,D]=i.useState(0);i.useEffect(()=>{let M=!1;return za().then(U=>{if(M)return;const G=U.find(K=>K.project===e)??{project:e};o(G),G.codeRootOrigin==="project"&&G.codeRoot&&d(G.codeRoot),G.config?.kind==="github"&&(l("github"),p(G.config.repo),C(G.config.branch??""))}).catch(U=>!M&&o({project:e,error:U.message})),oi().then(U=>!M&&v({state:"done",value:U})).catch(U=>!M&&v({state:"failed",error:U.message})),()=>{M=!0}},[e]),i.useEffect(()=>{const M=U=>{U.key==="Escape"&&s()};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[s]),i.useEffect(()=>{if(r!=="local"||c.trim()===""){m({state:"idle"});return}const M=new AbortController;m({state:"loading"});const U=setTimeout(()=>{si(c.trim(),M.signal).then(G=>m({state:"done",value:G})).catch(G=>{G.name!=="AbortError"&&m({state:"failed",error:G.message})})},nn);return()=>{clearTimeout(U),M.abort()}},[r,c]),i.useEffect(()=>{const M=L.trim();if(M.replace("/","").length<2){z({state:"idle"});return}const U=new AbortController;z({state:"loading"});const G=setTimeout(()=>{Ql(M,U.signal).then(K=>{z({state:"done",value:K}),D(0)}).catch(K=>{K.name!=="AbortError"&&z({state:"failed",error:K.message})})},sc);return()=>{clearTimeout(G),U.abort()}},[L]);const V=X&&!(I.state==="done"&&I.value.some(M=>M.fullName.toLowerCase()===h.trim().toLowerCase()));i.useEffect(()=>{if(V)return;if(r!=="github"||!ac.test(h.trim())){g({state:"idle"}),$.current=null;return}const M=$.current;if(M&&M.repo===h&&M.branch===f)return;const U=new AbortController;g({state:"loading"});const G=setTimeout(()=>{Zl(h.trim(),f||void 0,U.signal).then(K=>{g({state:"done",value:K});const fe=K.ok&&!f?K.branch:f;$.current={repo:h,branch:fe},fe!==f&&C(fe)}).catch(K=>{K.name!=="AbortError"&&g({state:"failed",error:K.message})})},nn);return()=>{clearTimeout(G),U.abort()}},[r,h,f,V]);const T=c.trim()===""||u.state==="done"&&u.value.ok,W=i.useMemo(()=>r==="local"?T?{kind:"local"}:null:j.state!=="done"||!j.value.ok?null:{kind:"github",repo:j.value.repo.fullName,branch:j.value.branch},[r,j,T]),J=r==="local"?c.trim():void 0,be=W?JSON.stringify([W,J]):null;i.useEffect(()=>{if(!W){N({state:"idle"});return}const M=new AbortController;N({state:"loading"});const U=setTimeout(()=>{ei(e,W,J,M.signal).then(G=>N({state:"done",value:G})).catch(G=>{G.name!=="AbortError"&&N({state:"failed",error:G.message})})},nc);return()=>{clearTimeout(U),M.abort()}},[e,be]);const ue=M=>{p(M),C(""),S(M),B(!0)},Ue=M=>{p(M),C(""),S(""),B(!1)},ye=I.state==="done"?I.value:[],Ee=X&&I.state!=="idle",Ne=M=>{Ee&&(M.key==="ArrowDown"?(M.preventDefault(),D(U=>Math.min(ye.length-1,U+1))):M.key==="ArrowUp"?(M.preventDefault(),D(U=>Math.max(0,U-1))):M.key==="Enter"&&ye[q]?(M.preventDefault(),Ue(ye[q].fullName)):M.key==="Escape"&&(M.stopPropagation(),B(!1)))},ot=async()=>{if(W){R(!0),y(null);try{await ti(e,W,J),s()}catch(M){y(M.message),R(!1)}}},$e=a?.defaultCodeRoot??(a?.codeRootOrigin==="default"?a.codeRoot:void 0),He=u.state==="failed"?u.error:u.state==="done"&&!u.value.ok?u.value.error:null,te=j.state==="done"?j.value:null,pe=te?.repo,he=te?.branches??[],Re=j.state==="failed"?j.error:te&&!te.ok&&te.field==="repo"?te.error:null,Pe=Ee?null:Re,Me=te&&!te.ok&&te.field==="branch"?te.error:null,we=f&&!he.includes(f)?[f,...he]:he;return t.jsx("div",{className:"modal-overlay",onClick:s,children:t.jsxs("div",{className:"project-settings",onClick:M=>M.stopPropagation(),role:"dialog","aria-label":"Project settings",children:[t.jsxs("header",{className:"ps-header",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"ps-title",children:"Project settings"}),t.jsxs("div",{className:"ps-subtitle",children:[t.jsx(ca,{size:13}),e]})]}),t.jsx("button",{className:"ps-close",onClick:s,title:"Close (Esc)",children:t.jsx(pn,{size:18})})]}),t.jsxs("div",{className:"ps-body",children:[a?.error&&!a.config&&t.jsxs("div",{className:"ps-alert error",children:[t.jsx(Rl,{size:14}),t.jsxs("span",{children:["The saved settings cannot be read: ",a.error,". Applying replaces them."]})]}),t.jsx("div",{className:"ps-section-label",children:"Where is the code read from?"}),t.jsxs("div",{className:"ps-modes",role:"radiogroup",children:[t.jsxs("button",{className:`ps-mode${r==="local"?" selected":""}`,role:"radio","aria-checked":r==="local",disabled:n,onClick:()=>l("local"),children:[t.jsx(ys,{size:16,className:"ps-mode-icon"}),t.jsxs("span",{className:"ps-mode-text",children:[t.jsx("span",{className:"ps-mode-title",children:"Local working copy"}),t.jsx("span",{className:"ps-mode-desc",children:"Current checkout, uncommitted work included"})]}),r==="local"&&t.jsx(Xe,{size:16,className:"ps-mode-check"})]}),t.jsxs("button",{className:`ps-mode${r==="github"?" selected":""}`,role:"radio","aria-checked":r==="github",disabled:n,onClick:()=>l("github"),children:[t.jsx(bs,{size:16,className:"ps-mode-icon"}),t.jsxs("span",{className:"ps-mode-text",children:[t.jsx("span",{className:"ps-mode-title",children:"GitHub repository"}),t.jsx("span",{className:"ps-mode-desc",children:"Published code of one branch"})]}),r==="github"&&t.jsx(Xe,{size:16,className:"ps-mode-check"})]})]}),r==="local"&&t.jsxs("label",{className:"ps-field",children:[t.jsx("span",{className:"ps-label",children:"Code root on this machine"}),t.jsxs("span",{className:`ps-input-wrap${He?" invalid":""}`,children:[t.jsx(Tt,{size:14,className:"ps-input-icon"}),t.jsx("input",{className:"ps-input",value:c,placeholder:$e?`Machine default: ${$e}`:"Absolute path of the repository",autoFocus:!0,disabled:n,onChange:M=>d(M.target.value)}),u.state==="loading"&&t.jsx(Jt,{size:14,className:"ps-input-status spinning"}),u.state==="done"&&u.value.ok&&t.jsx(Xe,{size:14,className:"ps-input-status ok"}),!n&&c!==""&&t.jsx("button",{type:"button",className:"ps-link muted ps-input-action",onClick:()=>d(""),children:"Use default"})]}),He?t.jsx("span",{className:"ps-help error",children:He}):c.trim()!==""?u.state==="done"?t.jsx("span",{className:"ps-help ok",children:"Folder found · used by this project only, on this machine"}):t.jsx("span",{className:"ps-help",children:"Checked as you type."}):$e?t.jsx("span",{className:"ps-help",children:"Uses the machine default. Stored on this machine only, never synced."}):t.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"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"ps-field",children:[t.jsx("label",{className:"ps-label",htmlFor:"ps-repo-input",children:"Repository"}),t.jsxs("div",{className:"ps-combobox",children:[t.jsxs("span",{className:`ps-input-wrap${Pe?" invalid":""}`,children:[pe?t.jsx(wt,{size:14,className:"ps-input-icon"}):t.jsx(at,{size:14,className:"ps-input-icon"}),t.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":Ee,"aria-controls":"ps-repo-suggestions",onChange:M=>ue(M.target.value),onKeyDown:Ne,onFocus:()=>B(!0),onBlur:()=>B(!1)}),(j.state==="loading"||I.state==="loading")&&t.jsx(Jt,{size:14,className:"ps-input-status spinning"}),j.state!=="loading"&&I.state!=="loading"&&pe&&!Pe&&t.jsx(Xe,{size:14,className:"ps-input-status ok"})]}),Ee&&t.jsxs("ul",{className:"ps-suggestions",id:"ps-repo-suggestions",role:"listbox",children:[I.state==="loading"&&t.jsx("li",{className:"ps-suggestion-note",children:"Searching…"}),I.state==="failed"&&t.jsx("li",{className:"ps-suggestion-note error",children:I.error}),I.state==="done"&&ye.length===0&&t.jsx("li",{className:"ps-suggestion-note",children:"No repository found"}),ye.map((M,U)=>t.jsxs("li",{role:"option","aria-selected":U===q,className:`ps-suggestion${U===q?" highlighted":""}`,onMouseEnter:()=>D(U),onMouseDown:G=>{G.preventDefault(),Ue(M.fullName)},children:[t.jsxs("span",{className:"ps-suggestion-name",children:[M.private?t.jsx(zl,{size:12}):t.jsx(wt,{size:12}),M.fullName]}),M.description&&t.jsx("span",{className:"ps-suggestion-desc",children:M.description})]},M.fullName))]})]}),Pe?t.jsx("span",{className:"ps-help error",children:Pe}):pe?t.jsxs("span",{className:"ps-help ok",children:["Found · ",pe.private?"private":"public"," · default branch ",pe.defaultBranch]}):t.jsxs("span",{className:"ps-help",children:["Searched as you type",x.state==="done"&&x.value.configured?", private repositories included":"","."]})]}),t.jsxs("label",{className:"ps-field",children:[t.jsx("span",{className:"ps-label",children:"Branch"}),t.jsxs("span",{className:`ps-input-wrap${Me?" invalid":""}`,children:[t.jsx(Tl,{size:14,className:"ps-input-icon"}),t.jsxs("select",{className:"ps-input ps-select",value:f,disabled:n||we.length===0,onChange:M=>C(M.target.value),children:[we.length===0&&t.jsx("option",{value:"",children:"—"}),we.map(M=>t.jsxs("option",{value:M,children:[M,M===pe?.defaultBranch?" (default)":""]},M))]}),f&&f===pe?.defaultBranch&&t.jsx("span",{className:"ps-chip",children:"default"})]}),Me?t.jsx("span",{className:"ps-help error",children:Me}):te?.ok?t.jsxs("span",{className:"ps-help",children:["Head ",te.head.sha.slice(0,7)," · ",te.head.message," · ",oc(te.head.date)]}):null]}),t.jsxs("div",{className:"ps-field",children:[t.jsx("span",{className:"ps-label",children:"GitHub access"}),t.jsxs("span",{className:"ps-token",children:[t.jsx(_l,{size:14,className:`ps-token-icon${x.state==="done"&&x.value.login?" ok":x.state==="done"&&x.value.error?" error":""}`}),t.jsxs("span",{className:"ps-token-text",children:[x.state==="loading"&&"Checking the token…",x.state==="failed"&&x.error,x.state==="done"&&(x.value.configured?x.value.login?`${x.value.variable} · connected as ${x.value.login}`:`${x.value.variable} rejected — ${x.value.error}`:`${x.value.variable} is not set · public repositories only`)]})]}),t.jsx("span",{className:"ps-help",children:"Set in the MCP server's environment variables only — not editable here."})]})]}),b.state!=="idle"&&t.jsxs("div",{className:`ps-preview${b.state==="failed"||b.state==="done"&&b.value.sourceError?" error":""}`,children:[b.state==="loading"?t.jsx(Jt,{size:16,className:"ps-preview-icon spinning"}):t.jsx(Ul,{size:16,className:"ps-preview-icon"}),t.jsxs("div",{className:"ps-preview-text",children:[b.state==="loading"&&t.jsx("span",{className:"ps-preview-title",children:"Checking the docs against this source…"}),b.state==="failed"&&t.jsx("span",{className:"ps-preview-title",children:b.error}),b.state==="done"&&t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"ps-preview-title",children:["Checked against ",b.value.label," — ",b.value.docs," doc",b.value.docs===1?"":"s"]}),t.jsx("span",{className:"ps-preview-counts",children:b.value.sourceError?b.value.sourceError:[`${b.value.upToDate} up to date`,`${b.value.stale} would be outdated`,`${b.value.unverifiable} unverifiable`,...b.value.broken>0?[`${b.value.broken} with broken tracking`]:[]].join(" · ")})]})]})]})]}),t.jsxs("footer",{className:"ps-footer",children:[t.jsxs("div",{className:"ps-footer-note",children:[t.jsx(Al,{size:14}),t.jsxs("span",{children:["Source saved with the docs, shared across machines.",t.jsx("br",{}),"Applied at once — no restart."]})]}),E&&t.jsx("span",{className:"ps-help error ps-save-error",children:E}),t.jsx("button",{className:"ps-btn",onClick:s,children:"Cancel"}),!n&&t.jsx("button",{className:"ps-btn primary",onClick:ot,disabled:!W||w,children:w?"Applying…":"Apply"})]})]})})}function lc({entry:e}){return e.status!=="imported"?t.jsx(Ns,{size:14,className:"mig-icon warn"}):e.kind==="code-root"?t.jsx(Tt,{size:14,className:"mig-icon"}):e.kind==="local"?t.jsx(ys,{size:14,className:"mig-icon"}):t.jsx(bs,{size:14,className:"mig-icon accent"})}function ic({onClose:e,onReviewProject:s}){const[n,a]=i.useState(null),[o,r]=i.useState(null),[l,c]=i.useState(!1);i.useEffect(()=>{Fa().then(a).catch(h=>r(h.message))},[]);const d=h=>{ri().catch(()=>{}).finally(()=>{e(),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 t.jsx("div",{className:"modal-overlay",onClick:()=>d(),children:t.jsxs("div",{className:"migration-report",onClick:h=>h.stopPropagation(),role:"dialog","aria-label":"Code source settings imported",children:[t.jsxs("header",{className:"mig-header",children:[t.jsx("span",{className:"mig-badge",children:t.jsx(Il,{size:18})}),t.jsxs("div",{children:[t.jsx("h2",{className:"mig-title",children:"Code source settings imported"}),t.jsx("p",{className:"mig-subtitle",children:"Found in this server's environment. They now live in each project's settings."})]})]}),o&&t.jsx("div",{className:"ps-alert error mig-error",children:o}),n&&t.jsxs(t.Fragment,{children:[n.entries.length>0&&t.jsxs("table",{className:"mig-table",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{children:"Project"}),t.jsx("th",{children:"Now configured as"}),t.jsx("th",{children:"From"})]})}),t.jsx("tbody",{children:n.entries.map((h,p)=>t.jsxs("tr",{className:h.status!=="imported"?"not-imported":void 0,children:[t.jsx("td",{className:h.project?void 0:"mig-scope",children:h.project??"This machine"}),t.jsx("td",{children:t.jsxs("span",{className:"mig-source",children:[t.jsx(lc,{entry:h}),h.detail]})}),t.jsx("td",{className:"mig-from",children:h.from})]},p))})]}),t.jsxs("div",{className:"mig-callout",children:[t.jsxs("div",{className:"mig-callout-text",children:[t.jsx("span",{className:"mig-callout-title",children:"These variables are no longer read"}),t.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."}),t.jsx("pre",{className:"mig-vars",children:n.variables.join(`
|
|
8
|
+
`)})]}),t.jsx("button",{className:"mig-copy",onClick:u,title:"Copy the list",children:l?t.jsx(Se,{size:14}):t.jsx(Lt,{size:14})})]})]}),t.jsxs("footer",{className:"mig-footer",children:[t.jsx("span",{className:"mig-footer-note",children:"This report stays in Settings."}),m&&t.jsx("button",{className:"ps-btn",onClick:()=>d(()=>s(m)),children:"Review project settings"}),t.jsx("button",{className:"ps-btn primary",onClick:()=>d(),children:"Done"})]})]})})}function cs({tone:e,children:s,wide:n}){return t.jsx("span",{className:`logs-badge logs-badge--${e}${n?" logs-badge--wide":""}`,children:s})}function ao({source:e,title:s,meta:n,following:a,onToggleFollow:o}){const[r,l]=i.useState(null),c=async()=>{l(null);try{await qi()}catch(d){l(d instanceof Error?d.message:String(d))}};return t.jsxs("div",{className:"logs-page-header",children:[t.jsxs("div",{className:"logs-page-heading",children:[t.jsxs("div",{className:"logs-breadcrumb",children:["Logs / ",s]}),t.jsx("h2",{className:"logs-title",children:s}),t.jsx("div",{className:"logs-file-meta",children:n}),r&&t.jsx("div",{className:"logs-inline-error",children:r})]}),t.jsxs("div",{className:"logs-actions",children:[t.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:[t.jsx("span",{className:"logs-live-dot"}),a?"Following":"Paused"]}),t.jsxs("button",{className:"logs-btn",onClick:c,title:"Open the log directory on the server machine",children:[t.jsx(Tt,{size:14}),"Open folder"]}),t.jsxs("a",{className:"logs-btn",href:Gi(e),download:!0,title:"Download the whole file",children:[t.jsx(Dl,{size:14}),"Download"]})]})]})}function oo({value:e,onChange:s,placeholder:n}){return t.jsxs("label",{className:"logs-search",children:[t.jsx(at,{size:14}),t.jsx("input",{value:e,onChange:a=>s(a.target.value),placeholder:n,spellCheck:!1})]})}function ro({options:e,value:s,onChange:n}){return t.jsx("div",{className:"logs-segmented",role:"tablist",children:e.map(a=>t.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,t.jsx("span",{className:"logs-segment-count",children:a.count.toLocaleString("fr-FR")})]},a.value))})}function tt({value:e,onChange:s,options:n,prefix:a,withClock:o,width:r}){const l=n.find(c=>c.value===e)?.label??e;return t.jsxs("label",{className:"logs-select",style:{width:r},children:[o&&t.jsx(Qn,{size:14}),t.jsxs("span",{className:"logs-select-value",children:[a?`${a}: `:"",l]}),t.jsx(Dt,{size:12}),t.jsx("select",{value:e,onChange:c=>s(c.target.value),children:n.map(c=>t.jsx("option",{value:c.value,children:c.label},c.value))})]})}function cc(e,s){if(e===null)return"not loaded yet";const n=Math.max(0,Math.round((s-e)/1e3));return n<60?`updated ${n} s ago`:`updated ${Math.round(n/60)} min ago`}function lo({following:e,text:s,checkedAt:n,error:a}){const o=Yi();return t.jsxs("div",{className:"logs-status",children:[t.jsx("span",{className:`logs-live-dot${e?"":" paused"}`}),a?t.jsx("span",{className:"logs-status-error",children:a}):t.jsxs("span",{children:[s," · ",cc(n,o)]}),t.jsx("span",{className:"logs-status-order",children:"Newest at the bottom"})]})}function io({contentKey:e,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)},[e]);const r=()=>{const l=a.current;l&&(o.current=l.scrollHeight-l.scrollTop-l.clientHeight<40)};return t.jsx("div",{className:s,ref:a,onScroll:r,children:n})}const dc=["today","day","week","all"];function uc(e){return e.ok?"ok":e.status==="404"||e.status==="422"?"warn":"error"}function hc(e){return e.status==="ok"?"OK":e.status==="rejected"?"Rejected":e.status==="failed"?"Failed":e.status==="network error"?"Network":e.status}function mc(e){return i.useMemo(()=>{const s=e.filter(c=>It(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=[...e].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}},[e])}function pc(e){const s=`GET /repos/${e.repo}/`;return!e.repo||!e.command.startsWith(s)?e.command:`GET /repos/…/${e.command.slice(s.length)}`}function fc({data:e,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,C]=i.useState("today"),[j,g]=i.useState(new Set),[b,N]=i.useState(null),x=i.useMemo(()=>e?.entries??[],[e]),v=mc(x),w=i.useMemo(()=>[...new Set(x.map(D=>D.trigger))].sort((D,V)=>D.localeCompare(V)),[x]),R=i.useMemo(()=>{const D=r.trim().toLowerCase();return x.filter(V=>so(V.ts,f)&&(u==="all"||u==="ok"===V.ok)&&(h==="all"||V.trigger===h)&&(!D||V.action.toLowerCase().includes(D)||V.command.toLowerCase().includes(D)||(V.repo??"").toLowerCase().includes(D)||(V.error??"").toLowerCase().includes(D)))},[x,r,f,u,h]),E=i.useMemo(()=>c==="all"?R:R.filter(D=>D.kind===c),[R,c]),y=E.slice(-1e3),$=`${e?.file.size}:${y.length}:${c}:${u}:${h}:${f}:${r}`,L=D=>g(V=>{const T=new Set(V);return T.has(D)?T.delete(D):T.add(D),T}),S=async(D,V)=>{try{await navigator.clipboard.writeText(D.raw),N(V),setTimeout(()=>N(T=>T===V?null:T),1500)}catch{}},I=e?.file,z=I?I.exists?`${I.path} · ${et(I.size)} · one line per call to GitHub`:`${I.path} · no call to GitHub recorded yet`:"Loading…",X=`${a?"Following new calls":"Paused"} · ${ee(E.length)} of ${ee(x.length)} calls match`+(E.length>y.length?` · showing the latest ${ee(y.length)}`:"")+(e?.unreadable?` · ${e.unreadable} unreadable`:""),B=v.rate,q=B?.reset?new Date(B.reset):null;return t.jsxs("div",{className:"logs-panel",children:[t.jsx(ao,{source:"github",title:"GitHub access",meta:z,following:a,onToggleFollow:o}),t.jsxs("div",{className:"logs-stats",children:[t.jsxs("div",{className:"logs-stat",children:[t.jsx("div",{className:"logs-stat-label",children:"Calls today"}),t.jsxs("div",{className:"logs-stat-row",children:[t.jsx("span",{className:"logs-stat-value",children:ee(v.total)}),t.jsxs("span",{className:"logs-stat-detail",children:[ee(v.git)," git · ",ee(v.api)," REST API"]})]})]}),t.jsxs("div",{className:"logs-stat",children:[t.jsx("div",{className:"logs-stat-label",children:"Failed"}),t.jsxs("div",{className:"logs-stat-row",children:[t.jsx("span",{className:`logs-stat-value${v.failed?" error":""}`,children:ee(v.failed)}),t.jsx("span",{className:"logs-stat-detail",children:v.failed?v.failureSummary:"no failure today"})]})]}),t.jsxs("div",{className:"logs-stat",children:[t.jsx("div",{className:"logs-stat-label",children:"Average duration"}),t.jsxs("div",{className:"logs-stat-row",children:[t.jsx("span",{className:"logs-stat-value",children:v.average===null?"—":ft(v.average)}),v.slowest&&t.jsxs("span",{className:"logs-stat-detail",title:v.slowest.command,children:["slowest: ",v.slowest.kind==="git"?v.slowest.command.split(" ").slice(0,2).join(" "):v.slowest.action," ",ft(v.slowest.durationMs)]})]})]}),t.jsxs("div",{className:"logs-stat",children:[t.jsxs("div",{className:"logs-stat-label",children:["API rate limit",q&&t.jsxs("span",{className:"logs-stat-aside",children:["resets ",q.toLocaleTimeString("fr-FR",{hour:"2-digit",minute:"2-digit"})]})]}),B?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"logs-stat-value small",children:[ee(B.remaining)," / ",ee(B.limit)]}),t.jsx("div",{className:"logs-gauge",children:t.jsx("div",{className:`logs-gauge-fill${B.remaining/B.limit<.1?" low":""}`,style:{width:`${Math.max(0,Math.min(100,B.remaining/B.limit*100))}%`}})})]}):t.jsxs("div",{className:"logs-stat-row",children:[t.jsx("span",{className:"logs-stat-value small",children:"—"}),t.jsx("span",{className:"logs-stat-detail",children:"known after the next API call"})]})]})]}),t.jsxs("div",{className:"logs-toolbar",children:[t.jsx(oo,{value:r,onChange:l,placeholder:"Filter by command, path, repository…"}),t.jsx(ro,{value:c,onChange:d,options:[{value:"all",label:"All",count:R.length},{value:"git",label:"Git",count:R.filter(D=>D.kind==="git").length,tone:"git"},{value:"api",label:"REST API",count:R.filter(D=>D.kind==="api").length,tone:"info"}]}),t.jsx("div",{className:"logs-toolbar-spacer"}),t.jsx(tt,{value:u,onChange:m,prefix:"Status",width:130,options:[{value:"all",label:"all"},{value:"ok",label:"succeeded"},{value:"failed",label:"failed"}]}),t.jsx(tt,{value:h,onChange:p,prefix:"Triggered by",width:200,options:[{value:"all",label:"all"},...w.map(D=>({value:D,label:D}))]}),t.jsx(tt,{value:f,onChange:C,withClock:!0,width:150,options:dc.map(D=>({value:D,label:to[D]}))})]}),t.jsxs("div",{className:"logs-table",children:[t.jsxs("div",{className:"logs-table-head logs-github-grid",children:[t.jsx("span",{children:"Time"}),t.jsx("span",{children:"Kind"}),t.jsx("span",{children:"What was done"}),t.jsx("span",{children:"Repository"}),t.jsx("span",{children:"Triggered by"}),t.jsx("span",{children:"Status"}),t.jsx("span",{className:"align-right",children:"Duration"})]}),t.jsxs(io,{className:"logs-table-body",contentKey:$,children:[y.length===0&&t.jsx("div",{className:"logs-empty",children:e?x.length?"No call matches these filters.":"No call to GitHub recorded yet.":s?"":"Loading…"}),y.map((D,V)=>{const T=`${D.ts}|${E.length-y.length+V}`,W=j.has(T),J=uc(D);return t.jsxs("div",{className:`logs-row logs-row--tall${W?` open logs-row--${J==="ok"?"info":J}`:""}`,children:[t.jsxs("button",{className:"logs-row-line logs-github-grid",onClick:()=>L(T),title:D.ts,children:[t.jsx("span",{className:"logs-cell-time",children:eo(D.ts)}),t.jsx("span",{children:t.jsx(cs,{tone:D.kind==="git"?"git":"info",children:D.kind==="git"?"GIT":"API"})}),t.jsxs("span",{className:"logs-cell-what",children:[t.jsx("span",{className:"logs-cell-action",children:D.action}),t.jsx("span",{className:"logs-cell-command",title:D.command,children:pc(D)})]}),t.jsx("span",{className:`logs-cell-repo${D.repo?"":" muted"}`,children:D.repo??"—"}),t.jsx("span",{className:"logs-cell-trigger",children:D.trigger}),t.jsx("span",{children:t.jsx(cs,{tone:J,wide:!0,children:hc(D)})}),t.jsx("span",{className:"logs-cell-duration",children:ft(D.durationMs)}),W?t.jsx(Vn,{size:12,className:"logs-row-chevron"}):t.jsx(Dt,{size:12,className:"logs-row-chevron hover-only"})]}),W&&t.jsxs("div",{className:"logs-row-detail logs-detail--github",children:[t.jsxs("div",{className:"logs-detail-main",children:[t.jsx("div",{className:"logs-detail-text",children:D.ok?`Completed in ${ft(D.durationMs)}.`:D.error??"Failed without an error message."}),t.jsx("pre",{className:"logs-detail-context",children:[`time ${D.ts}`,`command ${D.command}`,`trigger ${D.trigger}`,...D.rateLimit?[`quota ${ee(D.rateLimit.remaining)} / ${ee(D.rateLimit.limit)} requests left`]:[]].join(`
|
|
9
|
+
`)})]}),t.jsxs("button",{className:"logs-btn logs-btn--small",onClick:()=>S(D,T),children:[b===T?t.jsx(Se,{size:12}):t.jsx(Lt,{size:12}),b===T?"Copied":"Copy log line"]})]})]},T)})]})]}),t.jsx(lo,{following:a,text:X,checkedAt:n,error:s})]})}const es={DEBUG:"neutral",INFO:"info",WARN:"warn",ERROR:"error"},gc=["DEBUG","INFO","WARN","ERROR"],xc=["hour","day","week","all"],vc="GitHub";function jc({data:e,error:s,checkedAt:n,following:a,onToggleFollow:o}){const r=re(),[l,c]=i.useState(""),[d,u]=i.useState("all"),[m,h]=i.useState("all"),[p,f]=i.useState("day"),[C,j]=i.useState(new Set),g=i.useMemo(()=>e?.entries??[],[e]),b=i.useMemo(()=>[...new Set(g.map(S=>S.scope))].sort((S,I)=>S.localeCompare(I)),[g]),N=i.useMemo(()=>{const S=l.trim().toLowerCase();return g.filter(I=>(m==="all"||I.scope===m)&&so(I.ts,p)&&(!S||I.message.toLowerCase().includes(S)||I.scope.toLowerCase().includes(S)||I.continuation.some(z=>z.toLowerCase().includes(S))))},[g,l,m,p]),x=i.useMemo(()=>{const S={DEBUG:0,INFO:0,WARN:0,ERROR:0};for(const I of N)S[I.level]++;return S},[N]),v=i.useMemo(()=>d==="all"?N:N.filter(S=>S.level===d),[N,d]),w=v.slice(-1500),R=`${e?.file.size}:${w.length}:${d}:${m}:${p}:${l}`,E=S=>j(I=>{const z=new Set(I);return z.has(S)?z.delete(S):z.add(S),z}),y=e?.file,$=y?y.exists?`${y.path} · ${et(y.size)} · ${e.partial?`last ${ee(g.length)} lines`:`${ee(g.length)} lines`}`:`${y.path} · not written yet`:"Loading…",L=`${a?"Following new lines":"Paused"} · ${ee(v.length)} of ${ee(g.length)} lines match`+(v.length>w.length?` · showing the latest ${ee(w.length)}`:"")+(e?.unreadable?` · ${e.unreadable} unreadable`:"");return t.jsxs("div",{className:"logs-panel",children:[t.jsx(ao,{source:"server",title:"Full log",meta:$,following:a,onToggleFollow:o}),t.jsxs("div",{className:"logs-toolbar",children:[t.jsx(oo,{value:l,onChange:c,placeholder:"Filter messages, tools, paths…"}),t.jsx(ro,{value:d,onChange:u,options:[{value:"all",label:"All",count:N.length},...gc.map(S=>({value:S,label:S[0]+S.slice(1).toLowerCase(),count:x[S],tone:es[S]}))]}),t.jsx("div",{className:"logs-toolbar-spacer"}),t.jsx(tt,{value:m,onChange:h,prefix:"Source",width:150,options:[{value:"all",label:"all"},...b.map(S=>({value:S,label:S}))]}),t.jsx(tt,{value:p,onChange:f,withClock:!0,width:150,options:xc.map(S=>({value:S,label:to[S]}))})]}),t.jsxs("div",{className:"logs-table",children:[t.jsxs("div",{className:"logs-table-head logs-server-grid",children:[t.jsx("span",{children:"Time"}),t.jsx("span",{children:"Level"}),t.jsx("span",{children:"Source"}),t.jsx("span",{children:"Message"})]}),t.jsxs(io,{className:"logs-table-body",contentKey:R,children:[w.length===0&&t.jsx("div",{className:"logs-empty",children:e?"No line matches these filters.":s?"":"Loading…"}),w.map((S,I)=>{const z=`${S.ts}|${S.pid}|${v.length-w.length+I}`,X=C.has(z),B=S.scope===vc;return t.jsxs("div",{className:`logs-row${X?` open logs-row--${es[S.level]}`:""}`,children:[t.jsxs("button",{className:"logs-row-line logs-server-grid",onClick:()=>E(z),title:S.ts,children:[t.jsx("span",{className:"logs-cell-time",children:eo(S.ts)}),t.jsx("span",{children:t.jsx(cs,{tone:es[S.level],children:S.level})}),t.jsx("span",{className:`logs-cell-scope${B?" github":""}`,children:S.scope}),t.jsxs("span",{className:`logs-cell-message logs-level-text--${S.level.toLowerCase()}`,children:[S.message,S.continuation.length>0&&!X&&t.jsxs("span",{className:"logs-more",children:[" +",S.continuation.length," lines"]})]}),X?t.jsx(Vn,{size:12,className:"logs-row-chevron"}):t.jsx(Dt,{size:12,className:"logs-row-chevron hover-only"})]}),X&&t.jsxs("div",{className:"logs-row-detail logs-detail--server",children:[t.jsx("pre",{className:"logs-detail-context",children:[`time ${S.ts}`,`process ${S.process} · PID ${S.pid}`,`scope ${S.scope}`,"",S.message,...S.continuation].join(`
|
|
10
|
+
`)}),B&&t.jsxs("button",{className:"logs-link",onClick:()=>r(kt("github")),children:[t.jsx(wt,{size:12}),"Open in GitHub log"]})]})]},z)})]})]}),t.jsx(lo,{following:a,text:L,checkedAt:n,error:s})]})}function bc({source:e}){const s=re(),[n,a]=i.useState(!0),o=()=>a(p=>!p),{directory:r}=Ji(n),l=is("server",e==="server",n),c=is("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=>It(f.ts));return{calls:p.length,failed:p.filter(f=>!f.ok).length}},[c.data]),m=d.get("server"),h=d.get("github");return t.jsxs("div",{className:"logs-view",children:[t.jsxs("aside",{className:"logs-sidebar",children:[t.jsx("div",{className:"logs-sidebar-label",children:"Server"}),t.jsxs("button",{className:`logs-source${e==="server"?" active":""}`,onClick:()=>s(kt("server")),children:[t.jsx(ka,{size:16,className:"logs-source-icon"}),t.jsxs("span",{className:"logs-source-text",children:[t.jsx("span",{className:"logs-source-title",children:"Full log"}),t.jsxs("span",{className:"logs-source-sub",children:["server.log · ",m?et(m.size):"…"," · every event"]})]}),e==="server"&&n&&t.jsx("span",{className:"logs-live-dot",title:"Following"})]}),t.jsx("div",{className:"logs-sidebar-label",children:"Specific logs"}),t.jsxs("button",{className:`logs-source${e==="github"?" active":""}`,onClick:()=>s(kt("github")),children:[t.jsx(wt,{size:16,className:"logs-source-icon"}),t.jsxs("span",{className:"logs-source-text",children:[t.jsx("span",{className:"logs-source-title",children:"GitHub access"}),t.jsxs("span",{className:"logs-source-sub",children:["github.log · ",ee(u.calls)," call",u.calls===1?"":"s"," today"]})]}),u.failed>0&&t.jsxs("span",{className:"logs-source-badge",children:[u.failed," failed"]}),e==="github"&&n&&u.failed===0&&t.jsx("span",{className:"logs-live-dot",title:"Following"})]}),t.jsxs("div",{className:"logs-sidebar-footer",children:[t.jsx("div",{className:"logs-sidebar-label",children:"Log directory"}),t.jsx("div",{className:"logs-dir",title:r?.dir,children:r?.dir??"…"}),t.jsxs("div",{className:"logs-dir-sizes",children:["server.log ",m?et(m.size):"—"," · github.log"," ",h?.exists?et(h.size):"not written yet"]})]})]}),t.jsx("main",{className:"logs-main",children:e==="server"?t.jsx(jc,{...l,following:n,onToggleFollow:o}):t.jsx(fc,{...c,following:n,onToggleFollow:o})})]})}function yc(){const{currentProject:e,readOnly:s}=Y(),{publications:n,error:a,reload:o}=Ja(e),[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 t.jsxs("div",{className:"pubs-view",children:[t.jsxs("header",{className:"pubs-header",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"pubs-title",children:"Publications"}),t.jsx("div",{className:"pubs-subtitle",children:n===null?"Loading…":`${c.length} document${c.length===1?"":"s"} published in ${e}`+(d>0?` · ${d} changed since published`:"")})]}),t.jsxs("div",{className:"pubs-filter",role:"tablist",children:[t.jsxs("button",{className:r==="all"?"active":"",onClick:()=>l("all"),children:["All · ",c.length]}),t.jsxs("button",{className:r==="modified"?"active":"",onClick:()=>l("modified"),children:["Changed · ",d]})]})]}),a&&t.jsx("div",{className:"publish-error pubs-load-error",children:a}),n!==null&&c.length===0&&t.jsxs("div",{className:"pubs-empty",children:[t.jsx(Mt,{size:28}),t.jsxs("div",{children:["No published document in ",e,"."]}),t.jsx("div",{className:"pubs-empty-hint",children:"Publish one from the toolbar of the document."})]}),c.length>0&&t.jsxs("div",{className:"pubs-table",children:[t.jsxs("div",{className:"pubs-row pubs-row--head",children:[t.jsx("span",{children:"Document"}),t.jsx("span",{children:"Version note"}),t.jsx("span",{children:"Published"}),t.jsx("span",{children:"State"}),t.jsx("span",{})]}),m.map(h=>t.jsx(wc,{publication:h,readOnly:s,onChanged:o},h.id)),m.length===0&&t.jsx("div",{className:"pubs-row-empty",children:"No publication changed since it was published."})]})]})}function Nc({publication:e}){return e.status==="missing"?t.jsx("span",{className:"pubs-badge pubs-badge--missing",children:"Document removed"}):e.status==="modified"?t.jsxs("span",{className:"pubs-badge pubs-badge--modified",children:["Changed · ",Te(e.version)," → ",Te(e.currentVersion)]}):t.jsxs("span",{className:"pubs-badge pubs-badge--current",children:["Up to date · ",Te(e.version)]})}function wc({publication:e,readOnly:s,onChanged:n}){const a=re(),{copied:o,copy:r}=Ka(),[l,c]=i.useState("idle"),[d,u]=i.useState(""),[m,h]=i.useState(!1),[p,f]=i.useState(null),C=hn(e.token),j=e.docId.includes("/")?e.docId.slice(0,e.docId.lastIndexOf("/")):"",g=async b=>{h(!0),f(null);try{await b(),c("idle"),u(""),n()}catch(N){f(N instanceof Error?N.message:String(N))}finally{h(!1)}};return t.jsxs("div",{className:`pubs-row-wrap${l!=="idle"?" pubs-row-wrap--active":""}`,children:[t.jsxs("div",{className:"pubs-row",children:[t.jsxs("span",{className:"pubs-doc",children:[t.jsx(oa,{size:14,className:"pubs-doc-icon"}),t.jsxs("span",{className:"pubs-doc-text",children:[e.status==="missing"?t.jsx("span",{className:"pubs-doc-title pubs-doc-title--missing",children:e.title}):t.jsx("button",{className:"pubs-doc-title",onClick:()=>a(ne(e.project,e.docId)),title:"Open the document",children:e.title}),t.jsx("span",{className:"pubs-doc-folder",children:j||"root"})]})]}),t.jsx("span",{className:`pubs-note${e.note?"":" pubs-note--empty"}`,title:e.note||void 0,children:e.note||"—"}),t.jsx("span",{className:"pubs-date",children:us(e.publishedAt)}),t.jsx("span",{children:t.jsx(Nc,{publication:e})}),t.jsxs("span",{className:"pubs-actions",children:[!s&&e.status==="modified"&&t.jsxs("button",{className:`pubs-update-btn${l==="update"?" active":""}`,onClick:()=>c(l==="update"?"idle":"update"),children:[t.jsx(Ct,{size:14}),"Update"]}),t.jsx("button",{className:"publish-icon-btn",onClick:()=>r(C),title:"Copy the link",children:o?t.jsx(Se,{size:14}):t.jsx(Lt,{size:14})}),t.jsx("a",{className:"publish-icon-btn",href:C,target:"_blank",rel:"noopener noreferrer",title:"Open the public page",children:t.jsx(na,{size:14})}),!s&&t.jsx("button",{className:`publish-icon-btn publish-icon-btn--danger${l==="unpublish"?" active":""}`,onClick:()=>c(l==="unpublish"?"idle":"unpublish"),title:"Unpublish",children:t.jsx(ws,{size:14})})]})]}),l==="update"&&t.jsxs("div",{className:"pubs-row-panel",children:[t.jsxs("label",{className:"publish-field pubs-row-panel-field",children:[t.jsxs("span",{className:"publish-field-label",children:["Note for the new version ",t.jsx("span",{className:"publish-field-optional",children:"(optional)"})]}),t.jsx("input",{className:"publish-input",value:d,maxLength:ts,placeholder:"e.g. Added the Entry points section",onChange:b=>u(b.target.value),autoFocus:!0})]}),t.jsxs("div",{className:"publish-actions",children:[t.jsx("button",{className:"btn-secondary",onClick:()=>c("idle"),disabled:m,children:"Cancel"}),t.jsxs("button",{className:"btn-primary",onClick:()=>g(()=>gn(e.id,d)),disabled:m,children:[t.jsx(Ct,{size:14}),m?"Updating…":"Update publication"]})]})]}),l==="unpublish"&&t.jsx("div",{className:"pubs-row-panel",children:t.jsx(Qa,{title:e.title,busy:m,onCancel:()=>c("idle"),onConfirm:()=>g(()=>fn(e.id))})}),p&&t.jsx("div",{className:"publish-error pubs-row-error",children:p})]})}const co="mcp-documentor.panelWidth",St=264,Cc=200,kc=520,uo=e=>Math.min(kc,Math.max(Cc,Math.round(e)));function Sc(){try{const e=Number(localStorage.getItem(co));return e?uo(e):St}catch{return St}}function an(e){try{localStorage.setItem(co,String(e))}catch{}}function Ec(){const[e,s]=i.useState(Sc),[n,a]=i.useState(!1);return{width:e,resizing:n,startResize:l=>{l.preventDefault();const c=l.clientX,d=e;let u=d;a(!0);const m=p=>{u=uo(d+p.clientX-c),s(u)},h=()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",h),a(!1),an(u)};window.addEventListener("pointermove",m),window.addEventListener("pointerup",h)},resetWidth:()=>{s(St),an(St)}}}function $c(){const{codeSourceMigrationPending:e,setCodeSourceMigrationPending:s,currentProject:n,selectedDocId:a}=Y(),o=ce(),r=re(),l=Ta(o.pathname),c=Cs(o.pathname),d=l!==null||c,[u,m]=i.useState(!1),[h,p]=i.useState(!1),[f,C]=i.useState("docs"),[j,g]=i.useState(!0),b=Ec(),[N,x]=i.useState(0),[v,w]=i.useState(null),[R,E]=i.useState(!1),y=R||e,$=()=>{d&&r(ne(n,a))};i.useEffect(()=>{const I=z=>{(z.metaKey||z.ctrlKey)&&z.key.toLowerCase()==="k"&&(z.preventDefault(),d&&r(ne(n,a)),C("search"),g(!0),x(X=>X+1))};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[d,r,n,a]);const L=I=>{if(I==="logs"){l||r(kt("server"));return}if(I==="publications"){c||r(La);return}if(!d&&I===f){g(z=>!z);return}$(),C(I),g(!0)},S=l?"logs":c?"publications":j?f:null;return t.jsxs("div",{className:"dashboard",children:[t.jsx(Qi,{active:S,onSelect:L,onOpenSettings:()=>m(!u),onOpenProjectSettings:w}),h&&t.jsx(tc,{onClose:()=>p(!1)}),u&&t.jsx(Zi,{onClose:()=>m(!1),onShowMigrationReport:()=>{m(!1),E(!0)}}),v&&t.jsx(rc,{project:v,onClose:()=>w(null)}),y&&t.jsx(ic,{onClose:()=>{E(!1),s(!1)},onReviewProject:w}),l?t.jsx(bc,{source:l}):c?t.jsx(yc,{}):t.jsxs("div",{className:"dashboard-body",children:[t.jsxs("div",{className:`nav-panel-wrapper${j?"":" collapsed"}${b.resizing?" resizing":""}`,style:{"--panel-width":`${b.width}px`},children:[t.jsx(ui,{mode:f,searchFocusToken:N,onCreateDoc:()=>p(!0),onOpenProjectSettings:w,onClose:()=>g(!1)}),j&&t.jsx("div",{className:"nav-panel-resizer",onPointerDown:b.startResize,onDoubleClick:b.resetWidth,title:"Drag to resize · double-click to reset"})]}),t.jsx(Bi,{})]})]})}const gt="[mcp-documentor]",Rc=3e3;async function on(e){const s=await fetch(e);if(!s.ok)throw new Error(`${e} answered HTTP ${s.status}: ${await s.text()}`);return s.json()}const Pc=()=>{const e=Y(),s=i.useRef(e);s.current=e,i.useEffect(()=>{let n=null,a,o=!1;const r=u=>{_a(u).then(m=>{s.current.currentProject===u&&s.current.setDocs(m)})},l=u=>{if(u.type==="INITIAL_STATE")console.info(`${gt} Received INITIAL_STATE from server`),s.current.applyInitialState(u.data);else if(u.type==="CONFIG_UPDATED")console.info(`${gt} Received CONFIG_UPDATED from server`);else if(u.type==="BUNDLES_UPDATED")console.info(`${gt} 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():u.type==="COMMENTS_CHANGED"&&u.data?.project===s.current.currentProject&&s.current.bumpCommentsVersion()},c=async u=>{const m=await on("/api/initial-state");o||(s.current.applyInitialState(m),u&&(s.current.bumpCodeSourcesVersion(),s.current.bumpPublicationsVersion(),s.current.bumpCommentsVersion(),r(s.current.currentProject)))},d=async()=>{try{const u=n?`?since=${n.seq}&epoch=${encodeURIComponent(n.epoch)}`:"",m=await on(`/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(`${gt} Polling /api/changes failed: ${u instanceof Error?u.message:String(u)}`)}o||(a=setTimeout(d,Rc))};return d(),()=>{o=!0,clearTimeout(a)}},[])};function rn(e){return Ta(e)!==null||Cs(e)}function Dc(){const e=ce(),s=re(),{hasReceivedInitialState:n,projects:a,setCurrentProject:o,setDocs:r,setSelectedDocId:l,setSelectedDoc:c}=Y();i.useEffect(()=>{if(!n||rn(e.pathname))return;const{project:m}=Ws(e.pathname);if(m)return;const h=qs(),p=(h&&a.includes(h)?h:a[0])??"default";s(ne(p,null),{replace:!0})},[n,a,e.pathname,s]),i.useEffect(()=>{if(!n||!Cs(e.pathname))return;const m=qs();o((m&&a.includes(m)?m:a[0])??"default")},[n,a,e.pathname]);const{project:d,docId:u}=rn(e.pathname)?{project:null,docId:null}:Ws(e.pathname);i.useEffect(()=>{if(!d)return;let m=!1;return o(d),Kl(d),(async()=>{const h=await _a(d);m||r(h)})(),()=>{m=!0}},[d]),i.useEffect(()=>{d&&(l(u),u===null&&c(null))},[d,u])}function Lc(){return Pc(),Dc(),Ai(),Lr([{path:"*",element:t.jsx($c,{})}])}function Tc(){return t.jsx(fl,{children:t.jsx(Lc,{})})}qo.createRoot(document.getElementById("root")).render(t.jsx(i.StrictMode,{children:t.jsx(Tc,{})}));
|