1import{q as m,r as o,Q as V,j as e,S as W,n as T,h as F,f as p,i as C}from"./index-DYqdqpF7.js";import{R as _}from"./refresh-cw-DhLoVi1d.js";import{C as G}from"./circle-alert-BW8HTM1_.js";import{C as N}from"./chart-column-CGLigiiw.js";import{S as D}from"./sparkles-B1fNcQn3.js";import{E as y}from"./external-link-CDHttz-G.js";import{E}from"./eye-B5Sl9-LJ.js";import{U as w}from"./users-C8B-AzGH.js";import{T as A}from"./trending-up-C5YU6eCu.js";import{L as k}from"./link-2-BcpPtIUj.js";import{M as h,S as R}from"./smartphone-CjjkFnjf.js";import{T as I}from"./ticket-BvbFYPvD.js";import{H as Z}from"./heart-DVcJacAw.js";/** 2 * @license lucide-react v0.468.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const M=m("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/** 7 * @license lucide-react v0.468.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const B=m("Chrome",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["line",{x1:"21.17",x2:"12",y1:"8",y2:"8",key:"a0cw5f"}],["line",{x1:"3.95",x2:"8.54",y1:"6.06",y2:"14",key:"1kftof"}],["line",{x1:"10.88",x2:"15.46",y1:"21.94",y2:"14",key:"1ymyh8"}]]);/** 12 * @license lucide-react v0.468.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const L=m("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** 17 * @license lucide-react v0.468.0 - ISC 18 * 19 * This source code is licensed under the ISC license. 20 * See the LICENSE file in the root directory of this source tree. 21 */const K=m("Tablet",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]]);/** 22 * @license lucide-react v0.468.0 - ISC 23 * 24 * This source code is licensed under the ISC license. 25 * See the LICENSE file in the root directory of this source tree. 26 */const O=m("TrendingDown",[["polyline",{points:"22 17 13.5 8.5 8.5 13.5 2 7",key:"1r2t7k"}],["polyline",{points:"16 17 22 17 22 11",key:"11uiuu"}]]);/** 27 * @license lucide-react v0.468.0 - ISC 28 * 29 * This source code is licensed under the ISC license. 30 * See the LICENSE file in the root directory of this source tree. 31 */const U=m("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function Q(s){if(s<60)return`${Math.round(s)}s`;const t=Math.floor(s/60),r=Math.round(s%60);return`${t}m ${r}s`}function b(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}function $(s,t){return t===0?0:Math.round((s-t)/t*100)}function J(s){const t=s.toLowerCase();return t.includes("mobile")?R:t.includes("tablet")?K:h}function v({icon:s,label:t,value:r,change:i,color:n}){return e.jsxs("div",{className:"bg-card rounded-xl p-5 border border-border hover:border-primary/30 transition-all duration-300 hover:shadow-xl hover:shadow-primary/5",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsx("div",{className:`w-12 h-12 rounded-xl ${n} flex items-center justify-center`,children:e.jsx(s,{size:24,className:"text-white"})}),i!==void 0&&i!==0&&e.jsxs("div",{className:`flex items-center gap-1 text-xs font-medium px-2 py-1 rounded-full ${i>0?"text-emerald-400 bg-emerald-500/20":"text-red-400 bg-red-500/20"}`,children:[i>0?e.jsx(A,{size:12}):e.jsx(O,{size:12}),Math.abs(i),"%"]})]}),e.jsx("p",{className:"text-3xl font-bold text-foreground mb-1",children:r}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t})]})}function c({title:s,icon:t,items:r,total:i,renderItem:n}){return e.jsxs("div",{className:"bg-card rounded-xl border border-border overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b border-border bg-muted/30 flex items-center gap-2",children:[e.jsx(t,{size:18,className:"text-primary"}),e.jsx("h3",{className:"font-semibold text-foreground",children:s}),e.jsxs("span",{className:"ml-auto text-xs text-muted-foreground",children:[i," total"]})]}),e.jsx("div",{className:"divide-y divide-border max-h-[300px] overflow-y-auto",children:r.length===0?e.jsx("div",{className:"p-4 text-center text-muted-foreground text-sm",children:"Aucune donnée"}):r.map((d,x)=>e.jsxs("div",{className:"p-3 flex items-center justify-between hover:bg-muted/50 transition-colors",children:[e.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:n?n(d):e.jsx("span",{className:"text-sm text-foreground truncate",children:d.x||"(direct)"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:b(d.y)}),e.jsx("div",{className:"w-16 h-1.5 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary rounded-full",style:{width:`${i>0?d.y/i*100:0}%`}})})]})]},x))})]})}function X({data:s}){if(!s.length)return null;const t=Math.max(...s.map(r=>r.pageviews),1);return e.jsxs("div",{className:"bg-card rounded-xl border border-border p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(N,{size:18,className:"text-primary"}),e.jsx("h3",{className:"font-semibold text-foreground",children:"Tendance des visites"})]}),e.jsx("div",{className:"flex items-end gap-1 h-24",children:s.map((r,i)=>e.jsx("div",{className:"flex-1 flex flex-col items-center gap-1",title:`${r.date}: ${r.pageviews} pages vues`,children:e.jsx("div",{className:"w-full bg-primary/80 rounded-t hover:bg-primary transition-colors cursor-pointer",style:{height:`${r.pageviews/t*100}%`,minHeight:r.pageviews>0?"4px":"0"}})},i))}),e.jsxs("div",{className:"flex justify-between mt-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:s[0]?.date}),e.jsx("span",{children:s[s.length-1]?.date})]})]})}function Y({realtime:s}){return s?e.jsxs("div",{className:"bg-gradient-to-r from-emerald-500/20 via-emerald-500/10 to-transparent roun
31ded-xl border border-emerald-500/30 p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-emerald-500/30 flex items-center justify-center",children:e.jsx(M,{size:24,className:"text-emerald-400"})}),e.jsx("div",{className:"absolute -top-1 -right-1 w-3 h-3 bg-emerald-400 rounded-full animate-pulse"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-3xl font-bold text-foreground",children:s.active_visitors}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Visiteurs actifs maintenant"})]})]}),s.pages.length>0&&e.jsxs("div",{className:"mt-4 space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wider",children:"Pages actives"}),s.pages.slice(0,3).map((t,r)=>e.jsxs("div",{className:"text-sm text-foreground truncate",children:["⢠",t.x," (",t.count,")"]},r))]})]}):null}function ee({events:s}){if(!s)return null;const t={"donation-modal-open":Z,"donation-continue-to-ticketing":I,"concert-view":C,"concert-ticket-click":I,"concert-calendar-download":T,"newsletter-subscribe":p,"newsletter-modal-open":p,"waiting-list-join":w,"bio-view":w,"faq-view":M,"faq-question-open":M,"press-view":k,"press-kit-download":k,"press-article-click":y,"gallery-view":h,"gallery-image-view":h,"video-play":h,"audio-play":C,"scroll-depth":A,"social-click":L,"external-link-click":y,"contact-form-open":p,"contact-form-submit":p,"contact-form-success":p,"cta-click":U};return e.jsxs("div",{className:"bg-card rounded-xl border border-border overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b border-border bg-muted/30 flex items-center gap-2",children:[e.jsx(U,{size:18,className:"text-primary"}),e.jsx("h3",{className:"font-semibold text-foreground",children:"Ãvénements custom"}),e.jsxs("span",{className:"ml-auto text-xs text-muted-foreground",children:[s.total," total"]})]}),e.jsx("div",{className:"divide-y divide-border",children:s.events.length===0?e.jsx("div",{className:"p-4 text-center text-muted-foreground text-sm",children:"Aucun événement"}):s.events.map((r,i)=>{const n=t[r.x]||D;return e.jsxs("div",{className:"p-3 flex items-center gap-3 hover:bg-muted/50 transition-colors",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/20 flex items-center justify-center",children:e.jsx(n,{size:16,className:"text-primary"})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"text-sm text-foreground truncate",children:r.x})}),e.jsx("span",{className:"text-sm font-bold text-foreground",children:b(r.y)})]},i)})})]})}function pe(){const[s,t]=o.useState(null),[r,i]=o.useState(!0),[n,d]=o.useState(null),[x,q]=o.useState(7),u=o.useCallback(async()=>{i(!0),d(null);try{const l=V(),j=await fetch(`/api/v1/admin/analytics/dashboard?days=${x}`,{headers:l});if(!j.ok)throw new Error("Impossible de charger les analytics");const H=await j.json();t(H)}catch(l){d(l instanceof Error?l.message:"Erreur inconnue")}finally{i(!1)}},[x]);o.useEffect(()=>{u()},[u]),o.useEffect(()=>{const l=setInterval(u,3e4);return()=>clearInterval(l)},[u]);const z=()=>!s?.base_url||!s?.website_id?null:`${s.base_url}/share/${s.website_id}`;if(r&&!s)return e.jsx("div",{className:"p-6 flex items-center justify-center min-h-[400px]",children:e.jsx(_,{className:"animate-spin text-primary",size:32})});if(n&&!s)return e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"bg-destructive/10 border border-destructive/30 rounded-xl p-6 text-center",children:[e.jsx(G,{className:"mx-auto mb-4 text-destructive",size:48}),e.jsx("h2",{className:"text-xl font-semibold text-foreground mb-2",children:"Erreur"}),e.jsx("p",{className:"text-muted-foreground",children:n})]})});if(!s?.configured)return e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-xl bg-gradient-to-br from-primary/20 to-primary/5",children:e.jsx(N,{className:"text-primary",size:28})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground",children:"Analytics"}),e.jsx("p",{className:"text-muted-foreground",children:"Configuration requise"})]})]}),e.jsx("div",{className:"bg-amber-500/10 border border-amber-500/30 rounded-xl p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(W,{className:"text-amber-500 mt-1",size:24}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground mb-2",children:"Umami API
31non configurée"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Pour afficher les analytics détaillées, configurez ces variables :"}),e.jsxs("div",{className:"bg-card rounded-lg p-4 font-mono text-sm space-y-2",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-primary",children:"APP_UMAMI_WEBSITE_ID"}),"=votre-website-id"]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-primary",children:"APP_UMAMI_SCRIPT_URL"}),"=https://umami.example.com/script.js"]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-amber-400",children:"APP_UMAMI_USERNAME"}),"=admin"]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-amber-400",children:"APP_UMAMI_PASSWORD"}),"=votre-mot-de-passe"]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-4",children:"ð¡ Utilisez vos identifiants Umami (self-hosted)"})]})]})})]});const a=s.stats?.current,g=s.stats?.previous,f=a&&a.visits>0?Math.round(a.bounces/a.visits*100):0,P=a&&a.visits>0?a.totaltime/a.visits:0,S=a&&a.visits>0?a.pageviews/a.visits:0;return e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-xl bg-gradient-to-br from-primary/20 to-primary/5",children:e.jsx(N,{className:"text-primary",size:28})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground",children:"Analytics"}),e.jsxs("p",{className:"text-muted-foreground flex items-center gap-2",children:[e.jsx(D,{size:14,className:"text-primary"}),"Umami ⢠RGPD-friendly ⢠Cookieless"]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("select",{value:x,onChange:l=>q(Number(l.target.value)),className:"px-4 py-2 rounded-lg bg-card border border-border text-sm",children:[e.jsx("option",{value:1,children:"Dernières 24h"}),e.jsx("option",{value:7,children:"7 derniers jours"}),e.jsx("option",{value:30,children:"30 derniers jours"}),e.jsx("option",{value:90,children:"3 mois"})]}),e.jsxs("button",{onClick:u,disabled:r,className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-card border border-border hover:bg-accent transition-all",children:[e.jsx(_,{size:16,className:r?"animate-spin":""}),"Actualiser"]}),z()&&e.jsxs("a",{href:z(),target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-primary text-primary-foreground hover:opacity-90 transition-all",children:[e.jsx(y,{size:16}),"Umami"]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-5 gap-4",children:[e.jsx("div",{className:"lg:col-span-1",children:e.jsx(Y,{realtime:s.realtime})}),e.jsxs("div",{className:"lg:col-span-4 grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(v,{icon:E,label:"Pages vues",value:a?b(a.pageviews):"â",change:g?$(a?.pageviews||0,g.pageviews):void 0,color:"bg-blue-500"}),e.jsx(v,{icon:w,label:"Visiteurs uniques",value:a?b(a.visitors):"â",change:g?$(a?.visitors||0,g.visitors):void 0,color:"bg-emerald-500"}),e.jsx(v,{icon:T,label:"Temps moyen",value:P>0?Q(P):"â",color:"bg-amber-500"}),e.jsx(v,{icon:A,label:"Pages/visite",value:S>0?S.toFixed(1):"â",color:"bg-purple-500"})]})]}),a&&e.jsx("div",{className:"bg-card rounded-xl p-4 border border-border flex items-center gap-4",children:e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Taux de rebond"}),e.jsxs("span",{className:"text-sm font-bold text-foreground",children:[f,"%"]})]}),e.jsx("div",{className:"h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all ${f<40?"bg-emerald-500":f<60?"bg-amber-500":"bg-red-500"}`,style:{width:`${f}%`}})})]})}),s.pageviews_chart&&s.pageviews_chart.data.length>0&&e.jsx(X,{data:s.pageviews_chart.data}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[e.jsx(c,{title:"Pages populaires",icon:E,items:s.pages?.items||[],total:s.pages?.total||0,renderItem:l=>e.jsx("span",{className:"text-sm text-foreground truncate",title:l.x,children:l.x||"/"})}),e.jsx(ee,{events:s.events}),e.jsx(c,{title:"Pays",icon:L,items:s.countries?.items||[],total:s.countries?.total||0})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsx(c,{title:"Sources de trafic",icon:k,items:s.referrers?.items||[],total:s.referrers?.total||0,renderItem:l=>e.jsx("span",{className:"text-sm text-foreground truncate",children:l.x||"(direct)"})}),e.jsx(c,{title:"Villes",icon:F,items:s.cities?.items||[],total:s.cities?.total||0})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(c,{title:"Navigateurs",icon:B,items:s.browsers?.items||[],total:s.browsers?.total||0}),e.jsx(c,{title:"Systèmes",icon:h,items:s.os?.items||[],total:s.os?.total||0}
31),e.jsx(c,{title:"Appareils",icon:R,items:s.devices?.items||[],total:s.devices?.total||0,renderItem:l=>{const j=J(l.x);return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(j,{size:14,className:"text-muted-foreground"}),e.jsx("span",{className:"text-sm text-foreground",children:l.x})]})}})]})]})}export{pe as AdminAnalytics,pe 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.