1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/useGscOAuthResult-BCfq4JPS.js","assets/vendor-LNsQq_cZ.js","assets/index-BlfuXllL.js","assets/index-dmJSJtx7.css","assets/jobPolling-DwXTAgbA.js"])))=>i.map(i=>d[i]); 2import{bS as Js,bT as Zs,D as vs,h as Ns,a4 as H,n as M,i as me,B as _e,bR as ne,bU as et,ay as $e,bV as st,Y as tt,bi as ue,bW as ks,bX as at,c as rt,d as ot,e as nt,g as it,bY as cs,bZ as ds,bP as lt,bQ as ct,U as ms,a0 as dt,$ as mt,_ as Ds,b_ as ut}from"./index-BlfuXllL.js";import{u as D,r as u,j as e,aw as te,ay as ve,e as _,aO as xe,bf as ae,a5 as Ce,bz as Ge,bA as ht,bB as xt,g as Ke,y as pt,_ as Ss,ap as _s,b3 as Oe,aT as Cs,aL as Ts,bC as bt,bD as gt,bE as ft,aI as Te,ax as Ne,q as yt,aR as jt,bF as wt,bG as ke,bH as ze,az as Ve,X as vt,I as Ue,bI as Nt,aA as us,b7 as kt,aF as Dt,at as St,bJ as He,bK as _t,aC as Ls,aX as Ct}from"./vendor-LNsQq_cZ.js";import{D as be}from"./DashboardLayout-BIjoE7W7.js";import{P as Tt}from"./PageHeader-B0op3_k6.js";import{P as As,u as Lt}from"./useProgressSteps-Ci-b5uPP.js";import{Q as Ps}from"./QuotaIndicator-DGiX0yJu.js";import{V as ge}from"./VisualStatCard-CORDrWJC.js";import{u as Be}from"./useRunGuard-D3li7yEt.js";import{u as At,P as Pt}from"./usePresencePillar-CU8JGrrF.js";import{u as Et}from"./useSeoDashboardAccess-BIyBZZxk.js";import{N as qt}from"./Footer-DYW6H5XG.js";import{N as Mt}from"./NoBulleEmptyState-BtDkF2m2.js";import{I as K}from"./InfoTip-CTRmmFPb.js";import{u as Es,o as We,l as Rt,c as It,r as $t,e as Ft,f as Gt,h as Kt,i as Ot,j as zt,k as Vt,m as Ut,n as Ht,p as qs,q as Bt,g as Ms,d as Wt,b as Yt,a as hs,s as Qt,t as Xt,v as Jt}from"./useGscOAuthResult-BCfq4JPS.js";import{x as Zt,E as Rs,X as ea,Y as Is,F as sa,R as ta,z as aa,U as ra}from"./UnifiedChart-CiLIBTLI.js";import{P as oa,L as V}from"./primitives-DVeGIww6.js";import"./HelpDocLink-CGO7_a1i.js";import"./ConsentLink-eGsqgkwE.js";import"./jobPolling-DwXTAgbA.js";import"./index-Dh4i1-J3.js";var na=Zt({chartName:"LineChart",GraphicalChild:Rs,axisComponents:[{axisType:"xAxis",AxisComp:ea},{axisType:"yAxis",AxisComp:Is}],formatAxisMap:sa});const ia=["gsc_connect","gsc_performance","ranked_keywords","competitors","keyword_opportunities","tracked_keywords","content_strategy","onpage_audit","pagespeed","other"],la={gsc_connect:"connections",gsc_performance:"performance",ranked_keywords:"performance",competitors:"performance",keyword_opportunities:"strategy",tracked_keywords:"strategy",content_strategy:"strategy",onpage_audit:"technical",pagespeed:"technical",other:null};function $s(s){return!!s&&ia.includes(s)}function ca(s){return $s(s.category)?la[s.category]:null}function da(s){return $s(s.category)&&s.category!=="other"}const Fs="seo_gsc_prompt";function ma(s,t){return`seo_gsc_prompt:${s}:${t}`}function ua(s,t){if(!s||!t)return!0;const r=Js(Fs,s,t);if(r===void 0||r==="true")return!0;try{return localStorage.getItem(ma(s,t))==="true"}catch{return!0}}function ha(s,t){!s||!t||Zs(Fs,s,t)}function xa(s){return s.skipNetwork||s.loadingInitial||s.scanning||!s.websiteUrl||!s.gscStatusKnown||s.gscConnected?!1:!s.alreadySeen}const pa=({isOpen:s,bulleId:t,onClose:r,onConnected:a})=>{const{t:o}=D(),[n,m]=u.useState(!1);Es(()=>{s&&a()},()=>{m(!1)});const i=async()=>{m(!0);try{await We(t)}catch(d){_.error(H(d,o("seoDashboard.gsc.cannotStart","Impossible de démarrer la connexion."))),m(!1)}},c=[{key:"clicks",titleKey:"seoDashboard.gscModal.benefits.clicks.title",titleFallback:"Vos clics réels",descKey:"seoDashboard.gscModal.benefits.clicks.desc",descFallback:"Le trafic Google mesuré, pas une estimation"},{key:"queries",titleKey:"seoDashboard.gscModal.benefits.queries.title",titleFallback:"Les requêtes exactes",descKey:"seoDashboard.gscModal.benefits.queries.desc",descFallback:"Ce que tapent vraiment vos visiteurs dans Google"},{key:"positions",titleKey:"seoDashboard.gscModal.benefits.positions.title",titleFallback:"Vos positions mesurées",descKey:"seoDashboard.gscModal.benefits.positions.desc",descFallback:"Le classement réel de vos pages dans les résultats Google"}];return e.jsx(vs,{open:s,onOpenChange:d=>!d&&r(),children:e.jsxs(Ns,{className:"max-w-md max-h-[90vh] overflow-y-auto p-0",children:[e.jsxs("div",{className:"px-6 sm:px-7 pt-7 pb-6",children:[e.jsx("h2",{className:"font-display text-2xl font-bold tracking-tight text-gray-900 mb-1.5",children:o("seoDashboard.gscModal.title","Connectez Google Search Console")}),e.jsx("p",{className:"text-[13px] font-medium text-brand-500 mb-4",children:o("seoDashboard.gscModal.subtitle","Vos vraies données Google dans le Dashboard SEO")}),e.jsx("p",{className:"text-[15px] leading-relaxed text-gray-600 mb-5",children:o("seoDashboard.gscModal.description","Search Console est l'outil gratuit de Google qui mesure votre présence dans les résultats de recherche. En le connectant, votre Dashboard SEO affiche vos données réelles plutôt que des estimations.")}),e.jsx("div",{className:"divide-y divide-gray-100 border-y border-gray-100",children:c.map(({key:d,titleKey:l,titleFallback:h,descKey:x,descFallback:w})=>e.jsxs("div",{className:"py-3",children:[e.jsx("div",{className:"text-sm font-semibold text-gray-900",children:o(l,h)}),e.jsx("div",{className:"text-[13px] text-gray-500",children:o(x,w)})]},d))})]}),e.jsxs("div",{className:"border-t border-gray-100 bg-white px-6 sm:px-7 py-4 flex items-center gap-3",children:[e.jsxs("button",{onClick:i,disabled:n,className:"flex-1 inline-flex items-center justify-center gap-2 px-5 py-3 rounded-lg text-white text-[15px] font-semibold bg-gradient-to-r from-brand-500 to-brand-600 hover:from-brand-600 hover:to-brand-700 shadow-md transition disabled:opacity-60",children:[n?e.jsx(te,{className:"w-4 h-4 animate-spin"}):e.jsx(ve,{className:"w-4 h-4"}),n?o("seoDashboard.gsc.connecting","Ouverture de Googleâ¦"):o("settings.searchConsole.connectButton","Connecter (1 clic)")]}),e.jsx("button",{onClick:r,className:"px-4 py-3 rounded-lg bg-gray-100 text-gray-600 text-sm font-semibold hover:bg-gray-200 transition",children:o("seoDashboard.gscModal.later","Plus tard")})]})]})})},xs=5,ps=({snapshot:s})=>{const{t}=D(),[r,a]=u.useState(!1),o=s.ranked_keywords,n=(o==null?void 0:o.keywords)||[],m=(o==null?void 0:o.total_count)||n.length,i=r?n:n.slice(0,xs);return e.jsxs("section",{className:"bg-white/70 backdrop-blur-xl border border-gray-200/60 rounded-2xl shadow-sm p-6",children:[e.jsx("div",{className:"flex items-center gap-3 pb-4 border-b border-gray-100 mb-4",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-900 flex items-center gap-1.5",children:[e.jsx("span",{children:t("seoDashboard.blocks.keywords.title","Mots-clés positionné
2s")}),e.jsx(K,{content:t("seoDashboard.blocks.keywords.titleTooltip","Ensemble des mots-clés sur lesquels votre site apparaît dans les 100 premiers résultats Google.")})]}),e.jsx("p",{className:"text-sm text-gray-500",children:t("seoDashboard.blocks.keywords.subtitle","{{count}} mots-clés où votre site apparaît dans les résultats Google",{count:m})})]})}),n.length===0?e.jsx(ba,{text:t("seoDashboard.blocks.keywords.empty","Votre site n'est positionné sur aucun mot-clé dans Google. C'est normal pour un site jeune, publier du contenu (via Article Manager) aidera à le faire émerger.")}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"overflow-x-auto -mx-2 px-2",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-xs text-gray-500 border-b border-gray-100",children:[e.jsx("th",{className:"text-left font-medium pb-3",children:t("seoDashboard.blocks.keywords.col.keyword","Mot-clé")}),e.jsx(Ee,{label:t("seoDashboard.blocks.keywords.col.position","Position"),tooltip:t("seoDashboard.blocks.keywords.col.positionTooltip","Position moyenne de votre site dans Google. Top 3 = excellent, â¤10 = page 1, 11-30 = pages 2-3, 31+ = à améliorer."),width:"w-24"}),e.jsx(Ee,{label:t("seoDashboard.blocks.keywords.col.volume","Volume/mois"),tooltip:t("seoDashboard.blocks.keywords.col.volumeTooltip","Nombre estimé de recherches mensuelles sur Google pour ce mot-clé."),width:"w-28"}),e.jsx(Ee,{label:t("seoDashboard.blocks.keywords.col.cpc","CPC"),tooltip:t("seoDashboard.blocks.keywords.col.cpcTooltip","Coût Par Clic moyen, ce que coûterait une publicité ciblant ce mot-clé."),width:"w-20"}),e.jsx("th",{className:"w-10"})]})}),e.jsx("tbody",{children:i.map((c,d)=>e.jsxs("tr",{className:"border-b border-gray-50 last:border-0 hover:bg-orange-50/30 transition-colors",children:[e.jsx("td",{className:"py-2.5 pr-3 font-medium text-gray-900",children:c.keyword}),e.jsx("td",{className:"py-2.5 text-right text-sm font-medium text-gray-900 tabular-nums",children:c.position>0?c.position:","}),e.jsx("td",{className:"py-2.5 text-right text-gray-700 tabular-nums",children:M(c.search_volume)}),e.jsx("td",{className:"py-2.5 text-right text-gray-700 tabular-nums",children:c.cpc?`${c.cpc.toFixed(2)}â¬`:","}),e.jsx("td",{className:"py-2.5 text-right",children:c.url&&e.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"text-gray-400 hover:text-orange-500 inline-flex transition-colors",title:c.url,children:e.jsx(xe,{className:"w-3.5 h-3.5"})})})]},d))})]})}),n.length>xs&&e.jsxs("button",{onClick:()=>a(c=>!c),className:"mt-4 w-full flex items-center justify-center gap-1.5 px-4 py-2.5 text-sm font-medium text-orange-500 hover:bg-orange-50 border border-dashed border-gray-200 hover:border-orange-200 rounded-xl transition-colors",children:[e.jsx(ae,{className:`w-4 h-4 transition-transform ${r?"rotate-180":""}`}),r?t("seoDashboard.blocks.keywords.showLess","Voir moins"):t("seoDashboard.blocks.keywords.showAll","Voir les {{count}} mots-clés",{count:n.length})]})]})]})},Ee=({label:s,tooltip:t,width:r})=>e.jsx("th",{className:`text-right font-medium pb-3 ${r}`,children:e.jsxs("span",{className:"inline-flex items-center gap-1 justify-end",children:[s,e.jsx(K,{content:t,width:240,size:"xs"})]})}),ba=({text:s})=>e.jsx("div",{className:"text-sm text-gray-500 leading-relaxed py-3",children:s}),bs=5,ga=({snapshot:s})=>{var m;const{t}=D(),r=((m=s.competitors)==null?void 0:m.competitors)||[],[a,o]=Ce.useState(!1),n=a?r:r.slice(0,bs);return e.jsxs("section",{className:"bg-white/70 backdrop-blur-xl border border-gray-200/60 rounded-2xl shadow-sm p-6",children:[e.jsx("div",{className:"flex items-center gap-3 pb-4 border-b border-gray-100 mb-4",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-900 flex items-center gap-1.5",children:[e.jsx("span",{children:t("seoDashboard.blocks.competitors.title","Concurrents organiques")}),e.jsx(K,{content:e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("strong",{className:"font-medium text-gray-900",children:t("seoDashboard.blocks.competitors.labelIntersections","Mots-clés en commun")})," ","· ",t("seoDashboard.blocks.competitors.titleTooltipIntersections","Vos concurrents et vous êtes positionné
2s sur les mêmes requêtes Google.")]}),e.jsxs("div",{className:"mt-1.5",children:[e.jsx("strong",{className:"font-medium text-gray-900",children:t("seoDashboard.blocks.competitors.labelAvgPosition","Position moyenne")})," ","· ",t("seoDashboard.blocks.competitors.titleTooltipAvgPosition","Leur classement Google sur l'ensemble de ces mots-clés.")]}),e.jsxs("div",{className:"mt-1.5",children:[e.jsx("strong",{className:"font-medium text-gray-900",children:t("seoDashboard.blocks.competitors.labelTraffic","Trafic estimé/mois")})," ","· ",t("seoDashboard.blocks.competitors.titleTooltipTraffic","Estimation basée sur le volume Google, leur position et le taux de clic moyen.")]})]})})]}),e.jsx("p",{className:"text-sm text-gray-500",children:t("seoDashboard.blocks.competitors.subtitle","Sites qui apparaissent sur les mêmes mots-clés que vous")})]})}),r.length===0?e.jsx("div",{className:"text-sm text-gray-500 leading-relaxed py-3",children:t("seoDashboard.blocks.competitors.empty","Aucun concurrent identifié pour ce site. Cela peut arriver pour un site très récent ou un secteur de niche.")}):e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"space-y-2",children:n.map((i,c)=>{const d=c<3;return e.jsxs("li",{className:"flex items-center justify-between gap-3 p-3 rounded-xl border border-gray-100 hover:border-orange-200 hover:bg-orange-50/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:`w-7 h-7 rounded-full text-xs font-bold flex items-center justify-center flex-shrink-0 tabular-nums ${d?"bg-orange-100 text-orange-700":"bg-gray-100 text-gray-600"}`,children:c+1}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("a",{href:`https://${i.domain}`,target:"_blank",rel:"noopener noreferrer",className:"font-medium text-gray-900 hover:text-orange-500 inline-flex items-center gap-1.5 truncate transition-colors",children:[i.domain,e.jsx(xe,{className:"w-3 h-3 text-gray-400 flex-shrink-0"})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-0.5",children:[t("seoDashboard.blocks.competitors.intersections","{{count}} mots-clés en commun",{count:i.intersections}),i.avg_position>0&&e.jsxs(e.Fragment,{children:[" · ",t("seoDashboard.blocks.competitors.avgPosition","position moyenne {{pos}}",{pos:Math.round(i.avg_position)})]})]})]})]}),e.jsxs("div",{className:"text-right flex-shrink-0",children:[e.jsx("div",{className:"text-sm font-semibold text-gray-900 tabular-nums",children:M(Math.round(i.etv))}),e.jsx("div",{className:"text-xs text-gray-500",children:t("seoDashboard.blocks.competitors.trafficEstimate","trafic estimé/mois")})]})]},c)})}),r.length>bs&&e.jsxs("button",{onClick:()=>o(i=>!i),className:"mt-4 w-full flex items-center justify-center gap-1.5 px-4 py-2.5 text-sm font-medium text-orange-500 hover:bg-orange-50 border border-dashed border-gray-200 hover:border-orange-200 rounded-xl transition-colors",children:[e.jsx(ae,{className:`w-4 h-4 transition-transform ${a?"rotate-180":""}`}),a?t("seoDashboard.blocks.competitors.showLess","Voir moins"):t("seoDashboard.blocks.competitors.showAll","Voir les {{count}} concurrents",{count:r.length})]})]})]})},fa={LCP:"Largest Contentful Paint : temps de chargement du plus gros élément visible. Objectif Google : < 2,5 s.",CLS:"Cumulative Layout Shift : stabilité visuelle. Objectif : < 0,1.",INP:"Interaction to Next Paint : temps de réponse de votre site quand l'utilisateur clique/tape. Objectif : < 200 ms.",FCP:"First Contentful Paint : moment où le premier texte/image s'affiche. Objectif : < 1,8 s."};function ya(s){return s==null?"text-slate-400":s>=90?"text-green-600":s>=50?"text-orange-500":"text-red-600"}function ja(s){return s==="FAST"?"bg-green-500":s==="AVERAGE"?"bg-orange-500":s==="SLOW"?"bg-red-500":"bg-slate-300"}const wa=({snapshot:s})=>{var c,d,l,h,x,w,p,b,v;const{t}=D(),r=s.pagespeed,a=(r==null?void 0:r.mobile)??((r==null?void 0:r.strategy)==="mobile"?r:null),o=(r==null?void 0:r.desktop)??((r==null?void 0:r.strategy)==="desktop"?r:null),[n,m]=Ce.useState(a!=null&&a.success?"mobile":o!=null&&o.success?"desktop":"mobile"),i=n==="mobile"?a:o;return!i||!i.success?null:e.jsxs("section",{className:"bg-white rounded-2xl border border-slate-200 p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 flex-wrap gap-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-orange-50 rounded-lg",children:e.jsx(Ge,{className:"w-5 h-5 text-orange-500"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-slate-900",children:t("seoDashboard.pageSpeed.title","Performance Google (PageSpeed Insights)")}),e.jsx("p",{className:"text-sm text-slate-500",children:t("seoDashboard.pageSpeed.subtitle","Scores Lighthouse + Core Web Vitals mesurés sur vos visiteurs Chrome")})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[((c=i.field_data)==null?void 0:c.overall)&&e.jsx("span",{className:`text-[10px] font-semibold px-2 py-0.5 rounded-full ${i.field_data.overall==="FAST"?"bg-green-50 text-green-700":i.field_data.overall==="AVERAGE"?"bg-orange-50 text-orange-500":"bg-red-50 text-red-700"}`,children:i.field_data.overall==="FAST"?"Rapide":i.field_data.overall==="AVERAGE"?"Moyen":"Lent"}),e.jsxs("div",{className:"inline-flex bg-white rounded-lg p-0.5 border border-slate-200",children:[e.jsxs("button",{onClick:()=>m("mobile"),disabled:!(a!=null&&a.success),className:`inline-flex items-center gap-1 px-2.5 py-1 text-xs font-medium rounded-md transition-colors ${n==="mobile"?"bg-slate-800 text-white":"text-slate-600 hover:bg-slate-50 disabled:opacity-40"}`,children:[e.jsx(ht,{className:"w-3 h-3"})," Mobile"]}),e.jsxs("button",{onClick:()=>m("desktop"),disabled:!(o!=null&&o.success),className:`inline-flex items-center gap-1 px-2.5 py-1 text-xs font-medium rounded-md transition-colors ${n==="desktop"?"bg-slate-800 text-white":"text-slate-600 hover:bg-slate-50 disabled:opacity-40"}`,children:[e.jsx(xt,{className:"w-3 h-3"})," Desktop"]})]})]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 mb-4",children:[{label:t("seoDashboard.blocks.onpage.scores.performance","Performance"),score:i.scores.performance},{label:t("seoDashboard.blocks.onpage.scores.accessibility","Accessibilité"),score:i.scores.accessibility},{label:t("seoDashboard.blocks.onpage.scores.seo","SEO"),score:i.scores.seo},{label:t("seoDashboard.blocks.onpage.scores.bestPractices","Best practices"),score:i.scores.best_practices}].map(g=>e.jsxs("div",{className:"bg-slate-50 rounded-lg p-3 text-center border border-slate-100",children:[e.jsx("div",{className:`text-3xl font-bold ${ya(g.score)}`,children:g.score!=null?g.score:","}),e.jsx("div",{className:"text-[11px] text-slate-500 uppercase tracking-wide mt-1",children:g.label})]},g.label))}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[{label:"LCP",hint:"Vitesse",value:i.core_web_vitals.lcp,cat:(l=(d=i.field_data)==null?void 0:d.lcp)==null?void 0:l.category},{label:"CLS",hint:"Stabilité",value:i.core_web_vitals.cls,cat:(x=(h=i.field_data)==null?void 0:h.cls)==null?void 0:x.category},{label:"INP",hint:"Réactivité",value:i.core_web_vitals.inp,cat:(p=(w=i.field_data)==null?void 0:w.inp)==null?void 0:p.category},{label:"FCP",hint:"1er affichage",value:i.core_web_vitals.fcp,cat:(v=(b=i.field_data)==null?void 0:b.fcp)==null?void 0:v.category}].map(g=>e.jsxs("div",{className:"bg-white rounded-lg p-2.5 border border-slate-100",title:fa[g.label]||"",children:[e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-xs font-semibold text-slate-700",children:g.label}),g.cat&&e.jsx("span",{className:`inline-block w-2 h-2 rounded-full ${ja(g.cat)}`})]}),e.jsx("div",{className:"text-base font-semibold text-slate-900",children:g.value||","}),e.jsx("div",{className:"text-[10px] text-slate-400 mt-0.5",children:g.hint})]},g.label))}),e.jsxs("div",{className:"mt-3 text-[10px] text-slate-500 flex flex-wrap items-center gap-3",children:[e.jsx("span",{children:"Pastille = mesure réelle visiteurs Chrome 28 derniers jours :"}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-green-500"})," Rapide"]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-orange-500"})," Moyen"]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-red-500"})," Lent"]})]})]})};function va(s){return s>=.66?"high":s>=.33?"medium":"low"}function Na(s){const t=(s||"").toUpperCase();return t==="HIGH"?"high":t==="MEDIUM"?"medium":t==="LOW"?"low":null}const ka={low:{count:1,iconColor:"text-emerald-600",textColor:"text-emerald-700",tooltipKey:"seoDashboard.competitionLevel.tooltipLow",labelKey:"seoDashboard.competitionLevel.low"},medium:{count:2,iconColor:"text-amber-600",textColor:"text-amber-700",tooltipKey:"seoDashboard.competitionLevel.tooltipMedium",labelKey:"seoDashboard.competitionLevel.medium"},high:{count:3,iconColor:"text-rose-600",textColor:"text-rose-700",tooltipKey:"seoDashboard.competitionLevel.tooltipHigh",labelKey:"seoDashboard.competitionLevel.high"}},qe=({className:s})=>e.jsx("svg",{className:s,fill:"currentColor",viewBox:"0 0 16 16","aria-hidden":"true",children:e.jsx("path",{d:"M8 0a3.5 3.5 0 100 7 3.5 3.5 0 000-7zm0 8c-3.31 0-6 2.5-6 5.5V16h12v-2.5C14 10.5 11.31 8 8 8z"})}),Gs=({competition:s,level:t,size:r="sm",showLabel:a=!0,labelSize:o="xs"})=>{const{t:n}=D(),m=s!=null?va(s):Na(t||"")??"low",i=ka[m],c=r==="md"?"w-4 h-4":"w-3.5 h-3.5",d=o==="base"?"text-base font-semibold":"text-xs font-medium";return e.jsxs("span",{className:"inline-flex items-center gap-1",title:n(i.tooltipKey),children:[e.jsxs("span",{className:"inline-flex -space-x-0.5","aria-hidden":"true",children:[e.jsx(qe,{className:`${c} ${i.count>=1?i.iconColor:"text-gray-200"}`}),e.jsx(qe,{className:`${c} ${i.count>=2?i.iconColor:"text-gray-200"}`}),e.jsx(qe,{className:`${c} ${i.count>=3?i.iconColor:"text-gray-200"}`})]}),a&&e.jsx("span",{className:`${d} ${i.textColor}`,children:n(i.labelKey)})]})},gs=5,Da=({snapshot:s})=>{var c;const{t}=D(),r=Ke(),a=((c=s.keyword_suggestions)==null?void 0:c.keywords)||[],[o,n]=Ce.useState(!1),m=o?a:a.slice(0,gs),i=(d,l,h)=>{const x=new URLSearchParams({action:"create",seed:d});l&&x.set("volume",String(l)),h&&x.set("cpc",String(h)),r(`/dashboard/articles?${x.toString()}`)};return e.jsxs("section",{className:"bg-white/70 backdrop-blur-xl border border-gray-200/60 rounded-2xl shadow-sm p-6",children:[e.jsx("div",{className:"flex items-center gap-3 pb-4 border-b border-gray-100 mb-4",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-900 flex items-center gap-1.5",children:[e.jsx("span",{children:t("seoDashboard.blocks.suggestions.title","Mots-clés à exploiter")}),e.jsx(K,{content:t("seoDashboard.blocks.suggestions.titleTooltip","Idées de mots-clés à fort potentiel selon votre activité et votre zone. Cliquez pour générer un contenu optimisé qui vous fera apparaître sur ces requêtes.")})]}),e.jsx("p",{className:"text-sm text-gray-500",children:t("seoDashboard.blocks.suggestions.subtitle","Idées de contenus pour booster votre référencement")})]})}),a.length===0?e.jsxs("div",{className:"text-sm text-gray-500 leading-relaxed py-3 space-y-2",children:[e.jsx("p",{children:t("seoDashboard.blocks.suggestions.empty","Pas de suggestions générées pour ce scan.")}),s.page_context&&e.jsx("p",{className:"text-xs",children:e.jsx(pt,{i18nKey:"seoDashboard.blocks.suggestions.scrapedContext",values:{title:s.page_context.title||s.page_context.h1||"(vide)"},components:{1:e.jsx(Ss,{to:"/dashboard/parametres#general",className:"text-orange-500 underline font-medium hover:text-orange-600 transition-colors"})}})})]}):e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"space-y-2",children:m.map((d,l)=>e.jsxs("li",{className:"flex items-center justify-between gap-3 p-3 rounded-xl border border-gray-100 hover:border-orange-200 hover:bg-orange-50/30 transition-colors",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 truncate",children:d.keyword}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1 flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsx("span",{className:"tabular-nums",children:t("seoDashboard.blocks.suggestions.volume","{{volume}} recherches/mois",{volume:M(d.search_volume||0)})}),d.cpc>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{className:"tabular-nums",children:t("seoDashboard.blocks.suggestions.cpc","CPC {{cpc}}â¬",{cpc:d.cpc.toFixed(2)})})]}),e.jsx("span",{children:"·"}),e.jsx(Gs,{competition:d.competition})]})]}),e.jsx("button",{onClick:()=>i(d.keyword,d.search_volume,d.cpc),title:t("seoDashboard.blocks.suggestions.generateTitle","Créer un article sur ce mot-clé"),className:"flex-shrink-0 inline-flex items-center justify-center w-8 h-8 text-gray-600 hover:text-orange-500 bg-white hover:bg-orange-50 border border-gray-200 hover:border-orange-200 rounded-lg transition-colors",children:e.jsx(Sa,{})})]},l))}),a.length>gs&&e.jsxs("button",{onClick:()=>n(d=>!d),className:"mt-4 w-full flex items-center justify-center gap-1.5 px-4 py-2.5 text-sm font-medium text-orange-500 hover:bg-orange-50 border border-dashed border-gray-200 hover:border-orange-200 rounded-xl transition-colors",children:[e.jsx(ae,{className:`w-4 h-4 transition-transform ${o?"rotate-180":""}`}),o?t("seoDashboard.blocks.suggestions.showLess","Voir moins"):t("seoDashboard.blocks.suggestions.showAll","Voir les {{count}} suggestions",{count:a.length})]})]})]})},Sa=()=>e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.5 3.5a2.121 2.121 0 113 3L7 19l-4 1 1-4L16.5 3.5z"})}),_a=({bulleId:s,quota:t,onQuotaUpdate:r})=>{const{t:a}=D(),[o,n]=u.useState(""),[m,i]=u.useState(!1),[c,d]=u.useState(null),[l,h]=u.useState(null),w=t.lookups.remaining<=0,p=async()=>{const b=o.trim();if(b){i(!0),h(null);try{const v=await Rt(s,b);if(!(v!=null&&v.result)||!(v!=null&&v.quota))throw new Error(a("seoDashboard.blocks.keywordSearch.failed","La recherche a échoué."));d(v.result),r(v.quota)}catch(v){const g=H(v,a("seoDashboard.blocks.keywordSearch.failed","La recherche a échoué."));h(g),_.error(g)}finally{i(!1)}}};return e.jsxs("section",{className:"bg-white/70 backdrop-blur-xl border border-gray-200/60 rounded-2xl shadow-sm p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 pb-4 border-b border-gray-100 mb-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-900 flex items-center gap-1.5",children:[e.jsx("span",{children:a("seoDashboard.blocks.keywordSearch.title","Rechercher un mot-clé")}),e.jsx(K,{content:a("seoDashboard.blocks.keywordSearch.titleTooltip","Saisissez n'importe quel mot-clé pour obtenir son volume de recherche Google, sa concurrence, son CPC et 5 variantes proches.")})]}),e.jsx("p",{className:"text-sm text-gray-500",children:a("seoDashboard.blocks.keywordSearch.subtitle","Volume, concurrence et variantes pour n'importe quel mot-clé")})]}),e.jsx(Ps,{used:t.lookups.used,max:t.lookups.quota,className:"flex-shrink-0"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx("input",{type:"text",value:o,onChange:b=>n(b.target.value),onKeyDown:b=>b.key==="Enter"&&!m&&!w&&p(),placeholder:a("seoDashboard.blocks.keywordSearch.placeholder","ex: meilleure recette de bourguignon"),disabled:m||w,className:"flex-1 px-4 py-2.5 border border-gray-200 rounded-xl focus:outline-none focus:ring-2 focus:ring-orange-300 focus:border-orange-300 text-gray-900 text-sm placeholder:text-gray-400 disabled:bg-gray-50",maxLength:200}),e.jsx(me,{disabled:w||!o.trim(),onDisabledClick:()=>{w?_.warning(a("seoDashboard.blocks.keywordSearch.blocked.quotaReached","Quota de recherches atteint")):o.trim()||_.warning(a("seoDashboard.blocks.keywordSearch.blocked.keywordRequired","Saisissez un mot-clé"))}
2,children:e.jsx(_e,{size:"lg",radius:"xl",onClick:p,disabled:w||!o.trim(),isLoading:m,loadingLabel:a("seoDashboard.blocks.keywordSearch.searching","Rechercheâ¦"),leftIcon:e.jsx(_s,{className:"w-4 h-4"}),className:"w-full text-sm min-w-[140px]",children:a("seoDashboard.blocks.keywordSearch.search","Rechercher")})})]}),w&&e.jsx("div",{className:"mt-2 text-xs text-red-600",children:a("seoDashboard.blocks.keywordSearch.quotaReached","Quota mensuel atteint ({{used}}/{{quota}}).",{used:t.lookups.used,quota:t.lookups.quota})}),l&&e.jsx("div",{className:"mt-3 p-3 bg-red-50 border border-red-200 rounded-lg text-sm text-red-700",children:l}),c&&!l&&e.jsx(Ca,{result:c})]})},Ca=({result:s})=>{const{t}=D(),r=Ke(),a=s.main,o=(n,m,i)=>{const c=new URLSearchParams({action:"create",seed:n});m&&c.set("volume",String(m)),i&&c.set("cpc",String(i)),r(`/dashboard/articles?${c.toString()}`)};return e.jsxs("div",{className:"mt-5 pt-5 border-t border-gray-100 space-y-5",children:[a?e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2 mb-3 flex-wrap",children:[e.jsx("h4",{className:"text-base font-semibold text-gray-900",children:a.keyword}),e.jsx("span",{className:"text-xs text-gray-500",children:t("seoDashboard.blocks.keywordSearch.mainTitle","Mot-clé analysé")})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsx(fe,{label:t("seoDashboard.blocks.keywordSearch.volume","Volume/mois"),tooltip:t("seoDashboard.blocks.keywordSearch.volumeTooltip","Nombre estimé de recherches mensuelles sur Google pour ce mot-clé."),value:M(a.search_volume||0)}),e.jsx(fe,{label:t("seoDashboard.blocks.keywordSearch.competition","Concurrence"),tooltip:t("seoDashboard.blocks.keywordSearch.competitionTooltip","Niveau de concurrence pour se positionner : Faible = facile, Forte = difficile."),customValue:e.jsx("div",{className:"mt-1",children:e.jsx(Gs,{competition:a.competition,level:a.competition_level,size:"md",labelSize:"base"})})}),e.jsx(fe,{label:"CPC",tooltip:t("seoDashboard.blocks.keywordSearch.cpcTooltip","Coût Par Clic moyen, ce que coûterait une publicité ciblant ce mot-clé."),value:a.cpc?`${a.cpc.toFixed(2)}â¬`:","}),e.jsx(fe,{label:t("seoDashboard.blocks.keywordSearch.difficulty","Indice"),tooltip:t("seoDashboard.blocks.keywordSearch.difficultyTooltip","Score sur 100 : plus c'est haut, plus c'est difficile de se positionner."),value:`${Math.round((a.competition||0)*100)}`,suffix:"/100",progressBar:{pct:Math.round((a.competition||0)*100),color:"bg-orange-400"}})]})]}):e.jsx("div",{className:"text-sm text-gray-500 leading-relaxed py-3",children:t("seoDashboard.blocks.keywordSearch.noMain","Pas de données précises pour ce mot-clé (peut arriver pour des termes très spécifiques).")}),s.related&&s.related.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] text-gray-500 uppercase tracking-wide font-semibold mb-2",children:t("seoDashboard.blocks.keywordSearch.related","Variantes proches")}),e.jsx("ul",{className:"space-y-2",children:s.related.map((n,m)=>e.jsxs("li",{className:"flex items-center justify-between gap-3 p-2.5 rounded-lg border border-gray-100 hover:border-orange-200 hover:bg-orange-50/30 transition-colors",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-sm text-gray-900 truncate",children:n.keyword}),e.jsxs("div",{className:"text-xs text-gray-500",children:[e.jsxs("span",{className:"tabular-nums",children:[M(n.search_volume||0)," recherches/mois"]})," ","·"," ",e.jsx("span",{className:"tabular-nums",children:n.cpc>0?`CPC ${n.cpc.toFixed(2)}â¬`:"CPC non dispo"})]})]}),e.jsx("button",{onClick:()=>o(n.keyword,n.search_volume,n.cpc),title:t("seoDashboard.blocks.suggestions.generateTitle","Créer un article sur ce mot-clé"),className:"flex-shrink-0 inline-flex items-center justify-center w-8 h-8 text-gray-600 hover:text-orange-500 bg-white hover:bg-orange-50 border border-gray-200 hover:border-orange-200 rounded-lg transition-colors",children:e.jsx(Ta,{})})]},m))})]})]})},fe=({label:s,tooltip:t,value:r,suffix:a,customValue:o,progressBar:n})=>e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl p-4",children:[e.jsxs("div",{className:"text-[11px] text-gray-500 flex items-center gap-1 mb-1",children:[e.jsx("span",{children:s}),e.jsx(K,{content:t,width:224,size:"xs"})]}),o??e.jsxs("div",{className:"text-2xl font-semibold text-gray-900 tabular-nums leading-tight",children:[r,a&&e.jsx("span",{className:"text-base text-gray-400",children:a})]}),n&&e.jsx("div",{className:"w-full h-1 bg-gray-100 rounded-full overflow-hidden mt-2",children:e.jsx("div",{className:`h-full ${n.color}`,style:{width:`${Math.min(100,Math.max(0,n.pct))}%`}})})]}),Ta=()=>e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.5 3.5a2.121 2.121 0 113 3L7 19l-4 1 1-4L16.5 3.5z"})}),La="bg-slate-200 rounded animate-pulse",R=({w:s="w-full",h:t="h-3",className:r=""})=>e.jsx("div",{className:`${La} ${s} ${t} ${r}`}),de=({className:s="",children:t})=>e.jsx("div",{className:`bg-white rounded-2xl border border-slate-200 p-6 ${s}`,children:t}),Ks=({rows:s=5})=>e.jsxs(de,{children:[e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsx(R,{w:"w-40",h:"h-4"}),e.jsx(R,{w:"w-60",h:"h-3"})]}),e.jsx("div",{className:"space-y-3",children:Array.from({length:s}).map((t,r)=>e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(R,{w:"w-full",h:"h-3"})},r))})]}),Ye=({rows:s=6,cols:t=4})=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`2fr ${"1fr ".repeat(t-1)}`},children:Array.from({length:t}).map((r,a)=>e.jsx(R,{h:"h-2.5",w:a===0?"w-20":"w-12"},a))}),Array.from({length:s}).map((r,a)=>e.jsx("div",{className:"grid gap-2 py-2 border-b border-slate-100",style:{gridTemplateColumns:`2fr ${"1fr ".repeat(t-1)}`},children:Array.from({length:t}).map((o,n)=>e.jsx(R,{h:"h-3",w:n===0?`w-${["3/4","5/6","2/3","4/5"][a%4]}`:"w-10"},n))},a))]}),Os=()=>e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-end gap-3",children:[e.jsx(R,{w:"w-20",h:"h-8"}),e.jsx(R,{w:"w-32",h:"h-3"})]}),e.jsx("div",{className:"h-56 bg-slate-100 rounded-xl animate-pulse"})]}),Aa=()=>e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:Array.from({length:4}).map((s,t)=>e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl p-4 space-y-3 animate-pulse",children:[e.jsx("div",{className:"w-4 h-4 bg-slate-200 rounded"}),e.jsx(R,{w:"w-16",h:"h-7"}),e.jsx(R,{w:"w-24",h:"h-3"})]},t))}),Pa=()=>e.jsxs("div",{className:"space-y-4",children:[e.jsx(Aa,{}),e.jsx(de,{className:"!p-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 bg-slate-200 rounded-lg animate-pulse flex-shrink-0"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(R,{w:"w-32",h:"h-3"}),e.jsx(R,{w:"w-56",h:"h-4"})]}),e.jsx("div",{className:"h-10 w-36 bg-slate-200 rounded-xl animate-pulse flex-shrink-0 hidden sm:block"})]})}),e.jsx(zs,{count:5}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4 items-start",children:[e.jsx(de,{className:"lg:col-span-2",children:e.jsx(Os,{})}),e.jsx(Ks,{rows:4})]})]}),zs=({count:s=5})=>e.jsx("div",{className:"flex gap-1 bg-white/85 border border-gray-200/60 p-1.5 rounded-full w-max max-w-full",children:Array.from({length:s}).map((t,r)=>e.jsx("div",{className:"h-9 w-28 bg-slate-100 rounded-full animate-pulse"},r))}),Ea=()=>e.jsxs("div",{className:"mt-2",children:[e.jsx(zs,{count:5}
2),e.jsxs("div",{className:"space-y-4 mt-6",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4 items-start",children:[e.jsxs(de,{className:"lg:col-span-2",children:[e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsx(R,{w:"w-40",h:"h-4"}),e.jsx(R,{w:"w-60",h:"h-3"})]}),e.jsx(Os,{})]}),e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-slate-100 animate-pulse flex-shrink-0"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{w:"w-36",h:"h-4"}),e.jsx(R,{w:"w-44",h:"h-3"})]})]})})]}),e.jsxs(de,{children:[e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsx(R,{w:"w-36",h:"h-4"}),e.jsx(R,{w:"w-56",h:"h-3"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{w:"w-full",h:"h-3"}),e.jsx(R,{w:"w-11/12",h:"h-3"}),e.jsx(R,{w:"w-10/12",h:"h-3"})]})]})]})]}),qa=({bulleId:s,hasWebsiteUrl:t,refreshQuota:r,onQuotaChange:a})=>{const{t:o}=D(),n=Be(s),[m,i]=u.useState([]),[c,d]=u.useState(50),[l,h]=u.useState(!0),[x,w]=u.useState(!1),[p,b]=u.useState(!1),[v,g]=u.useState("");n.onScopeChange(()=>b(!1)),u.useEffect(()=>{if(s){if(ne(s)){const k=et();i(k.tracked_keywords),d(k.max_per_bulle),h(!1);return}h(!0),It(s).then(k=>{i(k.tracked_keywords??[]),d(k.max_per_bulle??50)}).catch(()=>i([])).finally(()=>h(!1))}},[s]);const S=async()=>{const k=v.trim();if(k){w(!0);try{const j=await Ft(s,k);i(T=>[j.tracked_keyword,...T]),g(""),_.success(o("seoDashboard.blocks.trackedKeywords.added","Mot-clé suivi ajouté : « {{keyword}} »",{keyword:j.tracked_keyword.keyword}))}catch(j){_.error(H(j,o("seoDashboard.blocks.trackedKeywords.addFailed","Impossible d'ajouter ce mot-clé.")))}finally{w(!1)}}},[y,E]=u.useState(null),[C,N]=u.useState(!1),P=k=>E(k),A=async()=>{if(y){N(!0);try{await Gt(s,y.id),i(k=>k.filter(j=>j.id!==y.id)),E(null)}catch(k){_.error(H(k,o("seoDashboard.blocks.trackedKeywords.deleteFailed","Suppression impossible.")))}finally{N(!1)}}},O=async()=>{const k=n.begin(s,"refresh");b(!0);try{const j=await $t(s,{shouldAbort:k.isStale});if(k.isStale())return;i(j.tracked_keywords),j.quota&&(a==null||a(j.quota)),j.recap.failed>0?_.warning(o("seoDashboard.blocks.trackedKeywords.refreshedPartial","{{count}} mots-clés rafraîchis, {{failed}} n'ont pas pu être mesurés.",{count:j.recap.checked,failed:j.recap.failed})):_.success(o("seoDashboard.blocks.trackedKeywords.refreshed","{{count}} mots-clés rafraîchis.",{count:j.recap.checked}))}catch(j){if(k.isStale())return;_.error(H(j,o("seoDashboard.blocks.trackedKeywords.refreshFailed","Rafraîchissement impossible.")))}finally{k.isStale()||b(!1)}},q=m.length>=c,G=!!(r&&!r.is_unlimited&&r.remaining<=0),B=G?o("seoDashboard.blocks.trackedKeywords.blocked.quota","Quota de rafraîchissements atteint pour ce mois. Vos positions sont aussi remises à jour à chaque scan complet."):r&&!r.is_unlimited?o("seoDashboard.blocks.trackedKeywords.refreshAllTitleQuota","Rafraîchir tous les mots-clés ({{remaining}} restants ce mois-ci)",{remaining:r.remaining}):o("seoDashboard.blocks.trackedKeywords.refreshAllTitle","Rafraîchir tous les mots-clés");return e.jsxs("section",{className:"bg-white/70 backdrop-blur-xl border border-gray-200/60 rounded-2xl shadow-sm p-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 pb-4 border-b border-gray-100 mb-4 flex-wrap",children:[e.jsx("div",{className:"flex items-center gap-3 min-w-0",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-900 flex items-center gap-1.5",children:[e.jsx("span",{children:o("seoDashboard.blocks.trackedKeywords.title","Mots-clés suivis")}),e.jsx(K,{content:o("seoDashboard.blocks.trackedKeywords.titleTooltip","Ajoutez vos mots-clés stratégiques pour mesurer leur position Google à chaque scan. Idéal pour vérifier l'impact de vos publications sur des requêtes précises.")})]}),e.jsx("p",{className:"text-sm text-gray-500",children:o("seoDashboard.blocks.trackedKeywords.subtitle","Vos mots-clés stratégiques, mesurés à chaque scan ({{count}}/{{max}})",{count:m.length,max:c})})]})}),m.length>0&&e.jsx(me,{disabled:G&&!p,onDisabledClick:()=>_.warning(o("seoDashboard.blocks.trackedKeywords.blocked.quota","Quota de rafraîchissements atteint pour ce mois. Vos positions sont aussi remises à jour à chaque scan complet.")),children:e.jsx("button",{onClick:O,disabled:p||G,title:B,className:"flex-shrink-0 inline-flex items-center justify-center w-8 h-8 text-gray-600 hover:text-orange-500 bg-white hover:bg-orange-50 border border-gray-200 hover:border-orange-200 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:p?e.jsx(te,{className:"w-4 h-4 animate-spin"}):e.jsx(Oe,{className:"w-4 h-4"})})})]}),t?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 mb-4",children:[e.jsx("input",{type:"text",value:v,onCh
2ange:k=>g(k.target.value),onKeyDown:k=>k.key==="Enter"&&!x&&!q&&S(),placeholder:o("seoDashboard.blocks.trackedKeywords.placeholder","ex: traitement termites Paris"),disabled:x||q,maxLength:200,className:"flex-1 px-4 py-2.5 border border-gray-200 rounded-xl focus:outline-none focus:ring-2 focus:ring-orange-300 focus:border-orange-300 text-gray-900 text-sm placeholder:text-gray-400 disabled:bg-gray-50"}),e.jsx(me,{disabled:q||!v.trim(),onDisabledClick:()=>{q?_.warning(o("seoDashboard.blocks.trackedKeywords.blocked.atLimit","Limite de mots-clés suivis atteinte")):v.trim()||_.warning(o("seoDashboard.blocks.trackedKeywords.blocked.keywordRequired","Saisissez un mot-clé à suivre"))},children:e.jsx(_e,{size:"lg",radius:"xl",onClick:S,disabled:q||!v.trim(),isLoading:x,leftIcon:e.jsx(Cs,{className:"w-4 h-4"}),className:"w-full text-sm",children:o("seoDashboard.blocks.trackedKeywords.add","Ajouter")})})]}),q&&e.jsx("div",{className:"text-xs text-gray-500 mb-3",children:o("seoDashboard.blocks.trackedKeywords.atLimit","Limite atteinte ({{max}} mots-clés max). Supprimez-en un avant d'en ajouter d'autres.",{max:c})}),l?e.jsx(Ye,{rows:4,cols:5}):m.length===0?e.jsx("div",{className:"text-sm text-gray-500 leading-relaxed py-3",children:o("seoDashboard.blocks.trackedKeywords.empty","Pas encore de mots-clés suivis. Ajoutez-en pour mesurer leur progression dans Google chaque mois.")}):e.jsx("div",{className:"overflow-x-auto -mx-2 px-2",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-xs text-gray-500 border-b border-gray-100",children:[e.jsx("th",{className:"text-left font-medium pb-3",children:o("seoDashboard.blocks.trackedKeywords.col.keyword","Mot-clé")}),e.jsx(ye,{label:o("seoDashboard.blocks.trackedKeywords.col.position","Position"),tooltip:o("seoDashboard.blocks.trackedKeywords.col.positionTooltip",'Position actuelle de votre site dans Google sur ce mot-clé. "," = trop loin pour être mesuré.'),width:"w-24"}),e.jsx(ye,{label:o("seoDashboard.blocks.trackedKeywords.col.delta","Ãvol."),tooltip:o("seoDashboard.blocks.trackedKeywords.col.deltaTooltip","Gain ou perte de positions depuis la dernière mesure. +3 = vous êtes monté de 3 places."),width:"w-20"}),e.jsx(ye,{label:o("seoDashboard.blocks.trackedKeywords.col.trend","Tendance"),tooltip:o("seoDashboard.blocks.trackedKeywords.col.trendTooltip","Ãvolution de la position sur l'ensemble des mesures effectuées."),width:"w-24",align:"center"}),e.jsx(ye,{label:o("seoDashboard.blocks.trackedKeywords.col.volume","Vol/mois"),tooltip:o("seoDashboard.blocks.trackedKeywords.col.volumeTooltip","Nombre estimé de recherches mensuelles sur Google pour ce mot-clé."),width:"w-24"}),e.jsx("th",{className:"w-8"})]})}),e.jsx("tbody",{children:m.map(k=>e.jsx(Ma,{kw:k,onDelete:P},k.id))})]})})]}):e.jsx("div",{className:"text-sm text-gray-500 leading-relaxed py-3",children:o("seoDashboard.blocks.trackedKeywords.needWebsite","Renseignez d'abord l'URL du site web (en haut de la page) pour suivre vos mots-clés.")}),e.jsx($e,{isOpen:y!==null,title:o("seoDashboard.blocks.trackedKeywords.confirmDelete.title","Arrêter de suivre ce mot-clé ?"),subtitle:y==null?void 0:y.keyword,description:o("seoDashboard.blocks.trackedKeywords.confirmDelete.description","L'historique de position sera perdu. Vous pourrez recommencer à suivre ce mot-clé plus tard."),confirmLabel:o("seoDashboard.blocks.trackedKeywords.stopTracking","Arrêter le suivi"),loading:C,onConfirm:A,onCancel:()=>E(null)})]})},ye=({label:s,tooltip:t,width:r,align:a="right"})=>{const o=a==="center"?"justify-center":"justify-end";return e.jsx("th",{className:`${a==="center"?"text-center":"text-right"} font-medium pb-3 ${r}`,children:e.jsxs("span",{className:`inline-flex items-center gap-1 ${o}`,children:[s,e.jsx(K,{content:t,width:240,size:"xs"})]})})},Ma=({kw:s,onDelete:t})=>{const{t:r}=D();return e.jsxs("tr",{className:"border-b border-gray-50 last:border-0 hover:bg-orange-50/30 transition-colors",children:[e.jsxs("td",{className:"py-2.5 pr-3",children:[e.jsx("div",{className:"font-medium text-gray-900",children:s.keyword}),s.last_url?e.jsxs("a",{href:s.last_url,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-gray-500 hover:text-orange-500 inline-flex items-center gap-1 transition-colors",children:[e.jsx(xe,{className:"w-3 h-3"})," ",s.last_url.replace(/^https?:\/\//,"")]}):e.jsx("span",{className:"text-xs text-gray-400",children:r("seoDashboard.blocks.trackedKeywords.notRanked","Pas encore positionné")})]}),e.jsx("td",{className:"py-2.5 text-right text-sm font-medium text-gray-900 tabular-nums",children:s.last_position!=null&&s.last_position>0?s.last_position:e.jsx("span",{className:"text-gray-300",children:","})}),e.jsx("td",{className:"py-2.5 text-right",children:e.jsx(Ia,{delta:s.delta})}),e.jsx("td",{className:"py-2.5",children:e.jsx(Ra,{history:s.history})}),e.jsx("td",{className:"py-2.5 text-right text-gray-700 tabular-nums",children:s.last_search_volume!=null?M(s.last_search_volume):","}),e.jsx("td",{className:"py-2.5 text-right",children:e.jsx("button",{onClick:()=>t(s),className:"text-gray-400 hover:text-red-500 transition-colors",title:r("seoDashboard.blocks.trackedKeywords.deleteTitle","Arrêter le suivi"),children:e.jsx(Ts,{className:"w-4 h-4"})})})]})},Ra=({history:s})=>{const t=(s||[]).filter(n=>n.position!=null&&n.position>0).map(n=>({pos:n.position}));if(t.length<2)return e.jsx("div",{className:"text-xs text-gray-300 text-center",children:","});const r=t[0].pos,a=t[t.length-1].pos,o=a<r?"#059669":a>r?"#e11d48":"#9ca3af";return e.jsx("div",{className:"w-20 h-7 mx-auto",children:e.jsx(ta,{width:"100%",height:"100%",children:e.jsxs(na,{data:t,margin:{top:2,right:2,left:2,bottom:2},children:[e.jsx(Is,{hide:!0,reversed:!0,domain:["dataMin","dataMax"]}),e.jsx(aa,{content:({payload:n})=>{if(!n||n.length===0)return null;const m=n[0].payload.pos;return e.jsxs("div",{className:"bg-gray-900 text-white text-[10px] px-1.5 py-0.5 rounded",children:["#",m]})},cursor:!1}),e.jsx(Rs,{type:"monotone",dataKey:"pos",stroke:o,strokeWidth:1.5,dot:!1,isAnimationActive:!1})]})})})},Ia=({delta:s})=>s==null?e.jsx("span",{className:"text-gray-300 text-xs",children:","}):s===0?e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-gray-500 text-xs tabular-nums",children:[e.jsx(bt,{className:"w-3 h-3"})," 0"]}
2):s>0?e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-emerald-600 text-xs font-semibold tabular-nums",children:[e.jsx(gt,{className:"w-3 h-3"})," +",s]}):e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-rose-600 text-xs font-semibold tabular-nums",children:[e.jsx(ft,{className:"w-3 h-3"})," ",s]}),fs=5,$a=({bulleId:s})=>{const{t}=D(),[r,a]=u.useState([]),[o,n]=u.useState(!0),[m,i]=u.useState(!1),[c,d]=u.useState(""),[l,h]=u.useState(null),[x,w]=u.useState(new Set);u.useEffect(()=>{if(ne(s)){a(st()),n(!1);return}n(!0),Kt(s).then(y=>a(y??[])).catch(()=>a([])).finally(()=>n(!1))},[s]);const p=async()=>{var E,C;const y=c.trim();if(y){i(!0);try{const N=await Ot(s,y);a(P=>[...P,N]),d(""),_.success(t("seoDashboard.competitors.addedSuccess","Concurrent ajouté"))}catch(N){_.error(((C=(E=N==null?void 0:N.response)==null?void 0:E.data)==null?void 0:C.detail)||t("seoDashboard.competitors.addFailed","Impossible d'ajouter ce concurrent."))}finally{i(!1)}}},b=async y=>{var E,C;h(y);try{const N=await Vt(s,y);a(P=>P.map(A=>A.id===y?N:A))}catch(N){_.error(((C=(E=N==null?void 0:N.response)==null?void 0:E.data)==null?void 0:C.detail)||t("seoDashboard.competitors.refreshFailed","Ãchec du rafraîchissement."))}finally{h(null)}},v=async(y,E)=>{var C,N;if(confirm(t("seoDashboard.competitors.confirmDelete",{domain:E,defaultValue:"Retirer « {{domain}} » des concurrents suivis ?"})))try{await zt(s,y),a(P=>P.filter(A=>A.id!==y))}catch(P){_.error(((N=(C=P==null?void 0:P.response)==null?void 0:C.data)==null?void 0:N.detail)||t("seoDashboard.competitors.deleteFailed","Ãchec de la suppression."))}},g=y=>{w(E=>{const C=new Set(E);return C.has(y)?C.delete(y):C.add(y),C})},S=fs-r.length;return e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-200 p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-slate-900",children:t("seoDashboard.competitors.title","Concurrents suivis")}),e.jsx("p",{className:"text-xs text-slate-500",children:t("seoDashboard.competitors.subtitle","Ãpinglez jusqu'à 5 concurrents et voyez les mots-clés où ils vous devancent.")})]})}),e.jsxs("span",{className:"text-xs text-slate-500",children:[r.length," / ",fs]})]}),S>0&&e.jsxs("div",{className:"mb-4 flex gap-2",children:[e.jsx("input",{type:"text",value:c,onChange:y=>d(y.target.value),placeholder:t("seoDashboard.competitors.placeholder","ex: concurrent-local.fr"),className:"flex-1 px-3 py-2 text-sm border border-slate-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-orange-500",onKeyDown:y=>y.key==="Enter"&&p()}),e.jsx(me,{disabled:m||!c.trim(),onDisabledClick:()=>{m||c.trim()||_.warning(t("seoDashboard.competitors.blocked.domainRequired","Saisissez le domaine du concurrent"))},children:e.jsxs("button",{onClick:p,disabled:m||!c.trim(),className:"px-4 py-2 bg-gradient-to-r from-orange-500 to-orange-600 text-white text-sm font-medium rounded-lg hover:from-orange-600 hover:to-orange-700 disabled:opacity-50 flex items-center gap-1.5",children:[m?e.jsx(te,{className:"w-4 h-4 animate-spin"}):e.jsx(Cs,{className:"w-4 h-4"}),t("seoDashboard.competitors.add","Ajouter")]})})]}),o?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(te,{className:"w-5 h-5 animate-spin text-slate-400"})}):r.length===0?e.jsx("div",{className:"text-center py-8 text-sm text-slate-500",children:t("seoDashboard.competitors.empty","Aucun concurrent suivi. Ajoutez-en un pour suivre ses performances et identifier vos opportunités.")}):e.jsx("ul",{className:"space-y-3",children:r.map(y=>e.jsx(Fa,{competitor:y,expanded:x.has(y.id),refreshing:l===y.id,onToggle:()=>g(y.id),onRefresh:()=>b(y.id),onDelete:()=>v(y.id,y.domain)},y.id))})]})},Fa=({competitor:s,expanded:t,refreshing:r,onToggle:a,onRefresh:o,onDelete:n})=>{const{t:m}=D(),i=s.stats,c=!!s.last_refresh_error&&!i,d=(i==null?void 0:i.gap_keywords)??[];return e.jsxs("li",{className:"border border-slate-200 rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 bg-slate-50/50",children:[e.jsxs("button",{type:"button",onClick:a,className:"flex items-center gap-2 flex-1 min-w-0 text-left",children:[t?e.jsx(ae,{className:"w-4 h-4 text-slate-400 flex-shrink-0"}):e.jsx(Te,{className:"w-4 h-4 text-slate-400 flex-shrink-0"}),e.jsxs("a",{href:`https://${s.domain}`,target:"_blank",rel:"noopener noreferrer",onClick:l=>l.stopPropagation(),className:"font-mono text-sm font-semibold text-slate-900 hover:text-orange-500 flex items-center gap-1 truncate",children:[s.domain,e.jsx(xe,{className:"w-3 h-3 flex-shrink-0 text-slate-400"})]}),i&&e.jsxs("span",{className:"text-xs text-slate-500 flex-shrink-0 ml-2",children:[i.keywords_total," ",m("seoDashboard.competitors.keywords","mots-clés")," · ",e.jsx("strong",{className:"text-orange-500",children:d.length})," ",m("seoDashboard.competitors.opportunities","opportunités")]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0 ml-2",children:[e.jsx("button",{onClick:o,disabled:r,className:"p-1.5 text-slate-500 hover:text-orange-500 hover:bg-orange-50 rounded-lg disabled:opacity-50",title:m("seoDashboard.competitors.refresh","Rafraîchir"),children:e.jsx(Oe,{className:`w-3.5 h-3.5 ${r?"animate-spin":""}`})}),e.jsx("button",{onClick:n,className:"p-1.5 text-slate-500 hover:text-red-600 hover:bg-red-50 rounded-lg",title:m("seoDashboard.competitors.delete","Retirer"),children:e.jsx(Ts,{className:"w-3.5 h-3.5"})})]})]}),t&&e.jsx("div",{className:"px-4 py-3 bg-white",children:c?e.jsxs("div",{className:"flex items-start gap-2 text-sm text-red-700 bg-red-50 rounded-lg p-3",children:[e.jsx(Ne,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:s.last_refresh_error})]}):i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 mb-4",children:[e.jsx(je,{label:m("seoDashboard.competitors.traffic","Trafic estimé"),value:M(i.traffic_estimate??0)}),e.jsx(je,{label:m("seoDashboard.competitors.totalKeywords","Mots-clés"),value:M(i.keywords_total??0)}),e.jsx(je,{label:m("seoDashboard.competitors.commonKeywords","En commun"),value:M(i.keywords_common??0)}),e.jsx(je,{label:m("seoDashboard.competitors.avgPosition","Position moy."),value:i.avg_position!=null?String(i.avg_position):"â"})]}),d.length>0?e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-xs uppercase tracking-wide font-semibold text-slate-500 mb-2",children:m("seoDashboard.competitors.gapTitle","Mots-clés où il vous devance")}),e.jsx("ul",{className:"space-y-1 max-h-72 overflow-y-auto pr-1",children:d.slice(0,20).map((l,h)=>e.jsxs("li",{className:"flex items-center justify-between text-sm py-1.5 px-2 hover:bg-slate-50 rounded",children:[e.jsx("span",{className:"text-slate-700 truncate flex-1",children:l.keyword}),e.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0 text-xs text-slate-500",children:[e.jsxs("span",{title:"Volume de recherche / mois",children:[M(l.search_volume)," /mois"]}),l.competitor_position!=null&&e.jsxs("span",{className:"font-medium text-orange-500",children:["#",l.competitor_position]})]})]},h))})]}):e.jsx("p",{className:"text-sm text-slate-500 italic",children:m("seoDashboard.competitors.noGap","Pas d'opportunité claire â vous êtes déjà positionné
2s sur les mêmes requêtes.")}),s.last_refreshed_at&&e.jsx("p",{className:"text-[10px] text-slate-400 mt-3",children:m("seoDashboard.competitors.lastRefreshed","Données du {{date}}",{date:tt(s.last_refreshed_at)})})]}):e.jsx("div",{className:"text-sm text-slate-500 italic",children:m("seoDashboard.competitors.noStatsYet","Pas encore de données. Cliquez sur Rafraîchir pour charger les stats.")})})]})},je=({label:s,value:t})=>e.jsxs("div",{className:"bg-slate-50 rounded-lg p-3",children:[e.jsx("div",{className:"text-xs text-slate-500 mb-0.5",children:s}),e.jsx("div",{className:"text-lg font-bold text-slate-900",children:t})]});function Vs(s){const t=s.match(/^https?:\/\/([^/]+)/);return t?t[1].replace(/^www\./,""):""}function Ga(s,t){const r=s.replace(/^https?:\/\/[^/]+/,"")||"/";return t?`${Vs(s)}${r}`:r}const De=5;function Us(){const{i18n:s}=D();return u.useMemo(()=>new Intl.DateTimeFormat(ue(),{day:"numeric",month:"short"}),[s.language])}function Hs(){const{i18n:s}=D();return u.useMemo(()=>new Intl.DateTimeFormat(ue(),{day:"numeric",month:"short",year:"numeric"}),[s.language])}function Bs(s,t,r){if(!s)return null;const a=new Date(`${s.start}T00:00:00`),o=new Date(`${s.end}T00:00:00`);return{start:t.format(a),end:r.format(o)}}const Ka=({bulleId:s}
2)=>{const{t}=D(),r=Us(),a=Hs(),[o,n]=u.useState([]),[m,i]=u.useState(null),[c,d]=u.useState(!0),[l,h]=u.useState(!1),x=l?o:o.slice(0,De),w=Bs(m,r,a);return u.useEffect(()=>{d(!0),Ut(s).then(p=>{n(p.queries??[]),i(p.period??null)}).catch(()=>n([])).finally(()=>d(!1))},[s]),e.jsxs("section",{className:"bg-white/70 backdrop-blur-xl border border-gray-200/60 rounded-2xl shadow-sm p-6",children:[e.jsx("div",{className:"flex items-center gap-3 pb-4 border-b border-gray-100 mb-4",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-900 flex items-center gap-1.5",children:[e.jsx("span",{children:t("seoDashboard.gsc.topQueries","Top requêtes Google")}),e.jsx(K,{content:t("seoDashboard.gsc.topQueriesTooltip","Les requêtes Google sur lesquelles votre site a été vu ou cliqué le plus souvent sur les 28 derniers jours (visiteurs réels).")})]}),e.jsx("p",{className:"text-sm text-gray-500",children:w?t("seoDashboard.gsc.period28d","Du {{start}} au {{end}}",w):t("seoDashboard.gsc.last28d","28 derniers jours")})]})}),c?e.jsx(Ye,{rows:5,cols:4}):o.length===0?e.jsx("div",{className:"text-sm text-gray-500 leading-relaxed py-3",children:t("seoDashboard.gsc.noQueries","Aucune requête mesurée sur cette période.")}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"overflow-x-auto -mx-2 px-2",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-xs text-gray-500 border-b border-gray-100",children:[e.jsx("th",{className:"text-left font-medium pb-3",children:t("seoDashboard.gsc.cols.query","Requête")}),e.jsx(Me,{label:t("seoDashboard.gsc.cols.clicks","Clics"),tooltip:t("seoDashboard.gsc.cols.clicksTooltipQuery","Nombre de fois où quelqu'un a cliqué vers votre site depuis ce résultat Google (28 derniers jours)."),width:"w-16"}),e.jsx(Me,{label:t("seoDashboard.gsc.cols.impressions","Impr."),tooltip:t("seoDashboard.gsc.cols.impressionsTooltipQuery","Nombre de fois où votre site est apparu dans Google sur cette recherche (28 derniers jours)."),width:"w-20"}),e.jsx(Me,{label:t("seoDashboard.gsc.cols.position","Pos."),tooltip:t("seoDashboard.gsc.cols.positionTooltipQuery","Position moyenne de votre site dans Google sur cette requête."),width:"w-16"})]})}),e.jsx("tbody",{children:x.map((p,b)=>e.jsxs("tr",{className:"border-b border-gray-50 last:border-0 hover:bg-orange-50/30 transition-colors",children:[e.jsx("td",{className:"py-2.5 pr-2 font-medium text-gray-900 truncate max-w-xs",title:p.query,children:p.query}),e.jsx("td",{className:"py-2.5 text-right font-semibold text-gray-900 tabular-nums",children:p.clicks}),e.jsx("td",{className:"py-2.5 text-right text-gray-600 tabular-nums",children:M(p.impressions)}),e.jsx("td",{className:"py-2.5 text-right text-gray-700 tabular-nums",children:p.position.toFixed(1)})]},b))})]})}),o.length>De&&e.jsxs("button",{onClick:()=>h(p=>!p),className:"mt-4 w-full flex items-center justify-center gap-1.5 px-4 py-2.5 text-sm font-medium text-orange-500 hover:bg-orange-50 border border-dashed border-gray-200 hover:border-orange-200 rounded-xl transition-colors",children:[e.jsx(ae,{className:`w-4 h-4 transition-transform ${l?"rotate-180":""}`}),l?t("seoDashboard.gsc.showLess","Voir moins"):t("seoDashboard.gsc.showAllQueries","Voir les {{count}} requêtes",{count:o.length})]})]})]})},Me=({label:s,tooltip:t,width:r})=>e.jsx("th",{className:`text-right font-medium pb-3 ${r}`,children:e.jsxs("span",{className:"inline-flex items-center gap-1 justify-end",children:[s,e.jsx(K,{content:t,width:240,size:"xs"})]})}),Oa=({bulleId:s}
2)=>{const{t}=D(),r=Us(),a=Hs(),[o,n]=u.useState([]),[m,i]=u.useState(null),[c,d]=u.useState(!0),[l,h]=u.useState(!1),x=l?o:o.slice(0,De),w=new Set(o.map(b=>Vs(b.page))).size>1,p=Bs(m,r,a);return u.useEffect(()=>{d(!0),Ht(s).then(b=>{n(b.pages??[]),i(b.period??null)}).catch(()=>n([])).finally(()=>d(!1))},[s]),e.jsxs("section",{className:"bg-white/70 backdrop-blur-xl border border-gray-200/60 rounded-2xl shadow-sm p-6",children:[e.jsx("div",{className:"flex items-center gap-3 pb-4 border-b border-gray-100 mb-4",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-900 flex items-center gap-1.5",children:[e.jsx("span",{children:t("seoDashboard.gsc.topPages","Top pages Google")}),e.jsx(K,{content:t("seoDashboard.gsc.topPagesTooltip","Les pages de votre site qui reçoivent le plus de visites depuis Google sur 28 jours, utile pour identifier vos pages stars et celles à pousser.")})]}),e.jsx("p",{className:"text-sm text-gray-500",children:p?t("seoDashboard.gsc.period28d","Du {{start}} au {{end}}",p):t("seoDashboard.gsc.last28d","28 derniers jours")})]})}),c?e.jsx(Ye,{rows:5,cols:4}):o.length===0?e.jsx("div",{className:"text-sm text-gray-500 leading-relaxed py-3",children:t("seoDashboard.gsc.noPages","Aucune page mesurée sur cette période.")}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center text-xs text-gray-500 pb-2 border-b border-gray-100 mb-1 -mx-2 px-2",children:[e.jsx("span",{className:"flex-1 font-medium",children:t("seoDashboard.gsc.cols.page","Page")}),e.jsx("span",{className:"w-12 text-right font-medium",children:e.jsxs("span",{className:"inline-flex items-center gap-1 justify-end",children:[t("seoDashboard.gsc.cols.clicks","Clics"),e.jsx(K,{width:240,size:"xs",content:t("seoDashboard.gsc.cols.clicksTooltipPage","Nombre de visites Google vers cette page (28 derniers jours).")})]})}),e.jsx("span",{className:"w-20 text-right font-medium",children:e.jsxs("span",{className:"inline-flex items-center gap-1 justify-end",children:[t("seoDashboard.gsc.cols.impressions","Impr."),e.jsx(K,{width:240,size:"xs",content:t("seoDashboard.gsc.cols.impressionsTooltipPage","Nombre de fois où cette page est apparue dans Google (28 derniers jours).")})]})})]}),e.jsx("ul",{className:"divide-y divide-gray-50",children:x.map((b,v)=>e.jsxs("li",{className:"flex items-center justify-between gap-3 py-2.5 hover:bg-orange-50/30 -mx-2 px-2 rounded-md transition-colors",children:[e.jsx("a",{href:b.page,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-gray-800 hover:text-orange-500 truncate flex-1 transition-colors",title:b.page,children:Ga(b.page,w)}),e.jsx("span",{className:"text-sm font-semibold text-gray-900 tabular-nums w-12 text-right flex-shrink-0",children:b.clicks}),e.jsx("span",{className:"text-sm text-gray-500 tabular-nums w-20 text-right flex-shrink-0",children:M(b.impressions)})]},v))}),o.length>De&&e.jsxs("button",{onClick:()=>h(b=>!b),className:"mt-4 w-full flex items-center justify-center gap-1.5 px-4 py-2.5 text-sm font-medium text-orange-500 hover:bg-orange-50 border border-dashed border-gray-200 hover:border-orange-200 rounded-xl transition-colors",children:[e.jsx(ae,{className:`w-4 h-4 transition-transform ${l?"rotate-180":""}`}),l?t("seoDashboard.gsc.showLess","Voir moins"):t("seoDashboard.gsc.showAllPages","Voir les {{count}} pages",{count:o.length})]})]})]})},za=1e4,Qe=new Set(["is_https","has_html_doctype","canonical","has_links","favicon","is_indexable","seo_friendly_url","seo_friendly_url_characters_check","seo_friendly_url_dynamic_check","seo_friendly_url_keywords_check","seo_friendly_url_relative_length_check","frame","has_meta_refresh_redirect","is_redirect","is_resource","no_favicon"]),Va={no_h1_tag:{label:"Pas de balise H1",severity:"high",what:"Le titre principal de la page n'est pas balisé.",fix:"Ajouter une balise <h1> avec le titre principal."},no_title:{label:"Titre manquant",severity:"high",what:"La balise <title> est vide ou absente.",fix:"Ajouter <title> (50-65 caractères, avec mots-clés)."},no_description:{label:"Meta description manquante",severity:"high",what:"Pas de meta description, Google génère un texte automatique.",fix:'Ajouter <meta name="description"> (150-160 caractères).'},title_too_long:{label:"Titre trop long",severity:"medium",what:"Plus de 65 caractères, Google le tronque.",fix:"Raccourcir à 50-65 caractères."},title_too_short:{label:"Titre trop court",severity:"medium",what:"Vous n'utilisez pas tout l'espace SERP disponible.",fix:"Ãtoffer à 50-65 caractères."},no_image_alt:{label:"Images sans alt",severity:"medium",what:"Une ou plusieurs images n'ont pas de texte alternatif.",fix:'Ajouter alt="..." sur chaque <img>.'},no_image_title:{label:"Images sans title",severity:"low",what:"Tooltip au survol manquant.",fix:'Ajouter title="..." sur chaque <img> (optionnel).'},duplicate_title_tag:{label:"Titre dupliqué",severity:"high",what:"Plusieurs pages partagent ce même <title>.",fix:"Personnaliser le titre unique de chaque page."},duplicate_meta_tags:{label:"Meta tags dupliqués",severity:"high",what:"La description ou d'autres meta tags s
2ont identiques sur plusieurs pages.",fix:"Rédiger une meta description unique par page."},high_loading_time:{label:"Page lente (> 3s)",severity:"high",what:"Le chargement dépasse 3 secondes, Google pénalise.",fix:"Optimiser images (WebP, lazy load), minifier CSS/JS, activer le cache."},is_http:{label:"Site non HTTPS",severity:"high",what:"Le site n'est pas en HTTPS, Google flag « non sécurisé ».",fix:"Installer un certificat SSL (Let's Encrypt gratuit) + redirection 301."},is_broken:{label:"Page cassée",severity:"high",what:"Erreur de rendu détectée.",fix:"Vérifier les logs serveur et le rendu HTML."},is_4xx_code:{label:"Erreur 4xx",severity:"high",what:"Page non trouvée (404, 403...).",fix:"Restaurer la page ou rediriger en 301."},is_5xx_code:{label:"Erreur 5xx",severity:"high",what:"Erreur serveur, Google peut désindexer si persistant.",fix:"Vérifier d'urgence les logs serveur et l'hébergement."},no_canonical:{label:"Pas de balise canonical",severity:"medium",what:"Risque de contenu dupliqué si plusieurs URLs servent la même page.",fix:'Ajouter <link rel="canonical" href="URL_principale">.'},duplicate_title:{label:"Titre dupliqué",severity:"high",what:"Plusieurs pages ont exactement le même <title>.",fix:"Rédiger un titre unique par page."},duplicate_description:{label:"Meta description dupliquée",severity:"medium",what:"Plusieurs pages partagent la même meta description.",fix:"Rédiger une description unique par page."},duplicate_content:{label:"Contenu dupliqué",severity:"medium",what:"Corps de texte trop similaire à d'autres pages du site.",fix:"Différencier le contenu ou consolider en une seule page (avec canonical)."},low_content_rate:{label:"Peu de contenu",severity:"medium",what:"Ratio texte/HTML faible, page perçue comme « light » par Google.",fix:"Ãtoffer le contenu textuel pertinent (>300 mots conseillés)."},low_readability_rate:{label:"Lisibilité faible",severity:"low",what:"Le texte est jugé complexe ou peu lisible.",fix:"Phrases plus courtes, paragraphes aérés, vocabulaire simple."},non_indexable:{label:"Page non indexable",severity:"medium",what:"Bloquée par robots.txt, meta robots ou canonical externe.",fix:"Vérifier que c'est volontaire, sinon corriger."},has_render_blocking_resources:{label:"Ressources qui bloquent le rendu",severity:"medium",what:"Du CSS ou JavaScript bloque l'affichage initial de la page.",fix:"Marquer les scripts non critiques en async/defer, inliner le CSS critique."},has_broken_links:{label:"Liens cassés",severity:"high",what:"La page contient des liens qui pointent vers une URL 404/500.",fix:"Lister les liens cassés et les corriger ou supprimer."},has_duplicate_meta_tags:{label:"Meta tags dupliqués",severity:"medium",what:"Cette page partage des meta tags identiques avec d'autres pages.",fix:"Rédiger une meta description unique pour chaque page."},has_no_image_alt:{label:"Images sans alt",severity:"medium",what:"Certaines images n'ont pas d'attribut alt sur cette page.",fix:'Ajouter alt="..." descriptif sur chaque <img>.'},has_no_image_title:{label:"Images sans title",severity:"low",what:"Certaines images n'ont pas d'attribut title.",fix:'Optionnel : ajouter title="..." comme tooltip au survol.'},high_waiting_time:{label:"Temps de réponse serveur lent",severity:"medium",what:"Le serveur met du temps à répondre (TTFB élevé).",fix:"Optimiser le backend, activer la mise en cache serveur, considérer un CDN."},size_greater_than_3mb:{label:"Page trop lourde (> 3MB)",severity:"medium",what:"Le poids total de la page dépasse 3MB, mauvais sur mobile.",fix:"Compresser les images (WebP), minifier CSS/JS, lazy load les médias."},flash:{label:"Utilisation de Flash",severity:"high",what:"Flash n'est plus supporté depuis 2020.",fix:"Migrer vers HTML5 / JavaScript moderne."},irrelevant_description:{label:"Meta description non pertinente",severity:"low",what:"La meta description ne reflète pas le contenu de la page.",fix:"Réécrire la description pour qu'elle résume vraiment la page."},irrelevant_title:{label:"Titre non pertinent",severity:"medium",what:"Le titre ne reflète pas le contenu principal de la page.",fix:"Réécrire le titre pour qu'il décrive précisément le contenu."},irrelevant_meta_keywords:{label:"Meta keywords non pertinents",severity:"low",what:"Les meta keywords ne correspondent pas au contenu.",fix:"Soit retirer la balise meta keywords, soit la corriger."},deprecated_html_tags:{label:"Balises HTML obsolètes",severity:"low",what:"La page contient des balises HTML dépréciées.",fix:"Remplacer par du CSS moderne."}};function Xe(s,t){const r=Va[s],a=(r==null?void 0:r.label)??s.replace(/_/g," "),o=(r==null?void 0:r.what)??"",n=(r==null?void 0:r.fix)??"";return{label:t?String(t(`seoDashboard.audit.issues.${s}.label`,a)):a,severity:(r==null?void 0:r.severity)??"low",what:t?String(t(`seoDashboard.audit.issues.${s}.what`,o)):o,fix:t?String(t(`seoDashboard.audit.issues.${s}.fix`,n)):n}}const Se=[{key:"broken_links",severity:"high"},{key:"duplicate_title",severity:"high"},{key:"broken_resources",severity:"medium"},{key:"duplicate_description",severity:"medium"},{key:"duplicate_content",severity:"medium"},{key:"non_indexable",severity:"low"}],Ua={broken_links:["has_broken_links","is_4xx_code","is_5xx_code","is_broken"],duplicate_title:["duplicate_title","duplicate_title_tag"],duplicate_description:["duplicate_description","duplicate_meta_tags","has_duplicate_meta_tags"],duplicate_content:["duplicate_content"],non_indexable:["non_indexable"],broken_resources:["has_broken_resources","broken_resources"]};function Ha(s,t){const r=Ua[t]||[];return s.some(a=>r.includes(a))}function Je(s,t){const a=new Intl.DateTimeFormat(ue(),{day:"numeric",month:"long",year:"numeric"}).format(s).replace(/(^|\s)([a-zà -ÿ])/,(n,m,i)=>m+i.toUpperCase()),o=String(s.getMinutes()).padStart(2,"0");return t.startsWith("fr")?`${a} à ${s.getHours()}h${o}`:`${a} at ${String(s.getHours()).padStart(2,"0")}:${o}`}const Ba=({className:s})=>
2e.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",className:s,children:[e.jsx("path",{d:"M7.86 2h8.28L22 7.86v8.28L16.14 22H7.86L2 16.14V7.86L7.86 2z"}),e.jsx("path",{d:"M12 8v5",stroke:"white",strokeWidth:"2.2",strokeLinecap:"round",fill:"none"}),e.jsx("circle",{cx:"12",cy:"16.6",r:"1.15",fill:"white"})]}),Wa=({className:s})=>e.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",className:s,children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),e.jsx("path",{d:"M12 9.5v4",stroke:"white",strokeWidth:"2.2",strokeLinecap:"round",fill:"none"}),e.jsx("circle",{cx:"12",cy:"17",r:"1.15",fill:"white"})]});function Ya(s){return s==="high"?e.jsx(Ba,{className:"w-3.5 h-3.5 text-rose-600 flex-shrink-0"}):s==="medium"?e.jsx(Wa,{className:"w-3.5 h-3.5 text-amber-600 flex-shrink-0"}):e.jsx(Ve,{className:"w-3.5 h-3.5 text-gray-400 flex-shrink-0"})}function Qa(s,t,r){var l;const a=((l=s.summary)==null?void 0:l.aggregated)||{},o=s.target_url||"",n=s.completed_at?Je(new Date(s.completed_at),r):",",m=a.pages_crawled||s.max_pages||0,i=Le(a),c=[];c.push(`# ${t("seoDashboard.onpageAudit.markdownTitle","Audit SEO du site {{url}}",{url:o})}`),c.push(""),c.push(`*${t("seoDashboard.onpageAudit.markdownIntro","Audit du {{date}} · {{pages}} pages analysées",{date:n,pages:m})}*`),c.push(""),c.push(`## ${t("seoDashboard.onpageAudit.markdownScoreHeader","Score global : {{score}}/100",{score:i})}`),c.push(""),c.push(`## ${t("seoDashboard.onpageAudit.markdownProblemsHeader","Problèmes détectés")}`);for(const h of Se){const x=t(`seoDashboard.audit.counters.${h.key}.label`,h.key);c.push(`- **${x}** : ${Number(a[h.key]||0)}`)}c.push("");const d=(s.pages_sample||[]).map(h=>({...h,realIssues:h.issues.filter(x=>!Qe.has(x))})).filter(h=>h.realIssues.length>0);if(d.length>0){c.push(`## ${t("seoDashboard.onpageAudit.markdownPagesHeader","Pages avec problèmes ({{n}})",{n:d.length})}`),c.push("");for(const h of d){const x=h.url.replace(/^https?:\/\/[^/]+/,"")||"/";c.push(`### ${x}${h.status_code!=null?` (HTTP ${h.status_code})`:""}`);for(const w of h.realIssues){const p=Xe(w,t);c.push(`- **${p.label}** : ${p.what}`),p.fix&&c.push(` - *${t("seoDashboard.onpageAudit.howToFix","Comment corriger : ").trim()}* ${p.fix}`)}c.push("")}}return c.join(` 3`)}function Xa(s,t,r){var l;const a=((l=s.summary)==null?void 0:l.aggregated)||{},o=s.target_url||"",n=s.completed_at?Je(new Date(s.completed_at),r):",",m=a.pages_crawled||s.max_pages||0,i=Le(a),c=[];c.push(t("seoDashboard.onpageAudit.promptIntro","Tu es un expert SEO technique. Voici l'audit complet du site {{url}} (score {{score}}/100, {{pages}} pages analysées le {{date}}).",{url:o,score:i,pages:m,date:n})),c.push(""),c.push(`${t("seoDashboard.onpageAudit.promptProblemsHeader","PROBLÃMES DÃTECTÃS")} :`);for(const h of Se){const x=t(`seoDashboard.audit.counters.${h.key}.label`,h.key);c.push(`- ${x} : ${Number(a[h.key]||0)}`)}c.push("");const d=(s.pages_sample||[]).map(h=>({...h,realIssues:h.issues.filter(x=>!Qe.has(x))})).filter(h=>h.realIssues.length>0);if(d.length>0){c.push(`${t("seoDashboard.onpageAudit.promptPagesHeader","PAGES IMPACTÃES (échantillon)")} :`);for(const h of d){const x=h.url.replace(/^https?:\/\/[^/]+/,"")||"/",w=h.realIssues.map(p=>Xe(p,t).label).join(", ");c.push(`- ${x}${h.status_code!=null?` (HTTP ${h.status_code})`:""} : ${w}`)}c.push("")}return c.push(t("seoDashboard.onpageAudit.promptInstruction","Donne-moi un plan de correction priorisé en 3 niveaux (Critique / Important / Optionnel), avec pour chaque problème : la cause technique, la solution concrète à appliquer, et l'impact SEO attendu.")),c.join(` 4`)}function Le(s){if(typeof(s==null?void 0:s.onpage_score)=="number"&&s.onpage_score>0)return Math.round(s.onpage_score);let t=100;return t-=Math.min(40,Number((s==null?void 0:s.broken_links)||0)*2),t-=Math.min(20,Number((s==null?void 0:s.duplicate_title)||0)*3),t-=Math.min(15,Number((s==null?void 0:s.duplicate_description)||0)*1.5),t-=Math.min(15,Number((s==null?void 0:s.duplicate_content)||0)*2),t-=Math.min(10,Number((s==null?void 0:s.broken_resources)||0)*.5),Math.max(0,Math.round(t))}const Ja=({bulleId:s}
4)=>{var b,v;const{t,i18n:r}=D(),[a,o]=u.useState(null),[n,m]=u.useState(!0),i=u.useRef(null),c=Be(s),d=async()=>{const g=c.begin(s);if(ne(s)){const S=ks();return o(S),m(!1),S}try{const S=await qs(s);return g.isStale()?null:(o(S),S)}catch{return g.isStale()||o({exists:!1}),null}finally{g.isStale()||m(!1)}};u.useEffect(()=>{d()},[s]),u.useEffect(()=>{if((a==null?void 0:a.status)!=="in_progress"){i.current&&(window.clearTimeout(i.current),i.current=null);return}return i.current=window.setTimeout(async()=>{await d()},za),()=>{i.current&&window.clearTimeout(i.current)}},[s,a==null?void 0:a.status,a==null?void 0:a.last_polled_at]);const l=async()=>{if(a)try{await navigator.clipboard.writeText(Qa(a,t,r.language||"fr")),_.success(t("seoDashboard.onpageAudit.exportMarkdownSuccess","Rapport copié au presse-papiers"))}catch{_.error(t("seoDashboard.onpageAudit.exportFailed","Impossible de copier"))}},h=async()=>{if(a)try{await navigator.clipboard.writeText(Xa(a,t,r.language||"fr")),_.success(t("seoDashboard.onpageAudit.exportPromptSuccess","Prompt IA copié au presse-papiers"))}catch{_.error(t("seoDashboard.onpageAudit.exportFailed","Impossible de copier"))}};if(n)return e.jsx(Ks,{rows:3});const x=a!=null&&a.completed_at?new Date(a.completed_at):null,w=Number(((v=(b=a==null?void 0:a.summary)==null?void 0:b.aggregated)==null?void 0:v.pages_crawled)||(a==null?void 0:a.max_pages)||0),p=a!=null&&a.exists?a.status==="in_progress"?t("seoDashboard.onpageAudit.subtitleInProgress","Analyse en coursâ¦"):a.not_applicable?t("seoDashboard.onpageAudit.subtitleNotApplicable","Audit non applicable"):a.status==="failed"?t("seoDashboard.onpageAudit.subtitleFailed","L'audit a échoué"):t("seoDashboard.onpageAudit.subtitleCompleted","Audit du {{date}} · {{pages}} pages analysées",{date:x?Je(x,r.language||"fr"):",",pages:w}):t("seoDashboard.onpageAudit.subtitleEmpty","Analyse de vos pages");return e.jsxs("section",{className:"bg-white/70 backdrop-blur-xl border border-gray-200/60 rounded-2xl shadow-sm p-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 pb-4 border-b border-gray-100 mb-4 flex-wrap",children:[e.jsx("div",{className:"flex items-center gap-3 min-w-0",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-900 flex items-center gap-1.5",children:[e.jsx("span",{children:t("seoDashboard.onpageAudit.title","Audit complet du site")}),e.jsx(K,{content:t("seoDashboard.onpageAudit.titleTooltip","Nous parcourons
4jusqu'à 100 pages de votre site et détectons les problèmes techniques : liens cassés, titres dupliqués, contenu en double, pages non indexables, etc.")})]}),e.jsx("p",{className:"text-sm text-gray-500",children:p})]})}),(a==null?void 0:a.status)==="completed"&&e.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:e.jsx(Za,{onCopyMarkdown:l,onCopyPrompt:h})})]}),a!=null&&a.exists?a.status==="in_progress"?e.jsx(sr,{audit:a}):a.not_applicable?e.jsx(Re,{messageKey:"notApplicableNeedSite",lastError:a.last_error}):a.status==="failed"?e.jsx(Re,{messageKey:"failedNeedScan",lastError:a.last_error}):e.jsx(tr,{audit:a}):e.jsx(Re,{messageKey:"emptyNeedScan"})]})},Za=({onCopyMarkdown:s,onCopyPrompt:t})=>{const{t:r}=D(),[a,o]=u.useState(!1),n=u.useRef(null),m=u.useRef(null),[i,c]=u.useState({top:0,left:0,w:320}),d=u.useCallback(()=>{const l=n.current;if(!l)return;const h=l.getBoundingClientRect(),x=window.innerWidth,w=8,p=Math.min(320,x-w*2);let b=h.right-p;b=Math.max(w,Math.min(b,x-w-p)),c({top:h.bottom+6,left:b,w:p})},[]);return u.useEffect(()=>{if(!a)return;d();const l=w=>{var p,b;(p=n.current)!=null&&p.contains(w.target)||(b=m.current)!=null&&b.contains(w.target)||o(!1)},h=()=>d(),x=setTimeout(()=>document.addEventListener("mousedown",l),10);return window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{clearTimeout(x),document.removeEventListener("mousedown",l),window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[a,d]),e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:n,type:"button",onClick:()=>o(l=>!l),title:r("seoDashboard.onpageAudit.exportTitle","Exporter ce rapport"),className:"inline-flex items-center justify-center w-8 h-8 text-gray-600 hover:text-orange-500 bg-white hover:bg-orange-50 border border-gray-200 hover:border-orange-200 rounded-lg transition-colors",children:e.jsx(jt,{className:"w-4 h-4"})}),a&&yt.createPortal(e.jsxs("div",{ref:m,className:"fixed bg-white border border-gray-200 rounded-xl shadow-xl p-1.5",style:{to
4p:i.top,left:i.left,width:i.w,zIndex:99999},children:[e.jsxs("button",{onClick:()=>{s(),o(!1)},className:"w-full text-left px-3 py-2.5 hover:bg-orange-50 rounded-lg flex items-start gap-2.5 transition-colors",children:[e.jsx("div",{className:"w-7 h-7 bg-orange-100 rounded-lg flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(wt,{className:"w-4 h-4 text-orange-500"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-sm text-gray-900",children:r("seoDashboard.onpageAudit.exportMarkdown","Copier le rapport en Markdown")}),e.jsx("div",{className:"text-xs text-gray-500 leading-relaxed mt-0.5",children:r("seoDashboard.onpageAudit.exportMarkdownDescription","Score, compteurs, pages problématiques, formaté MD prêt à coller dans Notion / Slack / mail.")})]})]}),e.jsxs("button",{onClick:()=>{t(),o(!1)},className:"w-full text-left px-3 py-2.5 hover:bg-orange-50 rounded-lg flex items-start gap-2.5 transition-colors",children:[e.jsx("div",{className:"w-7 h-7 bg-orange-100 rounded-lg flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(ke,{className:"w-4 h-4 text-orange-500"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-sm text-gray-900",children:r("seoDashboard.onpageAudit.exportPrompt","Copier un prompt IA pour corriger")}),e.jsx("div",{className:"text-xs text-gray-500 leading-relaxed mt-0.5",children:r("seoDashboard.onpageAudit.exportPromptDescription","Prompt complet avec contexte (URL, score, liste des problèmes) à coller dans ChatGPT / Claude, vous obtenez un plan de correction priorisé.")})]})]})]}),document.body)]})},er={emptyNeedScan:"L'audit technique se déclenche automatiquement avec chaque analyse complète. Lancez une analyse (bouton en haut de la page) pour voir l'audit de vos pages ici.",failedNeedScan:"L'audit du dernier scan n'a pas abouti. Relancez une analyse complète (bouton en haut de la page) pour réessayer.",notApplicableNeedSite:"Le site déclaré pour cette bulle est une page hébergée sur une plateforme tierce (Doctolib, Planity, Facebookâ¦). L'audit technique analyse votre propre site : renseignez son adresse dans les paramètres du site web pour en profiter."},Re=({messageKey:s,lastError:t})=>{const{t:r}=D(),a=s==="failedNeedScan";return e.jsxs("div",{className:"text-center py-6",children:[e.jsx("div",{className:`inline-flex items-center justify-center w-12 h-12 rounded-full mb-3 ${a?"bg-rose-50":"bg-orange-100"}`,children:e.jsx(ze,{className:`w-6 h-6 ${a?"text-rose-600":"text-orange-500"}`})}),e.jsx("p",{className:"text-sm text-gray-700 max-w-md mx-auto leading-relaxed",children:r(`seoDashboard.onpageAudit.${s}`,er[s])}),s!=="emptyNeedScan"&&t&&e.jsx("p",{className:"text-xs text-gray-400 mt-2 max-w-md mx-auto",children:t})]})},sr=({audit:s})=>{const{t}=D(),r=s.started_at?new Date(s.started_at):null,[a,o]=u.useState(0);u.useEffect(()=>{const d=setInterval(()=>o(l=>l+1),1e3);return()=>clearInterval(d)},[]);const n=r?Math.floor((Date.now()-r.getTime())/1e3):0,m=[{id:"start",label:t("seoDashboard.onpageAudit.steps.start","Démarrage du crawl"),progress:15,atSec:0},{id:"pages",label:t("seoDashboard.onpageAudit.steps.pages","Parcours des pages"),progress:45,atSec:25},{id:"issues",label:t("seoDashboard.onpageAudit.steps.issues","Détection des problèmes"),progress:75,atSec:90},{id:"report",label:t("seoDashboard.onpageAudit.steps.report","Compilation du rapport"),progress:100,atSec:180}],i=m.reduce((d,l,h)=>n>=l.atSec?h:d,0),c=m.map((d,l)=>({id:d.id,label:d.label,progress:d.progress,status:l<i?"completed":l===i?"active":"pending"}));if(i===m.length-1){m[i-1].progress,m[i].progress;const d=Math.min(.85,(n-m[i].atSec)/120);c[i].activeProgress=Math.max(0,d)}return e.jsxs("div",{className:"py-2",children:[e.jsx(As,{title:t("seoDashboard.onpageAudit.crawling","Analyse en cours"),steps:c,compact:!0}),e.jsx("p",{className:"text-xs text-gray-400 mt-3",children:t("seoDashboard.onpageAudit.elapsed","Lancé il y a {{sec}}s, résultats attendus dans 1 à 5 min.",{sec:n})})]})},tr=({audit:s})=>{var h;const{t}=D(),r=(h=s.summary)==null?void 0:h.aggregated,[a,o]=u.useState(null);if(!r)return e.jsx("div",{className:"text-sm text-gray-500",children:t("seoDashboard.onpageAudit.noData","Aucune donnée disponible.")});
4const n=Se.some(x=>Number(r[x.key]||0)>0),m=Number(r.pages_crawled||s.max_pages||0),i=Le(r),c=i>=80?"scoreGood":i>=60?"scoreMedium":"scoreLow",d=i>=80?"Excellent. Votre site est globalement propre techniquement.":i>=60?"Correct mais quelques points à corriger pour optimiser.":"Plusieurs points importants à corriger sur le site.",l=(s.pages_sample||[]).map(x=>({...x,realIssues:x.issues.filter(w=>!Qe.has(w))})).filter(x=>x.realIssues.length>0);return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-baseline gap-3",children:[e.jsxs("div",{className:"text-5xl font-semibold text-gray-900 tabular-nums leading-none",children:[i,e.jsx("span",{className:"text-2xl text-gray-400 font-normal",children:"/100"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-gray-700",children:t("seoDashboard.onpageAudit.globalScore","Score global")}),e.jsx("div",{className:"text-xs text-gray-500",children:t("seoDashboard.onpageAudit.basedOnPages","Calculé sur {{n}} pages analysées",{n:m})})]})]}),e.jsx("div",{className:"text-sm text-gray-700 max-w-xs sm:text-right",children:t(`seoDashboard.onpageAudit.${c}`,d)})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:Se.map(x=>{const w=Number(r[x.key]||0);return e.jsx(ar,{counterKey:x.key,count:w,onClick:()=>o(x.key)},x.key)})}),l.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs uppercase tracking-wide font-semibold text-gray-500 mb-2",children:t("seoDashboard.onpageAudit.problemPages","Pages avec problèmes ({{n}})",{n:l.length})}),e.jsx("ul",{className:"space-y-2 max-h-96 overflow-y-auto pr-1",children:l.map((x,w)=>e.jsx(or,{page:x},`${x.url}-${w}`))})]}),!n&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-emerald-700 leading-relaxed py-2",children:[e.jsx(Ve,{className:"w-5 h-5 text-emerald-600 flex-shrink-0"}),t("seoDashboard.onpageAudit.allClean","Aucun problème majeur détecté sur les pages analysées.")]}),e.jsx(rr,{counterKey:a,count:a?Number(r[a]||0):0,relatedPages:a?l.filter(x=>Ha(x.realIssues,a)):[],onClose:()=>o(null)})]})},ar=({counterKey:s,count:t,onClick:r})=>{const{t:a}=D(),o=t===0,n=a(`seoDashboard.audit.counters.${s}.label`,s);return e.jsxs("button",{type:"button",onClick:r,className:"group text-left bg-white border border-gray-200 hover:border-orange-300 rounded-xl p-4 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:`text-2xl font-semibold tabular-nums leading-none ${o?"text-gray-300":"text-gray-900"}`,children:t}),e.jsx(Te,{className:"w-3.5 h-3.5 text-gray-300 group-hover:text-orange-500 transition-colors flex-shrink-0"})]}),e.jsx("div",{className:"text-xs font-medium text-gray-700",children:n})]})},rr=({counterKey:s,count:t,relatedPages:r,onClose:a})=>{const{t:o}=D();if(!s)return null;const n=o(`seoDashboard.audit.counters.${s}.label`,s),m=o(`seoDashboard.audit.counters.${s}.what`,""),i=o(`seoDashboard.audit.counters.${s}.fix`,""),c=t===0;return e.jsx(vs,{open:!0,onOpenChange:d=>!d&&a(),children:e.jsxs(Ns,{size:"default",hideCloseButton:!0,className:"p-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 p-6 pb-4 border-b border-gray-100",children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[e.jsx("div",{className:"w-10 h-10 bg-orange-100 rounded-xl flex items-center justify-center flex-shrink-0",children:e.jsx(ze,{className:"w-5 h-5 text-orange-500"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900",children:n}),e.jsx("p",{className:"text-sm text-gray-500 mt-0.5",children:c?o("seoDashboard.onpageAudit.counterDialog.zeroSubtitle","Aucune occurrence détectée sur ce scan."):o("seoDashboard.onpageAudit.counterDialog.countSubtitle",{defaultValue:"{{count}} occurrence(s) détectée(s)",count:t})})]})]}),e.jsx("button",{type:"button",onClick:a,"aria-label":o("common.close","Fermer"),className:"text-gray-400 hover:text-gray-600 transition-colors flex-shrink-0",children:e.jsx(vt,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-6 space-y-5 max-h-[60vh] overflow-y-auto",children:[m&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs uppercase tracking-wide font-semibold text-gray-500 mb-1.5",children:o("seoDashboard.onpageAudit.counterDialog.whatHeader","De quoi s'agit-il ?")}),e.jsx("p",{className:"text-sm text-gray-700 leading-relaxed",children:m})]}),i&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs uppercase tracking-wide font-semibold text-gray-500 mb-1.5",children:o("seoDashboard.onpageAudit.counterDialog.fixHeader","Comment corriger")}),e.jsx("p",{className:"text-sm text-gray-700 leading-relaxed",children:i})]}),!c&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs uppercase tracking-wide font-semibold text-gray-500 mb-1.5",children:o("seoDashboard.onpageAudit.counterDialog.pagesHeader","Pages impactées de l'échantillon")}),r.length===0?e.jsx("p",{className:"text-sm text-gray-500 leading-relaxed",children:o("seoDashboard.onpageAudit.counterDialog.noPageInSample","Le compteur est fiable mais l'échantillon analysé ne permet pas de pointer les pages précises. Search Console (Couverture / Pages) listera les URL concernées.")}):e.jsx("ul",{className:"space-y-1.5",children:r.map((d,l)=>e.jsx("li",{children:e.jsxs("a",{href:d.url,target:"_blank",rel:"noopener noreferrer",className:"group flex items-center gap-2 text-sm text-gray-700 hover:text-orange-500 break-all",children:[e.jsx("span",{className:"truncate",children:d.url.replace(/^https?:\/\/[^/]+/,"")||"/"}),e.jsx(xe,{className:"w-3 h-3 flex-shrink-0 text-gray-300 group-hover:text-orange-500"})]})},`${d.url}-${l}`))})]})]})]})})},or=({page:s})=>{const{t}=D(),[r,a]=u.useState(!1),o=s.url.replace(/^https?:\/\/[^/]+/,"")||"/",n=s.status_code!=null&&s.status_code>
4=400;return e.jsxs("li",{className:"rounded-lg border border-gray-200 bg-white overflow-hidden",children:[e.jsx("button",{type:"button",onClick:()=>a(m=>!m),className:"w-full p-3 text-left hover:bg-orange-50/30 transition-colors",children:e.jsxs("div",{className:"flex items-center gap-2",children:[r?e.jsx(ae,{className:"w-3.5 h-3.5 text-gray-400 flex-shrink-0"}):e.jsx(Te,{className:"w-3.5 h-3.5 text-gray-400 flex-shrink-0"}),s.status_code!=null&&e.jsx("span",{className:`text-[10px] font-bold px-1.5 py-0.5 rounded flex-shrink-0 tabular-nums ${n?"bg-rose-50 text-rose-700 border border-rose-100":"bg-gray-100 text-gray-600 border border-gray-200"}`,children:s.status_code}),e.jsx("span",{className:"text-sm text-gray-800 truncate flex-1 min-w-0",title:s.url,children:o}),e.jsx("span",{className:"flex-shrink-0 text-[11px] font-medium text-gray-600",children:t("seoDashboard.onpageAudit.problemCount",{count:s.realIssues.length})})]})}),r&&e.jsx("div",{className:"px-3 pb-3 pt-1 ml-4 border-l border-gray-100 space-y-3",children:s.realIssues.map((m,i)=>{const c=Xe(m,t);return e.jsxs("div",{className:"pl-3",children:[e.jsxs("div",{className:"font-semibold text-sm text-gray-900 mb-1 flex items-center gap-1.5",children:[Ya(c.severity),c.label]}),c.what&&e.jsx("div",{className:"text-xs text-gray-600 mb-1 leading-relaxed",children:c.what}),c.fix&&e.jsxs("div",{className:"text-xs text-gray-500 leading-relaxed",children:[e.jsx("span",{className:"font-medium text-gray-700",children:t("seoDashboard.onpageAudit.howToFix","Comment corriger : ")}),c.fix]})]},i)})})]})},nr=({snapshot:s,bulleId:t,gscConnected:r})=>{var W;const{t:a,i18n:o}=D(),[n,m]=Ue(),[i,c]=u.useState([]),[d,l]=u.useState(null),[h,x]=u.useState(!1),w=()=>{const f=new URLSearchParams(n);f.set("tab","connections"),m(f,{replace:!1}),requestAnimationFrame(()=>{var $;($=document.getElementById("seo-connections"))==null||$.scrollIntoView({behavior:"smooth",block:"start"})})},p=u.useMemo(()=>{const f=new Intl.DateTimeFormat(ue(),{month:"short"});return Array.from({length:12},($,oe)=>{const ie=f.format(new Date(2e3,oe,1));return ie.charAt(0).toUpperCase()+ie.slice(1)})},[o.language]),b=u.useMemo(()=>new Intl.DateTimeFormat(ue(),{month:"long",year:"numeric"}),[o.language]);u.useEffect(()=>{if(!r){c([]),l(null);return}x(!0),Bt(t).then(f=>{c(f.months||[]),l(f.period_comparison||null)}).catch(()=>{c([]),l(null)}).finally(()=>x(!1))},[t,r]);const v=((W=s==null?void 0:s.historical_rank)==null?void 0:W.months)||[],g={};for(const f of v.slice(-12)){const $=`${f.year}-${String(f.month).padStart(2,"0")}`;g[$]={label:`${p[(f.month||1)-1]} ${String(f.year).slice(-2)}`,year:f.year,month:f.month,dfseoEtv:Math.round(f.etv||0),dfseoCount:f.count||0}}for(const f of i.slice(-12)){const $=`${f.year}-${String(f.month).padStart(2,"0")}`;g[$]?(g[$].gscClicks=f.clicks,g[$].gscImpressions=f.impressions):g[$]={label:`${p[(f.month||1)-1]} ${String(f.year).slice(-2)}`,year:f.year,month:f.month,gscClicks:f.clicks,gscImpressions:f.impressions}}const S=Object.entries(g).sort(([f],[$])=>f.localeCompare($)).map(([,f])=>f);if(S.length===0&&!h)return null;const y=new Date,E=`${y.getFullYear()}-${String(y.getMonth()+1).padStart(2,"0")}`,C=S[S.length-1],P=C&&`${C.year}-${String(C.month).padStart(2,"0")}`===E?S.length-2:S.length-1,A=S[P],O=S[P-1],q=A==null?void 0:A.gscClicks,G=A?S.find(f=>f.year===A.year-1&&f.month===A.month):void 0,B=G==null?void 0:G.gscClicks,k=B!=null&&B>0,j=k?B:O==null?void 0:O.gscClicks,T=q!=null&&j!=null&&j>0?Math.round((q-j)/j*100):null,z=A?b.format(new Date(A.year,(A.month||1)-1,1)):"",Z=k&&G?b.format(new Date(G.year,(G.month||1)-1,1)):"",re=((d==null?void 0:d.days_compared)??99)>=3,X=(f,$)=>f==null?null:e.jsxs("div",{className:"text-xs text-gray-500",children:[e.jsxs("span",{className:`font-medium ${f>0?"text-green-600":f<0?"text-red-600":"text-gray-400"}`,children:[f>0?"â²":f<0?"â¼":""," ",Math.abs(f),"%"]}),e.jsx("span",{className:"text-gray-400 ml-1",children:$})]}),Q=r&&d&&re?e.jsxs("div",{className:"text-right flex-shrink-0",children:[e.jsx("div",{className:"text-xl font-semibold text-gray-900 tabular-nums",children:M(d.current.clicks)}),e.jsx("div",{className:"text-xs text-gray-500",children:a("seoDashboard.unifiedTraffic.kpi.clicksFor","clics du {{period}}",{period:d.current.label})}),X(d.delta_pct,d.comparison_basis==="yoy"?a("seoDashboard.unifiedTraffic.kpi.vsPeriodLastYear","vs {{period}} (l'an dernier)",{period:d.previous.label}):a("seoDashboard.unifiedTraffic.kpi.vsPeriod","vs {{period}}",{period:d.previous.label}))]}):r&&q!=null?e.jsxs("div",{className:"text-right flex-shrink-0",children:[e.jsx("div",{className:"text-xl font-semibold text-gray-900 tabular-nums",children:M(q)}),e.jsx("div",{className:"text-xs text-gray-500 capitalize",children:a("seoDashboard.unifiedTraffic.kpi.realClicksIn","vrais clics en {{month}}",{month:z})}),X(T,k?a("seoDashboard.unifiedTraffic.kpi.vsMonthLastYear","vs {{month}} (l'an dernier)",{month:Z}):a("seoDashboard.unifiedTraffic.kpi.vsPreviousMonth","vs mois précédent"))]}):null,F=r?[{label:a("seoDashboard.unifiedTraffic.legend.realClicks","Clics réels"),color:"#f97316",type:"line"},{label:a("seoDashboard.unifiedTraffic.legend.impressions","Impressions"),color:"#fed7aa",type:"area"}]:[{label:a("seoDashboard.unifiedTraffic.legend.estimateTraffic","Trafic estimé"),color:"#f97316",type:"dashed"},{label:a("seoDashboard.unifiedTraffic.legend.rankedKeywords","Mots-clés positionné
4s"),color:"#fed7aa",type:"area"}],J=r?[{type:"area",dataKey:"gscImpressions",name:a("seoDashboard.unifiedTraffic.impressions","Impressions Google (Search Console)"),color:"#fdba74",gradientColor:"#fb923c",yAxisId:"right"},{type:"line",dataKey:"gscClicks",name:a("seoDashboard.unifiedTraffic.realClicks","Clics réels (Search Console)"),color:"#f97316",yAxisId:"left"}]:[{type:"area",dataKey:"dfseoCount",name:a("seoDashboard.unifiedTraffic.dfseoVisibility","Mots-clés positionnés (estimation)"),color:"#fdba74",gradientColor:"#fb923c",yAxisId:"right"},{type:"line",dataKey:"dfseoEtv",name:a("seoDashboard.unifiedTraffic.estimateTraffic","Estimation trafic (théorique)"),color:"#f97316",dashed:!0,yAxisId:"left"}],ee=r?e.jsx("p",{className:"text-xs text-gray-400 leading-relaxed",children:a("seoDashboard.unifiedTraffic.disclaimerReal","Données mesurées directement par Google Search Console sur vos visiteurs réels.")}):e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 sm:gap-3 pt-4 border-t border-gray-100",children:[e.jsxs("p",{className:"text-xs text-gray-500 leading-relaxed flex items-start gap-1.5 min-w-0 sm:flex-1",children:[e.jsxs("svg",{className:"w-3.5 h-3.5 text-gray-400 flex-shrink-0 mt-px",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 8h.01M11 12h1v4h1"})]}),e.jsx("span",{children:a("seoDashboard.unifiedTraffic.disclaimerEstimate","Estimation théorique = volume Google à taux de clic moyen selon votre position.")})]}),e.jsxs("button",{type:"button",onClick:w,className:"inline-flex items-center gap-1 text-xs font-medium text-orange-500 hover:text-orange-600 transition-colors flex-shrink-0 self-start sm:self-auto",children:[e.jsx("span",{className:"text-left",children:a("seoDashboard.unifiedTraffic.connectCta","Connecter Search Console pour vos vrais clics")}),e.jsx("svg",{className:"w-3 h-3 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]})]});return e.jsx(ra,{title:a("seoDashboard.unifiedTraffic.title","Trafic organique mensuel"),subtitle:r?a("seoDashboard.unifiedTraffic.subtitleReal","Clics et impressions mesurés par Google sur 12 mois"):a("seoDashboard.unifiedTraffic.subtitleEstimateOnly","Estimation théorique du trafic sur 12 mois"),rightSlot:Q,data:S,xKey:"label",series:J,dualAxis:!0,inlineLegend:F,yTickFormatter:f=>f>=1e3?`${M(f/1e3)}k`:M(f),footer:ee})},ir=({className:s,...t})=>e.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!t["aria-label"],role:t["aria-label"]?"img":void 0,className:s,...t,children:[e.jsx("path",{d:"M7.86 2h8.28L22 7.86v8.28L16.14 22H7.86L2 16.14V7.86L7.86 2z"}),e.jsx("path",{d:"M12 8v5",stroke:"white",strokeWidth:"2.2",strokeLinecap:"round",fill:"none"}),e.jsx("circle",{cx:"12",cy:"16.6",r:"1.15",fill:"white"})]}),lr=({className:s,...t})=>e.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!t["aria-label"],role:t["aria-label"]?"img":void 0,className:s,...t,children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),e.jsx("path",{d:"M12 9.5v4",stroke:"white",strokeWidth:"2.2",strokeLinecap:"round",fill:"none"}),e.jsx("circle",{cx:"12",cy:"17",r:"1.15",fill:"white"})]}),cr=({snapshot:s,onRecommendationClick:t})=>{const{t:r}=D(),[a,o]=u.useState(!1),n=s.ai_analysis;return e.jsxs("div",{className:"bg-white/70 backdrop-blur-xl border border-gray-200/60 rounded-2xl shadow-sm p-6",children:[e.jsx("div",{className:"flex items-center gap-3 pb-4 border-b border-gray-100 mb-5",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900",children:r("seoDashboard.aiAnalysis.title","Analyse IA")}),e.jsx("p",{className:"text-sm text-gray-500",children:r("seoDashboard.aiAnalysis.subtitle","Résumé et recommandations priorisées")})]})}),n?e.jsxs(e.Fragment,{children:[n.summary&&e.jsx("p",{className:"text-sm text-gray-700 leading-relaxed mb-6",children:n.summary}),n.recommendations.length===0?e.jsx("p",{className:"text-sm text-gray-500 italic",children:r("seoDashboard.aiAnalysis.noRecommendations","Aucune recommandation à afficher pour ce snapshot.")}):e.jsx(dr,{recos:n.recommendations,expanded:a,onToggleExpand:o,onRecommendationClick:t})]}):e.jsx(mr,{})]})},ys={critical:0,important:1,"nice-to-have":2},dr=({recos:s,expanded:t,onToggleExpand:r,onRecommendationClick:a})=>{const{t:o}=D(),n=[...s].sort((d,l)=>(ys[d.priority]??3)-(ys[l.priority]??3)),m=t?n:n.slice(0,1),i=n.length-m.length,c=d=>
4{if(a&&da(d))return()=>a(d)};return e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"space-y-2.5",children:m.map((d,l)=>e.jsx(ur,{reco:d,onClick:c(d)},l))}),i>0&&e.jsxs("button",{onClick:()=>r(!0),className:"mt-4 w-full flex items-center justify-center gap-1.5 px-4 py-2.5 text-sm font-medium text-orange-500 hover:bg-orange-50 border border-dashed border-gray-200 hover:border-orange-200 rounded-xl transition-colors",children:[e.jsx(ae,{className:"w-4 h-4"}),o("seoDashboard.aiAnalysis.showAll","Voir les {{count}} autres recommandations",{count:i})]}),t&&n.length>1&&e.jsx("button",{onClick:()=>r(!1),className:"mt-4 w-full text-xs font-medium text-gray-500 hover:text-gray-700 transition-colors",children:o("seoDashboard.aiAnalysis.showLess","Réduire")})]})},mr=()=>{const{t:s}=D();return e.jsxs("div",{className:"text-center py-8 px-4",children:[e.jsx(ke,{className:"w-8 h-8 text-gray-300 mx-auto mb-3"}),e.jsx("p",{className:"text-sm text-gray-600 mb-1",children:s("seoDashboard.aiAnalysis.empty.title","L'analyse IA n'a pas pu être générée.")}),e.jsx("p",{className:"text-xs text-gray-500",children:s("seoDashboard.aiAnalysis.empty.hintAuto","Elle sera relancée automatiquement au prochain scan.")})]})},js={critical:{fallbackLabel:"Critique",barColor:"bg-red-500",Icon:ir,iconColor:"text-red-500"},important:{fallbackLabel:"Important",barColor:"bg-orange-500",Icon:lr,iconColor:"text-orange-500"},"nice-to-have":{fallbackLabel:"Optionnel",barColor:"bg-gray-300",Icon:Nt,iconColor:"text-gray-400"}},ur=({reco:s,onClick:t})=>{const{t:r}=D(),a=js[s.priority]||js.important,o=a.Icon,n=r(`seoDashboard.aiAnalysis.priority.${s.priority}`,a.fallbackLabel),m=!!t,i=e.jsxs("div",{className:"flex items-stretch",children:[e.jsx("div",{className:`w-1 flex-shrink-0 ${a.barColor}`}),e.jsxs("div",{className:"p-4 flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx(o,{className:`w-4 h-4 flex-shrink-0 ${a.iconColor}`,"aria-label":n}),e.jsx("h3",{className:"text-sm font-semibold text-gray-900 min-w-0 flex-1",children:s.title}),m&&e.jsx(Te,{className:"w-4 h-4 text-gray-300 group-hover:text-orange-500 transition-colors flex-shrink-0"})]}),e.jsx("p",{className:"text-sm text-gray-600 leading-relaxed mb-1",children:s.what}),s.why&&e.jsx("p",{className:"text-xs text-gray-400 italic leading-relaxed",children:s.why})]})]});return m?e.jsx("li",{children:e.jsx("button",{type:"button",onClick:t,className:"w-full text-left bg-white border border-gray-200 hover:border-orange-300 hover:bg-orange-50/30 rounded-xl overflow-hidden transition-colors group",children:i})}):e.jsx("li",{className:"bg-white border border-gray-200 rounded-xl overflow-hidden",children:i})},hr=({bulleId:s,onStatusChange:t})=>{const{t:r}=D(),[a,o]=u.useState(null),[n,m]=u.useState(!0),i=u.useCallback(async()=>{if(ne(s)){o({connected:!1}),t==null||t({connected:!1}),m(!1);return}m(!0);try{const g=await Ms(s);o(g),t==null||t(g)}catch{o({connected:!1}),t==null||t({connected:!1})}finally{m(!1)}},[s,t]);u.useEffect(()=>{i()},[i]),Es(()=>{_.success(r("seoDashboard.gsc.connectedToast","Search Console connecté !")),i()},g=>{_.error(g||r("seoDashboard.gsc.connectFailed","La connexion à Search Console a échoué."))});const[c,d]=u.useState(!1),l=async()=>{if(!ne(s)){d(!0);try{await We(s)}catch(g){_.error(H(g,r("seoDashboard.gsc.cannotStart","Impossible de démarrer la connexion.")))}finally{d(!1)}}},[h,x]=u.useState(!1),[w,p]=u.useState(!1),b=()=>x(!0),v=async()=>{p(!0);try{await Yt(s),await i(),x(!1)}catch(g){_.error(H(g,r("seoDashboard.gsc.disconnectFailed","Déconnexion impossible.")))}finally{p(!1)}};if(n)return e.jsx("section",{className:"bg-white rounded-2xl border border-slate-200 p-4",children:e.jsxs("div",{className:"flex items-center gap-2 text-slate-400 text-sm",children:[e.jsx(te,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{children:r("seoDashboard.gsc.loading","Chargement Search Consoleâ¦")})]})});if(!(a!=null&&a.connected))return e.jsxs("section",{className:"bg-white rounded-2xl border border-slate-200 p-5 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(ve,{className:"w-5 h-5 text-slate-400 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-slate-900",children:r("seoDashboard.gsc.connectTitleSlim","Google Search Console")}),e.jsx("div",{className:"text-xs text-slate-500",children:r("seoDashboard.gsc.connectShortDesc","Connectez votre Search Console pour voir vos vraies données Google (clics, requêtes, positions).")})]})]}
4),e.jsxs("button",{onClick:l,disabled:c,className:"flex-shrink-0 inline-flex items-center gap-1.5 px-3 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-lg transition-colors disabled:opacity-60",children:[c?e.jsx(te,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(ve,{className:"w-3.5 h-3.5"}),c?r("seoDashboard.gsc.connecting","Ouverture de Googleâ¦"):r("seoDashboard.gsc.connectShort","Connecter (1 clic)")]})]});if(a.connected&&!a.site_url){const g=Wt(a.property_issue);return e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"bg-white rounded-2xl border border-slate-200 p-5 flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(Ne,{className:"w-5 h-5 text-amber-500 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-slate-900",children:r(g.titleKey,g.titleFallback)}),e.jsx("div",{className:"text-xs text-slate-500",children:r(g.descKey,g.descFallback,{email:a.google_account_email||"Google"})})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[g.action==="set_website_url"?e.jsx(Ss,{to:"/dashboard/seo",className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-orange-500 hover:bg-orange-50 rounded-lg transition-colors",children:r(g.actionKey,g.actionFallback)}):e.jsxs("button",{onClick:g.action==="retry"?i:l,disabled:c,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-orange-500 hover:bg-orange-50 rounded-lg transition-colors disabled:opacity-60",children:[c&&e.jsx(te,{className:"w-3.5 h-3.5 animate-spin"}),r(g.actionKey,g.actionFallback)]}),e.jsxs("button",{onClick:b,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs text-slate-600 hover:text-red-600 hover:bg-red-50 rounded-lg transition-colors",children:[e.jsx(us,{className:"w-3.5 h-3.5"}),r("seoDashboard.gsc.disconnect","Déconnecter")]})]})]}),e.jsx($e,{isOpen:h,title:r("seoDashboard.gsc.confirmDisconnect.title","Déconnecter Google Search Console ?"),subtitle:a.google_account_email||void 0,description:r("seoDashboard.gsc.confirmDisconnect.description","Les données mises en cache seront supprimées. Vous pourrez reconnecter Search Console à tout moment."),confirmLabel:r("seoDashboard.gsc.disconnect","Déconnecter"),hideConfirmIcon:!0,loading:w,onConfirm:v,onCancel:()=>x(!1)})]})}return e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"bg-white rounded-2xl border border-slate-200 p-4 flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(Ve,{className:"w-5 h-5 text-green-600 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-slate-900",children:r("seoDashboard.gsc.connectedTitle","Search Console connecté")}),e.jsxs("div",{className:"text-xs text-slate-500 truncate",children:[a.google_account_email," · ",xr(a.site_url)]})]})]}),e.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:e.jsxs("button",{onClick:b,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs text-slate-600 hover:text-red-600 hover:bg-red-50 rounded-lg transition-colors",children:[e.jsx(us,{className:"w-3.5 h-3.5"}),r("seoDashboard.gsc.disconnect","Déconnecter")]})})]}),e.jsx($e,{isOpen:h,title:r("seoDashboard.gsc.confirmDisconnect.title","Déconnecter Google Search Console ?"),subtitle:a.google_account_email,description:r("seoDashboard.gsc.confirmDisconnect.description","Les données mises en cache seront supprimées. Vous pourrez reconnecter Search Console à tout moment."),confirmLabel:r("seoDashboard.gsc.disconnect","Déconnecter"),hideConfirmIcon:!0,loading:w,onConfirm:v,onCancel:()=>x(!1)})]})};function xr(s){return s.replace(/^sc-domain:/,"")}function pr(){return e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl p-4 space-y-3",children:[e.jsx("div",{className:"w-4 h-4 bg-gray-200 rounded"}),e.jsx(V,{w:"w-16",h:"h-7",tone:"bg-gray-200"}),e.jsx(V,{w:"w-24",h:"h-3"})]})}function br(){return e.jsxs("main",{className:"flex-1 w-full max-w-5xl mx-auto px-4 sm:px-6 py-6 sm:py-8","aria-hidden":"true",role:"status","aria-label":"Chargement",children:[e.jsx(oa,{subtitle:!0}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 mb-4 animate-pulse",children:[0,1,2,3].map(s=>e.jsx(pr,{},s))}),e.jsx("div",{className:"bg-white/70 rounded-2xl border border-gray-200/60 p-5 mb-4 animate-pulse",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-gray-200 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[e.jsx(V,{w:"w-32",h:"h-3"}),e.jsx(V,{w:"w-56",h:"h-4",tone:"bg-gray-200"})]}),e.jsx("div",{className:"h-10 w-36 bg-gray-200 rounded-xl flex-shrink-0 hidden sm:block"})]})}),e.jsx("div",{className:"flex gap-1 p-1.5 mb-6 bg-white/85 border border-gray-200/60 rounded-full w-max max-w-full animate-pulse",children:[0,1,2,3,4].map(s=>e.jsx("div",{className:"h-9 w-28 bg-gray-100 rounded-full"},s))}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4 items-start",children:[e.jsxs("div",{className:"lg:col-span-2 bg-white/70 rounded-2xl border border-gray-200/60 p-6 animate-pulse",children:[e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsx(V,{w:"w-40",h:"h-4",tone:"bg-gray-200"}),e.jsx(V,{w:"w-60",h:"h-3"})]}),e.jsx("div",{className:"h-56 bg-gray-100 rounded-xl"})]}),e.jsxs("div",{className:"bg-white/70 rounded-2xl border border-gray-200/60 p-6 animate-pulse",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-14 h-14 roun
4ded-full bg-gray-100 flex-shrink-0"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(V,{w:"w-36",h:"h-4",tone:"bg-gray-200"}),e.jsx(V,{w:"w-44",h:"h-3"})]})]}),e.jsx("div",{className:"mt-4 space-y-3",children:[0,1,2,3].map(s=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between mb-1.5",children:[e.jsx(V,{w:"w-32",h:"h-4"}),e.jsx(V,{w:"w-10",h:"h-4"})]}),e.jsx("div",{className:"h-1.5 rounded-full bg-gray-100"})]},s))})]})]}),e.jsxs("div",{className:"bg-white/70 rounded-2xl border border-gray-200/60 p-6 animate-pulse space-y-2",children:[e.jsx(V,{w:"w-28",h:"h-4",tone:"bg-gray-200"}),e.jsx(V,{w:"w-full",h:"h-3"}),e.jsx(V,{w:"w-11/12",h:"h-3"}),e.jsx(V,{w:"w-9/12",h:"h-3"})]})]})]})}const he=[{id:"seo-overview",tabKey:"overview"},{id:"seo-performance",tabKey:"performance"},{id:"seo-strategy",tabKey:"strategy"},{id:"seo-technical",tabKey:"technical"},{id:"seo-connections",tabKey:"connections"}],Fe=Object.fromEntries(he.map(s=>[s.tabKey,s.id]));function Ze(s){const t=document.getElementById(s);t&&t.scrollIntoView({behavior:"smooth",block:"start"})}const gr=()=>{const{t:s}=D(),[t,r]=u.useState(he[0].id);u.useEffect(()=>{const o=()=>{const n=window.scrollY+140;let m=he[0].id;for(const i of he){const c=document.getElementById(i.id);c&&c.offsetTop<=n&&(m=i.id)}r(m)};return window.addEventListener("scroll",o,{passive:!0}),o(),()=>window.removeEventListener("scroll",o)},[]);const a={overview:s("seoDashboard.tabs.overview","Vue d'ensemble"),performance:s("seoDashboard.tabs.performance","Performances"),strategy:s("seoDashboard.tabs.strategy","Opportunités"),technical:s("seoDashboard.tabs.technical","Technique"),connections:s("seoDashboard.tabs.connections","Connexions")};return e.jsx("nav",{"data-tutorial":"seo-tabs",className:"sticky top-3 z-30 flex gap-1 p-1.5 mb-6 bg-white/85 backdrop-blur-xl border border-gray-200/60 rounded-full shadow-sm w-max max-w-full overflow-x-auto [scrollbar-width:none]",children:he.map(o=>e.jsx("button",{type:"button","data-tutorial":o.tabKey==="connections"?"seo-gsc-connect":void 0,onClick:()=>Ze(o.id),className:`whitespace-nowrap px-4 py-2 rounded-full text-sm font-medium transition-colors ${t===o.id?"bg-orange-50 text-orange-500":"text-slate-600 hover:text-slate-900"}`,children:a[o.tabKey]},o.id))})},Or=()=>{var os,ns;const{t:s}=D(),t=Ke(),[r,a]=Ue(),{allowed:o,loading:n}=Et(),{isBulleFreemium:m,subscriptionStatus:i}=at(),{currentUser:c}=rt(),{selectedSphere:d}=ot(),{selectedBulle:l,bulles:h}=nt(),{isRunning:x}=it(),w=!n&&!o&&!x&&m,p=x||w,b=p||ne(l==null?void 0:l.id),{pillar:v,loading:g}=At("web"),S=p?mt:d,y=p?ms:l,E=p?[ms]:h,C=Ce.useMemo(()=>w?{config:ds(),snapshot:cs()}:null,[w]),[N,P]=u.useState(x?ds():null),[A,O]=u.useState(x?cs():null),[q,G]=u.useState(!1),[B,k]=u.useState(null),[j,T]=u.useState(null),z=!!(j!=null&&j.connected&&(j!=null&&j.site_url)&&(j!=null&&j.has_cached_data));u.useEffect(()=>{if(T(null),!o||!(l!=null&&l.id)||b)return;let L=!1;return Ms(l.id).then(I=>{L||T(I)}).catch(()=>{L||T({connected:!1})}),()=>{L=!0}},[o,l==null?void 0:l.id,b]);const[Z,re]=u.useState(""),[X,Q]=u.useState(!1),[F,J]=u.useState(!1),[ee,W]=u.useState(null),f=Lt([{id:"keywords",label:s("seoDashboard.scan.phrases.keywords","On repère vos mots-clés positionnés sur Googleâ¦"),progress:25},{id:"competitors",label:s("seoDashboard.scan.phrases.competitors","On compare votre site à vos concurrentsâ¦"),progress:50},{id:"onpage",label:s("seoDashboard.scan.phrases.onpage","On audite la santé technique de vos pagesâ¦"),progress:75},{id:"opportunities",label:s("seoDashboard.scan.phrases.opportunities","On cherche des opportunités à exploiterâ¦"),progress:100}]),$=u.useRef([]),oe=()=>{$.current.forEach(L=>clearTimeout(L)),$.current=[]};u.useEffect(()=>oe,[]);const ie=Be((l==null?void 0:l.id)??"");ie.onScopeChange(()=>{J(!1),W(null),oe(),f.reset()}),u.useEffect(()=>{!o||!(l!=null&&l.id)||b||(G(!0),k(null),Promise.all([hs(l.id),Qt(l.id)]).then(([L,I])=>{P(L),O(I.snapshot),re((L==null?void 0:L.website_url)||"")}).catch(L=>{k(H(L,s("seoDashboard.errors.configFailed","Impossible de charger la configuration.")))}).finally(()=>G(!1)))},[o,l==null?void 0:l.id,b,s]),u.useEffect(()=>{!n&&!o&&!x&&i&&!m&&t("/dashboard",{replace:!0})},[n,o,t,x,i,m]);const es=u.useRef(new Set),pe=u.useRef(null);u.useEffect(()=>{var L,I,Pe;!o||n||b||q||F||!(l!=null&&l.id)||!N||es.current.has(l.id)||N.website_url&&(A||(((I=(L=N.quota)==null?void 0:L.scans)==null?void 0:I.remaining)??0)<=0||ee||(es.current.add(l.id),(Pe=pe.current)==null||Pe.call(pe,{silent:!0})))},[o,n,b,q,l==null?void 0:l.id,N==null?void 0:N.website_url,(ns=(os=N==null?void 0:N.quota)==null?void 0:os.scans)==null?void 0:ns.remaining,A,F,ee]);const Ae=(c==null?void 0:c.uid)??null,[Ws,ss]=u.useState(!0);u.useEffect(()=>{ss(ua(Ae,l==null?void 0:l.id))},[Ae,l==null?void 0:l.id]);const ts=()=>{ha(Ae,l==null?void 0:l.id),ss(!0)},as=xa({skipNetwork:b,loadingInitial:q,scanning:F,websiteUrl:N==null?void 0:N.website_url,gscStatusKnown:j!==null,gscConnected:!!(j!=null&&j.connected),alreadySeen:Ws}),Ys=lt("seo-gsc-connect",ct.SEO_GSC_CONNECT,as);if(!p&&(n||!o))return e.jsx(be,{children:e.jsx(br,{})});const Qs=async()=>
4{if(b||!(l!=null&&l.id))return;const L=ie.begin(l.id,"config");Q(!0);try{await Jt(l.id,Z.trim()||null);const I=await hs(l.id);if(L.isStale())return;P(I),re((I==null?void 0:I.website_url)||"")}catch(I){if(L.isStale())return;_.error(H(I,s("seoDashboard.errors.saveUrlFailed","Impossible d'enregistrer l'URL.")))}finally{L.isStale()||Q(!1)}},rs=async L=>{var is,ls;if(b||!(l!=null&&l.id))return;const I=ie.begin(l.id,"scan");J(!0),W(null),!!A&&(f.setStepLabel("keywords",s("seoDashboard.scan.phrasesRefresh.keywords","On vérifie l'évolution de vos positions Googleâ¦")),f.setStepLabel("competitors",s("seoDashboard.scan.phrasesRefresh.competitors","On revoit le palmarès de vos concurrentsâ¦")),f.setStepLabel("onpage",s("seoDashboard.scan.phrasesRefresh.onpage","On réaudite la santé technique de vos pagesâ¦")),f.setStepLabel("opportunities",s("seoDashboard.scan.phrasesRefresh.opportunities","On cherche de nouvelles opportunitésâ¦"))),f.start(),oe(),$.current.push(setTimeout(()=>f.advance(),12e3),setTimeout(()=>f.advance(),25e3),setTimeout(()=>f.advance(),45e3));try{const Y=await Xt(l.id,{shouldAbort:I.isStale});if(I.isStale())return;if(!(Y!=null&&Y.snapshot))throw new Error(s("seoDashboard.scan.failed","Le scan a échoué."));if(O(Y.snapshot),P(se=>se&&{...se,quota:Y.quota,last_scan_at:Y.snapshot.scanned_at,last_scan_status:Y.snapshot.scan_status}),L!=null&&L.silent?_.success(s("seoDashboard.scan.autoFirstSuccess","Première analyse SEO lancée automatiquement. Prochain scan disponible le {{date}}.",{date:dt(Y.quota.resets_at)})):_.success(s("seoDashboard.scan.success","Scan terminé ! {{count}} mots-clés analysés.",{count:((ls=(is=Y.snapshot.ranked_keywords)==null?void 0:is.keywords)==null?void 0:ls.length)||0})),oe(),f.completeAll(),await new Promise(se=>setTimeout(se,600)),I.isStale())return;const ce=r.get("tab");if(ce&&ce!=="overview"){const se=new URLSearchParams(r);se.delete("tab"),a(se,{replace:!0})}}catch(Y){if(I.isStale())return;const ce=H(Y,s("seoDashboard.scan.failed","Le scan a échoué."));W(ce),oe(),f.fail(ce),L!=null&&L.silent||_.error(ce)}finally{I.isStale()||J(!1)}};pe.current=rs;const U=C?C.config:N,le=C?C.snapshot:A,Xs=(()=>{if(U!=null&&U.website_url)try{return new URL(U.website_url).hostname.replace(/^www\./,"")}catch{return U.website_url}return(y==null?void 0:y.name)||""})();return S?E.length===0?e.jsx(be,{children:e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(Mt,{description:s("seoDashboard.empty.noBulleInSphere.description","Créez votre première bulle pour suivre votre référencement SEO.")})})}):e.jsx(be,{children:e.jsxs("main",{className:"flex-1 w-full max-w-5xl mx-auto px-4 sm:px-6 py-6 sm:py-8 stagger-rise",children:[e.jsx(Tt,{icon:e.jsx(kt,{className:"w-5 h-5"}),title:s("seoDashboard.title","Dashboard SEO"),subtitle:Xs||void 0,helpKey:"seoDashboard",videoKey:"seo"}),y?q?e.jsx(Pa,{}):B?e.jsx(ws,{icon:Ne,title:s("seoDashboard.errors.title","Une erreur est survenue"),description:B}):!U||U.website_url_source==="none"?e.jsx(yr,{bulleName:(U==null?void 0:U.bulle_name)||y.name,urlDraft:Z,setUrlDraft:re,onSave:Qs,saving:X}):e.jsxs(e.Fragment,{children:[le&&!F&&e.jsx("div",{className:"mb-4",children:e.jsx(wr,{snapshot:le,bulleId:y.id,gscConnected:z})}),F?e.jsx("div",{className:"bg-white rounded-2xl border border-slate-200 p-5 mb-4 flex flex-col justify-center",children:e.jsx(As,{title:le?s("seoDashboard.scan.refreshingTitle","Rafraîchissement de l'analyse SEOâ¦"):s("seoDashboard.scan.scanningTitle","Analyse SEO en coursâ¦"),steps:f.steps,error:f.error,compact:!0})}):e.jsx(jr,{config:U,snapshot:le,bulleId:y.id,scanError:ee,onScan:rs}),F&&!le?e.jsx(Ea,{}):e.jsx(fr,{snapshot:le,setSnapshot:O,config:U,setConfig:P,selectedBulleId:y.id,gscConnectedWithSite:z,setGscStatus:T,webPillar:p?null:v,webPillarLoading:g}),e.jsx(pa,{isOpen:as&&Ys,bulleId:y.id,onClose:ts,onConnected:ts})]}):e.jsx(ws,{icon:Ne,title:s("seoDashboard.empty.noBulle.title","Sélectionnez une bulle"),description:s("seoDashboard.empty.noBulle.description","Choisissez une bulle depuis le sélecteur en haut pour voir son dashboard SEO.")})]})}):e.jsx(be,{children:e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(qt,{})})})},fr=({snapshot:s,setSnapshot:t,config:r,setConfig:a,selectedBulleId:o,gscConnectedWithSite:n,setGscStatus:m,webPillar:i,webPillarLoading:c})=>{var w;const{t:d}=D(),[l,h]=Ue();u.useEffect(()=>{const p=l.get("tab");if(!p)return;const b=Fe[p],v=new URLSearchParams(l);if(v.delete("tab"),h(v,{replace:!0}),!b)return;const g=()=>{const y=document.getElementById(b);y&&y.scrollIntoView({behavior:"auto",block:"start"})},S=[setTimeout(g,50),setTimeout(g,300),setTimeout(g,1200)];return()=>S.forEach(clearTimeout)},[]);const x=async p=>{if(p.category==="gsc_connect"){try{await We(o)}catch(v){_.error(H(v,d("seoDashboard.gsc.cannotStart","Impossible de démarrer la connexion.")))}return}const b=ca(p);b&&Ze(Fe[b]??"seo-overview")};return e.jsxs("div",{className:"mt-2",children:[e.jsx(gr,{}),e.jsx("section",{id:"seo-overview","data-tutorial":"seo-overview",className:"scroll-mt-24",children:s?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4 items-start",children:[e.jsx("div",{className:"lg:col-span-2 space-y-4 min-w-0",children:e.jsx(nr,{snapshot:s,bulleId:o,gscConnected:n})}),e.jsx("div",{className:"space-y-4 min-w-0",children:e.jsx(Pt,{pillar:"web",data:i,loading:c})})]}),e.jsx(cr,{snapshot:s,bulleId:o,onSnapshotUpdate:t,onRecommendationClick:x})]}):e.jsx(Ie,{title:d("seoDashboard.tabsEmpty.overview.title","Pas encore de scan"),description:d("seoDashboard.tabsEmpty.overview.description","
4Lancez votre première analyse SEO (bouton orange en haut) pour voir votre vue d'ensemble.")})}),e.jsxs("section",{id:"seo-performance",className:"scroll-mt-24",children:[e.jsx(we,{icon:Ls,iconBg:"bg-orange-50",iconColor:"text-orange-500",title:d("seoDashboard.tabs.performance","Performances")}),s||n?e.jsxs("div",{className:"space-y-4",children:[n?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 items-start",children:[s&&e.jsx(ps,{snapshot:s}),e.jsx(Ka,{bulleId:o})]}),e.jsx(Oa,{bulleId:o})]}):s&&e.jsx(ps,{snapshot:s}),s&&e.jsx(ga,{snapshot:s})]}):e.jsx(Ie,{title:d("seoDashboard.tabsEmpty.performance.title","Données indisponibles"),description:d("seoDashboard.tabsEmpty.performance.description","Lancez un scan ou connectez Search Console pour voir vos performances.")})]}),e.jsxs("section",{id:"seo-strategy",className:"scroll-mt-24",children:[e.jsx(we,{icon:He,iconBg:"bg-orange-50",iconColor:"text-orange-500",title:d("seoDashboard.tabs.strategy","Opportunités")}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(qa,{bulleId:o,hasWebsiteUrl:!!(r!=null&&r.website_url),refreshQuota:(w=r==null?void 0:r.quota)==null?void 0:w.keyword_refreshes,onQuotaChange:p=>a(b=>b&&{...b,quota:p})}),e.jsx($a,{bulleId:o}),s&&e.jsx(Da,{snapshot:s}),e.jsx(_a,{bulleId:o,quota:r.quota,onQuotaUpdate:p=>a(b=>b&&{...b,quota:p})})]})]}),e.jsxs("section",{id:"seo-technical",className:"scroll-mt-24",children:[e.jsx(we,{icon:ze,iconBg:"bg-orange-50",iconColor:"text-orange-500",title:d("seoDashboard.tabs.technical","Technique")}),s?e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ja,{bulleId:o}),e.jsx(wa,{snapshot:s})]}):e.jsx(Ie,{title:d("seoDashboard.tabsEmpty.technical.title","Audit technique non disponible"),description:d("seoDashboard.tabsEmpty.technical.description","Lancez un scan pour analyser la santé technique de votre site.")})]}),e.jsxs("section",{id:"seo-connections",className:"scroll-mt-24",children:[e.jsx(we,{icon:ve,iconBg:"bg-orange-50",iconColor:"text-orange-500",title:d("seoDashboard.tabs.connections","Connexions")}),e.jsx(hr,{bulleId:o,onStatusChange:m})]})]})},Ie=({title:s,description:t})=>e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-200 p-12 text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-slate-900 mb-2",children:s}),e.jsx("p",{className:"text-slate-600 max-w-md mx-auto text-sm",children:t})]}),we=({icon:s,iconBg:t,iconColor:r,title:a,anchorId:o})=>e.jsxs("div",{id:o,className:"flex items-center gap-3 mt-8 mb-4 scroll-mt-24",children:[e.jsx("div",{className:`p-1.5 rounded-lg ${t}`,children:e.jsx(s,{className:`w-4 h-4 ${r}`})}),e.jsx("h2",{className:"text-xs uppercase tracking-wider font-semibold text-slate-500",children:a}),e.jsx("div",{className:"flex-1 h-px bg-slate-200"})]}),ws=({icon:s,title:t,description:r})=>e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-200 p-12 text-center",children:[e.jsx(s,{className:"w-10 h-10 text-slate-400 mx-auto mb-4"}),e.jsx("h2",{className:"text-lg font-semibold text-slate-900 mb-2",children:t}),e.jsx("p",{className:"text-slate-600 max-w-md mx-auto",children:r})]}),yr=({bulleName:s,urlDraft:t,setUrlDraft:r,onSave:a,saving:o})=>{const{t:n}=D(),m=[{key:"keywords",Icon:_s,titleKey:"seoDashboard.urlInput.benefits.keywords.title",titleFallback:"Vos mots-clés positionnés sur Google",descKey:"seoDashboard.urlInput.benefits.keywords.desc",descFallback:"Position, volume, évolution mois par mois"},{key:"competitors",Icon:St,titleKey:"seoDashboard.urlInput.benefits.competitors.title",titleFallback:"Les concurrents organiques",descKey:"seoDashboard.urlInput.benefits.competitors.desc",descFallback:"Sites qui se positionnent sur vos mêmes mots-clés"},{key:"onpage",Icon:Ge,titleKey:"seoDashboard.urlInput.benefits.onpage.title",titleFallback:"L'audit technique complet",descKey:"seoDashboard.urlInput.benefits.onpage.desc",descFallback:"Lighthouse, Core Web Vitals, SEO on-page"},{key:"opportunities",Icon:He,titleKey:"seoDashboard.urlInput.benefits.opportunities.title",titleFallback:"Des opportunités de mots-clés",descKey:"seoDashboard.urlInput.benefits.opportunities.desc",descFallback:"Termes à fort potentiel pour grimper dans Google"}];return e.jsxs("div",{className:"bg-white/70 backdrop-blur-xl border border-gray-200/60 rounded-2xl shadow-sm p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 pb-4 border-b border-gray-100 mb-4",children:[e.jsx("div",{className:"w-10 h-10 bg-orange-100 rounded-xl flex items-center justify-center flex-shrink-0",children:e.jsx(Dt,{className:"w-5 h-5 text-orange-500"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-900 flex items-center gap-1.5",children:[e.jsx("span",{children:n("seoDashboard.urlInput.title","Démarrez votre suivi SEO")}),e.jsx(K,{content:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"block font-semibold mb-1.5 text-gray-900",children:n("seoDashboard.scan.tooltipExplainTitle","Ce que fait une analyse SEO")}
4),e.jsx("span",{className:"block text-gray-600 leading-relaxed",children:n("seoDashboard.scan.tooltipExplain","On récupère vos mots-clés positionnés sur Google, vos concurrents organiques, la santé technique de votre site et des opportunités de mots-clés à exploiter.")})]})})]}),e.jsx("p",{className:"text-sm text-gray-500 truncate",children:n("seoDashboard.urlInput.subtitle","Site web de « {{bulle}} »",{bulle:s})})]})]}),e.jsx("div",{className:"space-y-4 mb-6",children:e.jsxs("div",{children:[e.jsx("label",{htmlFor:"seo-url-input",className:"block text-sm font-medium text-gray-700 mb-2",children:n("seoDashboard.urlInput.inputLabel","URL du site")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx("input",{id:"seo-url-input",type:"url",value:t,onChange:i=>r(i.target.value),placeholder:"https://votre-site.fr",className:"flex-1 px-4 py-2 rounded-lg border border-gray-200 focus:ring-2 focus:ring-orange-500 focus:border-transparent text-gray-900"}),e.jsx(me,{disabled:!t.trim(),onDisabledClick:()=>{_.warning(n("seoDashboard.urlInput.blocked.urlRequired","Saisissez l'URL de votre site"))},children:e.jsx(_e,{radius:"xl",onClick:a,disabled:!t.trim(),isLoading:o,loadingLabel:n("seoDashboard.urlInput.saving","Enregistrementâ¦"),className:"w-full px-5 whitespace-nowrap",children:n("seoDashboard.urlInput.save","Lancer l'analyse")})})]})]})}),e.jsxs("div",{className:"pt-5 border-t border-gray-100",children:[e.jsx("div",{className:"text-sm font-semibold text-gray-900 mb-4",children:n("seoDashboard.urlInput.benefits.title","Vous obtenez")}),e.jsx("div",{className:"space-y-3",children:m.map(({key:i,Icon:c,titleKey:d,descKey:l,titleFallback:h,descFallback:x})=>e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-orange-50 flex items-center justify-center flex-shrink-0",children:e.jsx(c,{className:"w-4 h-4 text-orange-500"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900",children:n(d,h)}),e.jsx("div",{className:"text-xs text-gray-500",children:n(l,x)})]})]},i))})]})]})},jr=({config:s,snapshot:t,bulleId:r,scanError:a,onScan:o})=>{var p,b,v,g;const{t:n,i18n:m}=D(),[i,c]=u.useState(!1),d=((b=(p=s.quota)==null?void 0:p.scans)==null?void 0:b.remaining)??0,l=((g=(v=s.quota)==null?void 0:v.scans)==null?void 0:g.quota)??0,h=d<=0,x=async()=>{c(!0);try{const{downloadLatestSnapshotPdf:S}=await Ds(async()=>{const{downloadLatestSnapshotPdf:y}=await import("./useGscOAuthResult-BCfq4JPS.js").then(E=>E.w);return{downloadLatestSnapshotPdf:y}},__vite__mapDeps([0,1,2,3,4]));await S(r)}catch(S){_.error(H(S,n("seoDashboard.snapshot.exportFailed","Impossible d'exporter le PDF.")))}finally{c(!1)}},w=(()=>{if(!t)return null;const S=new Date(t.scanned_at),y=m.language||"fr",C=new Intl.DateTimeFormat(ue(),{day:"numeric",month:"long",year:"numeric"}).format(S).replace(/(^|\s)([a-zà -ÿ])/,(A,O,q)=>O+q.toUpperCase()),N=String(S.getMinutes()).padStart(2,"0"),P=y.startsWith("fr")?`${S.getHours()}h${N}`:`${String(S.getHours()).padStart(2,"0")}:${N}`;return n("seoDashboard.snapshot.scannedDateTime","{{date}} à {{time}}",{date:C,time:P})})();return e.jsxs("div",{className:"bg-white/70 backdrop-blur-xl rounded-2xl border border-gray-200/60 shadow-sm p-5 mb-4 flex flex-col justify-center",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[t?e.jsx("button",{type:"button",onClick:x,disabled:i,title:n("seoDashboard.snapshot.exportTitle","Télécharger le rapport SEO complet en PDF"),className:"w-9 h-9 rounded-lg bg-orange-500 hover:bg-orange-600 flex items-center justify-center flex-shrink-0 transition-colors disabled:opacity-60 disabled:cursor-not-allowed",children:i?e.jsx(te,{className:"w-4 h-4 text-white animate-spin"}):e.jsx(Ct,{className:"w-4 h-4 text-white"})}):e.jsx("div",{className:"w-9 h-9 rounded-lg bg-orange-500 flex items-center justify-center flex-shrink-0",children:e.jsx(ke,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs text-slate-500 mb-0.5",children:t?n("seoDashboard.snapshot.title","Dernière analyse"):n("seoDashboard.scan.statusLabel","Ãtat")}),e.jsxs("div",{className:"text-sm font-semibold text-slate-900 flex items-center gap-1.5",children:[e.jsx("span",{className:"truncate",children:t?w:n("seoDashboard.scan.firstTitle","Lancer votre première analyse")}),e.jsx(K,{content:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"block font-semibold mb-1.5 text-gray-900",children:n("seoDashboard.scan.tooltipExplainTitle","Ce que fait une analyse SEO")}
4),e.jsx("span",{className:"block text-gray-600 leading-relaxed mb-2.5",children:n("seoDashboard.scan.tooltipExplain","On récupère vos mots-clés positionnés sur Google, vos concurrents organiques, la santé technique de votre site et des opportunités de mots-clés à exploiter.")}),e.jsxs("span",{className:"block pt-2 border-t border-gray-200",children:[e.jsxs("span",{className:"text-gray-500",children:[n("seoDashboard.scan.tooltipQuotaLabel","Quota mensuel")," : "]}),e.jsx("span",{className:"font-medium text-gray-900",children:n("seoDashboard.scan.tooltipQuotaRemaining","{{remaining}}/{{quota}} restant{{plural}}",{remaining:d,quota:l,plural:d>1?"s":""})})]})]})})]})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1.5 flex-shrink-0",children:[e.jsx(me,{disabled:h,onDisabledClick:()=>{_.warning(n("seoDashboard.scan.blocked.quotaReached","Quota mensuel de scans atteint"))},children:e.jsx(_e,{variant:"gradient",radius:"xl",onClick:o,disabled:h,leftIcon:t?e.jsx(Oe,{className:"w-4 h-4"}):e.jsx(ke,{className:"w-4 h-4"}),className:"text-sm",children:t?n("seoDashboard.scan.refresh","Rafraîchir"):n("seoDashboard.scan.start","Lancer l'analyse")})}),e.jsx(Ps,{used:l-d,max:l})]})]}),a&&e.jsx("div",{className:"mt-3 p-3 bg-red-50 border border-red-200 rounded-lg text-sm text-red-700",children:a})]})},wr=({snapshot:s,bulleId:t,gscConnected:r})=>{var C,N,P,A,O,q,G,B,k;const{t:a,i18n:o}=D(),n=j=>Ze(Fe[j]??"seo-overview"),[m,i]=u.useState(null),[c,d]=u.useState([]);u.useEffect(()=>{if(!r){i(null),d([]);return}Ds(async()=>{const{getGscTrafficMonthly:j}=await import("./useGscOAuthResult-BCfq4JPS.js").then(T=>T.w);return{getGscTrafficMonthly:j}},__vite__mapDeps([0,1,2,3,4])).then(({getGscTrafficMonthly:j})=>j(t).then(T=>{i(T.period_comparison||null),d(T.months||[])}).catch(()=>{i(null),d([])}))},[t,r]);const[l,h]=u.useState(null);u.useEffect(()=>{if(ne(t)){h(ks());return}let j=!1;return qs(t).then(T=>{j||h(T)}).catch(()=>{j||h({exists:!1})}),()=>{j=!0}},[t]);const x=((N=(C=s.ranked_keywords)==null?void 0:C.keywords)==null?void 0:N.length)||0,w=((P=s.ranked_keywords)==null?void 0:P.total_count)||x;(O=(A=s.competitors)==null?void 0:A.competitors)!=null&&O.length;const p=(l==null?void 0:l.status)==="completed"?Le(((q=l.summary)==null?void 0:q.aggregated)||{}):null,b=((B=(G=s.keyword_suggestions)==null?void 0:G.keywords)==null?void 0:B.length)||0,v=((k=s.historical_rank)==null?void 0:k.months)||[],g=v.map(j=>j.count||0),S=(()=>{const j=g.length;if(j<2)return null;const T=g[j-1],z=g[j-2];return z?Math.round((T-z)/z*100):null})(),y=(()=>{if(m&&(m.days_compared??99)>=3&&m.current.clicks>=0)return{value:M(m.current.clicks),sub:a("seoDashboard.snapshot.trafficSubGsc","clics, {{label}}",{label:m.current.label}),deltaPct:m.delta_pct,isEstimate:!1,basis:m.comparison_basis==="yoy"?"yoy":"mom"};if(c.length>=1){const X=new Date,Q=c.filter(f=>!(f.year===X.getFullYear()&&f.month===X.getMonth()+1)),F=Q[Q.length-1],J=F?Q.find(f=>f.year===F.year-1&&f.month===F.month):void 0,ee=!!J&&J.clicks>0,W=ee?J:Q[Q.length-2];if(F){const f=new Intl.DateTimeFormat(ut(),{month:"long"}).format(new Date(F.year,F.month-1,1));return{value:M(F.clicks),sub:a("seoDashboard.unifiedTraffic.kpi.realClicksIn","vrais clics en {{month}}",{month:f}),deltaPct:W&&W.clicks>0?Math.round((F.clicks-W.clicks)/W.clicks*100):null,isEstimate:!1,basis:ee?"yoy":"mom"}}}const j=v.map(X=>Math.round(X.etv||0)),T=j.length,z=T>=1?j[T-1]:0,Z=T>=2?j[T-2]:0,re=Z>0?Math.round((z-Z)/Z*100):null;return{value:z>0?`~${M(z)}`:",",sub:a("seoDashboard.snapshot.trafficSubEstimate","trafic estimé / mois"),deltaPct:re,sparkline:j.length>=2?j:void 0,isEstimate:!0}})(),E=p==null?"bg-gray-300":p>=80?"bg-green-500":p>=50?"bg-orange-400":"bg-red-500";return e.jsxs("div",{children:[e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsx(ge,{icon:_t,label:a("seoDashboard.snapshot.rankedKeywords","Mots-clés positionnés"),value:M(w),deltaPct:S,deltaTooltip:a("seoDashboard.snapshot.deltaTooltipRanked","Ãvolution sur 1 mois (dernier mois vs mois précédent dans l'historique)"),sparkline:g.length>=2?g:void 0,onClick:()=>n("performance"),ariaLabel:a("seoDashboard.snapshot.cardAria.rankedKeywords","Voir le détail des mots-clés positionné
4s")}),e.jsx(ge,{icon:Ge,label:a("seoDashboard.snapshot.onpageScore","Santé du site"),value:p!=null?`${p}/100`:"--/100",subline:p==null?a("seoDashboard.snapshot.auditInProgress","Audit en coursâ¦"):void 0,progressBar:p!=null?{pct:p,color:E}:void 0,onClick:()=>n("technical"),ariaLabel:a("seoDashboard.snapshot.cardAria.onpageScore","Voir l'audit technique du site")}),e.jsx(ge,{icon:Ls,label:y.isEstimate?a("seoDashboard.snapshot.trafficEstimate","Trafic mensuel estimé"):a("seoDashboard.snapshot.trafficReal","Clics ce mois-ci"),value:y.value,deltaPct:y.deltaPct,deltaTooltip:y.isEstimate?a("seoDashboard.snapshot.deltaTooltipTrafficEstimate","Ãvolution sur 1 mois (dernier mois vs mois précédent, estimation)"):y.basis==="yoy"?a("seoDashboard.snapshot.deltaTooltipTrafficGscYoy","Ãvolution clics : même fenêtre l'an dernier (comparaison à saisonnalité égale)"):a("seoDashboard.snapshot.deltaTooltipTrafficGsc","Ãvolution clics : même fenêtre du mois en cours vs même fenêtre du mois précédent"),sparkline:y.sparkline,onClick:()=>n("performance"),ariaLabel:a("seoDashboard.snapshot.cardAria.traffic","Voir les performances Google")}),e.jsx(ge,{icon:He,label:a("seoDashboard.snapshot.suggestions","Opportunités à exploiter"),value:M(b),onClick:()=>n("strategy"),ariaLabel:a("seoDashboard.snapshot.cardAria.suggestions","Voir les opportunités SEO")})]}),(()=>{const j=(s.errors||[]).filter(T=>!T.block.startsWith("pagespeed"));return j.length===0?null:e.jsxs("div",{className:"mt-5 pt-4 border-t border-gray-100 text-xs text-gray-500",children:[e.jsx("div",{className:"font-medium mb-1 text-gray-700",children:a("seoDashboard.snapshot.partialWarning","Certains blocs n'ont pas pu être récupérés :")}),e.jsx("ul",{className:"list-disc pl-4 space-y-0.5",children:j.map((T,z)=>e.jsxs("li",{children:[e.jsx("span",{className:"text-gray-700",children:T.block}),", ",T.error]},z))})]})})()]})};export{Or 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.