1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7017],{77017:function(e,t,a){"use strict";a.r(t);var r=a(57437),s=a(2265),l=a(11444),i=a(99427),n=a.n(i),o=a(32713),d=a(10679),c=a(43309),u=a(65234),m=a(23711),x=a(26031),g=a(38157),p=a(3860),b=a(36595),h=a(80699),v=a(4),y=a(78676),f=a(1092),j=a(72420),w=a(27397),N=a(8541),S=a(95472),D=a(40897),k=a.n(D),C=a(89671),P=a(32285),E=a(66648),M=a(80580),F=a(25484),T=a(91269),R=a(39775),_=a(46644),B=a(96592),A=a(5277),Z=a(610),L=a(86033),I=a(80496);function O(e){let{value:t,onChange:a,allLabel:l,options:i=[],widthClass:n="w-[350px]"}=e,[o,d]=(0,s.useState)(!1),c=(0,s.useRef)(null),u="all"!==t&&t?i.find(e=>e===t)||t:l;return(0,s.useEffect)(()=>{if(!o)return;let e=e=>{c.current&&!c.current.contains(e.target)&&d(!1)},t=e=>{"Escape"===e.key&&d(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[o]),(0,r.jsxs)("div",{ref:c,className:"relative ".concat(n," max-w-full"),children:[(0,r.jsxs)("button",{type:"button","aria-haspopup":"listbox","aria-expanded":o,onClick:()=>d(e=>!e),className:"w-full border border-black rounded-full px-4 py-2 text-sm text-left focus:outline-none hover:bg-gray-50 bg-white flex items-center gap-2 font-light text-[#2d2d2d]",children:[(0,r.jsx)("span",{className:"flex-1 min-w-0 truncate",children:u}),(0,r.jsx)("svg",{className:"shrink-0 w-4 h-4 text-gray-500 transition-transform ".concat(o?"rotate-180":""),viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":!0,children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]}),o&&(0,r.jsxs)("ul",{role:"listbox",className:"absolute z-30 mt-1 left-0 right-0 max-h-64 overflow-y-auto rounded-xl border border-gray-200 bg-white shadow-lg py-1",children:[(0,r.jsx)("li",{role:"option","aria-selected":"all"===t,children:(0,r.jsx)("button",{type:"button",className:"w-full text-left px-4 py-2 text-sm whitespace-normal break-words hover:bg-gray-50 ".concat("all"===t?"bg-[#E7FFA9]/70 font-medium":""),onClick:()=>{a("all"),d(!1)},children:l})}),i.map(e=>(0,r.jsx)("li",{role:"option","aria-selected":t===e,children:(0,r.jsx)("button",{type:"button",className:"w-full text-left px-4 py-2 text-sm whitespace-normal break-words hover:bg-gray-50 ".concat(t===e?"bg-[#E7FFA9]/70 font-medium":""),onClick:()=>{a(e),d(!1)},children:e})},e))]})]})}let G=[10,20,50,100],H={topServices:{title:"Servicios m\xe1s vendidos",insightKey:"topServices",variant:"catalog"},topProducts:{title:"Productos m\xe1s vendidos",insightKey:"topProducts",variant:"catalog"},topServiceCategories:{title:"Categorias de servicios mas vendidas",insightKey:"topServiceCategories",variant:"catalog"},topProductCategories:{title:"Categorias de productos mas vendidas",insightKey:"topProductCategories",variant:"catalog"},topExtras:{title:"Extras m\xe1s vendidos",insightKey:"topExtras",variant:"catalog"},topPacks:{title:"Packs m\xe1s vendidos",insightKey:"topPacks",variant:"catalog"},employeesByRevenue:{title:"M\xe1s facturaci\xf3n",insightKey:"employeesByRevenue",variant:"employee",metric:"revenue"},employeesByServiceUnits:{title:"M\xe1s servicios (unidades)",insightKey:"employeesByServiceUnits",variant:"employee",metric:"serviceUnits"},employeesByCommission:{title:"M\xe1s comisiones",insightKey:"employeesByCommission",variant:"employee",metric:"commission"},employeesByProductUnits:{title:"M\xe1s productos (unidades)",insightKey:"employeesByProductUnits",variant:"employee",metric:"productUnits"},employeesByAvgTicket:{title:"Ticket medio",insightKey:"employeesByAvgTicket",variant:"employee",metric:"avgTicket"},employeesByRevenuePerHour:{title:"M\xe1s facturaci\xf3n / hora",insightKey:"employeesByRevenuePerHour",variant:"employee",metric:"revenuePerHour"}},K={labels:[],revenueData:[],groupBy:"date",totalRevenue:0,totalCollected:0,totalPendingDebt:0,totalAppointments:0,totalServicesSold:0,totalProductsSold:0,serviceRevenueData:[],productRevenueData:[],paymentMethodStats:{cash:0,card:0,bizum:0,crypto:0,
1custom:[]},absenceRevenue:0,revenuePerService:{},revenuePerProduct:{},revenuePerServiceCategory:{},revenuePerProductCategory:{},billingInsights:{topServices:[],topProducts:[],topServiceCategories:[],topProductCategories:[],topExtras:[],topPacks:[],employeesByRevenue:[],employeesByServiceUnits:[],employeesByProductUnits:[],employeesByAvgTicket:[],employeesByRevenuePerHour:[],employeesByCommission:[]}};t.default=()=>{var e,t,a,i,D,U,V,q,z,Q,W,Y,J,X;let $=(0,l.v9)(e=>{var t;return(null===(t=e.company)||void 0===t?void 0:t.name)||""}),ee=(0,l.v9)(e=>e.company),et=(0,A.Xz)(ee),ea=(0,Z.f)(ee),er=(0,Z.c)(ee),[es,el]=(0,s.useState)((()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-30),{startDate:t.toISOString().split("T")[0],endDate:e.toISOString().split("T")[0]}})()),ei=(0,s.useRef)(null),en=(0,s.useRef)(0),[eo,ed]=(0,s.useState)({}),[ec,eu]=(0,s.useState)(null),[em,ex]=(0,s.useState)(!0),[eg,ep]=(0,s.useState)([]),[eb,eh]=(0,s.useState)(!0),[ev,ey]=(0,s.useState)("all"),[ef,ej]=(0,s.useState)([]),[ew,eN]=(0,s.use
1State)(0),[eS,eD]=(0,s.useState)([]),[ek,eC]=(0,s.useState)(""),[eP,eE]=(0,s.useState)(!1),[eM,eF]=(0,s.useState)(!1),[eT,eR]=(0,s.useState)("services"),[e_,eB]=(0,s.useState)("all"),[eA,eZ]=(0,s.useState)("all"),[eL,eI]=(0,s.useState)(!1),[eO,eG]=(0,s.useState)(0),eH=(0,s.useRef)(null),eK=(0,s.useRef)(0),eU=(0,s.useRef)(0),[eV,eq]=(0,s.useState)("general"),[ez,eQ]=(0,s.useState)("datos"),[eW,eY]=(0,s.useState)(null),[eJ,eX]=(0,s.useState)(!1),[e$,e0]=(0,s.useState)(3),[e1,e2]=(0,s.useState)("current"),[e4,e5]=(0,s.useState)(""),[e3,e7]=(0,s.useState)("accumulated"),[e6,e9]=(0,s.useState)(()=>new Date().getMonth()+1),[e8,te]=(0,s.useState)(5),[tt,ta]=(0,s.useState)(!1),[tr,ts]=(0,s.useState)(!1),[tl,ti]=(0,s.useState)(!1),tn=(0,s.useMemo)(()=>{let e=et?[{id:"general",label:"General"},{id:"statistics",label:"Estad\xedsticas"},{id:"services",label:"Servicios"},{id:"products",label:"Productos"},{id:"employees",label:"Empleados"},{id:"tickets",label:"Tickets"},{id:"ranking",label:"Ranking"}]:[{id:"general",label:"General"},{id:"tickets",label:"Tickets"}];if(!ea)return e;let t=[{id:"cierre-diario",label:"Cierre diario"}];return er&&t.push({id:"asientos",label:"Asientos"}),[...e,...t]},[et,ea,er]);(0,s.useEffect)(()=>{et||"general"===eV||"tickets"===eV||"cierre-diario"===eV||"asientos"===eV||eq("general")},[et,eV]),(0,s.useEffect)(()=>{ea||"cierre-diario"!==eV||eq("general")},[ea,eV]),(0,s.useEffect)(()=>{er||"asientos"!==eV||eq("general")},[er,eV]);
1let[to,td]=(0,s.useState)({open:!1,kind:null,title:"",limit:20,variant:"catalog",employeeMetric:null,rows:[],loading:!1}),[tc,tu]=(0,s.useState)(!1),[tm,tx]=(0,s.useState)(!1),[tg,tp]=(0,s.useState)(0),[tb,th]=(0,s.useState)(0),[tv,ty]=(0,s.useState)(0),[tf,tj]=(0,s.useState)(0),[tw,tN]=(0,s.useState)(!0),[tS,tD]=(0,s.useState)(!0),[tk,tC]=(0,s.useState)(!0),[tP,tE]=(0,s.useState)(null),[tM,tF]=(0,s.useState)(!0),[tT,tR]=(0,s.useState)(null),[t_,tB]=(0,s.useState)(!0),[tA,tZ]=(0,s.useState)(null),[tL,tI]=(0,s.useState)(!0),[tO,tG]=(0,s.useState)(null),[tH,tK]=(0,s.useState)(null);(0,s.useEffect)(()=>{let e=!1;return(async()=>{let t=eS.find(e=>String(e._id)===String(ek)),a=eS.length>=2&&!!(null==t?void 0:t.isHeadquarters),r=await (0,u.listEmployees)(a?{groupAll:1}:void 0);!e&&(null==r?void 0:r.success)&&Array.isArray(r.data)&&ej(r.data)})(),()=>{e=!0}},[eS,ek]),(0,s.useEffect)(()=>{let e=!1;return(async()=>{try{var t;let a=await (0,u.pHS)();if(e)return;if(!(null==a?void 0:a.canSwitchGroupSalons)||!Array.isArray(a.data)||a.data.length<2){eD([]);return}eD(a.data);let r=(0,m.R6)(),s=new Set(a.data.map(e=>String(e._id))),l=r&&s.has(r)&&r||a.activeCompanyId||a.homeCompanyId||String((null==ee?void 0:ee.id)||(null==ee?void 0:ee._id)||"")||String((null===(t=a.data[0])||void 0===t?void 0:t._id)||"");eC(String(l))}catch(t){e||eD([])}})(),()=>{e=!0}},[null==ee?void 0:ee.id,null==ee?void 0:ee._id]);let tU=e=>{let t=String(e||"");t&&t!==String(ek)&&(eE(!1),eC(t),(0,m.tI)(t),ey("all"),window.location.reload())},tV=(0,s.useMemo)(()=>{if(!ek||0===eS.length)return"Sal\xf3n";let e=eS.find(e=>String(e._id)===String(ek));return e?e.isHeadquarters?"Todos los salones":e.name:"Sal\xf3n"},[eS,ek]),tq=(0,s.useMemo)(()=>{if("all"===ev)return"Todos";let e=ef.find(e=>String(e._id||e.employeeId)===String(ev));if(!e)return"Empleado";let t=e.employeeName||e.name||"Empleado";return e.salonName?"".concat(t," \xb7 ").concat(e.salonName):t},[ef,ev]);(0,s.useEffect)(()=>{let e=!1;return(async()=>{var t;if(!es.startDate||!es.endDate){tp(0),th(0),tN(!1),tD(!1);return}tN(!0),tD(!0);let a={startDate:es.startDate,endDate:es.endDate},r=await Promise.allSettled([(0,u.hi7)(a),(0,u.O_D)(a)]);if(e)return;let[s,l]=r;"fulfilled"===s.status&&tp(null!==(t=s.value)&&void 0!==t?t:0),"fulfilled"===l.status&&th(Number(l.value)||0),tN(!1),tD(!1)})(),()=>{e=!0}},[es.startDate,es.endDate]),(0,s.useEffect)(()=>{(async()=>{tF(!0);try{let e={};(null==es?void 0:es.startDate)&&(null==es?void 0:es.endDate)&&(e.startDate=es.startDate,e.endDate=es.endDate),ev&&"all"!==ev&&(e.stylistId=ev);let t=await (0,u.IJ8)(e);(null==t?void 0:t.success)&&tE(t)}catch(e){}finally{tF(!1)}})()},[null==es?void 0:es.startDate,null==es?void 0:es.endDate,ev]),(0,s.useEffect)(()=>{let e=!1,t=++eK.current,a=e=>{if(ed(e),ty(Number(null==e?void 0:e.totalServicesSold)||0),tj(Number(null==e?void 0:e.totalProductsSold)||0),e.revenuePerService){let t=Object.keys(e.revenuePerService),a=Object.values(e.revenuePerService);tR({labels:t,data:a,total:a.reduce((e,t)=>e+t,0),meta:Array.isArray(e.revenuePerServiceMeta)?e.revenuePerServiceMeta:[]})}else tR(null);if(e.revenuePerProduct){let t=Object.keys(e.revenuePerProduct),a=Object.values(e.revenuePerProduct);tZ({labels:t,data:a,total:a.reduce((e,t)=>e+t,0),meta:Array.isArray(e.revenuePerProductMeta)?e.revenuePerProductMeta:[]})}else tZ(null);if(e.revenuePerServiceCategory){let t=Object.keys(e.revenuePerServiceCategory),a=Object.values(e.revenuePerServiceCategory);tG({labels:t,data:a,total:a.reduce((e,t)=>e+Number(t||0),0)})}else tG(null);if(e.revenuePerProductCategory){let t=Object.keys(e.revenuePerProductCategory),a=Object.values(e.revenuePerProductCategory);tK({labels:t,data:a,total:a.reduce((e,t)=>e+Number(t||0),0)})}else tK(null);let t=e.totalRevenue||0,a=e.totalAppointments||0;eN(a>0?t/a:0)};return(async()=>{ex(!0),tB(!0),tI(!0),tC(!0);try{if(!es.startDate||!es.endDate){eH.current=null,eG(e=>e+1),ed(K),eu(null),eN(0),ty(0),tj(0),tR(null),tZ(null),tG(null),tK(null);return}eu(null);let r={startDate:es.startDate,endDate:es.endDate},s=await (0,u.Ghx)(void 0,r,"date",ev);if(e||eK.current!==t)return;eH.current=s,a(s),eG(e=>e+1)}catch(a){if(console.error("Error fetching revenue data",a),e||eK.current!==t)return;eH.current=null,eG(e=>e+1),eu((null==a?void 0:a.message)||"Error al cargar datos de facturaci\xf3n"),ed(K),tR(null),tZ(null),tG(null),tK(null),eN(0),ty(0),tj(0),B.ZP.error("No se pudieron cargar los datos de facturaci\xf3n")}
1finally{e||eK.current!==t||(ex(!1),tB(!1),tI(!1),tC(!1))}})(),()=>{e=!0}},[es.startDate,es.endDate,ev]),(0,s.useEffect)(()=>{let e=e_&&"all"!==e_?e_:void 0,t=eA&&"all"!==eA?eA:void 0;if(!es.startDate||!es.endDate||!eH.current)return;if(!e&&!t){ed(eH.current),eI(!1);return}let a=!1,r=++eU.current;return(async()=>{eI(!0);try{var s,l,i,n,o,d,c;let m={startDate:es.startDate,endDate:es.endDate},x=await (0,u.Ghx)(void 0,m,"date",ev,e,t);if(a||eU.current!==r)return;let g=eH.current||{};ed({...g,labels:null!==(s=null==x?void 0:x.labels)&&void 0!==s?s:g.labels,revenueData:null!==(l=null==x?void 0:x.revenueData)&&void 0!==l?l:g.revenueData,serviceRevenueData:null!==(i=null==x?void 0:x.serviceRevenueData)&&void 0!==i?i:g.serviceRevenueData,productRevenueData:null!==(n=null==x?void 0:x.productRevenueData)&&void 0!==n?n:g.productRevenueData,totalRevenue:null!==(o=null==x?void 0:x.totalRevenue)&&void 0!==o?o:g.totalRevenue,totalAppointments:null!==(d=null==x?void 0:x.totalAppointments)&&void 0!==d?d:g.totalAppointments,paymentMethodStats:null!==(c=null==x?void 0:x.paymentMethodStats)&&void 0!==c?c:g.paymentMethodStats})}catch(e){console.error("Error filtering chart revenue:",e),a||B.ZP.error("No se pudo filtrar la gr\xe1fica")}finally{a||eU.current!==r||eI(!1)}})(),()=>{a=!0}},[e_,eA,es.startDate,es.endDate,ev,eO]);let tz=(0,s.useMemo)(()=>{if(!eo||!eo.labels)return eo||{labels:[],revenueData:[],groupBy:"date"};if("products"===eT)return eo.productRevenueData&&Array.isArray(eo.productRevenueData)&&eo.productRevenueData.length>0?{...eo,revenueData:eo.productRevenueData,groupBy:"date"}:{labels:eo.labels||[],revenueData:eo.labels?eo.labels.map(()=>0):[],groupBy:"date"};if("services"===eT)return eo.serviceRevenueData&&Array.isArray(eo.serviceRevenueData)?{...eo,revenueData:eo.serviceRevenueData,groupBy:"date"}:eo;if("total"===eT){let e=eo.serviceRevenueData&&Array.isArray(eo.serviceRevenueData)?eo.serviceRevenueData:eo.labels?eo.labels.map(()=>0):[],t=eo.productRevenueData&&Array.isArray(eo.productRevenueData)?eo.productRevenueData:eo.labels?eo.labels.map(()=>0):[],a=eo.labels.map((a,r)=>(e[r]||0)+(t[r]||0));return{...eo,revenueData:a,groupBy:"date"}}return eo},[eo,eT]);(0,s.useEffect)(()=>{(async()=>{eh(!0);try{if(!es.startDate||!es.endDate){ep({labels:[],revenueData:[],groupBy:"date",totalCitas:0});return}let e=await (0,u.Gq2)({startDate:es.startDate,endDate:es.endDate,status:"Completed",..."all"!==ev&&{stylistId:ev}}),t=Array.isArray(null==e?void 0:e.data)?e.data:[],a=new Map(t.map(e=>[e.date,Number(e.count)||0])),r={},s=new Date("".concat(es.startDate,"T12:00:00")),l=new Date("".concat(es.endDate,"T12:00:00")),i=0,n=e=>String(e).padStart(2,"0");for(let e=new Date(s);e<=l;e.setDate(e.getDate()+1)){let t="".concat(e.getFullYear(),"-").concat(n(e.getMonth()+1),"-").concat(n(e.getDate())),s=e.toLocaleDateString("es-ES",{day:"2-digit",month:"2-digit"}),l=a.get(t)||0;r[s]=l,i+=l}ep({groupBy:"date",labels:Object.keys(r),revenueData:Object.values(r),totalCitas:i})}catch(e){console.error("Error fetching appointments data",e),ep({labels:[],revenueData:[],groupBy:"date",totalCitas:0}),B.ZP.error("No se pudieron cargar las citas del periodo")}finally{eh(!1)}})()},[es.startDate,es.endDate,ev]),(0,s.useEffect)(()=>{if("statistics"!==eV)return;let e=!1;return(async()=>{eX(!0),eY(null);try{let t=await (0,u.PP4)({employeeId:ev,compareMonth:e6,compareYearSpan:e8});e||eY(t)}catch(t){e||(eY(null),B.ZP.error("No se pudieron cargar las estad\xedsticas de citas"))}finally{e||eX(!1)}})(),()=>{e=!0}},[eV,ev,e6,e8]),(0,s.useEffect)(()=>{("statistics"===eV||"services"===eV||"products"===eV||"employees"===eV)&&eQ("datos")},[eV]);let tQ=(0,s.useMemo)(()=>(null==tO?void 0:tO.labels)?[...tO.labels]:[],[tO]),tW=(0,s.useMemo)(()=>(null==tH?void 0:tH.labels)?[...tH.labels]:[],[tH]),tY=(0,s.useMemo)(()=>{let e=(null==tT?void 0:tT.labels)||[],t=(0,x.CM)((null==tT?void 0:tT.meta)||[]);return e.map(e=>({value:e,label:e,badge:t.get(e)||void 0}))},[tT]),tJ=(0,s.useMemo)(()=>{let e=(null==tA?void 0:tA.labels)||[],t=(0,x.CM)((null==tA?void 0:tA.meta)||[]);return e.map(e=>({value:e,label:e,badge:t.get(e)||void 0}))},[tA]),tX=(0,s.useMemo)(()=>
1{if("all"===ev)return"Todos los empleados";let e=ef.find(e=>String(e._id||e.employeeId)===String(ev));if(!e)return"Empleado seleccionado";let t=e.employeeName||"Empleado seleccionado";if(e.salonName){let a=e.salonIsHeadquarters?"Central":e.salonName;return"".concat(t," \xb7 ").concat(a)}return t},[ev,ef]);(0,s.useEffect)(()=>{if("statistics"!==eV||!eW)return;let e=eW.previousMonths||[];e2("current"),e5(e[0]?"".concat(e[0].year,"-").concat(e[0].month):"")},[eV,eW,ev]);let t$=async()=>{if(!es.startDate||!es.endDate){B.ZP.error("Selecciona un rango de fechas");return}let e=await (0,o.sf)({startDate:es.startDate,endDate:es.endDate,selectedEmployee:ev,employees:ef,salonName:$});e.success?B.ZP.success("PDF exportado correctamente"):B.ZP.error(e.message||"Error al generar PDF")},t0=async()=>{if(!es.startDate||!es.endDate){B.ZP.error("Selecciona un rango de fechas");return}ts(!0);try{let e=await (0,d.hJ)({startDate:es.startDate,endDate:es.endDate,selectedEmployee:ev,employees:ef,salonName:$});e.success?B.ZP.success("Excel exportado correctamente"):B.ZP.error(e.message||"Error al generar Excel")}finally{ts(!1)}},t1=async()=>{if(!es.startDate||!es.endDate){B.ZP.error("Selecciona un rango de fechas");return}let e="services"===eT&&"all"!==e_?e_:void 0,t="products"===eT&&"all"!==eA?eA:void 0;ta(!0);try{let a=await (0,o.gt)({startDate:es.startDate,endDate:es.endDate,selectedEmployee:ev,employees:ef,salonName:$,serviceName:e,productName:t});a.success?B.ZP.success("PDF de ranking descargado"):B.ZP.error(a.message||"Error al generar el PDF")}finally{ta(!1)}},t2=async()=>{if(!es.startDate||!es.endDate){B.ZP.error("Selecciona un rango de fechas");return}let e="services"===eT&&"all"!==e_?e_:void 0,t="products"===eT&&"all"!==eA?eA:void 0;ti(!0);try{let a=await (0,d.HK)({startDate:es.startDate,endDate:es.endDate,selectedEmployee:ev,employees:ef,salonName:$,serviceName:e,productName:t});a.success?B.ZP.success("Excel de ranking descargado"):B.ZP.error(a.message||"Error al generar el Excel")}finally{ti(!1)}},t4=(0,s.useCallback)(async(e,t)=>{var a,r;let s=H[e];if(!s||!es.startDate||!es.endDate)return;let l=++en.current;td(a=>{var r;return{...a,open:!0,kind:e,title:s.title,limit:t,variant:s.variant,employeeMetric:null!==(r=s.metric)&&void 0!==r?r:null,loading:!0,rows:[]}});let i=null==eo?void 0:null===(a=eo.billingInsights)||void 0===a?void 0:a[s.insightKey];if(Array.isArray(i)&&i.length>0){let e=t<=i.length;if(en.current!==l||(td(a=>({...a,loading:!e,rows:i.slice(0,Math.min(t,i.length))})),e))return}try{let e={startDate:es.startDate,endDate:es.endDate},a=e_&&"all"!==e_?e_:void 0,i=eA&&"all"!==eA?eA:void 0,n=await (0,u.Ghx)(void 0,e,"date",ev,a,i,void 0,t);if(en.current!==l)return;let o=Array.isArray(null==n?void 0:null===(r=n.billingInsights)||void 0===r?void 0:r[s.insightKey])?n.billingInsights[s.insightKey]:[];td(e=>({...e,loading:!1,rows:o}))}catch(e){if(console.error(e),en.current!==l)return;B.ZP.error("No se pudo cargar el ranking"),td(e=>{var t;return{...e,loading:!1,rows:(null===(t=e.rows)||void 0===t?void 0:t.length)?e.rows:[]}})}},[es.startDate,es.endDate,ev,e_,eA,null==eo?void 0:eo.billingInsights]),t5=e=>{t4(e,20)},t3=(0,s.useCallback)(()=>{td(e=>e.loading||tc||tm?e:(en.current+=1,{open:!1,kind:null,title:"",limit:20,variant:"catalog",employeeMetric:null,rows:[],loading:!1}))},[tc,tm]),t7=async()=>{if(!to.open||to.loading||!to.kind){B.ZP.error("Espera a que termine de cargar el ranking");return}if(!es.startDate||!es.endDate){B.ZP.error("Selecciona un rango de fechas");return}tu(!0);try{let e=await (0,o.yM)({startDate:es.startDate,endDate:es.endDate,selectedEmployee:ev,employees:ef,salonName:$,rankingTitle:"Top ".concat(to.limit," â ").concat(to.title),variant:to.variant,employeeMetric:to.employeeMetric,rows:to.rows});e.success?B.ZP.success("PDF del ranking descargado"):B.ZP.error(e.message||"Error al generar el PDF")}finally{tu(!1)}},t6=async()=>{if(!to.open||to.loading||!to.kind){B.ZP.error("Espera a que termine de cargar el ranking");return}if(!es.startDate||!es.endDate){B.ZP.error("Selecciona un rango de fechas");return}tx(!0);
1try{let e=await (0,d.Ly)({startDate:es.startDate,endDate:es.endDate,selectedEmployee:ev,employees:ef,salonName:$,rankingTitle:"Top ".concat(to.limit," â ").concat(to.title),variant:to.variant,employeeMetric:to.employeeMetric,rows:to.rows});e.success?B.ZP.success("Excel del ranking descargado"):B.ZP.error(e.message||"Error al generar el Excel")}finally{tx(!1)}};return(0,r.jsx)("div",{className:n().dashboardContainer,children:(0,r.jsxs)("div",{className:n().leftSection,children:[(0,r.jsx)("div",{className:"bg-white rounded-xl border border-gray-200 px-6 py-4 mb-4",children:(0,r.jsx)("h1",{className:"text-xl font-semibold text-gray-800 m-0",children:"Facturaci\xf3n"})}),(0,r.jsx)("div",{className:"bg-white rounded-xl border border-gray-200 p-5 mb-6",children:(0,r.jsxs)("div",{className:"flex items-end gap-4 flex-wrap",children:[eS.length>=2&&(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)("label",{className:"text-xs text-gray-500 font-medium",children:"Sal\xf3n"}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{eF(!1),eE(e=>!e)},className:"px-4 py-2 rounded-full border border-black bg-white text-[#2d2d2d] text-sm font-light hover:bg-gray-50 transition-all whitespace-nowrap min-w-[180px] text-left","aria-label":"Elegir facturaci\xf3n del sal\xf3n","aria-expanded":eP,children:[tV," â¾"]}),eP&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 z-[19]",onClick:()=>eE(!1),"aria-hidden":"true"}),(0,r.jsx)("div",{className:"absolute left-0 mt-1 min-w-[220px] rounded-xl border border-gray-200 bg-white shadow-lg z-20 py-1 max-h-64 overflow-y-auto",children:eS.map(e=>{let t=String(e._id),a=e.isHeadquarters?"Todos los salones":e.name,s=t===String(ek);return(0,r.jsx)("button",{type:"button",className:"block w-full text-left px-4 py-2 text-sm hover:bg-gray-50 ".concat(s?"font-medium bg-gray-50":""),onClick:()=>tU(t),children:a},t)})})]})]})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)("label",{className:"text-xs text-gray-500 font-medium",children:"Empleado"}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{eE(!1),eF(e=>!e)},className:"px-4 py-2 rounded-full border border-black bg-white text-[#2d2d2d] text-sm font-light hover:bg-gray-50 transition-all whitespace-nowrap min-w-[160px] text-left","aria-label":"Filtrar por empleado","aria-expanded":eM,children:[tq," â¾"]}),eM&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 z-[19]",onClick:()=>eF(!1),"aria-hidden":"true"}),(0,r.jsxs)("div",{className:"absolute left-0 mt-1 min-w-[260px] rounded-xl border border-gray-200 bg-white shadow-lg z-20 py-1 max-h-64 overflow-y-auto",children:[(0,r.jsx)("button",{type:"button",className:"block w-full text-left px-4 py-2 text-sm hover:bg-gray-50 ".concat("all"===ev?"font-medium bg-gray-50":""),onClick:()=>{ey("all"),eF(!1)},children:"Todos"}),ef.map(e=>{let t=String(e._id||e.employeeId),a=t===String(ev),s=e.employeeName||e.name||"Empleado";return(0,r.jsx)("button",{type:"button",className:"block w-full text-left px-4 py-2 text-sm hover:bg-gray-50 ".concat(a?"font-medium bg-gray-50":""),onClick:()=>{ey(t),eF(!1)},children:(0,r.jsxs)("span",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"truncate",children:s}),e.salonName?(0,r.jsx)("span",{className:"shrink-0 text-[11px] font-medium text-gray-500 bg-gray-100 rounded-full px-2 py-0.5",children:e.salonIsHeadquarters?"Central":e.salonName}):null]})},t)})]})]})]})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)("label",{className:"text-xs text-gray-500 font-medium",children:"Desde"}),(0,r.jsx)(v.Z,{value:es.startDate,onChange:e=>{el(t=>({...t,startDate:e})),setTimeout(()=>{var e,t;return null===(t=ei.current)||void 0===t?void 0:null===(e=t.focus)||void 0===e?void 0:e.call(t)},0)},inputClassName:"border border-gray-300 rounded-full px-4 py-2 text-sm focus:outline-none focus:border-[#E7FFA9]"})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)("label",{className:"text-xs text-gray-500 font-medium",children:"Hasta"}),(0,r.jsx)(v.Z,{ref:ei,value:es.endDate,onChange:e=>el(t=>({...t,endDate:e})),inputClassName:"border border-gray-300 rounded-full px-4 py-2 text-sm focus:outline-none focus:border-[#
1E7FFA9]"})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)("label",{className:"text-xs text-gray-500 font-medium",children:"Facturaci\xf3n total:"}),(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[!em&&(0,r.jsx)("span",{className:"bg-[#E7FFA9] text-gray-900 font-semibold px-5 py-2 rounded-full text-sm",children:(0,P.T4)((null==eo?void 0:eo.totalRevenue)!==void 0?eo.totalRevenue:Object.values((null==eo?void 0:eo.revenuePerService)||{}).reduce((e,t)=>e+(Number(t)||0),0)+Object.values((null==eo?void 0:eo.revenuePerProduct)||{}).reduce((e,t)=>e+(Number(t)||0),0))}),(0,r.jsx)("button",{type:"button",onClick:t$,disabled:tr||em,className:"px-4 py-2 rounded-full border border-gray-300 bg-white text-gray-700 text-sm font-medium hover:bg-gray-50 transition-all whitespace-nowrap disabled:opacity-50 disabled:cursor-not-allowed",children:"Exportar PDF"}),(0,r.jsx)("button",{type:"button",onClick:t0,disabled:tr||em,className:"px-4 py-2 rounded-full border border-gray-300 bg-white text-gray-700 text-sm font-medium hover:bg-gray-50 transition-all whitespace-nowrap disabled:opacity-50 disabled:cursor-not-allowed",children:tr?"Generando Excelâ¦":"Exportar Excel"})]})]})]})}),ec&&(0,r.jsx)("div",{className:"mb-4 px-4 py-3 bg-red-50 border border-red-200 rounded-xl text-sm text-red-800",children:ec}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1 mb-4 border-b border-gray-200 bg-white rounded-t-xl px-2 pt-1 overflow-hidden",role:"tablist",children:tn.map(e=>(0,r.jsx)("button",{type:"button",role:"tab","aria-selected":eV===e.id,onClick:()=>eq(e.id),className:"px-4 py-2.5 text-sm font-medium rounded-t-lg border-b-2 -mb-px transition-colors whitespace-nowrap shrink-0 ".concat(eV===e.id?"border-gray-900 text-gray-900 bg-gray-50":"border-transparent text-gray-500 hover:text-gray-800"),children:e.label},e.id))}),"general"===eV&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:n().statsGrid,children:c.G8.map(e=>(0,r.jsxs)("div",{className:"bg-white rounded-xl border border-gray-200 p-4 flex items-center gap-3",children:[(0,r.jsx)("div",{className:"text-gray-500",children:e.icon}),(0,r.jsxs)("div",{className:"flex flex-col",children:[(0,r.jsx)("span",{className:"text-xs text-gray-500 font-normal",children:e.title}),(0,r.jsx)("span",{className:"text-2xl font-semibold text-gray-900",children:e.title===C.bc.APPOINTMENTS?tS?(0,r.jsx)(N.O,{width:"60px",height:"28px",borderRadius:"4px"}):Math.trunc(Number(tb||0)).toString():e.title===C.bc.SERVICES?tk?(0,r.jsx)(N.O,{width:"60px",height:"28px",borderRadius:"4px"}):Math.trunc(Number(tv||0)).toString():e.title===C.bc.PRODUCTS?tk?(0,r.jsx)(N.O,{width:"60px",height:"28px",borderRadius:"4px"}):Math.trunc(Number(tf||0)).toString():e.title===C.bc.CUSTOMERS?tw?(0,r.jsx)(N.O,{width:"60px",height:"28px",borderRadius:"4px"}):Math.trunc(Number(tg||0)).toString():0})]})]},e.id))}),(0,r.jsxs)("div",{className:"bg-[#E7FFA9] rounded-xl p-4 flex items-center justify-between mb-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-gray-800",children:"Ticket medio"}),(0,r.jsx)("p",{className:"text-xs text-gray-600",children:"Promedio por cita completada."})]}),(0,r.jsx)("div",{className:"text-right",children:em?(0,r.jsx)(N.O,{width:"80px",height:"32px",borderRadius:"4px"}):(0,r.jsx)("span",{className:"text-3xl font-bold text-gray-900",children:(0,P.T4)(ew)})})]}),(0,r.jsxs)("div",{className:"bg-[#E7FFA9] rounded-xl p-4 flex items-center justify-between mb-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-gray-800",children:"Cobros por ausencias"}),(0,r.jsx)("p",{className:"text-xs text-gray-600",children:"Total cobrado por ausencias en el per\xedodo."})]}),(0,r.jsx)("div",{className:"text-right",children:em?(0,r.jsx)(N.O,{width:"80px",height:"32px",borderRadius:"4px"}):(0,r.jsx)("span",{className:"text-3xl font-bold text-gray-900",children:(0,P.T4)((null==eo?void 0:eo.absenceRevenue)||0)})})]}),(0,r.jsx)("div",{className:"bg-white rounded-xl border border-gray-200 px-6 py-4 mb-4",children:(0,r.jsx)("h2",{className:"text-sm font-medium text-gray-800 m-0",children:"Desglose por m\xe9todo de pago"})}),(0,r.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mb-6",children:(0,_.l)(eo).map(e=>{let t="cash"===e.key?M.Z:"card"===e.key?F.Z:"bizum"===e.key?T.Z:"crypto"===e.key?R.Z:null;return(0,r.jsxs)("div",{className:"bg-white rounded-xl border border-gray-200 p-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 mb-2",children:[(0,r.jsx)("div",{className:"p-2 bg-gray-50 rounded-lg",children:t?(0,r.jsx)(E.default,{src:t,alt:e.label,className:"w-6 h-6"}):(0,r.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"#4d7c0f",strokeWidth:"1.6","aria-hidden":"true",children:[(0,r.jsx)("rect",{x:"3",y:"6",width:"18",height:"12",rx:"2"}),(0,r.jsx)("path",{d:"M3 10h18"}),(0,r.jsx)("path",{d:"M7 15h4"})]})}),(0,r.jsx)("span",{className:"text-sm text-gray-500 font-medium",children:e.label})]}),em?(0,r.jsx)(N.O,{width:"100px",height:"32px",borderRadius:"4px"}):(0,r.jsx)("span",{className:"text-2xl font-bold text-gray-900",children:(0,P.T4)(e.amount)}),e.detail?(0,r.jsx)("p",{className:"text-[10px] text-gray-400 mt-1",children:e.detail}):null]},e.key)})}),(0,r.jsx)("p",{className:"text-xs text-gray-600 mb-4 px-1 leading-relaxed",children:"Gr\xe1ficas del periodo seleccionado arriba (fechas y empleado). Para comparar intervalos distintos, cambia el rango de fechas y revisa de nuevo."}),(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 mb-4",style:{alignItems:"stretch"},children:[(0,r.jsxs)("div",{className:"bg-white rounded-xl border border-gray-200 p-6 flex flex-col",style:{minHeight:"340px"},children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-gray-700 text-center mb-4",children:C.lD}),(0,r.jsx)("div",{className:"flex-1 flex flex-col",children:(0,r.jsx)(j.Z,{statsData:tP,isLoading:tM})})]}),(0,r.jsxs)("div",{className:"bg-white rounded-xl border border-gray-200 p-6 flex flex-col",style:{minHeight:"340px"},children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-gray-700 text-center mb-4",children:"Servicios vendidos"}),(0,r.jsx)("div",{className:"flex-1 flex flex-col",children:(0,r.jsx)(w.Z,{statsData:tT,isLoading:t_,title:"Servicios",colors:["#E7FFA9","#2d2d2d","#9ca3af","#d1d5db","#6b7280","#374151"]})})]}),(0,r.jsxs)("div",{className:"bg-white rounded-xl border border-gray-200 p-6 flex flex-col",style:{minHeight:"340px"},children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-gray-700 text-center mb-4",children:"Productos vendidos"}),(0,r.jsx)("div",{className:"flex-1 flex flex-col",children:(0,r.jsx)(w.Z,{statsData:tA,isLoading:tL,title:"Productos",colors:["#E7FFA9","#2d2d2d","#9ca3af","#d1d5db","#6b7280","#374151"]})})]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-6 max-w-4xl mx-auto md:max-w-none",style:{alignItems:"stretch"},children:[(0,r.jsxs)("div",{className:"bg-white rounded-xl border border-gray-200 p-6 flex flex-col",style:{minHeight:"340px"},children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-gray-700 text-center mb-4",children:"Categor\xedas de servicios"}),(0,r.jsx)("div",{className:"flex-1 flex flex-col",children:(0,r.jsx)(w.Z,{statsData:tO,isLoading:t_,title:"Categor\xedas servicios",colors:["#E7FFA9","#2d2d2d","#9ca3af","#d1d5db","#6b7280","#374151"]})})]}),(0,r.jsxs)("div",{className:"bg-white rounded-xl border border-gray-200 p-6 flex flex-col",style:{minHeight:"340px"},children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-gray-700 text-center mb-4",children:"Categor\xedas de productos"}),(0,r.jsx)("div",{className:"flex-1 flex flex-col",children:(0,r.jsx)(w.Z,{statsData:tH,isLoading:tL,title:"Categor\xedas productos",colors:["#E7FFA9","#2d2d2d","#9ca3af","#d1d5db","#6b7280","#374151"]})})]})]}),(0,r.jsxs)("div",{className:"bg-white rounded-xl border border-gray-200 mb-6",children:[(0,r.jsx)("div",{className:"p-5",children:(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-4",children:[(0,r.jsx)("h2",{className:"text-base font-semibold text-gray-800",children:"Gr\xe1ficas de facturaci\xf3n"}),(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{onClick:()=>{eR("services"),eB("all")},className:"px-5 py-2 text-sm font-medium rounded-full transition-all ".concat("services"===eT?"bg-black text-white":"bg-white text-gray-800 border border-gray-300 hover:bg-gray-50"),children:"Servicios"}),(0,r.jsx)("button",{onClick:()=>{eR("products"),eZ("all")},className:"px-5 py-2 text-sm font-medium rounded-full transition-all ".concat("products"===eT?"bg-black text-white":"bg-white text-gray-800 border border-gray-300 hover:bg-gray-50"),children:"Productos"}),(0,r.jsx)("button",{onClick:()=>{eR("total"),eB("all"),eZ("all")},className:"px-5 py-2 text-sm font-medium rounded-full transition-all ".concat("total"===eT?"bg-black text-white":"bg-white text-gray-800 border border-gray-300 hover:bg-gray-50"),children:"Total"})]}),"services"===eT&&(null==tT?void 0:null===(e=tT.labels)||void 0===e?void 0:e.length)>0&&(0,r.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,r.jsx)("label",{className:"text-xs text-gray-500 font-medium whitespace-nowrap",children:"Filtrar por:"}),(0,r.jsx)(O,{value:e_,onChange:eB,allLabel:"Todos los servicios",options:tT.labels})]}),"products"===eT&&(null==tA?void 0:null===(t=tA.labels)||void 0===t?void 0:t.length)>0&&(0,r.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,r.jsx)("label",{className:"text-xs text-gray-500 font-medium whitespace-nowrap",children:"Filtrar por:"}),(0,r.jsx)(O,{value:eA,onChange:eZ,allLabel:"Todos los productos",options:tA.labels})]})]})]})}),em?(0,r.jsx)("div",{className:"p-6",style:{backgroundColor:"#F5F5F5"},children:(0,r.jsx)(N.O,{width:"100%",height:"400px",shape:"square",borderRadius:"8px"})}):(0,r.jsx)("div",{style:{backgroundColor:"#F5F5F5"},className:eL?"opacity-60 transition-opacity":"transition-opacity",children:(0,r.jsx)(f.Z,{data:tz,isLoading:!1,chartType:"products"===eT?"products":"total"===eT?"total":"revenue"})})]}),(0,r.jsxs)("div",{className:"bg-white rounded-xl border border-gray-200 mb-6",children:[(0,r.jsx)("div",{className:"p-5",children:(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsx)("h2",{className:"text-base font-semibold text-gray-800",children:"Gr\xe1fico de citas"}),!eb&&(0,r.jsxs)("span",{className:"bg-[#E7FFA9] text-gray-900 font-semibold px-5 py-2 rounded-full text-sm",children:[(null==eg?void 0:eg.totalCitas)||0," cita",1!==((null==eg?void 0:eg.totalCitas)||0)?"s":""]})]})}),eb?(0,r.jsx)("div",{className:"p-6",style:{backgroundColor:"#F5F5F5"},children:(0,r.jsx)(N.O,{width:"100%",height:"400px",shape:"square",borderRadius:"8px"})}):(0,r.jsx)("div",{style:{backgroundColor:"#F5F5F5"},children:(0,r.jsx)(f.Z,{data:eg,isLoading:eb,chartType:"appointments"})})]})]}),et&&"ranking"===eV&&(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"bg-white rounded-xl border border-gray-200 px-6 py-4 mb-4",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3 mb-1",children:[(0,r.jsx)("h2",{className:"text-base font-semibold text-gray-800 m-0",children:"Rankings del periodo"}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2 justify-end shrink-0",children:[(0,r.jsx)("button",{type:"button",onClick:t1,disabled:tt||tl||em,className:"shrink-0 px-4 py-2 rounded-full border border-gray-300 bg-white text-gray-700 text-sm font-medium hover:bg-gray-50 transition-all disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap",children:tt?"Generando PDFâ¦":"Descargar ranking completo (PDF)"}),(0,r.jsx)("button",{type:"button",onClick:t2,disabled:tt||tl||em,className:"shrink-0 px-4 py-2 rounded-full border border-gray-300 bg-white text-gray-700 text-sm font-medium hover:bg-gray-50 transition-all disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap",children:tl?"Generando Excelâ¦":"Descargar ranking completo (Excel)"})]})]}),(0,r.jsx)("p",{className:"text-xs text-gray-500 m-0 mb-4",children:"Basado en ventas de caja del rango de fechas y el filtro de empleado. Los importes reparten el total del ticket entre l\xedneas seg\xfan su peso (misma l\xf3gica que el diario de ventas). En pantalla se muestran como m\xe1ximo 10 posiciones por lista; usa \xabVer m\xe1s\xbb en cada ranking para ampliar (10â100) y descargar solo ese listado en PDF o Excel. Los botones superiores descargan todos los rankings juntos. La facturaci\xf3n por hora usa las horas netas de fichaje en el mismo rango (entrada a salida menos pausas con fin registrado)."}),"all"!==ev?(0,r.jsx)("p",{className:"text-xs text-amber-900 bg-amber-50 border border-amber-100 rounded-lg px-3 py-2 mb-4",children:"Est\xe1s filtrando por un empleado: los rankings de equipo muestran solo las ventas atribuidas a esa persona."}):null,(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4 mb-6",children:[(0,r.jsx)(y.vQ,{title:"Servicios m\xe1s vendidos",rows:null==eo?void 0:null===(a=eo.billingInsights)||void 0===a?void 0:a.topServices,isLoading:em,onVerMore:()=>t5("topServices")}),(0,r.jsx)(y.vQ,{title:"Productos m\xe1s vendidos",rows:null==eo?void 0:null===(i=eo.billingInsights)||void 0===i?void 0:i.topProducts,isLoading:em,onVerMore:()=>t5("topProducts")}),(0,r.jsx)(y.vQ,{title:"Categorias de servicios mas vendidas",rows:null==eo?void 0:null===(D=eo.billingInsights)||void 0===D?void 0:D.topServiceCategories,isLoading:em,onVerMore:()=>t5("topServiceCategories")}),(0,r.jsx)(y.vQ,{title:"Categorias de productos mas vendidas",rows:null==eo?void 0:null===(U=eo.billingInsights)||void 0===U?void 0:U.topProductCategories,isLoading:em,onVerMore:()=>t5("topProductCategories")}),(0,r.jsx)(y.vQ,{title:"Extras m\xe1s vendidos",rows:null==eo?void 0:null===(V=eo.billingInsights)||void 0===V?void 0:V.topExtras,isLoading:em,onVerMore:()=>t5("topExtras")}),(0,r.jsx)(y.vQ,{title:"Packs m\xe1s vendidos",rows:null==eo?void 0:null===(q=eo.billingInsights)||void 0===q?void 0:q.topPacks,isLoading:em,onVerMore:()=>t5("topPacks")})]}),(0,r.jsx)("h3",{className:"text-sm font-semibold text-gray-800 mb
1-3",children:"Empleados (vista: top 10)"}),(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4 mb-2",children:[(0,r.jsx)(y.fx,{title:"M\xe1s facturaci\xf3n",subtitle:"Suma de importe atribuido en l\xedneas de venta.",rows:null==eo?void 0:null===(z=eo.billingInsights)||void 0===z?void 0:z.employeesByRevenue,isLoading:em,metric:"revenue",onVerMore:()=>t5("employeesByRevenue")}),(0,r.jsx)(y.fx,{title:"M\xe1s servicios (unidades)",subtitle:"Suma de cantidades en l\xedneas tipo servicio.",rows:null==eo?void 0:null===(Q=eo.billingInsights)||void 0===Q?void 0:Q.employeesByServiceUnits,isLoading:em,metric:"serviceUnits",onVerMore:()=>t5("employeesByServiceUnits")}),(0,r.jsx)(y.fx,{title:"M\xe1s comisiones",subtitle:"Suma de comisiones guardadas en cada ticket (desde que existe el desglose en pagos).",rows:null==eo?void 0:null===(W=eo.billingInsights)||void 0===W?void 0:W.employeesByCommission,isLoading:em,metric:"commission",onVerMore:()=>t5("employeesByCommission")}),(0,r.jsx)(y.fx,{title:"M\xe1s productos (unidades)",subtitle:"Suma de cantidades en l\xedneas tipo producto.",rows:null==eo?void 0:null===(Y=eo.billingInsights)||void 0===Y?void 0:Y.employeesByProductUnits,isLoading:em,metric:"productUnits",onVerMore:()=>t5("employeesByProductUnits")}),(0,r.jsx)(y.fx,{title:"Ticket medio",subtitle:"Facturaci\xf3n atribuida \xf7 n\xba de tickets en el periodo.",rows:null==eo?void 0:null===(J=eo.billingInsights)||void 0===J?void 0:J.employeesByAvgTicket,isLoading:em,metric:"avgTicket",onVerMore:()=>t5("employeesByAvgTicket")}),(0,r.jsx)(y.fx,{title:"M\xe1s facturaci\xf3n / hora",subtitle:"Facturaci\xf3n atribuida en el periodo \xf7 horas netas fichadas en el mismo rango. Solo aparecen empleados con fichajes cerrados y facturaci\xf3n en el periodo.",rows:null==eo?void 0:null===(X=eo.billingInsights)||void 0===X?void 0:X.employeesByRevenuePerHour,isLoading:em,metric:"revenuePerHour",onVerMore:()=>t5("employeesByRevenuePerHour")})]})]})}),et&&"statistics"===eV&&(0,r.jsx)(g.Z,{billingStats:eW,billingStatsLoading:eJ,billingStatsSubTab:ez,setBillingStatsSubTab:eQ,billingStatsHistoryMonths:e$,setBillingStatsHistoryMonths:e0,billingStatsCompareA:e1,setBillingStatsCompareA:e2,billingStatsCompareB:e4,setBillingStatsCompareB:e5,billingStatsCompareMode:e3,setBillingStatsCompareMode:e7,billingStatsCompareMonth:e6,setBillingStatsCompareMonth:e9,billingStatsCompareYearSpan:e8,setBillingStatsCompareYearSpan:te,selectedEmployee:ev,exportMeta:{salonName:$,sectionTitle:"Estad\xedsticas",employeeLegend:tX}}),et&&"services"===eV&&(0,r.jsx)(p.Z,{catalogType:"service",categoryOptions:tQ,itemOptions:tY,selectedEmployee:ev,scopeLabel:"servicios",salonName:$,salonBadgeFallback:eS.length>=2&&tV&&"Todos los salones"!==tV?tV:"",employeeLegend:tX,periodStart:es.startDate,periodEnd:es.endDate}),et&&"products"===eV&&(0,r.jsx)(p.Z,{catalogType:"product",categoryOptions:tW,itemOptions:tJ,selectedEmployee:ev,scopeLabel:"productos",salonName:$,salonBadgeFallback:eS.length>=2&&tV&&"Todos los salones"!==tV?tV:"",employeeLegend:tX,periodStart:es.startDate,periodEnd:es.endDate}),et&&"employees"===eV&&(0,r.jsx)(b.Z,{employees:ef,globalEmployeeId:ev,salonName:$,globalEmployeeLegend:tX,periodStart:es.startDate,periodEnd:es.endDate}),"tickets"===eV&&(0,r.jsx)(h.Z,{periodStart:es.startDate,periodEnd:es.endDate,selectedEmployee:ev,employees:ef,salonName:$,employeeLegend:tX}),ea&&"cierre-diario"===eV&&(0,r.jsx)(L.Z,{}),er&&"asientos"===eV&&(0,r.jsx)(I.Z,{}),(0,r.jsx)(S.V,{visible:to.open,onHide:()=>{to.loading||tc||tm||t3()},header:(0,r.jsxs)("div",{className:k().modalHeader,children:[(0,r.jsxs)("h2",{children:["Top ",to.limit," â ",to.title]}),(0,r.jsx)("button",{type:"button","data-close-button":"true",className:"cursor-pointer",disabled:to.loading||tc||tm,onClick:()=>{to.loading||tc||tm||t3()},"aria-label":"Cerrar",children:(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,r.jsx)("path",{d:"M1 1L13 13M1 13L13 1",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),closable:!1,modal:!0,dismissableMask:!to.loading&&!tc&&!tm,baseZIndex:1e6,style:{width:"min(720px, 94vw)",maxWidth:"760px",borderRadius:"24px"}
1,breakpoints:{"768px":"96vw","480px":"100vw"},contentStyle:{padding:0,maxHeight:"80vh",overflow:"hidden"},children:(0,r.jsxs)("div",{className:k().modalBody,style:{display:"block",gridTemplateColumns:"unset",gap:0},children:[(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-3",children:[(0,r.jsx)("p",{className:"text-xs text-gray-600 m-0 shrink-0",children:"Selecciona el tama\xf1o del ranking:"}),(0,r.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:G.map(e=>(0,r.jsx)("button",{type:"button",className:"px-3 py-1 rounded-full text-xs border ".concat(to.limit===e?"bg-black text-white border-black":"bg-white text-gray-800 border-gray-200 hover:border-gray-300"),disabled:to.loading||tc||tm||!to.kind,onClick:()=>{to.loading||tc||tm||e===to.limit||t4(to.kind,e)},children:e},e))})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2 justify-end mb-3 pb-3 border-b border-gray-100",children:[(0,r.jsx)("button",{type:"button",onClick:t7,disabled:to.loading||tc||tm,className:"shrink-0 px-4 py-2 rounded-full border border-gray-300 bg-white text-gray-700 text-sm font-medium hover:bg-gray-50 transition-all disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap",children:tc?"Generando PDFâ¦":"Descargar PDF"}),(0,r.jsx)("button",{type:"button",onClick:t6,disabled:to.loading||tc||tm,className:"shrink-0 px-4 py-2 rounded-full border border-gray-300 bg-white text-gray-700 text-sm font-medium hover:bg-gray-50 transition-all disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap",children:tm?"Generando Excelâ¦":"Descargar Excel"})]}),(0,r.jsx)("div",{className:"rounded-xl border border-gray-200 bg-white p-3",style:{maxHeight:"62vh",overflowY:"auto",overflowX:"hidden",scrollbarGutter:"stable"},children:to.loading?(0,r.jsx)("p",{className:"text-sm text-gray-500 m-0",children:"Cargando..."}):0===to.rows.length?(0,r.jsx)("p",{className:"text-sm text-gray-500 m-0",children:"No hay datos en este periodo."}):"catalog"===to.variant?(0,r.jsx)("div",{className:"space-y-2",children:to.rows.map(e=>{var t;return(0,r.jsxs)("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1 text-sm border-b border-gray-100 pb-2",children:[(0,r.jsxs)("span",{className:"text-gray-700 flex-1 min-w-0",children:[e.rank,". ",e.name]}),(0,r.jsx)("span",{className:"text-gray-600 whitespace-nowrap shrink-0",children:null==(t=e.units)||Number.isNaN(Number(t))?"â":Number(t).toLocaleString("es-ES",{maximumFractionDigits:2})}),(0,r.jsx)("span",{className:"font-semibold text-gray-900 whitespace-nowrap shrink-0 ml-auto",children:(0,P.T4)(e.revenue)})]},"".concat(e.rank,"-").concat(e.name))})}):(0,r.jsx)("div",{className:"space-y-2",children:to.rows.map(e=>{let{detail:t,value:a}=(0,y.lN)(e,to.employeeMetric);return(0,r.jsxs)("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-1 text-sm border-b border-gray-100 pb-2",children:[(0,r.jsxs)("span",{className:"text-gray-700 shrink-0",children:[e.rank,". ",e.employeeName||"Empleado"]}),(0,r.jsx)("span",{className:"text-gray-600 text-xs flex-1 min-w-0",children:t}),(0,r.jsx)("span",{className:"font-semibold text-gray-900 whitespace-nowrap shrink-0 ml-auto",children:a})]},"".concat(e.rank,"-").concat(e.employeeId||e.employeeName))})})})]})})]})})}},99427:function(e){e.exports={dashboardContainer:"DashboardTab_dashboardContainer__2q39F",leftSection:"DashboardTab_leftSection__9i2GD",rightSection:"DashboardTab_rightSection___31UD",lineContain:"DashboardTab_lineContain__K6Ckc",detailSection:"DashboardTab_detailSection__zrQeB",commonContainerWithIMG:"DashboardTab_commonContainerWithIMG__kNgfL",commonContainerWithoutIMG:"DashboardTab_commonContainerWithoutIMG__znyhl",statsGrid:"DashboardTab_statsGrid__QohsT",pieChartContainer:"DashboardTab_pieChartContainer__7kthc",pieChart:"DashboardTab_pieChart__WagSE",skeleton:"DashboardTab_skeleton__GJZuS",headAndSelect:"DashboardTab_headAndSelect__e61Ku",dropdownContain:"DashboardTab_dropdownContain__dszl7",barchartSkeleton:"DashboardTab_barchartSkeleton__FvEe7"}}}]);
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.