1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/chunks/CommentMarkdownEditor-WOJH_Tkk.js","js/chunks/react-CIdOxwLC.js","js/chunks/hydrateServerComponents-B9oKa6Kw.js","js/chunks/userPrefs-CmKfdyBa.js","css/hydrateServerComponents-D-xFXgU7.css","js/chunks/TextInput-gxADkvDF.js","css/TextInput-B7FXM384.css","css/CommentMarkdownEditor-axZFA-ep.css","js/chunks/ComposerTools-B6yHEtHk.js"])))=>i.map(i=>d[i]); 2import{r as m,j as i}from"./react-CIdOxwLC.js";import{aK as Lt,aL as Pt,aM as Dt,aN as Mt,a as fe,aO as se,aP as ie,aQ as Pe,e as F,aB as Ee,aR as Tt,p as $t,I as ne,i as at,j as lt,k as ct,l as ut,aH as At,n as dt,o as mt,C as Ge,aS as Ot,aT as Ft,b as Ne,W as _e,T as be,aU as Ht,aV as It,aW as Bt,aX as zt,aY as Qt,aZ as qt,a_ as Vt,a$ as Gt,b0 as Ut}from"./hydrateServerComponents-B9oKa6Kw.js";import{h as Se}from"./htmlText-DEssuVVd.js";import{t as je,p as Wt,f as Ue}from"./relativeTime-C033wpEl.js";import{A as Kt}from"./Avatar-DK9eK5kd.js";import{_ as ft}from"./userPrefs-CmKfdyBa.js";var Zt=class extends Lt{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type="infinite",super.setOptions(e)}getOptimisticResult(e){return e._type="infinite",super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){var x,N;const{state:n}=e,s=super.createResult(e,t),{isFetching:o,isRefetching:r,isError:a,isRefetchError:l}=s,c=(N=(x=n.fetchMeta)==null?void 0:x.fetchMore)==null?void 0:N.direction,u=a&&c==="forward",d=o&&c==="forward",p=a&&c==="backward",f=o&&c==="backward";return{...s,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Dt(t,n.data),hasPreviousPage:Pt(t,n.data),isFetchNextPageError:u,isFetchingNextPage:d,isFetchPreviousPageError:p,isFetchingPreviousPage:f,isRefetchError:l&&!u&&!p,isRefetching:r&&!d&&!f}}};function Xt(e,t){return Mt(e,Zt)}const pe=({postType:e,postId:t})=>`/${e}/${t}/comments`;function Jt(e,{sort:t="best",page:n=1,perPage:s=30}={}){const o=new URLSearchParams({sort:t,page:String(n),perPage:String(s)});return fe(`${pe(e)}?${o.toString()}`)}function Yt(e,t,n=0){return fe(pe(e),{method:"POST",body:{content:t,parentId:n}})}function en(e,t,n){return fe(`${pe(e)}/${t}`,{method:"PATCH",body:{content:n}})}function pt(e,t,n=!1){return fe(`${pe(e)}/${t}`,{method:"DELETE",keepalive:n})}function ht(e,t,n,s=!1){return fe(`${pe(e)}/${t}/moderation`,{method:"POST",body:{action:n},keepalive:s})}const tn=3e4;function nn(e,t,n,s=!1){const o=n&&n.sort===t?n:void 0,r=o==null?void 0:o.perPage;return Xt({queryKey:se(e,t),queryFn:({pageParam:a})=>Jt(e,{sort:t,page:a,perPage:r}),initialPageParam:1,getNextPageParam:a=>a.page*a.perPage<a.total?a.page+1:void 0,initialData:o?{pages:[o],pageParams:[1]}:void 0,staleTime:3e4,refetchInterval:s?tn:!1})}const Ce=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),sn=e=>/^(https?:\/\/|\/)/i.test(e.trim()),We=e=>e.replace(new RegExp("(\\*\\*|__)(?=\\S)([\\s\\S]+?)(?<=\\S)\\1","g"),"<strong>$2</strong>").replace(new RegExp("~~(?=\\S)([\\s\\S]+?)(?<=\\S)~~","g"),"<s>$1</s>").replace(new RegExp("(\\*|_)(?=\\S)([\\s\\S]+?)(?<=\\S)\\1","g"),"<em>$2</em>");function Ke(e){const t=[],n=o=>`\0${t.push(o)-1}\0`,s=e.replace(/\[([^\]]+)\]\(([^)\s]+)\)|https?:\/\/[^\s<]+/g,(o,r,a)=>{if(r!==void 0&&a!==void 0)return sn(a)?n(`<a href="${Ce(a)}" rel="ugc nofollow noopener" target="_blank">${We(r)}</a>`):o;const l=o.replace(/[.,;:!?)]+$/,"");return n(`<a href="${l}" rel="ugc nofollow noopener" target="_blank">${l}</a>`)+o.slice(l.length)});return We(s).replace(/\u0000(\d+)\u0000/g,(o,r)=>t[Number(r)])}const on=/(?:\\|[ \t]{2,})$/,rn=/^[ \t]*[-*+][ \t]+(.*)$/,an=/^[ \t]*\d+[.)][ \t]+(.*)$/;function ln(e){const t=e.replace(/\r\n?/g,` 3`).split(` 4`),n=[];let s=[],o=null;const r=()=>{if(s.length===0)return;const l=s.map(c=>Ce(c.replace(on,""))).join(` 5`);n.push(`<p>${Ke(l).replace(/\n/g,"<br>")}</p>`),s=[]},a=()=>
5{if(!o)return;const l=o.ordered?"ol":"ul",c=o.items.map(u=>`<li>${Ke(Ce(u))}</li>`).join("");n.push(`<${l}>${c}</${l}>`),o=null};for(const l of t){const c=l.match(rn),u=l.match(an);if(c||u){r();const d=!!u;o&&o.ordered!==d&&a(),o??(o={ordered:d,items:[]}),o.items.push((u??c)[1]);continue}if(a(),l.trim()===""){r();continue}s.push(l)}return r(),a(),n.join("")||"<p></p>"}const cn=4e3,un=m.createContext(cn),gt=ln,dn="Envoi impossible. Votre commentaire est de retour dans le champ, réessayez.";function Ze(e){var s;if(!(e instanceof Ee)||e.status!==429)return dn;const t=Math.ceil(Number((s=e.details)==null?void 0:s.retry_after));return`Vous publiez trop vite. Votre commentaire est de retour dans le champ, réessayez dans ${Number.isFinite(t)&&t>0?`${t} seconde${t>1?"s":""}`:"quelques instants"}.`}function mn(e){var t;if(e instanceof Ee&&e.status===403)switch((t=e.details)==null?void 0:t.reason){case"edit_window_closed":return"Le délai pour modifier ce commentaire est écoulé.";case"not_comment_author":return"Vous ne pouvez modifier que vos propres commentaires."}return e instanceof Ee&&e.status===404?"Ce commentaire n'existe plus.":"La modification n'a pas pu être enregistrée."}function De(e,t){const n=ie(),s=m.useContext(un),o=se(e,t);return()=>{setTimeout(()=>{n.invalidateQueries({queryKey:o}).then(()=>Tt(e,t,n.getQueryData(o)))},s)}}function de(e,t){return{...e,pages:e.pages.map(t)}}function fn(e,t,n){const s=ie(),o=De(e,t),r=se(e,t),a=(c,u)=>{const d=s.getQueryData(r);d&&s.setQueryData(r,de(d,p=>({...p,comments:p.comments.map(f=>f.id===c?u(f):{...f,replies:f.replies.map(h=>h.id===c?u(h):h)})})))},l=(c,u)=>{const d=s.getQueryData(r);d&&s.setQueryData(r,de(d,(p,f)=>({...p,total:u&&f===0?Math.max(0,p.total-1):p.total,comments:p.comments.filter(h=>h.id!==c).map(h=>({...h,replies:h.replies.filter(x=>x.id!==c)}))})))};return Pe({mutationFn:({content:c,parentId:u})=>Yt(e,c,u),onMutate:async({content:c,parentId:u,html:d})=>{await s.cancelQueries({queryKey:r});const p=s.getQueryData(r);if(!p)return{optimisticId:void 0};const f=-Date.now(),h={id:f,postType:e.postType,postId:e.postId,authorName:"Vous",parentId:u,threadRootId:u,depth:u>0?1:0,contentHtml:d||gt(c),contentMarkdown:c,status:"pending",score:0,replyCount:0,source:"native",createdAt:new Date().toISOString(),isMine:!0,replies:[],delivery:"sending"};return s.setQueryData(r,de(p,(x,N)=>u===0?N===0?{...x,total:x.total+1,comments:[h,...x.comments]}:x:{...x,comments:x.comments.map(w=>w.id===u||w.replies.some(j=>j.id===u)?{...w,replies:[...w.replies,h]}:w)})),n==null||n(f),{optimisticId:f}},onError:(c,u,d)=>{(d==null?void 0:d.optimisticId)!==void 0&&l(d.optimisticId,u.parentId===0)},onSuccess:(c,u,d)=>{if((d==null?void 0:d.optimisticId)===void 0){o();return}c!=null&&c.comment_id&&pn(s,r,d.optimisticId,c.comment_id);const p=(c==null?void 0:c.comment_id)||d.optimisticId;p!==d.optimisticId&&(n==null||n(p)),a(p,({delivery:f,...h})=>({...h,contentHtml:(c==null?void 0:c.content_html)||h.contentHtml})),o()}})}function pn(e,t,n,s){if(n===void 0)return;const o=e.getQueryData(t);o&&e.setQueryData(t,de(o,r=>({...r,comments:r.comments.map(a=>a.id===n?{...a,id:s,threadRootId:s}:a.replies.some(l=>l.id===n)?{...a,replies:a.replies.map(l=>l.id===n?{...l,id:s}:l)}:a)})))}function ye(e,t,n,s=0){var c;const o=e.pages.some(u=>u.comments.some(d=>d.id===t)),r=((c=Me(e,t))==null?void 0:c.status)==="deleted",l=o&&s!==0&&(s===-1?!r:r)?s:0;return de(e,(u,d)=>({...u,total:l!==0&&d===0?Math.max(0,u.total+l):u.total,comments:u.comments.map(p=>p.id===t?{...p,...n(p)}:{...p,replies:p.replies.map(f=>f.id===t?n(f):f)})}))}function xt(e,t,n,s,o=0,r,a){const l=ie(),c=De(e,t),u=se(e,t);return Pe({mutationFn:n,onMutate:async d=>{await l.cancelQueries({queryKey:u});const p=l.getQueryData(u),f=o===-1?wt:ye;return p&&l.setQueryData(u,f(p,d.commentId,s(d),o)),{previous:p}},onError:(d,p,f)=>{f!=null&&f.previous&&l.setQueryData(u,f.previous),a&&F.error(typeof a=="function"?a(d):a)},onSuccess:(d,p)=>{const f=r==null?void 0:r(d);if(f){const h=l.getQueryData(u);h&&l.setQueryData(u,ye(h,p.commentId,f))}c()}})}function hn(e,t){return xt(e,t,({commentId:n,content:s})=>en(e,n,s??""),({content:n,html:s})=>o=>({...o,contentHtml:s||gt(n??""),contentMarkdown:n??o.contentMarkdown,status:o.status==="published"||o.status==="pending"?"pending":o.status,editedAt:new Date().toISOString()}),0,n=>n.content_html?s=>({...s,contentHtml:n.content_html}):null,mn)}const bt=e=>({...e,status:"deleted",contentHtml:"",score:0,viewerVote:null});function me(e,t){const n=e.pages.flatMap(r=>r.comments).find(r=>r.id===t||r.replies.some(a=>a.id===t));if(n===void 0)return[t];const s=[t];let o=[t];for(;o.length>0;){const r=n.replies.filter(a=>o.includes(a.parentId)&&!s.includes(a.id));r.forEach(a=>s.push(a.id)),o=r.map(a=>a.id)}return s}function wt(e,t,n,s){return me(e,t).reduce((o,r)=>ye(o,r,n,r===t?s:0),e)}function gn(e,t){return xt(e,t,({commentId:n})=>pt(e,n),()=>bt,-1,void 0,"La suppression nâa pas abouti, le commentaire est toujours en ligne.")}const _t=5e3,yt=3e4;function Me(e,t){for(const n of e.pages)for(const s of n.comments){if(s.id===t)return s;const o=s.replies.find(r=>r.id===t);if(o)return o}}function xn(e,t){const n=ie(),s=se(e,t),o=gn(e,t),r=m.useRef(new Set).current;return m.useEffect(()=>{const a=()=>{r.forEach(l=>{pt(e,l,!0).catch(()=>{})}),r.clear()};return window.addEventListener("pagehide",a),()=>{window.removeEventListener("pagehide",a),a()}},[]),a=>{if(r.has(a))return;const l=n.getQueryData(s),c=l?me(l,a).map(f=>Me(l,f)).filter(f=>f!==void 0):[];
5l&&n.setQueryData(s,wt(l,a,bt,-1)),r.add(a);const u=()=>{const f=n.getQueryData(s);!f||c.length===0||n.setQueryData(s,c.reduce((h,x)=>ye(h,x.id,()=>x,x.id===a?1:0),f))},d=()=>{r.delete(a)&&u()},p=F("Commentaire supprimé",{duration:_t,focusAction:!0,action:{label:"Annuler",onClick:()=>{d(),F.dismiss(p)}},onDismiss:()=>{r.delete(a)&&o.mutate({commentId:a},{onError:u})}});setTimeout(()=>{r.has(a)&&F.dismiss(p)},yt)}}const Re={publish:{patch:{status:"published"},done:"Commentaire approuvé"},pending:{patch:{status:"pending"},done:"Commentaire remis en modération"},spam:{patch:{status:"spam"},done:"Commentaire marqué comme indésirable"},hide:{patch:{status:"shadowed"},done:"Commentaire masqué"},report:{patch:{status:"reported_hidden"},done:"Commentaire masqué comme signalé"},delete:{patch:{status:"deleted",contentHtml:""},done:"Commentaire supprimé"},pin:{patch:{isPinned:!0},done:"Commentaire épinglé"},unpin:{patch:{isPinned:!1},done:"Ãpingle retirée"}};function ve(e,t,n){return{...e,pages:e.pages.map(s=>({...s,comments:s.comments.map(o=>o.id===t?{...o,...n(o)}:{...o,replies:o.replies.map(r=>r.id===t?n(r):r)})}))}}function bn(e,t){const n=ie(),s=De(e,t),o=se(e,t);return Pe({mutationFn:({commentId:r,action:a})=>ht(e,r,a),onMutate:async({commentId:r,action:a})=>{await n.cancelQueries({queryKey:o});const l=n.getQueryData(o),c=Re[a];if(l&&c){const u=a==="delete"?me(l,r):[r];n.setQueryData(o,u.reduce((d,p)=>ve(d,p,f=>({...f,...c.patch})),l))}return{previous:l}},onError:(r,a,l)=>{l!=null&&l.previous&&n.setQueryData(o,l.previous),F.error("La décision de modération nâa pas pu être appliquée.")},onSuccess:(r,{action:a})=>{var c;const l=n.getQueryData(o);if(l&&n.setQueryData(o,ve(l,r.comment.id,()=>r.comment)),!r.applied&&(a==="pin"||a==="unpin")){F.warning("Seul un commentaire publié de premier niveau peut être épinglé.");return}if(!r.applied){F.warning("Rien à changer : ce commentaire était déjà dans cet état.");return}s(),a!=="delete"&&F.success(((c=Re[a])==null?void 0:c.done)??"Décision appliquée")}})}function wn(e,t){const n=ie(),s=se(e,t),o=bn(e,t),r=m.useRef(new Set).current;return m.useEffect(()=>{const a=()=>{r.forEach(l=>{ht(e,l,"delete",!0).catch(()=>{})}),r.clear()};return window.addEventListener("pagehide",a),()=>{window.removeEventListener("pagehide",a),a()}},[]),(a,l)=>{if(l!=="delete"){if(r.has(a))return;r.add(a),o.mutate({commentId:a,action:l},{onSettled:()=>r.delete(a)});return}if(r.has(a))return;const c=n.getQueryData(s),u=c?me(c,a).map(f=>Me(c,f)).filter(f=>f!==void 0):[];c&&n.setQueryData(s,me(c,a).reduce((f,h)=>ve(f,h,x=>({...x,...Re.delete.patch})),c)),r.add(a);const d=()=>{const f=n.getQueryData(s);!f||u.length===0||n.setQueryData(s,u.reduce((h,x)=>ve(h,x.id,()=>x),f))},p=F("Commentaire supprimé",{duration:_t,focusAction:!0,action:{label:"Annuler",onClick:()=>{r.delete(a)&&d(),F.dismiss(p)}},onDismiss:()=>{r.delete(a)&&o.mutate({commentId:a,action:"delete"},{onError:d})}});setTimeout(()=>{r.has(a)&&F.dismiss(p)},yt)}}const _n=5;function yn(e){const t=/^#comment-(\d+)$/.exec(e);return t?Number(t[1]):null}function vn(e,t){return e.some(n=>n.comments.some(s=>s.id===t||s.replies.some(o=>o.id===t)))}function Sn(e,t){for(const n of e)for(const s of n.comments)if(s.id===t||s.replies.some(o=>o.id===t))return s.id;return null}function Xe(e){const t=document.getElementById(`comment-${e}`);return t?(t.scrollIntoView({behavior:$t()?"auto":"smooth",block:"center"}),!0):!1}function Je(e){return e.status==="published"}class En{constructor(t,n){this.pageUrl=t,this.byId=new Map,this.children=new Map;for(const s of n)this.byId.set(s.id,s);for(const s of n){if(!Je(s))continue;const o=this.renderedAncestor(s),r=this.children.get(o);r?r.push(s):this.children.set(o,[s])}}nodes(t){return(this.children.get(t)??[]).map(n=>this.node(n,t))}renderedAncestor(t){if(t.parentId===0)return 0;let n=this.byId.get(t.parentId)??this.byId.get(t.threadRootId);for(;n&&!Je(n);)n=this.byId.get(n.parentId);return n?n.id:0}anchor(t){return`${this.pageUrl}#comment-${t}`}node(t,n){const s=this.nodes(t.id),o={"@type":"Comment"};return s.length>0&&(o["@id"]=this.anchor(t.id)),o.url=this.anchor(t.id),o.author={"@type":"Person",name:t.authorName},o.datePublished=je(t.createdAt),t.editedAt&&(o.dateModified=je(t.editedAt)),o.text=Se(t.contentHtml).replace(/\s+/g," ").trim(),n>0&&(o.parentItem={"@type":"Comment","@id":this.anchor(n)}),t.score>0&&(o.interactionStatistic=[{"@type":"InteractionCounter",interactionType:"https://schema.org/LikeAction",userInteractionCount:t.score}]),s.length>0&&(o.commentCount=s.length,o.comment=s),o}}function Nn(e,t,n=`${t}#article`,s="Article"){const o=new En(t,e.comments.flatMap(a=>
5[a,...a.replies??[]])),r={"@context":"https://schema.org","@type":s,"@id":n};return typeof e.commentCount=="number"&&(r.commentCount=e.commentCount),r.comment=o.nodes(0),r}const jn={post:{prefix:"Lire :",fallbackLabel:"Lire lâarticle",icon:"document"},product:{prefix:"Voir :",fallbackLabel:"Voir la fiche produit",icon:"smartphone"}},Cn="Contenu indisponible";function Rn({type:e,id:t,title:n,href:s,className:o=""}){const r=jn[e],a=(n==null?void 0:n.trim())??"",l=`${e}:${t}`,c=["inline-flex max-w-full items-center gap-100 align-middle rounded-medium bg-background-block","border border-solid border-background-separator","px-200 py-100 no-underline font-fontFamilySecondary text-4xs leading-body",o].filter(Boolean).join(" ");return s?i.jsxs("a",{href:s,rel:"ugc","data-slot":"comment-content-link","data-content-ref":l,className:`${c} text-font-body`,children:[i.jsx(ne,{name:r.icon,size:14,color:"inherit",className:"shrink-0"}),a?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"shrink-0 font-bold text-font-indicator",children:r.prefix}),i.jsx("span",{className:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap",children:a})]}):i.jsx("span",{className:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap font-bold",children:r.fallbackLabel})]}):i.jsxs("span",{"data-slot":"comment-content-link","data-content-ref":l,className:`${c} text-font-indicator`,children:[i.jsx(ne,{name:"prohibit",size:14,color:"inherit",className:"shrink-0"}),Cn]})}const kn="Lien affilié",Ye=28,et="h-[1.75rem] w-[1.75rem] shrink-0 rounded-small";function Ln({merchant:e,label:t,href:n,logoUrl:s,className:o=""}){const[r,a]=m.useState(!1),l=m.useCallback(()=>a(!0),[]),c=!!s&&!r,u=e.trim().charAt(0).toUpperCase(),d=["flex max-w-full items-center gap-200 rounded-medium border border-background-separator","bg-background-block p-200 no-underline font-fontFamilySecondary",o].filter(Boolean).join(" ");return i.jsxs("a",{href:n,target:"_blank",rel:"ugc sponsored nofollow noopener noreferrer","data-slot":"comment-merchant-link","data-merchant":e,className:d,children:[c?i.jsx("img",{src:s,alt:"",width:Ye,height:Ye,loading:"lazy",onError:l,"aria-hidden":"true",className:`${et} bg-background-white object-contain`}):i.jsx("span",{"aria-hidden":"true",className:`${et} flex items-center justify-center bg-background-neutral-light text-4xs font-bold text-font-body`,children:u}),i.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[i.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap text-4xs font-bold text-font-body",children:t}),i.jsxs("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap text-5xs text-font-indicator",children:["Acheter sur ",e," ",i.jsx("span",{"aria-hidden":"true",children:"·"})," ",kn]})]}),i.jsx(ne,{name:"cart",size:18,color:"indicator",className:"shrink-0"})]})}const Pn=new Set(["p","ul","ol","li","blockquote","strong","em","b","i","del","s"]),Dn=new Set(["br","img","hr","wbr","input","source"]),Mn=new Set(["ul","ol"]),Tn=new Set(["post","product"]),ke=/<a\b[^>]*\sdata-(?:content-ref|merchant)\s*=/i,$n=/<a\b([^>]*)>([\s\S]*?)<\/a>/gi,vt=/<(\/?)([a-z][a-z0-9]*)\b([^>]*?)(\/?)>/gi;function xe(e,t){const n=e.match(new RegExp(`\\s${t}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`,"i"));if(!n)return null;const s=n[1]!==void 0?n[1]:n[2];return Se(s)}function Le(e){const t=[];for(const[,n,s,,o]of e.matchAll(vt)){const r=s.toLowerCase();if(!Dn.has(r)&&!o)if(n){if(t.pop()!==r)return!1}else t.push(r)}return t.length===0}function An(e){const t=e.trim();if(!t)return!1;if(t.startsWith("/")||t.startsWith("#"))return!0;try{const{protocol:n}=new URL(t);return n==="http:"||n==="https:"||n==="mailto:"}catch{return!1}}function On(e,t){const n=xe(e,"href"),s=n&&An(n)?n:null,o=Se(t).trim(),r=xe(e,"data-content-ref");if(r){const[l,...c]=r.split(":"),u=c.join(":").trim();return!Tn.has(l)||!u?null:{kind:"content-ref",type:l,id:u,title:o,href:s}}const a=xe(e,"data-merchant");return a&&s?{kind:"merchant",merchant:a,label:o||a,href:s,logoUrl:xe(e,"data-merchant-logo")}:null}function Te(e){return e.some(t=>t.kind==="element"?Te(t.children):t.kind!=="html")}function Fn(e){const t=[];let n=0;for(const o of e.matchAll($n)){const r=On(o[1],o[2]);if(!r)continue;const a=e.slice(n,o.index);if(!Le(a))return null;a&&t.push({kind:"html",html:a}),t.push(r),n=o.index+o[0].length}const s=e.slice(n);return Le(s)?(s&&t.push({kind:"html",html:s}),t):null}function Hn(e,t,n){const s=new RegExp(`<(/?)${t}\\b([^>]*?)(/?)>`,"gi");let o=1;for(const r of e.slice(n).matchAll(s))if(r[1]){if(o-=1,o===0)return n+r.index}else r[3]||(o+=1);return-1}function In(e,t){for(const n of e.slice(t).matchAll(vt)){const s=n[2].toLowerCase();if(!n[1]&&!n[4]&&Pn.has(s))return{index:t+n.index,tag:s,contentStart:t+n.index+n[0].length}}return null}function St(e,t=!1){const n=[];let s=0;const o=r=>{if(!r)return!0;
5if(t)return r.trim()==="";if(!ke.test(r))return n.push({kind:"html",html:r}),!0;const a=Fn(r);return a?(n.push(...a),!0):!1};for(;s<e.length;){const r=In(e,s);if(!r)return o(e.slice(s))?n:null;if(!o(e.slice(s,r.index)))return null;const a=Hn(e,r.tag,r.contentStart);if(a===-1)return null;const l=e.slice(r.contentStart,a),c=r.tag.length+3,u=e.slice(r.index,a+c);if(!t&&!ke.test(u))n.push({kind:"html",html:u});else{const d=St(l,Mn.has(r.tag));if(!d)return null;!t&&!Te(d)?n.push({kind:"html",html:u}):n.push({kind:"element",tag:r.tag,children:d})}s=a+c}return n}function Bn(e){const t=[{kind:"html",html:e}];if(!ke.test(e)||!Le(e))return t;const n=St(e);return n&&Te(n)?n:t}const zn=/^\s*<(?:p|ul|ol|blockquote|div|pre|table|figure|hr|h[1-6])\b/i;function Qn(e,t){switch(e.kind){case"element":return m.createElement(e.tag,{key:t},i.jsx(Et,{nodes:e.children}));case"content-ref":return i.jsx(Rn,{type:e.type,id:e.id,title:e.title,href:e.href},t);case"merchant":return i.jsx(Ln,{merchant:e.merchant,label:e.label,href:e.href,logoUrl:e.logoUrl,className:"my-200"},t);default:return zn.test(e.html)?i.jsx("div",{className:"contents",dangerouslySetInnerHTML:{__html:e.html}},t):i.jsx("span",{dangerouslySetInnerHTML:{__html:e.html}},t)}}function Et({nodes:e}){return i.jsx(i.Fragment,{children:e.map((t,n)=>Qn(t,n))})}function qn({html:e,className:t=""}){const n=m.useMemo(()=>Bn(e),[e]);return n.length===1&&n[0].kind==="html"?i.jsx("div",{className:t,dangerouslySetInnerHTML:{__html:n[0].html}}):i.jsx("div",{className:t,children:i.jsx(Et,{nodes:n})})}const tt=6e5;function Vn(e,t){const n=Wt(e).getTime();return Number.isNaN(n)?0:Math.min(tt,Math.max(0,n+tt-t))}function Gn(e){return e.status!=="deleted"?!0:(("replies"in e?e.replies:void 0)??[]).some(n=>n.status!=="deleted")}function $e(e){return e.filter(Gn)}const Un={pending:"En attente de validation",shadowed:"Masqué â son auteur le voit toujours",spam:"Indésirable â masqué pour tout le monde",reported_hidden:"Masqué après signalements"},Wn={pending:"pending",shadowed:"shadowed",spam:"spam",reported_hidden:"reported"};function Kn(e){return Wn[e.status]??null}function Zn(e){return Un[e.status]??null}const Xn=new Set(["pending","shadowed","spam","reported_hidden"]),Jn=[{action:"publish",label:({status:e})=>e==="spam"?"Retirer la marque indésirable":e==="shadowed"||e==="reported_hidden"?"Démasquer":"Approuver",icon:({status:e})=>e==="shadowed"||e==="reported_hidden"?"eye":"check-circle",appliesTo:({status:e})=>Xn.has(e)},{action:"pending",label:()=>"Remettre en modération",icon:()=>"clock-dash",appliesTo:({status:e})=>e!=="pending"&&e!=="deleted"},{action:"spam",label:()=>"Marquer comme indésirable",icon:()=>"prohibit",danger:!0,appliesTo:({status:e})=>e!=="spam"&&e!=="deleted"},{action:"hide",label:()=>"Masquer",icon:()=>"eye-off",danger:!0,appliesTo:({status:e})=>e!=="shadowed"&&e!=="deleted"},{action:"pin",label:()=>"Ãpingler en haut du fil",icon:()=>"push-pin",appliesTo:e=>e.status==="published"&&e.depth===0&&e.isPinned!==!0},{action:"unpin",label:()=>"Retirer lâépingle",icon:()=>"push-pin-slash",appliesTo:e=>e.isPinned===!0},{action:"delete",label:()=>"Supprimer ce commentaire",icon:()=>"trash-delete",danger:!0,appliesTo:({status:e})=>e!=="deleted"}];function Yn(e){return Jn.filter(t=>t.appliesTo(e))}const es="content___zGB61",ts="fieldset___1v3j0",ns="legend___bF2L9",ss="option___t60bF",os="radio___6MXM6",rs="optionLabel___ExX-e",is="footer___PDQpZ",re={content:es,fieldset:ts,legend:ns,option:ss,radio:os,optionLabel:rs,footer:is},as=[{value:"spam",label:"Spam ou publicité"},{value:"hate",label:"Haine ou discrimination"},{value:"harassment",label:"Harcèlement ou menaces"},{value:"violence",label:"Violence ou contenu choquant"},{value:"sexual",label:"Contenu sexuel"},{value:"self-harm",label:"Automutilation ou suicide"},{value:"other",label:"Autre"}];function ls({isOpen:e,onClose:t,onSubmit:n,authorName:s,isSubmitting:o=!1}){const[r,a]=m.useState(""),l=m.useId(),c=m.useId(),u=m.useId();return m.useEffect(()=>{e||a("")},[e]),i.jsx(at,{isOpen:e,onClose:t,titleId:l,descriptionId:c,children:i.jsxs(lt,{className:re.content,children:[i.jsxs(ct,{children:[i.jsx(ut,{id:l,children:s?`Signaler le commentaire de ${s}`:"Signaler ce commentaire"}),i.jsx(At,{id:c,children:"Votre signalement est transmis à notre équipe de modération. Il reste anonyme pour lâauteur du commentaire."})]}),i.jsx(dt,{children:i.jsxs("fieldset",{className:re.fieldset,children:[i.jsx("legend",{className:re.legend,children:"Motif du signalement"}),as.map(d=>i.jsxs("label",{className:re.option,children:[i.jsx("input",{type:"radio",name:u,value:d.value,checked:r===d.value,onChange:()=>
5a(d.value),className:re.radio}),i.jsx("span",{className:re.optionLabel,children:d.label})]},d.value))]})}),i.jsxs(mt,{className:re.footer,children:[i.jsx(Ge,{variant:"ghost",color:"tertiary",onClick:t,disabled:o,children:"Annuler"}),i.jsx(Ge,{variant:"contained",color:"primary",onClick:()=>r!==""&&n(r),disabled:r===""||o,children:o?"Envoiâ¦":"Signaler"})]})]})})}const cs="sending___u9T41",us="rowStatus___59FOG",ds="rowPending___M6HpM",ms="rowShadowed___eQz-6",fs="rowSpam___HRG-T",ps="rowReported___tt6Ht",hs="publishingIdle___4D9Ey",gs="publishing___P-w-J",xs="groupLabel___8ZRBa",bs="menuRoot___jSpFM",ws="menuSurface___8ymF2",_s="menuSurfaceUp___6Zr1E",ys="menuSurfaceCollapsed___VGRPV",vs="menuSurfaceOpen___OP4pN",Ss="menuTrigger___ptCE6",Es="menuPanel___L80OB",Ns="item___zTIzv",js="itemLabel___lgZ-d",Cs="itemDanger___fhNKn",Rs="divider___mPvXP",k={sending:cs,rowStatus:us,rowPending:ds,rowShadowed:ms,rowSpam:fs,rowReported:ps,publishingIdle:hs,publishing:gs,groupLabel:xs,menuRoot:bs,menuSurface:ws,menuSurfaceUp:_s,menuSurfaceCollapsed:ys,menuSurfaceOpen:vs,menuTrigger:Ss,menuPanel:Es,item:Ns,itemLabel:js,itemDanger:Cs,divider:Rs};function ks(e){let t=e.parentElement;for(;t&&t!==document.body;){const{overflowY:n}=window.getComputedStyle(t);if(n==="auto"||n==="scroll")return t;t=t.parentElement}return null}function Ls({commentId:e,authorName:t,canDelete:n,onDelete:s,canReport:o,isLoggedIn:r,requireLogin:a,moderationEntries:l=[]}){const[c,u]=m.useState(!1),[d,p]=m.useState(!1),[f,h]=m.useState("down"),[x,N]=m.useState(null),w=m.useRef(null),j=m.useRef(null),H=m.useId(),K={type:"comment",id:e},{data:Z}=Ot(K,r&&o&&c),T=Ft(e),X=((Z==null?void 0:Z.me)??[]).some(b=>b.type==="report"),Q=(b=!1)=>{var R,_;u(!1),b&&((_=(R=j.current)==null?void 0:R.querySelector("button"))==null||_.focus())},I=()=>{var R;const b=`${window.location.origin}${window.location.pathname}#comment-${e}`;(((R=navigator.clipboard)==null?void 0:R.writeText(b))??Promise.reject(new Error("no clipboard"))).then(()=>F.success("Lien du commentaire copié")).catch(()=>F.error("Le lien nâa pas pu être copié.")),Q(!0)},$=()=>{if(!r){a(null),Q(!0);return}Q(!0),p(!0)},J=b=>{T.mutate(b),p(!1)},L=[];L.push({key:"copy-link",label:"Copier le lien",icon:"link",onSelect:I}),n&&L.push({key:"delete",label:"Supprimer",icon:"trash-delete",tone:"danger",onSelect:()=>{Q(),s(e)}}),o&&L.push({key:"report",label:X?"Signalé":"Signaler",icon:"flag",tone:"danger",disabled:X,onSelect:$});for(const b of l)L.push({key:b.key,label:b.label,icon:b.icon,tone:b.danger?"danger":void 0,group:"moderation",onSelect:()=>{Q(),b.onSelect()}});const B=m.useRef([]),M=t?`Options du commentaire de ${t}`:"Options du commentaire",U=44,Y=16,S=1,W=8,q=Y+L.length*U+Math.max(0,L.length-1)*S+(l.length>0?20:0),he=()=>{const b=w.current;if(b){const R=ks(b),_=R?R.getBoundingClientRect():{top:0,bottom:window.innerHeight},v=b.getBoundingClientRect(),E=_.bottom-v.bottom,A=v.top-_.top,V=E<q&&A>E?"up":"down";h(V);const te=(V==="up"?A:E)-W;N(Math.min(q,Math.max(U*2,te)))}u(!0)};return m.useLayoutEffect(()=>{if(!c)return;const b=requestAnimationFrame(()=>{var R;return(R=B.current[0])==null?void 0:R.focus({preventScroll:!0})});return()=>cancelAnimationFrame(b)},[c]),m.useEffect(()=>{if(!c)return;const b=_=>{const v=w.current;v&&!v.contains(_.target)&&u(!1)},R=_=>{var A,V,te,le;if(_.key==="Escape"){_.stopPropagation(),Q(!0);return}if(_.key==="Tab"){u(!1);return}const v=B.current.filter(g=>g!==null);if(v.length===0)return;const E=v.indexOf(document.activeElement);_.key==="ArrowDown"?(_.preventDefault(),(A=v[(E+1+v.length)%v.length])==null||A.focus()):_.key==="ArrowUp"?(_.preventDefault(),(V=v[(E-1+v.length)%v.length])==null||V.focus()):_.key==="Home"?(_.preventDefault(),(te=v[0])==null||te.focus()):_.key==="End"&&(_.preventDefault(),(le=v[v.length-1])==null||le.focus())};return document.addEventListener("pointerdown",b),document.addEventListener("keydown",R),()=>{document.removeEventListener("pointerdown",b),document.removeEventListener("keydown",R)}},[c]),i.jsxs("div",{ref:w,className:`${k.menuRoot} ml-auto`,"data-menu-open":c||void 0,children:[i.jsx("div",{ref:j,className:"contents",children:i.jsx(Ne,{name:"options-horizontal",size:18,appearance:"ghost",color:"inherit",hoverEffect:!1,className:k.menuTrigger,ariaLabel:M,"aria-haspopup":"menu","aria-expanded":c,"aria-controls":H,onClick:()=>{c?u(!1):he()}})}),i.jsx("div",{className:[k.menuSurface,c?k.menuSurfaceOpen:k.menuSurfaceCollapsed,f==="up"?k.menuSurfaceUp:""].filter(
5Boolean).join(" "),style:{"--comment-menu-open-h":`${x??q}px`,"--comment-menu-scrolls":x!==null&&x<q?"auto":"hidden"},children:i.jsx("div",{id:H,role:"menu","aria-label":M,"aria-hidden":!c,className:k.menuPanel,children:L.map((b,R)=>{var _;return i.jsxs(m.Fragment,{children:[R>0&&i.jsx("span",{className:k.divider,"aria-hidden":"true"}),b.group==="moderation"&&((_=L[R-1])==null?void 0:_.group)!=="moderation"&&i.jsx("span",{className:k.groupLabel,role:"presentation",children:"Modération"}),i.jsxs("button",{ref:v=>{B.current[R]=v},type:"button",role:"menuitem",tabIndex:-1,className:`${k.item} ${b.tone==="danger"?k.itemDanger:""}`,disabled:b.disabled,"aria-disabled":b.disabled,"aria-label":b.group==="moderation"?`${b.label} â modération`:void 0,onClick:b.onSelect,children:[i.jsx(ne,{name:b.icon,size:18,color:"inherit"}),i.jsx("span",{className:k.itemLabel,children:b.label})]})]},b.key)})})}),i.jsx(ls,{isOpen:d,onClose:()=>p(!1),onSubmit:J,authorName:t,isSubmitting:T.isPending})]})}const Ps="heart___F9kfl",Ds="pop___ZRnlD",nt={heart:Ps,pop:Ds};function Ms({score:e,disabled:t=!1,viewerVote:n=null,onVote:s}){const o=n==="up",[r,a]=m.useState(!1),[l,c]=m.useState(o);l!==o&&(c(o),o&&a(!0));const u=()=>s("up",!o);return i.jsxs("button",{type:"button",disabled:t,"aria-pressed":o,"aria-label":o?"Je n'aime plus":"J'aime",onClick:u,className:`inline-flex items-center gap-100 rounded-small bg-transparent border-0 px-0 py-100 cursor-pointer font-fontFamilySecondary text-5xs font-bold ${o?"text-system-error":"text-font-indicator"} disabled:opacity-50 disabled:cursor-not-allowed`,children:[i.jsx("span",{className:`${nt.heart}${r?` ${nt.pop}`:""}`,onAnimationEnd:()=>a(!1),children:i.jsx(ne,{name:"heart-like",size:18,color:"inherit"})}),i.jsx("span",{"aria-hidden":"true",children:e>0?e:"J'aime"})]})}const Ts=[];function $s(e,t){const[n,s]=m.useState(!1);return m.useEffect(()=>{if(!t){s(!1);return}const o=Vn(e,Date.now());if(s(o>0),o<=0)return;const r=setTimeout(()=>s(!1),o);return()=>clearTimeout(r)},[e,t]),n}const As={pending:k.rowPending,shadowed:k.rowShadowed,spam:k.rowSpam,reported:k.rowReported},st={author:"Auteur",team:"La rédaction"};function Ae({comment:e,replies:t=Ts,isLoggedIn:n,requireLogin:s,onEditIntent:o,onDelete:r,onVote:a,onReplyIntent:l,forceExpandReplies:c=!1,anchored:u=!0,highlightFor:d=null,moderatorView:p=!1,onModerate:f,promoted:h=!1}){var Y;const[x,N]=m.useState(null),w=x??c,j=e.delivery==="sending",H=(e.status==="pending"||e.id<0)&&!j,K=p?Zn(e):null,Z=H?"pending":p?Kn(e):null,T=j||H||K!==null,X=j?"Publicationâ¦":K??"En attente de validation",Q=e.depth>0&&!h,I=e.status==="deleted",$=$e(t),J=()=>{l==null||l(e),n||s(null)},L=()=>o==null?void 0:o(e),B=$s(e.createdAt,e.isMine&&e.id>0)&&o!==void 0,M=!T,U=i.jsx("ul",{className:`comment__replies flex list-none flex-col p-0 gap-400 ${I?"m-0":"mt-300"}`,children:$.map(S=>i.jsx("li",{children:i.jsx(Ae,{comment:S,isLoggedIn:n,requireLogin:s,onEditIntent:o,onDelete:r,onVote:a,onReplyIntent:l,anchored:u,highlightFor:d,moderatorView:p,onModerate:f,promoted:I})},S.id))});return I?$.length>0?U:null:i.jsx("article",{id:u?`comment-${e.id}`:void 0,className:["comment relative",d===e.id?"comment--highlighted":"",j?k.sending:"",Z?`${k.rowStatus} ${As[Z]}`:""].filter(Boolean).join(" "),children:i.jsxs("div",{className:"flex gap-300",children:[i.jsx(Kt,{name:e.authorName,size:Q?"sm":"md"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("header",{className:"relative flex min-w-0 items-center gap-200",children:[i.jsx("strong",{className:"max-w-[150px] overflow-hidden text-ellipsis whitespace-nowrap font-fontFamilySecondary font-bold text-4xs text-font-body",children:e.authorName}),(Y=e.authorBadges)==null?void 0:Y.map(S=>st[S]&&i.jsx(_e,{variant:"secondary",size:"sm",children:st[S]},S)),e.isPinned&&i.jsx("span",{className:"inline-flex text-font-indicator",title:"Ãpinglé en haut du fil",children:i.jsx(ne,{name:"push-pin",size:14,variant:"solid",color:"inherit",ariaLabel:"Ãpinglé"})}),i.jsxs("time",{suppressHydrationWarning:!0,className:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap font-fontFamilySecondary text-4xs text-font-indicator",dateTime:je(e.createdAt),children:["· ",Ue(e.createdAt)]}),e.editedAt&&i.jsx("span",{className:"whitespace-nowrap font-fontFamilySecondary text-4xs text-font-indicator",title:`Modifié ${Ue(e.editedAt)}`,children:"· modifié"}),i.jsx(Ls,{commentId:e.id,authorName:e.authorName,canDelete:e.isMine&&e.id>0,onDelete:r,canReport:!e.isMine&&!H&&!j&&e.status!=="deleted",isLoggedIn:n,requireLogin:s,moderationEntries:p&&f&&e.id>0?Yn(e).map(S=>({key:`moderate-${S.action}`,label:S.label(e),icon:S.icon(e),danger:S.danger,onSelect:()=>f(e.id,S.action)})):[]})]}),i.jsx(qn,{html:e.contentHtml,className:`comment__content font-fontFamilySecondary text-3xs leading-body [word-wrap:break-word] ${T?"text-font-indicator":"text-font-body"}`}),(e.isMine||K!==null)&&i.jsx("p",{role:"status","aria-live":"polite",className:T?`${k.publishing} mt-100 font-fontFamilySecondary text-5xs`:k.publishingIdle,children:T?X:""}),(M||B)&&i.jsxs("footer",{className:"mt-100 flex items-center gap-500",children:[M&&i.jsx(Ms,{score:e.score,viewerVote:e.viewerVote??null,onVote:(S,W)=>n?a(e.id,S,W):s({kind:"comment-vote",commentId:e.id,value:S})}),B&&i.jsx(be,{as:"button",variant:"none",onClick:L,className:"px-0 py-100 font-fontFamilySecondary font-bold text-5xs text-font-indicator",children:"Modifier"}),M&&l&&i.jsx(be,{as:"button",variant:"none",onClick:J,className:"px-0 py-100 font-fontFamilySecondary font-bold text-5xs text-font-indicator",children:"Répondre"})]}),$.length>0&&i.jsxs("div",{className:"mt-100",children:[i.jsxs(be,{as:"button",variant:"none",className:"inline-flex items-center gap-100 px-0 font-fontFamilySecondary font-normal text-5xs text-primary","aria-expanded":w,onClick:()=>N(!w),children:[i.jsx(ne,{name:w?"caret-up":"caret-down",size:12,color:"inherit"}),w?"Masquer les réponses":`Voir ${$.length} réponse${$.length>
51?"s":""}`]}),i.jsx("div",{hidden:!w,children:U})]})]})]})})}const Os=new Set(["spam","shadowed","reported_hidden"]);function Nt(e,t){const n={pinned:[],thread:[],unwanted:[]};for(const s of e)t&&Os.has(s.status)?n.unwanted.push(s):s.isPinned?n.pinned.push(s):n.thread.push(s);return n}const Fs="notice___BMTY7",jt={notice:Fs},Hs="unwanted___x058X",Is="unwantedSummary___KCEmY",ot={unwanted:Hs,unwantedSummary:Is};function Bs({comments:e,expandRepliesFor:t,...n}){const s=$e(e);if(s.length===0)return i.jsx("p",{className:`${jt.notice} font-fontFamilySecondary text-3xs text-font-indicator`,children:"Aucun commentaire pour le moment. Lancez la discussion !"});const{pinned:o,thread:r,unwanted:a}=Nt(s,n.moderatorView??!1),l=c=>i.jsx("ul",{className:"comments-list m-0 flex list-none flex-col p-0",children:c.map(u=>i.jsx("li",{children:i.jsx(Ae,{comment:u,replies:u.replies,forceExpandReplies:t===u.id,...n})},u.id))});return i.jsxs(i.Fragment,{children:[l([...o,...r]),a.length>0&&i.jsxs("details",{className:ot.unwanted,children:[i.jsxs("summary",{className:ot.unwantedSummary,children:[i.jsx(ne,{name:"eye-off",size:16,color:"inherit"}),"Voir les commentaires masqués"]}),l(a)]})]})}function Ct(e,t){const[n,s]=m.useState(null);return m.useEffect(()=>{if(!t||n)return;let o=!1;return e().then(r=>{o||s(()=>r)}),()=>{o=!0}},[t,n]),n}const zs=400;function Qs({isLoggedIn:e,fieldBoxRef:t,load:n}){const[s,o]=m.useState(!1),[r,a]=m.useState(!1),[l,c]=m.useState(!1),u=Ct(n,e&&(s||l));return m.useEffect(()=>{const d=t.current;if(!e||!d||l||typeof IntersectionObserver>"u")return;const p=new IntersectionObserver(f=>{f.some(h=>h.isIntersecting)&&(p.disconnect(),c(!0))});return p.observe(d),()=>p.disconnect()},[e,l,t]),m.useEffect(()=>{const d=t.current;if(!s||!d||r)return;let p=0;const f=()=>{p=window.setTimeout(()=>a(!0),0)},h=N=>{N.target!==d||N.propertyName!=="min-height"||f()};d.addEventListener("transitionend",h);const x=setTimeout(f,zs);return()=>{d.removeEventListener("transitionend",h),clearTimeout(x),clearTimeout(p)}},[s,r,t]),{Editor:u,showEditor:u!==null&&r,wantsEditor:s,requestEditor:()=>{e&&o(!0)},collapseEditor:()=>{o(!1),a(!1)}}}const qs="root___frpH7",Vs="field___vXlOT",Gs="fieldExpanded___2--xK",Us="sendButton___gZ9Az",Ws="toolbarRow___kRhMe",Ks="toolbarRowOpen___cKOB-",Zs="toolbarRowInner___WoGJL",Xs="toolbarRowContent___8z6JE",Js="toolbarControls___1v1VC",Ys="toolbarControlsReady___ZU6Sh",eo="placeholder___F-W7z",to="placeholderGone___ZY-IG",G={root:qs,field:Vs,fieldExpanded:Gs,sendButton:Us,toolbarRow:Ws,toolbarRowOpen:Ks,toolbarRowInner:Zs,toolbarRowContent:Xs,toolbarControls:Js,toolbarControlsReady:Ys,placeholder:eo,placeholderGone:to};function no(){return ft(()=>import("./CommentMarkdownEditor-WOJH_Tkk.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])).then(e=>e.default)}function so(){return ft(()=>import("./ComposerTools-B6yHEtHk.js"),__vite__mapDeps([8,1,2,3,4])).then(e=>e.default)}function Rt(){const[e,t]=m.useState(0);return m.useEffect(()=>{const n=window.visualViewport;if(!n)return;const s=()=>t(Math.max(0,window.innerHeight-n.height-n.offsetTop));return s(),n.addEventListener("resize",s),n.addEventListener("scroll",s,{passive:!0}),()=>{n.removeEventListener("resize",s),n.removeEventListener("scroll",s)}},[]),e}function rt({isLoggedIn:e,onRequireLogin:t,loginUrl:n="/connexion",replyingTo:s,editing:o,restoredDraft:r,error:a,onDraftCleared:l,onCancelReply:c,onSubmit:u,tools:d,isSubmitting:p=!1}){const f=Ht(),[h,x]=m.useState(""),N=m.useRef(h);N.current=h;const w=m.useRef(l);w.current=l;const j=g=>{var P;const C=N.current.trim()!=="";N.current=g,x(g),C&&g.trim()===""&&((P=w.current)==null||P.call(w))},H=m.useRef(null),K=m.useRef(null),[Z,T]=m.useState(0),[X,Q]=m.useState(null),I=m.useRef(null),$=m.useRef(null),J=Rt(),{Editor:L,showEditor:B,wantsEditor:M,requestEditor:U,collapseEditor:Y}=Qs({isLoggedIn:e,fieldBoxRef:K,load:no}),S=()=>{var g;return L?((g=I.current)==null?void 0:g.getMarkdown())??h:h},W=g=>{const C=g.relatedTarget;C&&g.currentTarget.contains(C)||S().trim()!==""||s||o||Y()},O=!!(d&&d.length>0),q=Ct(so,O),b=o!==void 0&&!B?"":h;m.useLayoutEffect(()=>{const g=$.current;if(!g)return;g.style.height="auto";const C=g.scrollHeight;C>0?g.style.height=`${C}px`:g.style.removeProperty("height")},[b]),m.useEffect(()=>{var g;
5s&&((g=$.current)==null||g.focus())},[s]);const R=g=>{x(g),T(C=>C+1),U()},_=o==null?void 0:o.id;m.useEffect(()=>{if(_===void 0){x(""),T(g=>g+1);return}R((o==null?void 0:o.content)??"")},[_]);const v=r==null?void 0:r.seq;m.useEffect(()=>{v!==void 0&&S().trim()===""&&R((r==null?void 0:r.content)??"")},[v]);const E=()=>{var C,P;if(p)return;const g=S().trim();g&&(u(g,L?((C=I.current)==null?void 0:C.getHtml())??"":""),N.current="",x(""),(P=I.current)==null||P.clear())},A=!!h.trim(),V=g=>{var ge;if(g.key!=="Enter"||g.shiftKey||g.nativeEvent.isComposing)return;const C=g.target,P=C==null?void 0:C.closest('textarea, [contenteditable="true"]');if(!P)return;const ee=(ge=window.getSelection())==null?void 0:ge.anchorNode,oe=ee instanceof Element?ee:ee==null?void 0:ee.parentElement,ae=oe==null?void 0:oe.closest("li");ae&&P.contains(ae)||(g.preventDefault(),E())},te=()=>{var g,C;if(o){const P=document.activeElement;P&&((g=H.current)!=null&&g.contains(P))&&P.blur(),x(""),(C=I.current)==null||C.clear(),T(ee=>ee+1),Y()}else S().trim()===""&&Y();c()},le=s||o?i.jsxs("div",{className:"mb-200 flex w-fit items-center gap-100 rounded-full bg-background-block px-200 py-50 font-fontFamilySecondary text-4xs text-font-indicator",children:[o?i.jsx("strong",{className:"font-bold text-font-body",children:"Modification"}):i.jsxs(i.Fragment,{children:["Réponse à ",i.jsx("strong",{className:"font-bold text-font-body",children:s})]}),i.jsx(Ne,{name:"close",size:12,appearance:"ghost",color:"inherit",ariaLabel:o?"Annuler la modification":"Annuler la réponse",onClick:te,className:"ml-100"})]}):null;return i.jsxs("div",{ref:H,"data-composer-bar":"true",className:G.root,style:{marginBottom:J||void 0},onBlurCapture:W,children:[a&&i.jsx("p",{role:"alert",className:"mb-200 font-fontFamilySecondary text-4xs leading-body text-system-error",children:a}),le,i.jsxs("div",{className:"flex items-end gap-200",children:[i.jsxs("div",{ref:K,className:`${G.field} ${M?G.fieldExpanded:""} min-w-0 flex-1`,onKeyDownCapture:V,children:[B&&L?i.jsx(L,{ref:I,defaultValue:h,onChange:j,focusOnMount:M,toolbar:"fixed",toolbarContainer:X},Z):i.jsx("textarea",{ref:$,rows:1,value:b,readOnly:!e,onFocus:()=>{var g;if(e){U();return}(g=$.current)==null||g.blur(),t()},onChange:g=>j(g.target.value),"aria-label":"Votre commentaire",className:"w-full resize-none border-0 bg-transparent p-0 font-fontFamilySecondary text-3xs leading-body text-font-body outline-none"}),i.jsx("span",{"aria-hidden":"true",className:`${G.placeholder} ${M||A?G.placeholderGone:""}`,children:"Dites-nous ce que vous en pensez"})]}),e?i.jsx(Ne,{name:"arrow-up",size:16,rounded:!0,ariaLabel:o?"Enregistrer":"Publier",color:"inherit",disabled:!A||p,onClick:E,style:{"--action-button-background":A?"var(--hds-color-primary, #2f6fed)":"var(--hds-color-background-accent, rgb(243 244 252))","--action-button-color":A?"var(--hds-color-font-body-inverted, #fff)":"var(--hds-color-font-indicator, #6b7280)"},className:`${G.sendButton} shrink-0`}):i.jsx(be,{as:"a",href:f?void 0:n,color:"primary",variant:"contained",onClick:g=>{g.preventDefault(),t()},className:"shrink-0",children:"Se connecter"})]}),i.jsx("div",{className:`${G.toolbarRow} ${M||O?G.toolbarRowOpen:""}`,inert:M||O?void 0:!0,children:i.jsx("div",{className:G.toolbarRowInner,children:i.jsxs("div",{className:G.toolbarRowContent,children:[i.jsx("div",{ref:Q,className:`${G.toolbarControls} ${B?G.toolbarControlsReady:""}`}),q&&d&&O&&i.jsx(q,{tools:d,isLoggedIn:e,onRequireLogin:t})]})})})]})}const oo="slot___rsyZe",ro="slotOpen___gqxvS",io="slotFade___9Bifb",ao="fade___YCaCc",we={slot:oo,slotOpen:ro,slotFade:io,fade:ao},lo=3,it=i.jsx("header",{children:i.jsx("h2",{className:"m-0 font-fontFamilyPrimary text-m text-font-body",children:"Commentaires"})});function co({comment:e,onReadComment:t,itemProps:n}){const s=m.useRef(null),[o,r]=m.useState(!1),[a,l]=m.useState(!1);return m.useEffect(()=>{const c=s.current;if(!c)return;const u=()=>{r(c.scrollHeight>c.clientHeight+1),l(!0)};u();const d=new ResizeObserver(u);return d.observe(c),()=>d.disconnect()},[]),i.jsxs("li",{children:[i.jsxs("div",{ref:s,className:`${we.slot} ${a&&!o?we.slotOpen:""}`,children:[i.jsx(Ae,{comment:e,replies:e.replies,anchored:!1,...n}),o&&i.jsx("div",{"aria-hidden":"true",className:we.slotFade})]}),o&&i.jsxs("button",{type:"button",onClick:()=>t(e.id),className:"mx-auto mt-200 flex w-fit cursor-pointer items-center gap-100 rounded-full border-0 bg-background-block px-300 py-100 font-fontFamilySecondary text-4xs font-bold text-font-body",children:["Lire la suite",i.jsx(ne,{name:"caret-down",size:12,color:"inherit"})]})]})}function uo({comments:e,total:t,onOpen:n,onReadComment:s,composer:o,...r}){const a=Nt($e(e),r.moderatorView??!1),l=[...a.pinned,...a.thread].slice(0,lo),c=t>l.length;return l.length===0?i.jsxs("section",{"aria-label":"Commentaires",className:"flex flex-col gap-400",children:[it,i.jsx("button",{type:"button",onClick:n,className:"w-full cursor-pointer rounded-medium border-0 bg-background-block p-400 text-left font-fontFamilySecondary text-3xs text-font-indicator",children:"Aucun commentaire pour le moment. Lancez la discussion !"}),o]}):i.jsxs("section",{"aria-label":"Aperçu des commentaires",className:"flex flex-col gap-400",children:[it,i.jsxs("div",{className:"relative",children:[i.jsx("ul",{className:"comments-list m-0 flex list-none flex-col p-0 gap-500",children:l.map(u=>i.jsx(co,{comment:u,onReadComment:s,itemProps:{...r}},u.id))}),c&&i.jsx("div",{"aria-hidden":"true","data-testid":"comments-preview-fade",className:we.fade})]}),i.jsxs("button",{type:"button",onClick:n,className:"inline-flex items-center gap-200 self-start cursor-pointer rounded-full border-0 bg-background-block px-400 py-200 font-fontFamilySecondary text-3xs font-bold text-font-body",children:["Voir tous les commentaires",t>0&&i.jsx(_e,{variant:"default",size:"sm",children:t})]}),o]})}function mo(e){const[t,n]=m.useState(null);return m.useEffect(()=>{if(!e)return;const s=yn(window.location.hash);s!==null&&(window.history.replaceState(null,"",window.location.pathname+window.location.search),window.scrollTo({top:0,behavior:"instant"}),n(s))},[e]),t}function fo(e,t,n,s=0){const o=m.useRef(!1),r=m.useRef(0),[a,l]=m.useState(!1),[c,u]=m.useState(!1);m.useEffect(()=>{o.current=!1,r.current=0,l(!1),u(!1)},[e,s]);const{pages:d,isLoading:p,hasNextPage:f,isFetchingNextPage:h,fetchNextPage:x}=n;m.useEffect(()=>{let w=0;const j=()=>clearTimeout(w);return e===null||o.current||!t||p||!d||d.length===0?j:Xe(e)?(l(!0),o.current=!0,j):vn(d,e)?(w=window.setTimeout(()=>Xe(e),0),l(!0),o.current=!0,j):r.current>=_n||!f?(o.current=!0,j):(h||(r.current+=1,x()),j)},[d,p,f,h,e,t,s]);const N=a&&!c;return m.useEffect(()=>{if(!N)return;const w=()=>u(!0);return window.addEventListener("pointerdown",w),window.addEventListener("keydown",w),()=>{window.removeEventListener("pointerdown",w),window.removeEventListener("keydown",w)}},[N]),N}const po="header___v9ZBw",ho="body___ZzwWo",go="footer___Qyolu",xo="drawer___5M0Fl",bo="closedNotice___XXqdc",ue={header:po,body:ho,footer:go,drawer:xo,closedNotice:bo},wo="recent",_o=["comment-vote","comment-reaction"];function yo({postType:e,postId:t,isLoggedIn:n,loginUrl:s,pageUrl:o,articleId:r,articleType:a,initialThread:l,canPost:c=!0}){var ze,Qe,qe,Ve;const u={postType:e,postId:t},d=wo,[p,f]=m.useState(null),[h,x]=m.useState(null),[N,w]=m.useState(null),[j,H]=m.useState(null),[K,Z]=m.useState(null);zt(u,d);const[T,X]=m.useState(null),[Q,I]=m.useState(0),$=y=>{X(y),I(D=>D+1)},J=fn(u,d,$),L=hn(u,d),B=xn(u,d),M=Qt(u,d),U=wn(u,d),Y=ie(),{requireLogin:S,pendingIntent:W,isLoggedIn:O}=qt(`${e}:${t}`,n,_o);m.useEffect(()=>{!W||!O||W.kind==="comment-vote"&&M.mutate({commentId:W.commentId,value:W.value,active:!0})},[W,O]);const[q,he]=m.useState(!1);m.useEffect(()=>{he(!0)},[]);const b=mo(q),[R,_]=m.useState(null),v=R??b!==null;m.useEffect(()=>{!q||window.location.hash!=="#comments"||(window.history.replaceState(null,"",window.location.pathname+window.location.search),window.scrollTo({top:0,behavior:"instant"}),_(!0))},[q]);const E=nn(u,d,l,v),A=Vt(()=>_(!1)),V=Rt();m.useEffect(()=>(document.documentElement.classList.toggle("comments-drawer-open",v),v||(X(null),w(null)),()=>document.documentElement.classList.remove("comments-drawer-open")),[v]);const te=m.useRef(v);te.current=v,m.useEffect(()=>Gt(()=>_(!te.current)),[]),m.useEffect(()=>
5{O&&Y.invalidateQueries({queryKey:se(u,d)})},[O]);const g=fo(T??b,v,{pages:(ze=E.data)==null?void 0:ze.pages,isLoading:E.isLoading,hasNextPage:E.hasNextPage,isFetchingNextPage:E.isFetchingNextPage,fetchNextPage:()=>{E.fetchNextPage()}},Q)?T??b:null,C=((Qe=E.data)==null?void 0:Qe.pages)??[],P=((qe=C[0])==null?void 0:qe.total)??0,ee=((Ve=C[0])==null?void 0:Ve.canModerate)===!0,oe=C.flatMap(y=>y.comments),ae=T??b,ge=m.useMemo(()=>ae===null?null:Sn(C,ae),[C,ae]);m.useEffect(()=>{Ut({open:v,total:P})},[v,P]);const Oe=m.useMemo(()=>l?JSON.stringify(Nn(l,o,r,a)).replace(/</g,"\\u003c"):null,[l,o,r,a]),Fe=y=>{f(null),x({id:y.id,content:y.contentMarkdown??Se(y.contentHtml)})},He=i.jsxs(i.Fragment,{children:[E.isLoading&&i.jsx("p",{className:`${jt.notice} font-fontFamilySecondary text-3xs text-font-indicator`,children:"Chargement des commentairesâ¦"}),E.isError&&oe.length===0&&i.jsxs("p",{role:"alert",className:"font-fontFamilySecondary text-3xs text-font-body",children:["Impossible de charger les commentaires."," ",i.jsx("button",{type:"button",className:"underline bg-transparent border-0 cursor-pointer",onClick:()=>void E.refetch(),children:"Réessayer"})]}),!E.isLoading&&(E.data||!E.isError)&&i.jsx(Bs,{comments:oe,isLoggedIn:O,requireLogin:S,onEditIntent:c?Fe:void 0,onDelete:B,onVote:(y,D,z)=>M.mutate({commentId:y,value:D,active:z}),onReplyIntent:c?y=>{var D;f({id:y.id,authorName:y.authorName}),(D=document.getElementById(`comment-${y.id}`))==null||D.scrollIntoView({block:"nearest",behavior:"smooth"})}:void 0,expandRepliesFor:K??ge,highlightFor:(p==null?void 0:p.id)??g,moderatorView:ee,onModerate:(y,D)=>U(y,D)}),E.hasNextPage&&i.jsx("button",{type:"button",disabled:E.isFetchingNextPage,onClick:()=>void E.fetchNextPage(),className:"mt-300 font-fontFamilySecondary font-bold text-3xs text-primary bg-transparent border-0 cursor-pointer",children:E.isFetchingNextPage?"Chargementâ¦":"Voir plus de commentaires"})]}),Ie=i.jsx("p",{className:ue.closedNotice,children:"Les commentaires sont fermés pour cet article."}),Be=c?i.jsx(rt,{isLoggedIn:O,onRequireLogin:()=>S(null),loginUrl:s,replyingTo:p==null?void 0:p.authorName,editing:h??void 0,restoredDraft:N??void 0,error:(N==null?void 0:N.message)??null,onDraftCleared:()=>w(null),onCancelReply:()=>{f(null),x(null),w(null)},isSubmitting:J.isPending||L.isPending,onSubmit:(y,D)=>{if(h){const ce={id:h.id,content:y};L.mutate({commentId:ce.id,content:y,html:D},{onSuccess:()=>{F.success("Commentaire modifié"),$(ce.id)},onError:()=>x(ce)}),x(null);return}const z=p;w(null),J.mutate({content:y,html:D,parentId:(z==null?void 0:z.id)??0},{onError:ce=>{w({seq:Date.now(),content:y,message:Ze(ce)}),z&&f(z)}}),z&&Z(z.id),f(null)}}):Ie,kt=c?i.jsx("div",{style:{"--composer-bleed":"0px"},children:i.jsx(rt,{isLoggedIn:O,onRequireLogin:()=>S(null),loginUrl:s,restoredDraft:j??void 0,error:(j==null?void 0:j.message)??null,onDraftCleared:()=>H(null),onCancelReply:()=>{},isSubmitting:J.isPending,onSubmit:(y,D)=>{H(null),J.mutate({content:y,html:D,parentId:0},{onError:z=>H({seq:Date.now(),content:y,message:Ze(z)})})}})}):Ie;return i.jsxs("div",{children:[Oe&&i.jsx("script",{type:"application/ld+json",dangerouslySetInnerHTML:{__html:Oe}}),q?i.jsxs(i.Fragment,{children:[i.jsx(uo,{comments:oe,total:P,onOpen:()=>_(!0),onReadComment:y=>{X(y),_(!0)},isLoggedIn:O,requireLogin:S,onEditIntent:c?y=>{Fe(y),_(!0)}:void 0,onDelete:B,onVote:(y,D,z)=>M.mutate({commentId:y,value:D,active:z}),onReplyIntent:c?y=>{f({id:y.id,authorName:y.authorName}),_(!0)}:void 0,composer:kt,moderatorView:ee,onModerate:(y,D)=>U(y,D)}),i.jsx(at,{isOpen:v,onClose:()=>_(!1),closeOnClickOutside:!1,modal:!1,children:i.jsxs(lt,{mobileVariant:"bottom-drawer",desktopVariant:"side-right",size:"large",flush:!0,className:`${ue.drawer} max-md:h-[90dvh] max-md:max-h-[90dvh] !border !border-solid !border-background-separator shadow-[0_0_2rem_rgba(0,0,0,0.18)]`,style:{transform:A.offset?`translateY(${A.offset}px)`:void 0,transition:A.dragging?"none":void 0,height:V?`calc(90dvh + ${V}px)`:void 0,maxHeight:V?`calc(90dvh + ${V}px)`:void 0},children:[i.jsxs(ct,{className:`${ue.header} flex flex-col gap-300`,children:[i.jsx("span",{...A.handleProps,"aria-hidden":"true",className:"mx-auto h-[4px] w-[42px] curs
5or-grab rounded-full bg-font-indicator opacity-60 md:hidden"}),i.jsx("div",{className:"flex items-center gap-200 pr-800",children:i.jsxs(ut,{className:"flex items-center gap-200",children:["Commentaires",i.jsx(_e,{variant:"default",size:"sm",children:P})]})})]}),i.jsx(dt,{className:ue.body,style:{overflowX:"clip"},children:He}),i.jsx(mt,{className:ue.footer,children:Be})]})})]}):i.jsxs("section",{className:"flex flex-col gap-400",children:[i.jsxs("header",{className:"flex items-center gap-200",children:[i.jsx("h2",{className:"m-0 font-fontFamilyPrimary text-base text-font-body",children:"Commentaires"}),i.jsx(_e,{variant:"default",size:"sm",children:P})]}),Be,He]})]})}function Ro(e){const[t]=m.useState(()=>new It({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}));return i.jsx(Bt,{client:t,children:i.jsx(yo,{...e})})}export{Ro as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.