PageSourceSearch

https://kanalpha-interne-8357.taskade.app/chunks/QuickDash-FTJ7WDNI.js

js kanalpha-interne-8357.taskade.app collected 2026-10-03 15:02:04 UTC 44,406 bytes, 5 lines download raw bytes

1var __IMPORT_META_ENV={};var __PROCESS_ENV={NODE_ENV:"production"};
2import{a as qe}from"/chunks/chunk-2L6GQL5M.js";import{c as ie}from"/chunks/chunk-IGCT6PAT.js";import{b as le,c as de,d as Fe,e as bt,f as ye,g as xt,h as Ne,i as we,j as ke,k as ht}from"/chunks/chunk-MHRBD33R.js";import{a as mt,b as pt,c as gt}from"/chunks/chunk-OIOX2OT5.js";import"/chunks/chunk-QKICUY2S.js";import{a as ft}from"/chunks/chunk-U62VSPRW.js";import"/chunks/chunk-AD6DUYMF.js";import{b as E}from"/chunks/chunk-DP67E3KD.js";import{b as ue}from"/chunks/chunk-ZSQ2II6E.js";import{a as _}from"/chunks/chunk-A6NSEO7N.js";import{a as me}from"/chunks/chunk-5LKAQM72.js";import"/chunks/chunk-YQIDYBH5.js";import{Df as Ie,Ha as fe,Is as it,Ph as ot,Re as Ze,Sm as at,Ui as rt,Vw as ne,Ye as je,af as Y,df as be,eB as he,eC as ct,ef as xe,ff as Je,gB as ve,jg as tt,nD as ut,nw as dt,or as st,qg as nt,tf as et,tj as W,wv as lt}from"/chunks/chunk-62QHDT2Z.js";import{a as te}from"/chunks/chunk-K5NUDHSY.js";import"/chunks/chunk-X3JFCYHJ.js";import{c as q}from"/chunks/chunk-VHATOFCX.js";import{c as pe,e as Oe}from"/chunks/chunk-EWMNDR7R.js";import"/chunks/chunk-ZP4OMTXP.js";import{a as ge}from"/chunks/chunk-DKSMBCPM.js";import{B as Le,g as Ee}from"/chunks/chunk-Z2TP6DSD.js";import"/chunks/chunk-GQOIBJBD.js";import"/chunks/chunk-PE5MZRD7.js";import{a as ee}from"/chunks/chunk-2F2XG2RD.js";import{d as j}from"/chunks/chunk-43M3N6VY.js";var Te=j(ee());var Nt=j(ee());var M=j(_());function wt(o){let n=new Date;if(o==="today")return new Date(n.getFullYear(),n.getMonth(),n.getDate());if(o==="week"){let a=new Date(n);return a.setDate(a.getDate()-(a.getDay()+6)%7),a.setHours(0,0,0,0),a}return new Date(n.getFullYear(),n.getMonth(),1)}function Kt(o){let n=new Date;if(o==="today"){let l=new Date(n.getFullYear(),n.getMonth(),n.getDate()-1),d=new Date(l);return d.setDate(d.getDate()+1),[l,d]}if(o==="week"){let l=wt("week"),d=new Date(l);return d.setDate(d.getDate()-7),[d,new Date(l)]}let a=new Date(n.getFullYear(),n.getMonth()-1,1),i=new Date(n.getFullYear(),n.getMonth(),1);return[a,i]}function vt(o,n){return n===0?o>0?100:null:Math.round((o-n)/n*100)}var Gt={today:"Aujourd'hui",week:"Cette semaine",month:"Ce mois"};function Be({period:o,onPeriodChange:n}){let a=q(d=>d.orders),i=q(d=>d.loaded),l=(0,Nt.useMemo)(()=>{let d=wt(o),[b,f]=Kt(o),y=a.filter(u=>new Date(u.createdAt)>=d),k=a.filter(u=>{let h=new Date(u.createdAt);return h>=b&&h<f}),I=y.reduce((u,h)=>u+h.total,0),c=k.reduce((u,h)=>u+h.total,0),P=y.length,D=k.length,g=a[0]?.currency??"EUR";return{curTotal:I,prevTotal:c,curCount:P,prevCount:D,pctTotal:vt(I,c),pctCount:vt(P,D),currency:g}},[a,o]);return(0,M.jsxs)("div",{className:"space-y-3",children:[(0,M.jsx)("div",{className:"flex items-center gap-1.5 bg-muted/50 rounded-xl p-1 w-fit",children:["today","week","month"].map(d=>(0,M.jsx)("button",{onClick:()=>n(d),className:`px-3 py-1.5 rounded-lg text-xs font-medium transition-all duration-150 ${o===d?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:Gt[d]},d))}),(0,M.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,M.jsx)(yt,{icon:W,label:"Montant total",value:i?pe(l.curTotal,l.currency):null,pct:l.pctTotal,loading:!i,accent:!0}),(0,M.jsx)(yt,{icon:ne,label:"Commandes",value:i?String(l.curCount):null,pct:l.pctCount,loading:!i})]})]})}function yt({icon:o,label:n,value:a,pct:i,loading:l,accent:d}){let b=i!==null&&i>=0;return(0,M.jsxs)("div",{className:"bg-card border border-border/50 rounded-2xl p-4 flex flex-col gap-2",children:[(0,M.jsxs)("div",{className:"flex items-center justify-between",children:[(0,M.jsx)("div",{className:`w-8 h-8 rounded-xl flex items-center justify-center ${d?"bg-brand/10 text-brand":"bg-muted text-muted-foreground"}`,children:(0,M.jsx)(o,{className:"w-4 h-4"})}),i!==null&&!l&&(0,M.jsxs)("span",{className:`flex items-center gap-0.5 text-[10px] font-semibold ${b?"text-emerald-500":"text-red-400"}`,children:[(0,M.jsx)(b?ve:he,{className:"w-3 h-3"}),Math.abs(i),"%"]})]}),l?(0,M.jsxs)("div",{className:"space-y-1.5",children:[(0,M.jsx)("div",{className:"h-6 w-20 bg-muted/60 rounded-md animate-pulse"}),(0,M.jsx)("div",{className:"h-3 w-16 bg-muted/40 rounded animate-pulse"})]}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)("p",{className:"text-xl font-bold tracking-tight leading-none",children:a}),(0,M.jsx)("p",{className:"text-[11px] text-muted-foreground",children:n})]})]})}var F=j(ee());var C=j(_());function Ht(){let o=new Date;return new Date(o.getFullYear(),o.getMonth(),o.getDate())}var zt={web:"Boutique Web",store:"Boutique Physique",phone:"T\xE9l\xE9phone",wholesale:"Grossiste",pos:"Point de Vente",app:"Application Mobile",woocommerce:"WooCommerce",shopify:"Shopify",manual:"Manuel"};function Yt(o){return zt[o]||o.charAt(0).toUpperCase()+o.slice(1)}var kt=["#6366f1","#06b6d4","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899","#84cc16"];function Vt(o){let n=0;for(let a=0;a<o.length;
2a++)n=o.charCodeAt(a)+((n<<5)-n);return kt[Math.abs(n)%kt.length]}function Ue({channelOrder:o,onOrderChange:n}){let a=q(g=>g.orders),i=q(g=>g.loaded),l=te(g=>g.channels);function d(g){return l.find(h=>h.key===g)?.color||Vt(g)}let b=(0,F.useMemo)(()=>{let g=new Set;for(let u of a)u.channel&&g.add(u.channel);return[...g]},[a]),f=(0,F.useMemo)(()=>{let g=o.filter(h=>b.includes(h)),u=b.filter(h=>!o.includes(h));return[...g,...u]},[o,b]),y=(0,F.useMemo)(()=>Ht(),[]),k=(0,F.useMemo)(()=>{let g={};for(let u of a)!u.channel||new Date(u.createdAt)<y||(g[u.channel]||(g[u.channel]={total:0,count:0,currency:u.currency||"EUR"}),g[u.channel].total+=u.total,g[u.channel].count+=1);return g},[a,y]),[I,c]=(0,F.useState)(!1),P=(0,F.useRef)(n);P.current=n,(0,F.useEffect)(()=>{if(!i)return;let g=f.join(","),u=o.join(",");g!==u&&P.current(f)},[i,f.join(",")]);let D=(0,F.useCallback)(g=>{if(c(!1),!g.destination)return;let u=[...f],[h]=u.splice(g.source.index,1);u.splice(g.destination.index,0,h),n(u)},[f,n]);return i?f.length===0?(0,C.jsx)("div",{className:"text-center py-6 text-sm text-muted-foreground",children:"Aucune commande enregistr\xE9e"}):(0,C.jsx)(mt,{onDragStart:()=>c(!0),onDragEnd:D,children:(0,C.jsx)(gt,{droppableId:"channels",direction:"horizontal",children:g=>(0,C.jsxs)("div",{ref:g.innerRef,...g.droppableProps,className:"grid grid-cols-2 gap-3",children:[f.map((u,h)=>{let $=k[u],z=d(u);return(0,C.jsx)(pt,{draggableId:u,index:h,children:(N,O)=>(0,C.jsx)(Qt,{dragRef:N.innerRef,dragProps:N.draggableProps,handleProps:N.dragHandleProps,channel:u,color:z,stat:$,isDragging:O.isDragging,isGlobalDragging:I})},u)}),g.placeholder]})})}):(0,C.jsx)("div",{className:"grid grid-cols-2 gap-3",children:[1,2,3,4].map(g=>(0,C.jsx)("div",{className:"h-28 rounded-2xl bg-muted/40 animate-pulse"},g))})}function Qt({dragRef:o,dragProps:n,handleProps:a,channel:i,color:l,stat:d,isDragging:b}){let f=(0,F.useRef)(null),[y,k]=(0,F.useState)(!1),I=()=>{f.current=setTimeout(()=>{k(!0),navigator.vibrate&&navigator.vibrate(30)},400)},c=()=>{f.current&&clearTimeout(f.current),f.current=null,setTimeout(()=>k(!1),800)};return(0,C.jsxs)("div",{ref:o,...n,onPointerDown:I,onPointerUp:c,onPointerCancel:c,className:`relative bg-card border rounded-2xl p-3.5 flex flex-col gap-2 select-none transition-all duration-150 ${b?"shadow-2xl scale-[1.03] border-brand/40 z-50 rotate-1":"border-border/50 hover:border-border active:scale-[0.98]"} ${y?"ring-2 ring-brand/40":""}`,style:n.style,children:[(0,C.jsx)("div",{className:"absolute top-0 left-0 right-0 h-1 rounded-t-2xl",style:{background:`linear-gradient(90deg, ${l}, ${l}99)`}}),(0,C.jsx)("div",{...a??{},className:`absolute top-2 right-2 transition-opacity duration-150 cursor-grab active:cursor-grabbing ${y||b?"opacity-60":"opacity-0 md:opacity-30 md:hover:opacity-70"}`,title:"R\xE9organiser",children:(0,C.jsx)(at,{className:"w-3.5 h-3.5 text-muted-foreground"})}),(0,C.jsxs)("div",{className:"flex items-center gap-1.5 pr-5",children:[(0,C.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:l}}),(0,C.jsx)("p",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider truncate",children:Yt(i)})]}),d?(0,C.jsxs)("div",{className:"space-y-1",children:[(0,C.jsxs)("div",{className:"flex items-center gap-1",children:[(0,C.jsx)(W,{className:"w-3.5 h-3.5 shrink-0",style:{color:l}}),(0,C.jsx)("span",{className:"text-base font-bold leading-none truncate",children:pe(d.total,d.currency)})]}),(0,C.jsxs)("div",{className:"flex items-center gap-1",children:[(0,C.jsx)(ne,{className:"w-3 h-3 text-muted-foreground shrink-0"}),(0,C.jsxs)("span",{className:"text-xs text-muted-foreground",children:[d.count," commande",d.count!==1?"s":""," aujourd'hui"]})]})]}):(0,C.jsxs)("div",{className:"space-y-1",children:[(0,C.jsx)("p",{className:"text-base font-bold text-muted-foreground/40",children:"\u2014"}),(0,C.jsx)("p",{className:"text-xs text-muted-foreground/40",children:"Aucune commande aujourd'hui"})]})]})}var G=j(ee());var x=j(_()),_e=5,Ct={"tp-high":0,"tp-med":1,"tp-low":2},St={"tp-high":{label:"Haute",color:"text-red-400",Icon:et},"tp-med":{label:"Moyenne",color:"text-amber-400",Icon:st},"tp-low":{label:"Basse",color:"text-muted-foreground",Icon:Y}};
2function Dt(o){return[...o].sort((n,a)=>{let i=Ct[n.priority]??1,l=Ct[a.priority]??1;return i!==l?i-l:n.due&&a.due?n.due.localeCompare(a.due):n.due?-1:a.due?1:0})}function Xt(o){if(!o)return{label:"",urgent:!1};let n=new Date(o),a=new Date;a.setHours(0,0,0,0);let i=Math.floor((n.getTime()-a.getTime())/864e5);return i<0?{label:"En retard",urgent:!0}:i===0?{label:"Aujourd'hui",urgent:!0}:i===1?{label:"Demain",urgent:!1}:i<=7?{label:`Dans ${i}j`,urgent:!1}:{label:n.toLocaleDateString("fr-FR",{day:"numeric",month:"short"}),urgent:!1}}function $e({open:o,onToggle:n,page:a,onPageChange:i}){let l=ue(),b=ge(N=>N.user)?.nodeId??"",[f,y]=(0,G.useState)([]),[k,I]=(0,G.useState)(!0),[c,P]=(0,G.useState)(new Set);(0,G.useEffect)(()=>{if(!b)return;let N=!1;return I(!0),qe.list().then(O=>{if(N)return;let R=O.filter(T=>T.assigneeId===b||T.ownerId===b&&!T.assigneeId&&T.status!=="ts-cancelled");y(R)}).catch(()=>{}).finally(()=>{N||I(!1)}),()=>{N=!0}},[b]);let D=(0,G.useMemo)(()=>{let N=Dt(f.filter(R=>R.status!=="ts-done"&&R.status!=="ts-cancelled")),O=Dt(f.filter(R=>R.status==="ts-done"));return[...N,...O]},[f]),g=(0,G.useMemo)(()=>f.filter(N=>N.status!=="ts-done"&&N.status!=="ts-cancelled").length,[f]),u=Math.max(1,Math.ceil(D.length/_e)),h=Math.min(a,u-1),$=D.slice(h*_e,(h+1)*_e),z=(0,G.useCallback)(async N=>{P(O=>new Set(O).add(N.id)),y(O=>O.map(R=>R.id===N.id?{...R,status:R.status==="ts-done"?"ts-todo":"ts-done"}:R));try{await qe.toggleDone(N)}catch{y(O=>O.map(R=>R.id===N.id?{...R,status:N.status}:R))}P(O=>{let R=new Set(O);return R.delete(N.id),R})},[]);return(0,x.jsxs)("div",{className:"bg-card border border-border/50 rounded-2xl overflow-hidden",children:[(0,x.jsxs)("button",{onClick:()=>n(!o),className:"w-full flex items-center gap-2.5 px-4 py-3.5 hover:bg-accent/50 transition-colors duration-150 text-left","aria-expanded":o,children:[(0,x.jsx)("div",{className:"w-7 h-7 rounded-lg bg-brand/10 flex items-center justify-center shrink-0",children:(0,x.jsx)(nt,{className:"w-3.5 h-3.5 text-brand"})}),(0,x.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,x.jsx)("span",{className:"text-sm font-semibold",children:"Mes t\xE2ches"}),g>0&&(0,x.jsx)("span",{className:"ml-2 inline-flex items-center justify-center w-5 h-5 rounded-full bg-brand text-brand-foreground text-[9px] font-bold",children:g>99?"99+":g})]}),(0,x.jsx)(Y,{className:E("w-4 h-4 text-muted-foreground transition-transform duration-200",o?"rotate-0":"-rotate-90")})]}),(0,x.jsx)("div",{className:E("overflow-hidden transition-all duration-200",o?"max-h-[600px] opacity-100":"max-h-0 opacity-0"),children:(0,x.jsxs)("div",{className:"border-t border-border/30",children:[k?(0,x.jsx)("div",{className:"p-3 space-y-2",children:[1,2,3].map(N=>(0,x.jsx)("div",{className:"h-11 rounded-xl bg-muted/40 animate-pulse"},N))}):D.length===0?(0,x.jsxs)("div",{className:"py-8 text-center",children:[(0,x.jsx)(Ie,{className:"w-6 h-6 text-muted-foreground/30 mx-auto mb-2"}),(0,x.jsx)("p",{className:"text-xs text-muted-foreground",children:"Aucune t\xE2che assign\xE9e"})]}):(0,x.jsx)("div",{className:"divide-y divide-border/20",children:$.map(N=>(0,x.jsx)(Wt,{task:N,onToggle:z,toggling:c.has(N.id)},N.id))}),u>1&&(0,x.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 border-t border-border/20",children:[(0,x.jsx)("button",{disabled:h===0,onClick:()=>i(h-1),className:"p-1.5 rounded-lg hover:bg-accent disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:(0,x.jsx)(be,{className:"w-3.5 h-3.5"})}),(0,x.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:[h+1," / ",u,(0,x.jsxs)("span",{className:"ml-1 text-muted-foreground/50",children:["(",D.length," t\xE2ches)"]})]}),(0,x.jsx)("button",{disabled:h>=u-1,onClick:()=>i(h+1),className:"p-1.5 rounded-lg hover:bg-accent disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:(0,x.jsx)(xe,{className:"w-3.5 h-3.5"})})]}),(0,x.jsx)("div",{className:"px-4 pb-3 pt-1",children:(0,x.jsxs)("button",{onClick:()=>l("/dashboard/tasks"),className:"w-full flex items-center justify-center gap-1.5 py-2 rounded-xl text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-accent transition-all duration-150",children:["Voir toutes mes t\xE2ches",(0,x.jsx)(fe,{className:"w-3.5 h-3.5"})]})})]})})]})}function Wt({task:o,onToggle:n,toggling:a}){let i=o.status==="ts-done",l=St[o.priority]??St["tp-med"],d=l.Icon,b=o.due?Xt(o.due):null;return(0,x.jsxs)("div",{className:E("flex items-center gap-3 px-4 py-3 group transition-colors duration-100","hover:bg-accent/40",i&&"opacity-50"),children:[(0,x.jsxs)("button",{onClick:()=>n(o),disabled:a,className:E("shrink-0 w-5 h-5 rounded-full border-2 flex items-center justify-center transition-all duration-150",i?"border-emerald-500 bg-emerald-500 text-white":"border-border hover:border-brand",a&&"opacity-50"),"aria-label":i?"Marquer comme \xE0 faire":"Marquer comme fait",children:[i&&(0,x.jsx)(Ie,{className:"w-3 h-3"}),!i&&(0,x.jsx)(tt,{className:"w-2.5 h-2.5 opacity-0 group-hover:opacity-30 transition-opacity"})]}),(0,x.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,x.jsx)("p",{className:E("text-xs font-medium truncate",i&&"line-through text-muted-foreground"),children:o.title}),b&&(0,x.jsx)("p",{className:E("text-[10px] mt-0.5",b.urgent?"text-red-400 font-medium":"text-muted-foreground"),children:b.label})]}),(0,x.jsx)(d,{className:E("w-3.5 h-3.5 shrink-0",l.color),title:l.label})]})}var Tt=j(ee());var S=j(_());function Ke({open:o,onToggle:n}){let a=ue(),i=ie(y=>y.fetchAll),l=ie(y=>y.loaded),d=ie(y=>y.teams),b=ie(y=>y.allUsers);(0,Tt.useEffect)(()=>{l||i()},[l,i]);let f=d.reduce((y,k)=>y+k.memberIds.length,0);return(0,S.jsxs)("div",{className:"bg-card border border-border/50 rounded-2xl overflow-hidden",children:[(0,S.jsxs)("button",{onClick:()=>n(!o),className:"w-full flex items-center gap-2.5 px-4 py-3.5 hover:bg-accent/50 transition-colors duration-150 text-left","aria-expanded":o,children:[(0,S.jsx)("div",{className:"w-7 h-7 rounded-lg bg-accent flex items-center justify-center shrink-0",children:(0,S.jsx)(ct,{className:"w-3.5 h-3.5 text-muted-foreground"})}),(0,S.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,S.jsx)("span",{className:"text-sm font-semibold",children:"\xC9quipes"}),l&&d.length>0&&(0,S.jsxs)("span",{className:"ml-2 text-[10px] text-muted-foreground",children:[d.length," \xE9quipe",d.length>
21?"s":""," \xB7 ",f," membre",f>1?"s":""]})]}),(0,S.jsx)(Y,{className:E("w-4 h-4 text-muted-foreground transition-transform duration-200",o?"rotate-0":"-rotate-90")})]}),(0,S.jsx)("div",{className:E("overflow-hidden transition-all duration-200",o?"max-h-[500px] opacity-100":"max-h-0 opacity-0"),children:(0,S.jsxs)("div",{className:"border-t border-border/30 p-3 space-y-2",children:[l?d.length===0?(0,S.jsx)("p",{className:"text-xs text-muted-foreground text-center py-4",children:"Aucune \xE9quipe"}):d.map(y=>(0,S.jsx)(Jt,{team:y,allUsers:b},y.id)):(0,S.jsx)("div",{className:"space-y-2",children:[1,2].map(y=>(0,S.jsx)("div",{className:"h-14 rounded-xl bg-muted/40 animate-pulse"},y))}),(0,S.jsxs)("button",{onClick:()=>a("/dashboard/team"),className:"w-full flex items-center justify-center gap-1.5 py-2 rounded-xl text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-accent transition-all duration-150",children:["G\xE9rer les \xE9quipes",(0,S.jsx)(fe,{className:"w-3.5 h-3.5"})]})]})})]})}var Zt=4;function Jt({team:o,allUsers:n}){let a=o.memberIds.map(d=>n.find(b=>b.id===d)).filter(Boolean),i=a.slice(0,Zt),l=a.length-i.length;return(0,S.jsxs)("div",{className:"flex items-center gap-3 px-1 py-1 rounded-xl hover:bg-accent/40 transition-colors duration-100",children:[(0,S.jsx)("div",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{backgroundColor:o.color}}),(0,S.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,S.jsx)("p",{className:"text-xs font-semibold truncate",children:o.name}),(0,S.jsxs)("p",{className:"text-[10px] text-muted-foreground",children:[a.length," membre",a.length!==1?"s":""]})]}),(0,S.jsxs)("div",{className:"flex items-center -space-x-1.5 shrink-0",children:[i.map(d=>{let b=Le(d,Ee.FIRST_NAME)||Le(d,Ee.PSEUDO)||"?",f=b.charAt(0).toUpperCase();return(0,S.jsx)("div",{title:b,className:"w-6 h-6 rounded-full bg-muted border-2 border-card flex items-center justify-center text-[9px] font-bold text-muted-foreground",children:f},d.id)}),l>0&&(0,S.jsxs)("div",{className:"w-6 h-6 rounded-full bg-accent border-2 border-card flex items-center justify-center text-[9px] font-bold text-muted-foreground",children:["+",l]})]})]})}var v=j(ee());var e=j(_()),Pt={"7d":"7 jours","1m":"1 mois","3m":"3 mois","6m":"6 mois"};function en(o){let n=new Date;return o==="7d"?n.setDate(n.getDate()-7):o==="1m"?n.setMonth(n.getMonth()-1):o==="3m"?n.setMonth(n.getMonth()-3):n.setMonth(n.getMonth()-6),n.setHours(0,0,0,0),n}function tn(o){let n=new Date;return o==="7d"?n.setDate(n.getDate()-14):o==="1m"?n.setMonth(n.getMonth()-2):o==="3m"?n.setMonth(n.getMonth()-6):n.setMonth(n.getMonth()-12),n.setHours(0,0,0,0),n}function De(o){return o.toLocaleString("fr-FR",{style:"currency",currency:"EUR",minimumFractionDigits:2})}function oe(o){return o>=1e6?(o/1e6).toFixed(1)+"M\u20AC":o>=1e3?(o/1e3).toFixed(1)+"k\u20AC":o.toFixed(0)+"\u20AC"}function Rt(o,n){return n===0?o>0?100:null:Math.round((o-n)/n*100)}var At=["#6366f1","#06b6d4","#10b981","#f59e0b","#ef4444","#8b5cf6","#ec4899","#84cc16"];function Mt(o,n){let a=[...o].reduce((i,l)=>i+l.charCodeAt(0),0);return At[(a+n)%At.length]}var re=[{id:"overview",label:"Vue d'ensemble"},{id:"evolution",label:"\xC9volution CA"},{id:"channels",label:"Par canal"},{id:"products",label:"Top produits"},{id:"statuses",label:"Statuts"}];function Ce({active:o,payload:n,label:a}){return!o||!n?.length?null:(0,e.jsxs)("div",{className:"bg-card border border-border/60 rounded-xl px-3 py-2 shadow-xl text-[11px]",children:[a&&(0,e.jsx)("p",{className:"font-semibold text-foreground mb-1",children:a}),n.map((i,l)=>(0,e.jsxs)("p",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{className:"inline-block w-2 h-2 rounded-full",style:{background:i.color||i.fill}}),(0,e.jsxs)("span",{className:"text-muted-foreground",children:[i.name,":"]}),(0,e.jsx)("span",{className:"font-semibold",children:typeof i.value=="number"&&i.value>100?De(i.value):i.value})]},l))]})}function nn({chips:o,selected:n,onChange:a}){let i=n.length===0;return(0,e.jsxs)("div",{className:"flex items-center gap-1.5 overflow-x-auto pb-0.5 no-scrollbar",children:[(0,e.jsx)("button",{onClick:()=>a([]),className:E("shrink-0 px-2.5 py-1 rounded-full text-[10px] font-semibold transition-all",i?"bg-foreground text-background":"bg-muted/50 text-muted-foreground hover:text-foreground"),children:"Tous"}),o.map(l=>{let d=n.includes(l.key);return(0,e.jsxs)("button",{onClick:()=>a(d?n.filter(b=>b!==l.key):[...n,l.key]),className:E("shrink-0 flex items-center gap-1 px-2.5 py-1 rounded-full text-[10px] font-semibold transition-all border",d?"text-white":"bg-muted/30 text-muted-foreground hover:text-foreground border-transparent"),style:d?{backgroundColor:l.color,borderColor:l.color}:{borderColor:l.color+"44"},children:[(0,e.jsx)("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:d?"
2white":l.color}}),l.label]},l.key)})]})}function on({options:o,selected:n,onChange:a}){let[i,l]=(0,v.useState)(!1),[d,b]=(0,v.useState)(""),f=(0,v.useRef)(null);(0,v.useEffect)(()=>{if(!i)return;let c=P=>{f.current&&!f.current.contains(P.target)&&l(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[i]);let y=(0,v.useMemo)(()=>{let c=d.trim().toLowerCase();return c?o.filter(P=>P.name.toLowerCase().includes(c)||P.sku.toLowerCase().includes(c)):o},[o,d]),k=c=>a(n.includes(c)?n.filter(P=>P!==c):[...n,c]),I=n.length===0?"Tous les produits":n.length===1?o.find(c=>c.sku===n[0])?.name||n[0]:`${n.length} produits`;return(0,e.jsxs)("div",{ref:f,className:"relative",children:[(0,e.jsxs)("button",{onClick:()=>l(c=>!c),className:"w-full flex items-center justify-between gap-1.5 px-2.5 py-1.5 rounded-lg border border-border bg-muted/30 text-xs text-left hover:bg-muted/60 transition-colors",children:[(0,e.jsx)("span",{className:E("truncate",n.length===0&&"text-muted-foreground"),children:I}),(0,e.jsx)(Y,{className:"w-3 h-3 text-muted-foreground shrink-0"})]}),i&&(0,e.jsxs)("div",{className:"absolute z-50 top-full mt-1 left-0 right-0 bg-card border border-border rounded-xl shadow-xl overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 px-2.5 py-2 border-b border-border",children:[(0,e.jsx)(dt,{className:"w-3 h-3 text-muted-foreground shrink-0"}),(0,e.jsx)("input",{autoFocus:!0,value:d,onChange:c=>b(c.target.value),placeholder:"Nom ou SKU\u2026",className:"flex-1 text-[11px] bg-transparent outline-none placeholder:text-muted-foreground/50"})]}),(0,e.jsxs)("div",{className:"max-h-44 overflow-y-auto",children:[(0,e.jsxs)("button",{onClick:()=>{a([]),l(!1)},className:"w-full text-left px-3 py-1.5 text-[11px] text-muted-foreground hover:bg-muted/50 flex items-center gap-1.5",children:[(0,e.jsx)("span",{className:E("w-3.5 h-3.5 rounded border flex items-center justify-center shrink-0",n.length===0?"bg-foreground border-foreground":"border-border"),children:n.length===0&&(0,e.jsx)(je,{className:"w-2 h-2 text-background"})}),"Tous les produits"]}),y.map(c=>{let P=n.includes(c.sku);return(0,e.jsxs)("button",{onClick:()=>k(c.sku),className:"w-full text-left px-3 py-1.5 text-[11px] hover:bg-muted/50 flex items-center gap-1.5",children:[(0,e.jsx)("span",{className:E("w-3.5 h-3.5 rounded border flex items-center justify-center shrink-0",P?"bg-foreground border-foreground":"border-border"),children:P&&(0,e.jsx)(je,{className:"w-2 h-2 text-background"})}),(0,e.jsx)("span",{className:"truncate flex-1",children:c.name}),(0,e.jsx)("span",{className:"text-muted-foreground/50 font-mono text-[9px] shrink-0",children:c.sku})]},c.sku)})]})]})]})}function Se({icon:o,label:n,value:a,pctVal:i,color:l,loading:d}){let b=i!=null&&i>=0,f=b?ve:he;return(0,e.jsxs)("div",{className:"bg-card border border-border/50 rounded-2xl p-3.5 flex flex-col gap-2",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:(l||"#6366f1")+"20",color:l||"#6366f1"},children:(0,e.jsx)(o,{className:"w-3.5 h-3.5"})}),i!=null&&!d&&(0,e.jsxs)("span",{className:E("flex items-center gap-0.5 text-[10px] font-semibold",b?"text-emerald-500":"text-red-400"),children:[(0,e.jsx)(f,{className:"w-3 h-3"}),Math.abs(i),"%"]})]}),d?(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)("div",{className:"h-5 w-20 bg-muted/60 rounded animate-pulse"}),(0,e.jsx)("div",{className:"h-3 w-14 bg-muted/40 rounded animate-pulse"})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("p",{className:"text-lg font-bold tracking-tight leading-none",children:a}),(0,e.jsx)("p",{className:"text-[10px] text-muted-foreground",children:n})]})]})}function Ge({open:o,onToggle:n,period:a,onPeriodChange:i}){let l=q(t=>t.orders),d=q(t=>t.loaded),b=te(t=>t.products),f=te(t=>t.channels),y=te(t=>t.categories),[k,I]=(0,v.useState)([]),[c,P]=(0,v.useState)([]),[D,g]=(0,v.useState)(""),[u,h]=(0,v.useState)(0),$=(0,v.useRef)(null),z=t=>{$.current=t.touches[0].clientX},N=t=>{if($.current===null)return;let r=t.changedTouches[0].clientX-$.current;r<-40&&h(s=>Math.min(s+1,re.length-1)),r>40&&h(s=>Math.max(s-1,0)),$.current=null},O=k.length>0||c.length>0||D!=="",R=()=>{I([]),P([]),g("")},T=(0,v.useMemo)(()=>en(a),[a]),He=(0,v.useMemo)(()=>tn(a),[a]),Pe=(0,v.useMemo)(()=>{let t={};return f.forEach((r,s)=>{t[r.key]=r.color||Mt(r.key,s)}),t},[f]),V=(0,v.useCallback)((t,r=0)=>Pe[t]||Mt(t,r),[Pe]),Q=(0,v.useCallback)(t=>f.find(r=>r.key===t)?.key||t,[f]),ae=(0,v.useMemo)(()=>l.filter(t=>new Date(t.createdAt)>=T),[l,T]),B=(0,v.useMemo)(()=>k.length===0?ae:ae.filter(t=>k.includes(t.channel)),[ae,k]),Re=(0,v.useMemo)(()=>l.filter(t=>{let r=new Date(t.createdAt);return r>=He&&r<T}),[l,He,T]),ze=(0,v.useMemo)(()=>k.length===0?Re:Re.filter(t=>k.includes(t.channel)),[Re,k]),Ye=(0,v.useMemo)(()=>{let t=new Set;return ae.forEach(r=>{r.channel&&t.add(r.channel)}),[...t].map((r,s)=>({key:r,label:Q(r),color:V(r,s)}))},[ae,Pe,V,Q]),Et=(0,v.useMemo)(()=>{let t=new Map;return B.forEach(r=>
2r.items.forEach(s=>{s.sku&&!t.has(s.sku)&&t.set(s.sku,s.name)})),[...t.entries()].map(([r,s])=>({sku:r,name:s})).sort((r,s)=>r.name.localeCompare(s.name,"fr"))},[B]),Ve=(0,v.useMemo)(()=>y.filter(t=>!t.parentId).map(t=>({value:t.name,label:t.name})),[y]),X=(0,v.useMemo)(()=>{let t=new Map;return b.forEach(r=>t.set(r.sku,r.category)),t},[b]),U=(0,v.useMemo)(()=>{let t=new Map;for(let r of B)for(let s of r.items){if(!s.sku||c.length>0&&!c.includes(s.sku)||D&&(X.get(s.sku)||"")!==D)continue;let p=t.get(s.sku);p?(p.qty+=s.qty,p.ca+=s.total):t.set(s.sku,{sku:s.sku,name:s.name,qty:s.qty,ca:s.total})}return[...t.values()].sort((r,s)=>s.ca-r.ca)},[B,c,D,X]),H=U.reduce((t,r)=>t+r.ca,0),ce=U.reduce((t,r)=>t+r.qty,0),K=B.length,Lt=K>0?H/K:0,Ot=ze.reduce((t,r)=>{let s=0;for(let p of r.items)c.length>0&&!c.includes(p.sku||"")||D&&(X.get(p.sku||"")||"")!==D||(s+=p.total);return t+s},0),jt=ze.length,It=Rt(H,Ot),Ft=Rt(K,jt),Z=(0,v.useMemo)(()=>{let t=new Map;for(let r of B){let s=r.channel||"autre",p=0,m=0;for(let A of r.items)c.length>0&&!c.includes(A.sku||"")||D&&(X.get(A.sku||"")||"")!==D||(p+=A.total,m+=A.qty);let w=t.get(s);w?(w.ca+=p,w.count++,w.qty+=m):t.set(s,{key:s,ca:p,count:1,qty:m})}return[...t.values()].sort((r,s)=>s.ca-r.ca)},[B,c,D,X]),J=(0,v.useMemo)(()=>{let t=new Map;return B.forEach(r=>t.set(r.status,(t.get(r.status)||0)+1)),[...t.entries()].map(([r,s])=>({status:r,label:Oe(r).label,color:Oe(r).color,count:s})).sort((r,s)=>s.count-r.count)},[B]),qt=(0,v.useMemo)(()=>{let t=a==="7d"?7:a==="1m"?30:a==="3m"?90:180,r=t<=30?1:t<=90?7:14,s=new Map;for(let m=0;m<t;m+=r){let w=new Date(T);w.setDate(w.getDate()+m);let A=w.toLocaleDateString("fr-FR",{day:"2-digit",month:"2-digit"});s.set(A,{date:A})}let p=k.length>0?k:[...new Set(B.map(m=>m.channel).filter(Boolean))];for(let m of B){let w=new Date(m.createdAt),A=Math.floor((w.getTime()-T.getTime())/(864e5*r))*r,se=new Date(T);se.setDate(se.getDate()+A);let $t=se.toLocaleDateString("fr-FR",{day:"2-digit",month:"2-digit"}),Ae=s.get($t);if(!Ae)continue;let Xe=m.channel||"autre",We=0;for(let Me of m.items)c.length>0&&!c.includes(Me.sku||"")||D&&(X.get(Me.sku||"")||"")!==D||(We+=Me.total);Ae[Xe]=(Ae[Xe]||0)+We}return{data:[...s.values()],chKeys:p}},[B,T,a,k,c,D,X]),Qe=(0,v.useCallback)(()=>{let t=w=>'"'+w.replace(/"/g,'""')+'"',r=`# P\xE9riode: ${Pt[a]}`,s=[t("Produit"),t("SKU"),t("Qt\xE9"),t("CA (\u20AC)")].join(","),p=U.map(w=>[t(w.name),t(w.sku),t(String(w.qty)),t(w.ca.toFixed(2))].join(",")).join(`\r
3`),m=[t("TOTAL"),t(""),t(String(ce)),t(H.toFixed(2))].join(",");return[r,s,p,m].join(`\r
4`)},[U,ce,H,a]),Bt=(0,v.useCallback)(()=>{let t=new Date().toISOString().split("T")[0],r=new Blob(["\uFEFF"+Qe()],{type:"text/csv;charset=utf-8;"}),s=URL.createObjectURL(r),p=document.createElement("a");p.href=s,p.download=`stats_${a}_${t}.csv`,document.body.appendChild(p),p.click(),document.body.removeChild(p),URL.revokeObjectURL(s),me.success(`CSV t\xE9l\xE9charg\xE9 \u2014 ${U.length} produit(s)`)},[Qe,a,U.length]),Ut=(0,v.useCallback)(async()=>{let t=U.map(r=>`${r.name}	${r.sku}	${r.qty}	${r.ca.toFixed(2)}`).join(`
5`);try{await navigator.clipboard.writeText(t),me.success("Copi\xE9")}catch{me.error("Impossible de copier")}},[U]);function _t(t){if(!d)return(0,e.jsx)("div",{className:"space-y-2 py-2",children:[0,1,2].map(r=>(0,e.jsx)("div",{className:"h-8 bg-muted/40 rounded-xl animate-pulse"},r))});if(t==="overview"){let r=K>0;return(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-2.5",children:[(0,e.jsx)(Se,{icon:W,label:"Chiffre d'affaires",value:De(H),pctVal:It,color:"#6366f1",loading:!d}),(0,e.jsx)(Se,{icon:ne,label:"Commandes",value:String(K),pctVal:Ft,color:"#06b6d4",loading:!d}),(0,e.jsx)(Se,{icon:it,label:"Articles vendus",value:String(ce),color:"#10b981",loading:!d}),(0,e.jsx)(Se,{icon:W,label:"Panier moyen",value:De(Lt),color:"#f59e0b",loading:!d})]}),r&&Z.length>0&&(0,e.jsxs)("div",{className:"bg-muted/30 rounded-2xl p-3 space-y-2",children:[(0,e.jsx)("p",{className:"text-[9px] font-semibold uppercase tracking-wider text-muted-foreground
5/60",children:"R\xE9partition canaux"}),Z.slice(0,5).map((s,p)=>{let m=H>0?s.ca/H*100:0,w=V(s.key,p);return(0,e.jsxs)("div",{className:"space-y-0.5",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between text-[10px]",children:[(0,e.jsxs)("span",{className:"flex items-center gap-1.5 font-medium",children:[(0,e.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:w}}),Q(s.key),(0,e.jsxs)("span",{className:"text-muted-foreground/50",children:[s.count," cmd"]})]}),(0,e.jsx)("span",{className:"text-muted-foreground tabular-nums",children:oe(s.ca)})]}),(0,e.jsx)("div",{className:"h-1.5 bg-muted rounded-full overflow-hidden",children:(0,e.jsx)("div",{className:"h-full rounded-full transition-all duration-700",style:{width:`${m}%`,background:w}})})]},s.key)})]}),!r&&(0,e.jsx)("div",{className:"text-center py-8 text-[11px] text-muted-foreground/50",children:"Aucune vente sur cette p\xE9riode"})]})}if(t==="evolution"){let{data:r,chKeys:s}=qt,p=s.length>0&&r.some(m=>s.some(w=>m[w]>0));return(0,e.jsx)("div",{className:"space-y-2",children:p?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("p",{className:"text-[9px] font-semibold uppercase tracking-wider text-muted-foreground/60",children:"CA empil\xE9 par canal \xB7 dans le temps"}),(0,e.jsx)(de,{width:"100%",height:180,children:(0,e.jsxs)(ke,{data:r,margin:{top:4,right:4,left:0,bottom:0},children:[(0,e.jsx)(xt,{strokeDasharray:"3 3",stroke:"rgba(255,255,255,0.04)"}),(0,e.jsx)(Ne,{dataKey:"date",tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"}}),(0,e.jsx)(we,{tickFormatter:oe,tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"},width:40}),(0,e.jsx)(le,{content:(0,e.jsx)(Ce,{})}),s.map((m,w)=>(0,e.jsx)(ye,{dataKey:m,name:Q(m),stackId:"a",fill:V(m,w),radius:w===s.length-1?[4,4,0,0]:[0,0,0,0]},m))]})}),(0,e.jsx)("div",{className:"flex flex-wrap gap-2",children:s.map((m,w)=>(0,e.jsxs)("span",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",children:[(0,e.jsx)("span",{className:"w-2 h-2 rounded-full",style:{background:V(m,w)}}),Q(m)]},m))})]}):(0,e.jsx)("div",{className:"text-center py-8 text-[11px] text-muted-foreground/50",children:"Aucune donn\xE9e"})})}if(t==="channels"){let r=Z.length>0,s=Z.map((p,m)=>({name:Q(p.key),ca:p.ca,commandes:p.count,fill:V(p.key,m)}));return(0,e.jsx)("div",{className:"space-y-2",children:r?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("p",{className:"text-[9px] font-semibold uppercase tracking-wider text-muted-foreground/60",children:"CA & commandes par canal"}),(0,e.jsx)(de,{width:"100%",height:Math.max(100,Z.length*38),children:(0,e.jsxs)(ke,{data:s,layout:"vertical",margin:{top:0,right:52,left:4,bottom:0},children:[(0,e.jsx)(Ne,{type:"number",tickFormatter:oe,tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"}}),(0,e.jsx)(we,{type:"category",dataKey:"name",tick:{fontSize:10,fill:"hsl(var(--foreground))"},width:76}),(0,e.jsx)(le,{content:(0,e.jsx)(Ce,{})}),(0,e.jsx)(ye,{dataKey:"ca",name:"CA",radius:[0,6,6,0],children:s.map((p,m)=>(0,e.jsx)(Fe,{fill:p.fill},m))})]})}),(0,e.jsx)("div",{className:"space-y-1",children:Z.map((p,m)=>{let w=H>0?Math.round(p.ca/H*100):0;return(0,e.jsxs)("div",{className:"flex items-center gap-2 px-2.5 py-1.5 rounded-xl bg-muted/30 text-[10px]",children:[(0,e.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:V(p.key,m)}}),(0,e.jsx)("span",{className:"flex-1 font-medium truncate",children:Q(p.key)}),(0,e.jsxs)("span",{className:"text-muted-foreground",children:[p.count," cmd"]}),(0,e.jsxs)("span",{className:"text-muted-foreground/60",children:[w,"%"]}),(0,e.jsx)("span",{className:"font-semibold tabular-nums",children:oe(p.ca)})]},p.key)})})]}):(0,e.jsx)("div",{className:"text-center py-8 text-[11px] text-muted-foreground/50",children:"Aucune donn\xE9e"})})}if(t==="products"){let r=U.slice(0,8),s=r.length>0,p=r.map(m=>({name:m.name.length>22?m.name.slice(0,20)+"\u2026":m.name,ca:m.ca,qty:m.qty}));return(0,e.jsx)("div",{className:"space-y-2",children:s?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("p",{className:"text-[9px] font-semibold uppercase tracking-wider text-muted-foreground
5/60",children:["Top ",r.length," produits par CA"]}),(0,e.jsx)(de,{width:"100%",height:Math.max(120,r.length*26),children:(0,e.jsxs)(ke,{data:p,layout:"vertical",margin:{top:0,right:52,left:4,bottom:0},children:[(0,e.jsx)(Ne,{type:"number",tickFormatter:oe,tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"}}),(0,e.jsx)(we,{type:"category",dataKey:"name",tick:{fontSize:9,fill:"hsl(var(--foreground))"},width:90}),(0,e.jsx)(le,{content:(0,e.jsx)(Ce,{})}),(0,e.jsx)(ye,{dataKey:"ca",name:"CA",radius:[0,6,6,0],fill:"#6366f1"})]})}),(0,e.jsxs)("div",{className:"rounded-xl border border-border/40 overflow-hidden",children:[(0,e.jsxs)("div",{className:"grid grid-cols-[1fr_auto_auto] gap-2 px-3 py-1.5 bg-muted/50 border-b border-border/30",children:[(0,e.jsx)("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Produit"}),(0,e.jsx)("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-muted-foreground/70 text-right",children:"Qt\xE9"}),(0,e.jsx)("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-muted-foreground/70 text-right min-w-[64px]",children:"CA"})]}),(0,e.jsx)("div",{className:"divide-y divide-border/20 max-h-36 overflow-y-auto",children:r.map(m=>(0,e.jsxs)("div",{className:"grid grid-cols-[1fr_auto_auto] gap-2 px-3 py-1.5 hover:bg-muted/30",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("p",{className:"text-[11px] font-medium truncate",children:m.name}),(0,e.jsx)("p",{className:"text-[9px] text-muted-foreground/50 font-mono",children:m.sku})]}),(0,e.jsx)("span",{className:"text-[11px] text-muted-foreground self-center text-right tabular-nums",children:m.qty}),(0,e.jsx)("span",{className:"text-[11px] font-semibold self-center text-right tabular-nums min-w-[64px]",children:oe(m.ca)})]},m.sku))}),(0,e.jsxs)("div",{className:"grid grid-cols-[1fr_auto_auto] gap-2 px-3 py-2 bg-muted/40 border-t border-border/40",children:[(0,e.jsxs)("span",{className:"text-[10px] font-semibold text-muted-foreground",children:["TOTAL \u2014 ",U.length," produit",U.length>1?"s":""]}),(0,e.jsx)("span",{className:"text-[11px] font-bold text-right tabular-nums",children:ce}),(0,e.jsx)("span",{className:"text-[11px] font-bold text-right tabular-nums text-indigo-400 min-w-[64px]",children:De(H)})]})]})]}):(0,e.jsx)("div",{className:"text-center py-8 text-[11px] text-muted-foreground/50",children:"Aucune vente"})})}if(t==="statuses"){let r=J.length>0,s=J.find(A=>A.status==="os-completed"||A.status==="os-delivered"),p=J.find(A=>A.status==="os-cancelled"),m=s&&K>0?Math.round(s.count/K*100):0,w=p&&K>0?Math.round(p.count/K*100):0;return(0,e.jsx)("div",{className:"space-y-2",children:r?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("p",{className:"text-[9px] font-semibold uppercase tracking-wider text-muted-foreground/60",children:"Distribution des statuts"}),(0,e.jsxs)("div",{className:"flex gap-3 items-center",children:[(0,e.jsx)(de,{width:110,height:110,children:(0,e.jsxs)(ht,{children:[(0,e.jsx)(bt,{data:J,cx:"50%",cy:"50%",innerRadius:30,outerRadius:50,dataKey:"count",nameKey:"label",paddingAngle:2,children:J.map((A,se)=>(0,e.jsx)(Fe,{fill:A.color},se))}),(0,e.jsx)(le,{content:(0,e.jsx)(Ce,{})})]})}),(0,e.jsx)("div",{className:"flex-1 space-y-1.5 min-w-0",children:J.map(A=>(0,e.jsxs)("div",{className:"flex items-center gap-2 text-[10px]",children:[(0,e.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:A.color}}),(0,e.jsx)("span",{className:"flex-1 truncate text-muted-foreground",children:A.label}),(0,e.jsx)("span",{className:"font-semibold tabular-nums",children:A.count}),(0,e.jsxs)("span",{className:"text-muted-foreground/60 w-7 text-right",children:[K>0?Math.round(A.count/K*100):0,"%"]})]},A.status))})]}),(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,e.jsxs)("div",{className:"bg-emerald-500/10 border border-emerald-500/20 rounded-xl p-2.5 text-center",children:[(0,e.jsxs)("p",{className:"text-xl font-bold text-emerald-400",children:[m,"%"]}),(0,e.jsx)("p",{className:"text-[9px] text-muted-foreground mt-0.5",children:"Taux compl\xE9tion"})]}),(0,e.jsxs)("div",{className:"bg-red-500/10 border border-red-500/20 rounded-xl p-2.5 text-center",children:[(0,e.jsxs)("p",{className:"text-xl font-bold text-red-400",children:[w,"%"]}),(0,e.jsx)("p",{className:"text-[9px] text-muted-foreground mt-0.5",children:"Taux annulation"})]})]})]}):(0,e.jsx)("div",{className:"text-center py-8 text-[11px] text-muted-foreground
5/50",children:"Aucune commande"})})}return null}return(0,e.jsxs)("div",{className:"rounded-2xl border border-border/60 bg-card overflow-hidden",children:[(0,e.jsxs)("button",{onClick:()=>n(!o),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-muted/30 transition-colors",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(Ze,{className:"w-3.5 h-3.5 text-muted-foreground"}),(0,e.jsx)("span",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Statistiques ventes"}),O&&(0,e.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-indigo-500 shrink-0"})]}),o?(0,e.jsx)(Je,{className:"w-3.5 h-3.5 text-muted-foreground"}):(0,e.jsx)(Y,{className:"w-3.5 h-3.5 text-muted-foreground"})]}),o&&(0,e.jsxs)("div",{className:"border-t border-border/40",children:[(0,e.jsxs)("div",{className:"px-4 pt-3 pb-2 space-y-2.5",children:[(0,e.jsx)("div",{className:"flex items-center gap-1 bg-muted/40 rounded-xl p-1",children:["7d","1m","3m","6m"].map(t=>(0,e.jsx)("button",{onClick:()=>i(t),className:E("flex-1 py-1.5 rounded-lg text-[11px] font-medium transition-all",a===t?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:Pt[t]},t))}),Ye.length>0&&(0,e.jsx)(nn,{chips:Ye,selected:k,onChange:I}),(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)("p",{className:"text-[9px] font-semibold uppercase tracking-wider text-muted-foreground/60",children:"Filtres produits"}),O&&(0,e.jsxs)("button",{onClick:R,className:"flex items-center gap-1 text-[9px] text-muted-foreground hover:text-foreground transition-colors",children:[(0,e.jsx)(lt,{className:"w-2.5 h-2.5"})," R\xE9initialiser"]})]}),(0,e.jsx)(on,{options:Et,selected:c,onChange:P}),Ve.length>0&&(0,e.jsxs)("select",{value:D,onChange:t=>g(t.target.value),className:"w-full px-2.5 py-1.5 rounded-lg border border-border bg-muted/30 text-xs text-foreground appearance-none cursor-pointer hover:bg-muted/60 outline-none",children:[(0,e.jsx)("option",{value:"",children:"Toutes cat\xE9gories"}),Ve.map(t=>(0,e.jsx)("option",{value:t.value,children:t.label},t.value))]})]})]}),(0,e.jsx)("div",{className:"flex overflow-x-auto border-t border-border/30 n
5o-scrollbar px-1",children:re.map((t,r)=>(0,e.jsxs)("button",{onClick:()=>h(r),className:E("relative shrink-0 px-3 py-2 text-[10px] font-semibold whitespace-nowrap transition-all",u===r?"text-foreground":"text-muted-foreground hover:text-foreground/70"),children:[t.label,u===r&&(0,e.jsx)("span",{className:"absolute bottom-0 left-1/2 -translate-x-1/2 w-1 h-1 rounded-full bg-indigo-500"})]},t.id))}),(0,e.jsx)("div",{className:"px-4 pt-3 pb-2 min-h-[180px]",onTouchStart:z,onTouchEnd:N,children:_t(re[u].id)}),(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 pb-3",children:[(0,e.jsx)("button",{onClick:()=>h(t=>Math.max(t-1,0)),disabled:u===0,className:"w-7 h-7 rounded-full bg-muted/50 flex items-center justify-center disabled:opacity-20 hover:bg-muted transition-colors",children:(0,e.jsx)(be,{className:"w-3.5 h-3.5"})}),(0,e.jsx)("div",{className:"flex items-center gap-1.5",children:re.map((t,r)=>(0,e.jsx)("button",{onClick:()=>h(r),className:E("rounded-full transition-all",r===u?"w-4 h-1.5 bg-indigo-500":"w-1.5 h-1.5 bg-muted-foreground/30 hover:bg-muted-foreground/60")},r))}),(0,e.jsx)("button",{onClick:()=>h(t=>Math.min(t+1,re.length-1)),disabled:u===re.length-1,className:"w-7 h-7 rounded-full bg-muted/50 flex items-center justify-center disabled:opacity-20 hover:bg-muted transition-colors",children:(0,e.jsx)(xe,{className:"w-3.5 h-3.5"})})]}),U.length>0&&(0,e.jsxs)("div",{className:"flex gap-2 px-4 pb-4",children:[(0,e.jsxs)("button",{onClick:Ut,className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-2 rounded-xl border border-border text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors",children:[(0,e.jsx)(ot,{className:"w-3 h-3"})," Copier"]}),(0,e.jsxs)("button",{onClick:Bt,className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-2 rounded-xl border border-border text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors",children:[(0,e.jsx)(rt,{className:"w-3 h-3"})," CSV"]})]})]})]})}var L=j(_());function rn(){let o=ge(T=>T.user),n=o?.nodeId??"",{period:a,setPeriod:i,channelOrder:l,setChannelOrder:d,tasksOpen:b,setTasksOpen:f,tasksPage:y,setTasksPage:k,teamOpen:I,setTeamOpen:c,statsOpen:P,setStatsOpen:D,statsPeriod:g,setStatsPeriod:u}=ft(n),h=q(T=>T.loaded),$=q(T=>T.loading),z=q(T=>T.fetchAll);(0,Te.useEffect)(()=>{!h&&!$&&z()},[h,$,z]);let N=(0,Te.useCallback)(T=>{f(T),T||k(0)},[f,k]),O=new Date().getHours(),R=O<12?"Bonjour":O<18?"Bon apr\xE8s-midi":"Bonsoir";return(0,L.jsxs)("div",{className:"max-w-2xl mx-auto space-y-5 pb-4",children:[(0,L.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,L.jsx)("div",{className:"w-8 h-8 rounded-xl bg-gradient-to-br from-brand to-brand-accent flex items-center justify-center shrink-0",children:(0,L.jsx)(ut,{className:"w-4 h-4 text-white"})}),(0,L.jsxs)("div",{children:[(0,L.jsxs)("h1",{className:"text-base font-bold leading-tight",children:[R,", ",o?.pseudo," \u{1F44B}"]}),(0,L.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Vue rapide"})]})]}),(0,L.jsx)("section",{children:(0,L.jsx)(Be,{period:a,onPeriodChange:i})}),(0,L.jsxs)("section",{children:[(0,L.jsx)(an,{children:"Canaux de vente \u2014 aujourd'hui"}),(0,L.jsx)(Ue,{channelOrder:l,onOrderChange:d})]}),(0,L.jsx)("section",{children:(0,L.jsx)($e,{open:b,onToggle:N,page:y,onPageChange:k})}),(0,L.jsx)("section",{children:(0,L.jsx)(Ke,{open:I,onToggle:c})}),(0,L.jsx)("section",{children:(0,L.jsx)(Ge,{open:P,onToggle:D,period:g,onPeriodChange:u})})]})}function an({children:o}){return(0,L.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground mb-2 px-0.5",children:o})}export{rn 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.