1import{r as m,j as e,U as ne,l as V,b as X,x as le,at as W,t as ge,d as C,z as $,y as be,a5 as je,P as we,aL as Ne,aq as ye}from"./index-BH8Hq4fF.js";import{M as Se}from"./ManagerDialog-iFzxbOnI.js";import{i as Ce,n as ve,D as G,S as Y,s as J,a as ke}from"./salesStatus-DacX2vgZ.js";import{S as Z}from"./SuggestInput-Dw6uowgY.js";import{C as oe}from"./clipboard-paste-9hEC__C5.js";import{C as _e,L as Me}from"./CustomerContactCells-U8S6NwFE.js";import{l as ze,d as $e,c as Ae,b as Le}from"./salesContactLog-DXFJiFqW.js";import{i as Pe}from"./phone-DXeRciLF.js";import{S as ee}from"./square-check-big-BrCHknOR.js";import{S as Ee}from"./square-minus-DGiQYq3W.js";import{S as te}from"./square-CAXqjE6a.js";import"./bell-ring-Db0rTCDW.js";import"./salesAgreement-CGXfxtmS.js";import"./salesMessages-Do06lsB_.js";import"./salesQuote-Bcsvg3aD.js";import"./money-CmD9E_V-.js";const B=l=>String(l??"").trim().replace(/\s+/g," ").toLowerCase(),E=l=>String(l??"").replace(/\D/g,""),Ie=["×©× ×××§××","×©× ××§××","××עצ×","××ש קשר","× ×××","××פ××",'×××"×',"××××","××××××","ס××××ס","ס×××ס"];function De(l){const r=l.map(i=>String(i||"").trim()).join(" ");return Ie.filter(i=>r.includes(i)).length>=2}function Fe(l){const r=String(l??"");return(r.includes(" ")?r.split(" "):r.split(",")).map(f=>String(f).trim())}function Ke(l){const r=String(l??"").split(/\r?\n/),i=[];let f=0,S=0;for(const c of r){if(!c.trim())continue;const g=Fe(c);if(De(g)){S+=1;continue}const[j,x,N,o,s,d]=g;if(!String(j||"").trim()){f+=1;continue}i.push({name:String(j).trim(),moatza:String(x||"").trim(),contactName:String(N||"").trim(),phone:String(o||"").trim(),email:String(s||"").trim(),status:ve(d),statusKnown:Ce(d)})}return{rows:i,skipped:f,header:S}}function Be(l,r=[],i=[]){const{rows:f,skipped:S,header:c}=Ke(l),g=new Map((r||[]).map(s=>[B(s.name),s])),j=new Set((i||[]).filter(s=>E(s.phone)).map(s=>`${s.customer_id}|${E(s.phone)}`)),x=new Map;let N=0;for(const s of f){const d=B(s.name);if(!x.has(d)){const w=g.get(d)||null;x.set(d,{key:d,name:s.name,existing:w,pastedStatus:s.status,statusKnown:s.statusKnown,status:w?w.status:s.status,moatza:(w==null?void 0:w.moatza)||s.moatza,contacts:[],seenPhones:new Set})}const b=x.get(d);if(!b.moatza&&s.moatza&&(b.moatza=s.moatza),!b.statusKnown&&s.statusKnown&&(b.statusKnown=!0,b.pastedStatus=s.status,b.existing||(b.status=s.status)),!s.contactName&&!s.phone&&!s.email)continue;const u=E(s.phone);if(u&&(b.seenPhones.has(u)||b.existing&&j.has(`${b.existing.id}|${u}`))){N+=1;continue}u&&b.seenPhones.add(u),b.contacts.push({name:s.contactName,phone:s.phone,email:s.email})}const o=[...x.values()].map(({seenPhones:s,...d})=>({...d,statusChange:d.existing&&d.statusKnown&&d.pastedStatus!==d.existing.status?{from:d.existing.status,to:d.pastedStatus}:null}));return{plan:o,rows:f.length,skipped:S,header:c,duplicates:N,newCustomers:o.filter(s=>!s.existing).length,existingCustomers:o.filter(s=>s.existing).length,newContacts:o.reduce((s,d)=>s+d.contacts.length,0),statusChanges:o.filter(s=>s.statusChange).length,statusRead:o.filter(s=>s.statusKnown).length}}const M="w-full h-10 px-3 rounded-xl border border-slate-200 bg-white text-sm focus:outline-none focus:ring-2 focus:ring-emerald-100 focus:border-emerald-300",A="block text-xs font-medium text-slate-600 mb-1";function Re({customers:l=[],contacts:r=[],onClose:i,onSave:f,onSaveMany:S}){const[c,g]=m.useState("choose"),[j,x]=m.useState(!1),N=c==="manual"?"××ספת ××§××":c==="paste"?"××××§× ××קס×":"××ספת ××§××";return e.jsxs(Se,{onClose:i,title:N,icon:c==="paste"?oe:ne,tone:"emerald",maxWidth:c==="paste"?"max-w-3xl":"max-w-xl",align:"top",hideFooter:!0,children:[c==="choose"&&e.jsx(Ue,{onPick:g}),c==="manual"&&e.jsx(Te,{customers:l,busy:j,setBusy:x,onBack:()=>g("choose"),onSave:f}),c==="paste"&&e.jsx(He,{customers:l,contacts:r,busy:j,setBusy:x,onBack:()=>g("choose"),onSaveMany:S})]})}function Ue({onPick:l}){const r=[{key:"manual",icon:ne,title:"××× ×",desc:"××§×× ×××, ×¢× ××ש קשר ×××",tint:"bg-emerald-50 text-emerald-600"},{key:"paste",icon:oe,title:"××××§× ××קס×",desc:"רש××× ×©××× â ש××¨× ××× ××ש קשר",tint:"bg-blue-50 text-blue-600"}];return e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:r.map(i=>{const f=i.icon;return e.jsxs("button",{type:"button",onClick:()=>l(i.key),className:"text-right rounded-2xl border border-slate-200 p-4 hover:border-emerald-300 hover:bg-emerald-50/30 transition-all",children:[e.jsx("div",{className:`w-10 h-10 rounded-xl ${i.tint} flex items-center justify-center mb-2`,children:e.jsx(f,{className:"w-5 h-5"})}),e.jsx("p",{className:"text-sm font-bold text-slate-800",children:i.title}),e.jsx("p",{className:"text-xs text-slate-500 mt-0.5",children:i.desc})]},i.key)})})}function Te({customers:l,busy:r,setBusy:i,onBack:f,onSave:S}){const[c,g]=m.useState({name:"",moatza:"",contactName:"",phone:"",email:"",status:G}),j=s=>d=>g(b=>({...b,[s]:d.target.value})),x=m.useMemo(()=>l.find(s=>
1B(s.name)===B(c.name))||null,[l,c.name]),N=m.useMemo(()=>[...new Set(l.map(s=>(s.moatza||"").trim()).filter(Boolean))].sort(),[l]),o=async s=>{if(s.preventDefault(),!!c.name.trim()){i(!0);try{await S({...c,existing:x})}finally{i(!1)}}};return e.jsxs("form",{onSubmit:o,className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:A,htmlFor:"sc-name",children:"×©× ×××§××"}),e.jsx(Z,{id:"sc-name",value:c.name,options:l.map(s=>s.name),onChange:s=>g(d=>({...d,name:s})),placeholder:"×§××××¥ ×צ×××",newLabel:"××§×× ××ש",className:M}),x&&e.jsxs("p",{className:"text-xs text-emerald-700 mt-1 flex items-center gap-1",children:[e.jsx(V,{className:"w-3.5 h-3.5"}),"××§×× ×§××× â ××ש ×קשר ×ת××סף ××××, ×× ××××צר ××§×× × ×סף."]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:A,htmlFor:"sc-moatza",children:"××עצ×"}),x!=null&&x.moatza?e.jsx("input",{id:"sc-moatza",value:x.moatza,disabled:!0,className:`${M} disabled:bg-slate-50 disabled:text-slate-500`}):e.jsx(Z,{id:"sc-moatza",value:c.moatza,options:N,onChange:s=>g(d=>({...d,moatza:s})),placeholder:"××× ×שר",newLabel:"××ספת ××עצ×",className:M})]}),e.jsxs("div",{children:[e.jsx("label",{className:A,htmlFor:"sc-status",children:"ס××××ס"}),e.jsx("select",{id:"sc-status",value:x?x.status:c.status,onChange:j("status"),disabled:!!x,className:`${M} disabled:bg-slate-50 disabled:text-slate-500`,children:Y.map(s=>e.jsx("option",{value:s.key,children:s.short},s.key))})]})]}),e.jsxs("div",{className:"pt-2 border-t border-slate-100",children:[e.jsx("p",{className:"text-xs font-bold text-slate-700 mb-2",children:"××ש קשר"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:A,htmlFor:"sc-contact",children:"ש×"}),e.jsx("input",{id:"sc-contact",value:c.contactName,onChange:j("contactName"),className:M,placeholder:"×× ×"})]}),e.jsxs("div",{children:[e.jsx("label",{className:A,htmlFor:"sc-phone",children:"× ×××"}),e.jsx("input",{id:"sc-phone",value:c.phone,onChange:j("phone"),className:M,dir:"ltr",placeholder:"050-1234567"})]}),e.jsxs("div",{children:[e.jsx("label",{className:A,htmlFor:"sc-email",children:'×××"×'}),e.jsx("input",{id:"sc-email",type:"email",value:c.email,onChange:j("email"),className:M,dir:"ltr",placeholder:"[email protected]"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-3",children:[e.jsx("button",{type:"button",onClick:f,className:"h-10 px-4 rounded-full border border-slate-200 text-sm font-medium hover:bg-slate-50",children:"××ר×"}),e.jsxs("button",{type:"submit",disabled:r||!c.name.trim(),className:"inline-flex items-center gap-1.5 h-10 px-5 rounded-full bg-emerald-600 text-white text-sm font-bold hover:bg-emerald-700 disabled:opacity-50",children:[r&&e.jsx(X,{className:"w-4 h-4 animate-spin"}),x?"××סף ××ש קשר":"××סף ××§××"]})]})]})}const qe="×§××××¥ ×צ××× ××× ×שר ×× × ××× 050-1234567 [email protected] ×ת××××";function He({customers:l,contacts:r,busy:i,setBusy:f,onBack:S,onSaveMany:c}){const[g,j]=m.useState(""),[x,N]=m.useState(!1),o=m.useMemo(()=>Be(g,l,r),[g,l,r]),s=!o.plan.length,d=o.plan.length>0&&o.statusRead===0,b=async()=>{f(!0);try{await c({...o,applyStatuses:x})}finally{f(!1)}};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-600 mb-1",children:"×עת××§× ××××§×¡× ×â×××××§× ×××. ש××¨× ××× ××ש קשר, ×ס×ר ××¢××××ת:"}),e.jsx("p",{className:"text-xs font-bold text-slate-700 mb-2",children:'×©× ×××§×× Â· ×××¢×¦× Â· ××ש קשר · × ××× Â· ×××"× Â· ס××××ס'}),e.jsx("textarea",{value:g,onChange:u=>j(u.target.value),rows:7,dir:"rtl",placeholder:qe,"aria-label":"×××קת רש××ת ××§×××ת",className:"w-full rounded-xl border border-slate-200 bg-white p-3 text-sm font-mono focus:outline-none focus:ring-2 focus:ring-emerald-100 focus:border-emerald-300"}),e.jsx("p",{className:"text-[0.6875rem] text-slate-400 mt-1",children:"ש×רת ×××תר×ת, ×× ××עתק×, ת×××× ×ת××××."})]}),!s&&e.jsxs("div",{className:"rounded-xl border border-slate-200 overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap gap-4 px-4 py-3 bg-slate-50 text-sm",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(V,{className:"w-4 h-4 text-emerald-600"}),e.jsx("b",{children:o.newCustomers})," ××§×××ת ××ש××"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(le,{className:"w-4 h-4 text-blue-600"}),e.jsx("b",{children:o.newContacts})," ×× ×©× ×§×©×¨"]}),o.existingCustomers>0&&e.jsxs("span",{className:"text-slate-500",children:[o.existingCustomers," ××§×××ת ×§××××× ×תע××× ×"]})]}),e.jsx("div",{className:"max-h-56 overflow-auto divide-y divide-slate-100",children:o.plan.map(u=>e.jsxs("div",{className:"px-4 py-2 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-sm font-medium text-slate-800 truncate",children:[u.name,u.existing&&e.jsx("span",{className:"mr-2 text-[0.6875rem] font-normal text-emerald-700",children:"×§×××"})]}),e.jsxs("p",{className:"text-xs text-slate-500 truncate",children:[u.moatza||"â"," · ",u.contacts.length?u.contacts.map(w=>w.name||w.phone).join(", "):"××× ×× ×©× ×§×©×¨"]})]}),e.jsxs("span",{className:"text-[0.6875rem] text-slate-400 whitespace-nowrap",children:[u.contacts.length," ×× ×©× ×§×©×¨"]})]},u.key))}),(o.duplicates>0||o.skipped>0||d)&&e.jsxs("div",{className:"px-4 py-2 bg-amber-50 text-xs text-amber-800 space-y-0.5",children:[o.duplicates>0&&e.jsxs("p",{className:"flex items-center gap-1.5",children:[e.jsx(W,{className:"w-3.5 h-3.5"})," ",o.duplicates," ש×ר×ת ×× ×× ×©× ×§×©×¨ ש××ר ×§××××× â ××××××."]}),o.skipped>0&&e.jsxs("p",{className:"flex items-center gap-1.5",children:[e.jsx(W,{className:"w-3.5 h-3.5"})," ",o.skipped," ש×ר×ת ××× ×©× ××§×× â ×× ×××× ×¡×."]}),d&&e.jsxs("p",{className:"flex items-center gap-1.5",children:[e.jsx(W,{className:"w-3.5 h-3.5"}),'×× ×××× ×¡××××ס ×××£ ש××¨× â ×××× ×××× ×¡× ×"×ש××××§". ×××§× ×©×ס××××ס ××× ××¢×××× ×ש×ש×ת.']})]}),o.statusChanges>0&&e.jsxs("div",{className:"px-4 py-3 bg-blue-50 border-t border-blue-100 space-y-1.5",children:[e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:x,onChange:u=>N(u.target.checked),className:"mt-0.5"}),e.jsxs("span",{className:"text-xs text-blue-900",children:[e.jsxs("b",{children:["×¢××× ×× ×ת ×ס××××ס ×©× ",o.statusChanges," ××§×××ת ×§×××××"]})," ××¤× ×××××××. ××× ×¡×××× â ×ס××××ס ש××× ××ש×ר ××¤× ×©××× ××ער×ת."]})]}),e.jsxs("div",{className:"text-[0.6875rem] text-blue-800/80 max-h-20 overflow-auto pr-6",children:[o.plan.filter(u=>u.statusChange).slice(0,12).map(u=>e.jsxs("p",{children:[u.name,": ",J(u.statusChange.from)," â ",J(u.statusChange.to)]},u.key)),o.statusChanges>12&&e.jsxs("p",{children:["××¢×× ",o.statusChanges-12,"â¦"]})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-1",children:[e.jsx("button",{type:"button",onClick:S,className:"h-10 px-4 roun
1ded-full border border-slate-200 text-sm font-medium hover:bg-slate-50",children:"××ר×"}),e.jsxs("button",{type:"button",onClick:b,disabled:i||s,className:"inline-flex items-center gap-1.5 h-10 px-5 rounded-full bg-emerald-600 text-white text-sm font-bold hover:bg-emerald-700 disabled:opacity-40",children:[i&&e.jsx(X,{className:"w-4 h-4 animate-spin"}),s?"×××××§× ×¨×©×××":`××סף ${o.newCustomers} ××§×××ת ×-${o.newContacts} ×× ×©× ×§×©×¨${x?` · ${o.statusChanges} ס××××ס××`:""}`]})]})]})}const Oe=[{key:"all",label:'ס×"× ××§×××ת',desc:"×× ×רש×××",icon:le,color:"text-slate-700",bg:"bg-slate-100"},...Y.map(l=>({key:l.key,label:l.label,desc:l.desc,icon:V,color:{blue:"text-blue-600",amber:"text-amber-600",emerald:"text-emerald-600",slate:"text-slate-600"}[l.tone],bg:{blue:"bg-blue-50",amber:"bg-amber-50",emerald:"bg-emerald-50",slate:"bg-slate-100"}[l.tone]}))],L=()=>crypto.randomUUID?crypto.randomUUID():`sc_${Date.now()}_${Math.random().toString(36).slice(2)}`,se=200;async function ae(l,r){for(let i=0;i<r.length;i+=se)await C.entities[l].bulkCreate(r.slice(i,i+se))}function ct(){const l=ge(),[r,i]=m.useState([]),[f,S]=m.useState([]),[c,g]=m.useState([]),[j,x]=m.useState([]),[N,o]=m.useState([]),[s,d]=m.useState([]),[b,u]=m.useState(!0),[w,re]=m.useState(""),[I,ie]=m.useState("all"),[ce,D]=m.useState(!1),[_,R]=m.useState(()=>new Set);m.useEffect(()=>{U()},[]);async function U(){u(!0);try{const[t,a,n,p,y,h]=await Promise.all([C.entities.SalesCustomer.filterAll({},"name"),C.entities.SalesContact.filterAll({},"-is_starred"),C.entities.SalesActivity.filterAll({},"-created_date").catch(()=>[]),C.entities.SalesAgreement.filterAll({},"-created_date").catch(()=>[]),C.entities.SalesQuote.filterAll({},"-created_date").catch(()=>[]),C.entities.SalesNote.filterAll({},"-created_date").catch(()=>[])]);i(t||[]),S(a||[]),g(n||[]),x(p||[]),o(y||[]),d(h||[])}catch{$.error("ש×××× ×××¢×× ×ª ×××§×××ת")}finally{u(!1)}}const P=m.useMemo(()=>{const t=new Map;for(const a of f)a!=null&&a.customer_id&&(t.has(a.customer_id)||t.set(a.customer_id,[]),t.get(a.customer_id).push(a));for(const a of t.values())a.sort((n,p)=>(p.is_starred?1:0)-(n.is_starred?1:0));return t},[f]),T=m.useMemo(()=>{const t=new Map;for(const a of c)a!=null&&a.customer_id&&(t.has(a.customer_id)||t.set(a.customer_id,[]),t.get(a.customer_id).push(a));return t},[c]),q=m.useMemo(()=>{const t=new Map;for(const a of s)a!=null&&a.customer_id&&(t.has(a.customer_id)||t.set(a.customer_id,[]),t.get(a.customer_id).push(a));return t},[s]),H=m.useMemo(()=>ze(c),[c]),O=m.useMemo(()=>$e(s),[s]),me=m.useMemo(()=>{const t=new Map,a=new Set([...T.keys(),...q.keys()]);for(const n of a)t.set(n,Ae(T.get(n)||[],{agreements:j,quotes:N,notes:q.get(n)||[]}));return t},[T,q,j,N]),de=m.useMemo(()=>{const t={all:r.length};for(const a of Y)t[a.key]=r.filter(n=>n.status===a.key).length;return t},[r]),z=m.useMemo(()=>{const t=w.trim().toLowerCase(),a=E(w),n=r.filter(p=>{if(I!=="all"&&p.status!==I)return!1;if(!t)return!0;const y=P.get(p.id)||[];return!!(`${p.name} ${p.moatza||""}`.toLowerCase().includes(t)||y.some(h=>String(h.name||"").toLowerCase().includes(t))||a&&y.some(h=>E(h.phone).includes(a)))});return Le(n,H,O)},[r,P,w,I,H,O]),Q=m.useMemo(()=>{const t=[];for(const a of _)for(const n of P.get(a)||[])Pe(n.phone)&&t.push(n);return t},[_,P]),F=m.useMemo(()=>z.map(t=>t.id),[z]),K=F.length===0?"none":F.every(t=>_.has(t))?"all":F.some(t=>_.has(t))?"some":"none",ue=t=>R(a=>{const n=new Set(a);return n.has(t)?n.delete(t):n.add(t),n}),xe=t=>R(a=>{const n=new Set(a);return F.forEach(p=>t?n.add(p):n.delete(p)),n});function he(){if(!Q.length){$.error("×××£ ××× ××××§×××ת שס××× × ××× ××ש קשר ×¢× × ×××");return}l("/admin-messages",{state:{salesContactIds:Q.map(t=>t.id)}})}async function pe({name:t,moatza:a,contactName:n,phone:p,email:y,status:h,existing:v}){try{let k=v==null?void 0:v.id;k||(k=(await C.entities.SalesCustomer.create({id:L(),name:t.trim(),moatza:(a||"").trim()||null,status:h||G})).id,C.entities.SalesStatusEvent.create({id:L(),customer_id:k,from_status:null,to_
1status:h||G}).catch(()=>{})),(n||p||y)&&await C.entities.SalesContact.create({id:L(),customer_id:k,name:(n||"").trim()||null,phone:(p||"").trim()||null,email:(y||"").trim()||null,is_starred:!1}),$.success(v?"××ש ×קשר × ×סף ×××§××":"×××§×× × ×סף"),D(!1),U()}catch(k){$.error(/duplicate|unique/i.test(String(k==null?void 0:k.message))?"××§×× ××©× ××× ××ר ×§×××":"ש×××× ×ש××ר×")}}async function fe(t){try{const a=[],n=new Map;for(const h of t.plan){if(h.existing){n.set(h.key,h.existing.id);continue}const v=L();n.set(h.key,v),a.push({id:v,name:h.name,moatza:h.moatza||null,status:h.status})}await ae("SalesCustomer",a);const p=t.plan.flatMap(h=>h.contacts.map(v=>({id:L(),customer_id:n.get(h.key),name:v.name||null,phone:v.phone||null,email:v.email||null,is_starred:!1})));await ae("SalesContact",p);let y=0;if(t.applyStatuses)for(const h of t.plan)h.statusChange&&(await C.entities.SalesCustomer.update(h.existing.id,{status:h.statusChange.to,updated_date:new Date().toISOString()}),C.entities.SalesStatusEvent.create({id:L(),customer_id:h.existing.id,from_status:h.statusChange.from||null,to_status:h.statusChange.to}).catch(()=>{}),y+=1);$.success(`${a.length} ××§×××ת ×-${p.length} ×× ×©× ×§×©×¨ × ×ספ×`+(y?` · ${y} ס××××ס×× ×¢×××× ×`:"")),D(!1),U()}catch(a){$.error("ש×××× ×ש××ר×: "+((a==null?void 0:a.message)||""))}}return e.jsxs("div",{dir:"rtl",className:"p-4 sm:p-6 max-w-7xl mx-auto",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-extrabold text-slate-800 mb-5",children:"ש××××§ ×××§×××ת"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3 mb-5",children:Oe.map(t=>{const a=t.icon,n=I===t.key;return e.jsxs("button",{onClick:()=>ie(n&&t.key!=="all"?"all":t.key),"aria-pressed":n,className:`text-right bg-white rounded-2xl border p-3 transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-emerald-300 ${n?"border-emerald-300 shadow-md ring-2 ring-emerald-100":"border-slate-200 shadow-sm hover:shadow-md"}`,children:[e.jsx("div",{className:`w-8 h-8 rounded-lg ${t.bg} flex items-center justify-center mb-1.5`,children:e.jsx(a,{className:`w-4 h-4 ${t.color}`})}),e.jsx("p",{className:"text-xl font-bold text-slate-800",children:de[t.key]||0}),e.jsx("p",{className:"text-xs font-medium text-slate-700",children:t.label}),e.jsx("p",{className:"text-xs text-slate-400 line-clamp-1",children:t.desc})]},t.key)})}),e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-200 shadow-sm p-3 mb-4 flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 min-w-[220px]",children:[e.jsx(be,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400","aria-hidden":"true"}),e.jsx("input",{type:"text",value:w,onChange:t=>re(t.target.value),placeholder:"××פ×ש ××¤× ×©× ×× ××פ××â¦","aria-label":"××פ×ש ××§××",className:"w-full h-10 rounded-full border border-slate-200 bg-slate-50 pr-10 pl-4 text-sm focus:outline-none focus:ring-2 focus:ring-emerald-100 focus:border-emerald-300 focus:bg-white transition-all"})]}),_.size>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:he,className:"inline-flex items-center gap-1.5 h-10 px-5 rounded-full bg-blue-600 text-white text-sm font-bold hover:bg-blue-700 shadow-sm transition-all",children:[e.jsx(je,{className:"w-4 h-4"})," ש×× ××××¢× (",Q.length,")"]}),e.jsxs("button",{type:"button",onClick:()=>R(new Set),className:"h-10 px-3.5 rounded-full border border-slate-200 text-xs font-bold text-slate-600 hover:bg-slate-50",children:["× ××§×× ×ס×××× (",_.size,")"]})]}),e.jsxs("button",{type:"button",onClick:()=>D(!0),className:"inline-flex items-center gap-1.5 h-10 px-5 rounded-full bg-emerald-600 text-white text-sm font-bold hover:bg-emerald-700 shadow-sm transition-all",children:[e.jsx(we,{className:"w-4 h-4"})," ××ספת ××§××"]})]}),e.jsx("div",{className:"bg-white rounded-2xl border border-slate-200 shadow-sm overflow-hidden",children:b?e.jsx("div",{className:"flex justify-center py-14",children:e.jsx(X,{className:"w-6 h-6 text-emerald-600 animate-spin"})}):z.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center px-6",children:[e.jsx(Ne,{className:"w-8 h-8 text-slate-300 mb-3","aria-hidden":"true"}),e.jsx("p",{className:"text-sm text-slate-500",children:r.length===0?"×¢×× ×× × ××¡×¤× ××§×××ת":"××× ××§×××ת ×ת××××× ×××פ×ש"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-[0.6875rem] text-slate-400 px-4 py-2",children:[z.length," ××§×××ת",z.length!==r.length?` ×ת×× ${r.length}`:""]}),e.jsx("div",{className:"overflow-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-slate-200 bg-slate-50",children:[e.jsx("th",{className:"w-10 px-2 py-2",children:e.jsx("button",{type:"button",onClick:()=>xe(K!=="all"),"aria-label":K==="all"?"××××× ×¡×××× ×××":"ס×××× ×× ×ש×ר×ת",className:"w-6 h-6 grid place-items-center rounded hover:bg-slate-200/60",children:K==="all"?e.jsx(ee,{className:"w-4 h-4 text-blue-600"}):K==="some"?e.jsx(Ee,{className:"w-4 h-4 text-blue-600"}):e.jsx(te,{className:"w-4 h-4 text-slate-300"})})}),[{h:"×©× ×××§××"},{h:"××עצ×"},{h:"××ש קשר"},{h:"קשר",w:"w-16"},{h:"×תקשר×ת ××ר×× ×"},{h:"ס××××ס"}].map(({h:t,w:a})=>e.jsx("th",{className:`text-right font-medium text-slate-500 px-3 py-2 whitespace-nowrap ${a||""}`,children:t},t))]})}),e.jsx("tbody",{children:z.map(t=>{const a=P.get(t.id)||[],n=a[0],p=_.has(t.id);return e.jsxs("tr",{onClick:()=>l(`/sales/customers/${t.id}`),className:`border-b border-slate-100 last:border-0 cursor-pointer ${p?"bg-blue-50/50":"hover:bg-emerald-50/40"}`,children:[e.jsx("td",{className:"w-10 px-2 py-2.5",onClick:y=>{y.stopPropagation(),ue(t.id)},children:e.jsx("button",{type:"button","aria-label":p?`××××× ×¡×××× ${t.name}`:`ס×××× ${t.name}`,"aria-pressed":p,className:"w-6 h-6 grid place-items-center rounded hover:bg-slate-100",children:p?e.jsx(ee,{className:"w-4 h-4 text-blue-600"}):e.jsx(te,{className:"w-4 h-4 text-slate-300"})})}),e.jsx("td",{className:"px-3 py-2.5 font-medium text-slate-800",children:t.name}),e.jsx("td",{className:"px-3 py-2.5 text-slate-600",children:t.moatza||"â"}),e.jsxs("td",{className:"px-3 py-2.5 text-slate-600",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[(n==null?void 0:n.is_starred)&&e.jsx(ye,{className:"w-3.5 h-3.5 text-amber-500 fill-amber-400","aria-label":"×××¢××£"}),(n==null?void 0:n.name)||"â"]}
1),a.length>1&&e.jsxs("span",{className:"text-[0.6875rem] text-slate-400",children:[" +",a.length-1]})]}),e.jsx("td",{className:"px-2 py-2.5 w-16",children:e.jsx(_e,{contacts:a})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsx(Me,{last:H.get(t.id),timeline:me.get(t.id)||[],reminderDue:O.has(t.id)})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${ke(t.status)}`,children:J(t.status)})})]},t.id)})})]})})]})}),ce&&e.jsx(Re,{customers:r,contacts:f,onClose:()=>D(!1),onSave:pe,onSaveMany:fe})]})}export{ct 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.