PageSourceSearch

https://selyt.cl/assets/sales-page-D8E0shXp.js

js selyt.cl collected 2026-10-02 00:15:29 UTC 48,958 bytes, 11 lines download raw bytes

1import{r as k,u as U,d as We,j as e,ad as M,ae as P,w as Ue,aA as Qe,s as Y,aB as Je,aC as Le,aD as Xe,aE as Ye,aF as Te,aG as Ze,aH as Me,aI as Pe,aJ as Ae,aK as $e,aL as es,aM as ss}from"./vendor-ByXk4kz0.js";import{f as as,y as Z,e as ts,C as N,d as f,n as ne,o as ie,A as rs,T as Ee,B as C,x as ls,w as i,p as ns,D as ee,j as se,k as ae,l as te,E as xe}from"./index-BOWIUa5W.js";import{T as De,a as qe,b as q,c as I}from"./tabs-tHU2za6m.js";import{I as is}from"./input-2ZAfIJ_8.js";import{L as Ie}from"./label-Dqu46QPK.js";import{L as B,a7 as R,c as Ke,a8 as K,J as me,S as he,V,aI as Re,aA as z,H as Fe,T as He,g as pe,U as cs,q as _e,m as re,M as ze,ac as W,b as Ge}from"./icons-vendor-2uA-iZSn.js";import"./capacitor-vendor-8XoStP7I.js";import"./supabase-vendor-BZjl9asz.js";const le={customerRut:"RUT del cliente",customerPhone:"Teléfono del cliente",customerEmail:"Email del cliente",customerAddress:"Dirección del cliente",customerName:"Nombre del cliente",notes:"Notas adicionales"};function Ve({saleId:F}){const[A,n]=k.useState({}),[t,H]=k.useState(""),[r,v]=k.useState(null),[G,p]=k.useState(!1),{toast:x}=as(),{data:$,isLoading:m}=U({queryKey:[`/api/sale-update-requests/sale/${F}`],refetchInterval:5e3,enabled:!!F}),O=We({mutationFn:async d=>ts(`/api/sale-update-requests/${d.requestId}/respond`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({updatedData:d.updatedData,responseMessage:d.responseMessage})}),onSuccess:()=>{x({title:"Respuesta enviada",description:"Los datos actualizados han sido enviados al administrador para revisión."}),p(!0),n({}),H(""),v(null),Z.invalidateQueries({queryKey:[`/api/sale-update-requests/sale/${F}`]}),Z.invalidateQueries({queryKey:["/api/sale-update-requests/seller"]}),Z.invalidateQueries({queryKey:["/api/sales"]}),Z.invalidateQueries({queryKey:["/api/sale-update-requests/all"]})},onError:d=>{v("No se pudo enviar la respuesta. Intenta nuevamente."),x({title:"Error",description:"No se pudo enviar la respuesta. Intenta nuevamente.",variant:"destructive"}),console.error("Error responding to update request:",d)}}),c=$==null?void 0:$.find(d=>d.status==="pending");if(k.useEffect(()=>{if(G&&!c){const d=setTimeout(()=>p(!1),5e3);return()=>clearTimeout(d)}},[G,c]),m)return e.jsx(N,{children:e.jsx(f,{className:"flex items-center justify-center py-8",children:e.jsx(B,{className:"h-6 w-6 animate-spin"})})});if(G&&!c)return e.jsx(N,{className:"border-green-200 bg-green-50 dark:bg-green-950/20 dark:border-green-900",children:e.jsx(f,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-green-100 flex items-center justify-center flex-shrink-0",children:e.jsx(R,{className:"h-5 w-5 text-green-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-green-900 dark:text-green-100 text-sm",children:"¡Datos enviados exitosamente!"}),e.jsx("p",{className:"text-xs text-green-700 dark:text-green-300 mt-0.5",children:"El administrador revisará la información y actualizará tu venta."})]})]})})});if(!c)return null;const ce=()=>{const j=c.requestedFields.filter(E=>{var u;return!((u=A[E])!=null&&u.trim())});if(j.length>0){const E=j.map(u=>le[u]||u).join(", ");v(`Completa los campos requeridos: ${E}`),x({title:"Campos incompletos",description:"Por favor completa todos los campos solicitados.",variant:"destructive"});return}v(null),O.mutate({requestId:c.id,updatedData:A,responseMessage:t})},S=c.requestedFields;return e.jsxs(N,{className:"border-orange-200 bg-orange-50/50 dark:bg-orange-950/20 dark:border-orange-900",children:[e.jsx(ne,{children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ke,{className:"h-5 w-5 text-orange-600 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(ie,{className:"text-orange-900 dark:text-orange-100",children:"Actualización de datos solicitada"}),e.jsx(rs,{className:"text-orange-700 dark:text-orange-300",children:"El administrador necesita que actualices la siguiente información de esta venta"})]})]})}),e.jsxs(f,{className:"space-y-4",children:[c.requestMessage&&e.jsxs("div",{className:"bg-white dark:bg-slate-900 border border-orange-100 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs text-orange-600 font-medium mb-1",children:"Mensaje del administrador"}),e.jsx("p",{className:"text-sm text-slate-700 dark:text-slate-300",children:c.requestMessage})]}),e.jsx("div",{className:"space-y-3",children:S.map(d=>{var j,E;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(Ie,{htmlFor:d,className:"text-sm font-medium",children:[le[d]||d,e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d==="notes"||d==="customerAddress"?e.jsx(Ee,{id:d,value:A[d]||"",onChange:u=>{n(D=>({...D,[d]:u.target.value})),v(null)},placeholder:`Ingresa ${((j=le[d])==null?void 0:j.toLowerCase())||d}`,className:"bg-white dark:bg-slate-900","data-testid":`textarea-${d}`}):e.jsx(is,{id:d,type:d==="customerEmail"?"email":"text",value:A[d]||"",onChange:u=>{n(D=>({...D,[d]:u.target.value})),v(null)},placeholder:`Ingresa ${((E=le[d])==null?void 0:E.toLowerCase())||d}`,className:"bg-white dark:bg-slate-900","data-testid":`input-${d}`})]},d)})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(Ie,{htmlFor:"responseMessage",className:"text-sm font-medium",children:["Mensaje adicional"," ",e.jsx("span",{className:"text-slate-400 font-normal",children:"(opcional)"})]}),e.jsx(Ee,{id:"responseMessage",value:t,onChange:d=>H(d.target.value),placeholder:"Agrega un comentario si lo deseas...",rows:2,className:"bg-white dark:bg-slate-900","data-testid":"textarea-response-message"})]}),r&&e.jsxs("div",{className:"flex items-start gap-2 bg-red-50 border border-red-200 rounded-lg p-3",children:[e.jsx(K,{className:"h-4 w-4 text-red-500 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-red-700",children:r})]}),e.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-orange-100",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Solicitado el"," ",M(new Date(c.createdAt),"PPP",{locale:P})]}),e.jsx(C,{onClick:ce,disabled:O.isPending,className:"bg-orange-600 hover:bg-orange-700 text-white","data-testid":"button-submit-response",children:O.isPending?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"h-4 w-4 mr-2 animate-spin"}),"Enviando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(R,{className:"h-4 w-4 mr-2"}),"Enviar respuesta"]})})]})]})]})}const ue={nuevo:"Nuevo",contactado:"Contactado",en_proceso:"En Proceso",visita_agendada:"Visita Agendada",negociacion:"Negociación",cerrado_exitoso:"Cerrado Exitoso",cerrado_perdido:"Cerrado Perdido",descartado:"Descartado"};function bs(){var ve,we,ye,Ce,ke,Se;
1const[,F]=Ue(),A=Qe(),{isDesktop:n}=ls(),[t,H]=k.useState(null),[r,v]=k.useState(null),[G,p]=k.useState("all"),[x,$]=k.useState("hogar"),{data:m,isLoading:O}=U({queryKey:["/api/sales"]}),{data:c,isLoading:ce}=U({queryKey:["/api/immo/leads"]});k.useEffect(()=>{if(m&&A){const a=new URLSearchParams(A).get("saleId");if(a){const l=parseInt(a,10),o=m.find(h=>h.id===l);o&&(H(o),F("/sales",{replace:!0}))}}},[m,A,F]);const{data:S,isLoading:d}=U({queryKey:[`/api/sales/${t==null?void 0:t.id}/history`],enabled:!!t}),{data:j}=U({queryKey:["/api/sale-update-requests/seller"]}),E=s=>{const a=s.toLowerCase();return a==="activa"?"bg-emerald-100 text-emerald-700 border border-emerald-200":a==="instalacion"||a==="coordinacion"||a==="revision"||a==="pending"?"bg-amber-100 text-amber-700 border border-amber-200":a==="objecion"||a==="cancelada"||a==="descomisionado"||a.includes("cancelled")?"bg-rose-100 text-rose-700 border border-rose-200":a.includes("completed")?"bg-emerald-100 text-emerald-700 border border-emerald-200":"bg-slate-100 text-slate-600 border border-slate-200"},u=s=>({pending:"Pendiente",completed:"Completada",cancelled:"Cancelada",processing:"En proceso",approved:"Aprobada",rejected:"Rechazada"})[s.toLowerCase()]||s,D=s=>{if(!m)return[];if(s==="all")return m;const a=["activa","instalacion"],l=["objecion","cancelada","descomisionado","cancelled"];return s==="activas"?m.filter(o=>a.some(h=>o.status.toLowerCase().includes(h))):s==="proceso"?m.filter(o=>{const h=o.status.toLowerCase(),g=a.some(y=>h.includes(y)),w=l.some(y=>h.includes(y));return!g&&!w}):s==="problema"?m.filter(o=>l.some(h=>o.status.toLowerCase().includes(h))):m},Be=(s=[])=>{if(!(s!=null&&s.length))return{total:0,count:0,activas:0,proceso:0,problema:0};const a=["activa","instalacion"],l=["objecion","cancelada","descomisionado","cancelled"];return s.reduce((o,h)=>{const g=h.status.toLowerCase(),w=a.some(T=>g.includes(T)),y=l.some(T=>g.includes(T)),L=!w&&!y;return{total:o.total+(w?h.commission:0),count:o.count+1,activas:o.activas+(w?1:0),proceso:o.proceso+(L?1:0),problema:o.problema+(y?1:0)}},{total:0,count:0,activas:0,proceso:0,problema:0})},ge=async s=>{const a=`Hola, te comparto el estado de mi venta #${s.id}.
2
3📌 Producto: ${s.product.name}
4👤 Cliente: ${s.customerName}
5✅ Estado: ${u(s.status)}
6
7Enviado desde Selyt`;if(navigator.share)try{await navigator.share({title:`Venta #${s.id} - Selyt`,text:a})}catch(l){console.error("Error sharing:",l)}else navigator.clipboard.writeText(a),alert("Copiado al portapapeles")},je=s=>{const a=`Hola, te comparto el estado de mi venta #${s.id}.
8
9📌 Producto: ${s.product.name}
10👤 Cliente: ${s.customerName}
11✅ Estado: ${u(s.status)}`;window.open(`https://wa.me/?text=${encodeURIComponent(a)}`,"_blank")},b=Be(m||[]),de=s=>{const a=s.toLowerCase();return a==="cerrado_exitoso"?"bg-emerald-100 text-emerald-700 border border-emerald-200":a==="negociacion"||a==="visita_agendada"?"bg-blue-100 text-blue-700 border border-blue-200":a==="en_proceso"||a==="contactado"||a==="nuevo"?"bg-amber-100 text-amber-700 border border-amber-200":a==="cerrado_perdido"||a==="descartado"?"bg-rose-100 text-rose-700 border border-rose-200":"bg-slate-100 text-slate-600 border border-slate-200"},Q=s=>{if(!c)return[];if(s==="all")return c;const a=["cerrado_exitoso"],l=["nuevo","contactado","en_proceso","visita_agendada","negociacion"],o=["cerrado_perdido","descartado"];return s==="activas"?c.filter(h=>a.includes(h.status||"")):s==="proceso"?c.filter(h=>l.includes(h.status||"")):s==="problema"?c.filter(h=>o.includes(h.status||"")):c},_=(()=>{if(!(c!=null&&c.length))return{count:0,activas:0,proceso:0,problema:0};const s=["cerrado_exitoso"],a=["cerrado_perdido","descartado"];return c.reduce((l,o)=>{const h=o.status||"",g=s.includes(h),w=a.includes(h),y=!g&&!w;return{count:l.count+1,activas:l.activas+(g?1:0),proceso:l.proceso+(y?1:0),problema:l.problema+(w?1:0)}},{count:0,activas:0,proceso:0,problema:0})})(),oe=s=>(j==null?void 0:j.some(a=>a.saleId===s&&a.status==="pending"))||!1,J=s=>ce?e.jsx("div",{className:"flex justify-center items-center p-8",children:e.jsx(B,{className:"h-8 w-8 animate-spin"})}):!s||s.length===0?e.jsx(N,{children:e.jsxs(f,{className:"p-8 text-center",children:[e.jsx(z,{className:"h-12 w-12 mx-auto text-gray-400 mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No hay gestiones inmobiliarias"}),e.jsx(C,{variant:"outline",className:"mt-4",onClick:()=>F("/immo"),children:"Ver Propiedades"})]})}):s.map(a=>{var l;return e.jsx(Y.div,{initial:{opacity:0,y:5}
11,animate:{opacity:1,y:0},whileTap:{scale:.98},children:e.jsxs("div",{className:"bg-white rounded-xl p-3 shadow-sm border border-gray-100 cursor-pointer active:bg-gray-50 transition-colors",onClick:()=>v(a),children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-gradient-to-br from-blue-500 to-indigo-600 flex items-center justify-center shrink-0",children:e.jsx(z,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-900 truncate",children:a.customerName}),e.jsx("p",{className:"text-xs text-gray-500 truncate",children:((l=a.property)==null?void 0:l.title)||`Propiedad #${a.propertyId}`}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[e.jsx("span",{className:i("inline-block px-2 py-0.5 rounded-full text-[10px] font-medium",de(a.status||"nuevo")),children:ue[a.status||"nuevo"]||a.status}),a.interestType&&e.jsx("span",{className:"text-[10px] text-gray-400",children:a.interestType==="compra"?"Compra":"Arriendo"})]})]}),e.jsx(Ge,{className:"h-4 w-4 text-gray-300 mt-1"})]}),e.jsxs("div",{className:"flex items-center justify-between mt-2 pt-2 border-t border-gray-100",children:[e.jsx("div",{className:"flex items-center gap-3 text-[10px] text-gray-400",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(W,{className:"h-3 w-3"}),a.customerPhone]})}),e.jsx("span",{className:"text-[10px] text-gray-400",children:a.createdAt&&M(new Date(a.createdAt),"dd MMM",{locale:P})})]})]})},a.id)}),X=s=>O?e.jsx("div",{className:"flex justify-center items-center p-8",children:e.jsx(B,{className:"h-8 w-8 animate-spin"})}):!s||s.length===0?e.jsx(N,{children:e.jsxs(f,{className:"p-8 text-center",children:[e.jsx(he,{className:"h-12 w-12 mx-auto text-gray-400 mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No hay ventas en este estado"})]})}):[...s].sort((l,o)=>{const h=oe(l.id),g=oe(o.id);return h&&!g?-1:!h&&g?1:0}).map(l=>{var o;return e.jsx(Y.div,{initial:{opacity:0,y:5},animate:{opacity:1,y:0},whileTap:{scale:.98},children:e.jsxs("div",{className:"bg-white rounded-xl p-3 shadow-sm border border-gray-100 cursor-pointer active:bg-gray-50 transition-colors",onClick:()=>H(l),"data-testid":`sale-${l.id}`,children:[oe(l.id)&&e.jsxs("div",{className:"mb-2 flex items-center gap-2 px-2 py-1.5 bg-orange-500 text-white rounded-lg text-xs font-medium",children:[e.jsx(Re,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Actualización requerida"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-900 truncate",children:l.customerName}),l.isFromMarketplace&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 bg-violet-100 text-violet-700 rounded text-[9px] font-semibold flex-shrink-0",children:[e.jsx(pe,{className:"h-2.5 w-2.5"}),"Tienda"]})]}),e.jsxs("p",{className:"text-xs text-gray-500 truncate mt-0.5",children:[((o=l.product.brand)==null?void 0:o.name)&&e.jsxs(e.Fragment,{children:[l.product.brand.name," · "]}),l.product.name]})]}),e.jsxs("div",{className:"text-right ml-3",children:[e.jsxs("p",{className:"text-base font-bold text-gray-900",children:["$",Math.round(l.commission).toLocaleString("es-CL")]}),e.jsx("span",{className:i("inline-block mt-1 px-2 py-0.5 rounded-full text-[10px] font-medium",E(l.status)),children:u(l.status)})]})]}),e.jsxs("div",{className:"flex items-center justify-between mt-2 pt-2 border-t border-gray-100",children:[e.jsx("span",{className:"text-[10px] text-gray-400",children:M(new Date(l.date),"dd MMM yyyy",{locale:P})}),e.jsxs("span",{className:"flex items-center gap-1 text-blue-500",children:[e.jsx("span",{className:"text-[10px] font-medium",children:"Ver avance"}),e.jsx(Ge,{className:"h-3.5 w-3.5"})]})]})]})},l.id)}),Oe=n?e.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[e.jsx(N,{className:"bg-gradient-to-br from-blue-500 to-blue-600 border-0 shadow-lg cursor-pointer hover:shadow-xl transition-shadow",onClick:()=>p("all"),children:e.jsx(f,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-blue-100 font-medium",children:"Ganancias Totales"}),e.jsxs("p",{className:"text-2xl font-bold text-white mt-1",children:["$",Math.round(b.total).toLocaleStr
11ing("es-CL")]})]}),e.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/20 flex items-center justify-center",children:e.jsx(me,{className:"h-5 w-5 text-white"})})]})})}),e.jsx(N,{className:"bg-gradient-to-br from-indigo-500 to-indigo-600 border-0 shadow-lg cursor-pointer hover:shadow-xl transition-shadow",onClick:()=>p("all"),children:e.jsx(f,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-indigo-100 font-medium",children:"Total Ventas"}),e.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:b.count})]}),e.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/20 flex items-center justify-center",children:e.jsx(he,{className:"h-5 w-5 text-white"})})]})})}),e.jsx(N,{className:"bg-gradient-to-br from-emerald-500 to-emerald-600 border-0 shadow-lg cursor-pointer hover:shadow-xl transition-shadow",onClick:()=>p("activas"),children:e.jsx(f,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-emerald-100 font-medium",children:"Activas"}),e.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:b.activas})]}),e.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/20 flex items-center justify-center",children:e.jsx(R,{className:"h-5 w-5 text-white"})})]})})}),e.jsx(N,{className:"bg-gradient-to-br from-amber-500 to-amber-600 border-0 shadow-lg cursor-pointer hover:shadow-xl transition-shadow",onClick:()=>p("proceso"),children:e.jsx(f,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-amber-100 font-medium",children:"En Proceso"}),e.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:b.proceso})]}),e.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/20 flex items-center justify-center",children:e.jsx(V,{className:"h-5 w-5 text-white"})})]})})})]}):null,be=j&&j.some(s=>s.status==="pending")&&e.jsx(Y.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},className:"bg-gradient-to-r from-orange-500 to-orange-600 text-white rounded-xl shadow-lg overflow-hidden",children:e.jsxs("div",{className:"p-4 flex items-center gap-4",children:[e.jsx("div",{className:"flex-shrink-0 w-12 h-12 bg-white/20 rounded-xl flex items-center justify-center",children:e.jsx(Re,{className:"h-6 w-6"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-base",children:j.filter(s=>s.status==="pending").length===1?"¡Tienes 1 venta que necesita actualización!":`¡Tienes ${j.filter(s=>s.status==="pending").length} ventas que necesitan actualización!`}),e.jsx("p",{className:"text-sm text-orange-100",children:"Haz clic en las ventas marcadas para completar los datos solicitados"})]}),e.jsx(Ke,{className:"h-6 w-6 flex-shrink-0 animate-pulse"})]})}),Ne=e.jsxs(De,{value:G,onValueChange:p,className:"w-full","data-tour":"sales-list",children:[e.jsxs(qe,{className:i("mb-3",n?"inline-flex h-11 bg-slate-100 rounded-xl p-1":"grid w-full grid-cols-4 h-10 p-1 bg-gray-100 rounded-xl gap-1"),"data-tour":"sales-filters",children:[e.jsxs(q,{value:"all","data-testid":"tab-all",className:i(n?"data-[state=active]:bg-white data-[state=active]:shadow-sm rounded-lg px-4":"text-xs font-medium data-[state=active]:bg-white data-[state=active]:shadow-sm rounded-lg"),children:[n&&e.jsx(he,{className:"h-4 w-4 mr-2"}),e.jsx("span",{children:"Todas"}),n&&e.jsx("span",{className:"ml-2 px-1.5 py-0.5 bg-slate-200 rounded text-sm font-bold",children:(m==null?void 0:m.length)||0})]}),e.jsxs(q,{value:"activas","data-testid":"tab-activas",className:i(n?"data-[state=active]:bg-white data-[state=active]:shadow-sm rounded-lg px-4":"text-xs font-medium data-[state=active]:bg-white data-[state=active]:shadow-sm rounded-lg"),children:[n&&e.jsx(R,{className:"h-4 w-4 mr-2"}),e.jsx("span",{children:"Activas"}),n&&e.jsx("span",{className:"ml-2 px-1.5 py-0.5 bg-emerald-100 text-emerald-700 rounded text-sm font-bold",children:b.activas})]}),e.jsxs(q,{value:"proceso","data-testid":"tab-proceso",className:i(n?"data-[state=active]:bg-white data-[state=active]:shadow-sm rounded-lg px-4":"text-xs font-medium data-[state=active]:bg-white data-[state=active]:shadow-sm rounded-lg"),children:[n&&e.jsx(V,{className:"h-4 w-4 mr-2"}),e.jsx("span",{children:"Proceso"}),n&&e.jsx("span",{className:"ml-2 px-1.5 py-0.5 bg-amber-100 text-amber-700 rounded text-sm font-bold",children:b.proceso})]}),e.jsxs(q,{value:"problema","data-testid":"tab-problema",className:i(n?"data-[state=active]:bg-white data-[state=active]:shadow-sm rounded-lg px-4":"text-xs font-medium data-[state=active]:bg-white data-[state=active]:shadow-sm rounded-lg"),children:[n&&e.jsx(K,{className:"h-4 w-4 mr-2"}),e.jsx("span",{children:"Problema"}),n&&e.jsx("span",{className:"ml-2 px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded text-sm font-bold",children:b.problema})]})]}),e.jsx(I,{value:"all",className:i(n?"grid grid-cols-2 xl:grid-cols-3 gap-4":"space-y-2"),children:X(D("all"))}),e.jsx(I,{value:"activas",className:i(n?"grid grid-cols-2 xl:grid-cols-3 gap-4":"space-y-2"),children:X(D("activas"))}),e.jsx(I,{value:"proceso",className:i(n?"grid grid-cols-2 xl:grid-cols-3 gap-4":"space-y-2"),children:X(D("proceso"))}),e.jsx(I,{value:"problema",className:i(n?"grid grid-cols-2 xl:grid-cols-3 gap-4":"space-y-2"),children:X(D("problema"))})]}),fe=e.jsxs(De,{value:G,onValueChange:p,className:"w-full",children:[e.jsxs(qe,{className:i("mb-3",n?"inline-flex h-11 bg-slate-100 rounded-xl p-1":"grid w-full grid-cols-4 h-10 p-1 bg-gray-100 rounded-xl gap-1"),children:[e.jsxs(q,{value:"all",className:i(n?"data-[state=active]:bg-white data-[state=active]:shadow-sm rounded-lg px-4":"text-xs font-medium data-[state=active]:bg-white data-[state=active]:shadow-sm rounded-lg"),children:[n&&e.jsx(z,{className:"h-4 w-4 mr-2"}),e.jsx("span",{children:"Todas"}),n&&e.jsx("span",{className:"ml-2 px-1.5 py-0.5 bg-slate-200 rounded text-sm font-bold",children:(c==null?void 0:c.length)||0})]}),e.jsxs(q,{value:"activas",className:i(n?"data-[state=active]:bg-white data-[state=active]:shadow-sm rounded-lg px-4":"text-xs font-medium data-[state=active]:bg-white data-[state=active]:shadow-sm rounded-lg"),children:[n&&e.jsx(R,{className:"h-4 w-4 mr-2"}),e.jsx("span",{children:"Cerradas"}),n&&e.jsx("span",{className:"ml-2 px-1.5 py-0.5 bg-emerald-100 text-emerald-700 rounded text-sm font-bold",children:_.activas})]}),e.jsxs(q,{value:"proceso",className:i(n?"data-[state=active]:bg-white data-[state=active]:shadow-sm rounded-lg px-4":"text-xs font-medium data-[state=active]:bg-white data-[state=active]:shadow-sm rounded-lg"),children:[n&&e.jsx(V,{className:"h-4 w-4 mr-2"}),e.jsx("span",{children:"Gestión"}),n&&e.jsx("span",{className:"ml-2 px-1.5 py-0.5 bg-amber-100 text-amber-700 rounded text-sm font-bold",children:_.proceso})]}),e.jsxs(q,{value:"problema",className:i(n?"data-[state=active]:bg-white data-[state=active]:shadow-sm rounded-lg px-4":"text-xs font-medium data-[state=active]:bg-white data-[state=active]:shadow-sm rounded-lg"),children:[n&&e.jsx(K,{className:"h-4 w-4 mr-2"}),e.jsx("span",{children:"Perdidas"}),n&&e.jsx("span",{className:"ml-2 px-1.5 py-0.5 bg-rose-100 text-rose-700 rounded text-sm font-bold",children:_.problema})]})]}),e.jsx(I,{value:"all",className:i(n?"grid grid-cols-2 xl:grid-cols-3 gap-4":"space-y-2"),children:J(Q("all"))}),e.jsx(I,{value:"activas",className:i(n?"grid grid-cols-2 xl:grid-cols-3 gap-4":"space-y-2"),children:J(Q("activas"))}),e.jsx(I,{value:"proceso",className:i(n?"grid grid-cols-2 xl:grid-cols-3 gap-4":"space-y-2"),children:J(Q("proceso"))}),e.jsx(I,{value:"problema",className:i(n?"grid grid-cols-2 xl:grid-cols-3 gap-4":"space-y-2"),children:J(Q("problema"))})]});return n?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex bg-gray-100 rounded-xl p-1",children:[e.jsxs("button",{onClick:()=>{$("hogar"),p("all")},className:i("flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-all",x==="hogar"?"bg-white text-blue-600 shadow-sm":"text-gray-500 hover:text-gray-700"),children:[e.jsx(Fe,{className:"h-4 w-4"}),"Hogar",e.jsx("span",{className:i("text-xs px-2 py-0.5 rounded-full",x==="hogar"?"bg-blue-100 text-blue-600":"bg-gray-200 text-gray-500"),children:(m==null?void 0:m.length)||0})]}),e.jsxs("button",{onClick:()=>{$("inmobiliario"),p("all")},className:i("flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-all",x==="inmobiliario"?"bg-white text-indigo-600 shadow-sm":"text-gray-500 hover:text-gray-700"),children:[e.jsx(z,{className:"h-4 w-4"}),"Inmobiliario",e.jsx("span",{className:i("text-xs px-2 py-0.5 rounded-full",x==="inmobiliario"?"bg-indigo-100 text-indigo-600":"bg-gray-200 text-gray-500"),children:(c==null?void 0:c.length)||0})]})]}),e.jsxs(ns,{variant:"outline",className:i("h-8 px-3",x==="hogar"?"bg-emerald-50 text-emerald-700 border-emerald-200":"bg-indigo-50 text-indigo-700 border-indigo-200"),children:[e.jsx(He,{className:"h-3.5 w-3.5 mr-1.5"}),x==="hogar"?`${b.activas} activas`:`${_.activas} cerradas`]})]}),x==="hogar"&&Oe,x==="hogar"&&m&&m.length>0&&(()=>{const s=new Date,a=[];for(let l=7;l>=0;l--){const o=Je(Le(s,l),{weekStartsOn:1}
11),h=Xe(Le(s,l),{weekStartsOn:1}),g=m.filter(L=>{const T=new Date(L.createdAt);return Ye(T,{start:o,end:h})}),w=g.filter(L=>L.status==="activa"||L.status==="active").length,y=g.reduce((L,T)=>T.status==="activa"||T.status==="active"?L+(T.sellerCommission||0):L,0);a.push({name:`S${8-l}`,ventas:g.length,activas:w,ganancias:y})}return e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(N,{className:"border-slate-200 shadow-sm",children:[e.jsx(ne,{className:"pb-2",children:e.jsxs(ie,{className:"text-sm font-semibold text-slate-700 flex items-center gap-2",children:[e.jsx(He,{className:"h-4 w-4 text-emerald-500"}),"Ventas por Semana"]})}),e.jsxs(f,{className:"pt-0",children:[e.jsx("div",{className:"h-40",children:e.jsx(Te,{width:"100%",height:"100%",children:e.jsxs(Ze,{data:a,margin:{top:10,right:10,left:0,bottom:0},children:[e.jsx(Me,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fontSize:11,fill:"#9ca3af"}}),e.jsx(Pe,{axisLine:!1,tickLine:!1,tick:{fontSize:11,fill:"#9ca3af"},width:30}),e.jsx(Ae,{contentStyle:{backgroundColor:"white",border:"1px solid #e5e7eb",borderRadius:"12px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)"},formatter:(l,o)=>[l,o==="ventas"?"Total":"Activas"]}),e.jsx($e,{dataKey:"ventas",fill:"#3b82f6",radius:[4,4,0,0]}),e.jsx($e,{dataKey:"activas",fill:"#10b981",radius:[4,4,0,0]})]})})}),e.jsxs("div",{className:"flex items-center justify-center gap-6 mt-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full bg-blue-500"}),e.jsx("span",{className:"text-xs text-gray-600",children:"Total"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full bg-emerald-500"}),e.jsx("span",{className:"text-xs text-gray-600",children:"Activas"})]})]})]})]}),e.jsxs(N,{className:"border-slate-200 shadow-sm",children:[e.jsx(ne,{className:"pb-2",children:e.jsxs(ie,{className:"text-sm font-semibold text-slate-700 flex items-center gap-2",children:[e.jsx(me,{className:"h-4 w-4 text-blue-500"}),"Ganancias por Semana"]})}),e.jsxs(f,{className:"pt-0",children:[e.jsx("div",{className:"h-40",children:e.jsx(Te,{width:"100%",height:"100%",children:e.jsxs(es,{data:a,margin:{top:10,right:10,left:0,bottom:0},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"colorGananciasVentas",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#10b981",stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:"#10b981",stopOpacity:0})]})}),e.jsx(Me,{dataKey:"name",axisLine:!1,tickLine:!1,tick:{fontSize:11,fill:"#9ca3af"}}),e.jsx(Pe,{axisLine:!1,tickLine:!1,tick:{fontSize:11,fill:"#9ca3af"},tickFormatter:l=>l>0?`$${(l/1e3).toFixed(0)}k`:"0",width:45}),e.jsx(Ae,{contentStyle:{backgroundColor:"white",border:"1px solid #e5e7eb",borderRadius:"12px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)"},formatter:l=>[`$${l.toLocaleString("es-CL")}`,"Ganancias"]}),e.jsx(ss,{type:"monotone",dataKey:"ganancias",stroke:"#10b981",strokeWidth:2,fillOpacity:1,fill:"url(#colorGananciasVentas)"})]})})}),e.jsx("div",{className:"flex items-center justify-center gap-6 mt-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full bg-emerald-500"}),e.jsx("span",{className:"text-xs text-gray-600",children:"Ganancias Semanales"})]})})]})]})]})})(),x==="hogar"&&be,e.jsxs(N,{className:"border-slate-200 shadow-sm",children:[e.jsx(ne,{className:"pb-3",children:e.jsx(ie,{className:"text-lg font-semibold text-slate-900",children:x==="hogar"?"Historial de Ventas":"Gestiones Inmobiliarias"})}),e.jsx(f,{children:x==="hogar"?Ne:fe})]}),e.jsx(ee,{open:!!t,onOpenChange:()=>H(null),children:e.jsxs(se,{className:"sm:max-w-md p-0 overflow-hidden border-0 rounded-3xl",children:[e.jsx(ae,{className:"sr-only",children:e.jsx(te,{children:"Detalle de Venta"})}),t&&e.jsxs("div",{className:"p-6 pt-10 space-y-5",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:i("w-16 h-16 rounded-full mx-auto flex items-center justify-center ring-4",t.status.toLowerCase()==="activa"?"bg-emerald-500 ring-emerald-200":t.status.toLowerCase().includes("objecion")||t.status.toLowerCase().includes("cancelada")||t.status.toLowerCase().includes("cancelled")?"bg-rose-500 ring-rose-200":"bg-amber-500 ring-amber-200"),children:t.status.toLowerCase()==="activa"?e.jsx(R,{className:"h-7 w-7 text-white"}):t.status.toLowerCase().includes("objecion")||t.status.toLowerCase()==="cancelada"||t.status.toLowerCase().includes("cancelled")?e.jsx(K,{className:"h-7 w-7 text-white"}):e.jsx(V,{className:"h-7 w-7 text-white"})}),e.jsx("p",{className:i("text-base font-semibold mt-3",t.status.toLowerCase()==="activa"?"text-emerald-700":t.status.toLowerCase().includes("objecion")||t.status.toLowerCase()==="cancelada"||t.status.toLowerCase().includes("cancelled")?"text-rose-700":"text-amber-700"),children:u(t.status)}),e.jsx("p",{className:"text-sm text-slate-500",children:"Estado actual"})]}),e.jsxs("div",{className:"bg-slate-50 rounded-xl p-3 text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsxs("p",{className:"text-sm font-semibold text-slate-900",children:[((ve=t.product.brand)==null?void 0:ve.name)&&e.jsxs(e.Fragment,{children:[t.product.brand.name," - "]}),t.product.name]}),t.isFromMarketplace&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-vi
11olet-100 text-violet-700 rounded-full text-[10px] font-semibold",children:[e.jsx(pe,{className:"h-3 w-3"}),"Tienda"]})]}),e.jsxs("p",{className:"text-xs text-slate-500 mt-1",children:["Ingresada el"," ",M(new Date(t.date),"d 'de' MMMM yyyy, HH:mm",{locale:P})]}),t.customerAddress&&e.jsx("p",{className:"text-xs text-slate-600 mt-2",children:t.customerAddress}),t.customerPhone&&e.jsxs("p",{className:"text-xs text-slate-500 mt-1",children:["Tel: ",t.customerPhone]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-center",children:[e.jsxs("div",{className:"bg-slate-50 rounded-xl p-4",children:[e.jsx(cs,{className:"h-5 w-5 text-slate-400 mx-auto"}),e.jsx("p",{className:"text-sm font-medium text-slate-900 mt-2 truncate",children:t.customerName}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Cliente"})]}),e.jsxs("div",{className:"bg-emerald-50 rounded-xl p-4",children:[e.jsx(me,{className:"h-5 w-5 text-emerald-500 mx-auto"}),e.jsxs("p",{className:"text-lg font-bold text-emerald-600 mt-1",children:["$",Math.round(t.commission).toLocaleString("es-CL")]}),e.jsx("p",{className:"text-xs text-emerald-600 mt-1",children:"Ganancia"})]})]}),e.jsx(Ve,{saleId:t.id}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(C,{variant:"outline",className:"flex-1 gap-2 rounded-xl h-12",onClick:()=>ge(t),children:[e.jsx(_e,{className:"h-4 w-4"}),"Compartir"]}),e.jsxs(C,{variant:"outline",className:"flex-1 gap-2 rounded-xl h-12 border-green-200 bg-green-50 text-green-700 hover:bg-green-100",onClick:()=>je(t),children:[e.jsx(re,{className:"h-4 w-4"}),"WhatsApp"]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700 mb-3",children:"Camino de la venta"}),d?e.jsx("div",{className:"flex items-center justify-center py-6",children:e.jsx(B,{className:"h-5 w-5 animate-spin text-slate-400"})}):S&&S.length>0?e.jsx(xe,{className:i(S.length>4?"h-[220px]":""),children:e.jsxs("div",{className:"relative pr-2",children:[e.jsx("div",{className:"absolute left-[13px] top-4 bottom-4 w-0.5 bg-slate-200"}),e.jsx("div",{className:"space-y-3",children:S.map((s,a)=>{const l=s.statusType.name.toLowerCase().includes("activa"),o=s.statusType.name.toLowerCase().includes("objecion")||s.statusType.name.toLowerCase().includes("cancelada");return e.jsxs("div",{className:"flex items-start gap-3 relative",children:[e.jsx("div",{className:i("w-7 h-7 rounded-full flex items-center justify-center flex-shrink-0 z-10",a===0?l?"bg-emerald-500":o?"bg-rose-500":"bg-amber-500":"bg-slate-300"),children:a===0?l?e.jsx(R,{className:"h-4 w-4 text-white"}):o?e.jsx(K,{className:"h-4 w-4 text-white"}):e.jsx(V,{className:"h-4 w-4 text-white"}):e.jsx("div",{className:"w-2.5 h-2.5 bg-white rounded-full"})}),e.jsxs("div",{className:"flex-1 min-w-0 pb-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:i("text-sm font-medium",a===0?l?"text-emerald-700":o?"text-rose-700":"text-amber-700":"text-slate-600"),children:s.statusType.name}),e.jsx("span",{className:"text-xs text-slate-400",children:M(new Date(s.createdAt),"d MMM, HH:mm",{locale:P})})]}),s.statusReason&&e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:s.statusReason.name}),s.notes&&e.jsxs("p",{className:"text-xs text-slate-400 mt-1 italic",children:['"',s.notes,'"']})]})]},s.id)})})]})}):e.jsx("p",{className:"text-sm text-slate-500 text-center py-4",children:"Venta recién creada"})]})]})]})}),e.jsx(ee,{open:!!r,onOpenChange:()=>v(null),children:e.jsxs(se,{className:"sm:max-w-md p-0 overflow-hidden border-0 rounded-3xl",children:[e.jsx(ae,{className:"sr-only",children:e.jsx(te,{children:"Detalle de Gestión Inmobiliaria"})}),r&&e.jsxs("div",{className:"p-6 space-y-5",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-14 h-14 rounded-xl bg-gradient-to-br from-indigo-500 to-purple-600 flex items-center justify-center",children:e.jsx(z,{className:"h-7 w-7 text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-lg font-semibold text-gray-900",children:r.customerName}),e.jsx("span",{className:i("inline-block mt-1 px-2.5 py-0.5 rounded-full text-xs font-medium",de(r.status||"nuevo")),children:ue[r.status||"nuevo"]||r.status})]})]}),e.jsxs("div",{className:"bg-slate-50 rounded-xl p-4",children:[e.jsx("p",{className:"text-xs text-slate-500 font-medium mb-1",children:"Propiedad de interés"}),e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:((we=r.property)==null?void 0:we.title)||`Propiedad #${r.propertyId}`}),((ye=r.property)==null?void 0:ye.commune)&&e.jsxs("p",{className:"text-xs text-slate-500 mt-1 flex items-center gap-1",children:[e.jsx(ze,{className:"h-3 w-3"}),r.property.commune,","," ",r.property.region]})]}),e.jsxs("div",{className:"bg-slate-50 rounded-xl p-4",children:[e.jsx("p",{className:"text-xs text-slate-500 font-medium mb-2",children:"Datos de contacto"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm text-slate-900 flex items-center gap-2",children:[e.jsx(W,{className:"h-4 w-4 text-slate-400"}),r.customerPhone]}),r.customerEmail&&e.jsxs("p",{className:"text-sm text-slate-900 flex items-center gap-2",children:[e.jsx("span",{className:"w-4 h-4 text-slate-400 text-center text-xs",children:"@"}),r.customerEmail]}),r.customerRut&&e.jsxs("p",{className:"text-xs text-slate-500",children:["RUT: ",r.customerRut]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.interestType&&e.jsxs("div",{className:"bg-indigo-50 rounded-xl p-4 text-center",children:[e.jsx("p",{className:"text-lg font-bold text-indigo-600 capitalize",children:r.interestType}),e.jsx("p",{className:"text-xs text-indigo-500 mt-1",children:"Tipo interés"})]}),r.financingType&&e.jsxs("div",{className:"bg-purple-50 rounded-xl p-4 text-center",children:[e.jsx("p",{className:"text-sm font-bold text-purple-600 capitalize",children:r.financingType.replace("_"," ")}),e.jsx("p",{className:"text-xs text-purple-500 mt-1",children:"Financiamiento"})]})]}),r.notes&&e.jsxs("div",{className:"bg-amber-50 rounded-xl p-4",children:[e.jsx("p",{className:"text-xs text-amber-600 font-medium mb-1",children:"Notas"}),e.jsx("p",{className:"text-sm text-gray-700",children:r.notes})]}),e.jsxs("div",{className:"text-center text-xs text-slate-400 pt-2",children:["Registrado el"," ",r.createdAt&&M(new Date(r.createdAt),"d 'de' MMMM yyyy, HH:mm",{locale:P})]}),e.jsxs("div",{className:"flex gap-3 pt-2",children:[e.jsxs(C,{variant:"outline",className:"flex-1 gap-2 rounded-xl h-11",onClick:()=>window.open(`tel:${r.customerPhone}`,"_self"),children:[e.jsx(W,{className:"h-4 w-4"}),"Llamar"]}),e.jsxs(C,{variant:"outline",className:"flex-1 gap-2 rounded-xl h-11 border-green-200 bg-green-50 text-green-600 hover:bg-green-100",onClick:()=>window.open(`https://wa.me/${r.customerPhone.replace(/\D/g,"")}`,"_blank"),children:[e.jsx(re,{className:"h-4 w-4"}),"WhatsApp"]})]})]})]})})]}):e.jsxs(Y.div,{initial:{opacity:0,y:20}
11,animate:{opacity:1,y:0},transition:{duration:.3,ease:"easeOut"},className:"min-h-screen bg-gradient-to-b from-white to-gray-50 pb-20",children:[e.jsxs("div",{className:"px-4 pb-3",children:[e.jsxs("div",{className:"flex bg-gray-100 rounded-xl p-1 mb-4",children:[e.jsxs("button",{onClick:()=>{$("hogar"),p("all")},className:i("flex-1 flex items-center justify-center gap-2 py-2.5 rounded-lg text-sm font-medium transition-all",x==="hogar"?"bg-white text-blue-600 shadow-sm":"text-gray-500"),children:[e.jsx(Fe,{className:"h-4 w-4"}),"Hogar",((m==null?void 0:m.length)||0)>0&&e.jsx("span",{className:i("text-[10px] px-1.5 py-0.5 rounded-full",x==="hogar"?"bg-blue-100 text-blue-600":"bg-gray-200 text-gray-500"),children:(m==null?void 0:m.length)||0})]}),e.jsxs("button",{onClick:()=>{$("inmobiliario"),p("all")},className:i("flex-1 flex items-center justify-center gap-2 py-2.5 rounded-lg text-sm font-medium transition-all",x==="inmobiliario"?"bg-white text-indigo-600 shadow-sm":"text-gray-500"),children:[e.jsx(z,{className:"h-4 w-4"}),"Inmobiliario",((c==null?void 0:c.length)||0)>0&&e.jsx("span",{className:i("text-[10px] px-1.5 py-0.5 rounded-full",x==="inmobiliario"?"bg-indigo-100 text-indigo-600":"bg-gray-200 text-gray-500"),children:(c==null?void 0:c.length)||0})]})]}),e.jsx("div",{className:i("rounded-2xl p-4 shadow-lg",x==="hogar"?"bg-gradient-to-r from-blue-600 to-blue-500":"bg-gradient-to-r from-indigo-600 to-purple-600"),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{onClick:()=>p("all"),className:"cursor-pointer",children:[e.jsx("p",{className:"text-xs text-blue-100 font-medium",children:x==="hogar"?"Ganancias":"Gestiones"}),e.jsx("p",{className:"text-2xl font-bold text-white",children:x==="hogar"?`$${Math.round(b.total).toLocaleString("es-CL")}`:(c==null?void 0:c.length)||0})]}),e.jsxs("div",{className:"flex items-center gap-3 text-center",children:[e.jsxs("div",{onClick:()=>p("activas"),className:"bg-white/15 rounded-xl px-3 py-2 cursor-pointer active:bg-white/25 transition-colors",children:[e.jsx("p",{className:"text-lg font-bold text-white",children:x==="hogar"?b.activas:_.activas}),e.jsx("p",{className:"text-[10px] text-blue-100",children:x==="hogar"?"Activas":"Cerradas"})]}),e.jsxs("div",{onClick:()=>p("proceso"),className:"bg-white/15 rounded-xl px-3 py-2 cursor-pointer active:bg-white/25 transition-colors",children:[e.jsx("p",{className:"text-lg font-bold text-white",children:x==="hogar"?b.proceso:_.proceso}),e.jsx("p",{className:"text-[10px] text-blue-100",children:x==="hogar"?"Proceso":"Gestión"})]}),e.jsxs("div",{onClick:()=>p("problema"),className:"bg-white/15 rounded-xl px-3 py-2 cursor-pointer active:bg-white/25 transition-colors",children:[e.jsx("p",{className:"text-lg font-bold text-white",children:x==="hogar"?b.problema:_.problema}),e.jsx("p",{className:"text-[10px] text-blue-100",children:x==="hogar"?"Problema":"Perdidas"})]})]})]})})]}),e.jsxs("div",{className:"px-4 pb-4 space-y-3",children:[x==="hogar"&&be,x==="hogar"?Ne:fe]}),e.jsx(ee,{open:!!t,onOpenChange:()=>H(null),children:e.jsxs(se,{className:"max-w-sm p-0 border-0 max-h-[85vh] overflow-hidden rounded-2xl bg-white",children:[e.jsx(ae,{className:"sr-only",children:e.jsx(te,{children:"Detalle de Venta"})}),t&&e.jsx(xe,{className:"max-h-[85vh]",children:e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:i("w-10 h-10 rounded-full flex items-center justify-center",t.status.toLowerCase()==="activa"?"bg-emerald-100":t.status.toLowerCase().includes("objecion")||t.status.toLowerCase()==="cancelada"||t.status.toLowerCase().includes("cancelled")?"bg-rose-100":"bg-amber-100"),children:t.status.toLowerCase()==="activa"?e.jsx(R,{className:"h-5 w-5 text-emerald-600"}):t.status.toLowerCase().includes("objecion")||t.status.toLowerCase()==="cancelada"||t.status.toLowerCase().includes("cancelled")?e.jsx(K,{className:"h-5 w-5 text-rose-600"}):e.jsx(V,{className:"h-5 w-5 text-amber-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-gray-900",children:u(t.status)}),e.jsx("p",{className:"text-xs text-gray-500",children:M(new Date(t.date),"d MMM yyyy",{locale:P})})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-lg font-bold text-gray-900",children:["$",Math.round(t.commission).toLocaleStr
11ing("es-CL")]}),e.jsx("p",{className:"text-[10px] text-gray-500",children:"Ganancia"})]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-xl p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Producto"}),t.isFromMarketplace&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 bg-violet-100 text-violet-700 rounded text-[9px] font-semibold",children:[e.jsx(pe,{className:"h-2.5 w-2.5"}),"Tienda"]})]}),e.jsxs("p",{className:"text-sm font-medium text-gray-900 mt-0.5",children:[((Ce=t.product.brand)==null?void 0:Ce.name)&&e.jsxs(e.Fragment,{children:[t.product.brand.name," · "]}),t.product.name]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-xl p-3",children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Cliente"}),e.jsx("p",{className:"text-sm font-medium text-gray-900 mt-0.5",children:t.customerName}),t.customerAddress&&e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:t.customerAddress}),t.customerPhone&&e.jsxs("p",{className:"text-xs text-gray-500",children:["Tel: ",t.customerPhone]})]}),e.jsx(Ve,{saleId:t.id}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(C,{variant:"outline",size:"sm",className:"flex-1 gap-1.5 rounded-xl",onClick:()=>ge(t),children:[e.jsx(_e,{className:"h-3.5 w-3.5"}),"Compartir"]}),e.jsxs(C,{variant:"outline",size:"sm",className:"flex-1 gap-1.5 rounded-xl border-green-100 bg-green-50 text-green-600 hover:bg-green-100",onClick:()=>je(t),children:[e.jsx(re,{className:"h-3.5 w-3.5"}),"WhatsApp"]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-gray-900 mb-3",children:"Historial"}),d?e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(B,{className:"h-4 w-4 animate-spin text-gray-400"})}):S&&S.length>0?e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-[9px] top-3 bottom-3 w-px bg-gray-200"}),e.jsx("div",{className:"space-y-3",children:S.map((s,a)=>{const l=s.statusType.name.toLowerCase().includes("activa"),o=s.statusType.name.toLowerCase().includes("objecion")||s.statusType.name.toLowerCase().includes("cancelada");return e.jsxs("div",{className:"flex items-start gap-3 relative",children:[e.jsx("div",{className:i("w-5 h-5 rounded-full flex items-center justify-center flex-shrink-0 z-10",a===0?l?"bg-emerald-500":o?"bg-rose-500":"bg-amber-500":"bg-gray-200"),children:a===0?e.jsx("div",{className:"w-2 h-2 bg-white rounded-full"}):e.jsx("div",{className:"w-1.5 h-1.5 bg-gray-400 rounded-full"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-gray-900",children:s.statusType.name}),e.jsx("span",{className:"text-[10px] text-gray-400",children:M(new Date(s.createdAt),"d MMM, HH:mm",{locale:P})})]}),s.statusReason&&e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:s.statusReason.name}),s.notes&&e.jsxs("p",{className:"text-xs text-gray-400 mt-0.5 italic",children:['"',s.notes,'"']})]})]},s.id)})})]}):e.jsx("p",{className:"text-xs text-gray-500 text-center py-3",children:"Venta recién creada"})]})]})})]})}),e.jsx(ee,{open:!!r,onOpenChange:()=>v(null),children:e.jsxs(se,{className:"max-w-sm p-0 border-0 max-h-[85vh] overflow-hidden rounded-2xl bg-white",children:[e.jsx(ae,{className:"sr-only",children:e.jsx(te,{children:"Detalle de Gestión Inmobiliaria"})}),r&&e.jsx(xe,{className:"max-h-[85vh]",children:e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-gradient-to-br from-indigo-500 to-purple-600 flex items-center justify-center",children:e.jsx(z,{className:"h-6 w-6 text-white"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-base font-semibold text-gray-900",children:r.customerName}),e.jsx("span",{className:i("inline-block mt-1 px-2 py-0.5 rounded-full text-[10px] font-medium",de(r.status||"nuevo")),children:ue[r.status||"nuevo"]||r.status})]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-xl p-3",children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Propiedad de interés"}),e.jsx("p",{className:"text-sm font-medium text-gray-900 mt-0.5",children:((ke=r.property)==null?void 0:ke.title)||`Propiedad #${r.propertyId}`}),((Se=r.property)==null?void 0:Se.commune)&&e.jsxs("p",{className:"text-xs text-gray-500 mt-1 flex items-center gap-1",children:[e.jsx(ze,{className:"h-3 w-3"}),r.property.commune,","," ",r.property.region]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-xl p-3",children:[e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"Contacto"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"text-sm text-gray-900 flex items-center gap-2",children:[e.jsx(W,{className:"h-3.5 w-3.5 text-gray-400"}),r.customerPhone]}),r.customerEmail&&e.jsxs("p",{className:"text-sm text-gray-900 flex items-center gap-2",children:[e.jsx("span",{className:"w-3.5 h-3.5 text-gray-400 text-center",children:"@"}),r.customerEmail]}),r.customerRut&&e.jsxs("p",{className:"text-xs text-gray-500",children:["RUT: ",r.customerRut]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.interestType&&e.jsxs("div",{className:"bg-indigo-50 rounded-xl p-3 text-center",children:[e.jsx("p",{className:"text-lg font-bold text-indigo-600 capitalize",children:r.interestType}),e.jsx("p",{className:"text-[10px] text-indigo-500",children:"Tipo interés"})]}),r.financingType&&e.jsxs("div",{className:"bg-purple-50 rounded-xl p-3 text-center",children:[e.jsx("p",{className:"text-sm font-bold text-purple-600 capitalize",children:r.financingType.replace("_"," ")}),e.jsx("p",{className:"text-[10px] text-purple-500",children:"Financiamiento"})]})]}),r.notes&&e.jsxs("div",{className:"bg-amber-50 rounded-xl p-3",children:[e.jsx("p",{className:"text-xs text-amber-600 font-medium mb-1",children:"Notas"}),e.jsx("p",{className:"text-sm text-gray-700",children:r.notes})]}),e.jsxs("div",{className:"text-center text-xs text-gray-400 pt-2",children:["Registrado el"," ",r.createdAt&&M(new Date(r.createdAt),"d 'de' MMMM yyyy, HH:mm",{locale:P})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(C,{variant:"outline",size:"sm",className:"flex-1 gap-1.5 rounded-xl",onClick:()=>window.open(`tel:${r.customerPhone}`,"_self"),children:[e.jsx(W,{className:"h-3.5 w-3.5"}),"Llamar"]}),e.jsxs(C,{variant:"outline",size:"sm",className:"flex-1 gap-1.5 rounded-xl border-green-100 bg-green-50 text-green-600 hover:bg-green-100",onClick:()=>window.open(`https://wa.me/${r.customerPhone.replace(/\D/g,"")}`,"_blank"),children:[e.jsx(re,{className:"h-3.5 w-3.5"}),"WhatsApp"]})]})]})})]})})]})}export{bs 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.