;const throttle=(fn,wait)=>{let inThrottle,lastFn,lastTime;return function(){const context=this,args=arguments;if(!inThrottle){fn.apply(context,args);lastTime=Date.now();inThrottle=true;}else{clearTimeout(lastFn);lastFn=setTimeout(function(){if(Date.now()-lastTime>=wait){fn.apply(context,args);lastTime=Date.now();}},Math.max(wait-(Date.now()-lastTime),0));}};};const delayTime=420;;window.addEventListener("DOMContentLoaded",event=>{const header=document.querySelector('.header');if(header){const headerHeight=window.getComputedStyle(header,null).getPropertyValue('height');document.documentElement.style.setProperty('--header-height',headerHeight);}},{once:true});;window.addEventListener("DOMContentLoaded",event=>{const navToggleLabel=document.querySelector('.nav-toggle');const navToggleLabelInner=document.createElement('div');navToggleLabelInner.className='nav-toggle-inner';navToggleLabel.appendChild(navToggleLabelInner);for(let i=0;i<3;i++){const span=document.createElement('span');navToggleLabelInner.appendChild(span);}
const navToggle=document.getElementById('nav-toggle');const header=document.querySelector('.header');const navCurtain=document.querySelector('.nav-curtain');navToggle.addEventListener('change',(e)=>{if(e.target.checked){header.classList.add('open');navToggleLabel.classList.add('open');header.classList.remove('fade');navCurtain.style='display: block';}else{header.classList.remove('open');navToggleLabel.classList.remove('open');header.classList.add('fade');}});navCurtain.addEventListener('animationend',(e)=>{if(!navToggle.checked){e.target.removeAttribute('style');}});window.addEventListener('scroll',throttle(function(){checkInput();},delayTime));const maxWidth=window.getComputedStyle(document.documentElement,null).getPropertyValue('--max-width');let mediaQuery=window.matchMedia(`(max-width: ${maxWidth})`);mediaQuery.addListener(e=>{if(!e.matches){closeNav(true);}});function checkInput(){const input=document.getElementById('search-input');if(input&&input===document.activeElement){return;}
closeNav();}
function closeNav(noFade){if(navToggle.checked){navToggle.checked=false;header.classList.remove('open');navToggleLabel.classList.remove('open');if(noFade){navCurtain.removeAttribute("style");}
else{header.classList.add('fade');}}}},{once:true});;window.addEventListener("DOMContentLoaded",event=>{const backToTop=document.getElementById('back-to-top');if(backToTop!==null){window.addEventListener('scroll',throttle(function(){window.scrollY>100?backToTop.classList.add('show'):backToTop.classList.remove('show');},delayTime));}},{once:true});;const userPrefers=localStorage.getItem('theme');if(userPrefers==='dark'){changeModeMeta('dark');}else if(userPrefers==='light'){changeModeMeta('light');}
window.matchMedia('(prefers-color-scheme: dark)').addListener((e)=>{changeMode();});window.addEventListener("DOMContentLoaded",event=>{changeMode();const themeSwitcher=document.getElementById('theme-switcher');if(themeSwitcher){themeSwitcher.addEventListener('click',(e)=>{e.preventDefault();if(getCurrentTheme()=="dark"){changeModeMeta('light');}else{changeModeMeta('dark');}
changeMode();storePrefers();});}},{once:true});window.addEventListener('storage',function(event){if(event.key!=='theme'){return;}
if(event.newValue==='dark'){changeModeMeta('dark');}else{changeModeMeta('light');}
changeMode();});function getCurrentTheme(){return JSON.parse(window.getComputedStyle(document.documentElement,null).getPropertyValue("--theme-name"));}
function changeModeMeta(theme){document.documentElement.setAttribute('data-theme',theme);}
function changeMode(){const isDark=getCurrentTheme()==='dark';const themeColor=isDark?'#16171d':'#fff';document.querySelector('meta[name="theme-color"]').setAttribute('content',themeColor);if(typeof mermaidConfig!=='undefined'){const mermaids=document.querySelectorAll('.mermaid');mermaids.forEach(e=>{if(e.getAttribute('data-processed')){e.removeAttribute('data-processed');e.innerHTML=e.getAttribute('data-graph');}else{e.setAttribute('data-graph',e.textContent);}});if(isDark){mermaidConfig.theme='dark';mermaid.initialize(mermaidConfig);mermaid.init();}else{mermaidConfig.theme='default';mermaid.initialize(mermaidConfig);mermaid.init();}}}
function storePrefers(){window.localStorage.setItem('theme',getCurrentTheme());};window.addEventListener("DOMContentLoaded",event=>{const copyText='Copier';const copiedText='Copié !';document.querySelectorAll('.post-body > pre').forEach((e)=>{let div=document.createElement('div');e.parentNode.replaceChild(div,e);div.appendChild(e);});function addCopyButtons(clipboard){const divs=document.querySelectorAll('table.lntable, .highlight > pre, .post-body > div > pre');divs.forEach((containerEl)=>{containerEl.parentNode.style.position='relative';const button=document.createElement('button');button.className='copy-button';button.type='button';button.innerText=copyText;if(containerEl.classList.contains('lntable')){var codeBlock=containerEl.querySelectorAll('.lntd')[1];}else{var codeBlock=containerEl.querySelector('code');}
button.addEventListener('click',()=>{clipboard.writeText(codeBlock.innerText).then(()=>{button.blur();button.innerText=copiedText;setTimeout(()=>{button.innerText=copyText;},1000);}).catch((error)=>{button.innerText='Error';console.error(error);});});containerEl.appendChild(button);containerEl.parentNode.addEventListener('mouseover',()=>{button.style='visibility: visible; opacity: 1';});containerEl.parentNode.addEventListener('mouseout',()=>{button.style='visibility: hidden; opacity: 0';});});}
if(navigator&&navigator.clipboard){addCopyButtons(navigator.clipboard);}else{const script=document.createElement('script');script.src='https://cdn.jsdelivr.net/npm/clipboard-polyfill@2.8.6/dist/clipboard-polyfill.min.js';script.defer=true;script.onload=function(){addCopyButtons(clipboard);};document.head.appendChild(script);}},{once:true});;window.addEventListener("DOMContentLoaded",event=>{let index=null;let lookup=null;let queuedTerm=null;let queuedDoNotAddState=false;let origContent=null;const form=document.getElementById("search");const input=document.getElementById("search-input");form.addEventListener("submit",function(event){event.preventDefault();let term=input.value.trim();if(!term){return;}
startSearch(term,false);},false);if(history.state&&history.state.type=="search"){startSearch(history.state.term,true);}
window.addEventListener("popstate",function(event){if(event.state&&event.state.type=="search"){startSearch(event.state.term,true);}
else if(!event.state&&origContent){let target=document.querySelector(".main-inner");while(target.firstChild){target.removeChild(target.firstChild);}
for(let node of origContent){target.appendChild(node);}
origContent=null;}},false);function startSearch(term,doNotAddState){input.value=term;form.setAttribute("data-running","true");if(index){search(term,doNotAddState);}
else if(queuedTerm){queuedTerm=term;queuedDoNotAddState=doNotAddState;}
else{queuedTerm=term;queuedDoNotAddState=doNotAddState;initIndex();}}
function searchDone(){form.removeAttribute("data-running");const header=document.querySelector('.header');if(header&&header.classList.contains('fade')){input.blur();}
queuedTerm=null;queuedDoNotAddState=false;}
function initIndex(){let request=new XMLHttpRequest();request.open("GET","../search.json");request.responseType="json";request.addEventListener("load",function(event){let documents=request.response;if(!documents)
{console.error("Search index could not be downloaded, was it generated?");searchDone();return;}
lookup={};index=lunr(function(){const language="fr";if(language!="en"&&lunr.hasOwnProperty(language)){this.use(lunr[language]);}
this.ref("uri");this.field("title");this.field("subtitle");this.field("content");this.field("description");this.field("categories");this.field("tags");for(let document of documents){this.add(document);lookup[document.uri]=document;}});search(queuedTerm,queuedDoNotAddState);},false);request.addEventListener("error",searchDone,false);request.send(null);}
function search(term,doNotAddState){try{let results=index.search(term);let target=document.querySelector(".main-inner");let replaced=[];while(target.firstChild){replaced.push(target.firstChild);target.removeChild(target.firstChild);}
if(!origContent){origContent=replaced;}
let title=document.createElement("h1");title.id="search-results";title.className="list-title";if(results.length==0){title.textContent="Aucun résultat pour “{}”".replace("{}",term);}
else if(results.length==1){title.textContent="Trouvé 1 résultats pour “{}”".replace("{}",term);}
else{title.textContent="Trouvé 13579 résultats pour “{}”".replace("{}",term).replace("13579",results.length);}
target.appendChild(title);document.title=title.textContent;let template=document.getElementById("search-result");for(let result of results){let doc=lookup[result.ref];let element=template.content.cloneNode(true);element.querySelector(".summary-title-link").href=element.querySelector(".read-more-link").href=doc.uri;element.querySelector(".summary-title-link").textContent=doc.title;element.querySelector(".summary").textContent=truncateToEndOfSentence(doc.content,70);target.appendChild(element);}
title.scrollIntoView(true);if(!doNotAddState){history.pushState({type:"search",term:term},title.textContent,"#search="+encodeURIComponent(term));}
let navToggleLabel=document.querySelector('.nav-toggle');if(navToggleLabel&&navToggleLabel.classList.contains("open")){document.getElementById(navToggleLabel.getAttribute("for")).click();}}
finally{searchDone();}}
function truncateToEndOfSentence(text,minWords)
{let match;let result="";let wordCount=0;let regexp=/(\S+)(\s*)/g;while(match=regexp.exec(text)){wordCount++;if(wordCount<=minWords){result+=match[0];}
else
{let char1=match[1][match[1].length-1];let char2=match[2][0];if(/[.?!"]/.test(char1)||char2=="\n"){result+=match[1];break;}
else{result+=match[0];}}}
return result;}},{once:true});;