1var __IMPORT_META_ENV={};var __PROCESS_ENV={NODE_ENV:"production"}; 2import{a as we}from"/chunks/chunk-Z6FYTB65.js";import{e as U,f as se,h as D,i as Ne,j as ae,k as E,l as ye,m as Se,n as X}from"/chunks/chunk-OE5DXI5O.js";import{a as T}from"/chunks/chunk-A6NSEO7N.js";import{Ak as ge,Cs as re,Is as A,Le as B,Rg as O,Xe as pe,Ye as fe,af as K,co as Q,cv as he,da as ee,ef as te,ff as xe,gB as be,kD as ve,nB as _,nq as q}from"/chunks/chunk-62QHDT2Z.js";import{a as ue,b as Z,c as k,e as z}from"/chunks/chunk-EWMNDR7R.js";import"/chunks/chunk-ZP4OMTXP.js";import{a as w}from"/chunks/chunk-DKSMBCPM.js";import{f as Y,g as I,s as W,v as me}from"/chunks/chunk-Z2TP6DSD.js";import"/chunks/chunk-GQOIBJBD.js";import{a as le}from"/chunks/chunk-PE5MZRD7.js";import{a as G}from"/chunks/chunk-2F2XG2RD.js";import{d as S}from"/chunks/chunk-43M3N6VY.js";var j=S(G());function Ie(e){return`prep_stats_${e}`}function Le(e){try{return JSON.parse(localStorage.getItem(Ie(e))||"{}")}catch{return{}}}function ke(e,a){try{localStorage.setItem(Ie(e),JSON.stringify(a))}catch{}}function V(){return new Date().toISOString().split("T")[0]}function oe(e){return`prep_timer_${e}`}function qe(e){try{let a=localStorage.getItem(oe(e));return a?JSON.parse(a):null}catch{return null}}function ne(e,a){try{a?localStorage.setItem(oe(e),JSON.stringify(a)):localStorage.removeItem(oe(e))}catch{}}function De(e){return`prep_checked_${e}`}function Ue(e){try{return JSON.parse(localStorage.getItem(De(e))||"{}")}catch{return{}}}function F(e,a){try{localStorage.setItem(De(e),JSON.stringify(a))}catch{}}var Xe=new Set(["os-received","os-paid","os-processing","os-shipping"]),Fe=new Set(["os-closed","os-completed","os-refunded","os-cancelled"]),b=le()((e,a)=>({orders:[],loaded:!1,loading:!1,activeOrderId:null,timerStart:null,checkedItems:{},stats:{},fetchOrders:async()=>{let t=w.getState().user;if(t){e({loading:!0});try{let r=(await W(Y.ORDERS)).map(ue),l=t.prepAdminId?String(t.prepAdminId).trim():"",o=t.prepChannels?t.prepChannels.split(",").map(u=>u.trim()).filter(Boolean):[],d=r.filter(u=>!(l&&u.ownerId&&u.ownerId!==l||o.length>0&&!o.includes(u.channel))),f=qe(t.userId),x=Le(t.userId),h=f?Ue(t.userId):{},N={...x};try{let c=(await W(Y.USERS)).find(v=>String(v.id)===String(t.nodeId));if(c){let v=c.fieldValues?.[I.PREP_STATS];if(v){let y=JSON.parse(v);for(let[C,$]of Object.entries(y)){let L=N[C];(!L||L.count<$.count)&&(N[C]=$)}ke(t.userId,N)}}}catch{}e({orders:d,loaded:!0,loading:!1,activeOrderId:f?.orderId||null,timerStart:f?.startedAt||null,checkedItems:h,stats:N})}catch{e({loading:!1})}}},refresh:async()=>{let{fetchOrders:t}=a();await t()},startPrep:t=>{let n=w.getState().user;if(!n)return;let r=Date.now();ne(n.userId,{orderId:t,startedAt:r}),F(n.userId,{}),e({activeOrderId:t,timerStart:r,checkedItems:{}}),Z.update(t,{[I.O_STATUS]:"os-processing"}).catch(()=>{})},toggleItem:t=>{let n=w.getState().user;if(!n)return;let r=a().checkedItems,l={...r,[t]:!r[t]};F(n.userId,l),e({checkedItems:l})},checkAll:()=>{let t=w.getState().user;if(!t)return;let n=a().activeOrder();if(!n)return;let r={};n.items.forEach((l,o)=>{r[String(o)]=!0}),F(t.userId,r),e({checkedItems:r})},finishPrep:async()=>{let t=w.getState().user,{activeOrderId:n,timerStart:r}=a();if(!t||!n)return;let l=r?Math.round((Date.now()-r)/1e3):0,o=[t.firstName,t.lastName].filter(Boolean).join(" ")||t.pseudo||t.email,d=V();await Z.update(n,{[I.O_STATUS]:"os-shipping",[I.O_PREPARER_NAME]:o,[I.O_PREPARER_NODE_ID]:t.nodeId,[I.O_PREP_TIME]:l,[I.O_PREP_DATE]:d});let f={...a().stats},x=V();f[x]||(f[x]={count:0,totalTime:0}),f[x].count+=1,f[x].totalTime+=l,ke(t.userId,f),me(Y.USERS,t.nodeId,{[I.PREP_STATS]:JSON.stringify(f)}).catch(()=>{}),ne(t.userId,null),F(t.userId,{});let h=a().orders.map(N=>N.id===n?{...N,status:"os-shipping"}:N);e({activeOrderId:null,timerStart:null,checkedItems:{},stats:f,orders:h})},cancelPrep:()=>{let t=w.getState().user;if(!t)return;let{activeOrderId:n}=a();if(!n)return;ne(t.userId,null),F(t.userId,{}),Z.update(n,{[I.O_STATUS]:"os-paid"}).catch(()=>{});let r=a().orders.map(l=>l.id===n?{...l,status:"os-paid"}:l);e({activeOrderId:null,timerStart:null,checkedItems:{},orders:r})},queueOrders:()=>{let{orders:t,activeOrderId:n}=a();return t.filter(r=>Xe.has(r.status)&&r.id!==n).sort((r,l)=>new Date(r.createdAt).getTime()-new Date(l.createdAt).getTime())},activeOrder:()=>{let{orders:t,activeOrderId:n}=a();return n&&t.find(r=>r.id===n)||null},archiveOrders:()=>a().orders.filter(t=>Fe.has(t.status)).sort((t,n)=>new Date(n.updatedAt||n.createdAt).getTime()-new Date(t.updatedAt||t.createdAt).getTime()),elapsed:()=>{let{timerStart:t}=a();return t?Math.round((Date.now()-t)/1e3):0},_myArchivedOrders:()=>{let t=w.getState().user;if(!t)return[];let{orders:n}=a();return n.filter(r=>{if(r.preparerNodeId&&r.preparerNodeId===t.nodeId)return!0;
2if(!r.preparerNodeId&&r.preparerName){let l=[t.firstName,t.lastName].filter(Boolean).join(" ")||t.pseudo;return r.preparerName.toLowerCase().startsWith(l.toLowerCase().split(" ")[0])}return!1})},todayStats:()=>{let n=w.getState().user?a().stats[V()]||{count:0,totalTime:0}:{count:0,totalTime:0},r=a()._myArchivedOrders(),l=V(),o=r.filter(x=>(x.prepDate||x.updatedAt?.slice(0,10))===l),d=Math.max(n.count,o.length),f=n.totalTime>0?n.totalTime:o.reduce((x,h)=>x+(h.prepTime||0),0);return{count:d,totalTime:f}},weekStats:()=>{let t=w.getState().user,n=a().stats,r=new Date,l=0,o=0;for(let u=0;u<7;u++){let c=new Date(r);c.setDate(c.getDate()-u);let v=c.toISOString().split("T")[0],y=n[v];y&&(l+=y.count,o+=y.totalTime)}let d=new Date(Date.now()-7*864e5).toISOString().slice(0,10),x=a()._myArchivedOrders().filter(u=>(u.prepDate||u.updatedAt?.slice(0,10)||"")>=d),h=Math.max(l,x.length),N=o>0?o:x.reduce((u,c)=>u+(c.prepTime||0),0);return{count:h,totalTime:N}},dailyHistory:()=>{let t=a().stats,n=a()._myArchivedOrders(),r=new Date,l=[];for(let o=6;o>=0;o--){let d=new Date(r);d.setDate(d.getDate()-o);let f=d.toISOString().split("T")[0],x=t[f],h=n.filter(c=>(c.prepDate||c.updatedAt?.slice(0,10))===f),N=Math.max(x?.count||0,h.length),u=(x?.totalTime??0)>0?x.totalTime:h.reduce((c,v)=>c+(v.prepTime||0),0);l.push({date:f,count:N,avgTime:N>0?Math.round(u/N):0})}return l}}));var Re=S(G());function R(e,a){let t=+D(e)-+D(a);return t<0?-1:t>0?1:t}function Oe(e,a,t){let[n,r]=E(t?.in,e,a),l=n.getFullYear()-r.getFullYear(),o=n.getMonth()-r.getMonth();return l*12+o}function Te(e){return a=>{let n=(e?Math[e]:Math.trunc)(a);return n===0?0:n}}function Ae(e,a){return+D(e)-+D(a)}function Me(e,a){let t=D(e,a?.in);return t.setHours(23,59,59,999),t}function Pe(e,a){let t=D(e,a?.in);return+Me(t,a)==+we(t,a)}function Ce(e,a,t){let[n,r,l]=E(t?.in,e,e,a),o=R(r,l),d=Math.abs(Oe(r,l));if(d<1)return 0;r.getMonth()===1&&r.getDate()>27&&r.setDate(30),r.setMonth(r.getMonth()-o*d);let f=R(r,l)===-o;Pe(n)&&d===1&&R(n,l)===1&&(f=!1);let x=o*(d-+f);return x===0?0:x}function _e(e,a,t){let n=Ae(e,a)/1e3;return Te(t?.roundingMethod)(n)}function Ee(e,a,t){let n=Ne(),r=t?.locale??n.locale??Se,l=2520,o=R(e,a);if(isNaN(o))throw new RangeError("Invalid time value");let d=Object.assign({},t,{addSuffix:t?.addSuffix,comparison:o}),[f,x]=E(t?.in,...o>0?[a,e]:[e,a]),h=_e(x,f),N=(ae(x)-ae(f))/1e3,u=Math.round((h-N)/60),c;if(u<2)return t?.includeSeconds?h<5?r.formatDistance("lessThanXSeconds",5,d):h<10?r.formatDistance("lessThanXSeconds",10,d):h<20?r.formatDistance("lessThanXSeconds",20,d):h<40?r.formatDistance("halfAMinute",0,d):h<60?r.formatDistance("lessThanXMinutes",1,d):r.formatDistance("xMinutes",1,d):u===0?r.formatDistance("lessThanXMinutes",1,d):r.formatDistance("xMinutes",u,d);if(u<45)return r.formatDistance("xMinutes",u,d);if(u<90)return r.formatDistance("aboutXHours",1,d);if(u<se){let v=Math.round(u/60);return r.formatDistance("aboutXHours",v,d)}else{if(u<l)return r.formatDistance("xDays",1,d);if(u<U){let v=Math.round(u/se);return r.formatDistance("xDays",v,d)}else if(u<U*2)return c=Math.round(u/U),r.formatDistance("aboutXMonths",c,d)}if(c=Ce(x,f),c<12){let v=Math.round(u/U);return r.formatDistance("xMonths",v,d)}else{let v=c%12,y=Math.trunc(c/12);return v<3?r.formatDistance("aboutXYears",y,d):v<9?r.formatDistance("overXYears",y,d):r.formatDistance("almostXYears",y+1,d)}}function H(e,a){return Ee(e,ye(e),a)}var i=S(T());function He({order:e,onStart:a}){let t=w(d=>d.user?.prepShowPrices??!0),n=z(e.status),r=e.items.reduce((d,f)=>d+f.qty,0),l=e.items.slice(0,3).filter(d=>d.image),o=e.createdAt?H(new Date(e.createdAt),{addSuffix:!0,locale:X}):"";return(0,i.jsxs)("button",{onClick:a,className:"w-full text-left bg-card border border-border rounded-xl p-4 hover:border-brand/40 hover:shadow-lg hover:shadow-brand/5 transition-all duration-200 active:scale-[0.98] group",children:[(0,i.jsxs)("div",{className:"flex items-start justify-between gap-3 mb-3",children:[(0,i.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,i.jsxs)("span",{className:"font-semibold text-sm text-foreground",children:["#",e.orderNum]}),(0,i.jsx)("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full font-medium",style:{background:n.color+"20",color:n.color},children:n.label}),e.channel&&(0,i.jsx)("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-accent/30 text-muted-foreground",children:e.channel})]}
2),(0,i.jsxs)("p",{className:"text-xs text-foreground/80 truncate",children:[e.firstName," ",e.lastName]})]}),(0,i.jsx)(te,{className:"w-4 h-4 text-muted-foreground group-hover:text-brand transition-colors shrink-0 mt-1"})]}),(0,i.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,i.jsx)("div",{className:"flex -space-x-2",children:l.length>0?l.map((d,f)=>(0,i.jsx)("div",{className:"w-8 h-8 rounded-lg border-2 border-card bg-accent/20 overflow-hidden shrink-0",children:(0,i.jsx)("img",{src:d.image,alt:"",className:"w-full h-full object-cover",onError:x=>{x.target.style.display="none"}})},f)):(0,i.jsx)("div",{className:"w-8 h-8 rounded-lg border border-border bg-accent/10 flex items-center justify-center",children:(0,i.jsx)(Q,{className:"w-3.5 h-3.5 text-muted-foreground"})})}),(0,i.jsxs)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,i.jsx)(A,{className:"w-3 h-3"}),(0,i.jsxs)("span",{children:[r," article",r>1?"s":""]})]}),t&&(0,i.jsx)("span",{className:"ml-auto text-xs font-semibold text-foreground",children:k(e.total,e.currency)})]}),(0,i.jsxs)("div",{className:"flex items-center justify-between text-[10px] text-muted-foreground",children:[(0,i.jsxs)("span",{className:"flex items-center gap-1 truncate max-w-[60%]",children:[(0,i.jsx)(q,{className:"w-3 h-3 shrink-0"}),e.shipCity||e.billCity,e.shipZip?` ${e.shipZip}`:""]}),(0,i.jsxs)("span",{className:"flex items-center gap-1 shrink-0",children:[(0,i.jsx)(O,{className:"w-3 h-3"}),o]})]})]})}function Je({order:e}){let a=w(o=>o.user?.prepShowPrices??!0),[t,n]=(0,Re.useState)(!1),r=e.items.reduce((o,d)=>o+d.qty,0),l=e.updatedAt?H(new Date(e.updatedAt),{addSuffix:!0,locale:X}):"";return(0,i.jsxs)("div",{className:"border border-border/50 rounded-lg overflow-hidden bg-card/40",children:[(0,i.jsxs)("button",{onClick:()=>n(o=>!o),className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-muted/30 transition-colors",children:[(0,i.jsx)(_,{className:"w-3.5 h-3.5 text-cyan-500 shrink-0"}),(0,i.jsxs)("span",{className:"text-xs font-medium text-foreground/80 flex-1 truncate",children:["#",e.orderNum," \u2014 ",e.firstName," ",e.lastName]}),(0,i.jsx)("span",{className:"text-[10px] text-muted-foreground shrink-0 hidden sm:block",children:l}),t?(0,i.jsx)(K,{className:"w-3.5 h-3.5 text-muted-foreground shrink-0"}):(0,i.jsx)(te,{className:"w-3.5 h-3.5 text-muted-foreground shrink-0"})]}),t&&(0,i.jsxs)("div",{className:"px-3 pb-3 pt-1 border-t border-border/30 space-y-2",children:[(0,i.jsxs)("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[(0,i.jsxs)("span",{className:"flex items-center gap-1",children:[(0,i.jsx)(A,{className:"w-3 h-3"}),r," article",r>1?"s":""]}),a&&(0,i.jsx)("span",{className:"font-medium text-foreground/70",children:k(e.total,e.currency)}),(e.shipCity||e.billCity)&&(0,i.jsxs)("span",{className:"flex items-center gap-1",children:[(0,i.jsx)(q,{className:"w-3 h-3 shrink-0"}),e.shipCity||e.billCity,e.shipZip?` ${e.shipZip}`:""]})]}),e.items.length>0&&(0,i.jsx)("ul",{className:"space-y-0.5",children:e.items.map((o,d)=>(0,i.jsxs)("li",{className:"flex items-center gap-2 text-[11px] text-foreground/70",children:[o.image&&(0,i.jsx)("img",{src:o.image,alt:"",className:"w-5 h-5 rounded object-cover shrink-0 opacity-70",onError:f=>{f.target.style.display="none"}}),(0,i.jsx)("span",{className:"truncate flex-1",children:o.name}),(0,i.jsxs)("span",{className:"shrink-0 text-muted-foreground",children:["\xD7",o.qty]})]},d))})]})]})}function ie(){let e=b(r=>r.queueOrders()),a=b(r=>r.startPrep),t=e.filter(r=>r.status!=="os-shipping"),n=e.filter(r=>r.status==="os-shipping");return t.length===0&&n.length===0?(0,i.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(0,i.jsx)("div",{className:"w-14 h-14 rounded-2xl bg-brand/10 flex items-center justify-center mb-4",children:(0,i.jsx)(A,{className:"w-7 h-7 text-brand"})}),(0,i.jsx)("p",{className:"text-sm font-medium text-foreground mb-1",children:"Aucune commande en attente"}),(0,i.jsx)("p",{className:"text-xs text-muted-foreground",children:"Les nouvelles commandes appara\xEEtront ici"})]}):(0,i.jsxs)("div",{className:"space-y-4",children:[t.length>0&&(0,i.jsxs)("div",{className:"space-y-3",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between px-1",children:[(0,i.jsxs)("span",{className:"text-xs font-medium text-muted-foreground",children:[t.length," commande",t.length>
21?"s":""," en attente"]}),(0,i.jsx)("span",{className:"text-[10px] text-muted-foreground/60",children:"Plus ancienne en premier"})]}),(0,i.jsx)("div",{className:"space-y-2",children:t.map(r=>(0,i.jsx)(He,{order:r,onStart:()=>a(r.id)},r.id))})]}),t.length===0&&(0,i.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[(0,i.jsx)("p",{className:"text-sm font-medium text-foreground mb-1",children:"Aucune commande en attente"}),(0,i.jsx)("p",{className:"text-xs text-muted-foreground",children:"Les nouvelles commandes appara\xEEtront ici"})]}),n.length>0&&(0,i.jsxs)("div",{className:"space-y-1.5",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2 px-1",children:[(0,i.jsx)(_,{className:"w-3.5 h-3.5 text-cyan-500"}),(0,i.jsxs)("span",{className:"text-[11px] font-medium text-muted-foreground",children:[n.length," en livraison"]})]}),(0,i.jsx)("div",{className:"space-y-1",children:n.map(r=>(0,i.jsx)(Je,{order:r},r.id))})]})]})}var M=S(G());var s=S(T());function Ye(e){let a=Math.floor(e/60),t=e%60;return`${String(a).padStart(2,"0")}:${String(t).padStart(2,"0")}`}function de(){let e=b(g=>g.activeOrder()),a=b(g=>g.checkedItems),t=b(g=>g.toggleItem),n=b(g=>g.checkAll),r=b(g=>g.finishPrep),l=b(g=>g.cancelPrep),o=b(g=>g.timerStart),d=w(g=>g.user?.prepShowPrices??!0),[f,x]=(0,M.useState)(0),[h,N]=(0,M.useState)(!1),[u,c]=(0,M.useState)(!1);(0,M.useEffect)(()=>{if(!o)return;let g=()=>x(Math.round((Date.now()-o)/1e3));g();let P=setInterval(g,1e3);return()=>clearInterval(P)},[o]);let v=(0,M.useCallback)(async()=>{c(!0);try{await r()}finally{c(!1)}},[r]);if(!e)return null;let y=e.items.length,C=e.items.filter((g,P)=>a[String(P)]).length,$=y>0&&C===y,L=y>0?C/y*100:0;return(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"bg-card border border-border rounded-xl p-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,s.jsxs)("span",{className:"font-semibold text-sm",children:["#",e.orderNum]}),e.channel&&(0,s.jsx)("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-accent/30 text-muted-foreground",children:e.channel})]}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:[e.firstName," ",e.lastName]})]}),(0,s.jsx)("div",{className:"flex items-center gap-3",children:(0,s.jsxs)("div",{className:"flex items-center gap-1.5 bg-amber-500/10 border border-amber-500/20 rounded-lg px-3 py-1.5",children:[(0,s.jsx)(O,{className:"w-4 h-4 text-amber-500 animate-pulse"}),(0,s.jsx)("span",{className:"text-lg font-mono font-bold text-amber-500",children:Ye(f)})]})})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between text-[10px] text-muted-foreground",children:[(0,s.jsxs)("span",{children:[C,"/",y," articles pr\xE9par\xE9s"]}),(0,s.jsxs)("span",{children:[Math.round(L),"%"]})]}),(0,s.jsx)("div",{className:"h-2 bg-accent/20 rounded-full overflow-hidden",children:(0,s.jsx)("div",{className:"h-full rounded-full transition-all duration-300 ease-out",style:{width:`${L}%`,background:$?"linear-gradient(90deg, #10b981, #14b8a6)":"linear-gradient(90deg, #3b82f6, #8b5cf6)"}})})]})]}),(0,s.jsxs)("div",{className:"bg-card border border-border rounded-xl overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,s.jsxs)("span",{className:"text-xs font-medium text-foreground flex items-center gap-1.5",children:[(0,s.jsx)(A,{className:"w-3.5 h-3.5 text-brand"}),"Articles \xE0 pr\xE9parer"]}),(0,s.jsxs)("button",{onClick:n,className:"text-[10px] text-brand hover:text-brand/80 flex items-center gap-1 transition-colors",children:[(0,s.jsx)(pe,{className:"w-3 h-3"}),"Tout cocher"]})]}),(0,s.jsx)("div",{className:"divide-y divide-border",children:e.items.map((g,P)=>{let J=!!a[String(P)];return(0,s.jsxs)("button",{onClick:()=>t(String(P)),className:`w-full flex items-center gap-3 px-4 py-3 text-left transition-all duration-150 active:scale-[0.99] ${J?"bg-emerald-500/5":"hover:bg-accent/10"}`,children:[(0,s.jsx)("div",{className:`w-6 h-6 rounded-lg border-2 flex items-center justify-center shrink-0 transition-all duration-200 ${J?"bg-emerald-500 border-emerald-500 shadow-sm shadow-emerald-500/30":"border-border hover:border-brand/40"}`,children:J&&(0,s.jsx)(fe,{className:"w-3.5 h-3.5 text-white"})}),g.image?(0,s.jsx)("div",{className:"w-10 h-10 rounded-lg overflow-hidden bg-accent/10 shrink-0 border border-border",children:(0,s.jsx)("img",{src:g.image,alt:"",className:"w-full h-full object-cover",onError:$e=>{$e.target.style.display="none"}})}):(0,s.jsx)("div",{className:"w-10 h-10 rounded-lg bg-accent/10 border border-border flex items-center justify-center shrink-0",children:(0,s.jsx)(Q,{className:"w-4 h-4 text-muted-foreground"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:`text-sm truncate transition-all ${J?"line-through text-muted-foreground":"text-foreground"}`,children:g.name}),g.sku&&(0,s.jsxs)("p",{className:"text-[10px] text-muted-foreground",children:["SKU: ",g.sku]})]}),(0,s.jsxs)("div",{className:"text-right shrink-0",children:[(0,s.jsxs)("span",{className:"text-sm font-bold text-foreground",children:["\xD7",g.qty]}),d&&(0,s.jsx)("p",{className:"text-[10px] text-muted-foreground",children:k(g.total||g.price*g.qty)})]})]},P)})})]}),(0,s.jsxs)("div",{className:"bg-card border border-border rounded-xl overflow-hidden",children:[(0,s.jsxs)("button",{onClick:()=>N(!h),className:"w-full flex items-center justify-between px-4 py-3 text-left hover:bg-accent/5 transition-colors",children:[(0,s.jsxs)("span",{className:"text-xs font-medium text-foreground flex items-center gap-1.5",children:[(0,s.jsx)(ge,{className:"w-3.5 h-3.5 text-muted-foreground"}),"D\xE9tails facturation & livraison"]}),h?(0,s.jsx)(xe,{className:"w-3.5 h-3.5 text-muted-foreground"}):(0,s.jsx)(K,{className:"w-3.5 h-3.5 text-muted-foreground"})]}),h&&(0,s.jsxs)("div",{className:"px-4 pb-4 space-y-3 border-t border-border pt-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-[10px] text-muted-foreground mb-1 flex items-center gap-1",children:[(0,s.jsx)(q,{className:"w-3 h-3"})," Adresse de livraison"]}),(0,s.jsxs)("p",{className:"text-xs text-foreground",children:[e.shipFName||e.firstName," ",e.shipLName||e.lastName]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:e.shipAddr||e.billAddr}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:[e.shipZip||e.billZip," ",e.shipCity||e.billCity,", ",e.shipCountry||e.billCountry]})]}),e.shipMethod&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-[10px] text-muted-foreground mb-1 flex items-center gap-1",children:[(0,s.jsx)(_,{className:"w-3 h-3"})," M\xE9thode d'exp\xE9dition"]}),(0,s.jsx)("p",{className:"text-xs text-foreground",children:e.shipMethod})]}),e.note&&(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-[10px] text-muted-foreground mb-1",children:"Note client"}),(0,s.jsx)("p",{className:"text-xs text-foreground bg-accent/10 rounded-lg p-2",children:e.note})]}),d&&(0,s.jsxs)("div",{className:"border-t border-border pt-2 space-y-1",children:[(0,s.jsxs)("div",{className:"flex justify-between text-xs text-muted-foreground",children:[(0,s.jsx)("span",{children:"Sous-total"}),(0,s.jsx)("span",{children:k(e.subtotal,e.currency)})]}),(0,s.jsxs)("div",{className:"flex justify-between text-xs text-muted-foreground",children:[(0,s.jsx)("span",{children:"Livraison"}),(0,s.jsx)("span",{children:k(e.shipping,e.currency)})]}),e.tax>0&&(0,s.jsxs)("div",{className:"flex justify-between text-xs text-muted-foreground",children:[(0,s.jsx)("span",{children:"TVA"}),(0,s.jsx)("span",{children:k(e.tax,e.currency)})]}),(0,s.jsxs)("div",{className:"flex justify-between text-xs font-semibold text-foreground pt-1 border-t border-border",children:[(0,s.jsx)("span",{children:"Total"}),(0,s.jsx)("span",{children:k(e.total,e.currency)})]})]})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsxs)("button",{onClick:l,className:"flex-1 flex items-center justify-center gap-1.5 px-4 py-3 rounded-xl border border-border text-sm text-muted-foreground hover:bg-accent/10 transition-colors",children:[(0,s.jsx)(ve,{className:"w-4 h-4"}),"Annuler"]}),(0,s.jsx)("button",{onClick:v,disabled:!$||u,className:"flex-[2] flex items-center justify-center gap-2 px-4 py-3 rounded-xl text-sm font-semibold transition-all duration-200 disabled:opacity-40 disabled:cursor-not-allowed bg-emerald-500 text-white hover:bg-emerald-600 active:scale-[0.97] shadow-lg shadow-emerald-500/20",children:u?(0,s.jsx)("div",{className:"w-4 h-4 border-2 border-white border-t-transparent roun
2ded-full animate-spin"}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(_,{className:"w-4 h-4"}),"Valider \u2014 En livraison"]})})]})]})}var m=S(T());function je(e){if(e===0)return"\u2014";let a=Math.floor(e/60),t=e%60;return a===0?`${t}s`:`${a}m${t>0?` ${t}s`:""}`}function Ze({data:e}){let a=Math.max(...e,1),t=120,n=32,r=e.map((o,d)=>({x:d/Math.max(e.length-1,1)*t,y:n-o/a*(n-4)-2})),l=r.map((o,d)=>`${d===0?"M":"L"} ${o.x} ${o.y}`).join(" ");return(0,m.jsxs)("svg",{width:t,height:n,className:"shrink-0",children:[(0,m.jsx)("defs",{children:(0,m.jsxs)("linearGradient",{id:"spark-grad",x1:"0",y1:"0",x2:"1",y2:"0",children:[(0,m.jsx)("stop",{offset:"0%",stopColor:"#3b82f6"}),(0,m.jsx)("stop",{offset:"100%",stopColor:"#8b5cf6"})]})}),(0,m.jsx)("path",{d:l,fill:"none",stroke:"url(#spark-grad)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),r.map((o,d)=>(0,m.jsx)("circle",{cx:o.x,cy:o.y,r:"2",fill:d===r.length-1?"#8b5cf6":"#3b82f6"},d))]})}function ce(){let e=b(o=>o.todayStats()),a=b(o=>o.weekStats()),t=b(o=>o.dailyHistory()),n=e.count>0?Math.round(e.totalTime/e.count):0,r=a.count>0?Math.round(a.totalTime/a.count):0,l=t.map(o=>new Date(o.date).toLocaleDateString("fr-FR",{weekday:"short"}).slice(0,3));return(0,m.jsxs)("div",{className:"space-y-3",children:[(0,m.jsxs)("div",{className:"flex items-center gap-1.5 px-1",children:[(0,m.jsx)(B,{className:"w-3.5 h-3.5 text-brand"}),(0,m.jsx)("span",{className:"text-xs font-medium text-foreground",children:"Mes statistiques"})]}),(0,m.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,m.jsxs)("div",{className:"bg-card border border-border rounded-xl p-3",children:[(0,m.jsxs)("div",{className:"flex items-center gap-1.5 mb-2",children:[(0,m.jsx)(A,{className:"w-3 h-3 text-blue-400"}),(0,m.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Aujourd'hui"})]}),(0,m.jsx)("p",{className:"text-xl font-bold text-foreground",children:e.count}),(0,m.jsxs)("p",{className:"text-[10px] text-muted-foreground",children:["commande",e.count>1?"s":""]})]}),(0,m.jsxs)("div",{className:"bg-card border border-border rounded-xl p-3",children:[(0,m.jsxs)("div",{className:"flex items-center gap-1.5 mb-2",children:[(0,m.jsx)(O,{className:"w-3 h-3 text-amber-400"}),(0,m.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Temps moyen"})]}),(0,m.jsx)("p",{className:"text-xl font-bold text-foreground",children:je(n)}),(0,m.jsx)("p",{className:"text-[10px] text-muted-foreground",children:"par commande"})]}),(0,m.jsxs)("div",{className:"bg-card border border-border rounded-xl p-3",children:[(0,m.jsxs)("div",{className:"flex items-center gap-1.5 mb-2",children:[(0,m.jsx)(be,{className:"w-3 h-3 text-emerald-400"}),(0,m.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Cette semaine"})]}),(0,m.jsx)("p",{className:"text-xl font-bold text-foreground",children:a.count}),(0,m.jsxs)("p",{className:"text-[10px] text-muted-foreground",children:["commande",a.count>1?"s":""]})]}),(0,m.jsxs)("div",{className:"bg-card border border-border rounded-xl p-3",children:[(0,m.jsxs)("div",{className:"flex items-center gap-1.5 mb-2",children:[(0,m.jsx)(O,{className:"w-3 h-3 text-purple-400"}),(0,m.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Moy. semaine"})]}),(0,m.jsx)("p",{className:"text-xl font-bold text-foreground",children:je(r)}),(0,m.jsx)("p",{className:"text-[10px] text-muted-foreground",children:"par commande"})]})]}),(0,m.jsxs)("div",{className:"bg-card border border-border rounded-xl p-4",children:[(0,m.jsx)("p",{className:"text-[10px] text-muted-foreground mb-3",children:"7 derniers jours"}),(0,m.jsxs)("div",{className:"flex items-end gap-3",children:[(0,m.jsx)(Ze,{data:t.map(o=>o.count)}),(0,m.jsx)("div",{className:"flex-1 flex justify-between text-[9px] text-muted-foreground/60",children:l.map((o,d)=>(0,m.jsx)("span",{children:o},d))})]})]})]})}var p=S(T());function ze({className:e=""}){return(0,p.jsx)("div",{className:`animate-pulse rounded-lg bg-muted/60 ${e}`})}function Be({order:e}){let a=w(n=>n.user?.prepShowPrices??!0),t=z(e.status);return(0,p.jsxs)("div",{className:"bg-card/50 border border-border/50 rounded-xl p-3 opacity-70",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between",children:[(0,p.jsxs)("div",{className:"flex items-center gap-2",children:[(0,p.jsxs)("span",{className:"text-xs font-medium text-foreground
2/70",children:["#",e.orderNum]}),(0,p.jsx)("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full font-medium",style:{background:t.color+"15",color:t.color},children:t.label})]}),a&&(0,p.jsx)("span",{className:"text-xs text-muted-foreground",children:k(e.total,e.currency)})]}),(0,p.jsxs)("p",{className:"text-[10px] text-muted-foreground mt-1",children:[e.firstName," ",e.lastName,e.updatedAt&&(0,p.jsxs)("span",{children:[" \xB7 ",H(new Date(e.updatedAt),{addSuffix:!0,locale:X})]})]})]})}function Ke(){let e=b(c=>c.loaded),a=b(c=>c.loading),t=b(c=>c.fetchOrders),n=b(c=>c.refresh),r=b(c=>c.activeOrderId),l=b(c=>c.queueOrders()),o=b(c=>c.archiveOrders()),[d,f]=(0,j.useState)("queue"),[x,h]=(0,j.useState)(!1);(0,j.useEffect)(()=>{t()},[t]),(0,j.useEffect)(()=>{let c=setInterval(()=>{n()},3e4);return()=>clearInterval(c)},[n]);let N=async()=>{h(!0),await n(),setTimeout(()=>h(!1),500)};if(r)return(0,p.jsxs)("div",{className:"max-w-lg mx-auto px-4 py-4",children:[(0,p.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,p.jsx)(re,{className:"w-5 h-5 text-brand"}),(0,p.jsx)("h1",{className:"text-lg font-bold text-foreground",children:"Pr\xE9paration en cours"})]}),(0,p.jsx)(de,{})]});let u=[{key:"queue",label:"File",icon:O,count:l.length},{key:"archive",label:"Archives",icon:ee,count:o.length},{key:"stats",label:"Stats",icon:B}];return(0,p.jsxs)("div",{className:"max-w-lg mx-auto px-4 py-4",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,p.jsxs)("div",{className:"flex items-center gap-2",children:[(0,p.jsx)(re,{className:"w-5 h-5 text-brand"}),(0,p.jsx)("h1",{className:"text-lg font-bold text-foreground",children:"Pr\xE9paration"})]}),(0,p.jsx)("button",{onClick:N,disabled:x,className:"p-2 rounded-lg hover:bg-accent/20 transition-colors",children:(0,p.jsx)(he,{className:`w-4 h-4 text-muted-foreground ${x?"animate-spin":""}`})})]}),(0,p.jsx)("div",{className:"flex gap-1 bg-accent/10 rounded-xl p-1 mb-4",children:u.map(c=>{let v=c.icon,y=d===c.key;return(0,p.jsxs)("button",{onClick:()=>f(c.key),className:`flex-1 flex items-center justify-center gap-1.5 py-2 rounded-lg text-xs font-medium transition-all duration-200 ${y?"bg-card shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[(0,p.jsx)(v,{className:"w-3.5 h-3.5"}),c.label,c.count!==void 0&&c.count>0&&(0,p.jsx)("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full ${y?"bg-brand/10 text-brand":"bg-accent/30"}`,children:c.count})]},c.key)})}),!e&&a&&(0,p.jsx)("div",{className:"space-y-3",children:[1,2,3].map(c=>(0,p.jsx)(ze,{className:"h-24"}
2,c))}),e&&d==="queue"&&(0,p.jsx)(ie,{}),e&&d==="archive"&&(0,p.jsx)("div",{className:"space-y-2",children:o.length===0?(0,p.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(0,p.jsx)(ee,{className:"w-8 h-8 text-muted-foreground/40 mb-2"}),(0,p.jsx)("p",{className:"text-xs text-muted-foreground",children:"Aucune commande archiv\xE9e"})]}):o.slice(0,20).map(c=>(0,p.jsx)(Be,{order:c},c.id))}),e&&d==="stats"&&(0,p.jsx)(ce,{})]})}export{Ke 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.