1import{u as Bt,m as Ut,j as e,M as da,s as U,c as _t,K as fe,f as xa,p as ma,b as pa,l as ge,r as pt,a as Ve}from"./index-PXpjhCaY.js";import{r as i,R as ua,a as Gt,u as ba}from"./vendor-react-SfNqDmFq.js";import{u as ha}from"./platforms-Cu3PO84F.js";import{C as ut}from"./ConfirmModal-Dajri4A9.js";import{E as bt}from"./EmptyState-C-MIKlE3.js";import{S as ht,l as ga}from"./SalesMarketplaceSwitcher-Pg4DevjV.js";import{f as fa}from"./formatters-BZJ8BkrL.js";import{P as Ne,b3 as ye,ar as Me,u as ya,ap as ja,F as gt,R as Ke,aT as va,T as je,b as Na,aC as wa,$ as ka,Y as Wt,ay as Kt,X as ve,am as Ca,b4 as Sa,aU as pe,b5 as Ea,a as Ht,a8 as Pa,V as Ma,s as qt,a5 as _e,b6 as Ta,l as Aa,b7 as $a,b8 as Da,y as Be,an as ft,I as yt,ac as jt,x as vt,al as Fa,b9 as za,ba as La,aw as Ra,ax as Oa,av as Ia,at as Va}from"./vendor-icons-Dq2TnJO2.js";import{R as Nt,A as Ba,C as Ua,X as _a,Y as Ga,T as wt,a as kt,P as Wa,c as Ka,d as Ha}from"./vendor-charts-CR7lJZ_9.js";import{A as Yt}from"./ActionSheet-Dp9SJVvB.js";import{a as Ct,W as qa}from"./WheelSheet-BVFoDOaD.js";import"./vendor-state-GakPUnLx.js";import"./vendor-http-C0Zqfgkc.js";function Ya(){const a=Bt(m=>m.user),r=Ut(m=>{var c;return(c=m.subscription)==null?void 0:c.tier}),o=(a==null?void 0:a.businessType)||"personal";return r!=="business"&&o!=="personal"?"personal":o}const Xa={Colissimo:"https://www.laposte.fr/outils/suivre-vos-envois?code={tracking}","Lettre suivie":"https://www.laposte.fr/outils/suivre-vos-envois?code={tracking}","La Poste":"https://www.laposte.fr/outils/suivre-vos-envois?code={tracking}",Chronopost:"https://www.chronopost.fr/tracking-no-list?liession={tracking}","Mondial Relay":"https://www.mondialrelay.fr/suivi-de-colis?numeroExpedition={tracking}&codePostal={postalCode}",UPS:"https://www.ups.com/track?tracknum={tracking}",DHL:"https://www.dhl.com/fr-fr/home/suivi.html?tracking-id={tracking}"},Ja=["Colissimo","Mondial Relay","Lettre suivie","Chronopost","La Poste","UPS","DHL","Autre"];function Ge(a,r,o){if(!r||!a)return null;const m=Xa[a];if(!m)return null;let c=m.replace("{tracking}",encodeURIComponent(r));return c=c.replace("{postalCode}",encodeURIComponent(o||"")),c}const Qa=[{value:"",label:"Expédié (pas de statut)",icon:"â"},{value:"En transit",label:"En transit",icon:"ð"},{value:"En livraison",label:"En livraison",icon:"ð"},{value:"Livré",label:"Livré",icon:"â
"}];function St({sale:a,isOpen:r,onClose:o,onSaved:m}){var ie,ee;const c=!!a.shippedDate,[x,E]=i.useState(String(a.realShippingCostEur||0)),[P,y]=i.useState(a.shippedDate||new Date().toISOString().split("T")[0]),[b,z]=i.useState(a.shippingCarrier||""),[d,u]=i.useState(a.trackingNumber||""),[T,$]=i.useState(a.buyerPostalCode||""),[w,W]=i.useState(null),[B,K]=i.useState(!1),[A,H]=i.useState(!1),[j,g]=i.useState(!1),[L,D]=i.useState(null),v=((ie=a.trackingStatus)==null?void 0:ie.status)||"",[F,_]=i.useState(v),q=Ge(b,d,T),O=async h=>{var p,I;h.preventDefault(),K(!0),D(null);try{await U.markShipped(a.id,{realShippingCostEur:parseFloat(x)||0,trackingNumber:d.trim()||null,shippingCarrier:b||null,shippedDate:P,buyerPostalCode:T.trim()||null}),w&&await U.uploadShippingInvoice(a.id,w),c&&F&&F!==v&&await U.updateTrackingStatus(a.id,F),m(),o()}catch(C){D(((I=(p=C==null?void 0:C.response)==null?void 0:p.data)==null?void 0:I.error)||"Erreur lors de la mise à jour")}finally{K(!1)}},ue=async()=>{var h,p;H(!0),D(null);try{await U.markShipped(a.id,{realShippingCostEur:parseFloat(x)||0,trackingNumber:d.trim()||null,shippingCarrier:b||null,buyerPostalCode:T.trim()||null}),w&&await U.uploadShippingInvoice(a.id,w),m(),o()}catch(I){D(((p=(h=I==null?void 0:I.response)==null?void 0:h.data)==null?void 0:p.error)||"Erreur lors de l'enregistrement")}finally{H(!1)}},re=async()=>{var h,p;g(!0),D(null);try{await U.markShipped(a.id,{realShippingCostEur:0,trackingNumber:null,shippingCarrier:null,shippedDate:null,buyerPostalCode:null}),m(),o()}catch(I){D(((p=(h=I==null?void 0:I.response)==null?void 0:h.data)==null?void 0:p.error)||"Erreur lors de la réinitialisation")}finally{g(!1)}},ne=h=>{var C;const p=(C=h.target.files)==null?void 0:C[0];if(!p)return;if(!["application/pdf","image/png","image/jpeg"].includes(p.type)){D("Format accepté : PDF, PNG ou JPG");return}if(p.size>5*1024*1024){D("Fichier trop volumineux (max 5 Mo)");return}D(null),W(p)};return e.jsx(da,{isOpen:r,onClose:o,title:c?"Modifier l'expédition":"Expédier l'article",size:"md",children:e.jsxs("form",{onSubmit:O,className:"space-y-5",children:[e.jsxs("div",{className:"p-3.5 rounded-xl bg-lab-surface border border-lab-border-subtle flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-accent-primary/10",children:e.jsx(Ne,{size:18,className:"text-accent-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-lab-text-primary truncate",children:a.item.name}),e.jsxs("p",{className:"text-xs text-lab-text-tertiary",children:["Vendu le ",new Date(a.saleDate).toLocaleDateString("fr-FR",{day:"numeric",month:"long",year:"numeric"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Frais d'envoi réels (â¬)"}),e.jsx("input",{type:"number",step:"0.01",min:"0",className:"input",value:x,onChange:h=>E(h.target.value)}),(parseFloat(x)||0)!==a.realShippingCostEur&&a.realShippingCostEur>0&&e.jsxs("p",{className:"text-[11px] text-type-fire mt-1",children:["Ancien : ",fa(a.realShippingCostEur)," â la marge sera recalculée"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Date d'expédition"}),e.jsx("input",{type:"date",className:"input",value:P,onChange:h=>y(h.target.value),required:!0})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"N° de suivi"}),e.jsx("input",{type:"text",className:"input",placeholder:"Ex: 6A12345678901",value:d,onChange:h=>u(h.target.value)}),e.jsx("p",{className:"text-[11px] text-lab-text-tertiary mt-1",children:"Le transporteur est détecté automatiquement (Colissimo, DHL, Chronopost...)"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Transporteur (optionnel)"}),e.jsxs("select",{className:"input",value:b,onChange:h=>z(h.target.value),children:[e.jsx("option",{value:"",children:"Auto-détection..."}),Ja.map(h=>e.jsx("option",{value:h,children:h},h))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Code postal destinataire"}),e.jsx("input",{type:"text",className:"input",placeholder:"Ex: 75001",maxLength:10,value:T,onChange:h=>$(h.target.value)})]})]})]}),q&&e.jsxs("div",{className:"flex items-center gap-2 p-2.5 rounded-lg bg-accent-primary/5 border border-accent-primary/15",children:[e.jsx(ye,{size:14,className:"text-accent-primary flex-shrink-0"}),e.jsxs("a",{href:q,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-accent-primary hover:underline truncate flex items-center gap-1",children:["Suivre le colis ",e.jsx(Me,{size:12})]})]}),c&&e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Statut de livraison"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:Qa.map(h=>{const p=h.value===F||!h.value&&!F;return e.jsxs("button",{type:"button",onClick:()=>
1_(h.value),className:`flex items-center gap-2 p-2.5 rounded-xl border text-sm font-medium transition-all ${p?h.value==="Livré"?"bg-accent-success/10 border-accent-success/30 text-accent-success":h.value?"bg-accent-primary/10 border-accent-primary/30 text-accent-primary":"bg-lab-surface border-lab-border-default text-lab-text-primary":"bg-lab-surface border-lab-border-subtle text-lab-text-tertiary hover:border-lab-border-default hover:text-lab-text-secondary cursor-pointer"}`,children:[e.jsx("span",{children:h.icon}),h.label,p&&e.jsx(ya,{size:14,className:"ml-auto"})]},h.value||"none")})}),a.trackingStatus&&e.jsxs("p",{className:"text-[11px] text-lab-text-tertiary mt-1.5",children:["Dernière mise à jour : ",new Date(a.trackingStatus.lastUpdate).toLocaleDateString("fr-FR",{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}),(ee=a.trackingStatus.description)!=null&&ee.includes("manuellement")?" · Manuel":" · API"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Facture d'envoi (optionnel)"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"file",accept:".pdf,.png,.jpg,.jpeg",onChange:ne,className:"hidden",id:"shipping-invoice-input"}),e.jsxs("label",{htmlFor:"shipping-invoice-input",className:"flex items-center gap-3 p-3 rounded-xl border border-dashed border-lab-border-default hover:border-accent-primary/40 cursor-pointer transition-colors group",children:[e.jsx("div",{className:"p-2 rounded-lg bg-lab-surface group-hover:bg-accent-primary/10 transition-colors",children:e.jsx(ja,{size:16,className:"text-lab-text-tertiary group-hover:text-accent-primary transition-colors"})}),e.jsx("div",{className:"flex-1 min-w-0",children:w?e.jsx("p",{className:"text-sm text-lab-text-primary truncate",children:w.name}):a.shippingInvoicePath?e.jsxs("p",{className:"text-sm text-accent-success flex items-center gap-1",children:[e.jsx(gt,{size:13})," Facture existante"]}):e.jsx("p",{className:"text-sm text-lab-text-tertiary",children:"PDF, PNG ou JPG (max 5 Mo)"})})]})]}),a.shippingInvoicePath&&!w&&e.jsxs("a",{href:U.getShippingInvoiceUrl(a.id),target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 mt-1.5 text-xs text-accent-primary hover:underline",children:[e.jsx(gt,{size:12})," Télécharger la facture actuelle"]})]}),L&&e.jsx("div",{className:"p-3 rounded-lg bg-accent-danger/10 border border-accent-danger/20 text-sm text-accent-danger",children:L}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-lab-border-subtle",children:[c?e.jsxs("button",{type:"button",onClick:re,disabled:j||B,className:"text-sm text-accent-danger hover:text-accent-danger/80 flex items-center gap-1.5 transition-colors",children:[j?e.jsx("div",{className:"w-3.5 h-3.5 rounded-full border-2 border-accent-danger/30 border-t-accent-danger animate-spin"}):e.jsx(Ke,{size:14}),"Annuler l'expédition"]}):e.jsx("div",{}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{type:"button",onClick:o,className:"btn btn-secondary",children:"Fermer"}),!c&&e.jsx("button",{type:"button",onClick:ue,className:"btn btn-secondary flex items-center gap-2",disabled:B||A||j,children:A?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-lab-text-tertiary/30 border-t-lab-text-tertiary animate-spin"}),"Enregistrement..."]}):e.jsxs(e.Fragment,{children:[e.jsx(va,{size:16}),"Enregistrer"]})}),e.jsx("button",{type:"submit",className:"btn btn-primary flex items-center gap-2",disabled:B||A||j,children:B?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white/30 border-t-white animate-spin"}),"Enregistrement..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ne,{size:16}),c?"Mettre à jour":"Marquer comme expédié"]})})]})]})]})})}const Et=a=>new Intl.NumberFormat("fr-FR",{style:"currency",currency:"EUR",maximumFractionDigits:0}).format(Math.round(a||0)),Za=a=>new Intl.NumberFormat("fr-FR",{style:"currency",currency:"EUR"}).format(Math.round((a||0)*100)/100);function es(a){return a==="personal"?"Bénéfice réalisé":"Marge brute"}const ts={ebay:"#5B9BF0",vinted:"#34d399",cardmarket:"#eab308",autres:"#6d6885"},Pt=["#B07CF0","#FB7A45","#5B9BF0","#34d399","#eab308"];function Mt(a,r){return ts[a.toLowerCase().trim()]||Pt[r%Pt.length]}const Tt=ua.memo(function({active:r,payload:o,label:m}){return!r||!o||!o.length?null:e.jsxs("div",{className:"bg-lab-elevated border border-lab-border-default rounded-lg p-2.5 shadow-glass",children:[e.jsx("p",{className:"text-xs font-medium text-lab-text-primary mb-1.5",children:m}),o.map((c,x)=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:c.color}}),e.jsxs("span",{className:"text-lab-text-secondary",children:[c.name," :"]}),e.jsx("span",{className:"font-mono text-lab-text-primary",children:Za(c.value)})]},x))]})});function At({monthly:a,byPlatform:r,topProducts:o,businessType:m,isMobile:c=!1}){const[x,E]=i.useState(!c),P=es(m),y=a.some(d=>d.ca>0||d.count>0),b=r.reduce((d,u)=>d+u.ca,0)||1,z=e.jsxs("button",{onClick:()=>E(d=>!d),className:"w-full flex items-center justify-between gap-3 px-4 py-3 hover:bg-lab-elevated/50 rounded-t-2xl transition-colors touch-manipulation","aria-expanded":x,children:[e.jsxs("span",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"p-1.5 rounded-lg bg-accent-primary/10",children:e.jsx(je,{size:16,className:"text-accent-primary"})}),e.jsx("span",{className:"text-[15px] font-semibold text-lab-text-primary",children:"Statistiques de vente"})]}),e.jsxs("span",{className:"flex items-center gap-1.5 text-label-sm text-lab-text-tertiary",children:[x?"Masquer":"Afficher",x?e.jsx(ka,{size:16}):e.jsx(Wt,{size:16})]})]});return e.jsxs("section",{className:"rounded-2xl border border-lab-border-subtle bg-lab-surface/40 mb-4 overflow-hidden animate-in fade-in",children:[z,x&&e.jsx("div",{className:"px-4 pb-4 animate-in slide-in-from-top-2",children:y?e.jsxs("div",{className:`grid gap-3 ${c?"grid-cols-1":"grid-cols-1 lg:grid-cols-3"}`,children:[e.jsxs("div",{className:"lg:col-span-2 rounded-xl border border-lab-border-subtle bg-lab-surface p-3",children:[e.jsxs("p",{className:"text-label-sm text-lab-text-secondary font-medium mb-2 flex items-center gap-1.5",children:[e.jsx(je,{size:14,className:"text-accent-primary"})," CA & ",P.toLowerCase()," â ",a.length," mois"]}),e.jsx("div",{className:"h-44",children:e.jsx(Nt,{width:"100%",height:"100%",children:e.jsxs(Ba,{data:a,margin:{top:5,right:6,left:-18,bottom:0},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"sCA",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",
1stopColor:"#eab308",stopOpacity:.25}),e.jsx("stop",{offset:"95%",stopColor:"#eab308",stopOpacity:0})]}),e.jsxs("linearGradient",{id:"sMarge",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#34d399",stopOpacity:.22}),e.jsx("stop",{offset:"95%",stopColor:"#34d399",stopOpacity:0})]})]}),e.jsx(Ua,{strokeDasharray:"3 3",stroke:"rgba(255,255,255,0.04)",vertical:!1}),e.jsx(_a,{dataKey:"name",stroke:"rgba(245,245,247,0.4)",fontSize:11,tickLine:!1,axisLine:!1}),e.jsx(Ga,{stroke:"rgba(245,245,247,0.4)",fontSize:11,tickLine:!1,axisLine:!1,tickFormatter:d=>`${d}â¬`,width:48}),e.jsx(wt,{content:e.jsx(Tt,{})}),e.jsx(kt,{type:"monotone",dataKey:"ca",name:"CA",stroke:"#eab308",strokeWidth:2,fill:"url(#sCA)"}),e.jsx(kt,{type:"monotone",dataKey:"marge",name:P,stroke:"#34d399",strokeWidth:2,fill:"url(#sMarge)"})]})})}),e.jsxs("div",{className:"flex items-center justify-center gap-5 mt-2 pt-2 border-t border-lab-border-subtle",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-label-sm text-lab-text-secondary",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-sm bg-accent-primary"}),"Chiffre d'affaires"]}),e.jsxs("span",{className:"flex items-center gap-1.5 text-label-sm text-lab-text-secondary",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-sm bg-type-grass"}),P]})]})]}),e.jsxs("div",{className:"rounded-xl border border-lab-border-subtle bg-lab-surface p-3",children:[e.jsxs("p",{className:"text-label-sm text-lab-text-secondary font-medium mb-2 flex items-center gap-1.5",children:[e.jsx(Na,{size:14,className:"text-type-psychic"})," Par plateforme"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-[92px] h-[92px] shrink-0",children:e.jsx(Nt,{width:"100%",height:"100%",children:e.jsxs(Wa,{children:[e.jsx(Ka,{data:r,dataKey:"ca",nameKey:"name",innerRadius:26,outerRadius:44,paddingAngle:2,stroke:"none",children:r.map((d,u)=>e.jsx(Ha,{fill:Mt(d.name,u)},d.name))}),e.jsx(wt,{content:e.jsx(Tt,{})})]})})}),e.jsx("div",{className:"flex-1 min-w-0 space-y-1",children:r.map((d,u)=>e.jsxs("div",{className:"flex items-center gap-1.5 text-[11.5px]",children:[e.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{background:Mt(d.name,u)}}),e.jsx("span",{className:"text-lab-text-secondary truncate flex-1",children:d.name}),e.jsxs("span",{className:"text-lab-text-tertiary font-mono",children:[Math.round(d.ca/b*100),"%"]})]},d.name))})]})]}),e.jsxs("div",{className:"lg:col-span-3 rounded-xl border border-lab-border-subtle bg-lab-surface p-3",children:[e.jsxs("p",{className:"text-label-sm text-lab-text-secondary font-medium mb-2 flex items-center gap-1.5",children:[e.jsx(wa,{size:14,className:"text-accent-primary"})," Top produits vendus"]}),e.jsx("div",{className:`grid gap-2 ${c?"grid-cols-1":"grid-cols-2"}`,children:o.map((d,u)=>e.jsxs("div",{className:"flex items-center gap-2.5 rounded-lg bg-lab-elevated/40 px-2.5 py-1.5",children:[e.jsx("span",{className:"w-5 text-center text-label-sm font-mono text-lab-text-tertiary shrink-0",children:u+1}),d.image?e.jsx("img",{src:d.image,alt:"",className:"w-8 h-11 rounded object-cover border border-lab-border-subtle shrink-0",loading:"lazy"}):e.jsx("span",{className:"w-8 h-11 rounded bg-lab-elevated border border-lab-border-subtle shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[12.5px] font-medium text-lab-text-primary truncate",children:d.name}),e.jsxs("p",{className:"text-[11px] text-lab-text-tertiary",children:[d.count," vendu",d.count>1?"s":""," · marge ",Et(d.marge)]})]}),e.jsx("span",{className:"font-mono text-[13px] text-lab-text-primary shrink-0",children:Et(d.revenue)})]},d.name))})]})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-lab-text-tertiary",children:[e.jsx(je,{size:30,strokeWidth:1,className:"mb-2 opacity-30"}),e.jsx("p",{className:"text-sm",children:"Pas encore de données sur la période"})]})})]})}const We={priceMin:"",priceMax:"",margeMin:"",margeMax:"",sort:"date"};function $t(a){let r=0;return a.priceMin&&r++,a.priceMax&&r++,a.margeMin&&r++,a.margeMax&&r++,a.sort&&a.sort!=="date"&&r++,r}const as=[{key:"date",label:"Récent",icon:Ca},{key:"price",label:"Prix",icon:Sa},{key:"marge",label:"Marge",icon:je}],Ee="w-full rounded-lg bg-lab-elevated border border-lab-border-subtle px-3 py-2 text-sm text-lab-text-primary font-mono placeholder:text-lab-text-tertiary/50 focus:border-accent-primary/50 focus:outline-none";function Dt({open:a,value:r,marginLabel:o,isMobile:m=!1,onApply:c,onClose:x}){const[E,P]=i.useState(r);i.useEffect(()=>{a&&P(r)},[a,r]),i.useEffect(()=>{const u=T=>{T.key==="Escape"&&x()};return a&&window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[a,x]);const y=i.useRef(x);if(y.current=x,i.useEffect(()=>{if(a)return _t(()=>y.current())},[a]),!a)return null;const b=u=>P(T=>({...T,...u})),z=m?"inset-x-0 bottom-0 rounded-t-2xl max-h-[85vh]":"top-0 right-0 h-full w-[380px] max-w-[92vw]",d=m?"animate-in slide-in-from-bottom":"animate-in slide-in-from-right";return Gt.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[70]",role:"dialog","aria-modal":"true","aria-label":"Filtres avancés",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:x}),e.jsxs("div",{className:`absolute ${z} ${d} bg-lab-base border border-lab-border-subtle shadow-elevated flex flex-col`,style:{paddingBottom:m?"env(safe-area-inset-bottom)":void 0},children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-lab-border-subtle",children:[e.jsxs("h3",{className:"flex items-center gap-2 text-[15px] font-semibold text-lab-text-primary",children:[e.jsx(Kt,{size:16,className:"text-accent-primary"})," Filtres avancés"]}),e.jsx("button",{onClick:x,className:"btn-icon h-9 w-9","aria-label":"Fermer",children:e.jsx(ve,{size:18})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-label-sm text-lab-text-tertiary uppercase tracking-wider mb-2",children:"Trier par"}),e.jsx("div",{className:"inline-flex w-full gap-1 rounded-full border border-lab-border-subtle bg-lab-surface/60 p-1",children:as.map(u=>{const T=E.sort===u.key;return e.jsxs("button",{onClick:()=>b({sort:u.key}),className:`flex-1 h-9 rounded-full text-xs font-semibold flex items-center justify-center gap-1.5 transition-all touch-manipulation ${T?"bg-accent-primary/20 text-accent-primary ring-1 ring-accent-primary/40":"text-lab-text-tertiary hover:text-lab-text-primary"}`,"aria-pressed":T,children:[e.jsx(u.icon,{size:14})," ",u.label]},u.key)})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-label-sm text-lab-text-tertiary uppercase tracking-wider mb-2",children:"Prix de vente (â¬)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",inputMode:"decimal",placeholder:"min",value:E.priceMin,onChange:u=>b({priceMin:u.target.value}),className:Ee}),e.jsx("span",{className:"text-lab-text-tertiary",children:"â"}),e.jsx("input",{type:"number",inputMode:"decimal",placeholder:"max",value:E.priceMax,onChange:u=>b({priceMax:u.target.value}),className:Ee})]})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-label-sm text-lab-text-tertiary uppercase tracking-wider mb-2",children:[o," (â¬)"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",inputMode:"decimal",placeholder:"min",value:E.margeMin,onChange:u=>b({margeMin:u.target.value}),className:Ee}),e.jsx("span",{className:"text-lab-text-tertiary",children:"â"}),e.jsx("input",{type:"number",inputMode:"decimal",placeholder:"max",value:E.margeMax,onChange:u=>b({margeMax:u.target.value}),className:Ee})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-label-sm text-lab-text-tertiary uppercase tracking-wider mb-2",children:"Vues rapides"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{onClick:()=>b({sort:"marge",margeMin:"20"}),className:"px-3 py-1.5 rounded-full text-xs bg-type-grass/10 text-type-grass border border-type-grass/20 touch-manipulation",children:"Meilleures marges"}),e.jsx("button",{onClick:()=>b({sort:"price"}),className:"px-3 py-1.5 rounded-full text-xs bg-accent-primary/10 text-accent-primary border border-accent-primary/20 touch-manipulation",children:"Grosses ventes"}),e.jsx("button",{onClick:()=>b({sort:"marge",margeMax:"0"}),className:"px-3 py-1.5 rounded-full text-xs bg-accent-danger/10 text-accent-danger border border-accent-danger/20 touch-manipulation",children:"Ventes à perte"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 px-5 py-4 border-t border-lab-border-subtle",children:[e.jsxs("button",{onClick:()=>P(We),className:"btn-secondary flex items-center gap-1.5 px-3",children:[e.jsx(Ke,{size:15})," Réinitialiser"]}
1),e.jsx("button",{onClick:()=>{c(E),x()},className:"btn-primary flex-1",children:"Appliquer"})]})]})]}),document.body)}const ss=[{value:"week",label:"Semaine"},{value:"month",label:"Ce mois"},{value:"lastMonth",label:"Mois dernier (M-1)"},{value:"year",label:"Année"},{value:"all",label:"Tout"},{value:"custom",label:"Personnaliséeâ¦"}],Ft={week:"Semaine",month:"Ce mois",lastMonth:"M-1",year:"Année",all:"Tout",custom:"Perso."},rs=[{value:"",label:"Toutes"},{value:"todo",label:"à gérer"},{value:"pending",label:"à expédier"},{value:"shipped",label:"Expédiées"}],zt={"":"Toutes",todo:"à gérer",pending:"à expédier",shipped:"Expédiées"};function Ue({label:a,active:r,onOpen:o,ariaLabel:m}){return e.jsxs("button",{type:"button",onClick:()=>{fe(),o()},"aria-label":m,className:`flex h-11 min-w-0 flex-1 items-center justify-center gap-1 rounded-xl border px-2 text-[12.5px] font-semibold transition-colors active:bg-lab-subtle/60 ${r?"border-accent-primary/40 bg-accent-primary/[0.12] text-accent-light":"border-lab-border-subtle bg-lab-surface text-lab-text-secondary"}`,children:[e.jsx("span",{className:"truncate",children:a}),e.jsx(Wt,{size:12,className:"shrink-0 opacity-60","aria-hidden":!0})]})}function ns({isOpen:a,onClose:r,dateRange:o,onDatePreset:m,onCustomRange:c}){const[x,E]=i.useState(o.preset),[P,y]=i.useState(o.from||""),[b,z]=i.useState(o.to||"");i.useEffect(()=>{a&&(E(o.preset),y(o.from||""),z(o.to||""))},[a,o]);const d=()=>{x==="custom"?c(P||null,b||null):m(x),r()};return e.jsxs(Yt,{isOpen:a,onClose:r,title:"Période",subtitle:"Ventes affichées et totaux",children:[e.jsx("div",{className:"px-1 pb-1",children:e.jsx(qa,{options:ss,value:x,onChange:E,ariaLabel:"Période"})}),x==="custom"&&e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx("input",{type:"date",value:P,onChange:u=>y(u.target.value),className:"input h-11 min-w-0 flex-1 text-[13px]","aria-label":"Date de début"}),e.jsx("input",{type:"date",value:b,onChange:u=>z(u.target.value),className:"input h-11 min-w-0 flex-1 text-[13px]","aria-label":"Date de fin"})]}),e.jsx("button",{type:"button",onClick:d,className:"mt-3 w-full rounded-xl py-3 text-sm font-semibold text-white transition-all active:scale-[0.99]",style:{background:"linear-gradient(180deg, var(--cert-accent), var(--cert-accent-deep))"},children:"Appliquer"})]})}function is({dateRange:a,onDatePreset:r,onCustomRange:o,shippingFilter:m,onShippingChange:c,platformFilter:x,onPlatformChange:E,platforms:P,advCount:y,onOpenAdvanced:b,onRefreshTracking:z,refreshingTracking:d,onSyncEbay:u,syncingEbay:T}){var D;const[$,w]=i.useState(!1),[W,B]=i.useState(!1),[K,A]=i.useState(!1),[H,j]=i.useState(!1),g=i.useMemo(()=>{const v=["ebay","cardmarket","vinted"],F=O=>O.name.toLowerCase().trim(),_=P.filter(O=>F(O)!=="cardmarket (auto)"),q=[..._.filter(O=>v.includes(F(O))).sort((O,ue)=>v.indexOf(F(O))-v.indexOf(F(ue))),..._.filter(O=>!v.includes(F(O)))];return[{value:"",label:"Toutes plateformes"},...q.map(O=>({value:String(O.id),label:O.name}))]},[P]),L=x&&((D=P.find(v=>String(v.id)===x))==null?void 0:D.name)||"Plateforme";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-stretch gap-1.5",children:[e.jsx(Ue,{label:Ft[a.preset]||"Période",active:a.preset!=="month",onOpen:()=>w(!0),ariaLabel:`Période : ${Ft[a.preset]}`}),e.jsx(Ue,{label:zt[m],active:m!=="",onOpen:()=>B(!0),ariaLabel:`Statut d'expédition : ${zt[m]}`}),e.jsx(Ue,{label:L,active:x!=="",onOpen:()=>A(!0),ariaLabel:`Plateforme : ${L}`}),e.jsxs("button",{type:"button",onClick:()=>{fe(),b()},className:`relative flex h-11 w-11 shrink-0 items-center justify-center rounded-xl border transition-colors ${y>0?"border-accent-primary/40 bg-accent-primary/10 text-accent-light":"border-lab-border-subtle bg-lab-surface text-lab-text-secondary"}`,"aria-label":`Filtres avancés${y>0?` (${y} actifs)`:""}`,children:[e.jsx(Kt,{size:18}),y>0&&e.jsx("span",{className:"absolute -right-1.5 -top-1.5 flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-accent-primary px-1 text-[10px] font-bold tabular-nums text-white",children:y})]}),e.jsx("button",{type:"button",onClick:()=>{fe(),j(!0)},className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl border border-lab-border-subtle bg-lab-surface text-lab-text-secondary transition-colors active:bg-lab-subtle/60","aria-label":"Actions (suivis, synchronisation eBay)",children:d||T?e.jsx(pe,{size:17,className:"animate-spin text-accent-light"}):e.jsx(Ea,{size:18})})]}),e.jsx(ns,{isOpen:$,onClose:()=>w(!1),dateRange:a,onDatePreset:r,onCustomRange:o}),e.jsx(Ct,{isOpen:W,onClose:()=>B(!1),title:"Statut d'expédition",subtitle:"« à gérer » = à expédier ou à délister",options:rs,value:m,onApply:v=>c(v)}),e.jsx(Ct,{isOpen:K,onClose:()=>A(!1),title:"Plateforme",options:g,value:x,onApply:E}),e.jsx(Yt,{isOpen:H,onClose:()=>j(!1),title:"Actions",children:e.jsxs("div",{className:"space-y-1",children:[z&&e.jsxs("button",{type:"button",disabled:d,onClick:()=>{fe(),j(!1),z()},className:"flex min-h-[52px] w-full items-center gap-3 rounded-xl px-2 py-2 text-left transition-colors active:bg-white/[0.05] disabled:opacity-50",children:[e.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-accent-primary/10 text-accent-light",children:e.jsx(pe,{size:17,className:d?"animate-spin":"","aria-hidden":!0})}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-[14px] font-semibold text-lab-text-primary",children:d?"Actualisationâ¦":"Actualiser les suivis"}),e.jsx("span",{className:"block text-[12px] text-lab-text-tertiary",children:"Colis non livrés, tous transporteurs"})]})]}),u&&e.jsxs("button",{type:"button",disabled:T,onClick:()=>{fe(),j(!1),u()},className:"flex min-h-[52px] w-full items-center gap-3 rounded-xl px-2 py-2 text-left transition-colors active:bg-white/[0.05] disabled:opacity-50",children:[e.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-accent-primary/10 text-accent-light",children:e.jsx(Ht,{size:17,"aria-hidden":!0})}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-[14px] font-semibold text-lab-text-primary",children:T?"Synchronisationâ¦":"Synchroniser eBay"}),e.jsx("span",{className:"block text-[12px] text-lab-text-tertiary",children:"Importer les commandes récentes"})]})]})]})})]})}const ls=a=>new Intl.NumberFormat("fr-FR",{style:"currency",currency:"EUR"}).format(Math.round((a||0)*100)/100),Lt=a=>new Date(a).toLocaleDateString("fr-FR",{day:"numeric",month:"long",year:"numeric"});function cs({sale:a,businessType:r,fiscalLabel1:o,fiscalLabel2:m,showSlot2:c,margeLabel:x,stateLabel:E,stateBadgeClass:P,onClose:y,onViewItem:b,onShip:z}){var H;i.useEffect(()=>{const j=g=>{g.key==="Escape"&&y()};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[y]);const d=i.useRef(y);d.current=y,i.useEffect(()=>_t(()=>d.current()),[]);const u=r!=="personal",T=a.fiscalTvaEur??a.computedTvaReverserEur??0,$=a.fiscalVirementEur??a.computedVirementPrudentEur??0,w=a.computedCashNetOperationalEur??0,W=a.item.costTotalPurchaseEur??0,B=w-W,K=(a.crossListingAlerts||[]).filter(j=>!j.removed),A=({label:j,value:g,neg:L,strong:D,valueClass:v})=>e.jsxs("div",{className:`flex items-center justify-between py-2 ${D?"border-t border-lab-border-subtle mt-1 pt-2.5":""}`,children:[e.jsx("span",{className:`text-sm ${D?"text-lab-text-primary font-medium":"text-lab-text-secondary"}`,children:j}),e.jsxs("span",{className:`font-mono text-sm ${D?"font-semibold":""} ${v||(L?"text-lab-text-tertiary":"text-lab-text-primary")}`,children:[L&&g>0?"â":"",ls(g)]})]});return Gt.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[80] flex items-end sm:items-center justify-center",role:"dialog","aria-modal":"true","aria-label":"Détail de la vente",children:[e.jsx("div",{className:"absolute inset-0 bg-black/55",onClick:y}
1),e.jsxs("div",{className:"relative w-full sm:max-w-lg max-h-[90vh] overflow-y-auto bg-lab-base border border-lab-border-subtle rounded-t-2xl sm:rounded-2xl shadow-elevated animate-in slide-in-from-bottom sm:zoom-in-95",style:{paddingBottom:"env(safe-area-inset-bottom)"},children:[e.jsxs("div",{className:"sticky top-0 z-10 flex items-start justify-between gap-3 px-5 py-4 bg-lab-base border-b border-lab-border-subtle",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[a.item.imageUrl?e.jsx("img",{src:a.item.imageUrl,alt:"",className:"w-11 h-14 rounded-lg object-cover border border-lab-border-subtle shrink-0"}):e.jsx("span",{className:"w-11 h-14 rounded-lg bg-lab-elevated border border-lab-border-subtle shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-[15px] font-semibold text-lab-text-primary truncate",children:a.item.name}),e.jsxs("p",{className:"text-xs text-lab-text-tertiary",children:[Lt(a.saleDate),(H=a.salePlatform)!=null&&H.name?` · ${a.salePlatform.name}`:""]}),e.jsx("span",{className:`inline-flex items-center gap-1 mt-1 text-[11px] font-medium px-2 py-0.5 rounded-full ${P}`,children:E})]})]}),e.jsx("button",{onClick:y,className:"btn-icon h-9 w-9 shrink-0","aria-label":"Fermer",children:e.jsx(ve,{size:18})})]}),e.jsxs("div",{className:"px-5 py-4 space-y-5",children:[e.jsxs("section",{children:[e.jsxs("p",{className:"text-label-sm text-lab-text-tertiary uppercase tracking-wider mb-1 flex items-center gap-1.5",children:[e.jsx(Pa,{size:13,className:"text-accent-primary"})," Ventilation"]}),e.jsx(A,{label:"Prix de vente",value:a.saleTotalClientEur}),e.jsx(A,{label:"Frais plateforme",value:a.platformFeesEur,neg:!0}),e.jsx(A,{label:"Frais d'envoi",value:a.realShippingCostEur,neg:!0}),e.jsx(A,{label:"Encaissement net",value:w,strong:!0}),e.jsx(A,{label:"Coût d'achat",value:W,neg:!0}),e.jsx(A,{label:x,value:B,strong:!0,valueClass:B>=0?"text-type-grass":"text-accent-danger"})]}),u&&e.jsxs("section",{children:[e.jsx("p",{className:"text-label-sm text-lab-text-tertiary uppercase tracking-wider mb-1",children:"Fiscalité de la vente"}),e.jsx(A,{label:o,value:T,valueClass:"text-type-fire"}),c&&e.jsx(A,{label:m,value:$,valueClass:"text-type-psychic"})]}),(a.buyerIdentity||a.salePaymentMethod||a.buyerIdNumber)&&e.jsxs("section",{children:[e.jsxs("p",{className:"text-label-sm text-lab-text-tertiary uppercase tracking-wider mb-1 flex items-center gap-1.5",children:[e.jsx(Ma,{size:13,className:"text-lab-text-tertiary"})," Livre de police"]}),a.buyerIdentity&&e.jsxs("div",{className:"flex justify-between py-1.5 text-sm",children:[e.jsx("span",{className:"text-lab-text-secondary",children:"Acheteur"}),e.jsx("span",{className:"text-lab-text-primary",children:a.buyerIdentity})]}),a.salePaymentMethod&&e.jsxs("div",{className:"flex justify-between py-1.5 text-sm",children:[e.jsx("span",{className:"text-lab-text-secondary",children:"Paiement"}),e.jsx("span",{className:"text-lab-text-primary",children:a.salePaymentMethod})]}),a.buyerIdNumber&&e.jsxs("div",{className:"flex justify-between py-1.5 text-sm",children:[e.jsx("span",{className:"text-lab-text-secondary",children:"Pièce d'identité"}),e.jsx("span",{className:"text-lab-text-primary font-mono",children:a.buyerIdNumber})]})]}),a.shippedDate&&e.jsxs("section",{children:[e.jsxs("p",{className:"text-label-sm text-lab-text-tertiary uppercase tracking-wider mb-1 flex items-center gap-1.5",children:[e.jsx(Ne,{size:13,className:"text-type-grass"})," Expédition"]}),e.jsxs("div",{className:"flex justify-between py-1.5 text-sm",children:[e.jsx("span",{className:"text-lab-text-secondary",children:"Expédié le"}),e.jsx("span",{className:"text-lab-text-primary",children:Lt(a.shippedDate)})]}),a.shippingCarrier&&e.jsxs("div",{className:"flex justify-between py-1.5 text-sm",children:[e.jsx("span",{className:"text-lab-text-secondary",children:"Transporteur"}),e.jsx("span",{className:"text-lab-text-primary",children:a.shippingCarrier})]}),a.trackingNumber&&e.jsxs("div",{className:"flex justify-between py-1.5 text-sm",children:[e.jsx("span",{className:"text-lab-text-secondary",children:"Suivi"}),e.jsx("span",{className:"text-lab-text-primary font-mono truncate max-w-[55%]",children:a.trackingNumber})]})]}),K.length>0&&e.jsxs("section",{className:"rounded-xl bg-accent-danger/8 border border-accent-danger/20 p-3",children:[e.jsxs("p",{className:"text-sm font-medium text-accent-danger flex items-center gap-1.5",children:[e.jsx(qt,{size:14})," à délister (",K.length,")"]}),e.jsxs("p",{className:"text-xs text-lab-text-secondary mt-1",children:["Encore en vente sur : ",K.map(j=>
1j.marketplace).join(", ")]})]})]}),e.jsxs("div",{className:"sticky bottom-0 flex items-center gap-2 px-5 py-4 bg-lab-base border-t border-lab-border-subtle",children:[!a.shippedDate&&e.jsxs("button",{onClick:()=>{z(),y()},className:"btn-secondary flex items-center gap-1.5 px-3",children:[e.jsx(ye,{size:15})," Expédier"]}),e.jsxs("button",{onClick:()=>{b(),y()},className:"btn-primary flex-1 flex items-center justify-center gap-1.5",children:[e.jsx(_e,{size:15})," Voir l'article"]})]})]})]}),document.body)}function Rt(a){if(!a.shippedDate)return{label:"à expédier",color:"accent-warning",icon:"ð¦"};if(a.trackingStatus)switch(a.trackingStatus.status){case"Livré":return{label:"Livré",color:"accent-success",icon:"â
"};case"En livraison":return{label:"En livraison",color:"accent-primary",icon:"ð"};case"En transit":return{label:"En transit",color:"accent-primary",icon:"ð"};case"Pris en charge":return{label:"Pris en charge",color:"accent-primary",icon:"ð"};case"Exception":return{label:"Exception",color:"accent-danger",icon:"â ï¸"};default:return{label:a.trackingStatus.status,color:"accent-success",icon:"â"}}return{label:"Expédié",color:"accent-success",icon:"â"}}const os={red:{borderClass:"border-accent-danger/30",bgClass:"bg-accent-danger/10"},orange:{borderClass:"border-accent-warning/30",bgClass:"bg-accent-warning/10"},green:{borderClass:"border-accent-success/30",bgClass:"bg-accent-success/10"},delivered:{borderClass:"border-emerald-700/50",bgClass:"bg-emerald-700/15"}},Ot={red:{label:"à délister",badgeClass:"bg-accent-danger/15 text-accent-danger"},orange:{label:"à expédier",badgeClass:"bg-accent-warning/15 text-accent-warning"},green:{label:"En transit",badgeClass:"bg-accent-success/15 text-accent-success"},delivered:{label:"Livré",badgeClass:"bg-emerald-700/20 text-emerald-400"}};function Pe(a){var c;const r=(a.crossListingAlerts||[]).filter(x=>!x.removed),o=(x,E)=>({state:x,...os[x],pending:E});if(r.length>0)return o("red",r);if(!a.shippedDate)return o("orange",[]);const m=((c=a.trackingStatus)==null?void 0:c.status)==="Livré";return o(m?"delivered":"green",[])}function It(a){const r=new Date,o=c=>`${c.getFullYear()}-${String(c.getMonth()+1).padStart(2,"0")}-${String(c.getDate()).padStart(2,"0")}`,m=o(r);switch(a){case"week":{const c=new Date(r),x=c.getDay();return c.setDate(c.getDate()-(x===0?6:x-1)),{from:o(c),to:m}}case"month":return{from:`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-01`,to:m};case"lastMonth":{const c=new Date(r.getFullYear(),r.getMonth()-1,1),x=new Date(r.getFullYear(),r.getMonth(),0);return{from:o(c),to:o(x)}}case"year":return{from:`${r.getFullYear()}-01-01`,to:m};case"all":return{from:null,to:null};case"custom":return{from:null,to:null};default:return{from:null,to:null}}}const Vt=[{key:"week",label:"Semaine"},{key:"month",label:"Ce mois"},{key:"lastMonth",label:"M-1"},{key:"year",label:"Année"},{key:"all",label:"Tout"}];function me(a){const r=[];return a.subType?r.push(a.subType):a.type&&r.push(a.type),a.language&&r.push(a.language),a.setName&&r.push(a.setNumber?`${a.setName} ${a.setNumber}`:a.setName),a.gradingCompany&&a.grade&&r.push(`${a.gradingCompany} ${a.grade}`),r.join(" · ")}function ks(){var ct,ot;const a=ba(),r=Ya(),o=r!=="personal",m=r==="micro",c=m?"Cotisations URSSAF":"TVA à reverser",x=m?"Versement libératoire":"IS",E=m?"URSSAF":"TVA",P=m?"Vers. lib.":"IS",y=r==="personal"?"Bénéfice réalisé":"Marge brute",b=xa(),z=Bt(t=>t.user),d=Ut(t=>t.subscription),[u,T]=i.useState(null),$=ma("sales:default"),[w,W]=i.useState(($==null?void 0:$.sales)??[]),{platforms:B,fetchPlatforms:K}=ha(),[A,H]=i.useState($===void 0),[j,g]=i.useState(1),[L,D]=i.useState(($==null?void 0:$.totalPages)??1),[v,F]=i.useState(""),[_,q]=i.useState(null),[O,ue]=i.useState(null),[re,ne]=i.useState(""),[ie,ee]=i.useState(""),h=i.useRef(null),[p,I]=i.useState(""),[C,be]=i.useState({preset:"month",...It("month")}),[Xt,Te]=i.useState(!1),[f,le]=i.useState(We),[He,we]=i.useState(!1),Ae=$t(f),[$e,qe]=i.useState(!1),[De,Ye]=i.useState(!1),[ce,te]=i.useState(null),[oe,Fe]=i.useState(null),[Jt,Qt]=i.useState(($==null?void 0:$.serverTotals)??null),[J,Zt]=i.useState(($==null?void 0:$.total)??0),[ae,ea]=i.useState(null),[ta,aa]=i.useState(!1),ze=async()=>{var t;try{const s=await U.stats({months:6});(t=s.data)!=null&&t.success&&ea(s.data.data)}catch{}};i.useEffect(()=>{K(),ze()},[]),i.useEffect(()=>{const t=new AbortController;return Q(t.signal),()=>t.abort()},[j,v,re,p,C.from,C.to,f.priceMin,f.priceMax,f.margeMin,f.margeMax,f.sort]);const Xe=t=>{ee(t),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{ne(t),g(1)},400)},Q=async t=>{H(!0);try{const s=await U.list({page:j,limit:20,platformId:v?parseInt(v):void 0,search:re.trim()||void 0,shipped:p==="shipped"?"true":p==="pending"?"false":void 0,todo:p==="todo"?"true":void 0,dateFrom:C.from||void 0,dateTo:C.to||void 0,priceMin:f.priceMin?parseFloat(f.priceMin):void 0,priceMax:f.priceMax?parseFloat(f.priceMax):void 0,margeMin:f.margeMin?parseFloat(f.margeMin):void 0,margeMax:f.margeMax?parseFloat(f.margeMax):void 0,sort:f.sort!=="date"?f.sort:void 0},t);s.data.success&&(W(s.data.data.items),D(s.data.data.totalPages),Zt(s.data.data.total??0),s.data.data.aggregates&&(Qt(s.data.data.aggregates),aa(!!s.data.data.aggregates.versementLiberatoire)),j===1&&!v&&!re&&!p&&C.preset==="month"&&$t(f)===0&&pa("sales:default",{sales:s.data.data.items,totalPages:s.data.data.totalPages,total:s.data.data.total,serverTotals:s.data.data.aggregates??null}))}catch(s){if((s==null?void 0:s.name)==="CanceledError"||(s==null?void 0:s.code)==="ERR_CANCELED")return;console.error("Error loading sales:",s),b.addToast("Impossible de charger les ventes â vérifiez votre connexion","error")}finally{t!=null&&t.aborted||H(!1)}},Je=i.useRef(()=>{Q(),ze()});Je.current=()=>{Q(),ze()},i.useEffect(()=>{const t=()=>{Je.current()};return window.addEventListener("pull-to-refresh",t),()=>window.removeEventListener("pull-to-refresh",t)},[]);const Qe=t=>{q({action:"deleteSale",data:{id:t}})},Ze=async(t,s)=>{try{await U.removeCrossListing(t,s),W(n=>n.map(l=>l.id===t?{...l,crossListingAlerts:(l.crossListingAlerts||[]).map(N=>N.marketplace===s?{...N,removed:!0}:N)}:l))}catch(n){console.error("removeCrossListing",n),b.addToast("Ãchec du retrait de l'annonce â réessayez","error")}},sa=async t=>{var s,n,l,N,k;T(t.id);try{const G=(((s=(await Ve.get(`/marketplace/listings/item/${t.item.id}`)).data)==null?void 0:s.data)||[]).find(M=>M.marketplace==="ebay"&&M.status==="active");if(G){const M=await Ve.delete(`/marketplace/listings/${G.id}`);if(!((n=M.data)!=null&&n.success)){b.addToast(((l=M.data)==null?void 0:l.error)||"Erreur eBay","error");return}}await Ze(t.id,"eBay"),b.addToast("Annonce eBay retirée","success")}catch(R){b.addToast(`Erreur eBay : ${((k=(N=R.response)==null?void 0:N.data)==null?void 0:k.error)||R.message||"échec"}`,"error")}finally{T(null)}},et=(t,s)=>{const n=s.marketplace.toLowerCase(),l=n==="vinted"?(z==null?void 0:z.vintedProfileUrl)||"https://www.vinted.fr":ga(n,s.url,t.item.name);return e.jsxs("div",{className:`flex items-center ${ge?"gap-3":"gap-2"} px-2.5 py-1 rounded-lg bg-lab-elevated border border-accent-danger/20 text-[12px]`,children:[e.jsx("span",{className:"font-medium text-lab-text-primary",children:s.marketplace}),s.price!=null&&e.jsxs("span",{className:"text-lab-text-tertiary font-mono",children:[s.price.toFixed(2)," â¬"]}),n==="ebay"?e.jsx("button",{onClick:()=>sa(t),disabled:u===t.id,className:`${ge?"min-h-[36px] px-3 rounded-lg active:bg-accent-danger/25":"px-2 py-0.5 rounded-md hover:bg-accent-danger/25"} bg-accent-danger/15 text-accent-danger font-medium disabled:opacity-50 transition-colors`,title:"Termine l'annonce sur eBay via l'API",children:u===t.id?"â¦":"Retirer via API"}):e.jsxs(e.Fragment,{children:[e.jsxs("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:`text-accent-primary hover:underline flex items-center gap-0.5 ${ge?"min-h-[36px] px-1":""}`,children:[n==="vinted"?"Profil Vinted":"Ouvrir"," ",e.jsx(Me,{size:10})]}),e.jsx("button",{onClick:()=>Ze(t.id,s.marketplace),className:`${ge?"min-h-[36px] px-3 rounded-lg active:bg-accent-success/25":"px-2 py-0.5 rounded-md hover:bg-accent-success/25"} bg-accent-success/15 text-accent-success font-medium transition-colors`,children:"â Retirée"})]})]},s.marketplace)},tt=async t=>{try{const{data:s}=await U.refreshTracking(t);W(n=>n.map(l=>l.id===t?{...l,trackingStatus:s.trackingStatus,shippingCarrier:s.shippingCarrier||l.shippingCarrier}:l))}catch{}},at=async()=>{var t,s,n,l,N;Ye(!0);try{const R=(await Ve.post("/marketplace/sync-orders",{},{timeout:12e4})).data;if(R.success){const G=((t=R.data)==null?void 0:t.ebayProcessed)||0,M=((s=R.data)==null?void 0:s.ebaySkipped)||0;b.addToast(G>0?`â ${G} vente(s) eBay importée(s)${M?` (${M} déjà traitée(s))`:""}`:R.message||"Aucune nouvelle vente eBay à importer","success"),await Q()}else b.addToast("Erreur : "+(R.error||"synchronisation"),"error")}catch(k){const R=(n=k==null?void 0:k.response)==null?void 0:n.status;b.addToast(R===403?"Abonnement Pro requis pour synchroniser les commandes eBay":R===401?"Session expirée â reconnectez-vous":((N=(l=k==null?void 0:k.response)==null?void 0:l.data)==null?void 0:N.error)||"Erreur de synchronisation","error")}finally{Ye(!1)}},st=async()=>{var t,s;qe(!0);try{const{data:n}=await U.refreshAllTracking(),l=n==null?void 0:n.data;if(await Q(),l)if(l.refreshed===0)b.addToast("Aucune commande expédiée non livrée à actualiser","info");else{let N=`â
Suivi actualisé : ${l.updated} mis à jour sur ${l.refreshed} commandes`;l.errors&&(N+=` (${l.errors} erreurs)`),b.addToast(N,l.errors?"warning":"success")}}catch(n){b.addToast(`Erreur : ${((s=(t=n==null?void 0:n.response)==null?void 0:t.data)==null?void 0:s.error)||(n==null?void 0:n.message)||"Erreur inconnue"}`,"error")}finally{qe(!1)}},Le=t=>{if(t==="custom")Te(!0),be({preset:"custom",from:C.from,to:C.to});else{Te(!1);
1const s=It(t);be({preset:t,...s}),g(1)}},Y=t=>{I(t),g(1)},V=t=>new Intl.NumberFormat("fr-FR",{style:"currency",currency:"EUR"}).format(t),de=t=>new Intl.NumberFormat("fr-FR",{style:"currency",currency:"EUR",minimumFractionDigits:0,maximumFractionDigits:0}).format(t),ra=t=>{const s=new Date(t),l=Math.floor((new Date().getTime()-s.getTime())/(1e3*60*60*24));return l===0?"Aujourd'hui":l===1?"Hier":l<7?`Il y a ${l}j`:s.toLocaleDateString("fr-FR",{day:"numeric",month:"short"})},S=Jt??w.reduce((t,s)=>({ca:t.ca+s.saleTotalClientEur,marge:t.marge+(s.computedCashNetOperationalEur-s.item.costTotalPurchaseEur),achat:t.achat+s.item.costTotalPurchaseEur,tva:t.tva+(s.fiscalTvaEur??s.computedTvaReverserEur),virement:t.virement+(s.fiscalVirementEur??s.computedVirementPrudentEur)}),{ca:0,marge:0,achat:0,tva:0,virement:0}),xe=i.useMemo(()=>w.filter(t=>!t.shippedDate).length,[w]),rt=J>0?S.ca/J:0,ke=r==="sasu"||m&&ta,Re=[{label:"CA total",value:S.ca,icon:Ta,color:"primary"},{label:y,value:S.marge,icon:je,color:"grass"},{label:"Panier moyen",value:rt,icon:Ht,color:"water"},...o?[{label:c,value:S.tva,icon:Aa,color:"fire"}]:[],...ke?[{label:x,value:S.virement,icon:m?$a:Da,color:"psychic"}]:[]],na={primary:{bg:"bg-accent-primary/10",border:"border-accent-primary/20",text:"text-accent-primary",icon:"text-accent-primary"},grass:{bg:"bg-type-grass/10",border:"border-type-grass/20",text:"text-type-grass",icon:"text-type-grass"},fire:{bg:"bg-type-fire/10",border:"border-type-fire/20",text:"text-type-fire",icon:"text-type-fire"},psychic:{bg:"bg-type-psychic/10",border:"border-type-psychic/20",text:"text-type-psychic",icon:"text-type-psychic"},water:{bg:"bg-type-water/10",border:"border-type-water/20",text:"text-type-water",icon:"text-type-water"}},he=t=>`h-8 px-2.5 rounded-md text-[12px] transition-colors whitespace-nowrap ${t?"bg-lab-subtle text-lab-text-primary font-semibold":"text-lab-text-tertiary hover:text-lab-text-secondary font-medium"}`,Oe=r==="personal"?"Bénéfice":"Marge",ia={date:"Date",achat:"Achat",price:"Vente",marge:Oe},se=(t=>{const s=t.endsWith("_asc");return{dim:s?t.slice(0,-4):t,asc:s}})(f.sort||"date"),la=t=>{let s;se.dim!==t?s=t:se.asc?s="date":s=`${t}_asc`,le({...f,sort:s}),g(1)},Ce=(t,s)=>{const n=se.dim===t,l=n?se.asc?Ra:Oa:Ia;return e.jsxs("button",{onClick:()=>la(t),title:`Trier par ${s}`,className:`inline-flex items-center gap-1 uppercase tracking-wider text-[10px] font-semibold transition-colors ${n?"text-accent-primary":"text-lab-text-tertiary hover:text-lab-text-secondary"}`,children:[s,e.jsx(l,{size:12,className:n?"":"opacity-40"})]})},ca=t=>{const s=t.computedCashNetOperationalEur-t.item.costTotalPurchaseEur,n=t.item.costTotalPurchaseEur,l=n>0?s/n*100:null;return{marge:s,pct:l,positive:s>=0}},nt=(ct=B.find(t=>String(t.id)===v))==null?void 0:ct.name,X=[];re.trim()&&X.push({key:"search",label:`Recherche « ${re.trim()} »`,onClear:()=>{ee(""),ne(""),g(1)}}),v&&nt&&X.push({key:"plat",label:nt,onClear:()=>{F(""),g(1)}}),p==="todo"&&X.push({key:"ship",label:"Articles à gérer",accent:!0,onClear:()=>Y("")}),p==="pending"&&X.push({key:"ship",label:"à expédier",onClear:()=>Y("")}),p==="shipped"&&X.push({key:"ship",label:"Expédiées",onClear:()=>Y("")}),(f.priceMin||f.priceMax)&&X.push({key:"price",label:`Vente ${f.priceMin||"0"}â${f.priceMax||"â"} â¬`,accent:!0,onClear:()=>{le({...f,priceMin:"",priceMax:""}),g(1)}}),(f.margeMin||f.margeMax)&&X.push({key:"marge",label:`${y} ${f.margeMin||"ââ"}â${f.margeMax||"â"} â¬`,accent:!0,onClear:()=>{le({...f,margeMin:"",margeMax:""}),g(1)}}),(se.dim!=="date"||se.asc)&&X.push({key:"sort",label:`Tri : ${ia[se.dim]} ${se.asc?"â":"â"}`,accent:!0,onClear:()=>{le({...f,sort:"date"}),g(1)}});const oa=()=>{ee(""),ne(""),F(""),I(""),le(We),g(1)},it=(t,s="w-10",n="h-[54px]")=>e.jsxs("div",{className:`relative ${s} ${n} rounded-md overflow-hidden bg-lab-subtle border border-lab-border-default flex items-center justify-center shrink-0`,children:[e.jsx(Va,{size:15,className:"text-lab-text-tertiary/40"}),t.item.imageUrl&&e.jsx("img",{src:t.item.imageUrl,alt:"",loading:"lazy",onError:l=>{l.currentTarget.style.display="none"},className:"absolute inset-0 w-full h-full object-cover"})]}),lt=oe?e.jsx(cs,{sale:oe,businessType:r,fiscalLabel1:c,fiscalLabel2:x,showSlot2:ke,margeLabel:y,stateLabel:Ot[Pe(oe).state].label,stateBadgeClass:Ot[Pe(oe).state].badgeClass,onClose:()=>Fe(null),onViewItem:()=>a(`/inventory/${oe.item.id}`),onShip:()=>te(oe)}):null,Se=(d==null?void 0:d.tier)==="free";return ge?e.jsxs("div",{className:"-mx-4 -mt-1 animate-in",children:[e.jsx("div",{className:"px-4 pt-2",children:e.jsx(ht,{salesCount:w.length})}),e.jsx("div",{className:"px-4 pt-1 pb-3",children:e.jsxs("div",{className:"rounded-2xl border border-white/[0.06] bg-lab-elevated/70 px-4 pb-3 pt-2.5",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsxs("span",{className:"truncate text-[10.5px] uppercase tracking-[0.14em]",style:{fontFamily:"'Fraunces', Georgia, serif",color:"var(--dash-gold)"},children:["Chiffre d'affaires · ",C.preset==="custom"?"Période perso.":((ot=Vt.find(t=>t.key===C.preset))==null?void 0:ot.label)??"Période"]}),J>0&&e.jsxs("span",{className:"shrink-0 text-[11px] tabular-nums text-lab-text-tertiary",children:[J.toLocaleStr
1ing("fr-FR")," vente",J>1?"s":""]})]}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-baseline gap-x-2",children:[e.jsx("span",{className:"font-mono text-[26px] font-bold leading-tight tabular-nums text-lab-text-primary",children:de(S.ca)}),e.jsxs("span",{className:`font-mono text-[12px] tabular-nums ${S.marge>=0?"text-type-grass":"text-accent-danger"}`,children:[S.marge>=0?"+":"",de(S.marge)," de ",r==="personal"?"bénéfice":"marge"]})]}),e.jsx("div",{className:"my-2.5 h-px bg-white/[0.06]"}),e.jsxs("div",{className:"flex items-center gap-4 overflow-x-auto scrollbar-hide",children:[e.jsxs("div",{className:"shrink-0",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.08em] text-lab-text-tertiary",children:"Panier moyen"}),e.jsx("p",{className:"mt-px font-mono text-[14px] font-semibold tabular-nums text-lab-text-primary",children:de(rt)})]}),o&&e.jsxs("div",{className:"shrink-0",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.08em] text-lab-text-tertiary",children:E}),e.jsx("p",{className:"mt-px font-mono text-[14px] font-semibold tabular-nums text-lab-text-primary",children:de(S.tva)})]}),ke&&e.jsxs("div",{className:"shrink-0",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.08em] text-lab-text-tertiary",children:P}),e.jsx("p",{className:"mt-px font-mono text-[14px] font-semibold tabular-nums text-lab-text-primary",children:de(S.virement)})]}),xe>0&&e.jsxs("button",{type:"button",onClick:()=>Y(p==="pending"?"":"pending"),"aria-pressed":p==="pending",className:`relative ml-auto flex shrink-0 items-center gap-1 rounded-full border px-3 py-1.5 text-[11.5px] font-semibold transition-colors after:absolute after:inset-[-8px] after:content-[''] ${p==="pending"?"border-accent-warning/60 bg-accent-warning/25 text-accent-warning":"border-accent-warning/25 bg-accent-warning/10 text-accent-warning"}`,children:[xe," à expédier",e.jsx(Be,{size:12,"aria-hidden":!0})]})]})]})}),ae&&e.jsx("div",{className:"px-4 pb-1",children:e.jsx(At,{monthly:ae.monthly,byPlatform:ae.byPlatform,topProducts:ae.topProducts,businessType:r,isMobile:!0})}),e.jsx("div",{className:"px-4 pb-2.5",children:e.jsxs("div",{className:"relative",children:[e.jsx(ft,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-lab-text-tertiary/60"}),e.jsx("input",{type:"text",value:ie,onChange:t=>Xe(t.target.value),onKeyDown:pt,placeholder:"Rechercher un article venduâ¦",enterKeyHint:"search",autoComplete:"off",className:"w-full pl-9 pr-9 py-2.5 rounded-xl bg-white/[0.05] border border-white/[0.06] text-[14px] text-lab-text-primary placeholder:text-lab-text-tertiary/40 focus:outline-none focus:border-accent-primary/30 focus:bg-white/[0.07] transition-all"}),ie&&e.jsx("button",{onClick:()=>{ee(""),ne(""),g(1)},className:"absolute right-2.5 top-1/2 -translate-y-1/2 w-5 h-5 rounded-full bg-white/[0.1] flex items-center justify-center active:bg-white/[0.15]",children:e.jsx(ve,{size:12,className:"text-lab-text-tertiary"})})]})}),e.jsx("div",{className:"px-4 pb-3",children:e.jsx(is,{dateRange:C,onDatePreset:Le,onCustomRange:(t,s)=>{Te(!1),be({preset:"custom",from:t,to:s}),g(1)},shippingFilter:p,onShippingChange:Y,platformFilter:v,onPlatformChange:t=>{F(t),g(1)},platforms:B,advCount:Ae,onOpenAdvanced:()=>we(!0),onRefreshTracking:Se?void 0:st,refreshingTracking:$e,onSyncEbay:Se?void 0:at,syncingEbay:De})}),A&&w.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full border-2 border-accent-primary/30 border-t-accent-primary animate-spin"}),e.jsx("p",{className:"text-sm text-lab-text-tertiary",children:"Chargement..."})]}):w.length===0?e.jsx("div",{className:"px-4",children:e.jsx(bt,{type:"sales",title:v||p?"Aucune vente":"Aucune vente enregistrée",description:p==="pending"?"Toutes les ventes sont expédiées !":p==="shipped"?"Aucune vente expédiée sur cette période.":v?"Aucune vente sur cette plateforme.":"Vendez vos premiers articles pour voir vos statistiques ici.",action:v||p?{label:"Voir toutes",onClick:()=>{F(""),I(""),g(1)}}:{label:"Voir l'inventaire",onClick:()=>a("/inventory")}})}):e.jsx("div",{className:`px-4 space-y-2 transition-opacity ${A?"opacity-60 pointer-events-none":""}`,children:w.map((t,s)=>{var xt,mt;const n=t.computedCashNetOperationalEur-t.item.costTotalPurchaseEur,l=n>=0,N=t.item.costTotalPurchaseEur>0?n/t.item.costTotalPurchaseEur*100:null,k=O===t.id,R=!!t.shippedDate,G=t.trackingNumber?Ge(t.shippingCarrier,t.trackingNumber,t.buyerPostalCode):null,M=Rt(t),dt=Pe(t);return e.jsxs("div",{className:`rounded-2xl border overflow-hidden transition-all border-l-4 ${dt.borderClass} ${dt.bgClass}`,style:{animationDelay:`${s*30}ms`},children:[e.jsxs("button",{onClick:()=>ue(k?null:t.id),className:"w-full flex items-center gap-3 px-4 py-3.5 text-left active:bg-white/[0.02] transition-colors",children:[it(t,"w-11","h-14"),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[15px] font-medium text-lab-text-primary truncate",children:t.item.name}),(me(t.item)||t.item.collectionCardKey)&&e.jsxs("p",{className:"text-[11px] text-lab-text-tertiary truncate mt-0.5 flex items-center gap-1.5",children:[me(t.item)&&e.jsx("span",{className:"truncate",children:me(t.item)}),t.item.collectionCardKey&&e.jsx("span",{className:"shrink-0 inline-flex items-center h-[15p
1x] px-1.5 rounded bg-white/[0.06] text-[10px] font-semibold text-lab-text-secondary",children:"Collection"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx("span",{className:"text-[12px] text-lab-text-tertiary",children:ra(t.saleDate)}),((xt=t.salePlatform)==null?void 0:xt.name)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-lab-text-tertiary/30",children:"·"}),e.jsx("span",{className:"text-[12px] text-lab-text-tertiary",children:t.salePlatform.name})]}),e.jsx("span",{className:"text-lab-text-tertiary/30",children:"·"}),e.jsxs("span",{className:`text-[11px] font-medium text-${M.color} flex items-center gap-0.5`,children:[M.icon," ",M.label]}),t.crossListingAlerts&&t.crossListingAlerts.some(Z=>!Z.removed)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-lab-text-tertiary/30",children:"·"}),e.jsxs("span",{className:"text-[11px] font-medium text-accent-danger flex items-center gap-0.5",children:["â ï¸ ",t.crossListingAlerts.filter(Z=>!Z.removed).map(Z=>Z.marketplace).join(", ")]})]})]})]}),e.jsxs("div",{className:"text-right flex-shrink-0",children:[e.jsx("p",{className:"text-[16px] font-semibold font-mono text-lab-text-primary",children:V(t.saleTotalClientEur)}),e.jsxs("p",{className:`text-[12px] font-mono font-medium ${l?"text-accent-success":"text-accent-danger"}`,children:[n>0?"+":"",V(n),e.jsx("span",{className:"text-[10px] opacity-80 ml-1",children:N===null?"· â":`· ${N>0?"+":""}${Math.round(N)} %`})]})]})]}),k&&e.jsxs("div",{className:"border-t border-white/[0.04] animate-in",children:[e.jsxs("div",{className:"px-4 py-3 grid grid-cols-2 gap-y-2.5 gap-x-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-lab-text-tertiary uppercase tracking-wider",children:"Coût achat"}),e.jsx("p",{className:"text-[14px] font-mono text-lab-text-secondary",children:V(t.item.costTotalPurchaseEur)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-lab-text-tertiary uppercase tracking-wider",children:"Frais plateforme"}),e.jsx("p",{className:"text-[14px] font-mono text-lab-text-secondary",children:V(t.platformFeesEur)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-lab-text-tertiary uppercase tracking-wider",children:"Frais envoi"}),e.jsx("p",{className:"text-[14px] font-mono text-lab-text-secondary",children:V(t.realShippingCostEur)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-lab-text-tertiary uppercase tracking-wider",children:y}),e.jsxs("p",{className:`text-[14px] font-mono font-semibold ${l?"text-accent-success":"text-accent-danger"}`,children:[n>0?"+":"",V(n),e.jsx("span",{className:"text-[11px] opacity-80 ml-1",children:N===null?"· â":`· ${N>0?"+":""}${Math.round(N)} %`})]})]}),o&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-lab-text-tertiary uppercase tracking-wider",children:c}),e.jsx("p",{className:"text-[14px] font-mono text-type-fire",children:V(t.fiscalTvaEur??t.computedTvaReverserEur)})]}),ke&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-lab-text-tertiary uppercase tracking-wider",children:x}),e.jsx("p",{className:"text-[14px] font-mono text-type-psychic font-semibold",children:V(t.fiscalVirementEur??t.computedVirementPrudentEur)})]})]}),e.jsx("div",{className:"px-4 pb-3",children:R?e.jsxs("div",{className:`p-3 rounded-xl bg-${M.color}/5 border border-${M.color}/15 space-y-1.5`,children:[e.jsxs("div",{className:`flex items-center gap-2 text-${M.color} text-[13px] font-medium`,children:[e.jsx("span",{children:M.icon}),M.label," â ",new Date(t.shippedDate).toLocaleDateString("fr-FR"),t.shippingCarrier&&e.jsxs("span",{className:"text-lab-text-tertiary",children:["· ",t.shippingCarrier]})]}),((mt=t.trackingStatus)==null?void 0:mt.description)&&e.jsx("p",{className:"text-[12px] text-lab-text-secondary",children:t.trackingStatus.description}),t.trackingNumber&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[12px] text-lab-text-tertiary font-mono",children:t.trackingNumber}),G&&e.jsxs("a",{href:G,target:"_blank",rel:"noopener noreferrer",className:"text-[12px] text-accent-primary flex items-center gap-0.5",children:["Suivre ",e.jsx(Me,{size:10})]}),e.jsx("button",{onClick:()=>tt(t.id),className:"text-[12px] text-lab-text-tertiary hover:text-accent-primary flex items-center gap-0.5 transition-colors",children:e.jsx(pe,{size:10})})]}),e.jsx("button",{onClick:()=>te(t),className:"text-[12px] text-lab-text-tertiary hover:text-accent-primary transition-colors",children:"Modifier l'expédition"})]}):e.jsxs("button",{onClick:()=>te(t),className:"w-full p-3 rounded-xl bg-accent-warning/8 border border-accent-warning/15 flex items-center justify-center gap-2 text-[13px] font-medium text-accent-warning active:bg-accent-warning/12 transition-colors",children:[e.jsx(ye,{size:15})," Expédier cet article"]})}),(()=>{const Z=(t.crossListingAlerts||[]).filter(Ie=>!Ie.removed);return Z.length===0?null:e.jsx("div",{className:"px-4 pb-3",children:e.jsxs("div",{className:"p-3 rounded-xl bg-accent-danger/8 border border-accent-danger/15 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-accent-danger text-[13px] font-medium",children:[e.jsx("span",{children:"â ï¸"})," à retirer (",Z.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Z.map(Ie=>et(t,Ie))})]})})})(),e.jsx("div",{className:"px-4 pb-2",children:e.jsx("p",{className:"text-[12px] text-lab-text-tertiary",children:new Date(t.saleDate).toLocaleDateString("fr-FR",{weekday:"long",day:"numeric",month:"long",year:"numeric"})})}),e.jsxs("div",{className:"flex border-t border-white/[0.04]",children:[e.jsxs("button",{onClick:()=>Fe(t),className:"flex-1 flex items-center justify-center gap-2 py-3 text-[13px] font-medium text-lab-text-secondary active:bg-white/[0.04] transition-colors",children:[e.jsx(yt,{size:15})," Détails"]}
1),e.jsx("div",{className:"w-px bg-white/[0.04]"}),e.jsxs("button",{onClick:()=>a(`/inventory/${t.item.id}`),className:"flex-1 flex items-center justify-center gap-2 py-3 text-[13px] font-medium text-accent-primary active:bg-accent-primary/5 transition-colors",children:[e.jsx(_e,{size:15})," Voir l'article"]}),e.jsx("div",{className:"w-px bg-white/[0.04]"}),e.jsxs("button",{onClick:()=>Qe(t.id),className:"flex-1 flex items-center justify-center gap-2 py-3 text-[13px] font-medium text-accent-danger active:bg-accent-danger/5 transition-colors",children:[e.jsx(jt,{size:15})," Annuler"]})]})]})]},t.id)})}),L>1&&e.jsxs("div",{className:"flex items-center justify-between px-4 py-4 mt-2",children:[e.jsxs("p",{className:"text-[13px] text-lab-text-tertiary",children:["Page ",j," / ",L]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>g(t=>Math.max(1,t-1)),disabled:j===1,className:"w-9 h-9 rounded-xl bg-lab-elevated/60 border border-white/[0.04] flex items-center justify-center disabled:opacity-30 active:bg-white/[0.06] transition-colors",children:e.jsx(vt,{size:18,className:"text-lab-text-secondary"})}),e.jsx("button",{onClick:()=>g(t=>Math.min(L,t+1)),disabled:j===L,className:"w-9 h-9 rounded-xl bg-lab-elevated/60 border border-white/[0.04] flex items-center justify-center disabled:opacity-30 active:bg-white/[0.06] transition-colors",children:e.jsx(Be,{size:18,className:"text-lab-text-secondary"})})]})]}),ce&&e.jsx(St,{sale:ce,isOpen:!!ce,onClose:()=>te(null),onSaved:Q}),e.jsx(ut,{isOpen:!!_,onCancel:()=>q(null),onConfirm:async()=>{if(!_)return;const{action:t,data:s}=_;q(null);try{t==="deleteSale"&&(await U.delete(s.id),Q())}catch(n){console.error("Error:",n),b.addToast("Ãchec de l'annulation de la vente â réessayez","error")}},title:"Annuler cette vente",message:"Ãtes-vous sûr ? L'article repassera en stock.",confirmLabel:"Oui, annuler la vente",variant:"warning"}),e.jsx(Dt,{open:He,value:f,marginLabel:r==="personal"?"Bénéfice":"Marge",isMobile:!0,onApply:t=>{le(t),g(1)},onClose:()=>we(!1)}),lt]}):e.jsxs("div",{className:"space-y-6 animate-in",children:[e.jsx(ht,{salesCount:w.length}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-display-lg font-display text-lab-text-primary mb-1",children:"Ventes"}),e.jsx("p",{className:"text-lab-text-secondary",children:o?"Gérez vos ventes, expéditions et suivi":"Gérez vos ventes et expéditions"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[xe>0&&e.jsxs("button",{onClick:()=>Y(p==="pending"?"":"pending"),className:"flex items-center gap-2 px-4 py-2 rounded-xl bg-accent-warning/10 border border-accent-warning/20 text-accent-warning text-sm font-medium hover:bg-accent-warning/15 transition-colors",children:[e.jsx(Ne,{size:16}),xe," à expédier"]}),!Se&&e.jsxs("button",{onClick:at,disabled:De,title:"Importe les commandes eBay récentes en ventes (eBay uniquement)",className:"flex items-center gap-2 px-4 py-2 rounded-xl bg-lab-surface border border-lab-border-subtle text-lab-text-secondary text-sm font-medium hover:border-lab-border-hover transition-colors disabled:opacity-50",children:[e.jsx(pe,{size:16,className:De?"animate-spin":""}),"Synchroniser eBay"]})]})]}),e.jsx("div",{className:`grid grid-cols-2 sm:grid-cols-3 ${Re.length>=5?"lg:grid-cols-5":Re.length===4?"lg:grid-cols-4":"lg:grid-cols-3"} gap-4 stagger-children`,children:Re.map((t,s)=>{const n=na[t.color];return e.jsx("div",{className:`relative overflow-hidden rounded-xl ${n.bg} border ${n.border} p-5`,style:{animationDelay:`${s*50}ms`},children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-lg ${n.bg}`,children:e.jsx(t.icon,{size:20,strokeWidth:1.5,className:n.icon})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-label-sm text-lab-text-tertiary",children:t.label}),e.jsx("p",{className:`font-mono text-xl font-semibold ${n.text}`,children:V(t.value)})]})]})},t.label)})}),ae&&e.jsx(At,{monthly:ae.monthly,byPlatform:ae.byPlatform,topProducts:ae.topProducts,businessType:r}),e.jsxs("div",{className:"sticky top-0 z-30 rounded-xl border border-lab-border-subtle bg-lab-elevated p-2",style:{boxShadow:"inset 0 1px 0 rgba(255,255,255,0.03), 0 8px 24px -18px rgba(0,0,0,0.8)"},children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("div",{className:"flex-1 min-w-[220px] flex items-center gap-2 h-[38px] px-3 rounded-lg bg-lab-surface border border-lab-border-subtle focus-within:border-accent-primary/40 transition-colors",children:[e.jsx(ft,{size:15,className:"shrink-0 text-lab-text-tertiary"}),e.jsx("input",{type:"text",value:ie,onChange:t=>Xe(t.target.value),onKeyDown:pt,placeholder:"Rechercher un article vendu, une plateformeâ¦",enterKeyHint:"search",autoComplete:"off",className:"flex-1 min-w-0 bg-transparent border-0 outline-none text-sm text-lab-text-primary placeholder:text-lab-text-tertiary/50"}),ie&&e.jsx("button",{onClick:()=>{ee(""),ne(""),g(1)},className:"shrink-0 w-[18px] h-[18px] rounded-full bg-lab-muted flex items-center justify-center text-lab-text-tertiary hover:text-lab-text-primary transition-colors","aria-label":"Effacer la recherche",children:e.jsx(ve,{size:11})})]}),e.jsxs("div",{className:"shrink-0 flex items-center h-[38px] p-[3px] gap-0.5 rounded-lg bg-lab-surface border border-lab-border-subtle",children:[Vt.map(t=>e.jsx("button",{onClick:()=>Le(t.key),className:he(C.preset===t.key),children:t.label},t.key)),e.jsx("button",{onClick:()=>Le("custom"),title:"Période personnalisée",className:`h-8 w-8 flex items-center justify-center rounded-md transition-colors ${C.preset==="custom"?"bg-lab-subtle text-lab-text-primary":"text-lab-text-tertiary hover:text-lab-text-secondary"}`,children:e.jsx(Fa,{size:14})})]}),e.jsxs("div",{className:"shrink-0 flex items-center h-[38px] p-[3px] gap-0.5 rounded-lg bg-lab-surface border border-lab-border-subtle",children:[e.jsx("button",{onClick:()=>Y(""),className:he(p===""),children:"Toutes"}),e.jsxs("button",{onClick:()=>Y("todo"),className:`${he(p==="todo")} inline-flex items-center gap-1.5`,title:"Articles à gérer : à expédier ou annonce à retirer",children:[e.jsx(za,{size:13})," à gérer"]}),e.jsxs("button",{onClick:()=>Y("pending"),className:`${he(p==="pending")} inline-flex items-center gap-1.5`,children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-warning"})," à expédier",xe>0&&e.jsx("span",{className:"font-mono text-[10px] text-accent-warning bg-accent-warning/15 rounded px-1",children:xe})]}),e.jsx("button",{onClick:()=>Y("shipped"),className:he(p==="shipped"),children:"Expédiées"})]}),e.jsxs("div",{className:"shrink-0 relative h-[38px]",children:[e.jsxs("select",{className:"appearance-none h-[38px] rounded-lg bg-lab-surface border border-lab-border-subtle text-xs font-medium text-lab-text-primary pl-3 pr-8 outline-none cursor-pointer focus:border-accent-primary/40",value:v,onCh
1ange:t=>{F(t.target.value),g(1)},children:[e.jsx("option",{value:"",children:"Toutes plateformes"}),(()=>{const t=["ebay","cardmarket","vinted"];return B.filter(n=>n.name.toLowerCase().trim()!=="cardmarket (auto)").sort((n,l)=>{const N=t.indexOf(n.name.toLowerCase().trim()),k=t.indexOf(l.name.toLowerCase().trim());return(N===-1?999:N)-(k===-1?999:k)})})().map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]}),e.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"absolute right-2.5 top-1/2 -translate-y-1/2 pointer-events-none text-lab-text-tertiary",children:e.jsx("path",{d:"m6 9 6 6 6-6"})})]}),e.jsxs("button",{onClick:()=>we(!0),className:"shrink-0 inline-flex items-center gap-2 h-[38px] px-3 rounded-lg bg-accent-primary/12 border border-accent-primary/35 text-accent-light text-xs font-semibold hover:bg-accent-primary/18 transition-colors",children:[e.jsx(La,{size:15})," Filtres",Ae>0&&e.jsx("span",{className:"font-mono text-[10px] font-bold text-white bg-accent-primary rounded-full min-w-[17px] h-[17px] px-1 inline-flex items-center justify-center",children:Ae})]}),!Se&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"shrink-0 w-px h-[22px] bg-lab-border-default"}),e.jsx("button",{onClick:st,disabled:$e,title:"Actualiser tous les suivis de colis non livrés",className:"shrink-0 flex items-center justify-center w-[38px] h-[38px] rounded-lg bg-lab-surface border border-lab-border-subtle text-lab-text-secondary hover:text-lab-text-primary hover:border-lab-border-hover transition-colors disabled:opacity-50",children:e.jsx(pe,{size:16,className:$e?"animate-spin":""})})]})]}),Xt&&e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx("input",{type:"date",className:"input py-1.5 text-sm",value:C.from||"",onChange:t=>{be({...C,from:t.target.value}),g(1)}}),e.jsx("span",{className:"text-lab-text-tertiary text-sm",children:"â"}),e.jsx("input",{type:"date",className:"input py-1.5 text-sm",value:C.to||"",onChange:t=>{be({...C,to:t.target.value}),g(1)}})]}),X.length>0&&e.jsxs("div",{className:"flex items-center gap-1.5 mt-2.5 pt-2.5 border-t border-lab-border-subtle flex-wrap",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider text-lab-text-tertiary",children:"Filtres actifs"}),X.map(t=>e.jsxs("span",{className:`inline-flex items-center gap-1.5 h-[26px] pl-2.5 pr-1.5 rounded-lg text-[11.5px] border ${t.accent?"bg-accent-primary/10 border-accent-primary/28 text-accent-light":"bg-lab-subtle border-lab-border-subtle text-lab-text-primary"}`,children:[t.label,e.jsx("button",{onClick:t.onClear,className:"w-4 h-4 rounded flex items-center justify-center text-lab-text-tertiary hover:text-lab-text-primary hover:bg-white/10 transition-colors","aria-label":`Retirer ${t.label}`,children:e.jsx(ve,{size:10})})]},t.key)),e.jsxs("button",{onClick:oa,className:"ml-0.5 inline-flex items-center gap-1 h-[26px] px-2 rounded-lg text-[11.5px] font-semibold text-lab-text-tertiary hover:text-lab-text-primary transition-colors",children:[e.jsx(Ke,{size:12})," Tout réinitialiser"]}),e.jsxs("span",{className:"ml-auto font-mono text-[11px] text-lab-text-tertiary hidden md:inline",children:[J," vente",J>1?"s":""," · ",e.jsx("span",{className:"text-lab-text-primary",children:de(S.ca)})," CA"]})]})]}),e.jsxs("div",{className:"card overflow-hidden p-0",children:[A&&w.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-64 gap-4",children:[e.jsx("div",{className:"spinner spinner-lg"}),e.jsx("p",{className:"text-lab-text-tertiary",children:"Chargement..."})]}):w.length===0?e.jsx(bt,{type:"sales",title:v||p?"Aucune vente trouvée":"Aucune vente enregistrée",description:p==="pending"?"Toutes les ventes sont expédiées sur cette période !":p==="shipped"?"Aucune vente expédiée sur cette période.":v?"Aucune vente sur cette plateforme pour la période sélectionnée.":"Vendez vos premiers articles depuis l'inventaire pour voir apparaître vos statistiques ici.",action:v||p?{label:"Réinitialiser les filtres",onClick:()=>{F(""),I(""),g(1)}}:{label:"Voir l'inventaire",onClick:()=>a("/inventory")}}):e.jsx("div",{className:`table-container table-mobile-cards transition-opacity ${A?"opacity-60 pointer-events-none":""}`,children:e.jsxs("table",{className:"table-lab",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"w-[56px]"}),e.jsx("th",{children:e.jsxs("span",{className:"inline-flex items-center gap-2",children:["Article",Ce("date","Date")]})}),e.jsx("th",{className:"w-[120px]",children:"Plateforme"}),e.jsx("th",{className:"w-[110px]",children:"Statut"}),e.jsx("th",{className:"text-right w-[96px]",children:Ce("achat","Achat")}),e.jsx("th",{className:"text-right w-[104px]",children:Ce("price","Vente")}),e.jsx("th",{className:"text-right w-[132px]",children:Ce("marge",Oe)}),e.jsx("th",{className:"text-right w-[128px]",children:"Actions"})]})}),e.jsx("tbody",{children:w.map(t=>{var R,G;const s=!!t.shippedDate,n=t.trackingNumber?Ge(t.shippingCarrier,t.trackingNumber,t.buyerPostalCode):null,l=Rt(t),N=Pe(t),k=ca(t);return e.jsxs(i.Fragment,{children:[e.jsxs("tr",{className:`group ${N.bgClass}`,children:[e.jsx("td",{"data-label":"",className:`border-l-4 ${N.borderClass}`,children:it(t)}),e.jsx("td",{"data-label":"Article",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-lab-text-primary curs
1or-pointer hover:text-accent-primary transition-colors truncate max-w-[280px]",onClick:()=>a(`/inventory/${t.item.id}`),title:t.item.name,children:t.item.name}),(me(t.item)||t.item.collectionCardKey)&&e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[me(t.item)&&e.jsx("span",{className:"text-[11px] text-lab-text-tertiary truncate max-w-[240px]",children:me(t.item)}),t.item.collectionCardKey&&e.jsx("span",{className:"shrink-0 inline-flex items-center h-[16px] px-1.5 rounded bg-lab-subtle text-[10px] font-semibold text-lab-text-secondary",children:"Collection"})]}),e.jsx("div",{className:"text-[11px] text-lab-text-tertiary/80 font-mono mt-0.5",children:new Date(t.saleDate).toLocaleDateString("fr-FR")})]})}),e.jsx("td",{"data-label":"Plateforme",children:e.jsx("span",{className:"badge-info whitespace-nowrap",children:((R=t.salePlatform)==null?void 0:R.name)||"â"})}),e.jsx("td",{"data-label":"Statut",children:s?e.jsxs("div",{className:"group/status relative",children:[e.jsxs("button",{onClick:()=>te(t),className:`inline-flex items-center gap-1 px-2 py-1 rounded-lg text-[12px] font-medium bg-${l.color}/10 text-${l.color} border border-${l.color}/15 hover:bg-${l.color}/20 transition-colors cursor-pointer`,title:"Modifier l'expédition",children:[l.icon," ",l.label]}),e.jsxs("div",{className:"absolute bottom-full left-0 mb-1 hidden group-hover/status:block z-20 p-2.5 rounded-lg bg-lab-elevated border border-lab-border-default shadow-lg text-xs whitespace-nowrap",children:[e.jsxs("p",{className:"text-lab-text-primary font-medium",children:[new Date(t.shippedDate).toLocaleDateString("fr-FR"),t.shippingCarrier&&` · ${t.shippingCarrier}`]}),((G=t.trackingStatus)==null?void 0:G.description)&&e.jsx("p",{className:"text-lab-text-secondary mt-0.5",children:t.trackingStatus.description}),t.trackingNumber&&e.jsx("p",{className:"text-lab-text-tertiary font-mono mt-0.5",children:t.trackingNumber}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[n&&e.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline flex items-center gap-1",children:["Suivre ",e.jsx(Me,{size:10})]}),t.trackingNumber&&e.jsxs("button",{onClick:M=>{M.stopPropagation(),tt(t.id)},className:"text-lab-text-tertiary hover:text-accent-primary flex items-center gap-0.5 transition-colors",title:"Rafraîchir le statut",children:[e.jsx(pe,{size:10})," Refresh"]})]})]})]}):e.jsxs("button",{onClick:()=>te(t),className:"inline-flex items-center gap-1 px-2 py-1 rounded-lg text-[12px] font-medium bg-accent-warning/10 text-accent-warning border border-accent-warning/15 hover:bg-accent-warning/15 transition-colors cursor-pointer",children:[e.jsx(Ne,{size:13})," à expédier"]})}),e.jsx("td",{"data-label":"Achat",className:"text-right font-mono text-sm text-lab-text-secondary whitespace-nowrap",children:V(t.item.costTotalPurchaseEur)}),e.jsx("td",{"data-label":"Vente",className:"text-right font-mono text-sm font-medium text-lab-text-primary whitespace-nowrap",children:V(t.saleTotalClientEur)}),e.jsx("td",{"data-label":Oe,className:"text-right whitespace-nowrap",children:e.jsxs("div",{className:"inline-flex flex-col items-end",children:[e.jsxs("div",{className:`font-mono text-[15px] font-bold leading-none ${k.positive?"text-type-grass":"text-accent-danger"}`,children:[k.marge>0?"+":"",V(k.marge)]}),e.jsx("span",{className:`inline-block mt-1 font-mono text-[10.5px] font-bold px-1.5 py-px rounded ${k.pct===null?"bg-lab-subtle text-lab-text-tertiary":k.positive?"bg-type-grass/14 text-type-grass":"bg-accent-danger/14 text-accent-danger"}`,children:k.pct===null?"â":`${k.pct>0?"+":""}${Math.round(k.pct)} %`})]})}),e.jsx("td",{"data-label":"",className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx("button",{onClick:()=>Fe(t),className:"btn-icon p-2 hover:text-accent-primary hover:bg-accent-primary/10",title:"Détail de la vente",children:e.jsx(yt,{size:16,strokeWidth:1.5})}),n?e.jsx("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"btn-icon p-2 hover:text-accent-primary hover:bg-accent-primary/10",title:"Suivre le colis",children:e.jsx(ye,{size:16,strokeWidth:1.5})}):e.jsx("button",{onClick:()=>te(t),className:"btn-icon p-2 hover:text-accent-warning hover:bg-accent-warning/10",title:"Expédier",children:e.jsx(ye,{size:16,strokeWidth:1.5})}),e.jsx("button",{onClick:()=>a(`/inventory/${t.item.id}`),className:"btn-icon p-2",title:"Voir l'article",children:e.jsx(_e,{size:16,strokeWidth:1.5})}),e.jsx("button",{onClick:()=>Qe(t.id),className:"btn-icon p-2 hover:text-accent-danger hover:bg-accent-danger/10",title:"Annuler la vente",children:e.jsx(jt,{size:16,strokeWidth:1.5})})]})})]}),N.state==="red"&&e.jsx("tr",{className:"bg-accent-danger/10",children:e.jsx("td",{colSpan:8,className:"border-l-4 border-accent-danger/30 !pt-0 !pb-2.5",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-[12px] font-semibold text-accent-danger flex items-center gap-1 shrink-0",children:[e.jsx(qt,{size:13})," Encore en ligne â à retirer :"]}),N.pending.map(M=>et(t,M))]})})})]},t.id)})}),w.length>0&&e.jsx("tfoot",{className:"hidden md:table-footer-group",children:e.jsxs("tr",{className:"bg-lab-surface/60 border-t border-lab-border-default",children:[e.jsx("td",{className:"border-l-4 border-transparent"}),e.jsxs("td",{className:"text-[12px] font-semibold text-lab-text-secondary",children:["Total · ",J," vente",J>1?"s":""]}),e.jsx("td",{}),e.jsx("td",{}),e.jsx("td",{className:"text-right font-mono text-sm font-semibold text-lab-text-secondary",children:V(S.ach
1at)}),e.jsx("td",{className:"text-right font-mono text-sm font-semibold text-lab-text-primary",children:V(S.ca)}),e.jsxs("td",{className:"text-right",children:[e.jsxs("div",{className:`font-mono text-[15px] font-bold leading-none ${S.marge>=0?"text-type-grass":"text-accent-danger"}`,children:[S.marge>0?"+":"",V(S.marge)]}),e.jsx("span",{className:`inline-block mt-1 font-mono text-[10.5px] font-bold px-1.5 py-px rounded ${S.achat>0?S.marge>=0?"bg-type-grass/14 text-type-grass":"bg-accent-danger/14 text-accent-danger":"bg-lab-subtle text-lab-text-tertiary"}`,children:S.achat>0?`${S.marge>0?"+":""}${Math.round(S.marge/S.achat*100)} %`:"â"})]}),e.jsx("td",{})]})})]})}),L>1&&e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t border-lab-border-subtle",children:[e.jsxs("p",{className:"text-label-sm text-lab-text-tertiary",children:["Page ",j," sur ",L]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>g(t=>Math.max(1,t-1)),disabled:j===1,className:"btn-secondary p-2.5 disabled:opacity-30",children:e.jsx(vt,{size:18,strokeWidth:1.5})}),e.jsx("button",{onClick:()=>g(t=>Math.min(L,t+1)),disabled:j===L,className:"btn-secondary p-2.5 disabled:opacity-30",children:e.jsx(Be,{size:18,strokeWidth:1.5})})]})]})]}),ce&&e.jsx(St,{sale:ce,isOpen:!!ce,onClose:()=>te(null),onSaved:Q}),e.jsx(ut,{isOpen:!!_,onCancel:()=>q(null),onConfirm:async()=>{if(!_)return;const{action:t,data:s}=_;q(null);try{t==="deleteSale"&&(await U.delete(s.id),Q())}catch(n){console.error("Error:",n),b.addToast("Ãchec de l'annulation de la vente â réessayez","error")}},title:"Annuler cette vente",message:"Ãtes-vous sûr ? L'article repassera en stock.",confirmLabel:"Oui, annuler la vente",variant:"warning"}),e.jsx(Dt,{open:He,value:f,marginLabel:r==="personal"?"Bénéfice":"Marge",onApply:t=>{le(t),g(1)},onClose:()=>we(!1)}),lt]})}export{ks 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.